v3dv: implement vkBindImageMemory
authorIago Toral Quiroga <itoral@igalia.com>
Thu, 5 Dec 2019 09:36:24 +0000 (10:36 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 21:21:25 +0000 (21:21 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

src/broadcom/vulkan/v3dv_device.c
src/broadcom/vulkan/v3dv_private.h

index 60b83bb..aabe2a4 100644 (file)
@@ -1275,3 +1275,27 @@ v3dv_GetImageMemoryRequirements(VkDevice _device,
    pMemoryRequirements->alignment = image->alignment;
    pMemoryRequirements->memoryTypeBits = 0x3; /* Both memory types */
 }
+
+VkResult
+v3dv_BindImageMemory(VkDevice _device,
+                     VkImage _image,
+                     VkDeviceMemory _memory,
+                     VkDeviceSize memoryOffset)
+{
+   V3DV_FROM_HANDLE(v3dv_device_memory, mem, _memory);
+   V3DV_FROM_HANDLE(v3dv_image, image, _image);
+
+   /* Valid usage:
+    *
+    *   "memoryOffset must be an integer multiple of the alignment member of
+    *    the VkMemoryRequirements structure returned from a call to
+    *    vkGetImageMemoryRequirements with image"
+    */
+   assert(memoryOffset % image->alignment == 0);
+   assert(memoryOffset < mem->size);
+
+   image->mem = mem;
+   image->mem_offset = memoryOffset;
+
+   return VK_SUCCESS;
+}
index 57a02fe..a37d0fc 100644 (file)
@@ -273,6 +273,9 @@ struct v3dv_image {
    uint32_t size; /* Total size in bytes */
    uint32_t cube_map_stride;
    uint32_t alignment;
+
+   struct v3dv_device_memory *mem;
+   VkDeviceSize mem_offset;
 };
 
 struct v3dv_shader_module {