diff options
author | Marek Olšák <[email protected]> | 2014-08-20 00:33:34 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2014-09-01 20:09:19 +0200 |
commit | 0b56e23e7f3d5852a90e965b2958fd446270a7f8 (patch) | |
tree | bab07c5fc3ff581f42c888c3ab6730ee369a7454 | |
parent | 1a428a52566521bcd86299904eeea19a0b7aecb5 (diff) |
egl/dri2: use the correct screen index
Required for multi-GPU configuration where each GPU has its own X screen.
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.h | 1 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_x11.c | 39 |
2 files changed, 30 insertions, 10 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index 0dd9d69d08e..52f05fbfd3c 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -184,6 +184,7 @@ struct dri2_egl_display #ifdef HAVE_X11_PLATFORM xcb_connection_t *conn; + int screen; #endif #ifdef HAVE_WAYLAND_PLATFORM diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index 4ef1f3e4b44..a7a73383cbe 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -178,6 +178,17 @@ swrastGetImage(__DRIdrawable * read, } +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; +} + + /** * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). */ @@ -214,7 +225,8 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, dri2_surf->drawable = xcb_generate_id(dri2_dpy->conn); s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn)); xcb_create_pixmap(dri2_dpy->conn, conf->BufferSize, - dri2_surf->drawable, s.data->root, + dri2_surf->drawable, + get_xcb_screen(s, dri2_dpy->screen)->root, dri2_surf->base.Width, dri2_surf->base.Height); } else { dri2_surf->drawable = drawable; @@ -515,9 +527,9 @@ dri2_x11_connect(struct dri2_egl_display *dri2_dpy) XCB_DRI2_MINOR_VERSION); s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn)); - connect_cookie = xcb_dri2_connect_unchecked (dri2_dpy->conn, - s.data->root, - XCB_DRI2_DRIVER_TYPE_DRI); + connect_cookie = xcb_dri2_connect_unchecked(dri2_dpy->conn, + get_xcb_screen(s, dri2_dpy->screen)->root, + XCB_DRI2_DRIVER_TYPE_DRI); xfixes_query = xcb_xfixes_query_version_reply (dri2_dpy->conn, @@ -581,7 +593,8 @@ dri2_x11_authenticate(_EGLDisplay *disp, uint32_t id) s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn)); authenticate_cookie = - xcb_dri2_authenticate_unchecked(dri2_dpy->conn, s.data->root, id); + xcb_dri2_authenticate_unchecked(dri2_dpy->conn, + get_xcb_screen(s, dri2_dpy->screen)->root, id); authenticate = xcb_dri2_authenticate_reply(dri2_dpy->conn, authenticate_cookie, NULL); @@ -630,7 +643,7 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy, }; s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn)); - d = xcb_screen_allowed_depths_iterator(s.data); + d = xcb_screen_allowed_depths_iterator(get_xcb_screen(s, dri2_dpy->screen)); id = 1; surface_type = @@ -1065,10 +1078,13 @@ dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp) disp->DriverData = (void *) dri2_dpy; if (disp->PlatformDisplay == NULL) { - dri2_dpy->conn = xcb_connect(0, 0); + dri2_dpy->conn = xcb_connect(0, &dri2_dpy->screen); dri2_dpy->own_device = true; } else { - dri2_dpy->conn = XGetXCBConnection((Display *) disp->PlatformDisplay); + Display *dpy = disp->PlatformDisplay; + + dri2_dpy->conn = XGetXCBConnection(dpy); + dri2_dpy->screen = DefaultScreen(dpy); } if (xcb_connection_has_error(dri2_dpy->conn)) { @@ -1185,10 +1201,13 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp) disp->DriverData = (void *) dri2_dpy; if (disp->PlatformDisplay == NULL) { - dri2_dpy->conn = xcb_connect(0, 0); + dri2_dpy->conn = xcb_connect(0, &dri2_dpy->screen); dri2_dpy->own_device = true; } else { - dri2_dpy->conn = XGetXCBConnection((Display *) disp->PlatformDisplay); + Display *dpy = disp->PlatformDisplay; + + dri2_dpy->conn = XGetXCBConnection(dpy); + dri2_dpy->screen = DefaultScreen(dpy); } if (xcb_connection_has_error(dri2_dpy->conn)) { |