[Mesa-dev] [PATCH 2/2] radv: fix VK_EXT_memory_budget if one heap isn't available
Bas Nieuwenhuizen
bas at basnieuwenhuizen.nl
Tue Jun 11 21:46:28 UTC 2019
So can we rephrase this entire thing based on
physical_devices->mem_type_indices, instead of opencoding ordering &
detection?
On Tue, Jun 11, 2019 at 4:43 PM Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
>
> On VegaM, the visible VRAM size is equal to the VRAM size, which
> means only two heaps are exposed.
>
> This fixes dEQP-VK.api.info.device.memory_budget.
>
> Cc: 19.0 19.1 <mesa-stable at lists.freedesktop.org>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
> src/amd/vulkan/radv_device.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
> index 358fc7cb30a..31b9b4e9875 100644
> --- a/src/amd/vulkan/radv_device.c
> +++ b/src/amd/vulkan/radv_device.c
> @@ -1489,9 +1489,11 @@ radv_get_memory_budget_properties(VkPhysicalDevice physicalDevice,
> RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
> VkPhysicalDeviceMemoryProperties *memory_properties = &device->memory_properties;
> uint64_t visible_vram_size = radv_get_visible_vram_size(device);
> + int vram_index = -1, visible_vram_index = -1, gtt_index = -1;
> uint64_t vram_size = radv_get_vram_size(device);
> uint64_t gtt_size = device->rad_info.gart_size;
> uint64_t heap_budget, heap_usage;
> + uint32_t heap_count = 0;
>
> /* For all memory heaps, the computation of budget is as follow:
> * heap_budget = heap_size - global_heap_usage + app_heap_usage
> @@ -1503,6 +1505,7 @@ radv_get_memory_budget_properties(VkPhysicalDevice physicalDevice,
> * in presence of shared buffers).
> */
> if (vram_size) {
> + vram_index = heap_count++;
> heap_usage = device->ws->query_value(device->ws,
> RADEON_ALLOCATED_VRAM);
>
> @@ -1510,11 +1513,12 @@ radv_get_memory_budget_properties(VkPhysicalDevice physicalDevice,
> device->ws->query_value(device->ws, RADEON_VRAM_USAGE) +
> heap_usage;
>
> - memoryBudget->heapBudget[RADV_MEM_HEAP_VRAM] = heap_budget;
> - memoryBudget->heapUsage[RADV_MEM_HEAP_VRAM] = heap_usage;
> + memoryBudget->heapBudget[vram_index] = heap_budget;
> + memoryBudget->heapUsage[vram_index] = heap_usage;
> }
>
> if (visible_vram_size) {
> + visible_vram_index = heap_count++;
> heap_usage = device->ws->query_value(device->ws,
> RADEON_ALLOCATED_VRAM_VIS);
>
> @@ -1522,11 +1526,12 @@ radv_get_memory_budget_properties(VkPhysicalDevice physicalDevice,
> device->ws->query_value(device->ws, RADEON_VRAM_VIS_USAGE) +
> heap_usage;
>
> - memoryBudget->heapBudget[RADV_MEM_HEAP_VRAM_CPU_ACCESS] = heap_budget;
> - memoryBudget->heapUsage[RADV_MEM_HEAP_VRAM_CPU_ACCESS] = heap_usage;
> + memoryBudget->heapBudget[visible_vram_index] = heap_budget;
> + memoryBudget->heapUsage[visible_vram_index] = heap_usage;
> }
>
> if (gtt_size) {
> + gtt_index = heap_count++;
> heap_usage = device->ws->query_value(device->ws,
> RADEON_ALLOCATED_GTT);
>
> @@ -1534,8 +1539,8 @@ radv_get_memory_budget_properties(VkPhysicalDevice physicalDevice,
> device->ws->query_value(device->ws, RADEON_GTT_USAGE) +
> heap_usage;
>
> - memoryBudget->heapBudget[RADV_MEM_HEAP_GTT] = heap_budget;
> - memoryBudget->heapUsage[RADV_MEM_HEAP_GTT] = heap_usage;
> + memoryBudget->heapBudget[gtt_index] = heap_budget;
> + memoryBudget->heapUsage[gtt_index++] = heap_usage;
> }
>
> /* The heapBudget and heapUsage values must be zero for array elements
> --
> 2.22.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list