util: add dri config option force_compat_shaders

This allows us to force all shaders to offer shader features only
provided to compatibility shaders.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14040>
This commit is contained in:
Timothy Arceri 2021-12-03 20:53:46 +11:00 committed by Marge Bot
parent 2d7c25fb9d
commit f225e0679a
7 changed files with 16 additions and 0 deletions

View file

@ -495,6 +495,7 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
this->language_version = version;
this->compat_shader = compat_token_present ||
this->ctx->Const.ForceCompatShaders ||
(this->ctx->API == API_OPENGL_COMPAT &&
this->language_version == 140) ||
(!this->es_shader && this->language_version < 140);

View file

@ -35,6 +35,7 @@ DRI_CONF_SECTION_DEBUG
DRI_CONF_ALLOW_DRAW_OUT_OF_ORDER(false)
DRI_CONF_GLTHREAD_NOP_CHECK_FRAMEBUFFER_STATUS(false)
DRI_CONF_FORCE_COMPAT_PROFILE(false)
DRI_CONF_FORCE_COMPAT_SHADERS(false)
DRI_CONF_FORCE_GL_NAMES_REUSE(false)
DRI_CONF_TRANSCODE_ETC(false)
DRI_CONF_TRANSCODE_ASTC(false)

View file

@ -41,6 +41,7 @@ u_driconf_fill_st_options(struct st_config_options *options,
query_bool_option(disable_blend_func_extended);
query_bool_option(disable_arb_gpu_shader5);
query_bool_option(disable_glsl_line_continuations);
query_bool_option(force_compat_shaders);
query_bool_option(force_glsl_extensions_warn);
query_int_option(force_glsl_version);
query_bool_option(allow_extra_pp_tokens);

View file

@ -218,6 +218,7 @@ struct st_config_options
bool disable_blend_func_extended;
bool disable_glsl_line_continuations;
bool disable_arb_gpu_shader5;
bool force_compat_shaders;
bool force_glsl_extensions_warn;
unsigned force_glsl_version;
bool allow_extra_pp_tokens;

View file

@ -3930,6 +3930,12 @@ struct gl_constants
*/
GLboolean ForceGLSLExtensionsWarn;
/**
* Force all shaders to behave as if they were declared with the
* compatibility token.
*/
GLboolean ForceCompatShaders;
/**
* If non-zero, forces GLSL shaders to behave as if they began
* with "#version ForceGLSLVersion".

View file

@ -1189,6 +1189,8 @@ void st_init_extensions(struct pipe_screen *screen,
consts->ForceGLSLVersion = options->force_glsl_version;
}
consts->ForceCompatShaders = options->force_compat_shaders;
consts->AllowExtraPPTokens = options->allow_extra_pp_tokens;
consts->AllowHigherCompatVersion = options->allow_higher_compat_version;

View file

@ -238,6 +238,10 @@
DRI_CONF_OPT_B(force_compat_profile, def, \
"Force an OpenGL compatibility context")
#define DRI_CONF_FORCE_COMPAT_SHADERS(def) \
DRI_CONF_OPT_B(force_compat_shaders, def, \
"Force OpenGL compatibility shaders")
#define DRI_CONF_FORCE_DIRECT_GLX_CONTEXT(def) \
DRI_CONF_OPT_B(force_direct_glx_context, def, \
"Force direct GLX context (even if indirect is requested)")