From 56bab0483a8aca11ed76815cb37260e8ce60df52 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Wed, 16 Sep 2015 10:54:31 -0600 Subject: [PATCH] SPV: Minor corrections to previous big merge for images and atomics. --- SPIRV/GlslangToSpv.cpp | 48 +++++++--------------- SPIRV/doc.cpp | 2 - Test/baseResults/spv.do-simple.vert.out | 12 +++--- .../spv.do-while-continue-break.vert.out | 16 ++++---- Test/baseResults/spv.doWhileLoop.frag.out | 12 +++--- Test/baseResults/spv.image.frag.out | 8 ++-- Test/baseResults/spv.loopsArtificial.frag.out | 28 ++++++------- glslang/Include/revision.h | 4 +- 8 files changed, 54 insertions(+), 76 deletions(-) diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 72292e6..0a61a2b 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -844,9 +844,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt builder.setAccessChainRValue(result); return false; - } - else if (node->getOp() == glslang::EOpImageStore) - { + } else if (node->getOp() == glslang::EOpImageStore) { // "imageStore" is a special case, which has no result return false; } @@ -1819,45 +1817,27 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO // Check for image functions other than queries if (node->isImage()) { - // Process image load/store - if (node->getOp() == glslang::EOpImageLoad || - node->getOp() == glslang::EOpImageStore) { - std::vector operands; - auto opIt = arguments.begin(); - operands.push_back(*(opIt++)); + std::vector operands; + auto opIt = arguments.begin(); + operands.push_back(*(opIt++)); + operands.push_back(*(opIt++)); + if (node->getOp() == glslang::EOpImageStore) operands.push_back(*(opIt++)); - if (sampler.ms) { - // For MS, image operand mask has to be added to indicate the presence of "sample" operand. - spv::Id sample = *(opIt++); - for (; opIt != arguments.end(); ++opIt) - operands.push_back(*opIt); - - operands.push_back(spv::ImageOperandsSampleMask); - operands.push_back(sample); - } else { - for (; opIt != arguments.end(); ++opIt) - operands.push_back(*opIt); - } - - if (node->getOp() == glslang::EOpImageLoad) - return builder.createOp(spv::OpImageRead, convertGlslangToSpvType(node->getType()), operands); - else { - builder.createNoResultOp(spv::OpImageWrite, operands); - return spv::NoResult; - } + // TODO: add 'sample' operand + if (node->getOp() == glslang::EOpImageLoad) { + return builder.createOp(spv::OpImageRead, convertGlslangToSpvType(node->getType()), operands); + } else if (node->getOp() == glslang::EOpImageStore) { + builder.createNoResultOp(spv::OpImageWrite, operands); + return spv::NoResult; } else { // Process image atomic operations // GLSL "IMAGE_PARAMS" will involve in constructing an image texel pointer and this pointer, // as the first source operand, is required by SPIR-V atomic operations. - std::vector imageParams; - auto opIt = arguments.begin(); - imageParams.push_back(*(opIt++)); - imageParams.push_back(*(opIt++)); - imageParams.push_back(sampler.ms ? *(opIt++) : 0); // For non-MS, the value should be 0 + operands.push_back(sampler.ms ? *(opIt++) : 0); // For non-MS, the value should be 0 spv::Id resultTypeId = builder.makePointer(spv::StorageClassImage, convertGlslangToSpvType(node->getType())); - spv::Id pointer = builder.createOp(spv::OpImageTexelPointer, resultTypeId, imageParams); + spv::Id pointer = builder.createOp(spv::OpImageTexelPointer, resultTypeId, operands); std::vector operands; operands.push_back(pointer); diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp index ccc163d..ff0d780 100755 --- a/SPIRV/doc.cpp +++ b/SPIRV/doc.cpp @@ -1635,12 +1635,10 @@ void Parameterize() InstructionDesc[OpImageRead].operands.push(OperandId, "'Image'"); InstructionDesc[OpImageRead].operands.push(OperandId, "'Coordinate'"); - InstructionDesc[OpImageRead].operands.push(OperandOptionalImage, ""); InstructionDesc[OpImageWrite].operands.push(OperandId, "'Image'"); InstructionDesc[OpImageWrite].operands.push(OperandId, "'Coordinate'"); InstructionDesc[OpImageWrite].operands.push(OperandId, "'Texel'"); - InstructionDesc[OpImageWrite].operands.push(OperandOptionalImage, ""); InstructionDesc[OpImageSampleImplicitLod].operands.push(OperandId, "'Sampled Image'"); InstructionDesc[OpImageSampleImplicitLod].operands.push(OperandId, "'Coordinate'"); diff --git a/Test/baseResults/spv.do-simple.vert.out b/Test/baseResults/spv.do-simple.vert.out index b33dae8..be11114 100755 --- a/Test/baseResults/spv.do-simple.vert.out +++ b/Test/baseResults/spv.do-simple.vert.out @@ -25,11 +25,11 @@ Linked vertex stage: 6: TypeInt 32 1 7: TypePointer Function 6(int) 9: 6(int) Constant 0 - 13: TypeBool - 15: 13(bool) ConstantTrue + 14: TypeBool + 15: 14(bool) ConstantTrue 19: 6(int) Constant 10 23: 6(int) Constant 1 - 25: 13(bool) ConstantFalse + 25: 14(bool) ConstantFalse 26: TypePointer Input 6(int) 27(gl_VertexID): 26(ptr) Variable Input 28(gl_InstanceID): 26(ptr) Variable Input @@ -39,15 +39,15 @@ Linked vertex stage: Store 8(i) 9 Branch 10 10: Label - 14: 13(bool) Phi 15 5 25 12 + 13: 14(bool) Phi 15 5 25 12 LoopMerge 11 None Branch 16 16: Label SelectionMerge 12 None - BranchConditional 14 12 17 + BranchConditional 13 12 17 17: Label 18: 6(int) Load 8(i) - 20: 13(bool) SLessThan 18 19 + 20: 14(bool) SLessThan 18 19 SelectionMerge 21 None BranchConditional 20 21 11 21: Label diff --git a/Test/baseResults/spv.do-while-continue-break.vert.out b/Test/baseResults/spv.do-while-continue-break.vert.out index edca3d4..5687acd 100755 --- a/Test/baseResults/spv.do-while-continue-break.vert.out +++ b/Test/baseResults/spv.do-while-continue-break.vert.out @@ -32,12 +32,12 @@ Linked vertex stage: 6: TypeInt 32 1 7: TypePointer Function 6(int) 9: 6(int) Constant 0 - 13: TypeBool - 15: 13(bool) ConstantTrue + 14: TypeBool + 15: 14(bool) ConstantTrue 19: 6(int) Constant 1 21: 6(int) Constant 19 26: 6(int) Constant 2 - 31: 13(bool) ConstantFalse + 31: 14(bool) ConstantFalse 35: 6(int) Constant 5 40: 6(int) Constant 3 43: 6(int) Constant 42 @@ -59,17 +59,17 @@ Linked vertex stage: Store 8(i) 9 Branch 10 10: Label - 14: 13(bool) Phi 15 5 31 28 31 38 + 13: 14(bool) Phi 15 5 31 28 31 38 LoopMerge 11 None Branch 16 16: Label SelectionMerge 12 None - BranchConditional 14 12 17 + BranchConditional 13 12 17 17: Label 18: 6(int) Load 8(i) 20: 6(int) IAdd 18 19 Store 8(i) 20 - 22: 13(bool) SLessThan 20 21 + 22: 14(bool) SLessThan 20 21 SelectionMerge 23 None BranchConditional 22 23 11 23: Label @@ -77,7 +77,7 @@ Linked vertex stage: 12: Label Store 24(A) 9 25: 6(int) Load 8(i) - 27: 13(bool) IEqual 25 26 + 27: 14(bool) IEqual 25 26 SelectionMerge 29 None BranchConditional 27 28 29 28: Label @@ -88,7 +88,7 @@ Linked vertex stage: Branch 29 29: Label 34: 6(int) Load 8(i) - 36: 13(bool) IEqual 34 35 + 36: 14(bool) IEqual 34 35 SelectionMerge 38 None BranchConditional 36 37 38 37: Label diff --git a/Test/baseResults/spv.doWhileLoop.frag.out b/Test/baseResults/spv.doWhileLoop.frag.out index b895177..1a204b0 100755 --- a/Test/baseResults/spv.doWhileLoop.frag.out +++ b/Test/baseResults/spv.doWhileLoop.frag.out @@ -28,13 +28,13 @@ Linked fragment stage: 8: TypePointer Function 7(fvec4) 10: TypePointer Input 7(fvec4) 11(BaseColor): 10(ptr) Variable Input - 16: TypeBool - 18: 16(bool) ConstantTrue + 17: TypeBool + 18: 17(bool) ConstantTrue 23: TypePointer UniformConstant 6(float) 24(d): 23(ptr) Variable UniformConstant 28: TypePointer UniformConstant 7(fvec4) 29(bigColor): 28(ptr) Variable UniformConstant - 33: 16(bool) ConstantFalse + 33: 17(bool) ConstantFalse 34: TypePointer Output 7(fvec4) 35(gl_FragColor): 34(ptr) Variable Output 4(main): 2 Function None 3 @@ -44,17 +44,17 @@ Linked fragment stage: Store 9(color) 12 Branch 13 13: Label - 17: 16(bool) Phi 18 5 33 15 + 16: 17(bool) Phi 18 5 33 15 LoopMerge 14 None Branch 19 19: Label SelectionMerge 15 None - BranchConditional 17 15 20 + BranchConditional 16 15 20 20: Label 21: 7(fvec4) Load 9(color) 22: 6(float) CompositeExtract 21 0 25: 6(float) Load 24(d) - 26: 16(bool) FOrdLessThan 22 25 + 26: 17(bool) FOrdLessThan 22 25 SelectionMerge 27 None BranchConditional 26 27 14 27: Label diff --git a/Test/baseResults/spv.image.frag.out b/Test/baseResults/spv.image.frag.out index f686ee3..f5874ed 100644 --- a/Test/baseResults/spv.image.frag.out +++ b/Test/baseResults/spv.image.frag.out @@ -329,24 +329,24 @@ Linked fragment stage: ImageWrite 209 210 211 212: 95 Load 97(i2DMS) 213: 27(ivec2) Load 143(ic2D) - 215: 126(fvec4) ImageRead 212 213 214 + 215: 126(fvec4) ImageRead 212 213 216: 126(fvec4) Load 128(v) 217: 126(fvec4) FAdd 216 215 Store 128(v) 217 218: 95 Load 97(i2DMS) 219: 27(ivec2) Load 143(ic2D) 221: 126(fvec4) Load 128(v) - ImageWrite 218 219 221 220 + ImageWrite 218 219 220 222: 105 Load 107(i2DMSArray) 223: 7(ivec3) Load 153(ic3D) - 225: 126(fvec4) ImageRead 222 223 224 + 225: 126(fvec4) ImageRead 222 223 226: 126(fvec4) Load 128(v) 227: 126(fvec4) FAdd 226 225 Store 128(v) 227 228: 105 Load 107(i2DMSArray) 229: 7(ivec3) Load 153(ic3D) 231: 126(fvec4) Load 128(v) - ImageWrite 228 229 231 230 + ImageWrite 228 229 230 Store 234(ui) 235 239: 6(int) Load 133(ic1D) 242: 241(ptr) ImageTexelPointer 238(ii1D) 239 0 diff --git a/Test/baseResults/spv.loopsArtificial.frag.out b/Test/baseResults/spv.loopsArtificial.frag.out index 74cea2d..3871d85 100755 --- a/Test/baseResults/spv.loopsArtificial.frag.out +++ b/Test/baseResults/spv.loopsArtificial.frag.out @@ -117,15 +117,15 @@ Linked fragment stage: 8: TypePointer Function 7(fvec4) 10: TypePointer Input 7(fvec4) 11(BaseColor): 10(ptr) Variable Input - 16: TypeBool - 18: 16(bool) ConstantTrue + 17: TypeBool + 18: 17(bool) ConstantTrue 23: TypePointer UniformConstant 6(float) 24(d4): 23(ptr) Variable UniformConstant 28: TypePointer UniformConstant 7(fvec4) 29(bigColor4): 28(ptr) Variable UniformConstant 39: 6(float) Constant 1073741824 53: 6(float) Constant 1065353216 - 57: 16(bool) ConstantFalse + 57: 17(bool) ConstantFalse 83(d13): 23(ptr) Variable UniformConstant 147: TypePointer Output 7(fvec4) 148(gl_FragColor): 147(ptr) Variable Output @@ -181,17 +181,17 @@ Linked fragment stage: Store 9(color) 12 Branch 13 13: Label - 17: 16(bool) Phi 18 5 57 49 57 64 + 16: 17(bool) Phi 18 5 57 49 57 64 LoopMerge 14 None Branch 19 19: Label SelectionMerge 15 None - BranchConditional 17 15 20 + BranchConditional 16 15 20 20: Label 21: 7(fvec4) Load 9(color) 22: 6(float) CompositeExtract 21 2 25: 6(float) Load 24(d4) - 26: 16(bool) FOrdLessThan 22 25 + 26: 17(bool) FOrdLessThan 22 25 SelectionMerge 27 None BranchConditional 26 27 14 27: Label @@ -204,7 +204,7 @@ Linked fragment stage: 33: 7(fvec4) Load 9(color) 34: 6(float) CompositeExtract 33 0 35: 6(float) Load 24(d4) - 36: 16(bool) FOrdLessThan 34 35 + 36: 17(bool) FOrdLessThan 34 35 SelectionMerge 38 None BranchConditional 36 37 38 37: Label @@ -217,7 +217,7 @@ Linked fragment stage: 45: 7(fvec4) Load 9(color) 46: 6(float) CompositeExtract 45 2 47: 6(float) Load 24(d4) - 48: 16(bool) FOrdLessThan 46 47 + 48: 17(bool) FOrdLessThan 46 47 SelectionMerge 50 None BranchConditional 48 49 50 49: Label @@ -234,7 +234,7 @@ Linked fragment stage: 59: 7(fvec4) Load 9(color) 60: 6(float) CompositeExtract 59 1 61: 6(float) Load 24(d4) - 62: 16(bool) FOrdLessThan 60 61 + 62: 17(bool) FOrdLessThan 60 61 SelectionMerge 64 None BranchConditional 62 63 71 63: Label @@ -263,14 +263,14 @@ Linked fragment stage: 81: 7(fvec4) Load 9(color) 82: 6(float) CompositeExtract 81 3 84: 6(float) Load 83(d13) - 85: 16(bool) FOrdLessThan 82 84 + 85: 17(bool) FOrdLessThan 82 84 LoopMerge 79 None BranchConditional 85 80 79 80: Label 86: 7(fvec4) Load 9(color) 87: 6(float) CompositeExtract 86 2 88: 6(float) Load 83(d13) - 89: 16(bool) FOrdLessThan 87 88 + 89: 17(bool) FOrdLessThan 87 88 SelectionMerge 91 None BranchConditional 89 90 95 90: Label @@ -293,7 +293,7 @@ Linked fragment stage: 102: 7(fvec4) Load 9(color) 103: 6(float) CompositeExtract 102 0 104: 6(float) Load 24(d4) - 105: 16(bool) FOrdLessThan 103 104 + 105: 17(bool) FOrdLessThan 103 104 SelectionMerge 107 None BranchConditional 105 106 107 106: Label @@ -306,7 +306,7 @@ Linked fragment stage: 113: 7(fvec4) Load 9(color) 114: 6(float) CompositeExtract 113 2 115: 6(float) Load 24(d4) - 116: 16(bool) FOrdLessThan 114 115 + 116: 17(bool) FOrdLessThan 114 115 SelectionMerge 118 None BranchConditional 116 117 118 117: Label @@ -323,7 +323,7 @@ Linked fragment stage: 125: 7(fvec4) Load 9(color) 126: 6(float) CompositeExtract 125 1 127: 6(float) Load 24(d4) - 128: 16(bool) FOrdLessThan 126 127 + 128: 17(bool) FOrdLessThan 126 127 SelectionMerge 130 None BranchConditional 128 129 137 129: Label diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index aa5dcd9..570012a 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // For the version, it uses the latest git tag followed by the number of commits. // For the date, it uses the current date (when then script is run). -#define GLSLANG_REVISION "3.0.756" -#define GLSLANG_DATE "15-Sep-2015" +#define GLSLANG_REVISION "3.0.769" +#define GLSLANG_DATE "16-Sep-2015" -- 2.7.4