From 62c0f4811d7baa937a94dd18e4d8b0c724996814 Mon Sep 17 00:00:00 2001 From: Karmjit Mahil Date: Mon, 27 Apr 2026 15:33:11 +0100 Subject: [PATCH] pvr: Use os_get_gpu_heap_size() To use the common function, this gives up the warning about the memory being too small to meet the Vulkan spec for low end devices. Note: the common helper expose 25% for devices with <=1GiB but to adhere to the Vulkan spec, the value is clamped to 1GiB. Signed-off-by: Karmjit Mahil --- src/imagination/vulkan/pvr_physical_device.c | 26 ++++---------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/imagination/vulkan/pvr_physical_device.c b/src/imagination/vulkan/pvr_physical_device.c index f2df4f91d23..a3b3ebefc80 100644 --- a/src/imagination/vulkan/pvr_physical_device.c +++ b/src/imagination/vulkan/pvr_physical_device.c @@ -18,6 +18,7 @@ #include "util/disk_cache.h" #include "util/ralloc.h" +#include "util/os_misc.h" #include "vk_util.h" #include "vk_log.h" @@ -986,30 +987,13 @@ static bool pvr_device_is_conformant(const struct pvr_device_info *info) return false; } -/* Minimum required by the Vulkan 1.1 spec (see Table 32. Required Limits) */ +/* Minimum required by the Vulkan spec Limits (maxMemoryAllocationSize) */ #define PVR_MAX_MEMORY_ALLOCATION_SIZE (1ull << 30) -static uint64_t pvr_compute_heap_size(void) +static inline uint64_t pvr_compute_heap_size(void) { - /* Query the total ram from the system */ - uint64_t total_ram; - if (!os_get_total_physical_memory(&total_ram)) - return 0; - - if (total_ram < PVR_MAX_MEMORY_ALLOCATION_SIZE) { - mesa_logw( - "Warning: The available RAM is below the minimum required by the Vulkan specification!"); - } - - /* We don't want to burn too much ram with the GPU. If the user has 4GiB - * or less, we use at most half. If they have more than 4GiB, we use 3/4. - */ - uint64_t available_ram; - if (total_ram <= 4ULL * 1024ULL * 1024ULL * 1024ULL) - available_ram = total_ram / 2U; - else - available_ram = total_ram * 3U / 4U; - + uint64_t available_ram = + os_get_gpu_heap_size(OS_GPU_HEAP_SIZE_HEURISTIC, NULL); return MAX2(available_ram, PVR_MAX_MEMORY_ALLOCATION_SIZE); }