Mesa (main): venus: suballocate memory in more cases

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 27 04:04:08 UTC 2021


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

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Mon Jul 26 18:09:39 2021 -0700

venus: suballocate memory in more cases

When a dedicated allocation is not required, ignore it and suballocate.

Fixes dEQP-VK.api.invariance.random.

Cc: 21.2 mesa-stable
Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12072>

---

 src/virtio/vulkan/vn_device_memory.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/virtio/vulkan/vn_device_memory.c b/src/virtio/vulkan/vn_device_memory.c
index cae604aaf52..27e758ad515 100644
--- a/src/virtio/vulkan/vn_device_memory.c
+++ b/src/virtio/vulkan/vn_device_memory.c
@@ -14,7 +14,9 @@
 #include "venus-protocol/vn_protocol_driver_transport.h"
 
 #include "vn_android.h"
+#include "vn_buffer.h"
 #include "vn_device.h"
+#include "vn_image.h"
 
 /* device memory commands */
 
@@ -188,9 +190,29 @@ vn_device_memory_should_suballocate(const VkMemoryAllocateInfo *alloc_info,
    if (alloc_info->allocationSize > 64 * 1024)
       return false;
 
-   /* reject if there is any pnext struct */
-   if (alloc_info->pNext)
-      return false;
+   /* reject if there is any pnext struct other than
+    * VkMemoryDedicatedAllocateInfo, or if dedicated allocation is required
+    */
+   if (alloc_info->pNext) {
+      const VkMemoryDedicatedAllocateInfo *dedicated = alloc_info->pNext;
+      if (dedicated->sType !=
+             VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO ||
+          dedicated->pNext)
+         return false;
+
+      const struct vn_image *img = vn_image_from_handle(dedicated->image);
+      if (img) {
+         for (uint32_t i = 0; i < ARRAY_SIZE(img->dedicated_requirements);
+              i++) {
+            if (img->dedicated_requirements[i].requiresDedicatedAllocation)
+               return false;
+         }
+      }
+
+      const struct vn_buffer *buf = vn_buffer_from_handle(dedicated->buffer);
+      if (buf && buf->dedicated_requirements.requiresDedicatedAllocation)
+         return false;
+   }
 
    return true;
 }



More information about the mesa-commit mailing list