Front-end: Implement GL_OES_gpu_shader5.
This commit is contained in:
parent
ace4c45afc
commit
e3933d684d
16 changed files with 785 additions and 104 deletions
|
|
@ -493,19 +493,24 @@ void TBuiltIns::initialize(int version, EProfile profile)
|
|||
"\n");
|
||||
}
|
||||
|
||||
if (profile != EEsProfile && version >= 400) {
|
||||
if ((profile != EEsProfile && version >= 400) ||
|
||||
(profile == EEsProfile && version >= 310)) { // GL_OES_gpu_shader5
|
||||
|
||||
commonBuiltins.append(
|
||||
"float fma(float, float, float );"
|
||||
"vec2 fma(vec2, vec2, vec2 );"
|
||||
"vec3 fma(vec3, vec3, vec3 );"
|
||||
"vec4 fma(vec4, vec4, vec4 );"
|
||||
|
||||
"double fma(double, double, double);"
|
||||
"dvec2 fma(dvec2, dvec2, dvec2 );"
|
||||
"dvec3 fma(dvec3, dvec3, dvec3 );"
|
||||
"dvec4 fma(dvec4, dvec4, dvec4 );"
|
||||
|
||||
"\n");
|
||||
|
||||
if (profile != EEsProfile) {
|
||||
commonBuiltins.append(
|
||||
"double fma(double, double, double);"
|
||||
"dvec2 fma(dvec2, dvec2, dvec2 );"
|
||||
"dvec3 fma(dvec3, dvec3, dvec3 );"
|
||||
"dvec4 fma(dvec4, dvec4, dvec4 );"
|
||||
"\n");
|
||||
}
|
||||
}
|
||||
|
||||
if ((profile == EEsProfile && version >= 310) ||
|
||||
|
|
@ -2221,9 +2226,6 @@ void TBuiltIns::addGatherFunctions(TSampler sampler, TString& typeName, int vers
|
|||
|
||||
for (int offset = 0; offset < 3; ++offset) { // loop over three forms of offset in the call name: none, Offset, and Offsets
|
||||
|
||||
if (profile == EEsProfile && offset == 2)
|
||||
continue;
|
||||
|
||||
for (int comp = 0; comp < 2; ++comp) { // loop over presence of comp argument
|
||||
|
||||
if (comp > 0 && sampler.shadow)
|
||||
|
|
@ -2802,8 +2804,11 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
|
|||
//
|
||||
|
||||
// N.B.: a symbol should only be tagged once, and this function is called multiple times, once
|
||||
// per stage that's used for this profile. So, stick common ones in the fragment stage to
|
||||
// ensure they are tagged exactly once.
|
||||
// per stage that's used for this profile. So
|
||||
// - generally, stick common ones in the fragment stage to ensure they are tagged exactly once
|
||||
// - for ES, which has different precisions for different stages, the coarsest-grained tagging
|
||||
// for a built-in used in many stages needs to be once for the fragment stage and once for
|
||||
// the vertex stage
|
||||
|
||||
switch(language) {
|
||||
case EShLangVertex:
|
||||
|
|
@ -2822,6 +2827,15 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
|
|||
BuiltInVariable("gl_MultiTexCoord7", EbvMultiTexCoord7, symbolTable);
|
||||
BuiltInVariable("gl_FogCoord", EbvFogFragCoord, symbolTable);
|
||||
|
||||
if (profile == EEsProfile) {
|
||||
symbolTable.setFunctionExtensions("texture2DGradEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("textureCubeGradEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("textureGatherOffsets", Num_AEP_gpu_shader5, AEP_gpu_shader5);
|
||||
if (version >= 310)
|
||||
symbolTable.setFunctionExtensions("fma", Num_AEP_gpu_shader5, AEP_gpu_shader5);
|
||||
}
|
||||
|
||||
// Fall through
|
||||
|
||||
case EShLangTessControl:
|
||||
|
|
@ -2931,15 +2945,21 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
|
|||
|
||||
// built-in functions
|
||||
|
||||
if (version == 100) {
|
||||
symbolTable.setFunctionExtensions("dFdx", 1, &E_GL_OES_standard_derivatives);
|
||||
symbolTable.setFunctionExtensions("dFdy", 1, &E_GL_OES_standard_derivatives);
|
||||
symbolTable.setFunctionExtensions("fwidth", 1, &E_GL_OES_standard_derivatives);
|
||||
}
|
||||
if (profile == EEsProfile) {
|
||||
symbolTable.setFunctionExtensions("texture2DLodEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("texture2DProjLodEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("textureCubeLodEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("texture2DLodEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("texture2DProjLodEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("textureCubeLodEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("texture2DGradEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("textureCubeGradEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("textureGatherOffsets", Num_AEP_gpu_shader5, AEP_gpu_shader5);
|
||||
if (version == 100) {
|
||||
symbolTable.setFunctionExtensions("dFdx", 1, &E_GL_OES_standard_derivatives);
|
||||
symbolTable.setFunctionExtensions("dFdy", 1, &E_GL_OES_standard_derivatives);
|
||||
symbolTable.setFunctionExtensions("fwidth", 1, &E_GL_OES_standard_derivatives);
|
||||
}
|
||||
if (version >= 310)
|
||||
symbolTable.setFunctionExtensions("fma", Num_AEP_gpu_shader5, AEP_gpu_shader5);
|
||||
} else if (version < 130) {
|
||||
symbolTable.setFunctionExtensions("texture1DLod", 1, &E_GL_ARB_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("texture2DLod", 1, &E_GL_ARB_shader_texture_lod);
|
||||
|
|
@ -2973,12 +2993,6 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
|
|||
symbolTable.setFunctionExtensions("shadow2DRectProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
|
||||
}
|
||||
|
||||
if (profile == EEsProfile) {
|
||||
symbolTable.setFunctionExtensions("texture2DGradEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
symbolTable.setFunctionExtensions("textureCubeGradEXT", 1, &E_GL_EXT_shader_texture_lod);
|
||||
}
|
||||
|
||||
// E_GL_ARB_shader_image_load_store
|
||||
if (profile != EEsProfile && version < 420)
|
||||
symbolTable.setFunctionExtensions("memoryBarrier", 1, &E_GL_ARB_shader_image_load_store);
|
||||
|
|
|
|||
|
|
@ -505,13 +505,19 @@ TIntermTyped* TParseContext::handleBracketDereference(TSourceLoc loc, TIntermTyp
|
|||
else
|
||||
error(loc, "", "[", "array must be redeclared with a size before being indexed with a variable");
|
||||
}
|
||||
if (base->getBasicType() == EbtBlock)
|
||||
requireProfile(base->getLoc(), ~EEsProfile, "variable indexing block array");
|
||||
else if (language == EShLangFragment && base->getQualifier().isPipeOutput())
|
||||
if (base->getBasicType() == EbtBlock) {
|
||||
if (base->getQualifier().storage == EvqBuffer)
|
||||
requireProfile(base->getLoc(), ~EEsProfile, "variable indexing buffer block array");
|
||||
else if (base->getQualifier().storage == EvqUniform)
|
||||
profileRequires(base->getLoc(), EEsProfile, 0, Num_AEP_gpu_shader5, AEP_gpu_shader5, "variable indexing uniform block array");
|
||||
else
|
||||
requireProfile(base->getLoc(), ~EEsProfile, "variable indexing in/out block array");
|
||||
} else if (language == EShLangFragment && base->getQualifier().isPipeOutput())
|
||||
requireProfile(base->getLoc(), ~EEsProfile, "variable indexing fragment shader ouput array");
|
||||
else if (base->getBasicType() == EbtSampler && version >= 130) {
|
||||
const char* explanation = "variable indexing sampler array";
|
||||
requireProfile(base->getLoc(), ECoreProfile | ECompatibilityProfile, explanation);
|
||||
requireProfile(base->getLoc(), EEsProfile | ECoreProfile | ECompatibilityProfile, explanation);
|
||||
profileRequires(base->getLoc(), EEsProfile, 0, Num_AEP_gpu_shader5, AEP_gpu_shader5, explanation);
|
||||
profileRequires(base->getLoc(), ECoreProfile | ECompatibilityProfile, 400, nullptr, explanation);
|
||||
}
|
||||
|
||||
|
|
@ -1332,6 +1338,9 @@ void TParseContext::nonOpBuiltInCheck(TSourceLoc loc, const TFunction& fnCandida
|
|||
profileRequires(loc, ~EEsProfile, 400, E_GL_ARB_texture_gather, feature);
|
||||
else
|
||||
profileRequires(loc, ~EEsProfile, 400, E_GL_ARB_gpu_shader5, feature);
|
||||
int offsetArg = fnCandidate[0].type->getSampler().shadow ? 3 : 2;
|
||||
if (! callNode.getSequence()[offsetArg]->getAsConstantUnion())
|
||||
profileRequires(loc, EEsProfile, 0, Num_AEP_gpu_shader5, AEP_gpu_shader5, "non-constant offset argument");
|
||||
if (! fnCandidate[0].type->getSampler().shadow)
|
||||
compArg = 3;
|
||||
} else if (fnCandidate.getName().compare("textureGatherOffsets") == 0) {
|
||||
|
|
|
|||
|
|
@ -941,12 +941,14 @@ int TScanContext::tokenizeIdentifier()
|
|||
return keyword;
|
||||
|
||||
case PRECISE:
|
||||
if (parseContext.profile == EEsProfile && parseContext.version >= 310)
|
||||
if ((parseContext.profile == EEsProfile && parseContext.extensionsTurnedOn(Num_AEP_gpu_shader5, AEP_gpu_shader5)) ||
|
||||
(parseContext.profile != EEsProfile && parseContext.version >= 400))
|
||||
return keyword;
|
||||
if (parseContext.profile == EEsProfile && parseContext.version == 310) {
|
||||
reservedWord();
|
||||
else if (parseContext.profile == EEsProfile ||
|
||||
(parseContext.profile != EEsProfile && parseContext.version < 400))
|
||||
return identifierOrType();
|
||||
return keyword;
|
||||
return keyword;
|
||||
}
|
||||
return identifierOrType();
|
||||
|
||||
case INVARIANT:
|
||||
if (parseContext.profile != EEsProfile && parseContext.version < 120)
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ public:
|
|||
TSymbol(name),
|
||||
mangledName(*name + '('),
|
||||
op(tOp),
|
||||
defined(false), prototyped(false) { returnType.shallowCopy(retType); }
|
||||
defined(false), prototyped(false) { returnType.shallowCopy(retType); }
|
||||
virtual TFunction* clone() const;
|
||||
virtual ~TFunction();
|
||||
|
||||
|
|
@ -486,8 +486,8 @@ public:
|
|||
//
|
||||
protected:
|
||||
static const int globalLevel = 3;
|
||||
bool isSharedLevel(int level) { return level <= 1; } // exclude all per-compile levels
|
||||
bool isBuiltInLevel(int level) { return level <= 2; } // exclude user globals
|
||||
bool isSharedLevel(int level) { return level <= 1; } // exclude all per-compile levels
|
||||
bool isBuiltInLevel(int level) { return level <= 2; } // exclude user globals
|
||||
bool isGlobalLevel(int level) { return level <= globalLevel; } // include user globals
|
||||
public:
|
||||
bool isEmpty() { return table.size() == 0; }
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ void TParseContext::initializeExtensionBehavior()
|
|||
extensionBehavior[E_GL_OES_texture_storage_multisample_2d_array] = EBhDisablePartial;
|
||||
extensionBehavior[E_GL_EXT_geometry_shader] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_geometry_point_size] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_gpu_shader5] = EBhDisablePartial;
|
||||
extensionBehavior[E_GL_EXT_gpu_shader5] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_primitive_bounding_box] = EBhDisablePartial;
|
||||
extensionBehavior[E_GL_EXT_shader_io_blocks] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_tessellation_shader] = EBhDisable;
|
||||
|
|
@ -194,7 +194,7 @@ void TParseContext::initializeExtensionBehavior()
|
|||
// OES matching AEP
|
||||
extensionBehavior[E_GL_OES_geometry_shader] = EBhDisable;
|
||||
extensionBehavior[E_GL_OES_geometry_point_size] = EBhDisable;
|
||||
extensionBehavior[E_GL_OES_gpu_shader5] = EBhDisablePartial;
|
||||
extensionBehavior[E_GL_OES_gpu_shader5] = EBhDisable;
|
||||
extensionBehavior[E_GL_OES_primitive_bounding_box] = EBhDisablePartial;
|
||||
extensionBehavior[E_GL_OES_shader_io_blocks] = EBhDisable;
|
||||
extensionBehavior[E_GL_OES_tessellation_shader] = EBhDisable;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue