pipebuffer: slab: if size < alignment, use alignment to find bucket
authorLuca Barbieri <luca@luca-barbieri.com>
Tue, 23 Feb 2010 16:55:24 +0000 (08:55 -0800)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 23 Feb 2010 19:50:24 +0000 (19:50 +0000)
If the size is lower than the alignment, we must use the alignment to
select the bucket.

Otherwise, the selected bucket won't be able to satisfy our request
and will fail.

Signed-off-by: José Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c

index c445cb578b09aeaa45affa9005cfff841c45509a..24e2820f881a44b0a27bfb2a8dca9ab033d901b4 100644 (file)
@@ -483,11 +483,15 @@ pb_slab_range_manager_create_buffer(struct pb_manager *_mgr,
 {
    struct pb_slab_range_manager *mgr = pb_slab_range_manager(_mgr);
    pb_size bufSize;
+   pb_size reqSize = size;
    unsigned i;
 
+   if(desc->alignment > reqSize)
+          reqSize = desc->alignment;
+
    bufSize = mgr->minBufSize;
    for (i = 0; i < mgr->numBuckets; ++i) {
-      if(bufSize >= size)
+      if(bufSize >= reqSize)
         return mgr->buckets[i]->create_buffer(mgr->buckets[i], size, desc);
       bufSize *= 2;
    }