Browse Source

Fix precise on matrix with matrix subscript. (#2545)

Tex Riddell 5 years ago
parent
commit
f032e2bce5

+ 7 - 2
lib/HLSL/HLModule.cpp

@@ -1099,8 +1099,13 @@ void HLModule::MarkPreciseAttributeOnPtrWithFunctionCall(llvm::Value *Ptr,
           MarkPreciseAttributeOnValWithFunctionCall(arg, Builder, M);
           MarkPreciseAttributeOnValWithFunctionCall(arg, Builder, M);
         }
         }
       } else {
       } else {
-        IRBuilder<> Builder(CI->getNextNode());
-        MarkPreciseAttributeOnValWithFunctionCall(CI, Builder, M);
+        if (CI->getType()->isPointerTy()) {
+          // For instance, matrix subscript...
+          MarkPreciseAttributeOnPtrWithFunctionCall(CI, M);
+        } else {
+          IRBuilder<> Builder(CI->getNextNode());
+          MarkPreciseAttributeOnValWithFunctionCall(CI, Builder, M);
+        }
       }
       }
     } else {
     } else {
       // Must be GEP here.
       // Must be GEP here.

+ 12 - 0
tools/clang/test/HLSLFileCheck/hlsl/types/modifiers/precise/precise-matrix-subscript.hlsl

@@ -0,0 +1,12 @@
+// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s
+
+// CHECK: define void @main()
+
+float3x3 main(float3 normal : IN) : OUT
+{
+    precise float3x3 ret; // <---- precise
+    ret[0] = normal;
+    ret[1] = normal;
+    ret[2] = normal;
+    return ret;
+}