Mesa (master): panfrost: Compact the bo_access readers array
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Jan 18 14:16:30 UTC 2020
Module: Mesa
Branch: master
Commit: 5e8386c606293de4f9cbbc2666a9e9e3758b6b29
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5e8386c606293de4f9cbbc2666a9e9e3758b6b29
Author: Icecream95 <ixn at keemail.me>
Date: Thu Jan 16 09:51:17 2020 +1300
panfrost: Compact the bo_access readers array
Previously, the array bo_access->readers was only cleared when there
were no unsignaled fences, which in some situations never happened.
That resulted in the array having thousands of NULL pointers, but only
a handful of active readers.
With this patch, all the unsignaled readers are moved to the front of
the array, effectively building a new array only containing the active
readers in-place. This results in the readers array usually only having
a couple of elements.
Reviewed-by: Boris Brezillon <boris.brezillon at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3419>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3419>
---
src/gallium/drivers/panfrost/pan_job.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index 1b7d370b998..8ec00022999 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -346,7 +346,9 @@ panfrost_bo_access_gc_fences(struct panfrost_context *ctx,
access->writer = NULL;
}
- unsigned nreaders = 0;
+ struct panfrost_batch_fence **readers_array = util_dynarray_begin(&access->readers);
+ struct panfrost_batch_fence **new_readers = readers_array;
+
util_dynarray_foreach(&access->readers, struct panfrost_batch_fence *,
reader) {
if (!(*reader))
@@ -356,12 +358,15 @@ panfrost_bo_access_gc_fences(struct panfrost_context *ctx,
panfrost_batch_fence_unreference(*reader);
*reader = NULL;
} else {
- nreaders++;
+ /* Build a new array of only unsignaled fences in-place */
+ *(new_readers++) = *reader;
}
}
- if (!nreaders)
- util_dynarray_clear(&access->readers);
+ if (!util_dynarray_resize(&access->readers, struct panfrost_batch_fence *,
+ new_readers - readers_array) &&
+ new_readers != readers_array)
+ unreachable("Invalid dynarray access->readers");
}
/* Collect signaled fences to keep the kernel-side syncobj-map small. The
More information about the mesa-commit
mailing list