Correctly handle comma operator w/matrices (#3921)
The special HLSL matrix codegen didn't handle the comma operator. Since the operation is simple enough, skip special handling and fallback to the default behavior Fixed #3916
This commit is contained in:
Родитель
7ed55d8ed7
Коммит
dd86223362
|
@ -204,17 +204,16 @@ public:
|
|||
if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(E)) {
|
||||
if (hlsl::IsHLSLMatType(E->getType()) ||
|
||||
hlsl::IsHLSLMatType(BinOp->getLHS()->getType())) {
|
||||
if (BinOp->getOpcode() != BO_Assign) {
|
||||
llvm::Value *LHS = CGF.EmitScalarExpr(BinOp->getLHS());
|
||||
llvm::Value *RHS = CGF.EmitScalarExpr(BinOp->getRHS());
|
||||
return CGF.CGM.getHLSLRuntime().EmitHLSLMatrixOperationCall(
|
||||
CGF, E, ConvertType(E->getType()), { LHS, RHS });
|
||||
}
|
||||
else {
|
||||
if (BinOp->getOpcode() == BO_Assign) {
|
||||
LValue LHS = CGF.EmitLValue(BinOp->getLHS());
|
||||
llvm::Value *RHS = CGF.EmitScalarExpr(BinOp->getRHS());
|
||||
CGF.CGM.getHLSLRuntime().EmitHLSLMatrixStore(CGF, RHS, LHS.getAddress(), BinOp->getLHS()->getType());
|
||||
return RHS;
|
||||
} else if (BinOp->getOpcode() != BO_Comma) { // comma handled by standard Visit below
|
||||
llvm::Value *LHS = CGF.EmitScalarExpr(BinOp->getLHS());
|
||||
llvm::Value *RHS = CGF.EmitScalarExpr(BinOp->getRHS());
|
||||
return CGF.CGM.getHLSLRuntime().EmitHLSLMatrixOperationCall(
|
||||
CGF, E, ConvertType(E->getType()), { LHS, RHS });
|
||||
}
|
||||
}
|
||||
} else if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(E)) {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
// RUN: %dxc -E vecret -T ps_6_0 %s | FileCheck %s
|
||||
// RUN: %dxc -T lib_6_3 %s | FileCheck %s -check-prefix=CHK_MAT
|
||||
|
||||
// verify that the comma operator works with matrix types
|
||||
|
||||
// CHECK: dx.op.loadInput
|
||||
// CHECK-NEXT: dx.op.loadInput
|
||||
// CHECK-NEXT: dx.op.loadInput
|
||||
// CHECK-NEXT: dx.op.loadInput
|
||||
|
||||
// CHECK-NEXT: dx.op.storeOutput
|
||||
// CHECK-NEXT: dx.op.storeOutput
|
||||
// CHECK-NEXT: dx.op.storeOutput
|
||||
// CHECK-NEXT: dx.op.storeOutput
|
||||
|
||||
// CHK_MAT: store %class.matrix.float.2.2
|
||||
// CHK_MAT: load %class.matrix.float.2.2
|
||||
|
||||
// Check where the result IS NOT a matrix type
|
||||
float4 vecret(float2x2 pmat : M, float4 pvec : V) : SV_Target {
|
||||
return pmat , pvec;
|
||||
}
|
||||
|
||||
// Check where the result IS a matrix type
|
||||
export
|
||||
float2x2 matret(float2x2 pmat : M, float4 pvec : V) {
|
||||
return pmat;
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче