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 ee77168d57)
This commit is contained in:
Louis-Francis Ratté-Boulianne
2024-01-24 00:56:09 -05:00
committed by Eric Engestrom
parent 76d30497b6
commit 05ea7d854e
6 changed files with 9 additions and 8 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

@@ -92,7 +92,7 @@ panfrost_blit(struct pipe_context *pipe, const struct pipe_blit_info *info)
/* Legalize here because it could trigger a recursive blit otherwise */
pan_legalize_afbc_format(ctx, pan_resource(info->dst.resource),
info->dst.format, true);
info->dst.format, true, false);
panfrost_blitter_save(ctx, info->render_condition_enable
? PAN_RENDER_BLIT_COND

View File

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

View File

@@ -68,7 +68,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

@@ -1363,7 +1363,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);
@@ -1373,7 +1373,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;
}
@@ -1381,7 +1381,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);