Module: Mesa
Branch: main
Commit: 4eeabb59f59bf98f7db69754a00e4ba2452dea9f
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4eeabb59f59bf98f7db69754a00e4ba2452dea9f

Author: Mike Blumenkrantz <[email protected]>
Date:   Fri Apr 29 11:02:55 2022 -0400

zink: rebind resources for export as needed

exporting all resources breaks suballocation, so instead just use the
existing heuristics and then forcibly rebind resources as needed
for this functionality

Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16252>

---

 src/gallium/drivers/zink/zink_resource.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_resource.c 
b/src/gallium/drivers/zink/zink_resource.c
index a31173a3ea0..79338cf8a66 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -1193,6 +1193,15 @@ zink_resource_get_handle(struct pipe_screen *pscreen,
       if (whandle->type == WINSYS_HANDLE_TYPE_KMS) {
          whandle->handle = -1;
       } else {
+         if (!res->obj->exportable) {
+            assert(!res->all_binds); //TODO handle if problematic
+            assert(!zink_resource_usage_is_unflushed(res));
+            if (!add_resource_bind(screen->copy_context, res, ZINK_BIND_DMABUF 
| PIPE_BIND_SHARED))
+               return false;
+            screen->copy_context->base.flush(&screen->copy_context->base, 
NULL, 0);
+            obj = res->obj;
+         }
+
          VkMemoryGetFdInfoKHR fd_info = {0};
          int fd;
          fd_info.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR;

Reply via email to