Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
215 changes: 215 additions & 0 deletions test/Feature/HLSLLib/mad.32.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
#--- source.hlsl
StructuredBuffer<float4> M0 : register(t0);
StructuredBuffer<float4> A0 : register(t1);
StructuredBuffer<float4> B0 : register(t2);
StructuredBuffer<int4> M1 : register(t3);
StructuredBuffer<int4> A1 : register(t4);
StructuredBuffer<int4> B1 : register(t5);
StructuredBuffer<uint4> M2 : register(t6);
StructuredBuffer<uint4> A2 : register(t7);
StructuredBuffer<uint4> B2 : register(t8);

RWStructuredBuffer<float4> Out0 : register(u9);
RWStructuredBuffer<int4> Out1 : register(u10);
RWStructuredBuffer<uint4> Out2 : register(u11);


[numthreads(1,1,1)]
void main() {
// float
Out0[0] = mad(M0[0], A0[0], B0[0]);
Out0[1] = float4(mad(M0[1].xyz, A0[1].xyz, B0[1].xyz), mad(M0[1].w, A0[1].w, B0[1].w));
Out0[2] = float4(mad(M0[2].xy, A0[2].xy, B0[2].xy), mad(M0[2].zw, A0[2].zw, B0[2].zw));
Out0[3] = mad(float4(1.0, 1.5, 1e+38, -1e+38), float4(1.0, 10, 4, 4), float4(1.0, -5.5, 0, 0));

// int
Out1[0] = mad(M1[0], A1[0], B1[0]);
Out1[1] = int4(mad(M1[1].xyz, A1[1].xyz, B1[1].xyz), mad(M1[1].w, A1[1].w, B1[1].w));
Out1[2] = int4(mad(M1[2].xy, A1[2].xy, B1[2].xy), mad(M1[2].zw, A1[2].zw, B1[2].zw));
Out1[3] = mad(int4(-2147483647, -256, 2147483647, -2147483648), int4(1, -256, 1, 1), int4(0, 0, 1, -1));

// uint
Out2[0] = mad(M2[0], A2[0], B2[0]);
Out2[1] = uint4(mad(M2[1].xyz, A2[1].xyz, B2[1].xyz), mad(M2[1].w, A2[1].w, B2[1].w));
Out2[2] = uint4(mad(M2[2].xy, A2[2].xy, B2[2].xy), mad(M2[2].zw, A2[2].zw, B2[2].zw));
Out2[3] = mad(uint4(2, 16, 65536, 4294967295), uint4(2, 16, 65536, 1), uint4(1, 15, 1, 1));
}
//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: M0
Format: Float32
Stride: 16
Data: [ NaN, -Inf, -0x1.e7d42cp-127, -0, 0, 0x1.e7d42cp-127, Inf, 1.0, -1.0, 0, 1, 1.5 ]
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, 1.0, -1.0, 0, 1, 1.5
- Name: A0
Format: Float32
Stride: 16
Data: [ NaN, -Inf, -0x1.e7d42cp-127, -0, 0, 0x1.e7d42cp-127, Inf, 1.0, -1.0, 0, 1, 10 ]
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, 1.0, -1.0, 0, 1, 10
- Name: B0
Format: Float32
Stride: 16
Data: [ NaN, -Inf, -0x1.e7d42cp-127, -0, 0, 0x1.e7d42cp-127, Inf, 1.0, -1.0, 1, 0, -5.5 ]
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, 1.0, -1.0, 1, 0, -5.5
- Name: M1
Format: Int32
Stride: 16
Data: [ -2147483647, -256, -1, 0, 1, 2, 16, 2147483647, 1, -1, 1, 10 ]
- Name: A1
Format: Int32
Stride: 16
Data: [ 1, -256, -1, 0, 1, 3, 16, 0, 1, -1, 10, 100 ]
- Name: B1
Format: Int32
Stride: 16
Data: [ 0, 0, 0, 0, 1, 3, 1, 255, 2147483646, -2147483647, -10, -2000 ]
- Name: M2
Format: UInt32
Stride: 16
Data: [ 0, 1, 2, 16, 2147483647, 0, 10, 0, 100, 1000, 65536, 4294967295 ]
- Name: A2
Format: UInt32
Stride: 16
Data: [ 0, 1, 2, 16, 1, 0, 10, 1, 2, 5, 65536, 1 ]
- Name: B2
Format: UInt32
Stride: 16
Data: [ 0, 0, 1, 15, 0, 10, 10, 1, 50, 100, 1, 1 ]
- Name: Out0
Format: Float32
Stride: 16
ZeroInitSize: 64
- Name: ExpectedOut0
Format: Float32
Stride: 16
Data: [ NaN, NaN, 0, 0, 0, 0, Inf, 2, 0, 1, 1, 9.5, 2, 9.5, Inf, -Inf ]
- Name: Out1
Format: Int32
Stride: 16
ZeroInitSize: 64
- Name: ExpectedOut1
Format: Int32
Stride: 16
Data: [ -2147483647, 65536, 1, 0, 2, 9, 257, 255, 2147483647, -2147483646, 0, -1000, -2147483647, 65536, -2147483648, 2147483647 ]
- Name: Out2
Format: UInt32
Stride: 16
ZeroInitSize: 64
- Name: ExpectedOut2
Format: UInt32
Stride: 16
Data: [ 0, 1, 5, 271, 2147483647, 10, 110, 1, 250, 5100, 1, 0, 5, 271, 1, 0 ]
Results:
- Result: Test0
Rule: BufferFloatULP
ULPT: 1
Actual: Out0
Expected: ExpectedOut0
- Result: Test1
Rule: BufferExact
Actual: Out1
Expected: ExpectedOut1
- Result: Test2
Rule: BufferExact
Actual: Out2
Expected: ExpectedOut2
DescriptorSets:
- Resources:
- Name: M0
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: A0
Kind: StructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
- Name: B0
Kind: StructuredBuffer
DirectXBinding:
Register: 2
Space: 0
VulkanBinding:
Binding: 2
- Name: M1
Kind: StructuredBuffer
DirectXBinding:
Register: 3
Space: 0
VulkanBinding:
Binding: 3
- Name: A1
Kind: StructuredBuffer
DirectXBinding:
Register: 4
Space: 0
VulkanBinding:
Binding: 4
- Name: B1
Kind: StructuredBuffer
DirectXBinding:
Register: 5
Space: 0
VulkanBinding:
Binding: 5
- Name: M2
Kind: StructuredBuffer
DirectXBinding:
Register: 6
Space: 0
VulkanBinding:
Binding: 6
- Name: A2
Kind: StructuredBuffer
DirectXBinding:
Register: 7
Space: 0
VulkanBinding:
Binding: 7
- Name: B2
Kind: StructuredBuffer
DirectXBinding:
Register: 8
Space: 0
VulkanBinding:
Binding: 8
- Name: Out0
Kind: RWStructuredBuffer
DirectXBinding:
Register: 9
Space: 0
VulkanBinding:
Binding: 9
- Name: Out1
Kind: RWStructuredBuffer
DirectXBinding:
Register: 10
Space: 0
VulkanBinding:
Binding: 10
- Name: Out2
Kind: RWStructuredBuffer
DirectXBinding:
Register: 11
Space: 0
VulkanBinding:
Binding: 11
#--- end

# https://github.com/llvm/llvm-project/issues/140095
# UNSUPPORTED: Clang-Vulkan

# 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
90 changes: 90 additions & 0 deletions test/Feature/HLSLLib/mad.fp16.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#--- source.hlsl
StructuredBuffer<half4> M : register(t0);
StructuredBuffer<half4> A : register(t1);
StructuredBuffer<half4> B : register(t2);

RWStructuredBuffer<half4> Out : register(u3);


[numthreads(1,1,1)]
void main() {
Out[0] = mad(M[0], A[0], B[0]);
Out[1] = half4(mad(M[1].xyz, A[1].xyz, B[1].xyz), mad(M[1].w, A[1].w, B[1].w));
Out[2] = half4(mad(M[2].xy, A[2].xy, B[2].xy), mad(M[2].zw, A[2].zw, B[2].zw));
Out[3] = mad(half4(1, 1.5, 300, -300), half4(1, 10, 300, 300), half4(1, -5.5, 1, -1));
}
//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: M
Format: Float16
Stride: 8
Data: [ 0x7e00, 0xfc00, 0x03FF, 0x8000, 0x0000, 0x7c00, 0x3c00, 0xbc00, 0x0000, 0x3c00, 0x3e00, 0xc300 ]
# NaN, -Inf, denorm, -0, 0, Inf, 1, -1, 0, 1, 1.5, -3.5
- Name: A
Format: Float16
Stride: 8
Data: [ 0x7e00, 0xfc00, 0x3c00, 0x8000, 0x0000, 0x7c00, 0x3c00, 0xbc00, 0x0000, 0x3c00, 0x4900, 0x4500 ]
# NaN, -Inf, 1, -0, 0, Inf, 1, -1, 0, 1, 10, 5
- Name: B
Format: Float16
Stride: 8
Data: [ 0x7e00, 0xfc00, 0x03FF, 0x8000, 0x0000, 0x7c00, 0x3c00, 0xbc00, 0x3c00, 0x0000, 0xc580, 0x3c00 ]
# NaN, -Inf, denorm, -0, 0, Inf, 1, -1, 1, 0, -5.5, 1
- Name: Out
Format: Float16
Stride: 8
ZeroInitSize: 32
- Name: ExpectedOut
Format: Float16
Stride: 8
Data: [ 0x7e00, 0x7e00, 0x07FE, 0x0000, 0x0000, 0x7c00, 0x4000, 0, 0x3c00, 0x3c00, 0x48c0, 0xcc20, 0x4000, 0x48c0, 0x7c00, 0xfc00 ]
# NaN, NaN, 0.00012195110, 0, 0, Inf, 2, 0, 1, 1, 9.5, -16.5, 2, 9.5, Inf, -Inf
Results:
- Result: Test0
Rule: BufferFloatULP
ULPT: 1
Actual: Out
Expected: ExpectedOut
DescriptorSets:
- Resources:
- Name: M
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: A
Kind: StructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
- Name: B
Kind: StructuredBuffer
DirectXBinding:
Register: 2
Space: 0
VulkanBinding:
Binding: 2
- Name: Out
Kind: RWStructuredBuffer
DirectXBinding:
Register: 3
Space: 0
VulkanBinding:
Binding: 3
#--- end

# REQUIRES: Half
# RUN: split-file %s %t
# RUN: %dxc_target -enable-16bit-types -Gis -HV 202x -T cs_6_5 -Fo %t.o %t/source.hlsl

# RUN: %offloader %t/pipeline.yaml %t.o
92 changes: 92 additions & 0 deletions test/Feature/HLSLLib/mad.fp64.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#--- source.hlsl
StructuredBuffer<double4> M : register(t0);
StructuredBuffer<double4> A : register(t1);
StructuredBuffer<double4> B : register(t2);

RWStructuredBuffer<double4> Out : register(u3);


[numthreads(1,1,1)]
void main() {
Out[0] = mad(M[0], A[0], B[0]);
Out[1] = double4(mad(M[1].xyz, A[1].xyz, B[1].xyz), mad(M[1].w, A[1].w, B[1].w));
Out[2] = double4(mad(M[2].xy, A[2].xy, B[2].xy), mad(M[2].zw, A[2].zw, B[2].zw));
Out[3] = mad(double4(1.0, 1.5, 1e+308l, -1e+308l), double4(1.0, 10, 2, 2), double4(1.0, -5.5, 0, 0));
}
//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: M
Format: Float64
Stride: 32
Data: [ NaN, -Inf, 0x0.fffffffffffffp-1022, -0, 0, Inf, 1.0, -1.0, 0, 1, 1.5, -3.5 ]
# NaN, -Inf, denorm, -0, 0, Inf, 1.0, -1.0, 0, 1, 1.5, -3.5
- Name: A
Format: Float64
Stride: 32
Data: [ NaN, -Inf, 1, -0, 0, Inf, 1.0, -1.0, 0, 1, 10, 5 ]
# NaN, -Inf, 1, -0, 0, Inf, 1.0, -1.0, 0, 1, 10, 5
- Name: B
Format: Float64
Stride: 32
Data: [ NaN, -Inf, 0, -0, 0, Inf, 1.0, -1.0, 1, 0, -5.5, 1 ]
# NaN, -Inf, 0, -0, 0, Inf, 1.0, -1.0, 1, 0, -5.5, 1
- Name: Out
Format: Float64
Stride: 32
ZeroInitSize: 128
- Name: ExpectedOut
Format: Float64
Stride: 32
Data: [ NaN, NaN, 0x0.fffffffffffffp-1022, 0, 0, Inf, 2, 0, 1, 1, 9.5, -16.5, 2, 9.5, Inf, -Inf ]
Results:
- Result: Test0
Rule: BufferFloatULP
ULPT: 1
Actual: Out
Expected: ExpectedOut
DescriptorSets:
- Resources:
- Name: M
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: A
Kind: StructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
- Name: B
Kind: StructuredBuffer
DirectXBinding:
Register: 2
Space: 0
VulkanBinding:
Binding: 2
- Name: Out
Kind: RWStructuredBuffer
DirectXBinding:
Register: 3
Space: 0
VulkanBinding:
Binding: 3
#--- end

# https://github.com/llvm/offload-test-suite/issues/358
# XFAIL: DirectX-WARP

# REQUIRES: Double
# RUN: split-file %s %t
# RUN: %dxc_target -HV 202x -Gis -T cs_6_5 -Fo %t.o %t/source.hlsl

# RUN: %offloader %t/pipeline.yaml %t.o
Loading
Loading