From be216ae9d9e900147a69b90a2ffd8a3ee24dcb32 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 18 Aug 2021 09:35:53 -0500 Subject: [PATCH] anv: Move compute_heap_size lower in the file Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_device.c | 50 +++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index e31fa2f..7a5c574 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -116,31 +116,6 @@ compiler_perf_log(UNUSED void *data, UNUSED unsigned *id, const char *fmt, ...) va_end(args); } -static uint64_t -anv_compute_heap_size(int fd, uint64_t gtt_size) -{ - /* Query the total ram from the system */ - uint64_t total_ram; - if (!os_get_total_physical_memory(&total_ram)) - return 0; - - /* 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 / 2; - else - available_ram = total_ram * 3 / 4; - - /* We also want to leave some padding for things we allocate in the driver, - * so don't go over 3/4 of the GTT either. - */ - uint64_t available_gtt = gtt_size * 3 / 4; - - return MIN2(available_ram, available_gtt); -} - #if defined(VK_USE_PLATFORM_WAYLAND_KHR) || \ defined(VK_USE_PLATFORM_XCB_KHR) || \ defined(VK_USE_PLATFORM_XLIB_KHR) || \ @@ -329,6 +304,31 @@ get_device_extensions(const struct anv_physical_device *device, }; } +static uint64_t +anv_compute_heap_size(int fd, uint64_t gtt_size) +{ + /* Query the total ram from the system */ + uint64_t total_ram; + if (!os_get_total_physical_memory(&total_ram)) + return 0; + + /* 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 / 2; + else + available_ram = total_ram * 3 / 4; + + /* We also want to leave some padding for things we allocate in the driver, + * so don't go over 3/4 of the GTT either. + */ + uint64_t available_gtt = gtt_size * 3 / 4; + + return MIN2(available_ram, available_gtt); +} + static bool anv_get_query_meminfo(struct anv_physical_device *device, int fd) { -- 2.7.4