From 189b2033a44ae231fd6045f23778771cd6986f9c Mon Sep 17 00:00:00 2001 From: qining Date: Tue, 12 Apr 2016 23:16:20 -0400 Subject: [PATCH] Refine the code and address comments --- SPIRV/GlslangToSpv.cpp | 15 ++------------- SPIRV/SpvBuilder.cpp | 4 +++- .../spv.specConstantOperations.vert.out | 4 ++-- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 0240d8d4..39f3b8bc 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -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); diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index df87e9c2..7896deb4 100644 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -1216,7 +1216,9 @@ Id Builder::createTriOp(Op opCode, Id typeId, Id op1, Id op2, Id op3) // generation mode. if (generatingOpCodeForSpecConst) { std::vector 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()); } diff --git a/Test/baseResults/spv.specConstantOperations.vert.out b/Test/baseResults/spv.specConstantOperations.vert.out index 7544b32f..eedbea5c 100644 --- a/Test/baseResults/spv.specConstantOperations.vert.out +++ b/Test/baseResults/spv.specConstantOperations.vert.out @@ -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