typedef VkResult (VKAPI *PFN_vkFlushMappedMemoryRanges)(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges);
typedef VkResult (VKAPI *PFN_vkInvalidateMappedMemoryRanges)(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges);
typedef VkResult (VKAPI *PFN_vkDestroyObject)(VkDevice device, VkObjectType objType, VkObject object);
-typedef VkResult (VKAPI *PFN_vkBindObjectMemory)(VkDevice device, VkObjectType objType, VkObject object, VkDeviceMemory mem, VkDeviceSize memOffset);
-typedef VkResult (VKAPI *PFN_vkGetObjectMemoryRequirements)(VkDevice device, VkObjectType objType, VkObject object, VkMemoryRequirements* pMemoryRequirements);
+typedef VkResult (VKAPI *PFN_vkBindBufferMemory)(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset);
+typedef VkResult (VKAPI *PFN_vkBindImageMemory)(VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset);
+typedef VkResult (VKAPI *PFN_vkGetBufferMemoryRequirements)(VkDevice device, VkBuffer buffer, VkMemoryRequirements* pMemoryRequirements);
+typedef VkResult (VKAPI *PFN_vkGetImageMemoryRequirements)(VkDevice device, VkImage image, VkMemoryRequirements* pMemoryRequirements);
typedef VkResult (VKAPI *PFN_vkQueueBindSparseBufferMemory)(VkQueue queue, VkBuffer buffer, VkDeviceSize rangeOffset, VkDeviceSize rangeSize, VkDeviceMemory mem, VkDeviceSize memOffset);
typedef VkResult (VKAPI *PFN_vkQueueBindSparseImageMemory)(VkQueue queue, VkImage image, const VkImageMemoryBindInfo* pBindInfo, VkDeviceMemory mem, VkDeviceSize memOffset);
typedef VkResult (VKAPI *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo* pCreateInfo, VkFence* pFence);
VkObjectType objType,
VkObject object);
-VkResult VKAPI vkBindObjectMemory(
+VkResult VKAPI vkBindBufferMemory(
VkDevice device,
- VkObjectType objType,
- VkObject object,
+ VkBuffer buffer,
VkDeviceMemory mem,
VkDeviceSize memOffset);
-VkResult VKAPI vkGetObjectMemoryRequirements(
+VkResult VKAPI vkBindImageMemory(
VkDevice device,
- VkObjectType objType,
- VkObject object,
+ VkImage image,
+ VkDeviceMemory mem,
+ VkDeviceSize memOffset);
+
+VkResult VKAPI vkGetBufferMemoryRequirements(
+ VkDevice device,
+ VkBuffer buffer,
+ VkMemoryRequirements* pMemoryRequirements);
+
+VkResult VKAPI vkGetImageMemoryRequirements(
+ VkDevice device,
+ VkImage image,
VkMemoryRequirements* pMemoryRequirements);
VkResult VKAPI vkQueueBindSparseBufferMemory(
}
}
-VkResult anv_GetObjectMemoryRequirements(
+VkResult anv_GetBufferMemoryRequirements(
VkDevice device,
- VkObjectType objType,
- VkObject object,
+ VkBuffer _buffer,
VkMemoryRequirements* pMemoryRequirements)
{
+ ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
/* The Vulkan spec (git aaed022) says:
*
*/
pMemoryRequirements->memoryTypeBits = 1;
- switch (objType) {
- case VK_OBJECT_TYPE_BUFFER: {
- struct anv_buffer *buffer = anv_buffer_from_handle(object);
- pMemoryRequirements->size = buffer->size;
- pMemoryRequirements->alignment = 16;
- break;
- }
- case VK_OBJECT_TYPE_IMAGE: {
- struct anv_image *image = anv_image_from_handle(object);
- pMemoryRequirements->size = image->size;
- pMemoryRequirements->alignment = image->alignment;
- break;
- }
- default:
- pMemoryRequirements->size = 0;
- break;
- }
+ pMemoryRequirements->size = buffer->size;
+ pMemoryRequirements->alignment = 16;
return VK_SUCCESS;
}
-VkResult anv_BindObjectMemory(
+VkResult anv_GetImageMemoryRequirements(
VkDevice device,
- VkObjectType objType,
- VkObject object,
+ VkImage _image,
+ VkMemoryRequirements* pMemoryRequirements)
+{
+ ANV_FROM_HANDLE(anv_image, image, _image);
+
+ /* The Vulkan spec (git aaed022) says:
+ *
+ * memoryTypeBits is a bitfield and contains one bit set for every
+ * supported memory type for the resource. The bit `1<<i` is set if and
+ * only if the memory type `i` in the VkPhysicalDeviceMemoryProperties
+ * structure for the physical device is supported.
+ *
+ * We support exactly one memory type.
+ */
+ pMemoryRequirements->memoryTypeBits = 1;
+
+ pMemoryRequirements->size = image->size;
+ pMemoryRequirements->alignment = image->alignment;
+
+ return VK_SUCCESS;
+}
+
+VkResult anv_BindBufferMemory(
+ VkDevice device,
+ VkBuffer _buffer,
VkDeviceMemory _mem,
VkDeviceSize memOffset)
{
ANV_FROM_HANDLE(anv_device_memory, mem, _mem);
- struct anv_buffer *buffer;
- struct anv_image *image;
+ ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
- switch (objType) {
- case VK_OBJECT_TYPE_BUFFER:
- buffer = anv_buffer_from_handle(object);
- buffer->bo = &mem->bo;
- buffer->offset = memOffset;
- break;
- case VK_OBJECT_TYPE_IMAGE:
- image = anv_image_from_handle(object);
- image->bo = &mem->bo;
- image->offset = memOffset;
- break;
- default:
- break;
- }
+ buffer->bo = &mem->bo;
+ buffer->offset = memOffset;
+
+ return VK_SUCCESS;
+}
+
+VkResult anv_BindImageMemory(
+ VkDevice device,
+ VkImage _image,
+ VkDeviceMemory _mem,
+ VkDeviceSize memOffset)
+{
+ ANV_FROM_HANDLE(anv_device_memory, mem, _mem);
+ ANV_FROM_HANDLE(anv_image, image, _image);
+
+ image->bo = &mem->bo;
+ image->offset = memOffset;
return VK_SUCCESS;
}
},
(VkDeviceMemory *) &memory);
- anv_BindObjectMemory(VK_NULL_HANDLE,
- VK_OBJECT_TYPE_IMAGE,
- (VkImage) image,
- (VkDeviceMemory) memory, 0);
+ anv_BindImageMemory(VK_NULL_HANDLE,
+ anv_image_to_handle(image),
+ anv_device_memory_to_handle(memory), 0);
ret = anv_gem_set_tiling(device, memory->bo.gem_handle,
surface->stride, I915_TILING_X);