From: Jason Ekstrand Date: Wed, 8 Jul 2015 01:16:42 +0000 (-0700) Subject: vk/vulkan.h: Switch from GetObjectInfo to GetMemoryRequirements X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ef8980e256c30fa672efd515e768a1405752d803;p=mesa.git vk/vulkan.h: Switch from GetObjectInfo to GetMemoryRequirements --- diff --git a/include/vulkan/vulkan.h b/include/vulkan/vulkan.h index 8cb9827eae2..8a593556414 100644 --- a/include/vulkan/vulkan.h +++ b/include/vulkan/vulkan.h @@ -1113,14 +1113,6 @@ typedef enum { VK_ENUM_RANGE(SUBRESOURCE_INFO_TYPE, LAYOUT, LAYOUT) } VkSubresourceInfoType; -typedef enum { - // Info type for vkGetObjectInfo() - VK_OBJECT_INFO_TYPE_MEMORY_ALLOCATION_COUNT = 0x00000000, - VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS = 0x00000001, - - VK_ENUM_RANGE(OBJECT_INFO_TYPE, MEMORY_ALLOCATION_COUNT, MEMORY_REQUIREMENTS) -} VkObjectInfoType; - // Physical device compatibility flags typedef VkFlags VkPhysicalDeviceCompatibilityFlags; @@ -1930,8 +1922,8 @@ typedef VkResult (VKAPI *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory mem) 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_vkGetObjectInfo)(VkDevice device, VkObjectType objType, VkObject object, VkObjectInfoType infoType, size_t* pDataSize, void* pData); typedef VkResult (VKAPI *PFN_vkQueueBindObjectMemory)(VkQueue queue, VkObjectType objType, VkObject object, uint32_t allocationIdx, VkDeviceMemory mem, VkDeviceSize offset); +typedef VkResult (VKAPI *PFN_vkGetObjectMemoryRequirements)(VkDevice device, VkObjectType objType, VkObject object, VkMemoryRequirements* pMemoryRequirements); typedef VkResult (VKAPI *PFN_vkQueueBindObjectMemoryRange)(VkQueue queue, VkObjectType objType, VkObject object, uint32_t allocationIdx, VkDeviceSize rangeOffset, VkDeviceSize rangeSize, VkDeviceMemory mem, VkDeviceSize memOffset); typedef VkResult (VKAPI *PFN_vkQueueBindImageMemoryRange)(VkQueue queue, VkImage image, uint32_t allocationIdx, const VkImageMemoryBindInfo* pBindInfo, VkDeviceMemory mem, VkDeviceSize memOffset); typedef VkResult (VKAPI *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo* pCreateInfo, VkFence* pFence); @@ -2122,14 +2114,6 @@ VkResult VKAPI vkDestroyObject( VkObjectType objType, VkObject object); -VkResult VKAPI vkGetObjectInfo( - VkDevice device, - VkObjectType objType, - VkObject object, - VkObjectInfoType infoType, - size_t* pDataSize, - void* pData); - VkResult VKAPI vkQueueBindObjectMemory( VkQueue queue, VkObjectType objType, @@ -2138,6 +2122,12 @@ VkResult VKAPI vkQueueBindObjectMemory( VkDeviceMemory mem, VkDeviceSize memOffset); +VkResult VKAPI vkGetObjectMemoryRequirements( + VkDevice device, + VkObjectType objType, + VkObject object, + VkMemoryRequirements* pMemoryRequirements); + VkResult VKAPI vkQueueBindObjectMemoryRange( VkQueue queue, VkObjectType objType, diff --git a/src/vulkan/device.c b/src/vulkan/device.c index 83c3908b4fd..53c29cafb3d 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -1076,85 +1076,39 @@ VkResult anv_DestroyObject( } } -static void -fill_memory_requirements( +VkResult anv_GetObjectMemoryRequirements( + VkDevice device, VkObjectType objType, VkObject object, - VkMemoryRequirements * memory_requirements) + VkMemoryRequirements* pMemoryRequirements) { - struct anv_buffer *buffer; - struct anv_image *image; - - memory_requirements->memPropsAllowed = + pMemoryRequirements->memPropsAllowed = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | /* VK_MEMORY_PROPERTY_HOST_NON_COHERENT_BIT | */ /* VK_MEMORY_PROPERTY_HOST_UNCACHED_BIT | */ VK_MEMORY_PROPERTY_HOST_WRITE_COMBINED_BIT; - memory_requirements->memPropsRequired = 0; + pMemoryRequirements->memPropsRequired = 0; switch (objType) { - case VK_OBJECT_TYPE_BUFFER: - buffer = (struct anv_buffer *) object; - memory_requirements->size = buffer->size; - memory_requirements->alignment = 16; - break; - case VK_OBJECT_TYPE_IMAGE: - image = (struct anv_image *) object; - memory_requirements->size = image->size; - memory_requirements->alignment = image->alignment; - break; - default: - memory_requirements->size = 0; + case VK_OBJECT_TYPE_BUFFER: { + struct anv_buffer *buffer = (struct anv_buffer *) object; + pMemoryRequirements->size = buffer->size; + pMemoryRequirements->alignment = 16; break; } -} - -static uint32_t -get_allocation_count(VkObjectType objType) -{ - switch (objType) { - case VK_OBJECT_TYPE_BUFFER: - case VK_OBJECT_TYPE_IMAGE: - return 1; - default: - return 0; + case VK_OBJECT_TYPE_IMAGE: { + struct anv_image *image = (struct anv_image *) object; + pMemoryRequirements->size = image->size; + pMemoryRequirements->alignment = image->alignment; + break; } -} - -VkResult anv_GetObjectInfo( - VkDevice _device, - VkObjectType objType, - VkObject object, - VkObjectInfoType infoType, - size_t* pDataSize, - void* pData) -{ - VkMemoryRequirements memory_requirements; - uint32_t *count; - - switch (infoType) { - case VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS: - *pDataSize = sizeof(memory_requirements); - if (pData == NULL) - return VK_SUCCESS; - - fill_memory_requirements(objType, object, pData); - return VK_SUCCESS; - - case VK_OBJECT_INFO_TYPE_MEMORY_ALLOCATION_COUNT: - *pDataSize = sizeof(count); - if (pData == NULL) - return VK_SUCCESS; - - count = pData; - *count = get_allocation_count(objType); - return VK_SUCCESS; - default: - return vk_error(VK_UNSUPPORTED); + pMemoryRequirements->size = 0; + break; } + return VK_SUCCESS; } VkResult anv_QueueBindObjectMemory(