panfrost: Split out image access tracking

This logic is not device-specific. It is pulled from our existing Bifrost image
implementation and will be reused for Valhall.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15795>
This commit is contained in:
Alyssa Rosenzweig 2022-04-07 10:41:45 -04:00 committed by Marge Bot
parent 5d187e9cad
commit 0510e2373e
2 changed files with 29 additions and 0 deletions

View File

@ -424,4 +424,9 @@ panfrost_set_batch_masks_blend(struct panfrost_batch *batch);
void
panfrost_set_batch_masks_zs(struct panfrost_batch *batch);
void
panfrost_track_image_access(struct panfrost_batch *batch,
enum pipe_shader_type stage,
struct pipe_image_view *image);
#endif

View File

@ -219,3 +219,27 @@ panfrost_set_batch_masks_zs(struct panfrost_batch *batch)
batch->read |= PIPE_CLEAR_STENCIL;
}
}
void
panfrost_track_image_access(struct panfrost_batch *batch,
enum pipe_shader_type stage,
struct pipe_image_view *image)
{
struct panfrost_resource *rsrc = pan_resource(image->resource);
if (image->shader_access & PIPE_IMAGE_ACCESS_WRITE) {
panfrost_batch_write_rsrc(batch, rsrc, stage);
bool is_buffer = rsrc->base.target == PIPE_BUFFER;
unsigned level = is_buffer ? 0 : image->u.tex.level;
BITSET_SET(rsrc->valid.data, level);
if (is_buffer) {
util_range_add(&rsrc->base, &rsrc->valid_buffer_range,
0, rsrc->base.width0);
}
} else {
panfrost_batch_read_rsrc(batch, rsrc, stage);
}
}