Fix #809: smear scalar condition in OpSelect for selecting vector operands.

This commit is contained in:
John Kessenich
2017-03-30 10:09:28 -06:00
parent 4dc835c369
commit e434ad923e
6 changed files with 72 additions and 56 deletions

View File

@@ -1823,7 +1823,15 @@ bool TGlslangToSpvTraverser::visitSelection(glslang::TVisit /* visit */, glslang
node->getFalseBlock()->traverse(this);
spv::Id falseValue = accessChainLoad(node->getTrueBlock()->getAsTyped()->getType());
spv::Id select = builder.createTriOp(spv::OpSelect, convertGlslangToSpvType(node->getType()), condition, trueValue, falseValue);
// smear condition to vector, if necessary (AST is always scalar)
if (builder.isVector(trueValue))
condition = builder.smearScalar(spv::NoPrecision, condition,
builder.makeVectorType(builder.makeBoolType(),
builder.getNumComponents(trueValue)));
spv::Id select = builder.createTriOp(spv::OpSelect,
convertGlslangToSpvType(node->getType()), condition,
trueValue, falseValue);
builder.clearAccessChain();
builder.setAccessChainRValue(select);
};