diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index ea596b4f03e..0ea574e144b 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -1348,6 +1348,13 @@ agx_emit_tex(agx_builder *b, nir_tex_instr *instr) compare = index; break; + case nir_tex_src_texture_offset: + texture = index; + break; + case nir_tex_src_sampler_offset: + sampler = index; + break; + case nir_tex_src_ddx: { int y_idx = nir_tex_instr_src_index(instr, nir_tex_src_ddy); assert(y_idx >= 0 && "we only handle gradients"); @@ -1373,10 +1380,8 @@ agx_emit_tex(agx_builder *b, nir_tex_instr *instr) /* handled above */ break; - case nir_tex_src_texture_offset: - case nir_tex_src_sampler_offset: default: - unreachable("todo"); + unreachable("Unexpected texture source"); } } diff --git a/src/asahi/compiler/agx_nir_lower_texture.c b/src/asahi/compiler/agx_nir_lower_texture.c index d338e508bc5..fddec9ab2c3 100644 --- a/src/asahi/compiler/agx_nir_lower_texture.c +++ b/src/asahi/compiler/agx_nir_lower_texture.c @@ -38,15 +38,16 @@ texture_descriptor_ptr(nir_builder *b, nir_tex_instr *tex) if (handle_idx >= 0) return tex->src[handle_idx].src.ssa; - /* For non-bindless, compute from the texture index, offset, and table */ - unsigned base_B = tex->texture_index * AGX_TEXTURE_DESC_STRIDE; - nir_ssa_def *offs = nir_imm_int(b, base_B); + /* For non-bindless, compute from the texture index */ + nir_ssa_def *offs; int offs_idx = nir_tex_instr_src_index(tex, nir_tex_src_texture_offset); if (offs_idx >= 0) { nir_ssa_def *offset_src = tex->src[offs_idx].src.ssa; - offs = nir_iadd(b, offs, - nir_imul_imm(b, offset_src, AGX_TEXTURE_DESC_STRIDE)); + offs = nir_imul_imm(b, offset_src, AGX_TEXTURE_DESC_STRIDE); + } else { + unsigned base_B = tex->texture_index * AGX_TEXTURE_DESC_STRIDE; + offs = nir_imm_int(b, base_B); } return nir_iadd(b, nir_load_texture_base_agx(b), nir_u2u64(b, offs)); @@ -322,6 +323,7 @@ agx_nir_lower_texture(nir_shader *s, bool support_lod_bias) .lower_txp = ~0, .lower_invalid_implicit_lod = true, .lower_tg4_offsets = true, + .lower_index_to_offset = true, /* XXX: Metal seems to handle just like 3D txd, so why doesn't it work? * TODO: Stop using this lowering @@ -333,6 +335,8 @@ agx_nir_lower_texture(nir_shader *s, bool support_lod_bias) [nir_tex_src_lod] = {true, 16}, [nir_tex_src_bias] = {true, 16}, [nir_tex_src_ms_index] = {true, 16}, + [nir_tex_src_texture_offset] = {true, 16}, + [nir_tex_src_sampler_offset] = {true, 16}, }; NIR_PASS(progress, s, nir_lower_tex, &lower_tex_options);