anv: Stop tracking VMA allocations
authorJason Ekstrand <jason@jlekstrand.net>
Mon, 2 Dec 2019 20:38:45 +0000 (14:38 -0600)
committerJason Ekstrand <jason@jlekstrand.net>
Thu, 5 Dec 2019 16:59:10 +0000 (10:59 -0600)
util_vma_heap_alloc will already return 0 if it doesn't have enough
space.  The only thing the vma_*_available tracking was doing was
preventing us from allocating too much on any given heap.  Now that
we're tracking that in the heap itself, we can drop these.

Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_private.h

index f1d18619274eb26c28484ac0d31aeb21db647390..c50d182aa323f4ef35a73bc1c2fc542945a2c258 100644 (file)
@@ -2557,13 +2557,12 @@ VkResult anv_CreateDevice(
       struct anv_memory_heap *low_heap =
          &physical_device->memory.heaps[physical_device->memory.heap_count - 1];
       util_vma_heap_init(&device->vma_lo, low_heap->vma_start, low_heap->vma_size);
-      device->vma_lo_available = low_heap->size;
 
       struct anv_memory_heap *high_heap =
          &physical_device->memory.heaps[0];
-      util_vma_heap_init(&device->vma_hi, high_heap->vma_start, high_heap->vma_size);
-      device->vma_hi_available = physical_device->memory.heap_count == 1 ? 0 :
-         high_heap->size;
+      uint64_t high_heap_size =
+         physical_device->memory.heap_count == 1 ? 0 : high_heap->size;
+      util_vma_heap_init(&device->vma_hi, high_heap->vma_start, high_heap_size);
    }
 
    list_inithead(&device->memory_objects);
@@ -3019,22 +3018,19 @@ anv_vma_alloc(struct anv_device *device, struct anv_bo *bo)
 
    bo->offset = 0;
 
-   if (bo->flags & EXEC_OBJECT_SUPPORTS_48B_ADDRESS &&
-       device->vma_hi_available >= bo->size) {
+   if (bo->flags & EXEC_OBJECT_SUPPORTS_48B_ADDRESS) {
       uint64_t addr = util_vma_heap_alloc(&device->vma_hi, bo->size, 4096);
       if (addr) {
          bo->offset = gen_canonical_address(addr);
          assert(addr == gen_48b_address(bo->offset));
-         device->vma_hi_available -= bo->size;
       }
    }
 
-   if (bo->offset == 0 && device->vma_lo_available >= bo->size) {
+   if (bo->offset == 0) {
       uint64_t addr = util_vma_heap_alloc(&device->vma_lo, bo->size, 4096);
       if (addr) {
          bo->offset = gen_canonical_address(addr);
          assert(addr == gen_48b_address(bo->offset));
-         device->vma_lo_available -= bo->size;
       }
    }
 
@@ -3056,7 +3052,6 @@ anv_vma_free(struct anv_device *device, struct anv_bo *bo)
    if (addr_48b >= LOW_HEAP_MIN_ADDRESS &&
        addr_48b <= LOW_HEAP_MAX_ADDRESS) {
       util_vma_heap_free(&device->vma_lo, addr_48b, bo->size);
-      device->vma_lo_available += bo->size;
    } else {
       ASSERTED const struct anv_physical_device *physical_device =
          &device->instance->physicalDevice;
@@ -3064,7 +3059,6 @@ anv_vma_free(struct anv_device *device, struct anv_bo *bo)
              addr_48b < (physical_device->memory.heaps[0].vma_start +
                          physical_device->memory.heaps[0].vma_size));
       util_vma_heap_free(&device->vma_hi, addr_48b, bo->size);
-      device->vma_hi_available += bo->size;
    }
 
    pthread_mutex_unlock(&device->vma_mutex);
index 2abbb866b2fb7bb4b89ceaa26a01db1e4096b5c1..e80fc2eed9685ec9641bc6c6185b2048513ee7eb 100644 (file)
@@ -1214,8 +1214,6 @@ struct anv_device {
     pthread_mutex_t                             vma_mutex;
     struct util_vma_heap                        vma_lo;
     struct util_vma_heap                        vma_hi;
-    uint64_t                                    vma_lo_available;
-    uint64_t                                    vma_hi_available;
 
     /** List of all anv_device_memory objects */
     struct list_head                            memory_objects;