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

Author: Samuel Pitoiset <samuel.pitoi...@gmail.com>
Date:   Wed Dec 20 18:02:37 2023 +0100

radv: move radv_BindImageMemory2() to radv_image.c

Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26757>

---

 src/amd/vulkan/radv_device.c | 69 --------------------------------------------
 src/amd/vulkan/radv_image.c  | 69 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 69 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 65e2683ae11..0da0a60ce86 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -1400,75 +1400,6 @@ radv_GetDeviceImageMemoryRequirements(VkDevice device, 
const VkDeviceImageMemory
    radv_DestroyImage(device, image, NULL);
 }
 
-VKAPI_ATTR VkResult VKAPI_CALL
-radv_BindImageMemory2(VkDevice _device, uint32_t bindInfoCount, const 
VkBindImageMemoryInfo *pBindInfos)
-{
-   RADV_FROM_HANDLE(radv_device, device, _device);
-
-   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);
-
-      /* Ignore this struct on Android, we cannot access swapchain structures 
there. */
-#ifdef RADV_USE_WSI_PLATFORM
-      const VkBindImageMemorySwapchainInfoKHR *swapchain_info =
-         vk_find_struct_const(pBindInfos[i].pNext, 
BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR);
-
-      if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE) {
-         struct radv_image *swapchain_img =
-            
radv_image_from_handle(wsi_common_get_image(swapchain_info->swapchain, 
swapchain_info->imageIndex));
-
-         image->bindings[0].bo = swapchain_img->bindings[0].bo;
-         image->bindings[0].offset = swapchain_img->bindings[0].offset;
-         continue;
-      }
-#endif
-
-      if (mem->alloc_size) {
-         VkImageMemoryRequirementsInfo2 info = {
-            .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2,
-            .image = pBindInfos[i].image,
-         };
-         VkMemoryRequirements2 reqs = {
-            .sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
-         };
-
-         radv_GetImageMemoryRequirements2(_device, &info, &reqs);
-
-         if (pBindInfos[i].memoryOffset + reqs.memoryRequirements.size > 
mem->alloc_size) {
-            return vk_errorf(device, VK_ERROR_UNKNOWN, "Device memory object 
too small for the image.\n");
-         }
-      }
-
-      if (image->disjoint) {
-         const VkBindImagePlaneMemoryInfo *plane_info =
-            vk_find_struct_const(pBindInfos[i].pNext, 
BIND_IMAGE_PLANE_MEMORY_INFO);
-
-         switch (plane_info->planeAspect) {
-         case VK_IMAGE_ASPECT_PLANE_0_BIT:
-            image->bindings[0].bo = mem->bo;
-            image->bindings[0].offset = pBindInfos[i].memoryOffset;
-            break;
-         case VK_IMAGE_ASPECT_PLANE_1_BIT:
-            image->bindings[1].bo = mem->bo;
-            image->bindings[1].offset = pBindInfos[i].memoryOffset;
-            break;
-         case VK_IMAGE_ASPECT_PLANE_2_BIT:
-            image->bindings[2].bo = mem->bo;
-            image->bindings[2].offset = pBindInfos[i].memoryOffset;
-            break;
-         default:
-            break;
-         }
-      } else {
-         image->bindings[0].bo = mem->bo;
-         image->bindings[0].offset = pBindInfos[i].memoryOffset;
-      }
-      radv_rmv_log_image_bind(device, pBindInfos[i].image);
-   }
-   return VK_SUCCESS;
-}
-
 static inline unsigned
 si_tile_mode_index(const struct radv_image_plane *plane, unsigned level, bool 
stencil)
 {
diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index 5d4dccbb9bc..bb3eb85027a 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -1590,6 +1590,75 @@ radv_DestroyImage(VkDevice _device, VkImage _image, 
const VkAllocationCallbacks
    radv_destroy_image(device, pAllocator, image);
 }
 
+VKAPI_ATTR VkResult VKAPI_CALL
+radv_BindImageMemory2(VkDevice _device, uint32_t bindInfoCount, const 
VkBindImageMemoryInfo *pBindInfos)
+{
+   RADV_FROM_HANDLE(radv_device, device, _device);
+
+   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);
+
+      /* Ignore this struct on Android, we cannot access swapchain structures 
there. */
+#ifdef RADV_USE_WSI_PLATFORM
+      const VkBindImageMemorySwapchainInfoKHR *swapchain_info =
+         vk_find_struct_const(pBindInfos[i].pNext, 
BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR);
+
+      if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE) {
+         struct radv_image *swapchain_img =
+            
radv_image_from_handle(wsi_common_get_image(swapchain_info->swapchain, 
swapchain_info->imageIndex));
+
+         image->bindings[0].bo = swapchain_img->bindings[0].bo;
+         image->bindings[0].offset = swapchain_img->bindings[0].offset;
+         continue;
+      }
+#endif
+
+      if (mem->alloc_size) {
+         VkImageMemoryRequirementsInfo2 info = {
+            .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2,
+            .image = pBindInfos[i].image,
+         };
+         VkMemoryRequirements2 reqs = {
+            .sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
+         };
+
+         radv_GetImageMemoryRequirements2(_device, &info, &reqs);
+
+         if (pBindInfos[i].memoryOffset + reqs.memoryRequirements.size > 
mem->alloc_size) {
+            return vk_errorf(device, VK_ERROR_UNKNOWN, "Device memory object 
too small for the image.\n");
+         }
+      }
+
+      if (image->disjoint) {
+         const VkBindImagePlaneMemoryInfo *plane_info =
+            vk_find_struct_const(pBindInfos[i].pNext, 
BIND_IMAGE_PLANE_MEMORY_INFO);
+
+         switch (plane_info->planeAspect) {
+         case VK_IMAGE_ASPECT_PLANE_0_BIT:
+            image->bindings[0].bo = mem->bo;
+            image->bindings[0].offset = pBindInfos[i].memoryOffset;
+            break;
+         case VK_IMAGE_ASPECT_PLANE_1_BIT:
+            image->bindings[1].bo = mem->bo;
+            image->bindings[1].offset = pBindInfos[i].memoryOffset;
+            break;
+         case VK_IMAGE_ASPECT_PLANE_2_BIT:
+            image->bindings[2].bo = mem->bo;
+            image->bindings[2].offset = pBindInfos[i].memoryOffset;
+            break;
+         default:
+            break;
+         }
+      } else {
+         image->bindings[0].bo = mem->bo;
+         image->bindings[0].offset = pBindInfos[i].memoryOffset;
+      }
+      radv_rmv_log_image_bind(device, pBindInfos[i].image);
+   }
+   return VK_SUCCESS;
+}
+
 VKAPI_ATTR void VKAPI_CALL
 radv_GetImageSubresourceLayout2KHR(VkDevice _device, VkImage _image, const 
VkImageSubresource2KHR *pSubresource,
                                    VkSubresourceLayout2KHR *pLayout)

Reply via email to