vulkan/android: improve memoryTypeBits reporting in AHB props query
Instead of reporting all memory types being compatible, at least we can limit the types to those compatible for dma-buf import. Optionally, we can do even better here to actually create the image or buffer with the AHB to get more accurate memory type bits for memory import. However, it is optional since we can touch up in the common layer upon actual AHB import time. Reviewed-by: Antonio Ospite <antonio.ospite@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36388>
This commit is contained in:
@@ -857,8 +857,6 @@ vk_common_GetAndroidHardwareBufferPropertiesANDROID(
|
||||
VkAndroidHardwareBufferPropertiesANDROID *pProperties)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_device, device, device_h);
|
||||
struct vk_physical_device *pdevice = device->physical;
|
||||
|
||||
VkResult result;
|
||||
|
||||
VkAndroidHardwareBufferFormatPropertiesANDROID *format_prop =
|
||||
@@ -897,13 +895,16 @@ vk_common_GetAndroidHardwareBufferPropertiesANDROID(
|
||||
assert(handle && handle->numFds > 0);
|
||||
pProperties->allocationSize = lseek(handle->data[0], 0, SEEK_END);
|
||||
|
||||
VkPhysicalDeviceMemoryProperties mem_props;
|
||||
VkMemoryFdPropertiesKHR fd_props = {
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_FD_PROPERTIES_KHR,
|
||||
};
|
||||
result = device->dispatch_table.GetMemoryFdPropertiesKHR(
|
||||
device_h, VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, handle->data[0],
|
||||
&fd_props);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
device->physical->dispatch_table.GetPhysicalDeviceMemoryProperties(
|
||||
(VkPhysicalDevice)pdevice, &mem_props);
|
||||
|
||||
/* All memory types. (Should we be smarter than this?) */
|
||||
pProperties->memoryTypeBits = (1u << mem_props.memoryTypeCount) - 1;
|
||||
pProperties->memoryTypeBits = fd_props.memoryTypeBits;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user