Web: Use isEsProfile() instead of run-time testing; remove more atomics
Saves 2.5K, and design is better.
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index a91f180..33c4db4 100644
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -2075,6 +2075,7 @@
spv::Builder::AccessChain::CoherentFlags lvalueCoherentFlags;
+#ifndef GLSLANG_WEB
if (node->getOp() == glslang::EOpAtomicCounterIncrement ||
node->getOp() == glslang::EOpAtomicCounterDecrement ||
node->getOp() == glslang::EOpAtomicCounter ||
@@ -2083,7 +2084,10 @@
lvalueCoherentFlags = builder.getAccessChain().coherentFlags;
lvalueCoherentFlags |= TranslateCoherent(operandNode->getAsTyped()->getType());
} else
+#endif
+ {
operand = accessChainLoad(node->getOperand()->getType());
+ }
OpDecorations decorations = { TranslatePrecisionDecoration(node->getOperationPrecision()),
TranslateNoContractionDecoration(node->getType().getQualifier()),
diff --git a/Test/baseResults/size b/Test/baseResults/size
index 6de1c4d..68d9adc 100644
--- a/Test/baseResults/size
+++ b/Test/baseResults/size
@@ -1 +1 @@
-601088 ../build/install/bin/glslangValidator.exe
+598528 ../build/install/bin/glslangValidator.exe
diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h
index 9fa47fa..79c9efc 100644
--- a/glslang/Include/Types.h
+++ b/glslang/Include/Types.h
@@ -894,10 +894,6 @@
{
return layoutPacking != ElpNone;
}
- bool hasOffset() const
- {
- return layoutOffset != layoutNotSet;
- }
bool hasAlign() const
{
return layoutAlign != layoutNotSet;
@@ -921,6 +917,7 @@
return layoutBinding != layoutBindingEnd;
}
#ifdef GLSLANG_WEB
+ bool hasOffset() const { return false; }
bool isNonPerspective() const { return false; }
bool hasIndex() const { return false; }
bool hasComponent() const { return false; }
@@ -938,6 +935,10 @@
bool hasBufferReferenceAlign() const { return false; }
bool isNonUniform() const { return false; }
#else
+ bool hasOffset() const
+ {
+ return layoutOffset != layoutNotSet;
+ }
bool isNonPerspective() const { return nopersp; }
bool hasIndex() const
{
diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp
index 6e0090c..798728c 100644
--- a/glslang/MachineIndependent/Initialize.cpp
+++ b/glslang/MachineIndependent/Initialize.cpp
@@ -6166,14 +6166,14 @@
// enumerate all the types
#ifdef GLSLANG_WEB
const TBasicType bTypes[] = { EbtFloat, EbtInt, EbtUint };
- const int image = 0;
bool skipBuffer = true;
bool skipCubeArrayed = true;
+ const int image = 0;
#else
const TBasicType bTypes[] = { EbtFloat, EbtInt, EbtUint, EbtFloat16 };
- for (int image = 0; image <= 1; ++image) // loop over "bool" image vs sampler
bool skipBuffer = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 140);
bool skipCubeArrayed = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 130);
+ for (int image = 0; image <= 1; ++image) // loop over "bool" image vs sampler
#endif
{
for (int shadow = 0; shadow <= 1; ++shadow) { // loop over "bool" shadow or not
diff --git a/glslang/MachineIndependent/Intermediate.cpp b/glslang/MachineIndependent/Intermediate.cpp
index fcc509d..966040b 100644
--- a/glslang/MachineIndependent/Intermediate.cpp
+++ b/glslang/MachineIndependent/Intermediate.cpp
@@ -1604,11 +1604,7 @@
//
bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperator op) const
{
-#ifdef GLSLANG_WEB
- return false;
-#endif
-
- if (profile == EEsProfile || version == 110)
+ if (isEsProfile() || version == 110)
return false;
if (from == to)
@@ -1916,14 +1912,10 @@
std::tuple<TBasicType, TBasicType> TIntermediate::getConversionDestinatonType(TBasicType type0, TBasicType type1, TOperator op) const
{
-#ifdef GLSLANG_WEB
- return std::make_tuple(EbtNumTypes, EbtNumTypes);
-#endif
-
TBasicType res0 = EbtNumTypes;
TBasicType res1 = EbtNumTypes;
- if (profile == EEsProfile || version == 110)
+ if (isEsProfile() || version == 110)
return std::make_tuple(res0, res1);
if (getSource() == EShSourceHlsl) {
diff --git a/glslang/MachineIndependent/ParseContextBase.cpp b/glslang/MachineIndependent/ParseContextBase.cpp
index 9fbbe59..aebd834 100644
--- a/glslang/MachineIndependent/ParseContextBase.cpp
+++ b/glslang/MachineIndependent/ParseContextBase.cpp
@@ -170,13 +170,13 @@
case EbtSampler:
message = "can't modify a sampler";
break;
- case EbtAtomicUint:
- message = "can't modify an atomic_uint";
- break;
case EbtVoid:
message = "can't modify void";
break;
#ifndef GLSLANG_WEB
+ case EbtAtomicUint:
+ message = "can't modify an atomic_uint";
+ break;
case EbtAccStructNV:
message = "can't modify accelerationStructureNV";
break;
diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp
index aa888e5..4ff266e 100644
--- a/glslang/MachineIndependent/ParseHelper.cpp
+++ b/glslang/MachineIndependent/ParseHelper.cpp
@@ -60,9 +60,9 @@
atomicUintOffsets(nullptr), anyIndexLimits(false)
{
// decide whether precision qualifiers should be ignored or respected
- if (profile == EEsProfile || spvVersion.vulkan > 0) {
+ if (isEsProfile() || spvVersion.vulkan > 0) {
precisionManager.respectPrecisionQualifiers();
- if (! parsingBuiltins && language == EShLangFragment && profile != EEsProfile && spvVersion.vulkan > 0)
+ if (! parsingBuiltins && language == EShLangFragment && !isEsProfile() && spvVersion.vulkan > 0)
precisionManager.warnAboutDefaults();
}
@@ -123,7 +123,7 @@
// replace with real precision defaults for those that have them
if (obeyPrecisionQualifiers()) {
- if (profile == EEsProfile) {
+ if (isEsProfile()) {
// Most don't have defaults, a few default to lowp.
TSampler sampler;
sampler.set(EbtFloat, Esd2D);
@@ -140,7 +140,7 @@
// is used to resolve the precision from the supplied arguments/operands instead.
// So, we don't actually want to replace EpqNone with a default precision for built-ins.
if (! parsingBuiltins) {
- if (profile == EEsProfile && language == EShLangFragment) {
+ if (isEsProfile() && language == EShLangFragment) {
defaultPrecision[EbtInt] = EpqMedium;
defaultPrecision[EbtUint] = EpqMedium;
} else {
@@ -149,7 +149,7 @@
defaultPrecision[EbtFloat] = EpqHigh;
}
- if (profile != EEsProfile) {
+ if (!isEsProfile()) {
// Non-ES profile
// All sampler precisions default to highp.
for (int type = 0; type < maxSamplerIndex; ++type)
@@ -2049,7 +2049,7 @@
} else {
if (fnCandidate.getName().compare(0, 19, "imageAtomicExchange") != 0)
error(loc, "only supported on integer images", fnCandidate.getName().c_str(), "");
- else if (imageType.getQualifier().getFormat() != ElfR32f && profile == EEsProfile)
+ else if (imageType.getQualifier().getFormat() != ElfR32f && isEsProfile())
error(loc, "only supported on image with format r32f", fnCandidate.getName().c_str(), "");
}
@@ -2097,7 +2097,7 @@
//
// ES and desktop 4.3 and earlier: swizzles may not be used
// desktop 4.4 and later: swizzles may be used
- bool swizzleOkay = (profile != EEsProfile) && (version >= 440);
+ bool swizzleOkay = (!isEsProfile()) && (version >= 440);
const TIntermTyped* base = TIntermediate::findLValueBase(arg0, swizzleOkay);
if (base == nullptr || base->getType().getQualifier().storage != EvqVaryingIn)
error(loc, "first argument must be an interpolant, or interpolant-array element", fnCandidate.getName().c_str(), "");
@@ -2318,7 +2318,7 @@
} else {
if (fnCandidate.getName().compare(0, 19, "imageAtomicExchange") != 0)
error(loc, "only supported on integer images", fnCandidate.getName().c_str(), "");
- else if (imageType.getQualifier().getFormat() != ElfR32f && profile == EEsProfile)
+ else if (imageType.getQualifier().getFormat() != ElfR32f && isEsProfile())
error(loc, "only supported on image with format r32f", fnCandidate.getName().c_str(), "");
}
}
@@ -2545,7 +2545,7 @@
case EvqFragDepth:
intermediate.setDepthReplacing();
// "In addition, it is an error to statically write to gl_FragDepth in the fragment shader."
- if (profile == EEsProfile && intermediate.getEarlyFragmentTests())
+ if (isEsProfile() && intermediate.getEarlyFragmentTests())
message = "can't modify gl_FragDepth if using early_fragment_tests";
break;
@@ -2639,7 +2639,7 @@
// in undefined behavior."
// however, before that, ES tests required an error.
if (identifier.find("__") != TString::npos) {
- if (profile == EEsProfile && version <= 300)
+ if (isEsProfile() && version <= 300)
error(loc, "identifiers containing consecutive underscores (\"__\") are reserved, and an error if version <= 300", identifier.c_str(), "");
else
warn(loc, "identifiers containing consecutive underscores (\"__\") are reserved", identifier.c_str(), "");
@@ -2664,13 +2664,13 @@
else if (strncmp(identifier, "defined", 8) == 0)
ppError(loc, "\"defined\" can't be (un)defined:", op, identifier);
else if (strstr(identifier, "__") != 0) {
- if (profile == EEsProfile && version >= 300 &&
+ if (isEsProfile() && version >= 300 &&
(strcmp(identifier, "__LINE__") == 0 ||
strcmp(identifier, "__FILE__") == 0 ||
strcmp(identifier, "__VERSION__") == 0))
ppError(loc, "predefined names can't be (un)defined:", op, identifier);
else {
- if (profile == EEsProfile && version <= 300)
+ if (isEsProfile() && version <= 300)
ppError(loc, "names containing consecutive underscores are reserved, and an error if version <= 300:", op, identifier);
else
ppWarn(loc, "names containing consecutive underscores are reserved:", op, identifier);
@@ -2685,10 +2685,14 @@
//
bool TParseContext::lineContinuationCheck(const TSourceLoc& loc, bool endOfComment)
{
+#ifdef GLSLANG_WEB
+ return true;
+#endif
+
const char* message = "line continuation";
- bool lineContinuationAllowed = (profile == EEsProfile && version >= 300) ||
- (profile != EEsProfile && (version >= 420 || extensionTurnedOn(E_GL_ARB_shading_language_420pack)));
+ bool lineContinuationAllowed = (isEsProfile() && version >= 300) ||
+ (!isEsProfile() && (version >= 420 || extensionTurnedOn(E_GL_ARB_shading_language_420pack)));
if (endOfComment) {
if (lineContinuationAllowed)
@@ -3414,8 +3418,8 @@
error(loc, "can only have one interpolation qualifier (flat, smooth, noperspective, __explicitInterpAMD)", "", "");
// Ordering
- if (! force && ((profile != EEsProfile && version < 420) ||
- (profile == EEsProfile && version < 310))
+ if (! force && ((!isEsProfile() && version < 420) ||
+ (isEsProfile() && version < 310))
&& ! extensionTurnedOn(E_GL_ARB_shading_language_420pack)) {
// non-function parameters
if (src.isNoContraction() && (dst.invariant || dst.isInterpolation() || dst.isAuxiliary() || dst.storage != EvqTemporary || dst.precision != EpqNone))
@@ -3752,16 +3756,15 @@
error(loc, "only outermost dimension of an array of arrays can be a specialization constant", "[]", "");
// desktop always allows outer-dimension-unsized variable arrays,
-#ifdef GLSLANG_WEB
- return;
-#else
- if (profile != EEsProfile)
+
+ if (!isEsProfile())
return;
-#endif
// for ES, if size isn't coming from an initializer, it has to be explicitly declared now,
// with very few exceptions
+#ifndef GLSLANG_WEB
+
// last member of ssbo block exception:
if (qualifier.storage == EvqBuffer && lastMember)
return;
@@ -3770,27 +3773,27 @@
switch (language) {
case EShLangGeometry:
if (qualifier.storage == EvqVaryingIn)
- if ((profile == EEsProfile && version >= 320) ||
+ if ((isEsProfile() && version >= 320) ||
extensionsTurnedOn(Num_AEP_geometry_shader, AEP_geometry_shader))
return;
break;
case EShLangTessControl:
if ( qualifier.storage == EvqVaryingIn ||
(qualifier.storage == EvqVaryingOut && ! qualifier.patch))
- if ((profile == EEsProfile && version >= 320) ||
+ if ((isEsProfile() && version >= 320) ||
extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader))
return;
break;
case EShLangTessEvaluation:
if ((qualifier.storage == EvqVaryingIn && ! qualifier.patch) ||
qualifier.storage == EvqVaryingOut)
- if ((profile == EEsProfile && version >= 320) ||
+ if ((isEsProfile() && version >= 320) ||
extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader))
return;
break;
case EShLangMeshNV:
if (qualifier.storage == EvqVaryingOut)
- if ((profile == EEsProfile && version >= 320) ||
+ if ((isEsProfile() && version >= 320) ||
extensionTurnedOn(E_GL_NV_mesh_shader))
return;
break;
@@ -3798,6 +3801,8 @@
break;
}
+#endif
+
arraySizeRequiredCheck(loc, *arraySizes);
}
@@ -3995,7 +4000,7 @@
// source string number source-string-number.
bool TParseContext::lineDirectiveShouldSetNextLine() const
{
- return profile == EEsProfile || version >= 330;
+ return isEsProfile() || version >= 330;
}
//
@@ -4030,15 +4035,15 @@
if (! builtInName(identifier) || symbolTable.atBuiltInLevel() || ! symbolTable.atGlobalLevel())
return nullptr;
- bool nonEsRedecls = (profile != EEsProfile && (version >= 130 || identifier == "gl_TexCoord"));
- bool esRedecls = (profile == EEsProfile &&
+ bool nonEsRedecls = (!isEsProfile() && (version >= 130 || identifier == "gl_TexCoord"));
+ bool esRedecls = (isEsProfile() &&
(version >= 320 || extensionsTurnedOn(Num_AEP_shader_io_blocks, AEP_shader_io_blocks)));
if (! esRedecls && ! nonEsRedecls)
return nullptr;
// 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 && extensionTurnedOn(E_GL_ARB_separate_shader_objects)) {
+ if (!isEsProfile() && version <= 140 && extensionTurnedOn(E_GL_ARB_separate_shader_objects)) {
if (identifier == "gl_Position" ||
identifier == "gl_PointSize" ||
identifier == "gl_ClipVertex" ||
@@ -4722,18 +4727,18 @@
// about the stage itself.
switch (language) {
case EShLangGeometry:
- if (profile == EEsProfile && version == 310)
+ if (isEsProfile() && version == 310)
requireExtensions(getCurrentLoc(), Num_AEP_geometry_shader, AEP_geometry_shader, "geometry shaders");
break;
case EShLangTessControl:
case EShLangTessEvaluation:
- if (profile == EEsProfile && version == 310)
+ if (isEsProfile() && version == 310)
requireExtensions(getCurrentLoc(), Num_AEP_tessellation_shader, AEP_tessellation_shader, "tessellation shaders");
- else if (profile != EEsProfile && version < 400)
+ else if (!isEsProfile() && version < 400)
requireExtensions(getCurrentLoc(), 1, &E_GL_ARB_tessellation_shader, "tessellation shaders");
break;
case EShLangCompute:
- if (profile != EEsProfile && version < 430)
+ if (!isEsProfile() && version < 430)
requireExtensions(getCurrentLoc(), 1, &E_GL_ARB_compute_shader, "compute shaders");
break;
case EShLangTaskNV:
@@ -5672,18 +5677,22 @@
if (spvVersion.vulkan == 0 && lastBinding >= resources.maxCombinedTextureImageUnits)
error(loc, "sampler binding not less than gl_MaxCombinedTextureImageUnits", "binding", type.isArray() ? "(using array)" : "");
}
+#ifndef GLSLANG_WEB
if (type.getBasicType() == EbtAtomicUint) {
if (qualifier.layoutBinding >= (unsigned int)resources.maxAtomicCounterBindings) {
error(loc, "atomic_uint binding is too large; see gl_MaxAtomicCounterBindings", "binding", "");
return;
}
}
+#endif
} else if (!intermediate.getAutoMapBindings()) {
// some types require bindings
+#ifndef GLSLANG_WEB
// atomic_uint
if (type.getBasicType() == EbtAtomicUint)
error(loc, "layout(binding=X) is required", "atomic_uint", "");
+#endif
// SPIR-V
if (spvVersion.spv > 0) {
@@ -5725,7 +5734,7 @@
if (type.getSampler().type == EbtUint && qualifier.getFormat() < ElfIntGuard)
error(loc, "does not apply to unsigned integer images", TQualifier::getLayoutFormatString(qualifier.getFormat()), "");
- if (profile == EEsProfile) {
+ if (isEsProfile()) {
// "Except for image variables qualified with the format qualifiers r32f, r32i, and r32ui, image variables must
// specify either memory qualifier readonly or the memory qualifier writeonly."
if (! (qualifier.getFormat() == ElfR32f || qualifier.getFormat() == ElfR32i || qualifier.getFormat() == ElfR32ui)) {
@@ -5807,7 +5816,7 @@
case EvqVaryingIn:
{
const char* feature = "location qualifier on input";
- if (profile == EEsProfile && version < 310)
+ if (isEsProfile() && version < 310)
requireStage(loc, EShLangVertex, feature);
else
requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature);
@@ -5824,7 +5833,7 @@
case EvqVaryingOut:
{
const char* feature = "location qualifier on output";
- if (profile == EEsProfile && version < 310)
+ if (isEsProfile() && version < 310)
requireStage(loc, EShLangFragment, feature);
else
requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature);
@@ -5954,6 +5963,7 @@
// Correct and/or advance an object's offset layout qualifier.
void TParseContext::fixOffset(const TSourceLoc& loc, TSymbol& symbol)
{
+#ifndef GLSLANG_WEB
const TQualifier& qualifier = symbol.getType().getQualifier();
if (symbol.getType().getBasicType() == EbtAtomicUint) {
if (qualifier.hasBinding() && (int)qualifier.layoutBinding < resources.maxAtomicCounterBindings) {
@@ -5984,6 +5994,7 @@
atomicUintOffsets[qualifier.layoutBinding] = offset + numOffsets;
}
}
+#endif
}
//
@@ -6012,7 +6023,7 @@
extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float32) ||
extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float64);
- if (profile == EEsProfile || version < 120)
+ if (isEsProfile() || version < 120)
function = findFunctionExact(loc, call, builtIn);
else if (version < 400)
function = findFunction120(loc, call, builtIn);
@@ -6299,11 +6310,13 @@
return bestMatch;
}
-// When a declaration includes a type, but not a variable name, it can be
+// When a declaration includes a type, but not a variable name, it can be used
// to establish defaults.
void TParseContext::declareTypeDefaults(const TSourceLoc& loc, const TPublicType& publicType)
{
- if (publicType.basicType == EbtAtomicUint && publicType.qualifier.hasBinding() && publicType.qualifier.hasOffset()) {
+#ifndef GLSLANG_WEB
+ if (publicType.basicType == EbtAtomicUint && publicType.qualifier.hasBinding() &&
+ publicType.qualifier.hasOffset()) {
if (publicType.qualifier.layoutBinding >= (unsigned int)resources.maxAtomicCounterBindings) {
error(loc, "atomic_uint binding is too large", "binding", "");
return;
@@ -6314,6 +6327,7 @@
if (publicType.qualifier.hasLayout() && !publicType.qualifier.hasBufferReference())
warn(loc, "useless application of layout qualifier", "layout", "");
+#endif
}
//
@@ -6510,7 +6524,7 @@
//
TStorageQualifier qualifier = variable->getType().getQualifier().storage;
if (! (qualifier == EvqTemporary || qualifier == EvqGlobal || qualifier == EvqConst ||
- (qualifier == EvqUniform && profile != EEsProfile && version >= 120))) {
+ (qualifier == EvqUniform && !isEsProfile() && version >= 120))) {
error(loc, " cannot initialize this type of qualifier ", variable->getType().getStorageQualifierString(), "");
return nullptr;
}
@@ -6582,7 +6596,7 @@
// qualifier any initializer must be a constant expression."
if (symbolTable.atGlobalLevel() && ! initializer->getType().getQualifier().isConstant()) {
const char* initFeature = "non-constant global initializer (needs GL_EXT_shader_non_constant_global_initializers)";
- if (profile == EEsProfile) {
+ if (isEsProfile()) {
if (relaxedErrors() && ! extensionTurnedOn(E_GL_EXT_shader_non_constant_global_initializers))
warn(loc, "not allowed in this version", initFeature, "");
else
@@ -7724,7 +7738,7 @@
bool pipeOut = qualifier.isPipeOutput();
bool pipeIn = qualifier.isPipeInput();
- if (version >= 300 || (profile != EEsProfile && version >= 420)) {
+ if (version >= 300 || (!isEsProfile() && version >= 420)) {
if (! pipeOut)
error(loc, "can only apply to an output", "invariant", "");
} else {
@@ -8080,7 +8094,7 @@
// "it is an error to have no statement between a label and the end of the switch statement."
// The specifications were updated to remove this (being ill-defined what a "statement" was),
// so, this became a warning. However, 3.0 tests still check for the error.
- if (profile == EEsProfile && version <= 300 && ! relaxedErrors())
+ if (isEsProfile() && version <= 300 && ! relaxedErrors())
error(loc, "last case/default label not followed by statements", "switch", "");
else
warn(loc, "last case/default label not followed by statements", "switch", "");
diff --git a/glslang/MachineIndependent/Scan.cpp b/glslang/MachineIndependent/Scan.cpp
index ae7f75c..ad0c12c 100644
--- a/glslang/MachineIndependent/Scan.cpp
+++ b/glslang/MachineIndependent/Scan.cpp
@@ -904,8 +904,8 @@
case SWITCH:
case DEFAULT:
- if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
- (parseContext.profile != EEsProfile && parseContext.version < 130))
+ if ((parseContext.isEsProfile() && parseContext.version < 300) ||
+ (!parseContext.isEsProfile() && parseContext.version < 130))
reservedWord();
return keyword;
@@ -938,14 +938,14 @@
return keyword;
case SMOOTH:
- if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
- (parseContext.profile != EEsProfile && parseContext.version < 130))
+ if ((parseContext.isEsProfile() && parseContext.version < 300) ||
+ (!parseContext.isEsProfile() && parseContext.version < 130))
return identifierOrType();
return keyword;
case FLAT:
- if (parseContext.profile == EEsProfile && parseContext.version < 300)
+ if (parseContext.isEsProfile() && parseContext.version < 300)
reservedWord();
- else if (parseContext.profile != EEsProfile && parseContext.version < 130)
+ else if (!parseContext.isEsProfile() && parseContext.version < 130)
return identifierOrType();
return keyword;
case CENTROID:
@@ -953,30 +953,30 @@
return identifierOrType();
return keyword;
case INVARIANT:
- if (parseContext.profile != EEsProfile && parseContext.version < 120)
+ if (!parseContext.isEsProfile() && parseContext.version < 120)
return identifierOrType();
return keyword;
case PACKED:
- if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
- (parseContext.profile != EEsProfile && parseContext.version < 330))
+ if ((parseContext.isEsProfile() && parseContext.version < 300) ||
+ (!parseContext.isEsProfile() && parseContext.version < 330))
return reservedWord();
return identifierOrType();
case RESOURCE:
{
- bool reserved = (parseContext.profile == EEsProfile && parseContext.version >= 300) ||
- (parseContext.profile != EEsProfile && parseContext.version >= 420);
+ bool reserved = (parseContext.isEsProfile() && parseContext.version >= 300) ||
+ (!parseContext.isEsProfile() && parseContext.version >= 420);
return identifierOrReserved(reserved);
}
case SUPERP:
{
- bool reserved = parseContext.profile == EEsProfile || parseContext.version >= 130;
+ bool reserved = parseContext.isEsProfile() || parseContext.version >= 130;
return identifierOrReserved(reserved);
}
#ifndef GLSLANG_WEB
case NOPERSPECTIVE:
- if (parseContext.profile == EEsProfile && parseContext.version >= 300 &&
+ if (parseContext.isEsProfile() && parseContext.version >= 300 &&
parseContext.extensionTurnedOn(E_GL_NV_shader_noperspective_interpolation))
return keyword;
return es30ReservedFromGLSL(130);
@@ -988,13 +988,13 @@
return identifierOrType();
case ATTRIBUTE:
case VARYING:
- if (parseContext.profile == EEsProfile && parseContext.version >= 300)
+ if (parseContext.isEsProfile() && parseContext.version >= 300)
reservedWord();
return keyword;
case BUFFER:
afterBuffer = true;
- if ((parseContext.profile == EEsProfile && parseContext.version < 310) ||
- (parseContext.profile != EEsProfile && parseContext.version < 430))
+ if ((parseContext.isEsProfile() && parseContext.version < 310) ||
+ (!parseContext.isEsProfile() && parseContext.version < 430))
return identifierOrType();
return keyword;
case PAYLOADNV:
@@ -1004,12 +1004,12 @@
case CALLDATAINNV:
case ACCSTRUCTNV:
if (parseContext.symbolTable.atBuiltInLevel() ||
- (parseContext.profile != EEsProfile && parseContext.version >= 460
+ (!parseContext.isEsProfile() && parseContext.version >= 460
&& parseContext.extensionTurnedOn(E_GL_NV_ray_tracing)))
return keyword;
return identifierOrType();
case ATOMIC_UINT:
- if ((parseContext.profile == EEsProfile && parseContext.version >= 310) ||
+ if ((parseContext.isEsProfile() && parseContext.version >= 310) ||
parseContext.extensionTurnedOn(E_GL_ARB_shader_atomic_counters))
return keyword;
return es30ReservedFromGLSL(420);
@@ -1023,28 +1023,28 @@
case RESTRICT:
case READONLY:
case WRITEONLY:
- if (parseContext.profile == EEsProfile && parseContext.version >= 310)
+ if (parseContext.isEsProfile() && parseContext.version >= 310)
return keyword;
return es30ReservedFromGLSL(parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store) ? 130 : 420);
case VOLATILE:
- if (parseContext.profile == EEsProfile && parseContext.version >= 310)
+ if (parseContext.isEsProfile() && parseContext.version >= 310)
return keyword;
- if (! parseContext.symbolTable.atBuiltInLevel() && (parseContext.profile == EEsProfile ||
+ if (! parseContext.symbolTable.atBuiltInLevel() && (parseContext.isEsProfile() ||
(parseContext.version < 420 && ! parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))))
reservedWord();
return keyword;
case PATCH:
if (parseContext.symbolTable.atBuiltInLevel() ||
- (parseContext.profile == EEsProfile &&
+ (parseContext.isEsProfile() &&
(parseContext.version >= 320 ||
parseContext.extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader))) ||
- (parseContext.profile != EEsProfile && parseContext.extensionTurnedOn(E_GL_ARB_tessellation_shader)))
+ (!parseContext.isEsProfile() && parseContext.extensionTurnedOn(E_GL_ARB_tessellation_shader)))
return keyword;
return es30ReservedFromGLSL(400);
case SAMPLE:
- if ((parseContext.profile == EEsProfile && parseContext.version >= 320) ||
+ if ((parseContext.isEsProfile() && parseContext.version >= 320) ||
parseContext.extensionsTurnedOn(1, &E_GL_OES_shader_multisample_interpolation))
return keyword;
return es30ReservedFromGLSL(400);
@@ -1058,15 +1058,15 @@
const int numLayoutExts = 2;
const char* layoutExts[numLayoutExts] = { E_GL_ARB_shading_language_420pack,
E_GL_ARB_explicit_attrib_location };
- if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
- (parseContext.profile != EEsProfile && parseContext.version < 140 &&
+ if ((parseContext.isEsProfile() && parseContext.version < 300) ||
+ (!parseContext.isEsProfile() && parseContext.version < 140 &&
! parseContext.extensionsTurnedOn(numLayoutExts, layoutExts)))
return identifierOrType();
return keyword;
}
case SHARED:
- if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
- (parseContext.profile != EEsProfile && parseContext.version < 140))
+ if ((parseContext.isEsProfile() && parseContext.version < 300) ||
+ (!parseContext.isEsProfile() && parseContext.version < 140))
return identifierOrType();
return keyword;
@@ -1118,7 +1118,7 @@
case IIMAGEBUFFER:
case UIMAGEBUFFER:
afterType = true;
- if ((parseContext.profile == EEsProfile && parseContext.version >= 320) ||
+ if ((parseContext.isEsProfile() && parseContext.version >= 320) ||
parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer))
return keyword;
return firstGenerationImage(false);
@@ -1142,7 +1142,7 @@
case IIMAGECUBEARRAY:
case UIMAGECUBEARRAY:
afterType = true;
- if ((parseContext.profile == EEsProfile && parseContext.version >= 320) ||
+ if ((parseContext.isEsProfile() && parseContext.version >= 320) ||
parseContext.extensionsTurnedOn(Num_AEP_texture_cube_map_array, AEP_texture_cube_map_array))
return keyword;
return secondGenerationImage();
@@ -1161,7 +1161,7 @@
case DVEC3:
case DVEC4:
afterType = true;
- if (parseContext.profile == EEsProfile || parseContext.version < 400)
+ if (parseContext.isEsProfile() || parseContext.version < 400)
reservedWord();
return keyword;
@@ -1175,7 +1175,7 @@
case U64VEC4:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
- (parseContext.profile != EEsProfile && parseContext.version >= 450 &&
+ (!parseContext.isEsProfile() && parseContext.version >= 450 &&
(parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_int64))))
@@ -1195,7 +1195,7 @@
((parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_8bit_storage) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_int8)) &&
- parseContext.profile != EEsProfile && parseContext.version >= 450))
+ !parseContext.isEsProfile() && parseContext.version >= 450))
return keyword;
return identifierOrType();
@@ -1209,7 +1209,7 @@
case U16VEC4:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
- (parseContext.profile != EEsProfile && parseContext.version >= 450 &&
+ (!parseContext.isEsProfile() && parseContext.version >= 450 &&
(parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_int16) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_16bit_storage) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
@@ -1228,7 +1228,7 @@
if (parseContext.symbolTable.atBuiltInLevel() ||
((parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_int32)) &&
- parseContext.profile != EEsProfile && parseContext.version >= 450))
+ !parseContext.isEsProfile() && parseContext.version >= 450))
return keyword;
return identifierOrType();
case FLOAT32_T:
@@ -1251,7 +1251,7 @@
if (parseContext.symbolTable.atBuiltInLevel() ||
((parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float32)) &&
- parseContext.profile != EEsProfile && parseContext.version >= 450))
+ !parseContext.isEsProfile() && parseContext.version >= 450))
return keyword;
return identifierOrType();
@@ -1275,7 +1275,7 @@
if (parseContext.symbolTable.atBuiltInLevel() ||
((parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float64)) &&
- parseContext.profile != EEsProfile && parseContext.version >= 450))
+ !parseContext.isEsProfile() && parseContext.version >= 450))
return keyword;
return identifierOrType();
@@ -1285,7 +1285,7 @@
case F16VEC4:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
- (parseContext.profile != EEsProfile && parseContext.version >= 450 &&
+ (!parseContext.isEsProfile() && parseContext.version >= 450 &&
(parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_16bit_storage) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
@@ -1308,7 +1308,7 @@
case F16MAT4X4:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
- (parseContext.profile != EEsProfile && parseContext.version >= 450 &&
+ (!parseContext.isEsProfile() && parseContext.version >= 450 &&
(parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float16))))
@@ -1322,10 +1322,10 @@
case ISAMPLERCUBEARRAY:
case USAMPLERCUBEARRAY:
afterType = true;
- if ((parseContext.profile == EEsProfile && parseContext.version >= 320) ||
+ if ((parseContext.isEsProfile() && parseContext.version >= 320) ||
parseContext.extensionsTurnedOn(Num_AEP_texture_cube_map_array, AEP_texture_cube_map_array))
return keyword;
- if (parseContext.profile == EEsProfile || (parseContext.version < 400 && ! parseContext.extensionTurnedOn(E_GL_ARB_texture_cube_map_array)))
+ if (parseContext.isEsProfile() || (parseContext.version < 400 && ! parseContext.extensionTurnedOn(E_GL_ARB_texture_cube_map_array)))
reservedWord();
return keyword;
@@ -1349,7 +1349,7 @@
case SAMPLER3D:
afterType = true;
- if (parseContext.profile == EEsProfile && parseContext.version < 300) {
+ if (parseContext.isEsProfile() && parseContext.version < 300) {
if (!parseContext.extensionTurnedOn(E_GL_OES_texture_3D))
reservedWord();
}
@@ -1357,7 +1357,7 @@
case SAMPLER2DSHADOW:
afterType = true;
- if (parseContext.profile == EEsProfile && parseContext.version < 300) {
+ if (parseContext.isEsProfile() && parseContext.version < 300) {
if (!parseContext.extensionTurnedOn(E_GL_EXT_shadow_samplers))
reservedWord();
}
@@ -1378,7 +1378,7 @@
case SAMPLERBUFFER:
afterType = true;
- if ((parseContext.profile == EEsProfile && parseContext.version >= 320) ||
+ if ((parseContext.isEsProfile() && parseContext.version >= 320) ||
parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer))
return keyword;
return es30ReservedFromGLSL(130);
@@ -1386,7 +1386,7 @@
case ISAMPLERBUFFER:
case USAMPLERBUFFER:
afterType = true;
- if ((parseContext.profile == EEsProfile && parseContext.version >= 320) ||
+ if ((parseContext.isEsProfile() && parseContext.version >= 320) ||
parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer))
return keyword;
return es30ReservedFromGLSL(140);
@@ -1395,7 +1395,7 @@
case ISAMPLER2DMS:
case USAMPLER2DMS:
afterType = true;
- if (parseContext.profile == EEsProfile && parseContext.version >= 310)
+ if (parseContext.isEsProfile() && parseContext.version >= 310)
return keyword;
return es30ReservedFromGLSL(150);
@@ -1403,7 +1403,7 @@
case ISAMPLER2DMSARRAY:
case USAMPLER2DMSARRAY:
afterType = true;
- if ((parseContext.profile == EEsProfile && parseContext.version >= 320) ||
+ if ((parseContext.isEsProfile() && parseContext.version >= 320) ||
parseContext.extensionsTurnedOn(1, &E_GL_OES_texture_storage_multisample_2d_array))
return keyword;
return es30ReservedFromGLSL(150);
@@ -1411,14 +1411,14 @@
case SAMPLER1D:
case SAMPLER1DSHADOW:
afterType = true;
- if (parseContext.profile == EEsProfile)
+ if (parseContext.isEsProfile())
reservedWord();
return keyword;
case SAMPLER2DRECT:
case SAMPLER2DRECTSHADOW:
afterType = true;
- if (parseContext.profile == EEsProfile)
+ if (parseContext.isEsProfile())
reservedWord();
else if (parseContext.version < 140 && ! parseContext.symbolTable.atBuiltInLevel() && ! parseContext.extensionTurnedOn(E_GL_ARB_texture_rectangle)) {
if (parseContext.relaxedErrors())
@@ -1430,10 +1430,10 @@
case SAMPLER1DARRAY:
afterType = true;
- if (parseContext.profile == EEsProfile && parseContext.version == 300)
+ if (parseContext.isEsProfile() && parseContext.version == 300)
reservedWord();
- else if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
- (parseContext.profile != EEsProfile && parseContext.version < 130))
+ else if ((parseContext.isEsProfile() && parseContext.version < 300) ||
+ (!parseContext.isEsProfile() && parseContext.version < 130))
return identifierOrType();
return keyword;
@@ -1551,29 +1551,29 @@
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float_fetch) &&
- parseContext.profile != EEsProfile && parseContext.version >= 450))
+ !parseContext.isEsProfile() && parseContext.version >= 450))
return keyword;
return identifierOrType();
case EXPLICITINTERPAMD:
- if (parseContext.profile != EEsProfile && parseContext.version >= 450 &&
+ if (!parseContext.isEsProfile() && parseContext.version >= 450 &&
parseContext.extensionTurnedOn(E_GL_AMD_shader_explicit_vertex_parameter))
return keyword;
return identifierOrType();
case PERVERTEXNV:
- if (((parseContext.profile != EEsProfile && parseContext.version >= 450) ||
- (parseContext.profile == EEsProfile && parseContext.version >= 320)) &&
+ if (((!parseContext.isEsProfile() && parseContext.version >= 450) ||
+ (parseContext.isEsProfile() && parseContext.version >= 320)) &&
parseContext.extensionTurnedOn(E_GL_NV_fragment_shader_barycentric))
return keyword;
return identifierOrType();
case PRECISE:
- if ((parseContext.profile == EEsProfile &&
+ if ((parseContext.isEsProfile() &&
(parseContext.version >= 320 || parseContext.extensionsTurnedOn(Num_AEP_gpu_shader5, AEP_gpu_shader5))) ||
- (parseContext.profile != EEsProfile && parseContext.version >= 400))
+ (!parseContext.isEsProfile() && parseContext.version >= 400))
return keyword;
- if (parseContext.profile == EEsProfile && parseContext.version == 310) {
+ if (parseContext.isEsProfile() && parseContext.version == 310) {
reservedWord();
return keyword;
}
@@ -1582,8 +1582,8 @@
case PERPRIMITIVENV:
case PERVIEWNV:
case PERTASKNV:
- if ((parseContext.profile != EEsProfile && parseContext.version >= 450) ||
- (parseContext.profile == EEsProfile && parseContext.version >= 320) ||
+ if ((!parseContext.isEsProfile() && parseContext.version >= 450) ||
+ (parseContext.isEsProfile() && parseContext.version >= 320) ||
parseContext.extensionTurnedOn(E_GL_NV_mesh_shader))
return keyword;
return identifierOrType();
@@ -1662,13 +1662,13 @@
if (parseContext.symbolTable.atBuiltInLevel())
return keyword;
- if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
- (parseContext.profile != EEsProfile && parseContext.version < version)) {
+ if ((parseContext.isEsProfile() && parseContext.version < 300) ||
+ (!parseContext.isEsProfile() && parseContext.version < version)) {
if (parseContext.forwardCompatible)
parseContext.warn(loc, "future reserved word in ES 300 and keyword in GLSL", tokenText, "");
return identifierOrType();
- } else if (parseContext.profile == EEsProfile && parseContext.version >= 300)
+ } else if (parseContext.isEsProfile() && parseContext.version >= 300)
reservedWord();
return keyword;
@@ -1678,8 +1678,8 @@
// showed up, both in an es version and a non-ES version.
int TScanContext::nonreservedKeyword(int esVersion, int nonEsVersion)
{
- if ((parseContext.profile == EEsProfile && parseContext.version < esVersion) ||
- (parseContext.profile != EEsProfile && parseContext.version < nonEsVersion)) {
+ if ((parseContext.isEsProfile() && parseContext.version < esVersion) ||
+ (!parseContext.isEsProfile() && parseContext.version < nonEsVersion)) {
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future keyword", tokenText, "");
@@ -1691,7 +1691,7 @@
int TScanContext::precisionKeyword()
{
- if (parseContext.profile == EEsProfile || parseContext.version >= 130)
+ if (parseContext.isEsProfile() || parseContext.version >= 130)
return keyword;
if (parseContext.forwardCompatible)
@@ -1717,13 +1717,13 @@
{
afterType = true;
- if (parseContext.profile == EEsProfile && parseContext.version >= 300) {
+ if (parseContext.isEsProfile() && parseContext.version >= 300) {
reservedWord();
return keyword;
}
- if (parseContext.profile != EEsProfile && parseContext.version >= 400)
+ if (!parseContext.isEsProfile() && parseContext.version >= 400)
return keyword;
if (parseContext.forwardCompatible)
@@ -1735,13 +1735,13 @@
int TScanContext::firstGenerationImage(bool inEs310)
{
if (parseContext.symbolTable.atBuiltInLevel() ||
- (parseContext.profile != EEsProfile && (parseContext.version >= 420 ||
+ (!parseContext.isEsProfile() && (parseContext.version >= 420 ||
parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) ||
- (inEs310 && parseContext.profile == EEsProfile && parseContext.version >= 310))
+ (inEs310 && parseContext.isEsProfile() && parseContext.version >= 310))
return keyword;
- if ((parseContext.profile == EEsProfile && parseContext.version >= 300) ||
- (parseContext.profile != EEsProfile && parseContext.version >= 130)) {
+ if ((parseContext.isEsProfile() && parseContext.version >= 300) ||
+ (!parseContext.isEsProfile() && parseContext.version >= 130)) {
reservedWord();
return keyword;
@@ -1755,13 +1755,13 @@
int TScanContext::secondGenerationImage()
{
- if (parseContext.profile == EEsProfile && parseContext.version >= 310) {
+ if (parseContext.isEsProfile() && parseContext.version >= 310) {
reservedWord();
return keyword;
}
if (parseContext.symbolTable.atBuiltInLevel() ||
- (parseContext.profile != EEsProfile &&
+ (!parseContext.isEsProfile() &&
(parseContext.version >= 420 || parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))))
return keyword;
diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp
index b01cbe3..bced5d7 100755
--- a/glslang/MachineIndependent/ShaderLang.cpp
+++ b/glslang/MachineIndependent/ShaderLang.cpp
@@ -377,8 +377,6 @@
infoSink, commonTable, symbolTables);
#endif
-
-
return true;
}
diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp
index 05ace4d..e9c4c4d 100644
--- a/glslang/MachineIndependent/Versions.cpp
+++ b/glslang/MachineIndependent/Versions.cpp
@@ -306,7 +306,7 @@
// or needed by the preprocessor (which does not use a shared symbol table).
void TParseVersions::getPreamble(std::string& preamble)
{
- if (profile == EEsProfile) {
+ if (isEsProfile()) {
preamble =
"#define GL_ES 1\n"
"#define GL_FRAGMENT_PRECISION_HIGH 1\n"
@@ -352,7 +352,7 @@
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
;
- if (profile == EEsProfile && version >= 300) {
+ if (isEsProfile() && version >= 300) {
preamble += "#define GL_NV_shader_noperspective_interpolation 1\n";
}
@@ -458,8 +458,8 @@
}
#ifndef GLSLANG_WEB
- if ((profile != EEsProfile && version >= 140) ||
- (profile == EEsProfile && version >= 310)) {
+ if ((!isEsProfile() && version >= 140) ||
+ (isEsProfile() && version >= 310)) {
preamble +=
"#define GL_EXT_device_group 1\n"
"#define GL_EXT_multiview 1\n"
diff --git a/glslang/MachineIndependent/glslang.m4 b/glslang/MachineIndependent/glslang.m4
index 1bc12d2..d1ad04d 100644
--- a/glslang/MachineIndependent/glslang.m4
+++ b/glslang/MachineIndependent/glslang.m4
@@ -3265,7 +3265,7 @@
if ($1.arraySizes) {
parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
- if (parseContext.profile == EEsProfile)
+ if (parseContext.isEsProfile())
parseContext.arraySizeRequiredCheck($1.loc, *$1.arraySizes);
}
@@ -3287,7 +3287,7 @@
if ($2.arraySizes) {
parseContext.profileRequires($2.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type");
- if (parseContext.profile == EEsProfile)
+ if (parseContext.isEsProfile())
parseContext.arraySizeRequiredCheck($2.loc, *$2.arraySizes);
}
diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y
index bc32ade..4055dcc 100644
--- a/glslang/MachineIndependent/glslang.y
+++ b/glslang/MachineIndependent/glslang.y
@@ -3265,7 +3265,7 @@
if ($1.arraySizes) {
parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
- if (parseContext.profile == EEsProfile)
+ if (parseContext.isEsProfile())
parseContext.arraySizeRequiredCheck($1.loc, *$1.arraySizes);
}
@@ -3287,7 +3287,7 @@
if ($2.arraySizes) {
parseContext.profileRequires($2.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type");
- if (parseContext.profile == EEsProfile)
+ if (parseContext.isEsProfile())
parseContext.arraySizeRequiredCheck($2.loc, *$2.arraySizes);
}
diff --git a/glslang/MachineIndependent/glslang_tab.cpp b/glslang/MachineIndependent/glslang_tab.cpp
index 499b20f..3889132 100644
--- a/glslang/MachineIndependent/glslang_tab.cpp
+++ b/glslang/MachineIndependent/glslang_tab.cpp
@@ -9319,7 +9319,7 @@
if ((yyvsp[-2].interm.type).arraySizes) {
parseContext.profileRequires((yyvsp[-2].interm.type).loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
parseContext.profileRequires((yyvsp[-2].interm.type).loc, EEsProfile, 300, 0, "arrayed type");
- if (parseContext.profile == EEsProfile)
+ if (parseContext.isEsProfile())
parseContext.arraySizeRequiredCheck((yyvsp[-2].interm.type).loc, *(yyvsp[-2].interm.type).arraySizes);
}
@@ -9346,7 +9346,7 @@
if ((yyvsp[-2].interm.type).arraySizes) {
parseContext.profileRequires((yyvsp[-2].interm.type).loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
parseContext.profileRequires((yyvsp[-2].interm.type).loc, EEsProfile, 300, 0, "arrayed type");
- if (parseContext.profile == EEsProfile)
+ if (parseContext.isEsProfile())
parseContext.arraySizeRequiredCheck((yyvsp[-2].interm.type).loc, *(yyvsp[-2].interm.type).arraySizes);
}
diff --git a/glslang/MachineIndependent/linkValidate.cpp b/glslang/MachineIndependent/linkValidate.cpp
index 1293923..b5b3cdb 100644
--- a/glslang/MachineIndependent/linkValidate.cpp
+++ b/glslang/MachineIndependent/linkValidate.cpp
@@ -120,7 +120,7 @@
version = unit.version;
requestedExtensions = unit.requestedExtensions;
} else {
- if ((profile == EEsProfile) != (unit.profile == EEsProfile))
+ if ((isEsProfile()) != (unit.isEsProfile()))
error(infoSink, "Cannot cross link ES and desktop profiles");
else if (unit.profile == ECompatibilityProfile)
profile = ECompatibilityProfile;
@@ -952,7 +952,7 @@
}
}
- if (profile == EEsProfile) {
+ if (isEsProfile()) {
if (numFragOut > 1 && fragOutWithNoLocation)
error(infoSink, "when more than one fragment shader output, all must have location qualifiers");
}
@@ -1091,7 +1091,7 @@
TIoRange range(locationRange, componentRange, type.getBasicType(), qualifier.hasIndex() ? qualifier.layoutIndex : 0);
// check for collisions, except for vertex inputs on desktop targeting OpenGL
- if (! (profile != EEsProfile && language == EShLangVertex && qualifier.isPipeInput()) || spvVersion.vulkan > 0)
+ if (! (!isEsProfile() && language == EShLangVertex && qualifier.isPipeInput()) || spvVersion.vulkan > 0)
collision = checkLocationRange(set, range, type, typeCollision);
if (collision < 0)
diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h
index 2dcacff..affab4b 100644
--- a/glslang/MachineIndependent/localintermediate.h
+++ b/glslang/MachineIndependent/localintermediate.h
@@ -460,6 +460,7 @@
#ifdef GLSLANG_WEB
void output(TInfoSink&, bool tree) { }
+ bool isEsProfile() const { return false; }
bool getXfbMode() const { return false; }
bool isMultiStream() const { return false; }
TLayoutGeometry getOutputPrimitive() const { return ElgNone; }
@@ -483,6 +484,8 @@
#else
void output(TInfoSink&, bool tree);
+ bool isEsProfile() const { return profile == EEsProfile; }
+
void setShiftBinding(TResourceType res, unsigned int shift)
{
shiftBinding[res] = shift;
diff --git a/glslang/MachineIndependent/parseVersions.h b/glslang/MachineIndependent/parseVersions.h
index 8c96434..bd46c6d 100755
--- a/glslang/MachineIndependent/parseVersions.h
+++ b/glslang/MachineIndependent/parseVersions.h
@@ -67,6 +67,7 @@
virtual void requireStage(const TSourceLoc&, EShLanguageMask, const char* featureDesc);
virtual void requireStage(const TSourceLoc&, EShLanguage, const char* featureDesc);
#ifdef GLSLANG_WEB
+ bool isEsProfile() const { return true; }
virtual void initializeExtensionBehavior() { }
virtual void checkDeprecated(const TSourceLoc&, int queryProfiles, int depVersion, const char* featureDesc) { }
virtual void requireNotRemoved(const TSourceLoc&, int queryProfiles, int removedVersion, const char* featureDesc) { }
@@ -92,6 +93,7 @@
virtual void explicitFloat32Check(const TSourceLoc&, const char* op, bool builtIn = false) { }
virtual void explicitFloat64Check(const TSourceLoc&, const char* op, bool builtIn = false) { }
#else
+ bool isEsProfile() const { return profile == EEsProfile; }
virtual void initializeExtensionBehavior();
virtual void checkDeprecated(const TSourceLoc&, int queryProfiles, int depVersion, const char* featureDesc);
virtual void requireNotRemoved(const TSourceLoc&, int queryProfiles, int removedVersion, const char* featureDesc);
diff --git a/glslang/MachineIndependent/preprocessor/Pp.cpp b/glslang/MachineIndependent/preprocessor/Pp.cpp
index 68ccfdf..fc23c04 100755
--- a/glslang/MachineIndependent/preprocessor/Pp.cpp
+++ b/glslang/MachineIndependent/preprocessor/Pp.cpp
@@ -545,7 +545,7 @@
case MacroExpandStarted:
break;
case MacroExpandUndef:
- if (! shortCircuit && parseContext.profile == EEsProfile) {
+ if (! shortCircuit && parseContext.isEsProfile()) {
const char* message = "undefined macro in expression not allowed in es profile";
if (parseContext.relaxedErrors())
parseContext.ppWarn(ppToken->loc, message, "preprocessor evaluation", ppToken->name);