Mesa (main): mesa: add allow_glsl_compat_shaders for shader-db
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Nov 24 11:14:11 UTC 2021
Module: Mesa
Branch: main
Commit: 6c78ec4eac6e9ef82b3b29f7a8784f47866c02c0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6c78ec4eac6e9ef82b3b29f7a8784f47866c02c0
Author: Marek Olšák <marek.olsak at amd.com>
Date: Thu Nov 18 23:14:01 2021 -0500
mesa: add allow_glsl_compat_shaders for shader-db
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13870>
---
src/compiler/glsl/glsl_parser_extras.cpp | 8 ++++++--
src/gallium/auxiliary/pipe-loader/driinfo_gallium.h | 1 +
src/gallium/auxiliary/util/u_driconf.c | 1 +
src/gallium/include/frontend/api.h | 1 +
src/mesa/main/mtypes.h | 6 ++++++
src/mesa/state_tracker/st_extensions.c | 1 +
src/util/driconf.h | 4 ++++
7 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 35dd433bc89..31de7d22758 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -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;
diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
index 29ad8e700aa..64d9378e3ee 100644
--- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
+++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
@@ -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)
diff --git a/src/gallium/auxiliary/util/u_driconf.c b/src/gallium/auxiliary/util/u_driconf.c
index cf87e5acdbf..8381dfd64c8 100644
--- a/src/gallium/auxiliary/util/u_driconf.c
+++ b/src/gallium/auxiliary/util/u_driconf.c
@@ -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);
diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h
index 66a03b24d43..783ae18b093 100644
--- a/src/gallium/include/frontend/api.h
+++ b/src/gallium/include/frontend/api.h
@@ -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;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 48a42950e5f..1a43d7ce980 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -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
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index d74f905a1ef..05195d1fa0b 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -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;
diff --git a/src/util/driconf.h b/src/util/driconf.h
index 45431eb5f5b..24726e04bd3 100644
--- a/src/util/driconf.h
+++ b/src/util/driconf.h
@@ -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()")
More information about the mesa-commit
mailing list