Commit 09c323a4 by zmo@google.com

Add an option to support for GL_OES_EGL_image_external.

Comes with this extension is the new sampler type samplerExternalOES. ANGLEBUG=175 TEST=compile the attached shader file Review URL: http://codereview.appspot.com/4809076 git-svn-id: https://angleproject.googlecode.com/svn/trunk@728 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 6ae8f6ce
...@@ -115,6 +115,7 @@ typedef struct ...@@ -115,6 +115,7 @@ typedef struct
// Extensions. // Extensions.
// Set to 1 to enable the extension, else 0. // Set to 1 to enable the extension, else 0.
int OES_standard_derivatives; int OES_standard_derivatives;
int OES_EGL_image_external;
} ShBuiltInResources; } ShBuiltInResources;
// //
......
...@@ -53,6 +53,7 @@ void GenerateResources(ShBuiltInResources* resources) ...@@ -53,6 +53,7 @@ void GenerateResources(ShBuiltInResources* resources)
resources->MaxDrawBuffers = 1; resources->MaxDrawBuffers = 1;
resources->OES_standard_derivatives = 0; resources->OES_standard_derivatives = 0;
resources->OES_EGL_image_external = 0;
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
...@@ -94,6 +95,7 @@ int main(int argc, char* argv[]) ...@@ -94,6 +95,7 @@ int main(int argc, char* argv[])
failCode = EFailUsage; failCode = EFailUsage;
} }
break; break;
case 'a': resources.OES_EGL_image_external = 1; break;
default: failCode = EFailUsage; default: failCode = EFailUsage;
} }
} else { } else {
...@@ -174,7 +176,7 @@ int main(int argc, char* argv[]) ...@@ -174,7 +176,7 @@ int main(int argc, char* argv[])
// //
void usage() void usage()
{ {
printf("Usage: translate [-i -m -o -u -b=e -b=g -b=h] file1 file2 ...\n" printf("Usage: translate [-i -m -o -u -b=e -b=g -b=h -a] file1 file2 ...\n"
"Where: filename : filename ending in .frag or .vert\n" "Where: filename : filename ending in .frag or .vert\n"
" -i : print intermediate tree\n" " -i : print intermediate tree\n"
" -m : map long variable names\n" " -m : map long variable names\n"
...@@ -182,7 +184,8 @@ void usage() ...@@ -182,7 +184,8 @@ void usage()
" -u : print active attribs and uniforms\n" " -u : print active attribs and uniforms\n"
" -b=e : output GLSL ES code (this is by default)\n" " -b=e : output GLSL ES code (this is by default)\n"
" -b=g : output GLSL code\n" " -b=g : output GLSL code\n"
" -b=h : output HLSL code\n"); " -b=h : output HLSL code\n"
" -a : enable GL_OES_EGL_image_external\n");
} }
// //
......
#define MAJOR_VERSION 0 #define MAJOR_VERSION 0
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 725 #define BUILD_REVISION 726
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -42,6 +42,7 @@ enum TBasicType ...@@ -42,6 +42,7 @@ enum TBasicType
EbtGuardSamplerBegin, // non type: see implementation of IsSampler() EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
EbtSampler2D, EbtSampler2D,
EbtSamplerCube, EbtSamplerCube,
EbtSamplerExternalOES, // Only valid if OES_EGL_image_external exists.
EbtGuardSamplerEnd, // non type: see implementation of IsSampler() EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
EbtStruct, EbtStruct,
EbtAddress, // should be deprecated?? EbtAddress, // should be deprecated??
...@@ -57,6 +58,7 @@ inline const char* getBasicString(TBasicType t) ...@@ -57,6 +58,7 @@ inline const char* getBasicString(TBasicType t)
case EbtBool: return "bool"; break; case EbtBool: return "bool"; break;
case EbtSampler2D: return "sampler2D"; break; case EbtSampler2D: return "sampler2D"; break;
case EbtSamplerCube: return "samplerCube"; break; case EbtSamplerCube: return "samplerCube"; break;
case EbtSamplerExternalOES: return "samplerExternalOES"; break;
case EbtStruct: return "structure"; break; case EbtStruct: return "structure"; break;
default: return "unknown type"; default: return "unknown type";
} }
......
...@@ -19,6 +19,7 @@ bool InitializeSymbolTable( ...@@ -19,6 +19,7 @@ bool InitializeSymbolTable(
{ {
TIntermediate intermediate(infoSink); TIntermediate intermediate(infoSink);
TExtensionBehavior extBehavior; TExtensionBehavior extBehavior;
InitExtensionBehavior(resources, extBehavior);
// The builtins deliberately don't specify precisions for the function // The builtins deliberately don't specify precisions for the function
// arguments and return types. For that reason we don't try to check them. // arguments and return types. For that reason we don't try to check them.
TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, 0, false, NULL, infoSink); TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, 0, false, NULL, infoSink);
......
...@@ -13,7 +13,8 @@ typedef enum { ...@@ -13,7 +13,8 @@ typedef enum {
EBhRequire, EBhRequire,
EBhEnable, EBhEnable,
EBhWarn, EBhWarn,
EBhDisable EBhDisable,
EBhUndefined,
} TBehavior; } TBehavior;
inline const char* getBehaviorString(TBehavior b) inline const char* getBehaviorString(TBehavior b)
......
...@@ -363,6 +363,12 @@ static TString BuiltInFunctionsVertex(const ShBuiltInResources& resources) ...@@ -363,6 +363,12 @@ static TString BuiltInFunctionsVertex(const ShBuiltInResources& resources)
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);")); s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));
s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);")); s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));
if (resources.OES_EGL_image_external) {
s.append(TString("vec4 texture2D(samplerExternalOES sampler, vec2 coord);"));
s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec3 coord);"));
s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec4 coord);"));
}
return s; return s;
} }
...@@ -388,6 +394,12 @@ static TString BuiltInFunctionsFragment(const ShBuiltInResources& resources) ...@@ -388,6 +394,12 @@ static TString BuiltInFunctionsFragment(const ShBuiltInResources& resources)
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);")); s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);"));
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);")); s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);"));
if (resources.OES_EGL_image_external) {
s.append(TString("vec4 texture2D(samplerExternalOES sampler, vec2 coord);"));
s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec3 coord);"));
s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec4 coord);"));
}
if (resources.OES_standard_derivatives) { if (resources.OES_standard_derivatives) {
s.append(TString("float dFdx(float p);")); s.append(TString("float dFdx(float p);"));
s.append(TString("vec2 dFdx(vec2 p);")); s.append(TString("vec2 dFdx(vec2 p);"));
...@@ -625,5 +637,7 @@ void InitExtensionBehavior(const ShBuiltInResources& resources, ...@@ -625,5 +637,7 @@ void InitExtensionBehavior(const ShBuiltInResources& resources,
TExtensionBehavior& extBehavior) TExtensionBehavior& extBehavior)
{ {
if (resources.OES_standard_derivatives) if (resources.OES_standard_derivatives)
extBehavior["GL_OES_standard_derivatives"] = EBhDisable; extBehavior["GL_OES_standard_derivatives"] = EBhUndefined;
if (resources.OES_EGL_image_external)
extBehavior["GL_OES_EGL_image_external"] = EBhUndefined;
} }
...@@ -943,6 +943,12 @@ bool TParseContext::extensionErrorCheck(int line, const TString& extension) ...@@ -943,6 +943,12 @@ bool TParseContext::extensionErrorCheck(int line, const TString& extension)
return false; return false;
} }
bool TParseContext::supportsExtension(const char* extension)
{
TExtensionBehavior::const_iterator iter = extensionBehavior.find(extension);
return (iter != extensionBehavior.end());
}
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Non-Errors. // Non-Errors.
......
...@@ -85,6 +85,7 @@ struct TParseContext { ...@@ -85,6 +85,7 @@ struct TParseContext {
bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type, TVariable*& variable); bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type, TVariable*& variable);
bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type); bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
bool extensionErrorCheck(int line, const TString&); bool extensionErrorCheck(int line, const TString&);
bool supportsExtension(const char* extension);
const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0); const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0);
bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType, bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType,
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0); TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
......
...@@ -104,6 +104,7 @@ void ShInitBuiltInResources(ShBuiltInResources* resources) ...@@ -104,6 +104,7 @@ void ShInitBuiltInResources(ShBuiltInResources* resources)
// Extensions. // Extensions.
resources->OES_standard_derivatives = 0; resources->OES_standard_derivatives = 0;
resources->OES_EGL_image_external = 0;
} }
// //
......
...@@ -28,7 +28,9 @@ void TranslatorESSL::writeExtensionBehavior() { ...@@ -28,7 +28,9 @@ void TranslatorESSL::writeExtensionBehavior() {
const TExtensionBehavior& extensionBehavior = getExtensionBehavior(); const TExtensionBehavior& extensionBehavior = getExtensionBehavior();
for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin(); for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin();
iter != extensionBehavior.end(); ++iter) { iter != extensionBehavior.end(); ++iter) {
sink << "#extension " << iter->first << " : " if (iter->second != EBhUndefined) {
<< getBehaviorString(iter->second) << "\n"; sink << "#extension " << iter->first << " : "
<< getBehaviorString(iter->second) << "\n";
}
} }
} }
...@@ -120,6 +120,7 @@ O [0-7] ...@@ -120,6 +120,7 @@ O [0-7]
"sampler2D" { context->lexAfterType = true; return SAMPLER2D; } "sampler2D" { context->lexAfterType = true; return SAMPLER2D; }
"samplerCube" { context->lexAfterType = true; return SAMPLERCUBE; } "samplerCube" { context->lexAfterType = true; return SAMPLERCUBE; }
"samplerExternalOES" { context->lexAfterType = true; return SAMPLER_EXTERNAL_OES; }
"struct" { context->lexAfterType = true; return(STRUCT); } "struct" { context->lexAfterType = true; return(STRUCT); }
......
...@@ -98,7 +98,7 @@ extern void yyerror(TParseContext* context, const char* reason); ...@@ -98,7 +98,7 @@ extern void yyerror(TParseContext* context, const char* reason);
%token <lex> BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4 %token <lex> BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4
%token <lex> MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING %token <lex> MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING
%token <lex> STRUCT VOID_TYPE WHILE %token <lex> STRUCT VOID_TYPE WHILE
%token <lex> SAMPLER2D SAMPLERCUBE %token <lex> SAMPLER2D SAMPLERCUBE SAMPLER_EXTERNAL_OES
%token <lex> IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT BOOLCONSTANT %token <lex> IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT BOOLCONSTANT
%token <lex> FIELD_SELECTION %token <lex> FIELD_SELECTION
...@@ -1615,6 +1615,15 @@ type_specifier_nonarray ...@@ -1615,6 +1615,15 @@ type_specifier_nonarray
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtSamplerCube, qual, $1.line); $$.setBasic(EbtSamplerCube, qual, $1.line);
} }
| SAMPLER_EXTERNAL_OES {
if (!context->supportsExtension("GL_OES_EGL_image_external")) {
context->error($1.line, "unsupported type", "samplerExternalOES", "");
context->recover();
}
FRAG_VERT_ONLY("samplerExternalOES", $1.line);
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtSamplerExternalOES, qual, $1.line);
}
| struct_specifier { | struct_specifier {
FRAG_VERT_ONLY("struct", $1.line); FRAG_VERT_ONLY("struct", $1.line);
$$ = $1; $$ = $1;
......
...@@ -79,57 +79,58 @@ ...@@ -79,57 +79,58 @@
WHILE = 295, WHILE = 295,
SAMPLER2D = 296, SAMPLER2D = 296,
SAMPLERCUBE = 297, SAMPLERCUBE = 297,
IDENTIFIER = 298, SAMPLER_EXTERNAL_OES = 298,
TYPE_NAME = 299, IDENTIFIER = 299,
FLOATCONSTANT = 300, TYPE_NAME = 300,
INTCONSTANT = 301, FLOATCONSTANT = 301,
BOOLCONSTANT = 302, INTCONSTANT = 302,
FIELD_SELECTION = 303, BOOLCONSTANT = 303,
LEFT_OP = 304, FIELD_SELECTION = 304,
RIGHT_OP = 305, LEFT_OP = 305,
INC_OP = 306, RIGHT_OP = 306,
DEC_OP = 307, INC_OP = 307,
LE_OP = 308, DEC_OP = 308,
GE_OP = 309, LE_OP = 309,
EQ_OP = 310, GE_OP = 310,
NE_OP = 311, EQ_OP = 311,
AND_OP = 312, NE_OP = 312,
OR_OP = 313, AND_OP = 313,
XOR_OP = 314, OR_OP = 314,
MUL_ASSIGN = 315, XOR_OP = 315,
DIV_ASSIGN = 316, MUL_ASSIGN = 316,
ADD_ASSIGN = 317, DIV_ASSIGN = 317,
MOD_ASSIGN = 318, ADD_ASSIGN = 318,
LEFT_ASSIGN = 319, MOD_ASSIGN = 319,
RIGHT_ASSIGN = 320, LEFT_ASSIGN = 320,
AND_ASSIGN = 321, RIGHT_ASSIGN = 321,
XOR_ASSIGN = 322, AND_ASSIGN = 322,
OR_ASSIGN = 323, XOR_ASSIGN = 323,
SUB_ASSIGN = 324, OR_ASSIGN = 324,
LEFT_PAREN = 325, SUB_ASSIGN = 325,
RIGHT_PAREN = 326, LEFT_PAREN = 326,
LEFT_BRACKET = 327, RIGHT_PAREN = 327,
RIGHT_BRACKET = 328, LEFT_BRACKET = 328,
LEFT_BRACE = 329, RIGHT_BRACKET = 329,
RIGHT_BRACE = 330, LEFT_BRACE = 330,
DOT = 331, RIGHT_BRACE = 331,
COMMA = 332, DOT = 332,
COLON = 333, COMMA = 333,
EQUAL = 334, COLON = 334,
SEMICOLON = 335, EQUAL = 335,
BANG = 336, SEMICOLON = 336,
DASH = 337, BANG = 337,
TILDE = 338, DASH = 338,
PLUS = 339, TILDE = 339,
STAR = 340, PLUS = 340,
SLASH = 341, STAR = 341,
PERCENT = 342, SLASH = 342,
LEFT_ANGLE = 343, PERCENT = 343,
RIGHT_ANGLE = 344, LEFT_ANGLE = 344,
VERTICAL_BAR = 345, RIGHT_ANGLE = 345,
CARET = 346, VERTICAL_BAR = 346,
AMPERSAND = 347, CARET = 347,
QUESTION = 348 AMPERSAND = 348,
QUESTION = 349
}; };
#endif #endif
/* Tokens. */ /* Tokens. */
...@@ -173,57 +174,58 @@ ...@@ -173,57 +174,58 @@
#define WHILE 295 #define WHILE 295
#define SAMPLER2D 296 #define SAMPLER2D 296
#define SAMPLERCUBE 297 #define SAMPLERCUBE 297
#define IDENTIFIER 298 #define SAMPLER_EXTERNAL_OES 298
#define TYPE_NAME 299 #define IDENTIFIER 299
#define FLOATCONSTANT 300 #define TYPE_NAME 300
#define INTCONSTANT 301 #define FLOATCONSTANT 301
#define BOOLCONSTANT 302 #define INTCONSTANT 302
#define FIELD_SELECTION 303 #define BOOLCONSTANT 303
#define LEFT_OP 304 #define FIELD_SELECTION 304
#define RIGHT_OP 305 #define LEFT_OP 305
#define INC_OP 306 #define RIGHT_OP 306
#define DEC_OP 307 #define INC_OP 307
#define LE_OP 308 #define DEC_OP 308
#define GE_OP 309 #define LE_OP 309
#define EQ_OP 310 #define GE_OP 310
#define NE_OP 311 #define EQ_OP 311
#define AND_OP 312 #define NE_OP 312
#define OR_OP 313 #define AND_OP 313
#define XOR_OP 314 #define OR_OP 314
#define MUL_ASSIGN 315 #define XOR_OP 315
#define DIV_ASSIGN 316 #define MUL_ASSIGN 316
#define ADD_ASSIGN 317 #define DIV_ASSIGN 317
#define MOD_ASSIGN 318 #define ADD_ASSIGN 318
#define LEFT_ASSIGN 319 #define MOD_ASSIGN 319
#define RIGHT_ASSIGN 320 #define LEFT_ASSIGN 320
#define AND_ASSIGN 321 #define RIGHT_ASSIGN 321
#define XOR_ASSIGN 322 #define AND_ASSIGN 322
#define OR_ASSIGN 323 #define XOR_ASSIGN 323
#define SUB_ASSIGN 324 #define OR_ASSIGN 324
#define LEFT_PAREN 325 #define SUB_ASSIGN 325
#define RIGHT_PAREN 326 #define LEFT_PAREN 326
#define LEFT_BRACKET 327 #define RIGHT_PAREN 327
#define RIGHT_BRACKET 328 #define LEFT_BRACKET 328
#define LEFT_BRACE 329 #define RIGHT_BRACKET 329
#define RIGHT_BRACE 330 #define LEFT_BRACE 330
#define DOT 331 #define RIGHT_BRACE 331
#define COMMA 332 #define DOT 332
#define COLON 333 #define COMMA 333
#define EQUAL 334 #define COLON 334
#define SEMICOLON 335 #define EQUAL 335
#define BANG 336 #define SEMICOLON 336
#define DASH 337 #define BANG 337
#define TILDE 338 #define DASH 338
#define PLUS 339 #define TILDE 339
#define STAR 340 #define PLUS 340
#define SLASH 341 #define STAR 341
#define PERCENT 342 #define SLASH 342
#define LEFT_ANGLE 343 #define PERCENT 343
#define RIGHT_ANGLE 344 #define LEFT_ANGLE 344
#define VERTICAL_BAR 345 #define RIGHT_ANGLE 345
#define CARET 346 #define VERTICAL_BAR 346
#define AMPERSAND 347 #define CARET 347
#define QUESTION 348 #define AMPERSAND 348
#define QUESTION 349
......
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