sna: Trim color cache allocation to a single page
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 7 Oct 2013 21:04:22 +0000 (22:04 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 7 Oct 2013 21:06:32 +0000 (22:06 +0100)
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>
src/sna/sna_gradient.c
src/sna/sna_render.h

index 26e4167..818a8b7 100644 (file)
@@ -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;
index ad8121e..7f4b8e6 100644 (file)
@@ -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;