diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-07 22:04:22 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-07 22:06:32 +0100 |
commit | 1fb4f60671cfb0e461a2e5969ee9d0f0e39d93a4 (patch) | |
tree | 01b40d493b98304854f980ff1a37a8167bc4ded5 /src | |
parent | 55cd67485ff34a28ab8eaa7b1b6958b96c072317 (diff) |
sna: Trim color cache allocation to a single page
Instead trying to allocate 4100 bytes, fix the logic to only require a
maximum of 4096 bytes in the cache buffer.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/sna_gradient.c | 9 | ||||
-rw-r--r-- | src/sna/sna_render.h | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/sna/sna_gradient.c b/src/sna/sna_gradient.c index 26e41675..818a8b79 100644 --- a/src/sna/sna_gradient.c +++ b/src/sna/sna_gradient.c @@ -246,8 +246,8 @@ sna_render_finish_solid(struct sna *sna, bool force) struct kgem_bo *old; int i; - DBG(("sna_render_finish_solid(force=%d, domain=%d, busy=%d, dirty=%d)\n", - force, cache->cache_bo->domain, cache->cache_bo->rq != NULL, cache->dirty)); + DBG(("sna_render_finish_solid(force=%d, domain=%d, busy=%d, dirty=%d, size=%d)\n", + force, cache->cache_bo->domain, cache->cache_bo->rq != NULL, cache->dirty, cache->size)); if (!force && cache->cache_bo->domain != DOMAIN_GPU) return; @@ -353,9 +353,10 @@ sna_render_get_solid(struct sna *sna, uint32_t color) } } - sna_render_finish_solid(sna, i == 1024); + sna_render_finish_solid(sna, i == ARRAY_SIZE(cache->color)); i = cache->size++; + assert(i < ARRAY_SIZE(cache->color)); cache->color[i] = color; cache->dirty = 1; DBG(("sna_render_get_solid(%d) = %x (new)\n", i, color)); @@ -429,7 +430,7 @@ static bool sna_solid_cache_init(struct sna *sna) if (!cache->cache_bo) return false; - cache->last = 1024; + cache->last = 0; cache->color[cache->last] = 0; cache->dirty = 0; cache->size = 0; diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index ad8121e0..7f4b8e66 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -287,7 +287,7 @@ struct sna_render { struct sna_solid_cache { struct kgem_bo *cache_bo; struct kgem_bo *bo[1024]; - uint32_t color[1025]; + uint32_t color[1024]; int last; int size; int dirty; |