Add GL_EXT_texture_shadow_lod support

Closes #3302.
This commit is contained in:
Nathaniel Cesario 2023-08-11 15:19:35 -06:00 committed by arcady-lunarg
parent 3787b6947f
commit ffefbcd9f3
10 changed files with 213 additions and 0 deletions

View file

@ -4820,6 +4820,33 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
// GL_EXT_texture_shadow_lod overloads
if (profile == EEsProfile) { // ES
if (version >= 300) {
commonBuiltins.append("float texture(sampler2DArrayShadow, vec4, float);"
"float textureOffset(sampler2DArrayShadow, vec4, ivec2, float);"
"float textureLod(sampler2DArrayShadow, vec4, float);"
"float textureLodOffset(sampler2DArrayShadow, vec4, float, ivec2);"
"\n");
}
if (version >= 320) {
commonBuiltins.append("float texture(samplerCubeArrayShadow, vec4, float, float);"
"float textureLod(samplerCubeShadow, vec4, float);"
"float textureLod(samplerCubeArrayShadow, vec4, float, float);"
"\n");
}
} else if (version >= 130) { // Desktop
commonBuiltins.append("float texture(sampler2DArrayShadow, vec4, float);"
"float texture(samplerCubeArrayShadow, vec4, float, float);"
"float textureOffset(sampler2DArrayShadow, vec4, ivec2);"
"float textureOffset(sampler2DArrayShadow, vec4, ivec2, float);"
"float textureLod(sampler2DArrayShadow, vec4, float);"
"float textureLod(samplerCubeShadow, vec4, float);"
"float textureLod(samplerCubeArrayShadow, vec4, float, float);"
"float textureLodOffset(sampler2DArrayShadow, vec4, float, ivec2);"
"\n");
}
//============================================================================
//
// Standard Uniforms
@ -8741,6 +8768,36 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setFunctionExtensions("textureBlockMatchSADQCOM", 1, &E_GL_QCOM_image_processing);
symbolTable.setFunctionExtensions("textureBlockMatchSSDQCOM", 1, &E_GL_QCOM_image_processing);
}
// GL_EXT_texture_shadow_lod
// NOTE: These are the mangled names of individual overloads, since this extension adds overloads for
// existing built-in functions.
if (profile == EEsProfile) {
if (version >= 300) {
symbolTable.setSingleFunctionExtensions("texture(sAS21;vf4;f1;", 1, &E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("textureOffset(sAS21;vf4;vi2;f1;", 1,
&E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("textureLod(sAS21;vf4;f1;", 1, &E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("textureLodOffset(sAS21;vf4;f1;vi2;", 1,
&E_GL_EXT_texture_shadow_lod);
}
if (version >= 320) {
symbolTable.setSingleFunctionExtensions("texture(sASC1;vf4;f1;", 1, &E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("texture(sASC1;vf4;f1;f1;", 1, &E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("textureLod(sASC1;vf4;f1;f1;", 1, &E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("textureLod(sSC1;vf4;f1;", 1, &E_GL_EXT_texture_shadow_lod);
}
} else if (version >= 130) {
symbolTable.setSingleFunctionExtensions("texture(sAS21;vf4;f1;", 1, &E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("texture(sASC1;vf4;f1;f1;", 1, &E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("textureOffset(sAS21;vf4;vi2;", 1, &E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("textureOffset(sAS21;vf4;vi2;f1;", 1, &E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("textureLod(sAS21;vf4;f1;", 1, &E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("textureLod(sASC1;vf4;f1;f1;", 1, &E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("textureLod(sSC1;vf4;f1;", 1, &E_GL_EXT_texture_shadow_lod);
symbolTable.setSingleFunctionExtensions("textureLodOffset(sAS21;vf4;f1;vi2;", 1,
&E_GL_EXT_texture_shadow_lod);
}
break;
case EShLangCompute:

View file

@ -318,6 +318,16 @@ void TSymbolTableLevel::setFunctionExtensions(const char* name, int num, const c
}
}
// Make a single function require an extension(s). i.e., this will only set the extensions for the symbol that matches 'name' exactly.
// This is different from setFunctionExtensions, which uses std::map::lower_bound to effectively set all symbols that start with 'name'.
// Should only be used for a version/profile that actually needs the extension(s).
void TSymbolTableLevel::setSingleFunctionExtensions(const char* name, int num, const char* const extensions[])
{
if (auto candidate = level.find(name); candidate != level.end()) {
candidate->second->setExtensions(num, extensions);
}
}
//
// Make all symbols in this table level read only.
//

View file

@ -571,6 +571,7 @@ public:
void relateToOperator(const char* name, TOperator op);
void setFunctionExtensions(const char* name, int num, const char* const extensions[]);
void setSingleFunctionExtensions(const char* name, int num, const char* const extensions[]);
void dump(TInfoSink& infoSink, bool complete = false) const;
TSymbolTableLevel* clone() const;
void readOnly();
@ -872,6 +873,12 @@ public:
table[level]->setFunctionExtensions(name, num, extensions);
}
void setSingleFunctionExtensions(const char* name, int num, const char* const extensions[])
{
for (unsigned int level = 0; level < table.size(); ++level)
table[level]->setSingleFunctionExtensions(name, num, extensions);
}
void setVariableExtensions(const char* name, int numExts, const char* const extensions[])
{
TSymbol* symbol = find(TString(name));

View file

@ -359,6 +359,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_opacity_micromap] = EBhDisable;
extensionBehavior[E_GL_EXT_ray_tracing_position_fetch] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_tile_image] = EBhDisable;
extensionBehavior[E_GL_EXT_texture_shadow_lod] = EBhDisable;
// OVR extensions
extensionBehavior[E_GL_OVR_multiview] = EBhDisable;

View file

@ -333,6 +333,8 @@ const char* const E_GL_EXT_shader_atomic_float2 = "GL_EXT_shader_atomic_float2";
const char* const E_GL_EXT_shader_tile_image = "GL_EXT_shader_tile_image";
const char* const E_GL_EXT_texture_shadow_lod = "GL_EXT_texture_shadow_lod";
// Arrays of extensions for the above AEP duplications
const char* const AEP_geometry_shader[] = { E_GL_EXT_geometry_shader, E_GL_OES_geometry_shader };