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");
/* handled above */
break;
- case nir_tex_src_texture_offset:
- case nir_tex_src_sampler_offset:
default:
- unreachable("todo");
+ unreachable("Unexpected texture source");
}
}
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));
.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
[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);