GL_ARB_shader_draw_parameters:  From @amdrexu, implement extension.
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index be8d659..508ebed 100755
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -321,6 +321,12 @@
     case glslang::EbvCullDistance:         return spv::BuiltInCullDistance;
     case glslang::EbvVertexId:             return spv::BuiltInVertexId;
     case glslang::EbvInstanceId:           return spv::BuiltInInstanceId;
+    case glslang::EbvBaseVertex:
+    case glslang::EbvBaseInstance:
+    case glslang::EbvDrawId:
+        // TODO: Add SPIR-V builtin ID.
+        spv::MissingFunctionality("Draw parameters");
+        return (spv::BuiltIn)spv::BadValue;
     case glslang::EbvPrimitiveId:          return spv::BuiltInPrimitiveId;
     case glslang::EbvInvocationId:         return spv::BuiltInInvocationId;
     case glslang::EbvLayer:                return spv::BuiltInLayer;
diff --git a/Test/440.vert b/Test/440.vert
index 0427669..ac946be 100644
--- a/Test/440.vert
+++ b/Test/440.vert
@@ -159,3 +159,19 @@
     dmat4x4 m2;

     float f;

 } bbinst10;

+

+int drawParamsBad()

+{

+    return gl_BaseVertexARB + gl_BaseInstanceARB + gl_DrawIDARB; // ERROR, extension not requested

+}

+

+#extension GL_ARB_shader_draw_parameters: enable

+

+int drawParams()

+{

+    return gl_BaseVertexARB + gl_BaseInstanceARB + gl_DrawIDARB;

+    gl_BaseVertexARB = 3;       // ERROR, can't write to shader 'in'

+    gl_BaseInstanceARB = 3;     // ERROR, can't write to shader 'in'

+    gl_DrawIDARB = 3;           // ERROR, can't write to shader 'in'

+    glBaseInstanceARB;          // ERROR, not defined

+}

diff --git a/Test/baseResults/440.vert.out b/Test/baseResults/440.vert.out
index 0dfecad..48dc67e 100644
--- a/Test/baseResults/440.vert.out
+++ b/Test/baseResults/440.vert.out
@@ -42,12 +42,51 @@
 ERROR: 0:155: 'xfb_buffer' : buffer is too large: gl_MaxTransformFeedbackBuffers is 4

 ERROR: 0:155: 'xfb_stride' : 1/4 stride is too large: gl_MaxTransformFeedbackInterleavedComponents is 64

 ERROR: 0:157: 'xfb_buffer' : buffer is too large: gl_MaxTransformFeedbackBuffers is 4

-ERROR: 42 compilation errors.  No code generated.

+ERROR: 0:165: 'gl_BaseVertexARB' : required extension not requested: GL_ARB_shader_draw_parameters

+ERROR: 0:165: 'gl_BaseInstanceARB' : required extension not requested: GL_ARB_shader_draw_parameters

+ERROR: 0:165: 'gl_DrawIDARB' : required extension not requested: GL_ARB_shader_draw_parameters

+ERROR: 0:173: 'assign' :  l-value required "gl_BaseVertexARB" (can't modify shader input)

+ERROR: 0:174: 'assign' :  l-value required "gl_BaseInstanceARB" (can't modify shader input)

+ERROR: 0:175: 'assign' :  l-value required "gl_DrawIDARB" (can't modify shader input)

+ERROR: 0:176: 'glBaseInstanceARB' : undeclared identifier 

+ERROR: 49 compilation errors.  No code generated.

 

 

 Shader version: 440

+Requested GL_ARB_shader_draw_parameters

 in xfb mode

 ERROR: node is still EOpNull!

+0:163  Function Definition: drawParamsBad( (global int)

+0:163    Function Parameters: 

+0:165    Sequence

+0:165      Branch: Return with expression

+0:165        add (temp int)

+0:165          add (temp int)

+0:165            'gl_BaseVertexARB' (in int BaseVertex)

+0:165            'gl_BaseInstanceARB' (in int BaseInstance)

+0:165          'gl_DrawIDARB' (in int DrawId)

+0:170  Function Definition: drawParams( (global int)

+0:170    Function Parameters: 

+0:172    Sequence

+0:172      Branch: Return with expression

+0:172        add (temp int)

+0:172          add (temp int)

+0:172            'gl_BaseVertexARB' (in int BaseVertex)

+0:172            'gl_BaseInstanceARB' (in int BaseInstance)

+0:172          'gl_DrawIDARB' (in int DrawId)

+0:173      move second child to first child (temp int)

+0:173        'gl_BaseVertexARB' (in int BaseVertex)

+0:173        Constant:

+0:173          3 (const int)

+0:174      move second child to first child (temp int)

+0:174        'gl_BaseInstanceARB' (in int BaseInstance)

+0:174        Constant:

+0:174          3 (const int)

+0:175      move second child to first child (temp int)

+0:175        'gl_DrawIDARB' (in int DrawId)

+0:175        Constant:

+0:175          3 (const int)

+0:176      'glBaseInstanceARB' (temp float)

 0:?   Linker Objects

 0:?     'a' (layout(location=2 component=2 ) in 2-component vector of float)

 0:?     'b' (layout(location=2 component=1 ) in float)

@@ -114,8 +153,40 @@
 ERROR:     xfb_buffer 7, components (1/4 stride) needed are 66, gl_MaxTransformFeedbackInterleavedComponents is 64

 

 Shader version: 440

+Requested GL_ARB_shader_draw_parameters

 in xfb mode

 ERROR: node is still EOpNull!

+0:163  Function Definition: drawParamsBad( (global int)

+0:163    Function Parameters: 

+0:165    Sequence

+0:165      Branch: Return with expression

+0:165        add (temp int)

+0:165          add (temp int)

+0:165            'gl_BaseVertexARB' (in int BaseVertex)

+0:165            'gl_BaseInstanceARB' (in int BaseInstance)

+0:165          'gl_DrawIDARB' (in int DrawId)

+0:170  Function Definition: drawParams( (global int)

+0:170    Function Parameters: 

+0:172    Sequence

+0:172      Branch: Return with expression

+0:172        add (temp int)

+0:172          add (temp int)

+0:172            'gl_BaseVertexARB' (in int BaseVertex)

+0:172            'gl_BaseInstanceARB' (in int BaseInstance)

+0:172          'gl_DrawIDARB' (in int DrawId)

+0:173      move second child to first child (temp int)

+0:173        'gl_BaseVertexARB' (in int BaseVertex)

+0:173        Constant:

+0:173          3 (const int)

+0:174      move second child to first child (temp int)

+0:174        'gl_BaseInstanceARB' (in int BaseInstance)

+0:174        Constant:

+0:174          3 (const int)

+0:175      move second child to first child (temp int)

+0:175        'gl_DrawIDARB' (in int DrawId)

+0:175        Constant:

+0:175          3 (const int)

+0:176      'glBaseInstanceARB' (temp float)

 0:?   Linker Objects

 0:?     'a' (layout(location=2 component=2 ) in 2-component vector of float)

 0:?     'b' (layout(location=2 component=1 ) in float)

diff --git a/glslang/Include/BaseTypes.h b/glslang/Include/BaseTypes.h
index bed63b0..35d47af 100644
--- a/glslang/Include/BaseTypes.h
+++ b/glslang/Include/BaseTypes.h
@@ -57,10 +57,14 @@
 };
 
 //
-// Qualifiers and built-ins.  These are mainly used to see what can be read
-// or written, and by the machine dependent translator to know which registers
-// to allocate variables in.  Since built-ins tend to go to different registers
-// than varying or uniform, it makes sense they are peers, not sub-classes.
+// Storage qualifiers.  Should align with different kinds of storage or
+// resource or GLSL storage qualifier.  Expansion is deprecated.
+//
+// N.B.: You probably DON'T want to add anything here, but rather just add it
+// to the built-in variables.  See the comment above TBuiltInVariable.
+//
+// A new built-in variable will normally be an existing qualifier, like 'in', 'out', etc.
+// DO NOT follow the design pattern of, say EvqInstanceId, etc.
 //
 enum TStorageQualifier {
     EvqTemporary,     // For temporaries (within a function), read/write
@@ -105,7 +109,7 @@
 // between built-in variable names and an numerical value (the enum).
 //
 // For backward compatibility, there is some redundancy between the
-// TStorageQualifier and these.  Both should be maintained accurately.
+// TStorageQualifier and these.  Existing members should both be maintained accurately.
 // However, any new built-in variable (and any existing non-redundant one)
 // must follow the pattern that the specific built-in is here, and only its
 // general qualifier is in TStorageQualifier.
@@ -126,6 +130,9 @@
     EbvLocalInvocationIndex,
     EbvVertexId,
     EbvInstanceId,
+    EbvBaseVertex,
+    EbvBaseInstance,
+    EbvDrawId,
     EbvPosition,
     EbvPointSize,
     EbvClipVertex,
@@ -214,6 +221,9 @@
     case EbvLocalInvocationIndex: return "LocalInvocationIndex";
     case EbvVertexId:             return "VertexId";
     case EbvInstanceId:           return "InstanceId";
+    case EbvBaseVertex:           return "BaseVertex";
+    case EbvBaseInstance:         return "BaseInstance";
+    case EbvDrawId:               return "DrawId";
     case EbvPosition:             return "Position";
     case EbvPointSize:            return "PointSize";
     case EbvClipVertex:           return "ClipVertex";
diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h
index 4ce6131..5097b47 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.787"
-#define GLSLANG_DATE "13-Oct-2015"
+#define GLSLANG_REVISION "3.0.788"
+#define GLSLANG_DATE "14-Oct-2015"
diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp
index f72dd27..a929876 100644
--- a/glslang/MachineIndependent/Initialize.cpp
+++ b/glslang/MachineIndependent/Initialize.cpp
@@ -1483,6 +1483,13 @@
             stageBuiltins[EShLangVertex].append(
                 "int gl_InstanceID;"          // needs qualifier fixed later
                 );
+        if (version >= 440) {
+            stageBuiltins[EShLangVertex].append(
+                "in int gl_BaseVertexARB;"
+                "in int gl_BaseInstanceARB;"
+                "in int gl_DrawIDARB;"
+                );
+        }
     } else {
         // ES profile
         if (version == 100) {
@@ -2890,6 +2897,16 @@
 
     switch(language) {
     case EShLangVertex:
+        if (profile != EEsProfile && version >= 440) {
+            symbolTable.setVariableExtensions("gl_BaseVertexARB",   1, &E_GL_ARB_shader_draw_parameters);
+            symbolTable.setVariableExtensions("gl_BaseInstanceARB", 1, &E_GL_ARB_shader_draw_parameters);
+            symbolTable.setVariableExtensions("gl_DrawIDARB",       1, &E_GL_ARB_shader_draw_parameters);
+
+            BuiltInVariable("gl_BaseVertexARB",   EbvBaseVertex,   symbolTable);
+            BuiltInVariable("gl_BaseInstanceARB", EbvBaseInstance, symbolTable);
+            BuiltInVariable("gl_DrawIDARB",       EbvDrawId,       symbolTable);
+        }
+
         // Compatibility variables, vertex only
         BuiltInVariable("gl_Color",          EbvColor,          symbolTable);
         BuiltInVariable("gl_SecondaryColor", EbvSecondaryColor, symbolTable);
diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp
index 28f8106..8953498 100644
--- a/glslang/MachineIndependent/Versions.cpp
+++ b/glslang/MachineIndependent/Versions.cpp
@@ -169,6 +169,7 @@
     extensionBehavior[E_GL_ARB_explicit_attrib_location]     = EBhDisable;
     extensionBehavior[E_GL_ARB_shader_image_load_store]      = EBhDisable;
     extensionBehavior[E_GL_ARB_shader_atomic_counters]       = EBhDisable;
+    extensionBehavior[E_GL_ARB_shader_draw_parameters]       = EBhDisable;
     extensionBehavior[E_GL_ARB_derivative_control]           = EBhDisable;
     extensionBehavior[E_GL_ARB_shader_texture_image_samples] = EBhDisable;
     extensionBehavior[E_GL_ARB_viewport_array]               = EBhDisable;
@@ -269,6 +270,7 @@
             "#define GL_ARB_explicit_attrib_location 1\n"
             "#define GL_ARB_shader_image_load_store 1\n"
             "#define GL_ARB_shader_atomic_counters 1\n"
+            "#define GL_ARB_shader_draw_parameters 1\n"
             "#define GL_ARB_derivative_control 1\n"
             "#define GL_ARB_shader_texture_image_samples 1\n"
             "#define GL_ARB_viewport_array 1\n"
diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h
index bb3cbc4..a30ea7a 100644
--- a/glslang/MachineIndependent/Versions.h
+++ b/glslang/MachineIndependent/Versions.h
@@ -107,6 +107,7 @@
 const char* const E_GL_ARB_explicit_attrib_location     = "GL_ARB_explicit_attrib_location";
 const char* const E_GL_ARB_shader_image_load_store      = "GL_ARB_shader_image_load_store";
 const char* const E_GL_ARB_shader_atomic_counters       = "GL_ARB_shader_atomic_counters";
+const char* const E_GL_ARB_shader_draw_parameters       = "GL_ARB_shader_draw_parameters";
 const char* const E_GL_ARB_derivative_control           = "GL_ARB_derivative_control";
 const char* const E_GL_ARB_shader_texture_image_samples = "GL_ARB_shader_texture_image_samples";
 const char* const E_GL_ARB_viewport_array               = "GL_ARB_viewport_array";