mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 02:48:06 +02:00
panfrost: Cache number of users of a resource
This can be tracked efficiently with atomics, and reduces the places we
use the rsrc->track.users bitmap which has concurrency issues.
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12528>
(cherry picked from commit b8da5b1b7f)
This commit is contained in:
parent
2987bf8761
commit
ca3c31add8
4 changed files with 12 additions and 3 deletions
|
|
@ -1183,7 +1183,7 @@
|
||||||
"description": "panfrost: Cache number of users of a resource",
|
"description": "panfrost: Cache number of users of a resource",
|
||||||
"nominated": true,
|
"nominated": true,
|
||||||
"nomination_type": 0,
|
"nomination_type": 0,
|
||||||
"resolution": 0,
|
"resolution": 1,
|
||||||
"main_sha": null,
|
"main_sha": null,
|
||||||
"because_sha": null
|
"because_sha": null
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,8 @@ panfrost_batch_cleanup(struct panfrost_batch *batch)
|
||||||
if (rsrc->track.writer == batch)
|
if (rsrc->track.writer == batch)
|
||||||
rsrc->track.writer = NULL;
|
rsrc->track.writer = NULL;
|
||||||
|
|
||||||
|
rsrc->track.nr_users--;
|
||||||
|
|
||||||
pipe_resource_reference((struct pipe_resource **) &rsrc, NULL);
|
pipe_resource_reference((struct pipe_resource **) &rsrc, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -272,6 +274,9 @@ panfrost_batch_update_access(struct panfrost_batch *batch,
|
||||||
if (!found) {
|
if (!found) {
|
||||||
BITSET_SET(rsrc->track.users, batch_idx);
|
BITSET_SET(rsrc->track.users, batch_idx);
|
||||||
|
|
||||||
|
/* Cache number of batches accessing a resource */
|
||||||
|
rsrc->track.nr_users++;
|
||||||
|
|
||||||
/* Reference the resource on the batch */
|
/* Reference the resource on the batch */
|
||||||
pipe_reference(NULL, &rsrc->base.reference);
|
pipe_reference(NULL, &rsrc->base.reference);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -894,7 +894,7 @@ panfrost_ptr_map(struct pipe_context *pctx,
|
||||||
(usage & PIPE_MAP_WRITE) &&
|
(usage & PIPE_MAP_WRITE) &&
|
||||||
!(resource->target == PIPE_BUFFER
|
!(resource->target == PIPE_BUFFER
|
||||||
&& !util_ranges_intersect(&rsrc->valid_buffer_range, box->x, box->x + box->width)) &&
|
&& !util_ranges_intersect(&rsrc->valid_buffer_range, box->x, box->x + box->width)) &&
|
||||||
BITSET_COUNT(rsrc->track.users) != 0) {
|
rsrc->track.nr_users > 0) {
|
||||||
|
|
||||||
/* When a resource to be modified is already being used by a
|
/* When a resource to be modified is already being used by a
|
||||||
* pending batch, it is often faster to copy the whole BO than
|
* pending batch, it is often faster to copy the whole BO than
|
||||||
|
|
@ -913,7 +913,7 @@ panfrost_ptr_map(struct pipe_context *pctx,
|
||||||
* not ready yet (still accessed by one of the already flushed
|
* not ready yet (still accessed by one of the already flushed
|
||||||
* batches), we try to allocate a new one to avoid waiting.
|
* batches), we try to allocate a new one to avoid waiting.
|
||||||
*/
|
*/
|
||||||
if (BITSET_COUNT(rsrc->track.users) ||
|
if (rsrc->track.nr_users > 0 ||
|
||||||
!panfrost_bo_wait(bo, 0, true)) {
|
!panfrost_bo_wait(bo, 0, true)) {
|
||||||
/* We want the BO to be MMAPed. */
|
/* We want the BO to be MMAPed. */
|
||||||
uint32_t flags = bo->flags & ~PAN_BO_DELAY_MMAP;
|
uint32_t flags = bo->flags & ~PAN_BO_DELAY_MMAP;
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,10 @@ struct panfrost_resource {
|
||||||
struct {
|
struct {
|
||||||
struct panfrost_batch *writer;
|
struct panfrost_batch *writer;
|
||||||
BITSET_DECLARE(users, PAN_MAX_BATCHES);
|
BITSET_DECLARE(users, PAN_MAX_BATCHES);
|
||||||
|
|
||||||
|
/** Number of batches accessing this resource. Used to check if
|
||||||
|
* a resource is in use. */
|
||||||
|
_Atomic unsigned nr_users;
|
||||||
} track;
|
} track;
|
||||||
|
|
||||||
struct renderonly_scanout *scanout;
|
struct renderonly_scanout *scanout;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue