freedreno/a6xx: Add helper to check if UBWC is supported
Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8659>
This commit is contained in:
parent
38b073ebfe
commit
55f4f6882f
|
@ -37,7 +37,7 @@
|
|||
* it can be tiled doesn't mean it can be compressed.
|
||||
*/
|
||||
static bool
|
||||
ok_ubwc_format(struct fd_resource *rsc, enum pipe_format pfmt)
|
||||
ok_ubwc_format(struct pipe_screen *pscreen, enum pipe_format pfmt)
|
||||
{
|
||||
switch (pfmt) {
|
||||
case PIPE_FORMAT_X24S8_UINT:
|
||||
|
@ -47,7 +47,7 @@ ok_ubwc_format(struct fd_resource *rsc, enum pipe_format pfmt)
|
|||
* fd_resource_uncompress() at the point of stencil sampling because
|
||||
* that itself uses stencil sampling in the fd_blitter_blit path.
|
||||
*/
|
||||
return fd_screen(rsc->base.screen)->info.a6xx.has_z24uint_s8uint;
|
||||
return fd_screen(pscreen)->info.a6xx.has_z24uint_s8uint;
|
||||
|
||||
case PIPE_FORMAT_R8_G8B8_420_UNORM:
|
||||
return true;
|
||||
|
@ -90,6 +90,19 @@ ok_ubwc_format(struct fd_resource *rsc, enum pipe_format pfmt)
|
|||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
can_do_ubwc(struct pipe_resource *prsc)
|
||||
{
|
||||
/* limit things to simple single level 2d for now: */
|
||||
if ((prsc->depth0 != 1) || (prsc->array_size != 1) || (prsc->last_level != 0))
|
||||
return false;
|
||||
if (prsc->target != PIPE_TEXTURE_2D)
|
||||
return false;
|
||||
if (!ok_ubwc_format(prsc->screen, prsc->format))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the rsc is in an ok state to be used with the specified format.
|
||||
* This handles the case of UBWC buffers used with non-UBWC compatible
|
||||
|
@ -102,7 +115,7 @@ fd6_validate_format(struct fd_context *ctx, struct fd_resource *rsc,
|
|||
if (!rsc->layout.ubwc)
|
||||
return;
|
||||
|
||||
if (ok_ubwc_format(rsc, format))
|
||||
if (ok_ubwc_format(rsc->base.screen, format))
|
||||
return;
|
||||
|
||||
fd_resource_uncompress(ctx, rsc);
|
||||
|
@ -145,7 +158,7 @@ fd6_setup_slices(struct fd_resource *rsc)
|
|||
if (!(fd_mesa_debug & FD_DBG_NOLRZ) && has_depth(rsc->base.format))
|
||||
setup_lrz(rsc);
|
||||
|
||||
if (rsc->layout.ubwc && !ok_ubwc_format(rsc, rsc->base.format))
|
||||
if (rsc->layout.ubwc && !ok_ubwc_format(rsc->base.screen, rsc->base.format))
|
||||
rsc->layout.ubwc = false;
|
||||
|
||||
fdl6_layout(&rsc->layout, prsc->format, fd_resource_nr_samples(prsc),
|
||||
|
@ -166,12 +179,7 @@ fill_ubwc_buffer_sizes(struct fd_resource *rsc)
|
|||
.pitch = rsc->layout.pitch0,
|
||||
};
|
||||
|
||||
/* limit things to simple single level 2d for now: */
|
||||
if ((prsc->depth0 != 1) || (prsc->array_size != 1) || (prsc->last_level != 0))
|
||||
return -1;
|
||||
if (prsc->target != PIPE_TEXTURE_2D)
|
||||
return -1;
|
||||
if (!ok_ubwc_format(rsc, prsc->format))
|
||||
if (!can_do_ubwc(prsc))
|
||||
return -1;
|
||||
|
||||
rsc->layout.ubwc = true;
|
||||
|
|
Loading…
Reference in New Issue