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
// Extensions.
// Set to 1 to enable the extension, else 0.
int OES_standard_derivatives;
int OES_EGL_image_external;
} ShBuiltInResources;
//
......
......@@ -53,6 +53,7 @@ void GenerateResources(ShBuiltInResources* resources)
resources->MaxDrawBuffers = 1;
resources->OES_standard_derivatives = 0;
resources->OES_EGL_image_external = 0;
}
int main(int argc, char* argv[])
......@@ -94,6 +95,7 @@ int main(int argc, char* argv[])
failCode = EFailUsage;
}
break;
case 'a': resources.OES_EGL_image_external = 1; break;
default: failCode = EFailUsage;
}
} else {
......@@ -174,7 +176,7 @@ int main(int argc, char* argv[])
//
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"
" -i : print intermediate tree\n"
" -m : map long variable names\n"
......@@ -182,7 +184,8 @@ void usage()
" -u : print active attribs and uniforms\n"
" -b=e : output GLSL ES code (this is by default)\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 MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 725
#define BUILD_REVISION 726
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -42,6 +42,7 @@ enum TBasicType
EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
EbtSampler2D,
EbtSamplerCube,
EbtSamplerExternalOES, // Only valid if OES_EGL_image_external exists.
EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
EbtStruct,
EbtAddress, // should be deprecated??
......@@ -57,6 +58,7 @@ inline const char* getBasicString(TBasicType t)
case EbtBool: return "bool"; break;
case EbtSampler2D: return "sampler2D"; break;
case EbtSamplerCube: return "samplerCube"; break;
case EbtSamplerExternalOES: return "samplerExternalOES"; break;
case EbtStruct: return "structure"; break;
default: return "unknown type";
}
......
......@@ -19,6 +19,7 @@ bool InitializeSymbolTable(
{
TIntermediate intermediate(infoSink);
TExtensionBehavior extBehavior;
InitExtensionBehavior(resources, extBehavior);
// The builtins deliberately don't specify precisions for the function
// 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);
......
......@@ -13,7 +13,8 @@ typedef enum {
EBhRequire,
EBhEnable,
EBhWarn,
EBhDisable
EBhDisable,
EBhUndefined,
} TBehavior;
inline const char* getBehaviorString(TBehavior b)
......
......@@ -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 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;
}
......@@ -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 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) {
s.append(TString("float dFdx(float p);"));
s.append(TString("vec2 dFdx(vec2 p);"));
......@@ -625,5 +637,7 @@ void InitExtensionBehavior(const ShBuiltInResources& resources,
TExtensionBehavior& extBehavior)
{
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)
return false;
}
bool TParseContext::supportsExtension(const char* extension)
{
TExtensionBehavior::const_iterator iter = extensionBehavior.find(extension);
return (iter != extensionBehavior.end());
}
/////////////////////////////////////////////////////////////////////////////////
//
// Non-Errors.
......
......@@ -85,6 +85,7 @@ struct TParseContext {
bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type, TVariable*& variable);
bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
bool extensionErrorCheck(int line, const TString&);
bool supportsExtension(const char* extension);
const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0);
bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType,
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
......
......@@ -104,6 +104,7 @@ void ShInitBuiltInResources(ShBuiltInResources* resources)
// Extensions.
resources->OES_standard_derivatives = 0;
resources->OES_EGL_image_external = 0;
}
//
......
......@@ -28,7 +28,9 @@ void TranslatorESSL::writeExtensionBehavior() {
const TExtensionBehavior& extensionBehavior = getExtensionBehavior();
for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin();
iter != extensionBehavior.end(); ++iter) {
sink << "#extension " << iter->first << " : "
<< getBehaviorString(iter->second) << "\n";
if (iter->second != EBhUndefined) {
sink << "#extension " << iter->first << " : "
<< getBehaviorString(iter->second) << "\n";
}
}
}
......@@ -120,6 +120,7 @@ O [0-7]
"sampler2D" { context->lexAfterType = true; return SAMPLER2D; }
"samplerCube" { context->lexAfterType = true; return SAMPLERCUBE; }
"samplerExternalOES" { context->lexAfterType = true; return SAMPLER_EXTERNAL_OES; }
"struct" { context->lexAfterType = true; return(STRUCT); }
......
......@@ -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> MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING
%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> FIELD_SELECTION
......@@ -1615,6 +1615,15 @@ type_specifier_nonarray
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.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 {
FRAG_VERT_ONLY("struct", $1.line);
$$ = $1;
......
......@@ -79,57 +79,58 @@
WHILE = 295,
SAMPLER2D = 296,
SAMPLERCUBE = 297,
IDENTIFIER = 298,
TYPE_NAME = 299,
FLOATCONSTANT = 300,
INTCONSTANT = 301,
BOOLCONSTANT = 302,
FIELD_SELECTION = 303,
LEFT_OP = 304,
RIGHT_OP = 305,
INC_OP = 306,
DEC_OP = 307,
LE_OP = 308,
GE_OP = 309,
EQ_OP = 310,
NE_OP = 311,
AND_OP = 312,
OR_OP = 313,
XOR_OP = 314,
MUL_ASSIGN = 315,
DIV_ASSIGN = 316,
ADD_ASSIGN = 317,
MOD_ASSIGN = 318,
LEFT_ASSIGN = 319,
RIGHT_ASSIGN = 320,
AND_ASSIGN = 321,
XOR_ASSIGN = 322,
OR_ASSIGN = 323,
SUB_ASSIGN = 324,
LEFT_PAREN = 325,
RIGHT_PAREN = 326,
LEFT_BRACKET = 327,
RIGHT_BRACKET = 328,
LEFT_BRACE = 329,
RIGHT_BRACE = 330,
DOT = 331,
COMMA = 332,
COLON = 333,
EQUAL = 334,
SEMICOLON = 335,
BANG = 336,
DASH = 337,
TILDE = 338,
PLUS = 339,
STAR = 340,
SLASH = 341,
PERCENT = 342,
LEFT_ANGLE = 343,
RIGHT_ANGLE = 344,
VERTICAL_BAR = 345,
CARET = 346,
AMPERSAND = 347,
QUESTION = 348
SAMPLER_EXTERNAL_OES = 298,
IDENTIFIER = 299,
TYPE_NAME = 300,
FLOATCONSTANT = 301,
INTCONSTANT = 302,
BOOLCONSTANT = 303,
FIELD_SELECTION = 304,
LEFT_OP = 305,
RIGHT_OP = 306,
INC_OP = 307,
DEC_OP = 308,
LE_OP = 309,
GE_OP = 310,
EQ_OP = 311,
NE_OP = 312,
AND_OP = 313,
OR_OP = 314,
XOR_OP = 315,
MUL_ASSIGN = 316,
DIV_ASSIGN = 317,
ADD_ASSIGN = 318,
MOD_ASSIGN = 319,
LEFT_ASSIGN = 320,
RIGHT_ASSIGN = 321,
AND_ASSIGN = 322,
XOR_ASSIGN = 323,
OR_ASSIGN = 324,
SUB_ASSIGN = 325,
LEFT_PAREN = 326,
RIGHT_PAREN = 327,
LEFT_BRACKET = 328,
RIGHT_BRACKET = 329,
LEFT_BRACE = 330,
RIGHT_BRACE = 331,
DOT = 332,
COMMA = 333,
COLON = 334,
EQUAL = 335,
SEMICOLON = 336,
BANG = 337,
DASH = 338,
TILDE = 339,
PLUS = 340,
STAR = 341,
SLASH = 342,
PERCENT = 343,
LEFT_ANGLE = 344,
RIGHT_ANGLE = 345,
VERTICAL_BAR = 346,
CARET = 347,
AMPERSAND = 348,
QUESTION = 349
};
#endif
/* Tokens. */
......@@ -173,57 +174,58 @@
#define WHILE 295
#define SAMPLER2D 296
#define SAMPLERCUBE 297
#define IDENTIFIER 298
#define TYPE_NAME 299
#define FLOATCONSTANT 300
#define INTCONSTANT 301
#define BOOLCONSTANT 302
#define FIELD_SELECTION 303
#define LEFT_OP 304
#define RIGHT_OP 305
#define INC_OP 306
#define DEC_OP 307
#define LE_OP 308
#define GE_OP 309
#define EQ_OP 310
#define NE_OP 311
#define AND_OP 312
#define OR_OP 313
#define XOR_OP 314
#define MUL_ASSIGN 315
#define DIV_ASSIGN 316
#define ADD_ASSIGN 317
#define MOD_ASSIGN 318
#define LEFT_ASSIGN 319
#define RIGHT_ASSIGN 320
#define AND_ASSIGN 321
#define XOR_ASSIGN 322
#define OR_ASSIGN 323
#define SUB_ASSIGN 324
#define LEFT_PAREN 325
#define RIGHT_PAREN 326
#define LEFT_BRACKET 327
#define RIGHT_BRACKET 328
#define LEFT_BRACE 329
#define RIGHT_BRACE 330
#define DOT 331
#define COMMA 332
#define COLON 333
#define EQUAL 334
#define SEMICOLON 335
#define BANG 336
#define DASH 337
#define TILDE 338
#define PLUS 339
#define STAR 340
#define SLASH 341
#define PERCENT 342
#define LEFT_ANGLE 343
#define RIGHT_ANGLE 344
#define VERTICAL_BAR 345
#define CARET 346
#define AMPERSAND 347
#define QUESTION 348
#define SAMPLER_EXTERNAL_OES 298
#define IDENTIFIER 299
#define TYPE_NAME 300
#define FLOATCONSTANT 301
#define INTCONSTANT 302
#define BOOLCONSTANT 303
#define FIELD_SELECTION 304
#define LEFT_OP 305
#define RIGHT_OP 306
#define INC_OP 307
#define DEC_OP 308
#define LE_OP 309
#define GE_OP 310
#define EQ_OP 311
#define NE_OP 312
#define AND_OP 313
#define OR_OP 314
#define XOR_OP 315
#define MUL_ASSIGN 316
#define DIV_ASSIGN 317
#define ADD_ASSIGN 318
#define MOD_ASSIGN 319
#define LEFT_ASSIGN 320
#define RIGHT_ASSIGN 321
#define AND_ASSIGN 322
#define XOR_ASSIGN 323
#define OR_ASSIGN 324
#define SUB_ASSIGN 325
#define LEFT_PAREN 326
#define RIGHT_PAREN 327
#define LEFT_BRACKET 328
#define RIGHT_BRACKET 329
#define LEFT_BRACE 330
#define RIGHT_BRACE 331
#define DOT 332
#define COMMA 333
#define COLON 334
#define EQUAL 335
#define SEMICOLON 336
#define BANG 337
#define DASH 338
#define TILDE 339
#define PLUS 340
#define STAR 341
#define SLASH 342
#define PERCENT 343
#define LEFT_ANGLE 344
#define RIGHT_ANGLE 345
#define VERTICAL_BAR 346
#define CARET 347
#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