From e24228e3278ff27e704355bfc03259c1c98bcc98 Mon Sep 17 00:00:00 2001 From: Lorenzo Rossi Date: Mon, 13 Apr 2026 11:40:38 +0200 Subject: [PATCH] panfrost,panvk: Move lower_texture_late inside postproc Signed-off-by: Lorenzo Rossi Reviewed-by: Christoph Pillmayer Reviewed-by: Faith Ekstrand Reviewed-by: Lars-Ivar Hesselberg Simonsen Part-of: --- src/gallium/drivers/panfrost/pan_shader.c | 1 - src/panfrost/clc/pan_compile.c | 1 - .../compiler/bifrost/bifrost_compile.h | 2 -- src/panfrost/compiler/bifrost/bifrost_nir.c | 20 ++++++++++++++----- src/panfrost/compiler/pan_compiler.c | 12 ----------- src/panfrost/compiler/pan_nir.h | 1 - .../vulkan/panvk_vX_cmd_frame_shaders.c | 1 - src/panfrost/vulkan/panvk_vX_shader.c | 1 - 8 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_shader.c b/src/gallium/drivers/panfrost/pan_shader.c index 057af378eb9..c24133444c4 100644 --- a/src/gallium/drivers/panfrost/pan_shader.c +++ b/src/gallium/drivers/panfrost/pan_shader.c @@ -188,7 +188,6 @@ panfrost_shader_compile(struct panfrost_screen *screen, const nir_shader *ir, NIR_PASS(_, s, panfrost_nir_lower_res_indices, &inputs); pan_postprocess_nir(s, panfrost_device_gpu_id(dev)); - pan_nir_lower_texture_late(s, inputs.gpu_id); if (s->info.stage == MESA_SHADER_VERTEX) { NIR_PASS(_, s, nir_inline_sysval, diff --git a/src/panfrost/clc/pan_compile.c b/src/panfrost/clc/pan_compile.c index 116adc26c59..7dda091ab72 100644 --- a/src/panfrost/clc/pan_compile.c +++ b/src/panfrost/clc/pan_compile.c @@ -430,7 +430,6 @@ main(int argc, const char **argv) nir_address_format_62bit_generic); pan_postprocess_nir(s, inputs.gpu_id); - pan_nir_lower_texture_late(s, inputs.gpu_id); NIR_PASS(_, s, nir_shader_intrinsics_pass, lower_sysvals, nir_metadata_control_flow, NULL); diff --git a/src/panfrost/compiler/bifrost/bifrost_compile.h b/src/panfrost/compiler/bifrost/bifrost_compile.h index 811f5f4339b..2bbb3578598 100644 --- a/src/panfrost/compiler/bifrost/bifrost_compile.h +++ b/src/panfrost/compiler/bifrost/bifrost_compile.h @@ -65,8 +65,6 @@ bifrost_precompiled_kernel_prepare_push_uniforms( void bifrost_preprocess_nir(nir_shader *nir, uint64_t gpu_id); void bifrost_optimize_nir(nir_shader *nir, uint64_t gpu_id); void bifrost_postprocess_nir(nir_shader *nir, uint64_t gpu_id); -void bifrost_lower_texture_nir(nir_shader *nir, uint64_t gpu_id); -void bifrost_lower_texture_late_nir(nir_shader *nir, uint64_t gpu_id); void bifrost_compile_shader_nir(nir_shader *nir, const struct pan_compile_inputs *inputs, diff --git a/src/panfrost/compiler/bifrost/bifrost_nir.c b/src/panfrost/compiler/bifrost/bifrost_nir.c index f0c65692cbc..7f81d48b6a9 100644 --- a/src/panfrost/compiler/bifrost/bifrost_nir.c +++ b/src/panfrost/compiler/bifrost/bifrost_nir.c @@ -714,6 +714,9 @@ mem_access_size_align_cb(nir_intrinsic_op intrin, uint8_t bytes, }; } +static void bi_lower_texture_nir(nir_shader *nir, uint64_t gpu_id); +static void bi_lower_texture_late_nir(nir_shader *nir, uint64_t gpu_id); + void bifrost_postprocess_nir(nir_shader *nir, uint64_t gpu_id) { @@ -727,7 +730,7 @@ bifrost_postprocess_nir(nir_shader *nir, uint64_t gpu_id) NIR_PASS(_, nir, nir_opt_sink, move_all); NIR_PASS(_, nir, nir_opt_move, move_all); - bifrost_lower_texture_nir(nir, gpu_id); + bi_lower_texture_nir(nir, gpu_id); if (nir->info.stage == MESA_SHADER_FRAGMENT) { NIR_PASS(_, nir, pan_nir_lower_noperspective_fs); @@ -816,10 +819,12 @@ bifrost_postprocess_nir(nir_shader *nir, uint64_t gpu_id) NIR_PASS(_, nir, nir_lower_alu); NIR_PASS(_, nir, nir_lower_frag_coord_to_pixel_coord); NIR_PASS(_, nir, pan_nir_lower_var_special_pan); + + bi_lower_texture_late_nir(nir, gpu_id); } -void -bifrost_lower_texture_nir(nir_shader *nir, uint64_t gpu_id) +static void +bi_lower_texture_nir(nir_shader *nir, uint64_t gpu_id) { NIR_PASS(_, nir, nir_lower_image_atomics_to_global, NULL, NULL); @@ -964,8 +969,13 @@ pan_nir_lower_buf_image_access(nir_shader *shader, unsigned arch) nir_metadata_control_flow, &arch); } -void -bifrost_lower_texture_late_nir(nir_shader *nir, uint64_t gpu_id) +/* This must be called after any lowering of resource indices + * (panfrost_nir_lower_res_indices / panvk_per_arch(nir_lower_descriptors)) + * and lowering of attribute indices (pan_nir_lower_image_index / + * pan_nir_lower_texel_buffer_fetch_index) + */ +static void +bi_lower_texture_late_nir(nir_shader *nir, uint64_t gpu_id) { NIR_PASS(_, nir, pan_nir_lower_texel_buffer_fetch, pan_arch(gpu_id)); NIR_PASS(_, nir, pan_nir_lower_buf_image_access, pan_arch(gpu_id)); diff --git a/src/panfrost/compiler/pan_compiler.c b/src/panfrost/compiler/pan_compiler.c index ce81a13e34f..21d4e1bcad8 100644 --- a/src/panfrost/compiler/pan_compiler.c +++ b/src/panfrost/compiler/pan_compiler.c @@ -101,18 +101,6 @@ pan_nir_lower_texture_early(nir_shader *nir, uint64_t gpu_id) NIR_PASS(_, nir, nir_lower_tex, &lower_tex_options); } - -void -pan_nir_lower_texture_late(nir_shader *nir, uint64_t gpu_id) -{ - /* This must be called after any lowering of resource indices - * (panfrost_nir_lower_res_indices / panvk_per_arch(nir_lower_descriptors)) - * and lowering of attribute indices (pan_nir_lower_image_index / - * pan_nir_lower_texel_buffer_fetch_index) */ - if (pan_arch(gpu_id) >= 6) - bifrost_lower_texture_late_nir(nir, gpu_id); -} - /** Converts a per-component mask to a byte mask */ uint16_t pan_to_bytemask(unsigned bytes, unsigned mask) diff --git a/src/panfrost/compiler/pan_nir.h b/src/panfrost/compiler/pan_nir.h index 6443d04f8e8..c9cc4aee353 100644 --- a/src/panfrost/compiler/pan_nir.h +++ b/src/panfrost/compiler/pan_nir.h @@ -73,7 +73,6 @@ bool pan_nir_lower_texel_buffer_fetch_index(nir_shader *shader, unsigned attrib_offset); void pan_nir_lower_texture_early(nir_shader *nir, uint64_t gpu_id); -void pan_nir_lower_texture_late(nir_shader *nir, uint64_t gpu_id); nir_alu_type pan_unpacked_type_for_format(const struct util_format_description *desc); diff --git a/src/panfrost/vulkan/panvk_vX_cmd_frame_shaders.c b/src/panfrost/vulkan/panvk_vX_cmd_frame_shaders.c index 196614c3fe6..47f0c70be27 100644 --- a/src/panfrost/vulkan/panvk_vX_cmd_frame_shaders.c +++ b/src/panfrost/vulkan/panvk_vX_cmd_frame_shaders.c @@ -223,7 +223,6 @@ get_frame_shader(struct panvk_device *dev, pan_preprocess_nir(nir, inputs.gpu_id); pan_nir_lower_texture_early(nir, inputs.gpu_id); pan_postprocess_nir(nir, inputs.gpu_id); - pan_nir_lower_texture_late(nir, inputs.gpu_id); VkResult result = panvk_per_arch(create_internal_shader)( dev, nir, &inputs, &shader); diff --git a/src/panfrost/vulkan/panvk_vX_shader.c b/src/panfrost/vulkan/panvk_vX_shader.c index 9ddd39bfb76..b26a0bedf68 100644 --- a/src/panfrost/vulkan/panvk_vX_shader.c +++ b/src/panfrost/vulkan/panvk_vX_shader.c @@ -981,7 +981,6 @@ panvk_compile_nir(struct panvk_device *dev, nir_shader *nir, } pan_postprocess_nir(nir, input.gpu_id); - pan_nir_lower_texture_late(nir, input.gpu_id); if (noperspective_varyings && nir->info.stage == MESA_SHADER_VERTEX) { NIR_PASS(_, nir, nir_inline_sysval,