glslang -> SPIR-V: smear scalars for integer (scalar * vector). OpVectorTimesScalar is only for floats.
This commit is contained in:
parent
9b0d9c8aa4
commit
ec43d0abec
1 changed files with 14 additions and 11 deletions
|
|
@ -1693,7 +1693,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
|
||||||
bool isFloat = typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble;
|
bool isFloat = typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble;
|
||||||
|
|
||||||
spv::Op binOp = spv::OpNop;
|
spv::Op binOp = spv::OpNop;
|
||||||
bool needsPromotion = true;
|
bool needMatchingVectors = true; // for non-matrix ops, would a scalar need to smear to match a vector?
|
||||||
bool comparison = false;
|
bool comparison = false;
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
|
@ -1720,11 +1720,14 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
|
||||||
break;
|
break;
|
||||||
case glslang::EOpVectorTimesScalar:
|
case glslang::EOpVectorTimesScalar:
|
||||||
case glslang::EOpVectorTimesScalarAssign:
|
case glslang::EOpVectorTimesScalarAssign:
|
||||||
if (builder.isVector(right))
|
if (isFloat) {
|
||||||
std::swap(left, right);
|
if (builder.isVector(right))
|
||||||
assert(builder.isScalar(right));
|
std::swap(left, right);
|
||||||
binOp = spv::OpVectorTimesScalar;
|
assert(builder.isScalar(right));
|
||||||
needsPromotion = false;
|
needMatchingVectors = false;
|
||||||
|
binOp = spv::OpVectorTimesScalar;
|
||||||
|
} else
|
||||||
|
binOp = spv::OpIMul;
|
||||||
break;
|
break;
|
||||||
case glslang::EOpVectorTimesMatrix:
|
case glslang::EOpVectorTimesMatrix:
|
||||||
case glslang::EOpVectorTimesMatrixAssign:
|
case glslang::EOpVectorTimesMatrixAssign:
|
||||||
|
|
@ -1752,7 +1755,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
|
||||||
break;
|
break;
|
||||||
case glslang::EOpOuterProduct:
|
case glslang::EOpOuterProduct:
|
||||||
binOp = spv::OpOuterProduct;
|
binOp = spv::OpOuterProduct;
|
||||||
needsPromotion = false;
|
needMatchingVectors = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case glslang::EOpDiv:
|
case glslang::EOpDiv:
|
||||||
|
|
@ -1789,7 +1792,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
|
||||||
binOp = spv::OpBitwiseAnd;
|
binOp = spv::OpBitwiseAnd;
|
||||||
break;
|
break;
|
||||||
case glslang::EOpLogicalAnd:
|
case glslang::EOpLogicalAnd:
|
||||||
needsPromotion = false;
|
needMatchingVectors = false;
|
||||||
binOp = spv::OpLogicalAnd;
|
binOp = spv::OpLogicalAnd;
|
||||||
break;
|
break;
|
||||||
case glslang::EOpInclusiveOr:
|
case glslang::EOpInclusiveOr:
|
||||||
|
|
@ -1797,7 +1800,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
|
||||||
binOp = spv::OpBitwiseOr;
|
binOp = spv::OpBitwiseOr;
|
||||||
break;
|
break;
|
||||||
case glslang::EOpLogicalOr:
|
case glslang::EOpLogicalOr:
|
||||||
needsPromotion = false;
|
needMatchingVectors = false;
|
||||||
binOp = spv::OpLogicalOr;
|
binOp = spv::OpLogicalOr;
|
||||||
break;
|
break;
|
||||||
case glslang::EOpExclusiveOr:
|
case glslang::EOpExclusiveOr:
|
||||||
|
|
@ -1805,7 +1808,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
|
||||||
binOp = spv::OpBitwiseXor;
|
binOp = spv::OpBitwiseXor;
|
||||||
break;
|
break;
|
||||||
case glslang::EOpLogicalXor:
|
case glslang::EOpLogicalXor:
|
||||||
needsPromotion = false;
|
needMatchingVectors = false;
|
||||||
binOp = spv::OpLogicalXor;
|
binOp = spv::OpLogicalXor;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -1849,7 +1852,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
|
||||||
}
|
}
|
||||||
|
|
||||||
// No matrix involved; make both operands be the same number of components, if needed
|
// No matrix involved; make both operands be the same number of components, if needed
|
||||||
if (needsPromotion)
|
if (needMatchingVectors)
|
||||||
builder.promoteScalar(precision, left, right);
|
builder.promoteScalar(precision, left, right);
|
||||||
|
|
||||||
spv::Id id = builder.createBinOp(binOp, typeId, left, right);
|
spv::Id id = builder.createBinOp(binOp, typeId, left, right);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue