[Mesa-dev] [PATCH 07/15] anv: add support for VK_KHR_bind_memory2

Lionel Landwerlin lionel.g.landwerlin at intel.com
Fri Sep 15 14:10:59 UTC 2017


Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 src/intel/vulkan/anv_device.c      | 32 ++++++++++++++++++++++++++++++++
 src/intel/vulkan/anv_extensions.py |  1 +
 src/intel/vulkan/anv_image.c       | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 8e2ed9eac45..4b30c0005fd 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1884,6 +1884,38 @@ VkResult anv_BindBufferMemory(
    return VK_SUCCESS;
 }
 
+VkResult anv_BindBufferMemory2KHR(
+    VkDevice                                    device,
+    uint32_t                                    bindInfoCount,
+    const VkBindBufferMemoryInfoKHR*            pBindInfos)
+{
+   VkResult result = VK_SUCCESS;
+
+   for (uint32_t i = 0; i < bindInfoCount; i++) {
+      const VkBindBufferMemoryInfoKHR *bind_info = &pBindInfos[i];
+
+      if (bind_info->pNext == NULL) {
+         result = anv_BindBufferMemory(device, bind_info->buffer,
+                                       bind_info->memory,
+                                       bind_info->memoryOffset);
+      } else {
+         vk_foreach_struct_const(s, pBindInfos->pNext) {
+            switch (s->sType) {
+            default:
+               anv_debug_ignored_stype(s->sType);
+               break;
+            }
+         }
+      }
+
+      /* Stop at the first error. */
+      if (result != VK_SUCCESS)
+         break;
+   }
+
+   return result;
+}
+
 VkResult anv_QueueBindSparse(
     VkQueue                                     _queue,
     uint32_t                                    bindInfoCount,
diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py
index acec785959b..cb0e36b7233 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -45,6 +45,7 @@ class Extension:
             self.enable = enable;
 
 EXTENSIONS = [
+    Extension('VK_KHR_bind_memory2',                      1, True),
     Extension('VK_KHR_dedicated_allocation',              1, True),
     Extension('VK_KHR_descriptor_update_template',        1, True),
     Extension('VK_KHR_external_fence',                    1,
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 492b341303a..2aa83154f82 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -32,6 +32,7 @@
 #include "util/debug.h"
 
 #include "vk_format_info.h"
+#include "vk_util.h"
 
 /**
  * Exactly one bit must be set in \a aspect.
@@ -442,6 +443,38 @@ VkResult anv_BindImageMemory(
    return VK_SUCCESS;
 }
 
+VkResult anv_BindImageMemory2KHR(
+    VkDevice                                    device,
+    uint32_t                                    bindInfoCount,
+    const VkBindImageMemoryInfoKHR*             pBindInfos)
+{
+   VkResult result = VK_SUCCESS;
+
+   for (uint32_t i = 0; i < bindInfoCount; i++) {
+      const VkBindImageMemoryInfoKHR *bind_info = &pBindInfos[i];
+
+      if (pBindInfos->pNext == NULL) {
+         result = anv_BindImageMemory(device, bind_info->image,
+                                      bind_info->memory,
+                                      bind_info->memoryOffset);
+      } else {
+         vk_foreach_struct_const(s, bind_info->pNext) {
+            switch (s->sType) {
+            default:
+               anv_debug_ignored_stype(s->sType);
+               break;
+            }
+         }
+      }
+
+      /* Stop at the first error. */
+      if (result != VK_SUCCESS)
+         break;
+   }
+
+   return result;
+}
+
 static void
 anv_surface_get_subresource_layout(struct anv_image *image,
                                    struct anv_surface *surface,
-- 
2.14.1



More information about the mesa-dev mailing list