From e15603bdf1ec01c135d4fbf9b6a7adba3123c927 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 30 Mar 2023 13:55:14 -0400 Subject: [PATCH] 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 Reviewed-by: Italo Nicola Reviewed-by: Boris Brezillon Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 32 +++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 5e902c05051..6d7171c1190 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -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]));