panfrost: Always upload a workaround sampler

The hardware requires a valid sampler even for texelFetch (txf), even though its
contents are ignored. We'd rather not pass on this requirement to the frontends,
so we should handle it by uploading our own workaround sampler in the case when
no sampler is already present. We already do this on Valhall (for rusticl), so
we just need to port the same workaround back to Midgard/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 13:55:14 -04:00 committed by Marge Bot
parent 06bfe07212
commit e15603bdf1

View file

@ -1821,14 +1821,24 @@ panfrost_emit_texture_descriptors(struct panfrost_batch *batch,
#endif
}
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_sampler_descriptors(struct panfrost_batch *batch,
enum pipe_shader_type stage)
{
struct panfrost_context *ctx = batch->ctx;
/* We always need at least 1 sampler for txf to work */
if (!ctx->sampler_count[stage])
return 0;
return panfrost_upload_wa_sampler(batch);
struct panfrost_ptr T = pan_pool_alloc_desc_array(
&batch->pool.base, ctx->sampler_count[stage], SAMPLER);
@ -3077,15 +3087,6 @@ 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)
@ -3107,14 +3108,9 @@ panfrost_emit_resources(struct panfrost_batch *batch,
panfrost_make_resource_table(T, PAN_TABLE_TEXTURE, batch->textures[stage],
ctx->sampler_view_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);
}
/* We always need at least 1 sampler for txf to work */
panfrost_make_resource_table(T, PAN_TABLE_SAMPLER, batch->samplers[stage],
MAX2(ctx->sampler_count[stage], 1));
panfrost_make_resource_table(T, PAN_TABLE_IMAGE, batch->images[stage],
util_last_bit(ctx->image_mask[stage]));