diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp index 85bb06125c2..fbeea362abd 100644 --- a/src/compiler/glsl/glsl_parser_extras.cpp +++ b/src/compiler/glsl/glsl_parser_extras.cpp @@ -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); diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h index 64d9378e3ee..e79da788178 100644 --- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h +++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h @@ -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) diff --git a/src/gallium/auxiliary/util/u_driconf.c b/src/gallium/auxiliary/util/u_driconf.c index 8381dfd64c8..893c3b69aaf 100644 --- a/src/gallium/auxiliary/util/u_driconf.c +++ b/src/gallium/auxiliary/util/u_driconf.c @@ -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); diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h index 783ae18b093..c7aab405159 100644 --- a/src/gallium/include/frontend/api.h +++ b/src/gallium/include/frontend/api.h @@ -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; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index f6e6001b565..6096bcb9328 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -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". diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index f9a77d505f6..5880279176a 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -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; diff --git a/src/util/driconf.h b/src/util/driconf.h index 24726e04bd3..7539fdee4fc 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -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)")