Mesa (main): iris: Use a num_buckets pointer in add_bucket
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Dec 14 07:54:54 UTC 2021
Module: Mesa
Branch: main
Commit: 7a8bf62ac83e50e9da7a24ae474bcf5c7b2f43d0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7a8bf62ac83e50e9da7a24ae474bcf5c7b2f43d0
Author: Nanley Chery <nanley.g.chery at intel.com>
Date: Wed Dec 1 13:45:05 2021 -0500
iris: Use a num_buckets pointer in add_bucket
Store a pointer to the appropriate cache bucket counter, then increment
the integer it points to. This keeps us from having to add code for
incrementing when a new cache bucket is added.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14012>
---
src/gallium/drivers/iris/iris_bufmgr.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index 71d09fd9afd..30ff727a7f1 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -1993,22 +1993,18 @@ iris_bo_export_gem_handle_for_device(struct iris_bo *bo, int drm_fd,
static void
add_bucket(struct iris_bufmgr *bufmgr, int size, bool local)
{
- unsigned int i = local ?
- bufmgr->num_local_buckets : bufmgr->num_buckets;
+ int *num_buckets = local ?
+ &bufmgr->num_local_buckets : &bufmgr->num_buckets;
struct bo_cache_bucket *buckets = local ?
bufmgr->local_cache_bucket : bufmgr->cache_bucket;
+ unsigned int i = (*num_buckets)++;
assert(i < ARRAY_SIZE(bufmgr->cache_bucket));
list_inithead(&buckets[i].head);
buckets[i].size = size;
- if (local)
- bufmgr->num_local_buckets++;
- else
- bufmgr->num_buckets++;
-
assert(bucket_for_size(bufmgr, size, local) == &buckets[i]);
assert(bucket_for_size(bufmgr, size - 2048, local) == &buckets[i]);
assert(bucket_for_size(bufmgr, size + 1, local) != &buckets[i]);
More information about the mesa-commit
mailing list