From a66a9280fb7a59a0b4659358c8ded43552aba401 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Wed, 4 Mar 2026 21:58:24 +1100 Subject: [PATCH] glsl: add workaround for MDK2 HD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows a shader to compile that uses an embedded struct declaration which are not allowed in glsl 1.20+ Reviewed-by: Tapani Pälli Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14986 (cherry picked from commit f109bfc3f1a79e47466f10564a0f9377fe23ec50) Part-of: --- .pick_status.json | 2 +- src/compiler/glsl/ast_to_hir.cpp | 1 + src/compiler/glsl/glsl_parser_extras.cpp | 2 ++ src/compiler/glsl/glsl_parser_extras.h | 1 + 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/consts_exts.h | 6 ++++++ src/mesa/state_tracker/st_extensions.c | 3 +++ src/util/00-mesa-defaults.conf | 4 ++++ src/util/driconf.h | 4 ++++ 11 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index b197b8bf791..e06646bc48d 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2704,7 +2704,7 @@ "description": "glsl: add workaround for MDK2 HD", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index 77f27a1f837..92a8a9b5d98 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -7667,6 +7667,7 @@ ast_process_struct_or_iface_block_members(ir_exec_list *instructions, * embedded structures in 1.10 only. */ if (state->language_version != 110 && + !state->allow_glsl_embedded_structure_declarations && decl_list->type->specifier->structure != NULL) _mesa_glsl_error(&loc, state, "embedded structure declarations are not allowed"); diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp index 3bcf7872764..52c2c51b69f 100644 --- a/src/compiler/glsl/glsl_parser_extras.cpp +++ b/src/compiler/glsl/glsl_parser_extras.cpp @@ -329,6 +329,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, ctx->Const.AllowVertexTextureBias; this->allow_glsl_120_subset_in_110 = ctx->Const.AllowGLSL120SubsetIn110; + this->allow_glsl_embedded_structure_declarations = + ctx->Const.AllowGLSLEmbeddedStructureDeclarations; this->allow_builtin_variable_redeclaration = ctx->Const.AllowGLSLBuiltinVariableRedeclaration; this->ignore_write_to_readonly_var = diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h index 8a1ccc993b7..b57bd7b9e73 100644 --- a/src/compiler/glsl/glsl_parser_extras.h +++ b/src/compiler/glsl/glsl_parser_extras.h @@ -1023,6 +1023,7 @@ struct _mesa_glsl_parse_state { char *alias_shader_extension; bool allow_vertex_texture_bias; bool allow_glsl_120_subset_in_110; + bool allow_glsl_embedded_structure_declarations; bool allow_builtin_variable_redeclaration; bool ignore_write_to_readonly_var; diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h index 7c2c39a20af..a812f5bb44f 100644 --- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h +++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h @@ -27,6 +27,7 @@ DRI_CONF_SECTION_DEBUG DRI_CONF_ALLOW_EXTRA_PP_TOKENS(false) DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER(false) DRI_CONF_ALLOW_GLSL_120_SUBSET_IN_110(false) + DRI_CONF_ALLOW_GLSL_EMBEDDED_STRUCTURE_DECLARATIONS(false) DRI_CONF_ALLOW_GLSL_BUILTIN_CONST_EXPRESSION(false) DRI_CONF_ALLOW_GLSL_RELAXED_ES(false) DRI_CONF_ALLOW_GLSL_BUILTIN_VARIABLE_REDECLARATION(false) diff --git a/src/gallium/auxiliary/util/u_driconf.c b/src/gallium/auxiliary/util/u_driconf.c index e37de3a7f70..298d44a2dbb 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_extra_pp_tokens); query_bool_option(allow_glsl_extension_directive_midshader); query_bool_option(allow_glsl_120_subset_in_110); + query_bool_option(allow_glsl_embedded_structure_declarations); query_bool_option(allow_glsl_builtin_const_expression); query_bool_option(allow_glsl_relaxed_es); query_bool_option(allow_glsl_builtin_variable_redeclaration); diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h index 042272f0e63..1bae937b41f 100644 --- a/src/gallium/include/frontend/api.h +++ b/src/gallium/include/frontend/api.h @@ -180,6 +180,7 @@ struct st_config_options bool allow_extra_pp_tokens; bool allow_glsl_extension_directive_midshader; bool allow_glsl_120_subset_in_110; + bool allow_glsl_embedded_structure_declarations; bool allow_glsl_builtin_const_expression; bool allow_glsl_relaxed_es; bool allow_glsl_builtin_variable_redeclaration; diff --git a/src/mesa/main/consts_exts.h b/src/mesa/main/consts_exts.h index 65f20369485..de58a3100cb 100644 --- a/src/mesa/main/consts_exts.h +++ b/src/mesa/main/consts_exts.h @@ -541,6 +541,12 @@ struct gl_constants */ GLboolean AllowGLSL120SubsetIn110; + /** + * Allow a embedded structure declarations which were allowed in GLSL 1.10 + * but are no longer allowed in GLSL 1.20+ + */ + GLboolean AllowGLSLEmbeddedStructureDeclarations; + /** * Allow builtins as part of constant expressions. This was not allowed * until GLSL 1.20 this allows it everywhere. diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index f8e8b15c78d..0b5d11e4aeb 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -1551,6 +1551,9 @@ void st_init_extensions(struct pipe_screen *screen, if (options->allow_glsl_120_subset_in_110) consts->AllowGLSL120SubsetIn110 = GL_TRUE; + if (options->allow_glsl_embedded_structure_declarations) + consts->AllowGLSLEmbeddedStructureDeclarations = GL_TRUE; + if (options->allow_glsl_builtin_const_expression) consts->AllowGLSLBuiltinConstantExpression = GL_TRUE; diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf index 35e56845f7c..1835ed86956 100644 --- a/src/util/00-mesa-defaults.conf +++ b/src/util/00-mesa-defaults.conf @@ -286,6 +286,10 @@ TODO: document the other workarounds.