Browse Source

Updated glslang.

Branimir Karadžić 7 years ago
parent
commit
1462079d39
44 changed files with 1016 additions and 965 deletions
  1. 140 74
      3rdparty/glslang/SPIRV/GlslangToSpv.cpp
  2. 44 13
      3rdparty/glslang/SPIRV/SpvBuilder.cpp
  3. 9 7
      3rdparty/glslang/SPIRV/SpvBuilder.h
  4. 5 0
      3rdparty/glslang/SPIRV/doc.cpp
  5. 1 2
      3rdparty/glslang/Test/baseResults/310.comp.out
  6. 1 6
      3rdparty/glslang/Test/baseResults/atomic_uint.frag.out
  7. 5 3
      3rdparty/glslang/Test/baseResults/glspv.frag.out
  8. 161 199
      3rdparty/glslang/Test/baseResults/hlsl.conditional.frag.out
  9. 233 304
      3rdparty/glslang/Test/baseResults/hlsl.getsampleposition.dx10.frag.out
  10. 4 4
      3rdparty/glslang/Test/baseResults/hlsl.implicitBool.frag.out
  11. 47 57
      3rdparty/glslang/Test/baseResults/hlsl.intrinsics.lit.frag.out
  12. 43 54
      3rdparty/glslang/Test/baseResults/hlsl.type.identifier.frag.out
  13. 4 4
      3rdparty/glslang/Test/baseResults/link1.vk.frag.out
  14. 1 2
      3rdparty/glslang/Test/baseResults/specExamples.vert.out
  15. 24 24
      3rdparty/glslang/Test/baseResults/spv.400.frag.out
  16. 12 12
      3rdparty/glslang/Test/baseResults/spv.Operations.frag.out
  17. 12 12
      3rdparty/glslang/Test/baseResults/spv.bitCast.frag.out
  18. 54 54
      3rdparty/glslang/Test/baseResults/spv.conversion.frag.out
  19. 12 9
      3rdparty/glslang/Test/baseResults/spv.debugInfo.frag.out
  20. 13 4
      3rdparty/glslang/Test/baseResults/spv.glsl.register.noautoassign.frag.out
  21. 8 8
      3rdparty/glslang/Test/baseResults/spv.sparseTexture.frag.out
  22. 8 8
      3rdparty/glslang/Test/baseResults/spv.sparseTextureClamp.frag.out
  23. 33 33
      3rdparty/glslang/Test/baseResults/spv.types.frag.out
  24. 14 1
      3rdparty/glslang/Test/baseResults/vulkan.frag.out
  25. 11 1
      3rdparty/glslang/Test/baseResults/vulkan.vert.out
  26. 4 3
      3rdparty/glslang/Test/glspv.frag
  27. 2 2
      3rdparty/glslang/Test/glspv.vert
  28. 1 1
      3rdparty/glslang/Test/link2.vk.frag
  29. 1 1
      3rdparty/glslang/Test/runtests
  30. 13 13
      3rdparty/glslang/Test/spv.glsl.register.noautoassign.frag
  31. 2 2
      3rdparty/glslang/Test/spv.targetOpenGL.vert
  32. 5 5
      3rdparty/glslang/Test/vulkan.frag
  33. 8 2
      3rdparty/glslang/glslang/Include/intermediate.h
  34. 8 1
      3rdparty/glslang/glslang/MachineIndependent/Intermediate.cpp
  35. 17 5
      3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp
  36. 2 0
      3rdparty/glslang/glslang/MachineIndependent/intermOut.cpp
  37. 15 10
      3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp
  38. 10 8
      3rdparty/glslang/glslang/MachineIndependent/linkValidate.cpp
  39. 1 1
      3rdparty/glslang/glslang/MachineIndependent/localintermediate.h
  40. 1 1
      3rdparty/glslang/gtests/Config.FromFile.cpp
  41. 3 2
      3rdparty/glslang/gtests/Hlsl.FromFile.cpp
  42. 5 4
      3rdparty/glslang/gtests/Spv.FromFile.cpp
  43. 12 4
      3rdparty/glslang/gtests/TestFixture.h
  44. 7 5
      3rdparty/glslang/hlsl/hlslParseHelper.cpp

+ 140 - 74
3rdparty/glslang/SPIRV/GlslangToSpv.cpp

@@ -777,7 +777,7 @@ spv::LoopControlMask TGlslangToSpvTraverser::TranslateLoopControl(const glslang:
         control = control | spv::LoopControlDontUnrollMask;
     if (loopNode.getUnroll())
         control = control | spv::LoopControlUnrollMask;
-    if (loopNode.getLoopDependency() == glslang::TIntermLoop::dependencyInfinite)
+    if (unsigned(loopNode.getLoopDependency()) == glslang::TIntermLoop::dependencyInfinite)
         control = control | spv::LoopControlDependencyInfiniteMask;
     else if (loopNode.getLoopDependency() > 0) {
         control = control | spv::LoopControlDependencyLengthMask;
@@ -1973,18 +1973,29 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
 // next layer copies r-values into memory to use the access-chain mechanism
 bool TGlslangToSpvTraverser::visitSelection(glslang::TVisit /* visit */, glslang::TIntermSelection* node)
 {
-    // See if it simple and safe to generate OpSelect instead of using control flow.
-    // Crucially, side effects must be avoided, and there are performance trade-offs.
-    // Return true if good idea (and safe) for OpSelect, false otherwise.
-    const auto selectPolicy = [&]() -> bool {
-        if ((!node->getType().isScalar() && !node->getType().isVector()) ||
-            node->getBasicType() == glslang::EbtVoid)
-            return false;
-
+    // See if it simple and safe, or required, to execute both sides.
+    // Crucially, side effects must be either semantically required or avoided,
+    // and there are performance trade-offs.
+    // Return true if required or a good idea (and safe) to execute both sides,
+    // false otherwise.
+    const auto bothSidesPolicy = [&]() -> bool {
+        // do we have both sides?
         if (node->getTrueBlock()  == nullptr ||
             node->getFalseBlock() == nullptr)
             return false;
 
+        // required? (unless we write additional code to look for side effects
+        // and make performance trade-offs if none are present)
+        if (!node->getShortCircuit())
+            return true;
+
+        // if not required to execute both, decide based on performance/practicality...
+
+        // see if OpSelect can handle it
+        if ((!node->getType().isScalar() && !node->getType().isVector()) ||
+            node->getBasicType() == glslang::EbtVoid)
+            return false;
+
         assert(node->getType() == node->getTrueBlock() ->getAsTyped()->getType() &&
                node->getType() == node->getFalseBlock()->getAsTyped()->getType());
 
@@ -1997,10 +2008,14 @@ bool TGlslangToSpvTraverser::visitSelection(glslang::TVisit /* visit */, glslang
                operandOkay(node->getFalseBlock()->getAsTyped());
     };
 
-    // Emit OpSelect for this selection.
-    const auto handleAsOpSelect = [&]() {
-        node->getCondition()->traverse(this);
-        spv::Id condition = accessChainLoad(node->getCondition()->getType());
+    spv::Id result = spv::NoResult; // upcoming result selecting between trueValue and falseValue
+    // emit the condition before doing anything with selection
+    node->getCondition()->traverse(this);
+    spv::Id condition = accessChainLoad(node->getCondition()->getType());
+
+    // Find a way of executing both sides and selecting the right result.
+    const auto executeBothSides = [&]() -> void {
+        // execute both sides
         node->getTrueBlock()->traverse(this);
         spv::Id trueValue = accessChainLoad(node->getTrueBlock()->getAsTyped()->getType());
         node->getFalseBlock()->traverse(this);
@@ -2008,72 +2023,98 @@ bool TGlslangToSpvTraverser::visitSelection(glslang::TVisit /* visit */, glslang
 
         builder.setLine(node->getLoc().line);
 
-        // smear condition to vector, if necessary (AST is always scalar)
-        if (builder.isVector(trueValue))
-            condition = builder.smearScalar(spv::NoPrecision, condition, 
-                                            builder.makeVectorType(builder.makeBoolType(),
-                                                                   builder.getNumComponents(trueValue)));
+        // done if void
+        if (node->getBasicType() == glslang::EbtVoid)
+            return;
 
-        spv::Id select = builder.createTriOp(spv::OpSelect,
-                                             convertGlslangToSpvType(node->getType()), condition,
-                                                                     trueValue, falseValue);
-        builder.clearAccessChain();
-        builder.setAccessChainRValue(select);
-    };
+        // emit code to select between trueValue and falseValue
 
-    // Try for OpSelect
+        // see if OpSelect can handle it
+        if (node->getType().isScalar() || node->getType().isVector()) {
+            // Emit OpSelect for this selection.
 
-    if (selectPolicy()) {
-        SpecConstantOpModeGuard spec_constant_op_mode_setter(&builder);
-        if (node->getType().getQualifier().isSpecConstant())
-            spec_constant_op_mode_setter.turnOnSpecConstantOpMode();
+            // smear condition to vector, if necessary (AST is always scalar)
+            if (builder.isVector(trueValue))
+                condition = builder.smearScalar(spv::NoPrecision, condition, 
+                                                builder.makeVectorType(builder.makeBoolType(),
+                                                                       builder.getNumComponents(trueValue)));
 
-        handleAsOpSelect();
-        return false;
-    }
+            // OpSelect
+            result = builder.createTriOp(spv::OpSelect,
+                                         convertGlslangToSpvType(node->getType()), condition,
+                                                                 trueValue, falseValue);
 
-    // Instead, emit control flow...    
-    // Don't handle results as temporaries, because there will be two names
-    // and better to leave SSA to later passes.
-    spv::Id result = (node->getBasicType() == glslang::EbtVoid)
-                        ? spv::NoResult
-                        : builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(node->getType()));
+            builder.clearAccessChain();
+            builder.setAccessChainRValue(result);
+        } else {
+            // We need control flow to select the result.
+            // TODO: Once SPIR-V OpSelect allows arbitrary types, eliminate this path.
+            result = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(node->getType()));
 
-    // emit the condition before doing anything with selection
-    node->getCondition()->traverse(this);
+            // Selection control:
+            const spv::SelectionControlMask control = TranslateSelectionControl(*node);
 
-    // Selection control:
-    const spv::SelectionControlMask control = TranslateSelectionControl(*node);
+            // make an "if" based on the value created by the condition
+            spv::Builder::If ifBuilder(condition, control, builder);
 
-    // make an "if" based on the value created by the condition
-    spv::Builder::If ifBuilder(accessChainLoad(node->getCondition()->getType()), control, builder);
+            // emit the "then" statement
+            builder.createStore(trueValue, result);
+            ifBuilder.makeBeginElse();
+            // emit the "else" statement
+            builder.createStore(falseValue, result);
 
-    // emit the "then" statement
-    if (node->getTrueBlock() != nullptr) {
-        node->getTrueBlock()->traverse(this);
-        if (result != spv::NoResult)
-             builder.createStore(accessChainLoad(node->getTrueBlock()->getAsTyped()->getType()), result);
-    }
+            // finish off the control flow
+            ifBuilder.makeEndIf();
 
-    if (node->getFalseBlock() != nullptr) {
-        ifBuilder.makeBeginElse();
-        // emit the "else" statement
-        node->getFalseBlock()->traverse(this);
-        if (result != spv::NoResult)
-            builder.createStore(accessChainLoad(node->getFalseBlock()->getAsTyped()->getType()), result);
-    }
+            builder.clearAccessChain();
+            builder.setAccessChainLValue(result);
+        }
+    };
 
-    // finish off the control flow
-    ifBuilder.makeEndIf();
+    // Execute the one side needed, as per the condition
+    const auto executeOneSide = [&]() {
+        // Always emit control flow.
+        if (node->getBasicType() != glslang::EbtVoid)
+            result = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(node->getType()));
 
-    if (result != spv::NoResult) {
-        // GLSL only has r-values as the result of a :?, but
-        // if we have an l-value, that can be more efficient if it will
-        // become the base of a complex r-value expression, because the
-        // next layer copies r-values into memory to use the access-chain mechanism
-        builder.clearAccessChain();
-        builder.setAccessChainLValue(result);
-    }
+        // Selection control:
+        const spv::SelectionControlMask control = TranslateSelectionControl(*node);
+
+        // make an "if" based on the value created by the condition
+        spv::Builder::If ifBuilder(condition, control, builder);
+
+        // emit the "then" statement
+        if (node->getTrueBlock() != nullptr) {
+            node->getTrueBlock()->traverse(this);
+            if (result != spv::NoResult)
+                builder.createStore(accessChainLoad(node->getTrueBlock()->getAsTyped()->getType()), result);
+        }
+
+        if (node->getFalseBlock() != nullptr) {
+            ifBuilder.makeBeginElse();
+            // emit the "else" statement
+            node->getFalseBlock()->traverse(this);
+            if (result != spv::NoResult)
+                builder.createStore(accessChainLoad(node->getFalseBlock()->getAsTyped()->getType()), result);
+        }
+
+        // finish off the control flow
+        ifBuilder.makeEndIf();
+
+        if (result != spv::NoResult) {
+            builder.clearAccessChain();
+            builder.setAccessChainLValue(result);
+        }
+    };
+
+    // Try for OpSelect (or a requirement to execute both sides)
+    if (bothSidesPolicy()) {
+        SpecConstantOpModeGuard spec_constant_op_mode_setter(&builder);
+        if (node->getType().getQualifier().isSpecConstant())
+            spec_constant_op_mode_setter.turnOnSpecConstantOpMode();
+        executeBothSides();
+    } else
+        executeOneSide();
 
     return false;
 }
@@ -2627,7 +2668,8 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
                 builder.addMemberDecoration(spvType, member, spv::DecorationLocation, memberQualifier.layoutLocation);
 
             if (qualifier.hasLocation())      // track for upcoming inheritance
-                locationOffset += glslangIntermediate->computeTypeLocationSize(glslangMember);
+                locationOffset += glslangIntermediate->computeTypeLocationSize(
+                                                glslangMember, glslangIntermediate->getStage());
 
             // component, XFB, others
             if (glslangMember.getQualifier().hasComponent())
@@ -3229,8 +3271,6 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
 
     builder.setLine(node->getLoc().line);
 
-    auto resultType = [&node,this]{ return convertGlslangToSpvType(node->getType()); };
-
     // Process a GLSL texturing op (will be SPV image)
     const glslang::TSampler sampler = node->getAsAggregate() ? node->getAsAggregate()->getSequence()[0]->getAsTyped()->getType().getSampler()
                                                              : node->getAsUnaryNode()->getOperand()->getAsTyped()->getType().getSampler();
@@ -3279,6 +3319,20 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
         }
     }
 
+    int components = node->getType().getVectorSize();
+
+    if (node->getOp() == glslang::EOpTextureFetch) {
+        // These must produce 4 components, per SPIR-V spec.  We'll add a conversion constructor if needed.
+        // This will only happen through the HLSL path for operator[], so we do not have to handle e.g.
+        // the EOpTexture/Proj/Lod/etc family.  It would be harmless to do so, but would need more logic
+        // here around e.g. which ones return scalars or other types.
+        components = 4;
+    }
+
+    glslang::TType returnType(node->getType().getBasicType(), glslang::EvqTemporary, components);
+
+    auto resultType = [&returnType,this]{ return convertGlslangToSpvType(returnType); };
+
     // Check for image functions other than queries
     if (node->isImage()) {
         std::vector<spv::Id> operands;
@@ -3325,9 +3379,14 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
             if (builder.getImageTypeFormat(builder.getImageType(operands.front())) == spv::ImageFormatUnknown)
                 builder.addCapability(spv::CapabilityStorageImageReadWithoutFormat);
 
-            spv::Id result = builder.createOp(spv::OpImageRead, resultType(), operands);
-            builder.setPrecision(result, precision);
-            return result;
+            std::vector<spv::Id> result = { builder.createOp(spv::OpImageRead, resultType(), operands) };
+            builder.setPrecision(result[0], precision);
+
+            // If needed, add a conversion constructor to the proper size.
+            if (components != node->getType().getVectorSize())
+                result[0] = builder.createConstructor(precision, result, convertGlslangToSpvType(node->getType()));
+
+            return result[0];
 #ifdef AMD_EXTENSIONS
         } else if (node->getOp() == glslang::EOpImageStore || node->getOp() == glslang::EOpImageStoreLod) {
 #else
@@ -3601,7 +3660,14 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
         }
     }
 
-    return builder.createTextureCall(precision, resultType(), sparse, cracked.fetch, cracked.proj, cracked.gather, noImplicitLod, params);
+    std::vector<spv::Id> result = { 
+        builder.createTextureCall(precision, resultType(), sparse, cracked.fetch, cracked.proj, cracked.gather, noImplicitLod, params)
+    };
+
+    if (components != node->getType().getVectorSize())
+        result[0] = builder.createConstructor(precision, result, convertGlslangToSpvType(node->getType()));
+
+    return result[0];
 }
 
 spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAggregate* node)

+ 44 - 13
3rdparty/glslang/SPIRV/SpvBuilder.cpp

@@ -622,7 +622,7 @@ Id Builder::getContainedTypeId(Id typeId) const
 
 // See if a scalar constant of this type has already been created, so it
 // can be reused rather than duplicated.  (Required by the specification).
-Id Builder::findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned value) const
+Id Builder::findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned value)
 {
     Instruction* constant;
     for (int i = 0; i < (int)groupedConstants[typeClass].size(); ++i) {
@@ -637,7 +637,7 @@ Id Builder::findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned valu
 }
 
 // Version of findScalarConstant (see above) for scalars that take two operands (e.g. a 'double' or 'int64').
-Id Builder::findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned v1, unsigned v2) const
+Id Builder::findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned v1, unsigned v2)
 {
     Instruction* constant;
     for (int i = 0; i < (int)groupedConstants[typeClass].size(); ++i) {
@@ -849,7 +849,7 @@ Id Builder::makeFloat16Constant(float f16, bool specConstant)
 }
 #endif
 
-Id Builder::findCompositeConstant(Op typeClass, const std::vector<Id>& comps) const
+Id Builder::findCompositeConstant(Op typeClass, const std::vector<Id>& comps)
 {
     Instruction* constant = 0;
     bool found = false;
@@ -877,6 +877,30 @@ Id Builder::findCompositeConstant(Op typeClass, const std::vector<Id>& comps) co
     return found ? constant->getResultId() : NoResult;
 }
 
+Id Builder::findStructConstant(Id typeId, const std::vector<Id>& comps)
+{
+    Instruction* constant = 0;
+    bool found = false;
+    for (int i = 0; i < (int)groupedStructConstants[typeId].size(); ++i) {
+        constant = groupedStructConstants[typeId][i];
+
+        // same contents?
+        bool mismatch = false;
+        for (int op = 0; op < constant->getNumOperands(); ++op) {
+            if (constant->getIdOperand(op) != comps[op]) {
+                mismatch = true;
+                break;
+            }
+        }
+        if (! mismatch) {
+            found = true;
+            break;
+        }
+    }
+
+    return found ? constant->getResultId() : NoResult;
+}
+
 // Comments in header
 Id Builder::makeCompositeConstant(Id typeId, const std::vector<Id>& members, bool specConstant)
 {
@@ -887,25 +911,33 @@ Id Builder::makeCompositeConstant(Id typeId, const std::vector<Id>& members, boo
     switch (typeClass) {
     case OpTypeVector:
     case OpTypeArray:
-    case OpTypeStruct:
     case OpTypeMatrix:
+        if (! specConstant) {
+            Id existing = findCompositeConstant(typeClass, members);
+            if (existing)
+                return existing;
+        }
+        break;
+    case OpTypeStruct:
+        if (! specConstant) {
+            Id existing = findStructConstant(typeId, members);
+            if (existing)
+                return existing;
+        }
         break;
     default:
         assert(0);
         return makeFloatConstant(0.0);
     }
 
-    if (! specConstant) {
-        Id existing = findCompositeConstant(typeClass, members);
-        if (existing)
-            return existing;
-    }
-
     Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
     for (int op = 0; op < (int)members.size(); ++op)
         c->addIdOperand(members[op]);
     constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
-    groupedConstants[typeClass].push_back(c);
+    if (typeClass == OpTypeStruct)
+        groupedStructConstants[typeId].push_back(c);
+    else
+        groupedConstants[typeClass].push_back(c);
     module.mapInstruction(c);
 
     return c->getResultId();
@@ -2421,7 +2453,6 @@ void Builder::dump(std::vector<unsigned int>& out) const
 
     // Debug instructions
     dumpInstructions(out, strings);
-    dumpModuleProcesses(out);
     dumpSourceInstructions(out);
     for (int e = 0; e < (int)sourceExtensions.size(); ++e) {
         Instruction sourceExtInst(0, 0, OpSourceExtension);
@@ -2429,7 +2460,7 @@ void Builder::dump(std::vector<unsigned int>& out) const
         sourceExtInst.dump(out);
     }
     dumpInstructions(out, names);
-    dumpInstructions(out, lines);
+    dumpModuleProcesses(out);
 
     // Annotation instructions
     dumpInstructions(out, decorations);

+ 9 - 7
3rdparty/glslang/SPIRV/SpvBuilder.h

@@ -55,6 +55,7 @@
 #include <set>
 #include <sstream>
 #include <stack>
+#include <unordered_map>
 
 namespace spv {
 
@@ -149,7 +150,7 @@ public:
     bool isAggregate(Id resultId)    const { return isAggregateType(getTypeId(resultId)); }
     bool isSampledImage(Id resultId) const { return isSampledImageType(getTypeId(resultId)); }
 
-    bool isBoolType(Id typeId)         const { return groupedTypes[OpTypeBool].size() > 0 && typeId == groupedTypes[OpTypeBool].back()->getResultId(); }
+    bool isBoolType(Id typeId)               { return groupedTypes[OpTypeBool].size() > 0 && typeId == groupedTypes[OpTypeBool].back()->getResultId(); }
     bool isIntType(Id typeId)          const { return getTypeClass(typeId) == OpTypeInt && module.getInstruction(typeId)->getImmediateOperand(1) != 0; }
     bool isUintType(Id typeId)         const { return getTypeClass(typeId) == OpTypeInt && module.getInstruction(typeId)->getImmediateOperand(1) == 0; }
     bool isFloatType(Id typeId)        const { return getTypeClass(typeId) == OpTypeFloat; }
@@ -576,9 +577,10 @@ public:
  protected:
     Id makeIntConstant(Id typeId, unsigned value, bool specConstant);
     Id makeInt64Constant(Id typeId, unsigned long long value, bool specConstant);
-    Id findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned value) const;
-    Id findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned v1, unsigned v2) const;
-    Id findCompositeConstant(Op typeClass, const std::vector<Id>& comps) const;
+    Id findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned value);
+    Id findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned v1, unsigned v2);
+    Id findCompositeConstant(Op typeClass, const std::vector<Id>& comps);
+    Id findStructConstant(Id typeId, const std::vector<Id>& comps);
     Id collapseAccessChain();
     void remapDynamicSwizzle();
     void transferAccessChainSwizzle(bool dynamic);
@@ -616,15 +618,15 @@ public:
     std::vector<std::unique_ptr<Instruction> > entryPoints;
     std::vector<std::unique_ptr<Instruction> > executionModes;
     std::vector<std::unique_ptr<Instruction> > names;
-    std::vector<std::unique_ptr<Instruction> > lines;
     std::vector<std::unique_ptr<Instruction> > decorations;
     std::vector<std::unique_ptr<Instruction> > constantsTypesGlobals;
     std::vector<std::unique_ptr<Instruction> > externals;
     std::vector<std::unique_ptr<Function> > functions;
 
      // not output, internally used for quick & dirty canonical (unique) creation
-    std::vector<Instruction*> groupedConstants[OpConstant];  // all types appear before OpConstant
-    std::vector<Instruction*> groupedTypes[OpConstant];
+    std::unordered_map<unsigned int, std::vector<Instruction*>> groupedConstants;       // map type opcodes to constant inst.
+    std::unordered_map<unsigned int, std::vector<Instruction*>> groupedStructConstants; // map struct-id to constant instructions
+    std::unordered_map<unsigned int, std::vector<Instruction*>> groupedTypes;           // map type opcodes to type instructions
 
     // stack of switches
     std::stack<Block*> switchMerges;

+ 5 - 0
3rdparty/glslang/SPIRV/doc.cpp

@@ -1197,6 +1197,8 @@ const char* OpcodeString(int op)
     case 319: return "OpAtomicFlagClear";
     case 320: return "OpImageSparseRead";
 
+    case OpModuleProcessed: return "OpModuleProcesses";
+
     case 4421: return "OpSubgroupBallotKHR";
     case 4422: return "OpSubgroupFirstInvocationKHR";
     case 4428: return "OpSubgroupAllKHR";
@@ -1348,6 +1350,7 @@ void Parameterize()
     InstructionDesc[OpReleaseEvent].setResultAndType(false, false);
     InstructionDesc[OpGroupWaitEvents].setResultAndType(false, false);
     InstructionDesc[OpAtomicFlagClear].setResultAndType(false, false);
+    InstructionDesc[OpModuleProcessed].setResultAndType(false, false);
 
     // Specific additional context-dependent operands
 
@@ -2839,6 +2842,8 @@ void Parameterize()
     InstructionDesc[OpSubgroupReadInvocationKHR].operands.push(OperandId, "'Value'");
     InstructionDesc[OpSubgroupReadInvocationKHR].operands.push(OperandId, "'Index'");
 
+    InstructionDesc[OpModuleProcessed].operands.push(OperandLiteralString, "'process'");
+
 #ifdef AMD_EXTENSIONS
     InstructionDesc[OpGroupIAddNonUniformAMD].capabilities.push_back(CapabilityGroups);
     InstructionDesc[OpGroupIAddNonUniformAMD].operands.push(OperandScope, "'Execution'");

+ 1 - 2
3rdparty/glslang/Test/baseResults/310.comp.out

@@ -40,7 +40,6 @@ ERROR: 0:119: 'r8ui' : does not apply to signed integer images
 ERROR: 0:128: 'atomic_uint' : samplers and atomic_uints cannot be output parameters 
 ERROR: 0:130: 'return' : type does not match, or is not convertible to, the function's return type 
 ERROR: 0:136: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: non_uniform_counter
-ERROR: 0:136: 'atomic_uint' : layout(binding=X) is required 
 ERROR: 0:141: 'atomic_uint' : atomic counters can only be highp 
 ERROR: 0:141: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
 ERROR: 0:143: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
@@ -84,7 +83,7 @@ WARNING: 0:238: '#define' : names containing consecutive underscores are reserve
 ERROR: 0:244: 'gl_DeviceIndex' : required extension not requested: GL_EXT_device_group
 ERROR: 0:245: 'gl_ViewIndex' : undeclared identifier 
 ERROR: 0:255: 'gl_ViewIndex' : undeclared identifier 
-ERROR: 83 compilation errors.  No code generated.
+ERROR: 82 compilation errors.  No code generated.
 
 
 Shader version: 310

+ 1 - 6
3rdparty/glslang/Test/baseResults/atomic_uint.frag.out

@@ -2,7 +2,6 @@ atomic_uint.frag
 ERROR: 0:10: 'atomic_uint' : samplers and atomic_uints cannot be output parameters 
 ERROR: 0:12: 'return' : type does not match, or is not convertible to, the function's return type 
 ERROR: 0:18: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: non_uniform_counter
-ERROR: 0:18: 'atomic_uint' : layout(binding=X) is required 
 ERROR: 0:23: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
 ERROR: 0:28: '+' :  wrong operand types: no operation '+' exists that takes a left-hand operand of type 'layout( binding=0 offset=0) uniform atomic_uint' and a right operand of type 'layout( binding=0 offset=0) uniform atomic_uint' (or there is no acceptable conversion)
 ERROR: 0:29: '-' :  wrong operand type no operation '-' exists that takes an operand of type layout( binding=0 offset=0) uniform atomic_uint (or there is no acceptable conversion)
@@ -10,14 +9,10 @@ ERROR: 0:31: '[]' : scalar integer expression required
 ERROR: 0:34: 'assign' :  l-value required "counter" (can't modify a uniform)
 ERROR: 0:34: 'assign' :  cannot convert from ' const int' to 'layout( binding=0 offset=0) uniform atomic_uint'
 ERROR: 0:37: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: acin
-ERROR: 0:37: 'atomic_uint' : layout(binding=X) is required 
 ERROR: 0:38: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: acg
-ERROR: 0:38: 'atomic_uint' : layout(binding=X) is required 
-ERROR: 0:40: 'atomic_uint' : layout(binding=X) is required 
-ERROR: 0:46: 'atomic_uint' : layout(binding=X) is required 
 ERROR: 0:47: 'offset' : atomic counters sharing the same offset: 12
 ERROR: 0:48: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
-ERROR: 18 compilation errors.  No code generated.
+ERROR: 13 compilation errors.  No code generated.
 
 
 Shader version: 420

+ 5 - 3
3rdparty/glslang/Test/baseResults/glspv.frag.out

@@ -1,13 +1,15 @@
 glspv.frag
 ERROR: 0:4: '#error' : GL_SPIRV is set ( correct , not an error )  
 ERROR: 0:6: '#error' : GL_SPIR is 100  
+ERROR: 0:14: 'f' : non-opaque uniform variables need a layout(location=L) 
 ERROR: 0:21: 'noise1' : no matching overloaded function found 
 ERROR: 0:22: 'noise2' : no matching overloaded function found 
 ERROR: 0:23: 'noise3' : no matching overloaded function found 
 ERROR: 0:24: 'noise4' : no matching overloaded function found 
-ERROR: 0:27: 'input_attachment_index' : only allowed when using GLSL for Vulkan 
-ERROR: 0:27: '' :  syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
-ERROR: 8 compilation errors.  No code generated.
+ERROR: 0:27: 'atomic_uint' : layout(binding=X) is required 
+ERROR: 0:28: 'input_attachment_index' : only allowed when using GLSL for Vulkan 
+ERROR: 0:28: '' :  syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
+ERROR: 10 compilation errors.  No code generated.
 
 
 SPIR-V is not generated for failed compile or link

+ 161 - 199
3rdparty/glslang/Test/baseResults/hlsl.conditional.frag.out

@@ -78,7 +78,7 @@ gl_FragCoord origin is upper left
 0:17      Sequence
 0:17        move second child to first child ( temp 4-component vector of float)
 0:17          'ret' ( temp 4-component vector of float)
-0:17          Test condition and select ( temp 4-component vector of float)
+0:17          Test condition and select ( temp 4-component vector of float): no shortcircuit
 0:17            Condition
 0:17            Compare Not Equal ( temp bool)
 0:17              t: direct index for structure ( uniform float)
@@ -169,7 +169,7 @@ gl_FragCoord origin is upper left
 0:37          'e' ( temp int)
 0:37          move second child to first child ( temp int)
 0:37            'a' ( temp int)
-0:37            Test condition and select ( temp int)
+0:37            Test condition and select ( temp int): no shortcircuit
 0:37              Condition
 0:37              Convert int to bool ( temp bool)
 0:37                'b' ( temp int)
@@ -182,7 +182,7 @@ gl_FragCoord origin is upper left
 0:37                10 (const int)
 0:37        move second child to first child ( temp int)
 0:37          'b' ( temp int)
-0:37          Test condition and select ( temp int)
+0:37          Test condition and select ( temp int): no shortcircuit
 0:37            Condition
 0:37            Convert int to bool ( temp bool)
 0:37              'a' ( temp int)
@@ -195,7 +195,7 @@ gl_FragCoord origin is upper left
 0:37              11 (const int)
 0:39      move second child to first child ( temp 4-component vector of float)
 0:39        'f' ( temp 4-component vector of float)
-0:39        Test condition and select ( temp 4-component vector of float)
+0:39        Test condition and select ( temp 4-component vector of float): no shortcircuit
 0:39          Condition
 0:39          Compare Less Than ( temp bool)
 0:39            direct index ( temp float)
@@ -341,7 +341,7 @@ gl_FragCoord origin is upper left
 0:17      Sequence
 0:17        move second child to first child ( temp 4-component vector of float)
 0:17          'ret' ( temp 4-component vector of float)
-0:17          Test condition and select ( temp 4-component vector of float)
+0:17          Test condition and select ( temp 4-component vector of float): no shortcircuit
 0:17            Condition
 0:17            Compare Not Equal ( temp bool)
 0:17              t: direct index for structure ( uniform float)
@@ -432,7 +432,7 @@ gl_FragCoord origin is upper left
 0:37          'e' ( temp int)
 0:37          move second child to first child ( temp int)
 0:37            'a' ( temp int)
-0:37            Test condition and select ( temp int)
+0:37            Test condition and select ( temp int): no shortcircuit
 0:37              Condition
 0:37              Convert int to bool ( temp bool)
 0:37                'b' ( temp int)
@@ -445,7 +445,7 @@ gl_FragCoord origin is upper left
 0:37                10 (const int)
 0:37        move second child to first child ( temp int)
 0:37          'b' ( temp int)
-0:37          Test condition and select ( temp int)
+0:37          Test condition and select ( temp int): no shortcircuit
 0:37            Condition
 0:37            Convert int to bool ( temp bool)
 0:37              'a' ( temp int)
@@ -458,7 +458,7 @@ gl_FragCoord origin is upper left
 0:37              11 (const int)
 0:39      move second child to first child ( temp 4-component vector of float)
 0:39        'f' ( temp 4-component vector of float)
-0:39        Test condition and select ( temp 4-component vector of float)
+0:39        Test condition and select ( temp 4-component vector of float): no shortcircuit
 0:39          Condition
 0:39          Compare Less Than ( temp bool)
 0:39            direct index ( temp float)
@@ -523,12 +523,12 @@ gl_FragCoord origin is upper left
 
 // Module Version 10000
 // Generated by (magic number): 80004
-// Id's are bound by 220
+// Id's are bound by 206
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "PixelShaderFunction" 213 216
+                              EntryPoint Fragment 4  "PixelShaderFunction" 199 202
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "PixelShaderFunction"
@@ -548,20 +548,20 @@ gl_FragCoord origin is upper left
                               MemberName 29($Global) 4  "f"
                               Name 31  ""
                               Name 85  "ret"
-                              Name 113  "a"
-                              Name 115  "b"
-                              Name 117  "c"
-                              Name 119  "d"
-                              Name 120  "ret"
-                              Name 140  "e"
-                              Name 161  "f"
-                              Name 200  "param"
-                              Name 201  "param"
-                              Name 202  "param"
-                              Name 211  "input"
-                              Name 213  "input"
-                              Name 216  "@entryPointOutput"
-                              Name 217  "param"
+                              Name 110  "a"
+                              Name 112  "b"
+                              Name 114  "c"
+                              Name 116  "d"
+                              Name 117  "ret"
+                              Name 137  "e"
+                              Name 150  "f"
+                              Name 186  "param"
+                              Name 187  "param"
+                              Name 188  "param"
+                              Name 197  "input"
+                              Name 199  "input"
+                              Name 202  "@entryPointOutput"
+                              Name 203  "param"
                               MemberDecorate 29($Global) 0 Offset 0
                               MemberDecorate 29($Global) 1 Offset 16
                               MemberDecorate 29($Global) 2 Offset 32
@@ -569,8 +569,8 @@ gl_FragCoord origin is upper left
                               MemberDecorate 29($Global) 4 Offset 52
                               Decorate 29($Global) Block
                               Decorate 31 DescriptorSet 0
-                              Decorate 213(input) Location 0
-                              Decorate 216(@entryPointOutput) Location 0
+                              Decorate 199(input) Location 0
+                              Decorate 202(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
@@ -598,41 +598,41 @@ gl_FragCoord origin is upper left
               48:     32(int) Constant 4
               49:             TypePointer Uniform 6(float)
               53:     32(int) Constant 3
-             100:    6(float) Constant 1065353216
-             101:    7(fvec4) ConstantComposite 100 100 100 100
-             112:             TypePointer Function 32(int)
-             114:     32(int) Constant 5
-             116:     32(int) Constant 6
-             118:     32(int) Constant 7
-             143:             TypeInt 32 0
-             144:    143(int) Constant 0
-             150:     32(int) Constant 10
-             159:     32(int) Constant 11
-             163:             TypePointer Function 6(float)
-             166:    143(int) Constant 1
-             192:    13(bool) ConstantTrue
-             193:    13(bool) ConstantFalse
-             194:   14(bvec2) ConstantComposite 192 193
-             195:    6(float) Constant 1073741824
-             196:   16(fvec2) ConstantComposite 100 195
-             197:    6(float) Constant 1077936128
-             198:    6(float) Constant 1082130432
-             199:   16(fvec2) ConstantComposite 197 198
-             204:    6(float) Constant 1092616192
-             212:             TypePointer Input 7(fvec4)
-      213(input):    212(ptr) Variable Input
-             215:             TypePointer Output 7(fvec4)
-216(@entryPointOutput):    215(ptr) Variable Output
+              96:    6(float) Constant 1065353216
+              97:    7(fvec4) ConstantComposite 96 96 96 96
+             109:             TypePointer Function 32(int)
+             111:     32(int) Constant 5
+             113:     32(int) Constant 6
+             115:     32(int) Constant 7
+             139:             TypeInt 32 0
+             140:    139(int) Constant 0
+             143:     32(int) Constant 10
+             148:     32(int) Constant 11
+             151:             TypePointer Function 6(float)
+             154:    139(int) Constant 1
+             178:    13(bool) ConstantTrue
+             179:    13(bool) ConstantFalse
+             180:   14(bvec2) ConstantComposite 178 179
+             181:    6(float) Constant 1073741824
+             182:   16(fvec2) ConstantComposite 96 181
+             183:    6(float) Constant 1077936128
+             184:    6(float) Constant 1082130432
+             185:   16(fvec2) ConstantComposite 183 184
+             190:    6(float) Constant 1092616192
+             198:             TypePointer Input 7(fvec4)
+      199(input):    198(ptr) Variable Input
+             201:             TypePointer Output 7(fvec4)
+202(@entryPointOutput):    201(ptr) Variable Output
 4(PixelShaderFunction):           2 Function None 3
                5:             Label
-      211(input):     24(ptr) Variable Function
-      217(param):     24(ptr) Variable Function
-             214:    7(fvec4) Load 213(input)
-                              Store 211(input) 214
-             218:    7(fvec4) Load 211(input)
-                              Store 217(param) 218
-             219:    7(fvec4) FunctionCall 27(@PixelShaderFunction(vf4;) 217(param)
-                              Store 216(@entryPointOutput) 219
+      197(input):     24(ptr) Variable Function
+      203(param):     24(ptr) Variable Function
+             200:    7(fvec4) Load 199(input)
+                              Store 197(input) 200
+             204:    7(fvec4) Load 197(input)
+                              Store 203(param) 204
+             205:    7(fvec4) FunctionCall 27(@PixelShaderFunction(vf4;) 203(param)
+                              Store 202(@entryPointOutput) 205
                               Return
                               FunctionEnd
   9(vectorCond():    7(fvec4) Function None 8
@@ -682,154 +682,116 @@ gl_FragCoord origin is upper left
  11(scalarCond():    7(fvec4) Function None 8
               12:             Label
          85(ret):     24(ptr) Variable Function
-              86:     24(ptr) Variable Function
-              87:     49(ptr) AccessChain 31 53
-              88:    6(float) Load 87
-              89:     49(ptr) AccessChain 31 48
-              90:    6(float) Load 89
-              91:    13(bool) FOrdNotEqual 88 90
-                              SelectionMerge 93 None
-                              BranchConditional 91 92 99
-              92:               Label
-              94:     49(ptr)   AccessChain 31 53
-              95:    6(float)   Load 94
-              96:     34(ptr)   AccessChain 31 33
-              97:    7(fvec4)   Load 96
-              98:    7(fvec4)   VectorTimesScalar 97 95
-                                Store 86 98
-                                Branch 93
-              99:               Label
-                                Store 86 101
-                                Branch 93
-              93:             Label
-             102:    7(fvec4) Load 86
-                              Store 85(ret) 102
-             103:    7(fvec4) Load 85(ret)
-                              ReturnValue 103
+              86:     49(ptr) AccessChain 31 53
+              87:    6(float) Load 86
+              88:     49(ptr) AccessChain 31 48
+              89:    6(float) Load 88
+              90:    13(bool) FOrdNotEqual 87 89
+              91:     49(ptr) AccessChain 31 53
+              92:    6(float) Load 91
+              93:     34(ptr) AccessChain 31 33
+              94:    7(fvec4) Load 93
+              95:    7(fvec4) VectorTimesScalar 94 92
+              98:   43(bvec4) CompositeConstruct 90 90 90 90
+              99:    7(fvec4) Select 98 95 97
+                              Store 85(ret) 99
+             100:    7(fvec4) Load 85(ret)
+                              ReturnValue 100
                               FunctionEnd
 22(fbSelect(vb2;vf2;vf2;):   16(fvec2) Function None 18
          19(cnd):     15(ptr) FunctionParameter
         20(src0):     17(ptr) FunctionParameter
         21(src1):     17(ptr) FunctionParameter
               23:             Label
-             106:   16(fvec2) Load 21(src1)
-             107:   16(fvec2) Load 20(src0)
-             108:   14(bvec2) Load 19(cnd)
-             109:   16(fvec2) Select 108 107 106
-                              ReturnValue 109
+             103:   16(fvec2) Load 21(src1)
+             104:   16(fvec2) Load 20(src0)
+             105:   14(bvec2) Load 19(cnd)
+             106:   16(fvec2) Select 105 104 103
+                              ReturnValue 106
                               FunctionEnd
 27(@PixelShaderFunction(vf4;):    7(fvec4) Function None 25
        26(input):     24(ptr) FunctionParameter
               28:             Label
-          113(a):    112(ptr) Variable Function
-          115(b):    112(ptr) Variable Function
-          117(c):    112(ptr) Variable Function
-          119(d):    112(ptr) Variable Function
-        120(ret):     24(ptr) Variable Function
-          140(e):    112(ptr) Variable Function
-             141:    112(ptr) Variable Function
-             152:    112(ptr) Variable Function
-          161(f):     24(ptr) Variable Function
-             162:     24(ptr) Variable Function
-      200(param):     15(ptr) Variable Function
-      201(param):     17(ptr) Variable Function
-      202(param):     17(ptr) Variable Function
-                              Store 113(a) 114
-                              Store 115(b) 116
-                              Store 117(c) 118
-                              Store 119(d) 118
-             121:     32(int) Load 113(a)
-             122:    6(float) ConvertSToF 121
-             123:    7(fvec4) Load 26(input)
-             124:    7(fvec4) VectorTimesScalar 123 122
-             125:     32(int) Load 115(b)
-             126:    6(float) ConvertSToF 125
-             127:    7(fvec4) Load 26(input)
-             128:    7(fvec4) VectorTimesScalar 127 126
-             129:    7(fvec4) FAdd 124 128
-             130:     32(int) Load 117(c)
-             131:    6(float) ConvertSToF 130
-             132:    7(fvec4) Load 26(input)
-             133:    7(fvec4) VectorTimesScalar 132 131
-             134:    7(fvec4) FAdd 129 133
-             135:     32(int) Load 119(d)
-             136:    6(float) ConvertSToF 135
-             137:    7(fvec4) Load 26(input)
-             138:    7(fvec4) VectorTimesScalar 137 136
-             139:    7(fvec4) FAdd 134 138
-                              Store 120(ret) 139
-             142:     32(int) Load 115(b)
-             145:    13(bool) INotEqual 142 144
-                              SelectionMerge 147 None
-                              BranchConditional 145 146 149
-             146:               Label
-             148:     32(int)   Load 119(d)
-                                Store 117(c) 148
-                                Store 141 148
-                                Branch 147
-             149:               Label
-                                Store 141 150
-                                Branch 147
-             147:             Label
-             151:     32(int) Load 141
-                              Store 113(a) 151
-                              Store 140(e) 151
-             153:     32(int) Load 113(a)
-             154:    13(bool) INotEqual 153 144
-                              SelectionMerge 156 None
-                              BranchConditional 154 155 158
-             155:               Label
-             157:     32(int)   Load 117(c)
-                                Store 119(d) 157
-                                Store 152 157
-                                Branch 156
-             158:               Label
-                                Store 152 159
-                                Branch 156
-             156:             Label
-             160:     32(int) Load 152
-                              Store 115(b) 160
-             164:    163(ptr) AccessChain 120(ret) 144
-             165:    6(float) Load 164
-             167:    163(ptr) AccessChain 26(input) 166
-             168:    6(float) Load 167
-             169:    13(bool) FOrdLessThan 165 168
-                              SelectionMerge 171 None
-                              BranchConditional 169 170 176
-             170:               Label
-             172:     32(int)   Load 117(c)
-             173:    6(float)   ConvertSToF 172
-             174:    7(fvec4)   Load 26(input)
-             175:    7(fvec4)   VectorTimesScalar 174 173
-                                Store 162 175
-                                Branch 171
-             176:               Label
-             177:     32(int)   Load 119(d)
-             178:    6(float)   ConvertSToF 177
-             179:    7(fvec4)   Load 26(input)
-             180:    7(fvec4)   VectorTimesScalar 179 178
-                                Store 162 180
-                                Branch 171
-             171:             Label
-             181:    7(fvec4) Load 162
-                              Store 161(f) 181
-             182:     32(int) Load 140(e)
-             183:    6(float) ConvertSToF 182
-             184:    7(fvec4) Load 120(ret)
-             185:    7(fvec4) VectorTimesScalar 184 183
-             186:    7(fvec4) Load 161(f)
-             187:    7(fvec4) FAdd 185 186
-             188:    7(fvec4) FunctionCall 9(vectorCond()
-             189:    7(fvec4) FAdd 187 188
-             190:    7(fvec4) FunctionCall 11(scalarCond()
-             191:    7(fvec4) FAdd 189 190
-                              Store 200(param) 194
-                              Store 201(param) 196
-                              Store 202(param) 199
-             203:   16(fvec2) FunctionCall 22(fbSelect(vb2;vf2;vf2;) 200(param) 201(param) 202(param)
-             205:    6(float) CompositeExtract 203 0
-             206:    6(float) CompositeExtract 203 1
-             207:    7(fvec4) CompositeConstruct 205 206 204 204
-             208:    7(fvec4) FAdd 191 207
-                              ReturnValue 208
+          110(a):    109(ptr) Variable Function
+          112(b):    109(ptr) Variable Function
+          114(c):    109(ptr) Variable Function
+          116(d):    109(ptr) Variable Function
+        117(ret):     24(ptr) Variable Function
+          137(e):    109(ptr) Variable Function
+          150(f):     24(ptr) Variable Function
+      186(param):     15(ptr) Variable Function
+      187(param):     17(ptr) Variable Function
+      188(param):     17(ptr) Variable Function
+                              Store 110(a) 111
+                              Store 112(b) 113
+                              Store 114(c) 115
+                              Store 116(d) 115
+             118:     32(int) Load 110(a)
+             119:    6(float) ConvertSToF 118
+             120:    7(fvec4) Load 26(input)
+             121:    7(fvec4) VectorTimesScalar 120 119
+             122:     32(int) Load 112(b)
+             123:    6(float) ConvertSToF 122
+             124:    7(fvec4) Load 26(input)
+             125:    7(fvec4) VectorTimesScalar 124 123
+             126:    7(fvec4) FAdd 121 125
+             127:     32(int) Load 114(c)
+             128:    6(float) ConvertSToF 127
+             129:    7(fvec4) Load 26(input)
+             130:    7(fvec4) VectorTimesScalar 129 128
+             131:    7(fvec4) FAdd 126 130
+             132:     32(int) Load 116(d)
+             133:    6(float) ConvertSToF 132
+             134:    7(fvec4) Load 26(input)
+             135:    7(fvec4) VectorTimesScalar 134 133
+             136:    7(fvec4) FAdd 131 135
+                              Store 117(ret) 136
+             138:     32(int) Load 112(b)
+             141:    13(bool) INotEqual 138 140
+             142:     32(int) Load 116(d)
+                              Store 114(c) 142
+             144:     32(int) Select 141 142 143
+                              Store 110(a) 144
+                              Store 137(e) 144
+             145:     32(int) Load 110(a)
+             146:    13(bool) INotEqual 145 140
+             147:     32(int) Load 114(c)
+                              Store 116(d) 147
+             149:     32(int) Select 146 147 148
+                              Store 112(b) 149
+             152:    151(ptr) AccessChain 117(ret) 140
+             153:    6(float) Load 152
+             155:    151(ptr) AccessChain 26(input) 154
+             156:    6(float) Load 155
+             157:    13(bool) FOrdLessThan 153 156
+             158:     32(int) Load 114(c)
+             159:    6(float) ConvertSToF 158
+             160:    7(fvec4) Load 26(input)
+             161:    7(fvec4) VectorTimesScalar 160 159
+             162:     32(int) Load 116(d)
+             163:    6(float) ConvertSToF 162
+             164:    7(fvec4) Load 26(input)
+             165:    7(fvec4) VectorTimesScalar 164 163
+             166:   43(bvec4) CompositeConstruct 157 157 157 157
+             167:    7(fvec4) Select 166 161 165
+                              Store 150(f) 167
+             168:     32(int) Load 137(e)
+             169:    6(float) ConvertSToF 168
+             170:    7(fvec4) Load 117(ret)
+             171:    7(fvec4) VectorTimesScalar 170 169
+             172:    7(fvec4) Load 150(f)
+             173:    7(fvec4) FAdd 171 172
+             174:    7(fvec4) FunctionCall 9(vectorCond()
+             175:    7(fvec4) FAdd 173 174
+             176:    7(fvec4) FunctionCall 11(scalarCond()
+             177:    7(fvec4) FAdd 175 176
+                              Store 186(param) 180
+                              Store 187(param) 182
+                              Store 188(param) 185
+             189:   16(fvec2) FunctionCall 22(fbSelect(vb2;vf2;vf2;) 186(param) 187(param) 188(param)
+             191:    6(float) CompositeExtract 189 0
+             192:    6(float) CompositeExtract 189 1
+             193:    7(fvec4) CompositeConstruct 191 192 190 190
+             194:    7(fvec4) FAdd 177 193
+                              ReturnValue 194
                               FunctionEnd

+ 233 - 304
3rdparty/glslang/Test/baseResults/hlsl.getsampleposition.dx10.frag.out

@@ -14,7 +14,7 @@ gl_FragCoord origin is upper left
 0:16              '@sampleCount' ( temp uint)
 0:16              imageQuerySamples ( temp uint)
 0:16                'g_tTex2dmsf4' ( uniform texture2DMS)
-0:16            Test condition and select ( temp 2-component vector of float)
+0:16            Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:16              Condition
 0:16              Compare Equal ( temp bool)
 0:16                '@sampleCount' ( temp uint)
@@ -29,7 +29,7 @@ gl_FragCoord origin is upper left
 0:?                   -0.250000
 0:16                'sample' ( in int)
 0:16              false case
-0:16              Test condition and select ( temp 2-component vector of float)
+0:16              Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:16                Condition
 0:16                Compare Equal ( temp bool)
 0:16                  '@sampleCount' ( temp uint)
@@ -48,7 +48,7 @@ gl_FragCoord origin is upper left
 0:?                     0.375000
 0:16                  'sample' ( in int)
 0:16                false case
-0:16                Test condition and select ( temp 2-component vector of float)
+0:16                Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:16                  Condition
 0:16                  Compare Equal ( temp bool)
 0:16                    '@sampleCount' ( temp uint)
@@ -75,7 +75,7 @@ gl_FragCoord origin is upper left
 0:?                       -0.437500
 0:16                    'sample' ( in int)
 0:16                  false case
-0:16                  Test condition and select ( temp 2-component vector of float)
+0:16                  Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:16                    Condition
 0:16                    Compare Equal ( temp bool)
 0:16                      '@sampleCount' ( temp uint)
@@ -129,7 +129,7 @@ gl_FragCoord origin is upper left
 0:17              '@sampleCount' ( temp uint)
 0:17              imageQuerySamples ( temp uint)
 0:17                'g_tTex2dmsf4a' ( uniform texture2DMSArray)
-0:17            Test condition and select ( temp 2-component vector of float)
+0:17            Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:17              Condition
 0:17              Compare Equal ( temp bool)
 0:17                '@sampleCount' ( temp uint)
@@ -144,7 +144,7 @@ gl_FragCoord origin is upper left
 0:?                   -0.250000
 0:17                'sample' ( in int)
 0:17              false case
-0:17              Test condition and select ( temp 2-component vector of float)
+0:17              Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:17                Condition
 0:17                Compare Equal ( temp bool)
 0:17                  '@sampleCount' ( temp uint)
@@ -163,7 +163,7 @@ gl_FragCoord origin is upper left
 0:?                     0.375000
 0:17                  'sample' ( in int)
 0:17                false case
-0:17                Test condition and select ( temp 2-component vector of float)
+0:17                Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:17                  Condition
 0:17                  Compare Equal ( temp bool)
 0:17                    '@sampleCount' ( temp uint)
@@ -190,7 +190,7 @@ gl_FragCoord origin is upper left
 0:?                       -0.437500
 0:17                    'sample' ( in int)
 0:17                  false case
-0:17                  Test condition and select ( temp 2-component vector of float)
+0:17                  Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:17                    Condition
 0:17                    Compare Equal ( temp bool)
 0:17                      '@sampleCount' ( temp uint)
@@ -305,7 +305,7 @@ gl_FragCoord origin is upper left
 0:16              '@sampleCount' ( temp uint)
 0:16              imageQuerySamples ( temp uint)
 0:16                'g_tTex2dmsf4' ( uniform texture2DMS)
-0:16            Test condition and select ( temp 2-component vector of float)
+0:16            Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:16              Condition
 0:16              Compare Equal ( temp bool)
 0:16                '@sampleCount' ( temp uint)
@@ -320,7 +320,7 @@ gl_FragCoord origin is upper left
 0:?                   -0.250000
 0:16                'sample' ( in int)
 0:16              false case
-0:16              Test condition and select ( temp 2-component vector of float)
+0:16              Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:16                Condition
 0:16                Compare Equal ( temp bool)
 0:16                  '@sampleCount' ( temp uint)
@@ -339,7 +339,7 @@ gl_FragCoord origin is upper left
 0:?                     0.375000
 0:16                  'sample' ( in int)
 0:16                false case
-0:16                Test condition and select ( temp 2-component vector of float)
+0:16                Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:16                  Condition
 0:16                  Compare Equal ( temp bool)
 0:16                    '@sampleCount' ( temp uint)
@@ -366,7 +366,7 @@ gl_FragCoord origin is upper left
 0:?                       -0.437500
 0:16                    'sample' ( in int)
 0:16                  false case
-0:16                  Test condition and select ( temp 2-component vector of float)
+0:16                  Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:16                    Condition
 0:16                    Compare Equal ( temp bool)
 0:16                      '@sampleCount' ( temp uint)
@@ -420,7 +420,7 @@ gl_FragCoord origin is upper left
 0:17              '@sampleCount' ( temp uint)
 0:17              imageQuerySamples ( temp uint)
 0:17                'g_tTex2dmsf4a' ( uniform texture2DMSArray)
-0:17            Test condition and select ( temp 2-component vector of float)
+0:17            Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:17              Condition
 0:17              Compare Equal ( temp bool)
 0:17                '@sampleCount' ( temp uint)
@@ -435,7 +435,7 @@ gl_FragCoord origin is upper left
 0:?                   -0.250000
 0:17                'sample' ( in int)
 0:17              false case
-0:17              Test condition and select ( temp 2-component vector of float)
+0:17              Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:17                Condition
 0:17                Compare Equal ( temp bool)
 0:17                  '@sampleCount' ( temp uint)
@@ -454,7 +454,7 @@ gl_FragCoord origin is upper left
 0:?                     0.375000
 0:17                  'sample' ( in int)
 0:17                false case
-0:17                Test condition and select ( temp 2-component vector of float)
+0:17                Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:17                  Condition
 0:17                  Compare Equal ( temp bool)
 0:17                    '@sampleCount' ( temp uint)
@@ -481,7 +481,7 @@ gl_FragCoord origin is upper left
 0:?                       -0.437500
 0:17                    'sample' ( in int)
 0:17                  false case
-0:17                  Test condition and select ( temp 2-component vector of float)
+0:17                  Test condition and select ( temp 2-component vector of float): no shortcircuit
 0:17                    Condition
 0:17                    Compare Equal ( temp bool)
 0:17                      '@sampleCount' ( temp uint)
@@ -579,13 +579,13 @@ gl_FragCoord origin is upper left
 
 // Module Version 10000
 // Generated by (magic number): 80004
-// Id's are bound by 221
+// Id's are bound by 198
 
                               Capability Shader
                               Capability ImageQuery
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 204 211 215
+                              EntryPoint Fragment 4  "main" 181 188 192
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "main"
@@ -597,33 +597,33 @@ gl_FragCoord origin is upper left
                               Name 17  "r00"
                               Name 20  "@sampleCount"
                               Name 23  "g_tTex2dmsf4"
-                              Name 42  "indexable"
-                              Name 65  "indexable"
-                              Name 96  "indexable"
-                              Name 129  "indexable"
-                              Name 138  "r01"
-                              Name 139  "@sampleCount"
-                              Name 142  "g_tTex2dmsf4a"
-                              Name 151  "indexable"
-                              Name 161  "indexable"
-                              Name 171  "indexable"
-                              Name 181  "indexable"
-                              Name 190  "psout"
-                              Name 202  "sample"
-                              Name 204  "sample"
-                              Name 206  "flattenTemp"
-                              Name 207  "param"
-                              Name 211  "@entryPointOutput.Color"
-                              Name 215  "@entryPointOutput.Depth"
-                              Name 220  "g_sSamp"
+                              Name 39  "indexable"
+                              Name 58  "indexable"
+                              Name 85  "indexable"
+                              Name 114  "indexable"
+                              Name 127  "r01"
+                              Name 128  "@sampleCount"
+                              Name 131  "g_tTex2dmsf4a"
+                              Name 137  "indexable"
+                              Name 143  "indexable"
+                              Name 149  "indexable"
+                              Name 155  "indexable"
+                              Name 167  "psout"
+                              Name 179  "sample"
+                              Name 181  "sample"
+                              Name 183  "flattenTemp"
+                              Name 184  "param"
+                              Name 188  "@entryPointOutput.Color"
+                              Name 192  "@entryPointOutput.Depth"
+                              Name 197  "g_sSamp"
                               Decorate 23(g_tTex2dmsf4) DescriptorSet 0
-                              Decorate 142(g_tTex2dmsf4a) DescriptorSet 0
-                              Decorate 204(sample) Flat
-                              Decorate 204(sample) Location 0
-                              Decorate 211(@entryPointOutput.Color) Location 0
-                              Decorate 215(@entryPointOutput.Depth) BuiltIn FragDepth
-                              Decorate 220(g_sSamp) DescriptorSet 0
-                              Decorate 220(g_sSamp) Binding 0
+                              Decorate 131(g_tTex2dmsf4a) DescriptorSet 0
+                              Decorate 181(sample) Flat
+                              Decorate 181(sample) Location 0
+                              Decorate 188(@entryPointOutput.Color) Location 0
+                              Decorate 192(@entryPointOutput.Depth) BuiltIn FragDepth
+                              Decorate 197(g_sSamp) DescriptorSet 0
+                              Decorate 197(g_sSamp) Binding 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeInt 32 1
@@ -639,110 +639,111 @@ gl_FragCoord origin is upper left
               21:             TypeImage 8(float) 2D multi-sampled sampled format:Unknown
               22:             TypePointer UniformConstant 21
 23(g_tTex2dmsf4):     22(ptr) Variable UniformConstant
-              28:      6(int) Constant 2
-              29:             TypeBool
-              33:     18(int) Constant 2
-              34:             TypeArray 15(fvec2) 33
-              35:    8(float) Constant 1048576000
-              36:   15(fvec2) ConstantComposite 35 35
-              37:    8(float) Constant 3196059648
-              38:   15(fvec2) ConstantComposite 37 37
-              39:          34 ConstantComposite 36 38
-              41:             TypePointer Function 34
-              48:      6(int) Constant 4
-              52:     18(int) Constant 4
-              53:             TypeArray 15(fvec2) 52
-              54:    8(float) Constant 3187671040
-              55:    8(float) Constant 3200253952
-              56:   15(fvec2) ConstantComposite 54 55
-              57:    8(float) Constant 1052770304
-              58:   15(fvec2) ConstantComposite 57 54
-              59:    8(float) Constant 1040187392
-              60:   15(fvec2) ConstantComposite 55 59
-              61:   15(fvec2) ConstantComposite 59 57
-              62:          53 ConstantComposite 56 58 60 61
-              64:             TypePointer Function 53
-              71:      6(int) Constant 8
-              75:     18(int) Constant 8
-              76:             TypeArray 15(fvec2) 75
-              77:    8(float) Constant 1031798784
-              78:    8(float) Constant 3191865344
-              79:   15(fvec2) ConstantComposite 77 78
-              80:    8(float) Constant 3179282432
-              81:    8(float) Constant 1044381696
-              82:   15(fvec2) ConstantComposite 80 81
-              83:    8(float) Constant 1050673152
-              84:   15(fvec2) ConstantComposite 83 77
-              85:    8(float) Constant 3198156800
-              86:   15(fvec2) ConstantComposite 78 85
-              87:   15(fvec2) ConstantComposite 85 83
-              88:    8(float) Constant 3202351104
-              89:   15(fvec2) ConstantComposite 88 80
-              90:    8(float) Constant 1054867456
-              91:   15(fvec2) ConstantComposite 81 90
-              92:   15(fvec2) ConstantComposite 90 88
-              93:          76 ConstantComposite 79 82 84 86 87 89 91 92
-              95:             TypePointer Function 76
-             102:      6(int) Constant 16
-             106:     18(int) Constant 16
-             107:             TypeArray 15(fvec2) 106
-             108:   15(fvec2) ConstantComposite 77 77
-             109:   15(fvec2) ConstantComposite 80 78
-             110:   15(fvec2) ConstantComposite 78 59
-             111:   15(fvec2) ConstantComposite 35 80
-             112:   15(fvec2) ConstantComposite 85 54
-             113:   15(fvec2) ConstantComposite 59 83
-             114:   15(fvec2) ConstantComposite 83 81
-             115:   15(fvec2) ConstantComposite 81 85
-             116:   15(fvec2) ConstantComposite 54 57
-             117:    8(float) Constant 0
-             118:   15(fvec2) ConstantComposite 117 88
-             119:   15(fvec2) ConstantComposite 37 55
-             120:   15(fvec2) ConstantComposite 55 35
-             121:    8(float) Constant 3204448256
-             122:   15(fvec2) ConstantComposite 121 117
-             123:   15(fvec2) ConstantComposite 90 37
-             124:   15(fvec2) ConstantComposite 57 90
-             125:   15(fvec2) ConstantComposite 88 121
-             126:         107 ConstantComposite 108 109 110 111 112 113 114 115 116 118 119 120 122 123 124 125
-             128:             TypePointer Function 107
-             133:   15(fvec2) ConstantComposite 117 117
-             140:             TypeImage 8(float) 2D array multi-sampled sampled format:Unknown
-             141:             TypePointer UniformConstant 140
-142(g_tTex2dmsf4a):    141(ptr) Variable UniformConstant
-             189:             TypePointer Function 10(PS_OUTPUT)
-             191:      6(int) Constant 0
-             192:    8(float) Constant 1065353216
-             193:    9(fvec4) ConstantComposite 192 192 192 192
-             194:             TypePointer Function 9(fvec4)
-             196:      6(int) Constant 1
-             197:             TypePointer Function 8(float)
-             203:             TypePointer Input 6(int)
-     204(sample):    203(ptr) Variable Input
-             210:             TypePointer Output 9(fvec4)
-211(@entryPointOutput.Color):    210(ptr) Variable Output
-             214:             TypePointer Output 8(float)
-215(@entryPointOutput.Depth):    214(ptr) Variable Output
-             218:             TypeSampler
-             219:             TypePointer UniformConstant 218
-    220(g_sSamp):    219(ptr) Variable UniformConstant
+              27:      6(int) Constant 2
+              28:             TypeBool
+              30:     18(int) Constant 2
+              31:             TypeArray 15(fvec2) 30
+              32:    8(float) Constant 1048576000
+              33:   15(fvec2) ConstantComposite 32 32
+              34:    8(float) Constant 3196059648
+              35:   15(fvec2) ConstantComposite 34 34
+              36:          31 ConstantComposite 33 35
+              38:             TypePointer Function 31
+              43:      6(int) Constant 4
+              45:     18(int) Constant 4
+              46:             TypeArray 15(fvec2) 45
+              47:    8(float) Constant 3187671040
+              48:    8(float) Constant 3200253952
+              49:   15(fvec2) ConstantComposite 47 48
+              50:    8(float) Constant 1052770304
+              51:   15(fvec2) ConstantComposite 50 47
+              52:    8(float) Constant 1040187392
+              53:   15(fvec2) ConstantComposite 48 52
+              54:   15(fvec2) ConstantComposite 52 50
+              55:          46 ConstantComposite 49 51 53 54
+              57:             TypePointer Function 46
+              62:      6(int) Constant 8
+              64:     18(int) Constant 8
+              65:             TypeArray 15(fvec2) 64
+              66:    8(float) Constant 1031798784
+              67:    8(float) Constant 3191865344
+              68:   15(fvec2) ConstantComposite 66 67
+              69:    8(float) Constant 3179282432
+              70:    8(float) Constant 1044381696
+              71:   15(fvec2) ConstantComposite 69 70
+              72:    8(float) Constant 1050673152
+              73:   15(fvec2) ConstantComposite 72 66
+              74:    8(float) Constant 3198156800
+              75:   15(fvec2) ConstantComposite 67 74
+              76:   15(fvec2) ConstantComposite 74 72
+              77:    8(float) Constant 3202351104
+              78:   15(fvec2) ConstantComposite 77 69
+              79:    8(float) Constant 1054867456
+              80:   15(fvec2) ConstantComposite 70 79
+              81:   15(fvec2) ConstantComposite 79 77
+              82:          65 ConstantComposite 68 71 73 75 76 78 80 81
+              84:             TypePointer Function 65
+              89:      6(int) Constant 16
+              91:     18(int) Constant 16
+              92:             TypeArray 15(fvec2) 91
+              93:   15(fvec2) ConstantComposite 66 66
+              94:   15(fvec2) ConstantComposite 69 67
+              95:   15(fvec2) ConstantComposite 67 52
+              96:   15(fvec2) ConstantComposite 32 69
+              97:   15(fvec2) ConstantComposite 74 47
+              98:   15(fvec2) ConstantComposite 52 72
+              99:   15(fvec2) ConstantComposite 72 70
+             100:   15(fvec2) ConstantComposite 70 74
+             101:   15(fvec2) ConstantComposite 47 50
+             102:    8(float) Constant 0
+             103:   15(fvec2) ConstantComposite 102 77
+             104:   15(fvec2) ConstantComposite 34 48
+             105:   15(fvec2) ConstantComposite 48 32
+             106:    8(float) Constant 3204448256
+             107:   15(fvec2) ConstantComposite 106 102
+             108:   15(fvec2) ConstantComposite 79 34
+             109:   15(fvec2) ConstantComposite 50 79
+             110:   15(fvec2) ConstantComposite 77 106
+             111:          92 ConstantComposite 93 94 95 96 97 98 99 100 101 103 104 105 107 108 109 110
+             113:             TypePointer Function 92
+             117:   15(fvec2) ConstantComposite 102 102
+             118:             TypeVector 28(bool) 2
+             129:             TypeImage 8(float) 2D array multi-sampled sampled format:Unknown
+             130:             TypePointer UniformConstant 129
+131(g_tTex2dmsf4a):    130(ptr) Variable UniformConstant
+             166:             TypePointer Function 10(PS_OUTPUT)
+             168:      6(int) Constant 0
+             169:    8(float) Constant 1065353216
+             170:    9(fvec4) ConstantComposite 169 169 169 169
+             171:             TypePointer Function 9(fvec4)
+             173:      6(int) Constant 1
+             174:             TypePointer Function 8(float)
+             180:             TypePointer Input 6(int)
+     181(sample):    180(ptr) Variable Input
+             187:             TypePointer Output 9(fvec4)
+188(@entryPointOutput.Color):    187(ptr) Variable Output
+             191:             TypePointer Output 8(float)
+192(@entryPointOutput.Depth):    191(ptr) Variable Output
+             195:             TypeSampler
+             196:             TypePointer UniformConstant 195
+    197(g_sSamp):    196(ptr) Variable UniformConstant
          4(main):           2 Function None 3
                5:             Label
-     202(sample):      7(ptr) Variable Function
-206(flattenTemp):    189(ptr) Variable Function
-      207(param):      7(ptr) Variable Function
-             205:      6(int) Load 204(sample)
-                              Store 202(sample) 205
-             208:      6(int) Load 202(sample)
-                              Store 207(param) 208
-             209:10(PS_OUTPUT) FunctionCall 13(@main(i1;) 207(param)
-                              Store 206(flattenTemp) 209
-             212:    194(ptr) AccessChain 206(flattenTemp) 191
-             213:    9(fvec4) Load 212
-                              Store 211(@entryPointOutput.Color) 213
-             216:    197(ptr) AccessChain 206(flattenTemp) 196
-             217:    8(float) Load 216
-                              Store 215(@entryPointOutput.Depth) 217
+     179(sample):      7(ptr) Variable Function
+183(flattenTemp):    166(ptr) Variable Function
+      184(param):      7(ptr) Variable Function
+             182:      6(int) Load 181(sample)
+                              Store 179(sample) 182
+             185:      6(int) Load 179(sample)
+                              Store 184(param) 185
+             186:10(PS_OUTPUT) FunctionCall 13(@main(i1;) 184(param)
+                              Store 183(flattenTemp) 186
+             189:    171(ptr) AccessChain 183(flattenTemp) 168
+             190:    9(fvec4) Load 189
+                              Store 188(@entryPointOutput.Color) 190
+             193:    174(ptr) AccessChain 183(flattenTemp) 173
+             194:    8(float) Load 193
+                              Store 192(@entryPointOutput.Depth) 194
                               Return
                               FunctionEnd
    13(@main(i1;):10(PS_OUTPUT) Function None 11
@@ -750,165 +751,93 @@ gl_FragCoord origin is upper left
               14:             Label
          17(r00):     16(ptr) Variable Function
 20(@sampleCount):     19(ptr) Variable Function
-              26:     16(ptr) Variable Function
-   42(indexable):     41(ptr) Variable Function
-              46:     16(ptr) Variable Function
-   65(indexable):     64(ptr) Variable Function
-              69:     16(ptr) Variable Function
-   96(indexable):     95(ptr) Variable Function
-             100:     16(ptr) Variable Function
-  129(indexable):    128(ptr) Variable Function
-        138(r01):     16(ptr) Variable Function
-139(@sampleCount):     19(ptr) Variable Function
-             145:     16(ptr) Variable Function
-  151(indexable):     41(ptr) Variable Function
-             155:     16(ptr) Variable Function
-  161(indexable):     64(ptr) Variable Function
-             165:     16(ptr) Variable Function
-  171(indexable):     95(ptr) Variable Function
-             175:     16(ptr) Variable Function
-  181(indexable):    128(ptr) Variable Function
-      190(psout):    189(ptr) Variable Function
+   39(indexable):     38(ptr) Variable Function
+   58(indexable):     57(ptr) Variable Function
+   85(indexable):     84(ptr) Variable Function
+  114(indexable):    113(ptr) Variable Function
+        127(r01):     16(ptr) Variable Function
+128(@sampleCount):     19(ptr) Variable Function
+  137(indexable):     38(ptr) Variable Function
+  143(indexable):     57(ptr) Variable Function
+  149(indexable):     84(ptr) Variable Function
+  155(indexable):    113(ptr) Variable Function
+      167(psout):    166(ptr) Variable Function
               24:          21 Load 23(g_tTex2dmsf4)
               25:     18(int) ImageQuerySamples 24
                               Store 20(@sampleCount) 25
-              27:     18(int) Load 20(@sampleCount)
-              30:    29(bool) IEqual 27 28
-                              SelectionMerge 32 None
-                              BranchConditional 30 31 45
-              31:               Label
-              40:      6(int)   Load 12(sample)
-                                Store 42(indexable) 39
-              43:     16(ptr)   AccessChain 42(indexable) 40
-              44:   15(fvec2)   Load 43
-                                Store 26 44
-                                Branch 32
-              45:               Label
-              47:     18(int)   Load 20(@sampleCount)
-              49:    29(bool)   IEqual 47 48
-                                SelectionMerge 51 None
-                                BranchConditional 49 50 68
-              50:                 Label
-              63:      6(int)     Load 12(sample)
-                                  Store 65(indexable) 62
-              66:     16(ptr)     AccessChain 65(indexable) 63
-              67:   15(fvec2)     Load 66
-                                  Store 46 67
-                                  Branch 51
-              68:                 Label
-              70:     18(int)     Load 20(@sampleCount)
-              72:    29(bool)     IEqual 70 71
-                                  SelectionMerge 74 None
-                                  BranchConditional 72 73 99
-              73:                   Label
-              94:      6(int)       Load 12(sample)
-                                    Store 96(indexable) 93
-              97:     16(ptr)       AccessChain 96(indexable) 94
-              98:   15(fvec2)       Load 97
-                                    Store 69 98
-                                    Branch 74
-              99:                   Label
-             101:     18(int)       Load 20(@sampleCount)
-             103:    29(bool)       IEqual 101 102
-                                    SelectionMerge 105 None
-                                    BranchConditional 103 104 132
-             104:                     Label
-             127:      6(int)         Load 12(sample)
-                                      Store 129(indexable) 126
-             130:     16(ptr)         AccessChain 129(indexable) 127
-             131:   15(fvec2)         Load 130
-                                      Store 100 131
-                                      Branch 105
-             132:                     Label
-                                      Store 100 133
-                                      Branch 105
-             105:                   Label
-             134:   15(fvec2)       Load 100
-                                    Store 69 134
-                                    Branch 74
-              74:                 Label
-             135:   15(fvec2)     Load 69
-                                  Store 46 135
-                                  Branch 51
-              51:               Label
-             136:   15(fvec2)   Load 46
-                                Store 26 136
-                                Branch 32
-              32:             Label
-             137:   15(fvec2) Load 26
-                              Store 17(r00) 137
-             143:         140 Load 142(g_tTex2dmsf4a)
-             144:     18(int) ImageQuerySamples 143
-                              Store 139(@sampleCount) 144
-             146:     18(int) Load 139(@sampleCount)
-             147:    29(bool) IEqual 146 28
-                              SelectionMerge 149 None
-                              BranchConditional 147 148 154
-             148:               Label
-             150:      6(int)   Load 12(sample)
-                                Store 151(indexable) 39
-             152:     16(ptr)   AccessChain 151(indexable) 150
-             153:   15(fvec2)   Load 152
-                                Store 145 153
-                                Branch 149
-             154:               Label
-             156:     18(int)   Load 139(@sampleCount)
-             157:    29(bool)   IEqual 156 48
-                                SelectionMerge 159 None
-                                BranchConditional 157 158 164
-             158:                 Label
-             160:      6(int)     Load 12(sample)
-                                  Store 161(indexable) 62
-             162:     16(ptr)     AccessChain 161(indexable) 160
-             163:   15(fvec2)     Load 162
-                                  Store 155 163
-                                  Branch 159
-             164:                 Label
-             166:     18(int)     Load 139(@sampleCount)
-             167:    29(bool)     IEqual 166 71
-                                  SelectionMerge 169 None
-                                  BranchConditional 167 168 174
-             168:                   Label
-             170:      6(int)       Load 12(sample)
-                                    Store 171(indexable) 93
-             172:     16(ptr)       AccessChain 171(indexable) 170
-             173:   15(fvec2)       Load 172
-                                    Store 165 173
-                                    Branch 169
-             174:                   Label
-             176:     18(int)       Load 139(@sampleCount)
-             177:    29(bool)       IEqual 176 102
-                                    SelectionMerge 179 None
-                                    BranchConditional 177 178 184
-             178:                     Label
-             180:      6(int)         Load 12(sample)
-                                      Store 181(indexable) 126
-             182:     16(ptr)         AccessChain 181(indexable) 180
-             183:   15(fvec2)         Load 182
-                                      Store 175 183
-                                      Branch 179
-             184:                     Label
-                                      Store 175 133
-                                      Branch 179
-             179:                   Label
-             185:   15(fvec2)       Load 175
-                                    Store 165 185
-                                    Branch 169
-             169:                 Label
-             186:   15(fvec2)     Load 165
-                                  Store 155 186
-                                  Branch 159
-             159:               Label
-             187:   15(fvec2)   Load 155
-                                Store 145 187
-                                Branch 149
-             149:             Label
-             188:   15(fvec2) Load 145
-                              Store 138(r01) 188
-             195:    194(ptr) AccessChain 190(psout) 191
-                              Store 195 193
-             198:    197(ptr) AccessChain 190(psout) 196
-                              Store 198 192
-             199:10(PS_OUTPUT) Load 190(psout)
-                              ReturnValue 199
+              26:     18(int) Load 20(@sampleCount)
+              29:    28(bool) IEqual 26 27
+              37:      6(int) Load 12(sample)
+                              Store 39(indexable) 36
+              40:     16(ptr) AccessChain 39(indexable) 37
+              41:   15(fvec2) Load 40
+              42:     18(int) Load 20(@sampleCount)
+              44:    28(bool) IEqual 42 43
+              56:      6(int) Load 12(sample)
+                              Store 58(indexable) 55
+              59:     16(ptr) AccessChain 58(indexable) 56
+              60:   15(fvec2) Load 59
+              61:     18(int) Load 20(@sampleCount)
+              63:    28(bool) IEqual 61 62
+              83:      6(int) Load 12(sample)
+                              Store 85(indexable) 82
+              86:     16(ptr) AccessChain 85(indexable) 83
+              87:   15(fvec2) Load 86
+              88:     18(int) Load 20(@sampleCount)
+              90:    28(bool) IEqual 88 89
+             112:      6(int) Load 12(sample)
+                              Store 114(indexable) 111
+             115:     16(ptr) AccessChain 114(indexable) 112
+             116:   15(fvec2) Load 115
+             119:  118(bvec2) CompositeConstruct 90 90
+             120:   15(fvec2) Select 119 116 117
+             121:  118(bvec2) CompositeConstruct 63 63
+             122:   15(fvec2) Select 121 87 120
+             123:  118(bvec2) CompositeConstruct 44 44
+             124:   15(fvec2) Select 123 60 122
+             125:  118(bvec2) CompositeConstruct 29 29
+             126:   15(fvec2) Select 125 41 124
+                              Store 17(r00) 126
+             132:         129 Load 131(g_tTex2dmsf4a)
+             133:     18(int) ImageQuerySamples 132
+                              Store 128(@sampleCount) 133
+             134:     18(int) Load 128(@sampleCount)
+             135:    28(bool) IEqual 134 27
+             136:      6(int) Load 12(sample)
+                              Store 137(indexable) 36
+             138:     16(ptr) AccessChain 137(indexable) 136
+             139:   15(fvec2) Load 138
+             140:     18(int) Load 128(@sampleCount)
+             141:    28(bool) IEqual 140 43
+             142:      6(int) Load 12(sample)
+                              Store 143(indexable) 55
+             144:     16(ptr) AccessChain 143(indexable) 142
+             145:   15(fvec2) Load 144
+             146:     18(int) Load 128(@sampleCount)
+             147:    28(bool) IEqual 146 62
+             148:      6(int) Load 12(sample)
+                              Store 149(indexable) 82
+             150:     16(ptr) AccessChain 149(indexable) 148
+             151:   15(fvec2) Load 150
+             152:     18(int) Load 128(@sampleCount)
+             153:    28(bool) IEqual 152 89
+             154:      6(int) Load 12(sample)
+                              Store 155(indexable) 111
+             156:     16(ptr) AccessChain 155(indexable) 154
+             157:   15(fvec2) Load 156
+             158:  118(bvec2) CompositeConstruct 153 153
+             159:   15(fvec2) Select 158 157 117
+             160:  118(bvec2) CompositeConstruct 147 147
+             161:   15(fvec2) Select 160 151 159
+             162:  118(bvec2) CompositeConstruct 141 141
+             163:   15(fvec2) Select 162 145 161
+             164:  118(bvec2) CompositeConstruct 135 135
+             165:   15(fvec2) Select 164 139 163
+                              Store 127(r01) 165
+             172:    171(ptr) AccessChain 167(psout) 168
+                              Store 172 170
+             175:    174(ptr) AccessChain 167(psout) 173
+                              Store 175 169
+             176:10(PS_OUTPUT) Load 167(psout)
+                              ReturnValue 176
                               FunctionEnd

+ 4 - 4
3rdparty/glslang/Test/baseResults/hlsl.implicitBool.frag.out

@@ -133,7 +133,7 @@ gl_FragCoord origin is upper left
 0:28      Sequence
 0:28        move second child to first child ( temp float)
 0:28          'g' ( temp float)
-0:28          Test condition and select ( temp float)
+0:28          Test condition and select ( temp float): no shortcircuit
 0:28            Condition
 0:28            Convert float to bool ( temp bool)
 0:28              condf: direct index for structure ( uniform float)
@@ -302,7 +302,7 @@ gl_FragCoord origin is upper left
 0:28      Sequence
 0:28        move second child to first child ( temp float)
 0:28          'g' ( temp float)
-0:28          Test condition and select ( temp float)
+0:28          Test condition and select ( temp float): no shortcircuit
 0:28            Condition
 0:28            Convert float to bool ( temp bool)
 0:28              condf: direct index for structure ( uniform float)
@@ -358,8 +358,8 @@ gl_FragCoord origin is upper left
                               Name 138  "@entryPointOutput"
                               MemberDecorate 16($Global) 0 Offset 0
                               MemberDecorate 16($Global) 1 Offset 4
-                              MemberDecorate 16($Global) 2 Offset 16
-                              MemberDecorate 16($Global) 3 Offset 32
+                              MemberDecorate 16($Global) 2 Offset 8
+                              MemberDecorate 16($Global) 3 Offset 12
                               Decorate 16($Global) Block
                               Decorate 18 DescriptorSet 0
                               Decorate 138(@entryPointOutput) Location 0

+ 47 - 57
3rdparty/glslang/Test/baseResults/hlsl.intrinsics.lit.frag.out

@@ -18,7 +18,7 @@ gl_FragCoord origin is upper left
 0:3              'n_dot_l' ( in float)
 0:3              Constant:
 0:3                0.000000
-0:3            Test condition and select ( temp float)
+0:3            Test condition and select ( temp float): no shortcircuit
 0:3              Condition
 0:3              Compare Less Than ( temp bool)
 0:3                min ( temp float)
@@ -79,7 +79,7 @@ gl_FragCoord origin is upper left
 0:3              'n_dot_l' ( in float)
 0:3              Constant:
 0:3                0.000000
-0:3            Test condition and select ( temp float)
+0:3            Test condition and select ( temp float): no shortcircuit
 0:3              Condition
 0:3              Compare Less Than ( temp bool)
 0:3                min ( temp float)
@@ -119,12 +119,12 @@ gl_FragCoord origin is upper left
 
 // Module Version 10000
 // Generated by (magic number): 80004
-// Id's are bound by 52
+// Id's are bound by 48
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "PixelShaderFunction" 37 40 43
+                              EntryPoint Fragment 4  "PixelShaderFunction" 33 36 39
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "PixelShaderFunction"
@@ -133,18 +133,18 @@ gl_FragCoord origin is upper left
                               Name 10  "n_dot_h"
                               Name 11  "m"
                               Name 16  "r0"
-                              Name 35  "n_dot_l"
-                              Name 37  "n_dot_l"
-                              Name 39  "n_dot_h"
-                              Name 40  "n_dot_h"
-                              Name 42  "m"
-                              Name 43  "m"
+                              Name 31  "n_dot_l"
+                              Name 33  "n_dot_l"
+                              Name 35  "n_dot_h"
+                              Name 36  "n_dot_h"
+                              Name 38  "m"
+                              Name 39  "m"
+                              Name 41  "param"
+                              Name 43  "param"
                               Name 45  "param"
-                              Name 47  "param"
-                              Name 49  "param"
-                              Decorate 37(n_dot_l) Location 0
-                              Decorate 40(n_dot_h) Location 1
-                              Decorate 43(m) Location 2
+                              Decorate 33(n_dot_l) Location 0
+                              Decorate 36(n_dot_h) Location 1
+                              Decorate 39(m) Location 2
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
@@ -154,32 +154,32 @@ gl_FragCoord origin is upper left
               15:             TypePointer Function 14(fvec4)
               17:    6(float) Constant 1065353216
               19:    6(float) Constant 0
-              25:             TypeBool
-              36:             TypePointer Input 6(float)
-     37(n_dot_l):     36(ptr) Variable Input
-     40(n_dot_h):     36(ptr) Variable Input
-           43(m):     36(ptr) Variable Input
+              24:             TypeBool
+              32:             TypePointer Input 6(float)
+     33(n_dot_l):     32(ptr) Variable Input
+     36(n_dot_h):     32(ptr) Variable Input
+           39(m):     32(ptr) Variable Input
 4(PixelShaderFunction):           2 Function None 3
                5:             Label
-     35(n_dot_l):      7(ptr) Variable Function
-     39(n_dot_h):      7(ptr) Variable Function
-           42(m):      7(ptr) Variable Function
+     31(n_dot_l):      7(ptr) Variable Function
+     35(n_dot_h):      7(ptr) Variable Function
+           38(m):      7(ptr) Variable Function
+       41(param):      7(ptr) Variable Function
+       43(param):      7(ptr) Variable Function
        45(param):      7(ptr) Variable Function
-       47(param):      7(ptr) Variable Function
-       49(param):      7(ptr) Variable Function
-              38:    6(float) Load 37(n_dot_l)
-                              Store 35(n_dot_l) 38
-              41:    6(float) Load 40(n_dot_h)
-                              Store 39(n_dot_h) 41
-              44:    6(float) Load 43(m)
-                              Store 42(m) 44
-              46:    6(float) Load 35(n_dot_l)
+              34:    6(float) Load 33(n_dot_l)
+                              Store 31(n_dot_l) 34
+              37:    6(float) Load 36(n_dot_h)
+                              Store 35(n_dot_h) 37
+              40:    6(float) Load 39(m)
+                              Store 38(m) 40
+              42:    6(float) Load 31(n_dot_l)
+                              Store 41(param) 42
+              44:    6(float) Load 35(n_dot_h)
+                              Store 43(param) 44
+              46:    6(float) Load 38(m)
                               Store 45(param) 46
-              48:    6(float) Load 39(n_dot_h)
-                              Store 47(param) 48
-              50:    6(float) Load 42(m)
-                              Store 49(param) 50
-              51:           2 FunctionCall 12(@PixelShaderFunction(f1;f1;f1;) 45(param) 47(param) 49(param)
+              47:           2 FunctionCall 12(@PixelShaderFunction(f1;f1;f1;) 41(param) 43(param) 45(param)
                               Return
                               FunctionEnd
 12(@PixelShaderFunction(f1;f1;f1;):           2 Function None 8
@@ -188,27 +188,17 @@ gl_FragCoord origin is upper left
            11(m):      7(ptr) FunctionParameter
               13:             Label
           16(r0):     15(ptr) Variable Function
-              21:      7(ptr) Variable Function
               18:    6(float) Load 9(n_dot_l)
               20:    6(float) ExtInst 1(GLSL.std.450) 40(FMax) 18 19
-              22:    6(float) Load 9(n_dot_l)
-              23:    6(float) Load 10(n_dot_h)
-              24:    6(float) ExtInst 1(GLSL.std.450) 37(FMin) 22 23
-              26:    25(bool) FOrdLessThan 24 19
-                              SelectionMerge 28 None
-                              BranchConditional 26 27 29
-              27:               Label
-                                Store 21 19
-                                Branch 28
-              29:               Label
-              30:    6(float)   Load 10(n_dot_h)
-              31:    6(float)   Load 11(m)
-              32:    6(float)   FMul 30 31
-                                Store 21 32
-                                Branch 28
-              28:             Label
-              33:    6(float) Load 21
-              34:   14(fvec4) CompositeConstruct 17 20 33 17
-                              Store 16(r0) 34
+              21:    6(float) Load 9(n_dot_l)
+              22:    6(float) Load 10(n_dot_h)
+              23:    6(float) ExtInst 1(GLSL.std.450) 37(FMin) 21 22
+              25:    24(bool) FOrdLessThan 23 19
+              26:    6(float) Load 10(n_dot_h)
+              27:    6(float) Load 11(m)
+              28:    6(float) FMul 26 27
+              29:    6(float) Select 25 19 28
+              30:   14(fvec4) CompositeConstruct 17 20 29 17
+                              Store 16(r0) 30
                               Return
                               FunctionEnd

+ 43 - 54
3rdparty/glslang/Test/baseResults/hlsl.type.identifier.frag.out

@@ -86,7 +86,7 @@ gl_FragCoord origin is upper left
 0:25                    'uint' ( temp mediump uint)
 0:25                'min16float' ( temp mediump float)
 0:25              'min10float' ( temp mediump float)
-0:25            Test condition and select ( temp mediump float)
+0:25            Test condition and select ( temp mediump float): no shortcircuit
 0:25              Condition
 0:25              direct index ( temp bool)
 0:25                'bool' ( temp 2-element array of bool)
@@ -221,7 +221,7 @@ gl_FragCoord origin is upper left
 0:25                    'uint' ( temp mediump uint)
 0:25                'min16float' ( temp mediump float)
 0:25              'min10float' ( temp mediump float)
-0:25            Test condition and select ( temp mediump float)
+0:25            Test condition and select ( temp mediump float): no shortcircuit
 0:25              Condition
 0:25              direct index ( temp bool)
 0:25                'bool' ( temp 2-element array of bool)
@@ -267,12 +267,12 @@ gl_FragCoord origin is upper left
 
 // Module Version 10000
 // Generated by (magic number): 80004
-// Id's are bound by 109
+// Id's are bound by 105
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 107
+                              EntryPoint Fragment 4  "main" 103
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "main"
@@ -289,9 +289,9 @@ gl_FragCoord origin is upper left
                               Name 56  "foo_t"
                               MemberName 56(foo_t) 0  "float"
                               Name 58  "float"
-                              Name 86  "param"
-                              Name 93  "half2x3"
-                              Name 107  "@entryPointOutput"
+                              Name 82  "param"
+                              Name 89  "half2x3"
+                              Name 103  "@entryPointOutput"
                               Decorate 49(min16float) RelaxedPrecision
                               Decorate 50 RelaxedPrecision
                               Decorate 51 RelaxedPrecision
@@ -308,15 +308,14 @@ gl_FragCoord origin is upper left
                               Decorate 72 RelaxedPrecision
                               Decorate 73 RelaxedPrecision
                               Decorate 74 RelaxedPrecision
-                              Decorate 80 RelaxedPrecision
+                              Decorate 77 RelaxedPrecision
+                              Decorate 78 RelaxedPrecision
+                              Decorate 79 RelaxedPrecision
                               Decorate 81 RelaxedPrecision
                               Decorate 83 RelaxedPrecision
                               Decorate 84 RelaxedPrecision
                               Decorate 85 RelaxedPrecision
-                              Decorate 87 RelaxedPrecision
-                              Decorate 88 RelaxedPrecision
-                              Decorate 89 RelaxedPrecision
-                              Decorate 107(@entryPointOutput) Location 0
+                              Decorate 103(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
@@ -341,16 +340,16 @@ gl_FragCoord origin is upper left
        56(foo_t):             TypeStruct 6(float)
               57:             TypePointer Function 56(foo_t)
               59:    6(float) Constant 1109917696
-              90:             TypeVector 6(float) 3
-              91:             TypeMatrix 90(fvec3) 2
-              92:             TypePointer Function 91
-              97:     22(int) Constant 0
-             106:             TypePointer Output 12(fvec4)
-107(@entryPointOutput):    106(ptr) Variable Output
+              86:             TypeVector 6(float) 3
+              87:             TypeMatrix 86(fvec3) 2
+              88:             TypePointer Function 87
+              93:     22(int) Constant 0
+             102:             TypePointer Output 12(fvec4)
+103(@entryPointOutput):    102(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-             108:   12(fvec4) FunctionCall 14(@main()
-                              Store 107(@entryPointOutput) 108
+             104:   12(fvec4) FunctionCall 14(@main()
+                              Store 103(@entryPointOutput) 104
                               Return
                               FunctionEnd
       10(fn(f1;):    6(float) Function None 8
@@ -369,9 +368,8 @@ gl_FragCoord origin is upper left
   52(min10float):      7(ptr) Variable Function
         54(half):      7(ptr) Variable Function
        58(float):     57(ptr) Variable Function
-              75:      7(ptr) Variable Function
-       86(param):      7(ptr) Variable Function
-     93(half2x3):     92(ptr) Variable Function
+       82(param):      7(ptr) Variable Function
+     89(half2x3):     88(ptr) Variable Function
                               Store 19(float) 20
               27:    6(float) Load 19(float)
               29:    21(bool) FOrdNotEqual 27 28
@@ -412,36 +410,27 @@ gl_FragCoord origin is upper left
               72:    6(float) FAdd 70 71
               73:    6(float) Load 52(min10float)
               74:    6(float) FAdd 72 73
-              76:     37(ptr) AccessChain 26(bool) 40
-              77:    21(bool) Load 76
-                              SelectionMerge 79 None
-                              BranchConditional 77 78 82
-              78:               Label
-              80:     33(int)   Load 35(int)
-              81:    6(float)   ConvertSToF 80
-                                Store 75 81
-                                Branch 79
-              82:               Label
-              83:    6(float)   Load 19(float)
-                                Store 75 83
-                                Branch 79
-              79:             Label
-              84:    6(float) Load 75
-              85:    6(float) FAdd 74 84
-              87:    6(float) Load 19(float)
-                              Store 86(param) 87
-              88:    6(float) FunctionCall 10(fn(f1;) 86(param)
-              89:    6(float) FAdd 85 88
-                              Store 19(float) 89
-              94:    6(float) Load 19(float)
+              75:     37(ptr) AccessChain 26(bool) 40
+              76:    21(bool) Load 75
+              77:     33(int) Load 35(int)
+              78:    6(float) ConvertSToF 77
+              79:    6(float) Load 19(float)
+              80:    6(float) Select 76 78 79
+              81:    6(float) FAdd 74 80
+              83:    6(float) Load 19(float)
+                              Store 82(param) 83
+              84:    6(float) FunctionCall 10(fn(f1;) 82(param)
+              85:    6(float) FAdd 81 84
+                              Store 19(float) 85
+              90:    6(float) Load 19(float)
+              91:    6(float) Load 19(float)
+              92:    6(float) FMul 90 91
+              94:      7(ptr) AccessChain 89(half2x3) 40 93
+                              Store 94 92
               95:    6(float) Load 19(float)
-              96:    6(float) FMul 94 95
-              98:      7(ptr) AccessChain 93(half2x3) 40 97
-                              Store 98 96
-              99:    6(float) Load 19(float)
-             100:      7(ptr) AccessChain 93(half2x3) 40 97
-             101:    6(float) Load 100
-             102:    6(float) FAdd 99 101
-             103:   12(fvec4) CompositeConstruct 102 102 102 102
-                              ReturnValue 103
+              96:      7(ptr) AccessChain 89(half2x3) 40 93
+              97:    6(float) Load 96
+              98:    6(float) FAdd 95 97
+              99:   12(fvec4) CompositeConstruct 98 98 98 98
+                              ReturnValue 99
                               FunctionEnd

+ 4 - 4
3rdparty/glslang/Test/baseResults/link1.vk.frag.out

@@ -20,12 +20,12 @@ gl_FragCoord origin is upper left
 0:7    Sequence
 0:7      Branch: Return with expression
 0:7        texture ( global highp 4-component vector of float)
-0:7          's2D' ( uniform highp sampler2D)
+0:7          's2D' (layout( binding=1) uniform highp sampler2D)
 0:7          Constant:
 0:7            0.500000
 0:7            0.500000
 0:?   Linker Objects
-0:?     's2D' ( uniform highp sampler2D)
+0:?     's2D' (layout( binding=1) uniform highp sampler2D)
 
 
 Linked fragment stage:
@@ -45,12 +45,12 @@ gl_FragCoord origin is upper left
 0:7    Sequence
 0:7      Branch: Return with expression
 0:7        texture ( global highp 4-component vector of float)
-0:7          's2D' ( uniform highp sampler2D)
+0:7          's2D' (layout( binding=1) uniform highp sampler2D)
 0:7          Constant:
 0:7            0.500000
 0:7            0.500000
 0:?   Linker Objects
 0:?     'color' ( out highp 4-component vector of float)
-0:?     's2D' ( uniform highp sampler2D)
+0:?     's2D' (layout( binding=1) uniform highp sampler2D)
 
 SPIR-V is not generated for failed compile or link

+ 1 - 2
3rdparty/glslang/Test/baseResults/specExamples.vert.out

@@ -19,7 +19,6 @@ ERROR: 0:85: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCount
 ERROR: 0:87: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
 ERROR: 0:89: 'binding' : atomic_uint binding is too large 
 ERROR: 0:91: 'bar' : redefinition 
-ERROR: 0:92: 'atomic_uint' : layout(binding=X) is required 
 ERROR: 0:94: 'a2' : redefinition 
 ERROR: 0:95: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
 ERROR: 0:96: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
@@ -32,7 +31,7 @@ ERROR: 0:134: '' : function does not return a value: funcA
 ERROR: 0:136: '' : function does not return a value: funcB
 ERROR: 0:153: '' : function does not return a value: func3
 ERROR: 0:170: 'coherent' : argument cannot drop memory qualifier when passed to formal parameter 
-ERROR: 33 compilation errors.  No code generated.
+ERROR: 32 compilation errors.  No code generated.
 
 
 Shader version: 430

+ 24 - 24
3rdparty/glslang/Test/baseResults/spv.400.frag.out

@@ -273,10 +273,10 @@ spv.400.frag
      439(bvec2v):    438(ptr) Variable Function
      448(bvec3v):    447(ptr) Variable Function
      457(bvec4v):    456(ptr) Variable Function
-             556:    429(ptr) Variable Function
-             565:    438(ptr) Variable Function
-             574:    447(ptr) Variable Function
-             583:    456(ptr) Variable Function
+             557:    429(ptr) Variable Function
+             566:    438(ptr) Variable Function
+             575:    447(ptr) Variable Function
+             584:    456(ptr) Variable Function
      739(dmat2v):    738(ptr) Variable Function
      745(dmat3v):    744(ptr) Variable Function
      751(dmat4v):    750(ptr) Variable Function
@@ -875,61 +875,61 @@ spv.400.frag
              554:   53(fvec4) Load 55(dvec4v)
              555:  455(bvec4) IsNan 554
                               Store 457(bvec4v) 555
-             557:   428(bool) Load 430(boolv)
+             556:   428(bool) Load 430(boolv)
                               SelectionMerge 559 None
-                              BranchConditional 557 558 562
+                              BranchConditional 556 558 562
              558:               Label
              560:   39(float)   Load 41(doublev)
              561:   428(bool)   IsInf 560
-                                Store 556 561
+                                Store 557 561
                                 Branch 559
              562:               Label
-                                Store 556 563
+                                Store 557 563
                                 Branch 559
              559:             Label
-             564:   428(bool) Load 556
+             564:   428(bool) Load 557
                               Store 430(boolv) 564
-             566:   428(bool) Load 430(boolv)
+             565:   428(bool) Load 430(boolv)
                               SelectionMerge 568 None
-                              BranchConditional 566 567 571
+                              BranchConditional 565 567 571
              567:               Label
              569:   43(fvec2)   Load 45(dvec2v)
              570:  437(bvec2)   IsInf 569
-                                Store 565 570
+                                Store 566 570
                                 Branch 568
              571:               Label
-                                Store 565 572
+                                Store 566 572
                                 Branch 568
              568:             Label
-             573:  437(bvec2) Load 565
+             573:  437(bvec2) Load 566
                               Store 439(bvec2v) 573
-             575:   428(bool) Load 430(boolv)
+             574:   428(bool) Load 430(boolv)
                               SelectionMerge 577 None
-                              BranchConditional 575 576 580
+                              BranchConditional 574 576 580
              576:               Label
              578:   48(fvec3)   Load 50(dvec3v)
              579:  446(bvec3)   IsInf 578
-                                Store 574 579
+                                Store 575 579
                                 Branch 577
              580:               Label
-                                Store 574 581
+                                Store 575 581
                                 Branch 577
              577:             Label
-             582:  446(bvec3) Load 574
+             582:  446(bvec3) Load 575
                               Store 448(bvec3v) 582
-             584:   428(bool) Load 430(boolv)
+             583:   428(bool) Load 430(boolv)
                               SelectionMerge 586 None
-                              BranchConditional 584 585 589
+                              BranchConditional 583 585 589
              585:               Label
              587:   53(fvec4)   Load 55(dvec4v)
              588:  455(bvec4)   IsInf 587
-                                Store 583 588
+                                Store 584 588
                                 Branch 586
              589:               Label
-                                Store 583 590
+                                Store 584 590
                                 Branch 586
              586:             Label
-             591:  455(bvec4) Load 583
+             591:  455(bvec4) Load 584
                               Store 457(bvec4v) 591
              592:   39(float) Load 41(doublev)
              593:   39(float) ExtInst 1(GLSL.std.450) 66(Length) 592

+ 12 - 12
3rdparty/glslang/Test/baseResults/spv.Operations.frag.out

@@ -90,10 +90,10 @@ spv.Operations.frag
           188(f):    143(ptr) Variable Function
           285(u):    284(ptr) Variable Function
           305(b):    304(ptr) Variable Function
-             486:      8(ptr) Variable Function
+             487:      8(ptr) Variable Function
          503(m1):    502(ptr) Variable Function
          510(m2):    502(ptr) Variable Function
-             513:    502(ptr) Variable Function
+             514:    502(ptr) Variable Function
               12:    7(fvec4) Load 11(uv4)
               13:    7(fvec4) ExtInst 1(GLSL.std.450) 11(Radians) 12
                               Store 9(v) 13
@@ -658,9 +658,9 @@ spv.Operations.frag
              482:   178(bool) Load 305(b)
              483:   178(bool) LogicalNot 482
                               Store 305(b) 483
-             487:   178(bool) Load 305(b)
+             486:   178(bool) Load 305(b)
                               SelectionMerge 489 None
-                              BranchConditional 487 488 498
+                              BranchConditional 486 488 498
              488:               Label
              490:     18(int)   Load 20(i)
              491:    6(float)   ConvertSToF 490
@@ -670,30 +670,30 @@ spv.Operations.frag
              495:    7(fvec4)   FAdd 492 494
              496:    7(fvec4)   Load 9(v)
              497:    7(fvec4)   FAdd 495 496
-                                Store 486 497
+                                Store 487 497
                                 Branch 489
              498:               Label
              499:    7(fvec4)   Load 9(v)
-                                Store 486 499
+                                Store 487 499
                                 Branch 489
              489:             Label
-             500:    7(fvec4) Load 486
+             500:    7(fvec4) Load 487
                               Store 485(FragColor) 500
                               Store 503(m1) 509
                               Store 510(m2) 512
-             514:   178(bool) Load 305(b)
+             513:   178(bool) Load 305(b)
                               SelectionMerge 516 None
-                              BranchConditional 514 515 518
+                              BranchConditional 513 515 518
              515:               Label
              517:         501   Load 503(m1)
-                                Store 513 517
+                                Store 514 517
                                 Branch 516
              518:               Label
              519:         501   Load 510(m2)
-                                Store 513 519
+                                Store 514 519
                                 Branch 516
              516:             Label
-             520:      8(ptr) AccessChain 513 405
+             520:      8(ptr) AccessChain 514 405
              521:    7(fvec4) Load 520
              522:    7(fvec4) Load 485(FragColor)
              523:    7(fvec4) FAdd 522 521

+ 12 - 12
3rdparty/glslang/Test/baseResults/spv.bitCast.frag.out

@@ -86,8 +86,8 @@ spv.bitCast.frag
          148(u4):    147(ptr) Variable Input
              153:             TypePointer Output 46(fvec4)
   154(fragColor):    153(ptr) Variable Output
-             159:             TypeBool
-             160:             TypeVector 159(bool) 4
+             158:             TypeBool
+             159:             TypeVector 158(bool) 4
              168:   12(float) Constant 1045220557
              169:   46(fvec4) ConstantComposite 168 168 168 168
          4(main):           2 Function None 3
@@ -95,7 +95,7 @@ spv.bitCast.frag
         9(idata):      8(ptr) Variable Function
        55(udata):     54(ptr) Variable Function
        85(fdata):     84(ptr) Variable Function
-             155:     84(ptr) Variable Function
+             162:     84(ptr) Variable Function
                               Store 9(idata) 11
               15:   12(float) Load 14(f1)
               16:      6(int) Bitcast 15
@@ -211,24 +211,24 @@ spv.bitCast.frag
              151:   46(fvec4) Load 85(fdata)
              152:   46(fvec4) FAdd 151 150
                               Store 85(fdata) 152
-             156:    7(ivec4) Load 9(idata)
-             157:   53(ivec4) Bitcast 156
-             158:   53(ivec4) Load 55(udata)
-             161:  160(bvec4) IEqual 157 158
-             162:   159(bool) All 161
+             155:    7(ivec4) Load 9(idata)
+             156:   53(ivec4) Bitcast 155
+             157:   53(ivec4) Load 55(udata)
+             160:  159(bvec4) IEqual 156 157
+             161:   158(bool) All 160
                               SelectionMerge 164 None
-                              BranchConditional 162 163 166
+                              BranchConditional 161 163 166
              163:               Label
              165:   46(fvec4)   Load 85(fdata)
-                                Store 155 165
+                                Store 162 165
                                 Branch 164
              166:               Label
              167:   46(fvec4)   Load 85(fdata)
              170:   46(fvec4)   FAdd 167 169
-                                Store 155 170
+                                Store 162 170
                                 Branch 164
              164:             Label
-             171:   46(fvec4) Load 155
+             171:   46(fvec4) Load 162
                               Store 154(fragColor) 171
                               Return
                               FunctionEnd

+ 54 - 54
3rdparty/glslang/Test/baseResults/spv.conversion.frag.out

@@ -119,8 +119,8 @@ spv.conversion.frag
              315:     13(int) Constant 1
              321:             TypePointer Output 95(fvec4)
 322(gl_FragColor):    321(ptr) Variable Output
-             337:     13(int) Constant 2
-             350:     13(int) Constant 3
+             336:     13(int) Constant 2
+             349:     13(int) Constant 3
              427:             TypePointer Private 6(bool)
         428(u_b):    427(ptr) Variable Private
              429:             TypePointer Private 23(bvec2)
@@ -163,9 +163,9 @@ spv.conversion.frag
          110(f2):    109(ptr) Variable Function
          114(f3):    113(ptr) Variable Function
          118(f4):    117(ptr) Variable Function
-             297:    105(ptr) Variable Function
-             307:    105(ptr) Variable Function
-             323:    117(ptr) Variable Function
+             298:    105(ptr) Variable Function
+             309:    105(ptr) Variable Function
+             353:    117(ptr) Variable Function
         417(cv2):     93(ptr) Variable Function
         418(cv5):     44(ptr) Variable Function
               12:      9(int) Load 11(u_i)
@@ -425,72 +425,72 @@ spv.conversion.frag
                               SelectionMerge 296 None
                               BranchConditional 294 295 296
              295:               Label
-             298:     6(bool)   Load 8(b)
+             297:     6(bool)   Load 8(b)
                                 SelectionMerge 300 None
-                                BranchConditional 298 299 303
+                                BranchConditional 297 299 303
              299:                 Label
              301:      9(int)     Load 58(i)
              302:   16(float)     ConvertSToF 301
-                                  Store 297 302
+                                  Store 298 302
                                   Branch 300
              303:                 Label
              304:    105(ptr)     AccessChain 110(f2) 14
              305:   16(float)     Load 304
-                                  Store 297 305
+                                  Store 298 305
                                   Branch 300
              300:               Label
-             306:   16(float)   Load 297
-             308:      7(ptr)   AccessChain 25(b2) 14
-             309:     6(bool)   Load 308
+             306:   16(float)   Load 298
+             307:      7(ptr)   AccessChain 25(b2) 14
+             308:     6(bool)   Load 307
                                 SelectionMerge 311 None
-                                BranchConditional 309 310 314
+                                BranchConditional 308 310 314
              310:                 Label
              312:    105(ptr)     AccessChain 114(f3) 14
              313:   16(float)     Load 312
-                                  Store 307 313
+                                  Store 309 313
                                   Branch 311
              314:                 Label
              316:     57(ptr)     AccessChain 68(i2) 315
              317:      9(int)     Load 316
              318:   16(float)     ConvertSToF 317
-                                  Store 307 318
+                                  Store 309 318
                                   Branch 311
              311:               Label
-             319:   16(float)   Load 307
+             319:   16(float)   Load 309
              320:   16(float)   FAdd 306 319
                                 Store 106(f) 320
                                 Branch 296
              296:             Label
-             324:     6(bool) Load 8(b)
-             325:      7(ptr) AccessChain 25(b2) 14
-             326:     6(bool) Load 325
-             327:     6(bool) LogicalOr 324 326
-             328:      7(ptr) AccessChain 25(b2) 315
-             329:     6(bool) Load 328
-             330:     6(bool) LogicalOr 327 329
-             331:      7(ptr) AccessChain 33(b3) 14
-             332:     6(bool) Load 331
-             333:     6(bool) LogicalOr 330 332
-             334:      7(ptr) AccessChain 33(b3) 315
-             335:     6(bool) Load 334
-             336:     6(bool) LogicalOr 333 335
-             338:      7(ptr) AccessChain 33(b3) 337
-             339:     6(bool) Load 338
-             340:     6(bool) LogicalOr 336 339
-             341:      7(ptr) AccessChain 45(b4) 14
-             342:     6(bool) Load 341
-             343:     6(bool) LogicalOr 340 342
-             344:      7(ptr) AccessChain 45(b4) 315
-             345:     6(bool) Load 344
-             346:     6(bool) LogicalOr 343 345
-             347:      7(ptr) AccessChain 45(b4) 337
-             348:     6(bool) Load 347
-             349:     6(bool) LogicalOr 346 348
-             351:      7(ptr) AccessChain 45(b4) 350
-             352:     6(bool) Load 351
-             353:     6(bool) LogicalOr 349 352
+             323:     6(bool) Load 8(b)
+             324:      7(ptr) AccessChain 25(b2) 14
+             325:     6(bool) Load 324
+             326:     6(bool) LogicalOr 323 325
+             327:      7(ptr) AccessChain 25(b2) 315
+             328:     6(bool) Load 327
+             329:     6(bool) LogicalOr 326 328
+             330:      7(ptr) AccessChain 33(b3) 14
+             331:     6(bool) Load 330
+             332:     6(bool) LogicalOr 329 331
+             333:      7(ptr) AccessChain 33(b3) 315
+             334:     6(bool) Load 333
+             335:     6(bool) LogicalOr 332 334
+             337:      7(ptr) AccessChain 33(b3) 336
+             338:     6(bool) Load 337
+             339:     6(bool) LogicalOr 335 338
+             340:      7(ptr) AccessChain 45(b4) 14
+             341:     6(bool) Load 340
+             342:     6(bool) LogicalOr 339 341
+             343:      7(ptr) AccessChain 45(b4) 315
+             344:     6(bool) Load 343
+             345:     6(bool) LogicalOr 342 344
+             346:      7(ptr) AccessChain 45(b4) 336
+             347:     6(bool) Load 346
+             348:     6(bool) LogicalOr 345 347
+             350:      7(ptr) AccessChain 45(b4) 349
+             351:     6(bool) Load 350
+             352:     6(bool) LogicalOr 348 351
                               SelectionMerge 355 None
-                              BranchConditional 353 354 415
+                              BranchConditional 352 354 415
              354:               Label
              356:      9(int)   Load 58(i)
              357:     57(ptr)   AccessChain 68(i2) 14
@@ -505,7 +505,7 @@ spv.conversion.frag
              366:     57(ptr)   AccessChain 81(i3) 315
              367:      9(int)   Load 366
              368:      9(int)   IAdd 365 367
-             369:     57(ptr)   AccessChain 81(i3) 337
+             369:     57(ptr)   AccessChain 81(i3) 336
              370:      9(int)   Load 369
              371:      9(int)   IAdd 368 370
              372:     57(ptr)   AccessChain 94(i4) 14
@@ -514,10 +514,10 @@ spv.conversion.frag
              375:     57(ptr)   AccessChain 94(i4) 315
              376:      9(int)   Load 375
              377:      9(int)   IAdd 374 376
-             378:     57(ptr)   AccessChain 94(i4) 337
+             378:     57(ptr)   AccessChain 94(i4) 336
              379:      9(int)   Load 378
              380:      9(int)   IAdd 377 379
-             381:     57(ptr)   AccessChain 94(i4) 350
+             381:     57(ptr)   AccessChain 94(i4) 349
              382:      9(int)   Load 381
              383:      9(int)   IAdd 380 382
              384:   16(float)   ConvertSToF 383
@@ -535,7 +535,7 @@ spv.conversion.frag
              396:    105(ptr)   AccessChain 114(f3) 315
              397:   16(float)   Load 396
              398:   16(float)   FAdd 395 397
-             399:    105(ptr)   AccessChain 114(f3) 337
+             399:    105(ptr)   AccessChain 114(f3) 336
              400:   16(float)   Load 399
              401:   16(float)   FAdd 398 400
              402:    105(ptr)   AccessChain 118(f4) 14
@@ -544,20 +544,20 @@ spv.conversion.frag
              405:    105(ptr)   AccessChain 118(f4) 315
              406:   16(float)   Load 405
              407:   16(float)   FAdd 404 406
-             408:    105(ptr)   AccessChain 118(f4) 337
+             408:    105(ptr)   AccessChain 118(f4) 336
              409:   16(float)   Load 408
              410:   16(float)   FAdd 407 409
-             411:    105(ptr)   AccessChain 118(f4) 350
+             411:    105(ptr)   AccessChain 118(f4) 349
              412:   16(float)   Load 411
              413:   16(float)   FAdd 410 412
              414:   95(fvec4)   CompositeConstruct 413 413 413 413
-                                Store 323 414
+                                Store 353 414
                                 Branch 355
              415:               Label
-                                Store 323 151
+                                Store 353 151
                                 Branch 355
              355:             Label
-             416:   95(fvec4) Load 323
+             416:   95(fvec4) Load 353
                               Store 322(gl_FragColor) 416
                               Store 417(cv2) 102
              419:   92(ivec4) Load 417(cv2)

+ 12 - 9
3rdparty/glslang/Test/baseResults/spv.debugInfo.frag.out

@@ -11,6 +11,7 @@ spv.debugInfo.frag
                1:             String  "spv.debugInfo.frag"
                               Source GLSL 450 1  "// OpModuleProcessed no-storage-format
 // OpModuleProcessed resource-set-binding 3
+// OpModuleProcessed auto-map-bindings
 // OpModuleProcessed auto-map-locations
 // OpModuleProcessed client opengl100
 // OpModuleProcessed target-env opengl
@@ -95,7 +96,9 @@ void main()
                               MemberDecorate 54(ubuf) 0 Offset 0
                               Decorate 54(ubuf) Block
                               Decorate 56 DescriptorSet 3
+                              Decorate 56 Binding 0
                               Decorate 69(s2d) DescriptorSet 3
+                              Decorate 69(s2d) Binding 1
                3:             TypeVoid
                4:             TypeFunction 3
                7:             TypeInt 32 1
@@ -135,13 +138,13 @@ void main()
               77:             TypePointer Uniform 7(int)
              106:      7(int) Constant 10
              111:      7(int) Constant 1
-             114:             TypePointer Output 10(float)
-             117:   10(float) Constant 1092616192
+             113:             TypePointer Output 10(float)
+             116:   10(float) Constant 1092616192
          5(main):           3 Function None 4
                6:             Label
        59(param):     58(ptr) Variable Function
            99(i):     19(ptr) Variable Function
-             113:     16(ptr) Variable Function
+             118:     16(ptr) Variable Function
                               Line 1 30 0
               61:     60(ptr) AccessChain 56 18
               62:       53(S) Load 61
@@ -216,24 +219,24 @@ void main()
                                 Branch 100
              102:             Label
                               Line 1 49 0
-             115:    114(ptr) AccessChain 52(outv) 32
-             116:   10(float) Load 115
-             118:    37(bool) FOrdLessThan 116 117
+             114:    113(ptr) AccessChain 52(outv) 32
+             115:   10(float) Load 114
+             117:    37(bool) FOrdLessThan 115 116
                               SelectionMerge 120 None
-                              BranchConditional 118 119 123
+                              BranchConditional 117 119 123
              119:               Label
                                 Line 1 50 0
              121:   11(fvec4)   Load 52(outv)
              122:   11(fvec4)   ExtInst 2(GLSL.std.450) 13(Sin) 121
                                 Store 52(outv) 122
-                                Store 113 122
+                                Store 118 122
                                 Branch 120
              123:               Label
                                 Line 1 51 0
              124:   11(fvec4)   Load 52(outv)
              125:   11(fvec4)   ExtInst 2(GLSL.std.450) 14(Cos) 124
                                 Store 52(outv) 125
-                                Store 113 125
+                                Store 118 125
                                 Branch 120
              120:             Label
                               Return

+ 13 - 4
3rdparty/glslang/Test/baseResults/spv.glsl.register.noautoassign.frag.out

@@ -41,19 +41,25 @@ spv.glsl.register.noautoassign.frag
                               Name 137  "FragColor"
                               Name 141  "g_tTex_unused3"
                               Decorate 17(g_tTex1) DescriptorSet 0
-                              Decorate 17(g_tTex1) Binding 11
+                              Decorate 17(g_tTex1) Binding 17
                               Decorate 21(g_sSamp1) DescriptorSet 0
                               Decorate 21(g_sSamp1) Binding 5
                               Decorate 27(g_tTex2) DescriptorSet 0
+                              Decorate 27(g_tTex2) Binding 18
                               Decorate 29(g_sSamp2) DescriptorSet 0
+                              Decorate 29(g_sSamp2) Binding 6
                               Decorate 39(g_tTex3) DescriptorSet 0
-                              Decorate 39(g_tTex3) Binding 13
+                              Decorate 39(g_tTex3) Binding 19
                               Decorate 46(g_sSamp3) DescriptorSet 0
                               Decorate 46(g_sSamp3) Binding 7
                               Decorate 64(g_tTex4) DescriptorSet 0
+                              Decorate 64(g_tTex4) Binding 20
                               Decorate 69(g_sSamp4) DescriptorSet 0
+                              Decorate 69(g_sSamp4) Binding 8
                               Decorate 84(g_tTex5) DescriptorSet 0
+                              Decorate 84(g_tTex5) Binding 21
                               Decorate 86(g_sSamp5) DescriptorSet 0
+                              Decorate 86(g_sSamp5) Binding 9
                               MemberDecorate 93(MyStruct_t) 0 Offset 0
                               MemberDecorate 93(MyStruct_t) 1 Offset 4
                               MemberDecorate 93(MyStruct_t) 2 Offset 16
@@ -65,13 +71,16 @@ spv.glsl.register.noautoassign.frag
                               Decorate 97 DescriptorSet 0
                               Decorate 97 Binding 19
                               Decorate 119(g_tTex_unused1) DescriptorSet 0
-                              Decorate 119(g_tTex_unused1) Binding 10
+                              Decorate 119(g_tTex_unused1) Binding 22
                               Decorate 121(g_sSamp_unused1) DescriptorSet 0
+                              Decorate 121(g_sSamp_unused1) Binding 10
                               Decorate 126(g_tTex_unused2) DescriptorSet 0
-                              Decorate 126(g_tTex_unused2) Binding 12
+                              Decorate 126(g_tTex_unused2) Binding 23
                               Decorate 128(g_sSamp_unused2) DescriptorSet 0
+                              Decorate 128(g_sSamp_unused2) Binding 11
                               Decorate 137(FragColor) Location 0
                               Decorate 141(g_tTex_unused3) DescriptorSet 0
+                              Decorate 141(g_tTex_unused3) Binding 24
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32

+ 8 - 8
3rdparty/glslang/Test/baseResults/spv.sparseTexture.frag.out

@@ -182,14 +182,14 @@ spv.sparseTexture.frag
       414(i2DMS):    413(ptr) Variable UniformConstant
              422:             TypePointer Output 11(fvec4)
    423(outColor):    422(ptr) Variable Output
-             426:             TypeBool
+             425:             TypeBool
          4(main):           2 Function None 3
                5:             Label
      8(resident):      7(ptr) Variable Function
        13(texel):     12(ptr) Variable Function
       18(itexel):     17(ptr) Variable Function
       23(utexel):     22(ptr) Variable Function
-             424:     12(ptr) Variable Function
+             427:     12(ptr) Variable Function
                               Store 8(resident) 9
                               Store 13(texel) 15
                               Store 18(itexel) 19
@@ -565,13 +565,13 @@ spv.sparseTexture.frag
              420:      6(int) Load 8(resident)
              421:      6(int) BitwiseOr 420 419
                               Store 8(resident) 421
-             425:      6(int) Load 8(resident)
-             427:   426(bool) ImageSparseTexelsResident 425
+             424:      6(int) Load 8(resident)
+             426:   425(bool) ImageSparseTexelsResident 424
                               SelectionMerge 429 None
-                              BranchConditional 427 428 431
+                              BranchConditional 426 428 431
              428:               Label
              430:   11(fvec4)   Load 13(texel)
-                                Store 424 430
+                                Store 427 430
                                 Branch 429
              431:               Label
              432:   16(ivec4)   Load 18(itexel)
@@ -579,10 +579,10 @@ spv.sparseTexture.frag
              434:   21(ivec4)   Load 23(utexel)
              435:   11(fvec4)   ConvertUToF 434
              436:   11(fvec4)   FAdd 433 435
-                                Store 424 436
+                                Store 427 436
                                 Branch 429
              429:             Label
-             437:   11(fvec4) Load 424
+             437:   11(fvec4) Load 427
                               Store 423(outColor) 437
                               Return
                               FunctionEnd

+ 8 - 8
3rdparty/glslang/Test/baseResults/spv.sparseTextureClamp.frag.out

@@ -145,14 +145,14 @@ spv.sparseTextureClamp.frag
              310:  157(ivec2) ConstantComposite 143 143
              344:             TypePointer Output 11(fvec4)
    345(outColor):    344(ptr) Variable Output
-             348:             TypeBool
+             347:             TypeBool
          4(main):           2 Function None 3
                5:             Label
      8(resident):      7(ptr) Variable Function
        13(texel):     12(ptr) Variable Function
       18(itexel):     17(ptr) Variable Function
       23(utexel):     22(ptr) Variable Function
-             346:     12(ptr) Variable Function
+             349:     12(ptr) Variable Function
                               Store 8(resident) 9
                               Store 13(texel) 15
                               Store 18(itexel) 19
@@ -442,13 +442,13 @@ spv.sparseTextureClamp.frag
              342:   16(ivec4) Load 18(itexel)
              343:   16(ivec4) IAdd 342 341
                               Store 18(itexel) 343
-             347:      6(int) Load 8(resident)
-             349:   348(bool) ImageSparseTexelsResident 347
+             346:      6(int) Load 8(resident)
+             348:   347(bool) ImageSparseTexelsResident 346
                               SelectionMerge 351 None
-                              BranchConditional 349 350 353
+                              BranchConditional 348 350 353
              350:               Label
              352:   11(fvec4)   Load 13(texel)
-                                Store 346 352
+                                Store 349 352
                                 Branch 351
              353:               Label
              354:   16(ivec4)   Load 18(itexel)
@@ -456,10 +456,10 @@ spv.sparseTextureClamp.frag
              356:   21(ivec4)   Load 23(utexel)
              357:   11(fvec4)   ConvertUToF 356
              358:   11(fvec4)   FAdd 355 357
-                                Store 346 358
+                                Store 349 358
                                 Branch 351
              351:             Label
-             359:   11(fvec4) Load 346
+             359:   11(fvec4) Load 349
                               Store 345(outColor) 359
                               Return
                               FunctionEnd

+ 33 - 33
3rdparty/glslang/Test/baseResults/spv.types.frag.out

@@ -141,7 +141,7 @@ spv.types.frag
          139(f2):    138(ptr) Variable Function
          148(f3):    147(ptr) Variable Function
          157(f4):    156(ptr) Variable Function
-             166:    156(ptr) Variable Function
+             194:    156(ptr) Variable Function
               11:     6(bool) Load 10(u_b)
               13:     6(bool) Load 12(i_b)
               14:     6(bool) LogicalAnd 11 13
@@ -235,36 +235,36 @@ spv.types.frag
              162:  155(fvec4) Load 161(i_f4)
              163:  155(fvec4) FAdd 160 162
                               Store 157(f4) 163
-             167:     6(bool) Load 8(b)
-             168:      7(ptr) AccessChain 17(b2) 21
-             169:     6(bool) Load 168
-             170:     6(bool) LogicalOr 167 169
-             171:      7(ptr) AccessChain 17(b2) 28
-             172:     6(bool) Load 171
-             173:     6(bool) LogicalOr 170 172
-             174:      7(ptr) AccessChain 38(b3) 21
-             175:     6(bool) Load 174
-             176:     6(bool) LogicalOr 173 175
-             177:      7(ptr) AccessChain 38(b3) 28
-             178:     6(bool) Load 177
-             179:     6(bool) LogicalOr 176 178
-             180:      7(ptr) AccessChain 38(b3) 53
-             181:     6(bool) Load 180
-             182:     6(bool) LogicalOr 179 181
-             183:      7(ptr) AccessChain 63(b4) 21
-             184:     6(bool) Load 183
-             185:     6(bool) LogicalOr 182 184
-             186:      7(ptr) AccessChain 63(b4) 28
-             187:     6(bool) Load 186
-             188:     6(bool) LogicalOr 185 187
-             189:      7(ptr) AccessChain 63(b4) 53
-             190:     6(bool) Load 189
-             191:     6(bool) LogicalOr 188 190
-             192:      7(ptr) AccessChain 63(b4) 84
-             193:     6(bool) Load 192
-             194:     6(bool) LogicalOr 191 193
+             166:     6(bool) Load 8(b)
+             167:      7(ptr) AccessChain 17(b2) 21
+             168:     6(bool) Load 167
+             169:     6(bool) LogicalOr 166 168
+             170:      7(ptr) AccessChain 17(b2) 28
+             171:     6(bool) Load 170
+             172:     6(bool) LogicalOr 169 171
+             173:      7(ptr) AccessChain 38(b3) 21
+             174:     6(bool) Load 173
+             175:     6(bool) LogicalOr 172 174
+             176:      7(ptr) AccessChain 38(b3) 28
+             177:     6(bool) Load 176
+             178:     6(bool) LogicalOr 175 177
+             179:      7(ptr) AccessChain 38(b3) 53
+             180:     6(bool) Load 179
+             181:     6(bool) LogicalOr 178 180
+             182:      7(ptr) AccessChain 63(b4) 21
+             183:     6(bool) Load 182
+             184:     6(bool) LogicalOr 181 183
+             185:      7(ptr) AccessChain 63(b4) 28
+             186:     6(bool) Load 185
+             187:     6(bool) LogicalOr 184 186
+             188:      7(ptr) AccessChain 63(b4) 53
+             189:     6(bool) Load 188
+             190:     6(bool) LogicalOr 187 189
+             191:      7(ptr) AccessChain 63(b4) 84
+             192:     6(bool) Load 191
+             193:     6(bool) LogicalOr 190 192
                               SelectionMerge 196 None
-                              BranchConditional 194 195 256
+                              BranchConditional 193 195 256
              195:               Label
              197:     92(int)   Load 94(i)
              198:     93(ptr)   AccessChain 103(i2) 21
@@ -325,13 +325,13 @@ spv.types.frag
              253:  128(float)   Load 252
              254:  128(float)   FAdd 251 253
              255:  155(fvec4)   CompositeConstruct 254 254 254 254
-                                Store 166 255
+                                Store 194 255
                                 Branch 196
              256:               Label
-                                Store 166 258
+                                Store 194 258
                                 Branch 196
              196:             Label
-             259:  155(fvec4) Load 166
+             259:  155(fvec4) Load 194
                               Store 165(gl_FragColor) 259
                               Return
                               FunctionEnd

+ 14 - 1
3rdparty/glslang/Test/baseResults/vulkan.frag.out

@@ -1,4 +1,11 @@
 vulkan.frag
+ERROR: 0:3: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:4: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:5: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:6: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:8: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:9: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:10: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:14: 'sampler2D' : sampler-constructor requires two arguments 
 ERROR: 0:15: 'sampler2D' : sampler-constructor first argument must be a scalar textureXXX type 
 ERROR: 0:16: 'sampler2D' : sampler-constructor first argument must be a scalar textureXXX type 
@@ -14,13 +21,19 @@ ERROR: 0:28: 'sampler2D' : sampler/image types can only be used in uniform varia
 ERROR: 0:29: 'sampler3D' : sampler-constructor cannot make an array of samplers 
 ERROR: 0:29: 'sampler3D' : sampler/image types can only be used in uniform variables or function parameters: s3d
 ERROR: 0:29: '=' :  cannot convert from ' const float' to ' global 4-element array of highp sampler3D'
+ERROR: 0:31: 'location' : SPIR-V requires location for user input/output 
 ERROR: 0:39: 'push_constant' : can only be used with a uniform 
 ERROR: 0:43: 'non-opaque uniforms outside a block' : not allowed when using GLSL for Vulkan 
 ERROR: 0:43: 'push_constant' : can only be used with a block 
 ERROR: 0:45: 'push_constant' : cannot declare a default, can only be used on a block 
+ERROR: 0:51: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:52: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:52: 'input_attachment_index' : can only be used with a subpass 
+ERROR: 0:53: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:53: 'input_attachment_index' : can only be used with a subpass 
+ERROR: 0:54: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:54: 'subpass' : requires an input_attachment_index layout qualifier 
+ERROR: 0:55: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:60: 'subpassLoadMS' : no matching overloaded function found 
 ERROR: 0:61: 'subpassLoad' : no matching overloaded function found 
 ERROR: 0:63: 'subpassLoadMS' : no matching overloaded function found 
@@ -43,7 +56,7 @@ ERROR: 0:101: 'noise1' : no matching overloaded function found
 ERROR: 0:102: 'noise2' : no matching overloaded function found 
 ERROR: 0:103: 'noise3' : no matching overloaded function found 
 ERROR: 0:104: 'noise4' : no matching overloaded function found 
-ERROR: 42 compilation errors.  No code generated.
+ERROR: 55 compilation errors.  No code generated.
 
 
 ERROR: Linking fragment stage: Only one push_constant block is allowed per stage

+ 11 - 1
3rdparty/glslang/Test/baseResults/vulkan.vert.out

@@ -1,12 +1,20 @@
 vulkan.vert
 ERROR: 0:3: 'subpass input' : not supported in this stage: vertex
+ERROR: 0:3: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:4: 'subpass input' : not supported in this stage: vertex
+ERROR: 0:4: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:5: 'subpass input' : not supported in this stage: vertex
+ERROR: 0:5: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:6: 'subpass input' : not supported in this stage: vertex
+ERROR: 0:6: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:7: 'subpass input' : not supported in this stage: vertex
+ERROR: 0:7: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:8: 'subpass input' : not supported in this stage: vertex
+ERROR: 0:8: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:10: 'location' : SPIR-V requires location for user input/output 
 ERROR: 0:12: 'constant_id' : can only be applied to a scalar 
 ERROR: 0:13: 'constant_id' : specialization-constant id already used 
+ERROR: 0:13: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:13: 'constant_id' : can only be applied to 'const'-qualified scalar 
 ERROR: 0:13: 'constant_id' : cannot be applied to this type 
 ERROR: 0:14: 'constant_id' : specialization-constant id is too large 
@@ -26,7 +34,9 @@ ERROR: 0:49: '[]' : only outermost dimension of an array of arrays can be a spec
 ERROR: 0:50: '[]' : only outermost dimension of an array of arrays can be a specialization constant 
 ERROR: 0:51: '[]' : only outermost dimension of an array of arrays can be a specialization constant 
 ERROR: 0:54: '[]' : only outermost dimension of an array of arrays can be a specialization constant 
-ERROR: 27 compilation errors.  No code generated.
+ERROR: 0:54: 'location' : SPIR-V requires location for user input/output 
+ERROR: 0:58: 'location' : SPIR-V requires location for user input/output 
+ERROR: 37 compilation errors.  No code generated.
 
 
 SPIR-V is not generated for failed compile or link

+ 4 - 3
3rdparty/glslang/Test/glspv.frag

@@ -11,10 +11,10 @@ void main()
 {
 }
 
-uniform float f; // ERROR, no location
+uniform float f;                           // ERROR, no location
 layout(location = 2) uniform float g;
-uniform sampler2D s1;
-layout(location = 3) uniform sampler2D s2;
+uniform sampler2D s1;                      // ERROR, no binding
+layout(location = 3) uniform sampler2D s2; // ERROR, no binding
 
 void noise()
 {
@@ -24,4 +24,5 @@ void noise()
     noise4(1);
 }
 
+uniform atomic_uint atomic;                // ERROR, no binding
 layout(input_attachment_index = 1) uniform subpassInput sub; // ERROR, no inputs

+ 2 - 2
3rdparty/glslang/Test/glspv.vert

@@ -5,8 +5,8 @@ layout(push_constant) uniform Material { int a; } mat;            // ERROR, can'
 layout(set = 0, binding = 0, std140) uniform Bt1 { int a; } bt1;
 layout(set = 1, binding = 0, std140) uniform Bt2 { int a; } bt2;  // ERROR, set has to be 0
 
-layout(shared) uniform Bt3 { int a; } bt3;                        // ERROR, no shared
-layout(packed) uniform Bt4 { int a; } bt4;                        // ERROR, no shared
+layout(shared) uniform Bt3 { int a; } bt3;                        // ERROR, no shared, no binding
+layout(packed) uniform Bt4 { int a; } bt4;                        // ERROR, no shared, no binding
 
 void main()
 {

+ 1 - 1
3rdparty/glslang/Test/link2.vk.frag

@@ -1,6 +1,6 @@
 #version 450
 
-uniform sampler2D s2D;
+layout(binding=1) uniform sampler2D s2D;
 
 vec4 getColor()
 {

+ 1 - 1
3rdparty/glslang/Test/runtests

@@ -126,7 +126,7 @@ diff -b $BASEDIR/spv.looseUniformNoLoc.vert.out $TARGETDIR/spv.looseUniformNoLoc
 # Testing debug information
 #
 echo Testing SPV Debug Information
-$EXE -g --relaxed-errors --suppress-warnings --aml --hlsl-offsets --nsf \
+$EXE -g --relaxed-errors --suppress-warnings --aml --amb --hlsl-offsets --nsf \
      -G -H spv.debugInfo.frag --rsb frag 3 > $TARGETDIR/spv.debugInfo.frag.out
 diff -b $BASEDIR/spv.debugInfo.frag.out $TARGETDIR/spv.debugInfo.frag.out || HASERROR=1
 $EXE -g -D -Od -e newMain -g --amb --aml --fua --hlsl-iomap --nsf --sib 1 --ssb 2 --sbb 3 --stb 4 --suavb 5 --sub 6 \

+ 13 - 13
3rdparty/glslang/Test/spv.glsl.register.noautoassign.frag

@@ -1,23 +1,23 @@
 #version 450
 
 uniform layout(binding=0) sampler       g_sSamp1;
-uniform sampler       g_sSamp2;
+uniform layout(binding=1) sampler       g_sSamp2;
 uniform layout(binding=2) sampler       g_sSamp3[2];
-uniform sampler       g_sSamp4[3];
-uniform sampler       g_sSamp5;
+uniform layout(binding=3) sampler       g_sSamp4[3];
+uniform layout(binding=4) sampler       g_sSamp5;
 
-uniform sampler       g_sSamp_unused1;
-uniform sampler       g_sSamp_unused2;
+uniform layout(binding=5) sampler       g_sSamp_unused1;
+uniform layout(binding=6) sampler       g_sSamp_unused2;
 
-uniform layout(binding=1) texture1D          g_tTex1;
-uniform texture1D  g_tTex2;
-uniform layout(binding=3) texture1D          g_tTex3[2];
-uniform texture1D          g_tTex4[3];
-uniform texture1D          g_tTex5;
+uniform layout(binding=7) texture1D          g_tTex1;
+uniform layout(binding=8) texture1D          g_tTex2;
+uniform layout(binding=9) texture1D          g_tTex3[2];
+uniform layout(binding=10) texture1D          g_tTex4[3];
+uniform layout(binding=11) texture1D          g_tTex5;
 
-uniform layout(binding=0)  texture1D          g_tTex_unused1;
-uniform layout(binding=2)  texture1D          g_tTex_unused2;
-uniform texture1D          g_tTex_unused3;
+uniform layout(binding=12) texture1D          g_tTex_unused1;
+uniform layout(binding=13) texture1D          g_tTex_unused2;
+uniform layout(binding=14) texture1D          g_tTex_unused3;
 
 struct MyStruct_t {
     int a;

+ 2 - 2
3rdparty/glslang/Test/spv.targetOpenGL.vert

@@ -2,8 +2,8 @@
 
 layout(constant_id = 3) const int a = 2;
 layout(location = 2) uniform float f;
-layout(location = 4) uniform sampler2D s1;
-uniform sampler2D s2;
+layout(location = 4, binding = 1) uniform sampler2D s1;
+layout(binding = 2) uniform sampler2D s2;
 
 void main()
 {

+ 5 - 5
3rdparty/glslang/Test/vulkan.frag

@@ -1,9 +1,9 @@
 #version 450
 
-uniform sampler s;
-uniform sampler sA[4];
-uniform texture2D t2d;
-uniform texture3D t3d[4];
+uniform sampler s;         // ERROR, no binding
+uniform sampler sA[4];     // ERROR, no binding
+uniform texture2D t2d;     // ERROR, no binding
+uniform texture3D t3d[4];  // ERROR, no binding
 int i;
 uniform samplerShadow sShadow;
 uniform texture3D t3d5[5];
@@ -28,7 +28,7 @@ void badConst()
 sampler2D s2D = sampler2D(t2d, s);            // ERROR, no sampler constructor
 sampler3D s3d[4] = sampler3D[4](t3d, sA[2]);  // ERROR, no sampler constructor
 
-out vec4 color;
+out vec4 color; // ERROR, no location
 
 void main()
 {

+ 8 - 2
3rdparty/glslang/glslang/Include/intermediate.h

@@ -1336,9 +1336,11 @@ class TIntermSelection : public TIntermTyped {
 public:
     TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB) :
         TIntermTyped(EbtVoid), condition(cond), trueBlock(trueB), falseBlock(falseB),
+        shortCircuit(true),
         flatten(false), dontFlatten(false) {}
     TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB, const TType& type) :
         TIntermTyped(type), condition(cond), trueBlock(trueB), falseBlock(falseB),
+        shortCircuit(true),
         flatten(false), dontFlatten(false) {}
     virtual void traverse(TIntermTraverser*);
     virtual TIntermTyped* getCondition() const { return condition; }
@@ -1347,6 +1349,9 @@ public:
     virtual       TIntermSelection* getAsSelectionNode()       { return this; }
     virtual const TIntermSelection* getAsSelectionNode() const { return this; }
 
+    void setNoShortCircuit() { shortCircuit = false; }
+    bool getShortCircuit() const { return shortCircuit; }
+
     void setFlatten()     { flatten = true; }
     void setDontFlatten() { dontFlatten = true; }
     bool getFlatten()     const { return flatten; }
@@ -1356,8 +1361,9 @@ protected:
     TIntermTyped* condition;
     TIntermNode* trueBlock;
     TIntermNode* falseBlock;
-    bool flatten;     // true if flatten requested
-    bool dontFlatten; // true if requested to not flatten
+    bool shortCircuit; // normally all if-then-else and all GLSL ?: short-circuit, but HLSL ?: does not
+    bool flatten;      // true if flatten requested
+    bool dontFlatten;  // true if requested to not flatten
 };
 
 //

+ 8 - 1
3rdparty/glslang/glslang/MachineIndependent/Intermediate.cpp

@@ -1672,7 +1672,11 @@ TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* true
     // If it's void, go to the if-then-else selection()
     if (trueBlock->getBasicType() == EbtVoid && falseBlock->getBasicType() == EbtVoid) {
         TIntermNodePair pair = { trueBlock, falseBlock };
-        return addSelection(cond, pair, loc);
+        TIntermSelection* selection = addSelection(cond, pair, loc);
+        if (getSource() == EShSourceHlsl)
+            selection->setNoShortCircuit();
+
+        return selection;
     }
 
     //
@@ -1743,6 +1747,9 @@ TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* true
     else
         node->getQualifier().makeTemporary();
 
+    if (getSource() == EShSourceHlsl)
+        node->setNoShortCircuit();
+
     return node;
 }
 

+ 17 - 5
3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp

@@ -4663,12 +4663,23 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
                 return;
             }
         }
-    }
+    } else if (!intermediate.getAutoMapBindings()) {
+        // some types require bindings
 
-    // atomic_uint
-    if (type.getBasicType() == EbtAtomicUint) {
-        if (! type.getQualifier().hasBinding())
+        // atomic_uint
+        if (type.getBasicType() == EbtAtomicUint)
             error(loc, "layout(binding=X) is required", "atomic_uint", "");
+
+        // SPIR-V
+        if (spvVersion.spv > 0) {
+            if (qualifier.isUniformOrBuffer()) {
+                if (type.getBasicType() == EbtBlock && !qualifier.layoutPushConstant &&
+                                                       !qualifier.layoutAttachment)
+                    error(loc, "uniform/buffer blocks require layout(binding=X)", "binding", "");
+                else if (spvVersion.vulkan > 0 && type.getBasicType() == EbtSampler)
+                    error(loc, "sampler/texture/image requires layout(binding=X)", "binding", "");
+            }
+        }
     }
 
     // "The offset qualifier can only be used on block members of blocks..."
@@ -6072,7 +6083,8 @@ void TParseContext::fixBlockLocations(const TSourceLoc& loc, TQualifier& qualifi
                     memberQualifier.layoutLocation = nextLocation;
                     memberQualifier.layoutComponent = TQualifier::layoutComponentEnd;
                 }
-                nextLocation = memberQualifier.layoutLocation + intermediate.computeTypeLocationSize(*typeList[member].type);
+                nextLocation = memberQualifier.layoutLocation + intermediate.computeTypeLocationSize(
+                                    *typeList[member].type, language);
             }
         }
     }

+ 2 - 0
3rdparty/glslang/glslang/MachineIndependent/intermOut.cpp

@@ -819,6 +819,8 @@ bool TOutputTraverser::visitSelection(TVisit /* visit */, TIntermSelection* node
     out.debug << "Test condition and select";
     out.debug << " (" << node->getCompleteString() << ")";
 
+    if (node->getShortCircuit() == false)
+        out.debug << ": no shortcircuit";
     if (node->getFlatten())
         out.debug << ": Flatten";
     if (node->getDontFlatten())

+ 15 - 10
3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp

@@ -353,7 +353,9 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
 {
     TDefaultIoResolverBase(const TIntermediate &intermediate) :
         intermediate(intermediate),
-        nextUniformLocation(0)
+        nextUniformLocation(0),
+        nextInputLocation(0),
+        nextOutputLocation(0)
     { }
 
     int getBaseBinding(TResourceType res, unsigned int set) const {
@@ -446,7 +448,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
     {
         return true;
     }
-    int resolveInOutLocation(EShLanguage /*stage*/, const char* /*name*/, const TType& type, bool /*is_live*/) override
+    int resolveInOutLocation(EShLanguage stage, const char* /*name*/, const TType& type, bool /*is_live*/) override
     {
         // kick out of not doing this
         if (!doAutoLocationMapping())
@@ -464,14 +466,15 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
                 return -1;
         }
 
-        // Placeholder.
-        // TODO: It would be nice to flesh this out using 
-        // intermediate->computeTypeLocationSize(type), or functions that call it like
-        // intermediate->addUsedLocation()
-        // These in turn would want the intermediate, which is not available here, but
-        // is available in many places, and a lot of copying from it could be saved if
-        // it were just available.
-        return 0;
+        // point to the right input or output location counter
+        int& nextLocation = type.getQualifier().isPipeInput() ? nextInputLocation : nextOutputLocation;
+
+        // Placeholder. This does not do proper cross-stage lining up, nor
+        // work with mixed location/no-location declarations.
+        int location = nextLocation;
+        nextLocation += TIntermediate::computeTypeLocationSize(type, stage);
+
+        return location;
     }
     int resolveInOutComponent(EShLanguage /*stage*/, const char* /*name*/, const TType& /*type*/, bool /*is_live*/) override
     {
@@ -492,6 +495,8 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
 protected:
     const TIntermediate &intermediate;
     int nextUniformLocation;
+    int nextInputLocation;
+    int nextOutputLocation;
 
     // Return descriptor set specific base if there is one, and the generic base otherwise.
     int selectBaseBinding(int base, int descriptorSetBase) const {

+ 10 - 8
3rdparty/glslang/glslang/MachineIndependent/linkValidate.cpp

@@ -773,9 +773,9 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
         // Strip off the outer array dimension for those having an extra one.
         if (type.isArray() && qualifier.isArrayedIo(language)) {
             TType elementType(type, 0);
-            size = computeTypeLocationSize(elementType);
+            size = computeTypeLocationSize(elementType, language);
         } else
-            size = computeTypeLocationSize(type);
+            size = computeTypeLocationSize(type, language);
     }
 
     // Locations, and components within locations.
@@ -907,7 +907,7 @@ bool TIntermediate::addUsedConstantId(int id)
 
 // Recursively figure out how many locations are used up by an input or output type.
 // Return the size of type, as measured by "locations".
-int TIntermediate::computeTypeLocationSize(const TType& type) const
+int TIntermediate::computeTypeLocationSize(const TType& type, EShLanguage stage)
 {
     // "If the declared input is an array of size n and each element takes m locations, it will be assigned m * n
     // consecutive locations..."
@@ -916,9 +916,9 @@ int TIntermediate::computeTypeLocationSize(const TType& type) const
         TType elementType(type, 0);
         if (type.isImplicitlySizedArray()) {
             // TODO: are there valid cases of having an implicitly-sized array with a location?  If so, running this code too early.
-            return computeTypeLocationSize(elementType);
+            return computeTypeLocationSize(elementType, stage);
         } else
-            return type.getOuterArraySize() * computeTypeLocationSize(elementType);
+            return type.getOuterArraySize() * computeTypeLocationSize(elementType, stage);
     }
 
     // "The locations consumed by block and structure members are determined by applying the rules above
@@ -927,7 +927,7 @@ int TIntermediate::computeTypeLocationSize(const TType& type) const
         int size = 0;
         for (int member = 0; member < (int)type.getStruct()->size(); ++member) {
             TType memberType(type, member);
-            size += computeTypeLocationSize(memberType);
+            size += computeTypeLocationSize(memberType, stage);
         }
         return size;
     }
@@ -941,7 +941,7 @@ int TIntermediate::computeTypeLocationSize(const TType& type) const
     if (type.isScalar())
         return 1;
     if (type.isVector()) {
-        if (language == EShLangVertex && type.getQualifier().isPipeInput())
+        if (stage == EShLangVertex && type.getQualifier().isPipeInput())
             return 1;
         if (type.getBasicType() == EbtDouble && type.getVectorSize() > 2)
             return 2;
@@ -954,7 +954,7 @@ int TIntermediate::computeTypeLocationSize(const TType& type) const
     // for an n-element array of m-component vectors..."
     if (type.isMatrix()) {
         TType columnType(type, 0);
-        return type.getMatrixCols() * computeTypeLocationSize(columnType);
+        return type.getMatrixCols() * computeTypeLocationSize(columnType, stage);
     }
 
     assert(0);
@@ -1197,6 +1197,8 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b
     if (type.isVector()) {
         int scalarAlign = getBaseAlignmentScalar(type, size);
         switch (type.getVectorSize()) {
+        case 1: // HLSL has this, GLSL does not
+            return scalarAlign;
         case 2:
             size *= 2;
             return 2 * scalarAlign;

+ 1 - 1
3rdparty/glslang/glslang/MachineIndependent/localintermediate.h

@@ -575,7 +575,7 @@ public:
     int checkLocationRange(int set, const TIoRange& range, const TType&, bool& typeCollision);
     int addUsedOffsets(int binding, int offset, int numOffsets);
     bool addUsedConstantId(int id);
-    int computeTypeLocationSize(const TType&) const;
+    static int computeTypeLocationSize(const TType&, EShLanguage);
 
     bool setXfbBufferStride(int buffer, unsigned stride)
     {

+ 1 - 1
3rdparty/glslang/gtests/Config.FromFile.cpp

@@ -97,7 +97,7 @@ TEST_P(ConfigTest, FromFile)
 INSTANTIATE_TEST_CASE_P(
     Glsl, ConfigTest,
     ::testing::ValuesIn(std::vector<TestCaseSpec>({
-        {"specExamples.vert", "baseResults/test.conf", "specExamples.vert.out", (EShMessages)(EShMsgAST | EShMsgCascadingErrors)},
+        {"specExamples.vert", "baseResults/test.conf", "specExamplesConf.vert.out", (EShMessages)(EShMsgAST | EShMsgCascadingErrors)},
         {"100Limits.vert", "100.conf", "100LimitsConf.vert.out", EShMsgCascadingErrors},
     })),
 );

+ 3 - 2
3rdparty/glslang/gtests/Hlsl.FromFile.cpp

@@ -67,7 +67,7 @@ TEST_P(HlslCompileTest, FromFile)
 {
     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
                             Source::HLSL, Semantics::Vulkan,
-                            Target::BothASTAndSpv, GetParam().entryPoint);
+                            Target::BothASTAndSpv, true, GetParam().entryPoint);
 }
 
 TEST_P(HlslCompileAndFlattenTest, FromFile)
@@ -83,7 +83,7 @@ TEST_P(HlslLegalizeTest, FromFile)
 {
     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
                             Source::HLSL, Semantics::Vulkan,
-                            Target::Spv, GetParam().entryPoint,
+                            Target::Spv, true, GetParam().entryPoint,
                             "/baseLegalResults/", false);
 }
 
@@ -189,6 +189,7 @@ INSTANTIATE_TEST_CASE_P(
         {"hlsl.hull.ctrlpt-2.tesc", "main"},
         {"hlsl.identifier.sample.frag", "main"},
         {"hlsl.if.frag", "PixelShaderFunction"},
+        {"hlsl.imagefetch-subvec4.comp", "main"},
         {"hlsl.implicitBool.frag", "main"},
         {"hlsl.inf.vert", "main"},
         {"hlsl.inoutquals.frag", "main"},

+ 5 - 4
3rdparty/glslang/gtests/Spv.FromFile.cpp

@@ -101,7 +101,7 @@ TEST_P(VulkanSemantics, FromFile)
 {
     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
                             Source::GLSL, Semantics::Vulkan,
-                            Target::Spv);
+                            Target::Spv, false);
 }
 
 // GLSL-level Vulkan semantics test. Expected to error out before generating
@@ -110,7 +110,7 @@ TEST_P(OpenGLSemantics, FromFile)
 {
     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
                             Source::GLSL, Semantics::OpenGL,
-                            Target::Spv);
+                            Target::Spv, false);
 }
 
 // GLSL-level Vulkan semantics test that need to see the AST for validation.
@@ -168,8 +168,8 @@ TEST_P(CompileVulkanToSpirvTestAMD, FromFile)
 TEST_P(CompileVulkanToSpirvTestNV, FromFile)
 {
     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
-        Source::GLSL, Semantics::Vulkan,
-        Target::Spv);
+                            Source::GLSL, Semantics::Vulkan,
+                            Target::Spv);
 }
 #endif
 
@@ -235,6 +235,7 @@ INSTANTIATE_TEST_CASE_P(
         "spv.branch-return.vert",
         "spv.builtInXFB.vert",
         "spv.conditionalDiscard.frag",
+        "spv.constStruct.vert",
         "spv.controlFlowAttributes.frag",
         "spv.conversion.frag",
         "spv.dataOut.frag",

+ 12 - 4
3rdparty/glslang/gtests/TestFixture.h

@@ -199,12 +199,16 @@ public:
             const std::string& entryPointName, EShMessages controls,
             bool flattenUniformArrays = false,
             EShTextureSamplerTransformMode texSampTransMode = EShTexSampTransKeep,
-            bool disableOptimizer = true)
+            bool disableOptimizer = true,
+            bool automap = true)
     {
         const EShLanguage kind = GetShaderStage(GetSuffix(shaderName));
 
         glslang::TShader shader(kind);
-        shader.setAutoMapLocations(true);
+        if (automap) {
+            shader.setAutoMapLocations(true);
+            shader.setAutoMapBindings(true);
+        }
         shader.setTextureSamplerTransformMode(texSampTransMode);
         shader.setFlattenUniformArrays(flattenUniformArrays);
 
@@ -302,6 +306,7 @@ public:
         const EShLanguage kind = GetShaderStage(GetSuffix(shaderName));
 
         glslang::TShader shader(kind);
+        shader.setAutoMapBindings(true);
         shader.setAutoMapLocations(true);
 
         bool success = compile(&shader, code, entryPointName, controls);
@@ -384,6 +389,7 @@ public:
                                  Source source,
                                  Semantics semantics,
                                  Target target,
+                                 bool automap = true,
                                  const std::string& entryPointName="",
                                  const std::string& baseDir="/baseResults/",
                                  const bool disableOptimizer = true)
@@ -397,7 +403,8 @@ public:
         tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
 
         const EShMessages controls = DeriveOptions(source, semantics, target);
-        GlslangResult result = compileAndLink(testName, input, entryPointName, controls, false, EShTexSampTransKeep, disableOptimizer);
+        GlslangResult result = compileAndLink(testName, input, entryPointName, controls, false, EShTexSampTransKeep,
+                                              disableOptimizer, automap);
 
         // Generate the hybrid output in the way of glslangValidator.
         std::ostringstream stream;
@@ -592,7 +599,8 @@ public:
         tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
 
         const EShMessages controls = DeriveOptions(source, semantics, target);
-        GlslangResult result = compileAndLink(testName, input, entryPointName, controls, false, EShTexSampTransUpgradeTextureRemoveSampler);
+        GlslangResult result = compileAndLink(testName, input, entryPointName, controls, false,
+                                              EShTexSampTransUpgradeTextureRemoveSampler);
 
         // Generate the hybrid output in the way of glslangValidator.
         std::ostringstream stream;

+ 7 - 5
3rdparty/glslang/hlsl/hlslParseHelper.cpp

@@ -829,7 +829,9 @@ TIntermTyped* HlslParseContext::handleBracketDereference(const TSourceLoc& loc,
     } else {
         // at least one of base and index is variable...
 
-        if (base->getAsSymbolNode() && wasFlattened(base)) {
+        if (base->getType().isScalarOrVec1())
+            result = base;
+        else if (base->getAsSymbolNode() && wasFlattened(base)) {
             if (index->getQualifier().storage != EvqConst)
                 error(loc, "Invalid variable index to flattened array", base->getAsSymbolNode()->getName().c_str(), "");
 
@@ -1254,7 +1256,7 @@ int HlslParseContext::addFlattenedMember(const TVariable& variable, const TType&
             // inherited locations must be auto bumped, not replicated
             if (flattenData.nextLocation != TQualifier::layoutLocationEnd) {
                 memberVariable->getWritableType().getQualifier().layoutLocation = flattenData.nextLocation;
-                flattenData.nextLocation += intermediate.computeTypeLocationSize(memberVariable->getType());
+                flattenData.nextLocation += intermediate.computeTypeLocationSize(memberVariable->getType(), language);
                 nextOutLocation = std::max(nextOutLocation, flattenData.nextLocation);
             }
         }
@@ -1534,9 +1536,9 @@ void HlslParseContext::assignToInterface(TVariable& variable)
                     int size;
                     if (type.isArray() && qualifier.isArrayedIo(language)) {
                         TType elementType(type, 0);
-                        size = intermediate.computeTypeLocationSize(elementType);
+                        size = intermediate.computeTypeLocationSize(elementType, language);
                     } else
-                        size = intermediate.computeTypeLocationSize(type);
+                        size = intermediate.computeTypeLocationSize(type, language);
 
                     if (qualifier.storage == EvqVaryingIn) {
                         variable.getWritableType().getQualifier().layoutLocation = nextInLocation;
@@ -8631,7 +8633,7 @@ void HlslParseContext::fixBlockLocations(const TSourceLoc& loc, TQualifier& qual
                     memberQualifier.layoutComponent = 0;
                 }
                 nextLocation = memberQualifier.layoutLocation +
-                               intermediate.computeTypeLocationSize(*typeList[member].type);
+                               intermediate.computeTypeLocationSize(*typeList[member].type, language);
             }
         }
     }