From 4da5b11ca9d23e61772900200f55d93fba7f8bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 13 Nov 2024 15:33:43 -0500 Subject: [PATCH] nir: add nir_io_separate_clip_cull_distance_arrays to replace PIPE_CAP to make the flag available in NIR passes Reviewed-by: Alyssa Rosenzweig Part-of: --- docs/gallium/screen.rst | 3 --- src/compiler/glsl/gl_nir_linker.c | 3 ++- src/compiler/nir/nir.h | 9 +++++++++ src/gallium/auxiliary/util/u_screen.c | 1 - src/gallium/drivers/zink/zink_compiler.c | 2 +- src/gallium/drivers/zink/zink_screen.c | 1 - src/gallium/include/pipe/p_defines.h | 1 - src/mesa/main/consts_exts.h | 2 -- src/mesa/state_tracker/st_extensions.c | 2 -- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst index 6aa792965f2..3664e4e7784 100644 --- a/docs/gallium/screen.rst +++ b/docs/gallium/screen.rst @@ -375,9 +375,6 @@ The integer capabilities: * ``PIPE_CAP_CULL_DISTANCE``: Whether the driver supports the :ext:`GL_ARB_cull_distance` extension and thus implements proper support for culling planes. -* ``PIPE_CAP_CULL_DISTANCE_NOCOMBINE``: Whether the driver wants to skip - running the ``nir_lower_clip_cull_distance_arrays`` pass in order to get - VARYING_SLOT_CULL_DIST0 slot variables. * ``PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES``: Whether primitive restart is supported for patch primitives. * ``PIPE_CAP_SHADER_GROUP_VOTE``: Whether the ``VOTE_*`` ops can be used in diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c index 752b63a3b64..0255f2a1573 100644 --- a/src/compiler/glsl/gl_nir_linker.c +++ b/src/compiler/glsl/gl_nir_linker.c @@ -1470,7 +1470,8 @@ prelink_lowering(const struct gl_constants *consts, * - shader_info::clip_distance_array_size * - shader_info::cull_distance_array_size */ - if (consts->CombinedClipCullDistanceArrays) + if (!(nir->options->io_options & + nir_io_separate_clip_cull_distance_arrays)) NIR_PASS(_, nir, nir_lower_clip_cull_distance_arrays); } diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index bc1054c1815..108ac560afd 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3865,6 +3865,15 @@ typedef enum { * Use MESA_GLSL_DISABLE_IO_OPT=1 instead. */ nir_io_dont_optimize = BITFIELD_BIT(17), + + /** + * 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_arrays does + * that. + */ + nir_io_separate_clip_cull_distance_arrays = BITFIELD_BIT(18), } nir_io_options; typedef enum { diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index 14e0b53c92b..308fff33f80 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -304,7 +304,6 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen, case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT: case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR: case PIPE_CAP_CULL_DISTANCE: - case PIPE_CAP_CULL_DISTANCE_NOCOMBINE: case PIPE_CAP_SHADER_GROUP_VOTE: case PIPE_CAP_MAX_WINDOW_RECTANGLES: /* Enables EXT_window_rectangles */ case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED: diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 48e7193cefa..4d0ab964c96 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -1338,7 +1338,7 @@ zink_screen_init_compiler(struct zink_screen *screen) { static const struct nir_shader_compiler_options default_options = { - .io_options = nir_io_has_intrinsics, + .io_options = nir_io_has_intrinsics | nir_io_separate_clip_cull_distance_arrays, .lower_ffma16 = true, .lower_ffma32 = true, .lower_ffma64 = true, diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index bc4fd921718..6e8b03352f6 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -639,7 +639,6 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_PREFER_REAL_BUFFER_IN_CONSTBUF0: case PIPE_CAP_PACKED_UNIFORMS: case PIPE_CAP_SHADER_PACK_HALF_FLOAT: - case PIPE_CAP_CULL_DISTANCE_NOCOMBINE: case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: case PIPE_CAP_LOAD_CONSTBUF: case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 36c7623e25d..8dbd94a6ac5 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -837,7 +837,6 @@ enum pipe_cap PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT, PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR, PIPE_CAP_CULL_DISTANCE, - PIPE_CAP_CULL_DISTANCE_NOCOMBINE, PIPE_CAP_SHADER_GROUP_VOTE, PIPE_CAP_MAX_WINDOW_RECTANGLES, PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED, diff --git a/src/mesa/main/consts_exts.h b/src/mesa/main/consts_exts.h index 5359ec357f4..c013112f627 100644 --- a/src/mesa/main/consts_exts.h +++ b/src/mesa/main/consts_exts.h @@ -950,8 +950,6 @@ struct gl_constants bool HasFBFetch; - bool CombinedClipCullDistanceArrays; - bool PointSizeFixed; /** Wether or not glBitmap uses red textures rather than alpha */ diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 06e26b73947..0a0fd61ad1e 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -199,8 +199,6 @@ void st_init_limits(struct pipe_screen *screen, c->HasFBFetch = screen->get_param(screen, PIPE_CAP_FBFETCH); - c->CombinedClipCullDistanceArrays = !screen->get_param(screen, PIPE_CAP_CULL_DISTANCE_NOCOMBINE); - c->PointSizeFixed = screen->get_param(screen, PIPE_CAP_POINT_SIZE_FIXED) != PIPE_POINT_SIZE_LOWER_ALWAYS; for (sh = 0; sh < PIPE_SHADER_TYPES; ++sh) {