From f9341082a20b969c48a28675bd63b0410bd72f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 14 Nov 2025 13:40:31 -0500 Subject: [PATCH] nir,glsl,zink: remove the option nir_io_separate_clip_cull_distance_arrays This calls nir_separate_merged_clip_cull_io in zink, which is better than having to handle separate clip & cull arrays in all passes. Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/glsl/gl_nir_linker.c | 4 +--- src/compiler/nir/nir_shader_compiler_options.h | 9 --------- src/compiler/nir/nir_unlower_io_to_vars.c | 11 ++--------- src/gallium/drivers/zink/zink_compiler.c | 3 ++- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c index 94df327286a..891d707e9f5 100644 --- a/src/compiler/glsl/gl_nir_linker.c +++ b/src/compiler/glsl/gl_nir_linker.c @@ -1446,9 +1446,7 @@ prelink_lowering(const struct pipe_screen *screen, * - shader_info::clip_distance_array_size * - shader_info::cull_distance_array_size */ - if (!(nir->options->io_options & - nir_io_separate_clip_cull_distance_arrays)) - NIR_PASS(_, nir, nir_lower_clip_cull_distance_array_vars); + NIR_PASS(_, nir, nir_lower_clip_cull_distance_array_vars); } return true; diff --git a/src/compiler/nir/nir_shader_compiler_options.h b/src/compiler/nir/nir_shader_compiler_options.h index 5ad97375342..ecf7f5b39c6 100644 --- a/src/compiler/nir/nir_shader_compiler_options.h +++ b/src/compiler/nir/nir_shader_compiler_options.h @@ -207,15 +207,6 @@ typedef enum { * This is only affects GLSL compilation and Gallium. */ nir_io_has_intrinsics = BITFIELD_BIT(16), - - /** - * Whether clip and cull distance arrays should be separate. If this is not - * set, cull distances will be moved into VARYING_SLOT_CLIP_DISTn after clip - * distances, and shader_info::clip_distance_array_size will be the index - * of the first cull distance. nir_lower_clip_cull_distance_array_vars does - * that. - */ - nir_io_separate_clip_cull_distance_arrays = BITFIELD_BIT(17), } nir_io_options; typedef enum { diff --git a/src/compiler/nir/nir_unlower_io_to_vars.c b/src/compiler/nir/nir_unlower_io_to_vars.c index 8202fd7e841..ee2658e3a60 100644 --- a/src/compiler/nir/nir_unlower_io_to_vars.c +++ b/src/compiler/nir/nir_unlower_io_to_vars.c @@ -288,15 +288,8 @@ create_vars(nir_builder *b, nir_intrinsic_instr *intr, void *opaque) case VARYING_SLOT_CLIP_DIST1: case VARYING_SLOT_CULL_DIST0: case VARYING_SLOT_CULL_DIST1: - if (nir->options->io_options & - nir_io_separate_clip_cull_distance_arrays) { - decl_size = desc.sem.location >= VARYING_SLOT_CULL_DIST0 ? - nir->info.cull_distance_array_size : - nir->info.clip_distance_array_size; - } else { - decl_size = nir->info.clip_distance_array_size + - nir->info.cull_distance_array_size; - } + decl_size = nir->info.clip_distance_array_size + + nir->info.cull_distance_array_size; component = (desc.sem.location == VARYING_SLOT_CLIP_DIST1 || desc.sem.location == VARYING_SLOT_CULL_DIST1) * 4 + desc.component; diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 4d2d967ce9c..b322e6f3f16 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -1265,7 +1265,7 @@ zink_screen_init_compiler(struct zink_screen *screen) { static const struct nir_shader_compiler_options default_options = { - .io_options = nir_io_has_intrinsics | nir_io_separate_clip_cull_distance_arrays, + .io_options = nir_io_has_intrinsics, .lower_ffma16 = true, .lower_ffma32 = true, .lower_ffma64 = true, @@ -6189,6 +6189,7 @@ zink_shader_init(struct zink_screen *screen, struct zink_shader *zs) } NIR_PASS(_, nir, nir_lower_io_to_scalar, nir_var_shader_in | nir_var_shader_out, NULL, NULL); + NIR_PASS(_, nir, nir_separate_merged_clip_cull_io); optimize_nir(nir, NULL, true); NIR_PASS(_, nir, bound_image_arrays); NIR_PASS(_, nir, flatten_image_arrays);