소스 검색

Merge pull request #1422 from python3kgae/mat_fix

Fix crash when get matrix element on a function call.
Xiang Li 7 년 전
부모
커밋
3e24ab8ac1
2개의 변경된 파일14개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      tools/clang/lib/CodeGen/CGExpr.cpp
  2. 13 0
      tools/clang/test/CodeGenHLSL/quick-test/matrix_return_sub2.hlsl

+ 1 - 1
tools/clang/lib/CodeGen/CGExpr.cpp

@@ -2847,7 +2847,7 @@ CodeGenFunction::EmitExtMatrixElementExpr(const ExtMatrixElementExpr *E) {
 
     // Store the vector to memory (because LValue wants an address).
     llvm::Value *VecMem = CreateMemTemp(E->getBase()->getType());
-    Builder.CreateStore(Vec, VecMem);
+    CGM.getHLSLRuntime().EmitHLSLMatrixStore(*this, Vec, VecMem, E->getBase()->getType());
     Base = MakeAddrLValue(VecMem, E->getBase()->getType());
   }
   

+ 13 - 0
tools/clang/test/CodeGenHLSL/quick-test/matrix_return_sub2.hlsl

@@ -0,0 +1,13 @@
+// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
+
+// Make sure this works on function that returns matrix
+// CHECK: call %dx.types.CBufRet.f32 @dx.op.cbufferLoad
+
+float4x4 m;
+float4x4 GetMat() {
+  return m;
+}
+
+float main() : SV_Target {
+  return GetMat()._m01;
+}