SPV 1.4: Add support for OpCopyLogical, careful of Boolean differences.

This commit is contained in:
John Kessenich
2019-01-15 21:48:27 +07:00
parent 1f4d04687b
commit fbb6bdf046
9 changed files with 636 additions and 0 deletions

View File

@@ -3656,6 +3656,20 @@ void TGlslangToSpvTraverser::multiTypeStore(const glslang::TType& type, spv::Id
// where the two types were the same type in GLSL. This requires member
// by member copy, recursively.
// SPIR-V 1.4 added an instruction to do help do this.
if (glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_4) {
// However, bool in uniform space is changed to int, so
// OpCopyLogical does not work for that.
// TODO: It would be more robust to do a full recursive verification of the types satisfying SPIR-V rules.
bool rBool = builder.containsType(builder.getTypeId(rValue), spv::OpTypeBool, 0);
bool lBool = builder.containsType(lType, spv::OpTypeBool, 0);
if (lBool == rBool) {
spv::Id logicalCopy = builder.createUnaryOp(spv::OpCopyLogical, lType, rValue);
accessChainStore(type, logicalCopy);
return;
}
}
// If an array, copy element by element.
if (type.isArray()) {
glslang::TType glslangElementType(type, 0);