pan/{mdg,bi}: Always use sampler 0 for txf

Now that we upload workaround samplers for txf, sampler 0 is guaranteed to be
valid but other samplers are not. So ignore whatever the current sampler_index
value is (it's formally undefined in NIR) and use 0, which we know is valid. We
already do this on Valhall for OpenCL, just need to generalize for Midgard and
Bifrost.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Italo Nicola <italonicola@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22223>
This commit is contained in:
Alyssa Rosenzweig
2023-03-30 14:00:46 -04:00
committed by Marge Bot
parent e15603bdf1
commit b9cc2b2a98
2 changed files with 17 additions and 3 deletions
+9 -3
View File
@@ -3534,9 +3534,7 @@ bi_emit_tex_valhall(bi_builder *b, nir_tex_instr *instr)
/* 32-bit indices to be allocated as consecutive staging registers */
bi_index sregs[VALHALL_TEX_SREG_COUNT] = {};
bool has_sampler = nir_tex_instr_need_sampler(instr);
bi_index sampler = bi_imm_u32(has_sampler ? instr->sampler_index : 0);
bi_index sampler = bi_imm_u32(instr->sampler_index);
bi_index texture = bi_imm_u32(instr->texture_index);
uint32_t tables = (PAN_TABLE_SAMPLER << 11) | (PAN_TABLE_TEXTURE << 27);
@@ -3779,6 +3777,14 @@ bi_is_simple_tex(nir_tex_instr *instr)
static void
bi_emit_tex(bi_builder *b, nir_tex_instr *instr)
{
/* If txf is used, we assume there is a valid sampler bound at index 0. Use
* it for txf operations, since there may be no other valid samplers. This is
* a workaround: txf does not require a sampler in NIR (so sampler_index is
* undefined) but we need one in the hardware. This is ABI with the driver.
*/
if (!nir_tex_instr_need_sampler(instr))
instr->sampler_index = 0;
if (b->shader->arch >= 9)
bi_emit_tex_valhall(b, instr);
else if (bi_is_simple_tex(instr))
+8
View File
@@ -2334,6 +2334,14 @@ emit_texop_native(compiler_context *ctx, nir_tex_instr *instr,
int texture_index = instr->texture_index;
int sampler_index = instr->sampler_index;
/* If txf is used, we assume there is a valid sampler bound at index 0. Use
* it for txf operations, since there may be no other valid samplers. This is
* a workaround: txf does not require a sampler in NIR (so sampler_index is
* undefined) but we need one in the hardware. This is ABI with the driver.
*/
if (!nir_tex_instr_need_sampler(instr))
sampler_index = 0;
nir_alu_type dest_base = nir_alu_type_get_base_type(instr->dest_type);
/* texture instructions support float outmods */