From 68c3c6eb0cafd5eb2c208dd76a3a65187256700c Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Tue, 2 Aug 2011 15:54:15 +0800 Subject: [PATCH] glamor-es2: Add gles2 option. First commit to enable gles2 support. --enable-glamor-ddx --enable-glamor-gles2 will set thwo MACROs GLAMOR_DDX and GLAMOR_GLES2. Currently, the gles2 support is still incomplete. Signed-off-by: Zhigang Gong --- Makefile.am | 6 +++++- configure.ac | 23 +++++++++++++++++++++++ glamor/glamor_priv.h | 18 ++++++++++++++++++ hw/xfree86/Makefile.am | 8 ++++++-- hw/xfree86/common/xf86pciBus.c | 4 ++++ hw/xfree86/glamor/Makefile.am | 7 +++++-- hw/xfree86/glamor/glamor.c | 7 ++++++- hw/xfree86/glamor/glamor_crtc.c | 18 ++++++++++++++++-- include/xorg-config.h.in | 11 +++++++++++ 9 files changed, 94 insertions(+), 8 deletions(-) diff --git a/Makefile.am b/Makefile.am index 0c701633d..632258eec 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,6 +17,10 @@ if RECORD RECORD_DIR=record endif +if GLAMOR +GLAMOR_DIR=glamor +endif + SUBDIRS = \ doc \ man \ @@ -38,7 +42,7 @@ SUBDIRS = \ $(COMPOSITE_DIR) \ $(GLX_DIR) \ exa \ - glamor \ + $(GLAMOR_DIR) \ config \ hw \ test diff --git a/configure.ac b/configure.ac index caefc4674..73c1bea0e 100644 --- a/configure.ac +++ b/configure.ac @@ -646,6 +646,8 @@ AC_ARG_ENABLE(xnest, AS_HELP_STRING([--enable-xnest], [Build Xnest serv AC_ARG_ENABLE(xquartz, AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto]) AC_ARG_ENABLE(standalone-xpbproxy, AS_HELP_STRING([--enable-standalone-xpbproxy], [Build a standalone xpbproxy (in addition to the one integrated into Xquartz as a separate thread) (default: no)]), [STANDALONE_XPBPROXY=$enableval], [STANDALONE_XPBPROXY=no]) AC_ARG_ENABLE(xwin, AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto]) +#AC_ARG_ENABLE(glamor, AS_HELP_STRING([--enable-glamor], [Build glamor server (default: no)]), [GLAMOR=$enableval], [GLAMOR=no]) +AC_ARG_ENABLE(glamor-ddx, AS_HELP_STRING([--enable-glamor-ddx], [Build glamor ddx (default: no)]), [GLAMOR_DDX=$enableval], [GLAMOR_DDX=no]) dnl kdrive and its subsystems AC_ARG_ENABLE(kdrive, AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no]) AC_ARG_ENABLE(xephyr, AS_HELP_STRING([--enable-xephyr], [Build the kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval], [XEPHYR=auto]) @@ -655,6 +657,8 @@ dnl kdrive options AC_ARG_ENABLE(kdrive-kbd, AS_HELP_STRING([--enable-kdrive-kbd], [Build kbd driver for kdrive (default: auto)]), [KDRIVE_KBD=$enableval], [KDRIVE_KBD=auto]) AC_ARG_ENABLE(kdrive-mouse, AC_HELP_STRING([--enable-kdrive-mouse], [Build mouse driver for kdrive (default: auto)]), [KDRIVE_MOUSE=$enableval], [KDRIVE_MOUSE=auto]) AC_ARG_ENABLE(kdrive-evdev, AC_HELP_STRING([--enable-kdrive-evdev], [Build evdev driver for kdrive (default: auto)]), [KDRIVE_EVDEV=$enableval], [KDRIVE_EVDEV=auto]) +dnl glamor options +AC_ARG_ENABLE(glamor-gles2, AS_HELP_STRING([--enable-glamor-gles2], [Build glamor based on gles2 (default: no)]), [GLAMOR_GLES2=$enableval], [GLAMOR_GLES2=no]) dnl chown/chmod to be setuid root as part of build @@ -1765,6 +1769,25 @@ AM_CONDITIONAL([SOLARIS_VT], [test "x$solaris_vt" = xyes]) AM_CONDITIONAL([DGA], [test "x$DGA" = xyes]) AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes]) +dnl glamor + +AM_CONDITIONAL([GLAMOR], [test "x$XEPHYR" = xyes || test "x$GLAMOR_DDX" = xyes]) + +GLAMOR=yes + +if test "x$GLAMOR" = xyes; then + AC_DEFINE(GLAMOR,1,[Build Glamor]) + if test "x$GLAMOR_GLES2" = xyes; then + AC_DEFINE(GLAMOR_GLES2,1,[Build glamor over GLES2]) + else + AC_DEFINE(GLAMOR_GL,1,[Build glamor over GL]) + fi + + if test "x$GLAMOR_DDX" = xyes; then + AC_DEFINE(GLAMOR_DDX,1,[Enable glamor ddx driver]) + fi +fi + dnl XWin DDX AC_MSG_CHECKING([whether to build XWin DDX]) diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index b7fcfbdeb..6005a2cd9 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -29,10 +29,28 @@ #ifdef HAVE_DIX_CONFIG_H #include +#include #endif #include "glamor.h" + +#ifdef GLAMOR_GLES2 + +#define GLEW_ES_ONLY 1 + +#define GL_BGRA GL_BGRA_EXT +#define GL_COLOR_INDEX 0x1900 +#define GL_BITMAP 0x1A00 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 + +#endif + #include #ifdef RENDER diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am index 830f17ac9..f76a36155 100644 --- a/hw/xfree86/Makefile.am +++ b/hw/xfree86/Makefile.am @@ -27,12 +27,16 @@ if INT10MODULE INT10_SUBDIR = int10 endif -SUBDIRS = common ddc i2c x86emu $(INT10_SUBDIR) fbdevhw glamor os-support parser \ +if GLAMOR +GLAMOR_DIR=glamor +endif + +SUBDIRS = common ddc i2c x86emu $(INT10_SUBDIR) fbdevhw $(GLAMOR_DIR) os-support parser \ ramdac shadowfb $(VBE_SUBDIR) $(VGAHW_SUBDIR) $(XAA_SUBDIR) \ loader dixmods exa modes \ $(DRI_SUBDIR) $(DRI2_SUBDIR) $(XF86UTILS_SUBDIR) doc man -DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw glamor os-support \ +DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw $(GLAMOR_DIR) os-support \ parser ramdac shadowfb vbe vgahw xaa \ loader dixmods dri dri2 exa modes \ utils doc man diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index 56fb62f64..663e70ad9 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -1118,7 +1118,11 @@ videoPtrToDriverList(struct pci_device *dev, } else if (dev->device_id == 0x8108) { break; /* "hooray" for poulsbo */ } else { +#if GLAMOR_DDX driverList[0] = "glamor"; +#else + driverList[0] = "intel"; +#endif } break; case 0x102b: driverList[0] = "mga"; break; diff --git a/hw/xfree86/glamor/Makefile.am b/hw/xfree86/glamor/Makefile.am index d691009eb..d9dc8a90a 100644 --- a/hw/xfree86/glamor/Makefile.am +++ b/hw/xfree86/glamor/Makefile.am @@ -12,8 +12,11 @@ glamor_la_CFLAGS = \ -I$(top_srcdir)/glamor \ -I/usr/include/drm -glamor_la_LDFLAGS = \ - -module -avoid-version -L$(libdir) -lEGL $(top_builddir)/glamor/libglamor.la -lGLEW +glamor_la_LDFLAGS = \ + -module -avoid-version -L$(libdir) -lEGL \ + $(top_builddir)/glamor/libglamor.la \ + -L$(libdir)/../lib64 -lGLEW + glamor_ladir = $(moduledir)/drivers glamor_la_SOURCES = \ glamor.c \ diff --git a/hw/xfree86/glamor/glamor.c b/hw/xfree86/glamor/glamor.c index 1da7eb20d..a1128da43 100644 --- a/hw/xfree86/glamor/glamor.c +++ b/hw/xfree86/glamor/glamor.c @@ -38,7 +38,13 @@ #define GL_GLEXT_PROTOTYPES #define EGL_EGLEXT_PROTOTYPES #define EGL_DISPLAY_NO_X_MESA + +#if GLAMOR_GLES2 +#include +#else #include +#endif + #include #include @@ -322,7 +328,6 @@ glamor_screen_init_ddx(int scrnIndex, ScreenPtr screen, int argc, char **argv) glamor->display = eglGetDRMDisplayMESA(glamor->fd); eglBindAPI(EGL_OPENGL_API); - LogMessageVerb(X_INFO, 0, "%s glCreateProgramObjectARB=%p", __FUNCTION__, *(&glCreateProgramObjectARB)); if (!eglInitialize(glamor->display, &glamor->major, &glamor->minor)) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglInitialize() failed\n"); diff --git a/hw/xfree86/glamor/glamor_crtc.c b/hw/xfree86/glamor/glamor_crtc.c index cf4940291..d2f98fb5f 100644 --- a/hw/xfree86/glamor/glamor_crtc.c +++ b/hw/xfree86/glamor/glamor_crtc.c @@ -53,7 +53,17 @@ #define GL_GLEXT_PROTOTYPES #define EGL_EGLEXT_PROTOTYPES #define EGL_DISPLAY_NO_X_MESA + +#if GLAMOR_GLES2 +#include +#include +#ifndef GL_BGRA +#define GL_BGRA GL_BGRA_EXT +#endif +#else #include +#endif + #include #include @@ -482,11 +492,15 @@ drmmode_load_cursor_argb (xf86CrtcPtr crtc, CARD32 *image) GL_TEXTURE_MAG_FILTER, GL_NEAREST); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, drmmode_crtc->cursor); } - - glPixelStorei(GL_UNPACK_ROW_LENGTH, 64); glBindTexture(GL_TEXTURE_2D, drmmode_crtc->cursor_tex); +#if GLAMOR_GLES2 + glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, 64, 64, 0, + GL_BGRA, GL_UNSIGNED_BYTE, image); +#else + glPixelStorei(GL_UNPACK_ROW_LENGTH, 64); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, image); +#endif } diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in index 0d1ea9142..c9760b090 100644 --- a/include/xorg-config.h.in +++ b/include/xorg-config.h.in @@ -139,4 +139,15 @@ /* Build with libdrm support */ #undef WITH_LIBDRM + +/* Build GLAMOR */ +#undef GLAMOR + +/* Build GLAMOR over GLES2*/ +#undef GLAMOR_GLES2 + +/* Build GLAMOR ddx*/ +#undef GLAMOR_DDX + + #endif /* _XORG_CONFIG_H_ */