diff --git a/deps/glslang/glslang/glslang/MachineIndependent/Constant.cpp b/deps/glslang/glslang/glslang/MachineIndependent/Constant.cpp index 4637b8b2bc..c080bb056c 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/Constant.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/Constant.cpp @@ -191,9 +191,9 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right break; case EbtUint8: - if (rightUnionArray[i] == 0) { + if (rightUnionArray[i] == 0) newConstArray[i].setU8Const(0xFF); - } else + else newConstArray[i].setU8Const(leftUnionArray[i].getU8Const() / rightUnionArray[i].getU8Const()); break; @@ -207,9 +207,9 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right break; case EbtUint16: - if (rightUnionArray[i] == 0) { + if (rightUnionArray[i] == 0) newConstArray[i].setU16Const(0xFFFF); - } else + else newConstArray[i].setU16Const(leftUnionArray[i].getU16Const() / rightUnionArray[i].getU16Const()); break; diff --git a/deps/glslang/glslang/glslang/MachineIndependent/LiveTraverser.h b/deps/glslang/glslang/glslang/MachineIndependent/LiveTraverser.h index fcb1fa9bb7..1465b27120 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/LiveTraverser.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/LiveTraverser.h @@ -104,7 +104,8 @@ protected: return true; // traverse all code TIntermConstantUnion* constant = node->getCondition()->getAsConstantUnion(); - if (constant) { + if (constant) + { // cull the path that is dead if (constant->getConstArray()[0].getBConst() == true && node->getTrueBlock()) node->getTrueBlock()->traverse(this); @@ -112,8 +113,8 @@ protected: node->getFalseBlock()->traverse(this); return false; // don't traverse any more, we did it all above - } else - return true; // traverse the whole subtree + } + return true; // traverse the whole subtree } // Track live functions as well as uniforms, so that we don't visit dead functions diff --git a/deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp b/deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp index 560d0aff10..0e93717f45 100755 --- a/deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp @@ -81,22 +81,26 @@ bool TInputScanner::consumeComment() get(); // consume the '/' int c = peek(); - if (c == '/') { - + if (c == '/') + { // a '//' style comment get(); // consume the second '/' c = get(); - for (;;) { + for (;;) + { while (c != EndOfInput && c != '\\' && c != '\r' && c != '\n') c = get(); - if (c == EndOfInput || c == '\r' || c == '\n') { + if (c == EndOfInput || c == '\r' || c == '\n') + { while (c == '\r' || c == '\n') c = get(); // we reached the end of the comment break; - } else { + } + else + { // it's a '\', so we need to keep going, after skipping what's escaped // read the skipped character @@ -107,26 +111,30 @@ bool TInputScanner::consumeComment() get(); c = get(); } - }; + } // put back the last non-comment character if (c != EndOfInput) unget(); - } else if (c == '*') { + } + else if (c == '*') + { // a '/*' style comment get(); // consume the '*' c = get(); - for (;;) { + for (;;) + { while (c != EndOfInput && c != '*') c = get(); - if (c == '*') { + if (c == '*') + { c = get(); if (c == '/') break; // end of comment // not end of comment } else // end of input break; - }; + } } else { @@ -141,7 +149,8 @@ bool TInputScanner::consumeComment() // skip whitespace, then skip a comment, rinse, repeat void TInputScanner::consumeWhitespaceComment(bool& foundNonSpaceTab) { - for (;;) { + for (;;) + { consumeWhiteSpace(foundNonSpaceTab); // if not starting a comment now, then done @@ -153,7 +162,7 @@ void TInputScanner::consumeWhitespaceComment(bool& foundNonSpaceTab) foundNonSpaceTab = true; if (!consumeComment()) return; - }; + } } // Returns true if there was non-white space (e.g., a comment, newline) before the #version @@ -311,11 +320,10 @@ namespace glslang { void TScanContext::fillInKeywordMap() { - if (KeywordMap != NULL) { - // this is really an error, as this should called only once per process - // but, the only risk is if two threads called simultaneously + // this is really an error, as this should called only once per process + // but, the only risk is if two threads called simultaneously + if (KeywordMap) return; - } KeywordMap = new std::unordered_map; (*KeywordMap)["const"] = CONST; @@ -828,707 +836,780 @@ int TScanContext::tokenizeIdentifier() return reservedWord(); auto it = KeywordMap->find(tokenText); - if (it == KeywordMap->end()) { - // Should have an identifier of some sort + // Should have an identifier of some sort + if (it == KeywordMap->end()) return identifierOrType(); - } keyword = it->second; - switch (keyword) { - case CONST: - case UNIFORM: - case IN: - case OUT: - case INOUT: - case BREAK: - case CONTINUE: - case DO: - case FOR: - case WHILE: - case IF: - case ELSE: - case DISCARD: - case RETURN: - case CASE: - return keyword; - - case STRUCT: - 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)) - reservedWord(); - return keyword; - - case VOID: - case BOOL: - case FLOAT: - case INT: - case BVEC2: - case BVEC3: - case BVEC4: - case VEC2: - case VEC3: - case VEC4: - case IVEC2: - case IVEC3: - case IVEC4: - case MAT2: - case MAT3: - case MAT4: - case SAMPLER2D: - case SAMPLERCUBE: - afterType = true; - return keyword; - - case BOOLCONSTANT: - if (strcmp("true", tokenText) == 0) - parserToken->sType.lex.b = true; - else - parserToken->sType.lex.b = false; - return keyword; - - case ATTRIBUTE: - case VARYING: - if (_parseContext.profile == EEsProfile && _parseContext.version >= 300) - reservedWord(); - return keyword; - - case BUFFER: - if ((_parseContext.profile == EEsProfile && _parseContext.version < 310) || - (_parseContext.profile != EEsProfile && _parseContext.version < 430)) - return identifierOrType(); - return keyword; - - case ATOMIC_UINT: - if ((_parseContext.profile == EEsProfile && _parseContext.version >= 310) || - _parseContext.extensionTurnedOn(E_GL_ARB_shader_atomic_counters)) - return keyword; - return es30ReservedFromGLSL(420); - - case COHERENT: - case RESTRICT: - case READONLY: - case WRITEONLY: - if (_parseContext.profile == EEsProfile && _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) - return keyword; - if (! _parseContext.symbolTable.atBuiltInLevel() && (_parseContext.profile == EEsProfile || - (_parseContext.version < 420 && ! _parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store)))) - reservedWord(); - return keyword; - - case LAYOUT: + switch (keyword) { - 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 CONST: + case UNIFORM: + case IN: + case OUT: + case INOUT: + case BREAK: + case CONTINUE: + case DO: + case FOR: + case WHILE: + case IF: + case ELSE: + case DISCARD: + case RETURN: + case CASE: + return keyword; - case PATCH: - if (_parseContext.symbolTable.atBuiltInLevel() || - (_parseContext.profile == EEsProfile && - (_parseContext.version >= 320 || - _parseContext.extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader))) || - (_parseContext.profile != EEsProfile && _parseContext.extensionTurnedOn(E_GL_ARB_tessellation_shader))) - return keyword; + case STRUCT: + afterStruct = true; + return keyword; - return es30ReservedFromGLSL(400); + case NONUNIFORM: + if (_parseContext.extensionTurnedOn( + E_GL_EXT_nonuniform_qualifier)) + return keyword; + return identifierOrType(); - case SAMPLE: - if ((_parseContext.profile == EEsProfile && _parseContext.version >= 320) || - _parseContext.extensionsTurnedOn(1, &E_GL_OES_shader_multisample_interpolation)) - return keyword; - return es30ReservedFromGLSL(400); + case SWITCH: + case DEFAULT: + if (( _parseContext.profile == EEsProfile + && _parseContext.version < 300) + || (_parseContext.profile != EEsProfile + && _parseContext.version < 130)) + reservedWord(); + return keyword; - case SUBROUTINE: - return es30ReservedFromGLSL(400); + case VOID: + case BOOL: + case FLOAT: + case INT: + case BVEC2: + case BVEC3: + case BVEC4: + case VEC2: + case VEC3: + case VEC4: + case IVEC2: + case IVEC3: + case IVEC4: + case MAT2: + case MAT3: + case MAT4: + case SAMPLER2D: + case SAMPLERCUBE: + afterType = true; + return keyword; - case HIGH_PRECISION: - case MEDIUM_PRECISION: - case LOW_PRECISION: - case PRECISION: - return precisionKeyword(); + case BOOLCONSTANT: + if (strcmp("true", tokenText) == 0) + parserToken->sType.lex.b = true; + else + parserToken->sType.lex.b = false; + return keyword; - case MAT2X2: - case MAT2X3: - case MAT2X4: - case MAT3X2: - case MAT3X3: - case MAT3X4: - case MAT4X2: - case MAT4X3: - case MAT4X4: - return matNxM(); + case ATTRIBUTE: + case VARYING: + if (_parseContext.profile == EEsProfile + && _parseContext.version >= 300) + reservedWord(); + return keyword; - case DMAT2: - case DMAT3: - case DMAT4: - case DMAT2X2: - case DMAT2X3: - case DMAT2X4: - case DMAT3X2: - case DMAT3X3: - case DMAT3X4: - case DMAT4X2: - case DMAT4X3: - case DMAT4X4: - return dMat(); + case BUFFER: + if ((_parseContext.profile == EEsProfile + && _parseContext.version < 310) + || (_parseContext.profile != EEsProfile + && _parseContext.version < 430)) + return identifierOrType(); + return keyword; - case IMAGE1D: - case IIMAGE1D: - case UIMAGE1D: - case IMAGE1DARRAY: - case IIMAGE1DARRAY: - case UIMAGE1DARRAY: - case IMAGE2DRECT: - case IIMAGE2DRECT: - case UIMAGE2DRECT: - afterType = true; - return firstGenerationImage(false); + case ATOMIC_UINT: + if ((_parseContext.profile == EEsProfile + && _parseContext.version >= 310) + || _parseContext.extensionTurnedOn( + E_GL_ARB_shader_atomic_counters)) + return keyword; + return es30ReservedFromGLSL(420); - case IMAGEBUFFER: - case IIMAGEBUFFER: - case UIMAGEBUFFER: - afterType = true; - if ((_parseContext.profile == EEsProfile && _parseContext.version >= 320) || - _parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer)) - return keyword; - return firstGenerationImage(false); + case COHERENT: + case RESTRICT: + case READONLY: + case WRITEONLY: + if (_parseContext.profile == EEsProfile + && _parseContext.version >= 310) + return keyword; + return es30ReservedFromGLSL(_parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store) ? 130 : 420); - case IMAGE2D: - case IIMAGE2D: - case UIMAGE2D: - case IMAGE3D: - case IIMAGE3D: - case UIMAGE3D: - case IMAGECUBE: - case IIMAGECUBE: - case UIMAGECUBE: - case IMAGE2DARRAY: - case IIMAGE2DARRAY: - case UIMAGE2DARRAY: - afterType = true; - return firstGenerationImage(true); + case VOLATILE: + if (_parseContext.profile == EEsProfile + && _parseContext.version >= 310) + return keyword; + if ( !_parseContext.symbolTable.atBuiltInLevel() + && (_parseContext.profile == EEsProfile + || (_parseContext.version < 420 + && !_parseContext.extensionTurnedOn( + E_GL_ARB_shader_image_load_store)))) + reservedWord(); + return keyword; - case IMAGECUBEARRAY: - case IIMAGECUBEARRAY: - case UIMAGECUBEARRAY: - afterType = true; - if ((_parseContext.profile == EEsProfile && _parseContext.version >= 320) || - _parseContext.extensionsTurnedOn(Num_AEP_texture_cube_map_array, AEP_texture_cube_map_array)) - return keyword; - return secondGenerationImage(); + 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 IMAGE2DMS: - case IIMAGE2DMS: - case UIMAGE2DMS: - case IMAGE2DMSARRAY: - case IIMAGE2DMSARRAY: - case UIMAGE2DMSARRAY: - afterType = true; - return secondGenerationImage(); + case PATCH: + if (_parseContext.symbolTable.atBuiltInLevel() || + (_parseContext.profile == EEsProfile && + (_parseContext.version >= 320 || + _parseContext.extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader))) || + (_parseContext.profile != EEsProfile && _parseContext.extensionTurnedOn(E_GL_ARB_tessellation_shader))) + return keyword; - case DOUBLE: - case DVEC2: - case DVEC3: - case DVEC4: - afterType = true; - if (_parseContext.profile == EEsProfile || _parseContext.version < 400) - reservedWord(); - return keyword; + return es30ReservedFromGLSL(400); - case INT64_T: - case UINT64_T: - case I64VEC2: - case I64VEC3: - case I64VEC4: - case U64VEC2: - case U64VEC3: - case U64VEC4: - afterType = true; - if (_parseContext.symbolTable.atBuiltInLevel() || - (_parseContext.profile != EEsProfile && _parseContext.version >= 450 && - (_parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) || - _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || - _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_int64)))) - return keyword; - return identifierOrType(); + case SAMPLE: + if ((_parseContext.profile == EEsProfile + && _parseContext.version >= 320) + || _parseContext.extensionsTurnedOn(1, + &E_GL_OES_shader_multisample_interpolation)) + return keyword; + return es30ReservedFromGLSL(400); - case INT8_T: - case UINT8_T: - case I8VEC2: - case I8VEC3: - case I8VEC4: - case U8VEC2: - case U8VEC3: - case U8VEC4: - afterType = true; - if (_parseContext.symbolTable.atBuiltInLevel() || - ((_parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || - _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_int8)) && - _parseContext.profile != EEsProfile && _parseContext.version >= 450)) - return keyword; - return identifierOrType(); + case SUBROUTINE: + return es30ReservedFromGLSL(400); - case INT16_T: - case UINT16_T: - case I16VEC2: - case I16VEC3: - case I16VEC4: - case U16VEC2: - case U16VEC3: - case U16VEC4: - afterType = true; - if (_parseContext.symbolTable.atBuiltInLevel() || - (_parseContext.profile != EEsProfile && _parseContext.version >= 450 && - ( + case HIGH_PRECISION: + case MEDIUM_PRECISION: + case LOW_PRECISION: + case PRECISION: + return precisionKeyword(); + case MAT2X2: + case MAT2X3: + case MAT2X4: + case MAT3X2: + case MAT3X3: + case MAT3X4: + case MAT4X2: + case MAT4X3: + case MAT4X4: + return matNxM(); + case DMAT2: + case DMAT3: + case DMAT4: + case DMAT2X2: + case DMAT2X3: + case DMAT2X4: + case DMAT3X2: + case DMAT3X3: + case DMAT3X4: + case DMAT4X2: + case DMAT4X3: + case DMAT4X4: + return dMat(); + case IMAGE1D: + case IIMAGE1D: + case UIMAGE1D: + case IMAGE1DARRAY: + case IIMAGE1DARRAY: + case UIMAGE1DARRAY: + case IMAGE2DRECT: + case IIMAGE2DRECT: + case UIMAGE2DRECT: + afterType = true; + return firstGenerationImage(false); + case IMAGEBUFFER: + case IIMAGEBUFFER: + case UIMAGEBUFFER: + afterType = true; + if ((_parseContext.profile == EEsProfile + && _parseContext.version >= 320) + || _parseContext.extensionsTurnedOn( + Num_AEP_texture_buffer, AEP_texture_buffer)) + return keyword; + return firstGenerationImage(false); + + case IMAGE2D: + case IIMAGE2D: + case UIMAGE2D: + case IMAGE3D: + case IIMAGE3D: + case UIMAGE3D: + case IMAGECUBE: + case IIMAGECUBE: + case UIMAGECUBE: + case IMAGE2DARRAY: + case IIMAGE2DARRAY: + case UIMAGE2DARRAY: + afterType = true; + return firstGenerationImage(true); + + case IMAGECUBEARRAY: + case IIMAGECUBEARRAY: + case UIMAGECUBEARRAY: + afterType = true; + if ((_parseContext.profile == EEsProfile + && _parseContext.version >= 320) + || _parseContext.extensionsTurnedOn( + Num_AEP_texture_cube_map_array, + AEP_texture_cube_map_array)) + return keyword; + return secondGenerationImage(); + + case IMAGE2DMS: + case IIMAGE2DMS: + case UIMAGE2DMS: + case IMAGE2DMSARRAY: + case IIMAGE2DMSARRAY: + case UIMAGE2DMSARRAY: + afterType = true; + return secondGenerationImage(); + + case DOUBLE: + case DVEC2: + case DVEC3: + case DVEC4: + afterType = true; + if (_parseContext.profile == EEsProfile + || _parseContext.version < 400) + reservedWord(); + return keyword; + + case INT64_T: + case UINT64_T: + case I64VEC2: + case I64VEC3: + case I64VEC4: + case U64VEC2: + case U64VEC3: + case U64VEC4: + afterType = true; + if (_parseContext.symbolTable.atBuiltInLevel() || + (_parseContext.profile != EEsProfile && _parseContext.version >= 450 && + (_parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) || + _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || + _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_int64)))) + return keyword; + return identifierOrType(); + + case INT8_T: + case UINT8_T: + case I8VEC2: + case I8VEC3: + case I8VEC4: + case U8VEC2: + case U8VEC3: + case U8VEC4: + afterType = true; + if (_parseContext.symbolTable.atBuiltInLevel() || + ((_parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || + _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_int8)) && + _parseContext.profile != EEsProfile && _parseContext.version >= 450)) + return keyword; + return identifierOrType(); + + case INT16_T: + case UINT16_T: + case I16VEC2: + case I16VEC3: + case I16VEC4: + case U16VEC2: + case U16VEC3: + 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) || + _parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_int16) || #endif - _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || - _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_int16)))) - return keyword; - return identifierOrType(); - case INT32_T: - case UINT32_T: - case I32VEC2: - case I32VEC3: - case I32VEC4: - case U32VEC2: - case U32VEC3: - case U32VEC4: - afterType = true; - if (_parseContext.symbolTable.atBuiltInLevel() || - ((_parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || - _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_int32)) && - _parseContext.profile != EEsProfile && _parseContext.version >= 450)) - return keyword; - return identifierOrType(); - case FLOAT32_T: - case F32VEC2: - case F32VEC3: - case F32VEC4: - case F32MAT2: - case F32MAT3: - case F32MAT4: - case F32MAT2X2: - case F32MAT2X3: - case F32MAT2X4: - case F32MAT3X2: - case F32MAT3X3: - case F32MAT3X4: - case F32MAT4X2: - case F32MAT4X3: - case F32MAT4X4: - afterType = true; - if (_parseContext.symbolTable.atBuiltInLevel() || - ((_parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || - _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_float32)) && - _parseContext.profile != EEsProfile && _parseContext.version >= 450)) - return keyword; - return identifierOrType(); + _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || + _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_int16)))) + return keyword; + return identifierOrType(); + case INT32_T: + case UINT32_T: + case I32VEC2: + case I32VEC3: + case I32VEC4: + case U32VEC2: + case U32VEC3: + case U32VEC4: + afterType = true; + if (_parseContext.symbolTable.atBuiltInLevel() || + ((_parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || + _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_int32)) && + _parseContext.profile != EEsProfile && _parseContext.version >= 450)) + return keyword; + return identifierOrType(); + case FLOAT32_T: + case F32VEC2: + case F32VEC3: + case F32VEC4: + case F32MAT2: + case F32MAT3: + case F32MAT4: + case F32MAT2X2: + case F32MAT2X3: + case F32MAT2X4: + case F32MAT3X2: + case F32MAT3X3: + case F32MAT3X4: + case F32MAT4X2: + case F32MAT4X3: + case F32MAT4X4: + afterType = true; + if (_parseContext.symbolTable.atBuiltInLevel() || + ((_parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || + _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_float32)) && + _parseContext.profile != EEsProfile && _parseContext.version >= 450)) + return keyword; + return identifierOrType(); - case FLOAT64_T: - case F64VEC2: - case F64VEC3: - case F64VEC4: - case F64MAT2: - case F64MAT3: - case F64MAT4: - case F64MAT2X2: - case F64MAT2X3: - case F64MAT2X4: - case F64MAT3X2: - case F64MAT3X3: - case F64MAT3X4: - case F64MAT4X2: - case F64MAT4X3: - case F64MAT4X4: - afterType = true; - if (_parseContext.symbolTable.atBuiltInLevel() || - ((_parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || - _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_float64)) && - _parseContext.profile != EEsProfile && _parseContext.version >= 450)) - return keyword; - return identifierOrType(); + case FLOAT64_T: + case F64VEC2: + case F64VEC3: + case F64VEC4: + case F64MAT2: + case F64MAT3: + case F64MAT4: + case F64MAT2X2: + case F64MAT2X3: + case F64MAT2X4: + case F64MAT3X2: + case F64MAT3X3: + case F64MAT3X4: + case F64MAT4X2: + case F64MAT4X3: + case F64MAT4X4: + afterType = true; + if (_parseContext.symbolTable.atBuiltInLevel() || + ((_parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || + _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_float64)) && + _parseContext.profile != EEsProfile && _parseContext.version >= 450)) + return keyword; + return identifierOrType(); - case FLOAT16_T: - case F16VEC2: - case F16VEC3: - case F16VEC4: - case F16MAT2: - case F16MAT3: - case F16MAT4: - case F16MAT2X2: - case F16MAT2X3: - case F16MAT2X4: - case F16MAT3X2: - case F16MAT3X3: - case F16MAT3X4: - case F16MAT4X2: - case F16MAT4X3: - case F16MAT4X4: - afterType = true; - if (_parseContext.symbolTable.atBuiltInLevel() || - (_parseContext.profile != EEsProfile && _parseContext.version >= 450 && - ( + case FLOAT16_T: + case F16VEC2: + case F16VEC3: + case F16VEC4: + case F16MAT2: + case F16MAT3: + case F16MAT4: + case F16MAT2X2: + case F16MAT2X3: + case F16MAT2X4: + case F16MAT3X2: + case F16MAT3X3: + case F16MAT3X4: + case F16MAT4X2: + case F16MAT4X3: + 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) || + _parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float) || #endif - _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || - _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_float16)))) - return keyword; + _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types) || + _parseContext.extensionTurnedOn(E_GL_KHX_shader_explicit_arithmetic_types_float16)))) + return keyword; - return identifierOrType(); + return identifierOrType(); - case SAMPLERCUBEARRAY: - case SAMPLERCUBEARRAYSHADOW: - case ISAMPLERCUBEARRAY: - case USAMPLERCUBEARRAY: - afterType = true; - if ((_parseContext.profile == EEsProfile && _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))) - reservedWord(); - return keyword; + case SAMPLERCUBEARRAY: + case SAMPLERCUBEARRAYSHADOW: + case ISAMPLERCUBEARRAY: + case USAMPLERCUBEARRAY: + afterType = true; + if ((_parseContext.profile == EEsProfile + && _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))) + reservedWord(); + return keyword; - case ISAMPLER1D: - case ISAMPLER1DARRAY: - case SAMPLER1DARRAYSHADOW: - case USAMPLER1D: - case USAMPLER1DARRAY: - afterType = true; - return es30ReservedFromGLSL(130); + case ISAMPLER1D: + case ISAMPLER1DARRAY: + case SAMPLER1DARRAYSHADOW: + case USAMPLER1D: + case USAMPLER1DARRAY: + afterType = true; + return es30ReservedFromGLSL(130); - case UINT: - case UVEC2: - case UVEC3: - case UVEC4: - case SAMPLERCUBESHADOW: - case SAMPLER2DARRAY: - case SAMPLER2DARRAYSHADOW: - case ISAMPLER2D: - case ISAMPLER3D: - case ISAMPLERCUBE: - case ISAMPLER2DARRAY: - case USAMPLER2D: - case USAMPLER3D: - case USAMPLERCUBE: - case USAMPLER2DARRAY: - afterType = true; - return nonreservedKeyword(300, 130); + case UINT: + case UVEC2: + case UVEC3: + case UVEC4: + case SAMPLERCUBESHADOW: + case SAMPLER2DARRAY: + case SAMPLER2DARRAYSHADOW: + case ISAMPLER2D: + case ISAMPLER3D: + case ISAMPLERCUBE: + case ISAMPLER2DARRAY: + case USAMPLER2D: + case USAMPLER3D: + case USAMPLERCUBE: + case USAMPLER2DARRAY: + afterType = true; + return nonreservedKeyword(300, 130); - case ISAMPLER2DRECT: - case USAMPLER2DRECT: - afterType = true; - return es30ReservedFromGLSL(140); + case ISAMPLER2DRECT: + case USAMPLER2DRECT: + afterType = true; + return es30ReservedFromGLSL(140); - case SAMPLERBUFFER: - afterType = true; - if ((_parseContext.profile == EEsProfile && _parseContext.version >= 320) || - _parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer)) - return keyword; - return es30ReservedFromGLSL(130); + case SAMPLERBUFFER: + afterType = true; + if ((_parseContext.profile == EEsProfile + && _parseContext.version >= 320) + || _parseContext.extensionsTurnedOn( + Num_AEP_texture_buffer, AEP_texture_buffer)) + return keyword; + return es30ReservedFromGLSL(130); - case ISAMPLERBUFFER: - case USAMPLERBUFFER: - afterType = true; - if ((_parseContext.profile == EEsProfile && _parseContext.version >= 320) || - _parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer)) - return keyword; - return es30ReservedFromGLSL(140); + case ISAMPLERBUFFER: + case USAMPLERBUFFER: + afterType = true; + if ((_parseContext.profile == EEsProfile + && _parseContext.version >= 320) + || _parseContext.extensionsTurnedOn( + Num_AEP_texture_buffer, AEP_texture_buffer)) + return keyword; + return es30ReservedFromGLSL(140); - case SAMPLER2DMS: - case ISAMPLER2DMS: - case USAMPLER2DMS: - afterType = true; - if (_parseContext.profile == EEsProfile && _parseContext.version >= 310) - return keyword; - return es30ReservedFromGLSL(150); + case SAMPLER2DMS: + case ISAMPLER2DMS: + case USAMPLER2DMS: + afterType = true; + if (_parseContext.profile == EEsProfile + && _parseContext.version >= 310) + return keyword; + return es30ReservedFromGLSL(150); - case SAMPLER2DMSARRAY: - case ISAMPLER2DMSARRAY: - case USAMPLER2DMSARRAY: - afterType = true; - if ((_parseContext.profile == EEsProfile && _parseContext.version >= 320) || - _parseContext.extensionsTurnedOn(1, &E_GL_OES_texture_storage_multisample_2d_array)) - return keyword; - return es30ReservedFromGLSL(150); + case SAMPLER2DMSARRAY: + case ISAMPLER2DMSARRAY: + case USAMPLER2DMSARRAY: + afterType = true; + if ((_parseContext.profile == EEsProfile + && _parseContext.version >= 320) + || _parseContext.extensionsTurnedOn(1, + &E_GL_OES_texture_storage_multisample_2d_array)) + return keyword; + return es30ReservedFromGLSL(150); - case SAMPLER1D: - case SAMPLER1DSHADOW: - afterType = true; - if (_parseContext.profile == EEsProfile) - reservedWord(); - return keyword; + case SAMPLER1D: + case SAMPLER1DSHADOW: + afterType = true; + if (_parseContext.profile == EEsProfile) + 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 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 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) - reservedWord(); - else if (_parseContext.version < 140 && ! _parseContext.symbolTable.atBuiltInLevel() && ! _parseContext.extensionTurnedOn(E_GL_ARB_texture_rectangle)) { - if (_parseContext.relaxedErrors()) - _parseContext.requireExtensions(loc, 1, &E_GL_ARB_texture_rectangle, "texture-rectangle sampler keyword"); - else - reservedWord(); - } - return keyword; + case SAMPLER2DRECT: + case SAMPLER2DRECTSHADOW: + afterType = true; + if (_parseContext.profile == EEsProfile) + reservedWord(); + else if (_parseContext.version < 140 + && ! _parseContext.symbolTable.atBuiltInLevel() + && ! _parseContext.extensionTurnedOn( + E_GL_ARB_texture_rectangle)) + { + if (_parseContext.relaxedErrors()) + _parseContext.requireExtensions(loc, 1, &E_GL_ARB_texture_rectangle, "texture-rectangle sampler keyword"); + else + reservedWord(); + } + return keyword; - case SAMPLER1DARRAY: - afterType = true; - if (_parseContext.profile == EEsProfile && _parseContext.version == 300) - reservedWord(); - else if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) || - (_parseContext.profile != EEsProfile && _parseContext.version < 130)) - return identifierOrType(); - return keyword; + case SAMPLER1DARRAY: + afterType = true; + if (_parseContext.profile == EEsProfile + && _parseContext.version == 300) + reservedWord(); + else if ( (_parseContext.profile == EEsProfile + && _parseContext.version < 300) + || (_parseContext.profile != EEsProfile + && _parseContext.version < 130)) + return identifierOrType(); + return keyword; - case SAMPLEREXTERNALOES: - afterType = true; - if (_parseContext.symbolTable.atBuiltInLevel() || - _parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external) || - _parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external_essl3)) - return keyword; - return identifierOrType(); + case SAMPLEREXTERNALOES: + afterType = true; + if ( _parseContext.symbolTable.atBuiltInLevel() + || _parseContext.extensionTurnedOn( + E_GL_OES_EGL_image_external) + || _parseContext.extensionTurnedOn( + E_GL_OES_EGL_image_external_essl3)) + return keyword; + return identifierOrType(); - case TEXTURE2D: - case TEXTURECUBE: - case TEXTURECUBEARRAY: - case ITEXTURECUBEARRAY: - case UTEXTURECUBEARRAY: - case ITEXTURE1DARRAY: - case UTEXTURE1D: - case ITEXTURE1D: - case UTEXTURE1DARRAY: - case TEXTUREBUFFER: - case TEXTURE2DARRAY: - case ITEXTURE2D: - case ITEXTURE3D: - case ITEXTURECUBE: - case ITEXTURE2DARRAY: - case UTEXTURE2D: - case UTEXTURE3D: - case UTEXTURECUBE: - case UTEXTURE2DARRAY: - case ITEXTURE2DRECT: - case UTEXTURE2DRECT: - case ITEXTUREBUFFER: - case UTEXTUREBUFFER: - case TEXTURE2DMS: - case ITEXTURE2DMS: - case UTEXTURE2DMS: - case TEXTURE2DMSARRAY: - case ITEXTURE2DMSARRAY: - case UTEXTURE2DMSARRAY: - case TEXTURE1D: - case TEXTURE3D: - case TEXTURE2DRECT: - case TEXTURE1DARRAY: - case SAMPLER: - case SAMPLERSHADOW: - if (_parseContext.spvVersion.vulkan > 0) - return keyword; - else - return identifierOrType(); + case TEXTURE2D: + case TEXTURECUBE: + case TEXTURECUBEARRAY: + case ITEXTURECUBEARRAY: + case UTEXTURECUBEARRAY: + case ITEXTURE1DARRAY: + case UTEXTURE1D: + case ITEXTURE1D: + case UTEXTURE1DARRAY: + case TEXTUREBUFFER: + case TEXTURE2DARRAY: + case ITEXTURE2D: + case ITEXTURE3D: + case ITEXTURECUBE: + case ITEXTURE2DARRAY: + case UTEXTURE2D: + case UTEXTURE3D: + case UTEXTURECUBE: + case UTEXTURE2DARRAY: + case ITEXTURE2DRECT: + case UTEXTURE2DRECT: + case ITEXTUREBUFFER: + case UTEXTUREBUFFER: + case TEXTURE2DMS: + case ITEXTURE2DMS: + case UTEXTURE2DMS: + case TEXTURE2DMSARRAY: + case ITEXTURE2DMSARRAY: + case UTEXTURE2DMSARRAY: + case TEXTURE1D: + case TEXTURE3D: + case TEXTURE2DRECT: + case TEXTURE1DARRAY: + case SAMPLER: + case SAMPLERSHADOW: + if (_parseContext.spvVersion.vulkan > 0) + return keyword; + return identifierOrType(); - case SUBPASSINPUT: - case SUBPASSINPUTMS: - case ISUBPASSINPUT: - case ISUBPASSINPUTMS: - case USUBPASSINPUT: - case USUBPASSINPUTMS: - if (_parseContext.spvVersion.vulkan > 0) - return keyword; - else - return identifierOrType(); + case SUBPASSINPUT: + case SUBPASSINPUTMS: + case ISUBPASSINPUT: + case ISUBPASSINPUTMS: + case USUBPASSINPUT: + case USUBPASSINPUTMS: + if (_parseContext.spvVersion.vulkan > 0) + return keyword; + return identifierOrType(); #ifdef AMD_EXTENSIONS - case F16SAMPLER1D: - case F16SAMPLER2D: - case F16SAMPLER3D: - case F16SAMPLER2DRECT: - case F16SAMPLERCUBE: - case F16SAMPLER1DARRAY: - case F16SAMPLER2DARRAY: - case F16SAMPLERCUBEARRAY: - case F16SAMPLERBUFFER: - case F16SAMPLER2DMS: - case F16SAMPLER2DMSARRAY: - case F16SAMPLER1DSHADOW: - case F16SAMPLER2DSHADOW: - case F16SAMPLER1DARRAYSHADOW: - case F16SAMPLER2DARRAYSHADOW: - case F16SAMPLER2DRECTSHADOW: - case F16SAMPLERCUBESHADOW: - case F16SAMPLERCUBEARRAYSHADOW: + case F16SAMPLER1D: + case F16SAMPLER2D: + case F16SAMPLER3D: + case F16SAMPLER2DRECT: + case F16SAMPLERCUBE: + case F16SAMPLER1DARRAY: + case F16SAMPLER2DARRAY: + case F16SAMPLERCUBEARRAY: + case F16SAMPLERBUFFER: + case F16SAMPLER2DMS: + case F16SAMPLER2DMSARRAY: + case F16SAMPLER1DSHADOW: + case F16SAMPLER2DSHADOW: + case F16SAMPLER1DARRAYSHADOW: + case F16SAMPLER2DARRAYSHADOW: + case F16SAMPLER2DRECTSHADOW: + case F16SAMPLERCUBESHADOW: + case F16SAMPLERCUBEARRAYSHADOW: - case F16IMAGE1D: - case F16IMAGE2D: - case F16IMAGE3D: - case F16IMAGE2DRECT: - case F16IMAGECUBE: - case F16IMAGE1DARRAY: - case F16IMAGE2DARRAY: - case F16IMAGECUBEARRAY: - case F16IMAGEBUFFER: - case F16IMAGE2DMS: - case F16IMAGE2DMSARRAY: + case F16IMAGE1D: + case F16IMAGE2D: + case F16IMAGE3D: + case F16IMAGE2DRECT: + case F16IMAGECUBE: + case F16IMAGE1DARRAY: + case F16IMAGE2DARRAY: + case F16IMAGECUBEARRAY: + case F16IMAGEBUFFER: + case F16IMAGE2DMS: + case F16IMAGE2DMSARRAY: - case F16TEXTURE1D: - case F16TEXTURE2D: - case F16TEXTURE3D: - case F16TEXTURE2DRECT: - case F16TEXTURECUBE: - case F16TEXTURE1DARRAY: - case F16TEXTURE2DARRAY: - case F16TEXTURECUBEARRAY: - case F16TEXTUREBUFFER: - case F16TEXTURE2DMS: - case F16TEXTURE2DMSARRAY: + case F16TEXTURE1D: + case F16TEXTURE2D: + case F16TEXTURE3D: + case F16TEXTURE2DRECT: + case F16TEXTURECUBE: + case F16TEXTURE1DARRAY: + case F16TEXTURE2DARRAY: + case F16TEXTURECUBEARRAY: + case F16TEXTUREBUFFER: + case F16TEXTURE2DMS: + case F16TEXTURE2DMSARRAY: - case F16SUBPASSINPUT: - case F16SUBPASSINPUTMS: - afterType = true; - if (_parseContext.symbolTable.atBuiltInLevel() || - (_parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float_fetch) && - _parseContext.profile != EEsProfile && _parseContext.version >= 450)) - return keyword; - return identifierOrType(); + case F16SUBPASSINPUT: + case F16SUBPASSINPUTMS: + afterType = true; + if ( _parseContext.symbolTable.atBuiltInLevel() + || (_parseContext.extensionTurnedOn( + E_GL_AMD_gpu_shader_half_float_fetch) + && _parseContext.profile != EEsProfile + && _parseContext.version >= 450)) + return keyword; + return identifierOrType(); #endif - case NOPERSPECTIVE: + case NOPERSPECTIVE: #ifdef NV_EXTENSIONS - if (_parseContext.profile == EEsProfile && _parseContext.version >= 300 && - _parseContext.extensionTurnedOn(E_GL_NV_shader_noperspective_interpolation)) - return keyword; + if (_parseContext.profile == EEsProfile + && _parseContext.version >= 300 + && _parseContext.extensionTurnedOn( + E_GL_NV_shader_noperspective_interpolation)) + return keyword; #endif - return es30ReservedFromGLSL(130); + return es30ReservedFromGLSL(130); - case SMOOTH: - if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) || - (_parseContext.profile != EEsProfile && _parseContext.version < 130)) - return identifierOrType(); - return keyword; + 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 && - _parseContext.extensionTurnedOn(E_GL_AMD_shader_explicit_vertex_parameter)) - return keyword; - return identifierOrType(); + case __EXPLICITINTERPAMD: + if ( _parseContext.profile != EEsProfile + && _parseContext.version >= 450 + && _parseContext.extensionTurnedOn( + E_GL_AMD_shader_explicit_vertex_parameter)) + 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 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 CENTROID: + if (_parseContext.version < 120) + return identifierOrType(); + return keyword; - case PRECISE: - if ((_parseContext.profile == EEsProfile && - (_parseContext.version >= 320 || _parseContext.extensionsTurnedOn(Num_AEP_gpu_shader5, AEP_gpu_shader5))) || - (_parseContext.profile != EEsProfile && _parseContext.version >= 400)) - return keyword; - if (_parseContext.profile == EEsProfile && _parseContext.version == 310) { - reservedWord(); - return keyword; - } - return identifierOrType(); + case PRECISE: + if ( (_parseContext.profile == EEsProfile + && (_parseContext.version >= 320 + || _parseContext.extensionsTurnedOn( + Num_AEP_gpu_shader5, AEP_gpu_shader5))) + || (_parseContext.profile != EEsProfile + && _parseContext.version >= 400)) + return keyword; + if ( _parseContext.profile == EEsProfile + && _parseContext.version == 310) + { + reservedWord(); + return keyword; + } + return identifierOrType(); - case INVARIANT: - if (_parseContext.profile != EEsProfile && _parseContext.version < 120) - return identifierOrType(); - return keyword; + 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 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); + 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); + } + + default: + _parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc); + break; } - default: - _parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc); - return 0; - } + return 0; } int TScanContext::identifierOrType() { parserToken->sType.lex.string = NewPoolTString(tokenText); - if (field) - return IDENTIFIER; - - parserToken->sType.lex.symbol = _parseContext.symbolTable.find(*parserToken->sType.lex.string); - if ((afterType == false && afterStruct == false) && parserToken->sType.lex.symbol != NULL) { - if (const TVariable* variable = parserToken->sType.lex.symbol->getAsVariable()) { - if (variable->isUserType()) { - afterType = true; - - return TYPE_NAME; - } - } + if (!field) + { + parserToken->sType.lex.symbol = _parseContext.symbolTable.find(*parserToken->sType.lex.string); + if ((afterType == false + && afterStruct == false) + && parserToken->sType.lex.symbol) + { + if (const TVariable* variable = parserToken->sType.lex.symbol->getAsVariable()) + { + if (variable->isUserType()) + { + afterType = true; + return TYPE_NAME; + } + } + } } - return IDENTIFIER; } @@ -1545,9 +1626,9 @@ int TScanContext::reservedWord() int TScanContext::identifierOrReserved(bool reserved) { - if (reserved) { + if (reserved) + { reservedWord(); - return 0; } @@ -1564,13 +1645,20 @@ 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.profile == EEsProfile + && _parseContext.version < 300) + || (_parseContext.profile != EEsProfile + && _parseContext.version < version)) + { if (_parseContext.forwardCompatible) - _parseContext.warn(loc, "future reserved word in ES 300 and keyword in GLSL", tokenText, ""); + _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.profile == EEsProfile + && _parseContext.version >= 300) reservedWord(); return keyword; @@ -1580,8 +1668,11 @@ 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.profile == EEsProfile + && _parseContext.version < esVersion) + || (_parseContext.profile != EEsProfile + && _parseContext.version < nonEsVersion)) + { if (_parseContext.forwardCompatible) _parseContext.warn(loc, "using future keyword", tokenText, ""); @@ -1619,13 +1710,15 @@ int TScanContext::dMat() { afterType = true; - if (_parseContext.profile == EEsProfile && _parseContext.version >= 300) { + if ( _parseContext.profile == EEsProfile + && _parseContext.version >= 300) + { reservedWord(); - return keyword; } - if (_parseContext.profile != EEsProfile && _parseContext.version >= 400) + if ( _parseContext.profile != EEsProfile + && _parseContext.version >= 400) return keyword; if (_parseContext.forwardCompatible) @@ -1636,16 +1729,19 @@ int TScanContext::dMat() int TScanContext::firstGenerationImage(bool inEs310) { - if (_parseContext.symbolTable.atBuiltInLevel() || - (_parseContext.profile != EEsProfile && (_parseContext.version >= 420 || - _parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) || - (inEs310 && _parseContext.profile == EEsProfile && _parseContext.version >= 310)) + if ( _parseContext.symbolTable.atBuiltInLevel() + || (_parseContext.profile != EEsProfile + && (_parseContext.version >= 420 + || _parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) + || (inEs310 && _parseContext.profile == EEsProfile && _parseContext.version >= 310)) return keyword; - if ((_parseContext.profile == EEsProfile && _parseContext.version >= 300) || - (_parseContext.profile != EEsProfile && _parseContext.version >= 130)) { + if ( (_parseContext.profile == EEsProfile + && _parseContext.version >= 300) + || (_parseContext.profile != EEsProfile + && _parseContext.version >= 130)) + { reservedWord(); - return keyword; } @@ -1657,14 +1753,18 @@ int TScanContext::firstGenerationImage(bool inEs310) int TScanContext::secondGenerationImage() { - if (_parseContext.profile == EEsProfile && _parseContext.version >= 310) { + if ( _parseContext.profile == EEsProfile + && _parseContext.version >= 310) + { reservedWord(); return keyword; } - if (_parseContext.symbolTable.atBuiltInLevel() || - (_parseContext.profile != EEsProfile && - (_parseContext.version >= 420 || _parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store)))) + if ( _parseContext.symbolTable.atBuiltInLevel() + || (_parseContext.profile != EEsProfile + && (_parseContext.version >= 420 + || _parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) + ) return keyword; if (_parseContext.forwardCompatible) diff --git a/deps/glslang/glslang/glslang/MachineIndependent/Scan.h b/deps/glslang/glslang/glslang/MachineIndependent/Scan.h index 1c219daa7c..08286a5d3f 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/Scan.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/Scan.h @@ -107,12 +107,12 @@ public: // N.B. Sources can have a length of 0. int sourceToRead = currentSource; size_t charToRead = currentChar; - while(charToRead >= lengths[sourceToRead]) { + while(charToRead >= lengths[sourceToRead]) + { charToRead = 0; sourceToRead += 1; - if (sourceToRead >= numSources) { + if (sourceToRead >= numSources) return EndOfInput; - } } // Here, we care about making negative valued characters positive @@ -130,15 +130,16 @@ public: --currentChar; --loc[currentSource].column; --logicalSourceLoc.column; - if (loc[currentSource].column < 0) { + if (loc[currentSource].column < 0) + { // We've moved back past a new line. Find the // previous newline (or start of the file) to compute // the column count on the now current line. size_t chIndex = currentChar; - while (chIndex > 0) { - if (sources[currentSource][chIndex] == '\n') { + while (chIndex > 0) + { + if (sources[currentSource][chIndex] == '\n') break; - } --chIndex; } logicalSourceLoc.column = (int)(currentChar - chIndex); @@ -148,10 +149,10 @@ public: do { --currentSource; } while (currentSource > 0 && lengths[currentSource] == 0); - if (lengths[currentSource] == 0) { + if (lengths[currentSource] == 0) // set to 0 if we've backed up to the start of an empty string currentChar = 0; - } else + else currentChar = lengths[currentSource] - 1; } if (peek() == '\n') { @@ -207,11 +208,9 @@ public: const TSourceLoc& getSourceLoc() const { - if (singleLogical) { + if (singleLogical) return logicalSourceLoc; - } else { - return loc[std::max(0, std::min(currentSource, numSources - finale - 1))]; - } + return loc[std::max(0, std::min(currentSource, numSources - finale - 1))]; } // Returns the index (starting from 0) of the most recent valid source string we are reading from. int getLastValidSourceIndex() const { return std::min(currentSource, numSources - 1); } diff --git a/deps/glslang/glslang/glslang/MachineIndependent/ShaderLang.cpp b/deps/glslang/glslang/glslang/MachineIndependent/ShaderLang.cpp index 82c16a01ed..fa95ed95d3 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/ShaderLang.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/ShaderLang.cpp @@ -65,20 +65,23 @@ namespace { // anonymous namespace for file-local functions and symbols // Total number of successful initializers of glslang: a refcount // Shared global; access should be protected by a global mutex/critical section. -int NumberOfClients = 0; +static int NumberOfClients = 0; using namespace glslang; // Create a language specific version of parseables. -TBuiltInParseables* CreateBuiltInParseables(TInfoSink& infoSink, EShSource source) +TBuiltInParseables* CreateBuiltInParseables( + TInfoSink& infoSink, EShSource source) { - switch (source) { - case EShSourceGlsl: return new TBuiltIns(); // GLSL builtIns - - default: - infoSink.info.message(EPrefixInternalError, "Unable to determine source language"); - return NULL; + switch (source) + { + case EShSourceGlsl: + return new TBuiltIns(); // GLSL builtIns + default: + infoSink.info.message(EPrefixInternalError, "Unable to determine source language"); + break; } + return NULL; } // Create a language specific version of a parse context. @@ -1233,7 +1236,7 @@ void ShDestruct(ShHandle handle) // // Cleanup symbol tables // -int __fastcall ShFinalize() +int __fastcall ShFinalize(void) { glslang::GetGlobalLock(); --NumberOfClients; @@ -1316,15 +1319,15 @@ int ShCompile( TIntermediate intermediate(compiler->getLanguage()); TShader::ForbidIncluder includer; - bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, NULL, - "", optLevel, resources, defaultVersion, ENoProfile, false, - forwardCompatible, messages, intermediate, includer); + bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, NULL, "", optLevel, resources, defaultVersion, ENoProfile, false, + forwardCompatible, messages, intermediate, includer); - // // Call the machine dependent compiler - // - if (success && intermediate.getTreeRoot() && optLevel != EShOptNoGeneration) - success = compiler->compile(intermediate.getTreeRoot(), intermediate.getVersion(), intermediate.getProfile()); + if ( success + && intermediate.getTreeRoot() + && optLevel != EShOptNoGeneration) + success = compiler->compile(intermediate.getTreeRoot(), + intermediate.getVersion(), intermediate.getProfile()); intermediate.removeTree(); @@ -1351,13 +1354,13 @@ int ShLinkExt( THandleList cObjects; - for (int i = 0; i < numHandles; ++i) { + for (int i = 0; i < numHandles; ++i) + { if (compHandles[i] == 0) return 0; TShHandleBase* base = reinterpret_cast(compHandles[i]); - if (base->getAsLinker()) { + if (base->getAsLinker()) cObjects.push_back(base->getAsLinker()); - } if (base->getAsCompiler()) cObjects.push_back(base->getAsCompiler()); @@ -1375,33 +1378,28 @@ int ShLinkExt( linker->infoSink.info.erase(); - for (int i = 0; i < numHandles; ++i) { - if (cObjects[i]->getAsCompiler()) { - if (! cObjects[i]->getAsCompiler()->linkable()) { + for (int i = 0; i < numHandles; ++i) + { + if (cObjects[i]->getAsCompiler()) + { + if (! cObjects[i]->getAsCompiler()->linkable()) + { linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code."); return 0; } } } - bool ret = linker->link(cObjects); - - return ret ? 1 : 0; + return linker->link(cObjects) ? 1 : 0; } // // ShSetEncrpytionMethod is a place-holder for specifying // how source code is encrypted. // -void ShSetEncryptionMethod(ShHandle handle) -{ - if (handle == 0) - return; -} +void ShSetEncryptionMethod(ShHandle handle) { } -// // Return any compiler/linker/uniformmap log of messages for the application. -// const char* ShGetInfoLog(const ShHandle handle) { if (handle == 0) @@ -1536,30 +1534,19 @@ namespace glslang { #define QUOTE(s) #s #define STR(n) QUOTE(n) -const char* GetEsslVersionString() +const char* GetEsslVersionString(void) { return "OpenGL ES GLSL 3.20 glslang Khronos. " STR(GLSLANG_MINOR_VERSION) "." STR(GLSLANG_PATCH_LEVEL); } -const char* GetGlslVersionString() +const char* GetGlslVersionString(void) { return "4.60 glslang Khronos. " STR(GLSLANG_MINOR_VERSION) "." STR(GLSLANG_PATCH_LEVEL); } -int GetKhronosToolId() -{ - return 8; -} - -bool InitializeProcess() -{ - return ShInitialize() != 0; -} - -void FinalizeProcess() -{ - ShFinalize(); -} +int GetKhronosToolId(void) { return 8; } +bool InitializeProcess(void) { return ShInitialize() != 0; } +void FinalizeProcess(void) { ShFinalize(); } class TDeferredCompiler : public TCompiler { public: @@ -1598,19 +1585,20 @@ void TShader::setStrings(const char* const* s, int n) lengths = NULL; } -void TShader::setStringsWithLengths(const char* const* s, const int* l, int n) +void TShader::setStringsWithLengths( + const char* const* s, const int* l, int n) { - strings = s; - numStrings = n; - lengths = l; + strings = s; + numStrings = n; + lengths = l; } void TShader::setStringsWithLengthsAndNames( const char* const* s, const int* l, const char* const* names, int n) { - strings = s; - numStrings = n; - lengths = l; + strings = s; + numStrings = n; + lengths = l; stringNames = names; } @@ -1671,8 +1659,10 @@ void TShader::setTextureSamplerTransformMode(EShTextureSamplerTransformMode mode // // Returns true for success. // -bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile, - bool forwardCompatible, EShMessages messages, Includer& includer) +bool TShader::parse(const TBuiltInResource* builtInResources, + int defaultVersion, EProfile defaultProfile, + bool forceDefaultVersionAndProfile, + bool forwardCompatible, EShMessages messages, Includer& includer) { if (! InitThread()) return false; @@ -1682,20 +1672,20 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion preamble = ""; return CompileDeferred(compiler, strings, numStrings, lengths, stringNames, - preamble, EShOptNone, builtInResources, defaultVersion, - defaultProfile, forceDefaultVersionAndProfile, - forwardCompatible, messages, *intermediate, includer, sourceEntryPointName, - &environment); + preamble, EShOptNone, builtInResources, defaultVersion, + defaultProfile, forceDefaultVersionAndProfile, + forwardCompatible, messages, *intermediate, includer, sourceEntryPointName, + &environment); } // Fill in a string with the result of preprocessing ShaderStrings // Returns true if all extensions, pragmas and version strings were valid. bool TShader::preprocess(const TBuiltInResource* builtInResources, - int defaultVersion, EProfile defaultProfile, - bool forceDefaultVersionAndProfile, - bool forwardCompatible, EShMessages message, - std::string* output_string, - Includer& includer) + int defaultVersion, EProfile defaultProfile, + bool forceDefaultVersionAndProfile, + bool forwardCompatible, EShMessages message, + std::string* output_string, + Includer& includer) { if (! InitThread()) return false; @@ -1704,18 +1694,20 @@ bool TShader::preprocess(const TBuiltInResource* builtInResources, if (! preamble) preamble = ""; - return PreprocessDeferred(compiler, strings, numStrings, lengths, stringNames, preamble, - EShOptNone, builtInResources, defaultVersion, - defaultProfile, forceDefaultVersionAndProfile, - forwardCompatible, message, includer, *intermediate, output_string); + return PreprocessDeferred( + compiler, strings, numStrings, lengths, stringNames, preamble, + EShOptNone, builtInResources, defaultVersion, + defaultProfile, forceDefaultVersionAndProfile, + forwardCompatible, message, includer, + *intermediate, output_string); } -const char* TShader::getInfoLog() +const char* TShader::getInfoLog(void) { return infoSink->info.c_str(); } -const char* TShader::getInfoDebugLog() +const char* TShader::getInfoDebugLog(void) { return infoSink->debug.c_str(); } @@ -1724,8 +1716,9 @@ TProgram::TProgram() : reflection(0), ioMapper(NULL), linked(false) { pool = new TPoolAllocator; infoSink = new TInfoSink; - for (int s = 0; s < EShLangCount; ++s) { - intermediate[s] = 0; + for (int s = 0; s < EShLangCount; ++s) + { + intermediate[s] = 0; newedIntermediate[s] = false; } } @@ -1788,28 +1781,32 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages) numNonEsShaders++; } - if (numEsShaders > 0 && numNonEsShaders > 0) { + if (numEsShaders > 0 && numNonEsShaders > 0) + { infoSink->info.message(EPrefixError, "Cannot mix ES profile with non-ES profile shaders"); return false; - } else if (numEsShaders > 1) { + } + + if (numEsShaders > 1) + { infoSink->info.message(EPrefixError, "Cannot attach multiple ES shaders of the same type to a single program"); return false; } - // // Be efficient for the common single compilation unit per stage case, // reusing it's TIntermediate instead of merging into a new one. - // TIntermediate *firstIntermediate = stages[stage].front()->intermediate; if (stages[stage].size() == 1) intermediate[stage] = firstIntermediate; - else { + else + { intermediate[stage] = new TIntermediate(stage, - firstIntermediate->getVersion(), - firstIntermediate->getProfile()); + firstIntermediate->getVersion(), + firstIntermediate->getProfile()); - // The new TIntermediate must use the same origin as the original TIntermediates. + // The new TIntermediate must use the same + // origin as the original TIntermediates. // Otherwise linking will fail due to different coordinate systems. if (firstIntermediate->getOriginUpperLeft()) intermediate[stage]->setOriginUpperLeft(); @@ -1856,8 +1853,10 @@ bool TProgram::buildReflection(void) reflection = new TReflection; - for (int s = 0; s < EShLangCount; ++s) { - if (intermediate[s]) { + for (int s = 0; s < EShLangCount; ++s) + { + if (intermediate[s]) + { if (! reflection->addStage((EShLanguage)s, *intermediate[s])) return false; } @@ -1895,8 +1894,10 @@ bool TProgram::mapIO(TIoMapResolver* resolver) ioMapper = new TIoMapper; - for (int s = 0; s < EShLangCount; ++s) { - if (intermediate[s]) { + for (int s = 0; s < EShLangCount; ++s) + { + if (intermediate[s]) + { if (! ioMapper->addStage((EShLanguage)s, *intermediate[s], *infoSink, resolver)) return false; } diff --git a/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.cpp b/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.cpp index 21434d9e0f..0b9f9f93cb 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.cpp @@ -173,9 +173,8 @@ void TType::buildMangledName(TString& mangledName) const void TVariable::dump(TInfoSink& infoSink) const { infoSink.debug << getName().c_str() << ": " << type.getStorageQualifierString() << " " << type.getBasicTypeString(); - if (type.isArray()) { + if (type.isArray()) infoSink.debug << "[0]"; - } infoSink.debug << "\n"; } @@ -299,15 +298,13 @@ TVariable::TVariable(const TVariable& copyOf) : TSymbol(copyOf) TVariable* TVariable::clone() const { - TVariable *variable = new TVariable(*this); - - return variable; + return new TVariable(*this); } TFunction::TFunction(const TFunction& copyOf) : TSymbol(copyOf) { for (unsigned int i = 0; i < copyOf.parameters.size(); ++i) { - TParameter param; + TParameter param = {}; parameters.push_back(param); parameters.back().copyParam(copyOf.parameters[i]); } diff --git a/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h b/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h index e643347875..cce700f8d9 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h @@ -129,10 +129,8 @@ protected: int numExtensions; const char** extensions; // an array of pointers to existing constant char strings - // // N.B.: Non-const functions that will be generally used should assert on this, // to avoid overwriting shared symbol-table information. - // bool writable; }; @@ -400,8 +398,7 @@ public: // Only supporting amend of anonymous blocks so far. if (IsAnonymous(symbol.getName())) return insertAnonymousMembers(symbol, firstNewMember); - else - return false; + return false; } bool insertAnonymousMembers(TSymbol& symbol, int firstMember) @@ -421,8 +418,7 @@ public: tLevel::const_iterator it = level.find(name); if (it == level.end()) return 0; - else - return (*it).second; + return (*it).second; } void findFunctionNameList(const TString& name, TVector& list) @@ -533,12 +529,8 @@ protected: class TSymbolTable { public: - TSymbolTable() : uniqueId(0), noBuiltInRedeclarations(false), separateNameSpaces(false), adoptedLevels(0) - { - // - // This symbol table cannot be used until push() is called. - // - } + // This symbol table cannot be used until push() is called. + TSymbolTable() : uniqueId(0), noBuiltInRedeclarations(false), separateNameSpaces(false), adoptedLevels(0) { } ~TSymbolTable() { // this can be called explicitly; safest to code it so it can be called multiple times @@ -677,10 +669,8 @@ public: table[globalLevel]->insert(*copy, separateNameSpaces); if (shared->getAsVariable()) return copy; - else { - // return the copy of the anonymous member - return table[globalLevel]->find(shared->getName()); - } + // return the copy of the anonymous member + return table[globalLevel]->find(shared->getName()); } // Normal find of a symbol, that can optionally say whether the symbol was found diff --git a/deps/glslang/glslang/glslang/MachineIndependent/iomapper.cpp b/deps/glslang/glslang/glslang/MachineIndependent/iomapper.cpp index 5deb62f31f..1b8a1e8df3 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/iomapper.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/iomapper.cpp @@ -253,27 +253,26 @@ struct TResolverUniformAdaptor ent.newBinding = -1; ent.newSet = -1; ent.newIndex = -1; - const bool isValid = resolver.validateBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), - ent.live); - if (isValid) { - ent.newBinding = resolver.resolveBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), - ent.live); + const bool isValid = resolver.validateBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live); + + if (isValid) + { + ent.newBinding = resolver.resolveBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live); ent.newSet = resolver.resolveSet(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live); - ent.newLocation = resolver.resolveUniformLocation(stage, ent.symbol->getName().c_str(), - ent.symbol->getType(), ent.live); + ent.newLocation = resolver.resolveUniformLocation(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live); if (ent.newBinding != -1) { if (ent.newBinding >= int(TQualifier::layoutBindingEnd)) { - TString err = "mapped binding out of range: " + ent.symbol->getName(); - + TString err = "mapped binding out of range: " + + ent.symbol->getName(); infoSink.info.message(EPrefixInternalError, err.c_str()); error = true; } } if (ent.newSet != -1) { if (ent.newSet >= int(TQualifier::layoutSetEnd)) { - TString err = "mapped set out of range: " + ent.symbol->getName(); - + TString err = "mapped set out of range: " + + ent.symbol->getName(); infoSink.info.message(EPrefixInternalError, err.c_str()); error = true; } @@ -314,23 +313,25 @@ struct TResolverInOutAdaptor ent.newSet = -1; ent.newIndex = -1; const bool isValid = resolver.validateInOut(stage, - ent.symbol->getName().c_str(), - ent.symbol->getType(), - ent.live); + ent.symbol->getName().c_str(), + ent.symbol->getType(), + ent.live); if (isValid) { ent.newLocation = resolver.resolveInOutLocation(stage, - ent.symbol->getName().c_str(), - ent.symbol->getType(), - ent.live); + ent.symbol->getName().c_str(), + ent.symbol->getType(), + ent.live); ent.newComponent = resolver.resolveInOutComponent(stage, - ent.symbol->getName().c_str(), - ent.symbol->getType(), - ent.live); + ent.symbol->getName().c_str(), + ent.symbol->getType(), + ent.live); ent.newIndex = resolver.resolveInOutIndex(stage, - ent.symbol->getName().c_str(), - ent.symbol->getType(), - ent.live); - } else { + ent.symbol->getName().c_str(), + ent.symbol->getType(), + ent.live); + } + else + { TString errorMsg = "Invalid shader In/Out variable semantic: "; errorMsg += ent.symbol->getType().getQualifier().semanticName; infoSink.info.message(EPrefixInternalError, errorMsg.c_str()); @@ -359,37 +360,33 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver { } int getBaseBinding(TResourceType res, unsigned int set) const { - return selectBaseBinding(intermediate.getShiftBinding(res), - intermediate.getShiftBindingForSet(res, set)); + // Return descriptor set specific base if + // there is one, and the generic base otherwise. + int base = intermediate.getShiftBinding(res); + int descriptorSetBase = intermediate.getShiftBindingForSet(res, set); + return descriptorSetBase != -1 ? descriptorSetBase : base; } const std::vector& getResourceSetBinding() const { return intermediate.getResourceSetBinding(); } - bool doAutoBindingMapping() const { return intermediate.getAutoMapBindings(); } - bool doAutoLocationMapping() const { return intermediate.getAutoMapLocations(); } - typedef std::vector TSlotSet; typedef std::unordered_map TSlotSetMap; TSlotSetMap slots; - TSlotSet::iterator findSlot(int set, int slot) - { - return std::lower_bound(slots[set].begin(), slots[set].end(), slot); - } - bool checkEmpty(int set, int slot) { - TSlotSet::iterator at = findSlot(set, slot); + TSlotSet::iterator at = std::lower_bound(slots[set].begin(), slots[set].end(), slot); return !(at != slots[set].end() && *at == slot); } int reserveSlot(int set, int slot, int size = 1) { - TSlotSet::iterator at = findSlot(set, slot); + TSlotSet::iterator at = std::lower_bound(slots[set].begin(), slots[set].end(), slot); // tolerate aliasing, by not double-recording aliases // (policy about appropriateness of the alias is higher up) - for (int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) + { if (at == slots[set].end() || *at != slot + i) at = slots[set].insert(at, slot + i); ++at; @@ -400,12 +397,13 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver int getFreeSlot(int set, int base, int size = 1) { - TSlotSet::iterator at = findSlot(set, base); + TSlotSet::iterator at = std::lower_bound(slots[set].begin(), slots[set].end(), base); if (at == slots[set].end()) return reserveSlot(set, base, size); // look for a big enough gap - for (; at != slots[set].end(); ++at) { + for (; at != slots[set].end(); ++at) + { if (*at - base >= size) break; base = *at + 1; @@ -417,7 +415,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver virtual int resolveBinding(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& type, bool is_live) override = 0; - int resolveSet(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& type, bool /*is_live*/) override + int resolveSet(EShLanguage stage, const char* name, const glslang::TType& type, bool is_live) override { if (type.getQualifier().hasSet()) return type.getQualifier().layoutSet; @@ -428,21 +426,24 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver return 0; } - int resolveUniformLocation(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& type, bool /*is_live*/) override + int resolveUniformLocation(EShLanguage stage, const char* name, const glslang::TType& type, bool is_live) override { // kick out of not doing this - if (!doAutoLocationMapping()) + if (!intermediate.getAutoMapLocations()) return -1; - // no locations added if already present, a built-in variable, a block, or an opaque - if (type.getQualifier().hasLocation() || type.isBuiltIn() || - type.getBasicType() == EbtBlock || - type.getBasicType() == EbtAtomicUint || - (type.containsOpaque() && intermediate.getSpv().openGl == 0)) + // no locations added if already present, + // a built-in variable, a block, or an opaque + if ( type.getQualifier().hasLocation() + || type.isBuiltIn() + || type.getBasicType() == EbtBlock + || type.getBasicType() == EbtAtomicUint + || (type.containsOpaque() && intermediate.getSpv().openGl == 0)) return -1; // no locations on blocks of built-in variables - if (type.isStruct()) { + if (type.isStruct()) + { if (type.getStruct()->size() < 1) return -1; if ((*type.getStruct())[0].type->isBuiltIn()) @@ -455,14 +456,16 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver return location; } - bool validateInOut(EShLanguage /*stage*/, const char* /*name*/, const TType& /*type*/, bool /*is_live*/) override + + bool validateInOut(EShLanguage stage, const char* name, const TType& type, bool is_live) override { return true; } - int resolveInOutLocation(EShLanguage stage, const char* /*name*/, const TType& type, bool /*is_live*/) override + + int resolveInOutLocation(EShLanguage stage, const char* name, const TType& type, bool is_live) override { // kick out of not doing this - if (!doAutoLocationMapping()) + if (!intermediate.getAutoMapLocations()) return -1; // no locations added if already present, or a built-in variable @@ -470,7 +473,8 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver return -1; // no locations on blocks of built-in variables - if (type.isStruct()) { + if (type.isStruct()) + { if (type.getStruct()->size() < 1) return -1; if ((*type.getStruct())[0].type->isBuiltIn()) @@ -486,27 +490,30 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver int typeLocationSize; // Don’t take into account the outer-most array if the stage’s // interface is automatically an array. - if (type.getQualifier().isArrayedIo(stage)) { + if (type.getQualifier().isArrayedIo(stage)) + { TType elementType(type, 0); typeLocationSize = TIntermediate::computeTypeLocationSize(elementType, stage); - } else { - typeLocationSize = TIntermediate::computeTypeLocationSize(type, stage); } + else + typeLocationSize = TIntermediate::computeTypeLocationSize(type, stage); nextLocation += typeLocationSize; return location; } - int resolveInOutComponent(EShLanguage /*stage*/, const char* /*name*/, const TType& /*type*/, bool /*is_live*/) override - { - return -1; - } - int resolveInOutIndex(EShLanguage /*stage*/, const char* /*name*/, const TType& /*type*/, bool /*is_live*/) override + + int resolveInOutComponent(EShLanguage stage, const char* name, const TType& type, bool is_live) override { return -1; } - void notifyBinding(EShLanguage, const char* /*name*/, const TType&, bool /*is_live*/) override {} - void notifyInOut(EShLanguage, const char* /*name*/, const TType&, bool /*is_live*/) override {} + int resolveInOutIndex(EShLanguage stage, const char* name, const TType& type, bool is_live) override + { + return -1; + } + + void notifyBinding(EShLanguage, const char* name, const TType&, bool is_live) override {} + void notifyInOut(EShLanguage, const char* name, const TType&, bool is_live) override {} void endNotifications(EShLanguage) override {} void beginNotifications(EShLanguage) override {} void beginResolve(EShLanguage) override {} @@ -518,30 +525,10 @@ protected: int nextInputLocation; int nextOutputLocation; - // Return descriptor set specific base if there is one, and the generic base otherwise. - int selectBaseBinding(int base, int descriptorSetBase) const { - return descriptorSetBase != -1 ? descriptorSetBase : base; - } - - static int getLayoutSet(const glslang::TType& type) { - if (type.getQualifier().hasSet()) - return type.getQualifier().layoutSet; - else - return 0; - } - - static bool isSamplerType(const glslang::TType& type) { - return type.getBasicType() == glslang::EbtSampler && type.getSampler().isPureSampler(); - } - static bool isTextureType(const glslang::TType& type) { return (type.getBasicType() == glslang::EbtSampler && (type.getSampler().isTexture() || type.getSampler().isSubpass())); } - - static bool isUboType(const glslang::TType& type) { - return type.getQualifier().storage == EvqUniform; - } }; /* @@ -558,63 +545,57 @@ struct TDefaultIoResolver : public TDefaultIoResolverBase { TDefaultIoResolver(const TIntermediate &intermediate) : TDefaultIoResolverBase(intermediate) { } - bool validateBinding(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& /*type*/, bool /*is_live*/) override + bool validateBinding(EShLanguage stage, const char* name, const glslang::TType& type, bool is_live) override { return true; } - int resolveBinding(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& type, bool is_live) override + int resolveBinding(EShLanguage stage, const char* name, const glslang::TType& type, bool is_live) override { - const int set = getLayoutSet(type); + const int set = (type.getQualifier().hasSet()) ? type.getQualifier().layoutSet : 0; // On OpenGL arrays of opaque types take a seperate binding for each element int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1; - if (type.getQualifier().hasBinding()) { - if (isImageType(type)) + if (type.getQualifier().hasBinding()) + { + if (type.getBasicType() == glslang::EbtSampler && type.getSampler().isImage()) return reserveSlot(set, getBaseBinding(EResImage, set) + type.getQualifier().layoutBinding, numBindings); if (isTextureType(type)) return reserveSlot(set, getBaseBinding(EResTexture, set) + type.getQualifier().layoutBinding, numBindings); - if (isSsboType(type)) + if (type.getQualifier().storage == EvqBuffer) return reserveSlot(set, getBaseBinding(EResSsbo, set) + type.getQualifier().layoutBinding, numBindings); - if (isSamplerType(type)) + if (type.getBasicType() == glslang::EbtSampler && type.getSampler().isPureSampler()) return reserveSlot(set, getBaseBinding(EResSampler, set) + type.getQualifier().layoutBinding, numBindings); - if (isUboType(type)) + if (type.getQualifier().storage == EvqUniform) return reserveSlot(set, getBaseBinding(EResUbo, set) + type.getQualifier().layoutBinding, numBindings); - } else if (is_live && doAutoBindingMapping()) { + } + else if (is_live && intermediate.getAutoMapBindings()) + { // find free slot, the caller did make sure it passes all vars with binding // first and now all are passed that do not have a binding and needs one - if (isImageType(type)) + if (type.getBasicType() == glslang::EbtSampler && type.getSampler().isImage()) return getFreeSlot(set, getBaseBinding(EResImage, set), numBindings); if (isTextureType(type)) return getFreeSlot(set, getBaseBinding(EResTexture, set), numBindings); - if (isSsboType(type)) + if (type.getQualifier().storage == EvqBuffer) return getFreeSlot(set, getBaseBinding(EResSsbo, set), numBindings); - if (isSamplerType(type)) + if (type.getBasicType() == glslang::EbtSampler && type.getSampler().isPureSampler()) return getFreeSlot(set, getBaseBinding(EResSampler, set), numBindings); - if (isUboType(type)) + if (type.getQualifier().storage == EvqUniform) return getFreeSlot(set, getBaseBinding(EResUbo, set), numBindings); } return -1; } - -protected: - static bool isImageType(const glslang::TType& type) { - return type.getBasicType() == glslang::EbtSampler && type.getSampler().isImage(); - } - - static bool isSsboType(const glslang::TType& type) { - return type.getQualifier().storage == EvqBuffer; - } }; /******************************************************************************** @@ -671,34 +652,37 @@ struct TDefaultHlslIoResolver : public TDefaultIoResolverBase int resolveBinding(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& type, bool is_live) override { - const int set = getLayoutSet(type); + const int set = (type.getQualifier().hasSet()) ? type.getQualifier().layoutSet : 0; - if (type.getQualifier().hasBinding()) { + if (type.getQualifier().hasBinding()) + { if (isUavType(type)) return reserveSlot(set, getBaseBinding(EResUav, set) + type.getQualifier().layoutBinding); - if (isSrvType(type)) + if (isTextureType(type) || type.getQualifier().storage == EvqBuffer) return reserveSlot(set, getBaseBinding(EResTexture, set) + type.getQualifier().layoutBinding); - if (isSamplerType(type)) + if (type.getBasicType() == glslang::EbtSampler && type.getSampler().isPureSampler()) return reserveSlot(set, getBaseBinding(EResSampler, set) + type.getQualifier().layoutBinding); - if (isUboType(type)) + if (type.getQualifier().storage == EvqUniform) return reserveSlot(set, getBaseBinding(EResUbo, set) + type.getQualifier().layoutBinding); - } else if (is_live && doAutoBindingMapping()) { + } + else if (is_live && intermediate.getAutoMapBindings()) + { // find free slot, the caller did make sure it passes all vars with binding // first and now all are passed that do not have a binding and needs one if (isUavType(type)) return getFreeSlot(set, getBaseBinding(EResUav, set)); - if (isSrvType(type)) + if (isTextureType(type) || type.getQualifier().storage == EvqBuffer) return getFreeSlot(set, getBaseBinding(EResTexture, set)); - if (isSamplerType(type)) + if (type.getBasicType() == glslang::EbtSampler && type.getSampler().isPureSampler()) return getFreeSlot(set, getBaseBinding(EResSampler, set)); - if (isUboType(type)) + if (type.getQualifier().storage == EvqUniform) return getFreeSlot(set, getBaseBinding(EResUbo, set)); } @@ -706,18 +690,13 @@ struct TDefaultHlslIoResolver : public TDefaultIoResolverBase } protected: - // Return true if this is a SRV (shader resource view) type: - static bool isSrvType(const glslang::TType& type) { - return isTextureType(type) || type.getQualifier().storage == EvqBuffer; - } - // Return true if this is a UAV (unordered access view) type: static bool isUavType(const glslang::TType& type) { if (type.getQualifier().readonly) return false; - - return (type.getBasicType() == glslang::EbtSampler && type.getSampler().isImage()) || - (type.getQualifier().storage == EvqBuffer); + return ( type.getBasicType() == glslang::EbtSampler + && type.getSampler().isImage()) + || (type.getQualifier().storage == EvqBuffer); } }; @@ -728,14 +707,16 @@ protected: // Returns false if the input is too malformed to do this. bool TIoMapper::addStage(EShLanguage stage, TIntermediate &intermediate, TInfoSink &infoSink, TIoMapResolver *resolver) { - bool somethingToDo = !intermediate.getResourceSetBinding().empty() || - intermediate.getAutoMapBindings() || - intermediate.getAutoMapLocations(); + bool somethingToDo = + !intermediate.getResourceSetBinding().empty() + || intermediate.getAutoMapBindings() + || intermediate.getAutoMapLocations(); - for (int res = 0; res < EResCount; ++res) { - somethingToDo = somethingToDo || - (intermediate.getShiftBinding(TResourceType(res)) != 0) || - intermediate.hasShiftBindingForSet(TResourceType(res)); + for (int res = 0; res < EResCount; ++res) + { + somethingToDo = somethingToDo + || (intermediate.getShiftBinding(TResourceType(res)) != 0) + || intermediate.hasShiftBindingForSet(TResourceType(res)); } if (!somethingToDo && resolver == NULL) diff --git a/deps/glslang/glslang/glslang/MachineIndependent/localintermediate.h b/deps/glslang/glslang/glslang/MachineIndependent/localintermediate.h index 26bc15c061..e8e81a67f7 100755 --- a/deps/glslang/glslang/glslang/MachineIndependent/localintermediate.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/localintermediate.h @@ -267,7 +267,7 @@ public: shiftBinding[res] = shift; const char* name = getResourceName(res); - if (name != NULL) + if (name) processes.addIfNonZero(name, shift); } diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp index fc68f91879..56c55634a8 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp @@ -104,10 +104,9 @@ int TPpContext::CPPdefine(TPpToken* ppToken) _parseContext.ppError(ppToken->loc, "must be followed by macro name", "#define", ""); return token; } - if (ppToken->loc.string >= 0) { - // We are in user code; check for reserved name use: + // We are in user code; check for reserved name use: + if (ppToken->loc.string >= 0) _parseContext.reservedPpErrorCheck(ppToken->loc, ppToken->name, "#define"); - } // save the macro name const int defAtom = atomStrings.getAddAtom(ppToken->name); @@ -120,18 +119,22 @@ int TPpContext::CPPdefine(TPpToken* ppToken) token = scanToken(ppToken); if (mac.args.size() == 0 && token == ')') break; - if (token != PpAtomIdentifier) { + if (token != PpAtomIdentifier) + { _parseContext.ppError(ppToken->loc, "bad argument", "#define", ""); return token; } + mac.emptyArgs = 0; const int argAtom = atomStrings.getAddAtom(ppToken->name); // check for duplication of parameter name bool duplicate = false; - for (size_t a = 0; a < mac.args.size(); ++a) { - if (mac.args[a] == argAtom) { + for (size_t a = 0; a < mac.args.size(); ++a) + { + if (mac.args[a] == argAtom) + { _parseContext.ppError(ppToken->loc, "duplicate macro parameter", "#define", ""); duplicate = true; break; @@ -141,7 +144,9 @@ int TPpContext::CPPdefine(TPpToken* ppToken) mac.args.push_back(argAtom); token = scanToken(ppToken); } while (token == ','); - if (token != ')') { + + if (token != ')') + { _parseContext.ppError(ppToken->loc, "missing parenthesis", "#define", ""); return token; @@ -152,7 +157,8 @@ int TPpContext::CPPdefine(TPpToken* ppToken) // record the definition of the macro TSourceLoc defineLoc = ppToken->loc; // because ppToken is going to go to the next line before we report errors - while (token != '\n' && token != EndOfInput) { + while (token != '\n' && token != EndOfInput) + { mac.body.putToken(token, ppToken); token = scanToken(ppToken); if (token != '\n' && ppToken->space) @@ -161,14 +167,17 @@ int TPpContext::CPPdefine(TPpToken* ppToken) // check for duplicate definition MacroSymbol* existing = lookupMacroDef(defAtom); - if (existing != NULL) { - if (! existing->undef) { + if (existing != NULL) + { + if (! existing->undef) + { // Already defined -- need to make sure they are identical: // "Two replacement lists are identical if and only if the preprocessing tokens in both have the same number, // ordering, spelling, and white-space separation, where all white-space separations are considered identical." if (existing->args.size() != mac.args.size() || existing->emptyArgs != mac.emptyArgs) _parseContext.ppError(defineLoc, "Macro redefined; different number of arguments:", "#define", atomStrings.getString(defAtom)); - else { + else + { if (existing->args != mac.args) _parseContext.ppError(defineLoc, "Macro redefined; different argument names:", "#define", atomStrings.getString(defAtom)); existing->body.reset(); @@ -180,7 +189,8 @@ int TPpContext::CPPdefine(TPpToken* ppToken) TPpToken newPpToken; oldToken = existing->body.getToken(_parseContext, &oldPpToken); newToken = mac.body.getToken(_parseContext, &newPpToken); - if (oldToken != newToken || oldPpToken != newPpToken) { + if (oldToken != newToken || oldPpToken != newPpToken) + { _parseContext.ppError(defineLoc, "Macro redefined; different substitutions:", "#define", atomStrings.getString(defAtom)); break; } @@ -198,7 +208,8 @@ int TPpContext::CPPdefine(TPpToken* ppToken) int TPpContext::CPPundef(TPpToken* ppToken) { int token = scanToken(ppToken); - if (token != PpAtomIdentifier) { + if (token != PpAtomIdentifier) + { _parseContext.ppError(ppToken->loc, "must be followed by macro name", "#undef", ""); return token; @@ -207,7 +218,7 @@ int TPpContext::CPPundef(TPpToken* ppToken) _parseContext.reservedPpErrorCheck(ppToken->loc, ppToken->name, "#undef"); MacroSymbol* macro = lookupMacroDef(atomStrings.getAtom(ppToken->name)); - if (macro != NULL) + if (macro) macro->undef = 1; token = scanToken(ppToken); if (token != '\n') @@ -226,8 +237,10 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken) int depth = 0; int token = scanToken(ppToken); - while (token != EndOfInput) { - if (token != '#') { + while (token != EndOfInput) + { + if (token != '#') + { while (token != '\n' && token != EndOfInput) token = scanToken(ppToken); @@ -242,20 +255,25 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken) continue; int nextAtom = atomStrings.getAtom(ppToken->name); - if (nextAtom == PpAtomIf || nextAtom == PpAtomIfdef || nextAtom == PpAtomIfndef) { + if (nextAtom == PpAtomIf || nextAtom == PpAtomIfdef || nextAtom == PpAtomIfndef) + { depth++; - if (ifdepth >= maxIfNesting || elsetracker >= maxIfNesting) { + if (ifdepth >= maxIfNesting || elsetracker >= maxIfNesting) + { _parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#if/#ifdef/#ifndef", ""); return EndOfInput; - } else { - ifdepth++; - elsetracker++; } - } else if (nextAtom == PpAtomEndif) { + + ifdepth++; + elsetracker++; + } + else if (nextAtom == PpAtomEndif) + { token = extraTokenCheck(nextAtom, ppToken, scanToken(ppToken)); elseSeen[elsetracker] = false; --elsetracker; - if (depth == 0) { + if (depth == 0) + { // found the #endif we are looking for if (ifdepth > 0) --ifdepth; @@ -263,18 +281,24 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken) } --depth; --ifdepth; - } else if (matchelse && depth == 0) { - if (nextAtom == PpAtomElse) { + } + else if (matchelse && depth == 0) + { + if (nextAtom == PpAtomElse) + { elseSeen[elsetracker] = true; token = extraTokenCheck(nextAtom, ppToken, scanToken(ppToken)); // found the #else we are looking for break; - } else if (nextAtom == PpAtomElif) { + } + else if (nextAtom == PpAtomElif) + { if (elseSeen[elsetracker]) _parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", ""); /* we decrement ifdepth here, because CPPif will increment * it and we really want to leave it alone */ - if (ifdepth > 0) { + if (ifdepth > 0) + { --ifdepth; elseSeen[elsetracker] = false; --elsetracker; @@ -282,13 +306,17 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken) return CPPif(ppToken); } - } else if (nextAtom == PpAtomElse) { + } + else if (nextAtom == PpAtomElse) + { if (elseSeen[elsetracker]) _parseContext.ppError(ppToken->loc, "#else after #else", "#else", ""); else elseSeen[elsetracker] = true; token = extraTokenCheck(nextAtom, ppToken, scanToken(ppToken)); - } else if (nextAtom == PpAtomElif) { + } + else if (nextAtom == PpAtomElif) + { if (elseSeen[elsetracker]) _parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", ""); } @@ -300,30 +328,30 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken) // Call when there should be no more tokens left on a line. int TPpContext::extraTokenCheck(int contextAtom, TPpToken* ppToken, int token) { - if (token != '\n' && token != EndOfInput) { - static const char* message = "unexpected tokens following directive"; + if (token != '\n' && token != EndOfInput) + { + static const char* message = "unexpected tokens following directive"; + const char* label; + if (contextAtom == PpAtomElse) + label = "#else"; + else if (contextAtom == PpAtomElif) + label = "#elif"; + else if (contextAtom == PpAtomEndif) + label = "#endif"; + else if (contextAtom == PpAtomIf) + label = "#if"; + else if (contextAtom == PpAtomLine) + label = "#line"; + else + label = ""; - const char* label; - if (contextAtom == PpAtomElse) - label = "#else"; - else if (contextAtom == PpAtomElif) - label = "#elif"; - else if (contextAtom == PpAtomEndif) - label = "#endif"; - else if (contextAtom == PpAtomIf) - label = "#if"; - else if (contextAtom == PpAtomLine) - label = "#line"; - else - label = ""; + if (_parseContext.relaxedErrors()) + _parseContext.ppWarn(ppToken->loc, message, label, ""); + else + _parseContext.ppError(ppToken->loc, message, label, ""); - if (_parseContext.relaxedErrors()) - _parseContext.ppWarn(ppToken->loc, message, label, ""); - else - _parseContext.ppError(ppToken->loc, message, label, ""); - - while (token != '\n' && token != EndOfInput) - token = scanToken(ppToken); + while (token != '\n' && token != EndOfInput) + token = scanToken(ppToken); } return token; @@ -565,20 +593,24 @@ int TPpContext::CPPif(TPpToken* ppToken) int TPpContext::CPPifdef(int defined, TPpToken* ppToken) { int token = scanToken(ppToken); - if (ifdepth > maxIfNesting || elsetracker > maxIfNesting) { + if (ifdepth > maxIfNesting || elsetracker > maxIfNesting) + { _parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#ifdef", ""); return EndOfInput; - } else { - elsetracker++; - ifdepth++; } - if (token != PpAtomIdentifier) { + elsetracker++; + ifdepth++; + + if (token != PpAtomIdentifier) + { if (defined) _parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifdef", ""); else _parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifndef", ""); - } else { + } + else + { MacroSymbol* macro = lookupMacroDef(atomStrings.getAtom(ppToken->name)); token = scanToken(ppToken); if (token != '\n') { @@ -732,18 +764,18 @@ int TPpContext::CPPerror(TPpToken* ppToken) std::string message; TSourceLoc loc = ppToken->loc; - while (token != '\n' && token != EndOfInput) { + while (token != '\n' && token != EndOfInput) + { if (token == PpAtomConstInt16 || token == PpAtomConstUint16 || token == PpAtomConstInt || token == PpAtomConstUint || token == PpAtomConstInt64 || token == PpAtomConstUint64 || token == PpAtomConstFloat16 || - token == PpAtomConstFloat || token == PpAtomConstDouble) { + token == PpAtomConstFloat || token == PpAtomConstDouble) message.append(ppToken->name); - } else if (token == PpAtomIdentifier || token == PpAtomConstString) { + else if (token == PpAtomIdentifier || token == PpAtomConstString) message.append(ppToken->name); - } else { + else message.append(atomStrings.getString(token)); - } message.append(" "); token = scanToken(ppToken); } @@ -807,7 +839,8 @@ int TPpContext::CPPversion(TPpToken* ppToken) } versionSeen = true; - if (token == '\n') { + if (token == '\n') + { _parseContext.ppError(ppToken->loc, "must be followed by version number", "#version", ""); return token; @@ -821,10 +854,13 @@ int TPpContext::CPPversion(TPpToken* ppToken) int line = ppToken->loc.line; token = scanToken(ppToken); - if (token == '\n') { + if (token == '\n') + { _parseContext.notifyVersion(line, versionNumber, NULL); return token; - } else { + } + else + { int profileAtom = atomStrings.getAtom(ppToken->name); if (profileAtom != PpAtomCore && profileAtom != PpAtomCompatibility && @@ -835,8 +871,7 @@ int TPpContext::CPPversion(TPpToken* ppToken) if (token == '\n') return token; - else - _parseContext.ppError(ppToken->loc, "bad tokens following profile -- expected newline", "#version", ""); + _parseContext.ppError(ppToken->loc, "bad tokens following profile -- expected newline", "#version", ""); } return token; @@ -860,13 +895,15 @@ int TPpContext::CPPextension(TPpToken* ppToken) strcpy(extensionName, ppToken->name); token = scanToken(ppToken); - if (token != ':') { + if (token != ':') + { _parseContext.ppError(ppToken->loc, "':' missing after extension name", "#extension", ""); return token; } token = scanToken(ppToken); - if (token != PpAtomIdentifier) { + if (token != PpAtomIdentifier) + { _parseContext.ppError(ppToken->loc, "behavior for extension not specified", "#extension", ""); return token; } @@ -877,8 +914,8 @@ int TPpContext::CPPextension(TPpToken* ppToken) token = scanToken(ppToken); if (token == '\n') return token; - else - _parseContext.ppError(ppToken->loc, "extra tokens -- expected newline", "#extension",""); + + _parseContext.ppError(ppToken->loc, "extra tokens -- expected newline", "#extension",""); return token; } @@ -980,16 +1017,19 @@ int TPpContext::scanHeaderName(TPpToken* ppToken, char delimit) int len = 0; ppToken->name[0] = '\0'; - do { + for (;;) + { int ch = inputStack.back()->getch(); // done yet? - if (ch == delimit) { + if (ch == delimit) + { ppToken->name[len] = '\0'; if (tooLong) _parseContext.ppError(ppToken->loc, "header name too long", "", ""); return PpAtomConstString; - } else if (ch == EndOfInput) + } + else if (ch == EndOfInput) return EndOfInput; // found a character to expand the name with @@ -997,7 +1037,7 @@ int TPpContext::scanHeaderName(TPpToken* ppToken, char delimit) ppToken->name[len++] = (char)ch; else tooLong = true; - } while (true); + } } // Macro-expand a macro argument 'arg' to create 'expandedArg'. @@ -1010,7 +1050,8 @@ TPpContext::TokenStream* TPpContext::PrescanMacroArg(TokenStream& arg, TPpToken* pushInput(new tMarkerInput(this)); pushTokenStreamInput(arg); int token; - while ((token = scanToken(ppToken)) != tMarkerInput::marker && token != EndOfInput) { + while ((token = scanToken(ppToken)) != tMarkerInput::marker && token != EndOfInput) + { token = tokenPaste(token, *ppToken); if (token == tMarkerInput::marker || token == EndOfInput) break; @@ -1019,14 +1060,14 @@ TPpContext::TokenStream* TPpContext::PrescanMacroArg(TokenStream& arg, TPpToken* expandedArg->putToken(token, ppToken); } - if (token == EndOfInput) { + if (token == EndOfInput) + { // MacroExpand ate the marker, so had bad input, recover delete expandedArg; expandedArg = NULL; - } else { - // remove the marker - popInput(); } + else // remove the marker + popInput(); return expandedArg; } @@ -1056,13 +1097,15 @@ int TPpContext::tMacroInput::scan(TPpToken* ppToken) // corresponding argument's preprocessing token sequence." bool pasting = false; - if (postpaste) { + if (postpaste) + { // don't expand next token pasting = true; postpaste = false; } - if (prepaste) { + if (prepaste) + { // already know we should be on a ##, verify prepaste = false; postpaste = true; diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp index 8d71dc9b8c..f37cb6d347 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp @@ -164,7 +164,8 @@ TStringAtomMap::TStringAtomMap() char t[2]; t[1] = '\0'; - while (*s) { + while (*s) + { t[0] = *s; addAtomFixed(t, s[0]); s++; diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp index 613a799d88..ff76035743 100755 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp @@ -334,8 +334,7 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken) return PpAtomConstDouble; else if (isFloat16) return PpAtomConstFloat16; - else - return PpAtomConstFloat; + return PpAtomConstFloat; } // Recognize a character literal. @@ -349,10 +348,9 @@ int TPpContext::characterLiteral(TPpToken* ppToken) ppToken->name[0] = 0; ppToken->ival = 0; - if (_parseContext.intermediate.getSource() != EShSourceHlsl) { - // illegal, except in macro definition, for which case we report the character + // illegal, except in macro definition, for which case we report the character + if (_parseContext.intermediate.getSource() != EShSourceHlsl) return '\''; - } int ch = getChar(); switch (ch) { @@ -446,7 +444,8 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) ppToken->i64val = 0; ppToken->space = false; ch = getch(); - for (;;) { + for (;;) + { while (ch == ' ' || ch == '\t') { ppToken->space = true; ch = getch(); @@ -850,49 +849,37 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) } case '*': ch = getch(); - if (ch == '=') { + if (ch == '=') return PPAtomMulAssign; - } else { - ungetch(); - return '*'; - } + ungetch(); + return '*'; case '%': ch = getch(); - if (ch == '=') { + if (ch == '=') return PPAtomModAssign; - } else { - ungetch(); - return '%'; - } + ungetch(); + return '%'; case '^': ch = getch(); - if (ch == '^') { + if (ch == '^') return PpAtomXor; - } else { - if (ch == '=') - return PpAtomXorAssign; - else{ - ungetch(); - return '^'; - } - } + if (ch == '=') + return PpAtomXorAssign; + ungetch(); + return '^'; case '=': ch = getch(); - if (ch == '=') { + if (ch == '=') return PpAtomEQ; - } else { - ungetch(); - return '='; - } + ungetch(); + return '='; case '!': ch = getch(); - if (ch == '=') { + if (ch == '=') return PpAtomNE; - } else { - ungetch(); - return '!'; - } + ungetch(); + return '!'; case '|': ch = getch(); if (ch == '|') { @@ -1043,14 +1030,18 @@ int TPpContext::tokenize(TPpToken& ppToken) return EndOfInput; } if (token == '#') { - if (previous_token == '\n') { + if (previous_token == '\n') + { token = readCPPline(&ppToken); - if (token == EndOfInput) { + if (token == EndOfInput) + { missingEndifCheck(); return EndOfInput; } continue; - } else { + } + else + { _parseContext.ppError(ppToken.loc, "preprocessor directive cannot be preceded by another token", "#", ""); return EndOfInput; } @@ -1105,7 +1096,8 @@ int TPpContext::tokenize(TPpToken& ppToken) int TPpContext::tokenPaste(int token, TPpToken& ppToken) { // starting with ## is illegal, skip to next token - if (token == PpAtomPaste) { + if (token == PpAtomPaste) + { _parseContext.ppError(ppToken.loc, "unexpected location", "##", ""); return scanToken(&ppToken); } @@ -1113,14 +1105,16 @@ int TPpContext::tokenPaste(int token, TPpToken& ppToken) int resultToken = token; // "foo" pasted with "35" is an identifier, not a number // ## can be chained, process all in the chain at once - while (peekPasting()) { + while (peekPasting()) + { TPpToken pastedPpToken; // next token has to be ## token = scanToken(&pastedPpToken); // This covers end of macro expansion - if (endOfReplacementList()) { + if (endOfReplacementList()) + { _parseContext.ppError(ppToken.loc, "unexpected location; end of replacement list", "##", ""); break; } @@ -1135,35 +1129,36 @@ int TPpContext::tokenPaste(int token, TPpToken& ppToken) } // get the token text - switch (resultToken) { - case PpAtomIdentifier: - // already have the correct text in token.names - break; - case '=': - case '!': - case '-': - case '~': - case '+': - case '*': - case '/': - case '%': - case '<': - case '>': - case '|': - case '^': - case '&': - case PpAtomRight: - case PpAtomLeft: - case PpAtomAnd: - case PpAtomOr: - case PpAtomXor: - strcpy(ppToken.name, atomStrings.getString(resultToken)); - strcpy(pastedPpToken.name, atomStrings.getString(token)); - break; - default: - _parseContext.ppError(ppToken.loc, "not supported for these tokens", "##", ""); - return resultToken; - } + switch (resultToken) + { + case PpAtomIdentifier: + // already have the correct text in token.names + break; + case '=': + case '!': + case '-': + case '~': + case '+': + case '*': + case '/': + case '%': + case '<': + case '>': + case '|': + case '^': + case '&': + case PpAtomRight: + case PpAtomLeft: + case PpAtomAnd: + case PpAtomOr: + case PpAtomXor: + strcpy(ppToken.name, atomStrings.getString(resultToken)); + strcpy(pastedPpToken.name, atomStrings.getString(token)); + break; + default: + _parseContext.ppError(ppToken.loc, "not supported for these tokens", "##", ""); + return resultToken; + } // combine the tokens if (strlen(ppToken.name) + strlen(pastedPpToken.name) > MaxTokenLength) { @@ -1173,7 +1168,8 @@ int TPpContext::tokenPaste(int token, TPpToken& ppToken) strncat(ppToken.name, pastedPpToken.name, MaxTokenLength - strlen(ppToken.name)); // correct the kind of token we are making, if needed (identifiers stay identifiers) - if (resultToken != PpAtomIdentifier) { + if (resultToken != PpAtomIdentifier) + { int newToken = atomStrings.getAtom(ppToken.name); if (newToken > 0) resultToken = newToken; diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp index d20bbe70b8..5c887c43d3 100755 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp @@ -105,46 +105,50 @@ namespace { // be saved (restored)? bool SaveName(int atom) { - switch (atom) { - case PpAtomIdentifier: - case PpAtomConstString: - case PpAtomConstInt: - case PpAtomConstUint: - case PpAtomConstInt64: - case PpAtomConstUint64: - #ifdef AMD_EXTENSIONS - case PpAtomConstInt16: - case PpAtomConstUint16: - #endif - case PpAtomConstFloat: - case PpAtomConstDouble: - case PpAtomConstFloat16: - return true; - default: - return false; - } + switch (atom) + { + case PpAtomIdentifier: + case PpAtomConstString: + case PpAtomConstInt: + case PpAtomConstUint: + case PpAtomConstInt64: + case PpAtomConstUint64: +#ifdef AMD_EXTENSIONS + case PpAtomConstInt16: + case PpAtomConstUint16: +#endif + case PpAtomConstFloat: + case PpAtomConstDouble: + case PpAtomConstFloat16: + return true; + default: + break; + } + return false; } // When recording (and playing back) should the numeric value // be saved (restored)? bool SaveValue(int atom) { - switch (atom) { - case PpAtomConstInt: - case PpAtomConstUint: - case PpAtomConstInt64: - case PpAtomConstUint64: - #ifdef AMD_EXTENSIONS - case PpAtomConstInt16: - case PpAtomConstUint16: - #endif - case PpAtomConstFloat: - case PpAtomConstDouble: - case PpAtomConstFloat16: - return true; - default: - return false; - } + switch (atom) + { + case PpAtomConstInt: + case PpAtomConstUint: + case PpAtomConstInt64: + case PpAtomConstUint64: +#ifdef AMD_EXTENSIONS + case PpAtomConstInt16: + case PpAtomConstUint16: +#endif + case PpAtomConstFloat: + case PpAtomConstDouble: + case PpAtomConstFloat16: + return true; + default: + break; + } + return false; } } @@ -178,7 +182,8 @@ void TPpContext::TokenStream::putToken(int atom, TPpToken* ppToken) putSubtoken(static_cast(atom)); // save the backing name string - if (SaveName(atom)) { + if (SaveName(atom)) + { const char* s = ppToken->name; while (*s) putSubtoken(*s++); @@ -186,7 +191,8 @@ void TPpContext::TokenStream::putToken(int atom, TPpToken* ppToken) } // save the numeric value - if (SaveValue(atom)) { + if (SaveValue(atom)) + { const char* n = reinterpret_cast(&ppToken->i64val); for (size_t i = 0; i < sizeof(ppToken->i64val); ++i) putSubtoken(*n++); @@ -207,15 +213,20 @@ int TPpContext::TokenStream::getToken(TParseContextBase& _parseContext, TPpToken ppToken->loc = _parseContext.getCurrentLoc(); // get the backing name string - if (SaveName(atom)) { + if (SaveName(atom)) + { int ch = getSubtoken(); int len = 0; - while (ch != 0 && ch != EndOfInput) { - if (len < MaxTokenLength) { + while (ch != 0 && ch != EndOfInput) + { + if (len < MaxTokenLength) + { ppToken->name[len] = (char)ch; len++; ch = getSubtoken(); - } else { + } + else + { _parseContext.error(ppToken->loc, "token too long", "", ""); break; } @@ -224,13 +235,17 @@ int TPpContext::TokenStream::getToken(TParseContextBase& _parseContext, TPpToken } // Check for ##, unless the current # is the last character - if (atom == '#') { - if (current < data.size()) { - if (getSubtoken() == '#') { + if (atom == '#') + { + if (current < data.size()) + { + if (getSubtoken() == '#') + { _parseContext.requireProfile(ppToken->loc, ~EEsProfile, "token pasting (##)"); _parseContext.profileRequires(ppToken->loc, ~EEsProfile, 130, 0, "token pasting (##)"); atom = PpAtomPaste; - } else + } + else ungetSubtoken(); } } @@ -273,15 +288,17 @@ bool TPpContext::TokenStream::peekTokenizedPasting(bool lastTokenPastes) // Are we at the last non-whitespace token? savePos = current; bool moreTokens = false; - do { + for (;;) + { subtoken = getSubtoken(); if (subtoken == EndOfInput) break; - if (subtoken != ' ') { + if (subtoken != ' ') + { moreTokens = true; break; } - } while (true); + } current = savePos; return !moreTokens; @@ -323,9 +340,9 @@ int TPpContext::tUngotTokenInput::scan(TPpToken* ppToken) if (done) return EndOfInput; - int ret = token; + int ret = token; *ppToken = lval; - done = true; + done = true; return ret; } diff --git a/deps/glslang/glslang/glslang/MachineIndependent/propagateNoContraction.cpp b/deps/glslang/glslang/glslang/MachineIndependent/propagateNoContraction.cpp index b49e93b7cd..21a5cf5db5 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/propagateNoContraction.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/propagateNoContraction.cpp @@ -93,8 +93,9 @@ bool isDereferenceOperation(glslang::TOperator op) case glslang::EOpMatrixSwizzle: return true; default: - return false; + break; } + return false; } // Returns true if the opcode leads to an assignment operation. @@ -123,8 +124,9 @@ bool isAssignOperation(glslang::TOperator op) case glslang::EOpPreDecrement: return true; default: - return false; + break; } + return false; } // A helper function to get the unsigned int from a given constant union node. @@ -180,8 +182,9 @@ bool isArithmeticOperation(glslang::TOperator op) case glslang::EOpPreDecrement: return true; default: - return false; + break; } + return false; } // A helper class to help manage the populating_initial_no_contraction_ flag. @@ -232,10 +235,11 @@ ObjectAccessChain getSubAccessChainAfterPrefix(const ObjectAccessChain& chain, // class TSymbolDefinitionCollectingTraverser : public glslang::TIntermTraverser { public: - TSymbolDefinitionCollectingTraverser(NodeMapping* symbol_definition_mapping, - AccessChainMapping* accesschain_mapping, - ObjectAccesschainSet* precise_objects, - ReturnBranchNodeSet* precise_return_nodes); + TSymbolDefinitionCollectingTraverser( + NodeMapping* symbol_definition_mapping, + AccessChainMapping* accesschain_mapping, + ObjectAccesschainSet* precise_objects, + ReturnBranchNodeSet* precise_return_nodes); bool visitUnary(glslang::TVisit, glslang::TIntermUnary*) override; bool visitBinary(glslang::TVisit, glslang::TIntermBinary*) override; @@ -288,7 +292,7 @@ void TSymbolDefinitionCollectingTraverser::visitSymbol(glslang::TIntermSymbol* n // Visits an aggregate node, traverses all of its children. bool TSymbolDefinitionCollectingTraverser::visitAggregate(glslang::TVisit, - glslang::TIntermAggregate* node) + glslang::TIntermAggregate* node) { // This aggregate node might be a function definition node, in which case we need to // cache this node, so we can get the preciseness information of the return value @@ -310,11 +314,13 @@ bool TSymbolDefinitionCollectingTraverser::visitAggregate(glslang::TVisit, } bool TSymbolDefinitionCollectingTraverser::visitBranch(glslang::TVisit, - glslang::TIntermBranch* node) + glslang::TIntermBranch* node) { - if (node->getFlowOp() == glslang::EOpReturn && node->getExpression() && - current_function_definition_node_ && - current_function_definition_node_->getType().getQualifier().noContraction) { + if ( node->getFlowOp() == glslang::EOpReturn + && node->getExpression() + && current_function_definition_node_ + && current_function_definition_node_->getType().getQualifier().noContraction) + { // This node is a return node with an expression, and its function has a // precise return value. We need to find the involved objects in its // expression and add them to the set of initial precise objects. @@ -325,17 +331,20 @@ bool TSymbolDefinitionCollectingTraverser::visitBranch(glslang::TVisit, } // Visits a unary node. This might be an implicit assignment like i++, i--. etc. -bool TSymbolDefinitionCollectingTraverser::visitUnary(glslang::TVisit /* visit */, - glslang::TIntermUnary* node) +bool TSymbolDefinitionCollectingTraverser::visitUnary( + glslang::TVisit visit, + glslang::TIntermUnary* node) { current_object_.clear(); node->getOperand()->traverse(this); - if (isAssignOperation(node->getOp())) { + if (isAssignOperation(node->getOp())) + { // We should always be able to get an access chain of the operand node. // If the operand node object is 'precise', we collect its access chain // for the initial set of 'precise' objects. - if (isPreciseObjectNode(node->getOperand())) { + if (isPreciseObjectNode(node->getOperand())) + { // The operand node is an 'precise' object node, add its // access chain to the set of 'precise' objects. This is to collect // the initial set of 'precise' objects. @@ -354,8 +363,8 @@ bool TSymbolDefinitionCollectingTraverser::visitUnary(glslang::TVisit /* visit * // Visits a binary node and updates the mapping from symbol IDs to the definition // nodes. Also collects the access chains for the initial precise objects. -bool TSymbolDefinitionCollectingTraverser::visitBinary(glslang::TVisit /* visit */, - glslang::TIntermBinary* node) +bool TSymbolDefinitionCollectingTraverser::visitBinary(glslang::TVisit visit, + glslang::TIntermBinary* node) { // Traverses the left node to build the access chain info for the object. current_object_.clear(); @@ -414,21 +423,19 @@ bool TSymbolDefinitionCollectingTraverser::visitBinary(glslang::TVisit /* visit std::tuple getSymbolToDefinitionMappingAndPreciseSymbolIDs(const glslang::TIntermediate& intermediate) { - auto result_tuple = std::make_tuple(NodeMapping(), AccessChainMapping(), ObjectAccesschainSet(), - ReturnBranchNodeSet()); - + auto result_tuple = std::make_tuple(NodeMapping(), AccessChainMapping(), + ObjectAccesschainSet(), ReturnBranchNodeSet()); TIntermNode* root = intermediate.getTreeRoot(); if (root == 0) return result_tuple; - NodeMapping& symbol_definition_mapping = std::get<0>(result_tuple); - AccessChainMapping& accesschain_mapping = std::get<1>(result_tuple); - ObjectAccesschainSet& precise_objects = std::get<2>(result_tuple); + NodeMapping& symbol_definition_mapping = std::get<0>(result_tuple); + AccessChainMapping& accesschain_mapping = std::get<1>(result_tuple); + ObjectAccesschainSet& precise_objects = std::get<2>(result_tuple); ReturnBranchNodeSet& precise_return_nodes = std::get<3>(result_tuple); // Traverses the AST and populate the results. - TSymbolDefinitionCollectingTraverser collector(&symbol_definition_mapping, &accesschain_mapping, - &precise_objects, &precise_return_nodes); + TSymbolDefinitionCollectingTraverser collector(&symbol_definition_mapping, &accesschain_mapping, &precise_objects, &precise_return_nodes); root->traverse(&collector); return result_tuple; diff --git a/deps/glslang/glslang/glslang/MachineIndependent/reflection.cpp b/deps/glslang/glslang/glslang/MachineIndependent/reflection.cpp index f7401d2286..f72e9f7918 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/reflection.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/reflection.cpp @@ -389,24 +389,24 @@ public: switch ((int)sampler.dim) { case Esd1D: switch ((int)sampler.shadow) { - case false: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY : GL_SAMPLER_1D; - case true: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY_SHADOW : GL_SAMPLER_1D_SHADOW; + case 0: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY : GL_SAMPLER_1D; + case 1: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY_SHADOW : GL_SAMPLER_1D_SHADOW; } case Esd2D: switch ((int)sampler.ms) { - case false: + case 0: switch ((int)sampler.shadow) { - case false: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY : GL_SAMPLER_2D; - case true: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY_SHADOW : GL_SAMPLER_2D_SHADOW; + case 0: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY : GL_SAMPLER_2D; + case 1: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY_SHADOW : GL_SAMPLER_2D_SHADOW; } - case true: return sampler.arrayed ? GL_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_SAMPLER_2D_MULTISAMPLE; + case 1: return sampler.arrayed ? GL_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_SAMPLER_2D_MULTISAMPLE; } case Esd3D: return GL_SAMPLER_3D; case EsdCube: switch ((int)sampler.shadow) { - case false: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY : GL_SAMPLER_CUBE; - case true: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW : GL_SAMPLER_CUBE_SHADOW; + case 0: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY : GL_SAMPLER_CUBE; + case 1: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW : GL_SAMPLER_CUBE_SHADOW; } case EsdRect: return sampler.shadow ? GL_SAMPLER_2D_RECT_SHADOW : GL_SAMPLER_2D_RECT; @@ -418,24 +418,24 @@ public: switch ((int)sampler.dim) { case Esd1D: switch ((int)sampler.shadow) { - case false: return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_AMD : GL_FLOAT16_SAMPLER_1D_AMD; - case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_1D_SHADOW_AMD; + case 0: return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_AMD : GL_FLOAT16_SAMPLER_1D_AMD; + case 1: return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_1D_SHADOW_AMD; } case Esd2D: switch ((int)sampler.ms) { - case false: + case 0: switch ((int)sampler.shadow) { - case false: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_AMD; - case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_2D_SHADOW_AMD; + case 0: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_AMD; + case 1: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_2D_SHADOW_AMD; } - case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_AMD; + case 1: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_AMD; } case Esd3D: return GL_FLOAT16_SAMPLER_3D_AMD; case EsdCube: switch ((int)sampler.shadow) { - case false: return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_AMD : GL_FLOAT16_SAMPLER_CUBE_AMD; - case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_CUBE_SHADOW_AMD; + case 0: return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_AMD : GL_FLOAT16_SAMPLER_CUBE_AMD; + case 1: return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_CUBE_SHADOW_AMD; } case EsdRect: return sampler.shadow ? GL_FLOAT16_SAMPLER_2D_RECT_SHADOW_AMD : GL_FLOAT16_SAMPLER_2D_RECT_AMD; @@ -449,8 +449,8 @@ public: return sampler.arrayed ? GL_INT_SAMPLER_1D_ARRAY : GL_INT_SAMPLER_1D; case Esd2D: switch ((int)sampler.ms) { - case false: return sampler.arrayed ? GL_INT_SAMPLER_2D_ARRAY : GL_INT_SAMPLER_2D; - case true: return sampler.arrayed ? GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY + case 0: return sampler.arrayed ? GL_INT_SAMPLER_2D_ARRAY : GL_INT_SAMPLER_2D; + case 1: return sampler.arrayed ? GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_INT_SAMPLER_2D_MULTISAMPLE; } case Esd3D: @@ -468,8 +468,8 @@ public: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_1D_ARRAY : GL_UNSIGNED_INT_SAMPLER_1D; case Esd2D: switch ((int)sampler.ms) { - case false: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D; - case true: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY + case 0: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D; + case 1: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE; } case Esd3D: @@ -493,8 +493,8 @@ public: return sampler.arrayed ? GL_IMAGE_1D_ARRAY : GL_IMAGE_1D; case Esd2D: switch ((int)sampler.ms) { - case false: return sampler.arrayed ? GL_IMAGE_2D_ARRAY : GL_IMAGE_2D; - case true: return sampler.arrayed ? GL_IMAGE_2D_MULTISAMPLE_ARRAY : GL_IMAGE_2D_MULTISAMPLE; + case 0: return sampler.arrayed ? GL_IMAGE_2D_ARRAY : GL_IMAGE_2D; + case 1: return sampler.arrayed ? GL_IMAGE_2D_MULTISAMPLE_ARRAY : GL_IMAGE_2D_MULTISAMPLE; } case Esd3D: return GL_IMAGE_3D; @@ -512,8 +512,8 @@ public: return sampler.arrayed ? GL_FLOAT16_IMAGE_1D_ARRAY_AMD : GL_FLOAT16_IMAGE_1D_AMD; case Esd2D: switch ((int)sampler.ms) { - case false: return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_AMD; - case true: return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_MULTISAMPLE_AMD; + case 0: return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_AMD; + case 1: return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_MULTISAMPLE_AMD; } case Esd3D: return GL_FLOAT16_IMAGE_3D_AMD; @@ -531,8 +531,8 @@ public: return sampler.arrayed ? GL_INT_IMAGE_1D_ARRAY : GL_INT_IMAGE_1D; case Esd2D: switch ((int)sampler.ms) { - case false: return sampler.arrayed ? GL_INT_IMAGE_2D_ARRAY : GL_INT_IMAGE_2D; - case true: return sampler.arrayed ? GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_INT_IMAGE_2D_MULTISAMPLE; + case 0: return sampler.arrayed ? GL_INT_IMAGE_2D_ARRAY : GL_INT_IMAGE_2D; + case 1: return sampler.arrayed ? GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_INT_IMAGE_2D_MULTISAMPLE; } case Esd3D: return GL_INT_IMAGE_3D; @@ -549,8 +549,8 @@ public: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_1D_ARRAY : GL_UNSIGNED_INT_IMAGE_1D; case Esd2D: switch ((int)sampler.ms) { - case false: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_ARRAY : GL_UNSIGNED_INT_IMAGE_2D; - case true: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY + case 0: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_ARRAY : GL_UNSIGNED_INT_IMAGE_2D; + case 1: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE; } case Esd3D: