Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 175 additions & 0 deletions test/Feature/HLSLLib/fma.fp64.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
#--- source.hlsl
Comment thread
NeKon69 marked this conversation as resolved.
Outdated

StructuredBuffer<double4> A : register(t0);
StructuredBuffer<double4> B : register(t1);
StructuredBuffer<double4> C : register(t2);

RWStructuredBuffer<double> Out : register(u3);
Comment thread
NeKon69 marked this conversation as resolved.
Outdated

[numthreads(1,1,1)]
void main() {
double s = fma(A[0].x, B[0].x, C[0].x);
Comment thread
NeKon69 marked this conversation as resolved.
Outdated

double2 v2 = fma(A[1].zw, B[1].zw, C[1].zw);

double3 v3 = fma(A[1].xyz, B[1].xyz, C[1].xyz);

double4 v4 = fma(A[0], B[0], C[0]);

Comment thread
NeKon69 marked this conversation as resolved.
Outdated
double2x2 m22a = double2x2(A[2].x, A[2].y, A[2].z, A[2].w);
double2x2 m22b = double2x2(B[2].x, B[2].y, B[2].z, B[2].w);
double2x2 m22c = double2x2(C[2].x, C[2].y, C[2].z, C[2].w);
double2x2 r22 = fma(m22a, m22b, m22c);

double4x4 m44a = double4x4(A[3].x, A[3].y, A[3].z, A[3].w,
A[4].x, A[4].y, A[4].z, A[4].w,
A[5].x, A[5].y, A[5].z, A[5].w,
A[6].x, A[6].y, A[6].z, A[6].w);
double4x4 m44b = double4x4(B[3].x, B[3].y, B[3].z, B[3].w,
B[4].x, B[4].y, B[4].z, B[4].w,
B[5].x, B[5].y, B[5].z, B[5].w,
B[6].x, B[6].y, B[6].z, B[6].w);
double4x4 m44c = double4x4(C[3].x, C[3].y, C[3].z, C[3].w,
C[4].x, C[4].y, C[4].z, C[4].w,
C[5].x, C[5].y, C[5].z, C[5].w,
C[6].x, C[6].y, C[6].z, C[6].w);
Comment thread
NeKon69 marked this conversation as resolved.
Outdated
double4x4 r44 = fma(m44a, m44b, m44c);
double4 precise = fma(A[7], B[7], C[7]);
Comment thread
NeKon69 marked this conversation as resolved.
Outdated
uint idx = 0;

Out[idx++] = s;
Out[idx++] = v4.x;
Out[idx++] = v4.y;
Out[idx++] = v4.z;
Out[idx++] = v4.w;
Out[idx++] = v3.x;
Out[idx++] = v3.y;
Out[idx++] = v3.z;
Out[idx++] = v2.x;
Out[idx++] = v2.y;
Out[idx++] = r22[0][0];
Out[idx++] = r22[0][1];
Out[idx++] = r22[1][0];
Out[idx++] = r22[1][1];
Out[idx++] = r44[0][0];
Out[idx++] = r44[0][1];
Out[idx++] = r44[0][2];
Out[idx++] = r44[0][3];
Out[idx++] = r44[1][0];
Out[idx++] = r44[1][1];
Out[idx++] = r44[1][2];
Out[idx++] = r44[1][3];
Out[idx++] = r44[2][0];
Out[idx++] = r44[2][1];
Out[idx++] = r44[2][2];
Out[idx++] = r44[2][3];
Out[idx++] = r44[3][0];
Out[idx++] = r44[3][1];
Out[idx++] = r44[3][2];
Out[idx++] = r44[3][3];
Out[idx++] = precise.x;
Out[idx++] = precise.y;
Out[idx++] = precise.z;
Out[idx++] = precise.w;
}

//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: A
Format: Float64
Stride: 32
Data: [ NaN, -Inf, Inf, -0.0,
Comment thread
NeKon69 marked this conversation as resolved.
Outdated
0.25, -0.25, 10.4, -10.6,
1.5, -2.5, 0.5, -0.5,
NaN, -Inf, Inf, -0.0,
0.0, 10.0, -10.0, 10.5,
-10.5, 0.25, -0.25, 42.5,
1e+200, -1e+200, 1e-200, -1e-200,
0x1.0000000000001p+0, 0x1p+500, 0x1.8p+500, 0x1p-500 ]
- Name: B
Format: Float64
Stride: 32
Data: [ 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0,
2.0, -1.0, 4.0, 4.0,
1.0, 1.0, 1.0, 1.0,
1.0, 2.0, -1.0, 1.0,
1.0, 4.0, 4.0, 2.0,
1.0, 1.0, 1.0, 1.0,
0x1.ffffffffffffep-1, 0x1p-500, 0x1p-500, 1.0 ]
- Name: C
Format: Float64
Stride: 32
Data: [ 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.25, 0.75, -1.5, 1.5,
0.0, 0.0, 0.0, 0.0,
0.0, 0.5, 0.5, 0.0,
0.0, 0.5, -0.5, -0.5,
0.0, 0.0, 0.0, 0.0,
-1.0, 0x1p-52, -0x1p-52, 0x1p-500 ]
- Name: Out
Format: Float64
Stride: 8
FillSize: 272
- Name: Expected
Format: Float64
Stride: 8
Data: [ NaN,
NaN, -Inf, Inf, 0.0,
0.25, -0.25, 10.4,
10.4, -10.6,
3.25, 3.25, 0.5, -0.5,
NaN, -Inf, Inf, 0.0,
0.0, 20.5, 10.5, 10.5,
-10.5, 1.5, -1.5, 84.5,
1e+200, -1e+200, 1e-200, -1e-200,
-0x1p-104, 0x1.0000000000001p+0,
0x1.7ffffffffffffp+0, 0x1p-499 ]
Results:
- Result: Result
Rule: BufferExact
Actual: Out
Expected: Expected
DescriptorSets:
- Resources:
- Name: A
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: B
Kind: StructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
- Name: C
Kind: StructuredBuffer
DirectXBinding:
Register: 2
Space: 0
VulkanBinding:
Binding: 2
- Name: Out
Kind: RWStructuredBuffer
DirectXBinding:
Register: 3
Space: 0
VulkanBinding:
Binding: 3
#--- end

Comment thread
NeKon69 marked this conversation as resolved.
Outdated
# REQUIRES: Double
# RUN: split-file %s %t
# RUN: %dxc_target -Gis -HV 202x -T cs_6_5 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
Loading