radv: Add VK_KHR_bind_memory2 support.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sun, 17 Sep 2017 11:55:16 +0000 (13:55 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 20 Sep 2017 19:48:35 +0000 (21:48 +0200)
Nothing too exciting, just adding the possibility for a pNext pointer,
and batch binding. Our binding is pretty much trivial.

It also adds VK_IMAGE_CREATE_ALIAS_BIT_KHR, but since we store no
state in radv_image, I don't think we have to do anything there.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_entrypoints_gen.py

index e6d595dfbe5e33a45cf597c83fa44136112de69e..7bfdddf0eea4939b1c1349f108a14f50050f1ab6 100644 (file)
@@ -174,6 +174,10 @@ static const VkExtensionProperties common_device_extensions[] = {
                .extensionName = VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME,
                .specVersion = 1,
        },
+       {
+               .extensionName = VK_KHR_BIND_MEMORY_2_EXTENSION_NAME,
+               .specVersion = 1,
+       },
 };
 static const VkExtensionProperties ext_sema_device_extensions[] = {
        {
@@ -2481,44 +2485,74 @@ void radv_GetDeviceMemoryCommitment(
        *pCommittedMemoryInBytes = 0;
 }
 
+VkResult radv_BindBufferMemory2KHR(VkDevice device,
+                                   uint32_t bindInfoCount,
+                                   const VkBindBufferMemoryInfoKHR *pBindInfos)
+{
+       for (uint32_t i = 0; i < bindInfoCount; ++i) {
+               RADV_FROM_HANDLE(radv_device_memory, mem, pBindInfos[i].memory);
+               RADV_FROM_HANDLE(radv_buffer, buffer, pBindInfos[i].buffer);
+
+               if (mem) {
+                       buffer->bo = mem->bo;
+                       buffer->offset = pBindInfos[i].memoryOffset;
+               } else {
+                       buffer->bo = NULL;
+               }
+       }
+       return VK_SUCCESS;
+}
+
 VkResult radv_BindBufferMemory(
        VkDevice                                    device,
-       VkBuffer                                    _buffer,
-       VkDeviceMemory                              _memory,
+       VkBuffer                                    buffer,
+       VkDeviceMemory                              memory,
        VkDeviceSize                                memoryOffset)
 {
-       RADV_FROM_HANDLE(radv_device_memory, mem, _memory);
-       RADV_FROM_HANDLE(radv_buffer, buffer, _buffer);
+       const VkBindBufferMemoryInfoKHR info = {
+               .sType = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHR,
+               .buffer = buffer,
+               .memory = memory,
+               .memoryOffset = memoryOffset
+       };
 
-       if (mem) {
-               buffer->bo = mem->bo;
-               buffer->offset = memoryOffset;
-       } else {
-               buffer->bo = NULL;
-               buffer->offset = 0;
-       }
+       return radv_BindBufferMemory2KHR(device, 1, &info);
+}
 
+VkResult radv_BindImageMemory2KHR(VkDevice device,
+                                  uint32_t bindInfoCount,
+                                  const VkBindImageMemoryInfoKHR *pBindInfos)
+{
+       for (uint32_t i = 0; i < bindInfoCount; ++i) {
+               RADV_FROM_HANDLE(radv_device_memory, mem, pBindInfos[i].memory);
+               RADV_FROM_HANDLE(radv_image, image, pBindInfos[i].image);
+
+               if (mem) {
+                       image->bo = mem->bo;
+                       image->offset = pBindInfos[i].memoryOffset;
+               } else {
+                       image->bo = NULL;
+                       image->offset = 0;
+               }
+       }
        return VK_SUCCESS;
 }
 
+
 VkResult radv_BindImageMemory(
        VkDevice                                    device,
-       VkImage                                     _image,
-       VkDeviceMemory                              _memory,
+       VkImage                                     image,
+       VkDeviceMemory                              memory,
        VkDeviceSize                                memoryOffset)
 {
-       RADV_FROM_HANDLE(radv_device_memory, mem, _memory);
-       RADV_FROM_HANDLE(radv_image, image, _image);
-
-       if (mem) {
-               image->bo = mem->bo;
-               image->offset = memoryOffset;
-       } else {
-               image->bo = NULL;
-               image->offset = 0;
-       }
+       const VkBindImageMemoryInfoKHR info = {
+               .sType = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHR,
+               .image = image,
+               .memory = memory,
+               .memoryOffset = memoryOffset
+       };
 
-       return VK_SUCCESS;
+       return radv_BindImageMemory2KHR(device, 1, &info);
 }
 
 
index 9634f76fcd6969424ac28596fdd6ade776466234..21738f4da9027bb7266706c06c6710f7bec87516 100644 (file)
@@ -57,6 +57,7 @@ SUPPORTED_EXTENSIONS = [
     'VK_KHR_external_semaphore_capabilities',
     'VK_KHR_external_semaphore',
     'VK_KHR_external_semaphore_fd',
+    'VK_KHR_bind_memory2',
 ]
 
 # We generate a static hash table for entry point lookup