소스 검색

[spirv] report error for non-float col matrix (#2474)

Handling array of structure of non-float col-major matrix case.
Jaebaek Seo 6 년 전
부모
커밋
3e77425bb6

+ 5 - 0
tools/clang/lib/SPIRV/AstTypeProbe.cpp

@@ -1097,6 +1097,11 @@ bool isOrContainsNonFpColMajorMatrix(const ASTContext &astContext,
     if (isMxNMatrix(arrayType->getElementType(), &elemType) &&
         !elemType->isFloatingType())
       return isColMajorDecl(decl);
+    if (const auto *structType = arrayType->getElementType()->getAs<RecordType>()) {
+      return isOrContainsNonFpColMajorMatrix(astContext, spirvOptions,
+                                             arrayType->getElementType(),
+                                             structType->getDecl());
+    }
   }
 
   if (const auto *structType = type->getAs<RecordType>()) {

+ 38 - 0
tools/clang/test/CodeGenSPIRV/vk.layout.non-fp-matrix.array.struct.error.hlsl

@@ -0,0 +1,38 @@
+// Run: %dxc -T vs_6_0 -E main
+
+struct A {
+  uint2x3 a;
+};
+
+struct B {
+  A a[7];
+};
+
+StructuredBuffer<B> buffer;
+
+struct T {
+  uint a;
+  float1x3 c;
+  uint3x3 d;
+  uint2x3 f;
+  uint g;
+};
+
+struct U {
+  uint a[3];
+  float b;
+  uint3 c;
+  float2 e;
+  T f[7];
+  uint g;
+};
+
+StructuredBuffer<U> buffer2;
+
+void main()
+{
+}
+
+
+// CHECK: :11:21: error: externally initialized non-floating-point column-major matrices not supported yet
+// CHECK: :30:21: error: externally initialized non-floating-point column-major matrices not supported yet

+ 3 - 0
tools/clang/unittests/SPIRV/CodeGenSpirvTest.cpp

@@ -1857,6 +1857,9 @@ TEST_F(FileTest, VulkanSubpassInputError) {
 TEST_F(FileTest, NonFpColMajorError) {
   runFileTest("vk.layout.non-fp-matrix.error.hlsl", Expect::Failure);
 }
+TEST_F(FileTest, NonFpColMajorErrorArrayStruct) {
+  runFileTest("vk.layout.non-fp-matrix.array.struct.error.hlsl", Expect::Failure);
+}
 
 TEST_F(FileTest, NamespaceFunctions) {
   runFileTest("namespace.functions.hlsl");