diff --git a/test/Basic/Matrix/matrix_elementwise_cast.test b/test/Basic/Matrix/matrix_elementwise_cast.test new file mode 100644 index 00000000..2b801306 --- /dev/null +++ b/test/Basic/Matrix/matrix_elementwise_cast.test @@ -0,0 +1,105 @@ +#--- source.hlsl +RWBuffer In : register(u0); +RWBuffer MatOut : register(u1); +RWBuffer ArrOut : register(u2); +RWBuffer StructOut : register(u3); + +struct S { + int A,B,C; + float X,Y,Z; +}; + +[numthreads(6,1,1)] +void main(uint GI : SV_GroupIndex) { + float2x3 A = float2x3(In[0], In[1], In[2], + In[3], In[4], In[5]); + float Arr[2][3] = {In[0], In[1], In[2], + In[3], In[4], In[5]}; + + S s = {(int)In[0], (int)In[1], (int)In[2], + In[3], In[4], In[5]}; + + const uint COLS = 3; // float2x3 => 2 rows, 3 columns + uint row = GI / COLS; // 0..1 + uint col = GI % COLS; // 0..2 + + int2x3 B = (int2x3)A; + int2x3 C = (int2x3)Arr; + int2x3 D = (int2x3)s; + + MatOut[GI] = B[row][col]; + ArrOut[GI] = C[row][col]; + StructOut[GI] = D[row][col]; +} +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In + Format: Float32 + Data: [ 1.1, 2.2, 3.3, 4.4, 5.5, 6.6] + - Name: MatOut + Format: Int32 + FillSize: 24 + - Name: ArrOut + Format: Int32 + FillSize: 24 + - Name: StructOut + Format: Int32 + FillSize: 24 + - Name: ExpectedOut + Format: Int32 + Data: [ 1, 2, 3, 4, 5, 6 ] +Results: + - Result: MatOut + Rule: BufferExact + Actual: MatOut + Expected: ExpectedOut + - Result: ArrOut + Rule: BufferExact + Actual: ArrOut + Expected: ExpectedOut + - Result: StructOut + Rule: BufferExact + Actual: StructOut + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: In + Kind: RWBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: MatOut + Kind: RWBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: ArrOut + Kind: RWBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 + - Name: StructOut + Kind: RWBuffer + DirectXBinding: + Register: 3 + Space: 0 + VulkanBinding: + Binding: 3 +... +#--- end + +# RUN: split-file %s %t +# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o diff --git a/test/Basic/Matrix/matrix_elementwise_vector_cast.test b/test/Basic/Matrix/matrix_elementwise_vector_cast.test new file mode 100644 index 00000000..8f40d0cd --- /dev/null +++ b/test/Basic/Matrix/matrix_elementwise_vector_cast.test @@ -0,0 +1,78 @@ +#--- source.hlsl +RWBuffer In : register(u0); +RWBuffer FloatMatOut : register(u1); +RWBuffer IntMatOut : register(u2); + +[numthreads(4,1,1)] +void main(uint GI : SV_GroupIndex) { + float4 V = float4(In[0], In[1],In[2], In[3]); + float2x2 M = (float2x2)V; + int2x2 M2 = (int2x2)V; + const uint COLS = 2; // float2x2 => 2 rows, 2 columns + uint row = GI / COLS; // 0..1 + uint col = GI % COLS; // 0..2 + + FloatMatOut[GI] = M[row][col]; + IntMatOut[GI] = M2[row][col]; +} +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In + Format: Float32 + Data: [ 1.1, 2.2, 3.3, 4.4] + - Name: FloatMatOut + Format: Float32 + FillSize: 16 + - Name: IntMatOut + Format: Int32 + FillSize: 16 + - Name: ExpectedFloatOut + Format: Float32 + Data: [ 1.1, 2.2, 3.3, 4.4] + - Name: ExpectedIntOut + Format: Int32 + Data: [ 1, 2, 3, 4 ] +Results: + - Result: FloatMatOut + Rule: BufferExact + Actual: FloatMatOut + Expected: ExpectedFloatOut + - Result: IntMatOut + Rule: BufferExact + Actual: IntMatOut + Expected: ExpectedIntOut +DescriptorSets: + - Resources: + - Name: In + Kind: RWBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: FloatMatOut + Kind: RWBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: IntMatOut + Kind: RWBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 +... +#--- end + +# RUN: split-file %s %t +# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o diff --git a/test/Basic/matrix_m-based_getter.test b/test/Basic/Matrix/matrix_m-based_getter.test similarity index 100% rename from test/Basic/matrix_m-based_getter.test rename to test/Basic/Matrix/matrix_m-based_getter.test diff --git a/test/Basic/matrix_one-based_getter.test b/test/Basic/Matrix/matrix_one-based_getter.test similarity index 100% rename from test/Basic/matrix_one-based_getter.test rename to test/Basic/Matrix/matrix_one-based_getter.test diff --git a/test/Basic/matrix_scalar_arithmetic.test b/test/Basic/Matrix/matrix_scalar_arithmetic.test similarity index 100% rename from test/Basic/matrix_scalar_arithmetic.test rename to test/Basic/Matrix/matrix_scalar_arithmetic.test diff --git a/test/Basic/matrix_scalar_constructor.test b/test/Basic/Matrix/matrix_scalar_constructor.test similarity index 100% rename from test/Basic/matrix_scalar_constructor.test rename to test/Basic/Matrix/matrix_scalar_constructor.test diff --git a/test/Basic/matrix_single_subscript_load.test b/test/Basic/Matrix/matrix_single_subscript_load.test similarity index 100% rename from test/Basic/matrix_single_subscript_load.test rename to test/Basic/Matrix/matrix_single_subscript_load.test diff --git a/test/Basic/matrix_single_subscript_store.test b/test/Basic/Matrix/matrix_single_subscript_store.test similarity index 100% rename from test/Basic/matrix_single_subscript_store.test rename to test/Basic/Matrix/matrix_single_subscript_store.test diff --git a/test/Basic/matrix_swizzle_one_based.test b/test/Basic/Matrix/matrix_swizzle_one_based.test similarity index 100% rename from test/Basic/matrix_swizzle_one_based.test rename to test/Basic/Matrix/matrix_swizzle_one_based.test diff --git a/test/Basic/matrix_swizzle_zero_based.test b/test/Basic/Matrix/matrix_swizzle_zero_based.test similarity index 100% rename from test/Basic/matrix_swizzle_zero_based.test rename to test/Basic/Matrix/matrix_swizzle_zero_based.test diff --git a/test/Basic/Matrix/matrix_trunc_cast.test b/test/Basic/Matrix/matrix_trunc_cast.test new file mode 100644 index 00000000..04aeef2f --- /dev/null +++ b/test/Basic/Matrix/matrix_trunc_cast.test @@ -0,0 +1,61 @@ +#--- source.hlsl +RWBuffer In : register(u0); +RWBuffer Out : register(u1); + +[numthreads(4,1,1)] +void main(uint GI : SV_GroupIndex) { + int4x4 A = int4x4(In[0], In[1], In[2], In[3], + In[4], In[5], In[6], In[7], + In[8], In[9], In[10], In[11], + In[12], In[13], In[14], In[15]); + + int2x2 B = (int2x2)A; + const uint COLS = 2; // int2x3 => 2 rows, 2 columns + uint row = GI / COLS; // 0..1 + uint col = GI % COLS; // 0..1 + Out[GI] = B[row][col]; +} +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In + Format: Int32 + Data: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + - Name: Out + Format: Int32 + FillSize: 16 + - Name: ExpectedOut + Format: Int32 + Data: [1, 2, 5, 6] +Results: + - Result: Out + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: In + Kind: RWBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Out + Kind: RWBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# RUN: split-file %s %t +# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o