bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources) { compileResources = resources; setResourceString(); assert(symbolTable.isEmpty()); symbolTable.push(); // COMMON_BUILTINS symbolTable.push(); // ESSL1_BUILTINS symbolTable.push(); // ESSL3_BUILTINS TPublicType integer; integer.type = EbtInt; integer.primarySize = 1; integer.secondarySize = 1; integer.array = false; TPublicType floatingPoint; floatingPoint.type = EbtFloat; floatingPoint.primarySize = 1; floatingPoint.secondarySize = 1; floatingPoint.array = false; TPublicType sampler; sampler.primarySize = 1; sampler.secondarySize = 1; sampler.array = false; switch(shaderType) { case GL_FRAGMENT_SHADER: symbolTable.setDefaultPrecision(integer, EbpMedium); break; case GL_VERTEX_SHADER: symbolTable.setDefaultPrecision(integer, EbpHigh); symbolTable.setDefaultPrecision(floatingPoint, EbpHigh); break; default: assert(false && "Language not supported"); } // We set defaults for all the sampler types, even those that are // only available if an extension exists. for (int samplerType = EbtGuardSamplerBegin + 1; samplerType < EbtGuardSamplerEnd; ++samplerType) { sampler.type = static_cast<TBasicType>(samplerType); symbolTable.setDefaultPrecision(sampler, EbpLow); } InsertBuiltInFunctions(shaderType, shaderSpec, resources, symbolTable); IdentifyBuiltIns(shaderType, shaderSpec, resources, symbolTable); return true; }
bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources) { compileResources = resources; setResourceString(); assert(symbolTable.isEmpty()); symbolTable.push(); // COMMON_BUILTINS symbolTable.push(); // ESSL1_BUILTINS symbolTable.push(); // ESSL3_BUILTINS symbolTable.push(); // ESSL3_1_BUILTINS TPublicType integer; integer.type = EbtInt; integer.primarySize = 1; integer.secondarySize = 1; integer.array = false; TPublicType floatingPoint; floatingPoint.type = EbtFloat; floatingPoint.primarySize = 1; floatingPoint.secondarySize = 1; floatingPoint.array = false; switch(shaderType) { case GL_FRAGMENT_SHADER: symbolTable.setDefaultPrecision(integer, EbpMedium); break; case GL_VERTEX_SHADER: symbolTable.setDefaultPrecision(integer, EbpHigh); symbolTable.setDefaultPrecision(floatingPoint, EbpHigh); break; default: assert(false && "Language not supported"); } // Set defaults for sampler types that have default precision, even those that are // only available if an extension exists. // New sampler types in ESSL3 don't have default precision. ESSL1 types do. initSamplerDefaultPrecision(EbtSampler2D); initSamplerDefaultPrecision(EbtSamplerCube); // SamplerExternalOES is specified in the extension to have default precision. initSamplerDefaultPrecision(EbtSamplerExternalOES); // It isn't specified whether Sampler2DRect has default precision. initSamplerDefaultPrecision(EbtSampler2DRect); InsertBuiltInFunctions(shaderType, shaderSpec, resources, symbolTable); IdentifyBuiltIns(shaderType, shaderSpec, resources, symbolTable); return true; }