mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
panfrost: Remove pan_image_state
Instead just group the fields about validity into a simpler structure in panfrost_resource. Panvk can do the same. Common code shouldn't be thinking in terms of this 'larger' structure anyway. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11123>
This commit is contained in:
parent
6f0e1c27d9
commit
a9a8d74d1f
5 changed files with 31 additions and 35 deletions
|
|
@ -1544,7 +1544,7 @@ emit_image_bufs(struct panfrost_batch *batch, enum pipe_shader_type shader,
|
|||
if (image->shader_access & PIPE_IMAGE_ACCESS_WRITE) {
|
||||
flags |= PAN_BO_ACCESS_WRITE;
|
||||
unsigned level = is_buffer ? 0 : image->u.tex.level;
|
||||
BITSET_SET(rsrc->state.data_valid, level);
|
||||
BITSET_SET(rsrc->valid.data, level);
|
||||
}
|
||||
panfrost_batch_add_bo(batch, rsrc->image.data.bo, flags);
|
||||
|
||||
|
|
@ -2427,7 +2427,7 @@ panfrost_initialize_surface(struct panfrost_batch *batch,
|
|||
{
|
||||
if (surf) {
|
||||
struct panfrost_resource *rsrc = pan_resource(surf->texture);
|
||||
BITSET_SET(rsrc->state.data_valid, surf->u.tex.level);
|
||||
BITSET_SET(rsrc->valid.data, surf->u.tex.level);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -657,24 +657,24 @@ panfrost_batch_to_fb_info(const struct panfrost_batch *batch,
|
|||
rts[i].image = &prsrc->image;
|
||||
rts[i].nr_samples = surf->nr_samples ? : MAX2(surf->texture->nr_samples, 1);
|
||||
memcpy(rts[i].swizzle, id_swz, sizeof(rts[i].swizzle));
|
||||
fb->rts[i].crc_valid = &prsrc->state.crc_valid;
|
||||
fb->rts[i].crc_valid = &prsrc->valid.crc;
|
||||
fb->rts[i].view = &rts[i];
|
||||
|
||||
/* Preload if the RT is read or updated */
|
||||
if (!(batch->clear & mask) &&
|
||||
((batch->read & mask) ||
|
||||
((batch->draws & mask) &&
|
||||
BITSET_TEST(prsrc->state.data_valid, fb->rts[i].view->first_level))))
|
||||
BITSET_TEST(prsrc->valid.data, fb->rts[i].view->first_level))))
|
||||
fb->rts[i].preload = true;
|
||||
|
||||
}
|
||||
|
||||
const struct pan_image_view *s_view = NULL, *z_view = NULL;
|
||||
const struct pan_image_state *s_state = NULL, *z_state = NULL;
|
||||
struct panfrost_resource *z_rsrc = NULL, *s_rsrc = NULL;
|
||||
|
||||
if (batch->key.zsbuf) {
|
||||
struct pipe_surface *surf = batch->key.zsbuf;
|
||||
struct panfrost_resource *prsrc = pan_resource(surf->texture);
|
||||
z_rsrc = pan_resource(surf->texture);
|
||||
|
||||
zs->format = surf->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT ?
|
||||
PIPE_FORMAT_Z32_FLOAT : surf->format;
|
||||
|
|
@ -682,29 +682,28 @@ panfrost_batch_to_fb_info(const struct panfrost_batch *batch,
|
|||
zs->last_level = zs->first_level = surf->u.tex.level;
|
||||
zs->first_layer = surf->u.tex.first_layer;
|
||||
zs->last_layer = surf->u.tex.last_layer;
|
||||
zs->image = &prsrc->image;
|
||||
zs->image = &z_rsrc->image;
|
||||
zs->nr_samples = surf->nr_samples ? : MAX2(surf->texture->nr_samples, 1);
|
||||
memcpy(zs->swizzle, id_swz, sizeof(zs->swizzle));
|
||||
fb->zs.view.zs = zs;
|
||||
z_view = zs;
|
||||
z_state = &prsrc->state;
|
||||
if (util_format_is_depth_and_stencil(zs->format)) {
|
||||
s_view = zs;
|
||||
s_state = &prsrc->state;
|
||||
s_rsrc = z_rsrc;
|
||||
}
|
||||
|
||||
if (prsrc->separate_stencil) {
|
||||
if (z_rsrc->separate_stencil) {
|
||||
s_rsrc = z_rsrc->separate_stencil;
|
||||
s->format = PIPE_FORMAT_S8_UINT;
|
||||
s->dim = MALI_TEXTURE_DIMENSION_2D;
|
||||
s->last_level = s->first_level = surf->u.tex.level;
|
||||
s->first_layer = surf->u.tex.first_layer;
|
||||
s->last_layer = surf->u.tex.last_layer;
|
||||
s->image = &prsrc->separate_stencil->image;
|
||||
s->image = &s_rsrc->image;
|
||||
s->nr_samples = surf->nr_samples ? : MAX2(surf->texture->nr_samples, 1);
|
||||
memcpy(s->swizzle, id_swz, sizeof(s->swizzle));
|
||||
fb->zs.view.s = s;
|
||||
s_view = s;
|
||||
s_state = &prsrc->separate_stencil->state;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -724,20 +723,20 @@ panfrost_batch_to_fb_info(const struct panfrost_batch *batch,
|
|||
if (!fb->zs.clear.z &&
|
||||
((batch->read & PIPE_CLEAR_DEPTH) ||
|
||||
((batch->draws & PIPE_CLEAR_DEPTH) &&
|
||||
BITSET_TEST(z_state->data_valid, z_view->first_level))))
|
||||
z_rsrc && BITSET_TEST(z_rsrc->valid.data, z_view->first_level))))
|
||||
fb->zs.preload.z = true;
|
||||
|
||||
if (!fb->zs.clear.s &&
|
||||
((batch->read & PIPE_CLEAR_STENCIL) ||
|
||||
((batch->draws & PIPE_CLEAR_STENCIL) &&
|
||||
BITSET_TEST(s_state->data_valid, s_view->first_level))))
|
||||
s_rsrc && BITSET_TEST(s_rsrc->valid.data, s_view->first_level))))
|
||||
fb->zs.preload.s = true;
|
||||
|
||||
/* Preserve both component if we have a combined ZS view and
|
||||
* one component needs to be preserved.
|
||||
*/
|
||||
if (s_view == z_view && fb->zs.discard.z != fb->zs.discard.s) {
|
||||
bool valid = BITSET_TEST(z_state->data_valid, z_view->first_level);
|
||||
bool valid = BITSET_TEST(z_rsrc->valid.data, z_view->first_level);
|
||||
|
||||
fb->zs.discard.z = false;
|
||||
fb->zs.discard.s = false;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
|
|||
|
||||
rsc->modifier_constant = true;
|
||||
|
||||
BITSET_SET(rsc->state.data_valid, 0);
|
||||
BITSET_SET(rsc->valid.data, 0);
|
||||
panfrost_resource_set_damage_region(pscreen, &rsc->base, 0, NULL);
|
||||
|
||||
if (dev->ro) {
|
||||
|
|
@ -845,7 +845,7 @@ panfrost_ptr_map(struct pipe_context *pctx,
|
|||
* from a pending batch XXX */
|
||||
panfrost_flush_batches_accessing_bo(ctx, rsrc->image.data.bo, true);
|
||||
|
||||
if ((usage & PIPE_MAP_READ) && BITSET_TEST(rsrc->state.data_valid, level)) {
|
||||
if ((usage & PIPE_MAP_READ) && BITSET_TEST(rsrc->valid.data, level)) {
|
||||
pan_blit_to_staging(pctx, transfer);
|
||||
panfrost_flush_batches_accessing_bo(ctx, staging->image.data.bo, true);
|
||||
panfrost_bo_wait(staging->image.data.bo, INT64_MAX, false);
|
||||
|
|
@ -943,7 +943,7 @@ panfrost_ptr_map(struct pipe_context *pctx,
|
|||
transfer->map = ralloc_size(transfer, transfer->base.layer_stride * box->depth);
|
||||
assert(box->depth == 1);
|
||||
|
||||
if ((usage & PIPE_MAP_READ) && BITSET_TEST(rsrc->state.data_valid, level)) {
|
||||
if ((usage & PIPE_MAP_READ) && BITSET_TEST(rsrc->valid.data, level)) {
|
||||
panfrost_load_tiled_image(
|
||||
transfer->map,
|
||||
bo->ptr.cpu + rsrc->image.layout.slices[level].offset,
|
||||
|
|
@ -974,7 +974,7 @@ panfrost_ptr_map(struct pipe_context *pctx,
|
|||
* initialized (maybe), so be conservative */
|
||||
|
||||
if (usage & PIPE_MAP_WRITE) {
|
||||
BITSET_SET(rsrc->state.data_valid, level);
|
||||
BITSET_SET(rsrc->valid.data, level);
|
||||
panfrost_minmax_cache_invalidate(rsrc->index_cache, &transfer->base);
|
||||
}
|
||||
|
||||
|
|
@ -1017,7 +1017,7 @@ pan_resource_modifier_convert(struct panfrost_context *ctx,
|
|||
};
|
||||
|
||||
for (int i = 0; i <= rsrc->base.last_level; i++) {
|
||||
if (BITSET_TEST(rsrc->state.data_valid, i)) {
|
||||
if (BITSET_TEST(rsrc->valid.data, i)) {
|
||||
blit.dst.level = blit.src.level = i;
|
||||
panfrost_blit(&ctx->base, &blit);
|
||||
}
|
||||
|
|
@ -1078,7 +1078,7 @@ panfrost_ptr_unmap(struct pipe_context *pctx,
|
|||
struct panfrost_device *dev = pan_device(pctx->screen);
|
||||
|
||||
if (transfer->usage & PIPE_MAP_WRITE)
|
||||
prsrc->state.crc_valid = false;
|
||||
prsrc->valid.crc = false;
|
||||
|
||||
/* AFBC will use a staging resource. `initialized` will be set when the
|
||||
* fragment job is created; this is deferred to prevent useless surface
|
||||
|
|
@ -1112,7 +1112,7 @@ panfrost_ptr_unmap(struct pipe_context *pctx,
|
|||
struct panfrost_bo *bo = prsrc->image.data.bo;
|
||||
|
||||
if (transfer->usage & PIPE_MAP_WRITE) {
|
||||
BITSET_SET(prsrc->state.data_valid, transfer->level);
|
||||
BITSET_SET(prsrc->valid.data, transfer->level);
|
||||
|
||||
if (prsrc->image.layout.modifier == DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED) {
|
||||
assert(transfer->box.depth == 1);
|
||||
|
|
@ -1178,7 +1178,7 @@ panfrost_ptr_flush_region(struct pipe_context *pctx,
|
|||
transfer->box.x + box->x,
|
||||
transfer->box.x + box->x + box->width);
|
||||
} else {
|
||||
BITSET_SET(rsc->state.data_valid, transfer->level);
|
||||
BITSET_SET(rsc->valid.data, transfer->level);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1225,7 +1225,7 @@ panfrost_generate_mipmap(
|
|||
|
||||
assert(rsrc->image.data.bo);
|
||||
for (unsigned l = base_level + 1; l <= last_level; ++l)
|
||||
BITSET_CLEAR(rsrc->state.data_valid, l);
|
||||
BITSET_CLEAR(rsrc->valid.data, l);
|
||||
|
||||
/* Beyond that, we just delegate the hard stuff. */
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,14 @@ struct panfrost_resource {
|
|||
/* Description of the resource layout */
|
||||
struct pan_image image;
|
||||
|
||||
/* Image state */
|
||||
struct pan_image_state state;
|
||||
struct {
|
||||
/* Is the checksum for this image valid? Implicitly refers to
|
||||
* the first slice; we only checksum non-mipmapped 2D images */
|
||||
bool crc;
|
||||
|
||||
/* Has anything been written to this slice? */
|
||||
BITSET_DECLARE(data, MAX_MIP_LEVELS);
|
||||
} valid;
|
||||
|
||||
/* Whether the modifier can be changed */
|
||||
bool modifier_constant;
|
||||
|
|
|
|||
|
|
@ -99,15 +99,6 @@ struct pan_image_layout {
|
|||
unsigned crc_size;
|
||||
};
|
||||
|
||||
struct pan_image_state {
|
||||
/* Is the checksum for this image valid? Implicitly refers to the first
|
||||
* slice, as we only checksum non-mipmapped 2D images */
|
||||
bool crc_valid;
|
||||
|
||||
/* Has anything been written to this slice? */
|
||||
BITSET_DECLARE(data_valid, MAX_MIP_LEVELS);
|
||||
};
|
||||
|
||||
struct pan_image_mem {
|
||||
struct panfrost_bo *bo;
|
||||
unsigned offset;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue