Mesa (main): anv: Move compute_heap_size lower in the file

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 18 17:27:23 UTC 2021


Module: Mesa
Branch: main
Commit: be216ae9d9e900147a69b90a2ffd8a3ee24dcb32
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=be216ae9d9e900147a69b90a2ffd8a3ee24dcb32

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Wed Aug 18 09:35:53 2021 -0500

anv: Move compute_heap_size lower in the file

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12433>

---

 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 e31fa2f9d41..7a5c57411e7 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)
 {



More information about the mesa-commit mailing list