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); }