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>
This commit is contained in:
Louis-Francis Ratté-Boulianne
2024-01-24 00:56:09 -05:00
committed by Marge Bot
parent 62ed14b386
commit ee77168d57
5 changed files with 9 additions and 8 deletions

View File

@@ -107,11 +107,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

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

@@ -1383,7 +1383,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);
@@ -1393,7 +1393,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;
}
@@ -1401,7 +1401,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

@@ -196,7 +196,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);