Add GL_OES_EGL_image_external. Includes new keyword, type, name mangling, built-in function calls, etc.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24007 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-11-11 23:29:59 +00:00
parent 99296369d3
commit bd1a5b7727
12 changed files with 118 additions and 8 deletions

View file

@ -65,6 +65,7 @@ struct TSampler {
bool shadow : 1;
bool ms : 1;
bool image : 1;
bool external : 1; // GL_OES_EGL_image_external
void clear()
{
@ -74,6 +75,7 @@ struct TSampler {
shadow = false;
ms = false;
image = false;
external = false;
}
void set(TBasicType t, TSamplerDim d, bool a = false, bool s = false, bool m = false)
@ -84,6 +86,7 @@ struct TSampler {
shadow = s;
ms = m;
image = false;
external = false;
}
void setImage(TBasicType t, TSamplerDim d, bool a = false, bool s = false, bool m = false)
@ -94,6 +97,7 @@ struct TSampler {
shadow = s;
ms = m;
image = true;
external = false;
}
bool operator==(const TSampler& right) const
@ -103,7 +107,8 @@ struct TSampler {
arrayed == right.arrayed &&
shadow == right.shadow &&
ms == right.ms &&
image == right.image;
image == right.image &&
external == right.external;
}
TString getString() const
@ -120,6 +125,10 @@ struct TSampler {
s.append("image");
else
s.append("sampler");
if (external) {
s.append("ExternalOES");
return s;
}
switch (dim) {
case Esd1D: s.append("1D"); break;
case Esd2D: s.append("2D"); break;

View file

@ -686,6 +686,15 @@ void TBuiltIns::initialize(int version, EProfile profile)
"\n");
}
if (profile == EEsProfile) {
// GL_OES_EGL_image_external, caught by keyword check
commonBuiltins.append(
"vec4 texture2D(samplerExternalOES, vec2 coord);"
"vec4 texture2DProj(samplerExternalOES, vec3);"
"vec4 texture2DProj(samplerExternalOES, vec4);"
"\n");
}
//
// Noise functions.
//

View file

@ -74,6 +74,9 @@ TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb,
defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
sampler.set(EbtFloat, EsdCube);
defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
sampler.set(EbtFloat, Esd2D);
sampler.external = true;
defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
switch (language) {
case EShLangFragment:
@ -1715,10 +1718,11 @@ void TParseContext::setDefaultPrecision(TSourceLoc loc, TPublicType& publicType,
// correlates with the declaration of defaultSamplerPrecision[]
int TParseContext::computeSamplerTypeIndex(TSampler& sampler)
{
int arrayIndex = sampler.arrayed ? 1 : 0;
int shadowIndex = sampler.shadow ? 1 : 0;
int arrayIndex = sampler.arrayed ? 1 : 0;
int shadowIndex = sampler.shadow ? 1 : 0;
int externalIndex = sampler.external ? 1 : 0;
return EsdNumDims * (EbtNumTypes * (2 * arrayIndex + shadowIndex) + sampler.type) + sampler.dim;
return EsdNumDims * (EbtNumTypes * (2 * (2 * arrayIndex + shadowIndex) + externalIndex) + sampler.type) + sampler.dim;
}
TPrecisionQualifier TParseContext::getDefaultPrecision(TPublicType& publicType)

View file

@ -238,7 +238,7 @@ protected:
int numErrors; // number of compile-time errors encountered
bool parsingBuiltins; // true if parsing built-in symbols/functions
TMap<TString, TExtensionBehavior> extensionBehavior; // for each extension string, what its current behavior is set to
static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2)); // see computeSamplerTypeIndex()
static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2 * 2)); // see computeSamplerTypeIndex()
TPrecisionQualifier defaultSamplerPrecision[maxSamplerIndex];
bool afterEOF;
TQualifier globalBufferDefaults;

View file

@ -424,6 +424,7 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["sampler2DRect"] = SAMPLER2DRECT;
(*KeywordMap)["sampler2DRectShadow"] = SAMPLER2DRECTSHADOW;
(*KeywordMap)["sampler1DArray"] = SAMPLER1DARRAY;
(*KeywordMap)["samplerExternalOES"] = SAMPLEREXTERNALOES; // GL_OES_EGL_image_external
(*KeywordMap)["noperspective"] = NOPERSPECTIVE;
(*KeywordMap)["smooth"] = SMOOTH;
(*KeywordMap)["flat"] = FLAT;
@ -811,6 +812,12 @@ int TScanContext::tokenizeIdentifier()
return identifierOrType();
return keyword;
case SAMPLEREXTERNALOES:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() || parseContext.extensionsTurnedOn(1, &GL_OES_EGL_image_external))
return keyword;
return identifierOrType();
case NOPERSPECTIVE:
return es30ReservedFromGLSL(130);

View file

@ -77,6 +77,8 @@ void TType::buildMangledName(TString& mangledName)
mangledName += "A";
if (sampler.shadow)
mangledName += "S";
if (sampler.external)
mangledName += "E";
switch (sampler.dim) {
case Esd1D: mangledName += "1"; break;
case Esd2D: mangledName += "2"; break;

View file

@ -152,6 +152,7 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior[GL_OES_texture_3D] = EBhDisable;
extensionBehavior[GL_OES_standard_derivatives] = EBhDisable;
extensionBehavior[GL_EXT_frag_depth] = EBhDisable;
extensionBehavior[GL_OES_EGL_image_external] = EBhDisable;
extensionBehavior[GL_ARB_texture_rectangle] = EBhDisable;
extensionBehavior[GL_3DL_array_objects] = EBhDisable;
@ -169,7 +170,8 @@ const char* TParseContext::getPreamble()
"#define GL_ES 1\n"
"#define GL_OES_texture_3D 1\n"
"#define GL_OES_standard_derivatives 1\n"
"#define GL_EXT_frag_depth 1\n";
"#define GL_EXT_frag_depth 1\n"
"#define GL_OES_EGL_image_external 1\n";
} else {
return
"#define GL_FRAGMENT_PRECISION_HIGH 1\n"

View file

@ -75,6 +75,7 @@ typedef enum {
const char* const GL_OES_texture_3D = "GL_OES_texture_3D";
const char* const GL_OES_standard_derivatives = "GL_OES_standard_derivatives";
const char* const GL_EXT_frag_depth = "GL_EXT_frag_depth";
const char* const GL_OES_EGL_image_external = "GL_OES_EGL_image_external";
const char* const GL_ARB_texture_rectangle = "GL_ARB_texture_rectangle";
const char* const GL_3DL_array_objects = "GL_3DL_array_objects";

View file

@ -139,6 +139,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
%token <lex> ISAMPLERCUBEARRAY USAMPLERCUBEARRAY
%token <lex> SAMPLER2DMS ISAMPLER2DMS USAMPLER2DMS
%token <lex> SAMPLER2DMSARRAY ISAMPLER2DMSARRAY USAMPLER2DMSARRAY
%token <lex> SAMPLEREXTERNALOES
%token <lex> IMAGE1D IIMAGE1D UIMAGE1D IMAGE2D IIMAGE2D
%token <lex> UIMAGE2D IMAGE3D IIMAGE3D UIMAGE3D
@ -1951,6 +1952,12 @@ type_specifier_nonarray
$$.basicType = EbtSampler;
$$.sampler.setImage(EbtUint, Esd2D, true, false, true);
}
| SAMPLEREXTERNALOES { // GL_OES_EGL_image_external
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtSampler;
$$.sampler.set(EbtFloat, Esd2D);
$$.sampler.external = true;
}
| struct_specifier {
$$ = $1;
$$.qualifier.storage = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;