Fix incompatibility with <GL/glext.h>

New extensions in glext.h follow the pattern:

    #ifndef GL_ARB_texture_rectangle
    #define GL_ARB_texture_rectangle 1
    #define GL_TEXTURE_RECTANGLE_ARB          0x84F5
    #define GL_TEXTURE_BINDING_RECTANGLE_ARB  0x84F6
    #define GL_PROXY_TEXTURE_RECTANGLE_ARB    0x84F7
    #define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
    #endif /* GL_ARB_texture_rectangle */

Versions.h tries to declare:

    const char* const GL_ARB_texture_rectangle = "GL_ARB_texture_rectangle";

Which means, if you've included glext.h before Versions.h, that the
compiler will see "const char* const 1 = ...", and rightly refuse to
continue.

The ham-fisted approach taken here is to rename the variables in
Versions.h with a leading underscore.  This does sort of undermine the
comment about "better to have the compiler do spelling checks", but.

Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Adam Jackson 2015-06-30 10:11:38 -04:00
parent 1189a7bc4a
commit 93deac5295
6 changed files with 221 additions and 221 deletions

View file

@ -730,12 +730,12 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
//
if (field == "length") {
if (base->isArray()) {
profileRequires(loc, ENoProfile, 120, GL_3DL_array_objects, ".length");
profileRequires(loc, ENoProfile, 120, _GL_3DL_array_objects, ".length");
profileRequires(loc, EEsProfile, 300, nullptr, ".length");
} else if (base->isVector() || base->isMatrix()) {
const char* feature = ".length() on vectors and matrices";
requireProfile(loc, ~EEsProfile, feature);
profileRequires(loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, feature);
profileRequires(loc, ~EEsProfile, 420, _GL_ARB_shading_language_420pack, feature);
} else {
error(loc, "does not operate on this type:", field.c_str(), base->getType().getCompleteString().c_str());
@ -761,7 +761,7 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
if (base->isScalar()) {
const char* dotFeature = "scalar swizzle";
requireProfile(loc, ~EEsProfile, dotFeature);
profileRequires(loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, dotFeature);
profileRequires(loc, ~EEsProfile, 420, _GL_ARB_shading_language_420pack, dotFeature);
}
TVectorFields fields;
@ -1310,13 +1310,13 @@ void TParseContext::nonOpBuiltInCheck(TSourceLoc loc, const TFunction& fnCandida
if (fnCandidate.getName().compare("textureGatherOffset") == 0) {
// GL_ARB_texture_gather is good enough for 2D non-shadow textures with no component argument
if (fnCandidate[0].type->getSampler().dim == Esd2D && ! fnCandidate[0].type->getSampler().shadow && fnCandidate.getParamCount() == 3)
profileRequires(loc, ~EEsProfile, 400, GL_ARB_texture_gather, feature);
profileRequires(loc, ~EEsProfile, 400, _GL_ARB_texture_gather, feature);
else
profileRequires(loc, ~EEsProfile, 400, GL_ARB_gpu_shader5, feature);
profileRequires(loc, ~EEsProfile, 400, _GL_ARB_gpu_shader5, feature);
if (! fnCandidate[0].type->getSampler().shadow)
compArg = 3;
} else if (fnCandidate.getName().compare("textureGatherOffsets") == 0) {
profileRequires(loc, ~EEsProfile, 400, GL_ARB_gpu_shader5, feature);
profileRequires(loc, ~EEsProfile, 400, _GL_ARB_gpu_shader5, feature);
if (! fnCandidate[0].type->getSampler().shadow)
compArg = 3;
// check for constant offsets
@ -1327,11 +1327,11 @@ void TParseContext::nonOpBuiltInCheck(TSourceLoc loc, const TFunction& fnCandida
// More than two arguments needs gpu_shader5, and rectangular or shadow needs gpu_shader5,
// otherwise, need GL_ARB_texture_gather.
if (fnCandidate.getParamCount() > 2 || fnCandidate[0].type->getSampler().dim == EsdRect || fnCandidate[0].type->getSampler().shadow) {
profileRequires(loc, ~EEsProfile, 400, GL_ARB_gpu_shader5, feature);
profileRequires(loc, ~EEsProfile, 400, _GL_ARB_gpu_shader5, feature);
if (! fnCandidate[0].type->getSampler().shadow)
compArg = 2;
} else
profileRequires(loc, ~EEsProfile, 400, GL_ARB_texture_gather, feature);
profileRequires(loc, ~EEsProfile, 400, _GL_ARB_texture_gather, feature);
}
if (compArg > 0 && compArg < fnCandidate.getParamCount()) {
@ -1381,7 +1381,7 @@ void TParseContext::nonOpBuiltInCheck(TSourceLoc loc, const TFunction& fnCandida
// GL_ARB_shader_texture_image_samples
if (fnCandidate.getName().compare(0, 14, "textureSamples") == 0 || fnCandidate.getName().compare(0, 12, "imageSamples") == 0)
profileRequires(loc, ~EEsProfile, 450, GL_ARB_shader_texture_image_samples, "textureSamples and imageSamples");
profileRequires(loc, ~EEsProfile, 450, _GL_ARB_shader_texture_image_samples, "textureSamples and imageSamples");
if (fnCandidate.getName().compare(0, 11, "imageAtomic") == 0) {
const TType& imageType = callNode.getSequence()[0]->getAsTyped()->getType();
@ -1402,7 +1402,7 @@ TFunction* TParseContext::handleConstructorCall(TSourceLoc loc, const TPublicTyp
type.getQualifier().precision = EpqNone;
if (type.isArray()) {
profileRequires(loc, ENoProfile, 120, GL_3DL_array_objects, "arrayed constructor");
profileRequires(loc, ENoProfile, 120, _GL_3DL_array_objects, "arrayed constructor");
profileRequires(loc, EEsProfile, 300, nullptr, "arrayed constructor");
}
@ -1841,7 +1841,7 @@ bool TParseContext::lineContinuationCheck(TSourceLoc loc, bool endOfComment)
const char* message = "line continuation";
bool lineContinuationAllowed = (profile == EEsProfile && version >= 300) ||
(profile != EEsProfile && (version >= 420 || extensionsTurnedOn(1, &GL_ARB_shading_language_420pack)));
(profile != EEsProfile && (version >= 420 || extensionsTurnedOn(1, &_GL_ARB_shading_language_420pack)));
if (endOfComment) {
if (lineContinuationAllowed)
@ -1858,7 +1858,7 @@ bool TParseContext::lineContinuationCheck(TSourceLoc loc, bool endOfComment)
return true;
} else {
profileRequires(loc, EEsProfile, 300, nullptr, message);
profileRequires(loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, message);
profileRequires(loc, ~EEsProfile, 420, _GL_ARB_shading_language_420pack, message);
}
return lineContinuationAllowed;
@ -2228,7 +2228,7 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
// Ordering
if (! force && ((profile != EEsProfile && version < 420) ||
(profile == EEsProfile && version < 310))
&& ! extensionsTurnedOn(1, &GL_ARB_shading_language_420pack)) {
&& ! extensionsTurnedOn(1, &_GL_ARB_shading_language_420pack)) {
// non-function parameters
if (src.invariant && (dst.isInterpolation() || dst.isAuxiliary() || dst.storage != EvqTemporary || dst.precision != EpqNone))
error(loc, "invariant qualifier must appear first", "", "");
@ -2411,7 +2411,7 @@ void TParseContext::arraySizeCheck(TSourceLoc loc, TIntermTyped* expr, int& size
bool TParseContext::arrayQualifierError(TSourceLoc loc, const TQualifier& qualifier)
{
if (qualifier.storage == EvqConst) {
profileRequires(loc, ENoProfile, 120, GL_3DL_array_objects, "const array");
profileRequires(loc, ENoProfile, 120, _GL_3DL_array_objects, "const array");
profileRequires(loc, EEsProfile, 300, nullptr, "const array");
}
@ -2683,7 +2683,7 @@ TSymbol* TParseContext::redeclareBuiltinVariable(TSourceLoc loc, const TString&
// 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
if (profile != EEsProfile && version <= 140 && extensionsTurnedOn(1, &GL_ARB_separate_shader_objects)) {
if (profile != EEsProfile && version <= 140 && extensionsTurnedOn(1, &_GL_ARB_separate_shader_objects)) {
if (identifier == "gl_Position" ||
identifier == "gl_PointSize" ||
identifier == "gl_ClipVertex" ||
@ -2800,7 +2800,7 @@ void TParseContext::redeclareBuiltinBlock(TSourceLoc loc, TTypeList& newTypeList
{
const char* feature = "built-in block redeclaration";
profileRequires(loc, EEsProfile, 0, Num_AEP_shader_io_blocks, AEP_shader_io_blocks, feature);
profileRequires(loc, ~EEsProfile, 410, GL_ARB_separate_shader_objects, feature);
profileRequires(loc, ~EEsProfile, 410, _GL_ARB_separate_shader_objects, feature);
if (blockName != "gl_PerVertex" && blockName != "gl_PerFragment") {
error(loc, "cannot redeclare block: ", "block declaration", blockName.c_str());
@ -2998,7 +2998,7 @@ void TParseContext::arrayObjectCheck(TSourceLoc loc, const TType& type, const ch
{
// Some versions don't allow comparing arrays or structures containing arrays
if (type.containsArray()) {
profileRequires(loc, ENoProfile, 120, GL_3DL_array_objects, op);
profileRequires(loc, ENoProfile, 120, _GL_3DL_array_objects, op);
profileRequires(loc, EEsProfile, 300, nullptr, op);
}
}
@ -3194,11 +3194,11 @@ void TParseContext::finalErrorCheck()
if (profile == EEsProfile && version == 310)
requireExtensions(getCurrentLoc(), Num_AEP_tessellation_shader, AEP_tessellation_shader, "tessellation shaders");
else if (profile != EEsProfile && version < 400)
requireExtensions(getCurrentLoc(), 1, &GL_ARB_tessellation_shader, "tessellation shaders");
requireExtensions(getCurrentLoc(), 1, &_GL_ARB_tessellation_shader, "tessellation shaders");
break;
case EShLangCompute:
if (profile != EEsProfile && version < 430)
requireExtensions(getCurrentLoc(), 1, &GL_ARB_compute_shader, "tessellation shaders");
requireExtensions(getCurrentLoc(), 1, &_GL_ARB_compute_shader, "tessellation shaders");
break;
default:
break;
@ -3248,8 +3248,8 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
(format > ElfEsIntGuard && format < ElfIntGuard) ||
(format > ElfEsUintGuard && format < ElfCount))
requireProfile(loc, ENoProfile | ECoreProfile | ECompatibilityProfile, "image load-store format");
profileRequires(loc, ENoProfile | ECoreProfile | ECompatibilityProfile, 420, GL_ARB_shader_image_load_store, "image load store");
profileRequires(loc, EEsProfile, 310, GL_ARB_shader_image_load_store, "image load store");
profileRequires(loc, ENoProfile | ECoreProfile | ECompatibilityProfile, 420, _GL_ARB_shader_image_load_store, "image load store");
profileRequires(loc, EEsProfile, 310, _GL_ARB_shader_image_load_store, "image load store");
publicType.qualifier.layoutFormat = format;
return;
}
@ -3344,7 +3344,7 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
return;
}
if (id == "early_fragment_tests") {
profileRequires(loc, ENoProfile | ECoreProfile | ECompatibilityProfile, 420, GL_ARB_shader_image_load_store, "early_fragment_tests");
profileRequires(loc, ENoProfile | ECoreProfile | ECompatibilityProfile, 420, _GL_ARB_shader_image_load_store, "early_fragment_tests");
profileRequires(loc, EEsProfile, 310, nullptr, "early_fragment_tests");
publicType.shaderQualifiers.earlyFragmentTests = true;
return;
@ -3375,7 +3375,7 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
value = constUnion->getConstArray()[0].getIConst();
if (! constUnion->isLiteral()) {
requireProfile(loc, ECoreProfile | ECompatibilityProfile, nonLiteralFeature);
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, GL_ARB_enhanced_layouts, nonLiteralFeature);
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, _GL_ARB_enhanced_layouts, nonLiteralFeature);
}
} else {
// grammar should have give out the error message
@ -3392,7 +3392,7 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
if (id == "offset") {
const char* feature = "uniform offset";
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, feature);
const char* exts[2] = { GL_ARB_enhanced_layouts, GL_ARB_shader_atomic_counters };
const char* exts[2] = { _GL_ARB_enhanced_layouts, _GL_ARB_shader_atomic_counters };
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 420, 2, exts, feature);
profileRequires(loc, EEsProfile, 310, nullptr, feature);
publicType.qualifier.layoutOffset = value;
@ -3400,7 +3400,7 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
} else if (id == "align") {
const char* feature = "uniform buffer-member align";
requireProfile(loc, ECoreProfile | ECompatibilityProfile, feature);
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, GL_ARB_enhanced_layouts, feature);
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, _GL_ARB_enhanced_layouts, feature);
// "The specified alignment must be a power of 2, or a compile-time error results."
if (! IsPow2(value))
error(loc, "must be a power of 2", "align", "");
@ -3409,7 +3409,7 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
return;
} else if (id == "location") {
profileRequires(loc, EEsProfile, 300, nullptr, "location");
const char* exts[2] = { GL_ARB_separate_shader_objects, GL_ARB_explicit_attrib_location };
const char* exts[2] = { _GL_ARB_separate_shader_objects, _GL_ARB_explicit_attrib_location };
profileRequires(loc, ~EEsProfile, 330, 2, exts, "location");
if ((unsigned int)value >= TQualifier::layoutLocationEnd)
error(loc, "location is too large", id.c_str(), "");
@ -3423,7 +3423,7 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
publicType.qualifier.layoutSet = value;
return;
} else if (id == "binding") {
profileRequires(loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, "binding");
profileRequires(loc, ~EEsProfile, 420, _GL_ARB_shading_language_420pack, "binding");
profileRequires(loc, EEsProfile, 310, nullptr, "binding");
if ((unsigned int)value >= TQualifier::layoutBindingEnd)
error(loc, "binding is too large", id.c_str(), "");
@ -3432,7 +3432,7 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
return;
} else if (id == "component") {
requireProfile(loc, ECoreProfile | ECompatibilityProfile, "component");
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, GL_ARB_enhanced_layouts, "component");
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, _GL_ARB_enhanced_layouts, "component");
if ((unsigned)value >= TQualifier::layoutComponentEnd)
error(loc, "component is too large", id.c_str(), "");
else
@ -3447,7 +3447,7 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
const char* feature = "transform feedback qualifier";
requireStage(loc, (EShLanguageMask)(EShLangVertexMask | EShLangGeometryMask | EShLangTessControlMask | EShLangTessEvaluationMask), feature);
requireProfile(loc, ECoreProfile | ECompatibilityProfile, feature);
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, GL_ARB_enhanced_layouts, feature);
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, _GL_ARB_enhanced_layouts, feature);
if (id == "xfb_buffer") {
// "It is a compile-time error to specify an *xfb_buffer* that is greater than
// the implementation-dependent constant gl_MaxTransformFeedbackBuffers."
@ -3513,7 +3513,7 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
case EShLangFragment:
if (id == "index") {
requireProfile(loc, ECompatibilityProfile | ECoreProfile, "index layout qualifier on fragment output");
const char* exts[2] = { GL_ARB_separate_shader_objects, GL_ARB_explicit_attrib_location };
const char* exts[2] = { _GL_ARB_separate_shader_objects, _GL_ARB_explicit_attrib_location };
profileRequires(loc, ECompatibilityProfile | ECoreProfile, 330, 2, exts, "index layout qualifier on fragment output");
publicType.qualifier.layoutIndex = value;
return;
@ -3678,7 +3678,7 @@ void TParseContext::layoutTypeCheck(TSourceLoc loc, const TType& type)
case EvqVaryingIn:
case EvqVaryingOut:
if (type.getBasicType() == EbtBlock)
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, GL_ARB_enhanced_layouts, "location qualifier on in/out block");
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, _GL_ARB_enhanced_layouts, "location qualifier on in/out block");
break;
case EvqUniform:
case EvqBuffer:
@ -3806,11 +3806,11 @@ void TParseContext::layoutQualifierCheck(TSourceLoc loc, const TQualifier& quali
else
requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature);
if (language == EShLangVertex) {
const char* exts[2] = { GL_ARB_separate_shader_objects, GL_ARB_explicit_attrib_location };
const char* exts[2] = { _GL_ARB_separate_shader_objects, _GL_ARB_explicit_attrib_location };
profileRequires(loc, ~EEsProfile, 330, 2, exts, feature);
profileRequires(loc, EEsProfile, 300, nullptr, feature);
} else {
profileRequires(loc, ~EEsProfile, 410, GL_ARB_separate_shader_objects, feature);
profileRequires(loc, ~EEsProfile, 410, _GL_ARB_separate_shader_objects, feature);
profileRequires(loc, EEsProfile, 310, nullptr, feature);
}
break;
@ -3823,11 +3823,11 @@ void TParseContext::layoutQualifierCheck(TSourceLoc loc, const TQualifier& quali
else
requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature);
if (language == EShLangFragment) {
const char* exts[2] = { GL_ARB_separate_shader_objects, GL_ARB_explicit_attrib_location };
const char* exts[2] = { _GL_ARB_separate_shader_objects, _GL_ARB_explicit_attrib_location };
profileRequires(loc, ~EEsProfile, 330, 2, exts, feature);
profileRequires(loc, EEsProfile, 300, nullptr, feature);
} else {
profileRequires(loc, ~EEsProfile, 410, GL_ARB_separate_shader_objects, feature);
profileRequires(loc, ~EEsProfile, 410, _GL_ARB_separate_shader_objects, feature);
profileRequires(loc, EEsProfile, 310, nullptr, feature);
}
break;
@ -4107,7 +4107,7 @@ TIntermNode* TParseContext::declareVariable(TSourceLoc loc, TString& identifier,
declareArray(loc, identifier, type, symbol, newDeclaration);
if (initializer) {
profileRequires(loc, ENoProfile, 120, GL_3DL_array_objects, "initializer");
profileRequires(loc, ENoProfile, 120, _GL_3DL_array_objects, "initializer");
profileRequires(loc, EEsProfile, 300, nullptr, "initializer");
}
} else {
@ -4246,7 +4246,7 @@ TIntermNode* TParseContext::executeInitializer(TSourceLoc loc, TIntermTyped* ini
if (initializer->getType().getQualifier().storage != EvqConst) {
const char* initFeature = "non-constant initializer";
requireProfile(loc, ~EEsProfile, initFeature);
profileRequires(loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, initFeature);
profileRequires(loc, ~EEsProfile, 420, _GL_ARB_shading_language_420pack, initFeature);
variable->getWritableType().getQualifier().storage = EvqConstReadOnly;
qualifier = EvqConstReadOnly;
}
@ -4580,7 +4580,7 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr
requireProfile(memberLoc, ~EEsProfile, "implicitly-sized array in a block");
if (memberQualifier.hasOffset()) {
requireProfile(memberLoc, ~EEsProfile, "offset on block member");
profileRequires(memberLoc, ~EEsProfile, 440, GL_ARB_enhanced_layouts, "offset on block member");
profileRequires(memberLoc, ~EEsProfile, 440, _GL_ARB_enhanced_layouts, "offset on block member");
}
TBasicType basicType = memberType.getBasicType();
@ -4653,7 +4653,7 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr
case EvqVaryingIn:
case EvqVaryingOut:
requireProfile(memberLoc, ECoreProfile | ECompatibilityProfile | EEsProfile, feature);
profileRequires(memberLoc, ECoreProfile | ECompatibilityProfile, 440, GL_ARB_enhanced_layouts, feature);
profileRequires(memberLoc, ECoreProfile | ECompatibilityProfile, 440, _GL_ARB_enhanced_layouts, feature);
profileRequires(memberLoc, EEsProfile, 0, Num_AEP_shader_io_blocks, AEP_shader_io_blocks, feature);
memberWithLocation = true;
break;
@ -4767,7 +4767,7 @@ void TParseContext::blockStageIoCheck(TSourceLoc loc, const TQualifier& qualifie
profileRequires(loc, EEsProfile, 310, nullptr, "buffer block");
break;
case EvqVaryingIn:
profileRequires(loc, ~EEsProfile, 150, GL_ARB_separate_shader_objects, "input block");
profileRequires(loc, ~EEsProfile, 150, _GL_ARB_separate_shader_objects, "input block");
// It is a compile-time error to have an input block in a vertex shader or an output block in a fragment shader
// "Compute shaders do not permit user-defined input variables..."
requireStage(loc, (EShLanguageMask)(EShLangTessControlMask|EShLangTessEvaluationMask|EShLangGeometryMask|EShLangFragmentMask), "input block");
@ -4775,7 +4775,7 @@ void TParseContext::blockStageIoCheck(TSourceLoc loc, const TQualifier& qualifie
profileRequires(loc, EEsProfile, 0, Num_AEP_shader_io_blocks, AEP_shader_io_blocks, "fragment input block");
break;
case EvqVaryingOut:
profileRequires(loc, ~EEsProfile, 150, GL_ARB_separate_shader_objects, "output block");
profileRequires(loc, ~EEsProfile, 150, _GL_ARB_separate_shader_objects, "output block");
requireStage(loc, (EShLanguageMask)(EShLangVertexMask|EShLangTessControlMask|EShLangTessEvaluationMask|EShLangGeometryMask), "output block");
// ES 310 can have a block before shader_io is turned on, so skip this test for built-ins
if (language == EShLangVertex && ! parsingBuiltins)