panfrost: add can_discard flag to pan_legalize_afbc_format

There might be a more efficient path when legalizing a resource if
we don't need to worry about its content. For example, it doesn't
make sense to copy the resource content when converting the modifier
if the resource content is discarded anyway.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Fixes: 33b48a5585 ("panfrost: Add debug flag to force packing of AFBC textures on upload")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27208>
(cherry picked from commit ee77168d575cd41c0202ef918bf4935cc1603489)
This commit is contained in:
Louis-Francis Ratté-Boulianne 2024-01-24 00:56:09 -05:00 committed by Eric Engestrom
parent dae3eb155a
commit 97c0e12da3
6 changed files with 10 additions and 9 deletions

View file

@ -934,7 +934,7 @@
"description": "panfrost: add can_discard flag to pan_legalize_afbc_format",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "33b48a55857b15f7e7b892a89cad2f0ad2399ba6",
"notes": null

View file

@ -106,11 +106,11 @@ panfrost_blit(struct pipe_context *pipe, const struct pipe_blit_info *info)
/* Legalize here because it could trigger a recursive blit otherwise */
struct panfrost_resource *src = pan_resource(info->src.resource);
enum pipe_format src_view_format = util_format_linear(info->src.format);
pan_legalize_afbc_format(ctx, src, src_view_format, false);
pan_legalize_afbc_format(ctx, src, src_view_format, false, false);
struct panfrost_resource *dst = pan_resource(info->dst.resource);
enum pipe_format dst_view_format = util_format_linear(info->dst.format);
pan_legalize_afbc_format(ctx, dst, dst_view_format, true);
pan_legalize_afbc_format(ctx, dst, dst_view_format, true, false);
panfrost_blit_no_afbc_legalization(pipe, info);
}

View file

@ -3374,7 +3374,7 @@ panfrost_create_sampler_view(struct pipe_context *pctx,
rzalloc(pctx, struct panfrost_sampler_view);
pan_legalize_afbc_format(ctx, pan_resource(texture), template->format,
false);
false, false);
pipe_reference(NULL, &texture->reference);

View file

@ -65,7 +65,7 @@ panfrost_batch_add_surface(struct panfrost_batch *batch,
{
if (surf) {
struct panfrost_resource *rsrc = pan_resource(surf->texture);
pan_legalize_afbc_format(batch->ctx, rsrc, surf->format, true);
pan_legalize_afbc_format(batch->ctx, rsrc, surf->format, true, false);
panfrost_batch_write_rsrc(batch, rsrc, PIPE_SHADER_FRAGMENT);
}
}

View file

@ -1378,7 +1378,7 @@ pan_resource_modifier_convert(struct panfrost_context *ctx,
void
pan_legalize_afbc_format(struct panfrost_context *ctx,
struct panfrost_resource *rsrc,
enum pipe_format format, bool write)
enum pipe_format format, bool write, bool discard)
{
struct panfrost_device *dev = pan_device(ctx->base.screen);
@ -1388,7 +1388,7 @@ pan_legalize_afbc_format(struct panfrost_context *ctx,
if (panfrost_afbc_format(dev->arch, rsrc->base.format) !=
panfrost_afbc_format(dev->arch, format)) {
pan_resource_modifier_convert(
ctx, rsrc, DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED, true,
ctx, rsrc, DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED, !discard,
"Reinterpreting AFBC surface as incompatible format");
return;
}
@ -1396,7 +1396,7 @@ pan_legalize_afbc_format(struct panfrost_context *ctx,
if (write && (rsrc->image.layout.modifier & AFBC_FORMAT_MOD_SPARSE) == 0)
pan_resource_modifier_convert(
ctx, rsrc, rsrc->image.layout.modifier | AFBC_FORMAT_MOD_SPARSE,
true, "Legalizing resource to allow writing");
!discard, "Legalizing resource to allow writing");
}
static bool

View file

@ -194,7 +194,8 @@ void pan_resource_modifier_convert(struct panfrost_context *ctx,
void pan_legalize_afbc_format(struct panfrost_context *ctx,
struct panfrost_resource *rsrc,
enum pipe_format format, bool write);
enum pipe_format format, bool write,
bool discard);
void pan_dump_resource(struct panfrost_context *ctx,
struct panfrost_resource *rsc);