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.
(cherry picked from commit cf588ab3f1)
This commit is contained in:
Chia-I Wu 2010-07-06 14:34:43 +08:00
parent 6afe2936f7
commit f6bba7b996
6 changed files with 86 additions and 42 deletions

View file

@ -699,7 +699,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
@ -1216,6 +1216,10 @@ yes)
if test "x$enable_egl" != xyes; then
AC_MSG_ERROR([cannot build egl state tracker without EGL library])
fi
# 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
;;
xorg)
PKG_CHECK_MODULES([LIBDRM_XORG], [libdrm >= $LIBDRM_XORG_REQUIRED])

View file

@ -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 */

View file

@ -37,6 +37,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,
@ -878,3 +880,15 @@ x11_create_dri2_display(EGLNativeDisplayType dpy,
return &dri2dpy->base;
}
#else /* GLX_DIRECT_RENDERING */
struct native_display *
x11_create_dri2_display(EGLNativeDisplayType dpy,
struct native_event_handler *event_handler,
struct drm_api *api)
{
return NULL;
}
#endif /* GLX_DIRECT_RENDERING */

View file

@ -70,7 +70,9 @@ native_create_probe(EGLNativeDisplayType dpy)
xscr = x11_screen_create(xdpy, scr);
if (xscr) {
if (x11_screen_support(xscr, X11_SCREEN_EXTENSION_DRI2)) {
#ifdef GLX_DIRECT_RENDERING
driver_name = x11_screen_probe_dri2(xscr, NULL, NULL);
#endif
if (driver_name)
nprobe->data = strdup(driver_name);
}

View file

@ -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;
}
@ -233,6 +243,39 @@ x11_screen_convert_visual(struct x11_screen *xscr, const XVisualInfo *visual,
mode->xRenderable = TRUE;
}
/**
* 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.
*/
@ -391,37 +434,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.
*/
@ -489,3 +501,5 @@ dri2InvalidateBuffers(Display *dpy, XID drawable)
xscr->dri_invalidate_buffers(xscr, drawable, xscr->dri_user_data);
}
#endif /* GLX_DIRECT_RENDERING */

View file

@ -68,20 +68,18 @@ void
x11_screen_convert_visual(struct x11_screen *xscr, const XVisualInfo *visual,
__GLcontextModes *mode);
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);
@ -91,6 +89,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);
@ -105,7 +112,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_ */