mesa: add allow_glsl_compat_shaders for shader-db

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13870>
This commit is contained in:
Marek Olšák 2021-11-18 23:14:01 -05:00 committed by Marge Bot
parent 09342dcfc0
commit 6c78ec4eac
7 changed files with 20 additions and 2 deletions

View file

@ -458,7 +458,8 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
} else if (strcmp(ident, "compatibility") == 0) {
compat_token_present = true;
if (this->ctx->API != API_OPENGL_COMPAT) {
if (this->ctx->API != API_OPENGL_COMPAT &&
!this->ctx->Const.AllowGLSLCompatShaders) {
_mesa_glsl_error(locp, this,
"the compatibility profile is not supported");
}
@ -874,7 +875,10 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
}
} else {
const _mesa_glsl_extension *extension = find_extension(name);
if (extension && extension->compatible_with_state(state, api, gl_version)) {
if (extension &&
(extension->compatible_with_state(state, api, gl_version) ||
(state->ctx->Const.AllowGLSLCompatShaders &&
extension->compatible_with_state(state, API_OPENGL_COMPAT, gl_version)))) {
extension->set_flags(state, behavior);
if (extension->available_pred == has_ANDROID_extension_pack_es31a) {
for (unsigned i = 0;

View file

@ -28,6 +28,7 @@ DRI_CONF_SECTION_DEBUG
DRI_CONF_ALLOW_GLSL_CROSS_STAGE_INTERPOLATION_MISMATCH(false)
DRI_CONF_DO_DCE_BEFORE_CLIP_CULL_ANALYSIS(false)
DRI_CONF_ALLOW_HIGHER_COMPAT_VERSION(false)
DRI_CONF_ALLOW_GLSL_COMPAT_SHADERS(false)
DRI_CONF_FORCE_GLSL_ABS_SQRT(false)
DRI_CONF_GLSL_CORRECT_DERIVATIVES_AFTER_DISCARD(false)
DRI_CONF_GLSL_IGNORE_WRITE_TO_READONLY_VAR(false)

View file

@ -50,6 +50,7 @@ u_driconf_fill_st_options(struct st_config_options *options,
query_bool_option(allow_glsl_relaxed_es);
query_bool_option(allow_glsl_builtin_variable_redeclaration);
query_bool_option(allow_higher_compat_version);
query_bool_option(allow_glsl_compat_shaders);
query_bool_option(glsl_ignore_write_to_readonly_var);
query_bool_option(glsl_zero_init);
query_bool_option(force_integer_tex_nearest);

View file

@ -227,6 +227,7 @@ struct st_config_options
bool allow_glsl_relaxed_es;
bool allow_glsl_builtin_variable_redeclaration;
bool allow_higher_compat_version;
bool allow_glsl_compat_shaders;
bool glsl_ignore_write_to_readonly_var;
bool glsl_zero_init;
bool vs_position_always_invariant;

View file

@ -3971,6 +3971,12 @@ struct gl_constants
*/
GLboolean AllowHigherCompatVersion;
/**
* Allow GLSL shaders with the compatibility version directive
* in non-compatibility profiles. (for shader-db)
*/
GLboolean AllowGLSLCompatShaders;
/**
* Allow extra tokens at end of preprocessor directives. The CTS now tests
* to make sure these are not allowed. However, previously drivers would

View file

@ -1199,6 +1199,7 @@ void st_init_extensions(struct pipe_screen *screen,
consts->AllowExtraPPTokens = options->allow_extra_pp_tokens;
consts->AllowHigherCompatVersion = options->allow_higher_compat_version;
consts->AllowGLSLCompatShaders = options->allow_glsl_compat_shaders;
consts->ForceGLSLAbsSqrt = options->force_glsl_abs_sqrt;

View file

@ -196,6 +196,10 @@
DRI_CONF_OPT_B(allow_higher_compat_version, def, \
"Allow a higher compat profile (version 3.1+) for apps that request it")
#define DRI_CONF_ALLOW_GLSL_COMPAT_SHADERS(def) \
DRI_CONF_OPT_B(allow_glsl_compat_shaders, def, \
"Allow in GLSL: #version xxx compatibility")
#define DRI_CONF_FORCE_GLSL_ABS_SQRT(def) \
DRI_CONF_OPT_B(force_glsl_abs_sqrt, def, \
"Force computing the absolute value for sqrt() and inversesqrt()")