Mesa (main): anv: use nir_shader_instructions_pass in anv_nir_lower_ycbcr_textures

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 5 10:29:40 UTC 2021


Module: Mesa
Branch: main
Commit: 6e0c38567f43b927fd035370ad6441eaeac8f44e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e0c38567f43b927fd035370ad6441eaeac8f44e

Author: Marcin Ślusarz <marcin.slusarz at intel.com>
Date:   Fri Aug  6 14:46:21 2021 +0200

anv: use nir_shader_instructions_pass in anv_nir_lower_ycbcr_textures

No functional changes.

Signed-off-by: Marcin Ślusarz <marcin.slusarz at intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13189>

---

 src/intel/vulkan/anv_nir_lower_ycbcr_textures.c | 48 ++++++++-----------------
 1 file changed, 15 insertions(+), 33 deletions(-)

diff --git a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
index a1504120247..fdc77d87988 100644
--- a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
+++ b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
@@ -199,10 +199,17 @@ swizzle_channel(struct isl_swizzle swizzle, unsigned channel)
 }
 
 static bool
-try_lower_tex_ycbcr(const struct anv_pipeline_layout *layout,
-                    nir_builder *builder,
-                    nir_tex_instr *tex)
+anv_nir_lower_ycbcr_textures_instr(nir_builder *builder,
+                                   nir_instr *instr,
+                                   void *cb_data)
 {
+   const struct anv_pipeline_layout *layout = cb_data;
+
+   if (instr->type != nir_instr_type_tex)
+      return false;
+
+   nir_tex_instr *tex = nir_instr_as_tex(instr);
+
    int deref_src_idx = nir_tex_instr_src_index(tex, nir_tex_src_texture_deref);
    assert(deref_src_idx >= 0);
    nir_deref_instr *deref = nir_src_as_deref(tex->src[deref_src_idx].src);
@@ -334,34 +341,9 @@ bool
 anv_nir_lower_ycbcr_textures(nir_shader *shader,
                              const struct anv_pipeline_layout *layout)
 {
-   bool progress = false;
-
-   nir_foreach_function(function, shader) {
-      if (!function->impl)
-         continue;
-
-      bool function_progress = false;
-      nir_builder builder;
-      nir_builder_init(&builder, function->impl);
-
-      nir_foreach_block(block, function->impl) {
-         nir_foreach_instr_safe(instr, block) {
-            if (instr->type != nir_instr_type_tex)
-               continue;
-
-            nir_tex_instr *tex = nir_instr_as_tex(instr);
-            function_progress |= try_lower_tex_ycbcr(layout, &builder, tex);
-         }
-      }
-
-      if (function_progress) {
-         nir_metadata_preserve(function->impl,
-                               nir_metadata_block_index |
-                               nir_metadata_dominance);
-      }
-
-      progress |= function_progress;
-   }
-
-   return progress;
+   return nir_shader_instructions_pass(shader,
+                                       anv_nir_lower_ycbcr_textures_instr,
+                                       nir_metadata_block_index |
+                                       nir_metadata_dominance,
+                                       (void *)layout);
 }



More information about the mesa-commit mailing list