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

Binary file not shown.

View File

@ -110,4 +110,31 @@ void foo239()
{
gl_FragDepth = f13; // ERROR
gl_FragDepthEXT = f13;
}
}
#extension GL_OES_EGL_image_external : enable
uniform samplerExternalOES sExt;
void foo245()
{
texture2D(sExt, vec2(0.2));
texture2DProj(sExt, vec3(f13));
texture2DProj(sExt, v[2]);
}
precision mediump samplerExternalOES;
uniform samplerExternalOES mediumExt;
uniform highp samplerExternalOES highExt;
void foo246()
{
texture2D(mediumExt, vec2(0.2));
texture2DProj(highExt, v[2]);
texture3D(sExt, vec3(f13)); // ERROR
texture2DProjLod(sExt, vec3(f13), f13); // ERROR
}
#extension GL_OES_EGL_image_external : disable
uniform samplerExternalOES badExt; // syntax ERROR

View File

@ -48,7 +48,10 @@ ERROR: 0:93: 'fwidth' : required extension not requested: GL_OES_standard_deriva
ERROR: 0:103: 'gl_FragDepth' : undeclared identifier
ERROR: 0:104: 'gl_FragDepthEXT' : required extension not requested: GL_EXT_frag_depth
ERROR: 0:111: 'gl_FragDepth' : undeclared identifier
ERROR: 43 compilation errors. No code generated.
ERROR: 0:134: 'texture3D' : no matching overloaded function found
ERROR: 0:135: 'texture2DProjLod' : no matching overloaded function found
ERROR: 0:140: '' : syntax error
ERROR: 46 compilation errors. No code generated.
ERROR: node is still EOpNull!
0:3 Sequence
@ -184,6 +187,42 @@ ERROR: node is still EOpNull!
0:112 move second child to first child (highp float)
0:112 'gl_FragDepthEXT' (gl_FragDepth highp float)
0:112 'f13' (invariant mediump float)
0:119 Function Definition: foo245( (void)
0:119 Function Parameters:
0:121 Sequence
0:121 Function Call: texture2D(sE21;vf2; (lowp 4-component vector of float)
0:121 'sExt' (uniform lowp samplerExternalOES)
0:121 Constant:
0:121 0.200000
0:121 0.200000
0:122 Function Call: texture2DProj(sE21;vf3; (lowp 4-component vector of float)
0:122 'sExt' (uniform lowp samplerExternalOES)
0:122 Construct vec3 (3-component vector of float)
0:122 'f13' (invariant mediump float)
0:123 Function Call: texture2DProj(sE21;vf4; (lowp 4-component vector of float)
0:123 'sExt' (uniform lowp samplerExternalOES)
0:123 direct index (smooth mediump 4-component vector of float)
0:123 'v' (smooth in 3-element array of mediump 4-component vector of float)
0:123 Constant:
0:123 2 (const int)
0:130 Function Definition: foo246( (void)
0:130 Function Parameters:
0:132 Sequence
0:132 Function Call: texture2D(sE21;vf2; (mediump 4-component vector of float)
0:132 'mediumExt' (uniform mediump samplerExternalOES)
0:132 Constant:
0:132 0.200000
0:132 0.200000
0:133 Function Call: texture2DProj(sE21;vf4; (highp 4-component vector of float)
0:133 'highExt' (uniform highp samplerExternalOES)
0:133 direct index (smooth mediump 4-component vector of float)
0:133 'v' (smooth in 3-element array of mediump 4-component vector of float)
0:133 Constant:
0:133 2 (const int)
0:134 Constant:
0:134 0.000000
0:135 Constant:
0:135 0.000000
0:? Linker Objects
0:? 'a' (3-element array of mediump int)
0:? 'uint' (mediump int)
@ -200,4 +239,7 @@ ERROR: node is still EOpNull!
0:? 'vary2D' (smooth in lowp sampler2D)
0:? 's3D' (uniform mediump sampler3D)
0:? 's3D2' (uniform highp sampler3D)
0:? 'sExt' (uniform lowp samplerExternalOES)
0:? 'mediumExt' (uniform mediump samplerExternalOES)
0:? 'highExt' (uniform highp samplerExternalOES)

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;