diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index be8d65962403ecbfe2441ee8a8e2d9bc8a8db61c..508ebed219a9dbf6d153bc3a6b113dd46f4f987c 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -321,6 +321,12 @@ spv::BuiltIn TranslateBuiltInDecoration(glslang::TBuiltInVariable builtIn) 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 04276690e0249e6eae43b22fa18c3622e66f8c40..ac946be0dee8868e7f907ef3319c57fef4955d18 100644 --- a/Test/440.vert +++ b/Test/440.vert @@ -159,3 +159,19 @@ out layout(xfb_buffer=7, xfb_offset=0) bblck10 { // link ERROR, implicit stride 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 0dfecada6f6058d260b0b231e8e0e41aed80a076..48dc67e4829e9a9bf571b94cca742b70e98014ad 100644 --- a/Test/baseResults/440.vert.out +++ b/Test/baseResults/440.vert.out @@ -42,12 +42,51 @@ ERROR: 0:152: 'xfb_buffer' : buffer is too large: gl_MaxTransformFeedbackBuffers 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: Linking vertex stage: xfb_stride is too large: 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 bed63b0071687ce033b096674848d0b972365008..35d47af23ac5056d1e3571ff883ff00915b09870 100644 --- a/glslang/Include/BaseTypes.h +++ b/glslang/Include/BaseTypes.h @@ -57,10 +57,14 @@ enum TBasicType { }; // -// 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 @@ enum TStorageQualifier { // 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 @@ enum TBuiltInVariable { EbvLocalInvocationIndex, EbvVertexId, EbvInstanceId, + EbvBaseVertex, + EbvBaseInstance, + EbvDrawId, EbvPosition, EbvPointSize, EbvClipVertex, @@ -214,6 +221,9 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v) 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 4ce613169a2c8fdc827b7ddfe0fd4dcf41f61970..5097b47486ac74400dd6c7cd5699d7ef331a43bd 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 f72dd277f6250b687504426e2fb76d5071aa32fe..a929876b54cda3858da36a576f8edc5fe27ef66a 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -1483,6 +1483,13 @@ void TBuiltIns::initialize(int version, EProfile profile) 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 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb 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 28f81061049d041d3ab26da0d4dc660d6cb4040c..89534988796b4d47dd30e6fc40818c6718746773 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -169,6 +169,7 @@ void TParseContext::initializeExtensionBehavior() 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 @@ const char* TParseContext::getPreamble() "#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 bb3cbc4dedcdfc7cd55c25aebb1f88eb9e770f56..a30ea7a63325fef9eb9c230c75fea7dbab415b7f 100644 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -107,6 +107,7 @@ const char* const E_GL_ARB_shader_texture_lod = "GL_ARB_shader_texture 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";