Mesa (17.1): anv: Advertise both 32-bit and 48-bit heaps when we have enough memory

Juan Antonio Suárez Romero jasuarez at kemper.freedesktop.org
Sat Jun 3 17:04:09 UTC 2017


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

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Wed May 17 11:54:12 2017 -0700

anv: Advertise both 32-bit and 48-bit heaps when we have enough memory

Reviewed-by: Nanley Chery <nanley.g.chery at intel.com>
Cc: "17.1" <mesa-stable at lists.freedesktop.org>
(cherry picked from commit 50d0eb5096bd9514821a641f25c0b3455c0f8a88)
Signed-off-by: Juan A. Suarez Romero <jasuarez at igalia.com>

---

 src/intel/vulkan/anv_device.c | 42 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 52181f1259..726ccce085 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -112,12 +112,42 @@ anv_physical_device_init_heaps(struct anv_physical_device *device, int fd)
    if (result != VK_SUCCESS)
       return result;
 
-   device->memory.heap_count = 1;
-   device->memory.heaps[0] = (struct anv_memory_heap) {
-      .size = heap_size,
-      .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
-      .supports_48bit_addresses = device->supports_48bit_addresses,
-   };
+   if (heap_size <= 3ull * (1ull << 30)) {
+      /* In this case, everything fits nicely into the 32-bit address space,
+       * so there's no need for supporting 48bit addresses on client-allocated
+       * memory objects.
+       */
+      device->memory.heap_count = 1;
+      device->memory.heaps[0] = (struct anv_memory_heap) {
+         .size = heap_size,
+         .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
+         .supports_48bit_addresses = false,
+      };
+   } else {
+      /* Not everything will fit nicely into a 32-bit address space.  In this
+       * case we need a 64-bit heap.  Advertise a small 32-bit heap and a
+       * larger 48-bit heap.  If we're in this case, then we have a total heap
+       * size larger than 3GiB which most likely means they have 8 GiB of
+       * video memory and so carving off 1 GiB for the 32-bit heap should be
+       * reasonable.
+       */
+      const uint64_t heap_size_32bit = 1ull << 30;
+      const uint64_t heap_size_48bit = heap_size - heap_size_32bit;
+
+      assert(device->supports_48bit_addresses);
+
+      device->memory.heap_count = 2;
+      device->memory.heaps[0] = (struct anv_memory_heap) {
+         .size = heap_size_48bit,
+         .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
+         .supports_48bit_addresses = true,
+      };
+      device->memory.heaps[1] = (struct anv_memory_heap) {
+         .size = heap_size_32bit,
+         .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
+         .supports_48bit_addresses = false,
+      };
+   }
 
    uint32_t type_count = 0;
    for (uint32_t heap = 0; heap < device->memory.heap_count; heap++) {




More information about the mesa-commit mailing list