瀏覽代碼

Split matrix orientation override test into /Zpr and /Zpc flavors (#1807)

Tests cover #pragma pack_matrix behavior under /Zpc and /Zpr both, at the codegen and ast levels.
Tristan Labelle 6 年之前
父節點
當前提交
79d5890739

+ 38 - 0
tools/clang/test/CodeGenHLSL/quick-test/matrix_orientation_overrides_Zpc.hlsl

@@ -0,0 +1,38 @@
+// RUN: %dxc /T vs_6_0 /E main /Zpc %s | FileCheck %s
+
+// Test effective matrix orientations with every combination
+// of default and explicit matrix orientations.
+
+struct S1 { row_major int2x2 mat; };
+struct S2 { int2x2 mat; }; // Default to column_major from /Zpc
+
+#pragma pack_matrix(row_major)
+struct S3 { column_major int2x2 mat; };
+struct S4 { int2x2 mat; }; // Default to row_major from #pragma
+
+#pragma pack_matrix(column_major)
+struct S5 { row_major int2x2 mat; };
+struct S6 { int2x2 mat; }; // Default to column_major from #pragma
+
+RWStructuredBuffer<S1> sb1;
+RWStructuredBuffer<S2> sb2;
+RWStructuredBuffer<S3> sb3;
+RWStructuredBuffer<S4> sb4;
+RWStructuredBuffer<S5> sb5;
+RWStructuredBuffer<S6> sb6;
+
+void main()
+{
+    // CHECK: i32 11, i32 12, i32 21, i32 22
+    sb1[0].mat = int2x2(11, 12, 21, 22);
+    // CHECK: i32 11, i32 21, i32 12, i32 22
+    sb2[0].mat = int2x2(11, 12, 21, 22);
+    // CHECK: i32 11, i32 21, i32 12, i32 22
+    sb3[0].mat = int2x2(11, 12, 21, 22);
+    // CHECK: i32 11, i32 12, i32 21, i32 22
+    sb4[0].mat = int2x2(11, 12, 21, 22);
+    // CHECK: i32 11, i32 12, i32 21, i32 22
+    sb5[0].mat = int2x2(11, 12, 21, 22);
+    // CHECK: i32 11, i32 21, i32 12, i32 22
+    sb6[0].mat = int2x2(11, 12, 21, 22);
+}

+ 0 - 0
tools/clang/test/CodeGenHLSL/quick-test/matrix_orientation_overrides.hlsl → tools/clang/test/CodeGenHLSL/quick-test/matrix_orientation_overrides_Zpr.hlsl


+ 29 - 0
tools/clang/test/CodeGenHLSL/quick-test/matrix_orientation_overrides_ast.hlsl

@@ -0,0 +1,29 @@
+// RUN: %dxc /T vs_6_0 /E main /Zpc -ast-dump %s | FileCheck %s
+
+// Test that the declarations in the ast get annotated with row/column major as expected
+
+void main()
+{
+    // CHECK: rm_Zpc 'row_major int2x2
+    row_major int2x2 rm_Zpc;
+    // CHECK: cm_Zpc 'column_major int2x2
+    column_major int2x2 cm_Zpc;
+    // CHECK: def_Zpc 'int2x2
+    int2x2 def_Zpc; // Default to column_major from (implicit) /Zpc
+
+    #pragma pack_matrix(row_major)
+    // CHECK: rm_prm 'row_major int2x2
+    row_major int2x2 rm_prm;
+    // CHECK: cm_prm 'column_major int2x2
+    column_major int2x2 cm_prm;
+    // CHECK: def_prm 'row_major int2x2
+    int2x2 def_prm; // Default to row_major from #pragma
+
+    #pragma pack_matrix(column_major)
+    // CHECK: rm_pcm 'row_major int2x2
+    row_major int2x2 rm_pcm;
+    // CHECK: cm_pcm 'column_major int2x2
+    column_major int2x2 cm_pcm;
+    // CHECK: def_pcm 'column_major int2x2
+    int2x2 def_pcm; // Default to column_major from #pragma
+}