Fix #857: Convert uniform int to local bool for struct alias assignment.
This was done for one direction, but not both directions, so this commit
picks up the other direction.
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index f8722fc..31f7aab 100755
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -2590,20 +2590,22 @@
if (builder.isScalarType(nominalTypeId)) {
// Conversion for bool
spv::Id boolType = builder.makeBoolType();
- if (nominalTypeId != boolType) {
- spv::Id zero = builder.makeUintConstant(0);
- spv::Id one = builder.makeUintConstant(1);
- rvalue = builder.createTriOp(spv::OpSelect, nominalTypeId, rvalue, one, zero);
- }
+ if (nominalTypeId != boolType)
+ rvalue = builder.createTriOp(spv::OpSelect, nominalTypeId, rvalue, builder.makeUintConstant(1),
+ builder.makeUintConstant(0));
+ else if (builder.getTypeId(rvalue) != boolType)
+ rvalue = builder.createBinOp(spv::OpINotEqual, boolType, rvalue, builder.makeUintConstant(0));
} else if (builder.isVectorType(nominalTypeId)) {
// Conversion for bvec
int vecSize = builder.getNumTypeComponents(nominalTypeId);
spv::Id bvecType = builder.makeVectorType(builder.makeBoolType(), vecSize);
- if (nominalTypeId != bvecType) {
- spv::Id zero = makeSmearedConstant(builder.makeUintConstant(0), vecSize);
- spv::Id one = makeSmearedConstant(builder.makeUintConstant(1), vecSize);
- rvalue = builder.createTriOp(spv::OpSelect, nominalTypeId, rvalue, one, zero);
- }
+ if (nominalTypeId != bvecType)
+ rvalue = builder.createTriOp(spv::OpSelect, nominalTypeId, rvalue,
+ makeSmearedConstant(builder.makeUintConstant(1), vecSize),
+ makeSmearedConstant(builder.makeUintConstant(0), vecSize));
+ else if (builder.getTypeId(rvalue) != bvecType)
+ rvalue = builder.createBinOp(spv::OpINotEqual, bvecType, rvalue,
+ makeSmearedConstant(builder.makeUintConstant(0), vecSize));
}
}