GL_ARB_shader_draw_parameters: From @amdrexu, implement extension.

This commit is contained in:
John Kessenich 2015-10-14 14:10:30 -06:00
parent b5c046e58b
commit da581a2b95
8 changed files with 131 additions and 8 deletions

View file

@ -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";

View file

@ -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"

View file

@ -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);

View file

@ -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"

View file

@ -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";