diff --git a/test/Feature/HLSLLib/firstbitlow.16.test b/test/Feature/HLSLLib/firstbitlow.16.test new file mode 100644 index 00000000..2c5f2dd0 --- /dev/null +++ b/test/Feature/HLSLLib/firstbitlow.16.test @@ -0,0 +1,88 @@ +#--- source.hlsl + +StructuredBuffer In1 : register(t0); +StructuredBuffer In2 : register(t1); +RWStructuredBuffer Out : register(u2); + +[numthreads(1,1,1)] +void main() { + Out[0] = firstbitlow(In1[0]); + uint32_t4 Out1 = {firstbitlow(In1[0].xyz), firstbitlow(In1[0].w)}; + uint32_t4 Out2 = {firstbitlow(In2[0].xy), firstbitlow(In2[0].zw)}; + Out[1] = Out1; + Out[2] = Out2; +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In1 + Format: Hex16 + Stride: 8 + Data: [ + 0x0000, + 0x00E8, + 0x8000, + 0xFFFF, + ] + - Name: In2 + Format: Int16 + Stride: 8 + Data: [-1, -8, 8, 0] + - Name: Out + Format: UInt32 + Stride: 16 + ZeroInitSize: 48 + - Name: ExpectedOut # The result we expect + Format: UInt32 + Stride: 16 + # All bits set (4294967295) is returned when no bit is set on the input + Data: [4294967295, 3, 15, 0, 4294967295, 3, 15, 0, 0, 3, 3, 4294967295] +Results: + - Result: Test1 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: In1 + Kind: StructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: In2 + Kind: StructuredBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: Out + Kind: RWStructuredBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 +... +#--- end + +# REQUIRES: Int16 + +# Fails with 'gpu-exec: error: Failed to materializeAll.:' +# XFAIL: Metal + +# 16/64 bit firstbitlow doesn't have a DXC-Vulkan lowering +# https://github.com/microsoft/DirectXShaderCompiler/blob/48d6e3c635f0ab3ae79580c37003e6faeca6c671/tools/clang/test/CodeGenSPIRV/intrinsics.firstbitlow.64bit.hlsl#L5 +# UNSUPPORTED: DXC-Vulkan + +# RUN: split-file %s %t +# RUN: %dxc_target -T cs_6_5 -enable-16bit-types -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o diff --git a/test/Feature/HLSLLib/firstbitlow.32.test b/test/Feature/HLSLLib/firstbitlow.32.test new file mode 100644 index 00000000..9942dae4 --- /dev/null +++ b/test/Feature/HLSLLib/firstbitlow.32.test @@ -0,0 +1,79 @@ +#--- source.hlsl + +StructuredBuffer In1 : register(t0); +StructuredBuffer In2 : register(t1); +RWStructuredBuffer Out : register(u2); + +[numthreads(1,1,1)] +void main() { + Out[0] = firstbitlow(In1[0]); + uint4 Out1 = {firstbitlow(In1[0].xyz), firstbitlow(In1[0].w)}; + uint4 Out2 = {firstbitlow(In2[0].xy), firstbitlow(In2[0].zw)}; + Out[1] = Out1; + Out[2] = Out2; +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In1 + Format: Hex32 + Stride: 16 + Data: [ + 0x00000000, + 0x000000E8, + 0x80000000, + 0xFFFFFFFF, + ] + - Name: In2 + Format: Int32 + Stride: 16 + Data: [-1, -8, 8, 0] + - Name: Out + Format: UInt32 + Stride: 16 + ZeroInitSize: 48 + - Name: ExpectedOut # The result we expect + Format: UInt32 + Stride: 16 + # All bits set (4294967295) is returned when no bit is set on the input + Data: [4294967295, 3, 31, 0, 4294967295, 3, 31, 0, 0, 3, 3, 4294967295] +Results: + - Result: Test1 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: In1 + Kind: StructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: In2 + Kind: StructuredBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: Out + Kind: RWStructuredBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 +... +#--- 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/firstbitlow.64.test b/test/Feature/HLSLLib/firstbitlow.64.test new file mode 100644 index 00000000..9044ce77 --- /dev/null +++ b/test/Feature/HLSLLib/firstbitlow.64.test @@ -0,0 +1,91 @@ +#--- source.hlsl + +StructuredBuffer In1 : register(t0); +StructuredBuffer In2 : register(t1); +RWStructuredBuffer Out : register(u2); + +[numthreads(1,1,1)] +void main() { + Out[0] = firstbitlow(In1[0]); + uint32_t4 Out1 = {firstbitlow(In1[0].xyz), firstbitlow(In1[0].w)}; + uint32_t4 Out2 = {firstbitlow(In2[0].xy), firstbitlow(In2[0].zw)}; + Out[1] = Out1; + Out[2] = Out2; +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In1 + Format: Hex64 + Stride: 32 + Data: [ + 0x0000000000000000, + 0x00000000000000E8, + 0x8000000000000000, + 0xFFFFFFFFFFFFFFFF, + ] + - Name: In2 + Format: Int64 + Stride: 32 + Data: [-1, -8, 8, 0] + - Name: Out + Format: UInt32 + Stride: 16 + ZeroInitSize: 48 + - Name: ExpectedOut # The result we expect + Format: UInt32 + Stride: 16 + # All bits set (4294967295) is returned when no bit is set on the input + Data: [4294967295, 3, 63, 0, 4294967295, 3, 63, 0, 0, 3, 3, 4294967295] +Results: + - Result: Test1 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: In1 + Kind: StructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: In2 + Kind: StructuredBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: Out + Kind: RWStructuredBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 +... +#--- end + +# REQUIRES: Int64 + +# Fails with 'gpu-exec: error: Failed to materializeAll.:' +# XFAIL: Metal + +# 16/64 bit firstbitlow doesn't have a DXC-Vulkan lowering +# https://github.com/microsoft/DirectXShaderCompiler/blob/48d6e3c635f0ab3ae79580c37003e6faeca6c671/tools/clang/test/CodeGenSPIRV/intrinsics.firstbitlow.64bit.hlsl#L5 +# UNSUPPORTED: DXC-Vulkan + +# https://github.com/llvm/llvm-project/issues/143003 +# XFAIL: Clang-Vulkan + +# 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