Simplify function calls for extensionsTurnedOn().

Lots of places in the code use extensionsTurnedOn(1, ...). This
patch introduces a new method, extensionTurnedOn(), for testing
if a single extension is turned on.
This commit is contained in:
Lei Zhang 2015-07-05 17:48:53 -04:00
Родитель 3a194f7ba4
Коммит c4d20e0041
4 изменённых файлов: 28 добавлений и 22 удалений

Просмотреть файл

@ -1841,7 +1841,7 @@ bool TParseContext::lineContinuationCheck(TSourceLoc loc, bool endOfComment)
const char* message = "line continuation"; const char* message = "line continuation";
bool lineContinuationAllowed = (profile == EEsProfile && version >= 300) || bool lineContinuationAllowed = (profile == EEsProfile && version >= 300) ||
(profile != EEsProfile && (version >= 420 || extensionsTurnedOn(1, &E_GL_ARB_shading_language_420pack))); (profile != EEsProfile && (version >= 420 || extensionTurnedOn(E_GL_ARB_shading_language_420pack)));
if (endOfComment) { if (endOfComment) {
if (lineContinuationAllowed) if (lineContinuationAllowed)
@ -2228,7 +2228,7 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
// Ordering // Ordering
if (! force && ((profile != EEsProfile && version < 420) || if (! force && ((profile != EEsProfile && version < 420) ||
(profile == EEsProfile && version < 310)) (profile == EEsProfile && version < 310))
&& ! extensionsTurnedOn(1, &E_GL_ARB_shading_language_420pack)) { && ! extensionTurnedOn(E_GL_ARB_shading_language_420pack)) {
// non-function parameters // non-function parameters
if (src.invariant && (dst.isInterpolation() || dst.isAuxiliary() || dst.storage != EvqTemporary || dst.precision != EpqNone)) if (src.invariant && (dst.isInterpolation() || dst.isAuxiliary() || dst.storage != EvqTemporary || dst.precision != EpqNone))
error(loc, "invariant qualifier must appear first", "", ""); error(loc, "invariant qualifier must appear first", "", "");
@ -2691,7 +2691,7 @@ TSymbol* TParseContext::redeclareBuiltinVariable(TSourceLoc loc, const TString&
// Special case when using GL_ARB_separate_shader_objects // Special case when using GL_ARB_separate_shader_objects
bool ssoPre150 = false; // means the only reason this variable is redeclared is due to this combination bool ssoPre150 = false; // means the only reason this variable is redeclared is due to this combination
if (profile != EEsProfile && version <= 140 && extensionsTurnedOn(1, &E_GL_ARB_separate_shader_objects)) { if (profile != EEsProfile && version <= 140 && extensionTurnedOn(E_GL_ARB_separate_shader_objects)) {
if (identifier == "gl_Position" || if (identifier == "gl_Position" ||
identifier == "gl_PointSize" || identifier == "gl_PointSize" ||
identifier == "gl_ClipVertex" || identifier == "gl_ClipVertex" ||

Просмотреть файл

@ -227,6 +227,7 @@ public:
void requireNotRemoved(TSourceLoc, int queryProfiles, int removedVersion, const char* featureDesc); void requireNotRemoved(TSourceLoc, int queryProfiles, int removedVersion, const char* featureDesc);
void requireExtensions(TSourceLoc, int numExtensions, const char* const extensions[], const char* featureDesc); void requireExtensions(TSourceLoc, int numExtensions, const char* const extensions[], const char* featureDesc);
TExtensionBehavior getExtensionBehavior(const char*); TExtensionBehavior getExtensionBehavior(const char*);
bool extensionTurnedOn(const char* const extension);
bool extensionsTurnedOn(int numExtensions, const char* const extensions[]); bool extensionsTurnedOn(int numExtensions, const char* const extensions[]);
void updateExtensionBehavior(int line, const char* const extension, const char* behavior); void updateExtensionBehavior(int line, const char* const extension, const char* behavior);
void fullIntegerCheck(TSourceLoc, const char* op); void fullIntegerCheck(TSourceLoc, const char* op);

Просмотреть файл

@ -686,7 +686,7 @@ int TScanContext::tokenizeIdentifier()
case ATOMIC_UINT: case ATOMIC_UINT:
if ((parseContext.profile == EEsProfile && parseContext.version >= 310) || if ((parseContext.profile == EEsProfile && parseContext.version >= 310) ||
parseContext.extensionsTurnedOn(1, &E_GL_ARB_shader_atomic_counters)) parseContext.extensionTurnedOn(E_GL_ARB_shader_atomic_counters))
return keyword; return keyword;
return es30ReservedFromGLSL(420); return es30ReservedFromGLSL(420);
@ -696,12 +696,12 @@ int TScanContext::tokenizeIdentifier()
case WRITEONLY: case WRITEONLY:
if (parseContext.profile == EEsProfile && parseContext.version >= 310) if (parseContext.profile == EEsProfile && parseContext.version >= 310)
return keyword; return keyword;
return es30ReservedFromGLSL(parseContext.extensionsTurnedOn(1, &E_GL_ARB_shader_image_load_store) ? 130 : 420); return es30ReservedFromGLSL(parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store) ? 130 : 420);
case VOLATILE: case VOLATILE:
if (parseContext.profile == EEsProfile && parseContext.version >= 310) if (parseContext.profile == EEsProfile && parseContext.version >= 310)
return keyword; return keyword;
if (! parseContext.symbolTable.atBuiltInLevel() && (parseContext.profile == EEsProfile || (parseContext.version < 420 && ! parseContext.extensionsTurnedOn(1, &E_GL_ARB_shader_image_load_store)))) if (! parseContext.symbolTable.atBuiltInLevel() && (parseContext.profile == EEsProfile || (parseContext.version < 420 && ! parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))))
reservedWord(); reservedWord();
return keyword; return keyword;
@ -725,7 +725,7 @@ int TScanContext::tokenizeIdentifier()
case PATCH: case PATCH:
if (parseContext.symbolTable.atBuiltInLevel() || if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.profile == EEsProfile && parseContext.extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader)) || (parseContext.profile == EEsProfile && parseContext.extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader)) ||
(parseContext.profile != EEsProfile && parseContext.extensionsTurnedOn(1, &E_GL_ARB_tessellation_shader))) (parseContext.profile != EEsProfile && parseContext.extensionTurnedOn(E_GL_ARB_tessellation_shader)))
return keyword; return keyword;
return es30ReservedFromGLSL(400); return es30ReservedFromGLSL(400);
@ -818,7 +818,7 @@ int TScanContext::tokenizeIdentifier()
case ISAMPLERCUBEARRAY: case ISAMPLERCUBEARRAY:
case USAMPLERCUBEARRAY: case USAMPLERCUBEARRAY:
afterType = true; afterType = true;
if (parseContext.profile == EEsProfile || (parseContext.version < 400 && ! parseContext.extensionsTurnedOn(1, &E_GL_ARB_texture_cube_map_array))) if (parseContext.profile == EEsProfile || (parseContext.version < 400 && ! parseContext.extensionTurnedOn(E_GL_ARB_texture_cube_map_array)))
reservedWord(); reservedWord();
return keyword; return keyword;
@ -880,7 +880,7 @@ int TScanContext::tokenizeIdentifier()
case SAMPLER3D: case SAMPLER3D:
afterType = true; afterType = true;
if (parseContext.profile == EEsProfile && parseContext.version < 300) { if (parseContext.profile == EEsProfile && parseContext.version < 300) {
if (! parseContext.extensionsTurnedOn(1, &E_GL_OES_texture_3D)) if (! parseContext.extensionTurnedOn(E_GL_OES_texture_3D))
reservedWord(); reservedWord();
} }
return keyword; return keyword;
@ -896,7 +896,7 @@ int TScanContext::tokenizeIdentifier()
afterType = true; afterType = true;
if (parseContext.profile == EEsProfile) if (parseContext.profile == EEsProfile)
reservedWord(); reservedWord();
else if (parseContext.version < 140 && ! parseContext.symbolTable.atBuiltInLevel() && ! parseContext.extensionsTurnedOn(1, &E_GL_ARB_texture_rectangle)) { else if (parseContext.version < 140 && ! parseContext.symbolTable.atBuiltInLevel() && ! parseContext.extensionTurnedOn(E_GL_ARB_texture_rectangle)) {
if (parseContext.relaxedErrors()) if (parseContext.relaxedErrors())
parseContext.requireExtensions(loc, 1, &E_GL_ARB_texture_rectangle, "texture-rectangle sampler keyword"); parseContext.requireExtensions(loc, 1, &E_GL_ARB_texture_rectangle, "texture-rectangle sampler keyword");
else else
@ -915,7 +915,7 @@ int TScanContext::tokenizeIdentifier()
case SAMPLEREXTERNALOES: case SAMPLEREXTERNALOES:
afterType = true; afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() || parseContext.extensionsTurnedOn(1, &E_GL_OES_EGL_image_external)) if (parseContext.symbolTable.atBuiltInLevel() || parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external))
return keyword; return keyword;
return identifierOrType(); return identifierOrType();
@ -1107,7 +1107,7 @@ int TScanContext::firstGenerationImage(bool inEs310)
afterType = true; afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() || if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.profile != EEsProfile && (parseContext.version >= 420 || parseContext.extensionsTurnedOn(1, &E_GL_ARB_shader_image_load_store))) || (parseContext.profile != EEsProfile && (parseContext.version >= 420 || parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) ||
(inEs310 && parseContext.profile == EEsProfile && parseContext.version >= 310)) (inEs310 && parseContext.profile == EEsProfile && parseContext.version >= 310))
return keyword; return keyword;
@ -1135,7 +1135,7 @@ int TScanContext::secondGenerationImage()
if (parseContext.symbolTable.atBuiltInLevel() || if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.profile != EEsProfile && (parseContext.profile != EEsProfile &&
(parseContext.version >= 420 || parseContext.extensionsTurnedOn(1, &E_GL_ARB_shader_image_load_store)))) (parseContext.version >= 420 || parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))))
return keyword; return keyword;
if (parseContext.forwardCompatible) if (parseContext.forwardCompatible)

Просмотреть файл

@ -448,20 +448,25 @@ TExtensionBehavior TParseContext::getExtensionBehavior(const char* extension)
return iter->second; return iter->second;
} }
// Returns true if the given extension is set to enable, require, or warn.
bool TParseContext::extensionTurnedOn(const char* const extension)
{
switch (getExtensionBehavior(extension)) {
case EBhEnable:
case EBhRequire:
case EBhWarn:
return true;
default:
break;
}
return false;
}
// See if any of the extensions are set to enable, require, or warn. // See if any of the extensions are set to enable, require, or warn.
bool TParseContext::extensionsTurnedOn(int numExtensions, const char* const extensions[]) bool TParseContext::extensionsTurnedOn(int numExtensions, const char* const extensions[])
{ {
for (int i = 0; i < numExtensions; ++i) { for (int i = 0; i < numExtensions; ++i) {
switch (getExtensionBehavior(extensions[i])) { if (extensionTurnedOn(extensions[i])) return true;
case EBhEnable:
case EBhRequire:
case EBhWarn:
return true;
default:
break;
}
} }
return false; return false;
} }