From 489e38c708d8a89a59e189e92ed5190c459569f0 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 18 May 2021 07:14:57 +0000 Subject: [PATCH] radv: fix heap indices when computing the budget RADV_HEAP_* is the heap type, not the index. Fixes dEQP-VK.info.device_memory_budget. Fixes: 08d162f0b57 ("radv: expose 2/3rd of total memory as VRAM and 1/3rd as GTT on APUs") Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_device.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 101d3be0dfc..38de336d39d 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -2429,9 +2429,15 @@ radv_get_memory_budget_properties(VkPhysicalDevice physicalDevice, * too small for games but the budgets need to be redistributed accordingly. */ + assert(device->heaps == (RADV_HEAP_GTT | RADV_HEAP_VRAM_VIS)); + assert(device->memory_properties.memoryHeaps[0].flags == 0); /* GTT */ + assert(device->memory_properties.memoryHeaps[1].flags == VK_MEMORY_HEAP_DEVICE_LOCAL_BIT); + uint8_t gtt_heap_idx = 0, vram_vis_heap_idx = 1; + /* Get the visible VRAM/GTT heap sizes and internal usages. */ - uint64_t vram_vis_heap_size = device->memory_properties.memoryHeaps[RADV_HEAP_VRAM_VIS].size; - uint64_t gtt_heap_size = device->memory_properties.memoryHeaps[RADV_HEAP_GTT].size; + uint64_t gtt_heap_size = device->memory_properties.memoryHeaps[gtt_heap_idx].size; + uint64_t vram_vis_heap_size = device->memory_properties.memoryHeaps[vram_vis_heap_idx].size; + uint64_t vram_vis_internal_usage = device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM_VIS) + device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM); uint64_t gtt_internal_usage = device->ws->query_value(device->ws, RADEON_ALLOCATED_GTT); @@ -2457,10 +2463,10 @@ radv_get_memory_budget_properties(VkPhysicalDevice physicalDevice, device->rad_info.gart_page_size); uint64_t gtt_free_space = total_free_space - vram_vis_free_space; - memoryBudget->heapBudget[RADV_HEAP_VRAM_VIS] = vram_vis_free_space + vram_vis_internal_usage; - memoryBudget->heapUsage[RADV_HEAP_VRAM_VIS] = vram_vis_internal_usage; - memoryBudget->heapBudget[RADV_HEAP_GTT] = gtt_free_space + gtt_internal_usage; - memoryBudget->heapUsage[RADV_HEAP_GTT] = gtt_internal_usage; + memoryBudget->heapBudget[vram_vis_heap_idx] = vram_vis_free_space + vram_vis_internal_usage; + memoryBudget->heapUsage[vram_vis_heap_idx] = vram_vis_internal_usage; + memoryBudget->heapBudget[gtt_heap_idx] = gtt_free_space + gtt_internal_usage; + memoryBudget->heapUsage[gtt_heap_idx] = gtt_internal_usage; } else { unsigned mask = device->heaps; unsigned heap = 0;