mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
panfrost: add resource modifier conversion
Adds a helper function to convert a resource to a chosen modifier. Signed-off-by: Italo Nicola <italonicola@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8066>
This commit is contained in:
parent
c7c4fbc823
commit
f63a35baee
2 changed files with 53 additions and 0 deletions
|
|
@ -1114,6 +1114,55 @@ panfrost_ptr_map(struct pipe_context *pctx,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
pan_resource_modifier_convert(struct panfrost_context *ctx,
|
||||
struct panfrost_resource *rsrc,
|
||||
uint64_t modifier)
|
||||
{
|
||||
assert(!rsrc->modifier_constant);
|
||||
|
||||
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 = {0};
|
||||
|
||||
unsigned depth = rsrc->base.target == PIPE_TEXTURE_3D ?
|
||||
rsrc->base.depth0 : rsrc->base.array_size;
|
||||
|
||||
struct pipe_box box =
|
||||
{ 0, 0, 0, rsrc->base.width0, rsrc->base.height0, depth };
|
||||
|
||||
for (int i = 0; i <= rsrc->base.last_level; i++) {
|
||||
if (!rsrc->layout.slices[i].initialized)
|
||||
continue;
|
||||
|
||||
blit.dst.resource = &tmp_rsrc->base;
|
||||
blit.dst.format = pan_blit_format(tmp_rsrc->base.format);
|
||||
blit.dst.level = i;
|
||||
blit.dst.box = box;
|
||||
blit.src.resource = &rsrc->base;
|
||||
blit.src.format = pan_blit_format(rsrc->base.format);
|
||||
blit.src.level = i;
|
||||
blit.src.box = box;
|
||||
blit.mask = util_format_get_mask(blit.dst.format);
|
||||
blit.filter = PIPE_TEX_FILTER_NEAREST;
|
||||
|
||||
panfrost_blit(&ctx->base, &blit);
|
||||
}
|
||||
|
||||
panfrost_bo_unreference(rsrc->bo);
|
||||
if (rsrc->checksum_bo)
|
||||
panfrost_bo_unreference(rsrc->checksum_bo);
|
||||
|
||||
rsrc->bo = tmp_rsrc->bo;
|
||||
panfrost_bo_reference(rsrc->bo);
|
||||
|
||||
panfrost_resource_setup(pan_device(ctx->base.screen), rsrc, NULL, modifier);
|
||||
pipe_resource_reference(&tmp_prsrc, NULL);
|
||||
}
|
||||
|
||||
static bool
|
||||
panfrost_should_linear_convert(struct panfrost_resource *prsrc,
|
||||
struct pipe_transfer *transfer)
|
||||
|
|
|
|||
|
|
@ -146,5 +146,9 @@ panfrost_translate_texture_dimension(enum pipe_texture_target t) {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
pan_resource_modifier_convert(struct panfrost_context *ctx,
|
||||
struct panfrost_resource *rsrc,
|
||||
uint64_t modifier);
|
||||
|
||||
#endif /* PAN_RESOURCE_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue