diff --git a/test/Feature/HLSLLib/min.32.test b/test/Feature/HLSLLib/min.32.test new file mode 100644 index 00000000..75fdfb39 --- /dev/null +++ b/test/Feature/HLSLLib/min.32.test @@ -0,0 +1,176 @@ +#--- source.hlsl +StructuredBuffer X0 : register(t0); +StructuredBuffer Y0 : register(t1); +StructuredBuffer X1 : register(t2); +StructuredBuffer Y1 : register(t3); +StructuredBuffer X2 : register(t4); +StructuredBuffer Y2 : register(t5); + +RWStructuredBuffer Out0 : register(u6); +RWStructuredBuffer Out1 : register(u7); +RWStructuredBuffer Out2 : register(u8); + + +[numthreads(1,1,1)] +void main() { + // float + Out0[0] = min(X0[0], Y0[0]); + Out0[1] = float4(min(X0[1].xyz, Y0[1].xyz), min(X0[1].w, Y0[1].w)); + Out0[2] = float4(min(X0[2].xy, Y0[2].xy), min(X0[2].zw, Y0[2].zw)); + Out0[3] = min(half4(1.0, -1.0, 31408, -415), half4(-1.0, 1.0, 1.5, 129.5)); + + // int + Out1[0] = min(X1[0], Y1[0]); + Out1[1] = int4(min(X1[1].xyz, Y1[1].xyz), min(X1[1].w, Y1[1].w)); + Out1[2] = int4(min(X1[2].xy, Y1[2].xy), min(X1[2].zw, Y1[2].zw)); + Out1[3] = min(X1[3], Y1[3]); + Out1[3] = min(int4(-2147483648, -10, 10, 2147483647), int4(0, 10, 10, 0)); + + // uint + Out2[0] = min(X2[0], Y2[0]); + Out2[1] = uint4(min(X2[1].xyz, Y2[1].xyz), min(X2[1].w, Y2[1].w)); + Out2[2] = uint4(min(X2[2].xy, Y2[2].xy), min(X2[2].zw, Y2[2].zw)); + Out2[3] = min(X2[3], Y2[3]); + Out2[3] = min(uint4(0, 0, 10, 10000), uint4(0, 256, 4, 10001)); +} +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: X0 + Format: Float32 + Stride: 16 + Data: [ 1.0, -1.0, 31408, -415, 3.14159, 42, -123.456, 0.0001, -10, 10.5, 3e+38, 0 ] + - Name: Y0 + Format: Float32 + Stride: 16 + Data: [ -1.0, 1.0, 1.5, 129.5, 2.71828, 42, -654.321, 0.0002, 10, 10.5, 0, -3e+38 ] + - Name: X1 + Format: Int32 + Stride: 16 + Data: [ -2147483648, -10, 0, 0, 10, 2147483647, 1000, 2500, 1, -1, 512, -2048 ] + - Name: Y1 + Format: Int32 + Stride: 16 + Data: [ 0, 10, -10, 10, 10, 0, 1500, 2000, -1, 1, 511, -2047 ] + - Name: X2 + Format: UInt32 + Stride: 16 + Data: [ 0, 0, 10, 10000, 2147483647, 4294967295, 1000, 2500, 1, 256, 512, 2048 ] + - Name: Y2 + Format: UInt32 + Stride: 16 + Data: [ 0, 256, 4, 10001, 0, 4294967295, 1500, 2000, 0, 200, 511, 2047 ] + - Name: Out0 + Format: Float32 + Stride: 16 + ZeroInitSize: 64 + - Name: ExpectedOut0 + Format: Float32 + Stride: 16 + Data: [ -1.0, -1.0, 1.5, -415, 2.71828, 42, -654.321, 0.0001, -10, 10.5, 0, -3e+38, -1.0, -1.0, 1.5, -415 ] + - Name: Out1 + Format: Int32 + Stride: 16 + ZeroInitSize: 64 + - Name: ExpectedOut1 + Format: Int32 + Stride: 16 + Data: [ -2147483648, -10, -10, 0, 10, 0, 1000, 2000, -1, -1, 511, -2048, -2147483648, -10, 10, 0 ] + - Name: Out2 + Format: UInt32 + Stride: 16 + ZeroInitSize: 64 + - Name: ExpectedOut2 + Format: UInt32 + Stride: 16 + Data: [ 0, 0, 4, 10000, 0, 4294967295, 1000, 2000, 0, 200, 511, 2047, 0, 0, 4, 10000 ] +Results: + - Result: Test0 + Rule: BufferFloatEpsilon + Epsilon: 0 + Actual: Out0 + Expected: ExpectedOut0 + - Result: Test1 + Rule: BufferExact + Actual: Out1 + Expected: ExpectedOut1 + - Result: Test2 + Rule: BufferExact + Actual: Out2 + Expected: ExpectedOut2 +DescriptorSets: + - Resources: + - Name: X0 + Kind: StructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Y0 + Kind: StructuredBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: X1 + Kind: StructuredBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 + - Name: Y1 + Kind: StructuredBuffer + DirectXBinding: + Register: 3 + Space: 0 + VulkanBinding: + Binding: 3 + - Name: X2 + Kind: StructuredBuffer + DirectXBinding: + Register: 4 + Space: 0 + VulkanBinding: + Binding: 4 + - Name: Y2 + Kind: StructuredBuffer + DirectXBinding: + Register: 5 + Space: 0 + VulkanBinding: + Binding: 5 + - Name: Out0 + Kind: RWStructuredBuffer + DirectXBinding: + Register: 6 + Space: 0 + VulkanBinding: + Binding: 6 + - Name: Out1 + Kind: RWStructuredBuffer + DirectXBinding: + Register: 7 + Space: 0 + VulkanBinding: + Binding: 7 + - Name: Out2 + Kind: RWStructuredBuffer + DirectXBinding: + Register: 8 + Space: 0 + VulkanBinding: + Binding: 8 +#--- end + + +# RUN: split-file %s %t +# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o diff --git a/test/Feature/HLSLLib/min.fp16.test b/test/Feature/HLSLLib/min.fp16.test new file mode 100644 index 00000000..7197018a --- /dev/null +++ b/test/Feature/HLSLLib/min.fp16.test @@ -0,0 +1,76 @@ +#--- source.hlsl +StructuredBuffer X : register(t0); +StructuredBuffer Y : register(t1); + +RWStructuredBuffer Out : register(u2); + + +[numthreads(1,1,1)] +void main() { + Out[0] = min(X[0], Y[0]); + Out[1] = half4(min(X[1].xyz, Y[1].xyz), min(X[1].w, Y[1].w)); + Out[2] = half4(min(X[2].xy, Y[2].xy), min(X[2].zw, Y[2].zw)); + Out[3] = min(half4(1.0, -1.0, 31408, -415), half4(-1.0, 1.0, 1.5, 129.5)); +} +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: X + Format: Float16 + Stride: 8 + Data: [ 0x3c00, 0xbc00, 0x77ab, 0xde7c, 0x4248, 0x5140, 0xd7b7, 0x068e, 0xc900, 0x4940, 0x7bff, 0x0000 ] + # 1.0, -1.0, 31408, -415, 3.14159, 42, -123.456, 0.0001, -10, 10.5, 65504, 0 + - Name: Y + Format: Float16 + Stride: 8 + Data: [ 0xbc00, 0x3c00, 0x3e00, 0x580c, 0x4170, 0x5140, 0xe11d, 0x0a8e, 0x4900, 0x4940, 0x0000, 0xfbff ] + # -1.0, 1.0, 1.5, 129.5, 2.71828, 42, -654.321, 0.0002, 10, 10.5, 0, -65504 + - Name: Out + Format: Float16 + Stride: 8 + ZeroInitSize: 32 + - Name: ExpectedOut + Format: Float16 + Stride: 8 + Data: [ 0xbc00, 0xbc00, 0x3e00, 0xde7c, 0x4170, 0x5140, 0xe11d, 0x068e, 0xc900, 0x4940, 0x0000, 0xfbff, 0xbc00, 0xbc00, 0x3e00, 0xde7c ] + # -1.0, -1.0, 1.5, -415, 2.71828, 42, -654.321, 0.0001, -10, 10.5, 0, -65504, -1.0, -1.0, 1.5, -415 +Results: + - Result: Test0 + Rule: BufferFloatEpsilon + Epsilon: 0 + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: X + Kind: StructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Y + Kind: StructuredBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: Out + Kind: RWStructuredBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 +#--- end + +# REQUIRES: Half +# RUN: split-file %s %t +# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o diff --git a/test/Feature/HLSLLib/min.fp64.test b/test/Feature/HLSLLib/min.fp64.test new file mode 100644 index 00000000..98f9d526 --- /dev/null +++ b/test/Feature/HLSLLib/min.fp64.test @@ -0,0 +1,73 @@ +#--- source.hlsl +StructuredBuffer X : register(t0); +StructuredBuffer Y : register(t1); + +RWStructuredBuffer Out : register(u2); + + +[numthreads(1,1,1)] +void main() { + Out[0] = min(X[0], Y[0]); + Out[1] = double4(min(X[1].xyz, Y[1].xyz), min(X[1].w, Y[1].w)); + Out[2] = double4(min(X[2].xy, Y[2].xy), min(X[2].zw, Y[2].zw)); + Out[3] = min(double4(1.0, -1.0, 31408, -415), double4(-1.0, 1.0, 1.5, 129.5)); +} +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: X + Format: Float64 + Stride: 32 + Data: [ 1.0, -1.0, 31408, -415, 3.14159, 42, -123.456, 0.0001, -10, 10.5, 1e+308, 0 ] + - Name: Y + Format: Float64 + Stride: 32 + Data: [ -1.0, 1.0, 1.5, 129.5, 2.71828, 42, -654.321, 0.0002, 10, 10.5, 0, -1e+308 ] + - Name: Out + Format: Float64 + Stride: 32 + ZeroInitSize: 128 + - Name: ExpectedOut0 + Format: Float64 + Stride: 32 + Data: [ -1.0, -1.0, 1.5, -415, 2.71828, 42, -654.321, 0.0001, -10, 10.5, 0, -1e+308, -1.0, -1.0, 1.5, -415 ] +Results: + - Result: Test0 + Rule: BufferFloatEpsilon + Epsilon: 0 + Actual: Out + Expected: ExpectedOut0 +DescriptorSets: + - Resources: + - Name: X + Kind: StructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Y + Kind: StructuredBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: Out + Kind: RWStructuredBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 +#--- end + +# REQUIRES: Double +# RUN: split-file %s %t +# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o diff --git a/test/Feature/HLSLLib/min.int16.test b/test/Feature/HLSLLib/min.int16.test new file mode 100644 index 00000000..78b4ab7a --- /dev/null +++ b/test/Feature/HLSLLib/min.int16.test @@ -0,0 +1,126 @@ +#--- source.hlsl +StructuredBuffer X0 : register(t0); +StructuredBuffer Y0 : register(t1); +StructuredBuffer X1 : register(t2); +StructuredBuffer Y1 : register(t3); + +RWStructuredBuffer Out0 : register(u4); +RWStructuredBuffer Out1 : register(u5); + + +[numthreads(1,1,1)] +void main() { + // int16_t + Out0[0] = min(X0[0], Y0[0]); + Out0[1] = int16_t4(min(X0[1].xyz, Y0[1].xyz), min(X0[1].w, Y0[1].w)); + Out0[2] = int16_t4(min(X0[2].xy, Y0[2].xy), min(X0[2].zw, Y0[2].zw)); + Out0[3] = min(int16_t4(-32768, -10, 10, 32767), int16_t4(0, 10, 15, 0)); + + // uint16_t + Out1[0] = min(X1[0], Y1[0]); + Out1[1] = uint16_t4(min(X1[1].xyz, Y1[1].xyz), min(X1[1].w, Y1[1].w)); + Out1[2] = uint16_t4(min(X1[2].xy, Y1[2].xy), min(X1[2].zw, Y1[2].zw)); + Out1[3] = min(uint16_t4(0, 0, 10, 10000), uint16_t4(0, 256, 4, 10001)); +} +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: X0 + Format: Int16 + Stride: 8 + Data: [-32768, -10, 0, 0, 10, 32767, 1000, 2500, 1, -1, 512, -2048 ] + - Name: Y0 + Format: Int16 + Stride: 8 + Data: [ 0, 10, -3114, 272, 15, 0, 1500, 2000, -1, 1, 511, -2047 ] + - Name: X1 + Format: UInt16 + Stride: 8 + Data: [ 0, 0, 10, 10000, 32767, 65535, 1000, 2500, 1, 256, 512, 2048 ] + - Name: Y1 + Format: UInt16 + Stride: 8 + Data: [ 0, 256, 4, 10001, 0, 65535, 1500, 2000, 0, 200, 511, 2047 ] + - Name: Out0 + Format: Int16 + Stride: 8 + ZeroInitSize: 32 + - Name: ExpectedOut0 + Format: Int16 + Stride: 8 + Data: [ -32768, -10, -3114, 0, 10, 0, 1000, 2000, -1, -1, 511, -2048, -32768, -10, 10, 0 ] + - Name: Out1 + Format: UInt16 + Stride: 8 + ZeroInitSize: 32 + - Name: ExpectedOut1 + Format: UInt16 + Stride: 8 + Data: [ 0, 0, 4, 10000, 0, 65535, 1000, 2000, 0, 200, 511, 2047, 0, 0, 4, 10000 ] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out0 + Expected: ExpectedOut0 + - Result: Test1 + Rule: BufferExact + Actual: Out1 + Expected: ExpectedOut1 +DescriptorSets: + - Resources: + - Name: X0 + Kind: StructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Y0 + Kind: StructuredBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: X1 + Kind: StructuredBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 + - Name: Y1 + Kind: StructuredBuffer + DirectXBinding: + Register: 3 + Space: 0 + VulkanBinding: + Binding: 3 + - Name: Out0 + Kind: RWStructuredBuffer + DirectXBinding: + Register: 4 + Space: 0 + VulkanBinding: + Binding: 4 + - Name: Out1 + Kind: RWStructuredBuffer + DirectXBinding: + Register: 5 + Space: 0 + VulkanBinding: + Binding: 5 +#--- end + +# https://github.com/microsoft/DirectXShaderCompiler/issues/7691 +# XFAIL: DXC-Vulkan + +# REQUIRES: Int16 +# RUN: split-file %s %t +# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o diff --git a/test/Feature/HLSLLib/min.int64.test b/test/Feature/HLSLLib/min.int64.test new file mode 100644 index 00000000..da78c451 --- /dev/null +++ b/test/Feature/HLSLLib/min.int64.test @@ -0,0 +1,123 @@ +#--- source.hlsl +StructuredBuffer X0 : register(t0); +StructuredBuffer Y0 : register(t1); +StructuredBuffer X1 : register(t2); +StructuredBuffer Y1 : register(t3); + +RWStructuredBuffer Out0 : register(u4); +RWStructuredBuffer Out1 : register(u5); + + +[numthreads(1,1,1)] +void main() { + // int64_t + Out0[0] = min(X0[0], Y0[0]); + Out0[1] = int64_t4(min(X0[1].xyz, Y0[1].xyz), min(X0[1].w, Y0[1].w)); + Out0[2] = int64_t4(min(X0[2].xy, Y0[2].xy), min(X0[2].zw, Y0[2].zw)); + Out0[3] = min(int64_t4(-9223372036854775808, -10, 10, 9223372036854775807), int64_t4(0, 10, 15, 0)); + + // uint64_t + Out1[0] = min(X1[0], Y1[0]); + Out1[1] = uint64_t4(min(X1[1].xyz, Y1[1].xyz), min(X1[1].w, Y1[1].w)); + Out1[2] = uint64_t4(min(X1[2].xy, Y1[2].xy), min(X1[2].zw, Y1[2].zw)); + Out1[3] = min(uint64_t4(0, 0, 10, 10000), uint64_t4(0, 256, 4, 10001)); +} +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: X0 + Format: Int64 + Stride: 32 + Data: [ -9223372036854775808, -10, 0, 0, 10, 9223372036854775807, 1000, 2500, 1, -1, 512, -2048 ] + - Name: Y0 + Format: Int64 + Stride: 32 + Data: [ 0, 10, -3114, 272, 15, 0, 1500, 2000, -1, 1, 511, -2047 ] + - Name: X1 + Format: UInt64 + Stride: 32 + Data: [ 0, 0, 10, 10000, 9223372036854775807, 18446744073709551615, 1000, 2500, 1, 256, 512, 2048 ] + - Name: Y1 + Format: UInt64 + Stride: 32 + Data: [ 0, 256, 4, 10001, 0, 18446744073709551615, 1500, 2000, 0, 200, 511, 2047 ] + - Name: Out0 + Format: Int64 + Stride: 32 + ZeroInitSize: 128 + - Name: ExpectedOut0 + Format: Int64 + Stride: 32 + Data: [ -9223372036854775808, -10, -3114, 0, 10, 0, 1000, 2000, -1, -1, 511, -2048, -9223372036854775808, -10, 10, 0 ] + - Name: Out1 + Format: UInt64 + Stride: 32 + ZeroInitSize: 128 + - Name: ExpectedOut1 + Format: UInt64 + Stride: 32 + Data: [ 0, 0, 4, 10000, 0, 18446744073709551615, 1000, 2000, 0, 200, 511, 2047, 0, 0, 4, 10000 ] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out0 + Expected: ExpectedOut0 + - Result: Test1 + Rule: BufferExact + Actual: Out1 + Expected: ExpectedOut1 +DescriptorSets: + - Resources: + - Name: X0 + Kind: StructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Y0 + Kind: StructuredBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: X1 + Kind: StructuredBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 + - Name: Y1 + Kind: StructuredBuffer + DirectXBinding: + Register: 3 + Space: 0 + VulkanBinding: + Binding: 3 + - Name: Out0 + Kind: RWStructuredBuffer + DirectXBinding: + Register: 4 + Space: 0 + VulkanBinding: + Binding: 4 + - Name: Out1 + Kind: RWStructuredBuffer + DirectXBinding: + Register: 5 + Space: 0 + VulkanBinding: + Binding: 5 +#--- end + +# REQUIRES: Int64 +# RUN: split-file %s %t +# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o