[Mesa-stable] [PATCH] auxiliary/vl: use the correct screen index

Emil Velikov emil.l.velikov at gmail.com
Fri Jul 10 10:46:17 PDT 2015


Inspired (copied) from Marek's commit for egl/x11
commit 0b56e23e7f3(egl/dri2: use the correct screen index)

Cc: 10.6 <mesa-stable at lists.freedesktop.org>
Cc: Marek Olšák <marek.olsak at amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/gallium/auxiliary/vl/vl_winsys_dri.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index 7e61b88..ac2feec 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -293,6 +293,16 @@ vl_screen_get_private(struct vl_screen *vscreen)
    return vscreen;
 }
 
+static xcb_screen_t *
+get_xcb_screen(xcb_screen_iterator_t iter, int screen)
+{
+    for (; iter.rem; --screen, xcb_screen_next(&iter))
+        if (screen == 0)
+            return iter.data;
+
+    return NULL;
+}
+
 struct vl_screen*
 vl_screen_create(Display *display, int screen)
 {
@@ -333,9 +343,11 @@ vl_screen_create(Display *display, int screen)
    if (dri2_query == NULL || error != NULL || dri2_query->minor_version < 2)
       goto free_query;
 
-   s = xcb_setup_roots_iterator(xcb_get_setup(scrn->conn));
-   while (screen--)
-	xcb_screen_next(&s);
+   s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn));
+   screen = get_xcb_screen(s, dri2_dpy->screen);
+   if (!screen)
+      goto free_query;
+
    driverType = XCB_DRI2_DRIVER_TYPE_DRI;
 #ifdef DRI2DriverPrimeShift
    {
-- 
2.4.5



More information about the mesa-stable mailing list