summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>2021-04-26 11:43:44 +0000
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>2021-05-05 08:44:17 +0200
commit986a3243cf9b97e910ff05a5c119ca919b3bc3e0 (patch)
tree1ffd467cc2d4b66059a53d2fe7f3eb40b959d7ce
parent340703e044ba6ef148d69bcd3a121263d720ab91 (diff)
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 <samuel.pitoiset@gmail.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9774>
-rw-r--r--src/amd/vulkan/radv_device.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 033d2a197de..2fdd64d6eab 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;