Mesa (master): vulkan/wsi/x11: Destroy Present event context when destroying swapchain

Michel Dänzer daenzer at kemper.freedesktop.org
Wed Nov 30 03:36:36 UTC 2016


Module: Mesa
Branch: master
Commit: 550cd272b4b97fc06dbd3b5fad2bf0e5d526236d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=550cd272b4b97fc06dbd3b5fad2bf0e5d526236d

Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Jul 28 17:54:49 2016 +0900

vulkan/wsi/x11: Destroy Present event context when destroying swapchain

Without this, the X server may accumulate stale Present event contexts
if a client creates and destroys multiple swapchains using the same
window.

v2: Based on Chris Wilson's review:
* Use xcb_present_select_input_checked so that protocol errors
  generated by old X servers can be handled gracefully
* Use xcb_discard_reply() instead of free(xcb_request_check())
v3: Rebased on top of this code having been refactored out of anv

Reviewed-by: Dave Airlie <airlied at redhat.com>

---

 src/vulkan/wsi/wsi_common_x11.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 8e0043f..56398ce 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -891,6 +891,8 @@ x11_swapchain_destroy(struct wsi_swapchain *anv_chain,
                       const VkAllocationCallbacks *pAllocator)
 {
    struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
+   xcb_void_cookie_t cookie;
+
    for (uint32_t i = 0; i < chain->image_count; i++)
       x11_image_finish(chain, pAllocator, &chain->images[i]);
 
@@ -904,6 +906,10 @@ x11_swapchain_destroy(struct wsi_swapchain *anv_chain,
    }
 
    xcb_unregister_for_special_event(chain->conn, chain->special_event);
+   cookie = xcb_present_select_input_checked(chain->conn, chain->event_id,
+                                             chain->window,
+                                             XCB_PRESENT_EVENT_MASK_NO_EVENT);
+   xcb_discard_reply(chain->conn, cookie.sequence);
 
    vk_free(pAllocator, chain);
 




More information about the mesa-commit mailing list