From f032e2bce5004de7f19bd30f99bd5edebbd709c3 Mon Sep 17 00:00:00 2001 From: Tex Riddell Date: Thu, 24 Oct 2019 17:08:05 -0700 Subject: [PATCH] Fix precise on matrix with matrix subscript. (#2545) --- lib/HLSL/HLModule.cpp | 9 +++++++-- .../modifiers/precise/precise-matrix-subscript.hlsl | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tools/clang/test/HLSLFileCheck/hlsl/types/modifiers/precise/precise-matrix-subscript.hlsl diff --git a/lib/HLSL/HLModule.cpp b/lib/HLSL/HLModule.cpp index 01f559f86..0393a6dba 100644 --- a/lib/HLSL/HLModule.cpp +++ b/lib/HLSL/HLModule.cpp @@ -1099,8 +1099,13 @@ void HLModule::MarkPreciseAttributeOnPtrWithFunctionCall(llvm::Value *Ptr, MarkPreciseAttributeOnValWithFunctionCall(arg, Builder, M); } } 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 { // Must be GEP here. diff --git a/tools/clang/test/HLSLFileCheck/hlsl/types/modifiers/precise/precise-matrix-subscript.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/types/modifiers/precise/precise-matrix-subscript.hlsl new file mode 100644 index 000000000..ce93dab28 --- /dev/null +++ b/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; +}