diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index d490ce04bf4..60496e4336d 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -3494,8 +3494,6 @@ emit_intrinsic(struct ir3_context *ctx, nir_intrinsic_instr *intr) break; } case nir_intrinsic_prefetch_ubo_ir3: { - if (!ir3_bindless_resource(intr->src[0])) - break; struct ir3_instruction *offset = create_immed(b, 0); struct ir3_instruction *idx = ir3_get_src(ctx, &intr->src[0])[0]; struct ir3_instruction *ldc = ir3_LDC(b, idx, 0, offset, 0); diff --git a/src/freedreno/ir3/ir3_nir_opt_preamble.c b/src/freedreno/ir3/ir3_nir_opt_preamble.c index 5888fa6e47b..5a8675e6ceb 100644 --- a/src/freedreno/ir3/ir3_nir_opt_preamble.c +++ b/src/freedreno/ir3/ir3_nir_opt_preamble.c @@ -714,6 +714,12 @@ get_preamble_offset(nir_def *def) return nir_intrinsic_base(nir_def_as_intrinsic(def)); } +static bool +should_prefetch_descriptor(nir_def *desc) +{ + return desc != NULL && ir3_bindless_resource(nir_src_for_ssa(desc)); +} + /* Prefetch descriptors in the preamble. This is an optimization introduced on * a7xx, mainly useful when the preamble is an early preamble, and replaces the * use of CP_LOAD_STATE on a6xx to prefetch descriptors in HLSQ. @@ -765,8 +771,9 @@ ir3_nir_opt_prefetch_descriptors(nir_shader *nir, struct ir3_shader_variant *v) nir_def *preamble_descs[2] = { NULL, NULL }; get_descriptors(instr, descs); - /* We must have found at least one descriptor */ - if (!descs[0] && !descs[1]) + /* Bail unless we found at least one bindless descriptor */ + if (!(should_prefetch_descriptor(descs[0]) || + should_prefetch_descriptor(descs[1]))) continue; /* The instruction itself must be hoistable.