From 6e666c6303bbcd810a5027efb743a6b180b6c90e Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Wed, 15 Feb 2023 22:34:46 +0100 Subject: [PATCH] nir: Skip samplers and textures in lower_explicit_io We have specialized lowering passes dealing with most of that already: 1. gl_nir_lower_samplers_as_deref 2. nir_lower_samplers 3. nir_lower_cl_images If we need more than that, those passes can deal with following deref chains as well. We _might_ need to improve nir_lower_cl_images a bit for more complex kernels, but CL also doesn't allow indirect images, so we are always able to optimize the entire deref chain away. Signed-off-by: Karol Herbst Reviewed-by: Faith Ekstrand Part-of: --- src/compiler/nir/nir_lower_io.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index 608b268b5d5..bfedfc48a66 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -2115,6 +2115,15 @@ static void lower_explicit_io_deref(nir_builder *b, nir_deref_instr *deref, nir_address_format addr_format) { + /* Ignore samplers/textures, because they are handled by other passes like `nir_lower_samplers`. + * Also do it only for those being uniforms, otherwise it will break GL bindless textures handles + * stored in UBOs. + */ + if (nir_deref_mode_is_in_set(deref, nir_var_uniform) && + (glsl_type_is_sampler(deref->type) || + glsl_type_is_texture(deref->type))) + return; + /* Just delete the deref if it's not used. We can't use * nir_deref_instr_remove_if_unused here because it may remove more than * one deref which could break our list walking since we walk the list