Commit 80f92a19 by John Kessenich

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.
parent 0d2b4713
...@@ -2590,20 +2590,22 @@ void TGlslangToSpvTraverser::accessChainStore(const glslang::TType& type, spv::I ...@@ -2590,20 +2590,22 @@ void TGlslangToSpvTraverser::accessChainStore(const glslang::TType& type, spv::I
if (builder.isScalarType(nominalTypeId)) { if (builder.isScalarType(nominalTypeId)) {
// Conversion for bool // Conversion for bool
spv::Id boolType = builder.makeBoolType(); spv::Id boolType = builder.makeBoolType();
if (nominalTypeId != boolType) { if (nominalTypeId != boolType)
spv::Id zero = builder.makeUintConstant(0); rvalue = builder.createTriOp(spv::OpSelect, nominalTypeId, rvalue, builder.makeUintConstant(1),
spv::Id one = builder.makeUintConstant(1); builder.makeUintConstant(0));
rvalue = builder.createTriOp(spv::OpSelect, nominalTypeId, rvalue, one, zero); else if (builder.getTypeId(rvalue) != boolType)
} rvalue = builder.createBinOp(spv::OpINotEqual, boolType, rvalue, builder.makeUintConstant(0));
} else if (builder.isVectorType(nominalTypeId)) { } else if (builder.isVectorType(nominalTypeId)) {
// Conversion for bvec // Conversion for bvec
int vecSize = builder.getNumTypeComponents(nominalTypeId); int vecSize = builder.getNumTypeComponents(nominalTypeId);
spv::Id bvecType = builder.makeVectorType(builder.makeBoolType(), vecSize); spv::Id bvecType = builder.makeVectorType(builder.makeBoolType(), vecSize);
if (nominalTypeId != bvecType) { if (nominalTypeId != bvecType)
spv::Id zero = makeSmearedConstant(builder.makeUintConstant(0), vecSize); rvalue = builder.createTriOp(spv::OpSelect, nominalTypeId, rvalue,
spv::Id one = makeSmearedConstant(builder.makeUintConstant(1), vecSize); makeSmearedConstant(builder.makeUintConstant(1), vecSize),
rvalue = builder.createTriOp(spv::OpSelect, nominalTypeId, rvalue, one, zero); makeSmearedConstant(builder.makeUintConstant(0), vecSize));
} else if (builder.getTypeId(rvalue) != bvecType)
rvalue = builder.createBinOp(spv::OpINotEqual, bvecType, rvalue,
makeSmearedConstant(builder.makeUintConstant(0), vecSize));
} }
} }
......
...@@ -53,9 +53,9 @@ Warning, version 450 is not yet complete; most version-specific features are pre ...@@ -53,9 +53,9 @@ Warning, version 450 is not yet complete; most version-specific features are pre
29: 6(bool) ConstantFalse 29: 6(bool) ConstantFalse
30: 9(bvec2) ConstantComposite 29 29 30: 9(bvec2) ConstantComposite 29 29
31: 22(int) Constant 0 31: 22(int) Constant 0
32: 23(ivec2) ConstantComposite 31 31 32: 22(int) Constant 1
33: 22(int) Constant 1 33: 23(ivec2) ConstantComposite 31 31
34: 23(ivec2) ConstantComposite 33 33 34: 23(ivec2) ConstantComposite 32 32
36: TypePointer Uniform 23(ivec2) 36: TypePointer Uniform 23(ivec2)
38: TypeVector 22(int) 4 38: TypeVector 22(int) 4
39(Uniform): TypeStruct 38(ivec4) 39(Uniform): TypeStruct 38(ivec4)
...@@ -73,7 +73,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre ...@@ -73,7 +73,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre
5: Label 5: Label
62(param): 8(ptr) Variable Function 62(param): 8(ptr) Variable Function
67(param): 10(ptr) Variable Function 67(param): 10(ptr) Variable Function
35: 23(ivec2) Select 30 34 32 35: 23(ivec2) Select 30 34 33
37: 36(ptr) AccessChain 26 28 37: 36(ptr) AccessChain 26 28
Store 37 35 Store 37 35
43: 42(ptr) AccessChain 41 28 43: 42(ptr) AccessChain 41 28
...@@ -88,7 +88,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre ...@@ -88,7 +88,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre
51: 22(int) CompositeExtract 50 0 51: 22(int) CompositeExtract 50 0
52: 6(bool) INotEqual 51 31 52: 6(bool) INotEqual 51 31
53: 9(bvec2) CompositeConstruct 52 52 53: 9(bvec2) CompositeConstruct 52 52
54: 23(ivec2) Select 53 34 32 54: 23(ivec2) Select 53 34 33
55: 36(ptr) AccessChain 26 28 55: 36(ptr) AccessChain 26 28
Store 55 54 Store 55 54
Branch 48 Branch 48
...@@ -106,7 +106,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre ...@@ -106,7 +106,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre
Store 62(param) 66 Store 62(param) 66
68: 2 FunctionCall 14(foo(vb4;vb2;) 62(param) 67(param) 68: 2 FunctionCall 14(foo(vb4;vb2;) 62(param) 67(param)
69: 9(bvec2) Load 67(param) 69: 9(bvec2) Load 67(param)
70: 23(ivec2) Select 69 34 32 70: 23(ivec2) Select 69 34 33
71: 36(ptr) AccessChain 26 28 71: 36(ptr) AccessChain 26 28
Store 71 70 Store 71 70
Branch 61 Branch 61
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment