panfrost: Make data_valid a bitset
More compact and will allow simpler code. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11123>
This commit is contained in:
committed by
Marge Bot
parent
77aff51090
commit
6f0e1c27d9
@@ -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;
|
||||
rsrc->state.slices[level].data_valid = true;
|
||||
BITSET_SET(rsrc->state.data_valid, level);
|
||||
}
|
||||
panfrost_batch_add_bo(batch, rsrc->image.data.bo, flags);
|
||||
|
||||
@@ -2425,13 +2425,10 @@ static void
|
||||
panfrost_initialize_surface(struct panfrost_batch *batch,
|
||||
struct pipe_surface *surf)
|
||||
{
|
||||
if (!surf)
|
||||
return;
|
||||
|
||||
unsigned level = surf->u.tex.level;
|
||||
struct panfrost_resource *rsrc = pan_resource(surf->texture);
|
||||
|
||||
rsrc->state.slices[level].data_valid = true;
|
||||
if (surf) {
|
||||
struct panfrost_resource *rsrc = pan_resource(surf->texture);
|
||||
BITSET_SET(rsrc->state.data_valid, surf->u.tex.level);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -664,7 +664,7 @@ panfrost_batch_to_fb_info(const struct panfrost_batch *batch,
|
||||
if (!(batch->clear & mask) &&
|
||||
((batch->read & mask) ||
|
||||
((batch->draws & mask) &&
|
||||
prsrc->state.slices[fb->rts[i].view->first_level].data_valid)))
|
||||
BITSET_TEST(prsrc->state.data_valid, fb->rts[i].view->first_level))))
|
||||
fb->rts[i].preload = true;
|
||||
|
||||
}
|
||||
@@ -724,20 +724,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) &&
|
||||
z_state->slices[z_view->first_level].data_valid)))
|
||||
BITSET_TEST(z_state->data_valid, z_view->first_level))))
|
||||
fb->zs.preload.z = true;
|
||||
|
||||
if (!fb->zs.clear.s &&
|
||||
((batch->read & PIPE_CLEAR_STENCIL) ||
|
||||
((batch->draws & PIPE_CLEAR_STENCIL) &&
|
||||
s_state->slices[s_view->first_level].data_valid)))
|
||||
BITSET_TEST(s_state->data_valid, 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 = z_state->slices[z_view->first_level].data_valid;
|
||||
bool valid = BITSET_TEST(z_state->data_valid, 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;
|
||||
|
||||
rsc->state.slices[0].data_valid = true;
|
||||
BITSET_SET(rsc->state.data_valid, 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) && rsrc->state.slices[level].data_valid) {
|
||||
if ((usage & PIPE_MAP_READ) && BITSET_TEST(rsrc->state.data_valid, 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) && rsrc->state.slices[level].data_valid) {
|
||||
if ((usage & PIPE_MAP_READ) && BITSET_TEST(rsrc->state.data_valid, 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) {
|
||||
rsrc->state.slices[level].data_valid = true;
|
||||
BITSET_SET(rsrc->state.data_valid, 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 (rsrc->state.slices[i].data_valid) {
|
||||
if (BITSET_TEST(rsrc->state.data_valid, i)) {
|
||||
blit.dst.level = blit.src.level = i;
|
||||
panfrost_blit(&ctx->base, &blit);
|
||||
}
|
||||
@@ -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) {
|
||||
prsrc->state.slices[transfer->level].data_valid = true;
|
||||
BITSET_SET(prsrc->state.data_valid, transfer->level);
|
||||
|
||||
if (prsrc->image.layout.modifier == DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED) {
|
||||
assert(transfer->box.depth == 1);
|
||||
@@ -1178,8 +1178,7 @@ panfrost_ptr_flush_region(struct pipe_context *pctx,
|
||||
transfer->box.x + box->x,
|
||||
transfer->box.x + box->x + box->width);
|
||||
} else {
|
||||
unsigned level = transfer->level;
|
||||
rsc->state.slices[level].data_valid = true;
|
||||
BITSET_SET(rsc->state.data_valid, transfer->level);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1226,7 +1225,7 @@ panfrost_generate_mipmap(
|
||||
|
||||
assert(rsrc->image.data.bo);
|
||||
for (unsigned l = base_level + 1; l <= last_level; ++l)
|
||||
rsrc->state.slices[l].data_valid = false;
|
||||
BITSET_CLEAR(rsrc->state.data_valid, l);
|
||||
|
||||
/* Beyond that, we just delegate the hard stuff. */
|
||||
|
||||
|
||||
@@ -99,17 +99,13 @@ struct pan_image_layout {
|
||||
unsigned crc_size;
|
||||
};
|
||||
|
||||
struct pan_image_slice_state {
|
||||
/* Has anything been written to this slice? */
|
||||
bool data_valid;
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
struct pan_image_slice_state slices[MAX_MIP_LEVELS];
|
||||
/* Has anything been written to this slice? */
|
||||
BITSET_DECLARE(data_valid, MAX_MIP_LEVELS);
|
||||
};
|
||||
|
||||
struct pan_image_mem {
|
||||
|
||||
Reference in New Issue
Block a user