From 5a4dff59225ad6e9b805028cc27c1d40efe70edd Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Wed, 1 May 2024 09:47:15 -0400 Subject: [PATCH] ir3: Fix non-bindless s2en texture/sampler order In gallium samplers and textures have a 1:1 correspondance, so it was impossible to tell which is which. But we use non-bindless textures for subpass loads, which don't have a sampler (so common code lowers to an index of 0) and therefore the order matters. With dynamic rendering, we can have more than 16 slots for input attachments, so the s2en wasn't getting optimized away and suddenly it starts mattering, and it turns out we got it wrong. By fixing this we also make the order the same as the bindless order, which was always tested well by Vulkan. Part-of: --- src/freedreno/ir3/ir3_compiler_nir.c | 7 +++---- src/freedreno/ir3/ir3_cp.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index 2ccbf5af210..8331c5ea6f4 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -1659,7 +1659,7 @@ get_image_ssbo_samp_tex_src(struct ir3_context *ctx, nir_src *src, bool image) texture = create_immed_typed(ctx->block, tex_idx, TYPE_U16); sampler = create_immed_typed(ctx->block, tex_idx, TYPE_U16); - info.samp_tex = ir3_collect(b, sampler, texture); + info.samp_tex = ir3_collect(b, texture, sampler); } return info; @@ -1866,8 +1866,7 @@ get_bindless_samp_src(struct ir3_context *ctx, nir_src *tex, info.flags |= IR3_INSTR_A1EN; } - /* Note: the indirect source is now a vec2 instead of hvec2, and - * for some reason the texture and sampler are swapped. + /* Note: the indirect source is now a vec2 instead of hvec2 */ struct ir3_instruction *texture, *sampler; @@ -3446,7 +3445,7 @@ get_tex_samp_tex_src(struct ir3_context *ctx, nir_tex_instr *tex) info.samp_idx = tex->texture_index; } - info.samp_tex = ir3_collect(b, sampler, texture); + info.samp_tex = ir3_collect(b, texture, sampler); } return info; diff --git a/src/freedreno/ir3/ir3_cp.c b/src/freedreno/ir3/ir3_cp.c index df0363c0ee7..643c6a46a58 100644 --- a/src/freedreno/ir3/ir3_cp.c +++ b/src/freedreno/ir3/ir3_cp.c @@ -549,8 +549,8 @@ instr_cp(struct ir3_cp_ctx *ctx, struct ir3_instruction *instr) assert(samp_tex->opc == OPC_META_COLLECT); - struct ir3_register *samp = samp_tex->srcs[0]; - struct ir3_register *tex = samp_tex->srcs[1]; + struct ir3_register *tex = samp_tex->srcs[0]; + struct ir3_register *samp = samp_tex->srcs[1]; if ((samp->flags & IR3_REG_IMMED) && (tex->flags & IR3_REG_IMMED) && (samp->iim_val < 16) && (tex->iim_val < 16)) {