The draft spec lives at http://kiwitree.net/~chadv/vulkan/#1.0-VK_EXT_external_memory_dma_buf.
I plan to ask Khronos to merge the spec this week. --- src/intel/vulkan/anv_device.c | 13 ++++++------- src/intel/vulkan/anv_extensions.py | 1 + src/intel/vulkan/anv_formats.c | 23 ++++++++++++++++++++--- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 67028e8da9f..a28eaf242ca 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -1538,11 +1538,11 @@ VkResult anv_AllocateMemory( * ignored. */ if (fd_info && fd_info->handleType) { - /* At the moment, we only support the OPAQUE_FD memory type which is - * just a GEM buffer. - */ + /* At the moment, we support only the below handle types. */ assert(fd_info->handleType == - VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR); + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR || + fd_info->handleType == + VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT); result = anv_bo_cache_import(device, &device->bo_cache, fd_info->fd, &mem->bo); @@ -1616,9 +1616,8 @@ VkResult anv_GetMemoryFdKHR( assert(pGetFdInfo->sType == VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR); - /* We support only one handle type. */ - assert(pGetFdInfo->handleType == - VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR); + assert(pGetFdInfo->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR || + pGetFdInfo->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT); return anv_bo_cache_export(dev, &dev->bo_cache, mem->bo, pFd); } diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py index b1e984b8cd0..093c89fef01 100644 --- a/src/intel/vulkan/anv_extensions.py +++ b/src/intel/vulkan/anv_extensions.py @@ -86,6 +86,7 @@ EXTENSIONS = [ Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'), Extension('VK_KHX_multiview', 1, True), Extension('VK_EXT_debug_report', 8, True), + Extension('VK_EXT_external_memory_dma_buf', 1, True), ] class VkVersion: diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index 810f26cc750..0dd990bb9a8 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -860,7 +860,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties( pImageFormatProperties, NULL); } -static const VkExternalMemoryPropertiesKHR prime_fd_props = { +static const VkExternalMemoryPropertiesKHR opaque_fd_props = { /* If we can handle external, then we can both import and export it. */ .externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_KHR | VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_KHR, @@ -871,6 +871,17 @@ static const VkExternalMemoryPropertiesKHR prime_fd_props = { VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR, }; +static const VkExternalMemoryPropertiesKHR dma_buf_props = { + /* If we can handle external, then we can both import and export it. */ + .externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_KHR | + VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_KHR, + /* For the moment, let's not support mixing and matching */ + .exportFromImportedHandleTypes = + VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, + .compatibleHandleTypes = + VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, +}; + VkResult anv_GetPhysicalDeviceImageFormatProperties2KHR( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR* base_info, @@ -924,7 +935,10 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2KHR( switch (external_info->handleType) { case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR: if (external_props) - external_props->externalMemoryProperties = prime_fd_props; + external_props->externalMemoryProperties = opaque_fd_props; + case VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT: + if (external_props) + external_props->externalMemoryProperties = dma_buf_props; break; default: /* From the Vulkan 1.0.42 spec: @@ -1005,7 +1019,10 @@ void anv_GetPhysicalDeviceExternalBufferPropertiesKHR( switch (pExternalBufferInfo->handleType) { case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR: - pExternalBufferProperties->externalMemoryProperties = prime_fd_props; + pExternalBufferProperties->externalMemoryProperties = opaque_fd_props; + return; + case VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT: + pExternalBufferProperties->externalMemoryProperties = dma_buf_props; return; default: goto unsupported; -- 2.13.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev