Mesa (main): radv: fix heap indices when computing the budget
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu May 20 14:37:02 UTC 2021
Module: Mesa
Branch: main
Commit: 489e38c708d8a89a59e189e92ed5190c459569f0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=489e38c708d8a89a59e189e92ed5190c459569f0
Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date: Tue May 18 07:14:57 2021 +0000
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 <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10852>
---
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;
More information about the mesa-commit
mailing list