Refine the code and address comments

This commit is contained in:
qining 2016-04-12 23:16:20 -04:00
parent e24aa5edbb
commit 189b2033a4
3 changed files with 7 additions and 16 deletions

View File

@ -3306,22 +3306,11 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Dec
break;
case glslang::EOpConvUintToInt:
if (builder.isInSpecConstCodeGenMode()) {
// Build zero scalar or vector for OpIAdd to do the conversion when
// generating for OpSpecConstantOp instruction.
zero = builder.makeIntConstant(0);
zero = makeSmearedConstant(zero, vectorSize);
}
// Don't 'break' here as this case should be grouped together with
// EOpConvIntToUint when generating normal run-time conversion
// instruction.
case glslang::EOpConvIntToUint:
if (builder.isInSpecConstCodeGenMode()) {
// Build zero scalar or vector for OpIAdd.
if (zero == 0) {
zero = builder.makeUintConstant(0);
zero = makeSmearedConstant(zero, vectorSize);
}
zero = builder.makeUintConstant(0);
zero = makeSmearedConstant(zero, vectorSize);
// Use OpIAdd, instead of OpBitcast to do the conversion when
// generating for OpSpecConstantOp instruction.
return builder.createBinOp(spv::OpIAdd, destType, operand, zero);

View File

@ -1216,7 +1216,9 @@ Id Builder::createTriOp(Op opCode, Id typeId, Id op1, Id op2, Id op3)
// generation mode.
if (generatingOpCodeForSpecConst) {
std::vector<Id> operands(3);
operands[0] = op1; operands[1] = op2; operands[2] = op3;
operands[0] = op1;
operands[1] = op2;
operands[2] = op3;
return createSpecConstantOp(
opCode, typeId, operands, std::vector<Id>());
}

View File

@ -50,7 +50,7 @@ Linked vertex stage:
48: 41(int) Constant 1
49: 41(int) SpecConstantOp 169 45 48 44
50: 41(int) SpecConstantOp 128 43 44
51: 6(int) SpecConstantOp 128 42 12
51: 6(int) SpecConstantOp 128 42 44
52: 6(int) SpecConstantOp 126 19
53: 6(int) SpecConstantOp 200 19
54: 6(int) SpecConstantOp 128 19 20
@ -104,7 +104,7 @@ Linked vertex stage:
102: 88(ivec4) ConstantComposite 48 48 48 48
103: 88(ivec4) SpecConstantOp 169 97 102 96
104: 88(ivec4) SpecConstantOp 128 87 96
105: 85(ivec4) SpecConstantOp 128 91 99
105: 85(ivec4) SpecConstantOp 128 91 96
106: 85(ivec4) SpecConstantOp 200 87
107: 85(ivec4) SpecConstantOp 126 87
108: 85(ivec4) ConstantComposite 20 20 20 20