SPV: Add modes for spacing, depth, depth replacing, winding, and point mode.
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index 90cb2c0..be8d659 100755
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -445,15 +445,30 @@
         case glslang::ElgTriangles:           mode = spv::ExecutionModeInputTriangles;     break;
         case glslang::ElgQuads:               mode = spv::ExecutionModeInputQuads;         break;
         case glslang::ElgIsolines:            mode = spv::ExecutionModeInputIsolines;      break;
-        default:                              mode = spv::BadValue;    break;
+        default:                              mode = spv::BadValue;                        break;
         }
         if (mode != spv::BadValue)
             builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode);
 
-        // TODO
-        //builder.addExecutionMode(spv::VertexSpacingMdName, glslangIntermediate->getVertexSpacing());
-        //builder.addExecutionMode(spv::VertexOrderMdName, glslangIntermediate->getVertexOrder());
-        //builder.addExecutionMode(spv::PointModeMdName, glslangIntermediate->getPointMode());
+        switch (glslangIntermediate->getVertexSpacing()) {
+        case glslang::EvsEqual:            mode = spv::ExecutionModeSpacingEqual;          break;
+        case glslang::EvsFractionalEven:   mode = spv::ExecutionModeSpacingFractionalEven; break;
+        case glslang::EvsFractionalOdd:    mode = spv::ExecutionModeSpacingFractionalOdd;  break;
+        default:                           mode = spv::BadValue;                           break;
+        }
+        if (mode != spv::BadValue)
+            builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode);
+
+        switch (glslangIntermediate->getVertexOrder()) {
+        case glslang::EvoCw:     mode = spv::ExecutionModeVertexOrderCw;  break;
+        case glslang::EvoCcw:    mode = spv::ExecutionModeVertexOrderCcw; break;
+        default:                 mode = spv::BadValue;                    break;
+        }
+        if (mode != spv::BadValue)
+            builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode);
+
+        if (glslangIntermediate->getPointMode())
+            builder.addExecutionMode(shaderEntry, spv::ExecutionModePointMode);
         break;
 
     case EShLangGeometry:
@@ -468,6 +483,7 @@
         }
         if (mode != spv::BadValue)
             builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode);
+
         builder.addExecutionMode(shaderEntry, spv::ExecutionModeInvocations, glslangIntermediate->getInvocations());
 
         switch (glslangIntermediate->getOutputPrimitive()) {
@@ -485,10 +501,26 @@
         builder.addCapability(spv::CapabilityShader);
         if (glslangIntermediate->getPixelCenterInteger())
             builder.addExecutionMode(shaderEntry, spv::ExecutionModePixelCenterInteger);
+
         if (glslangIntermediate->getOriginUpperLeft())
             builder.addExecutionMode(shaderEntry, spv::ExecutionModeOriginUpperLeft);
         else
             builder.addExecutionMode(shaderEntry, spv::ExecutionModeOriginLowerLeft);
+
+        if (glslangIntermediate->getEarlyFragmentTests())
+            builder.addExecutionMode(shaderEntry, spv::ExecutionModeEarlyFragmentTests);
+
+        switch(glslangIntermediate->getDepth()) {
+        case glslang::EldAny:      mode = spv::ExecutionModeDepthAny;     break;
+        case glslang::EldGreater:  mode = spv::ExecutionModeDepthGreater; break;
+        case glslang::EldLess:     mode = spv::ExecutionModeDepthLess;    break;
+        default:                   mode = spv::BadValue;                  break;
+        }
+        if (mode != spv::BadValue)
+            builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode);
+
+        if (glslangIntermediate->getDepth() != glslang::EldUnchanged && glslangIntermediate->isDepthReplacing())
+            builder.addExecutionMode(shaderEntry, spv::ExecutionModeDepthReplacing);
         break;
 
     case EShLangCompute:
diff --git a/Test/baseResults/spv.400.tese.out b/Test/baseResults/spv.400.tese.out
index 9a63b16..1199acd 100755
--- a/Test/baseResults/spv.400.tese.out
+++ b/Test/baseResults/spv.400.tese.out
@@ -16,6 +16,9 @@
                               MemoryModel Logical GLSL450

                               EntryPoint TessellationEvaluation 4  "main"

                               ExecutionMode 4 InputTriangles

+                              ExecutionMode 4 SpacingFractionalOdd

+                              ExecutionMode 4 VertexOrderCcw

+                              ExecutionMode 4 PointMode

                               Name 4  "main"

                               Name 8  "a"

                               Name 13  "p"

diff --git a/Test/baseResults/spv.depthOut.frag.out b/Test/baseResults/spv.depthOut.frag.out
index 426b106..a3baf4a 100755
--- a/Test/baseResults/spv.depthOut.frag.out
+++ b/Test/baseResults/spv.depthOut.frag.out
@@ -1,6 +1,5 @@
 spv.depthOut.frag

-WARNING: 0:3: varying deprecated in version 130; may be removed in future release

-WARNING: 0:4: varying deprecated in version 130; may be removed in future release

+Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.

 

 

 Linked fragment stage:

@@ -10,12 +9,14 @@
 // Generated by (magic number): 51a00bb

 // Id's are bound by 18

 

-                              Source GLSL 130

+                              Source GLSL 450

                               Capability Shader

                1:             ExtInstImport  "GLSL.std.450"

                               MemoryModel Logical GLSL450

                               EntryPoint Fragment 4  "main"

                               ExecutionMode 4 OriginLowerLeft

+                              ExecutionMode 4 DepthAny

+                              ExecutionMode 4 DepthReplacing

                               Name 4  "main"

                               Name 8  "gl_FragDepth"

                               Name 10  "Depth"

diff --git a/Test/spv.depthOut.frag b/Test/spv.depthOut.frag
index 5a89271..9b6890e 100644
--- a/Test/spv.depthOut.frag
+++ b/Test/spv.depthOut.frag
@@ -1,7 +1,9 @@
-#version 130

+#version 450

 

-varying vec4 Color;

-varying float Depth;

+in vec4 Color;

+in float Depth;

+

+layout(depth_any) out float gl_FragDepth;

 

 void main()

 {

diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h
index 1b7bb52..a1bfe13 100644
--- a/glslang/Include/revision.h
+++ b/glslang/Include/revision.h
@@ -2,5 +2,5 @@
 // For the version, it uses the latest git tag followed by the number of commits.
 // For the date, it uses the current date (when then script is run).
 
-#define GLSLANG_REVISION "3.0.785"
+#define GLSLANG_REVISION "3.0.786"
 #define GLSLANG_DATE "13-Oct-2015"
diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp
index 0cdaf82..b5d245c 100644
--- a/glslang/MachineIndependent/ParseHelper.cpp
+++ b/glslang/MachineIndependent/ParseHelper.cpp
@@ -1921,6 +1921,7 @@
             message = "can't modify a readonly buffer";
         break;
     case EvqFragDepth:
+        intermediate.setDepthReplacing();
         // "In addition, it is an error to statically write to gl_FragDepth in the fragment shader."
         if (profile == EEsProfile && intermediate.getEarlyFragmentTests())
             message = "can't modify gl_FragDepth if using early_fragment_tests";
diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h
index dedf1e6..5212abe 100644
--- a/glslang/MachineIndependent/localintermediate.h
+++ b/glslang/MachineIndependent/localintermediate.h
@@ -127,7 +127,7 @@
     explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) : language(l), treeRoot(0), profile(p), version(v), 
         numMains(0), numErrors(0), recursive(false),
         invocations(0), vertices(0), inputPrimitive(ElgNone), outputPrimitive(ElgNone), pixelCenterInteger(false), originUpperLeft(false),
-        vertexSpacing(EvsNone), vertexOrder(EvoNone), pointMode(false), earlyFragmentTests(false), depthLayout(EldNone), blendEquations(0), xfbMode(false)
+        vertexSpacing(EvsNone), vertexOrder(EvoNone), pointMode(false), earlyFragmentTests(false), depthLayout(EldNone), depthReplacing(false), blendEquations(0), xfbMode(false)
     {
         localSize[0] = 1;
         localSize[1] = 1;
@@ -276,6 +276,8 @@
         return true;
     }
     TLayoutDepth getDepth() const { return depthLayout; }
+    void setDepthReplacing() { depthReplacing = true; }
+    bool isDepthReplacing() const { return depthReplacing; }
 
     void addBlendEquation(TBlendEquationShift b) { blendEquations |= (1 << b); }
     unsigned int getBlendEquations() const { return blendEquations; }
@@ -335,6 +337,7 @@
     int localSize[3];
     bool earlyFragmentTests;
     TLayoutDepth depthLayout;
+    bool depthReplacing;
     int blendEquations;        // an 'or'ing of masks of shifts of TBlendEquationShift
     bool xfbMode;