summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp')
-rw-r--r--src/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp469
1 files changed, 232 insertions, 237 deletions
diff --git a/src/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp b/src/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp
index 482f6ba..9a9b69c 100644
--- a/src/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp
+++ b/src/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp
@@ -324,7 +324,9 @@ struct str_hash
// A single global usable by all threads, by all versions, by all languages.
// After a single process-level initialization, this is read only and thread safe
std::unordered_map<const char*, int, str_hash, str_eq>* KeywordMap = nullptr;
+#ifndef GLSLANG_WEB
std::unordered_set<const char*, str_hash, str_eq>* ReservedSet = nullptr;
+#endif
};
@@ -341,9 +343,14 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["const"] = CONST;
(*KeywordMap)["uniform"] = UNIFORM;
- (*KeywordMap)["nonuniformEXT"] = NONUNIFORM;
(*KeywordMap)["in"] = IN;
(*KeywordMap)["out"] = OUT;
+ (*KeywordMap)["smooth"] = SMOOTH;
+ (*KeywordMap)["flat"] = FLAT;
+ (*KeywordMap)["centroid"] = CENTROID;
+ (*KeywordMap)["invariant"] = INVARIANT;
+ (*KeywordMap)["packed"] = PACKED;
+ (*KeywordMap)["resource"] = RESOURCE;
(*KeywordMap)["inout"] = INOUT;
(*KeywordMap)["struct"] = STRUCT;
(*KeywordMap)["break"] = BREAK;
@@ -376,8 +383,33 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["mat4"] = MAT4;
(*KeywordMap)["true"] = BOOLCONSTANT;
(*KeywordMap)["false"] = BOOLCONSTANT;
+ (*KeywordMap)["layout"] = LAYOUT;
+ (*KeywordMap)["shared"] = SHARED;
+ (*KeywordMap)["highp"] = HIGH_PRECISION;
+ (*KeywordMap)["mediump"] = MEDIUM_PRECISION;
+ (*KeywordMap)["lowp"] = LOW_PRECISION;
+ (*KeywordMap)["superp"] = SUPERP;
+ (*KeywordMap)["precision"] = PRECISION;
+ (*KeywordMap)["mat2x2"] = MAT2X2;
+ (*KeywordMap)["mat2x3"] = MAT2X3;
+ (*KeywordMap)["mat2x4"] = MAT2X4;
+ (*KeywordMap)["mat3x2"] = MAT3X2;
+ (*KeywordMap)["mat3x3"] = MAT3X3;
+ (*KeywordMap)["mat3x4"] = MAT3X4;
+ (*KeywordMap)["mat4x2"] = MAT4X2;
+ (*KeywordMap)["mat4x3"] = MAT4X3;
+ (*KeywordMap)["mat4x4"] = MAT4X4;
+ (*KeywordMap)["uint"] = UINT;
+ (*KeywordMap)["uvec2"] = UVEC2;
+ (*KeywordMap)["uvec3"] = UVEC3;
+ (*KeywordMap)["uvec4"] = UVEC4;
+
+#ifndef GLSLANG_WEB
+ (*KeywordMap)["nonuniformEXT"] = NONUNIFORM;
+ (*KeywordMap)["demote"] = DEMOTE;
(*KeywordMap)["attribute"] = ATTRIBUTE;
(*KeywordMap)["varying"] = VARYING;
+ (*KeywordMap)["noperspective"] = NOPERSPECTIVE;
(*KeywordMap)["buffer"] = BUFFER;
(*KeywordMap)["coherent"] = COHERENT;
(*KeywordMap)["devicecoherent"] = DEVICECOHERENT;
@@ -390,24 +422,9 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["writeonly"] = WRITEONLY;
(*KeywordMap)["atomic_uint"] = ATOMIC_UINT;
(*KeywordMap)["volatile"] = VOLATILE;
- (*KeywordMap)["layout"] = LAYOUT;
- (*KeywordMap)["shared"] = SHARED;
(*KeywordMap)["patch"] = PATCH;
(*KeywordMap)["sample"] = SAMPLE;
(*KeywordMap)["subroutine"] = SUBROUTINE;
- (*KeywordMap)["highp"] = HIGH_PRECISION;
- (*KeywordMap)["mediump"] = MEDIUM_PRECISION;
- (*KeywordMap)["lowp"] = LOW_PRECISION;
- (*KeywordMap)["precision"] = PRECISION;
- (*KeywordMap)["mat2x2"] = MAT2X2;
- (*KeywordMap)["mat2x3"] = MAT2X3;
- (*KeywordMap)["mat2x4"] = MAT2X4;
- (*KeywordMap)["mat3x2"] = MAT3X2;
- (*KeywordMap)["mat3x3"] = MAT3X3;
- (*KeywordMap)["mat3x4"] = MAT3X4;
- (*KeywordMap)["mat4x2"] = MAT4X2;
- (*KeywordMap)["mat4x3"] = MAT4X3;
- (*KeywordMap)["mat4x4"] = MAT4X4;
(*KeywordMap)["dmat2"] = DMAT2;
(*KeywordMap)["dmat3"] = DMAT3;
(*KeywordMap)["dmat4"] = DMAT4;
@@ -457,11 +474,6 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["dvec2"] = DVEC2;
(*KeywordMap)["dvec3"] = DVEC3;
(*KeywordMap)["dvec4"] = DVEC4;
- (*KeywordMap)["uint"] = UINT;
- (*KeywordMap)["uvec2"] = UVEC2;
- (*KeywordMap)["uvec3"] = UVEC3;
- (*KeywordMap)["uvec4"] = UVEC4;
-
(*KeywordMap)["int64_t"] = INT64_T;
(*KeywordMap)["uint64_t"] = UINT64_T;
(*KeywordMap)["i64vec2"] = I64VEC2;
@@ -548,6 +560,7 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["f64mat4x2"] = F64MAT4X2;
(*KeywordMap)["f64mat4x3"] = F64MAT4X3;
(*KeywordMap)["f64mat4x4"] = F64MAT4X4;
+#endif
(*KeywordMap)["sampler2D"] = SAMPLER2D;
(*KeywordMap)["samplerCube"] = SAMPLERCUBE;
@@ -555,12 +568,6 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["samplerCubeArrayShadow"] = SAMPLERCUBEARRAYSHADOW;
(*KeywordMap)["isamplerCubeArray"] = ISAMPLERCUBEARRAY;
(*KeywordMap)["usamplerCubeArray"] = USAMPLERCUBEARRAY;
- (*KeywordMap)["sampler1DArrayShadow"] = SAMPLER1DARRAYSHADOW;
- (*KeywordMap)["isampler1DArray"] = ISAMPLER1DARRAY;
- (*KeywordMap)["usampler1D"] = USAMPLER1D;
- (*KeywordMap)["isampler1D"] = ISAMPLER1D;
- (*KeywordMap)["usampler1DArray"] = USAMPLER1DARRAY;
- (*KeywordMap)["samplerBuffer"] = SAMPLERBUFFER;
(*KeywordMap)["samplerCubeShadow"] = SAMPLERCUBESHADOW;
(*KeywordMap)["sampler2DArray"] = SAMPLER2DARRAY;
(*KeywordMap)["sampler2DArrayShadow"] = SAMPLER2DARRAYSHADOW;
@@ -572,6 +579,16 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["usampler3D"] = USAMPLER3D;
(*KeywordMap)["usamplerCube"] = USAMPLERCUBE;
(*KeywordMap)["usampler2DArray"] = USAMPLER2DARRAY;
+ (*KeywordMap)["sampler3D"] = SAMPLER3D;
+ (*KeywordMap)["sampler2DShadow"] = SAMPLER2DSHADOW;
+
+#ifndef GLSLANG_WEB
+ (*KeywordMap)["sampler1DArrayShadow"] = SAMPLER1DARRAYSHADOW;
+ (*KeywordMap)["isampler1DArray"] = ISAMPLER1DARRAY;
+ (*KeywordMap)["usampler1D"] = USAMPLER1D;
+ (*KeywordMap)["isampler1D"] = ISAMPLER1D;
+ (*KeywordMap)["usampler1DArray"] = USAMPLER1DARRAY;
+ (*KeywordMap)["samplerBuffer"] = SAMPLERBUFFER;
(*KeywordMap)["isampler2DRect"] = ISAMPLER2DRECT;
(*KeywordMap)["usampler2DRect"] = USAMPLER2DRECT;
(*KeywordMap)["isamplerBuffer"] = ISAMPLERBUFFER;
@@ -584,8 +601,6 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["usampler2DMSArray"] = USAMPLER2DMSARRAY;
(*KeywordMap)["sampler1D"] = SAMPLER1D;
(*KeywordMap)["sampler1DShadow"] = SAMPLER1DSHADOW;
- (*KeywordMap)["sampler3D"] = SAMPLER3D;
- (*KeywordMap)["sampler2DShadow"] = SAMPLER2DSHADOW;
(*KeywordMap)["sampler2DRect"] = SAMPLER2DRECT;
(*KeywordMap)["sampler2DRectShadow"] = SAMPLER2DRECTSHADOW;
(*KeywordMap)["sampler1DArray"] = SAMPLER1DARRAY;
@@ -638,7 +653,6 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["usubpassInput"] = USUBPASSINPUT;
(*KeywordMap)["usubpassInputMS"] = USUBPASSINPUTMS;
-#ifdef AMD_EXTENSIONS
(*KeywordMap)["f16sampler1D"] = F16SAMPLER1D;
(*KeywordMap)["f16sampler2D"] = F16SAMPLER2D;
(*KeywordMap)["f16sampler3D"] = F16SAMPLER3D;
@@ -684,25 +698,10 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["f16subpassInput"] = F16SUBPASSINPUT;
(*KeywordMap)["f16subpassInputMS"] = F16SUBPASSINPUTMS;
-#endif
-
- (*KeywordMap)["noperspective"] = NOPERSPECTIVE;
- (*KeywordMap)["smooth"] = SMOOTH;
- (*KeywordMap)["flat"] = FLAT;
-#ifdef AMD_EXTENSIONS
(*KeywordMap)["__explicitInterpAMD"] = EXPLICITINTERPAMD;
-#endif
- (*KeywordMap)["centroid"] = CENTROID;
-#ifdef NV_EXTENSIONS
(*KeywordMap)["pervertexNV"] = PERVERTEXNV;
-#endif
(*KeywordMap)["precise"] = PRECISE;
- (*KeywordMap)["invariant"] = INVARIANT;
- (*KeywordMap)["packed"] = PACKED;
- (*KeywordMap)["resource"] = RESOURCE;
- (*KeywordMap)["superp"] = SUPERP;
-#ifdef NV_EXTENSIONS
(*KeywordMap)["rayPayloadNV"] = PAYLOADNV;
(*KeywordMap)["rayPayloadInNV"] = PAYLOADINNV;
(*KeywordMap)["hitAttributeNV"] = HITATTRNV;
@@ -712,9 +711,10 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["perprimitiveNV"] = PERPRIMITIVENV;
(*KeywordMap)["perviewNV"] = PERVIEWNV;
(*KeywordMap)["taskNV"] = PERTASKNV;
-#endif
(*KeywordMap)["fcoopmatNV"] = FCOOPMATNV;
+ (*KeywordMap)["icoopmatNV"] = ICOOPMATNV;
+ (*KeywordMap)["ucoopmatNV"] = UCOOPMATNV;
ReservedSet = new std::unordered_set<const char*, str_hash, str_eq>;
@@ -755,14 +755,17 @@ void TScanContext::fillInKeywordMap()
ReservedSet->insert("cast");
ReservedSet->insert("namespace");
ReservedSet->insert("using");
+#endif
}
void TScanContext::deleteKeywordMap()
{
delete KeywordMap;
KeywordMap = nullptr;
+#ifndef GLSLANG_WEB
delete ReservedSet;
ReservedSet = nullptr;
+#endif
}
// Called by yylex to get the next token.
@@ -841,13 +844,15 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
case PpAtomConstInt: parserToken->sType.lex.i = ppToken.ival; return INTCONSTANT;
case PpAtomConstUint: parserToken->sType.lex.i = ppToken.ival; return UINTCONSTANT;
+ case PpAtomConstFloat: parserToken->sType.lex.d = ppToken.dval; return FLOATCONSTANT;
+#ifndef GLSLANG_WEB
case PpAtomConstInt16: parserToken->sType.lex.i = ppToken.ival; return INT16CONSTANT;
case PpAtomConstUint16: parserToken->sType.lex.i = ppToken.ival; return UINT16CONSTANT;
case PpAtomConstInt64: parserToken->sType.lex.i64 = ppToken.i64val; return INT64CONSTANT;
case PpAtomConstUint64: parserToken->sType.lex.i64 = ppToken.i64val; return UINT64CONSTANT;
- case PpAtomConstFloat: parserToken->sType.lex.d = ppToken.dval; return FLOATCONSTANT;
case PpAtomConstDouble: parserToken->sType.lex.d = ppToken.dval; return DOUBLECONSTANT;
case PpAtomConstFloat16: parserToken->sType.lex.d = ppToken.dval; return FLOAT16CONSTANT;
+#endif
case PpAtomIdentifier:
{
int token = tokenizeIdentifier();
@@ -869,8 +874,10 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
int TScanContext::tokenizeIdentifier()
{
+#ifndef GLSLANG_WEB
if (ReservedSet->find(tokenText) != ReservedSet->end())
return reservedWord();
+#endif
auto it = KeywordMap->find(tokenText);
if (it == KeywordMap->end()) {
@@ -901,16 +908,10 @@ int TScanContext::tokenizeIdentifier()
afterStruct = true;
return keyword;
- case NONUNIFORM:
- if (parseContext.extensionTurnedOn(E_GL_EXT_nonuniform_qualifier))
- return keyword;
- else
- return identifierOrType();
-
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;
@@ -942,20 +943,66 @@ int TScanContext::tokenizeIdentifier()
parserToken->sType.lex.b = false;
return keyword;
+ case SMOOTH:
+ if ((parseContext.isEsProfile() && parseContext.version < 300) ||
+ (!parseContext.isEsProfile() && parseContext.version < 130))
+ return identifierOrType();
+ return keyword;
+ case FLAT:
+ if (parseContext.isEsProfile() && parseContext.version < 300)
+ reservedWord();
+ else if (!parseContext.isEsProfile() && parseContext.version < 130)
+ return identifierOrType();
+ return keyword;
+ case CENTROID:
+ if (parseContext.version < 120)
+ return identifierOrType();
+ return keyword;
+ case INVARIANT:
+ if (!parseContext.isEsProfile() && parseContext.version < 120)
+ return identifierOrType();
+ return keyword;
+ case PACKED:
+ if ((parseContext.isEsProfile() && parseContext.version < 300) ||
+ (!parseContext.isEsProfile() && parseContext.version < 330))
+ return reservedWord();
+ return identifierOrType();
+
+ case RESOURCE:
+ {
+ bool reserved = (parseContext.isEsProfile() && parseContext.version >= 300) ||
+ (!parseContext.isEsProfile() && parseContext.version >= 420);
+ return identifierOrReserved(reserved);
+ }
+ case SUPERP:
+ {
+ bool reserved = parseContext.isEsProfile() || parseContext.version >= 130;
+ return identifierOrReserved(reserved);
+ }
+
+#ifndef GLSLANG_WEB
+ case NOPERSPECTIVE:
+ if (parseContext.isEsProfile() && parseContext.version >= 300 &&
+ parseContext.extensionTurnedOn(E_GL_NV_shader_noperspective_interpolation))
+ return keyword;
+ return es30ReservedFromGLSL(130);
+
+ case NONUNIFORM:
+ if (parseContext.extensionTurnedOn(E_GL_EXT_nonuniform_qualifier))
+ return keyword;
+ else
+ 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;
-
-#ifdef NV_EXTENSIONS
case PAYLOADNV:
case PAYLOADINNV:
case HITATTRNV:
@@ -963,14 +1010,12 @@ int TScanContext::tokenizeIdentifier()
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();
-#endif
-
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);
@@ -984,53 +1029,52 @@ int TScanContext::tokenizeIdentifier()
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 LAYOUT:
- {
- 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 &&
- ! parseContext.extensionsTurnedOn(numLayoutExts, layoutExts)))
- return identifierOrType();
- return keyword;
- }
- case SHARED:
- if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
- (parseContext.profile != EEsProfile && parseContext.version < 140))
- return identifierOrType();
- 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);
case SUBROUTINE:
return es30ReservedFromGLSL(400);
+ case SHARED:
+ if ((parseContext.isEsProfile() && parseContext.version < 300) ||
+ (!parseContext.isEsProfile() && parseContext.version < 140))
+ return identifierOrType();
+ return keyword;
+#endif
+
+ case LAYOUT:
+ {
+ const int numLayoutExts = 2;
+ const char* layoutExts[numLayoutExts] = { E_GL_ARB_shading_language_420pack,
+ E_GL_ARB_explicit_attrib_location };
+ if ((parseContext.isEsProfile() && parseContext.version < 300) ||
+ (!parseContext.isEsProfile() && parseContext.version < 140 &&
+ ! parseContext.extensionsTurnedOn(numLayoutExts, layoutExts)))
+ return identifierOrType();
+ return keyword;
+ }
case HIGH_PRECISION:
case MEDIUM_PRECISION:
@@ -1049,6 +1093,7 @@ int TScanContext::tokenizeIdentifier()
case MAT4X4:
return matNxM();
+#ifndef GLSLANG_WEB
case DMAT2:
case DMAT3:
case DMAT4:
@@ -1079,7 +1124,7 @@ int TScanContext::tokenizeIdentifier()
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);
@@ -1103,7 +1148,7 @@ int TScanContext::tokenizeIdentifier()
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();
@@ -1122,7 +1167,7 @@ int TScanContext::tokenizeIdentifier()
case DVEC3:
case DVEC4:
afterType = true;
- if (parseContext.profile == EEsProfile || parseContext.version < 400)
+ if (parseContext.isEsProfile() || parseContext.version < 400)
reservedWord();
return keyword;
@@ -1136,7 +1181,7 @@ int TScanContext::tokenizeIdentifier()
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))))
@@ -1156,7 +1201,7 @@ int TScanContext::tokenizeIdentifier()
((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();
@@ -1170,11 +1215,8 @@ int TScanContext::tokenizeIdentifier()
case U16VEC4:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
- (parseContext.profile != EEsProfile && parseContext.version >= 450 &&
- (
-#ifdef AMD_EXTENSIONS
- parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_int16) ||
-#endif
+ (!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) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_int16))))
@@ -1192,7 +1234,7 @@ int TScanContext::tokenizeIdentifier()
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:
@@ -1215,7 +1257,7 @@ int TScanContext::tokenizeIdentifier()
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();
@@ -1239,7 +1281,7 @@ int TScanContext::tokenizeIdentifier()
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();
@@ -1249,11 +1291,8 @@ int TScanContext::tokenizeIdentifier()
case F16VEC4:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
- (parseContext.profile != EEsProfile && parseContext.version >= 450 &&
- (
-#ifdef AMD_EXTENSIONS
- parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float) ||
-#endif
+ (!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) ||
parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float16))))
@@ -1275,37 +1314,27 @@ int TScanContext::tokenizeIdentifier()
case F16MAT4X4:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
- (parseContext.profile != EEsProfile && parseContext.version >= 450 &&
- (
-#ifdef AMD_EXTENSIONS
- parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float) ||
-#endif
+ (!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))))
return keyword;
return identifierOrType();
+#endif
case SAMPLERCUBEARRAY:
case SAMPLERCUBEARRAYSHADOW:
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;
- case ISAMPLER1D:
- case ISAMPLER1DARRAY:
- case SAMPLER1DARRAYSHADOW:
- case USAMPLER1D:
- case USAMPLER1DARRAY:
- afterType = true;
- return es30ReservedFromGLSL(130);
-
case UINT:
case UVEC2:
case UVEC3:
@@ -1324,6 +1353,30 @@ int TScanContext::tokenizeIdentifier()
afterType = true;
return nonreservedKeyword(300, 130);
+ case SAMPLER3D:
+ afterType = true;
+ if (parseContext.isEsProfile() && parseContext.version < 300) {
+ if (!parseContext.extensionTurnedOn(E_GL_OES_texture_3D))
+ reservedWord();
+ }
+ return keyword;
+
+ case SAMPLER2DSHADOW:
+ afterType = true;
+ if (parseContext.isEsProfile() && parseContext.version < 300) {
+ if (!parseContext.extensionTurnedOn(E_GL_EXT_shadow_samplers))
+ reservedWord();
+ }
+ return keyword;
+
+#ifndef GLSLANG_WEB
+ case ISAMPLER1D:
+ case ISAMPLER1DARRAY:
+ case SAMPLER1DARRAYSHADOW:
+ case USAMPLER1D:
+ case USAMPLER1DARRAY:
+ afterType = true;
+ return es30ReservedFromGLSL(130);
case ISAMPLER2DRECT:
case USAMPLER2DRECT:
afterType = true;
@@ -1331,7 +1384,7 @@ int TScanContext::tokenizeIdentifier()
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);
@@ -1339,7 +1392,7 @@ int TScanContext::tokenizeIdentifier()
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);
@@ -1348,7 +1401,7 @@ int TScanContext::tokenizeIdentifier()
case ISAMPLER2DMS:
case USAMPLER2DMS:
afterType = true;
- if (parseContext.profile == EEsProfile && parseContext.version >= 310)
+ if (parseContext.isEsProfile() && parseContext.version >= 310)
return keyword;
return es30ReservedFromGLSL(150);
@@ -1356,7 +1409,7 @@ int TScanContext::tokenizeIdentifier()
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);
@@ -1364,30 +1417,14 @@ int TScanContext::tokenizeIdentifier()
case SAMPLER1D:
case SAMPLER1DSHADOW:
afterType = true;
- if (parseContext.profile == EEsProfile)
+ if (parseContext.isEsProfile())
reservedWord();
return keyword;
- case SAMPLER3D:
- afterType = true;
- if (parseContext.profile == EEsProfile && parseContext.version < 300) {
- if (!parseContext.extensionTurnedOn(E_GL_OES_texture_3D))
- reservedWord();
- }
- return keyword;
-
- case SAMPLER2DSHADOW:
- afterType = true;
- if (parseContext.profile == EEsProfile && parseContext.version < 300) {
- if (!parseContext.extensionTurnedOn(E_GL_EXT_shadow_samplers))
- 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())
@@ -1399,10 +1436,10 @@ int TScanContext::tokenizeIdentifier()
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;
@@ -1472,7 +1509,6 @@ int TScanContext::tokenizeIdentifier()
else
return identifierOrType();
-#ifdef AMD_EXTENSIONS
case F16SAMPLER1D:
case F16SAMPLER2D:
case F16SAMPLER3D:
@@ -1521,98 +1557,42 @@ int TScanContext::tokenizeIdentifier()
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();
-#endif
- case NOPERSPECTIVE:
-#ifdef NV_EXTENSIONS
- if (parseContext.profile == EEsProfile && parseContext.version >= 300 &&
- parseContext.extensionTurnedOn(E_GL_NV_shader_noperspective_interpolation))
- return keyword;
-#endif
- return es30ReservedFromGLSL(130);
-
- case SMOOTH:
- if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
- (parseContext.profile != EEsProfile && parseContext.version < 130))
- return identifierOrType();
- return keyword;
-
-#ifdef AMD_EXTENSIONS
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();
-#endif
-#ifdef NV_EXTENSIONS
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();
-#endif
-
- case FLAT:
- if (parseContext.profile == EEsProfile && parseContext.version < 300)
- reservedWord();
- else if (parseContext.profile != EEsProfile && parseContext.version < 130)
- return identifierOrType();
- return keyword;
-
- case CENTROID:
- if (parseContext.version < 120)
- return identifierOrType();
- return keyword;
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;
}
return identifierOrType();
- case INVARIANT:
- if (parseContext.profile != EEsProfile && parseContext.version < 120)
- return identifierOrType();
- return keyword;
-
- case PACKED:
- if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
- (parseContext.profile != EEsProfile && parseContext.version < 330))
- return reservedWord();
- return identifierOrType();
-
- case RESOURCE:
- {
- bool reserved = (parseContext.profile == EEsProfile && parseContext.version >= 300) ||
- (parseContext.profile != EEsProfile && parseContext.version >= 420);
- return identifierOrReserved(reserved);
- }
- case SUPERP:
- {
- bool reserved = parseContext.profile == EEsProfile || parseContext.version >= 130;
- return identifierOrReserved(reserved);
- }
-
-#ifdef NV_EXTENSIONS
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();
-#endif
case FCOOPMATNV:
afterType = true;
@@ -1621,6 +1601,21 @@ int TScanContext::tokenizeIdentifier()
return keyword;
return identifierOrType();
+ case UCOOPMATNV:
+ case ICOOPMATNV:
+ afterType = true;
+ if (parseContext.symbolTable.atBuiltInLevel() ||
+ parseContext.extensionTurnedOn(E_GL_NV_integer_cooperative_matrix))
+ return keyword;
+ return identifierOrType();
+
+ case DEMOTE:
+ if (parseContext.extensionTurnedOn(E_GL_EXT_demote_to_helper_invocation))
+ return keyword;
+ else
+ return identifierOrType();
+#endif
+
default:
parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc);
return 0;
@@ -1638,7 +1633,7 @@ int TScanContext::identifierOrType()
if (const TVariable* variable = parserToken->sType.lex.symbol->getAsVariable()) {
if (variable->isUserType() &&
// treat redeclaration of forward-declared buffer/uniform reference as an identifier
- !(variable->getType().getBasicType() == EbtReference && afterBuffer)) {
+ !(variable->getType().isReference() && afterBuffer)) {
afterType = true;
return TYPE_NAME;
@@ -1668,7 +1663,7 @@ int TScanContext::identifierOrReserved(bool reserved)
return 0;
}
- if (parseContext.forwardCompatible)
+ if (parseContext.isForwardCompatible())
parseContext.warn(loc, "using future reserved keyword", tokenText, "");
return identifierOrType();
@@ -1681,13 +1676,13 @@ int TScanContext::es30ReservedFromGLSL(int version)
if (parseContext.symbolTable.atBuiltInLevel())
return keyword;
- if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
- (parseContext.profile != EEsProfile && parseContext.version < version)) {
- if (parseContext.forwardCompatible)
+ if ((parseContext.isEsProfile() && parseContext.version < 300) ||
+ (!parseContext.isEsProfile() && parseContext.version < version)) {
+ if (parseContext.isForwardCompatible())
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;
@@ -1697,9 +1692,9 @@ int TScanContext::es30ReservedFromGLSL(int version)
// 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.forwardCompatible)
+ if ((parseContext.isEsProfile() && parseContext.version < esVersion) ||
+ (!parseContext.isEsProfile() && parseContext.version < nonEsVersion)) {
+ if (parseContext.isForwardCompatible())
parseContext.warn(loc, "using future keyword", tokenText, "");
return identifierOrType();
@@ -1710,10 +1705,10 @@ int TScanContext::nonreservedKeyword(int esVersion, int nonEsVersion)
int TScanContext::precisionKeyword()
{
- if (parseContext.profile == EEsProfile || parseContext.version >= 130)
+ if (parseContext.isEsProfile() || parseContext.version >= 130)
return keyword;
- if (parseContext.forwardCompatible)
+ if (parseContext.isForwardCompatible())
parseContext.warn(loc, "using ES precision qualifier keyword", tokenText, "");
return identifierOrType();
@@ -1726,7 +1721,7 @@ int TScanContext::matNxM()
if (parseContext.version > 110)
return keyword;
- if (parseContext.forwardCompatible)
+ if (parseContext.isForwardCompatible())
parseContext.warn(loc, "using future non-square matrix type keyword", tokenText, "");
return identifierOrType();
@@ -1736,16 +1731,16 @@ int TScanContext::dMat()
{
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)
+ if (parseContext.isForwardCompatible())
parseContext.warn(loc, "using future type keyword", tokenText, "");
return identifierOrType();
@@ -1754,19 +1749,19 @@ int TScanContext::dMat()
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;
}
- if (parseContext.forwardCompatible)
+ if (parseContext.isForwardCompatible())
parseContext.warn(loc, "using future type keyword", tokenText, "");
return identifierOrType();
@@ -1774,17 +1769,17 @@ int TScanContext::firstGenerationImage(bool inEs310)
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;
- if (parseContext.forwardCompatible)
+ if (parseContext.isForwardCompatible())
parseContext.warn(loc, "using future type keyword", tokenText, "");
return identifierOrType();