mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 03:08:05 +02:00
panfrost: Move out-of-band CRC info to pan_image
We already have the data BO stored there, let's move the out-of-band CRC BO too. We also add a CRC mode to pan_image_layout so we can easily know where the CRC resides. Signed-off-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/10033>
This commit is contained in:
parent
1c7e8a1692
commit
50f39908aa
6 changed files with 49 additions and 28 deletions
|
|
@ -561,8 +561,8 @@ panfrost_batch_add_resource_bos(struct panfrost_batch *batch,
|
|||
{
|
||||
panfrost_batch_add_bo(batch, rsrc->image.data.bo, flags);
|
||||
|
||||
if (rsrc->checksum_bo)
|
||||
panfrost_batch_add_bo(batch, rsrc->checksum_bo, flags);
|
||||
if (rsrc->image.crc.bo)
|
||||
panfrost_batch_add_bo(batch, rsrc->image.crc.bo, flags);
|
||||
|
||||
if (rsrc->separate_stencil)
|
||||
panfrost_batch_add_bo(batch, rsrc->separate_stencil->image.data.bo, flags);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ panfrost_mfbd_has_zs_crc_ext(struct panfrost_batch *batch)
|
|||
if (batch->key.nr_cbufs == 1) {
|
||||
struct pipe_surface *surf = batch->key.cbufs[0];
|
||||
|
||||
if (surf->texture && pan_resource(surf->texture)->checksummed)
|
||||
if (surf->texture &&
|
||||
pan_resource(surf->texture)->image.layout.crc_mode != PAN_IMAGE_CRC_NONE)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -255,15 +256,16 @@ panfrost_mfbd_zs_crc_ext_set_bufs(struct panfrost_batch *batch,
|
|||
struct pipe_surface *c_surf = batch->key.cbufs[0];
|
||||
struct panfrost_resource *rsrc = pan_resource(c_surf->texture);
|
||||
|
||||
if (rsrc->checksummed) {
|
||||
if (rsrc->image.layout.crc_mode != PAN_IMAGE_CRC_NONE) {
|
||||
unsigned level = c_surf->u.tex.level;
|
||||
struct pan_image_slice_layout *slice = &rsrc->image.layout.slices[level];
|
||||
|
||||
*checksum_slice = &rsrc->state.slices[level];
|
||||
|
||||
ext->crc_row_stride = slice->crc.stride;
|
||||
if (rsrc->checksum_bo) {
|
||||
ext->crc_base = rsrc->checksum_bo->ptr.gpu;
|
||||
if (rsrc->image.layout.crc_mode == PAN_IMAGE_CRC_OOB) {
|
||||
ext->crc_base = rsrc->image.crc.bo->ptr.gpu +
|
||||
slice->crc.offset;
|
||||
} else {
|
||||
ext->crc_base = rsrc->image.data.bo->ptr.gpu +
|
||||
slice->crc.offset;
|
||||
|
|
|
|||
|
|
@ -112,8 +112,8 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
|
|||
panfrost_compute_checksum_size(&rsc->image.layout.slices[0],
|
||||
templat->width0,
|
||||
templat->height0);
|
||||
rsc->checksum_bo = panfrost_bo_create(dev, size, 0);
|
||||
rsc->checksummed = true;
|
||||
rsc->image.crc.bo = panfrost_bo_create(dev, size, 0);
|
||||
rsc->image.layout.crc_mode = PAN_IMAGE_CRC_OOB;
|
||||
}
|
||||
|
||||
/* If we import an AFBC resource, it should be in a format that's
|
||||
|
|
@ -379,6 +379,7 @@ panfrost_setup_layout(struct panfrost_device *dev,
|
|||
bool should_align = renderable || tiled || afbc;
|
||||
bool is_3d = res->target == PIPE_TEXTURE_3D;
|
||||
|
||||
unsigned oob_crc_offset = 0;
|
||||
unsigned offset = 0;
|
||||
unsigned tile_h = 1, tile_w = 1, tile_shift = 0;
|
||||
|
||||
|
|
@ -464,13 +465,17 @@ panfrost_setup_layout(struct panfrost_device *dev,
|
|||
offset += slice_full_size;
|
||||
|
||||
/* Add a checksum region if necessary */
|
||||
if (pres->checksummed) {
|
||||
slice->crc.offset = offset;
|
||||
|
||||
if (pres->image.layout.crc_mode != PAN_IMAGE_CRC_NONE) {
|
||||
unsigned size = panfrost_compute_checksum_size(
|
||||
slice, width, height);
|
||||
|
||||
offset += size;
|
||||
if (pres->image.layout.crc_mode == PAN_IMAGE_CRC_INBAND) {
|
||||
slice->crc.offset = offset;
|
||||
offset += size;
|
||||
} else {
|
||||
slice->crc.offset = oob_crc_offset;
|
||||
oob_crc_offset += size;
|
||||
}
|
||||
}
|
||||
|
||||
width = u_minify(width, 1);
|
||||
|
|
@ -484,6 +489,7 @@ panfrost_setup_layout(struct panfrost_device *dev,
|
|||
pres->image.layout.array_stride = ALIGN_POT(offset, 64);
|
||||
pres->image.layout.data_size =
|
||||
ALIGN_POT(pres->image.layout.array_stride * res->array_size, 4096);
|
||||
pres->image.layout.crc_size = oob_crc_offset;
|
||||
if (bo_size)
|
||||
*bo_size = pres->image.layout.data_size;
|
||||
}
|
||||
|
|
@ -639,7 +645,8 @@ panfrost_resource_setup(struct panfrost_device *dev, struct panfrost_resource *p
|
|||
{
|
||||
pres->image.layout.modifier = (modifier != DRM_FORMAT_MOD_INVALID) ? modifier :
|
||||
panfrost_best_modifier(dev, pres);
|
||||
pres->checksummed = panfrost_should_checksum(dev, pres);
|
||||
pres->image.layout.crc_mode = panfrost_should_checksum(dev, pres) ?
|
||||
PAN_IMAGE_CRC_INBAND : PAN_IMAGE_CRC_NONE;
|
||||
|
||||
/* We can only switch tiled->linear if the resource isn't already
|
||||
* linear and if we control the modifier */
|
||||
|
|
@ -805,8 +812,8 @@ panfrost_resource_destroy(struct pipe_screen *screen,
|
|||
if (rsrc->image.data.bo)
|
||||
panfrost_bo_unreference(rsrc->image.data.bo);
|
||||
|
||||
if (rsrc->checksum_bo)
|
||||
panfrost_bo_unreference(rsrc->checksum_bo);
|
||||
if (rsrc->image.crc.bo)
|
||||
panfrost_bo_unreference(rsrc->image.crc.bo);
|
||||
|
||||
util_range_destroy(&rsrc->valid_buffer_range);
|
||||
ralloc_free(rsrc);
|
||||
|
|
@ -1133,8 +1140,8 @@ pan_resource_modifier_convert(struct panfrost_context *ctx,
|
|||
}
|
||||
|
||||
panfrost_bo_unreference(rsrc->image.data.bo);
|
||||
if (rsrc->checksum_bo)
|
||||
panfrost_bo_unreference(rsrc->checksum_bo);
|
||||
if (rsrc->image.crc.bo)
|
||||
panfrost_bo_unreference(rsrc->image.crc.bo);
|
||||
|
||||
rsrc->image.data.bo = tmp_rsrc->image.data.bo;
|
||||
panfrost_bo_reference(rsrc->image.data.bo);
|
||||
|
|
@ -1198,8 +1205,8 @@ panfrost_ptr_unmap(struct pipe_context *pctx,
|
|||
if (panfrost_should_linear_convert(prsrc, transfer)) {
|
||||
|
||||
panfrost_bo_unreference(prsrc->image.data.bo);
|
||||
if (prsrc->checksum_bo)
|
||||
panfrost_bo_unreference(prsrc->checksum_bo);
|
||||
if (prsrc->image.crc.bo)
|
||||
panfrost_bo_unreference(prsrc->image.crc.bo);
|
||||
|
||||
panfrost_resource_setup(dev, prsrc, NULL, DRM_FORMAT_MOD_LINEAR);
|
||||
|
||||
|
|
|
|||
|
|
@ -60,12 +60,6 @@ struct panfrost_resource {
|
|||
/* Whether the modifier can be changed */
|
||||
bool modifier_constant;
|
||||
|
||||
/* Is transaction elimination enabled? */
|
||||
bool checksummed;
|
||||
|
||||
/* The CRC BO can be allocated separately */
|
||||
struct panfrost_bo *checksum_bo;
|
||||
|
||||
/* Used to decide when to convert to another modifier */
|
||||
uint16_t modifier_updates;
|
||||
|
||||
|
|
|
|||
|
|
@ -223,16 +223,22 @@ panfrost_sfbd_fragment(struct panfrost_batch *batch, bool has_draws)
|
|||
if (batch->key.nr_cbufs && batch->key.cbufs[0]) {
|
||||
struct pipe_surface *surf = batch->key.cbufs[0];
|
||||
struct panfrost_resource *rsrc = pan_resource(surf->texture);
|
||||
struct panfrost_bo *bo = rsrc->image.data.bo;
|
||||
|
||||
panfrost_sfbd_set_cbuf(¶ms, surf);
|
||||
|
||||
if (rsrc->checksummed) {
|
||||
if (rsrc->image.layout.crc_mode != PAN_IMAGE_CRC_NONE) {
|
||||
unsigned level = surf->u.tex.level;
|
||||
struct pan_image_slice_layout *slice = &rsrc->image.layout.slices[level];
|
||||
|
||||
if (rsrc->image.layout.crc_mode == PAN_IMAGE_CRC_INBAND) {
|
||||
params.crc_buffer.base = rsrc->image.data.bo->ptr.gpu +
|
||||
rsrc->image.data.offset +
|
||||
slice->crc.offset;
|
||||
} else {
|
||||
params.crc_buffer.base = rsrc->image.crc.bo->ptr.gpu +
|
||||
slice->crc.offset;
|
||||
}
|
||||
params.crc_buffer.row_stride = slice->crc.stride;
|
||||
params.crc_buffer.base = bo->ptr.gpu + slice->crc.offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,12 @@ struct pan_image_slice_layout {
|
|||
} crc;
|
||||
};
|
||||
|
||||
enum pan_image_crc_mode {
|
||||
PAN_IMAGE_CRC_NONE,
|
||||
PAN_IMAGE_CRC_INBAND,
|
||||
PAN_IMAGE_CRC_OOB,
|
||||
};
|
||||
|
||||
struct pan_image_layout {
|
||||
uint64_t modifier;
|
||||
enum pipe_format format;
|
||||
|
|
@ -82,6 +88,11 @@ struct pan_image_layout {
|
|||
unsigned array_size;
|
||||
unsigned array_stride;
|
||||
unsigned data_size;
|
||||
|
||||
enum pan_image_crc_mode crc_mode;
|
||||
/* crc_size != 0 only if crc_mode == OOB otherwise CRC words are
|
||||
* counted in data_size */
|
||||
unsigned crc_size;
|
||||
};
|
||||
|
||||
struct pan_image_slice_state {
|
||||
|
|
@ -103,6 +114,7 @@ struct pan_image_mem {
|
|||
|
||||
struct pan_image {
|
||||
struct pan_image_mem data;
|
||||
struct pan_image_mem crc;
|
||||
struct pan_image_layout layout;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue