<div dir="ltr">You're missing one other caller in anv_queue.c<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 16, 2017 at 11:55 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">This will allow us to implement VK_ANDROID_native_buffer without dup'ing<br>
the fd. We must close the fd in VK_KHR_external_memory_fd, but we should<br>
not in VK_ANDROID_native_buffer.<br>
---<br>
src/intel/vulkan/anv_<wbr>allocator.c | 12 ------------<br>
src/intel/vulkan/anv_device.c | 11 +++++++++++<br>
src/intel/vulkan/anv_intel.c | 2 ++<br>
3 files changed, 13 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_<wbr>allocator.c b/src/intel/vulkan/anv_<wbr>allocator.c<br>
index 0f123563f7..401cea40e6 100644<br>
--- a/src/intel/vulkan/anv_<wbr>allocator.c<br>
+++ b/src/intel/vulkan/anv_<wbr>allocator.c<br>
@@ -1324,18 +1324,6 @@ anv_bo_cache_import(struct anv_device *device,<br>
}<br>
<br>
pthread_mutex_unlock(&cache-><wbr>mutex);<br>
-<br>
- /* From the Vulkan spec:<br>
- *<br>
- * "Importing memory from a file descriptor transfers ownership of<br>
- * the file descriptor from the application to the Vulkan<br>
- * implementation. The application must not perform any operations on<br>
- * the file descriptor after a successful import."<br>
- *<br>
- * If the import fails, we leave the file descriptor open.<br>
- */<br>
- close(fd);<br>
-<br>
*bo_out = &bo->bo;<br>
<br>
return VK_SUCCESS;<br>
diff --git a/src/intel/vulkan/anv_device.<wbr>c b/src/intel/vulkan/anv_device.<wbr>c<br>
index 2c10a2fe7f..1634b5158c 100644<br>
--- a/src/intel/vulkan/anv_device.<wbr>c<br>
+++ b/src/intel/vulkan/anv_device.<wbr>c<br>
@@ -1547,6 +1547,17 @@ VkResult anv_AllocateMemory(<br>
&mem->bo);<br>
if (result != VK_SUCCESS)<br>
goto fail;<br>
+<br>
+ /* From the Vulkan spec:<br>
+ *<br>
+ * "Importing memory from a file descriptor transfers ownership of<br>
+ * the file descriptor from the application to the Vulkan<br>
+ * implementation. The application must not perform any operations on<br>
+ * the file descriptor after a successful import."<br>
+ *<br>
+ * If the import fails, we leave the file descriptor open.<br>
+ */<br>
+ close(fd_info->fd);<br>
} else {<br>
result = anv_bo_cache_alloc(device, &device->bo_cache,<br>
pAllocateInfo->allocationSize,<br>
diff --git a/src/intel/vulkan/anv_intel.c b/src/intel/vulkan/anv_intel.c<br>
index 9f8cd92734..d6bad44091 100644<br>
--- a/src/intel/vulkan/anv_intel.c<br>
+++ b/src/intel/vulkan/anv_intel.c<br>
@@ -71,6 +71,8 @@ VkResult anv_CreateDmaBufImageINTEL(<br>
if (result != VK_SUCCESS)<br>
goto fail;<br>
<br>
+ close(pCreateInfo->fd);<br>
+<br>
image = anv_image_from_handle(image_h)<wbr>;<br>
<br>
result = anv_bo_cache_import(device, &device->bo_cache,<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.13.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">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>