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.
This commit is contained in:
parent
0d2b4713c5
commit
80f92a190a
4 changed files with 303 additions and 295 deletions
|
|
@ -2590,20 +2590,22 @@ void TGlslangToSpvTraverser::accessChainStore(const glslang::TType& type, spv::I
|
|||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue