From 2359bd0a1dae6deae4e130fd34571d3c700ad91b Mon Sep 17 00:00:00 2001
From: John Kessenich <cepheus@frii.com>
Date: Sun, 6 Dec 2015 19:29:11 -0700
Subject: [PATCH] SPV: Fix extra operands when using the "struct" form of a
 built-in taking an 'out' param.

---
 SPIRV/GlslangToSpv.cpp               | 6 ++++--
 Test/baseResults/spv.intOps.vert.out | 4 ++--
 glslang/Include/revision.h           | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index 41b6c5daf..1d77b02cc 100755
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -2892,9 +2892,11 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
     }
 
     spv::Id id = 0;
-    if (libCall >= 0)
+    if (libCall >= 0) {
+        while (consumedOperands < (int)operands.size())
+            operands.pop_back();
         id = builder.createBuiltinCall(precision, typeId, stdBuiltins, libCall, operands);
-    else {
+    } else {
         switch (consumedOperands) {
         case 0:
             // should all be handled by visitAggregate and createNoArgOperation
diff --git a/Test/baseResults/spv.intOps.vert.out b/Test/baseResults/spv.intOps.vert.out
index 7a57ac44c..649c05ab4 100644
--- a/Test/baseResults/spv.intOps.vert.out
+++ b/Test/baseResults/spv.intOps.vert.out
@@ -193,7 +193,7 @@ Linked vertex stage:
               97:    7(ivec4) IAdd 96 95
                               Store 9(iout) 97
              101:   98(fvec3) Load 100(v3)
-             106:105(ResType) ExtInst 1(GLSL.std.450) 52(FrexpStruct) 101 104(i3out)
+             106:105(ResType) ExtInst 1(GLSL.std.450) 52(FrexpStruct) 101
              107:  102(ivec3) CompositeExtract 106 1
                               Store 104(i3out) 107
              108:   98(fvec3) CompositeExtract 106 0
@@ -211,7 +211,7 @@ Linked vertex stage:
              119:    7(ivec4) VectorShuffle 118 117 4 5 6 3
                               Store 9(iout) 119
              122:   18(float) Load 121(v1)
-             126:125(ResType) ExtInst 1(GLSL.std.450) 52(FrexpStruct) 122 124(i1out)
+             126:125(ResType) ExtInst 1(GLSL.std.450) 52(FrexpStruct) 122
              127:      6(int) CompositeExtract 126 1
                               Store 124(i1out) 127
              128:   18(float) CompositeExtract 126 0
diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h
index 647ba850a..3d84f80d0 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 "SPIRV99.822"
+#define GLSLANG_REVISION "SPIRV99.823"
 #define GLSLANG_DATE "06-Dec-2015"
-- 
GitLab