glslang front-end: Implement AEP *_point_size extensions.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31560 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2015-06-23 04:14:00 +00:00
parent 6e76bdc88d
commit b61b82182f
11 changed files with 248 additions and 40 deletions

View file

@ -2884,6 +2884,18 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
BuiltInVariable("gl_TexCoord", EbvTexCoord, symbolTable);
BuiltInVariable("gl_FogFragCoord", EbvFogFragCoord, symbolTable);
// gl_PointSize, when it needs to be tied to an extension, is always a member of a block.
// (Sometimes with an instance name, sometimes anonymous).
// However, the current automatic extension scheme does not work per block member,
// so for now check when parsing.
//
//if (profile == EEsProfile) {
// if (language == EShLangGeometry)
// symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_geometry_point_size, AEP_geometry_point_size);
// else if (language == EShLangTessEvaluation || language == EShLangTessControl)
// symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_tessellation_point_size, AEP_tessellation_point_size);
//}
break;
case EShLangFragment:

View file

@ -385,11 +385,11 @@ void C_DECL TParseContext::warn(TSourceLoc loc, const char* szReason, const char
//
// Handle seeing a variable identifier in the grammar.
//
TIntermTyped* TParseContext::handleVariable(TSourceLoc loc, TSymbol* symbol, TString* string)
TIntermTyped* TParseContext::handleVariable(TSourceLoc loc, TSymbol* symbol, const TString* string)
{
TIntermTyped* node = 0;
// Error check for function requiring specific extensions present.
// Error check for requiring specific extensions present.
if (symbol && symbol->getNumExtensions())
requireExtensions(loc, symbol->getNumExtensions(), symbol->getExtensions(), symbol->getName().c_str());
@ -411,6 +411,9 @@ TIntermTyped* TParseContext::handleVariable(TSourceLoc loc, TSymbol* symbol, TSt
if (anon) {
// It was a member of an anonymous container.
// The "getNumExtensions()" mechanism above doesn't yet work for block members
blockMemberExtensionCheck(loc, 0, *string);
// Create a subtree for its dereference.
variable = anon->getAnonContainer().getAsVariable();
TIntermTyped* container = intermediate.addSymbol(*variable, loc);
@ -716,7 +719,7 @@ TIntermTyped* TParseContext::handleUnaryMath(TSourceLoc loc, const char* str, TO
//
// Handle seeing a base.field dereference in the grammar.
//
TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped* base, TString& field)
TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped* base, const TString& field)
{
variableCheck(base);
@ -804,6 +807,7 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
if (base->getType().getQualifier().storage == EvqConst)
result = intermediate.foldDereference(base, member, loc);
else {
blockMemberExtensionCheck(loc, base, field);
TIntermTyped* index = intermediate.addConstantUnion(member, loc);
result = intermediate.addIndex(EOpIndexDirectStruct, base, index, loc);
result->setType(*(*fields)[member].type);
@ -816,6 +820,16 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
return result;
}
void TParseContext::blockMemberExtensionCheck(TSourceLoc loc, const TIntermTyped* /*base*/, const TString& field)
{
if (profile == EEsProfile && field == "gl_PointSize") {
if (language == EShLangGeometry)
requireExtensions(loc, Num_AEP_geometry_point_size, AEP_geometry_point_size, "gl_PointSize");
else if (language == EShLangTessControl || language == EShLangTessEvaluation)
requireExtensions(loc, Num_AEP_tessellation_point_size, AEP_tessellation_point_size, "gl_PointSize");
}
}
//
// Handle seeing a function declarator in the grammar. This is the precursor
// to recognizing a function prototype or function definition.

View file

@ -84,7 +84,7 @@ public:
bool builtInName(const TString&);
void handlePragma(TSourceLoc, const TVector<TString>&);
TIntermTyped* handleVariable(TSourceLoc, TSymbol* symbol, TString* string);
TIntermTyped* handleVariable(TSourceLoc, TSymbol* symbol, const TString* string);
TIntermTyped* handleBracketDereference(TSourceLoc, TIntermTyped* base, TIntermTyped* index);
void checkIndex(TSourceLoc, const TType&, int& index);
void handleIndexLimits(TSourceLoc, TIntermTyped* base, TIntermTyped* index);
@ -100,8 +100,9 @@ public:
TIntermTyped* handleBinaryMath(TSourceLoc, const char* str, TOperator op, TIntermTyped* left, TIntermTyped* right);
TIntermTyped* handleUnaryMath(TSourceLoc, const char* str, TOperator op, TIntermTyped* childNode);
TIntermTyped* handleDotDereference(TSourceLoc, TIntermTyped* base, TString& field);
TFunction* handleFunctionDeclarator(TSourceLoc loc, TFunction& function, bool prototype);
TIntermTyped* handleDotDereference(TSourceLoc, TIntermTyped* base, const TString& field);
void blockMemberExtensionCheck(TSourceLoc, const TIntermTyped* base, const TString& field);
TFunction* handleFunctionDeclarator(TSourceLoc, TFunction& function, bool prototype);
TIntermAggregate* handleFunctionDefinition(TSourceLoc, TFunction&);
TIntermTyped* handleFunctionCall(TSourceLoc, TFunction*, TIntermNode*);
void checkLocation(TSourceLoc, TOperator);

View file

@ -182,21 +182,23 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior[GL_OES_shader_multisample_interpolation] = EBhDisablePartial;
extensionBehavior[GL_OES_texture_storage_multisample_2d_array] = EBhDisablePartial;
extensionBehavior[GL_EXT_geometry_shader] = EBhDisable;
extensionBehavior[GL_EXT_geometry_point_size] = EBhDisablePartial;
extensionBehavior[GL_EXT_geometry_point_size] = EBhDisable;
extensionBehavior[GL_EXT_gpu_shader5] = EBhDisablePartial;
extensionBehavior[GL_EXT_primitive_bounding_box] = EBhDisablePartial;
extensionBehavior[GL_EXT_shader_io_blocks] = EBhDisable;
extensionBehavior[GL_EXT_tessellation_shader] = EBhDisable;
extensionBehavior[GL_EXT_tessellation_point_size] = EBhDisablePartial;
extensionBehavior[GL_EXT_tessellation_point_size] = EBhDisable;
extensionBehavior[GL_EXT_texture_buffer] = EBhDisablePartial;
extensionBehavior[GL_EXT_texture_cube_map_array] = EBhDisablePartial;
// OES matching AEP
extensionBehavior[GL_OES_geometry_shader] = EBhDisable;
extensionBehavior[GL_OES_geometry_point_size] = EBhDisable;
extensionBehavior[GL_OES_gpu_shader5] = EBhDisablePartial;
extensionBehavior[GL_OES_primitive_bounding_box] = EBhDisablePartial;
extensionBehavior[GL_OES_shader_io_blocks] = EBhDisable;
extensionBehavior[GL_OES_tessellation_shader] = EBhDisable;
extensionBehavior[GL_OES_tessellation_point_size] = EBhDisable;
extensionBehavior[GL_OES_texture_buffer] = EBhDisablePartial;
extensionBehavior[GL_OES_texture_cube_map_array] = EBhDisablePartial;
}
@ -234,10 +236,12 @@ const char* TParseContext::getPreamble()
// OES matching AEP
"#define GL_OES_geometry_shader 1\n"
"#define GL_OES_geometry_point_size 1\n"
"#define GL_OES_gpu_shader5 1\n"
"#define GL_OES_primitive_bounding_box 1\n"
"#define GL_OES_shader_io_blocks 1\n"
"#define GL_OES_tessellation_shader 1\n"
"#define GL_OES_tessellation_point_size 1\n"
"#define GL_OES_texture_buffer 1\n"
"#define GL_OES_texture_cube_map_array 1\n"
;

View file

@ -131,10 +131,12 @@ const char* const GL_EXT_texture_cube_map_array = "GL_EXT_texture_
// OES matching AEP
const char* const GL_OES_geometry_shader = "GL_OES_geometry_shader";
const char* const GL_OES_geometry_point_size = "GL_OES_geometry_point_size";
const char* const GL_OES_gpu_shader5 = "GL_OES_gpu_shader5";
const char* const GL_OES_primitive_bounding_box = "GL_OES_primitive_bounding_box";
const char* const GL_OES_shader_io_blocks = "GL_OES_shader_io_blocks";
const char* const GL_OES_tessellation_shader = "GL_OES_tessellation_shader";
const char* const GL_OES_tessellation_point_size = "GL_OES_tessellation_point_size";
const char* const GL_OES_texture_buffer = "GL_OES_texture_buffer";
const char* const GL_OES_texture_cube_map_array = "GL_OES_texture_cube_map_array";
@ -143,6 +145,9 @@ const char* const GL_OES_texture_cube_map_array = "GL_OES_texture_
const char* const AEP_geometry_shader[] = { GL_EXT_geometry_shader, GL_OES_geometry_shader };
const int Num_AEP_geometry_shader = sizeof(AEP_geometry_shader)/sizeof(AEP_geometry_shader[0]);
const char* const AEP_geometry_point_size[] = { GL_EXT_geometry_point_size, GL_OES_geometry_point_size };
const int Num_AEP_geometry_point_size = sizeof(AEP_geometry_point_size)/sizeof(AEP_geometry_point_size[0]);
const char* const AEP_gpu_shader5[] = { GL_EXT_gpu_shader5, GL_OES_gpu_shader5 };
const int Num_AEP_gpu_shader5 = sizeof(AEP_gpu_shader5)/sizeof(AEP_gpu_shader5[0]);
@ -155,6 +160,9 @@ const int Num_AEP_shader_io_blocks = sizeof(AEP_shader_io_blocks)/sizeof(AEP_sha
const char* const AEP_tessellation_shader[] = { GL_EXT_tessellation_shader, GL_OES_tessellation_shader };
const int Num_AEP_tessellation_shader = sizeof(AEP_tessellation_shader)/sizeof(AEP_tessellation_shader[0]);
const char* const AEP_tessellation_point_size[] = { GL_EXT_tessellation_point_size, GL_OES_tessellation_point_size };
const int Num_AEP_tessellation_point_size = sizeof(AEP_tessellation_point_size)/sizeof(AEP_tessellation_point_size[0]);
const char* const AEP_texture_buffer[] = { GL_EXT_texture_buffer, GL_OES_texture_buffer };
const int Num_AEP_texture_buffer = sizeof(AEP_texture_buffer)/sizeof(AEP_texture_buffer[0]);