Commit 2a1e8f95 by Olli Etuaho Committed by Commit Bot

Refer to GLSL extensions through TExtension enum

Extensions are now referred to by enum values instead of strings most of the time. This gets rid of unnecessary copying of strings. The code is easier to work with than before as typoing the extension enum names will be caught by the compiler. BUG=angleproject:2147 TEST=angle_unittests Change-Id: Ifa61b9f86ef03211188fc23bc23a5ce4e4d8c390 Reviewed-on: https://chromium-review.googlesource.com/571002 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent ad17d2a0
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
'compiler/translator/EmulatePrecision.h', 'compiler/translator/EmulatePrecision.h',
'compiler/translator/ExpandIntegerPowExpressions.cpp', 'compiler/translator/ExpandIntegerPowExpressions.cpp',
'compiler/translator/ExpandIntegerPowExpressions.h', 'compiler/translator/ExpandIntegerPowExpressions.h',
'compiler/translator/ExtensionBehavior.cpp',
'compiler/translator/ExtensionBehavior.h', 'compiler/translator/ExtensionBehavior.h',
'compiler/translator/FindMain.cpp', 'compiler/translator/FindMain.cpp',
'compiler/translator/FindMain.h', 'compiler/translator/FindMain.h',
......
...@@ -475,7 +475,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) ...@@ -475,7 +475,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
{ {
OutputVariable info; OutputVariable info;
setBuiltInInfoFromSymbolTable("gl_FragData", &info); setBuiltInInfoFromSymbolTable("gl_FragData", &info);
if (!::IsExtensionEnabled(mExtensionBehavior, "GL_EXT_draw_buffers")) if (!IsExtensionEnabled(mExtensionBehavior, TExtension::EXT_draw_buffers))
{ {
info.arraySize = 1; info.arraySize = 1;
} }
...@@ -527,7 +527,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) ...@@ -527,7 +527,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
else else
{ {
ASSERT(mShaderType == GL_VERTEX_SHADER && ASSERT(mShaderType == GL_VERTEX_SHADER &&
IsExtensionEnabled(mExtensionBehavior, "GL_OVR_multiview")); IsExtensionEnabled(mExtensionBehavior, TExtension::OVR_multiview));
} }
break; break;
default: default:
......
...@@ -430,7 +430,8 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[], ...@@ -430,7 +430,8 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
arrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root); arrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root);
if (success && (compileOptions & SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW) && if (success && (compileOptions & SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW) &&
parseContext.isMultiviewExtensionEnabled() && getShaderType() != GL_COMPUTE_SHADER) parseContext.isExtensionEnabled(TExtension::OVR_multiview) &&
getShaderType() != GL_COMPUTE_SHADER)
{ {
DeclareAndInitBuiltinsForInstancedMultiview(root, mNumViews, shaderType, compileOptions, DeclareAndInitBuiltinsForInstancedMultiview(root, mNumViews, shaderType, compileOptions,
outputType, &symbolTable); outputType, &symbolTable);
...@@ -514,7 +515,7 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[], ...@@ -514,7 +515,7 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
if (success && shaderType == GL_FRAGMENT_SHADER && shaderVersion == 100 && if (success && shaderType == GL_FRAGMENT_SHADER && shaderVersion == 100 &&
compileResources.EXT_draw_buffers && compileResources.MaxDrawBuffers > 1 && compileResources.EXT_draw_buffers && compileResources.MaxDrawBuffers > 1 &&
IsExtensionEnabled(extensionBehavior, "GL_EXT_draw_buffers")) IsExtensionEnabled(extensionBehavior, TExtension::EXT_draw_buffers))
{ {
EmulateGLFragColorBroadcast(root, compileResources.MaxDrawBuffers, &outputVariables, EmulateGLFragColorBroadcast(root, compileResources.MaxDrawBuffers, &outputVariables,
&symbolTable, shaderVersion); &symbolTable, shaderVersion);
......
...@@ -162,7 +162,7 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation &loc, ...@@ -162,7 +162,7 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation &loc,
return; return;
} }
TExtensionBehavior::iterator iter = mExtensionBehavior.find(name); TExtensionBehavior::iterator iter = mExtensionBehavior.find(GetExtensionByName(name.c_str()));
if (iter != mExtensionBehavior.end()) if (iter != mExtensionBehavior.end())
{ {
iter->second = behaviorVal; iter->second = behaviorVal;
......
//
// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ExtensionBehavior.cpp: Extension name enumeration and data structures for storing extension
// behavior.
#include "compiler/translator/ExtensionBehavior.h"
#include "common/debug.h"
#define LIST_EXTENSIONS(OP) \
OP(ARB_texture_rectangle) \
OP(ARM_shader_framebuffer_fetch) \
OP(EXT_blend_func_extended) \
OP(EXT_draw_buffers) \
OP(EXT_frag_depth) \
OP(EXT_shader_framebuffer_fetch) \
OP(EXT_shader_texture_lod) \
OP(EXT_YUV_target) \
OP(NV_EGL_stream_consumer_external) \
OP(NV_shader_framebuffer_fetch) \
OP(OES_EGL_image_external) \
OP(OES_EGL_image_external_essl3) \
OP(OES_geometry_shader) \
OP(OES_standard_derivatives) \
OP(OVR_multiview)
namespace sh
{
#define RETURN_EXTENSION_NAME_CASE(ext) \
case TExtension::ext: \
return "GL_" #ext;
const char *GetExtensionNameString(TExtension extension)
{
switch (extension)
{
LIST_EXTENSIONS(RETURN_EXTENSION_NAME_CASE)
default:
UNREACHABLE();
return "";
}
}
#define RETURN_EXTENSION_IF_NAME_MATCHES(ext) \
if (strcmp(extWithoutGLPrefix, #ext) == 0) \
{ \
return TExtension::ext; \
}
TExtension GetExtensionByName(const char *extension)
{
// If first characters of the extension don't equal "GL_", early out.
if (strncmp(extension, "GL_", 3) != 0)
{
return TExtension::UNDEFINED;
}
const char *extWithoutGLPrefix = extension + 3;
LIST_EXTENSIONS(RETURN_EXTENSION_IF_NAME_MATCHES)
return TExtension::UNDEFINED;
}
const char *GetBehaviorString(TBehavior b)
{
switch (b)
{
case EBhRequire:
return "require";
case EBhEnable:
return "enable";
case EBhWarn:
return "warn";
case EBhDisable:
return "disable";
default:
return nullptr;
}
}
bool IsExtensionEnabled(const TExtensionBehavior &extBehavior, TExtension extension)
{
ASSERT(extension != TExtension::UNDEFINED);
auto iter = extBehavior.find(extension);
return iter != extBehavior.end() && (iter->second == EBhEnable || iter->second == EBhRequire);
}
} // namespace sh
...@@ -3,39 +3,57 @@ ...@@ -3,39 +3,57 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// ExtensionBehavior.h: Extension name enumeration and data structures for storing extension
// behavior.
#ifndef COMPILER_TRANSLATOR_EXTENSIONBEHAVIOR_H_ #ifndef COMPILER_TRANSLATOR_EXTENSIONBEHAVIOR_H_
#define COMPILER_TRANSLATOR_EXTENSIONBEHAVIOR_H_ #define COMPILER_TRANSLATOR_EXTENSIONBEHAVIOR_H_
#include <map> #include <map>
#include <string>
typedef enum { EBhRequire, EBhEnable, EBhWarn, EBhDisable, EBhUndefined } TBehavior; namespace sh
{
inline const char *getBehaviorString(TBehavior b) enum class TExtension
{ {
switch (b) UNDEFINED, // Special value used to indicate no extension.
{
case EBhRequire: ARB_texture_rectangle,
return "require"; ARM_shader_framebuffer_fetch,
case EBhEnable: EXT_blend_func_extended,
return "enable"; EXT_draw_buffers,
case EBhWarn: EXT_frag_depth,
return "warn"; EXT_shader_framebuffer_fetch,
case EBhDisable: EXT_shader_texture_lod,
return "disable"; EXT_YUV_target,
default: NV_EGL_stream_consumer_external,
return nullptr; NV_shader_framebuffer_fetch,
} OES_EGL_image_external,
} OES_EGL_image_external_essl3,
OES_geometry_shader,
// Mapping between extension name and behavior. OES_standard_derivatives,
typedef std::map<std::string, TBehavior> TExtensionBehavior; OVR_multiview
};
inline bool IsExtensionEnabled(const TExtensionBehavior &extBehavior, const char *extension)
enum TBehavior
{ {
auto iter = extBehavior.find(extension); EBhRequire,
return iter != extBehavior.end() && (iter->second == EBhEnable || iter->second == EBhRequire); EBhEnable,
} EBhWarn,
EBhDisable,
EBhUndefined
};
const char *GetExtensionNameString(TExtension extension);
TExtension GetExtensionByName(const char *extension);
const char *GetBehaviorString(TBehavior b);
// Mapping between extension id and behavior.
typedef std::map<TExtension, TBehavior> TExtensionBehavior;
bool IsExtensionEnabled(const TExtensionBehavior &extBehavior, TExtension extension);
} // namespace sh
#endif // COMPILER_TRANSLATOR_EXTENSIONBEHAVIOR_H_ #endif // COMPILER_TRANSLATOR_EXTENSIONBEHAVIOR_H_
...@@ -107,7 +107,7 @@ void InsertInitCode(TIntermSequence *mainBody, ...@@ -107,7 +107,7 @@ void InsertInitCode(TIntermSequence *mainBody,
{ {
initializedSymbol = ReferenceBuiltInVariable(name, symbolTable, shaderVersion); initializedSymbol = ReferenceBuiltInVariable(name, symbolTable, shaderVersion);
if (initializedSymbol->getQualifier() == EvqFragData && if (initializedSymbol->getQualifier() == EvqFragData &&
!IsExtensionEnabled(extensionBehavior, "GL_EXT_draw_buffers")) !IsExtensionEnabled(extensionBehavior, TExtension::EXT_draw_buffers))
{ {
// If GL_EXT_draw_buffers is disabled, only the 0th index of gl_FragData can be // If GL_EXT_draw_buffers is disabled, only the 0th index of gl_FragData can be
// written to. // written to.
......
...@@ -130,7 +130,8 @@ OutputHLSL::OutputHLSL(sh::GLenum shaderType, ...@@ -130,7 +130,8 @@ OutputHLSL::OutputHLSL(sh::GLenum shaderType,
mUsesFrontFacing = false; mUsesFrontFacing = false;
mUsesPointSize = false; mUsesPointSize = false;
mUsesInstanceID = false; mUsesInstanceID = false;
mHasMultiviewExtensionEnabled = IsExtensionEnabled(mExtensionBehavior, "GL_OVR_multiview"); mHasMultiviewExtensionEnabled =
IsExtensionEnabled(mExtensionBehavior, TExtension::OVR_multiview);
mUsesViewID = false; mUsesViewID = false;
mUsesVertexID = false; mUsesVertexID = false;
mUsesFragDepth = false; mUsesFragDepth = false;
...@@ -417,9 +418,8 @@ void OutputHLSL::header(TInfoSinkBase &out, const BuiltInFunctionEmulator *built ...@@ -417,9 +418,8 @@ void OutputHLSL::header(TInfoSinkBase &out, const BuiltInFunctionEmulator *built
if (mShaderType == GL_FRAGMENT_SHADER) if (mShaderType == GL_FRAGMENT_SHADER)
{ {
TExtensionBehavior::const_iterator iter = mExtensionBehavior.find("GL_EXT_draw_buffers"); const bool usingMRTExtension =
const bool usingMRTExtension = (iter != mExtensionBehavior.end() && IsExtensionEnabled(mExtensionBehavior, TExtension::EXT_draw_buffers);
(iter->second == EBhEnable || iter->second == EBhRequire));
out << "// Varyings\n"; out << "// Varyings\n";
out << varyings; out << varyings;
......
...@@ -138,7 +138,7 @@ class TParseContext : angle::NonCopyable ...@@ -138,7 +138,7 @@ class TParseContext : angle::NonCopyable
void checkIsParameterQualifierValid(const TSourceLoc &line, void checkIsParameterQualifierValid(const TSourceLoc &line,
const TTypeQualifierBuilder &typeQualifierBuilder, const TTypeQualifierBuilder &typeQualifierBuilder,
TType *type); TType *type);
bool checkCanUseExtension(const TSourceLoc &line, const TString &extension); bool checkCanUseExtension(const TSourceLoc &line, TExtension extension);
// Done for all declarations, whether empty or not. // Done for all declarations, whether empty or not.
void declarationQualifierErrorCheck(const sh::TQualifier qualifier, void declarationQualifierErrorCheck(const sh::TQualifier qualifier,
...@@ -168,12 +168,8 @@ class TParseContext : angle::NonCopyable ...@@ -168,12 +168,8 @@ class TParseContext : angle::NonCopyable
{ {
return mDirectiveHandler.extensionBehavior(); return mDirectiveHandler.extensionBehavior();
} }
bool supportsExtension(const char *extension); bool supportsExtension(TExtension extension);
bool isExtensionEnabled(const char *extension) const; bool isExtensionEnabled(TExtension extension) const;
bool isMultiviewExtensionEnabled() const
{
return mMultiviewAvailable && isExtensionEnabled("GL_OVR_multiview");
}
void handleExtensionDirective(const TSourceLoc &loc, const char *extName, const char *behavior); void handleExtensionDirective(const TSourceLoc &loc, const char *extName, const char *behavior);
void handlePragmaDirective(const TSourceLoc &loc, void handlePragmaDirective(const TSourceLoc &loc,
const char *name, const char *name,
...@@ -580,8 +576,6 @@ class TParseContext : angle::NonCopyable ...@@ -580,8 +576,6 @@ class TParseContext : angle::NonCopyable
int mMinProgramTexelOffset; int mMinProgramTexelOffset;
int mMaxProgramTexelOffset; int mMaxProgramTexelOffset;
bool mMultiviewAvailable;
// keep track of local group size declared in layout. It should be declared only once. // keep track of local group size declared in layout. It should be declared only once.
bool mComputeShaderLocalSizeDeclared; bool mComputeShaderLocalSizeDeclared;
sh::WorkGroupSize mComputeShaderLocalSize; sh::WorkGroupSize mComputeShaderLocalSize;
......
...@@ -43,7 +43,7 @@ int TSymbolUniqueId::get() const ...@@ -43,7 +43,7 @@ int TSymbolUniqueId::get() const
} }
TSymbol::TSymbol(TSymbolTable *symbolTable, const TString *n) TSymbol::TSymbol(TSymbolTable *symbolTable, const TString *n)
: uniqueId(symbolTable->nextUniqueId()), name(n) : uniqueId(symbolTable->nextUniqueId()), name(n), extension(TExtension::UNDEFINED)
{ {
} }
...@@ -300,7 +300,7 @@ TInterfaceBlockName *TSymbolTable::declareInterfaceBlockName(const TString *name ...@@ -300,7 +300,7 @@ TInterfaceBlockName *TSymbolTable::declareInterfaceBlockName(const TString *name
} }
TInterfaceBlockName *TSymbolTable::insertInterfaceBlockNameExt(ESymbolLevel level, TInterfaceBlockName *TSymbolTable::insertInterfaceBlockNameExt(ESymbolLevel level,
const char *ext, TExtension ext,
const TString *name) const TString *name)
{ {
TInterfaceBlockName *blockNameSymbol = new TInterfaceBlockName(this, name); TInterfaceBlockName *blockNameSymbol = new TInterfaceBlockName(this, name);
...@@ -332,7 +332,7 @@ TVariable *TSymbolTable::insertVariable(ESymbolLevel level, const TString *name, ...@@ -332,7 +332,7 @@ TVariable *TSymbolTable::insertVariable(ESymbolLevel level, const TString *name,
} }
TVariable *TSymbolTable::insertVariableExt(ESymbolLevel level, TVariable *TSymbolTable::insertVariableExt(ESymbolLevel level,
const char *ext, TExtension ext,
const char *name, const char *name,
const TType &type) const TType &type)
{ {
...@@ -361,7 +361,7 @@ TVariable *TSymbolTable::insertStructType(ESymbolLevel level, TStructure *str) ...@@ -361,7 +361,7 @@ TVariable *TSymbolTable::insertStructType(ESymbolLevel level, TStructure *str)
void TSymbolTable::insertBuiltIn(ESymbolLevel level, void TSymbolTable::insertBuiltIn(ESymbolLevel level,
TOperator op, TOperator op,
const char *ext, TExtension ext,
const TType *rvalue, const TType *rvalue,
const char *name, const char *name,
const TType *ptype1, const TType *ptype1,
...@@ -530,12 +530,13 @@ void TSymbolTable::insertBuiltInOp(ESymbolLevel level, ...@@ -530,12 +530,13 @@ void TSymbolTable::insertBuiltInOp(ESymbolLevel level,
const char *name = GetOperatorString(op); const char *name = GetOperatorString(op);
ASSERT(strlen(name) > 0); ASSERT(strlen(name) > 0);
insertUnmangledBuiltInName(name, level); insertUnmangledBuiltInName(name, level);
insertBuiltIn(level, op, "", rvalue, name, ptype1, ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, op, TExtension::UNDEFINED, rvalue, name, ptype1, ptype2, ptype3, ptype4,
ptype5);
} }
void TSymbolTable::insertBuiltInOp(ESymbolLevel level, void TSymbolTable::insertBuiltInOp(ESymbolLevel level,
TOperator op, TOperator op,
const char *ext, TExtension ext,
const TType *rvalue, const TType *rvalue,
const TType *ptype1, const TType *ptype1,
const TType *ptype2, const TType *ptype2,
...@@ -558,7 +559,7 @@ void TSymbolTable::insertBuiltInFunctionNoParameters(ESymbolLevel level, ...@@ -558,7 +559,7 @@ void TSymbolTable::insertBuiltInFunctionNoParameters(ESymbolLevel level,
} }
void TSymbolTable::insertBuiltInFunctionNoParametersExt(ESymbolLevel level, void TSymbolTable::insertBuiltInFunctionNoParametersExt(ESymbolLevel level,
const char *ext, TExtension ext,
TOperator op, TOperator op,
const TType *rvalue, const TType *rvalue,
const char *name) const char *name)
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <set> #include <set>
#include "common/angleutils.h" #include "common/angleutils.h"
#include "compiler/translator/ExtensionBehavior.h"
#include "compiler/translator/InfoSink.h" #include "compiler/translator/InfoSink.h"
#include "compiler/translator/IntermNode.h" #include "compiler/translator/IntermNode.h"
...@@ -74,13 +75,13 @@ class TSymbol : angle::NonCopyable ...@@ -74,13 +75,13 @@ class TSymbol : angle::NonCopyable
virtual bool isFunction() const { return false; } virtual bool isFunction() const { return false; }
virtual bool isVariable() const { return false; } virtual bool isVariable() const { return false; }
int getUniqueId() const { return uniqueId; } int getUniqueId() const { return uniqueId; }
void relateToExtension(const TString &ext) { extension = ext; } void relateToExtension(TExtension ext) { extension = ext; }
const TString &getExtension() const { return extension; } TExtension getExtension() const { return extension; }
private: private:
const int uniqueId; const int uniqueId;
const TString *name; const TString *name;
TString extension; TExtension extension;
}; };
// Variable, meaning a symbol that's not a function. // Variable, meaning a symbol that's not a function.
...@@ -165,8 +166,8 @@ class TFunction : public TSymbol ...@@ -165,8 +166,8 @@ class TFunction : public TSymbol
TFunction(TSymbolTable *symbolTable, TFunction(TSymbolTable *symbolTable,
const TString *name, const TString *name,
const TType *retType, const TType *retType,
TOperator tOp = EOpNull, TOperator tOp = EOpNull,
const char *ext = "") TExtension ext = TExtension::UNDEFINED)
: TSymbol(symbolTable, name), : TSymbol(symbolTable, name),
returnType(retType), returnType(retType),
mangledName(nullptr), mangledName(nullptr),
...@@ -343,12 +344,12 @@ class TSymbolTable : angle::NonCopyable ...@@ -343,12 +344,12 @@ class TSymbolTable : angle::NonCopyable
// declaration failed due to redefinition. // declaration failed due to redefinition.
TVariable *insertVariable(ESymbolLevel level, const char *name, const TType &type); TVariable *insertVariable(ESymbolLevel level, const char *name, const TType &type);
TVariable *insertVariableExt(ESymbolLevel level, TVariable *insertVariableExt(ESymbolLevel level,
const char *ext, TExtension ext,
const char *name, const char *name,
const TType &type); const TType &type);
TVariable *insertStructType(ESymbolLevel level, TStructure *str); TVariable *insertStructType(ESymbolLevel level, TStructure *str);
TInterfaceBlockName *insertInterfaceBlockNameExt(ESymbolLevel level, TInterfaceBlockName *insertInterfaceBlockNameExt(ESymbolLevel level,
const char *ext, TExtension ext,
const TString *name); const TString *name);
bool insertConstInt(ESymbolLevel level, const char *name, int value, TPrecision precision) bool insertConstInt(ESymbolLevel level, const char *name, int value, TPrecision precision)
...@@ -362,7 +363,7 @@ class TSymbolTable : angle::NonCopyable ...@@ -362,7 +363,7 @@ class TSymbolTable : angle::NonCopyable
} }
bool insertConstIntExt(ESymbolLevel level, bool insertConstIntExt(ESymbolLevel level,
const char *ext, TExtension ext,
const char *name, const char *name,
int value, int value,
TPrecision precision) TPrecision precision)
...@@ -395,7 +396,7 @@ class TSymbolTable : angle::NonCopyable ...@@ -395,7 +396,7 @@ class TSymbolTable : angle::NonCopyable
void insertBuiltIn(ESymbolLevel level, void insertBuiltIn(ESymbolLevel level,
TOperator op, TOperator op,
const char *ext, TExtension ext,
const TType *rvalue, const TType *rvalue,
const char *name, const char *name,
const TType *ptype1, const TType *ptype1,
...@@ -414,11 +415,12 @@ class TSymbolTable : angle::NonCopyable ...@@ -414,11 +415,12 @@ class TSymbolTable : angle::NonCopyable
const TType *ptype5 = 0) const TType *ptype5 = 0)
{ {
insertUnmangledBuiltInName(name, level); insertUnmangledBuiltInName(name, level);
insertBuiltIn(level, EOpNull, "", rvalue, name, ptype1, ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, EOpNull, TExtension::UNDEFINED, rvalue, name, ptype1, ptype2, ptype3,
ptype4, ptype5);
} }
void insertBuiltIn(ESymbolLevel level, void insertBuiltIn(ESymbolLevel level,
const char *ext, TExtension ext,
const TType *rvalue, const TType *rvalue,
const char *name, const char *name,
const TType *ptype1, const TType *ptype1,
...@@ -442,7 +444,7 @@ class TSymbolTable : angle::NonCopyable ...@@ -442,7 +444,7 @@ class TSymbolTable : angle::NonCopyable
void insertBuiltInOp(ESymbolLevel level, void insertBuiltInOp(ESymbolLevel level,
TOperator op, TOperator op,
const char *ext, TExtension ext,
const TType *rvalue, const TType *rvalue,
const TType *ptype1, const TType *ptype1,
const TType *ptype2 = 0, const TType *ptype2 = 0,
...@@ -456,7 +458,7 @@ class TSymbolTable : angle::NonCopyable ...@@ -456,7 +458,7 @@ class TSymbolTable : angle::NonCopyable
const char *name); const char *name);
void insertBuiltInFunctionNoParametersExt(ESymbolLevel level, void insertBuiltInFunctionNoParametersExt(ESymbolLevel level,
const char *ext, TExtension ext,
TOperator op, TOperator op,
const TType *rvalue, const TType *rvalue,
const char *name); const char *name);
...@@ -524,7 +526,7 @@ class TSymbolTable : angle::NonCopyable ...@@ -524,7 +526,7 @@ class TSymbolTable : angle::NonCopyable
bool insert(ESymbolLevel level, TSymbol *symbol) { return table[level]->insert(symbol); } bool insert(ESymbolLevel level, TSymbol *symbol) { return table[level]->insert(symbol); }
bool insert(ESymbolLevel level, const char *ext, TSymbol *symbol) bool insert(ESymbolLevel level, TExtension ext, TSymbol *symbol)
{ {
symbol->relateToExtension(ext); symbol->relateToExtension(ext);
return table[level]->insert(symbol); return table[level]->insert(symbol);
......
...@@ -136,16 +136,16 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions) ...@@ -136,16 +136,16 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions)
{ {
if (iter->second != EBhUndefined) if (iter->second != EBhUndefined)
{ {
const bool isMultiview = (iter->first == "GL_OVR_multiview"); const bool isMultiview = (iter->first == TExtension::OVR_multiview);
if (getResources().NV_shader_framebuffer_fetch && if (getResources().NV_shader_framebuffer_fetch &&
iter->first == "GL_EXT_shader_framebuffer_fetch") iter->first == TExtension::EXT_shader_framebuffer_fetch)
{ {
sink << "#extension GL_NV_shader_framebuffer_fetch : " sink << "#extension GL_NV_shader_framebuffer_fetch : "
<< getBehaviorString(iter->second) << "\n"; << GetBehaviorString(iter->second) << "\n";
} }
else if (getResources().NV_draw_buffers && iter->first == "GL_EXT_draw_buffers") else if (getResources().NV_draw_buffers && iter->first == TExtension::EXT_draw_buffers)
{ {
sink << "#extension GL_NV_draw_buffers : " << getBehaviorString(iter->second) sink << "#extension GL_NV_draw_buffers : " << GetBehaviorString(iter->second)
<< "\n"; << "\n";
} }
else if (isMultiview && isMultiviewExtEmulated) else if (isMultiview && isMultiviewExtEmulated)
...@@ -159,13 +159,13 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions) ...@@ -159,13 +159,13 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions)
sink << "#extension GL_NV_viewport_array2 : require\n"; sink << "#extension GL_NV_viewport_array2 : require\n";
} }
} }
else if (iter->first == "GL_OES_geometry_shader") else if (iter->first == TExtension::OES_geometry_shader)
{ {
sink << "#ifdef GL_OES_geometry_shader\n" sink << "#ifdef GL_OES_geometry_shader\n"
<< "#extension GL_OES_geometry_shader : " << getBehaviorString(iter->second) << "#extension GL_OES_geometry_shader : " << GetBehaviorString(iter->second)
<< "\n" << "\n"
<< "#elif defined GL_EXT_geometry_shader\n" << "#elif defined GL_EXT_geometry_shader\n"
<< "#extension GL_EXT_geometry_shader : " << getBehaviorString(iter->second) << "#extension GL_EXT_geometry_shader : " << GetBehaviorString(iter->second)
<< "\n"; << "\n";
if (iter->second == EBhRequire) if (iter->second == EBhRequire)
{ {
...@@ -177,8 +177,8 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions) ...@@ -177,8 +177,8 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions)
} }
else else
{ {
sink << "#extension " << iter->first << " : " << getBehaviorString(iter->second) sink << "#extension " << GetExtensionNameString(iter->first) << " : "
<< "\n"; << GetBehaviorString(iter->second) << "\n";
} }
} }
} }
......
...@@ -130,7 +130,7 @@ void TranslatorGLSL::translate(TIntermBlock *root, ShCompileOptions compileOptio ...@@ -130,7 +130,7 @@ void TranslatorGLSL::translate(TIntermBlock *root, ShCompileOptions compileOptio
if (getShaderType() == GL_FRAGMENT_SHADER) if (getShaderType() == GL_FRAGMENT_SHADER)
{ {
const bool mayHaveESSL1SecondaryOutputs = const bool mayHaveESSL1SecondaryOutputs =
IsExtensionEnabled(getExtensionBehavior(), "GL_EXT_blend_func_extended") && IsExtensionEnabled(getExtensionBehavior(), TExtension::EXT_blend_func_extended) &&
getShaderVersion() == 100; getShaderVersion() == 100;
const bool declareGLFragmentOutputs = IsGLSL130OrNewer(getOutputType()); const bool declareGLFragmentOutputs = IsGLSL130OrNewer(getOutputType());
...@@ -264,26 +264,26 @@ void TranslatorGLSL::writeExtensionBehavior(TIntermNode *root, ShCompileOptions ...@@ -264,26 +264,26 @@ void TranslatorGLSL::writeExtensionBehavior(TIntermNode *root, ShCompileOptions
{ {
// For GLSL output, we don't need to emit most extensions explicitly, // For GLSL output, we don't need to emit most extensions explicitly,
// but some we need to translate in GL compatibility profile. // but some we need to translate in GL compatibility profile.
if (iter.first == "GL_EXT_shader_texture_lod") if (iter.first == TExtension::EXT_shader_texture_lod)
{ {
sink << "#extension GL_ARB_shader_texture_lod : " << getBehaviorString(iter.second) sink << "#extension GL_ARB_shader_texture_lod : " << GetBehaviorString(iter.second)
<< "\n"; << "\n";
} }
if (iter.first == "GL_EXT_draw_buffers") if (iter.first == TExtension::EXT_draw_buffers)
{ {
sink << "#extension GL_ARB_draw_buffers : " << getBehaviorString(iter.second) sink << "#extension GL_ARB_draw_buffers : " << GetBehaviorString(iter.second)
<< "\n"; << "\n";
} }
if (iter.first == "GL_OES_geometry_shader") if (iter.first == TExtension::OES_geometry_shader)
{ {
sink << "#extension GL_ARB_geometry_shader4 : " << getBehaviorString(iter.second) sink << "#extension GL_ARB_geometry_shader4 : " << GetBehaviorString(iter.second)
<< "\n"; << "\n";
} }
} }
const bool isMultiview = (iter.first == "GL_OVR_multiview"); const bool isMultiview = (iter.first == TExtension::OVR_multiview);
if (isMultiview && getShaderType() == GL_VERTEX_SHADER && if (isMultiview && getShaderType() == GL_VERTEX_SHADER &&
(compileOptions & SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER) != 0u) (compileOptions & SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER) != 0u)
{ {
......
...@@ -51,7 +51,7 @@ ValidateOutputsTraverser::ValidateOutputsTraverser(const TExtensionBehavior &ext ...@@ -51,7 +51,7 @@ ValidateOutputsTraverser::ValidateOutputsTraverser(const TExtensionBehavior &ext
: TIntermTraverser(true, false, false), : TIntermTraverser(true, false, false),
mMaxDrawBuffers(maxDrawBuffers), mMaxDrawBuffers(maxDrawBuffers),
mAllowUnspecifiedOutputLocationResolution( mAllowUnspecifiedOutputLocationResolution(
IsExtensionEnabled(extBehavior, "GL_EXT_blend_func_extended")), IsExtensionEnabled(extBehavior, TExtension::EXT_blend_func_extended)),
mUsesFragDepth(false) mUsesFragDepth(false)
{ {
} }
......
...@@ -80,7 +80,7 @@ static int ES2_ident_ES3_keyword_multiview_keyword(TParseContext *context, int t ...@@ -80,7 +80,7 @@ static int ES2_ident_ES3_keyword_multiview_keyword(TParseContext *context, int t
static int ES2_ident_ES3_reserved_ES3_1_keyword(TParseContext *context, int token); static int ES2_ident_ES3_reserved_ES3_1_keyword(TParseContext *context, int token);
static int ES2_and_ES3_reserved_ES3_1_keyword(TParseContext *context, int token); static int ES2_and_ES3_reserved_ES3_1_keyword(TParseContext *context, int token);
static int ES2_and_ES3_ident_ES3_1_keyword(TParseContext *context, int token); static int ES2_and_ES3_ident_ES3_1_keyword(TParseContext *context, int token);
static int ES3_extension_keyword_else_ident(TParseContext *context, const char *extension, int token); static int ES3_extension_keyword_else_ident(TParseContext *context, TExtension extension, int token);
static int uint_constant(TParseContext *context); static int uint_constant(TParseContext *context);
static int int_constant(TParseContext *context); static int int_constant(TParseContext *context);
static int float_constant(yyscan_t yyscanner); static int float_constant(yyscan_t yyscanner);
...@@ -198,13 +198,13 @@ O [0-7] ...@@ -198,13 +198,13 @@ O [0-7]
"sampler2DShadow" { return ES2_reserved_ES3_keyword(context, SAMPLER2DSHADOW); } "sampler2DShadow" { return ES2_reserved_ES3_keyword(context, SAMPLER2DSHADOW); }
"samplerCubeShadow" { return ES2_ident_ES3_keyword(context, SAMPLERCUBESHADOW); } "samplerCubeShadow" { return ES2_ident_ES3_keyword(context, SAMPLERCUBESHADOW); }
"sampler2DArrayShadow" { return ES2_ident_ES3_keyword(context, SAMPLER2DARRAYSHADOW); } "sampler2DArrayShadow" { return ES2_ident_ES3_keyword(context, SAMPLER2DARRAYSHADOW); }
"__samplerExternal2DY2YEXT" { return ES3_extension_keyword_else_ident(context, "GL_EXT_YUV_target", SAMPLEREXTERNAL2DY2YEXT); } "__samplerExternal2DY2YEXT" { return ES3_extension_keyword_else_ident(context, TExtension::EXT_YUV_target, SAMPLEREXTERNAL2DY2YEXT); }
"struct" { return STRUCT; } "struct" { return STRUCT; }
"layout" { return ES2_ident_ES3_keyword_multiview_keyword(context, LAYOUT); } "layout" { return ES2_ident_ES3_keyword_multiview_keyword(context, LAYOUT); }
"yuvCscStandardEXT" { return ES3_extension_keyword_else_ident(context, "GL_EXT_YUV_target", YUVCSCSTANDARDEXT); } "yuvCscStandardEXT" { return ES3_extension_keyword_else_ident(context, TExtension::EXT_YUV_target, YUVCSCSTANDARDEXT); }
"itu_601" { return yuvcscstandardext_constant(context); } "itu_601" { return yuvcscstandardext_constant(context); }
"itu_601_full_range" { return yuvcscstandardext_constant(context); } "itu_601_full_range" { return yuvcscstandardext_constant(context); }
"itu_709" { return yuvcscstandardext_constant(context); } "itu_709" { return yuvcscstandardext_constant(context); }
...@@ -523,7 +523,7 @@ int ES2_ident_ES3_keyword_multiview_keyword(TParseContext *context, int token) ...@@ -523,7 +523,7 @@ int ES2_ident_ES3_keyword_multiview_keyword(TParseContext *context, int token)
// not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name // not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name
// except when multiview extension is enabled // except when multiview extension is enabled
if (context->getShaderVersion() < 300 && !context->isMultiviewExtensionEnabled()) if (context->getShaderVersion() < 300 && !context->isExtensionEnabled(TExtension::OVR_multiview))
{ {
yylval->lex.string = NewPoolTString(yytext); yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner); return check_type(yyscanner);
...@@ -559,7 +559,7 @@ int ES2_and_ES3_ident_ES3_1_keyword(TParseContext *context, int token) ...@@ -559,7 +559,7 @@ int ES2_and_ES3_ident_ES3_1_keyword(TParseContext *context, int token)
return token; return token;
} }
int ES3_extension_keyword_else_ident(TParseContext *context, const char* extension, int token) int ES3_extension_keyword_else_ident(TParseContext *context, TExtension extension, int token)
{ {
struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner();
yyscan_t yyscanner = (yyscan_t) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->getScanner();
...@@ -641,7 +641,7 @@ int yuvcscstandardext_constant(TParseContext *context) ...@@ -641,7 +641,7 @@ int yuvcscstandardext_constant(TParseContext *context)
yyscan_t yyscanner = (yyscan_t) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->getScanner();
// a reserved word in GLSL ES 3.00 with enabled extension, otherwise could be used as an identifier/type name // a reserved word in GLSL ES 3.00 with enabled extension, otherwise could be used as an identifier/type name
if (context->getShaderVersion() >= 300 && context->isExtensionEnabled("GL_EXT_YUV_target")) if (context->getShaderVersion() >= 300 && context->isExtensionEnabled(TExtension::EXT_YUV_target))
{ {
yylval->lex.string = NewPoolTString(yytext); yylval->lex.string = NewPoolTString(yytext);
return YUVCSCSTANDARDEXTCONSTANT; return YUVCSCSTANDARDEXTCONSTANT;
...@@ -686,7 +686,7 @@ int glslang_scan(size_t count, const char* const string[], const int length[], ...@@ -686,7 +686,7 @@ int glslang_scan(size_t count, const char* const string[], const int length[],
const TExtensionBehavior& extBehavior = context->extensionBehavior(); const TExtensionBehavior& extBehavior = context->extensionBehavior();
for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
iter != extBehavior.end(); ++iter) { iter != extBehavior.end(); ++iter) {
preprocessor->predefineMacro(iter->first.c_str(), 1); preprocessor->predefineMacro(GetExtensionNameString(iter->first), 1);
} }
if (context->getFragmentPrecisionHigh()) if (context->getFragmentPrecisionHigh())
preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1); preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1);
......
...@@ -146,7 +146,7 @@ extern void yyerror(YYLTYPE* yylloc, TParseContext* context, void *scanner, cons ...@@ -146,7 +146,7 @@ extern void yyerror(YYLTYPE* yylloc, TParseContext* context, void *scanner, cons
} }
#define ES3_OR_NEWER_OR_MULTIVIEW(TOKEN, LINE, REASON) { \ #define ES3_OR_NEWER_OR_MULTIVIEW(TOKEN, LINE, REASON) { \
if (context->getShaderVersion() < 300 && !context->isMultiviewExtensionEnabled()) { \ if (context->getShaderVersion() < 300 && !context->isExtensionEnabled(TExtension::OVR_multiview)) { \
context->error(LINE, REASON " supported in GLSL ES 3.00 and above only", TOKEN); \ context->error(LINE, REASON " supported in GLSL ES 3.00 and above only", TOKEN); \
} \ } \
} }
...@@ -279,7 +279,7 @@ primary_expression ...@@ -279,7 +279,7 @@ primary_expression
$$ = context->addScalarLiteral(unionArray, @1); $$ = context->addScalarLiteral(unionArray, @1);
} }
| YUVCSCSTANDARDEXTCONSTANT { | YUVCSCSTANDARDEXTCONSTANT {
if (!context->isExtensionEnabled("GL_EXT_YUV_target")) { if (!context->isExtensionEnabled(TExtension::EXT_YUV_target)) {
context->error(@1, "unsupported value", $1.string->c_str()); context->error(@1, "unsupported value", $1.string->c_str());
} }
TConstantUnion *unionArray = new TConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
...@@ -1049,7 +1049,7 @@ type_specifier_nonarray ...@@ -1049,7 +1049,7 @@ type_specifier_nonarray
$$.setMatrix(4, 3); $$.setMatrix(4, 3);
} }
| YUVCSCSTANDARDEXT { | YUVCSCSTANDARDEXT {
if (!context->isExtensionEnabled("GL_EXT_YUV_target")) { if (!context->isExtensionEnabled(TExtension::EXT_YUV_target)) {
context->error(@1, "unsupported type", "yuvCscStandardEXT"); context->error(@1, "unsupported type", "yuvCscStandardEXT");
} }
$$.initialize(EbtYuvCscStandardEXT, @1); $$.initialize(EbtYuvCscStandardEXT, @1);
...@@ -1109,20 +1109,20 @@ type_specifier_nonarray ...@@ -1109,20 +1109,20 @@ type_specifier_nonarray
$$.initialize(EbtSampler2DArrayShadow, @1); $$.initialize(EbtSampler2DArrayShadow, @1);
} }
| SAMPLER_EXTERNAL_OES { | SAMPLER_EXTERNAL_OES {
if (!context->supportsExtension("GL_OES_EGL_image_external") && if (!context->supportsExtension(TExtension::OES_EGL_image_external) &&
!context->supportsExtension("GL_NV_EGL_stream_consumer_external")) { !context->supportsExtension(TExtension::NV_EGL_stream_consumer_external)) {
context->error(@1, "unsupported type", "samplerExternalOES"); context->error(@1, "unsupported type", "samplerExternalOES");
} }
$$.initialize(EbtSamplerExternalOES, @1); $$.initialize(EbtSamplerExternalOES, @1);
} }
| SAMPLEREXTERNAL2DY2YEXT { | SAMPLEREXTERNAL2DY2YEXT {
if (!context->isExtensionEnabled("GL_EXT_YUV_target")) { if (!context->isExtensionEnabled(TExtension::EXT_YUV_target)) {
context->error(@1, "unsupported type", "__samplerExternal2DY2YEXT"); context->error(@1, "unsupported type", "__samplerExternal2DY2YEXT");
} }
$$.initialize(EbtSamplerExternal2DY2YEXT, @1); $$.initialize(EbtSamplerExternal2DY2YEXT, @1);
} }
| SAMPLER2DRECT { | SAMPLER2DRECT {
if (!context->supportsExtension("GL_ARB_texture_rectangle")) { if (!context->supportsExtension(TExtension::ARB_texture_rectangle)) {
context->error(@1, "unsupported type", "sampler2DRect"); context->error(@1, "unsupported type", "sampler2DRect");
} }
$$.initialize(EbtSampler2DRect, @1); $$.initialize(EbtSampler2DRect, @1);
......
...@@ -63,13 +63,37 @@ ...@@ -63,13 +63,37 @@
#define yyget_lval yyget_lval
#define yyset_lval yyset_lval #ifdef yyget_lval
#define yyget_lval_ALREADY_DEFINED
#else
#define yyget_lval yyget_lval
#endif
#ifdef yyset_lval
#define yyset_lval_ALREADY_DEFINED
#else
#define yyset_lval yyset_lval
#endif
#define yyget_lloc yyget_lloc
#define yyset_lloc yyset_lloc #ifdef yyget_lloc
#define yyget_lloc_ALREADY_DEFINED
#else
#define yyget_lloc yyget_lloc
#endif
#ifdef yyset_lloc
#define yyset_lloc_ALREADY_DEFINED
#else
#define yyset_lloc yyset_lloc
#endif
...@@ -1195,7 +1219,7 @@ static int ES2_ident_ES3_keyword_multiview_keyword(TParseContext *context, int t ...@@ -1195,7 +1219,7 @@ static int ES2_ident_ES3_keyword_multiview_keyword(TParseContext *context, int t
static int ES2_ident_ES3_reserved_ES3_1_keyword(TParseContext *context, int token); static int ES2_ident_ES3_reserved_ES3_1_keyword(TParseContext *context, int token);
static int ES2_and_ES3_reserved_ES3_1_keyword(TParseContext *context, int token); static int ES2_and_ES3_reserved_ES3_1_keyword(TParseContext *context, int token);
static int ES2_and_ES3_ident_ES3_1_keyword(TParseContext *context, int token); static int ES2_and_ES3_ident_ES3_1_keyword(TParseContext *context, int token);
static int ES3_extension_keyword_else_ident(TParseContext *context, const char *extension, int token); static int ES3_extension_keyword_else_ident(TParseContext *context, TExtension extension, int token);
static int uint_constant(TParseContext *context); static int uint_constant(TParseContext *context);
static int int_constant(TParseContext *context); static int int_constant(TParseContext *context);
static int float_constant(yyscan_t yyscanner); static int float_constant(yyscan_t yyscanner);
...@@ -1995,7 +2019,7 @@ YY_RULE_SETUP ...@@ -1995,7 +2019,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 82: case 82:
YY_RULE_SETUP YY_RULE_SETUP
{ return ES3_extension_keyword_else_ident(context, "GL_EXT_YUV_target", SAMPLEREXTERNAL2DY2YEXT); } { return ES3_extension_keyword_else_ident(context, TExtension::EXT_YUV_target, SAMPLEREXTERNAL2DY2YEXT); }
YY_BREAK YY_BREAK
case 83: case 83:
YY_RULE_SETUP YY_RULE_SETUP
...@@ -2007,7 +2031,7 @@ YY_RULE_SETUP ...@@ -2007,7 +2031,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 85: case 85:
YY_RULE_SETUP YY_RULE_SETUP
{ return ES3_extension_keyword_else_ident(context, "GL_EXT_YUV_target", YUVCSCSTANDARDEXT); } { return ES3_extension_keyword_else_ident(context, TExtension::EXT_YUV_target, YUVCSCSTANDARDEXT); }
YY_BREAK YY_BREAK
case 86: case 86:
YY_RULE_SETUP YY_RULE_SETUP
...@@ -2736,6 +2760,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) ...@@ -2736,6 +2760,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
/* "- 2" to take care of EOB's */
YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
} }
yyg->yy_n_chars += number_to_move; yyg->yy_n_chars += number_to_move;
...@@ -3853,7 +3879,7 @@ int ES2_ident_ES3_keyword_multiview_keyword(TParseContext *context, int token) ...@@ -3853,7 +3879,7 @@ int ES2_ident_ES3_keyword_multiview_keyword(TParseContext *context, int token)
// not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name // not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name
// except when multiview extension is enabled // except when multiview extension is enabled
if (context->getShaderVersion() < 300 && !context->isMultiviewExtensionEnabled()) if (context->getShaderVersion() < 300 && !context->isExtensionEnabled(TExtension::OVR_multiview))
{ {
yylval->lex.string = NewPoolTString(yytext); yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner); return check_type(yyscanner);
...@@ -3889,7 +3915,7 @@ int ES2_and_ES3_ident_ES3_1_keyword(TParseContext *context, int token) ...@@ -3889,7 +3915,7 @@ int ES2_and_ES3_ident_ES3_1_keyword(TParseContext *context, int token)
return token; return token;
} }
int ES3_extension_keyword_else_ident(TParseContext *context, const char* extension, int token) int ES3_extension_keyword_else_ident(TParseContext *context, TExtension extension, int token)
{ {
struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner();
yyscan_t yyscanner = (yyscan_t) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->getScanner();
...@@ -3971,7 +3997,7 @@ int yuvcscstandardext_constant(TParseContext *context) ...@@ -3971,7 +3997,7 @@ int yuvcscstandardext_constant(TParseContext *context)
yyscan_t yyscanner = (yyscan_t) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->getScanner();
// a reserved word in GLSL ES 3.00 with enabled extension, otherwise could be used as an identifier/type name // a reserved word in GLSL ES 3.00 with enabled extension, otherwise could be used as an identifier/type name
if (context->getShaderVersion() >= 300 && context->isExtensionEnabled("GL_EXT_YUV_target")) if (context->getShaderVersion() >= 300 && context->isExtensionEnabled(TExtension::EXT_YUV_target))
{ {
yylval->lex.string = NewPoolTString(yytext); yylval->lex.string = NewPoolTString(yytext);
return YUVCSCSTANDARDEXTCONSTANT; return YUVCSCSTANDARDEXTCONSTANT;
...@@ -4016,7 +4042,7 @@ int glslang_scan(size_t count, const char* const string[], const int length[], ...@@ -4016,7 +4042,7 @@ int glslang_scan(size_t count, const char* const string[], const int length[],
const TExtensionBehavior& extBehavior = context->extensionBehavior(); const TExtensionBehavior& extBehavior = context->extensionBehavior();
for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
iter != extBehavior.end(); ++iter) { iter != extBehavior.end(); ++iter) {
preprocessor->predefineMacro(iter->first.c_str(), 1); preprocessor->predefineMacro(GetExtensionNameString(iter->first), 1);
} }
if (context->getFragmentPrecisionHigh()) if (context->getFragmentPrecisionHigh())
preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1); preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1);
......
...@@ -416,7 +416,7 @@ extern void yyerror(YYLTYPE* yylloc, TParseContext* context, void *scanner, cons ...@@ -416,7 +416,7 @@ extern void yyerror(YYLTYPE* yylloc, TParseContext* context, void *scanner, cons
} }
#define ES3_OR_NEWER_OR_MULTIVIEW(TOKEN, LINE, REASON) { \ #define ES3_OR_NEWER_OR_MULTIVIEW(TOKEN, LINE, REASON) { \
if (context->getShaderVersion() < 300 && !context->isMultiviewExtensionEnabled()) { \ if (context->getShaderVersion() < 300 && !context->isExtensionEnabled(TExtension::OVR_multiview)) { \
context->error(LINE, REASON " supported in GLSL ES 3.00 and above only", TOKEN); \ context->error(LINE, REASON " supported in GLSL ES 3.00 and above only", TOKEN); \
} \ } \
} }
...@@ -2586,7 +2586,7 @@ yyreduce: ...@@ -2586,7 +2586,7 @@ yyreduce:
case 10: case 10:
{ {
if (!context->isExtensionEnabled("GL_EXT_YUV_target")) { if (!context->isExtensionEnabled(TExtension::EXT_YUV_target)) {
context->error((yylsp[0]), "unsupported value", (yyvsp[0].lex).string->c_str()); context->error((yylsp[0]), "unsupported value", (yyvsp[0].lex).string->c_str());
} }
TConstantUnion *unionArray = new TConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
...@@ -4089,7 +4089,7 @@ yyreduce: ...@@ -4089,7 +4089,7 @@ yyreduce:
case 189: case 189:
{ {
if (!context->isExtensionEnabled("GL_EXT_YUV_target")) { if (!context->isExtensionEnabled(TExtension::EXT_YUV_target)) {
context->error((yylsp[0]), "unsupported type", "yuvCscStandardEXT"); context->error((yylsp[0]), "unsupported type", "yuvCscStandardEXT");
} }
(yyval.interm.typeSpecifierNonArray).initialize(EbtYuvCscStandardEXT, (yylsp[0])); (yyval.interm.typeSpecifierNonArray).initialize(EbtYuvCscStandardEXT, (yylsp[0]));
...@@ -4244,8 +4244,8 @@ yyreduce: ...@@ -4244,8 +4244,8 @@ yyreduce:
case 208: case 208:
{ {
if (!context->supportsExtension("GL_OES_EGL_image_external") && if (!context->supportsExtension(TExtension::OES_EGL_image_external) &&
!context->supportsExtension("GL_NV_EGL_stream_consumer_external")) { !context->supportsExtension(TExtension::NV_EGL_stream_consumer_external)) {
context->error((yylsp[0]), "unsupported type", "samplerExternalOES"); context->error((yylsp[0]), "unsupported type", "samplerExternalOES");
} }
(yyval.interm.typeSpecifierNonArray).initialize(EbtSamplerExternalOES, (yylsp[0])); (yyval.interm.typeSpecifierNonArray).initialize(EbtSamplerExternalOES, (yylsp[0]));
...@@ -4256,7 +4256,7 @@ yyreduce: ...@@ -4256,7 +4256,7 @@ yyreduce:
case 209: case 209:
{ {
if (!context->isExtensionEnabled("GL_EXT_YUV_target")) { if (!context->isExtensionEnabled(TExtension::EXT_YUV_target)) {
context->error((yylsp[0]), "unsupported type", "__samplerExternal2DY2YEXT"); context->error((yylsp[0]), "unsupported type", "__samplerExternal2DY2YEXT");
} }
(yyval.interm.typeSpecifierNonArray).initialize(EbtSamplerExternal2DY2YEXT, (yylsp[0])); (yyval.interm.typeSpecifierNonArray).initialize(EbtSamplerExternal2DY2YEXT, (yylsp[0]));
...@@ -4267,7 +4267,7 @@ yyreduce: ...@@ -4267,7 +4267,7 @@ yyreduce:
case 210: case 210:
{ {
if (!context->supportsExtension("GL_ARB_texture_rectangle")) { if (!context->supportsExtension(TExtension::ARB_texture_rectangle)) {
context->error((yylsp[0]), "unsupported type", "sampler2DRect"); context->error((yylsp[0]), "unsupported type", "sampler2DRect");
} }
(yyval.interm.typeSpecifierNonArray).initialize(EbtSampler2DRect, (yylsp[0])); (yyval.interm.typeSpecifierNonArray).initialize(EbtSampler2DRect, (yylsp[0]));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment