[Mesa-dev] [PATCH 2/4] i965/drm: Round down buffer size and calculate the bucket index
James Xiong
james.xiong at intel.com
Sat May 5 00:56:03 UTC 2018
From: "Xiong, James" <james.xiong at intel.com>
a buffer is now put in cached bucket #n when its size is between
bucket[n].size and bucket[n+1].size - 1
Signed-off-by: Xiong, James <james.xiong at intel.com>
---
src/mesa/drivers/dri/i965/brw_bufmgr.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index e68da26..6a9b005 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -189,8 +189,8 @@ bo_tile_pitch(struct brw_bufmgr *bufmgr, uint32_t pitch, uint32_t tiling)
static struct bo_cache_bucket *
bucket_for_size(struct brw_bufmgr *bufmgr, uint64_t size)
{
- /* Calculating the pages and rounding up to the page size. */
- const unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
+ /* Calculating the pages and rounding down to the page size. */
+ const unsigned pages = (size < PAGE_SIZE) ? 1 : size / PAGE_SIZE;
/* Row Bucket sizes clz((x-1) | 3) Row Column
* in pages stride size
@@ -211,8 +211,7 @@ bucket_for_size(struct brw_bufmgr *bufmgr, uint64_t size)
int col_size_log2 = row - 1;
col_size_log2 += (col_size_log2 < 0);
- const unsigned col = (pages - prev_row_max_pages +
- ((1 << col_size_log2) - 1)) >> col_size_log2;
+ const unsigned col = (pages - prev_row_max_pages) >> col_size_log2;
/* Calculating the index based on the row and column. */
const unsigned index = (row * 4) + (col - 1);
@@ -1285,9 +1284,9 @@ add_bucket(struct brw_bufmgr *bufmgr, int size)
bufmgr->cache_bucket[i].size = size;
bufmgr->num_buckets++;
+ assert(bucket_for_size(bufmgr, size - 1) == &bufmgr->cache_bucket[i==0?0:i-1]);
assert(bucket_for_size(bufmgr, size) == &bufmgr->cache_bucket[i]);
- assert(bucket_for_size(bufmgr, size - 2048) == &bufmgr->cache_bucket[i]);
- assert(bucket_for_size(bufmgr, size + 1) != &bufmgr->cache_bucket[i]);
+ assert(bucket_for_size(bufmgr, size + 1) == &bufmgr->cache_bucket[i]);
}
static void
--
2.7.4
More information about the mesa-dev
mailing list