<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 7, 2017 at 6:48 AM, Chad Versace <span dir="ltr"><<a href="mailto:chadversary@chromium.org" target="_blank">chadversary@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The draft spec lives at<br>
<a href="http://kiwitree.net/~chadv/vulkan/#1.0-VK_EXT_external_memory_dma_buf" rel="noreferrer" target="_blank">http://kiwitree.net/~chadv/vul<wbr>kan/#1.0-VK_EXT_external_memor<wbr>y_dma_buf</a>.<br>
<br>
I plan to ask Khronos to merge the spec this week.<br>
---<br>
src/intel/vulkan/anv_device.<wbr>c | 13 ++++++-------<br>
src/intel/vulkan/anv_extensio<wbr>ns.py | 1 +<br>
src/intel/vulkan/anv_formats.<wbr>c | 23 ++++++++++++++++++++---<br>
3 files changed, 27 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_device.<wbr>c b/src/intel/vulkan/anv_device.<wbr>c<br>
index 67028e8da9f..a28eaf242ca 100644<br>
--- a/src/intel/vulkan/anv_device.<wbr>c<br>
+++ b/src/intel/vulkan/anv_device.<wbr>c<br>
@@ -1538,11 +1538,11 @@ VkResult anv_AllocateMemory(<br>
* ignored.<br>
*/<br>
if (fd_info && fd_info->handleType) {<br>
- /* At the moment, we only support the OPAQUE_FD memory type which is<br>
- * just a GEM buffer.<br>
- */<br>
+ /* At the moment, we support only the below handle types. */<br>
assert(fd_info->handleType ==<br>
- VK_EXTERNAL_MEMORY_HANDLE_TYP<wbr>E_OPAQUE_FD_BIT_KHR);<br>
+ VK_EXTERNAL_MEMORY_HANDLE_TYP<wbr>E_OPAQUE_FD_BIT_KHR ||<br>
+ fd_info->handleType ==<br>
+ VK_EXTERNAL_MEMORY_HANDLE_TYP<wbr>E_DMA_BUF_BIT_EXT);<br>
<br>
result = anv_bo_cache_import(device, &device->bo_cache,<br>
fd_info->fd, &mem->bo);<br>
@@ -1616,9 +1616,8 @@ VkResult anv_GetMemoryFdKHR(<br>
<br>
assert(pGetFdInfo->sType == VK_STRUCTURE_TYPE_MEMORY_GET_F<wbr>D_INFO_KHR);<br>
<br>
- /* We support only one handle type. */<br>
- assert(pGetFdInfo->handleType ==<br>
- VK_EXTERNAL_MEMORY_HANDLE_TYPE<wbr>_OPAQUE_FD_BIT_KHR);<br>
+ assert(pGetFdInfo->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE<wbr>_OPAQUE_FD_BIT_KHR ||<br>
+ pGetFdInfo->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE<wbr>_DMA_BUF_BIT_EXT);<br>
<br>
return anv_bo_cache_export(dev, &dev->bo_cache, mem->bo, pFd);<br>
}<br>
diff --git a/src/intel/vulkan/anv_extensi<wbr>ons.py b/src/intel/vulkan/anv_extensi<wbr>ons.py<br>
index b1e984b8cd0..093c89fef01 100644<br>
--- a/src/intel/vulkan/anv_extensi<wbr>ons.py<br>
+++ b/src/intel/vulkan/anv_extensi<wbr>ons.py<br>
@@ -86,6 +86,7 @@ EXTENSIONS = [<br>
Extension('VK_KHR_xlib_surfac<wbr>e', 6, 'VK_USE_PLATFORM_XLIB_KHR'),<br>
Extension('VK_KHX_multiview',<wbr> 1, True),<br>
Extension('VK_EXT_debug_repor<wbr>t', 8, True),<br>
+ Extension('VK_EXT_external_mem<wbr>ory_dma_buf', 1, True),<br>
]<br>
<br>
class VkVersion:<br>
diff --git a/src/intel/vulkan/anv_formats<wbr>.c b/src/intel/vulkan/anv_formats<wbr>.c<br>
index 810f26cc750..0dd990bb9a8 100644<br>
--- a/src/intel/vulkan/anv_formats<wbr>.c<br>
+++ b/src/intel/vulkan/anv_formats<wbr>.c<br>
@@ -860,7 +860,7 @@ VkResult anv_GetPhysicalDeviceImageForm<wbr>atProperties(<br>
pImageFormatProperties, NULL);<br>
}<br>
<br>
-static const VkExternalMemoryPropertiesKHR prime_fd_props = {<br>
+static const VkExternalMemoryPropertiesKHR opaque_fd_props = {<br>
/* If we can handle external, then we can both import and export it. */<br>
.externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_EXP<wbr>ORTABLE_BIT_KHR |<br>
VK_EXTERNAL_MEMORY_FEATURE_IMP<wbr>ORTABLE_BIT_KHR,<br>
@@ -871,6 +871,17 @@ static const VkExternalMemoryPropertiesKHR prime_fd_props = {<br>
VK_EXTERNAL_MEMORY_HANDLE_TYP<wbr>E_OPAQUE_FD_BIT_KHR,<br>
};<br>
<br>
+static const VkExternalMemoryPropertiesKHR dma_buf_props = {<br>
+ /* If we can handle external, then we can both import and export it. */<br>
+ .externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_EXP<wbr>ORTABLE_BIT_KHR |<br>
+ VK_EXTERNAL_MEMORY_FEATURE_IM<wbr>PORTABLE_BIT_KHR,<br>
+ /* For the moment, let's not support mixing and matching */<br>
+ .<wbr>exportFromImportedHandleTypes =<br>
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE<wbr>_DMA_BUF_BIT_EXT,<br>
+ .compatibleHandleTypes =<br>
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE<wbr>_DMA_BUF_BIT_EXT,<br>
+};<br></blockquote><div><br></div><div>My plan for this has always been to just add the DMA_BUF_BIT flags to prime_fd_props and use that for both types.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
VkResult anv_GetPhysicalDeviceImageForm<wbr>atProperties2KHR(<br>
VkPhysicalDevice physicalDevice,<br>
const VkPhysicalDeviceImageFormatInf<wbr>o2KHR* base_info,<br>
@@ -924,7 +935,10 @@ VkResult anv_GetPhysicalDeviceImageForm<wbr>atProperties2KHR(<br>
switch (external_info->handleType) {<br>
case VK_EXTERNAL_MEMORY_HANDLE_TYPE<wbr>_OPAQUE_FD_BIT_KHR:<br>
if (external_props)<br>
- external_props->externalMemory<wbr>Properties = prime_fd_props;<br>
+ external_props->externalMemory<wbr>Properties = opaque_fd_props;<br>
+ case VK_EXTERNAL_MEMORY_HANDLE_TYPE<wbr>_DMA_BUF_BIT_EXT:<br>
+ if (external_props)<br>
+ external_props->externalMemory<wbr>Properties = dma_buf_props;<br>
break;<br>
default:<br>
/* From the Vulkan 1.0.42 spec:<br>
@@ -1005,7 +1019,10 @@ void anv_GetPhysicalDeviceExternalB<wbr>ufferPropertiesKHR(<br>
<br>
switch (pExternalBufferInfo->handleTy<wbr>pe) {<br>
case VK_EXTERNAL_MEMORY_HANDLE_TYPE<wbr>_OPAQUE_FD_BIT_KHR:<br>
- pExternalBufferProperties->ext<wbr>ernalMemoryProperties = prime_fd_props;<br>
+ pExternalBufferProperties->ext<wbr>ernalMemoryProperties = opaque_fd_props;<br>
+ return;<br>
+ case VK_EXTERNAL_MEMORY_HANDLE_TYPE<wbr>_DMA_BUF_BIT_EXT:<br>
+ pExternalBufferProperties->ext<wbr>ernalMemoryProperties = dma_buf_props;<br>
return;<br>
default:<br>
goto unsupported;<br>
<span class="m_-2486189918822861436HOEnZb"><font color="#888888">--<br>
2.13.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>