panfrost: add copy_resource flag to pan_resource_modifier_convert
When converting the modifier for a resource, it's not always
needed to blit the content as well. Creating a new resource with
the right format/modifier might be enough.
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 62ed14b3868e304371b3e096da94c6dc3e24a299)
This commit is contained in:
parent
dc7b4111fd
commit
dae3eb155a
4 changed files with 33 additions and 35 deletions
|
|
@ -944,7 +944,7 @@
|
|||
"description": "panfrost: add copy_resource flag to pan_resource_modifier_convert",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "33b48a55857b15f7e7b892a89cad2f0ad2399ba6",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ panfrost_set_shader_images(struct pipe_context *pctx,
|
|||
*/
|
||||
if (drm_is_afbc(rsrc->image.layout.modifier)) {
|
||||
pan_resource_modifier_convert(
|
||||
ctx, rsrc, DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED,
|
||||
ctx, rsrc, DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED, true,
|
||||
"Shader image");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1317,48 +1317,45 @@ panfrost_ptr_map(struct pipe_context *pctx, struct pipe_resource *resource,
|
|||
void
|
||||
pan_resource_modifier_convert(struct panfrost_context *ctx,
|
||||
struct panfrost_resource *rsrc, uint64_t modifier,
|
||||
const char *reason)
|
||||
bool copy_resource, const char *reason)
|
||||
{
|
||||
assert(!rsrc->modifier_constant);
|
||||
|
||||
perf_debug_ctx(ctx, "%s AFBC with a blit. Reason: %s",
|
||||
drm_is_afbc(modifier) ? "Unpacking" : "Disabling", reason);
|
||||
|
||||
struct pipe_resource *tmp_prsrc = panfrost_resource_create_with_modifier(
|
||||
ctx->base.screen, &rsrc->base, modifier);
|
||||
struct panfrost_resource *tmp_rsrc = pan_resource(tmp_prsrc);
|
||||
|
||||
struct pipe_blit_info blit = {
|
||||
.dst.resource = &tmp_rsrc->base,
|
||||
.dst.format = tmp_rsrc->base.format,
|
||||
.src.resource = &rsrc->base,
|
||||
.src.format = rsrc->base.format,
|
||||
.mask = util_format_get_mask(tmp_rsrc->base.format),
|
||||
.filter = PIPE_TEX_FILTER_NEAREST,
|
||||
};
|
||||
if (copy_resource) {
|
||||
struct pipe_blit_info blit = {
|
||||
.dst.resource = &tmp_rsrc->base,
|
||||
.dst.format = tmp_rsrc->base.format,
|
||||
.src.resource = &rsrc->base,
|
||||
.src.format = rsrc->base.format,
|
||||
.mask = util_format_get_mask(tmp_rsrc->base.format),
|
||||
.filter = PIPE_TEX_FILTER_NEAREST,
|
||||
};
|
||||
|
||||
/* data_valid is not valid until flushed */
|
||||
panfrost_flush_writer(ctx, rsrc, "AFBC decompressing blit");
|
||||
/* data_valid is not valid until flushed */
|
||||
panfrost_flush_writer(ctx, rsrc, "AFBC decompressing blit");
|
||||
|
||||
for (int i = 0; i <= rsrc->base.last_level; i++) {
|
||||
if (BITSET_TEST(rsrc->valid.data, i)) {
|
||||
blit.dst.level = blit.src.level = i;
|
||||
for (int i = 0; i <= rsrc->base.last_level; i++) {
|
||||
if (BITSET_TEST(rsrc->valid.data, i)) {
|
||||
blit.dst.level = blit.src.level = i;
|
||||
|
||||
u_box_3d(0, 0, 0,
|
||||
u_minify(rsrc->base.width0, i),
|
||||
u_minify(rsrc->base.height0, i),
|
||||
util_num_layers(&rsrc->base, i),
|
||||
&blit.dst.box);
|
||||
blit.src.box = blit.dst.box;
|
||||
u_box_3d(0, 0, 0, u_minify(rsrc->base.width0, i),
|
||||
u_minify(rsrc->base.height0, i),
|
||||
util_num_layers(&rsrc->base, i), &blit.dst.box);
|
||||
blit.src.box = blit.dst.box;
|
||||
|
||||
panfrost_blit_no_afbc_legalization(&ctx->base, &blit);
|
||||
panfrost_blit_no_afbc_legalization(&ctx->base, &blit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* we lose track of tmp_rsrc after this point, and the BO migration
|
||||
* (from tmp_rsrc to rsrc) doesn't transfer the last_writer to rsrc
|
||||
*/
|
||||
panfrost_flush_writer(ctx, tmp_rsrc, "AFBC decompressing blit");
|
||||
/* we lose track of tmp_rsrc after this point, and the BO migration
|
||||
* (from tmp_rsrc to rsrc) doesn't transfer the last_writer to rsrc
|
||||
*/
|
||||
panfrost_flush_writer(ctx, tmp_rsrc, "AFBC decompressing blit");
|
||||
}
|
||||
|
||||
panfrost_bo_unreference(rsrc->image.data.bo);
|
||||
|
||||
|
|
@ -1366,7 +1363,7 @@ pan_resource_modifier_convert(struct panfrost_context *ctx,
|
|||
panfrost_bo_reference(rsrc->image.data.bo);
|
||||
|
||||
panfrost_resource_setup(pan_device(ctx->base.screen), rsrc, modifier,
|
||||
blit.dst.format);
|
||||
tmp_rsrc->base.format);
|
||||
/* panfrost_resource_setup will force the modifier to stay constant when
|
||||
* called with a specific modifier. We don't want that here, we want to
|
||||
* be able to convert back to another modifier if needed */
|
||||
|
|
@ -1391,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,
|
||||
ctx, rsrc, DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED, true,
|
||||
"Reinterpreting AFBC surface as incompatible format");
|
||||
return;
|
||||
}
|
||||
|
|
@ -1399,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,
|
||||
"Legalizing resource to allow writing");
|
||||
true, "Legalizing resource to allow writing");
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
|||
|
|
@ -189,7 +189,8 @@ void panfrost_pack_afbc(struct panfrost_context *ctx,
|
|||
|
||||
void pan_resource_modifier_convert(struct panfrost_context *ctx,
|
||||
struct panfrost_resource *rsrc,
|
||||
uint64_t modifier, const char *reason);
|
||||
uint64_t modifier, bool copy_resource,
|
||||
const char *reason);
|
||||
|
||||
void pan_legalize_afbc_format(struct panfrost_context *ctx,
|
||||
struct panfrost_resource *rsrc,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue