X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Futil%2Fvma.c;h=dddc3fe187cd6faad05f3171f0a6d5b4533ef32a;hb=ca719c6e303966e8acf8a5d7d094e0075e36f6a0;hp=f17ec0c08f1211e46a3220138247a19e678a558e;hpb=adbcef37d2d1f838ef24a4ab1f4332cc87b5fdad;p=mesa.git diff --git a/src/util/vma.c b/src/util/vma.c index f17ec0c08f1..dddc3fe187c 100644 --- a/src/util/vma.c +++ b/src/util/vma.c @@ -22,6 +22,7 @@ */ #include +#include #include "util/u_math.h" #include "util/vma.h" @@ -304,3 +305,22 @@ util_vma_heap_free(struct util_vma_heap *heap, util_vma_heap_validate(heap); } + +void +util_vma_heap_print(struct util_vma_heap *heap, FILE *fp, + const char *tab, uint64_t total_size) +{ + fprintf(fp, "%sutil_vma_heap:\n", tab); + + uint64_t total_free = 0; + util_vma_foreach_hole(hole, heap) { + fprintf(fp, "%s hole: offset = %"PRIu64" (0x%"PRIx64", " + "size = %"PRIu64" (0x%"PRIx64")\n", + tab, hole->offset, hole->offset, hole->size, hole->size); + total_free += hole->size; + } + assert(total_free <= total_size); + fprintf(fp, "%s%"PRIu64"B (0x%"PRIx64") free (%.2f%% full)\n", + tab, total_free, total_free, + ((double)(total_size - total_free) / (double)total_size) * 100); +}