Module: Mesa Branch: main Commit: 2883c6ddaa02bbf284b5cb148d741d65e87e9fa7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2883c6ddaa02bbf284b5cb148d741d65e87e9fa7
Author: Paulo Zanoni <paulo.r.zan...@intel.com> Date: Fri Oct 13 14:56:03 2023 -0700 anv: alloc client visible addresses at the bottom of vma_hi Kill vma_cva and just toggle heap->alloc_high instead. This way, client visible addresses will remain isolated in their own little corner, except we have one less vma to deal with. For TR-TT we'll need a special vma, and if we don't use the trick above we'll need yet another trtt_cva_vma, increasing complexity even more. Reviewed-by: Lionel Landwerlin <lionel.g.landwer...@intel.com> Signed-off-by: Paulo Zanoni <paulo.r.zan...@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26036> --- src/intel/vulkan/anv_device.c | 14 ++++---------- src/intel/vulkan/anv_private.h | 5 ----- src/intel/vulkan/anv_va.c | 11 ++--------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 2b364643227..2dacd673058 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3198,10 +3198,6 @@ VkResult anv_CreateDevice( device->physical->va.low_heap.addr, device->physical->va.low_heap.size); - util_vma_heap_init(&device->vma_cva, - device->physical->va.client_visible_heap.addr, - device->physical->va.client_visible_heap.size); - util_vma_heap_init(&device->vma_hi, device->physical->va.high_heap.addr, device->physical->va.high_heap.size); @@ -3672,7 +3668,6 @@ VkResult anv_CreateDevice( fail_vmas: util_vma_heap_finish(&device->vma_desc); util_vma_heap_finish(&device->vma_hi); - util_vma_heap_finish(&device->vma_cva); util_vma_heap_finish(&device->vma_lo); pthread_mutex_destroy(&device->vma_mutex); fail_queues: @@ -3784,7 +3779,6 @@ void anv_DestroyDevice( util_vma_heap_finish(&device->vma_desc); util_vma_heap_finish(&device->vma_hi); - util_vma_heap_finish(&device->vma_cva); util_vma_heap_finish(&device->vma_lo); pthread_mutex_destroy(&device->vma_mutex); @@ -3841,9 +3835,6 @@ static struct util_vma_heap * anv_vma_heap_for_flags(struct anv_device *device, enum anv_bo_alloc_flags alloc_flags) { - if (alloc_flags & ANV_BO_ALLOC_CLIENT_VISIBLE_ADDRESS) - return &device->vma_cva; - if (alloc_flags & ANV_BO_ALLOC_32BIT_ADDRESS) return &device->vma_lo; @@ -3866,13 +3857,17 @@ anv_vma_alloc(struct anv_device *device, *out_vma_heap = anv_vma_heap_for_flags(device, alloc_flags); if (alloc_flags & ANV_BO_ALLOC_CLIENT_VISIBLE_ADDRESS) { + assert(*out_vma_heap == &device->vma_hi); + if (client_address) { if (util_vma_heap_alloc_addr(*out_vma_heap, client_address, size)) { addr = client_address; } } else { + (*out_vma_heap)->alloc_high = false; addr = util_vma_heap_alloc(*out_vma_heap, size, align); + (*out_vma_heap)->alloc_high = true; } /* We don't want to fall back to other heaps */ goto done; @@ -3895,7 +3890,6 @@ anv_vma_free(struct anv_device *device, uint64_t address, uint64_t size) { assert(vma_heap == &device->vma_lo || - vma_heap == &device->vma_cva || vma_heap == &device->vma_hi || vma_heap == &device->vma_desc); diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 26f1736ea5e..fc155b43346 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1005,10 +1005,6 @@ struct anv_physical_device { * Instruction state pool */ struct anv_va_range instruction_state_pool; - /** - * Client visible VMA allocation heap - */ - struct anv_va_range client_visible_heap; /** * Client heap */ @@ -1554,7 +1550,6 @@ struct anv_device { pthread_mutex_t vma_mutex; struct util_vma_heap vma_lo; - struct util_vma_heap vma_cva; struct util_vma_heap vma_hi; struct util_vma_heap vma_desc; diff --git a/src/intel/vulkan/anv_va.c b/src/intel/vulkan/anv_va.c index 0859ddbcea1..be142f61105 100644 --- a/src/intel/vulkan/anv_va.c +++ b/src/intel/vulkan/anv_va.c @@ -61,7 +61,6 @@ anv_device_print_vas(struct anv_physical_device *device) PRINT_HEAP(indirect_descriptor_pool); PRINT_HEAP(indirect_push_descriptor_pool); PRINT_HEAP(instruction_state_pool); - PRINT_HEAP(client_visible_heap); PRINT_HEAP(high_heap); } @@ -154,18 +153,12 @@ anv_physical_device_init_va_ranges(struct anv_physical_device *device) address = align64(address, _4Gb); address = va_add(&device->va.instruction_state_pool, address, 2 * _1Gb); - /* Whatever we have left we split in 2 for app allocations client-visible & - * non-client-visible. - * - * Leave the last 4GiB out of the high vma range, so that no state + /* Leave the last 4GiB out of the high vma range, so that no state * base address + size can overflow 48 bits. For more information see * the comment about Wa32bitGeneralStateOffset in anv_allocator.c */ uint64_t user_heaps_size = device->gtt_size - address - 4 * _1Gb; - uint64_t heaps_size_Gb = user_heaps_size / _1Gb / 2 ; - - address = va_add(&device->va.client_visible_heap, address, heaps_size_Gb * _1Gb); - address = va_add(&device->va.high_heap, address, heaps_size_Gb * _1Gb); + address = va_add(&device->va.high_heap, address, user_heaps_size); if (INTEL_DEBUG(DEBUG_HEAPS)) anv_device_print_vas(device);