diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst index 64a54dd6cbd..6aa792965f2 100644 --- a/docs/gallium/screen.rst +++ b/docs/gallium/screen.rst @@ -653,6 +653,7 @@ The integer capabilities: * ``PIPE_CAP_SHADER_SUBGROUP_SUPPORTED_FEATURES``: Bitmask of shader subgroup features listed in :ext:`GL_KHR_shader_subgroup`. * ``PIPE_CAP_SHADER_SUBGROUP_QUAD_ALL_STAGES``: Whether shader subgroup quad operations are supported by shader stages other than fragment shader. * ``PIPE_CAP_MULTIVIEW``: Whether multiview rendering of array textures is supported. A return of ``1`` indicates support for OVR_multiview, and ``2`` additionally supports OVR_multiview2. +* ``PIPE_CAP_CALL_FINALIZE_NIR_IN_LINKER``: Whether `pipe_screen::finalize_nir` can be called in the GLSL linker before the NIR is stored in the shader cache. It's always called again after st/mesa adds code for shader variants. It must be 1 if the driver wants to report compile failures to the GLSL linker. It must be 0 if two consecutive `finalize_nir` calls on the same shader can break it, or if `finalize_nir` can't handle NIR that isn't fully lowered for the driver, or if `finalize_nir` breaks passes that st/mesa runs after it. Setting it to 1 is generally safe for drivers that expose nir_io_has_intrinsics and that don't enable any optional shader variants in st/mesa. Since it's difficult to support, any future refactoring can change it to 0. .. _pipe_capf: diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index 2ff2289da8e..14e0b53c92b 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -565,6 +565,7 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen, case PIPE_CAP_SHADER_SUBGROUP_SUPPORTED_STAGES: case PIPE_CAP_SHADER_SUBGROUP_SUPPORTED_FEATURES: case PIPE_CAP_SHADER_SUBGROUP_QUAD_ALL_STAGES: + case PIPE_CAP_CALL_FINALIZE_NIR_IN_LINKER: return 0; default: diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index 6fb9ca74489..82c42843835 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -413,6 +413,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap) case PIPE_CAP_USER_VERTEX_BUFFERS: case PIPE_CAP_MIXED_COLOR_DEPTH_BITS: case PIPE_CAP_TGSI_TEXCOORD: + case PIPE_CAP_CALL_FINALIZE_NIR_IN_LINKER: return 1; case PIPE_CAP_TEXTURE_TRANSFER_MODES: diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index c136dce8ac8..3de87a57300 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -130,6 +130,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param) case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION: case PIPE_CAP_LEGACY_MATH_RULES: case PIPE_CAP_TGSI_TEXCOORD: + case PIPE_CAP_CALL_FINALIZE_NIR_IN_LINKER: return 1; case PIPE_CAP_TEXTURE_TRANSFER_MODES: diff --git a/src/gallium/drivers/radeonsi/si_get.c b/src/gallium/drivers/radeonsi/si_get.c index 8487112095e..34c7db41fea 100644 --- a/src/gallium/drivers/radeonsi/si_get.c +++ b/src/gallium/drivers/radeonsi/si_get.c @@ -178,6 +178,7 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_NULL_TEXTURES: case PIPE_CAP_HAS_CONST_BW: case PIPE_CAP_CL_GL_SHARING: + case PIPE_CAP_CALL_FINALIZE_NIR_IN_LINKER: return 1; /* Tahiti and Verde only: reduction mode is unsupported due to a bug diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 2027eeb6ef0..bc4fd921718 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -645,6 +645,7 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: case PIPE_CAP_ALLOW_GLTHREAD_BUFFER_SUBDATA_OPT: case PIPE_CAP_NIR_SAMPLERS_AS_DEREF: + case PIPE_CAP_CALL_FINALIZE_NIR_IN_LINKER: return 1; case PIPE_CAP_DRAW_VERTEX_STATE: diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 2bca75f2731..36c7623e25d 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -987,6 +987,7 @@ enum pipe_cap PIPE_CAP_SHADER_SUBGROUP_SUPPORTED_FEATURES, PIPE_CAP_SHADER_SUBGROUP_QUAD_ALL_STAGES, PIPE_CAP_MULTIVIEW, + PIPE_CAP_CALL_FINALIZE_NIR_IN_LINKER, PIPE_CAP_LAST, /* XXX do not add caps after PIPE_CAP_LAST! */ }; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index a13657b25d6..48bd8edad2d 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -625,7 +625,8 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, screen->get_param(screen, PIPE_CAP_CONDITIONAL_RENDER); st->lower_rect_tex = !screen->get_param(screen, PIPE_CAP_TEXRECT); - st->allow_st_finalize_nir_twice = screen->finalize_nir != NULL; + st->allow_st_finalize_nir_twice = + screen->get_param(screen, PIPE_CAP_CALL_FINALIZE_NIR_IN_LINKER); st->has_hw_atomics = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,