From cf588ab3f1edb89be4cd57045a3888ff482fa817 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 6 Jul 2010 14:34:43 +0800 Subject: st/egl: Add support for !GLX_DIRECT_RENDERING. st/egl uses GLX code for DRI2 support. It should honor GLX_DIRECT_RENDERING. Also updates configure.ac to define GLX_DIRECT_RENDERING for st/egl. --- configure.ac | 6 +- src/gallium/state_trackers/egl/x11/glxinit.c | 4 ++ src/gallium/state_trackers/egl/x11/native_dri2.c | 14 +++++ src/gallium/state_trackers/egl/x11/x11_screen.c | 76 ++++++++++++++---------- src/gallium/state_trackers/egl/x11/x11_screen.h | 26 ++++---- 5 files changed, 84 insertions(+), 42 deletions(-) diff --git a/configure.ac b/configure.ac index 16fd1e43bb..f66b93c791 100644 --- a/configure.ac +++ b/configure.ac @@ -680,7 +680,7 @@ AC_SUBST([DRI_DRIVER_SEARCH_DIR]) dnl Direct rendering or just indirect rendering AC_ARG_ENABLE([driglx-direct], [AS_HELP_STRING([--disable-driglx-direct], - [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])], + [enable direct rendering in GLX and EGL for DRI @<:@default=enabled@:>@])], [driglx_direct="$enableval"], [driglx_direct="yes"]) dnl Which drivers to build - default is chosen by platform @@ -1292,6 +1292,10 @@ AC_SUBST([EGL_CLIENT_APIS]) if test "x$HAVE_ST_EGL" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl" + # define GLX_DIRECT_RENDERING even when the driver is not dri + if test "x$mesa_driver" != xdri -a "x$driglx_direct" = xyes; then + DEFINES="$DEFINES -DGLX_DIRECT_RENDERING" + fi fi if test "x$HAVE_ST_XORG" = xyes; then diff --git a/src/gallium/state_trackers/egl/x11/glxinit.c b/src/gallium/state_trackers/egl/x11/glxinit.c index 1ed2afd345..dd351899e2 100644 --- a/src/gallium/state_trackers/egl/x11/glxinit.c +++ b/src/gallium/state_trackers/egl/x11/glxinit.c @@ -16,6 +16,8 @@ #include "glxinit.h" +#ifdef GLX_DIRECT_RENDERING + typedef struct GLXGenericGetString { CARD8 reqType; @@ -680,3 +682,5 @@ __glXInitialize(Display * dpy) return dpyPriv; } + +#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index 1bef59d864..1be1e42468 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -38,6 +38,8 @@ #include "native_x11.h" #include "x11_screen.h" +#ifdef GLX_DIRECT_RENDERING + enum dri2_surface_type { DRI2_SURFACE_TYPE_WINDOW, DRI2_SURFACE_TYPE_PIXMAP, @@ -784,3 +786,15 @@ x11_create_dri2_display(Display *dpy, return &dri2dpy->base; } + +#else /* GLX_DIRECT_RENDERING */ + +struct native_display * +x11_create_dri2_display(Display *dpy, + struct native_event_handler *event_handler, + void *user_data) +{ + return NULL; +} + +#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c b/src/gallium/state_trackers/egl/x11/x11_screen.c index 6bdff26ec0..6a22b30c4d 100644 --- a/src/gallium/state_trackers/egl/x11/x11_screen.c +++ b/src/gallium/state_trackers/egl/x11/x11_screen.c @@ -39,8 +39,10 @@ #include "glxinit.h" struct x11_screen { +#ifdef GLX_DIRECT_RENDERING /* dummy base class */ struct __GLXDRIdisplayRec base; +#endif Display *dpy; int number; @@ -103,15 +105,19 @@ x11_screen_destroy(struct x11_screen *xscr) if (xscr->dri_device) Xfree(xscr->dri_device); +#ifdef GLX_DIRECT_RENDERING /* xscr->glx_dpy will be destroyed with the X display */ if (xscr->glx_dpy) xscr->glx_dpy->dri2Display = NULL; +#endif if (xscr->visuals) XFree(xscr->visuals); FREE(xscr); } +#ifdef GLX_DIRECT_RENDERING + static boolean x11_screen_init_dri2(struct x11_screen *xscr) { @@ -133,6 +139,8 @@ x11_screen_init_glx(struct x11_screen *xscr) return (xscr->glx_dpy != NULL); } +#endif /* GLX_DIRECT_RENDERING */ + /** * Return true if the screen supports the extension. */ @@ -145,12 +153,14 @@ x11_screen_support(struct x11_screen *xscr, enum x11_screen_extension ext) case X11_SCREEN_EXTENSION_XSHM: supported = XShmQueryExtension(xscr->dpy); break; +#ifdef GLX_DIRECT_RENDERING case X11_SCREEN_EXTENSION_GLX: supported = x11_screen_init_glx(xscr); break; case X11_SCREEN_EXTENSION_DRI2: supported = x11_screen_init_dri2(xscr); break; +#endif default: break; } @@ -176,6 +186,39 @@ x11_screen_get_visuals(struct x11_screen *xscr, int *num_visuals) return xscr->visuals; } +/** + * Return the depth of a drawable. + * + * Unlike other drawable functions, the drawable needs not be a DRI2 drawable. + */ +uint +x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable) +{ + unsigned int depth; + + if (drawable != xscr->last_drawable) { + Window root; + int x, y; + unsigned int w, h, border; + Status ok; + + ok = XGetGeometry(xscr->dpy, drawable, &root, + &x, &y, &w, &h, &border, &depth); + if (!ok) + depth = 0; + + xscr->last_drawable = drawable; + xscr->last_depth = depth; + } + else { + depth = xscr->last_depth; + } + + return depth; +} + +#ifdef GLX_DIRECT_RENDERING + /** * Return the GLX fbconfigs. */ @@ -334,37 +377,6 @@ x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable, return (struct x11_drawable_buffer *) dri2bufs; } -/** - * Return the depth of a drawable. - * - * Unlike other drawable functions, the drawable needs not be a DRI2 drawable. - */ -uint -x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable) -{ - unsigned int depth; - - if (drawable != xscr->last_drawable) { - Window root; - int x, y; - unsigned int w, h, border; - Status ok; - - ok = XGetGeometry(xscr->dpy, drawable, &root, - &x, &y, &w, &h, &border, &depth); - if (!ok) - depth = 0; - - xscr->last_drawable = drawable; - xscr->last_depth = depth; - } - else { - depth = xscr->last_depth; - } - - return depth; -} - /** * Create a mode list of the given size. */ @@ -432,3 +444,5 @@ dri2InvalidateBuffers(Display *dpy, XID drawable) xscr->dri_invalidate_buffers(xscr, drawable, xscr->dri_user_data); } + +#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.h b/src/gallium/state_trackers/egl/x11/x11_screen.h index a3c5ee1491..bc0ef69ec6 100644 --- a/src/gallium/state_trackers/egl/x11/x11_screen.h +++ b/src/gallium/state_trackers/egl/x11/x11_screen.h @@ -67,20 +67,18 @@ x11_screen_support(struct x11_screen *xscr, enum x11_screen_extension ext); const XVisualInfo * x11_screen_get_visuals(struct x11_screen *xscr, int *num_visuals); +uint +x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable); + +#ifdef GLX_DIRECT_RENDERING + +/* GLX */ const __GLcontextModes * x11_screen_get_glx_configs(struct x11_screen *xscr); const __GLcontextModes * x11_screen_get_glx_visuals(struct x11_screen *xscr); -const char * -x11_screen_probe_dri2(struct x11_screen *xscr, int *major, int *minor); - -int -x11_screen_enable_dri2(struct x11_screen *xscr, - x11_drawable_invalidate_buffers invalidate_buffers, - void *user_data); - __GLcontextModes * x11_context_modes_create(unsigned count); @@ -90,6 +88,15 @@ x11_context_modes_destroy(__GLcontextModes *modes); unsigned x11_context_modes_count(const __GLcontextModes *modes); +/* DRI2 */ +const char * +x11_screen_probe_dri2(struct x11_screen *xscr, int *major, int *minor); + +int +x11_screen_enable_dri2(struct x11_screen *xscr, + x11_drawable_invalidate_buffers invalidate_buffers, + void *user_data); + void x11_drawable_enable_dri2(struct x11_screen *xscr, Drawable drawable, boolean on); @@ -104,7 +111,6 @@ x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable, int *width, int *height, unsigned int *attachments, boolean with_format, int num_ins, int *num_outs); -uint -x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable); +#endif /* GLX_DIRECT_RENDERING */ #endif /* _X11_SCREEN_H_ */ -- cgit v1.2.3