panfrost: Upload default sampler for txf
In NIR, txf does not take a sampler. However, in the hardware it does take a sampler. If there is no sampler bound and we use txf, the hardware will read back all-0's due to bounds checking. As a workaround, bind a trivial sampler and use that. As-is this workaround is Valhall specific, making use of an extra resource table. I'm punting on generalizing back to Bifrost until I can discuss the issue in more depth with Jason and Karol and figure out the right fix. Fixes api.image_properties_query. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18656>
This commit is contained in:
committed by
Marge Bot
parent
6d180c84fb
commit
ff29ff5fad
@@ -3246,6 +3246,14 @@ panfrost_emit_primitive(struct panfrost_context *ctx,
|
||||
}
|
||||
|
||||
#if PAN_ARCH >= 9
|
||||
static mali_ptr
|
||||
panfrost_upload_wa_sampler(struct panfrost_batch *batch)
|
||||
{
|
||||
struct panfrost_ptr T = pan_pool_alloc_desc(&batch->pool.base, SAMPLER);
|
||||
pan_pack(T.cpu, SAMPLER, cfg);
|
||||
return T.gpu;
|
||||
}
|
||||
|
||||
static mali_ptr
|
||||
panfrost_emit_resources(struct panfrost_batch *batch,
|
||||
enum pipe_shader_type stage,
|
||||
@@ -3267,9 +3275,17 @@ panfrost_emit_resources(struct panfrost_batch *batch,
|
||||
batch->textures[stage],
|
||||
ctx->sampler_view_count[stage]);
|
||||
|
||||
panfrost_make_resource_table(T, PAN_TABLE_SAMPLER,
|
||||
batch->samplers[stage],
|
||||
ctx->sampler_count[stage]);
|
||||
|
||||
if (ctx->sampler_count[stage]) {
|
||||
panfrost_make_resource_table(T, PAN_TABLE_SAMPLER,
|
||||
batch->samplers[stage],
|
||||
ctx->sampler_count[stage]);
|
||||
} else {
|
||||
/* We always need at least 1 sampler for txf to work */
|
||||
panfrost_make_resource_table(T, PAN_TABLE_SAMPLER,
|
||||
panfrost_upload_wa_sampler(batch),
|
||||
1);
|
||||
}
|
||||
|
||||
panfrost_make_resource_table(T, PAN_TABLE_IMAGE,
|
||||
batch->images[stage],
|
||||
|
||||
@@ -3666,7 +3666,9 @@ 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] = { };
|
||||
|
||||
bi_index sampler = bi_imm_u32(instr->sampler_index);
|
||||
|
||||
bool has_sampler = nir_tex_instr_need_sampler(instr);
|
||||
bi_index sampler = bi_imm_u32(has_sampler ? instr->sampler_index : 0);
|
||||
bi_index texture = bi_imm_u32(instr->texture_index);
|
||||
uint32_t tables = (PAN_TABLE_SAMPLER << 11) | (PAN_TABLE_TEXTURE << 27);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user