[Mesa-dev] [PATCH 03/10] util: Make vma.c support non-power-of-two alignments.

Kenneth Graunke kenneth at whitecape.org
Fri May 4 01:12:33 UTC 2018


I want to use this in a bucketing allocator for i965.
---
 src/util/vma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/util/vma.c b/src/util/vma.c
index 3d61f6969ed..d6ee05988ef 100644
--- a/src/util/vma.c
+++ b/src/util/vma.c
@@ -88,7 +88,6 @@ util_vma_heap_alloc(struct util_vma_heap *heap,
    assert(size > 0);
 
    assert(alignment > 0);
-   assert(util_is_power_of_two_nonzero(alignment));
 
    util_vma_heap_validate(heap);
 
@@ -107,7 +106,7 @@ util_vma_heap_alloc(struct util_vma_heap *heap,
       /* Align the offset.  We align down and not up because we are allocating
        * from the top of the hole and not the bottom.
        */
-      offset &= ~(alignment - 1);
+      offset = (offset / alignment) * alignment;
 
       if (offset < hole->offset)
          continue;
-- 
2.17.0



More information about the mesa-dev mailing list