diff options
author | Boris Brezillon <[email protected]> | 2019-09-15 20:17:14 +0200 |
---|---|---|
committer | Boris Brezillon <[email protected]> | 2019-10-03 16:55:38 -0400 |
commit | 82399b58d3250d974cb6a74c3aa96f6f2fbafef0 (patch) | |
tree | f0ce2a6036158f0793c1d446fe8e9c581b764419 /src/gallium/drivers/panfrost/pan_job.c | |
parent | a45984b244e6825f52327e34d63755e170048709 (diff) |
panfrost: Add a panfrost_flush_batches_accessing_bo() helper
This will allow us to only flush batches touching a specific resource,
which is particularly useful when the CPU needs to access a BO.
Signed-off-by: Boris Brezillon <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium/drivers/panfrost/pan_job.c')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_job.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index 3ccf4bb6b3e..e7eae399830 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -953,6 +953,37 @@ panfrost_flush_all_batches(struct panfrost_context *ctx, bool wait) } void +panfrost_flush_batches_accessing_bo(struct panfrost_context *ctx, + struct panfrost_bo *bo, + uint32_t access_type) +{ + struct panfrost_bo_access *access; + struct hash_entry *hentry; + + /* It doesn't make any to flush only the readers. */ + assert(access_type == PAN_BO_ACCESS_WRITE || + access_type == PAN_BO_ACCESS_RW); + + hentry = _mesa_hash_table_search(ctx->accessed_bos, bo); + access = hentry ? hentry->data : NULL; + if (!access) + return; + + if (access_type & PAN_BO_ACCESS_WRITE && access->writer && + access->writer->batch) + panfrost_batch_submit(access->writer->batch); + + if (!(access_type & PAN_BO_ACCESS_READ)) + return; + + util_dynarray_foreach(&access->readers, struct panfrost_batch_fence *, + reader) { + if (*reader && (*reader)->batch) + panfrost_batch_submit((*reader)->batch); + } +} + +void panfrost_batch_set_requirements(struct panfrost_batch *batch) { struct panfrost_context *ctx = batch->ctx; |