From 986a3243cf9b97e910ff05a5c119ca919b3bc3e0 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 26 Apr 2021 11:43:44 +0000 Subject: [PATCH] radv: adjust the computation of the total usage of memory used internal_usage is the memory allocated by the current process (intent) while system_usage is the memory allocated globally (actual). Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_device.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 033d2a1..2fdd64d 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -2405,26 +2405,28 @@ radv_get_memory_budget_properties(VkPhysicalDevice physicalDevice, unsigned mask = device->heaps; unsigned heap = 0; while (mask) { - uint64_t internal_usage = 0, total_usage = 0; + uint64_t internal_usage = 0, system_usage = 0; unsigned type = 1u << u_bit_scan(&mask); switch (type) { case RADV_HEAP_VRAM: internal_usage = device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM); - total_usage = device->ws->query_value(device->ws, RADEON_VRAM_USAGE); + system_usage = device->ws->query_value(device->ws, RADEON_VRAM_USAGE); break; case RADV_HEAP_VRAM_VIS: internal_usage = device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM_VIS); if (!(device->heaps & RADV_HEAP_VRAM)) internal_usage += device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM); - total_usage = device->ws->query_value(device->ws, RADEON_VRAM_VIS_USAGE); + system_usage = device->ws->query_value(device->ws, RADEON_VRAM_VIS_USAGE); break; case RADV_HEAP_GTT: internal_usage = device->ws->query_value(device->ws, RADEON_ALLOCATED_GTT); - total_usage = device->ws->query_value(device->ws, RADEON_GTT_USAGE); + system_usage = device->ws->query_value(device->ws, RADEON_GTT_USAGE); break; } + uint64_t total_usage = MAX2(internal_usage, system_usage); + uint64_t free_space = device->memory_properties.memoryHeaps[heap].size - MIN2(device->memory_properties.memoryHeaps[heap].size, total_usage); memoryBudget->heapBudget[heap] = free_space + internal_usage; -- 2.7.4