From 4909e23d11a76a4765887ca06a89d035d7e2345d Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Thu, 6 Nov 2025 11:00:02 -0500 Subject: [PATCH] panvk: Pull multiview lowering out of panvk_lower_nir() It only applies to vertex shaders right now. Also, once we add geometry, it won't really work anymore so we'll need to do something else. Reviewed-by: Christoph Pillmayer Acked-by: Eric R. Smith Part-of: --- src/panfrost/vulkan/panvk_vX_shader.c | 38 +++++++++++++++------------ 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/panfrost/vulkan/panvk_vX_shader.c b/src/panfrost/vulkan/panvk_vX_shader.c index a37020ed349..fade7770a9e 100644 --- a/src/panfrost/vulkan/panvk_vX_shader.c +++ b/src/panfrost/vulkan/panvk_vX_shader.c @@ -780,23 +780,6 @@ panvk_lower_nir(struct panvk_device *dev, nir_shader *nir, }; NIR_PASS(_, nir, nir_opt_access, &access_options); -#if PAN_ARCH >= 10 - if (stage == MESA_SHADER_VERTEX && compile_input->view_mask) { - nir_lower_multiview_options options = { - .view_mask = compile_input->view_mask, - .allowed_per_view_outputs = ~0 - }; - /* The only case where this should fail is with memory/image writes, - * which we don't support in vertex shaders */ - assert(nir_can_lower_multiview(nir, options)); - NIR_PASS(_, nir, nir_lower_multiview, options); - /* Pull output writes out of the loop and give them constant offsets for - * pan_nir_lower_store_components */ - NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, - nir_shader_get_entrypoint(nir), nir_var_shader_out); - } -#endif - const struct lower_ycbcr_state ycbcr_state = { .set_layout_count = set_layout_count, .set_layouts = set_layouts, @@ -1327,6 +1310,27 @@ panvk_compile_shader(struct panvk_device *dev, nir_shader *nir = clone_nir ? nir_shader_clone(NULL, info->nir) : info->nir; +#if PAN_ARCH >= 10 + if (inputs.view_mask) { + nir_lower_multiview_options options = { + .view_mask = inputs.view_mask, + .allowed_per_view_outputs = ~0 + }; + + /* The only case where this should fail is with memory/image + * writes, which we don't support in vertex shaders + */ + assert(nir_can_lower_multiview(nir, options)); + NIR_PASS(_, nir, nir_lower_multiview, options); + + /* Pull output writes out of the loop and give them constant + * offsets for pan_lower_store_components + */ + NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, + nir_shader_get_entrypoint(nir), nir_var_shader_out); + } +#endif + panvk_lower_nir(dev, nir, info->set_layout_count, info->set_layouts, info->robustness, state, &inputs, &variant->desc_info);