mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
pan/nir/tex: Support full index+offset
Previously, we only supported one of the index or the offset source and relied on lower_index_to_offset to ensure we only had one or the other. However, now that we're doing things in NIR, it's trivial to support the full index+offset form. Reviewed-by: Ryan Mckeever <ryan.mckeever@collabora.com> Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41320>
This commit is contained in:
parent
61acf0e781
commit
c73d4e14f9
1 changed files with 11 additions and 7 deletions
|
|
@ -22,6 +22,15 @@ struct tex_srcs {
|
|||
nir_def *z_cmpr;
|
||||
};
|
||||
|
||||
static nir_def *
|
||||
combine_index(nir_builder *b, nir_def *offset, uint32_t index)
|
||||
{
|
||||
if (offset)
|
||||
return nir_iadd_imm(b, offset, index);
|
||||
else
|
||||
return nir_imm_int(b, index);
|
||||
}
|
||||
|
||||
static struct tex_srcs
|
||||
steal_tex_srcs(nir_builder *b, nir_tex_instr *tex)
|
||||
{
|
||||
|
|
@ -50,13 +59,8 @@ steal_tex_srcs(nir_builder *b, nir_tex_instr *tex)
|
|||
}
|
||||
tex->num_srcs = 0;
|
||||
|
||||
/* If we don't have a texture or sampler handle, grab it from the
|
||||
* immediate texture/sampler_index.
|
||||
*/
|
||||
if (!srcs.tex_h)
|
||||
srcs.tex_h = nir_imm_int(b, tex->texture_index);
|
||||
if (!srcs.samp_h)
|
||||
srcs.samp_h = nir_imm_int(b, tex->sampler_index);
|
||||
srcs.tex_h = combine_index(b, srcs.tex_h, tex->texture_index);
|
||||
srcs.samp_h = combine_index(b, srcs.samp_h, tex->sampler_index);
|
||||
|
||||
return srcs;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue