From c1d9f17d856a1829c5e717db88c013e48986f52a Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 17 Feb 2017 22:51:07 -0800 Subject: [PATCH] vulkan/wsi: Improve the DRI3 error message This commit improves the message by suggesting that users with custom xorg.conf files double-check DRI3. More importantly, it includes a little heuristic to check to see if we're running on AMD or NVIDIA's proprietary X11 drivers and, if we are, doesn't emit the warning. This way, users with both a discrete card and Intel graphics don't get the warning when they're just running on the discrete card. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99715 Cc: Rene Lindsay Cc: Jacob Lifshay --- src/vulkan/wsi/wsi_common_x11.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 64ba921..2ca9e63 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -49,6 +49,7 @@ struct wsi_x11_connection { bool has_dri3; bool has_present; + bool is_proprietary_x11; }; struct wsi_x11 { @@ -63,8 +64,8 @@ static struct wsi_x11_connection * wsi_x11_connection_create(const VkAllocationCallbacks *alloc, xcb_connection_t *conn) { - xcb_query_extension_cookie_t dri3_cookie, pres_cookie; - xcb_query_extension_reply_t *dri3_reply, *pres_reply; + xcb_query_extension_cookie_t dri3_cookie, pres_cookie, amd_cookie, nv_cookie; + xcb_query_extension_reply_t *dri3_reply, *pres_reply, *amd_reply, *nv_reply; struct wsi_x11_connection *wsi_conn = vk_alloc(alloc, sizeof(*wsi_conn), 8, @@ -75,20 +76,39 @@ wsi_x11_connection_create(const VkAllocationCallbacks *alloc, dri3_cookie = xcb_query_extension(conn, 4, "DRI3"); pres_cookie = xcb_query_extension(conn, 7, "PRESENT"); + /* We try to be nice to users and emit a warning if they try to use a + * Vulkan application on a system without DRI3 enabled. However, this ends + * up spewing the warning when a user has, for example, both Intel + * integrated graphics and a discrete card with proprietary driers and are + * running on the discrete card with the proprietary DDX. In this case, we + * really don't want to print the warning because it just confuses users. + * As a heuristic to detect this case, we check for a couple of proprietary + * X11 extensions. + */ + amd_cookie = xcb_query_extension(conn, 4, "ATIFGLRXDRI"); + nv_cookie = xcb_query_extension(conn, 4, "NV-CONTROL"); + dri3_reply = xcb_query_extension_reply(conn, dri3_cookie, NULL); pres_reply = xcb_query_extension_reply(conn, pres_cookie, NULL); - if (dri3_reply == NULL || pres_reply == NULL) { + amd_reply = xcb_query_extension_reply(conn, amd_cookie, NULL); + nv_reply = xcb_query_extension_reply(conn, nv_cookie, NULL); + if (!dri3_reply || !pres_reply || !amd_reply || !nv_reply) { free(dri3_reply); free(pres_reply); + free(amd_reply); + free(nv_reply); vk_free(alloc, wsi_conn); return NULL; } wsi_conn->has_dri3 = dri3_reply->present != 0; wsi_conn->has_present = pres_reply->present != 0; + wsi_conn->is_proprietary_x11 = amd_reply->present || nv_reply->present; free(dri3_reply); free(pres_reply); + free(amd_reply); + free(nv_reply); return wsi_conn; } @@ -265,8 +285,11 @@ VkBool32 wsi_get_physical_device_xcb_presentation_support( return false; if (!wsi_conn->has_dri3) { - fprintf(stderr, "vulkan: No DRI3 support detected - required for presentation\n"); - fprintf(stderr, "Note: Buggy applications may crash, if they do please report to vendor\n"); + if (!wsi_conn->is_proprietary_x11) { + fprintf(stderr, "vulkan: No DRI3 support detected - required for presentation\n"); + fprintf(stderr, "If you have manually modified xorg.conf, please ensure DRI3 is enabled\n" + fprintf(stderr, "Note: Buggy applications may crash, if they do please report to vendor\n"); + } return false; } -- 2.5.0.400.gff86faf