diff --git a/test/Feature/HLSLLib/ldexp.16.test b/test/Feature/HLSLLib/ldexp.16.test new file mode 100644 index 0000000..f993a16 --- /dev/null +++ b/test/Feature/HLSLLib/ldexp.16.test @@ -0,0 +1,79 @@ +#--- source.hlsl + +StructuredBuffer In : register(t0); +RWStructuredBuffer Out : register(u1); + +[numthreads(1,1,1)] +void main() { + // X Exp + // ------------------ + // 0x4248 0x8000 + // 0x0000 0x3C00 + // 0xFC00 0xB800 + // 0x7E00 0x7C00 + // 0x8000 0x3C00 + // 0x3C00 0x0000 + // 0xB800 0xFC00 + // 0x7C00 0x7E00 + // 0x4248 0xB800 + // 0x0000 0x7C00 + // 0x3C00 0x4C00 (overflow) + // 0x3C00 0xCE40 (underflow) + Out[0] = ldexp(In[0], In[1]); + Out[1].x = ldexp(In[1].x, In[1].y); + Out[1].yzw = ldexp(In[1].yzw, In[0].yzw); + Out[2].xy = ldexp(In[0].xy, In[1].zw); + Out[2].zw = ldexp(In[2].xy, In[2].zw); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In + Format: Float16 + Stride: 8 + Data: [ 0x4248, 0x0000, 0xFC00, 0x7E00, 0x8000, 0x3C00, 0xB800, 0x7C00, 0x3C00, 0x3C00, 0x4C00, 0xCE40 ] # [ 3.140625, 0, -inf, NaN, -0, 1, -0.5, inf, 1, 1, 16, -25 ] + - Name: Out + Format: Float16 + Stride: 8 + ZeroInitSize: 24 + - Name: ExpectedOut # The result we expect + Format: Float16 + Stride: 8 + Data: [ 0x4248, 0x0000, 0xFC00, 0x7E00, 0x8000, 0x3C00, 0x8000, 0x7E00, 0x4071, 0x7E00, 0x7C00, 0x0000 ] # [ 3.140625, 0, -inf, NaN, -0, 1, -0, NaN, 2.220703, NaN, inf, 0 ] +Results: + - Result: Test1 + Rule: BufferFuzzy + ULPT: 1 + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: In + Kind: StructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Out + Kind: RWStructuredBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# REQUIRES: Half + +# UNSUPPORTED: Clang-Vulkan +# 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/ldexp.32.test b/test/Feature/HLSLLib/ldexp.32.test new file mode 100644 index 0000000..8af7c87 --- /dev/null +++ b/test/Feature/HLSLLib/ldexp.32.test @@ -0,0 +1,77 @@ +#--- source.hlsl + +StructuredBuffer In : register(t0); +RWStructuredBuffer Out : register(u1); + +[numthreads(1,1,1)] +void main() { + // X Exp + // ------------------ + // 3.14159 -0 + // 0 1 + // -inf -0.5 + // NaN inf + // -0 1 + // 1 0 + // -0.5 -inf + // inf NaN + // 3.14159 -0.5 + // 0 inf + // 1 128 (overflow) + // 1 -150 (underflow) + Out[0] = ldexp(In[0], In[1]); + Out[1].x = ldexp(In[1].x, In[1].y); + Out[1].yzw = ldexp(In[1].yzw, In[0].yzw); + Out[2].xy = ldexp(In[0].xy, In[1].zw); + Out[2].zw = ldexp(In[2].xy, In[2].zw); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In + Format: Float32 + Stride: 16 + Data: [ 3.14159, 0, -inf, NaN, -0, 1, -0.5, inf, 1, 1, 128, -150 ] + - Name: Out + Format: Float32 + Stride: 16 + ZeroInitSize: 48 + - Name: ExpectedOut # The result we expect + Format: Float32 + Stride: 16 + Data: [ 3.14159, 0, -inf, NaN, -0, 1, -0, NaN, 2.2214396, NaN, inf, 0 ] +Results: + - Result: Test1 + Rule: BufferFuzzy + ULPT: 1 + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: In + Kind: StructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Out + Kind: RWStructuredBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# UNSUPPORTED: 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