Mesa (main): iris: Add and use BUCKET_ARRAY_SIZE

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 14 07:54:54 UTC 2021


Module: Mesa
Branch: main
Commit: cd787b4e68b0127d0d8cac3d8ecc17c199d74030
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd787b4e68b0127d0d8cac3d8ecc17c199d74030

Author: Nanley Chery <nanley.g.chery at intel.com>
Date:   Thu Dec  2 10:18:23 2021 -0500

iris: Add and use BUCKET_ARRAY_SIZE

This improves an assert in add_bucket.

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 | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index 21fd9379e3f..6bc04549ba3 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -183,6 +183,8 @@ struct iris_slab {
    struct iris_bo *entries;
 };
 
+#define BUCKET_ARRAY_SIZE (14 * 4)
+
 struct iris_bufmgr {
    /**
     * List into the list of bufmgr.
@@ -197,11 +199,11 @@ struct iris_bufmgr {
    simple_mtx_t bo_deps_lock;
 
    /** Array of lists of cached gem objects of power-of-two sizes */
-   struct bo_cache_bucket cache_bucket[14 * 4];
+   struct bo_cache_bucket cache_bucket[BUCKET_ARRAY_SIZE];
    int num_buckets;
 
    /** Same as cache_bucket, but for local memory gem objects */
-   struct bo_cache_bucket local_cache_bucket[14 * 4];
+   struct bo_cache_bucket local_cache_bucket[BUCKET_ARRAY_SIZE];
    int num_local_buckets;
 
    time_t time;
@@ -2002,7 +2004,7 @@ add_bucket(struct iris_bufmgr *bufmgr, int size, enum iris_heap heap)
       bufmgr->local_cache_bucket : bufmgr->cache_bucket;
 
    unsigned int i = (*num_buckets)++;
-   assert(i < ARRAY_SIZE(bufmgr->cache_bucket));
+   assert(i < BUCKET_ARRAY_SIZE);
 
    list_inithead(&buckets[i].head);
    buckets[i].size = size;



More information about the mesa-commit mailing list