From 40fdd97de38d86e537e59a73f7500a41ce28a8ae Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Mon, 5 Aug 2024 11:02:07 +0800 Subject: [PATCH] glsl: set shader_info.subgroup_size for KHR_shader_subgroup Signed-off-by: Qiang Yu Part-of: --- src/compiler/glsl/glsl_parser_extras.cpp | 1 + src/compiler/glsl/glsl_to_nir.cpp | 2 -- src/compiler/glsl/linker.cpp | 6 ++++++ src/mesa/main/shader_types.h | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp index 9ffc95e8a87..ed54f785a4d 100644 --- a/src/compiler/glsl/glsl_parser_extras.cpp +++ b/src/compiler/glsl/glsl_parser_extras.cpp @@ -2473,6 +2473,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader, shader->has_implicit_conversions = state->has_implicit_conversions(); shader->has_implicit_int_to_uint_conversion = state->has_implicit_int_to_uint_conversion(); + shader->KHR_shader_subgroup_basic_enable = state->KHR_shader_subgroup_basic_enable; struct gl_shader_compiler_options *options = &ctx->Const.ShaderCompilerOptions[shader->Stage]; diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 3aa0783d1d5..6b140208335 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -172,8 +172,6 @@ glsl_to_nir(const struct gl_constants *consts, nir_print_shader(shader, stdout); } - shader->info.subgroup_size = SUBGROUP_SIZE_UNIFORM; - return shader; } diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 2f83957373a..6993fe0a6c4 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -1540,6 +1540,7 @@ link_intrastage_shaders(void *mem_ctx, bool allow_missing_main) { bool arb_fragment_coord_conventions_enable = false; + bool KHR_shader_subgroup_basic_enable = false; /* Check that global variables defined in multiple shaders are consistent. */ @@ -1551,6 +1552,8 @@ link_intrastage_shaders(void *mem_ctx, false); if (shader_list[i]->ARB_fragment_coord_conventions_enable) arb_fragment_coord_conventions_enable = true; + if (shader_list[i]->KHR_shader_subgroup_basic_enable) + KHR_shader_subgroup_basic_enable = true; } if (!prog->data->LinkStatus) @@ -1660,6 +1663,9 @@ link_intrastage_shaders(void *mem_ctx, populate_symbol_table(linked, shader_list[0]->symbols); + gl_prog->info.subgroup_size = KHR_shader_subgroup_basic_enable ? + SUBGROUP_SIZE_API_CONSTANT : SUBGROUP_SIZE_UNIFORM; + /* The pointer to the main function in the final linked shader (i.e., the * copy of the original shader that contained the main function). */ diff --git a/src/mesa/main/shader_types.h b/src/mesa/main/shader_types.h index 709206c6eaf..bf1cbdf9991 100644 --- a/src/mesa/main/shader_types.h +++ b/src/mesa/main/shader_types.h @@ -188,6 +188,7 @@ struct gl_shader bool EarlyFragmentTests; bool ARB_fragment_coord_conventions_enable; + bool KHR_shader_subgroup_basic_enable; bool redeclares_gl_fragcoord; bool uses_gl_fragcoord;