From 5e6fff7ac4a4e0d06d394391f6e2dd2eb6ff8aee Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 19 Jul 2009 09:22:31 +0200 Subject: svga: Do the gallium intel configure trick for svga as well Since the drivers we produce on systems where we use configure depend on none stable kernel API the driver deliverables should not be built by default in the mesa 7.7 release. People wishing to shoot them self in the foot have to pull the trigger themself, we just hand them the gun. --- configure.ac | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 25e4321510f..e15e1f60c44 100644 --- a/configure.ac +++ b/configure.ac @@ -1200,13 +1200,15 @@ dnl dnl Gallium SVGA configuration dnl AC_ARG_ENABLE([gallium-svga], - [AS_HELP_STRING([--disable-gallium-svga], - [build gallium SVGA @<:@default=enabled@:>@])], + [AS_HELP_STRING([--enable-gallium-svga], + [build gallium SVGA @<:@default=disabled@:>@])], [enable_gallium_svga="$enableval"], - [enable_gallium_svga=yes]) + [enable_gallium_svga=auto]) if test "x$enable_gallium_svga" = xyes; then GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS vmware" GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" +elif test "x$enable_gallium_svga" = xauto; then + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" fi dnl -- cgit v1.2.3 From ce4f23aab9e10675a569bab92d0edcbca7399d33 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 4 Nov 2009 23:02:13 +0000 Subject: i965g: Build with configure --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 910c0b1a4b8..11887edc522 100644 --- a/configure.ac +++ b/configure.ac @@ -1191,8 +1191,8 @@ AC_ARG_ENABLE([gallium-intel], [enable_gallium_intel="$enableval"], [enable_gallium_intel=yes]) if test "x$enable_gallium_intel" = xyes; then - GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS intel" - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915" + GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS intel i965" + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965" fi dnl -- cgit v1.2.3 From 8ac2503397c0618db9caec1c702622830e1268ff Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 4 Dec 2009 16:01:41 +0000 Subject: i915g: Do not build winsys and binaries by default Using a hack in the configure script the gallium intel drivers have 3 options. Off, nothing is built. On, the driver and binaries are built. Auto, only the driver but not the binaries and winsys is built. Since the i915g driver builds everywhere its can enable the driver per default, so we can get build coverage. But building the binaries per default is a pain for distributions and testers since they conflict on the install target with the old mesa drivers. Which are more stable/faster/better. So this change gives us the best of both worlds. --- configure.ac | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index f9476a46dda..054857d5599 100644 --- a/configure.ac +++ b/configure.ac @@ -1206,13 +1206,15 @@ dnl dnl Gallium Intel configuration dnl AC_ARG_ENABLE([gallium-intel], - [AS_HELP_STRING([--disable-gallium-intel], - [build gallium intel @<:@default=enabled@:>@])], + [AS_HELP_STRING([--enable-gallium-intel], + [build gallium intel @<:@default=disabled@:>@])], [enable_gallium_intel="$enableval"], - [enable_gallium_intel=yes]) + [enable_gallium_intel=auto]) if test "x$enable_gallium_intel" = xyes; then GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS intel" GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915" +elif test "x$enable_gallium_intel" = xauto; then + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915" fi dnl -- cgit v1.2.3 From bc0532b0ed3c6dca3a198c64384636d96b2056ef Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 4 Dec 2009 18:50:29 +0000 Subject: gallium: DRI drivers enabled by default, Xorg drivers auto by default. This change enabled gallium dri drivers by default under the configure build system. Xorg drivers are built automaticaly if a Xorg dev enviroment is installed and the Xorg version is higher then 1.6.0. --- configure.ac | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 054857d5599..25e4321510f 100644 --- a/configure.ac +++ b/configure.ac @@ -1143,7 +1143,14 @@ yes) GALLIUM_STATE_TRACKERS_DIRS=glx ;; dri) - test "x$enable_egl" = xyes && GALLIUM_STATE_TRACKERS_DIRS=egl + GALLIUM_STATE_TRACKERS_DIRS="dri" + if test "x$enable_egl" = xyes; then + GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl" + fi + # Have only tested st/xorg on 1.6.0 servers + PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0], + HAVE_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg", + HAVE_XORG="no") ;; esac ;; -- cgit v1.2.3 From 2f127e5236ca3c53bfe25fc4ffcfe16ae55ed42b Mon Sep 17 00:00:00 2001 From: Sedat Dilek Date: Thu, 17 Dec 2009 19:14:53 +0100 Subject: configure.ac: Add glsl to SRC_DIRS Signed-off-by: Brian Paul --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 25e4321510f..6fa0a605e07 100644 --- a/configure.ac +++ b/configure.ac @@ -413,7 +413,7 @@ esac dnl dnl Driver specific build directories dnl -SRC_DIRS="mesa glew" +SRC_DIRS="glsl mesa glew" GLU_DIRS="sgi" WINDOW_SYSTEM="" GALLIUM_DIRS="auxiliary drivers state_trackers" -- cgit v1.2.3 From ae1c0a06e81b8c6f015a3b64616a5d3a989f9373 Mon Sep 17 00:00:00 2001 From: Fabio Pedretti Date: Tue, 22 Dec 2009 10:43:35 +1000 Subject: configure.ac: fix for libdrm_radeon API changes. --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 6fa0a605e07..944108b08e8 100644 --- a/configure.ac +++ b/configure.ac @@ -19,6 +19,7 @@ AC_CANONICAL_HOST dnl Versions for external dependencies LIBDRM_REQUIRED=2.4.15 +LIBDRM_RADEON_REQUIRED=2.4.17 DRI2PROTO_REQUIRED=1.99.3 dnl Check for progs @@ -577,7 +578,7 @@ dri) GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED" DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED" - PKG_CHECK_MODULES([LIBDRM_RADEON], [libdrm_radeon], HAVE_LIBDRM_RADEON=yes, HAVE_LIBDRM_RADEON=no) + PKG_CHECK_MODULES([LIBDRM_RADEON], [libdrm_radeon libdrm >= $LIBDRM_RADEON_REQUIRED], HAVE_LIBDRM_RADEON=yes, HAVE_LIBDRM_RADEON=no) if test "$HAVE_LIBDRM_RADEON" = yes; then RADEON_CFLAGS="-DHAVE_LIBDRM_RADEON=1 $LIBDRM_RADEON_CFLAGS" -- cgit v1.2.3 From bf064ce0c31abb036fc035c59fdc1134705a5e3f Mon Sep 17 00:00:00 2001 From: Fabio Pedretti Date: Tue, 22 Dec 2009 10:43:35 +1000 Subject: configure.ac: fix for libdrm_radeon API changes. --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index e15e1f60c44..a15ca111e27 100644 --- a/configure.ac +++ b/configure.ac @@ -19,6 +19,7 @@ AC_CANONICAL_HOST dnl Versions for external dependencies LIBDRM_REQUIRED=2.4.15 +LIBDRM_RADEON_REQUIRED=2.4.17 DRI2PROTO_REQUIRED=1.99.3 dnl Check for progs @@ -577,7 +578,7 @@ dri) GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED" DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED" - PKG_CHECK_MODULES([LIBDRM_RADEON], [libdrm_radeon], HAVE_LIBDRM_RADEON=yes, HAVE_LIBDRM_RADEON=no) + PKG_CHECK_MODULES([LIBDRM_RADEON], [libdrm_radeon libdrm >= $LIBDRM_RADEON_REQUIRED], HAVE_LIBDRM_RADEON=yes, HAVE_LIBDRM_RADEON=no) if test "$HAVE_LIBDRM_RADEON" = yes; then RADEON_CFLAGS="-DHAVE_LIBDRM_RADEON=1 $LIBDRM_RADEON_CFLAGS" -- cgit v1.2.3 From c978ab017d103e60e7e69b6a7857a70baca29e7b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 2 Jan 2010 20:22:52 +0000 Subject: gallium: Hunt down all references to GALLIUM_AUXILIARY_DIRS. --- configs/autoconf.in | 1 - configs/default | 1 - configs/linux-llvm | 2 -- configure.ac | 3 --- 4 files changed, 7 deletions(-) (limited to 'configure.ac') diff --git a/configs/autoconf.in b/configs/autoconf.in index 241ac994632..b94d9bce469 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -66,7 +66,6 @@ SRC_DIRS = @SRC_DIRS@ GLU_DIRS = @GLU_DIRS@ DRIVER_DIRS = @DRIVER_DIRS@ GALLIUM_DIRS = @GALLIUM_DIRS@ -GALLIUM_AUXILIARY_DIRS = @GALLIUM_AUXILIARY_DIRS@ GALLIUM_DRIVERS_DIRS = @GALLIUM_DRIVERS_DIRS@ GALLIUM_WINSYS_DIRS = @GALLIUM_WINSYS_DIRS@ GALLIUM_WINSYS_DRM_DIRS = @GALLIUM_WINSYS_DRM_DIRS@ diff --git a/configs/default b/configs/default index d745d5bc57e..94beca4fa67 100644 --- a/configs/default +++ b/configs/default @@ -94,7 +94,6 @@ EGL_DRIVERS_DIRS = demo # Gallium directories and GALLIUM_DIRS = auxiliary drivers state_trackers -GALLIUM_AUXILIARY_DIRS = rbug draw translate cso_cache pipebuffer tgsi rtasm util indices vl GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 trace identity GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) diff --git a/configs/linux-llvm b/configs/linux-llvm index 19b53cc5461..dbf7e3ed7a9 100644 --- a/configs/linux-llvm +++ b/configs/linux-llvm @@ -6,8 +6,6 @@ include $(TOP)/configs/linux CONFIG_NAME = linux-llvm -#GALLIUM_AUXILIARY_DIRS += gallivm - # Add llvmpipe driver GALLIUM_DRIVERS_DIRS += llvmpipe diff --git a/configure.ac b/configure.ac index d83dd4315b7..72afabcf9eb 100644 --- a/configure.ac +++ b/configure.ac @@ -420,7 +420,6 @@ WINDOW_SYSTEM="" GALLIUM_DIRS="auxiliary drivers state_trackers" GALLIUM_WINSYS_DIRS="" GALLIUM_WINSYS_DRM_DIRS="" -GALLIUM_AUXILIARY_DIRS="rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices vl" GALLIUM_DRIVERS_DIRS="softpipe failover trace identity" GALLIUM_STATE_TRACKERS_DIRS="" @@ -447,7 +446,6 @@ AC_SUBST([GALLIUM_DIRS]) AC_SUBST([GALLIUM_WINSYS_DIRS]) AC_SUBST([GALLIUM_WINSYS_DRM_DIRS]) AC_SUBST([GALLIUM_DRIVERS_DIRS]) -AC_SUBST([GALLIUM_AUXILIARY_DIRS]) AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS]) AC_SUBST([RADEON_CFLAGS]) AC_SUBST([RADEON_LDFLAGS]) @@ -1306,7 +1304,6 @@ if echo "$SRC_DIRS" | grep 'gallium' >/dev/null 2>&1; then echo " Gallium dirs: $GALLIUM_DIRS" echo " Winsys dirs: $GALLIUM_WINSYS_DIRS" echo " Winsys drm dirs:$GALLIUM_WINSYS_DRM_DIRS" - echo " Auxiliary dirs: $GALLIUM_AUXILIARY_DIRS" echo " Driver dirs: $GALLIUM_DRIVERS_DIRS" echo " Trackers dirs: $GALLIUM_STATE_TRACKERS_DIRS" else -- cgit v1.2.3 From e388d62b4712bcd75cecad53f5ca20a2bb6f89b1 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Sat, 2 Jan 2010 18:59:54 -0500 Subject: Compile with -fvisibility-hidden by default We have all functions that need to be visible marked with PUBLIC and this is trimming around 4% off the DRI driver .so size. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 72afabcf9eb..b2a969bc8c9 100644 --- a/configure.ac +++ b/configure.ac @@ -95,7 +95,7 @@ esac dnl Add flags for gcc and g++ if test "x$GCC" = xyes; then - CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math" + CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math -fvisibility=hidden" # Work around aliasing bugs - developers should comment this out CFLAGS="$CFLAGS -fno-strict-aliasing" -- cgit v1.2.3 From 8616cec5c9889e6166839b33baa8db52f04d409c Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Fri, 1 Jan 2010 17:03:33 -0500 Subject: Check for libdrm_$chipset.pc when needed This adds missing pkg-config lookup for intel and moves the radeon lookup into a case...esac so it's only looked up when one or more of the radeon drivers are enabled. --- configs/autoconf.in | 2 ++ configure.ac | 30 +++++++++++++++++++++--------- src/mesa/drivers/dri/i915/Makefile | 3 ++- src/mesa/drivers/dri/i965/Makefile | 3 ++- 4 files changed, 27 insertions(+), 11 deletions(-) (limited to 'configure.ac') diff --git a/configs/autoconf.in b/configs/autoconf.in index b94d9bce469..f63618ebea2 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -22,6 +22,8 @@ LDFLAGS = @LDFLAGS@ EXTRA_LIB_PATH = @EXTRA_LIB_PATH@ RADEON_CFLAGS = @RADEON_CFLAGS@ RADEON_LDFLAGS = @RADEON_LDFLAGS@ +INTEL_LIBS = @INTEL_LIBS@ +INTEL_CFLAGS = @INTEL_CFLAGS@ # Assembler MESA_ASM_SOURCES = @MESA_ASM_SOURCES@ diff --git a/configure.ac b/configure.ac index b2a969bc8c9..d3fbd027132 100644 --- a/configure.ac +++ b/configure.ac @@ -447,8 +447,6 @@ AC_SUBST([GALLIUM_WINSYS_DIRS]) AC_SUBST([GALLIUM_WINSYS_DRM_DIRS]) AC_SUBST([GALLIUM_DRIVERS_DIRS]) AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS]) -AC_SUBST([RADEON_CFLAGS]) -AC_SUBST([RADEON_LDFLAGS]) dnl dnl User supplied program configuration @@ -576,13 +574,6 @@ dri) GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED" DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED" - PKG_CHECK_MODULES([LIBDRM_RADEON], [libdrm_radeon libdrm >= $LIBDRM_RADEON_REQUIRED], HAVE_LIBDRM_RADEON=yes, HAVE_LIBDRM_RADEON=no) - - if test "$HAVE_LIBDRM_RADEON" = yes; then - RADEON_CFLAGS="-DHAVE_LIBDRM_RADEON=1 $LIBDRM_RADEON_CFLAGS" - RADEON_LDFLAGS=$LIBDRM_RADEON_LIBS - fi - # find the DRI deps for libGL if test "$x11_pkgconfig" = yes; then # add xcb modules if necessary @@ -802,6 +793,27 @@ AC_SUBST([DRI_DIRS]) AC_SUBST([EXPAT_INCLUDES]) AC_SUBST([DRI_LIB_DEPS]) +case $DRI_DIRS in +*i915*|*i965*) + PKG_CHECK_MODULES([INTEL], [libdrm_intel]) + ;; + +*radeon*|*r200*|*r300*|*r600*) + PKG_CHECK_MODULES([LIBDRM_RADEON], + [libdrm_radeon libdrm >= $LIBDRM_RADEON_REQUIRED], + HAVE_LIBDRM_RADEON=yes, + HAVE_LIBDRM_RADEON=no) + + if test "$HAVE_LIBDRM_RADEON" = yes; then + RADEON_CFLAGS="-DHAVE_LIBDRM_RADEON=1 $LIBDRM_RADEON_CFLAGS" + RADEON_LDFLAGS=$LIBDRM_RADEON_LIBS + fi + ;; +esac +AC_SUBST([RADEON_CFLAGS]) +AC_SUBST([RADEON_LDFLAGS]) + + dnl dnl OSMesa configuration dnl diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile index 37f15aa7671..788e78654eb 100644 --- a/src/mesa/drivers/dri/i915/Makefile +++ b/src/mesa/drivers/dri/i915/Makefile @@ -64,7 +64,8 @@ DRIVER_DEFINES = -I../intel -I../intel/server -DI915 \ $(shell pkg-config libdrm --atleast-version=2.3.1 \ && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP") -DRI_LIB_DEPS += -ldrm_intel +INCLUDES += $(INTEL_CFLAGS) +DRI_LIB_DEPS += $(INTEL_LIBS) include ../Makefile.template diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile index 7a55333e896..7cdbdc70713 100644 --- a/src/mesa/drivers/dri/i965/Makefile +++ b/src/mesa/drivers/dri/i965/Makefile @@ -96,7 +96,8 @@ ASM_SOURCES = DRIVER_DEFINES = -I../intel -I../intel/server -DRI_LIB_DEPS += -ldrm_intel +INCLUDES += $(INTEL_CFLAGS) +DRI_LIB_DEPS += $(INTEL_LIBS) include ../Makefile.template -- cgit v1.2.3 From e5d351dcfde58777162552cf5cd2a9cd8299f4cd Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 23 Dec 2009 11:18:00 +0800 Subject: Add es state tracker to autoconf. mesa/es is needed in SRC_DIRS to build es state tracker. Signed-off-by: Chia-I Wu --- configure.ac | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index cc588d5fabd..2984ee24a03 100644 --- a/configure.ac +++ b/configure.ac @@ -1154,14 +1154,22 @@ yes) test -d "$srcdir/src/gallium/state_trackers/$tracker" || \ AC_MSG_ERROR([state tracker '$tracker' doesn't exist]) - if test "$tracker" = egl && test "x$enable_egl" != xyes; then - AC_MSG_ERROR([cannot build egl state tracker without EGL library]) - fi - if test "$tracker" = xorg; then + case "$tracker" in + egl) + if test "x$enable_egl" != xyes; then + AC_MSG_ERROR([cannot build egl state tracker without EGL library]) + fi + ;; + xorg) PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1], HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71", HAVE_XEXTPROTO_71="no") - fi + ;; + es) + # mesa/es is required to build es state tracker + SRC_DIRS="mesa/es $SRC_DIRS" + ;; + esac done GALLIUM_STATE_TRACKERS_DIRS="$state_trackers" ;; -- cgit v1.2.3 From 27fe7a7303d93bc38df1f3c2861d07af3e82546d Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 7 Jan 2010 10:29:29 -0500 Subject: configure: Fix matching for dri driver to actually work The shell case statement obviously only evaluates the first matching block. Thanks to Julien Cristau for spotting the bug. --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index d3fbd027132..d8af5ea9ef9 100644 --- a/configure.ac +++ b/configure.ac @@ -797,7 +797,9 @@ case $DRI_DIRS in *i915*|*i965*) PKG_CHECK_MODULES([INTEL], [libdrm_intel]) ;; +esac +case $DRI_DIRS in *radeon*|*r200*|*r300*|*r600*) PKG_CHECK_MODULES([LIBDRM_RADEON], [libdrm_radeon libdrm >= $LIBDRM_RADEON_REQUIRED], -- cgit v1.2.3 From a35f6bb207efe3c959bbd16a37f2049e5aceeea9 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Fri, 17 Jul 2009 03:30:29 -0400 Subject: DRI2: add SwapBuffers support Support the new DRI2 protocol request, DRI2SwapBuffers, in both direct and indirect rendering context. This request allows the display server to optimize back->front swaps (e.g. through page flipping) and allows us to more easily support other GLX features like swap interval and the OML sync extension in DRI2. Signed-off-by: Jesse Barnes --- configure.ac | 2 +- include/GL/internal/dri_interface.h | 14 +++++++++++++- src/glx/x11/dri2.c | 16 ++++++++++++++++ src/glx/x11/dri2.h | 3 +++ src/glx/x11/dri2_glx.c | 32 +++++++++++++++++++++++++++++++- src/mesa/drivers/dri/common/dri_util.c | 1 + src/mesa/drivers/dri/common/dri_util.h | 2 ++ 7 files changed, 67 insertions(+), 3 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index b2a969bc8c9..fd300504bf7 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_CANONICAL_HOST dnl Versions for external dependencies LIBDRM_REQUIRED=2.4.15 LIBDRM_RADEON_REQUIRED=2.4.17 -DRI2PROTO_REQUIRED=1.99.3 +DRI2PROTO_REQUIRED=2.2 dnl Check for progs AC_PROG_CPP diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 910c9166b5e..ec6238f8734 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -262,10 +262,22 @@ struct __DRItexBufferExtensionRec { * Used by drivers that implement DRI2 */ #define __DRI2_FLUSH "DRI2_Flush" -#define __DRI2_FLUSH_VERSION 1 +#define __DRI2_FLUSH_VERSION 2 struct __DRI2flushExtensionRec { __DRIextension base; void (*flush)(__DRIdrawable *drawable); + + /** + * Flush all rendering queue in the driver to the drm and + * invalidate all buffers. The driver will call out to + * getBuffers/getBuffersWithFormat before it starts rendering + * again. + * + * \param drawable the drawable to flush and invalidate + * + * \since 2 + */ + void (*flushInvalidate)(__DRIdrawable *drawable); }; diff --git a/src/glx/x11/dri2.c b/src/glx/x11/dri2.c index dad04470a00..a0f8901d42d 100644 --- a/src/glx/x11/dri2.c +++ b/src/glx/x11/dri2.c @@ -380,4 +380,20 @@ DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region, SyncHandle(); } +void DRI2SwapBuffers(Display *dpy, XID drawable) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2SwapBuffersReq *req; + + XextSimpleCheckExtension (dpy, info, dri2ExtensionName); + + LockDisplay(dpy); + GetReq(DRI2SwapBuffers, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2SwapBuffers; + req->drawable = drawable; + UnlockDisplay(dpy); + SyncHandle(); +} + #endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/x11/dri2.h b/src/glx/x11/dri2.h index a6fe66e136d..ba6eff5e4f7 100644 --- a/src/glx/x11/dri2.h +++ b/src/glx/x11/dri2.h @@ -85,4 +85,7 @@ DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region, CARD32 dest, CARD32 src); +extern void +DRI2SwapBuffers(Display *dpy, XID drawable); + #endif diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c index 89efe3ab292..114cad2ae7d 100644 --- a/src/glx/x11/dri2_glx.c +++ b/src/glx/x11/dri2_glx.c @@ -35,6 +35,7 @@ #include #include #include +#include "glapi.h" #include "glxclient.h" #include "glcontextmodes.h" #include "xf86dri.h" @@ -64,6 +65,7 @@ struct __GLXDRIdisplayPrivateRec int driMajor; int driMinor; int driPatch; + int swapAvailable; }; struct __GLXDRIcontextPrivateRec @@ -240,7 +242,7 @@ dri2SwapBuffers(__GLXDRIdrawable * pdraw) } static void -dri2WaitX(__GLXDRIdrawable * pdraw) +dri2WaitX(__GLXDRIdrawable *pdraw) { __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; XRectangle xrect; @@ -342,6 +344,31 @@ process_buffers(__GLXDRIdrawablePrivate * pdraw, DRI2Buffer * buffers, } +static void dri2SwapBuffers(__GLXDRIdrawable *pdraw) +{ + __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; + __GLXdisplayPrivate *dpyPriv = __glXInitialize(priv->base.psc->dpy); + __GLXDRIdisplayPrivate *pdp = + (__GLXDRIdisplayPrivate *)dpyPriv->dri2Display; + __GLXscreenConfigs *psc = pdraw->psc; + +#ifdef __DRI2_FLUSH + if (pdraw->psc->f) + (*pdraw->psc->f->flush)(pdraw->driDrawable); +#endif + + /* Old servers can't handle swapbuffers */ + if (!pdp->swapAvailable) + return dri2CopySubBuffer(pdraw, 0, 0, priv->width, priv->height); + + DRI2SwapBuffers(pdraw->psc->dpy, pdraw->drawable); + +#if __DRI2_FLUSH_VERSION >= 2 + if (pdraw->psc->f) + (*pdraw->psc->f->flushInvalidate)(pdraw->driDrawable); +#endif +} + static __DRIbuffer * dri2GetBuffers(__DRIdrawable * driDrawable, int *width, int *height, @@ -559,6 +586,9 @@ dri2CreateDisplay(Display * dpy) } pdp->driPatch = 0; + pdp->swapAvailable = 0; + if (pdp->driMinor >= 2) + pdp->swapAvailable = 1; pdp->base.destroyDisplay = dri2DestroyDisplay; pdp->base.createScreen = dri2CreateScreen; diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 547f18a009e..cd271ede091 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -454,6 +454,7 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config, pdp->driScreenPriv = psp; pdp->driContextPriv = &psp->dummyContextPriv; + pdp->validBuffers = GL_FALSE; if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &config->modes, renderType == GLX_PIXMAP_BIT)) { diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index c95a5c8299a..c3046d6b186 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -380,6 +380,8 @@ struct __DRIdrawableRec { * GLX_MESA_swap_control. */ unsigned int swap_interval; + + GLboolean validBuffers; }; /** -- cgit v1.2.3 From d4c1ee05345e1e185ac15a3cd3552d9bb0d61bc3 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 21 Dec 2009 11:13:18 +0800 Subject: egl: Clean up the Makefile rules. This allows libEGL to be built as a static library and removes libX11 from the dependencies. Signed-off-by: Chia-I Wu --- configs/autoconf.in | 3 +++ configs/default | 5 ++++- configure.ac | 18 ++++++++++-------- src/egl/main/Makefile | 25 ++++++++++++++----------- 4 files changed, 31 insertions(+), 20 deletions(-) (limited to 'configure.ac') diff --git a/configs/autoconf.in b/configs/autoconf.in index f63618ebea2..49c009052b6 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -54,6 +54,7 @@ GLU_LIB_NAME = @GLU_LIB_NAME@ GLUT_LIB_NAME = @GLUT_LIB_NAME@ GLW_LIB_NAME = @GLW_LIB_NAME@ OSMESA_LIB_NAME = @OSMESA_LIB_NAME@ +EGL_LIB_NAME = @EGL_LIB_NAME@ # Globs used to install the lib and all symlinks GL_LIB_GLOB = @GL_LIB_GLOB@ @@ -61,12 +62,14 @@ GLU_LIB_GLOB = @GLU_LIB_GLOB@ GLUT_LIB_GLOB = @GLUT_LIB_GLOB@ GLW_LIB_GLOB = @GLW_LIB_GLOB@ OSMESA_LIB_GLOB = @OSMESA_LIB_GLOB@ +EGL_LIB_GLOB = @EGL_LIB_GLOB@ # Directories to build LIB_DIR = @LIB_DIR@ SRC_DIRS = @SRC_DIRS@ GLU_DIRS = @GLU_DIRS@ DRIVER_DIRS = @DRIVER_DIRS@ +EGL_DRIVERS_DIRS = @EGL_DRIVERS_DIRS@ GALLIUM_DIRS = @GALLIUM_DIRS@ GALLIUM_DRIVERS_DIRS = @GALLIUM_DRIVERS_DIRS@ GALLIUM_WINSYS_DIRS = @GALLIUM_WINSYS_DIRS@ diff --git a/configs/default b/configs/default index 94beca4fa67..f5a4bc195f3 100644 --- a/configs/default +++ b/configs/default @@ -55,6 +55,7 @@ GLUT_LIB = glut GLEW_LIB = GLEW GLW_LIB = GLw OSMESA_LIB = OSMesa +EGL_LIB = EGL # Library names (actual file names) @@ -64,6 +65,7 @@ GLUT_LIB_NAME = lib$(GLUT_LIB).so GLEW_LIB_NAME = lib$(GLEW_LIB).a GLW_LIB_NAME = lib$(GLW_LIB).so OSMESA_LIB_NAME = lib$(OSMESA_LIB).so +EGL_LIB_NAME = lib$(EGL_LIB).so # globs used to install the lib and all symlinks GL_LIB_GLOB = $(GL_LIB_NAME)* @@ -71,6 +73,7 @@ GLU_LIB_GLOB = $(GLU_LIB_NAME)* GLUT_LIB_GLOB = $(GLUT_LIB_NAME)* GLW_LIB_GLOB = $(GLW_LIB_NAME)* OSMESA_LIB_GLOB = $(OSMESA_LIB_NAME)* +EGL_LIB_GLOB = $(EGL_LIB_NAME)* # Optional assembly language optimization files for libGL MESA_ASM_SOURCES = @@ -89,7 +92,7 @@ DRIVER_DIRS = x11 osmesa # Which subdirs under $(TOP)/progs/ to enter: PROGRAM_DIRS = demos redbook samples glsl objviewer xdemos -# EGL directories +# EGL drivers to build EGL_DRIVERS_DIRS = demo # Gallium directories and diff --git a/configure.ac b/configure.ac index d8af5ea9ef9..43069de1ea0 100644 --- a/configure.ac +++ b/configure.ac @@ -243,24 +243,28 @@ GLU_LIB_NAME='lib$(GLU_LIB).'${LIB_EXTENSION} GLUT_LIB_NAME='lib$(GLUT_LIB).'${LIB_EXTENSION} GLW_LIB_NAME='lib$(GLW_LIB).'${LIB_EXTENSION} OSMESA_LIB_NAME='lib$(OSMESA_LIB).'${LIB_EXTENSION} +EGL_LIB_NAME='lib$(EGL_LIB).'${LIB_EXTENSION} GL_LIB_GLOB='lib$(GL_LIB).*'${LIB_EXTENSION}'*' GLU_LIB_GLOB='lib$(GLU_LIB).*'${LIB_EXTENSION}'*' GLUT_LIB_GLOB='lib$(GLUT_LIB).*'${LIB_EXTENSION}'*' GLW_LIB_GLOB='lib$(GLW_LIB).*'${LIB_EXTENSION}'*' OSMESA_LIB_GLOB='lib$(OSMESA_LIB).*'${LIB_EXTENSION}'*' +EGL_LIB_GLOB='lib$(EGL_LIB).*'${LIB_EXTENSION}'*' AC_SUBST([GL_LIB_NAME]) AC_SUBST([GLU_LIB_NAME]) AC_SUBST([GLUT_LIB_NAME]) AC_SUBST([GLW_LIB_NAME]) AC_SUBST([OSMESA_LIB_NAME]) +AC_SUBST([EGL_LIB_NAME]) AC_SUBST([GL_LIB_GLOB]) AC_SUBST([GLU_LIB_GLOB]) AC_SUBST([GLUT_LIB_GLOB]) AC_SUBST([GLW_LIB_GLOB]) AC_SUBST([OSMESA_LIB_GLOB]) +AC_SUBST([EGL_LIB_GLOB]) dnl dnl Arch/platform-specific settings @@ -900,17 +904,15 @@ AC_ARG_ENABLE([egl], [enable_egl=yes]) if test "x$enable_egl" = xyes; then SRC_DIRS="$SRC_DIRS egl" - - if test "$x11_pkgconfig" = yes; then - PKG_CHECK_MODULES([EGL], [x11]) - EGL_LIB_DEPS="$EGL_LIBS" - else - # should check these... - EGL_LIB_DEPS="$X_LIBS -lX11" + EGL_LIB_DEPS="$DLOPEN_LIBS -lpthread" + EGL_DRIVERS_DIRS="" + if test "$enable_static" != yes && test "$mesa_driver" != osmesa; then + # build egl_glx when libGL is built + EGL_DRIVERS_DIRS="glx" fi - EGL_LIB_DEPS="$EGL_LIB_DEPS $DLOPEN_LIBS" fi AC_SUBST([EGL_LIB_DEPS]) +AC_SUBST([EGL_DRIVERS_DIRS]) dnl dnl GLU configuration diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index c951b070f1f..ec326a845df 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -4,7 +4,10 @@ TOP = ../../.. include $(TOP)/configs/current -INCLUDE_DIRS = -I$(TOP)/include -I$(TOP)/src/mesa/glapi $(X11_INCLUDES) +EGL_MAJOR = 1 +EGL_MINOR = 0 + +INCLUDE_DIRS = -I$(TOP)/include HEADERS = \ eglcompiler.h \ @@ -43,7 +46,7 @@ SOURCES = \ OBJECTS = $(SOURCES:.c=.o) -# Undefined for now +# use dl*() to load drivers LOCAL_CFLAGS = -D_EGL_PLATFORM_X=1 @@ -56,21 +59,21 @@ default: depend library # EGL Library -library: $(TOP)/$(LIB_DIR)/libEGL.so +library: $(TOP)/$(LIB_DIR)/$(EGL_LIB_NAME) -$(TOP)/$(LIB_DIR)/libEGL.so: $(OBJECTS) - $(MKLIB) -o EGL -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - -major 1 -minor 0 \ - -install $(TOP)/$(LIB_DIR) \ +$(TOP)/$(LIB_DIR)/$(EGL_LIB_NAME): $(OBJECTS) + $(MKLIB) -o $(EGL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + -major $(EGL_MAJOR) -minor $(EGL_MINOR) \ + -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \ $(EGL_LIB_DEPS) $(OBJECTS) install: default $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(MINSTALL) $(TOP)/$(LIB_DIR)/libEGL.so* $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(EGL_LIB_GLOB) \ + $(DESTDIR)$(INSTALL_LIB_DIR) clean: - -rm -f *.o *.so* - -rm -f core.* + -rm -f *.o -rm -f depend depend.bak @@ -82,5 +85,5 @@ depend: $(SOURCES) $(HEADERS) $(SOURCES) $(HEADERS) > /dev/null 2>/dev/null -include depend +-include depend # DO NOT DELETE -- cgit v1.2.3 From f2f83d9a7891428ea7c784a75bd9e2968fdf00ae Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Mon, 11 Jan 2010 17:28:10 -0500 Subject: GLX: check glproto version This was a silent dependency before, but now we really need 1.4.11 for INTEL_swap_event support, so check for it. Signed-off-by: Jesse Barnes --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 33437f54f89..b3887231137 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,7 @@ dnl Versions for external dependencies LIBDRM_REQUIRED=2.4.15 LIBDRM_RADEON_REQUIRED=2.4.17 DRI2PROTO_REQUIRED=2.2 +GLPROTO_REQUIRED=1.4.11 dnl Check for progs AC_PROG_CPP @@ -577,6 +578,7 @@ dri) PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED]) GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED" DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED" + PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED]) # find the DRI deps for libGL if test "$x11_pkgconfig" = yes; then -- cgit v1.2.3 From 49381d63e61c724b156b76068058df1c01a906c2 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 11 Jan 2010 01:23:01 +0800 Subject: st/egl_g3d: New EGL state tracker that uses Gallium. This new (intermediate) EGL state tracker is the base work for EGL drivers that uses Gallium. It makes it easier to support new window systems. Currently, there is support only for X11. This driver supports multiple APIs (OpenVG, OpenGL, ...) and supports hardware acceleration through winsys/drm. Signed-off-by: Chia-I Wu --- configs/autoconf.in | 1 + configs/default | 2 + configure.ac | 29 + src/gallium/state_trackers/egl_g3d/Makefile | 72 ++ .../state_trackers/egl_g3d/common/egl_g3d.c | 921 +++++++++++++++++++++ .../state_trackers/egl_g3d/common/egl_g3d.h | 113 +++ src/gallium/state_trackers/egl_g3d/common/egl_st.c | 131 +++ src/gallium/state_trackers/egl_g3d/common/egl_st.h | 73 ++ src/gallium/state_trackers/egl_g3d/common/native.h | 168 ++++ .../state_trackers/egl_g3d/common/st_public_tmp.h | 20 + src/gallium/state_trackers/egl_g3d/x11/glxinit.c | 573 +++++++++++++ src/gallium/state_trackers/egl_g3d/x11/glxinit.h | 14 + .../state_trackers/egl_g3d/x11/native_dri2.c | 693 ++++++++++++++++ .../state_trackers/egl_g3d/x11/native_x11.c | 73 ++ .../state_trackers/egl_g3d/x11/native_x11.h | 41 + .../state_trackers/egl_g3d/x11/native_ximage.c | 680 +++++++++++++++ src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c | 231 ++++++ src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h | 40 + .../state_trackers/egl_g3d/x11/x11_screen.c | 402 +++++++++ .../state_trackers/egl_g3d/x11/x11_screen.h | 99 +++ 20 files changed, 4376 insertions(+) create mode 100644 src/gallium/state_trackers/egl_g3d/Makefile create mode 100644 src/gallium/state_trackers/egl_g3d/common/egl_g3d.c create mode 100644 src/gallium/state_trackers/egl_g3d/common/egl_g3d.h create mode 100644 src/gallium/state_trackers/egl_g3d/common/egl_st.c create mode 100644 src/gallium/state_trackers/egl_g3d/common/egl_st.h create mode 100644 src/gallium/state_trackers/egl_g3d/common/native.h create mode 100644 src/gallium/state_trackers/egl_g3d/common/st_public_tmp.h create mode 100644 src/gallium/state_trackers/egl_g3d/x11/glxinit.c create mode 100644 src/gallium/state_trackers/egl_g3d/x11/glxinit.h create mode 100644 src/gallium/state_trackers/egl_g3d/x11/native_dri2.c create mode 100644 src/gallium/state_trackers/egl_g3d/x11/native_x11.c create mode 100644 src/gallium/state_trackers/egl_g3d/x11/native_x11.h create mode 100644 src/gallium/state_trackers/egl_g3d/x11/native_ximage.c create mode 100644 src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c create mode 100644 src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h create mode 100644 src/gallium/state_trackers/egl_g3d/x11/x11_screen.c create mode 100644 src/gallium/state_trackers/egl_g3d/x11/x11_screen.h (limited to 'configure.ac') diff --git a/configs/autoconf.in b/configs/autoconf.in index 49c009052b6..c6d315e4d2e 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -84,6 +84,7 @@ PROGRAM_DIRS = @PROGRAM_DIRS@ # Driver specific build vars DRI_DIRS = @DRI_DIRS@ WINDOW_SYSTEM = @WINDOW_SYSTEM@ +EGL_DISPLAYS = @EGL_DISPLAYS@ USING_EGL = @USING_EGL@ # Dependencies diff --git a/configs/default b/configs/default index f5a4bc195f3..8b4557d26a8 100644 --- a/configs/default +++ b/configs/default @@ -104,6 +104,8 @@ GALLIUM_WINSYS_DIRS = xlib egl_xlib GALLIUM_WINSYS_DRM_DIRS = GALLIUM_STATE_TRACKERS_DIRS = glx +# native displays EGL should support +EGL_DISPLAYS = x11 # Library dependencies #EXTRA_LIB_PATH ?= diff --git a/configure.ac b/configure.ac index b3887231137..8a8919b1373 100644 --- a/configure.ac +++ b/configure.ac @@ -1191,6 +1191,35 @@ yes) ;; esac +AC_ARG_WITH([egl-displays], + [AS_HELP_STRING([--with-egl-displays@<:@=DIRS...@:>@], + [comma delimited native displays libEGL supports, e.g. + "x11" @<:@default=auto@:>@])], + [with_egl_displays="$withval"], + [with_egl_displays=yes]) + +EGL_DISPLAYS="" +case "$with_egl_displays" in +yes) + if test "x$enable_egl" = xyes && test "x$mesa_driver" != xosmesa; then + EGL_DISPLAYS="x11" + fi + ;; +*) + if test "x$enable_egl" != xyes; then + AC_MSG_ERROR([cannot build egl state tracker without EGL library]) + fi + # verify the requested driver directories exist + egl_displays=`IFS=', '; echo $with_egl_displays` + for dpy in $egl_displays; do + test -d "$srcdir/src/gallium/state_trackers/egl_g3d/$dpy" || \ + AC_MSG_ERROR([EGL display '$dpy' does't exist]) + done + EGL_DISPLAYS="$egl_displays" + ;; +esac +AC_SUBST([EGL_DISPLAYS]) + AC_ARG_WITH([xorg-driver-dir], [AS_HELP_STRING([--with-xorg-driver-dir=DIR], [Default xorg driver directory[[default=${libdir}/xorg/modules/drivers]]])], diff --git a/src/gallium/state_trackers/egl_g3d/Makefile b/src/gallium/state_trackers/egl_g3d/Makefile new file mode 100644 index 00000000000..213eb3e815b --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/Makefile @@ -0,0 +1,72 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +common_INCLUDES = \ + -I. \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/src/egl/main \ + -I$(TOP)/include + +common_SOURCES = $(wildcard common/*.c) +common_OBJECTS = $(common_SOURCES:.c=.o) + + +x11_INCLUDES = \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/glx/x11 \ + -I$(TOP)/src/mesa \ + $(shell pkg-config --cflags-only-I libdrm) + +x11_SOURCES = $(wildcard x11/*.c) $(TOP)/src/glx/x11/dri2.c +x11_OBJECTS = $(x11_SOURCES:.c=.o) + + +kms_INCLUDES = $(shell pkg-config --cflags-only-I libdrm) +kms_SOURCES = $(wildcard kms/*.c) +kms_OBJECTS = $(kms_SOURCES:.c=.o) + + +ALL_INCLUDES = $(common_INCLUDES) $(x11_INCLUDES) $(kms_INCLUDES) +ALL_SOURCES = $(common_SOURCES) $(x11_SOURCES) $(kms_SOURCES) +ALL_OBJECTS = $(common_OBJECTS) $(x11_OBJECTS) $(kms_OBJECTS) + +##### TARGETS ##### + +EGL_DISPLAYS_MODS = $(foreach dpy, $(EGL_DISPLAYS), libegl$(dpy).a) + +default: depend $(EGL_DISPLAYS_MODS) + + +libeglx11.a: $(x11_OBJECTS) $(common_OBJECTS) Makefile + $(MKLIB) -o eglx11 -static $(x11_OBJECTS) $(common_OBJECTS) + +libeglkms.a: $(kms_OBJECTS) $(common_OBJECTS) Makefile + $(MKLIB) -o eglkms -static $(kms_OBJECTS) $(common_OBJECTS) + +depend: + rm -f depend + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(ALL_INCLUDES) $(ALL_SOURCES) 2> /dev/null + +clean: + rm -f $(ALL_OBJECTS) + rm -f $(EGL_DISPLAYS_MODS) + rm -f depend depend.bak + +# Dummy target +install: + @echo -n "" + +##### RULES ##### + +$(common_OBJECTS): %.o: %.c + $(CC) -c $(common_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ + +$(x11_OBJECTS): %.o: %.c + $(CC) -c $(common_INCLUDES) $(x11_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ + +$(kms_OBJECTS): %.o: %.c + $(CC) -c $(common_INCLUDES) $(kms_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ + +sinclude depend diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c new file mode 100644 index 00000000000..f4a58f77ebe --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c @@ -0,0 +1,921 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include "util/u_memory.h" +#include "egldriver.h" +#include "eglcurrent.h" +#include "eglconfigutil.h" +#include "egllog.h" + +#include "native.h" +#include "egl_g3d.h" +#include "egl_st.h" + +/** + * Validate the draw/read surfaces of the context. + */ +static void +egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct pipe_screen *screen = gdpy->native->screen; + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + EGLint num_surfaces; + EGLint s, i; + + /* validate draw and/or read buffers */ + num_surfaces = (gctx->base.ReadSurface == gctx->base.DrawSurface) ? 1 : 2; + for (s = 0; s < num_surfaces; s++) { + struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; + struct egl_g3d_surface *gsurf; + struct egl_g3d_buffer *gbuf; + + if (s == 0) { + gsurf = egl_g3d_surface(gctx->base.DrawSurface); + gbuf = &gctx->draw; + } + else { + gsurf = egl_g3d_surface(gctx->base.ReadSurface); + gbuf = &gctx->read; + } + + if (!gctx->force_validate) { + EGLint cur_w, cur_h; + + cur_w = gsurf->base.Width; + cur_h = gsurf->base.Height; + gsurf->native->validate(gsurf->native, + gbuf->native_atts, gbuf->num_atts, + NULL, + &gsurf->base.Width, &gsurf->base.Height); + /* validate only when the geometry changed */ + if (gsurf->base.Width == cur_w && gsurf->base.Height == cur_h) + continue; + } + + gsurf->native->validate(gsurf->native, + gbuf->native_atts, gbuf->num_atts, + (struct pipe_texture **) textures, + &gsurf->base.Width, &gsurf->base.Height); + for (i = 0; i < gbuf->num_atts; i++) { + struct pipe_texture *pt = textures[i]; + struct pipe_surface *ps; + + if (pt) { + ps = screen->get_tex_surface(screen, pt, 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_GPU_WRITE); + gctx->stapi->st_set_framebuffer_surface(gbuf->st_fb, + gbuf->st_atts[i], ps); + + if (gbuf->native_atts[i] == gsurf->render_att) + pipe_surface_reference(&gsurf->render_surface, ps); + + pipe_surface_reference(&ps, NULL); + pipe_texture_reference(&pt, NULL); + } + } + + gctx->stapi->st_resize_framebuffer(gbuf->st_fb, + gsurf->base.Width, gsurf->base.Height); + } + + gctx->force_validate = EGL_FALSE; + +} + +/** + * Create a st_framebuffer. + */ +static struct st_framebuffer * +create_framebuffer(_EGLContext *ctx, _EGLSurface *surf) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config); + + return gctx->stapi->st_create_framebuffer(&gconf->native->mode, + gconf->native->color_format, gconf->native->depth_format, + gconf->native->stencil_format, + gsurf->base.Width, gsurf->base.Height, &gsurf->base); +} + +/** + * Update the attachments of draw/read surfaces. + */ +static void +egl_g3d_route_context(_EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + const uint st_att_map[NUM_NATIVE_ATTACHMENTS] = { + ST_SURFACE_FRONT_LEFT, + ST_SURFACE_BACK_LEFT, + ST_SURFACE_FRONT_RIGHT, + ST_SURFACE_BACK_RIGHT, + }; + EGLint s, i; + + /* route draw and read buffers' attachments */ + for (s = 0; s < 2; s++) { + struct egl_g3d_surface *gsurf; + struct egl_g3d_buffer *gbuf; + + if (s == 0) { + gsurf = egl_g3d_surface(gctx->base.DrawSurface); + gbuf = &gctx->draw; + } + else { + gsurf = egl_g3d_surface(gctx->base.ReadSurface); + gbuf = &gctx->read; + } + + gbuf->native_atts[0] = gsurf->render_att; + gbuf->num_atts = 1; + + for (i = 0; i < gbuf->num_atts; i++) + gbuf->st_atts[i] = st_att_map[gbuf->native_atts[i]]; + + /* FIXME OpenGL defaults to draw the front or back buffer when the + * context is single-buffered or double-buffered respectively. In EGL, + * however, the buffer to be drawn is determined by the surface, instead + * of the context. As a result, rendering to a pixmap surface with a + * double-buffered context does not work as expected. + * + * gctx->stapi->st_draw_front_buffer(gctx->st_ctx, natt == + * NATIVE_ATTACHMENT_FRONT_LEFT); + */ + + /* + * FIXME If the back buffer is asked for here, and the front buffer is + * later needed by the client API (e.g. glDrawBuffer is called to draw + * the front buffer), it will create a new pipe texture and draw there. + * One fix is to ask for both buffers here, but it would be a waste if + * the front buffer is never used. A better fix is to add a callback to + * the pipe screen with context private (just like flush_frontbuffer). + */ + } +} + +/** + * Reallocate the context's framebuffers after draw/read surfaces change. + */ +static EGLBoolean +egl_g3d_realloc_context(_EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + struct egl_g3d_surface *gdraw = egl_g3d_surface(gctx->base.DrawSurface); + struct egl_g3d_surface *gread = egl_g3d_surface(gctx->base.ReadSurface); + + /* unreference the old framebuffers */ + if (gctx->draw.st_fb) { + EGLBoolean is_equal = (gctx->draw.st_fb == gctx->read.st_fb); + void *priv; + + priv = gctx->stapi->st_framebuffer_private(gctx->draw.st_fb); + if (!gdraw || priv != (void *) &gdraw->base) { + gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); + gctx->draw.st_fb = NULL; + gctx->draw.num_atts = 0; + } + + if (is_equal) { + gctx->read.st_fb = NULL; + gctx->draw.num_atts = 0; + } + else { + priv = gctx->stapi->st_framebuffer_private(gctx->read.st_fb); + if (!gread || priv != (void *) &gread->base) { + gctx->stapi->st_unreference_framebuffer(gctx->read.st_fb); + gctx->read.st_fb = NULL; + gctx->draw.num_atts = 0; + } + } + } + + if (!gdraw) + return EGL_TRUE; + + /* create the draw fb */ + if (!gctx->draw.st_fb) { + gctx->draw.st_fb = create_framebuffer(&gctx->base, &gdraw->base); + if (!gctx->draw.st_fb) + return EGL_FALSE; + } + + /* create the read fb */ + if (!gctx->read.st_fb) { + if (gread != gdraw) { + gctx->read.st_fb = create_framebuffer(&gctx->base, &gread->base); + if (!gctx->read.st_fb) { + gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); + gctx->draw.st_fb = NULL; + return EGL_FALSE; + } + } + else { + /* there is no st_reference_framebuffer... */ + gctx->read.st_fb = gctx->draw.st_fb; + } + } + + egl_g3d_route_context(dpy, &gctx->base); + gctx->force_validate = EGL_TRUE; + + return EGL_TRUE; +} + +/** + * Return the current context of the given API. + */ +static struct egl_g3d_context * +egl_g3d_get_current_context(EGLint api) +{ + _EGLThreadInfo *t = _eglGetCurrentThread(); + EGLint api_index = _eglConvertApiToIndex(api); + return egl_g3d_context(t->CurrentContexts[api_index]); +} + +/** + * Return the state tracker for the given context. + */ +static const struct egl_g3d_st * +egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + const struct egl_g3d_st *stapi; + EGLint idx = -1; + + switch (ctx->ClientAPI) { + case EGL_OPENGL_ES_API: + switch (ctx->ClientVersion) { + case 1: + idx = EGL_G3D_ST_OPENGL_ES; + break; + case 2: + idx = EGL_G3D_ST_OPENGL_ES2; + break; + default: + _eglLog(_EGL_WARNING, "unknown client version %d", + ctx->ClientVersion); + break; + } + break; + case EGL_OPENVG_API: + idx = EGL_G3D_ST_OPENVG; + break; + case EGL_OPENGL_API: + idx = EGL_G3D_ST_OPENGL; + break; + default: + _eglLog(_EGL_WARNING, "unknown client API 0x%04x", ctx->ClientAPI); + break; + } + + stapi = (idx >= 0) ? gdrv->stapis[idx] : NULL; + return stapi; +} + +/** + * Return an API mask that consists of the state trackers that supports the + * given mode. + * + * FIXME add st_is_mode_supported()? + */ +static EGLint +get_mode_api_mask(const __GLcontextModes *mode, EGLint api_mask) +{ + EGLint check; + + /* OpenGL ES 1.x and 2.x are checked together */ + check = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT; + if (api_mask & check) { + /* this is required by EGL, not by OpenGL ES */ + if (mode->drawableType & GLX_WINDOW_BIT && !mode->doubleBufferMode) + api_mask &= ~check; + } + + check = EGL_OPENVG_BIT; + if (api_mask & check) { + /* vega st needs the depth/stencil rb */ + if (!mode->depthBits && !mode->stencilBits) + api_mask &= ~check; + } + + return api_mask; +} + +/** + * Add configs to display and return the next config ID. + */ +static EGLint +egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + const struct native_config **native_configs; + int num_configs, i; + + native_configs = gdpy->native->get_configs(gdpy->native, + &num_configs); + if (!num_configs) { + if (native_configs) + free(native_configs); + return id; + } + + for (i = 0; i < num_configs; i++) { + EGLint api_mask; + struct egl_g3d_config *gconf; + EGLBoolean valid; + + api_mask = get_mode_api_mask(&native_configs[i]->mode, gdrv->api_mask); + if (!api_mask) { + _eglLog(_EGL_DEBUG, "no state tracker supports config 0x%x", + native_configs[i]->mode.visualID); + continue; + } + + gconf = CALLOC_STRUCT(egl_g3d_config); + if (!gconf) + continue; + + _eglInitConfig(&gconf->base, id); + valid = _eglConfigFromContextModesRec(&gconf->base, + &native_configs[i]->mode, api_mask, api_mask); + if (valid) + valid = _eglValidateConfig(&gconf->base, EGL_FALSE); + if (!valid) { + _eglLog(_EGL_DEBUG, "skip invalid config 0x%x", + native_configs[i]->mode.visualID); + free(gconf); + continue; + } + + gconf->native = native_configs[i]; + _eglAddConfig(dpy, &gconf->base); + id++; + } + + free(native_configs); + return id; +} + +/** + * Flush the front buffer of the context's draw surface. + */ +static void +egl_g3d_flush_frontbuffer(void *dummy, struct pipe_surface *surf, + void *context_private) +{ + struct egl_g3d_context *gctx = egl_g3d_context(context_private); + struct egl_g3d_surface *gsurf = egl_g3d_surface(gctx->base.DrawSurface); + + if (gsurf) { + gsurf->native->flush_frontbuffer(gsurf->native); + egl_g3d_validate_context(gctx->base.Display, &gctx->base); + } +} + +static EGLBoolean +egl_g3d_terminate(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + + _eglReleaseDisplayResources(drv, dpy); + _eglCleanupDisplay(dpy); + + if (gdpy->native) + gdpy->native->destroy(gdpy->native); + + free(gdpy); + dpy->DriverData = NULL; + + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, + EGLint *major, EGLint *minor) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct egl_g3d_display *gdpy; + + gdpy = CALLOC_STRUCT(egl_g3d_display); + if (!gdpy) { + _eglError(EGL_BAD_ALLOC, "eglInitialize"); + goto fail; + } + dpy->DriverData = gdpy; + + gdpy->native = + native_create_display(dpy->NativeDisplay, egl_g3d_flush_frontbuffer); + if (!gdpy->native) { + _eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)"); + goto fail; + } + + dpy->ClientAPIsMask = gdrv->api_mask; + + if (egl_g3d_add_configs(drv, dpy, 1) == 1) { + _eglError(EGL_NOT_INITIALIZED, "eglInitialize(unable to add configs)"); + goto fail; + } + + *major = 1; + *minor = 4; + + return EGL_TRUE; + +fail: + if (gdpy) + egl_g3d_terminate(drv, dpy); + return EGL_FALSE; +} + +static _EGLContext * +egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, + _EGLContext *share, const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_context *xshare = egl_g3d_context(share); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_context *gctx; + const __GLcontextModes *mode; + + gctx = CALLOC_STRUCT(egl_g3d_context); + if (!gctx) { + _eglError(EGL_BAD_ALLOC, "eglCreateContext"); + return NULL; + } + + if (!_eglInitContext(drv, &gctx->base, conf, attribs)) { + free(gctx); + return NULL; + } + + gctx->stapi = egl_g3d_choose_st(drv, &gctx->base); + if (!gctx->stapi) { + free(gctx); + return NULL; + } + + mode = &gconf->native->mode; + gctx->pipe = + gdpy->native->create_context(gdpy->native, (void *) &gctx->base); + gctx->st_ctx = gctx->stapi->st_create_context(gctx->pipe, mode, + (xshare) ? xshare->st_ctx : NULL); + + return &gctx->base; +} + +static EGLBoolean +egl_g3d_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + + if (_eglIsContextBound(&gctx->base)) + return EGL_TRUE; + + egl_g3d_realloc_context(dpy, &gctx->base); + + /* it will destroy pipe context */ + gctx->stapi->st_destroy_context(gctx->st_ctx); + + free(gctx); + + return EGL_TRUE; +} + +static _EGLSurface * +egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, EGLNativeWindowType win, + const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_surface *gsurf; + + gsurf = CALLOC_STRUCT(egl_g3d_surface); + if (!gsurf) { + _eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface"); + return NULL; + } + + if (!_eglInitSurface(drv, &gsurf->base, EGL_WINDOW_BIT, conf, attribs)) { + free(gsurf); + return NULL; + } + + gsurf->native = + gdpy->native->create_window_surface(gdpy->native, win, gconf->native); + if (!gsurf->native) { + free(gsurf); + return NULL; + } + + if (!gsurf->native->validate(gsurf->native, NULL, 0, NULL, + &gsurf->base.Width, &gsurf->base.Height)) { + gsurf->native->destroy(gsurf->native); + free(gsurf); + return NULL; + } + + gsurf->render_att = (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER || + !gconf->native->mode.doubleBufferMode) ? + NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; + + return &gsurf->base; +} + +static _EGLSurface * +egl_g3d_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, EGLNativePixmapType pix, + const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_surface *gsurf; + + gsurf = CALLOC_STRUCT(egl_g3d_surface); + if (!gsurf) { + _eglError(EGL_BAD_ALLOC, "eglCreatePixmapSurface"); + return NULL; + } + + if (!_eglInitSurface(drv, &gsurf->base, EGL_PIXMAP_BIT, conf, attribs)) { + free(gsurf); + return NULL; + } + + gsurf->native = + gdpy->native->create_pixmap_surface(gdpy->native, pix, gconf->native); + if (!gsurf->native) { + free(gsurf); + return NULL; + } + + if (!gsurf->native->validate(gsurf->native, NULL, 0, NULL, + &gsurf->base.Width, &gsurf->base.Height)) { + gsurf->native->destroy(gsurf->native); + free(gsurf); + return NULL; + } + + gsurf->render_att = NATIVE_ATTACHMENT_FRONT_LEFT; + + return &gsurf->base; +} + +static _EGLSurface * +egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_surface *gsurf; + + gsurf = CALLOC_STRUCT(egl_g3d_surface); + if (!gsurf) { + _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); + return NULL; + } + + if (!_eglInitSurface(drv, &gsurf->base, EGL_PBUFFER_BIT, conf, attribs)) { + free(gsurf); + return NULL; + } + + gsurf->native = + gdpy->native->create_pbuffer_surface(gdpy->native, gconf->native, + gsurf->base.Width, gsurf->base.Height); + if (!gsurf->native) { + free(gsurf); + return NULL; + } + + gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ? + NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; + + return &gsurf->base; +} + +static EGLBoolean +egl_g3d_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + + if (_eglIsSurfaceBound(&gsurf->base)) + return EGL_TRUE; + + pipe_surface_reference(&gsurf->render_surface, NULL); + gsurf->native->destroy(gsurf->native); + free(gsurf); + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + struct egl_g3d_context *old_gctx; + EGLint api; + EGLBoolean ok = EGL_TRUE; + + /* find the old context */ + api = (gctx) ? gctx->base.ClientAPI : eglQueryAPI(); + old_gctx = egl_g3d_get_current_context(api); + if (old_gctx && !_eglIsContextLinked(&old_gctx->base)) + old_gctx = NULL; + + if (!_eglMakeCurrent(drv, dpy, draw, read, ctx)) + return EGL_FALSE; + + if (old_gctx) { + /* flush old context */ + old_gctx->stapi->st_flush(old_gctx->st_ctx, + PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); + + /* + * The old context is no longer current, and egl_g3d_realloc_context() + * should be called to destroy the framebuffers. However, it is possible + * that it will be made current again with the same draw/read surfaces. + * It might be better to keep it around. + */ + } + + if (gctx) { + struct egl_g3d_surface *gdraw = egl_g3d_surface(draw); + + ok = egl_g3d_realloc_context(dpy, &gctx->base); + if (ok) { + ok = gctx->stapi->st_make_current(gctx->st_ctx, + gctx->draw.st_fb, gctx->read.st_fb); + if (ok) { + egl_g3d_validate_context(dpy, &gctx->base); + if (gdraw->base.Type == EGL_WINDOW_BIT) { + gctx->base.WindowRenderBuffer = + (gdraw->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) ? + EGL_SINGLE_BUFFER : EGL_BACK_BUFFER; + } + } + } + } + else if (old_gctx) { + ok = old_gctx->stapi->st_make_current(NULL, NULL, NULL); + old_gctx->base.WindowRenderBuffer = EGL_NONE; + } + + return ok; +} + +static EGLBoolean +egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + _EGLContext *ctx = _eglGetCurrentContext(); + struct egl_g3d_context *gctx = NULL; + + /* no-op for pixmap or pbuffer surface */ + if (gsurf->base.Type == EGL_PIXMAP_BIT || + gsurf->base.Type == EGL_PBUFFER_BIT) + return EGL_TRUE; + + /* or when the surface is single-buffered */ + if (gsurf->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) + return EGL_TRUE; + + if (ctx && ctx->DrawSurface == surf) + gctx = egl_g3d_context(ctx); + + /* flush if the surface is current */ + if (gctx) + gctx->stapi->st_notify_swapbuffers(gctx->draw.st_fb); + + /* + * We drew on the back buffer, unless there was no back buffer. + * In that case, we drew on the front buffer. Either case, we call + * swap_buffers. + */ + if (!gsurf->native->swap_buffers(gsurf->native)) + return EGL_FALSE; + + if (gctx) { + struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config); + + /* force validation if the swap method is not copy */ + if (gconf->native->mode.swapMethod != GLX_SWAP_COPY_OML) + gctx->force_validate = EGL_TRUE; + egl_g3d_validate_context(dpy, &gctx->base); + } + + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + gctx->stapi->st_finish(gctx->st_ctx); + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_wait_native(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine) +{ + _EGLSurface *surf = _eglGetCurrentSurface(EGL_DRAW); + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + + if (engine != EGL_CORE_NATIVE_ENGINE) + return _eglError(EGL_BAD_PARAMETER, "eglWaitNative"); + + if (gsurf) + gsurf->native->wait(gsurf->native); + + return EGL_TRUE; +} + +static _EGLProc +egl_g3d_get_proc_address(const char *procname) +{ + /* FIXME how come _EGLDriver is not passed? */ + const struct egl_g3d_st *stapi; + _EGLProc proc; + EGLint i; + + for (i = 0; i < NUM_EGL_G3D_STS; i++) { + stapi = egl_g3d_get_st(i); + if (stapi) { + proc = (_EGLProc) stapi->st_get_proc_address(procname); + if (proc) + return proc; + } + } + + return (_EGLProc) NULL; +} + +static EGLBoolean +egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *surf, EGLint buffer) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + struct egl_g3d_context *gctx; + enum pipe_format target_format; + int target; + + if (!gsurf || gsurf->base.Type != EGL_PBUFFER_BIT) + return _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); + if (buffer != EGL_BACK_BUFFER) + return _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); + if (gsurf->base.BoundToTexture) + return _eglError(EGL_BAD_ACCESS, "eglBindTexImage"); + + switch (gsurf->base.TextureFormat) { + case EGL_TEXTURE_RGB: + target_format = PIPE_FORMAT_R8G8B8_UNORM; + break; + case EGL_TEXTURE_RGBA: + target_format = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + default: + return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + } + + switch (gsurf->base.TextureTarget) { + case EGL_TEXTURE_2D: + target = ST_TEXTURE_2D; + break; + default: + return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + } + + /* flush properly if the surface is bound */ + if (gsurf->base.Binding) { + gctx = egl_g3d_context(gsurf->base.Binding); + gctx->stapi->st_flush(gctx->st_ctx, + PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); + } + + /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */ + gctx = egl_g3d_get_current_context(EGL_OPENGL_API); + if (gctx) { + if (!gsurf->render_surface) + return EGL_FALSE; + + gctx->stapi->st_bind_texture_surface(gsurf->render_surface, + target, gsurf->base.MipmapLevel, target_format); + gsurf->base.BoundToTexture = EGL_TRUE; + } + + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_release_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *surf, EGLint buffer) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + + if (!gsurf || gsurf->base.Type != EGL_PBUFFER_BIT || + !gsurf->base.BoundToTexture) + return _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); + if (buffer != EGL_BACK_BUFFER) + return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); + + if (gsurf->render_surface) { + _EGLThreadInfo *t = _eglGetCurrentThread(); + /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */ + struct egl_g3d_context *gctx = egl_g3d_context( + t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_API)]); + + /* what if the context the surface binds to is no longer current? */ + if (gctx) + gctx->stapi->st_unbind_texture_surface(gsurf->render_surface, + ST_TEXTURE_2D, gsurf->base.MipmapLevel); + } + + gsurf->base.BoundToTexture = EGL_FALSE; + + return EGL_TRUE; +} + +static void +egl_g3d_unload(_EGLDriver *drv) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + free(gdrv); +} + +_EGLDriver * +_eglMain(const char *args) +{ + static char driver_name[64]; + struct egl_g3d_driver *gdrv; + EGLint i; + + snprintf(driver_name, sizeof(driver_name), + "Gallium/%s", native_get_name()); + + gdrv = CALLOC_STRUCT(egl_g3d_driver); + if (!gdrv) + return NULL; + + _eglInitDriverFallbacks(&gdrv->base); + + gdrv->base.API.Initialize = egl_g3d_initialize; + gdrv->base.API.Terminate = egl_g3d_terminate; + gdrv->base.API.CreateContext = egl_g3d_create_context; + gdrv->base.API.DestroyContext = egl_g3d_destroy_context; + gdrv->base.API.CreateWindowSurface = egl_g3d_create_window_surface; + gdrv->base.API.CreatePixmapSurface = egl_g3d_create_pixmap_surface; + gdrv->base.API.CreatePbufferSurface = egl_g3d_create_pbuffer_surface; + gdrv->base.API.DestroySurface = egl_g3d_destroy_surface; + gdrv->base.API.MakeCurrent = egl_g3d_make_current; + gdrv->base.API.SwapBuffers = egl_g3d_swap_buffers; + gdrv->base.API.WaitClient = egl_g3d_wait_client; + gdrv->base.API.WaitNative = egl_g3d_wait_native; + gdrv->base.API.GetProcAddress = egl_g3d_get_proc_address; + + gdrv->base.API.BindTexImage = egl_g3d_bind_tex_image; + gdrv->base.API.ReleaseTexImage = egl_g3d_release_tex_image; + + gdrv->base.Name = driver_name; + gdrv->base.Unload = egl_g3d_unload; + + for (i = 0; i < NUM_EGL_G3D_STS; i++) { + gdrv->stapis[i] = egl_g3d_get_st(i); + if (gdrv->stapis[i]) + gdrv->api_mask |= gdrv->stapis[i]->api_bit; + } + + if (gdrv->api_mask) + _eglLog(_EGL_DEBUG, "Driver API mask: 0x%x", gdrv->api_mask); + else + _eglLog(_EGL_WARNING, "No supported client API"); + + return &gdrv->base; +} diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h new file mode 100644 index 00000000000..525bb488e2d --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h @@ -0,0 +1,113 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _EGL_G3D_H_ +#define _EGL_G3D_H_ + +#include "pipe/p_compiler.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "pipe/p_format.h" +#include "egldriver.h" +#include "egldisplay.h" +#include "eglcontext.h" +#include "eglsurface.h" +#include "eglconfig.h" + +#include "native.h" +#include "egl_st.h" + +struct egl_g3d_driver { + _EGLDriver base; + const struct egl_g3d_st *stapis[NUM_EGL_G3D_STS]; + EGLint api_mask; +}; + +struct egl_g3d_display { + struct native_display *native; +}; + +struct egl_g3d_buffer { + struct st_framebuffer *st_fb; + EGLint num_atts; + enum native_attachment native_atts[NUM_NATIVE_ATTACHMENTS]; + uint st_atts[NUM_NATIVE_ATTACHMENTS]; +}; + +struct egl_g3d_context { + _EGLContext base; + + const struct egl_g3d_st *stapi; + struct pipe_context *pipe; + + struct st_context *st_ctx; + EGLBoolean force_validate; + struct egl_g3d_buffer draw, read; +}; + +struct egl_g3d_surface { + _EGLSurface base; + struct native_surface *native; + enum native_attachment render_att; + struct pipe_surface *render_surface; +}; + +struct egl_g3d_config { + _EGLConfig base; + const struct native_config *native; +}; + + +static INLINE struct egl_g3d_driver * +egl_g3d_driver(_EGLDriver *drv) +{ + return (struct egl_g3d_driver *) drv; +} + +static INLINE struct egl_g3d_display * +egl_g3d_display(_EGLDisplay *dpy) +{ + /* note that it is not direct casting */ + return (struct egl_g3d_display *) dpy->DriverData; +} + +static INLINE struct egl_g3d_context * +egl_g3d_context(_EGLContext *ctx) +{ + return (struct egl_g3d_context *) ctx; +} + +static INLINE struct egl_g3d_surface * +egl_g3d_surface(_EGLSurface *surf) +{ + return (struct egl_g3d_surface *) surf; +} + +static INLINE struct egl_g3d_config * +egl_g3d_config(_EGLConfig *conf) +{ + return (struct egl_g3d_config *) conf; +} + +#endif /* _EGL_G3D_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_st.c b/src/gallium/state_trackers/egl_g3d/common/egl_st.c new file mode 100644 index 00000000000..a88ff911cd5 --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/common/egl_st.c @@ -0,0 +1,131 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include "pipe/p_compiler.h" +#include "util/u_memory.h" +#include "egllog.h" +#include "EGL/egl.h" /* for EGL_api_BIT */ + +#include "egl_st.h" + +#ifndef HAVE_DLADDR +#define HAVE_DLADDR 1 +#endif + +#if HAVE_DLADDR + +static const char * +egl_g3d_st_names[] = { +#define ST_PUBLIC(name, ...) #name, +#include "st_public_tmp.h" + NULL +}; + +static boolean +egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym) +{ + st_proc *procs = (st_proc *) stapi; + void *handle; + Dl_info info; + const char **name; + + if (!dladdr(sym, &info)) + return FALSE; + handle = dlopen(info.dli_fname, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE); + if (!handle) + return FALSE; + + for (name = egl_g3d_st_names; *name; name++) { + st_proc proc = (st_proc) dlsym(handle, *name); + if (!proc) { + _eglLog(_EGL_WARNING, "%s is missing in %s", *name, info.dli_fname); + memset(stapi, 0, sizeof(*stapi)); + dlclose(handle); + return FALSE; + } + *procs++ = proc; + } + + dlclose(handle); + return TRUE; +} + +#else /* HAVE_DLADDR */ + +static boolean +egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym) +{ +#define ST_PUBLIC(name, ...) stapi->name = name; +#include "st_public_tmp.h" + return TRUE; +} + +#endif /* HAVE_DLADDR */ + +static boolean +egl_g3d_init_st(struct egl_g3d_st *stapi, const char *api) +{ + void *handle, *sym; + boolean res = FALSE; + + /* already initialized */ + if (stapi->st_notify_swapbuffers != NULL) + return TRUE; + + handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL); + if (!handle) + return FALSE; + + sym = dlsym(handle, api); + if (sym && egl_g3d_fill_st(stapi, sym)) + res = TRUE; + + dlclose(handle); + return res; +} + +static struct { + const char *symbol; + EGLint api_bit; +} egl_g3d_st_info[NUM_EGL_G3D_STS] = { + { "st_api_OpenGL_ES1", EGL_OPENGL_ES_BIT }, + { "st_api_OpenVG", EGL_OPENVG_BIT }, + { "st_api_OpenGL_ES2", EGL_OPENGL_ES2_BIT }, + { "st_api_OpenGL", EGL_OPENGL_BIT }, +}; + +const struct egl_g3d_st * +egl_g3d_get_st(enum egl_g3d_st_api api) +{ + static struct egl_g3d_st all_trackers[NUM_EGL_G3D_STS]; + + if (egl_g3d_init_st(&all_trackers[api], egl_g3d_st_info[api].symbol)) { + all_trackers[api].api_bit = egl_g3d_st_info[api].api_bit; + return &all_trackers[api]; + } + else { + return NULL; + } +} diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_st.h b/src/gallium/state_trackers/egl_g3d/common/egl_st.h new file mode 100644 index 00000000000..8fb464bd3d7 --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/common/egl_st.h @@ -0,0 +1,73 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _EGL_ST_H_ +#define _EGL_ST_H_ + +#include "GL/gl.h" /* for GL types */ +#include "GL/internal/glcore.h" /* for __GLcontextModes */ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "pipe/p_context.h" + +/* avoid calling st functions directly */ +#if 1 + +#define ST_SURFACE_FRONT_LEFT 0 +#define ST_SURFACE_BACK_LEFT 1 +#define ST_SURFACE_FRONT_RIGHT 2 +#define ST_SURFACE_BACK_RIGHT 3 + +#define ST_TEXTURE_2D 0x2 + +struct st_context; +struct st_framebuffer; +typedef void (*st_proc)(); + +#else +#include "state_tracker/st_public.h" +#endif + +/* remember to update egl_g3d_get_st() when update the enums */ +enum egl_g3d_st_api { + EGL_G3D_ST_OPENGL_ES = 0, + EGL_G3D_ST_OPENVG, + EGL_G3D_ST_OPENGL_ES2, + EGL_G3D_ST_OPENGL, + + NUM_EGL_G3D_STS +}; + +struct egl_g3d_st { +#define ST_PUBLIC(name, ret, ...) ret (*name)(__VA_ARGS__); +#include "st_public_tmp.h" + /* fields must be added here */ + EGLint api_bit; +}; + +const struct egl_g3d_st * +egl_g3d_get_st(enum egl_g3d_st_api api); + +#endif /* _EGL_ST_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/common/native.h b/src/gallium/state_trackers/egl_g3d/common/native.h new file mode 100644 index 00000000000..34abd86a31f --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/common/native.h @@ -0,0 +1,168 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _NATIVE_H_ +#define _NATIVE_H_ + +#include "EGL/egl.h" /* for EGL native types */ +#include "GL/gl.h" /* for GL types needed by __GLcontextModes */ +#include "GL/internal/glcore.h" /* for __GLcontextModes */ + +#include "pipe/p_compiler.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "pipe/p_state.h" + +/** + * Only color buffers are listed. The others are allocated privately through, + * for example, st_renderbuffer_alloc_storage(). + */ +enum native_attachment { + NATIVE_ATTACHMENT_FRONT_LEFT, + NATIVE_ATTACHMENT_BACK_LEFT, + NATIVE_ATTACHMENT_FRONT_RIGHT, + NATIVE_ATTACHMENT_BACK_RIGHT, + + NUM_NATIVE_ATTACHMENTS +}; + +struct native_surface { + void (*destroy)(struct native_surface *nsurf); + + /** + * Swap the front and back buffers so that the back buffer is visible. It + * is no-op if the surface is single-buffered. The contents of the back + * buffer after swapping may or may not be preserved. + */ + boolean (*swap_buffers)(struct native_surface *nsurf); + + /** + * Make the front buffer visible. In some native displays, changes to the + * front buffer might not be visible immediately and require manual flush. + */ + boolean (*flush_frontbuffer)(struct native_surface *nsurf); + + /** + * Validate the buffers of the surface. Those not listed in the attachments + * will be destroyed. The returned textures are owned by the caller. + */ + boolean (*validate)(struct native_surface *nsurf, + const enum native_attachment *natts, + unsigned num_natts, + struct pipe_texture **textures, + int *width, int *height); + + /** + * Wait until all native commands affecting the surface has been executed. + */ + void (*wait)(struct native_surface *nsurf); +}; + +struct native_config { + __GLcontextModes mode; + enum pipe_format color_format; + enum pipe_format depth_format; + enum pipe_format stencil_format; +}; + +/** + * A pipe winsys abstracts the OS. A pipe screen abstracts the graphcis + * hardware. A native display consists of a pipe winsys, a pipe screen, and + * the native display server. + */ +struct native_display { + struct pipe_screen *screen; + void (*destroy)(struct native_display *ndpy); + + /** + * Get the supported configs. The configs are owned by the display, but + * the returned array should be free()ed. + * + * The configs will be converted to EGL config by + * _eglConfigFromContextModesRec and validated by _eglValidateConfig. + * Those failing to pass the test will be skipped. + */ + const struct native_config **(*get_configs)(struct native_display *ndpy, + int *num_configs); + + /** + * Create a pipe context. + */ + struct pipe_context *(*create_context)(struct native_display *ndpy, + void *context_private); + + /** + * Create a window surface. Required unless no config has GLX_WINDOW_BIT + * set. + */ + struct native_surface *(*create_window_surface)(struct native_display *ndpy, + EGLNativeWindowType win, + const struct native_config *nconf); + + /** + * Create a pixmap surface. Required unless no config has GLX_PIXMAP_BIT + * set. + */ + struct native_surface *(*create_pixmap_surface)(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf); + + /** + * Create a pbuffer surface. Required unless no config has GLX_PBUFFER_BIT + * set. + */ + struct native_surface *(*create_pbuffer_surface)(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height); + +#if 0 + struct native_mode *(*get_modes)(struct native_display *ndpy, + int *num_modes); + + /** + * Create a screen surface. + */ + struct native_surface *(*create_screen_surface)(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height); + + boolean (*set_mode)(struct native_display *ndpy, + const struct native_mode *nmode, + struct native_surface *nsurf); +#endif +}; + + +typedef void (*native_flush_frontbuffer)(void *dummy, + struct pipe_surface *surf, + void *context_private); + +const char * +native_get_name(void); + +struct native_display * +native_create_display(EGLNativeDisplayType dpy, + native_flush_frontbuffer flush_frontbuffer); + +#endif /* _NATIVE_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/common/st_public_tmp.h b/src/gallium/state_trackers/egl_g3d/common/st_public_tmp.h new file mode 100644 index 00000000000..507a0ec4027 --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/common/st_public_tmp.h @@ -0,0 +1,20 @@ +ST_PUBLIC(st_create_context, struct st_context *, struct pipe_context *pipe, const __GLcontextModes *visual, struct st_context *share) +ST_PUBLIC(st_destroy_context, void, struct st_context *st) +ST_PUBLIC(st_copy_context_state, void, struct st_context *dst, struct st_context *src, uint mask) +ST_PUBLIC(st_create_framebuffer, struct st_framebuffer *, const __GLcontextModes *visual, enum pipe_format colorFormat, enum pipe_format depthFormat, enum pipe_format stencilFormat, uint width, uint height, void *privateData) +ST_PUBLIC(st_resize_framebuffer, void, struct st_framebuffer *stfb, uint width, uint height) +ST_PUBLIC(st_set_framebuffer_surface, void, struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface *surf) +ST_PUBLIC(st_get_framebuffer_dimensions, void, struct st_framebuffer *stfb, uint *width, uint *height) +ST_PUBLIC(st_get_framebuffer_surface, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface **surface) +ST_PUBLIC(st_get_framebuffer_texture, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_texture **texture) +ST_PUBLIC(st_framebuffer_private, void *, struct st_framebuffer *stfb) +ST_PUBLIC(st_unreference_framebuffer, void, struct st_framebuffer *stfb) +ST_PUBLIC(st_make_current, GLboolean, struct st_context *st, struct st_framebuffer *draw, struct st_framebuffer *read) +ST_PUBLIC(st_get_current, struct st_context *, void) +ST_PUBLIC(st_flush, void, struct st_context *st, uint pipeFlushFlags, struct pipe_fence_handle **fence) +ST_PUBLIC(st_finish, void, struct st_context *st) +ST_PUBLIC(st_notify_swapbuffers, void, struct st_framebuffer *stfb) +ST_PUBLIC(st_bind_texture_surface, int, struct pipe_surface *ps, int target, int level, enum pipe_format format) +ST_PUBLIC(st_unbind_texture_surface, int, struct pipe_surface *ps, int target, int level) +ST_PUBLIC(st_get_proc_address, st_proc, const char *procname) +#undef ST_PUBLIC diff --git a/src/gallium/state_trackers/egl_g3d/x11/glxinit.c b/src/gallium/state_trackers/egl_g3d/x11/glxinit.c new file mode 100644 index 00000000000..c955a908b93 --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/x11/glxinit.c @@ -0,0 +1,573 @@ +/** + * GLX initialization. Code based on glxext.c, glx_query.c, and + * glcontextmodes.c under src/glx/x11/. The major difference is that no DRI + * related code here. + * + */ + +#include +#include +#include +#include +#include +#include + +#include "x11_screen.h" +#include "glxinit.h" + +typedef struct GLXGenericGetString +{ + CARD8 reqType; + CARD8 glxCode; + CARD16 length B16; + CARD32 for_whom B32; + CARD32 name B32; +} xGLXGenericGetStringReq; + +#define sz_xGLXGenericGetStringReq 12 +#define X_GLXGenericGetString 0 + +/* Extension required boiler plate */ + +static char *__glXExtensionName = GLX_EXTENSION_NAME; +static XExtensionInfo *__glXExtensionInfo = NULL; + +static /* const */ XExtensionHooks __glXExtensionHooks = { NULL }; +static +XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo, + __glXExtensionName, &__glXExtensionHooks, + __GLX_NUMBER_EVENTS, NULL) + +static GLint +_gl_convert_from_x_visual_type(int visualType) +{ +#define NUM_VISUAL_TYPES 6 + static const int glx_visual_types[NUM_VISUAL_TYPES] = { + GLX_STATIC_GRAY, GLX_GRAY_SCALE, + GLX_STATIC_COLOR, GLX_PSEUDO_COLOR, + GLX_TRUE_COLOR, GLX_DIRECT_COLOR + }; + + return ((unsigned) visualType < NUM_VISUAL_TYPES) + ? glx_visual_types[visualType] : GLX_NONE; +} + +_X_HIDDEN char * +__glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name) +{ + xGLXGenericGetStringReq *req; + xGLXSingleReply reply; + int length; + int numbytes; + char *buf; + CARD32 for_whom = screen; + CARD32 glxCode = X_GLXQueryServerString; + + + LockDisplay(dpy); + + + /* All of the GLX protocol requests for getting a string from the server + * look the same. The exact meaning of the for_whom field is usually + * either the screen number (for glXQueryServerString) or the context tag + * (for GLXSingle). + */ + + GetReq(GLXGenericGetString, req); + req->reqType = opcode; + req->glxCode = glxCode; + req->for_whom = for_whom; + req->name = name; + + _XReply(dpy, (xReply *) & reply, 0, False); + + length = reply.length * 4; + numbytes = reply.size; + + buf = (char *) Xmalloc(numbytes); + if (buf != NULL) { + _XRead(dpy, buf, numbytes); + length -= numbytes; + } + + _XEatData(dpy, length); + + UnlockDisplay(dpy); + SyncHandle(); + + return buf; +} + +/************************************************************************/ +/* +** Free the per screen configs data as well as the array of +** __glXScreenConfigs. +*/ +static void +FreeScreenConfigs(__GLXdisplayPrivate * priv) +{ + __GLXscreenConfigs *psc; + GLint i, screens; + + /* Free screen configuration information */ + psc = priv->screenConfigs; + screens = ScreenCount(priv->dpy); + for (i = 0; i < screens; i++, psc++) { + if (psc->configs) { + x11_context_modes_destroy(psc->configs); + psc->configs = NULL; /* NOTE: just for paranoia */ + } + if (psc->visuals) { + x11_context_modes_destroy(psc->visuals); + psc->visuals = NULL; /* NOTE: just for paranoia */ + } + Xfree((char *) psc->serverGLXexts); + } + XFree((char *) priv->screenConfigs); + priv->screenConfigs = NULL; +} + +/************************************************************************/ + +/* +** Query the version of the GLX extension. This procedure works even if +** the client extension is not completely set up. +*/ +static Bool +QueryVersion(Display * dpy, int opcode, int *major, int *minor) +{ + xGLXQueryVersionReq *req; + xGLXQueryVersionReply reply; + + /* Send the glXQueryVersion request */ + LockDisplay(dpy); + GetReq(GLXQueryVersion, req); + req->reqType = opcode; + req->glxCode = X_GLXQueryVersion; + req->majorVersion = GLX_MAJOR_VERSION; + req->minorVersion = GLX_MINOR_VERSION; + _XReply(dpy, (xReply *) & reply, 0, False); + UnlockDisplay(dpy); + SyncHandle(); + + if (reply.majorVersion != GLX_MAJOR_VERSION) { + /* + ** The server does not support the same major release as this + ** client. + */ + return GL_FALSE; + } + *major = reply.majorVersion; + *minor = min(reply.minorVersion, GLX_MINOR_VERSION); + return GL_TRUE; +} + +_X_HIDDEN void +__glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count, + const INT32 * bp, Bool tagged_only, + Bool fbconfig_style_tags) +{ + int i; + + if (!tagged_only) { + /* Copy in the first set of properties */ + config->visualID = *bp++; + + config->visualType = _gl_convert_from_x_visual_type(*bp++); + + config->rgbMode = *bp++; + + config->redBits = *bp++; + config->greenBits = *bp++; + config->blueBits = *bp++; + config->alphaBits = *bp++; + config->accumRedBits = *bp++; + config->accumGreenBits = *bp++; + config->accumBlueBits = *bp++; + config->accumAlphaBits = *bp++; + + config->doubleBufferMode = *bp++; + config->stereoMode = *bp++; + + config->rgbBits = *bp++; + config->depthBits = *bp++; + config->stencilBits = *bp++; + config->numAuxBuffers = *bp++; + config->level = *bp++; + + count -= __GLX_MIN_CONFIG_PROPS; + } + + /* + ** Additional properties may be in a list at the end + ** of the reply. They are in pairs of property type + ** and property value. + */ + +#define FETCH_OR_SET(tag) \ + config-> tag = ( fbconfig_style_tags ) ? *bp++ : 1 + + for (i = 0; i < count; i += 2) { + switch (*bp++) { + case GLX_RGBA: + FETCH_OR_SET(rgbMode); + break; + case GLX_BUFFER_SIZE: + config->rgbBits = *bp++; + break; + case GLX_LEVEL: + config->level = *bp++; + break; + case GLX_DOUBLEBUFFER: + FETCH_OR_SET(doubleBufferMode); + break; + case GLX_STEREO: + FETCH_OR_SET(stereoMode); + break; + case GLX_AUX_BUFFERS: + config->numAuxBuffers = *bp++; + break; + case GLX_RED_SIZE: + config->redBits = *bp++; + break; + case GLX_GREEN_SIZE: + config->greenBits = *bp++; + break; + case GLX_BLUE_SIZE: + config->blueBits = *bp++; + break; + case GLX_ALPHA_SIZE: + config->alphaBits = *bp++; + break; + case GLX_DEPTH_SIZE: + config->depthBits = *bp++; + break; + case GLX_STENCIL_SIZE: + config->stencilBits = *bp++; + break; + case GLX_ACCUM_RED_SIZE: + config->accumRedBits = *bp++; + break; + case GLX_ACCUM_GREEN_SIZE: + config->accumGreenBits = *bp++; + break; + case GLX_ACCUM_BLUE_SIZE: + config->accumBlueBits = *bp++; + break; + case GLX_ACCUM_ALPHA_SIZE: + config->accumAlphaBits = *bp++; + break; + case GLX_VISUAL_CAVEAT_EXT: + config->visualRating = *bp++; + break; + case GLX_X_VISUAL_TYPE: + config->visualType = *bp++; + break; + case GLX_TRANSPARENT_TYPE: + config->transparentPixel = *bp++; + break; + case GLX_TRANSPARENT_INDEX_VALUE: + config->transparentIndex = *bp++; + break; + case GLX_TRANSPARENT_RED_VALUE: + config->transparentRed = *bp++; + break; + case GLX_TRANSPARENT_GREEN_VALUE: + config->transparentGreen = *bp++; + break; + case GLX_TRANSPARENT_BLUE_VALUE: + config->transparentBlue = *bp++; + break; + case GLX_TRANSPARENT_ALPHA_VALUE: + config->transparentAlpha = *bp++; + break; + case GLX_VISUAL_ID: + config->visualID = *bp++; + break; + case GLX_DRAWABLE_TYPE: + config->drawableType = *bp++; + break; + case GLX_RENDER_TYPE: + config->renderType = *bp++; + break; + case GLX_X_RENDERABLE: + config->xRenderable = *bp++; + break; + case GLX_FBCONFIG_ID: + config->fbconfigID = *bp++; + break; + case GLX_MAX_PBUFFER_WIDTH: + config->maxPbufferWidth = *bp++; + break; + case GLX_MAX_PBUFFER_HEIGHT: + config->maxPbufferHeight = *bp++; + break; + case GLX_MAX_PBUFFER_PIXELS: + config->maxPbufferPixels = *bp++; + break; + case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX: + config->optimalPbufferWidth = *bp++; + break; + case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX: + config->optimalPbufferHeight = *bp++; + break; + case GLX_VISUAL_SELECT_GROUP_SGIX: + config->visualSelectGroup = *bp++; + break; + case GLX_SWAP_METHOD_OML: + config->swapMethod = *bp++; + break; + case GLX_SAMPLE_BUFFERS_SGIS: + config->sampleBuffers = *bp++; + break; + case GLX_SAMPLES_SGIS: + config->samples = *bp++; + break; + case GLX_BIND_TO_TEXTURE_RGB_EXT: + config->bindToTextureRgb = *bp++; + break; + case GLX_BIND_TO_TEXTURE_RGBA_EXT: + config->bindToTextureRgba = *bp++; + break; + case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: + config->bindToMipmapTexture = *bp++; + break; + case GLX_BIND_TO_TEXTURE_TARGETS_EXT: + config->bindToTextureTargets = *bp++; + break; + case GLX_Y_INVERTED_EXT: + config->yInverted = *bp++; + break; + case None: + i = count; + break; + default: + break; + } + } + + config->renderType = + (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; + + config->haveAccumBuffer = ((config->accumRedBits + + config->accumGreenBits + + config->accumBlueBits + + config->accumAlphaBits) > 0); + config->haveDepthBuffer = (config->depthBits > 0); + config->haveStencilBuffer = (config->stencilBits > 0); +} + +static __GLcontextModes * +createConfigsFromProperties(Display * dpy, int nvisuals, int nprops, + int screen, GLboolean tagged_only) +{ + INT32 buf[__GLX_TOTAL_CONFIG], *props; + unsigned prop_size; + __GLcontextModes *modes, *m; + int i; + + if (nprops == 0) + return NULL; + + /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */ + + /* Check number of properties */ + if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS) + return NULL; + + /* Allocate memory for our config structure */ + modes = x11_context_modes_create(nvisuals); + if (!modes) + return NULL; + + prop_size = nprops * __GLX_SIZE_INT32; + if (prop_size <= sizeof(buf)) + props = buf; + else + props = Xmalloc(prop_size); + + /* Read each config structure and convert it into our format */ + m = modes; + for (i = 0; i < nvisuals; i++) { + _XRead(dpy, (char *) props, prop_size); + /* Older X servers don't send this so we default it here. */ + m->drawableType = GLX_WINDOW_BIT; + __glXInitializeVisualConfigFromTags(m, nprops, props, + tagged_only, GL_TRUE); + m->screen = screen; + m = m->next; + } + + if (props != buf) + Xfree(props); + + return modes; +} + +static GLboolean +getVisualConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen) +{ + xGLXGetVisualConfigsReq *req; + __GLXscreenConfigs *psc; + xGLXGetVisualConfigsReply reply; + + LockDisplay(dpy); + + psc = priv->screenConfigs + screen; + psc->visuals = NULL; + GetReq(GLXGetVisualConfigs, req); + req->reqType = priv->majorOpcode; + req->glxCode = X_GLXGetVisualConfigs; + req->screen = screen; + + if (!_XReply(dpy, (xReply *) & reply, 0, False)) + goto out; + + psc->visuals = createConfigsFromProperties(dpy, + reply.numVisuals, + reply.numProps, + screen, GL_FALSE); + + out: + UnlockDisplay(dpy); + return psc->visuals != NULL; +} + +static GLboolean +getFBConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen) +{ + xGLXGetFBConfigsReq *fb_req; + xGLXGetFBConfigsSGIXReq *sgi_req; + xGLXVendorPrivateWithReplyReq *vpreq; + xGLXGetFBConfigsReply reply; + __GLXscreenConfigs *psc; + + psc = priv->screenConfigs + screen; + psc->serverGLXexts = + __glXQueryServerString(dpy, priv->majorOpcode, screen, GLX_EXTENSIONS); + + LockDisplay(dpy); + + psc->configs = NULL; + if (atof(priv->serverGLXversion) >= 1.3) { + GetReq(GLXGetFBConfigs, fb_req); + fb_req->reqType = priv->majorOpcode; + fb_req->glxCode = X_GLXGetFBConfigs; + fb_req->screen = screen; + } + else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) { + GetReqExtra(GLXVendorPrivateWithReply, + sz_xGLXGetFBConfigsSGIXReq + + sz_xGLXVendorPrivateWithReplyReq, vpreq); + sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq; + sgi_req->reqType = priv->majorOpcode; + sgi_req->glxCode = X_GLXVendorPrivateWithReply; + sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX; + sgi_req->screen = screen; + } + else + goto out; + + if (!_XReply(dpy, (xReply *) & reply, 0, False)) + goto out; + + psc->configs = createConfigsFromProperties(dpy, + reply.numFBConfigs, + reply.numAttribs * 2, + screen, GL_TRUE); + + out: + UnlockDisplay(dpy); + return psc->configs != NULL; +} + +static GLboolean +AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv) +{ + __GLXscreenConfigs *psc; + GLint i, screens; + + /* + ** First allocate memory for the array of per screen configs. + */ + screens = ScreenCount(dpy); + psc = (__GLXscreenConfigs *) Xmalloc(screens * sizeof(__GLXscreenConfigs)); + if (!psc) { + return GL_FALSE; + } + memset(psc, 0, screens * sizeof(__GLXscreenConfigs)); + priv->screenConfigs = psc; + + priv->serverGLXversion = + __glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION); + if (priv->serverGLXversion == NULL) { + FreeScreenConfigs(priv); + return GL_FALSE; + } + + for (i = 0; i < screens; i++, psc++) { + getFBConfigs(dpy, priv, i); + getVisualConfigs(dpy, priv, i); + psc->scr = i; + psc->dpy = dpy; + } + + SyncHandle(); + + return GL_TRUE; +} + +_X_HIDDEN void +__glXRelease(__GLXdisplayPrivate *dpyPriv) +{ + FreeScreenConfigs(dpyPriv); + + if (dpyPriv->serverGLXvendor) { + Xfree((char *) dpyPriv->serverGLXvendor); + dpyPriv->serverGLXvendor = NULL; + } + if (dpyPriv->serverGLXversion) { + Xfree((char *) dpyPriv->serverGLXversion); + dpyPriv->serverGLXversion = NULL; + } + + Xfree(dpyPriv); +} + +_X_HIDDEN __GLXdisplayPrivate * +__glXInitialize(Display * dpy) +{ + XExtDisplayInfo *info = __glXFindDisplay(dpy); + __GLXdisplayPrivate *dpyPriv; + int major, minor; + + if (!XextHasExtension(info)) + return NULL; + + /* See if the versions are compatible */ + if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor)) + return NULL; + + dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate)); + if (!dpyPriv) + return NULL; + + /* + ** Init the display private and then read in the screen config + ** structures from the server. + */ + dpyPriv->majorOpcode = info->codes->major_opcode; + dpyPriv->majorVersion = major; + dpyPriv->minorVersion = minor; + dpyPriv->dpy = dpy; + + dpyPriv->serverGLXvendor = NULL; + dpyPriv->serverGLXversion = NULL; + + if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) { + Xfree(dpyPriv); + return NULL; + } + + return dpyPriv; +} diff --git a/src/gallium/state_trackers/egl_g3d/x11/glxinit.h b/src/gallium/state_trackers/egl_g3d/x11/glxinit.h new file mode 100644 index 00000000000..515a8252220 --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/x11/glxinit.h @@ -0,0 +1,14 @@ +#ifndef GLXINIT_INCLUDED +#define GLXINIT_INCLUDED + +#include + +#ifndef GLX_DIRECT_RENDERING +#define GLX_DIRECT_RENDERING +#endif +#include "glxclient.h" + +extern void +__glXRelease(__GLXdisplayPrivate *dpyPriv); + +#endif /* GLXINIT_INCLUDED */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c new file mode 100644 index 00000000000..0dda786bbdb --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c @@ -0,0 +1,693 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "util/u_memory.h" +#include "util/u_math.h" +#include "util/u_format.h" +#include "pipe/p_compiler.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "state_tracker/drm_api.h" +#include "egllog.h" + +#include "native_x11.h" +#include "x11_screen.h" + +enum dri2_surface_type { + DRI2_SURFACE_TYPE_WINDOW, + DRI2_SURFACE_TYPE_PIXMAP, + DRI2_SURFACE_TYPE_PBUFFER +}; + +struct dri2_display { + struct native_display base; + Display *dpy; + boolean own_dpy; + + struct drm_api *api; + struct x11_screen *xscr; + int xscr_number; + + struct dri2_config *configs; + int num_configs; +}; + +struct dri2_surface { + struct native_surface base; + Drawable drawable; + enum dri2_surface_type type; + enum pipe_format color_format; + struct dri2_display *dri2dpy; + + struct pipe_texture *pbuffer_textures[NUM_NATIVE_ATTACHMENTS]; + boolean have_back, have_fake; + int width, height; +}; + +struct dri2_config { + struct native_config base; +}; + +static INLINE struct dri2_display * +dri2_display(const struct native_display *ndpy) +{ + return (struct dri2_display *) ndpy; +} + +static INLINE struct dri2_surface * +dri2_surface(const struct native_surface *nsurf) +{ + return (struct dri2_surface *) nsurf; +} + +static INLINE struct dri2_config * +dri2_config(const struct native_config *nconf) +{ + return (struct dri2_config *) nconf; +} + +static boolean +dri2_surface_flush_frontbuffer(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + + /* pbuffer is private */ + if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) + return TRUE; + + /* copy to real front buffer */ + if (dri2surf->have_fake) + x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, + 0, 0, dri2surf->width, dri2surf->height, + DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft); + + return TRUE; +} + +static boolean +dri2_surface_swap_buffers(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + + /* pbuffer is private */ + if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) + return TRUE; + + /* copy to front buffer */ + if (dri2surf->have_back) + x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, + 0, 0, dri2surf->width, dri2surf->height, + DRI2BufferBackLeft, DRI2BufferFrontLeft); + + /* and update fake front buffer */ + if (dri2surf->have_fake) + x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, + 0, 0, dri2surf->width, dri2surf->height, + DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); + + return TRUE; +} + +static boolean +dri2_surface_validate(struct native_surface *nsurf, + const enum native_attachment *natts, + unsigned num_natts, + struct pipe_texture **textures, + int *width, int *height) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + unsigned int dri2atts[NUM_NATIVE_ATTACHMENTS]; + EGLint texture_indices[NUM_NATIVE_ATTACHMENTS]; + struct pipe_texture templ; + struct x11_drawable_buffer *xbufs; + int num_ins, num_outs, i; + + if (num_natts) { + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.last_level = 0; + templ.width0 = dri2surf->width; + templ.height0 = dri2surf->height; + templ.depth0 = 1; + templ.format = dri2surf->color_format; + templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + + if (textures) + memset(textures, 0, sizeof(*textures) * num_natts); + } + + /* create textures for pbuffer */ + if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) { + struct pipe_screen *screen = dri2dpy->base.screen; + + for (i = 0; i < num_natts; i++) { + enum native_attachment natt = natts[i]; + struct pipe_texture *ptex = dri2surf->pbuffer_textures[natt]; + + if (!ptex) { + ptex = screen->texture_create(screen, &templ); + dri2surf->pbuffer_textures[natt] = ptex; + } + + if (textures) + pipe_texture_reference(&textures[i], ptex); + } + + if (width) + *width = dri2surf->width; + if (height) + *height = dri2surf->height; + + return TRUE; + } + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) + texture_indices[i] = -1; + + /* prepare the attachments */ + num_ins = num_natts; + for (i = 0; i < num_natts; i++) { + unsigned int dri2att; + + switch (natts[i]) { + case NATIVE_ATTACHMENT_FRONT_LEFT: + dri2att = DRI2BufferFrontLeft; + break; + case NATIVE_ATTACHMENT_BACK_LEFT: + dri2att = DRI2BufferBackLeft; + break; + case NATIVE_ATTACHMENT_FRONT_RIGHT: + dri2att = DRI2BufferFrontRight; + break; + case NATIVE_ATTACHMENT_BACK_RIGHT: + dri2att = DRI2BufferBackRight; + break; + default: + assert(0); + dri2att = 0; + break; + } + dri2atts[i] = dri2att; + texture_indices[natts[i]] = i; + } + + dri2surf->have_back = FALSE; + dri2surf->have_fake = FALSE; + + xbufs = x11_drawable_get_buffers(dri2dpy->xscr, dri2surf->drawable, + &dri2surf->width, &dri2surf->height, + dri2atts, FALSE, num_ins, &num_outs); + if (!xbufs) + return FALSE; + + /* update width and height */ + templ.width0 = dri2surf->width; + templ.height0 = dri2surf->height; + + for (i = 0; i < num_outs; i++) { + struct x11_drawable_buffer *xbuf = &xbufs[i]; + const char *desc; + enum native_attachment natt; + + switch (xbuf->attachment) { + case DRI2BufferFrontLeft: + natt = NATIVE_ATTACHMENT_FRONT_LEFT; + desc = "DRI2 Front Buffer"; + break; + case DRI2BufferFakeFrontLeft: + natt = NATIVE_ATTACHMENT_FRONT_LEFT; + desc = "DRI2 Fake Front Buffer"; + dri2surf->have_fake = TRUE; + break; + case DRI2BufferBackLeft: + natt = NATIVE_ATTACHMENT_BACK_LEFT; + desc = "DRI2 Back Buffer"; + dri2surf->have_back = TRUE; + break; + default: + desc = NULL; + break; + } + + if (!desc || texture_indices[natt] < 0 || + (textures && textures[texture_indices[natt]])) { + if (!desc) + _eglLog(_EGL_WARNING, "unknown buffer %d", xbuf->attachment); + else if (texture_indices[natt] < 0) + _eglLog(_EGL_WARNING, "unexpected buffer %d", xbuf->attachment); + else if (textures && textures[texture_indices[natt]]) + _eglLog(_EGL_WARNING, "both real and fake front buffers are listed"); + continue; + } + + if (textures) { + struct pipe_texture *ptex = + dri2dpy->api->texture_from_shared_handle(dri2dpy->api, + dri2dpy->base.screen, &templ, + desc, xbuf->pitch, xbuf->name); + if (ptex) { + /* the caller owns the textures */ + textures[texture_indices[natt]] = ptex; + } + } + } + + free(xbufs); + + if (width) + *width = dri2surf->width; + if (height) + *height = dri2surf->height; + + return TRUE; +} + +static void +dri2_surface_wait(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + + if (dri2surf->have_fake) { + x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, + 0, 0, dri2surf->width, dri2surf->height, + DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); + } +} + +static void +dri2_surface_destroy(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + int i; + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { + struct pipe_texture *ptex = dri2surf->pbuffer_textures[i]; + pipe_texture_reference(&ptex, NULL); + } + + if (dri2surf->drawable) + x11_drawable_enable_dri2(dri2surf->dri2dpy->xscr, + dri2surf->drawable, FALSE); + free(dri2surf); +} + +static struct dri2_surface * +dri2_display_create_surface(struct native_display *ndpy, + enum dri2_surface_type type, + Drawable drawable, + const struct native_config *nconf) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + struct dri2_config *dri2conf = dri2_config(nconf); + struct dri2_surface *dri2surf; + + dri2surf = CALLOC_STRUCT(dri2_surface); + if (!dri2surf) + return NULL; + + if (drawable) + x11_drawable_enable_dri2(dri2dpy->xscr, drawable, TRUE); + + dri2surf->dri2dpy = dri2dpy; + dri2surf->type = type; + dri2surf->drawable = drawable; + dri2surf->color_format = dri2conf->base.color_format; + + dri2surf->base.destroy = dri2_surface_destroy; + dri2surf->base.swap_buffers = dri2_surface_swap_buffers; + dri2surf->base.flush_frontbuffer = dri2_surface_flush_frontbuffer; + dri2surf->base.validate = dri2_surface_validate; + dri2surf->base.wait = dri2_surface_wait; + + return dri2surf; +} + +static struct native_surface * +dri2_display_create_window_surface(struct native_display *ndpy, + EGLNativeWindowType win, + const struct native_config *nconf) +{ + struct dri2_surface *dri2surf; + + dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_WINDOW, + (Drawable) win, nconf); + return (dri2surf) ? &dri2surf->base : NULL; +} + +static struct native_surface * +dri2_display_create_pixmap_surface(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf) +{ + struct dri2_surface *dri2surf; + + dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_PIXMAP, + (Drawable) pix, nconf); + return (dri2surf) ? &dri2surf->base : NULL; +} + +static struct native_surface * +dri2_display_create_pbuffer_surface(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height) +{ + struct dri2_surface *dri2surf; + + dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_PBUFFER, + (Drawable) None, nconf); + if (dri2surf) { + dri2surf->width = width; + dri2surf->height = height; + } + return (dri2surf) ? &dri2surf->base : NULL; +} + +static struct pipe_context * +dri2_display_create_context(struct native_display *ndpy, void *context_private) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + struct pipe_context *pctx; + + pctx = dri2dpy->api->create_context(dri2dpy->api, dri2dpy->base.screen); + if (pctx) + pctx->priv = context_private; + return pctx; +} + +static int +choose_color_format(const __GLcontextModes *mode, enum pipe_format formats[32]) +{ + int count = 0; + + switch (mode->rgbBits) { + case 32: + formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; + formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; + break; + case 24: + formats[count++] = PIPE_FORMAT_X8R8G8B8_UNORM; + formats[count++] = PIPE_FORMAT_B8G8R8X8_UNORM; + formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; + formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; + break; + case 16: + formats[count++] = PIPE_FORMAT_R5G6B5_UNORM; + break; + default: + break; + } + + return count; +} + +static int +choose_depth_stencil_format(const __GLcontextModes *mode, + enum pipe_format formats[32]) +{ + int count = 0; + + switch (mode->depthBits) { + case 32: + formats[count++] = PIPE_FORMAT_Z32_UNORM; + break; + case 24: + if (mode->stencilBits) { + formats[count++] = PIPE_FORMAT_S8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24S8_UNORM; + } + else { + formats[count++] = PIPE_FORMAT_X8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24X8_UNORM; + } + break; + case 16: + formats[count++] = PIPE_FORMAT_Z16_UNORM; + break; + default: + break; + } + + return count; +} + +static boolean +is_format_supported(struct pipe_screen *screen, + enum pipe_format fmt, boolean is_color) +{ + return screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D, + (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET : + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); +} + +static boolean +dri2_display_convert_config(struct native_display *ndpy, + const __GLcontextModes *mode, + struct native_config *nconf) +{ + enum pipe_format formats[32]; + int num_formats, i; + + if (!(mode->renderType & GLX_RGBA_BIT) || !mode->rgbMode) + return FALSE; + + /* skip single-buffered configs */ + if (!mode->doubleBufferMode) + return FALSE; + + nconf->mode = *mode; + nconf->mode.renderType = GLX_RGBA_BIT; + nconf->mode.rgbMode = TRUE; + /* pbuffer is allocated locally and is always supported */ + nconf->mode.drawableType |= GLX_PBUFFER_BIT; + /* the swap method is always copy */ + nconf->mode.swapMethod = GLX_SWAP_COPY_OML; + + /* fix up */ + nconf->mode.rgbBits = + nconf->mode.redBits + nconf->mode.greenBits + + nconf->mode.blueBits + nconf->mode.alphaBits; + if (!(nconf->mode.drawableType & GLX_WINDOW_BIT)) { + nconf->mode.visualID = 0; + nconf->mode.visualType = GLX_NONE; + } + if (!(nconf->mode.drawableType & GLX_PBUFFER_BIT)) { + nconf->mode.bindToTextureRgb = FALSE; + nconf->mode.bindToTextureRgba = FALSE; + } + + nconf->color_format = PIPE_FORMAT_NONE; + nconf->depth_format = PIPE_FORMAT_NONE; + nconf->stencil_format = PIPE_FORMAT_NONE; + + /* choose color format */ + num_formats = choose_color_format(mode, formats); + for (i = 0; i < num_formats; i++) { + if (is_format_supported(ndpy->screen, formats[i], TRUE)) { + nconf->color_format = formats[i]; + break; + } + } + if (nconf->color_format == PIPE_FORMAT_NONE) + return FALSE; + + /* choose depth/stencil format */ + num_formats = choose_depth_stencil_format(mode, formats); + for (i = 0; i < num_formats; i++) { + if (is_format_supported(ndpy->screen, formats[i], FALSE)) { + nconf->depth_format = formats[i]; + nconf->stencil_format = formats[i]; + break; + } + } + if ((nconf->mode.depthBits && nconf->depth_format == PIPE_FORMAT_NONE) || + (nconf->mode.stencilBits && nconf->stencil_format == PIPE_FORMAT_NONE)) + return FALSE; + + return TRUE; +} + +static const struct native_config ** +dri2_display_get_configs(struct native_display *ndpy, int *num_configs) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + const struct native_config **configs; + int i; + + /* first time */ + if (!dri2dpy->configs) { + const __GLcontextModes *modes; + int num_modes, count; + + modes = x11_screen_get_glx_configs(dri2dpy->xscr); + if (!modes) + return NULL; + num_modes = x11_context_modes_count(modes); + + dri2dpy->configs = calloc(num_modes, sizeof(*dri2dpy->configs)); + if (!dri2dpy->configs) + return NULL; + + count = 0; + for (i = 0; i < num_modes; i++) { + struct native_config *nconf = &dri2dpy->configs[count].base; + if (dri2_display_convert_config(&dri2dpy->base, modes, nconf)) + count++; + modes = modes->next; + } + + dri2dpy->num_configs = count; + } + + configs = malloc(dri2dpy->num_configs * sizeof(*configs)); + if (configs) { + for (i = 0; i < dri2dpy->num_configs; i++) + configs[i] = (const struct native_config *) &dri2dpy->configs[i]; + if (num_configs) + *num_configs = dri2dpy->num_configs; + } + + return configs; +} + +static void +dri2_display_destroy(struct native_display *ndpy) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + + if (dri2dpy->configs) + free(dri2dpy->configs); + + if (dri2dpy->base.screen) + dri2dpy->base.screen->destroy(dri2dpy->base.screen); + + if (dri2dpy->xscr) + x11_screen_destroy(dri2dpy->xscr); + if (dri2dpy->own_dpy) + XCloseDisplay(dri2dpy->dpy); + if (dri2dpy->api && dri2dpy->api->destroy) + dri2dpy->api->destroy(dri2dpy->api); + free(dri2dpy); +} + +/** + * Initialize DRI2 and pipe screen. + */ +static boolean +dri2_display_init_screen(struct native_display *ndpy) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + const char *driver = dri2dpy->api->name; + struct drm_create_screen_arg arg; + int fd; + + if (!x11_screen_support(dri2dpy->xscr, X11_SCREEN_EXTENSION_DRI2) || + !x11_screen_support(dri2dpy->xscr, X11_SCREEN_EXTENSION_GLX)) { + _eglLog(_EGL_WARNING, "GLX/DRI2 is not supported"); + return FALSE; + } + + fd = x11_screen_enable_dri2(dri2dpy->xscr, driver); + if (fd < 0) + return FALSE; + + memset(&arg, 0, sizeof(arg)); + arg.mode = DRM_CREATE_NORMAL; + dri2dpy->base.screen = dri2dpy->api->create_screen(dri2dpy->api, fd, &arg); + if (!dri2dpy->base.screen) { + _eglLog(_EGL_WARNING, "failed to create DRM screen"); + return FALSE; + } + + return TRUE; +} + +static void +dri2_display_flush_frontbuffer(void *dummy, struct pipe_surface *surf, + void *context_private) +{ + /* TODO get native surface from context private, and remove the callback */ + _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied"); +} + +struct native_display * +x11_create_dri2_display(EGLNativeDisplayType dpy, + struct drm_api *api, + native_flush_frontbuffer flush_frontbuffer) +{ + struct dri2_display *dri2dpy; + + dri2dpy = CALLOC_STRUCT(dri2_display); + if (!dri2dpy) + return NULL; + + dri2dpy->api = api; + if (!dri2dpy->api) { + _eglLog(_EGL_WARNING, "failed to create DRM API"); + free(dri2dpy); + return NULL; + } + + dri2dpy->dpy = dpy; + if (!dri2dpy->dpy) { + dri2dpy->dpy = XOpenDisplay(NULL); + if (!dri2dpy->dpy) { + dri2_display_destroy(&dri2dpy->base); + return NULL; + } + dri2dpy->own_dpy = TRUE; + } + + dri2dpy->xscr_number = DefaultScreen(dri2dpy->dpy); + dri2dpy->xscr = x11_screen_create(dri2dpy->dpy, dri2dpy->xscr_number); + if (!dri2dpy->xscr) { + dri2_display_destroy(&dri2dpy->base); + return NULL; + } + + if (!dri2_display_init_screen(&dri2dpy->base)) { + dri2_display_destroy(&dri2dpy->base); + return NULL; + } + + if (!flush_frontbuffer) + flush_frontbuffer = dri2_display_flush_frontbuffer; + + dri2dpy->base.screen->flush_frontbuffer = + (void (*)(struct pipe_screen *, struct pipe_surface *, void *)) + flush_frontbuffer; + + dri2dpy->base.destroy = dri2_display_destroy; + dri2dpy->base.get_configs = dri2_display_get_configs; + dri2dpy->base.create_context = dri2_display_create_context; + dri2dpy->base.create_window_surface = dri2_display_create_window_surface; + dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface; + dri2dpy->base.create_pbuffer_surface = dri2_display_create_pbuffer_surface; + + return &dri2dpy->base; +} diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_x11.c b/src/gallium/state_trackers/egl_g3d/x11/native_x11.c new file mode 100644 index 00000000000..a4f36e9deca --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/x11/native_x11.c @@ -0,0 +1,73 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include "util/u_debug.h" +#include "state_tracker/drm_api.h" +#include "egllog.h" + +#include "native_x11.h" + +static struct drm_api *api; + +const char * +native_get_name(void) +{ + static char x11_name[32]; + + if (!api) + api = drm_api_create(); + + if (api) + snprintf(x11_name, sizeof(x11_name), "X11/%s", api->name); + else + snprintf(x11_name, sizeof(x11_name), "X11"); + + return x11_name; +} + +struct native_display * +native_create_display(EGLNativeDisplayType dpy, + native_flush_frontbuffer flush_frontbuffer) +{ + struct native_display *ndpy = NULL; + boolean force_sw; + + if (!api) + api = drm_api_create(); + + force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE); + if (api && !force_sw) { + ndpy = x11_create_dri2_display(dpy, api, flush_frontbuffer); + } + + if (!ndpy) { + EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING; + + _eglLog(level, "use software fallback"); + ndpy = x11_create_ximage_display(dpy, TRUE, flush_frontbuffer); + } + + return ndpy; +} diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_x11.h b/src/gallium/state_trackers/egl_g3d/x11/native_x11.h new file mode 100644 index 00000000000..9217eb62529 --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/x11/native_x11.h @@ -0,0 +1,41 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _NATIVE_X11_H_ +#define _NATIVE_X11_H_ + +#include "state_tracker/drm_api.h" +#include "common/native.h" + +struct native_display * +x11_create_ximage_display(EGLNativeDisplayType dpy, + boolean use_xshm, + native_flush_frontbuffer flush_frontbuffer); + +struct native_display * +x11_create_dri2_display(EGLNativeDisplayType dpy, + struct drm_api *api, + native_flush_frontbuffer flush_frontbuffer); + +#endif /* _NATIVE_X11_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c new file mode 100644 index 00000000000..e02faa9b7ba --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c @@ -0,0 +1,680 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "util/u_memory.h" +#include "util/u_math.h" +#include "util/u_format.h" +#include "pipe/p_compiler.h" +#include "pipe/internal/p_winsys_screen.h" +#include "softpipe/sp_winsys.h" +#include "egllog.h" + +#include "sw_winsys.h" +#include "native_x11.h" +#include "x11_screen.h" + +enum ximage_surface_type { + XIMAGE_SURFACE_TYPE_WINDOW, + XIMAGE_SURFACE_TYPE_PIXMAP, + XIMAGE_SURFACE_TYPE_PBUFFER +}; + +struct ximage_display { + struct native_display base; + Display *dpy; + boolean own_dpy; + + struct x11_screen *xscr; + int xscr_number; + + boolean use_xshm; + + struct pipe_winsys *winsys; + struct ximage_config *configs; + int num_configs; +}; + +struct ximage_buffer { + XImage *ximage; + + struct pipe_texture *texture; + struct pipe_transfer *transfer; + XShmSegmentInfo *shm_info; + boolean xshm_attached; +}; + +struct ximage_surface { + struct native_surface base; + Drawable drawable; + enum ximage_surface_type type; + enum pipe_format color_format; + XVisualInfo visual; + struct ximage_display *xdpy; + + int width, height; + GC gc; + + struct ximage_buffer buffers[NUM_NATIVE_ATTACHMENTS]; +}; + +struct ximage_config { + struct native_config base; + const XVisualInfo *visual; +}; + +static INLINE struct ximage_display * +ximage_display(const struct native_display *ndpy) +{ + return (struct ximage_display *) ndpy; +} + +static INLINE struct ximage_surface * +ximage_surface(const struct native_surface *nsurf) +{ + return (struct ximage_surface *) nsurf; +} + +static INLINE struct ximage_config * +ximage_config(const struct native_config *nconf) +{ + return (struct ximage_config *) nconf; +} + +static void +ximage_surface_free_buffer(struct native_surface *nsurf, + enum native_attachment which) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_buffer *xbuf = &xsurf->buffers[which]; + struct pipe_screen *screen = xsurf->xdpy->base.screen; + + if (xbuf->transfer) { + screen->tex_transfer_destroy(xbuf->transfer); + xbuf->transfer = NULL; + } + pipe_texture_reference(&xbuf->texture, NULL); + + if (xbuf->shm_info) { + if (xbuf->xshm_attached) + XShmDetach(xsurf->xdpy->dpy, xbuf->shm_info); + if (xbuf->shm_info->shmaddr != (void *) -1) + shmdt(xbuf->shm_info->shmaddr); + if (xbuf->shm_info->shmid != -1) + shmctl(xbuf->shm_info->shmid, IPC_RMID, 0); + + xbuf->shm_info->shmaddr = (void *) -1; + xbuf->shm_info->shmid = -1; + } +} + +static boolean +ximage_surface_alloc_buffer(struct native_surface *nsurf, + enum native_attachment which) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_buffer *xbuf = &xsurf->buffers[which]; + struct pipe_screen *screen = xsurf->xdpy->base.screen; + struct pipe_texture templ; + + /* free old data */ + if (xbuf->texture) + ximage_surface_free_buffer(&xsurf->base, which); + + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.format = xsurf->color_format; + templ.width0 = xsurf->width; + templ.height0 = xsurf->height; + templ.depth0 = 1; + templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + + if (xbuf->shm_info) { + struct pipe_buffer *pbuf; + unsigned stride, size; + void *addr = NULL; + + stride = util_format_get_stride(xsurf->color_format, xsurf->width); + /* alignment should depend on visual? */ + stride = align(stride, 4); + size = stride * xsurf->height; + + /* create and attach shm object */ + xbuf->shm_info->shmid = shmget(IPC_PRIVATE, size, 0755); + if (xbuf->shm_info->shmid != -1) { + xbuf->shm_info->shmaddr = + shmat(xbuf->shm_info->shmid, NULL, 0); + if (xbuf->shm_info->shmaddr != (void *) -1) { + if (XShmAttach(xsurf->xdpy->dpy, xbuf->shm_info)) { + addr = xbuf->shm_info->shmaddr; + xbuf->xshm_attached = TRUE; + } + } + } + + if (addr) { + pbuf = screen->user_buffer_create(screen, addr, size); + if (pbuf) { + xbuf->texture = + screen->texture_blanket(screen, &templ, &stride, pbuf); + pipe_buffer_reference(&pbuf, NULL); + } + } + } + else { + xbuf->texture = screen->texture_create(screen, &templ); + } + + if (xbuf->texture) { + xbuf->transfer = screen->get_tex_transfer(screen, xbuf->texture, + 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, xsurf->width, xsurf->height); + if (!xbuf->transfer) + pipe_texture_reference(&xbuf->texture, NULL); + } + + /* clean up the buffer if allocation failed */ + if (!xbuf->texture) + ximage_surface_free_buffer(&xsurf->base, which); + + return (xbuf->texture != NULL); +} + +static boolean +ximage_surface_draw_buffer(struct native_surface *nsurf, + enum native_attachment which) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_buffer *xbuf = &xsurf->buffers[which]; + struct pipe_screen *screen = xsurf->xdpy->base.screen; + + if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER) + return TRUE; + + assert(xsurf->drawable && xbuf->ximage && xbuf->texture); + + xbuf->ximage->data = screen->transfer_map(screen, xbuf->transfer); + + if (xbuf->shm_info) + XShmPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, + xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height, False); + else + XPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, + xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height); + + xbuf->ximage->data = NULL; + screen->transfer_unmap(screen, xbuf->transfer); + + XSync(xsurf->xdpy->dpy, FALSE); + + return TRUE; +} + +static boolean +ximage_surface_flush_frontbuffer(struct native_surface *nsurf) +{ + return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); +} + +static boolean +ximage_surface_swap_buffers(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_buffer *xfront, *xback, xtmp; + + xfront = &xsurf->buffers[NATIVE_ATTACHMENT_FRONT_LEFT]; + xback = &xsurf->buffers[NATIVE_ATTACHMENT_BACK_LEFT]; + + /* draw the back buffer directly if there is no front buffer */ + if (!xfront->texture) + return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_BACK_LEFT); + + /* swap the buffers */ + xtmp = *xfront; + *xfront = *xback; + *xback = xtmp; + + return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); +} + +static void +ximage_surface_update_geometry(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + Status ok; + Window root; + int x, y; + unsigned int w, h, border, depth; + + /* pbuffer has fixed geometry */ + if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER) + return; + + ok = XGetGeometry(xsurf->xdpy->dpy, xsurf->drawable, + &root, &x, &y, &w, &h, &border, &depth); + if (ok) { + xsurf->width = w; + xsurf->height = h; + } +} + +static boolean +ximage_surface_validate(struct native_surface *nsurf, + const enum native_attachment *natts, + unsigned num_natts, + struct pipe_texture **textures, + int *width, int *height) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + boolean error = FALSE; + unsigned i; + + ximage_surface_update_geometry(&xsurf->base); + + if (textures) + memset(textures, 0, sizeof(*textures) * num_natts); + + for (i = 0; i < num_natts; i++) { + enum native_attachment natt = natts[i]; + struct ximage_buffer *xbuf = &xsurf->buffers[natt]; + + if (!xbuf) + continue; + + /* reallocate the texture */ + if (!xbuf->texture || + xsurf->width != xbuf->texture->width0 || + xsurf->height != xbuf->texture->height0) { + if (ximage_surface_alloc_buffer(&xsurf->base, natt)) { + /* update ximage */ + if (xbuf->ximage) { + xbuf->ximage->width = xbuf->transfer->width; + xbuf->ximage->height = xbuf->transfer->height; + xbuf->ximage->bytes_per_line = xbuf->transfer->stride; + } + } + } + + /* allocation failed */ + if (!xbuf->texture) { + unsigned j; + for (j = 0; j < i; j++) + pipe_texture_reference(&textures[j], NULL); + for (j = i; j < num_natts; j++) + textures[j] = NULL; + error = TRUE; + break; + } + + if (textures) + pipe_texture_reference(&textures[i], xbuf->texture); + } + + if (width) + *width = xsurf->width; + if (height) + *height = xsurf->height; + + return !error; +} + +static void +ximage_surface_wait(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + XSync(xsurf->xdpy->dpy, FALSE); + /* TODO XGetImage and update the front texture */ +} + +static void +ximage_surface_destroy(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + int i; + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { + struct ximage_buffer *xbuf = &xsurf->buffers[i]; + ximage_surface_free_buffer(&xsurf->base, i); + /* xbuf->shm_info is owned by xbuf->ximage? */ + if (xbuf->ximage) { + XDestroyImage(xbuf->ximage); + xbuf->ximage = NULL; + } + } + + if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) + XFreeGC(xsurf->xdpy->dpy, xsurf->gc); + free(xsurf); +} + +static struct ximage_surface * +ximage_display_create_surface(struct native_display *ndpy, + enum ximage_surface_type type, + Drawable drawable, + const struct native_config *nconf) +{ + struct ximage_display *xdpy = ximage_display(ndpy); + struct ximage_config *xconf = ximage_config(nconf); + struct ximage_surface *xsurf; + int i; + + xsurf = CALLOC_STRUCT(ximage_surface); + if (!xsurf) + return NULL; + + xsurf->xdpy = xdpy; + xsurf->type = type; + xsurf->color_format = xconf->base.color_format; + xsurf->drawable = drawable; + + if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) { + xsurf->drawable = drawable; + xsurf->visual = *xconf->visual; + + xsurf->gc = XCreateGC(xdpy->dpy, xsurf->drawable, 0, NULL); + if (!xsurf->gc) { + free(xsurf); + return NULL; + } + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { + struct ximage_buffer *xbuf = &xsurf->buffers[i]; + + if (xdpy->use_xshm) { + xbuf->shm_info = calloc(1, sizeof(*xbuf->shm_info)); + if (xbuf->shm_info) { + /* initialize shm info */ + xbuf->shm_info->shmid = -1; + xbuf->shm_info->shmaddr = (void *) -1; + xbuf->shm_info->readOnly = TRUE; + + xbuf->ximage = XShmCreateImage(xsurf->xdpy->dpy, + xsurf->visual.visual, + xsurf->visual.depth, + ZPixmap, NULL, + xbuf->shm_info, + 0, 0); + } + } + else { + xbuf->ximage = XCreateImage(xsurf->xdpy->dpy, + xsurf->visual.visual, + xsurf->visual.depth, + ZPixmap, 0, /* format, offset */ + NULL, /* data */ + 0, 0, /* size */ + 8, /* bitmap_pad */ + 0); /* bytes_per_line */ + } + + if (!xbuf->ximage) { + XFreeGC(xdpy->dpy, xsurf->gc); + free(xsurf); + return NULL; + } + } + } + + xsurf->base.destroy = ximage_surface_destroy; + xsurf->base.swap_buffers = ximage_surface_swap_buffers; + xsurf->base.flush_frontbuffer = ximage_surface_flush_frontbuffer; + xsurf->base.validate = ximage_surface_validate; + xsurf->base.wait = ximage_surface_wait; + + return xsurf; +} + +static struct native_surface * +ximage_display_create_window_surface(struct native_display *ndpy, + EGLNativeWindowType win, + const struct native_config *nconf) +{ + struct ximage_surface *xsurf; + + xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_WINDOW, + (Drawable) win, nconf); + return (xsurf) ? &xsurf->base : NULL; +} + +static struct native_surface * +ximage_display_create_pixmap_surface(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf) +{ + struct ximage_surface *xsurf; + + xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_PIXMAP, + (Drawable) pix, nconf); + return (xsurf) ? &xsurf->base : NULL; +} + +static struct native_surface * +ximage_display_create_pbuffer_surface(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height) +{ + struct ximage_surface *xsurf; + + xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_PBUFFER, + (Drawable) None, nconf); + if (xsurf) { + xsurf->width = width; + xsurf->height = height; + } + return (xsurf) ? &xsurf->base : NULL; +} + +static struct pipe_context * +ximage_display_create_context(struct native_display *ndpy, + void *context_private) +{ + struct pipe_context *pctx = softpipe_create(ndpy->screen); + if (pctx) + pctx->priv = context_private; + return pctx; +} + +static enum pipe_format +choose_format(const XVisualInfo *vinfo) +{ + enum pipe_format fmt; + /* TODO elaborate the formats */ + switch (vinfo->depth) { + case 32: + fmt = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case 24: + fmt = PIPE_FORMAT_X8R8G8B8_UNORM; + break; + case 16: + fmt = PIPE_FORMAT_R5G6B5_UNORM; + break; + default: + fmt = PIPE_FORMAT_NONE; + break; + } + + return fmt; +} + +static const struct native_config ** +ximage_display_get_configs(struct native_display *ndpy, int *num_configs) +{ + struct ximage_display *xdpy = ximage_display(ndpy); + const struct native_config **configs; + int i; + + /* first time */ + if (!xdpy->configs) { + const XVisualInfo *visuals; + int num_visuals, count, j; + + visuals = x11_screen_get_visuals(xdpy->xscr, &num_visuals); + if (!visuals) + return NULL; + + /* + * Create two configs for each visual. + * One with depth/stencil buffer; one without + */ + xdpy->configs = calloc(num_visuals * 2, sizeof(*xdpy->configs)); + if (!xdpy->configs) + return NULL; + + count = 0; + for (i = 0; i < num_visuals; i++) { + for (j = 0; j < 2; j++) { + struct ximage_config *xconf = &xdpy->configs[count]; + __GLcontextModes *mode = &xconf->base.mode; + + xconf->visual = &visuals[i]; + xconf->base.color_format = choose_format(xconf->visual); + if (xconf->base.color_format == PIPE_FORMAT_NONE) + continue; + + x11_screen_convert_visual(xdpy->xscr, xconf->visual, mode); + /* support double buffer mode */ + mode->doubleBufferMode = TRUE; + + xconf->base.depth_format = PIPE_FORMAT_NONE; + xconf->base.stencil_format = PIPE_FORMAT_NONE; + /* create the second config with depth/stencil buffer */ + if (j == 1) { + xconf->base.depth_format = PIPE_FORMAT_S8Z24_UNORM; + xconf->base.stencil_format = PIPE_FORMAT_S8Z24_UNORM; + mode->depthBits = 24; + mode->stencilBits = 8; + mode->haveDepthBuffer = TRUE; + mode->haveStencilBuffer = TRUE; + } + + mode->maxPbufferWidth = 4096; + mode->maxPbufferHeight = 4096; + mode->maxPbufferPixels = 4096 * 4096; + mode->drawableType = + GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT; + mode->swapMethod = GLX_SWAP_EXCHANGE_OML; + + if (mode->alphaBits) + mode->bindToTextureRgba = TRUE; + else + mode->bindToTextureRgb = TRUE; + + count++; + } + } + + xdpy->num_configs = count; + } + + configs = malloc(xdpy->num_configs * sizeof(*configs)); + if (configs) { + for (i = 0; i < xdpy->num_configs; i++) + configs[i] = (const struct native_config *) &xdpy->configs[i]; + if (num_configs) + *num_configs = xdpy->num_configs; + } + return configs; +} + +static void +ximage_display_destroy(struct native_display *ndpy) +{ + struct ximage_display *xdpy = ximage_display(ndpy); + + if (xdpy->configs) + free(xdpy->configs); + + xdpy->base.screen->destroy(xdpy->base.screen); + free(xdpy->winsys); + + x11_screen_destroy(xdpy->xscr); + if (xdpy->own_dpy) + XCloseDisplay(xdpy->dpy); + free(xdpy); +} + +static void +ximage_display_flush_frontbuffer(void *dummy, struct pipe_surface *surf, + void *context_private) +{ + /* TODO get native surface from context private, and remove the callback */ + _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied"); +} + +struct native_display * +x11_create_ximage_display(EGLNativeDisplayType dpy, + boolean use_xshm, + native_flush_frontbuffer flush_frontbuffer) +{ + struct ximage_display *xdpy; + + xdpy = CALLOC_STRUCT(ximage_display); + if (!xdpy) + return NULL; + + xdpy->dpy = dpy; + if (!xdpy->dpy) { + xdpy->dpy = XOpenDisplay(NULL); + if (!xdpy->dpy) { + free(xdpy); + return NULL; + } + xdpy->own_dpy = TRUE; + } + + xdpy->xscr_number = DefaultScreen(xdpy->dpy); + xdpy->xscr = x11_screen_create(xdpy->dpy, xdpy->xscr_number); + if (!xdpy->xscr) { + free(xdpy); + return NULL; + } + + xdpy->use_xshm = + (use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM)); + + xdpy->winsys = create_sw_winsys(); + if (!flush_frontbuffer) + flush_frontbuffer = ximage_display_flush_frontbuffer; + xdpy->winsys->flush_frontbuffer = + (void (*)(struct pipe_winsys *, struct pipe_surface *, void *)) + flush_frontbuffer; + + xdpy->base.screen = softpipe_create_screen(xdpy->winsys); + + xdpy->base.destroy = ximage_display_destroy; + + xdpy->base.get_configs = ximage_display_get_configs; + xdpy->base.create_context = ximage_display_create_context; + xdpy->base.create_window_surface = ximage_display_create_window_surface; + xdpy->base.create_pixmap_surface = ximage_display_create_pixmap_surface; + xdpy->base.create_pbuffer_surface = ximage_display_create_pbuffer_surface; + + return &xdpy->base; +} diff --git a/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c b/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c new file mode 100644 index 00000000000..6ee3ede38cb --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c @@ -0,0 +1,231 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * Totally software-based winsys layer. + * Note that the one winsys function that we can't implement here + * is flush_frontbuffer(). + * Whoever uses this code will have to provide that. + * + * Authors: Brian Paul + */ + + +#include "pipe/internal/p_winsys_screen.h" +#include "pipe/p_state.h" +#include "pipe/p_inlines.h" +#include "util/u_format.h" +#include "util/u_math.h" +#include "util/u_memory.h" + +#include "sw_winsys.h" + + + +/** Subclass of pipe_winsys */ +struct sw_pipe_winsys +{ + struct pipe_winsys Base; + /* no extra fields for now */ +}; + + +/** subclass of pipe_buffer */ +struct sw_pipe_buffer +{ + struct pipe_buffer Base; + boolean UserBuffer; /** Is this a user-space buffer? */ + void *Data; + void *Mapped; +}; + + +/** cast wrapper */ +static INLINE struct sw_pipe_buffer * +sw_pipe_buffer(struct pipe_buffer *b) +{ + return (struct sw_pipe_buffer *) b; +} + + +static const char * +get_name(struct pipe_winsys *pws) +{ + return "software"; +} + + +/** Create new pipe_buffer and allocate storage of given size */ +static struct pipe_buffer * +buffer_create(struct pipe_winsys *pws, + unsigned alignment, + unsigned usage, + unsigned size) +{ + struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); + if (!buffer) + return NULL; + + pipe_reference_init(&buffer->Base.reference, 1); + buffer->Base.alignment = alignment; + buffer->Base.usage = usage; + buffer->Base.size = size; + + /* align to 16-byte multiple for Cell */ + buffer->Data = align_malloc(size, MAX2(alignment, 16)); + + return &buffer->Base; +} + + +/** + * Create buffer which wraps user-space data. + */ +static struct pipe_buffer * +user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) +{ + struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); + if (!buffer) + return NULL; + + pipe_reference_init(&buffer->Base.reference, 1); + buffer->Base.size = bytes; + buffer->UserBuffer = TRUE; + buffer->Data = ptr; + + return &buffer->Base; +} + + +static void * +buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned flags) +{ + struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); + buffer->Mapped = buffer->Data; + return buffer->Mapped; +} + + +static void +buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) +{ + struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); + buffer->Mapped = NULL; +} + + +static void +buffer_destroy(struct pipe_buffer *buf) +{ + struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); + + if (buffer->Data && !buffer->UserBuffer) { + align_free(buffer->Data); + buffer->Data = NULL; + } + + free(buffer); +} + + +static struct pipe_buffer * +surface_buffer_create(struct pipe_winsys *winsys, + unsigned width, unsigned height, + enum pipe_format format, + unsigned usage, + unsigned tex_usage, + unsigned *stride) +{ + const unsigned alignment = 64; + unsigned nblocksy; + + nblocksy = util_format_get_nblocksy(format, height); + *stride = align(util_format_get_stride(format, width), alignment); + + return winsys->buffer_create(winsys, alignment, + usage, + *stride * nblocksy); +} + + +static void +fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, + struct pipe_fence_handle *fence) +{ + /* no-op */ +} + + +static int +fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, + unsigned flag) +{ + /* no-op */ + return 0; +} + + +static int +fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, + unsigned flag) +{ + /* no-op */ + return 0; +} + + +/** + * Create/return a new pipe_winsys object. + */ +struct pipe_winsys * +create_sw_winsys(void) +{ + struct sw_pipe_winsys *ws = CALLOC_STRUCT(sw_pipe_winsys); + if (!ws) + return NULL; + + /* Fill in this struct with callbacks that pipe will need to + * communicate with the window system, buffer manager, etc. + */ + ws->Base.buffer_create = buffer_create; + ws->Base.user_buffer_create = user_buffer_create; + ws->Base.buffer_map = buffer_map; + ws->Base.buffer_unmap = buffer_unmap; + ws->Base.buffer_destroy = buffer_destroy; + + ws->Base.surface_buffer_create = surface_buffer_create; + + ws->Base.fence_reference = fence_reference; + ws->Base.fence_signalled = fence_signalled; + ws->Base.fence_finish = fence_finish; + + ws->Base.flush_frontbuffer = NULL; /* not implemented here! */ + + ws->Base.get_name = get_name; + + return &ws->Base; +} diff --git a/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h b/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h new file mode 100644 index 00000000000..f96c5a14b0a --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef SW_WINSYS_H +#define SW_WINSYS_H + + +struct pipe_winsys; + + +extern struct pipe_winsys * +create_sw_winsys(void); + + +#endif /* SW_WINSYS_H */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c new file mode 100644 index 00000000000..1e98943242a --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c @@ -0,0 +1,402 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include "util/u_memory.h" +#include "util/u_math.h" +#include "xf86drm.h" +#include "egllog.h" + +#include "x11_screen.h" +#include "dri2.h" +#include "glxinit.h" + +struct x11_screen { + Display *dpy; + int number; + + __GLXdisplayPrivate *glx_dpy; + + int dri_major, dri_minor; + char *dri_driver; + char *dri_device; + int dri_fd; + + XVisualInfo *visuals; + int num_visuals; +}; + + +/** + * Create a X11 screen. + */ +struct x11_screen * +x11_screen_create(Display *dpy, int screen) +{ + struct x11_screen *xscr; + + if (screen >= ScreenCount(dpy)) + return NULL; + + xscr = CALLOC_STRUCT(x11_screen); + if (xscr) { + xscr->dpy = dpy; + xscr->number = screen; + + xscr->dri_major = -1; + xscr->dri_fd = -1; + } + return xscr; +} + +/** + * Destroy a X11 screen. + */ +void +x11_screen_destroy(struct x11_screen *xscr) +{ + if (xscr->dri_fd >= 0) + close(xscr->dri_fd); + if (xscr->dri_driver) + Xfree(xscr->dri_driver); + if (xscr->dri_device) + Xfree(xscr->dri_device); + + if (xscr->glx_dpy) + __glXRelease(xscr->glx_dpy); + if (xscr->visuals) + XFree(xscr->visuals); + free(xscr); +} + +static boolean +x11_screen_init_dri2(struct x11_screen *xscr) +{ + if (xscr->dri_major < 0) { + int eventBase, errorBase; + + if (!DRI2QueryExtension(xscr->dpy, &eventBase, &errorBase) || + !DRI2QueryVersion(xscr->dpy, &xscr->dri_major, &xscr->dri_minor)) + xscr->dri_major = -1; + } + return (xscr->dri_major >= 0); +} + +static boolean +x11_screen_init_glx(struct x11_screen *xscr) +{ + if (!xscr->glx_dpy) + xscr->glx_dpy = __glXInitialize(xscr->dpy); + return (xscr->glx_dpy != NULL); +} + +/** + * Return true if the screen supports the extension. + */ +boolean +x11_screen_support(struct x11_screen *xscr, enum x11_screen_extension ext) +{ + boolean supported = FALSE; + + switch (ext) { + case X11_SCREEN_EXTENSION_XSHM: + supported = XShmQueryExtension(xscr->dpy); + break; + case X11_SCREEN_EXTENSION_GLX: + supported = x11_screen_init_glx(xscr); + break; + case X11_SCREEN_EXTENSION_DRI2: + supported = x11_screen_init_dri2(xscr); + break; + default: + break; + } + + return supported; +} + +/** + * Return the X visuals. + */ +const XVisualInfo * +x11_screen_get_visuals(struct x11_screen *xscr, int *num_visuals) +{ + if (!xscr->visuals) { + XVisualInfo vinfo_template; + vinfo_template.screen = xscr->number; + xscr->visuals = XGetVisualInfo(xscr->dpy, VisualScreenMask, + &vinfo_template, &xscr->num_visuals); + } + + if (num_visuals) + *num_visuals = xscr->num_visuals; + return xscr->visuals; +} + +void +x11_screen_convert_visual(struct x11_screen *xscr, const XVisualInfo *visual, + __GLcontextModes *mode) +{ + int r, g, b, a; + int visual_type; + + r = util_bitcount(visual->red_mask); + g = util_bitcount(visual->green_mask); + b = util_bitcount(visual->blue_mask); + a = visual->depth - (r + g + b); +#if defined(__cplusplus) || defined(c_plusplus) + visual_type = visual->c_class; +#else + visual_type = visual->class; +#endif + + /* convert to GLX visual type */ + switch (visual_type) { + case TrueColor: + visual_type = GLX_TRUE_COLOR; + break; + case DirectColor: + visual_type = GLX_DIRECT_COLOR; + break; + case PseudoColor: + visual_type = GLX_PSEUDO_COLOR; + break; + case StaticColor: + visual_type = GLX_STATIC_COLOR; + break; + case GrayScale: + visual_type = GLX_GRAY_SCALE; + break; + case StaticGray: + visual_type = GLX_STATIC_GRAY; + break; + default: + visual_type = GLX_NONE; + break; + } + + mode->rgbBits = r + g + b + a; + mode->redBits = r; + mode->greenBits = g; + mode->blueBits = b; + mode->alphaBits = a; + mode->visualID = visual->visualid; + mode->visualType = visual_type; + + /* sane defaults */ + mode->renderType = GLX_RGBA_BIT; + mode->rgbMode = TRUE; + mode->visualRating = GLX_SLOW_CONFIG; + mode->xRenderable = TRUE; +} + +/** + * Return the GLX fbconfigs. + */ +const __GLcontextModes * +x11_screen_get_glx_configs(struct x11_screen *xscr) +{ + return (x11_screen_init_glx(xscr)) + ? xscr->glx_dpy->screenConfigs[xscr->number].configs + : NULL; +} + +/** + * Return the GLX visuals. + */ +const __GLcontextModes * +x11_screen_get_glx_visuals(struct x11_screen *xscr) +{ + return (x11_screen_init_glx(xscr)) + ? xscr->glx_dpy->screenConfigs[xscr->number].visuals + : NULL; +} + +static boolean +x11_screen_is_driver_equal(struct x11_screen *xscr, const char *driver) +{ + return (strcmp(xscr->dri_driver, driver) == 0); +} + +/** + * Enable DRI2 and returns the file descriptor of the DRM device. The file + * descriptor will be closed automatically when the screen is destoryed. + */ +int +x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver) +{ + if (xscr->dri_fd < 0) { + int fd; + drm_magic_t magic; + + /* get the driver name and the device name first */ + if (!xscr->dri_driver) { + if (!DRI2Connect(xscr->dpy, RootWindow(xscr->dpy, xscr->number), + &xscr->dri_driver, &xscr->dri_device)) { + xscr->dri_driver = xscr->dri_device = NULL; + return -1; + } + } + + if (!x11_screen_is_driver_equal(xscr, driver)) { + _eglLog(_EGL_WARNING, "Driver mismatch: %s != %s", + xscr->dri_driver, driver); + return -1; + } + + fd = open(xscr->dri_device, O_RDWR); + if (fd < 0) { + _eglLog(_EGL_WARNING, "failed to open %s", xscr->dri_device); + return -1; + } + + memset(&magic, 0, sizeof(magic)); + if (drmGetMagic(fd, &magic)) { + _eglLog(_EGL_WARNING, "failed to get magic"); + close(fd); + return -1; + } + + if (!DRI2Authenticate(xscr->dpy, + RootWindow(xscr->dpy, xscr->number), magic)) { + _eglLog(_EGL_WARNING, "failed to authenticate magic"); + close(fd); + return -1; + } + + xscr->dri_fd = fd; + } + + return xscr->dri_fd; +} + +/** + * Create/Destroy the DRI drawable. + */ +void +x11_drawable_enable_dri2(struct x11_screen *xscr, + Drawable drawable, boolean on) +{ + if (on) + DRI2CreateDrawable(xscr->dpy, drawable); + else + DRI2DestroyDrawable(xscr->dpy, drawable); +} + +/** + * Copy between buffers of the DRI2 drawable. + */ +void +x11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable, + int x, int y, int width, int height, + int src_buf, int dst_buf) +{ + XRectangle rect; + XserverRegion region; + + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + + region = XFixesCreateRegion(xscr->dpy, &rect, 1); + DRI2CopyRegion(xscr->dpy, drawable, region, dst_buf, src_buf); + XFixesDestroyRegion(xscr->dpy, region); +} + +/** + * Get the buffers of the DRI2 drawable. The returned array should be freed. + */ +struct x11_drawable_buffer * +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) +{ + DRI2Buffer *dri2bufs; + + if (with_format) + dri2bufs = DRI2GetBuffersWithFormat(xscr->dpy, drawable, width, height, + attachments, num_ins, num_outs); + else + dri2bufs = DRI2GetBuffers(xscr->dpy, drawable, width, height, + attachments, num_ins, num_outs); + + return (struct x11_drawable_buffer *) dri2bufs; +} + +/** + * Create a mode list of the given size. + */ +__GLcontextModes * +x11_context_modes_create(unsigned count) +{ + const size_t size = sizeof(__GLcontextModes); + __GLcontextModes *base = NULL; + __GLcontextModes **next; + unsigned i; + + next = &base; + for (i = 0; i < count; i++) { + *next = (__GLcontextModes *) calloc(1, size); + if (*next == NULL) { + x11_context_modes_destroy(base); + base = NULL; + break; + } + next = &((*next)->next); + } + + return base; +} + +/** + * Destroy a mode list. + */ +void +x11_context_modes_destroy(__GLcontextModes *modes) +{ + while (modes != NULL) { + __GLcontextModes *next = modes->next; + free(modes); + modes = next; + } +} + +/** + * Return the number of the modes in the mode list. + */ +unsigned +x11_context_modes_count(const __GLcontextModes *modes) +{ + const __GLcontextModes *mode; + int count = 0; + for (mode = modes; mode; mode = mode->next) + count++; + return count; +} diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h new file mode 100644 index 00000000000..86e8e0501a3 --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h @@ -0,0 +1,99 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _X11_SCREEN_H_ +#define _X11_SCREEN_H_ + +#include +#include +#include +#include "pipe/p_compiler.h" +#include "common/native.h" + +enum x11_screen_extension { + X11_SCREEN_EXTENSION_XSHM, + X11_SCREEN_EXTENSION_GLX, + X11_SCREEN_EXTENSION_DRI2, +}; + +/* the same as DRI2Buffer */ +struct x11_drawable_buffer { + unsigned int attachment; + unsigned int name; + unsigned int pitch; + unsigned int cpp; + unsigned int flags; +}; + +struct x11_screen; + +struct x11_screen * +x11_screen_create(Display *dpy, int screen); + +void +x11_screen_destroy(struct x11_screen *xscr); + +boolean +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); + +void +x11_screen_convert_visual(struct x11_screen *xscr, const XVisualInfo *visual, + __GLcontextModes *mode); + +const __GLcontextModes * +x11_screen_get_glx_configs(struct x11_screen *xscr); + +const __GLcontextModes * +x11_screen_get_glx_visuals(struct x11_screen *xscr); + +int +x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver); + +__GLcontextModes * +x11_context_modes_create(unsigned count); + +void +x11_context_modes_destroy(__GLcontextModes *modes); + +unsigned +x11_context_modes_count(const __GLcontextModes *modes); + +void +x11_drawable_enable_dri2(struct x11_screen *xscr, + Drawable drawable, boolean on); + +void +x11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable, + int x, int y, int width, int height, + int src_buf, int dst_buf); + +struct x11_drawable_buffer * +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); + +#endif /* _X11_SCREEN_H_ */ -- cgit v1.2.3 From a68b51deb2ea4f3cb51f2753b1b879e5677db225 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 3 Jan 2010 19:24:04 +0800 Subject: st/egl_g3d: Add support for KMS native display. The KMS native display implements the modeset interface using DRM modesetting. Signed-off-by: Chia-I Wu --- configure.ac | 2 +- .../state_trackers/egl_g3d/kms/native_kms.c | 866 +++++++++++++++++++++ .../state_trackers/egl_g3d/kms/native_kms.h | 138 ++++ 3 files changed, 1005 insertions(+), 1 deletion(-) create mode 100644 src/gallium/state_trackers/egl_g3d/kms/native_kms.c create mode 100644 src/gallium/state_trackers/egl_g3d/kms/native_kms.h (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 8a8919b1373..5fea166c67b 100644 --- a/configure.ac +++ b/configure.ac @@ -1194,7 +1194,7 @@ esac AC_ARG_WITH([egl-displays], [AS_HELP_STRING([--with-egl-displays@<:@=DIRS...@:>@], [comma delimited native displays libEGL supports, e.g. - "x11" @<:@default=auto@:>@])], + "x11,kms" @<:@default=auto@:>@])], [with_egl_displays="$withval"], [with_egl_displays=yes]) diff --git a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c b/src/gallium/state_trackers/egl_g3d/kms/native_kms.c new file mode 100644 index 00000000000..0e0babdb14f --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/kms/native_kms.c @@ -0,0 +1,866 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include + +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "util/u_debug.h" +#include "util/u_memory.h" +#include "egllog.h" + +#include "native_kms.h" + +static boolean +kms_surface_validate(struct native_surface *nsurf, + const enum native_attachment *natts, + unsigned num_natts, + struct pipe_texture **textures, + int *width, int *height) +{ + struct kms_surface *ksurf = kms_surface(nsurf); + struct kms_display *kdpy = ksurf->kdpy; + struct pipe_screen *screen = kdpy->base.screen; + struct pipe_texture templ, *ptex; + int i; + + if (num_natts) { + if (textures) + memset(textures, 0, sizeof(*textures) * num_natts); + + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.last_level = 0; + templ.width0 = ksurf->width; + templ.height0 = ksurf->height; + templ.depth0 = 1; + templ.format = ksurf->color_format; + templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + if (ksurf->type == KMS_SURFACE_TYPE_SCANOUT) + templ.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; + } + + /* create textures */ + for (i = 0; i < num_natts; i++) { + enum native_attachment natt = natts[i]; + + ptex = ksurf->textures[natt]; + if (!ptex) { + ptex = screen->texture_create(screen, &templ); + ksurf->textures[natt] = ptex; + } + + if (textures) + pipe_texture_reference(&textures[i], ptex); + } + + if (width) + *width = ksurf->width; + if (height) + *height = ksurf->height; + + return TRUE; +} + +/** + * Add textures as DRM framebuffers. + */ +static boolean +kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back) +{ + struct kms_surface *ksurf = kms_surface(nsurf); + struct kms_display *kdpy = ksurf->kdpy; + int num_framebuffers = (need_back) ? 2 : 1; + int i, err; + + for (i = 0; i < num_framebuffers; i++) { + struct kms_framebuffer *fb; + enum native_attachment natt; + unsigned int handle, stride; + uint block_bits; + + if (i == 0) { + fb = &ksurf->front_fb; + natt = NATIVE_ATTACHMENT_FRONT_LEFT; + } + else { + fb = &ksurf->back_fb; + natt = NATIVE_ATTACHMENT_BACK_LEFT; + } + + if (!fb->texture) { + /* make sure the texture has been allocated */ + kms_surface_validate(&ksurf->base, &natt, 1, NULL, NULL, NULL); + if (!ksurf->textures[natt]) + return FALSE; + + pipe_texture_reference(&fb->texture, ksurf->textures[natt]); + } + + /* already initialized */ + if (fb->buffer_id) + continue; + + /* TODO detect the real value */ + fb->is_passive = TRUE; + + if (!kdpy->api->local_handle_from_texture(kdpy->api, + kdpy->base.screen, fb->texture, &stride, &handle)) + return FALSE; + + block_bits = util_format_get_blocksizebits(ksurf->color_format); + err = drmModeAddFB(kdpy->fd, ksurf->width, ksurf->height, + block_bits, block_bits, stride, handle, &fb->buffer_id); + if (err) { + fb->buffer_id = 0; + return FALSE; + } + } + + return TRUE; +} + +static boolean +kms_surface_flush_frontbuffer(struct native_surface *nsurf) +{ +#ifdef DRM_MODE_FEATURE_DIRTYFB + struct kms_surface *ksurf = kms_surface(nsurf); + struct kms_display *kdpy = ksurf->kdpy; + + /* pbuffer is private */ + if (ksurf->type == KMS_SURFACE_TYPE_PBUFFER) + return TRUE; + + if (ksurf->front_fb.is_passive) + drmModeDirtyFB(kdpy->fd, ksurf->front_fb.buffer_id, NULL, 0); +#endif + + return TRUE; +} + +static boolean +kms_surface_swap_buffers(struct native_surface *nsurf) +{ + struct kms_surface *ksurf = kms_surface(nsurf); + struct kms_crtc *kcrtc = &ksurf->current_crtc; + struct kms_display *kdpy = ksurf->kdpy; + struct kms_framebuffer tmp_fb; + struct pipe_texture *tmp_texture; + int err; + + /* pbuffer is private */ + if (ksurf->type == KMS_SURFACE_TYPE_PBUFFER) + return TRUE; + + if (!ksurf->back_fb.buffer_id) { + if (!kms_surface_init_framebuffers(&ksurf->base, TRUE)) + return FALSE; + } + + if (ksurf->is_shown && kcrtc->crtc) { + err = drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id, + ksurf->back_fb.buffer_id, kcrtc->crtc->x, kcrtc->crtc->y, + kcrtc->connectors, kcrtc->num_connectors, &kcrtc->crtc->mode); + if (err) + return FALSE; + } + + /* swap the buffers */ + tmp_fb = ksurf->front_fb; + ksurf->front_fb = ksurf->back_fb; + ksurf->back_fb = tmp_fb; + + tmp_texture = ksurf->textures[NATIVE_ATTACHMENT_FRONT_LEFT]; + ksurf->textures[NATIVE_ATTACHMENT_FRONT_LEFT] = + ksurf->textures[NATIVE_ATTACHMENT_BACK_LEFT]; + ksurf->textures[NATIVE_ATTACHMENT_BACK_LEFT] = tmp_texture; + + return TRUE; +} + +static void +kms_surface_wait(struct native_surface *nsurf) +{ + /* no-op */ +} + +static void +kms_surface_destroy(struct native_surface *nsurf) +{ + struct kms_surface *ksurf = kms_surface(nsurf); + int i; + + if (ksurf->current_crtc.crtc) + drmModeFreeCrtc(ksurf->current_crtc.crtc); + + if (ksurf->front_fb.buffer_id) + drmModeRmFB(ksurf->kdpy->fd, ksurf->front_fb.buffer_id); + pipe_texture_reference(&ksurf->front_fb.texture, NULL); + + if (ksurf->back_fb.buffer_id) + drmModeRmFB(ksurf->kdpy->fd, ksurf->back_fb.buffer_id); + pipe_texture_reference(&ksurf->back_fb.texture, NULL); + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { + struct pipe_texture *ptex = ksurf->textures[i]; + pipe_texture_reference(&ptex, NULL); + } + + free(ksurf); +} + +static struct kms_surface * +kms_display_create_surface(struct native_display *ndpy, + enum kms_surface_type type, + const struct native_config *nconf, + uint width, uint height) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct kms_config *kconf = kms_config(nconf); + struct kms_surface *ksurf; + + ksurf = CALLOC_STRUCT(kms_surface); + if (!ksurf) + return NULL; + + ksurf->kdpy = kdpy; + ksurf->type = type; + ksurf->color_format = kconf->base.color_format; + ksurf->width = width; + ksurf->height = height; + + ksurf->base.destroy = kms_surface_destroy; + ksurf->base.swap_buffers = kms_surface_swap_buffers; + ksurf->base.flush_frontbuffer = kms_surface_flush_frontbuffer; + ksurf->base.validate = kms_surface_validate; + ksurf->base.wait = kms_surface_wait; + + return ksurf; +} + +/** + * Choose a CRTC that supports all given connectors. + */ +static uint32_t +kms_display_choose_crtc(struct native_display *ndpy, + uint32_t *connectors, int num_connectors) +{ + struct kms_display *kdpy = kms_display(ndpy); + int idx; + + for (idx = 0; idx < kdpy->resources->count_crtcs; idx++) { + boolean found_crtc = TRUE; + int i, j; + + for (i = 0; i < num_connectors; i++) { + drmModeConnectorPtr connector; + int encoder_idx = -1; + + connector = drmModeGetConnector(kdpy->fd, connectors[i]); + if (!connector) { + found_crtc = FALSE; + break; + } + + /* find an encoder the CRTC supports */ + for (j = 0; j < connector->count_encoders; j++) { + drmModeEncoderPtr encoder = + drmModeGetEncoder(kdpy->fd, connector->encoders[j]); + if (encoder->possible_crtcs & (1 << idx)) { + encoder_idx = j; + break; + } + drmModeFreeEncoder(encoder); + } + + drmModeFreeConnector(connector); + if (encoder_idx < 0) { + found_crtc = FALSE; + break; + } + } + + if (found_crtc) + break; + } + + if (idx >= kdpy->resources->count_crtcs) { + _eglLog(_EGL_WARNING, + "failed to find a CRTC that supports the given %d connectors", + num_connectors); + return 0; + } + + return kdpy->resources->crtcs[idx]; +} + +/** + * Remember the original CRTC status and set the CRTC + */ +static boolean +kms_display_set_crtc(struct native_display *ndpy, int crtc_idx, + uint32_t buffer_id, uint32_t x, uint32_t y, + uint32_t *connectors, int num_connectors, + drmModeModeInfoPtr mode) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct kms_crtc *kcrtc = &kdpy->saved_crtcs[crtc_idx]; + uint32_t crtc_id; + int err; + + if (kcrtc->crtc) { + crtc_id = kcrtc->crtc->crtc_id; + } + else { + int count = 0, i; + + /* + * Choose the CRTC once. It could be more dynamic, but let's keep it + * simple for now. + */ + crtc_id = kms_display_choose_crtc(&kdpy->base, + connectors, num_connectors); + + /* save the original CRTC status */ + kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id); + if (!kcrtc->crtc) + return FALSE; + + for (i = 0; i < kdpy->num_connectors; i++) { + struct kms_connector *kconn = &kdpy->connectors[i]; + drmModeConnectorPtr connector = kconn->connector; + drmModeEncoderPtr encoder; + + encoder = drmModeGetEncoder(kdpy->fd, connector->encoder_id); + if (encoder) { + if (encoder->crtc_id == crtc_id) { + kcrtc->connectors[count++] = connector->connector_id; + if (count >= Elements(kcrtc->connectors)) + break; + } + drmModeFreeEncoder(encoder); + } + } + + kcrtc->num_connectors = count; + } + + err = drmModeSetCrtc(kdpy->fd, crtc_id, buffer_id, x, y, + connectors, num_connectors, mode); + if (err) { + drmModeFreeCrtc(kcrtc->crtc); + kcrtc->crtc = NULL; + kcrtc->num_connectors = 0; + + return FALSE; + } + + return TRUE; +} + +static boolean +kms_display_program(struct native_display *ndpy, int crtc_idx, + struct native_surface *nsurf, uint x, uint y, + const struct native_connector **nconns, int num_nconns, + const struct native_mode *nmode) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct kms_surface *ksurf = kms_surface(nsurf); + const struct kms_mode *kmode = kms_mode(nmode); + uint32_t connector_ids[32]; + uint32_t buffer_id; + drmModeModeInfo mode_tmp, *mode; + int i; + + if (num_nconns > Elements(connector_ids)) { + _eglLog(_EGL_WARNING, "too many connectors (%d)", num_nconns); + num_nconns = Elements(connector_ids); + } + + if (ksurf) { + if (!kms_surface_init_framebuffers(&ksurf->base, FALSE)) + return FALSE; + + buffer_id = ksurf->front_fb.buffer_id; + /* the mode argument of drmModeSetCrtc is not constified */ + mode_tmp = kmode->mode; + mode = &mode_tmp; + } + else { + /* disable the CRTC */ + buffer_id = 0; + mode = NULL; + num_nconns = 0; + } + + for (i = 0; i < num_nconns; i++) { + struct kms_connector *kconn = kms_connector(nconns[i]); + connector_ids[i] = kconn->connector->connector_id; + } + + if (!kms_display_set_crtc(&kdpy->base, crtc_idx, buffer_id, x, y, + connector_ids, num_nconns, mode)) { + _eglLog(_EGL_WARNING, "failed to set CRTC %d", crtc_idx); + + return FALSE; + } + + if (kdpy->shown_surfaces[crtc_idx]) + kdpy->shown_surfaces[crtc_idx]->is_shown = FALSE; + kdpy->shown_surfaces[crtc_idx] = ksurf; + + /* remember the settings for buffer swapping */ + if (ksurf) { + uint32_t crtc_id = kdpy->saved_crtcs[crtc_idx].crtc->crtc_id; + struct kms_crtc *kcrtc = &ksurf->current_crtc; + + if (kcrtc->crtc) + drmModeFreeCrtc(kcrtc->crtc); + kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id); + + assert(num_nconns < Elements(kcrtc->connectors)); + memcpy(kcrtc->connectors, connector_ids, + sizeof(*connector_ids) * num_nconns); + kcrtc->num_connectors = num_nconns; + + ksurf->is_shown = TRUE; + } + + return TRUE; +} + +static const struct native_mode ** +kms_display_get_modes(struct native_display *ndpy, + const struct native_connector *nconn, + int *num_modes) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct kms_connector *kconn = kms_connector(nconn); + const struct native_mode **nmodes_return; + int count, i; + + /* delete old data */ + if (kconn->connector) { + drmModeFreeConnector(kconn->connector); + free(kconn->kms_modes); + + kconn->connector = NULL; + kconn->kms_modes = NULL; + kconn->num_modes = 0; + } + + /* detect again */ + kconn->connector = drmModeGetConnector(kdpy->fd, kconn->connector_id); + if (!kconn->connector) + return NULL; + + count = kconn->connector->count_modes; + kconn->kms_modes = calloc(count, sizeof(*kconn->kms_modes)); + if (!kconn->kms_modes) { + drmModeFreeConnector(kconn->connector); + kconn->connector = NULL; + + return NULL; + } + + for (i = 0; i < count; i++) { + struct kms_mode *kmode = &kconn->kms_modes[i]; + drmModeModeInfoPtr mode = &kconn->connector->modes[i]; + + kmode->mode = *mode; + + kmode->base.desc = kmode->mode.name; + kmode->base.width = kmode->mode.hdisplay; + kmode->base.height = kmode->mode.vdisplay; + kmode->base.refresh_rate = kmode->mode.vrefresh / 1000; + } + + nmodes_return = malloc(count * sizeof(*nmodes_return)); + if (nmodes_return) { + for (i = 0; i < count; i++) + nmodes_return[i] = &kconn->kms_modes[i].base; + if (num_modes) + *num_modes = count; + } + + return nmodes_return; +} + +static const struct native_connector ** +kms_display_get_connectors(struct native_display *ndpy, int *num_connectors, + int *num_crtc) +{ + struct kms_display *kdpy = kms_display(ndpy); + const struct native_connector **connectors; + int i; + + if (!kdpy->connectors) { + kdpy->connectors = + calloc(kdpy->resources->count_connectors, sizeof(*kdpy->connectors)); + if (!kdpy->connectors) + return NULL; + + for (i = 0; i < kdpy->resources->count_connectors; i++) { + struct kms_connector *kconn = &kdpy->connectors[i]; + + kconn->connector_id = kdpy->resources->connectors[i]; + /* kconn->connector is allocated when the modes are asked */ + } + + kdpy->num_connectors = kdpy->resources->count_connectors; + } + + connectors = malloc(kdpy->num_connectors * sizeof(*connectors)); + if (connectors) { + for (i = 0; i < kdpy->num_connectors; i++) + connectors[i] = &kdpy->connectors[i].base; + if (num_connectors) + *num_connectors = kdpy->num_connectors; + } + + if (num_crtc) + *num_crtc = kdpy->resources->count_crtcs; + + return connectors; +} + +static struct native_surface * +kms_display_create_scanout_surface(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height) +{ + struct kms_surface *ksurf; + + ksurf = kms_display_create_surface(ndpy, + KMS_SURFACE_TYPE_SCANOUT, nconf, width, height); + return &ksurf->base; +} + +static struct native_surface * +kms_display_create_pbuffer_surface(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height) +{ + struct kms_surface *ksurf; + + ksurf = kms_display_create_surface(ndpy, + KMS_SURFACE_TYPE_PBUFFER, nconf, width, height); + return &ksurf->base; +} + +static struct pipe_context * +kms_display_create_context(struct native_display *ndpy, void *context_private) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct pipe_context *pctx; + + pctx = kdpy->api->create_context(kdpy->api, kdpy->base.screen); + if (pctx) + pctx->priv = context_private; + return pctx; +} + +static boolean +kms_display_is_format_supported(struct native_display *ndpy, + enum pipe_format fmt, boolean is_color) +{ + return ndpy->screen->is_format_supported(ndpy->screen, + fmt, PIPE_TEXTURE_2D, + (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET : + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); +} + +static const struct native_config ** +kms_display_get_configs(struct native_display *ndpy, int *num_configs) +{ + struct kms_display *kdpy = kms_display(ndpy); + const struct native_config **configs; + + /* first time */ + if (!kdpy->config) { + struct native_config *nconf; + enum pipe_format format; + + kdpy->config = calloc(1, sizeof(*kdpy->config)); + if (!kdpy->config) + return NULL; + + nconf = &kdpy->config->base; + + /* always double-buffered */ + nconf->mode.doubleBufferMode = TRUE; + + format = PIPE_FORMAT_A8R8G8B8_UNORM; + if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) { + format = PIPE_FORMAT_B8G8R8A8_UNORM; + if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) + format = PIPE_FORMAT_NONE; + } + if (format == PIPE_FORMAT_NONE) + return NULL; + + nconf->color_format = format; + nconf->mode.redBits = 8; + nconf->mode.greenBits = 8; + nconf->mode.blueBits = 8; + nconf->mode.alphaBits = 8; + nconf->mode.rgbBits = 32; + + format = PIPE_FORMAT_S8Z24_UNORM; + if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) { + format = PIPE_FORMAT_Z24S8_UNORM; + if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) + format = PIPE_FORMAT_NONE; + } + if (format != PIPE_FORMAT_NONE) { + nconf->depth_format = format; + nconf->stencil_format = format; + + nconf->mode.depthBits = 24; + nconf->mode.stencilBits = 8; + nconf->mode.haveDepthBuffer = TRUE; + nconf->mode.haveStencilBuffer = TRUE; + } + + nconf->scanout_bit = TRUE; + nconf->mode.drawableType = GLX_PBUFFER_BIT; + nconf->mode.swapMethod = GLX_SWAP_EXCHANGE_OML; + + nconf->mode.visualID = 0; + nconf->mode.visualType = EGL_NONE; + + nconf->mode.renderType = GLX_RGBA_BIT; + nconf->mode.rgbMode = TRUE; + nconf->mode.xRenderable = FALSE; + } + + configs = malloc(sizeof(*configs)); + if (configs) { + configs[0] = &kdpy->config->base; + if (num_configs) + *num_configs = 1; + } + + return configs; +} + +static void +kms_display_destroy(struct native_display *ndpy) +{ + struct kms_display *kdpy = kms_display(ndpy); + int i; + + if (kdpy->config) + free(kdpy->config); + + if (kdpy->connectors) { + for (i = 0; i < kdpy->num_connectors; i++) { + struct kms_connector *kconn = &kdpy->connectors[i]; + if (kconn->connector) { + drmModeFreeConnector(kconn->connector); + free(kconn->kms_modes); + } + } + free(kdpy->connectors); + } + + if (kdpy->shown_surfaces) + free(kdpy->shown_surfaces); + + if (kdpy->saved_crtcs) { + for (i = 0; i < kdpy->resources->count_crtcs; i++) { + struct kms_crtc *kcrtc = &kdpy->saved_crtcs[i]; + + if (kcrtc->crtc) { + /* restore crtc */ + drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id, + kcrtc->crtc->buffer_id, kcrtc->crtc->x, kcrtc->crtc->y, + kcrtc->connectors, kcrtc->num_connectors, + &kcrtc->crtc->mode); + + drmModeFreeCrtc(kcrtc->crtc); + } + } + free(kdpy->saved_crtcs); + } + + if (kdpy->resources) + drmModeFreeResources(kdpy->resources); + + if (kdpy->base.screen) + kdpy->base.screen->destroy(kdpy->base.screen); + + if (kdpy->fd >= 0) + drmClose(kdpy->fd); + + if (kdpy->api) + kdpy->api->destroy(kdpy->api); + free(kdpy); +} + +/** + * Initialize KMS and pipe screen. + */ +static boolean +kms_display_init_screen(struct native_display *ndpy) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct drm_create_screen_arg arg; + int fd; + + fd = drmOpen(kdpy->api->name, NULL); + if (fd < 0) { + _eglLog(_EGL_WARNING, "failed to open DRM device"); + return FALSE; + } + +#if 0 + if (drmSetMaster(fd)) { + _eglLog(_EGL_WARNING, "failed to become DRM master"); + return FALSE; + } +#endif + + memset(&arg, 0, sizeof(arg)); + arg.mode = DRM_CREATE_NORMAL; + kdpy->base.screen = kdpy->api->create_screen(kdpy->api, fd, &arg); + if (!kdpy->base.screen) { + _eglLog(_EGL_WARNING, "failed to create DRM screen"); + drmClose(fd); + return FALSE; + } + + kdpy->fd = fd; + + return TRUE; +} + +static struct native_display_modeset kms_display_modeset = { + .get_connectors = kms_display_get_connectors, + .get_modes = kms_display_get_modes, + .create_scanout_surface = kms_display_create_scanout_surface, + .program = kms_display_program +}; + +static struct native_display * +kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api, + native_flush_frontbuffer flush_frontbuffer) +{ + struct kms_display *kdpy; + + kdpy = CALLOC_STRUCT(kms_display); + if (!kdpy) + return NULL; + + kdpy->api = api; + if (!kdpy->api) { + _eglLog(_EGL_WARNING, "failed to create DRM API"); + free(kdpy); + return NULL; + } + + kdpy->fd = -1; + if (!kms_display_init_screen(&kdpy->base)) { + kms_display_destroy(&kdpy->base); + return NULL; + } + + /* resources are fixed, unlike crtc, connector, or encoder */ + kdpy->resources = drmModeGetResources(kdpy->fd); + if (!kdpy->resources) { + kms_display_destroy(&kdpy->base); + return NULL; + } + + kdpy->saved_crtcs = + calloc(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs)); + if (!kdpy->saved_crtcs) { + kms_display_destroy(&kdpy->base); + return NULL; + } + + kdpy->shown_surfaces = + calloc(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces)); + if (!kdpy->shown_surfaces) { + kms_display_destroy(&kdpy->base); + return NULL; + } + + kdpy->base.screen->flush_frontbuffer = + (void (*)(struct pipe_screen *, struct pipe_surface *, void *)) + flush_frontbuffer; + + kdpy->base.destroy = kms_display_destroy; + kdpy->base.get_configs = kms_display_get_configs; + kdpy->base.create_context = kms_display_create_context; + kdpy->base.create_pbuffer_surface = kms_display_create_pbuffer_surface; + + kdpy->base.modeset = &kms_display_modeset; + + return &kdpy->base; +} + +static void +dummy_flush_frontbuffer(void *dummy, struct pipe_surface *surf, + void *context_private) +{ + _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied"); +} + +/* the api is destroyed with the native display */ +static struct drm_api *drm_api; + +const char * +native_get_name(void) +{ + static char kms_name[32]; + + if (!drm_api) + drm_api = drm_api_create(); + + if (drm_api) + snprintf(kms_name, sizeof(kms_name), "KMS/%s", drm_api->name); + else + snprintf(kms_name, sizeof(kms_name), "KMS"); + + return kms_name; +} + +struct native_display * +native_create_display(EGLNativeDisplayType dpy, + native_flush_frontbuffer flush_frontbuffer) +{ + struct native_display *ndpy = NULL; + + if (!drm_api) + drm_api = drm_api_create(); + + if (!flush_frontbuffer) + flush_frontbuffer = dummy_flush_frontbuffer; + + if (drm_api) + ndpy = kms_create_display(dpy, drm_api, flush_frontbuffer); + + return ndpy; +} diff --git a/src/gallium/state_trackers/egl_g3d/kms/native_kms.h b/src/gallium/state_trackers/egl_g3d/kms/native_kms.h new file mode 100644 index 00000000000..3f869b25acf --- /dev/null +++ b/src/gallium/state_trackers/egl_g3d/kms/native_kms.h @@ -0,0 +1,138 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _NATIVE_KMS_H_ +#define _NATIVE_KMS_H_ + +#include +#include + +#include "pipe/p_compiler.h" +#include "util/u_format.h" +#include "pipe/p_state.h" +#include "state_tracker/drm_api.h" + +#include "common/native.h" + +enum kms_surface_type { + KMS_SURFACE_TYPE_PBUFFER, + KMS_SURFACE_TYPE_SCANOUT +}; + +struct kms_config; +struct kms_connector; +struct kms_mode; + +struct kms_crtc { + drmModeCrtcPtr crtc; + uint32_t connectors[32]; + int num_connectors; +}; + +struct kms_display { + struct native_display base; + + int fd; + struct drm_api *api; + drmModeResPtr resources; + struct kms_config *config; + + struct kms_connector *connectors; + int num_connectors; + + struct kms_surface **shown_surfaces; + /* save the original settings of the CRTCs */ + struct kms_crtc *saved_crtcs; +}; + +struct kms_framebuffer { + struct pipe_texture *texture; + boolean is_passive; + + uint32_t buffer_id; +}; + +struct kms_surface { + struct native_surface base; + enum kms_surface_type type; + enum pipe_format color_format; + struct kms_display *kdpy; + int width, height; + + struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; + struct kms_framebuffer front_fb, back_fb; + + boolean is_shown; + struct kms_crtc current_crtc; +}; + +struct kms_config { + struct native_config base; +}; + +struct kms_connector { + struct native_connector base; + + uint32_t connector_id; + drmModeConnectorPtr connector; + struct kms_mode *kms_modes; + int num_modes; +}; + +struct kms_mode { + struct native_mode base; + drmModeModeInfo mode; +}; + +static INLINE struct kms_display * +kms_display(const struct native_display *ndpy) +{ + return (struct kms_display *) ndpy; +} + +static INLINE struct kms_surface * +kms_surface(const struct native_surface *nsurf) +{ + return (struct kms_surface *) nsurf; +} + +static INLINE struct kms_config * +kms_config(const struct native_config *nconf) +{ + return (struct kms_config *) nconf; +} + +static INLINE struct kms_connector * +kms_connector(const struct native_connector *nconn) +{ + return (struct kms_connector *) nconn; +} + +static INLINE struct kms_mode * +kms_mode(const struct native_mode *nmode) +{ + return (struct kms_mode *) nmode; +} + +#endif /* _NATIVE_KMS_H_ */ -- cgit v1.2.3 From 077d6dd7508af88509dd0499c5dfbdaa186b4015 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 10 Jan 2010 23:08:39 +0800 Subject: winsys/drm: Use egl_g3d to build EGL drivers. The new EGL drivers use egl_g3d and respect EGL_DISPLAYS. They are named after the display supported and the DRM name. Signed-off-by: Chia-I Wu --- configure.ac | 2 +- src/gallium/winsys/drm/Makefile.egl_g3d | 64 +++++++++++++++++++++++++ src/gallium/winsys/drm/i965/egl_g3d/Makefile | 14 ++++++ src/gallium/winsys/drm/i965/egl_g3d/dummy.c | 1 + src/gallium/winsys/drm/intel/egl_g3d/Makefile | 14 ++++++ src/gallium/winsys/drm/intel/egl_g3d/dummy.c | 1 + src/gallium/winsys/drm/nouveau/egl_g3d/Makefile | 19 ++++++++ src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c | 1 + src/gallium/winsys/drm/radeon/egl_g3d/Makefile | 14 ++++++ src/gallium/winsys/drm/radeon/egl_g3d/dummy.c | 1 + src/gallium/winsys/drm/vmware/egl_g3d/Makefile | 14 ++++++ src/gallium/winsys/drm/vmware/egl_g3d/dummy.c | 1 + 12 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 src/gallium/winsys/drm/Makefile.egl_g3d create mode 100644 src/gallium/winsys/drm/i965/egl_g3d/Makefile create mode 100644 src/gallium/winsys/drm/i965/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/intel/egl_g3d/Makefile create mode 100644 src/gallium/winsys/drm/intel/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/nouveau/egl_g3d/Makefile create mode 100644 src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/radeon/egl_g3d/Makefile create mode 100644 src/gallium/winsys/drm/radeon/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/vmware/egl_g3d/Makefile create mode 100644 src/gallium/winsys/drm/vmware/egl_g3d/dummy.c (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 5fea166c67b..23bce96ca63 100644 --- a/configure.ac +++ b/configure.ac @@ -1162,7 +1162,7 @@ yes) dri) GALLIUM_STATE_TRACKERS_DIRS="dri" if test "x$enable_egl" = xyes; then - GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl" + GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl egl_g3d" fi # Have only tested st/xorg on 1.6.0 servers PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0], diff --git a/src/gallium/winsys/drm/Makefile.egl_g3d b/src/gallium/winsys/drm/Makefile.egl_g3d new file mode 100644 index 00000000000..3ce27258529 --- /dev/null +++ b/src/gallium/winsys/drm/Makefile.egl_g3d @@ -0,0 +1,64 @@ +# src/gallium/winsys/drm/Makefile.egl_g3d + +# The driver Makefile should define +# +# EGL_DRIVER_NAME, the name of the driver +# EGL_DRIVER_SOURCES, the sources of the driver +# EGL_DRIVER_LIBS, extra libraries needed by the driver +# EGL_DRIVER_PIPES, the pipe drivers of the driver +# +# before including this file. + +EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o) + +common_LIBS = -ldrm -lm -ldl + +x11_ST = $(TOP)/src/gallium/state_trackers/egl_g3d/libeglx11.a +x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes + +kms_ST = $(TOP)/src/gallium/state_trackers/egl_g3d/libeglkms.a +kms_LIBS = $(common_LIBS) + +##### RULES ##### + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + + +##### TARGETS ##### + +EGL_DISPLAY_DRIVERS = $(foreach dpy, $(EGL_DISPLAYS), egl_$(dpy)_$(EGL_DRIVER_NAME).so) + +LIB_GALLIUM_DIR = $(TOP)/$(LIB_DIR)/gallium +EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(LIB_GALLIUM_DIR)/$(drv)) + +default: $(EGL_DISPLAY_LIBS) + +$(EGL_DISPLAY_LIBS): $(LIB_GALLIUM_DIR)/%.so: %.so + @mkdir -p $(LIB_GALLIUM_DIR) + $(INSTALL) $^ $(LIB_GALLIUM_DIR) + +define mklib-egl +$(MKLIB) -noprefix -o $@ $(EGL_DRIVER_OBJECTS) \ + -Wl,--whole-archive $($(1)_ST) -Wl,--no-whole-archive \ + $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $($(1)_LIBS) $(EGL_DRIVER_LIBS) +endef + +egl_x11_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(x11_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile + $(call mklib-egl,x11) + +egl_kms_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(kms_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile + $(call mklib-egl,kms) + +clean: + -rm -f $(EGL_DRIVER_OBJECTS) + -rm -f $(EGL_DISPLAY_DRIVERS) + +install: $(EGL_DISPLAY_LIBS) + @$(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + @echo "Install $(EGL_DISPLAY_DRIVERS)" + @for lib in "$(EGL_DISPLAY_LIBS)"; do \ + $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR); \ + done + +depend: diff --git a/src/gallium/winsys/drm/i965/egl_g3d/Makefile b/src/gallium/winsys/drm/i965/egl_g3d/Makefile new file mode 100644 index 00000000000..dd2efe24855 --- /dev/null +++ b/src/gallium/winsys/drm/i965/egl_g3d/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = i965 +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = -ldrm_intel + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/i965/libi965.a + +include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/i965/egl_g3d/dummy.c b/src/gallium/winsys/drm/i965/egl_g3d/dummy.c new file mode 100644 index 00000000000..4a1bc28b0b6 --- /dev/null +++ b/src/gallium/winsys/drm/i965/egl_g3d/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/intel/egl_g3d/Makefile b/src/gallium/winsys/drm/intel/egl_g3d/Makefile new file mode 100644 index 00000000000..cdbb680773c --- /dev/null +++ b/src/gallium/winsys/drm/intel/egl_g3d/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = i915 +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = -ldrm_intel + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/i915/libi915.a + +include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/intel/egl_g3d/dummy.c b/src/gallium/winsys/drm/intel/egl_g3d/dummy.c new file mode 100644 index 00000000000..4a1bc28b0b6 --- /dev/null +++ b/src/gallium/winsys/drm/intel/egl_g3d/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/nouveau/egl_g3d/Makefile b/src/gallium/winsys/drm/nouveau/egl_g3d/Makefile new file mode 100644 index 00000000000..865a5d56a97 --- /dev/null +++ b/src/gallium/winsys/drm/nouveau/egl_g3d/Makefile @@ -0,0 +1,19 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = nouveau +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = -ldrm_nouveau + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ + $(TOP)/src/gallium/drivers/nv04/libnv04.a \ + $(TOP)/src/gallium/drivers/nv10/libnv10.a \ + $(TOP)/src/gallium/drivers/nv20/libnv20.a \ + $(TOP)/src/gallium/drivers/nv30/libnv30.a \ + $(TOP)/src/gallium/drivers/nv40/libnv40.a \ + $(TOP)/src/gallium/drivers/nv50/libnv50.a \ + $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a + +include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c b/src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c new file mode 100644 index 00000000000..4a1bc28b0b6 --- /dev/null +++ b/src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/radeon/egl_g3d/Makefile b/src/gallium/winsys/drm/radeon/egl_g3d/Makefile new file mode 100644 index 00000000000..9027a5ff46d --- /dev/null +++ b/src/gallium/winsys/drm/radeon/egl_g3d/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = r300 +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = -ldrm_radeon + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/r300/libr300.a + +include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/radeon/egl_g3d/dummy.c b/src/gallium/winsys/drm/radeon/egl_g3d/dummy.c new file mode 100644 index 00000000000..4a1bc28b0b6 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/egl_g3d/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/vmware/egl_g3d/Makefile b/src/gallium/winsys/drm/vmware/egl_g3d/Makefile new file mode 100644 index 00000000000..3cf79924e08 --- /dev/null +++ b/src/gallium/winsys/drm/vmware/egl_g3d/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = vmwgfx +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/svga/libsvga.a + +include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/vmware/egl_g3d/dummy.c b/src/gallium/winsys/drm/vmware/egl_g3d/dummy.c new file mode 100644 index 00000000000..4a1bc28b0b6 --- /dev/null +++ b/src/gallium/winsys/drm/vmware/egl_g3d/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ -- cgit v1.2.3 From 99a37ed195801fd0a0b64a20f08c8d4f9d66137f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 5 Jan 2010 17:39:05 +0800 Subject: configure.ac: Fix es state tracker build. mesa/es should be built before the es state trackers. This is done by separating those that need to be built early from SRC_DIRS to CORE_DIRS. The new variable is not exported, and will be prepended to SRC_DIRS. Signed-off-by: Chia-I Wu --- configure.ac | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 1f94248824c..a5e181dbf44 100644 --- a/configure.ac +++ b/configure.ac @@ -419,7 +419,11 @@ esac dnl dnl Driver specific build directories dnl -SRC_DIRS="glsl mesa glew" + +dnl this variable will be prepended to SRC_DIRS and is not exported +CORE_DIRS="glsl mesa" + +SRC_DIRS="glew" GLU_DIRS="sgi" WINDOW_SYSTEM="" GALLIUM_DIRS="auxiliary drivers state_trackers" @@ -434,7 +438,7 @@ xlib) GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib" ;; dri) - SRC_DIRS="glx/x11 $SRC_DIRS" + CORE_DIRS="glx/x11 $CORE_DIRS" DRIVER_DIRS="dri" WINDOW_SYSTEM="dri" GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm" @@ -1191,7 +1195,7 @@ yes) ;; es) # mesa/es is required to build es state tracker - SRC_DIRS="mesa/es $SRC_DIRS" + CORE_DIRS="$CORE_DIRS mesa/es" ;; esac done @@ -1306,6 +1310,8 @@ if test "x$enable_gallium_nouveau" = xyes; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nv04 nv10 nv20 nv30 nv40 nv50" fi +dnl prepend CORE_DIRS to SRC_DIRS +SRC_DIRS="$CORE_DIRS $SRC_DIRS" dnl Restore LDFLAGS and CPPFLAGS LDFLAGS="$_SAVE_LDFLAGS" -- cgit v1.2.3 From ed59b13da8b036cb428ae5074d9217792191daeb Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Wed, 13 Jan 2010 15:48:14 -0500 Subject: GLX: use glproto CFLAGS etc. when building Roll the glproto check into the dri2proto and libdrm check so we get the proper CFLAGS and LDFLAGS for the package. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 23bce96ca63..4f28fc0d14d 100644 --- a/configure.ac +++ b/configure.ac @@ -576,9 +576,9 @@ dri) # Check for libdrm PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED]) PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED]) - GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED" - DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED" PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED]) + GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED glproto >= $GLPROTO_REQUIRED" + DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED" # find the DRI deps for libGL if test "$x11_pkgconfig" = yes; then -- cgit v1.2.3 From 877cadb65512a93f3ccf2f25bbc2f7565d75050f Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 14 Jan 2010 22:51:25 +0000 Subject: r300g: Build driver by default Do the auto trick that is used for both i915, i965 and svga. --- configs/default | 2 +- configure.ac | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'configure.ac') diff --git a/configs/default b/configs/default index 8b4557d26a8..ec9670dd634 100644 --- a/configs/default +++ b/configs/default @@ -98,7 +98,7 @@ EGL_DRIVERS_DIRS = demo # Gallium directories and GALLIUM_DIRS = auxiliary drivers state_trackers GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a -GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 trace identity +GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) GALLIUM_WINSYS_DIRS = xlib egl_xlib GALLIUM_WINSYS_DRM_DIRS = diff --git a/configure.ac b/configure.ac index 4f28fc0d14d..d01d0f18846 100644 --- a/configure.ac +++ b/configure.ac @@ -1279,10 +1279,12 @@ AC_ARG_ENABLE([gallium-radeon], [AS_HELP_STRING([--enable-gallium-radeon], [build gallium radeon @<:@default=disabled@:>@])], [enable_gallium_radeon="$enableval"], - [enable_gallium_radeon=no]) + [enable_gallium_radeon=auto]) if test "x$enable_gallium_radeon" = xyes; then GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS radeon" GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" +elif test "x$enable_gallium_radeon" = xauto; then + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" fi dnl -- cgit v1.2.3 From adda7f3215a0f749751977cbbb6cef67f7163be5 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 16 Jan 2010 18:34:23 -0800 Subject: Check if gcc supports -fvisibility=hidden before adding to CFLAGS Signed-off-by: Alan Coopersmith --- configure.ac | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index d01d0f18846..f121002d4be 100644 --- a/configure.ac +++ b/configure.ac @@ -96,7 +96,14 @@ esac dnl Add flags for gcc and g++ if test "x$GCC" = xyes; then - CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math -fvisibility=hidden" + CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math" + + # Enable -fvisibility=hidden if using a gcc that supports it + save_CFLAGS="$CFLAGS" + AC_MSG_CHECKING([whether $(CC) supports -fvisibility=hidden]) + CFLAGS="$CFLAGS -fvisibility=hidden" + AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]), + [CFLAGS="$save_CFLAGS" ; AC_MSG_RESULT([no])]); # Work around aliasing bugs - developers should comment this out CFLAGS="$CFLAGS -fno-strict-aliasing" -- cgit v1.2.3 From f8107a45ce92a7b0aedc2ae562ca609308b096a8 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 21 Jan 2010 16:42:58 -0800 Subject: Fix typo in configure message for gcc -fvisibility=hidden Need to use $CC for a shell variable, not $(CC) for a make variable which the shell interprets as running the command "CC". Signed-off-by: Alan Coopersmith --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 6ae526d5e1e..619ed47bcbd 100644 --- a/configure.ac +++ b/configure.ac @@ -100,7 +100,7 @@ if test "x$GCC" = xyes; then # Enable -fvisibility=hidden if using a gcc that supports it save_CFLAGS="$CFLAGS" - AC_MSG_CHECKING([whether $(CC) supports -fvisibility=hidden]) + AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden]) CFLAGS="$CFLAGS -fvisibility=hidden" AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]), [CFLAGS="$save_CFLAGS" ; AC_MSG_RESULT([no])]); -- cgit v1.2.3 From 2a928899e345e400c4266910b4e33b36a20575e2 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 15:12:19 +0800 Subject: egl: Remove USING_EGL and the related drivers. They do not build for a long while and there seems to be no active users. It might be better for them to live in the git histroy. --- configs/autoconf.in | 1 - configs/linux-dri-xcb | 13 - configs/linux-egl | 6 - configure.ac | 8 - src/mesa/drivers/dri/fb/Makefile | 3 - src/mesa/drivers/dri/fb/fb_egl.c | 881 ------------------ src/mesa/drivers/dri/r200/Makefile | 4 - src/mesa/drivers/dri/r200/server/radeon_egl.c | 1 - src/mesa/drivers/dri/r300/Makefile | 4 - src/mesa/drivers/dri/r300/server/radeon_egl.c | 1 - src/mesa/drivers/dri/r600/Makefile | 4 - src/mesa/drivers/dri/r600/server/radeon_egl.c | 1 - src/mesa/drivers/dri/radeon/server/radeon_egl.c | 1088 ----------------------- 13 files changed, 2015 deletions(-) delete mode 100644 src/mesa/drivers/dri/fb/fb_egl.c delete mode 120000 src/mesa/drivers/dri/r200/server/radeon_egl.c delete mode 120000 src/mesa/drivers/dri/r300/server/radeon_egl.c delete mode 120000 src/mesa/drivers/dri/r600/server/radeon_egl.c delete mode 100644 src/mesa/drivers/dri/radeon/server/radeon_egl.c (limited to 'configure.ac') diff --git a/configs/autoconf.in b/configs/autoconf.in index c6d315e4d2e..d9fa2dafe93 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -85,7 +85,6 @@ PROGRAM_DIRS = @PROGRAM_DIRS@ DRI_DIRS = @DRI_DIRS@ WINDOW_SYSTEM = @WINDOW_SYSTEM@ EGL_DISPLAYS = @EGL_DISPLAYS@ -USING_EGL = @USING_EGL@ # Dependencies X11_INCLUDES = @X11_INCLUDES@ diff --git a/configs/linux-dri-xcb b/configs/linux-dri-xcb index 827fb973308..7b99dccdb88 100644 --- a/configs/linux-dri-xcb +++ b/configs/linux-dri-xcb @@ -47,21 +47,8 @@ DRI_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB) GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl \ $(LIBDRM_LIB) $(shell pkg-config --libs xcb) $(shell pkg-config --libs x11-xcb) $(shell pkg-config --libs xcb-glx) - -# This is now 0 by default since it seems to confuse the hell out of people -# and generate a lot of extra noise on bugzilla. If you need to build with -# EGL, do 'make linux-dri USING_EGL=1' - -USING_EGL=0 - -# Directories -ifeq ($(USING_EGL), 1) -SRC_DIRS = egl glx/x11 gallium mesa glu glut/glx glew glw -PROGRAM_DIRS = egl -else SRC_DIRS = glx/x11 gallium mesa glu glut/glx glew glw PROGRAM_DIRS = xdemos -endif DRIVER_DIRS = dri WINDOW_SYSTEM=dri diff --git a/configs/linux-egl b/configs/linux-egl index e906806f4b8..6494a68aeb1 100644 --- a/configs/linux-egl +++ b/configs/linux-egl @@ -46,12 +46,6 @@ GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \ $(LIBDRM_LIB) -# This is now 0 by default since it seems to confuse the hell out of people -# and generate a lot of extra noise on bugzilla. If you need to build with -# EGL, do 'make linux-dri USING_EGL=1' - -USING_EGL=0 - # Directories SRC_DIRS = gallium mesa gallium/winsys glu egl PROGRAM_DIRS = egl diff --git a/configure.ac b/configure.ac index 619ed47bcbd..e5c2386320f 100644 --- a/configure.ac +++ b/configure.ac @@ -699,10 +699,6 @@ yes) ;; esac -dnl Just default to no EGL for now -USING_EGL=0 -AC_SUBST([USING_EGL]) - dnl Set DRI_DIRS, DEFINES and LIB_DEPS if test "$mesa_driver" = dri; then # Use TLS in GLX? @@ -710,10 +706,6 @@ if test "$mesa_driver" = dri; then DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS" fi - if test "x$USING_EGL" = x1; then - PROGRAM_DIRS="egl" - fi - # Platform specific settings and drivers to build case "$host_os" in linux*) diff --git a/src/mesa/drivers/dri/fb/Makefile b/src/mesa/drivers/dri/fb/Makefile index cf9b3a85563..848e2041e27 100644 --- a/src/mesa/drivers/dri/fb/Makefile +++ b/src/mesa/drivers/dri/fb/Makefile @@ -5,9 +5,6 @@ include $(TOP)/configs/current LIBNAME = fb_dri.so -ifeq ($(USING_EGL), 1) -EGL_SOURCES = server/radeon_egl.c -endif DRIVER_SOURCES = \ fb_dri.c \ diff --git a/src/mesa/drivers/dri/fb/fb_egl.c b/src/mesa/drivers/dri/fb/fb_egl.c deleted file mode 100644 index 02e44bb8eed..00000000000 --- a/src/mesa/drivers/dri/fb/fb_egl.c +++ /dev/null @@ -1,881 +0,0 @@ -/* - * Test egl driver for fb_dri.so - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "utils.h" -#include "buffers.h" -#include "main/extensions.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "vbo/vbo.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/tcontext.h" -#include "tnl/t_pipeline.h" -#include "drivers/common/driverfuncs.h" -#include "drirenderbuffer.h" - -#include "eglconfig.h" -#include "eglmain/context.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "eglglobals.h" -#include "eglmode.h" -#include "eglscreen.h" -#include "eglsurface.h" - -extern void -fbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis); - -/** - * fb driver-specific driver class derived from _EGLDriver - */ -typedef struct fb_driver -{ - _EGLDriver Base; /* base class/object */ - GLuint fbStuff; -} fbDriver; - -/** - * fb display-specific driver class derived from _EGLDisplay - */ -typedef struct fb_display -{ - _EGLDisplay Base; /* base class/object */ - void *pFB; -} fbDisplay; - -/** - * fb driver-specific screen class derived from _EGLScreen - */ -typedef struct fb_screen -{ - _EGLScreen Base; - char fb[NAME_MAX]; -} fbScreen; - - -/** - * fb driver-specific surface class derived from _EGLSurface - */ -typedef struct fb_surface -{ - _EGLSurface Base; /* base class/object */ - struct gl_framebuffer *mesa_framebuffer; -} fbSurface; - - -/** - * fb driver-specific context class derived from _EGLContext - */ -typedef struct fb_context -{ - _EGLContext Base; /* base class/object */ - GLcontext *glCtx; - struct { - __DRIcontext *context; - __DRIscreen *screen; - __DRIdrawable *drawable; /* drawable bound to this ctx */ - } dri; -} fbContext, *fbContextPtr; - -#define FB_CONTEXT(ctx) ((fbContextPtr)(ctx->DriverCtx)) - - -static EGLBoolean -fbFillInConfigs(_EGLDisplay *disp, unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer) { - _EGLConfig *configs; - _EGLConfig *c; - unsigned int i, num_configs; - unsigned int depth_buffer_factor; - unsigned int back_buffer_factor; - GLenum fb_format; - GLenum fb_type; - - /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy - * enough to add support. Basically, if a context is created with an - * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping - * will never be used. - */ - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ - }; - - uint8_t depth_bits_array[2]; - uint8_t stencil_bits_array[2]; - - depth_bits_array[0] = 0; - depth_bits_array[1] = depth_bits; - - /* Just like with the accumulation buffer, always provide some modes - * with a stencil buffer. It will be a sw fallback, but some apps won't - * care about that. - */ - stencil_bits_array[0] = 0; - stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; - - depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1; - back_buffer_factor = (have_back_buffer) ? 2 : 1; - - num_configs = depth_buffer_factor * back_buffer_factor * 2; - - if (pixel_bits == 16) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } else { - fb_format = GL_RGBA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = calloc(sizeof(*configs), num_configs); - c = configs; - if (!_eglFillInConfigs(c, fb_format, fb_type, - depth_bits_array, stencil_bits_array, depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - GLX_TRUE_COLOR)) { - fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__); - return EGL_FALSE; - } - - /* Mark the visual as slow if there are "fake" stencil bits. - */ - for (i = 0, c = configs; i < num_configs; i++, c++) { - int stencil = GET_CONFIG_ATTRIB(c, EGL_STENCIL_SIZE); - if ((stencil != 0) && (stencil != stencil_bits)) { - SET_CONFIG_ATTRIB(c, EGL_CONFIG_CAVEAT, EGL_SLOW_CONFIG); - } - } - - for (i = 0, c = configs; i < num_configs; i++, c++) - _eglAddConfig(disp, c); - - free(configs); - - return EGL_TRUE; -} - -static EGLBoolean -fbSetupFramebuffer(fbDisplay *disp, char *fbdev) -{ - int fd; - char dev[20]; - struct fb_var_screeninfo varInfo; - struct fb_fix_screeninfo fixedInfo; - - snprintf(dev, sizeof(dev), "/dev/%s", fbdev); - - /* open the framebuffer device */ - fd = open(dev, O_RDWR); - if (fd < 0) { - fprintf(stderr, "Error opening %s: %s\n", fbdev, strerror(errno)); - return EGL_FALSE; - } - - /* get the original variable screen info */ - if (ioctl(fd, FBIOGET_VSCREENINFO, &varInfo)) { - fprintf(stderr, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n", - strerror(errno)); - return EGL_FALSE; - } - - /* Turn off hw accels (otherwise mmap of mmio region will be - * refused) - */ - if (varInfo.accel_flags) { - varInfo.accel_flags = 0; - if (ioctl(fd, FBIOPUT_VSCREENINFO, &varInfo)) { - fprintf(stderr, "error: ioctl(FBIOPUT_VSCREENINFO) failed: %s\n", - strerror(errno)); - return EGL_FALSE; - } - } - - /* Get the fixed screen info */ - if (ioctl(fd, FBIOGET_FSCREENINFO, &fixedInfo)) { - fprintf(stderr, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n", - strerror(errno)); - return EGL_FALSE; - } - - if (fixedInfo.visual == FB_VISUAL_DIRECTCOLOR) { - struct fb_cmap cmap; - unsigned short red[256], green[256], blue[256]; - int rcols = 1 << varInfo.red.length; - int gcols = 1 << varInfo.green.length; - int bcols = 1 << varInfo.blue.length; - int i; - - cmap.start = 0; - cmap.len = gcols; - cmap.red = red; - cmap.green = green; - cmap.blue = blue; - cmap.transp = NULL; - - for (i = 0; i < rcols ; i++) - red[i] = (65536/(rcols-1)) * i; - - for (i = 0; i < gcols ; i++) - green[i] = (65536/(gcols-1)) * i; - - for (i = 0; i < bcols ; i++) - blue[i] = (65536/(bcols-1)) * i; - - if (ioctl(fd, FBIOPUTCMAP, (void *) &cmap) < 0) { - fprintf(stderr, "ioctl(FBIOPUTCMAP) failed [%d]\n", i); - exit(1); - } - } - - /* mmap the framebuffer into our address space */ - if (!disp->pFB) - disp->pFB = (caddr_t)mmap(0, /* start */ - fixedInfo.smem_len, /* bytes */ - PROT_READ | PROT_WRITE, /* prot */ - MAP_SHARED, /* flags */ - fd, /* fd */ - 0); /* offset */ - if (disp->pFB == (caddr_t)-1) { - fprintf(stderr, "error: unable to mmap framebuffer: %s\n", - strerror(errno)); - return EGL_FALSE; - } - - return EGL_TRUE; -} - -const char *sysfs = "/sys/class/graphics"; - -static EGLBoolean -fbInitialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) -{ - _EGLDisplay *disp = _eglLookupDisplay(dpy); - fbDisplay *display; - fbScreen *s; - _EGLScreen *scrn; - char c; - unsigned int x, y, r; - DIR *dir; - FILE *file; - struct dirent *dirent; - char path[NAME_MAX]; - - /* Switch display structure to one with our private fields */ - display = calloc(1, sizeof(*display)); - display->Base = *disp; - _eglHashInsert(_eglGlobal.Displays, disp->Handle, display); - free(disp); - - *major = 1; - *minor = 0; - - dir = opendir(sysfs); - if (!dir) { - printf("EGL - %s framebuffer device not found.", sysfs); - return EGL_FALSE; - } - - while ((dirent = readdir(dir))) { /* assignment! */ - - if (dirent->d_name[0] != 'f') - continue; - if (dirent->d_name[1] != 'b') - continue; - - if (fbSetupFramebuffer(display, dirent->d_name) == EGL_FALSE) - continue; - - /* Create a screen */ - s = (fbScreen *) calloc(1, sizeof(fbScreen)); - if (!s) - return EGL_FALSE; - - strncpy(s->fb, dirent->d_name, NAME_MAX); - scrn = &s->Base; - _eglInitScreen(scrn); - _eglAddScreen(&display->Base, scrn); - - snprintf(path, sizeof(path), "%s/%s/modes", sysfs, s->fb); - file = fopen(path, "r"); - while (fgets(path, sizeof(path), file)) { - sscanf(path, "%c:%ux%u-%u", &c, &x, &y, &r); - _eglAddMode(scrn, x, y, r * 1000, path); - } - fclose(file); - - fbFillInConfigs(&display->Base, 32, 24, 8, 1); - - } - closedir(dir); - - drv->Initialized = EGL_TRUE; - return EGL_TRUE; -} - - -static fbDisplay * -Lookup_fbDisplay(EGLDisplay dpy) -{ - _EGLDisplay *d = _eglLookupDisplay(dpy); - return (fbDisplay *) d; -} - - -static fbScreen * -Lookup_fbScreen(EGLDisplay dpy, EGLScreenMESA screen) -{ - _EGLScreen *s = _eglLookupScreen(dpy, screen); - return (fbScreen *) s; -} - - -static fbContext * -Lookup_fbContext(EGLContext ctx) -{ - _EGLContext *c = _eglLookupContext(ctx); - return (fbContext *) c; -} - - -static fbSurface * -Lookup_fbSurface(EGLSurface surf) -{ - _EGLSurface *s = _eglLookupSurface(surf); - return (fbSurface *) s; -} - - -static EGLBoolean -fbTerminate(_EGLDriver *drv, EGLDisplay dpy) -{ - fbDisplay *display = Lookup_fbDisplay(dpy); - _eglCleanupDisplay(&display->Base); - free(display); - free(drv); - return EGL_TRUE; -} - - -static const GLubyte * -get_string(GLcontext *ctx, GLenum pname) -{ - (void) ctx; - switch (pname) { - case GL_RENDERER: - return (const GLubyte *) "Mesa dumb framebuffer"; - default: - return NULL; - } -} - - -static void -update_state( GLcontext *ctx, GLuint new_state ) -{ - /* not much to do here - pass it on */ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); -} - - -/** - * Called by ctx->Driver.GetBufferSize from in core Mesa to query the - * current framebuffer size. - */ -static void -get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height ) -{ - *width = buffer->Width; - *height = buffer->Height; -} - - -static void -updateFramebufferSize(GLcontext *ctx) -{ - fbContextPtr fbmesa = FB_CONTEXT(ctx); - struct gl_framebuffer *fb = ctx->WinSysDrawBuffer; - if (fbmesa->dri.drawable->w != fb->Width || - fbmesa->dri.drawable->h != fb->Height) { - driUpdateFramebufferSize(ctx, fbmesa->dri.drawable); - } -} - -static void -viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) -{ - /* XXX this should be called after we acquire the DRI lock, not here */ - updateFramebufferSize(ctx); -} - - -static void -init_core_functions( struct dd_function_table *functions ) -{ - functions->GetString = get_string; - functions->UpdateState = update_state; - functions->GetBufferSize = get_buffer_size; - functions->Viewport = viewport; - - functions->Clear = _swrast_Clear; /* could accelerate with blits */ -} - - -static EGLContext -fbCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list) -{ - GLcontext *ctx; - _EGLConfig *conf; - fbContext *c; - _EGLDisplay *disp = _eglLookupDisplay(dpy); - struct dd_function_table functions; - GLvisual vis; - int i; - - conf = _eglLookupConfig(drv, dpy, config); - if (!conf) { - _eglError(EGL_BAD_CONFIG, "eglCreateContext"); - return EGL_NO_CONTEXT; - } - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs defined for now */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext"); - return EGL_NO_CONTEXT; - } - } - - c = (fbContext *) calloc(1, sizeof(fbContext)); - if (!c) - return EGL_NO_CONTEXT; - - _eglInitContext(&c->Base); - c->Base.Display = disp; - c->Base.Config = conf; - c->Base.DrawSurface = EGL_NO_SURFACE; - c->Base.ReadSurface = EGL_NO_SURFACE; - - /* link to display */ - _eglLinkContext(&c->Base, disp); - assert(c->Base.Handle); - - /* Init default driver functions then plug in our FBdev-specific functions - */ - _mesa_init_driver_functions(&functions); - init_core_functions(&functions); - - _eglConfigToContextModesRec(conf, &vis); - - ctx = c->glCtx = _mesa_create_context(&vis, NULL, &functions, (void *)c); - if (!c->glCtx) { - _mesa_free(c); - return GL_FALSE; - } - - /* Create module contexts */ - _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - _swsetup_Wakeup( ctx ); - - - /* use default TCL pipeline */ - { - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.RunPipeline = _tnl_run_pipeline; - } - - _mesa_enable_sw_extensions(ctx); - - return c->Base.Handle; -} - - -static EGLSurface -fbCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list) -{ - int i; - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs at this time */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreateWindowSurface"); - return EGL_NO_SURFACE; - } - } - printf("eglCreateWindowSurface()\n"); - /* XXX unfinished */ - - return EGL_NO_SURFACE; -} - - -static EGLSurface -fbCreatePixmapSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list) -{ - _EGLConfig *conf; - EGLint i; - - conf = _eglLookupConfig(drv, dpy, config); - if (!conf) { - _eglError(EGL_BAD_CONFIG, "eglCreatePixmapSurface"); - return EGL_NO_SURFACE; - } - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs at this time */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreatePixmapSurface"); - return EGL_NO_SURFACE; - } - } - - if (conf->Attrib[EGL_SURFACE_TYPE - FIRST_ATTRIB] == 0) { - _eglError(EGL_BAD_MATCH, "eglCreatePixmapSurface"); - return EGL_NO_SURFACE; - } - - printf("eglCreatePixmapSurface()\n"); - return EGL_NO_SURFACE; -} - - -static EGLSurface -fbCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) -{ - fbSurface *surf; - - surf = (fbSurface *) calloc(1, sizeof(fbSurface)); - if (!surf) { - return EGL_NO_SURFACE; - } - - if (_eglInitPbufferSurface(&surf->Base, drv, dpy, config, attrib_list) == EGL_NO_SURFACE) { - free(surf); - return EGL_NO_SURFACE; - } - - /* create software-based pbuffer */ - { - GLcontext *ctx = NULL; /* this _should_ be OK */ - GLvisual vis; - _EGLConfig *conf = _eglLookupConfig(drv, dpy, config); - assert(conf); /* bad config should be caught earlier */ - _eglConfigToContextModesRec(conf, &vis); - - surf->mesa_framebuffer = _mesa_create_framebuffer(&vis); - _mesa_add_soft_renderbuffers(surf->mesa_framebuffer, - GL_TRUE, /* color bufs */ - vis.haveDepthBuffer, - vis.haveStencilBuffer, - vis.haveAccumBuffer, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */ ); - - /* set pbuffer/framebuffer size */ - _mesa_resize_framebuffer(ctx, surf->mesa_framebuffer, - surf->Base.Width, surf->Base.Height); - } - - return surf->Base.Handle; -} - - -static EGLBoolean -fbDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) -{ - fbSurface *fs = Lookup_fbSurface(surface); - _eglUnlinkSurface(&fs->Base); - if (!_eglIsSurfaceBound(&fs->Base)) - free(fs); - return EGL_TRUE; -} - - -static EGLBoolean -fbDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) -{ - fbContext *fc = Lookup_fbContext(context); - _eglUnlinkContext(&fc->Base); - if (!_eglIsContextBound(&fc->Base)) - free(fc); - return EGL_TRUE; -} - - -static EGLBoolean -fbMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext context) -{ - fbSurface *readSurf = Lookup_fbSurface(read); - fbSurface *drawSurf = Lookup_fbSurface(draw); - fbContext *ctx = Lookup_fbContext(context); - EGLBoolean b; - - b = _eglMakeCurrent(drv, dpy, draw, read, context); - if (!b) - return EGL_FALSE; - - if (ctx) { - _mesa_make_current( ctx->glCtx, - drawSurf->mesa_framebuffer, - readSurf->mesa_framebuffer); - } else - _mesa_make_current( NULL, NULL, NULL ); - - return EGL_TRUE; -} - - -/** - * Create a drawing surface which can be directly displayed on a screen. - */ -static EGLSurface -fbCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, - const EGLint *attrib_list) -{ - _EGLConfig *config = _eglLookupConfig(drv, dpy, cfg); - fbDisplay *display = Lookup_fbDisplay(dpy); - fbSurface *surface; - EGLSurface surf; - GLvisual vis; - GLcontext *ctx = NULL; /* this should be OK */ - int origin, bytesPerPixel; - int width, height, stride; - - surface = (fbSurface *) malloc(sizeof(*surface)); - if (!surface) { - return EGL_NO_SURFACE; - } - - /* init base class, error check, etc. */ - surf = _eglInitScreenSurface(&surface->Base, drv, dpy, cfg, attrib_list); - if (surf == EGL_NO_SURFACE) { - free(surface); - return EGL_NO_SURFACE; - } - - /* convert EGLConfig to GLvisual */ - _eglConfigToContextModesRec(config, &vis); - - /* create Mesa framebuffer */ - surface->mesa_framebuffer = _mesa_create_framebuffer(&vis); - if (!surface->mesa_framebuffer) { - free(surface); - _eglUnlinkSurface(&surface->Base); - return EGL_NO_SURFACE; - } - - width = surface->Base.Width; - height = surface->Base.Height; - bytesPerPixel = vis.rgbBits / 8; - stride = width * bytesPerPixel; - origin = 0; - - /* front color renderbuffer */ - { - driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888, display->pFB, - bytesPerPixel, - origin, stride, NULL); - fbSetSpanFunctions(drb, &vis); - _mesa_add_renderbuffer(surface->mesa_framebuffer, - BUFFER_FRONT_LEFT, &drb->Base); - } - - /* back color renderbuffer */ - if (vis.doubleBufferMode) { - GLubyte *backBuf = _mesa_malloc(stride * height); - driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888, backBuf, - bytesPerPixel, - origin, stride, NULL); - fbSetSpanFunctions(drb, &vis); - _mesa_add_renderbuffer(surface->mesa_framebuffer, - BUFFER_BACK_LEFT, &drb->Base); - } - - /* other renderbuffers- software based */ - _mesa_add_soft_renderbuffers(surface->mesa_framebuffer, - GL_FALSE, /* color */ - vis.haveDepthBuffer, - vis.haveStencilBuffer, - vis.haveAccumBuffer, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - - _mesa_resize_framebuffer(ctx, surface->mesa_framebuffer, width, height); - - return surf; -} - - -/** - * Show the given surface on the named screen. - * If surface is EGL_NO_SURFACE, disable the screen's output. - */ -static EGLBoolean -fbShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, - EGLSurface surface, EGLModeMESA m) -{ - fbDisplay *display = Lookup_fbDisplay(dpy); - fbScreen *scrn = Lookup_fbScreen(dpy, screen); - fbSurface *surf = Lookup_fbSurface(surface); - FILE *file; - char buffer[NAME_MAX]; - _EGLMode *mode = _eglLookupMode(dpy, m); - int bits; - - if (!_eglShowSurfaceMESA(drv, dpy, screen, surface, m)) - return EGL_FALSE; - - snprintf(buffer, sizeof(buffer), "%s/%s/blank", sysfs, scrn->fb); - - file = fopen(buffer, "r+"); - if (!file) { -err: - printf("chown all fb sysfs attrib to allow write - %s\n", buffer); - return EGL_FALSE; - } - snprintf(buffer, sizeof(buffer), "%d", (m == EGL_NO_MODE_MESA ? VESA_POWERDOWN : VESA_VSYNC_SUSPEND)); - fputs(buffer, file); - fclose(file); - - if (m == EGL_NO_MODE_MESA) - return EGL_TRUE; - - snprintf(buffer, sizeof(buffer), "%s/%s/mode", sysfs, scrn->fb); - - file = fopen(buffer, "r+"); - if (!file) - goto err; - fputs(mode->Name, file); - fclose(file); - - snprintf(buffer, sizeof(buffer), "%s/%s/bits_per_pixel", sysfs, scrn->fb); - - file = fopen(buffer, "r+"); - if (!file) - goto err; - bits = GET_CONFIG_ATTRIB(surf->Base.Config, EGL_BUFFER_SIZE); - snprintf(buffer, sizeof(buffer), "%d", bits); - fputs(buffer, file); - fclose(file); - - fbSetupFramebuffer(display, scrn->fb); - - snprintf(buffer, sizeof(buffer), "%s/%s/blank", sysfs, scrn->fb); - - file = fopen(buffer, "r+"); - if (!file) - goto err; - - snprintf(buffer, sizeof(buffer), "%d", VESA_NO_BLANKING); - fputs(buffer, file); - fclose(file); - - return EGL_TRUE; -} - - -/* If the backbuffer is on a videocard, this is extraordinarily slow! - */ -static EGLBoolean -fbSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw) -{ - fbContext *context = (fbContext *)_eglGetCurrentContext(); - fbSurface *fs = Lookup_fbSurface(draw); - struct gl_renderbuffer * front_renderbuffer = fs->mesa_framebuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer; - void *frontBuffer = front_renderbuffer->Data; - int currentPitch = ((driRenderbuffer *)front_renderbuffer)->pitch; - void *backBuffer = fs->mesa_framebuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer->Data; - - if (!_eglSwapBuffers(drv, dpy, draw)) - return EGL_FALSE; - - if (context) { - GLcontext *ctx = context->glCtx; - - if (ctx->Visual.doubleBufferMode) { - int i; - int offset = 0; - char *tmp = _mesa_malloc(currentPitch); - - _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */ - - ASSERT(frontBuffer); - ASSERT(backBuffer); - - for (i = 0; i < fs->Base.Height; i++) { - _mesa_memcpy(tmp, (char *) backBuffer + offset, - currentPitch); - _mesa_memcpy((char *) frontBuffer + offset, tmp, - currentPitch); - offset += currentPitch; - } - - _mesa_free(tmp); - } - } - else { - /* XXX this shouldn't be an error but we can't handle it for now */ - _mesa_problem(NULL, "fbSwapBuffers: drawable has no context!\n"); - return EGL_FALSE; - } - return EGL_TRUE; -} - - -/** - * The bootstrap function. Return a new fbDriver object and - * plug in API functions. - */ -_EGLDriver * -_eglMain(_EGLDisplay *dpy) -{ - fbDriver *fb; - - fb = (fbDriver *) calloc(1, sizeof(fbDriver)); - if (!fb) { - return NULL; - } - - /* First fill in the dispatch table with defaults */ - _eglInitDriverFallbacks(&fb->Base); - - /* then plug in our fb-specific functions */ - fb->Base.Initialize = fbInitialize; - fb->Base.Terminate = fbTerminate; - fb->Base.CreateContext = fbCreateContext; - fb->Base.MakeCurrent = fbMakeCurrent; - fb->Base.CreateWindowSurface = fbCreateWindowSurface; - fb->Base.CreatePixmapSurface = fbCreatePixmapSurface; - fb->Base.CreatePbufferSurface = fbCreatePbufferSurface; - fb->Base.DestroySurface = fbDestroySurface; - fb->Base.DestroyContext = fbDestroyContext; - fb->Base.CreateScreenSurfaceMESA = fbCreateScreenSurfaceMESA; - fb->Base.ShowSurfaceMESA = fbShowSurfaceMESA; - fb->Base.SwapBuffers = fbSwapBuffers; - - /* enable supported extensions */ - fb->Base.MESA_screen_surface = EGL_TRUE; - fb->Base.MESA_copy_context = EGL_TRUE; - - return &fb->Base; -} diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile index a93dbaee910..14eb96c1bab 100644 --- a/src/mesa/drivers/dri/r200/Makefile +++ b/src/mesa/drivers/dri/r200/Makefile @@ -9,10 +9,6 @@ LIBNAME = r200_dri.so MINIGLX_SOURCES = server/radeon_dri.c -ifeq ($(USING_EGL), 1) -EGL_SOURCES = server/radeon_egl.c -endif - ifeq ($(RADEON_LDFLAGS),) CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c endif diff --git a/src/mesa/drivers/dri/r200/server/radeon_egl.c b/src/mesa/drivers/dri/r200/server/radeon_egl.c deleted file mode 120000 index d7735a76438..00000000000 --- a/src/mesa/drivers/dri/r200/server/radeon_egl.c +++ /dev/null @@ -1 +0,0 @@ -../../radeon/server/radeon_egl.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index acc4d4d8b18..04459c2ddfa 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -9,10 +9,6 @@ LIBNAME = r300_dri.so MINIGLX_SOURCES = server/radeon_dri.c -ifeq ($(USING_EGL), 1) -EGL_SOURCES = server/radeon_egl.c -endif - ifeq ($(RADEON_LDFLAGS),) CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c endif diff --git a/src/mesa/drivers/dri/r300/server/radeon_egl.c b/src/mesa/drivers/dri/r300/server/radeon_egl.c deleted file mode 120000 index d7735a76438..00000000000 --- a/src/mesa/drivers/dri/r300/server/radeon_egl.c +++ /dev/null @@ -1 +0,0 @@ -../../radeon/server/radeon_egl.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r600/Makefile b/src/mesa/drivers/dri/r600/Makefile index 8a45fc51b38..5d509415393 100644 --- a/src/mesa/drivers/dri/r600/Makefile +++ b/src/mesa/drivers/dri/r600/Makefile @@ -9,10 +9,6 @@ LIBNAME = r600_dri.so MINIGLX_SOURCES = server/radeon_dri.c -ifeq ($(USING_EGL), 1) -EGL_SOURCES = server/radeon_egl.c -endif - ifeq ($(RADEON_LDFLAGS),) CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c endif diff --git a/src/mesa/drivers/dri/r600/server/radeon_egl.c b/src/mesa/drivers/dri/r600/server/radeon_egl.c deleted file mode 120000 index d7735a76438..00000000000 --- a/src/mesa/drivers/dri/r600/server/radeon_egl.c +++ /dev/null @@ -1 +0,0 @@ -../../radeon/server/radeon_egl.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/radeon/server/radeon_egl.c b/src/mesa/drivers/dri/radeon/server/radeon_egl.c deleted file mode 100644 index c16d66e4ece..00000000000 --- a/src/mesa/drivers/dri/radeon/server/radeon_egl.c +++ /dev/null @@ -1,1088 +0,0 @@ -/* - * EGL driver for radeon_dri.so - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "eglconfig.h" -#include "eglcontext.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "eglglobals.h" -#include "egllog.h" -#include "eglmode.h" -#include "eglscreen.h" -#include "eglsurface.h" -#include "egldri.h" - -#include "mtypes.h" -#include "memops.h" -#include "drm.h" -#include "drm_sarea.h" -#include "radeon_drm.h" -#include "radeon_dri.h" -#include "radeon.h" - -static size_t radeon_drm_page_size; - -/** - * radeon driver-specific driver class derived from _EGLDriver - */ -typedef struct radeon_driver -{ - _EGLDriver Base; /* base class/object */ - GLuint radeonStuff; -} radeonDriver; - -static int -RADEONSetParam(driDisplay *disp, int param, int value) -{ - drm_radeon_setparam_t sp; - int ret; - - memset(&sp, 0, sizeof(sp)); - sp.param = param; - sp.value = value; - - if ((ret=drmCommandWrite(disp->drmFD, DRM_RADEON_SETPARAM, &sp, sizeof(sp)))) { - fprintf(stderr,"Set param failed\n", ret); - return -1; - } - - return 0; -} - -static int -RADEONCheckDRMVersion(driDisplay *disp, RADEONInfoPtr info) -{ - drmVersionPtr version; - - version = drmGetVersion(disp->drmFD); - if (version) { - int req_minor, req_patch; - - /* Need 1.21.x for card type detection getparam - */ - req_minor = 21; - req_patch = 0; - - if (version->version_major != 1 || - version->version_minor < req_minor || - (version->version_minor == req_minor && - version->version_patchlevel < req_patch)) { - /* Incompatible drm version */ - fprintf(stderr, - "[dri] RADEONDRIScreenInit failed because of a version " - "mismatch.\n" - "[dri] radeon.o kernel module version is %d.%d.%d " - "but version 1.%d.%d or newer is needed.\n" - "[dri] Disabling DRI.\n", - version->version_major, - version->version_minor, - version->version_patchlevel, - req_minor, - req_patch); - drmFreeVersion(version); - return 0; - } - - info->drmMinor = version->version_minor; - drmFreeVersion(version); - } - - return 1; -} - - -/** - * \brief Compute base 2 logarithm. - * - * \param val value. - * - * \return base 2 logarithm of \p val. - */ -static int RADEONMinBits(int val) -{ - int bits; - - if (!val) return 1; - for (bits = 0; val; val >>= 1, ++bits); - return bits; -} - - -/* Initialize the PCI GART state. Request memory for use in PCI space, - * and initialize the Radeon registers to point to that memory. - */ -static int RADEONDRIPciInit(driDisplay *disp, RADEONInfoPtr info) -{ - int ret; - int flags = DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL; - int s, l; - - ret = drmScatterGatherAlloc(disp->drmFD, info->gartSize*1024*1024, - &info->gartMemHandle); - if (ret < 0) { - fprintf(stderr, "[pci] Out of memory (%d)\n", ret); - return 0; - } - fprintf(stderr, - "[pci] %d kB allocated with handle 0x%04lx\n", - info->gartSize*1024, (long) info->gartMemHandle); - - info->gartOffset = 0; - - /* Initialize the CP ring buffer data */ - info->ringStart = info->gartOffset; - info->ringMapSize = info->ringSize*1024*1024 + radeon_drm_page_size; - - info->ringReadOffset = info->ringStart + info->ringMapSize; - info->ringReadMapSize = radeon_drm_page_size; - - /* Reserve space for vertex/indirect buffers */ - info->bufStart = info->ringReadOffset + info->ringReadMapSize; - info->bufMapSize = info->bufSize*1024*1024; - - /* Reserve the rest for AGP textures */ - info->gartTexStart = info->bufStart + info->bufMapSize; - s = (info->gartSize*1024*1024 - info->gartTexStart); - l = RADEONMinBits((s-1) / RADEON_NR_TEX_REGIONS); - if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; - info->gartTexMapSize = (s >> l) << l; - info->log2GARTTexGran = l; - - if (drmAddMap(disp->drmFD, info->ringStart, info->ringMapSize, - DRM_SCATTER_GATHER, flags, &info->ringHandle) < 0) { - fprintf(stderr, - "[pci] Could not add ring mapping\n"); - return 0; - } - fprintf(stderr, - "[pci] ring handle = 0x%08lx\n", info->ringHandle); - - if (drmAddMap(disp->drmFD, info->ringReadOffset, info->ringReadMapSize, - DRM_SCATTER_GATHER, flags, &info->ringReadPtrHandle) < 0) { - fprintf(stderr, - "[pci] Could not add ring read ptr mapping\n"); - return 0; - } - fprintf(stderr, - "[pci] ring read ptr handle = 0x%08lx\n", - info->ringReadPtrHandle); - - if (drmAddMap(disp->drmFD, info->bufStart, info->bufMapSize, - DRM_SCATTER_GATHER, 0, &info->bufHandle) < 0) { - fprintf(stderr, - "[pci] Could not add vertex/indirect buffers mapping\n"); - return 0; - } - fprintf(stderr, - "[pci] vertex/indirect buffers handle = 0x%08lx\n", - info->bufHandle); - - if (drmAddMap(disp->drmFD, info->gartTexStart, info->gartTexMapSize, - DRM_SCATTER_GATHER, 0, &info->gartTexHandle) < 0) { - fprintf(stderr, - "[pci] Could not add GART texture map mapping\n"); - return 0; - } - fprintf(stderr, - "[pci] GART texture map handle = 0x%08lx\n", - info->gartTexHandle); - - return 1; -} - - -/** - * \brief Initialize the AGP state - * - * \param ctx display handle. - * \param info driver private data. - * - * \return one on success, or zero on failure. - * - * Acquires and enables the AGP device. Reserves memory in the AGP space for - * the ring buffer, vertex buffers and textures. Initialize the Radeon - * registers to point to that memory and add client mappings. - */ -static int RADEONDRIAgpInit( driDisplay *disp, RADEONInfoPtr info) -{ - int mode, ret; - int s, l; - int agpmode = 1; - - if (drmAgpAcquire(disp->drmFD) < 0) { - fprintf(stderr, "[gart] AGP not available\n"); - return 0; - } - - mode = drmAgpGetMode(disp->drmFD); /* Default mode */ - /* Disable fast write entirely - too many lockups. - */ - mode &= ~RADEON_AGP_MODE_MASK; - switch (agpmode) { - case 4: mode |= RADEON_AGP_4X_MODE; - case 2: mode |= RADEON_AGP_2X_MODE; - case 1: default: mode |= RADEON_AGP_1X_MODE; - } - - if (drmAgpEnable(disp->drmFD, mode) < 0) { - fprintf(stderr, "[gart] AGP not enabled\n"); - drmAgpRelease(disp->drmFD); - return 0; - } - -#if 0 - /* Workaround for some hardware bugs */ - if (info->ChipFamily < CHIP_FAMILY_R200) - OUTREG(RADEON_AGP_CNTL, INREG(RADEON_AGP_CNTL) | 0x000e0000); -#endif - info->gartOffset = 0; - - if ((ret = drmAgpAlloc(disp->drmFD, info->gartSize*1024*1024, 0, NULL, - &info->gartMemHandle)) < 0) { - fprintf(stderr, "[gart] Out of memory (%d)\n", ret); - drmAgpRelease(disp->drmFD); - return 0; - } - fprintf(stderr, - "[gart] %d kB allocated with handle 0x%08x\n", - info->gartSize*1024, (unsigned)info->gartMemHandle); - - if (drmAgpBind(disp->drmFD, - info->gartMemHandle, info->gartOffset) < 0) { - fprintf(stderr, "[gart] Could not bind\n"); - drmAgpFree(disp->drmFD, info->gartMemHandle); - drmAgpRelease(disp->drmFD); - return 0; - } - - /* Initialize the CP ring buffer data */ - info->ringStart = info->gartOffset; - info->ringMapSize = info->ringSize*1024*1024 + radeon_drm_page_size; - - info->ringReadOffset = info->ringStart + info->ringMapSize; - info->ringReadMapSize = radeon_drm_page_size; - - /* Reserve space for vertex/indirect buffers */ - info->bufStart = info->ringReadOffset + info->ringReadMapSize; - info->bufMapSize = info->bufSize*1024*1024; - - /* Reserve the rest for AGP textures */ - info->gartTexStart = info->bufStart + info->bufMapSize; - s = (info->gartSize*1024*1024 - info->gartTexStart); - l = RADEONMinBits((s-1) / RADEON_NR_TEX_REGIONS); - if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; - info->gartTexMapSize = (s >> l) << l; - info->log2GARTTexGran = l; - - if (drmAddMap(disp->drmFD, info->ringStart, info->ringMapSize, - DRM_AGP, DRM_READ_ONLY, &info->ringHandle) < 0) { - fprintf(stderr, "[gart] Could not add ring mapping\n"); - return 0; - } - fprintf(stderr, "[gart] ring handle = 0x%08lx\n", info->ringHandle); - - - if (drmAddMap(disp->drmFD, info->ringReadOffset, info->ringReadMapSize, - DRM_AGP, DRM_READ_ONLY, &info->ringReadPtrHandle) < 0) { - fprintf(stderr, - "[gart] Could not add ring read ptr mapping\n"); - return 0; - } - - fprintf(stderr, - "[gart] ring read ptr handle = 0x%08lx\n", - info->ringReadPtrHandle); - - if (drmAddMap(disp->drmFD, info->bufStart, info->bufMapSize, - DRM_AGP, 0, &info->bufHandle) < 0) { - fprintf(stderr, - "[gart] Could not add vertex/indirect buffers mapping\n"); - return 0; - } - fprintf(stderr, - "[gart] vertex/indirect buffers handle = 0x%08lx\n", - info->bufHandle); - - if (drmAddMap(disp->drmFD, info->gartTexStart, info->gartTexMapSize, - DRM_AGP, 0, &info->gartTexHandle) < 0) { - fprintf(stderr, - "[gart] Could not add AGP texture map mapping\n"); - return 0; - } - fprintf(stderr, - "[gart] AGP texture map handle = 0x%08lx\n", - info->gartTexHandle); - - return 1; -} - - -/** - * Initialize all the memory-related fields of the RADEONInfo object. - * This includes the various 'offset' and 'size' fields. - */ -static int -RADEONMemoryInit(driDisplay *disp, RADEONInfoPtr info) -{ - int width_bytes = disp->virtualWidth * disp->cpp; - int cpp = disp->cpp; - int bufferSize = ((disp->virtualHeight * width_bytes - + RADEON_BUFFER_ALIGN) - & ~RADEON_BUFFER_ALIGN); - int depthSize = ((((disp->virtualHeight+15) & ~15) * width_bytes - + RADEON_BUFFER_ALIGN) - & ~RADEON_BUFFER_ALIGN); - int l; - int pcie_gart_table_size = 0; - - info->frontOffset = 0; - info->frontPitch = disp->virtualWidth; - - if (disp->card_type==RADEON_CARD_PCIE) - pcie_gart_table_size = RADEON_PCIGART_TABLE_SIZE; - - /* Front, back and depth buffers - everything else texture?? - */ - info->textureSize = disp->fbSize - pcie_gart_table_size - 2 * bufferSize - depthSize; - - if (info->textureSize < 0) - return 0; - - l = RADEONMinBits((info->textureSize-1) / RADEON_NR_TEX_REGIONS); - if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; - - /* Round the texture size up to the nearest whole number of - * texture regions. Again, be greedy about this, don't - * round down. - */ - info->log2TexGran = l; - info->textureSize = (info->textureSize >> l) << l; - - /* Set a minimum usable local texture heap size. This will fit - * two 256x256x32bpp textures. - */ - if (info->textureSize < 512 * 1024) { - info->textureOffset = 0; - info->textureSize = 0; - } - - /* Reserve space for textures */ - info->textureOffset = ((disp->fbSize - pcie_gart_table_size - info->textureSize + - RADEON_BUFFER_ALIGN) & - ~RADEON_BUFFER_ALIGN); - - /* Reserve space for the shared depth - * buffer. - */ - info->depthOffset = ((info->textureOffset - depthSize + - RADEON_BUFFER_ALIGN) & - ~RADEON_BUFFER_ALIGN); - info->depthPitch = disp->virtualWidth; - - info->backOffset = ((info->depthOffset - bufferSize + - RADEON_BUFFER_ALIGN) & - ~RADEON_BUFFER_ALIGN); - info->backPitch = disp->virtualWidth; - - if (pcie_gart_table_size) - info->pcieGartTableOffset = disp->fbSize - pcie_gart_table_size; - - fprintf(stderr, - "Will use back buffer at offset 0x%x, pitch %d\n", - info->backOffset, info->backPitch); - fprintf(stderr, - "Will use depth buffer at offset 0x%x, pitch %d\n", - info->depthOffset, info->depthPitch); - fprintf(stderr, - "Will use %d kb for textures at offset 0x%x\n", - info->textureSize/1024, info->textureOffset); - if (pcie_gart_table_size) - { - fprintf(stderr, - "Will use %d kb for PCIE GART Table at offset 0x%x\n", - pcie_gart_table_size/1024, info->pcieGartTableOffset); - } - - /* XXX I don't think these are needed. */ -#if 0 - info->frontPitchOffset = (((info->frontPitch * cpp / 64) << 22) | - (info->frontOffset >> 10)); - - info->backPitchOffset = (((info->backPitch * cpp / 64) << 22) | - (info->backOffset >> 10)); - - info->depthPitchOffset = (((info->depthPitch * cpp / 64) << 22) | - (info->depthOffset >> 10)); -#endif - - if (pcie_gart_table_size) - RADEONSetParam(disp, RADEON_SETPARAM_PCIGART_LOCATION, info->pcieGartTableOffset); - - return 1; -} - - -/** - * \brief Initialize the kernel data structures and enable the CP engine. - * - * \param ctx display handle. - * \param info driver private data. - * - * \return non-zero on success, or zero on failure. - * - * This function is a wrapper around the DRM_RADEON_CP_INIT command, passing - * all the parameters in a drm_radeon_init_t structure. - */ -static int RADEONDRIKernelInit( driDisplay *disp, - RADEONInfoPtr info) -{ - int cpp = disp->bpp / 8; - drm_radeon_init_t drmInfo; - int ret; - - memset(&drmInfo, 0, sizeof(drmInfo)); - - if ( (info->ChipFamily >= CHIP_FAMILY_R300) ) - drmInfo.func = RADEON_INIT_R300_CP; - else if ( (info->ChipFamily == CHIP_FAMILY_R200) || - (info->ChipFamily == CHIP_FAMILY_RV250) || - (info->ChipFamily == CHIP_FAMILY_M9) || - (info->ChipFamily == CHIP_FAMILY_RV280) ) - drmInfo.func = RADEON_INIT_R200_CP; - else - drmInfo.func = RADEON_INIT_CP; - - /* This is the struct passed to the kernel module for its initialization */ - /* XXX problem here: - * The front/back/depth_offset/pitch fields may change depending upon - * which drawing surface we're using!!! They can't be set just once - * during initialization. - * Looks like we'll need a new ioctl to update these fields for drawing - * to other surfaces... - */ - drmInfo.sarea_priv_offset = sizeof(drm_sarea_t); - drmInfo.cp_mode = RADEON_DEFAULT_CP_BM_MODE; - drmInfo.gart_size = info->gartSize*1024*1024; - drmInfo.ring_size = info->ringSize*1024*1024; - drmInfo.usec_timeout = 1000; - drmInfo.fb_bpp = disp->bpp; - drmInfo.depth_bpp = disp->bpp; - drmInfo.front_offset = info->frontOffset; - drmInfo.front_pitch = info->frontPitch * cpp; - drmInfo.back_offset = info->backOffset; - drmInfo.back_pitch = info->backPitch * cpp; - drmInfo.depth_offset = info->depthOffset; - drmInfo.depth_pitch = info->depthPitch * cpp; - drmInfo.ring_offset = info->ringHandle; - drmInfo.ring_rptr_offset = info->ringReadPtrHandle; - drmInfo.buffers_offset = info->bufHandle; - drmInfo.gart_textures_offset = info->gartTexHandle; - - ret = drmCommandWrite(disp->drmFD, DRM_RADEON_CP_INIT, &drmInfo, - sizeof(drm_radeon_init_t)); - - return ret >= 0; -} - - -/** - * \brief Add a map for the vertex buffers that will be accessed by any - * DRI-based clients. - * - * \param ctx display handle. - * \param info driver private data. - * - * \return one on success, or zero on failure. - * - * Calls drmAddBufs() with the previously allocated vertex buffers. - */ -static int RADEONDRIBufInit( driDisplay *disp, RADEONInfoPtr info ) -{ - /* Initialize vertex buffers */ - info->bufNumBufs = drmAddBufs(disp->drmFD, - info->bufMapSize / RADEON_BUFFER_SIZE, - RADEON_BUFFER_SIZE, - (disp->card_type!=RADEON_CARD_AGP) ? DRM_SG_BUFFER : DRM_AGP_BUFFER, - info->bufStart); - - if (info->bufNumBufs <= 0) { - fprintf(stderr, - "[drm] Could not create vertex/indirect buffers list\n"); - return 0; - } - fprintf(stderr, - "[drm] Added %d %d byte vertex/indirect buffers\n", - info->bufNumBufs, RADEON_BUFFER_SIZE); - - return 1; -} - - -/** - * \brief Install an IRQ handler. - * - * \param disp display handle. - * \param info driver private data. - * - * Attempts to install an IRQ handler via drmCtlInstHandler(), falling back to - * IRQ-free operation on failure. - */ -static void RADEONDRIIrqInit(driDisplay *disp, RADEONInfoPtr info) -{ - if ((drmCtlInstHandler(disp->drmFD, 0)) != 0) - fprintf(stderr, "[drm] failure adding irq handler, " - "there is a device already using that irq\n" - "[drm] falling back to irq-free operation\n"); -} - - -/** - * \brief Initialize the AGP heap. - * - * \param disp display handle. - * \param info driver private data. - * - * This function is a wrapper around the DRM_RADEON_INIT_HEAP command, passing - * all the parameters in a drm_radeon_mem_init_heap structure. - */ -static void RADEONDRIAgpHeapInit(driDisplay *disp, - RADEONInfoPtr info) -{ - drm_radeon_mem_init_heap_t drmHeap; - - /* Start up the simple memory manager for gart space */ - drmHeap.region = RADEON_MEM_REGION_GART; - drmHeap.start = 0; - drmHeap.size = info->gartTexMapSize; - - if (drmCommandWrite(disp->drmFD, DRM_RADEON_INIT_HEAP, - &drmHeap, sizeof(drmHeap))) { - fprintf(stderr, - "[drm] Failed to initialized gart heap manager\n"); - } else { - fprintf(stderr, - "[drm] Initialized kernel gart heap manager, %d\n", - info->gartTexMapSize); - } -} - -static int RADEONGetCardType(driDisplay *disp, RADEONInfoPtr info) -{ - drm_radeon_getparam_t gp; - int ret; - - gp.param = RADEON_PARAM_CARD_TYPE; - gp.value = &disp->card_type; - - ret=drmCommandWriteRead(disp->drmFD, DRM_RADEON_GETPARAM, &gp, sizeof(gp)); - if (ret) { - fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_CARD_TYPE) : %d\n", ret); - return -1; - } - - return disp->card_type; -} - -/** - * Called at the start of each server generation. - * - * \param disp display handle. - * \param info driver private data. - * - * \return non-zero on success, or zero on failure. - * - * Performs static frame buffer allocation. Opens the DRM device and add maps - * to the SAREA, framebuffer and MMIO regions. Fills in \p info with more - * information. Creates a \e server context to grab the lock for the - * initialization ioctls and calls the other initilization functions in this - * file. Starts the CP engine via the DRM_RADEON_CP_START command. - * - * Setups a RADEONDRIRec structure to be passed to radeon_dri.so for its - * initialization. - */ -static int -RADEONScreenInit( driDisplay *disp, RADEONInfoPtr info, - RADEONDRIPtr pRADEONDRI) -{ - int i, err; - - /* XXX this probably isn't needed here */ - { - int width_bytes = (disp->virtualWidth * disp->cpp); - int maxy = disp->fbSize / width_bytes; - - if (maxy <= disp->virtualHeight * 3) { - _eglLog(_EGL_WARNING, - "Static buffer allocation failed -- " - "need at least %d kB video memory (have %d kB)\n", - (disp->virtualWidth * disp->virtualHeight * - disp->cpp * 3 + 1023) / 1024, - disp->fbSize / 1024); - return 0; - } - } - - /* Memory manager setup */ - if (!RADEONMemoryInit(disp, info)) { - return 0; - } - - /* Create a 'server' context so we can grab the lock for - * initialization ioctls. - */ - if ((err = drmCreateContext(disp->drmFD, &disp->serverContext)) != 0) { - _eglLog(_EGL_WARNING, "%s: drmCreateContext failed %d\n", - __FUNCTION__, err); - return 0; - } - - DRM_LOCK(disp->drmFD, disp->pSAREA, disp->serverContext, 0); - - /* Initialize the kernel data structures */ - if (!RADEONDRIKernelInit(disp, info)) { - _eglLog(_EGL_WARNING, "RADEONDRIKernelInit failed\n"); - DRM_UNLOCK(disp->drmFD, disp->pSAREA, disp->serverContext); - return 0; - } - - /* Initialize the vertex buffers list */ - if (!RADEONDRIBufInit(disp, info)) { - fprintf(stderr, "RADEONDRIBufInit failed\n"); - DRM_UNLOCK(disp->drmFD, disp->pSAREA, disp->serverContext); - return 0; - } - - /* Initialize IRQ */ - RADEONDRIIrqInit(disp, info); - - /* Initialize kernel gart memory manager */ - RADEONDRIAgpHeapInit(disp, info); - - /* Initialize the SAREA private data structure */ - { - drm_radeon_sarea_t *pSAREAPriv; - pSAREAPriv = (drm_radeon_sarea_t *)(((char*)disp->pSAREA) + - sizeof(drm_sarea_t)); - memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); - pSAREAPriv->pfState = info->page_flip_enable; - } - - for ( i = 0;; i++ ) { - drmMapType type; - drmMapFlags flags; - drm_handle_t handle, offset; - drmSize size; - int rc, mtrr; - - if ( ( rc = drmGetMap( disp->drmFD, i, &offset, &size, &type, &flags, &handle, &mtrr ) ) != 0 ) - break; - if ( type == DRM_REGISTERS ) { - pRADEONDRI->registerHandle = offset; - pRADEONDRI->registerSize = size; - break; - } - } - /* Quick hack to clear the front & back buffers. Could also use - * the clear ioctl to do this, but would need to setup hw state - * first. - */ - drimemsetio((char *)disp->pFB + info->frontOffset, - 0xEE, - info->frontPitch * disp->cpp * disp->virtualHeight ); - - drimemsetio((char *)disp->pFB + info->backOffset, - 0x30, - info->backPitch * disp->cpp * disp->virtualHeight ); - - - /* This is the struct passed to radeon_dri.so for its initialization */ - pRADEONDRI->deviceID = info->Chipset; - pRADEONDRI->width = disp->virtualWidth; - pRADEONDRI->height = disp->virtualHeight; - pRADEONDRI->depth = disp->bpp; /* XXX: depth */ - pRADEONDRI->bpp = disp->bpp; - pRADEONDRI->IsPCI = (disp->card_type != RADEON_CARD_AGP);; - pRADEONDRI->frontOffset = info->frontOffset; - pRADEONDRI->frontPitch = info->frontPitch; - pRADEONDRI->backOffset = info->backOffset; - pRADEONDRI->backPitch = info->backPitch; - pRADEONDRI->depthOffset = info->depthOffset; - pRADEONDRI->depthPitch = info->depthPitch; - pRADEONDRI->textureOffset = info->textureOffset; - pRADEONDRI->textureSize = info->textureSize; - pRADEONDRI->log2TexGran = info->log2TexGran; - pRADEONDRI->statusHandle = info->ringReadPtrHandle; - pRADEONDRI->statusSize = info->ringReadMapSize; - pRADEONDRI->gartTexHandle = info->gartTexHandle; - pRADEONDRI->gartTexMapSize = info->gartTexMapSize; - pRADEONDRI->log2GARTTexGran = info->log2GARTTexGran; - pRADEONDRI->gartTexOffset = info->gartTexStart; - pRADEONDRI->sarea_priv_offset = sizeof(drm_sarea_t); - - /* Don't release the lock now - let the VT switch handler do it. */ - - return 1; -} - - -/** - * \brief Get Radeon chip family from chipset number. - * - * \param info driver private data. - * - * \return non-zero on success, or zero on failure. - * - * Called by radeonInitFBDev() to set RADEONInfoRec::ChipFamily - * according to the value of RADEONInfoRec::Chipset. Fails if the - * chipset is unrecognized or not appropriate for this driver (i.e., not - * an r100 style radeon) - */ -static int get_chipfamily_from_chipset( RADEONInfoPtr info ) -{ - switch (info->Chipset) { - case PCI_CHIP_RADEON_LY: - case PCI_CHIP_RADEON_LZ: - info->ChipFamily = CHIP_FAMILY_M6; - break; - - case PCI_CHIP_RADEON_QY: - case PCI_CHIP_RADEON_QZ: - info->ChipFamily = CHIP_FAMILY_VE; - break; - - case PCI_CHIP_R200_QL: - case PCI_CHIP_R200_QN: - case PCI_CHIP_R200_QO: - case PCI_CHIP_R200_Ql: - case PCI_CHIP_R200_BB: - info->ChipFamily = CHIP_FAMILY_R200; - break; - - case PCI_CHIP_RV200_QW: /* RV200 desktop */ - case PCI_CHIP_RV200_QX: - info->ChipFamily = CHIP_FAMILY_RV200; - break; - - case PCI_CHIP_RADEON_LW: - case PCI_CHIP_RADEON_LX: - info->ChipFamily = CHIP_FAMILY_M7; - break; - - case PCI_CHIP_RV250_Id: - case PCI_CHIP_RV250_Ie: - case PCI_CHIP_RV250_If: - case PCI_CHIP_RV250_Ig: - info->ChipFamily = CHIP_FAMILY_RV250; - break; - - case PCI_CHIP_RV250_Ld: - case PCI_CHIP_RV250_Le: - case PCI_CHIP_RV250_Lf: - case PCI_CHIP_RV250_Lg: - info->ChipFamily = CHIP_FAMILY_M9; - break; - - case PCI_CHIP_RV280_Y_: - case PCI_CHIP_RV280_Ya: - case PCI_CHIP_RV280_Yb: - case PCI_CHIP_RV280_Yc: - info->ChipFamily = CHIP_FAMILY_RV280; - break; - - case PCI_CHIP_R300_ND: - case PCI_CHIP_R300_NE: - case PCI_CHIP_R300_NF: - case PCI_CHIP_R300_NG: - info->ChipFamily = CHIP_FAMILY_R300; - break; - - case PCI_CHIP_RV370_5460: - info->ChipFamily = CHIP_FAMILY_RV380; - break; - - default: - /* Original Radeon/7200 */ - info->ChipFamily = CHIP_FAMILY_RADEON; - } - - return 1; -} - - -/** - * \brief Initialize the framebuffer device mode - * - * \param disp display handle. - * - * \return one on success, or zero on failure. - * - * Fills in \p info with some default values and some information from \p disp - * and then calls RADEONScreenInit() for the screen initialization. - * - * Before exiting clears the framebuffer memory accessing it directly. - */ -static int radeonInitFBDev( driDisplay *disp, RADEONDRIPtr pRADEONDRI ) -{ - int err; - RADEONInfoPtr info = calloc(1, sizeof(*info)); - - disp->driverPrivate = (void *)info; - - info->gartFastWrite = RADEON_DEFAULT_AGP_FAST_WRITE; - info->gartSize = RADEON_DEFAULT_AGP_SIZE; - info->gartTexSize = RADEON_DEFAULT_AGP_TEX_SIZE; - info->bufSize = RADEON_DEFAULT_BUFFER_SIZE; - info->ringSize = RADEON_DEFAULT_RING_SIZE; - info->page_flip_enable = RADEON_DEFAULT_PAGE_FLIP; - - fprintf(stderr, - "Using %d MB AGP aperture\n", info->gartSize); - fprintf(stderr, - "Using %d MB for the ring buffer\n", info->ringSize); - fprintf(stderr, - "Using %d MB for vertex/indirect buffers\n", info->bufSize); - fprintf(stderr, - "Using %d MB for AGP textures\n", info->gartTexSize); - fprintf(stderr, - "page flipping %sabled\n", info->page_flip_enable?"en":"dis"); - - info->Chipset = disp->chipset; - - if (!get_chipfamily_from_chipset( info )) { - fprintf(stderr, "Unknown or non-radeon chipset -- cannot continue\n"); - fprintf(stderr, "==> Verify PCI BusID is correct in miniglx.conf\n"); - return 0; - } -#if 0 - if (info->ChipFamily >= CHIP_FAMILY_R300) { - fprintf(stderr, - "Direct rendering not yet supported on " - "Radeon 9700 and newer cards\n"); - return 0; - } -#endif - -#if 00 - /* don't seem to need this here */ - info->frontPitch = disp->virtualWidth; -#endif - - /* Check the radeon DRM version */ - if (!RADEONCheckDRMVersion(disp, info)) { - return 0; - } - - if (RADEONGetCardType(disp, info)<0) - return 0; - - if (disp->card_type!=RADEON_CARD_AGP) { - /* Initialize PCI */ - if (!RADEONDRIPciInit(disp, info)) - return 0; - } - else { - /* Initialize AGP */ - if (!RADEONDRIAgpInit(disp, info)) - return 0; - } - - if (!RADEONScreenInit( disp, info, pRADEONDRI)) - return 0; - - /* Initialize and start the CP if required */ - if ((err = drmCommandNone(disp->drmFD, DRM_RADEON_CP_START)) != 0) { - fprintf(stderr, "%s: CP start %d\n", __FUNCTION__, err); - return 0; - } - - return 1; -} - - -/** - * Create list of all supported surface configs, attach list to the display. - */ -static EGLBoolean -radeonFillInConfigs(_EGLDisplay *disp, unsigned pixel_bits, - unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer) -{ - _EGLConfig *configs; - _EGLConfig *c; - unsigned int i, num_configs; - unsigned int depth_buffer_factor; - unsigned int back_buffer_factor; - GLenum fb_format; - GLenum fb_type; - - /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy - * enough to add support. Basically, if a context is created with an - * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping - * will never be used. - */ - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ - }; - - uint8_t depth_bits_array[2]; - uint8_t stencil_bits_array[2]; - - depth_bits_array[0] = depth_bits; - depth_bits_array[1] = depth_bits; - - /* Just like with the accumulation buffer, always provide some modes - * with a stencil buffer. It will be a sw fallback, but some apps won't - * care about that. - */ - stencil_bits_array[0] = 0; - stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; - - depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1; - back_buffer_factor = (have_back_buffer) ? 2 : 1; - - num_configs = depth_buffer_factor * back_buffer_factor * 2; - - if (pixel_bits == 16) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } else { - fb_format = GL_RGBA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = calloc(sizeof(*configs), num_configs); - c = configs; - if (!_eglFillInConfigs(c, fb_format, fb_type, - depth_bits_array, stencil_bits_array, - depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - GLX_TRUE_COLOR)) { - fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__); - return EGL_FALSE; - } - - /* Mark the visual as slow if there are "fake" stencil bits. - */ - for (i = 0, c = configs; i < num_configs; i++, c++) { - int stencil = GET_CONFIG_ATTRIB(c, EGL_STENCIL_SIZE); - if ((stencil != 0) && (stencil != stencil_bits)) { - SET_CONFIG_ATTRIB(c, EGL_CONFIG_CAVEAT, EGL_SLOW_CONFIG); - } - } - - for (i = 0, c = configs; i < num_configs; i++, c++) - _eglAddConfig(disp, c); - - free(configs); - - return EGL_TRUE; -} - - -/** - * Show the given surface on the named screen. - * If surface is EGL_NO_SURFACE, disable the screen's output. - */ -static EGLBoolean -radeonShowScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, - EGLSurface surface, EGLModeMESA m) -{ - EGLBoolean b = _eglDRIShowScreenSurfaceMESA(drv, dpy, screen, surface, m); - return b; -} - - -/** - * Called via eglInitialize() by user. - */ -static EGLBoolean -radeonInitialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) -{ - __DRIframebuffer framebuffer; - driDisplay *display; - - /* one-time init */ - radeon_drm_page_size = getpagesize(); - - if (!_eglDRIInitialize(drv, dpy, major, minor)) - return EGL_FALSE; - - display = Lookup_driDisplay(dpy); - - framebuffer.dev_priv_size = sizeof(RADEONDRIRec); - framebuffer.dev_priv = malloc(sizeof(RADEONDRIRec)); - - /* XXX we shouldn't hard-code values here! */ - /* we won't know the screen surface size until the user calls - * eglCreateScreenSurfaceMESA(). - */ -#if 0 - display->virtualWidth = 1024; - display->virtualHeight = 768; -#else - display->virtualWidth = 1280; - display->virtualHeight = 1024; -#endif - display->bpp = 32; - display->cpp = 4; - - if (!_eglDRIGetDisplayInfo(display)) - return EGL_FALSE; - - framebuffer.base = display->pFB; - framebuffer.width = display->virtualWidth; - framebuffer.height = display->virtualHeight; - framebuffer.stride = display->virtualWidth; - framebuffer.size = display->fbSize; - radeonInitFBDev( display, framebuffer.dev_priv ); - - if (!_eglDRICreateDisplay(display, &framebuffer)) - return EGL_FALSE; - - if (!_eglDRICreateScreens(display)) - return EGL_FALSE; - - /* create a variety of both 32 and 16-bit configurations */ - radeonFillInConfigs(&display->Base, 32, 24, 8, GL_TRUE); - radeonFillInConfigs(&display->Base, 16, 16, 0, GL_TRUE); - - drv->Initialized = EGL_TRUE; - return EGL_TRUE; -} - - -/** - * The bootstrap function. Return a new radeonDriver object and - * plug in API functions. - */ -_EGLDriver * -_eglMain(_EGLDisplay *dpy) -{ - radeonDriver *radeon; - - radeon = (radeonDriver *) calloc(1, sizeof(*radeon)); - if (!radeon) { - return NULL; - } - - /* First fill in the dispatch table with defaults */ - _eglDRIInitDriverFallbacks(&radeon->Base); - - /* then plug in our radeon-specific functions */ - radeon->Base.API.Initialize = radeonInitialize; - radeon->Base.API.ShowScreenSurfaceMESA = radeonShowScreenSurfaceMESA; - - return &radeon->Base; -} -- cgit v1.2.3 From 52d7b2cedee44fbd9a0e6405b974c62898bed169 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 15:18:45 +0800 Subject: st/egl: Remove the egl state tracker. The egl_g3d state tracker has support for KMS, and the support is based on the egl state tracker. As egl_g3d provides more features, it should be better to keep only egl_g3d to unify the efforts. --- configs/linux-dri | 2 +- configs/linux-opengl-es | 5 +- configure.ac | 6 +- src/gallium/state_trackers/egl/Makefile | 19 -- src/gallium/state_trackers/egl/egl_context.c | 105 ------- src/gallium/state_trackers/egl/egl_surface.c | 443 --------------------------- src/gallium/state_trackers/egl/egl_tracker.c | 272 ---------------- src/gallium/state_trackers/egl/egl_tracker.h | 195 ------------ src/gallium/state_trackers/egl/egl_visual.c | 85 ----- src/gallium/winsys/drm/i965/egl/Makefile | 29 -- src/gallium/winsys/drm/intel/egl/Makefile | 38 --- src/gallium/winsys/drm/intel/egl/dummy.c | 1 - src/gallium/winsys/drm/radeon/egl/Makefile | 38 --- src/gallium/winsys/drm/radeon/egl/dummy.c | 1 - src/gallium/winsys/drm/vmware/egl/Makefile | 18 -- 15 files changed, 8 insertions(+), 1249 deletions(-) delete mode 100644 src/gallium/state_trackers/egl/Makefile delete mode 100644 src/gallium/state_trackers/egl/egl_context.c delete mode 100644 src/gallium/state_trackers/egl/egl_surface.c delete mode 100644 src/gallium/state_trackers/egl/egl_tracker.c delete mode 100644 src/gallium/state_trackers/egl/egl_tracker.h delete mode 100644 src/gallium/state_trackers/egl/egl_visual.c delete mode 100644 src/gallium/winsys/drm/i965/egl/Makefile delete mode 100644 src/gallium/winsys/drm/intel/egl/Makefile delete mode 100644 src/gallium/winsys/drm/intel/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/radeon/egl/Makefile delete mode 100644 src/gallium/winsys/drm/radeon/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/vmware/egl/Makefile (limited to 'configure.ac') diff --git a/configs/linux-dri b/configs/linux-dri index 95f77ade1dd..feb2bba3a00 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -61,7 +61,7 @@ DRIVER_DIRS = dri WINDOW_SYSTEM = dri GALLIUM_WINSYS_DIRS = drm GALLIUM_WINSYS_DRM_DIRS = vmware intel i965 -GALLIUM_STATE_TRACKERS_DIRS = egl +GALLIUM_STATE_TRACKERS_DIRS = egl_g3d DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \ savage sis tdfx unichrome ffb swrast diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es index 566cd758e3e..e0136587167 100644 --- a/configs/linux-opengl-es +++ b/configs/linux-opengl-es @@ -9,6 +9,9 @@ LIB_DIR = lib SRC_DIRS = egl glsl mesa/es gallium gallium/winsys PROGRAM_DIRS = es1/screen es1/xegl es2/xegl +# egl_g3d needs this +DEFINES += -DGLX_DIRECT_RENDERING + # no mesa or egl drivers DRIVER_DIRS = EGL_DRIVERS_DIRS = @@ -22,6 +25,6 @@ GALLIUM_STATE_TRACKERS_DIRS = es # build egl_i915.so GALLIUM_DRIVERS_DIRS += trace i915 -GALLIUM_STATE_TRACKERS_DIRS += egl +GALLIUM_STATE_TRACKERS_DIRS += egl_g3d GALLIUM_WINSYS_DIRS += drm GALLIUM_WINSYS_DRM_DIRS = intel diff --git a/configure.ac b/configure.ac index e5c2386320f..bb011abff26 100644 --- a/configure.ac +++ b/configure.ac @@ -1165,7 +1165,7 @@ yes) dri) GALLIUM_STATE_TRACKERS_DIRS="dri" if test "x$enable_egl" = xyes; then - GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl egl_g3d" + GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl_g3d" fi # Have only tested st/xorg on 1.6.0 servers PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0], @@ -1182,9 +1182,9 @@ yes) AC_MSG_ERROR([state tracker '$tracker' doesn't exist]) case "$tracker" in - egl) + egl_g3d) if test "x$enable_egl" != xyes; then - AC_MSG_ERROR([cannot build egl state tracker without EGL library]) + AC_MSG_ERROR([cannot build egl_g3d state tracker without EGL library]) fi ;; xorg) diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile deleted file mode 100644 index e825aa718b6..00000000000 --- a/src/gallium/state_trackers/egl/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -TOP = ../../../.. -include $(TOP)/configs/current - -LIBNAME = egldrm - -LIBRARY_INCLUDES = \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/auxiliary \ - -I$(TOP)/src/mesa/drivers/dri/common \ - -I$(TOP)/src/mesa \ - -I$(TOP)/include \ - -I$(TOP)/src/egl/main \ - $(shell pkg-config --cflags-only-I libdrm) - - -C_SOURCES = $(wildcard ./*.c) - - -include ../../Makefile.template diff --git a/src/gallium/state_trackers/egl/egl_context.c b/src/gallium/state_trackers/egl/egl_context.c deleted file mode 100644 index fee186c6010..00000000000 --- a/src/gallium/state_trackers/egl/egl_context.c +++ /dev/null @@ -1,105 +0,0 @@ - -#include "utils.h" -#include -#include -#include -#include "egl_tracker.h" - -#include "egllog.h" - - -#include "pipe/p_context.h" -#include "pipe/p_screen.h" - -#include "state_tracker/st_public.h" -#include "state_tracker/drm_api.h" - -#include "GL/internal/glcore.h" - -_EGLContext * -drm_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list) -{ - struct drm_device *dev = lookup_drm_device(dpy); - struct drm_context *ctx; - struct drm_context *share = NULL; - struct st_context *st_share = NULL; - int i; - __GLcontextModes *visual; - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs defined for now */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext"); - return EGL_NO_CONTEXT; - } - } - - ctx = (struct drm_context *) calloc(1, sizeof(struct drm_context)); - if (!ctx) - goto err_c; - - _eglInitContext(drv, &ctx->base, conf, attrib_list); - - ctx->pipe = dev->api->create_context(dev->api, dev->screen); - if (!ctx->pipe) - goto err_pipe; - - if (share) - st_share = share->st; - - visual = drm_visual_from_config(conf); - ctx->st = st_create_context(ctx->pipe, visual, st_share); - drm_visual_modes_destroy(visual); - - if (!ctx->st) - goto err_gl; - - return &ctx->base; - -err_gl: - ctx->pipe->destroy(ctx->pipe); -err_pipe: - free(ctx); -err_c: - return NULL; -} - -EGLBoolean -drm_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *context) -{ - struct drm_context *c = lookup_drm_context(context); - if (!_eglIsContextBound(&c->base)) { - st_destroy_context(c->st); - free(c); - } - return EGL_TRUE; -} - -EGLBoolean -drm_make_current(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *context) -{ - struct drm_surface *readSurf = lookup_drm_surface(read); - struct drm_surface *drawSurf = lookup_drm_surface(draw); - struct drm_context *ctx = lookup_drm_context(context); - EGLBoolean b; - - b = _eglMakeCurrent(drv, dpy, draw, read, context); - if (!b) - return EGL_FALSE; - - if (ctx) { - if (!drawSurf || !readSurf) - return EGL_FALSE; - - st_make_current(ctx->st, drawSurf->stfb, readSurf->stfb); - - /* st_resize_framebuffer needs a bound context to work */ - st_resize_framebuffer(drawSurf->stfb, drawSurf->w, drawSurf->h); - st_resize_framebuffer(readSurf->stfb, readSurf->w, readSurf->h); - } else { - st_make_current(NULL, NULL, NULL); - } - - return EGL_TRUE; -} diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c deleted file mode 100644 index d55aa51b82d..00000000000 --- a/src/gallium/state_trackers/egl/egl_surface.c +++ /dev/null @@ -1,443 +0,0 @@ - -#include -#include -#include -#include "egl_tracker.h" - -#include "egllog.h" - -#include "pipe/p_inlines.h" -#include "pipe/p_screen.h" -#include "pipe/p_context.h" - -#include "state_tracker/drm_api.h" - -#include "util/u_format.h" -#include "util/u_rect.h" - -/* - * Util functions - */ - -static drmModeModeInfoPtr -drm_find_mode(drmModeConnectorPtr connector, _EGLMode *mode) -{ - int i; - drmModeModeInfoPtr m = NULL; - - for (i = 0; i < connector->count_modes; i++) { - m = &connector->modes[i]; - if (m->hdisplay == mode->Width && m->vdisplay == mode->Height && m->vrefresh == mode->RefreshRate) - break; - m = &connector->modes[0]; /* if we can't find one, return first */ - } - - return m; -} - -static struct st_framebuffer * -drm_create_framebuffer(struct pipe_screen *screen, - const __GLcontextModes *visual, - unsigned width, - unsigned height, - void *priv) -{ - enum pipe_format color_format, depth_stencil_format; - boolean d_depth_bits_last; - boolean ds_depth_bits_last; - - d_depth_bits_last = - screen->is_format_supported(screen, PIPE_FORMAT_X8Z24_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - ds_depth_bits_last = - screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - - if (visual->redBits == 8) { - if (visual->alphaBits == 8) - color_format = PIPE_FORMAT_A8R8G8B8_UNORM; - else - color_format = PIPE_FORMAT_X8R8G8B8_UNORM; - } else { - color_format = PIPE_FORMAT_R5G6B5_UNORM; - } - - switch(visual->depthBits) { - default: - case 0: - depth_stencil_format = PIPE_FORMAT_NONE; - break; - case 16: - depth_stencil_format = PIPE_FORMAT_Z16_UNORM; - break; - case 24: - if (visual->stencilBits == 0) { - depth_stencil_format = (d_depth_bits_last) ? - PIPE_FORMAT_X8Z24_UNORM: - PIPE_FORMAT_Z24X8_UNORM; - } else { - depth_stencil_format = (ds_depth_bits_last) ? - PIPE_FORMAT_S8Z24_UNORM: - PIPE_FORMAT_Z24S8_UNORM; - } - break; - case 32: - depth_stencil_format = PIPE_FORMAT_Z32_UNORM; - break; - } - - return st_create_framebuffer(visual, - color_format, - depth_stencil_format, - depth_stencil_format, - width, - height, - priv); -} - -static void -drm_create_texture(_EGLDisplay *dpy, - struct drm_screen *scrn, - unsigned w, unsigned h) -{ - struct drm_device *dev = lookup_drm_device(dpy); - struct pipe_screen *screen = dev->screen; - struct pipe_surface *surface; - struct pipe_texture *texture; - struct pipe_texture templat; - struct pipe_buffer *buf = NULL; - unsigned pitch = 0; - - memset(&templat, 0, sizeof(templat)); - templat.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; - templat.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; - templat.target = PIPE_TEXTURE_2D; - templat.last_level = 0; - templat.depth0 = 1; - templat.format = PIPE_FORMAT_A8R8G8B8_UNORM; - templat.width0 = w; - templat.height0 = h; - - texture = screen->texture_create(dev->screen, - &templat); - - if (!texture) - goto err_tex; - - surface = screen->get_tex_surface(screen, - texture, - 0, - 0, - 0, - PIPE_BUFFER_USAGE_GPU_WRITE); - - if (!surface) - goto err_surf; - - scrn->tex = texture; - scrn->surface = surface; - scrn->front.width = w; - scrn->front.height = h; - scrn->front.pitch = pitch; - dev->api->local_handle_from_texture(dev->api, screen, texture, - &scrn->front.pitch, &scrn->front.handle); - if (0) - goto err_handle; - - return; - -err_handle: - pipe_surface_reference(&surface, NULL); -err_surf: - pipe_texture_reference(&texture, NULL); -err_tex: - pipe_buffer_reference(&buf, NULL); - return; -} - -/* - * Exported functions - */ - -void -drm_takedown_shown_screen(_EGLDisplay *dpy, struct drm_screen *screen) -{ - struct drm_device *dev = lookup_drm_device(dpy); - - screen->surf = NULL; - - drmModeSetCrtc( - dev->drmFD, - screen->crtcID, - 0, /* FD */ - 0, 0, - NULL, 0, /* List of output ids */ - NULL); - - drmModeRmFB(dev->drmFD, screen->fbID); - drmModeFreeFB(screen->fb); - screen->fb = NULL; - - pipe_surface_reference(&screen->surface, NULL); - pipe_texture_reference(&screen->tex, NULL); - - screen->shown = 0; -} - -/** - * Called by libEGL's eglCreateWindowSurface(). - */ -_EGLSurface * -drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativeWindowType window, const EGLint *attrib_list) -{ - return NULL; -} - - -/** - * Called by libEGL's eglCreatePixmapSurface(). - */ -_EGLSurface * -drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativePixmapType pixmap, const EGLint *attrib_list) -{ - return NULL; -} - - -/** - * Called by libEGL's eglCreatePbufferSurface(). - */ -_EGLSurface * -drm_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, - const EGLint *attrib_list) -{ - struct drm_device *dev = lookup_drm_device(dpy); - int i; - int width = -1; - int height = -1; - struct drm_surface *surf = NULL; - __GLcontextModes *visual; - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - case EGL_WIDTH: - width = attrib_list[++i]; - break; - case EGL_HEIGHT: - height = attrib_list[++i]; - break; - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreatePbufferSurface"); - return EGL_NO_SURFACE; - } - } - - if (width < 1 || height < 1) { - _eglError(EGL_BAD_ATTRIBUTE, "eglCreatePbufferSurface"); - return NULL; - } - - surf = (struct drm_surface *) calloc(1, sizeof(struct drm_surface)); - if (!surf) - goto err; - - if (!_eglInitSurface(drv, &surf->base, EGL_PBUFFER_BIT, conf, attrib_list)) - goto err_surf; - - surf->w = width; - surf->h = height; - - visual = drm_visual_from_config(conf); - surf->stfb = drm_create_framebuffer(dev->screen, visual, - width, height, - (void*)surf); - drm_visual_modes_destroy(visual); - - return &surf->base; - -err_surf: - free(surf); -err: - return NULL; -} - -/** - * Called by libEGL's eglCreateScreenSurfaceMESA(). - */ -_EGLSurface * -drm_create_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *cfg, - const EGLint *attrib_list) -{ - EGLSurface surf = drm_create_pbuffer_surface(drv, dpy, cfg, attrib_list); - - return surf; -} - -/** - * Called by libEGL's eglShowScreenSurfaceMESA(). - */ -EGLBoolean -drm_show_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLScreen *screen, - _EGLSurface *surface, _EGLMode *mode) -{ - struct drm_device *dev = lookup_drm_device(dpy); - struct drm_surface *surf = lookup_drm_surface(surface); - struct drm_screen *scrn = lookup_drm_screen(screen); - int ret; - unsigned int i, k; - - if (scrn->shown) - drm_takedown_shown_screen(dpy, scrn); - - - drm_create_texture(dpy, scrn, mode->Width, mode->Height); - if (!scrn->tex) - goto err_tex; - - ret = drmModeAddFB(dev->drmFD, - scrn->front.width, scrn->front.height, - 32, 32, scrn->front.pitch, - scrn->front.handle, - &scrn->fbID); - - if (ret) - goto err_bo; - - scrn->fb = drmModeGetFB(dev->drmFD, scrn->fbID); - if (!scrn->fb) - goto err_bo; - - /* find a fitting crtc */ - { - drmModeConnector *con = scrn->connector; - - scrn->mode = drm_find_mode(con, mode); - if (!scrn->mode) - goto err_fb; - - for (k = 0; k < con->count_encoders; k++) { - drmModeEncoder *enc = drmModeGetEncoder(dev->drmFD, con->encoders[k]); - for (i = 0; i < dev->res->count_crtcs; i++) { - if (enc->possible_crtcs & (1<crtcID = dev->res->crtcs[i]; - - /* skip the rest */ - i = dev->res->count_crtcs; - k = dev->res->count_encoders; - } - } - drmModeFreeEncoder(enc); - } - } - - ret = drmModeSetCrtc(dev->drmFD, - scrn->crtcID, - scrn->fbID, - 0, 0, - &scrn->connectorID, 1, - scrn->mode); - - if (ret) - goto err_crtc; - - - if (scrn->dpms) - drmModeConnectorSetProperty(dev->drmFD, - scrn->connectorID, - scrn->dpms->prop_id, - DRM_MODE_DPMS_ON); - - surf->screen = scrn; - - scrn->surf = surf; - scrn->shown = 1; - - return EGL_TRUE; - -err_crtc: - scrn->crtcID = 0; - -err_fb: - drmModeRmFB(dev->drmFD, scrn->fbID); - drmModeFreeFB(scrn->fb); - scrn->fb = NULL; - -err_bo: - pipe_surface_reference(&scrn->surface, NULL); - pipe_texture_reference(&scrn->tex, NULL); - -err_tex: - return EGL_FALSE; -} - -/** - * Called by libEGL's eglDestroySurface(). - */ -EGLBoolean -drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface) -{ - struct drm_surface *surf = lookup_drm_surface(surface); - if (!_eglIsSurfaceBound(&surf->base)) { - if (surf->screen) - drm_takedown_shown_screen(dpy, surf->screen); - st_unreference_framebuffer(surf->stfb); - free(surf); - } - return EGL_TRUE; -} - -/** - * Called by libEGL's eglSwapBuffers(). - */ -EGLBoolean -drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw) -{ - struct drm_device *dev = lookup_drm_device(dpy); - struct drm_surface *surf = lookup_drm_surface(draw); - struct pipe_surface *back_surf; - - if (!surf) - return EGL_FALSE; - - st_get_framebuffer_surface(surf->stfb, ST_SURFACE_BACK_LEFT, &back_surf); - - if (back_surf) { - struct drm_context *ctx = lookup_drm_context(draw->Binding); - - st_notify_swapbuffers(surf->stfb); - - if (ctx && surf->screen) { - if (ctx->pipe->surface_copy) { - ctx->pipe->surface_copy(ctx->pipe, - surf->screen->surface, - 0, 0, - back_surf, - 0, 0, - surf->w, surf->h); - } else { - util_surface_copy(ctx->pipe, FALSE, - surf->screen->surface, - 0, 0, - back_surf, - 0, 0, - surf->w, surf->h); - } - ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL); - -#ifdef DRM_MODE_FEATURE_DIRTYFB - /* TODO query connector property to see if this is needed */ - drmModeDirtyFB(dev->drmFD, surf->screen->fbID, NULL, 0); -#else - (void)dev; -#endif - - /* TODO more stuff here */ - } - } - - return EGL_TRUE; -} diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c deleted file mode 100644 index 11583ec41c9..00000000000 --- a/src/gallium/state_trackers/egl/egl_tracker.c +++ /dev/null @@ -1,272 +0,0 @@ - -#include "utils.h" - -#include -#include -#include -#include "egl_tracker.h" - -#include - -#include "egllog.h" -#include "state_tracker/drm_api.h" - -#include "pipe/p_screen.h" -#include "pipe/internal/p_winsys_screen.h" - -/** HACK */ -void* driDriverAPI; - - -/* - * Exported functions - */ - -/** Called by libEGL just prior to unloading/closing the driver. - */ -static void -drm_unload(_EGLDriver *drv) -{ - free(drv); -} - -/** - * The bootstrap function. Return a new drm_driver object and - * plug in API functions. - * libEGL finds this function with dlopen()/dlsym() and calls it from - * "load driver" function. - */ -_EGLDriver * -_eglMain(const char *args) -{ - _EGLDriver *drv; - - drv = (_EGLDriver *) calloc(1, sizeof(_EGLDriver)); - if (!drv) { - return NULL; - } - - /* First fill in the dispatch table with defaults */ - _eglInitDriverFallbacks(drv); - /* then plug in our Drm-specific functions */ - drv->API.Initialize = drm_initialize; - drv->API.Terminate = drm_terminate; - drv->API.CreateContext = drm_create_context; - drv->API.MakeCurrent = drm_make_current; - drv->API.CreateWindowSurface = drm_create_window_surface; - drv->API.CreatePixmapSurface = drm_create_pixmap_surface; - drv->API.CreatePbufferSurface = drm_create_pbuffer_surface; - drv->API.DestroySurface = drm_destroy_surface; - drv->API.DestroyContext = drm_destroy_context; - drv->API.CreateScreenSurfaceMESA = drm_create_screen_surface_mesa; - drv->API.ShowScreenSurfaceMESA = drm_show_screen_surface_mesa; - drv->API.SwapBuffers = drm_swap_buffers; - - drv->Name = "DRM/Gallium/Win"; - drv->Unload = drm_unload; - - return drv; -} - -static void -drm_get_device_id(struct drm_device *device) -{ - char path[512]; - FILE *file; - char *ret; - - /* TODO get the real minor */ - int minor = 0; - - device->deviceID = 0; - - snprintf(path, sizeof(path), "/sys/class/drm/card%d/device/device", minor); - file = fopen(path, "r"); - if (!file) { - _eglLog(_EGL_WARNING, "Could not retrive device ID\n"); - return; - } - - ret = fgets(path, sizeof( path ), file); - fclose(file); - if (!ret) - return; - - sscanf(path, "%x", &device->deviceID); -} - -static void -drm_update_res(struct drm_device *dev) -{ - drmModeFreeResources(dev->res); - dev->res = drmModeGetResources(dev->drmFD); -} - -static void -drm_add_modes_from_connector(_EGLScreen *screen, drmModeConnectorPtr connector) -{ - drmModeModeInfoPtr m = NULL; - int i; - - for (i = 0; i < connector->count_modes; i++) { - m = &connector->modes[i]; - _eglAddNewMode(screen, m->hdisplay, m->vdisplay, m->vrefresh, m->name); - } -} - -static void -drm_find_dpms(struct drm_device *dev, struct drm_screen *screen) -{ - drmModeConnectorPtr c = screen->connector; - drmModePropertyPtr p; - int i; - - for (i = 0; i < c->count_props; i++) { - p = drmModeGetProperty(dev->drmFD, c->props[i]); - if (!strcmp(p->name, "DPMS")) - break; - - drmModeFreeProperty(p); - p = NULL; - } - - screen->dpms = p; -} - -static int drm_open_minor(int minor) -{ - char buf[64]; - - sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor); - return open(buf, O_RDWR, 0); -} - -EGLBoolean -drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor) -{ - struct drm_device *dev; - struct drm_screen *screen = NULL; - drmModeConnectorPtr connector = NULL; - drmModeResPtr res = NULL; - unsigned count_connectors = 0; - int num_screens = 0; - EGLint i; - int fd; - _EGLConfig *config; - - dev = (struct drm_device *) calloc(1, sizeof(struct drm_device)); - if (!dev) - return EGL_FALSE; - dev->api = drm_api_create(); - - /* try the first node */ - fd = drm_open_minor(0); - if (fd < 0) - goto err_fd; - - dev->drmFD = fd; - drm_get_device_id(dev); - - dev->screen = dev->api->create_screen(dev->api, dev->drmFD, NULL); - if (!dev->screen) - goto err_screen; - dev->winsys = dev->screen->winsys; - - drm_update_res(dev); - res = dev->res; - if (res) - count_connectors = res->count_connectors; - else - _eglLog(_EGL_WARNING, "Could not retrive kms information\n"); - - for(i = 0; i < count_connectors && i < MAX_SCREENS; i++) { - connector = drmModeGetConnector(fd, res->connectors[i]); - - if (!connector) - continue; - - if (connector->connection != DRM_MODE_CONNECTED) { - drmModeFreeConnector(connector); - continue; - } - - screen = malloc(sizeof(struct drm_screen)); - memset(screen, 0, sizeof(*screen)); - screen->connector = connector; - screen->connectorID = connector->connector_id; - _eglInitScreen(&screen->base); - _eglAddScreen(disp, &screen->base); - drm_add_modes_from_connector(&screen->base, connector); - drm_find_dpms(dev, screen); - dev->screens[num_screens++] = screen; - } - dev->count_screens = num_screens; - - disp->DriverData = dev; - - /* for now we only have one config */ - config = calloc(1, sizeof(*config)); - memset(config, 1, sizeof(*config)); - _eglInitConfig(config, 1); - _eglSetConfigAttrib(config, EGL_RED_SIZE, 8); - _eglSetConfigAttrib(config, EGL_GREEN_SIZE, 8); - _eglSetConfigAttrib(config, EGL_BLUE_SIZE, 8); - _eglSetConfigAttrib(config, EGL_ALPHA_SIZE, 8); - _eglSetConfigAttrib(config, EGL_BUFFER_SIZE, 32); - _eglSetConfigAttrib(config, EGL_DEPTH_SIZE, 24); - _eglSetConfigAttrib(config, EGL_STENCIL_SIZE, 8); - _eglSetConfigAttrib(config, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT); - _eglAddConfig(disp, config); - - disp->ClientAPIsMask = EGL_OPENGL_BIT /*| EGL_OPENGL_ES_BIT*/; - /* enable supported extensions */ - disp->Extensions.MESA_screen_surface = EGL_TRUE; - disp->Extensions.MESA_copy_context = EGL_TRUE; - - *major = 1; - *minor = 4; - - return EGL_TRUE; - -err_screen: - drmClose(fd); -err_fd: - free(dev); - return EGL_FALSE; -} - -EGLBoolean -drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct drm_device *dev = lookup_drm_device(dpy); - struct drm_screen *screen; - int i = 0; - - _eglReleaseDisplayResources(drv, dpy); - _eglCleanupDisplay(dpy); - - drmFreeVersion(dev->version); - - for (i = 0; i < dev->count_screens; i++) { - screen = dev->screens[i]; - - if (screen->shown) - drm_takedown_shown_screen(dpy, screen); - - drmModeFreeProperty(screen->dpms); - drmModeFreeConnector(screen->connector); - _eglDestroyScreen(&screen->base); - dev->screens[i] = NULL; - } - - dev->screen->destroy(dev->screen); - dev->winsys = NULL; - - drmClose(dev->drmFD); - - dev->api->destroy(dev->api); - free(dev); - dpy->DriverData = NULL; - - return EGL_TRUE; -} diff --git a/src/gallium/state_trackers/egl/egl_tracker.h b/src/gallium/state_trackers/egl/egl_tracker.h deleted file mode 100644 index 73eb1a1226e..00000000000 --- a/src/gallium/state_trackers/egl/egl_tracker.h +++ /dev/null @@ -1,195 +0,0 @@ - -#ifndef _EGL_TRACKER_H_ -#define _EGL_TRACKER_H_ - -#include - -#include "eglconfig.h" -#include "eglcontext.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "eglglobals.h" -#include "eglmode.h" -#include "eglscreen.h" -#include "eglsurface.h" - -#include "xf86drm.h" -#include "xf86drmMode.h" - -#include "pipe/p_compiler.h" - -#include "state_tracker/st_public.h" - -#define MAX_SCREENS 16 - -struct pipe_winsys; -struct pipe_screen; -struct pipe_context; -struct state_tracker; - -struct drm_screen; -struct drm_context; - -struct drm_device -{ - /* - * pipe - */ - - struct drm_api *api; - struct pipe_winsys *winsys; - struct pipe_screen *screen; - - /* - * drm - */ - - int drmFD; - drmVersionPtr version; - int deviceID; - - drmModeResPtr res; - - struct drm_screen *screens[MAX_SCREENS]; - size_t count_screens; -}; - -struct drm_surface -{ - _EGLSurface base; /* base class/object */ - - /* - * pipe - */ - - - struct st_framebuffer *stfb; - - /* - * drm - */ - - struct drm_screen *screen; - - int w; - int h; -}; - -struct drm_context -{ - _EGLContext base; /* base class/object */ - - /* pipe */ - - struct pipe_context *pipe; - struct st_context *st; -}; - -struct drm_screen -{ - _EGLScreen base; - - /* - * pipe - */ - - struct pipe_texture *tex; - struct pipe_surface *surface; - - /* - * drm - */ - - struct { - unsigned height; - unsigned width; - unsigned pitch; - unsigned handle; - } front; - - /* currently only support one connector */ - drmModeConnectorPtr connector; - uint32_t connectorID; - - /* dpms property */ - drmModePropertyPtr dpms; - - /* Has this screen been shown */ - int shown; - - /* Surface that is currently attached to this screen */ - struct drm_surface *surf; - - /* framebuffer */ - drmModeFBPtr fb; - uint32_t fbID; - - /* crtc and mode used */ - /*drmModeCrtcPtr crtc;*/ - uint32_t crtcID; - - drmModeModeInfoPtr mode; -}; - - -static INLINE struct drm_device * -lookup_drm_device(_EGLDisplay *d) -{ - return (struct drm_device *) d->DriverData; -} - - -static INLINE struct drm_context * -lookup_drm_context(_EGLContext *c) -{ - return (struct drm_context *) c; -} - - -static INLINE struct drm_surface * -lookup_drm_surface(_EGLSurface *s) -{ - return (struct drm_surface *) s; -} - -static INLINE struct drm_screen * -lookup_drm_screen(_EGLScreen *s) -{ - return (struct drm_screen *) s; -} - -/** - * egl_visual.h - */ -/*@{*/ -void drm_visual_modes_destroy(__GLcontextModes *modes); -__GLcontextModes* drm_visual_modes_create(unsigned count, size_t minimum_size); -__GLcontextModes* drm_visual_from_config(_EGLConfig *conf); -/*@}*/ - -/** - * egl_surface.h - */ -/*@{*/ -void drm_takedown_shown_screen(_EGLDisplay *dpy, struct drm_screen *screen); -/*@}*/ - -/** - * All function exported to the egl side. - */ -/*@{*/ -EGLBoolean drm_initialize(_EGLDriver *drv, _EGLDisplay *dpy, EGLint *major, EGLint *minor); -EGLBoolean drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy); -_EGLContext *drm_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list); -EGLBoolean drm_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *context); -_EGLSurface *drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativeWindowType window, const EGLint *attrib_list); -_EGLSurface *drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativePixmapType pixmap, const EGLint *attrib_list); -_EGLSurface *drm_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list); -_EGLSurface *drm_create_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list); -EGLBoolean drm_show_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, _EGLSurface *surface, _EGLMode *mode); -EGLBoolean drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface); -EGLBoolean drm_make_current(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *context); -EGLBoolean drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw); -/*@}*/ - -#endif diff --git a/src/gallium/state_trackers/egl/egl_visual.c b/src/gallium/state_trackers/egl/egl_visual.c deleted file mode 100644 index e59f893851e..00000000000 --- a/src/gallium/state_trackers/egl/egl_visual.c +++ /dev/null @@ -1,85 +0,0 @@ - -#include "egl_tracker.h" - -#include "egllog.h" - -void -drm_visual_modes_destroy(__GLcontextModes *modes) -{ - _eglLog(_EGL_DEBUG, "%s", __FUNCTION__); - - while (modes) { - __GLcontextModes * const next = modes->next; - free(modes); - modes = next; - } -} - -__GLcontextModes * -drm_visual_modes_create(unsigned count, size_t minimum_size) -{ - /* This code copied from libGLX, and modified */ - const size_t size = (minimum_size > sizeof(__GLcontextModes)) - ? minimum_size : sizeof(__GLcontextModes); - __GLcontextModes * head = NULL; - __GLcontextModes ** next; - unsigned i; - - _eglLog(_EGL_DEBUG, "%s %d %d", __FUNCTION__, count, minimum_size); - - next = & head; - for (i = 0 ; i < count ; i++) { - *next = (__GLcontextModes *) calloc(1, size); - if (*next == NULL) { - drm_visual_modes_destroy(head); - head = NULL; - break; - } - - (*next)->doubleBufferMode = 1; - (*next)->visualID = GLX_DONT_CARE; - (*next)->visualType = GLX_DONT_CARE; - (*next)->visualRating = GLX_NONE; - (*next)->transparentPixel = GLX_NONE; - (*next)->transparentRed = GLX_DONT_CARE; - (*next)->transparentGreen = GLX_DONT_CARE; - (*next)->transparentBlue = GLX_DONT_CARE; - (*next)->transparentAlpha = GLX_DONT_CARE; - (*next)->transparentIndex = GLX_DONT_CARE; - (*next)->xRenderable = GLX_DONT_CARE; - (*next)->fbconfigID = GLX_DONT_CARE; - (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML; - (*next)->bindToTextureRgb = GLX_DONT_CARE; - (*next)->bindToTextureRgba = GLX_DONT_CARE; - (*next)->bindToMipmapTexture = GLX_DONT_CARE; - (*next)->bindToTextureTargets = 0; - (*next)->yInverted = GLX_DONT_CARE; - - next = & ((*next)->next); - } - - return head; -} - -__GLcontextModes * -drm_visual_from_config(_EGLConfig *conf) -{ - __GLcontextModes *visual; - (void)conf; - - visual = drm_visual_modes_create(1, sizeof(*visual)); - visual->redBits = 8; - visual->greenBits = 8; - visual->blueBits = 8; - visual->alphaBits = 8; - - visual->rgbBits = 32; - visual->doubleBufferMode = 1; - - visual->depthBits = 24; - visual->haveDepthBuffer = visual->depthBits > 0; - visual->stencilBits = 8; - visual->haveStencilBuffer = visual->stencilBits > 0; - - return visual; -} diff --git a/src/gallium/winsys/drm/i965/egl/Makefile b/src/gallium/winsys/drm/i965/egl/Makefile deleted file mode 100644 index a1b32eb2a79..00000000000 --- a/src/gallium/winsys/drm/i965/egl/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -TOP = ../../../../../.. -GALLIUMDIR = ../../../.. -include $(TOP)/configs/current - -LIBNAME = EGL_i965.so - -PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ - $(GALLIUMDIR)/winsys/drm/i965/gem/libi965drm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/i965/libi965.a - -DRIVER_SOURCES = - -C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) \ - $(DRIVER_SOURCES) - -DRIVER_EXTRAS = -ldrm_intel - -ASM_SOURCES = - -DRIVER_DEFINES = -I../gem $(shell pkg-config libdrm --atleast-version=2.3.1 \ - && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP") - -include ../../Makefile.template - -symlinks: diff --git a/src/gallium/winsys/drm/intel/egl/Makefile b/src/gallium/winsys/drm/intel/egl/Makefile deleted file mode 100644 index c9c92b69b65..00000000000 --- a/src/gallium/winsys/drm/intel/egl/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -TOP = ../../../../../.. -GALLIUMDIR = ../../../.. -include $(TOP)/configs/current - -LIBNAME = egl_i915.so - -PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ - $(GALLIUMDIR)/winsys/drm/intel/gem/libinteldrm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/i915/libi915.a - -DRIVER_EXTRAS = -lm -lpthread -ldrm_intel - -OBJECTS = dummy.o - -default: $(TOP)/$(LIB_DIR)/$(LIBNAME) - -$(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) - @mkdir -p $(TOP)/$(LIB_DIR) - $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR) - -$(LIBNAME): $(OBJECTS) $(GALLIUM_AUXILIARIES) $(PIPE_DRIVERS) Makefile - $(MKLIB) -noprefix -o $@ $(OBJECTS) \ - -Wl,--whole-archive $(PIPE_DRIVERS) -Wl,--no-whole-archive \ - -Wl,--start-group $(GALLIUM_AUXILIARIES) -Wl,--end-group \ - $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) - -clean: - -rm -f *.o *.so *~ - -depend: - -symlinks: - -install: $(LIBNAME) - $(MINSTALL) -m 755 $(LIBNAME) $(INSTALL_DIR)/$(LIB_DIR) diff --git a/src/gallium/winsys/drm/intel/egl/dummy.c b/src/gallium/winsys/drm/intel/egl/dummy.c deleted file mode 100644 index 58c7af84e0a..00000000000 --- a/src/gallium/winsys/drm/intel/egl/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one .o is given */ diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile deleted file mode 100644 index fcbfd097865..00000000000 --- a/src/gallium/winsys/drm/radeon/egl/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -TOP = ../../../../../.. -GALLIUMDIR = ../../../.. -include $(TOP)/configs/current - -LIBNAME = egl_radeon.so - -PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ - $(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/r300/libr300.a - -DRIVER_EXTRAS = -lm -lpthread -ldrm_radeon - -OBJECTS = dummy.o - -default: $(TOP)/$(LIB_DIR)/$(LIBNAME) - -$(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) - @mkdir -p $(TOP)/$(LIB_DIR) - $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR) - -$(LIBNAME): $(OBJECTS) $(GALLIUM_AUXILIARIES) $(PIPE_DRIVERS) Makefile - $(MKLIB) -noprefix -o $@ $(OBJECTS) \ - -Wl,--whole-archive $(PIPE_DRIVERS) -Wl,--no-whole-archive \ - -Wl,--start-group $(GALLIUM_AUXILIARIES) -Wl,--end-group \ - $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) - -clean: - -rm -f *.o *.so *~ - -depend: - -symlinks: - -install: $(LIBNAME) - $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) diff --git a/src/gallium/winsys/drm/radeon/egl/dummy.c b/src/gallium/winsys/drm/radeon/egl/dummy.c deleted file mode 100644 index 58c7af84e0a..00000000000 --- a/src/gallium/winsys/drm/radeon/egl/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one .o is given */ diff --git a/src/gallium/winsys/drm/vmware/egl/Makefile b/src/gallium/winsys/drm/vmware/egl/Makefile deleted file mode 100644 index 8e2980c318c..00000000000 --- a/src/gallium/winsys/drm/vmware/egl/Makefile +++ /dev/null @@ -1,18 +0,0 @@ - -TOP = ../../../../../.. -include $(TOP)/configs/current - -LIBNAME = EGL_svga.so - -PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ - $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/svga/libsvga.a - -C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) - -include ../../Makefile.template - -symlinks: -- cgit v1.2.3 From a1306f4ef6f83a86d03720641f3cdc5e13485fa6 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 15:51:51 +0800 Subject: winsys/drm: Add swrast. The swrast winsys always returns NULL when drm_api_create is called. --- configs/default | 4 ++-- configure.ac | 12 ++++++++++++ docs/egl.html | 10 ++++++++++ src/gallium/winsys/drm/swrast/Makefile | 12 ++++++++++++ src/gallium/winsys/drm/swrast/core/Makefile | 10 ++++++++++ src/gallium/winsys/drm/swrast/core/swrast_drm_api.c | 13 +++++++++++++ src/gallium/winsys/drm/swrast/egl_g3d/Makefile | 12 ++++++++++++ src/gallium/winsys/drm/swrast/egl_g3d/dummy.c | 1 + 8 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/gallium/winsys/drm/swrast/Makefile create mode 100644 src/gallium/winsys/drm/swrast/core/Makefile create mode 100644 src/gallium/winsys/drm/swrast/core/swrast_drm_api.c create mode 100644 src/gallium/winsys/drm/swrast/egl_g3d/Makefile create mode 100644 src/gallium/winsys/drm/swrast/egl_g3d/dummy.c (limited to 'configure.ac') diff --git a/configs/default b/configs/default index 6863495be3e..2665f5296a6 100644 --- a/configs/default +++ b/configs/default @@ -100,8 +100,8 @@ GALLIUM_DIRS = auxiliary drivers state_trackers GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) -GALLIUM_WINSYS_DIRS = xlib egl_xlib -GALLIUM_WINSYS_DRM_DIRS = +GALLIUM_WINSYS_DIRS = drm xlib egl_xlib +GALLIUM_WINSYS_DRM_DIRS = swrast GALLIUM_STATE_TRACKERS_DIRS = glx # native displays EGL should support diff --git a/configure.ac b/configure.ac index bb011abff26..d6e32f590aa 100644 --- a/configure.ac +++ b/configure.ac @@ -1311,6 +1311,18 @@ if test "x$enable_gallium_nouveau" = xyes; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nv04 nv10 nv20 nv30 nv40 nv50" fi +dnl +dnl Gallium swrast configuration +dnl +AC_ARG_ENABLE([gallium-swrast], + [AS_HELP_STRING([--enable-gallium-swrast], + [build gallium swrast @<:@default=disabled@:>@])], + [enable_gallium_swrast="$enableval"], + [enable_gallium_swrast=auto]) +if test "x$enable_gallium_swrast" = xyes; then + GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS swrast" +fi + dnl prepend CORE_DIRS to SRC_DIRS SRC_DIRS="$CORE_DIRS $SRC_DIRS" diff --git a/docs/egl.html b/docs/egl.html index 5561d1a4b86..efc7b1ed3aa 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -81,6 +81,15 @@ that a number of EGL drivers depend on the egl_g3d state tracker. They will not be built without the egl_g3d state tracker.

+ + +
  • --enable-gallium-swrast + +

    This option is not specific to EGL. But if there is no driver for your +hardware, or you are experiencing problems with the hardware driver, you can +enable the swrast DRM driver. It is a dummy driver and EGL will fallback to +software rendering automatically.

    +
  • @@ -159,6 +168,7 @@ tracker to build. The available drivers are

  • egl_<dpy>_i965
  • egl_<dpy>_radeon
  • egl_<dpy>_nouveau
  • +
  • egl_<dpy>_swrast
  • egl_<dpy>_vmwgfx
  • diff --git a/src/gallium/winsys/drm/swrast/Makefile b/src/gallium/winsys/drm/swrast/Makefile new file mode 100644 index 00000000000..363b89584f2 --- /dev/null +++ b/src/gallium/winsys/drm/swrast/Makefile @@ -0,0 +1,12 @@ +# src/gallium/winsys/drm/swrast/Makefile +TOP = ../../../../.. +include $(TOP)/configs/current + +SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS) + +default install clean: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE) $@) || exit 1; \ + fi \ + done diff --git a/src/gallium/winsys/drm/swrast/core/Makefile b/src/gallium/winsys/drm/swrast/core/Makefile new file mode 100644 index 00000000000..93931ae22b9 --- /dev/null +++ b/src/gallium/winsys/drm/swrast/core/Makefile @@ -0,0 +1,10 @@ +# src/gallium/winsys/drm/swrast/core/Makefile + +TOP = ../../../../../.. +include $(TOP)/configs/current + +LIBNAME = swrastdrm + +C_SOURCES = swrast_drm_api.c + +include ../../../../Makefile.template diff --git a/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c b/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c new file mode 100644 index 00000000000..8c9f80e2c15 --- /dev/null +++ b/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c @@ -0,0 +1,13 @@ +#include "state_tracker/drm_api.h" + +static struct drm_api swrast_drm_api = +{ + .name = "swrast", +}; + +struct drm_api * +drm_api_create() +{ + (void) swrast_drm_api; + return NULL; +} diff --git a/src/gallium/winsys/drm/swrast/egl_g3d/Makefile b/src/gallium/winsys/drm/swrast/egl_g3d/Makefile new file mode 100644 index 00000000000..f0d051ea0ea --- /dev/null +++ b/src/gallium/winsys/drm/swrast/egl_g3d/Makefile @@ -0,0 +1,12 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = swrast +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/swrast/core/libswrastdrm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a + +include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/swrast/egl_g3d/dummy.c b/src/gallium/winsys/drm/swrast/egl_g3d/dummy.c new file mode 100644 index 00000000000..4a1bc28b0b6 --- /dev/null +++ b/src/gallium/winsys/drm/swrast/egl_g3d/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ -- cgit v1.2.3 From 3c967a920718c2a74996ac23b8c1964915db88c2 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 16:31:43 +0800 Subject: st/egl_g3d: Rename to st/egl. Simply the name to egl. --- configs/linux-dri | 2 +- configs/linux-opengl-es | 4 +- configure.ac | 8 +- docs/egl.html | 15 +- docs/opengles.html | 2 +- docs/openvg.html | 2 +- src/gallium/state_trackers/egl/Makefile | 75 ++ src/gallium/state_trackers/egl/common/egl_g3d.c | 1336 ++++++++++++++++++++ src/gallium/state_trackers/egl/common/egl_g3d.h | 127 ++ src/gallium/state_trackers/egl/common/egl_st.c | 131 ++ src/gallium/state_trackers/egl/common/egl_st.h | 73 ++ src/gallium/state_trackers/egl/common/native.h | 277 ++++ .../state_trackers/egl/common/st_public_tmp.h | 20 + src/gallium/state_trackers/egl/kms/native_kms.c | 866 +++++++++++++ src/gallium/state_trackers/egl/kms/native_kms.h | 139 ++ src/gallium/state_trackers/egl/x11/native_dri2.c | 705 +++++++++++ src/gallium/state_trackers/egl/x11/native_x11.c | 148 +++ src/gallium/state_trackers/egl/x11/native_x11.h | 37 + src/gallium/state_trackers/egl/x11/native_ximage.c | 694 ++++++++++ src/gallium/state_trackers/egl/x11/sw_winsys.c | 231 ++++ src/gallium/state_trackers/egl/x11/sw_winsys.h | 40 + src/gallium/state_trackers/egl/x11/x11_screen.c | 453 +++++++ src/gallium/state_trackers/egl/x11/x11_screen.h | 105 ++ src/gallium/state_trackers/egl_g3d/Makefile | 75 -- .../state_trackers/egl_g3d/common/egl_g3d.c | 1336 -------------------- .../state_trackers/egl_g3d/common/egl_g3d.h | 127 -- src/gallium/state_trackers/egl_g3d/common/egl_st.c | 131 -- src/gallium/state_trackers/egl_g3d/common/egl_st.h | 73 -- src/gallium/state_trackers/egl_g3d/common/native.h | 277 ---- .../state_trackers/egl_g3d/common/st_public_tmp.h | 20 - .../state_trackers/egl_g3d/kms/native_kms.c | 866 ------------- .../state_trackers/egl_g3d/kms/native_kms.h | 139 -- .../state_trackers/egl_g3d/x11/native_dri2.c | 705 ----------- .../state_trackers/egl_g3d/x11/native_x11.c | 148 --- .../state_trackers/egl_g3d/x11/native_x11.h | 37 - .../state_trackers/egl_g3d/x11/native_ximage.c | 694 ---------- src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c | 231 ---- src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h | 40 - .../state_trackers/egl_g3d/x11/x11_screen.c | 453 ------- .../state_trackers/egl_g3d/x11/x11_screen.h | 105 -- src/gallium/winsys/drm/Makefile.egl | 65 + src/gallium/winsys/drm/Makefile.egl_g3d | 65 - src/gallium/winsys/drm/i965/egl/Makefile | 14 + src/gallium/winsys/drm/i965/egl/dummy.c | 1 + src/gallium/winsys/drm/i965/egl_g3d/Makefile | 14 - src/gallium/winsys/drm/i965/egl_g3d/dummy.c | 1 - src/gallium/winsys/drm/intel/egl/Makefile | 14 + src/gallium/winsys/drm/intel/egl/dummy.c | 1 + src/gallium/winsys/drm/intel/egl_g3d/Makefile | 14 - src/gallium/winsys/drm/intel/egl_g3d/dummy.c | 1 - src/gallium/winsys/drm/nouveau/egl/Makefile | 19 + src/gallium/winsys/drm/nouveau/egl/dummy.c | 1 + src/gallium/winsys/drm/nouveau/egl_g3d/Makefile | 19 - src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c | 1 - src/gallium/winsys/drm/radeon/egl/Makefile | 14 + src/gallium/winsys/drm/radeon/egl/dummy.c | 1 + src/gallium/winsys/drm/radeon/egl_g3d/Makefile | 14 - src/gallium/winsys/drm/radeon/egl_g3d/dummy.c | 1 - src/gallium/winsys/drm/swrast/egl/Makefile | 12 + src/gallium/winsys/drm/swrast/egl/dummy.c | 1 + src/gallium/winsys/drm/swrast/egl_g3d/Makefile | 12 - src/gallium/winsys/drm/swrast/egl_g3d/dummy.c | 1 - src/gallium/winsys/drm/vmware/egl/Makefile | 14 + src/gallium/winsys/drm/vmware/egl/dummy.c | 1 + src/gallium/winsys/drm/vmware/egl_g3d/Makefile | 14 - src/gallium/winsys/drm/vmware/egl_g3d/dummy.c | 1 - 66 files changed, 5631 insertions(+), 5632 deletions(-) create mode 100644 src/gallium/state_trackers/egl/Makefile create mode 100644 src/gallium/state_trackers/egl/common/egl_g3d.c create mode 100644 src/gallium/state_trackers/egl/common/egl_g3d.h create mode 100644 src/gallium/state_trackers/egl/common/egl_st.c create mode 100644 src/gallium/state_trackers/egl/common/egl_st.h create mode 100644 src/gallium/state_trackers/egl/common/native.h create mode 100644 src/gallium/state_trackers/egl/common/st_public_tmp.h create mode 100644 src/gallium/state_trackers/egl/kms/native_kms.c create mode 100644 src/gallium/state_trackers/egl/kms/native_kms.h create mode 100644 src/gallium/state_trackers/egl/x11/native_dri2.c create mode 100644 src/gallium/state_trackers/egl/x11/native_x11.c create mode 100644 src/gallium/state_trackers/egl/x11/native_x11.h create mode 100644 src/gallium/state_trackers/egl/x11/native_ximage.c create mode 100644 src/gallium/state_trackers/egl/x11/sw_winsys.c create mode 100644 src/gallium/state_trackers/egl/x11/sw_winsys.h create mode 100644 src/gallium/state_trackers/egl/x11/x11_screen.c create mode 100644 src/gallium/state_trackers/egl/x11/x11_screen.h delete mode 100644 src/gallium/state_trackers/egl_g3d/Makefile delete mode 100644 src/gallium/state_trackers/egl_g3d/common/egl_g3d.c delete mode 100644 src/gallium/state_trackers/egl_g3d/common/egl_g3d.h delete mode 100644 src/gallium/state_trackers/egl_g3d/common/egl_st.c delete mode 100644 src/gallium/state_trackers/egl_g3d/common/egl_st.h delete mode 100644 src/gallium/state_trackers/egl_g3d/common/native.h delete mode 100644 src/gallium/state_trackers/egl_g3d/common/st_public_tmp.h delete mode 100644 src/gallium/state_trackers/egl_g3d/kms/native_kms.c delete mode 100644 src/gallium/state_trackers/egl_g3d/kms/native_kms.h delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/native_dri2.c delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/native_x11.c delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/native_x11.h delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/native_ximage.c delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/x11_screen.c delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/x11_screen.h create mode 100644 src/gallium/winsys/drm/Makefile.egl delete mode 100644 src/gallium/winsys/drm/Makefile.egl_g3d create mode 100644 src/gallium/winsys/drm/i965/egl/Makefile create mode 100644 src/gallium/winsys/drm/i965/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/i965/egl_g3d/Makefile delete mode 100644 src/gallium/winsys/drm/i965/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/intel/egl/Makefile create mode 100644 src/gallium/winsys/drm/intel/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/intel/egl_g3d/Makefile delete mode 100644 src/gallium/winsys/drm/intel/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/nouveau/egl/Makefile create mode 100644 src/gallium/winsys/drm/nouveau/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/nouveau/egl_g3d/Makefile delete mode 100644 src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/radeon/egl/Makefile create mode 100644 src/gallium/winsys/drm/radeon/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/radeon/egl_g3d/Makefile delete mode 100644 src/gallium/winsys/drm/radeon/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/swrast/egl/Makefile create mode 100644 src/gallium/winsys/drm/swrast/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/swrast/egl_g3d/Makefile delete mode 100644 src/gallium/winsys/drm/swrast/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/vmware/egl/Makefile create mode 100644 src/gallium/winsys/drm/vmware/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/vmware/egl_g3d/Makefile delete mode 100644 src/gallium/winsys/drm/vmware/egl_g3d/dummy.c (limited to 'configure.ac') diff --git a/configs/linux-dri b/configs/linux-dri index feb2bba3a00..95f77ade1dd 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -61,7 +61,7 @@ DRIVER_DIRS = dri WINDOW_SYSTEM = dri GALLIUM_WINSYS_DIRS = drm GALLIUM_WINSYS_DRM_DIRS = vmware intel i965 -GALLIUM_STATE_TRACKERS_DIRS = egl_g3d +GALLIUM_STATE_TRACKERS_DIRS = egl DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \ savage sis tdfx unichrome ffb swrast diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es index af784551a71..259c26a931b 100644 --- a/configs/linux-opengl-es +++ b/configs/linux-opengl-es @@ -9,7 +9,7 @@ LIB_DIR = lib SRC_DIRS = egl glsl mesa/es gallium gallium/winsys PROGRAM_DIRS = es1/screen es1/xegl es2/xegl -# egl_g3d needs this +# egl st needs this DEFINES += -DGLX_DIRECT_RENDERING # no mesa or egl drivers @@ -23,6 +23,6 @@ GALLIUM_STATE_TRACKERS_DIRS = es # build egl_x11_{swrast,i915}.so GALLIUM_DRIVERS_DIRS += trace i915 -GALLIUM_STATE_TRACKERS_DIRS += egl_g3d +GALLIUM_STATE_TRACKERS_DIRS += egl GALLIUM_WINSYS_DIRS += drm GALLIUM_WINSYS_DRM_DIRS += intel swrast diff --git a/configure.ac b/configure.ac index d6e32f590aa..370bd1b9b7f 100644 --- a/configure.ac +++ b/configure.ac @@ -1165,7 +1165,7 @@ yes) dri) GALLIUM_STATE_TRACKERS_DIRS="dri" if test "x$enable_egl" = xyes; then - GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl_g3d" + GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl" fi # Have only tested st/xorg on 1.6.0 servers PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0], @@ -1182,9 +1182,9 @@ yes) AC_MSG_ERROR([state tracker '$tracker' doesn't exist]) case "$tracker" in - egl_g3d) + egl) if test "x$enable_egl" != xyes; then - AC_MSG_ERROR([cannot build egl_g3d state tracker without EGL library]) + AC_MSG_ERROR([cannot build egl state tracker without EGL library]) fi ;; xorg) @@ -1223,7 +1223,7 @@ yes) # verify the requested driver directories exist egl_displays=`IFS=', '; echo $with_egl_displays` for dpy in $egl_displays; do - test -d "$srcdir/src/gallium/state_trackers/egl_g3d/$dpy" || \ + test -d "$srcdir/src/gallium/state_trackers/egl/$dpy" || \ AC_MSG_ERROR([EGL display '$dpy' does't exist]) done EGL_DISPLAYS="$egl_displays" diff --git a/docs/egl.html b/docs/egl.html index efc7b1ed3aa..08825989669 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -32,10 +32,10 @@ cards.

    the Gallium driver for your hardware. For example

    -  $ ./configure --with-state-trackers=egl_g3d,es,vega --enable-gallium-intel
    +  $ ./configure --with-state-trackers=egl,es,vega --enable-gallium-intel
     
    -

    The main library will be enabled by default. The egl_g3d state +

    The main library will be enabled by default. The egl state tracker is needed by a number of EGL drivers. EGL drivers will be covered later. The es state tracker provides OpenGL ES 1.x and 2.x and the vega state tracker provides OpenVG @@ -77,9 +77,8 @@ bare KMS (kernel modesetting).

    The argument is a comma separated string. It is usually used to specify the rendering APIs, like OpenGL ES or OpenVG, to build. But it should be noted -that a number of EGL drivers depend on the egl_g3d state tracker. -They will not be built without the egl_g3d state -tracker.

    +that a number of EGL drivers depend on the egl state tracker. +They will not be built without the egl state tracker.

    @@ -160,7 +159,7 @@ variable to true forces the use of software rendering.

    Gallium EGL drivers supports all rendering APIs specified in EGL 1.4. The support for optional EGL functions and EGL extensions is usually more complete -than the classic ones. These drivers depend on the egl_g3d state +than the classic ones. These drivers depend on the egl state tracker to build. The available drivers are

      @@ -218,8 +217,8 @@ runtime.

      Developers

      The sources of the main library and the classic drivers can be found at -src/egl/. The sources of the egl_g3d state tracker -can be found at src/gallium/state_trackers/egl_g3d/. +src/egl/. The sources of the egl state tracker can +be found at src/gallium/state_trackers/egl/.

      TODOs

      diff --git a/docs/opengles.html b/docs/opengles.html index a871e85d0b7..fc41e6771c1 100644 --- a/docs/opengles.html +++ b/docs/opengles.html @@ -20,7 +20,7 @@ for more information about EGL.

      Build the Libraries

        -
      1. Run configure with --with-state-trackers=egl_g3d,es and enable the Gallium driver for your hardware.
      2. +
      3. Run configure with --with-state-trackers=egl,es and enable the Gallium driver for your hardware.
      4. Build and install Mesa as usual.
      diff --git a/docs/openvg.html b/docs/openvg.html index cd39b133c43..cdf6b57e0f4 100644 --- a/docs/openvg.html +++ b/docs/openvg.html @@ -34,7 +34,7 @@ Please refer to Mesa EGL for more information about EGL.

      Sample build

      A sample build looks as follows:
      -  $ ./configure --with-state-trackers=egl_g3d,vega --enable-gallium-intel
      +  $ ./configure --with-state-trackers=egl,vega --enable-gallium-intel
         $ make
         $ make install
       
      diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile new file mode 100644 index 00000000000..b696f2fae93 --- /dev/null +++ b/src/gallium/state_trackers/egl/Makefile @@ -0,0 +1,75 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +common_INCLUDES = \ + -I. \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/src/egl/main \ + -I$(TOP)/include + +common_SOURCES = $(wildcard common/*.c) +common_OBJECTS = $(common_SOURCES:.c=.o) + + +x11_INCLUDES = \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/glx/x11 \ + -I$(TOP)/src/egl/drivers/xdri \ + -I$(TOP)/src/mesa \ + $(shell pkg-config --cflags-only-I libdrm) + +x11_SOURCES = $(wildcard x11/*.c) \ + $(TOP)/src/glx/x11/dri2.c \ + $(TOP)/src/egl/drivers/xdri/glxinit.c +x11_OBJECTS = $(x11_SOURCES:.c=.o) + + +kms_INCLUDES = $(shell pkg-config --cflags-only-I libdrm) +kms_SOURCES = $(wildcard kms/*.c) +kms_OBJECTS = $(kms_SOURCES:.c=.o) + + +ALL_INCLUDES = $(common_INCLUDES) $(x11_INCLUDES) $(kms_INCLUDES) +ALL_SOURCES = $(common_SOURCES) $(x11_SOURCES) $(kms_SOURCES) +ALL_OBJECTS = $(common_OBJECTS) $(x11_OBJECTS) $(kms_OBJECTS) + +##### TARGETS ##### + +EGL_DISPLAYS_MODS = $(foreach dpy, $(EGL_DISPLAYS), libegl$(dpy).a) + +default: depend $(EGL_DISPLAYS_MODS) + + +libeglx11.a: $(x11_OBJECTS) $(common_OBJECTS) Makefile + $(MKLIB) -o eglx11 -static $(x11_OBJECTS) $(common_OBJECTS) + +libeglkms.a: $(kms_OBJECTS) $(common_OBJECTS) Makefile + $(MKLIB) -o eglkms -static $(kms_OBJECTS) $(common_OBJECTS) + +depend: + rm -f depend + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(ALL_INCLUDES) $(ALL_SOURCES) 2> /dev/null + +clean: + rm -f $(ALL_OBJECTS) + rm -f $(EGL_DISPLAYS_MODS) + rm -f depend depend.bak + +# Dummy target +install: + @echo -n "" + +##### RULES ##### + +$(common_OBJECTS): %.o: %.c + $(CC) -c $(common_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ + +$(x11_OBJECTS): %.o: %.c + $(CC) -c $(common_INCLUDES) $(x11_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ + +$(kms_OBJECTS): %.o: %.c + $(CC) -c $(common_INCLUDES) $(kms_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ + +sinclude depend diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c new file mode 100644 index 00000000000..2ac6215646c --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -0,0 +1,1336 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include "pipe/p_screen.h" +#include "util/u_memory.h" +#include "util/u_rect.h" +#include "egldriver.h" +#include "eglcurrent.h" +#include "eglconfigutil.h" +#include "egllog.h" + +#include "native.h" +#include "egl_g3d.h" +#include "egl_st.h" + +/** + * Validate the draw/read surfaces of the context. + */ +static void +egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct pipe_screen *screen = gdpy->native->screen; + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + const uint st_att_map[NUM_NATIVE_ATTACHMENTS] = { + ST_SURFACE_FRONT_LEFT, + ST_SURFACE_BACK_LEFT, + ST_SURFACE_FRONT_RIGHT, + ST_SURFACE_BACK_RIGHT, + }; + EGLint num_surfaces, s; + + /* validate draw and/or read buffers */ + num_surfaces = (gctx->base.ReadSurface == gctx->base.DrawSurface) ? 1 : 2; + for (s = 0; s < num_surfaces; s++) { + struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; + struct egl_g3d_surface *gsurf; + struct egl_g3d_buffer *gbuf; + EGLint att; + + if (s == 0) { + gsurf = egl_g3d_surface(gctx->base.DrawSurface); + gbuf = &gctx->draw; + } + else { + gsurf = egl_g3d_surface(gctx->base.ReadSurface); + gbuf = &gctx->read; + } + + if (!gctx->force_validate) { + unsigned int seq_num; + + gsurf->native->validate(gsurf->native, gbuf->attachment_mask, + &seq_num, NULL, NULL, NULL); + /* skip validation */ + if (gsurf->sequence_number == seq_num) + continue; + } + + pipe_surface_reference(&gsurf->render_surface, NULL); + memset(textures, 0, sizeof(textures)); + + gsurf->native->validate(gsurf->native, gbuf->attachment_mask, + &gsurf->sequence_number, textures, + &gsurf->base.Width, &gsurf->base.Height); + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + struct pipe_texture *pt = textures[att]; + struct pipe_surface *ps; + + if (native_attachment_mask_test(gbuf->attachment_mask, att) && pt) { + ps = screen->get_tex_surface(screen, pt, 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_GPU_WRITE); + gctx->stapi->st_set_framebuffer_surface(gbuf->st_fb, + st_att_map[att], ps); + + if (gsurf->render_att == att) + pipe_surface_reference(&gsurf->render_surface, ps); + + pipe_surface_reference(&ps, NULL); + pipe_texture_reference(&pt, NULL); + } + } + + gctx->stapi->st_resize_framebuffer(gbuf->st_fb, + gsurf->base.Width, gsurf->base.Height); + } + + gctx->force_validate = EGL_FALSE; + +} + +/** + * Create a st_framebuffer. + */ +static struct st_framebuffer * +create_framebuffer(_EGLContext *ctx, _EGLSurface *surf) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config); + + return gctx->stapi->st_create_framebuffer(&gconf->native->mode, + gconf->native->color_format, gconf->native->depth_format, + gconf->native->stencil_format, + gsurf->base.Width, gsurf->base.Height, &gsurf->base); +} + +/** + * Update the attachments of draw/read surfaces. + */ +static void +egl_g3d_route_context(_EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + EGLint s; + + /* route draw and read buffers' attachments */ + for (s = 0; s < 2; s++) { + struct egl_g3d_surface *gsurf; + struct egl_g3d_buffer *gbuf; + + if (s == 0) { + gsurf = egl_g3d_surface(gctx->base.DrawSurface); + gbuf = &gctx->draw; + } + else { + gsurf = egl_g3d_surface(gctx->base.ReadSurface); + gbuf = &gctx->read; + } + + gbuf->attachment_mask = (1 << gsurf->render_att); + + /* FIXME OpenGL defaults to draw the front or back buffer when the + * context is single-buffered or double-buffered respectively. In EGL, + * however, the buffer to be drawn is determined by the surface, instead + * of the context. As a result, rendering to a pixmap surface with a + * double-buffered context does not work as expected. + * + * gctx->stapi->st_draw_front_buffer(gctx->st_ctx, natt == + * NATIVE_ATTACHMENT_FRONT_LEFT); + */ + + /* + * FIXME If the back buffer is asked for here, and the front buffer is + * later needed by the client API (e.g. glDrawBuffer is called to draw + * the front buffer), it will create a new pipe texture and draw there. + * One fix is to ask for both buffers here, but it would be a waste if + * the front buffer is never used. A better fix is to add a callback to + * the pipe screen with context private (just like flush_frontbuffer). + */ + } +} + +/** + * Reallocate the context's framebuffers after draw/read surfaces change. + */ +static EGLBoolean +egl_g3d_realloc_context(_EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + struct egl_g3d_surface *gdraw = egl_g3d_surface(gctx->base.DrawSurface); + struct egl_g3d_surface *gread = egl_g3d_surface(gctx->base.ReadSurface); + + /* unreference the old framebuffers */ + if (gctx->draw.st_fb) { + EGLBoolean is_equal = (gctx->draw.st_fb == gctx->read.st_fb); + void *priv; + + priv = gctx->stapi->st_framebuffer_private(gctx->draw.st_fb); + if (!gdraw || priv != (void *) &gdraw->base) { + gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); + gctx->draw.st_fb = NULL; + gctx->draw.attachment_mask = 0x0; + } + + if (is_equal) { + gctx->read.st_fb = NULL; + gctx->draw.attachment_mask = 0x0; + } + else { + priv = gctx->stapi->st_framebuffer_private(gctx->read.st_fb); + if (!gread || priv != (void *) &gread->base) { + gctx->stapi->st_unreference_framebuffer(gctx->read.st_fb); + gctx->read.st_fb = NULL; + gctx->draw.attachment_mask = 0x0; + } + } + } + + if (!gdraw) + return EGL_TRUE; + + /* create the draw fb */ + if (!gctx->draw.st_fb) { + gctx->draw.st_fb = create_framebuffer(&gctx->base, &gdraw->base); + if (!gctx->draw.st_fb) + return EGL_FALSE; + } + + /* create the read fb */ + if (!gctx->read.st_fb) { + if (gread != gdraw) { + gctx->read.st_fb = create_framebuffer(&gctx->base, &gread->base); + if (!gctx->read.st_fb) { + gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); + gctx->draw.st_fb = NULL; + return EGL_FALSE; + } + } + else { + /* there is no st_reference_framebuffer... */ + gctx->read.st_fb = gctx->draw.st_fb; + } + } + + egl_g3d_route_context(dpy, &gctx->base); + gctx->force_validate = EGL_TRUE; + + return EGL_TRUE; +} + +/** + * Return the current context of the given API. + */ +static struct egl_g3d_context * +egl_g3d_get_current_context(EGLint api) +{ + _EGLThreadInfo *t = _eglGetCurrentThread(); + EGLint api_index = _eglConvertApiToIndex(api); + return egl_g3d_context(t->CurrentContexts[api_index]); +} + +/** + * Return the state tracker for the given context. + */ +static const struct egl_g3d_st * +egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + const struct egl_g3d_st *stapi; + EGLint idx = -1; + + switch (ctx->ClientAPI) { + case EGL_OPENGL_ES_API: + switch (ctx->ClientVersion) { + case 1: + idx = EGL_G3D_ST_OPENGL_ES; + break; + case 2: + idx = EGL_G3D_ST_OPENGL_ES2; + break; + default: + _eglLog(_EGL_WARNING, "unknown client version %d", + ctx->ClientVersion); + break; + } + break; + case EGL_OPENVG_API: + idx = EGL_G3D_ST_OPENVG; + break; + case EGL_OPENGL_API: + idx = EGL_G3D_ST_OPENGL; + break; + default: + _eglLog(_EGL_WARNING, "unknown client API 0x%04x", ctx->ClientAPI); + break; + } + + stapi = (idx >= 0) ? gdrv->stapis[idx] : NULL; + return stapi; +} + +/** + * Initialize the state trackers. + */ +static void +egl_g3d_init_st(_EGLDriver *drv) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + EGLint i; + + /* already initialized */ + if (gdrv->api_mask) + return; + + for (i = 0; i < NUM_EGL_G3D_STS; i++) { + gdrv->stapis[i] = egl_g3d_get_st(i); + if (gdrv->stapis[i]) + gdrv->api_mask |= gdrv->stapis[i]->api_bit; + } + + if (gdrv->api_mask) + _eglLog(_EGL_DEBUG, "Driver API mask: 0x%x", gdrv->api_mask); + else + _eglLog(_EGL_WARNING, "No supported client API"); +} + +/** + * Get the probe object of the display. + * + * Note that this function may be called before the display is initialized. + */ +static struct native_probe * +egl_g3d_get_probe(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct native_probe *nprobe; + + nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key); + if (!nprobe || nprobe->display != dpy->NativeDisplay) { + if (nprobe) + nprobe->destroy(nprobe); + nprobe = native_create_probe(dpy->NativeDisplay); + _eglSetProbeCache(gdrv->probe_key, (void *) nprobe); + } + + return nprobe; +} + +/** + * Destroy the probe object of the display. The display may be NULL. + * + * Note that this function may be called before the display is initialized. + */ +static void +egl_g3d_destroy_probe(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct native_probe *nprobe; + + nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key); + if (nprobe && (!dpy || nprobe->display == dpy->NativeDisplay)) { + nprobe->destroy(nprobe); + _eglSetProbeCache(gdrv->probe_key, NULL); + } +} + +/** + * Return an API mask that consists of the state trackers that supports the + * given mode. + * + * FIXME add st_is_mode_supported()? + */ +static EGLint +get_mode_api_mask(const __GLcontextModes *mode, EGLint api_mask) +{ + EGLint check; + + /* OpenGL ES 1.x and 2.x are checked together */ + check = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT; + if (api_mask & check) { + /* this is required by EGL, not by OpenGL ES */ + if (mode->drawableType & GLX_WINDOW_BIT && !mode->doubleBufferMode) + api_mask &= ~check; + } + + check = EGL_OPENVG_BIT; + if (api_mask & check) { + /* vega st needs the depth/stencil rb */ + if (!mode->depthBits && !mode->stencilBits) + api_mask &= ~check; + } + + return api_mask; +} + +#ifdef EGL_MESA_screen_surface + +static void +egl_g3d_add_screens(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + const struct native_connector **native_connectors; + EGLint num_connectors, i; + + native_connectors = + gdpy->native->modeset->get_connectors(gdpy->native, &num_connectors, NULL); + if (!num_connectors) { + if (native_connectors) + free(native_connectors); + return; + } + + for (i = 0; i < num_connectors; i++) { + const struct native_connector *nconn = native_connectors[i]; + struct egl_g3d_screen *gscr; + const struct native_mode **native_modes; + EGLint num_modes, j; + + /* TODO support for hotplug */ + native_modes = + gdpy->native->modeset->get_modes(gdpy->native, nconn, &num_modes); + if (!num_modes) { + if (native_modes) + free(native_modes); + continue; + } + + gscr = CALLOC_STRUCT(egl_g3d_screen); + if (!gscr) { + free(native_modes); + continue; + } + + _eglInitScreen(&gscr->base); + + for (j = 0; j < num_modes; j++) { + const struct native_mode *nmode = native_modes[j]; + _EGLMode *mode; + + mode = _eglAddNewMode(&gscr->base, nmode->width, nmode->height, + nmode->refresh_rate, nmode->desc); + if (!mode) + break; + /* gscr->native_modes and gscr->base.Modes should be consistent */ + assert(mode == &gscr->base.Modes[j]); + } + + gscr->native = nconn; + gscr->native_modes = native_modes; + + _eglAddScreen(dpy, &gscr->base); + } + + free(native_connectors); +} + +#endif /* EGL_MESA_screen_surface */ + +/** + * Add configs to display and return the next config ID. + */ +static EGLint +egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + const struct native_config **native_configs; + int num_configs, i; + + native_configs = gdpy->native->get_configs(gdpy->native, + &num_configs); + if (!num_configs) { + if (native_configs) + free(native_configs); + return id; + } + + for (i = 0; i < num_configs; i++) { + EGLint api_mask; + struct egl_g3d_config *gconf; + EGLBoolean valid; + + api_mask = get_mode_api_mask(&native_configs[i]->mode, gdrv->api_mask); + if (!api_mask) { + _eglLog(_EGL_DEBUG, "no state tracker supports config 0x%x", + native_configs[i]->mode.visualID); + continue; + } + + gconf = CALLOC_STRUCT(egl_g3d_config); + if (!gconf) + continue; + + _eglInitConfig(&gconf->base, id); + valid = _eglConfigFromContextModesRec(&gconf->base, + &native_configs[i]->mode, api_mask, api_mask); + if (valid) { +#ifdef EGL_MESA_screen_surface + /* check if scanout surface bit is set */ + if (native_configs[i]->scanout_bit) { + EGLint val = GET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE); + val |= EGL_SCREEN_BIT_MESA; + SET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE, val); + } +#endif + valid = _eglValidateConfig(&gconf->base, EGL_FALSE); + } + if (!valid) { + _eglLog(_EGL_DEBUG, "skip invalid config 0x%x", + native_configs[i]->mode.visualID); + free(gconf); + continue; + } + + gconf->native = native_configs[i]; + _eglAddConfig(dpy, &gconf->base); + id++; + } + + free(native_configs); + return id; +} + +/** + * Flush the front buffer of the context's draw surface. + */ +static void +egl_g3d_flush_frontbuffer(struct pipe_screen *screen, + struct pipe_surface *surf, void *context_private) +{ + struct egl_g3d_context *gctx = egl_g3d_context(context_private); + struct egl_g3d_surface *gsurf = egl_g3d_surface(gctx->base.DrawSurface); + + if (gsurf) + gsurf->native->flush_frontbuffer(gsurf->native); +} + +/** + * Re-validate the context. + */ +static void +egl_g3d_update_buffer(struct pipe_screen *screen, void *context_private) +{ + struct egl_g3d_context *gctx = egl_g3d_context(context_private); + + /** + * It is likely that the surface has changed when this function is called. + * Set force_validate to skip an unnecessary check. + */ + gctx->force_validate = EGL_TRUE; + egl_g3d_validate_context(gctx->base.Display, &gctx->base); +} + +static EGLBoolean +egl_g3d_terminate(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + EGLint i; + + _eglReleaseDisplayResources(drv, dpy); + _eglCleanupDisplay(dpy); + + if (dpy->Screens) { + for (i = 0; i < dpy->NumScreens; i++) { + struct egl_g3d_screen *gscr = egl_g3d_screen(dpy->Screens[i]); + free(gscr->native_modes); + free(gscr); + } + free(dpy->Screens); + } + + if (gdpy->native) + gdpy->native->destroy(gdpy->native); + + free(gdpy); + dpy->DriverData = NULL; + + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, + EGLint *major, EGLint *minor) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct egl_g3d_display *gdpy; + + /* the probe object is unlikely to be needed again */ + egl_g3d_destroy_probe(drv, dpy); + + gdpy = CALLOC_STRUCT(egl_g3d_display); + if (!gdpy) { + _eglError(EGL_BAD_ALLOC, "eglInitialize"); + goto fail; + } + dpy->DriverData = gdpy; + + gdpy->native = native_create_display(dpy->NativeDisplay); + if (!gdpy->native) { + _eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)"); + goto fail; + } + + gdpy->native->screen->flush_frontbuffer = egl_g3d_flush_frontbuffer; + gdpy->native->screen->update_buffer = egl_g3d_update_buffer; + + egl_g3d_init_st(&gdrv->base); + dpy->ClientAPIsMask = gdrv->api_mask; + + if (egl_g3d_add_configs(drv, dpy, 1) == 1) { + _eglError(EGL_NOT_INITIALIZED, "eglInitialize(unable to add configs)"); + goto fail; + } + +#ifdef EGL_MESA_screen_surface + /* enable MESA_screen_surface */ + if (gdpy->native->modeset) { + dpy->Extensions.MESA_screen_surface = EGL_TRUE; + egl_g3d_add_screens(drv, dpy); + } +#endif + + *major = 1; + *minor = 4; + + return EGL_TRUE; + +fail: + if (gdpy) + egl_g3d_terminate(drv, dpy); + return EGL_FALSE; +} + +static _EGLContext * +egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, + _EGLContext *share, const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_context *gshare = egl_g3d_context(share); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_context *gctx; + const __GLcontextModes *mode; + + gctx = CALLOC_STRUCT(egl_g3d_context); + if (!gctx) { + _eglError(EGL_BAD_ALLOC, "eglCreateContext"); + return NULL; + } + + if (!_eglInitContext(drv, &gctx->base, conf, attribs)) { + free(gctx); + return NULL; + } + + gctx->stapi = egl_g3d_choose_st(drv, &gctx->base); + if (!gctx->stapi) { + free(gctx); + return NULL; + } + + mode = &gconf->native->mode; + gctx->pipe = + gdpy->native->create_context(gdpy->native, (void *) &gctx->base); + if (!gctx->pipe) { + free(gctx); + return NULL; + } + + gctx->st_ctx = gctx->stapi->st_create_context(gctx->pipe, mode, + (gshare) ? gshare->st_ctx : NULL); + if (!gctx->st_ctx) { + gctx->pipe->destroy(gctx->pipe); + free(gctx); + return NULL; + } + + return &gctx->base; +} + +static EGLBoolean +egl_g3d_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + + if (_eglIsContextBound(&gctx->base)) + return EGL_TRUE; + + egl_g3d_realloc_context(dpy, &gctx->base); + + /* it will destroy pipe context */ + gctx->stapi->st_destroy_context(gctx->st_ctx); + + free(gctx); + + return EGL_TRUE; +} + +static EGLBoolean +init_surface_geometry(_EGLSurface *surf) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + + return gsurf->native->validate(gsurf->native, 0x0, + &gsurf->sequence_number, NULL, + &gsurf->base.Width, &gsurf->base.Height); +} + +static _EGLSurface * +egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, EGLNativeWindowType win, + const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_surface *gsurf; + + gsurf = CALLOC_STRUCT(egl_g3d_surface); + if (!gsurf) { + _eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface"); + return NULL; + } + + if (!_eglInitSurface(drv, &gsurf->base, EGL_WINDOW_BIT, conf, attribs)) { + free(gsurf); + return NULL; + } + + gsurf->native = + gdpy->native->create_window_surface(gdpy->native, win, gconf->native); + if (!gsurf->native) { + free(gsurf); + return NULL; + } + + if (!init_surface_geometry(&gsurf->base)) { + gsurf->native->destroy(gsurf->native); + free(gsurf); + return NULL; + } + + gsurf->render_att = (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER || + !gconf->native->mode.doubleBufferMode) ? + NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; + + return &gsurf->base; +} + +static _EGLSurface * +egl_g3d_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, EGLNativePixmapType pix, + const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_surface *gsurf; + + gsurf = CALLOC_STRUCT(egl_g3d_surface); + if (!gsurf) { + _eglError(EGL_BAD_ALLOC, "eglCreatePixmapSurface"); + return NULL; + } + + if (!_eglInitSurface(drv, &gsurf->base, EGL_PIXMAP_BIT, conf, attribs)) { + free(gsurf); + return NULL; + } + + gsurf->native = + gdpy->native->create_pixmap_surface(gdpy->native, pix, gconf->native); + if (!gsurf->native) { + free(gsurf); + return NULL; + } + + if (!init_surface_geometry(&gsurf->base)) { + gsurf->native->destroy(gsurf->native); + free(gsurf); + return NULL; + } + + gsurf->render_att = NATIVE_ATTACHMENT_FRONT_LEFT; + + return &gsurf->base; +} + +static _EGLSurface * +egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_surface *gsurf; + + gsurf = CALLOC_STRUCT(egl_g3d_surface); + if (!gsurf) { + _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); + return NULL; + } + + if (!_eglInitSurface(drv, &gsurf->base, EGL_PBUFFER_BIT, conf, attribs)) { + free(gsurf); + return NULL; + } + + gsurf->native = + gdpy->native->create_pbuffer_surface(gdpy->native, gconf->native, + gsurf->base.Width, gsurf->base.Height); + if (!gsurf->native) { + free(gsurf); + return NULL; + } + + if (!init_surface_geometry(&gsurf->base)) { + gsurf->native->destroy(gsurf->native); + free(gsurf); + return NULL; + } + + gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ? + NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; + + return &gsurf->base; +} + +static EGLBoolean +egl_g3d_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + + if (_eglIsSurfaceBound(&gsurf->base)) + return EGL_TRUE; + + pipe_surface_reference(&gsurf->render_surface, NULL); + gsurf->native->destroy(gsurf->native); + free(gsurf); + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + struct egl_g3d_context *old_gctx; + EGLint api; + EGLBoolean ok = EGL_TRUE; + + /* find the old context */ + api = (gctx) ? gctx->base.ClientAPI : eglQueryAPI(); + old_gctx = egl_g3d_get_current_context(api); + if (old_gctx && !_eglIsContextLinked(&old_gctx->base)) + old_gctx = NULL; + + if (!_eglMakeCurrent(drv, dpy, draw, read, ctx)) + return EGL_FALSE; + + if (old_gctx) { + /* flush old context */ + old_gctx->stapi->st_flush(old_gctx->st_ctx, + PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); + + /* + * The old context is no longer current, and egl_g3d_realloc_context() + * should be called to destroy the framebuffers. However, it is possible + * that it will be made current again with the same draw/read surfaces. + * It might be better to keep it around. + */ + } + + if (gctx) { + struct egl_g3d_surface *gdraw = egl_g3d_surface(draw); + + ok = egl_g3d_realloc_context(dpy, &gctx->base); + if (ok) { + ok = gctx->stapi->st_make_current(gctx->st_ctx, + gctx->draw.st_fb, gctx->read.st_fb); + if (ok) { + egl_g3d_validate_context(dpy, &gctx->base); + if (gdraw->base.Type == EGL_WINDOW_BIT) { + gctx->base.WindowRenderBuffer = + (gdraw->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) ? + EGL_SINGLE_BUFFER : EGL_BACK_BUFFER; + } + } + } + } + else if (old_gctx) { + ok = old_gctx->stapi->st_make_current(NULL, NULL, NULL); + old_gctx->base.WindowRenderBuffer = EGL_NONE; + } + + return ok; +} + +static EGLBoolean +egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + _EGLContext *ctx = _eglGetCurrentContext(); + struct egl_g3d_context *gctx = NULL; + + /* no-op for pixmap or pbuffer surface */ + if (gsurf->base.Type == EGL_PIXMAP_BIT || + gsurf->base.Type == EGL_PBUFFER_BIT) + return EGL_TRUE; + + /* or when the surface is single-buffered */ + if (gsurf->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) + return EGL_TRUE; + + if (ctx && ctx->DrawSurface == surf) + gctx = egl_g3d_context(ctx); + + /* flush if the surface is current */ + if (gctx) + gctx->stapi->st_notify_swapbuffers(gctx->draw.st_fb); + + /* + * We drew on the back buffer, unless there was no back buffer. + * In that case, we drew on the front buffer. Either case, we call + * swap_buffers. + */ + if (!gsurf->native->swap_buffers(gsurf->native)) + return EGL_FALSE; + + if (gctx) { + struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config); + + /* force validation if the swap method is not copy */ + if (gconf->native->mode.swapMethod != GLX_SWAP_COPY_OML) { + gctx->force_validate = EGL_TRUE; + egl_g3d_validate_context(dpy, &gctx->base); + } + } + + return EGL_TRUE; +} + +/** + * Find a config that supports the pixmap. + */ +static _EGLConfig * +find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf; + EGLint i; + + for (i = 0; i < dpy->NumConfigs; i++) { + gconf = egl_g3d_config(dpy->Configs[i]); + if (gdpy->native->is_pixmap_supported(gdpy->native, pix, gconf->native)) + break; + } + + return (i < dpy->NumConfigs) ? &gconf->base : NULL; +} + +/** + * Get the pipe surface of the given attachment of the native surface. + */ +static struct pipe_surface * +get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf, + enum native_attachment natt) +{ + struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; + struct pipe_surface *psurf; + + textures[natt] = NULL; + nsurf->validate(nsurf, 1 << natt, NULL, textures, NULL, NULL); + if (!textures[natt]) + return NULL; + + psurf = ndpy->screen->get_tex_surface(ndpy->screen, textures[natt], + 0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE); + pipe_texture_reference(&textures[natt], NULL); + + return psurf; +} + +static EGLBoolean +egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, + NativePixmapType target) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + _EGLContext *ctx = _eglGetCurrentContext(); + struct egl_g3d_config *gconf; + struct native_surface *nsurf; + struct pipe_screen *screen = gdpy->native->screen; + struct pipe_surface *psurf; + + if (!gsurf->render_surface) + return EGL_TRUE; + + gconf = egl_g3d_config(find_pixmap_config(dpy, target)); + if (!gconf) + return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers"); + + nsurf = gdpy->native->create_pixmap_surface(gdpy->native, + target, gconf->native); + if (!nsurf) + return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers"); + + /* flush if the surface is current */ + if (ctx && ctx->DrawSurface == &gsurf->base) { + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + gctx->stapi->st_flush(gctx->st_ctx, + PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); + } + + psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); + if (psurf) { + struct pipe_context pipe; + + /** + * XXX This is hacky. If we might allow the EGLDisplay to create a pipe + * context of its own and use the blitter context for this. + */ + memset(&pipe, 0, sizeof(pipe)); + pipe.screen = screen; + + util_surface_copy(&pipe, FALSE, psurf, 0, 0, + gsurf->render_surface, 0, 0, psurf->width, psurf->height); + + pipe_surface_reference(&psurf, NULL); + nsurf->flush_frontbuffer(nsurf); + } + + nsurf->destroy(nsurf); + + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + gctx->stapi->st_finish(gctx->st_ctx); + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_wait_native(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine) +{ + _EGLSurface *surf = _eglGetCurrentSurface(EGL_DRAW); + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + + if (engine != EGL_CORE_NATIVE_ENGINE) + return _eglError(EGL_BAD_PARAMETER, "eglWaitNative"); + + if (gsurf) + gsurf->native->wait(gsurf->native); + + return EGL_TRUE; +} + +static _EGLProc +egl_g3d_get_proc_address(_EGLDriver *drv, const char *procname) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + _EGLProc proc; + EGLint i; + + /* in case this is called before a display is initialized */ + egl_g3d_init_st(&gdrv->base); + + for (i = 0; i < NUM_EGL_G3D_STS; i++) { + const struct egl_g3d_st *stapi = gdrv->stapis[i]; + if (stapi) { + proc = (_EGLProc) stapi->st_get_proc_address(procname); + if (proc) + return proc; + } + } + + return (_EGLProc) NULL; +} + +static EGLBoolean +egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *surf, EGLint buffer) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + struct egl_g3d_context *gctx; + enum pipe_format target_format; + int target; + + if (!gsurf || gsurf->base.Type != EGL_PBUFFER_BIT) + return _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); + if (buffer != EGL_BACK_BUFFER) + return _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); + if (gsurf->base.BoundToTexture) + return _eglError(EGL_BAD_ACCESS, "eglBindTexImage"); + + switch (gsurf->base.TextureFormat) { + case EGL_TEXTURE_RGB: + target_format = PIPE_FORMAT_R8G8B8_UNORM; + break; + case EGL_TEXTURE_RGBA: + target_format = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + default: + return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + } + + switch (gsurf->base.TextureTarget) { + case EGL_TEXTURE_2D: + target = ST_TEXTURE_2D; + break; + default: + return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + } + + /* flush properly if the surface is bound */ + if (gsurf->base.Binding) { + gctx = egl_g3d_context(gsurf->base.Binding); + gctx->stapi->st_flush(gctx->st_ctx, + PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); + } + + /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */ + gctx = egl_g3d_get_current_context(EGL_OPENGL_API); + if (gctx) { + if (!gsurf->render_surface) + return EGL_FALSE; + + gctx->stapi->st_bind_texture_surface(gsurf->render_surface, + target, gsurf->base.MipmapLevel, target_format); + gsurf->base.BoundToTexture = EGL_TRUE; + } + + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_release_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *surf, EGLint buffer) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + + if (!gsurf || gsurf->base.Type != EGL_PBUFFER_BIT || + !gsurf->base.BoundToTexture) + return _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); + if (buffer != EGL_BACK_BUFFER) + return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); + + if (gsurf->render_surface) { + _EGLThreadInfo *t = _eglGetCurrentThread(); + /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */ + struct egl_g3d_context *gctx = egl_g3d_context( + t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_API)]); + + /* what if the context the surface binds to is no longer current? */ + if (gctx) + gctx->stapi->st_unbind_texture_surface(gsurf->render_surface, + ST_TEXTURE_2D, gsurf->base.MipmapLevel); + } + + gsurf->base.BoundToTexture = EGL_FALSE; + + return EGL_TRUE; +} + +#ifdef EGL_MESA_screen_surface + +static _EGLSurface * +egl_g3d_create_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_surface *gsurf; + + gsurf = CALLOC_STRUCT(egl_g3d_surface); + if (!gsurf) { + _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); + return NULL; + } + + if (!_eglInitSurface(drv, &gsurf->base, + EGL_SCREEN_BIT_MESA, conf, attribs)) { + free(gsurf); + return NULL; + } + + gsurf->native = + gdpy->native->modeset->create_scanout_surface(gdpy->native, + gconf->native, gsurf->base.Width, gsurf->base.Height); + if (!gsurf->native) { + free(gsurf); + return NULL; + } + + gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ? + NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; + + return &gsurf->base; +} + +static EGLBoolean +egl_g3d_show_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLScreen *scr, _EGLSurface *surf, + _EGLMode *mode) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_screen *gscr = egl_g3d_screen(scr); + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + struct native_surface *nsurf; + const struct native_mode *nmode; + EGLBoolean changed; + + if (gsurf) { + EGLint idx; + + if (!mode) + return _eglError(EGL_BAD_MATCH, "eglShowSurfaceMESA"); + if (gsurf->base.Type != EGL_SCREEN_BIT_MESA) + return _eglError(EGL_BAD_SURFACE, "eglShowScreenSurfaceMESA"); + if (gsurf->base.Width < mode->Width || gsurf->base.Height < mode->Height) + return _eglError(EGL_BAD_MATCH, + "eglShowSurfaceMESA(surface smaller than mode size)"); + + /* find the index of the mode */ + for (idx = 0; idx < gscr->base.NumModes; idx++) + if (mode == &gscr->base.Modes[idx]) + break; + if (idx >= gscr->base.NumModes) { + return _eglError(EGL_BAD_MODE_MESA, + "eglShowSurfaceMESA(unknown mode)"); + } + + nsurf = gsurf->native; + nmode = gscr->native_modes[idx]; + } + else { + if (mode) + return _eglError(EGL_BAD_MATCH, "eglShowSurfaceMESA"); + + /* disable the screen */ + nsurf = NULL; + nmode = NULL; + } + + /* TODO surface panning by CRTC choosing */ + changed = gdpy->native->modeset->program(gdpy->native, 0, nsurf, + gscr->base.OriginX, gscr->base.OriginY, &gscr->native, 1, nmode); + if (changed) { + gscr->base.CurrentSurface = &gsurf->base; + gscr->base.CurrentMode = mode; + } + + return changed; +} + +#endif /* EGL_MESA_screen_surface */ + +static EGLint +egl_g3d_probe(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct native_probe *nprobe; + enum native_probe_result res; + EGLint score; + + nprobe = egl_g3d_get_probe(drv, dpy); + res = native_get_probe_result(nprobe); + + switch (res) { + case NATIVE_PROBE_UNKNOWN: + default: + score = 0; + break; + case NATIVE_PROBE_FALLBACK: + score = 40; + break; + case NATIVE_PROBE_SUPPORTED: + score = 50; + break; + case NATIVE_PROBE_EXACT: + score = 100; + break; + } + + return score; +} + +static void +egl_g3d_unload(_EGLDriver *drv) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + + egl_g3d_destroy_probe(drv, NULL); + free(gdrv); +} + +_EGLDriver * +_eglMain(const char *args) +{ + static char driver_name[64]; + struct egl_g3d_driver *gdrv; + + snprintf(driver_name, sizeof(driver_name), + "Gallium/%s", native_get_name()); + + gdrv = CALLOC_STRUCT(egl_g3d_driver); + if (!gdrv) + return NULL; + + _eglInitDriverFallbacks(&gdrv->base); + + gdrv->base.API.Initialize = egl_g3d_initialize; + gdrv->base.API.Terminate = egl_g3d_terminate; + gdrv->base.API.CreateContext = egl_g3d_create_context; + gdrv->base.API.DestroyContext = egl_g3d_destroy_context; + gdrv->base.API.CreateWindowSurface = egl_g3d_create_window_surface; + gdrv->base.API.CreatePixmapSurface = egl_g3d_create_pixmap_surface; + gdrv->base.API.CreatePbufferSurface = egl_g3d_create_pbuffer_surface; + gdrv->base.API.DestroySurface = egl_g3d_destroy_surface; + gdrv->base.API.MakeCurrent = egl_g3d_make_current; + gdrv->base.API.SwapBuffers = egl_g3d_swap_buffers; + gdrv->base.API.CopyBuffers = egl_g3d_copy_buffers; + gdrv->base.API.WaitClient = egl_g3d_wait_client; + gdrv->base.API.WaitNative = egl_g3d_wait_native; + gdrv->base.API.GetProcAddress = egl_g3d_get_proc_address; + + gdrv->base.API.BindTexImage = egl_g3d_bind_tex_image; + gdrv->base.API.ReleaseTexImage = egl_g3d_release_tex_image; + +#ifdef EGL_MESA_screen_surface + gdrv->base.API.CreateScreenSurfaceMESA = egl_g3d_create_screen_surface; + gdrv->base.API.ShowScreenSurfaceMESA = egl_g3d_show_screen_surface; +#endif + + gdrv->base.Name = driver_name; + gdrv->base.Probe = egl_g3d_probe; + gdrv->base.Unload = egl_g3d_unload; + + /* the key is " EGL G3D" */ + gdrv->probe_key = 0x0E61063D; + + return &gdrv->base; +} diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.h b/src/gallium/state_trackers/egl/common/egl_g3d.h new file mode 100644 index 00000000000..3dae8c40529 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_g3d.h @@ -0,0 +1,127 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _EGL_G3D_H_ +#define _EGL_G3D_H_ + +#include "pipe/p_compiler.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "pipe/p_format.h" +#include "egldriver.h" +#include "egldisplay.h" +#include "eglcontext.h" +#include "eglsurface.h" +#include "eglconfig.h" +#include "eglscreen.h" +#include "eglmode.h" + +#include "native.h" +#include "egl_st.h" + +struct egl_g3d_driver { + _EGLDriver base; + const struct egl_g3d_st *stapis[NUM_EGL_G3D_STS]; + EGLint api_mask; + + EGLint probe_key; +}; + +struct egl_g3d_display { + struct native_display *native; +}; + +struct egl_g3d_buffer { + struct st_framebuffer *st_fb; + uint attachment_mask; +}; + +struct egl_g3d_context { + _EGLContext base; + + const struct egl_g3d_st *stapi; + struct pipe_context *pipe; + + struct st_context *st_ctx; + EGLBoolean force_validate; + struct egl_g3d_buffer draw, read; +}; + +struct egl_g3d_surface { + _EGLSurface base; + struct native_surface *native; + enum native_attachment render_att; + struct pipe_surface *render_surface; + unsigned int sequence_number; +}; + +struct egl_g3d_config { + _EGLConfig base; + const struct native_config *native; +}; + +struct egl_g3d_screen { + _EGLScreen base; + const struct native_connector *native; + const struct native_mode **native_modes; +}; + +static INLINE struct egl_g3d_driver * +egl_g3d_driver(_EGLDriver *drv) +{ + return (struct egl_g3d_driver *) drv; +} + +static INLINE struct egl_g3d_display * +egl_g3d_display(_EGLDisplay *dpy) +{ + /* note that it is not direct casting */ + return (struct egl_g3d_display *) dpy->DriverData; +} + +static INLINE struct egl_g3d_context * +egl_g3d_context(_EGLContext *ctx) +{ + return (struct egl_g3d_context *) ctx; +} + +static INLINE struct egl_g3d_surface * +egl_g3d_surface(_EGLSurface *surf) +{ + return (struct egl_g3d_surface *) surf; +} + +static INLINE struct egl_g3d_config * +egl_g3d_config(_EGLConfig *conf) +{ + return (struct egl_g3d_config *) conf; +} + +static INLINE struct egl_g3d_screen * +egl_g3d_screen(_EGLScreen *scr) +{ + return (struct egl_g3d_screen *) scr; +} + +#endif /* _EGL_G3D_H_ */ diff --git a/src/gallium/state_trackers/egl/common/egl_st.c b/src/gallium/state_trackers/egl/common/egl_st.c new file mode 100644 index 00000000000..a88ff911cd5 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_st.c @@ -0,0 +1,131 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include "pipe/p_compiler.h" +#include "util/u_memory.h" +#include "egllog.h" +#include "EGL/egl.h" /* for EGL_api_BIT */ + +#include "egl_st.h" + +#ifndef HAVE_DLADDR +#define HAVE_DLADDR 1 +#endif + +#if HAVE_DLADDR + +static const char * +egl_g3d_st_names[] = { +#define ST_PUBLIC(name, ...) #name, +#include "st_public_tmp.h" + NULL +}; + +static boolean +egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym) +{ + st_proc *procs = (st_proc *) stapi; + void *handle; + Dl_info info; + const char **name; + + if (!dladdr(sym, &info)) + return FALSE; + handle = dlopen(info.dli_fname, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE); + if (!handle) + return FALSE; + + for (name = egl_g3d_st_names; *name; name++) { + st_proc proc = (st_proc) dlsym(handle, *name); + if (!proc) { + _eglLog(_EGL_WARNING, "%s is missing in %s", *name, info.dli_fname); + memset(stapi, 0, sizeof(*stapi)); + dlclose(handle); + return FALSE; + } + *procs++ = proc; + } + + dlclose(handle); + return TRUE; +} + +#else /* HAVE_DLADDR */ + +static boolean +egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym) +{ +#define ST_PUBLIC(name, ...) stapi->name = name; +#include "st_public_tmp.h" + return TRUE; +} + +#endif /* HAVE_DLADDR */ + +static boolean +egl_g3d_init_st(struct egl_g3d_st *stapi, const char *api) +{ + void *handle, *sym; + boolean res = FALSE; + + /* already initialized */ + if (stapi->st_notify_swapbuffers != NULL) + return TRUE; + + handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL); + if (!handle) + return FALSE; + + sym = dlsym(handle, api); + if (sym && egl_g3d_fill_st(stapi, sym)) + res = TRUE; + + dlclose(handle); + return res; +} + +static struct { + const char *symbol; + EGLint api_bit; +} egl_g3d_st_info[NUM_EGL_G3D_STS] = { + { "st_api_OpenGL_ES1", EGL_OPENGL_ES_BIT }, + { "st_api_OpenVG", EGL_OPENVG_BIT }, + { "st_api_OpenGL_ES2", EGL_OPENGL_ES2_BIT }, + { "st_api_OpenGL", EGL_OPENGL_BIT }, +}; + +const struct egl_g3d_st * +egl_g3d_get_st(enum egl_g3d_st_api api) +{ + static struct egl_g3d_st all_trackers[NUM_EGL_G3D_STS]; + + if (egl_g3d_init_st(&all_trackers[api], egl_g3d_st_info[api].symbol)) { + all_trackers[api].api_bit = egl_g3d_st_info[api].api_bit; + return &all_trackers[api]; + } + else { + return NULL; + } +} diff --git a/src/gallium/state_trackers/egl/common/egl_st.h b/src/gallium/state_trackers/egl/common/egl_st.h new file mode 100644 index 00000000000..8fb464bd3d7 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_st.h @@ -0,0 +1,73 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _EGL_ST_H_ +#define _EGL_ST_H_ + +#include "GL/gl.h" /* for GL types */ +#include "GL/internal/glcore.h" /* for __GLcontextModes */ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "pipe/p_context.h" + +/* avoid calling st functions directly */ +#if 1 + +#define ST_SURFACE_FRONT_LEFT 0 +#define ST_SURFACE_BACK_LEFT 1 +#define ST_SURFACE_FRONT_RIGHT 2 +#define ST_SURFACE_BACK_RIGHT 3 + +#define ST_TEXTURE_2D 0x2 + +struct st_context; +struct st_framebuffer; +typedef void (*st_proc)(); + +#else +#include "state_tracker/st_public.h" +#endif + +/* remember to update egl_g3d_get_st() when update the enums */ +enum egl_g3d_st_api { + EGL_G3D_ST_OPENGL_ES = 0, + EGL_G3D_ST_OPENVG, + EGL_G3D_ST_OPENGL_ES2, + EGL_G3D_ST_OPENGL, + + NUM_EGL_G3D_STS +}; + +struct egl_g3d_st { +#define ST_PUBLIC(name, ret, ...) ret (*name)(__VA_ARGS__); +#include "st_public_tmp.h" + /* fields must be added here */ + EGLint api_bit; +}; + +const struct egl_g3d_st * +egl_g3d_get_st(enum egl_g3d_st_api api); + +#endif /* _EGL_ST_H_ */ diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h new file mode 100644 index 00000000000..72a9cec7ef1 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/native.h @@ -0,0 +1,277 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _NATIVE_H_ +#define _NATIVE_H_ + +#include "EGL/egl.h" /* for EGL native types */ +#include "GL/gl.h" /* for GL types needed by __GLcontextModes */ +#include "GL/internal/glcore.h" /* for __GLcontextModes */ + +#include "pipe/p_compiler.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "pipe/p_state.h" + +/** + * Only color buffers are listed. The others are allocated privately through, + * for example, st_renderbuffer_alloc_storage(). + */ +enum native_attachment { + NATIVE_ATTACHMENT_FRONT_LEFT, + NATIVE_ATTACHMENT_BACK_LEFT, + NATIVE_ATTACHMENT_FRONT_RIGHT, + NATIVE_ATTACHMENT_BACK_RIGHT, + + NUM_NATIVE_ATTACHMENTS +}; + +/** + * Enumerations for probe results. + */ +enum native_probe_result { + NATIVE_PROBE_UNKNOWN, + NATIVE_PROBE_FALLBACK, + NATIVE_PROBE_SUPPORTED, + NATIVE_PROBE_EXACT, +}; + +/** + * A probe object for display probe. + */ +struct native_probe { + int magic; + EGLNativeDisplayType display; + void *data; + + void (*destroy)(struct native_probe *nprobe); +}; + +struct native_surface { + void (*destroy)(struct native_surface *nsurf); + + /** + * Swap the front and back buffers so that the back buffer is visible. It + * is no-op if the surface is single-buffered. The contents of the back + * buffer after swapping may or may not be preserved. + */ + boolean (*swap_buffers)(struct native_surface *nsurf); + + /** + * Make the front buffer visible. In some native displays, changes to the + * front buffer might not be visible immediately and require manual flush. + */ + boolean (*flush_frontbuffer)(struct native_surface *nsurf); + + /** + * Validate the buffers of the surface. textures, if not NULL, points to an + * array of size NUM_NATIVE_ATTACHMENTS and the returned textures are owned + * by the caller. A sequence number is also returned. The caller can use + * it to check if anything has changed since the last call. Any of the + * pointers may be NULL and it indicates the caller has no interest in those + * values. + * + * If this function is called multiple times with different attachment + * masks, those not listed in the latest call might be destroyed. This + * behavior might change in the future. + */ + boolean (*validate)(struct native_surface *nsurf, uint attachment_mask, + unsigned int *seq_num, struct pipe_texture **textures, + int *width, int *height); + + /** + * Wait until all native commands affecting the surface has been executed. + */ + void (*wait)(struct native_surface *nsurf); +}; + +struct native_config { + /* __GLcontextModes should go away some day */ + __GLcontextModes mode; + enum pipe_format color_format; + enum pipe_format depth_format; + enum pipe_format stencil_format; + + /* treat it as an additional flag to mode.drawableType */ + boolean scanout_bit; +}; + +struct native_connector { + int dummy; +}; + +struct native_mode { + const char *desc; + int width, height; + int refresh_rate; +}; + +struct native_display_modeset; + +/** + * A pipe winsys abstracts the OS. A pipe screen abstracts the graphcis + * hardware. A native display consists of a pipe winsys, a pipe screen, and + * the native display server. + */ +struct native_display { + /** + * The pipe screen of the native display. + * + * Note that the "flush_frontbuffer" and "update_buffer" callbacks will be + * overridden. + */ + struct pipe_screen *screen; + + void (*destroy)(struct native_display *ndpy); + + /** + * Get the supported configs. The configs are owned by the display, but + * the returned array should be free()ed. + * + * The configs will be converted to EGL config by + * _eglConfigFromContextModesRec and validated by _eglValidateConfig. + * Those failing to pass the test will be skipped. + */ + const struct native_config **(*get_configs)(struct native_display *ndpy, + int *num_configs); + + /** + * Test if a pixmap is supported by the given config. Required unless no + * config has GLX_PIXMAP_BIT set. + * + * This function is usually called to find a config that supports a given + * pixmap. Thus, it is usually called with the same pixmap in a row. + */ + boolean (*is_pixmap_supported)(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf); + + /** + * Create a pipe context. + */ + struct pipe_context *(*create_context)(struct native_display *ndpy, + void *context_private); + + /** + * Create a window surface. Required unless no config has GLX_WINDOW_BIT + * set. + */ + struct native_surface *(*create_window_surface)(struct native_display *ndpy, + EGLNativeWindowType win, + const struct native_config *nconf); + + /** + * Create a pixmap surface. Required unless no config has GLX_PIXMAP_BIT + * set. + */ + struct native_surface *(*create_pixmap_surface)(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf); + + /** + * Create a pbuffer surface. Required unless no config has GLX_PBUFFER_BIT + * set. + */ + struct native_surface *(*create_pbuffer_surface)(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height); + + const struct native_display_modeset *modeset; +}; + +/** + * Mode setting interface of the native display. It exposes the mode setting + * capabilities of the underlying graphics hardware. + */ +struct native_display_modeset { + /** + * Get the available physical connectors and the number of CRTCs. + */ + const struct native_connector **(*get_connectors)(struct native_display *ndpy, + int *num_connectors, + int *num_crtcs); + + /** + * Get the current supported modes of a connector. The returned modes may + * change every time this function is called and those from previous calls + * might become invalid. + */ + const struct native_mode **(*get_modes)(struct native_display *ndpy, + const struct native_connector *nconn, + int *num_modes); + + /** + * Create a scan-out surface. Required unless no config has + * GLX_SCREEN_BIT_MESA set. + */ + struct native_surface *(*create_scanout_surface)(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height); + + /** + * Program the CRTC to output the surface to the given connectors with the + * given mode. When surface is not given, the CRTC is disabled. + * + * This interface does not export a way to query capabilities of the CRTCs. + * The native display usually needs to dynamically map the index to a CRTC + * that supports the given connectors. + */ + boolean (*program)(struct native_display *ndpy, int crtc_idx, + struct native_surface *nsurf, uint x, uint y, + const struct native_connector **nconns, int num_nconns, + const struct native_mode *nmode); +}; + +/** + * Test whether an attachment is set in the mask. + */ +static INLINE boolean +native_attachment_mask_test(uint mask, enum native_attachment att) +{ + return !!(mask & (1 << att)); +} + +/** + * Return a probe object for the given display. + * + * Note that the returned object may be cached and used by different native + * display modules. It allows fast probing when multiple modules probe the + * same display. + */ +struct native_probe * +native_create_probe(EGLNativeDisplayType dpy); + +/** + * Probe the probe object. + */ +enum native_probe_result +native_get_probe_result(struct native_probe *nprobe); + +const char * +native_get_name(void); + +struct native_display * +native_create_display(EGLNativeDisplayType dpy); + +#endif /* _NATIVE_H_ */ diff --git a/src/gallium/state_trackers/egl/common/st_public_tmp.h b/src/gallium/state_trackers/egl/common/st_public_tmp.h new file mode 100644 index 00000000000..507a0ec4027 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/st_public_tmp.h @@ -0,0 +1,20 @@ +ST_PUBLIC(st_create_context, struct st_context *, struct pipe_context *pipe, const __GLcontextModes *visual, struct st_context *share) +ST_PUBLIC(st_destroy_context, void, struct st_context *st) +ST_PUBLIC(st_copy_context_state, void, struct st_context *dst, struct st_context *src, uint mask) +ST_PUBLIC(st_create_framebuffer, struct st_framebuffer *, const __GLcontextModes *visual, enum pipe_format colorFormat, enum pipe_format depthFormat, enum pipe_format stencilFormat, uint width, uint height, void *privateData) +ST_PUBLIC(st_resize_framebuffer, void, struct st_framebuffer *stfb, uint width, uint height) +ST_PUBLIC(st_set_framebuffer_surface, void, struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface *surf) +ST_PUBLIC(st_get_framebuffer_dimensions, void, struct st_framebuffer *stfb, uint *width, uint *height) +ST_PUBLIC(st_get_framebuffer_surface, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface **surface) +ST_PUBLIC(st_get_framebuffer_texture, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_texture **texture) +ST_PUBLIC(st_framebuffer_private, void *, struct st_framebuffer *stfb) +ST_PUBLIC(st_unreference_framebuffer, void, struct st_framebuffer *stfb) +ST_PUBLIC(st_make_current, GLboolean, struct st_context *st, struct st_framebuffer *draw, struct st_framebuffer *read) +ST_PUBLIC(st_get_current, struct st_context *, void) +ST_PUBLIC(st_flush, void, struct st_context *st, uint pipeFlushFlags, struct pipe_fence_handle **fence) +ST_PUBLIC(st_finish, void, struct st_context *st) +ST_PUBLIC(st_notify_swapbuffers, void, struct st_framebuffer *stfb) +ST_PUBLIC(st_bind_texture_surface, int, struct pipe_surface *ps, int target, int level, enum pipe_format format) +ST_PUBLIC(st_unbind_texture_surface, int, struct pipe_surface *ps, int target, int level) +ST_PUBLIC(st_get_proc_address, st_proc, const char *procname) +#undef ST_PUBLIC diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c new file mode 100644 index 00000000000..d5baf2c2f05 --- /dev/null +++ b/src/gallium/state_trackers/egl/kms/native_kms.c @@ -0,0 +1,866 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include + +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "util/u_debug.h" +#include "util/u_memory.h" +#include "egllog.h" + +#include "native_kms.h" + +static boolean +kms_surface_validate(struct native_surface *nsurf, uint attachment_mask, + unsigned int *seq_num, struct pipe_texture **textures, + int *width, int *height) +{ + struct kms_surface *ksurf = kms_surface(nsurf); + struct kms_display *kdpy = ksurf->kdpy; + struct pipe_screen *screen = kdpy->base.screen; + struct pipe_texture templ, *ptex; + int att; + + if (attachment_mask) { + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.last_level = 0; + templ.width0 = ksurf->width; + templ.height0 = ksurf->height; + templ.depth0 = 1; + templ.format = ksurf->color_format; + templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + if (ksurf->type == KMS_SURFACE_TYPE_SCANOUT) + templ.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; + } + + /* create textures */ + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + /* delay the allocation */ + if (!native_attachment_mask_test(attachment_mask, att)) + continue; + + ptex = ksurf->textures[att]; + if (!ptex) { + ptex = screen->texture_create(screen, &templ); + ksurf->textures[att] = ptex; + } + + if (textures) { + textures[att] = NULL; + pipe_texture_reference(&textures[att], ptex); + } + } + + if (seq_num) + *seq_num = ksurf->sequence_number; + if (width) + *width = ksurf->width; + if (height) + *height = ksurf->height; + + return TRUE; +} + +/** + * Add textures as DRM framebuffers. + */ +static boolean +kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back) +{ + struct kms_surface *ksurf = kms_surface(nsurf); + struct kms_display *kdpy = ksurf->kdpy; + int num_framebuffers = (need_back) ? 2 : 1; + int i, err; + + for (i = 0; i < num_framebuffers; i++) { + struct kms_framebuffer *fb; + enum native_attachment natt; + unsigned int handle, stride; + uint block_bits; + + if (i == 0) { + fb = &ksurf->front_fb; + natt = NATIVE_ATTACHMENT_FRONT_LEFT; + } + else { + fb = &ksurf->back_fb; + natt = NATIVE_ATTACHMENT_BACK_LEFT; + } + + if (!fb->texture) { + /* make sure the texture has been allocated */ + kms_surface_validate(&ksurf->base, 1 << natt, NULL, NULL, NULL, NULL); + if (!ksurf->textures[natt]) + return FALSE; + + pipe_texture_reference(&fb->texture, ksurf->textures[natt]); + } + + /* already initialized */ + if (fb->buffer_id) + continue; + + /* TODO detect the real value */ + fb->is_passive = TRUE; + + if (!kdpy->api->local_handle_from_texture(kdpy->api, + kdpy->base.screen, fb->texture, &stride, &handle)) + return FALSE; + + block_bits = util_format_get_blocksizebits(ksurf->color_format); + err = drmModeAddFB(kdpy->fd, ksurf->width, ksurf->height, + block_bits, block_bits, stride, handle, &fb->buffer_id); + if (err) { + fb->buffer_id = 0; + return FALSE; + } + } + + return TRUE; +} + +static boolean +kms_surface_flush_frontbuffer(struct native_surface *nsurf) +{ +#ifdef DRM_MODE_FEATURE_DIRTYFB + struct kms_surface *ksurf = kms_surface(nsurf); + struct kms_display *kdpy = ksurf->kdpy; + + /* pbuffer is private */ + if (ksurf->type == KMS_SURFACE_TYPE_PBUFFER) + return TRUE; + + if (ksurf->front_fb.is_passive) + drmModeDirtyFB(kdpy->fd, ksurf->front_fb.buffer_id, NULL, 0); +#endif + + return TRUE; +} + +static boolean +kms_surface_swap_buffers(struct native_surface *nsurf) +{ + struct kms_surface *ksurf = kms_surface(nsurf); + struct kms_crtc *kcrtc = &ksurf->current_crtc; + struct kms_display *kdpy = ksurf->kdpy; + struct kms_framebuffer tmp_fb; + struct pipe_texture *tmp_texture; + int err; + + /* pbuffer is private */ + if (ksurf->type == KMS_SURFACE_TYPE_PBUFFER) + return TRUE; + + if (!ksurf->back_fb.buffer_id) { + if (!kms_surface_init_framebuffers(&ksurf->base, TRUE)) + return FALSE; + } + + if (ksurf->is_shown && kcrtc->crtc) { + err = drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id, + ksurf->back_fb.buffer_id, kcrtc->crtc->x, kcrtc->crtc->y, + kcrtc->connectors, kcrtc->num_connectors, &kcrtc->crtc->mode); + if (err) + return FALSE; + } + + /* swap the buffers */ + tmp_fb = ksurf->front_fb; + ksurf->front_fb = ksurf->back_fb; + ksurf->back_fb = tmp_fb; + + tmp_texture = ksurf->textures[NATIVE_ATTACHMENT_FRONT_LEFT]; + ksurf->textures[NATIVE_ATTACHMENT_FRONT_LEFT] = + ksurf->textures[NATIVE_ATTACHMENT_BACK_LEFT]; + ksurf->textures[NATIVE_ATTACHMENT_BACK_LEFT] = tmp_texture; + + /* the front/back textures are swapped */ + ksurf->sequence_number++; + + return TRUE; +} + +static void +kms_surface_wait(struct native_surface *nsurf) +{ + /* no-op */ +} + +static void +kms_surface_destroy(struct native_surface *nsurf) +{ + struct kms_surface *ksurf = kms_surface(nsurf); + int i; + + if (ksurf->current_crtc.crtc) + drmModeFreeCrtc(ksurf->current_crtc.crtc); + + if (ksurf->front_fb.buffer_id) + drmModeRmFB(ksurf->kdpy->fd, ksurf->front_fb.buffer_id); + pipe_texture_reference(&ksurf->front_fb.texture, NULL); + + if (ksurf->back_fb.buffer_id) + drmModeRmFB(ksurf->kdpy->fd, ksurf->back_fb.buffer_id); + pipe_texture_reference(&ksurf->back_fb.texture, NULL); + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { + struct pipe_texture *ptex = ksurf->textures[i]; + pipe_texture_reference(&ptex, NULL); + } + + free(ksurf); +} + +static struct kms_surface * +kms_display_create_surface(struct native_display *ndpy, + enum kms_surface_type type, + const struct native_config *nconf, + uint width, uint height) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct kms_config *kconf = kms_config(nconf); + struct kms_surface *ksurf; + + ksurf = CALLOC_STRUCT(kms_surface); + if (!ksurf) + return NULL; + + ksurf->kdpy = kdpy; + ksurf->type = type; + ksurf->color_format = kconf->base.color_format; + ksurf->width = width; + ksurf->height = height; + + ksurf->base.destroy = kms_surface_destroy; + ksurf->base.swap_buffers = kms_surface_swap_buffers; + ksurf->base.flush_frontbuffer = kms_surface_flush_frontbuffer; + ksurf->base.validate = kms_surface_validate; + ksurf->base.wait = kms_surface_wait; + + return ksurf; +} + +/** + * Choose a CRTC that supports all given connectors. + */ +static uint32_t +kms_display_choose_crtc(struct native_display *ndpy, + uint32_t *connectors, int num_connectors) +{ + struct kms_display *kdpy = kms_display(ndpy); + int idx; + + for (idx = 0; idx < kdpy->resources->count_crtcs; idx++) { + boolean found_crtc = TRUE; + int i, j; + + for (i = 0; i < num_connectors; i++) { + drmModeConnectorPtr connector; + int encoder_idx = -1; + + connector = drmModeGetConnector(kdpy->fd, connectors[i]); + if (!connector) { + found_crtc = FALSE; + break; + } + + /* find an encoder the CRTC supports */ + for (j = 0; j < connector->count_encoders; j++) { + drmModeEncoderPtr encoder = + drmModeGetEncoder(kdpy->fd, connector->encoders[j]); + if (encoder->possible_crtcs & (1 << idx)) { + encoder_idx = j; + break; + } + drmModeFreeEncoder(encoder); + } + + drmModeFreeConnector(connector); + if (encoder_idx < 0) { + found_crtc = FALSE; + break; + } + } + + if (found_crtc) + break; + } + + if (idx >= kdpy->resources->count_crtcs) { + _eglLog(_EGL_WARNING, + "failed to find a CRTC that supports the given %d connectors", + num_connectors); + return 0; + } + + return kdpy->resources->crtcs[idx]; +} + +/** + * Remember the original CRTC status and set the CRTC + */ +static boolean +kms_display_set_crtc(struct native_display *ndpy, int crtc_idx, + uint32_t buffer_id, uint32_t x, uint32_t y, + uint32_t *connectors, int num_connectors, + drmModeModeInfoPtr mode) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct kms_crtc *kcrtc = &kdpy->saved_crtcs[crtc_idx]; + uint32_t crtc_id; + int err; + + if (kcrtc->crtc) { + crtc_id = kcrtc->crtc->crtc_id; + } + else { + int count = 0, i; + + /* + * Choose the CRTC once. It could be more dynamic, but let's keep it + * simple for now. + */ + crtc_id = kms_display_choose_crtc(&kdpy->base, + connectors, num_connectors); + + /* save the original CRTC status */ + kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id); + if (!kcrtc->crtc) + return FALSE; + + for (i = 0; i < kdpy->num_connectors; i++) { + struct kms_connector *kconn = &kdpy->connectors[i]; + drmModeConnectorPtr connector = kconn->connector; + drmModeEncoderPtr encoder; + + encoder = drmModeGetEncoder(kdpy->fd, connector->encoder_id); + if (encoder) { + if (encoder->crtc_id == crtc_id) { + kcrtc->connectors[count++] = connector->connector_id; + if (count >= Elements(kcrtc->connectors)) + break; + } + drmModeFreeEncoder(encoder); + } + } + + kcrtc->num_connectors = count; + } + + err = drmModeSetCrtc(kdpy->fd, crtc_id, buffer_id, x, y, + connectors, num_connectors, mode); + if (err) { + drmModeFreeCrtc(kcrtc->crtc); + kcrtc->crtc = NULL; + kcrtc->num_connectors = 0; + + return FALSE; + } + + return TRUE; +} + +static boolean +kms_display_program(struct native_display *ndpy, int crtc_idx, + struct native_surface *nsurf, uint x, uint y, + const struct native_connector **nconns, int num_nconns, + const struct native_mode *nmode) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct kms_surface *ksurf = kms_surface(nsurf); + const struct kms_mode *kmode = kms_mode(nmode); + uint32_t connector_ids[32]; + uint32_t buffer_id; + drmModeModeInfo mode_tmp, *mode; + int i; + + if (num_nconns > Elements(connector_ids)) { + _eglLog(_EGL_WARNING, "too many connectors (%d)", num_nconns); + num_nconns = Elements(connector_ids); + } + + if (ksurf) { + if (!kms_surface_init_framebuffers(&ksurf->base, FALSE)) + return FALSE; + + buffer_id = ksurf->front_fb.buffer_id; + /* the mode argument of drmModeSetCrtc is not constified */ + mode_tmp = kmode->mode; + mode = &mode_tmp; + } + else { + /* disable the CRTC */ + buffer_id = 0; + mode = NULL; + num_nconns = 0; + } + + for (i = 0; i < num_nconns; i++) { + struct kms_connector *kconn = kms_connector(nconns[i]); + connector_ids[i] = kconn->connector->connector_id; + } + + if (!kms_display_set_crtc(&kdpy->base, crtc_idx, buffer_id, x, y, + connector_ids, num_nconns, mode)) { + _eglLog(_EGL_WARNING, "failed to set CRTC %d", crtc_idx); + + return FALSE; + } + + if (kdpy->shown_surfaces[crtc_idx]) + kdpy->shown_surfaces[crtc_idx]->is_shown = FALSE; + kdpy->shown_surfaces[crtc_idx] = ksurf; + + /* remember the settings for buffer swapping */ + if (ksurf) { + uint32_t crtc_id = kdpy->saved_crtcs[crtc_idx].crtc->crtc_id; + struct kms_crtc *kcrtc = &ksurf->current_crtc; + + if (kcrtc->crtc) + drmModeFreeCrtc(kcrtc->crtc); + kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id); + + assert(num_nconns < Elements(kcrtc->connectors)); + memcpy(kcrtc->connectors, connector_ids, + sizeof(*connector_ids) * num_nconns); + kcrtc->num_connectors = num_nconns; + + ksurf->is_shown = TRUE; + } + + return TRUE; +} + +static const struct native_mode ** +kms_display_get_modes(struct native_display *ndpy, + const struct native_connector *nconn, + int *num_modes) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct kms_connector *kconn = kms_connector(nconn); + const struct native_mode **nmodes_return; + int count, i; + + /* delete old data */ + if (kconn->connector) { + drmModeFreeConnector(kconn->connector); + free(kconn->kms_modes); + + kconn->connector = NULL; + kconn->kms_modes = NULL; + kconn->num_modes = 0; + } + + /* detect again */ + kconn->connector = drmModeGetConnector(kdpy->fd, kconn->connector_id); + if (!kconn->connector) + return NULL; + + count = kconn->connector->count_modes; + kconn->kms_modes = calloc(count, sizeof(*kconn->kms_modes)); + if (!kconn->kms_modes) { + drmModeFreeConnector(kconn->connector); + kconn->connector = NULL; + + return NULL; + } + + for (i = 0; i < count; i++) { + struct kms_mode *kmode = &kconn->kms_modes[i]; + drmModeModeInfoPtr mode = &kconn->connector->modes[i]; + + kmode->mode = *mode; + + kmode->base.desc = kmode->mode.name; + kmode->base.width = kmode->mode.hdisplay; + kmode->base.height = kmode->mode.vdisplay; + kmode->base.refresh_rate = kmode->mode.vrefresh / 1000; + } + + nmodes_return = malloc(count * sizeof(*nmodes_return)); + if (nmodes_return) { + for (i = 0; i < count; i++) + nmodes_return[i] = &kconn->kms_modes[i].base; + if (num_modes) + *num_modes = count; + } + + return nmodes_return; +} + +static const struct native_connector ** +kms_display_get_connectors(struct native_display *ndpy, int *num_connectors, + int *num_crtc) +{ + struct kms_display *kdpy = kms_display(ndpy); + const struct native_connector **connectors; + int i; + + if (!kdpy->connectors) { + kdpy->connectors = + calloc(kdpy->resources->count_connectors, sizeof(*kdpy->connectors)); + if (!kdpy->connectors) + return NULL; + + for (i = 0; i < kdpy->resources->count_connectors; i++) { + struct kms_connector *kconn = &kdpy->connectors[i]; + + kconn->connector_id = kdpy->resources->connectors[i]; + /* kconn->connector is allocated when the modes are asked */ + } + + kdpy->num_connectors = kdpy->resources->count_connectors; + } + + connectors = malloc(kdpy->num_connectors * sizeof(*connectors)); + if (connectors) { + for (i = 0; i < kdpy->num_connectors; i++) + connectors[i] = &kdpy->connectors[i].base; + if (num_connectors) + *num_connectors = kdpy->num_connectors; + } + + if (num_crtc) + *num_crtc = kdpy->resources->count_crtcs; + + return connectors; +} + +static struct native_surface * +kms_display_create_scanout_surface(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height) +{ + struct kms_surface *ksurf; + + ksurf = kms_display_create_surface(ndpy, + KMS_SURFACE_TYPE_SCANOUT, nconf, width, height); + return &ksurf->base; +} + +static struct native_surface * +kms_display_create_pbuffer_surface(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height) +{ + struct kms_surface *ksurf; + + ksurf = kms_display_create_surface(ndpy, + KMS_SURFACE_TYPE_PBUFFER, nconf, width, height); + return &ksurf->base; +} + +static struct pipe_context * +kms_display_create_context(struct native_display *ndpy, void *context_private) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct pipe_context *pctx; + + pctx = kdpy->api->create_context(kdpy->api, kdpy->base.screen); + if (pctx) + pctx->priv = context_private; + return pctx; +} + +static boolean +kms_display_is_format_supported(struct native_display *ndpy, + enum pipe_format fmt, boolean is_color) +{ + return ndpy->screen->is_format_supported(ndpy->screen, + fmt, PIPE_TEXTURE_2D, + (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET : + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); +} + +static const struct native_config ** +kms_display_get_configs(struct native_display *ndpy, int *num_configs) +{ + struct kms_display *kdpy = kms_display(ndpy); + const struct native_config **configs; + + /* first time */ + if (!kdpy->config) { + struct native_config *nconf; + enum pipe_format format; + + kdpy->config = calloc(1, sizeof(*kdpy->config)); + if (!kdpy->config) + return NULL; + + nconf = &kdpy->config->base; + + /* always double-buffered */ + nconf->mode.doubleBufferMode = TRUE; + + format = PIPE_FORMAT_A8R8G8B8_UNORM; + if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) { + format = PIPE_FORMAT_B8G8R8A8_UNORM; + if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) + format = PIPE_FORMAT_NONE; + } + if (format == PIPE_FORMAT_NONE) + return NULL; + + nconf->color_format = format; + nconf->mode.redBits = 8; + nconf->mode.greenBits = 8; + nconf->mode.blueBits = 8; + nconf->mode.alphaBits = 8; + nconf->mode.rgbBits = 32; + + format = PIPE_FORMAT_S8Z24_UNORM; + if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) { + format = PIPE_FORMAT_Z24S8_UNORM; + if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) + format = PIPE_FORMAT_NONE; + } + if (format != PIPE_FORMAT_NONE) { + nconf->depth_format = format; + nconf->stencil_format = format; + + nconf->mode.depthBits = 24; + nconf->mode.stencilBits = 8; + nconf->mode.haveDepthBuffer = TRUE; + nconf->mode.haveStencilBuffer = TRUE; + } + + nconf->scanout_bit = TRUE; + nconf->mode.drawableType = GLX_PBUFFER_BIT; + nconf->mode.swapMethod = GLX_SWAP_EXCHANGE_OML; + + nconf->mode.visualID = 0; + nconf->mode.visualType = EGL_NONE; + + nconf->mode.renderType = GLX_RGBA_BIT; + nconf->mode.rgbMode = TRUE; + nconf->mode.xRenderable = FALSE; + } + + configs = malloc(sizeof(*configs)); + if (configs) { + configs[0] = &kdpy->config->base; + if (num_configs) + *num_configs = 1; + } + + return configs; +} + +static void +kms_display_destroy(struct native_display *ndpy) +{ + struct kms_display *kdpy = kms_display(ndpy); + int i; + + if (kdpy->config) + free(kdpy->config); + + if (kdpy->connectors) { + for (i = 0; i < kdpy->num_connectors; i++) { + struct kms_connector *kconn = &kdpy->connectors[i]; + if (kconn->connector) { + drmModeFreeConnector(kconn->connector); + free(kconn->kms_modes); + } + } + free(kdpy->connectors); + } + + if (kdpy->shown_surfaces) + free(kdpy->shown_surfaces); + + if (kdpy->saved_crtcs) { + for (i = 0; i < kdpy->resources->count_crtcs; i++) { + struct kms_crtc *kcrtc = &kdpy->saved_crtcs[i]; + + if (kcrtc->crtc) { + /* restore crtc */ + drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id, + kcrtc->crtc->buffer_id, kcrtc->crtc->x, kcrtc->crtc->y, + kcrtc->connectors, kcrtc->num_connectors, + &kcrtc->crtc->mode); + + drmModeFreeCrtc(kcrtc->crtc); + } + } + free(kdpy->saved_crtcs); + } + + if (kdpy->resources) + drmModeFreeResources(kdpy->resources); + + if (kdpy->base.screen) + kdpy->base.screen->destroy(kdpy->base.screen); + + if (kdpy->fd >= 0) + drmClose(kdpy->fd); + + if (kdpy->api) + kdpy->api->destroy(kdpy->api); + free(kdpy); +} + +/** + * Initialize KMS and pipe screen. + */ +static boolean +kms_display_init_screen(struct native_display *ndpy) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct drm_create_screen_arg arg; + int fd; + + fd = drmOpen(kdpy->api->name, NULL); + if (fd < 0) { + _eglLog(_EGL_WARNING, "failed to open DRM device"); + return FALSE; + } + +#if 0 + if (drmSetMaster(fd)) { + _eglLog(_EGL_WARNING, "failed to become DRM master"); + return FALSE; + } +#endif + + memset(&arg, 0, sizeof(arg)); + arg.mode = DRM_CREATE_NORMAL; + kdpy->base.screen = kdpy->api->create_screen(kdpy->api, fd, &arg); + if (!kdpy->base.screen) { + _eglLog(_EGL_WARNING, "failed to create DRM screen"); + drmClose(fd); + return FALSE; + } + + kdpy->fd = fd; + + return TRUE; +} + +static struct native_display_modeset kms_display_modeset = { + .get_connectors = kms_display_get_connectors, + .get_modes = kms_display_get_modes, + .create_scanout_surface = kms_display_create_scanout_surface, + .program = kms_display_program +}; + +static struct native_display * +kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api) +{ + struct kms_display *kdpy; + + kdpy = CALLOC_STRUCT(kms_display); + if (!kdpy) + return NULL; + + kdpy->api = api; + if (!kdpy->api) { + _eglLog(_EGL_WARNING, "failed to create DRM API"); + free(kdpy); + return NULL; + } + + kdpy->fd = -1; + if (!kms_display_init_screen(&kdpy->base)) { + kms_display_destroy(&kdpy->base); + return NULL; + } + + /* resources are fixed, unlike crtc, connector, or encoder */ + kdpy->resources = drmModeGetResources(kdpy->fd); + if (!kdpy->resources) { + kms_display_destroy(&kdpy->base); + return NULL; + } + + kdpy->saved_crtcs = + calloc(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs)); + if (!kdpy->saved_crtcs) { + kms_display_destroy(&kdpy->base); + return NULL; + } + + kdpy->shown_surfaces = + calloc(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces)); + if (!kdpy->shown_surfaces) { + kms_display_destroy(&kdpy->base); + return NULL; + } + + kdpy->base.destroy = kms_display_destroy; + kdpy->base.get_configs = kms_display_get_configs; + kdpy->base.create_context = kms_display_create_context; + kdpy->base.create_pbuffer_surface = kms_display_create_pbuffer_surface; + + kdpy->base.modeset = &kms_display_modeset; + + return &kdpy->base; +} + +struct native_probe * +native_create_probe(EGLNativeDisplayType dpy) +{ + return NULL; +} + +enum native_probe_result +native_get_probe_result(struct native_probe *nprobe) +{ + return NATIVE_PROBE_UNKNOWN; +} + +/* the api is destroyed with the native display */ +static struct drm_api *drm_api; + +const char * +native_get_name(void) +{ + static char kms_name[32]; + + if (!drm_api) + drm_api = drm_api_create(); + + if (drm_api) + snprintf(kms_name, sizeof(kms_name), "KMS/%s", drm_api->name); + else + snprintf(kms_name, sizeof(kms_name), "KMS"); + + return kms_name; +} + +struct native_display * +native_create_display(EGLNativeDisplayType dpy) +{ + struct native_display *ndpy = NULL; + + if (!drm_api) + drm_api = drm_api_create(); + + if (drm_api) + ndpy = kms_create_display(dpy, drm_api); + + return ndpy; +} diff --git a/src/gallium/state_trackers/egl/kms/native_kms.h b/src/gallium/state_trackers/egl/kms/native_kms.h new file mode 100644 index 00000000000..095186e3cf3 --- /dev/null +++ b/src/gallium/state_trackers/egl/kms/native_kms.h @@ -0,0 +1,139 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _NATIVE_KMS_H_ +#define _NATIVE_KMS_H_ + +#include +#include + +#include "pipe/p_compiler.h" +#include "util/u_format.h" +#include "pipe/p_state.h" +#include "state_tracker/drm_api.h" + +#include "common/native.h" + +enum kms_surface_type { + KMS_SURFACE_TYPE_PBUFFER, + KMS_SURFACE_TYPE_SCANOUT +}; + +struct kms_config; +struct kms_connector; +struct kms_mode; + +struct kms_crtc { + drmModeCrtcPtr crtc; + uint32_t connectors[32]; + int num_connectors; +}; + +struct kms_display { + struct native_display base; + + int fd; + struct drm_api *api; + drmModeResPtr resources; + struct kms_config *config; + + struct kms_connector *connectors; + int num_connectors; + + struct kms_surface **shown_surfaces; + /* save the original settings of the CRTCs */ + struct kms_crtc *saved_crtcs; +}; + +struct kms_framebuffer { + struct pipe_texture *texture; + boolean is_passive; + + uint32_t buffer_id; +}; + +struct kms_surface { + struct native_surface base; + enum kms_surface_type type; + enum pipe_format color_format; + struct kms_display *kdpy; + int width, height; + + struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; + unsigned int sequence_number; + struct kms_framebuffer front_fb, back_fb; + + boolean is_shown; + struct kms_crtc current_crtc; +}; + +struct kms_config { + struct native_config base; +}; + +struct kms_connector { + struct native_connector base; + + uint32_t connector_id; + drmModeConnectorPtr connector; + struct kms_mode *kms_modes; + int num_modes; +}; + +struct kms_mode { + struct native_mode base; + drmModeModeInfo mode; +}; + +static INLINE struct kms_display * +kms_display(const struct native_display *ndpy) +{ + return (struct kms_display *) ndpy; +} + +static INLINE struct kms_surface * +kms_surface(const struct native_surface *nsurf) +{ + return (struct kms_surface *) nsurf; +} + +static INLINE struct kms_config * +kms_config(const struct native_config *nconf) +{ + return (struct kms_config *) nconf; +} + +static INLINE struct kms_connector * +kms_connector(const struct native_connector *nconn) +{ + return (struct kms_connector *) nconn; +} + +static INLINE struct kms_mode * +kms_mode(const struct native_mode *nmode) +{ + return (struct kms_mode *) nmode; +} + +#endif /* _NATIVE_KMS_H_ */ diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c new file mode 100644 index 00000000000..07f82d878c5 --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -0,0 +1,705 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "util/u_memory.h" +#include "util/u_math.h" +#include "util/u_format.h" +#include "pipe/p_compiler.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "state_tracker/drm_api.h" +#include "egllog.h" + +#include "native_x11.h" +#include "x11_screen.h" + +enum dri2_surface_type { + DRI2_SURFACE_TYPE_WINDOW, + DRI2_SURFACE_TYPE_PIXMAP, + DRI2_SURFACE_TYPE_PBUFFER +}; + +struct dri2_display { + struct native_display base; + Display *dpy; + boolean own_dpy; + + struct drm_api *api; + struct x11_screen *xscr; + int xscr_number; + + struct dri2_config *configs; + int num_configs; +}; + +struct dri2_surface { + struct native_surface base; + Drawable drawable; + enum dri2_surface_type type; + enum pipe_format color_format; + struct dri2_display *dri2dpy; + + struct pipe_texture *pbuffer_textures[NUM_NATIVE_ATTACHMENTS]; + boolean have_back, have_fake; + int width, height; + unsigned int sequence_number; +}; + +struct dri2_config { + struct native_config base; +}; + +static INLINE struct dri2_display * +dri2_display(const struct native_display *ndpy) +{ + return (struct dri2_display *) ndpy; +} + +static INLINE struct dri2_surface * +dri2_surface(const struct native_surface *nsurf) +{ + return (struct dri2_surface *) nsurf; +} + +static INLINE struct dri2_config * +dri2_config(const struct native_config *nconf) +{ + return (struct dri2_config *) nconf; +} + +static boolean +dri2_surface_flush_frontbuffer(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + + /* pbuffer is private */ + if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) + return TRUE; + + /* copy to real front buffer */ + if (dri2surf->have_fake) + x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, + 0, 0, dri2surf->width, dri2surf->height, + DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft); + + return TRUE; +} + +static boolean +dri2_surface_swap_buffers(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + + /* pbuffer is private */ + if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) + return TRUE; + + /* copy to front buffer */ + if (dri2surf->have_back) + x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, + 0, 0, dri2surf->width, dri2surf->height, + DRI2BufferBackLeft, DRI2BufferFrontLeft); + + /* and update fake front buffer */ + if (dri2surf->have_fake) + x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, + 0, 0, dri2surf->width, dri2surf->height, + DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); + + return TRUE; +} + +static boolean +dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask, + unsigned int *seq_num, struct pipe_texture **textures, + int *width, int *height) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + unsigned int dri2atts[NUM_NATIVE_ATTACHMENTS]; + struct pipe_texture templ; + struct x11_drawable_buffer *xbufs; + int num_ins, num_outs, att, i; + + if (attachment_mask) { + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.last_level = 0; + templ.width0 = dri2surf->width; + templ.height0 = dri2surf->height; + templ.depth0 = 1; + templ.format = dri2surf->color_format; + templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + + if (textures) + memset(textures, 0, sizeof(*textures) * NUM_NATIVE_ATTACHMENTS); + } + + /* create textures for pbuffer */ + if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) { + struct pipe_screen *screen = dri2dpy->base.screen; + + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + struct pipe_texture *ptex = dri2surf->pbuffer_textures[att]; + + /* delay the allocation */ + if (!native_attachment_mask_test(attachment_mask, att)) + continue; + + if (!ptex) { + ptex = screen->texture_create(screen, &templ); + dri2surf->pbuffer_textures[att] = ptex; + } + + if (textures) + pipe_texture_reference(&textures[att], ptex); + } + + if (seq_num) + *seq_num = dri2surf->sequence_number; + if (width) + *width = dri2surf->width; + if (height) + *height = dri2surf->height; + + return TRUE; + } + + /* prepare the attachments */ + num_ins = 0; + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + if (native_attachment_mask_test(attachment_mask, att)) { + unsigned int dri2att; + + switch (att) { + case NATIVE_ATTACHMENT_FRONT_LEFT: + dri2att = DRI2BufferFrontLeft; + break; + case NATIVE_ATTACHMENT_BACK_LEFT: + dri2att = DRI2BufferBackLeft; + break; + case NATIVE_ATTACHMENT_FRONT_RIGHT: + dri2att = DRI2BufferFrontRight; + break; + case NATIVE_ATTACHMENT_BACK_RIGHT: + dri2att = DRI2BufferBackRight; + break; + default: + assert(0); + dri2att = 0; + break; + } + + dri2atts[num_ins] = dri2att; + num_ins++; + } + } + + dri2surf->have_back = FALSE; + dri2surf->have_fake = FALSE; + + /* remember old geometry */ + templ.width0 = dri2surf->width; + templ.height0 = dri2surf->height; + + xbufs = x11_drawable_get_buffers(dri2dpy->xscr, dri2surf->drawable, + &dri2surf->width, &dri2surf->height, + dri2atts, FALSE, num_ins, &num_outs); + if (!xbufs) + return FALSE; + + if (templ.width0 != dri2surf->width || templ.height0 != dri2surf->height) { + /* are there cases where the buffers change and the geometry doesn't? */ + dri2surf->sequence_number++; + + templ.width0 = dri2surf->width; + templ.height0 = dri2surf->height; + } + + for (i = 0; i < num_outs; i++) { + struct x11_drawable_buffer *xbuf = &xbufs[i]; + const char *desc; + enum native_attachment natt; + + switch (xbuf->attachment) { + case DRI2BufferFrontLeft: + natt = NATIVE_ATTACHMENT_FRONT_LEFT; + desc = "DRI2 Front Buffer"; + break; + case DRI2BufferFakeFrontLeft: + natt = NATIVE_ATTACHMENT_FRONT_LEFT; + desc = "DRI2 Fake Front Buffer"; + dri2surf->have_fake = TRUE; + break; + case DRI2BufferBackLeft: + natt = NATIVE_ATTACHMENT_BACK_LEFT; + desc = "DRI2 Back Buffer"; + dri2surf->have_back = TRUE; + break; + default: + desc = NULL; + break; + } + + if (!desc || !native_attachment_mask_test(attachment_mask, natt) || + (textures && textures[natt])) { + if (!desc) + _eglLog(_EGL_WARNING, "unknown buffer %d", xbuf->attachment); + else if (!native_attachment_mask_test(attachment_mask, natt)) + _eglLog(_EGL_WARNING, "unexpected buffer %d", xbuf->attachment); + else + _eglLog(_EGL_WARNING, "both real and fake front buffers are listed"); + continue; + } + + if (textures) { + struct pipe_texture *ptex = + dri2dpy->api->texture_from_shared_handle(dri2dpy->api, + dri2dpy->base.screen, &templ, + desc, xbuf->pitch, xbuf->name); + if (ptex) { + /* the caller owns the textures */ + textures[natt] = ptex; + } + } + } + + free(xbufs); + + if (seq_num) + *seq_num = dri2surf->sequence_number; + if (width) + *width = dri2surf->width; + if (height) + *height = dri2surf->height; + + return TRUE; +} + +static void +dri2_surface_wait(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + + if (dri2surf->have_fake) { + x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, + 0, 0, dri2surf->width, dri2surf->height, + DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); + } +} + +static void +dri2_surface_destroy(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + int i; + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { + struct pipe_texture *ptex = dri2surf->pbuffer_textures[i]; + pipe_texture_reference(&ptex, NULL); + } + + if (dri2surf->drawable) + x11_drawable_enable_dri2(dri2surf->dri2dpy->xscr, + dri2surf->drawable, FALSE); + free(dri2surf); +} + +static struct dri2_surface * +dri2_display_create_surface(struct native_display *ndpy, + enum dri2_surface_type type, + Drawable drawable, + const struct native_config *nconf) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + struct dri2_config *dri2conf = dri2_config(nconf); + struct dri2_surface *dri2surf; + + dri2surf = CALLOC_STRUCT(dri2_surface); + if (!dri2surf) + return NULL; + + if (drawable) + x11_drawable_enable_dri2(dri2dpy->xscr, drawable, TRUE); + + dri2surf->dri2dpy = dri2dpy; + dri2surf->type = type; + dri2surf->drawable = drawable; + dri2surf->color_format = dri2conf->base.color_format; + + dri2surf->base.destroy = dri2_surface_destroy; + dri2surf->base.swap_buffers = dri2_surface_swap_buffers; + dri2surf->base.flush_frontbuffer = dri2_surface_flush_frontbuffer; + dri2surf->base.validate = dri2_surface_validate; + dri2surf->base.wait = dri2_surface_wait; + + return dri2surf; +} + +static struct native_surface * +dri2_display_create_window_surface(struct native_display *ndpy, + EGLNativeWindowType win, + const struct native_config *nconf) +{ + struct dri2_surface *dri2surf; + + dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_WINDOW, + (Drawable) win, nconf); + return (dri2surf) ? &dri2surf->base : NULL; +} + +static struct native_surface * +dri2_display_create_pixmap_surface(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf) +{ + struct dri2_surface *dri2surf; + + dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_PIXMAP, + (Drawable) pix, nconf); + return (dri2surf) ? &dri2surf->base : NULL; +} + +static struct native_surface * +dri2_display_create_pbuffer_surface(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height) +{ + struct dri2_surface *dri2surf; + + dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_PBUFFER, + (Drawable) None, nconf); + if (dri2surf) { + dri2surf->width = width; + dri2surf->height = height; + } + return (dri2surf) ? &dri2surf->base : NULL; +} + +static struct pipe_context * +dri2_display_create_context(struct native_display *ndpy, void *context_private) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + struct pipe_context *pctx; + + pctx = dri2dpy->api->create_context(dri2dpy->api, dri2dpy->base.screen); + if (pctx) + pctx->priv = context_private; + return pctx; +} + +static int +choose_color_format(const __GLcontextModes *mode, enum pipe_format formats[32]) +{ + int count = 0; + + switch (mode->rgbBits) { + case 32: + formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; + formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; + break; + case 24: + formats[count++] = PIPE_FORMAT_X8R8G8B8_UNORM; + formats[count++] = PIPE_FORMAT_B8G8R8X8_UNORM; + formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; + formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; + break; + case 16: + formats[count++] = PIPE_FORMAT_R5G6B5_UNORM; + break; + default: + break; + } + + return count; +} + +static int +choose_depth_stencil_format(const __GLcontextModes *mode, + enum pipe_format formats[32]) +{ + int count = 0; + + switch (mode->depthBits) { + case 32: + formats[count++] = PIPE_FORMAT_Z32_UNORM; + break; + case 24: + if (mode->stencilBits) { + formats[count++] = PIPE_FORMAT_S8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24S8_UNORM; + } + else { + formats[count++] = PIPE_FORMAT_X8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24X8_UNORM; + } + break; + case 16: + formats[count++] = PIPE_FORMAT_Z16_UNORM; + break; + default: + break; + } + + return count; +} + +static boolean +is_format_supported(struct pipe_screen *screen, + enum pipe_format fmt, boolean is_color) +{ + return screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D, + (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET : + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); +} + +static boolean +dri2_display_convert_config(struct native_display *ndpy, + const __GLcontextModes *mode, + struct native_config *nconf) +{ + enum pipe_format formats[32]; + int num_formats, i; + + if (!(mode->renderType & GLX_RGBA_BIT) || !mode->rgbMode) + return FALSE; + + /* skip single-buffered configs */ + if (!mode->doubleBufferMode) + return FALSE; + + nconf->mode = *mode; + nconf->mode.renderType = GLX_RGBA_BIT; + nconf->mode.rgbMode = TRUE; + /* pbuffer is allocated locally and is always supported */ + nconf->mode.drawableType |= GLX_PBUFFER_BIT; + /* the swap method is always copy */ + nconf->mode.swapMethod = GLX_SWAP_COPY_OML; + + /* fix up */ + nconf->mode.rgbBits = + nconf->mode.redBits + nconf->mode.greenBits + + nconf->mode.blueBits + nconf->mode.alphaBits; + if (!(nconf->mode.drawableType & GLX_WINDOW_BIT)) { + nconf->mode.visualID = 0; + nconf->mode.visualType = GLX_NONE; + } + if (!(nconf->mode.drawableType & GLX_PBUFFER_BIT)) { + nconf->mode.bindToTextureRgb = FALSE; + nconf->mode.bindToTextureRgba = FALSE; + } + + nconf->color_format = PIPE_FORMAT_NONE; + nconf->depth_format = PIPE_FORMAT_NONE; + nconf->stencil_format = PIPE_FORMAT_NONE; + + /* choose color format */ + num_formats = choose_color_format(mode, formats); + for (i = 0; i < num_formats; i++) { + if (is_format_supported(ndpy->screen, formats[i], TRUE)) { + nconf->color_format = formats[i]; + break; + } + } + if (nconf->color_format == PIPE_FORMAT_NONE) + return FALSE; + + /* choose depth/stencil format */ + num_formats = choose_depth_stencil_format(mode, formats); + for (i = 0; i < num_formats; i++) { + if (is_format_supported(ndpy->screen, formats[i], FALSE)) { + nconf->depth_format = formats[i]; + nconf->stencil_format = formats[i]; + break; + } + } + if ((nconf->mode.depthBits && nconf->depth_format == PIPE_FORMAT_NONE) || + (nconf->mode.stencilBits && nconf->stencil_format == PIPE_FORMAT_NONE)) + return FALSE; + + return TRUE; +} + +static const struct native_config ** +dri2_display_get_configs(struct native_display *ndpy, int *num_configs) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + const struct native_config **configs; + int i; + + /* first time */ + if (!dri2dpy->configs) { + const __GLcontextModes *modes; + int num_modes, count; + + modes = x11_screen_get_glx_configs(dri2dpy->xscr); + if (!modes) + return NULL; + num_modes = x11_context_modes_count(modes); + + dri2dpy->configs = calloc(num_modes, sizeof(*dri2dpy->configs)); + if (!dri2dpy->configs) + return NULL; + + count = 0; + for (i = 0; i < num_modes; i++) { + struct native_config *nconf = &dri2dpy->configs[count].base; + if (dri2_display_convert_config(&dri2dpy->base, modes, nconf)) + count++; + modes = modes->next; + } + + dri2dpy->num_configs = count; + } + + configs = malloc(dri2dpy->num_configs * sizeof(*configs)); + if (configs) { + for (i = 0; i < dri2dpy->num_configs; i++) + configs[i] = (const struct native_config *) &dri2dpy->configs[i]; + if (num_configs) + *num_configs = dri2dpy->num_configs; + } + + return configs; +} + +static boolean +dri2_display_is_pixmap_supported(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + uint depth, nconf_depth; + + depth = x11_drawable_get_depth(dri2dpy->xscr, (Drawable) pix); + nconf_depth = util_format_get_blocksizebits(nconf->color_format); + + /* simple depth match for now */ + return (depth == nconf_depth || (depth == 24 && depth + 8 == nconf_depth)); +} + +static void +dri2_display_destroy(struct native_display *ndpy) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + + if (dri2dpy->configs) + free(dri2dpy->configs); + + if (dri2dpy->base.screen) + dri2dpy->base.screen->destroy(dri2dpy->base.screen); + + if (dri2dpy->xscr) + x11_screen_destroy(dri2dpy->xscr); + if (dri2dpy->own_dpy) + XCloseDisplay(dri2dpy->dpy); + if (dri2dpy->api && dri2dpy->api->destroy) + dri2dpy->api->destroy(dri2dpy->api); + free(dri2dpy); +} + +/** + * Initialize DRI2 and pipe screen. + */ +static boolean +dri2_display_init_screen(struct native_display *ndpy) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + const char *driver = dri2dpy->api->name; + struct drm_create_screen_arg arg; + int fd; + + if (!x11_screen_support(dri2dpy->xscr, X11_SCREEN_EXTENSION_DRI2) || + !x11_screen_support(dri2dpy->xscr, X11_SCREEN_EXTENSION_GLX)) { + _eglLog(_EGL_WARNING, "GLX/DRI2 is not supported"); + return FALSE; + } + + fd = x11_screen_enable_dri2(dri2dpy->xscr, driver); + if (fd < 0) + return FALSE; + + memset(&arg, 0, sizeof(arg)); + arg.mode = DRM_CREATE_NORMAL; + dri2dpy->base.screen = dri2dpy->api->create_screen(dri2dpy->api, fd, &arg); + if (!dri2dpy->base.screen) { + _eglLog(_EGL_WARNING, "failed to create DRM screen"); + return FALSE; + } + + return TRUE; +} + +struct native_display * +x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api) +{ + struct dri2_display *dri2dpy; + + dri2dpy = CALLOC_STRUCT(dri2_display); + if (!dri2dpy) + return NULL; + + dri2dpy->api = api; + if (!dri2dpy->api) { + _eglLog(_EGL_WARNING, "failed to create DRM API"); + free(dri2dpy); + return NULL; + } + + dri2dpy->dpy = dpy; + if (!dri2dpy->dpy) { + dri2dpy->dpy = XOpenDisplay(NULL); + if (!dri2dpy->dpy) { + dri2_display_destroy(&dri2dpy->base); + return NULL; + } + dri2dpy->own_dpy = TRUE; + } + + dri2dpy->xscr_number = DefaultScreen(dri2dpy->dpy); + dri2dpy->xscr = x11_screen_create(dri2dpy->dpy, dri2dpy->xscr_number); + if (!dri2dpy->xscr) { + dri2_display_destroy(&dri2dpy->base); + return NULL; + } + + if (!dri2_display_init_screen(&dri2dpy->base)) { + dri2_display_destroy(&dri2dpy->base); + return NULL; + } + + dri2dpy->base.destroy = dri2_display_destroy; + dri2dpy->base.get_configs = dri2_display_get_configs; + dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported; + dri2dpy->base.create_context = dri2_display_create_context; + dri2dpy->base.create_window_surface = dri2_display_create_window_surface; + dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface; + dri2dpy->base.create_pbuffer_surface = dri2_display_create_pbuffer_surface; + + return &dri2dpy->base; +} diff --git a/src/gallium/state_trackers/egl/x11/native_x11.c b/src/gallium/state_trackers/egl/x11/native_x11.c new file mode 100644 index 00000000000..695ab88010b --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/native_x11.c @@ -0,0 +1,148 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include "util/u_debug.h" +#include "util/u_memory.h" +#include "state_tracker/drm_api.h" +#include "egllog.h" + +#include "native_x11.h" +#include "x11_screen.h" + +#define X11_PROBE_MAGIC 0x11980BE /* "X11PROBE" */ + +static struct drm_api *api; + +static void +x11_probe_destroy(struct native_probe *nprobe) +{ + if (nprobe->data) + free(nprobe->data); + free(nprobe); +} + +struct native_probe * +native_create_probe(EGLNativeDisplayType dpy) +{ + struct native_probe *nprobe; + struct x11_screen *xscr; + int scr; + const char *driver_name = NULL; + Display *xdpy; + + nprobe = CALLOC_STRUCT(native_probe); + if (!nprobe) + return NULL; + + xdpy = dpy; + if (!xdpy) { + xdpy = XOpenDisplay(NULL); + if (!xdpy) { + free(nprobe); + return NULL; + } + } + + scr = DefaultScreen(xdpy); + xscr = x11_screen_create(xdpy, scr); + if (xscr) { + if (x11_screen_support(xscr, X11_SCREEN_EXTENSION_DRI2)) { + driver_name = x11_screen_probe_dri2(xscr); + nprobe->data = strdup(driver_name); + } + + x11_screen_destroy(xscr); + } + + if (xdpy != dpy) + XCloseDisplay(xdpy); + + nprobe->magic = X11_PROBE_MAGIC; + nprobe->display = dpy; + + nprobe->destroy = x11_probe_destroy; + + return nprobe; +} + +enum native_probe_result +native_get_probe_result(struct native_probe *nprobe) +{ + if (!nprobe || nprobe->magic != X11_PROBE_MAGIC) + return NATIVE_PROBE_UNKNOWN; + + if (!api) + api = drm_api_create(); + + /* this is a software driver */ + if (!api) + return NATIVE_PROBE_SUPPORTED; + + /* the display does not support DRI2 or the driver mismatches */ + if (!nprobe->data || strcmp(api->name, (const char *) nprobe->data) != 0) + return NATIVE_PROBE_FALLBACK; + + return NATIVE_PROBE_EXACT; +} + +const char * +native_get_name(void) +{ + static char x11_name[32]; + + if (!api) + api = drm_api_create(); + + if (api) + snprintf(x11_name, sizeof(x11_name), "X11/%s", api->name); + else + snprintf(x11_name, sizeof(x11_name), "X11"); + + return x11_name; +} + +struct native_display * +native_create_display(EGLNativeDisplayType dpy) +{ + struct native_display *ndpy = NULL; + boolean force_sw; + + if (!api) + api = drm_api_create(); + + force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE); + if (api && !force_sw) { + ndpy = x11_create_dri2_display(dpy, api); + } + + if (!ndpy) { + EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING; + + _eglLog(level, "use software fallback"); + ndpy = x11_create_ximage_display(dpy, TRUE); + } + + return ndpy; +} diff --git a/src/gallium/state_trackers/egl/x11/native_x11.h b/src/gallium/state_trackers/egl/x11/native_x11.h new file mode 100644 index 00000000000..622ddac5df6 --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/native_x11.h @@ -0,0 +1,37 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _NATIVE_X11_H_ +#define _NATIVE_X11_H_ + +#include "state_tracker/drm_api.h" +#include "common/native.h" + +struct native_display * +x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm); + +struct native_display * +x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api); + +#endif /* _NATIVE_X11_H_ */ diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c new file mode 100644 index 00000000000..dfa8df22234 --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -0,0 +1,694 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "util/u_memory.h" +#include "util/u_math.h" +#include "util/u_format.h" +#include "pipe/p_compiler.h" +#include "pipe/internal/p_winsys_screen.h" +#include "softpipe/sp_winsys.h" +#include "egllog.h" + +#include "sw_winsys.h" +#include "native_x11.h" +#include "x11_screen.h" + +enum ximage_surface_type { + XIMAGE_SURFACE_TYPE_WINDOW, + XIMAGE_SURFACE_TYPE_PIXMAP, + XIMAGE_SURFACE_TYPE_PBUFFER +}; + +struct ximage_display { + struct native_display base; + Display *dpy; + boolean own_dpy; + + struct x11_screen *xscr; + int xscr_number; + + boolean use_xshm; + + struct pipe_winsys *winsys; + struct ximage_config *configs; + int num_configs; +}; + +struct ximage_buffer { + XImage *ximage; + + struct pipe_texture *texture; + XShmSegmentInfo *shm_info; + boolean xshm_attached; +}; + +struct ximage_surface { + struct native_surface base; + Drawable drawable; + enum ximage_surface_type type; + enum pipe_format color_format; + XVisualInfo visual; + struct ximage_display *xdpy; + + int width, height; + GC gc; + + struct ximage_buffer buffers[NUM_NATIVE_ATTACHMENTS]; + unsigned int sequence_number; +}; + +struct ximage_config { + struct native_config base; + const XVisualInfo *visual; +}; + +static INLINE struct ximage_display * +ximage_display(const struct native_display *ndpy) +{ + return (struct ximage_display *) ndpy; +} + +static INLINE struct ximage_surface * +ximage_surface(const struct native_surface *nsurf) +{ + return (struct ximage_surface *) nsurf; +} + +static INLINE struct ximage_config * +ximage_config(const struct native_config *nconf) +{ + return (struct ximage_config *) nconf; +} + +static void +ximage_surface_free_buffer(struct native_surface *nsurf, + enum native_attachment which) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_buffer *xbuf = &xsurf->buffers[which]; + + pipe_texture_reference(&xbuf->texture, NULL); + + if (xbuf->shm_info) { + if (xbuf->xshm_attached) + XShmDetach(xsurf->xdpy->dpy, xbuf->shm_info); + if (xbuf->shm_info->shmaddr != (void *) -1) + shmdt(xbuf->shm_info->shmaddr); + if (xbuf->shm_info->shmid != -1) + shmctl(xbuf->shm_info->shmid, IPC_RMID, 0); + + xbuf->shm_info->shmaddr = (void *) -1; + xbuf->shm_info->shmid = -1; + } +} + +static boolean +ximage_surface_alloc_buffer(struct native_surface *nsurf, + enum native_attachment which) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_buffer *xbuf = &xsurf->buffers[which]; + struct pipe_screen *screen = xsurf->xdpy->base.screen; + struct pipe_texture templ; + + /* free old data */ + if (xbuf->texture) + ximage_surface_free_buffer(&xsurf->base, which); + + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.format = xsurf->color_format; + templ.width0 = xsurf->width; + templ.height0 = xsurf->height; + templ.depth0 = 1; + templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + + if (xbuf->shm_info) { + struct pipe_buffer *pbuf; + unsigned stride, size; + void *addr = NULL; + + stride = util_format_get_stride(xsurf->color_format, xsurf->width); + /* alignment should depend on visual? */ + stride = align(stride, 4); + size = stride * xsurf->height; + + /* create and attach shm object */ + xbuf->shm_info->shmid = shmget(IPC_PRIVATE, size, 0755); + if (xbuf->shm_info->shmid != -1) { + xbuf->shm_info->shmaddr = + shmat(xbuf->shm_info->shmid, NULL, 0); + if (xbuf->shm_info->shmaddr != (void *) -1) { + if (XShmAttach(xsurf->xdpy->dpy, xbuf->shm_info)) { + addr = xbuf->shm_info->shmaddr; + xbuf->xshm_attached = TRUE; + } + } + } + + if (addr) { + pbuf = screen->user_buffer_create(screen, addr, size); + if (pbuf) { + xbuf->texture = + screen->texture_blanket(screen, &templ, &stride, pbuf); + pipe_buffer_reference(&pbuf, NULL); + } + } + } + else { + xbuf->texture = screen->texture_create(screen, &templ); + } + + /* clean up the buffer if allocation failed */ + if (!xbuf->texture) + ximage_surface_free_buffer(&xsurf->base, which); + + return (xbuf->texture != NULL); +} + +static boolean +ximage_surface_draw_buffer(struct native_surface *nsurf, + enum native_attachment which) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_buffer *xbuf = &xsurf->buffers[which]; + struct pipe_screen *screen = xsurf->xdpy->base.screen; + struct pipe_transfer *transfer; + + if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER) + return TRUE; + + assert(xsurf->drawable && xbuf->ximage && xbuf->texture); + + transfer = screen->get_tex_transfer(screen, xbuf->texture, + 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, xsurf->width, xsurf->height); + if (!transfer) + return FALSE; + + xbuf->ximage->bytes_per_line = transfer->stride; + xbuf->ximage->data = screen->transfer_map(screen, transfer); + if (!xbuf->ximage->data) { + screen->tex_transfer_destroy(transfer); + return FALSE; + } + + + if (xbuf->shm_info) + XShmPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, + xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height, False); + else + XPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, + xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height); + + xbuf->ximage->data = NULL; + screen->transfer_unmap(screen, transfer); + + /* + * softpipe allows the pipe transfer to be re-used, but we don't want to + * rely on that behavior. + */ + screen->tex_transfer_destroy(transfer); + + XSync(xsurf->xdpy->dpy, FALSE); + + return TRUE; +} + +static boolean +ximage_surface_flush_frontbuffer(struct native_surface *nsurf) +{ + return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); +} + +static boolean +ximage_surface_swap_buffers(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_buffer *xfront, *xback, xtmp; + + xfront = &xsurf->buffers[NATIVE_ATTACHMENT_FRONT_LEFT]; + xback = &xsurf->buffers[NATIVE_ATTACHMENT_BACK_LEFT]; + + /* draw the back buffer directly if there is no front buffer */ + if (!xfront->texture) + return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_BACK_LEFT); + + /* swap the buffers */ + xtmp = *xfront; + *xfront = *xback; + *xback = xtmp; + + /* the front/back textures are swapped */ + xsurf->sequence_number++; + + return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); +} + +static void +ximage_surface_update_geometry(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + Status ok; + Window root; + int x, y; + unsigned int w, h, border, depth; + + /* pbuffer has fixed geometry */ + if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER) + return; + + ok = XGetGeometry(xsurf->xdpy->dpy, xsurf->drawable, + &root, &x, &y, &w, &h, &border, &depth); + if (ok) { + xsurf->width = w; + xsurf->height = h; + } +} + +static boolean +ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask, + unsigned int *seq_num, struct pipe_texture **textures, + int *width, int *height) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + boolean new_buffers = FALSE; + int att; + + ximage_surface_update_geometry(&xsurf->base); + + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + struct ximage_buffer *xbuf = &xsurf->buffers[att]; + + /* delay the allocation */ + if (!native_attachment_mask_test(attachment_mask, att)) + continue; + + /* reallocate the texture */ + if (!xbuf->texture || + xsurf->width != xbuf->texture->width0 || + xsurf->height != xbuf->texture->height0) { + new_buffers = TRUE; + if (ximage_surface_alloc_buffer(&xsurf->base, att)) { + /* update ximage */ + if (xbuf->ximage) { + xbuf->ximage->width = xsurf->width; + xbuf->ximage->height = xsurf->height; + } + } + } + + if (textures) { + textures[att] = NULL; + pipe_texture_reference(&textures[att], xbuf->texture); + } + } + + /* increase the sequence number so that caller knows */ + if (new_buffers) + xsurf->sequence_number++; + + if (seq_num) + *seq_num = xsurf->sequence_number; + if (width) + *width = xsurf->width; + if (height) + *height = xsurf->height; + + return TRUE; +} + +static void +ximage_surface_wait(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + XSync(xsurf->xdpy->dpy, FALSE); + /* TODO XGetImage and update the front texture */ +} + +static void +ximage_surface_destroy(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + int i; + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { + struct ximage_buffer *xbuf = &xsurf->buffers[i]; + ximage_surface_free_buffer(&xsurf->base, i); + /* xbuf->shm_info is owned by xbuf->ximage? */ + if (xbuf->ximage) { + XDestroyImage(xbuf->ximage); + xbuf->ximage = NULL; + } + } + + if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) + XFreeGC(xsurf->xdpy->dpy, xsurf->gc); + free(xsurf); +} + +static struct ximage_surface * +ximage_display_create_surface(struct native_display *ndpy, + enum ximage_surface_type type, + Drawable drawable, + const struct native_config *nconf) +{ + struct ximage_display *xdpy = ximage_display(ndpy); + struct ximage_config *xconf = ximage_config(nconf); + struct ximage_surface *xsurf; + int i; + + xsurf = CALLOC_STRUCT(ximage_surface); + if (!xsurf) + return NULL; + + xsurf->xdpy = xdpy; + xsurf->type = type; + xsurf->color_format = xconf->base.color_format; + xsurf->drawable = drawable; + + if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) { + xsurf->drawable = drawable; + xsurf->visual = *xconf->visual; + + xsurf->gc = XCreateGC(xdpy->dpy, xsurf->drawable, 0, NULL); + if (!xsurf->gc) { + free(xsurf); + return NULL; + } + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { + struct ximage_buffer *xbuf = &xsurf->buffers[i]; + + if (xdpy->use_xshm) { + xbuf->shm_info = calloc(1, sizeof(*xbuf->shm_info)); + if (xbuf->shm_info) { + /* initialize shm info */ + xbuf->shm_info->shmid = -1; + xbuf->shm_info->shmaddr = (void *) -1; + xbuf->shm_info->readOnly = TRUE; + + xbuf->ximage = XShmCreateImage(xsurf->xdpy->dpy, + xsurf->visual.visual, + xsurf->visual.depth, + ZPixmap, NULL, + xbuf->shm_info, + 0, 0); + } + } + else { + xbuf->ximage = XCreateImage(xsurf->xdpy->dpy, + xsurf->visual.visual, + xsurf->visual.depth, + ZPixmap, 0, /* format, offset */ + NULL, /* data */ + 0, 0, /* size */ + 8, /* bitmap_pad */ + 0); /* bytes_per_line */ + } + + if (!xbuf->ximage) { + XFreeGC(xdpy->dpy, xsurf->gc); + free(xsurf); + return NULL; + } + } + } + + xsurf->base.destroy = ximage_surface_destroy; + xsurf->base.swap_buffers = ximage_surface_swap_buffers; + xsurf->base.flush_frontbuffer = ximage_surface_flush_frontbuffer; + xsurf->base.validate = ximage_surface_validate; + xsurf->base.wait = ximage_surface_wait; + + return xsurf; +} + +static struct native_surface * +ximage_display_create_window_surface(struct native_display *ndpy, + EGLNativeWindowType win, + const struct native_config *nconf) +{ + struct ximage_surface *xsurf; + + xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_WINDOW, + (Drawable) win, nconf); + return (xsurf) ? &xsurf->base : NULL; +} + +static struct native_surface * +ximage_display_create_pixmap_surface(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf) +{ + struct ximage_surface *xsurf; + + xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_PIXMAP, + (Drawable) pix, nconf); + return (xsurf) ? &xsurf->base : NULL; +} + +static struct native_surface * +ximage_display_create_pbuffer_surface(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height) +{ + struct ximage_surface *xsurf; + + xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_PBUFFER, + (Drawable) None, nconf); + if (xsurf) { + xsurf->width = width; + xsurf->height = height; + } + return (xsurf) ? &xsurf->base : NULL; +} + +static struct pipe_context * +ximage_display_create_context(struct native_display *ndpy, + void *context_private) +{ + struct pipe_context *pctx = softpipe_create(ndpy->screen); + if (pctx) + pctx->priv = context_private; + return pctx; +} + +static enum pipe_format +choose_format(const XVisualInfo *vinfo) +{ + enum pipe_format fmt; + /* TODO elaborate the formats */ + switch (vinfo->depth) { + case 32: + fmt = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case 24: + fmt = PIPE_FORMAT_X8R8G8B8_UNORM; + break; + case 16: + fmt = PIPE_FORMAT_R5G6B5_UNORM; + break; + default: + fmt = PIPE_FORMAT_NONE; + break; + } + + return fmt; +} + +static const struct native_config ** +ximage_display_get_configs(struct native_display *ndpy, int *num_configs) +{ + struct ximage_display *xdpy = ximage_display(ndpy); + const struct native_config **configs; + int i; + + /* first time */ + if (!xdpy->configs) { + const XVisualInfo *visuals; + int num_visuals, count, j; + + visuals = x11_screen_get_visuals(xdpy->xscr, &num_visuals); + if (!visuals) + return NULL; + + /* + * Create two configs for each visual. + * One with depth/stencil buffer; one without + */ + xdpy->configs = calloc(num_visuals * 2, sizeof(*xdpy->configs)); + if (!xdpy->configs) + return NULL; + + count = 0; + for (i = 0; i < num_visuals; i++) { + for (j = 0; j < 2; j++) { + struct ximage_config *xconf = &xdpy->configs[count]; + __GLcontextModes *mode = &xconf->base.mode; + + xconf->visual = &visuals[i]; + xconf->base.color_format = choose_format(xconf->visual); + if (xconf->base.color_format == PIPE_FORMAT_NONE) + continue; + + x11_screen_convert_visual(xdpy->xscr, xconf->visual, mode); + /* support double buffer mode */ + mode->doubleBufferMode = TRUE; + + xconf->base.depth_format = PIPE_FORMAT_NONE; + xconf->base.stencil_format = PIPE_FORMAT_NONE; + /* create the second config with depth/stencil buffer */ + if (j == 1) { + xconf->base.depth_format = PIPE_FORMAT_S8Z24_UNORM; + xconf->base.stencil_format = PIPE_FORMAT_S8Z24_UNORM; + mode->depthBits = 24; + mode->stencilBits = 8; + mode->haveDepthBuffer = TRUE; + mode->haveStencilBuffer = TRUE; + } + + mode->maxPbufferWidth = 4096; + mode->maxPbufferHeight = 4096; + mode->maxPbufferPixels = 4096 * 4096; + mode->drawableType = + GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT; + mode->swapMethod = GLX_SWAP_EXCHANGE_OML; + + if (mode->alphaBits) + mode->bindToTextureRgba = TRUE; + else + mode->bindToTextureRgb = TRUE; + + count++; + } + } + + xdpy->num_configs = count; + } + + configs = malloc(xdpy->num_configs * sizeof(*configs)); + if (configs) { + for (i = 0; i < xdpy->num_configs; i++) + configs[i] = (const struct native_config *) &xdpy->configs[i]; + if (num_configs) + *num_configs = xdpy->num_configs; + } + return configs; +} + +static boolean +ximage_display_is_pixmap_supported(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf) +{ + struct ximage_display *xdpy = ximage_display(ndpy); + enum pipe_format fmt; + uint depth; + + depth = x11_drawable_get_depth(xdpy->xscr, (Drawable) pix); + switch (depth) { + case 32: + fmt = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case 24: + fmt = PIPE_FORMAT_X8R8G8B8_UNORM; + break; + case 16: + fmt = PIPE_FORMAT_R5G6B5_UNORM; + break; + default: + fmt = PIPE_FORMAT_NONE; + break; + } + + return (fmt == nconf->color_format); +} + +static void +ximage_display_destroy(struct native_display *ndpy) +{ + struct ximage_display *xdpy = ximage_display(ndpy); + + if (xdpy->configs) + free(xdpy->configs); + + xdpy->base.screen->destroy(xdpy->base.screen); + free(xdpy->winsys); + + x11_screen_destroy(xdpy->xscr); + if (xdpy->own_dpy) + XCloseDisplay(xdpy->dpy); + free(xdpy); +} + +struct native_display * +x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm) +{ + struct ximage_display *xdpy; + + xdpy = CALLOC_STRUCT(ximage_display); + if (!xdpy) + return NULL; + + xdpy->dpy = dpy; + if (!xdpy->dpy) { + xdpy->dpy = XOpenDisplay(NULL); + if (!xdpy->dpy) { + free(xdpy); + return NULL; + } + xdpy->own_dpy = TRUE; + } + + xdpy->xscr_number = DefaultScreen(xdpy->dpy); + xdpy->xscr = x11_screen_create(xdpy->dpy, xdpy->xscr_number); + if (!xdpy->xscr) { + free(xdpy); + return NULL; + } + + xdpy->use_xshm = + (use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM)); + + xdpy->winsys = create_sw_winsys(); + xdpy->base.screen = softpipe_create_screen(xdpy->winsys); + + xdpy->base.destroy = ximage_display_destroy; + + xdpy->base.get_configs = ximage_display_get_configs; + xdpy->base.is_pixmap_supported = ximage_display_is_pixmap_supported; + xdpy->base.create_context = ximage_display_create_context; + xdpy->base.create_window_surface = ximage_display_create_window_surface; + xdpy->base.create_pixmap_surface = ximage_display_create_pixmap_surface; + xdpy->base.create_pbuffer_surface = ximage_display_create_pbuffer_surface; + + return &xdpy->base; +} diff --git a/src/gallium/state_trackers/egl/x11/sw_winsys.c b/src/gallium/state_trackers/egl/x11/sw_winsys.c new file mode 100644 index 00000000000..6ee3ede38cb --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/sw_winsys.c @@ -0,0 +1,231 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * Totally software-based winsys layer. + * Note that the one winsys function that we can't implement here + * is flush_frontbuffer(). + * Whoever uses this code will have to provide that. + * + * Authors: Brian Paul + */ + + +#include "pipe/internal/p_winsys_screen.h" +#include "pipe/p_state.h" +#include "pipe/p_inlines.h" +#include "util/u_format.h" +#include "util/u_math.h" +#include "util/u_memory.h" + +#include "sw_winsys.h" + + + +/** Subclass of pipe_winsys */ +struct sw_pipe_winsys +{ + struct pipe_winsys Base; + /* no extra fields for now */ +}; + + +/** subclass of pipe_buffer */ +struct sw_pipe_buffer +{ + struct pipe_buffer Base; + boolean UserBuffer; /** Is this a user-space buffer? */ + void *Data; + void *Mapped; +}; + + +/** cast wrapper */ +static INLINE struct sw_pipe_buffer * +sw_pipe_buffer(struct pipe_buffer *b) +{ + return (struct sw_pipe_buffer *) b; +} + + +static const char * +get_name(struct pipe_winsys *pws) +{ + return "software"; +} + + +/** Create new pipe_buffer and allocate storage of given size */ +static struct pipe_buffer * +buffer_create(struct pipe_winsys *pws, + unsigned alignment, + unsigned usage, + unsigned size) +{ + struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); + if (!buffer) + return NULL; + + pipe_reference_init(&buffer->Base.reference, 1); + buffer->Base.alignment = alignment; + buffer->Base.usage = usage; + buffer->Base.size = size; + + /* align to 16-byte multiple for Cell */ + buffer->Data = align_malloc(size, MAX2(alignment, 16)); + + return &buffer->Base; +} + + +/** + * Create buffer which wraps user-space data. + */ +static struct pipe_buffer * +user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) +{ + struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); + if (!buffer) + return NULL; + + pipe_reference_init(&buffer->Base.reference, 1); + buffer->Base.size = bytes; + buffer->UserBuffer = TRUE; + buffer->Data = ptr; + + return &buffer->Base; +} + + +static void * +buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned flags) +{ + struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); + buffer->Mapped = buffer->Data; + return buffer->Mapped; +} + + +static void +buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) +{ + struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); + buffer->Mapped = NULL; +} + + +static void +buffer_destroy(struct pipe_buffer *buf) +{ + struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); + + if (buffer->Data && !buffer->UserBuffer) { + align_free(buffer->Data); + buffer->Data = NULL; + } + + free(buffer); +} + + +static struct pipe_buffer * +surface_buffer_create(struct pipe_winsys *winsys, + unsigned width, unsigned height, + enum pipe_format format, + unsigned usage, + unsigned tex_usage, + unsigned *stride) +{ + const unsigned alignment = 64; + unsigned nblocksy; + + nblocksy = util_format_get_nblocksy(format, height); + *stride = align(util_format_get_stride(format, width), alignment); + + return winsys->buffer_create(winsys, alignment, + usage, + *stride * nblocksy); +} + + +static void +fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, + struct pipe_fence_handle *fence) +{ + /* no-op */ +} + + +static int +fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, + unsigned flag) +{ + /* no-op */ + return 0; +} + + +static int +fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, + unsigned flag) +{ + /* no-op */ + return 0; +} + + +/** + * Create/return a new pipe_winsys object. + */ +struct pipe_winsys * +create_sw_winsys(void) +{ + struct sw_pipe_winsys *ws = CALLOC_STRUCT(sw_pipe_winsys); + if (!ws) + return NULL; + + /* Fill in this struct with callbacks that pipe will need to + * communicate with the window system, buffer manager, etc. + */ + ws->Base.buffer_create = buffer_create; + ws->Base.user_buffer_create = user_buffer_create; + ws->Base.buffer_map = buffer_map; + ws->Base.buffer_unmap = buffer_unmap; + ws->Base.buffer_destroy = buffer_destroy; + + ws->Base.surface_buffer_create = surface_buffer_create; + + ws->Base.fence_reference = fence_reference; + ws->Base.fence_signalled = fence_signalled; + ws->Base.fence_finish = fence_finish; + + ws->Base.flush_frontbuffer = NULL; /* not implemented here! */ + + ws->Base.get_name = get_name; + + return &ws->Base; +} diff --git a/src/gallium/state_trackers/egl/x11/sw_winsys.h b/src/gallium/state_trackers/egl/x11/sw_winsys.h new file mode 100644 index 00000000000..f96c5a14b0a --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/sw_winsys.h @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef SW_WINSYS_H +#define SW_WINSYS_H + + +struct pipe_winsys; + + +extern struct pipe_winsys * +create_sw_winsys(void); + + +#endif /* SW_WINSYS_H */ diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c b/src/gallium/state_trackers/egl/x11/x11_screen.c new file mode 100644 index 00000000000..76ce45ee574 --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/x11_screen.c @@ -0,0 +1,453 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include "util/u_memory.h" +#include "util/u_math.h" +#include "util/u_format.h" +#include "xf86drm.h" +#include "egllog.h" + +#include "x11_screen.h" +#include "dri2.h" +#include "glxinit.h" + +struct x11_screen { + Display *dpy; + int number; + + /* + * This is used to fetch GLX visuals/fbconfigs. It uses code from egl_xdri. + * It might be better to rewrite the part in Xlib or XCB. + */ + __GLXdisplayPrivate *glx_dpy; + + int dri_major, dri_minor; + char *dri_driver; + char *dri_device; + int dri_fd; + + XVisualInfo *visuals; + int num_visuals; + + /* cached values for x11_drawable_get_depth */ + Drawable last_drawable; + unsigned int last_depth; +}; + + +/** + * Create a X11 screen. + */ +struct x11_screen * +x11_screen_create(Display *dpy, int screen) +{ + struct x11_screen *xscr; + + if (screen >= ScreenCount(dpy)) + return NULL; + + xscr = CALLOC_STRUCT(x11_screen); + if (xscr) { + xscr->dpy = dpy; + xscr->number = screen; + + xscr->dri_major = -1; + xscr->dri_fd = -1; + } + return xscr; +} + +/** + * Destroy a X11 screen. + */ +void +x11_screen_destroy(struct x11_screen *xscr) +{ + if (xscr->dri_fd >= 0) + close(xscr->dri_fd); + if (xscr->dri_driver) + Xfree(xscr->dri_driver); + if (xscr->dri_device) + Xfree(xscr->dri_device); + + /* xscr->glx_dpy will be destroyed with the X display */ + + if (xscr->visuals) + XFree(xscr->visuals); + free(xscr); +} + +static boolean +x11_screen_init_dri2(struct x11_screen *xscr) +{ + if (xscr->dri_major < 0) { + int eventBase, errorBase; + + if (!DRI2QueryExtension(xscr->dpy, &eventBase, &errorBase) || + !DRI2QueryVersion(xscr->dpy, &xscr->dri_major, &xscr->dri_minor)) + xscr->dri_major = -1; + } + return (xscr->dri_major >= 0); +} + +static boolean +x11_screen_init_glx(struct x11_screen *xscr) +{ + if (!xscr->glx_dpy) + xscr->glx_dpy = __glXInitialize(xscr->dpy); + return (xscr->glx_dpy != NULL); +} + +/** + * Return true if the screen supports the extension. + */ +boolean +x11_screen_support(struct x11_screen *xscr, enum x11_screen_extension ext) +{ + boolean supported = FALSE; + + switch (ext) { + case X11_SCREEN_EXTENSION_XSHM: + supported = XShmQueryExtension(xscr->dpy); + break; + case X11_SCREEN_EXTENSION_GLX: + supported = x11_screen_init_glx(xscr); + break; + case X11_SCREEN_EXTENSION_DRI2: + supported = x11_screen_init_dri2(xscr); + break; + default: + break; + } + + return supported; +} + +/** + * Return the X visuals. + */ +const XVisualInfo * +x11_screen_get_visuals(struct x11_screen *xscr, int *num_visuals) +{ + if (!xscr->visuals) { + XVisualInfo vinfo_template; + vinfo_template.screen = xscr->number; + xscr->visuals = XGetVisualInfo(xscr->dpy, VisualScreenMask, + &vinfo_template, &xscr->num_visuals); + } + + if (num_visuals) + *num_visuals = xscr->num_visuals; + return xscr->visuals; +} + +void +x11_screen_convert_visual(struct x11_screen *xscr, const XVisualInfo *visual, + __GLcontextModes *mode) +{ + int r, g, b, a; + int visual_type; + + r = util_bitcount(visual->red_mask); + g = util_bitcount(visual->green_mask); + b = util_bitcount(visual->blue_mask); + a = visual->depth - (r + g + b); +#if defined(__cplusplus) || defined(c_plusplus) + visual_type = visual->c_class; +#else + visual_type = visual->class; +#endif + + /* convert to GLX visual type */ + switch (visual_type) { + case TrueColor: + visual_type = GLX_TRUE_COLOR; + break; + case DirectColor: + visual_type = GLX_DIRECT_COLOR; + break; + case PseudoColor: + visual_type = GLX_PSEUDO_COLOR; + break; + case StaticColor: + visual_type = GLX_STATIC_COLOR; + break; + case GrayScale: + visual_type = GLX_GRAY_SCALE; + break; + case StaticGray: + visual_type = GLX_STATIC_GRAY; + break; + default: + visual_type = GLX_NONE; + break; + } + + mode->rgbBits = r + g + b + a; + mode->redBits = r; + mode->greenBits = g; + mode->blueBits = b; + mode->alphaBits = a; + mode->visualID = visual->visualid; + mode->visualType = visual_type; + + /* sane defaults */ + mode->renderType = GLX_RGBA_BIT; + mode->rgbMode = TRUE; + mode->visualRating = GLX_SLOW_CONFIG; + mode->xRenderable = TRUE; +} + +/** + * Return the GLX fbconfigs. + */ +const __GLcontextModes * +x11_screen_get_glx_configs(struct x11_screen *xscr) +{ + return (x11_screen_init_glx(xscr)) + ? xscr->glx_dpy->screenConfigs[xscr->number].configs + : NULL; +} + +/** + * Return the GLX visuals. + */ +const __GLcontextModes * +x11_screen_get_glx_visuals(struct x11_screen *xscr) +{ + return (x11_screen_init_glx(xscr)) + ? xscr->glx_dpy->screenConfigs[xscr->number].visuals + : NULL; +} + +static boolean +x11_screen_is_driver_equal(struct x11_screen *xscr, const char *driver) +{ + return (strcmp(xscr->dri_driver, driver) == 0); +} + +/** + * Probe the screen for the DRI2 driver name. + */ +const char * +x11_screen_probe_dri2(struct x11_screen *xscr) +{ + /* get the driver name and the device name */ + if (!xscr->dri_driver) { + if (!DRI2Connect(xscr->dpy, RootWindow(xscr->dpy, xscr->number), + &xscr->dri_driver, &xscr->dri_device)) + xscr->dri_driver = xscr->dri_device = NULL; + } + + return xscr->dri_driver; +} + +/** + * Enable DRI2 and returns the file descriptor of the DRM device. The file + * descriptor will be closed automatically when the screen is destoryed. + */ +int +x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver) +{ + if (xscr->dri_fd < 0) { + int fd; + drm_magic_t magic; + + /* get the driver name and the device name first */ + if (!x11_screen_probe_dri2(xscr)) + return -1; + + if (!x11_screen_is_driver_equal(xscr, driver)) { + _eglLog(_EGL_WARNING, "Driver mismatch: %s != %s", + xscr->dri_driver, driver); + return -1; + } + + fd = open(xscr->dri_device, O_RDWR); + if (fd < 0) { + _eglLog(_EGL_WARNING, "failed to open %s", xscr->dri_device); + return -1; + } + + memset(&magic, 0, sizeof(magic)); + if (drmGetMagic(fd, &magic)) { + _eglLog(_EGL_WARNING, "failed to get magic"); + close(fd); + return -1; + } + + if (!DRI2Authenticate(xscr->dpy, + RootWindow(xscr->dpy, xscr->number), magic)) { + _eglLog(_EGL_WARNING, "failed to authenticate magic"); + close(fd); + return -1; + } + + xscr->dri_fd = fd; + } + + return xscr->dri_fd; +} + +/** + * Create/Destroy the DRI drawable. + */ +void +x11_drawable_enable_dri2(struct x11_screen *xscr, + Drawable drawable, boolean on) +{ + if (on) + DRI2CreateDrawable(xscr->dpy, drawable); + else + DRI2DestroyDrawable(xscr->dpy, drawable); +} + +/** + * Copy between buffers of the DRI2 drawable. + */ +void +x11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable, + int x, int y, int width, int height, + int src_buf, int dst_buf) +{ + XRectangle rect; + XserverRegion region; + + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + + region = XFixesCreateRegion(xscr->dpy, &rect, 1); + DRI2CopyRegion(xscr->dpy, drawable, region, dst_buf, src_buf); + XFixesDestroyRegion(xscr->dpy, region); +} + +/** + * Get the buffers of the DRI2 drawable. The returned array should be freed. + */ +struct x11_drawable_buffer * +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) +{ + DRI2Buffer *dri2bufs; + + if (with_format) + dri2bufs = DRI2GetBuffersWithFormat(xscr->dpy, drawable, width, height, + attachments, num_ins, num_outs); + else + dri2bufs = DRI2GetBuffers(xscr->dpy, drawable, width, height, + attachments, num_ins, num_outs); + + 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. + */ +__GLcontextModes * +x11_context_modes_create(unsigned count) +{ + const size_t size = sizeof(__GLcontextModes); + __GLcontextModes *base = NULL; + __GLcontextModes **next; + unsigned i; + + next = &base; + for (i = 0; i < count; i++) { + *next = (__GLcontextModes *) calloc(1, size); + if (*next == NULL) { + x11_context_modes_destroy(base); + base = NULL; + break; + } + next = &((*next)->next); + } + + return base; +} + +/** + * Destroy a mode list. + */ +void +x11_context_modes_destroy(__GLcontextModes *modes) +{ + while (modes != NULL) { + __GLcontextModes *next = modes->next; + free(modes); + modes = next; + } +} + +/** + * Return the number of the modes in the mode list. + */ +unsigned +x11_context_modes_count(const __GLcontextModes *modes) +{ + const __GLcontextModes *mode; + int count = 0; + for (mode = modes; mode; mode = mode->next) + count++; + return count; +} diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.h b/src/gallium/state_trackers/egl/x11/x11_screen.h new file mode 100644 index 00000000000..5432858ac3e --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/x11_screen.h @@ -0,0 +1,105 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _X11_SCREEN_H_ +#define _X11_SCREEN_H_ + +#include +#include +#include +#include "pipe/p_compiler.h" +#include "common/native.h" + +enum x11_screen_extension { + X11_SCREEN_EXTENSION_XSHM, + X11_SCREEN_EXTENSION_GLX, + X11_SCREEN_EXTENSION_DRI2, +}; + +/* the same as DRI2Buffer */ +struct x11_drawable_buffer { + unsigned int attachment; + unsigned int name; + unsigned int pitch; + unsigned int cpp; + unsigned int flags; +}; + +struct x11_screen; + +struct x11_screen * +x11_screen_create(Display *dpy, int screen); + +void +x11_screen_destroy(struct x11_screen *xscr); + +boolean +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); + +void +x11_screen_convert_visual(struct x11_screen *xscr, const XVisualInfo *visual, + __GLcontextModes *mode); + +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 +x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver); + +__GLcontextModes * +x11_context_modes_create(unsigned count); + +void +x11_context_modes_destroy(__GLcontextModes *modes); + +unsigned +x11_context_modes_count(const __GLcontextModes *modes); + +void +x11_drawable_enable_dri2(struct x11_screen *xscr, + Drawable drawable, boolean on); + +void +x11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable, + int x, int y, int width, int height, + int src_buf, int dst_buf); + +struct x11_drawable_buffer * +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 /* _X11_SCREEN_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/Makefile b/src/gallium/state_trackers/egl_g3d/Makefile deleted file mode 100644 index b696f2fae93..00000000000 --- a/src/gallium/state_trackers/egl_g3d/Makefile +++ /dev/null @@ -1,75 +0,0 @@ -TOP = ../../../.. -include $(TOP)/configs/current - -common_INCLUDES = \ - -I. \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/auxiliary \ - -I$(TOP)/src/egl/main \ - -I$(TOP)/include - -common_SOURCES = $(wildcard common/*.c) -common_OBJECTS = $(common_SOURCES:.c=.o) - - -x11_INCLUDES = \ - -I$(TOP)/src/gallium/drivers \ - -I$(TOP)/src/glx/x11 \ - -I$(TOP)/src/egl/drivers/xdri \ - -I$(TOP)/src/mesa \ - $(shell pkg-config --cflags-only-I libdrm) - -x11_SOURCES = $(wildcard x11/*.c) \ - $(TOP)/src/glx/x11/dri2.c \ - $(TOP)/src/egl/drivers/xdri/glxinit.c -x11_OBJECTS = $(x11_SOURCES:.c=.o) - - -kms_INCLUDES = $(shell pkg-config --cflags-only-I libdrm) -kms_SOURCES = $(wildcard kms/*.c) -kms_OBJECTS = $(kms_SOURCES:.c=.o) - - -ALL_INCLUDES = $(common_INCLUDES) $(x11_INCLUDES) $(kms_INCLUDES) -ALL_SOURCES = $(common_SOURCES) $(x11_SOURCES) $(kms_SOURCES) -ALL_OBJECTS = $(common_OBJECTS) $(x11_OBJECTS) $(kms_OBJECTS) - -##### TARGETS ##### - -EGL_DISPLAYS_MODS = $(foreach dpy, $(EGL_DISPLAYS), libegl$(dpy).a) - -default: depend $(EGL_DISPLAYS_MODS) - - -libeglx11.a: $(x11_OBJECTS) $(common_OBJECTS) Makefile - $(MKLIB) -o eglx11 -static $(x11_OBJECTS) $(common_OBJECTS) - -libeglkms.a: $(kms_OBJECTS) $(common_OBJECTS) Makefile - $(MKLIB) -o eglkms -static $(kms_OBJECTS) $(common_OBJECTS) - -depend: - rm -f depend - touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(ALL_INCLUDES) $(ALL_SOURCES) 2> /dev/null - -clean: - rm -f $(ALL_OBJECTS) - rm -f $(EGL_DISPLAYS_MODS) - rm -f depend depend.bak - -# Dummy target -install: - @echo -n "" - -##### RULES ##### - -$(common_OBJECTS): %.o: %.c - $(CC) -c $(common_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ - -$(x11_OBJECTS): %.o: %.c - $(CC) -c $(common_INCLUDES) $(x11_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ - -$(kms_OBJECTS): %.o: %.c - $(CC) -c $(common_INCLUDES) $(kms_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ - -sinclude depend diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c deleted file mode 100644 index 2ac6215646c..00000000000 --- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c +++ /dev/null @@ -1,1336 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include "pipe/p_screen.h" -#include "util/u_memory.h" -#include "util/u_rect.h" -#include "egldriver.h" -#include "eglcurrent.h" -#include "eglconfigutil.h" -#include "egllog.h" - -#include "native.h" -#include "egl_g3d.h" -#include "egl_st.h" - -/** - * Validate the draw/read surfaces of the context. - */ -static void -egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct pipe_screen *screen = gdpy->native->screen; - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - const uint st_att_map[NUM_NATIVE_ATTACHMENTS] = { - ST_SURFACE_FRONT_LEFT, - ST_SURFACE_BACK_LEFT, - ST_SURFACE_FRONT_RIGHT, - ST_SURFACE_BACK_RIGHT, - }; - EGLint num_surfaces, s; - - /* validate draw and/or read buffers */ - num_surfaces = (gctx->base.ReadSurface == gctx->base.DrawSurface) ? 1 : 2; - for (s = 0; s < num_surfaces; s++) { - struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; - struct egl_g3d_surface *gsurf; - struct egl_g3d_buffer *gbuf; - EGLint att; - - if (s == 0) { - gsurf = egl_g3d_surface(gctx->base.DrawSurface); - gbuf = &gctx->draw; - } - else { - gsurf = egl_g3d_surface(gctx->base.ReadSurface); - gbuf = &gctx->read; - } - - if (!gctx->force_validate) { - unsigned int seq_num; - - gsurf->native->validate(gsurf->native, gbuf->attachment_mask, - &seq_num, NULL, NULL, NULL); - /* skip validation */ - if (gsurf->sequence_number == seq_num) - continue; - } - - pipe_surface_reference(&gsurf->render_surface, NULL); - memset(textures, 0, sizeof(textures)); - - gsurf->native->validate(gsurf->native, gbuf->attachment_mask, - &gsurf->sequence_number, textures, - &gsurf->base.Width, &gsurf->base.Height); - for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { - struct pipe_texture *pt = textures[att]; - struct pipe_surface *ps; - - if (native_attachment_mask_test(gbuf->attachment_mask, att) && pt) { - ps = screen->get_tex_surface(screen, pt, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); - gctx->stapi->st_set_framebuffer_surface(gbuf->st_fb, - st_att_map[att], ps); - - if (gsurf->render_att == att) - pipe_surface_reference(&gsurf->render_surface, ps); - - pipe_surface_reference(&ps, NULL); - pipe_texture_reference(&pt, NULL); - } - } - - gctx->stapi->st_resize_framebuffer(gbuf->st_fb, - gsurf->base.Width, gsurf->base.Height); - } - - gctx->force_validate = EGL_FALSE; - -} - -/** - * Create a st_framebuffer. - */ -static struct st_framebuffer * -create_framebuffer(_EGLContext *ctx, _EGLSurface *surf) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config); - - return gctx->stapi->st_create_framebuffer(&gconf->native->mode, - gconf->native->color_format, gconf->native->depth_format, - gconf->native->stencil_format, - gsurf->base.Width, gsurf->base.Height, &gsurf->base); -} - -/** - * Update the attachments of draw/read surfaces. - */ -static void -egl_g3d_route_context(_EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - EGLint s; - - /* route draw and read buffers' attachments */ - for (s = 0; s < 2; s++) { - struct egl_g3d_surface *gsurf; - struct egl_g3d_buffer *gbuf; - - if (s == 0) { - gsurf = egl_g3d_surface(gctx->base.DrawSurface); - gbuf = &gctx->draw; - } - else { - gsurf = egl_g3d_surface(gctx->base.ReadSurface); - gbuf = &gctx->read; - } - - gbuf->attachment_mask = (1 << gsurf->render_att); - - /* FIXME OpenGL defaults to draw the front or back buffer when the - * context is single-buffered or double-buffered respectively. In EGL, - * however, the buffer to be drawn is determined by the surface, instead - * of the context. As a result, rendering to a pixmap surface with a - * double-buffered context does not work as expected. - * - * gctx->stapi->st_draw_front_buffer(gctx->st_ctx, natt == - * NATIVE_ATTACHMENT_FRONT_LEFT); - */ - - /* - * FIXME If the back buffer is asked for here, and the front buffer is - * later needed by the client API (e.g. glDrawBuffer is called to draw - * the front buffer), it will create a new pipe texture and draw there. - * One fix is to ask for both buffers here, but it would be a waste if - * the front buffer is never used. A better fix is to add a callback to - * the pipe screen with context private (just like flush_frontbuffer). - */ - } -} - -/** - * Reallocate the context's framebuffers after draw/read surfaces change. - */ -static EGLBoolean -egl_g3d_realloc_context(_EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - struct egl_g3d_surface *gdraw = egl_g3d_surface(gctx->base.DrawSurface); - struct egl_g3d_surface *gread = egl_g3d_surface(gctx->base.ReadSurface); - - /* unreference the old framebuffers */ - if (gctx->draw.st_fb) { - EGLBoolean is_equal = (gctx->draw.st_fb == gctx->read.st_fb); - void *priv; - - priv = gctx->stapi->st_framebuffer_private(gctx->draw.st_fb); - if (!gdraw || priv != (void *) &gdraw->base) { - gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); - gctx->draw.st_fb = NULL; - gctx->draw.attachment_mask = 0x0; - } - - if (is_equal) { - gctx->read.st_fb = NULL; - gctx->draw.attachment_mask = 0x0; - } - else { - priv = gctx->stapi->st_framebuffer_private(gctx->read.st_fb); - if (!gread || priv != (void *) &gread->base) { - gctx->stapi->st_unreference_framebuffer(gctx->read.st_fb); - gctx->read.st_fb = NULL; - gctx->draw.attachment_mask = 0x0; - } - } - } - - if (!gdraw) - return EGL_TRUE; - - /* create the draw fb */ - if (!gctx->draw.st_fb) { - gctx->draw.st_fb = create_framebuffer(&gctx->base, &gdraw->base); - if (!gctx->draw.st_fb) - return EGL_FALSE; - } - - /* create the read fb */ - if (!gctx->read.st_fb) { - if (gread != gdraw) { - gctx->read.st_fb = create_framebuffer(&gctx->base, &gread->base); - if (!gctx->read.st_fb) { - gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); - gctx->draw.st_fb = NULL; - return EGL_FALSE; - } - } - else { - /* there is no st_reference_framebuffer... */ - gctx->read.st_fb = gctx->draw.st_fb; - } - } - - egl_g3d_route_context(dpy, &gctx->base); - gctx->force_validate = EGL_TRUE; - - return EGL_TRUE; -} - -/** - * Return the current context of the given API. - */ -static struct egl_g3d_context * -egl_g3d_get_current_context(EGLint api) -{ - _EGLThreadInfo *t = _eglGetCurrentThread(); - EGLint api_index = _eglConvertApiToIndex(api); - return egl_g3d_context(t->CurrentContexts[api_index]); -} - -/** - * Return the state tracker for the given context. - */ -static const struct egl_g3d_st * -egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - const struct egl_g3d_st *stapi; - EGLint idx = -1; - - switch (ctx->ClientAPI) { - case EGL_OPENGL_ES_API: - switch (ctx->ClientVersion) { - case 1: - idx = EGL_G3D_ST_OPENGL_ES; - break; - case 2: - idx = EGL_G3D_ST_OPENGL_ES2; - break; - default: - _eglLog(_EGL_WARNING, "unknown client version %d", - ctx->ClientVersion); - break; - } - break; - case EGL_OPENVG_API: - idx = EGL_G3D_ST_OPENVG; - break; - case EGL_OPENGL_API: - idx = EGL_G3D_ST_OPENGL; - break; - default: - _eglLog(_EGL_WARNING, "unknown client API 0x%04x", ctx->ClientAPI); - break; - } - - stapi = (idx >= 0) ? gdrv->stapis[idx] : NULL; - return stapi; -} - -/** - * Initialize the state trackers. - */ -static void -egl_g3d_init_st(_EGLDriver *drv) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - EGLint i; - - /* already initialized */ - if (gdrv->api_mask) - return; - - for (i = 0; i < NUM_EGL_G3D_STS; i++) { - gdrv->stapis[i] = egl_g3d_get_st(i); - if (gdrv->stapis[i]) - gdrv->api_mask |= gdrv->stapis[i]->api_bit; - } - - if (gdrv->api_mask) - _eglLog(_EGL_DEBUG, "Driver API mask: 0x%x", gdrv->api_mask); - else - _eglLog(_EGL_WARNING, "No supported client API"); -} - -/** - * Get the probe object of the display. - * - * Note that this function may be called before the display is initialized. - */ -static struct native_probe * -egl_g3d_get_probe(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - struct native_probe *nprobe; - - nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key); - if (!nprobe || nprobe->display != dpy->NativeDisplay) { - if (nprobe) - nprobe->destroy(nprobe); - nprobe = native_create_probe(dpy->NativeDisplay); - _eglSetProbeCache(gdrv->probe_key, (void *) nprobe); - } - - return nprobe; -} - -/** - * Destroy the probe object of the display. The display may be NULL. - * - * Note that this function may be called before the display is initialized. - */ -static void -egl_g3d_destroy_probe(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - struct native_probe *nprobe; - - nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key); - if (nprobe && (!dpy || nprobe->display == dpy->NativeDisplay)) { - nprobe->destroy(nprobe); - _eglSetProbeCache(gdrv->probe_key, NULL); - } -} - -/** - * Return an API mask that consists of the state trackers that supports the - * given mode. - * - * FIXME add st_is_mode_supported()? - */ -static EGLint -get_mode_api_mask(const __GLcontextModes *mode, EGLint api_mask) -{ - EGLint check; - - /* OpenGL ES 1.x and 2.x are checked together */ - check = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT; - if (api_mask & check) { - /* this is required by EGL, not by OpenGL ES */ - if (mode->drawableType & GLX_WINDOW_BIT && !mode->doubleBufferMode) - api_mask &= ~check; - } - - check = EGL_OPENVG_BIT; - if (api_mask & check) { - /* vega st needs the depth/stencil rb */ - if (!mode->depthBits && !mode->stencilBits) - api_mask &= ~check; - } - - return api_mask; -} - -#ifdef EGL_MESA_screen_surface - -static void -egl_g3d_add_screens(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - const struct native_connector **native_connectors; - EGLint num_connectors, i; - - native_connectors = - gdpy->native->modeset->get_connectors(gdpy->native, &num_connectors, NULL); - if (!num_connectors) { - if (native_connectors) - free(native_connectors); - return; - } - - for (i = 0; i < num_connectors; i++) { - const struct native_connector *nconn = native_connectors[i]; - struct egl_g3d_screen *gscr; - const struct native_mode **native_modes; - EGLint num_modes, j; - - /* TODO support for hotplug */ - native_modes = - gdpy->native->modeset->get_modes(gdpy->native, nconn, &num_modes); - if (!num_modes) { - if (native_modes) - free(native_modes); - continue; - } - - gscr = CALLOC_STRUCT(egl_g3d_screen); - if (!gscr) { - free(native_modes); - continue; - } - - _eglInitScreen(&gscr->base); - - for (j = 0; j < num_modes; j++) { - const struct native_mode *nmode = native_modes[j]; - _EGLMode *mode; - - mode = _eglAddNewMode(&gscr->base, nmode->width, nmode->height, - nmode->refresh_rate, nmode->desc); - if (!mode) - break; - /* gscr->native_modes and gscr->base.Modes should be consistent */ - assert(mode == &gscr->base.Modes[j]); - } - - gscr->native = nconn; - gscr->native_modes = native_modes; - - _eglAddScreen(dpy, &gscr->base); - } - - free(native_connectors); -} - -#endif /* EGL_MESA_screen_surface */ - -/** - * Add configs to display and return the next config ID. - */ -static EGLint -egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - const struct native_config **native_configs; - int num_configs, i; - - native_configs = gdpy->native->get_configs(gdpy->native, - &num_configs); - if (!num_configs) { - if (native_configs) - free(native_configs); - return id; - } - - for (i = 0; i < num_configs; i++) { - EGLint api_mask; - struct egl_g3d_config *gconf; - EGLBoolean valid; - - api_mask = get_mode_api_mask(&native_configs[i]->mode, gdrv->api_mask); - if (!api_mask) { - _eglLog(_EGL_DEBUG, "no state tracker supports config 0x%x", - native_configs[i]->mode.visualID); - continue; - } - - gconf = CALLOC_STRUCT(egl_g3d_config); - if (!gconf) - continue; - - _eglInitConfig(&gconf->base, id); - valid = _eglConfigFromContextModesRec(&gconf->base, - &native_configs[i]->mode, api_mask, api_mask); - if (valid) { -#ifdef EGL_MESA_screen_surface - /* check if scanout surface bit is set */ - if (native_configs[i]->scanout_bit) { - EGLint val = GET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE); - val |= EGL_SCREEN_BIT_MESA; - SET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE, val); - } -#endif - valid = _eglValidateConfig(&gconf->base, EGL_FALSE); - } - if (!valid) { - _eglLog(_EGL_DEBUG, "skip invalid config 0x%x", - native_configs[i]->mode.visualID); - free(gconf); - continue; - } - - gconf->native = native_configs[i]; - _eglAddConfig(dpy, &gconf->base); - id++; - } - - free(native_configs); - return id; -} - -/** - * Flush the front buffer of the context's draw surface. - */ -static void -egl_g3d_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, void *context_private) -{ - struct egl_g3d_context *gctx = egl_g3d_context(context_private); - struct egl_g3d_surface *gsurf = egl_g3d_surface(gctx->base.DrawSurface); - - if (gsurf) - gsurf->native->flush_frontbuffer(gsurf->native); -} - -/** - * Re-validate the context. - */ -static void -egl_g3d_update_buffer(struct pipe_screen *screen, void *context_private) -{ - struct egl_g3d_context *gctx = egl_g3d_context(context_private); - - /** - * It is likely that the surface has changed when this function is called. - * Set force_validate to skip an unnecessary check. - */ - gctx->force_validate = EGL_TRUE; - egl_g3d_validate_context(gctx->base.Display, &gctx->base); -} - -static EGLBoolean -egl_g3d_terminate(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - EGLint i; - - _eglReleaseDisplayResources(drv, dpy); - _eglCleanupDisplay(dpy); - - if (dpy->Screens) { - for (i = 0; i < dpy->NumScreens; i++) { - struct egl_g3d_screen *gscr = egl_g3d_screen(dpy->Screens[i]); - free(gscr->native_modes); - free(gscr); - } - free(dpy->Screens); - } - - if (gdpy->native) - gdpy->native->destroy(gdpy->native); - - free(gdpy); - dpy->DriverData = NULL; - - return EGL_TRUE; -} - -static EGLBoolean -egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, - EGLint *major, EGLint *minor) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - struct egl_g3d_display *gdpy; - - /* the probe object is unlikely to be needed again */ - egl_g3d_destroy_probe(drv, dpy); - - gdpy = CALLOC_STRUCT(egl_g3d_display); - if (!gdpy) { - _eglError(EGL_BAD_ALLOC, "eglInitialize"); - goto fail; - } - dpy->DriverData = gdpy; - - gdpy->native = native_create_display(dpy->NativeDisplay); - if (!gdpy->native) { - _eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)"); - goto fail; - } - - gdpy->native->screen->flush_frontbuffer = egl_g3d_flush_frontbuffer; - gdpy->native->screen->update_buffer = egl_g3d_update_buffer; - - egl_g3d_init_st(&gdrv->base); - dpy->ClientAPIsMask = gdrv->api_mask; - - if (egl_g3d_add_configs(drv, dpy, 1) == 1) { - _eglError(EGL_NOT_INITIALIZED, "eglInitialize(unable to add configs)"); - goto fail; - } - -#ifdef EGL_MESA_screen_surface - /* enable MESA_screen_surface */ - if (gdpy->native->modeset) { - dpy->Extensions.MESA_screen_surface = EGL_TRUE; - egl_g3d_add_screens(drv, dpy); - } -#endif - - *major = 1; - *minor = 4; - - return EGL_TRUE; - -fail: - if (gdpy) - egl_g3d_terminate(drv, dpy); - return EGL_FALSE; -} - -static _EGLContext * -egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, - _EGLContext *share, const EGLint *attribs) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_context *gshare = egl_g3d_context(share); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_context *gctx; - const __GLcontextModes *mode; - - gctx = CALLOC_STRUCT(egl_g3d_context); - if (!gctx) { - _eglError(EGL_BAD_ALLOC, "eglCreateContext"); - return NULL; - } - - if (!_eglInitContext(drv, &gctx->base, conf, attribs)) { - free(gctx); - return NULL; - } - - gctx->stapi = egl_g3d_choose_st(drv, &gctx->base); - if (!gctx->stapi) { - free(gctx); - return NULL; - } - - mode = &gconf->native->mode; - gctx->pipe = - gdpy->native->create_context(gdpy->native, (void *) &gctx->base); - if (!gctx->pipe) { - free(gctx); - return NULL; - } - - gctx->st_ctx = gctx->stapi->st_create_context(gctx->pipe, mode, - (gshare) ? gshare->st_ctx : NULL); - if (!gctx->st_ctx) { - gctx->pipe->destroy(gctx->pipe); - free(gctx); - return NULL; - } - - return &gctx->base; -} - -static EGLBoolean -egl_g3d_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - - if (_eglIsContextBound(&gctx->base)) - return EGL_TRUE; - - egl_g3d_realloc_context(dpy, &gctx->base); - - /* it will destroy pipe context */ - gctx->stapi->st_destroy_context(gctx->st_ctx); - - free(gctx); - - return EGL_TRUE; -} - -static EGLBoolean -init_surface_geometry(_EGLSurface *surf) -{ - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - - return gsurf->native->validate(gsurf->native, 0x0, - &gsurf->sequence_number, NULL, - &gsurf->base.Width, &gsurf->base.Height); -} - -static _EGLSurface * -egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, EGLNativeWindowType win, - const EGLint *attribs) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_surface *gsurf; - - gsurf = CALLOC_STRUCT(egl_g3d_surface); - if (!gsurf) { - _eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface"); - return NULL; - } - - if (!_eglInitSurface(drv, &gsurf->base, EGL_WINDOW_BIT, conf, attribs)) { - free(gsurf); - return NULL; - } - - gsurf->native = - gdpy->native->create_window_surface(gdpy->native, win, gconf->native); - if (!gsurf->native) { - free(gsurf); - return NULL; - } - - if (!init_surface_geometry(&gsurf->base)) { - gsurf->native->destroy(gsurf->native); - free(gsurf); - return NULL; - } - - gsurf->render_att = (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER || - !gconf->native->mode.doubleBufferMode) ? - NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; - - return &gsurf->base; -} - -static _EGLSurface * -egl_g3d_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, EGLNativePixmapType pix, - const EGLint *attribs) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_surface *gsurf; - - gsurf = CALLOC_STRUCT(egl_g3d_surface); - if (!gsurf) { - _eglError(EGL_BAD_ALLOC, "eglCreatePixmapSurface"); - return NULL; - } - - if (!_eglInitSurface(drv, &gsurf->base, EGL_PIXMAP_BIT, conf, attribs)) { - free(gsurf); - return NULL; - } - - gsurf->native = - gdpy->native->create_pixmap_surface(gdpy->native, pix, gconf->native); - if (!gsurf->native) { - free(gsurf); - return NULL; - } - - if (!init_surface_geometry(&gsurf->base)) { - gsurf->native->destroy(gsurf->native); - free(gsurf); - return NULL; - } - - gsurf->render_att = NATIVE_ATTACHMENT_FRONT_LEFT; - - return &gsurf->base; -} - -static _EGLSurface * -egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, const EGLint *attribs) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_surface *gsurf; - - gsurf = CALLOC_STRUCT(egl_g3d_surface); - if (!gsurf) { - _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); - return NULL; - } - - if (!_eglInitSurface(drv, &gsurf->base, EGL_PBUFFER_BIT, conf, attribs)) { - free(gsurf); - return NULL; - } - - gsurf->native = - gdpy->native->create_pbuffer_surface(gdpy->native, gconf->native, - gsurf->base.Width, gsurf->base.Height); - if (!gsurf->native) { - free(gsurf); - return NULL; - } - - if (!init_surface_geometry(&gsurf->base)) { - gsurf->native->destroy(gsurf->native); - free(gsurf); - return NULL; - } - - gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ? - NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; - - return &gsurf->base; -} - -static EGLBoolean -egl_g3d_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) -{ - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - - if (_eglIsSurfaceBound(&gsurf->base)) - return EGL_TRUE; - - pipe_surface_reference(&gsurf->render_surface, NULL); - gsurf->native->destroy(gsurf->native); - free(gsurf); - return EGL_TRUE; -} - -static EGLBoolean -egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - struct egl_g3d_context *old_gctx; - EGLint api; - EGLBoolean ok = EGL_TRUE; - - /* find the old context */ - api = (gctx) ? gctx->base.ClientAPI : eglQueryAPI(); - old_gctx = egl_g3d_get_current_context(api); - if (old_gctx && !_eglIsContextLinked(&old_gctx->base)) - old_gctx = NULL; - - if (!_eglMakeCurrent(drv, dpy, draw, read, ctx)) - return EGL_FALSE; - - if (old_gctx) { - /* flush old context */ - old_gctx->stapi->st_flush(old_gctx->st_ctx, - PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); - - /* - * The old context is no longer current, and egl_g3d_realloc_context() - * should be called to destroy the framebuffers. However, it is possible - * that it will be made current again with the same draw/read surfaces. - * It might be better to keep it around. - */ - } - - if (gctx) { - struct egl_g3d_surface *gdraw = egl_g3d_surface(draw); - - ok = egl_g3d_realloc_context(dpy, &gctx->base); - if (ok) { - ok = gctx->stapi->st_make_current(gctx->st_ctx, - gctx->draw.st_fb, gctx->read.st_fb); - if (ok) { - egl_g3d_validate_context(dpy, &gctx->base); - if (gdraw->base.Type == EGL_WINDOW_BIT) { - gctx->base.WindowRenderBuffer = - (gdraw->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) ? - EGL_SINGLE_BUFFER : EGL_BACK_BUFFER; - } - } - } - } - else if (old_gctx) { - ok = old_gctx->stapi->st_make_current(NULL, NULL, NULL); - old_gctx->base.WindowRenderBuffer = EGL_NONE; - } - - return ok; -} - -static EGLBoolean -egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) -{ - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - _EGLContext *ctx = _eglGetCurrentContext(); - struct egl_g3d_context *gctx = NULL; - - /* no-op for pixmap or pbuffer surface */ - if (gsurf->base.Type == EGL_PIXMAP_BIT || - gsurf->base.Type == EGL_PBUFFER_BIT) - return EGL_TRUE; - - /* or when the surface is single-buffered */ - if (gsurf->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) - return EGL_TRUE; - - if (ctx && ctx->DrawSurface == surf) - gctx = egl_g3d_context(ctx); - - /* flush if the surface is current */ - if (gctx) - gctx->stapi->st_notify_swapbuffers(gctx->draw.st_fb); - - /* - * We drew on the back buffer, unless there was no back buffer. - * In that case, we drew on the front buffer. Either case, we call - * swap_buffers. - */ - if (!gsurf->native->swap_buffers(gsurf->native)) - return EGL_FALSE; - - if (gctx) { - struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config); - - /* force validation if the swap method is not copy */ - if (gconf->native->mode.swapMethod != GLX_SWAP_COPY_OML) { - gctx->force_validate = EGL_TRUE; - egl_g3d_validate_context(dpy, &gctx->base); - } - } - - return EGL_TRUE; -} - -/** - * Find a config that supports the pixmap. - */ -static _EGLConfig * -find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf; - EGLint i; - - for (i = 0; i < dpy->NumConfigs; i++) { - gconf = egl_g3d_config(dpy->Configs[i]); - if (gdpy->native->is_pixmap_supported(gdpy->native, pix, gconf->native)) - break; - } - - return (i < dpy->NumConfigs) ? &gconf->base : NULL; -} - -/** - * Get the pipe surface of the given attachment of the native surface. - */ -static struct pipe_surface * -get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf, - enum native_attachment natt) -{ - struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; - struct pipe_surface *psurf; - - textures[natt] = NULL; - nsurf->validate(nsurf, 1 << natt, NULL, textures, NULL, NULL); - if (!textures[natt]) - return NULL; - - psurf = ndpy->screen->get_tex_surface(ndpy->screen, textures[natt], - 0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE); - pipe_texture_reference(&textures[natt], NULL); - - return psurf; -} - -static EGLBoolean -egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, - NativePixmapType target) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - _EGLContext *ctx = _eglGetCurrentContext(); - struct egl_g3d_config *gconf; - struct native_surface *nsurf; - struct pipe_screen *screen = gdpy->native->screen; - struct pipe_surface *psurf; - - if (!gsurf->render_surface) - return EGL_TRUE; - - gconf = egl_g3d_config(find_pixmap_config(dpy, target)); - if (!gconf) - return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers"); - - nsurf = gdpy->native->create_pixmap_surface(gdpy->native, - target, gconf->native); - if (!nsurf) - return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers"); - - /* flush if the surface is current */ - if (ctx && ctx->DrawSurface == &gsurf->base) { - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - gctx->stapi->st_flush(gctx->st_ctx, - PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); - } - - psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); - if (psurf) { - struct pipe_context pipe; - - /** - * XXX This is hacky. If we might allow the EGLDisplay to create a pipe - * context of its own and use the blitter context for this. - */ - memset(&pipe, 0, sizeof(pipe)); - pipe.screen = screen; - - util_surface_copy(&pipe, FALSE, psurf, 0, 0, - gsurf->render_surface, 0, 0, psurf->width, psurf->height); - - pipe_surface_reference(&psurf, NULL); - nsurf->flush_frontbuffer(nsurf); - } - - nsurf->destroy(nsurf); - - return EGL_TRUE; -} - -static EGLBoolean -egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - gctx->stapi->st_finish(gctx->st_ctx); - return EGL_TRUE; -} - -static EGLBoolean -egl_g3d_wait_native(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine) -{ - _EGLSurface *surf = _eglGetCurrentSurface(EGL_DRAW); - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - - if (engine != EGL_CORE_NATIVE_ENGINE) - return _eglError(EGL_BAD_PARAMETER, "eglWaitNative"); - - if (gsurf) - gsurf->native->wait(gsurf->native); - - return EGL_TRUE; -} - -static _EGLProc -egl_g3d_get_proc_address(_EGLDriver *drv, const char *procname) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - _EGLProc proc; - EGLint i; - - /* in case this is called before a display is initialized */ - egl_g3d_init_st(&gdrv->base); - - for (i = 0; i < NUM_EGL_G3D_STS; i++) { - const struct egl_g3d_st *stapi = gdrv->stapis[i]; - if (stapi) { - proc = (_EGLProc) stapi->st_get_proc_address(procname); - if (proc) - return proc; - } - } - - return (_EGLProc) NULL; -} - -static EGLBoolean -egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSurface *surf, EGLint buffer) -{ - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - struct egl_g3d_context *gctx; - enum pipe_format target_format; - int target; - - if (!gsurf || gsurf->base.Type != EGL_PBUFFER_BIT) - return _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); - if (buffer != EGL_BACK_BUFFER) - return _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); - if (gsurf->base.BoundToTexture) - return _eglError(EGL_BAD_ACCESS, "eglBindTexImage"); - - switch (gsurf->base.TextureFormat) { - case EGL_TEXTURE_RGB: - target_format = PIPE_FORMAT_R8G8B8_UNORM; - break; - case EGL_TEXTURE_RGBA: - target_format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - default: - return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); - } - - switch (gsurf->base.TextureTarget) { - case EGL_TEXTURE_2D: - target = ST_TEXTURE_2D; - break; - default: - return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); - } - - /* flush properly if the surface is bound */ - if (gsurf->base.Binding) { - gctx = egl_g3d_context(gsurf->base.Binding); - gctx->stapi->st_flush(gctx->st_ctx, - PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); - } - - /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */ - gctx = egl_g3d_get_current_context(EGL_OPENGL_API); - if (gctx) { - if (!gsurf->render_surface) - return EGL_FALSE; - - gctx->stapi->st_bind_texture_surface(gsurf->render_surface, - target, gsurf->base.MipmapLevel, target_format); - gsurf->base.BoundToTexture = EGL_TRUE; - } - - return EGL_TRUE; -} - -static EGLBoolean -egl_g3d_release_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSurface *surf, EGLint buffer) -{ - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - - if (!gsurf || gsurf->base.Type != EGL_PBUFFER_BIT || - !gsurf->base.BoundToTexture) - return _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); - if (buffer != EGL_BACK_BUFFER) - return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); - - if (gsurf->render_surface) { - _EGLThreadInfo *t = _eglGetCurrentThread(); - /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */ - struct egl_g3d_context *gctx = egl_g3d_context( - t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_API)]); - - /* what if the context the surface binds to is no longer current? */ - if (gctx) - gctx->stapi->st_unbind_texture_surface(gsurf->render_surface, - ST_TEXTURE_2D, gsurf->base.MipmapLevel); - } - - gsurf->base.BoundToTexture = EGL_FALSE; - - return EGL_TRUE; -} - -#ifdef EGL_MESA_screen_surface - -static _EGLSurface * -egl_g3d_create_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, const EGLint *attribs) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_surface *gsurf; - - gsurf = CALLOC_STRUCT(egl_g3d_surface); - if (!gsurf) { - _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); - return NULL; - } - - if (!_eglInitSurface(drv, &gsurf->base, - EGL_SCREEN_BIT_MESA, conf, attribs)) { - free(gsurf); - return NULL; - } - - gsurf->native = - gdpy->native->modeset->create_scanout_surface(gdpy->native, - gconf->native, gsurf->base.Width, gsurf->base.Height); - if (!gsurf->native) { - free(gsurf); - return NULL; - } - - gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ? - NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; - - return &gsurf->base; -} - -static EGLBoolean -egl_g3d_show_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLScreen *scr, _EGLSurface *surf, - _EGLMode *mode) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_screen *gscr = egl_g3d_screen(scr); - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - struct native_surface *nsurf; - const struct native_mode *nmode; - EGLBoolean changed; - - if (gsurf) { - EGLint idx; - - if (!mode) - return _eglError(EGL_BAD_MATCH, "eglShowSurfaceMESA"); - if (gsurf->base.Type != EGL_SCREEN_BIT_MESA) - return _eglError(EGL_BAD_SURFACE, "eglShowScreenSurfaceMESA"); - if (gsurf->base.Width < mode->Width || gsurf->base.Height < mode->Height) - return _eglError(EGL_BAD_MATCH, - "eglShowSurfaceMESA(surface smaller than mode size)"); - - /* find the index of the mode */ - for (idx = 0; idx < gscr->base.NumModes; idx++) - if (mode == &gscr->base.Modes[idx]) - break; - if (idx >= gscr->base.NumModes) { - return _eglError(EGL_BAD_MODE_MESA, - "eglShowSurfaceMESA(unknown mode)"); - } - - nsurf = gsurf->native; - nmode = gscr->native_modes[idx]; - } - else { - if (mode) - return _eglError(EGL_BAD_MATCH, "eglShowSurfaceMESA"); - - /* disable the screen */ - nsurf = NULL; - nmode = NULL; - } - - /* TODO surface panning by CRTC choosing */ - changed = gdpy->native->modeset->program(gdpy->native, 0, nsurf, - gscr->base.OriginX, gscr->base.OriginY, &gscr->native, 1, nmode); - if (changed) { - gscr->base.CurrentSurface = &gsurf->base; - gscr->base.CurrentMode = mode; - } - - return changed; -} - -#endif /* EGL_MESA_screen_surface */ - -static EGLint -egl_g3d_probe(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct native_probe *nprobe; - enum native_probe_result res; - EGLint score; - - nprobe = egl_g3d_get_probe(drv, dpy); - res = native_get_probe_result(nprobe); - - switch (res) { - case NATIVE_PROBE_UNKNOWN: - default: - score = 0; - break; - case NATIVE_PROBE_FALLBACK: - score = 40; - break; - case NATIVE_PROBE_SUPPORTED: - score = 50; - break; - case NATIVE_PROBE_EXACT: - score = 100; - break; - } - - return score; -} - -static void -egl_g3d_unload(_EGLDriver *drv) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - - egl_g3d_destroy_probe(drv, NULL); - free(gdrv); -} - -_EGLDriver * -_eglMain(const char *args) -{ - static char driver_name[64]; - struct egl_g3d_driver *gdrv; - - snprintf(driver_name, sizeof(driver_name), - "Gallium/%s", native_get_name()); - - gdrv = CALLOC_STRUCT(egl_g3d_driver); - if (!gdrv) - return NULL; - - _eglInitDriverFallbacks(&gdrv->base); - - gdrv->base.API.Initialize = egl_g3d_initialize; - gdrv->base.API.Terminate = egl_g3d_terminate; - gdrv->base.API.CreateContext = egl_g3d_create_context; - gdrv->base.API.DestroyContext = egl_g3d_destroy_context; - gdrv->base.API.CreateWindowSurface = egl_g3d_create_window_surface; - gdrv->base.API.CreatePixmapSurface = egl_g3d_create_pixmap_surface; - gdrv->base.API.CreatePbufferSurface = egl_g3d_create_pbuffer_surface; - gdrv->base.API.DestroySurface = egl_g3d_destroy_surface; - gdrv->base.API.MakeCurrent = egl_g3d_make_current; - gdrv->base.API.SwapBuffers = egl_g3d_swap_buffers; - gdrv->base.API.CopyBuffers = egl_g3d_copy_buffers; - gdrv->base.API.WaitClient = egl_g3d_wait_client; - gdrv->base.API.WaitNative = egl_g3d_wait_native; - gdrv->base.API.GetProcAddress = egl_g3d_get_proc_address; - - gdrv->base.API.BindTexImage = egl_g3d_bind_tex_image; - gdrv->base.API.ReleaseTexImage = egl_g3d_release_tex_image; - -#ifdef EGL_MESA_screen_surface - gdrv->base.API.CreateScreenSurfaceMESA = egl_g3d_create_screen_surface; - gdrv->base.API.ShowScreenSurfaceMESA = egl_g3d_show_screen_surface; -#endif - - gdrv->base.Name = driver_name; - gdrv->base.Probe = egl_g3d_probe; - gdrv->base.Unload = egl_g3d_unload; - - /* the key is " EGL G3D" */ - gdrv->probe_key = 0x0E61063D; - - return &gdrv->base; -} diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h deleted file mode 100644 index 3dae8c40529..00000000000 --- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef _EGL_G3D_H_ -#define _EGL_G3D_H_ - -#include "pipe/p_compiler.h" -#include "pipe/p_screen.h" -#include "pipe/p_context.h" -#include "pipe/p_format.h" -#include "egldriver.h" -#include "egldisplay.h" -#include "eglcontext.h" -#include "eglsurface.h" -#include "eglconfig.h" -#include "eglscreen.h" -#include "eglmode.h" - -#include "native.h" -#include "egl_st.h" - -struct egl_g3d_driver { - _EGLDriver base; - const struct egl_g3d_st *stapis[NUM_EGL_G3D_STS]; - EGLint api_mask; - - EGLint probe_key; -}; - -struct egl_g3d_display { - struct native_display *native; -}; - -struct egl_g3d_buffer { - struct st_framebuffer *st_fb; - uint attachment_mask; -}; - -struct egl_g3d_context { - _EGLContext base; - - const struct egl_g3d_st *stapi; - struct pipe_context *pipe; - - struct st_context *st_ctx; - EGLBoolean force_validate; - struct egl_g3d_buffer draw, read; -}; - -struct egl_g3d_surface { - _EGLSurface base; - struct native_surface *native; - enum native_attachment render_att; - struct pipe_surface *render_surface; - unsigned int sequence_number; -}; - -struct egl_g3d_config { - _EGLConfig base; - const struct native_config *native; -}; - -struct egl_g3d_screen { - _EGLScreen base; - const struct native_connector *native; - const struct native_mode **native_modes; -}; - -static INLINE struct egl_g3d_driver * -egl_g3d_driver(_EGLDriver *drv) -{ - return (struct egl_g3d_driver *) drv; -} - -static INLINE struct egl_g3d_display * -egl_g3d_display(_EGLDisplay *dpy) -{ - /* note that it is not direct casting */ - return (struct egl_g3d_display *) dpy->DriverData; -} - -static INLINE struct egl_g3d_context * -egl_g3d_context(_EGLContext *ctx) -{ - return (struct egl_g3d_context *) ctx; -} - -static INLINE struct egl_g3d_surface * -egl_g3d_surface(_EGLSurface *surf) -{ - return (struct egl_g3d_surface *) surf; -} - -static INLINE struct egl_g3d_config * -egl_g3d_config(_EGLConfig *conf) -{ - return (struct egl_g3d_config *) conf; -} - -static INLINE struct egl_g3d_screen * -egl_g3d_screen(_EGLScreen *scr) -{ - return (struct egl_g3d_screen *) scr; -} - -#endif /* _EGL_G3D_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_st.c b/src/gallium/state_trackers/egl_g3d/common/egl_st.c deleted file mode 100644 index a88ff911cd5..00000000000 --- a/src/gallium/state_trackers/egl_g3d/common/egl_st.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include "pipe/p_compiler.h" -#include "util/u_memory.h" -#include "egllog.h" -#include "EGL/egl.h" /* for EGL_api_BIT */ - -#include "egl_st.h" - -#ifndef HAVE_DLADDR -#define HAVE_DLADDR 1 -#endif - -#if HAVE_DLADDR - -static const char * -egl_g3d_st_names[] = { -#define ST_PUBLIC(name, ...) #name, -#include "st_public_tmp.h" - NULL -}; - -static boolean -egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym) -{ - st_proc *procs = (st_proc *) stapi; - void *handle; - Dl_info info; - const char **name; - - if (!dladdr(sym, &info)) - return FALSE; - handle = dlopen(info.dli_fname, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE); - if (!handle) - return FALSE; - - for (name = egl_g3d_st_names; *name; name++) { - st_proc proc = (st_proc) dlsym(handle, *name); - if (!proc) { - _eglLog(_EGL_WARNING, "%s is missing in %s", *name, info.dli_fname); - memset(stapi, 0, sizeof(*stapi)); - dlclose(handle); - return FALSE; - } - *procs++ = proc; - } - - dlclose(handle); - return TRUE; -} - -#else /* HAVE_DLADDR */ - -static boolean -egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym) -{ -#define ST_PUBLIC(name, ...) stapi->name = name; -#include "st_public_tmp.h" - return TRUE; -} - -#endif /* HAVE_DLADDR */ - -static boolean -egl_g3d_init_st(struct egl_g3d_st *stapi, const char *api) -{ - void *handle, *sym; - boolean res = FALSE; - - /* already initialized */ - if (stapi->st_notify_swapbuffers != NULL) - return TRUE; - - handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL); - if (!handle) - return FALSE; - - sym = dlsym(handle, api); - if (sym && egl_g3d_fill_st(stapi, sym)) - res = TRUE; - - dlclose(handle); - return res; -} - -static struct { - const char *symbol; - EGLint api_bit; -} egl_g3d_st_info[NUM_EGL_G3D_STS] = { - { "st_api_OpenGL_ES1", EGL_OPENGL_ES_BIT }, - { "st_api_OpenVG", EGL_OPENVG_BIT }, - { "st_api_OpenGL_ES2", EGL_OPENGL_ES2_BIT }, - { "st_api_OpenGL", EGL_OPENGL_BIT }, -}; - -const struct egl_g3d_st * -egl_g3d_get_st(enum egl_g3d_st_api api) -{ - static struct egl_g3d_st all_trackers[NUM_EGL_G3D_STS]; - - if (egl_g3d_init_st(&all_trackers[api], egl_g3d_st_info[api].symbol)) { - all_trackers[api].api_bit = egl_g3d_st_info[api].api_bit; - return &all_trackers[api]; - } - else { - return NULL; - } -} diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_st.h b/src/gallium/state_trackers/egl_g3d/common/egl_st.h deleted file mode 100644 index 8fb464bd3d7..00000000000 --- a/src/gallium/state_trackers/egl_g3d/common/egl_st.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef _EGL_ST_H_ -#define _EGL_ST_H_ - -#include "GL/gl.h" /* for GL types */ -#include "GL/internal/glcore.h" /* for __GLcontextModes */ - -#include "pipe/p_compiler.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" - -/* avoid calling st functions directly */ -#if 1 - -#define ST_SURFACE_FRONT_LEFT 0 -#define ST_SURFACE_BACK_LEFT 1 -#define ST_SURFACE_FRONT_RIGHT 2 -#define ST_SURFACE_BACK_RIGHT 3 - -#define ST_TEXTURE_2D 0x2 - -struct st_context; -struct st_framebuffer; -typedef void (*st_proc)(); - -#else -#include "state_tracker/st_public.h" -#endif - -/* remember to update egl_g3d_get_st() when update the enums */ -enum egl_g3d_st_api { - EGL_G3D_ST_OPENGL_ES = 0, - EGL_G3D_ST_OPENVG, - EGL_G3D_ST_OPENGL_ES2, - EGL_G3D_ST_OPENGL, - - NUM_EGL_G3D_STS -}; - -struct egl_g3d_st { -#define ST_PUBLIC(name, ret, ...) ret (*name)(__VA_ARGS__); -#include "st_public_tmp.h" - /* fields must be added here */ - EGLint api_bit; -}; - -const struct egl_g3d_st * -egl_g3d_get_st(enum egl_g3d_st_api api); - -#endif /* _EGL_ST_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/common/native.h b/src/gallium/state_trackers/egl_g3d/common/native.h deleted file mode 100644 index 72a9cec7ef1..00000000000 --- a/src/gallium/state_trackers/egl_g3d/common/native.h +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef _NATIVE_H_ -#define _NATIVE_H_ - -#include "EGL/egl.h" /* for EGL native types */ -#include "GL/gl.h" /* for GL types needed by __GLcontextModes */ -#include "GL/internal/glcore.h" /* for __GLcontextModes */ - -#include "pipe/p_compiler.h" -#include "pipe/p_screen.h" -#include "pipe/p_context.h" -#include "pipe/p_state.h" - -/** - * Only color buffers are listed. The others are allocated privately through, - * for example, st_renderbuffer_alloc_storage(). - */ -enum native_attachment { - NATIVE_ATTACHMENT_FRONT_LEFT, - NATIVE_ATTACHMENT_BACK_LEFT, - NATIVE_ATTACHMENT_FRONT_RIGHT, - NATIVE_ATTACHMENT_BACK_RIGHT, - - NUM_NATIVE_ATTACHMENTS -}; - -/** - * Enumerations for probe results. - */ -enum native_probe_result { - NATIVE_PROBE_UNKNOWN, - NATIVE_PROBE_FALLBACK, - NATIVE_PROBE_SUPPORTED, - NATIVE_PROBE_EXACT, -}; - -/** - * A probe object for display probe. - */ -struct native_probe { - int magic; - EGLNativeDisplayType display; - void *data; - - void (*destroy)(struct native_probe *nprobe); -}; - -struct native_surface { - void (*destroy)(struct native_surface *nsurf); - - /** - * Swap the front and back buffers so that the back buffer is visible. It - * is no-op if the surface is single-buffered. The contents of the back - * buffer after swapping may or may not be preserved. - */ - boolean (*swap_buffers)(struct native_surface *nsurf); - - /** - * Make the front buffer visible. In some native displays, changes to the - * front buffer might not be visible immediately and require manual flush. - */ - boolean (*flush_frontbuffer)(struct native_surface *nsurf); - - /** - * Validate the buffers of the surface. textures, if not NULL, points to an - * array of size NUM_NATIVE_ATTACHMENTS and the returned textures are owned - * by the caller. A sequence number is also returned. The caller can use - * it to check if anything has changed since the last call. Any of the - * pointers may be NULL and it indicates the caller has no interest in those - * values. - * - * If this function is called multiple times with different attachment - * masks, those not listed in the latest call might be destroyed. This - * behavior might change in the future. - */ - boolean (*validate)(struct native_surface *nsurf, uint attachment_mask, - unsigned int *seq_num, struct pipe_texture **textures, - int *width, int *height); - - /** - * Wait until all native commands affecting the surface has been executed. - */ - void (*wait)(struct native_surface *nsurf); -}; - -struct native_config { - /* __GLcontextModes should go away some day */ - __GLcontextModes mode; - enum pipe_format color_format; - enum pipe_format depth_format; - enum pipe_format stencil_format; - - /* treat it as an additional flag to mode.drawableType */ - boolean scanout_bit; -}; - -struct native_connector { - int dummy; -}; - -struct native_mode { - const char *desc; - int width, height; - int refresh_rate; -}; - -struct native_display_modeset; - -/** - * A pipe winsys abstracts the OS. A pipe screen abstracts the graphcis - * hardware. A native display consists of a pipe winsys, a pipe screen, and - * the native display server. - */ -struct native_display { - /** - * The pipe screen of the native display. - * - * Note that the "flush_frontbuffer" and "update_buffer" callbacks will be - * overridden. - */ - struct pipe_screen *screen; - - void (*destroy)(struct native_display *ndpy); - - /** - * Get the supported configs. The configs are owned by the display, but - * the returned array should be free()ed. - * - * The configs will be converted to EGL config by - * _eglConfigFromContextModesRec and validated by _eglValidateConfig. - * Those failing to pass the test will be skipped. - */ - const struct native_config **(*get_configs)(struct native_display *ndpy, - int *num_configs); - - /** - * Test if a pixmap is supported by the given config. Required unless no - * config has GLX_PIXMAP_BIT set. - * - * This function is usually called to find a config that supports a given - * pixmap. Thus, it is usually called with the same pixmap in a row. - */ - boolean (*is_pixmap_supported)(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf); - - /** - * Create a pipe context. - */ - struct pipe_context *(*create_context)(struct native_display *ndpy, - void *context_private); - - /** - * Create a window surface. Required unless no config has GLX_WINDOW_BIT - * set. - */ - struct native_surface *(*create_window_surface)(struct native_display *ndpy, - EGLNativeWindowType win, - const struct native_config *nconf); - - /** - * Create a pixmap surface. Required unless no config has GLX_PIXMAP_BIT - * set. - */ - struct native_surface *(*create_pixmap_surface)(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf); - - /** - * Create a pbuffer surface. Required unless no config has GLX_PBUFFER_BIT - * set. - */ - struct native_surface *(*create_pbuffer_surface)(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height); - - const struct native_display_modeset *modeset; -}; - -/** - * Mode setting interface of the native display. It exposes the mode setting - * capabilities of the underlying graphics hardware. - */ -struct native_display_modeset { - /** - * Get the available physical connectors and the number of CRTCs. - */ - const struct native_connector **(*get_connectors)(struct native_display *ndpy, - int *num_connectors, - int *num_crtcs); - - /** - * Get the current supported modes of a connector. The returned modes may - * change every time this function is called and those from previous calls - * might become invalid. - */ - const struct native_mode **(*get_modes)(struct native_display *ndpy, - const struct native_connector *nconn, - int *num_modes); - - /** - * Create a scan-out surface. Required unless no config has - * GLX_SCREEN_BIT_MESA set. - */ - struct native_surface *(*create_scanout_surface)(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height); - - /** - * Program the CRTC to output the surface to the given connectors with the - * given mode. When surface is not given, the CRTC is disabled. - * - * This interface does not export a way to query capabilities of the CRTCs. - * The native display usually needs to dynamically map the index to a CRTC - * that supports the given connectors. - */ - boolean (*program)(struct native_display *ndpy, int crtc_idx, - struct native_surface *nsurf, uint x, uint y, - const struct native_connector **nconns, int num_nconns, - const struct native_mode *nmode); -}; - -/** - * Test whether an attachment is set in the mask. - */ -static INLINE boolean -native_attachment_mask_test(uint mask, enum native_attachment att) -{ - return !!(mask & (1 << att)); -} - -/** - * Return a probe object for the given display. - * - * Note that the returned object may be cached and used by different native - * display modules. It allows fast probing when multiple modules probe the - * same display. - */ -struct native_probe * -native_create_probe(EGLNativeDisplayType dpy); - -/** - * Probe the probe object. - */ -enum native_probe_result -native_get_probe_result(struct native_probe *nprobe); - -const char * -native_get_name(void); - -struct native_display * -native_create_display(EGLNativeDisplayType dpy); - -#endif /* _NATIVE_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/common/st_public_tmp.h b/src/gallium/state_trackers/egl_g3d/common/st_public_tmp.h deleted file mode 100644 index 507a0ec4027..00000000000 --- a/src/gallium/state_trackers/egl_g3d/common/st_public_tmp.h +++ /dev/null @@ -1,20 +0,0 @@ -ST_PUBLIC(st_create_context, struct st_context *, struct pipe_context *pipe, const __GLcontextModes *visual, struct st_context *share) -ST_PUBLIC(st_destroy_context, void, struct st_context *st) -ST_PUBLIC(st_copy_context_state, void, struct st_context *dst, struct st_context *src, uint mask) -ST_PUBLIC(st_create_framebuffer, struct st_framebuffer *, const __GLcontextModes *visual, enum pipe_format colorFormat, enum pipe_format depthFormat, enum pipe_format stencilFormat, uint width, uint height, void *privateData) -ST_PUBLIC(st_resize_framebuffer, void, struct st_framebuffer *stfb, uint width, uint height) -ST_PUBLIC(st_set_framebuffer_surface, void, struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface *surf) -ST_PUBLIC(st_get_framebuffer_dimensions, void, struct st_framebuffer *stfb, uint *width, uint *height) -ST_PUBLIC(st_get_framebuffer_surface, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface **surface) -ST_PUBLIC(st_get_framebuffer_texture, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_texture **texture) -ST_PUBLIC(st_framebuffer_private, void *, struct st_framebuffer *stfb) -ST_PUBLIC(st_unreference_framebuffer, void, struct st_framebuffer *stfb) -ST_PUBLIC(st_make_current, GLboolean, struct st_context *st, struct st_framebuffer *draw, struct st_framebuffer *read) -ST_PUBLIC(st_get_current, struct st_context *, void) -ST_PUBLIC(st_flush, void, struct st_context *st, uint pipeFlushFlags, struct pipe_fence_handle **fence) -ST_PUBLIC(st_finish, void, struct st_context *st) -ST_PUBLIC(st_notify_swapbuffers, void, struct st_framebuffer *stfb) -ST_PUBLIC(st_bind_texture_surface, int, struct pipe_surface *ps, int target, int level, enum pipe_format format) -ST_PUBLIC(st_unbind_texture_surface, int, struct pipe_surface *ps, int target, int level) -ST_PUBLIC(st_get_proc_address, st_proc, const char *procname) -#undef ST_PUBLIC diff --git a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c b/src/gallium/state_trackers/egl_g3d/kms/native_kms.c deleted file mode 100644 index d5baf2c2f05..00000000000 --- a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c +++ /dev/null @@ -1,866 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -#include "pipe/p_screen.h" -#include "pipe/p_context.h" -#include "util/u_debug.h" -#include "util/u_memory.h" -#include "egllog.h" - -#include "native_kms.h" - -static boolean -kms_surface_validate(struct native_surface *nsurf, uint attachment_mask, - unsigned int *seq_num, struct pipe_texture **textures, - int *width, int *height) -{ - struct kms_surface *ksurf = kms_surface(nsurf); - struct kms_display *kdpy = ksurf->kdpy; - struct pipe_screen *screen = kdpy->base.screen; - struct pipe_texture templ, *ptex; - int att; - - if (attachment_mask) { - memset(&templ, 0, sizeof(templ)); - templ.target = PIPE_TEXTURE_2D; - templ.last_level = 0; - templ.width0 = ksurf->width; - templ.height0 = ksurf->height; - templ.depth0 = 1; - templ.format = ksurf->color_format; - templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; - if (ksurf->type == KMS_SURFACE_TYPE_SCANOUT) - templ.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; - } - - /* create textures */ - for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { - /* delay the allocation */ - if (!native_attachment_mask_test(attachment_mask, att)) - continue; - - ptex = ksurf->textures[att]; - if (!ptex) { - ptex = screen->texture_create(screen, &templ); - ksurf->textures[att] = ptex; - } - - if (textures) { - textures[att] = NULL; - pipe_texture_reference(&textures[att], ptex); - } - } - - if (seq_num) - *seq_num = ksurf->sequence_number; - if (width) - *width = ksurf->width; - if (height) - *height = ksurf->height; - - return TRUE; -} - -/** - * Add textures as DRM framebuffers. - */ -static boolean -kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back) -{ - struct kms_surface *ksurf = kms_surface(nsurf); - struct kms_display *kdpy = ksurf->kdpy; - int num_framebuffers = (need_back) ? 2 : 1; - int i, err; - - for (i = 0; i < num_framebuffers; i++) { - struct kms_framebuffer *fb; - enum native_attachment natt; - unsigned int handle, stride; - uint block_bits; - - if (i == 0) { - fb = &ksurf->front_fb; - natt = NATIVE_ATTACHMENT_FRONT_LEFT; - } - else { - fb = &ksurf->back_fb; - natt = NATIVE_ATTACHMENT_BACK_LEFT; - } - - if (!fb->texture) { - /* make sure the texture has been allocated */ - kms_surface_validate(&ksurf->base, 1 << natt, NULL, NULL, NULL, NULL); - if (!ksurf->textures[natt]) - return FALSE; - - pipe_texture_reference(&fb->texture, ksurf->textures[natt]); - } - - /* already initialized */ - if (fb->buffer_id) - continue; - - /* TODO detect the real value */ - fb->is_passive = TRUE; - - if (!kdpy->api->local_handle_from_texture(kdpy->api, - kdpy->base.screen, fb->texture, &stride, &handle)) - return FALSE; - - block_bits = util_format_get_blocksizebits(ksurf->color_format); - err = drmModeAddFB(kdpy->fd, ksurf->width, ksurf->height, - block_bits, block_bits, stride, handle, &fb->buffer_id); - if (err) { - fb->buffer_id = 0; - return FALSE; - } - } - - return TRUE; -} - -static boolean -kms_surface_flush_frontbuffer(struct native_surface *nsurf) -{ -#ifdef DRM_MODE_FEATURE_DIRTYFB - struct kms_surface *ksurf = kms_surface(nsurf); - struct kms_display *kdpy = ksurf->kdpy; - - /* pbuffer is private */ - if (ksurf->type == KMS_SURFACE_TYPE_PBUFFER) - return TRUE; - - if (ksurf->front_fb.is_passive) - drmModeDirtyFB(kdpy->fd, ksurf->front_fb.buffer_id, NULL, 0); -#endif - - return TRUE; -} - -static boolean -kms_surface_swap_buffers(struct native_surface *nsurf) -{ - struct kms_surface *ksurf = kms_surface(nsurf); - struct kms_crtc *kcrtc = &ksurf->current_crtc; - struct kms_display *kdpy = ksurf->kdpy; - struct kms_framebuffer tmp_fb; - struct pipe_texture *tmp_texture; - int err; - - /* pbuffer is private */ - if (ksurf->type == KMS_SURFACE_TYPE_PBUFFER) - return TRUE; - - if (!ksurf->back_fb.buffer_id) { - if (!kms_surface_init_framebuffers(&ksurf->base, TRUE)) - return FALSE; - } - - if (ksurf->is_shown && kcrtc->crtc) { - err = drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id, - ksurf->back_fb.buffer_id, kcrtc->crtc->x, kcrtc->crtc->y, - kcrtc->connectors, kcrtc->num_connectors, &kcrtc->crtc->mode); - if (err) - return FALSE; - } - - /* swap the buffers */ - tmp_fb = ksurf->front_fb; - ksurf->front_fb = ksurf->back_fb; - ksurf->back_fb = tmp_fb; - - tmp_texture = ksurf->textures[NATIVE_ATTACHMENT_FRONT_LEFT]; - ksurf->textures[NATIVE_ATTACHMENT_FRONT_LEFT] = - ksurf->textures[NATIVE_ATTACHMENT_BACK_LEFT]; - ksurf->textures[NATIVE_ATTACHMENT_BACK_LEFT] = tmp_texture; - - /* the front/back textures are swapped */ - ksurf->sequence_number++; - - return TRUE; -} - -static void -kms_surface_wait(struct native_surface *nsurf) -{ - /* no-op */ -} - -static void -kms_surface_destroy(struct native_surface *nsurf) -{ - struct kms_surface *ksurf = kms_surface(nsurf); - int i; - - if (ksurf->current_crtc.crtc) - drmModeFreeCrtc(ksurf->current_crtc.crtc); - - if (ksurf->front_fb.buffer_id) - drmModeRmFB(ksurf->kdpy->fd, ksurf->front_fb.buffer_id); - pipe_texture_reference(&ksurf->front_fb.texture, NULL); - - if (ksurf->back_fb.buffer_id) - drmModeRmFB(ksurf->kdpy->fd, ksurf->back_fb.buffer_id); - pipe_texture_reference(&ksurf->back_fb.texture, NULL); - - for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { - struct pipe_texture *ptex = ksurf->textures[i]; - pipe_texture_reference(&ptex, NULL); - } - - free(ksurf); -} - -static struct kms_surface * -kms_display_create_surface(struct native_display *ndpy, - enum kms_surface_type type, - const struct native_config *nconf, - uint width, uint height) -{ - struct kms_display *kdpy = kms_display(ndpy); - struct kms_config *kconf = kms_config(nconf); - struct kms_surface *ksurf; - - ksurf = CALLOC_STRUCT(kms_surface); - if (!ksurf) - return NULL; - - ksurf->kdpy = kdpy; - ksurf->type = type; - ksurf->color_format = kconf->base.color_format; - ksurf->width = width; - ksurf->height = height; - - ksurf->base.destroy = kms_surface_destroy; - ksurf->base.swap_buffers = kms_surface_swap_buffers; - ksurf->base.flush_frontbuffer = kms_surface_flush_frontbuffer; - ksurf->base.validate = kms_surface_validate; - ksurf->base.wait = kms_surface_wait; - - return ksurf; -} - -/** - * Choose a CRTC that supports all given connectors. - */ -static uint32_t -kms_display_choose_crtc(struct native_display *ndpy, - uint32_t *connectors, int num_connectors) -{ - struct kms_display *kdpy = kms_display(ndpy); - int idx; - - for (idx = 0; idx < kdpy->resources->count_crtcs; idx++) { - boolean found_crtc = TRUE; - int i, j; - - for (i = 0; i < num_connectors; i++) { - drmModeConnectorPtr connector; - int encoder_idx = -1; - - connector = drmModeGetConnector(kdpy->fd, connectors[i]); - if (!connector) { - found_crtc = FALSE; - break; - } - - /* find an encoder the CRTC supports */ - for (j = 0; j < connector->count_encoders; j++) { - drmModeEncoderPtr encoder = - drmModeGetEncoder(kdpy->fd, connector->encoders[j]); - if (encoder->possible_crtcs & (1 << idx)) { - encoder_idx = j; - break; - } - drmModeFreeEncoder(encoder); - } - - drmModeFreeConnector(connector); - if (encoder_idx < 0) { - found_crtc = FALSE; - break; - } - } - - if (found_crtc) - break; - } - - if (idx >= kdpy->resources->count_crtcs) { - _eglLog(_EGL_WARNING, - "failed to find a CRTC that supports the given %d connectors", - num_connectors); - return 0; - } - - return kdpy->resources->crtcs[idx]; -} - -/** - * Remember the original CRTC status and set the CRTC - */ -static boolean -kms_display_set_crtc(struct native_display *ndpy, int crtc_idx, - uint32_t buffer_id, uint32_t x, uint32_t y, - uint32_t *connectors, int num_connectors, - drmModeModeInfoPtr mode) -{ - struct kms_display *kdpy = kms_display(ndpy); - struct kms_crtc *kcrtc = &kdpy->saved_crtcs[crtc_idx]; - uint32_t crtc_id; - int err; - - if (kcrtc->crtc) { - crtc_id = kcrtc->crtc->crtc_id; - } - else { - int count = 0, i; - - /* - * Choose the CRTC once. It could be more dynamic, but let's keep it - * simple for now. - */ - crtc_id = kms_display_choose_crtc(&kdpy->base, - connectors, num_connectors); - - /* save the original CRTC status */ - kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id); - if (!kcrtc->crtc) - return FALSE; - - for (i = 0; i < kdpy->num_connectors; i++) { - struct kms_connector *kconn = &kdpy->connectors[i]; - drmModeConnectorPtr connector = kconn->connector; - drmModeEncoderPtr encoder; - - encoder = drmModeGetEncoder(kdpy->fd, connector->encoder_id); - if (encoder) { - if (encoder->crtc_id == crtc_id) { - kcrtc->connectors[count++] = connector->connector_id; - if (count >= Elements(kcrtc->connectors)) - break; - } - drmModeFreeEncoder(encoder); - } - } - - kcrtc->num_connectors = count; - } - - err = drmModeSetCrtc(kdpy->fd, crtc_id, buffer_id, x, y, - connectors, num_connectors, mode); - if (err) { - drmModeFreeCrtc(kcrtc->crtc); - kcrtc->crtc = NULL; - kcrtc->num_connectors = 0; - - return FALSE; - } - - return TRUE; -} - -static boolean -kms_display_program(struct native_display *ndpy, int crtc_idx, - struct native_surface *nsurf, uint x, uint y, - const struct native_connector **nconns, int num_nconns, - const struct native_mode *nmode) -{ - struct kms_display *kdpy = kms_display(ndpy); - struct kms_surface *ksurf = kms_surface(nsurf); - const struct kms_mode *kmode = kms_mode(nmode); - uint32_t connector_ids[32]; - uint32_t buffer_id; - drmModeModeInfo mode_tmp, *mode; - int i; - - if (num_nconns > Elements(connector_ids)) { - _eglLog(_EGL_WARNING, "too many connectors (%d)", num_nconns); - num_nconns = Elements(connector_ids); - } - - if (ksurf) { - if (!kms_surface_init_framebuffers(&ksurf->base, FALSE)) - return FALSE; - - buffer_id = ksurf->front_fb.buffer_id; - /* the mode argument of drmModeSetCrtc is not constified */ - mode_tmp = kmode->mode; - mode = &mode_tmp; - } - else { - /* disable the CRTC */ - buffer_id = 0; - mode = NULL; - num_nconns = 0; - } - - for (i = 0; i < num_nconns; i++) { - struct kms_connector *kconn = kms_connector(nconns[i]); - connector_ids[i] = kconn->connector->connector_id; - } - - if (!kms_display_set_crtc(&kdpy->base, crtc_idx, buffer_id, x, y, - connector_ids, num_nconns, mode)) { - _eglLog(_EGL_WARNING, "failed to set CRTC %d", crtc_idx); - - return FALSE; - } - - if (kdpy->shown_surfaces[crtc_idx]) - kdpy->shown_surfaces[crtc_idx]->is_shown = FALSE; - kdpy->shown_surfaces[crtc_idx] = ksurf; - - /* remember the settings for buffer swapping */ - if (ksurf) { - uint32_t crtc_id = kdpy->saved_crtcs[crtc_idx].crtc->crtc_id; - struct kms_crtc *kcrtc = &ksurf->current_crtc; - - if (kcrtc->crtc) - drmModeFreeCrtc(kcrtc->crtc); - kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id); - - assert(num_nconns < Elements(kcrtc->connectors)); - memcpy(kcrtc->connectors, connector_ids, - sizeof(*connector_ids) * num_nconns); - kcrtc->num_connectors = num_nconns; - - ksurf->is_shown = TRUE; - } - - return TRUE; -} - -static const struct native_mode ** -kms_display_get_modes(struct native_display *ndpy, - const struct native_connector *nconn, - int *num_modes) -{ - struct kms_display *kdpy = kms_display(ndpy); - struct kms_connector *kconn = kms_connector(nconn); - const struct native_mode **nmodes_return; - int count, i; - - /* delete old data */ - if (kconn->connector) { - drmModeFreeConnector(kconn->connector); - free(kconn->kms_modes); - - kconn->connector = NULL; - kconn->kms_modes = NULL; - kconn->num_modes = 0; - } - - /* detect again */ - kconn->connector = drmModeGetConnector(kdpy->fd, kconn->connector_id); - if (!kconn->connector) - return NULL; - - count = kconn->connector->count_modes; - kconn->kms_modes = calloc(count, sizeof(*kconn->kms_modes)); - if (!kconn->kms_modes) { - drmModeFreeConnector(kconn->connector); - kconn->connector = NULL; - - return NULL; - } - - for (i = 0; i < count; i++) { - struct kms_mode *kmode = &kconn->kms_modes[i]; - drmModeModeInfoPtr mode = &kconn->connector->modes[i]; - - kmode->mode = *mode; - - kmode->base.desc = kmode->mode.name; - kmode->base.width = kmode->mode.hdisplay; - kmode->base.height = kmode->mode.vdisplay; - kmode->base.refresh_rate = kmode->mode.vrefresh / 1000; - } - - nmodes_return = malloc(count * sizeof(*nmodes_return)); - if (nmodes_return) { - for (i = 0; i < count; i++) - nmodes_return[i] = &kconn->kms_modes[i].base; - if (num_modes) - *num_modes = count; - } - - return nmodes_return; -} - -static const struct native_connector ** -kms_display_get_connectors(struct native_display *ndpy, int *num_connectors, - int *num_crtc) -{ - struct kms_display *kdpy = kms_display(ndpy); - const struct native_connector **connectors; - int i; - - if (!kdpy->connectors) { - kdpy->connectors = - calloc(kdpy->resources->count_connectors, sizeof(*kdpy->connectors)); - if (!kdpy->connectors) - return NULL; - - for (i = 0; i < kdpy->resources->count_connectors; i++) { - struct kms_connector *kconn = &kdpy->connectors[i]; - - kconn->connector_id = kdpy->resources->connectors[i]; - /* kconn->connector is allocated when the modes are asked */ - } - - kdpy->num_connectors = kdpy->resources->count_connectors; - } - - connectors = malloc(kdpy->num_connectors * sizeof(*connectors)); - if (connectors) { - for (i = 0; i < kdpy->num_connectors; i++) - connectors[i] = &kdpy->connectors[i].base; - if (num_connectors) - *num_connectors = kdpy->num_connectors; - } - - if (num_crtc) - *num_crtc = kdpy->resources->count_crtcs; - - return connectors; -} - -static struct native_surface * -kms_display_create_scanout_surface(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height) -{ - struct kms_surface *ksurf; - - ksurf = kms_display_create_surface(ndpy, - KMS_SURFACE_TYPE_SCANOUT, nconf, width, height); - return &ksurf->base; -} - -static struct native_surface * -kms_display_create_pbuffer_surface(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height) -{ - struct kms_surface *ksurf; - - ksurf = kms_display_create_surface(ndpy, - KMS_SURFACE_TYPE_PBUFFER, nconf, width, height); - return &ksurf->base; -} - -static struct pipe_context * -kms_display_create_context(struct native_display *ndpy, void *context_private) -{ - struct kms_display *kdpy = kms_display(ndpy); - struct pipe_context *pctx; - - pctx = kdpy->api->create_context(kdpy->api, kdpy->base.screen); - if (pctx) - pctx->priv = context_private; - return pctx; -} - -static boolean -kms_display_is_format_supported(struct native_display *ndpy, - enum pipe_format fmt, boolean is_color) -{ - return ndpy->screen->is_format_supported(ndpy->screen, - fmt, PIPE_TEXTURE_2D, - (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET : - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); -} - -static const struct native_config ** -kms_display_get_configs(struct native_display *ndpy, int *num_configs) -{ - struct kms_display *kdpy = kms_display(ndpy); - const struct native_config **configs; - - /* first time */ - if (!kdpy->config) { - struct native_config *nconf; - enum pipe_format format; - - kdpy->config = calloc(1, sizeof(*kdpy->config)); - if (!kdpy->config) - return NULL; - - nconf = &kdpy->config->base; - - /* always double-buffered */ - nconf->mode.doubleBufferMode = TRUE; - - format = PIPE_FORMAT_A8R8G8B8_UNORM; - if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) { - format = PIPE_FORMAT_B8G8R8A8_UNORM; - if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) - format = PIPE_FORMAT_NONE; - } - if (format == PIPE_FORMAT_NONE) - return NULL; - - nconf->color_format = format; - nconf->mode.redBits = 8; - nconf->mode.greenBits = 8; - nconf->mode.blueBits = 8; - nconf->mode.alphaBits = 8; - nconf->mode.rgbBits = 32; - - format = PIPE_FORMAT_S8Z24_UNORM; - if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) { - format = PIPE_FORMAT_Z24S8_UNORM; - if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) - format = PIPE_FORMAT_NONE; - } - if (format != PIPE_FORMAT_NONE) { - nconf->depth_format = format; - nconf->stencil_format = format; - - nconf->mode.depthBits = 24; - nconf->mode.stencilBits = 8; - nconf->mode.haveDepthBuffer = TRUE; - nconf->mode.haveStencilBuffer = TRUE; - } - - nconf->scanout_bit = TRUE; - nconf->mode.drawableType = GLX_PBUFFER_BIT; - nconf->mode.swapMethod = GLX_SWAP_EXCHANGE_OML; - - nconf->mode.visualID = 0; - nconf->mode.visualType = EGL_NONE; - - nconf->mode.renderType = GLX_RGBA_BIT; - nconf->mode.rgbMode = TRUE; - nconf->mode.xRenderable = FALSE; - } - - configs = malloc(sizeof(*configs)); - if (configs) { - configs[0] = &kdpy->config->base; - if (num_configs) - *num_configs = 1; - } - - return configs; -} - -static void -kms_display_destroy(struct native_display *ndpy) -{ - struct kms_display *kdpy = kms_display(ndpy); - int i; - - if (kdpy->config) - free(kdpy->config); - - if (kdpy->connectors) { - for (i = 0; i < kdpy->num_connectors; i++) { - struct kms_connector *kconn = &kdpy->connectors[i]; - if (kconn->connector) { - drmModeFreeConnector(kconn->connector); - free(kconn->kms_modes); - } - } - free(kdpy->connectors); - } - - if (kdpy->shown_surfaces) - free(kdpy->shown_surfaces); - - if (kdpy->saved_crtcs) { - for (i = 0; i < kdpy->resources->count_crtcs; i++) { - struct kms_crtc *kcrtc = &kdpy->saved_crtcs[i]; - - if (kcrtc->crtc) { - /* restore crtc */ - drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id, - kcrtc->crtc->buffer_id, kcrtc->crtc->x, kcrtc->crtc->y, - kcrtc->connectors, kcrtc->num_connectors, - &kcrtc->crtc->mode); - - drmModeFreeCrtc(kcrtc->crtc); - } - } - free(kdpy->saved_crtcs); - } - - if (kdpy->resources) - drmModeFreeResources(kdpy->resources); - - if (kdpy->base.screen) - kdpy->base.screen->destroy(kdpy->base.screen); - - if (kdpy->fd >= 0) - drmClose(kdpy->fd); - - if (kdpy->api) - kdpy->api->destroy(kdpy->api); - free(kdpy); -} - -/** - * Initialize KMS and pipe screen. - */ -static boolean -kms_display_init_screen(struct native_display *ndpy) -{ - struct kms_display *kdpy = kms_display(ndpy); - struct drm_create_screen_arg arg; - int fd; - - fd = drmOpen(kdpy->api->name, NULL); - if (fd < 0) { - _eglLog(_EGL_WARNING, "failed to open DRM device"); - return FALSE; - } - -#if 0 - if (drmSetMaster(fd)) { - _eglLog(_EGL_WARNING, "failed to become DRM master"); - return FALSE; - } -#endif - - memset(&arg, 0, sizeof(arg)); - arg.mode = DRM_CREATE_NORMAL; - kdpy->base.screen = kdpy->api->create_screen(kdpy->api, fd, &arg); - if (!kdpy->base.screen) { - _eglLog(_EGL_WARNING, "failed to create DRM screen"); - drmClose(fd); - return FALSE; - } - - kdpy->fd = fd; - - return TRUE; -} - -static struct native_display_modeset kms_display_modeset = { - .get_connectors = kms_display_get_connectors, - .get_modes = kms_display_get_modes, - .create_scanout_surface = kms_display_create_scanout_surface, - .program = kms_display_program -}; - -static struct native_display * -kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api) -{ - struct kms_display *kdpy; - - kdpy = CALLOC_STRUCT(kms_display); - if (!kdpy) - return NULL; - - kdpy->api = api; - if (!kdpy->api) { - _eglLog(_EGL_WARNING, "failed to create DRM API"); - free(kdpy); - return NULL; - } - - kdpy->fd = -1; - if (!kms_display_init_screen(&kdpy->base)) { - kms_display_destroy(&kdpy->base); - return NULL; - } - - /* resources are fixed, unlike crtc, connector, or encoder */ - kdpy->resources = drmModeGetResources(kdpy->fd); - if (!kdpy->resources) { - kms_display_destroy(&kdpy->base); - return NULL; - } - - kdpy->saved_crtcs = - calloc(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs)); - if (!kdpy->saved_crtcs) { - kms_display_destroy(&kdpy->base); - return NULL; - } - - kdpy->shown_surfaces = - calloc(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces)); - if (!kdpy->shown_surfaces) { - kms_display_destroy(&kdpy->base); - return NULL; - } - - kdpy->base.destroy = kms_display_destroy; - kdpy->base.get_configs = kms_display_get_configs; - kdpy->base.create_context = kms_display_create_context; - kdpy->base.create_pbuffer_surface = kms_display_create_pbuffer_surface; - - kdpy->base.modeset = &kms_display_modeset; - - return &kdpy->base; -} - -struct native_probe * -native_create_probe(EGLNativeDisplayType dpy) -{ - return NULL; -} - -enum native_probe_result -native_get_probe_result(struct native_probe *nprobe) -{ - return NATIVE_PROBE_UNKNOWN; -} - -/* the api is destroyed with the native display */ -static struct drm_api *drm_api; - -const char * -native_get_name(void) -{ - static char kms_name[32]; - - if (!drm_api) - drm_api = drm_api_create(); - - if (drm_api) - snprintf(kms_name, sizeof(kms_name), "KMS/%s", drm_api->name); - else - snprintf(kms_name, sizeof(kms_name), "KMS"); - - return kms_name; -} - -struct native_display * -native_create_display(EGLNativeDisplayType dpy) -{ - struct native_display *ndpy = NULL; - - if (!drm_api) - drm_api = drm_api_create(); - - if (drm_api) - ndpy = kms_create_display(dpy, drm_api); - - return ndpy; -} diff --git a/src/gallium/state_trackers/egl_g3d/kms/native_kms.h b/src/gallium/state_trackers/egl_g3d/kms/native_kms.h deleted file mode 100644 index 095186e3cf3..00000000000 --- a/src/gallium/state_trackers/egl_g3d/kms/native_kms.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef _NATIVE_KMS_H_ -#define _NATIVE_KMS_H_ - -#include -#include - -#include "pipe/p_compiler.h" -#include "util/u_format.h" -#include "pipe/p_state.h" -#include "state_tracker/drm_api.h" - -#include "common/native.h" - -enum kms_surface_type { - KMS_SURFACE_TYPE_PBUFFER, - KMS_SURFACE_TYPE_SCANOUT -}; - -struct kms_config; -struct kms_connector; -struct kms_mode; - -struct kms_crtc { - drmModeCrtcPtr crtc; - uint32_t connectors[32]; - int num_connectors; -}; - -struct kms_display { - struct native_display base; - - int fd; - struct drm_api *api; - drmModeResPtr resources; - struct kms_config *config; - - struct kms_connector *connectors; - int num_connectors; - - struct kms_surface **shown_surfaces; - /* save the original settings of the CRTCs */ - struct kms_crtc *saved_crtcs; -}; - -struct kms_framebuffer { - struct pipe_texture *texture; - boolean is_passive; - - uint32_t buffer_id; -}; - -struct kms_surface { - struct native_surface base; - enum kms_surface_type type; - enum pipe_format color_format; - struct kms_display *kdpy; - int width, height; - - struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; - unsigned int sequence_number; - struct kms_framebuffer front_fb, back_fb; - - boolean is_shown; - struct kms_crtc current_crtc; -}; - -struct kms_config { - struct native_config base; -}; - -struct kms_connector { - struct native_connector base; - - uint32_t connector_id; - drmModeConnectorPtr connector; - struct kms_mode *kms_modes; - int num_modes; -}; - -struct kms_mode { - struct native_mode base; - drmModeModeInfo mode; -}; - -static INLINE struct kms_display * -kms_display(const struct native_display *ndpy) -{ - return (struct kms_display *) ndpy; -} - -static INLINE struct kms_surface * -kms_surface(const struct native_surface *nsurf) -{ - return (struct kms_surface *) nsurf; -} - -static INLINE struct kms_config * -kms_config(const struct native_config *nconf) -{ - return (struct kms_config *) nconf; -} - -static INLINE struct kms_connector * -kms_connector(const struct native_connector *nconn) -{ - return (struct kms_connector *) nconn; -} - -static INLINE struct kms_mode * -kms_mode(const struct native_mode *nmode) -{ - return (struct kms_mode *) nmode; -} - -#endif /* _NATIVE_KMS_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c deleted file mode 100644 index 07f82d878c5..00000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c +++ /dev/null @@ -1,705 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "util/u_memory.h" -#include "util/u_math.h" -#include "util/u_format.h" -#include "pipe/p_compiler.h" -#include "pipe/p_screen.h" -#include "pipe/p_context.h" -#include "pipe/p_state.h" -#include "state_tracker/drm_api.h" -#include "egllog.h" - -#include "native_x11.h" -#include "x11_screen.h" - -enum dri2_surface_type { - DRI2_SURFACE_TYPE_WINDOW, - DRI2_SURFACE_TYPE_PIXMAP, - DRI2_SURFACE_TYPE_PBUFFER -}; - -struct dri2_display { - struct native_display base; - Display *dpy; - boolean own_dpy; - - struct drm_api *api; - struct x11_screen *xscr; - int xscr_number; - - struct dri2_config *configs; - int num_configs; -}; - -struct dri2_surface { - struct native_surface base; - Drawable drawable; - enum dri2_surface_type type; - enum pipe_format color_format; - struct dri2_display *dri2dpy; - - struct pipe_texture *pbuffer_textures[NUM_NATIVE_ATTACHMENTS]; - boolean have_back, have_fake; - int width, height; - unsigned int sequence_number; -}; - -struct dri2_config { - struct native_config base; -}; - -static INLINE struct dri2_display * -dri2_display(const struct native_display *ndpy) -{ - return (struct dri2_display *) ndpy; -} - -static INLINE struct dri2_surface * -dri2_surface(const struct native_surface *nsurf) -{ - return (struct dri2_surface *) nsurf; -} - -static INLINE struct dri2_config * -dri2_config(const struct native_config *nconf) -{ - return (struct dri2_config *) nconf; -} - -static boolean -dri2_surface_flush_frontbuffer(struct native_surface *nsurf) -{ - struct dri2_surface *dri2surf = dri2_surface(nsurf); - struct dri2_display *dri2dpy = dri2surf->dri2dpy; - - /* pbuffer is private */ - if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) - return TRUE; - - /* copy to real front buffer */ - if (dri2surf->have_fake) - x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, - 0, 0, dri2surf->width, dri2surf->height, - DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft); - - return TRUE; -} - -static boolean -dri2_surface_swap_buffers(struct native_surface *nsurf) -{ - struct dri2_surface *dri2surf = dri2_surface(nsurf); - struct dri2_display *dri2dpy = dri2surf->dri2dpy; - - /* pbuffer is private */ - if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) - return TRUE; - - /* copy to front buffer */ - if (dri2surf->have_back) - x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, - 0, 0, dri2surf->width, dri2surf->height, - DRI2BufferBackLeft, DRI2BufferFrontLeft); - - /* and update fake front buffer */ - if (dri2surf->have_fake) - x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, - 0, 0, dri2surf->width, dri2surf->height, - DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); - - return TRUE; -} - -static boolean -dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask, - unsigned int *seq_num, struct pipe_texture **textures, - int *width, int *height) -{ - struct dri2_surface *dri2surf = dri2_surface(nsurf); - struct dri2_display *dri2dpy = dri2surf->dri2dpy; - unsigned int dri2atts[NUM_NATIVE_ATTACHMENTS]; - struct pipe_texture templ; - struct x11_drawable_buffer *xbufs; - int num_ins, num_outs, att, i; - - if (attachment_mask) { - memset(&templ, 0, sizeof(templ)); - templ.target = PIPE_TEXTURE_2D; - templ.last_level = 0; - templ.width0 = dri2surf->width; - templ.height0 = dri2surf->height; - templ.depth0 = 1; - templ.format = dri2surf->color_format; - templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; - - if (textures) - memset(textures, 0, sizeof(*textures) * NUM_NATIVE_ATTACHMENTS); - } - - /* create textures for pbuffer */ - if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) { - struct pipe_screen *screen = dri2dpy->base.screen; - - for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { - struct pipe_texture *ptex = dri2surf->pbuffer_textures[att]; - - /* delay the allocation */ - if (!native_attachment_mask_test(attachment_mask, att)) - continue; - - if (!ptex) { - ptex = screen->texture_create(screen, &templ); - dri2surf->pbuffer_textures[att] = ptex; - } - - if (textures) - pipe_texture_reference(&textures[att], ptex); - } - - if (seq_num) - *seq_num = dri2surf->sequence_number; - if (width) - *width = dri2surf->width; - if (height) - *height = dri2surf->height; - - return TRUE; - } - - /* prepare the attachments */ - num_ins = 0; - for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { - if (native_attachment_mask_test(attachment_mask, att)) { - unsigned int dri2att; - - switch (att) { - case NATIVE_ATTACHMENT_FRONT_LEFT: - dri2att = DRI2BufferFrontLeft; - break; - case NATIVE_ATTACHMENT_BACK_LEFT: - dri2att = DRI2BufferBackLeft; - break; - case NATIVE_ATTACHMENT_FRONT_RIGHT: - dri2att = DRI2BufferFrontRight; - break; - case NATIVE_ATTACHMENT_BACK_RIGHT: - dri2att = DRI2BufferBackRight; - break; - default: - assert(0); - dri2att = 0; - break; - } - - dri2atts[num_ins] = dri2att; - num_ins++; - } - } - - dri2surf->have_back = FALSE; - dri2surf->have_fake = FALSE; - - /* remember old geometry */ - templ.width0 = dri2surf->width; - templ.height0 = dri2surf->height; - - xbufs = x11_drawable_get_buffers(dri2dpy->xscr, dri2surf->drawable, - &dri2surf->width, &dri2surf->height, - dri2atts, FALSE, num_ins, &num_outs); - if (!xbufs) - return FALSE; - - if (templ.width0 != dri2surf->width || templ.height0 != dri2surf->height) { - /* are there cases where the buffers change and the geometry doesn't? */ - dri2surf->sequence_number++; - - templ.width0 = dri2surf->width; - templ.height0 = dri2surf->height; - } - - for (i = 0; i < num_outs; i++) { - struct x11_drawable_buffer *xbuf = &xbufs[i]; - const char *desc; - enum native_attachment natt; - - switch (xbuf->attachment) { - case DRI2BufferFrontLeft: - natt = NATIVE_ATTACHMENT_FRONT_LEFT; - desc = "DRI2 Front Buffer"; - break; - case DRI2BufferFakeFrontLeft: - natt = NATIVE_ATTACHMENT_FRONT_LEFT; - desc = "DRI2 Fake Front Buffer"; - dri2surf->have_fake = TRUE; - break; - case DRI2BufferBackLeft: - natt = NATIVE_ATTACHMENT_BACK_LEFT; - desc = "DRI2 Back Buffer"; - dri2surf->have_back = TRUE; - break; - default: - desc = NULL; - break; - } - - if (!desc || !native_attachment_mask_test(attachment_mask, natt) || - (textures && textures[natt])) { - if (!desc) - _eglLog(_EGL_WARNING, "unknown buffer %d", xbuf->attachment); - else if (!native_attachment_mask_test(attachment_mask, natt)) - _eglLog(_EGL_WARNING, "unexpected buffer %d", xbuf->attachment); - else - _eglLog(_EGL_WARNING, "both real and fake front buffers are listed"); - continue; - } - - if (textures) { - struct pipe_texture *ptex = - dri2dpy->api->texture_from_shared_handle(dri2dpy->api, - dri2dpy->base.screen, &templ, - desc, xbuf->pitch, xbuf->name); - if (ptex) { - /* the caller owns the textures */ - textures[natt] = ptex; - } - } - } - - free(xbufs); - - if (seq_num) - *seq_num = dri2surf->sequence_number; - if (width) - *width = dri2surf->width; - if (height) - *height = dri2surf->height; - - return TRUE; -} - -static void -dri2_surface_wait(struct native_surface *nsurf) -{ - struct dri2_surface *dri2surf = dri2_surface(nsurf); - struct dri2_display *dri2dpy = dri2surf->dri2dpy; - - if (dri2surf->have_fake) { - x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, - 0, 0, dri2surf->width, dri2surf->height, - DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); - } -} - -static void -dri2_surface_destroy(struct native_surface *nsurf) -{ - struct dri2_surface *dri2surf = dri2_surface(nsurf); - int i; - - for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { - struct pipe_texture *ptex = dri2surf->pbuffer_textures[i]; - pipe_texture_reference(&ptex, NULL); - } - - if (dri2surf->drawable) - x11_drawable_enable_dri2(dri2surf->dri2dpy->xscr, - dri2surf->drawable, FALSE); - free(dri2surf); -} - -static struct dri2_surface * -dri2_display_create_surface(struct native_display *ndpy, - enum dri2_surface_type type, - Drawable drawable, - const struct native_config *nconf) -{ - struct dri2_display *dri2dpy = dri2_display(ndpy); - struct dri2_config *dri2conf = dri2_config(nconf); - struct dri2_surface *dri2surf; - - dri2surf = CALLOC_STRUCT(dri2_surface); - if (!dri2surf) - return NULL; - - if (drawable) - x11_drawable_enable_dri2(dri2dpy->xscr, drawable, TRUE); - - dri2surf->dri2dpy = dri2dpy; - dri2surf->type = type; - dri2surf->drawable = drawable; - dri2surf->color_format = dri2conf->base.color_format; - - dri2surf->base.destroy = dri2_surface_destroy; - dri2surf->base.swap_buffers = dri2_surface_swap_buffers; - dri2surf->base.flush_frontbuffer = dri2_surface_flush_frontbuffer; - dri2surf->base.validate = dri2_surface_validate; - dri2surf->base.wait = dri2_surface_wait; - - return dri2surf; -} - -static struct native_surface * -dri2_display_create_window_surface(struct native_display *ndpy, - EGLNativeWindowType win, - const struct native_config *nconf) -{ - struct dri2_surface *dri2surf; - - dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_WINDOW, - (Drawable) win, nconf); - return (dri2surf) ? &dri2surf->base : NULL; -} - -static struct native_surface * -dri2_display_create_pixmap_surface(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf) -{ - struct dri2_surface *dri2surf; - - dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_PIXMAP, - (Drawable) pix, nconf); - return (dri2surf) ? &dri2surf->base : NULL; -} - -static struct native_surface * -dri2_display_create_pbuffer_surface(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height) -{ - struct dri2_surface *dri2surf; - - dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_PBUFFER, - (Drawable) None, nconf); - if (dri2surf) { - dri2surf->width = width; - dri2surf->height = height; - } - return (dri2surf) ? &dri2surf->base : NULL; -} - -static struct pipe_context * -dri2_display_create_context(struct native_display *ndpy, void *context_private) -{ - struct dri2_display *dri2dpy = dri2_display(ndpy); - struct pipe_context *pctx; - - pctx = dri2dpy->api->create_context(dri2dpy->api, dri2dpy->base.screen); - if (pctx) - pctx->priv = context_private; - return pctx; -} - -static int -choose_color_format(const __GLcontextModes *mode, enum pipe_format formats[32]) -{ - int count = 0; - - switch (mode->rgbBits) { - case 32: - formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; - formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; - break; - case 24: - formats[count++] = PIPE_FORMAT_X8R8G8B8_UNORM; - formats[count++] = PIPE_FORMAT_B8G8R8X8_UNORM; - formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; - formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; - break; - case 16: - formats[count++] = PIPE_FORMAT_R5G6B5_UNORM; - break; - default: - break; - } - - return count; -} - -static int -choose_depth_stencil_format(const __GLcontextModes *mode, - enum pipe_format formats[32]) -{ - int count = 0; - - switch (mode->depthBits) { - case 32: - formats[count++] = PIPE_FORMAT_Z32_UNORM; - break; - case 24: - if (mode->stencilBits) { - formats[count++] = PIPE_FORMAT_S8Z24_UNORM; - formats[count++] = PIPE_FORMAT_Z24S8_UNORM; - } - else { - formats[count++] = PIPE_FORMAT_X8Z24_UNORM; - formats[count++] = PIPE_FORMAT_Z24X8_UNORM; - } - break; - case 16: - formats[count++] = PIPE_FORMAT_Z16_UNORM; - break; - default: - break; - } - - return count; -} - -static boolean -is_format_supported(struct pipe_screen *screen, - enum pipe_format fmt, boolean is_color) -{ - return screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D, - (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET : - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); -} - -static boolean -dri2_display_convert_config(struct native_display *ndpy, - const __GLcontextModes *mode, - struct native_config *nconf) -{ - enum pipe_format formats[32]; - int num_formats, i; - - if (!(mode->renderType & GLX_RGBA_BIT) || !mode->rgbMode) - return FALSE; - - /* skip single-buffered configs */ - if (!mode->doubleBufferMode) - return FALSE; - - nconf->mode = *mode; - nconf->mode.renderType = GLX_RGBA_BIT; - nconf->mode.rgbMode = TRUE; - /* pbuffer is allocated locally and is always supported */ - nconf->mode.drawableType |= GLX_PBUFFER_BIT; - /* the swap method is always copy */ - nconf->mode.swapMethod = GLX_SWAP_COPY_OML; - - /* fix up */ - nconf->mode.rgbBits = - nconf->mode.redBits + nconf->mode.greenBits + - nconf->mode.blueBits + nconf->mode.alphaBits; - if (!(nconf->mode.drawableType & GLX_WINDOW_BIT)) { - nconf->mode.visualID = 0; - nconf->mode.visualType = GLX_NONE; - } - if (!(nconf->mode.drawableType & GLX_PBUFFER_BIT)) { - nconf->mode.bindToTextureRgb = FALSE; - nconf->mode.bindToTextureRgba = FALSE; - } - - nconf->color_format = PIPE_FORMAT_NONE; - nconf->depth_format = PIPE_FORMAT_NONE; - nconf->stencil_format = PIPE_FORMAT_NONE; - - /* choose color format */ - num_formats = choose_color_format(mode, formats); - for (i = 0; i < num_formats; i++) { - if (is_format_supported(ndpy->screen, formats[i], TRUE)) { - nconf->color_format = formats[i]; - break; - } - } - if (nconf->color_format == PIPE_FORMAT_NONE) - return FALSE; - - /* choose depth/stencil format */ - num_formats = choose_depth_stencil_format(mode, formats); - for (i = 0; i < num_formats; i++) { - if (is_format_supported(ndpy->screen, formats[i], FALSE)) { - nconf->depth_format = formats[i]; - nconf->stencil_format = formats[i]; - break; - } - } - if ((nconf->mode.depthBits && nconf->depth_format == PIPE_FORMAT_NONE) || - (nconf->mode.stencilBits && nconf->stencil_format == PIPE_FORMAT_NONE)) - return FALSE; - - return TRUE; -} - -static const struct native_config ** -dri2_display_get_configs(struct native_display *ndpy, int *num_configs) -{ - struct dri2_display *dri2dpy = dri2_display(ndpy); - const struct native_config **configs; - int i; - - /* first time */ - if (!dri2dpy->configs) { - const __GLcontextModes *modes; - int num_modes, count; - - modes = x11_screen_get_glx_configs(dri2dpy->xscr); - if (!modes) - return NULL; - num_modes = x11_context_modes_count(modes); - - dri2dpy->configs = calloc(num_modes, sizeof(*dri2dpy->configs)); - if (!dri2dpy->configs) - return NULL; - - count = 0; - for (i = 0; i < num_modes; i++) { - struct native_config *nconf = &dri2dpy->configs[count].base; - if (dri2_display_convert_config(&dri2dpy->base, modes, nconf)) - count++; - modes = modes->next; - } - - dri2dpy->num_configs = count; - } - - configs = malloc(dri2dpy->num_configs * sizeof(*configs)); - if (configs) { - for (i = 0; i < dri2dpy->num_configs; i++) - configs[i] = (const struct native_config *) &dri2dpy->configs[i]; - if (num_configs) - *num_configs = dri2dpy->num_configs; - } - - return configs; -} - -static boolean -dri2_display_is_pixmap_supported(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf) -{ - struct dri2_display *dri2dpy = dri2_display(ndpy); - uint depth, nconf_depth; - - depth = x11_drawable_get_depth(dri2dpy->xscr, (Drawable) pix); - nconf_depth = util_format_get_blocksizebits(nconf->color_format); - - /* simple depth match for now */ - return (depth == nconf_depth || (depth == 24 && depth + 8 == nconf_depth)); -} - -static void -dri2_display_destroy(struct native_display *ndpy) -{ - struct dri2_display *dri2dpy = dri2_display(ndpy); - - if (dri2dpy->configs) - free(dri2dpy->configs); - - if (dri2dpy->base.screen) - dri2dpy->base.screen->destroy(dri2dpy->base.screen); - - if (dri2dpy->xscr) - x11_screen_destroy(dri2dpy->xscr); - if (dri2dpy->own_dpy) - XCloseDisplay(dri2dpy->dpy); - if (dri2dpy->api && dri2dpy->api->destroy) - dri2dpy->api->destroy(dri2dpy->api); - free(dri2dpy); -} - -/** - * Initialize DRI2 and pipe screen. - */ -static boolean -dri2_display_init_screen(struct native_display *ndpy) -{ - struct dri2_display *dri2dpy = dri2_display(ndpy); - const char *driver = dri2dpy->api->name; - struct drm_create_screen_arg arg; - int fd; - - if (!x11_screen_support(dri2dpy->xscr, X11_SCREEN_EXTENSION_DRI2) || - !x11_screen_support(dri2dpy->xscr, X11_SCREEN_EXTENSION_GLX)) { - _eglLog(_EGL_WARNING, "GLX/DRI2 is not supported"); - return FALSE; - } - - fd = x11_screen_enable_dri2(dri2dpy->xscr, driver); - if (fd < 0) - return FALSE; - - memset(&arg, 0, sizeof(arg)); - arg.mode = DRM_CREATE_NORMAL; - dri2dpy->base.screen = dri2dpy->api->create_screen(dri2dpy->api, fd, &arg); - if (!dri2dpy->base.screen) { - _eglLog(_EGL_WARNING, "failed to create DRM screen"); - return FALSE; - } - - return TRUE; -} - -struct native_display * -x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api) -{ - struct dri2_display *dri2dpy; - - dri2dpy = CALLOC_STRUCT(dri2_display); - if (!dri2dpy) - return NULL; - - dri2dpy->api = api; - if (!dri2dpy->api) { - _eglLog(_EGL_WARNING, "failed to create DRM API"); - free(dri2dpy); - return NULL; - } - - dri2dpy->dpy = dpy; - if (!dri2dpy->dpy) { - dri2dpy->dpy = XOpenDisplay(NULL); - if (!dri2dpy->dpy) { - dri2_display_destroy(&dri2dpy->base); - return NULL; - } - dri2dpy->own_dpy = TRUE; - } - - dri2dpy->xscr_number = DefaultScreen(dri2dpy->dpy); - dri2dpy->xscr = x11_screen_create(dri2dpy->dpy, dri2dpy->xscr_number); - if (!dri2dpy->xscr) { - dri2_display_destroy(&dri2dpy->base); - return NULL; - } - - if (!dri2_display_init_screen(&dri2dpy->base)) { - dri2_display_destroy(&dri2dpy->base); - return NULL; - } - - dri2dpy->base.destroy = dri2_display_destroy; - dri2dpy->base.get_configs = dri2_display_get_configs; - dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported; - dri2dpy->base.create_context = dri2_display_create_context; - dri2dpy->base.create_window_surface = dri2_display_create_window_surface; - dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface; - dri2dpy->base.create_pbuffer_surface = dri2_display_create_pbuffer_surface; - - return &dri2dpy->base; -} diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_x11.c b/src/gallium/state_trackers/egl_g3d/x11/native_x11.c deleted file mode 100644 index 695ab88010b..00000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/native_x11.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include "util/u_debug.h" -#include "util/u_memory.h" -#include "state_tracker/drm_api.h" -#include "egllog.h" - -#include "native_x11.h" -#include "x11_screen.h" - -#define X11_PROBE_MAGIC 0x11980BE /* "X11PROBE" */ - -static struct drm_api *api; - -static void -x11_probe_destroy(struct native_probe *nprobe) -{ - if (nprobe->data) - free(nprobe->data); - free(nprobe); -} - -struct native_probe * -native_create_probe(EGLNativeDisplayType dpy) -{ - struct native_probe *nprobe; - struct x11_screen *xscr; - int scr; - const char *driver_name = NULL; - Display *xdpy; - - nprobe = CALLOC_STRUCT(native_probe); - if (!nprobe) - return NULL; - - xdpy = dpy; - if (!xdpy) { - xdpy = XOpenDisplay(NULL); - if (!xdpy) { - free(nprobe); - return NULL; - } - } - - scr = DefaultScreen(xdpy); - xscr = x11_screen_create(xdpy, scr); - if (xscr) { - if (x11_screen_support(xscr, X11_SCREEN_EXTENSION_DRI2)) { - driver_name = x11_screen_probe_dri2(xscr); - nprobe->data = strdup(driver_name); - } - - x11_screen_destroy(xscr); - } - - if (xdpy != dpy) - XCloseDisplay(xdpy); - - nprobe->magic = X11_PROBE_MAGIC; - nprobe->display = dpy; - - nprobe->destroy = x11_probe_destroy; - - return nprobe; -} - -enum native_probe_result -native_get_probe_result(struct native_probe *nprobe) -{ - if (!nprobe || nprobe->magic != X11_PROBE_MAGIC) - return NATIVE_PROBE_UNKNOWN; - - if (!api) - api = drm_api_create(); - - /* this is a software driver */ - if (!api) - return NATIVE_PROBE_SUPPORTED; - - /* the display does not support DRI2 or the driver mismatches */ - if (!nprobe->data || strcmp(api->name, (const char *) nprobe->data) != 0) - return NATIVE_PROBE_FALLBACK; - - return NATIVE_PROBE_EXACT; -} - -const char * -native_get_name(void) -{ - static char x11_name[32]; - - if (!api) - api = drm_api_create(); - - if (api) - snprintf(x11_name, sizeof(x11_name), "X11/%s", api->name); - else - snprintf(x11_name, sizeof(x11_name), "X11"); - - return x11_name; -} - -struct native_display * -native_create_display(EGLNativeDisplayType dpy) -{ - struct native_display *ndpy = NULL; - boolean force_sw; - - if (!api) - api = drm_api_create(); - - force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE); - if (api && !force_sw) { - ndpy = x11_create_dri2_display(dpy, api); - } - - if (!ndpy) { - EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING; - - _eglLog(level, "use software fallback"); - ndpy = x11_create_ximage_display(dpy, TRUE); - } - - return ndpy; -} diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_x11.h b/src/gallium/state_trackers/egl_g3d/x11/native_x11.h deleted file mode 100644 index 622ddac5df6..00000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/native_x11.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef _NATIVE_X11_H_ -#define _NATIVE_X11_H_ - -#include "state_tracker/drm_api.h" -#include "common/native.h" - -struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm); - -struct native_display * -x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api); - -#endif /* _NATIVE_X11_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c deleted file mode 100644 index dfa8df22234..00000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c +++ /dev/null @@ -1,694 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "util/u_memory.h" -#include "util/u_math.h" -#include "util/u_format.h" -#include "pipe/p_compiler.h" -#include "pipe/internal/p_winsys_screen.h" -#include "softpipe/sp_winsys.h" -#include "egllog.h" - -#include "sw_winsys.h" -#include "native_x11.h" -#include "x11_screen.h" - -enum ximage_surface_type { - XIMAGE_SURFACE_TYPE_WINDOW, - XIMAGE_SURFACE_TYPE_PIXMAP, - XIMAGE_SURFACE_TYPE_PBUFFER -}; - -struct ximage_display { - struct native_display base; - Display *dpy; - boolean own_dpy; - - struct x11_screen *xscr; - int xscr_number; - - boolean use_xshm; - - struct pipe_winsys *winsys; - struct ximage_config *configs; - int num_configs; -}; - -struct ximage_buffer { - XImage *ximage; - - struct pipe_texture *texture; - XShmSegmentInfo *shm_info; - boolean xshm_attached; -}; - -struct ximage_surface { - struct native_surface base; - Drawable drawable; - enum ximage_surface_type type; - enum pipe_format color_format; - XVisualInfo visual; - struct ximage_display *xdpy; - - int width, height; - GC gc; - - struct ximage_buffer buffers[NUM_NATIVE_ATTACHMENTS]; - unsigned int sequence_number; -}; - -struct ximage_config { - struct native_config base; - const XVisualInfo *visual; -}; - -static INLINE struct ximage_display * -ximage_display(const struct native_display *ndpy) -{ - return (struct ximage_display *) ndpy; -} - -static INLINE struct ximage_surface * -ximage_surface(const struct native_surface *nsurf) -{ - return (struct ximage_surface *) nsurf; -} - -static INLINE struct ximage_config * -ximage_config(const struct native_config *nconf) -{ - return (struct ximage_config *) nconf; -} - -static void -ximage_surface_free_buffer(struct native_surface *nsurf, - enum native_attachment which) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - struct ximage_buffer *xbuf = &xsurf->buffers[which]; - - pipe_texture_reference(&xbuf->texture, NULL); - - if (xbuf->shm_info) { - if (xbuf->xshm_attached) - XShmDetach(xsurf->xdpy->dpy, xbuf->shm_info); - if (xbuf->shm_info->shmaddr != (void *) -1) - shmdt(xbuf->shm_info->shmaddr); - if (xbuf->shm_info->shmid != -1) - shmctl(xbuf->shm_info->shmid, IPC_RMID, 0); - - xbuf->shm_info->shmaddr = (void *) -1; - xbuf->shm_info->shmid = -1; - } -} - -static boolean -ximage_surface_alloc_buffer(struct native_surface *nsurf, - enum native_attachment which) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - struct ximage_buffer *xbuf = &xsurf->buffers[which]; - struct pipe_screen *screen = xsurf->xdpy->base.screen; - struct pipe_texture templ; - - /* free old data */ - if (xbuf->texture) - ximage_surface_free_buffer(&xsurf->base, which); - - memset(&templ, 0, sizeof(templ)); - templ.target = PIPE_TEXTURE_2D; - templ.format = xsurf->color_format; - templ.width0 = xsurf->width; - templ.height0 = xsurf->height; - templ.depth0 = 1; - templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; - - if (xbuf->shm_info) { - struct pipe_buffer *pbuf; - unsigned stride, size; - void *addr = NULL; - - stride = util_format_get_stride(xsurf->color_format, xsurf->width); - /* alignment should depend on visual? */ - stride = align(stride, 4); - size = stride * xsurf->height; - - /* create and attach shm object */ - xbuf->shm_info->shmid = shmget(IPC_PRIVATE, size, 0755); - if (xbuf->shm_info->shmid != -1) { - xbuf->shm_info->shmaddr = - shmat(xbuf->shm_info->shmid, NULL, 0); - if (xbuf->shm_info->shmaddr != (void *) -1) { - if (XShmAttach(xsurf->xdpy->dpy, xbuf->shm_info)) { - addr = xbuf->shm_info->shmaddr; - xbuf->xshm_attached = TRUE; - } - } - } - - if (addr) { - pbuf = screen->user_buffer_create(screen, addr, size); - if (pbuf) { - xbuf->texture = - screen->texture_blanket(screen, &templ, &stride, pbuf); - pipe_buffer_reference(&pbuf, NULL); - } - } - } - else { - xbuf->texture = screen->texture_create(screen, &templ); - } - - /* clean up the buffer if allocation failed */ - if (!xbuf->texture) - ximage_surface_free_buffer(&xsurf->base, which); - - return (xbuf->texture != NULL); -} - -static boolean -ximage_surface_draw_buffer(struct native_surface *nsurf, - enum native_attachment which) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - struct ximage_buffer *xbuf = &xsurf->buffers[which]; - struct pipe_screen *screen = xsurf->xdpy->base.screen; - struct pipe_transfer *transfer; - - if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER) - return TRUE; - - assert(xsurf->drawable && xbuf->ximage && xbuf->texture); - - transfer = screen->get_tex_transfer(screen, xbuf->texture, - 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, xsurf->width, xsurf->height); - if (!transfer) - return FALSE; - - xbuf->ximage->bytes_per_line = transfer->stride; - xbuf->ximage->data = screen->transfer_map(screen, transfer); - if (!xbuf->ximage->data) { - screen->tex_transfer_destroy(transfer); - return FALSE; - } - - - if (xbuf->shm_info) - XShmPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, - xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height, False); - else - XPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, - xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height); - - xbuf->ximage->data = NULL; - screen->transfer_unmap(screen, transfer); - - /* - * softpipe allows the pipe transfer to be re-used, but we don't want to - * rely on that behavior. - */ - screen->tex_transfer_destroy(transfer); - - XSync(xsurf->xdpy->dpy, FALSE); - - return TRUE; -} - -static boolean -ximage_surface_flush_frontbuffer(struct native_surface *nsurf) -{ - return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); -} - -static boolean -ximage_surface_swap_buffers(struct native_surface *nsurf) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - struct ximage_buffer *xfront, *xback, xtmp; - - xfront = &xsurf->buffers[NATIVE_ATTACHMENT_FRONT_LEFT]; - xback = &xsurf->buffers[NATIVE_ATTACHMENT_BACK_LEFT]; - - /* draw the back buffer directly if there is no front buffer */ - if (!xfront->texture) - return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_BACK_LEFT); - - /* swap the buffers */ - xtmp = *xfront; - *xfront = *xback; - *xback = xtmp; - - /* the front/back textures are swapped */ - xsurf->sequence_number++; - - return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); -} - -static void -ximage_surface_update_geometry(struct native_surface *nsurf) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - Status ok; - Window root; - int x, y; - unsigned int w, h, border, depth; - - /* pbuffer has fixed geometry */ - if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER) - return; - - ok = XGetGeometry(xsurf->xdpy->dpy, xsurf->drawable, - &root, &x, &y, &w, &h, &border, &depth); - if (ok) { - xsurf->width = w; - xsurf->height = h; - } -} - -static boolean -ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask, - unsigned int *seq_num, struct pipe_texture **textures, - int *width, int *height) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - boolean new_buffers = FALSE; - int att; - - ximage_surface_update_geometry(&xsurf->base); - - for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { - struct ximage_buffer *xbuf = &xsurf->buffers[att]; - - /* delay the allocation */ - if (!native_attachment_mask_test(attachment_mask, att)) - continue; - - /* reallocate the texture */ - if (!xbuf->texture || - xsurf->width != xbuf->texture->width0 || - xsurf->height != xbuf->texture->height0) { - new_buffers = TRUE; - if (ximage_surface_alloc_buffer(&xsurf->base, att)) { - /* update ximage */ - if (xbuf->ximage) { - xbuf->ximage->width = xsurf->width; - xbuf->ximage->height = xsurf->height; - } - } - } - - if (textures) { - textures[att] = NULL; - pipe_texture_reference(&textures[att], xbuf->texture); - } - } - - /* increase the sequence number so that caller knows */ - if (new_buffers) - xsurf->sequence_number++; - - if (seq_num) - *seq_num = xsurf->sequence_number; - if (width) - *width = xsurf->width; - if (height) - *height = xsurf->height; - - return TRUE; -} - -static void -ximage_surface_wait(struct native_surface *nsurf) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - XSync(xsurf->xdpy->dpy, FALSE); - /* TODO XGetImage and update the front texture */ -} - -static void -ximage_surface_destroy(struct native_surface *nsurf) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - int i; - - for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { - struct ximage_buffer *xbuf = &xsurf->buffers[i]; - ximage_surface_free_buffer(&xsurf->base, i); - /* xbuf->shm_info is owned by xbuf->ximage? */ - if (xbuf->ximage) { - XDestroyImage(xbuf->ximage); - xbuf->ximage = NULL; - } - } - - if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) - XFreeGC(xsurf->xdpy->dpy, xsurf->gc); - free(xsurf); -} - -static struct ximage_surface * -ximage_display_create_surface(struct native_display *ndpy, - enum ximage_surface_type type, - Drawable drawable, - const struct native_config *nconf) -{ - struct ximage_display *xdpy = ximage_display(ndpy); - struct ximage_config *xconf = ximage_config(nconf); - struct ximage_surface *xsurf; - int i; - - xsurf = CALLOC_STRUCT(ximage_surface); - if (!xsurf) - return NULL; - - xsurf->xdpy = xdpy; - xsurf->type = type; - xsurf->color_format = xconf->base.color_format; - xsurf->drawable = drawable; - - if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) { - xsurf->drawable = drawable; - xsurf->visual = *xconf->visual; - - xsurf->gc = XCreateGC(xdpy->dpy, xsurf->drawable, 0, NULL); - if (!xsurf->gc) { - free(xsurf); - return NULL; - } - - for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { - struct ximage_buffer *xbuf = &xsurf->buffers[i]; - - if (xdpy->use_xshm) { - xbuf->shm_info = calloc(1, sizeof(*xbuf->shm_info)); - if (xbuf->shm_info) { - /* initialize shm info */ - xbuf->shm_info->shmid = -1; - xbuf->shm_info->shmaddr = (void *) -1; - xbuf->shm_info->readOnly = TRUE; - - xbuf->ximage = XShmCreateImage(xsurf->xdpy->dpy, - xsurf->visual.visual, - xsurf->visual.depth, - ZPixmap, NULL, - xbuf->shm_info, - 0, 0); - } - } - else { - xbuf->ximage = XCreateImage(xsurf->xdpy->dpy, - xsurf->visual.visual, - xsurf->visual.depth, - ZPixmap, 0, /* format, offset */ - NULL, /* data */ - 0, 0, /* size */ - 8, /* bitmap_pad */ - 0); /* bytes_per_line */ - } - - if (!xbuf->ximage) { - XFreeGC(xdpy->dpy, xsurf->gc); - free(xsurf); - return NULL; - } - } - } - - xsurf->base.destroy = ximage_surface_destroy; - xsurf->base.swap_buffers = ximage_surface_swap_buffers; - xsurf->base.flush_frontbuffer = ximage_surface_flush_frontbuffer; - xsurf->base.validate = ximage_surface_validate; - xsurf->base.wait = ximage_surface_wait; - - return xsurf; -} - -static struct native_surface * -ximage_display_create_window_surface(struct native_display *ndpy, - EGLNativeWindowType win, - const struct native_config *nconf) -{ - struct ximage_surface *xsurf; - - xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_WINDOW, - (Drawable) win, nconf); - return (xsurf) ? &xsurf->base : NULL; -} - -static struct native_surface * -ximage_display_create_pixmap_surface(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf) -{ - struct ximage_surface *xsurf; - - xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_PIXMAP, - (Drawable) pix, nconf); - return (xsurf) ? &xsurf->base : NULL; -} - -static struct native_surface * -ximage_display_create_pbuffer_surface(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height) -{ - struct ximage_surface *xsurf; - - xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_PBUFFER, - (Drawable) None, nconf); - if (xsurf) { - xsurf->width = width; - xsurf->height = height; - } - return (xsurf) ? &xsurf->base : NULL; -} - -static struct pipe_context * -ximage_display_create_context(struct native_display *ndpy, - void *context_private) -{ - struct pipe_context *pctx = softpipe_create(ndpy->screen); - if (pctx) - pctx->priv = context_private; - return pctx; -} - -static enum pipe_format -choose_format(const XVisualInfo *vinfo) -{ - enum pipe_format fmt; - /* TODO elaborate the formats */ - switch (vinfo->depth) { - case 32: - fmt = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case 24: - fmt = PIPE_FORMAT_X8R8G8B8_UNORM; - break; - case 16: - fmt = PIPE_FORMAT_R5G6B5_UNORM; - break; - default: - fmt = PIPE_FORMAT_NONE; - break; - } - - return fmt; -} - -static const struct native_config ** -ximage_display_get_configs(struct native_display *ndpy, int *num_configs) -{ - struct ximage_display *xdpy = ximage_display(ndpy); - const struct native_config **configs; - int i; - - /* first time */ - if (!xdpy->configs) { - const XVisualInfo *visuals; - int num_visuals, count, j; - - visuals = x11_screen_get_visuals(xdpy->xscr, &num_visuals); - if (!visuals) - return NULL; - - /* - * Create two configs for each visual. - * One with depth/stencil buffer; one without - */ - xdpy->configs = calloc(num_visuals * 2, sizeof(*xdpy->configs)); - if (!xdpy->configs) - return NULL; - - count = 0; - for (i = 0; i < num_visuals; i++) { - for (j = 0; j < 2; j++) { - struct ximage_config *xconf = &xdpy->configs[count]; - __GLcontextModes *mode = &xconf->base.mode; - - xconf->visual = &visuals[i]; - xconf->base.color_format = choose_format(xconf->visual); - if (xconf->base.color_format == PIPE_FORMAT_NONE) - continue; - - x11_screen_convert_visual(xdpy->xscr, xconf->visual, mode); - /* support double buffer mode */ - mode->doubleBufferMode = TRUE; - - xconf->base.depth_format = PIPE_FORMAT_NONE; - xconf->base.stencil_format = PIPE_FORMAT_NONE; - /* create the second config with depth/stencil buffer */ - if (j == 1) { - xconf->base.depth_format = PIPE_FORMAT_S8Z24_UNORM; - xconf->base.stencil_format = PIPE_FORMAT_S8Z24_UNORM; - mode->depthBits = 24; - mode->stencilBits = 8; - mode->haveDepthBuffer = TRUE; - mode->haveStencilBuffer = TRUE; - } - - mode->maxPbufferWidth = 4096; - mode->maxPbufferHeight = 4096; - mode->maxPbufferPixels = 4096 * 4096; - mode->drawableType = - GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT; - mode->swapMethod = GLX_SWAP_EXCHANGE_OML; - - if (mode->alphaBits) - mode->bindToTextureRgba = TRUE; - else - mode->bindToTextureRgb = TRUE; - - count++; - } - } - - xdpy->num_configs = count; - } - - configs = malloc(xdpy->num_configs * sizeof(*configs)); - if (configs) { - for (i = 0; i < xdpy->num_configs; i++) - configs[i] = (const struct native_config *) &xdpy->configs[i]; - if (num_configs) - *num_configs = xdpy->num_configs; - } - return configs; -} - -static boolean -ximage_display_is_pixmap_supported(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf) -{ - struct ximage_display *xdpy = ximage_display(ndpy); - enum pipe_format fmt; - uint depth; - - depth = x11_drawable_get_depth(xdpy->xscr, (Drawable) pix); - switch (depth) { - case 32: - fmt = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case 24: - fmt = PIPE_FORMAT_X8R8G8B8_UNORM; - break; - case 16: - fmt = PIPE_FORMAT_R5G6B5_UNORM; - break; - default: - fmt = PIPE_FORMAT_NONE; - break; - } - - return (fmt == nconf->color_format); -} - -static void -ximage_display_destroy(struct native_display *ndpy) -{ - struct ximage_display *xdpy = ximage_display(ndpy); - - if (xdpy->configs) - free(xdpy->configs); - - xdpy->base.screen->destroy(xdpy->base.screen); - free(xdpy->winsys); - - x11_screen_destroy(xdpy->xscr); - if (xdpy->own_dpy) - XCloseDisplay(xdpy->dpy); - free(xdpy); -} - -struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm) -{ - struct ximage_display *xdpy; - - xdpy = CALLOC_STRUCT(ximage_display); - if (!xdpy) - return NULL; - - xdpy->dpy = dpy; - if (!xdpy->dpy) { - xdpy->dpy = XOpenDisplay(NULL); - if (!xdpy->dpy) { - free(xdpy); - return NULL; - } - xdpy->own_dpy = TRUE; - } - - xdpy->xscr_number = DefaultScreen(xdpy->dpy); - xdpy->xscr = x11_screen_create(xdpy->dpy, xdpy->xscr_number); - if (!xdpy->xscr) { - free(xdpy); - return NULL; - } - - xdpy->use_xshm = - (use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM)); - - xdpy->winsys = create_sw_winsys(); - xdpy->base.screen = softpipe_create_screen(xdpy->winsys); - - xdpy->base.destroy = ximage_display_destroy; - - xdpy->base.get_configs = ximage_display_get_configs; - xdpy->base.is_pixmap_supported = ximage_display_is_pixmap_supported; - xdpy->base.create_context = ximage_display_create_context; - xdpy->base.create_window_surface = ximage_display_create_window_surface; - xdpy->base.create_pixmap_surface = ximage_display_create_pixmap_surface; - xdpy->base.create_pbuffer_surface = ximage_display_create_pbuffer_surface; - - return &xdpy->base; -} diff --git a/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c b/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c deleted file mode 100644 index 6ee3ede38cb..00000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c +++ /dev/null @@ -1,231 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/** - * Totally software-based winsys layer. - * Note that the one winsys function that we can't implement here - * is flush_frontbuffer(). - * Whoever uses this code will have to provide that. - * - * Authors: Brian Paul - */ - - -#include "pipe/internal/p_winsys_screen.h" -#include "pipe/p_state.h" -#include "pipe/p_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" - -#include "sw_winsys.h" - - - -/** Subclass of pipe_winsys */ -struct sw_pipe_winsys -{ - struct pipe_winsys Base; - /* no extra fields for now */ -}; - - -/** subclass of pipe_buffer */ -struct sw_pipe_buffer -{ - struct pipe_buffer Base; - boolean UserBuffer; /** Is this a user-space buffer? */ - void *Data; - void *Mapped; -}; - - -/** cast wrapper */ -static INLINE struct sw_pipe_buffer * -sw_pipe_buffer(struct pipe_buffer *b) -{ - return (struct sw_pipe_buffer *) b; -} - - -static const char * -get_name(struct pipe_winsys *pws) -{ - return "software"; -} - - -/** Create new pipe_buffer and allocate storage of given size */ -static struct pipe_buffer * -buffer_create(struct pipe_winsys *pws, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); - if (!buffer) - return NULL; - - pipe_reference_init(&buffer->Base.reference, 1); - buffer->Base.alignment = alignment; - buffer->Base.usage = usage; - buffer->Base.size = size; - - /* align to 16-byte multiple for Cell */ - buffer->Data = align_malloc(size, MAX2(alignment, 16)); - - return &buffer->Base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) -{ - struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); - if (!buffer) - return NULL; - - pipe_reference_init(&buffer->Base.reference, 1); - buffer->Base.size = bytes; - buffer->UserBuffer = TRUE; - buffer->Data = ptr; - - return &buffer->Base; -} - - -static void * -buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned flags) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - buffer->Mapped = buffer->Data; - return buffer->Mapped; -} - - -static void -buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - buffer->Mapped = NULL; -} - - -static void -buffer_destroy(struct pipe_buffer *buf) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - - if (buffer->Data && !buffer->UserBuffer) { - align_free(buffer->Data); - buffer->Data = NULL; - } - - free(buffer); -} - - -static struct pipe_buffer * -surface_buffer_create(struct pipe_winsys *winsys, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - const unsigned alignment = 64; - unsigned nblocksy; - - nblocksy = util_format_get_nblocksy(format, height); - *stride = align(util_format_get_stride(format, width), alignment); - - return winsys->buffer_create(winsys, alignment, - usage, - *stride * nblocksy); -} - - -static void -fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ - /* no-op */ -} - - -static int -fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - /* no-op */ - return 0; -} - - -static int -fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - /* no-op */ - return 0; -} - - -/** - * Create/return a new pipe_winsys object. - */ -struct pipe_winsys * -create_sw_winsys(void) -{ - struct sw_pipe_winsys *ws = CALLOC_STRUCT(sw_pipe_winsys); - if (!ws) - return NULL; - - /* Fill in this struct with callbacks that pipe will need to - * communicate with the window system, buffer manager, etc. - */ - ws->Base.buffer_create = buffer_create; - ws->Base.user_buffer_create = user_buffer_create; - ws->Base.buffer_map = buffer_map; - ws->Base.buffer_unmap = buffer_unmap; - ws->Base.buffer_destroy = buffer_destroy; - - ws->Base.surface_buffer_create = surface_buffer_create; - - ws->Base.fence_reference = fence_reference; - ws->Base.fence_signalled = fence_signalled; - ws->Base.fence_finish = fence_finish; - - ws->Base.flush_frontbuffer = NULL; /* not implemented here! */ - - ws->Base.get_name = get_name; - - return &ws->Base; -} diff --git a/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h b/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h deleted file mode 100644 index f96c5a14b0a..00000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -#ifndef SW_WINSYS_H -#define SW_WINSYS_H - - -struct pipe_winsys; - - -extern struct pipe_winsys * -create_sw_winsys(void); - - -#endif /* SW_WINSYS_H */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c deleted file mode 100644 index 76ce45ee574..00000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include "util/u_memory.h" -#include "util/u_math.h" -#include "util/u_format.h" -#include "xf86drm.h" -#include "egllog.h" - -#include "x11_screen.h" -#include "dri2.h" -#include "glxinit.h" - -struct x11_screen { - Display *dpy; - int number; - - /* - * This is used to fetch GLX visuals/fbconfigs. It uses code from egl_xdri. - * It might be better to rewrite the part in Xlib or XCB. - */ - __GLXdisplayPrivate *glx_dpy; - - int dri_major, dri_minor; - char *dri_driver; - char *dri_device; - int dri_fd; - - XVisualInfo *visuals; - int num_visuals; - - /* cached values for x11_drawable_get_depth */ - Drawable last_drawable; - unsigned int last_depth; -}; - - -/** - * Create a X11 screen. - */ -struct x11_screen * -x11_screen_create(Display *dpy, int screen) -{ - struct x11_screen *xscr; - - if (screen >= ScreenCount(dpy)) - return NULL; - - xscr = CALLOC_STRUCT(x11_screen); - if (xscr) { - xscr->dpy = dpy; - xscr->number = screen; - - xscr->dri_major = -1; - xscr->dri_fd = -1; - } - return xscr; -} - -/** - * Destroy a X11 screen. - */ -void -x11_screen_destroy(struct x11_screen *xscr) -{ - if (xscr->dri_fd >= 0) - close(xscr->dri_fd); - if (xscr->dri_driver) - Xfree(xscr->dri_driver); - if (xscr->dri_device) - Xfree(xscr->dri_device); - - /* xscr->glx_dpy will be destroyed with the X display */ - - if (xscr->visuals) - XFree(xscr->visuals); - free(xscr); -} - -static boolean -x11_screen_init_dri2(struct x11_screen *xscr) -{ - if (xscr->dri_major < 0) { - int eventBase, errorBase; - - if (!DRI2QueryExtension(xscr->dpy, &eventBase, &errorBase) || - !DRI2QueryVersion(xscr->dpy, &xscr->dri_major, &xscr->dri_minor)) - xscr->dri_major = -1; - } - return (xscr->dri_major >= 0); -} - -static boolean -x11_screen_init_glx(struct x11_screen *xscr) -{ - if (!xscr->glx_dpy) - xscr->glx_dpy = __glXInitialize(xscr->dpy); - return (xscr->glx_dpy != NULL); -} - -/** - * Return true if the screen supports the extension. - */ -boolean -x11_screen_support(struct x11_screen *xscr, enum x11_screen_extension ext) -{ - boolean supported = FALSE; - - switch (ext) { - case X11_SCREEN_EXTENSION_XSHM: - supported = XShmQueryExtension(xscr->dpy); - break; - case X11_SCREEN_EXTENSION_GLX: - supported = x11_screen_init_glx(xscr); - break; - case X11_SCREEN_EXTENSION_DRI2: - supported = x11_screen_init_dri2(xscr); - break; - default: - break; - } - - return supported; -} - -/** - * Return the X visuals. - */ -const XVisualInfo * -x11_screen_get_visuals(struct x11_screen *xscr, int *num_visuals) -{ - if (!xscr->visuals) { - XVisualInfo vinfo_template; - vinfo_template.screen = xscr->number; - xscr->visuals = XGetVisualInfo(xscr->dpy, VisualScreenMask, - &vinfo_template, &xscr->num_visuals); - } - - if (num_visuals) - *num_visuals = xscr->num_visuals; - return xscr->visuals; -} - -void -x11_screen_convert_visual(struct x11_screen *xscr, const XVisualInfo *visual, - __GLcontextModes *mode) -{ - int r, g, b, a; - int visual_type; - - r = util_bitcount(visual->red_mask); - g = util_bitcount(visual->green_mask); - b = util_bitcount(visual->blue_mask); - a = visual->depth - (r + g + b); -#if defined(__cplusplus) || defined(c_plusplus) - visual_type = visual->c_class; -#else - visual_type = visual->class; -#endif - - /* convert to GLX visual type */ - switch (visual_type) { - case TrueColor: - visual_type = GLX_TRUE_COLOR; - break; - case DirectColor: - visual_type = GLX_DIRECT_COLOR; - break; - case PseudoColor: - visual_type = GLX_PSEUDO_COLOR; - break; - case StaticColor: - visual_type = GLX_STATIC_COLOR; - break; - case GrayScale: - visual_type = GLX_GRAY_SCALE; - break; - case StaticGray: - visual_type = GLX_STATIC_GRAY; - break; - default: - visual_type = GLX_NONE; - break; - } - - mode->rgbBits = r + g + b + a; - mode->redBits = r; - mode->greenBits = g; - mode->blueBits = b; - mode->alphaBits = a; - mode->visualID = visual->visualid; - mode->visualType = visual_type; - - /* sane defaults */ - mode->renderType = GLX_RGBA_BIT; - mode->rgbMode = TRUE; - mode->visualRating = GLX_SLOW_CONFIG; - mode->xRenderable = TRUE; -} - -/** - * Return the GLX fbconfigs. - */ -const __GLcontextModes * -x11_screen_get_glx_configs(struct x11_screen *xscr) -{ - return (x11_screen_init_glx(xscr)) - ? xscr->glx_dpy->screenConfigs[xscr->number].configs - : NULL; -} - -/** - * Return the GLX visuals. - */ -const __GLcontextModes * -x11_screen_get_glx_visuals(struct x11_screen *xscr) -{ - return (x11_screen_init_glx(xscr)) - ? xscr->glx_dpy->screenConfigs[xscr->number].visuals - : NULL; -} - -static boolean -x11_screen_is_driver_equal(struct x11_screen *xscr, const char *driver) -{ - return (strcmp(xscr->dri_driver, driver) == 0); -} - -/** - * Probe the screen for the DRI2 driver name. - */ -const char * -x11_screen_probe_dri2(struct x11_screen *xscr) -{ - /* get the driver name and the device name */ - if (!xscr->dri_driver) { - if (!DRI2Connect(xscr->dpy, RootWindow(xscr->dpy, xscr->number), - &xscr->dri_driver, &xscr->dri_device)) - xscr->dri_driver = xscr->dri_device = NULL; - } - - return xscr->dri_driver; -} - -/** - * Enable DRI2 and returns the file descriptor of the DRM device. The file - * descriptor will be closed automatically when the screen is destoryed. - */ -int -x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver) -{ - if (xscr->dri_fd < 0) { - int fd; - drm_magic_t magic; - - /* get the driver name and the device name first */ - if (!x11_screen_probe_dri2(xscr)) - return -1; - - if (!x11_screen_is_driver_equal(xscr, driver)) { - _eglLog(_EGL_WARNING, "Driver mismatch: %s != %s", - xscr->dri_driver, driver); - return -1; - } - - fd = open(xscr->dri_device, O_RDWR); - if (fd < 0) { - _eglLog(_EGL_WARNING, "failed to open %s", xscr->dri_device); - return -1; - } - - memset(&magic, 0, sizeof(magic)); - if (drmGetMagic(fd, &magic)) { - _eglLog(_EGL_WARNING, "failed to get magic"); - close(fd); - return -1; - } - - if (!DRI2Authenticate(xscr->dpy, - RootWindow(xscr->dpy, xscr->number), magic)) { - _eglLog(_EGL_WARNING, "failed to authenticate magic"); - close(fd); - return -1; - } - - xscr->dri_fd = fd; - } - - return xscr->dri_fd; -} - -/** - * Create/Destroy the DRI drawable. - */ -void -x11_drawable_enable_dri2(struct x11_screen *xscr, - Drawable drawable, boolean on) -{ - if (on) - DRI2CreateDrawable(xscr->dpy, drawable); - else - DRI2DestroyDrawable(xscr->dpy, drawable); -} - -/** - * Copy between buffers of the DRI2 drawable. - */ -void -x11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable, - int x, int y, int width, int height, - int src_buf, int dst_buf) -{ - XRectangle rect; - XserverRegion region; - - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height; - - region = XFixesCreateRegion(xscr->dpy, &rect, 1); - DRI2CopyRegion(xscr->dpy, drawable, region, dst_buf, src_buf); - XFixesDestroyRegion(xscr->dpy, region); -} - -/** - * Get the buffers of the DRI2 drawable. The returned array should be freed. - */ -struct x11_drawable_buffer * -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) -{ - DRI2Buffer *dri2bufs; - - if (with_format) - dri2bufs = DRI2GetBuffersWithFormat(xscr->dpy, drawable, width, height, - attachments, num_ins, num_outs); - else - dri2bufs = DRI2GetBuffers(xscr->dpy, drawable, width, height, - attachments, num_ins, num_outs); - - 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. - */ -__GLcontextModes * -x11_context_modes_create(unsigned count) -{ - const size_t size = sizeof(__GLcontextModes); - __GLcontextModes *base = NULL; - __GLcontextModes **next; - unsigned i; - - next = &base; - for (i = 0; i < count; i++) { - *next = (__GLcontextModes *) calloc(1, size); - if (*next == NULL) { - x11_context_modes_destroy(base); - base = NULL; - break; - } - next = &((*next)->next); - } - - return base; -} - -/** - * Destroy a mode list. - */ -void -x11_context_modes_destroy(__GLcontextModes *modes) -{ - while (modes != NULL) { - __GLcontextModes *next = modes->next; - free(modes); - modes = next; - } -} - -/** - * Return the number of the modes in the mode list. - */ -unsigned -x11_context_modes_count(const __GLcontextModes *modes) -{ - const __GLcontextModes *mode; - int count = 0; - for (mode = modes; mode; mode = mode->next) - count++; - return count; -} diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h deleted file mode 100644 index 5432858ac3e..00000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef _X11_SCREEN_H_ -#define _X11_SCREEN_H_ - -#include -#include -#include -#include "pipe/p_compiler.h" -#include "common/native.h" - -enum x11_screen_extension { - X11_SCREEN_EXTENSION_XSHM, - X11_SCREEN_EXTENSION_GLX, - X11_SCREEN_EXTENSION_DRI2, -}; - -/* the same as DRI2Buffer */ -struct x11_drawable_buffer { - unsigned int attachment; - unsigned int name; - unsigned int pitch; - unsigned int cpp; - unsigned int flags; -}; - -struct x11_screen; - -struct x11_screen * -x11_screen_create(Display *dpy, int screen); - -void -x11_screen_destroy(struct x11_screen *xscr); - -boolean -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); - -void -x11_screen_convert_visual(struct x11_screen *xscr, const XVisualInfo *visual, - __GLcontextModes *mode); - -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 -x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver); - -__GLcontextModes * -x11_context_modes_create(unsigned count); - -void -x11_context_modes_destroy(__GLcontextModes *modes); - -unsigned -x11_context_modes_count(const __GLcontextModes *modes); - -void -x11_drawable_enable_dri2(struct x11_screen *xscr, - Drawable drawable, boolean on); - -void -x11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable, - int x, int y, int width, int height, - int src_buf, int dst_buf); - -struct x11_drawable_buffer * -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 /* _X11_SCREEN_H_ */ diff --git a/src/gallium/winsys/drm/Makefile.egl b/src/gallium/winsys/drm/Makefile.egl new file mode 100644 index 00000000000..1b10f1115ca --- /dev/null +++ b/src/gallium/winsys/drm/Makefile.egl @@ -0,0 +1,65 @@ +# src/gallium/winsys/drm/Makefile.egl + +# The driver Makefile should define +# +# EGL_DRIVER_NAME, the name of the driver +# EGL_DRIVER_SOURCES, the sources of the driver +# EGL_DRIVER_LIBS, extra libraries needed by the driver +# EGL_DRIVER_PIPES, the pipe drivers of the driver +# +# before including this file. + +EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o) + +common_LIBS = -ldrm -lm -ldl + +x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a +x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes + +kms_ST = $(TOP)/src/gallium/state_trackers/egl/libeglkms.a +kms_LIBS = $(common_LIBS) + +##### RULES ##### + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + + +##### TARGETS ##### + +EGL_DISPLAY_DRIVERS = $(foreach dpy, $(EGL_DISPLAYS), egl_$(dpy)_$(EGL_DRIVER_NAME).so) + +LIB_GALLIUM_DIR = $(TOP)/$(LIB_DIR)/gallium +EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(LIB_GALLIUM_DIR)/$(drv)) + +default: $(EGL_DISPLAY_LIBS) + +$(EGL_DISPLAY_LIBS): $(LIB_GALLIUM_DIR)/%.so: %.so + @mkdir -p $(LIB_GALLIUM_DIR) + $(INSTALL) $^ $(LIB_GALLIUM_DIR) + +define mklib-egl +$(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \ + -Wl,--whole-archive $($(1)_ST) -Wl,--no-whole-archive \ + $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $($(1)_LIBS) $(EGL_DRIVER_LIBS) +endef + +egl_x11_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(x11_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile + $(call mklib-egl,x11) + +egl_kms_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(kms_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile + $(call mklib-egl,kms) + +clean: + -rm -f $(EGL_DRIVER_OBJECTS) + -rm -f $(EGL_DISPLAY_DRIVERS) + +install: $(EGL_DISPLAY_LIBS) + @$(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + @echo "Install $(EGL_DISPLAY_DRIVERS)" + @for lib in "$(EGL_DISPLAY_LIBS)"; do \ + $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR); \ + done + +depend: diff --git a/src/gallium/winsys/drm/Makefile.egl_g3d b/src/gallium/winsys/drm/Makefile.egl_g3d deleted file mode 100644 index d8f47396d16..00000000000 --- a/src/gallium/winsys/drm/Makefile.egl_g3d +++ /dev/null @@ -1,65 +0,0 @@ -# src/gallium/winsys/drm/Makefile.egl_g3d - -# The driver Makefile should define -# -# EGL_DRIVER_NAME, the name of the driver -# EGL_DRIVER_SOURCES, the sources of the driver -# EGL_DRIVER_LIBS, extra libraries needed by the driver -# EGL_DRIVER_PIPES, the pipe drivers of the driver -# -# before including this file. - -EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o) - -common_LIBS = -ldrm -lm -ldl - -x11_ST = $(TOP)/src/gallium/state_trackers/egl_g3d/libeglx11.a -x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes - -kms_ST = $(TOP)/src/gallium/state_trackers/egl_g3d/libeglkms.a -kms_LIBS = $(common_LIBS) - -##### RULES ##### - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ - - -##### TARGETS ##### - -EGL_DISPLAY_DRIVERS = $(foreach dpy, $(EGL_DISPLAYS), egl_$(dpy)_$(EGL_DRIVER_NAME).so) - -LIB_GALLIUM_DIR = $(TOP)/$(LIB_DIR)/gallium -EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(LIB_GALLIUM_DIR)/$(drv)) - -default: $(EGL_DISPLAY_LIBS) - -$(EGL_DISPLAY_LIBS): $(LIB_GALLIUM_DIR)/%.so: %.so - @mkdir -p $(LIB_GALLIUM_DIR) - $(INSTALL) $^ $(LIB_GALLIUM_DIR) - -define mklib-egl -$(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \ - -Wl,--whole-archive $($(1)_ST) -Wl,--no-whole-archive \ - $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $($(1)_LIBS) $(EGL_DRIVER_LIBS) -endef - -egl_x11_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(x11_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile - $(call mklib-egl,x11) - -egl_kms_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(kms_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile - $(call mklib-egl,kms) - -clean: - -rm -f $(EGL_DRIVER_OBJECTS) - -rm -f $(EGL_DISPLAY_DRIVERS) - -install: $(EGL_DISPLAY_LIBS) - @$(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) - @echo "Install $(EGL_DISPLAY_DRIVERS)" - @for lib in "$(EGL_DISPLAY_LIBS)"; do \ - $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR); \ - done - -depend: diff --git a/src/gallium/winsys/drm/i965/egl/Makefile b/src/gallium/winsys/drm/i965/egl/Makefile new file mode 100644 index 00000000000..1c132582005 --- /dev/null +++ b/src/gallium/winsys/drm/i965/egl/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = i965 +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = -ldrm_intel + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/i965/libi965.a + +include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/i965/egl/dummy.c b/src/gallium/winsys/drm/i965/egl/dummy.c new file mode 100644 index 00000000000..4a1bc28b0b6 --- /dev/null +++ b/src/gallium/winsys/drm/i965/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/i965/egl_g3d/Makefile b/src/gallium/winsys/drm/i965/egl_g3d/Makefile deleted file mode 100644 index dd2efe24855..00000000000 --- a/src/gallium/winsys/drm/i965/egl_g3d/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = i965 -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = -ldrm_intel - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/i965/libi965.a - -include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/i965/egl_g3d/dummy.c b/src/gallium/winsys/drm/i965/egl_g3d/dummy.c deleted file mode 100644 index 4a1bc28b0b6..00000000000 --- a/src/gallium/winsys/drm/i965/egl_g3d/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/intel/egl/Makefile b/src/gallium/winsys/drm/intel/egl/Makefile new file mode 100644 index 00000000000..60d675ca73d --- /dev/null +++ b/src/gallium/winsys/drm/intel/egl/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = i915 +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = -ldrm_intel + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/i915/libi915.a + +include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/intel/egl/dummy.c b/src/gallium/winsys/drm/intel/egl/dummy.c new file mode 100644 index 00000000000..4a1bc28b0b6 --- /dev/null +++ b/src/gallium/winsys/drm/intel/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/intel/egl_g3d/Makefile b/src/gallium/winsys/drm/intel/egl_g3d/Makefile deleted file mode 100644 index cdbb680773c..00000000000 --- a/src/gallium/winsys/drm/intel/egl_g3d/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = i915 -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = -ldrm_intel - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/i915/libi915.a - -include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/intel/egl_g3d/dummy.c b/src/gallium/winsys/drm/intel/egl_g3d/dummy.c deleted file mode 100644 index 4a1bc28b0b6..00000000000 --- a/src/gallium/winsys/drm/intel/egl_g3d/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/nouveau/egl/Makefile b/src/gallium/winsys/drm/nouveau/egl/Makefile new file mode 100644 index 00000000000..8e812acc86b --- /dev/null +++ b/src/gallium/winsys/drm/nouveau/egl/Makefile @@ -0,0 +1,19 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = nouveau +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = -ldrm_nouveau + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ + $(TOP)/src/gallium/drivers/nv04/libnv04.a \ + $(TOP)/src/gallium/drivers/nv10/libnv10.a \ + $(TOP)/src/gallium/drivers/nv20/libnv20.a \ + $(TOP)/src/gallium/drivers/nv30/libnv30.a \ + $(TOP)/src/gallium/drivers/nv40/libnv40.a \ + $(TOP)/src/gallium/drivers/nv50/libnv50.a \ + $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a + +include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/nouveau/egl/dummy.c b/src/gallium/winsys/drm/nouveau/egl/dummy.c new file mode 100644 index 00000000000..4a1bc28b0b6 --- /dev/null +++ b/src/gallium/winsys/drm/nouveau/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/nouveau/egl_g3d/Makefile b/src/gallium/winsys/drm/nouveau/egl_g3d/Makefile deleted file mode 100644 index 865a5d56a97..00000000000 --- a/src/gallium/winsys/drm/nouveau/egl_g3d/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = nouveau -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = -ldrm_nouveau - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ - $(TOP)/src/gallium/drivers/nv04/libnv04.a \ - $(TOP)/src/gallium/drivers/nv10/libnv10.a \ - $(TOP)/src/gallium/drivers/nv20/libnv20.a \ - $(TOP)/src/gallium/drivers/nv30/libnv30.a \ - $(TOP)/src/gallium/drivers/nv40/libnv40.a \ - $(TOP)/src/gallium/drivers/nv50/libnv50.a \ - $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a - -include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c b/src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c deleted file mode 100644 index 4a1bc28b0b6..00000000000 --- a/src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile new file mode 100644 index 00000000000..cd4f9b20f06 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/egl/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = radeon +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = -ldrm_radeon + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/r300/libr300.a + +include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/radeon/egl/dummy.c b/src/gallium/winsys/drm/radeon/egl/dummy.c new file mode 100644 index 00000000000..4a1bc28b0b6 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/radeon/egl_g3d/Makefile b/src/gallium/winsys/drm/radeon/egl_g3d/Makefile deleted file mode 100644 index e0de68c678f..00000000000 --- a/src/gallium/winsys/drm/radeon/egl_g3d/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = radeon -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = -ldrm_radeon - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/r300/libr300.a - -include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/radeon/egl_g3d/dummy.c b/src/gallium/winsys/drm/radeon/egl_g3d/dummy.c deleted file mode 100644 index 4a1bc28b0b6..00000000000 --- a/src/gallium/winsys/drm/radeon/egl_g3d/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/swrast/egl/Makefile b/src/gallium/winsys/drm/swrast/egl/Makefile new file mode 100644 index 00000000000..26fe2d2805a --- /dev/null +++ b/src/gallium/winsys/drm/swrast/egl/Makefile @@ -0,0 +1,12 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = swrast +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/swrast/core/libswrastdrm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a + +include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/swrast/egl/dummy.c b/src/gallium/winsys/drm/swrast/egl/dummy.c new file mode 100644 index 00000000000..4a1bc28b0b6 --- /dev/null +++ b/src/gallium/winsys/drm/swrast/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/swrast/egl_g3d/Makefile b/src/gallium/winsys/drm/swrast/egl_g3d/Makefile deleted file mode 100644 index f0d051ea0ea..00000000000 --- a/src/gallium/winsys/drm/swrast/egl_g3d/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = swrast -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/swrast/core/libswrastdrm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a - -include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/swrast/egl_g3d/dummy.c b/src/gallium/winsys/drm/swrast/egl_g3d/dummy.c deleted file mode 100644 index 4a1bc28b0b6..00000000000 --- a/src/gallium/winsys/drm/swrast/egl_g3d/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/vmware/egl/Makefile b/src/gallium/winsys/drm/vmware/egl/Makefile new file mode 100644 index 00000000000..a3e73131c35 --- /dev/null +++ b/src/gallium/winsys/drm/vmware/egl/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = vmwgfx +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/svga/libsvga.a + +include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/vmware/egl/dummy.c b/src/gallium/winsys/drm/vmware/egl/dummy.c new file mode 100644 index 00000000000..4a1bc28b0b6 --- /dev/null +++ b/src/gallium/winsys/drm/vmware/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/vmware/egl_g3d/Makefile b/src/gallium/winsys/drm/vmware/egl_g3d/Makefile deleted file mode 100644 index 3cf79924e08..00000000000 --- a/src/gallium/winsys/drm/vmware/egl_g3d/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = vmwgfx -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/svga/libsvga.a - -include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/vmware/egl_g3d/dummy.c b/src/gallium/winsys/drm/vmware/egl_g3d/dummy.c deleted file mode 100644 index 4a1bc28b0b6..00000000000 --- a/src/gallium/winsys/drm/vmware/egl_g3d/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one object file */ -- cgit v1.2.3 From 28c3e57c8354f988f49bac69a6866418e6009a5d Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 23 Jan 2010 20:18:43 +0800 Subject: egl: Install drivers to ${libdir}/egl. Install EGL drivers to EGL_DRIVER_INSTALL_DIR, which is default to ${libdir}/egl. --- configs/autoconf.in | 3 +++ configs/default | 3 +++ configure.ac | 7 +++++++ src/egl/drivers/Makefile.template | 4 ++-- src/egl/main/Makefile | 2 +- src/gallium/winsys/drm/Makefile.egl | 15 ++++++--------- 6 files changed, 22 insertions(+), 12 deletions(-) (limited to 'configure.ac') diff --git a/configs/autoconf.in b/configs/autoconf.in index d9fa2dafe93..b0024ec6899 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -130,6 +130,9 @@ DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INSTALL_DIR@ # Where libGL will look for DRI hardware drivers DRI_DRIVER_SEARCH_DIR = @DRI_DRIVER_SEARCH_DIR@ +# EGL driver install directory +EGL_DRIVER_INSTALL_DIR = @EGL_DRIVER_INSTALL_DIR@ + # Xorg driver install directory (for xorg state-tracker) XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@ diff --git a/configs/default b/configs/default index 3aa136b9c58..d79039561e2 100644 --- a/configs/default +++ b/configs/default @@ -130,6 +130,9 @@ DRI_DRIVER_INSTALL_DIR = $(INSTALL_LIB_DIR)/dri # Where libGL will look for DRI hardware drivers DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR) +# EGL driver install directory +EGL_DRIVER_INSTALL_DIR = $(INSTALL_LIB_DIR)/egl + # Xorg driver install directory (for xorg state-tracker) XORG_DRIVER_INSTALL_DIR = $(INSTALL_LIB_DIR)/xorg/modules/drivers diff --git a/configure.ac b/configure.ac index 370bd1b9b7f..6f8b76d7ca9 100644 --- a/configure.ac +++ b/configure.ac @@ -1231,6 +1231,13 @@ yes) esac AC_SUBST([EGL_DISPLAYS]) +AC_ARG_WITH([egl-driver-dir], + [AS_HELP_STRING([--with-egl-driver-dir=DIR], + [directory for EGL drivers [[default=${libdir}/egl]]])], + [EGL_DRIVER_INSTALL_DIR="$withval"], + [EGL_DRIVER_INSTALL_DIR='${libdir}/egl']) +AC_SUBST([EGL_DRIVER_INSTALL_DIR]) + AC_ARG_WITH([xorg-driver-dir], [AS_HELP_STRING([--with-xorg-driver-dir=DIR], [Default xorg driver directory[[default=${libdir}/xorg/modules/drivers]]])], diff --git a/src/egl/drivers/Makefile.template b/src/egl/drivers/Makefile.template index 02a65b094a7..e9a614ce62d 100644 --- a/src/egl/drivers/Makefile.template +++ b/src/egl/drivers/Makefile.template @@ -32,8 +32,8 @@ $(EGL_DRIVER): $(EGL_OBJECTS) Makefile $(TOP)/src/egl/drivers/Makefile.template install: $(EGL_DRIVER_PATH) - $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(MINSTALL) $(EGL_DRIVER_PATH) $(DESTDIR)$(INSTALL_LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR) + $(MINSTALL) $(EGL_DRIVER_PATH) $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR) clean: rm -f $(EGL_DRIVER) diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 66f8f01b8e2..20614d87536 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -53,7 +53,7 @@ EGL_DEFAULT_DISPLAY = $(word 1, $(EGL_DISPLAYS)) LOCAL_CFLAGS += \ -D_EGL_DEFAULT_DISPLAY=\"$(EGL_DEFAULT_DISPLAY)\" \ - -D_EGL_DRIVER_SEARCH_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" + -D_EGL_DRIVER_SEARCH_DIR=\"$(EGL_DRIVER_INSTALL_DIR)\" .c.o: $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(LOCAL_CFLAGS) $< -o $@ diff --git a/src/gallium/winsys/drm/Makefile.egl b/src/gallium/winsys/drm/Makefile.egl index 1b10f1115ca..d79ceee5b78 100644 --- a/src/gallium/winsys/drm/Makefile.egl +++ b/src/gallium/winsys/drm/Makefile.egl @@ -29,14 +29,12 @@ kms_LIBS = $(common_LIBS) EGL_DISPLAY_DRIVERS = $(foreach dpy, $(EGL_DISPLAYS), egl_$(dpy)_$(EGL_DRIVER_NAME).so) -LIB_GALLIUM_DIR = $(TOP)/$(LIB_DIR)/gallium -EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(LIB_GALLIUM_DIR)/$(drv)) +EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(TOP)/$(LIB_DIR)/$(drv)) default: $(EGL_DISPLAY_LIBS) -$(EGL_DISPLAY_LIBS): $(LIB_GALLIUM_DIR)/%.so: %.so - @mkdir -p $(LIB_GALLIUM_DIR) - $(INSTALL) $^ $(LIB_GALLIUM_DIR) +$(EGL_DISPLAY_LIBS): $(TOP)/$(LIB_DIR)/%.so: %.so + $(INSTALL) $< $(TOP)/$(LIB_DIR) define mklib-egl $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ @@ -56,10 +54,9 @@ clean: -rm -f $(EGL_DISPLAY_DRIVERS) install: $(EGL_DISPLAY_LIBS) - @$(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) - @echo "Install $(EGL_DISPLAY_DRIVERS)" - @for lib in "$(EGL_DISPLAY_LIBS)"; do \ - $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR); \ + $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR) + for lib in "$(EGL_DISPLAY_LIBS)"; do \ + $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \ done depend: -- cgit v1.2.3 From 146931769c75978c58ac0088e8ab630fc41074ec Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 21 Jan 2010 17:58:28 +0800 Subject: glx: Build GLX normally. GLX was built specially and before Mesa core because libglapi.a could not be built with IN_DRI_DRIVER defined. This is no longer the case since 6e99e6ddbf488f6955e34ef0bc438fdcb4d90f74. It works fine in my (limited) testing with both direct and indirect rendering. I also compare the outputs after preprocessing (gcc -E) with or without this commit, and they are identical. --- configure.ac | 2 +- src/glx/x11/Makefile | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 6f8b76d7ca9..10e0bd47aba 100644 --- a/configure.ac +++ b/configure.ac @@ -445,7 +445,7 @@ xlib) GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib" ;; dri) - CORE_DIRS="glx/x11 $CORE_DIRS" + SRC_DIRS="$SRC_DIRS glx/x11" DRIVER_DIRS="dri" WINDOW_SYSTEM="dri" GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm" diff --git a/src/glx/x11/Makefile b/src/glx/x11/Makefile index 86d84d4b9ff..e681be834f0 100644 --- a/src/glx/x11/Makefile +++ b/src/glx/x11/Makefile @@ -1,7 +1,7 @@ TOP = ../../.. include $(TOP)/configs/current -EXTRA_DEFINES = -DXF86VIDMODE -D_REENTRANT -UIN_DRI_DRIVER \ +EXTRA_DEFINES = -DXF86VIDMODE -D_REENTRANT \ -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" SOURCES = \ @@ -39,13 +39,9 @@ SOURCES = \ dri2_glx.c \ dri2.c -include $(TOP)/src/mesa/sources.mak +GLAPI_LIB = $(TOP)/src/mesa/libglapi.a -MESA_GLAPI_ASM_SOURCES = $(addprefix $(TOP)/src/mesa/, $(GLAPI_ASM_SOURCES)) -MESA_GLAPI_SOURCES = $(addprefix $(TOP)/src/mesa/, $(GLAPI_SOURCES)) -MESA_GLAPI_OBJECTS = $(addprefix $(TOP)/src/mesa/, $(GLAPI_OBJECTS)) - -OBJECTS = $(SOURCES:.c=.o) $(MESA_GLAPI_OBJECTS) +OBJECTS = $(SOURCES:.c=.o) INCLUDES = -I. \ -I$(TOP)/include \ @@ -70,18 +66,19 @@ INCLUDES = -I. \ default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) # Make libGL -$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile +$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) $(GLAPI_LIB) Makefile $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ -major 1 -minor 2 $(MKLIB_OPTIONS) \ -install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/lib$(GL_LIB).1.dylib \ - $(GL_LIB_DEPS) $(OBJECTS) + $(GL_LIB_DEPS) $(OBJECTS) $(GLAPI_LIB) +$(GLAPI_LIB): + @$(MAKE) -C $(TOP)/src/mesa libglapi.a -depend: $(SOURCES) $(MESA_GLAPI_SOURCES) $(MESA_GLAPI_ASM_SOURCES) Makefile +depend: $(SOURCES) Makefile rm -f depend touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) \ - $(MESA_GLAPI_SOURCES) $(MESA_GLAPI_ASM_SOURCES) + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) # Emacs tags -- cgit v1.2.3 From 42fa009e641c35a6543f2fb63b229c0adc8a30dc Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Wed, 3 Feb 2010 10:18:28 -0500 Subject: egl: Add driver for EGL on X with DRI2 --- configure.ac | 10 +- src/egl/drivers/dri2/Makefile | 19 + src/egl/drivers/dri2/egl_dri2.c | 931 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 959 insertions(+), 1 deletion(-) create mode 100644 src/egl/drivers/dri2/Makefile create mode 100644 src/egl/drivers/dri2/egl_dri2.c (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 10e0bd47aba..16d315e13ad 100644 --- a/configure.ac +++ b/configure.ac @@ -915,6 +915,10 @@ if test "x$enable_egl" = xyes; then # build egl_glx when libGL is built EGL_DRIVERS_DIRS="glx" fi + if test "$mesa_driver" == dri; then + # build egl_dri2 when dri is enabled + EGL_DRIVERS_DIRS="$EGL_DRIVERS_DIRS dri2" + fi fi AC_SUBST([EGL_LIB_DEPS]) AC_SUBST([EGL_DRIVERS_DIRS]) @@ -1395,7 +1399,11 @@ dnl Libraries echo "" echo " Shared libs: $enable_shared" echo " Static libs: $enable_static" -echo " EGL: $enable_egl" +if test "$enable_egl" = yes; then + echo " EGL: $EGL_DRIVERS_DIRS" +else + echo " EGL: no" +fi echo " GLU: $enable_glu" echo " GLw: $enable_glw (Motif: $enable_motif)" echo " glut: $enable_glut" diff --git a/src/egl/drivers/dri2/Makefile b/src/egl/drivers/dri2/Makefile new file mode 100644 index 00000000000..95f95745311 --- /dev/null +++ b/src/egl/drivers/dri2/Makefile @@ -0,0 +1,19 @@ +# src/egl/drivers/dri2/Makefile + +TOP = ../../../.. +include $(TOP)/configs/current + +EGL_DRIVER = egl_dri2.so +EGL_SOURCES = egl_dri2.c + +EGL_INCLUDES = \ + -I$(TOP)/include \ + -I$(TOP)/src/egl/main \ + -I$(TOP)/src/mesa \ + -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" \ + $(shell pkg-config --cflags xcb-dri2 xcb-xfixes x11-xcb libdrm) + +EGL_CFLAGS = +EGL_LIBS = $(shell pkg-config --libs xcb-dri2 xcb-xfixes x11-xcb libdrm) + +include ../Makefile.template diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c new file mode 100644 index 00000000000..56d2b8bbe65 --- /dev/null +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -0,0 +1,931 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Kristian Høgsberg + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "eglconfigutil.h" +#include "eglconfig.h" +#include "eglcontext.h" +#include "egldisplay.h" +#include "egldriver.h" +#include "eglcurrent.h" +#include "egllog.h" +#include "eglsurface.h" + +struct dri2_egl_driver +{ + _EGLDriver base; +}; + +struct dri2_egl_display +{ + xcb_connection_t *conn; + int dri2_major; + int dri2_minor; + __DRIscreen *dri_screen; + void *driver; + __DRIcoreExtension *core; + __DRIdri2Extension *dri2; + __DRI2flushExtension *flush; + int fd; + + __DRIdri2LoaderExtension loader_extension; + const __DRIextension *extensions[2]; +}; + +struct dri2_egl_context +{ + _EGLContext base; + __DRIcontext *dri_context; +}; + +struct dri2_egl_surface +{ + _EGLSurface base; + __DRIdrawable *dri_drawable; + xcb_drawable_t drawable; + __DRIbuffer buffers[5]; + int buffer_count; + xcb_xfixes_region_t region; + int have_back; + int have_fake_front; + int swap_interval; +}; + +struct dri2_egl_config +{ + _EGLConfig base; + const __DRIconfig *dri_config; +}; + +static struct dri2_egl_driver * +dri2_egl_driver(_EGLDriver *drv) +{ + return (struct dri2_egl_driver *) drv; +} + +static struct dri2_egl_display * +dri2_egl_display(_EGLDisplay *dpy) +{ + return (struct dri2_egl_display *) dpy->DriverData; +} + +static struct dri2_egl_context * +dri2_egl_context(_EGLContext *ctx) +{ + return (struct dri2_egl_context *) ctx; +} + +static struct dri2_egl_surface * +dri2_egl_surface(_EGLSurface *surf) +{ + return (struct dri2_egl_surface *) surf; +} + +static struct dri2_egl_config * +dri2_egl_config(_EGLConfig *conf) +{ + return (struct dri2_egl_config *) conf; +} + +EGLint dri2_to_egl_attribute_map[] = { + 0, + EGL_BUFFER_SIZE, /* __DRI_ATTRIB_BUFFER_SIZE */ + EGL_LEVEL, /* __DRI_ATTRIB_LEVEL */ + EGL_RED_SIZE, /* __DRI_ATTRIB_RED_SIZE */ + EGL_GREEN_SIZE, /* __DRI_ATTRIB_GREEN_SIZE */ + EGL_BLUE_SIZE, /* __DRI_ATTRIB_BLUE_SIZE */ + 0, /* __DRI_ATTRIB_LUMINANCE_SIZE */ + EGL_ALPHA_SIZE, /* __DRI_ATTRIB_ALPHA_SIZE */ + 0, /* __DRI_ATTRIB_ALPHA_MASK_SIZE */ + EGL_DEPTH_SIZE, /* __DRI_ATTRIB_DEPTH_SIZE */ + EGL_STENCIL_SIZE, /* __DRI_ATTRIB_STENCIL_SIZE */ + 0, /* __DRI_ATTRIB_ACCUM_RED_SIZE */ + 0, /* __DRI_ATTRIB_ACCUM_GREEN_SIZE */ + 0, /* __DRI_ATTRIB_ACCUM_BLUE_SIZE */ + 0, /* __DRI_ATTRIB_ACCUM_ALPHA_SIZE */ + EGL_SAMPLE_BUFFERS, /* __DRI_ATTRIB_SAMPLE_BUFFERS */ + EGL_SAMPLES, /* __DRI_ATTRIB_SAMPLES */ + 0, /* __DRI_ATTRIB_RENDER_TYPE, */ + 0, /* __DRI_ATTRIB_CONFIG_CAVEAT */ + 0, /* __DRI_ATTRIB_CONFORMANT */ + 0, /* __DRI_ATTRIB_DOUBLE_BUFFER */ + 0, /* __DRI_ATTRIB_STEREO */ + 0, /* __DRI_ATTRIB_AUX_BUFFERS */ + 0, /* __DRI_ATTRIB_TRANSPARENT_TYPE */ + 0, /* __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE */ + 0, /* __DRI_ATTRIB_TRANSPARENT_RED_VALUE */ + 0, /* __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE */ + 0, /* __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE */ + 0, /* __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE */ + 0, /* __DRI_ATTRIB_FLOAT_MODE */ + 0, /* __DRI_ATTRIB_RED_MASK */ + 0, /* __DRI_ATTRIB_GREEN_MASK */ + 0, /* __DRI_ATTRIB_BLUE_MASK */ + 0, /* __DRI_ATTRIB_ALPHA_MASK */ + EGL_MAX_PBUFFER_WIDTH, /* __DRI_ATTRIB_MAX_PBUFFER_WIDTH */ + EGL_MAX_PBUFFER_HEIGHT, /* __DRI_ATTRIB_MAX_PBUFFER_HEIGHT */ + EGL_MAX_PBUFFER_PIXELS, /* __DRI_ATTRIB_MAX_PBUFFER_PIXELS */ + 0, /* __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH */ + 0, /* __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT */ + 0, /* __DRI_ATTRIB_VISUAL_SELECT_GROUP */ + 0, /* __DRI_ATTRIB_SWAP_METHOD */ + EGL_MAX_SWAP_INTERVAL, /* __DRI_ATTRIB_MAX_SWAP_INTERVAL */ + EGL_MIN_SWAP_INTERVAL, /* __DRI_ATTRIB_MIN_SWAP_INTERVAL */ + EGL_BIND_TO_TEXTURE_RGB, /* __DRI_ATTRIB_BIND_TO_TEXTURE_RGB */ + EGL_BIND_TO_TEXTURE_RGBA, /* __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA */ + 0, /* __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE */ + 0, /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */ + 0, /* __DRI_ATTRIB_YINVERTED */ +}; + +static void +dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id) +{ + struct dri2_egl_config *conf; + struct dri2_egl_display *dri2_dpy; + unsigned int attrib, value, surface_type; + EGLint key; + int i; + + dri2_dpy = disp->DriverData; + conf = malloc(sizeof *conf); + if (conf == NULL) + return; + + conf->dri_config = dri_config; + _eglInitConfig(&conf->base, disp, id); + surface_type = EGL_PBUFFER_BIT | EGL_PIXMAP_BIT; + + i = 0; + while (dri2_dpy->core->indexConfigAttrib(dri_config, i++, &attrib, &value)) { + switch (attrib) { + case 0: + break; + + case __DRI_ATTRIB_RENDER_TYPE: + if (value & __DRI_ATTRIB_RGBA_BIT) + value = EGL_RGB_BUFFER; + else if (value & __DRI_ATTRIB_LUMINANCE_BIT) + value = EGL_LUMINANCE_BUFFER; + else + /* not valid */; + _eglSetConfigKey(&conf->base, EGL_COLOR_BUFFER_TYPE, value); + break; + + case __DRI_ATTRIB_CONFIG_CAVEAT: + if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG) + value = EGL_NON_CONFORMANT_CONFIG; + else if (value & __DRI_ATTRIB_SLOW_BIT) + value = EGL_SLOW_CONFIG; + else + value = EGL_NONE; + _eglSetConfigKey(&conf->base, EGL_CONFIG_CAVEAT, value); + break; + + case __DRI_ATTRIB_DOUBLE_BUFFER: + if (value) + surface_type |= EGL_WINDOW_BIT; + break; + + default: + key = dri2_to_egl_attribute_map[attrib]; + if (key != 0) + _eglSetConfigKey(&conf->base, key, value); + break; + } + } + + /* EGL_SWAP_BEHAVIOR_PRESERVED_BIT */ + _eglSetConfigKey(&conf->base, EGL_SURFACE_TYPE, surface_type); + + /* EGL_OPENGL_ES_BIT, EGL_OPENVG_BIT, EGL_OPENGL_ES2_BIT */ + _eglSetConfigKey(&conf->base, EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT); + _eglSetConfigKey(&conf->base, EGL_CONFORMANT, EGL_OPENGL_BIT); + + /* FIXME: Figure out how to get the visual ID and types */ + _eglSetConfigKey(&conf->base, EGL_NATIVE_VISUAL_ID, 0x21); + _eglSetConfigKey(&conf->base, EGL_NATIVE_VISUAL_TYPE, + XCB_VISUAL_CLASS_TRUE_COLOR); + + _eglSetConfigKey(&conf->base, EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE); + _eglSetConfigKey(&conf->base, EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE); + + if (!_eglValidateConfig(&conf->base, EGL_FALSE)) { + _eglLog(_EGL_DEBUG, "DRI2: failed to validate config %d", i); + free(conf); + return; + } + + _eglAddConfig(disp, &conf->base); +} + +/** + * Process list of buffer received from the server + * + * Processes the list of buffers received in a reply from the server to either + * \c DRI2GetBuffers or \c DRI2GetBuffersWithFormat. + */ +static void +dri2_process_buffers(struct dri2_egl_surface *dri2_surf, + xcb_dri2_dri2_buffer_t *buffers, unsigned count) +{ + struct dri2_egl_display *dri2_dpy = + dri2_egl_display(dri2_surf->base.Resource.Display); + xcb_rectangle_t rectangle; + int i; + + dri2_surf->buffer_count = count; + dri2_surf->have_fake_front = 0; + dri2_surf->have_back = 0; + + /* This assumes the DRI2 buffer attachment tokens matches the + * __DRIbuffer tokens. */ + for (i = 0; i < count; i++) { + dri2_surf->buffers[i].attachment = buffers[i].attachment; + dri2_surf->buffers[i].name = buffers[i].name; + dri2_surf->buffers[i].pitch = buffers[i].pitch; + dri2_surf->buffers[i].cpp = buffers[i].cpp; + dri2_surf->buffers[i].flags = buffers[i].flags; + if (dri2_surf->buffers[i].attachment == __DRI_BUFFER_FAKE_FRONT_LEFT) + dri2_surf->have_fake_front = 1; + if (dri2_surf->buffers[i].attachment == __DRI_BUFFER_BACK_LEFT) + dri2_surf->have_back = 1; + } + + if (dri2_surf->region != XCB_NONE) + xcb_xfixes_destroy_region(dri2_dpy->conn, dri2_surf->region); + + rectangle.x = 0; + rectangle.y = 0; + rectangle.width = dri2_surf->base.Width; + rectangle.height = dri2_surf->base.Height; + dri2_surf->region = xcb_generate_id(dri2_dpy->conn); + xcb_xfixes_create_region(dri2_dpy->conn, dri2_surf->region, 1, &rectangle); +} + +static __DRIbuffer * +dri2_get_buffers(__DRIdrawable * driDrawable, + int *width, int *height, + unsigned int *attachments, int count, + int *out_count, void *loaderPrivate) +{ + struct dri2_egl_surface *dri2_surf = loaderPrivate; + struct dri2_egl_display *dri2_dpy = + dri2_egl_display(dri2_surf->base.Resource.Display); + xcb_dri2_dri2_buffer_t *buffers; + xcb_dri2_get_buffers_reply_t *reply; + xcb_dri2_get_buffers_cookie_t cookie; + + cookie = xcb_dri2_get_buffers_unchecked (dri2_dpy->conn, + dri2_surf->drawable, + count, count, attachments); + reply = xcb_dri2_get_buffers_reply (dri2_dpy->conn, cookie, NULL); + buffers = xcb_dri2_get_buffers_buffers (reply); + if (buffers == NULL) + return NULL; + + *out_count = reply->count; + dri2_surf->base.Width = *width = reply->width; + dri2_surf->base.Height = *height = reply->height; + dri2_process_buffers(dri2_surf, buffers, *out_count); + + free(reply); + + return dri2_surf->buffers; +} + +static void +dri2_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate) +{ + /* FIXME: Does EGL support front buffer rendering at all? */ + +#if 0 + struct dri2_egl_surface *dri2_surf = loaderPrivate; + + dri2WaitGL(dri2_surf); +#endif +} + +static __DRIbuffer * +dri2_get_buffers_with_format(__DRIdrawable * driDrawable, + int *width, int *height, + unsigned int *attachments, int count, + int *out_count, void *loaderPrivate) +{ + struct dri2_egl_surface *dri2_surf = loaderPrivate; + struct dri2_egl_display *dri2_dpy = + dri2_egl_display(dri2_surf->base.Resource.Display); + xcb_dri2_dri2_buffer_t *buffers; + xcb_dri2_get_buffers_with_format_reply_t *reply; + xcb_dri2_get_buffers_with_format_cookie_t cookie; + xcb_dri2_attach_format_t *format_attachments; + + format_attachments = (xcb_dri2_attach_format_t *) attachments; + cookie = xcb_dri2_get_buffers_with_format_unchecked (dri2_dpy->conn, + dri2_surf->drawable, + count, count, + format_attachments); + + reply = xcb_dri2_get_buffers_with_format_reply (dri2_dpy->conn, + cookie, NULL); + if (reply == NULL) + return NULL; + + buffers = xcb_dri2_get_buffers_with_format_buffers (reply); + dri2_surf->base.Width = *width = reply->width; + dri2_surf->base.Height = *height = reply->height; + *out_count = reply->count; + dri2_process_buffers(dri2_surf, buffers, *out_count); + + free(reply); + + return dri2_surf->buffers; +} + +#ifdef GLX_USE_TLS +static const char dri_driver_format[] = "%.*s/tls/%.*s_dri.so"; +#else +static const char dri_driver_format[] = "%.*s/%.*s_dri.so"; +#endif + +static const char dri_driver_path[] = DEFAULT_DRIVER_DIR; + +/** + * Called via eglInitialize(), GLX_drv->API.Initialize(). + */ +static EGLBoolean +dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp, + EGLint *major, EGLint *minor) +{ + const __DRIextension **extensions; + const __DRIconfig **driver_configs; + struct dri2_egl_display *dri2_dpy; + char path[PATH_MAX], *search_paths, *p, *next, *end; + xcb_xfixes_query_version_reply_t *xfixes_query; + xcb_xfixes_query_version_cookie_t xfixes_query_cookie; + xcb_dri2_query_version_reply_t *dri2_query; + xcb_dri2_query_version_cookie_t dri2_query_cookie; + xcb_dri2_connect_reply_t *connect = NULL; + xcb_dri2_connect_cookie_t connect_cookie; + xcb_dri2_authenticate_reply_t *authenticate; + xcb_dri2_authenticate_cookie_t authenticate_cookie; + xcb_generic_error_t *error; + drm_magic_t magic; + xcb_screen_iterator_t s; + int i; + + dri2_dpy = malloc(sizeof *dri2_dpy); + if (!dri2_dpy) + return _eglError(EGL_BAD_ALLOC, "eglInitialize"); + + disp->DriverData = (void *) dri2_dpy; + dri2_dpy->conn = XGetXCBConnection(disp->NativeDisplay); + if (!dri2_dpy->conn) { + dri2_dpy->conn = xcb_connect(0, 0); + if (!dri2_dpy->conn) { + _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed"); + free(dri2_dpy); + return EGL_FALSE; + } + } + + xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_xfixes_id); + xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_dri2_id); + + xfixes_query_cookie = xcb_xfixes_query_version(dri2_dpy->conn, + XCB_XFIXES_MAJOR_VERSION, + XCB_XFIXES_MINOR_VERSION); + + dri2_query_cookie = xcb_dri2_query_version (dri2_dpy->conn, + XCB_DRI2_MAJOR_VERSION, + 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); + + xfixes_query = + xcb_xfixes_query_version_reply (dri2_dpy->conn, + xfixes_query_cookie, &error); + if (xfixes_query == NULL || + error != NULL || xfixes_query->major_version < 2) { + _eglLog(_EGL_FATAL, "DRI2: failed to query xfixes version"); + free(error); + goto handle_error; + } + free(xfixes_query); + + dri2_query = + xcb_dri2_query_version_reply (dri2_dpy->conn, dri2_query_cookie, &error); + if (dri2_query == NULL || error != NULL) { + _eglLog(_EGL_FATAL, "DRI2: failed to query version"); + free(error); + goto handle_error; + } + dri2_dpy->dri2_major = dri2_query->major_version; + dri2_dpy->dri2_minor = dri2_query->minor_version; + free(dri2_query); + + connect = xcb_dri2_connect_reply (dri2_dpy->conn, connect_cookie, NULL); + if (connect->driver_name_length == 0 && connect->device_name_length == 0) { + _eglLog(_EGL_FATAL, "DRI2: failed to authenticate"); + goto handle_error; + } + + search_paths = NULL; + if (geteuid() == getuid()) { + /* don't allow setuid apps to use LIBGL_DRIVERS_PATH */ + search_paths = getenv("LIBGL_DRIVERS_PATH"); + } + if (search_paths == NULL) + search_paths = DEFAULT_DRIVER_DIR; + + dri2_dpy->driver = NULL; + end = search_paths + strlen(search_paths); + for (p = search_paths; p < end && dri2_dpy->driver == NULL; p = next + 1) { + next = strchr(p, ':'); + if (next == NULL) + next = end; + + snprintf(path, sizeof path, + dri_driver_format, + next - p, p, + xcb_dri2_connect_driver_name_length (connect), + xcb_dri2_connect_driver_name (connect)); + + dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); + } + + if (dri2_dpy->driver == NULL) { + _eglLog(_EGL_FATAL, + "DRI2: failed to open any driver (search paths %s)", + search_paths); + goto handle_error; + } + + _eglLog(_EGL_DEBUG, "DRI2: dlopen(%s)", path); + extensions = dlsym(dri2_dpy->driver, __DRI_DRIVER_EXTENSIONS); + if (extensions == NULL) { + _eglLog(_EGL_FATAL, + "DRI2: driver exports no extensions (%s)", dlerror()); + goto handle_error; + } + + for (i = 0; extensions[i]; i++) { + if (strcmp(extensions[i]->name, __DRI_CORE) == 0) + dri2_dpy->core = (__DRIcoreExtension *) extensions[i]; + if (strcmp(extensions[i]->name, __DRI_DRI2) == 0) + dri2_dpy->dri2 = (__DRIdri2Extension *) extensions[i]; + } + + if (dri2_dpy->core == NULL) { + _eglLog(_EGL_FATAL, "DRI2: driver has no core extension"); + goto handle_error; + } + + if (dri2_dpy->dri2 == NULL) { + _eglLog(_EGL_FATAL, "DRI2: driver has no dri2 extension"); + goto handle_error; + } + + snprintf(path, sizeof path, "%.*s", + xcb_dri2_connect_device_name_length (connect), + xcb_dri2_connect_device_name (connect)); + dri2_dpy->fd = open (path, O_RDWR); + if (dri2_dpy->fd == -1) { + _eglLog(_EGL_FATAL, + "DRI2: could not open %s (%s)", path, strerror(errno)); + goto handle_error; + } + + if (drmGetMagic(dri2_dpy->fd, &magic)) { + _eglLog(_EGL_FATAL, "DRI2: failed to get drm magic"); + goto handle_error; + } + + authenticate_cookie = xcb_dri2_authenticate_unchecked (dri2_dpy->conn, + s.data->root, magic); + authenticate = xcb_dri2_authenticate_reply (dri2_dpy->conn, + authenticate_cookie, NULL); + if (authenticate == NULL || !authenticate->authenticated) { + _eglLog(_EGL_FATAL, "DRI2: failed to authenticate"); + goto handle_error; + } + + if (dri2_dpy->dri2_minor >= 1) { + dri2_dpy->loader_extension.base.name = __DRI_DRI2_LOADER; + dri2_dpy->loader_extension.base.version = 3; + dri2_dpy->loader_extension.getBuffers = dri2_get_buffers; + dri2_dpy->loader_extension.flushFrontBuffer = dri2_flush_front_buffer; + dri2_dpy->loader_extension.getBuffersWithFormat = + dri2_get_buffers_with_format; + } else { + dri2_dpy->loader_extension.base.name = __DRI_DRI2_LOADER; + dri2_dpy->loader_extension.base.version = 2; + dri2_dpy->loader_extension.getBuffers = dri2_get_buffers; + dri2_dpy->loader_extension.flushFrontBuffer = dri2_flush_front_buffer; + dri2_dpy->loader_extension.getBuffersWithFormat = NULL; + } + + dri2_dpy->extensions[0] = &dri2_dpy->loader_extension.base; + dri2_dpy->extensions[1] = NULL; + + dri2_dpy->dri_screen = + dri2_dpy->dri2->createNewScreen(0, dri2_dpy->fd, dri2_dpy->extensions, + &driver_configs, dri2_dpy); + + if (dri2_dpy->dri_screen == NULL) { + _eglLog(_EGL_FATAL, "DRI2: failed to create dri screen"); + free(dri2_dpy); + goto handle_error; + } + + extensions = dri2_dpy->core->getExtensions(dri2_dpy->dri_screen); + for (i = 0; extensions[i]; i++) { + if ((strcmp(extensions[i]->name, __DRI2_FLUSH) == 0)) + dri2_dpy->flush = (__DRI2flushExtension *) extensions[i]; + } + + if (dri2_dpy->flush == NULL) { + _eglLog(_EGL_FATAL, "DRI2: driver doesn't support the flush extension"); + free(dri2_dpy); + goto handle_error; + } + + for (i = 0; driver_configs[i]; i++) + dri2_add_config(disp, driver_configs[i], i + 1); + if (!disp->NumConfigs) { + _eglLog(_EGL_WARNING, "DRI2: failed to create any config"); + goto handle_error; + } + + disp->ClientAPIsMask = EGL_OPENGL_BIT; + + /* we're supporting EGL 1.4 */ + *major = 1; + *minor = 4; + + free (connect); + return EGL_TRUE; + + handle_error: + free(connect); + free(dri2_dpy); + return EGL_FALSE; +} + +/** + * Called via eglTerminate(), drv->API.Terminate(). + */ +static EGLBoolean +dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + + _eglReleaseDisplayResources(drv, disp); + _eglCleanupDisplay(disp); + + close(dri2_dpy->fd); + dlclose(dri2_dpy->driver); + free(dri2_dpy); + + disp->DriverData = NULL; + + return EGL_TRUE; +} + + +/** + * Called via eglCreateContext(), drv->API.CreateContext(). + */ +static _EGLContext * +dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, + _EGLContext *share_list, const EGLint *attrib_list) +{ + struct dri2_egl_context *dri2_ctx; + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct dri2_egl_context *dri2_ctx_shared = dri2_egl_context(share_list); + struct dri2_egl_config *dri2_config = dri2_egl_config(conf); + + dri2_ctx = malloc(sizeof *dri2_ctx); + if (!dri2_ctx) { + _eglError(EGL_BAD_ALLOC, "eglCreateContext"); + return NULL; + } + + if (!_eglInitContext(&dri2_ctx->base, disp, conf, attrib_list)) { + free(dri2_ctx); + return NULL; + } + + dri2_ctx->dri_context = + dri2_dpy->dri2->createNewContext(dri2_dpy->dri_screen, + dri2_config->dri_config, + dri2_ctx_shared ? + dri2_ctx_shared->dri_context : NULL, + dri2_ctx); + + if (!dri2_ctx->dri_context) { + free(dri2_ctx); + return NULL; + } + + return &dri2_ctx->base; +} + +static EGLBoolean +dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); + + if (_eglIsSurfaceBound(surf)) + return EGL_TRUE; + + (*dri2_dpy->core->destroyDrawable)(dri2_surf->dri_drawable); + + xcb_dri2_destroy_drawable (dri2_dpy->conn, dri2_surf->drawable); + + if (surf->Type == EGL_PBUFFER_BIT) + xcb_free_pixmap (dri2_dpy->conn, dri2_surf->drawable); + + free(surf); + + return EGL_TRUE; +} + +/** + * Called via eglMakeCurrent(), drv->API.MakeCurrent(). + */ +static EGLBoolean +dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf, + _EGLSurface *rsurf, _EGLContext *ctx) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct dri2_egl_surface *dri2_dsurf = dri2_egl_surface(dsurf); + struct dri2_egl_surface *dri2_rsurf = dri2_egl_surface(rsurf); + struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); + __DRIdrawable *ddraw, *rdraw; + __DRIcontext *cctx; + + /* bind the new context and return the "orphaned" one */ + if (!_eglBindContext(&ctx, &dsurf, &rsurf)) + return EGL_FALSE; + + ddraw = (dri2_dsurf) ? dri2_dsurf->dri_drawable : NULL; + rdraw = (dri2_rsurf) ? dri2_rsurf->dri_drawable : NULL; + cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL; + + if ((cctx == NULL && ddraw == NULL && rdraw == NULL) || + dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) { + if (dsurf) + dri2_destroy_surface(drv, disp, dsurf); + if (rsurf && rsurf != dsurf) + dri2_destroy_surface(drv, disp, rsurf); + if (ctx != NULL) + dri2_dpy->core->unbindContext(dri2_egl_context(ctx)->dri_context); + + return EGL_TRUE; + } else { + _eglBindContext(&ctx, &dsurf, &rsurf); + + return EGL_FALSE; + } +} + +/** + * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). + */ +static _EGLSurface * +dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, + _EGLConfig *conf, EGLNativeWindowType window, + const EGLint *attrib_list) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct dri2_egl_config *dri2_conf = dri2_egl_config(conf); + struct dri2_egl_surface *dri2_surf; + xcb_get_geometry_cookie_t cookie; + xcb_get_geometry_reply_t *reply; + xcb_screen_iterator_t s; + xcb_generic_error_t *error; + + dri2_surf = malloc(sizeof *dri2_surf); + if (!dri2_surf) { + _eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface"); + return NULL; + } + + if (!_eglInitSurface(&dri2_surf->base, disp, type, conf, attrib_list)) { + free(dri2_surf); + return NULL; + } + + dri2_surf->region = XCB_NONE; + if (type == EGL_PBUFFER_BIT) { + 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, + _eglGetConfigKey(conf, EGL_BUFFER_SIZE), + dri2_surf->drawable, s.data->root, + dri2_surf->base.Width, dri2_surf->base.Height); + } else { + dri2_surf->drawable = window; + } + + dri2_surf->dri_drawable = + (*dri2_dpy->dri2->createNewDrawable) (dri2_dpy->dri_screen, + dri2_conf->dri_config, dri2_surf); + if (dri2_surf == NULL) { + _eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface"); + free(dri2_surf); + return NULL; + } + + xcb_dri2_create_drawable (dri2_dpy->conn, dri2_surf->drawable); + + cookie = xcb_get_geometry (dri2_dpy->conn, dri2_surf->drawable); + reply = xcb_get_geometry_reply (dri2_dpy->conn, cookie, &error); + if (reply == NULL || error != NULL) { + _eglError(EGL_BAD_ALLOC, "xcb_get_geometry"); + free(dri2_surf); + free(error); + return NULL; + } + dri2_surf->base.Width = reply->width; + dri2_surf->base.Height = reply->height; + free(reply); + + return &dri2_surf->base; +} + +/** + * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). + */ +static _EGLSurface * +dri2_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, + _EGLConfig *conf, EGLNativeWindowType window, + const EGLint *attrib_list) +{ + return dri2_create_surface(drv, disp, EGL_WINDOW_BIT, conf, + window, attrib_list); +} + +static _EGLSurface * +dri2_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, + _EGLConfig *conf, EGLNativePixmapType pixmap, + const EGLint *attrib_list) +{ + return dri2_create_surface(drv, disp, EGL_PIXMAP_BIT, conf, + pixmap, attrib_list); +} + +static _EGLSurface * +dri2_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp, + _EGLConfig *conf, const EGLint *attrib_list) +{ + return dri2_create_surface(drv, disp, EGL_PBUFFER_BIT, conf, + XCB_WINDOW_NONE, attrib_list); +} + +static EGLBoolean +dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); + xcb_dri2_copy_region_cookie_t cookie; + + if (dri2_dpy->flush) + (*dri2_dpy->flush->flush)(dri2_surf->dri_drawable); + +#if 0 + /* FIXME: Add support for dri swapbuffers, that'll give us swap + * interval and page flipping (at least for fullscreen windows) as + * well as the page flip event. */ +#if __DRI2_FLUSH_VERSION >= 2 + if (pdraw->psc->f) + (*pdraw->psc->f->flushInvalidate)(pdraw->driDrawable); +#endif +#endif + + if (!dri2_surf->have_back) + return EGL_TRUE; + + cookie = xcb_dri2_copy_region_unchecked(dri2_dpy->conn, + dri2_surf->drawable, + dri2_surf->region, + XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT, + XCB_DRI2_ATTACHMENT_BUFFER_BACK_LEFT); + free(xcb_dri2_copy_region_reply(dri2_dpy->conn, cookie, NULL)); + + return EGL_TRUE; +} + +/* + * Called from eglGetProcAddress() via drv->API.GetProcAddress(). + */ +static _EGLProc +dri2_get_proc_address(_EGLDriver *drv, const char *procname) +{ + /* FIXME: Do we need to support lookup of EGL symbols too? */ + + return (_EGLProc) _glapi_get_proc_address(procname); +} + +static EGLBoolean +dri2_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) +{ + /* glXWaitGL(); */ + + return EGL_TRUE; +} + +static EGLBoolean +dri2_wait_native(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine) +{ + if (engine != EGL_CORE_NATIVE_ENGINE) + return _eglError(EGL_BAD_PARAMETER, "eglWaitNative"); + /* glXWaitX(); */ + + return EGL_TRUE; +} + +static void +dri2_unload(_EGLDriver *drv) +{ + struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv); + free(dri2_drv); +} + +/** + * This is the main entrypoint into the driver, called by libEGL. + * Create a new _EGLDriver object and init its dispatch table. + */ +_EGLDriver * +_eglMain(const char *args) +{ + struct dri2_egl_driver *dri2_drv; + + dri2_drv = malloc(sizeof *dri2_drv); + if (!dri2_drv) + return NULL; + + _eglInitDriverFallbacks(&dri2_drv->base); + dri2_drv->base.API.Initialize = dri2_initialize; + dri2_drv->base.API.Terminate = dri2_terminate; + dri2_drv->base.API.CreateContext = dri2_create_context; + dri2_drv->base.API.MakeCurrent = dri2_make_current; + dri2_drv->base.API.CreateWindowSurface = dri2_create_window_surface; + dri2_drv->base.API.CreatePixmapSurface = dri2_create_pixmap_surface; + dri2_drv->base.API.CreatePbufferSurface = dri2_create_pbuffer_surface; + dri2_drv->base.API.DestroySurface = dri2_destroy_surface; + dri2_drv->base.API.SwapBuffers = dri2_swap_buffers; + dri2_drv->base.API.GetProcAddress = dri2_get_proc_address; + dri2_drv->base.API.WaitClient = dri2_wait_client; + dri2_drv->base.API.WaitNative = dri2_wait_native; + + dri2_drv->base.Name = "DRI2"; + dri2_drv->base.Unload = dri2_unload; + + return &dri2_drv->base; +} -- cgit v1.2.3 From 5b6b67eb3ff714fbba8aed88a22a7646e1dbf655 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Thu, 4 Feb 2010 22:15:22 +0100 Subject: Nuke the nv0x-nv2x gallium pipe drivers. --- configure.ac | 2 +- src/gallium/docs/source/distro.rst | 15 - src/gallium/drivers/nouveau/Makefile | 3 +- src/gallium/drivers/nouveau/nouveau_winsys.h | 18 - src/gallium/drivers/nouveau/nv04_surface_2d.c | 547 ++++++++++++++ src/gallium/drivers/nouveau/nv04_surface_2d.h | 37 + src/gallium/drivers/nv04/Makefile | 21 - src/gallium/drivers/nv04/nv04_clear.c | 12 - src/gallium/drivers/nv04/nv04_context.c | 112 --- src/gallium/drivers/nv04/nv04_context.h | 151 ---- src/gallium/drivers/nv04/nv04_fragprog.c | 21 - src/gallium/drivers/nv04/nv04_fragtex.c | 73 -- src/gallium/drivers/nv04/nv04_miptree.c | 146 ---- src/gallium/drivers/nv04/nv04_prim_vbuf.c | 339 --------- src/gallium/drivers/nv04/nv04_screen.c | 222 ------ src/gallium/drivers/nv04/nv04_screen.h | 30 - src/gallium/drivers/nv04/nv04_state.c | 459 ----------- src/gallium/drivers/nv04/nv04_state.h | 72 -- src/gallium/drivers/nv04/nv04_state_emit.c | 246 ------ src/gallium/drivers/nv04/nv04_surface.c | 63 -- src/gallium/drivers/nv04/nv04_surface_2d.c | 547 -------------- src/gallium/drivers/nv04/nv04_surface_2d.h | 37 - src/gallium/drivers/nv04/nv04_transfer.c | 178 ----- src/gallium/drivers/nv04/nv04_vbo.c | 78 -- src/gallium/drivers/nv10/Makefile | 20 - src/gallium/drivers/nv10/nv10_clear.c | 14 - src/gallium/drivers/nv10/nv10_context.c | 298 -------- src/gallium/drivers/nv10/nv10_context.h | 153 ---- src/gallium/drivers/nv10/nv10_fragprog.c | 21 - src/gallium/drivers/nv10/nv10_fragtex.c | 130 ---- src/gallium/drivers/nv10/nv10_miptree.c | 165 ---- src/gallium/drivers/nv10/nv10_prim_vbuf.c | 267 ------- src/gallium/drivers/nv10/nv10_screen.c | 208 ----- src/gallium/drivers/nv10/nv10_screen.h | 28 - src/gallium/drivers/nv10/nv10_state.c | 590 --------------- src/gallium/drivers/nv10/nv10_state.h | 140 ---- src/gallium/drivers/nv10/nv10_state_emit.c | 333 -------- src/gallium/drivers/nv10/nv10_surface.c | 63 -- src/gallium/drivers/nv10/nv10_transfer.c | 178 ----- src/gallium/drivers/nv10/nv10_vbo.c | 78 -- src/gallium/drivers/nv20/Makefile | 21 - src/gallium/drivers/nv20/nv20_clear.c | 14 - src/gallium/drivers/nv20/nv20_context.c | 424 ----------- src/gallium/drivers/nv20/nv20_context.h | 152 ---- src/gallium/drivers/nv20/nv20_fragprog.c | 21 - src/gallium/drivers/nv20/nv20_fragtex.c | 130 ---- src/gallium/drivers/nv20/nv20_miptree.c | 226 ------ src/gallium/drivers/nv20/nv20_prim_vbuf.c | 440 ----------- src/gallium/drivers/nv20/nv20_screen.c | 204 ----- src/gallium/drivers/nv20/nv20_screen.h | 28 - src/gallium/drivers/nv20/nv20_state.c | 583 -------------- src/gallium/drivers/nv20/nv20_state.h | 140 ---- src/gallium/drivers/nv20/nv20_state_emit.c | 426 ----------- src/gallium/drivers/nv20/nv20_surface.c | 63 -- src/gallium/drivers/nv20/nv20_transfer.c | 178 ----- src/gallium/drivers/nv20/nv20_vbo.c | 79 -- src/gallium/drivers/nv20/nv20_vertprog.c | 841 --------------------- src/gallium/drivers/nv30/nv30_miptree.c | 2 +- src/gallium/drivers/nv30/nv30_screen.h | 2 +- src/gallium/drivers/nv40/nv40_miptree.c | 2 +- src/gallium/drivers/nv40/nv40_screen.h | 2 +- src/gallium/winsys/drm/nouveau/dri/Makefile | 3 - .../winsys/drm/nouveau/drm/nouveau_drm_api.c | 18 - src/gallium/winsys/drm/nouveau/egl/Makefile | 3 - src/gallium/winsys/drm/nouveau/xorg/Makefile | 3 - src/gallium/winsys/g3dvl/nouveau/Makefile | 5 +- 66 files changed, 592 insertions(+), 9533 deletions(-) create mode 100644 src/gallium/drivers/nouveau/nv04_surface_2d.c create mode 100644 src/gallium/drivers/nouveau/nv04_surface_2d.h delete mode 100644 src/gallium/drivers/nv04/Makefile delete mode 100644 src/gallium/drivers/nv04/nv04_clear.c delete mode 100644 src/gallium/drivers/nv04/nv04_context.c delete mode 100644 src/gallium/drivers/nv04/nv04_context.h delete mode 100644 src/gallium/drivers/nv04/nv04_fragprog.c delete mode 100644 src/gallium/drivers/nv04/nv04_fragtex.c delete mode 100644 src/gallium/drivers/nv04/nv04_miptree.c delete mode 100644 src/gallium/drivers/nv04/nv04_prim_vbuf.c delete mode 100644 src/gallium/drivers/nv04/nv04_screen.c delete mode 100644 src/gallium/drivers/nv04/nv04_screen.h delete mode 100644 src/gallium/drivers/nv04/nv04_state.c delete mode 100644 src/gallium/drivers/nv04/nv04_state.h delete mode 100644 src/gallium/drivers/nv04/nv04_state_emit.c delete mode 100644 src/gallium/drivers/nv04/nv04_surface.c delete mode 100644 src/gallium/drivers/nv04/nv04_surface_2d.c delete mode 100644 src/gallium/drivers/nv04/nv04_surface_2d.h delete mode 100644 src/gallium/drivers/nv04/nv04_transfer.c delete mode 100644 src/gallium/drivers/nv04/nv04_vbo.c delete mode 100644 src/gallium/drivers/nv10/Makefile delete mode 100644 src/gallium/drivers/nv10/nv10_clear.c delete mode 100644 src/gallium/drivers/nv10/nv10_context.c delete mode 100644 src/gallium/drivers/nv10/nv10_context.h delete mode 100644 src/gallium/drivers/nv10/nv10_fragprog.c delete mode 100644 src/gallium/drivers/nv10/nv10_fragtex.c delete mode 100644 src/gallium/drivers/nv10/nv10_miptree.c delete mode 100644 src/gallium/drivers/nv10/nv10_prim_vbuf.c delete mode 100644 src/gallium/drivers/nv10/nv10_screen.c delete mode 100644 src/gallium/drivers/nv10/nv10_screen.h delete mode 100644 src/gallium/drivers/nv10/nv10_state.c delete mode 100644 src/gallium/drivers/nv10/nv10_state.h delete mode 100644 src/gallium/drivers/nv10/nv10_state_emit.c delete mode 100644 src/gallium/drivers/nv10/nv10_surface.c delete mode 100644 src/gallium/drivers/nv10/nv10_transfer.c delete mode 100644 src/gallium/drivers/nv10/nv10_vbo.c delete mode 100644 src/gallium/drivers/nv20/Makefile delete mode 100644 src/gallium/drivers/nv20/nv20_clear.c delete mode 100644 src/gallium/drivers/nv20/nv20_context.c delete mode 100644 src/gallium/drivers/nv20/nv20_context.h delete mode 100644 src/gallium/drivers/nv20/nv20_fragprog.c delete mode 100644 src/gallium/drivers/nv20/nv20_fragtex.c delete mode 100644 src/gallium/drivers/nv20/nv20_miptree.c delete mode 100644 src/gallium/drivers/nv20/nv20_prim_vbuf.c delete mode 100644 src/gallium/drivers/nv20/nv20_screen.c delete mode 100644 src/gallium/drivers/nv20/nv20_screen.h delete mode 100644 src/gallium/drivers/nv20/nv20_state.c delete mode 100644 src/gallium/drivers/nv20/nv20_state.h delete mode 100644 src/gallium/drivers/nv20/nv20_state_emit.c delete mode 100644 src/gallium/drivers/nv20/nv20_surface.c delete mode 100644 src/gallium/drivers/nv20/nv20_transfer.c delete mode 100644 src/gallium/drivers/nv20/nv20_vbo.c delete mode 100644 src/gallium/drivers/nv20/nv20_vertprog.c (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 16d315e13ad..50feac4af33 100644 --- a/configure.ac +++ b/configure.ac @@ -1319,7 +1319,7 @@ AC_ARG_ENABLE([gallium-nouveau], [enable_gallium_nouveau=no]) if test "x$enable_gallium_nouveau" = xyes; then GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS nouveau" - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nv04 nv10 nv20 nv30 nv40 nv50" + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nv30 nv40 nv50" fi dnl diff --git a/src/gallium/docs/source/distro.rst b/src/gallium/docs/source/distro.rst index 0fabb639ad3..100afe33972 100644 --- a/src/gallium/docs/source/distro.rst +++ b/src/gallium/docs/source/distro.rst @@ -31,21 +31,6 @@ Wrapper driver. LLVM Softpipe ^^^^^^^^^^^^^ -nVidia nv04 -^^^^^^^^^^^ - -Deprecated. - -nVidia nv10 -^^^^^^^^^^^ - -Deprecated. - -nVidia nv20 -^^^^^^^^^^^ - -Deprecated. - nVidia nv30 ^^^^^^^^^^^ diff --git a/src/gallium/drivers/nouveau/Makefile b/src/gallium/drivers/nouveau/Makefile index 0cb66041d50..0e02680bc63 100644 --- a/src/gallium/drivers/nouveau/Makefile +++ b/src/gallium/drivers/nouveau/Makefile @@ -4,6 +4,7 @@ include $(TOP)/configs/current LIBNAME = nouveau C_SOURCES = nouveau_screen.c \ - nouveau_context.c + nouveau_context.c \ + nv04_surface_2d.c include ../../Makefile.template diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h index d81c5be51f2..4c5d2f8b1c1 100644 --- a/src/gallium/drivers/nouveau/nouveau_winsys.h +++ b/src/gallium/drivers/nouveau/nouveau_winsys.h @@ -26,24 +26,6 @@ /* use along with GPU_WRITE for 2D-only writes */ #define NOUVEAU_BUFFER_USAGE_NO_RENDER (1 << 19) -extern struct pipe_screen * -nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *); - -extern struct pipe_context * -nv04_create(struct pipe_screen *, unsigned pctx_id); - -extern struct pipe_screen * -nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *); - -extern struct pipe_context * -nv10_create(struct pipe_screen *, unsigned pctx_id); - -extern struct pipe_screen * -nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *); - -extern struct pipe_context * -nv20_create(struct pipe_screen *, unsigned pctx_id); - extern struct pipe_screen * nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *); diff --git a/src/gallium/drivers/nouveau/nv04_surface_2d.c b/src/gallium/drivers/nouveau/nv04_surface_2d.c new file mode 100644 index 00000000000..42c2ca932d8 --- /dev/null +++ b/src/gallium/drivers/nouveau/nv04_surface_2d.c @@ -0,0 +1,547 @@ +#include "pipe/p_context.h" +#include "pipe/p_format.h" +#include "util/u_format.h" +#include "util/u_math.h" +#include "util/u_memory.h" + +#include "nouveau/nouveau_winsys.h" +#include "nouveau/nouveau_util.h" +#include "nouveau/nouveau_screen.h" +#include "nv04_surface_2d.h" + +static INLINE int +nv04_surface_format(enum pipe_format format) +{ + switch (format) { + case PIPE_FORMAT_A8_UNORM: + case PIPE_FORMAT_L8_UNORM: + case PIPE_FORMAT_I8_UNORM: + return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8; + case PIPE_FORMAT_R16_SNORM: + case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_Z16_UNORM: + case PIPE_FORMAT_A8L8_UNORM: + return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5; + case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: + return NV04_CONTEXT_SURFACES_2D_FORMAT_A8R8G8B8; + case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32; + default: + return -1; + } +} + +static INLINE int +nv04_rect_format(enum pipe_format format) +{ + switch (format) { + case PIPE_FORMAT_A8_UNORM: + return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8; + case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_Z16_UNORM: + return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5; + case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8; + default: + return -1; + } +} + +static INLINE int +nv04_scaled_image_format(enum pipe_format format) +{ + switch (format) { + case PIPE_FORMAT_A8_UNORM: + case PIPE_FORMAT_L8_UNORM: + case PIPE_FORMAT_I8_UNORM: + return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_Y8; + case PIPE_FORMAT_A1R5G5B5_UNORM: + return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A1R5G5B5; + case PIPE_FORMAT_A8R8G8B8_UNORM: + return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A8R8G8B8; + case PIPE_FORMAT_X8R8G8B8_UNORM: + return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_X8R8G8B8; + case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_R16_SNORM: + case PIPE_FORMAT_A8L8_UNORM: + return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_R5G6B5; + default: + return -1; + } +} + +static INLINE unsigned +nv04_swizzle_bits_square(unsigned x, unsigned y) +{ + unsigned u = (x & 0x001) << 0 | + (x & 0x002) << 1 | + (x & 0x004) << 2 | + (x & 0x008) << 3 | + (x & 0x010) << 4 | + (x & 0x020) << 5 | + (x & 0x040) << 6 | + (x & 0x080) << 7 | + (x & 0x100) << 8 | + (x & 0x200) << 9 | + (x & 0x400) << 10 | + (x & 0x800) << 11; + + unsigned v = (y & 0x001) << 1 | + (y & 0x002) << 2 | + (y & 0x004) << 3 | + (y & 0x008) << 4 | + (y & 0x010) << 5 | + (y & 0x020) << 6 | + (y & 0x040) << 7 | + (y & 0x080) << 8 | + (y & 0x100) << 9 | + (y & 0x200) << 10 | + (y & 0x400) << 11 | + (y & 0x800) << 12; + return v | u; +} + +/* rectangular swizzled textures are linear concatenations of swizzled square tiles */ +static INLINE unsigned +nv04_swizzle_bits(unsigned x, unsigned y, unsigned w, unsigned h) +{ + unsigned s = MIN2(w, h); + unsigned m = s - 1; + return (((x | y) & ~m) * s) | nv04_swizzle_bits_square(x & m, y & m); +} + +static int +nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx, + struct pipe_surface *dst, int dx, int dy, + struct pipe_surface *src, int sx, int sy, + int w, int h) +{ + struct nouveau_channel *chan = ctx->swzsurf->channel; + struct nouveau_grobj *swzsurf = ctx->swzsurf; + struct nouveau_grobj *sifm = ctx->sifm; + struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); + struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); + const unsigned src_pitch = ((struct nv04_surface *)src)->pitch; + /* Max width & height may not be the same on all HW, but must be POT */ + const unsigned max_w = 1024; + const unsigned max_h = 1024; + unsigned sub_w = w > max_w ? max_w : w; + unsigned sub_h = h > max_h ? max_h : h; + unsigned x; + unsigned y; + + /* Swizzled surfaces must be POT */ + assert(util_is_pot(dst->width) && util_is_pot(dst->height)); + + /* If area is too large to copy in one shot we must copy it in POT chunks to meet alignment requirements */ + assert(sub_w == w || util_is_pot(sub_w)); + assert(sub_h == h || util_is_pot(sub_h)); + + MARK_RING (chan, 8 + ((w+sub_w)/sub_w)*((h+sub_h)/sub_h)*17, 2 + + ((w+sub_w)/sub_w)*((h+sub_h)/sub_h)*2); + + BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_DMA_IMAGE, 1); + OUT_RELOCo(chan, dst_bo, + NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + + BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_FORMAT, 1); + OUT_RING (chan, nv04_surface_format(dst->format) | + log2i(dst->width) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_U_SHIFT | + log2i(dst->height) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_V_SHIFT); + + BEGIN_RING(chan, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, 1); + OUT_RELOCo(chan, src_bo, + NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SURFACE, 1); + OUT_RING (chan, swzsurf->handle); + + for (y = 0; y < h; y += sub_h) { + sub_h = MIN2(sub_h, h - y); + + for (x = 0; x < w; x += sub_w) { + sub_w = MIN2(sub_w, w - x); + + assert(!(dst->offset & 63)); + + BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_OFFSET, 1); + OUT_RELOCl(chan, dst_bo, dst->offset, + NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + + BEGIN_RING(chan, sifm, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9); + OUT_RING (chan, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE); + OUT_RING (chan, nv04_scaled_image_format(src->format)); + OUT_RING (chan, NV03_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY); + OUT_RING (chan, (x + dx) | ((y + dy) << NV03_SCALED_IMAGE_FROM_MEMORY_CLIP_POINT_Y_SHIFT)); + OUT_RING (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_CLIP_SIZE_H_SHIFT | sub_w); + OUT_RING (chan, (x + dx) | ((y + dy) << NV03_SCALED_IMAGE_FROM_MEMORY_OUT_POINT_Y_SHIFT)); + OUT_RING (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_OUT_SIZE_H_SHIFT | sub_w); + OUT_RING (chan, 1 << 20); + OUT_RING (chan, 1 << 20); + + BEGIN_RING(chan, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_SIZE, 4); + OUT_RING (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_SIZE_H_SHIFT | sub_w); + OUT_RING (chan, src_pitch | + NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER | + NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE); + OUT_RELOCl(chan, src_bo, src->offset + (sy+y) * src_pitch + (sx+x) * util_format_get_blocksize(src->texture->format), + NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + OUT_RING (chan, 0); + } + } + + return 0; +} + +static int +nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx, + struct pipe_surface *dst, int dx, int dy, + struct pipe_surface *src, int sx, int sy, int w, int h) +{ + struct nouveau_channel *chan = ctx->m2mf->channel; + struct nouveau_grobj *m2mf = ctx->m2mf; + struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); + struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); + unsigned src_pitch = ((struct nv04_surface *)src)->pitch; + unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; + unsigned dst_offset = dst->offset + dy * dst_pitch + + dx * util_format_get_blocksize(dst->texture->format); + unsigned src_offset = src->offset + sy * src_pitch + + sx * util_format_get_blocksize(src->texture->format); + + MARK_RING (chan, 3 + ((h / 2047) + 1) * 9, 2 + ((h / 2047) + 1) * 2); + BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2); + OUT_RELOCo(chan, src_bo, + NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + OUT_RELOCo(chan, dst_bo, + NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + + while (h) { + int count = (h > 2047) ? 2047 : h; + + BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8); + OUT_RELOCl(chan, src_bo, src_offset, + NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD); + OUT_RELOCl(chan, dst_bo, dst_offset, + NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_WR); + OUT_RING (chan, src_pitch); + OUT_RING (chan, dst_pitch); + OUT_RING (chan, w * util_format_get_blocksize(src->texture->format)); + OUT_RING (chan, count); + OUT_RING (chan, 0x0101); + OUT_RING (chan, 0); + + h -= count; + src_offset += src_pitch * count; + dst_offset += dst_pitch * count; + } + + return 0; +} + +static int +nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst, + int dx, int dy, struct pipe_surface *src, int sx, int sy, + int w, int h) +{ + struct nouveau_channel *chan = ctx->surf2d->channel; + struct nouveau_grobj *surf2d = ctx->surf2d; + struct nouveau_grobj *blit = ctx->blit; + struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); + struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); + unsigned src_pitch = ((struct nv04_surface *)src)->pitch; + unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; + int format; + + format = nv04_surface_format(dst->format); + if (format < 0) + return 1; + + MARK_RING (chan, 12, 4); + BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2); + OUT_RELOCo(chan, src_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4); + OUT_RING (chan, format); + OUT_RING (chan, (dst_pitch << 16) | src_pitch); + OUT_RELOCl(chan, src_bo, src->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + + BEGIN_RING(chan, blit, 0x0300, 3); + OUT_RING (chan, (sy << 16) | sx); + OUT_RING (chan, (dy << 16) | dx); + OUT_RING (chan, ( h << 16) | w); + + return 0; +} + +static void +nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst, + int dx, int dy, struct pipe_surface *src, int sx, int sy, + int w, int h) +{ + unsigned src_pitch = ((struct nv04_surface *)src)->pitch; + unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; + int src_linear = src->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR; + int dst_linear = dst->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR; + + assert(src->format == dst->format); + + /* Setup transfer to swizzle the texture to vram if needed */ + if (src_linear && !dst_linear && w > 1 && h > 1) { + nv04_surface_copy_swizzle(ctx, dst, dx, dy, src, sx, sy, w, h); + return; + } + + /* NV_CONTEXT_SURFACES_2D has buffer alignment restrictions, fallback + * to NV_MEMORY_TO_MEMORY_FORMAT in this case. + */ + if ((src->offset & 63) || (dst->offset & 63) || + (src_pitch & 63) || (dst_pitch & 63)) { + nv04_surface_copy_m2mf(ctx, dst, dx, dy, src, sx, sy, w, h); + return; + } + + nv04_surface_copy_blit(ctx, dst, dx, dy, src, sx, sy, w, h); +} + +static void +nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst, + int dx, int dy, int w, int h, unsigned value) +{ + struct nouveau_channel *chan = ctx->surf2d->channel; + struct nouveau_grobj *surf2d = ctx->surf2d; + struct nouveau_grobj *rect = ctx->rect; + struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); + unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; + int cs2d_format, gdirect_format; + + cs2d_format = nv04_surface_format(dst->format); + assert(cs2d_format >= 0); + + gdirect_format = nv04_rect_format(dst->format); + assert(gdirect_format >= 0); + + MARK_RING (chan, 16, 4); + BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2); + OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4); + OUT_RING (chan, cs2d_format); + OUT_RING (chan, (dst_pitch << 16) | dst_pitch); + OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + + BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT, 1); + OUT_RING (chan, gdirect_format); + BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR1_A, 1); + OUT_RING (chan, value); + BEGIN_RING(chan, rect, + NV04_GDI_RECTANGLE_TEXT_UNCLIPPED_RECTANGLE_POINT(0), 2); + OUT_RING (chan, (dx << 16) | dy); + OUT_RING (chan, ( w << 16) | h); +} + +void +nv04_surface_2d_takedown(struct nv04_surface_2d **pctx) +{ + struct nv04_surface_2d *ctx; + + if (!pctx || !*pctx) + return; + ctx = *pctx; + *pctx = NULL; + + nouveau_notifier_free(&ctx->ntfy); + nouveau_grobj_free(&ctx->m2mf); + nouveau_grobj_free(&ctx->surf2d); + nouveau_grobj_free(&ctx->swzsurf); + nouveau_grobj_free(&ctx->rect); + nouveau_grobj_free(&ctx->blit); + nouveau_grobj_free(&ctx->sifm); + + FREE(ctx); +} + +struct nv04_surface_2d * +nv04_surface_2d_init(struct nouveau_screen *screen) +{ + struct nv04_surface_2d *ctx = CALLOC_STRUCT(nv04_surface_2d); + struct nouveau_channel *chan = screen->channel; + unsigned handle = 0x88000000, class; + int ret; + + if (!ctx) + return NULL; + + ret = nouveau_notifier_alloc(chan, handle++, 1, &ctx->ntfy); + if (ret) { + nv04_surface_2d_takedown(&ctx); + return NULL; + } + + ret = nouveau_grobj_alloc(chan, handle++, 0x0039, &ctx->m2mf); + if (ret) { + nv04_surface_2d_takedown(&ctx); + return NULL; + } + + BEGIN_RING(chan, ctx->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1); + OUT_RING (chan, ctx->ntfy->handle); + + if (chan->device->chipset < 0x10) + class = NV04_CONTEXT_SURFACES_2D; + else + class = NV10_CONTEXT_SURFACES_2D; + + ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->surf2d); + if (ret) { + nv04_surface_2d_takedown(&ctx); + return NULL; + } + + BEGIN_RING(chan, ctx->surf2d, + NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2); + OUT_RING (chan, chan->vram->handle); + OUT_RING (chan, chan->vram->handle); + + if (chan->device->chipset < 0x10) + class = NV04_IMAGE_BLIT; + else + class = NV12_IMAGE_BLIT; + + ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->blit); + if (ret) { + nv04_surface_2d_takedown(&ctx); + return NULL; + } + + BEGIN_RING(chan, ctx->blit, NV01_IMAGE_BLIT_DMA_NOTIFY, 1); + OUT_RING (chan, ctx->ntfy->handle); + BEGIN_RING(chan, ctx->blit, NV04_IMAGE_BLIT_SURFACE, 1); + OUT_RING (chan, ctx->surf2d->handle); + BEGIN_RING(chan, ctx->blit, NV01_IMAGE_BLIT_OPERATION, 1); + OUT_RING (chan, NV01_IMAGE_BLIT_OPERATION_SRCCOPY); + + ret = nouveau_grobj_alloc(chan, handle++, NV04_GDI_RECTANGLE_TEXT, + &ctx->rect); + if (ret) { + nv04_surface_2d_takedown(&ctx); + return NULL; + } + + BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_DMA_NOTIFY, 1); + OUT_RING (chan, ctx->ntfy->handle); + BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_SURFACE, 1); + OUT_RING (chan, ctx->surf2d->handle); + BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1); + OUT_RING (chan, NV04_GDI_RECTANGLE_TEXT_OPERATION_SRCCOPY); + BEGIN_RING(chan, ctx->rect, + NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT, 1); + OUT_RING (chan, NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_LE); + + switch (chan->device->chipset & 0xf0) { + case 0x00: + case 0x10: + class = NV04_SWIZZLED_SURFACE; + break; + case 0x20: + class = NV20_SWIZZLED_SURFACE; + break; + case 0x30: + class = NV30_SWIZZLED_SURFACE; + break; + case 0x40: + case 0x60: + class = NV40_SWIZZLED_SURFACE; + break; + default: + /* Famous last words: this really can't happen.. */ + assert(0); + break; + } + + ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->swzsurf); + if (ret) { + nv04_surface_2d_takedown(&ctx); + return NULL; + } + + switch (chan->device->chipset & 0xf0) { + case 0x10: + case 0x20: + class = NV10_SCALED_IMAGE_FROM_MEMORY; + break; + case 0x30: + class = NV30_SCALED_IMAGE_FROM_MEMORY; + break; + case 0x40: + case 0x60: + class = NV40_SCALED_IMAGE_FROM_MEMORY; + break; + default: + class = NV04_SCALED_IMAGE_FROM_MEMORY; + break; + } + + ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->sifm); + if (ret) { + nv04_surface_2d_takedown(&ctx); + return NULL; + } + + ctx->copy = nv04_surface_copy; + ctx->fill = nv04_surface_fill; + return ctx; +} + +struct nv04_surface* +nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns) +{ + int temp_flags; + + // printf("creating temp, flags is %i!\n", flags); + + if(ns->base.usage & PIPE_BUFFER_USAGE_DISCARD) + { + temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ; + ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_DISCARD; + } + else + { + temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE; + ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_GPU_READ; + } + + struct nv40_screen* screen = (struct nv40_screen*)pscreen; + ns->base.usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE; + + struct pipe_texture templ; + memset(&templ, 0, sizeof(templ)); + templ.format = ns->base.texture->format; + templ.target = PIPE_TEXTURE_2D; + templ.width0 = ns->base.width; + templ.height0 = ns->base.height; + templ.depth0 = 1; + templ.last_level = 0; + + // TODO: this is probably wrong and we should specifically handle multisampling somehow once it is implemented + templ.nr_samples = ns->base.texture->nr_samples; + + templ.tex_usage = ns->base.texture->tex_usage | PIPE_TEXTURE_USAGE_RENDER_TARGET; + + struct pipe_texture* temp_tex = pscreen->texture_create(pscreen, &templ); + struct nv04_surface* temp_ns = (struct nv04_surface*)pscreen->get_tex_surface(pscreen, temp_tex, 0, 0, 0, temp_flags); + temp_ns->backing = ns; + + if(ns->base.usage & PIPE_BUFFER_USAGE_GPU_READ) + eng2d->copy(eng2d, &temp_ns->backing->base, 0, 0, &ns->base, 0, 0, ns->base.width, ns->base.height); + + return temp_ns; +} + diff --git a/src/gallium/drivers/nouveau/nv04_surface_2d.h b/src/gallium/drivers/nouveau/nv04_surface_2d.h new file mode 100644 index 00000000000..ce696a11a39 --- /dev/null +++ b/src/gallium/drivers/nouveau/nv04_surface_2d.h @@ -0,0 +1,37 @@ +#ifndef __NV04_SURFACE_2D_H__ +#define __NV04_SURFACE_2D_H__ + +struct nv04_surface { + struct pipe_surface base; + unsigned pitch; + struct nv04_surface* backing; +}; + +struct nv04_surface_2d { + struct nouveau_notifier *ntfy; + struct nouveau_grobj *surf2d; + struct nouveau_grobj *swzsurf; + struct nouveau_grobj *m2mf; + struct nouveau_grobj *rect; + struct nouveau_grobj *blit; + struct nouveau_grobj *sifm; + + struct pipe_buffer *(*buf)(struct pipe_surface *); + + void (*copy)(struct nv04_surface_2d *, struct pipe_surface *dst, + int dx, int dy, struct pipe_surface *src, int sx, int sy, + int w, int h); + void (*fill)(struct nv04_surface_2d *, struct pipe_surface *dst, + int dx, int dy, int w, int h, unsigned value); +}; + +struct nv04_surface_2d * +nv04_surface_2d_init(struct nouveau_screen *screen); + +void +nv04_surface_2d_takedown(struct nv04_surface_2d **); + +struct nv04_surface* +nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns); + +#endif diff --git a/src/gallium/drivers/nv04/Makefile b/src/gallium/drivers/nv04/Makefile deleted file mode 100644 index 7c14bacb1de..00000000000 --- a/src/gallium/drivers/nv04/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -TOP = ../../../.. -include $(TOP)/configs/current - -LIBNAME = nv04 - -C_SOURCES = \ - nv04_surface_2d.c \ - nv04_clear.c \ - nv04_context.c \ - nv04_fragprog.c \ - nv04_fragtex.c \ - nv04_miptree.c \ - nv04_prim_vbuf.c \ - nv04_screen.c \ - nv04_state.c \ - nv04_state_emit.c \ - nv04_surface.c \ - nv04_transfer.c \ - nv04_vbo.c - -include ../../Makefile.template diff --git a/src/gallium/drivers/nv04/nv04_clear.c b/src/gallium/drivers/nv04/nv04_clear.c deleted file mode 100644 index 01cacd36fe1..00000000000 --- a/src/gallium/drivers/nv04/nv04_clear.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_state.h" - -#include "nv04_context.h" - -void -nv04_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue) -{ - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); -} diff --git a/src/gallium/drivers/nv04/nv04_context.c b/src/gallium/drivers/nv04/nv04_context.c deleted file mode 100644 index e91ffe0f5de..00000000000 --- a/src/gallium/drivers/nv04/nv04_context.c +++ /dev/null @@ -1,112 +0,0 @@ -#include "draw/draw_context.h" -#include "pipe/p_defines.h" -#include "util/u_simple_screen.h" - -#include "nv04_context.h" -#include "nv04_screen.h" - -static void -nv04_flush(struct pipe_context *pipe, unsigned flags, - struct pipe_fence_handle **fence) -{ - struct nv04_context *nv04 = nv04_context(pipe); - struct nv04_screen *screen = nv04->screen; - struct nouveau_channel *chan = screen->base.channel; - - draw_flush(nv04->draw); - - FIRE_RING(chan); - if (fence) - *fence = NULL; -} - -static void -nv04_destroy(struct pipe_context *pipe) -{ - struct nv04_context *nv04 = nv04_context(pipe); - - if (nv04->draw) - draw_destroy(nv04->draw); - - FREE(nv04); -} - -static boolean -nv04_init_hwctx(struct nv04_context *nv04) -{ - struct nv04_screen *screen = nv04->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *fahrenheit = screen->fahrenheit; - - // requires a valid handle -// BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_NOTIFY, 1); -// OUT_RING(0); - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_NOP, 1); - OUT_RING(chan, 0); - - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1); - OUT_RING(chan, 0x40182800); -// OUT_RING(1<<20/*no cull*/); - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_BLEND, 1); -// OUT_RING(0x24|(1<<6)|(1<<8)); - OUT_RING(chan, 0x120001a4); - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FORMAT, 1); - OUT_RING(chan, 0x332213a1); - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FILTER, 1); - OUT_RING(chan, 0x11001010); - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_COLORKEY, 1); - OUT_RING(chan, 0x0); -// BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_OFFSET, 1); -// OUT_RING(SCREEN_OFFSET); - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FOGCOLOR, 1); - OUT_RING(chan, 0xff000000); - - - - FIRE_RING (chan); - return TRUE; -} - -struct pipe_context * -nv04_create(struct pipe_screen *pscreen, unsigned pctx_id) -{ - struct nv04_screen *screen = nv04_screen(pscreen); - struct pipe_winsys *ws = pscreen->winsys; - struct nv04_context *nv04; - struct nouveau_winsys *nvws = screen->nvws; - - nv04 = CALLOC(1, sizeof(struct nv04_context)); - if (!nv04) - return NULL; - nv04->screen = screen; - nv04->pctx_id = pctx_id; - - nv04->nvws = nvws; - - nv04->pipe.winsys = ws; - nv04->pipe.screen = pscreen; - nv04->pipe.destroy = nv04_destroy; - nv04->pipe.draw_arrays = nv04_draw_arrays; - nv04->pipe.draw_elements = nv04_draw_elements; - nv04->pipe.clear = nv04_clear; - nv04->pipe.flush = nv04_flush; - - nv04->pipe.is_texture_referenced = nouveau_is_texture_referenced; - nv04->pipe.is_buffer_referenced = nouveau_is_buffer_referenced; - - nv04_init_surface_functions(nv04); - nv04_init_state_functions(nv04); - - nv04->draw = draw_create(); - assert(nv04->draw); - draw_wide_point_threshold(nv04->draw, 0.0); - draw_wide_line_threshold(nv04->draw, 0.0); - draw_enable_line_stipple(nv04->draw, FALSE); - draw_enable_point_sprites(nv04->draw, FALSE); - draw_set_rasterize_stage(nv04->draw, nv04_draw_vbuf_stage(nv04)); - - nv04_init_hwctx(nv04); - - return &nv04->pipe; -} - diff --git a/src/gallium/drivers/nv04/nv04_context.h b/src/gallium/drivers/nv04/nv04_context.h deleted file mode 100644 index 83acb591878..00000000000 --- a/src/gallium/drivers/nv04/nv04_context.h +++ /dev/null @@ -1,151 +0,0 @@ -#ifndef __NV04_CONTEXT_H__ -#define __NV04_CONTEXT_H__ - -#include - -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_state.h" -#include "pipe/p_compiler.h" - -#include "util/u_memory.h" -#include "util/u_math.h" -#include "util/u_inlines.h" - -#include "draw/draw_vertex.h" - -#include "nouveau/nouveau_winsys.h" -#include "nouveau/nouveau_gldefs.h" -#include "nouveau/nouveau_context.h" - -#include "nv04_state.h" - -#define NOUVEAU_ERR(fmt, args...) \ - fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args); -#define NOUVEAU_MSG(fmt, args...) \ - fprintf(stderr, "nouveau: "fmt, ##args); - -#include "nv04_screen.h" - -#define NV04_NEW_VERTPROG (1 << 1) -#define NV04_NEW_FRAGPROG (1 << 2) -#define NV04_NEW_BLEND (1 << 3) -#define NV04_NEW_RAST (1 << 4) -#define NV04_NEW_CONTROL (1 << 5) -#define NV04_NEW_VIEWPORT (1 << 6) -#define NV04_NEW_SAMPLER (1 << 7) -#define NV04_NEW_FRAMEBUFFER (1 << 8) -#define NV04_NEW_VTXARRAYS (1 << 9) - -struct nv04_context { - struct pipe_context pipe; - - struct nouveau_winsys *nvws; - struct nv04_screen *screen; - unsigned pctx_id; - - struct draw_context *draw; - - int chipset; - struct nouveau_notifier *sync; - - uint32_t dirty; - - struct nv04_blend_state *blend; - struct nv04_sampler_state *sampler[PIPE_MAX_SAMPLERS]; - struct nv04_fragtex_state fragtex; - struct nv04_rasterizer_state *rast; - struct nv04_depth_stencil_alpha_state *dsa; - - struct nv04_miptree *tex_miptree[PIPE_MAX_SAMPLERS]; - unsigned dirty_samplers; - unsigned fp_samplers; - unsigned vp_samplers; - - uint32_t rt_enable; - struct pipe_framebuffer_state *framebuffer; - struct pipe_surface *rt; - struct pipe_surface *zeta; - - struct { - struct pipe_buffer *buffer; - uint32_t format; - } tex[16]; - - unsigned vb_enable; - struct { - struct pipe_buffer *buffer; - unsigned delta; - } vb[16]; - - float *constbuf[PIPE_SHADER_TYPES][32][4]; - unsigned constbuf_nr[PIPE_SHADER_TYPES]; - - struct vertex_info vertex_info; - struct { - - struct nouveau_resource *exec_heap; - struct nouveau_resource *data_heap; - - struct nv04_vertex_program *active; - - struct nv04_vertex_program *current; - struct pipe_buffer *constant_buf; - } vertprog; - - struct { - struct nv04_fragment_program *active; - - struct nv04_fragment_program *current; - struct pipe_buffer *constant_buf; - } fragprog; - - struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; - struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS]; - - struct pipe_viewport_state viewport; -}; - -static INLINE struct nv04_context * -nv04_context(struct pipe_context *pipe) -{ - return (struct nv04_context *)pipe; -} - -extern void nv04_init_state_functions(struct nv04_context *nv04); -extern void nv04_init_surface_functions(struct nv04_context *nv04); -extern void nv04_screen_init_miptree_functions(struct pipe_screen *screen); - -/* nv04_clear.c */ -extern void nv04_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue); - -/* nv04_draw.c */ -extern struct draw_stage *nv04_draw_render_stage(struct nv04_context *nv04); - -/* nv04_fragprog.c */ -extern void nv04_fragprog_bind(struct nv04_context *, - struct nv04_fragment_program *); -extern void nv04_fragprog_destroy(struct nv04_context *, - struct nv04_fragment_program *); - -/* nv04_fragtex.c */ -extern void nv04_fragtex_bind(struct nv04_context *); - -/* nv04_prim_vbuf.c */ -struct draw_stage *nv04_draw_vbuf_stage( struct nv04_context *nv04 ); - -/* nv04_state.c and friends */ -extern void nv04_emit_hw_state(struct nv04_context *nv04); -extern void nv04_state_tex_update(struct nv04_context *nv04); - -/* nv04_vbo.c */ -extern void nv04_draw_arrays(struct pipe_context *, unsigned mode, - unsigned start, unsigned count); -extern void nv04_draw_elements( struct pipe_context *pipe, - struct pipe_buffer *indexBuffer, - unsigned indexSize, - unsigned prim, unsigned start, unsigned count); - - -#endif diff --git a/src/gallium/drivers/nv04/nv04_fragprog.c b/src/gallium/drivers/nv04/nv04_fragprog.c deleted file mode 100644 index 8a2af41fe06..00000000000 --- a/src/gallium/drivers/nv04/nv04_fragprog.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_state.h" - -#include "pipe/p_shader_tokens.h" -#include "tgsi/tgsi_parse.h" -#include "tgsi/tgsi_util.h" - -#include "nv04_context.h" - -void -nv04_fragprog_bind(struct nv04_context *nv04, struct nv04_fragment_program *fp) -{ -} - -void -nv04_fragprog_destroy(struct nv04_context *nv04, - struct nv04_fragment_program *fp) -{ -} - diff --git a/src/gallium/drivers/nv04/nv04_fragtex.c b/src/gallium/drivers/nv04/nv04_fragtex.c deleted file mode 100644 index c152b52119a..00000000000 --- a/src/gallium/drivers/nv04/nv04_fragtex.c +++ /dev/null @@ -1,73 +0,0 @@ -#include "nv04_context.h" -#include "nouveau/nouveau_util.h" - -#define _(m,tf) \ -{ \ - PIPE_FORMAT_##m, \ - NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_##tf, \ -} - -struct nv04_texture_format { - uint pipe; - int format; -}; - -static struct nv04_texture_format -nv04_texture_formats[] = { - _(A8R8G8B8_UNORM, A8R8G8B8), - _(X8R8G8B8_UNORM, X8R8G8B8), - _(A1R5G5B5_UNORM, A1R5G5B5), - _(A4R4G4B4_UNORM, A4R4G4B4), - _(L8_UNORM, Y8 ), - _(A8_UNORM, Y8 ), -}; - -static uint32_t -nv04_fragtex_format(uint pipe_format) -{ - struct nv04_texture_format *tf = nv04_texture_formats; - int i; - - for (i=0; i< sizeof(nv04_texture_formats)/sizeof(nv04_texture_formats[0]); i++) { - if (tf->pipe == pipe_format) - return tf->format; - tf++; - } - - NOUVEAU_ERR("unknown texture format %s\n", pf_name(pipe_format)); - return 0; -} - - -static void -nv04_fragtex_build(struct nv04_context *nv04, int unit) -{ - struct nv04_miptree *nv04mt = nv04->tex_miptree[unit]; - struct pipe_texture *pt = &nv04mt->base; - - switch (pt->target) { - case PIPE_TEXTURE_2D: - break; - default: - NOUVEAU_ERR("Unknown target %d\n", pt->target); - return; - } - - nv04->fragtex.format = NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_ZOH_CORNER - | NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_FOH_CORNER - | nv04_fragtex_format(pt->format) - | ( (pt->last_level + 1) << NV04_TEXTURED_TRIANGLE_FORMAT_MIPMAP_LEVELS_SHIFT ) - | ( log2i(pt->width0) << NV04_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_U_SHIFT ) - | ( log2i(pt->height0) << NV04_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_V_SHIFT ) - | NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_EDGE - | NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_CLAMP_TO_EDGE - ; -} - - -void -nv04_fragtex_bind(struct nv04_context *nv04) -{ - nv04_fragtex_build(nv04, 0); -} - diff --git a/src/gallium/drivers/nv04/nv04_miptree.c b/src/gallium/drivers/nv04/nv04_miptree.c deleted file mode 100644 index e4c38ac98e2..00000000000 --- a/src/gallium/drivers/nv04/nv04_miptree.c +++ /dev/null @@ -1,146 +0,0 @@ -#include "pipe/p_state.h" -#include "pipe/p_defines.h" -#include "util/u_inlines.h" -#include "util/u_math.h" - -#include "nv04_context.h" -#include "nv04_screen.h" - -static void -nv04_miptree_layout(struct nv04_miptree *nv04mt) -{ - struct pipe_texture *pt = &nv04mt->base; - uint offset = 0; - int nr_faces, l; - - nr_faces = 1; - - for (l = 0; l <= pt->last_level; l++) { - nv04mt->level[l].pitch = pt->width0; - nv04mt->level[l].pitch = (nv04mt->level[l].pitch + 63) & ~63; - } - - for (l = 0; l <= pt->last_level; l++) { - nv04mt->level[l].image_offset = - CALLOC(nr_faces, sizeof(unsigned)); - /* XXX guess was obviously missing */ - nv04mt->level[l].image_offset[0] = offset; - offset += nv04mt->level[l].pitch * u_minify(pt->height0, l); - } - - nv04mt->total_size = offset; -} - -static struct pipe_texture * -nv04_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt) -{ - struct nv04_miptree *mt; - - mt = MALLOC(sizeof(struct nv04_miptree)); - if (!mt) - return NULL; - mt->base = *pt; - pipe_reference_init(&mt->base.reference, 1); - mt->base.screen = pscreen; - - //mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR; - - nv04_miptree_layout(mt); - - mt->buffer = pscreen->buffer_create(pscreen, 256, PIPE_BUFFER_USAGE_PIXEL | - NOUVEAU_BUFFER_USAGE_TEXTURE, - mt->total_size); - if (!mt->buffer) { - printf("failed %d byte alloc\n",mt->total_size); - FREE(mt); - return NULL; - } - mt->bo = nouveau_bo(mt->buffer); - return &mt->base; -} - -static struct pipe_texture * -nv04_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt, - const unsigned *stride, struct pipe_buffer *pb) -{ - struct nv04_miptree *mt; - - /* Only supports 2D, non-mipmapped textures for the moment */ - if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 || - pt->depth0 != 1) - return NULL; - - mt = CALLOC_STRUCT(nv04_miptree); - if (!mt) - return NULL; - - mt->base = *pt; - pipe_reference_init(&mt->base.reference, 1); - mt->base.screen = pscreen; - mt->level[0].pitch = stride[0]; - mt->level[0].image_offset = CALLOC(1, sizeof(unsigned)); - - pipe_buffer_reference(&mt->buffer, pb); - mt->bo = nouveau_bo(mt->buffer); - return &mt->base; -} - -static void -nv04_miptree_destroy(struct pipe_texture *pt) -{ - struct nv04_miptree *mt = (struct nv04_miptree *)pt; - int l; - - pipe_buffer_reference(&mt->buffer, NULL); - for (l = 0; l <= pt->last_level; l++) { - if (mt->level[l].image_offset) - FREE(mt->level[l].image_offset); - } - - FREE(mt); -} - -static struct pipe_surface * -nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt, - unsigned face, unsigned level, unsigned zslice, - unsigned flags) -{ - struct nv04_miptree *nv04mt = (struct nv04_miptree *)pt; - struct nv04_surface *ns; - - ns = CALLOC_STRUCT(nv04_surface); - if (!ns) - return NULL; - pipe_texture_reference(&ns->base.texture, pt); - ns->base.format = pt->format; - ns->base.width = u_minify(pt->width0, level); - ns->base.height = u_minify(pt->height0, level); - ns->base.usage = flags; - pipe_reference_init(&ns->base.reference, 1); - ns->base.face = face; - ns->base.level = level; - ns->base.zslice = zslice; - ns->pitch = nv04mt->level[level].pitch; - - ns->base.offset = nv04mt->level[level].image_offset[0]; - - return &ns->base; -} - -static void -nv04_miptree_surface_del(struct pipe_surface *ps) -{ - pipe_texture_reference(&ps->texture, NULL); - FREE(ps); -} - -void -nv04_screen_init_miptree_functions(struct pipe_screen *pscreen) -{ - pscreen->texture_create = nv04_miptree_create; - pscreen->texture_blanket = nv04_miptree_blanket; - pscreen->texture_destroy = nv04_miptree_destroy; - pscreen->get_tex_surface = nv04_miptree_surface_new; - pscreen->tex_surface_destroy = nv04_miptree_surface_del; -} - diff --git a/src/gallium/drivers/nv04/nv04_prim_vbuf.c b/src/gallium/drivers/nv04/nv04_prim_vbuf.c deleted file mode 100644 index 03438c7fcb9..00000000000 --- a/src/gallium/drivers/nv04/nv04_prim_vbuf.c +++ /dev/null @@ -1,339 +0,0 @@ - -#include "util/u_debug.h" -#include "util/u_inlines.h" -#include "util/u_simple_screen.h" -#include "pipe/p_compiler.h" - -#include "draw/draw_vbuf.h" - -#include "nv04_context.h" -#include "nv04_state.h" - -#define VERTEX_SIZE 40 -#define VERTEX_BUFFER_SIZE (4096*VERTEX_SIZE) // 4096 vertices of 40 bytes each - -/** - * Primitive renderer for nv04. - */ -struct nv04_vbuf_render { - struct vbuf_render base; - - struct nv04_context *nv04; - - /** Vertex buffer */ - unsigned char* buffer; - - /** Vertex size in bytes */ - unsigned vertex_size; - - /** Current primitive */ - unsigned prim; -}; - - -/** - * Basically a cast wrapper. - */ -static INLINE struct nv04_vbuf_render * -nv04_vbuf_render( struct vbuf_render *render ) -{ - assert(render); - return (struct nv04_vbuf_render *)render; -} - - -static const struct vertex_info * -nv04_vbuf_render_get_vertex_info( struct vbuf_render *render ) -{ - struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render); - struct nv04_context *nv04 = nv04_render->nv04; - return &nv04->vertex_info; -} - - -static boolean -nv04_vbuf_render_allocate_vertices( struct vbuf_render *render, - ushort vertex_size, - ushort nr_vertices ) -{ - struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render); - - nv04_render->buffer = (unsigned char*) MALLOC(VERTEX_BUFFER_SIZE); - assert(!nv04_render->buffer); - - return nv04_render->buffer ? TRUE : FALSE; -} - -static void * -nv04_vbuf_render_map_vertices( struct vbuf_render *render ) -{ - struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render); - return nv04_render->buffer; -} - -static void -nv04_vbuf_render_unmap_vertices( struct vbuf_render *render, - ushort min_index, - ushort max_index ) -{ -} - -static boolean -nv04_vbuf_render_set_primitive( struct vbuf_render *render, - unsigned prim ) -{ - struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render); - - if (prim <= PIPE_PRIM_LINE_STRIP) - return FALSE; - - nv04_render->prim = prim; - return TRUE; -} - -static INLINE void nv04_2triangles(struct nv04_context* nv04, unsigned char* buffer, ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5) -{ - struct nv04_screen *screen = nv04->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *fahrenheit = screen->fahrenheit; - - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0xA), 49); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v0,8); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v1,8); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v2,8); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v3,8); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v4,8); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v5,8); - OUT_RING(chan, 0xFEDCBA); -} - -static INLINE void nv04_1triangle(struct nv04_context* nv04, unsigned char* buffer, ushort v0, ushort v1, ushort v2) -{ - struct nv04_screen *screen = nv04->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *fahrenheit = screen->fahrenheit; - - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0xD), 25); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v0,8); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v1,8); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v2,8); - OUT_RING(chan, 0xFED); -} - -static INLINE void nv04_1quad(struct nv04_context* nv04, unsigned char* buffer, ushort v0, ushort v1, ushort v2, ushort v3) -{ - struct nv04_screen *screen = nv04->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *fahrenheit = screen->fahrenheit; - - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0xC), 33); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v0,8); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v1,8); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v2,8); - OUT_RINGp(chan, buffer + VERTEX_SIZE * v3,8); - OUT_RING(chan, 0xFECEDC); -} - -static void nv04_vbuf_render_triangles_elts(struct nv04_vbuf_render * render, const ushort * indices, uint nr_indices) -{ - unsigned char* buffer = render->buffer; - struct nv04_context* nv04 = render->nv04; - int i; - - for( i=0; i< nr_indices-5; i+=6) - nv04_2triangles(nv04, - buffer, - indices[i+0], - indices[i+1], - indices[i+2], - indices[i+3], - indices[i+4], - indices[i+5] - ); - if (i != nr_indices) - { - nv04_1triangle(nv04, - buffer, - indices[i+0], - indices[i+1], - indices[i+2] - ); - i+=3; - } - if (i != nr_indices) - NOUVEAU_ERR("Houston, we have lost some vertices\n"); -} - -static void nv04_vbuf_render_tri_strip_elts(struct nv04_vbuf_render* render, const ushort* indices, uint nr_indices) -{ - const uint32_t striptbl[]={0x321210,0x543432,0x765654,0x987876,0xBA9A98,0xDCBCBA,0xFEDEDC}; - unsigned char* buffer = render->buffer; - struct nv04_context *nv04 = render->nv04; - struct nv04_screen *screen = nv04->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *fahrenheit = screen->fahrenheit; - int i,j; - - for(i = 0; ibuffer; - struct nv04_context *nv04 = render->nv04; - struct nv04_screen *screen = nv04->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *fahrenheit = screen->fahrenheit; - int i,j; - - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0), 8); - OUT_RINGp(chan, buffer + VERTEX_SIZE * indices[0], 8); - - for(i = 1; ibuffer; - struct nv04_context* nv04 = render->nv04; - int i; - - for(i = 0; i < nr_indices; i += 4) - nv04_1quad(nv04, - buffer, - indices[i+0], - indices[i+1], - indices[i+2], - indices[i+3] - ); -} - - -static void -nv04_vbuf_render_draw( struct vbuf_render *render, - const ushort *indices, - uint nr_indices) -{ - struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render); - - // emit the indices - switch( nv04_render->prim ) - { - case PIPE_PRIM_TRIANGLES: - nv04_vbuf_render_triangles_elts(nv04_render, indices, nr_indices); - break; - case PIPE_PRIM_QUAD_STRIP: - case PIPE_PRIM_TRIANGLE_STRIP: - nv04_vbuf_render_tri_strip_elts(nv04_render, indices, nr_indices); - break; - case PIPE_PRIM_TRIANGLE_FAN: - case PIPE_PRIM_POLYGON: - nv04_vbuf_render_tri_fan_elts(nv04_render, indices, nr_indices); - break; - case PIPE_PRIM_QUADS: - nv04_vbuf_render_quads_elts(nv04_render, indices, nr_indices); - break; - default: - NOUVEAU_ERR("You have to implement primitive %d, young padawan\n", nv04_render->prim); - break; - } -} - - -static void -nv04_vbuf_render_release_vertices( struct vbuf_render *render ) -{ - struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render); - - free(nv04_render->buffer); - nv04_render->buffer = NULL; -} - - -static void -nv04_vbuf_render_destroy( struct vbuf_render *render ) -{ - struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render); - FREE(nv04_render); -} - - -/** - * Create a new primitive render. - */ -static struct vbuf_render * -nv04_vbuf_render_create( struct nv04_context *nv04 ) -{ - struct nv04_vbuf_render *nv04_render = CALLOC_STRUCT(nv04_vbuf_render); - - nv04_render->nv04 = nv04; - - nv04_render->base.max_vertex_buffer_bytes = VERTEX_BUFFER_SIZE; - nv04_render->base.max_indices = 65536; - nv04_render->base.get_vertex_info = nv04_vbuf_render_get_vertex_info; - nv04_render->base.allocate_vertices = nv04_vbuf_render_allocate_vertices; - nv04_render->base.map_vertices = nv04_vbuf_render_map_vertices; - nv04_render->base.unmap_vertices = nv04_vbuf_render_unmap_vertices; - nv04_render->base.set_primitive = nv04_vbuf_render_set_primitive; - nv04_render->base.draw = nv04_vbuf_render_draw; - nv04_render->base.release_vertices = nv04_vbuf_render_release_vertices; - nv04_render->base.destroy = nv04_vbuf_render_destroy; - - return &nv04_render->base; -} - - -/** - * Create a new primitive vbuf/render stage. - */ -struct draw_stage *nv04_draw_vbuf_stage( struct nv04_context *nv04 ) -{ - struct vbuf_render *render; - struct draw_stage *stage; - - render = nv04_vbuf_render_create(nv04); - if(!render) - return NULL; - - stage = draw_vbuf_stage( nv04->draw, render ); - if(!stage) { - render->destroy(render); - return NULL; - } - - return stage; -} diff --git a/src/gallium/drivers/nv04/nv04_screen.c b/src/gallium/drivers/nv04/nv04_screen.c deleted file mode 100644 index 212b47bc3d2..00000000000 --- a/src/gallium/drivers/nv04/nv04_screen.c +++ /dev/null @@ -1,222 +0,0 @@ -#include "pipe/p_screen.h" -#include "util/u_inlines.h" - -#include "nv04_context.h" -#include "nv04_screen.h" - -static int -nv04_screen_get_param(struct pipe_screen *screen, int param) -{ - switch (param) { - case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: - return 1; - case PIPE_CAP_NPOT_TEXTURES: - return 0; - case PIPE_CAP_TWO_SIDED_STENCIL: - return 0; - case PIPE_CAP_GLSL: - return 0; - case PIPE_CAP_ANISOTROPIC_FILTER: - return 0; - case PIPE_CAP_POINT_SPRITE: - return 0; - case PIPE_CAP_MAX_RENDER_TARGETS: - return 1; - case PIPE_CAP_OCCLUSION_QUERY: - return 0; - case PIPE_CAP_TEXTURE_SHADOW_MAP: - return 0; - case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: - return 10; - case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: - return 0; - case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: - return 0; - case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS: - return 0; - case PIPE_CAP_TEXTURE_MIRROR_CLAMP: - return 0; - case PIPE_CAP_TEXTURE_MIRROR_REPEAT: - return 1; - case PIPE_CAP_TGSI_CONT_SUPPORTED: - return 0; - case PIPE_CAP_BLEND_EQUATION_SEPARATE: - return 0; - case NOUVEAU_CAP_HW_VTXBUF: - case NOUVEAU_CAP_HW_IDXBUF: - return 0; - case PIPE_CAP_INDEP_BLEND_ENABLE: - return 0; - case PIPE_CAP_INDEP_BLEND_FUNC: - return 0; - case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: - case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: - return 1; - case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: - case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: - return 0; - default: - NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); - return 0; - } -} - -static float -nv04_screen_get_paramf(struct pipe_screen *screen, int param) -{ - switch (param) { - case PIPE_CAP_MAX_LINE_WIDTH: - case PIPE_CAP_MAX_LINE_WIDTH_AA: - return 0.0; - case PIPE_CAP_MAX_POINT_WIDTH: - case PIPE_CAP_MAX_POINT_WIDTH_AA: - return 0.0; - case PIPE_CAP_MAX_TEXTURE_ANISOTROPY: - return 0.0; - case PIPE_CAP_MAX_TEXTURE_LOD_BIAS: - return 0.0; - default: - NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); - return 0.0; - } -} - -static boolean -nv04_screen_is_format_supported(struct pipe_screen *screen, - enum pipe_format format, - enum pipe_texture_target target, - unsigned tex_usage, unsigned geom_flags) -{ - if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) { - switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - return TRUE; - default: - break; - } - } else - if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) { - switch (format) { - case PIPE_FORMAT_Z16_UNORM: - return TRUE; - default: - break; - } - } else { - switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_A1R5G5B5_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_L8_UNORM: - case PIPE_FORMAT_A8_UNORM: - return TRUE; - default: - break; - } - } - - return FALSE; -} - -static void -nv04_screen_destroy(struct pipe_screen *pscreen) -{ - struct nv04_screen *screen = nv04_screen(pscreen); - - nouveau_notifier_free(&screen->sync); - nouveau_grobj_free(&screen->fahrenheit); - nv04_surface_2d_takedown(&screen->eng2d); - - nouveau_screen_fini(&screen->base); - - FREE(pscreen); -} - -static struct pipe_buffer * -nv04_surface_buffer(struct pipe_surface *surf) -{ - struct nv04_miptree *mt = (struct nv04_miptree *)surf->texture; - - return mt->buffer; -} - -struct pipe_screen * -nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) -{ - struct nv04_screen *screen = CALLOC_STRUCT(nv04_screen); - struct nouveau_channel *chan; - struct pipe_screen *pscreen; - unsigned fahrenheit_class = 0, sub3d_class = 0; - int ret; - - if (!screen) - return NULL; - pscreen = &screen->base.base; - - ret = nouveau_screen_init(&screen->base, dev); - if (ret) { - nv04_screen_destroy(pscreen); - return NULL; - } - chan = screen->base.channel; - - pscreen->winsys = ws; - pscreen->destroy = nv04_screen_destroy; - pscreen->get_param = nv04_screen_get_param; - pscreen->get_paramf = nv04_screen_get_paramf; - pscreen->is_format_supported = nv04_screen_is_format_supported; - - nv04_screen_init_miptree_functions(pscreen); - nv04_screen_init_transfer_functions(pscreen); - - if (dev->chipset >= 0x20) { - fahrenheit_class = 0; - sub3d_class = 0; - } else if (dev->chipset >= 0x10) { - fahrenheit_class = NV10_TEXTURED_TRIANGLE; - sub3d_class = NV10_CONTEXT_SURFACES_3D; - } else { - fahrenheit_class=NV04_TEXTURED_TRIANGLE; - sub3d_class = NV04_CONTEXT_SURFACES_3D; - } - - if (!fahrenheit_class) { - NOUVEAU_ERR("Unknown nv04 chipset: nv%02x\n", dev->chipset); - return NULL; - } - - /* 3D object */ - ret = nouveau_grobj_alloc(chan, 0xbeef0001, fahrenheit_class, - &screen->fahrenheit); - if (ret) { - NOUVEAU_ERR("Error creating 3D object: %d\n", ret); - return NULL; - } - BIND_RING(chan, screen->fahrenheit, 7); - - /* 3D surface object */ - ret = nouveau_grobj_alloc(chan, 0xbeef0002, sub3d_class, - &screen->context_surfaces_3d); - if (ret) { - NOUVEAU_ERR("Error creating 3D surface object: %d\n", ret); - return NULL; - } - BIND_RING(chan, screen->context_surfaces_3d, 6); - - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(&screen->base); - screen->eng2d->buf = nv04_surface_buffer; - - /* Notifier for sync purposes */ - ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); - if (ret) { - NOUVEAU_ERR("Error creating notifier object: %d\n", ret); - nv04_screen_destroy(pscreen); - return NULL; - } - - return pscreen; -} - diff --git a/src/gallium/drivers/nv04/nv04_screen.h b/src/gallium/drivers/nv04/nv04_screen.h deleted file mode 100644 index 11466b9442c..00000000000 --- a/src/gallium/drivers/nv04/nv04_screen.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __NV04_SCREEN_H__ -#define __NV04_SCREEN_H__ - -#include "nouveau/nouveau_screen.h" -#include "nv04_surface_2d.h" - -struct nv04_screen { - struct nouveau_screen base; - - struct nouveau_winsys *nvws; - unsigned chipset; - - /* HW graphics objects */ - struct nv04_surface_2d *eng2d; - struct nouveau_grobj *fahrenheit; - struct nouveau_grobj *context_surfaces_3d; - struct nouveau_notifier *sync; - -}; - -static INLINE struct nv04_screen * -nv04_screen(struct pipe_screen *screen) -{ - return (struct nv04_screen *)screen; -} - -void -nv04_screen_init_transfer_functions(struct pipe_screen *pscreen); - -#endif diff --git a/src/gallium/drivers/nv04/nv04_state.c b/src/gallium/drivers/nv04/nv04_state.c deleted file mode 100644 index 226aae35659..00000000000 --- a/src/gallium/drivers/nv04/nv04_state.c +++ /dev/null @@ -1,459 +0,0 @@ -#include "draw/draw_context.h" -#include "pipe/p_state.h" -#include "pipe/p_defines.h" -#include "pipe/p_shader_tokens.h" -#include "util/u_inlines.h" - -#include "tgsi/tgsi_parse.h" - -#include "nv04_context.h" -#include "nv04_state.h" - -static void * -nv04_blend_state_create(struct pipe_context *pipe, - const struct pipe_blend_state *cso) -{ - struct nv04_blend_state *cb; - - cb = MALLOC(sizeof(struct nv04_blend_state)); - - cb->b_enable = cso->rt[0].blend_enable ? 1 : 0; - cb->b_src = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) | - (nvgl_blend_func(cso->rt[0].rgb_src_factor))); - cb->b_dst = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) | - (nvgl_blend_func(cso->rt[0].rgb_dst_factor))); - - - return (void *)cb; -} - -static void -nv04_blend_state_bind(struct pipe_context *pipe, void *blend) -{ - struct nv04_context *nv04 = nv04_context(pipe); - - nv04->blend = (struct nv04_blend_state*)blend; - - nv04->dirty |= NV04_NEW_BLEND; -} - -static void -nv04_blend_state_delete(struct pipe_context *pipe, void *hwcso) -{ - free(hwcso); -} - - -static INLINE unsigned -wrap_mode(unsigned wrap) { - unsigned ret; - - switch (wrap) { - case PIPE_TEX_WRAP_REPEAT: - ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_REPEAT; - break; - case PIPE_TEX_WRAP_MIRROR_REPEAT: - ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_MIRRORED_REPEAT; - break; - case PIPE_TEX_WRAP_CLAMP_TO_EDGE: - ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_EDGE; - break; - case PIPE_TEX_WRAP_CLAMP_TO_BORDER: - ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_BORDER; - break; - case PIPE_TEX_WRAP_CLAMP: - ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP; - break; - case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: - case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: - case PIPE_TEX_WRAP_MIRROR_CLAMP: - default: - NOUVEAU_ERR("unknown wrap mode: %d\n", wrap); - ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP; - } - return ret >> NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_SHIFT; -} - -static void * -nv04_sampler_state_create(struct pipe_context *pipe, - const struct pipe_sampler_state *cso) -{ - - struct nv04_sampler_state *ss; - uint32_t filter = 0; - - ss = MALLOC(sizeof(struct nv04_sampler_state)); - - ss->format = ((wrap_mode(cso->wrap_s) << NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_SHIFT) | - (wrap_mode(cso->wrap_t) << NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_SHIFT)); - - if (cso->max_anisotropy > 1.0) { - filter |= NV04_TEXTURED_TRIANGLE_FILTER_ANISOTROPIC_MINIFY_ENABLE | NV04_TEXTURED_TRIANGLE_FILTER_ANISOTROPIC_MAGNIFY_ENABLE; - } - - switch (cso->mag_img_filter) { - case PIPE_TEX_FILTER_LINEAR: - filter |= NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY_LINEAR; - break; - case PIPE_TEX_FILTER_NEAREST: - default: - filter |= NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY_NEAREST; - break; - } - - switch (cso->min_img_filter) { - case PIPE_TEX_FILTER_LINEAR: - switch (cso->min_mip_filter) { - case PIPE_TEX_MIPFILTER_NEAREST: - filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST; - break; - case PIPE_TEX_MIPFILTER_LINEAR: - filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR; - break; - case PIPE_TEX_MIPFILTER_NONE: - default: - filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR; - break; - } - break; - case PIPE_TEX_FILTER_NEAREST: - default: - switch (cso->min_mip_filter) { - case PIPE_TEX_MIPFILTER_NEAREST: - filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST; - break; - case PIPE_TEX_MIPFILTER_LINEAR: - filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR; - break; - case PIPE_TEX_MIPFILTER_NONE: - default: - filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST; - break; - } - break; - } - - ss->filter = filter; - - return (void *)ss; -} - -static void -nv04_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler) -{ - struct nv04_context *nv04 = nv04_context(pipe); - unsigned unit; - - for (unit = 0; unit < nr; unit++) { - nv04->sampler[unit] = sampler[unit]; - nv04->dirty_samplers |= (1 << unit); - } -} - -static void -nv04_sampler_state_delete(struct pipe_context *pipe, void *hwcso) -{ - free(hwcso); -} - -static void -nv04_set_sampler_texture(struct pipe_context *pipe, unsigned nr, - struct pipe_texture **miptree) -{ - struct nv04_context *nv04 = nv04_context(pipe); - unsigned unit; - - for (unit = 0; unit < nr; unit++) { - nv04->tex_miptree[unit] = (struct nv04_miptree *)miptree[unit]; - nv04->dirty_samplers |= (1 << unit); - } -} - -static void * -nv04_rasterizer_state_create(struct pipe_context *pipe, - const struct pipe_rasterizer_state *cso) -{ - struct nv04_rasterizer_state *rs; - - /*XXX: ignored: - * scissor - * points/lines (no hw support, emulated with tris in gallium) - */ - rs = MALLOC(sizeof(struct nv04_rasterizer_state)); - - rs->blend = cso->flatshade ? NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_FLAT : NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_GOURAUD; - - return (void *)rs; -} - -static void -nv04_rasterizer_state_bind(struct pipe_context *pipe, void *rast) -{ - struct nv04_context *nv04 = nv04_context(pipe); - - nv04->rast = (struct nv04_rasterizer_state*)rast; - - draw_set_rasterizer_state(nv04->draw, (nv04->rast ? nv04->rast->templ : NULL)); - - nv04->dirty |= NV04_NEW_RAST | NV04_NEW_BLEND; -} - -static void -nv04_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso) -{ - free(hwcso); -} - -static INLINE uint32_t nv04_compare_func(uint32_t f) -{ - switch ( f ) { - case PIPE_FUNC_NEVER: return 1; - case PIPE_FUNC_LESS: return 2; - case PIPE_FUNC_EQUAL: return 3; - case PIPE_FUNC_LEQUAL: return 4; - case PIPE_FUNC_GREATER: return 5; - case PIPE_FUNC_NOTEQUAL: return 6; - case PIPE_FUNC_GEQUAL: return 7; - case PIPE_FUNC_ALWAYS: return 8; - } - NOUVEAU_MSG("Unable to find the function\n"); - return 0; -} - -static void * -nv04_depth_stencil_alpha_state_create(struct pipe_context *pipe, - const struct pipe_depth_stencil_alpha_state *cso) -{ - struct nv04_depth_stencil_alpha_state *hw; - - hw = MALLOC(sizeof(struct nv04_depth_stencil_alpha_state)); - - hw->control = float_to_ubyte(cso->alpha.ref_value); - hw->control |= ( nv04_compare_func(cso->alpha.func) << NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_SHIFT ); - hw->control |= cso->alpha.enabled ? NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_ENABLE : 0; - hw->control |= NV04_TEXTURED_TRIANGLE_CONTROL_ORIGIN; - hw->control |= cso->depth.enabled ? NV04_TEXTURED_TRIANGLE_CONTROL_Z_ENABLE : 0; - hw->control |= ( nv04_compare_func(cso->depth.func)<< NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_SHIFT ); - hw->control |= 1 << NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_SHIFT; // no culling, handled by the draw module - hw->control |= NV04_TEXTURED_TRIANGLE_CONTROL_DITHER_ENABLE; - hw->control |= NV04_TEXTURED_TRIANGLE_CONTROL_Z_PERSPECTIVE_ENABLE; - hw->control |= cso->depth.writemask ? NV04_TEXTURED_TRIANGLE_CONTROL_Z_WRITE : 0; - hw->control |= 1 << NV04_TEXTURED_TRIANGLE_CONTROL_Z_FORMAT_SHIFT; // integer zbuffer format - - return (void *)hw; -} - -static void -nv04_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso) -{ - struct nv04_context *nv04 = nv04_context(pipe); - - nv04->dsa = hwcso; - nv04->dirty |= NV04_NEW_CONTROL; -} - -static void -nv04_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso) -{ - free(hwcso); -} - -static void * -nv04_vp_state_create(struct pipe_context *pipe, - const struct pipe_shader_state *templ) -{ - struct nv04_context *nv04 = nv04_context(pipe); - - return draw_create_vertex_shader(nv04->draw, templ); -} - -static void -nv04_vp_state_bind(struct pipe_context *pipe, void *shader) -{ - struct nv04_context *nv04 = nv04_context(pipe); - - draw_bind_vertex_shader(nv04->draw, (struct draw_vertex_shader *) shader); - - nv04->dirty |= NV04_NEW_VERTPROG; -} - -static void -nv04_vp_state_delete(struct pipe_context *pipe, void *shader) -{ - struct nv04_context *nv04 = nv04_context(pipe); - - draw_delete_vertex_shader(nv04->draw, (struct draw_vertex_shader *) shader); -} - -static void * -nv04_fp_state_create(struct pipe_context *pipe, - const struct pipe_shader_state *cso) -{ - struct nv04_fragment_program *fp; - - fp = CALLOC(1, sizeof(struct nv04_fragment_program)); - fp->pipe.tokens = tgsi_dup_tokens(cso->tokens); - - return (void *)fp; -} - -static void -nv04_fp_state_bind(struct pipe_context *pipe, void *hwcso) -{ - struct nv04_context *nv04 = nv04_context(pipe); - struct nv04_fragment_program *fp = hwcso; - - nv04->fragprog.current = fp; - nv04->dirty |= NV04_NEW_FRAGPROG; -} - -static void -nv04_fp_state_delete(struct pipe_context *pipe, void *hwcso) -{ - struct nv04_context *nv04 = nv04_context(pipe); - struct nv04_fragment_program *fp = hwcso; - - nv04_fragprog_destroy(nv04, fp); - free((void*)fp->pipe.tokens); - free(fp); -} - -static void -nv04_set_blend_color(struct pipe_context *pipe, - const struct pipe_blend_color *bcol) -{ -} - -static void -nv04_set_clip_state(struct pipe_context *pipe, - const struct pipe_clip_state *clip) -{ -} - -static void -nv04_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, - struct pipe_buffer *buf ) -{ - struct nv04_context *nv04 = nv04_context(pipe); - struct pipe_screen *pscreen = pipe->screen; - - assert(shader < PIPE_SHADER_TYPES); - assert(index == 0); - - if (buf) { - void *mapped; - if (buf && buf->size && - (mapped = pipe_buffer_map(pscreen, buf, PIPE_BUFFER_USAGE_CPU_READ))) - { - memcpy(nv04->constbuf[shader], mapped, buf->size); - nv04->constbuf_nr[shader] = - buf->size / (4 * sizeof(float)); - pipe_buffer_unmap(pscreen, buf); - } - } -} - -static void -nv04_set_framebuffer_state(struct pipe_context *pipe, - const struct pipe_framebuffer_state *fb) -{ - struct nv04_context *nv04 = nv04_context(pipe); - - nv04->framebuffer = (struct pipe_framebuffer_state*)fb; - - nv04->dirty |= NV04_NEW_FRAMEBUFFER; -} -static void -nv04_set_polygon_stipple(struct pipe_context *pipe, - const struct pipe_poly_stipple *stipple) -{ - NOUVEAU_ERR("line stipple hahaha\n"); -} - -static void -nv04_set_scissor_state(struct pipe_context *pipe, - const struct pipe_scissor_state *s) -{ -/* struct nv04_context *nv04 = nv04_context(pipe); - - // XXX - BEGIN_RING(fahrenheit, NV04_TEXTURED_TRIANGLE_SCISSOR_HORIZ, 2); - OUT_RING (((s->maxx - s->minx) << 16) | s->minx); - OUT_RING (((s->maxy - s->miny) << 16) | s->miny);*/ -} - -static void -nv04_set_viewport_state(struct pipe_context *pipe, - const struct pipe_viewport_state *viewport) -{ - struct nv04_context *nv04 = nv04_context(pipe); - - nv04->viewport = *viewport; - - draw_set_viewport_state(nv04->draw, &nv04->viewport); -} - -static void -nv04_set_vertex_buffers(struct pipe_context *pipe, unsigned count, - const struct pipe_vertex_buffer *buffers) -{ - struct nv04_context *nv04 = nv04_context(pipe); - - memcpy(nv04->vtxbuf, buffers, count * sizeof(buffers[0])); - nv04->dirty |= NV04_NEW_VTXARRAYS; - - draw_set_vertex_buffers(nv04->draw, count, buffers); -} - -static void -nv04_set_vertex_elements(struct pipe_context *pipe, unsigned count, - const struct pipe_vertex_element *elements) -{ - struct nv04_context *nv04 = nv04_context(pipe); - - memcpy(nv04->vtxelt, elements, sizeof(*elements) * count); - nv04->dirty |= NV04_NEW_VTXARRAYS; - - draw_set_vertex_elements(nv04->draw, count, elements); -} - -void -nv04_init_state_functions(struct nv04_context *nv04) -{ - nv04->pipe.create_blend_state = nv04_blend_state_create; - nv04->pipe.bind_blend_state = nv04_blend_state_bind; - nv04->pipe.delete_blend_state = nv04_blend_state_delete; - - nv04->pipe.create_sampler_state = nv04_sampler_state_create; - nv04->pipe.bind_fragment_sampler_states = nv04_sampler_state_bind; - nv04->pipe.delete_sampler_state = nv04_sampler_state_delete; - nv04->pipe.set_fragment_sampler_textures = nv04_set_sampler_texture; - - nv04->pipe.create_rasterizer_state = nv04_rasterizer_state_create; - nv04->pipe.bind_rasterizer_state = nv04_rasterizer_state_bind; - nv04->pipe.delete_rasterizer_state = nv04_rasterizer_state_delete; - - nv04->pipe.create_depth_stencil_alpha_state = nv04_depth_stencil_alpha_state_create; - nv04->pipe.bind_depth_stencil_alpha_state = nv04_depth_stencil_alpha_state_bind; - nv04->pipe.delete_depth_stencil_alpha_state = nv04_depth_stencil_alpha_state_delete; - - nv04->pipe.create_vs_state = nv04_vp_state_create; - nv04->pipe.bind_vs_state = nv04_vp_state_bind; - nv04->pipe.delete_vs_state = nv04_vp_state_delete; - - nv04->pipe.create_fs_state = nv04_fp_state_create; - nv04->pipe.bind_fs_state = nv04_fp_state_bind; - nv04->pipe.delete_fs_state = nv04_fp_state_delete; - - nv04->pipe.set_blend_color = nv04_set_blend_color; - nv04->pipe.set_clip_state = nv04_set_clip_state; - nv04->pipe.set_constant_buffer = nv04_set_constant_buffer; - nv04->pipe.set_framebuffer_state = nv04_set_framebuffer_state; - nv04->pipe.set_polygon_stipple = nv04_set_polygon_stipple; - nv04->pipe.set_scissor_state = nv04_set_scissor_state; - nv04->pipe.set_viewport_state = nv04_set_viewport_state; - - nv04->pipe.set_vertex_buffers = nv04_set_vertex_buffers; - nv04->pipe.set_vertex_elements = nv04_set_vertex_elements; -} - diff --git a/src/gallium/drivers/nv04/nv04_state.h b/src/gallium/drivers/nv04/nv04_state.h deleted file mode 100644 index 81d1d2ebaa9..00000000000 --- a/src/gallium/drivers/nv04/nv04_state.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef __NV04_STATE_H__ -#define __NV04_STATE_H__ - -#include "pipe/p_state.h" -#include "tgsi/tgsi_scan.h" - -struct nv04_blend_state { - uint32_t b_enable; - uint32_t b_src; - uint32_t b_dst; -}; - -struct nv04_fragtex_state { - uint32_t format; -}; - -struct nv04_sampler_state { - uint32_t filter; - uint32_t format; -}; - -struct nv04_depth_stencil_alpha_state { - uint32_t control; -}; - -struct nv04_rasterizer_state { - uint32_t blend; - - const struct pipe_rasterizer_state *templ; -}; - -struct nv04_miptree { - struct pipe_texture base; - struct nouveau_bo *bo; - - struct pipe_buffer *buffer; - uint total_size; - - struct { - uint pitch; - uint *image_offset; - } level[PIPE_MAX_TEXTURE_LEVELS]; -}; - -struct nv04_fragment_program_data { - unsigned offset; - unsigned index; -}; - -struct nv04_fragment_program { - struct pipe_shader_state pipe; - struct tgsi_shader_info info; - - boolean translated; - boolean on_hw; - unsigned samplers; - - uint32_t *insn; - int insn_len; - - struct nv04_fragment_program_data *consts; - unsigned nr_consts; - - struct pipe_buffer *buffer; - - uint32_t fp_control; - uint32_t fp_reg_control; -}; - - - -#endif diff --git a/src/gallium/drivers/nv04/nv04_state_emit.c b/src/gallium/drivers/nv04/nv04_state_emit.c deleted file mode 100644 index b8d6dc560f0..00000000000 --- a/src/gallium/drivers/nv04/nv04_state_emit.c +++ /dev/null @@ -1,246 +0,0 @@ -#include "nv04_context.h" -#include "nv04_state.h" - -static void nv04_vertex_layout(struct pipe_context* pipe) -{ - struct nv04_context *nv04 = nv04_context(pipe); - struct nv04_fragment_program *fp = nv04->fragprog.current; - uint32_t src = 0; - int i; - struct vertex_info vinfo; - - memset(&vinfo, 0, sizeof(vinfo)); - - for (i = 0; i < fp->info.num_inputs; i++) { - int isn = fp->info.input_semantic_name[i]; - int isi = fp->info.input_semantic_index[i]; - switch (isn) { - case TGSI_SEMANTIC_POSITION: - draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++); - break; - case TGSI_SEMANTIC_COLOR: - draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++); - break; - default: - case TGSI_SEMANTIC_GENERIC: - draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++); - break; - case TGSI_SEMANTIC_FOG: - draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++); - break; - } - } - - printf("%d vertex input\n",fp->info.num_inputs); - draw_compute_vertex_size(&vinfo); -} - -static uint32_t nv04_blend_func(uint32_t f) -{ - switch ( f ) { - case PIPE_BLENDFACTOR_ZERO: return 0x1; - case PIPE_BLENDFACTOR_ONE: return 0x2; - case PIPE_BLENDFACTOR_SRC_COLOR: return 0x3; - case PIPE_BLENDFACTOR_INV_SRC_COLOR: return 0x4; - case PIPE_BLENDFACTOR_SRC_ALPHA: return 0x5; - case PIPE_BLENDFACTOR_INV_SRC_ALPHA: return 0x6; - case PIPE_BLENDFACTOR_DST_ALPHA: return 0x7; - case PIPE_BLENDFACTOR_INV_DST_ALPHA: return 0x8; - case PIPE_BLENDFACTOR_DST_COLOR: return 0x9; - case PIPE_BLENDFACTOR_INV_DST_COLOR: return 0xA; - case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: return 0xB; - } - NOUVEAU_MSG("Unable to find the blend function 0x%x\n",f); - return 0; -} - -static void nv04_emit_control(struct nv04_context* nv04) -{ - uint32_t control = nv04->dsa->control; - struct nv04_screen *screen = nv04->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *fahrenheit = screen->fahrenheit; - - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1); - OUT_RING(chan, control); -} - -static void nv04_emit_blend(struct nv04_context* nv04) -{ - struct nv04_screen *screen = nv04->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *fahrenheit = screen->fahrenheit; - uint32_t blend; - - blend=0x4; // texture MODULATE_ALPHA - blend|=0x20; // alpha is MSB - blend|=(2<<6); // flat shading - blend|=(1<<8); // persp correct - blend|=(0<<16); // no fog - blend|=(nv04->blend->b_enable<<20); - blend|=(nv04_blend_func(nv04->blend->b_src)<<24); - blend|=(nv04_blend_func(nv04->blend->b_dst)<<28); - - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_BLEND, 1); - OUT_RING(chan, blend); -} - -static void nv04_emit_sampler(struct nv04_context *nv04, int unit) -{ - struct nv04_miptree *nv04mt = nv04->tex_miptree[unit]; - struct pipe_texture *pt = &nv04mt->base; - struct nv04_screen *screen = nv04->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *fahrenheit = screen->fahrenheit; - struct nouveau_bo *bo = nouveau_bo(nv04mt->buffer); - - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_OFFSET, 3); - OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD); - OUT_RELOCd(chan, bo, (nv04->fragtex.format | nv04->sampler[unit]->format), NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/); - OUT_RING(chan, nv04->sampler[unit]->filter); -} - -static void nv04_state_emit_framebuffer(struct nv04_context* nv04) -{ - struct pipe_framebuffer_state* fb = nv04->framebuffer; - struct nv04_surface *rt, *zeta; - uint32_t rt_format, w, h; - int colour_format = 0, zeta_format = 0; - struct nv04_miptree *nv04mt = 0; - struct nv04_screen *screen = nv04->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *context_surfaces_3d = screen->context_surfaces_3d; - struct nouveau_bo *bo; - - w = fb->cbufs[0]->width; - h = fb->cbufs[0]->height; - colour_format = fb->cbufs[0]->format; - rt = (struct nv04_surface *)fb->cbufs[0]; - - if (fb->zsbuf) { - if (colour_format) { - assert(w == fb->zsbuf->width); - assert(h == fb->zsbuf->height); - } else { - w = fb->zsbuf->width; - h = fb->zsbuf->height; - } - - zeta_format = fb->zsbuf->format; - zeta = (struct nv04_surface *)fb->zsbuf; - } - - switch (colour_format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case 0: - rt_format = 0x108; - break; - case PIPE_FORMAT_R5G6B5_UNORM: - rt_format = 0x103; - break; - default: - assert(0); - } - - BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_FORMAT, 1); - OUT_RING(chan, rt_format); - - nv04mt = (struct nv04_miptree *)rt->base.texture; - bo = nouveau_bo(nv04mt->buffer); - /* FIXME pitches have to be aligned ! */ - BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2); - OUT_RING(chan, rt->pitch|(zeta->pitch<<16)); - OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - if (fb->zsbuf) { - nv04mt = (struct nv04_miptree *)zeta->base.texture; - BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1); - OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - } -} - -void -nv04_emit_hw_state(struct nv04_context *nv04) -{ - struct nv04_screen *screen = nv04->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *fahrenheit = screen->fahrenheit; - struct nouveau_grobj *context_surfaces_3d = screen->context_surfaces_3d; - int i; - - if (nv04->dirty & NV04_NEW_VERTPROG) { - //nv04_vertprog_bind(nv04, nv04->vertprog.current); - nv04->dirty &= ~NV04_NEW_VERTPROG; - } - - if (nv04->dirty & NV04_NEW_FRAGPROG) { - nv04_fragprog_bind(nv04, nv04->fragprog.current); - nv04->dirty &= ~NV04_NEW_FRAGPROG; - nv04->dirty_samplers |= (1<<10); - nv04->dirty_samplers = 0; - } - - if (nv04->dirty & NV04_NEW_CONTROL) { - nv04->dirty &= ~NV04_NEW_CONTROL; - - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1); - OUT_RING(chan, nv04->dsa->control); - } - - if (nv04->dirty & NV04_NEW_BLEND) { - nv04->dirty &= ~NV04_NEW_BLEND; - - nv04_emit_blend(nv04); - } - - if (nv04->dirty & NV04_NEW_VTXARRAYS) { - nv04->dirty &= ~NV04_NEW_VTXARRAYS; - nv04_vertex_layout(nv04); - } - - if (nv04->dirty & NV04_NEW_SAMPLER) { - nv04->dirty &= ~NV04_NEW_SAMPLER; - - nv04_emit_sampler(nv04, 0); - } - - if (nv04->dirty & NV04_NEW_VIEWPORT) { - nv04->dirty &= ~NV04_NEW_VIEWPORT; -// nv04_state_emit_viewport(nv04); - } - - if (nv04->dirty & NV04_NEW_FRAMEBUFFER) { - nv04->dirty &= ~NV04_NEW_FRAMEBUFFER; - nv04_state_emit_framebuffer(nv04); - } - - /* Emit relocs for every referenced buffer. - * This is to ensure the bufmgr has an accurate idea of how - * the buffer is used. This isn't very efficient, but we don't - * seem to take a significant performance hit. Will be improved - * at some point. Vertex arrays are emitted by nv04_vbo.c - */ - - /* Render target */ - unsigned rt_pitch = ((struct nv04_surface *)nv04->rt)->pitch; - unsigned zeta_pitch = ((struct nv04_surface *)nv04->zeta)->pitch; - - BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2); - OUT_RING(chan, rt_pitch|(zeta_pitch<<16)); - OUT_RELOCl(chan, nouveau_bo(nv04->rt), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - if (nv04->zeta) { - BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1); - OUT_RELOCl(chan, nouveau_bo(nv04->zeta), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - } - - /* Texture images */ - for (i = 0; i < 1; i++) { - if (!(nv04->fp_samplers & (1 << i))) - continue; - struct nv04_miptree *nv04mt = nv04->tex_miptree[i]; - struct nouveau_bo *bo = nouveau_bo(nv04mt->buffer); - BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_OFFSET, 2); - OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD); - OUT_RELOCd(chan, bo, (nv04->fragtex.format | nv04->sampler[i]->format), NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/); - } -} - diff --git a/src/gallium/drivers/nv04/nv04_surface.c b/src/gallium/drivers/nv04/nv04_surface.c deleted file mode 100644 index c5f8927c058..00000000000 --- a/src/gallium/drivers/nv04/nv04_surface.c +++ /dev/null @@ -1,63 +0,0 @@ - -/************************************************************************** - * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "nv04_context.h" -#include "pipe/p_defines.h" -#include "util/u_simple_screen.h" -#include "util/u_inlines.h" -#include "util/u_tile.h" - -static void -nv04_surface_copy(struct pipe_context *pipe, - struct pipe_surface *dest, unsigned destx, unsigned desty, - struct pipe_surface *src, unsigned srcx, unsigned srcy, - unsigned width, unsigned height) -{ - struct nv04_context *nv04 = nv04_context(pipe); - struct nv04_surface_2d *eng2d = nv04->screen->eng2d; - - eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height); -} - -static void -nv04_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest, - unsigned destx, unsigned desty, unsigned width, - unsigned height, unsigned value) -{ - struct nv04_context *nv04 = nv04_context(pipe); - struct nv04_surface_2d *eng2d = nv04->screen->eng2d; - - eng2d->fill(eng2d, dest, destx, desty, width, height, value); -} - -void -nv04_init_surface_functions(struct nv04_context *nv04) -{ - nv04->pipe.surface_copy = nv04_surface_copy; - nv04->pipe.surface_fill = nv04_surface_fill; -} diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c deleted file mode 100644 index 42c2ca932d8..00000000000 --- a/src/gallium/drivers/nv04/nv04_surface_2d.c +++ /dev/null @@ -1,547 +0,0 @@ -#include "pipe/p_context.h" -#include "pipe/p_format.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" - -#include "nouveau/nouveau_winsys.h" -#include "nouveau/nouveau_util.h" -#include "nouveau/nouveau_screen.h" -#include "nv04_surface_2d.h" - -static INLINE int -nv04_surface_format(enum pipe_format format) -{ - switch (format) { - case PIPE_FORMAT_A8_UNORM: - case PIPE_FORMAT_L8_UNORM: - case PIPE_FORMAT_I8_UNORM: - return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8; - case PIPE_FORMAT_R16_SNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_Z16_UNORM: - case PIPE_FORMAT_A8L8_UNORM: - return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5; - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_A8R8G8B8_UNORM: - return NV04_CONTEXT_SURFACES_2D_FORMAT_A8R8G8B8; - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: - return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32; - default: - return -1; - } -} - -static INLINE int -nv04_rect_format(enum pipe_format format) -{ - switch (format) { - case PIPE_FORMAT_A8_UNORM: - return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8; - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_A8L8_UNORM: - case PIPE_FORMAT_Z16_UNORM: - return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5; - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: - return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8; - default: - return -1; - } -} - -static INLINE int -nv04_scaled_image_format(enum pipe_format format) -{ - switch (format) { - case PIPE_FORMAT_A8_UNORM: - case PIPE_FORMAT_L8_UNORM: - case PIPE_FORMAT_I8_UNORM: - return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_Y8; - case PIPE_FORMAT_A1R5G5B5_UNORM: - return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A1R5G5B5; - case PIPE_FORMAT_A8R8G8B8_UNORM: - return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A8R8G8B8; - case PIPE_FORMAT_X8R8G8B8_UNORM: - return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_X8R8G8B8; - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_R16_SNORM: - case PIPE_FORMAT_A8L8_UNORM: - return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_R5G6B5; - default: - return -1; - } -} - -static INLINE unsigned -nv04_swizzle_bits_square(unsigned x, unsigned y) -{ - unsigned u = (x & 0x001) << 0 | - (x & 0x002) << 1 | - (x & 0x004) << 2 | - (x & 0x008) << 3 | - (x & 0x010) << 4 | - (x & 0x020) << 5 | - (x & 0x040) << 6 | - (x & 0x080) << 7 | - (x & 0x100) << 8 | - (x & 0x200) << 9 | - (x & 0x400) << 10 | - (x & 0x800) << 11; - - unsigned v = (y & 0x001) << 1 | - (y & 0x002) << 2 | - (y & 0x004) << 3 | - (y & 0x008) << 4 | - (y & 0x010) << 5 | - (y & 0x020) << 6 | - (y & 0x040) << 7 | - (y & 0x080) << 8 | - (y & 0x100) << 9 | - (y & 0x200) << 10 | - (y & 0x400) << 11 | - (y & 0x800) << 12; - return v | u; -} - -/* rectangular swizzled textures are linear concatenations of swizzled square tiles */ -static INLINE unsigned -nv04_swizzle_bits(unsigned x, unsigned y, unsigned w, unsigned h) -{ - unsigned s = MIN2(w, h); - unsigned m = s - 1; - return (((x | y) & ~m) * s) | nv04_swizzle_bits_square(x & m, y & m); -} - -static int -nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx, - struct pipe_surface *dst, int dx, int dy, - struct pipe_surface *src, int sx, int sy, - int w, int h) -{ - struct nouveau_channel *chan = ctx->swzsurf->channel; - struct nouveau_grobj *swzsurf = ctx->swzsurf; - struct nouveau_grobj *sifm = ctx->sifm; - struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); - struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); - const unsigned src_pitch = ((struct nv04_surface *)src)->pitch; - /* Max width & height may not be the same on all HW, but must be POT */ - const unsigned max_w = 1024; - const unsigned max_h = 1024; - unsigned sub_w = w > max_w ? max_w : w; - unsigned sub_h = h > max_h ? max_h : h; - unsigned x; - unsigned y; - - /* Swizzled surfaces must be POT */ - assert(util_is_pot(dst->width) && util_is_pot(dst->height)); - - /* If area is too large to copy in one shot we must copy it in POT chunks to meet alignment requirements */ - assert(sub_w == w || util_is_pot(sub_w)); - assert(sub_h == h || util_is_pot(sub_h)); - - MARK_RING (chan, 8 + ((w+sub_w)/sub_w)*((h+sub_h)/sub_h)*17, 2 + - ((w+sub_w)/sub_w)*((h+sub_h)/sub_h)*2); - - BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_DMA_IMAGE, 1); - OUT_RELOCo(chan, dst_bo, - NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - - BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_FORMAT, 1); - OUT_RING (chan, nv04_surface_format(dst->format) | - log2i(dst->width) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_U_SHIFT | - log2i(dst->height) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_V_SHIFT); - - BEGIN_RING(chan, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, 1); - OUT_RELOCo(chan, src_bo, - NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); - BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SURFACE, 1); - OUT_RING (chan, swzsurf->handle); - - for (y = 0; y < h; y += sub_h) { - sub_h = MIN2(sub_h, h - y); - - for (x = 0; x < w; x += sub_w) { - sub_w = MIN2(sub_w, w - x); - - assert(!(dst->offset & 63)); - - BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_OFFSET, 1); - OUT_RELOCl(chan, dst_bo, dst->offset, - NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - - BEGIN_RING(chan, sifm, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9); - OUT_RING (chan, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE); - OUT_RING (chan, nv04_scaled_image_format(src->format)); - OUT_RING (chan, NV03_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY); - OUT_RING (chan, (x + dx) | ((y + dy) << NV03_SCALED_IMAGE_FROM_MEMORY_CLIP_POINT_Y_SHIFT)); - OUT_RING (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_CLIP_SIZE_H_SHIFT | sub_w); - OUT_RING (chan, (x + dx) | ((y + dy) << NV03_SCALED_IMAGE_FROM_MEMORY_OUT_POINT_Y_SHIFT)); - OUT_RING (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_OUT_SIZE_H_SHIFT | sub_w); - OUT_RING (chan, 1 << 20); - OUT_RING (chan, 1 << 20); - - BEGIN_RING(chan, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_SIZE, 4); - OUT_RING (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_SIZE_H_SHIFT | sub_w); - OUT_RING (chan, src_pitch | - NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER | - NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE); - OUT_RELOCl(chan, src_bo, src->offset + (sy+y) * src_pitch + (sx+x) * util_format_get_blocksize(src->texture->format), - NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); - OUT_RING (chan, 0); - } - } - - return 0; -} - -static int -nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx, - struct pipe_surface *dst, int dx, int dy, - struct pipe_surface *src, int sx, int sy, int w, int h) -{ - struct nouveau_channel *chan = ctx->m2mf->channel; - struct nouveau_grobj *m2mf = ctx->m2mf; - struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); - struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); - unsigned src_pitch = ((struct nv04_surface *)src)->pitch; - unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; - unsigned dst_offset = dst->offset + dy * dst_pitch + - dx * util_format_get_blocksize(dst->texture->format); - unsigned src_offset = src->offset + sy * src_pitch + - sx * util_format_get_blocksize(src->texture->format); - - MARK_RING (chan, 3 + ((h / 2047) + 1) * 9, 2 + ((h / 2047) + 1) * 2); - BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2); - OUT_RELOCo(chan, src_bo, - NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); - OUT_RELOCo(chan, dst_bo, - NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - - while (h) { - int count = (h > 2047) ? 2047 : h; - - BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8); - OUT_RELOCl(chan, src_bo, src_offset, - NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD); - OUT_RELOCl(chan, dst_bo, dst_offset, - NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_WR); - OUT_RING (chan, src_pitch); - OUT_RING (chan, dst_pitch); - OUT_RING (chan, w * util_format_get_blocksize(src->texture->format)); - OUT_RING (chan, count); - OUT_RING (chan, 0x0101); - OUT_RING (chan, 0); - - h -= count; - src_offset += src_pitch * count; - dst_offset += dst_pitch * count; - } - - return 0; -} - -static int -nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst, - int dx, int dy, struct pipe_surface *src, int sx, int sy, - int w, int h) -{ - struct nouveau_channel *chan = ctx->surf2d->channel; - struct nouveau_grobj *surf2d = ctx->surf2d; - struct nouveau_grobj *blit = ctx->blit; - struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); - struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); - unsigned src_pitch = ((struct nv04_surface *)src)->pitch; - unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; - int format; - - format = nv04_surface_format(dst->format); - if (format < 0) - return 1; - - MARK_RING (chan, 12, 4); - BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2); - OUT_RELOCo(chan, src_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); - OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4); - OUT_RING (chan, format); - OUT_RING (chan, (dst_pitch << 16) | src_pitch); - OUT_RELOCl(chan, src_bo, src->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); - OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - - BEGIN_RING(chan, blit, 0x0300, 3); - OUT_RING (chan, (sy << 16) | sx); - OUT_RING (chan, (dy << 16) | dx); - OUT_RING (chan, ( h << 16) | w); - - return 0; -} - -static void -nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst, - int dx, int dy, struct pipe_surface *src, int sx, int sy, - int w, int h) -{ - unsigned src_pitch = ((struct nv04_surface *)src)->pitch; - unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; - int src_linear = src->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR; - int dst_linear = dst->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR; - - assert(src->format == dst->format); - - /* Setup transfer to swizzle the texture to vram if needed */ - if (src_linear && !dst_linear && w > 1 && h > 1) { - nv04_surface_copy_swizzle(ctx, dst, dx, dy, src, sx, sy, w, h); - return; - } - - /* NV_CONTEXT_SURFACES_2D has buffer alignment restrictions, fallback - * to NV_MEMORY_TO_MEMORY_FORMAT in this case. - */ - if ((src->offset & 63) || (dst->offset & 63) || - (src_pitch & 63) || (dst_pitch & 63)) { - nv04_surface_copy_m2mf(ctx, dst, dx, dy, src, sx, sy, w, h); - return; - } - - nv04_surface_copy_blit(ctx, dst, dx, dy, src, sx, sy, w, h); -} - -static void -nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst, - int dx, int dy, int w, int h, unsigned value) -{ - struct nouveau_channel *chan = ctx->surf2d->channel; - struct nouveau_grobj *surf2d = ctx->surf2d; - struct nouveau_grobj *rect = ctx->rect; - struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); - unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; - int cs2d_format, gdirect_format; - - cs2d_format = nv04_surface_format(dst->format); - assert(cs2d_format >= 0); - - gdirect_format = nv04_rect_format(dst->format); - assert(gdirect_format >= 0); - - MARK_RING (chan, 16, 4); - BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2); - OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4); - OUT_RING (chan, cs2d_format); - OUT_RING (chan, (dst_pitch << 16) | dst_pitch); - OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - - BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT, 1); - OUT_RING (chan, gdirect_format); - BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR1_A, 1); - OUT_RING (chan, value); - BEGIN_RING(chan, rect, - NV04_GDI_RECTANGLE_TEXT_UNCLIPPED_RECTANGLE_POINT(0), 2); - OUT_RING (chan, (dx << 16) | dy); - OUT_RING (chan, ( w << 16) | h); -} - -void -nv04_surface_2d_takedown(struct nv04_surface_2d **pctx) -{ - struct nv04_surface_2d *ctx; - - if (!pctx || !*pctx) - return; - ctx = *pctx; - *pctx = NULL; - - nouveau_notifier_free(&ctx->ntfy); - nouveau_grobj_free(&ctx->m2mf); - nouveau_grobj_free(&ctx->surf2d); - nouveau_grobj_free(&ctx->swzsurf); - nouveau_grobj_free(&ctx->rect); - nouveau_grobj_free(&ctx->blit); - nouveau_grobj_free(&ctx->sifm); - - FREE(ctx); -} - -struct nv04_surface_2d * -nv04_surface_2d_init(struct nouveau_screen *screen) -{ - struct nv04_surface_2d *ctx = CALLOC_STRUCT(nv04_surface_2d); - struct nouveau_channel *chan = screen->channel; - unsigned handle = 0x88000000, class; - int ret; - - if (!ctx) - return NULL; - - ret = nouveau_notifier_alloc(chan, handle++, 1, &ctx->ntfy); - if (ret) { - nv04_surface_2d_takedown(&ctx); - return NULL; - } - - ret = nouveau_grobj_alloc(chan, handle++, 0x0039, &ctx->m2mf); - if (ret) { - nv04_surface_2d_takedown(&ctx); - return NULL; - } - - BEGIN_RING(chan, ctx->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1); - OUT_RING (chan, ctx->ntfy->handle); - - if (chan->device->chipset < 0x10) - class = NV04_CONTEXT_SURFACES_2D; - else - class = NV10_CONTEXT_SURFACES_2D; - - ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->surf2d); - if (ret) { - nv04_surface_2d_takedown(&ctx); - return NULL; - } - - BEGIN_RING(chan, ctx->surf2d, - NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2); - OUT_RING (chan, chan->vram->handle); - OUT_RING (chan, chan->vram->handle); - - if (chan->device->chipset < 0x10) - class = NV04_IMAGE_BLIT; - else - class = NV12_IMAGE_BLIT; - - ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->blit); - if (ret) { - nv04_surface_2d_takedown(&ctx); - return NULL; - } - - BEGIN_RING(chan, ctx->blit, NV01_IMAGE_BLIT_DMA_NOTIFY, 1); - OUT_RING (chan, ctx->ntfy->handle); - BEGIN_RING(chan, ctx->blit, NV04_IMAGE_BLIT_SURFACE, 1); - OUT_RING (chan, ctx->surf2d->handle); - BEGIN_RING(chan, ctx->blit, NV01_IMAGE_BLIT_OPERATION, 1); - OUT_RING (chan, NV01_IMAGE_BLIT_OPERATION_SRCCOPY); - - ret = nouveau_grobj_alloc(chan, handle++, NV04_GDI_RECTANGLE_TEXT, - &ctx->rect); - if (ret) { - nv04_surface_2d_takedown(&ctx); - return NULL; - } - - BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_DMA_NOTIFY, 1); - OUT_RING (chan, ctx->ntfy->handle); - BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_SURFACE, 1); - OUT_RING (chan, ctx->surf2d->handle); - BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1); - OUT_RING (chan, NV04_GDI_RECTANGLE_TEXT_OPERATION_SRCCOPY); - BEGIN_RING(chan, ctx->rect, - NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT, 1); - OUT_RING (chan, NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_LE); - - switch (chan->device->chipset & 0xf0) { - case 0x00: - case 0x10: - class = NV04_SWIZZLED_SURFACE; - break; - case 0x20: - class = NV20_SWIZZLED_SURFACE; - break; - case 0x30: - class = NV30_SWIZZLED_SURFACE; - break; - case 0x40: - case 0x60: - class = NV40_SWIZZLED_SURFACE; - break; - default: - /* Famous last words: this really can't happen.. */ - assert(0); - break; - } - - ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->swzsurf); - if (ret) { - nv04_surface_2d_takedown(&ctx); - return NULL; - } - - switch (chan->device->chipset & 0xf0) { - case 0x10: - case 0x20: - class = NV10_SCALED_IMAGE_FROM_MEMORY; - break; - case 0x30: - class = NV30_SCALED_IMAGE_FROM_MEMORY; - break; - case 0x40: - case 0x60: - class = NV40_SCALED_IMAGE_FROM_MEMORY; - break; - default: - class = NV04_SCALED_IMAGE_FROM_MEMORY; - break; - } - - ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->sifm); - if (ret) { - nv04_surface_2d_takedown(&ctx); - return NULL; - } - - ctx->copy = nv04_surface_copy; - ctx->fill = nv04_surface_fill; - return ctx; -} - -struct nv04_surface* -nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns) -{ - int temp_flags; - - // printf("creating temp, flags is %i!\n", flags); - - if(ns->base.usage & PIPE_BUFFER_USAGE_DISCARD) - { - temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ; - ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_DISCARD; - } - else - { - temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE; - ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_GPU_READ; - } - - struct nv40_screen* screen = (struct nv40_screen*)pscreen; - ns->base.usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE; - - struct pipe_texture templ; - memset(&templ, 0, sizeof(templ)); - templ.format = ns->base.texture->format; - templ.target = PIPE_TEXTURE_2D; - templ.width0 = ns->base.width; - templ.height0 = ns->base.height; - templ.depth0 = 1; - templ.last_level = 0; - - // TODO: this is probably wrong and we should specifically handle multisampling somehow once it is implemented - templ.nr_samples = ns->base.texture->nr_samples; - - templ.tex_usage = ns->base.texture->tex_usage | PIPE_TEXTURE_USAGE_RENDER_TARGET; - - struct pipe_texture* temp_tex = pscreen->texture_create(pscreen, &templ); - struct nv04_surface* temp_ns = (struct nv04_surface*)pscreen->get_tex_surface(pscreen, temp_tex, 0, 0, 0, temp_flags); - temp_ns->backing = ns; - - if(ns->base.usage & PIPE_BUFFER_USAGE_GPU_READ) - eng2d->copy(eng2d, &temp_ns->backing->base, 0, 0, &ns->base, 0, 0, ns->base.width, ns->base.height); - - return temp_ns; -} - diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.h b/src/gallium/drivers/nv04/nv04_surface_2d.h deleted file mode 100644 index ce696a11a39..00000000000 --- a/src/gallium/drivers/nv04/nv04_surface_2d.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef __NV04_SURFACE_2D_H__ -#define __NV04_SURFACE_2D_H__ - -struct nv04_surface { - struct pipe_surface base; - unsigned pitch; - struct nv04_surface* backing; -}; - -struct nv04_surface_2d { - struct nouveau_notifier *ntfy; - struct nouveau_grobj *surf2d; - struct nouveau_grobj *swzsurf; - struct nouveau_grobj *m2mf; - struct nouveau_grobj *rect; - struct nouveau_grobj *blit; - struct nouveau_grobj *sifm; - - struct pipe_buffer *(*buf)(struct pipe_surface *); - - void (*copy)(struct nv04_surface_2d *, struct pipe_surface *dst, - int dx, int dy, struct pipe_surface *src, int sx, int sy, - int w, int h); - void (*fill)(struct nv04_surface_2d *, struct pipe_surface *dst, - int dx, int dy, int w, int h, unsigned value); -}; - -struct nv04_surface_2d * -nv04_surface_2d_init(struct nouveau_screen *screen); - -void -nv04_surface_2d_takedown(struct nv04_surface_2d **); - -struct nv04_surface* -nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns); - -#endif diff --git a/src/gallium/drivers/nv04/nv04_transfer.c b/src/gallium/drivers/nv04/nv04_transfer.c deleted file mode 100644 index 2e151483851..00000000000 --- a/src/gallium/drivers/nv04/nv04_transfer.c +++ /dev/null @@ -1,178 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "nv04_context.h" -#include "nv04_screen.h" -#include "nv04_state.h" - -struct nv04_transfer { - struct pipe_transfer base; - struct pipe_surface *surface; - boolean direct; -}; - -static void -nv04_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height, - struct pipe_texture *template) -{ - memset(template, 0, sizeof(struct pipe_texture)); - template->target = pt->target; - template->format = pt->format; - template->width0 = width; - template->height0 = height; - template->depth0 = 1; - template->last_level = 0; - template->nr_samples = pt->nr_samples; - - template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC | - NOUVEAU_TEXTURE_USAGE_LINEAR; -} - -static struct pipe_transfer * -nv04_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt, - unsigned face, unsigned level, unsigned zslice, - enum pipe_transfer_usage usage, - unsigned x, unsigned y, unsigned w, unsigned h) -{ - struct nv04_miptree *mt = (struct nv04_miptree *)pt; - struct nv04_transfer *tx; - struct pipe_texture tx_tex_template, *tx_tex; - - tx = CALLOC_STRUCT(nv04_transfer); - if (!tx) - return NULL; - - pipe_texture_reference(&tx->base.texture, pt); - tx->base.x = x; - tx->base.y = y; - tx->base.width = w; - tx->base.height = h; - tx->base.stride = mt->level[level].pitch; - tx->base.usage = usage; - tx->base.face = face; - tx->base.level = level; - tx->base.zslice = zslice; - - /* Direct access to texture */ - if ((pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC || - debug_get_bool_option("NOUVEAU_NO_TRANSFER", TRUE/*XXX:FALSE*/)) && - pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) - { - tx->direct = true; - tx->surface = pscreen->get_tex_surface(pscreen, pt, - 0, 0, 0, - pipe_transfer_buffer_flags(&tx->base)); - return &tx->base; - } - - tx->direct = false; - - nv04_compatible_transfer_tex(pt, w, h, &tx_tex_template); - - tx_tex = pscreen->texture_create(pscreen, &tx_tex_template); - if (!tx_tex) - { - FREE(tx); - return NULL; - } - - tx->base.stride = ((struct nv04_miptree*)tx_tex)->level[0].pitch; - - tx->surface = pscreen->get_tex_surface(pscreen, tx_tex, - face, level, zslice, - pipe_transfer_buffer_flags(&tx->base)); - - pipe_texture_reference(&tx_tex, NULL); - - if (!tx->surface) - { - pipe_surface_reference(&tx->surface, NULL); - FREE(tx); - return NULL; - } - - if (usage & PIPE_TRANSFER_READ) { - struct nv04_screen *nvscreen = nv04_screen(pscreen); - struct pipe_surface *src; - - src = pscreen->get_tex_surface(pscreen, pt, - face, level, zslice, - PIPE_BUFFER_USAGE_GPU_READ); - - /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */ - /* TODO: Check if SIFM can un-swizzle */ - nvscreen->eng2d->copy(nvscreen->eng2d, - tx->surface, 0, 0, - src, x, y, - w, h); - - pipe_surface_reference(&src, NULL); - } - - return &tx->base; -} - -static void -nv04_transfer_del(struct pipe_transfer *ptx) -{ - struct nv04_transfer *tx = (struct nv04_transfer *)ptx; - - if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) { - struct pipe_screen *pscreen = ptx->texture->screen; - struct nv04_screen *nvscreen = nv04_screen(pscreen); - struct pipe_surface *dst; - - dst = pscreen->get_tex_surface(pscreen, ptx->texture, - ptx->face, ptx->level, ptx->zslice, - PIPE_BUFFER_USAGE_GPU_WRITE); - - /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */ - nvscreen->eng2d->copy(nvscreen->eng2d, - dst, tx->base.x, tx->base.y, - tx->surface, 0, 0, - tx->base.width, tx->base.height); - - pipe_surface_reference(&dst, NULL); - } - - pipe_surface_reference(&tx->surface, NULL); - pipe_texture_reference(&ptx->texture, NULL); - FREE(ptx); -} - -static void * -nv04_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx) -{ - struct nv04_transfer *tx = (struct nv04_transfer *)ptx; - struct nv04_surface *ns = (struct nv04_surface *)tx->surface; - struct nv04_miptree *mt = (struct nv04_miptree *)tx->surface->texture; - void *map = pipe_buffer_map(pscreen, mt->buffer, - pipe_transfer_buffer_flags(ptx)); - - if(!tx->direct) - return map + ns->base.offset; - else - return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format); -} - -static void -nv04_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx) -{ - struct nv04_transfer *tx = (struct nv04_transfer *)ptx; - struct nv04_miptree *mt = (struct nv04_miptree *)tx->surface->texture; - - pipe_buffer_unmap(pscreen, mt->buffer); -} - -void -nv04_screen_init_transfer_functions(struct pipe_screen *pscreen) -{ - pscreen->get_tex_transfer = nv04_transfer_new; - pscreen->tex_transfer_destroy = nv04_transfer_del; - pscreen->transfer_map = nv04_transfer_map; - pscreen->transfer_unmap = nv04_transfer_unmap; -} diff --git a/src/gallium/drivers/nv04/nv04_vbo.c b/src/gallium/drivers/nv04/nv04_vbo.c deleted file mode 100644 index 606ce65fabd..00000000000 --- a/src/gallium/drivers/nv04/nv04_vbo.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "draw/draw_context.h" -#include "pipe/p_context.h" -#include "pipe/p_state.h" -#include "util/u_inlines.h" - -#include "nv04_context.h" -#include "nv04_state.h" - -#include "nouveau/nouveau_channel.h" -#include "nouveau/nouveau_pushbuf.h" - -void nv04_draw_elements( struct pipe_context *pipe, - struct pipe_buffer *indexBuffer, - unsigned indexSize, - unsigned prim, unsigned start, unsigned count) -{ - struct pipe_screen *pscreen = pipe->screen; - struct nv04_context *nv04 = nv04_context( pipe ); - struct draw_context *draw = nv04->draw; - unsigned i; - - nv04_emit_hw_state(nv04); - - /* - * Map vertex buffers - */ - for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - if (nv04->vtxbuf[i].buffer) { - void *buf - = pipe_buffer_map(pscreen, - nv04->vtxbuf[i].buffer, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_vertex_buffer(draw, i, buf); - } - } - /* Map index buffer, if present */ - if (indexBuffer) { - void *mapped_indexes - = pipe_buffer_map(pscreen, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); - } - else { - /* no index/element buffer */ - draw_set_mapped_element_buffer(draw, 0, NULL); - } - - draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, - nv04->constbuf[PIPE_SHADER_VERTEX], - nv04->constbuf_nr[PIPE_SHADER_VERTEX]); - - /* draw! */ - draw_arrays(nv04->draw, prim, start, count); - - /* - * unmap vertex/index buffers - */ - for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - if (nv04->vtxbuf[i].buffer) { - pipe_buffer_unmap(pscreen, nv04->vtxbuf[i].buffer); - draw_set_mapped_vertex_buffer(draw, i, NULL); - } - } - if (indexBuffer) { - pipe_buffer_unmap(pscreen, indexBuffer); - draw_set_mapped_element_buffer(draw, 0, NULL); - } -} - -void nv04_draw_arrays( struct pipe_context *pipe, - unsigned prim, unsigned start, unsigned count) -{ - printf("coucou in draw arrays\n"); - nv04_draw_elements(pipe, NULL, 0, prim, start, count); -} - - - diff --git a/src/gallium/drivers/nv10/Makefile b/src/gallium/drivers/nv10/Makefile deleted file mode 100644 index 62677f5194a..00000000000 --- a/src/gallium/drivers/nv10/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../../../.. -include $(TOP)/configs/current - -LIBNAME = nv10 - -C_SOURCES = \ - nv10_clear.c \ - nv10_context.c \ - nv10_fragprog.c \ - nv10_fragtex.c \ - nv10_miptree.c \ - nv10_prim_vbuf.c \ - nv10_screen.c \ - nv10_state.c \ - nv10_state_emit.c \ - nv10_surface.c \ - nv10_transfer.c \ - nv10_vbo.c - -include ../../Makefile.template diff --git a/src/gallium/drivers/nv10/nv10_clear.c b/src/gallium/drivers/nv10/nv10_clear.c deleted file mode 100644 index a39a2b5f525..00000000000 --- a/src/gallium/drivers/nv10/nv10_clear.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_state.h" -#include "util/u_clear.h" - -#include "nv10_context.h" - -void -nv10_clear(struct pipe_context *pipe, unsigned buffers, - const float *rgba, double depth, unsigned stencil) -{ - util_clear(pipe, nv10_context(pipe)->framebuffer, buffers, rgba, depth, - stencil); -} diff --git a/src/gallium/drivers/nv10/nv10_context.c b/src/gallium/drivers/nv10/nv10_context.c deleted file mode 100644 index a3ceb1da948..00000000000 --- a/src/gallium/drivers/nv10/nv10_context.c +++ /dev/null @@ -1,298 +0,0 @@ -#include "draw/draw_context.h" -#include "pipe/p_defines.h" -#include "util/u_simple_screen.h" - -#include "nv10_context.h" -#include "nv10_screen.h" - -static void -nv10_flush(struct pipe_context *pipe, unsigned flags, - struct pipe_fence_handle **fence) -{ - struct nv10_context *nv10 = nv10_context(pipe); - struct nv10_screen *screen = nv10->screen; - struct nouveau_channel *chan = screen->base.channel; - - draw_flush(nv10->draw); - - FIRE_RING(chan); - if (fence) - *fence = NULL; -} - -static void -nv10_destroy(struct pipe_context *pipe) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - if (nv10->draw) - draw_destroy(nv10->draw); - - FREE(nv10); -} - -static void nv10_init_hwctx(struct nv10_context *nv10) -{ - struct nv10_screen *screen = nv10->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *celsius = screen->celsius; - int i; - float projectionmatrix[16]; - - BEGIN_RING(chan, celsius, NV10TCL_DMA_NOTIFY, 1); - OUT_RING (chan, screen->sync->handle); - BEGIN_RING(chan, celsius, NV10TCL_DMA_IN_MEMORY0, 2); - OUT_RING (chan, chan->vram->handle); - OUT_RING (chan, chan->gart->handle); - BEGIN_RING(chan, celsius, NV10TCL_DMA_IN_MEMORY2, 2); - OUT_RING (chan, chan->vram->handle); - OUT_RING (chan, chan->vram->handle); - - BEGIN_RING(chan, celsius, NV10TCL_NOP, 1); - OUT_RING (chan, 0); - - BEGIN_RING(chan, celsius, NV10TCL_RT_HORIZ, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - - BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(0), 1); - OUT_RING (chan, (0x7ff<<16)|0x800); - BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_VERT(0), 1); - OUT_RING (chan, (0x7ff<<16)|0x800); - - for (i=1;i<8;i++) { - BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(i), 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_VERT(i), 1); - OUT_RING (chan, 0); - } - - BEGIN_RING(chan, celsius, 0x290, 1); - OUT_RING (chan, (0x10<<16)|1); - BEGIN_RING(chan, celsius, 0x3f4, 1); - OUT_RING (chan, 0); - - BEGIN_RING(chan, celsius, NV10TCL_NOP, 1); - OUT_RING (chan, 0); - - if (nv10->screen->celsius->grclass != NV10TCL) { - /* For nv11, nv17 */ - BEGIN_RING(chan, celsius, 0x120, 3); - OUT_RING (chan, 0); - OUT_RING (chan, 1); - OUT_RING (chan, 2); - - BEGIN_RING(chan, celsius, NV10TCL_NOP, 1); - OUT_RING (chan, 0); - } - - BEGIN_RING(chan, celsius, NV10TCL_NOP, 1); - OUT_RING (chan, 0); - - /* Set state */ - BEGIN_RING(chan, celsius, NV10TCL_FOG_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_FUNC, 2); - OUT_RING (chan, 0x207); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_TX_ENABLE(0), 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - - BEGIN_RING(chan, celsius, NV10TCL_RC_IN_ALPHA(0), 12); - OUT_RING (chan, 0x30141010); - OUT_RING (chan, 0); - OUT_RING (chan, 0x20040000); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0x00000c00); - OUT_RING (chan, 0); - OUT_RING (chan, 0x00000c00); - OUT_RING (chan, 0x18000000); - OUT_RING (chan, 0x300e0300); - OUT_RING (chan, 0x0c091c80); - - BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_DITHER_ENABLE, 2); - OUT_RING (chan, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_VERTEX_WEIGHT_ENABLE, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_SRC, 4); - OUT_RING (chan, 1); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0x8006); - BEGIN_RING(chan, celsius, NV10TCL_STENCIL_MASK, 8); - OUT_RING (chan, 0xff); - OUT_RING (chan, 0x207); - OUT_RING (chan, 0); - OUT_RING (chan, 0xff); - OUT_RING (chan, 0x1e00); - OUT_RING (chan, 0x1e00); - OUT_RING (chan, 0x1e00); - OUT_RING (chan, 0x1d01); - BEGIN_RING(chan, celsius, NV10TCL_NORMALIZE_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_FOG_ENABLE, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_LIGHT_MODEL, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_SEPARATE_SPECULAR_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_ENABLED_LIGHTS, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_POLYGON_OFFSET_POINT_ENABLE, 3); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_DEPTH_FUNC, 1); - OUT_RING (chan, 0x201); - BEGIN_RING(chan, celsius, NV10TCL_DEPTH_WRITE_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_DEPTH_TEST_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_POLYGON_OFFSET_FACTOR, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_POINT_SIZE, 1); - OUT_RING (chan, 8); - BEGIN_RING(chan, celsius, NV10TCL_POINT_PARAMETERS_ENABLE, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_LINE_WIDTH, 1); - OUT_RING (chan, 8); - BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_POLYGON_MODE_FRONT, 2); - OUT_RING (chan, 0x1b02); - OUT_RING (chan, 0x1b02); - BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE, 2); - OUT_RING (chan, 0x405); - OUT_RING (chan, 0x901); - BEGIN_RING(chan, celsius, NV10TCL_POLYGON_SMOOTH_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_TX_GEN_S(0), 8); - for (i=0;i<8;i++) { - OUT_RING (chan, 0); - } - BEGIN_RING(chan, celsius, NV10TCL_FOG_EQUATION_CONSTANT, 3); - OUT_RING (chan, 0x3fc00000); /* -1.50 */ - OUT_RING (chan, 0xbdb8aa0a); /* -0.09 */ - OUT_RING (chan, 0); /* 0.00 */ - - BEGIN_RING(chan, celsius, NV10TCL_NOP, 1); - OUT_RING (chan, 0); - - BEGIN_RING(chan, celsius, NV10TCL_FOG_MODE, 2); - OUT_RING (chan, 0x802); - OUT_RING (chan, 2); - /* for some reason VIEW_MATRIX_ENABLE need to be 6 instead of 4 when - * using texturing, except when using the texture matrix - */ - BEGIN_RING(chan, celsius, NV10TCL_VIEW_MATRIX_ENABLE, 1); - OUT_RING (chan, 6); - BEGIN_RING(chan, celsius, NV10TCL_COLOR_MASK, 1); - OUT_RING (chan, 0x01010101); - - /* Set vertex component */ - BEGIN_RING(chan, celsius, NV10TCL_VERTEX_COL_4F_R, 4); - OUT_RINGf (chan, 1.0); - OUT_RINGf (chan, 1.0); - OUT_RINGf (chan, 1.0); - OUT_RINGf (chan, 1.0); - BEGIN_RING(chan, celsius, NV10TCL_VERTEX_COL2_3F_R, 3); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_VERTEX_NOR_3F_X, 3); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RINGf (chan, 1.0); - BEGIN_RING(chan, celsius, NV10TCL_VERTEX_TX0_4F_S, 4); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 1.0); - BEGIN_RING(chan, celsius, NV10TCL_VERTEX_TX1_4F_S, 4); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 1.0); - BEGIN_RING(chan, celsius, NV10TCL_VERTEX_FOG_1F, 1); - OUT_RINGf (chan, 0.0); - BEGIN_RING(chan, celsius, NV10TCL_EDGEFLAG_ENABLE, 1); - OUT_RING (chan, 1); - - memset(projectionmatrix, 0, sizeof(projectionmatrix)); - BEGIN_RING(chan, celsius, NV10TCL_PROJECTION_MATRIX(0), 16); - projectionmatrix[0*4+0] = 1.0; - projectionmatrix[1*4+1] = 1.0; - projectionmatrix[2*4+2] = 1.0; - projectionmatrix[3*4+3] = 1.0; - for (i=0;i<16;i++) { - OUT_RINGf (chan, projectionmatrix[i]); - } - - BEGIN_RING(chan, celsius, NV10TCL_DEPTH_RANGE_NEAR, 2); - OUT_RING (chan, 0.0); - OUT_RINGf (chan, 16777216.0); - - BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_TRANSLATE_X, 4); - OUT_RINGf (chan, -2048.0); - OUT_RINGf (chan, -2048.0); - OUT_RINGf (chan, 16777215.0 * 0.5); - OUT_RING (chan, 0); - - FIRE_RING (chan); -} - -struct pipe_context * -nv10_create(struct pipe_screen *pscreen, unsigned pctx_id) -{ - struct nv10_screen *screen = nv10_screen(pscreen); - struct pipe_winsys *ws = pscreen->winsys; - struct nv10_context *nv10; - struct nouveau_winsys *nvws = screen->nvws; - - nv10 = CALLOC(1, sizeof(struct nv10_context)); - if (!nv10) - return NULL; - nv10->screen = screen; - nv10->pctx_id = pctx_id; - - nv10->nvws = nvws; - - nv10->pipe.winsys = ws; - nv10->pipe.screen = pscreen; - nv10->pipe.destroy = nv10_destroy; - nv10->pipe.draw_arrays = nv10_draw_arrays; - nv10->pipe.draw_elements = nv10_draw_elements; - nv10->pipe.clear = nv10_clear; - nv10->pipe.flush = nv10_flush; - - nv10->pipe.is_texture_referenced = nouveau_is_texture_referenced; - nv10->pipe.is_buffer_referenced = nouveau_is_buffer_referenced; - - nv10_init_surface_functions(nv10); - nv10_init_state_functions(nv10); - - nv10->draw = draw_create(); - assert(nv10->draw); - draw_set_rasterize_stage(nv10->draw, nv10_draw_vbuf_stage(nv10)); - - nv10_init_hwctx(nv10); - - return &nv10->pipe; -} - diff --git a/src/gallium/drivers/nv10/nv10_context.h b/src/gallium/drivers/nv10/nv10_context.h deleted file mode 100644 index f0dcbe3fefd..00000000000 --- a/src/gallium/drivers/nv10/nv10_context.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef __NV10_CONTEXT_H__ -#define __NV10_CONTEXT_H__ - -#include - -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_state.h" -#include "pipe/p_compiler.h" - -#include "util/u_memory.h" -#include "util/u_math.h" - -#include "draw/draw_vertex.h" - -#include "nouveau/nouveau_winsys.h" -#include "nouveau/nouveau_gldefs.h" -#include "nouveau/nouveau_context.h" - -#include "nv10_state.h" - -#define NOUVEAU_ERR(fmt, args...) \ - fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args); -#define NOUVEAU_MSG(fmt, args...) \ - fprintf(stderr, "nouveau: "fmt, ##args); - -#define NV10_NEW_VERTPROG (1 << 0) -#define NV10_NEW_FRAGPROG (1 << 1) -#define NV10_NEW_VTXARRAYS (1 << 2) -#define NV10_NEW_BLEND (1 << 3) -#define NV10_NEW_BLENDCOL (1 << 4) -#define NV10_NEW_RAST (1 << 5) -#define NV10_NEW_DSA (1 << 6) -#define NV10_NEW_VIEWPORT (1 << 7) -#define NV10_NEW_SCISSOR (1 << 8) -#define NV10_NEW_FRAMEBUFFER (1 << 9) - -#include "nv10_screen.h" - -struct nv10_context { - struct pipe_context pipe; - - struct nouveau_winsys *nvws; - struct nv10_screen *screen; - unsigned pctx_id; - - struct draw_context *draw; - - uint32_t dirty; - - struct nv10_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS]; - struct nv10_miptree *tex_miptree[PIPE_MAX_SAMPLERS]; - unsigned dirty_samplers; - unsigned fp_samplers; - unsigned vp_samplers; - - uint32_t rt_enable; - struct pipe_buffer *rt[4]; - struct pipe_buffer *zeta; - uint32_t lma_offset; - - struct nv10_blend_state *blend; - struct pipe_blend_color *blend_color; - struct nv10_rasterizer_state *rast; - struct nv10_depth_stencil_alpha_state *dsa; - struct pipe_viewport_state *viewport; - struct pipe_scissor_state *scissor; - struct pipe_framebuffer_state *framebuffer; - - //struct pipe_buffer *constbuf[PIPE_SHADER_TYPES]; - float *constbuf[PIPE_SHADER_TYPES][32][4]; - unsigned constbuf_nr[PIPE_SHADER_TYPES]; - - struct vertex_info vertex_info; - - struct { - struct pipe_buffer *buffer; - uint32_t format; - } tex[2]; - - unsigned vb_enable; - struct { - struct pipe_buffer *buffer; - unsigned delta; - } vb[16]; - -/* struct { - - struct nouveau_resource *exec_heap; - struct nouveau_resource *data_heap; - - struct nv10_vertex_program *active; - - struct nv10_vertex_program *current; - } vertprog; -*/ - struct { - struct nv10_fragment_program *active; - - struct nv10_fragment_program *current; - struct pipe_buffer *constant_buf; - } fragprog; - - struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; - struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS]; -}; - -static INLINE struct nv10_context * -nv10_context(struct pipe_context *pipe) -{ - return (struct nv10_context *)pipe; -} - -extern void nv10_init_state_functions(struct nv10_context *nv10); -extern void nv10_init_surface_functions(struct nv10_context *nv10); - -extern void nv10_screen_init_miptree_functions(struct pipe_screen *pscreen); - -/* nv10_clear.c */ -extern void nv10_clear(struct pipe_context *pipe, unsigned buffers, - const float *rgba, double depth, unsigned stencil); - - -/* nv10_draw.c */ -extern struct draw_stage *nv10_draw_render_stage(struct nv10_context *nv10); - -/* nv10_fragprog.c */ -extern void nv10_fragprog_bind(struct nv10_context *, - struct nv10_fragment_program *); -extern void nv10_fragprog_destroy(struct nv10_context *, - struct nv10_fragment_program *); - -/* nv10_fragtex.c */ -extern void nv10_fragtex_bind(struct nv10_context *); - -/* nv10_prim_vbuf.c */ -struct draw_stage *nv10_draw_vbuf_stage( struct nv10_context *nv10 ); -extern void nv10_vtxbuf_bind(struct nv10_context* nv10); - -/* nv10_state.c and friends */ -extern void nv10_emit_hw_state(struct nv10_context *nv10); -extern void nv10_state_tex_update(struct nv10_context *nv10); - -/* nv10_vbo.c */ -extern void nv10_draw_arrays(struct pipe_context *, unsigned mode, - unsigned start, unsigned count); -extern void nv10_draw_elements( struct pipe_context *pipe, - struct pipe_buffer *indexBuffer, - unsigned indexSize, - unsigned prim, unsigned start, unsigned count); - - -#endif diff --git a/src/gallium/drivers/nv10/nv10_fragprog.c b/src/gallium/drivers/nv10/nv10_fragprog.c deleted file mode 100644 index 698db5a16a9..00000000000 --- a/src/gallium/drivers/nv10/nv10_fragprog.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_state.h" - -#include "pipe/p_shader_tokens.h" -#include "tgsi/tgsi_parse.h" -#include "tgsi/tgsi_util.h" - -#include "nv10_context.h" - -void -nv10_fragprog_bind(struct nv10_context *nv10, struct nv10_fragment_program *fp) -{ -} - -void -nv10_fragprog_destroy(struct nv10_context *nv10, - struct nv10_fragment_program *fp) -{ -} - diff --git a/src/gallium/drivers/nv10/nv10_fragtex.c b/src/gallium/drivers/nv10/nv10_fragtex.c deleted file mode 100644 index c1f7ccb9ab6..00000000000 --- a/src/gallium/drivers/nv10/nv10_fragtex.c +++ /dev/null @@ -1,130 +0,0 @@ -#include "nv10_context.h" -#include "nouveau/nouveau_util.h" - -#define _(m,tf) \ -{ \ - TRUE, \ - PIPE_FORMAT_##m, \ - NV10TCL_TX_FORMAT_FORMAT_##tf, \ -} - -struct nv10_texture_format { - boolean defined; - uint pipe; - int format; -}; - -static struct nv10_texture_format -nv10_texture_formats[] = { - _(A8R8G8B8_UNORM, A8R8G8B8), - _(A1R5G5B5_UNORM, A1R5G5B5), - _(A4R4G4B4_UNORM, A4R4G4B4), - _(L8_UNORM , L8 ), - _(A8_UNORM , A8 ), - _(A8L8_UNORM , A8L8 ), -// _(RGB_DXT1 , DXT1, ), -// _(RGBA_DXT1 , DXT1, ), -// _(RGBA_DXT3 , DXT3, ), -// _(RGBA_DXT5 , DXT5, ), - {}, -}; - -static struct nv10_texture_format * -nv10_fragtex_format(uint pipe_format) -{ - struct nv10_texture_format *tf = nv10_texture_formats; - - while (tf->defined) { - if (tf->pipe == pipe_format) - return tf; - tf++; - } - - return NULL; -} - - -static void -nv10_fragtex_build(struct nv10_context *nv10, int unit) -{ -#if 0 - struct nv10_sampler_state *ps = nv10->tex_sampler[unit]; - struct nv10_miptree *nv10mt = nv10->tex_miptree[unit]; - struct pipe_texture *pt = &nv10mt->base; - struct nv10_texture_format *tf; - struct nv10_screen *screen = nv10->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *celsius = screen->celsius; - uint32_t txf, txs, txp; - - tf = nv10_fragtex_format(pt->format); - if (!tf || !tf->defined) { - NOUVEAU_ERR("Unsupported texture format: 0x%x\n", pt->format); - return; - } - - txf = tf->format << 8; - txf |= (pt->last_level + 1) << 16; - txf |= log2i(pt->width0) << 20; - txf |= log2i(pt->height0) << 24; - txf |= log2i(pt->depth0) << 28; - txf |= 8; - - switch (pt->target) { - case PIPE_TEXTURE_CUBE: - txf |= NV10TCL_TX_FORMAT_CUBE_MAP; - /* fall-through */ - case PIPE_TEXTURE_2D: - txf |= (2<<4); - break; - case PIPE_TEXTURE_1D: - txf |= (1<<4); - break; - default: - NOUVEAU_ERR("Unknown target %d\n", pt->target); - return; - } - - BEGIN_RING(chan, celsius, NV10TCL_TX_OFFSET(unit), 8); - OUT_RELOCl(chan, nouveau_bo(nv10mt->buffer), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD); - OUT_RELOCd(chan, nouveau_bo(nv10mt->buffer),txf,NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/); - OUT_RING (chan, ps->wrap); - OUT_RING (chan, 0x40000000); /* enable */ - OUT_RING (chan, txs); - OUT_RING (chan, ps->filt | 0x2000 /* magic */); - OUT_RING (chan, (pt->width0 << 16) | pt->height0); - OUT_RING (chan, ps->bcol); -#endif -} - -void -nv10_fragtex_bind(struct nv10_context *nv10) -{ -#if 0 - struct nv10_fragment_program *fp = nv10->fragprog.active; - struct nv10_screen *screen = nv10->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *celsius = screen->celsius; - unsigned samplers, unit; - - samplers = nv10->fp_samplers & ~fp->samplers; - while (samplers) { - unit = ffs(samplers) - 1; - samplers &= ~(1 << unit); - - BEGIN_RING(chan, celsius, NV10TCL_TX_ENABLE(unit), 1); - OUT_RING (chan, 0); - } - - samplers = nv10->dirty_samplers & fp->samplers; - while (samplers) { - unit = ffs(samplers) - 1; - samplers &= ~(1 << unit); - - nv10_fragtex_build(nv10, unit); - } - - nv10->fp_samplers = fp->samplers; -#endif -} - diff --git a/src/gallium/drivers/nv10/nv10_miptree.c b/src/gallium/drivers/nv10/nv10_miptree.c deleted file mode 100644 index 55bd6f76b3e..00000000000 --- a/src/gallium/drivers/nv10/nv10_miptree.c +++ /dev/null @@ -1,165 +0,0 @@ -#include "pipe/p_state.h" -#include "pipe/p_defines.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" - -#include "nv10_context.h" -#include "nv10_screen.h" - -static void -nv10_miptree_layout(struct nv10_miptree *nv10mt) -{ - struct pipe_texture *pt = &nv10mt->base; - boolean swizzled = FALSE; - uint width = pt->width0; - uint offset = 0; - int nr_faces, l, f; - - if (pt->target == PIPE_TEXTURE_CUBE) { - nr_faces = 6; - } else { - nr_faces = 1; - } - - for (l = 0; l <= pt->last_level; l++) { - if (swizzled) - nv10mt->level[l].pitch = util_format_get_stride(pt->format, width); - else - nv10mt->level[l].pitch = util_format_get_stride(pt->format, pt->width0); - nv10mt->level[l].pitch = (nv10mt->level[l].pitch + 63) & ~63; - - nv10mt->level[l].image_offset = - CALLOC(nr_faces, sizeof(unsigned)); - - width = u_minify(width, 1); - - } - - for (f = 0; f < nr_faces; f++) { - for (l = 0; l <= pt->last_level; l++) { - nv10mt->level[l].image_offset[f] = offset; - offset += nv10mt->level[l].pitch * u_minify(pt->height0, l); - } - } - - nv10mt->total_size = offset; -} - -static struct pipe_texture * -nv10_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt, - const unsigned *stride, struct pipe_buffer *pb) -{ - struct nv10_miptree *mt; - - /* Only supports 2D, non-mipmapped textures for the moment */ - if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 || - pt->depth0 != 1) - return NULL; - - mt = CALLOC_STRUCT(nv10_miptree); - if (!mt) - return NULL; - - mt->base = *pt; - pipe_reference_init(&mt->base.reference, 1); - mt->base.screen = pscreen; - mt->level[0].pitch = stride[0]; - mt->level[0].image_offset = CALLOC(1, sizeof(unsigned)); - - pipe_buffer_reference(&mt->buffer, pb); - mt->bo = nouveau_bo(mt->buffer); - return &mt->base; -} - -static struct pipe_texture * -nv10_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt) -{ - struct nv10_miptree *mt; - - mt = MALLOC(sizeof(struct nv10_miptree)); - if (!mt) - return NULL; - mt->base = *pt; - pipe_reference_init(&mt->base.reference, 1); - mt->base.screen = screen; - - nv10_miptree_layout(mt); - - mt->buffer = screen->buffer_create(screen, 256, PIPE_BUFFER_USAGE_PIXEL, - mt->total_size); - if (!mt->buffer) { - FREE(mt); - return NULL; - } - mt->bo = nouveau_bo(mt->buffer); - - return &mt->base; -} - -static void -nv10_miptree_destroy(struct pipe_texture *pt) -{ - struct nv10_miptree *nv10mt = (struct nv10_miptree *)pt; - int l; - - pipe_buffer_reference(&nv10mt->buffer, NULL); - for (l = 0; l <= pt->last_level; l++) { - if (nv10mt->level[l].image_offset) - FREE(nv10mt->level[l].image_offset); - } - FREE(nv10mt); -} - -static void -nv10_miptree_update(struct pipe_context *pipe, struct pipe_texture *mt, - uint face, uint levels) -{ -} - - -static struct pipe_surface * -nv10_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt, - unsigned face, unsigned level, unsigned zslice, - unsigned flags) -{ - struct nv10_miptree *nv10mt = (struct nv10_miptree *)pt; - struct nv04_surface *ns; - - ns = CALLOC_STRUCT(nv04_surface); - if (!ns) - return NULL; - pipe_texture_reference(&ns->base.texture, pt); - ns->base.format = pt->format; - ns->base.width = u_minify(pt->width0, level); - ns->base.height = u_minify(pt->height0, level); - ns->base.usage = flags; - pipe_reference_init(&ns->base.reference, 1); - ns->base.face = face; - ns->base.level = level; - ns->base.zslice = zslice; - ns->pitch = nv10mt->level[level].pitch; - - if (pt->target == PIPE_TEXTURE_CUBE) { - ns->base.offset = nv10mt->level[level].image_offset[face]; - } else { - ns->base.offset = nv10mt->level[level].image_offset[0]; - } - - return &ns->base; -} - -static void -nv10_miptree_surface_destroy(struct pipe_surface *surface) -{ -} - -void nv10_screen_init_miptree_functions(struct pipe_screen *pscreen) -{ - pscreen->texture_create = nv10_miptree_create; - pscreen->texture_blanket = nv10_miptree_blanket; - pscreen->texture_destroy = nv10_miptree_destroy; - pscreen->get_tex_surface = nv10_miptree_surface_get; - pscreen->tex_surface_destroy = nv10_miptree_surface_destroy; -} - diff --git a/src/gallium/drivers/nv10/nv10_prim_vbuf.c b/src/gallium/drivers/nv10/nv10_prim_vbuf.c deleted file mode 100644 index 0309465ab8d..00000000000 --- a/src/gallium/drivers/nv10/nv10_prim_vbuf.c +++ /dev/null @@ -1,267 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/** - * \file - * Build post-transformation, post-clipping vertex buffers and element - * lists by hooking into the end of the primitive pipeline and - * manipulating the vertex_id field in the vertex headers. - * - * XXX: work in progress - * - * \author José Fonseca - * \author Keith Whitwell - */ - - -#include "util/u_debug.h" -#include "util/u_inlines.h" - -#include "nv10_context.h" -#include "nv10_state.h" - -#include "draw/draw_vbuf.h" - -/** - * Primitive renderer for nv10. - */ -struct nv10_vbuf_render { - struct vbuf_render base; - - struct nv10_context *nv10; - - /** Vertex buffer */ - struct pipe_buffer* buffer; - - /** Vertex size in bytes */ - unsigned vertex_size; - - /** Hardware primitive */ - unsigned hwprim; -}; - - -void nv10_vtxbuf_bind( struct nv10_context* nv10 ) -{ - struct nv10_screen *screen = nv10->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *celsius = screen->celsius; - int i; - for(i = 0; i < 8; i++) { - BEGIN_RING(chan, celsius, NV10TCL_VTXBUF_ADDRESS(i), 1); - OUT_RING(chan, 0/*nv10->vtxbuf*/); - BEGIN_RING(chan, celsius, NV10TCL_VTXFMT(i), 1); - OUT_RING(chan, 0/*XXX*/); - } -} - -/** - * Basically a cast wrapper. - */ -static INLINE struct nv10_vbuf_render * -nv10_vbuf_render( struct vbuf_render *render ) -{ - assert(render); - return (struct nv10_vbuf_render *)render; -} - - -static const struct vertex_info * -nv10_vbuf_render_get_vertex_info( struct vbuf_render *render ) -{ - struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); - struct nv10_context *nv10 = nv10_render->nv10; - - nv10_emit_hw_state(nv10); - - return &nv10->vertex_info; -} - -static boolean -nv10_vbuf_render_allocate_vertices( struct vbuf_render *render, - ushort vertex_size, - ushort nr_vertices ) -{ - struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); - struct nv10_context *nv10 = nv10_render->nv10; - struct pipe_screen *screen = nv10->pipe.screen; - size_t size = (size_t)vertex_size * (size_t)nr_vertices; - - assert(!nv10_render->buffer); - nv10_render->buffer = screen->buffer_create(screen, 64, PIPE_BUFFER_USAGE_VERTEX, size); - - nv10->dirty |= NV10_NEW_VTXARRAYS; - - if (nv10_render->buffer) - return FALSE; - return TRUE; -} - -static void * -nv10_vbuf_render_map_vertices( struct vbuf_render *render ) -{ - struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); - struct nv10_context *nv10 = nv10_render->nv10; - struct pipe_screen *pscreen = nv10->pipe.screen; - - return pipe_buffer_map(pscreen, nv10_render->buffer, - PIPE_BUFFER_USAGE_CPU_WRITE); -} - -static void -nv10_vbuf_render_unmap_vertices( struct vbuf_render *render, - ushort min_index, - ushort max_index ) -{ - struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); - struct nv10_context *nv10 = nv10_render->nv10; - struct pipe_screen *pscreen = nv10->pipe.screen; - - assert(!nv10_render->buffer); - pipe_buffer_unmap(pscreen, nv10_render->buffer); -} - -static boolean -nv10_vbuf_render_set_primitive( struct vbuf_render *render, - unsigned prim ) -{ - struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); - unsigned hwp = nvgl_primitive(prim); - if (hwp == 0) - return FALSE; - - nv10_render->hwprim = hwp; - return TRUE; -} - - -static void -nv10_vbuf_render_draw( struct vbuf_render *render, - const ushort *indices, - uint nr_indices) -{ - struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); - struct nv10_context *nv10 = nv10_render->nv10; - struct nv10_screen *screen = nv10->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *celsius = screen->celsius; - int push, i; - - nv10_emit_hw_state(nv10); - - BEGIN_RING(chan, celsius, NV10TCL_VERTEX_ARRAY_OFFSET_POS, 1); - OUT_RELOCl(chan, nouveau_bo(nv10_render->buffer), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD); - - BEGIN_RING(chan, celsius, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1); - OUT_RING(chan, nv10_render->hwprim); - - if (nr_indices & 1) { - BEGIN_RING(chan, celsius, NV10TCL_VB_ELEMENT_U32, 1); - OUT_RING (chan, indices[0]); - indices++; nr_indices--; - } - - while (nr_indices) { - // XXX too big/small ? check the size - push = MIN2(nr_indices, 1200 * 2); - - BEGIN_RING_NI(chan, celsius, NV10TCL_VB_ELEMENT_U16, push >> 1); - for (i = 0; i < push; i+=2) - OUT_RING(chan, (indices[i+1] << 16) | indices[i]); - - nr_indices -= push; - indices += push; - } - - BEGIN_RING(chan, celsius, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1); - OUT_RING (chan, 0); -} - - -static void -nv10_vbuf_render_release_vertices( struct vbuf_render *render ) -{ - struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); - - assert(nv10_render->buffer); - pipe_buffer_reference(&nv10_render->buffer, NULL); -} - - -static void -nv10_vbuf_render_destroy( struct vbuf_render *render ) -{ - struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); - FREE(nv10_render); -} - - -/** - * Create a new primitive render. - */ -static struct vbuf_render * -nv10_vbuf_render_create( struct nv10_context *nv10 ) -{ - struct nv10_vbuf_render *nv10_render = CALLOC_STRUCT(nv10_vbuf_render); - - nv10_render->nv10 = nv10; - - nv10_render->base.max_vertex_buffer_bytes = 16*1024; - nv10_render->base.max_indices = 1024; - nv10_render->base.get_vertex_info = nv10_vbuf_render_get_vertex_info; - nv10_render->base.allocate_vertices = nv10_vbuf_render_allocate_vertices; - nv10_render->base.map_vertices = nv10_vbuf_render_map_vertices; - nv10_render->base.unmap_vertices = nv10_vbuf_render_unmap_vertices; - nv10_render->base.set_primitive = nv10_vbuf_render_set_primitive; - nv10_render->base.draw = nv10_vbuf_render_draw; - nv10_render->base.release_vertices = nv10_vbuf_render_release_vertices; - nv10_render->base.destroy = nv10_vbuf_render_destroy; - - return &nv10_render->base; -} - - -/** - * Create a new primitive vbuf/render stage. - */ -struct draw_stage *nv10_draw_vbuf_stage( struct nv10_context *nv10 ) -{ - struct vbuf_render *render; - struct draw_stage *stage; - - render = nv10_vbuf_render_create(nv10); - if(!render) - return NULL; - - stage = draw_vbuf_stage( nv10->draw, render ); - if(!stage) { - render->destroy(render); - return NULL; - } - - return stage; -} diff --git a/src/gallium/drivers/nv10/nv10_screen.c b/src/gallium/drivers/nv10/nv10_screen.c deleted file mode 100644 index 4e6bc129943..00000000000 --- a/src/gallium/drivers/nv10/nv10_screen.c +++ /dev/null @@ -1,208 +0,0 @@ -#include "pipe/p_screen.h" - -#include "nv10_context.h" -#include "nv10_screen.h" - -static int -nv10_screen_get_param(struct pipe_screen *screen, int param) -{ - switch (param) { - case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: - return 2; - case PIPE_CAP_NPOT_TEXTURES: - return 0; - case PIPE_CAP_TWO_SIDED_STENCIL: - return 0; - case PIPE_CAP_GLSL: - return 0; - case PIPE_CAP_ANISOTROPIC_FILTER: - return 1; - case PIPE_CAP_POINT_SPRITE: - return 0; - case PIPE_CAP_MAX_RENDER_TARGETS: - return 1; - case PIPE_CAP_OCCLUSION_QUERY: - return 0; - case PIPE_CAP_TEXTURE_SHADOW_MAP: - return 0; - case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: - return 12; - case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: - return 0; - case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: - return 12; - case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS: - return 0; - case PIPE_CAP_TGSI_CONT_SUPPORTED: - return 0; - case PIPE_CAP_BLEND_EQUATION_SEPARATE: - return 0; - case NOUVEAU_CAP_HW_VTXBUF: - case NOUVEAU_CAP_HW_IDXBUF: - return 0; - case PIPE_CAP_INDEP_BLEND_ENABLE: - return 0; - case PIPE_CAP_INDEP_BLEND_FUNC: - return 0; - case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: - case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: - return 1; - case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: - case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: - return 0; - default: - NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); - return 0; - } -} - -static float -nv10_screen_get_paramf(struct pipe_screen *screen, int param) -{ - switch (param) { - case PIPE_CAP_MAX_LINE_WIDTH: - case PIPE_CAP_MAX_LINE_WIDTH_AA: - return 10.0; - case PIPE_CAP_MAX_POINT_WIDTH: - case PIPE_CAP_MAX_POINT_WIDTH_AA: - return 64.0; - case PIPE_CAP_MAX_TEXTURE_ANISOTROPY: - return 2.0; - case PIPE_CAP_MAX_TEXTURE_LOD_BIAS: - return 4.0; - default: - NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); - return 0.0; - } -} - -static boolean -nv10_screen_is_format_supported(struct pipe_screen *screen, - enum pipe_format format, - enum pipe_texture_target target, - unsigned tex_usage, unsigned geom_flags) -{ - if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) { - switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - return TRUE; - default: - break; - } - } else - if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) { - switch (format) { - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z16_UNORM: - return TRUE; - default: - break; - } - } else { - switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_A1R5G5B5_UNORM: - case PIPE_FORMAT_A4R4G4B4_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_L8_UNORM: - case PIPE_FORMAT_A8_UNORM: - case PIPE_FORMAT_I8_UNORM: - return TRUE; - default: - break; - } - } - - return FALSE; -} - -static void -nv10_screen_destroy(struct pipe_screen *pscreen) -{ - struct nv10_screen *screen = nv10_screen(pscreen); - - nouveau_notifier_free(&screen->sync); - nouveau_grobj_free(&screen->celsius); - nv04_surface_2d_takedown(&screen->eng2d); - - nouveau_screen_fini(&screen->base); - - FREE(pscreen); -} - -static struct pipe_buffer * -nv10_surface_buffer(struct pipe_surface *surf) -{ - struct nv10_miptree *mt = (struct nv10_miptree *)surf->texture; - - return mt->buffer; -} - -struct pipe_screen * -nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) -{ - struct nv10_screen *screen = CALLOC_STRUCT(nv10_screen); - struct nouveau_channel *chan; - struct pipe_screen *pscreen; - unsigned celsius_class; - int ret; - - if (!screen) - return NULL; - pscreen = &screen->base.base; - - ret = nouveau_screen_init(&screen->base, dev); - if (ret) { - nv10_screen_destroy(pscreen); - return NULL; - } - chan = screen->base.channel; - - pscreen->winsys = ws; - pscreen->destroy = nv10_screen_destroy; - pscreen->get_param = nv10_screen_get_param; - pscreen->get_paramf = nv10_screen_get_paramf; - pscreen->is_format_supported = nv10_screen_is_format_supported; - - nv10_screen_init_miptree_functions(pscreen); - nv10_screen_init_transfer_functions(pscreen); - - /* 3D object */ - if (dev->chipset >= 0x20) - celsius_class = NV11TCL; - else if (dev->chipset >= 0x17) - celsius_class = NV17TCL; - else if (dev->chipset >= 0x11) - celsius_class = NV11TCL; - else - celsius_class = NV10TCL; - - if (!celsius_class) { - NOUVEAU_ERR("Unknown nv1x chipset: nv%02x\n", dev->chipset); - return NULL; - } - - ret = nouveau_grobj_alloc(chan, 0xbeef0001, celsius_class, - &screen->celsius); - if (ret) { - NOUVEAU_ERR("Error creating 3D object: %d\n", ret); - return FALSE; - } - - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(&screen->base); - screen->eng2d->buf = nv10_surface_buffer; - - /* Notifier for sync purposes */ - ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); - if (ret) { - NOUVEAU_ERR("Error creating notifier object: %d\n", ret); - nv10_screen_destroy(pscreen); - return NULL; - } - - return pscreen; -} - diff --git a/src/gallium/drivers/nv10/nv10_screen.h b/src/gallium/drivers/nv10/nv10_screen.h deleted file mode 100644 index 86b6d8def54..00000000000 --- a/src/gallium/drivers/nv10/nv10_screen.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __NV10_SCREEN_H__ -#define __NV10_SCREEN_H__ - -#include "nouveau/nouveau_screen.h" -#include "nv04/nv04_surface_2d.h" - -struct nv10_screen { - struct nouveau_screen base; - - struct nouveau_winsys *nvws; - - /* HW graphics objects */ - struct nv04_surface_2d *eng2d; - struct nouveau_grobj *celsius; - struct nouveau_notifier *sync; -}; - -static INLINE struct nv10_screen * -nv10_screen(struct pipe_screen *screen) -{ - return (struct nv10_screen *)screen; -} - - -void -nv10_screen_init_transfer_functions(struct pipe_screen *pscreen); - -#endif diff --git a/src/gallium/drivers/nv10/nv10_state.c b/src/gallium/drivers/nv10/nv10_state.c deleted file mode 100644 index 11e23b21c5c..00000000000 --- a/src/gallium/drivers/nv10/nv10_state.c +++ /dev/null @@ -1,590 +0,0 @@ -#include "draw/draw_context.h" -#include "pipe/p_state.h" -#include "pipe/p_defines.h" -#include "pipe/p_shader_tokens.h" -#include "util/u_inlines.h" - -#include "tgsi/tgsi_parse.h" - -#include "nv10_context.h" -#include "nv10_state.h" - -static void * -nv10_blend_state_create(struct pipe_context *pipe, - const struct pipe_blend_state *cso) -{ - struct nv10_blend_state *cb; - - cb = MALLOC(sizeof(struct nv10_blend_state)); - - cb->b_enable = cso->rt[0].blend_enable ? 1 : 0; - cb->b_srcfunc = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) | - (nvgl_blend_func(cso->rt[0].rgb_src_factor))); - cb->b_dstfunc = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) | - (nvgl_blend_func(cso->rt[0].rgb_dst_factor))); - - cb->c_mask = (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01<<24) : 0) | - ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01<<16) : 0) | - ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01<< 8) : 0) | - ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01<< 0) : 0)); - - cb->d_enable = cso->dither ? 1 : 0; - - return (void *)cb; -} - -static void -nv10_blend_state_bind(struct pipe_context *pipe, void *blend) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - nv10->blend = (struct nv10_blend_state*)blend; - - nv10->dirty |= NV10_NEW_BLEND; -} - -static void -nv10_blend_state_delete(struct pipe_context *pipe, void *hwcso) -{ - FREE(hwcso); -} - - -static INLINE unsigned -wrap_mode(unsigned wrap) { - unsigned ret; - - switch (wrap) { - case PIPE_TEX_WRAP_REPEAT: - ret = NV10TCL_TX_FORMAT_WRAP_S_REPEAT; - break; - case PIPE_TEX_WRAP_MIRROR_REPEAT: - ret = NV10TCL_TX_FORMAT_WRAP_S_MIRRORED_REPEAT; - break; - case PIPE_TEX_WRAP_CLAMP_TO_EDGE: - ret = NV10TCL_TX_FORMAT_WRAP_S_CLAMP_TO_EDGE; - break; - case PIPE_TEX_WRAP_CLAMP_TO_BORDER: - ret = NV10TCL_TX_FORMAT_WRAP_S_CLAMP_TO_BORDER; - break; - case PIPE_TEX_WRAP_CLAMP: - ret = NV10TCL_TX_FORMAT_WRAP_S_CLAMP; - break; - case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: - case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: - case PIPE_TEX_WRAP_MIRROR_CLAMP: - default: - NOUVEAU_ERR("unknown wrap mode: %d\n", wrap); - ret = NV10TCL_TX_FORMAT_WRAP_S_REPEAT; - break; - } - - return ret >> NV10TCL_TX_FORMAT_WRAP_S_SHIFT; -} - -static void * -nv10_sampler_state_create(struct pipe_context *pipe, - const struct pipe_sampler_state *cso) -{ - struct nv10_sampler_state *ps; - uint32_t filter = 0; - - ps = MALLOC(sizeof(struct nv10_sampler_state)); - - ps->wrap = ((wrap_mode(cso->wrap_s) << NV10TCL_TX_FORMAT_WRAP_S_SHIFT) | - (wrap_mode(cso->wrap_t) << NV10TCL_TX_FORMAT_WRAP_T_SHIFT)); - - ps->en = 0; - if (cso->max_anisotropy > 1.0) { - /* no idea, binary driver sets it, works without it.. meh.. */ - ps->wrap |= (1 << 5); - -/* if (cso->max_anisotropy >= 16.0) { - ps->en |= NV10TCL_TX_ENABLE_ANISO_16X; - } else - if (cso->max_anisotropy >= 12.0) { - ps->en |= NV10TCL_TX_ENABLE_ANISO_12X; - } else - if (cso->max_anisotropy >= 10.0) { - ps->en |= NV10TCL_TX_ENABLE_ANISO_10X; - } else - if (cso->max_anisotropy >= 8.0) { - ps->en |= NV10TCL_TX_ENABLE_ANISO_8X; - } else - if (cso->max_anisotropy >= 6.0) { - ps->en |= NV10TCL_TX_ENABLE_ANISO_6X; - } else - if (cso->max_anisotropy >= 4.0) { - ps->en |= NV10TCL_TX_ENABLE_ANISO_4X; - } else { - ps->en |= NV10TCL_TX_ENABLE_ANISO_2X; - }*/ - } - - switch (cso->mag_img_filter) { - case PIPE_TEX_FILTER_LINEAR: - filter |= NV10TCL_TX_FILTER_MAGNIFY_LINEAR; - break; - case PIPE_TEX_FILTER_NEAREST: - default: - filter |= NV10TCL_TX_FILTER_MAGNIFY_NEAREST; - break; - } - - switch (cso->min_img_filter) { - case PIPE_TEX_FILTER_LINEAR: - switch (cso->min_mip_filter) { - case PIPE_TEX_MIPFILTER_NEAREST: - filter |= NV10TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST; - break; - case PIPE_TEX_MIPFILTER_LINEAR: - filter |= NV10TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR; - break; - case PIPE_TEX_MIPFILTER_NONE: - default: - filter |= NV10TCL_TX_FILTER_MINIFY_LINEAR; - break; - } - break; - case PIPE_TEX_FILTER_NEAREST: - default: - switch (cso->min_mip_filter) { - case PIPE_TEX_MIPFILTER_NEAREST: - filter |= NV10TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST; - break; - case PIPE_TEX_MIPFILTER_LINEAR: - filter |= NV10TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR; - break; - case PIPE_TEX_MIPFILTER_NONE: - default: - filter |= NV10TCL_TX_FILTER_MINIFY_NEAREST; - break; - } - break; - } - - ps->filt = filter; - -/* if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { - switch (cso->compare_func) { - case PIPE_FUNC_NEVER: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_NEVER; - break; - case PIPE_FUNC_GREATER: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_GREATER; - break; - case PIPE_FUNC_EQUAL: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_EQUAL; - break; - case PIPE_FUNC_GEQUAL: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_GEQUAL; - break; - case PIPE_FUNC_LESS: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_LESS; - break; - case PIPE_FUNC_NOTEQUAL: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_NOTEQUAL; - break; - case PIPE_FUNC_LEQUAL: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_LEQUAL; - break; - case PIPE_FUNC_ALWAYS: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_ALWAYS; - break; - default: - break; - } - }*/ - - ps->bcol = ((float_to_ubyte(cso->border_color[3]) << 24) | - (float_to_ubyte(cso->border_color[0]) << 16) | - (float_to_ubyte(cso->border_color[1]) << 8) | - (float_to_ubyte(cso->border_color[2]) << 0)); - - return (void *)ps; -} - -static void -nv10_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler) -{ - struct nv10_context *nv10 = nv10_context(pipe); - unsigned unit; - - for (unit = 0; unit < nr; unit++) { - nv10->tex_sampler[unit] = sampler[unit]; - nv10->dirty_samplers |= (1 << unit); - } -} - -static void -nv10_sampler_state_delete(struct pipe_context *pipe, void *hwcso) -{ - FREE(hwcso); -} - -static void -nv10_set_sampler_texture(struct pipe_context *pipe, unsigned nr, - struct pipe_texture **miptree) -{ - struct nv10_context *nv10 = nv10_context(pipe); - unsigned unit; - - for (unit = 0; unit < nr; unit++) { - nv10->tex_miptree[unit] = (struct nv10_miptree *)miptree[unit]; - nv10->dirty_samplers |= (1 << unit); - } -} - -static void * -nv10_rasterizer_state_create(struct pipe_context *pipe, - const struct pipe_rasterizer_state *cso) -{ - struct nv10_rasterizer_state *rs; - int i; - - /*XXX: ignored: - * light_twoside - * offset_cw/ccw -nohw - * scissor - * point_smooth -nohw - * multisample - * offset_units / offset_scale - */ - rs = MALLOC(sizeof(struct nv10_rasterizer_state)); - - rs->templ = cso; - - rs->shade_model = cso->flatshade ? 0x1d00 : 0x1d01; - - rs->line_width = (unsigned char)(cso->line_width * 8.0) & 0xff; - rs->line_smooth_en = cso->line_smooth ? 1 : 0; - - rs->point_size = *(uint32_t*)&cso->point_size; - - rs->poly_smooth_en = cso->poly_smooth ? 1 : 0; - - if (cso->front_winding == PIPE_WINDING_CCW) { - rs->front_face = NV10TCL_FRONT_FACE_CCW; - rs->poly_mode_front = nvgl_polygon_mode(cso->fill_ccw); - rs->poly_mode_back = nvgl_polygon_mode(cso->fill_cw); - } else { - rs->front_face = NV10TCL_FRONT_FACE_CW; - rs->poly_mode_front = nvgl_polygon_mode(cso->fill_cw); - rs->poly_mode_back = nvgl_polygon_mode(cso->fill_ccw); - } - - switch (cso->cull_mode) { - case PIPE_WINDING_CCW: - rs->cull_face_en = 1; - if (cso->front_winding == PIPE_WINDING_CCW) - rs->cull_face = NV10TCL_CULL_FACE_FRONT; - else - rs->cull_face = NV10TCL_CULL_FACE_BACK; - break; - case PIPE_WINDING_CW: - rs->cull_face_en = 1; - if (cso->front_winding == PIPE_WINDING_CW) - rs->cull_face = NV10TCL_CULL_FACE_FRONT; - else - rs->cull_face = NV10TCL_CULL_FACE_BACK; - break; - case PIPE_WINDING_BOTH: - rs->cull_face_en = 1; - rs->cull_face = NV10TCL_CULL_FACE_FRONT_AND_BACK; - break; - case PIPE_WINDING_NONE: - default: - rs->cull_face_en = 0; - rs->cull_face = 0; - break; - } - - if (cso->point_sprite) { - rs->point_sprite = (1 << 0); - for (i = 0; i < 8; i++) { - if (cso->sprite_coord_mode[i] != PIPE_SPRITE_COORD_NONE) - rs->point_sprite |= (1 << (8 + i)); - } - } else { - rs->point_sprite = 0; - } - - return (void *)rs; -} - -static void -nv10_rasterizer_state_bind(struct pipe_context *pipe, void *rast) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - nv10->rast = (struct nv10_rasterizer_state*)rast; - - draw_set_rasterizer_state(nv10->draw, (nv10->rast ? nv10->rast->templ : NULL)); - - nv10->dirty |= NV10_NEW_RAST; -} - -static void -nv10_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso) -{ - FREE(hwcso); -} - -static void * -nv10_depth_stencil_alpha_state_create(struct pipe_context *pipe, - const struct pipe_depth_stencil_alpha_state *cso) -{ - struct nv10_depth_stencil_alpha_state *hw; - - hw = MALLOC(sizeof(struct nv10_depth_stencil_alpha_state)); - - hw->depth.func = nvgl_comparison_op(cso->depth.func); - hw->depth.write_enable = cso->depth.writemask ? 1 : 0; - hw->depth.test_enable = cso->depth.enabled ? 1 : 0; - - hw->stencil.enable = cso->stencil[0].enabled ? 1 : 0; - hw->stencil.wmask = cso->stencil[0].writemask; - hw->stencil.func = nvgl_comparison_op(cso->stencil[0].func); - hw->stencil.ref = cso->stencil[0].ref_value; - hw->stencil.vmask = cso->stencil[0].valuemask; - hw->stencil.fail = nvgl_stencil_op(cso->stencil[0].fail_op); - hw->stencil.zfail = nvgl_stencil_op(cso->stencil[0].zfail_op); - hw->stencil.zpass = nvgl_stencil_op(cso->stencil[0].zpass_op); - - hw->alpha.enabled = cso->alpha.enabled ? 1 : 0; - hw->alpha.func = nvgl_comparison_op(cso->alpha.func); - hw->alpha.ref = float_to_ubyte(cso->alpha.ref_value); - - return (void *)hw; -} - -static void -nv10_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *dsa) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - nv10->dsa = (struct nv10_depth_stencil_alpha_state*)dsa; - - nv10->dirty |= NV10_NEW_DSA; -} - -static void -nv10_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso) -{ - FREE(hwcso); -} - -static void * -nv10_vp_state_create(struct pipe_context *pipe, - const struct pipe_shader_state *templ) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - return draw_create_vertex_shader(nv10->draw, templ); -} - -static void -nv10_vp_state_bind(struct pipe_context *pipe, void *shader) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - draw_bind_vertex_shader(nv10->draw, (struct draw_vertex_shader *) shader); - - nv10->dirty |= NV10_NEW_VERTPROG; -} - -static void -nv10_vp_state_delete(struct pipe_context *pipe, void *shader) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - draw_delete_vertex_shader(nv10->draw, (struct draw_vertex_shader *) shader); -} - -static void * -nv10_fp_state_create(struct pipe_context *pipe, - const struct pipe_shader_state *cso) -{ - struct nv10_fragment_program *fp; - - fp = CALLOC(1, sizeof(struct nv10_fragment_program)); - fp->pipe.tokens = tgsi_dup_tokens(cso->tokens); - - tgsi_scan_shader(cso->tokens, &fp->info); - - return (void *)fp; -} - -static void -nv10_fp_state_bind(struct pipe_context *pipe, void *hwcso) -{ - struct nv10_context *nv10 = nv10_context(pipe); - struct nv10_fragment_program *fp = hwcso; - - nv10->fragprog.current = fp; - nv10->dirty |= NV10_NEW_FRAGPROG; -} - -static void -nv10_fp_state_delete(struct pipe_context *pipe, void *hwcso) -{ - struct nv10_context *nv10 = nv10_context(pipe); - struct nv10_fragment_program *fp = hwcso; - - nv10_fragprog_destroy(nv10, fp); - FREE((void*)fp->pipe.tokens); - FREE(fp); -} - -static void -nv10_set_blend_color(struct pipe_context *pipe, - const struct pipe_blend_color *bcol) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - nv10->blend_color = (struct pipe_blend_color*)bcol; - - nv10->dirty |= NV10_NEW_BLENDCOL; -} - -static void -nv10_set_clip_state(struct pipe_context *pipe, - const struct pipe_clip_state *clip) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - draw_set_clip_state(nv10->draw, clip); -} - -static void -nv10_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, - struct pipe_buffer *buf ) -{ - struct nv10_context *nv10 = nv10_context(pipe); - struct pipe_screen *pscreen = pipe->screen; - - assert(shader < PIPE_SHADER_TYPES); - assert(index == 0); - - if (buf) { - void *mapped; - if (buf->size && - (mapped = pipe_buffer_map(pscreen, buf, PIPE_BUFFER_USAGE_CPU_READ))) - { - memcpy(nv10->constbuf[shader], mapped, buf->size); - nv10->constbuf_nr[shader] = - buf->size / (4 * sizeof(float)); - pipe_buffer_unmap(pscreen, buf); - } - } -} - -static void -nv10_set_framebuffer_state(struct pipe_context *pipe, - const struct pipe_framebuffer_state *fb) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - nv10->framebuffer = (struct pipe_framebuffer_state*)fb; - - nv10->dirty |= NV10_NEW_FRAMEBUFFER; -} - -static void -nv10_set_polygon_stipple(struct pipe_context *pipe, - const struct pipe_poly_stipple *stipple) -{ - NOUVEAU_ERR("line stipple hahaha\n"); -} - -static void -nv10_set_scissor_state(struct pipe_context *pipe, - const struct pipe_scissor_state *s) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - nv10->scissor = (struct pipe_scissor_state*)s; - - nv10->dirty |= NV10_NEW_SCISSOR; -} - -static void -nv10_set_viewport_state(struct pipe_context *pipe, - const struct pipe_viewport_state *vpt) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - nv10->viewport = (struct pipe_viewport_state*)vpt; - - draw_set_viewport_state(nv10->draw, nv10->viewport); - - nv10->dirty |= NV10_NEW_VIEWPORT; -} - -static void -nv10_set_vertex_buffers(struct pipe_context *pipe, unsigned count, - const struct pipe_vertex_buffer *vb) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - memcpy(nv10->vtxbuf, vb, sizeof(*vb) * count); - nv10->dirty |= NV10_NEW_VTXARRAYS; - - draw_set_vertex_buffers(nv10->draw, count, vb); -} - -static void -nv10_set_vertex_elements(struct pipe_context *pipe, unsigned count, - const struct pipe_vertex_element *ve) -{ - struct nv10_context *nv10 = nv10_context(pipe); - - memcpy(nv10->vtxelt, ve, sizeof(*ve) * count); - nv10->dirty |= NV10_NEW_VTXARRAYS; - - draw_set_vertex_elements(nv10->draw, count, ve); -} - -void -nv10_init_state_functions(struct nv10_context *nv10) -{ - nv10->pipe.create_blend_state = nv10_blend_state_create; - nv10->pipe.bind_blend_state = nv10_blend_state_bind; - nv10->pipe.delete_blend_state = nv10_blend_state_delete; - - nv10->pipe.create_sampler_state = nv10_sampler_state_create; - nv10->pipe.bind_fragment_sampler_states = nv10_sampler_state_bind; - nv10->pipe.delete_sampler_state = nv10_sampler_state_delete; - nv10->pipe.set_fragment_sampler_textures = nv10_set_sampler_texture; - - nv10->pipe.create_rasterizer_state = nv10_rasterizer_state_create; - nv10->pipe.bind_rasterizer_state = nv10_rasterizer_state_bind; - nv10->pipe.delete_rasterizer_state = nv10_rasterizer_state_delete; - - nv10->pipe.create_depth_stencil_alpha_state = - nv10_depth_stencil_alpha_state_create; - nv10->pipe.bind_depth_stencil_alpha_state = - nv10_depth_stencil_alpha_state_bind; - nv10->pipe.delete_depth_stencil_alpha_state = - nv10_depth_stencil_alpha_state_delete; - - nv10->pipe.create_vs_state = nv10_vp_state_create; - nv10->pipe.bind_vs_state = nv10_vp_state_bind; - nv10->pipe.delete_vs_state = nv10_vp_state_delete; - - nv10->pipe.create_fs_state = nv10_fp_state_create; - nv10->pipe.bind_fs_state = nv10_fp_state_bind; - nv10->pipe.delete_fs_state = nv10_fp_state_delete; - - nv10->pipe.set_blend_color = nv10_set_blend_color; - nv10->pipe.set_clip_state = nv10_set_clip_state; - nv10->pipe.set_constant_buffer = nv10_set_constant_buffer; - nv10->pipe.set_framebuffer_state = nv10_set_framebuffer_state; - nv10->pipe.set_polygon_stipple = nv10_set_polygon_stipple; - nv10->pipe.set_scissor_state = nv10_set_scissor_state; - nv10->pipe.set_viewport_state = nv10_set_viewport_state; - - nv10->pipe.set_vertex_buffers = nv10_set_vertex_buffers; - nv10->pipe.set_vertex_elements = nv10_set_vertex_elements; -} - diff --git a/src/gallium/drivers/nv10/nv10_state.h b/src/gallium/drivers/nv10/nv10_state.h deleted file mode 100644 index 2524ac02e29..00000000000 --- a/src/gallium/drivers/nv10/nv10_state.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef __NV10_STATE_H__ -#define __NV10_STATE_H__ - -#include "pipe/p_state.h" -#include "tgsi/tgsi_scan.h" - -struct nv10_blend_state { - uint32_t b_enable; - uint32_t b_srcfunc; - uint32_t b_dstfunc; - - uint32_t c_mask; - - uint32_t d_enable; -}; - -struct nv10_sampler_state { - uint32_t wrap; - uint32_t en; - uint32_t filt; - uint32_t bcol; -}; - -struct nv10_rasterizer_state { - uint32_t shade_model; - - uint32_t line_width; - uint32_t line_smooth_en; - - uint32_t point_size; - - uint32_t poly_smooth_en; - - uint32_t poly_mode_front; - uint32_t poly_mode_back; - - uint32_t front_face; - uint32_t cull_face; - uint32_t cull_face_en; - - uint32_t point_sprite; - - const struct pipe_rasterizer_state *templ; -}; - -struct nv10_vertex_program_exec { - uint32_t data[4]; - boolean has_branch_offset; - int const_index; -}; - -struct nv10_vertex_program_data { - int index; /* immediates == -1 */ - float value[4]; -}; - -struct nv10_vertex_program { - const struct pipe_shader_state *pipe; - - boolean translated; - struct nv10_vertex_program_exec *insns; - unsigned nr_insns; - struct nv10_vertex_program_data *consts; - unsigned nr_consts; - - struct nouveau_resource *exec; - unsigned exec_start; - struct nouveau_resource *data; - unsigned data_start; - unsigned data_start_min; - - uint32_t ir; - uint32_t or; -}; - -struct nv10_fragment_program_data { - unsigned offset; - unsigned index; -}; - -struct nv10_fragment_program { - struct pipe_shader_state pipe; - struct tgsi_shader_info info; - - boolean translated; - boolean on_hw; - unsigned samplers; - - uint32_t *insn; - int insn_len; - - struct nv10_fragment_program_data *consts; - unsigned nr_consts; - - struct pipe_buffer *buffer; - - uint32_t fp_control; - uint32_t fp_reg_control; -}; - - -struct nv10_depth_stencil_alpha_state { - struct { - uint32_t func; - uint32_t write_enable; - uint32_t test_enable; - } depth; - - struct { - uint32_t enable; - uint32_t wmask; - uint32_t func; - uint32_t ref; - uint32_t vmask; - uint32_t fail; - uint32_t zfail; - uint32_t zpass; - } stencil; - - struct { - uint32_t enabled; - uint32_t func; - uint32_t ref; - } alpha; -}; - -struct nv10_miptree { - struct pipe_texture base; - struct nouveau_bo *bo; - - struct pipe_buffer *buffer; - uint total_size; - - struct { - uint pitch; - uint *image_offset; - } level[PIPE_MAX_TEXTURE_LEVELS]; -}; - -#endif diff --git a/src/gallium/drivers/nv10/nv10_state_emit.c b/src/gallium/drivers/nv10/nv10_state_emit.c deleted file mode 100644 index 30a596ca604..00000000000 --- a/src/gallium/drivers/nv10/nv10_state_emit.c +++ /dev/null @@ -1,333 +0,0 @@ -#include "nv10_context.h" -#include "nv10_state.h" - -static void nv10_state_emit_blend(struct nv10_context* nv10) -{ - struct nv10_blend_state *b = nv10->blend; - struct nv10_screen *screen = nv10->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *celsius = screen->celsius; - - BEGIN_RING(chan, celsius, NV10TCL_DITHER_ENABLE, 1); - OUT_RING (chan, b->d_enable); - - BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_ENABLE, 3); - OUT_RING (chan, b->b_enable); - OUT_RING (chan, b->b_srcfunc); - OUT_RING (chan, b->b_dstfunc); - - BEGIN_RING(chan, celsius, NV10TCL_COLOR_MASK, 1); - OUT_RING (chan, b->c_mask); -} - -static void nv10_state_emit_blend_color(struct nv10_context* nv10) -{ - struct pipe_blend_color *c = nv10->blend_color; - struct nv10_screen *screen = nv10->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *celsius = screen->celsius; - - BEGIN_RING(chan, celsius, NV10TCL_BLEND_COLOR, 1); - OUT_RING (chan, - (float_to_ubyte(c->color[3]) << 24)| - (float_to_ubyte(c->color[0]) << 16)| - (float_to_ubyte(c->color[1]) << 8) | - (float_to_ubyte(c->color[2]) << 0)); -} - -static void nv10_state_emit_rast(struct nv10_context* nv10) -{ - struct nv10_rasterizer_state *r = nv10->rast; - struct nv10_screen *screen = nv10->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *celsius = screen->celsius; - - BEGIN_RING(chan, celsius, NV10TCL_SHADE_MODEL, 2); - OUT_RING (chan, r->shade_model); - OUT_RING (chan, r->line_width); - - - BEGIN_RING(chan, celsius, NV10TCL_POINT_SIZE, 1); - OUT_RING (chan, r->point_size); - - BEGIN_RING(chan, celsius, NV10TCL_POLYGON_MODE_FRONT, 2); - OUT_RING (chan, r->poly_mode_front); - OUT_RING (chan, r->poly_mode_back); - - - BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE, 2); - OUT_RING (chan, r->cull_face); - OUT_RING (chan, r->front_face); - - BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 2); - OUT_RING (chan, r->line_smooth_en); - OUT_RING (chan, r->poly_smooth_en); - - BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE_ENABLE, 1); - OUT_RING (chan, r->cull_face_en); -} - -static void nv10_state_emit_dsa(struct nv10_context* nv10) -{ - struct nv10_depth_stencil_alpha_state *d = nv10->dsa; - struct nv10_screen *screen = nv10->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *celsius = screen->celsius; - - BEGIN_RING(chan, celsius, NV10TCL_DEPTH_FUNC, 1); - OUT_RING (chan, d->depth.func); - - BEGIN_RING(chan, celsius, NV10TCL_DEPTH_WRITE_ENABLE, 1); - OUT_RING (chan, d->depth.write_enable); - - BEGIN_RING(chan, celsius, NV10TCL_DEPTH_TEST_ENABLE, 1); - OUT_RING (chan, d->depth.test_enable); - -#if 0 - BEGIN_RING(chan, celsius, NV10TCL_STENCIL_ENABLE, 1); - OUT_RING (chan, d->stencil.enable); - BEGIN_RING(chan, celsius, NV10TCL_STENCIL_MASK, 7); - OUT_RINGp (chan, (uint32_t *)&(d->stencil.wmask), 7); -#endif - - BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_ENABLE, 1); - OUT_RING (chan, d->alpha.enabled); - - BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_FUNC, 1); - OUT_RING (chan, d->alpha.func); - - BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_REF, 1); - OUT_RING (chan, d->alpha.ref); -} - -static void nv10_state_emit_viewport(struct nv10_context* nv10) -{ -} - -static void nv10_state_emit_scissor(struct nv10_context* nv10) -{ - // XXX this is so not working -/* struct pipe_scissor_state *s = nv10->scissor; - BEGIN_RING(celsius, NV10TCL_SCISSOR_HORIZ, 2); - OUT_RING (((s->maxx - s->minx) << 16) | s->minx); - OUT_RING (((s->maxy - s->miny) << 16) | s->miny);*/ -} - -static void nv10_state_emit_framebuffer(struct nv10_context* nv10) -{ - struct pipe_framebuffer_state* fb = nv10->framebuffer; - struct nv04_surface *rt, *zeta = NULL; - uint32_t rt_format, w, h; - int colour_format = 0, zeta_format = 0; - struct nv10_miptree *nv10mt = 0; - - struct nv10_screen *screen = nv10->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *celsius = screen->celsius; - - w = fb->cbufs[0]->width; - h = fb->cbufs[0]->height; - colour_format = fb->cbufs[0]->format; - rt = (struct nv04_surface *)fb->cbufs[0]; - - if (fb->zsbuf) { - if (colour_format) { - assert(w == fb->zsbuf->width); - assert(h == fb->zsbuf->height); - } else { - w = fb->zsbuf->width; - h = fb->zsbuf->height; - } - - zeta_format = fb->zsbuf->format; - zeta = (struct nv04_surface *)fb->zsbuf; - } - - rt_format = NV10TCL_RT_FORMAT_TYPE_LINEAR; - - switch (colour_format) { - case PIPE_FORMAT_X8R8G8B8_UNORM: - rt_format |= NV10TCL_RT_FORMAT_COLOR_X8R8G8B8; - break; - case PIPE_FORMAT_A8R8G8B8_UNORM: - case 0: - rt_format |= NV10TCL_RT_FORMAT_COLOR_A8R8G8B8; - break; - case PIPE_FORMAT_R5G6B5_UNORM: - rt_format |= NV10TCL_RT_FORMAT_COLOR_R5G6B5; - break; - default: - assert(0); - } - - if (zeta) { - BEGIN_RING(chan, celsius, NV10TCL_RT_PITCH, 1); - OUT_RING (chan, rt->pitch | (zeta->pitch << 16)); - } else { - BEGIN_RING(chan, celsius, NV10TCL_RT_PITCH, 1); - OUT_RING (chan, rt->pitch | (rt->pitch << 16)); - } - - nv10mt = (struct nv10_miptree *)rt->base.texture; - nv10->rt[0] = nv10mt->buffer; - - if (zeta_format) - { - nv10mt = (struct nv10_miptree *)zeta->base.texture; - nv10->zeta = nv10mt->buffer; - } - - BEGIN_RING(chan, celsius, NV10TCL_RT_HORIZ, 3); - OUT_RING (chan, (w << 16) | 0); - OUT_RING (chan, (h << 16) | 0); - OUT_RING (chan, rt_format); - BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(0), 2); - OUT_RING (chan, ((w - 1) << 16) | 0 | 0x08000800); - OUT_RING (chan, ((h - 1) << 16) | 0 | 0x08000800); -} - -static void nv10_vertex_layout(struct nv10_context *nv10) -{ - struct nv10_fragment_program *fp = nv10->fragprog.current; - uint32_t src = 0; - int i; - struct vertex_info vinfo; - - memset(&vinfo, 0, sizeof(vinfo)); - - for (i = 0; i < fp->info.num_inputs; i++) { - switch (fp->info.input_semantic_name[i]) { - case TGSI_SEMANTIC_POSITION: - draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++); - break; - case TGSI_SEMANTIC_COLOR: - draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++); - break; - default: - case TGSI_SEMANTIC_GENERIC: - draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++); - break; - case TGSI_SEMANTIC_FOG: - draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++); - break; - } - } - draw_compute_vertex_size(&vinfo); -} - -void -nv10_emit_hw_state(struct nv10_context *nv10) -{ - struct nv10_screen *screen = nv10->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *celsius = screen->celsius; - struct nouveau_bo *rt_bo; - int i; - - if (nv10->dirty & NV10_NEW_VERTPROG) { - //nv10_vertprog_bind(nv10, nv10->vertprog.current); - nv10->dirty &= ~NV10_NEW_VERTPROG; - } - - if (nv10->dirty & NV10_NEW_FRAGPROG) { - nv10_fragprog_bind(nv10, nv10->fragprog.current); - /*XXX: clear NV10_NEW_FRAGPROG if no new program uploaded */ - nv10->dirty_samplers |= (1<<10); - nv10->dirty_samplers = 0; - } - - if (nv10->dirty_samplers || (nv10->dirty & NV10_NEW_FRAGPROG)) { - nv10_fragtex_bind(nv10); - nv10->dirty &= ~NV10_NEW_FRAGPROG; - } - - if (nv10->dirty & NV10_NEW_VTXARRAYS) { - nv10->dirty &= ~NV10_NEW_VTXARRAYS; - nv10_vertex_layout(nv10); - nv10_vtxbuf_bind(nv10); - } - - if (nv10->dirty & NV10_NEW_BLEND) { - nv10->dirty &= ~NV10_NEW_BLEND; - nv10_state_emit_blend(nv10); - } - - if (nv10->dirty & NV10_NEW_BLENDCOL) { - nv10->dirty &= ~NV10_NEW_BLENDCOL; - nv10_state_emit_blend_color(nv10); - } - - if (nv10->dirty & NV10_NEW_RAST) { - nv10->dirty &= ~NV10_NEW_RAST; - nv10_state_emit_rast(nv10); - } - - if (nv10->dirty & NV10_NEW_DSA) { - nv10->dirty &= ~NV10_NEW_DSA; - nv10_state_emit_dsa(nv10); - } - - if (nv10->dirty & NV10_NEW_VIEWPORT) { - nv10->dirty &= ~NV10_NEW_VIEWPORT; - nv10_state_emit_viewport(nv10); - } - - if (nv10->dirty & NV10_NEW_SCISSOR) { - nv10->dirty &= ~NV10_NEW_SCISSOR; - nv10_state_emit_scissor(nv10); - } - - if (nv10->dirty & NV10_NEW_FRAMEBUFFER) { - nv10->dirty &= ~NV10_NEW_FRAMEBUFFER; - nv10_state_emit_framebuffer(nv10); - } - - /* Emit relocs for every referenced buffer. - * This is to ensure the bufmgr has an accurate idea of how - * the buffer is used. This isn't very efficient, but we don't - * seem to take a significant performance hit. Will be improved - * at some point. Vertex arrays are emitted by nv10_vbo.c - */ - - /* Render target */ - rt_bo = nouveau_bo(nv10->rt[0]); -// XXX figre out who's who for NV10TCL_DMA_* and fill accordingly -// BEGIN_RING(chan, celsius, NV10TCL_DMA_COLOR0, 1); -// OUT_RELOCo(chan, rt_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - BEGIN_RING(chan, celsius, NV10TCL_COLOR_OFFSET, 1); - OUT_RELOCl(chan, rt_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - - if (nv10->zeta) { - struct nouveau_bo *zeta_bo = nouveau_bo(nv10->zeta); -// XXX -// BEGIN_RING(chan, celsius, NV10TCL_DMA_ZETA, 1); -// OUT_RELOCo(chan, zeta_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - BEGIN_RING(chan, celsius, NV10TCL_ZETA_OFFSET, 1); - OUT_RELOCl(chan, zeta_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - /* XXX for when we allocate LMA on nv17 */ -/* BEGIN_RING(chan, celsius, NV10TCL_LMA_DEPTH_BUFFER_OFFSET, 1); - OUT_RELOCl(chan, nouveau_bo(nv10->zeta + lma_offset));*/ - } - - /* Vertex buffer */ - BEGIN_RING(chan, celsius, NV10TCL_DMA_VTXBUF0, 1); - OUT_RELOCo(chan, rt_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - BEGIN_RING(chan, celsius, NV10TCL_COLOR_OFFSET, 1); - OUT_RELOCl(chan, rt_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - - /* Texture images */ - for (i = 0; i < 2; i++) { - if (!(nv10->fp_samplers & (1 << i))) - continue; - struct nouveau_bo *bo = nouveau_bo(nv10->tex[i].buffer); - BEGIN_RING(chan, celsius, NV10TCL_TX_OFFSET(i), 1); - OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | - NOUVEAU_BO_GART | NOUVEAU_BO_RD); - BEGIN_RING(chan, celsius, NV10TCL_TX_FORMAT(i), 1); - OUT_RELOCd(chan, bo, nv10->tex[i].format, - NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD | - NOUVEAU_BO_OR, NV10TCL_TX_FORMAT_DMA0, - NV10TCL_TX_FORMAT_DMA1); - } -} - diff --git a/src/gallium/drivers/nv10/nv10_surface.c b/src/gallium/drivers/nv10/nv10_surface.c deleted file mode 100644 index 6db0164dbe5..00000000000 --- a/src/gallium/drivers/nv10/nv10_surface.c +++ /dev/null @@ -1,63 +0,0 @@ - -/************************************************************************** - * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "nv10_context.h" -#include "pipe/p_defines.h" -#include "util/u_simple_screen.h" -#include "util/u_inlines.h" -#include "util/u_tile.h" - -static void -nv10_surface_copy(struct pipe_context *pipe, - struct pipe_surface *dest, unsigned destx, unsigned desty, - struct pipe_surface *src, unsigned srcx, unsigned srcy, - unsigned width, unsigned height) -{ - struct nv10_context *nv10 = nv10_context(pipe); - struct nv04_surface_2d *eng2d = nv10->screen->eng2d; - - eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height); -} - -static void -nv10_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest, - unsigned destx, unsigned desty, unsigned width, - unsigned height, unsigned value) -{ - struct nv10_context *nv10 = nv10_context(pipe); - struct nv04_surface_2d *eng2d = nv10->screen->eng2d; - - eng2d->fill(eng2d, dest, destx, desty, width, height, value); -} - -void -nv10_init_surface_functions(struct nv10_context *nv10) -{ - nv10->pipe.surface_copy = nv10_surface_copy; - nv10->pipe.surface_fill = nv10_surface_fill; -} diff --git a/src/gallium/drivers/nv10/nv10_transfer.c b/src/gallium/drivers/nv10/nv10_transfer.c deleted file mode 100644 index e554a587301..00000000000 --- a/src/gallium/drivers/nv10/nv10_transfer.c +++ /dev/null @@ -1,178 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "nv10_context.h" -#include "nv10_screen.h" -#include "nv10_state.h" - -struct nv10_transfer { - struct pipe_transfer base; - struct pipe_surface *surface; - boolean direct; -}; - -static void -nv10_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height, - struct pipe_texture *template) -{ - memset(template, 0, sizeof(struct pipe_texture)); - template->target = pt->target; - template->format = pt->format; - template->width0 = width; - template->height0 = height; - template->depth0 = 1; - template->last_level = 0; - template->nr_samples = pt->nr_samples; - - template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC | - NOUVEAU_TEXTURE_USAGE_LINEAR; -} - -static struct pipe_transfer * -nv10_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt, - unsigned face, unsigned level, unsigned zslice, - enum pipe_transfer_usage usage, - unsigned x, unsigned y, unsigned w, unsigned h) -{ - struct nv10_miptree *mt = (struct nv10_miptree *)pt; - struct nv10_transfer *tx; - struct pipe_texture tx_tex_template, *tx_tex; - - tx = CALLOC_STRUCT(nv10_transfer); - if (!tx) - return NULL; - - pipe_texture_reference(&tx->base.texture, pt); - tx->base.x = x; - tx->base.y = y; - tx->base.width = w; - tx->base.height = h; - tx->base.stride = mt->level[level].pitch; - tx->base.usage = usage; - tx->base.face = face; - tx->base.level = level; - tx->base.zslice = zslice; - - /* Direct access to texture */ - if ((pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC || - debug_get_bool_option("NOUVEAU_NO_TRANSFER", TRUE/*XXX:FALSE*/)) && - pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) - { - tx->direct = true; - tx->surface = pscreen->get_tex_surface(pscreen, pt, - 0, 0, 0, - pipe_transfer_buffer_flags(&tx->base)); - return &tx->base; - } - - tx->direct = false; - - nv10_compatible_transfer_tex(pt, w, h, &tx_tex_template); - - tx_tex = pscreen->texture_create(pscreen, &tx_tex_template); - if (!tx_tex) - { - FREE(tx); - return NULL; - } - - tx->base.stride = ((struct nv10_miptree*)tx_tex)->level[0].pitch; - - tx->surface = pscreen->get_tex_surface(pscreen, tx_tex, - face, level, zslice, - pipe_transfer_buffer_flags(&tx->base)); - - pipe_texture_reference(&tx_tex, NULL); - - if (!tx->surface) - { - pipe_surface_reference(&tx->surface, NULL); - FREE(tx); - return NULL; - } - - if (usage & PIPE_TRANSFER_READ) { - struct nv10_screen *nvscreen = nv10_screen(pscreen); - struct pipe_surface *src; - - src = pscreen->get_tex_surface(pscreen, pt, - face, level, zslice, - PIPE_BUFFER_USAGE_GPU_READ); - - /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */ - /* TODO: Check if SIFM can un-swizzle */ - nvscreen->eng2d->copy(nvscreen->eng2d, - tx->surface, 0, 0, - src, x, y, - w, h); - - pipe_surface_reference(&src, NULL); - } - - return &tx->base; -} - -static void -nv10_transfer_del(struct pipe_transfer *ptx) -{ - struct nv10_transfer *tx = (struct nv10_transfer *)ptx; - - if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) { - struct pipe_screen *pscreen = ptx->texture->screen; - struct nv10_screen *nvscreen = nv10_screen(pscreen); - struct pipe_surface *dst; - - dst = pscreen->get_tex_surface(pscreen, ptx->texture, - ptx->face, ptx->level, ptx->zslice, - PIPE_BUFFER_USAGE_GPU_WRITE); - - /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */ - nvscreen->eng2d->copy(nvscreen->eng2d, - dst, tx->base.x, tx->base.y, - tx->surface, 0, 0, - tx->base.width, tx->base.height); - - pipe_surface_reference(&dst, NULL); - } - - pipe_surface_reference(&tx->surface, NULL); - pipe_texture_reference(&ptx->texture, NULL); - FREE(ptx); -} - -static void * -nv10_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx) -{ - struct nv10_transfer *tx = (struct nv10_transfer *)ptx; - struct nv04_surface *ns = (struct nv04_surface *)tx->surface; - struct nv10_miptree *mt = (struct nv10_miptree *)tx->surface->texture; - void *map = pipe_buffer_map(pscreen, mt->buffer, - pipe_transfer_buffer_flags(ptx)); - - if(!tx->direct) - return map + ns->base.offset; - else - return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format); -} - -static void -nv10_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx) -{ - struct nv10_transfer *tx = (struct nv10_transfer *)ptx; - struct nv10_miptree *mt = (struct nv10_miptree *)tx->surface->texture; - - pipe_buffer_unmap(pscreen, mt->buffer); -} - -void -nv10_screen_init_transfer_functions(struct pipe_screen *pscreen) -{ - pscreen->get_tex_transfer = nv10_transfer_new; - pscreen->tex_transfer_destroy = nv10_transfer_del; - pscreen->transfer_map = nv10_transfer_map; - pscreen->transfer_unmap = nv10_transfer_unmap; -} diff --git a/src/gallium/drivers/nv10/nv10_vbo.c b/src/gallium/drivers/nv10/nv10_vbo.c deleted file mode 100644 index 31b34b5c0a8..00000000000 --- a/src/gallium/drivers/nv10/nv10_vbo.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "draw/draw_context.h" -#include "pipe/p_context.h" -#include "pipe/p_state.h" -#include "util/u_inlines.h" - -#include "nv10_context.h" -#include "nv10_state.h" - -#include "nouveau/nouveau_channel.h" -#include "nouveau/nouveau_pushbuf.h" - -void nv10_draw_elements( struct pipe_context *pipe, - struct pipe_buffer *indexBuffer, - unsigned indexSize, - unsigned prim, unsigned start, unsigned count) -{ - struct nv10_context *nv10 = nv10_context( pipe ); - struct draw_context *draw = nv10->draw; - struct pipe_screen *pscreen = pipe->screen; - unsigned i; - - nv10_emit_hw_state(nv10); - - /* - * Map vertex buffers - */ - for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - if (nv10->vtxbuf[i].buffer) { - void *buf = - pipe_buffer_map(pscreen, nv10->vtxbuf[i].buffer, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_vertex_buffer(draw, i, buf); - } - } - /* Map index buffer, if present */ - if (indexBuffer) { - void *mapped_indexes - = pipe_buffer_map(pscreen, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); - } - else { - /* no index/element buffer */ - draw_set_mapped_element_buffer(draw, 0, NULL); - } - - draw_set_mapped_constant_buffer(draw, - PIPE_SHADER_VERTEX, - 0, - nv10->constbuf[PIPE_SHADER_VERTEX], - nv10->constbuf_nr[PIPE_SHADER_VERTEX]); - - /* draw! */ - draw_arrays(nv10->draw, prim, start, count); - - /* - * unmap vertex/index buffers - */ - for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - if (nv10->vtxbuf[i].buffer) { - pipe_buffer_unmap(pscreen, nv10->vtxbuf[i].buffer); - draw_set_mapped_vertex_buffer(draw, i, NULL); - } - } - if (indexBuffer) { - pipe_buffer_unmap(pscreen, indexBuffer); - draw_set_mapped_element_buffer(draw, 0, NULL); - } -} - -void nv10_draw_arrays( struct pipe_context *pipe, - unsigned prim, unsigned start, unsigned count) -{ - nv10_draw_elements(pipe, NULL, 0, prim, start, count); -} - - - diff --git a/src/gallium/drivers/nv20/Makefile b/src/gallium/drivers/nv20/Makefile deleted file mode 100644 index 1305f26c591..00000000000 --- a/src/gallium/drivers/nv20/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -TOP = ../../../.. -include $(TOP)/configs/current - -LIBNAME = nv20 - -C_SOURCES = \ - nv20_clear.c \ - nv20_context.c \ - nv20_fragprog.c \ - nv20_fragtex.c \ - nv20_miptree.c \ - nv20_prim_vbuf.c \ - nv20_screen.c \ - nv20_state.c \ - nv20_state_emit.c \ - nv20_surface.c \ - nv20_transfer.c \ - nv20_vbo.c -# nv20_vertprog.c - -include ../../Makefile.template diff --git a/src/gallium/drivers/nv20/nv20_clear.c b/src/gallium/drivers/nv20/nv20_clear.c deleted file mode 100644 index 2b4490fa5e1..00000000000 --- a/src/gallium/drivers/nv20/nv20_clear.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_state.h" -#include "util/u_clear.h" - -#include "nv20_context.h" - -void -nv20_clear(struct pipe_context *pipe, unsigned buffers, - const float *rgba, double depth, unsigned stencil) -{ - util_clear(pipe, nv20_context(pipe)->framebuffer, buffers, rgba, depth, - stencil); -} diff --git a/src/gallium/drivers/nv20/nv20_context.c b/src/gallium/drivers/nv20/nv20_context.c deleted file mode 100644 index f0c0d8a4b3b..00000000000 --- a/src/gallium/drivers/nv20/nv20_context.c +++ /dev/null @@ -1,424 +0,0 @@ -#include "draw/draw_context.h" -#include "pipe/p_defines.h" -#include "util/u_simple_screen.h" - -#include "nv20_context.h" -#include "nv20_screen.h" - -static void -nv20_flush(struct pipe_context *pipe, unsigned flags, - struct pipe_fence_handle **fence) -{ - struct nv20_context *nv20 = nv20_context(pipe); - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - - draw_flush(nv20->draw); - - FIRE_RING(chan); - if (fence) - *fence = NULL; -} - -static void -nv20_destroy(struct pipe_context *pipe) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - if (nv20->draw) - draw_destroy(nv20->draw); - - FREE(nv20); -} - -static void nv20_init_hwctx(struct nv20_context *nv20) -{ - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - int i; - float projectionmatrix[16]; - const boolean is_nv25tcl = (kelvin->grclass == NV25TCL); - - BEGIN_RING(chan, kelvin, NV20TCL_DMA_NOTIFY, 1); - OUT_RING (chan, screen->sync->handle); - BEGIN_RING(chan, kelvin, NV20TCL_DMA_TEXTURE0, 2); - OUT_RING (chan, chan->vram->handle); - OUT_RING (chan, chan->gart->handle); /* TEXTURE1 */ - BEGIN_RING(chan, kelvin, NV20TCL_DMA_COLOR, 2); - OUT_RING (chan, chan->vram->handle); - OUT_RING (chan, chan->vram->handle); /* ZETA */ - - BEGIN_RING(chan, kelvin, NV20TCL_DMA_QUERY, 1); - OUT_RING (chan, 0); /* renouveau: beef0351, unique */ - - BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - - BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 1); - OUT_RING (chan, (0xfff << 16) | 0x0); - BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_VERT(0), 1); - OUT_RING (chan, (0xfff << 16) | 0x0); - - for (i = 1; i < NV20TCL_VIEWPORT_CLIP_HORIZ__SIZE; i++) { - BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(i), 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_VERT(i), 1); - OUT_RING (chan, 0); - } - - BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_MODE, 1); - OUT_RING (chan, 0); - - BEGIN_RING(chan, kelvin, 0x17e0, 3); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 1.0); - - if (is_nv25tcl) { - BEGIN_RING(chan, kelvin, NV20TCL_TX_RCOMP, 1); - OUT_RING (chan, NV20TCL_TX_RCOMP_LEQUAL | 0xdb0); - } else { - BEGIN_RING(chan, kelvin, 0x1e68, 1); - OUT_RING (chan, 0x4b800000); /* 16777216.000000 */ - BEGIN_RING(chan, kelvin, NV20TCL_TX_RCOMP, 1); - OUT_RING (chan, NV20TCL_TX_RCOMP_LEQUAL); - } - - BEGIN_RING(chan, kelvin, 0x290, 1); - OUT_RING (chan, (0x10 << 16) | 1); - BEGIN_RING(chan, kelvin, 0x9fc, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, 0x1d80, 1); - OUT_RING (chan, 1); - BEGIN_RING(chan, kelvin, 0x9f8, 1); - OUT_RING (chan, 4); - BEGIN_RING(chan, kelvin, 0x17ec, 3); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 1.0); - OUT_RINGf (chan, 0.0); - - if (is_nv25tcl) { - BEGIN_RING(chan, kelvin, 0x1d88, 1); - OUT_RING (chan, 3); - - BEGIN_RING(chan, kelvin, NV25TCL_DMA_IN_MEMORY9, 1); - OUT_RING (chan, chan->vram->handle); - BEGIN_RING(chan, kelvin, NV25TCL_DMA_IN_MEMORY8, 1); - OUT_RING (chan, chan->vram->handle); - } - BEGIN_RING(chan, kelvin, NV20TCL_DMA_FENCE, 1); - OUT_RING (chan, 0); /* renouveau: beef1e10 */ - - BEGIN_RING(chan, kelvin, 0x1e98, 1); - OUT_RING (chan, 0); -#if 0 - if (is_nv25tcl) { - BEGIN_RING(chan, NvSub3D, NV25TCL_DMA_IN_MEMORY4, 2); - OUT_RING (chan, NvDmaTT); /* renouveau: beef0202 */ - OUT_RING (chan, NvDmaFB); /* renouveau: beef0201 */ - - BEGIN_RING(chan, NvSub3D, NV20TCL_DMA_TEXTURE1, 1); - OUT_RING (chan, NvDmaTT); /* renouveau: beef0202 */ - } -#endif - BEGIN_RING(chan, kelvin, NV20TCL_NOTIFY, 1); - OUT_RING (chan, 0); - - BEGIN_RING(chan, kelvin, 0x120, 3); - OUT_RING (chan, 0); - OUT_RING (chan, 1); - OUT_RING (chan, 2); - -/* error: ILLEGAL_MTHD, PROTECTION_FAULT - BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_TRANSLATE_X, 4); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 512.0); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 0.0); -*/ - - if (is_nv25tcl) { - BEGIN_RING(chan, kelvin, 0x022c, 2); - OUT_RING (chan, 0x280); - OUT_RING (chan, 0x07d28000); - } - -/* * illegal method, protection fault - BEGIN_RING(chan, NvSub3D, 0x1c2c, 1); - OUT_RING (chan, 0); */ - - if (is_nv25tcl) { - BEGIN_RING(chan, kelvin, 0x1da4, 1); - OUT_RING (chan, 0); - } - -/* * crashes with illegal method, protection fault - BEGIN_RING(chan, NvSub3D, 0x1c18, 1); - OUT_RING (chan, 0x200); */ - - BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 2); - OUT_RING (chan, (0 << 16) | 0); - OUT_RING (chan, (0 << 16) | 0); - - /* *** Set state *** */ - - BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_FUNC, 2); - OUT_RING (chan, NV20TCL_ALPHA_FUNC_FUNC_ALWAYS); - OUT_RING (chan, 0); /* NV20TCL_ALPHA_FUNC_REF */ - - for (i = 0; i < NV20TCL_TX_ENABLE__SIZE; ++i) { - BEGIN_RING(chan, kelvin, NV20TCL_TX_ENABLE(i), 1); - OUT_RING (chan, 0); - } - BEGIN_RING(chan, kelvin, NV20TCL_TX_SHADER_OP, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_TX_SHADER_CULL_MODE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_RC_IN_ALPHA(0), 4); - OUT_RING (chan, 0x30d410d0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_RC_OUT_RGB(0), 4); - OUT_RING (chan, 0x00000c00); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_RC_ENABLE, 1); - OUT_RING (chan, 0x00011101); - BEGIN_RING(chan, kelvin, NV20TCL_RC_FINAL0, 2); - OUT_RING (chan, 0x130e0300); - OUT_RING (chan, 0x0c091c80); - BEGIN_RING(chan, kelvin, NV20TCL_RC_OUT_ALPHA(0), 4); - OUT_RING (chan, 0x00000c00); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_RC_IN_RGB(0), 4); - OUT_RING (chan, 0x20c400c0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_RC_COLOR0, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_RC_CONSTANT_COLOR0(0), 4); - OUT_RING (chan, 0x035125a0); - OUT_RING (chan, 0); - OUT_RING (chan, 0x40002000); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_MULTISAMPLE_CONTROL, 1); - OUT_RING (chan, 0xffff0000); - - BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_DITHER_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_SRC, 4); - OUT_RING (chan, NV20TCL_BLEND_FUNC_SRC_ONE); - OUT_RING (chan, NV20TCL_BLEND_FUNC_DST_ZERO); - OUT_RING (chan, 0); /* NV20TCL_BLEND_COLOR */ - OUT_RING (chan, NV20TCL_BLEND_EQUATION_FUNC_ADD); - BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_MASK, 7); - OUT_RING (chan, 0xff); - OUT_RING (chan, NV20TCL_STENCIL_FUNC_FUNC_ALWAYS); - OUT_RING (chan, 0); /* NV20TCL_STENCIL_FUNC_REF */ - OUT_RING (chan, 0xff); /* NV20TCL_STENCIL_FUNC_MASK */ - OUT_RING (chan, NV20TCL_STENCIL_OP_FAIL_KEEP); - OUT_RING (chan, NV20TCL_STENCIL_OP_ZFAIL_KEEP); - OUT_RING (chan, NV20TCL_STENCIL_OP_ZPASS_KEEP); - - BEGIN_RING(chan, kelvin, NV20TCL_COLOR_LOGIC_OP_ENABLE, 2); - OUT_RING (chan, 0); - OUT_RING (chan, NV20TCL_COLOR_LOGIC_OP_OP_COPY); - BEGIN_RING(chan, kelvin, 0x17cc, 1); - OUT_RING (chan, 0); - if (is_nv25tcl) { - BEGIN_RING(chan, kelvin, 0x1d84, 1); - OUT_RING (chan, 1); - } - BEGIN_RING(chan, kelvin, NV20TCL_LIGHTING_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_MODEL, 1); - OUT_RING (chan, 0x00020000); - BEGIN_RING(chan, kelvin, NV20TCL_SEPARATE_SPECULAR_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_MODEL_TWO_SIDE_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_ENABLED_LIGHTS, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_NORMALIZE_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_STIPPLE_PATTERN(0), - NV20TCL_POLYGON_STIPPLE_PATTERN__SIZE); - for (i = 0; i < NV20TCL_POLYGON_STIPPLE_PATTERN__SIZE; ++i) { - OUT_RING(chan, 0xffffffff); - } - - BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_OFFSET_POINT_ENABLE, 3); - OUT_RING (chan, 0); - OUT_RING (chan, 0); /* NV20TCL.POLYGON_OFFSET_LINE_ENABLE */ - OUT_RING (chan, 0); /* NV20TCL.POLYGON_OFFSET_FILL_ENABLE */ - BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_FUNC, 1); - OUT_RING (chan, NV20TCL_DEPTH_FUNC_LESS); - BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_WRITE_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_TEST_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_OFFSET_FACTOR, 2); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 0.0); /* NV20TCL.POLYGON_OFFSET_UNITS */ - BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_UNK17D8, 1); - OUT_RING (chan, 1); - if (!is_nv25tcl) { - BEGIN_RING(chan, kelvin, 0x1d84, 1); - OUT_RING (chan, 3); - } - BEGIN_RING(chan, kelvin, NV20TCL_POINT_SIZE, 1); - if (!is_nv25tcl) { - OUT_RING (chan, 8); - } else { - OUT_RINGf (chan, 1.0); - } - if (!is_nv25tcl) { - BEGIN_RING(chan, kelvin, NV20TCL_POINT_PARAMETERS_ENABLE, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); /* NV20TCL.POINT_SMOOTH_ENABLE */ - } else { - BEGIN_RING(chan, kelvin, NV20TCL_POINT_PARAMETERS_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, 0x0a1c, 1); - OUT_RING (chan, 0x800); - } - BEGIN_RING(chan, kelvin, NV20TCL_LINE_WIDTH, 1); - OUT_RING (chan, 8); - BEGIN_RING(chan, kelvin, NV20TCL_LINE_SMOOTH_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_MODE_FRONT, 2); - OUT_RING (chan, NV20TCL_POLYGON_MODE_FRONT_FILL); - OUT_RING (chan, NV20TCL_POLYGON_MODE_BACK_FILL); - BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE, 2); - OUT_RING (chan, NV20TCL_CULL_FACE_BACK); - OUT_RING (chan, NV20TCL_FRONT_FACE_CCW); - BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_SMOOTH_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_SHADE_MODEL, 1); - OUT_RING (chan, NV20TCL_SHADE_MODEL_SMOOTH); - BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_STIPPLE_ENABLE, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_TX_GEN_S(0), 4 * NV20TCL_TX_GEN_S__SIZE); - for (i=0; i < 4 * NV20TCL_TX_GEN_S__SIZE; ++i) { - OUT_RING(chan, 0); - } - BEGIN_RING(chan, kelvin, NV20TCL_FOG_EQUATION_CONSTANT, 3); - OUT_RINGf (chan, 1.5); - OUT_RINGf (chan, -0.090168); /* NV20TCL.FOG_EQUATION_LINEAR */ - OUT_RINGf (chan, 0.0); /* NV20TCL.FOG_EQUATION_QUADRATIC */ - BEGIN_RING(chan, kelvin, NV20TCL_FOG_MODE, 2); - OUT_RING (chan, NV20TCL_FOG_MODE_EXP_SIGNED); - OUT_RING (chan, NV20TCL_FOG_COORD_FOG); - BEGIN_RING(chan, kelvin, NV20TCL_FOG_ENABLE, 2); - OUT_RING (chan, 0); - OUT_RING (chan, 0); /* NV20TCL.FOG_COLOR */ - BEGIN_RING(chan, kelvin, NV20TCL_ENGINE, 1); - OUT_RING (chan, NV20TCL_ENGINE_FIXED); - - for (i = 0; i < NV20TCL_TX_MATRIX_ENABLE__SIZE; ++i) { - BEGIN_RING(chan, kelvin, NV20TCL_TX_MATRIX_ENABLE(i), 1); - OUT_RING (chan, 0); - } - - BEGIN_RING(chan, kelvin, NV20TCL_VTX_ATTR_4F_X(1), 4 * 15); - OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 0.0); OUT_RINGf(chan, 0.0); OUT_RINGf(chan, 1.0); - OUT_RINGf(chan, 0.0); OUT_RINGf(chan, 0.0); OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 1.0); - OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 1.0); - for (i = 4; i < 16; ++i) { - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 0.0); - OUT_RINGf(chan, 1.0); - } - - BEGIN_RING(chan, kelvin, NV20TCL_EDGEFLAG_ENABLE, 1); - OUT_RING (chan, 1); - BEGIN_RING(chan, kelvin, NV20TCL_COLOR_MASK, 1); - OUT_RING (chan, 0x00010101); - BEGIN_RING(chan, kelvin, NV20TCL_CLEAR_VALUE, 1); - OUT_RING (chan, 0); - - memset(projectionmatrix, 0, sizeof(projectionmatrix)); - projectionmatrix[0*4+0] = 1.0; - projectionmatrix[1*4+1] = 1.0; - projectionmatrix[2*4+2] = 16777215.0; - projectionmatrix[3*4+3] = 1.0; - BEGIN_RING(chan, kelvin, NV20TCL_PROJECTION_MATRIX(0), 16); - for (i = 0; i < 16; i++) { - OUT_RINGf (chan, projectionmatrix[i]); - } - - BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_RANGE_NEAR, 2); - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 16777216.0); /* [0, 1] scaled approx to [0, 2^24] */ - - BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_TRANSLATE_X, 4); - OUT_RINGf (chan, 0.0); /* x-offset, w/2 + 1.031250 */ - OUT_RINGf (chan, 0.0); /* y-offset, h/2 + 0.030762 */ - OUT_RINGf (chan, 0.0); - OUT_RINGf (chan, 16777215.0); - - BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_SCALE_X, 4); - OUT_RINGf (chan, 0.0); /* no effect?, w/2 */ - OUT_RINGf (chan, 0.0); /* no effect?, h/2 */ - OUT_RINGf (chan, 16777215.0 * 0.5); - OUT_RINGf (chan, 65535.0); - - FIRE_RING (chan); -} - -struct pipe_context * -nv20_create(struct pipe_screen *pscreen, unsigned pctx_id) -{ - struct nv20_screen *screen = nv20_screen(pscreen); - struct pipe_winsys *ws = pscreen->winsys; - struct nv20_context *nv20; - struct nouveau_winsys *nvws = screen->nvws; - - nv20 = CALLOC(1, sizeof(struct nv20_context)); - if (!nv20) - return NULL; - nv20->screen = screen; - nv20->pctx_id = pctx_id; - - nv20->nvws = nvws; - - nv20->pipe.winsys = ws; - nv20->pipe.screen = pscreen; - nv20->pipe.destroy = nv20_destroy; - nv20->pipe.draw_arrays = nv20_draw_arrays; - nv20->pipe.draw_elements = nv20_draw_elements; - nv20->pipe.clear = nv20_clear; - nv20->pipe.flush = nv20_flush; - - nv20->pipe.is_texture_referenced = nouveau_is_texture_referenced; - nv20->pipe.is_buffer_referenced = nouveau_is_buffer_referenced; - - nv20_init_surface_functions(nv20); - nv20_init_state_functions(nv20); - - nv20->draw = draw_create(); - assert(nv20->draw); - draw_set_rasterize_stage(nv20->draw, nv20_draw_vbuf_stage(nv20)); - - nv20_init_hwctx(nv20); - - return &nv20->pipe; -} - diff --git a/src/gallium/drivers/nv20/nv20_context.h b/src/gallium/drivers/nv20/nv20_context.h deleted file mode 100644 index 270f6488e8a..00000000000 --- a/src/gallium/drivers/nv20/nv20_context.h +++ /dev/null @@ -1,152 +0,0 @@ -#ifndef __NV20_CONTEXT_H__ -#define __NV20_CONTEXT_H__ - -#include - -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_state.h" -#include "pipe/p_compiler.h" - -#include "util/u_memory.h" -#include "util/u_math.h" - -#include "draw/draw_vertex.h" - -#include "nouveau/nouveau_winsys.h" -#include "nouveau/nouveau_gldefs.h" -#include "nouveau/nouveau_context.h" - -#include "nv20_state.h" - -#define NOUVEAU_ERR(fmt, args...) \ - fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args); -#define NOUVEAU_MSG(fmt, args...) \ - fprintf(stderr, "nouveau: "fmt, ##args); - -#define NV20_NEW_VERTPROG (1 << 0) -#define NV20_NEW_FRAGPROG (1 << 1) -#define NV20_NEW_VTXARRAYS (1 << 2) -#define NV20_NEW_BLEND (1 << 3) -#define NV20_NEW_BLENDCOL (1 << 4) -#define NV20_NEW_RAST (1 << 5) -#define NV20_NEW_DSA (1 << 6) -#define NV20_NEW_VIEWPORT (1 << 7) -#define NV20_NEW_SCISSOR (1 << 8) -#define NV20_NEW_FRAMEBUFFER (1 << 9) - -#include "nv20_screen.h" - -struct nv20_context { - struct pipe_context pipe; - - struct nouveau_winsys *nvws; - struct nv20_screen *screen; - unsigned pctx_id; - - struct draw_context *draw; - - uint32_t dirty; - - struct nv20_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS]; - struct nv20_miptree *tex_miptree[PIPE_MAX_SAMPLERS]; - unsigned dirty_samplers; - unsigned fp_samplers; - unsigned vp_samplers; - - uint32_t rt_enable; - struct pipe_buffer *rt[4]; - struct pipe_buffer *zeta; - uint32_t lma_offset; - - struct nv20_blend_state *blend; - struct pipe_blend_color *blend_color; - struct nv20_rasterizer_state *rast; - struct nv20_depth_stencil_alpha_state *dsa; - struct pipe_viewport_state *viewport; - struct pipe_scissor_state *scissor; - struct pipe_framebuffer_state *framebuffer; - - //struct pipe_buffer *constbuf[PIPE_SHADER_TYPES]; - float *constbuf[PIPE_SHADER_TYPES][32][4]; - unsigned constbuf_nr[PIPE_SHADER_TYPES]; - - struct vertex_info vertex_info; - - struct { - struct pipe_buffer *buffer; - uint32_t format; - } tex[2]; - - unsigned vb_enable; - struct { - struct pipe_buffer *buffer; - unsigned delta; - } vb[16]; - -/* struct { - - struct nouveau_resource *exec_heap; - struct nouveau_resource *data_heap; - - struct nv20_vertex_program *active; - - struct nv20_vertex_program *current; - } vertprog; -*/ - struct { - struct nv20_fragment_program *active; - - struct nv20_fragment_program *current; - struct pipe_buffer *constant_buf; - } fragprog; - - struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; - struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS]; -}; - -static INLINE struct nv20_context * -nv20_context(struct pipe_context *pipe) -{ - return (struct nv20_context *)pipe; -} - -extern void nv20_init_state_functions(struct nv20_context *nv20); -extern void nv20_init_surface_functions(struct nv20_context *nv20); - -extern void nv20_screen_init_miptree_functions(struct pipe_screen *pscreen); - -/* nv20_clear.c */ -extern void nv20_clear(struct pipe_context *pipe, unsigned buffers, - const float *rgba, double depth, unsigned stencil); - -/* nv20_draw.c */ -extern struct draw_stage *nv20_draw_render_stage(struct nv20_context *nv20); - -/* nv20_fragprog.c */ -extern void nv20_fragprog_bind(struct nv20_context *, - struct nv20_fragment_program *); -extern void nv20_fragprog_destroy(struct nv20_context *, - struct nv20_fragment_program *); - -/* nv20_fragtex.c */ -extern void nv20_fragtex_bind(struct nv20_context *); - -/* nv20_prim_vbuf.c */ -struct draw_stage *nv20_draw_vbuf_stage( struct nv20_context *nv20 ); -extern void nv20_vtxbuf_bind(struct nv20_context* nv20); - -/* nv20_state.c and friends */ -extern void nv20_emit_hw_state(struct nv20_context *nv20); -extern void nv20_state_tex_update(struct nv20_context *nv20); - -/* nv20_vbo.c */ -extern void nv20_draw_arrays(struct pipe_context *, unsigned mode, - unsigned start, unsigned count); -extern void nv20_draw_elements( struct pipe_context *pipe, - struct pipe_buffer *indexBuffer, - unsigned indexSize, - unsigned prim, unsigned start, unsigned count); - - -#endif diff --git a/src/gallium/drivers/nv20/nv20_fragprog.c b/src/gallium/drivers/nv20/nv20_fragprog.c deleted file mode 100644 index 4f496369dd3..00000000000 --- a/src/gallium/drivers/nv20/nv20_fragprog.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_state.h" - -#include "pipe/p_shader_tokens.h" -#include "tgsi/tgsi_parse.h" -#include "tgsi/tgsi_util.h" - -#include "nv20_context.h" - -void -nv20_fragprog_bind(struct nv20_context *nv20, struct nv20_fragment_program *fp) -{ -} - -void -nv20_fragprog_destroy(struct nv20_context *nv20, - struct nv20_fragment_program *fp) -{ -} - diff --git a/src/gallium/drivers/nv20/nv20_fragtex.c b/src/gallium/drivers/nv20/nv20_fragtex.c deleted file mode 100644 index dedbec73f39..00000000000 --- a/src/gallium/drivers/nv20/nv20_fragtex.c +++ /dev/null @@ -1,130 +0,0 @@ -#include "nv20_context.h" -#include "nouveau/nouveau_util.h" - -#define _(m,tf) \ -{ \ - TRUE, \ - PIPE_FORMAT_##m, \ - NV20TCL_TX_FORMAT_FORMAT_##tf, \ -} - -struct nv20_texture_format { - boolean defined; - uint pipe; - int format; -}; - -static struct nv20_texture_format -nv20_texture_formats[] = { - _(A8R8G8B8_UNORM, A8R8G8B8), - _(A1R5G5B5_UNORM, A1R5G5B5), - _(A4R4G4B4_UNORM, A4R4G4B4), - _(L8_UNORM , L8 ), - _(A8_UNORM , A8 ), - _(A8L8_UNORM , A8L8 ), -/* _(RGB_DXT1 , DXT1, ), */ -/* _(RGBA_DXT1 , DXT1, ), */ -/* _(RGBA_DXT3 , DXT3, ), */ -/* _(RGBA_DXT5 , DXT5, ), */ - {}, -}; - -static struct nv20_texture_format * -nv20_fragtex_format(uint pipe_format) -{ - struct nv20_texture_format *tf = nv20_texture_formats; - - while (tf->defined) { - if (tf->pipe == pipe_format) - return tf; - tf++; - } - - return NULL; -} - - -static void -nv20_fragtex_build(struct nv20_context *nv20, int unit) -{ -#if 0 - struct nv20_sampler_state *ps = nv20->tex_sampler[unit]; - struct nv20_miptree *nv20mt = nv20->tex_miptree[unit]; - struct pipe_texture *pt = &nv20mt->base; - struct nv20_texture_format *tf; - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - uint32_t txf, txs, txp; - - tf = nv20_fragtex_format(pt->format); - if (!tf || !tf->defined) { - NOUVEAU_ERR("Unsupported texture format: 0x%x\n", pt->format); - return; - } - - txf = tf->format << 8; - txf |= (pt->last_level + 1) << 16; - txf |= log2i(pt->width0) << 20; - txf |= log2i(pt->height0) << 24; - txf |= log2i(pt->depth0) << 28; - txf |= 8; - - switch (pt->target) { - case PIPE_TEXTURE_CUBE: - txf |= NV10TCL_TX_FORMAT_CUBE_MAP; - /* fall-through */ - case PIPE_TEXTURE_2D: - txf |= (2<<4); - break; - case PIPE_TEXTURE_1D: - txf |= (1<<4); - break; - default: - NOUVEAU_ERR("Unknown target %d\n", pt->target); - return; - } - - BEGIN_RING(chan, kelvin, NV10TCL_TX_OFFSET(unit), 8); - OUT_RELOCl(chan, nouveau_bo(nv20mt->buffer), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD); - OUT_RELOCd(chan, nouveau_bo(nv20mt->buffer),txf,NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/); - OUT_RING (chan, ps->wrap); - OUT_RING (chan, 0x40000000); /* enable */ - OUT_RING (chan, txs); - OUT_RING (chan, ps->filt | 0x2000 /* magic */); - OUT_RING (chan, (pt->width0 << 16) | pt->height0); - OUT_RING (chan, ps->bcol); -#endif -} - -void -nv20_fragtex_bind(struct nv20_context *nv20) -{ -#if 0 - struct nv20_fragment_program *fp = nv20->fragprog.active; - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - unsigned samplers, unit; - - samplers = nv20->fp_samplers & ~fp->samplers; - while (samplers) { - unit = ffs(samplers) - 1; - samplers &= ~(1 << unit); - - BEGIN_RING(chan, kelvin, NV10TCL_TX_ENABLE(unit), 1); - OUT_RING (chan, 0); - } - - samplers = nv20->dirty_samplers & fp->samplers; - while (samplers) { - unit = ffs(samplers) - 1; - samplers &= ~(1 << unit); - - nv20_fragtex_build(nv20, unit); - } - - nv20->fp_samplers = fp->samplers; -#endif -} - diff --git a/src/gallium/drivers/nv20/nv20_miptree.c b/src/gallium/drivers/nv20/nv20_miptree.c deleted file mode 100644 index 2d3473b0869..00000000000 --- a/src/gallium/drivers/nv20/nv20_miptree.c +++ /dev/null @@ -1,226 +0,0 @@ -#include "pipe/p_state.h" -#include "pipe/p_defines.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" - -#include "nv20_context.h" -#include "nv20_screen.h" -#include "../nv04/nv04_surface_2d.h" - -static void -nv20_miptree_layout(struct nv20_miptree *nv20mt) -{ - struct pipe_texture *pt = &nv20mt->base; - uint width = pt->width0; - uint offset = 0; - int nr_faces, l, f; - uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER | - PIPE_TEXTURE_USAGE_DEPTH_STENCIL | - PIPE_TEXTURE_USAGE_RENDER_TARGET | - PIPE_TEXTURE_USAGE_DISPLAY_TARGET | - PIPE_TEXTURE_USAGE_PRIMARY); - - if (pt->target == PIPE_TEXTURE_CUBE) { - nr_faces = 6; - } else { - nr_faces = 1; - } - - for (l = 0; l <= pt->last_level; l++) { - if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) - nv20mt->level[l].pitch = align(util_format_get_stride(pt->format, pt->width0), 64); - else - nv20mt->level[l].pitch = util_format_get_stride(pt->format, width); - - nv20mt->level[l].image_offset = - CALLOC(nr_faces, sizeof(unsigned)); - - width = u_minify(width, 1); - } - - for (f = 0; f < nr_faces; f++) { - for (l = 0; l < pt->last_level; l++) { - nv20mt->level[l].image_offset[f] = offset; - - if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) && - u_minify(pt->width0, l + 1) > 1 && u_minify(pt->height0, l + 1) > 1) - offset += align(nv20mt->level[l].pitch * u_minify(pt->height0, l), 64); - else - offset += nv20mt->level[l].pitch * u_minify(pt->height0, l); - } - - nv20mt->level[l].image_offset[f] = offset; - offset += nv20mt->level[l].pitch * u_minify(pt->height0, l); - } - - nv20mt->total_size = offset; -} - -static struct pipe_texture * -nv20_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt, - const unsigned *stride, struct pipe_buffer *pb) -{ - struct nv20_miptree *mt; - - /* Only supports 2D, non-mipmapped textures for the moment */ - if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 || - pt->depth0 != 1) - return NULL; - - mt = CALLOC_STRUCT(nv20_miptree); - if (!mt) - return NULL; - - mt->base = *pt; - pipe_reference_init(&mt->base.reference, 1); - mt->base.screen = pscreen; - mt->level[0].pitch = stride[0]; - mt->level[0].image_offset = CALLOC(1, sizeof(unsigned)); - - pipe_buffer_reference(&mt->buffer, pb); - mt->bo = nouveau_bo(mt->buffer); - return &mt->base; -} - -static struct pipe_texture * -nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt) -{ - struct nv20_miptree *mt; - unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL | - NOUVEAU_BUFFER_USAGE_TEXTURE; - - mt = MALLOC(sizeof(struct nv20_miptree)); - if (!mt) - return NULL; - mt->base = *pt; - pipe_reference_init(&mt->base.reference, 1); - mt->base.screen = screen; - - /* Swizzled textures must be POT */ - if (pt->width0 & (pt->width0 - 1) || - pt->height0 & (pt->height0 - 1)) - mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR; - else - if (pt->tex_usage & (PIPE_TEXTURE_USAGE_PRIMARY | - PIPE_TEXTURE_USAGE_DISPLAY_TARGET | - PIPE_TEXTURE_USAGE_DEPTH_STENCIL)) - mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR; - else - if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC) - mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR; - else { - switch (pt->format) { - /* TODO: Figure out which formats can be swizzled */ - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_R16_SNORM: - { - if (debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE)) - mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR; - break; - } - default: - mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR; - } - } - - if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC) - buf_usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE; - - /* apparently we can't render to swizzled surfaces smaller than 64 bytes, so make them linear. - * If the user did not ask for a render target, they can still render to it, but it will cost them an extra copy. - * This also happens for small mipmaps of large textures. */ - if (pt->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET && util_format_get_stride(pt->format, pt->width0) < 64) - mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR; - - nv20_miptree_layout(mt); - - mt->buffer = screen->buffer_create(screen, 256, buf_usage, mt->total_size); - if (!mt->buffer) { - FREE(mt); - return NULL; - } - mt->bo = nouveau_bo(mt->buffer); - - return &mt->base; -} - -static void -nv20_miptree_destroy(struct pipe_texture *pt) -{ - struct nv20_miptree *nv20mt = (struct nv20_miptree *)pt; - int l; - - pipe_buffer_reference(&nv20mt->buffer, NULL); - for (l = 0; l <= pt->last_level; l++) { - if (nv20mt->level[l].image_offset) - FREE(nv20mt->level[l].image_offset); - } -} - -static struct pipe_surface * -nv20_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt, - unsigned face, unsigned level, unsigned zslice, - unsigned flags) -{ - struct nv20_miptree *nv20mt = (struct nv20_miptree *)pt; - struct nv04_surface *ns; - - ns = CALLOC_STRUCT(nv04_surface); - if (!ns) - return NULL; - pipe_texture_reference(&ns->base.texture, pt); - ns->base.format = pt->format; - ns->base.width = u_minify(pt->width0, level); - ns->base.height = u_minify(pt->height0, level); - ns->base.usage = flags; - pipe_reference_init(&ns->base.reference, 1); - ns->base.face = face; - ns->base.level = level; - ns->base.zslice = zslice; - ns->pitch = nv20mt->level[level].pitch; - - if (pt->target == PIPE_TEXTURE_CUBE) { - ns->base.offset = nv20mt->level[level].image_offset[face]; - } else - if (pt->target == PIPE_TEXTURE_3D) { - ns->base.offset = nv20mt->level[level].image_offset[zslice]; - } else { - ns->base.offset = nv20mt->level[level].image_offset[0]; - } - - /* create a linear temporary that we can render into if necessary. - * Note that ns->pitch is always a multiple of 64 for linear surfaces and swizzled surfaces are POT, so - * ns->pitch & 63 is equivalent to (ns->pitch < 64 && swizzled)*/ - if((ns->pitch & 63) && (ns->base.usage & (PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER)) == PIPE_BUFFER_USAGE_GPU_WRITE) - return &nv04_surface_wrap_for_render(screen, ((struct nv20_screen*)screen)->eng2d, ns)->base; - - return &ns->base; -} - -static void -nv20_miptree_surface_destroy(struct pipe_surface *ps) -{ - struct nv04_surface* ns = (struct nv04_surface*)ps; - if(ns->backing) - { - struct nv20_screen* screen = (struct nv20_screen*)ps->texture->screen; - if(ns->backing->base.usage & PIPE_BUFFER_USAGE_GPU_WRITE) - screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height); - nv20_miptree_surface_destroy(&ns->backing->base); - } - - pipe_texture_reference(&ps->texture, NULL); - FREE(ps); -} - -void nv20_screen_init_miptree_functions(struct pipe_screen *pscreen) -{ - pscreen->texture_create = nv20_miptree_create; - pscreen->texture_blanket = nv20_miptree_blanket; - pscreen->texture_destroy = nv20_miptree_destroy; - pscreen->get_tex_surface = nv20_miptree_surface_get; - pscreen->tex_surface_destroy = nv20_miptree_surface_destroy; -} - diff --git a/src/gallium/drivers/nv20/nv20_prim_vbuf.c b/src/gallium/drivers/nv20/nv20_prim_vbuf.c deleted file mode 100644 index 581276ba22e..00000000000 --- a/src/gallium/drivers/nv20/nv20_prim_vbuf.c +++ /dev/null @@ -1,440 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/** - * \file - * Build post-transformation, post-clipping vertex buffers and element - * lists by hooking into the end of the primitive pipeline and - * manipulating the vertex_id field in the vertex headers. - * - * XXX: work in progress - * - * \author José Fonseca - * \author Keith Whitwell - */ - - -#include "util/u_debug.h" -#include "util/u_inlines.h" -#include "util/u_simple_screen.h" - -#include "nv20_context.h" -#include "nv20_state.h" - -#include "draw/draw_vbuf.h" - -/** - * Primitive renderer for nv20. - */ -struct nv20_vbuf_render { - struct vbuf_render base; - - struct nv20_context *nv20; - - /** Vertex buffer in VRAM */ - struct pipe_buffer *pbuffer; - - /** Vertex buffer in normal memory */ - void *mbuffer; - - /** Vertex size in bytes */ - /*unsigned vertex_size;*/ - - /** Hardware primitive */ - unsigned hwprim; -}; - -/** - * Basically a cast wrapper. - */ -static INLINE struct nv20_vbuf_render * -nv20_vbuf_render(struct vbuf_render *render) -{ - assert(render); - return (struct nv20_vbuf_render *)render; -} - -void nv20_vtxbuf_bind( struct nv20_context* nv20 ) -{ -#if 0 - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - int i; - for(i = 0; i < NV20TCL_VTXBUF_ADDRESS__SIZE; i++) { - BEGIN_RING(chan, kelvin, NV20TCL_VTXBUF_ADDRESS(i), 1); - OUT_RING(chan, 0/*nv20->vtxbuf*/); - BEGIN_RING(chan, kelvin, NV20TCL_VTXFMT(i) ,1); - OUT_RING(chan, 0/*XXX*/); - } -#endif -} - -static const struct vertex_info * -nv20_vbuf_render_get_vertex_info( struct vbuf_render *render ) -{ - struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); - struct nv20_context *nv20 = nv20_render->nv20; - - nv20_emit_hw_state(nv20); - - return &nv20->vertex_info; -} - -static void * -nv20__allocate_mbuffer(struct nv20_vbuf_render *nv20_render, size_t size) -{ - nv20_render->mbuffer = MALLOC(size); - return nv20_render->mbuffer; -} - -static void -nv20__allocate_pbuffer(struct nv20_vbuf_render *nv20_render, size_t size) -{ - struct pipe_screen *screen = nv20_render->nv20->pipe.screen; - nv20_render->pbuffer = screen->buffer_create(screen, 64, - PIPE_BUFFER_USAGE_VERTEX, size); -} - -static boolean -nv20_vbuf_render_allocate_vertices( struct vbuf_render *render, - ushort vertex_size, - ushort nr_vertices ) -{ - struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); - size_t size = (size_t)vertex_size * (size_t)nr_vertices; - void *buf; - - assert(!nv20_render->pbuffer); - assert(!nv20_render->mbuffer); - - /* - * For small amount of vertices, don't bother with pipe vertex - * buffer, the data will be passed directly via the fifo. - */ - /* XXX: Pipe vertex buffers don't work. */ - if (0 && size > 16 * 1024) { - nv20__allocate_pbuffer(nv20_render, size); - /* umm yeah so this is ugly */ - buf = nv20_render->pbuffer; - } else { - buf = nv20__allocate_mbuffer(nv20_render, size); - } - - if (buf) - nv20_render->nv20->dirty |= NV20_NEW_VTXARRAYS; - - return buf ? TRUE : FALSE; -} - -static void * -nv20_vbuf_render_map_vertices( struct vbuf_render *render ) -{ - struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); - struct pipe_screen *pscreen = nv20_render->nv20->pipe.screen; - - if (nv20_render->pbuffer) { - return pipe_buffer_map(pscreen, nv20_render->pbuffer, - PIPE_BUFFER_USAGE_CPU_WRITE); - } else if (nv20_render->mbuffer) { - return nv20_render->mbuffer; - } else - assert(0); - - /* warnings be gone */ - return NULL; -} - -static void -nv20_vbuf_render_unmap_vertices( struct vbuf_render *render, - ushort min_index, - ushort max_index ) -{ - struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); - struct pipe_screen *pscreen = nv20_render->nv20->pipe.screen; - - if (nv20_render->pbuffer) - pipe_buffer_unmap(pscreen, nv20_render->pbuffer); -} - -static boolean -nv20_vbuf_render_set_primitive( struct vbuf_render *render, - unsigned prim ) -{ - struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); - unsigned hwp = nvgl_primitive(prim); - if (hwp == 0) - return FALSE; - - nv20_render->hwprim = hwp; - return TRUE; -} - -static uint32_t -nv20__vtxhwformat(unsigned stride, unsigned fields, unsigned type) -{ - return (stride << NV20TCL_VTXFMT_STRIDE_SHIFT) | - (fields << NV20TCL_VTXFMT_SIZE_SHIFT) | - (type << NV20TCL_VTXFMT_TYPE_SHIFT); -} - -static unsigned -nv20__emit_format(struct nv20_context *nv20, enum attrib_emit type, int hwattr) -{ - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - uint32_t hwfmt = 0; - unsigned fields; - - switch (type) { - case EMIT_OMIT: - hwfmt = nv20__vtxhwformat(0, 0, 2); - fields = 0; - break; - case EMIT_1F: - hwfmt = nv20__vtxhwformat(4, 1, 2); - fields = 1; - break; - case EMIT_2F: - hwfmt = nv20__vtxhwformat(8, 2, 2); - fields = 2; - break; - case EMIT_3F: - hwfmt = nv20__vtxhwformat(12, 3, 2); - fields = 3; - break; - case EMIT_4F: - hwfmt = nv20__vtxhwformat(16, 4, 2); - fields = 4; - break; - default: - NOUVEAU_ERR("unhandled attrib_emit %d\n", type); - return 0; - } - - BEGIN_RING(chan, kelvin, NV20TCL_VTXFMT(hwattr), 1); - OUT_RING(chan, hwfmt); - return fields; -} - -static unsigned -nv20__emit_vertex_array_format(struct nv20_context *nv20) -{ - struct vertex_info *vinfo = &nv20->vertex_info; - int hwattr = NV20TCL_VTXFMT__SIZE; - int attr = 0; - unsigned nr_fields = 0; - - while (hwattr-- > 0) { - if (vinfo->hwfmt[0] & (1 << hwattr)) { - nr_fields += nv20__emit_format(nv20, - vinfo->attrib[attr].emit, hwattr); - attr++; - } else - nv20__emit_format(nv20, EMIT_OMIT, hwattr); - } - - return nr_fields; -} - -static void -nv20__draw_mbuffer(struct nv20_vbuf_render *nv20_render, - const ushort *indices, - uint nr_indices) -{ - struct nv20_context *nv20 = nv20_render->nv20; - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - struct vertex_info *vinfo = &nv20->vertex_info; - unsigned nr_fields; - int max_push; - ubyte *data = nv20_render->mbuffer; - int vsz = 4 * vinfo->size; - - nr_fields = nv20__emit_vertex_array_format(nv20); - - BEGIN_RING(chan, kelvin, NV20TCL_VERTEX_BEGIN_END, 1); - OUT_RING(chan, nv20_render->hwprim); - - max_push = 1200 / nr_fields; - while (nr_indices) { - int i; - int push = MIN2(nr_indices, max_push); - - BEGIN_RING_NI(chan, kelvin, NV20TCL_VERTEX_DATA, push * nr_fields); - for (i = 0; i < push; i++) { - /* XXX: fixme to handle other than floats? */ - int f = nr_fields; - float *attrv = (float*)&data[indices[i] * vsz]; - while (f-- > 0) - OUT_RINGf(chan, *attrv++); - } - - nr_indices -= push; - indices += push; - } - - BEGIN_RING(chan, kelvin, NV20TCL_VERTEX_BEGIN_END, 1); - OUT_RING(chan, NV20TCL_VERTEX_BEGIN_END_STOP); -} - -static void -nv20__draw_pbuffer(struct nv20_vbuf_render *nv20_render, - const ushort *indices, - uint nr_indices) -{ - struct nv20_context *nv20 = nv20_render->nv20; - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - int push, i; - - NOUVEAU_ERR("nv20__draw_pbuffer: this path is broken.\n"); - - BEGIN_RING(chan, kelvin, NV10TCL_VERTEX_ARRAY_OFFSET_POS, 1); - OUT_RELOCl(chan, nouveau_bo(nv20_render->pbuffer), 0, - NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD); - - BEGIN_RING(chan, kelvin, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1); - OUT_RING(chan, nv20_render->hwprim); - - if (nr_indices & 1) { - BEGIN_RING(chan, kelvin, NV10TCL_VB_ELEMENT_U32, 1); - OUT_RING (chan, indices[0]); - indices++; nr_indices--; - } - - while (nr_indices) { - // XXX too big/small ? check the size - push = MIN2(nr_indices, 1200 * 2); - - BEGIN_RING_NI(chan, kelvin, NV10TCL_VB_ELEMENT_U16, push >> 1); - for (i = 0; i < push; i+=2) - OUT_RING(chan, (indices[i+1] << 16) | indices[i]); - - nr_indices -= push; - indices += push; - } - - BEGIN_RING(chan, kelvin, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1); - OUT_RING (chan, 0); -} - -static void -nv20_vbuf_render_draw( struct vbuf_render *render, - const ushort *indices, - uint nr_indices) -{ - struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); - - nv20_emit_hw_state(nv20_render->nv20); - - if (nv20_render->pbuffer) - nv20__draw_pbuffer(nv20_render, indices, nr_indices); - else if (nv20_render->mbuffer) - nv20__draw_mbuffer(nv20_render, indices, nr_indices); - else - assert(0); -} - - -static void -nv20_vbuf_render_release_vertices( struct vbuf_render *render ) -{ - struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); - struct nv20_context *nv20 = nv20_render->nv20; - - if (nv20_render->pbuffer) { - pipe_buffer_reference(&nv20_render->pbuffer, NULL); - } else if (nv20_render->mbuffer) { - FREE(nv20_render->mbuffer); - nv20_render->mbuffer = NULL; - } else - assert(0); -} - - -static void -nv20_vbuf_render_destroy( struct vbuf_render *render ) -{ - struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); - - assert(!nv20_render->pbuffer); - assert(!nv20_render->mbuffer); - - FREE(nv20_render); -} - - -/** - * Create a new primitive render. - */ -static struct vbuf_render * -nv20_vbuf_render_create( struct nv20_context *nv20 ) -{ - struct nv20_vbuf_render *nv20_render = CALLOC_STRUCT(nv20_vbuf_render); - - nv20_render->nv20 = nv20; - - nv20_render->base.max_vertex_buffer_bytes = 16*1024; - nv20_render->base.max_indices = 1024; - nv20_render->base.get_vertex_info = nv20_vbuf_render_get_vertex_info; - nv20_render->base.allocate_vertices = - nv20_vbuf_render_allocate_vertices; - nv20_render->base.map_vertices = nv20_vbuf_render_map_vertices; - nv20_render->base.unmap_vertices = nv20_vbuf_render_unmap_vertices; - nv20_render->base.set_primitive = nv20_vbuf_render_set_primitive; - nv20_render->base.draw = nv20_vbuf_render_draw; - nv20_render->base.release_vertices = nv20_vbuf_render_release_vertices; - nv20_render->base.destroy = nv20_vbuf_render_destroy; - - return &nv20_render->base; -} - - -/** - * Create a new primitive vbuf/render stage. - */ -struct draw_stage *nv20_draw_vbuf_stage( struct nv20_context *nv20 ) -{ - struct vbuf_render *render; - struct draw_stage *stage; - - render = nv20_vbuf_render_create(nv20); - if(!render) - return NULL; - - stage = draw_vbuf_stage( nv20->draw, render ); - if(!stage) { - render->destroy(render); - return NULL; - } - - return stage; -} diff --git a/src/gallium/drivers/nv20/nv20_screen.c b/src/gallium/drivers/nv20/nv20_screen.c deleted file mode 100644 index df9401bcce0..00000000000 --- a/src/gallium/drivers/nv20/nv20_screen.c +++ /dev/null @@ -1,204 +0,0 @@ -#include "pipe/p_screen.h" - -#include "nv20_context.h" -#include "nv20_screen.h" - -static int -nv20_screen_get_param(struct pipe_screen *screen, int param) -{ - switch (param) { - case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: - return 2; - case PIPE_CAP_NPOT_TEXTURES: - return 0; - case PIPE_CAP_TWO_SIDED_STENCIL: - return 0; - case PIPE_CAP_GLSL: - return 0; - case PIPE_CAP_ANISOTROPIC_FILTER: - return 1; - case PIPE_CAP_POINT_SPRITE: - return 0; - case PIPE_CAP_MAX_RENDER_TARGETS: - return 1; - case PIPE_CAP_OCCLUSION_QUERY: - return 0; - case PIPE_CAP_TEXTURE_SHADOW_MAP: - return 0; - case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: - return 12; - case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: - return 0; - case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: - return 12; - case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS: - return 0; - case PIPE_CAP_TGSI_CONT_SUPPORTED: - return 0; - case PIPE_CAP_BLEND_EQUATION_SEPARATE: - return 0; - case NOUVEAU_CAP_HW_VTXBUF: - case NOUVEAU_CAP_HW_IDXBUF: - return 0; - case PIPE_CAP_INDEP_BLEND_ENABLE: - return 0; - case PIPE_CAP_INDEP_BLEND_FUNC: - return 0; - case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: - case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: - return 1; - case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: - case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: - return 0; - default: - NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); - return 0; - } -} - -static float -nv20_screen_get_paramf(struct pipe_screen *screen, int param) -{ - switch (param) { - case PIPE_CAP_MAX_LINE_WIDTH: - case PIPE_CAP_MAX_LINE_WIDTH_AA: - return 10.0; - case PIPE_CAP_MAX_POINT_WIDTH: - case PIPE_CAP_MAX_POINT_WIDTH_AA: - return 64.0; - case PIPE_CAP_MAX_TEXTURE_ANISOTROPY: - return 2.0; - case PIPE_CAP_MAX_TEXTURE_LOD_BIAS: - return 4.0; - default: - NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); - return 0.0; - } -} - -static boolean -nv20_screen_is_format_supported(struct pipe_screen *screen, - enum pipe_format format, - enum pipe_texture_target target, - unsigned tex_usage, unsigned geom_flags) -{ - if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) { - switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - return TRUE; - default: - break; - } - } else - if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) { - switch (format) { - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z16_UNORM: - return TRUE; - default: - break; - } - } else { - switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_A1R5G5B5_UNORM: - case PIPE_FORMAT_A4R4G4B4_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_L8_UNORM: - case PIPE_FORMAT_A8_UNORM: - case PIPE_FORMAT_I8_UNORM: - return TRUE; - default: - break; - } - } - - return FALSE; -} - -static void -nv20_screen_destroy(struct pipe_screen *pscreen) -{ - struct nv20_screen *screen = nv20_screen(pscreen); - - nouveau_notifier_free(&screen->sync); - nouveau_grobj_free(&screen->kelvin); - nv04_surface_2d_takedown(&screen->eng2d); - - nouveau_screen_fini(&screen->base); - - FREE(pscreen); -} - -static struct pipe_buffer * -nv20_surface_buffer(struct pipe_surface *surf) -{ - struct nv20_miptree *mt = (struct nv20_miptree *)surf->texture; - - return mt->buffer; -} - -struct pipe_screen * -nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) -{ - struct nv20_screen *screen = CALLOC_STRUCT(nv20_screen); - struct nouveau_channel *chan; - struct pipe_screen *pscreen; - unsigned kelvin_class = 0; - int ret; - - if (!screen) - return NULL; - pscreen = &screen->base.base; - - ret = nouveau_screen_init(&screen->base, dev); - if (ret) { - nv20_screen_destroy(pscreen); - return NULL; - } - chan = screen->base.channel; - - pscreen->winsys = ws; - pscreen->destroy = nv20_screen_destroy; - pscreen->get_param = nv20_screen_get_param; - pscreen->get_paramf = nv20_screen_get_paramf; - pscreen->is_format_supported = nv20_screen_is_format_supported; - - nv20_screen_init_miptree_functions(pscreen); - nv20_screen_init_transfer_functions(pscreen); - - /* 3D object */ - if (dev->chipset >= 0x25) - kelvin_class = NV25TCL; - else if (dev->chipset >= 0x20) - kelvin_class = NV20TCL; - - if (!kelvin_class || dev->chipset >= 0x30) { - NOUVEAU_ERR("Unknown nv2x chipset: nv%02x\n", dev->chipset); - return NULL; - } - - ret = nouveau_grobj_alloc(chan, 0xbeef0097, kelvin_class, - &screen->kelvin); - if (ret) { - NOUVEAU_ERR("Error creating 3D object: %d\n", ret); - return FALSE; - } - - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(&screen->base); - screen->eng2d->buf = nv20_surface_buffer; - - /* Notifier for sync purposes */ - ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); - if (ret) { - NOUVEAU_ERR("Error creating notifier object: %d\n", ret); - nv20_screen_destroy(pscreen); - return NULL; - } - - return pscreen; -} - diff --git a/src/gallium/drivers/nv20/nv20_screen.h b/src/gallium/drivers/nv20/nv20_screen.h deleted file mode 100644 index fc7bb050334..00000000000 --- a/src/gallium/drivers/nv20/nv20_screen.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __NV20_SCREEN_H__ -#define __NV20_SCREEN_H__ - -#include "nouveau/nouveau_screen.h" -#include "nv04/nv04_surface_2d.h" - -struct nv20_screen { - struct nouveau_screen base; - - struct nouveau_winsys *nvws; - - /* HW graphics objects */ - struct nv04_surface_2d *eng2d; - struct nouveau_grobj *kelvin; - struct nouveau_notifier *sync; -}; - -static INLINE struct nv20_screen * -nv20_screen(struct pipe_screen *screen) -{ - return (struct nv20_screen *)screen; -} - - -void -nv20_screen_init_transfer_functions(struct pipe_screen *pscreen); - -#endif diff --git a/src/gallium/drivers/nv20/nv20_state.c b/src/gallium/drivers/nv20/nv20_state.c deleted file mode 100644 index 923dc61cfb2..00000000000 --- a/src/gallium/drivers/nv20/nv20_state.c +++ /dev/null @@ -1,583 +0,0 @@ -#include "draw/draw_context.h" -#include "pipe/p_state.h" -#include "pipe/p_defines.h" -#include "pipe/p_shader_tokens.h" -#include "util/u_inlines.h" - -#include "tgsi/tgsi_parse.h" - -#include "nv20_context.h" -#include "nv20_state.h" - -static void * -nv20_blend_state_create(struct pipe_context *pipe, - const struct pipe_blend_state *cso) -{ - struct nv20_blend_state *cb; - - cb = MALLOC(sizeof(struct nv20_blend_state)); - - cb->b_enable = cso->rt[0].blend_enable ? 1 : 0; - cb->b_srcfunc = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) | - (nvgl_blend_func(cso->rt[0].rgb_src_factor))); - cb->b_dstfunc = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) | - (nvgl_blend_func(cso->rt[0].rgb_dst_factor))); - - cb->c_mask = (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01<<24) : 0) | - ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01<<16) : 0) | - ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01<< 8) : 0) | - ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01<< 0) : 0)); - - cb->d_enable = cso->dither ? 1 : 0; - - return (void *)cb; -} - -static void -nv20_blend_state_bind(struct pipe_context *pipe, void *blend) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - nv20->blend = (struct nv20_blend_state*)blend; - - nv20->dirty |= NV20_NEW_BLEND; -} - -static void -nv20_blend_state_delete(struct pipe_context *pipe, void *hwcso) -{ - FREE(hwcso); -} - - -static INLINE unsigned -wrap_mode(unsigned wrap) { - unsigned ret; - - switch (wrap) { - case PIPE_TEX_WRAP_REPEAT: - ret = NV20TCL_TX_WRAP_S_REPEAT; - break; - case PIPE_TEX_WRAP_MIRROR_REPEAT: - ret = NV20TCL_TX_WRAP_S_MIRRORED_REPEAT; - break; - case PIPE_TEX_WRAP_CLAMP_TO_EDGE: - ret = NV20TCL_TX_WRAP_S_CLAMP_TO_EDGE; - break; - case PIPE_TEX_WRAP_CLAMP_TO_BORDER: - ret = NV20TCL_TX_WRAP_S_CLAMP_TO_BORDER; - break; - case PIPE_TEX_WRAP_CLAMP: - ret = NV20TCL_TX_WRAP_S_CLAMP; - break; - case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: - case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: - case PIPE_TEX_WRAP_MIRROR_CLAMP: - default: - NOUVEAU_ERR("unknown wrap mode: %d\n", wrap); - ret = NV20TCL_TX_WRAP_S_REPEAT; - break; - } - - return (ret >> NV20TCL_TX_WRAP_S_SHIFT); -} - -static void * -nv20_sampler_state_create(struct pipe_context *pipe, - const struct pipe_sampler_state *cso) -{ - struct nv20_sampler_state *ps; - uint32_t filter = 0; - - ps = MALLOC(sizeof(struct nv20_sampler_state)); - - ps->wrap = ((wrap_mode(cso->wrap_s) << NV20TCL_TX_WRAP_S_SHIFT) | - (wrap_mode(cso->wrap_t) << NV20TCL_TX_WRAP_T_SHIFT)); - - ps->en = 0; - if (cso->max_anisotropy > 1.0) { - /* no idea, binary driver sets it, works without it.. meh.. */ - ps->wrap |= (1 << 5); - -/* if (cso->max_anisotropy >= 8.0) { - ps->en |= NV20TCL_TX_ENABLE_ANISO_8X; - } else - if (cso->max_anisotropy >= 4.0) { - ps->en |= NV20TCL_TX_ENABLE_ANISO_4X; - } else { - ps->en |= NV20TCL_TX_ENABLE_ANISO_2X; - }*/ - } - - switch (cso->mag_img_filter) { - case PIPE_TEX_FILTER_LINEAR: - filter |= NV20TCL_TX_FILTER_MAGNIFY_LINEAR; - break; - case PIPE_TEX_FILTER_NEAREST: - default: - filter |= NV20TCL_TX_FILTER_MAGNIFY_NEAREST; - break; - } - - switch (cso->min_img_filter) { - case PIPE_TEX_FILTER_LINEAR: - switch (cso->min_mip_filter) { - case PIPE_TEX_MIPFILTER_NEAREST: - filter |= - NV20TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST; - break; - case PIPE_TEX_MIPFILTER_LINEAR: - filter |= NV20TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR; - break; - case PIPE_TEX_MIPFILTER_NONE: - default: - filter |= NV20TCL_TX_FILTER_MINIFY_LINEAR; - break; - } - break; - case PIPE_TEX_FILTER_NEAREST: - default: - switch (cso->min_mip_filter) { - case PIPE_TEX_MIPFILTER_NEAREST: - filter |= - NV20TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST; - break; - case PIPE_TEX_MIPFILTER_LINEAR: - filter |= - NV20TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR; - break; - case PIPE_TEX_MIPFILTER_NONE: - default: - filter |= NV20TCL_TX_FILTER_MINIFY_NEAREST; - break; - } - break; - } - - ps->filt = filter; - -/* if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { - switch (cso->compare_func) { - case PIPE_FUNC_NEVER: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_NEVER; - break; - case PIPE_FUNC_GREATER: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_GREATER; - break; - case PIPE_FUNC_EQUAL: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_EQUAL; - break; - case PIPE_FUNC_GEQUAL: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_GEQUAL; - break; - case PIPE_FUNC_LESS: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_LESS; - break; - case PIPE_FUNC_NOTEQUAL: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_NOTEQUAL; - break; - case PIPE_FUNC_LEQUAL: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_LEQUAL; - break; - case PIPE_FUNC_ALWAYS: - ps->wrap |= NV10TCL_TX_WRAP_RCOMP_ALWAYS; - break; - default: - break; - } - }*/ - - ps->bcol = ((float_to_ubyte(cso->border_color[3]) << 24) | - (float_to_ubyte(cso->border_color[0]) << 16) | - (float_to_ubyte(cso->border_color[1]) << 8) | - (float_to_ubyte(cso->border_color[2]) << 0)); - - return (void *)ps; -} - -static void -nv20_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler) -{ - struct nv20_context *nv20 = nv20_context(pipe); - unsigned unit; - - for (unit = 0; unit < nr; unit++) { - nv20->tex_sampler[unit] = sampler[unit]; - nv20->dirty_samplers |= (1 << unit); - } -} - -static void -nv20_sampler_state_delete(struct pipe_context *pipe, void *hwcso) -{ - FREE(hwcso); -} - -static void -nv20_set_sampler_texture(struct pipe_context *pipe, unsigned nr, - struct pipe_texture **miptree) -{ - struct nv20_context *nv20 = nv20_context(pipe); - unsigned unit; - - for (unit = 0; unit < nr; unit++) { - nv20->tex_miptree[unit] = (struct nv20_miptree *)miptree[unit]; - nv20->dirty_samplers |= (1 << unit); - } -} - -static void * -nv20_rasterizer_state_create(struct pipe_context *pipe, - const struct pipe_rasterizer_state *cso) -{ - struct nv20_rasterizer_state *rs; - int i; - - /*XXX: ignored: - * light_twoside - * offset_cw/ccw -nohw - * scissor - * point_smooth -nohw - * multisample - * offset_units / offset_scale - */ - rs = MALLOC(sizeof(struct nv20_rasterizer_state)); - - rs->templ = cso; - - rs->shade_model = cso->flatshade ? NV20TCL_SHADE_MODEL_FLAT : - NV20TCL_SHADE_MODEL_SMOOTH; - - rs->line_width = (unsigned char)(cso->line_width * 8.0) & 0xff; - rs->line_smooth_en = cso->line_smooth ? 1 : 0; - - /* XXX: nv20 and nv25 different! */ - rs->point_size = *(uint32_t*)&cso->point_size; - - rs->poly_smooth_en = cso->poly_smooth ? 1 : 0; - - if (cso->front_winding == PIPE_WINDING_CCW) { - rs->front_face = NV20TCL_FRONT_FACE_CCW; - rs->poly_mode_front = nvgl_polygon_mode(cso->fill_ccw); - rs->poly_mode_back = nvgl_polygon_mode(cso->fill_cw); - } else { - rs->front_face = NV20TCL_FRONT_FACE_CW; - rs->poly_mode_front = nvgl_polygon_mode(cso->fill_cw); - rs->poly_mode_back = nvgl_polygon_mode(cso->fill_ccw); - } - - switch (cso->cull_mode) { - case PIPE_WINDING_CCW: - rs->cull_face_en = 1; - if (cso->front_winding == PIPE_WINDING_CCW) - rs->cull_face = NV20TCL_CULL_FACE_FRONT; - else - rs->cull_face = NV20TCL_CULL_FACE_BACK; - break; - case PIPE_WINDING_CW: - rs->cull_face_en = 1; - if (cso->front_winding == PIPE_WINDING_CW) - rs->cull_face = NV20TCL_CULL_FACE_FRONT; - else - rs->cull_face = NV20TCL_CULL_FACE_BACK; - break; - case PIPE_WINDING_BOTH: - rs->cull_face_en = 1; - rs->cull_face = NV20TCL_CULL_FACE_FRONT_AND_BACK; - break; - case PIPE_WINDING_NONE: - default: - rs->cull_face_en = 0; - rs->cull_face = 0; - break; - } - - if (cso->point_sprite) { - rs->point_sprite = (1 << 0); - for (i = 0; i < 8; i++) { - if (cso->sprite_coord_mode[i] != PIPE_SPRITE_COORD_NONE) - rs->point_sprite |= (1 << (8 + i)); - } - } else { - rs->point_sprite = 0; - } - - return (void *)rs; -} - -static void -nv20_rasterizer_state_bind(struct pipe_context *pipe, void *rast) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - nv20->rast = (struct nv20_rasterizer_state*)rast; - - draw_set_rasterizer_state(nv20->draw, (nv20->rast ? nv20->rast->templ : NULL)); - - nv20->dirty |= NV20_NEW_RAST; -} - -static void -nv20_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso) -{ - FREE(hwcso); -} - -static void * -nv20_depth_stencil_alpha_state_create(struct pipe_context *pipe, - const struct pipe_depth_stencil_alpha_state *cso) -{ - struct nv20_depth_stencil_alpha_state *hw; - - hw = MALLOC(sizeof(struct nv20_depth_stencil_alpha_state)); - - hw->depth.func = nvgl_comparison_op(cso->depth.func); - hw->depth.write_enable = cso->depth.writemask ? 1 : 0; - hw->depth.test_enable = cso->depth.enabled ? 1 : 0; - - hw->stencil.enable = cso->stencil[0].enabled ? 1 : 0; - hw->stencil.wmask = cso->stencil[0].writemask; - hw->stencil.func = nvgl_comparison_op(cso->stencil[0].func); - hw->stencil.ref = cso->stencil[0].ref_value; - hw->stencil.vmask = cso->stencil[0].valuemask; - hw->stencil.fail = nvgl_stencil_op(cso->stencil[0].fail_op); - hw->stencil.zfail = nvgl_stencil_op(cso->stencil[0].zfail_op); - hw->stencil.zpass = nvgl_stencil_op(cso->stencil[0].zpass_op); - - hw->alpha.enabled = cso->alpha.enabled ? 1 : 0; - hw->alpha.func = nvgl_comparison_op(cso->alpha.func); - hw->alpha.ref = float_to_ubyte(cso->alpha.ref_value); - - return (void *)hw; -} - -static void -nv20_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *dsa) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - nv20->dsa = (struct nv20_depth_stencil_alpha_state*)dsa; - - nv20->dirty |= NV20_NEW_DSA; -} - -static void -nv20_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso) -{ - FREE(hwcso); -} - -static void * -nv20_vp_state_create(struct pipe_context *pipe, - const struct pipe_shader_state *templ) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - return draw_create_vertex_shader(nv20->draw, templ); -} - -static void -nv20_vp_state_bind(struct pipe_context *pipe, void *shader) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - draw_bind_vertex_shader(nv20->draw, (struct draw_vertex_shader *) shader); - - nv20->dirty |= NV20_NEW_VERTPROG; -} - -static void -nv20_vp_state_delete(struct pipe_context *pipe, void *shader) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - draw_delete_vertex_shader(nv20->draw, (struct draw_vertex_shader *) shader); -} - -static void * -nv20_fp_state_create(struct pipe_context *pipe, - const struct pipe_shader_state *cso) -{ - struct nv20_fragment_program *fp; - - fp = CALLOC(1, sizeof(struct nv20_fragment_program)); - fp->pipe.tokens = tgsi_dup_tokens(cso->tokens); - - tgsi_scan_shader(cso->tokens, &fp->info); - - return (void *)fp; -} - -static void -nv20_fp_state_bind(struct pipe_context *pipe, void *hwcso) -{ - struct nv20_context *nv20 = nv20_context(pipe); - struct nv20_fragment_program *fp = hwcso; - - nv20->fragprog.current = fp; - nv20->dirty |= NV20_NEW_FRAGPROG; -} - -static void -nv20_fp_state_delete(struct pipe_context *pipe, void *hwcso) -{ - struct nv20_context *nv20 = nv20_context(pipe); - struct nv20_fragment_program *fp = hwcso; - - nv20_fragprog_destroy(nv20, fp); - FREE((void*)fp->pipe.tokens); - FREE(fp); -} - -static void -nv20_set_blend_color(struct pipe_context *pipe, - const struct pipe_blend_color *bcol) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - nv20->blend_color = (struct pipe_blend_color*)bcol; - - nv20->dirty |= NV20_NEW_BLENDCOL; -} - -static void -nv20_set_clip_state(struct pipe_context *pipe, - const struct pipe_clip_state *clip) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - draw_set_clip_state(nv20->draw, clip); -} - -static void -nv20_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, - struct pipe_buffer *buf ) -{ - struct nv20_context *nv20 = nv20_context(pipe); - struct pipe_screen *pscreen = pipe->screen; - - assert(shader < PIPE_SHADER_TYPES); - assert(index == 0); - - if (buf) { - void *mapped; - if (buf->size && - (mapped = pipe_buffer_map(pscreen, buf, PIPE_BUFFER_USAGE_CPU_READ))) - { - memcpy(nv20->constbuf[shader], mapped, buf->size); - nv20->constbuf_nr[shader] = - buf->size / (4 * sizeof(float)); - pipe_buffer_unmap(pscreen, buf); - } - } -} - -static void -nv20_set_framebuffer_state(struct pipe_context *pipe, - const struct pipe_framebuffer_state *fb) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - nv20->framebuffer = (struct pipe_framebuffer_state*)fb; - - nv20->dirty |= NV20_NEW_FRAMEBUFFER; -} - -static void -nv20_set_polygon_stipple(struct pipe_context *pipe, - const struct pipe_poly_stipple *stipple) -{ - NOUVEAU_ERR("line stipple hahaha\n"); -} - -static void -nv20_set_scissor_state(struct pipe_context *pipe, - const struct pipe_scissor_state *s) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - nv20->scissor = (struct pipe_scissor_state*)s; - - nv20->dirty |= NV20_NEW_SCISSOR; -} - -static void -nv20_set_viewport_state(struct pipe_context *pipe, - const struct pipe_viewport_state *vpt) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - nv20->viewport = (struct pipe_viewport_state*)vpt; - - draw_set_viewport_state(nv20->draw, nv20->viewport); - - nv20->dirty |= NV20_NEW_VIEWPORT; -} - -static void -nv20_set_vertex_buffers(struct pipe_context *pipe, unsigned count, - const struct pipe_vertex_buffer *vb) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - memcpy(nv20->vtxbuf, vb, sizeof(*vb) * count); - nv20->dirty |= NV20_NEW_VTXARRAYS; - - draw_set_vertex_buffers(nv20->draw, count, vb); -} - -static void -nv20_set_vertex_elements(struct pipe_context *pipe, unsigned count, - const struct pipe_vertex_element *ve) -{ - struct nv20_context *nv20 = nv20_context(pipe); - - memcpy(nv20->vtxelt, ve, sizeof(*ve) * count); - nv20->dirty |= NV20_NEW_VTXARRAYS; - - draw_set_vertex_elements(nv20->draw, count, ve); -} - -void -nv20_init_state_functions(struct nv20_context *nv20) -{ - nv20->pipe.create_blend_state = nv20_blend_state_create; - nv20->pipe.bind_blend_state = nv20_blend_state_bind; - nv20->pipe.delete_blend_state = nv20_blend_state_delete; - - nv20->pipe.create_sampler_state = nv20_sampler_state_create; - nv20->pipe.bind_fragment_sampler_states = nv20_sampler_state_bind; - nv20->pipe.delete_sampler_state = nv20_sampler_state_delete; - nv20->pipe.set_fragment_sampler_textures = nv20_set_sampler_texture; - - nv20->pipe.create_rasterizer_state = nv20_rasterizer_state_create; - nv20->pipe.bind_rasterizer_state = nv20_rasterizer_state_bind; - nv20->pipe.delete_rasterizer_state = nv20_rasterizer_state_delete; - - nv20->pipe.create_depth_stencil_alpha_state = - nv20_depth_stencil_alpha_state_create; - nv20->pipe.bind_depth_stencil_alpha_state = - nv20_depth_stencil_alpha_state_bind; - nv20->pipe.delete_depth_stencil_alpha_state = - nv20_depth_stencil_alpha_state_delete; - - nv20->pipe.create_vs_state = nv20_vp_state_create; - nv20->pipe.bind_vs_state = nv20_vp_state_bind; - nv20->pipe.delete_vs_state = nv20_vp_state_delete; - - nv20->pipe.create_fs_state = nv20_fp_state_create; - nv20->pipe.bind_fs_state = nv20_fp_state_bind; - nv20->pipe.delete_fs_state = nv20_fp_state_delete; - - nv20->pipe.set_blend_color = nv20_set_blend_color; - nv20->pipe.set_clip_state = nv20_set_clip_state; - nv20->pipe.set_constant_buffer = nv20_set_constant_buffer; - nv20->pipe.set_framebuffer_state = nv20_set_framebuffer_state; - nv20->pipe.set_polygon_stipple = nv20_set_polygon_stipple; - nv20->pipe.set_scissor_state = nv20_set_scissor_state; - nv20->pipe.set_viewport_state = nv20_set_viewport_state; - - nv20->pipe.set_vertex_buffers = nv20_set_vertex_buffers; - nv20->pipe.set_vertex_elements = nv20_set_vertex_elements; -} - diff --git a/src/gallium/drivers/nv20/nv20_state.h b/src/gallium/drivers/nv20/nv20_state.h deleted file mode 100644 index dde41065685..00000000000 --- a/src/gallium/drivers/nv20/nv20_state.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef __NV20_STATE_H__ -#define __NV20_STATE_H__ - -#include "pipe/p_state.h" -#include "tgsi/tgsi_scan.h" - -struct nv20_blend_state { - uint32_t b_enable; - uint32_t b_srcfunc; - uint32_t b_dstfunc; - - uint32_t c_mask; - - uint32_t d_enable; -}; - -struct nv20_sampler_state { - uint32_t wrap; - uint32_t en; - uint32_t filt; - uint32_t bcol; -}; - -struct nv20_rasterizer_state { - uint32_t shade_model; - - uint32_t line_width; - uint32_t line_smooth_en; - - uint32_t point_size; - - uint32_t poly_smooth_en; - - uint32_t poly_mode_front; - uint32_t poly_mode_back; - - uint32_t front_face; - uint32_t cull_face; - uint32_t cull_face_en; - - uint32_t point_sprite; - - const struct pipe_rasterizer_state *templ; -}; - -struct nv20_vertex_program_exec { - uint32_t data[4]; - boolean has_branch_offset; - int const_index; -}; - -struct nv20_vertex_program_data { - int index; /* immediates == -1 */ - float value[4]; -}; - -struct nv20_vertex_program { - const struct pipe_shader_state *pipe; - - boolean translated; - struct nv20_vertex_program_exec *insns; - unsigned nr_insns; - struct nv20_vertex_program_data *consts; - unsigned nr_consts; - - struct nouveau_resource *exec; - unsigned exec_start; - struct nouveau_resource *data; - unsigned data_start; - unsigned data_start_min; - - uint32_t ir; - uint32_t or; -}; - -struct nv20_fragment_program_data { - unsigned offset; - unsigned index; -}; - -struct nv20_fragment_program { - struct pipe_shader_state pipe; - struct tgsi_shader_info info; - - boolean translated; - boolean on_hw; - unsigned samplers; - - uint32_t *insn; - int insn_len; - - struct nv20_fragment_program_data *consts; - unsigned nr_consts; - - struct pipe_buffer *buffer; - - uint32_t fp_control; - uint32_t fp_reg_control; -}; - - -struct nv20_depth_stencil_alpha_state { - struct { - uint32_t func; - uint32_t write_enable; - uint32_t test_enable; - } depth; - - struct { - uint32_t enable; - uint32_t wmask; - uint32_t func; - uint32_t ref; - uint32_t vmask; - uint32_t fail; - uint32_t zfail; - uint32_t zpass; - } stencil; - - struct { - uint32_t enabled; - uint32_t func; - uint32_t ref; - } alpha; -}; - -struct nv20_miptree { - struct pipe_texture base; - struct nouveau_bo *bo; - - struct pipe_buffer *buffer; - uint total_size; - - struct { - uint pitch; - uint *image_offset; - } level[PIPE_MAX_TEXTURE_LEVELS]; -}; - -#endif diff --git a/src/gallium/drivers/nv20/nv20_state_emit.c b/src/gallium/drivers/nv20/nv20_state_emit.c deleted file mode 100644 index 6bbd1fdae9d..00000000000 --- a/src/gallium/drivers/nv20/nv20_state_emit.c +++ /dev/null @@ -1,426 +0,0 @@ -#include "nv20_context.h" -#include "nv20_state.h" -#include "draw/draw_context.h" - -static void nv20_state_emit_blend(struct nv20_context* nv20) -{ - struct nv20_blend_state *b = nv20->blend; - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - - BEGIN_RING(chan, kelvin, NV20TCL_DITHER_ENABLE, 1); - OUT_RING (chan, b->d_enable); - - BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_ENABLE, 1); - OUT_RING (chan, b->b_enable); - - BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_SRC, 2); - OUT_RING (chan, b->b_srcfunc); - OUT_RING (chan, b->b_dstfunc); - - BEGIN_RING(chan, kelvin, NV20TCL_COLOR_MASK, 1); - OUT_RING (chan, b->c_mask); -} - -static void nv20_state_emit_blend_color(struct nv20_context* nv20) -{ - struct pipe_blend_color *c = nv20->blend_color; - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - - BEGIN_RING(chan, kelvin, NV20TCL_BLEND_COLOR, 1); - OUT_RING (chan, - (float_to_ubyte(c->color[3]) << 24)| - (float_to_ubyte(c->color[0]) << 16)| - (float_to_ubyte(c->color[1]) << 8) | - (float_to_ubyte(c->color[2]) << 0)); -} - -static void nv20_state_emit_rast(struct nv20_context* nv20) -{ - struct nv20_rasterizer_state *r = nv20->rast; - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - - BEGIN_RING(chan, kelvin, NV20TCL_SHADE_MODEL, 2); - OUT_RING (chan, r->shade_model); - OUT_RING (chan, r->line_width); - - - BEGIN_RING(chan, kelvin, NV20TCL_POINT_SIZE, 1); - OUT_RING (chan, r->point_size); - - BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_MODE_FRONT, 2); - OUT_RING (chan, r->poly_mode_front); - OUT_RING (chan, r->poly_mode_back); - - - BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE, 2); - OUT_RING (chan, r->cull_face); - OUT_RING (chan, r->front_face); - - BEGIN_RING(chan, kelvin, NV20TCL_LINE_SMOOTH_ENABLE, 2); - OUT_RING (chan, r->line_smooth_en); - OUT_RING (chan, r->poly_smooth_en); - - BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE_ENABLE, 1); - OUT_RING (chan, r->cull_face_en); -} - -static void nv20_state_emit_dsa(struct nv20_context* nv20) -{ - struct nv20_depth_stencil_alpha_state *d = nv20->dsa; - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - - BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_FUNC, 1); - OUT_RING (chan, d->depth.func); - - BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_WRITE_ENABLE, 1); - OUT_RING (chan, d->depth.write_enable); - - BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_TEST_ENABLE, 1); - OUT_RING (chan, d->depth.test_enable); - - BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_UNK17D8, 1); - OUT_RING (chan, 1); - -#if 0 - BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_ENABLE, 1); - OUT_RING (chan, d->stencil.enable); - BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_MASK, 7); - OUT_RINGp (chan, (uint32_t *)&(d->stencil.wmask), 7); -#endif - - BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_ENABLE, 1); - OUT_RING (chan, d->alpha.enabled); - - BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_FUNC, 1); - OUT_RING (chan, d->alpha.func); - - BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_REF, 1); - OUT_RING (chan, d->alpha.ref); -} - -static void nv20_state_emit_viewport(struct nv20_context* nv20) -{ -} - -static void nv20_state_emit_scissor(struct nv20_context* nv20) -{ - /* NV20TCL_SCISSOR_* is probably a software method */ -/* struct pipe_scissor_state *s = nv20->scissor; - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - - BEGIN_RING(chan, kelvin, NV20TCL_SCISSOR_HORIZ, 2); - OUT_RING (chan, ((s->maxx - s->minx) << 16) | s->minx); - OUT_RING (chan, ((s->maxy - s->miny) << 16) | s->miny);*/ -} - -static void nv20_state_emit_framebuffer(struct nv20_context* nv20) -{ - struct pipe_framebuffer_state* fb = nv20->framebuffer; - struct nv04_surface *rt, *zeta = NULL; - uint32_t rt_format, w, h; - int colour_format = 0, zeta_format = 0; - struct nv20_miptree *nv20mt = 0; - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - - w = fb->cbufs[0]->width; - h = fb->cbufs[0]->height; - colour_format = fb->cbufs[0]->format; - rt = (struct nv04_surface *)fb->cbufs[0]; - - if (fb->zsbuf) { - if (colour_format) { - assert(w == fb->zsbuf->width); - assert(h == fb->zsbuf->height); - } else { - w = fb->zsbuf->width; - h = fb->zsbuf->height; - } - - zeta_format = fb->zsbuf->format; - zeta = (struct nv04_surface *)fb->zsbuf; - } - - rt_format = NV20TCL_RT_FORMAT_TYPE_LINEAR | 0x20; - - switch (colour_format) { - case PIPE_FORMAT_X8R8G8B8_UNORM: - rt_format |= NV20TCL_RT_FORMAT_COLOR_X8R8G8B8; - break; - case PIPE_FORMAT_A8R8G8B8_UNORM: - case 0: - rt_format |= NV20TCL_RT_FORMAT_COLOR_A8R8G8B8; - break; - case PIPE_FORMAT_R5G6B5_UNORM: - rt_format |= NV20TCL_RT_FORMAT_COLOR_R5G6B5; - break; - default: - assert(0); - } - - if (zeta) { - BEGIN_RING(chan, kelvin, NV20TCL_RT_PITCH, 1); - OUT_RING (chan, rt->pitch | (zeta->pitch << 16)); - } else { - BEGIN_RING(chan, kelvin, NV20TCL_RT_PITCH, 1); - OUT_RING (chan, rt->pitch | (rt->pitch << 16)); - } - - nv20mt = (struct nv20_miptree *)rt->base.texture; - nv20->rt[0] = nv20mt->buffer; - - if (zeta_format) - { - nv20mt = (struct nv20_miptree *)zeta->base.texture; - nv20->zeta = nv20mt->buffer; - } - - BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 3); - OUT_RING (chan, (w << 16) | 0); - OUT_RING (chan, (h << 16) | 0); /*NV20TCL_RT_VERT */ - OUT_RING (chan, rt_format); /* NV20TCL_RT_FORMAT */ - BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 2); - OUT_RING (chan, ((w - 1) << 16) | 0); - OUT_RING (chan, ((h - 1) << 16) | 0); -} - -static void nv20_vertex_layout(struct nv20_context *nv20) -{ - struct nv20_fragment_program *fp = nv20->fragprog.current; - struct draw_context *dc = nv20->draw; - int src; - int i; - struct vertex_info *vinfo = &nv20->vertex_info; - const enum interp_mode colorInterp = INTERP_LINEAR; - boolean colors[2] = { FALSE }; - boolean generics[12] = { FALSE }; - boolean fog = FALSE; - - memset(vinfo, 0, sizeof(*vinfo)); - - /* - * Assumed NV20 hardware vertex attribute order: - * 0 position, 1 ?, 2 ?, 3 col0, - * 4 col1?, 5 ?, 6 ?, 7 ?, - * 8 ?, 9 tex0, 10 tex1, 11 tex2, - * 12 tex3, 13 ?, 14 ?, 15 ? - * unaccounted: wgh, nor, fog - * There are total 16 attrs. - * vinfo->hwfmt[0] has a used-bit corresponding to each of these. - * relation to TGSI_SEMANTIC_*: - * - POSITION: position (always used) - * - COLOR: col1, col0 - * - GENERIC: tex3, tex2, tex1, tex0, normal, weight - * - FOG: fog - */ - - for (i = 0; i < fp->info.num_inputs; i++) { - int isn = fp->info.input_semantic_name[i]; - int isi = fp->info.input_semantic_index[i]; - switch (isn) { - case TGSI_SEMANTIC_POSITION: - break; - case TGSI_SEMANTIC_COLOR: - assert(isi < 2); - colors[isi] = TRUE; - break; - case TGSI_SEMANTIC_GENERIC: - assert(isi < 12); - generics[isi] = TRUE; - break; - case TGSI_SEMANTIC_FOG: - fog = TRUE; - break; - default: - assert(0 && "unknown input_semantic_name"); - } - } - - /* always do position */ { - src = draw_find_shader_output(dc, TGSI_SEMANTIC_POSITION, 0); - draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_LINEAR, src); - vinfo->hwfmt[0] |= (1 << 0); - } - - /* two unnamed generics */ - for (i = 4; i < 6; i++) { - if (!generics[i]) - continue; - src = draw_find_shader_output(dc, TGSI_SEMANTIC_GENERIC, i); - draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src); - vinfo->hwfmt[0] |= (1 << (i - 3)); - } - - if (colors[0]) { - src = draw_find_shader_output(dc, TGSI_SEMANTIC_COLOR, 0); - draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src); - vinfo->hwfmt[0] |= (1 << 3); - } - - if (colors[1]) { - src = draw_find_shader_output(dc, TGSI_SEMANTIC_COLOR, 1); - draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src); - vinfo->hwfmt[0] |= (1 << 4); - } - - /* four unnamed generics */ - for (i = 6; i < 10; i++) { - if (!generics[i]) - continue; - src = draw_find_shader_output(dc, TGSI_SEMANTIC_GENERIC, i); - draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src); - vinfo->hwfmt[0] |= (1 << (i - 1)); - } - - /* tex0, tex1, tex2, tex3 */ - for (i = 0; i < 4; i++) { - if (!generics[i]) - continue; - src = draw_find_shader_output(dc, TGSI_SEMANTIC_GENERIC, i); - draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src); - vinfo->hwfmt[0] |= (1 << (i + 9)); - } - - /* two unnamed generics */ - for (i = 10; i < 12; i++) { - if (!generics[i]) - continue; - src = draw_find_shader_output(dc, TGSI_SEMANTIC_GENERIC, i); - draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src); - vinfo->hwfmt[0] |= (1 << (i + 3)); - } - - if (fog) { - src = draw_find_shader_output(dc, TGSI_SEMANTIC_FOG, 0); - draw_emit_vertex_attr(vinfo, EMIT_1F, INTERP_PERSPECTIVE, src); - vinfo->hwfmt[0] |= (1 << 15); - } - - draw_compute_vertex_size(vinfo); -} - -void -nv20_emit_hw_state(struct nv20_context *nv20) -{ - struct nv20_screen *screen = nv20->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *kelvin = screen->kelvin; - struct nouveau_bo *rt_bo; - int i; - - if (nv20->dirty & NV20_NEW_VERTPROG) { - //nv20_vertprog_bind(nv20, nv20->vertprog.current); - nv20->dirty &= ~NV20_NEW_VERTPROG; - } - - if (nv20->dirty & NV20_NEW_FRAGPROG) { - nv20_fragprog_bind(nv20, nv20->fragprog.current); - /*XXX: clear NV20_NEW_FRAGPROG if no new program uploaded */ - nv20->dirty_samplers |= (1<<10); - nv20->dirty_samplers = 0; - } - - if (nv20->dirty_samplers || (nv20->dirty & NV20_NEW_FRAGPROG)) { - nv20_fragtex_bind(nv20); - nv20->dirty &= ~NV20_NEW_FRAGPROG; - } - - if (nv20->dirty & NV20_NEW_VTXARRAYS) { - nv20->dirty &= ~NV20_NEW_VTXARRAYS; - nv20_vertex_layout(nv20); - nv20_vtxbuf_bind(nv20); - } - - if (nv20->dirty & NV20_NEW_BLEND) { - nv20->dirty &= ~NV20_NEW_BLEND; - nv20_state_emit_blend(nv20); - } - - if (nv20->dirty & NV20_NEW_BLENDCOL) { - nv20->dirty &= ~NV20_NEW_BLENDCOL; - nv20_state_emit_blend_color(nv20); - } - - if (nv20->dirty & NV20_NEW_RAST) { - nv20->dirty &= ~NV20_NEW_RAST; - nv20_state_emit_rast(nv20); - } - - if (nv20->dirty & NV20_NEW_DSA) { - nv20->dirty &= ~NV20_NEW_DSA; - nv20_state_emit_dsa(nv20); - } - - if (nv20->dirty & NV20_NEW_VIEWPORT) { - nv20->dirty &= ~NV20_NEW_VIEWPORT; - nv20_state_emit_viewport(nv20); - } - - if (nv20->dirty & NV20_NEW_SCISSOR) { - nv20->dirty &= ~NV20_NEW_SCISSOR; - nv20_state_emit_scissor(nv20); - } - - if (nv20->dirty & NV20_NEW_FRAMEBUFFER) { - nv20->dirty &= ~NV20_NEW_FRAMEBUFFER; - nv20_state_emit_framebuffer(nv20); - } - - /* Emit relocs for every referenced buffer. - * This is to ensure the bufmgr has an accurate idea of how - * the buffer is used. This isn't very efficient, but we don't - * seem to take a significant performance hit. Will be improved - * at some point. Vertex arrays are emitted by nv20_vbo.c - */ - - /* Render target */ - rt_bo = nouveau_bo(nv20->rt[0]); - BEGIN_RING(chan, kelvin, NV20TCL_DMA_COLOR, 1); - OUT_RELOCo(chan, rt_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - BEGIN_RING(chan, kelvin, NV20TCL_COLOR_OFFSET, 1); - OUT_RELOCl(chan, rt_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - - if (nv20->zeta) { - struct nouveau_bo *zeta_bo = nouveau_bo(nv20->zeta); - BEGIN_RING(chan, kelvin, NV20TCL_DMA_ZETA, 1); - OUT_RELOCo(chan, zeta_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - BEGIN_RING(chan, kelvin, NV20TCL_ZETA_OFFSET, 1); - OUT_RELOCl(chan, zeta_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - /* XXX for when we allocate LMA on nv17 */ -/* BEGIN_RING(chan, kelvin, NV10TCL_LMA_DEPTH_BUFFER_OFFSET, 1); - OUT_RELOCl(chan, nouveau_bo(nv20->zeta + lma_offset));*/ - } - - /* Vertex buffer */ - BEGIN_RING(chan, kelvin, NV20TCL_DMA_VTXBUF0, 1); - OUT_RELOCo(chan, rt_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - BEGIN_RING(chan, kelvin, NV20TCL_COLOR_OFFSET, 1); - OUT_RELOCl(chan, rt_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - - /* Texture images */ - for (i = 0; i < 2; i++) { - if (!(nv20->fp_samplers & (1 << i))) - continue; - struct nouveau_bo *bo = nouveau_bo(nv20->tex[i].buffer); - BEGIN_RING(chan, kelvin, NV20TCL_TX_OFFSET(i), 1); - OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | - NOUVEAU_BO_GART | NOUVEAU_BO_RD); - BEGIN_RING(chan, kelvin, NV20TCL_TX_FORMAT(i), 1); - OUT_RELOCd(chan, bo, nv20->tex[i].format, - NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD | - NOUVEAU_BO_OR, NV20TCL_TX_FORMAT_DMA0, - NV20TCL_TX_FORMAT_DMA1); - } -} - diff --git a/src/gallium/drivers/nv20/nv20_surface.c b/src/gallium/drivers/nv20/nv20_surface.c deleted file mode 100644 index 5deb8cc6f1a..00000000000 --- a/src/gallium/drivers/nv20/nv20_surface.c +++ /dev/null @@ -1,63 +0,0 @@ - -/************************************************************************** - * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "nv20_context.h" -#include "pipe/p_defines.h" -#include "util/u_simple_screen.h" -#include "util/u_inlines.h" -#include "util/u_tile.h" - -static void -nv20_surface_copy(struct pipe_context *pipe, - struct pipe_surface *dest, unsigned destx, unsigned desty, - struct pipe_surface *src, unsigned srcx, unsigned srcy, - unsigned width, unsigned height) -{ - struct nv20_context *nv20 = nv20_context(pipe); - struct nv04_surface_2d *eng2d = nv20->screen->eng2d; - - eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height); -} - -static void -nv20_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest, - unsigned destx, unsigned desty, unsigned width, - unsigned height, unsigned value) -{ - struct nv20_context *nv20 = nv20_context(pipe); - struct nv04_surface_2d *eng2d = nv20->screen->eng2d; - - eng2d->fill(eng2d, dest, destx, desty, width, height, value); -} - -void -nv20_init_surface_functions(struct nv20_context *nv20) -{ - nv20->pipe.surface_copy = nv20_surface_copy; - nv20->pipe.surface_fill = nv20_surface_fill; -} diff --git a/src/gallium/drivers/nv20/nv20_transfer.c b/src/gallium/drivers/nv20/nv20_transfer.c deleted file mode 100644 index c91f8b12cc2..00000000000 --- a/src/gallium/drivers/nv20/nv20_transfer.c +++ /dev/null @@ -1,178 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "nv20_context.h" -#include "nv20_screen.h" -#include "nv20_state.h" - -struct nv20_transfer { - struct pipe_transfer base; - struct pipe_surface *surface; - boolean direct; -}; - -static void -nv20_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height, - struct pipe_texture *template) -{ - memset(template, 0, sizeof(struct pipe_texture)); - template->target = pt->target; - template->format = pt->format; - template->width0 = width; - template->height0 = height; - template->depth0 = 1; - template->last_level = 0; - template->nr_samples = pt->nr_samples; - - template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC | - NOUVEAU_TEXTURE_USAGE_LINEAR; -} - -static struct pipe_transfer * -nv20_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt, - unsigned face, unsigned level, unsigned zslice, - enum pipe_transfer_usage usage, - unsigned x, unsigned y, unsigned w, unsigned h) -{ - struct nv20_miptree *mt = (struct nv20_miptree *)pt; - struct nv20_transfer *tx; - struct pipe_texture tx_tex_template, *tx_tex; - - tx = CALLOC_STRUCT(nv20_transfer); - if (!tx) - return NULL; - - pipe_texture_reference(&tx->base.texture, pt); - tx->base.x = x; - tx->base.y = y; - tx->base.width = w; - tx->base.height = h; - tx->base.stride = mt->level[level].pitch; - tx->base.usage = usage; - tx->base.face = face; - tx->base.level = level; - tx->base.zslice = zslice; - - /* Direct access to texture */ - if ((pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC || - debug_get_bool_option("NOUVEAU_NO_TRANSFER", TRUE/*XXX:FALSE*/)) && - pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) - { - tx->direct = true; - tx->surface = pscreen->get_tex_surface(pscreen, pt, - 0, 0, 0, - pipe_transfer_buffer_flags(&tx->base)); - return &tx->base; - } - - tx->direct = false; - - nv20_compatible_transfer_tex(pt, w, h, &tx_tex_template); - - tx_tex = pscreen->texture_create(pscreen, &tx_tex_template); - if (!tx_tex) - { - FREE(tx); - return NULL; - } - - tx->base.stride = ((struct nv20_miptree*)tx_tex)->level[0].pitch; - - tx->surface = pscreen->get_tex_surface(pscreen, tx_tex, - face, level, zslice, - pipe_transfer_buffer_flags(&tx->base)); - - pipe_texture_reference(&tx_tex, NULL); - - if (!tx->surface) - { - pipe_surface_reference(&tx->surface, NULL); - FREE(tx); - return NULL; - } - - if (usage & PIPE_TRANSFER_READ) { - struct nv20_screen *nvscreen = nv20_screen(pscreen); - struct pipe_surface *src; - - src = pscreen->get_tex_surface(pscreen, pt, - face, level, zslice, - PIPE_BUFFER_USAGE_GPU_READ); - - /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */ - /* TODO: Check if SIFM can un-swizzle */ - nvscreen->eng2d->copy(nvscreen->eng2d, - tx->surface, 0, 0, - src, x, y, - w, h); - - pipe_surface_reference(&src, NULL); - } - - return &tx->base; -} - -static void -nv20_transfer_del(struct pipe_transfer *ptx) -{ - struct nv20_transfer *tx = (struct nv20_transfer *)ptx; - - if (!tx->direct && (ptx->usage = PIPE_TRANSFER_WRITE)) { - struct pipe_screen *pscreen = ptx->texture->screen; - struct nv20_screen *nvscreen = nv20_screen(pscreen); - struct pipe_surface *dst; - - dst = pscreen->get_tex_surface(pscreen, ptx->texture, - ptx->face, ptx->level, ptx->zslice, - PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER); - - /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */ - nvscreen->eng2d->copy(nvscreen->eng2d, - dst, tx->base.x, tx->base.y, - tx->surface, 0, 0, - tx->base.width, tx->base.height); - - pipe_surface_reference(&dst, NULL); - } - - pipe_surface_reference(&tx->surface, NULL); - pipe_texture_reference(&ptx->texture, NULL); - FREE(ptx); -} - -static void * -nv20_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx) -{ - struct nv20_transfer *tx = (struct nv20_transfer *)ptx; - struct nv04_surface *ns = (struct nv04_surface *)tx->surface; - struct nv20_miptree *mt = (struct nv20_miptree *)tx->surface->texture; - void *map = pipe_buffer_map(pscreen, mt->buffer, - pipe_transfer_buffer_flags(ptx)); - - if(!tx->direct) - return map + ns->base.offset; - else - return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format); -} - -static void -nv20_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx) -{ - struct nv20_transfer *tx = (struct nv20_transfer *)ptx; - struct nv20_miptree *mt = (struct nv20_miptree *)tx->surface->texture; - - pipe_buffer_unmap(pscreen, mt->buffer); -} - -void -nv20_screen_init_transfer_functions(struct pipe_screen *pscreen) -{ - pscreen->get_tex_transfer = nv20_transfer_new; - pscreen->tex_transfer_destroy = nv20_transfer_del; - pscreen->transfer_map = nv20_transfer_map; - pscreen->transfer_unmap = nv20_transfer_unmap; -} diff --git a/src/gallium/drivers/nv20/nv20_vbo.c b/src/gallium/drivers/nv20/nv20_vbo.c deleted file mode 100644 index 263f18706a5..00000000000 --- a/src/gallium/drivers/nv20/nv20_vbo.c +++ /dev/null @@ -1,79 +0,0 @@ -#include "draw/draw_context.h" -#include "pipe/p_context.h" -#include "pipe/p_state.h" -#include "util/u_inlines.h" - -#include "nv20_context.h" -#include "nv20_state.h" - -#include "nouveau/nouveau_channel.h" -#include "nouveau/nouveau_pushbuf.h" - -void nv20_draw_elements( struct pipe_context *pipe, - struct pipe_buffer *indexBuffer, - unsigned indexSize, - unsigned prim, unsigned start, unsigned count) -{ - struct pipe_screen *pscreen = pipe->screen; - struct nv20_context *nv20 = nv20_context( pipe ); - struct draw_context *draw = nv20->draw; - unsigned i; - - nv20_emit_hw_state(nv20); - - /* - * Map vertex buffers - */ - for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - if (nv20->vtxbuf[i].buffer) { - void *buf - = pipe_buffer_map(pscreen, - nv20->vtxbuf[i].buffer, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_vertex_buffer(draw, i, buf); - } - } - /* Map index buffer, if present */ - if (indexBuffer) { - void *mapped_indexes - = pipe_buffer_map(pscreen, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); - } - else { - /* no index/element buffer */ - draw_set_mapped_element_buffer(draw, 0, NULL); - } - - draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, - nv20->constbuf[PIPE_SHADER_VERTEX], - nv20->constbuf_nr[PIPE_SHADER_VERTEX]); - - /* draw! */ - draw_arrays(nv20->draw, prim, start, count); - - /* - * unmap vertex/index buffers - */ - for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - if (nv20->vtxbuf[i].buffer) { - pipe_buffer_unmap(pscreen, nv20->vtxbuf[i].buffer); - draw_set_mapped_vertex_buffer(draw, i, NULL); - } - } - if (indexBuffer) { - pipe_buffer_unmap(pscreen, indexBuffer); - draw_set_mapped_element_buffer(draw, 0, NULL); - } - - draw_flush(nv20->draw); -} - -void nv20_draw_arrays( struct pipe_context *pipe, - unsigned prim, unsigned start, unsigned count) -{ - nv20_draw_elements(pipe, NULL, 0, prim, start, count); -} - - - diff --git a/src/gallium/drivers/nv20/nv20_vertprog.c b/src/gallium/drivers/nv20/nv20_vertprog.c deleted file mode 100644 index 7283ed4d005..00000000000 --- a/src/gallium/drivers/nv20/nv20_vertprog.c +++ /dev/null @@ -1,841 +0,0 @@ -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_state.h" -#include "util/u_inlines.h" - -#include "pipe/p_shader_tokens.h" -#include "tgsi/tgsi_parse.h" -#include "tgsi/tgsi_dump.h" - -#include "nv20_context.h" -#include "nv20_state.h" - -/* TODO (at least...): - * 1. Indexed consts + ARL - * 2. Arb. swz/negation - * 3. NV_vp11, NV_vp2, NV_vp3 features - * - extra arith opcodes - * - branching - * - texture sampling - * - indexed attribs - * - indexed results - * 4. bugs - */ - -#define SWZ_X 0 -#define SWZ_Y 1 -#define SWZ_Z 2 -#define SWZ_W 3 -#define MASK_X 8 -#define MASK_Y 4 -#define MASK_Z 2 -#define MASK_W 1 -#define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W) -#define DEF_SCALE 0 -#define DEF_CTEST 0 -#include "nv20_shader.h" - -#define swz(s,x,y,z,w) nv20_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w) -#define neg(s) nv20_sr_neg((s)) -#define abs(s) nv20_sr_abs((s)) - -struct nv20_vpc { - struct nv20_vertex_program *vp; - - struct nv20_vertex_program_exec *vpi; - - unsigned output_map[PIPE_MAX_SHADER_OUTPUTS]; - - int high_temp; - int temp_temp_count; - - struct nv20_sreg *imm; - unsigned nr_imm; -}; - -static struct nv20_sreg -temp(struct nv20_vpc *vpc) -{ - int idx; - - idx = vpc->temp_temp_count++; - idx += vpc->high_temp + 1; - return nv20_sr(NV30SR_TEMP, idx); -} - -static struct nv20_sreg -constant(struct nv20_vpc *vpc, int pipe, float x, float y, float z, float w) -{ - struct nv20_vertex_program *vp = vpc->vp; - struct nv20_vertex_program_data *vpd; - int idx; - - if (pipe >= 0) { - for (idx = 0; idx < vp->nr_consts; idx++) { - if (vp->consts[idx].index == pipe) - return nv20_sr(NV30SR_CONST, idx); - } - } - - idx = vp->nr_consts++; - vp->consts = realloc(vp->consts, sizeof(*vpd) * vp->nr_consts); - vpd = &vp->consts[idx]; - - vpd->index = pipe; - vpd->value[0] = x; - vpd->value[1] = y; - vpd->value[2] = z; - vpd->value[3] = w; - return nv20_sr(NV30SR_CONST, idx); -} - -#define arith(cc,s,o,d,m,s0,s1,s2) \ - nv20_vp_arith((cc), (s), NV30_VP_INST_##o, (d), (m), (s0), (s1), (s2)) - -static void -emit_src(struct nv20_vpc *vpc, uint32_t *hw, int pos, struct nv20_sreg src) -{ - struct nv20_vertex_program *vp = vpc->vp; - uint32_t sr = 0; - - switch (src.type) { - case NV30SR_TEMP: - sr |= (NV30_VP_SRC_REG_TYPE_TEMP << NV30_VP_SRC_REG_TYPE_SHIFT); - sr |= (src.index << NV30_VP_SRC_TEMP_SRC_SHIFT); - break; - case NV30SR_INPUT: - sr |= (NV30_VP_SRC_REG_TYPE_INPUT << - NV30_VP_SRC_REG_TYPE_SHIFT); - vp->ir |= (1 << src.index); - hw[1] |= (src.index << NV30_VP_INST_INPUT_SRC_SHIFT); - break; - case NV30SR_CONST: - sr |= (NV30_VP_SRC_REG_TYPE_CONST << - NV30_VP_SRC_REG_TYPE_SHIFT); - assert(vpc->vpi->const_index == -1 || - vpc->vpi->const_index == src.index); - vpc->vpi->const_index = src.index; - break; - case NV30SR_NONE: - sr |= (NV30_VP_SRC_REG_TYPE_INPUT << - NV30_VP_SRC_REG_TYPE_SHIFT); - break; - default: - assert(0); - } - - if (src.negate) - sr |= NV30_VP_SRC_NEGATE; - - if (src.abs) - hw[0] |= (1 << (21 + pos)); - - sr |= ((src.swz[0] << NV30_VP_SRC_SWZ_X_SHIFT) | - (src.swz[1] << NV30_VP_SRC_SWZ_Y_SHIFT) | - (src.swz[2] << NV30_VP_SRC_SWZ_Z_SHIFT) | - (src.swz[3] << NV30_VP_SRC_SWZ_W_SHIFT)); - -/* - * |VVV| - * d�.�b - * \u/ - * - */ - - switch (pos) { - case 0: - hw[1] |= ((sr & NV30_VP_SRC0_HIGH_MASK) >> - NV30_VP_SRC0_HIGH_SHIFT) << NV30_VP_INST_SRC0H_SHIFT; - hw[2] |= (sr & NV30_VP_SRC0_LOW_MASK) << - NV30_VP_INST_SRC0L_SHIFT; - break; - case 1: - hw[2] |= sr << NV30_VP_INST_SRC1_SHIFT; - break; - case 2: - hw[2] |= ((sr & NV30_VP_SRC2_HIGH_MASK) >> - NV30_VP_SRC2_HIGH_SHIFT) << NV30_VP_INST_SRC2H_SHIFT; - hw[3] |= (sr & NV30_VP_SRC2_LOW_MASK) << - NV30_VP_INST_SRC2L_SHIFT; - break; - default: - assert(0); - } -} - -static void -emit_dst(struct nv20_vpc *vpc, uint32_t *hw, int slot, struct nv20_sreg dst) -{ - struct nv20_vertex_program *vp = vpc->vp; - - switch (dst.type) { - case NV30SR_TEMP: - hw[0] |= (dst.index << NV30_VP_INST_DEST_TEMP_ID_SHIFT); - break; - case NV30SR_OUTPUT: - switch (dst.index) { - case NV30_VP_INST_DEST_COL0 : vp->or |= (1 << 0); break; - case NV30_VP_INST_DEST_COL1 : vp->or |= (1 << 1); break; - case NV30_VP_INST_DEST_BFC0 : vp->or |= (1 << 2); break; - case NV30_VP_INST_DEST_BFC1 : vp->or |= (1 << 3); break; - case NV30_VP_INST_DEST_FOGC : vp->or |= (1 << 4); break; - case NV30_VP_INST_DEST_PSZ : vp->or |= (1 << 5); break; - case NV30_VP_INST_DEST_TC(0): vp->or |= (1 << 14); break; - case NV30_VP_INST_DEST_TC(1): vp->or |= (1 << 15); break; - case NV30_VP_INST_DEST_TC(2): vp->or |= (1 << 16); break; - case NV30_VP_INST_DEST_TC(3): vp->or |= (1 << 17); break; - case NV30_VP_INST_DEST_TC(4): vp->or |= (1 << 18); break; - case NV30_VP_INST_DEST_TC(5): vp->or |= (1 << 19); break; - case NV30_VP_INST_DEST_TC(6): vp->or |= (1 << 20); break; - case NV30_VP_INST_DEST_TC(7): vp->or |= (1 << 21); break; - default: - break; - } - - hw[3] |= (dst.index << NV30_VP_INST_DEST_SHIFT); - hw[0] |= NV30_VP_INST_VEC_DEST_TEMP_MASK | (1<<20); - - /*XXX: no way this is entirely correct, someone needs to - * figure out what exactly it is. - */ - hw[3] |= 0x800; - break; - default: - assert(0); - } -} - -static void -nv20_vp_arith(struct nv20_vpc *vpc, int slot, int op, - struct nv20_sreg dst, int mask, - struct nv20_sreg s0, struct nv20_sreg s1, - struct nv20_sreg s2) -{ - struct nv20_vertex_program *vp = vpc->vp; - uint32_t *hw; - - vp->insns = realloc(vp->insns, ++vp->nr_insns * sizeof(*vpc->vpi)); - vpc->vpi = &vp->insns[vp->nr_insns - 1]; - memset(vpc->vpi, 0, sizeof(*vpc->vpi)); - vpc->vpi->const_index = -1; - - hw = vpc->vpi->data; - - hw[0] |= (NV30_VP_INST_COND_TR << NV30_VP_INST_COND_SHIFT); - hw[0] |= ((0 << NV30_VP_INST_COND_SWZ_X_SHIFT) | - (1 << NV30_VP_INST_COND_SWZ_Y_SHIFT) | - (2 << NV30_VP_INST_COND_SWZ_Z_SHIFT) | - (3 << NV30_VP_INST_COND_SWZ_W_SHIFT)); - - hw[1] |= (op << NV30_VP_INST_VEC_OPCODE_SHIFT); -// hw[3] |= NV30_VP_INST_SCA_DEST_TEMP_MASK; -// hw[3] |= (mask << NV30_VP_INST_VEC_WRITEMASK_SHIFT); - - if (dst.type == NV30SR_OUTPUT) { - if (slot) - hw[3] |= (mask << NV30_VP_INST_SDEST_WRITEMASK_SHIFT); - else - hw[3] |= (mask << NV30_VP_INST_VDEST_WRITEMASK_SHIFT); - } else { - if (slot) - hw[3] |= (mask << NV30_VP_INST_STEMP_WRITEMASK_SHIFT); - else - hw[3] |= (mask << NV30_VP_INST_VTEMP_WRITEMASK_SHIFT); - } - - emit_dst(vpc, hw, slot, dst); - emit_src(vpc, hw, 0, s0); - emit_src(vpc, hw, 1, s1); - emit_src(vpc, hw, 2, s2); -} - -static INLINE struct nv20_sreg -tgsi_src(struct nv20_vpc *vpc, const struct tgsi_full_src_register *fsrc) { - struct nv20_sreg src; - - switch (fsrc->Register.File) { - case TGSI_FILE_INPUT: - src = nv20_sr(NV30SR_INPUT, fsrc->Register.Index); - break; - case TGSI_FILE_CONSTANT: - src = constant(vpc, fsrc->Register.Index, 0, 0, 0, 0); - break; - case TGSI_FILE_IMMEDIATE: - src = vpc->imm[fsrc->Register.Index]; - break; - case TGSI_FILE_TEMPORARY: - if (vpc->high_temp < fsrc->Register.Index) - vpc->high_temp = fsrc->Register.Index; - src = nv20_sr(NV30SR_TEMP, fsrc->Register.Index); - break; - default: - NOUVEAU_ERR("bad src file\n"); - break; - } - - src.abs = fsrc->Register.Absolute; - src.negate = fsrc->Register.Negate; - src.swz[0] = fsrc->Register.SwizzleX; - src.swz[1] = fsrc->Register.SwizzleY; - src.swz[2] = fsrc->Register.SwizzleZ; - src.swz[3] = fsrc->Register.SwizzleW; - return src; -} - -static INLINE struct nv20_sreg -tgsi_dst(struct nv20_vpc *vpc, const struct tgsi_full_dst_register *fdst) { - struct nv20_sreg dst; - - switch (fdst->Register.File) { - case TGSI_FILE_OUTPUT: - dst = nv20_sr(NV30SR_OUTPUT, - vpc->output_map[fdst->Register.Index]); - - break; - case TGSI_FILE_TEMPORARY: - dst = nv20_sr(NV30SR_TEMP, fdst->Register.Index); - if (vpc->high_temp < dst.index) - vpc->high_temp = dst.index; - break; - default: - NOUVEAU_ERR("bad dst file\n"); - break; - } - - return dst; -} - -static INLINE int -tgsi_mask(uint tgsi) -{ - int mask = 0; - - if (tgsi & TGSI_WRITEMASK_X) mask |= MASK_X; - if (tgsi & TGSI_WRITEMASK_Y) mask |= MASK_Y; - if (tgsi & TGSI_WRITEMASK_Z) mask |= MASK_Z; - if (tgsi & TGSI_WRITEMASK_W) mask |= MASK_W; - return mask; -} - -static boolean -nv20_vertprog_parse_instruction(struct nv20_vpc *vpc, - const struct tgsi_full_instruction *finst) -{ - struct nv20_sreg src[3], dst, tmp; - struct nv20_sreg none = nv20_sr(NV30SR_NONE, 0); - int mask; - int ai = -1, ci = -1; - int i; - - if (finst->Instruction.Opcode == TGSI_OPCODE_END) - return TRUE; - - vpc->temp_temp_count = 0; - for (i = 0; i < finst->Instruction.NumSrcRegs; i++) { - const struct tgsi_full_src_register *fsrc; - - fsrc = &finst->Src[i]; - if (fsrc->Register.File == TGSI_FILE_TEMPORARY) { - src[i] = tgsi_src(vpc, fsrc); - } - } - - for (i = 0; i < finst->Instruction.NumSrcRegs; i++) { - const struct tgsi_full_src_register *fsrc; - - fsrc = &finst->Src[i]; - switch (fsrc->Register.File) { - case TGSI_FILE_INPUT: - if (ai == -1 || ai == fsrc->Register.Index) { - ai = fsrc->Register.Index; - src[i] = tgsi_src(vpc, fsrc); - } else { - src[i] = temp(vpc); - arith(vpc, 0, OP_MOV, src[i], MASK_ALL, - tgsi_src(vpc, fsrc), none, none); - } - break; - /*XXX: index comparison is broken now that consts come from - * two different register files. - */ - case TGSI_FILE_CONSTANT: - case TGSI_FILE_IMMEDIATE: - if (ci == -1 || ci == fsrc->Register.Index) { - ci = fsrc->Register.Index; - src[i] = tgsi_src(vpc, fsrc); - } else { - src[i] = temp(vpc); - arith(vpc, 0, OP_MOV, src[i], MASK_ALL, - tgsi_src(vpc, fsrc), none, none); - } - break; - case TGSI_FILE_TEMPORARY: - /* handled above */ - break; - default: - NOUVEAU_ERR("bad src file\n"); - return FALSE; - } - } - - dst = tgsi_dst(vpc, &finst->Dst[0]); - mask = tgsi_mask(finst->Dst[0].Register.WriteMask); - - switch (finst->Instruction.Opcode) { - case TGSI_OPCODE_ABS: - arith(vpc, 0, OP_MOV, dst, mask, abs(src[0]), none, none); - break; - case TGSI_OPCODE_ADD: - arith(vpc, 0, OP_ADD, dst, mask, src[0], none, src[1]); - break; - case TGSI_OPCODE_ARL: - arith(vpc, 0, OP_ARL, dst, mask, src[0], none, none); - break; - case TGSI_OPCODE_DP3: - arith(vpc, 0, OP_DP3, dst, mask, src[0], src[1], none); - break; - case TGSI_OPCODE_DP4: - arith(vpc, 0, OP_DP4, dst, mask, src[0], src[1], none); - break; - case TGSI_OPCODE_DPH: - arith(vpc, 0, OP_DPH, dst, mask, src[0], src[1], none); - break; - case TGSI_OPCODE_DST: - arith(vpc, 0, OP_DST, dst, mask, src[0], src[1], none); - break; - case TGSI_OPCODE_EX2: - arith(vpc, 1, OP_EX2, dst, mask, none, none, src[0]); - break; - case TGSI_OPCODE_EXP: - arith(vpc, 1, OP_EXP, dst, mask, none, none, src[0]); - break; - case TGSI_OPCODE_FLR: - arith(vpc, 0, OP_FLR, dst, mask, src[0], none, none); - break; - case TGSI_OPCODE_FRC: - arith(vpc, 0, OP_FRC, dst, mask, src[0], none, none); - break; - case TGSI_OPCODE_LG2: - arith(vpc, 1, OP_LG2, dst, mask, none, none, src[0]); - break; - case TGSI_OPCODE_LIT: - arith(vpc, 1, OP_LIT, dst, mask, none, none, src[0]); - break; - case TGSI_OPCODE_LOG: - arith(vpc, 1, OP_LOG, dst, mask, none, none, src[0]); - break; - case TGSI_OPCODE_MAD: - arith(vpc, 0, OP_MAD, dst, mask, src[0], src[1], src[2]); - break; - case TGSI_OPCODE_MAX: - arith(vpc, 0, OP_MAX, dst, mask, src[0], src[1], none); - break; - case TGSI_OPCODE_MIN: - arith(vpc, 0, OP_MIN, dst, mask, src[0], src[1], none); - break; - case TGSI_OPCODE_MOV: - arith(vpc, 0, OP_MOV, dst, mask, src[0], none, none); - break; - case TGSI_OPCODE_MUL: - arith(vpc, 0, OP_MUL, dst, mask, src[0], src[1], none); - break; - case TGSI_OPCODE_POW: - tmp = temp(vpc); - arith(vpc, 1, OP_LG2, tmp, MASK_X, none, none, - swz(src[0], X, X, X, X)); - arith(vpc, 0, OP_MUL, tmp, MASK_X, swz(tmp, X, X, X, X), - swz(src[1], X, X, X, X), none); - arith(vpc, 1, OP_EX2, dst, mask, none, none, - swz(tmp, X, X, X, X)); - break; - case TGSI_OPCODE_RCP: - arith(vpc, 1, OP_RCP, dst, mask, none, none, src[0]); - break; - case TGSI_OPCODE_RET: - break; - case TGSI_OPCODE_RSQ: - arith(vpc, 1, OP_RSQ, dst, mask, none, none, src[0]); - break; - case TGSI_OPCODE_SGE: - arith(vpc, 0, OP_SGE, dst, mask, src[0], src[1], none); - break; - case TGSI_OPCODE_SGT: - arith(vpc, 0, OP_SGT, dst, mask, src[0], src[1], none); - break; - case TGSI_OPCODE_SLT: - arith(vpc, 0, OP_SLT, dst, mask, src[0], src[1], none); - break; - case TGSI_OPCODE_SUB: - arith(vpc, 0, OP_ADD, dst, mask, src[0], none, neg(src[1])); - break; - case TGSI_OPCODE_XPD: - tmp = temp(vpc); - arith(vpc, 0, OP_MUL, tmp, mask, - swz(src[0], Z, X, Y, Y), swz(src[1], Y, Z, X, X), none); - arith(vpc, 0, OP_MAD, dst, (mask & ~MASK_W), - swz(src[0], Y, Z, X, X), swz(src[1], Z, X, Y, Y), - neg(tmp)); - break; - default: - NOUVEAU_ERR("invalid opcode %d\n", finst->Instruction.Opcode); - return FALSE; - } - - return TRUE; -} - -static boolean -nv20_vertprog_parse_decl_output(struct nv20_vpc *vpc, - const struct tgsi_full_declaration *fdec) -{ - int hw; - - switch (fdec->Semantic.Name) { - case TGSI_SEMANTIC_POSITION: - hw = NV30_VP_INST_DEST_POS; - break; - case TGSI_SEMANTIC_COLOR: - if (fdec->Semantic.Index == 0) { - hw = NV30_VP_INST_DEST_COL0; - } else - if (fdec->Semantic.Index == 1) { - hw = NV30_VP_INST_DEST_COL1; - } else { - NOUVEAU_ERR("bad colour semantic index\n"); - return FALSE; - } - break; - case TGSI_SEMANTIC_BCOLOR: - if (fdec->Semantic.Index == 0) { - hw = NV30_VP_INST_DEST_BFC0; - } else - if (fdec->Semantic.Index == 1) { - hw = NV30_VP_INST_DEST_BFC1; - } else { - NOUVEAU_ERR("bad bcolour semantic index\n"); - return FALSE; - } - break; - case TGSI_SEMANTIC_FOG: - hw = NV30_VP_INST_DEST_FOGC; - break; - case TGSI_SEMANTIC_PSIZE: - hw = NV30_VP_INST_DEST_PSZ; - break; - case TGSI_SEMANTIC_GENERIC: - if (fdec->Semantic.Index <= 7) { - hw = NV30_VP_INST_DEST_TC(fdec->Semantic.Index); - } else { - NOUVEAU_ERR("bad generic semantic index\n"); - return FALSE; - } - break; - case TGSI_SEMANTIC_EDGEFLAG: - NOUVEAU_ERR("cannot handle edgeflag output\n"); - return FALSE; - default: - NOUVEAU_ERR("bad output semantic\n"); - return FALSE; - } - - vpc->output_map[fdec->Range.First] = hw; - return TRUE; -} - -static boolean -nv20_vertprog_prepare(struct nv20_vpc *vpc) -{ - struct tgsi_parse_context p; - int nr_imm = 0; - - tgsi_parse_init(&p, vpc->vp->pipe.tokens); - while (!tgsi_parse_end_of_tokens(&p)) { - const union tgsi_full_token *tok = &p.FullToken; - - tgsi_parse_token(&p); - switch(tok->Token.Type) { - case TGSI_TOKEN_TYPE_IMMEDIATE: - nr_imm++; - break; - default: - break; - } - } - tgsi_parse_free(&p); - - if (nr_imm) { - vpc->imm = CALLOC(nr_imm, sizeof(struct nv20_sreg)); - assert(vpc->imm); - } - - return TRUE; -} - -static void -nv20_vertprog_translate(struct nv20_context *nv20, - struct nv20_vertex_program *vp) -{ - struct tgsi_parse_context parse; - struct nv20_vpc *vpc = NULL; - - tgsi_dump(vp->pipe.tokens,0); - - vpc = CALLOC(1, sizeof(struct nv20_vpc)); - if (!vpc) - return; - vpc->vp = vp; - vpc->high_temp = -1; - - if (!nv20_vertprog_prepare(vpc)) { - FREE(vpc); - return; - } - - tgsi_parse_init(&parse, vp->pipe.tokens); - - while (!tgsi_parse_end_of_tokens(&parse)) { - tgsi_parse_token(&parse); - - switch (parse.FullToken.Token.Type) { - case TGSI_TOKEN_TYPE_DECLARATION: - { - const struct tgsi_full_declaration *fdec; - fdec = &parse.FullToken.FullDeclaration; - switch (fdec->Declaration.File) { - case TGSI_FILE_OUTPUT: - if (!nv20_vertprog_parse_decl_output(vpc, fdec)) - goto out_err; - break; - default: - break; - } - } - break; - case TGSI_TOKEN_TYPE_IMMEDIATE: - { - const struct tgsi_full_immediate *imm; - - imm = &parse.FullToken.FullImmediate; - assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32); - assert(imm->Immediate.NrTokens == 4 + 1); - vpc->imm[vpc->nr_imm++] = - constant(vpc, -1, - imm->u[0].Float, - imm->u[1].Float, - imm->u[2].Float, - imm->u[3].Float); - } - break; - case TGSI_TOKEN_TYPE_INSTRUCTION: - { - const struct tgsi_full_instruction *finst; - finst = &parse.FullToken.FullInstruction; - if (!nv20_vertprog_parse_instruction(vpc, finst)) - goto out_err; - } - break; - default: - break; - } - } - - vp->insns[vp->nr_insns - 1].data[3] |= NV30_VP_INST_LAST; - vp->translated = TRUE; -out_err: - tgsi_parse_free(&parse); - FREE(vpc); -} - -static boolean -nv20_vertprog_validate(struct nv20_context *nv20) -{ - struct pipe_screen *pscreen = nv20->pipe.screen; - struct nouveau_winsys *nvws = nv20->nvws; - struct nouveau_grobj *rankine = nv20->screen->rankine; - struct nv20_vertex_program *vp; - struct pipe_buffer *constbuf; - boolean upload_code = FALSE, upload_data = FALSE; - int i; - - vp = nv20->vertprog; - constbuf = nv20->constbuf[PIPE_SHADER_VERTEX]; - - /* Translate TGSI shader into hw bytecode */ - if (!vp->translated) { - nv20_vertprog_translate(nv20, vp); - if (!vp->translated) - return FALSE; - } - - /* Allocate hw vtxprog exec slots */ - if (!vp->exec) { - struct nouveau_resource *heap = nv20->screen->vp_exec_heap; - struct nouveau_stateobj *so; - uint vplen = vp->nr_insns; - - if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) { - while (heap->next && heap->size < vplen) { - struct nv20_vertex_program *evict; - - evict = heap->next->priv; - nvws->res_free(&evict->exec); - } - - if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) - assert(0); - } - - so = so_new(2, 0); - so_method(so, rankine, NV34TCL_VP_START_FROM_ID, 1); - so_data (so, vp->exec->start); - so_ref(so, &vp->so); - - upload_code = TRUE; - } - - /* Allocate hw vtxprog const slots */ - if (vp->nr_consts && !vp->data) { - struct nouveau_resource *heap = nv20->screen->vp_data_heap; - - if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) { - while (heap->next && heap->size < vp->nr_consts) { - struct nv20_vertex_program *evict; - - evict = heap->next->priv; - nvws->res_free(&evict->data); - } - - if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) - assert(0); - } - - /*XXX: handle this some day */ - assert(vp->data->start >= vp->data_start_min); - - upload_data = TRUE; - if (vp->data_start != vp->data->start) - upload_code = TRUE; - } - - /* If exec or data segments moved we need to patch the program to - * fixup offsets and register IDs. - */ - if (vp->exec_start != vp->exec->start) { - for (i = 0; i < vp->nr_insns; i++) { - struct nv20_vertex_program_exec *vpi = &vp->insns[i]; - - if (vpi->has_branch_offset) { - assert(0); - } - } - - vp->exec_start = vp->exec->start; - } - - if (vp->nr_consts && vp->data_start != vp->data->start) { - for (i = 0; i < vp->nr_insns; i++) { - struct nv20_vertex_program_exec *vpi = &vp->insns[i]; - - if (vpi->const_index >= 0) { - vpi->data[1] &= ~NV30_VP_INST_CONST_SRC_MASK; - vpi->data[1] |= - (vpi->const_index + vp->data->start) << - NV30_VP_INST_CONST_SRC_SHIFT; - - } - } - - vp->data_start = vp->data->start; - } - - /* Update + Upload constant values */ - if (vp->nr_consts) { - float *map = NULL; - - if (constbuf) { - map = pipe_buffer_map(pscreen, constbuf, - PIPE_BUFFER_USAGE_CPU_READ); - } - - for (i = 0; i < vp->nr_consts; i++) { - struct nv20_vertex_program_data *vpd = &vp->consts[i]; - - if (vpd->index >= 0) { - if (!upload_data && - !memcmp(vpd->value, &map[vpd->index * 4], - 4 * sizeof(float))) - continue; - memcpy(vpd->value, &map[vpd->index * 4], - 4 * sizeof(float)); - } - - BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_CONST_ID, 5); - OUT_RING (i + vp->data->start); - OUT_RINGp ((uint32_t *)vpd->value, 4); - } - - if (constbuf) - pipe_buffer_unmap(pscreen, constbuf); - } - - /* Upload vtxprog */ - if (upload_code) { -#if 0 - for (i = 0; i < vp->nr_insns; i++) { - NOUVEAU_MSG("VP inst %d: 0x%08x 0x%08x 0x%08x 0x%08x\n", - i, vp->insns[i].data[0], vp->insns[i].data[1], - vp->insns[i].data[2], vp->insns[i].data[3]); - } -#endif - BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_FROM_ID, 1); - OUT_RING (vp->exec->start); - for (i = 0; i < vp->nr_insns; i++) { - BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_INST(0), 4); - OUT_RINGp (vp->insns[i].data, 4); - } - } - - if (vp->so != nv20->state.hw[NV30_STATE_VERTPROG]) { - so_ref(vp->so, &nv20->state.hw[NV30_STATE_VERTPROG]); - return TRUE; - } - - return FALSE; -} - -void -nv20_vertprog_destroy(struct nv20_context *nv20, struct nv20_vertex_program *vp) -{ - struct nouveau_winsys *nvws = nv20->screen->nvws; - - vp->translated = FALSE; - - if (vp->nr_insns) { - FREE(vp->insns); - vp->insns = NULL; - vp->nr_insns = 0; - } - - if (vp->nr_consts) { - FREE(vp->consts); - vp->consts = NULL; - vp->nr_consts = 0; - } - - nvws->res_free(&vp->exec); - vp->exec_start = 0; - nvws->res_free(&vp->data); - vp->data_start = 0; - vp->data_start_min = 0; - - vp->ir = vp->or = 0; - so_ref(NULL, &vp->so); -} - -struct nv20_state_entry nv20_state_vertprog = { - .validate = nv20_vertprog_validate, - .dirty = { - .pipe = NV30_NEW_VERTPROG /*| NV30_NEW_UCP*/, - .hw = NV30_STATE_VERTPROG, - } -}; diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c index ea8a610fe69..c29c36e20aa 100644 --- a/src/gallium/drivers/nv30/nv30_miptree.c +++ b/src/gallium/drivers/nv30/nv30_miptree.c @@ -5,7 +5,7 @@ #include "util/u_math.h" #include "nv30_context.h" -#include "../nv04/nv04_surface_2d.h" +#include "../nouveau/nv04_surface_2d.h" static void nv30_miptree_layout(struct nv30_miptree *nv30mt) diff --git a/src/gallium/drivers/nv30/nv30_screen.h b/src/gallium/drivers/nv30/nv30_screen.h index 5fbd998b539..744a72de91a 100644 --- a/src/gallium/drivers/nv30/nv30_screen.h +++ b/src/gallium/drivers/nv30/nv30_screen.h @@ -3,7 +3,7 @@ #include "nouveau/nouveau_screen.h" -#include "nv04/nv04_surface_2d.h" +#include "nouveau/nv04_surface_2d.h" struct nv30_screen { struct nouveau_screen base; diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c index d62627daa55..ad1a9a51952 100644 --- a/src/gallium/drivers/nv40/nv40_miptree.c +++ b/src/gallium/drivers/nv40/nv40_miptree.c @@ -5,7 +5,7 @@ #include "util/u_math.h" #include "nv40_context.h" -#include "../nv04/nv04_surface_2d.h" +#include "../nouveau/nv04_surface_2d.h" diff --git a/src/gallium/drivers/nv40/nv40_screen.h b/src/gallium/drivers/nv40/nv40_screen.h index 57b4c8fc46c..98fde8755b9 100644 --- a/src/gallium/drivers/nv40/nv40_screen.h +++ b/src/gallium/drivers/nv40/nv40_screen.h @@ -2,7 +2,7 @@ #define __NV40_SCREEN_H__ #include "nouveau/nouveau_screen.h" -#include "nv04/nv04_surface_2d.h" +#include "nouveau/nv04_surface_2d.h" struct nv40_screen { struct nouveau_screen base; diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile index 0937f68c34b..7e95f79d03c 100644 --- a/src/gallium/winsys/drm/nouveau/dri/Makefile +++ b/src/gallium/winsys/drm/nouveau/dri/Makefile @@ -6,9 +6,6 @@ LIBNAME = nouveau_dri.so PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ - $(TOP)/src/gallium/drivers/nv04/libnv04.a \ - $(TOP)/src/gallium/drivers/nv10/libnv10.a \ - $(TOP)/src/gallium/drivers/nv20/libnv20.a \ $(TOP)/src/gallium/drivers/nv30/libnv30.a \ $(TOP)/src/gallium/drivers/nv40/libnv40.a \ $(TOP)/src/gallium/drivers/nv50/libnv50.a \ diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index 75cd1e2902b..3f41e5d0ceb 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -81,15 +81,6 @@ nouveau_drm_create_screen(struct drm_api *api, int fd, return NULL; switch (dev->chipset & 0xf0) { - case 0x00: - init = nv04_screen_create; - break; - case 0x10: - init = nv10_screen_create; - break; - case 0x20: - init = nv20_screen_create; - break; case 0x30: init = nv30_screen_create; break; @@ -160,15 +151,6 @@ nouveau_drm_create_context(struct drm_api *api, struct pipe_screen *pscreen) int i; switch (chipset & 0xf0) { - case 0x00: - init = nv04_create; - break; - case 0x10: - init = nv10_create; - break; - case 0x20: - init = nv20_create; - break; case 0x30: init = nv30_create; break; diff --git a/src/gallium/winsys/drm/nouveau/egl/Makefile b/src/gallium/winsys/drm/nouveau/egl/Makefile index 8e812acc86b..2c352603320 100644 --- a/src/gallium/winsys/drm/nouveau/egl/Makefile +++ b/src/gallium/winsys/drm/nouveau/egl/Makefile @@ -7,9 +7,6 @@ EGL_DRIVER_LIBS = -ldrm_nouveau EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ - $(TOP)/src/gallium/drivers/nv04/libnv04.a \ - $(TOP)/src/gallium/drivers/nv10/libnv10.a \ - $(TOP)/src/gallium/drivers/nv20/libnv20.a \ $(TOP)/src/gallium/drivers/nv30/libnv30.a \ $(TOP)/src/gallium/drivers/nv40/libnv40.a \ $(TOP)/src/gallium/drivers/nv50/libnv50.a \ diff --git a/src/gallium/winsys/drm/nouveau/xorg/Makefile b/src/gallium/winsys/drm/nouveau/xorg/Makefile index f0d3b337e83..179b50230b5 100644 --- a/src/gallium/winsys/drm/nouveau/xorg/Makefile +++ b/src/gallium/winsys/drm/nouveau/xorg/Makefile @@ -18,9 +18,6 @@ INCLUDES = \ LIBS = \ $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \ $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ - $(TOP)/src/gallium/drivers/nv04/libnv04.a \ - $(TOP)/src/gallium/drivers/nv10/libnv10.a \ - $(TOP)/src/gallium/drivers/nv20/libnv20.a \ $(TOP)/src/gallium/drivers/nv30/libnv30.a \ $(TOP)/src/gallium/drivers/nv40/libnv40.a \ $(TOP)/src/gallium/drivers/nv50/libnv50.a \ diff --git a/src/gallium/winsys/g3dvl/nouveau/Makefile b/src/gallium/winsys/g3dvl/nouveau/Makefile index 3965bd949f4..f07a7926d63 100644 --- a/src/gallium/winsys/g3dvl/nouveau/Makefile +++ b/src/gallium/winsys/g3dvl/nouveau/Makefile @@ -20,14 +20,11 @@ LDFLAGS += -L${DRMDIR}/lib \ -L${DRIDIR}/lib \ -L${GALLIUMDIR}/winsys/drm/nouveau/common \ -L${GALLIUMDIR}/auxiliary \ - -L${GALLIUMDIR}/drivers/nv04 \ - -L${GALLIUMDIR}/drivers/nv10 \ - -L${GALLIUMDIR}/drivers/nv20 \ -L${GALLIUMDIR}/drivers/nv30 \ -L${GALLIUMDIR}/drivers/nv40 \ -L${GALLIUMDIR}/drivers/nv50 -LIBS += -lnouveaudrm -ldriclient -ldrm_nouveau -ldrm -lnv04 -lnv10 -lnv20 -lnv30 -lnv40 -lnv50 -lgallium -lm +LIBS += -lnouveaudrm -ldriclient -ldrm_nouveau -ldrm -lnv30 -lnv40 -lnv50 -lgallium -lm ############################################# -- cgit v1.2.3 From 2eb7a2fccd5416d56fd88618ed3138aeeaf0da1c Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 5 Feb 2010 10:46:11 +0800 Subject: configure.ac: Check for xcb-dri2 to enable EGL dri2 driver. Check that xcb-dri2 is available before including EGL dri2 driver into EGL_DRIVERS_DIRS. --- configure.ac | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 16d315e13ad..b6f71f90430 100644 --- a/configure.ac +++ b/configure.ac @@ -911,13 +911,18 @@ if test "x$enable_egl" = xyes; then SRC_DIRS="$SRC_DIRS egl" EGL_LIB_DEPS="$DLOPEN_LIBS -lpthread" EGL_DRIVERS_DIRS="" - if test "$enable_static" != yes && test "$mesa_driver" != osmesa; then + if test "$enable_static" != yes; then # build egl_glx when libGL is built - EGL_DRIVERS_DIRS="glx" - fi - if test "$mesa_driver" == dri; then - # build egl_dri2 when dri is enabled - EGL_DRIVERS_DIRS="$EGL_DRIVERS_DIRS dri2" + if test "$mesa_driver" != osmesa; then + EGL_DRIVERS_DIRS="glx" + fi + + # build egl_dri2 when xcb-dri2 is available + PKG_CHECK_EXISTS([x11-xcb xcb-dri2 xcb-xfixes], + [have_xcb_dri2=yes],[have_xcb_dri2=no]) + if test "$have_xcb_dri2" = yes; then + EGL_DRIVERS_DIRS="$EGL_DRIVERS_DIRS dri2" + fi fi fi AC_SUBST([EGL_LIB_DEPS]) -- cgit v1.2.3 From 077bc2fda2afdbe0bf12e1baeafa4ce41b711d1d Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Fri, 5 Feb 2010 13:55:32 -0500 Subject: egl_dri2: Use pkg-config cflags and libs from configure output Running pkg-config in Makefiles is bad form, since it doesn't respect the PKG_CONFIG_PATH value set at ./configure time. --- configs/autoconf.in | 3 +++ configure.ac | 4 ++-- src/egl/drivers/dri2/Makefile | 5 ++--- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'configure.ac') diff --git a/configs/autoconf.in b/configs/autoconf.in index b0024ec6899..30637877f3b 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -153,3 +153,6 @@ GLW_PC_LIB_PRIV = @GLW_PC_LIB_PRIV@ GLW_PC_CFLAGS = @GLW_PC_CFLAGS@ OSMESA_PC_REQ = @OSMESA_PC_REQ@ OSMESA_PC_LIB_PRIV = @OSMESA_PC_LIB_PRIV@ + +EGL_DRI2_CFLAGS = @EGL_DRI2_CFLAGS@ +EGL_DRI2_LIBS = @EGL_DRI2_LIBS@ diff --git a/configure.ac b/configure.ac index af5a5fdc4b7..b6c6535fc6e 100644 --- a/configure.ac +++ b/configure.ac @@ -918,8 +918,8 @@ if test "x$enable_egl" = xyes; then fi # build egl_dri2 when xcb-dri2 is available - PKG_CHECK_EXISTS([x11-xcb xcb-dri2 xcb-xfixes], - [have_xcb_dri2=yes],[have_xcb_dri2=no]) + PKG_CHECK_MODULES([EGL_DRI2], [x11-xcb xcb-dri2 xcb-xfixes libdrm], + [have_xcb_dri2=yes],[have_xcb_dri2=no]) if test "$have_xcb_dri2" = yes; then EGL_DRIVERS_DIRS="$EGL_DRIVERS_DIRS dri2" fi diff --git a/src/egl/drivers/dri2/Makefile b/src/egl/drivers/dri2/Makefile index 95f95745311..129e67b8c66 100644 --- a/src/egl/drivers/dri2/Makefile +++ b/src/egl/drivers/dri2/Makefile @@ -11,9 +11,8 @@ EGL_INCLUDES = \ -I$(TOP)/src/egl/main \ -I$(TOP)/src/mesa \ -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" \ - $(shell pkg-config --cflags xcb-dri2 xcb-xfixes x11-xcb libdrm) + $(EGL_DRI2_CFLAGS) -EGL_CFLAGS = -EGL_LIBS = $(shell pkg-config --libs xcb-dri2 xcb-xfixes x11-xcb libdrm) +EGL_LIBS = $(EGL_DRI2_LIBS) include ../Makefile.template -- cgit v1.2.3 From 6e8897ff9f90601ebf6eed500ad942c11b54d1f7 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Tue, 9 Feb 2010 09:58:36 -0500 Subject: Retire miniglx and move the actual glx code up to src/glx --- Makefile | 6 +- configs/darwin | 4 +- configs/freebsd-dri | 2 +- configs/linux-dri | 2 +- configs/linux-dri-xcb | 2 +- configs/linux-indirect | 2 +- configure.ac | 2 +- docs/egl.html | 1 - src/gallium/state_trackers/egl/Makefile | 4 +- src/gallium/state_trackers/egl/x11/glxinit.c | 2 +- src/glx/Makefile | 95 +- src/glx/XF86dri.c | 637 ++ src/glx/clientattrib.c | 142 + src/glx/compsize.c | 189 + src/glx/dri2.c | 645 ++ src/glx/dri2.h | 106 + src/glx/dri2_glx.c | 666 ++ src/glx/dri_common.c | 450 ++ src/glx/dri_common.h | 63 + src/glx/dri_glx.c | 751 ++ src/glx/drisw_glx.c | 456 ++ src/glx/eval.c | 132 + src/glx/glcontextmodes.c | 544 ++ src/glx/glcontextmodes.h | 54 + src/glx/glx_pbuffer.c | 724 ++ src/glx/glx_query.c | 177 + src/glx/glxclient.h | 803 ++ src/glx/glxcmds.c | 3173 ++++++++ src/glx/glxcurrent.c | 513 ++ src/glx/glxext.c | 1060 +++ src/glx/glxextensions.c | 714 ++ src/glx/glxextensions.h | 292 + src/glx/glxhash.c | 473 ++ src/glx/glxhash.h | 20 + src/glx/indirect.c | 10669 +++++++++++++++++++++++++ src/glx/indirect.h | 721 ++ src/glx/indirect_init.c | 785 ++ src/glx/indirect_init.h | 41 + src/glx/indirect_size.c | 388 + src/glx/indirect_size.h | 88 + src/glx/indirect_texture_compression.c | 343 + src/glx/indirect_transpose_matrix.c | 85 + src/glx/indirect_vertex_array.c | 1985 +++++ src/glx/indirect_vertex_array.h | 64 + src/glx/indirect_vertex_array_priv.h | 311 + src/glx/indirect_vertex_program.c | 293 + src/glx/indirect_window_pos.c | 112 + src/glx/mini/Makefile | 89 - src/glx/mini/NOTES | 115 - src/glx/mini/dispatch.c | 64 - src/glx/mini/driver.h | 168 - src/glx/mini/example.miniglx.conf | 36 - src/glx/mini/miniglx.c | 2580 ------ src/glx/mini/miniglxP.h | 205 - src/glx/mini/miniglx_events.c | 983 --- src/glx/packrender.h | 243 + src/glx/packsingle.h | 213 + src/glx/pixel.c | 461 ++ src/glx/pixelstore.c | 352 + src/glx/render2.c | 381 + src/glx/renderpix.c | 218 + src/glx/single2.c | 974 +++ src/glx/singlepix.c | 196 + src/glx/vertarr.c | 212 + src/glx/x11/Makefile | 97 - src/glx/x11/XF86dri.c | 637 -- src/glx/x11/clientattrib.c | 142 - src/glx/x11/compsize.c | 189 - src/glx/x11/dri2.c | 645 -- src/glx/x11/dri2.h | 106 - src/glx/x11/dri2_glx.c | 666 -- src/glx/x11/dri_common.c | 450 -- src/glx/x11/dri_common.h | 63 - src/glx/x11/dri_glx.c | 751 -- src/glx/x11/drisw_glx.c | 456 -- src/glx/x11/eval.c | 132 - src/glx/x11/glcontextmodes.c | 544 -- src/glx/x11/glcontextmodes.h | 54 - src/glx/x11/glx_pbuffer.c | 724 -- src/glx/x11/glx_query.c | 177 - src/glx/x11/glxclient.h | 803 -- src/glx/x11/glxcmds.c | 3173 -------- src/glx/x11/glxcurrent.c | 513 -- src/glx/x11/glxext.c | 1060 --- src/glx/x11/glxextensions.c | 714 -- src/glx/x11/glxextensions.h | 292 - src/glx/x11/glxhash.c | 473 -- src/glx/x11/glxhash.h | 20 - src/glx/x11/indirect.c | 10669 ------------------------- src/glx/x11/indirect.h | 721 -- src/glx/x11/indirect_init.c | 785 -- src/glx/x11/indirect_init.h | 41 - src/glx/x11/indirect_size.c | 388 - src/glx/x11/indirect_size.h | 88 - src/glx/x11/indirect_texture_compression.c | 343 - src/glx/x11/indirect_transpose_matrix.c | 85 - src/glx/x11/indirect_vertex_array.c | 1985 ----- src/glx/x11/indirect_vertex_array.h | 64 - src/glx/x11/indirect_vertex_array_priv.h | 311 - src/glx/x11/indirect_vertex_program.c | 293 - src/glx/x11/indirect_window_pos.c | 112 - src/glx/x11/packrender.h | 243 - src/glx/x11/packsingle.h | 213 - src/glx/x11/pixel.c | 461 -- src/glx/x11/pixelstore.c | 352 - src/glx/x11/render2.c | 381 - src/glx/x11/renderpix.c | 218 - src/glx/x11/single2.c | 974 --- src/glx/x11/singlepix.c | 196 - src/glx/x11/vertarr.c | 212 - src/glx/x11/xf86dri.h | 124 - src/glx/x11/xf86dristr.h | 367 - src/glx/x11/xfont.c | 377 - src/glx/xf86dri.h | 124 + src/glx/xf86dristr.h | 367 + src/glx/xfont.c | 377 + src/mesa/glapi/Makefile | 20 +- src/mesa/main/dispatch.c | 2 +- 118 files changed, 32901 insertions(+), 37154 deletions(-) create mode 100644 src/glx/XF86dri.c create mode 100644 src/glx/clientattrib.c create mode 100644 src/glx/compsize.c create mode 100644 src/glx/dri2.c create mode 100644 src/glx/dri2.h create mode 100644 src/glx/dri2_glx.c create mode 100644 src/glx/dri_common.c create mode 100644 src/glx/dri_common.h create mode 100644 src/glx/dri_glx.c create mode 100644 src/glx/drisw_glx.c create mode 100644 src/glx/eval.c create mode 100644 src/glx/glcontextmodes.c create mode 100644 src/glx/glcontextmodes.h create mode 100644 src/glx/glx_pbuffer.c create mode 100644 src/glx/glx_query.c create mode 100644 src/glx/glxclient.h create mode 100644 src/glx/glxcmds.c create mode 100644 src/glx/glxcurrent.c create mode 100644 src/glx/glxext.c create mode 100644 src/glx/glxextensions.c create mode 100644 src/glx/glxextensions.h create mode 100644 src/glx/glxhash.c create mode 100644 src/glx/glxhash.h create mode 100644 src/glx/indirect.c create mode 100644 src/glx/indirect.h create mode 100644 src/glx/indirect_init.c create mode 100644 src/glx/indirect_init.h create mode 100644 src/glx/indirect_size.c create mode 100644 src/glx/indirect_size.h create mode 100644 src/glx/indirect_texture_compression.c create mode 100644 src/glx/indirect_transpose_matrix.c create mode 100644 src/glx/indirect_vertex_array.c create mode 100644 src/glx/indirect_vertex_array.h create mode 100644 src/glx/indirect_vertex_array_priv.h create mode 100644 src/glx/indirect_vertex_program.c create mode 100644 src/glx/indirect_window_pos.c delete mode 100644 src/glx/mini/Makefile delete mode 100644 src/glx/mini/NOTES delete mode 100644 src/glx/mini/dispatch.c delete mode 100644 src/glx/mini/driver.h delete mode 100644 src/glx/mini/example.miniglx.conf delete mode 100644 src/glx/mini/miniglx.c delete mode 100644 src/glx/mini/miniglxP.h delete mode 100644 src/glx/mini/miniglx_events.c create mode 100644 src/glx/packrender.h create mode 100644 src/glx/packsingle.h create mode 100644 src/glx/pixel.c create mode 100644 src/glx/pixelstore.c create mode 100644 src/glx/render2.c create mode 100644 src/glx/renderpix.c create mode 100644 src/glx/single2.c create mode 100644 src/glx/singlepix.c create mode 100644 src/glx/vertarr.c delete mode 100644 src/glx/x11/Makefile delete mode 100644 src/glx/x11/XF86dri.c delete mode 100644 src/glx/x11/clientattrib.c delete mode 100644 src/glx/x11/compsize.c delete mode 100644 src/glx/x11/dri2.c delete mode 100644 src/glx/x11/dri2.h delete mode 100644 src/glx/x11/dri2_glx.c delete mode 100644 src/glx/x11/dri_common.c delete mode 100644 src/glx/x11/dri_common.h delete mode 100644 src/glx/x11/dri_glx.c delete mode 100644 src/glx/x11/drisw_glx.c delete mode 100644 src/glx/x11/eval.c delete mode 100644 src/glx/x11/glcontextmodes.c delete mode 100644 src/glx/x11/glcontextmodes.h delete mode 100644 src/glx/x11/glx_pbuffer.c delete mode 100644 src/glx/x11/glx_query.c delete mode 100644 src/glx/x11/glxclient.h delete mode 100644 src/glx/x11/glxcmds.c delete mode 100644 src/glx/x11/glxcurrent.c delete mode 100644 src/glx/x11/glxext.c delete mode 100644 src/glx/x11/glxextensions.c delete mode 100644 src/glx/x11/glxextensions.h delete mode 100644 src/glx/x11/glxhash.c delete mode 100644 src/glx/x11/glxhash.h delete mode 100644 src/glx/x11/indirect.c delete mode 100644 src/glx/x11/indirect.h delete mode 100644 src/glx/x11/indirect_init.c delete mode 100644 src/glx/x11/indirect_init.h delete mode 100644 src/glx/x11/indirect_size.c delete mode 100644 src/glx/x11/indirect_size.h delete mode 100644 src/glx/x11/indirect_texture_compression.c delete mode 100644 src/glx/x11/indirect_transpose_matrix.c delete mode 100644 src/glx/x11/indirect_vertex_array.c delete mode 100644 src/glx/x11/indirect_vertex_array.h delete mode 100644 src/glx/x11/indirect_vertex_array_priv.h delete mode 100644 src/glx/x11/indirect_vertex_program.c delete mode 100644 src/glx/x11/indirect_window_pos.c delete mode 100644 src/glx/x11/packrender.h delete mode 100644 src/glx/x11/packsingle.h delete mode 100644 src/glx/x11/pixel.c delete mode 100644 src/glx/x11/pixelstore.c delete mode 100644 src/glx/x11/render2.c delete mode 100644 src/glx/x11/renderpix.c delete mode 100644 src/glx/x11/single2.c delete mode 100644 src/glx/x11/singlepix.c delete mode 100644 src/glx/x11/vertarr.c delete mode 100644 src/glx/x11/xf86dri.h delete mode 100644 src/glx/x11/xf86dristr.h delete mode 100644 src/glx/x11/xfont.c create mode 100644 src/glx/xf86dri.h create mode 100644 src/glx/xf86dristr.h create mode 100644 src/glx/xfont.c (limited to 'configure.ac') diff --git a/Makefile b/Makefile index bf8debfd5b3..09a8ca29771 100644 --- a/Makefile +++ b/Makefile @@ -361,8 +361,8 @@ DRI_FILES = \ $(DIRECTORY)/include/GL/internal/glcore.h \ $(DIRECTORY)/include/GL/internal/sarea.h \ $(DIRECTORY)/src/glx/Makefile \ - $(DIRECTORY)/src/glx/x11/Makefile \ - $(DIRECTORY)/src/glx/x11/*.[ch] \ + $(DIRECTORY)/src/glx/Makefile \ + $(DIRECTORY)/src/glx/*.[ch] \ $(DIRECTORY)/src/mesa/drivers/dri/Makefile \ $(DIRECTORY)/src/mesa/drivers/dri/Makefile.template \ $(DIRECTORY)/src/mesa/drivers/dri/dri.pc.in \ @@ -488,7 +488,7 @@ GLUT_FILES = \ DEPEND_FILES = \ $(TOP)/src/mesa/depend \ - $(TOP)/src/glx/x11/depend \ + $(TOP)/src/glx/depend \ $(TOP)/src/glw/depend \ $(TOP)/src/glut/glx/depend \ $(TOP)/src/glu/sgi/depend diff --git a/configs/darwin b/configs/darwin index 7556688fe6d..d28d5906ba1 100644 --- a/configs/darwin +++ b/configs/darwin @@ -16,7 +16,7 @@ DEFINES = -D_DARWIN_C_SOURCE -DPTHREADS -D_GNU_SOURCE \ -DGLX_ALIAS_UNSUPPORTED -DGLX_INDIRECT_RENDERING # -D_GNU_SOURCE - for src/mesa/main ... -# -DGLX_DIRECT_RENDERING - pulls in libdrm stuff in glx/x11 +# -DGLX_DIRECT_RENDERING - pulls in libdrm stuff in glx # -DGLX_USE_APPLEGL - supposed to be used with GLX_DIRECT_RENDERING to use AGL rather than DRM, but doesn't compile # -DIN_DRI_DRIVER @@ -49,7 +49,7 @@ GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXmu -lXt -lXi -lm # omit glw lib for now: -SRC_DIRS = glsl glx/x11 mesa gallium glu glut/glx glew +SRC_DIRS = glsl glx mesa gallium glu glut/glx glew GLU_DIRS = sgi DRIVER_DIRS = osmesa #DRIVER_DIRS = dri diff --git a/configs/freebsd-dri b/configs/freebsd-dri index 0ec25f916ed..da63e3b78c5 100644 --- a/configs/freebsd-dri +++ b/configs/freebsd-dri @@ -41,7 +41,7 @@ GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/local/lib -lGL -lXt -lX11 # Directories -SRC_DIRS = glx/x11 gallium mesa glu glut/glx glew glw +SRC_DIRS = glx gallium mesa glu glut/glx glew glw DRIVER_DIRS = dri PROGRAM_DIRS = WINDOW_SYSTEM=dri diff --git a/configs/linux-dri b/configs/linux-dri index 95f77ade1dd..634546c64ca 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -51,7 +51,7 @@ GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \ # Directories -SRC_DIRS := glx/x11 egl $(SRC_DIRS) +SRC_DIRS := glx egl $(SRC_DIRS) PROGRAM_DIRS := egl $(PROGRAM_DIRS) # EGL directories diff --git a/configs/linux-dri-xcb b/configs/linux-dri-xcb index 7b99dccdb88..691f8e4918c 100644 --- a/configs/linux-dri-xcb +++ b/configs/linux-dri-xcb @@ -47,7 +47,7 @@ DRI_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB) GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl \ $(LIBDRM_LIB) $(shell pkg-config --libs xcb) $(shell pkg-config --libs x11-xcb) $(shell pkg-config --libs xcb-glx) -SRC_DIRS = glx/x11 gallium mesa glu glut/glx glew glw +SRC_DIRS = glx gallium mesa glu glut/glx glew glw PROGRAM_DIRS = xdemos DRIVER_DIRS = dri diff --git a/configs/linux-indirect b/configs/linux-indirect index 4b81383c072..0914fba19bc 100644 --- a/configs/linux-indirect +++ b/configs/linux-indirect @@ -47,7 +47,7 @@ GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl # Directories -SRC_DIRS = glx/x11 glu glut/glx glew glw +SRC_DIRS = glx glu glut/glx glew glw DRIVER_DIRS = PROGRAM_DIRS = WINDOW_SYSTEM=dri diff --git a/configure.ac b/configure.ac index b6c6535fc6e..a273a16c891 100644 --- a/configure.ac +++ b/configure.ac @@ -445,7 +445,7 @@ xlib) GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib" ;; dri) - SRC_DIRS="$SRC_DIRS glx/x11" + SRC_DIRS="$SRC_DIRS glx" DRIVER_DIRS="dri" WINDOW_SYSTEM="dri" GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm" diff --git a/docs/egl.html b/docs/egl.html index 9eba402411d..844cc32079e 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -309,7 +309,6 @@ surfaces.

    • Pass the conformance tests
    • Better automatic driver selection: EGL_DISPLAY loads all drivers and might eat too much memory.
    • -
    • Stop using glxinit.c and sources from src/glx/x11/
    diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile index 2863320a480..794785006f5 100644 --- a/src/gallium/state_trackers/egl/Makefile +++ b/src/gallium/state_trackers/egl/Makefile @@ -14,12 +14,12 @@ common_OBJECTS = $(common_SOURCES:.c=.o) x11_INCLUDES = \ -I$(TOP)/src/gallium/drivers \ - -I$(TOP)/src/glx/x11 \ + -I$(TOP)/src/glx \ -I$(TOP)/src/mesa \ $(shell pkg-config --cflags-only-I libdrm) x11_SOURCES = $(wildcard x11/*.c) \ - $(TOP)/src/glx/x11/dri2.c + $(TOP)/src/glx/dri2.c x11_OBJECTS = $(x11_SOURCES:.c=.o) diff --git a/src/gallium/state_trackers/egl/x11/glxinit.c b/src/gallium/state_trackers/egl/x11/glxinit.c index ba6132788a7..1ed2afd3458 100644 --- a/src/gallium/state_trackers/egl/x11/glxinit.c +++ b/src/gallium/state_trackers/egl/x11/glxinit.c @@ -1,6 +1,6 @@ /** * GLX initialization. Code based on glxext.c, glx_query.c, and - * glcontextmodes.c under src/glx/x11/. The major difference is that DRI + * glcontextmodes.c under src/glx/. The major difference is that DRI * related code is stripped out. * * If the maintenance of this file takes too much time, we should consider diff --git a/src/glx/Makefile b/src/glx/Makefile index e0ab4a02401..e681be834f0 100644 --- a/src/glx/Makefile +++ b/src/glx/Makefile @@ -1,12 +1,97 @@ - -TOP = ../.. +TOP = ../../.. include $(TOP)/configs/current +EXTRA_DEFINES = -DXF86VIDMODE -D_REENTRANT \ + -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" + +SOURCES = \ + glcontextmodes.c \ + clientattrib.c \ + compsize.c \ + eval.c \ + glxcmds.c \ + glxcurrent.c \ + glxext.c \ + glxextensions.c \ + indirect.c \ + indirect_init.c \ + indirect_size.c \ + indirect_window_pos.c \ + indirect_texture_compression.c \ + indirect_transpose_matrix.c \ + indirect_vertex_array.c \ + indirect_vertex_program.c \ + pixel.c \ + pixelstore.c \ + render2.c \ + renderpix.c \ + single2.c \ + singlepix.c \ + vertarr.c \ + xfont.c \ + glx_pbuffer.c \ + glx_query.c \ + drisw_glx.c \ + dri_common.c \ + dri_glx.c \ + XF86dri.c \ + glxhash.c \ + dri2_glx.c \ + dri2.c + +GLAPI_LIB = $(TOP)/src/mesa/libglapi.a + +OBJECTS = $(SOURCES:.c=.o) + +INCLUDES = -I. \ + -I$(TOP)/include \ + -I$(TOP)/include/GL/internal \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/mesa/glapi \ + $(LIBDRM_CFLAGS) \ + $(DRI2PROTO_CFLAGS) \ + $(X11_INCLUDES) + + +##### RULES ##### + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(EXTRA_DEFINES) $< -o $@ + +.S.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(EXTRA_DEFINES) $< -o $@ + +##### TARGETS ##### + +default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) + +# Make libGL +$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) $(GLAPI_LIB) Makefile + $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + -major 1 -minor 2 $(MKLIB_OPTIONS) \ + -install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/lib$(GL_LIB).1.dylib \ + $(GL_LIB_DEPS) $(OBJECTS) $(GLAPI_LIB) + +$(GLAPI_LIB): + @$(MAKE) -C $(TOP)/src/mesa libglapi.a + +depend: $(SOURCES) Makefile + rm -f depend + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) + -default: - cd mini && $(MAKE) +# Emacs tags +tags: + etags `find . -name \*.[ch]` `find $(TOP)/include` +install: $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) + $(MAKE) -C $(TOP)/src/mesa install-libgl +# Remove .o and backup files clean: - -@cd mini && $(MAKE) clean + -rm -f $(TOP)/$(LIB_DIR)/libGL.so* + -rm -f *.o *~ + -rm -f depend depend.bak +-include depend diff --git a/src/glx/XF86dri.c b/src/glx/XF86dri.c new file mode 100644 index 00000000000..248d96ac5de --- /dev/null +++ b/src/glx/XF86dri.c @@ -0,0 +1,637 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +Copyright 2000 VA Linux Systems, Inc. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin + * Jens Owen + * Rickard E. (Rik) Faith + * + */ + +/* THIS IS NOT AN X CONSORTIUM STANDARD */ + +#ifdef GLX_DIRECT_RENDERING + +#define NEED_REPLIES +#include +#include +#include +#include "xf86dristr.h" + + +#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 +# define PUBLIC __attribute__((visibility("default"))) +# define USED __attribute__((used)) +#else +# define PUBLIC +# define USED +#endif + + + +static XExtensionInfo _xf86dri_info_data; +static XExtensionInfo *xf86dri_info = &_xf86dri_info_data; +static char xf86dri_extension_name[] = XF86DRINAME; + +#define XF86DRICheckExtension(dpy,i,val) \ + XextCheckExtension (dpy, i, xf86dri_extension_name, val) + +/***************************************************************************** + * * + * private utility routines * + * * + *****************************************************************************/ + +static int close_display(Display * dpy, XExtCodes * extCodes); +static /* const */ XExtensionHooks xf86dri_extension_hooks = { + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + close_display, /* close_display */ + NULL, /* wire_to_event */ + NULL, /* event_to_wire */ + NULL, /* error */ + NULL, /* error_string */ +}; + +static +XEXT_GENERATE_FIND_DISPLAY(find_display, xf86dri_info, + xf86dri_extension_name, + &xf86dri_extension_hooks, 0, NULL) + +static +XEXT_GENERATE_CLOSE_DISPLAY(close_display, xf86dri_info) + + +/***************************************************************************** + * * + * public XFree86-DRI Extension routines * + * * + *****************************************************************************/ +#if 0 +#include +#define TRACE(msg) fprintf(stderr,"XF86DRI%s\n", msg); +#else +#define TRACE(msg) +#endif + +Bool +XF86DRIQueryExtension(Display * dpy, int *event_basep, + int *error_basep) +{ + XExtDisplayInfo *info = find_display(dpy); + + TRACE("QueryExtension..."); + if (XextHasExtension(info)) { + *event_basep = info->codes->first_event; + *error_basep = info->codes->first_error; + TRACE("QueryExtension... return True"); + return True; + } + else { + TRACE("QueryExtension... return False"); + return False; + } +} + +Bool +XF86DRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion, + int *patchVersion) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIQueryVersionReply rep; + xXF86DRIQueryVersionReq *req; + + TRACE("QueryVersion..."); + XF86DRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIQueryVersion, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIQueryVersion; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("QueryVersion... return False"); + return False; + } + *majorVersion = rep.majorVersion; + *minorVersion = rep.minorVersion; + *patchVersion = rep.patchVersion; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("QueryVersion... return True"); + return True; +} + +Bool +XF86DRIQueryDirectRenderingCapable(Display * dpy, int screen, + Bool * isCapable) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIQueryDirectRenderingCapableReply rep; + xXF86DRIQueryDirectRenderingCapableReq *req; + + TRACE("QueryDirectRenderingCapable..."); + XF86DRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIQueryDirectRenderingCapable, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIQueryDirectRenderingCapable; + req->screen = screen; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("QueryDirectRenderingCapable... return False"); + return False; + } + *isCapable = rep.isCapable; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("QueryDirectRenderingCapable... return True"); + return True; +} + +Bool +XF86DRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA, + char **busIdString) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIOpenConnectionReply rep; + xXF86DRIOpenConnectionReq *req; + + TRACE("OpenConnection..."); + XF86DRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIOpenConnection, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIOpenConnection; + req->screen = screen; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("OpenConnection... return False"); + return False; + } + + *hSAREA = rep.hSAREALow; + if (sizeof(drm_handle_t) == 8) { + int shift = 32; /* var to prevent warning on next line */ + *hSAREA |= ((drm_handle_t) rep.hSAREAHigh) << shift; + } + + if (rep.length) { + if (!(*busIdString = (char *) Xcalloc(rep.busIdStringLength + 1, 1))) { + _XEatData(dpy, ((rep.busIdStringLength + 3) & ~3)); + UnlockDisplay(dpy); + SyncHandle(); + TRACE("OpenConnection... return False"); + return False; + } + _XReadPad(dpy, *busIdString, rep.busIdStringLength); + } + else { + *busIdString = NULL; + } + UnlockDisplay(dpy); + SyncHandle(); + TRACE("OpenConnection... return True"); + return True; +} + +Bool +XF86DRIAuthConnection(Display * dpy, int screen, drm_magic_t magic) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIAuthConnectionReq *req; + xXF86DRIAuthConnectionReply rep; + + TRACE("AuthConnection..."); + XF86DRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIAuthConnection, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIAuthConnection; + req->screen = screen; + req->magic = magic; + rep.authenticated = 0; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("AuthConnection... return False"); + return False; + } + UnlockDisplay(dpy); + SyncHandle(); + TRACE("AuthConnection... return True"); + return True; +} + +Bool +XF86DRICloseConnection(Display * dpy, int screen) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRICloseConnectionReq *req; + + TRACE("CloseConnection..."); + + XF86DRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRICloseConnection, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRICloseConnection; + req->screen = screen; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("CloseConnection... return True"); + return True; +} + +Bool +XF86DRIGetClientDriverName(Display * dpy, int screen, + int *ddxDriverMajorVersion, + int *ddxDriverMinorVersion, + int *ddxDriverPatchVersion, + char **clientDriverName) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIGetClientDriverNameReply rep; + xXF86DRIGetClientDriverNameReq *req; + + TRACE("GetClientDriverName..."); + XF86DRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIGetClientDriverName, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIGetClientDriverName; + req->screen = screen; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetClientDriverName... return False"); + return False; + } + + *ddxDriverMajorVersion = rep.ddxDriverMajorVersion; + *ddxDriverMinorVersion = rep.ddxDriverMinorVersion; + *ddxDriverPatchVersion = rep.ddxDriverPatchVersion; + + if (rep.length) { + if (! + (*clientDriverName = + (char *) Xcalloc(rep.clientDriverNameLength + 1, 1))) { + _XEatData(dpy, ((rep.clientDriverNameLength + 3) & ~3)); + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetClientDriverName... return False"); + return False; + } + _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength); + } + else { + *clientDriverName = NULL; + } + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetClientDriverName... return True"); + return True; +} + +Bool +XF86DRICreateContextWithConfig(Display * dpy, int screen, int configID, + XID * context, drm_context_t * hHWContext) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRICreateContextReply rep; + xXF86DRICreateContextReq *req; + + TRACE("CreateContext..."); + XF86DRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRICreateContext, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRICreateContext; + req->visual = configID; + req->screen = screen; + *context = XAllocID(dpy); + req->context = *context; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("CreateContext... return False"); + return False; + } + *hHWContext = rep.hHWContext; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("CreateContext... return True"); + return True; +} + +Bool +XF86DRICreateContext(Display * dpy, int screen, Visual * visual, + XID * context, drm_context_t * hHWContext) +{ + return XF86DRICreateContextWithConfig(dpy, screen, visual->visualid, + context, hHWContext); +} + +Bool +XF86DRIDestroyContext(Display * dpy, int screen, XID context) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIDestroyContextReq *req; + + TRACE("DestroyContext..."); + XF86DRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIDestroyContext, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIDestroyContext; + req->screen = screen; + req->context = context; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("DestroyContext... return True"); + return True; +} + +Bool +XF86DRICreateDrawable(Display * dpy, int screen, + XID drawable, drm_drawable_t * hHWDrawable) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRICreateDrawableReply rep; + xXF86DRICreateDrawableReq *req; + + TRACE("CreateDrawable..."); + XF86DRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRICreateDrawable, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRICreateDrawable; + req->screen = screen; + req->drawable = drawable; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("CreateDrawable... return False"); + return False; + } + *hHWDrawable = rep.hHWDrawable; + UnlockDisplay(dpy); + SyncHandle(); + TRACE("CreateDrawable... return True"); + return True; +} + +static int +noopErrorHandler(Display * dpy, XErrorEvent * xerr) +{ + return 0; +} + +Bool +XF86DRIDestroyDrawable(Display * dpy, int screen, XID drawable) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIDestroyDrawableReq *req; + int (*oldXErrorHandler) (Display *, XErrorEvent *); + + TRACE("DestroyDrawable..."); + XF86DRICheckExtension(dpy, info, False); + + /* This is called from the DRI driver, which used call it like this + * + * if (windowExists(drawable)) + * destroyDrawable(drawable); + * + * which is a textbook race condition - the window may disappear + * from the server between checking for its existance and + * destroying it. Instead we change the semantics of + * __DRIinterfaceMethodsRec::destroyDrawable() to succeed even if + * the windows is gone, by wrapping the destroy call in an error + * handler. */ + + XSync(dpy, False); + oldXErrorHandler = XSetErrorHandler(noopErrorHandler); + + LockDisplay(dpy); + GetReq(XF86DRIDestroyDrawable, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIDestroyDrawable; + req->screen = screen; + req->drawable = drawable; + UnlockDisplay(dpy); + SyncHandle(); + + XSetErrorHandler(oldXErrorHandler); + + TRACE("DestroyDrawable... return True"); + return True; +} + +Bool +XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, + unsigned int *index, unsigned int *stamp, + int *X, int *Y, int *W, int *H, + int *numClipRects, drm_clip_rect_t ** pClipRects, + int *backX, int *backY, + int *numBackClipRects, + drm_clip_rect_t ** pBackClipRects) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIGetDrawableInfoReply rep; + xXF86DRIGetDrawableInfoReq *req; + int total_rects; + + TRACE("GetDrawableInfo..."); + XF86DRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIGetDrawableInfo, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIGetDrawableInfo; + req->screen = screen; + req->drawable = drawable; + + if (!_XReply(dpy, (xReply *) & rep, 1, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDrawableInfo... return False"); + return False; + } + *index = rep.drawableTableIndex; + *stamp = rep.drawableTableStamp; + *X = (int) rep.drawableX; + *Y = (int) rep.drawableY; + *W = (int) rep.drawableWidth; + *H = (int) rep.drawableHeight; + *numClipRects = rep.numClipRects; + total_rects = *numClipRects; + + *backX = rep.backX; + *backY = rep.backY; + *numBackClipRects = rep.numBackClipRects; + total_rects += *numBackClipRects; + +#if 0 + /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks + * backwards compatibility (Because of the >> 2 shift) but the fix + * enables multi-threaded apps to work. + */ + if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) - + SIZEOF(xGenericReply) + + total_rects * sizeof(drm_clip_rect_t)) + + 3) & ~3) >> 2)) { + _XEatData(dpy, rep.length); + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDrawableInfo... return False"); + return False; + } +#endif + + if (*numClipRects) { + int len = sizeof(drm_clip_rect_t) * (*numClipRects); + + *pClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); + if (*pClipRects) + _XRead(dpy, (char *) *pClipRects, len); + } + else { + *pClipRects = NULL; + } + + if (*numBackClipRects) { + int len = sizeof(drm_clip_rect_t) * (*numBackClipRects); + + *pBackClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); + if (*pBackClipRects) + _XRead(dpy, (char *) *pBackClipRects, len); + } + else { + *pBackClipRects = NULL; + } + + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDrawableInfo... return True"); + return True; +} + +Bool +XF86DRIGetDeviceInfo(Display * dpy, int screen, drm_handle_t * hFrameBuffer, + int *fbOrigin, int *fbSize, int *fbStride, + int *devPrivateSize, void **pDevPrivate) +{ + XExtDisplayInfo *info = find_display(dpy); + xXF86DRIGetDeviceInfoReply rep; + xXF86DRIGetDeviceInfoReq *req; + + TRACE("GetDeviceInfo..."); + XF86DRICheckExtension(dpy, info, False); + + LockDisplay(dpy); + GetReq(XF86DRIGetDeviceInfo, req); + req->reqType = info->codes->major_opcode; + req->driReqType = X_XF86DRIGetDeviceInfo; + req->screen = screen; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDeviceInfo... return False"); + return False; + } + + *hFrameBuffer = rep.hFrameBufferLow; + if (sizeof(drm_handle_t) == 8) { + int shift = 32; /* var to prevent warning on next line */ + *hFrameBuffer |= ((drm_handle_t) rep.hFrameBufferHigh) << shift; + } + + *fbOrigin = rep.framebufferOrigin; + *fbSize = rep.framebufferSize; + *fbStride = rep.framebufferStride; + *devPrivateSize = rep.devPrivateSize; + + if (rep.length) { + if (!(*pDevPrivate = (void *) Xcalloc(rep.devPrivateSize, 1))) { + _XEatData(dpy, ((rep.devPrivateSize + 3) & ~3)); + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDeviceInfo... return False"); + return False; + } + _XRead(dpy, (char *) *pDevPrivate, rep.devPrivateSize); + } + else { + *pDevPrivate = NULL; + } + + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDeviceInfo... return True"); + return True; +} + +Bool +XF86DRIOpenFullScreen(Display * dpy, int screen, Drawable drawable) +{ + /* This function and the underlying X protocol are deprecated. + */ + (void) dpy; + (void) screen; + (void) drawable; + return False; +} + +Bool +XF86DRICloseFullScreen(Display * dpy, int screen, Drawable drawable) +{ + /* This function and the underlying X protocol are deprecated. + */ + (void) dpy; + (void) screen; + (void) drawable; + return True; +} + +#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/clientattrib.c b/src/glx/clientattrib.c new file mode 100644 index 00000000000..a7dfb534860 --- /dev/null +++ b/src/glx/clientattrib.c @@ -0,0 +1,142 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +#include +#include "glxclient.h" +#include "indirect.h" +#include "indirect_vertex_array.h" + +/*****************************************************************************/ + +static void +do_enable_disable(GLenum array, GLboolean val) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + unsigned index = 0; + + if (array == GL_TEXTURE_COORD_ARRAY) { + index = __glXGetActiveTextureUnit(state); + } + + if (!__glXSetArrayEnable(state, array, index, val)) { + __glXSetError(gc, GL_INVALID_ENUM); + } +} + +void +__indirect_glEnableClientState(GLenum array) +{ + do_enable_disable(array, GL_TRUE); +} + +void +__indirect_glDisableClientState(GLenum array) +{ + do_enable_disable(array, GL_FALSE); +} + +/************************************************************************/ + +void +__indirect_glPushClientAttrib(GLuint mask) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + __GLXattribute **spp = gc->attributes.stackPointer, *sp; + + if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) { + if (!(sp = *spp)) { + sp = (__GLXattribute *) Xmalloc(sizeof(__GLXattribute)); + *spp = sp; + } + sp->mask = mask; + gc->attributes.stackPointer = spp + 1; + if (mask & GL_CLIENT_PIXEL_STORE_BIT) { + sp->storePack = state->storePack; + sp->storeUnpack = state->storeUnpack; + } + if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { + __glXPushArrayState(state); + } + } + else { + __glXSetError(gc, GL_STACK_OVERFLOW); + return; + } +} + +void +__indirect_glPopClientAttrib(void) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + __GLXattribute **spp = gc->attributes.stackPointer, *sp; + GLuint mask; + + if (spp > &gc->attributes.stack[0]) { + --spp; + sp = *spp; + assert(sp != 0); + mask = sp->mask; + gc->attributes.stackPointer = spp; + + if (mask & GL_CLIENT_PIXEL_STORE_BIT) { + state->storePack = sp->storePack; + state->storeUnpack = sp->storeUnpack; + } + if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { + __glXPopArrayState(state); + } + + sp->mask = 0; + } + else { + __glXSetError(gc, GL_STACK_UNDERFLOW); + return; + } +} + +void +__glFreeAttributeState(__GLXcontext * gc) +{ + __GLXattribute *sp, **spp; + + for (spp = &gc->attributes.stack[0]; + spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; spp++) { + sp = *spp; + if (sp) { + XFree((char *) sp); + } + else { + break; + } + } +} diff --git a/src/glx/compsize.c b/src/glx/compsize.c new file mode 100644 index 00000000000..5ba6dc919e5 --- /dev/null +++ b/src/glx/compsize.c @@ -0,0 +1,189 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +#include +#include "glxclient.h" + +/* +** Return the number of elements per group of a specified format +*/ +GLint +__glElementsPerGroup(GLenum format, GLenum type) +{ + /* + ** To make row length computation valid for image extraction, + ** packed pixel types assume elements per group equals one. + */ + switch (type) { + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_SHORT_8_8_APPLE: + case GL_UNSIGNED_SHORT_8_8_REV_APPLE: + case GL_UNSIGNED_SHORT_15_1_MESA: + case GL_UNSIGNED_SHORT_1_15_REV_MESA: + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_INT_24_8_NV: + case GL_UNSIGNED_INT_24_8_MESA: + case GL_UNSIGNED_INT_8_24_REV_MESA: + return 1; + default: + break; + } + + switch (format) { + case GL_RGB: + case GL_BGR: + return 3; + case GL_422_EXT: + case GL_422_REV_EXT: + case GL_422_AVERAGE_EXT: + case GL_422_REV_AVERAGE_EXT: + case GL_YCBCR_422_APPLE: + case GL_LUMINANCE_ALPHA: + return 2; + case GL_RGBA: + case GL_BGRA: + case GL_ABGR_EXT: + return 4; + case GL_COLOR_INDEX: + case GL_STENCIL_INDEX: + case GL_DEPTH_COMPONENT: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_INTENSITY: + return 1; + default: + return 0; + } +} + +/* +** Return the number of bytes per element, based on the element type (other +** than GL_BITMAP). +*/ +GLint +__glBytesPerElement(GLenum type) +{ + switch (type) { + case GL_UNSIGNED_SHORT: + case GL_SHORT: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_SHORT_8_8_APPLE: + case GL_UNSIGNED_SHORT_8_8_REV_APPLE: + case GL_UNSIGNED_SHORT_15_1_MESA: + case GL_UNSIGNED_SHORT_1_15_REV_MESA: + return 2; + case GL_UNSIGNED_BYTE: + case GL_BYTE: + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + return 1; + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_INT_24_8_NV: + case GL_UNSIGNED_INT_24_8_MESA: + case GL_UNSIGNED_INT_8_24_REV_MESA: + return 4; + default: + return 0; + } +} + +/* +** Compute memory required for internal packed array of data of given type +** and format. +*/ +GLint +__glImageSize(GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, GLenum target) +{ + int bytes_per_row; + int components; + + switch (target) { + case GL_PROXY_TEXTURE_1D: + case GL_PROXY_TEXTURE_2D: + case GL_PROXY_TEXTURE_3D: + case GL_PROXY_TEXTURE_4D_SGIS: + case GL_PROXY_TEXTURE_CUBE_MAP: + case GL_PROXY_TEXTURE_RECTANGLE_ARB: + case GL_PROXY_HISTOGRAM: + case GL_PROXY_COLOR_TABLE: + case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: + case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: + case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: + case GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP: + return 0; + } + + if (width < 0 || height < 0 || depth < 0) { + return 0; + } + + /* + ** Zero is returned if either format or type are invalid. + */ + components = __glElementsPerGroup(format, type); + if (type == GL_BITMAP) { + if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) { + bytes_per_row = (width + 7) >> 3; + } + else { + return 0; + } + } + else { + bytes_per_row = __glBytesPerElement(type) * width; + } + + return bytes_per_row * height * depth * components; +} diff --git a/src/glx/dri2.c b/src/glx/dri2.c new file mode 100644 index 00000000000..91053d3fb61 --- /dev/null +++ b/src/glx/dri2.c @@ -0,0 +1,645 @@ +/* + * Copyright © 2008 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Soft- + * ware"), to deal in the Software without restriction, including without + * limitation the rights to use, copy, modify, merge, publish, distribute, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, provided that the above copyright + * notice(s) and this permission notice appear in all copies of the Soft- + * ware and that both the above copyright notice(s) and this permission + * notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- + * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY + * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN + * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- + * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- + * MANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall + * not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization of + * the copyright holder. + * + * Authors: + * Kristian Høgsberg (krh@redhat.com) + */ + + +#ifdef GLX_DIRECT_RENDERING + +#define NEED_REPLIES +#include +#include +#include +#include +#include +#include "xf86drm.h" +#include "dri2.h" +#include "glxclient.h" +#include "GL/glxext.h" + +/* Allow the build to work with an older versions of dri2proto.h and + * dri2tokens.h. + */ +#if DRI2_MINOR < 1 +#undef DRI2_MINOR +#define DRI2_MINOR 1 +#define X_DRI2GetBuffersWithFormat 7 +#endif + + +static char dri2ExtensionName[] = DRI2_NAME; +static XExtensionInfo *dri2Info; +static XEXT_GENERATE_CLOSE_DISPLAY (DRI2CloseDisplay, dri2Info) + +static Bool +DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire); +static Status +DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire); + +static /* const */ XExtensionHooks dri2ExtensionHooks = { + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + DRI2CloseDisplay, /* close_display */ + DRI2WireToEvent, /* wire_to_event */ + DRI2EventToWire, /* event_to_wire */ + NULL, /* error */ + NULL, /* error_string */ +}; + +static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay, + dri2Info, + dri2ExtensionName, + &dri2ExtensionHooks, + 1, NULL) + +static Bool +DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + XExtDisplayInfo *glx_info = __glXFindDisplay(dpy); + static int glx_event_base; + static Bool found_glx_info = False; + + XextCheckExtension(dpy, info, dri2ExtensionName, False); + + switch ((wire->u.u.type & 0x7f) - info->codes->first_event) { + +#ifdef X_DRI2SwapBuffers + case DRI2_BufferSwapComplete: + { + GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event; + xDRI2BufferSwapComplete *awire = (xDRI2BufferSwapComplete *)wire; + aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); + aevent->type = + (glx_info->codes->first_event + GLX_BufferSwapComplete) & 0x75; + aevent->send_event = (awire->type & 0x80) != 0; + aevent->display = dpy; + aevent->drawable = awire->drawable; + switch (awire->event_type) { + case DRI2_EXCHANGE_COMPLETE: + aevent->event_type = GLX_EXCHANGE_COMPLETE_INTEL; + break; + case DRI2_BLIT_COMPLETE: + aevent->event_type = GLX_BLIT_COMPLETE_INTEL; + break; + case DRI2_FLIP_COMPLETE: + aevent->event_type = GLX_FLIP_COMPLETE_INTEL; + break; + default: + /* unknown swap completion type */ + return False; + } + aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo; + aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo; + aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo; + return True; + } +#endif + + default: + /* client doesn't support server event */ + break; + } + + return False; +} + +/* We don't actually support this. It doesn't make sense for clients to + * send each other DRI2 events. + */ +static Status +DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + + XextCheckExtension(dpy, info, dri2ExtensionName, False); + + switch (event->type) { + default: + /* client doesn't support server event */ + break; + } + + return Success; +} + +Bool +DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + + if (XextHasExtension(info)) { + *eventBase = info->codes->first_event; + *errorBase = info->codes->first_error; + return True; + } + + return False; +} + +Bool +DRI2QueryVersion(Display * dpy, int *major, int *minor) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2QueryVersionReply rep; + xDRI2QueryVersionReq *req; + + XextCheckExtension(dpy, info, dri2ExtensionName, False); + + LockDisplay(dpy); + GetReq(DRI2QueryVersion, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2QueryVersion; + req->majorVersion = DRI2_MAJOR; + req->minorVersion = DRI2_MINOR; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + return False; + } + *major = rep.majorVersion; + *minor = rep.minorVersion; + UnlockDisplay(dpy); + SyncHandle(); + + return True; +} + +Bool +DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2ConnectReply rep; + xDRI2ConnectReq *req; + + XextCheckExtension(dpy, info, dri2ExtensionName, False); + + LockDisplay(dpy); + GetReq(DRI2Connect, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2Connect; + req->window = window; + req->driverType = DRI2DriverDRI; + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + return False; + } + + if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) { + UnlockDisplay(dpy); + SyncHandle(); + return False; + } + + *driverName = Xmalloc(rep.driverNameLength + 1); + if (*driverName == NULL) { + _XEatData(dpy, + ((rep.driverNameLength + 3) & ~3) + + ((rep.deviceNameLength + 3) & ~3)); + UnlockDisplay(dpy); + SyncHandle(); + return False; + } + _XReadPad(dpy, *driverName, rep.driverNameLength); + (*driverName)[rep.driverNameLength] = '\0'; + + *deviceName = Xmalloc(rep.deviceNameLength + 1); + if (*deviceName == NULL) { + Xfree(*driverName); + _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3)); + UnlockDisplay(dpy); + SyncHandle(); + return False; + } + _XReadPad(dpy, *deviceName, rep.deviceNameLength); + (*deviceName)[rep.deviceNameLength] = '\0'; + + UnlockDisplay(dpy); + SyncHandle(); + + return True; +} + +Bool +DRI2Authenticate(Display * dpy, XID window, drm_magic_t magic) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2AuthenticateReq *req; + xDRI2AuthenticateReply rep; + + XextCheckExtension(dpy, info, dri2ExtensionName, False); + + LockDisplay(dpy); + GetReq(DRI2Authenticate, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2Authenticate; + req->window = window; + req->magic = magic; + + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + return False; + } + + UnlockDisplay(dpy); + SyncHandle(); + + return rep.authenticated; +} + +void +DRI2CreateDrawable(Display * dpy, XID drawable) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2CreateDrawableReq *req; + + XextSimpleCheckExtension(dpy, info, dri2ExtensionName); + + LockDisplay(dpy); + GetReq(DRI2CreateDrawable, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2CreateDrawable; + req->drawable = drawable; + UnlockDisplay(dpy); + SyncHandle(); +} + +void +DRI2DestroyDrawable(Display * dpy, XID drawable) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2DestroyDrawableReq *req; + + XextSimpleCheckExtension(dpy, info, dri2ExtensionName); + + XSync(dpy, False); + + LockDisplay(dpy); + GetReq(DRI2DestroyDrawable, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2DestroyDrawable; + req->drawable = drawable; + UnlockDisplay(dpy); + SyncHandle(); +} + +DRI2Buffer * +DRI2GetBuffers(Display * dpy, XID drawable, + int *width, int *height, + unsigned int *attachments, int count, int *outCount) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2GetBuffersReply rep; + xDRI2GetBuffersReq *req; + DRI2Buffer *buffers; + xDRI2Buffer repBuffer; + CARD32 *p; + int i; + + XextCheckExtension(dpy, info, dri2ExtensionName, False); + + LockDisplay(dpy); + GetReqExtra(DRI2GetBuffers, count * 4, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2GetBuffers; + req->drawable = drawable; + req->count = count; + p = (CARD32 *) & req[1]; + for (i = 0; i < count; i++) + p[i] = attachments[i]; + + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + return NULL; + } + + *width = rep.width; + *height = rep.height; + *outCount = rep.count; + + buffers = Xmalloc(rep.count * sizeof buffers[0]); + if (buffers == NULL) { + _XEatData(dpy, rep.count * sizeof repBuffer); + UnlockDisplay(dpy); + SyncHandle(); + return NULL; + } + + for (i = 0; i < rep.count; i++) { + _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer); + buffers[i].attachment = repBuffer.attachment; + buffers[i].name = repBuffer.name; + buffers[i].pitch = repBuffer.pitch; + buffers[i].cpp = repBuffer.cpp; + buffers[i].flags = repBuffer.flags; + } + + UnlockDisplay(dpy); + SyncHandle(); + + return buffers; +} + + +DRI2Buffer * +DRI2GetBuffersWithFormat(Display * dpy, XID drawable, + int *width, int *height, + unsigned int *attachments, int count, int *outCount) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2GetBuffersReply rep; + xDRI2GetBuffersReq *req; + DRI2Buffer *buffers; + xDRI2Buffer repBuffer; + CARD32 *p; + int i; + + XextCheckExtension(dpy, info, dri2ExtensionName, False); + + LockDisplay(dpy); + GetReqExtra(DRI2GetBuffers, count * (4 * 2), req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2GetBuffersWithFormat; + req->drawable = drawable; + req->count = count; + p = (CARD32 *) & req[1]; + for (i = 0; i < (count * 2); i++) + p[i] = attachments[i]; + + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + return NULL; + } + + *width = rep.width; + *height = rep.height; + *outCount = rep.count; + + buffers = Xmalloc(rep.count * sizeof buffers[0]); + if (buffers == NULL) { + _XEatData(dpy, rep.count * sizeof repBuffer); + UnlockDisplay(dpy); + SyncHandle(); + return NULL; + } + + for (i = 0; i < rep.count; i++) { + _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer); + buffers[i].attachment = repBuffer.attachment; + buffers[i].name = repBuffer.name; + buffers[i].pitch = repBuffer.pitch; + buffers[i].cpp = repBuffer.cpp; + buffers[i].flags = repBuffer.flags; + } + + UnlockDisplay(dpy); + SyncHandle(); + + return buffers; +} + + +void +DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region, + CARD32 dest, CARD32 src) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2CopyRegionReq *req; + xDRI2CopyRegionReply rep; + + XextSimpleCheckExtension(dpy, info, dri2ExtensionName); + + LockDisplay(dpy); + GetReq(DRI2CopyRegion, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2CopyRegion; + req->drawable = drawable; + req->region = region; + req->dest = dest; + req->src = src; + + _XReply(dpy, (xReply *) & rep, 0, xFalse); + + UnlockDisplay(dpy); + SyncHandle(); +} + +#ifdef X_DRI2SwapBuffers +static void +load_swap_req(xDRI2SwapBuffersReq *req, CARD64 target, CARD64 divisor, + CARD64 remainder) +{ + req->target_msc_hi = target >> 32; + req->target_msc_lo = target & 0xffffffff; + req->divisor_hi = divisor >> 32; + req->divisor_lo = divisor & 0xffffffff; + req->remainder_hi = remainder >> 32; + req->remainder_lo = remainder & 0xffffffff; +} + +static CARD64 +vals_to_card64(CARD32 lo, CARD32 hi) +{ + return (CARD64)hi << 32 | lo; +} + +void DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc, + CARD64 divisor, CARD64 remainder, CARD64 *count) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2SwapBuffersReq *req; + xDRI2SwapBuffersReply rep; + + XextSimpleCheckExtension (dpy, info, dri2ExtensionName); + + LockDisplay(dpy); + GetReq(DRI2SwapBuffers, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2SwapBuffers; + req->drawable = drawable; + load_swap_req(req, target_msc, divisor, remainder); + + _XReply(dpy, (xReply *)&rep, 0, xFalse); + + *count = vals_to_card64(rep.swap_lo, rep.swap_hi); + + UnlockDisplay(dpy); + SyncHandle(); +} +#endif + +#ifdef X_DRI2GetMSC +Bool DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc, + CARD64 *sbc) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2GetMSCReq *req; + xDRI2MSCReply rep; + + XextCheckExtension (dpy, info, dri2ExtensionName, False); + + LockDisplay(dpy); + GetReq(DRI2GetMSC, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2GetMSC; + req->drawable = drawable; + + if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + return False; + } + + *ust = vals_to_card64(rep.ust_lo, rep.ust_hi); + *msc = vals_to_card64(rep.msc_lo, rep.msc_hi); + *sbc = vals_to_card64(rep.sbc_lo, rep.sbc_hi); + + UnlockDisplay(dpy); + SyncHandle(); + + return True; +} +#endif + +#ifdef X_DRI2WaitMSC +static void +load_msc_req(xDRI2WaitMSCReq *req, CARD64 target, CARD64 divisor, + CARD64 remainder) +{ + req->target_msc_hi = target >> 32; + req->target_msc_lo = target & 0xffffffff; + req->divisor_hi = divisor >> 32; + req->divisor_lo = divisor & 0xffffffff; + req->remainder_hi = remainder >> 32; + req->remainder_lo = remainder & 0xffffffff; +} + +Bool DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor, + CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2WaitMSCReq *req; + xDRI2MSCReply rep; + + XextCheckExtension (dpy, info, dri2ExtensionName, False); + + LockDisplay(dpy); + GetReq(DRI2WaitMSC, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2WaitMSC; + req->drawable = drawable; + load_msc_req(req, target_msc, divisor, remainder); + + if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + return False; + } + + *ust = ((CARD64)rep.ust_hi << 32) | (CARD64)rep.ust_lo; + *msc = ((CARD64)rep.msc_hi << 32) | (CARD64)rep.msc_lo; + *sbc = ((CARD64)rep.sbc_hi << 32) | (CARD64)rep.sbc_lo; + + UnlockDisplay(dpy); + SyncHandle(); + + return True; +} +#endif + +#ifdef X_DRI2WaitSBC +static void +load_sbc_req(xDRI2WaitSBCReq *req, CARD64 target) +{ + req->target_sbc_hi = target >> 32; + req->target_sbc_lo = target & 0xffffffff; +} + +Bool DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust, + CARD64 *msc, CARD64 *sbc) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2WaitSBCReq *req; + xDRI2MSCReply rep; + + XextCheckExtension (dpy, info, dri2ExtensionName, False); + + LockDisplay(dpy); + GetReq(DRI2WaitSBC, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2WaitSBC; + req->drawable = drawable; + load_sbc_req(req, target_sbc); + + if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + return False; + } + + *ust = ((CARD64)rep.ust_hi << 32) | rep.ust_lo; + *msc = ((CARD64)rep.msc_hi << 32) | rep.msc_lo; + *sbc = ((CARD64)rep.sbc_hi << 32) | rep.sbc_lo; + + UnlockDisplay(dpy); + SyncHandle(); + + return True; +} +#endif + +#ifdef X_DRI2SwapInterval +void DRI2SwapInterval(Display *dpy, XID drawable, int interval) +{ + XExtDisplayInfo *info = DRI2FindDisplay(dpy); + xDRI2SwapIntervalReq *req; + + XextSimpleCheckExtension (dpy, info, dri2ExtensionName); + + LockDisplay(dpy); + GetReq(DRI2SwapInterval, req); + req->reqType = info->codes->major_opcode; + req->dri2ReqType = X_DRI2SwapInterval; + req->drawable = drawable; + req->interval = interval; + UnlockDisplay(dpy); + SyncHandle(); +} +#endif + +#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/dri2.h b/src/glx/dri2.h new file mode 100644 index 00000000000..114e9f8f965 --- /dev/null +++ b/src/glx/dri2.h @@ -0,0 +1,106 @@ +/* + * Copyright © 2007,2008 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Soft- + * ware"), to deal in the Software without restriction, including without + * limitation the rights to use, copy, modify, merge, publish, distribute, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, provided that the above copyright + * notice(s) and this permission notice appear in all copies of the Soft- + * ware and that both the above copyright notice(s) and this permission + * notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- + * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY + * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN + * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- + * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- + * MANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall + * not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization of + * the copyright holder. + * + * Authors: + * Kristian Høgsberg (krh@redhat.com) + */ + +#ifndef _DRI2_H_ +#define _DRI2_H_ + +#include +#include + +typedef struct +{ + unsigned int attachment; + unsigned int name; + unsigned int pitch; + unsigned int cpp; + unsigned int flags; +} DRI2Buffer; + +extern Bool +DRI2QueryExtension(Display * display, int *eventBase, int *errorBase); + +extern Bool +DRI2QueryVersion(Display * display, int *major, int *minor); + +extern Bool +DRI2Connect(Display * display, XID window, + char **driverName, char **deviceName); + +extern Bool +DRI2Authenticate(Display * display, XID window, drm_magic_t magic); + +extern void +DRI2CreateDrawable(Display * display, XID drawable); + +extern void +DRI2DestroyDrawable(Display * display, XID handle); + +extern DRI2Buffer* +DRI2GetBuffers(Display * dpy, XID drawable, + int *width, int *height, + unsigned int *attachments, int count, + int *outCount); + +/** + * \note + * This function is only supported with DRI2 version 1.1 or later. + */ +extern DRI2Buffer* +DRI2GetBuffersWithFormat(Display * dpy, XID drawable, + int *width, int *height, + unsigned int *attachments, + int count, int *outCount); + +extern void +DRI2CopyRegion(Display * dpy, XID drawable, + XserverRegion region, + CARD32 dest, CARD32 src); + +extern void +DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor, + CARD64 remainder, CARD64 *count); + +extern Bool +DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc, CARD64 *sbc); + +extern Bool +DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor, + CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc); + +extern Bool +DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust, + CARD64 *msc, CARD64 *sbc); + +extern void +DRI2SwapInterval(Display *dpy, XID drawable, int interval); + +#endif diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c new file mode 100644 index 00000000000..15a3ea59073 --- /dev/null +++ b/src/glx/dri2_glx.c @@ -0,0 +1,666 @@ +/* + * Copyright © 2008 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Soft- + * ware"), to deal in the Software without restriction, including without + * limitation the rights to use, copy, modify, merge, publish, distribute, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, provided that the above copyright + * notice(s) and this permission notice appear in all copies of the Soft- + * ware and that both the above copyright notice(s) and this permission + * notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- + * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY + * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN + * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- + * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- + * MANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall + * not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization of + * the copyright holder. + * + * Authors: + * Kristian Høgsberg (krh@redhat.com) + */ + +#ifdef GLX_DIRECT_RENDERING + +#include +#include +#include +#include "glapi.h" +#include "glxclient.h" +#include +#include "xf86dri.h" +#include +#include +#include +#include +#include +#include "xf86drm.h" +#include "dri2.h" +#include "dri_common.h" +#include "../../mesa/drivers/dri/common/dri_util.h" + +#undef DRI2_MINOR +#define DRI2_MINOR 1 + +typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate; +typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate; +typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate; + +struct __GLXDRIdisplayPrivateRec +{ + __GLXDRIdisplay base; + + /* + ** XFree86-DRI version information + */ + int driMajor; + int driMinor; + int driPatch; + int swapAvailable; +}; + +struct __GLXDRIcontextPrivateRec +{ + __GLXDRIcontext base; + __DRIcontext *driContext; + __GLXscreenConfigs *psc; +}; + +struct __GLXDRIdrawablePrivateRec +{ + __GLXDRIdrawable base; + __DRIbuffer buffers[5]; + int bufferCount; + int width, height; + int have_back; + int have_fake_front; + int swap_interval; +}; + +static void dri2WaitX(__GLXDRIdrawable * pdraw); + +static void +dri2DestroyContext(__GLXDRIcontext * context, + __GLXscreenConfigs * psc, Display * dpy) +{ + __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; + const __DRIcoreExtension *core = pcp->psc->core; + + (*core->destroyContext) (pcp->driContext); + + Xfree(pcp); +} + +static Bool +dri2BindContext(__GLXDRIcontext * context, + __GLXDRIdrawable * draw, __GLXDRIdrawable * read) +{ + __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; + const __DRIcoreExtension *core = pcp->psc->core; + + return (*core->bindContext) (pcp->driContext, + draw->driDrawable, read->driDrawable); +} + +static void +dri2UnbindContext(__GLXDRIcontext * context) +{ + __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; + const __DRIcoreExtension *core = pcp->psc->core; + + (*core->unbindContext) (pcp->driContext); +} + +static __GLXDRIcontext * +dri2CreateContext(__GLXscreenConfigs * psc, + const __GLcontextModes * mode, + GLXContext gc, GLXContext shareList, int renderType) +{ + __GLXDRIcontextPrivate *pcp, *pcp_shared; + __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode; + __DRIcontext *shared = NULL; + + if (shareList) { + pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext; + shared = pcp_shared->driContext; + } + + pcp = Xmalloc(sizeof *pcp); + if (pcp == NULL) + return NULL; + + pcp->psc = psc; + pcp->driContext = + (*psc->dri2->createNewContext) (psc->__driScreen, + config->driConfig, shared, pcp); + gc->__driContext = pcp->driContext; + + if (pcp->driContext == NULL) { + Xfree(pcp); + return NULL; + } + + pcp->base.destroyContext = dri2DestroyContext; + pcp->base.bindContext = dri2BindContext; + pcp->base.unbindContext = dri2UnbindContext; + + return &pcp->base; +} + +static void +dri2DestroyDrawable(__GLXDRIdrawable * pdraw) +{ + const __DRIcoreExtension *core = pdraw->psc->core; + + (*core->destroyDrawable) (pdraw->driDrawable); + DRI2DestroyDrawable(pdraw->psc->dpy, pdraw->xDrawable); + Xfree(pdraw); +} + +static __GLXDRIdrawable * +dri2CreateDrawable(__GLXscreenConfigs * psc, + XID xDrawable, + GLXDrawable drawable, const __GLcontextModes * modes) +{ + __GLXDRIdrawablePrivate *pdraw; + __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; + + pdraw = Xmalloc(sizeof(*pdraw)); + if (!pdraw) + return NULL; + + pdraw->base.destroyDrawable = dri2DestroyDrawable; + pdraw->base.xDrawable = xDrawable; + pdraw->base.drawable = drawable; + pdraw->base.psc = psc; + pdraw->bufferCount = 0; + + DRI2CreateDrawable(psc->dpy, xDrawable); + + /* Create a new drawable */ + pdraw->base.driDrawable = + (*psc->dri2->createNewDrawable) (psc->__driScreen, + config->driConfig, pdraw); + + if (!pdraw->base.driDrawable) { + DRI2DestroyDrawable(psc->dpy, xDrawable); + Xfree(pdraw); + return NULL; + } + + return &pdraw->base; +} + +static int +dri2DrawableGetMSC(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw, + int64_t *ust, int64_t *msc, int64_t *sbc) +{ + return DRI2GetMSC(psc->dpy, pdraw->xDrawable, ust, msc, sbc); +} + +static int +dri2WaitForMSC(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor, + int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc) +{ + return DRI2WaitMSC(pdraw->psc->dpy, pdraw->xDrawable, target_msc, divisor, + remainder, ust, msc, sbc); +} + +static int +dri2WaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust, + int64_t *msc, int64_t *sbc) +{ + return DRI2WaitSBC(pdraw->psc->dpy, pdraw->xDrawable, target_sbc, ust, msc, + sbc); +} + +static void +dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height) +{ + __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; + XRectangle xrect; + XserverRegion region; + + /* Check we have the right attachments */ + if (!priv->have_back) + return; + + xrect.x = x; + xrect.y = priv->height - y - height; + xrect.width = width; + xrect.height = height; + +#ifdef __DRI2_FLUSH + if (pdraw->psc->f) + (*pdraw->psc->f->flush) (pdraw->driDrawable); +#endif + + region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1); + /* should get a fence ID back from here at some point */ + DRI2CopyRegion(pdraw->psc->dpy, pdraw->xDrawable, region, + DRI2BufferFrontLeft, DRI2BufferBackLeft); + XFixesDestroyRegion(pdraw->psc->dpy, region); + + /* Refresh the fake front (if present) after we just damaged the real + * front. + */ + dri2WaitX(pdraw); +} + +static void +dri2WaitX(__GLXDRIdrawable *pdraw) +{ + __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; + XRectangle xrect; + XserverRegion region; + + /* Check we have the right attachments */ + if (!priv->have_fake_front) + return; + + xrect.x = 0; + xrect.y = 0; + xrect.width = priv->width; + xrect.height = priv->height; + +#ifdef __DRI2_FLUSH + if (pdraw->psc->f) + (*pdraw->psc->f->flush) (pdraw->driDrawable); +#endif + + region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1); + DRI2CopyRegion(pdraw->psc->dpy, pdraw->xDrawable, region, + DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft); + XFixesDestroyRegion(pdraw->psc->dpy, region); +} + +static void +dri2WaitGL(__GLXDRIdrawable * pdraw) +{ + __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; + XRectangle xrect; + XserverRegion region; + + if (!priv->have_fake_front) + return; + + xrect.x = 0; + xrect.y = 0; + xrect.width = priv->width; + xrect.height = priv->height; + +#ifdef __DRI2_FLUSH + if (pdraw->psc->f) + (*pdraw->psc->f->flush) (pdraw->driDrawable); +#endif + + region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1); + DRI2CopyRegion(pdraw->psc->dpy, pdraw->xDrawable, region, + DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); + XFixesDestroyRegion(pdraw->psc->dpy, region); +} + + +static void +dri2FlushFrontBuffer(__DRIdrawable * driDrawable, void *loaderPrivate) +{ + (void) driDrawable; + dri2WaitGL((__GLXDRIdrawable *) loaderPrivate); +} + + +static void +dri2DestroyScreen(__GLXscreenConfigs * psc) +{ + /* Free the direct rendering per screen data */ + (*psc->core->destroyScreen) (psc->__driScreen); + close(psc->fd); + psc->__driScreen = NULL; +} + +/** + * Process list of buffer received from the server + * + * Processes the list of buffers received in a reply from the server to either + * \c DRI2GetBuffers or \c DRI2GetBuffersWithFormat. + */ +static void +process_buffers(__GLXDRIdrawablePrivate * pdraw, DRI2Buffer * buffers, + unsigned count) +{ + int i; + + pdraw->bufferCount = count; + pdraw->have_fake_front = 0; + pdraw->have_back = 0; + + /* This assumes the DRI2 buffer attachment tokens matches the + * __DRIbuffer tokens. */ + for (i = 0; i < count; i++) { + pdraw->buffers[i].attachment = buffers[i].attachment; + pdraw->buffers[i].name = buffers[i].name; + pdraw->buffers[i].pitch = buffers[i].pitch; + pdraw->buffers[i].cpp = buffers[i].cpp; + pdraw->buffers[i].flags = buffers[i].flags; + if (pdraw->buffers[i].attachment == __DRI_BUFFER_FAKE_FRONT_LEFT) + pdraw->have_fake_front = 1; + if (pdraw->buffers[i].attachment == __DRI_BUFFER_BACK_LEFT) + pdraw->have_back = 1; + } + +} + +static int64_t +dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor, + int64_t remainder) +{ + __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; + __GLXdisplayPrivate *dpyPriv = __glXInitialize(priv->base.psc->dpy); + __GLXDRIdisplayPrivate *pdp = + (__GLXDRIdisplayPrivate *)dpyPriv->dri2Display; + int64_t ret; + +#ifdef __DRI2_FLUSH + if (pdraw->psc->f) + (*pdraw->psc->f->flush)(pdraw->driDrawable); +#endif + + /* Old servers can't handle swapbuffers */ + if (!pdp->swapAvailable) { + dri2CopySubBuffer(pdraw, 0, 0, priv->width, priv->height); + return 0; + } + +#ifdef X_DRI2SwapBuffers + DRI2SwapBuffers(pdraw->psc->dpy, pdraw->xDrawable, target_msc, divisor, + remainder, &ret); +#endif + +#if __DRI2_FLUSH_VERSION >= 2 + if (pdraw->psc->f) + (*pdraw->psc->f->flushInvalidate)(pdraw->driDrawable); +#endif + + return ret; +} + +static __DRIbuffer * +dri2GetBuffers(__DRIdrawable * driDrawable, + int *width, int *height, + unsigned int *attachments, int count, + int *out_count, void *loaderPrivate) +{ + __GLXDRIdrawablePrivate *pdraw = loaderPrivate; + DRI2Buffer *buffers; + + buffers = DRI2GetBuffers(pdraw->base.psc->dpy, pdraw->base.xDrawable, + width, height, attachments, count, out_count); + if (buffers == NULL) + return NULL; + + pdraw->width = *width; + pdraw->height = *height; + process_buffers(pdraw, buffers, *out_count); + + Xfree(buffers); + + return pdraw->buffers; +} + +static __DRIbuffer * +dri2GetBuffersWithFormat(__DRIdrawable * driDrawable, + int *width, int *height, + unsigned int *attachments, int count, + int *out_count, void *loaderPrivate) +{ + __GLXDRIdrawablePrivate *pdraw = loaderPrivate; + DRI2Buffer *buffers; + + buffers = DRI2GetBuffersWithFormat(pdraw->base.psc->dpy, + pdraw->base.xDrawable, + width, height, attachments, + count, out_count); + if (buffers == NULL) + return NULL; + + pdraw->width = *width; + pdraw->height = *height; + process_buffers(pdraw, buffers, *out_count); + + Xfree(buffers); + + return pdraw->buffers; +} + +static void +dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval) +{ + __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; + + DRI2SwapInterval(priv->base.psc->dpy, pdraw->xDrawable, interval); + priv->swap_interval = interval; +} + +static unsigned int +dri2GetSwapInterval(__GLXDRIdrawable *pdraw) +{ + __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; + + return priv->swap_interval; +} + +static const __DRIdri2LoaderExtension dri2LoaderExtension = { + {__DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION}, + dri2GetBuffers, + dri2FlushFrontBuffer, + dri2GetBuffersWithFormat, +}; + +static const __DRIdri2LoaderExtension dri2LoaderExtension_old = { + {__DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION}, + dri2GetBuffers, + dri2FlushFrontBuffer, + NULL, +}; + +static const __DRIextension *loader_extensions[] = { + &dri2LoaderExtension.base, + &systemTimeExtension.base, + NULL +}; + +static const __DRIextension *loader_extensions_old[] = { + &dri2LoaderExtension_old.base, + &systemTimeExtension.base, + NULL +}; + +static __GLXDRIscreen * +dri2CreateScreen(__GLXscreenConfigs * psc, int screen, + __GLXdisplayPrivate * priv) +{ + const __DRIconfig **driver_configs; + const __DRIextension **extensions; + const __GLXDRIdisplayPrivate *const pdp = (__GLXDRIdisplayPrivate *) + priv->dri2Display; + __GLXDRIscreen *psp; + char *driverName, *deviceName; + drm_magic_t magic; + int i; + + psp = Xmalloc(sizeof *psp); + if (psp == NULL) + return NULL; + + /* Initialize per screen dynamic client GLX extensions */ + psc->ext_list_first_time = GL_TRUE; + + if (!DRI2Connect(psc->dpy, RootWindow(psc->dpy, screen), + &driverName, &deviceName)) { + XFree(psp); + return NULL; + } + + psc->driver = driOpenDriver(driverName); + if (psc->driver == NULL) { + ErrorMessageF("driver pointer missing\n"); + goto handle_error; + } + + extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS); + if (extensions == NULL) { + ErrorMessageF("driver exports no extensions (%s)\n", dlerror()); + goto handle_error; + } + + for (i = 0; extensions[i]; i++) { + if (strcmp(extensions[i]->name, __DRI_CORE) == 0) + psc->core = (__DRIcoreExtension *) extensions[i]; + if (strcmp(extensions[i]->name, __DRI_DRI2) == 0) + psc->dri2 = (__DRIdri2Extension *) extensions[i]; + } + + if (psc->core == NULL || psc->dri2 == NULL) { + ErrorMessageF("core dri or dri2 extension not found\n"); + goto handle_error; + } + + psc->fd = open(deviceName, O_RDWR); + if (psc->fd < 0) { + ErrorMessageF("failed to open drm device: %s\n", strerror(errno)); + goto handle_error; + } + + if (drmGetMagic(psc->fd, &magic)) { + ErrorMessageF("failed to get magic\n"); + goto handle_error; + } + + if (!DRI2Authenticate(psc->dpy, RootWindow(psc->dpy, screen), magic)) { + ErrorMessageF("failed to authenticate magic %d\n", magic); + goto handle_error; + } + + /* If the server does not support the protocol for + * DRI2GetBuffersWithFormat, don't supply that interface to the driver. + */ + psc->__driScreen = + psc->dri2->createNewScreen(screen, psc->fd, ((pdp->driMinor < 1) + ? loader_extensions_old + : loader_extensions), + &driver_configs, psc); + + if (psc->__driScreen == NULL) { + ErrorMessageF("failed to create dri screen\n"); + goto handle_error; + } + + driBindCommonExtensions(psc); + dri2BindExtensions(psc); + + psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs); + psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs); + + psc->driver_configs = driver_configs; + + psp->destroyScreen = dri2DestroyScreen; + psp->createContext = dri2CreateContext; + psp->createDrawable = dri2CreateDrawable; + psp->swapBuffers = dri2SwapBuffers; + psp->waitGL = dri2WaitGL; + psp->waitX = dri2WaitX; + psp->getDrawableMSC = NULL; + psp->waitForMSC = NULL; + psp->waitForSBC = NULL; + psp->setSwapInterval = NULL; + psp->getSwapInterval = NULL; + + if (pdp->driMinor >= 2) { +#ifdef X_DRI2GetMSC + psp->getDrawableMSC = dri2DrawableGetMSC; +#endif +#ifdef X_DRI2WaitMSC + psp->waitForMSC = dri2WaitForMSC; + psp->waitForSBC = dri2WaitForSBC; +#endif +#ifdef X_DRI2SwapInterval + psp->setSwapInterval = dri2SetSwapInterval; + psp->getSwapInterval = dri2GetSwapInterval; +#endif + } + + /* DRI2 suports SubBuffer through DRI2CopyRegion, so it's always + * available.*/ + psp->copySubBuffer = dri2CopySubBuffer; + __glXEnableDirectExtension(psc, "GLX_MESA_copy_sub_buffer"); + + Xfree(driverName); + Xfree(deviceName); + + return psp; + +handle_error: + Xfree(driverName); + Xfree(deviceName); + XFree(psp); + + /* FIXME: clean up here */ + + return NULL; +} + +/* Called from __glXFreeDisplayPrivate. + */ +static void +dri2DestroyDisplay(__GLXDRIdisplay * dpy) +{ + Xfree(dpy); +} + +/* + * Allocate, initialize and return a __DRIdisplayPrivate object. + * This is called from __glXInitialize() when we are given a new + * display pointer. + */ +_X_HIDDEN __GLXDRIdisplay * +dri2CreateDisplay(Display * dpy) +{ + __GLXDRIdisplayPrivate *pdp; + int eventBase, errorBase; + + if (!DRI2QueryExtension(dpy, &eventBase, &errorBase)) + return NULL; + + pdp = Xmalloc(sizeof *pdp); + if (pdp == NULL) + return NULL; + + if (!DRI2QueryVersion(dpy, &pdp->driMajor, &pdp->driMinor)) { + Xfree(pdp); + return NULL; + } + + pdp->driPatch = 0; + pdp->swapAvailable = 0; +#ifdef X_DRI2SwapBuffers + if (pdp->driMinor >= 2) + pdp->swapAvailable = 1; +#endif + + pdp->base.destroyDisplay = dri2DestroyDisplay; + pdp->base.createScreen = dri2CreateScreen; + + return &pdp->base; +} + +#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c new file mode 100644 index 00000000000..e4034161bb3 --- /dev/null +++ b/src/glx/dri_common.c @@ -0,0 +1,450 @@ +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright © 2008 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Soft- + * ware"), to deal in the Software without restriction, including without + * limitation the rights to use, copy, modify, merge, publish, distribute, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, provided that the above copyright + * notice(s) and this permission notice appear in all copies of the Soft- + * ware and that both the above copyright notice(s) and this permission + * notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- + * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY + * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN + * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- + * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- + * MANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall + * not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization of + * the copyright holder. + * + * Authors: + * Kevin E. Martin + * Brian Paul + * Kristian Høgsberg (krh@redhat.com) + */ + +#ifdef GLX_DIRECT_RENDERING + +#include +#include +#include +#include "glxclient.h" +#include "glcontextmodes.h" +#include "dri_common.h" + +#ifndef RTLD_NOW +#define RTLD_NOW 0 +#endif +#ifndef RTLD_GLOBAL +#define RTLD_GLOBAL 0 +#endif + +_X_HIDDEN void +InfoMessageF(const char *f, ...) +{ + va_list args; + const char *env; + + if ((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) { + fprintf(stderr, "libGL: "); + va_start(args, f); + vfprintf(stderr, f, args); + va_end(args); + } +} + +/** + * Print error to stderr, unless LIBGL_DEBUG=="quiet". + */ +_X_HIDDEN void +ErrorMessageF(const char *f, ...) +{ + va_list args; + const char *env; + + if ((env = getenv("LIBGL_DEBUG")) && !strstr(env, "quiet")) { + fprintf(stderr, "libGL error: "); + va_start(args, f); + vfprintf(stderr, f, args); + va_end(args); + } +} + +#ifndef DEFAULT_DRIVER_DIR +/* this is normally defined in Mesa/configs/default with DRI_DRIVER_SEARCH_PATH */ +#define DEFAULT_DRIVER_DIR "/usr/local/lib/dri" +#endif + +/** + * Try to \c dlopen the named driver. + * + * This function adds the "_dri.so" suffix to the driver name and searches the + * directories specified by the \c LIBGL_DRIVERS_PATH environment variable in + * order to find the driver. + * + * \param driverName - a name like "tdfx", "i810", "mga", etc. + * + * \returns + * A handle from \c dlopen, or \c NULL if driver file not found. + */ +_X_HIDDEN void * +driOpenDriver(const char *driverName) +{ + void *glhandle, *handle; + const char *libPaths, *p, *next; + char realDriverName[200]; + int len; + + /* Attempt to make sure libGL symbols will be visible to the driver */ + glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL); + + libPaths = NULL; + if (geteuid() == getuid()) { + /* don't allow setuid apps to use LIBGL_DRIVERS_PATH */ + libPaths = getenv("LIBGL_DRIVERS_PATH"); + if (!libPaths) + libPaths = getenv("LIBGL_DRIVERS_DIR"); /* deprecated */ + } + if (libPaths == NULL) + libPaths = DEFAULT_DRIVER_DIR; + + handle = NULL; + for (p = libPaths; *p; p = next) { + next = strchr(p, ':'); + if (next == NULL) { + len = strlen(p); + next = p + len; + } + else { + len = next - p; + next++; + } + +#ifdef GLX_USE_TLS + snprintf(realDriverName, sizeof realDriverName, + "%.*s/tls/%s_dri.so", len, p, driverName); + InfoMessageF("OpenDriver: trying %s\n", realDriverName); + handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL); +#endif + + if (handle == NULL) { + snprintf(realDriverName, sizeof realDriverName, + "%.*s/%s_dri.so", len, p, driverName); + InfoMessageF("OpenDriver: trying %s\n", realDriverName); + handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL); + } + + if (handle != NULL) + break; + else + ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror()); + } + + if (!handle) + ErrorMessageF("unable to load driver: %s_dri.so\n", driverName); + + if (glhandle) + dlclose(glhandle); + + return handle; +} + +_X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension = { + {__DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION}, + __glXGetUST, + __driGetMscRateOML +}; + +#define __ATTRIB(attrib, field) \ + { attrib, offsetof(__GLcontextModes, field) } + +static const struct +{ + unsigned int attrib, offset; +} attribMap[] = { + __ATTRIB(__DRI_ATTRIB_BUFFER_SIZE, rgbBits), + __ATTRIB(__DRI_ATTRIB_LEVEL, level), + __ATTRIB(__DRI_ATTRIB_RED_SIZE, redBits), + __ATTRIB(__DRI_ATTRIB_GREEN_SIZE, greenBits), + __ATTRIB(__DRI_ATTRIB_BLUE_SIZE, blueBits), + __ATTRIB(__DRI_ATTRIB_ALPHA_SIZE, alphaBits), + __ATTRIB(__DRI_ATTRIB_DEPTH_SIZE, depthBits), + __ATTRIB(__DRI_ATTRIB_STENCIL_SIZE, stencilBits), + __ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE, accumRedBits), + __ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE, accumGreenBits), + __ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE, accumBlueBits), + __ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE, accumAlphaBits), + __ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS, sampleBuffers), + __ATTRIB(__DRI_ATTRIB_SAMPLES, samples), + __ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode), + __ATTRIB(__DRI_ATTRIB_STEREO, stereoMode), + __ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers), +#if 0 + __ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel), + __ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentIndex), + __ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed), + __ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen), + __ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue), + __ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha), + __ATTRIB(__DRI_ATTRIB_RED_MASK, redMask), + __ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask), + __ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask), + __ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask), +#endif + __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth), + __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight), + __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels), + __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth), + __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight), +#if 0 + __ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod), +#endif +__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb), + __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba), + __ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE, + bindToMipmapTexture), + __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),}; + +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) + +static int +scalarEqual(__GLcontextModes * mode, unsigned int attrib, unsigned int value) +{ + unsigned int glxValue; + int i; + + for (i = 0; i < ARRAY_SIZE(attribMap); i++) + if (attribMap[i].attrib == attrib) { + glxValue = *(unsigned int *) ((char *) mode + attribMap[i].offset); + return glxValue == GLX_DONT_CARE || glxValue == value; + } + + return GL_TRUE; /* Is a non-existing attribute equal to value? */ +} + +static int +driConfigEqual(const __DRIcoreExtension * core, + __GLcontextModes * modes, const __DRIconfig * driConfig) +{ + unsigned int attrib, value, glxValue; + int i; + + i = 0; + while (core->indexConfigAttrib(driConfig, i++, &attrib, &value)) { + switch (attrib) { + case __DRI_ATTRIB_RENDER_TYPE: + glxValue = 0; + if (value & __DRI_ATTRIB_RGBA_BIT) { + glxValue |= GLX_RGBA_BIT; + } + else if (value & __DRI_ATTRIB_COLOR_INDEX_BIT) { + glxValue |= GLX_COLOR_INDEX_BIT; + } + if (glxValue != modes->renderType) + return GL_FALSE; + break; + + case __DRI_ATTRIB_CONFIG_CAVEAT: + if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG) + glxValue = GLX_NON_CONFORMANT_CONFIG; + else if (value & __DRI_ATTRIB_SLOW_BIT) + glxValue = GLX_SLOW_CONFIG; + else + glxValue = GLX_NONE; + if (glxValue != modes->visualRating) + return GL_FALSE; + break; + + case __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS: + glxValue = 0; + if (value & __DRI_ATTRIB_TEXTURE_1D_BIT) + glxValue |= GLX_TEXTURE_1D_BIT_EXT; + if (value & __DRI_ATTRIB_TEXTURE_2D_BIT) + glxValue |= GLX_TEXTURE_2D_BIT_EXT; + if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT) + glxValue |= GLX_TEXTURE_RECTANGLE_BIT_EXT; + if (modes->bindToTextureTargets != GLX_DONT_CARE && + glxValue != modes->bindToTextureTargets) + return GL_FALSE; + break; + + default: + if (!scalarEqual(modes, attrib, value)) + return GL_FALSE; + } + } + + return GL_TRUE; +} + +static __GLcontextModes * +createDriMode(const __DRIcoreExtension * core, + __GLcontextModes * modes, const __DRIconfig ** driConfigs) +{ + __GLXDRIconfigPrivate *config; + int i; + + for (i = 0; driConfigs[i]; i++) { + if (driConfigEqual(core, modes, driConfigs[i])) + break; + } + + if (driConfigs[i] == NULL) + return NULL; + + config = Xmalloc(sizeof *config); + if (config == NULL) + return NULL; + + config->modes = *modes; + config->driConfig = driConfigs[i]; + + return &config->modes; +} + +_X_HIDDEN __GLcontextModes * +driConvertConfigs(const __DRIcoreExtension * core, + __GLcontextModes * modes, const __DRIconfig ** configs) +{ + __GLcontextModes head, *tail, *m; + + tail = &head; + head.next = NULL; + for (m = modes; m; m = m->next) { + tail->next = createDriMode(core, m, configs); + if (tail->next == NULL) { + /* no matching dri config for m */ + continue; + } + + + tail = tail->next; + } + + _gl_context_modes_destroy(modes); + + return head.next; +} + +/* Bind DRI1 specific extensions */ +_X_HIDDEN void +driBindExtensions(__GLXscreenConfigs *psc) +{ + const __DRIextension **extensions; + int i; + + extensions = psc->core->getExtensions(psc->__driScreen); + + for (i = 0; extensions[i]; i++) { +#ifdef __DRI_SWAP_CONTROL + /* No DRI2 support for swap_control at the moment, since SwapBuffers + * is done by the X server */ + if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) { + psc->swapControl = (__DRIswapControlExtension *) extensions[i]; + __glXEnableDirectExtension(psc, "GLX_SGI_swap_control"); + __glXEnableDirectExtension(psc, "GLX_MESA_swap_control"); + } +#endif + +#ifdef __DRI_MEDIA_STREAM_COUNTER + if (strcmp(extensions[i]->name, __DRI_MEDIA_STREAM_COUNTER) == 0) { + psc->msc = (__DRImediaStreamCounterExtension *) extensions[i]; + __glXEnableDirectExtension(psc, "GLX_SGI_video_sync"); + } +#endif + +#ifdef __DRI_SWAP_BUFFER_COUNTER + /* No driver supports this at this time and the extension is + * not defined in dri_interface.h. Will enable + * GLX_OML_sync_control if implemented. */ +#endif + + /* Ignore unknown extensions */ + } +} + +/* Bind DRI2 specific extensions */ +_X_HIDDEN void +dri2BindExtensions(__GLXscreenConfigs *psc) +{ + const __DRIextension **extensions; + int i; + + extensions = psc->core->getExtensions(psc->__driScreen); + + for (i = 0; extensions[i]; i++) { +#ifdef __DRI_TEX_BUFFER + if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) { + psc->texBuffer = (__DRItexBufferExtension *) extensions[i]; + __glXEnableDirectExtension(psc, "GLX_EXT_texture_from_pixmap"); + } +#endif + + __glXEnableDirectExtension(psc, "GLX_SGI_video_sync"); + __glXEnableDirectExtension(psc, "GLX_SGI_swap_control"); + __glXEnableDirectExtension(psc, "GLX_MESA_swap_control"); + + /* FIXME: if DRI2 version supports it... */ + __glXEnableDirectExtension(psc, "INTEL_swap_event"); + +#ifdef __DRI2_FLUSH + if ((strcmp(extensions[i]->name, __DRI2_FLUSH) == 0)) { + psc->f = (__DRI2flushExtension *) extensions[i]; + /* internal driver extension, no GL extension exposed */ + } +#endif + } +} + +/* Bind extensions common to DRI1 and DRI2 */ +_X_HIDDEN void +driBindCommonExtensions(__GLXscreenConfigs *psc) +{ + const __DRIextension **extensions; + int i; + + extensions = psc->core->getExtensions(psc->__driScreen); + + for (i = 0; extensions[i]; i++) { +#ifdef __DRI_COPY_SUB_BUFFER + if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) { + psc->driCopySubBuffer = (__DRIcopySubBufferExtension *) extensions[i]; + __glXEnableDirectExtension(psc, "GLX_MESA_copy_sub_buffer"); + } +#endif + +#ifdef __DRI_ALLOCATE + if (strcmp(extensions[i]->name, __DRI_ALLOCATE) == 0) { + psc->allocate = (__DRIallocateExtension *) extensions[i]; + __glXEnableDirectExtension(psc, "GLX_MESA_allocate_memory"); + } +#endif + +#ifdef __DRI_FRAME_TRACKING + if (strcmp(extensions[i]->name, __DRI_FRAME_TRACKING) == 0) { + psc->frameTracking = (__DRIframeTrackingExtension *) extensions[i]; + __glXEnableDirectExtension(psc, "GLX_MESA_swap_frame_usage"); + } +#endif + +#ifdef __DRI_READ_DRAWABLE + if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) { + __glXEnableDirectExtension(psc, "GLX_SGI_make_current_read"); + } +#endif + + /* Ignore unknown extensions */ + } +} + +#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/dri_common.h b/src/glx/dri_common.h new file mode 100644 index 00000000000..bb178db7875 --- /dev/null +++ b/src/glx/dri_common.h @@ -0,0 +1,63 @@ +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright © 2008 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Soft- + * ware"), to deal in the Software without restriction, including without + * limitation the rights to use, copy, modify, merge, publish, distribute, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, provided that the above copyright + * notice(s) and this permission notice appear in all copies of the Soft- + * ware and that both the above copyright notice(s) and this permission + * notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- + * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY + * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN + * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- + * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- + * MANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall + * not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization of + * the copyright holder. + * + * Authors: + * Kevin E. Martin + * Brian Paul + * Kristian Høgsberg (krh@redhat.com) + */ + +#ifndef _DRI_COMMON_H +#define _DRI_COMMON_H + +typedef struct __GLXDRIconfigPrivateRec __GLXDRIconfigPrivate; + +struct __GLXDRIconfigPrivateRec +{ + __GLcontextModes modes; + const __DRIconfig *driConfig; +}; + +extern __GLcontextModes *driConvertConfigs(const __DRIcoreExtension * core, + __GLcontextModes * modes, + const __DRIconfig ** configs); + +extern const __DRIsystemTimeExtension systemTimeExtension; + +extern void InfoMessageF(const char *f, ...); + +extern void ErrorMessageF(const char *f, ...); + +extern void *driOpenDriver(const char *driverName); + +extern void driBindExtensions(__GLXscreenConfigs * psc); +extern void dri2BindExtensions(__GLXscreenConfigs * psc); +extern void driBindCommonExtensions(__GLXscreenConfigs * psc); + +#endif /* _DRI_COMMON_H */ diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c new file mode 100644 index 00000000000..0ff53c324f5 --- /dev/null +++ b/src/glx/dri_glx.c @@ -0,0 +1,751 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin + * Brian Paul + * + */ + +#ifdef GLX_DIRECT_RENDERING + +#include +#include +#include +#include "glxclient.h" +#include "xf86dri.h" +#include "dri2.h" +#include "sarea.h" +#include +#include +#include +#include "xf86drm.h" +#include "dri_common.h" + +typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate; +typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate; + +struct __GLXDRIdisplayPrivateRec +{ + __GLXDRIdisplay base; + + /* + ** XFree86-DRI version information + */ + int driMajor; + int driMinor; + int driPatch; +}; + +struct __GLXDRIcontextPrivateRec +{ + __GLXDRIcontext base; + __DRIcontext *driContext; + XID hwContextID; + __GLXscreenConfigs *psc; +}; + +/* + * Given a display pointer and screen number, determine the name of + * the DRI driver for the screen. (I.e. "r128", "tdfx", etc). + * Return True for success, False for failure. + */ +static Bool +driGetDriverName(Display * dpy, int scrNum, char **driverName) +{ + int directCapable; + Bool b; + int event, error; + int driverMajor, driverMinor, driverPatch; + + *driverName = NULL; + + if (XF86DRIQueryExtension(dpy, &event, &error)) { /* DRI1 */ + if (!XF86DRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) { + ErrorMessageF("XF86DRIQueryDirectRenderingCapable failed\n"); + return False; + } + if (!directCapable) { + ErrorMessageF("XF86DRIQueryDirectRenderingCapable returned false\n"); + return False; + } + + b = XF86DRIGetClientDriverName(dpy, scrNum, &driverMajor, &driverMinor, + &driverPatch, driverName); + if (!b) { + ErrorMessageF("Cannot determine driver name for screen %d\n", + scrNum); + return False; + } + + InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n", + driverMajor, driverMinor, driverPatch, *driverName, + scrNum); + + return True; + } + else if (DRI2QueryExtension(dpy, &event, &error)) { /* DRI2 */ + char *dev; + Bool ret = DRI2Connect(dpy, RootWindow(dpy, scrNum), driverName, &dev); + + if (ret) + Xfree(dev); + + return ret; + } + + return False; +} + +/* + * Exported function for querying the DRI driver for a given screen. + * + * The returned char pointer points to a static array that will be + * overwritten by subsequent calls. + */ +PUBLIC const char * +glXGetScreenDriver(Display * dpy, int scrNum) +{ + static char ret[32]; + char *driverName; + if (driGetDriverName(dpy, scrNum, &driverName)) { + int len; + if (!driverName) + return NULL; + len = strlen(driverName); + if (len >= 31) + return NULL; + memcpy(ret, driverName, len + 1); + Xfree(driverName); + return ret; + } + return NULL; +} + +/* + * Exported function for obtaining a driver's option list (UTF-8 encoded XML). + * + * The returned char pointer points directly into the driver. Therefore + * it should be treated as a constant. + * + * If the driver was not found or does not support configuration NULL is + * returned. + * + * Note: The driver remains opened after this function returns. + */ +PUBLIC const char * +glXGetDriverConfig(const char *driverName) +{ + void *handle = driOpenDriver(driverName); + if (handle) + return dlsym(handle, "__driConfigOptions"); + else + return NULL; +} + +#ifdef XDAMAGE_1_1_INTERFACE + +static GLboolean +has_damage_post(Display * dpy) +{ + static GLboolean inited = GL_FALSE; + static GLboolean has_damage; + + if (!inited) { + int major, minor; + + if (XDamageQueryVersion(dpy, &major, &minor) && + major == 1 && minor >= 1) { + has_damage = GL_TRUE; + } + else { + has_damage = GL_FALSE; + } + inited = GL_TRUE; + } + + return has_damage; +} + +static void +__glXReportDamage(__DRIdrawable * driDraw, + int x, int y, + drm_clip_rect_t * rects, int num_rects, + GLboolean front_buffer, void *loaderPrivate) +{ + XRectangle *xrects; + XserverRegion region; + int i; + int x_off, y_off; + __GLXDRIdrawable *glxDraw = loaderPrivate; + __GLXscreenConfigs *psc = glxDraw->psc; + Display *dpy = psc->dpy; + Drawable drawable; + + if (!has_damage_post(dpy)) + return; + + if (front_buffer) { + x_off = x; + y_off = y; + drawable = RootWindow(dpy, psc->scr); + } + else { + x_off = 0; + y_off = 0; + drawable = glxDraw->xDrawable; + } + + xrects = malloc(sizeof(XRectangle) * num_rects); + if (xrects == NULL) + return; + + for (i = 0; i < num_rects; i++) { + xrects[i].x = rects[i].x1 + x_off; + xrects[i].y = rects[i].y1 + y_off; + xrects[i].width = rects[i].x2 - rects[i].x1; + xrects[i].height = rects[i].y2 - rects[i].y1; + } + region = XFixesCreateRegion(dpy, xrects, num_rects); + free(xrects); + XDamageAdd(dpy, drawable, region); + XFixesDestroyRegion(dpy, region); +} + +static const __DRIdamageExtension damageExtension = { + {__DRI_DAMAGE, __DRI_DAMAGE_VERSION}, + __glXReportDamage, +}; + +#endif + +static GLboolean +__glXDRIGetDrawableInfo(__DRIdrawable * drawable, + unsigned int *index, unsigned int *stamp, + int *X, int *Y, int *W, int *H, + int *numClipRects, drm_clip_rect_t ** pClipRects, + int *backX, int *backY, + int *numBackClipRects, + drm_clip_rect_t ** pBackClipRects, + void *loaderPrivate) +{ + __GLXDRIdrawable *glxDraw = loaderPrivate; + __GLXscreenConfigs *psc = glxDraw->psc; + Display *dpy = psc->dpy; + + return XF86DRIGetDrawableInfo(dpy, psc->scr, glxDraw->drawable, + index, stamp, X, Y, W, H, + numClipRects, pClipRects, + backX, backY, + numBackClipRects, pBackClipRects); +} + +static const __DRIgetDrawableInfoExtension getDrawableInfoExtension = { + {__DRI_GET_DRAWABLE_INFO, __DRI_GET_DRAWABLE_INFO_VERSION}, + __glXDRIGetDrawableInfo +}; + +static const __DRIextension *loader_extensions[] = { + &systemTimeExtension.base, + &getDrawableInfoExtension.base, +#ifdef XDAMAGE_1_1_INTERFACE + &damageExtension.base, +#endif + NULL +}; + +/** + * Perform the required libGL-side initialization and call the client-side + * driver's \c __driCreateNewScreen function. + * + * \param dpy Display pointer. + * \param scrn Screen number on the display. + * \param psc DRI screen information. + * \param driDpy DRI display information. + * \param createNewScreen Pointer to the client-side driver's + * \c __driCreateNewScreen function. + * \returns A pointer to the \c __DRIscreen structure returned by + * the client-side driver on success, or \c NULL on failure. + */ +static void * +CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc, + __GLXDRIdisplayPrivate * driDpy) +{ + void *psp = NULL; + drm_handle_t hSAREA; + drmAddress pSAREA = MAP_FAILED; + char *BusID; + __DRIversion ddx_version; + __DRIversion dri_version; + __DRIversion drm_version; + __DRIframebuffer framebuffer; + int fd = -1; + int status; + + drm_magic_t magic; + drmVersionPtr version; + int newlyopened; + char *driverName; + drm_handle_t hFB; + int junk; + const __DRIconfig **driver_configs; + __GLcontextModes *visual; + + /* DRI protocol version. */ + dri_version.major = driDpy->driMajor; + dri_version.minor = driDpy->driMinor; + dri_version.patch = driDpy->driPatch; + + framebuffer.base = MAP_FAILED; + framebuffer.dev_priv = NULL; + + if (!XF86DRIOpenConnection(dpy, scrn, &hSAREA, &BusID)) { + ErrorMessageF("XF86DRIOpenConnection failed\n"); + goto handle_error; + } + + fd = drmOpenOnce(NULL, BusID, &newlyopened); + + Xfree(BusID); /* No longer needed */ + + if (fd < 0) { + ErrorMessageF("drmOpenOnce failed (%s)\n", strerror(-fd)); + goto handle_error; + } + + if (drmGetMagic(fd, &magic)) { + ErrorMessageF("drmGetMagic failed\n"); + goto handle_error; + } + + version = drmGetVersion(fd); + if (version) { + drm_version.major = version->version_major; + drm_version.minor = version->version_minor; + drm_version.patch = version->version_patchlevel; + drmFreeVersion(version); + } + else { + drm_version.major = -1; + drm_version.minor = -1; + drm_version.patch = -1; + } + + if (newlyopened && !XF86DRIAuthConnection(dpy, scrn, magic)) { + ErrorMessageF("XF86DRIAuthConnection failed\n"); + goto handle_error; + } + + /* Get device name (like "tdfx") and the ddx version numbers. + * We'll check the version in each DRI driver's "createNewScreen" + * function. */ + if (!XF86DRIGetClientDriverName(dpy, scrn, + &ddx_version.major, + &ddx_version.minor, + &ddx_version.patch, &driverName)) { + ErrorMessageF("XF86DRIGetClientDriverName failed\n"); + goto handle_error; + } + + Xfree(driverName); /* No longer needed. */ + + /* + * Get device-specific info. pDevPriv will point to a struct + * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) that + * has information about the screen size, depth, pitch, ancilliary + * buffers, DRM mmap handles, etc. + */ + if (!XF86DRIGetDeviceInfo(dpy, scrn, &hFB, &junk, + &framebuffer.size, &framebuffer.stride, + &framebuffer.dev_priv_size, + &framebuffer.dev_priv)) { + ErrorMessageF("XF86DRIGetDeviceInfo failed"); + goto handle_error; + } + + framebuffer.width = DisplayWidth(dpy, scrn); + framebuffer.height = DisplayHeight(dpy, scrn); + + /* Map the framebuffer region. */ + status = drmMap(fd, hFB, framebuffer.size, + (drmAddressPtr) & framebuffer.base); + if (status != 0) { + ErrorMessageF("drmMap of framebuffer failed (%s)", strerror(-status)); + goto handle_error; + } + + /* Map the SAREA region. Further mmap regions may be setup in + * each DRI driver's "createNewScreen" function. + */ + status = drmMap(fd, hSAREA, SAREA_MAX, &pSAREA); + if (status != 0) { + ErrorMessageF("drmMap of SAREA failed (%s)", strerror(-status)); + goto handle_error; + } + + psp = (*psc->legacy->createNewScreen) (scrn, + &ddx_version, + &dri_version, + &drm_version, + &framebuffer, + pSAREA, + fd, + loader_extensions, + &driver_configs, psc); + + if (psp == NULL) { + ErrorMessageF("Calling driver entry point failed"); + goto handle_error; + } + + psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs); + psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs); + + psc->driver_configs = driver_configs; + + /* Visuals with depth != screen depth are subject to automatic compositing + * in the X server, so DRI1 can't render to them properly. Mark them as + * non-conformant to prevent apps from picking them up accidentally. + */ + for (visual = psc->visuals; visual; visual = visual->next) { + XVisualInfo template; + XVisualInfo *visuals; + int num_visuals; + long mask; + + template.visualid = visual->visualID; + mask = VisualIDMask; + visuals = XGetVisualInfo(dpy, mask, &template, &num_visuals); + + if (visuals) { + if (num_visuals > 0 && visuals->depth != DefaultDepth(dpy, scrn)) + visual->visualRating = GLX_NON_CONFORMANT_CONFIG; + + XFree(visuals); + } + } + + return psp; + + handle_error: + if (pSAREA != MAP_FAILED) + drmUnmap(pSAREA, SAREA_MAX); + + if (framebuffer.base != MAP_FAILED) + drmUnmap((drmAddress) framebuffer.base, framebuffer.size); + + if (framebuffer.dev_priv != NULL) + Xfree(framebuffer.dev_priv); + + if (fd >= 0) + drmCloseOnce(fd); + + XF86DRICloseConnection(dpy, scrn); + + ErrorMessageF("reverting to software direct rendering\n"); + + return NULL; +} + +static void +driDestroyContext(__GLXDRIcontext * context, + __GLXscreenConfigs * psc, Display * dpy) +{ + __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; + + (*psc->core->destroyContext) (pcp->driContext); + + XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID); + Xfree(pcp); +} + +static Bool +driBindContext(__GLXDRIcontext * context, + __GLXDRIdrawable * draw, __GLXDRIdrawable * read) +{ + __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; + const __DRIcoreExtension *core = pcp->psc->core; + + return (*core->bindContext) (pcp->driContext, + draw->driDrawable, read->driDrawable); +} + +static void +driUnbindContext(__GLXDRIcontext * context) +{ + __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; + const __DRIcoreExtension *core = pcp->psc->core; + + (*core->unbindContext) (pcp->driContext); +} + +static __GLXDRIcontext * +driCreateContext(__GLXscreenConfigs * psc, + const __GLcontextModes * mode, + GLXContext gc, GLXContext shareList, int renderType) +{ + __GLXDRIcontextPrivate *pcp, *pcp_shared; + drm_context_t hwContext; + __DRIcontext *shared = NULL; + __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode; + + if (!psc || !psc->driScreen) + return NULL; + + if (shareList) { + pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext; + shared = pcp_shared->driContext; + } + + pcp = Xmalloc(sizeof *pcp); + if (pcp == NULL) + return NULL; + + pcp->psc = psc; + if (!XF86DRICreateContextWithConfig(psc->dpy, psc->scr, + mode->visualID, + &pcp->hwContextID, &hwContext)) { + Xfree(pcp); + return NULL; + } + + pcp->driContext = + (*psc->legacy->createNewContext) (psc->__driScreen, + config->driConfig, + renderType, shared, hwContext, pcp); + if (pcp->driContext == NULL) { + XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID); + Xfree(pcp); + return NULL; + } + + pcp->base.destroyContext = driDestroyContext; + pcp->base.bindContext = driBindContext; + pcp->base.unbindContext = driUnbindContext; + + return &pcp->base; +} + +static void +driDestroyDrawable(__GLXDRIdrawable * pdraw) +{ + __GLXscreenConfigs *psc = pdraw->psc; + + (*psc->core->destroyDrawable) (pdraw->driDrawable); + XF86DRIDestroyDrawable(psc->dpy, psc->scr, pdraw->drawable); + Xfree(pdraw); +} + +static __GLXDRIdrawable * +driCreateDrawable(__GLXscreenConfigs * psc, + XID xDrawable, + GLXDrawable drawable, const __GLcontextModes * modes) +{ + __GLXDRIdrawable *pdraw; + drm_drawable_t hwDrawable; + void *empty_attribute_list = NULL; + __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; + + /* Old dri can't handle GLX 1.3+ drawable constructors. */ + if (xDrawable != drawable) + return NULL; + + pdraw = Xmalloc(sizeof(*pdraw)); + if (!pdraw) + return NULL; + + pdraw->drawable = drawable; + pdraw->psc = psc; + + if (!XF86DRICreateDrawable(psc->dpy, psc->scr, drawable, &hwDrawable)) { + Xfree(pdraw); + return NULL; + } + + /* Create a new drawable */ + pdraw->driDrawable = + (*psc->legacy->createNewDrawable) (psc->__driScreen, + config->driConfig, + hwDrawable, + GLX_WINDOW_BIT, + empty_attribute_list, pdraw); + + if (!pdraw->driDrawable) { + XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable); + Xfree(pdraw); + return NULL; + } + + pdraw->destroyDrawable = driDestroyDrawable; + + return pdraw; +} + +static int64_t +driSwapBuffers(__GLXDRIdrawable * pdraw, int64_t unused1, int64_t unused2, + int64_t unused3) +{ + (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable); + return 0; +} + +static void +driCopySubBuffer(__GLXDRIdrawable * pdraw, + int x, int y, int width, int height) +{ + (*pdraw->psc->driCopySubBuffer->copySubBuffer) (pdraw->driDrawable, + x, y, width, height); +} + +static void +driDestroyScreen(__GLXscreenConfigs * psc) +{ + /* Free the direct rendering per screen data */ + if (psc->__driScreen) + (*psc->core->destroyScreen) (psc->__driScreen); + psc->__driScreen = NULL; + if (psc->driver) + dlclose(psc->driver); +} + +static __GLXDRIscreen * +driCreateScreen(__GLXscreenConfigs * psc, int screen, + __GLXdisplayPrivate * priv) +{ + __GLXDRIdisplayPrivate *pdp; + __GLXDRIscreen *psp; + const __DRIextension **extensions; + char *driverName; + int i; + + psp = Xcalloc(1, sizeof *psp); + if (psp == NULL) + return NULL; + + /* Initialize per screen dynamic client GLX extensions */ + psc->ext_list_first_time = GL_TRUE; + + if (!driGetDriverName(priv->dpy, screen, &driverName)) { + Xfree(psp); + return NULL; + } + + psc->driver = driOpenDriver(driverName); + Xfree(driverName); + if (psc->driver == NULL) { + Xfree(psp); + return NULL; + } + + extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS); + if (extensions == NULL) { + ErrorMessageF("driver exports no extensions (%s)\n", dlerror()); + Xfree(psp); + return NULL; + } + + for (i = 0; extensions[i]; i++) { + if (strcmp(extensions[i]->name, __DRI_CORE) == 0) + psc->core = (__DRIcoreExtension *) extensions[i]; + if (strcmp(extensions[i]->name, __DRI_LEGACY) == 0) + psc->legacy = (__DRIlegacyExtension *) extensions[i]; + } + + if (psc->core == NULL || psc->legacy == NULL) { + Xfree(psp); + return NULL; + } + + pdp = (__GLXDRIdisplayPrivate *) priv->driDisplay; + psc->__driScreen = CallCreateNewScreen(psc->dpy, screen, psc, pdp); + if (psc->__driScreen == NULL) { + dlclose(psc->driver); + Xfree(psp); + return NULL; + } + + driBindExtensions(psc); + driBindCommonExtensions(psc); + + if (psc->driCopySubBuffer) + psp->copySubBuffer = driCopySubBuffer; + + psp->destroyScreen = driDestroyScreen; + psp->createContext = driCreateContext; + psp->createDrawable = driCreateDrawable; + psp->swapBuffers = driSwapBuffers; + psp->waitX = NULL; + psp->waitGL = NULL; + + return psp; +} + +/* Called from __glXFreeDisplayPrivate. + */ +static void +driDestroyDisplay(__GLXDRIdisplay * dpy) +{ + Xfree(dpy); +} + +/* + * Allocate, initialize and return a __DRIdisplayPrivate object. + * This is called from __glXInitialize() when we are given a new + * display pointer. + */ +_X_HIDDEN __GLXDRIdisplay * +driCreateDisplay(Display * dpy) +{ + __GLXDRIdisplayPrivate *pdpyp; + int eventBase, errorBase; + int major, minor, patch; + + if (!XF86DRIQueryExtension(dpy, &eventBase, &errorBase)) { + return NULL; + } + + if (!XF86DRIQueryVersion(dpy, &major, &minor, &patch)) { + return NULL; + } + + pdpyp = Xmalloc(sizeof *pdpyp); + if (!pdpyp) { + return NULL; + } + + pdpyp->driMajor = major; + pdpyp->driMinor = minor; + pdpyp->driPatch = patch; + + pdpyp->base.destroyDisplay = driDestroyDisplay; + pdpyp->base.createScreen = driCreateScreen; + + return &pdpyp->base; +} + +#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c new file mode 100644 index 00000000000..eed9a8c4723 --- /dev/null +++ b/src/glx/drisw_glx.c @@ -0,0 +1,456 @@ +/* + * Copyright 2008 George Sapountzis + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifdef GLX_DIRECT_RENDERING + +#include +#include "glxclient.h" +#include +#include "dri_common.h" + +typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate; +typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate; +typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate; + +struct __GLXDRIdisplayPrivateRec +{ + __GLXDRIdisplay base; +}; + +struct __GLXDRIcontextPrivateRec +{ + __GLXDRIcontext base; + __DRIcontext *driContext; + __GLXscreenConfigs *psc; +}; + +struct __GLXDRIdrawablePrivateRec +{ + __GLXDRIdrawable base; + + GC gc; + GC swapgc; + + XVisualInfo *visinfo; + XImage *ximage; + int bpp; +}; + +/** + * swrast loader functions + */ + +static Bool +XCreateDrawable(__GLXDRIdrawablePrivate * pdp, + Display * dpy, XID drawable, int visualid) +{ + XGCValues gcvalues; + long visMask; + XVisualInfo visTemp; + int num_visuals; + + /* create GC's */ + pdp->gc = XCreateGC(dpy, drawable, 0, NULL); + pdp->swapgc = XCreateGC(dpy, drawable, 0, NULL); + + gcvalues.function = GXcopy; + gcvalues.graphics_exposures = False; + XChangeGC(dpy, pdp->gc, GCFunction, &gcvalues); + XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues); + XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues); + + /* create XImage */ + visTemp.screen = DefaultScreen(dpy); + visTemp.visualid = visualid; + visMask = (VisualScreenMask | VisualIDMask); + pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals); + + pdp->ximage = XCreateImage(dpy, pdp->visinfo->visual, pdp->visinfo->depth, ZPixmap, 0, /* format, offset */ + NULL, /* data */ + 0, 0, /* size */ + 32, /* bitmap_pad */ + 0); /* bytes_per_line */ + + /* get the true number of bits per pixel */ + pdp->bpp = pdp->ximage->bits_per_pixel; + + return True; +} + +static void +XDestroyDrawable(__GLXDRIdrawablePrivate * pdp, Display * dpy, XID drawable) +{ + XDestroyImage(pdp->ximage); + XFree(pdp->visinfo); + + XFreeGC(dpy, pdp->gc); + XFreeGC(dpy, pdp->swapgc); +} + +static void +swrastGetDrawableInfo(__DRIdrawable * draw, + int *x, int *y, int *w, int *h, void *loaderPrivate) +{ + __GLXDRIdrawablePrivate *pdp = loaderPrivate; + __GLXDRIdrawable *pdraw = &(pdp->base); + Display *dpy = pdraw->psc->dpy; + Drawable drawable; + + Window root; + Status stat; + unsigned int bw, depth; + + drawable = pdraw->xDrawable; + + stat = XGetGeometry(dpy, drawable, &root, + x, y, (unsigned int *) w, (unsigned int *) h, + &bw, &depth); +} + +static inline int +bytes_per_line(int w, int bpp, unsigned mul) +{ + unsigned mask = mul - 1; + + return ((w * bpp + mask) & ~mask) / 8; +} + +static void +swrastPutImage(__DRIdrawable * draw, int op, + int x, int y, int w, int h, char *data, void *loaderPrivate) +{ + __GLXDRIdrawablePrivate *pdp = loaderPrivate; + __GLXDRIdrawable *pdraw = &(pdp->base); + Display *dpy = pdraw->psc->dpy; + Drawable drawable; + XImage *ximage; + GC gc; + + switch (op) { + case __DRI_SWRAST_IMAGE_OP_DRAW: + gc = pdp->gc; + break; + case __DRI_SWRAST_IMAGE_OP_SWAP: + gc = pdp->swapgc; + break; + default: + return; + } + + drawable = pdraw->xDrawable; + + ximage = pdp->ximage; + ximage->data = data; + ximage->width = w; + ximage->height = h; + ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32); + + XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h); + + ximage->data = NULL; +} + +static void +swrastGetImage(__DRIdrawable * draw, + int x, int y, int w, int h, char *data, void *loaderPrivate) +{ + __GLXDRIdrawablePrivate *pdp = loaderPrivate; + __GLXDRIdrawable *pdraw = &(pdp->base); + Display *dpy = pdraw->psc->dpy; + Drawable drawable; + XImage *ximage; + + drawable = pdraw->xDrawable; + + ximage = pdp->ximage; + ximage->data = data; + ximage->width = w; + ximage->height = h; + ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32); + + XGetSubImage(dpy, drawable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0); + + ximage->data = NULL; +} + +static const __DRIswrastLoaderExtension swrastLoaderExtension = { + {__DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION}, + swrastGetDrawableInfo, + swrastPutImage, + swrastGetImage +}; + +static const __DRIextension *loader_extensions[] = { + &systemTimeExtension.base, + &swrastLoaderExtension.base, + NULL +}; + +/** + * GLXDRI functions + */ + +static void +driDestroyContext(__GLXDRIcontext * context, + __GLXscreenConfigs * psc, Display * dpy) +{ + __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; + const __DRIcoreExtension *core = pcp->psc->core; + + (*core->destroyContext) (pcp->driContext); + + Xfree(pcp); +} + +static Bool +driBindContext(__GLXDRIcontext * context, + __GLXDRIdrawable * draw, __GLXDRIdrawable * read) +{ + __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; + const __DRIcoreExtension *core = pcp->psc->core; + + return (*core->bindContext) (pcp->driContext, + draw->driDrawable, read->driDrawable); +} + +static void +driUnbindContext(__GLXDRIcontext * context) +{ + __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; + const __DRIcoreExtension *core = pcp->psc->core; + + (*core->unbindContext) (pcp->driContext); +} + +static __GLXDRIcontext * +driCreateContext(__GLXscreenConfigs * psc, + const __GLcontextModes * mode, + GLXContext gc, GLXContext shareList, int renderType) +{ + __GLXDRIcontextPrivate *pcp, *pcp_shared; + __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode; + const __DRIcoreExtension *core; + __DRIcontext *shared = NULL; + + if (!psc || !psc->driScreen) + return NULL; + + core = psc->core; + + if (shareList) { + pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext; + shared = pcp_shared->driContext; + } + + pcp = Xmalloc(sizeof *pcp); + if (pcp == NULL) + return NULL; + + pcp->psc = psc; + pcp->driContext = + (*core->createNewContext) (psc->__driScreen, + config->driConfig, shared, pcp); + if (pcp->driContext == NULL) { + Xfree(pcp); + return NULL; + } + + pcp->base.destroyContext = driDestroyContext; + pcp->base.bindContext = driBindContext; + pcp->base.unbindContext = driUnbindContext; + + return &pcp->base; +} + +static void +driDestroyDrawable(__GLXDRIdrawable * pdraw) +{ + __GLXDRIdrawablePrivate *pdp = (__GLXDRIdrawablePrivate *) pdraw; + const __DRIcoreExtension *core = pdraw->psc->core; + + (*core->destroyDrawable) (pdraw->driDrawable); + + XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable); + Xfree(pdp); +} + +static __GLXDRIdrawable * +driCreateDrawable(__GLXscreenConfigs * psc, + XID xDrawable, + GLXDrawable drawable, const __GLcontextModes * modes) +{ + __GLXDRIdrawable *pdraw; + __GLXDRIdrawablePrivate *pdp; + __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; + const __DRIswrastExtension *swrast = psc->swrast; + + /* Old dri can't handle GLX 1.3+ drawable constructors. */ + if (xDrawable != drawable) + return NULL; + + pdp = Xmalloc(sizeof(*pdp)); + if (!pdp) + return NULL; + + pdraw = &(pdp->base); + pdraw->xDrawable = xDrawable; + pdraw->drawable = drawable; + pdraw->psc = psc; + + XCreateDrawable(pdp, psc->dpy, xDrawable, modes->visualID); + + /* Create a new drawable */ + pdraw->driDrawable = + (*swrast->createNewDrawable) (psc->__driScreen, config->driConfig, pdp); + + if (!pdraw->driDrawable) { + XDestroyDrawable(pdp, psc->dpy, xDrawable); + Xfree(pdp); + return NULL; + } + + pdraw->destroyDrawable = driDestroyDrawable; + + return pdraw; +} + +static void +driSwapBuffers(__GLXDRIdrawable * pdraw) +{ + (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable); +} + +static void +driDestroyScreen(__GLXscreenConfigs * psc) +{ + /* Free the direct rendering per screen data */ + (*psc->core->destroyScreen) (psc->__driScreen); + psc->__driScreen = NULL; + if (psc->driver) + dlclose(psc->driver); +} + +static __GLXDRIscreen * +driCreateScreen(__GLXscreenConfigs * psc, int screen, + __GLXdisplayPrivate * priv) +{ + __GLXDRIscreen *psp; + const __DRIconfig **driver_configs; + const __DRIextension **extensions; + const char *driverName = "swrast"; + int i; + + psp = Xcalloc(1, sizeof *psp); + if (psp == NULL) + return NULL; + + /* Initialize per screen dynamic client GLX extensions */ + psc->ext_list_first_time = GL_TRUE; + + psc->driver = driOpenDriver(driverName); + if (psc->driver == NULL) + goto handle_error; + + extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS); + if (extensions == NULL) { + ErrorMessageF("driver exports no extensions (%s)\n", dlerror()); + goto handle_error; + } + + for (i = 0; extensions[i]; i++) { + if (strcmp(extensions[i]->name, __DRI_CORE) == 0) + psc->core = (__DRIcoreExtension *) extensions[i]; + if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0) + psc->swrast = (__DRIswrastExtension *) extensions[i]; + } + + if (psc->core == NULL || psc->swrast == NULL) { + ErrorMessageF("core dri extension not found\n"); + goto handle_error; + } + + psc->__driScreen = + psc->swrast->createNewScreen(screen, + loader_extensions, &driver_configs, psc); + if (psc->__driScreen == NULL) { + ErrorMessageF("failed to create dri screen\n"); + goto handle_error; + } + + driBindExtensions(psc); + driBindCommonExtensions(psc); + + psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs); + psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs); + + psc->driver_configs = driver_configs; + + psp->destroyScreen = driDestroyScreen; + psp->createContext = driCreateContext; + psp->createDrawable = driCreateDrawable; + psp->swapBuffers = driSwapBuffers; + psp->waitX = NULL; + psp->waitGL = NULL; + + return psp; + + handle_error: + Xfree(psp); + + if (psc->driver) + dlclose(psc->driver); + + ErrorMessageF("reverting to indirect rendering\n"); + + return NULL; +} + +/* Called from __glXFreeDisplayPrivate. + */ +static void +driDestroyDisplay(__GLXDRIdisplay * dpy) +{ + Xfree(dpy); +} + +/* + * Allocate, initialize and return a __DRIdisplayPrivate object. + * This is called from __glXInitialize() when we are given a new + * display pointer. + */ +_X_HIDDEN __GLXDRIdisplay * +driswCreateDisplay(Display * dpy) +{ + __GLXDRIdisplayPrivate *pdpyp; + + pdpyp = Xmalloc(sizeof *pdpyp); + if (pdpyp == NULL) + return NULL; + + pdpyp->base.destroyDisplay = driDestroyDisplay; + pdpyp->base.createScreen = driCreateScreen; + + return &pdpyp->base; +} + +#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/eval.c b/src/glx/eval.c new file mode 100644 index 00000000000..226fb7df2e8 --- /dev/null +++ b/src/glx/eval.c @@ -0,0 +1,132 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +#include "packrender.h" + +/* +** Routines to pack evaluator maps into the transport buffer. Maps are +** allowed to have extra arbitrary data, so these routines extract just +** the information that the GL needs. +*/ + +void +__glFillMap1f(GLint k, GLint order, GLint stride, + const GLfloat * points, GLubyte * pc) +{ + if (stride == k) { + /* Just copy the data */ + __GLX_PUT_FLOAT_ARRAY(0, points, order * k); + } + else { + GLint i; + + for (i = 0; i < order; i++) { + __GLX_PUT_FLOAT_ARRAY(0, points, k); + points += stride; + pc += k * __GLX_SIZE_FLOAT32; + } + } +} + +void +__glFillMap1d(GLint k, GLint order, GLint stride, + const GLdouble * points, GLubyte * pc) +{ + if (stride == k) { + /* Just copy the data */ + __GLX_PUT_DOUBLE_ARRAY(0, points, order * k); + } + else { + GLint i; + for (i = 0; i < order; i++) { + __GLX_PUT_DOUBLE_ARRAY(0, points, k); + points += stride; + pc += k * __GLX_SIZE_FLOAT64; + } + } +} + +void +__glFillMap2f(GLint k, GLint majorOrder, GLint minorOrder, + GLint majorStride, GLint minorStride, + const GLfloat * points, GLfloat * data) +{ + GLint i, j, x; + + if ((minorStride == k) && (majorStride == minorOrder * k)) { + /* Just copy the data */ + __GLX_MEM_COPY(data, points, majorOrder * majorStride * + __GLX_SIZE_FLOAT32); + return; + } + for (i = 0; i < majorOrder; i++) { + for (j = 0; j < minorOrder; j++) { + for (x = 0; x < k; x++) { + data[x] = points[x]; + } + points += minorStride; + data += k; + } + points += majorStride - minorStride * minorOrder; + } +} + +void +__glFillMap2d(GLint k, GLint majorOrder, GLint minorOrder, + GLint majorStride, GLint minorStride, + const GLdouble * points, GLdouble * data) +{ + int i, j, x; + + if ((minorStride == k) && (majorStride == minorOrder * k)) { + /* Just copy the data */ + __GLX_MEM_COPY(data, points, majorOrder * majorStride * + __GLX_SIZE_FLOAT64); + return; + } + +#ifdef __GLX_ALIGN64 + x = k * __GLX_SIZE_FLOAT64; +#endif + for (i = 0; i < majorOrder; i++) { + for (j = 0; j < minorOrder; j++) { +#ifdef __GLX_ALIGN64 + __GLX_MEM_COPY(data, points, x); +#else + for (x = 0; x < k; x++) { + data[x] = points[x]; + } +#endif + points += minorStride; + data += k; + } + points += majorStride - minorStride * minorOrder; + } +} diff --git a/src/glx/glcontextmodes.c b/src/glx/glcontextmodes.c new file mode 100644 index 00000000000..232031c2ca8 --- /dev/null +++ b/src/glx/glcontextmodes.c @@ -0,0 +1,544 @@ +/* + * (C) Copyright IBM Corporation 2003 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file glcontextmodes.c + * Utility routines for working with \c __GLcontextModes structures. At + * some point most or all of these functions will be moved to the Mesa + * code base. + * + * \author Ian Romanick + */ + +#if defined(IN_MINI_GLX) +#include +#else +#if defined(HAVE_DIX_CONFIG_H) +# include +#endif +#include +#include +#include "GL/glxint.h" +#endif + +/* Memory macros */ +#if defined(IN_MINI_GLX) +# include +# include +# define _mesa_malloc(b) malloc(b) +# define _mesa_free(m) free(m) +# define _mesa_memset memset +#else +# ifdef XFree86Server +# include +# include +# define _mesa_malloc(b) xalloc(b) +# define _mesa_free(m) xfree(m) +# define _mesa_memset memset +# else +# include +# define _mesa_memset memset +# define _mesa_malloc(b) Xmalloc(b) +# define _mesa_free(m) Xfree(m) +# endif /* XFree86Server */ +#endif /* !defined(IN_MINI_GLX) */ + +#include "glcontextmodes.h" + +#if !defined(IN_MINI_GLX) +#define NUM_VISUAL_TYPES 6 + +/** + * Convert an X visual type to a GLX visual type. + * + * \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.) + * to be converted. + * \return If \c visualType is a valid X visual type, a GLX visual type will + * be returned. Otherwise \c GLX_NONE will be returned. + */ +GLint +_gl_convert_from_x_visual_type(int visualType) +{ + static const int glx_visual_types[NUM_VISUAL_TYPES] = { + GLX_STATIC_GRAY, GLX_GRAY_SCALE, + GLX_STATIC_COLOR, GLX_PSEUDO_COLOR, + GLX_TRUE_COLOR, GLX_DIRECT_COLOR + }; + + return ((unsigned) visualType < NUM_VISUAL_TYPES) + ? glx_visual_types[visualType] : GLX_NONE; +} + + +/** + * Convert a GLX visual type to an X visual type. + * + * \param visualType GLX visual type (i.e., \c GLX_TRUE_COLOR, + * \c GLX_STATIC_GRAY, etc.) to be converted. + * \return If \c visualType is a valid GLX visual type, an X visual type will + * be returned. Otherwise -1 will be returned. + */ +GLint +_gl_convert_to_x_visual_type(int visualType) +{ + static const int x_visual_types[NUM_VISUAL_TYPES] = { + TrueColor, DirectColor, + PseudoColor, StaticColor, + GrayScale, StaticGray + }; + + return ((unsigned) (visualType - GLX_TRUE_COLOR) < NUM_VISUAL_TYPES) + ? x_visual_types[visualType - GLX_TRUE_COLOR] : -1; +} + + +/** + * Copy a GLX visual config structure to a GL context mode structure. All + * of the fields in \c config are copied to \c mode. Additional fields in + * \c mode that can be derrived from the fields of \c config (i.e., + * \c haveDepthBuffer) are also filled in. The remaining fields in \c mode + * that cannot be derived are set to default values. + * + * \param mode Destination GL context mode. + * \param config Source GLX visual config. + * + * \note + * The \c fbconfigID and \c visualID fields of the \c __GLcontextModes + * structure will be set to the \c vid of the \c __GLXvisualConfig structure. + */ +void +_gl_copy_visual_to_context_mode(__GLcontextModes * mode, + const __GLXvisualConfig * config) +{ + __GLcontextModes *const next = mode->next; + + (void) _mesa_memset(mode, 0, sizeof(__GLcontextModes)); + mode->next = next; + + mode->visualID = config->vid; + mode->visualType = _gl_convert_from_x_visual_type(config->class); + mode->xRenderable = GL_TRUE; + mode->fbconfigID = config->vid; + mode->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT; + + mode->rgbMode = (config->rgba != 0); + mode->renderType = (mode->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; + + mode->colorIndexMode = !(mode->rgbMode); + mode->doubleBufferMode = (config->doubleBuffer != 0); + mode->stereoMode = (config->stereo != 0); + + mode->haveAccumBuffer = ((config->accumRedSize + + config->accumGreenSize + + config->accumBlueSize + + config->accumAlphaSize) > 0); + mode->haveDepthBuffer = (config->depthSize > 0); + mode->haveStencilBuffer = (config->stencilSize > 0); + + mode->redBits = config->redSize; + mode->greenBits = config->greenSize; + mode->blueBits = config->blueSize; + mode->alphaBits = config->alphaSize; + mode->redMask = config->redMask; + mode->greenMask = config->greenMask; + mode->blueMask = config->blueMask; + mode->alphaMask = config->alphaMask; + mode->rgbBits = mode->rgbMode ? config->bufferSize : 0; + mode->indexBits = mode->colorIndexMode ? config->bufferSize : 0; + + mode->accumRedBits = config->accumRedSize; + mode->accumGreenBits = config->accumGreenSize; + mode->accumBlueBits = config->accumBlueSize; + mode->accumAlphaBits = config->accumAlphaSize; + mode->depthBits = config->depthSize; + mode->stencilBits = config->stencilSize; + + mode->numAuxBuffers = config->auxBuffers; + mode->level = config->level; + + mode->visualRating = config->visualRating; + mode->transparentPixel = config->transparentPixel; + mode->transparentRed = config->transparentRed; + mode->transparentGreen = config->transparentGreen; + mode->transparentBlue = config->transparentBlue; + mode->transparentAlpha = config->transparentAlpha; + mode->transparentIndex = config->transparentIndex; + mode->samples = config->multiSampleSize; + mode->sampleBuffers = config->nMultiSampleBuffers; + /* mode->visualSelectGroup = config->visualSelectGroup; ? */ + + mode->swapMethod = GLX_SWAP_UNDEFINED_OML; + + mode->bindToTextureRgb = (mode->rgbMode) ? GL_TRUE : GL_FALSE; + mode->bindToTextureRgba = (mode->rgbMode && mode->alphaBits) ? + GL_TRUE : GL_FALSE; + mode->bindToMipmapTexture = mode->rgbMode ? GL_TRUE : GL_FALSE; + mode->bindToTextureTargets = mode->rgbMode ? + GLX_TEXTURE_1D_BIT_EXT | GLX_TEXTURE_2D_BIT_EXT | + GLX_TEXTURE_RECTANGLE_BIT_EXT : 0; + mode->yInverted = GL_FALSE; +} + + +/** + * Get data from a GL context mode. + * + * \param mode GL context mode whose data is to be returned. + * \param attribute Attribute of \c mode that is to be returned. + * \param value_return Location to store the data member of \c mode. + * \return If \c attribute is a valid attribute of \c mode, zero is + * returned. Otherwise \c GLX_BAD_ATTRIBUTE is returned. + */ +int +_gl_get_context_mode_data(const __GLcontextModes * mode, int attribute, + int *value_return) +{ + switch (attribute) { + case GLX_USE_GL: + *value_return = GL_TRUE; + return 0; + case GLX_BUFFER_SIZE: + *value_return = mode->rgbBits; + return 0; + case GLX_RGBA: + *value_return = mode->rgbMode; + return 0; + case GLX_RED_SIZE: + *value_return = mode->redBits; + return 0; + case GLX_GREEN_SIZE: + *value_return = mode->greenBits; + return 0; + case GLX_BLUE_SIZE: + *value_return = mode->blueBits; + return 0; + case GLX_ALPHA_SIZE: + *value_return = mode->alphaBits; + return 0; + case GLX_DOUBLEBUFFER: + *value_return = mode->doubleBufferMode; + return 0; + case GLX_STEREO: + *value_return = mode->stereoMode; + return 0; + case GLX_AUX_BUFFERS: + *value_return = mode->numAuxBuffers; + return 0; + case GLX_DEPTH_SIZE: + *value_return = mode->depthBits; + return 0; + case GLX_STENCIL_SIZE: + *value_return = mode->stencilBits; + return 0; + case GLX_ACCUM_RED_SIZE: + *value_return = mode->accumRedBits; + return 0; + case GLX_ACCUM_GREEN_SIZE: + *value_return = mode->accumGreenBits; + return 0; + case GLX_ACCUM_BLUE_SIZE: + *value_return = mode->accumBlueBits; + return 0; + case GLX_ACCUM_ALPHA_SIZE: + *value_return = mode->accumAlphaBits; + return 0; + case GLX_LEVEL: + *value_return = mode->level; + return 0; + case GLX_TRANSPARENT_TYPE_EXT: + *value_return = mode->transparentPixel; + return 0; + case GLX_TRANSPARENT_RED_VALUE: + *value_return = mode->transparentRed; + return 0; + case GLX_TRANSPARENT_GREEN_VALUE: + *value_return = mode->transparentGreen; + return 0; + case GLX_TRANSPARENT_BLUE_VALUE: + *value_return = mode->transparentBlue; + return 0; + case GLX_TRANSPARENT_ALPHA_VALUE: + *value_return = mode->transparentAlpha; + return 0; + case GLX_TRANSPARENT_INDEX_VALUE: + *value_return = mode->transparentIndex; + return 0; + case GLX_X_VISUAL_TYPE: + *value_return = mode->visualType; + return 0; + case GLX_CONFIG_CAVEAT: + *value_return = mode->visualRating; + return 0; + case GLX_VISUAL_ID: + *value_return = mode->visualID; + return 0; + case GLX_DRAWABLE_TYPE: + *value_return = mode->drawableType; + return 0; + case GLX_RENDER_TYPE: + *value_return = mode->renderType; + return 0; + case GLX_X_RENDERABLE: + *value_return = mode->xRenderable; + return 0; + case GLX_FBCONFIG_ID: + *value_return = mode->fbconfigID; + return 0; + case GLX_MAX_PBUFFER_WIDTH: + *value_return = mode->maxPbufferWidth; + return 0; + case GLX_MAX_PBUFFER_HEIGHT: + *value_return = mode->maxPbufferHeight; + return 0; + case GLX_MAX_PBUFFER_PIXELS: + *value_return = mode->maxPbufferPixels; + return 0; + case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX: + *value_return = mode->optimalPbufferWidth; + return 0; + case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX: + *value_return = mode->optimalPbufferHeight; + return 0; + case GLX_SWAP_METHOD_OML: + *value_return = mode->swapMethod; + return 0; + case GLX_SAMPLE_BUFFERS_SGIS: + *value_return = mode->sampleBuffers; + return 0; + case GLX_SAMPLES_SGIS: + *value_return = mode->samples; + return 0; + case GLX_BIND_TO_TEXTURE_RGB_EXT: + *value_return = mode->bindToTextureRgb; + return 0; + case GLX_BIND_TO_TEXTURE_RGBA_EXT: + *value_return = mode->bindToTextureRgba; + return 0; + case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: + *value_return = mode->bindToMipmapTexture == GL_TRUE ? GL_TRUE : + GL_FALSE; + return 0; + case GLX_BIND_TO_TEXTURE_TARGETS_EXT: + *value_return = mode->bindToTextureTargets; + return 0; + case GLX_Y_INVERTED_EXT: + *value_return = mode->yInverted; + return 0; + + /* Applications are NOT allowed to query GLX_VISUAL_SELECT_GROUP_SGIX. + * It is ONLY for communication between the GLX client and the GLX + * server. + */ + case GLX_VISUAL_SELECT_GROUP_SGIX: + default: + return GLX_BAD_ATTRIBUTE; + } +} +#endif /* !defined(IN_MINI_GLX) */ + + +/** + * Allocate a linked list of \c __GLcontextModes structures. The fields of + * each structure will be initialized to "reasonable" default values. In + * most cases this is the default value defined by table 3.4 of the GLX + * 1.3 specification. This means that most values are either initialized to + * zero or \c GLX_DONT_CARE (which is -1). As support for additional + * extensions is added, the new values will be initialized to appropriate + * values from the extension specification. + * + * \param count Number of structures to allocate. + * \param minimum_size Minimum size of a structure to allocate. This allows + * for differences in the version of the + * \c __GLcontextModes stucture used in libGL and in a + * DRI-based driver. + * \returns A pointer to the first element in a linked list of \c count + * stuctures on success, or \c NULL on failure. + * + * \warning Use of \c minimum_size does \b not guarantee binary compatibility. + * The fundamental assumption is that if the \c minimum_size + * specified by the driver and the size of the \c __GLcontextModes + * structure in libGL is the same, then the meaning of each byte in + * the structure is the same in both places. \b Be \b careful! + * Basically this means that fields have to be added in libGL and + * then propagated to drivers. Drivers should \b never arbitrarilly + * extend the \c __GLcontextModes data-structure. + */ +__GLcontextModes * +_gl_context_modes_create(unsigned count, size_t minimum_size) +{ + const size_t size = (minimum_size > sizeof(__GLcontextModes)) + ? minimum_size : sizeof(__GLcontextModes); + __GLcontextModes *base = NULL; + __GLcontextModes **next; + unsigned i; + + next = &base; + for (i = 0; i < count; i++) { + *next = (__GLcontextModes *) _mesa_malloc(size); + if (*next == NULL) { + _gl_context_modes_destroy(base); + base = NULL; + break; + } + + (void) _mesa_memset(*next, 0, size); + (*next)->visualID = GLX_DONT_CARE; + (*next)->visualType = GLX_DONT_CARE; + (*next)->visualRating = GLX_NONE; + (*next)->transparentPixel = GLX_NONE; + (*next)->transparentRed = GLX_DONT_CARE; + (*next)->transparentGreen = GLX_DONT_CARE; + (*next)->transparentBlue = GLX_DONT_CARE; + (*next)->transparentAlpha = GLX_DONT_CARE; + (*next)->transparentIndex = GLX_DONT_CARE; + (*next)->xRenderable = GLX_DONT_CARE; + (*next)->fbconfigID = GLX_DONT_CARE; + (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML; + (*next)->bindToTextureRgb = GLX_DONT_CARE; + (*next)->bindToTextureRgba = GLX_DONT_CARE; + (*next)->bindToMipmapTexture = GLX_DONT_CARE; + (*next)->bindToTextureTargets = GLX_DONT_CARE; + (*next)->yInverted = GLX_DONT_CARE; + + next = &((*next)->next); + } + + return base; +} + + +/** + * Destroy a linked list of \c __GLcontextModes structures created by + * \c _gl_context_modes_create. + * + * \param modes Linked list of structures to be destroyed. All structres + * in the list will be freed. + */ +void +_gl_context_modes_destroy(__GLcontextModes * modes) +{ + while (modes != NULL) { + __GLcontextModes *const next = modes->next; + + _mesa_free(modes); + modes = next; + } +} + + +/** + * Find a context mode matching a Visual ID. + * + * \param modes List list of context-mode structures to be searched. + * \param vid Visual ID to be found. + * \returns A pointer to a context-mode in \c modes if \c vid was found in + * the list, or \c NULL if it was not. + */ + +__GLcontextModes * +_gl_context_modes_find_visual(__GLcontextModes * modes, int vid) +{ + __GLcontextModes *m; + + for (m = modes; m != NULL; m = m->next) + if (m->visualID == vid) + return m; + + return NULL; +} + +__GLcontextModes * +_gl_context_modes_find_fbconfig(__GLcontextModes * modes, int fbid) +{ + __GLcontextModes *m; + + for (m = modes; m != NULL; m = m->next) + if (m->fbconfigID == fbid) + return m; + + return NULL; +} + +/** + * Determine if two context-modes are the same. This is intended to be used + * by libGL implementations to compare to sets of driver generated FBconfigs. + * + * \param a Context-mode to be compared. + * \param b Context-mode to be compared. + * \returns \c GL_TRUE if the two context-modes are the same. \c GL_FALSE is + * returned otherwise. + */ +GLboolean +_gl_context_modes_are_same(const __GLcontextModes * a, + const __GLcontextModes * b) +{ + return ((a->rgbMode == b->rgbMode) && + (a->floatMode == b->floatMode) && + (a->colorIndexMode == b->colorIndexMode) && + (a->doubleBufferMode == b->doubleBufferMode) && + (a->stereoMode == b->stereoMode) && + (a->redBits == b->redBits) && + (a->greenBits == b->greenBits) && + (a->blueBits == b->blueBits) && (a->alphaBits == b->alphaBits) && +#if 0 /* For some reason these don't get set on the client-side in libGL. */ + (a->redMask == b->redMask) && + (a->greenMask == b->greenMask) && + (a->blueMask == b->blueMask) && (a->alphaMask == b->alphaMask) && +#endif + (a->rgbBits == b->rgbBits) && + (a->indexBits == b->indexBits) && + (a->accumRedBits == b->accumRedBits) && + (a->accumGreenBits == b->accumGreenBits) && + (a->accumBlueBits == b->accumBlueBits) && + (a->accumAlphaBits == b->accumAlphaBits) && + (a->depthBits == b->depthBits) && + (a->stencilBits == b->stencilBits) && + (a->numAuxBuffers == b->numAuxBuffers) && + (a->level == b->level) && + (a->pixmapMode == b->pixmapMode) && + (a->visualRating == b->visualRating) && + (a->transparentPixel == b->transparentPixel) && + ((a->transparentPixel != GLX_TRANSPARENT_RGB) || + ((a->transparentRed == b->transparentRed) && + (a->transparentGreen == b->transparentGreen) && + (a->transparentBlue == b->transparentBlue) && + (a->transparentAlpha == b->transparentAlpha))) && + ((a->transparentPixel != GLX_TRANSPARENT_INDEX) || + (a->transparentIndex == b->transparentIndex)) && + (a->sampleBuffers == b->sampleBuffers) && + (a->samples == b->samples) && + ((a->drawableType & b->drawableType) != 0) && + (a->renderType == b->renderType) && + (a->maxPbufferWidth == b->maxPbufferWidth) && + (a->maxPbufferHeight == b->maxPbufferHeight) && + (a->maxPbufferPixels == b->maxPbufferPixels) && + (a->optimalPbufferWidth == b->optimalPbufferWidth) && + (a->optimalPbufferHeight == b->optimalPbufferHeight) && + (a->swapMethod == b->swapMethod) && + (a->bindToTextureRgb == b->bindToTextureRgb) && + (a->bindToTextureRgba == b->bindToTextureRgba) && + (a->bindToMipmapTexture == b->bindToMipmapTexture) && + (a->bindToTextureTargets == b->bindToTextureTargets) && + (a->yInverted == b->yInverted)); +} diff --git a/src/glx/glcontextmodes.h b/src/glx/glcontextmodes.h new file mode 100644 index 00000000000..6676ae306c2 --- /dev/null +++ b/src/glx/glcontextmodes.h @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corporation 2003 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file glcontextmodes.h + * \author Ian Romanick + */ + +#ifndef GLCONTEXTMODES_H +#define GLCONTEXTMODES_H + +#include "GL/internal/glcore.h" + +#if !defined(IN_MINI_GLX) +extern GLint _gl_convert_from_x_visual_type(int visualType); +extern GLint _gl_convert_to_x_visual_type(int visualType); +extern void _gl_copy_visual_to_context_mode(__GLcontextModes * mode, + const __GLXvisualConfig * config); +extern int _gl_get_context_mode_data(const __GLcontextModes * mode, + int attribute, int *value_return); +#endif /* !defined(IN_MINI_GLX) */ + +extern __GLcontextModes *_gl_context_modes_create(unsigned count, + size_t minimum_size); +extern void _gl_context_modes_destroy(__GLcontextModes * modes); +extern __GLcontextModes *_gl_context_modes_find_visual(__GLcontextModes * + modes, int vid); +extern __GLcontextModes *_gl_context_modes_find_fbconfig(__GLcontextModes * + modes, int fbid); +extern GLboolean _gl_context_modes_are_same(const __GLcontextModes * a, + const __GLcontextModes * b); + +#endif /* GLCONTEXTMODES_H */ diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c new file mode 100644 index 00000000000..a0a02238b00 --- /dev/null +++ b/src/glx/glx_pbuffer.c @@ -0,0 +1,724 @@ +/* + * (C) Copyright IBM Corporation 2004 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file glx_pbuffer.c + * Implementation of pbuffer related functions. + * + * \author Ian Romanick + */ + +#include +#include "glxclient.h" +#include +#include +#include +#include +#include "glxextensions.h" + +#define WARN_ONCE_GLX_1_3(a, b) { \ + static int warned=1; \ + if(warned) { \ + warn_GLX_1_3((a), b ); \ + warned=0; \ + } \ + } + +/** + * Emit a warning when clients use GLX 1.3 functions on pre-1.3 systems. + */ +static void +warn_GLX_1_3(Display *dpy, const char *function_name) +{ + __GLXdisplayPrivate *priv = __glXInitialize(dpy); + + if (priv->minorVersion < 3) { + fprintf(stderr, + "WARNING: Application calling GLX 1.3 function \"%s\" " + "when GLX 1.3 is not supported! This is an application bug!\n", + function_name); + } +} + + +/** + * Change a drawable's attribute. + * + * This function is used to implement \c glXSelectEvent and + * \c glXSelectEventSGIX. + * + * \note + * This function dynamically determines whether to use the SGIX_pbuffer + * version of the protocol or the GLX 1.3 version of the protocol. + * + * \todo + * This function needs to be modified to work with direct-rendering drivers. + */ +static void +ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable, + const CARD32 * attribs, size_t num_attribs) +{ + __GLXdisplayPrivate *priv = __glXInitialize(dpy); + CARD32 *output; + CARD8 opcode; + + if ((dpy == NULL) || (drawable == 0)) { + return; + } + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return; + + LockDisplay(dpy); + + if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { + xGLXChangeDrawableAttributesReq *req; + + GetReqExtra(GLXChangeDrawableAttributes, 8 + (8 * num_attribs), req); + output = (CARD32 *) (req + 1); + + req->reqType = opcode; + req->glxCode = X_GLXChangeDrawableAttributes; + req->drawable = drawable; + req->numAttribs = (CARD32) num_attribs; + } + else { + xGLXVendorPrivateWithReplyReq *vpreq; + + GetReqExtra(GLXVendorPrivateWithReply, 4 + (8 * num_attribs), vpreq); + output = (CARD32 *) (vpreq + 1); + + vpreq->reqType = opcode; + vpreq->glxCode = X_GLXVendorPrivateWithReply; + vpreq->vendorCode = X_GLXvop_ChangeDrawableAttributesSGIX; + + output[0] = (CARD32) drawable; + output++; + } + + (void) memcpy(output, attribs, sizeof(CARD32) * 2 * num_attribs); + + UnlockDisplay(dpy); + SyncHandle(); + + return; +} + + +/** + * Destroy a pbuffer. + * + * This function is used to implement \c glXDestroyPbuffer and + * \c glXDestroyGLXPbufferSGIX. + * + * \note + * This function dynamically determines whether to use the SGIX_pbuffer + * version of the protocol or the GLX 1.3 version of the protocol. + * + * \todo + * This function needs to be modified to work with direct-rendering drivers. + */ +static void +DestroyPbuffer(Display * dpy, GLXDrawable drawable) +{ + __GLXdisplayPrivate *priv = __glXInitialize(dpy); + CARD8 opcode; + + if ((dpy == NULL) || (drawable == 0)) { + return; + } + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return; + + LockDisplay(dpy); + + if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { + xGLXDestroyPbufferReq *req; + + GetReq(GLXDestroyPbuffer, req); + req->reqType = opcode; + req->glxCode = X_GLXDestroyPbuffer; + req->pbuffer = (GLXPbuffer) drawable; + } + else { + xGLXVendorPrivateWithReplyReq *vpreq; + CARD32 *data; + + GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq); + data = (CARD32 *) (vpreq + 1); + + data[0] = (CARD32) drawable; + + vpreq->reqType = opcode; + vpreq->glxCode = X_GLXVendorPrivateWithReply; + vpreq->vendorCode = X_GLXvop_DestroyGLXPbufferSGIX; + } + + UnlockDisplay(dpy); + SyncHandle(); + + return; +} + + +#ifdef GLX_DIRECT_RENDERING +extern __GLXDRIdrawable *GetGLXDRIDrawable(Display * dpy, + GLXDrawable drawable, + int *const scrn_num); + +static GLenum +determineTextureTarget(const int *attribs, int numAttribs) +{ + GLenum target = 0; + int i; + + for (i = 0; i < numAttribs; i++) { + if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) { + switch (attribs[2 * i + 1]) { + case GLX_TEXTURE_2D_EXT: + target = GL_TEXTURE_2D; + break; + case GLX_TEXTURE_RECTANGLE_EXT: + target = GL_TEXTURE_RECTANGLE_ARB; + break; + } + } + } + + return target; +} + + +static GLenum +determineTextureFormat(const int *attribs, int numAttribs) +{ + int i; + + for (i = 0; i < numAttribs; i++) { + if (attribs[2 * i] == GLX_TEXTURE_FORMAT_EXT) + return attribs[2 * i + 1]; + } + + return 0; +} +#endif + +/** + * Get a drawable's attribute. + * + * This function is used to implement \c glXGetSelectedEvent and + * \c glXGetSelectedEventSGIX. + * + * \note + * This function dynamically determines whether to use the SGIX_pbuffer + * version of the protocol or the GLX 1.3 version of the protocol. + * + * \todo + * The number of attributes returned is likely to be small, probably less than + * 10. Given that, this routine should try to use an array on the stack to + * capture the reply rather than always calling Xmalloc. + * + * \todo + * This function needs to be modified to work with direct-rendering drivers. + */ +static int +GetDrawableAttribute(Display * dpy, GLXDrawable drawable, + int attribute, unsigned int *value) +{ + __GLXdisplayPrivate *priv; + xGLXGetDrawableAttributesReply reply; + CARD32 *data; + CARD8 opcode; + unsigned int length; + unsigned int i; + unsigned int num_attributes; + GLboolean use_glx_1_3; + + if ((dpy == NULL) || (drawable == 0)) { + return 0; + } + + priv = __glXInitialize(dpy); + use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3)); + + *value = 0; + + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return 0; + + LockDisplay(dpy); + + if (use_glx_1_3) { + xGLXGetDrawableAttributesReq *req; + + GetReqExtra(GLXGetDrawableAttributes, 4, req); + req->reqType = opcode; + req->glxCode = X_GLXGetDrawableAttributes; + req->drawable = drawable; + } + else { + xGLXVendorPrivateWithReplyReq *vpreq; + + GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq); + data = (CARD32 *) (vpreq + 1); + data[0] = (CARD32) drawable; + + vpreq->reqType = opcode; + vpreq->glxCode = X_GLXVendorPrivateWithReply; + vpreq->vendorCode = X_GLXvop_GetDrawableAttributesSGIX; + } + + _XReply(dpy, (xReply *) & reply, 0, False); + + if (reply.type == X_Error) { + UnlockDisplay(dpy); + SyncHandle(); + return 0; + } + + length = reply.length; + if (length) { + num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2; + data = (CARD32 *) Xmalloc(length * sizeof(CARD32)); + if (data == NULL) { + /* Throw data on the floor */ + _XEatData(dpy, length); + } + else { + _XRead(dpy, (char *) data, length * sizeof(CARD32)); + + /* Search the set of returned attributes for the attribute requested by + * the caller. + */ + for (i = 0; i < num_attributes; i++) { + if (data[i * 2] == attribute) { + *value = data[(i * 2) + 1]; + break; + } + } + +#ifdef GLX_DIRECT_RENDERING + { + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); + + if (pdraw != NULL && !pdraw->textureTarget) + pdraw->textureTarget = + determineTextureTarget((const int *) data, num_attributes); + if (pdraw != NULL && !pdraw->textureFormat) + pdraw->textureFormat = + determineTextureFormat((const int *) data, num_attributes); + } +#endif + + Xfree(data); + } + } + + UnlockDisplay(dpy); + SyncHandle(); + + return 0; +} + +/** + * Create a non-pbuffer GLX drawable. + * + * \todo + * This function needs to be modified to work with direct-rendering drivers. + */ +static GLXDrawable +CreateDrawable(Display * dpy, const __GLcontextModes * fbconfig, + Drawable drawable, const int *attrib_list, CARD8 glxCode) +{ + xGLXCreateWindowReq *req; + CARD32 *data; + unsigned int i; + CARD8 opcode; + + i = 0; + if (attrib_list) { + while (attrib_list[i * 2] != None) + i++; + } + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return None; + + LockDisplay(dpy); + GetReqExtra(GLXCreateWindow, 8 * i, req); + data = (CARD32 *) (req + 1); + + req->reqType = opcode; + req->glxCode = glxCode; + req->screen = (CARD32) fbconfig->screen; + req->fbconfig = fbconfig->fbconfigID; + req->window = (CARD32) drawable; + req->glxwindow = (GLXWindow) XAllocID(dpy); + req->numAttribs = (CARD32) i; + + memcpy(data, attrib_list, 8 * i); + + UnlockDisplay(dpy); + SyncHandle(); + +#ifdef GLX_DIRECT_RENDERING + do { + /* FIXME: Maybe delay __DRIdrawable creation until the drawable + * is actually bound to a context... */ + + __GLXdisplayPrivate *const priv = __glXInitialize(dpy); + __GLXDRIdrawable *pdraw; + __GLXscreenConfigs *psc; + + psc = &priv->screenConfigs[fbconfig->screen]; + if (psc->driScreen == NULL) + break; + pdraw = psc->driScreen->createDrawable(psc, drawable, + req->glxwindow, fbconfig); + if (pdraw == NULL) { + fprintf(stderr, "failed to create drawable\n"); + break; + } + + if (__glxHashInsert(psc->drawHash, req->glxwindow, pdraw)) { + (*pdraw->destroyDrawable) (pdraw); + return None; /* FIXME: Check what we're supposed to do here... */ + } + + pdraw->textureTarget = determineTextureTarget(attrib_list, i); + pdraw->textureFormat = determineTextureFormat(attrib_list, i); + } while (0); +#endif + + return (GLXDrawable) req->glxwindow; +} + + +/** + * Destroy a non-pbuffer GLX drawable. + * + * \todo + * This function needs to be modified to work with direct-rendering drivers. + */ +static void +DestroyDrawable(Display * dpy, GLXDrawable drawable, CARD32 glxCode) +{ + xGLXDestroyPbufferReq *req; + CARD8 opcode; + + if ((dpy == NULL) || (drawable == 0)) { + return; + } + + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return; + + LockDisplay(dpy); + + GetReqExtra(GLXDestroyPbuffer, 4, req); + req->reqType = opcode; + req->glxCode = glxCode; + req->pbuffer = (GLXPbuffer) drawable; + + UnlockDisplay(dpy); + SyncHandle(); + +#ifdef GLX_DIRECT_RENDERING + { + int screen; + __GLXdisplayPrivate *const priv = __glXInitialize(dpy); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); + __GLXscreenConfigs *psc = &priv->screenConfigs[screen]; + + if (pdraw != NULL) { + (*pdraw->destroyDrawable) (pdraw); + __glxHashDelete(psc->drawHash, drawable); + } + } +#endif + + return; +} + + +/** + * Create a pbuffer. + * + * This function is used to implement \c glXCreatePbuffer and + * \c glXCreateGLXPbufferSGIX. + * + * \note + * This function dynamically determines whether to use the SGIX_pbuffer + * version of the protocol or the GLX 1.3 version of the protocol. + * + * \todo + * This function needs to be modified to work with direct-rendering drivers. + */ +static GLXDrawable +CreatePbuffer(Display * dpy, const __GLcontextModes * fbconfig, + unsigned int width, unsigned int height, + const int *attrib_list, GLboolean size_in_attribs) +{ + __GLXdisplayPrivate *priv = __glXInitialize(dpy); + GLXDrawable id = 0; + CARD32 *data; + CARD8 opcode; + unsigned int i; + + i = 0; + if (attrib_list) { + while (attrib_list[i * 2]) + i++; + } + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return None; + + LockDisplay(dpy); + id = XAllocID(dpy); + + if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { + xGLXCreatePbufferReq *req; + unsigned int extra = (size_in_attribs) ? 0 : 2; + + GetReqExtra(GLXCreatePbuffer, (8 * (i + extra)), req); + data = (CARD32 *) (req + 1); + + req->reqType = opcode; + req->glxCode = X_GLXCreatePbuffer; + req->screen = (CARD32) fbconfig->screen; + req->fbconfig = fbconfig->fbconfigID; + req->pbuffer = (GLXPbuffer) id; + req->numAttribs = (CARD32) (i + extra); + + if (!size_in_attribs) { + data[(2 * i) + 0] = GLX_PBUFFER_WIDTH; + data[(2 * i) + 1] = width; + data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT; + data[(2 * i) + 3] = height; + data += 4; + } + } + else { + xGLXVendorPrivateReq *vpreq; + + GetReqExtra(GLXVendorPrivate, 20 + (8 * i), vpreq); + data = (CARD32 *) (vpreq + 1); + + vpreq->reqType = opcode; + vpreq->glxCode = X_GLXVendorPrivate; + vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX; + + data[0] = (CARD32) fbconfig->screen; + data[1] = (CARD32) fbconfig->fbconfigID; + data[2] = (CARD32) id; + data[3] = (CARD32) width; + data[4] = (CARD32) height; + data += 5; + } + + (void) memcpy(data, attrib_list, sizeof(CARD32) * 2 * i); + + UnlockDisplay(dpy); + SyncHandle(); + + return id; +} + + +/** + * Create a new pbuffer. + */ +PUBLIC GLXPbufferSGIX +glXCreateGLXPbufferSGIX(Display * dpy, GLXFBConfigSGIX config, + unsigned int width, unsigned int height, + int *attrib_list) +{ + return (GLXPbufferSGIX) CreatePbuffer(dpy, (__GLcontextModes *) config, + width, height, + attrib_list, GL_FALSE); +} + + +/** + * Create a new pbuffer. + */ +PUBLIC GLXPbuffer +glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int *attrib_list) +{ + int i, width, height; + + width = 0; + height = 0; + + WARN_ONCE_GLX_1_3(dpy, __func__); + + for (i = 0; attrib_list[i * 2]; i++) { + switch (attrib_list[i * 2]) { + case GLX_PBUFFER_WIDTH: + width = attrib_list[i * 2 + 1]; + break; + case GLX_PBUFFER_HEIGHT: + height = attrib_list[i * 2 + 1]; + break; + } + } + + return (GLXPbuffer) CreatePbuffer(dpy, (__GLcontextModes *) config, + width, height, attrib_list, GL_TRUE); +} + + +/** + * Destroy an existing pbuffer. + */ +PUBLIC void +glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf) +{ + DestroyPbuffer(dpy, pbuf); +} + + +/** + * Query an attribute of a drawable. + */ +PUBLIC void +glXQueryDrawable(Display * dpy, GLXDrawable drawable, + int attribute, unsigned int *value) +{ + WARN_ONCE_GLX_1_3(dpy, __func__); + GetDrawableAttribute(dpy, drawable, attribute, value); +} + + +/** + * Query an attribute of a pbuffer. + */ +PUBLIC int +glXQueryGLXPbufferSGIX(Display * dpy, GLXPbufferSGIX drawable, + int attribute, unsigned int *value) +{ + return GetDrawableAttribute(dpy, drawable, attribute, value); +} + + +/** + * Select the event mask for a drawable. + */ +PUBLIC void +glXSelectEvent(Display * dpy, GLXDrawable drawable, unsigned long mask) +{ + CARD32 attribs[2]; + + attribs[0] = (CARD32) GLX_EVENT_MASK; + attribs[1] = (CARD32) mask; + + ChangeDrawableAttribute(dpy, drawable, attribs, 1); +} + + +/** + * Get the selected event mask for a drawable. + */ +PUBLIC void +glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask) +{ + unsigned int value; + + + /* The non-sense with value is required because on LP64 platforms + * sizeof(unsigned int) != sizeof(unsigned long). On little-endian + * we could just type-cast the pointer, but why? + */ + + GetDrawableAttribute(dpy, drawable, GLX_EVENT_MASK_SGIX, &value); + *mask = value; +} + + +PUBLIC GLXPixmap +glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap, + const int *attrib_list) +{ + WARN_ONCE_GLX_1_3(dpy, __func__); + + return CreateDrawable(dpy, (__GLcontextModes *) config, + (Drawable) pixmap, attrib_list, X_GLXCreatePixmap); +} + + +PUBLIC GLXWindow +glXCreateWindow(Display * dpy, GLXFBConfig config, Window win, + const int *attrib_list) +{ + WARN_ONCE_GLX_1_3(dpy, __func__); + + return CreateDrawable(dpy, (__GLcontextModes *) config, + (Drawable) win, attrib_list, X_GLXCreateWindow); +} + + +PUBLIC void +glXDestroyPixmap(Display * dpy, GLXPixmap pixmap) +{ + WARN_ONCE_GLX_1_3(dpy, __func__); + + DestroyDrawable(dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap); +} + + +PUBLIC void +glXDestroyWindow(Display * dpy, GLXWindow win) +{ + WARN_ONCE_GLX_1_3(dpy, __func__); + + DestroyDrawable(dpy, (GLXDrawable) win, X_GLXDestroyWindow); +} + + +PUBLIC +GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX, + (Display * dpy, GLXPbufferSGIX pbuf), + (dpy, pbuf), glXDestroyPbuffer) + +PUBLIC +GLX_ALIAS_VOID(glXSelectEventSGIX, + (Display * dpy, GLXDrawable drawable, + unsigned long mask), (dpy, drawable, mask), glXSelectEvent) + +PUBLIC +GLX_ALIAS_VOID(glXGetSelectedEventSGIX, + (Display * dpy, GLXDrawable drawable, + unsigned long *mask), (dpy, drawable, mask), + glXGetSelectedEvent) + diff --git a/src/glx/glx_query.c b/src/glx/glx_query.c new file mode 100644 index 00000000000..efad13d376e --- /dev/null +++ b/src/glx/glx_query.c @@ -0,0 +1,177 @@ +/* + * (C) Copyright IBM Corporation 2004 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file glx_query.c + * Generic utility functions to query internal data from the server. + * + * \author Ian Romanick + */ + +#include "glxclient.h" + +#if defined(USE_XCB) +# include +# include +# include +#endif + +#ifdef USE_XCB + +/** + * Exchange a protocol request for glXQueryServerString. + */ +char * +__glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name) +{ + xcb_connection_t *c = XGetXCBConnection(dpy); + xcb_glx_query_server_string_reply_t *reply = + xcb_glx_query_server_string_reply(c, + xcb_glx_query_server_string(c, + screen, + name), + NULL); + + /* The spec doesn't mention this, but the Xorg server replies with + * a string already terminated with '\0'. */ + uint32_t len = xcb_glx_query_server_string_string_length(reply); + char *buf = Xmalloc(len); + memcpy(buf, xcb_glx_query_server_string_string(reply), len); + free(reply); + + return buf; +} + +/** + * Exchange a protocol request for glGetString. + */ +char * +__glXGetString(Display * dpy, int opcode, CARD32 contextTag, CARD32 name) +{ + xcb_connection_t *c = XGetXCBConnection(dpy); + xcb_glx_get_string_reply_t *reply = xcb_glx_get_string_reply(c, + xcb_glx_get_string + (c, + contextTag, + name), + NULL); + + /* The spec doesn't mention this, but the Xorg server replies with + * a string already terminated with '\0'. */ + uint32_t len = xcb_glx_get_string_string_length(reply); + char *buf = Xmalloc(len); + memcpy(buf, xcb_glx_get_string_string(reply), len); + free(reply); + + return buf; +} + +#else + +/** + * GLX protocol structure for the ficticious "GXLGenericGetString" request. + * + * This is a non-existant protocol packet. It just so happens that all of + * the real protocol packets used to request a string from the server have + * an identical binary layout. The only difference between them is the + * meaning of the \c for_whom field and the value of the \c glxCode. + */ +typedef struct GLXGenericGetString +{ + CARD8 reqType; + CARD8 glxCode; + CARD16 length B16; + CARD32 for_whom B32; + CARD32 name B32; +} xGLXGenericGetStringReq; + +/* These defines are only needed to make the GetReq macro happy. + */ +#define sz_xGLXGenericGetStringReq 12 +#define X_GLXGenericGetString 0 + +/** + * Query the Server GLX string. + * This routine will allocate the necessay space for the string. + */ +static char * +__glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode, + CARD32 for_whom, CARD32 name) +{ + xGLXGenericGetStringReq *req; + xGLXSingleReply reply; + int length; + int numbytes; + char *buf; + + + LockDisplay(dpy); + + + /* All of the GLX protocol requests for getting a string from the server + * look the same. The exact meaning of the for_whom field is usually + * either the screen number (for glXQueryServerString) or the context tag + * (for GLXSingle). + */ + + GetReq(GLXGenericGetString, req); + req->reqType = opcode; + req->glxCode = glxCode; + req->for_whom = for_whom; + req->name = name; + + _XReply(dpy, (xReply *) & reply, 0, False); + + length = reply.length * 4; + numbytes = reply.size; + + buf = (char *) Xmalloc(numbytes); + if (buf != NULL) { + _XRead(dpy, buf, numbytes); + length -= numbytes; + } + + _XEatData(dpy, length); + + UnlockDisplay(dpy); + SyncHandle(); + + return buf; +} + +char * +__glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name) +{ + return __glXGetStringFromServer(dpy, opcode, + X_GLXQueryServerString, screen, name); +} + +char * +__glXGetString(Display * dpy, int opcode, CARD32 contextTag, CARD32 name) +{ + return __glXGetStringFromServer(dpy, opcode, X_GLsop_GetString, + contextTag, name); +} + +#endif /* USE_XCB */ diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h new file mode 100644 index 00000000000..e0b286b6883 --- /dev/null +++ b/src/glx/glxclient.h @@ -0,0 +1,803 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +/** + * \file glxclient.h + * Direct rendering support added by Precision Insight, Inc. + * + * \author Kevin E. Martin + */ + +#ifndef _GLX_client_h_ +#define _GLX_client_h_ +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#include +#define GLX_GLXEXT_PROTOTYPES +#include +#include +#include +#include +#include +#ifdef WIN32 +#include +#endif +#include "GL/glxint.h" +#include "GL/glxproto.h" +#include "GL/internal/glcore.h" +#include "glapi/glapitable.h" +#include "glxhash.h" +#if defined( PTHREADS ) +# include +#endif + +#include "glxextensions.h" + + +/* If we build the library with gcc's -fvisibility=hidden flag, we'll + * use the PUBLIC macro to mark functions that are to be exported. + * + * We also need to define a USED attribute, so the optimizer doesn't + * inline a static function that we later use in an alias. - ajax + */ +#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 +# define PUBLIC __attribute__((visibility("default"))) +# define USED __attribute__((used)) +#else +# define PUBLIC +# define USED +#endif + + + +#define GLX_MAJOR_VERSION 1 /* current version numbers */ +#define GLX_MINOR_VERSION 4 + +#define __GLX_MAX_TEXTURE_UNITS 32 + +typedef struct __GLXscreenConfigsRec __GLXscreenConfigs; +typedef struct __GLXcontextRec __GLXcontext; +typedef struct __GLXdrawableRec __GLXdrawable; +typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate; +typedef struct _glapi_table __GLapi; + +/************************************************************************/ + +#ifdef GLX_DIRECT_RENDERING + +#define containerOf(ptr, type, member) \ + (type *)( (char *)ptr - offsetof(type,member) ) + +#include + + +/** + * Display dependent methods. This structure is initialized during the + * \c driCreateDisplay call. + */ +typedef struct __GLXDRIdisplayRec __GLXDRIdisplay; +typedef struct __GLXDRIscreenRec __GLXDRIscreen; +typedef struct __GLXDRIdrawableRec __GLXDRIdrawable; +typedef struct __GLXDRIcontextRec __GLXDRIcontext; + +#include "glxextensions.h" + +struct __GLXDRIdisplayRec +{ + /** + * Method to destroy the private DRI display data. + */ + void (*destroyDisplay) (__GLXDRIdisplay * display); + + __GLXDRIscreen *(*createScreen) (__GLXscreenConfigs * psc, int screen, + __GLXdisplayPrivate * priv); +}; + +struct __GLXDRIscreenRec { + + void (*destroyScreen)(__GLXscreenConfigs *psc); + + __GLXDRIcontext *(*createContext)(__GLXscreenConfigs *psc, + const __GLcontextModes *mode, + GLXContext gc, + GLXContext shareList, int renderType); + + __GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc, + XID drawable, + GLXDrawable glxDrawable, + const __GLcontextModes *modes); + + int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc, + int64_t divisor, int64_t remainder); + void (*copySubBuffer)(__GLXDRIdrawable *pdraw, + int x, int y, int width, int height); + void (*waitX)(__GLXDRIdrawable *pdraw); + void (*waitGL)(__GLXDRIdrawable *pdraw); + int (*getDrawableMSC)(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw, + int64_t *ust, int64_t *msc, int64_t *sbc); + int (*waitForMSC)(__GLXDRIdrawable *pdraw, int64_t target_msc, + int64_t divisor, int64_t remainder, int64_t *ust, + int64_t *msc, int64_t *sbc); + int (*waitForSBC)(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust, + int64_t *msc, int64_t *sbc); + void (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval); + int (*getSwapInterval)(__GLXDRIdrawable *pdraw); +}; + +struct __GLXDRIcontextRec +{ + void (*destroyContext) (__GLXDRIcontext * context, + __GLXscreenConfigs * psc, Display * dpy); + Bool(*bindContext) (__GLXDRIcontext * context, __GLXDRIdrawable * pdraw, + __GLXDRIdrawable * pread); + + void (*unbindContext) (__GLXDRIcontext * context); +}; + +struct __GLXDRIdrawableRec +{ + void (*destroyDrawable) (__GLXDRIdrawable * drawable); + + XID xDrawable; + XID drawable; + __GLXscreenConfigs *psc; + GLenum textureTarget; + __DRIdrawable *driDrawable; + GLenum textureFormat; /* EXT_texture_from_pixmap support */ +}; + +/* +** Function to create and DRI display data and initialize the display +** dependent methods. +*/ +extern __GLXDRIdisplay *driswCreateDisplay(Display * dpy); +extern __GLXDRIdisplay *driCreateDisplay(Display * dpy); +extern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy); + +extern void DRI_glXUseXFont(Font font, int first, int count, int listbase); + +/* +** Functions to obtain driver configuration information from a direct +** rendering client application +*/ +extern const char *glXGetScreenDriver(Display * dpy, int scrNum); + +extern const char *glXGetDriverConfig(const char *driverName); + +#endif + +/************************************************************************/ + +#define __GL_CLIENT_ATTRIB_STACK_DEPTH 16 + +typedef struct __GLXpixelStoreModeRec +{ + GLboolean swapEndian; + GLboolean lsbFirst; + GLuint rowLength; + GLuint imageHeight; + GLuint imageDepth; + GLuint skipRows; + GLuint skipPixels; + GLuint skipImages; + GLuint alignment; +} __GLXpixelStoreMode; + + +typedef struct __GLXattributeRec +{ + GLuint mask; + + /** + * Pixel storage state. Most of the pixel store mode state is kept + * here and used by the client code to manage the packing and + * unpacking of data sent to/received from the server. + */ + __GLXpixelStoreMode storePack, storeUnpack; + + /** + * Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically + * disabled? + */ + GLboolean NoDrawArraysProtocol; + + /** + * Vertex Array storage state. The vertex array component + * state is stored here and is used to manage the packing of + * DrawArrays data sent to the server. + */ + struct array_state_vector *array_state; +} __GLXattribute; + +typedef struct __GLXattributeMachineRec +{ + __GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; + __GLXattribute **stackPointer; +} __GLXattributeMachine; + +/** + * GLX state that needs to be kept on the client. One of these records + * exist for each context that has been made current by this client. + */ +struct __GLXcontextRec +{ + /** + * \name Drawing command buffer. + * + * Drawing commands are packed into this buffer before being sent as a + * single GLX protocol request. The buffer is sent when it overflows or + * is flushed by \c __glXFlushRenderBuffer. \c pc is the next location + * in the buffer to be filled. \c limit is described above in the buffer + * slop discussion. + * + * Commands that require large amounts of data to be transfered will + * also use this buffer to hold a header that describes the large + * command. + * + * These must be the first 6 fields since they are static initialized + * in the dummy context in glxext.c + */ + /*@{ */ + GLubyte *buf; + GLubyte *pc; + GLubyte *limit; + GLubyte *bufEnd; + GLint bufSize; + /*@} */ + + /** + * The XID of this rendering context. When the context is created a + * new XID is allocated. This is set to None when the context is + * destroyed but is still current to some thread. In this case the + * context will be freed on next MakeCurrent. + */ + XID xid; + + /** + * The XID of the \c shareList context. + */ + XID share_xid; + + /** + * Screen number. + */ + GLint screen; + __GLXscreenConfigs *psc; + + /** + * \c GL_TRUE if the context was created with ImportContext, which + * means the server-side context was created by another X client. + */ + GLboolean imported; + + /** + * The context tag returned by MakeCurrent when this context is made + * current. This tag is used to identify the context that a thread has + * current so that proper server context management can be done. It is + * used for all context specific commands (i.e., \c Render, \c RenderLarge, + * \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old + * context)). + */ + GLXContextTag currentContextTag; + + /** + * \name Rendering mode + * + * The rendering mode is kept on the client as well as the server. + * When \c glRenderMode is called, the buffer associated with the + * previous rendering mode (feedback or select) is filled. + */ + /*@{ */ + GLenum renderMode; + GLfloat *feedbackBuf; + GLuint *selectBuf; + /*@} */ + + /** + * This is \c GL_TRUE if the pixel unpack modes are such that an image + * can be unpacked from the clients memory by just copying. It may + * still be true that the server will have to do some work. This + * just promises that a straight copy will fetch the correct bytes. + */ + GLboolean fastImageUnpack; + + /** + * Fill newImage with the unpacked form of \c oldImage getting it + * ready for transport to the server. + */ + void (*fillImage) (__GLXcontext *, GLint, GLint, GLint, GLint, GLenum, + GLenum, const GLvoid *, GLubyte *, GLubyte *); + + /** + * Client side attribs. + */ + __GLXattributeMachine attributes; + + /** + * Client side error code. This is set when client side gl API + * routines need to set an error because of a bad enumerant or + * running out of memory, etc. + */ + GLenum error; + + /** + * Whether this context does direct rendering. + */ + Bool isDirect; + + /** + * \c dpy of current display for this context. Will be \c NULL if not + * current to any display, or if this is the "dummy context". + */ + Display *currentDpy; + + /** + * The current drawable for this context. Will be None if this + * context is not current to any drawable. currentReadable is below. + */ + GLXDrawable currentDrawable; + + /** + * \name GL Constant Strings + * + * Constant strings that describe the server implementation + * These pertain to GL attributes, not to be confused with + * GLX versioning attributes. + */ + /*@{ */ + GLubyte *vendor; + GLubyte *renderer; + GLubyte *version; + GLubyte *extensions; + /*@} */ + + /** + * Record the dpy this context was created on for later freeing + */ + Display *createDpy; + + /** + * Maximum small render command size. This is the smaller of 64k and + * the size of the above buffer. + */ + GLint maxSmallRenderCommandSize; + + /** + * Major opcode for the extension. Copied here so a lookup isn't + * needed. + */ + GLint majorOpcode; + + /** + * Pointer to the mode used to create this context. + */ + const __GLcontextModes *mode; + +#ifdef GLX_DIRECT_RENDERING + __GLXDRIcontext *driContext; + __DRIcontext *__driContext; +#endif + + /** + * The current read-drawable for this context. Will be None if this + * context is not current to any drawable. + * + * \since Internal API version 20030606. + */ + GLXDrawable currentReadable; + + /** + * Pointer to client-state data that is private to libGL. This is only + * used for indirect rendering contexts. + * + * No internal API version change was made for this change. Client-side + * drivers should NEVER use this data or even care that it exists. + */ + void *client_state_private; + + /** + * Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE. + */ + int renderType; + + /** + * \name Raw server GL version + * + * True core GL version supported by the server. This is the raw value + * returned by the server, and it may not reflect what is actually + * supported (or reported) by the client-side library. + */ + /*@{ */ + int server_major; /**< Major version number. */ + int server_minor; /**< Minor version number. */ + /*@} */ + + /** + * Thread ID we're currently current in. Zero if none. + */ + unsigned long thread_id; + + char gl_extension_bits[__GL_EXT_BYTES]; +}; + +#define __glXSetError(gc,code) \ + if (!(gc)->error) { \ + (gc)->error = code; \ + } + +extern void __glFreeAttributeState(__GLXcontext *); + +/************************************************************************/ + +/** + * The size of the largest drawing command known to the implementation + * that will use the GLXRender GLX command. In this case it is + * \c glPolygonStipple. + */ +#define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156 + +/** + * To keep the implementation fast, the code uses a "limit" pointer + * to determine when the drawing command buffer is too full to hold + * another fixed size command. This constant defines the amount of + * space that must always be available in the drawing command buffer + * at all times for the implementation to work. It is important that + * the number be just large enough, but not so large as to reduce the + * efficacy of the buffer. The "+32" is just to keep the code working + * in case somebody counts wrong. + */ +#define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32) + +/** + * This implementation uses a smaller threshold for switching + * to the RenderLarge protocol than the protcol requires so that + * large copies don't occur. + */ +#define __GLX_RENDER_CMD_SIZE_LIMIT 4096 + +/** + * One of these records exists per screen of the display. It contains + * a pointer to the config data for that screen (if the screen supports GL). + */ +struct __GLXscreenConfigsRec +{ + /** + * GLX extension string reported by the X-server. + */ + const char *serverGLXexts; + + /** + * GLX extension string to be reported to applications. This is the + * set of extensions that the application can actually use. + */ + char *effectiveGLXexts; + +#ifdef GLX_DIRECT_RENDERING + /** + * Per screen direct rendering interface functions and data. + */ + __DRIscreen *__driScreen; + const __DRIcoreExtension *core; + const __DRIlegacyExtension *legacy; + const __DRIswrastExtension *swrast; + const __DRIdri2Extension *dri2; + __glxHashTable *drawHash; + Display *dpy; + int scr, fd; + void *driver; + + __GLXDRIscreen *driScreen; + + const __DRIconfig **driver_configs; + +#ifdef __DRI_COPY_SUB_BUFFER + const __DRIcopySubBufferExtension *driCopySubBuffer; +#endif + +#ifdef __DRI_SWAP_CONTROL + const __DRIswapControlExtension *swapControl; +#endif + +#ifdef __DRI_ALLOCATE + const __DRIallocateExtension *allocate; +#endif + +#ifdef __DRI_FRAME_TRACKING + const __DRIframeTrackingExtension *frameTracking; +#endif + +#ifdef __DRI_MEDIA_STREAM_COUNTER + const __DRImediaStreamCounterExtension *msc; +#endif + +#ifdef __DRI_TEX_BUFFER + const __DRItexBufferExtension *texBuffer; +#endif + +#ifdef __DRI2_FLUSH + const __DRI2flushExtension *f; +#endif + +#endif + + /** + * Linked list of glx visuals and fbconfigs for this screen. + */ + __GLcontextModes *visuals, *configs; + + /** + * Per-screen dynamic GLX extension tracking. The \c direct_support + * field only contains enough bits for 64 extensions. Should libGL + * ever need to track more than 64 GLX extensions, we can safely grow + * this field. The \c __GLXscreenConfigs structure is not used outside + * libGL. + */ + /*@{ */ + unsigned char direct_support[8]; + GLboolean ext_list_first_time; + /*@} */ + +}; + +/** + * Per display private data. One of these records exists for each display + * that is using the OpenGL (GLX) extension. + */ +struct __GLXdisplayPrivateRec +{ + /** + * Back pointer to the display + */ + Display *dpy; + + /** + * The \c majorOpcode is common to all connections to the same server. + * It is also copied into the context structure. + */ + int majorOpcode; + + /** + * \name Server Version + * + * Major and minor version returned by the server during initialization. + */ + /*@{ */ + int majorVersion, minorVersion; + /*@} */ + + /** + * \name Storage for the servers GLX vendor and versions strings. + * + * These are the same for all screens on this display. These fields will + * be filled in on demand. + */ + /*@{ */ + const char *serverGLXvendor; + const char *serverGLXversion; + /*@} */ + + /** + * Configurations of visuals for all screens on this display. + * Also, per screen data which now includes the server \c GLX_EXTENSION + * string. + */ + __GLXscreenConfigs *screenConfigs; + +#ifdef GLX_DIRECT_RENDERING + /** + * Per display direct rendering interface functions and data. + */ + __GLXDRIdisplay *driswDisplay; + __GLXDRIdisplay *driDisplay; + __GLXDRIdisplay *dri2Display; +#endif +}; + + +extern GLubyte *__glXFlushRenderBuffer(__GLXcontext *, GLubyte *); + +extern void __glXSendLargeChunk(__GLXcontext * gc, GLint requestNumber, + GLint totalRequests, + const GLvoid * data, GLint dataLen); + +extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint, + const GLvoid *, GLint); + +/* Initialize the GLX extension for dpy */ +extern __GLXdisplayPrivate *__glXInitialize(Display *); + +extern void __glXPreferEGL(int state); + +/************************************************************************/ + +extern int __glXDebug; + +/* This is per-thread storage in an MT environment */ +#if defined( PTHREADS ) + +extern void __glXSetCurrentContext(__GLXcontext * c); + +# if defined( GLX_USE_TLS ) + +extern __thread void *__glX_tls_Context + __attribute__ ((tls_model("initial-exec"))); + +# define __glXGetCurrentContext() __glX_tls_Context + +# else + +extern __GLXcontext *__glXGetCurrentContext(void); + +# endif /* defined( GLX_USE_TLS ) */ + +#else + +extern __GLXcontext *__glXcurrentContext; +#define __glXGetCurrentContext() __glXcurrentContext +#define __glXSetCurrentContext(gc) __glXcurrentContext = gc + +#endif /* defined( PTHREADS ) */ + +extern void __glXSetCurrentContextNull(void); + +extern void __glXFreeContext(__GLXcontext *); + + +/* +** Global lock for all threads in this address space using the GLX +** extension +*/ +#if defined( PTHREADS ) +extern pthread_mutex_t __glXmutex; +#define __glXLock() pthread_mutex_lock(&__glXmutex) +#define __glXUnlock() pthread_mutex_unlock(&__glXmutex) +#else +#define __glXLock() +#define __glXUnlock() +#endif + +/* +** Setup for a command. Initialize the extension for dpy if necessary. +*/ +extern CARD8 __glXSetupForCommand(Display * dpy); + +/************************************************************************/ + +/* +** Data conversion and packing support. +*/ + +extern const GLuint __glXDefaultPixelStore[9]; + +/* Send an image to the server using RenderLarge. */ +extern void __glXSendLargeImage(__GLXcontext * gc, GLint compsize, GLint dim, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, + const GLvoid * src, GLubyte * pc, + GLubyte * modes); + +/* Return the size, in bytes, of some pixel data */ +extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum, GLenum); + +/* Return the number of elements per group of a specified format*/ +extern GLint __glElementsPerGroup(GLenum format, GLenum type); + +/* Return the number of bytes per element, based on the element type (other +** than GL_BITMAP). +*/ +extern GLint __glBytesPerElement(GLenum type); + +/* +** Fill the transport buffer with the data from the users buffer, +** applying some of the pixel store modes (unpack modes) to the data +** first. As a side effect of this call, the "modes" field is +** updated to contain the modes needed by the server to decode the +** sent data. +*/ +extern void __glFillImage(__GLXcontext *, GLint, GLint, GLint, GLint, GLenum, + GLenum, const GLvoid *, GLubyte *, GLubyte *); + +/* Copy map data with a stride into a packed buffer */ +extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *); +extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *); +extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint, + const GLfloat *, GLfloat *); +extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint, + const GLdouble *, GLdouble *); + +/* +** Empty an image out of the reply buffer into the clients memory applying +** the pack modes to pack back into the clients requested format. +*/ +extern void __glEmptyImage(__GLXcontext *, GLint, GLint, GLint, GLint, GLenum, + GLenum, const GLubyte *, GLvoid *); + + +/* +** Allocate and Initialize Vertex Array client state, and free. +*/ +extern void __glXInitVertexArrayState(__GLXcontext *); +extern void __glXFreeVertexArrayState(__GLXcontext *); + +/* +** Inform the Server of the major and minor numbers and of the client +** libraries extension string. +*/ +extern void __glXClientInfo(Display * dpy, int opcode); + +/************************************************************************/ + +/* +** Declarations that should be in Xlib +*/ +#ifdef __GL_USE_OUR_PROTOTYPES +extern void _XFlush(Display *); +extern Status _XReply(Display *, xReply *, int, Bool); +extern void _XRead(Display *, void *, long); +extern void _XSend(Display *, const void *, long); +#endif + + +extern void __glXInitializeVisualConfigFromTags(__GLcontextModes * config, + int count, const INT32 * bp, + Bool tagged_only, + Bool fbconfig_style_tags); + +extern char *__glXQueryServerString(Display * dpy, int opcode, + CARD32 screen, CARD32 name); +extern char *__glXGetString(Display * dpy, int opcode, + CARD32 screen, CARD32 name); + +extern char *__glXstrdup(const char *str); + + +extern const char __glXGLClientVersion[]; +extern const char __glXGLClientExtensions[]; + +/* Get the unadjusted system time */ +extern int __glXGetUST(int64_t * ust); + +extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, + int32_t * numerator, + int32_t * denominator); + +#ifdef GLX_DIRECT_RENDERING +GLboolean +__driGetMscRateOML(__DRIdrawable * draw, + int32_t * numerator, int32_t * denominator, void *private); + +/* So that dri2.c:DRI2WireToEvent() can access + * glx_info->codes->first_event */ +XExtDisplayInfo *__glXFindDisplay (Display *dpy); +#endif + +#endif /* !__GLX_client_h__ */ diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c new file mode 100644 index 00000000000..c3be974ea91 --- /dev/null +++ b/src/glx/glxcmds.c @@ -0,0 +1,3173 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +/** + * \file glxcmds.c + * Client-side GLX interface. + */ + +#include "glxclient.h" +#include "glapi.h" +#include "glxextensions.h" +#include "glcontextmodes.h" + +#ifdef GLX_DIRECT_RENDERING +#include +#include +#include "xf86dri.h" +#endif + +#if defined(USE_XCB) +#include +#include +#include +#endif + +static const char __glXGLXClientVendorName[] = "Mesa Project and SGI"; +static const char __glXGLXClientVersion[] = "1.4"; + + +/****************************************************************************/ + +#ifdef GLX_DIRECT_RENDERING + +static Bool windowExistsFlag; +static int +windowExistsErrorHandler(Display * dpy, XErrorEvent * xerr) +{ + if (xerr->error_code == BadWindow) { + windowExistsFlag = GL_FALSE; + } + return 0; +} + +/** + * Find drawables in the local hash that have been destroyed on the + * server. + * + * \param dpy Display to destroy drawables for + * \param screen Screen number to destroy drawables for + */ +static void +GarbageCollectDRIDrawables(Display * dpy, __GLXscreenConfigs * sc) +{ + XID draw; + __GLXDRIdrawable *pdraw; + XWindowAttributes xwa; + int (*oldXErrorHandler) (Display *, XErrorEvent *); + + /* Set no-op error handler so Xlib doesn't bail out if the windows + * has alreay been destroyed on the server. */ + XSync(dpy, GL_FALSE); + oldXErrorHandler = XSetErrorHandler(windowExistsErrorHandler); + + if (__glxHashFirst(sc->drawHash, &draw, (void *) &pdraw) == 1) { + do { + windowExistsFlag = GL_TRUE; + XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */ + if (!windowExistsFlag) { + /* Destroy the local drawable data, if the drawable no + longer exists in the Xserver */ + (*pdraw->destroyDrawable) (pdraw); + __glxHashDelete(sc->drawHash, draw); + } + } while (__glxHashNext(sc->drawHash, &draw, (void *) &pdraw) == 1); + } + + XSync(dpy, GL_FALSE); + XSetErrorHandler(oldXErrorHandler); +} + +extern __GLXDRIdrawable *GetGLXDRIDrawable(Display * dpy, + GLXDrawable drawable, + int *const scrn_num); + +/** + * Get the __DRIdrawable for the drawable associated with a GLXContext + * + * \param dpy The display associated with \c drawable. + * \param drawable GLXDrawable whose __DRIdrawable part is to be retrieved. + * \param scrn_num If non-NULL, the drawables screen is stored there + * \returns A pointer to the context's __DRIdrawable on success, or NULL if + * the drawable is not associated with a direct-rendering context. + */ +_X_HIDDEN __GLXDRIdrawable * +GetGLXDRIDrawable(Display * dpy, GLXDrawable drawable, int *const scrn_num) +{ + __GLXdisplayPrivate *priv = __glXInitialize(dpy); + __GLXDRIdrawable *pdraw; + const unsigned screen_count = ScreenCount(dpy); + unsigned i; + __GLXscreenConfigs *psc; + + if (priv == NULL) + return NULL; + + for (i = 0; i < screen_count; i++) { + psc = &priv->screenConfigs[i]; + if (psc->drawHash == NULL) + continue; + + if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0) { + if (scrn_num != NULL) + *scrn_num = i; + return pdraw; + } + } + + return NULL; +} + +#endif + + +/** + * Get the GLX per-screen data structure associated with a GLX context. + * + * \param dpy Display for which the GLX per-screen information is to be + * retrieved. + * \param scrn Screen on \c dpy for which the GLX per-screen information is + * to be retrieved. + * \returns A pointer to the GLX per-screen data if \c dpy and \c scrn + * specify a valid GLX screen, or NULL otherwise. + * + * \todo Should this function validate that \c scrn is within the screen + * number range for \c dpy? + */ + +static __GLXscreenConfigs * +GetGLXScreenConfigs(Display * dpy, int scrn) +{ + __GLXdisplayPrivate *const priv = __glXInitialize(dpy); + + return (priv + && priv->screenConfigs != + NULL) ? &priv->screenConfigs[scrn] : NULL; +} + + +static int +GetGLXPrivScreenConfig(Display * dpy, int scrn, __GLXdisplayPrivate ** ppriv, + __GLXscreenConfigs ** ppsc) +{ + /* Initialize the extension, if needed . This has the added value + * of initializing/allocating the display private + */ + + if (dpy == NULL) { + return GLX_NO_EXTENSION; + } + + *ppriv = __glXInitialize(dpy); + if (*ppriv == NULL) { + return GLX_NO_EXTENSION; + } + + /* Check screen number to see if its valid */ + if ((scrn < 0) || (scrn >= ScreenCount(dpy))) { + return GLX_BAD_SCREEN; + } + + /* Check to see if the GL is supported on this screen */ + *ppsc = &((*ppriv)->screenConfigs[scrn]); + if ((*ppsc)->configs == NULL) { + /* No support for GL on this screen regardless of visual */ + return GLX_BAD_VISUAL; + } + + return Success; +} + + +/** + * Determine if a \c GLXFBConfig supplied by the application is valid. + * + * \param dpy Application supplied \c Display pointer. + * \param config Application supplied \c GLXFBConfig. + * + * \returns If the \c GLXFBConfig is valid, the a pointer to the matching + * \c __GLcontextModes structure is returned. Otherwise, \c NULL + * is returned. + */ +static __GLcontextModes * +ValidateGLXFBConfig(Display * dpy, GLXFBConfig config) +{ + __GLXdisplayPrivate *const priv = __glXInitialize(dpy); + const unsigned num_screens = ScreenCount(dpy); + unsigned i; + const __GLcontextModes *modes; + + + if (priv != NULL) { + for (i = 0; i < num_screens; i++) { + for (modes = priv->screenConfigs[i].configs; modes != NULL; + modes = modes->next) { + if (modes == (__GLcontextModes *) config) { + return (__GLcontextModes *) config; + } + } + } + } + + return NULL; +} + + +/** + * \todo It should be possible to move the allocate of \c client_state_private + * later in the function for direct-rendering contexts. Direct-rendering + * contexts don't need to track client state, so they don't need that memory + * at all. + * + * \todo Eliminate \c __glXInitVertexArrayState. Replace it with a new + * function called \c __glXAllocateClientState that allocates the memory and + * does all the initialization (including the pixel pack / unpack). + */ +static GLXContext +AllocateGLXContext(Display * dpy) +{ + GLXContext gc; + int bufSize; + CARD8 opcode; + __GLXattribute *state; + + if (!dpy) + return NULL; + + opcode = __glXSetupForCommand(dpy); + if (!opcode) { + return NULL; + } + + /* Allocate our context record */ + gc = (GLXContext) Xmalloc(sizeof(struct __GLXcontextRec)); + if (!gc) { + /* Out of memory */ + return NULL; + } + memset(gc, 0, sizeof(struct __GLXcontextRec)); + + state = Xmalloc(sizeof(struct __GLXattributeRec)); + if (state == NULL) { + /* Out of memory */ + Xfree(gc); + return NULL; + } + gc->client_state_private = state; + memset(gc->client_state_private, 0, sizeof(struct __GLXattributeRec)); + state->NoDrawArraysProtocol = (getenv("LIBGL_NO_DRAWARRAYS") != NULL); + + /* + ** Create a temporary buffer to hold GLX rendering commands. The size + ** of the buffer is selected so that the maximum number of GLX rendering + ** commands can fit in a single X packet and still have room in the X + ** packet for the GLXRenderReq header. + */ + + bufSize = (XMaxRequestSize(dpy) * 4) - sz_xGLXRenderReq; + gc->buf = (GLubyte *) Xmalloc(bufSize); + if (!gc->buf) { + Xfree(gc->client_state_private); + Xfree(gc); + return NULL; + } + gc->bufSize = bufSize; + + /* Fill in the new context */ + gc->renderMode = GL_RENDER; + + state->storePack.alignment = 4; + state->storeUnpack.alignment = 4; + + gc->attributes.stackPointer = &gc->attributes.stack[0]; + + /* + ** PERFORMANCE NOTE: A mode dependent fill image can speed things up. + ** Other code uses the fastImageUnpack bit, but it is never set + ** to GL_TRUE. + */ + gc->fastImageUnpack = GL_FALSE; + gc->fillImage = __glFillImage; + gc->pc = gc->buf; + gc->bufEnd = gc->buf + bufSize; + gc->isDirect = GL_FALSE; + if (__glXDebug) { + /* + ** Set limit register so that there will be one command per packet + */ + gc->limit = gc->buf; + } + else { + gc->limit = gc->buf + bufSize - __GLX_BUFFER_LIMIT_SIZE; + } + gc->createDpy = dpy; + gc->majorOpcode = opcode; + + /* + ** Constrain the maximum drawing command size allowed to be + ** transfered using the X_GLXRender protocol request. First + ** constrain by a software limit, then constrain by the protocl + ** limit. + */ + if (bufSize > __GLX_RENDER_CMD_SIZE_LIMIT) { + bufSize = __GLX_RENDER_CMD_SIZE_LIMIT; + } + if (bufSize > __GLX_MAX_RENDER_CMD_SIZE) { + bufSize = __GLX_MAX_RENDER_CMD_SIZE; + } + gc->maxSmallRenderCommandSize = bufSize; + return gc; +} + + +/** + * Create a new context. Exactly one of \c vis and \c fbconfig should be + * non-NULL. + * + * \param use_glx_1_3 For FBConfigs, should GLX 1.3 protocol or + * SGIX_fbconfig protocol be used? + * \param renderType For FBConfigs, what is the rendering type? + */ + +static GLXContext +CreateContext(Display * dpy, XVisualInfo * vis, + const __GLcontextModes * const fbconfig, + GLXContext shareList, + Bool allowDirect, GLXContextID contextID, + Bool use_glx_1_3, int renderType) +{ + GLXContext gc; +#ifdef GLX_DIRECT_RENDERING + int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen; + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); +#endif + + if (dpy == NULL) + return NULL; + + gc = AllocateGLXContext(dpy); + if (!gc) + return NULL; + + if (None == contextID) { + if ((vis == NULL) && (fbconfig == NULL)) + return NULL; + +#ifdef GLX_DIRECT_RENDERING + if (allowDirect && psc->driScreen) { + const __GLcontextModes *mode; + + if (fbconfig == NULL) { + mode = _gl_context_modes_find_visual(psc->visuals, vis->visualid); + if (mode == NULL) { + xError error; + + error.errorCode = BadValue; + error.resourceID = vis->visualid; + error.sequenceNumber = dpy->request; + error.type = X_Error; + error.majorCode = gc->majorOpcode; + error.minorCode = X_GLXCreateContext; + _XError(dpy, &error); + return None; + } + if (renderType == 0) { + /* Initialize renderType now */ + renderType = mode->rgbMode ? GLX_RGBA_TYPE : GLX_COLOR_INDEX_TYPE; + } + } + else { + mode = fbconfig; + } + + gc->driContext = psc->driScreen->createContext(psc, mode, gc, + shareList, + renderType); + if (gc->driContext != NULL) { + gc->screen = mode->screen; + gc->psc = psc; + gc->mode = mode; + gc->isDirect = GL_TRUE; + } + } +#endif + + LockDisplay(dpy); + if (fbconfig == NULL) { + xGLXCreateContextReq *req; + + /* Send the glXCreateContext request */ + GetReq(GLXCreateContext, req); + req->reqType = gc->majorOpcode; + req->glxCode = X_GLXCreateContext; + req->context = gc->xid = XAllocID(dpy); + req->visual = vis->visualid; + req->screen = vis->screen; + req->shareList = shareList ? shareList->xid : None; +#ifdef GLX_DIRECT_RENDERING + req->isDirect = gc->driContext != NULL; +#else + req->isDirect = 0; +#endif + } + else if (use_glx_1_3) { + xGLXCreateNewContextReq *req; + + /* Send the glXCreateNewContext request */ + GetReq(GLXCreateNewContext, req); + req->reqType = gc->majorOpcode; + req->glxCode = X_GLXCreateNewContext; + req->context = gc->xid = XAllocID(dpy); + req->fbconfig = fbconfig->fbconfigID; + req->screen = fbconfig->screen; + req->renderType = renderType; + req->shareList = shareList ? shareList->xid : None; +#ifdef GLX_DIRECT_RENDERING + req->isDirect = gc->driContext != NULL; +#else + req->isDirect = 0; +#endif + } + else { + xGLXVendorPrivateWithReplyReq *vpreq; + xGLXCreateContextWithConfigSGIXReq *req; + + /* Send the glXCreateNewContext request */ + GetReqExtra(GLXVendorPrivateWithReply, + sz_xGLXCreateContextWithConfigSGIXReq - + sz_xGLXVendorPrivateWithReplyReq, vpreq); + req = (xGLXCreateContextWithConfigSGIXReq *) vpreq; + req->reqType = gc->majorOpcode; + req->glxCode = X_GLXVendorPrivateWithReply; + req->vendorCode = X_GLXvop_CreateContextWithConfigSGIX; + req->context = gc->xid = XAllocID(dpy); + req->fbconfig = fbconfig->fbconfigID; + req->screen = fbconfig->screen; + req->renderType = renderType; + req->shareList = shareList ? shareList->xid : None; +#ifdef GLX_DIRECT_RENDERING + req->isDirect = gc->driContext != NULL; +#else + req->isDirect = 0; +#endif + } + + UnlockDisplay(dpy); + SyncHandle(); + gc->imported = GL_FALSE; + } + else { + gc->xid = contextID; + gc->imported = GL_TRUE; + } + + gc->renderType = renderType; + + return gc; +} + +PUBLIC GLXContext +glXCreateContext(Display * dpy, XVisualInfo * vis, + GLXContext shareList, Bool allowDirect) +{ + return CreateContext(dpy, vis, NULL, shareList, allowDirect, None, + False, 0); +} + +_X_HIDDEN void +__glXFreeContext(__GLXcontext * gc) +{ + if (gc->vendor) + XFree((char *) gc->vendor); + if (gc->renderer) + XFree((char *) gc->renderer); + if (gc->version) + XFree((char *) gc->version); + if (gc->extensions) + XFree((char *) gc->extensions); + __glFreeAttributeState(gc); + XFree((char *) gc->buf); + Xfree((char *) gc->client_state_private); + XFree((char *) gc); + +} + +/* +** Destroy the named context +*/ +static void +DestroyContext(Display * dpy, GLXContext gc) +{ + xGLXDestroyContextReq *req; + GLXContextID xid; + CARD8 opcode; + GLboolean imported; + + opcode = __glXSetupForCommand(dpy); + if (!opcode || !gc) { + return; + } + + __glXLock(); + xid = gc->xid; + imported = gc->imported; + gc->xid = None; + + if (gc->currentDpy) { + /* This context is bound to some thread. According to the man page, + * we should not actually delete the context until it's unbound. + * Note that we set gc->xid = None above. In MakeContextCurrent() + * we check for that and delete the context there. + */ + __glXUnlock(); + return; + } + +#ifdef GLX_DIRECT_RENDERING + /* Destroy the direct rendering context */ + if (gc->driContext) { + (*gc->driContext->destroyContext) (gc->driContext, gc->psc, dpy); + gc->driContext = NULL; + GarbageCollectDRIDrawables(dpy, gc->psc); + } +#endif + + __glXFreeVertexArrayState(gc); + + if (gc->currentDpy) { + /* Have to free later cuz it's in use now */ + __glXUnlock(); + } + else { + /* Destroy the handle if not current to anybody */ + __glXUnlock(); + __glXFreeContext(gc); + } + + if (!imported) { + /* + ** This dpy also created the server side part of the context. + ** Send the glXDestroyContext request. + */ + LockDisplay(dpy); + GetReq(GLXDestroyContext, req); + req->reqType = opcode; + req->glxCode = X_GLXDestroyContext; + req->context = xid; + UnlockDisplay(dpy); + SyncHandle(); + } +} + +PUBLIC void +glXDestroyContext(Display * dpy, GLXContext gc) +{ + DestroyContext(dpy, gc); +} + +/* +** Return the major and minor version #s for the GLX extension +*/ +PUBLIC Bool +glXQueryVersion(Display * dpy, int *major, int *minor) +{ + __GLXdisplayPrivate *priv; + + /* Init the extension. This fetches the major and minor version. */ + priv = __glXInitialize(dpy); + if (!priv) + return GL_FALSE; + + if (major) + *major = priv->majorVersion; + if (minor) + *minor = priv->minorVersion; + return GL_TRUE; +} + +/* +** Query the existance of the GLX extension +*/ +PUBLIC Bool +glXQueryExtension(Display * dpy, int *errorBase, int *eventBase) +{ + int major_op, erb, evb; + Bool rv; + + rv = XQueryExtension(dpy, GLX_EXTENSION_NAME, &major_op, &evb, &erb); + if (rv) { + if (errorBase) + *errorBase = erb; + if (eventBase) + *eventBase = evb; + } + return rv; +} + +/* +** Put a barrier in the token stream that forces the GL to finish its +** work before X can proceed. +*/ +PUBLIC void +glXWaitGL(void) +{ + xGLXWaitGLReq *req; + GLXContext gc = __glXGetCurrentContext(); + Display *dpy = gc->currentDpy; + + if (!dpy) + return; + + /* Flush any pending commands out */ + __glXFlushRenderBuffer(gc, gc->pc); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + int screen; + __GLXDRIdrawable *pdraw = + GetGLXDRIDrawable(dpy, gc->currentDrawable, &screen); + + if (pdraw != NULL) { + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); + glFlush(); + if (psc->driScreen->waitGL != NULL) + (*psc->driScreen->waitGL) (pdraw); + } + return; + } +#endif + + /* Send the glXWaitGL request */ + LockDisplay(dpy); + GetReq(GLXWaitGL, req); + req->reqType = gc->majorOpcode; + req->glxCode = X_GLXWaitGL; + req->contextTag = gc->currentContextTag; + UnlockDisplay(dpy); + SyncHandle(); +} + +/* +** Put a barrier in the token stream that forces X to finish its +** work before GL can proceed. +*/ +PUBLIC void +glXWaitX(void) +{ + xGLXWaitXReq *req; + GLXContext gc = __glXGetCurrentContext(); + Display *dpy = gc->currentDpy; + + if (!dpy) + return; + + /* Flush any pending commands out */ + __glXFlushRenderBuffer(gc, gc->pc); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + int screen; + __GLXDRIdrawable *pdraw = + GetGLXDRIDrawable(dpy, gc->currentDrawable, &screen); + + if (pdraw != NULL) { + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); + if (psc->driScreen->waitX != NULL) + (*psc->driScreen->waitX) (pdraw); + } + else + XSync(dpy, False); + return; + } +#endif + + /* + ** Send the glXWaitX request. + */ + LockDisplay(dpy); + GetReq(GLXWaitX, req); + req->reqType = gc->majorOpcode; + req->glxCode = X_GLXWaitX; + req->contextTag = gc->currentContextTag; + UnlockDisplay(dpy); + SyncHandle(); +} + +PUBLIC void +glXUseXFont(Font font, int first, int count, int listBase) +{ + xGLXUseXFontReq *req; + GLXContext gc = __glXGetCurrentContext(); + Display *dpy = gc->currentDpy; + + if (!dpy) + return; + + /* Flush any pending commands out */ + (void) __glXFlushRenderBuffer(gc, gc->pc); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + DRI_glXUseXFont(font, first, count, listBase); + return; + } +#endif + + /* Send the glXUseFont request */ + LockDisplay(dpy); + GetReq(GLXUseXFont, req); + req->reqType = gc->majorOpcode; + req->glxCode = X_GLXUseXFont; + req->contextTag = gc->currentContextTag; + req->font = font; + req->first = first; + req->count = count; + req->listBase = listBase; + UnlockDisplay(dpy); + SyncHandle(); +} + +/************************************************************************/ + +/* +** Copy the source context to the destination context using the +** attribute "mask". +*/ +PUBLIC void +glXCopyContext(Display * dpy, GLXContext source, + GLXContext dest, unsigned long mask) +{ + xGLXCopyContextReq *req; + GLXContext gc = __glXGetCurrentContext(); + GLXContextTag tag; + CARD8 opcode; + + opcode = __glXSetupForCommand(dpy); + if (!opcode) { + return; + } + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + /* NOT_DONE: This does not work yet */ + } +#endif + + /* + ** If the source is the current context, send its tag so that the context + ** can be flushed before the copy. + */ + if (source == gc && dpy == gc->currentDpy) { + tag = gc->currentContextTag; + } + else { + tag = 0; + } + + /* Send the glXCopyContext request */ + LockDisplay(dpy); + GetReq(GLXCopyContext, req); + req->reqType = opcode; + req->glxCode = X_GLXCopyContext; + req->source = source ? source->xid : None; + req->dest = dest ? dest->xid : None; + req->mask = mask; + req->contextTag = tag; + UnlockDisplay(dpy); + SyncHandle(); +} + + +/** + * Determine if a context uses direct rendering. + * + * \param dpy Display where the context was created. + * \param contextID ID of the context to be tested. + * + * \returns \c GL_TRUE if the context is direct rendering or not. + */ +static Bool +__glXIsDirect(Display * dpy, GLXContextID contextID) +{ +#if !defined(USE_XCB) + xGLXIsDirectReq *req; + xGLXIsDirectReply reply; +#endif + CARD8 opcode; + + opcode = __glXSetupForCommand(dpy); + if (!opcode) { + return GL_FALSE; + } + +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + xcb_glx_is_direct_reply_t *reply = xcb_glx_is_direct_reply(c, + xcb_glx_is_direct + (c, contextID), + NULL); + + const Bool is_direct = reply->is_direct ? True : False; + free(reply); + + return is_direct; +#else + /* Send the glXIsDirect request */ + LockDisplay(dpy); + GetReq(GLXIsDirect, req); + req->reqType = opcode; + req->glxCode = X_GLXIsDirect; + req->context = contextID; + _XReply(dpy, (xReply *) & reply, 0, False); + UnlockDisplay(dpy); + SyncHandle(); + + return reply.isDirect; +#endif /* USE_XCB */ +} + +/** + * \todo + * Shouldn't this function \b always return \c GL_FALSE when + * \c GLX_DIRECT_RENDERING is not defined? Do we really need to bother with + * the GLX protocol here at all? + */ +PUBLIC Bool +glXIsDirect(Display * dpy, GLXContext gc) +{ + if (!gc) { + return GL_FALSE; +#ifdef GLX_DIRECT_RENDERING + } + else if (gc->driContext) { + return GL_TRUE; +#endif + } + return __glXIsDirect(dpy, gc->xid); +} + +PUBLIC GLXPixmap +glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap) +{ + xGLXCreateGLXPixmapReq *req; + GLXPixmap xid; + CARD8 opcode; + + opcode = __glXSetupForCommand(dpy); + if (!opcode) { + return None; + } + + /* Send the glXCreateGLXPixmap request */ + LockDisplay(dpy); + GetReq(GLXCreateGLXPixmap, req); + req->reqType = opcode; + req->glxCode = X_GLXCreateGLXPixmap; + req->screen = vis->screen; + req->visual = vis->visualid; + req->pixmap = pixmap; + req->glxpixmap = xid = XAllocID(dpy); + UnlockDisplay(dpy); + SyncHandle(); + +#ifdef GLX_DIRECT_RENDERING + do { + /* FIXME: Maybe delay __DRIdrawable creation until the drawable + * is actually bound to a context... */ + + __GLXdisplayPrivate *const priv = __glXInitialize(dpy); + __GLXDRIdrawable *pdraw; + __GLXscreenConfigs *psc; + __GLcontextModes *modes; + + psc = &priv->screenConfigs[vis->screen]; + if (psc->driScreen == NULL) + break; + modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid); + pdraw = psc->driScreen->createDrawable(psc, pixmap, req->glxpixmap, modes); + if (pdraw == NULL) { + fprintf(stderr, "failed to create pixmap\n"); + break; + } + + if (__glxHashInsert(psc->drawHash, req->glxpixmap, pdraw)) { + (*pdraw->destroyDrawable) (pdraw); + return None; /* FIXME: Check what we're supposed to do here... */ + } + } while (0); +#endif + + return xid; +} + +/* +** Destroy the named pixmap +*/ +PUBLIC void +glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap) +{ + xGLXDestroyGLXPixmapReq *req; + CARD8 opcode; + + opcode = __glXSetupForCommand(dpy); + if (!opcode) { + return; + } + + /* Send the glXDestroyGLXPixmap request */ + LockDisplay(dpy); + GetReq(GLXDestroyGLXPixmap, req); + req->reqType = opcode; + req->glxCode = X_GLXDestroyGLXPixmap; + req->glxpixmap = glxpixmap; + UnlockDisplay(dpy); + SyncHandle(); + +#ifdef GLX_DIRECT_RENDERING + { + int screen; + __GLXdisplayPrivate *const priv = __glXInitialize(dpy); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap, &screen); + __GLXscreenConfigs *psc = &priv->screenConfigs[screen]; + + if (pdraw != NULL) { + (*pdraw->destroyDrawable) (pdraw); + __glxHashDelete(psc->drawHash, glxpixmap); + } + } +#endif +} + +PUBLIC void +glXSwapBuffers(Display * dpy, GLXDrawable drawable) +{ + GLXContext gc; + GLXContextTag tag; + CARD8 opcode; +#ifdef USE_XCB + xcb_connection_t *c; +#else + xGLXSwapBuffersReq *req; +#endif + +#ifdef GLX_DIRECT_RENDERING + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); + + if (pdraw != NULL) { + glFlush(); + (*pdraw->psc->driScreen->swapBuffers)(pdraw, 0, 0, 0); + return; + } +#endif + + opcode = __glXSetupForCommand(dpy); + if (!opcode) { + return; + } + + /* + ** The calling thread may or may not have a current context. If it + ** does, send the context tag so the server can do a flush. + */ + gc = __glXGetCurrentContext(); + if ((gc != NULL) && (dpy == gc->currentDpy) && + ((drawable == gc->currentDrawable) + || (drawable == gc->currentReadable))) { + tag = gc->currentContextTag; + } + else { + tag = 0; + } + +#ifdef USE_XCB + c = XGetXCBConnection(dpy); + xcb_glx_swap_buffers(c, tag, drawable); + xcb_flush(c); +#else + /* Send the glXSwapBuffers request */ + LockDisplay(dpy); + GetReq(GLXSwapBuffers, req); + req->reqType = opcode; + req->glxCode = X_GLXSwapBuffers; + req->drawable = drawable; + req->contextTag = tag; + UnlockDisplay(dpy); + SyncHandle(); + XFlush(dpy); +#endif /* USE_XCB */ +} + + +/* +** Return configuration information for the given display, screen and +** visual combination. +*/ +PUBLIC int +glXGetConfig(Display * dpy, XVisualInfo * vis, int attribute, + int *value_return) +{ + __GLXdisplayPrivate *priv; + __GLXscreenConfigs *psc; + __GLcontextModes *modes; + int status; + + status = GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc); + if (status == Success) { + modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid); + + /* Lookup attribute after first finding a match on the visual */ + if (modes != NULL) { + return _gl_get_context_mode_data(modes, attribute, value_return); + } + + status = GLX_BAD_VISUAL; + } + + /* + ** If we can't find the config for this visual, this visual is not + ** supported by the OpenGL implementation on the server. + */ + if ((status == GLX_BAD_VISUAL) && (attribute == GLX_USE_GL)) { + *value_return = GL_FALSE; + status = Success; + } + + return status; +} + +/************************************************************************/ + +static void +init_fbconfig_for_chooser(__GLcontextModes * config, + GLboolean fbconfig_style_tags) +{ + memset(config, 0, sizeof(__GLcontextModes)); + config->visualID = (XID) GLX_DONT_CARE; + config->visualType = GLX_DONT_CARE; + + /* glXChooseFBConfig specifies different defaults for these two than + * glXChooseVisual. + */ + if (fbconfig_style_tags) { + config->rgbMode = GL_TRUE; + config->doubleBufferMode = GLX_DONT_CARE; + } + + config->visualRating = GLX_DONT_CARE; + config->transparentPixel = GLX_NONE; + config->transparentRed = GLX_DONT_CARE; + config->transparentGreen = GLX_DONT_CARE; + config->transparentBlue = GLX_DONT_CARE; + config->transparentAlpha = GLX_DONT_CARE; + config->transparentIndex = GLX_DONT_CARE; + + config->drawableType = GLX_WINDOW_BIT; + config->renderType = + (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; + config->xRenderable = GLX_DONT_CARE; + config->fbconfigID = (GLXFBConfigID) (GLX_DONT_CARE); + + config->swapMethod = GLX_DONT_CARE; +} + +#define MATCH_DONT_CARE( param ) \ + do { \ + if ( (a-> param != GLX_DONT_CARE) \ + && (a-> param != b-> param) ) { \ + return False; \ + } \ + } while ( 0 ) + +#define MATCH_MINIMUM( param ) \ + do { \ + if ( (a-> param != GLX_DONT_CARE) \ + && (a-> param > b-> param) ) { \ + return False; \ + } \ + } while ( 0 ) + +#define MATCH_EXACT( param ) \ + do { \ + if ( a-> param != b-> param) { \ + return False; \ + } \ + } while ( 0 ) + +/** + * Determine if two GLXFBConfigs are compatible. + * + * \param a Application specified config to test. + * \param b Server specified config to test against \c a. + */ +static Bool +fbconfigs_compatible(const __GLcontextModes * const a, + const __GLcontextModes * const b) +{ + MATCH_DONT_CARE(doubleBufferMode); + MATCH_DONT_CARE(visualType); + MATCH_DONT_CARE(visualRating); + MATCH_DONT_CARE(xRenderable); + MATCH_DONT_CARE(fbconfigID); + MATCH_DONT_CARE(swapMethod); + + MATCH_MINIMUM(rgbBits); + MATCH_MINIMUM(numAuxBuffers); + MATCH_MINIMUM(redBits); + MATCH_MINIMUM(greenBits); + MATCH_MINIMUM(blueBits); + MATCH_MINIMUM(alphaBits); + MATCH_MINIMUM(depthBits); + MATCH_MINIMUM(stencilBits); + MATCH_MINIMUM(accumRedBits); + MATCH_MINIMUM(accumGreenBits); + MATCH_MINIMUM(accumBlueBits); + MATCH_MINIMUM(accumAlphaBits); + MATCH_MINIMUM(sampleBuffers); + MATCH_MINIMUM(maxPbufferWidth); + MATCH_MINIMUM(maxPbufferHeight); + MATCH_MINIMUM(maxPbufferPixels); + MATCH_MINIMUM(samples); + + MATCH_DONT_CARE(stereoMode); + MATCH_EXACT(level); + + if (((a->drawableType & b->drawableType) == 0) + || ((a->renderType & b->renderType) == 0)) { + return False; + } + + + /* There is a bug in a few of the XFree86 DDX drivers. They contain + * visuals with a "transparent type" of 0 when they really mean GLX_NONE. + * Technically speaking, it is a bug in the DDX driver, but there is + * enough of an installed base to work around the problem here. In any + * case, 0 is not a valid value of the transparent type, so we'll treat 0 + * from the app as GLX_DONT_CARE. We'll consider GLX_NONE from the app and + * 0 from the server to be a match to maintain backward compatibility with + * the (broken) drivers. + */ + + if (a->transparentPixel != GLX_DONT_CARE && a->transparentPixel != 0) { + if (a->transparentPixel == GLX_NONE) { + if (b->transparentPixel != GLX_NONE && b->transparentPixel != 0) + return False; + } + else { + MATCH_EXACT(transparentPixel); + } + + switch (a->transparentPixel) { + case GLX_TRANSPARENT_RGB: + MATCH_DONT_CARE(transparentRed); + MATCH_DONT_CARE(transparentGreen); + MATCH_DONT_CARE(transparentBlue); + MATCH_DONT_CARE(transparentAlpha); + break; + + case GLX_TRANSPARENT_INDEX: + MATCH_DONT_CARE(transparentIndex); + break; + + default: + break; + } + } + + return True; +} + + +/* There's some trickly language in the GLX spec about how this is supposed + * to work. Basically, if a given component size is either not specified + * or the requested size is zero, it is supposed to act like PERFER_SMALLER. + * Well, that's really hard to do with the code as-is. This behavior is + * closer to correct, but still not technically right. + */ +#define PREFER_LARGER_OR_ZERO(comp) \ + do { \ + if ( ((*a)-> comp) != ((*b)-> comp) ) { \ + if ( ((*a)-> comp) == 0 ) { \ + return -1; \ + } \ + else if ( ((*b)-> comp) == 0 ) { \ + return 1; \ + } \ + else { \ + return ((*b)-> comp) - ((*a)-> comp) ; \ + } \ + } \ + } while( 0 ) + +#define PREFER_LARGER(comp) \ + do { \ + if ( ((*a)-> comp) != ((*b)-> comp) ) { \ + return ((*b)-> comp) - ((*a)-> comp) ; \ + } \ + } while( 0 ) + +#define PREFER_SMALLER(comp) \ + do { \ + if ( ((*a)-> comp) != ((*b)-> comp) ) { \ + return ((*a)-> comp) - ((*b)-> comp) ; \ + } \ + } while( 0 ) + +/** + * Compare two GLXFBConfigs. This function is intended to be used as the + * compare function passed in to qsort. + * + * \returns If \c a is a "better" config, according to the specification of + * SGIX_fbconfig, a number less than zero is returned. If \c b is + * better, then a number greater than zero is return. If both are + * equal, zero is returned. + * \sa qsort, glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX + */ +static int +fbconfig_compare(const __GLcontextModes * const *const a, + const __GLcontextModes * const *const b) +{ + /* The order of these comparisons must NOT change. It is defined by + * the GLX 1.3 spec and ARB_multisample. + */ + + PREFER_SMALLER(visualSelectGroup); + + /* The sort order for the visualRating is GLX_NONE, GLX_SLOW, and + * GLX_NON_CONFORMANT_CONFIG. It just so happens that this is the + * numerical sort order of the enums (0x8000, 0x8001, and 0x800D). + */ + PREFER_SMALLER(visualRating); + + /* This isn't quite right. It is supposed to compare the sum of the + * components the user specifically set minimums for. + */ + PREFER_LARGER_OR_ZERO(redBits); + PREFER_LARGER_OR_ZERO(greenBits); + PREFER_LARGER_OR_ZERO(blueBits); + PREFER_LARGER_OR_ZERO(alphaBits); + + PREFER_SMALLER(rgbBits); + + if (((*a)->doubleBufferMode != (*b)->doubleBufferMode)) { + /* Prefer single-buffer. + */ + return (!(*a)->doubleBufferMode) ? -1 : 1; + } + + PREFER_SMALLER(numAuxBuffers); + + PREFER_LARGER_OR_ZERO(depthBits); + PREFER_SMALLER(stencilBits); + + /* This isn't quite right. It is supposed to compare the sum of the + * components the user specifically set minimums for. + */ + PREFER_LARGER_OR_ZERO(accumRedBits); + PREFER_LARGER_OR_ZERO(accumGreenBits); + PREFER_LARGER_OR_ZERO(accumBlueBits); + PREFER_LARGER_OR_ZERO(accumAlphaBits); + + PREFER_SMALLER(visualType); + + /* None of the multisample specs say where this comparison should happen, + * so I put it near the end. + */ + PREFER_SMALLER(sampleBuffers); + PREFER_SMALLER(samples); + + /* None of the pbuffer or fbconfig specs say that this comparison needs + * to happen at all, but it seems like it should. + */ + PREFER_LARGER(maxPbufferWidth); + PREFER_LARGER(maxPbufferHeight); + PREFER_LARGER(maxPbufferPixels); + + return 0; +} + + +/** + * Selects and sorts a subset of the supplied configs based on the attributes. + * This function forms to basis of \c glXChooseVisual, \c glXChooseFBConfig, + * and \c glXChooseFBConfigSGIX. + * + * \param configs Array of pointers to possible configs. The elements of + * this array that do not meet the criteria will be set to + * NULL. The remaining elements will be sorted according to + * the various visual / FBConfig selection rules. + * \param num_configs Number of elements in the \c configs array. + * \param attribList Attributes used select from \c configs. This array is + * terminated by a \c None tag. The array can either take + * the form expected by \c glXChooseVisual (where boolean + * tags do not have a value) or by \c glXChooseFBConfig + * (where every tag has a value). + * \param fbconfig_style_tags Selects whether \c attribList is in + * \c glXChooseVisual style or + * \c glXChooseFBConfig style. + * \returns The number of valid elements left in \c configs. + * + * \sa glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX + */ +static int +choose_visual(__GLcontextModes ** configs, int num_configs, + const int *attribList, GLboolean fbconfig_style_tags) +{ + __GLcontextModes test_config; + int base; + int i; + + /* This is a fairly direct implementation of the selection method + * described by GLX_SGIX_fbconfig. Start by culling out all the + * configs that are not compatible with the selected parameter + * list. + */ + + init_fbconfig_for_chooser(&test_config, fbconfig_style_tags); + __glXInitializeVisualConfigFromTags(&test_config, 512, + (const INT32 *) attribList, + GL_TRUE, fbconfig_style_tags); + + base = 0; + for (i = 0; i < num_configs; i++) { + if (fbconfigs_compatible(&test_config, configs[i])) { + configs[base] = configs[i]; + base++; + } + } + + if (base == 0) { + return 0; + } + + if (base < num_configs) { + (void) memset(&configs[base], 0, sizeof(void *) * (num_configs - base)); + } + + /* After the incompatible configs are removed, the resulting + * list is sorted according to the rules set out in the various + * specifications. + */ + + qsort(configs, base, sizeof(__GLcontextModes *), + (int (*)(const void *, const void *)) fbconfig_compare); + return base; +} + + + + +/* +** Return the visual that best matches the template. Return None if no +** visual matches the template. +*/ +PUBLIC XVisualInfo * +glXChooseVisual(Display * dpy, int screen, int *attribList) +{ + XVisualInfo *visualList = NULL; + __GLXdisplayPrivate *priv; + __GLXscreenConfigs *psc; + __GLcontextModes test_config; + __GLcontextModes *modes; + const __GLcontextModes *best_config = NULL; + + /* + ** Get a list of all visuals, return if list is empty + */ + if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) { + return None; + } + + + /* + ** Build a template from the defaults and the attribute list + ** Free visual list and return if an unexpected token is encountered + */ + init_fbconfig_for_chooser(&test_config, GL_FALSE); + __glXInitializeVisualConfigFromTags(&test_config, 512, + (const INT32 *) attribList, + GL_TRUE, GL_FALSE); + + /* + ** Eliminate visuals that don't meet minimum requirements + ** Compute a score for those that do + ** Remember which visual, if any, got the highest score + ** If no visual is acceptable, return None + ** Otherwise, create an XVisualInfo list with just the selected X visual + ** and return this. + */ + for (modes = psc->visuals; modes != NULL; modes = modes->next) { + if (fbconfigs_compatible(&test_config, modes) + && ((best_config == NULL) + || + (fbconfig_compare + ((const __GLcontextModes * const *const) &modes, + &best_config) < 0))) { + XVisualInfo visualTemplate; + XVisualInfo *newList; + int i; + + visualTemplate.screen = screen; + visualTemplate.visualid = modes->visualID; + newList = XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask, + &visualTemplate, &i); + + if (newList) { + Xfree(visualList); + visualList = newList; + best_config = modes; + } + } + } + + return visualList; +} + + +PUBLIC const char * +glXQueryExtensionsString(Display * dpy, int screen) +{ + __GLXscreenConfigs *psc; + __GLXdisplayPrivate *priv; + + if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) { + return NULL; + } + + if (!psc->effectiveGLXexts) { + if (!psc->serverGLXexts) { + psc->serverGLXexts = + __glXQueryServerString(dpy, priv->majorOpcode, screen, + GLX_EXTENSIONS); + } + + __glXCalculateUsableExtensions(psc, +#ifdef GLX_DIRECT_RENDERING + (psc->driScreen != NULL), +#else + GL_FALSE, +#endif + priv->minorVersion); + } + + return psc->effectiveGLXexts; +} + +PUBLIC const char * +glXGetClientString(Display * dpy, int name) +{ + switch (name) { + case GLX_VENDOR: + return (__glXGLXClientVendorName); + case GLX_VERSION: + return (__glXGLXClientVersion); + case GLX_EXTENSIONS: + return (__glXGetClientExtensions()); + default: + return NULL; + } +} + +PUBLIC const char * +glXQueryServerString(Display * dpy, int screen, int name) +{ + __GLXscreenConfigs *psc; + __GLXdisplayPrivate *priv; + const char **str; + + + if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) { + return NULL; + } + + switch (name) { + case GLX_VENDOR: + str = &priv->serverGLXvendor; + break; + case GLX_VERSION: + str = &priv->serverGLXversion; + break; + case GLX_EXTENSIONS: + str = &psc->serverGLXexts; + break; + default: + return NULL; + } + + if (*str == NULL) { + *str = __glXQueryServerString(dpy, priv->majorOpcode, screen, name); + } + + return *str; +} + +void +__glXClientInfo(Display * dpy, int opcode) +{ + char *ext_str = __glXGetClientGLExtensionString(); + int size = strlen(ext_str) + 1; + +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + xcb_glx_client_info(c, + GLX_MAJOR_VERSION, GLX_MINOR_VERSION, size, ext_str); +#else + xGLXClientInfoReq *req; + + /* Send the glXClientInfo request */ + LockDisplay(dpy); + GetReq(GLXClientInfo, req); + req->reqType = opcode; + req->glxCode = X_GLXClientInfo; + req->major = GLX_MAJOR_VERSION; + req->minor = GLX_MINOR_VERSION; + + req->length += (size + 3) >> 2; + req->numbytes = size; + Data(dpy, ext_str, size); + + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + + Xfree(ext_str); +} + + +/* +** EXT_import_context +*/ + +PUBLIC Display * +glXGetCurrentDisplay(void) +{ + GLXContext gc = __glXGetCurrentContext(); + if (NULL == gc) + return NULL; + return gc->currentDpy; +} + +PUBLIC +GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (), + glXGetCurrentDisplay) + +/** + * Used internally by libGL to send \c xGLXQueryContextinfoExtReq requests + * to the X-server. + * + * \param dpy Display where \c ctx was created. + * \param ctx Context to query. + * \returns \c Success on success. \c GLX_BAD_CONTEXT if \c ctx is invalid, + * or zero if the request failed due to internal problems (i.e., + * unable to allocate temporary memory, etc.) + * + * \note + * This function dynamically determines whether to use the EXT_import_context + * version of the protocol or the GLX 1.3 version of the protocol. + */ +static int __glXQueryContextInfo(Display * dpy, GLXContext ctx) +{ + __GLXdisplayPrivate *priv = __glXInitialize(dpy); + xGLXQueryContextReply reply; + CARD8 opcode; + GLuint numValues; + int retval; + + if (ctx == NULL) { + return GLX_BAD_CONTEXT; + } + opcode = __glXSetupForCommand(dpy); + if (!opcode) { + return 0; + } + + /* Send the glXQueryContextInfoEXT request */ + LockDisplay(dpy); + + if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { + xGLXQueryContextReq *req; + + GetReq(GLXQueryContext, req); + + req->reqType = opcode; + req->glxCode = X_GLXQueryContext; + req->context = (unsigned int) (ctx->xid); + } + else { + xGLXVendorPrivateReq *vpreq; + xGLXQueryContextInfoEXTReq *req; + + GetReqExtra(GLXVendorPrivate, + sz_xGLXQueryContextInfoEXTReq - sz_xGLXVendorPrivateReq, + vpreq); + req = (xGLXQueryContextInfoEXTReq *) vpreq; + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivateWithReply; + req->vendorCode = X_GLXvop_QueryContextInfoEXT; + req->context = (unsigned int) (ctx->xid); + } + + _XReply(dpy, (xReply *) & reply, 0, False); + + numValues = reply.n; + if (numValues == 0) + retval = Success; + else if (numValues > __GLX_MAX_CONTEXT_PROPS) + retval = 0; + else { + int *propList, *pProp; + int nPropListBytes; + int i; + + nPropListBytes = numValues << 3; + propList = (int *) Xmalloc(nPropListBytes); + if (NULL == propList) { + retval = 0; + } + else { + _XRead(dpy, (char *) propList, nPropListBytes); + pProp = propList; + for (i = 0; i < numValues; i++) { + switch (*pProp++) { + case GLX_SHARE_CONTEXT_EXT: + ctx->share_xid = *pProp++; + break; + case GLX_VISUAL_ID_EXT: + ctx->mode = + _gl_context_modes_find_visual(ctx->psc->visuals, *pProp++); + break; + case GLX_SCREEN: + ctx->screen = *pProp++; + break; + case GLX_FBCONFIG_ID: + ctx->mode = + _gl_context_modes_find_fbconfig(ctx->psc->configs, + *pProp++); + break; + case GLX_RENDER_TYPE: + ctx->renderType = *pProp++; + break; + default: + pProp++; + continue; + } + } + Xfree((char *) propList); + retval = Success; + } + } + UnlockDisplay(dpy); + SyncHandle(); + return retval; +} + +PUBLIC int +glXQueryContext(Display * dpy, GLXContext ctx, int attribute, int *value) +{ + int retVal; + + /* get the information from the server if we don't have it already */ +#ifdef GLX_DIRECT_RENDERING + if (!ctx->driContext && (ctx->mode == NULL)) { +#else + if (ctx->mode == NULL) { +#endif + retVal = __glXQueryContextInfo(dpy, ctx); + if (Success != retVal) + return retVal; + } + switch (attribute) { + case GLX_SHARE_CONTEXT_EXT: + *value = (int) (ctx->share_xid); + break; + case GLX_VISUAL_ID_EXT: + *value = ctx->mode ? ctx->mode->visualID : None; + break; + case GLX_SCREEN: + *value = (int) (ctx->screen); + break; + case GLX_FBCONFIG_ID: + *value = ctx->mode ? ctx->mode->fbconfigID : None; + break; + case GLX_RENDER_TYPE: + *value = (int) (ctx->renderType); + break; + default: + return GLX_BAD_ATTRIBUTE; + } + return Success; +} + +PUBLIC +GLX_ALIAS(int, glXQueryContextInfoEXT, + (Display * dpy, GLXContext ctx, int attribute, int *value), + (dpy, ctx, attribute, value), glXQueryContext) + +PUBLIC GLXContextID glXGetContextIDEXT(const GLXContext ctx) +{ + return ctx->xid; +} + +PUBLIC GLXContext +glXImportContextEXT(Display * dpy, GLXContextID contextID) +{ + GLXContext ctx; + + if (contextID == None) { + return NULL; + } + if (__glXIsDirect(dpy, contextID)) { + return NULL; + } + + ctx = CreateContext(dpy, NULL, NULL, NULL, False, contextID, False, 0); + if (NULL != ctx) { + if (Success != __glXQueryContextInfo(dpy, ctx)) { + return NULL; + } + } + return ctx; +} + +PUBLIC void +glXFreeContextEXT(Display * dpy, GLXContext ctx) +{ + DestroyContext(dpy, ctx); +} + + + +/* + * GLX 1.3 functions - these are just stubs for now! + */ + +PUBLIC GLXFBConfig * +glXChooseFBConfig(Display * dpy, int screen, + const int *attribList, int *nitems) +{ + __GLcontextModes **config_list; + int list_size; + + + config_list = (__GLcontextModes **) + glXGetFBConfigs(dpy, screen, &list_size); + + if ((config_list != NULL) && (list_size > 0) && (attribList != NULL)) { + list_size = choose_visual(config_list, list_size, attribList, GL_TRUE); + if (list_size == 0) { + XFree(config_list); + config_list = NULL; + } + } + + *nitems = list_size; + return (GLXFBConfig *) config_list; +} + + +PUBLIC GLXContext +glXCreateNewContext(Display * dpy, GLXFBConfig config, + int renderType, GLXContext shareList, Bool allowDirect) +{ + return CreateContext(dpy, NULL, (__GLcontextModes *) config, shareList, + allowDirect, None, True, renderType); +} + + +PUBLIC GLXDrawable +glXGetCurrentReadDrawable(void) +{ + GLXContext gc = __glXGetCurrentContext(); + return gc->currentReadable; +} + + +PUBLIC GLXFBConfig * +glXGetFBConfigs(Display * dpy, int screen, int *nelements) +{ + __GLXdisplayPrivate *priv = __glXInitialize(dpy); + __GLcontextModes **config = NULL; + int i; + + *nelements = 0; + if (priv && (priv->screenConfigs != NULL) + && (screen >= 0) && (screen <= ScreenCount(dpy)) + && (priv->screenConfigs[screen].configs != NULL) + && (priv->screenConfigs[screen].configs->fbconfigID != GLX_DONT_CARE)) { + unsigned num_configs = 0; + __GLcontextModes *modes; + + + for (modes = priv->screenConfigs[screen].configs; modes != NULL; + modes = modes->next) { + if (modes->fbconfigID != GLX_DONT_CARE) { + num_configs++; + } + } + + config = (__GLcontextModes **) Xmalloc(sizeof(__GLcontextModes *) + * num_configs); + if (config != NULL) { + *nelements = num_configs; + i = 0; + for (modes = priv->screenConfigs[screen].configs; modes != NULL; + modes = modes->next) { + if (modes->fbconfigID != GLX_DONT_CARE) { + config[i] = modes; + i++; + } + } + } + } + return (GLXFBConfig *) config; +} + + +PUBLIC int +glXGetFBConfigAttrib(Display * dpy, GLXFBConfig config, + int attribute, int *value) +{ + __GLcontextModes *const modes = ValidateGLXFBConfig(dpy, config); + + return (modes != NULL) + ? _gl_get_context_mode_data(modes, attribute, value) + : GLXBadFBConfig; +} + + +PUBLIC XVisualInfo * +glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig config) +{ + XVisualInfo visualTemplate; + __GLcontextModes *fbconfig = (__GLcontextModes *) config; + int count; + + /* + ** Get a list of all visuals, return if list is empty + */ + visualTemplate.visualid = fbconfig->visualID; + return XGetVisualInfo(dpy, VisualIDMask, &visualTemplate, &count); +} + + +/* +** GLX_SGI_swap_control +*/ +static int +__glXSwapIntervalSGI(int interval) +{ + xGLXVendorPrivateReq *req; + GLXContext gc = __glXGetCurrentContext(); + __GLXscreenConfigs *psc; + Display *dpy; + CARD32 *interval_ptr; + CARD8 opcode; + + if (gc == NULL) { + return GLX_BAD_CONTEXT; + } + + if (interval <= 0) { + return GLX_BAD_VALUE; + } + +#ifdef __DRI_SWAP_CONTROL + if (gc->driContext) { + __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, + gc->screen ); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, + gc->currentDrawable, + NULL); + if (psc->swapControl != NULL && pdraw != NULL) { + psc->swapControl->setSwapInterval(pdraw->driDrawable, interval); + return 0; + } + else if (pdraw == NULL) { + return GLX_BAD_CONTEXT; + } + } +#endif + psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); + + if (gc->driContext && psc->driScreen && psc->driScreen->setSwapInterval) { + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, + gc->currentDrawable, + NULL); + psc->driScreen->setSwapInterval(pdraw, interval); + return 0; + } + + dpy = gc->currentDpy; + opcode = __glXSetupForCommand(dpy); + if (!opcode) { + return 0; + } + + /* Send the glXSwapIntervalSGI request */ + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, sizeof(CARD32), req); + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivate; + req->vendorCode = X_GLXvop_SwapIntervalSGI; + req->contextTag = gc->currentContextTag; + + interval_ptr = (CARD32 *) (req + 1); + *interval_ptr = interval; + + UnlockDisplay(dpy); + SyncHandle(); + XFlush(dpy); + + return 0; +} + + +/* +** GLX_MESA_swap_control +*/ +static int +__glXSwapIntervalMESA(unsigned int interval) +{ + GLXContext gc = __glXGetCurrentContext(); + + if (interval < 0) { + return GLX_BAD_VALUE; + } + +#ifdef __DRI_SWAP_CONTROL + if (gc != NULL && gc->driContext) { + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy, + gc->screen); + + if ((psc != NULL) && (psc->driScreen != NULL)) { + __GLXDRIdrawable *pdraw = + GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); + if (psc->swapControl != NULL && pdraw != NULL) { + psc->swapControl->setSwapInterval(pdraw->driDrawable, interval); + return 0; + } + } + } +#endif + + if (gc != NULL && gc->driContext) { + __GLXscreenConfigs *psc; + + psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); + if (psc->driScreen && psc->driScreen->setSwapInterval) { + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, + gc->currentDrawable, NULL); + psc->driScreen->setSwapInterval(pdraw, interval); + return 0; + } + } + + return GLX_BAD_CONTEXT; +} + + +static int +__glXGetSwapIntervalMESA(void) +{ +#ifdef __DRI_SWAP_CONTROL + GLXContext gc = __glXGetCurrentContext(); + + if (gc != NULL && gc->driContext) { + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy, + gc->screen); + + if ((psc != NULL) && (psc->driScreen != NULL)) { + __GLXDRIdrawable *pdraw = + GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); + if (psc->swapControl != NULL && pdraw != NULL) { + return psc->swapControl->getSwapInterval(pdraw->driDrawable); + } + } + } +#endif + if (gc != NULL && gc->driContext) { + __GLXscreenConfigs *psc; + + psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); + if (psc->driScreen && psc->driScreen->getSwapInterval) { + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, + gc->currentDrawable, NULL); + return psc->driScreen->getSwapInterval(pdraw); + } + } + + return 0; +} + + +/* +** GLX_MESA_swap_frame_usage +*/ + +static GLint +__glXBeginFrameTrackingMESA(Display * dpy, GLXDrawable drawable) +{ + int status = GLX_BAD_CONTEXT; +#ifdef __DRI_FRAME_TRACKING + int screen = 0; + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); + + if (pdraw != NULL && psc->frameTracking != NULL) + status = psc->frameTracking->frameTracking(pdraw->driDrawable, GL_TRUE); +#else + (void) dpy; + (void) drawable; +#endif + return status; +} + + +static GLint +__glXEndFrameTrackingMESA(Display * dpy, GLXDrawable drawable) +{ + int status = GLX_BAD_CONTEXT; +#ifdef __DRI_FRAME_TRACKING + int screen = 0; + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); + __GLXscreenConfigs *psc = GetGLXScreenConfigs(dpy, screen); + + if (pdraw != NULL && psc->frameTracking != NULL) + status = psc->frameTracking->frameTracking(pdraw->driDrawable, + GL_FALSE); +#else + (void) dpy; + (void) drawable; +#endif + return status; +} + + +static GLint +__glXGetFrameUsageMESA(Display * dpy, GLXDrawable drawable, GLfloat * usage) +{ + int status = GLX_BAD_CONTEXT; +#ifdef __DRI_FRAME_TRACKING + int screen = 0; + __GLXDRIdrawable *const pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); + + if (pdraw != NULL && psc->frameTracking != NULL) { + int64_t sbc, missedFrames; + float lastMissedUsage; + + status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable, + &sbc, + &missedFrames, + &lastMissedUsage, + usage); + } +#else + (void) dpy; + (void) drawable; + (void) usage; +#endif + return status; +} + + +static GLint +__glXQueryFrameTrackingMESA(Display * dpy, GLXDrawable drawable, + int64_t * sbc, int64_t * missedFrames, + GLfloat * lastMissedUsage) +{ + int status = GLX_BAD_CONTEXT; +#ifdef __DRI_FRAME_TRACKING + int screen = 0; + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); + + if (pdraw != NULL && psc->frameTracking != NULL) { + float usage; + + status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable, + sbc, missedFrames, + lastMissedUsage, + &usage); + } +#else + (void) dpy; + (void) drawable; + (void) sbc; + (void) missedFrames; + (void) lastMissedUsage; +#endif + return status; +} + + +/* +** GLX_SGI_video_sync +*/ +static int +__glXGetVideoSyncSGI(unsigned int *count) +{ + int64_t ust, msc, sbc; + int ret; + GLXContext gc = __glXGetCurrentContext(); + __GLXscreenConfigs *psc; + __GLXDRIdrawable *pdraw; + + if (!gc || !gc->driContext) + return GLX_BAD_CONTEXT; + + psc = GetGLXScreenConfigs(gc->currentDpy, gc->screen); + pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); + + /* FIXME: Looking at the GLX_SGI_video_sync spec in the extension registry, + * FIXME: there should be a GLX encoding for this call. I can find no + * FIXME: documentation for the GLX encoding. + */ +#ifdef __DRI_MEDIA_STREAM_COUNTER + if ( psc->msc && psc->driScreen ) { + ret = (*psc->msc->getDrawableMSC)(psc->__driScreen, + pdraw->driDrawable, &msc); + *count = (unsigned) msc; + + return (ret == 0) ? 0 : GLX_BAD_CONTEXT; + } +#endif + if (psc->driScreen && psc->driScreen->getDrawableMSC) { + ret = psc->driScreen->getDrawableMSC(psc, pdraw, &ust, &msc, &sbc); + *count = (unsigned) msc; + return (ret == True) ? 0 : GLX_BAD_CONTEXT; + } + + return GLX_BAD_CONTEXT; +} + +static int +__glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) +{ + GLXContext gc = __glXGetCurrentContext(); + __GLXscreenConfigs *psc; + __GLXDRIdrawable *pdraw; + int64_t ust, msc, sbc; + int ret; + + if (divisor <= 0 || remainder < 0) + return GLX_BAD_VALUE; + + if (!gc || !gc->driContext) + return GLX_BAD_CONTEXT; + + psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); + pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); + +#ifdef __DRI_MEDIA_STREAM_COUNTER + if (psc->msc != NULL && psc->driScreen ) { + ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, 0, + divisor, remainder, &msc, &sbc); + *count = (unsigned) msc; + return (ret == 0) ? 0 : GLX_BAD_CONTEXT; + } +#endif + if (psc->driScreen && psc->driScreen->waitForMSC) { + ret = psc->driScreen->waitForMSC(pdraw, 0, divisor, remainder, &ust, &msc, + &sbc); + *count = (unsigned) msc; + return (ret == True) ? 0 : GLX_BAD_CONTEXT; + } + + return GLX_BAD_CONTEXT; +} + + +/* +** GLX_SGIX_fbconfig +** Many of these functions are aliased to GLX 1.3 entry points in the +** GLX_functions table. +*/ + +PUBLIC +GLX_ALIAS(int, glXGetFBConfigAttribSGIX, + (Display * dpy, GLXFBConfigSGIX config, int attribute, int *value), + (dpy, config, attribute, value), glXGetFBConfigAttrib) + +PUBLIC GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX, + (Display * dpy, int screen, int *attrib_list, + int *nelements), (dpy, screen, attrib_list, nelements), + glXChooseFBConfig) + +PUBLIC GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX, + (Display * dpy, GLXFBConfigSGIX config), + (dpy, config), glXGetVisualFromFBConfig) + +PUBLIC GLXPixmap +glXCreateGLXPixmapWithConfigSGIX(Display * dpy, + GLXFBConfigSGIX config, + Pixmap pixmap) +{ + xGLXVendorPrivateWithReplyReq *vpreq; + xGLXCreateGLXPixmapWithConfigSGIXReq *req; + GLXPixmap xid = None; + CARD8 opcode; + const __GLcontextModes *const fbconfig = (__GLcontextModes *) config; + __GLXscreenConfigs *psc; + + + if ((dpy == NULL) || (config == NULL)) { + return None; + } + + psc = GetGLXScreenConfigs(dpy, fbconfig->screen); + if ((psc != NULL) + && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) { + opcode = __glXSetupForCommand(dpy); + if (!opcode) { + return None; + } + + /* Send the glXCreateGLXPixmapWithConfigSGIX request */ + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivateWithReply, + sz_xGLXCreateGLXPixmapWithConfigSGIXReq - + sz_xGLXVendorPrivateWithReplyReq, vpreq); + req = (xGLXCreateGLXPixmapWithConfigSGIXReq *) vpreq; + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivateWithReply; + req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX; + req->screen = fbconfig->screen; + req->fbconfig = fbconfig->fbconfigID; + req->pixmap = pixmap; + req->glxpixmap = xid = XAllocID(dpy); + UnlockDisplay(dpy); + SyncHandle(); + } + + return xid; +} + +PUBLIC GLXContext +glXCreateContextWithConfigSGIX(Display * dpy, + GLXFBConfigSGIX config, int renderType, + GLXContext shareList, Bool allowDirect) +{ + GLXContext gc = NULL; + const __GLcontextModes *const fbconfig = (__GLcontextModes *) config; + __GLXscreenConfigs *psc; + + + if ((dpy == NULL) || (config == NULL)) { + return None; + } + + psc = GetGLXScreenConfigs(dpy, fbconfig->screen); + if ((psc != NULL) + && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) { + gc = CreateContext(dpy, NULL, (__GLcontextModes *) config, shareList, + allowDirect, None, False, renderType); + } + + return gc; +} + + +PUBLIC GLXFBConfigSGIX +glXGetFBConfigFromVisualSGIX(Display * dpy, XVisualInfo * vis) +{ + __GLXdisplayPrivate *priv; + __GLXscreenConfigs *psc = NULL; + + if ((GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc) != Success) + && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit) + && (psc->configs->fbconfigID != GLX_DONT_CARE)) { + return (GLXFBConfigSGIX) _gl_context_modes_find_visual(psc->configs, + vis->visualid); + } + + return NULL; +} + + +/* +** GLX_SGIX_swap_group +*/ +static void +__glXJoinSwapGroupSGIX(Display * dpy, GLXDrawable drawable, + GLXDrawable member) +{ + (void) dpy; + (void) drawable; + (void) member; +} + + +/* +** GLX_SGIX_swap_barrier +*/ +static void +__glXBindSwapBarrierSGIX(Display * dpy, GLXDrawable drawable, int barrier) +{ + (void) dpy; + (void) drawable; + (void) barrier; +} + +static Bool +__glXQueryMaxSwapBarriersSGIX(Display * dpy, int screen, int *max) +{ + (void) dpy; + (void) screen; + (void) max; + return False; +} + + +/* +** GLX_OML_sync_control +*/ +static Bool +__glXGetSyncValuesOML(Display * dpy, GLXDrawable drawable, + int64_t * ust, int64_t * msc, int64_t * sbc) +{ + __GLXdisplayPrivate * const priv = __glXInitialize(dpy); + int i, ret; + __GLXDRIdrawable *pdraw; + __GLXscreenConfigs *psc; + + if (!priv) + return False; + + pdraw = GetGLXDRIDrawable(dpy, drawable, &i); + psc = &priv->screenConfigs[i]; + +#if defined(__DRI_SWAP_BUFFER_COUNTER) && defined(__DRI_MEDIA_STREAM_COUNTER) + if (pdraw && psc->sbc && psc->sbc) + return ( (pdraw && psc->sbc && psc->msc) + && ((*psc->msc->getMSC)(psc->driScreen, msc) == 0) + && ((*psc->sbc->getSBC)(pdraw->driDrawable, sbc) == 0) + && (__glXGetUST(ust) == 0) ); +#endif + if (pdraw && psc && psc->driScreen && psc->driScreen->getDrawableMSC) { + ret = psc->driScreen->getDrawableMSC(psc, pdraw, ust, msc, sbc); + return ret; + } + + return False; +} + +#ifdef GLX_DIRECT_RENDERING +_X_HIDDEN GLboolean +__driGetMscRateOML(__DRIdrawable * draw, + int32_t * numerator, int32_t * denominator, void *private) +{ +#ifdef XF86VIDMODE + __GLXscreenConfigs *psc; + XF86VidModeModeLine mode_line; + int dot_clock; + int i; + __GLXDRIdrawable *glxDraw = private; + + psc = glxDraw->psc; + if (XF86VidModeQueryVersion(psc->dpy, &i, &i) && + XF86VidModeGetModeLine(psc->dpy, psc->scr, &dot_clock, &mode_line)) { + unsigned n = dot_clock * 1000; + unsigned d = mode_line.vtotal * mode_line.htotal; + +# define V_INTERLACE 0x010 +# define V_DBLSCAN 0x020 + + if (mode_line.flags & V_INTERLACE) + n *= 2; + else if (mode_line.flags & V_DBLSCAN) + d *= 2; + + /* The OML_sync_control spec requires that if the refresh rate is a + * whole number, that the returned numerator be equal to the refresh + * rate and the denominator be 1. + */ + + if (n % d == 0) { + n /= d; + d = 1; + } + else { + static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 }; + + /* This is a poor man's way to reduce a fraction. It's far from + * perfect, but it will work well enough for this situation. + */ + + for (i = 0; f[i] != 0; i++) { + while (n % f[i] == 0 && d % f[i] == 0) { + d /= f[i]; + n /= f[i]; + } + } + } + + *numerator = n; + *denominator = d; + + return True; + } + else + return False; +#else + return False; +#endif +} +#endif + +/** + * Determine the refresh rate of the specified drawable and display. + * + * \param dpy Display whose refresh rate is to be determined. + * \param drawable Drawable whose refresh rate is to be determined. + * \param numerator Numerator of the refresh rate. + * \param demoninator Denominator of the refresh rate. + * \return If the refresh rate for the specified display and drawable could + * be calculated, True is returned. Otherwise False is returned. + * + * \note This function is implemented entirely client-side. A lot of other + * functionality is required to export GLX_OML_sync_control, so on + * XFree86 this function can be called for direct-rendering contexts + * when GLX_OML_sync_control appears in the client extension string. + */ + +_X_HIDDEN GLboolean +__glXGetMscRateOML(Display * dpy, GLXDrawable drawable, + int32_t * numerator, int32_t * denominator) +{ +#if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE ) + __GLXDRIdrawable *draw = GetGLXDRIDrawable(dpy, drawable, NULL); + + if (draw == NULL) + return False; + + return __driGetMscRateOML(draw->driDrawable, numerator, denominator, draw); +#else + (void) dpy; + (void) drawable; + (void) numerator; + (void) denominator; +#endif + return False; +} + + +static int64_t +__glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable, + int64_t target_msc, int64_t divisor, int64_t remainder) +{ + GLXContext gc = __glXGetCurrentContext(); + int screen; + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); + + if (!pdraw || !gc->driContext) /* no GLX for this */ + return -1; + + /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE + * error", but it also says "It [glXSwapBuffersMscOML] will return a value + * of -1 if the function failed because of errors detected in the input + * parameters" + */ + if (divisor < 0 || remainder < 0 || target_msc < 0) + return -1; + if (divisor > 0 && remainder >= divisor) + return -1; + +#ifdef __DRI_SWAP_BUFFER_COUNTER + if (psc->counters != NULL) + return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc, + divisor, remainder); +#endif + +#ifdef GLX_DIRECT_RENDERING + if (psc->driScreen && psc->driScreen->swapBuffers) + return (*psc->driScreen->swapBuffers)(pdraw, target_msc, divisor, + remainder); +#endif + + return -1; +} + + +static Bool +__glXWaitForMscOML(Display * dpy, GLXDrawable drawable, + int64_t target_msc, int64_t divisor, + int64_t remainder, int64_t * ust, + int64_t * msc, int64_t * sbc) +{ + int screen; + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); + __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); + int ret; + + fprintf(stderr, "waitmsc: %lld, %lld, %lld\n", target_msc, divisor, + remainder); + + /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE + * error", but the return type in the spec is Bool. + */ + if (divisor < 0 || remainder < 0 || target_msc < 0) + return False; + if (divisor > 0 && remainder >= divisor) + return False; + +#ifdef __DRI_MEDIA_STREAM_COUNTER + if (pdraw != NULL && psc->msc != NULL) { + fprintf(stderr, "dri1 msc\n"); + ret = (*psc->msc->waitForMSC) (pdraw->driDrawable, target_msc, + divisor, remainder, msc, sbc); + + /* __glXGetUST returns zero on success and non-zero on failure. + * This function returns True on success and False on failure. + */ + return ((ret == 0) && (__glXGetUST(ust) == 0)); + } +#endif + if (pdraw && psc->driScreen && psc->driScreen->waitForMSC) { + ret = psc->driScreen->waitForMSC(pdraw, target_msc, divisor, remainder, + ust, msc, sbc); + return ret; + } + + fprintf(stderr, "no drawable??\n"); + return False; +} + + +static Bool +__glXWaitForSbcOML(Display * dpy, GLXDrawable drawable, + int64_t target_sbc, int64_t * ust, + int64_t * msc, int64_t * sbc) +{ + int screen; + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); + int ret; + + /* The OML_sync_control spec says this should "generate a GLX_BAD_VALUE + * error", but the return type in the spec is Bool. + */ + if (target_sbc < 0) + return False; +#ifdef __DRI_SWAP_BUFFER_COUNTER + if (pdraw != NULL && psc->sbc != NULL) { + ret = + (*psc->sbc->waitForSBC) (pdraw->driDrawable, target_sbc, msc, sbc); + + /* __glXGetUST returns zero on success and non-zero on failure. + * This function returns True on success and False on failure. + */ + return ((ret == 0) && (__glXGetUST(ust) == 0)); + } +#endif + if (pdraw && psc->driScreen && psc->driScreen->waitForMSC) { + ret = psc->driScreen->waitForSBC(pdraw, target_sbc, ust, msc, sbc); + return ret; + } + return False; +} + + +/** + * GLX_MESA_allocate_memory + */ +/*@{*/ + +PUBLIC void * +glXAllocateMemoryMESA(Display * dpy, int scrn, + size_t size, float readFreq, + float writeFreq, float priority) +{ +#ifdef __DRI_ALLOCATE + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn); + + if (psc && psc->allocate) + return (*psc->allocate->allocateMemory) (psc->__driScreen, size, + readFreq, writeFreq, priority); + +#else + (void) dpy; + (void) scrn; + (void) size; + (void) readFreq; + (void) writeFreq; + (void) priority; +#endif /* __DRI_ALLOCATE */ + + return NULL; +} + + +PUBLIC void +glXFreeMemoryMESA(Display * dpy, int scrn, void *pointer) +{ +#ifdef __DRI_ALLOCATE + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn); + + if (psc && psc->allocate) + (*psc->allocate->freeMemory) (psc->__driScreen, pointer); + +#else + (void) dpy; + (void) scrn; + (void) pointer; +#endif /* __DRI_ALLOCATE */ +} + + +PUBLIC GLuint +glXGetMemoryOffsetMESA(Display * dpy, int scrn, const void *pointer) +{ +#ifdef __DRI_ALLOCATE + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn); + + if (psc && psc->allocate) + return (*psc->allocate->memoryOffset) (psc->__driScreen, pointer); + +#else + (void) dpy; + (void) scrn; + (void) pointer; +#endif /* GLX_DIRECT_RENDERING */ + + return ~0L; +} + +/*@}*/ + + +/** + * Mesa extension stubs. These will help reduce portability problems. + */ +/*@{*/ + +/** + * Release all buffers associated with the specified GLX drawable. + * + * \todo + * This function was intended for stand-alone Mesa. The issue there is that + * the library doesn't get any notification when a window is closed. In + * DRI there is a similar but slightly different issue. When GLX 1.3 is + * supported, there are 3 different functions to destroy a drawable. It + * should be possible to create GLX protocol (or have it determine which + * protocol to use based on the type of the drawable) to have one function + * do the work of 3. For the direct-rendering case, this function could + * just call the driver's \c __DRIdrawableRec::destroyDrawable function. + * This would reduce the frequency with which \c __driGarbageCollectDrawables + * would need to be used. This really should be done as part of the new DRI + * interface work. + * + * \sa http://oss.sgi.com/projects/ogl-sample/registry/MESA/release_buffers.txt + * __driGarbageCollectDrawables + * glXDestroyGLXPixmap + * glXDestroyPbuffer glXDestroyPixmap glXDestroyWindow + * glXDestroyGLXPbufferSGIX glXDestroyGLXVideoSourceSGIX + */ +static Bool +__glXReleaseBuffersMESA(Display * dpy, GLXDrawable d) +{ + (void) dpy; + (void) d; + return False; +} + + +PUBLIC GLXPixmap +glXCreateGLXPixmapMESA(Display * dpy, XVisualInfo * visual, + Pixmap pixmap, Colormap cmap) +{ + (void) dpy; + (void) visual; + (void) pixmap; + (void) cmap; + return 0; +} + +/*@}*/ + + +/** + * GLX_MESA_copy_sub_buffer + */ +#define X_GLXvop_CopySubBufferMESA 5154 /* temporary */ +static void +__glXCopySubBufferMESA(Display * dpy, GLXDrawable drawable, + int x, int y, int width, int height) +{ + xGLXVendorPrivateReq *req; + GLXContext gc; + GLXContextTag tag; + CARD32 *drawable_ptr; + INT32 *x_ptr, *y_ptr, *w_ptr, *h_ptr; + CARD8 opcode; + +#ifdef __DRI_COPY_SUB_BUFFER + int screen; + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); + if (pdraw != NULL) { + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); + if (psc->driScreen->copySubBuffer != NULL) { + glFlush(); + (*psc->driScreen->copySubBuffer) (pdraw, x, y, width, height); + } + + return; + } +#endif + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return; + + /* + ** The calling thread may or may not have a current context. If it + ** does, send the context tag so the server can do a flush. + */ + gc = __glXGetCurrentContext(); + if ((gc != NULL) && (dpy == gc->currentDpy) && + ((drawable == gc->currentDrawable) || + (drawable == gc->currentReadable))) { + tag = gc->currentContextTag; + } + else { + tag = 0; + } + + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32) * 4, req); + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivate; + req->vendorCode = X_GLXvop_CopySubBufferMESA; + req->contextTag = tag; + + drawable_ptr = (CARD32 *) (req + 1); + x_ptr = (INT32 *) (drawable_ptr + 1); + y_ptr = (INT32 *) (drawable_ptr + 2); + w_ptr = (INT32 *) (drawable_ptr + 3); + h_ptr = (INT32 *) (drawable_ptr + 4); + + *drawable_ptr = drawable; + *x_ptr = x; + *y_ptr = y; + *w_ptr = width; + *h_ptr = height; + + UnlockDisplay(dpy); + SyncHandle(); +} + + +/** + * GLX_EXT_texture_from_pixmap + */ +/*@{*/ +static void +__glXBindTexImageEXT(Display * dpy, + GLXDrawable drawable, int buffer, const int *attrib_list) +{ + xGLXVendorPrivateReq *req; + GLXContext gc = __glXGetCurrentContext(); + CARD32 *drawable_ptr; + INT32 *buffer_ptr; + CARD32 *num_attrib_ptr; + CARD32 *attrib_ptr; + CARD8 opcode; + unsigned int i; + + if (gc == NULL) + return; + + i = 0; + if (attrib_list) { + while (attrib_list[i * 2] != None) + i++; + } + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); + + if (pdraw != NULL) { + if (pdraw->psc->texBuffer->base.version >= 2 && + pdraw->psc->texBuffer->setTexBuffer2 != NULL) { + (*pdraw->psc->texBuffer->setTexBuffer2) (gc->__driContext, + pdraw->textureTarget, + pdraw->textureFormat, + pdraw->driDrawable); + } + else { + (*pdraw->psc->texBuffer->setTexBuffer) (gc->__driContext, + pdraw->textureTarget, + pdraw->driDrawable); + } + } + return; + } +#endif + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return; + + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, 12 + 8 * i, req); + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivate; + req->vendorCode = X_GLXvop_BindTexImageEXT; + req->contextTag = gc->currentContextTag; + + drawable_ptr = (CARD32 *) (req + 1); + buffer_ptr = (INT32 *) (drawable_ptr + 1); + num_attrib_ptr = (CARD32 *) (buffer_ptr + 1); + attrib_ptr = (CARD32 *) (num_attrib_ptr + 1); + + *drawable_ptr = drawable; + *buffer_ptr = buffer; + *num_attrib_ptr = (CARD32) i; + + i = 0; + if (attrib_list) { + while (attrib_list[i * 2] != None) { + *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 0]; + *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 1]; + i++; + } + } + + UnlockDisplay(dpy); + SyncHandle(); +} + +static void +__glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer) +{ + xGLXVendorPrivateReq *req; + GLXContext gc = __glXGetCurrentContext(); + CARD32 *drawable_ptr; + INT32 *buffer_ptr; + CARD8 opcode; + + if (gc == NULL) + return; + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) + return; +#endif + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return; + + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32), req); + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivate; + req->vendorCode = X_GLXvop_ReleaseTexImageEXT; + req->contextTag = gc->currentContextTag; + + drawable_ptr = (CARD32 *) (req + 1); + buffer_ptr = (INT32 *) (drawable_ptr + 1); + + *drawable_ptr = drawable; + *buffer_ptr = buffer; + + UnlockDisplay(dpy); + SyncHandle(); +} + +/*@}*/ + +/** + * \c strdup is actually not a standard ANSI C or POSIX routine. + * Irix will not define it if ANSI mode is in effect. + * + * \sa strdup + */ +_X_HIDDEN char * +__glXstrdup(const char *str) +{ + char *copy; + copy = (char *) Xmalloc(strlen(str) + 1); + if (!copy) + return NULL; + strcpy(copy, str); + return copy; +} + +/* +** glXGetProcAddress support +*/ + +struct name_address_pair +{ + const char *Name; + GLvoid *Address; +}; + +#define GLX_FUNCTION(f) { # f, (GLvoid *) f } +#define GLX_FUNCTION2(n,f) { # n, (GLvoid *) f } + +static const struct name_address_pair GLX_functions[] = { + /*** GLX_VERSION_1_0 ***/ + GLX_FUNCTION(glXChooseVisual), + GLX_FUNCTION(glXCopyContext), + GLX_FUNCTION(glXCreateContext), + GLX_FUNCTION(glXCreateGLXPixmap), + GLX_FUNCTION(glXDestroyContext), + GLX_FUNCTION(glXDestroyGLXPixmap), + GLX_FUNCTION(glXGetConfig), + GLX_FUNCTION(glXGetCurrentContext), + GLX_FUNCTION(glXGetCurrentDrawable), + GLX_FUNCTION(glXIsDirect), + GLX_FUNCTION(glXMakeCurrent), + GLX_FUNCTION(glXQueryExtension), + GLX_FUNCTION(glXQueryVersion), + GLX_FUNCTION(glXSwapBuffers), + GLX_FUNCTION(glXUseXFont), + GLX_FUNCTION(glXWaitGL), + GLX_FUNCTION(glXWaitX), + + /*** GLX_VERSION_1_1 ***/ + GLX_FUNCTION(glXGetClientString), + GLX_FUNCTION(glXQueryExtensionsString), + GLX_FUNCTION(glXQueryServerString), + + /*** GLX_VERSION_1_2 ***/ + GLX_FUNCTION(glXGetCurrentDisplay), + + /*** GLX_VERSION_1_3 ***/ + GLX_FUNCTION(glXChooseFBConfig), + GLX_FUNCTION(glXCreateNewContext), + GLX_FUNCTION(glXCreatePbuffer), + GLX_FUNCTION(glXCreatePixmap), + GLX_FUNCTION(glXCreateWindow), + GLX_FUNCTION(glXDestroyPbuffer), + GLX_FUNCTION(glXDestroyPixmap), + GLX_FUNCTION(glXDestroyWindow), + GLX_FUNCTION(glXGetCurrentReadDrawable), + GLX_FUNCTION(glXGetFBConfigAttrib), + GLX_FUNCTION(glXGetFBConfigs), + GLX_FUNCTION(glXGetSelectedEvent), + GLX_FUNCTION(glXGetVisualFromFBConfig), + GLX_FUNCTION(glXMakeContextCurrent), + GLX_FUNCTION(glXQueryContext), + GLX_FUNCTION(glXQueryDrawable), + GLX_FUNCTION(glXSelectEvent), + + /*** GLX_SGI_swap_control ***/ + GLX_FUNCTION2(glXSwapIntervalSGI, __glXSwapIntervalSGI), + + /*** GLX_SGI_video_sync ***/ + GLX_FUNCTION2(glXGetVideoSyncSGI, __glXGetVideoSyncSGI), + GLX_FUNCTION2(glXWaitVideoSyncSGI, __glXWaitVideoSyncSGI), + + /*** GLX_SGI_make_current_read ***/ + GLX_FUNCTION2(glXMakeCurrentReadSGI, glXMakeContextCurrent), + GLX_FUNCTION2(glXGetCurrentReadDrawableSGI, glXGetCurrentReadDrawable), + + /*** GLX_EXT_import_context ***/ + GLX_FUNCTION(glXFreeContextEXT), + GLX_FUNCTION(glXGetContextIDEXT), + GLX_FUNCTION2(glXGetCurrentDisplayEXT, glXGetCurrentDisplay), + GLX_FUNCTION(glXImportContextEXT), + GLX_FUNCTION2(glXQueryContextInfoEXT, glXQueryContext), + + /*** GLX_SGIX_fbconfig ***/ + GLX_FUNCTION2(glXGetFBConfigAttribSGIX, glXGetFBConfigAttrib), + GLX_FUNCTION2(glXChooseFBConfigSGIX, glXChooseFBConfig), + GLX_FUNCTION(glXCreateGLXPixmapWithConfigSGIX), + GLX_FUNCTION(glXCreateContextWithConfigSGIX), + GLX_FUNCTION2(glXGetVisualFromFBConfigSGIX, glXGetVisualFromFBConfig), + GLX_FUNCTION(glXGetFBConfigFromVisualSGIX), + + /*** GLX_SGIX_pbuffer ***/ + GLX_FUNCTION(glXCreateGLXPbufferSGIX), + GLX_FUNCTION(glXDestroyGLXPbufferSGIX), + GLX_FUNCTION(glXQueryGLXPbufferSGIX), + GLX_FUNCTION(glXSelectEventSGIX), + GLX_FUNCTION(glXGetSelectedEventSGIX), + + /*** GLX_SGIX_swap_group ***/ + GLX_FUNCTION2(glXJoinSwapGroupSGIX, __glXJoinSwapGroupSGIX), + + /*** GLX_SGIX_swap_barrier ***/ + GLX_FUNCTION2(glXBindSwapBarrierSGIX, __glXBindSwapBarrierSGIX), + GLX_FUNCTION2(glXQueryMaxSwapBarriersSGIX, __glXQueryMaxSwapBarriersSGIX), + + /*** GLX_MESA_allocate_memory ***/ + GLX_FUNCTION(glXAllocateMemoryMESA), + GLX_FUNCTION(glXFreeMemoryMESA), + GLX_FUNCTION(glXGetMemoryOffsetMESA), + + /*** GLX_MESA_copy_sub_buffer ***/ + GLX_FUNCTION2(glXCopySubBufferMESA, __glXCopySubBufferMESA), + + /*** GLX_MESA_pixmap_colormap ***/ + GLX_FUNCTION(glXCreateGLXPixmapMESA), + + /*** GLX_MESA_release_buffers ***/ + GLX_FUNCTION2(glXReleaseBuffersMESA, __glXReleaseBuffersMESA), + + /*** GLX_MESA_swap_control ***/ + GLX_FUNCTION2(glXSwapIntervalMESA, __glXSwapIntervalMESA), + GLX_FUNCTION2(glXGetSwapIntervalMESA, __glXGetSwapIntervalMESA), + + /*** GLX_MESA_swap_frame_usage ***/ + GLX_FUNCTION2(glXBeginFrameTrackingMESA, __glXBeginFrameTrackingMESA), + GLX_FUNCTION2(glXEndFrameTrackingMESA, __glXEndFrameTrackingMESA), + GLX_FUNCTION2(glXGetFrameUsageMESA, __glXGetFrameUsageMESA), + GLX_FUNCTION2(glXQueryFrameTrackingMESA, __glXQueryFrameTrackingMESA), + + /*** GLX_ARB_get_proc_address ***/ + GLX_FUNCTION(glXGetProcAddressARB), + + /*** GLX 1.4 ***/ + GLX_FUNCTION2(glXGetProcAddress, glXGetProcAddressARB), + + /*** GLX_OML_sync_control ***/ + GLX_FUNCTION2(glXWaitForSbcOML, __glXWaitForSbcOML), + GLX_FUNCTION2(glXWaitForMscOML, __glXWaitForMscOML), + GLX_FUNCTION2(glXSwapBuffersMscOML, __glXSwapBuffersMscOML), + GLX_FUNCTION2(glXGetMscRateOML, __glXGetMscRateOML), + GLX_FUNCTION2(glXGetSyncValuesOML, __glXGetSyncValuesOML), + + /*** GLX_EXT_texture_from_pixmap ***/ + GLX_FUNCTION2(glXBindTexImageEXT, __glXBindTexImageEXT), + GLX_FUNCTION2(glXReleaseTexImageEXT, __glXReleaseTexImageEXT), + +#ifdef GLX_DIRECT_RENDERING + /*** DRI configuration ***/ + GLX_FUNCTION(glXGetScreenDriver), + GLX_FUNCTION(glXGetDriverConfig), +#endif + + {NULL, NULL} /* end of list */ +}; + + +static const GLvoid * +get_glx_proc_address(const char *funcName) +{ + GLuint i; + + /* try static functions */ + for (i = 0; GLX_functions[i].Name; i++) { + if (strcmp(GLX_functions[i].Name, funcName) == 0) + return GLX_functions[i].Address; + } + + return NULL; +} + + +/** + * Get the address of a named GL function. This is the pre-GLX 1.4 name for + * \c glXGetProcAddress. + * + * \param procName Name of a GL or GLX function. + * \returns A pointer to the named function + * + * \sa glXGetProcAddress + */ +PUBLIC void (*glXGetProcAddressARB(const GLubyte * procName)) (void) +{ + typedef void (*gl_function) (void); + gl_function f; + + + /* Search the table of GLX and internal functions first. If that + * fails and the supplied name could be a valid core GL name, try + * searching the core GL function table. This check is done to prevent + * DRI based drivers from searching the core GL function table for + * internal API functions. + */ + + f = (gl_function) get_glx_proc_address((const char *) procName); + if ((f == NULL) && (procName[0] == 'g') && (procName[1] == 'l') + && (procName[2] != 'X')) { + f = (gl_function) _glapi_get_proc_address((const char *) procName); + } + + return f; +} + +/** + * Get the address of a named GL function. This is the GLX 1.4 name for + * \c glXGetProcAddressARB. + * + * \param procName Name of a GL or GLX function. + * \returns A pointer to the named function + * + * \sa glXGetProcAddressARB + */ +PUBLIC void (*glXGetProcAddress(const GLubyte * procName)) (void) +#if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED) + __attribute__ ((alias("glXGetProcAddressARB"))); +#else +{ + return glXGetProcAddressARB(procName); +} +#endif /* __GNUC__ */ + + +#ifdef GLX_DIRECT_RENDERING +/** + * Get the unadjusted system time (UST). Currently, the UST is measured in + * microseconds since Epoc. The actual resolution of the UST may vary from + * system to system, and the units may vary from release to release. + * Drivers should not call this function directly. They should instead use + * \c glXGetProcAddress to obtain a pointer to the function. + * + * \param ust Location to store the 64-bit UST + * \returns Zero on success or a negative errno value on failure. + * + * \sa glXGetProcAddress, PFNGLXGETUSTPROC + * + * \since Internal API version 20030317. + */ +_X_HIDDEN int +__glXGetUST(int64_t * ust) +{ + struct timeval tv; + + if (ust == NULL) { + return -EFAULT; + } + + if (gettimeofday(&tv, NULL) == 0) { + ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec; + return 0; + } + else { + return -errno; + } +} +#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c new file mode 100644 index 00000000000..c28360bdde9 --- /dev/null +++ b/src/glx/glxcurrent.c @@ -0,0 +1,513 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +/** + * \file glxcurrent.c + * Client-side GLX interface for current context management. + */ + +#include "glxclient.h" +#include "glapi.h" +#include "indirect_init.h" + +/* +** We setup some dummy structures here so that the API can be used +** even if no context is current. +*/ + +static GLubyte dummyBuffer[__GLX_BUFFER_LIMIT_SIZE]; + +/* +** Dummy context used by small commands when there is no current context. +** All the +** gl and glx entry points are designed to operate as nop's when using +** the dummy context structure. +*/ +static __GLXcontext dummyContext = { + &dummyBuffer[0], + &dummyBuffer[0], + &dummyBuffer[0], + &dummyBuffer[__GLX_BUFFER_LIMIT_SIZE], + sizeof(dummyBuffer), +}; + + +/* +** All indirect rendering contexts will share the same indirect dispatch table. +*/ +static __GLapi *IndirectAPI = NULL; + + +/* + * Current context management and locking + */ + +#if defined( PTHREADS ) + +_X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER; + +# if defined( GLX_USE_TLS ) + +/** + * Per-thread GLX context pointer. + * + * \c __glXSetCurrentContext is written is such a way that this pointer can + * \b never be \c NULL. This is important! Because of this + * \c __glXGetCurrentContext can be implemented as trivial macro. + */ +__thread void *__glX_tls_Context __attribute__ ((tls_model("initial-exec"))) + = &dummyContext; + +_X_HIDDEN void +__glXSetCurrentContext(__GLXcontext * c) +{ + __glX_tls_Context = (c != NULL) ? c : &dummyContext; +} + +# else + +static pthread_once_t once_control = PTHREAD_ONCE_INIT; + +/** + * Per-thread data key. + * + * Once \c init_thread_data has been called, the per-thread data key will + * take a value of \c NULL. As each new thread is created the default + * value, in that thread, will be \c NULL. + */ +static pthread_key_t ContextTSD; + +/** + * Initialize the per-thread data key. + * + * This function is called \b exactly once per-process (not per-thread!) to + * initialize the per-thread data key. This is ideally done using the + * \c pthread_once mechanism. + */ +static void +init_thread_data(void) +{ + if (pthread_key_create(&ContextTSD, NULL) != 0) { + perror("pthread_key_create"); + exit(-1); + } +} + +_X_HIDDEN void +__glXSetCurrentContext(__GLXcontext * c) +{ + pthread_once(&once_control, init_thread_data); + pthread_setspecific(ContextTSD, c); +} + +_X_HIDDEN __GLXcontext * +__glXGetCurrentContext(void) +{ + void *v; + + pthread_once(&once_control, init_thread_data); + + v = pthread_getspecific(ContextTSD); + return (v == NULL) ? &dummyContext : (__GLXcontext *) v; +} + +# endif /* defined( GLX_USE_TLS ) */ + +#elif defined( THREADS ) + +#error Unknown threading method specified. + +#else + +/* not thread safe */ +_X_HIDDEN __GLXcontext *__glXcurrentContext = &dummyContext; + +#endif + + +_X_HIDDEN void +__glXSetCurrentContextNull(void) +{ + __glXSetCurrentContext(&dummyContext); +#ifdef GLX_DIRECT_RENDERING + _glapi_set_dispatch(NULL); /* no-op functions */ + _glapi_set_context(NULL); +#endif +} + + +/************************************************************************/ + +PUBLIC GLXContext +glXGetCurrentContext(void) +{ + GLXContext cx = __glXGetCurrentContext(); + + if (cx == &dummyContext) { + return NULL; + } + else { + return cx; + } +} + +PUBLIC GLXDrawable +glXGetCurrentDrawable(void) +{ + GLXContext gc = __glXGetCurrentContext(); + return gc->currentDrawable; +} + + +/************************************************************************/ + +/** + * Sends a GLX protocol message to the specified display to make the context + * and the drawables current. + * + * \param dpy Display to send the message to. + * \param opcode Major opcode value for the display. + * \param gc_id Context tag for the context to be made current. + * \param draw Drawable ID for the "draw" drawable. + * \param read Drawable ID for the "read" drawable. + * \param reply Space to store the X-server's reply. + * + * \warning + * This function assumes that \c dpy is locked with \c LockDisplay on entry. + */ +static Bool +SendMakeCurrentRequest(Display * dpy, CARD8 opcode, + GLXContextID gc_id, GLXContextTag gc_tag, + GLXDrawable draw, GLXDrawable read, + xGLXMakeCurrentReply * reply) +{ + Bool ret; + + + LockDisplay(dpy); + + if (draw == read) { + xGLXMakeCurrentReq *req; + + GetReq(GLXMakeCurrent, req); + req->reqType = opcode; + req->glxCode = X_GLXMakeCurrent; + req->drawable = draw; + req->context = gc_id; + req->oldContextTag = gc_tag; + } + else { + __GLXdisplayPrivate *priv = __glXInitialize(dpy); + + /* If the server can support the GLX 1.3 version, we should + * perfer that. Not only that, some servers support GLX 1.3 but + * not the SGI extension. + */ + + if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { + xGLXMakeContextCurrentReq *req; + + GetReq(GLXMakeContextCurrent, req); + req->reqType = opcode; + req->glxCode = X_GLXMakeContextCurrent; + req->drawable = draw; + req->readdrawable = read; + req->context = gc_id; + req->oldContextTag = gc_tag; + } + else { + xGLXVendorPrivateWithReplyReq *vpreq; + xGLXMakeCurrentReadSGIReq *req; + + GetReqExtra(GLXVendorPrivateWithReply, + sz_xGLXMakeCurrentReadSGIReq - + sz_xGLXVendorPrivateWithReplyReq, vpreq); + req = (xGLXMakeCurrentReadSGIReq *) vpreq; + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivateWithReply; + req->vendorCode = X_GLXvop_MakeCurrentReadSGI; + req->drawable = draw; + req->readable = read; + req->context = gc_id; + req->oldContextTag = gc_tag; + } + } + + ret = _XReply(dpy, (xReply *) reply, 0, False); + + UnlockDisplay(dpy); + SyncHandle(); + + return ret; +} + + +#ifdef GLX_DIRECT_RENDERING +static __GLXDRIdrawable * +FetchDRIDrawable(Display * dpy, GLXDrawable glxDrawable, GLXContext gc) +{ + __GLXdisplayPrivate *const priv = __glXInitialize(dpy); + __GLXDRIdrawable *pdraw; + __GLXscreenConfigs *psc; + + if (priv == NULL) + return NULL; + + psc = &priv->screenConfigs[gc->screen]; + if (psc->drawHash == NULL) + return NULL; + + if (__glxHashLookup(psc->drawHash, glxDrawable, (void *) &pdraw) == 0) + return pdraw; + + pdraw = psc->driScreen->createDrawable(psc, glxDrawable, + glxDrawable, gc->mode); + if (__glxHashInsert(psc->drawHash, glxDrawable, pdraw)) { + (*pdraw->destroyDrawable) (pdraw); + return NULL; + } + + return pdraw; +} +#endif /* GLX_DIRECT_RENDERING */ + +static void +__glXGenerateError(Display * dpy, GLXContext gc, XID resource, + BYTE errorCode, CARD16 minorCode) +{ + xError error; + + error.errorCode = errorCode; + error.resourceID = resource; + error.sequenceNumber = dpy->request; + error.type = X_Error; + error.majorCode = gc->majorOpcode; + error.minorCode = minorCode; + _XError(dpy, &error); +} + +/** + * Make a particular context current. + * + * \note This is in this file so that it can access dummyContext. + */ +static Bool +MakeContextCurrent(Display * dpy, GLXDrawable draw, + GLXDrawable read, GLXContext gc) +{ + xGLXMakeCurrentReply reply; + const GLXContext oldGC = __glXGetCurrentContext(); + const CARD8 opcode = __glXSetupForCommand(dpy); + const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext)) + ? opcode : __glXSetupForCommand(oldGC->currentDpy); + Bool bindReturnValue; + __GLXattribute *state; + + if (!opcode || !oldOpcode) { + return GL_FALSE; + } + + /* Make sure that the new context has a nonzero ID. In the request, + * a zero context ID is used only to mean that we bind to no current + * context. + */ + if ((gc != NULL) && (gc->xid == None)) { + return GL_FALSE; + } + + if (gc == NULL && (draw != None || read != None)) { + __glXGenerateError(dpy, gc, (draw != None) ? draw : read, + BadMatch, X_GLXMakeContextCurrent); + return False; + } + if (gc != NULL && (draw == None || read == None)) { + __glXGenerateError(dpy, gc, None, BadMatch, X_GLXMakeContextCurrent); + return False; + } + + _glapi_check_multithread(); + + if (gc != NULL && gc->thread_id != 0 && gc->thread_id != _glthread_GetID()) { + __glXGenerateError(dpy, gc, gc->xid, + BadAccess, X_GLXMakeContextCurrent); + return False; + } + +#ifdef GLX_DIRECT_RENDERING + /* Bind the direct rendering context to the drawable */ + if (gc && gc->driContext) { + __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc); + __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc); + + if ((pdraw == NULL) || (pread == NULL)) { + __glXGenerateError(dpy, gc, (pdraw == NULL) ? draw : read, + GLXBadDrawable, X_GLXMakeContextCurrent); + return False; + } + + bindReturnValue = + (gc->driContext->bindContext) (gc->driContext, pdraw, pread); + } + else if (!gc && oldGC && oldGC->driContext) { + bindReturnValue = True; + } + else +#endif + { + /* Send a glXMakeCurrent request to bind the new context. */ + bindReturnValue = + SendMakeCurrentRequest(dpy, opcode, gc ? gc->xid : None, + ((dpy != oldGC->currentDpy) + || oldGC->isDirect) + ? None : oldGC->currentContextTag, draw, read, + &reply); + } + + + if (!bindReturnValue) { + return False; + } + +#ifdef GLX_DIRECT_RENDERING + if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) && + !oldGC->isDirect && oldGC != &dummyContext) { +#else + if ((dpy != oldGC->currentDpy) && oldGC != &dummyContext) { +#endif + xGLXMakeCurrentReply dummy_reply; + + /* We are either switching from one dpy to another and have to + * send a request to the previous dpy to unbind the previous + * context, or we are switching away from a indirect context to + * a direct context and have to send a request to the dpy to + * unbind the previous context. + */ + (void) SendMakeCurrentRequest(oldGC->currentDpy, oldOpcode, None, + oldGC->currentContextTag, None, None, + &dummy_reply); + } +#ifdef GLX_DIRECT_RENDERING + else if (oldGC->driContext && oldGC != gc) { + oldGC->driContext->unbindContext(oldGC->driContext); + } +#endif + + + /* Update our notion of what is current */ + __glXLock(); + if (gc == oldGC) { + /* Even though the contexts are the same the drawable might have + * changed. Note that gc cannot be the dummy, and that oldGC + * cannot be NULL, therefore if they are the same, gc is not + * NULL and not the dummy. + */ + gc->currentDrawable = draw; + gc->currentReadable = read; + } + else { + if (oldGC != &dummyContext) { + /* Old current context is no longer current to anybody */ + oldGC->currentDpy = 0; + oldGC->currentDrawable = None; + oldGC->currentReadable = None; + oldGC->currentContextTag = 0; + oldGC->thread_id = 0; + + if (oldGC->xid == None) { + /* We are switching away from a context that was + * previously destroyed, so we need to free the memory + * for the old handle. + */ +#ifdef GLX_DIRECT_RENDERING + /* Destroy the old direct rendering context */ + if (oldGC->driContext) { + oldGC->driContext->destroyContext(oldGC->driContext, + oldGC->psc, + oldGC->createDpy); + oldGC->driContext = NULL; + } +#endif + __glXFreeContext(oldGC); + } + } + if (gc) { + __glXSetCurrentContext(gc); + + gc->currentDpy = dpy; + gc->currentDrawable = draw; + gc->currentReadable = read; + gc->thread_id = _glthread_GetID(); + +#ifdef GLX_DIRECT_RENDERING + if (!gc->driContext) { +#endif + if (!IndirectAPI) + IndirectAPI = __glXNewIndirectAPI(); + _glapi_set_dispatch(IndirectAPI); + + state = (__GLXattribute *) (gc->client_state_private); + + gc->currentContextTag = reply.contextTag; + if (state->array_state == NULL) { + (void) glGetString(GL_EXTENSIONS); + (void) glGetString(GL_VERSION); + __glXInitVertexArrayState(gc); + } +#ifdef GLX_DIRECT_RENDERING + } + else { + gc->currentContextTag = -1; + } +#endif + } + else { + __glXSetCurrentContextNull(); + } + } + __glXUnlock(); + return GL_TRUE; +} + + +PUBLIC Bool +glXMakeCurrent(Display * dpy, GLXDrawable draw, GLXContext gc) +{ + return MakeContextCurrent(dpy, draw, draw, gc); +} + +PUBLIC +GLX_ALIAS(Bool, glXMakeCurrentReadSGI, + (Display * dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx), + (dpy, d, r, ctx), MakeContextCurrent) + +PUBLIC +GLX_ALIAS(Bool, glXMakeContextCurrent, + (Display * dpy, GLXDrawable d, GLXDrawable r, + GLXContext ctx), (dpy, d, r, ctx), MakeContextCurrent) diff --git a/src/glx/glxext.c b/src/glx/glxext.c new file mode 100644 index 00000000000..c2de1a3fff8 --- /dev/null +++ b/src/glx/glxext.c @@ -0,0 +1,1060 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +/** + * \file glxext.c + * GLX protocol interface boot-strap code. + * + * Direct rendering support added by Precision Insight, Inc. + * + * \author Kevin E. Martin + */ + +#include +#include "glxclient.h" +#include +#include +#include +#include "glxextensions.h" +#include "glcontextmodes.h" + +#ifdef USE_XCB +#include +#include +#include +#endif + + +#ifdef DEBUG +void __glXDumpDrawBuffer(__GLXcontext * ctx); +#endif + +/* +** You can set this cell to 1 to force the gl drawing stuff to be +** one command per packet +*/ +_X_HIDDEN int __glXDebug = 0; + +/* Extension required boiler plate */ + +static char *__glXExtensionName = GLX_EXTENSION_NAME; +XExtensionInfo *__glXExtensionInfo = NULL; + +static /* const */ char *error_list[] = { + "GLXBadContext", + "GLXBadContextState", + "GLXBadDrawable", + "GLXBadPixmap", + "GLXBadContextTag", + "GLXBadCurrentWindow", + "GLXBadRenderRequest", + "GLXBadLargeRequest", + "GLXUnsupportedPrivateRequest", + "GLXBadFBConfig", + "GLXBadPbuffer", + "GLXBadCurrentDrawable", + "GLXBadWindow", +}; + +static int +__glXCloseDisplay(Display * dpy, XExtCodes * codes) +{ + GLXContext gc; + + gc = __glXGetCurrentContext(); + if (dpy == gc->currentDpy) { + __glXSetCurrentContextNull(); + __glXFreeContext(gc); + } + + return XextRemoveDisplay(__glXExtensionInfo, dpy); +} + + +static +XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName, + __GLX_NUMBER_ERRORS, error_list) +static Bool +__glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire); +static Status +__glXEventToWire(Display *dpy, XEvent *event, xEvent *wire); + +static /* const */ XExtensionHooks __glXExtensionHooks = { + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + __glXCloseDisplay, /* close_display */ + __glXWireToEvent, /* wire_to_event */ + __glXEventToWire, /* event_to_wire */ + NULL, /* error */ + __glXErrorString, /* error_string */ +}; + +XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo, + __glXExtensionName, &__glXExtensionHooks, + __GLX_NUMBER_EVENTS, NULL) + +/* + * GLX events are a bit funky. We don't stuff the X event code into + * our user exposed (via XNextEvent) structure. Instead we use the GLX + * private event code namespace (and hope it doesn't conflict). Clients + * have to know that bit 15 in the event type field means they're getting + * a GLX event, and then handle the various sub-event types there, rather + * than simply checking the event code and handling it directly. + */ + +static Bool +__glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire) +{ + XExtDisplayInfo *info = __glXFindDisplay(dpy); + + XextCheckExtension(dpy, info, __glXExtensionName, False); + + switch ((wire->u.u.type & 0x7f) - info->codes->first_event) { + case GLX_PbufferClobber: + { + GLXPbufferClobberEvent *aevent = (GLXPbufferClobberEvent *)event; + xGLXPbufferClobberEvent *awire = (xGLXPbufferClobberEvent *)wire; + aevent->event_type = awire->type; + aevent->serial = awire->sequenceNumber; + aevent->event_type = awire->event_type; + aevent->draw_type = awire->draw_type; + aevent->drawable = awire->drawable; + aevent->buffer_mask = awire->buffer_mask; + aevent->aux_buffer = awire->aux_buffer; + aevent->x = awire->x; + aevent->y = awire->y; + aevent->width = awire->width; + aevent->height = awire->height; + aevent->count = awire->count; + return True; + } + /* No easy symbol to test for this, as GLX_BufferSwapComplete is + * defined in the local glx.h header, but the + * xGLXBufferSwapComplete typedef is only available in new versions + * of the external glxproto.h header, which doesn't have any + * testable versioning define. + * + * I'll use the related DRI2 define, in the hope that we won't + * receive these events unless we know how to ask for them: + */ +#ifdef X_DRI2SwapBuffers + case GLX_BufferSwapComplete: + { + GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event; + xGLXBufferSwapComplete *awire = (xGLXBufferSwapComplete *)wire; + aevent->event_type = awire->event_type; + aevent->drawable = awire->drawable; + aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo; + aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo; + aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo; + return True; + } +#endif + default: + /* client doesn't support server event */ + break; + } + + return False; +} + +/* We don't actually support this. It doesn't make sense for clients to + * send each other GLX events. + */ +static Status +__glXEventToWire(Display *dpy, XEvent *event, xEvent *wire) +{ + XExtDisplayInfo *info = __glXFindDisplay(dpy); + + XextCheckExtension(dpy, info, __glXExtensionName, False); + + switch (event->type) { + case GLX_DAMAGED: + break; + case GLX_SAVED: + break; + case GLX_EXCHANGE_COMPLETE_INTEL: + break; + case GLX_BLIT_COMPLETE_INTEL: + break; + case GLX_FLIP_COMPLETE_INTEL: + break; + default: + /* client doesn't support server event */ + break; + } + + return Success; +} + +/************************************************************************/ +/* +** Free the per screen configs data as well as the array of +** __glXScreenConfigs. +*/ +static void +FreeScreenConfigs(__GLXdisplayPrivate * priv) +{ + __GLXscreenConfigs *psc; + GLint i, screens; + + /* Free screen configuration information */ + psc = priv->screenConfigs; + screens = ScreenCount(priv->dpy); + for (i = 0; i < screens; i++, psc++) { + if (psc->configs) { + _gl_context_modes_destroy(psc->configs); + if (psc->effectiveGLXexts) + Xfree(psc->effectiveGLXexts); + psc->configs = NULL; /* NOTE: just for paranoia */ + } + if (psc->visuals) { + _gl_context_modes_destroy(psc->visuals); + psc->visuals = NULL; /* NOTE: just for paranoia */ + } + Xfree((char *) psc->serverGLXexts); + +#ifdef GLX_DIRECT_RENDERING + if (psc->driver_configs) { + unsigned int j; + for (j = 0; psc->driver_configs[j]; j++) + free((__DRIconfig *) psc->driver_configs[j]); + free(psc->driver_configs); + psc->driver_configs = NULL; + } + if (psc->driScreen) { + psc->driScreen->destroyScreen(psc); + __glxHashDestroy(psc->drawHash); + XFree(psc->driScreen); + psc->driScreen = NULL; + } +#endif + } + XFree((char *) priv->screenConfigs); + priv->screenConfigs = NULL; +} + +/* +** Release the private memory referred to in a display private +** structure. The caller will free the extension structure. +*/ +static int +__glXFreeDisplayPrivate(XExtData * extension) +{ + __GLXdisplayPrivate *priv; + + priv = (__GLXdisplayPrivate *) extension->private_data; + FreeScreenConfigs(priv); + if (priv->serverGLXvendor) { + Xfree((char *) priv->serverGLXvendor); + priv->serverGLXvendor = 0x0; /* to protect against double free's */ + } + if (priv->serverGLXversion) { + Xfree((char *) priv->serverGLXversion); + priv->serverGLXversion = 0x0; /* to protect against double free's */ + } + +#ifdef GLX_DIRECT_RENDERING + /* Free the direct rendering per display data */ + if (priv->driswDisplay) + (*priv->driswDisplay->destroyDisplay) (priv->driswDisplay); + priv->driswDisplay = NULL; + + if (priv->driDisplay) + (*priv->driDisplay->destroyDisplay) (priv->driDisplay); + priv->driDisplay = NULL; + + if (priv->dri2Display) + (*priv->dri2Display->destroyDisplay) (priv->dri2Display); + priv->dri2Display = NULL; +#endif + + Xfree((char *) priv); + return 0; +} + +/************************************************************************/ + +/* +** Query the version of the GLX extension. This procedure works even if +** the client extension is not completely set up. +*/ +static Bool +QueryVersion(Display * dpy, int opcode, int *major, int *minor) +{ +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + xcb_glx_query_version_reply_t *reply = xcb_glx_query_version_reply(c, + xcb_glx_query_version + (c, + GLX_MAJOR_VERSION, + GLX_MINOR_VERSION), + NULL); + + if (reply->major_version != GLX_MAJOR_VERSION) { + free(reply); + return GL_FALSE; + } + *major = reply->major_version; + *minor = min(reply->minor_version, GLX_MINOR_VERSION); + free(reply); + return GL_TRUE; +#else + xGLXQueryVersionReq *req; + xGLXQueryVersionReply reply; + + /* Send the glXQueryVersion request */ + LockDisplay(dpy); + GetReq(GLXQueryVersion, req); + req->reqType = opcode; + req->glxCode = X_GLXQueryVersion; + req->majorVersion = GLX_MAJOR_VERSION; + req->minorVersion = GLX_MINOR_VERSION; + _XReply(dpy, (xReply *) & reply, 0, False); + UnlockDisplay(dpy); + SyncHandle(); + + if (reply.majorVersion != GLX_MAJOR_VERSION) { + /* + ** The server does not support the same major release as this + ** client. + */ + return GL_FALSE; + } + *major = reply.majorVersion; + *minor = min(reply.minorVersion, GLX_MINOR_VERSION); + return GL_TRUE; +#endif /* USE_XCB */ +} + + +_X_HIDDEN void +__glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count, + const INT32 * bp, Bool tagged_only, + Bool fbconfig_style_tags) +{ + int i; + + if (!tagged_only) { + /* Copy in the first set of properties */ + config->visualID = *bp++; + + config->visualType = _gl_convert_from_x_visual_type(*bp++); + + config->rgbMode = *bp++; + + config->redBits = *bp++; + config->greenBits = *bp++; + config->blueBits = *bp++; + config->alphaBits = *bp++; + config->accumRedBits = *bp++; + config->accumGreenBits = *bp++; + config->accumBlueBits = *bp++; + config->accumAlphaBits = *bp++; + + config->doubleBufferMode = *bp++; + config->stereoMode = *bp++; + + config->rgbBits = *bp++; + config->depthBits = *bp++; + config->stencilBits = *bp++; + config->numAuxBuffers = *bp++; + config->level = *bp++; + + count -= __GLX_MIN_CONFIG_PROPS; + } + + /* + ** Additional properties may be in a list at the end + ** of the reply. They are in pairs of property type + ** and property value. + */ + +#define FETCH_OR_SET(tag) \ + config-> tag = ( fbconfig_style_tags ) ? *bp++ : 1 + + for (i = 0; i < count; i += 2) { + switch (*bp++) { + case GLX_RGBA: + FETCH_OR_SET(rgbMode); + break; + case GLX_BUFFER_SIZE: + config->rgbBits = *bp++; + break; + case GLX_LEVEL: + config->level = *bp++; + break; + case GLX_DOUBLEBUFFER: + FETCH_OR_SET(doubleBufferMode); + break; + case GLX_STEREO: + FETCH_OR_SET(stereoMode); + break; + case GLX_AUX_BUFFERS: + config->numAuxBuffers = *bp++; + break; + case GLX_RED_SIZE: + config->redBits = *bp++; + break; + case GLX_GREEN_SIZE: + config->greenBits = *bp++; + break; + case GLX_BLUE_SIZE: + config->blueBits = *bp++; + break; + case GLX_ALPHA_SIZE: + config->alphaBits = *bp++; + break; + case GLX_DEPTH_SIZE: + config->depthBits = *bp++; + break; + case GLX_STENCIL_SIZE: + config->stencilBits = *bp++; + break; + case GLX_ACCUM_RED_SIZE: + config->accumRedBits = *bp++; + break; + case GLX_ACCUM_GREEN_SIZE: + config->accumGreenBits = *bp++; + break; + case GLX_ACCUM_BLUE_SIZE: + config->accumBlueBits = *bp++; + break; + case GLX_ACCUM_ALPHA_SIZE: + config->accumAlphaBits = *bp++; + break; + case GLX_VISUAL_CAVEAT_EXT: + config->visualRating = *bp++; + break; + case GLX_X_VISUAL_TYPE: + config->visualType = *bp++; + break; + case GLX_TRANSPARENT_TYPE: + config->transparentPixel = *bp++; + break; + case GLX_TRANSPARENT_INDEX_VALUE: + config->transparentIndex = *bp++; + break; + case GLX_TRANSPARENT_RED_VALUE: + config->transparentRed = *bp++; + break; + case GLX_TRANSPARENT_GREEN_VALUE: + config->transparentGreen = *bp++; + break; + case GLX_TRANSPARENT_BLUE_VALUE: + config->transparentBlue = *bp++; + break; + case GLX_TRANSPARENT_ALPHA_VALUE: + config->transparentAlpha = *bp++; + break; + case GLX_VISUAL_ID: + config->visualID = *bp++; + break; + case GLX_DRAWABLE_TYPE: + config->drawableType = *bp++; + break; + case GLX_RENDER_TYPE: + config->renderType = *bp++; + break; + case GLX_X_RENDERABLE: + config->xRenderable = *bp++; + break; + case GLX_FBCONFIG_ID: + config->fbconfigID = *bp++; + break; + case GLX_MAX_PBUFFER_WIDTH: + config->maxPbufferWidth = *bp++; + break; + case GLX_MAX_PBUFFER_HEIGHT: + config->maxPbufferHeight = *bp++; + break; + case GLX_MAX_PBUFFER_PIXELS: + config->maxPbufferPixels = *bp++; + break; + case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX: + config->optimalPbufferWidth = *bp++; + break; + case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX: + config->optimalPbufferHeight = *bp++; + break; + case GLX_VISUAL_SELECT_GROUP_SGIX: + config->visualSelectGroup = *bp++; + break; + case GLX_SWAP_METHOD_OML: + config->swapMethod = *bp++; + break; + case GLX_SAMPLE_BUFFERS_SGIS: + config->sampleBuffers = *bp++; + break; + case GLX_SAMPLES_SGIS: + config->samples = *bp++; + break; + case GLX_BIND_TO_TEXTURE_RGB_EXT: + config->bindToTextureRgb = *bp++; + break; + case GLX_BIND_TO_TEXTURE_RGBA_EXT: + config->bindToTextureRgba = *bp++; + break; + case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: + config->bindToMipmapTexture = *bp++; + break; + case GLX_BIND_TO_TEXTURE_TARGETS_EXT: + config->bindToTextureTargets = *bp++; + break; + case GLX_Y_INVERTED_EXT: + config->yInverted = *bp++; + break; + case None: + i = count; + break; + default: + break; + } + } + + config->renderType = + (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; + + config->haveAccumBuffer = ((config->accumRedBits + + config->accumGreenBits + + config->accumBlueBits + + config->accumAlphaBits) > 0); + config->haveDepthBuffer = (config->depthBits > 0); + config->haveStencilBuffer = (config->stencilBits > 0); +} + +static __GLcontextModes * +createConfigsFromProperties(Display * dpy, int nvisuals, int nprops, + int screen, GLboolean tagged_only) +{ + INT32 buf[__GLX_TOTAL_CONFIG], *props; + unsigned prop_size; + __GLcontextModes *modes, *m; + int i; + + if (nprops == 0) + return NULL; + + /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */ + + /* Check number of properties */ + if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS) + return NULL; + + /* Allocate memory for our config structure */ + modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes)); + if (!modes) + return NULL; + + prop_size = nprops * __GLX_SIZE_INT32; + if (prop_size <= sizeof(buf)) + props = buf; + else + props = Xmalloc(prop_size); + + /* Read each config structure and convert it into our format */ + m = modes; + for (i = 0; i < nvisuals; i++) { + _XRead(dpy, (char *) props, prop_size); + /* Older X servers don't send this so we default it here. */ + m->drawableType = GLX_WINDOW_BIT; + __glXInitializeVisualConfigFromTags(m, nprops, props, + tagged_only, GL_TRUE); + m->screen = screen; + m = m->next; + } + + if (props != buf) + Xfree(props); + + return modes; +} + +static GLboolean +getVisualConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen) +{ + xGLXGetVisualConfigsReq *req; + __GLXscreenConfigs *psc; + xGLXGetVisualConfigsReply reply; + + LockDisplay(dpy); + + psc = priv->screenConfigs + screen; + psc->visuals = NULL; + GetReq(GLXGetVisualConfigs, req); + req->reqType = priv->majorOpcode; + req->glxCode = X_GLXGetVisualConfigs; + req->screen = screen; + + if (!_XReply(dpy, (xReply *) & reply, 0, False)) + goto out; + + psc->visuals = createConfigsFromProperties(dpy, + reply.numVisuals, + reply.numProps, + screen, GL_FALSE); + + out: + UnlockDisplay(dpy); + return psc->visuals != NULL; +} + +static GLboolean +getFBConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen) +{ + xGLXGetFBConfigsReq *fb_req; + xGLXGetFBConfigsSGIXReq *sgi_req; + xGLXVendorPrivateWithReplyReq *vpreq; + xGLXGetFBConfigsReply reply; + __GLXscreenConfigs *psc; + + psc = priv->screenConfigs + screen; + psc->serverGLXexts = + __glXQueryServerString(dpy, priv->majorOpcode, screen, GLX_EXTENSIONS); + + LockDisplay(dpy); + + psc->configs = NULL; + if (atof(priv->serverGLXversion) >= 1.3) { + GetReq(GLXGetFBConfigs, fb_req); + fb_req->reqType = priv->majorOpcode; + fb_req->glxCode = X_GLXGetFBConfigs; + fb_req->screen = screen; + } + else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) { + GetReqExtra(GLXVendorPrivateWithReply, + sz_xGLXGetFBConfigsSGIXReq + + sz_xGLXVendorPrivateWithReplyReq, vpreq); + sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq; + sgi_req->reqType = priv->majorOpcode; + sgi_req->glxCode = X_GLXVendorPrivateWithReply; + sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX; + sgi_req->screen = screen; + } + else + goto out; + + if (!_XReply(dpy, (xReply *) & reply, 0, False)) + goto out; + + psc->configs = createConfigsFromProperties(dpy, + reply.numFBConfigs, + reply.numAttribs * 2, + screen, GL_TRUE); + + out: + UnlockDisplay(dpy); + return psc->configs != NULL; +} + +/* +** Allocate the memory for the per screen configs for each screen. +** If that works then fetch the per screen configs data. +*/ +static Bool +AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv) +{ + __GLXscreenConfigs *psc; + GLint i, screens; + + /* + ** First allocate memory for the array of per screen configs. + */ + screens = ScreenCount(dpy); + psc = (__GLXscreenConfigs *) Xmalloc(screens * sizeof(__GLXscreenConfigs)); + if (!psc) { + return GL_FALSE; + } + memset(psc, 0, screens * sizeof(__GLXscreenConfigs)); + priv->screenConfigs = psc; + + priv->serverGLXversion = + __glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION); + if (priv->serverGLXversion == NULL) { + FreeScreenConfigs(priv); + return GL_FALSE; + } + + for (i = 0; i < screens; i++, psc++) { + getVisualConfigs(dpy, priv, i); + getFBConfigs(dpy, priv, i); + +#ifdef GLX_DIRECT_RENDERING + psc->scr = i; + psc->dpy = dpy; + psc->drawHash = __glxHashCreate(); + if (psc->drawHash == NULL) + continue; + + if (priv->dri2Display) + psc->driScreen = (*priv->dri2Display->createScreen) (psc, i, priv); + + if (psc->driScreen == NULL && priv->driDisplay) + psc->driScreen = (*priv->driDisplay->createScreen) (psc, i, priv); + + if (psc->driScreen == NULL && priv->driswDisplay) + psc->driScreen = (*priv->driswDisplay->createScreen) (psc, i, priv); + + if (psc->driScreen == NULL) { + __glxHashDestroy(psc->drawHash); + psc->drawHash = NULL; + } +#endif + } + SyncHandle(); + return GL_TRUE; +} + +/* +** Initialize the client side extension code. +*/ +_X_HIDDEN __GLXdisplayPrivate * +__glXInitialize(Display * dpy) +{ + XExtDisplayInfo *info = __glXFindDisplay(dpy); + XExtData **privList, *private, *found; + __GLXdisplayPrivate *dpyPriv; + XEDataObject dataObj; + int major, minor; +#ifdef GLX_DIRECT_RENDERING + Bool glx_direct, glx_accel; +#endif + + /* The one and only long long lock */ + __glXLock(); + + if (!XextHasExtension(info)) { + /* No GLX extension supported by this server. Oh well. */ + __glXUnlock(); + XMissingExtension(dpy, __glXExtensionName); + return 0; + } + + /* See if a display private already exists. If so, return it */ + dataObj.display = dpy; + privList = XEHeadOfExtensionList(dataObj); + found = XFindOnExtensionList(privList, info->codes->extension); + if (found) { + __glXUnlock(); + return (__GLXdisplayPrivate *) found->private_data; + } + + /* See if the versions are compatible */ + if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor)) { + /* The client and server do not agree on versions. Punt. */ + __glXUnlock(); + return 0; + } + + /* + ** Allocate memory for all the pieces needed for this buffer. + */ + private = (XExtData *) Xmalloc(sizeof(XExtData)); + if (!private) { + __glXUnlock(); + return 0; + } + dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate)); + if (!dpyPriv) { + __glXUnlock(); + Xfree((char *) private); + return 0; + } + + /* + ** Init the display private and then read in the screen config + ** structures from the server. + */ + dpyPriv->majorOpcode = info->codes->major_opcode; + dpyPriv->majorVersion = major; + dpyPriv->minorVersion = minor; + dpyPriv->dpy = dpy; + + dpyPriv->serverGLXvendor = 0x0; + dpyPriv->serverGLXversion = 0x0; + +#ifdef GLX_DIRECT_RENDERING + glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL); + glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL); + + /* + ** Initialize the direct rendering per display data and functions. + ** Note: This _must_ be done before calling any other DRI routines + ** (e.g., those called in AllocAndFetchScreenConfigs). + */ + if (glx_direct && glx_accel) { + dpyPriv->dri2Display = dri2CreateDisplay(dpy); + dpyPriv->driDisplay = driCreateDisplay(dpy); + } + if (glx_direct) + dpyPriv->driswDisplay = driswCreateDisplay(dpy); +#endif + + if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) { + __glXUnlock(); + Xfree((char *) dpyPriv); + Xfree((char *) private); + return 0; + } + + /* + ** Fill in the private structure. This is the actual structure that + ** hangs off of the Display structure. Our private structure is + ** referred to by this structure. Got that? + */ + private->number = info->codes->extension; + private->next = 0; + private->free_private = __glXFreeDisplayPrivate; + private->private_data = (char *) dpyPriv; + XAddToExtensionList(privList, private); + + if (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion >= 1) { + __glXClientInfo(dpy, dpyPriv->majorOpcode); + } + __glXUnlock(); + + return dpyPriv; +} + +/* +** Setup for sending a GLX command on dpy. Make sure the extension is +** initialized. Try to avoid calling __glXInitialize as its kinda slow. +*/ +_X_HIDDEN CARD8 +__glXSetupForCommand(Display * dpy) +{ + GLXContext gc; + __GLXdisplayPrivate *priv; + + /* If this thread has a current context, flush its rendering commands */ + gc = __glXGetCurrentContext(); + if (gc->currentDpy) { + /* Flush rendering buffer of the current context, if any */ + (void) __glXFlushRenderBuffer(gc, gc->pc); + + if (gc->currentDpy == dpy) { + /* Use opcode from gc because its right */ + return gc->majorOpcode; + } + else { + /* + ** Have to get info about argument dpy because it might be to + ** a different server + */ + } + } + + /* Forced to lookup extension via the slow initialize route */ + priv = __glXInitialize(dpy); + if (!priv) { + return 0; + } + return priv->majorOpcode; +} + +/** + * Flush the drawing command transport buffer. + * + * \param ctx Context whose transport buffer is to be flushed. + * \param pc Pointer to first unused buffer location. + * + * \todo + * Modify this function to use \c ctx->pc instead of the explicit + * \c pc parameter. + */ +_X_HIDDEN GLubyte * +__glXFlushRenderBuffer(__GLXcontext * ctx, GLubyte * pc) +{ + Display *const dpy = ctx->currentDpy; +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); +#else + xGLXRenderReq *req; +#endif /* USE_XCB */ + const GLint size = pc - ctx->buf; + + if ((dpy != NULL) && (size > 0)) { +#ifdef USE_XCB + xcb_glx_render(c, ctx->currentContextTag, size, + (const uint8_t *) ctx->buf); +#else + /* Send the entire buffer as an X request */ + LockDisplay(dpy); + GetReq(GLXRender, req); + req->reqType = ctx->majorOpcode; + req->glxCode = X_GLXRender; + req->contextTag = ctx->currentContextTag; + req->length += (size + 3) >> 2; + _XSend(dpy, (char *) ctx->buf, size); + UnlockDisplay(dpy); + SyncHandle(); +#endif + } + + /* Reset pointer and return it */ + ctx->pc = ctx->buf; + return ctx->pc; +} + + +/** + * Send a portion of a GLXRenderLarge command to the server. The advantage of + * this function over \c __glXSendLargeCommand is that callers can use the + * data buffer in the GLX context and may be able to avoid allocating an + * extra buffer. The disadvantage is the clients will have to do more + * GLX protocol work (i.e., calculating \c totalRequests, etc.). + * + * \sa __glXSendLargeCommand + * + * \param gc GLX context + * \param requestNumber Which part of the whole command is this? The first + * request is 1. + * \param totalRequests How many requests will there be? + * \param data Command data. + * \param dataLen Size, in bytes, of the command data. + */ +_X_HIDDEN void +__glXSendLargeChunk(__GLXcontext * gc, GLint requestNumber, + GLint totalRequests, const GLvoid * data, GLint dataLen) +{ + Display *dpy = gc->currentDpy; +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + xcb_glx_render_large(c, gc->currentContextTag, requestNumber, + totalRequests, dataLen, data); +#else + xGLXRenderLargeReq *req; + + if (requestNumber == 1) { + LockDisplay(dpy); + } + + GetReq(GLXRenderLarge, req); + req->reqType = gc->majorOpcode; + req->glxCode = X_GLXRenderLarge; + req->contextTag = gc->currentContextTag; + req->length += (dataLen + 3) >> 2; + req->requestNumber = requestNumber; + req->requestTotal = totalRequests; + req->dataBytes = dataLen; + Data(dpy, data, dataLen); + + if (requestNumber == totalRequests) { + UnlockDisplay(dpy); + SyncHandle(); + } +#endif /* USE_XCB */ +} + + +/** + * Send a command that is too large for the GLXRender protocol request. + * + * Send a large command, one that is too large for some reason to + * send using the GLXRender protocol request. One reason to send + * a large command is to avoid copying the data. + * + * \param ctx GLX context + * \param header Header data. + * \param headerLen Size, in bytes, of the header data. It is assumed that + * the header data will always be small enough to fit in + * a single X protocol packet. + * \param data Command data. + * \param dataLen Size, in bytes, of the command data. + */ +_X_HIDDEN void +__glXSendLargeCommand(__GLXcontext * ctx, + const GLvoid * header, GLint headerLen, + const GLvoid * data, GLint dataLen) +{ + GLint maxSize; + GLint totalRequests, requestNumber; + + /* + ** Calculate the maximum amount of data can be stuffed into a single + ** packet. sz_xGLXRenderReq is added because bufSize is the maximum + ** packet size minus sz_xGLXRenderReq. + */ + maxSize = (ctx->bufSize + sz_xGLXRenderReq) - sz_xGLXRenderLargeReq; + totalRequests = 1 + (dataLen / maxSize); + if (dataLen % maxSize) + totalRequests++; + + /* + ** Send all of the command, except the large array, as one request. + */ + assert(headerLen <= maxSize); + __glXSendLargeChunk(ctx, 1, totalRequests, header, headerLen); + + /* + ** Send enough requests until the whole array is sent. + */ + for (requestNumber = 2; requestNumber <= (totalRequests - 1); + requestNumber++) { + __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, maxSize); + data = (const GLvoid *) (((const GLubyte *) data) + maxSize); + dataLen -= maxSize; + assert(dataLen > 0); + } + + assert(dataLen <= maxSize); + __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, dataLen); +} + +/************************************************************************/ + +#ifdef DEBUG +_X_HIDDEN void +__glXDumpDrawBuffer(__GLXcontext * ctx) +{ + GLubyte *p = ctx->buf; + GLubyte *end = ctx->pc; + GLushort opcode, length; + + while (p < end) { + /* Fetch opcode */ + opcode = *((GLushort *) p); + length = *((GLushort *) (p + 2)); + printf("%2x: %5d: ", opcode, length); + length -= 4; + p += 4; + while (length > 0) { + printf("%08x ", *((unsigned *) p)); + p += 4; + length -= 4; + } + printf("\n"); + } +} +#endif diff --git a/src/glx/glxextensions.c b/src/glx/glxextensions.c new file mode 100644 index 00000000000..56c69cbfcba --- /dev/null +++ b/src/glx/glxextensions.c @@ -0,0 +1,714 @@ +/* + * (C) Copyright IBM Corporation 2002, 2004 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file glxextensions.c + * + * \author Ian Romanick + */ + +#include "glxclient.h" +#include +#include +#include +#include "glxextensions.h" + + +#define SET_BIT(m,b) (m[ (b) / 8 ] |= (1U << ((b) % 8))) +#define CLR_BIT(m,b) (m[ (b) / 8 ] &= ~(1U << ((b) % 8))) +#define IS_SET(m,b) ((m[ (b) / 8 ] & (1U << ((b) % 8))) != 0) +#define CONCAT(a,b) a ## b +#define GLX(n) "GLX_" # n, 4 + sizeof( # n ) - 1, CONCAT(n,_bit) +#define GL(n) "GL_" # n, 3 + sizeof( # n ) - 1, GL_ ## n ## _bit +#define VER(a,b) a, b +#define Y 1 +#define N 0 +#define EXT_ENABLED(bit,supported) (IS_SET( supported, bit )) + + +struct extension_info +{ + const char *const name; + unsigned name_len; + + unsigned char bit; + + /* This is the lowest version of GLX that "requires" this extension. + * For example, GLX 1.3 requires SGIX_fbconfig, SGIX_pbuffer, and + * SGI_make_current_read. If the extension is not required by any known + * version of GLX, use 0, 0. + */ + unsigned char version_major; + unsigned char version_minor; + unsigned char client_support; + unsigned char direct_support; + unsigned char client_only; /** Is the extension client-side only? */ + unsigned char direct_only; /** Is the extension for direct + * contexts only? + */ +}; + +/* *INDENT-OFF* */ +static const struct extension_info known_glx_extensions[] = { + { GLX(ARB_get_proc_address), VER(1,4), Y, N, Y, N }, + { GLX(ARB_multisample), VER(1,4), Y, Y, N, N }, + { GLX(ARB_render_texture), VER(0,0), N, N, N, N }, + { GLX(ATI_pixel_format_float), VER(0,0), N, N, N, N }, + { GLX(EXT_import_context), VER(0,0), Y, Y, N, N }, + { GLX(EXT_visual_info), VER(0,0), Y, Y, N, N }, + { GLX(EXT_visual_rating), VER(0,0), Y, Y, N, N }, + { GLX(MESA_agp_offset), VER(0,0), N, N, N, Y }, /* Deprecated */ + { GLX(MESA_allocate_memory), VER(0,0), Y, N, N, Y }, + { GLX(MESA_copy_sub_buffer), VER(0,0), Y, N, N, N }, + { GLX(MESA_pixmap_colormap), VER(0,0), N, N, N, N }, /* Deprecated */ + { GLX(MESA_release_buffers), VER(0,0), N, N, N, N }, /* Deprecated */ + { GLX(MESA_swap_control), VER(0,0), Y, N, N, Y }, + { GLX(MESA_swap_frame_usage), VER(0,0), Y, N, N, Y }, + { GLX(NV_float_buffer), VER(0,0), N, N, N, N }, + { GLX(NV_render_depth_texture), VER(0,0), N, N, N, N }, + { GLX(NV_render_texture_rectangle), VER(0,0), N, N, N, N }, + { GLX(NV_vertex_array_range), VER(0,0), N, N, N, Y }, /* Deprecated */ + { GLX(OML_swap_method), VER(0,0), Y, Y, N, N }, + { GLX(OML_sync_control), VER(0,0), Y, N, N, Y }, + { GLX(SGI_make_current_read), VER(1,3), Y, N, N, N }, + { GLX(SGI_swap_control), VER(0,0), Y, N, N, N }, + { GLX(SGI_video_sync), VER(0,0), Y, N, N, Y }, + { GLX(SGIS_blended_overlay), VER(0,0), N, N, N, N }, + { GLX(SGIS_color_range), VER(0,0), N, N, N, N }, + { GLX(SGIS_multisample), VER(0,0), Y, Y, N, N }, + { GLX(SGIX_fbconfig), VER(1,3), Y, Y, N, N }, + { GLX(SGIX_pbuffer), VER(1,3), Y, Y, N, N }, + { GLX(SGIX_swap_barrier), VER(0,0), N, N, N, N }, + { GLX(SGIX_swap_group), VER(0,0), N, N, N, N }, + { GLX(SGIX_visual_select_group), VER(0,0), Y, Y, N, N }, + { GLX(EXT_texture_from_pixmap), VER(0,0), Y, N, N, N }, + { GLX(INTEL_swap_event), VER(1,4), Y, Y, N, N }, + { NULL } +}; + +static const struct extension_info known_gl_extensions[] = { + { GL(ARB_depth_texture), VER(1,4), Y, N, N, N }, + { GL(ARB_draw_buffers), VER(0,0), Y, N, N, N }, + { GL(ARB_fragment_program), VER(0,0), Y, N, N, N }, + { GL(ARB_fragment_program_shadow), VER(0,0), Y, N, N, N }, + { GL(ARB_framebuffer_object), VER(0,0), Y, N, N, N }, + { GL(ARB_imaging), VER(0,0), Y, N, N, N }, + { GL(ARB_multisample), VER(1,3), Y, N, N, N }, + { GL(ARB_multitexture), VER(1,3), Y, N, N, N }, + { GL(ARB_occlusion_query), VER(1,5), Y, N, N, N }, + { GL(ARB_point_parameters), VER(1,4), Y, N, N, N }, + { GL(ARB_point_sprite), VER(0,0), Y, N, N, N }, + { GL(ARB_shadow), VER(1,4), Y, N, N, N }, + { GL(ARB_shadow_ambient), VER(0,0), Y, N, N, N }, + { GL(ARB_texture_border_clamp), VER(1,3), Y, N, N, N }, + { GL(ARB_texture_compression), VER(1,3), Y, N, N, N }, + { GL(ARB_texture_cube_map), VER(1,3), Y, N, N, N }, + { GL(ARB_texture_env_add), VER(1,3), Y, N, N, N }, + { GL(ARB_texture_env_combine), VER(1,3), Y, N, N, N }, + { GL(ARB_texture_env_crossbar), VER(1,4), Y, N, N, N }, + { GL(ARB_texture_env_dot3), VER(1,3), Y, N, N, N }, + { GL(ARB_texture_mirrored_repeat), VER(1,4), Y, N, N, N }, + { GL(ARB_texture_non_power_of_two), VER(1,5), Y, N, N, N }, + { GL(ARB_texture_rectangle), VER(0,0), Y, N, N, N }, + { GL(ARB_transpose_matrix), VER(1,3), Y, N, Y, N }, + { GL(ARB_vertex_buffer_object), VER(1,5), N, N, N, N }, + { GL(ARB_vertex_program), VER(0,0), Y, N, N, N }, + { GL(ARB_window_pos), VER(1,4), Y, N, N, N }, + { GL(EXT_abgr), VER(0,0), Y, N, N, N }, + { GL(EXT_bgra), VER(1,2), Y, N, N, N }, + { GL(EXT_blend_color), VER(1,4), Y, N, N, N }, + { GL(EXT_blend_equation_separate), VER(0,0), Y, N, N, N }, + { GL(EXT_blend_func_separate), VER(1,4), Y, N, N, N }, + { GL(EXT_blend_logic_op), VER(1,4), Y, N, N, N }, + { GL(EXT_blend_minmax), VER(1,4), Y, N, N, N }, + { GL(EXT_blend_subtract), VER(1,4), Y, N, N, N }, + { GL(EXT_clip_volume_hint), VER(0,0), Y, N, N, N }, + { GL(EXT_compiled_vertex_array), VER(0,0), N, N, N, N }, + { GL(EXT_convolution), VER(0,0), N, N, N, N }, + { GL(EXT_copy_texture), VER(1,1), Y, N, N, N }, + { GL(EXT_cull_vertex), VER(0,0), N, N, N, N }, + { GL(EXT_depth_bounds_test), VER(0,0), N, N, N, N }, + { GL(EXT_draw_range_elements), VER(1,2), Y, N, Y, N }, + { GL(EXT_fog_coord), VER(1,4), Y, N, N, N }, + { GL(EXT_framebuffer_blit), VER(0,0), Y, N, N, N }, + { GL(EXT_framebuffer_multisample), VER(0,0), Y, N, N, N }, + { GL(EXT_framebuffer_object), VER(0,0), Y, N, N, N }, + { GL(EXT_multi_draw_arrays), VER(1,4), Y, N, Y, N }, + { GL(EXT_packed_depth_stencil), VER(0,0), Y, N, N, N }, + { GL(EXT_packed_pixels), VER(1,2), Y, N, N, N }, + { GL(EXT_paletted_texture), VER(0,0), Y, N, N, N }, + { GL(EXT_pixel_buffer_object), VER(0,0), N, N, N, N }, + { GL(EXT_point_parameters), VER(1,4), Y, N, N, N }, + { GL(EXT_polygon_offset), VER(1,1), Y, N, N, N }, + { GL(EXT_rescale_normal), VER(1,2), Y, N, N, N }, + { GL(EXT_secondary_color), VER(1,4), Y, N, N, N }, + { GL(EXT_separate_specular_color), VER(1,2), Y, N, N, N }, + { GL(EXT_shadow_funcs), VER(1,5), Y, N, N, N }, + { GL(EXT_shared_texture_palette), VER(0,0), Y, N, N, N }, + { GL(EXT_stencil_two_side), VER(0,0), Y, N, N, N }, + { GL(EXT_stencil_wrap), VER(1,4), Y, N, N, N }, + { GL(EXT_subtexture), VER(1,1), Y, N, N, N }, + { GL(EXT_texture), VER(1,1), Y, N, N, N }, + { GL(EXT_texture3D), VER(1,2), Y, N, N, N }, + { GL(EXT_texture_compression_dxt1), VER(0,0), Y, N, N, N }, + { GL(EXT_texture_compression_s3tc), VER(0,0), Y, N, N, N }, + { GL(EXT_texture_edge_clamp), VER(1,2), Y, N, N, N }, + { GL(EXT_texture_env_add), VER(1,3), Y, N, N, N }, + { GL(EXT_texture_env_combine), VER(1,3), Y, N, N, N }, + { GL(EXT_texture_env_dot3), VER(0,0), Y, N, N, N }, + { GL(EXT_texture_filter_anisotropic), VER(0,0), Y, N, N, N }, + { GL(EXT_texture_lod), VER(1,2), Y, N, N, N }, + { GL(EXT_texture_lod_bias), VER(1,4), Y, N, N, N }, + { GL(EXT_texture_mirror_clamp), VER(0,0), Y, N, N, N }, + { GL(EXT_texture_object), VER(1,1), Y, N, N, N }, + { GL(EXT_texture_rectangle), VER(0,0), Y, N, N, N }, + { GL(EXT_vertex_array), VER(0,0), Y, N, N, N }, + { GL(3DFX_texture_compression_FXT1), VER(0,0), Y, N, N, N }, + { GL(APPLE_packed_pixels), VER(1,2), Y, N, N, N }, + { GL(APPLE_ycbcr_422), VER(0,0), Y, N, N, N }, + { GL(ATI_draw_buffers), VER(0,0), Y, N, N, N }, + { GL(ATI_text_fragment_shader), VER(0,0), Y, N, N, N }, + { GL(ATI_texture_env_combine3), VER(0,0), Y, N, N, N }, + { GL(ATI_texture_float), VER(0,0), Y, N, N, N }, + { GL(ATI_texture_mirror_once), VER(0,0), Y, N, N, N }, + { GL(ATIX_texture_env_combine3), VER(0,0), Y, N, N, N }, + { GL(HP_convolution_border_modes), VER(0,0), Y, N, N, N }, + { GL(HP_occlusion_test), VER(0,0), Y, N, N, N }, + { GL(IBM_cull_vertex), VER(0,0), Y, N, N, N }, + { GL(IBM_pixel_filter_hint), VER(0,0), Y, N, N, N }, + { GL(IBM_rasterpos_clip), VER(0,0), Y, N, N, N }, + { GL(IBM_texture_clamp_nodraw), VER(0,0), Y, N, N, N }, + { GL(IBM_texture_mirrored_repeat), VER(0,0), Y, N, N, N }, + { GL(INGR_blend_func_separate), VER(0,0), Y, N, N, N }, + { GL(INGR_interlace_read), VER(0,0), Y, N, N, N }, + { GL(MESA_pack_invert), VER(0,0), Y, N, N, N }, + { GL(MESA_ycbcr_texture), VER(0,0), Y, N, N, N }, + { GL(NV_blend_square), VER(1,4), Y, N, N, N }, + { GL(NV_copy_depth_to_color), VER(0,0), Y, N, N, N }, + { GL(NV_depth_clamp), VER(0,0), Y, N, N, N }, + { GL(NV_fog_distance), VER(0,0), Y, N, N, N }, + { GL(NV_fragment_program), VER(0,0), Y, N, N, N }, + { GL(NV_fragment_program_option), VER(0,0), Y, N, N, N }, + { GL(NV_fragment_program2), VER(0,0), Y, N, N, N }, + { GL(NV_light_max_exponent), VER(0,0), Y, N, N, N }, + { GL(NV_multisample_filter_hint), VER(0,0), Y, N, N, N }, + { GL(NV_packed_depth_stencil), VER(0,0), Y, N, N, N }, + { GL(NV_point_sprite), VER(0,0), Y, N, N, N }, + { GL(NV_texgen_reflection), VER(0,0), Y, N, N, N }, + { GL(NV_texture_compression_vtc), VER(0,0), Y, N, N, N }, + { GL(NV_texture_env_combine4), VER(0,0), Y, N, N, N }, + { GL(NV_texture_rectangle), VER(0,0), Y, N, N, N }, + { GL(NV_vertex_program), VER(0,0), Y, N, N, N }, + { GL(NV_vertex_program1_1), VER(0,0), Y, N, N, N }, + { GL(NV_vertex_program2), VER(0,0), Y, N, N, N }, + { GL(NV_vertex_program2_option), VER(0,0), Y, N, N, N }, + { GL(NV_vertex_program3), VER(0,0), Y, N, N, N }, + { GL(OES_read_format), VER(0,0), Y, N, N, N }, + { GL(OES_compressed_paletted_texture),VER(0,0), Y, N, N, N }, + { GL(SGI_color_matrix), VER(0,0), Y, N, N, N }, + { GL(SGI_color_table), VER(0,0), Y, N, N, N }, + { GL(SGI_texture_color_table), VER(0,0), Y, N, N, N }, + { GL(SGIS_generate_mipmap), VER(1,4), Y, N, N, N }, + { GL(SGIS_multisample), VER(0,0), Y, N, N, N }, + { GL(SGIS_texture_border_clamp), VER(1,3), Y, N, N, N }, + { GL(SGIS_texture_edge_clamp), VER(1,2), Y, N, N, N }, + { GL(SGIS_texture_lod), VER(1,2), Y, N, N, N }, + { GL(SGIX_blend_alpha_minmax), VER(0,0), Y, N, N, N }, + { GL(SGIX_clipmap), VER(0,0), Y, N, N, N }, + { GL(SGIX_depth_texture), VER(0,0), Y, N, N, N }, + { GL(SGIX_fog_offset), VER(0,0), Y, N, N, N }, + { GL(SGIX_shadow), VER(0,0), Y, N, N, N }, + { GL(SGIX_shadow_ambient), VER(0,0), Y, N, N, N }, + { GL(SGIX_texture_coordinate_clamp), VER(0,0), Y, N, N, N }, + { GL(SGIX_texture_lod_bias), VER(0,0), Y, N, N, N }, + { GL(SGIX_texture_range), VER(0,0), Y, N, N, N }, + { GL(SGIX_texture_scale_bias), VER(0,0), Y, N, N, N }, + { GL(SGIX_vertex_preclip), VER(0,0), Y, N, N, N }, + { GL(SGIX_vertex_preclip_hint), VER(0,0), Y, N, N, N }, + { GL(SGIX_ycrcb), VER(0,0), Y, N, N, N }, + { GL(SUN_convolution_border_modes), VER(0,0), Y, N, N, N }, + { GL(SUN_multi_draw_arrays), VER(0,0), Y, N, Y, N }, + { GL(SUN_slice_accum), VER(0,0), Y, N, N, N }, + { NULL } +}; +/* *INDENT-ON* */ + + +/* global bit-fields of available extensions and their characteristics */ +static unsigned char client_glx_support[8]; +static unsigned char client_glx_only[8]; +static unsigned char direct_glx_only[8]; +static unsigned char client_gl_support[__GL_EXT_BYTES]; +static unsigned char client_gl_only[__GL_EXT_BYTES]; + +/** + * Bits representing the set of extensions that are enabled by default in all + * direct rendering drivers. + */ +static unsigned char direct_glx_support[8]; + +/** + * Highest core GL version that can be supported for indirect rendering. + */ +static const unsigned gl_major = 1; +static const unsigned gl_minor = 4; + +/* client extensions string */ +static const char *__glXGLXClientExtensions = NULL; + +static void __glXExtensionsCtr(void); +static void __glXExtensionsCtrScreen(__GLXscreenConfigs * psc); +static void __glXProcessServerString(const struct extension_info *ext, + const char *server_string, + unsigned char *server_support); + +/** + * Set the state of a GLX extension. + * + * \param name Name of the extension. + * \param name_len Length, in characters, of the extension name. + * \param state New state (either enabled or disabled) of the extension. + * \param supported Table in which the state of the extension is to be set. + */ +static void +set_glx_extension(const struct extension_info *ext, + const char *name, unsigned name_len, GLboolean state, + unsigned char *supported) +{ + unsigned i; + + + for (i = 0; ext[i].name != NULL; i++) { + if ((name_len == ext[i].name_len) + && (strncmp(ext[i].name, name, name_len) == 0)) { + if (state) { + SET_BIT(supported, ext[i].bit); + } + else { + CLR_BIT(supported, ext[i].bit); + } + + return; + } + } +} + + +#define NUL '\0' +#define SEPARATOR ' ' + +/** + * Convert the server's extension string to a bit-field. + * + * \param server_string GLX extension string from the server. + * \param server_support Bit-field of supported extensions. + * + * \note + * This function is used to process both GLX and GL extension strings. The + * bit-fields used to track each of these have different sizes. Therefore, + * the data pointed by \c server_support must be preinitialized to zero. + */ +static void +__glXProcessServerString(const struct extension_info *ext, + const char *server_string, + unsigned char *server_support) +{ + unsigned base; + unsigned len; + + for (base = 0; server_string[base] != NUL; /* empty */ ) { + /* Determine the length of the next extension name. + */ + for (len = 0; (server_string[base + len] != SEPARATOR) + && (server_string[base + len] != NUL); len++) { + /* empty */ + } + + /* Set the bit for the extension in the server_support table. + */ + set_glx_extension(ext, &server_string[base], len, GL_TRUE, + server_support); + + + /* Advance to the next extension string. This means that we skip + * over the previous string and any trialing white-space. + */ + for (base += len; (server_string[base] == SEPARATOR) + && (server_string[base] != NUL); base++) { + /* empty */ + } + } +} + +void +__glXEnableDirectExtension(__GLXscreenConfigs * psc, const char *name) +{ + __glXExtensionsCtr(); + __glXExtensionsCtrScreen(psc); + + set_glx_extension(known_glx_extensions, + name, strlen(name), GL_TRUE, psc->direct_support); +} + +/** + * Initialize global extension support tables. + */ + +static void +__glXExtensionsCtr(void) +{ + unsigned i; + static GLboolean ext_list_first_time = GL_TRUE; + + + if (ext_list_first_time) { + ext_list_first_time = GL_FALSE; + + (void) memset(client_glx_support, 0, sizeof(client_glx_support)); + (void) memset(direct_glx_support, 0, sizeof(direct_glx_support)); + (void) memset(client_glx_only, 0, sizeof(client_glx_only)); + (void) memset(direct_glx_only, 0, sizeof(direct_glx_only)); + + (void) memset(client_gl_support, 0, sizeof(client_gl_support)); + (void) memset(client_gl_only, 0, sizeof(client_gl_only)); + + for (i = 0; known_glx_extensions[i].name != NULL; i++) { + const unsigned bit = known_glx_extensions[i].bit; + + if (known_glx_extensions[i].client_support) { + SET_BIT(client_glx_support, bit); + } + + if (known_glx_extensions[i].direct_support) { + SET_BIT(direct_glx_support, bit); + } + + if (known_glx_extensions[i].client_only) { + SET_BIT(client_glx_only, bit); + } + + if (known_glx_extensions[i].direct_only) { + SET_BIT(direct_glx_only, bit); + } + } + + for (i = 0; known_gl_extensions[i].name != NULL; i++) { + const unsigned bit = known_gl_extensions[i].bit; + + if (known_gl_extensions[i].client_support) { + SET_BIT(client_gl_support, bit); + } + + if (known_gl_extensions[i].client_only) { + SET_BIT(client_gl_only, bit); + } + } + +#if 0 + fprintf(stderr, "[%s:%u] Maximum client library version: %u.%u\n", + __func__, __LINE__, gl_major, gl_minor); +#endif + } +} + + +/** + * Make sure that per-screen direct-support table is initialized. + * + * \param psc Pointer to GLX per-screen record. + */ + +static void +__glXExtensionsCtrScreen(__GLXscreenConfigs * psc) +{ + if (psc->ext_list_first_time) { + psc->ext_list_first_time = GL_FALSE; + (void) memcpy(psc->direct_support, direct_glx_support, + sizeof(direct_glx_support)); + } +} + + +/** + * Check if a certain extension is enabled on a given screen. + * + * \param psc Pointer to GLX per-screen record. + * \param bit Bit index in the direct-support table. + * \returns If the extension bit is enabled for the screen, \c GL_TRUE is + * returned. If the extension bit is not enabled or if \c psc is + * \c NULL, then \c GL_FALSE is returned. + */ +GLboolean +__glXExtensionBitIsEnabled(__GLXscreenConfigs * psc, unsigned bit) +{ + GLboolean enabled = GL_FALSE; + + if (psc != NULL) { + __glXExtensionsCtr(); + __glXExtensionsCtrScreen(psc); + enabled = EXT_ENABLED(bit, psc->direct_support); + } + + return enabled; +} + + +/** + * Check if a certain extension is enabled in a given context. + * + */ +GLboolean +__glExtensionBitIsEnabled(const __GLXcontext * gc, unsigned bit) +{ + GLboolean enabled = GL_FALSE; + + if (gc != NULL) { + enabled = EXT_ENABLED(bit, gc->gl_extension_bits); + } + + return enabled; +} + + + +/** + * Convert a bit-field to a string of supported extensions. + */ +static char * +__glXGetStringFromTable(const struct extension_info *ext, + const unsigned char *supported) +{ + unsigned i; + unsigned ext_str_len; + char *ext_str; + char *point; + + + ext_str_len = 0; + for (i = 0; ext[i].name != NULL; i++) { + if (EXT_ENABLED(ext[i].bit, supported)) { + ext_str_len += ext[i].name_len + 1; + } + } + + ext_str = Xmalloc(ext_str_len + 1); + if (ext_str != NULL) { + point = ext_str; + + for (i = 0; ext[i].name != NULL; i++) { + if (EXT_ENABLED(ext[i].bit, supported)) { + (void) memcpy(point, ext[i].name, ext[i].name_len); + point += ext[i].name_len; + + *point = ' '; + point++; + } + } + + *point = '\0'; + } + + return ext_str; +} + + +/** + * Get the string of client library supported extensions. + */ +const char * +__glXGetClientExtensions(void) +{ + if (__glXGLXClientExtensions == NULL) { + __glXExtensionsCtr(); + __glXGLXClientExtensions = __glXGetStringFromTable(known_glx_extensions, + client_glx_support); + } + + return __glXGLXClientExtensions; +} + + +/** + * Calculate the list of application usable extensions. The resulting + * string is stored in \c psc->effectiveGLXexts. + * + * \param psc Pointer to GLX per-screen record. + * \param display_is_direct_capable True if the display is capable of + * direct rendering. + * \param minor_version GLX minor version from the server. + */ + +void +__glXCalculateUsableExtensions(__GLXscreenConfigs * psc, + GLboolean display_is_direct_capable, + int minor_version) +{ + unsigned char server_support[8]; + unsigned char usable[8]; + unsigned i; + + __glXExtensionsCtr(); + __glXExtensionsCtrScreen(psc); + + (void) memset(server_support, 0, sizeof(server_support)); + __glXProcessServerString(known_glx_extensions, + psc->serverGLXexts, server_support); + + + /* This is a hack. Some servers support GLX 1.3 but don't export + * all of the extensions implied by GLX 1.3. If the server claims + * support for GLX 1.3, enable support for the extensions that can be + * "emulated" as well. + */ + + if (minor_version >= 3) { + SET_BIT(server_support, EXT_visual_info_bit); + SET_BIT(server_support, EXT_visual_rating_bit); + SET_BIT(server_support, SGI_make_current_read_bit); + SET_BIT(server_support, SGIX_fbconfig_bit); + SET_BIT(server_support, SGIX_pbuffer_bit); + + /* This one is a little iffy. GLX 1.3 doesn't incorporate all of this + * extension. However, the only part that is not strictly client-side + * is shared. That's the glXQueryContext / glXQueryContextInfoEXT + * function. + */ + + SET_BIT(server_support, EXT_import_context_bit); + } + + + /* An extension is supported if the client-side (i.e., libGL) supports + * it and the "server" supports it. In this case that means that either + * the true server supports it or it is only for direct-rendering and + * the direct rendering driver supports it. + * + * If the display is not capable of direct rendering, then the extension + * is enabled if and only if the client-side library and the server + * support it. + */ + + if (display_is_direct_capable) { + for (i = 0; i < 8; i++) { + usable[i] = (client_glx_support[i] & client_glx_only[i]) + | (client_glx_support[i] & psc->direct_support[i] & + server_support[i]) + | (client_glx_support[i] & psc->direct_support[i] & + direct_glx_only[i]); + } + } + else { + for (i = 0; i < 8; i++) { + usable[i] = (client_glx_support[i] & client_glx_only[i]) + | (client_glx_support[i] & server_support[i]); + } + } + + psc->effectiveGLXexts = __glXGetStringFromTable(known_glx_extensions, + usable); +} + + +/** + * Calculate the list of application usable extensions. The resulting + * string is stored in \c gc->extensions. + * + * \param gc Pointer to GLX context. + * \param server_string Extension string from the server. + * \param major_version GL major version from the server. + * \param minor_version GL minor version from the server. + */ + +void +__glXCalculateUsableGLExtensions(__GLXcontext * gc, + const char *server_string, + int major_version, int minor_version) +{ + unsigned char server_support[__GL_EXT_BYTES]; + unsigned char usable[__GL_EXT_BYTES]; + unsigned i; + + + __glXExtensionsCtr(); + + (void) memset(server_support, 0, sizeof(server_support)); + __glXProcessServerString(known_gl_extensions, server_string, + server_support); + + + /* Handle lazy servers that don't export all the extensions strings that + * are part of the GL core version that they support. + */ + + for (i = 0; i < __GL_EXT_BYTES; i++) { + if ((known_gl_extensions[i].version_major != 0) + && ((major_version > known_gl_extensions[i].version_major) + || ((major_version == known_gl_extensions[i].version_major) + && (minor_version >= + known_gl_extensions[i].version_minor)))) { + SET_BIT(server_support, known_gl_extensions[i].bit); + } + } + + + /* An extension is supported if the client-side (i.e., libGL) supports + * it and the server supports it or the client-side library supports it + * and it only needs client-side support. + */ + + for (i = 0; i < __GL_EXT_BYTES; i++) { + usable[i] = (client_gl_support[i] & client_gl_only[i]) + | (client_gl_support[i] & server_support[i]); + } + + gc->extensions = (unsigned char *) + __glXGetStringFromTable(known_gl_extensions, usable); + (void) memcpy(gc->gl_extension_bits, usable, sizeof(usable)); +} + + +/** + * Calculates the maximum core GL version that can be supported for indirect + * rendering. + */ +void +__glXGetGLVersion(int *major_version, int *minor_version) +{ + __glXExtensionsCtr(); + *major_version = gl_major; + *minor_version = gl_minor; +} + + +/** + * Get a string representing the set of extensions supported by the client + * library. This is currently only used to send the list of extensions + * supported by the client to the server. + */ +char * +__glXGetClientGLExtensionString(void) +{ + __glXExtensionsCtr(); + return __glXGetStringFromTable(known_gl_extensions, client_gl_support); +} diff --git a/src/glx/glxextensions.h b/src/glx/glxextensions.h new file mode 100644 index 00000000000..f556b1239c9 --- /dev/null +++ b/src/glx/glxextensions.h @@ -0,0 +1,292 @@ +/* + * (C) Copyright IBM Corporation 2002, 2004 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file glxextensions.h + * + * \author Ian Romanick + */ + +#ifndef GLX_GLXEXTENSIONS_H +#define GLX_GLXEXTENSIONS_H + +enum +{ + ARB_get_proc_address_bit = 0, + ARB_multisample_bit, + ARB_render_texture_bit, + ATI_pixel_format_float_bit, + EXT_visual_info_bit, + EXT_visual_rating_bit, + EXT_import_context_bit, + MESA_agp_offset_bit, + MESA_allocate_memory_bit, /* Replaces MESA_agp_offset & NV_vertex_array_range */ + MESA_copy_sub_buffer_bit, + MESA_depth_float_bit, + MESA_pixmap_colormap_bit, + MESA_release_buffers_bit, + MESA_swap_control_bit, + MESA_swap_frame_usage_bit, + NV_float_buffer_bit, + NV_render_depth_texture_bit, + NV_render_texture_rectangle_bit, + NV_vertex_array_range_bit, + OML_swap_method_bit, + OML_sync_control_bit, + SGI_make_current_read_bit, + SGI_swap_control_bit, + SGI_video_sync_bit, + SGIS_blended_overlay_bit, + SGIS_color_range_bit, + SGIS_multisample_bit, + SGIX_fbconfig_bit, + SGIX_pbuffer_bit, + SGIX_swap_barrier_bit, + SGIX_swap_group_bit, + SGIX_visual_select_group_bit, + EXT_texture_from_pixmap_bit, + INTEL_swap_event_bit, +}; + +enum +{ + GL_ARB_depth_texture_bit = 0, + GL_ARB_draw_buffers_bit, + GL_ARB_fragment_program_bit, + GL_ARB_fragment_program_shadow_bit, + GL_ARB_framebuffer_object_bit, + GL_ARB_imaging_bit, + GL_ARB_multisample_bit, + GL_ARB_multitexture_bit, + GL_ARB_occlusion_query_bit, + GL_ARB_point_parameters_bit, + GL_ARB_point_sprite_bit, + GL_ARB_shadow_bit, + GL_ARB_shadow_ambient_bit, + GL_ARB_texture_border_clamp_bit, + GL_ARB_texture_cube_map_bit, + GL_ARB_texture_compression_bit, + GL_ARB_texture_env_add_bit, + GL_ARB_texture_env_combine_bit, + GL_ARB_texture_env_crossbar_bit, + GL_ARB_texture_env_dot3_bit, + GL_ARB_texture_mirrored_repeat_bit, + GL_ARB_texture_non_power_of_two_bit, + GL_ARB_texture_rectangle_bit, + GL_ARB_transpose_matrix_bit, + GL_ARB_vertex_buffer_object_bit, + GL_ARB_vertex_program_bit, + GL_ARB_window_pos_bit, + GL_EXT_abgr_bit, + GL_EXT_bgra_bit, + GL_EXT_blend_color_bit, + GL_EXT_blend_equation_separate_bit, + GL_EXT_blend_func_separate_bit, + GL_EXT_blend_logic_op_bit, + GL_EXT_blend_minmax_bit, + GL_EXT_blend_subtract_bit, + GL_EXT_clip_volume_hint_bit, + GL_EXT_compiled_vertex_array_bit, + GL_EXT_convolution_bit, + GL_EXT_copy_texture_bit, + GL_EXT_cull_vertex_bit, + GL_EXT_depth_bounds_test_bit, + GL_EXT_draw_range_elements_bit, + GL_EXT_fog_coord_bit, + GL_EXT_framebuffer_blit_bit, + GL_EXT_framebuffer_multisample_bit, + GL_EXT_framebuffer_object_bit, + GL_EXT_multi_draw_arrays_bit, + GL_EXT_packed_depth_stencil_bit, + GL_EXT_packed_pixels_bit, + GL_EXT_paletted_texture_bit, + GL_EXT_pixel_buffer_object_bit, + GL_EXT_polygon_offset_bit, + GL_EXT_rescale_normal_bit, + GL_EXT_secondary_color_bit, + GL_EXT_separate_specular_color_bit, + GL_EXT_shadow_funcs_bit, + GL_EXT_shared_texture_palette_bit, + GL_EXT_stencil_two_side_bit, + GL_EXT_stencil_wrap_bit, + GL_EXT_subtexture_bit, + GL_EXT_texture_bit, + GL_EXT_texture3D_bit, + GL_EXT_texture_compression_dxt1_bit, + GL_EXT_texture_compression_s3tc_bit, + GL_EXT_texture_edge_clamp_bit, + GL_EXT_texture_env_combine_bit, + GL_EXT_texture_env_dot3_bit, + GL_EXT_texture_filter_anisotropic_bit, + GL_EXT_texture_lod_bit, + GL_EXT_texture_lod_bias_bit, + GL_EXT_texture_mirror_clamp_bit, + GL_EXT_texture_object_bit, + GL_EXT_vertex_array_bit, + GL_3DFX_texture_compression_FXT1_bit, + GL_APPLE_packed_pixels_bit, + GL_APPLE_ycbcr_422_bit, + GL_ATI_text_fragment_shader_bit, + GL_ATI_texture_env_combine3_bit, + GL_ATI_texture_float_bit, + GL_ATI_texture_mirror_once_bit, + GL_HP_convolution_border_modes_bit, + GL_HP_occlusion_test_bit, + GL_IBM_cull_vertex_bit, + GL_IBM_pixel_filter_hint_bit, + GL_IBM_rasterpos_clip_bit, + GL_IBM_texture_clamp_nodraw_bit, + GL_INGR_interlace_read_bit, + GL_MESA_pack_invert_bit, + GL_MESA_ycbcr_texture_bit, + GL_NV_blend_square_bit, + GL_NV_copy_depth_to_color_bit, + GL_NV_depth_clamp_bit, + GL_NV_fog_distance_bit, + GL_NV_fragment_program_bit, + GL_NV_fragment_program_option_bit, + GL_NV_fragment_program2_bit, + GL_NV_light_max_exponent_bit, + GL_NV_multisample_filter_hint_bit, + GL_NV_packed_depth_stencil_bit, + GL_NV_point_sprite_bit, + GL_NV_texgen_reflection_bit, + GL_NV_texture_compression_vtc_bit, + GL_NV_texture_env_combine4_bit, + GL_NV_vertex_program_bit, + GL_NV_vertex_program1_1_bit, + GL_NV_vertex_program2_bit, + GL_NV_vertex_program2_option_bit, + GL_NV_vertex_program3_bit, + GL_OES_compressed_paletted_texture_bit, + GL_OES_read_format_bit, + GL_SGI_color_matrix_bit, + GL_SGI_color_table_bit, + GL_SGI_texture_color_table_bit, + GL_SGIS_generate_mipmap_bit, + GL_SGIS_multisample_bit, + GL_SGIS_texture_lod_bit, + GL_SGIX_blend_alpha_minmax_bit, + GL_SGIX_clipmap_bit, + GL_SGIX_depth_texture_bit, + GL_SGIX_fog_offset_bit, + GL_SGIX_shadow_bit, + GL_SGIX_texture_coordinate_clamp_bit, + GL_SGIX_texture_lod_bias_bit, + GL_SGIX_texture_range_bit, + GL_SGIX_texture_scale_bias_bit, + GL_SGIX_vertex_preclip_bit, + GL_SGIX_vertex_preclip_hint_bit, + GL_SGIX_ycrcb_bit, + GL_SUN_convolution_border_modes_bit, + GL_SUN_slice_accum_bit, + + /* This *MUST* go here. If it gets put after the duplicate values it will + * get the value after the last duplicate. + */ + __NUM_GL_EXTS, + + + /* Alias extension bits. These extensions exist in either vendor-specific + * or EXT form and were later promoted to either EXT or ARB form. In all + * cases, the meaning is *exactly* the same. That's why + * EXT_texture_env_combine is *NOT* an alias of ARB_texture_env_combine and + * EXT_texture_env_dot3 is *NOT* an alias of ARB_texture_env_dot3. Be + * careful! When in doubt, src/mesa/main/extensions.c in the Mesa tree + * is a great reference. + */ + + GL_ATI_blend_equation_separate_bit = GL_EXT_blend_equation_separate_bit, + GL_ATI_draw_buffers_bit = GL_ARB_draw_buffers_bit, + GL_ATIX_texture_env_combine3_bit = GL_ATI_texture_env_combine3_bit, + GL_EXT_point_parameters_bit = GL_ARB_point_parameters_bit, + GL_EXT_texture_env_add_bit = GL_ARB_texture_env_add_bit, + GL_EXT_texture_rectangle_bit = GL_ARB_texture_rectangle_bit, + GL_IBM_texture_mirrored_repeat_bit = GL_ARB_texture_mirrored_repeat_bit, + GL_INGR_blend_func_separate_bit = GL_EXT_blend_func_separate_bit, + GL_MESA_window_pos_bit = GL_ARB_window_pos_bit, + GL_NV_texture_rectangle_bit = GL_ARB_texture_rectangle_bit, + GL_SGIS_texture_border_clamp_bit = GL_ARB_texture_border_clamp_bit, + GL_SGIS_texture_edge_clamp_bit = GL_EXT_texture_edge_clamp_bit, + GL_SGIX_shadow_ambient_bit = GL_ARB_shadow_ambient_bit, + GL_SUN_multi_draw_arrays_bit = GL_EXT_multi_draw_arrays_bit +}; + +#define __GL_EXT_BYTES ((__NUM_GL_EXTS + 7) / 8) + +struct __GLXscreenConfigsRec; +struct __GLXcontextRec; + +extern GLboolean __glXExtensionBitIsEnabled(struct __GLXscreenConfigsRec *psc, + unsigned bit); +extern const char *__glXGetClientExtensions(void); +extern void __glXCalculateUsableExtensions(struct __GLXscreenConfigsRec *psc, + GLboolean + display_is_direct_capable, + int server_minor_version); + +extern void __glXCalculateUsableGLExtensions(struct __GLXcontextRec *gc, + const char *server_string, + int major_version, + int minor_version); +extern void __glXGetGLVersion(int *major_version, int *minor_version); +extern char *__glXGetClientGLExtensionString(void); + +extern GLboolean __glExtensionBitIsEnabled(const struct __GLXcontextRec *gc, + unsigned bit); + +extern void +__glXEnableDirectExtension(struct __GLXscreenConfigsRec *psc, + const char *name); + +/* Source-level backwards compatibility with old drivers. They won't + * find the respective functions, though. + */ +typedef void (*PFNGLXENABLEEXTENSIONPROC) (const char *name, + GLboolean force_client); +typedef void (*PFNGLXDISABLEEXTENSIONPROC) (const char *name); + +/* GLX_ALIAS should be used for functions with a non-void return type. + GLX_ALIAS_VOID is for functions with a void return type. */ +#ifdef GLX_NO_STATIC_EXTENSION_FUNCTIONS +# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) +# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) +#else +# if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED) +# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \ + return_type real_func proto_args \ + __attribute__ ((alias( # aliased_func ) )); +# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \ + GLX_ALIAS(void, real_func, proto_args, args, aliased_func) +# else +# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \ + return_type real_func proto_args \ + { return aliased_func args ; } +# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \ + void real_func proto_args \ + { aliased_func args ; } +# endif /* __GNUC__ */ +#endif /* GLX_NO_STATIC_EXTENSION_FUNCTIONS */ + +#endif /* GLX_GLXEXTENSIONS_H */ diff --git a/src/glx/glxhash.c b/src/glx/glxhash.c new file mode 100644 index 00000000000..b76ec323459 --- /dev/null +++ b/src/glx/glxhash.c @@ -0,0 +1,473 @@ +/* glxhash.c -- Small hash table support for integer -> integer mapping + * Taken from libdrm. + * + * Created: Sun Apr 18 09:35:45 1999 by faith@precisioninsight.com + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: Rickard E. (Rik) Faith + * + * DESCRIPTION + * + * This file contains a straightforward implementation of a fixed-sized + * hash table using self-organizing linked lists [Knuth73, pp. 398-399] for + * collision resolution. There are two potentially interesting things + * about this implementation: + * + * 1) The table is power-of-two sized. Prime sized tables are more + * traditional, but do not have a significant advantage over power-of-two + * sized table, especially when double hashing is not used for collision + * resolution. + * + * 2) The hash computation uses a table of random integers [Hanson97, + * pp. 39-41]. + * + * FUTURE ENHANCEMENTS + * + * With a table size of 512, the current implementation is sufficient for a + * few hundred keys. Since this is well above the expected size of the + * tables for which this implementation was designed, the implementation of + * dynamic hash tables was postponed until the need arises. A common (and + * naive) approach to dynamic hash table implementation simply creates a + * new hash table when necessary, rehashes all the data into the new table, + * and destroys the old table. The approach in [Larson88] is superior in + * two ways: 1) only a portion of the table is expanded when needed, + * distributing the expansion cost over several insertions, and 2) portions + * of the table can be locked, enabling a scalable thread-safe + * implementation. + * + * REFERENCES + * + * [Hanson97] David R. Hanson. C Interfaces and Implementations: + * Techniques for Creating Reusable Software. Reading, Massachusetts: + * Addison-Wesley, 1997. + * + * [Knuth73] Donald E. Knuth. The Art of Computer Programming. Volume 3: + * Sorting and Searching. Reading, Massachusetts: Addison-Wesley, 1973. + * + * [Larson88] Per-Ake Larson. "Dynamic Hash Tables". CACM 31(4), April + * 1988, pp. 446-457. + * + */ + +#include "glxhash.h" +#include + +#define HASH_MAIN 0 + +#include +#include +#include + +#define HASH_MAGIC 0xdeadbeef +#define HASH_DEBUG 0 +#define HASH_SIZE 512 /* Good for about 100 entries */ + /* If you change this value, you probably + have to change the HashHash hashing + function! */ + +#define HASH_ALLOC malloc +#define HASH_FREE free +#ifndef __GLIBC__ +#define HASH_RANDOM_DECL char *ps, rs[256] +#define HASH_RANDOM_INIT(seed) ps = initstate(seed, rs, sizeof(rs)) +#define HASH_RANDOM random() +#define HASH_RANDOM_DESTROY setstate(ps) +#else +#define HASH_RANDOM_DECL struct random_data rd; int32_t rv; char rs[256] +#define HASH_RANDOM_INIT(seed) \ + do { \ + (void) memset(&rd, 0, sizeof(rd)); \ + (void) initstate_r(seed, rs, sizeof(rs), &rd); \ + } while(0) +#define HASH_RANDOM ((void) random_r(&rd, &rv), rv) +#define HASH_RANDOM_DESTROY +#endif + +typedef struct __glxHashBucket +{ + unsigned long key; + void *value; + struct __glxHashBucket *next; +} __glxHashBucket, *__glxHashBucketPtr; + +typedef struct __glxHashTable *__glxHashTablePtr; +struct __glxHashTable +{ + unsigned long magic; + unsigned long hits; /* At top of linked list */ + unsigned long partials; /* Not at top of linked list */ + unsigned long misses; /* Not in table */ + __glxHashBucketPtr buckets[HASH_SIZE]; + int p0; + __glxHashBucketPtr p1; +}; + +static unsigned long +HashHash(unsigned long key) +{ + unsigned long hash = 0; + unsigned long tmp = key; + static int init = 0; + static unsigned long scatter[256]; + int i; + + if (!init) { + HASH_RANDOM_DECL; + HASH_RANDOM_INIT(37); + for (i = 0; i < 256; i++) + scatter[i] = HASH_RANDOM; + HASH_RANDOM_DESTROY; + ++init; + } + + while (tmp) { + hash = (hash << 1) + scatter[tmp & 0xff]; + tmp >>= 8; + } + + hash %= HASH_SIZE; +#if HASH_DEBUG + printf("Hash(%d) = %d\n", key, hash); +#endif + return hash; +} + +_X_HIDDEN __glxHashTable * +__glxHashCreate(void) +{ + __glxHashTablePtr table; + int i; + + table = HASH_ALLOC(sizeof(*table)); + if (!table) + return NULL; + table->magic = HASH_MAGIC; + table->hits = 0; + table->partials = 0; + table->misses = 0; + + for (i = 0; i < HASH_SIZE; i++) + table->buckets[i] = NULL; + return table; +} + +_X_HIDDEN int +__glxHashDestroy(__glxHashTable * t) +{ + __glxHashTablePtr table = (__glxHashTablePtr) t; + __glxHashBucketPtr bucket; + __glxHashBucketPtr next; + int i; + + if (table->magic != HASH_MAGIC) + return -1; /* Bad magic */ + + for (i = 0; i < HASH_SIZE; i++) { + for (bucket = table->buckets[i]; bucket;) { + next = bucket->next; + HASH_FREE(bucket); + bucket = next; + } + } + HASH_FREE(table); + return 0; +} + +/* Find the bucket and organize the list so that this bucket is at the + top. */ + +static __glxHashBucketPtr +HashFind(__glxHashTablePtr table, unsigned long key, unsigned long *h) +{ + unsigned long hash = HashHash(key); + __glxHashBucketPtr prev = NULL; + __glxHashBucketPtr bucket; + + if (h) + *h = hash; + + for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) { + if (bucket->key == key) { + if (prev) { + /* Organize */ + prev->next = bucket->next; + bucket->next = table->buckets[hash]; + table->buckets[hash] = bucket; + ++table->partials; + } + else { + ++table->hits; + } + return bucket; + } + prev = bucket; + } + ++table->misses; + return NULL; +} + +_X_HIDDEN int +__glxHashLookup(__glxHashTable * t, unsigned long key, void **value) +{ + __glxHashTablePtr table = (__glxHashTablePtr) t; + __glxHashBucketPtr bucket; + + if (!table || table->magic != HASH_MAGIC) + return -1; /* Bad magic */ + + bucket = HashFind(table, key, NULL); + if (!bucket) + return 1; /* Not found */ + *value = bucket->value; + return 0; /* Found */ +} + +_X_HIDDEN int +__glxHashInsert(__glxHashTable * t, unsigned long key, void *value) +{ + __glxHashTablePtr table = (__glxHashTablePtr) t; + __glxHashBucketPtr bucket; + unsigned long hash; + + if (table->magic != HASH_MAGIC) + return -1; /* Bad magic */ + + if (HashFind(table, key, &hash)) + return 1; /* Already in table */ + + bucket = HASH_ALLOC(sizeof(*bucket)); + if (!bucket) + return -1; /* Error */ + bucket->key = key; + bucket->value = value; + bucket->next = table->buckets[hash]; + table->buckets[hash] = bucket; +#if HASH_DEBUG + printf("Inserted %d at %d/%p\n", key, hash, bucket); +#endif + return 0; /* Added to table */ +} + +_X_HIDDEN int +__glxHashDelete(__glxHashTable * t, unsigned long key) +{ + __glxHashTablePtr table = (__glxHashTablePtr) t; + unsigned long hash; + __glxHashBucketPtr bucket; + + if (table->magic != HASH_MAGIC) + return -1; /* Bad magic */ + + bucket = HashFind(table, key, &hash); + + if (!bucket) + return 1; /* Not found */ + + table->buckets[hash] = bucket->next; + HASH_FREE(bucket); + return 0; +} + +_X_HIDDEN int +__glxHashNext(__glxHashTable * t, unsigned long *key, void **value) +{ + __glxHashTablePtr table = (__glxHashTablePtr) t; + + while (table->p0 < HASH_SIZE) { + if (table->p1) { + *key = table->p1->key; + *value = table->p1->value; + table->p1 = table->p1->next; + return 1; + } + table->p1 = table->buckets[table->p0]; + ++table->p0; + } + return 0; +} + +_X_HIDDEN int +__glxHashFirst(__glxHashTable * t, unsigned long *key, void **value) +{ + __glxHashTablePtr table = (__glxHashTablePtr) t; + + if (table->magic != HASH_MAGIC) + return -1; /* Bad magic */ + + table->p0 = 0; + table->p1 = table->buckets[0]; + return __glxHashNext(table, key, value); +} + +#if HASH_MAIN +#define DIST_LIMIT 10 +static int dist[DIST_LIMIT]; + +static void +clear_dist(void) +{ + int i; + + for (i = 0; i < DIST_LIMIT; i++) + dist[i] = 0; +} + +static int +count_entries(__glxHashBucketPtr bucket) +{ + int count = 0; + + for (; bucket; bucket = bucket->next) + ++count; + return count; +} + +static void +update_dist(int count) +{ + if (count >= DIST_LIMIT) + ++dist[DIST_LIMIT - 1]; + else + ++dist[count]; +} + +static void +compute_dist(__glxHashTablePtr table) +{ + int i; + __glxHashBucketPtr bucket; + + printf("Hits = %ld, partials = %ld, misses = %ld\n", + table->hits, table->partials, table->misses); + clear_dist(); + for (i = 0; i < HASH_SIZE; i++) { + bucket = table->buckets[i]; + update_dist(count_entries(bucket)); + } + for (i = 0; i < DIST_LIMIT; i++) { + if (i != DIST_LIMIT - 1) + printf("%5d %10d\n", i, dist[i]); + else + printf("other %10d\n", dist[i]); + } +} + +static void +check_table(__glxHashTablePtr table, unsigned long key, unsigned long value) +{ + unsigned long retval = 0; + int retcode = __glxHashLookup(table, key, &retval); + + switch (retcode) { + case -1: + printf("Bad magic = 0x%08lx:" + " key = %lu, expected = %lu, returned = %lu\n", + table->magic, key, value, retval); + break; + case 1: + printf("Not found: key = %lu, expected = %lu returned = %lu\n", + key, value, retval); + break; + case 0: + if (value != retval) + printf("Bad value: key = %lu, expected = %lu, returned = %lu\n", + key, value, retval); + break; + default: + printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n", + retcode, key, value, retval); + break; + } +} + +int +main(void) +{ + __glxHashTablePtr table; + int i; + + printf("\n***** 256 consecutive integers ****\n"); + table = __glxHashCreate(); + for (i = 0; i < 256; i++) + __glxHashInsert(table, i, i); + for (i = 0; i < 256; i++) + check_table(table, i, i); + for (i = 256; i >= 0; i--) + check_table(table, i, i); + compute_dist(table); + __glxHashDestroy(table); + + printf("\n***** 1024 consecutive integers ****\n"); + table = __glxHashCreate(); + for (i = 0; i < 1024; i++) + __glxHashInsert(table, i, i); + for (i = 0; i < 1024; i++) + check_table(table, i, i); + for (i = 1024; i >= 0; i--) + check_table(table, i, i); + compute_dist(table); + __glxHashDestroy(table); + + printf("\n***** 1024 consecutive page addresses (4k pages) ****\n"); + table = __glxHashCreate(); + for (i = 0; i < 1024; i++) + __glxHashInsert(table, i * 4096, i); + for (i = 0; i < 1024; i++) + check_table(table, i * 4096, i); + for (i = 1024; i >= 0; i--) + check_table(table, i * 4096, i); + compute_dist(table); + __glxHashDestroy(table); + + printf("\n***** 1024 random integers ****\n"); + table = __glxHashCreate(); + srandom(0xbeefbeef); + for (i = 0; i < 1024; i++) + __glxHashInsert(table, random(), i); + srandom(0xbeefbeef); + for (i = 0; i < 1024; i++) + check_table(table, random(), i); + srandom(0xbeefbeef); + for (i = 0; i < 1024; i++) + check_table(table, random(), i); + compute_dist(table); + __glxHashDestroy(table); + + printf("\n***** 5000 random integers ****\n"); + table = __glxHashCreate(); + srandom(0xbeefbeef); + for (i = 0; i < 5000; i++) + __glxHashInsert(table, random(), i); + srandom(0xbeefbeef); + for (i = 0; i < 5000; i++) + check_table(table, random(), i); + srandom(0xbeefbeef); + for (i = 0; i < 5000; i++) + check_table(table, random(), i); + compute_dist(table); + __glxHashDestroy(table); + + return 0; +} +#endif diff --git a/src/glx/glxhash.h b/src/glx/glxhash.h new file mode 100644 index 00000000000..710712dd28a --- /dev/null +++ b/src/glx/glxhash.h @@ -0,0 +1,20 @@ +#ifndef _GLX_HASH_H_ +#define _GLX_HASH_H_ + + +typedef struct __glxHashTable __glxHashTable; + +/* Hash table routines */ +extern __glxHashTable *__glxHashCreate(void); +extern int __glxHashDestroy(__glxHashTable * t); +extern int __glxHashLookup(__glxHashTable * t, unsigned long key, + void **value); +extern int __glxHashInsert(__glxHashTable * t, unsigned long key, + void *value); +extern int __glxHashDelete(__glxHashTable * t, unsigned long key); +extern int __glxHashFirst(__glxHashTable * t, unsigned long *key, + void **value); +extern int __glxHashNext(__glxHashTable * t, unsigned long *key, + void **value); + +#endif /* _GLX_HASH_H_ */ diff --git a/src/glx/indirect.c b/src/glx/indirect.c new file mode 100644 index 00000000000..48bae1478f4 --- /dev/null +++ b/src/glx/indirect.c @@ -0,0 +1,10669 @@ +/* DO NOT EDIT - This file generated automatically by glX_proto_send.py (from Mesa) script */ + +/* + * (C) Copyright IBM Corporation 2004, 2005 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + + +#include +#include "indirect.h" +#include "glxclient.h" +#include "indirect_size.h" +#include "glapitable.h" +#include "glapidispatch.h" +#include "glapi.h" +#include "glthread.h" +#include +#ifdef USE_XCB +#include +#include +#include +#endif /* USE_XCB */ + +#define __GLX_PAD(n) (((n) + 3) & ~3) + +# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) +# define FASTCALL __attribute__((fastcall)) +# else +# define FASTCALL +# endif +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define NOINLINE __attribute__((noinline)) +# else +# define NOINLINE +# endif + +#if !defined __GNUC__ || __GNUC__ < 3 +# define __builtin_expect(x, y) x +#endif + +/* If the size and opcode values are known at compile-time, this will, on + * x86 at least, emit them with a single instruction. + */ +#define emit_header(dest, op, size) \ + do { union { short s[2]; int i; } temp; \ + temp.s[0] = (size); temp.s[1] = (op); \ + *((int *)(dest)) = temp.i; } while(0) + +NOINLINE CARD32 +__glXReadReply(Display * dpy, size_t size, void *dest, + GLboolean reply_is_always_array) +{ + xGLXSingleReply reply; + + (void) _XReply(dpy, (xReply *) & reply, 0, False); + if (size != 0) { + if ((reply.length > 0) || reply_is_always_array) { + const GLint bytes = (reply_is_always_array) + ? (4 * reply.length) : (reply.size * size); + const GLint extra = 4 - (bytes & 3); + + _XRead(dpy, dest, bytes); + if (extra < 4) { + _XEatData(dpy, extra); + } + } else { + (void) memcpy(dest, &(reply.pad3), size); + } + } + + return reply.retval; +} + +NOINLINE void +__glXReadPixelReply(Display * dpy, __GLXcontext * gc, unsigned max_dim, + GLint width, GLint height, GLint depth, GLenum format, + GLenum type, void *dest, GLboolean dimensions_in_reply) +{ + xGLXSingleReply reply; + GLint size; + + (void) _XReply(dpy, (xReply *) & reply, 0, False); + + if (dimensions_in_reply) { + width = reply.pad3; + height = reply.pad4; + depth = reply.pad5; + + if ((height == 0) || (max_dim < 2)) { + height = 1; + } + if ((depth == 0) || (max_dim < 3)) { + depth = 1; + } + } + + size = reply.length * 4; + if (size != 0) { + void *buf = Xmalloc(size); + + if (buf == NULL) { + _XEatData(dpy, size); + __glXSetError(gc, GL_OUT_OF_MEMORY); + } else { + const GLint extra = 4 - (size & 3); + + _XRead(dpy, buf, size); + if (extra < 4) { + _XEatData(dpy, extra); + } + + __glEmptyImage(gc, 3, width, height, depth, format, type, + buf, dest); + Xfree(buf); + } + } +} + +#define X_GLXSingle 0 + +NOINLINE FASTCALL GLubyte * +__glXSetupSingleRequest(__GLXcontext * gc, GLint sop, GLint cmdlen) +{ + xGLXSingleReq *req; + Display *const dpy = gc->currentDpy; + + (void) __glXFlushRenderBuffer(gc, gc->pc); + LockDisplay(dpy); + GetReqExtra(GLXSingle, cmdlen, req); + req->reqType = gc->majorOpcode; + req->contextTag = gc->currentContextTag; + req->glxCode = sop; + return (GLubyte *) (req) + sz_xGLXSingleReq; +} + +NOINLINE FASTCALL GLubyte * +__glXSetupVendorRequest(__GLXcontext * gc, GLint code, GLint vop, + GLint cmdlen) +{ + xGLXVendorPrivateReq *req; + Display *const dpy = gc->currentDpy; + + (void) __glXFlushRenderBuffer(gc, gc->pc); + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, cmdlen, req); + req->reqType = gc->majorOpcode; + req->glxCode = code; + req->vendorCode = vop; + req->contextTag = gc->currentContextTag; + return (GLubyte *) (req) + sz_xGLXVendorPrivateReq; +} + +const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + +#define zero (__glXDefaultPixelStore+0) +#define one (__glXDefaultPixelStore+8) +#define default_pixel_store_1D (__glXDefaultPixelStore+4) +#define default_pixel_store_1D_size 20 +#define default_pixel_store_2D (__glXDefaultPixelStore+4) +#define default_pixel_store_2D_size 20 +#define default_pixel_store_3D (__glXDefaultPixelStore+0) +#define default_pixel_store_3D_size 36 +#define default_pixel_store_4D (__glXDefaultPixelStore+0) +#define default_pixel_store_4D_size 36 + +static FASTCALL NOINLINE void +generic_3_byte(GLint rop, const void *ptr) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + + emit_header(gc->pc, rop, cmdlen); + (void) memcpy((void *) (gc->pc + 4), ptr, 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +static FASTCALL NOINLINE void +generic_4_byte(GLint rop, const void *ptr) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + + emit_header(gc->pc, rop, cmdlen); + (void) memcpy((void *) (gc->pc + 4), ptr, 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +static FASTCALL NOINLINE void +generic_6_byte(GLint rop, const void *ptr) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + + emit_header(gc->pc, rop, cmdlen); + (void) memcpy((void *) (gc->pc + 4), ptr, 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +static FASTCALL NOINLINE void +generic_8_byte(GLint rop, const void *ptr) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + + emit_header(gc->pc, rop, cmdlen); + (void) memcpy((void *) (gc->pc + 4), ptr, 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +static FASTCALL NOINLINE void +generic_12_byte(GLint rop, const void *ptr) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + + emit_header(gc->pc, rop, cmdlen); + (void) memcpy((void *) (gc->pc + 4), ptr, 12); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +static FASTCALL NOINLINE void +generic_16_byte(GLint rop, const void *ptr) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + + emit_header(gc->pc, rop, cmdlen); + (void) memcpy((void *) (gc->pc + 4), ptr, 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +static FASTCALL NOINLINE void +generic_24_byte(GLint rop, const void *ptr) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + + emit_header(gc->pc, rop, cmdlen); + (void) memcpy((void *) (gc->pc + 4), ptr, 24); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +static FASTCALL NOINLINE void +generic_32_byte(GLint rop, const void *ptr) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 36; + + emit_header(gc->pc, rop, cmdlen); + (void) memcpy((void *) (gc->pc + 4), ptr, 32); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLsop_NewList 101 +void +__indirect_glNewList(GLuint list, GLenum mode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_new_list(c, gc->currentContextTag, list, mode); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_NewList, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&list), 4); + (void) memcpy((void *) (pc + 4), (void *) (&mode), 4); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_EndList 102 +void +__indirect_glEndList(void) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 0; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_end_list(c, gc->currentContextTag); +#else + (void) __glXSetupSingleRequest(gc, X_GLsop_EndList, cmdlen); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLrop_CallList 1 +void +__indirect_glCallList(GLuint list) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_CallList, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&list), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_CallLists 2 +void +__indirect_glCallLists(GLsizei n, GLenum type, const GLvoid * lists) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glCallLists_size(type); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * n)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((n >= 0) && (gc->currentDpy != NULL), 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, X_GLrop_CallLists, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&type), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (lists), + (compsize * n)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = X_GLrop_CallLists; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (pc + 12), (void *) (&type), 4); + __glXSendLargeCommand(gc, pc, 16, lists, (compsize * n)); + } + } +} + +#define X_GLsop_DeleteLists 103 +void +__indirect_glDeleteLists(GLuint list, GLsizei range) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_delete_lists(c, gc->currentContextTag, list, range); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_DeleteLists, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&list), 4); + (void) memcpy((void *) (pc + 4), (void *) (&range), 4); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GenLists 104 +GLuint +__indirect_glGenLists(GLsizei range) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + GLuint retval = (GLuint) 0; +#ifndef USE_XCB + const GLuint cmdlen = 4; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_gen_lists_reply_t *reply = + xcb_glx_gen_lists_reply(c, + xcb_glx_gen_lists(c, + gc->currentContextTag, + range), NULL); + retval = reply->ret_val; + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GenLists, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&range), 4); + retval = (GLuint) __glXReadReply(dpy, 0, NULL, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return retval; +} + +#define X_GLrop_ListBase 3 +void +__indirect_glListBase(GLuint base) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_ListBase, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&base), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Begin 4 +void +__indirect_glBegin(GLenum mode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Begin, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Bitmap 5 +void +__indirect_glBitmap(GLsizei width, GLsizei height, GLfloat xorig, + GLfloat yorig, GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = + (bitmap != NULL) ? __glImageSize(width, height, 1, GL_COLOR_INDEX, + GL_BITMAP, 0) : 0; + const GLuint cmdlen = 48 + __GLX_PAD(compsize); + if (__builtin_expect(gc->currentDpy != NULL, 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, X_GLrop_Bitmap, cmdlen); + (void) memcpy((void *) (gc->pc + 24), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (&height), 4); + (void) memcpy((void *) (gc->pc + 32), (void *) (&xorig), 4); + (void) memcpy((void *) (gc->pc + 36), (void *) (&yorig), 4); + (void) memcpy((void *) (gc->pc + 40), (void *) (&xmove), 4); + (void) memcpy((void *) (gc->pc + 44), (void *) (&ymove), 4); + if (compsize > 0) { + (*gc->fillImage) (gc, 2, width, height, 1, GL_COLOR_INDEX, + GL_BITMAP, bitmap, gc->pc + 48, gc->pc + 4); + } else { + (void) memcpy(gc->pc + 4, default_pixel_store_2D, + default_pixel_store_2D_size); + } + gc->pc += cmdlen; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = X_GLrop_Bitmap; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 28), (void *) (&width), 4); + (void) memcpy((void *) (pc + 32), (void *) (&height), 4); + (void) memcpy((void *) (pc + 36), (void *) (&xorig), 4); + (void) memcpy((void *) (pc + 40), (void *) (&yorig), 4); + (void) memcpy((void *) (pc + 44), (void *) (&xmove), 4); + (void) memcpy((void *) (pc + 48), (void *) (&ymove), 4); + __glXSendLargeImage(gc, compsize, 2, width, height, 1, + GL_COLOR_INDEX, GL_BITMAP, bitmap, pc + 52, + pc + 8); + } + } +} + +#define X_GLrop_Color3bv 6 +void +__indirect_glColor3b(GLbyte red, GLbyte green, GLbyte blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Color3bv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); + (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); + (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color3bv 6 +void +__indirect_glColor3bv(const GLbyte *v) +{ + generic_3_byte(X_GLrop_Color3bv, v); +} + +#define X_GLrop_Color3dv 7 +void +__indirect_glColor3d(GLdouble red, GLdouble green, GLdouble blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_Color3dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&green), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&blue), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color3dv 7 +void +__indirect_glColor3dv(const GLdouble * v) +{ + generic_24_byte(X_GLrop_Color3dv, v); +} + +#define X_GLrop_Color3fv 8 +void +__indirect_glColor3f(GLfloat red, GLfloat green, GLfloat blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Color3fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color3fv 8 +void +__indirect_glColor3fv(const GLfloat * v) +{ + generic_12_byte(X_GLrop_Color3fv, v); +} + +#define X_GLrop_Color3iv 9 +void +__indirect_glColor3i(GLint red, GLint green, GLint blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Color3iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color3iv 9 +void +__indirect_glColor3iv(const GLint * v) +{ + generic_12_byte(X_GLrop_Color3iv, v); +} + +#define X_GLrop_Color3sv 10 +void +__indirect_glColor3s(GLshort red, GLshort green, GLshort blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Color3sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&green), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&blue), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color3sv 10 +void +__indirect_glColor3sv(const GLshort * v) +{ + generic_6_byte(X_GLrop_Color3sv, v); +} + +#define X_GLrop_Color3ubv 11 +void +__indirect_glColor3ub(GLubyte red, GLubyte green, GLubyte blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Color3ubv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); + (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); + (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color3ubv 11 +void +__indirect_glColor3ubv(const GLubyte *v) +{ + generic_3_byte(X_GLrop_Color3ubv, v); +} + +#define X_GLrop_Color3uiv 12 +void +__indirect_glColor3ui(GLuint red, GLuint green, GLuint blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Color3uiv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color3uiv 12 +void +__indirect_glColor3uiv(const GLuint * v) +{ + generic_12_byte(X_GLrop_Color3uiv, v); +} + +#define X_GLrop_Color3usv 13 +void +__indirect_glColor3us(GLushort red, GLushort green, GLushort blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Color3usv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&green), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&blue), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color3usv 13 +void +__indirect_glColor3usv(const GLushort * v) +{ + generic_6_byte(X_GLrop_Color3usv, v); +} + +#define X_GLrop_Color4bv 14 +void +__indirect_glColor4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Color4bv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); + (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); + (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); + (void) memcpy((void *) (gc->pc + 7), (void *) (&alpha), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color4bv 14 +void +__indirect_glColor4bv(const GLbyte *v) +{ + generic_4_byte(X_GLrop_Color4bv, v); +} + +#define X_GLrop_Color4dv 15 +void +__indirect_glColor4d(GLdouble red, GLdouble green, GLdouble blue, + GLdouble alpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 36; + emit_header(gc->pc, X_GLrop_Color4dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&green), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&blue), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&alpha), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color4dv 15 +void +__indirect_glColor4dv(const GLdouble * v) +{ + generic_32_byte(X_GLrop_Color4dv, v); +} + +#define X_GLrop_Color4fv 16 +void +__indirect_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Color4fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&alpha), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color4fv 16 +void +__indirect_glColor4fv(const GLfloat * v) +{ + generic_16_byte(X_GLrop_Color4fv, v); +} + +#define X_GLrop_Color4iv 17 +void +__indirect_glColor4i(GLint red, GLint green, GLint blue, GLint alpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Color4iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&alpha), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color4iv 17 +void +__indirect_glColor4iv(const GLint * v) +{ + generic_16_byte(X_GLrop_Color4iv, v); +} + +#define X_GLrop_Color4sv 18 +void +__indirect_glColor4s(GLshort red, GLshort green, GLshort blue, GLshort alpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Color4sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&green), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&blue), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&alpha), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color4sv 18 +void +__indirect_glColor4sv(const GLshort * v) +{ + generic_8_byte(X_GLrop_Color4sv, v); +} + +#define X_GLrop_Color4ubv 19 +void +__indirect_glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Color4ubv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); + (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); + (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); + (void) memcpy((void *) (gc->pc + 7), (void *) (&alpha), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color4ubv 19 +void +__indirect_glColor4ubv(const GLubyte *v) +{ + generic_4_byte(X_GLrop_Color4ubv, v); +} + +#define X_GLrop_Color4uiv 20 +void +__indirect_glColor4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Color4uiv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&alpha), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color4uiv 20 +void +__indirect_glColor4uiv(const GLuint * v) +{ + generic_16_byte(X_GLrop_Color4uiv, v); +} + +#define X_GLrop_Color4usv 21 +void +__indirect_glColor4us(GLushort red, GLushort green, GLushort blue, + GLushort alpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Color4usv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&green), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&blue), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&alpha), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Color4usv 21 +void +__indirect_glColor4usv(const GLushort * v) +{ + generic_8_byte(X_GLrop_Color4usv, v); +} + +#define X_GLrop_EdgeFlagv 22 +void +__indirect_glEdgeFlag(GLboolean flag) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_EdgeFlagv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&flag), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_EdgeFlagv 22 +void +__indirect_glEdgeFlagv(const GLboolean * flag) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_EdgeFlagv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (flag), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_End 23 +void +__indirect_glEnd(void) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 4; + emit_header(gc->pc, X_GLrop_End, cmdlen); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Indexdv 24 +void +__indirect_glIndexd(GLdouble c) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Indexdv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&c), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Indexdv 24 +void +__indirect_glIndexdv(const GLdouble * c) +{ + generic_8_byte(X_GLrop_Indexdv, c); +} + +#define X_GLrop_Indexfv 25 +void +__indirect_glIndexf(GLfloat c) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Indexfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&c), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Indexfv 25 +void +__indirect_glIndexfv(const GLfloat * c) +{ + generic_4_byte(X_GLrop_Indexfv, c); +} + +#define X_GLrop_Indexiv 26 +void +__indirect_glIndexi(GLint c) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Indexiv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&c), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Indexiv 26 +void +__indirect_glIndexiv(const GLint * c) +{ + generic_4_byte(X_GLrop_Indexiv, c); +} + +#define X_GLrop_Indexsv 27 +void +__indirect_glIndexs(GLshort c) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Indexsv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&c), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Indexsv 27 +void +__indirect_glIndexsv(const GLshort * c) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Indexsv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (c), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Normal3bv 28 +void +__indirect_glNormal3b(GLbyte nx, GLbyte ny, GLbyte nz) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Normal3bv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&nx), 1); + (void) memcpy((void *) (gc->pc + 5), (void *) (&ny), 1); + (void) memcpy((void *) (gc->pc + 6), (void *) (&nz), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Normal3bv 28 +void +__indirect_glNormal3bv(const GLbyte *v) +{ + generic_3_byte(X_GLrop_Normal3bv, v); +} + +#define X_GLrop_Normal3dv 29 +void +__indirect_glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_Normal3dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&nx), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&ny), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&nz), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Normal3dv 29 +void +__indirect_glNormal3dv(const GLdouble * v) +{ + generic_24_byte(X_GLrop_Normal3dv, v); +} + +#define X_GLrop_Normal3fv 30 +void +__indirect_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Normal3fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&nx), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&ny), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&nz), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Normal3fv 30 +void +__indirect_glNormal3fv(const GLfloat * v) +{ + generic_12_byte(X_GLrop_Normal3fv, v); +} + +#define X_GLrop_Normal3iv 31 +void +__indirect_glNormal3i(GLint nx, GLint ny, GLint nz) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Normal3iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&nx), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&ny), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&nz), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Normal3iv 31 +void +__indirect_glNormal3iv(const GLint * v) +{ + generic_12_byte(X_GLrop_Normal3iv, v); +} + +#define X_GLrop_Normal3sv 32 +void +__indirect_glNormal3s(GLshort nx, GLshort ny, GLshort nz) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Normal3sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&nx), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&ny), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&nz), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Normal3sv 32 +void +__indirect_glNormal3sv(const GLshort * v) +{ + generic_6_byte(X_GLrop_Normal3sv, v); +} + +#define X_GLrop_RasterPos2dv 33 +void +__indirect_glRasterPos2d(GLdouble x, GLdouble y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_RasterPos2dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_RasterPos2dv 33 +void +__indirect_glRasterPos2dv(const GLdouble * v) +{ + generic_16_byte(X_GLrop_RasterPos2dv, v); +} + +#define X_GLrop_RasterPos2fv 34 +void +__indirect_glRasterPos2f(GLfloat x, GLfloat y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_RasterPos2fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_RasterPos2fv 34 +void +__indirect_glRasterPos2fv(const GLfloat * v) +{ + generic_8_byte(X_GLrop_RasterPos2fv, v); +} + +#define X_GLrop_RasterPos2iv 35 +void +__indirect_glRasterPos2i(GLint x, GLint y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_RasterPos2iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_RasterPos2iv 35 +void +__indirect_glRasterPos2iv(const GLint * v) +{ + generic_8_byte(X_GLrop_RasterPos2iv, v); +} + +#define X_GLrop_RasterPos2sv 36 +void +__indirect_glRasterPos2s(GLshort x, GLshort y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_RasterPos2sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&y), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_RasterPos2sv 36 +void +__indirect_glRasterPos2sv(const GLshort * v) +{ + generic_4_byte(X_GLrop_RasterPos2sv, v); +} + +#define X_GLrop_RasterPos3dv 37 +void +__indirect_glRasterPos3d(GLdouble x, GLdouble y, GLdouble z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_RasterPos3dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_RasterPos3dv 37 +void +__indirect_glRasterPos3dv(const GLdouble * v) +{ + generic_24_byte(X_GLrop_RasterPos3dv, v); +} + +#define X_GLrop_RasterPos3fv 38 +void +__indirect_glRasterPos3f(GLfloat x, GLfloat y, GLfloat z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_RasterPos3fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_RasterPos3fv 38 +void +__indirect_glRasterPos3fv(const GLfloat * v) +{ + generic_12_byte(X_GLrop_RasterPos3fv, v); +} + +#define X_GLrop_RasterPos3iv 39 +void +__indirect_glRasterPos3i(GLint x, GLint y, GLint z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_RasterPos3iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_RasterPos3iv 39 +void +__indirect_glRasterPos3iv(const GLint * v) +{ + generic_12_byte(X_GLrop_RasterPos3iv, v); +} + +#define X_GLrop_RasterPos3sv 40 +void +__indirect_glRasterPos3s(GLshort x, GLshort y, GLshort z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_RasterPos3sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&y), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&z), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_RasterPos3sv 40 +void +__indirect_glRasterPos3sv(const GLshort * v) +{ + generic_6_byte(X_GLrop_RasterPos3sv, v); +} + +#define X_GLrop_RasterPos4dv 41 +void +__indirect_glRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 36; + emit_header(gc->pc, X_GLrop_RasterPos4dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&w), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_RasterPos4dv 41 +void +__indirect_glRasterPos4dv(const GLdouble * v) +{ + generic_32_byte(X_GLrop_RasterPos4dv, v); +} + +#define X_GLrop_RasterPos4fv 42 +void +__indirect_glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_RasterPos4fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&w), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_RasterPos4fv 42 +void +__indirect_glRasterPos4fv(const GLfloat * v) +{ + generic_16_byte(X_GLrop_RasterPos4fv, v); +} + +#define X_GLrop_RasterPos4iv 43 +void +__indirect_glRasterPos4i(GLint x, GLint y, GLint z, GLint w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_RasterPos4iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&w), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_RasterPos4iv 43 +void +__indirect_glRasterPos4iv(const GLint * v) +{ + generic_16_byte(X_GLrop_RasterPos4iv, v); +} + +#define X_GLrop_RasterPos4sv 44 +void +__indirect_glRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_RasterPos4sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&y), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&z), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&w), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_RasterPos4sv 44 +void +__indirect_glRasterPos4sv(const GLshort * v) +{ + generic_8_byte(X_GLrop_RasterPos4sv, v); +} + +#define X_GLrop_Rectdv 45 +void +__indirect_glRectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 36; + emit_header(gc->pc, X_GLrop_Rectdv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x1), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y1), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&x2), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&y2), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Rectdv 45 +void +__indirect_glRectdv(const GLdouble * v1, const GLdouble * v2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 36; + emit_header(gc->pc, X_GLrop_Rectdv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (v1), 16); + (void) memcpy((void *) (gc->pc + 20), (void *) (v2), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Rectfv 46 +void +__indirect_glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Rectfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x1), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y1), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&x2), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y2), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Rectfv 46 +void +__indirect_glRectfv(const GLfloat * v1, const GLfloat * v2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Rectfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (v1), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (v2), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Rectiv 47 +void +__indirect_glRecti(GLint x1, GLint y1, GLint x2, GLint y2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Rectiv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x1), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y1), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&x2), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y2), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Rectiv 47 +void +__indirect_glRectiv(const GLint * v1, const GLint * v2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Rectiv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (v1), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (v2), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Rectsv 48 +void +__indirect_glRects(GLshort x1, GLshort y1, GLshort x2, GLshort y2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Rectsv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x1), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&y1), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x2), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&y2), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Rectsv 48 +void +__indirect_glRectsv(const GLshort * v1, const GLshort * v2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Rectsv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (v1), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v2), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord1dv 49 +void +__indirect_glTexCoord1d(GLdouble s) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_TexCoord1dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord1dv 49 +void +__indirect_glTexCoord1dv(const GLdouble * v) +{ + generic_8_byte(X_GLrop_TexCoord1dv, v); +} + +#define X_GLrop_TexCoord1fv 50 +void +__indirect_glTexCoord1f(GLfloat s) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_TexCoord1fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord1fv 50 +void +__indirect_glTexCoord1fv(const GLfloat * v) +{ + generic_4_byte(X_GLrop_TexCoord1fv, v); +} + +#define X_GLrop_TexCoord1iv 51 +void +__indirect_glTexCoord1i(GLint s) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_TexCoord1iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord1iv 51 +void +__indirect_glTexCoord1iv(const GLint * v) +{ + generic_4_byte(X_GLrop_TexCoord1iv, v); +} + +#define X_GLrop_TexCoord1sv 52 +void +__indirect_glTexCoord1s(GLshort s) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_TexCoord1sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord1sv 52 +void +__indirect_glTexCoord1sv(const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_TexCoord1sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (v), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord2dv 53 +void +__indirect_glTexCoord2d(GLdouble s, GLdouble t) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_TexCoord2dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord2dv 53 +void +__indirect_glTexCoord2dv(const GLdouble * v) +{ + generic_16_byte(X_GLrop_TexCoord2dv, v); +} + +#define X_GLrop_TexCoord2fv 54 +void +__indirect_glTexCoord2f(GLfloat s, GLfloat t) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_TexCoord2fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&t), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord2fv 54 +void +__indirect_glTexCoord2fv(const GLfloat * v) +{ + generic_8_byte(X_GLrop_TexCoord2fv, v); +} + +#define X_GLrop_TexCoord2iv 55 +void +__indirect_glTexCoord2i(GLint s, GLint t) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_TexCoord2iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&t), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord2iv 55 +void +__indirect_glTexCoord2iv(const GLint * v) +{ + generic_8_byte(X_GLrop_TexCoord2iv, v); +} + +#define X_GLrop_TexCoord2sv 56 +void +__indirect_glTexCoord2s(GLshort s, GLshort t) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_TexCoord2sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&t), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord2sv 56 +void +__indirect_glTexCoord2sv(const GLshort * v) +{ + generic_4_byte(X_GLrop_TexCoord2sv, v); +} + +#define X_GLrop_TexCoord3dv 57 +void +__indirect_glTexCoord3d(GLdouble s, GLdouble t, GLdouble r) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_TexCoord3dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&r), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord3dv 57 +void +__indirect_glTexCoord3dv(const GLdouble * v) +{ + generic_24_byte(X_GLrop_TexCoord3dv, v); +} + +#define X_GLrop_TexCoord3fv 58 +void +__indirect_glTexCoord3f(GLfloat s, GLfloat t, GLfloat r) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_TexCoord3fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&t), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&r), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord3fv 58 +void +__indirect_glTexCoord3fv(const GLfloat * v) +{ + generic_12_byte(X_GLrop_TexCoord3fv, v); +} + +#define X_GLrop_TexCoord3iv 59 +void +__indirect_glTexCoord3i(GLint s, GLint t, GLint r) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_TexCoord3iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&t), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&r), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord3iv 59 +void +__indirect_glTexCoord3iv(const GLint * v) +{ + generic_12_byte(X_GLrop_TexCoord3iv, v); +} + +#define X_GLrop_TexCoord3sv 60 +void +__indirect_glTexCoord3s(GLshort s, GLshort t, GLshort r) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_TexCoord3sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&t), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&r), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord3sv 60 +void +__indirect_glTexCoord3sv(const GLshort * v) +{ + generic_6_byte(X_GLrop_TexCoord3sv, v); +} + +#define X_GLrop_TexCoord4dv 61 +void +__indirect_glTexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 36; + emit_header(gc->pc, X_GLrop_TexCoord4dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&r), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&q), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord4dv 61 +void +__indirect_glTexCoord4dv(const GLdouble * v) +{ + generic_32_byte(X_GLrop_TexCoord4dv, v); +} + +#define X_GLrop_TexCoord4fv 62 +void +__indirect_glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_TexCoord4fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&t), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&r), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&q), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord4fv 62 +void +__indirect_glTexCoord4fv(const GLfloat * v) +{ + generic_16_byte(X_GLrop_TexCoord4fv, v); +} + +#define X_GLrop_TexCoord4iv 63 +void +__indirect_glTexCoord4i(GLint s, GLint t, GLint r, GLint q) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_TexCoord4iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&t), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&r), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&q), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord4iv 63 +void +__indirect_glTexCoord4iv(const GLint * v) +{ + generic_16_byte(X_GLrop_TexCoord4iv, v); +} + +#define X_GLrop_TexCoord4sv 64 +void +__indirect_glTexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_TexCoord4sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&t), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&r), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&q), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexCoord4sv 64 +void +__indirect_glTexCoord4sv(const GLshort * v) +{ + generic_8_byte(X_GLrop_TexCoord4sv, v); +} + +#define X_GLrop_Vertex2dv 65 +void +__indirect_glVertex2d(GLdouble x, GLdouble y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Vertex2dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Vertex2dv 65 +void +__indirect_glVertex2dv(const GLdouble * v) +{ + generic_16_byte(X_GLrop_Vertex2dv, v); +} + +#define X_GLrop_Vertex2fv 66 +void +__indirect_glVertex2f(GLfloat x, GLfloat y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Vertex2fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Vertex2fv 66 +void +__indirect_glVertex2fv(const GLfloat * v) +{ + generic_8_byte(X_GLrop_Vertex2fv, v); +} + +#define X_GLrop_Vertex2iv 67 +void +__indirect_glVertex2i(GLint x, GLint y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Vertex2iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Vertex2iv 67 +void +__indirect_glVertex2iv(const GLint * v) +{ + generic_8_byte(X_GLrop_Vertex2iv, v); +} + +#define X_GLrop_Vertex2sv 68 +void +__indirect_glVertex2s(GLshort x, GLshort y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Vertex2sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&y), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Vertex2sv 68 +void +__indirect_glVertex2sv(const GLshort * v) +{ + generic_4_byte(X_GLrop_Vertex2sv, v); +} + +#define X_GLrop_Vertex3dv 69 +void +__indirect_glVertex3d(GLdouble x, GLdouble y, GLdouble z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_Vertex3dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Vertex3dv 69 +void +__indirect_glVertex3dv(const GLdouble * v) +{ + generic_24_byte(X_GLrop_Vertex3dv, v); +} + +#define X_GLrop_Vertex3fv 70 +void +__indirect_glVertex3f(GLfloat x, GLfloat y, GLfloat z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Vertex3fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Vertex3fv 70 +void +__indirect_glVertex3fv(const GLfloat * v) +{ + generic_12_byte(X_GLrop_Vertex3fv, v); +} + +#define X_GLrop_Vertex3iv 71 +void +__indirect_glVertex3i(GLint x, GLint y, GLint z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Vertex3iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Vertex3iv 71 +void +__indirect_glVertex3iv(const GLint * v) +{ + generic_12_byte(X_GLrop_Vertex3iv, v); +} + +#define X_GLrop_Vertex3sv 72 +void +__indirect_glVertex3s(GLshort x, GLshort y, GLshort z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Vertex3sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&y), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&z), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Vertex3sv 72 +void +__indirect_glVertex3sv(const GLshort * v) +{ + generic_6_byte(X_GLrop_Vertex3sv, v); +} + +#define X_GLrop_Vertex4dv 73 +void +__indirect_glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 36; + emit_header(gc->pc, X_GLrop_Vertex4dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&w), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Vertex4dv 73 +void +__indirect_glVertex4dv(const GLdouble * v) +{ + generic_32_byte(X_GLrop_Vertex4dv, v); +} + +#define X_GLrop_Vertex4fv 74 +void +__indirect_glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Vertex4fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&w), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Vertex4fv 74 +void +__indirect_glVertex4fv(const GLfloat * v) +{ + generic_16_byte(X_GLrop_Vertex4fv, v); +} + +#define X_GLrop_Vertex4iv 75 +void +__indirect_glVertex4i(GLint x, GLint y, GLint z, GLint w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Vertex4iv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&w), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Vertex4iv 75 +void +__indirect_glVertex4iv(const GLint * v) +{ + generic_16_byte(X_GLrop_Vertex4iv, v); +} + +#define X_GLrop_Vertex4sv 76 +void +__indirect_glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Vertex4sv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&y), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&z), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&w), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Vertex4sv 76 +void +__indirect_glVertex4sv(const GLshort * v) +{ + generic_8_byte(X_GLrop_Vertex4sv, v); +} + +#define X_GLrop_ClipPlane 77 +void +__indirect_glClipPlane(GLenum plane, const GLdouble * equation) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 40; + emit_header(gc->pc, X_GLrop_ClipPlane, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (equation), 32); + (void) memcpy((void *) (gc->pc + 36), (void *) (&plane), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ColorMaterial 78 +void +__indirect_glColorMaterial(GLenum face, GLenum mode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_ColorMaterial, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&mode), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_CullFace 79 +void +__indirect_glCullFace(GLenum mode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_CullFace, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Fogf 80 +void +__indirect_glFogf(GLenum pname, GLfloat param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Fogf, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Fogfv 81 +void +__indirect_glFogfv(GLenum pname, const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glFogfv_size(pname); + const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_Fogfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Fogi 82 +void +__indirect_glFogi(GLenum pname, GLint param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Fogi, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Fogiv 83 +void +__indirect_glFogiv(GLenum pname, const GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glFogiv_size(pname); + const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_Fogiv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_FrontFace 84 +void +__indirect_glFrontFace(GLenum mode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_FrontFace, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Hint 85 +void +__indirect_glHint(GLenum target, GLenum mode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Hint, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&mode), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Lightf 86 +void +__indirect_glLightf(GLenum light, GLenum pname, GLfloat param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Lightf, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&light), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Lightfv 87 +void +__indirect_glLightfv(GLenum light, GLenum pname, const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glLightfv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_Lightfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&light), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Lighti 88 +void +__indirect_glLighti(GLenum light, GLenum pname, GLint param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Lighti, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&light), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Lightiv 89 +void +__indirect_glLightiv(GLenum light, GLenum pname, const GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glLightiv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_Lightiv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&light), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_LightModelf 90 +void +__indirect_glLightModelf(GLenum pname, GLfloat param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_LightModelf, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_LightModelfv 91 +void +__indirect_glLightModelfv(GLenum pname, const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glLightModelfv_size(pname); + const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_LightModelfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_LightModeli 92 +void +__indirect_glLightModeli(GLenum pname, GLint param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_LightModeli, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_LightModeliv 93 +void +__indirect_glLightModeliv(GLenum pname, const GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glLightModeliv_size(pname); + const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_LightModeliv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_LineStipple 94 +void +__indirect_glLineStipple(GLint factor, GLushort pattern) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_LineStipple, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&factor), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pattern), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_LineWidth 95 +void +__indirect_glLineWidth(GLfloat width) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_LineWidth, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&width), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Materialf 96 +void +__indirect_glMaterialf(GLenum face, GLenum pname, GLfloat param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Materialf, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Materialfv 97 +void +__indirect_glMaterialfv(GLenum face, GLenum pname, const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glMaterialfv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_Materialfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Materiali 98 +void +__indirect_glMateriali(GLenum face, GLenum pname, GLint param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Materiali, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Materialiv 99 +void +__indirect_glMaterialiv(GLenum face, GLenum pname, const GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glMaterialiv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_Materialiv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PointSize 100 +void +__indirect_glPointSize(GLfloat size) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_PointSize, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&size), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PolygonMode 101 +void +__indirect_glPolygonMode(GLenum face, GLenum mode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_PolygonMode, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&mode), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PolygonStipple 102 +void +__indirect_glPolygonStipple(const GLubyte *mask) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = + (mask != NULL) ? __glImageSize(32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, + 0) : 0; + const GLuint cmdlen = 24 + __GLX_PAD(compsize); + emit_header(gc->pc, X_GLrop_PolygonStipple, cmdlen); + if (compsize > 0) { + (*gc->fillImage) (gc, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, mask, + gc->pc + 24, gc->pc + 4); + } else { + (void) memcpy(gc->pc + 4, default_pixel_store_2D, + default_pixel_store_2D_size); + } + gc->pc += cmdlen; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Scissor 103 +void +__indirect_glScissor(GLint x, GLint y, GLsizei width, GLsizei height) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Scissor, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&height), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ShadeModel 104 +void +__indirect_glShadeModel(GLenum mode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_ShadeModel, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexParameterf 105 +void +__indirect_glTexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_TexParameterf, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexParameterfv 106 +void +__indirect_glTexParameterfv(GLenum target, GLenum pname, + const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glTexParameterfv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_TexParameterfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexParameteri 107 +void +__indirect_glTexParameteri(GLenum target, GLenum pname, GLint param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_TexParameteri, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexParameteriv 108 +void +__indirect_glTexParameteriv(GLenum target, GLenum pname, const GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glTexParameteriv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_TexParameteriv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +static void +__glx_TexImage_1D2D(unsigned opcode, unsigned dim, GLenum target, GLint level, + GLint internalformat, GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid * pixels) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = + __glImageSize(width, height, 1, format, type, target); + const GLuint cmdlen = 56 + __GLX_PAD(compsize); + if (__builtin_expect(gc->currentDpy != NULL, 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, opcode, cmdlen); + (void) memcpy((void *) (gc->pc + 24), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (&level), 4); + (void) memcpy((void *) (gc->pc + 32), (void *) (&internalformat), + 4); + (void) memcpy((void *) (gc->pc + 36), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 40), (void *) (&height), 4); + (void) memcpy((void *) (gc->pc + 44), (void *) (&border), 4); + (void) memcpy((void *) (gc->pc + 48), (void *) (&format), 4); + (void) memcpy((void *) (gc->pc + 52), (void *) (&type), 4); + if ((compsize > 0) && (pixels != NULL)) { + (*gc->fillImage) (gc, dim, width, height, 1, format, type, + pixels, gc->pc + 56, gc->pc + 4); + } else { + (void) memcpy(gc->pc + 4, default_pixel_store_2D, + default_pixel_store_2D_size); + } + gc->pc += cmdlen; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = opcode; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 28), (void *) (&target), 4); + (void) memcpy((void *) (pc + 32), (void *) (&level), 4); + (void) memcpy((void *) (pc + 36), (void *) (&internalformat), 4); + (void) memcpy((void *) (pc + 40), (void *) (&width), 4); + (void) memcpy((void *) (pc + 44), (void *) (&height), 4); + (void) memcpy((void *) (pc + 48), (void *) (&border), 4); + (void) memcpy((void *) (pc + 52), (void *) (&format), 4); + (void) memcpy((void *) (pc + 56), (void *) (&type), 4); + __glXSendLargeImage(gc, compsize, dim, width, height, 1, format, + type, pixels, pc + 60, pc + 8); + } + } +} + +#define X_GLrop_TexImage1D 109 +void +__indirect_glTexImage1D(GLenum target, GLint level, GLint internalformat, + GLsizei width, GLint border, GLenum format, + GLenum type, const GLvoid * pixels) +{ + __glx_TexImage_1D2D(X_GLrop_TexImage1D, 1, target, level, internalformat, + width, 1, border, format, type, pixels); +} + +#define X_GLrop_TexImage2D 110 +void +__indirect_glTexImage2D(GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + __glx_TexImage_1D2D(X_GLrop_TexImage2D, 2, target, level, internalformat, + width, height, border, format, type, pixels); +} + +#define X_GLrop_TexEnvf 111 +void +__indirect_glTexEnvf(GLenum target, GLenum pname, GLfloat param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_TexEnvf, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexEnvfv 112 +void +__indirect_glTexEnvfv(GLenum target, GLenum pname, const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glTexEnvfv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_TexEnvfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexEnvi 113 +void +__indirect_glTexEnvi(GLenum target, GLenum pname, GLint param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_TexEnvi, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexEnviv 114 +void +__indirect_glTexEnviv(GLenum target, GLenum pname, const GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glTexEnviv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_TexEnviv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexGend 115 +void +__indirect_glTexGend(GLenum coord, GLenum pname, GLdouble param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_TexGend, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (¶m), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&coord), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&pname), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexGendv 116 +void +__indirect_glTexGendv(GLenum coord, GLenum pname, const GLdouble * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glTexGendv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 8)); + emit_header(gc->pc, X_GLrop_TexGendv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 8)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexGenf 117 +void +__indirect_glTexGenf(GLenum coord, GLenum pname, GLfloat param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_TexGenf, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexGenfv 118 +void +__indirect_glTexGenfv(GLenum coord, GLenum pname, const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glTexGenfv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_TexGenfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexGeni 119 +void +__indirect_glTexGeni(GLenum coord, GLenum pname, GLint param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_TexGeni, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_TexGeniv 120 +void +__indirect_glTexGeniv(GLenum coord, GLenum pname, const GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glTexGeniv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_TexGeniv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_InitNames 121 +void +__indirect_glInitNames(void) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 4; + emit_header(gc->pc, X_GLrop_InitNames, cmdlen); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_LoadName 122 +void +__indirect_glLoadName(GLuint name) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_LoadName, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&name), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PassThrough 123 +void +__indirect_glPassThrough(GLfloat token) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_PassThrough, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&token), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PopName 124 +void +__indirect_glPopName(void) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 4; + emit_header(gc->pc, X_GLrop_PopName, cmdlen); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PushName 125 +void +__indirect_glPushName(GLuint name) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_PushName, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&name), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_DrawBuffer 126 +void +__indirect_glDrawBuffer(GLenum mode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_DrawBuffer, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Clear 127 +void +__indirect_glClear(GLbitfield mask) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Clear, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mask), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ClearAccum 128 +void +__indirect_glClearAccum(GLfloat red, GLfloat green, GLfloat blue, + GLfloat alpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_ClearAccum, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&alpha), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ClearIndex 129 +void +__indirect_glClearIndex(GLfloat c) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_ClearIndex, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&c), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ClearColor 130 +void +__indirect_glClearColor(GLclampf red, GLclampf green, GLclampf blue, + GLclampf alpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_ClearColor, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&alpha), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ClearStencil 131 +void +__indirect_glClearStencil(GLint s) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_ClearStencil, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ClearDepth 132 +void +__indirect_glClearDepth(GLclampd depth) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_ClearDepth, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&depth), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_StencilMask 133 +void +__indirect_glStencilMask(GLuint mask) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_StencilMask, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mask), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ColorMask 134 +void +__indirect_glColorMask(GLboolean red, GLboolean green, GLboolean blue, + GLboolean alpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_ColorMask, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); + (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); + (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); + (void) memcpy((void *) (gc->pc + 7), (void *) (&alpha), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_DepthMask 135 +void +__indirect_glDepthMask(GLboolean flag) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_DepthMask, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&flag), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_IndexMask 136 +void +__indirect_glIndexMask(GLuint mask) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_IndexMask, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mask), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Accum 137 +void +__indirect_glAccum(GLenum op, GLfloat value) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_Accum, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&value), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PopAttrib 141 +void +__indirect_glPopAttrib(void) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 4; + emit_header(gc->pc, X_GLrop_PopAttrib, cmdlen); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PushAttrib 142 +void +__indirect_glPushAttrib(GLbitfield mask) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_PushAttrib, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mask), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MapGrid1d 147 +void +__indirect_glMapGrid1d(GLint un, GLdouble u1, GLdouble u2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_MapGrid1d, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&u1), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&u2), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&un), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MapGrid1f 148 +void +__indirect_glMapGrid1f(GLint un, GLfloat u1, GLfloat u2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_MapGrid1f, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&un), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&u1), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&u2), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MapGrid2d 149 +void +__indirect_glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, + GLdouble v1, GLdouble v2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 44; + emit_header(gc->pc, X_GLrop_MapGrid2d, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&u1), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&u2), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&v1), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&v2), 8); + (void) memcpy((void *) (gc->pc + 36), (void *) (&un), 4); + (void) memcpy((void *) (gc->pc + 40), (void *) (&vn), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MapGrid2f 150 +void +__indirect_glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, + GLfloat v2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_MapGrid2f, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&un), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&u1), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&u2), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&vn), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&v1), 4); + (void) memcpy((void *) (gc->pc + 24), (void *) (&v2), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_EvalCoord1dv 151 +void +__indirect_glEvalCoord1d(GLdouble u) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_EvalCoord1dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&u), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_EvalCoord1dv 151 +void +__indirect_glEvalCoord1dv(const GLdouble * u) +{ + generic_8_byte(X_GLrop_EvalCoord1dv, u); +} + +#define X_GLrop_EvalCoord1fv 152 +void +__indirect_glEvalCoord1f(GLfloat u) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_EvalCoord1fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&u), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_EvalCoord1fv 152 +void +__indirect_glEvalCoord1fv(const GLfloat * u) +{ + generic_4_byte(X_GLrop_EvalCoord1fv, u); +} + +#define X_GLrop_EvalCoord2dv 153 +void +__indirect_glEvalCoord2d(GLdouble u, GLdouble v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_EvalCoord2dv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&u), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_EvalCoord2dv 153 +void +__indirect_glEvalCoord2dv(const GLdouble * u) +{ + generic_16_byte(X_GLrop_EvalCoord2dv, u); +} + +#define X_GLrop_EvalCoord2fv 154 +void +__indirect_glEvalCoord2f(GLfloat u, GLfloat v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_EvalCoord2fv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&u), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_EvalCoord2fv 154 +void +__indirect_glEvalCoord2fv(const GLfloat * u) +{ + generic_8_byte(X_GLrop_EvalCoord2fv, u); +} + +#define X_GLrop_EvalMesh1 155 +void +__indirect_glEvalMesh1(GLenum mode, GLint i1, GLint i2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_EvalMesh1, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&i1), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&i2), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_EvalPoint1 156 +void +__indirect_glEvalPoint1(GLint i) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_EvalPoint1, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&i), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_EvalMesh2 157 +void +__indirect_glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_EvalMesh2, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&i1), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&i2), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&j1), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&j2), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_EvalPoint2 158 +void +__indirect_glEvalPoint2(GLint i, GLint j) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_EvalPoint2, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&i), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&j), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_AlphaFunc 159 +void +__indirect_glAlphaFunc(GLenum func, GLclampf ref) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_AlphaFunc, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&func), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&ref), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_BlendFunc 160 +void +__indirect_glBlendFunc(GLenum sfactor, GLenum dfactor) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_BlendFunc, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&sfactor), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&dfactor), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_LogicOp 161 +void +__indirect_glLogicOp(GLenum opcode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_LogicOp, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&opcode), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_StencilFunc 162 +void +__indirect_glStencilFunc(GLenum func, GLint ref, GLuint mask) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_StencilFunc, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&func), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&ref), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&mask), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_StencilOp 163 +void +__indirect_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_StencilOp, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&fail), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&zfail), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&zpass), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_DepthFunc 164 +void +__indirect_glDepthFunc(GLenum func) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_DepthFunc, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&func), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PixelZoom 165 +void +__indirect_glPixelZoom(GLfloat xfactor, GLfloat yfactor) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_PixelZoom, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&xfactor), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&yfactor), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PixelTransferf 166 +void +__indirect_glPixelTransferf(GLenum pname, GLfloat param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_PixelTransferf, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PixelTransferi 167 +void +__indirect_glPixelTransferi(GLenum pname, GLint param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_PixelTransferi, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PixelMapfv 168 +void +__indirect_glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat * values) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 4)); + if (mapsize < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((mapsize >= 0) && (gc->currentDpy != NULL), 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, X_GLrop_PixelMapfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&map), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&mapsize), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (values), + (mapsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = X_GLrop_PixelMapfv; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 8), (void *) (&map), 4); + (void) memcpy((void *) (pc + 12), (void *) (&mapsize), 4); + __glXSendLargeCommand(gc, pc, 16, values, (mapsize * 4)); + } + } +} + +#define X_GLrop_PixelMapuiv 169 +void +__indirect_glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint * values) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 4)); + if (mapsize < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((mapsize >= 0) && (gc->currentDpy != NULL), 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, X_GLrop_PixelMapuiv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&map), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&mapsize), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (values), + (mapsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = X_GLrop_PixelMapuiv; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 8), (void *) (&map), 4); + (void) memcpy((void *) (pc + 12), (void *) (&mapsize), 4); + __glXSendLargeCommand(gc, pc, 16, values, (mapsize * 4)); + } + } +} + +#define X_GLrop_PixelMapusv 170 +void +__indirect_glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort * values) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 2)); + if (mapsize < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((mapsize >= 0) && (gc->currentDpy != NULL), 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, X_GLrop_PixelMapusv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&map), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&mapsize), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (values), + (mapsize * 2)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = X_GLrop_PixelMapusv; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 8), (void *) (&map), 4); + (void) memcpy((void *) (pc + 12), (void *) (&mapsize), 4); + __glXSendLargeCommand(gc, pc, 16, values, (mapsize * 2)); + } + } +} + +#define X_GLrop_ReadBuffer 171 +void +__indirect_glReadBuffer(GLenum mode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_ReadBuffer, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_CopyPixels 172 +void +__indirect_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, + GLenum type) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_CopyPixels, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&height), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&type), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLsop_ReadPixels 111 +void +__indirect_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid * pixels) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const __GLXattribute *const state = gc->client_state_private; + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 28; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_read_pixels_reply_t *reply = + xcb_glx_read_pixels_reply(c, + xcb_glx_read_pixels(c, + gc-> + currentContextTag, + x, y, width, height, + format, type, + state->storePack. + swapEndian, 0), + NULL); + (void) memcpy(pixels, xcb_glx_read_pixels_data(reply), + xcb_glx_read_pixels_data_length(reply) * + sizeof(GLvoid)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_ReadPixels, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&x), 4); + (void) memcpy((void *) (pc + 4), (void *) (&y), 4); + (void) memcpy((void *) (pc + 8), (void *) (&width), 4); + (void) memcpy((void *) (pc + 12), (void *) (&height), 4); + (void) memcpy((void *) (pc + 16), (void *) (&format), 4); + (void) memcpy((void *) (pc + 20), (void *) (&type), 4); + *(int32_t *) (pc + 24) = 0; + *(int8_t *) (pc + 24) = state->storePack.swapEndian; + __glXReadPixelReply(dpy, gc, 2, width, height, 1, format, type, + pixels, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLrop_DrawPixels 173 +void +__indirect_glDrawPixels(GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid * pixels) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = + (pixels != NULL) ? __glImageSize(width, height, 1, format, type, + 0) : 0; + const GLuint cmdlen = 40 + __GLX_PAD(compsize); + if (__builtin_expect(gc->currentDpy != NULL, 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, X_GLrop_DrawPixels, cmdlen); + (void) memcpy((void *) (gc->pc + 24), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (&height), 4); + (void) memcpy((void *) (gc->pc + 32), (void *) (&format), 4); + (void) memcpy((void *) (gc->pc + 36), (void *) (&type), 4); + if (compsize > 0) { + (*gc->fillImage) (gc, 2, width, height, 1, format, type, + pixels, gc->pc + 40, gc->pc + 4); + } else { + (void) memcpy(gc->pc + 4, default_pixel_store_2D, + default_pixel_store_2D_size); + } + gc->pc += cmdlen; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = X_GLrop_DrawPixels; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 28), (void *) (&width), 4); + (void) memcpy((void *) (pc + 32), (void *) (&height), 4); + (void) memcpy((void *) (pc + 36), (void *) (&format), 4); + (void) memcpy((void *) (pc + 40), (void *) (&type), 4); + __glXSendLargeImage(gc, compsize, 2, width, height, 1, format, + type, pixels, pc + 44, pc + 8); + } + } +} + +#define X_GLsop_GetClipPlane 113 +void +__indirect_glGetClipPlane(GLenum plane, GLdouble * equation) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 4; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_clip_plane_reply_t *reply = + xcb_glx_get_clip_plane_reply(c, + xcb_glx_get_clip_plane(c, + gc-> + currentContextTag, + plane), NULL); + (void) memcpy(equation, xcb_glx_get_clip_plane_data(reply), + xcb_glx_get_clip_plane_data_length(reply) * + sizeof(GLdouble)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetClipPlane, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&plane), 4); + (void) __glXReadReply(dpy, 8, equation, GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetLightfv 118 +void +__indirect_glGetLightfv(GLenum light, GLenum pname, GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_lightfv_reply_t *reply = + xcb_glx_get_lightfv_reply(c, + xcb_glx_get_lightfv(c, + gc-> + currentContextTag, + light, pname), + NULL); + if (xcb_glx_get_lightfv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_lightfv_data(reply), + xcb_glx_get_lightfv_data_length(reply) * + sizeof(GLfloat)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetLightfv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&light), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetLightiv 119 +void +__indirect_glGetLightiv(GLenum light, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_lightiv_reply_t *reply = + xcb_glx_get_lightiv_reply(c, + xcb_glx_get_lightiv(c, + gc-> + currentContextTag, + light, pname), + NULL); + if (xcb_glx_get_lightiv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_lightiv_data(reply), + xcb_glx_get_lightiv_data_length(reply) * + sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetLightiv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&light), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetMapdv 120 +void +__indirect_glGetMapdv(GLenum target, GLenum query, GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_mapdv_reply_t *reply = + xcb_glx_get_mapdv_reply(c, + xcb_glx_get_mapdv(c, + gc->currentContextTag, + target, query), NULL); + if (xcb_glx_get_mapdv_data_length(reply) == 0) + (void) memcpy(v, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(v, xcb_glx_get_mapdv_data(reply), + xcb_glx_get_mapdv_data_length(reply) * + sizeof(GLdouble)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetMapdv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&query), 4); + (void) __glXReadReply(dpy, 8, v, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetMapfv 121 +void +__indirect_glGetMapfv(GLenum target, GLenum query, GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_mapfv_reply_t *reply = + xcb_glx_get_mapfv_reply(c, + xcb_glx_get_mapfv(c, + gc->currentContextTag, + target, query), NULL); + if (xcb_glx_get_mapfv_data_length(reply) == 0) + (void) memcpy(v, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(v, xcb_glx_get_mapfv_data(reply), + xcb_glx_get_mapfv_data_length(reply) * + sizeof(GLfloat)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetMapfv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&query), 4); + (void) __glXReadReply(dpy, 4, v, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetMapiv 122 +void +__indirect_glGetMapiv(GLenum target, GLenum query, GLint * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_mapiv_reply_t *reply = + xcb_glx_get_mapiv_reply(c, + xcb_glx_get_mapiv(c, + gc->currentContextTag, + target, query), NULL); + if (xcb_glx_get_mapiv_data_length(reply) == 0) + (void) memcpy(v, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(v, xcb_glx_get_mapiv_data(reply), + xcb_glx_get_mapiv_data_length(reply) * + sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetMapiv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&query), 4); + (void) __glXReadReply(dpy, 4, v, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetMaterialfv 123 +void +__indirect_glGetMaterialfv(GLenum face, GLenum pname, GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_materialfv_reply_t *reply = + xcb_glx_get_materialfv_reply(c, + xcb_glx_get_materialfv(c, + gc-> + currentContextTag, + face, pname), + NULL); + if (xcb_glx_get_materialfv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_materialfv_data(reply), + xcb_glx_get_materialfv_data_length(reply) * + sizeof(GLfloat)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetMaterialfv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&face), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetMaterialiv 124 +void +__indirect_glGetMaterialiv(GLenum face, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_materialiv_reply_t *reply = + xcb_glx_get_materialiv_reply(c, + xcb_glx_get_materialiv(c, + gc-> + currentContextTag, + face, pname), + NULL); + if (xcb_glx_get_materialiv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_materialiv_data(reply), + xcb_glx_get_materialiv_data_length(reply) * + sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetMaterialiv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&face), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetPixelMapfv 125 +void +__indirect_glGetPixelMapfv(GLenum map, GLfloat * values) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 4; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_pixel_mapfv_reply_t *reply = + xcb_glx_get_pixel_mapfv_reply(c, + xcb_glx_get_pixel_mapfv(c, + gc-> + currentContextTag, + map), NULL); + if (xcb_glx_get_pixel_mapfv_data_length(reply) == 0) + (void) memcpy(values, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(values, xcb_glx_get_pixel_mapfv_data(reply), + xcb_glx_get_pixel_mapfv_data_length(reply) * + sizeof(GLfloat)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetPixelMapfv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&map), 4); + (void) __glXReadReply(dpy, 4, values, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetPixelMapuiv 126 +void +__indirect_glGetPixelMapuiv(GLenum map, GLuint * values) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 4; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_pixel_mapuiv_reply_t *reply = + xcb_glx_get_pixel_mapuiv_reply(c, + xcb_glx_get_pixel_mapuiv(c, + gc-> + currentContextTag, + map), + NULL); + if (xcb_glx_get_pixel_mapuiv_data_length(reply) == 0) + (void) memcpy(values, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(values, xcb_glx_get_pixel_mapuiv_data(reply), + xcb_glx_get_pixel_mapuiv_data_length(reply) * + sizeof(GLuint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetPixelMapuiv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&map), 4); + (void) __glXReadReply(dpy, 4, values, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetPixelMapusv 127 +void +__indirect_glGetPixelMapusv(GLenum map, GLushort * values) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 4; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_pixel_mapusv_reply_t *reply = + xcb_glx_get_pixel_mapusv_reply(c, + xcb_glx_get_pixel_mapusv(c, + gc-> + currentContextTag, + map), + NULL); + if (xcb_glx_get_pixel_mapusv_data_length(reply) == 0) + (void) memcpy(values, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(values, xcb_glx_get_pixel_mapusv_data(reply), + xcb_glx_get_pixel_mapusv_data_length(reply) * + sizeof(GLushort)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetPixelMapusv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&map), 4); + (void) __glXReadReply(dpy, 2, values, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetPolygonStipple 128 +void +__indirect_glGetPolygonStipple(GLubyte *mask) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 4; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_polygon_stipple_reply_t *reply = + xcb_glx_get_polygon_stipple_reply(c, + xcb_glx_get_polygon_stipple(c, + gc-> + currentContextTag, + 0), + NULL); + (void) memcpy(mask, xcb_glx_get_polygon_stipple_data(reply), + xcb_glx_get_polygon_stipple_data_length(reply) * + sizeof(GLubyte)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetPolygonStipple, cmdlen); + *(int32_t *) (pc + 0) = 0; + __glXReadPixelReply(dpy, gc, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, + mask, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetTexEnvfv 130 +void +__indirect_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_tex_envfv_reply_t *reply = + xcb_glx_get_tex_envfv_reply(c, + xcb_glx_get_tex_envfv(c, + gc-> + currentContextTag, + target, pname), + NULL); + if (xcb_glx_get_tex_envfv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_tex_envfv_data(reply), + xcb_glx_get_tex_envfv_data_length(reply) * + sizeof(GLfloat)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetTexEnvfv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetTexEnviv 131 +void +__indirect_glGetTexEnviv(GLenum target, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_tex_enviv_reply_t *reply = + xcb_glx_get_tex_enviv_reply(c, + xcb_glx_get_tex_enviv(c, + gc-> + currentContextTag, + target, pname), + NULL); + if (xcb_glx_get_tex_enviv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_tex_enviv_data(reply), + xcb_glx_get_tex_enviv_data_length(reply) * + sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetTexEnviv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetTexGendv 132 +void +__indirect_glGetTexGendv(GLenum coord, GLenum pname, GLdouble * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_tex_gendv_reply_t *reply = + xcb_glx_get_tex_gendv_reply(c, + xcb_glx_get_tex_gendv(c, + gc-> + currentContextTag, + coord, pname), + NULL); + if (xcb_glx_get_tex_gendv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_tex_gendv_data(reply), + xcb_glx_get_tex_gendv_data_length(reply) * + sizeof(GLdouble)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetTexGendv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&coord), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 8, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetTexGenfv 133 +void +__indirect_glGetTexGenfv(GLenum coord, GLenum pname, GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_tex_genfv_reply_t *reply = + xcb_glx_get_tex_genfv_reply(c, + xcb_glx_get_tex_genfv(c, + gc-> + currentContextTag, + coord, pname), + NULL); + if (xcb_glx_get_tex_genfv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_tex_genfv_data(reply), + xcb_glx_get_tex_genfv_data_length(reply) * + sizeof(GLfloat)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetTexGenfv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&coord), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetTexGeniv 134 +void +__indirect_glGetTexGeniv(GLenum coord, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_tex_geniv_reply_t *reply = + xcb_glx_get_tex_geniv_reply(c, + xcb_glx_get_tex_geniv(c, + gc-> + currentContextTag, + coord, pname), + NULL); + if (xcb_glx_get_tex_geniv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_tex_geniv_data(reply), + xcb_glx_get_tex_geniv_data_length(reply) * + sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetTexGeniv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&coord), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetTexImage 135 +void +__indirect_glGetTexImage(GLenum target, GLint level, GLenum format, + GLenum type, GLvoid * pixels) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const __GLXattribute *const state = gc->client_state_private; + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 20; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_tex_image_reply_t *reply = + xcb_glx_get_tex_image_reply(c, + xcb_glx_get_tex_image(c, + gc-> + currentContextTag, + target, level, + format, type, + state-> + storePack. + swapEndian), + NULL); + (void) memcpy(pixels, xcb_glx_get_tex_image_data(reply), + xcb_glx_get_tex_image_data_length(reply) * + sizeof(GLvoid)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetTexImage, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&level), 4); + (void) memcpy((void *) (pc + 8), (void *) (&format), 4); + (void) memcpy((void *) (pc + 12), (void *) (&type), 4); + *(int32_t *) (pc + 16) = 0; + *(int8_t *) (pc + 16) = state->storePack.swapEndian; + __glXReadPixelReply(dpy, gc, 3, 0, 0, 0, format, type, pixels, + GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetTexParameterfv 136 +void +__indirect_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_tex_parameterfv_reply_t *reply = + xcb_glx_get_tex_parameterfv_reply(c, + xcb_glx_get_tex_parameterfv(c, + gc-> + currentContextTag, + target, + pname), + NULL); + if (xcb_glx_get_tex_parameterfv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_tex_parameterfv_data(reply), + xcb_glx_get_tex_parameterfv_data_length(reply) * + sizeof(GLfloat)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetTexParameterfv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetTexParameteriv 137 +void +__indirect_glGetTexParameteriv(GLenum target, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_tex_parameteriv_reply_t *reply = + xcb_glx_get_tex_parameteriv_reply(c, + xcb_glx_get_tex_parameteriv(c, + gc-> + currentContextTag, + target, + pname), + NULL); + if (xcb_glx_get_tex_parameteriv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_tex_parameteriv_data(reply), + xcb_glx_get_tex_parameteriv_data_length(reply) * + sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetTexParameteriv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetTexLevelParameterfv 138 +void +__indirect_glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, + GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 12; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_tex_level_parameterfv_reply_t *reply = + xcb_glx_get_tex_level_parameterfv_reply(c, + xcb_glx_get_tex_level_parameterfv + (c, gc->currentContextTag, + target, level, pname), + NULL); + if (xcb_glx_get_tex_level_parameterfv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, + xcb_glx_get_tex_level_parameterfv_data(reply), + xcb_glx_get_tex_level_parameterfv_data_length(reply) + * sizeof(GLfloat)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetTexLevelParameterfv, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&level), 4); + (void) memcpy((void *) (pc + 8), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetTexLevelParameteriv 139 +void +__indirect_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, + GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 12; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_tex_level_parameteriv_reply_t *reply = + xcb_glx_get_tex_level_parameteriv_reply(c, + xcb_glx_get_tex_level_parameteriv + (c, gc->currentContextTag, + target, level, pname), + NULL); + if (xcb_glx_get_tex_level_parameteriv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, + xcb_glx_get_tex_level_parameteriv_data(reply), + xcb_glx_get_tex_level_parameteriv_data_length(reply) + * sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetTexLevelParameteriv, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&level), 4); + (void) memcpy((void *) (pc + 8), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_IsList 141 +GLboolean +__indirect_glIsList(GLuint list) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + GLboolean retval = (GLboolean) 0; +#ifndef USE_XCB + const GLuint cmdlen = 4; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_is_list_reply_t *reply = + xcb_glx_is_list_reply(c, + xcb_glx_is_list(c, gc->currentContextTag, + list), NULL); + retval = reply->ret_val; + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_IsList, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&list), 4); + retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return retval; +} + +#define X_GLrop_DepthRange 174 +void +__indirect_glDepthRange(GLclampd zNear, GLclampd zFar) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_DepthRange, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&zNear), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&zFar), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Frustum 175 +void +__indirect_glFrustum(GLdouble left, GLdouble right, GLdouble bottom, + GLdouble top, GLdouble zNear, GLdouble zFar) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 52; + emit_header(gc->pc, X_GLrop_Frustum, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&left), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&right), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&bottom), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&top), 8); + (void) memcpy((void *) (gc->pc + 36), (void *) (&zNear), 8); + (void) memcpy((void *) (gc->pc + 44), (void *) (&zFar), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_LoadIdentity 176 +void +__indirect_glLoadIdentity(void) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 4; + emit_header(gc->pc, X_GLrop_LoadIdentity, cmdlen); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_LoadMatrixf 177 +void +__indirect_glLoadMatrixf(const GLfloat * m) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 68; + emit_header(gc->pc, X_GLrop_LoadMatrixf, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (m), 64); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_LoadMatrixd 178 +void +__indirect_glLoadMatrixd(const GLdouble * m) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 132; + emit_header(gc->pc, X_GLrop_LoadMatrixd, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (m), 128); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MatrixMode 179 +void +__indirect_glMatrixMode(GLenum mode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_MatrixMode, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultMatrixf 180 +void +__indirect_glMultMatrixf(const GLfloat * m) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 68; + emit_header(gc->pc, X_GLrop_MultMatrixf, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (m), 64); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultMatrixd 181 +void +__indirect_glMultMatrixd(const GLdouble * m) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 132; + emit_header(gc->pc, X_GLrop_MultMatrixd, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (m), 128); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Ortho 182 +void +__indirect_glOrtho(GLdouble left, GLdouble right, GLdouble bottom, + GLdouble top, GLdouble zNear, GLdouble zFar) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 52; + emit_header(gc->pc, X_GLrop_Ortho, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&left), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&right), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&bottom), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&top), 8); + (void) memcpy((void *) (gc->pc + 36), (void *) (&zNear), 8); + (void) memcpy((void *) (gc->pc + 44), (void *) (&zFar), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PopMatrix 183 +void +__indirect_glPopMatrix(void) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 4; + emit_header(gc->pc, X_GLrop_PopMatrix, cmdlen); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PushMatrix 184 +void +__indirect_glPushMatrix(void) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 4; + emit_header(gc->pc, X_GLrop_PushMatrix, cmdlen); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Rotated 185 +void +__indirect_glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 36; + emit_header(gc->pc, X_GLrop_Rotated, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&angle), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&z), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Rotatef 186 +void +__indirect_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Rotatef, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&angle), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&z), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Scaled 187 +void +__indirect_glScaled(GLdouble x, GLdouble y, GLdouble z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_Scaled, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Scalef 188 +void +__indirect_glScalef(GLfloat x, GLfloat y, GLfloat z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Scalef, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Translated 189 +void +__indirect_glTranslated(GLdouble x, GLdouble y, GLdouble z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_Translated, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Translatef 190 +void +__indirect_glTranslatef(GLfloat x, GLfloat y, GLfloat z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Translatef, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Viewport 191 +void +__indirect_glViewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Viewport, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&height), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_BindTexture 4117 +void +__indirect_glBindTexture(GLenum target, GLuint texture) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_BindTexture, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&texture), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Indexubv 194 +void +__indirect_glIndexub(GLubyte c) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Indexubv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&c), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Indexubv 194 +void +__indirect_glIndexubv(const GLubyte *c) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_Indexubv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (c), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PolygonOffset 192 +void +__indirect_glPolygonOffset(GLfloat factor, GLfloat units) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_PolygonOffset, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&factor), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&units), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_CopyTexImage1D 4119 +void +__indirect_glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, + GLint x, GLint y, GLsizei width, GLint border) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 32; + emit_header(gc->pc, X_GLrop_CopyTexImage1D, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&level), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&internalformat), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 24), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (&border), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_CopyTexImage2D 4120 +void +__indirect_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, + GLint x, GLint y, GLsizei width, GLsizei height, + GLint border) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 36; + emit_header(gc->pc, X_GLrop_CopyTexImage2D, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&level), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&internalformat), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 24), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (&height), 4); + (void) memcpy((void *) (gc->pc + 32), (void *) (&border), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_CopyTexSubImage1D 4121 +void +__indirect_glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, + GLint x, GLint y, GLsizei width) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_CopyTexSubImage1D, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&level), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&xoffset), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 24), (void *) (&width), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_CopyTexSubImage2D 4122 +void +__indirect_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint x, GLint y, GLsizei width, + GLsizei height) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 36; + emit_header(gc->pc, X_GLrop_CopyTexSubImage2D, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&level), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&xoffset), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&yoffset), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 24), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 32), (void *) (&height), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLsop_DeleteTextures 144 +void +__indirect_glDeleteTextures(GLsizei n, const GLuint * textures) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); +#endif + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_delete_textures(c, gc->currentContextTag, n, textures); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_DeleteTextures, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4)); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_DeleteTexturesEXT 12 +void +glDeleteTexturesEXT(GLsizei n, const GLuint * textures) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_DeleteTextures(GET_DISPATCH(), (n, textures)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivate, + X_GLvop_DeleteTexturesEXT, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4)); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLsop_GenTextures 145 +void +__indirect_glGenTextures(GLsizei n, GLuint * textures) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 4; +#endif + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_gen_textures_reply_t *reply = + xcb_glx_gen_textures_reply(c, + xcb_glx_gen_textures(c, + gc-> + currentContextTag, + n), NULL); + (void) memcpy(textures, xcb_glx_gen_textures_data(reply), + xcb_glx_gen_textures_data_length(reply) * + sizeof(GLuint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GenTextures, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) __glXReadReply(dpy, 4, textures, GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GenTexturesEXT 13 +void +glGenTexturesEXT(GLsizei n, GLuint * textures) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GenTextures(GET_DISPATCH(), (n, textures)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 4; + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GenTexturesEXT, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) __glXReadReply(dpy, 4, textures, GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLsop_IsTexture 146 +GLboolean +__indirect_glIsTexture(GLuint texture) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + GLboolean retval = (GLboolean) 0; +#ifndef USE_XCB + const GLuint cmdlen = 4; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_is_texture_reply_t *reply = + xcb_glx_is_texture_reply(c, + xcb_glx_is_texture(c, + gc->currentContextTag, + texture), NULL); + retval = reply->ret_val; + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_IsTexture, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&texture), 4); + retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return retval; +} + +#define X_GLvop_IsTextureEXT 14 +GLboolean +glIsTextureEXT(GLuint texture) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + return CALL_IsTexture(GET_DISPATCH(), (texture)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + GLboolean retval = (GLboolean) 0; + const GLuint cmdlen = 4; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_IsTextureEXT, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&texture), 4); + retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return retval; + } +} + +#define X_GLrop_PrioritizeTextures 4118 +void +__indirect_glPrioritizeTextures(GLsizei n, const GLuint * textures, + const GLclampf * priorities) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8 + __GLX_PAD((n * 4)) + __GLX_PAD((n * 4)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_PrioritizeTextures, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (textures), (n * 4)); + (void) memcpy((void *) (gc->pc + 8 + (n * 4)), (void *) (priorities), + (n * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +static void +__glx_TexSubImage_1D2D(unsigned opcode, unsigned dim, GLenum target, + GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid * pixels) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = + (pixels != NULL) ? __glImageSize(width, height, 1, format, type, + target) : 0; + const GLuint cmdlen = 60 + __GLX_PAD(compsize); + if (__builtin_expect(gc->currentDpy != NULL, 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, opcode, cmdlen); + (void) memcpy((void *) (gc->pc + 24), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (&level), 4); + (void) memcpy((void *) (gc->pc + 32), (void *) (&xoffset), 4); + (void) memcpy((void *) (gc->pc + 36), (void *) (&yoffset), 4); + (void) memcpy((void *) (gc->pc + 40), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 44), (void *) (&height), 4); + (void) memcpy((void *) (gc->pc + 48), (void *) (&format), 4); + (void) memcpy((void *) (gc->pc + 52), (void *) (&type), 4); + (void) memset((void *) (gc->pc + 56), 0, 4); + if (compsize > 0) { + (*gc->fillImage) (gc, dim, width, height, 1, format, type, + pixels, gc->pc + 60, gc->pc + 4); + } else { + (void) memcpy(gc->pc + 4, default_pixel_store_2D, + default_pixel_store_2D_size); + } + gc->pc += cmdlen; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = opcode; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 28), (void *) (&target), 4); + (void) memcpy((void *) (pc + 32), (void *) (&level), 4); + (void) memcpy((void *) (pc + 36), (void *) (&xoffset), 4); + (void) memcpy((void *) (pc + 40), (void *) (&yoffset), 4); + (void) memcpy((void *) (pc + 44), (void *) (&width), 4); + (void) memcpy((void *) (pc + 48), (void *) (&height), 4); + (void) memcpy((void *) (pc + 52), (void *) (&format), 4); + (void) memcpy((void *) (pc + 56), (void *) (&type), 4); + (void) memset((void *) (pc + 60), 0, 4); + __glXSendLargeImage(gc, compsize, dim, width, height, 1, format, + type, pixels, pc + 64, pc + 8); + } + } +} + +#define X_GLrop_TexSubImage1D 4099 +void +__indirect_glTexSubImage1D(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, GLenum type, + const GLvoid * pixels) +{ + __glx_TexSubImage_1D2D(X_GLrop_TexSubImage1D, 1, target, level, xoffset, + 1, width, 1, format, type, pixels); +} + +#define X_GLrop_TexSubImage2D 4100 +void +__indirect_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid * pixels) +{ + __glx_TexSubImage_1D2D(X_GLrop_TexSubImage2D, 2, target, level, xoffset, + yoffset, width, height, format, type, pixels); +} + +#define X_GLrop_BlendColor 4096 +void +__indirect_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, + GLclampf alpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_BlendColor, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&alpha), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_BlendEquation 4097 +void +__indirect_glBlendEquation(GLenum mode) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_BlendEquation, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ColorTable 2053 +void +__indirect_glColorTable(GLenum target, GLenum internalformat, GLsizei width, + GLenum format, GLenum type, const GLvoid * table) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = + (table != NULL) ? __glImageSize(width, 1, 1, format, type, + target) : 0; + const GLuint cmdlen = 44 + __GLX_PAD(compsize); + if (__builtin_expect(gc->currentDpy != NULL, 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, X_GLrop_ColorTable, cmdlen); + (void) memcpy((void *) (gc->pc + 24), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (&internalformat), + 4); + (void) memcpy((void *) (gc->pc + 32), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 36), (void *) (&format), 4); + (void) memcpy((void *) (gc->pc + 40), (void *) (&type), 4); + if (compsize > 0) { + (*gc->fillImage) (gc, 1, width, 1, 1, format, type, table, + gc->pc + 44, gc->pc + 4); + } else { + (void) memcpy(gc->pc + 4, default_pixel_store_1D, + default_pixel_store_1D_size); + } + gc->pc += cmdlen; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = X_GLrop_ColorTable; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 28), (void *) (&target), 4); + (void) memcpy((void *) (pc + 32), (void *) (&internalformat), 4); + (void) memcpy((void *) (pc + 36), (void *) (&width), 4); + (void) memcpy((void *) (pc + 40), (void *) (&format), 4); + (void) memcpy((void *) (pc + 44), (void *) (&type), 4); + __glXSendLargeImage(gc, compsize, 1, width, 1, 1, format, type, + table, pc + 48, pc + 8); + } + } +} + +#define X_GLrop_ColorTableParameterfv 2054 +void +__indirect_glColorTableParameterfv(GLenum target, GLenum pname, + const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glColorTableParameterfv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_ColorTableParameterfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ColorTableParameteriv 2055 +void +__indirect_glColorTableParameteriv(GLenum target, GLenum pname, + const GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glColorTableParameteriv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_ColorTableParameteriv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_CopyColorTable 2056 +void +__indirect_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, + GLint y, GLsizei width) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_CopyColorTable, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&internalformat), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&width), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLsop_GetColorTable 147 +void +__indirect_glGetColorTable(GLenum target, GLenum format, GLenum type, + GLvoid * table) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const __GLXattribute *const state = gc->client_state_private; + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 16; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_color_table_reply_t *reply = + xcb_glx_get_color_table_reply(c, + xcb_glx_get_color_table(c, + gc-> + currentContextTag, + target, + format, + type, + state-> + storePack. + swapEndian), + NULL); + (void) memcpy(table, xcb_glx_get_color_table_data(reply), + xcb_glx_get_color_table_data_length(reply) * + sizeof(GLvoid)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetColorTable, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&format), 4); + (void) memcpy((void *) (pc + 8), (void *) (&type), 4); + *(int32_t *) (pc + 12) = 0; + *(int8_t *) (pc + 12) = state->storePack.swapEndian; + __glXReadPixelReply(dpy, gc, 1, 0, 0, 0, format, type, table, + GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GetColorTableSGI 4098 +void +glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid * table) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetColorTable(GET_DISPATCH(), (target, format, type, table)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + const __GLXattribute *const state = gc->client_state_private; + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 16; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetColorTableSGI, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&format), 4); + (void) memcpy((void *) (pc + 8), (void *) (&type), 4); + *(int32_t *) (pc + 12) = 0; + *(int8_t *) (pc + 12) = state->storePack.swapEndian; + __glXReadPixelReply(dpy, gc, 1, 0, 0, 0, format, type, table, + GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLsop_GetColorTableParameterfv 148 +void +__indirect_glGetColorTableParameterfv(GLenum target, GLenum pname, + GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_color_table_parameterfv_reply_t *reply = + xcb_glx_get_color_table_parameterfv_reply(c, + xcb_glx_get_color_table_parameterfv + (c, + gc->currentContextTag, + target, pname), NULL); + if (xcb_glx_get_color_table_parameterfv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, + xcb_glx_get_color_table_parameterfv_data(reply), + xcb_glx_get_color_table_parameterfv_data_length + (reply) * sizeof(GLfloat)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetColorTableParameterfv, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GetColorTableParameterfvSGI 4099 +void +glGetColorTableParameterfvEXT(GLenum target, GLenum pname, GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetColorTableParameterfv(GET_DISPATCH(), + (target, pname, params)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetColorTableParameterfvSGI, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLsop_GetColorTableParameteriv 149 +void +__indirect_glGetColorTableParameteriv(GLenum target, GLenum pname, + GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_color_table_parameteriv_reply_t *reply = + xcb_glx_get_color_table_parameteriv_reply(c, + xcb_glx_get_color_table_parameteriv + (c, + gc->currentContextTag, + target, pname), NULL); + if (xcb_glx_get_color_table_parameteriv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, + xcb_glx_get_color_table_parameteriv_data(reply), + xcb_glx_get_color_table_parameteriv_data_length + (reply) * sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetColorTableParameteriv, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GetColorTableParameterivSGI 4100 +void +glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetColorTableParameteriv(GET_DISPATCH(), + (target, pname, params)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetColorTableParameterivSGI, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLrop_ColorSubTable 195 +void +__indirect_glColorSubTable(GLenum target, GLsizei start, GLsizei count, + GLenum format, GLenum type, const GLvoid * data) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = + (data != NULL) ? __glImageSize(count, 1, 1, format, type, target) : 0; + const GLuint cmdlen = 44 + __GLX_PAD(compsize); + if (__builtin_expect(gc->currentDpy != NULL, 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, X_GLrop_ColorSubTable, cmdlen); + (void) memcpy((void *) (gc->pc + 24), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (&start), 4); + (void) memcpy((void *) (gc->pc + 32), (void *) (&count), 4); + (void) memcpy((void *) (gc->pc + 36), (void *) (&format), 4); + (void) memcpy((void *) (gc->pc + 40), (void *) (&type), 4); + if (compsize > 0) { + (*gc->fillImage) (gc, 1, count, 1, 1, format, type, data, + gc->pc + 44, gc->pc + 4); + } else { + (void) memcpy(gc->pc + 4, default_pixel_store_1D, + default_pixel_store_1D_size); + } + gc->pc += cmdlen; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = X_GLrop_ColorSubTable; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 28), (void *) (&target), 4); + (void) memcpy((void *) (pc + 32), (void *) (&start), 4); + (void) memcpy((void *) (pc + 36), (void *) (&count), 4); + (void) memcpy((void *) (pc + 40), (void *) (&format), 4); + (void) memcpy((void *) (pc + 44), (void *) (&type), 4); + __glXSendLargeImage(gc, compsize, 1, count, 1, 1, format, type, + data, pc + 48, pc + 8); + } + } +} + +#define X_GLrop_CopyColorSubTable 196 +void +__indirect_glCopyColorSubTable(GLenum target, GLsizei start, GLint x, GLint y, + GLsizei width) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_CopyColorSubTable, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&start), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&width), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +static void +__glx_ConvolutionFilter_1D2D(unsigned opcode, unsigned dim, GLenum target, + GLenum internalformat, GLsizei width, + GLsizei height, GLenum format, GLenum type, + const GLvoid * image) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = + (image != NULL) ? __glImageSize(width, height, 1, format, type, + target) : 0; + const GLuint cmdlen = 48 + __GLX_PAD(compsize); + if (__builtin_expect(gc->currentDpy != NULL, 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, opcode, cmdlen); + (void) memcpy((void *) (gc->pc + 24), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (&internalformat), + 4); + (void) memcpy((void *) (gc->pc + 32), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 36), (void *) (&height), 4); + (void) memcpy((void *) (gc->pc + 40), (void *) (&format), 4); + (void) memcpy((void *) (gc->pc + 44), (void *) (&type), 4); + if (compsize > 0) { + (*gc->fillImage) (gc, dim, width, height, 1, format, type, + image, gc->pc + 48, gc->pc + 4); + } else { + (void) memcpy(gc->pc + 4, default_pixel_store_2D, + default_pixel_store_2D_size); + } + gc->pc += cmdlen; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = opcode; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 28), (void *) (&target), 4); + (void) memcpy((void *) (pc + 32), (void *) (&internalformat), 4); + (void) memcpy((void *) (pc + 36), (void *) (&width), 4); + (void) memcpy((void *) (pc + 40), (void *) (&height), 4); + (void) memcpy((void *) (pc + 44), (void *) (&format), 4); + (void) memcpy((void *) (pc + 48), (void *) (&type), 4); + __glXSendLargeImage(gc, compsize, dim, width, height, 1, format, + type, image, pc + 52, pc + 8); + } + } +} + +#define X_GLrop_ConvolutionFilter1D 4101 +void +__indirect_glConvolutionFilter1D(GLenum target, GLenum internalformat, + GLsizei width, GLenum format, GLenum type, + const GLvoid * image) +{ + __glx_ConvolutionFilter_1D2D(X_GLrop_ConvolutionFilter1D, 1, target, + internalformat, width, 1, format, type, + image); +} + +#define X_GLrop_ConvolutionFilter2D 4102 +void +__indirect_glConvolutionFilter2D(GLenum target, GLenum internalformat, + GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid * image) +{ + __glx_ConvolutionFilter_1D2D(X_GLrop_ConvolutionFilter2D, 2, target, + internalformat, width, height, format, type, + image); +} + +#define X_GLrop_ConvolutionParameterf 4103 +void +__indirect_glConvolutionParameterf(GLenum target, GLenum pname, + GLfloat params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_ConvolutionParameterf, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (¶ms), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ConvolutionParameterfv 4104 +void +__indirect_glConvolutionParameterfv(GLenum target, GLenum pname, + const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glConvolutionParameterfv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_ConvolutionParameterfv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ConvolutionParameteri 4105 +void +__indirect_glConvolutionParameteri(GLenum target, GLenum pname, GLint params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_ConvolutionParameteri, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (¶ms), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ConvolutionParameteriv 4106 +void +__indirect_glConvolutionParameteriv(GLenum target, GLenum pname, + const GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glConvolutionParameteriv_size(pname); + const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_ConvolutionParameteriv, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_CopyConvolutionFilter1D 4107 +void +__indirect_glCopyConvolutionFilter1D(GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_CopyConvolutionFilter1D, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&internalformat), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&width), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_CopyConvolutionFilter2D 4108 +void +__indirect_glCopyConvolutionFilter2D(GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width, + GLsizei height) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_CopyConvolutionFilter2D, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&internalformat), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 24), (void *) (&height), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLsop_GetConvolutionFilter 150 +void +__indirect_glGetConvolutionFilter(GLenum target, GLenum format, GLenum type, + GLvoid * image) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const __GLXattribute *const state = gc->client_state_private; + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 16; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_convolution_filter_reply_t *reply = + xcb_glx_get_convolution_filter_reply(c, + xcb_glx_get_convolution_filter + (c, gc->currentContextTag, + target, format, type, + state->storePack. + swapEndian), NULL); + (void) memcpy(image, xcb_glx_get_convolution_filter_data(reply), + xcb_glx_get_convolution_filter_data_length(reply) * + sizeof(GLvoid)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetConvolutionFilter, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&format), 4); + (void) memcpy((void *) (pc + 8), (void *) (&type), 4); + *(int32_t *) (pc + 12) = 0; + *(int8_t *) (pc + 12) = state->storePack.swapEndian; + __glXReadPixelReply(dpy, gc, 2, 0, 0, 0, format, type, image, + GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GetConvolutionFilterEXT 1 +void +gl_dispatch_stub_356(GLenum target, GLenum format, GLenum type, + GLvoid * image) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetConvolutionFilter(GET_DISPATCH(), + (target, format, type, image)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + const __GLXattribute *const state = gc->client_state_private; + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 16; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetConvolutionFilterEXT, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&format), 4); + (void) memcpy((void *) (pc + 8), (void *) (&type), 4); + *(int32_t *) (pc + 12) = 0; + *(int8_t *) (pc + 12) = state->storePack.swapEndian; + __glXReadPixelReply(dpy, gc, 2, 0, 0, 0, format, type, image, + GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLsop_GetConvolutionParameterfv 151 +void +__indirect_glGetConvolutionParameterfv(GLenum target, GLenum pname, + GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_convolution_parameterfv_reply_t *reply = + xcb_glx_get_convolution_parameterfv_reply(c, + xcb_glx_get_convolution_parameterfv + (c, + gc->currentContextTag, + target, pname), NULL); + if (xcb_glx_get_convolution_parameterfv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, + xcb_glx_get_convolution_parameterfv_data(reply), + xcb_glx_get_convolution_parameterfv_data_length + (reply) * sizeof(GLfloat)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetConvolutionParameterfv, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GetConvolutionParameterfvEXT 2 +void +gl_dispatch_stub_357(GLenum target, GLenum pname, GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetConvolutionParameterfv(GET_DISPATCH(), + (target, pname, params)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetConvolutionParameterfvEXT, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLsop_GetConvolutionParameteriv 152 +void +__indirect_glGetConvolutionParameteriv(GLenum target, GLenum pname, + GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_convolution_parameteriv_reply_t *reply = + xcb_glx_get_convolution_parameteriv_reply(c, + xcb_glx_get_convolution_parameteriv + (c, + gc->currentContextTag, + target, pname), NULL); + if (xcb_glx_get_convolution_parameteriv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, + xcb_glx_get_convolution_parameteriv_data(reply), + xcb_glx_get_convolution_parameteriv_data_length + (reply) * sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetConvolutionParameteriv, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GetConvolutionParameterivEXT 3 +void +gl_dispatch_stub_358(GLenum target, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetConvolutionParameteriv(GET_DISPATCH(), + (target, pname, params)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetConvolutionParameterivEXT, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLsop_GetHistogram 154 +void +__indirect_glGetHistogram(GLenum target, GLboolean reset, GLenum format, + GLenum type, GLvoid * values) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const __GLXattribute *const state = gc->client_state_private; + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 16; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_histogram_reply_t *reply = + xcb_glx_get_histogram_reply(c, + xcb_glx_get_histogram(c, + gc-> + currentContextTag, + target, reset, + format, type, + state-> + storePack. + swapEndian), + NULL); + (void) memcpy(values, xcb_glx_get_histogram_data(reply), + xcb_glx_get_histogram_data_length(reply) * + sizeof(GLvoid)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetHistogram, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&format), 4); + (void) memcpy((void *) (pc + 8), (void *) (&type), 4); + *(int32_t *) (pc + 12) = 0; + *(int8_t *) (pc + 12) = state->storePack.swapEndian; + *(int8_t *) (pc + 13) = reset; + __glXReadPixelReply(dpy, gc, 1, 0, 0, 0, format, type, values, + GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GetHistogramEXT 5 +void +gl_dispatch_stub_361(GLenum target, GLboolean reset, GLenum format, + GLenum type, GLvoid * values) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetHistogram(GET_DISPATCH(), + (target, reset, format, type, values)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + const __GLXattribute *const state = gc->client_state_private; + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 16; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetHistogramEXT, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&format), 4); + (void) memcpy((void *) (pc + 8), (void *) (&type), 4); + *(int32_t *) (pc + 12) = 0; + *(int8_t *) (pc + 12) = state->storePack.swapEndian; + *(int8_t *) (pc + 13) = reset; + __glXReadPixelReply(dpy, gc, 1, 0, 0, 0, format, type, values, + GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLsop_GetHistogramParameterfv 155 +void +__indirect_glGetHistogramParameterfv(GLenum target, GLenum pname, + GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_histogram_parameterfv_reply_t *reply = + xcb_glx_get_histogram_parameterfv_reply(c, + xcb_glx_get_histogram_parameterfv + (c, gc->currentContextTag, + target, pname), NULL); + if (xcb_glx_get_histogram_parameterfv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, + xcb_glx_get_histogram_parameterfv_data(reply), + xcb_glx_get_histogram_parameterfv_data_length(reply) + * sizeof(GLfloat)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetHistogramParameterfv, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GetHistogramParameterfvEXT 6 +void +gl_dispatch_stub_362(GLenum target, GLenum pname, GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetHistogramParameterfv(GET_DISPATCH(), (target, pname, params)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetHistogramParameterfvEXT, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLsop_GetHistogramParameteriv 156 +void +__indirect_glGetHistogramParameteriv(GLenum target, GLenum pname, + GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_histogram_parameteriv_reply_t *reply = + xcb_glx_get_histogram_parameteriv_reply(c, + xcb_glx_get_histogram_parameteriv + (c, gc->currentContextTag, + target, pname), NULL); + if (xcb_glx_get_histogram_parameteriv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, + xcb_glx_get_histogram_parameteriv_data(reply), + xcb_glx_get_histogram_parameteriv_data_length(reply) + * sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetHistogramParameteriv, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GetHistogramParameterivEXT 7 +void +gl_dispatch_stub_363(GLenum target, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetHistogramParameteriv(GET_DISPATCH(), (target, pname, params)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetHistogramParameterivEXT, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLsop_GetMinmax 157 +void +__indirect_glGetMinmax(GLenum target, GLboolean reset, GLenum format, + GLenum type, GLvoid * values) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const __GLXattribute *const state = gc->client_state_private; + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 16; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_minmax_reply_t *reply = + xcb_glx_get_minmax_reply(c, + xcb_glx_get_minmax(c, + gc->currentContextTag, + target, reset, format, + type, + state->storePack. + swapEndian), NULL); + (void) memcpy(values, xcb_glx_get_minmax_data(reply), + xcb_glx_get_minmax_data_length(reply) * sizeof(GLvoid)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetMinmax, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&format), 4); + (void) memcpy((void *) (pc + 8), (void *) (&type), 4); + *(int32_t *) (pc + 12) = 0; + *(int8_t *) (pc + 12) = state->storePack.swapEndian; + *(int8_t *) (pc + 13) = reset; + __glXReadPixelReply(dpy, gc, 1, 2, 1, 1, format, type, values, + GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GetMinmaxEXT 8 +void +gl_dispatch_stub_364(GLenum target, GLboolean reset, GLenum format, + GLenum type, GLvoid * values) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetMinmax(GET_DISPATCH(), (target, reset, format, type, values)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + const __GLXattribute *const state = gc->client_state_private; + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 16; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetMinmaxEXT, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&format), 4); + (void) memcpy((void *) (pc + 8), (void *) (&type), 4); + *(int32_t *) (pc + 12) = 0; + *(int8_t *) (pc + 12) = state->storePack.swapEndian; + *(int8_t *) (pc + 13) = reset; + __glXReadPixelReply(dpy, gc, 1, 2, 1, 1, format, type, values, + GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLsop_GetMinmaxParameterfv 158 +void +__indirect_glGetMinmaxParameterfv(GLenum target, GLenum pname, + GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_minmax_parameterfv_reply_t *reply = + xcb_glx_get_minmax_parameterfv_reply(c, + xcb_glx_get_minmax_parameterfv + (c, gc->currentContextTag, + target, pname), NULL); + if (xcb_glx_get_minmax_parameterfv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_minmax_parameterfv_data(reply), + xcb_glx_get_minmax_parameterfv_data_length(reply) * + sizeof(GLfloat)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetMinmaxParameterfv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GetMinmaxParameterfvEXT 9 +void +gl_dispatch_stub_365(GLenum target, GLenum pname, GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetMinmaxParameterfv(GET_DISPATCH(), (target, pname, params)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetMinmaxParameterfvEXT, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLsop_GetMinmaxParameteriv 159 +void +__indirect_glGetMinmaxParameteriv(GLenum target, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_minmax_parameteriv_reply_t *reply = + xcb_glx_get_minmax_parameteriv_reply(c, + xcb_glx_get_minmax_parameteriv + (c, gc->currentContextTag, + target, pname), NULL); + if (xcb_glx_get_minmax_parameteriv_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_minmax_parameteriv_data(reply), + xcb_glx_get_minmax_parameteriv_data_length(reply) * + sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetMinmaxParameteriv, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLvop_GetMinmaxParameterivEXT 10 +void +gl_dispatch_stub_366(GLenum target, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetMinmaxParameteriv(GET_DISPATCH(), (target, pname, params)); + } else +#endif + { + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetMinmaxParameterivEXT, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; + } +} + +#define X_GLrop_Histogram 4110 +void +__indirect_glHistogram(GLenum target, GLsizei width, GLenum internalformat, + GLboolean sink) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_Histogram, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&internalformat), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&sink), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_Minmax 4111 +void +__indirect_glMinmax(GLenum target, GLenum internalformat, GLboolean sink) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_Minmax, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&internalformat), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&sink), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ResetHistogram 4112 +void +__indirect_glResetHistogram(GLenum target) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_ResetHistogram, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ResetMinmax 4113 +void +__indirect_glResetMinmax(GLenum target) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_ResetMinmax, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +static void +__glx_TexImage_3D4D(unsigned opcode, unsigned dim, GLenum target, GLint level, + GLint internalformat, GLsizei width, GLsizei height, + GLsizei depth, GLsizei extent, GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = + (pixels != NULL) ? __glImageSize(width, height, depth, format, type, + target) : 0; + const GLuint cmdlen = 84 + __GLX_PAD(compsize); + if (__builtin_expect(gc->currentDpy != NULL, 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, opcode, cmdlen); + (void) memcpy((void *) (gc->pc + 40), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 44), (void *) (&level), 4); + (void) memcpy((void *) (gc->pc + 48), (void *) (&internalformat), + 4); + (void) memcpy((void *) (gc->pc + 52), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 56), (void *) (&height), 4); + (void) memcpy((void *) (gc->pc + 60), (void *) (&depth), 4); + (void) memcpy((void *) (gc->pc + 64), (void *) (&extent), 4); + (void) memcpy((void *) (gc->pc + 68), (void *) (&border), 4); + (void) memcpy((void *) (gc->pc + 72), (void *) (&format), 4); + (void) memcpy((void *) (gc->pc + 76), (void *) (&type), 4); + (void) memcpy((void *) (gc->pc + 80), + (void *) ((pixels == NULL) ? one : zero), 4); + if (compsize > 0) { + (*gc->fillImage) (gc, dim, width, height, depth, format, type, + pixels, gc->pc + 84, gc->pc + 4); + } else { + (void) memcpy(gc->pc + 4, default_pixel_store_4D, + default_pixel_store_4D_size); + } + gc->pc += cmdlen; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = opcode; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 44), (void *) (&target), 4); + (void) memcpy((void *) (pc + 48), (void *) (&level), 4); + (void) memcpy((void *) (pc + 52), (void *) (&internalformat), 4); + (void) memcpy((void *) (pc + 56), (void *) (&width), 4); + (void) memcpy((void *) (pc + 60), (void *) (&height), 4); + (void) memcpy((void *) (pc + 64), (void *) (&depth), 4); + (void) memcpy((void *) (pc + 68), (void *) (&extent), 4); + (void) memcpy((void *) (pc + 72), (void *) (&border), 4); + (void) memcpy((void *) (pc + 76), (void *) (&format), 4); + (void) memcpy((void *) (pc + 80), (void *) (&type), 4); + (void) memcpy((void *) (pc + 84), zero, 4); + __glXSendLargeImage(gc, compsize, dim, width, height, depth, + format, type, pixels, pc + 88, pc + 8); + } + } +} + +#define X_GLrop_TexImage3D 4114 +void +__indirect_glTexImage3D(GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid * pixels) +{ + __glx_TexImage_3D4D(X_GLrop_TexImage3D, 3, target, level, internalformat, + width, height, depth, 1, border, format, type, + pixels); +} + +static void +__glx_TexSubImage_3D4D(unsigned opcode, unsigned dim, GLenum target, + GLint level, GLint xoffset, GLint yoffset, + GLint zoffset, GLint woffset, GLsizei width, + GLsizei height, GLsizei depth, GLsizei extent, + GLenum format, GLenum type, const GLvoid * pixels) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = + (pixels != NULL) ? __glImageSize(width, height, depth, format, type, + target) : 0; + const GLuint cmdlen = 92 + __GLX_PAD(compsize); + if (__builtin_expect(gc->currentDpy != NULL, 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, opcode, cmdlen); + (void) memcpy((void *) (gc->pc + 40), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 44), (void *) (&level), 4); + (void) memcpy((void *) (gc->pc + 48), (void *) (&xoffset), 4); + (void) memcpy((void *) (gc->pc + 52), (void *) (&yoffset), 4); + (void) memcpy((void *) (gc->pc + 56), (void *) (&zoffset), 4); + (void) memcpy((void *) (gc->pc + 60), (void *) (&woffset), 4); + (void) memcpy((void *) (gc->pc + 64), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 68), (void *) (&height), 4); + (void) memcpy((void *) (gc->pc + 72), (void *) (&depth), 4); + (void) memcpy((void *) (gc->pc + 76), (void *) (&extent), 4); + (void) memcpy((void *) (gc->pc + 80), (void *) (&format), 4); + (void) memcpy((void *) (gc->pc + 84), (void *) (&type), 4); + (void) memset((void *) (gc->pc + 88), 0, 4); + if (compsize > 0) { + (*gc->fillImage) (gc, dim, width, height, depth, format, type, + pixels, gc->pc + 92, gc->pc + 4); + } else { + (void) memcpy(gc->pc + 4, default_pixel_store_4D, + default_pixel_store_4D_size); + } + gc->pc += cmdlen; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = opcode; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 44), (void *) (&target), 4); + (void) memcpy((void *) (pc + 48), (void *) (&level), 4); + (void) memcpy((void *) (pc + 52), (void *) (&xoffset), 4); + (void) memcpy((void *) (pc + 56), (void *) (&yoffset), 4); + (void) memcpy((void *) (pc + 60), (void *) (&zoffset), 4); + (void) memcpy((void *) (pc + 64), (void *) (&woffset), 4); + (void) memcpy((void *) (pc + 68), (void *) (&width), 4); + (void) memcpy((void *) (pc + 72), (void *) (&height), 4); + (void) memcpy((void *) (pc + 76), (void *) (&depth), 4); + (void) memcpy((void *) (pc + 80), (void *) (&extent), 4); + (void) memcpy((void *) (pc + 84), (void *) (&format), 4); + (void) memcpy((void *) (pc + 88), (void *) (&type), 4); + (void) memset((void *) (pc + 92), 0, 4); + __glXSendLargeImage(gc, compsize, dim, width, height, depth, + format, type, pixels, pc + 96, pc + 8); + } + } +} + +#define X_GLrop_TexSubImage3D 4115 +void +__indirect_glTexSubImage3D(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, GLenum format, + GLenum type, const GLvoid * pixels) +{ + __glx_TexSubImage_3D4D(X_GLrop_TexSubImage3D, 3, target, level, xoffset, + yoffset, zoffset, 1, width, height, depth, 1, + format, type, pixels); +} + +#define X_GLrop_CopyTexSubImage3D 4123 +void +__indirect_glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLint x, GLint y, + GLsizei width, GLsizei height) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 40; + emit_header(gc->pc, X_GLrop_CopyTexSubImage3D, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&level), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&xoffset), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&yoffset), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&zoffset), 4); + (void) memcpy((void *) (gc->pc + 24), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 32), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 36), (void *) (&height), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ActiveTextureARB 197 +void +__indirect_glActiveTextureARB(GLenum texture) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_ActiveTextureARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&texture), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord1dvARB 198 +void +__indirect_glMultiTexCoord1dARB(GLenum target, GLdouble s) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_MultiTexCoord1dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&target), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord1dvARB 198 +void +__indirect_glMultiTexCoord1dvARB(GLenum target, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_MultiTexCoord1dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (v), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&target), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord1fvARB 199 +void +__indirect_glMultiTexCoord1fARB(GLenum target, GLfloat s) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_MultiTexCoord1fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord1fvARB 199 +void +__indirect_glMultiTexCoord1fvARB(GLenum target, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_MultiTexCoord1fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord1ivARB 200 +void +__indirect_glMultiTexCoord1iARB(GLenum target, GLint s) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_MultiTexCoord1ivARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord1ivARB 200 +void +__indirect_glMultiTexCoord1ivARB(GLenum target, const GLint * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_MultiTexCoord1ivARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord1svARB 201 +void +__indirect_glMultiTexCoord1sARB(GLenum target, GLshort s) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_MultiTexCoord1svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord1svARB 201 +void +__indirect_glMultiTexCoord1svARB(GLenum target, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_MultiTexCoord1svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord2dvARB 202 +void +__indirect_glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_MultiTexCoord2dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&target), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord2dvARB 202 +void +__indirect_glMultiTexCoord2dvARB(GLenum target, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_MultiTexCoord2dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (v), 16); + (void) memcpy((void *) (gc->pc + 20), (void *) (&target), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord2fvARB 203 +void +__indirect_glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_MultiTexCoord2fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord2fvARB 203 +void +__indirect_glMultiTexCoord2fvARB(GLenum target, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_MultiTexCoord2fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord2ivARB 204 +void +__indirect_glMultiTexCoord2iARB(GLenum target, GLint s, GLint t) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_MultiTexCoord2ivARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord2ivARB 204 +void +__indirect_glMultiTexCoord2ivARB(GLenum target, const GLint * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_MultiTexCoord2ivARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord2svARB 205 +void +__indirect_glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_MultiTexCoord2svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&t), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord2svARB 205 +void +__indirect_glMultiTexCoord2svARB(GLenum target, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_MultiTexCoord2svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord3dvARB 206 +void +__indirect_glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, + GLdouble r) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 32; + emit_header(gc->pc, X_GLrop_MultiTexCoord3dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&r), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&target), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord3dvARB 206 +void +__indirect_glMultiTexCoord3dvARB(GLenum target, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 32; + emit_header(gc->pc, X_GLrop_MultiTexCoord3dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (v), 24); + (void) memcpy((void *) (gc->pc + 28), (void *) (&target), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord3fvARB 207 +void +__indirect_glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, + GLfloat r) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_MultiTexCoord3fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&r), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord3fvARB 207 +void +__indirect_glMultiTexCoord3fvARB(GLenum target, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_MultiTexCoord3fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 12); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord3ivARB 208 +void +__indirect_glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_MultiTexCoord3ivARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&r), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord3ivARB 208 +void +__indirect_glMultiTexCoord3ivARB(GLenum target, const GLint * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_MultiTexCoord3ivARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 12); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord3svARB 209 +void +__indirect_glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, + GLshort r) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_MultiTexCoord3svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&t), 2); + (void) memcpy((void *) (gc->pc + 12), (void *) (&r), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord3svARB 209 +void +__indirect_glMultiTexCoord3svARB(GLenum target, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_MultiTexCoord3svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 6); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord4dvARB 210 +void +__indirect_glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, + GLdouble r, GLdouble q) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 40; + emit_header(gc->pc, X_GLrop_MultiTexCoord4dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&r), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&q), 8); + (void) memcpy((void *) (gc->pc + 36), (void *) (&target), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord4dvARB 210 +void +__indirect_glMultiTexCoord4dvARB(GLenum target, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 40; + emit_header(gc->pc, X_GLrop_MultiTexCoord4dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (v), 32); + (void) memcpy((void *) (gc->pc + 36), (void *) (&target), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord4fvARB 211 +void +__indirect_glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, + GLfloat r, GLfloat q) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_MultiTexCoord4fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&r), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&q), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord4fvARB 211 +void +__indirect_glMultiTexCoord4fvARB(GLenum target, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_MultiTexCoord4fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord4ivARB 212 +void +__indirect_glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, + GLint q) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_MultiTexCoord4ivARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&r), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&q), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord4ivARB 212 +void +__indirect_glMultiTexCoord4ivARB(GLenum target, const GLint * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_MultiTexCoord4ivARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord4svARB 213 +void +__indirect_glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, + GLshort r, GLshort q) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_MultiTexCoord4svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&t), 2); + (void) memcpy((void *) (gc->pc + 12), (void *) (&r), 2); + (void) memcpy((void *) (gc->pc + 14), (void *) (&q), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_MultiTexCoord4svARB 213 +void +__indirect_glMultiTexCoord4svARB(GLenum target, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_MultiTexCoord4svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_SampleCoverageARB 229 +void +__indirect_glSampleCoverageARB(GLclampf value, GLboolean invert) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_SampleCoverageARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&value), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&invert), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLvop_GetProgramStringARB 1308 +void +__indirect_glGetProgramStringARB(GLenum target, GLenum pname, GLvoid * string) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetProgramStringARB, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 1, string, GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_GetProgramivARB 1307 +void +__indirect_glGetProgramivARB(GLenum target, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetProgramivARB, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLrop_ProgramEnvParameter4dvARB 4185 +void +__indirect_glProgramEnvParameter4dARB(GLenum target, GLuint index, GLdouble x, + GLdouble y, GLdouble z, GLdouble w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 44; + emit_header(gc->pc, X_GLrop_ProgramEnvParameter4dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&z), 8); + (void) memcpy((void *) (gc->pc + 36), (void *) (&w), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ProgramEnvParameter4dvARB 4185 +void +__indirect_glProgramEnvParameter4dvARB(GLenum target, GLuint index, + const GLdouble * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 44; + emit_header(gc->pc, X_GLrop_ProgramEnvParameter4dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), 32); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ProgramEnvParameter4fvARB 4184 +void +__indirect_glProgramEnvParameter4fARB(GLenum target, GLuint index, GLfloat x, + GLfloat y, GLfloat z, GLfloat w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_ProgramEnvParameter4fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 4); + (void) memcpy((void *) (gc->pc + 24), (void *) (&w), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ProgramEnvParameter4fvARB 4184 +void +__indirect_glProgramEnvParameter4fvARB(GLenum target, GLuint index, + const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_ProgramEnvParameter4fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ProgramLocalParameter4dvARB 4216 +void +__indirect_glProgramLocalParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, GLdouble z, + GLdouble w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 44; + emit_header(gc->pc, X_GLrop_ProgramLocalParameter4dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&z), 8); + (void) memcpy((void *) (gc->pc + 36), (void *) (&w), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ProgramLocalParameter4dvARB 4216 +void +__indirect_glProgramLocalParameter4dvARB(GLenum target, GLuint index, + const GLdouble * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 44; + emit_header(gc->pc, X_GLrop_ProgramLocalParameter4dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), 32); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ProgramLocalParameter4fvARB 4215 +void +__indirect_glProgramLocalParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, + GLfloat w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_ProgramLocalParameter4fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 4); + (void) memcpy((void *) (gc->pc + 24), (void *) (&w), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ProgramLocalParameter4fvARB 4215 +void +__indirect_glProgramLocalParameter4fvARB(GLenum target, GLuint index, + const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_ProgramLocalParameter4fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ProgramStringARB 4217 +void +__indirect_glProgramStringARB(GLenum target, GLenum format, GLsizei len, + const GLvoid * string) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16 + __GLX_PAD(len); + if (len < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((len >= 0) && (gc->currentDpy != NULL), 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, X_GLrop_ProgramStringARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&format), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&len), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (string), len); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = X_GLrop_ProgramStringARB; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 8), (void *) (&target), 4); + (void) memcpy((void *) (pc + 12), (void *) (&format), 4); + (void) memcpy((void *) (pc + 16), (void *) (&len), 4); + __glXSendLargeCommand(gc, pc, 20, string, len); + } + } +} + +#define X_GLrop_VertexAttrib1dvARB 4197 +void +__indirect_glVertexAttrib1dARB(GLuint index, GLdouble x) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib1dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib1dvARB 4197 +void +__indirect_glVertexAttrib1dvARB(GLuint index, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib1dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib1fvARB 4193 +void +__indirect_glVertexAttrib1fARB(GLuint index, GLfloat x) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib1fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib1fvARB 4193 +void +__indirect_glVertexAttrib1fvARB(GLuint index, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib1fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib1svARB 4189 +void +__indirect_glVertexAttrib1sARB(GLuint index, GLshort x) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib1svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib1svARB 4189 +void +__indirect_glVertexAttrib1svARB(GLuint index, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib1svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib2dvARB 4198 +void +__indirect_glVertexAttrib2dARB(GLuint index, GLdouble x, GLdouble y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_VertexAttrib2dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib2dvARB 4198 +void +__indirect_glVertexAttrib2dvARB(GLuint index, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_VertexAttrib2dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib2fvARB 4194 +void +__indirect_glVertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib2fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib2fvARB 4194 +void +__indirect_glVertexAttrib2fvARB(GLuint index, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib2fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib2svARB 4190 +void +__indirect_glVertexAttrib2sARB(GLuint index, GLshort x, GLshort y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib2svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&y), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib2svARB 4190 +void +__indirect_glVertexAttrib2svARB(GLuint index, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib2svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib3dvARB 4199 +void +__indirect_glVertexAttrib3dARB(GLuint index, GLdouble x, GLdouble y, + GLdouble z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 32; + emit_header(gc->pc, X_GLrop_VertexAttrib3dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 24), (void *) (&z), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib3dvARB 4199 +void +__indirect_glVertexAttrib3dvARB(GLuint index, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 32; + emit_header(gc->pc, X_GLrop_VertexAttrib3dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 24); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib3fvARB 4195 +void +__indirect_glVertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_VertexAttrib3fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&z), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib3fvARB 4195 +void +__indirect_glVertexAttrib3fvARB(GLuint index, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_VertexAttrib3fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 12); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib3svARB 4191 +void +__indirect_glVertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib3svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&y), 2); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib3svARB 4191 +void +__indirect_glVertexAttrib3svARB(GLuint index, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib3svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 6); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4NbvARB 4235 +void +__indirect_glVertexAttrib4NbvARB(GLuint index, const GLbyte *v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib4NbvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4NivARB 4237 +void +__indirect_glVertexAttrib4NivARB(GLuint index, const GLint * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_VertexAttrib4NivARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4NsvARB 4236 +void +__indirect_glVertexAttrib4NsvARB(GLuint index, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib4NsvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4NubvARB 4201 +void +__indirect_glVertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, + GLubyte z, GLubyte w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib4NubvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 1); + (void) memcpy((void *) (gc->pc + 9), (void *) (&y), 1); + (void) memcpy((void *) (gc->pc + 10), (void *) (&z), 1); + (void) memcpy((void *) (gc->pc + 11), (void *) (&w), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4NubvARB 4201 +void +__indirect_glVertexAttrib4NubvARB(GLuint index, const GLubyte *v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib4NubvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4NuivARB 4239 +void +__indirect_glVertexAttrib4NuivARB(GLuint index, const GLuint * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_VertexAttrib4NuivARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4NusvARB 4238 +void +__indirect_glVertexAttrib4NusvARB(GLuint index, const GLushort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib4NusvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4bvARB 4230 +void +__indirect_glVertexAttrib4bvARB(GLuint index, const GLbyte *v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib4bvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4dvARB 4200 +void +__indirect_glVertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, + GLdouble z, GLdouble w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 40; + emit_header(gc->pc, X_GLrop_VertexAttrib4dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 24), (void *) (&z), 8); + (void) memcpy((void *) (gc->pc + 32), (void *) (&w), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4dvARB 4200 +void +__indirect_glVertexAttrib4dvARB(GLuint index, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 40; + emit_header(gc->pc, X_GLrop_VertexAttrib4dvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 32); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4fvARB 4196 +void +__indirect_glVertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, + GLfloat w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_VertexAttrib4fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&z), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&w), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4fvARB 4196 +void +__indirect_glVertexAttrib4fvARB(GLuint index, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_VertexAttrib4fvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4ivARB 4231 +void +__indirect_glVertexAttrib4ivARB(GLuint index, const GLint * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_VertexAttrib4ivARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4svARB 4192 +void +__indirect_glVertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, + GLshort w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib4svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&y), 2); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 2); + (void) memcpy((void *) (gc->pc + 14), (void *) (&w), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4svARB 4192 +void +__indirect_glVertexAttrib4svARB(GLuint index, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib4svARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4ubvARB 4232 +void +__indirect_glVertexAttrib4ubvARB(GLuint index, const GLubyte *v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib4ubvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4uivARB 4234 +void +__indirect_glVertexAttrib4uivARB(GLuint index, const GLuint * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_VertexAttrib4uivARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4usvARB 4233 +void +__indirect_glVertexAttrib4usvARB(GLuint index, const GLushort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib4usvARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_BeginQueryARB 231 +void +__indirect_glBeginQueryARB(GLenum target, GLuint id) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_BeginQueryARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&id), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLsop_DeleteQueriesARB 161 +void +__indirect_glDeleteQueriesARB(GLsizei n, const GLuint * ids) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); +#endif + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_delete_queries_arb(c, gc->currentContextTag, n, ids); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_DeleteQueriesARB, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) memcpy((void *) (pc + 4), (void *) (ids), (n * 4)); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLrop_EndQueryARB 232 +void +__indirect_glEndQueryARB(GLenum target) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_EndQueryARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLsop_GenQueriesARB 162 +void +__indirect_glGenQueriesARB(GLsizei n, GLuint * ids) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 4; +#endif + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_gen_queries_arb_reply_t *reply = + xcb_glx_gen_queries_arb_reply(c, + xcb_glx_gen_queries_arb(c, + gc-> + currentContextTag, + n), NULL); + (void) memcpy(ids, xcb_glx_gen_queries_arb_data(reply), + xcb_glx_gen_queries_arb_data_length(reply) * + sizeof(GLuint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GenQueriesARB, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) __glXReadReply(dpy, 4, ids, GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetQueryObjectivARB 165 +void +__indirect_glGetQueryObjectivARB(GLuint id, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_query_objectiv_arb_reply_t *reply = + xcb_glx_get_query_objectiv_arb_reply(c, + xcb_glx_get_query_objectiv_arb + (c, gc->currentContextTag, + id, pname), NULL); + if (xcb_glx_get_query_objectiv_arb_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_query_objectiv_arb_data(reply), + xcb_glx_get_query_objectiv_arb_data_length(reply) * + sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetQueryObjectivARB, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&id), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetQueryObjectuivARB 166 +void +__indirect_glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_query_objectuiv_arb_reply_t *reply = + xcb_glx_get_query_objectuiv_arb_reply(c, + xcb_glx_get_query_objectuiv_arb + (c, gc->currentContextTag, + id, pname), NULL); + if (xcb_glx_get_query_objectuiv_arb_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_query_objectuiv_arb_data(reply), + xcb_glx_get_query_objectuiv_arb_data_length(reply) * + sizeof(GLuint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetQueryObjectuivARB, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&id), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_GetQueryivARB 164 +void +__indirect_glGetQueryivARB(GLenum target, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; +#ifndef USE_XCB + const GLuint cmdlen = 8; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_get_queryiv_arb_reply_t *reply = + xcb_glx_get_queryiv_arb_reply(c, + xcb_glx_get_queryiv_arb(c, + gc-> + currentContextTag, + target, + pname), + NULL); + if (xcb_glx_get_queryiv_arb_data_length(reply) == 0) + (void) memcpy(params, &reply->datum, sizeof(reply->datum)); + else + (void) memcpy(params, xcb_glx_get_queryiv_arb_data(reply), + xcb_glx_get_queryiv_arb_data_length(reply) * + sizeof(GLint)); + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_GetQueryivARB, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return; +} + +#define X_GLsop_IsQueryARB 163 +GLboolean +__indirect_glIsQueryARB(GLuint id) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + GLboolean retval = (GLboolean) 0; +#ifndef USE_XCB + const GLuint cmdlen = 4; +#endif + if (__builtin_expect(dpy != NULL, 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_is_query_arb_reply_t *reply = + xcb_glx_is_query_arb_reply(c, + xcb_glx_is_query_arb(c, + gc-> + currentContextTag, + id), NULL); + retval = reply->ret_val; + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_IsQueryARB, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&id), 4); + retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return retval; +} + +#define X_GLrop_DrawBuffersARB 233 +void +__indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8 + __GLX_PAD((n * 4)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((n >= 0) && (gc->currentDpy != NULL), 1)) { + if (cmdlen <= gc->maxSmallRenderCommandSize) { + if ((gc->pc + cmdlen) > gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + emit_header(gc->pc, X_GLrop_DrawBuffersARB, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (bufs), (n * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } else { + const GLint op = X_GLrop_DrawBuffersARB; + const GLuint cmdlenLarge = cmdlen + 4; + GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); + (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); + (void) memcpy((void *) (pc + 4), (void *) (&op), 4); + (void) memcpy((void *) (pc + 8), (void *) (&n), 4); + __glXSendLargeCommand(gc, pc, 12, bufs, (n * 4)); + } + } +} + +#define X_GLrop_RenderbufferStorageMultisample 4331 +void +__indirect_glRenderbufferStorageMultisample(GLenum target, GLsizei samples, + GLenum internalformat, + GLsizei width, GLsizei height) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_RenderbufferStorageMultisample, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&samples), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&internalformat), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&height), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_SampleMaskSGIS 2048 +void +__indirect_glSampleMaskSGIS(GLclampf value, GLboolean invert) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_SampleMaskSGIS, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&value), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&invert), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_SamplePatternSGIS 2049 +void +__indirect_glSamplePatternSGIS(GLenum pattern) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_SamplePatternSGIS, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pattern), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PointParameterfEXT 2065 +void +__indirect_glPointParameterfEXT(GLenum pname, GLfloat param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_PointParameterfEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PointParameterfvEXT 2066 +void +__indirect_glPointParameterfvEXT(GLenum pname, const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glPointParameterfvEXT_size(pname); + const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_PointParameterfvEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_SecondaryColor3bvEXT 4126 +void +__indirect_glSecondaryColor3bEXT(GLbyte red, GLbyte green, GLbyte blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_SecondaryColor3bvEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); + (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); + (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_SecondaryColor3bvEXT 4126 +void +__indirect_glSecondaryColor3bvEXT(const GLbyte *v) +{ + generic_3_byte(X_GLrop_SecondaryColor3bvEXT, v); +} + +#define X_GLrop_SecondaryColor3dvEXT 4130 +void +__indirect_glSecondaryColor3dEXT(GLdouble red, GLdouble green, GLdouble blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_SecondaryColor3dvEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&green), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&blue), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_SecondaryColor3dvEXT 4130 +void +__indirect_glSecondaryColor3dvEXT(const GLdouble * v) +{ + generic_24_byte(X_GLrop_SecondaryColor3dvEXT, v); +} + +#define X_GLrop_SecondaryColor3fvEXT 4129 +void +__indirect_glSecondaryColor3fEXT(GLfloat red, GLfloat green, GLfloat blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_SecondaryColor3fvEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_SecondaryColor3fvEXT 4129 +void +__indirect_glSecondaryColor3fvEXT(const GLfloat * v) +{ + generic_12_byte(X_GLrop_SecondaryColor3fvEXT, v); +} + +#define X_GLrop_SecondaryColor3ivEXT 4128 +void +__indirect_glSecondaryColor3iEXT(GLint red, GLint green, GLint blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_SecondaryColor3ivEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_SecondaryColor3ivEXT 4128 +void +__indirect_glSecondaryColor3ivEXT(const GLint * v) +{ + generic_12_byte(X_GLrop_SecondaryColor3ivEXT, v); +} + +#define X_GLrop_SecondaryColor3svEXT 4127 +void +__indirect_glSecondaryColor3sEXT(GLshort red, GLshort green, GLshort blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_SecondaryColor3svEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&green), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&blue), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_SecondaryColor3svEXT 4127 +void +__indirect_glSecondaryColor3svEXT(const GLshort * v) +{ + generic_6_byte(X_GLrop_SecondaryColor3svEXT, v); +} + +#define X_GLrop_SecondaryColor3ubvEXT 4131 +void +__indirect_glSecondaryColor3ubEXT(GLubyte red, GLubyte green, GLubyte blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_SecondaryColor3ubvEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); + (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); + (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_SecondaryColor3ubvEXT 4131 +void +__indirect_glSecondaryColor3ubvEXT(const GLubyte *v) +{ + generic_3_byte(X_GLrop_SecondaryColor3ubvEXT, v); +} + +#define X_GLrop_SecondaryColor3uivEXT 4133 +void +__indirect_glSecondaryColor3uiEXT(GLuint red, GLuint green, GLuint blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_SecondaryColor3uivEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_SecondaryColor3uivEXT 4133 +void +__indirect_glSecondaryColor3uivEXT(const GLuint * v) +{ + generic_12_byte(X_GLrop_SecondaryColor3uivEXT, v); +} + +#define X_GLrop_SecondaryColor3usvEXT 4132 +void +__indirect_glSecondaryColor3usEXT(GLushort red, GLushort green, GLushort blue) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_SecondaryColor3usvEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 2); + (void) memcpy((void *) (gc->pc + 6), (void *) (&green), 2); + (void) memcpy((void *) (gc->pc + 8), (void *) (&blue), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_SecondaryColor3usvEXT 4132 +void +__indirect_glSecondaryColor3usvEXT(const GLushort * v) +{ + generic_6_byte(X_GLrop_SecondaryColor3usvEXT, v); +} + +#define X_GLrop_FogCoorddvEXT 4125 +void +__indirect_glFogCoorddEXT(GLdouble coord) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_FogCoorddvEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_FogCoorddvEXT 4125 +void +__indirect_glFogCoorddvEXT(const GLdouble * coord) +{ + generic_8_byte(X_GLrop_FogCoorddvEXT, coord); +} + +#define X_GLrop_FogCoordfvEXT 4124 +void +__indirect_glFogCoordfEXT(GLfloat coord) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_FogCoordfvEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_FogCoordfvEXT 4124 +void +__indirect_glFogCoordfvEXT(const GLfloat * coord) +{ + generic_4_byte(X_GLrop_FogCoordfvEXT, coord); +} + +#define X_GLrop_BlendFuncSeparateEXT 4134 +void +__indirect_glBlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorAlpha, GLenum dfactorAlpha) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_BlendFuncSeparateEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&sfactorRGB), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&dfactorRGB), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&sfactorAlpha), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&dfactorAlpha), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_WindowPos3fvMESA 230 +void +__indirect_glWindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_WindowPos3fvMESA, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_WindowPos3fvMESA 230 +void +__indirect_glWindowPos3fvMESA(const GLfloat * v) +{ + generic_12_byte(X_GLrop_WindowPos3fvMESA, v); +} + +#define X_GLvop_AreProgramsResidentNV 1293 +GLboolean +__indirect_glAreProgramsResidentNV(GLsizei n, const GLuint * ids, + GLboolean * residences) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + GLboolean retval = (GLboolean) 0; + const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return 0; + } + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_AreProgramsResidentNV, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) memcpy((void *) (pc + 4), (void *) (ids), (n * 4)); + retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return retval; +} + +#define X_GLrop_BindProgramNV 4180 +void +__indirect_glBindProgramNV(GLenum target, GLuint program) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_BindProgramNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&program), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLvop_DeleteProgramsNV 1294 +void +__indirect_glDeleteProgramsNV(GLsizei n, const GLuint * programs) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivate, + X_GLvop_DeleteProgramsNV, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) memcpy((void *) (pc + 4), (void *) (programs), (n * 4)); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLrop_ExecuteProgramNV 4181 +void +__indirect_glExecuteProgramNV(GLenum target, GLuint id, + const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_ExecuteProgramNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&id), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (params), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLvop_GenProgramsNV 1295 +void +__indirect_glGenProgramsNV(GLsizei n, GLuint * programs) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 4; + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GenProgramsNV, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) __glXReadReply(dpy, 4, programs, GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_GetProgramParameterdvNV 1297 +void +__indirect_glGetProgramParameterdvNV(GLenum target, GLuint index, + GLenum pname, GLdouble * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 12; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetProgramParameterdvNV, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (pc + 8), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 8, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_GetProgramParameterfvNV 1296 +void +__indirect_glGetProgramParameterfvNV(GLenum target, GLuint index, + GLenum pname, GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 12; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetProgramParameterfvNV, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (pc + 8), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_GetProgramStringNV 1299 +void +__indirect_glGetProgramStringNV(GLuint id, GLenum pname, GLubyte *program) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetProgramStringNV, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&id), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 1, program, GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_GetProgramivNV 1298 +void +__indirect_glGetProgramivNV(GLuint id, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetProgramivNV, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&id), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_GetTrackMatrixivNV 1300 +void +__indirect_glGetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, + GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 12; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetTrackMatrixivNV, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&address), 4); + (void) memcpy((void *) (pc + 8), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_GetVertexAttribdvNV 1301 +void +__indirect_glGetVertexAttribdvNV(GLuint index, GLenum pname, + GLdouble * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetVertexAttribdvNV, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&index), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 8, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_GetVertexAttribfvNV 1302 +void +__indirect_glGetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetVertexAttribfvNV, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&index), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_GetVertexAttribivNV 1303 +void +__indirect_glGetVertexAttribivNV(GLuint index, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetVertexAttribivNV, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&index), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_IsProgramNV 1304 +GLboolean +__indirect_glIsProgramNV(GLuint program) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + GLboolean retval = (GLboolean) 0; + const GLuint cmdlen = 4; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_IsProgramNV, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&program), 4); + retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return retval; +} + +#define X_GLrop_LoadProgramNV 4183 +void +__indirect_glLoadProgramNV(GLenum target, GLuint id, GLsizei len, + const GLubyte *program) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16 + __GLX_PAD(len); + if (len < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(len >= 0, 1)) { + emit_header(gc->pc, X_GLrop_LoadProgramNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&id), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&len), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (program), len); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_ProgramParameters4dvNV 4187 +void +__indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, + const GLdouble * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16 + __GLX_PAD((num * 32)); + if (num < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(num >= 0, 1)) { + emit_header(gc->pc, X_GLrop_ProgramParameters4dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&num), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (params), (num * 32)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_ProgramParameters4fvNV 4186 +void +__indirect_glProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, + const GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16 + __GLX_PAD((num * 16)); + if (num < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(num >= 0, 1)) { + emit_header(gc->pc, X_GLrop_ProgramParameters4fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&num), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (params), (num * 16)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_RequestResidentProgramsNV 4182 +void +__indirect_glRequestResidentProgramsNV(GLsizei n, const GLuint * ids) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8 + __GLX_PAD((n * 4)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_RequestResidentProgramsNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (ids), (n * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_TrackMatrixNV 4188 +void +__indirect_glTrackMatrixNV(GLenum target, GLuint address, GLenum matrix, + GLenum transform) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_TrackMatrixNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&address), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&matrix), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&transform), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib1dvNV 4273 +void +__indirect_glVertexAttrib1dNV(GLuint index, GLdouble x) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib1dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib1dvNV 4273 +void +__indirect_glVertexAttrib1dvNV(GLuint index, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib1dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib1fvNV 4269 +void +__indirect_glVertexAttrib1fNV(GLuint index, GLfloat x) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib1fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib1fvNV 4269 +void +__indirect_glVertexAttrib1fvNV(GLuint index, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib1fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib1svNV 4265 +void +__indirect_glVertexAttrib1sNV(GLuint index, GLshort x) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib1svNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib1svNV 4265 +void +__indirect_glVertexAttrib1svNV(GLuint index, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib1svNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib2dvNV 4274 +void +__indirect_glVertexAttrib2dNV(GLuint index, GLdouble x, GLdouble y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_VertexAttrib2dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib2dvNV 4274 +void +__indirect_glVertexAttrib2dvNV(GLuint index, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_VertexAttrib2dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib2fvNV 4270 +void +__indirect_glVertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib2fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib2fvNV 4270 +void +__indirect_glVertexAttrib2fvNV(GLuint index, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib2fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib2svNV 4266 +void +__indirect_glVertexAttrib2sNV(GLuint index, GLshort x, GLshort y) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib2svNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&y), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib2svNV 4266 +void +__indirect_glVertexAttrib2svNV(GLuint index, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib2svNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib3dvNV 4275 +void +__indirect_glVertexAttrib3dNV(GLuint index, GLdouble x, GLdouble y, + GLdouble z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 32; + emit_header(gc->pc, X_GLrop_VertexAttrib3dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 24), (void *) (&z), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib3dvNV 4275 +void +__indirect_glVertexAttrib3dvNV(GLuint index, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 32; + emit_header(gc->pc, X_GLrop_VertexAttrib3dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 24); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib3fvNV 4271 +void +__indirect_glVertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_VertexAttrib3fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&z), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib3fvNV 4271 +void +__indirect_glVertexAttrib3fvNV(GLuint index, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_VertexAttrib3fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 12); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib3svNV 4267 +void +__indirect_glVertexAttrib3sNV(GLuint index, GLshort x, GLshort y, GLshort z) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib3svNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&y), 2); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib3svNV 4267 +void +__indirect_glVertexAttrib3svNV(GLuint index, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib3svNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 6); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4dvNV 4276 +void +__indirect_glVertexAttrib4dNV(GLuint index, GLdouble x, GLdouble y, + GLdouble z, GLdouble w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 40; + emit_header(gc->pc, X_GLrop_VertexAttrib4dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 24), (void *) (&z), 8); + (void) memcpy((void *) (gc->pc + 32), (void *) (&w), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4dvNV 4276 +void +__indirect_glVertexAttrib4dvNV(GLuint index, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 40; + emit_header(gc->pc, X_GLrop_VertexAttrib4dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 32); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4fvNV 4272 +void +__indirect_glVertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z, + GLfloat w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_VertexAttrib4fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&z), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&w), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4fvNV 4272 +void +__indirect_glVertexAttrib4fvNV(GLuint index, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_VertexAttrib4fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4svNV 4268 +void +__indirect_glVertexAttrib4sNV(GLuint index, GLshort x, GLshort y, GLshort z, + GLshort w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib4svNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); + (void) memcpy((void *) (gc->pc + 10), (void *) (&y), 2); + (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 2); + (void) memcpy((void *) (gc->pc + 14), (void *) (&w), 2); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4svNV 4268 +void +__indirect_glVertexAttrib4svNV(GLuint index, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 16; + emit_header(gc->pc, X_GLrop_VertexAttrib4svNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4ubvNV 4277 +void +__indirect_glVertexAttrib4ubNV(GLuint index, GLubyte x, GLubyte y, GLubyte z, + GLubyte w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib4ubvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 1); + (void) memcpy((void *) (gc->pc + 9), (void *) (&y), 1); + (void) memcpy((void *) (gc->pc + 10), (void *) (&z), 1); + (void) memcpy((void *) (gc->pc + 11), (void *) (&w), 1); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttrib4ubvNV 4277 +void +__indirect_glVertexAttrib4ubvNV(GLuint index, const GLubyte *v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_VertexAttrib4ubvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_VertexAttribs1dvNV 4210 +void +__indirect_glVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 8)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs1dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 8)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_VertexAttribs1fvNV 4206 +void +__indirect_glVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 4)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs1fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_VertexAttribs1svNV 4202 +void +__indirect_glVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 2)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs1svNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 2)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_VertexAttribs2dvNV 4211 +void +__indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 16)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs2dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 16)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_VertexAttribs2fvNV 4207 +void +__indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 8)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs2fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 8)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_VertexAttribs2svNV 4203 +void +__indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 4)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs2svNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_VertexAttribs3dvNV 4212 +void +__indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 24)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs3dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 24)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_VertexAttribs3fvNV 4208 +void +__indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 12)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs3fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 12)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_VertexAttribs3svNV 4204 +void +__indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 6)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs3svNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 6)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_VertexAttribs4dvNV 4213 +void +__indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 32)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs4dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 32)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_VertexAttribs4fvNV 4209 +void +__indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 16)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs4fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 16)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_VertexAttribs4svNV 4205 +void +__indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 8)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs4svNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 8)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_VertexAttribs4ubvNV 4214 +void +__indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte *v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12 + __GLX_PAD((n * 4)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_VertexAttribs4ubvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_PointParameteriNV 4221 +void +__indirect_glPointParameteriNV(GLenum pname, GLint param) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_PointParameteriNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_PointParameterivNV 4222 +void +__indirect_glPointParameterivNV(GLenum pname, const GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint compsize = __glPointParameterivNV_size(pname); + const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4)); + emit_header(gc->pc, X_GLrop_PointParameterivNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_ActiveStencilFaceEXT 4220 +void +__indirect_glActiveStencilFaceEXT(GLenum face) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_ActiveStencilFaceEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLvop_GetProgramNamedParameterdvNV 1311 +void +__indirect_glGetProgramNamedParameterdvNV(GLuint id, GLsizei len, + const GLubyte *name, + GLdouble * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8 + __GLX_PAD(len); + if (len < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((len >= 0) && (dpy != NULL), 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetProgramNamedParameterdvNV, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&id), 4); + (void) memcpy((void *) (pc + 4), (void *) (&len), 4); + (void) memcpy((void *) (pc + 8), (void *) (name), len); + (void) __glXReadReply(dpy, 8, params, GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_GetProgramNamedParameterfvNV 1310 +void +__indirect_glGetProgramNamedParameterfvNV(GLuint id, GLsizei len, + const GLubyte *name, + GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8 + __GLX_PAD(len); + if (len < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((len >= 0) && (dpy != NULL), 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetProgramNamedParameterfvNV, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&id), 4); + (void) memcpy((void *) (pc + 4), (void *) (&len), 4); + (void) memcpy((void *) (pc + 8), (void *) (name), len); + (void) __glXReadReply(dpy, 4, params, GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLrop_ProgramNamedParameter4dvNV 4219 +void +__indirect_glProgramNamedParameter4dNV(GLuint id, GLsizei len, + const GLubyte *name, GLdouble x, + GLdouble y, GLdouble z, GLdouble w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 44 + __GLX_PAD(len); + if (len < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(len >= 0, 1)) { + emit_header(gc->pc, X_GLrop_ProgramNamedParameter4dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); + (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); + (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); + (void) memcpy((void *) (gc->pc + 28), (void *) (&w), 8); + (void) memcpy((void *) (gc->pc + 36), (void *) (&id), 4); + (void) memcpy((void *) (gc->pc + 40), (void *) (&len), 4); + (void) memcpy((void *) (gc->pc + 44), (void *) (name), len); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_ProgramNamedParameter4dvNV 4219 +void +__indirect_glProgramNamedParameter4dvNV(GLuint id, GLsizei len, + const GLubyte *name, + const GLdouble * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 44 + __GLX_PAD(len); + if (len < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(len >= 0, 1)) { + emit_header(gc->pc, X_GLrop_ProgramNamedParameter4dvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (v), 32); + (void) memcpy((void *) (gc->pc + 36), (void *) (&id), 4); + (void) memcpy((void *) (gc->pc + 40), (void *) (&len), 4); + (void) memcpy((void *) (gc->pc + 44), (void *) (name), len); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_ProgramNamedParameter4fvNV 4218 +void +__indirect_glProgramNamedParameter4fNV(GLuint id, GLsizei len, + const GLubyte *name, GLfloat x, + GLfloat y, GLfloat z, GLfloat w) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28 + __GLX_PAD(len); + if (len < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(len >= 0, 1)) { + emit_header(gc->pc, X_GLrop_ProgramNamedParameter4fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&id), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&len), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 4); + (void) memcpy((void *) (gc->pc + 24), (void *) (&w), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (name), len); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_ProgramNamedParameter4fvNV 4218 +void +__indirect_glProgramNamedParameter4fvNV(GLuint id, GLsizei len, + const GLubyte *name, + const GLfloat * v) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28 + __GLX_PAD(len); + if (len < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(len >= 0, 1)) { + emit_header(gc->pc, X_GLrop_ProgramNamedParameter4fvNV, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&id), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&len), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (v), 16); + (void) memcpy((void *) (gc->pc + 28), (void *) (name), len); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_BlendEquationSeparateEXT 4228 +void +__indirect_glBlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_BlendEquationSeparateEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&modeRGB), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&modeA), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_BindFramebufferEXT 4319 +void +__indirect_glBindFramebufferEXT(GLenum target, GLuint framebuffer) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_BindFramebufferEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&framebuffer), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_BindRenderbufferEXT 4316 +void +__indirect_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 12; + emit_header(gc->pc, X_GLrop_BindRenderbufferEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&renderbuffer), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLvop_CheckFramebufferStatusEXT 1427 +GLenum +__indirect_glCheckFramebufferStatusEXT(GLenum target) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + GLenum retval = (GLenum) 0; + const GLuint cmdlen = 4; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_CheckFramebufferStatusEXT, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + retval = (GLenum) __glXReadReply(dpy, 0, NULL, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return retval; +} + +#define X_GLrop_DeleteFramebuffersEXT 4320 +void +__indirect_glDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8 + __GLX_PAD((n * 4)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_DeleteFramebuffersEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (framebuffers), + (n * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_DeleteRenderbuffersEXT 4317 +void +__indirect_glDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8 + __GLX_PAD((n * 4)); + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect(n >= 0, 1)) { + emit_header(gc->pc, X_GLrop_DeleteRenderbuffersEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (renderbuffers), + (n * 4)); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + +#define X_GLrop_FramebufferRenderbufferEXT 4324 +void +__indirect_glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, + GLenum renderbuffertarget, + GLuint renderbuffer) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_FramebufferRenderbufferEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&attachment), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&renderbuffertarget), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&renderbuffer), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_FramebufferTexture1DEXT 4321 +void +__indirect_glFramebufferTexture1DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, + GLint level) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_FramebufferTexture1DEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&attachment), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&textarget), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&texture), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&level), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_FramebufferTexture2DEXT 4322 +void +__indirect_glFramebufferTexture2DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, + GLint level) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_FramebufferTexture2DEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&attachment), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&textarget), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&texture), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&level), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_FramebufferTexture3DEXT 4323 +void +__indirect_glFramebufferTexture3DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, + GLint level, GLint zoffset) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 28; + emit_header(gc->pc, X_GLrop_FramebufferTexture3DEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&attachment), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&textarget), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&texture), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&level), 4); + (void) memcpy((void *) (gc->pc + 24), (void *) (&zoffset), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLvop_GenFramebuffersEXT 1426 +void +__indirect_glGenFramebuffersEXT(GLsizei n, GLuint * framebuffers) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 4; + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GenFramebuffersEXT, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) __glXReadReply(dpy, 4, framebuffers, GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_GenRenderbuffersEXT 1423 +void +__indirect_glGenRenderbuffersEXT(GLsizei n, GLuint * renderbuffers) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 4; + if (n < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GenRenderbuffersEXT, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) __glXReadReply(dpy, 4, renderbuffers, GL_TRUE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLrop_GenerateMipmapEXT 4325 +void +__indirect_glGenerateMipmapEXT(GLenum target) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 8; + emit_header(gc->pc, X_GLrop_GenerateMipmapEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLvop_GetFramebufferAttachmentParameterivEXT 1428 +void +__indirect_glGetFramebufferAttachmentParameterivEXT(GLenum target, + GLenum attachment, + GLenum pname, + GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 12; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetFramebufferAttachmentParameterivEXT, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&attachment), 4); + (void) memcpy((void *) (pc + 8), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_GetRenderbufferParameterivEXT 1424 +void +__indirect_glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, + GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetRenderbufferParameterivEXT, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); + (void) __glXReadReply(dpy, 4, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +#define X_GLvop_IsFramebufferEXT 1425 +GLboolean +__indirect_glIsFramebufferEXT(GLuint framebuffer) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + GLboolean retval = (GLboolean) 0; + const GLuint cmdlen = 4; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_IsFramebufferEXT, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&framebuffer), 4); + retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return retval; +} + +#define X_GLvop_IsRenderbufferEXT 1422 +GLboolean +__indirect_glIsRenderbufferEXT(GLuint renderbuffer) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + GLboolean retval = (GLboolean) 0; + const GLuint cmdlen = 4; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_IsRenderbufferEXT, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&renderbuffer), 4); + retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return retval; +} + +#define X_GLrop_RenderbufferStorageEXT 4318 +void +__indirect_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, + GLsizei width, GLsizei height) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 20; + emit_header(gc->pc, X_GLrop_RenderbufferStorageEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&internalformat), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&width), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&height), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_BlitFramebufferEXT 4330 +void +__indirect_glBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, + GLint srcY1, GLint dstX0, GLint dstY0, + GLint dstX1, GLint dstY1, GLbitfield mask, + GLenum filter) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 44; + emit_header(gc->pc, X_GLrop_BlitFramebufferEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&srcX0), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&srcY0), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&srcX1), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&srcY1), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&dstX0), 4); + (void) memcpy((void *) (gc->pc + 24), (void *) (&dstY0), 4); + (void) memcpy((void *) (gc->pc + 28), (void *) (&dstX1), 4); + (void) memcpy((void *) (gc->pc + 32), (void *) (&dstY1), 4); + (void) memcpy((void *) (gc->pc + 36), (void *) (&mask), 4); + (void) memcpy((void *) (gc->pc + 40), (void *) (&filter), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + +#define X_GLrop_FramebufferTextureLayerEXT 237 +void +__indirect_glFramebufferTextureLayerEXT(GLenum target, GLenum attachment, + GLuint texture, GLint level, + GLint layer) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + const GLuint cmdlen = 24; + emit_header(gc->pc, X_GLrop_FramebufferTextureLayerEXT, cmdlen); + (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); + (void) memcpy((void *) (gc->pc + 8), (void *) (&attachment), 4); + (void) memcpy((void *) (gc->pc + 12), (void *) (&texture), 4); + (void) memcpy((void *) (gc->pc + 16), (void *) (&level), 4); + (void) memcpy((void *) (gc->pc + 20), (void *) (&layer), 4); + gc->pc += cmdlen; + if (__builtin_expect(gc->pc > gc->limit, 0)) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + + +# undef FASTCALL +# undef NOINLINE diff --git a/src/glx/indirect.h b/src/glx/indirect.h new file mode 100644 index 00000000000..9e73b338184 --- /dev/null +++ b/src/glx/indirect.h @@ -0,0 +1,721 @@ +/* DO NOT EDIT - This file generated automatically by glX_proto_send.py (from Mesa) script */ + +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * (C) Copyright IBM Corporation 2004 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT, IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#if !defined( _INDIRECT_H_ ) +# define _INDIRECT_H_ + +/** + * \file + * Prototypes for indirect rendering functions. + * + * \author Kevin E. Martin + * \author Ian Romanick + */ + +# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) && defined(__ELF__) +# define HIDDEN __attribute__((visibility("hidden"))) +# else +# define HIDDEN +# endif +# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) +# define FASTCALL __attribute__((fastcall)) +# else +# define FASTCALL +# endif +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define NOINLINE __attribute__((noinline)) +# else +# define NOINLINE +# endif + +#include "glxclient.h" + +extern HIDDEN NOINLINE CARD32 __glXReadReply( Display *dpy, size_t size, + void * dest, GLboolean reply_is_always_array ); + +extern HIDDEN NOINLINE void __glXReadPixelReply( Display *dpy, + __GLXcontext * gc, unsigned max_dim, GLint width, GLint height, + GLint depth, GLenum format, GLenum type, void * dest, + GLboolean dimensions_in_reply ); + +extern HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupSingleRequest( + __GLXcontext * gc, GLint sop, GLint cmdlen ); + +extern HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest( + __GLXcontext * gc, GLint code, GLint vop, GLint cmdlen ); + +extern HIDDEN void __indirect_glNewList(GLuint list, GLenum mode); +extern HIDDEN void __indirect_glEndList(void); +extern HIDDEN void __indirect_glCallList(GLuint list); +extern HIDDEN void __indirect_glCallLists(GLsizei n, GLenum type, const GLvoid * lists); +extern HIDDEN void __indirect_glDeleteLists(GLuint list, GLsizei range); +extern HIDDEN GLuint __indirect_glGenLists(GLsizei range); +extern HIDDEN void __indirect_glListBase(GLuint base); +extern HIDDEN void __indirect_glBegin(GLenum mode); +extern HIDDEN void __indirect_glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap); +extern HIDDEN void __indirect_glColor3b(GLbyte red, GLbyte green, GLbyte blue); +extern HIDDEN void __indirect_glColor3bv(const GLbyte * v); +extern HIDDEN void __indirect_glColor3d(GLdouble red, GLdouble green, GLdouble blue); +extern HIDDEN void __indirect_glColor3dv(const GLdouble * v); +extern HIDDEN void __indirect_glColor3f(GLfloat red, GLfloat green, GLfloat blue); +extern HIDDEN void __indirect_glColor3fv(const GLfloat * v); +extern HIDDEN void __indirect_glColor3i(GLint red, GLint green, GLint blue); +extern HIDDEN void __indirect_glColor3iv(const GLint * v); +extern HIDDEN void __indirect_glColor3s(GLshort red, GLshort green, GLshort blue); +extern HIDDEN void __indirect_glColor3sv(const GLshort * v); +extern HIDDEN void __indirect_glColor3ub(GLubyte red, GLubyte green, GLubyte blue); +extern HIDDEN void __indirect_glColor3ubv(const GLubyte * v); +extern HIDDEN void __indirect_glColor3ui(GLuint red, GLuint green, GLuint blue); +extern HIDDEN void __indirect_glColor3uiv(const GLuint * v); +extern HIDDEN void __indirect_glColor3us(GLushort red, GLushort green, GLushort blue); +extern HIDDEN void __indirect_glColor3usv(const GLushort * v); +extern HIDDEN void __indirect_glColor4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +extern HIDDEN void __indirect_glColor4bv(const GLbyte * v); +extern HIDDEN void __indirect_glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +extern HIDDEN void __indirect_glColor4dv(const GLdouble * v); +extern HIDDEN void __indirect_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +extern HIDDEN void __indirect_glColor4fv(const GLfloat * v); +extern HIDDEN void __indirect_glColor4i(GLint red, GLint green, GLint blue, GLint alpha); +extern HIDDEN void __indirect_glColor4iv(const GLint * v); +extern HIDDEN void __indirect_glColor4s(GLshort red, GLshort green, GLshort blue, GLshort alpha); +extern HIDDEN void __indirect_glColor4sv(const GLshort * v); +extern HIDDEN void __indirect_glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +extern HIDDEN void __indirect_glColor4ubv(const GLubyte * v); +extern HIDDEN void __indirect_glColor4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha); +extern HIDDEN void __indirect_glColor4uiv(const GLuint * v); +extern HIDDEN void __indirect_glColor4us(GLushort red, GLushort green, GLushort blue, GLushort alpha); +extern HIDDEN void __indirect_glColor4usv(const GLushort * v); +extern HIDDEN void __indirect_glEdgeFlag(GLboolean flag); +extern HIDDEN void __indirect_glEdgeFlagv(const GLboolean * flag); +extern HIDDEN void __indirect_glEnd(void); +extern HIDDEN void __indirect_glIndexd(GLdouble c); +extern HIDDEN void __indirect_glIndexdv(const GLdouble * c); +extern HIDDEN void __indirect_glIndexf(GLfloat c); +extern HIDDEN void __indirect_glIndexfv(const GLfloat * c); +extern HIDDEN void __indirect_glIndexi(GLint c); +extern HIDDEN void __indirect_glIndexiv(const GLint * c); +extern HIDDEN void __indirect_glIndexs(GLshort c); +extern HIDDEN void __indirect_glIndexsv(const GLshort * c); +extern HIDDEN void __indirect_glNormal3b(GLbyte nx, GLbyte ny, GLbyte nz); +extern HIDDEN void __indirect_glNormal3bv(const GLbyte * v); +extern HIDDEN void __indirect_glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz); +extern HIDDEN void __indirect_glNormal3dv(const GLdouble * v); +extern HIDDEN void __indirect_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz); +extern HIDDEN void __indirect_glNormal3fv(const GLfloat * v); +extern HIDDEN void __indirect_glNormal3i(GLint nx, GLint ny, GLint nz); +extern HIDDEN void __indirect_glNormal3iv(const GLint * v); +extern HIDDEN void __indirect_glNormal3s(GLshort nx, GLshort ny, GLshort nz); +extern HIDDEN void __indirect_glNormal3sv(const GLshort * v); +extern HIDDEN void __indirect_glRasterPos2d(GLdouble x, GLdouble y); +extern HIDDEN void __indirect_glRasterPos2dv(const GLdouble * v); +extern HIDDEN void __indirect_glRasterPos2f(GLfloat x, GLfloat y); +extern HIDDEN void __indirect_glRasterPos2fv(const GLfloat * v); +extern HIDDEN void __indirect_glRasterPos2i(GLint x, GLint y); +extern HIDDEN void __indirect_glRasterPos2iv(const GLint * v); +extern HIDDEN void __indirect_glRasterPos2s(GLshort x, GLshort y); +extern HIDDEN void __indirect_glRasterPos2sv(const GLshort * v); +extern HIDDEN void __indirect_glRasterPos3d(GLdouble x, GLdouble y, GLdouble z); +extern HIDDEN void __indirect_glRasterPos3dv(const GLdouble * v); +extern HIDDEN void __indirect_glRasterPos3f(GLfloat x, GLfloat y, GLfloat z); +extern HIDDEN void __indirect_glRasterPos3fv(const GLfloat * v); +extern HIDDEN void __indirect_glRasterPos3i(GLint x, GLint y, GLint z); +extern HIDDEN void __indirect_glRasterPos3iv(const GLint * v); +extern HIDDEN void __indirect_glRasterPos3s(GLshort x, GLshort y, GLshort z); +extern HIDDEN void __indirect_glRasterPos3sv(const GLshort * v); +extern HIDDEN void __indirect_glRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +extern HIDDEN void __indirect_glRasterPos4dv(const GLdouble * v); +extern HIDDEN void __indirect_glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +extern HIDDEN void __indirect_glRasterPos4fv(const GLfloat * v); +extern HIDDEN void __indirect_glRasterPos4i(GLint x, GLint y, GLint z, GLint w); +extern HIDDEN void __indirect_glRasterPos4iv(const GLint * v); +extern HIDDEN void __indirect_glRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w); +extern HIDDEN void __indirect_glRasterPos4sv(const GLshort * v); +extern HIDDEN void __indirect_glRectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +extern HIDDEN void __indirect_glRectdv(const GLdouble * v1, const GLdouble * v2); +extern HIDDEN void __indirect_glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +extern HIDDEN void __indirect_glRectfv(const GLfloat * v1, const GLfloat * v2); +extern HIDDEN void __indirect_glRecti(GLint x1, GLint y1, GLint x2, GLint y2); +extern HIDDEN void __indirect_glRectiv(const GLint * v1, const GLint * v2); +extern HIDDEN void __indirect_glRects(GLshort x1, GLshort y1, GLshort x2, GLshort y2); +extern HIDDEN void __indirect_glRectsv(const GLshort * v1, const GLshort * v2); +extern HIDDEN void __indirect_glTexCoord1d(GLdouble s); +extern HIDDEN void __indirect_glTexCoord1dv(const GLdouble * v); +extern HIDDEN void __indirect_glTexCoord1f(GLfloat s); +extern HIDDEN void __indirect_glTexCoord1fv(const GLfloat * v); +extern HIDDEN void __indirect_glTexCoord1i(GLint s); +extern HIDDEN void __indirect_glTexCoord1iv(const GLint * v); +extern HIDDEN void __indirect_glTexCoord1s(GLshort s); +extern HIDDEN void __indirect_glTexCoord1sv(const GLshort * v); +extern HIDDEN void __indirect_glTexCoord2d(GLdouble s, GLdouble t); +extern HIDDEN void __indirect_glTexCoord2dv(const GLdouble * v); +extern HIDDEN void __indirect_glTexCoord2f(GLfloat s, GLfloat t); +extern HIDDEN void __indirect_glTexCoord2fv(const GLfloat * v); +extern HIDDEN void __indirect_glTexCoord2i(GLint s, GLint t); +extern HIDDEN void __indirect_glTexCoord2iv(const GLint * v); +extern HIDDEN void __indirect_glTexCoord2s(GLshort s, GLshort t); +extern HIDDEN void __indirect_glTexCoord2sv(const GLshort * v); +extern HIDDEN void __indirect_glTexCoord3d(GLdouble s, GLdouble t, GLdouble r); +extern HIDDEN void __indirect_glTexCoord3dv(const GLdouble * v); +extern HIDDEN void __indirect_glTexCoord3f(GLfloat s, GLfloat t, GLfloat r); +extern HIDDEN void __indirect_glTexCoord3fv(const GLfloat * v); +extern HIDDEN void __indirect_glTexCoord3i(GLint s, GLint t, GLint r); +extern HIDDEN void __indirect_glTexCoord3iv(const GLint * v); +extern HIDDEN void __indirect_glTexCoord3s(GLshort s, GLshort t, GLshort r); +extern HIDDEN void __indirect_glTexCoord3sv(const GLshort * v); +extern HIDDEN void __indirect_glTexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q); +extern HIDDEN void __indirect_glTexCoord4dv(const GLdouble * v); +extern HIDDEN void __indirect_glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q); +extern HIDDEN void __indirect_glTexCoord4fv(const GLfloat * v); +extern HIDDEN void __indirect_glTexCoord4i(GLint s, GLint t, GLint r, GLint q); +extern HIDDEN void __indirect_glTexCoord4iv(const GLint * v); +extern HIDDEN void __indirect_glTexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q); +extern HIDDEN void __indirect_glTexCoord4sv(const GLshort * v); +extern HIDDEN void __indirect_glVertex2d(GLdouble x, GLdouble y); +extern HIDDEN void __indirect_glVertex2dv(const GLdouble * v); +extern HIDDEN void __indirect_glVertex2f(GLfloat x, GLfloat y); +extern HIDDEN void __indirect_glVertex2fv(const GLfloat * v); +extern HIDDEN void __indirect_glVertex2i(GLint x, GLint y); +extern HIDDEN void __indirect_glVertex2iv(const GLint * v); +extern HIDDEN void __indirect_glVertex2s(GLshort x, GLshort y); +extern HIDDEN void __indirect_glVertex2sv(const GLshort * v); +extern HIDDEN void __indirect_glVertex3d(GLdouble x, GLdouble y, GLdouble z); +extern HIDDEN void __indirect_glVertex3dv(const GLdouble * v); +extern HIDDEN void __indirect_glVertex3f(GLfloat x, GLfloat y, GLfloat z); +extern HIDDEN void __indirect_glVertex3fv(const GLfloat * v); +extern HIDDEN void __indirect_glVertex3i(GLint x, GLint y, GLint z); +extern HIDDEN void __indirect_glVertex3iv(const GLint * v); +extern HIDDEN void __indirect_glVertex3s(GLshort x, GLshort y, GLshort z); +extern HIDDEN void __indirect_glVertex3sv(const GLshort * v); +extern HIDDEN void __indirect_glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +extern HIDDEN void __indirect_glVertex4dv(const GLdouble * v); +extern HIDDEN void __indirect_glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +extern HIDDEN void __indirect_glVertex4fv(const GLfloat * v); +extern HIDDEN void __indirect_glVertex4i(GLint x, GLint y, GLint z, GLint w); +extern HIDDEN void __indirect_glVertex4iv(const GLint * v); +extern HIDDEN void __indirect_glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w); +extern HIDDEN void __indirect_glVertex4sv(const GLshort * v); +extern HIDDEN void __indirect_glClipPlane(GLenum plane, const GLdouble * equation); +extern HIDDEN void __indirect_glColorMaterial(GLenum face, GLenum mode); +extern HIDDEN void __indirect_glCullFace(GLenum mode); +extern HIDDEN void __indirect_glFogf(GLenum pname, GLfloat param); +extern HIDDEN void __indirect_glFogfv(GLenum pname, const GLfloat * params); +extern HIDDEN void __indirect_glFogi(GLenum pname, GLint param); +extern HIDDEN void __indirect_glFogiv(GLenum pname, const GLint * params); +extern HIDDEN void __indirect_glFrontFace(GLenum mode); +extern HIDDEN void __indirect_glHint(GLenum target, GLenum mode); +extern HIDDEN void __indirect_glLightf(GLenum light, GLenum pname, GLfloat param); +extern HIDDEN void __indirect_glLightfv(GLenum light, GLenum pname, const GLfloat * params); +extern HIDDEN void __indirect_glLighti(GLenum light, GLenum pname, GLint param); +extern HIDDEN void __indirect_glLightiv(GLenum light, GLenum pname, const GLint * params); +extern HIDDEN void __indirect_glLightModelf(GLenum pname, GLfloat param); +extern HIDDEN void __indirect_glLightModelfv(GLenum pname, const GLfloat * params); +extern HIDDEN void __indirect_glLightModeli(GLenum pname, GLint param); +extern HIDDEN void __indirect_glLightModeliv(GLenum pname, const GLint * params); +extern HIDDEN void __indirect_glLineStipple(GLint factor, GLushort pattern); +extern HIDDEN void __indirect_glLineWidth(GLfloat width); +extern HIDDEN void __indirect_glMaterialf(GLenum face, GLenum pname, GLfloat param); +extern HIDDEN void __indirect_glMaterialfv(GLenum face, GLenum pname, const GLfloat * params); +extern HIDDEN void __indirect_glMateriali(GLenum face, GLenum pname, GLint param); +extern HIDDEN void __indirect_glMaterialiv(GLenum face, GLenum pname, const GLint * params); +extern HIDDEN void __indirect_glPointSize(GLfloat size); +extern HIDDEN void __indirect_glPolygonMode(GLenum face, GLenum mode); +extern HIDDEN void __indirect_glPolygonStipple(const GLubyte * mask); +extern HIDDEN void __indirect_glScissor(GLint x, GLint y, GLsizei width, GLsizei height); +extern HIDDEN void __indirect_glShadeModel(GLenum mode); +extern HIDDEN void __indirect_glTexParameterf(GLenum target, GLenum pname, GLfloat param); +extern HIDDEN void __indirect_glTexParameterfv(GLenum target, GLenum pname, const GLfloat * params); +extern HIDDEN void __indirect_glTexParameteri(GLenum target, GLenum pname, GLint param); +extern HIDDEN void __indirect_glTexParameteriv(GLenum target, GLenum pname, const GLint * params); +extern HIDDEN void __indirect_glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid * pixels); +extern HIDDEN void __indirect_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels); +extern HIDDEN void __indirect_glTexEnvf(GLenum target, GLenum pname, GLfloat param); +extern HIDDEN void __indirect_glTexEnvfv(GLenum target, GLenum pname, const GLfloat * params); +extern HIDDEN void __indirect_glTexEnvi(GLenum target, GLenum pname, GLint param); +extern HIDDEN void __indirect_glTexEnviv(GLenum target, GLenum pname, const GLint * params); +extern HIDDEN void __indirect_glTexGend(GLenum coord, GLenum pname, GLdouble param); +extern HIDDEN void __indirect_glTexGendv(GLenum coord, GLenum pname, const GLdouble * params); +extern HIDDEN void __indirect_glTexGenf(GLenum coord, GLenum pname, GLfloat param); +extern HIDDEN void __indirect_glTexGenfv(GLenum coord, GLenum pname, const GLfloat * params); +extern HIDDEN void __indirect_glTexGeni(GLenum coord, GLenum pname, GLint param); +extern HIDDEN void __indirect_glTexGeniv(GLenum coord, GLenum pname, const GLint * params); +extern HIDDEN void __indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer); +extern HIDDEN void __indirect_glSelectBuffer(GLsizei size, GLuint * buffer); +extern HIDDEN GLint __indirect_glRenderMode(GLenum mode); +extern HIDDEN void __indirect_glInitNames(void); +extern HIDDEN void __indirect_glLoadName(GLuint name); +extern HIDDEN void __indirect_glPassThrough(GLfloat token); +extern HIDDEN void __indirect_glPopName(void); +extern HIDDEN void __indirect_glPushName(GLuint name); +extern HIDDEN void __indirect_glDrawBuffer(GLenum mode); +extern HIDDEN void __indirect_glClear(GLbitfield mask); +extern HIDDEN void __indirect_glClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +extern HIDDEN void __indirect_glClearIndex(GLfloat c); +extern HIDDEN void __indirect_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +extern HIDDEN void __indirect_glClearStencil(GLint s); +extern HIDDEN void __indirect_glClearDepth(GLclampd depth); +extern HIDDEN void __indirect_glStencilMask(GLuint mask); +extern HIDDEN void __indirect_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +extern HIDDEN void __indirect_glDepthMask(GLboolean flag); +extern HIDDEN void __indirect_glIndexMask(GLuint mask); +extern HIDDEN void __indirect_glAccum(GLenum op, GLfloat value); +extern HIDDEN void __indirect_glDisable(GLenum cap); +extern HIDDEN void __indirect_glEnable(GLenum cap); +extern HIDDEN void __indirect_glFinish(void); +extern HIDDEN void __indirect_glFlush(void); +extern HIDDEN void __indirect_glPopAttrib(void); +extern HIDDEN void __indirect_glPushAttrib(GLbitfield mask); +extern HIDDEN void __indirect_glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points); +extern HIDDEN void __indirect_glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points); +extern HIDDEN void __indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points); +extern HIDDEN void __indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points); +extern HIDDEN void __indirect_glMapGrid1d(GLint un, GLdouble u1, GLdouble u2); +extern HIDDEN void __indirect_glMapGrid1f(GLint un, GLfloat u1, GLfloat u2); +extern HIDDEN void __indirect_glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +extern HIDDEN void __indirect_glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +extern HIDDEN void __indirect_glEvalCoord1d(GLdouble u); +extern HIDDEN void __indirect_glEvalCoord1dv(const GLdouble * u); +extern HIDDEN void __indirect_glEvalCoord1f(GLfloat u); +extern HIDDEN void __indirect_glEvalCoord1fv(const GLfloat * u); +extern HIDDEN void __indirect_glEvalCoord2d(GLdouble u, GLdouble v); +extern HIDDEN void __indirect_glEvalCoord2dv(const GLdouble * u); +extern HIDDEN void __indirect_glEvalCoord2f(GLfloat u, GLfloat v); +extern HIDDEN void __indirect_glEvalCoord2fv(const GLfloat * u); +extern HIDDEN void __indirect_glEvalMesh1(GLenum mode, GLint i1, GLint i2); +extern HIDDEN void __indirect_glEvalPoint1(GLint i); +extern HIDDEN void __indirect_glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +extern HIDDEN void __indirect_glEvalPoint2(GLint i, GLint j); +extern HIDDEN void __indirect_glAlphaFunc(GLenum func, GLclampf ref); +extern HIDDEN void __indirect_glBlendFunc(GLenum sfactor, GLenum dfactor); +extern HIDDEN void __indirect_glLogicOp(GLenum opcode); +extern HIDDEN void __indirect_glStencilFunc(GLenum func, GLint ref, GLuint mask); +extern HIDDEN void __indirect_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass); +extern HIDDEN void __indirect_glDepthFunc(GLenum func); +extern HIDDEN void __indirect_glPixelZoom(GLfloat xfactor, GLfloat yfactor); +extern HIDDEN void __indirect_glPixelTransferf(GLenum pname, GLfloat param); +extern HIDDEN void __indirect_glPixelTransferi(GLenum pname, GLint param); +extern HIDDEN void __indirect_glPixelStoref(GLenum pname, GLfloat param); +extern HIDDEN void __indirect_glPixelStorei(GLenum pname, GLint param); +extern HIDDEN void __indirect_glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat * values); +extern HIDDEN void __indirect_glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint * values); +extern HIDDEN void __indirect_glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort * values); +extern HIDDEN void __indirect_glReadBuffer(GLenum mode); +extern HIDDEN void __indirect_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +extern HIDDEN void __indirect_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * pixels); +extern HIDDEN void __indirect_glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels); +extern HIDDEN void __indirect_glGetBooleanv(GLenum pname, GLboolean * params); +extern HIDDEN void __indirect_glGetClipPlane(GLenum plane, GLdouble * equation); +extern HIDDEN void __indirect_glGetDoublev(GLenum pname, GLdouble * params); +extern HIDDEN GLenum __indirect_glGetError(void); +extern HIDDEN void __indirect_glGetFloatv(GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetIntegerv(GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetLightfv(GLenum light, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetLightiv(GLenum light, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetMapdv(GLenum target, GLenum query, GLdouble * v); +extern HIDDEN void __indirect_glGetMapfv(GLenum target, GLenum query, GLfloat * v); +extern HIDDEN void __indirect_glGetMapiv(GLenum target, GLenum query, GLint * v); +extern HIDDEN void __indirect_glGetMaterialfv(GLenum face, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetMaterialiv(GLenum face, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetPixelMapfv(GLenum map, GLfloat * values); +extern HIDDEN void __indirect_glGetPixelMapuiv(GLenum map, GLuint * values); +extern HIDDEN void __indirect_glGetPixelMapusv(GLenum map, GLushort * values); +extern HIDDEN void __indirect_glGetPolygonStipple(GLubyte * mask); +extern HIDDEN const GLubyte * __indirect_glGetString(GLenum name); +extern HIDDEN void __indirect_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetTexEnviv(GLenum target, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetTexGendv(GLenum coord, GLenum pname, GLdouble * params); +extern HIDDEN void __indirect_glGetTexGenfv(GLenum coord, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetTexGeniv(GLenum coord, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid * pixels); +extern HIDDEN void __indirect_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetTexParameteriv(GLenum target, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint * params); +extern HIDDEN GLboolean __indirect_glIsEnabled(GLenum cap); +extern HIDDEN GLboolean __indirect_glIsList(GLuint list); +extern HIDDEN void __indirect_glDepthRange(GLclampd zNear, GLclampd zFar); +extern HIDDEN void __indirect_glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +extern HIDDEN void __indirect_glLoadIdentity(void); +extern HIDDEN void __indirect_glLoadMatrixf(const GLfloat * m); +extern HIDDEN void __indirect_glLoadMatrixd(const GLdouble * m); +extern HIDDEN void __indirect_glMatrixMode(GLenum mode); +extern HIDDEN void __indirect_glMultMatrixf(const GLfloat * m); +extern HIDDEN void __indirect_glMultMatrixd(const GLdouble * m); +extern HIDDEN void __indirect_glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +extern HIDDEN void __indirect_glPopMatrix(void); +extern HIDDEN void __indirect_glPushMatrix(void); +extern HIDDEN void __indirect_glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +extern HIDDEN void __indirect_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +extern HIDDEN void __indirect_glScaled(GLdouble x, GLdouble y, GLdouble z); +extern HIDDEN void __indirect_glScalef(GLfloat x, GLfloat y, GLfloat z); +extern HIDDEN void __indirect_glTranslated(GLdouble x, GLdouble y, GLdouble z); +extern HIDDEN void __indirect_glTranslatef(GLfloat x, GLfloat y, GLfloat z); +extern HIDDEN void __indirect_glViewport(GLint x, GLint y, GLsizei width, GLsizei height); +extern HIDDEN void __indirect_glArrayElement(GLint i); +extern HIDDEN void __indirect_glBindTexture(GLenum target, GLuint texture); +extern HIDDEN void __indirect_glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); +extern HIDDEN void __indirect_glDisableClientState(GLenum array); +extern HIDDEN void __indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count); +extern HIDDEN void __indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices); +extern HIDDEN void __indirect_glEdgeFlagPointer(GLsizei stride, const GLvoid * pointer); +extern HIDDEN void __indirect_glEnableClientState(GLenum array); +extern HIDDEN void __indirect_glIndexPointer(GLenum type, GLsizei stride, const GLvoid * pointer); +extern HIDDEN void __indirect_glIndexub(GLubyte c); +extern HIDDEN void __indirect_glIndexubv(const GLubyte * c); +extern HIDDEN void __indirect_glInterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer); +extern HIDDEN void __indirect_glNormalPointer(GLenum type, GLsizei stride, const GLvoid * pointer); +extern HIDDEN void __indirect_glPolygonOffset(GLfloat factor, GLfloat units); +extern HIDDEN void __indirect_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); +extern HIDDEN void __indirect_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); +extern HIDDEN GLboolean __indirect_glAreTexturesResident(GLsizei n, const GLuint * textures, GLboolean * residences); +GLAPI GLboolean GLAPIENTRY glAreTexturesResidentEXT(GLsizei n, const GLuint * textures, GLboolean * residences); +extern HIDDEN void __indirect_glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +extern HIDDEN void __indirect_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +extern HIDDEN void __indirect_glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +extern HIDDEN void __indirect_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +extern HIDDEN void __indirect_glDeleteTextures(GLsizei n, const GLuint * textures); +GLAPI void GLAPIENTRY glDeleteTexturesEXT(GLsizei n, const GLuint * textures); +extern HIDDEN void __indirect_glGenTextures(GLsizei n, GLuint * textures); +GLAPI void GLAPIENTRY glGenTexturesEXT(GLsizei n, GLuint * textures); +extern HIDDEN void __indirect_glGetPointerv(GLenum pname, GLvoid ** params); +extern HIDDEN GLboolean __indirect_glIsTexture(GLuint texture); +GLAPI GLboolean GLAPIENTRY glIsTextureEXT(GLuint texture); +extern HIDDEN void __indirect_glPrioritizeTextures(GLsizei n, const GLuint * textures, const GLclampf * priorities); +extern HIDDEN void __indirect_glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels); +extern HIDDEN void __indirect_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels); +extern HIDDEN void __indirect_glPopClientAttrib(void); +extern HIDDEN void __indirect_glPushClientAttrib(GLbitfield mask); +extern HIDDEN void __indirect_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +extern HIDDEN void __indirect_glBlendEquation(GLenum mode); +extern HIDDEN void __indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices); +extern HIDDEN void __indirect_glColorTable(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table); +extern HIDDEN void __indirect_glColorTableParameterfv(GLenum target, GLenum pname, const GLfloat * params); +extern HIDDEN void __indirect_glColorTableParameteriv(GLenum target, GLenum pname, const GLint * params); +extern HIDDEN void __indirect_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +extern HIDDEN void __indirect_glGetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * table); +GLAPI void GLAPIENTRY glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid * table); +extern HIDDEN void __indirect_glGetColorTableParameterfv(GLenum target, GLenum pname, GLfloat * params); +GLAPI void GLAPIENTRY glGetColorTableParameterfvEXT(GLenum target, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetColorTableParameteriv(GLenum target, GLenum pname, GLint * params); +GLAPI void GLAPIENTRY glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glColorSubTable(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid * data); +extern HIDDEN void __indirect_glCopyColorSubTable(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +extern HIDDEN void __indirect_glConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * image); +extern HIDDEN void __indirect_glConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * image); +extern HIDDEN void __indirect_glConvolutionParameterf(GLenum target, GLenum pname, GLfloat params); +extern HIDDEN void __indirect_glConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat * params); +extern HIDDEN void __indirect_glConvolutionParameteri(GLenum target, GLenum pname, GLint params); +extern HIDDEN void __indirect_glConvolutionParameteriv(GLenum target, GLenum pname, const GLint * params); +extern HIDDEN void __indirect_glCopyConvolutionFilter1D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +extern HIDDEN void __indirect_glCopyConvolutionFilter2D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +extern HIDDEN void __indirect_glGetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid * image); +extern HIDDEN void gl_dispatch_stub_356(GLenum target, GLenum format, GLenum type, GLvoid * image); +extern HIDDEN void __indirect_glGetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat * params); +extern HIDDEN void gl_dispatch_stub_357(GLenum target, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetConvolutionParameteriv(GLenum target, GLenum pname, GLint * params); +extern HIDDEN void gl_dispatch_stub_358(GLenum target, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span); +extern HIDDEN void gl_dispatch_stub_359(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span); +extern HIDDEN void __indirect_glSeparableFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * row, const GLvoid * column); +extern HIDDEN void __indirect_glGetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); +extern HIDDEN void gl_dispatch_stub_361(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); +extern HIDDEN void __indirect_glGetHistogramParameterfv(GLenum target, GLenum pname, GLfloat * params); +extern HIDDEN void gl_dispatch_stub_362(GLenum target, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetHistogramParameteriv(GLenum target, GLenum pname, GLint * params); +extern HIDDEN void gl_dispatch_stub_363(GLenum target, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); +extern HIDDEN void gl_dispatch_stub_364(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); +extern HIDDEN void __indirect_glGetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat * params); +extern HIDDEN void gl_dispatch_stub_365(GLenum target, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetMinmaxParameteriv(GLenum target, GLenum pname, GLint * params); +extern HIDDEN void gl_dispatch_stub_366(GLenum target, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glHistogram(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +extern HIDDEN void __indirect_glMinmax(GLenum target, GLenum internalformat, GLboolean sink); +extern HIDDEN void __indirect_glResetHistogram(GLenum target); +extern HIDDEN void __indirect_glResetMinmax(GLenum target); +extern HIDDEN void __indirect_glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels); +extern HIDDEN void __indirect_glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels); +extern HIDDEN void __indirect_glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +extern HIDDEN void __indirect_glActiveTextureARB(GLenum texture); +extern HIDDEN void __indirect_glClientActiveTextureARB(GLenum texture); +extern HIDDEN void __indirect_glMultiTexCoord1dARB(GLenum target, GLdouble s); +extern HIDDEN void __indirect_glMultiTexCoord1dvARB(GLenum target, const GLdouble * v); +extern HIDDEN void __indirect_glMultiTexCoord1fARB(GLenum target, GLfloat s); +extern HIDDEN void __indirect_glMultiTexCoord1fvARB(GLenum target, const GLfloat * v); +extern HIDDEN void __indirect_glMultiTexCoord1iARB(GLenum target, GLint s); +extern HIDDEN void __indirect_glMultiTexCoord1ivARB(GLenum target, const GLint * v); +extern HIDDEN void __indirect_glMultiTexCoord1sARB(GLenum target, GLshort s); +extern HIDDEN void __indirect_glMultiTexCoord1svARB(GLenum target, const GLshort * v); +extern HIDDEN void __indirect_glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t); +extern HIDDEN void __indirect_glMultiTexCoord2dvARB(GLenum target, const GLdouble * v); +extern HIDDEN void __indirect_glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); +extern HIDDEN void __indirect_glMultiTexCoord2fvARB(GLenum target, const GLfloat * v); +extern HIDDEN void __indirect_glMultiTexCoord2iARB(GLenum target, GLint s, GLint t); +extern HIDDEN void __indirect_glMultiTexCoord2ivARB(GLenum target, const GLint * v); +extern HIDDEN void __indirect_glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t); +extern HIDDEN void __indirect_glMultiTexCoord2svARB(GLenum target, const GLshort * v); +extern HIDDEN void __indirect_glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r); +extern HIDDEN void __indirect_glMultiTexCoord3dvARB(GLenum target, const GLdouble * v); +extern HIDDEN void __indirect_glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r); +extern HIDDEN void __indirect_glMultiTexCoord3fvARB(GLenum target, const GLfloat * v); +extern HIDDEN void __indirect_glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r); +extern HIDDEN void __indirect_glMultiTexCoord3ivARB(GLenum target, const GLint * v); +extern HIDDEN void __indirect_glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r); +extern HIDDEN void __indirect_glMultiTexCoord3svARB(GLenum target, const GLshort * v); +extern HIDDEN void __indirect_glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +extern HIDDEN void __indirect_glMultiTexCoord4dvARB(GLenum target, const GLdouble * v); +extern HIDDEN void __indirect_glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +extern HIDDEN void __indirect_glMultiTexCoord4fvARB(GLenum target, const GLfloat * v); +extern HIDDEN void __indirect_glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q); +extern HIDDEN void __indirect_glMultiTexCoord4ivARB(GLenum target, const GLint * v); +extern HIDDEN void __indirect_glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +extern HIDDEN void __indirect_glMultiTexCoord4svARB(GLenum target, const GLshort * v); +extern HIDDEN void __indirect_glLoadTransposeMatrixdARB(const GLdouble * m); +extern HIDDEN void __indirect_glLoadTransposeMatrixfARB(const GLfloat * m); +extern HIDDEN void __indirect_glMultTransposeMatrixdARB(const GLdouble * m); +extern HIDDEN void __indirect_glMultTransposeMatrixfARB(const GLfloat * m); +extern HIDDEN void __indirect_glSampleCoverageARB(GLclampf value, GLboolean invert); +extern HIDDEN void __indirect_glCompressedTexImage1DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid * data); +extern HIDDEN void __indirect_glCompressedTexImage2DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data); +extern HIDDEN void __indirect_glCompressedTexImage3DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid * data); +extern HIDDEN void __indirect_glCompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid * data); +extern HIDDEN void __indirect_glCompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data); +extern HIDDEN void __indirect_glCompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid * data); +extern HIDDEN void __indirect_glGetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img); +extern HIDDEN void __indirect_glDisableVertexAttribArrayARB(GLuint index); +extern HIDDEN void __indirect_glEnableVertexAttribArrayARB(GLuint index); +extern HIDDEN void __indirect_glGetProgramEnvParameterdvARB(GLenum target, GLuint index, GLdouble * params); +extern HIDDEN void __indirect_glGetProgramEnvParameterfvARB(GLenum target, GLuint index, GLfloat * params); +extern HIDDEN void __indirect_glGetProgramLocalParameterdvARB(GLenum target, GLuint index, GLdouble * params); +extern HIDDEN void __indirect_glGetProgramLocalParameterfvARB(GLenum target, GLuint index, GLfloat * params); +extern HIDDEN void __indirect_glGetProgramStringARB(GLenum target, GLenum pname, GLvoid * string); +extern HIDDEN void __indirect_glGetProgramivARB(GLenum target, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble * params); +extern HIDDEN void __indirect_glGetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetVertexAttribivARB(GLuint index, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glProgramEnvParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +extern HIDDEN void __indirect_glProgramEnvParameter4dvARB(GLenum target, GLuint index, const GLdouble * params); +extern HIDDEN void __indirect_glProgramEnvParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +extern HIDDEN void __indirect_glProgramEnvParameter4fvARB(GLenum target, GLuint index, const GLfloat * params); +extern HIDDEN void __indirect_glProgramLocalParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +extern HIDDEN void __indirect_glProgramLocalParameter4dvARB(GLenum target, GLuint index, const GLdouble * params); +extern HIDDEN void __indirect_glProgramLocalParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +extern HIDDEN void __indirect_glProgramLocalParameter4fvARB(GLenum target, GLuint index, const GLfloat * params); +extern HIDDEN void __indirect_glProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid * string); +extern HIDDEN void __indirect_glVertexAttrib1dARB(GLuint index, GLdouble x); +extern HIDDEN void __indirect_glVertexAttrib1dvARB(GLuint index, const GLdouble * v); +extern HIDDEN void __indirect_glVertexAttrib1fARB(GLuint index, GLfloat x); +extern HIDDEN void __indirect_glVertexAttrib1fvARB(GLuint index, const GLfloat * v); +extern HIDDEN void __indirect_glVertexAttrib1sARB(GLuint index, GLshort x); +extern HIDDEN void __indirect_glVertexAttrib1svARB(GLuint index, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttrib2dARB(GLuint index, GLdouble x, GLdouble y); +extern HIDDEN void __indirect_glVertexAttrib2dvARB(GLuint index, const GLdouble * v); +extern HIDDEN void __indirect_glVertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y); +extern HIDDEN void __indirect_glVertexAttrib2fvARB(GLuint index, const GLfloat * v); +extern HIDDEN void __indirect_glVertexAttrib2sARB(GLuint index, GLshort x, GLshort y); +extern HIDDEN void __indirect_glVertexAttrib2svARB(GLuint index, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttrib3dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z); +extern HIDDEN void __indirect_glVertexAttrib3dvARB(GLuint index, const GLdouble * v); +extern HIDDEN void __indirect_glVertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z); +extern HIDDEN void __indirect_glVertexAttrib3fvARB(GLuint index, const GLfloat * v); +extern HIDDEN void __indirect_glVertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z); +extern HIDDEN void __indirect_glVertexAttrib3svARB(GLuint index, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttrib4NbvARB(GLuint index, const GLbyte * v); +extern HIDDEN void __indirect_glVertexAttrib4NivARB(GLuint index, const GLint * v); +extern HIDDEN void __indirect_glVertexAttrib4NsvARB(GLuint index, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +extern HIDDEN void __indirect_glVertexAttrib4NubvARB(GLuint index, const GLubyte * v); +extern HIDDEN void __indirect_glVertexAttrib4NuivARB(GLuint index, const GLuint * v); +extern HIDDEN void __indirect_glVertexAttrib4NusvARB(GLuint index, const GLushort * v); +extern HIDDEN void __indirect_glVertexAttrib4bvARB(GLuint index, const GLbyte * v); +extern HIDDEN void __indirect_glVertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +extern HIDDEN void __indirect_glVertexAttrib4dvARB(GLuint index, const GLdouble * v); +extern HIDDEN void __indirect_glVertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +extern HIDDEN void __indirect_glVertexAttrib4fvARB(GLuint index, const GLfloat * v); +extern HIDDEN void __indirect_glVertexAttrib4ivARB(GLuint index, const GLint * v); +extern HIDDEN void __indirect_glVertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +extern HIDDEN void __indirect_glVertexAttrib4svARB(GLuint index, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttrib4ubvARB(GLuint index, const GLubyte * v); +extern HIDDEN void __indirect_glVertexAttrib4uivARB(GLuint index, const GLuint * v); +extern HIDDEN void __indirect_glVertexAttrib4usvARB(GLuint index, const GLushort * v); +extern HIDDEN void __indirect_glVertexAttribPointerARB(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer); +extern HIDDEN void __indirect_glBeginQueryARB(GLenum target, GLuint id); +extern HIDDEN void __indirect_glDeleteQueriesARB(GLsizei n, const GLuint * ids); +extern HIDDEN void __indirect_glEndQueryARB(GLenum target); +extern HIDDEN void __indirect_glGenQueriesARB(GLsizei n, GLuint * ids); +extern HIDDEN void __indirect_glGetQueryObjectivARB(GLuint id, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint * params); +extern HIDDEN void __indirect_glGetQueryivARB(GLenum target, GLenum pname, GLint * params); +extern HIDDEN GLboolean __indirect_glIsQueryARB(GLuint id); +extern HIDDEN void __indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs); +extern HIDDEN void __indirect_glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +extern HIDDEN void __indirect_glSampleMaskSGIS(GLclampf value, GLboolean invert); +extern HIDDEN void __indirect_glSamplePatternSGIS(GLenum pattern); +extern HIDDEN void __indirect_glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); +extern HIDDEN void __indirect_glEdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean * pointer); +extern HIDDEN void __indirect_glIndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); +extern HIDDEN void __indirect_glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); +extern HIDDEN void __indirect_glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); +extern HIDDEN void __indirect_glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); +extern HIDDEN void __indirect_glPointParameterfEXT(GLenum pname, GLfloat param); +extern HIDDEN void __indirect_glPointParameterfvEXT(GLenum pname, const GLfloat * params); +extern HIDDEN void __indirect_glSecondaryColor3bEXT(GLbyte red, GLbyte green, GLbyte blue); +extern HIDDEN void __indirect_glSecondaryColor3bvEXT(const GLbyte * v); +extern HIDDEN void __indirect_glSecondaryColor3dEXT(GLdouble red, GLdouble green, GLdouble blue); +extern HIDDEN void __indirect_glSecondaryColor3dvEXT(const GLdouble * v); +extern HIDDEN void __indirect_glSecondaryColor3fEXT(GLfloat red, GLfloat green, GLfloat blue); +extern HIDDEN void __indirect_glSecondaryColor3fvEXT(const GLfloat * v); +extern HIDDEN void __indirect_glSecondaryColor3iEXT(GLint red, GLint green, GLint blue); +extern HIDDEN void __indirect_glSecondaryColor3ivEXT(const GLint * v); +extern HIDDEN void __indirect_glSecondaryColor3sEXT(GLshort red, GLshort green, GLshort blue); +extern HIDDEN void __indirect_glSecondaryColor3svEXT(const GLshort * v); +extern HIDDEN void __indirect_glSecondaryColor3ubEXT(GLubyte red, GLubyte green, GLubyte blue); +extern HIDDEN void __indirect_glSecondaryColor3ubvEXT(const GLubyte * v); +extern HIDDEN void __indirect_glSecondaryColor3uiEXT(GLuint red, GLuint green, GLuint blue); +extern HIDDEN void __indirect_glSecondaryColor3uivEXT(const GLuint * v); +extern HIDDEN void __indirect_glSecondaryColor3usEXT(GLushort red, GLushort green, GLushort blue); +extern HIDDEN void __indirect_glSecondaryColor3usvEXT(const GLushort * v); +extern HIDDEN void __indirect_glSecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); +extern HIDDEN void __indirect_glMultiDrawArraysEXT(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount); +extern HIDDEN void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount); +extern HIDDEN void __indirect_glFogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid * pointer); +extern HIDDEN void __indirect_glFogCoorddEXT(GLdouble coord); +extern HIDDEN void __indirect_glFogCoorddvEXT(const GLdouble * coord); +extern HIDDEN void __indirect_glFogCoordfEXT(GLfloat coord); +extern HIDDEN void __indirect_glFogCoordfvEXT(const GLfloat * coord); +extern HIDDEN void __indirect_glBlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +extern HIDDEN void __indirect_glWindowPos2dMESA(GLdouble x, GLdouble y); +extern HIDDEN void __indirect_glWindowPos2dvMESA(const GLdouble * v); +extern HIDDEN void __indirect_glWindowPos2fMESA(GLfloat x, GLfloat y); +extern HIDDEN void __indirect_glWindowPos2fvMESA(const GLfloat * v); +extern HIDDEN void __indirect_glWindowPos2iMESA(GLint x, GLint y); +extern HIDDEN void __indirect_glWindowPos2ivMESA(const GLint * v); +extern HIDDEN void __indirect_glWindowPos2sMESA(GLshort x, GLshort y); +extern HIDDEN void __indirect_glWindowPos2svMESA(const GLshort * v); +extern HIDDEN void __indirect_glWindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z); +extern HIDDEN void __indirect_glWindowPos3dvMESA(const GLdouble * v); +extern HIDDEN void __indirect_glWindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z); +extern HIDDEN void __indirect_glWindowPos3fvMESA(const GLfloat * v); +extern HIDDEN void __indirect_glWindowPos3iMESA(GLint x, GLint y, GLint z); +extern HIDDEN void __indirect_glWindowPos3ivMESA(const GLint * v); +extern HIDDEN void __indirect_glWindowPos3sMESA(GLshort x, GLshort y, GLshort z); +extern HIDDEN void __indirect_glWindowPos3svMESA(const GLshort * v); +extern HIDDEN GLboolean __indirect_glAreProgramsResidentNV(GLsizei n, const GLuint * ids, GLboolean * residences); +extern HIDDEN void __indirect_glBindProgramNV(GLenum target, GLuint program); +extern HIDDEN void __indirect_glDeleteProgramsNV(GLsizei n, const GLuint * programs); +extern HIDDEN void __indirect_glExecuteProgramNV(GLenum target, GLuint id, const GLfloat * params); +extern HIDDEN void __indirect_glGenProgramsNV(GLsizei n, GLuint * programs); +extern HIDDEN void __indirect_glGetProgramParameterdvNV(GLenum target, GLuint index, GLenum pname, GLdouble * params); +extern HIDDEN void __indirect_glGetProgramParameterfvNV(GLenum target, GLuint index, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetProgramStringNV(GLuint id, GLenum pname, GLubyte * program); +extern HIDDEN void __indirect_glGetProgramivNV(GLuint id, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid ** pointer); +extern HIDDEN void __indirect_glGetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble * params); +extern HIDDEN void __indirect_glGetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat * params); +extern HIDDEN void __indirect_glGetVertexAttribivNV(GLuint index, GLenum pname, GLint * params); +extern HIDDEN GLboolean __indirect_glIsProgramNV(GLuint program); +extern HIDDEN void __indirect_glLoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte * program); +extern HIDDEN void __indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble * params); +extern HIDDEN void __indirect_glProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, const GLfloat * params); +extern HIDDEN void __indirect_glRequestResidentProgramsNV(GLsizei n, const GLuint * ids); +extern HIDDEN void __indirect_glTrackMatrixNV(GLenum target, GLuint address, GLenum matrix, GLenum transform); +extern HIDDEN void __indirect_glVertexAttrib1dNV(GLuint index, GLdouble x); +extern HIDDEN void __indirect_glVertexAttrib1dvNV(GLuint index, const GLdouble * v); +extern HIDDEN void __indirect_glVertexAttrib1fNV(GLuint index, GLfloat x); +extern HIDDEN void __indirect_glVertexAttrib1fvNV(GLuint index, const GLfloat * v); +extern HIDDEN void __indirect_glVertexAttrib1sNV(GLuint index, GLshort x); +extern HIDDEN void __indirect_glVertexAttrib1svNV(GLuint index, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttrib2dNV(GLuint index, GLdouble x, GLdouble y); +extern HIDDEN void __indirect_glVertexAttrib2dvNV(GLuint index, const GLdouble * v); +extern HIDDEN void __indirect_glVertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y); +extern HIDDEN void __indirect_glVertexAttrib2fvNV(GLuint index, const GLfloat * v); +extern HIDDEN void __indirect_glVertexAttrib2sNV(GLuint index, GLshort x, GLshort y); +extern HIDDEN void __indirect_glVertexAttrib2svNV(GLuint index, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttrib3dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z); +extern HIDDEN void __indirect_glVertexAttrib3dvNV(GLuint index, const GLdouble * v); +extern HIDDEN void __indirect_glVertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z); +extern HIDDEN void __indirect_glVertexAttrib3fvNV(GLuint index, const GLfloat * v); +extern HIDDEN void __indirect_glVertexAttrib3sNV(GLuint index, GLshort x, GLshort y, GLshort z); +extern HIDDEN void __indirect_glVertexAttrib3svNV(GLuint index, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttrib4dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +extern HIDDEN void __indirect_glVertexAttrib4dvNV(GLuint index, const GLdouble * v); +extern HIDDEN void __indirect_glVertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +extern HIDDEN void __indirect_glVertexAttrib4fvNV(GLuint index, const GLfloat * v); +extern HIDDEN void __indirect_glVertexAttrib4sNV(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +extern HIDDEN void __indirect_glVertexAttrib4svNV(GLuint index, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttrib4ubNV(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +extern HIDDEN void __indirect_glVertexAttrib4ubvNV(GLuint index, const GLubyte * v); +extern HIDDEN void __indirect_glVertexAttribPointerNV(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); +extern HIDDEN void __indirect_glVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble * v); +extern HIDDEN void __indirect_glVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat * v); +extern HIDDEN void __indirect_glVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v); +extern HIDDEN void __indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v); +extern HIDDEN void __indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v); +extern HIDDEN void __indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v); +extern HIDDEN void __indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v); +extern HIDDEN void __indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v); +extern HIDDEN void __indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v); +extern HIDDEN void __indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte * v); +extern HIDDEN void __indirect_glPointParameteriNV(GLenum pname, GLint param); +extern HIDDEN void __indirect_glPointParameterivNV(GLenum pname, const GLint * params); +extern HIDDEN void __indirect_glActiveStencilFaceEXT(GLenum face); +extern HIDDEN void __indirect_glGetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble * params); +extern HIDDEN void __indirect_glGetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat * params); +extern HIDDEN void __indirect_glProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +extern HIDDEN void __indirect_glProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v); +extern HIDDEN void __indirect_glProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +extern HIDDEN void __indirect_glProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v); +extern HIDDEN void __indirect_glBlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA); +extern HIDDEN void __indirect_glBindFramebufferEXT(GLenum target, GLuint framebuffer); +extern HIDDEN void __indirect_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer); +extern HIDDEN GLenum __indirect_glCheckFramebufferStatusEXT(GLenum target); +extern HIDDEN void __indirect_glDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers); +extern HIDDEN void __indirect_glDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers); +extern HIDDEN void __indirect_glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +extern HIDDEN void __indirect_glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +extern HIDDEN void __indirect_glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +extern HIDDEN void __indirect_glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +extern HIDDEN void __indirect_glGenFramebuffersEXT(GLsizei n, GLuint * framebuffers); +extern HIDDEN void __indirect_glGenRenderbuffersEXT(GLsizei n, GLuint * renderbuffers); +extern HIDDEN void __indirect_glGenerateMipmapEXT(GLenum target); +extern HIDDEN void __indirect_glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint * params); +extern HIDDEN void __indirect_glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint * params); +extern HIDDEN GLboolean __indirect_glIsFramebufferEXT(GLuint framebuffer); +extern HIDDEN GLboolean __indirect_glIsRenderbufferEXT(GLuint renderbuffer); +extern HIDDEN void __indirect_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +extern HIDDEN void __indirect_glBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +extern HIDDEN void __indirect_glFramebufferTextureLayerEXT(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); + +# undef HIDDEN +# undef FASTCALL +# undef NOINLINE + +#endif /* !defined( _INDIRECT_H_ ) */ diff --git a/src/glx/indirect_init.c b/src/glx/indirect_init.c new file mode 100644 index 00000000000..73ca993027b --- /dev/null +++ b/src/glx/indirect_init.c @@ -0,0 +1,785 @@ +/* DO NOT EDIT - This file generated automatically by glX_proto_send.py (from Mesa) script */ + +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * (C) Copyright IBM Corporation 2004 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT, IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** + * \file indirect_init.c + * Initialize indirect rendering dispatch table. + * + * \author Kevin E. Martin + * \author Brian Paul + * \author Ian Romanick + */ + +#include "indirect_init.h" +#include "indirect.h" +#include "glapi.h" + + +/** + * No-op function used to initialize functions that have no GLX protocol + * support. + */ +static int NoOp(void) +{ + return 0; +} + +/** + * Create and initialize a new GL dispatch table. The table is initialized + * with GLX indirect rendering protocol functions. + */ +__GLapi * __glXNewIndirectAPI( void ) +{ + __GLapi *glAPI; + GLuint entries; + + entries = _glapi_get_dispatch_table_size(); + glAPI = (__GLapi *) Xmalloc(entries * sizeof(void *)); + + /* first, set all entries to point to no-op functions */ + { + int i; + void **dispatch = (void **) glAPI; + for (i = 0; i < entries; i++) { + dispatch[i] = (void *) NoOp; + } + } + + /* now, initialize the entries we understand */ + + /* 1.0 */ + + glAPI->Accum = __indirect_glAccum; + glAPI->AlphaFunc = __indirect_glAlphaFunc; + glAPI->Begin = __indirect_glBegin; + glAPI->Bitmap = __indirect_glBitmap; + glAPI->BlendFunc = __indirect_glBlendFunc; + glAPI->CallList = __indirect_glCallList; + glAPI->CallLists = __indirect_glCallLists; + glAPI->Clear = __indirect_glClear; + glAPI->ClearAccum = __indirect_glClearAccum; + glAPI->ClearColor = __indirect_glClearColor; + glAPI->ClearDepth = __indirect_glClearDepth; + glAPI->ClearIndex = __indirect_glClearIndex; + glAPI->ClearStencil = __indirect_glClearStencil; + glAPI->ClipPlane = __indirect_glClipPlane; + glAPI->Color3b = __indirect_glColor3b; + glAPI->Color3bv = __indirect_glColor3bv; + glAPI->Color3d = __indirect_glColor3d; + glAPI->Color3dv = __indirect_glColor3dv; + glAPI->Color3f = __indirect_glColor3f; + glAPI->Color3fv = __indirect_glColor3fv; + glAPI->Color3i = __indirect_glColor3i; + glAPI->Color3iv = __indirect_glColor3iv; + glAPI->Color3s = __indirect_glColor3s; + glAPI->Color3sv = __indirect_glColor3sv; + glAPI->Color3ub = __indirect_glColor3ub; + glAPI->Color3ubv = __indirect_glColor3ubv; + glAPI->Color3ui = __indirect_glColor3ui; + glAPI->Color3uiv = __indirect_glColor3uiv; + glAPI->Color3us = __indirect_glColor3us; + glAPI->Color3usv = __indirect_glColor3usv; + glAPI->Color4b = __indirect_glColor4b; + glAPI->Color4bv = __indirect_glColor4bv; + glAPI->Color4d = __indirect_glColor4d; + glAPI->Color4dv = __indirect_glColor4dv; + glAPI->Color4f = __indirect_glColor4f; + glAPI->Color4fv = __indirect_glColor4fv; + glAPI->Color4i = __indirect_glColor4i; + glAPI->Color4iv = __indirect_glColor4iv; + glAPI->Color4s = __indirect_glColor4s; + glAPI->Color4sv = __indirect_glColor4sv; + glAPI->Color4ub = __indirect_glColor4ub; + glAPI->Color4ubv = __indirect_glColor4ubv; + glAPI->Color4ui = __indirect_glColor4ui; + glAPI->Color4uiv = __indirect_glColor4uiv; + glAPI->Color4us = __indirect_glColor4us; + glAPI->Color4usv = __indirect_glColor4usv; + glAPI->ColorMask = __indirect_glColorMask; + glAPI->ColorMaterial = __indirect_glColorMaterial; + glAPI->CopyPixels = __indirect_glCopyPixels; + glAPI->CullFace = __indirect_glCullFace; + glAPI->DeleteLists = __indirect_glDeleteLists; + glAPI->DepthFunc = __indirect_glDepthFunc; + glAPI->DepthMask = __indirect_glDepthMask; + glAPI->DepthRange = __indirect_glDepthRange; + glAPI->Disable = __indirect_glDisable; + glAPI->DrawBuffer = __indirect_glDrawBuffer; + glAPI->DrawPixels = __indirect_glDrawPixels; + glAPI->EdgeFlag = __indirect_glEdgeFlag; + glAPI->EdgeFlagv = __indirect_glEdgeFlagv; + glAPI->Enable = __indirect_glEnable; + glAPI->End = __indirect_glEnd; + glAPI->EndList = __indirect_glEndList; + glAPI->EvalCoord1d = __indirect_glEvalCoord1d; + glAPI->EvalCoord1dv = __indirect_glEvalCoord1dv; + glAPI->EvalCoord1f = __indirect_glEvalCoord1f; + glAPI->EvalCoord1fv = __indirect_glEvalCoord1fv; + glAPI->EvalCoord2d = __indirect_glEvalCoord2d; + glAPI->EvalCoord2dv = __indirect_glEvalCoord2dv; + glAPI->EvalCoord2f = __indirect_glEvalCoord2f; + glAPI->EvalCoord2fv = __indirect_glEvalCoord2fv; + glAPI->EvalMesh1 = __indirect_glEvalMesh1; + glAPI->EvalMesh2 = __indirect_glEvalMesh2; + glAPI->EvalPoint1 = __indirect_glEvalPoint1; + glAPI->EvalPoint2 = __indirect_glEvalPoint2; + glAPI->FeedbackBuffer = __indirect_glFeedbackBuffer; + glAPI->Finish = __indirect_glFinish; + glAPI->Flush = __indirect_glFlush; + glAPI->Fogf = __indirect_glFogf; + glAPI->Fogfv = __indirect_glFogfv; + glAPI->Fogi = __indirect_glFogi; + glAPI->Fogiv = __indirect_glFogiv; + glAPI->FrontFace = __indirect_glFrontFace; + glAPI->Frustum = __indirect_glFrustum; + glAPI->GenLists = __indirect_glGenLists; + glAPI->GetBooleanv = __indirect_glGetBooleanv; + glAPI->GetClipPlane = __indirect_glGetClipPlane; + glAPI->GetDoublev = __indirect_glGetDoublev; + glAPI->GetError = __indirect_glGetError; + glAPI->GetFloatv = __indirect_glGetFloatv; + glAPI->GetIntegerv = __indirect_glGetIntegerv; + glAPI->GetLightfv = __indirect_glGetLightfv; + glAPI->GetLightiv = __indirect_glGetLightiv; + glAPI->GetMapdv = __indirect_glGetMapdv; + glAPI->GetMapfv = __indirect_glGetMapfv; + glAPI->GetMapiv = __indirect_glGetMapiv; + glAPI->GetMaterialfv = __indirect_glGetMaterialfv; + glAPI->GetMaterialiv = __indirect_glGetMaterialiv; + glAPI->GetPixelMapfv = __indirect_glGetPixelMapfv; + glAPI->GetPixelMapuiv = __indirect_glGetPixelMapuiv; + glAPI->GetPixelMapusv = __indirect_glGetPixelMapusv; + glAPI->GetPolygonStipple = __indirect_glGetPolygonStipple; + glAPI->GetString = __indirect_glGetString; + glAPI->GetTexEnvfv = __indirect_glGetTexEnvfv; + glAPI->GetTexEnviv = __indirect_glGetTexEnviv; + glAPI->GetTexGendv = __indirect_glGetTexGendv; + glAPI->GetTexGenfv = __indirect_glGetTexGenfv; + glAPI->GetTexGeniv = __indirect_glGetTexGeniv; + glAPI->GetTexImage = __indirect_glGetTexImage; + glAPI->GetTexLevelParameterfv = __indirect_glGetTexLevelParameterfv; + glAPI->GetTexLevelParameteriv = __indirect_glGetTexLevelParameteriv; + glAPI->GetTexParameterfv = __indirect_glGetTexParameterfv; + glAPI->GetTexParameteriv = __indirect_glGetTexParameteriv; + glAPI->Hint = __indirect_glHint; + glAPI->IndexMask = __indirect_glIndexMask; + glAPI->Indexd = __indirect_glIndexd; + glAPI->Indexdv = __indirect_glIndexdv; + glAPI->Indexf = __indirect_glIndexf; + glAPI->Indexfv = __indirect_glIndexfv; + glAPI->Indexi = __indirect_glIndexi; + glAPI->Indexiv = __indirect_glIndexiv; + glAPI->Indexs = __indirect_glIndexs; + glAPI->Indexsv = __indirect_glIndexsv; + glAPI->InitNames = __indirect_glInitNames; + glAPI->IsEnabled = __indirect_glIsEnabled; + glAPI->IsList = __indirect_glIsList; + glAPI->LightModelf = __indirect_glLightModelf; + glAPI->LightModelfv = __indirect_glLightModelfv; + glAPI->LightModeli = __indirect_glLightModeli; + glAPI->LightModeliv = __indirect_glLightModeliv; + glAPI->Lightf = __indirect_glLightf; + glAPI->Lightfv = __indirect_glLightfv; + glAPI->Lighti = __indirect_glLighti; + glAPI->Lightiv = __indirect_glLightiv; + glAPI->LineStipple = __indirect_glLineStipple; + glAPI->LineWidth = __indirect_glLineWidth; + glAPI->ListBase = __indirect_glListBase; + glAPI->LoadIdentity = __indirect_glLoadIdentity; + glAPI->LoadMatrixd = __indirect_glLoadMatrixd; + glAPI->LoadMatrixf = __indirect_glLoadMatrixf; + glAPI->LoadName = __indirect_glLoadName; + glAPI->LogicOp = __indirect_glLogicOp; + glAPI->Map1d = __indirect_glMap1d; + glAPI->Map1f = __indirect_glMap1f; + glAPI->Map2d = __indirect_glMap2d; + glAPI->Map2f = __indirect_glMap2f; + glAPI->MapGrid1d = __indirect_glMapGrid1d; + glAPI->MapGrid1f = __indirect_glMapGrid1f; + glAPI->MapGrid2d = __indirect_glMapGrid2d; + glAPI->MapGrid2f = __indirect_glMapGrid2f; + glAPI->Materialf = __indirect_glMaterialf; + glAPI->Materialfv = __indirect_glMaterialfv; + glAPI->Materiali = __indirect_glMateriali; + glAPI->Materialiv = __indirect_glMaterialiv; + glAPI->MatrixMode = __indirect_glMatrixMode; + glAPI->MultMatrixd = __indirect_glMultMatrixd; + glAPI->MultMatrixf = __indirect_glMultMatrixf; + glAPI->NewList = __indirect_glNewList; + glAPI->Normal3b = __indirect_glNormal3b; + glAPI->Normal3bv = __indirect_glNormal3bv; + glAPI->Normal3d = __indirect_glNormal3d; + glAPI->Normal3dv = __indirect_glNormal3dv; + glAPI->Normal3f = __indirect_glNormal3f; + glAPI->Normal3fv = __indirect_glNormal3fv; + glAPI->Normal3i = __indirect_glNormal3i; + glAPI->Normal3iv = __indirect_glNormal3iv; + glAPI->Normal3s = __indirect_glNormal3s; + glAPI->Normal3sv = __indirect_glNormal3sv; + glAPI->Ortho = __indirect_glOrtho; + glAPI->PassThrough = __indirect_glPassThrough; + glAPI->PixelMapfv = __indirect_glPixelMapfv; + glAPI->PixelMapuiv = __indirect_glPixelMapuiv; + glAPI->PixelMapusv = __indirect_glPixelMapusv; + glAPI->PixelStoref = __indirect_glPixelStoref; + glAPI->PixelStorei = __indirect_glPixelStorei; + glAPI->PixelTransferf = __indirect_glPixelTransferf; + glAPI->PixelTransferi = __indirect_glPixelTransferi; + glAPI->PixelZoom = __indirect_glPixelZoom; + glAPI->PointSize = __indirect_glPointSize; + glAPI->PolygonMode = __indirect_glPolygonMode; + glAPI->PolygonStipple = __indirect_glPolygonStipple; + glAPI->PopAttrib = __indirect_glPopAttrib; + glAPI->PopMatrix = __indirect_glPopMatrix; + glAPI->PopName = __indirect_glPopName; + glAPI->PushAttrib = __indirect_glPushAttrib; + glAPI->PushMatrix = __indirect_glPushMatrix; + glAPI->PushName = __indirect_glPushName; + glAPI->RasterPos2d = __indirect_glRasterPos2d; + glAPI->RasterPos2dv = __indirect_glRasterPos2dv; + glAPI->RasterPos2f = __indirect_glRasterPos2f; + glAPI->RasterPos2fv = __indirect_glRasterPos2fv; + glAPI->RasterPos2i = __indirect_glRasterPos2i; + glAPI->RasterPos2iv = __indirect_glRasterPos2iv; + glAPI->RasterPos2s = __indirect_glRasterPos2s; + glAPI->RasterPos2sv = __indirect_glRasterPos2sv; + glAPI->RasterPos3d = __indirect_glRasterPos3d; + glAPI->RasterPos3dv = __indirect_glRasterPos3dv; + glAPI->RasterPos3f = __indirect_glRasterPos3f; + glAPI->RasterPos3fv = __indirect_glRasterPos3fv; + glAPI->RasterPos3i = __indirect_glRasterPos3i; + glAPI->RasterPos3iv = __indirect_glRasterPos3iv; + glAPI->RasterPos3s = __indirect_glRasterPos3s; + glAPI->RasterPos3sv = __indirect_glRasterPos3sv; + glAPI->RasterPos4d = __indirect_glRasterPos4d; + glAPI->RasterPos4dv = __indirect_glRasterPos4dv; + glAPI->RasterPos4f = __indirect_glRasterPos4f; + glAPI->RasterPos4fv = __indirect_glRasterPos4fv; + glAPI->RasterPos4i = __indirect_glRasterPos4i; + glAPI->RasterPos4iv = __indirect_glRasterPos4iv; + glAPI->RasterPos4s = __indirect_glRasterPos4s; + glAPI->RasterPos4sv = __indirect_glRasterPos4sv; + glAPI->ReadBuffer = __indirect_glReadBuffer; + glAPI->ReadPixels = __indirect_glReadPixels; + glAPI->Rectd = __indirect_glRectd; + glAPI->Rectdv = __indirect_glRectdv; + glAPI->Rectf = __indirect_glRectf; + glAPI->Rectfv = __indirect_glRectfv; + glAPI->Recti = __indirect_glRecti; + glAPI->Rectiv = __indirect_glRectiv; + glAPI->Rects = __indirect_glRects; + glAPI->Rectsv = __indirect_glRectsv; + glAPI->RenderMode = __indirect_glRenderMode; + glAPI->Rotated = __indirect_glRotated; + glAPI->Rotatef = __indirect_glRotatef; + glAPI->Scaled = __indirect_glScaled; + glAPI->Scalef = __indirect_glScalef; + glAPI->Scissor = __indirect_glScissor; + glAPI->SelectBuffer = __indirect_glSelectBuffer; + glAPI->ShadeModel = __indirect_glShadeModel; + glAPI->StencilFunc = __indirect_glStencilFunc; + glAPI->StencilMask = __indirect_glStencilMask; + glAPI->StencilOp = __indirect_glStencilOp; + glAPI->TexCoord1d = __indirect_glTexCoord1d; + glAPI->TexCoord1dv = __indirect_glTexCoord1dv; + glAPI->TexCoord1f = __indirect_glTexCoord1f; + glAPI->TexCoord1fv = __indirect_glTexCoord1fv; + glAPI->TexCoord1i = __indirect_glTexCoord1i; + glAPI->TexCoord1iv = __indirect_glTexCoord1iv; + glAPI->TexCoord1s = __indirect_glTexCoord1s; + glAPI->TexCoord1sv = __indirect_glTexCoord1sv; + glAPI->TexCoord2d = __indirect_glTexCoord2d; + glAPI->TexCoord2dv = __indirect_glTexCoord2dv; + glAPI->TexCoord2f = __indirect_glTexCoord2f; + glAPI->TexCoord2fv = __indirect_glTexCoord2fv; + glAPI->TexCoord2i = __indirect_glTexCoord2i; + glAPI->TexCoord2iv = __indirect_glTexCoord2iv; + glAPI->TexCoord2s = __indirect_glTexCoord2s; + glAPI->TexCoord2sv = __indirect_glTexCoord2sv; + glAPI->TexCoord3d = __indirect_glTexCoord3d; + glAPI->TexCoord3dv = __indirect_glTexCoord3dv; + glAPI->TexCoord3f = __indirect_glTexCoord3f; + glAPI->TexCoord3fv = __indirect_glTexCoord3fv; + glAPI->TexCoord3i = __indirect_glTexCoord3i; + glAPI->TexCoord3iv = __indirect_glTexCoord3iv; + glAPI->TexCoord3s = __indirect_glTexCoord3s; + glAPI->TexCoord3sv = __indirect_glTexCoord3sv; + glAPI->TexCoord4d = __indirect_glTexCoord4d; + glAPI->TexCoord4dv = __indirect_glTexCoord4dv; + glAPI->TexCoord4f = __indirect_glTexCoord4f; + glAPI->TexCoord4fv = __indirect_glTexCoord4fv; + glAPI->TexCoord4i = __indirect_glTexCoord4i; + glAPI->TexCoord4iv = __indirect_glTexCoord4iv; + glAPI->TexCoord4s = __indirect_glTexCoord4s; + glAPI->TexCoord4sv = __indirect_glTexCoord4sv; + glAPI->TexEnvf = __indirect_glTexEnvf; + glAPI->TexEnvfv = __indirect_glTexEnvfv; + glAPI->TexEnvi = __indirect_glTexEnvi; + glAPI->TexEnviv = __indirect_glTexEnviv; + glAPI->TexGend = __indirect_glTexGend; + glAPI->TexGendv = __indirect_glTexGendv; + glAPI->TexGenf = __indirect_glTexGenf; + glAPI->TexGenfv = __indirect_glTexGenfv; + glAPI->TexGeni = __indirect_glTexGeni; + glAPI->TexGeniv = __indirect_glTexGeniv; + glAPI->TexImage1D = __indirect_glTexImage1D; + glAPI->TexImage2D = __indirect_glTexImage2D; + glAPI->TexParameterf = __indirect_glTexParameterf; + glAPI->TexParameterfv = __indirect_glTexParameterfv; + glAPI->TexParameteri = __indirect_glTexParameteri; + glAPI->TexParameteriv = __indirect_glTexParameteriv; + glAPI->Translated = __indirect_glTranslated; + glAPI->Translatef = __indirect_glTranslatef; + glAPI->Vertex2d = __indirect_glVertex2d; + glAPI->Vertex2dv = __indirect_glVertex2dv; + glAPI->Vertex2f = __indirect_glVertex2f; + glAPI->Vertex2fv = __indirect_glVertex2fv; + glAPI->Vertex2i = __indirect_glVertex2i; + glAPI->Vertex2iv = __indirect_glVertex2iv; + glAPI->Vertex2s = __indirect_glVertex2s; + glAPI->Vertex2sv = __indirect_glVertex2sv; + glAPI->Vertex3d = __indirect_glVertex3d; + glAPI->Vertex3dv = __indirect_glVertex3dv; + glAPI->Vertex3f = __indirect_glVertex3f; + glAPI->Vertex3fv = __indirect_glVertex3fv; + glAPI->Vertex3i = __indirect_glVertex3i; + glAPI->Vertex3iv = __indirect_glVertex3iv; + glAPI->Vertex3s = __indirect_glVertex3s; + glAPI->Vertex3sv = __indirect_glVertex3sv; + glAPI->Vertex4d = __indirect_glVertex4d; + glAPI->Vertex4dv = __indirect_glVertex4dv; + glAPI->Vertex4f = __indirect_glVertex4f; + glAPI->Vertex4fv = __indirect_glVertex4fv; + glAPI->Vertex4i = __indirect_glVertex4i; + glAPI->Vertex4iv = __indirect_glVertex4iv; + glAPI->Vertex4s = __indirect_glVertex4s; + glAPI->Vertex4sv = __indirect_glVertex4sv; + glAPI->Viewport = __indirect_glViewport; + + /* 1.1 */ + + glAPI->AreTexturesResident = __indirect_glAreTexturesResident; + glAPI->ArrayElement = __indirect_glArrayElement; + glAPI->BindTexture = __indirect_glBindTexture; + glAPI->ColorPointer = __indirect_glColorPointer; + glAPI->CopyTexImage1D = __indirect_glCopyTexImage1D; + glAPI->CopyTexImage2D = __indirect_glCopyTexImage2D; + glAPI->CopyTexSubImage1D = __indirect_glCopyTexSubImage1D; + glAPI->CopyTexSubImage2D = __indirect_glCopyTexSubImage2D; + glAPI->DeleteTextures = __indirect_glDeleteTextures; + glAPI->DisableClientState = __indirect_glDisableClientState; + glAPI->DrawArrays = __indirect_glDrawArrays; + glAPI->DrawElements = __indirect_glDrawElements; + glAPI->EdgeFlagPointer = __indirect_glEdgeFlagPointer; + glAPI->EnableClientState = __indirect_glEnableClientState; + glAPI->GenTextures = __indirect_glGenTextures; + glAPI->GetPointerv = __indirect_glGetPointerv; + glAPI->IndexPointer = __indirect_glIndexPointer; + glAPI->Indexub = __indirect_glIndexub; + glAPI->Indexubv = __indirect_glIndexubv; + glAPI->InterleavedArrays = __indirect_glInterleavedArrays; + glAPI->IsTexture = __indirect_glIsTexture; + glAPI->NormalPointer = __indirect_glNormalPointer; + glAPI->PolygonOffset = __indirect_glPolygonOffset; + glAPI->PopClientAttrib = __indirect_glPopClientAttrib; + glAPI->PrioritizeTextures = __indirect_glPrioritizeTextures; + glAPI->PushClientAttrib = __indirect_glPushClientAttrib; + glAPI->TexCoordPointer = __indirect_glTexCoordPointer; + glAPI->TexSubImage1D = __indirect_glTexSubImage1D; + glAPI->TexSubImage2D = __indirect_glTexSubImage2D; + glAPI->VertexPointer = __indirect_glVertexPointer; + + /* 1.2 */ + + glAPI->BlendColor = __indirect_glBlendColor; + glAPI->BlendEquation = __indirect_glBlendEquation; + glAPI->ColorSubTable = __indirect_glColorSubTable; + glAPI->ColorTable = __indirect_glColorTable; + glAPI->ColorTableParameterfv = __indirect_glColorTableParameterfv; + glAPI->ColorTableParameteriv = __indirect_glColorTableParameteriv; + glAPI->ConvolutionFilter1D = __indirect_glConvolutionFilter1D; + glAPI->ConvolutionFilter2D = __indirect_glConvolutionFilter2D; + glAPI->ConvolutionParameterf = __indirect_glConvolutionParameterf; + glAPI->ConvolutionParameterfv = __indirect_glConvolutionParameterfv; + glAPI->ConvolutionParameteri = __indirect_glConvolutionParameteri; + glAPI->ConvolutionParameteriv = __indirect_glConvolutionParameteriv; + glAPI->CopyColorSubTable = __indirect_glCopyColorSubTable; + glAPI->CopyColorTable = __indirect_glCopyColorTable; + glAPI->CopyConvolutionFilter1D = __indirect_glCopyConvolutionFilter1D; + glAPI->CopyConvolutionFilter2D = __indirect_glCopyConvolutionFilter2D; + glAPI->CopyTexSubImage3D = __indirect_glCopyTexSubImage3D; + glAPI->DrawRangeElements = __indirect_glDrawRangeElements; + glAPI->GetColorTable = __indirect_glGetColorTable; + glAPI->GetColorTableParameterfv = __indirect_glGetColorTableParameterfv; + glAPI->GetColorTableParameteriv = __indirect_glGetColorTableParameteriv; + glAPI->GetConvolutionFilter = __indirect_glGetConvolutionFilter; + glAPI->GetConvolutionParameterfv = __indirect_glGetConvolutionParameterfv; + glAPI->GetConvolutionParameteriv = __indirect_glGetConvolutionParameteriv; + glAPI->GetHistogram = __indirect_glGetHistogram; + glAPI->GetHistogramParameterfv = __indirect_glGetHistogramParameterfv; + glAPI->GetHistogramParameteriv = __indirect_glGetHistogramParameteriv; + glAPI->GetMinmax = __indirect_glGetMinmax; + glAPI->GetMinmaxParameterfv = __indirect_glGetMinmaxParameterfv; + glAPI->GetMinmaxParameteriv = __indirect_glGetMinmaxParameteriv; + glAPI->GetSeparableFilter = __indirect_glGetSeparableFilter; + glAPI->Histogram = __indirect_glHistogram; + glAPI->Minmax = __indirect_glMinmax; + glAPI->ResetHistogram = __indirect_glResetHistogram; + glAPI->ResetMinmax = __indirect_glResetMinmax; + glAPI->SeparableFilter2D = __indirect_glSeparableFilter2D; + glAPI->TexImage3D = __indirect_glTexImage3D; + glAPI->TexSubImage3D = __indirect_glTexSubImage3D; + + /* 1. GL_ARB_multitexture */ + + glAPI->ActiveTextureARB = __indirect_glActiveTextureARB; + glAPI->ClientActiveTextureARB = __indirect_glClientActiveTextureARB; + glAPI->MultiTexCoord1dARB = __indirect_glMultiTexCoord1dARB; + glAPI->MultiTexCoord1dvARB = __indirect_glMultiTexCoord1dvARB; + glAPI->MultiTexCoord1fARB = __indirect_glMultiTexCoord1fARB; + glAPI->MultiTexCoord1fvARB = __indirect_glMultiTexCoord1fvARB; + glAPI->MultiTexCoord1iARB = __indirect_glMultiTexCoord1iARB; + glAPI->MultiTexCoord1ivARB = __indirect_glMultiTexCoord1ivARB; + glAPI->MultiTexCoord1sARB = __indirect_glMultiTexCoord1sARB; + glAPI->MultiTexCoord1svARB = __indirect_glMultiTexCoord1svARB; + glAPI->MultiTexCoord2dARB = __indirect_glMultiTexCoord2dARB; + glAPI->MultiTexCoord2dvARB = __indirect_glMultiTexCoord2dvARB; + glAPI->MultiTexCoord2fARB = __indirect_glMultiTexCoord2fARB; + glAPI->MultiTexCoord2fvARB = __indirect_glMultiTexCoord2fvARB; + glAPI->MultiTexCoord2iARB = __indirect_glMultiTexCoord2iARB; + glAPI->MultiTexCoord2ivARB = __indirect_glMultiTexCoord2ivARB; + glAPI->MultiTexCoord2sARB = __indirect_glMultiTexCoord2sARB; + glAPI->MultiTexCoord2svARB = __indirect_glMultiTexCoord2svARB; + glAPI->MultiTexCoord3dARB = __indirect_glMultiTexCoord3dARB; + glAPI->MultiTexCoord3dvARB = __indirect_glMultiTexCoord3dvARB; + glAPI->MultiTexCoord3fARB = __indirect_glMultiTexCoord3fARB; + glAPI->MultiTexCoord3fvARB = __indirect_glMultiTexCoord3fvARB; + glAPI->MultiTexCoord3iARB = __indirect_glMultiTexCoord3iARB; + glAPI->MultiTexCoord3ivARB = __indirect_glMultiTexCoord3ivARB; + glAPI->MultiTexCoord3sARB = __indirect_glMultiTexCoord3sARB; + glAPI->MultiTexCoord3svARB = __indirect_glMultiTexCoord3svARB; + glAPI->MultiTexCoord4dARB = __indirect_glMultiTexCoord4dARB; + glAPI->MultiTexCoord4dvARB = __indirect_glMultiTexCoord4dvARB; + glAPI->MultiTexCoord4fARB = __indirect_glMultiTexCoord4fARB; + glAPI->MultiTexCoord4fvARB = __indirect_glMultiTexCoord4fvARB; + glAPI->MultiTexCoord4iARB = __indirect_glMultiTexCoord4iARB; + glAPI->MultiTexCoord4ivARB = __indirect_glMultiTexCoord4ivARB; + glAPI->MultiTexCoord4sARB = __indirect_glMultiTexCoord4sARB; + glAPI->MultiTexCoord4svARB = __indirect_glMultiTexCoord4svARB; + + /* 3. GL_ARB_transpose_matrix */ + + glAPI->LoadTransposeMatrixdARB = __indirect_glLoadTransposeMatrixdARB; + glAPI->LoadTransposeMatrixfARB = __indirect_glLoadTransposeMatrixfARB; + glAPI->MultTransposeMatrixdARB = __indirect_glMultTransposeMatrixdARB; + glAPI->MultTransposeMatrixfARB = __indirect_glMultTransposeMatrixfARB; + + /* 5. GL_ARB_multisample */ + + glAPI->SampleCoverageARB = __indirect_glSampleCoverageARB; + + /* 12. GL_ARB_texture_compression */ + + glAPI->CompressedTexImage1DARB = __indirect_glCompressedTexImage1DARB; + glAPI->CompressedTexImage2DARB = __indirect_glCompressedTexImage2DARB; + glAPI->CompressedTexImage3DARB = __indirect_glCompressedTexImage3DARB; + glAPI->CompressedTexSubImage1DARB = __indirect_glCompressedTexSubImage1DARB; + glAPI->CompressedTexSubImage2DARB = __indirect_glCompressedTexSubImage2DARB; + glAPI->CompressedTexSubImage3DARB = __indirect_glCompressedTexSubImage3DARB; + glAPI->GetCompressedTexImageARB = __indirect_glGetCompressedTexImageARB; + + /* 26. GL_ARB_vertex_program */ + + glAPI->DisableVertexAttribArrayARB = __indirect_glDisableVertexAttribArrayARB; + glAPI->EnableVertexAttribArrayARB = __indirect_glEnableVertexAttribArrayARB; + glAPI->GetProgramEnvParameterdvARB = __indirect_glGetProgramEnvParameterdvARB; + glAPI->GetProgramEnvParameterfvARB = __indirect_glGetProgramEnvParameterfvARB; + glAPI->GetProgramLocalParameterdvARB = __indirect_glGetProgramLocalParameterdvARB; + glAPI->GetProgramLocalParameterfvARB = __indirect_glGetProgramLocalParameterfvARB; + glAPI->GetProgramStringARB = __indirect_glGetProgramStringARB; + glAPI->GetProgramivARB = __indirect_glGetProgramivARB; + glAPI->GetVertexAttribdvARB = __indirect_glGetVertexAttribdvARB; + glAPI->GetVertexAttribfvARB = __indirect_glGetVertexAttribfvARB; + glAPI->GetVertexAttribivARB = __indirect_glGetVertexAttribivARB; + glAPI->ProgramEnvParameter4dARB = __indirect_glProgramEnvParameter4dARB; + glAPI->ProgramEnvParameter4dvARB = __indirect_glProgramEnvParameter4dvARB; + glAPI->ProgramEnvParameter4fARB = __indirect_glProgramEnvParameter4fARB; + glAPI->ProgramEnvParameter4fvARB = __indirect_glProgramEnvParameter4fvARB; + glAPI->ProgramLocalParameter4dARB = __indirect_glProgramLocalParameter4dARB; + glAPI->ProgramLocalParameter4dvARB = __indirect_glProgramLocalParameter4dvARB; + glAPI->ProgramLocalParameter4fARB = __indirect_glProgramLocalParameter4fARB; + glAPI->ProgramLocalParameter4fvARB = __indirect_glProgramLocalParameter4fvARB; + glAPI->ProgramStringARB = __indirect_glProgramStringARB; + glAPI->VertexAttrib1dARB = __indirect_glVertexAttrib1dARB; + glAPI->VertexAttrib1dvARB = __indirect_glVertexAttrib1dvARB; + glAPI->VertexAttrib1fARB = __indirect_glVertexAttrib1fARB; + glAPI->VertexAttrib1fvARB = __indirect_glVertexAttrib1fvARB; + glAPI->VertexAttrib1sARB = __indirect_glVertexAttrib1sARB; + glAPI->VertexAttrib1svARB = __indirect_glVertexAttrib1svARB; + glAPI->VertexAttrib2dARB = __indirect_glVertexAttrib2dARB; + glAPI->VertexAttrib2dvARB = __indirect_glVertexAttrib2dvARB; + glAPI->VertexAttrib2fARB = __indirect_glVertexAttrib2fARB; + glAPI->VertexAttrib2fvARB = __indirect_glVertexAttrib2fvARB; + glAPI->VertexAttrib2sARB = __indirect_glVertexAttrib2sARB; + glAPI->VertexAttrib2svARB = __indirect_glVertexAttrib2svARB; + glAPI->VertexAttrib3dARB = __indirect_glVertexAttrib3dARB; + glAPI->VertexAttrib3dvARB = __indirect_glVertexAttrib3dvARB; + glAPI->VertexAttrib3fARB = __indirect_glVertexAttrib3fARB; + glAPI->VertexAttrib3fvARB = __indirect_glVertexAttrib3fvARB; + glAPI->VertexAttrib3sARB = __indirect_glVertexAttrib3sARB; + glAPI->VertexAttrib3svARB = __indirect_glVertexAttrib3svARB; + glAPI->VertexAttrib4NbvARB = __indirect_glVertexAttrib4NbvARB; + glAPI->VertexAttrib4NivARB = __indirect_glVertexAttrib4NivARB; + glAPI->VertexAttrib4NsvARB = __indirect_glVertexAttrib4NsvARB; + glAPI->VertexAttrib4NubARB = __indirect_glVertexAttrib4NubARB; + glAPI->VertexAttrib4NubvARB = __indirect_glVertexAttrib4NubvARB; + glAPI->VertexAttrib4NuivARB = __indirect_glVertexAttrib4NuivARB; + glAPI->VertexAttrib4NusvARB = __indirect_glVertexAttrib4NusvARB; + glAPI->VertexAttrib4bvARB = __indirect_glVertexAttrib4bvARB; + glAPI->VertexAttrib4dARB = __indirect_glVertexAttrib4dARB; + glAPI->VertexAttrib4dvARB = __indirect_glVertexAttrib4dvARB; + glAPI->VertexAttrib4fARB = __indirect_glVertexAttrib4fARB; + glAPI->VertexAttrib4fvARB = __indirect_glVertexAttrib4fvARB; + glAPI->VertexAttrib4ivARB = __indirect_glVertexAttrib4ivARB; + glAPI->VertexAttrib4sARB = __indirect_glVertexAttrib4sARB; + glAPI->VertexAttrib4svARB = __indirect_glVertexAttrib4svARB; + glAPI->VertexAttrib4ubvARB = __indirect_glVertexAttrib4ubvARB; + glAPI->VertexAttrib4uivARB = __indirect_glVertexAttrib4uivARB; + glAPI->VertexAttrib4usvARB = __indirect_glVertexAttrib4usvARB; + glAPI->VertexAttribPointerARB = __indirect_glVertexAttribPointerARB; + + /* 29. GL_ARB_occlusion_query */ + + glAPI->BeginQueryARB = __indirect_glBeginQueryARB; + glAPI->DeleteQueriesARB = __indirect_glDeleteQueriesARB; + glAPI->EndQueryARB = __indirect_glEndQueryARB; + glAPI->GenQueriesARB = __indirect_glGenQueriesARB; + glAPI->GetQueryObjectivARB = __indirect_glGetQueryObjectivARB; + glAPI->GetQueryObjectuivARB = __indirect_glGetQueryObjectuivARB; + glAPI->GetQueryivARB = __indirect_glGetQueryivARB; + glAPI->IsQueryARB = __indirect_glIsQueryARB; + + /* 37. GL_ARB_draw_buffers */ + + glAPI->DrawBuffersARB = __indirect_glDrawBuffersARB; + + /* 45. GL_ARB_framebuffer_object */ + + glAPI->RenderbufferStorageMultisample = __indirect_glRenderbufferStorageMultisample; + + /* 25. GL_SGIS_multisample */ + + glAPI->SampleMaskSGIS = __indirect_glSampleMaskSGIS; + glAPI->SamplePatternSGIS = __indirect_glSamplePatternSGIS; + + /* 30. GL_EXT_vertex_array */ + + glAPI->ColorPointerEXT = __indirect_glColorPointerEXT; + glAPI->EdgeFlagPointerEXT = __indirect_glEdgeFlagPointerEXT; + glAPI->IndexPointerEXT = __indirect_glIndexPointerEXT; + glAPI->NormalPointerEXT = __indirect_glNormalPointerEXT; + glAPI->TexCoordPointerEXT = __indirect_glTexCoordPointerEXT; + glAPI->VertexPointerEXT = __indirect_glVertexPointerEXT; + + /* 54. GL_EXT_point_parameters */ + + glAPI->PointParameterfEXT = __indirect_glPointParameterfEXT; + glAPI->PointParameterfvEXT = __indirect_glPointParameterfvEXT; + + /* 145. GL_EXT_secondary_color */ + + glAPI->SecondaryColor3bEXT = __indirect_glSecondaryColor3bEXT; + glAPI->SecondaryColor3bvEXT = __indirect_glSecondaryColor3bvEXT; + glAPI->SecondaryColor3dEXT = __indirect_glSecondaryColor3dEXT; + glAPI->SecondaryColor3dvEXT = __indirect_glSecondaryColor3dvEXT; + glAPI->SecondaryColor3fEXT = __indirect_glSecondaryColor3fEXT; + glAPI->SecondaryColor3fvEXT = __indirect_glSecondaryColor3fvEXT; + glAPI->SecondaryColor3iEXT = __indirect_glSecondaryColor3iEXT; + glAPI->SecondaryColor3ivEXT = __indirect_glSecondaryColor3ivEXT; + glAPI->SecondaryColor3sEXT = __indirect_glSecondaryColor3sEXT; + glAPI->SecondaryColor3svEXT = __indirect_glSecondaryColor3svEXT; + glAPI->SecondaryColor3ubEXT = __indirect_glSecondaryColor3ubEXT; + glAPI->SecondaryColor3ubvEXT = __indirect_glSecondaryColor3ubvEXT; + glAPI->SecondaryColor3uiEXT = __indirect_glSecondaryColor3uiEXT; + glAPI->SecondaryColor3uivEXT = __indirect_glSecondaryColor3uivEXT; + glAPI->SecondaryColor3usEXT = __indirect_glSecondaryColor3usEXT; + glAPI->SecondaryColor3usvEXT = __indirect_glSecondaryColor3usvEXT; + glAPI->SecondaryColorPointerEXT = __indirect_glSecondaryColorPointerEXT; + + /* 148. GL_EXT_multi_draw_arrays */ + + glAPI->MultiDrawArraysEXT = __indirect_glMultiDrawArraysEXT; + glAPI->MultiDrawElementsEXT = __indirect_glMultiDrawElementsEXT; + + /* 149. GL_EXT_fog_coord */ + + glAPI->FogCoordPointerEXT = __indirect_glFogCoordPointerEXT; + glAPI->FogCoorddEXT = __indirect_glFogCoorddEXT; + glAPI->FogCoorddvEXT = __indirect_glFogCoorddvEXT; + glAPI->FogCoordfEXT = __indirect_glFogCoordfEXT; + glAPI->FogCoordfvEXT = __indirect_glFogCoordfvEXT; + + /* 173. GL_EXT_blend_func_separate */ + + glAPI->BlendFuncSeparateEXT = __indirect_glBlendFuncSeparateEXT; + + /* 197. GL_MESA_window_pos */ + + glAPI->WindowPos2dMESA = __indirect_glWindowPos2dMESA; + glAPI->WindowPos2dvMESA = __indirect_glWindowPos2dvMESA; + glAPI->WindowPos2fMESA = __indirect_glWindowPos2fMESA; + glAPI->WindowPos2fvMESA = __indirect_glWindowPos2fvMESA; + glAPI->WindowPos2iMESA = __indirect_glWindowPos2iMESA; + glAPI->WindowPos2ivMESA = __indirect_glWindowPos2ivMESA; + glAPI->WindowPos2sMESA = __indirect_glWindowPos2sMESA; + glAPI->WindowPos2svMESA = __indirect_glWindowPos2svMESA; + glAPI->WindowPos3dMESA = __indirect_glWindowPos3dMESA; + glAPI->WindowPos3dvMESA = __indirect_glWindowPos3dvMESA; + glAPI->WindowPos3fMESA = __indirect_glWindowPos3fMESA; + glAPI->WindowPos3fvMESA = __indirect_glWindowPos3fvMESA; + glAPI->WindowPos3iMESA = __indirect_glWindowPos3iMESA; + glAPI->WindowPos3ivMESA = __indirect_glWindowPos3ivMESA; + glAPI->WindowPos3sMESA = __indirect_glWindowPos3sMESA; + glAPI->WindowPos3svMESA = __indirect_glWindowPos3svMESA; + + /* 233. GL_NV_vertex_program */ + + glAPI->AreProgramsResidentNV = __indirect_glAreProgramsResidentNV; + glAPI->BindProgramNV = __indirect_glBindProgramNV; + glAPI->DeleteProgramsNV = __indirect_glDeleteProgramsNV; + glAPI->ExecuteProgramNV = __indirect_glExecuteProgramNV; + glAPI->GenProgramsNV = __indirect_glGenProgramsNV; + glAPI->GetProgramParameterdvNV = __indirect_glGetProgramParameterdvNV; + glAPI->GetProgramParameterfvNV = __indirect_glGetProgramParameterfvNV; + glAPI->GetProgramStringNV = __indirect_glGetProgramStringNV; + glAPI->GetProgramivNV = __indirect_glGetProgramivNV; + glAPI->GetTrackMatrixivNV = __indirect_glGetTrackMatrixivNV; + glAPI->GetVertexAttribPointervNV = __indirect_glGetVertexAttribPointervNV; + glAPI->GetVertexAttribdvNV = __indirect_glGetVertexAttribdvNV; + glAPI->GetVertexAttribfvNV = __indirect_glGetVertexAttribfvNV; + glAPI->GetVertexAttribivNV = __indirect_glGetVertexAttribivNV; + glAPI->IsProgramNV = __indirect_glIsProgramNV; + glAPI->LoadProgramNV = __indirect_glLoadProgramNV; + glAPI->ProgramParameters4dvNV = __indirect_glProgramParameters4dvNV; + glAPI->ProgramParameters4fvNV = __indirect_glProgramParameters4fvNV; + glAPI->RequestResidentProgramsNV = __indirect_glRequestResidentProgramsNV; + glAPI->TrackMatrixNV = __indirect_glTrackMatrixNV; + glAPI->VertexAttrib1dNV = __indirect_glVertexAttrib1dNV; + glAPI->VertexAttrib1dvNV = __indirect_glVertexAttrib1dvNV; + glAPI->VertexAttrib1fNV = __indirect_glVertexAttrib1fNV; + glAPI->VertexAttrib1fvNV = __indirect_glVertexAttrib1fvNV; + glAPI->VertexAttrib1sNV = __indirect_glVertexAttrib1sNV; + glAPI->VertexAttrib1svNV = __indirect_glVertexAttrib1svNV; + glAPI->VertexAttrib2dNV = __indirect_glVertexAttrib2dNV; + glAPI->VertexAttrib2dvNV = __indirect_glVertexAttrib2dvNV; + glAPI->VertexAttrib2fNV = __indirect_glVertexAttrib2fNV; + glAPI->VertexAttrib2fvNV = __indirect_glVertexAttrib2fvNV; + glAPI->VertexAttrib2sNV = __indirect_glVertexAttrib2sNV; + glAPI->VertexAttrib2svNV = __indirect_glVertexAttrib2svNV; + glAPI->VertexAttrib3dNV = __indirect_glVertexAttrib3dNV; + glAPI->VertexAttrib3dvNV = __indirect_glVertexAttrib3dvNV; + glAPI->VertexAttrib3fNV = __indirect_glVertexAttrib3fNV; + glAPI->VertexAttrib3fvNV = __indirect_glVertexAttrib3fvNV; + glAPI->VertexAttrib3sNV = __indirect_glVertexAttrib3sNV; + glAPI->VertexAttrib3svNV = __indirect_glVertexAttrib3svNV; + glAPI->VertexAttrib4dNV = __indirect_glVertexAttrib4dNV; + glAPI->VertexAttrib4dvNV = __indirect_glVertexAttrib4dvNV; + glAPI->VertexAttrib4fNV = __indirect_glVertexAttrib4fNV; + glAPI->VertexAttrib4fvNV = __indirect_glVertexAttrib4fvNV; + glAPI->VertexAttrib4sNV = __indirect_glVertexAttrib4sNV; + glAPI->VertexAttrib4svNV = __indirect_glVertexAttrib4svNV; + glAPI->VertexAttrib4ubNV = __indirect_glVertexAttrib4ubNV; + glAPI->VertexAttrib4ubvNV = __indirect_glVertexAttrib4ubvNV; + glAPI->VertexAttribPointerNV = __indirect_glVertexAttribPointerNV; + glAPI->VertexAttribs1dvNV = __indirect_glVertexAttribs1dvNV; + glAPI->VertexAttribs1fvNV = __indirect_glVertexAttribs1fvNV; + glAPI->VertexAttribs1svNV = __indirect_glVertexAttribs1svNV; + glAPI->VertexAttribs2dvNV = __indirect_glVertexAttribs2dvNV; + glAPI->VertexAttribs2fvNV = __indirect_glVertexAttribs2fvNV; + glAPI->VertexAttribs2svNV = __indirect_glVertexAttribs2svNV; + glAPI->VertexAttribs3dvNV = __indirect_glVertexAttribs3dvNV; + glAPI->VertexAttribs3fvNV = __indirect_glVertexAttribs3fvNV; + glAPI->VertexAttribs3svNV = __indirect_glVertexAttribs3svNV; + glAPI->VertexAttribs4dvNV = __indirect_glVertexAttribs4dvNV; + glAPI->VertexAttribs4fvNV = __indirect_glVertexAttribs4fvNV; + glAPI->VertexAttribs4svNV = __indirect_glVertexAttribs4svNV; + glAPI->VertexAttribs4ubvNV = __indirect_glVertexAttribs4ubvNV; + + /* 262. GL_NV_point_sprite */ + + glAPI->PointParameteriNV = __indirect_glPointParameteriNV; + glAPI->PointParameterivNV = __indirect_glPointParameterivNV; + + /* 268. GL_EXT_stencil_two_side */ + + glAPI->ActiveStencilFaceEXT = __indirect_glActiveStencilFaceEXT; + + /* 282. GL_NV_fragment_program */ + + glAPI->GetProgramNamedParameterdvNV = __indirect_glGetProgramNamedParameterdvNV; + glAPI->GetProgramNamedParameterfvNV = __indirect_glGetProgramNamedParameterfvNV; + glAPI->ProgramNamedParameter4dNV = __indirect_glProgramNamedParameter4dNV; + glAPI->ProgramNamedParameter4dvNV = __indirect_glProgramNamedParameter4dvNV; + glAPI->ProgramNamedParameter4fNV = __indirect_glProgramNamedParameter4fNV; + glAPI->ProgramNamedParameter4fvNV = __indirect_glProgramNamedParameter4fvNV; + + /* 299. GL_EXT_blend_equation_separate */ + + glAPI->BlendEquationSeparateEXT = __indirect_glBlendEquationSeparateEXT; + + /* 310. GL_EXT_framebuffer_object */ + + glAPI->BindFramebufferEXT = __indirect_glBindFramebufferEXT; + glAPI->BindRenderbufferEXT = __indirect_glBindRenderbufferEXT; + glAPI->CheckFramebufferStatusEXT = __indirect_glCheckFramebufferStatusEXT; + glAPI->DeleteFramebuffersEXT = __indirect_glDeleteFramebuffersEXT; + glAPI->DeleteRenderbuffersEXT = __indirect_glDeleteRenderbuffersEXT; + glAPI->FramebufferRenderbufferEXT = __indirect_glFramebufferRenderbufferEXT; + glAPI->FramebufferTexture1DEXT = __indirect_glFramebufferTexture1DEXT; + glAPI->FramebufferTexture2DEXT = __indirect_glFramebufferTexture2DEXT; + glAPI->FramebufferTexture3DEXT = __indirect_glFramebufferTexture3DEXT; + glAPI->GenFramebuffersEXT = __indirect_glGenFramebuffersEXT; + glAPI->GenRenderbuffersEXT = __indirect_glGenRenderbuffersEXT; + glAPI->GenerateMipmapEXT = __indirect_glGenerateMipmapEXT; + glAPI->GetFramebufferAttachmentParameterivEXT = __indirect_glGetFramebufferAttachmentParameterivEXT; + glAPI->GetRenderbufferParameterivEXT = __indirect_glGetRenderbufferParameterivEXT; + glAPI->IsFramebufferEXT = __indirect_glIsFramebufferEXT; + glAPI->IsRenderbufferEXT = __indirect_glIsRenderbufferEXT; + glAPI->RenderbufferStorageEXT = __indirect_glRenderbufferStorageEXT; + + /* 316. GL_EXT_framebuffer_blit */ + + glAPI->BlitFramebufferEXT = __indirect_glBlitFramebufferEXT; + + /* 329. GL_EXT_texture_array */ + + glAPI->FramebufferTextureLayerEXT = __indirect_glFramebufferTextureLayerEXT; + + return glAPI; +} + diff --git a/src/glx/indirect_init.h b/src/glx/indirect_init.h new file mode 100644 index 00000000000..72255f13014 --- /dev/null +++ b/src/glx/indirect_init.h @@ -0,0 +1,41 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin + * + */ + +#ifndef _INDIRECT_INIT_H_ +#define _INDIRECT_INIT_H_ + +#include "glxclient.h" + +extern __GLapi *__glXNewIndirectAPI(void); + +#endif /* _INDIRECT_INIT_H_ */ diff --git a/src/glx/indirect_size.c b/src/glx/indirect_size.c new file mode 100644 index 00000000000..6356ddd49b5 --- /dev/null +++ b/src/glx/indirect_size.c @@ -0,0 +1,388 @@ +/* DO NOT EDIT - This file generated automatically by glX_proto_size.py (from Mesa) script */ + +/* + * (C) Copyright IBM Corporation 2004 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + + +#include +#include "indirect_size.h" + +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define PURE __attribute__((pure)) +# else +# define PURE +# endif + +# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) +# define FASTCALL __attribute__((fastcall)) +# else +# define FASTCALL +# endif + +# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) && defined(__ELF__) +# define INTERNAL __attribute__((visibility("internal"))) +# else +# define INTERNAL +# endif + + +#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__) +# undef HAVE_ALIAS +#endif +#ifdef HAVE_ALIAS +# define ALIAS2(from,to) \ + INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \ + __attribute__ ((alias( # to ))); +# define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size ) +#else +# define ALIAS(from,to) \ + INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \ + { return __gl ## to ## _size( e ); } +#endif + + +INTERNAL PURE FASTCALL GLint +__glCallLists_size(GLenum e) +{ + switch (e) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + return 1; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_2_BYTES: + case GL_HALF_FLOAT: + return 2; + case GL_3_BYTES: + return 3; + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_4_BYTES: + return 4; + default: + return 0; + } +} + +INTERNAL PURE FASTCALL GLint +__glFogfv_size(GLenum e) +{ + switch (e) { + case GL_FOG_INDEX: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_FOG_MODE: + case GL_FOG_OFFSET_VALUE_SGIX: + case GL_FOG_DISTANCE_MODE_NV: + return 1; + case GL_FOG_COLOR: + return 4; + default: + return 0; + } +} + +INTERNAL PURE FASTCALL GLint +__glLightfv_size(GLenum e) +{ + switch (e) { + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + return 1; + case GL_SPOT_DIRECTION: + return 3; + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_POSITION: + return 4; + default: + return 0; + } +} + +INTERNAL PURE FASTCALL GLint +__glLightModelfv_size(GLenum e) +{ + switch (e) { + case GL_LIGHT_MODEL_LOCAL_VIEWER: + case GL_LIGHT_MODEL_TWO_SIDE: + case GL_LIGHT_MODEL_COLOR_CONTROL: +/* case GL_LIGHT_MODEL_COLOR_CONTROL_EXT:*/ + return 1; + case GL_LIGHT_MODEL_AMBIENT: + return 4; + default: + return 0; + } +} + +INTERNAL PURE FASTCALL GLint +__glMaterialfv_size(GLenum e) +{ + switch (e) { + case GL_SHININESS: + return 1; + case GL_COLOR_INDEXES: + return 3; + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_EMISSION: + case GL_AMBIENT_AND_DIFFUSE: + return 4; + default: + return 0; + } +} + +INTERNAL PURE FASTCALL GLint +__glTexParameterfv_size(GLenum e) +{ + switch (e) { + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_TEXTURE_PRIORITY: + case GL_TEXTURE_WRAP_R: + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: +/* case GL_SHADOW_AMBIENT_SGIX:*/ + case GL_TEXTURE_MIN_LOD: + case GL_TEXTURE_MAX_LOD: + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: + case GL_TEXTURE_CLIPMAP_FRAME_SGIX: + case GL_TEXTURE_LOD_BIAS_S_SGIX: + case GL_TEXTURE_LOD_BIAS_T_SGIX: + case GL_TEXTURE_LOD_BIAS_R_SGIX: + case GL_GENERATE_MIPMAP: +/* case GL_GENERATE_MIPMAP_SGIS:*/ + case GL_TEXTURE_COMPARE_SGIX: + case GL_TEXTURE_COMPARE_OPERATOR_SGIX: + case GL_TEXTURE_MAX_CLAMP_S_SGIX: + case GL_TEXTURE_MAX_CLAMP_T_SGIX: + case GL_TEXTURE_MAX_CLAMP_R_SGIX: + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + case GL_TEXTURE_LOD_BIAS: +/* case GL_TEXTURE_LOD_BIAS_EXT:*/ + case GL_TEXTURE_STORAGE_HINT_APPLE: + case GL_STORAGE_PRIVATE_APPLE: + case GL_STORAGE_CACHED_APPLE: + case GL_STORAGE_SHARED_APPLE: + case GL_DEPTH_TEXTURE_MODE: +/* case GL_DEPTH_TEXTURE_MODE_ARB:*/ + case GL_TEXTURE_COMPARE_MODE: +/* case GL_TEXTURE_COMPARE_MODE_ARB:*/ + case GL_TEXTURE_COMPARE_FUNC: +/* case GL_TEXTURE_COMPARE_FUNC_ARB:*/ + case GL_TEXTURE_UNSIGNED_REMAP_MODE_NV: + return 1; + case GL_TEXTURE_CLIPMAP_CENTER_SGIX: + case GL_TEXTURE_CLIPMAP_OFFSET_SGIX: + return 2; + case GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX: + return 3; + case GL_TEXTURE_BORDER_COLOR: + case GL_POST_TEXTURE_FILTER_BIAS_SGIX: + case GL_POST_TEXTURE_FILTER_SCALE_SGIX: + return 4; + default: + return 0; + } +} + +INTERNAL PURE FASTCALL GLint +__glTexEnvfv_size(GLenum e) +{ + switch (e) { + case GL_ALPHA_SCALE: + case GL_TEXTURE_ENV_MODE: + case GL_TEXTURE_LOD_BIAS: + case GL_COMBINE_RGB: + case GL_COMBINE_ALPHA: + case GL_RGB_SCALE: + case GL_SOURCE0_RGB: + case GL_SOURCE1_RGB: + case GL_SOURCE2_RGB: + case GL_SOURCE3_RGB_NV: + case GL_SOURCE0_ALPHA: + case GL_SOURCE1_ALPHA: + case GL_SOURCE2_ALPHA: + case GL_SOURCE3_ALPHA_NV: + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + case GL_OPERAND3_RGB_NV: + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + case GL_OPERAND3_ALPHA_NV: + case GL_BUMP_TARGET_ATI: + case GL_COORD_REPLACE_ARB: +/* case GL_COORD_REPLACE_NV:*/ + return 1; + case GL_TEXTURE_ENV_COLOR: + return 4; + default: + return 0; + } +} + +INTERNAL PURE FASTCALL GLint +__glTexGendv_size(GLenum e) +{ + switch (e) { + case GL_TEXTURE_GEN_MODE: + return 1; + case GL_OBJECT_PLANE: + case GL_EYE_PLANE: + return 4; + default: + return 0; + } +} + +INTERNAL PURE FASTCALL GLint +__glMap1d_size(GLenum e) +{ + switch (e) { + case GL_MAP1_INDEX: + case GL_MAP1_TEXTURE_COORD_1: + return 1; + case GL_MAP1_TEXTURE_COORD_2: + return 2; + case GL_MAP1_NORMAL: + case GL_MAP1_TEXTURE_COORD_3: + case GL_MAP1_VERTEX_3: + return 3; + case GL_MAP1_COLOR_4: + case GL_MAP1_TEXTURE_COORD_4: + case GL_MAP1_VERTEX_4: + return 4; + default: + return 0; + } +} + +INTERNAL PURE FASTCALL GLint +__glMap2d_size(GLenum e) +{ + switch (e) { + case GL_MAP2_INDEX: + case GL_MAP2_TEXTURE_COORD_1: + return 1; + case GL_MAP2_TEXTURE_COORD_2: + return 2; + case GL_MAP2_NORMAL: + case GL_MAP2_TEXTURE_COORD_3: + case GL_MAP2_VERTEX_3: + return 3; + case GL_MAP2_COLOR_4: + case GL_MAP2_TEXTURE_COORD_4: + case GL_MAP2_VERTEX_4: + return 4; + default: + return 0; + } +} + +INTERNAL PURE FASTCALL GLint +__glColorTableParameterfv_size(GLenum e) +{ + switch (e) { + case GL_COLOR_TABLE_SCALE: + case GL_COLOR_TABLE_BIAS: + return 4; + default: + return 0; + } +} + +INTERNAL PURE FASTCALL GLint +__glConvolutionParameterfv_size(GLenum e) +{ + switch (e) { + case GL_CONVOLUTION_BORDER_MODE: +/* case GL_CONVOLUTION_BORDER_MODE_EXT:*/ + return 1; + case GL_CONVOLUTION_FILTER_SCALE: +/* case GL_CONVOLUTION_FILTER_SCALE_EXT:*/ + case GL_CONVOLUTION_FILTER_BIAS: +/* case GL_CONVOLUTION_FILTER_BIAS_EXT:*/ + case GL_CONVOLUTION_BORDER_COLOR: +/* case GL_CONVOLUTION_BORDER_COLOR_HP:*/ + return 4; + default: + return 0; + } +} + +INTERNAL PURE FASTCALL GLint +__glPointParameterfvEXT_size(GLenum e) +{ + switch (e) { + case GL_POINT_SIZE_MIN: +/* case GL_POINT_SIZE_MIN_ARB:*/ +/* case GL_POINT_SIZE_MIN_SGIS:*/ + case GL_POINT_SIZE_MAX: +/* case GL_POINT_SIZE_MAX_ARB:*/ +/* case GL_POINT_SIZE_MAX_SGIS:*/ + case GL_POINT_FADE_THRESHOLD_SIZE: +/* case GL_POINT_FADE_THRESHOLD_SIZE_ARB:*/ +/* case GL_POINT_FADE_THRESHOLD_SIZE_SGIS:*/ + case GL_POINT_SPRITE_R_MODE_NV: + case GL_POINT_SPRITE_COORD_ORIGIN: + return 1; + case GL_POINT_DISTANCE_ATTENUATION: +/* case GL_POINT_DISTANCE_ATTENUATION_ARB:*/ +/* case GL_POINT_DISTANCE_ATTENUATION_SGIS:*/ + return 3; + default: + return 0; + } +} + +ALIAS(Fogiv, Fogfv) + ALIAS(Lightiv, Lightfv) + ALIAS(LightModeliv, LightModelfv) + ALIAS(Materialiv, Materialfv) + ALIAS(TexParameteriv, TexParameterfv) + ALIAS(TexEnviv, TexEnvfv) + ALIAS(TexGenfv, TexGendv) + ALIAS(TexGeniv, TexGendv) + ALIAS(Map1f, Map1d) + ALIAS(Map2f, Map2d) + ALIAS(ColorTableParameteriv, ColorTableParameterfv) + ALIAS(ConvolutionParameteriv, ConvolutionParameterfv) + ALIAS(PointParameterivNV, PointParameterfvEXT) +# undef PURE +# undef FASTCALL +# undef INTERNAL diff --git a/src/glx/indirect_size.h b/src/glx/indirect_size.h new file mode 100644 index 00000000000..af0919f9645 --- /dev/null +++ b/src/glx/indirect_size.h @@ -0,0 +1,88 @@ +/* DO NOT EDIT - This file generated automatically by glX_proto_size.py (from Mesa) script */ + +/* + * (C) Copyright IBM Corporation 2004 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#if !defined( _INDIRECT_SIZE_H_ ) +# define _INDIRECT_SIZE_H_ + +/** + * \file + * Prototypes for functions used to determine the number of data elements in + * various GLX protocol messages. + * + * \author Ian Romanick + */ + +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define PURE __attribute__((pure)) +# else +# define PURE +# endif + +# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) +# define FASTCALL __attribute__((fastcall)) +# else +# define FASTCALL +# endif + +# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) && defined(__ELF__) +# define INTERNAL __attribute__((visibility("internal"))) +# else +# define INTERNAL +# endif + +extern INTERNAL PURE FASTCALL GLint __glCallLists_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glFogfv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glFogiv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glLightfv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glLightiv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glLightModelfv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glLightModeliv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glMaterialfv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glMaterialiv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glTexParameterfv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glTexParameteriv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glTexEnvfv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glTexEnviv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glTexGendv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glTexGenfv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glTexGeniv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glMap1d_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glMap1f_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glMap2d_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glMap2f_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glColorTableParameterfv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glColorTableParameteriv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glConvolutionParameterfv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glConvolutionParameteriv_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glPointParameterfvEXT_size(GLenum); +extern INTERNAL PURE FASTCALL GLint __glPointParameterivNV_size(GLenum); + +# undef PURE +# undef FASTCALL +# undef INTERNAL + +#endif /* !defined( _INDIRECT_SIZE_H_ ) */ diff --git a/src/glx/indirect_texture_compression.c b/src/glx/indirect_texture_compression.c new file mode 100644 index 00000000000..fa927ebdf68 --- /dev/null +++ b/src/glx/indirect_texture_compression.c @@ -0,0 +1,343 @@ +/* + * (C) Copyright IBM Corporation 2004 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file glx_texture_compression.c + * Contains the routines required to implement GLX protocol for + * ARB_texture_compression and related extensions. + * + * \sa http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_compression.txt + * + * \author Ian Romanick + */ + +#include "packrender.h" +#include "packsingle.h" +#include "indirect.h" + +#include + + +void +__indirect_glGetCompressedTexImageARB(GLenum target, GLint level, + GLvoid * img) +{ + __GLX_SINGLE_DECLARE_VARIABLES(); + xGLXGetTexImageReply reply; + size_t image_bytes; + + __GLX_SINGLE_LOAD_VARIABLES(); + __GLX_SINGLE_BEGIN(X_GLsop_GetCompressedTexImage, 8); + __GLX_SINGLE_PUT_LONG(0, target); + __GLX_SINGLE_PUT_LONG(4, level); + __GLX_SINGLE_READ_XREPLY(); + + image_bytes = reply.width; + assert(image_bytes <= ((4 * reply.length) - 0)); + assert(image_bytes >= ((4 * reply.length) - 3)); + + if (image_bytes != 0) { + _XRead(dpy, (char *) img, image_bytes); + if (image_bytes < (4 * reply.length)) { + _XEatData(dpy, (4 * reply.length) - image_bytes); + } + } + + __GLX_SINGLE_END(); +} + + +/** + * Internal function used for \c glCompressedTexImage1D and + * \c glCompressedTexImage2D. + */ +static void +CompressedTexImage1D2D(GLenum target, GLint level, + GLenum internal_format, + GLsizei width, GLsizei height, + GLint border, GLsizei image_size, + const GLvoid * data, CARD32 rop) +{ + __GLX_DECLARE_VARIABLES(); + + __GLX_LOAD_VARIABLES(); + if (gc->currentDpy == NULL) { + return; + } + + if ((target == GL_PROXY_TEXTURE_1D) + || (target == GL_PROXY_TEXTURE_2D) + || (target == GL_PROXY_TEXTURE_CUBE_MAP)) { + compsize = 0; + } + else { + compsize = image_size; + } + + cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE + compsize); + if (cmdlen <= gc->maxSmallRenderCommandSize) { + __GLX_BEGIN_VARIABLE(rop, cmdlen); + __GLX_PUT_LONG(4, target); + __GLX_PUT_LONG(8, level); + __GLX_PUT_LONG(12, internal_format); + __GLX_PUT_LONG(16, width); + __GLX_PUT_LONG(20, height); + __GLX_PUT_LONG(24, border); + __GLX_PUT_LONG(28, image_size); + if (compsize != 0) { + __GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE, + data, image_size); + } + __GLX_END(cmdlen); + } + else { + assert(compsize != 0); + + __GLX_BEGIN_VARIABLE_LARGE(rop, cmdlen + 4); + __GLX_PUT_LONG(8, target); + __GLX_PUT_LONG(12, level); + __GLX_PUT_LONG(16, internal_format); + __GLX_PUT_LONG(20, width); + __GLX_PUT_LONG(24, height); + __GLX_PUT_LONG(28, border); + __GLX_PUT_LONG(32, image_size); + __glXSendLargeCommand(gc, gc->pc, + __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE + 4, + data, image_size); + } +} + + +/** + * Internal function used for \c glCompressedTexSubImage1D and + * \c glCompressedTexSubImage2D. + */ +static void +CompressedTexSubImage1D2D(GLenum target, GLint level, + GLsizei xoffset, GLsizei yoffset, + GLsizei width, GLsizei height, + GLenum format, GLsizei image_size, + const GLvoid * data, CARD32 rop) +{ + __GLX_DECLARE_VARIABLES(); + + __GLX_LOAD_VARIABLES(); + if (gc->currentDpy == NULL) { + return; + } + + if (target == GL_PROXY_TEXTURE_3D) { + compsize = 0; + } + else { + compsize = image_size; + } + + cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE + compsize); + if (cmdlen <= gc->maxSmallRenderCommandSize) { + __GLX_BEGIN_VARIABLE(rop, cmdlen); + __GLX_PUT_LONG(4, target); + __GLX_PUT_LONG(8, level); + __GLX_PUT_LONG(12, xoffset); + __GLX_PUT_LONG(16, yoffset); + __GLX_PUT_LONG(20, width); + __GLX_PUT_LONG(24, height); + __GLX_PUT_LONG(28, format); + __GLX_PUT_LONG(32, image_size); + if (compsize != 0) { + __GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE, + data, image_size); + } + __GLX_END(cmdlen); + } + else { + assert(compsize != 0); + + __GLX_BEGIN_VARIABLE_LARGE(rop, cmdlen + 4); + __GLX_PUT_LONG(8, target); + __GLX_PUT_LONG(12, level); + __GLX_PUT_LONG(16, xoffset); + __GLX_PUT_LONG(20, yoffset); + __GLX_PUT_LONG(24, width); + __GLX_PUT_LONG(28, height); + __GLX_PUT_LONG(32, format); + __GLX_PUT_LONG(36, image_size); + __glXSendLargeCommand(gc, gc->pc, + __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE + 4, + data, image_size); + } +} + + +void +__indirect_glCompressedTexImage1DARB(GLenum target, GLint level, + GLenum internal_format, GLsizei width, + GLint border, GLsizei image_size, + const GLvoid * data) +{ + CompressedTexImage1D2D(target, level, internal_format, width, 0, + border, image_size, data, + X_GLrop_CompressedTexImage1D); +} + + +void +__indirect_glCompressedTexImage2DARB(GLenum target, GLint level, + GLenum internal_format, + GLsizei width, GLsizei height, + GLint border, GLsizei image_size, + const GLvoid * data) +{ + CompressedTexImage1D2D(target, level, internal_format, width, height, + border, image_size, data, + X_GLrop_CompressedTexImage2D); +} + + +void +__indirect_glCompressedTexImage3DARB(GLenum target, GLint level, + GLenum internal_format, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLsizei image_size, const GLvoid * data) +{ + __GLX_DECLARE_VARIABLES(); + + __GLX_LOAD_VARIABLES(); + if (gc->currentDpy == NULL) { + return; + } + + cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE + image_size); + if (cmdlen <= gc->maxSmallRenderCommandSize) { + __GLX_BEGIN_VARIABLE(X_GLrop_CompressedTexImage3D, cmdlen); + __GLX_PUT_LONG(4, target); + __GLX_PUT_LONG(8, level); + __GLX_PUT_LONG(12, internal_format); + __GLX_PUT_LONG(16, width); + __GLX_PUT_LONG(20, height); + __GLX_PUT_LONG(24, depth); + __GLX_PUT_LONG(28, border); + __GLX_PUT_LONG(32, image_size); + if (image_size != 0) { + __GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE, + data, image_size); + } + __GLX_END(cmdlen); + } + else { + __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_CompressedTexImage3D, cmdlen + 4); + __GLX_PUT_LONG(8, target); + __GLX_PUT_LONG(12, level); + __GLX_PUT_LONG(16, internal_format); + __GLX_PUT_LONG(20, width); + __GLX_PUT_LONG(24, height); + __GLX_PUT_LONG(28, depth); + __GLX_PUT_LONG(32, border); + __GLX_PUT_LONG(36, image_size); + __glXSendLargeCommand(gc, gc->pc, + __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE + 4, + data, image_size); + } +} + + +void +__indirect_glCompressedTexSubImage1DARB(GLenum target, GLint level, + GLint xoffset, + GLsizei width, + GLenum format, GLsizei image_size, + const GLvoid * data) +{ + CompressedTexSubImage1D2D(target, level, xoffset, 0, width, 0, + format, image_size, data, + X_GLrop_CompressedTexSubImage1D); +} + + +void +__indirect_glCompressedTexSubImage2DARB(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLsizei image_size, + const GLvoid * data) +{ + CompressedTexSubImage1D2D(target, level, xoffset, yoffset, width, height, + format, image_size, data, + X_GLrop_CompressedTexSubImage2D); +} + + +void +__indirect_glCompressedTexSubImage3DARB(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, GLsizei image_size, + const GLvoid * data) +{ + __GLX_DECLARE_VARIABLES(); + + __GLX_LOAD_VARIABLES(); + if (gc->currentDpy == NULL) { + return; + } + + cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE + + image_size); + if (cmdlen <= gc->maxSmallRenderCommandSize) { + __GLX_BEGIN_VARIABLE(X_GLrop_CompressedTexSubImage3D, cmdlen); + __GLX_PUT_LONG(4, target); + __GLX_PUT_LONG(8, level); + __GLX_PUT_LONG(12, xoffset); + __GLX_PUT_LONG(16, yoffset); + __GLX_PUT_LONG(20, zoffset); + __GLX_PUT_LONG(24, width); + __GLX_PUT_LONG(28, height); + __GLX_PUT_LONG(32, depth); + __GLX_PUT_LONG(36, format); + __GLX_PUT_LONG(40, image_size); + if (image_size != 0) { + __GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE, + data, image_size); + } + __GLX_END(cmdlen); + } + else { + __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_CompressedTexSubImage3D, cmdlen + 4); + __GLX_PUT_LONG(8, target); + __GLX_PUT_LONG(12, level); + __GLX_PUT_LONG(16, xoffset); + __GLX_PUT_LONG(20, yoffset); + __GLX_PUT_LONG(24, zoffset); + __GLX_PUT_LONG(28, width); + __GLX_PUT_LONG(32, height); + __GLX_PUT_LONG(36, depth); + __GLX_PUT_LONG(40, format); + __GLX_PUT_LONG(44, image_size); + __glXSendLargeCommand(gc, gc->pc, + __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE + 4, + data, image_size); + } +} diff --git a/src/glx/indirect_transpose_matrix.c b/src/glx/indirect_transpose_matrix.c new file mode 100644 index 00000000000..618db9f5d4f --- /dev/null +++ b/src/glx/indirect_transpose_matrix.c @@ -0,0 +1,85 @@ +/* + * (C) Copyright IBM Corporation 2004 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include "indirect.h" + +static void +TransposeMatrixf(const GLfloat s[16], GLfloat d[16]) +{ + int i, j; + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + d[i * 4 + j] = s[j * 4 + i]; + } + } +} + +static void +TransposeMatrixd(const GLdouble s[16], GLdouble d[16]) +{ + int i, j; + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + d[i * 4 + j] = s[j * 4 + i]; + } + } +} + + +void +__indirect_glLoadTransposeMatrixdARB(const GLdouble * m) +{ + GLdouble mt[16]; + + TransposeMatrixd(m, mt); + __indirect_glLoadMatrixd(mt); +} + +void +__indirect_glLoadTransposeMatrixfARB(const GLfloat * m) +{ + GLfloat mt[16]; + + TransposeMatrixf(m, mt); + __indirect_glLoadMatrixf(mt); +} + +void +__indirect_glMultTransposeMatrixdARB(const GLdouble * m) +{ + GLdouble mt[16]; + + TransposeMatrixd(m, mt); + __indirect_glMultMatrixd(mt); +} + +void +__indirect_glMultTransposeMatrixfARB(const GLfloat * m) +{ + GLfloat mt[16]; + + TransposeMatrixf(m, mt); + __indirect_glMultMatrixf(mt); +} diff --git a/src/glx/indirect_vertex_array.c b/src/glx/indirect_vertex_array.c new file mode 100644 index 00000000000..ad9882528ff --- /dev/null +++ b/src/glx/indirect_vertex_array.c @@ -0,0 +1,1985 @@ +/* + * (C) Copyright IBM Corporation 2004, 2005 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include + +#include "glxclient.h" +#include "indirect.h" +#include +#include "glxextensions.h" +#include "indirect_vertex_array.h" +#include "indirect_vertex_array_priv.h" + +#define __GLX_PAD(n) (((n)+3) & ~3) + +/** + * \file indirect_vertex_array.c + * Implement GLX protocol for vertex arrays and vertex buffer objects. + * + * The most important function in this fill is \c fill_array_info_cache. + * The \c array_state_vector contains a cache of the ARRAY_INFO data sent + * in the DrawArrays protocol. Certain operations, such as enabling or + * disabling an array, can invalidate this cache. \c fill_array_info_cache + * fills-in this data. Additionally, it examines the enabled state and + * other factors to determine what "version" of DrawArrays protocoal can be + * used. + * + * Current, only two versions of DrawArrays protocol are implemented. The + * first version is the "none" protocol. This is the fallback when the + * server does not support GL 1.1 / EXT_vertex_arrays. It is implemented + * by sending batches of immediate mode commands that are equivalent to the + * DrawArrays protocol. + * + * The other protocol that is currently implemented is the "old" protocol. + * This is the GL 1.1 DrawArrays protocol. The only difference between GL + * 1.1 and EXT_vertex_arrays is the opcode used for the DrawArrays command. + * This protocol is called "old" because the ARB is in the process of + * defining a new protocol, which will probably be called wither "new" or + * "vbo", to support multiple texture coordinate arrays, generic attributes, + * and vertex buffer objects. + * + * \author Ian Romanick + */ + +static void emit_DrawArrays_none(GLenum mode, GLint first, GLsizei count); +static void emit_DrawArrays_old(GLenum mode, GLint first, GLsizei count); + +static void emit_DrawElements_none(GLenum mode, GLsizei count, GLenum type, + const GLvoid * indices); +static void emit_DrawElements_old(GLenum mode, GLsizei count, GLenum type, + const GLvoid * indices); + + +static GLubyte *emit_element_none(GLubyte * dst, + const struct array_state_vector *arrays, + unsigned index); +static GLubyte *emit_element_old(GLubyte * dst, + const struct array_state_vector *arrays, + unsigned index); +static struct array_state *get_array_entry(const struct array_state_vector + *arrays, GLenum key, + unsigned index); +static void fill_array_info_cache(struct array_state_vector *arrays); +static GLboolean validate_mode(__GLXcontext * gc, GLenum mode); +static GLboolean validate_count(__GLXcontext * gc, GLsizei count); +static GLboolean validate_type(__GLXcontext * gc, GLenum type); + + +/** + * Table of sizes, in bytes, of a GL types. All of the type enums are be in + * the range 0x1400 - 0x140F. That includes types added by extensions (i.e., + * \c GL_HALF_FLOAT_NV). This elements of this table correspond to the + * type enums masked with 0x0f. + * + * \notes + * \c GL_HALF_FLOAT_NV is not included. Neither are \c GL_2_BYTES, + * \c GL_3_BYTES, or \c GL_4_BYTES. + */ +const GLuint __glXTypeSize_table[16] = { + 1, 1, 2, 2, 4, 4, 4, 0, 0, 0, 8, 0, 0, 0, 0, 0 +}; + + +/** + * Free the per-context array state that was allocated with + * __glXInitVertexArrayState(). + */ +void +__glXFreeVertexArrayState(__GLXcontext * gc) +{ + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + + if (arrays) { + if (arrays->stack) { + free(arrays->stack); + arrays->stack = NULL; + } + if (arrays->arrays) { + free(arrays->arrays); + arrays->arrays = NULL; + } + free(arrays); + state->array_state = NULL; + } +} + + +/** + * Initialize vertex array state of a GLX context. + * + * \param gc GLX context whose vertex array state is to be initialized. + * + * \warning + * This function may only be called after __GLXcontext::gl_extension_bits, + * __GLXcontext::server_minor, and __GLXcontext::server_major have been + * initialized. These values are used to determine what vertex arrays are + * supported. + * + * \bug + * Return values from malloc are not properly tested. + */ +void +__glXInitVertexArrayState(__GLXcontext * gc) +{ + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays; + + unsigned array_count; + int texture_units = 1, vertex_program_attribs = 0; + unsigned i, j; + + GLboolean got_fog = GL_FALSE; + GLboolean got_secondary_color = GL_FALSE; + + + arrays = calloc(1, sizeof(struct array_state_vector)); + state->array_state = arrays; + + arrays->old_DrawArrays_possible = !state->NoDrawArraysProtocol; + arrays->new_DrawArrays_possible = GL_FALSE; + arrays->DrawArrays = NULL; + + arrays->active_texture_unit = 0; + + + /* Determine how many arrays are actually needed. Only arrays that + * are supported by the server are create. For example, if the server + * supports only 2 texture units, then only 2 texture coordinate arrays + * are created. + * + * At the very least, GL_VERTEX_ARRAY, GL_NORMAL_ARRAY, + * GL_COLOR_ARRAY, GL_INDEX_ARRAY, GL_TEXTURE_COORD_ARRAY, and + * GL_EDGE_FLAG_ARRAY are supported. + */ + + array_count = 5; + + if (__glExtensionBitIsEnabled(gc, GL_EXT_fog_coord_bit) + || (gc->server_major > 1) || (gc->server_minor >= 4)) { + got_fog = GL_TRUE; + array_count++; + } + + if (__glExtensionBitIsEnabled(gc, GL_EXT_secondary_color_bit) + || (gc->server_major > 1) || (gc->server_minor >= 4)) { + got_secondary_color = GL_TRUE; + array_count++; + } + + if (__glExtensionBitIsEnabled(gc, GL_ARB_multitexture_bit) + || (gc->server_major > 1) || (gc->server_minor >= 3)) { + __indirect_glGetIntegerv(GL_MAX_TEXTURE_UNITS, &texture_units); + } + + if (__glExtensionBitIsEnabled(gc, GL_ARB_vertex_program_bit)) { + __indirect_glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, + GL_MAX_PROGRAM_ATTRIBS_ARB, + &vertex_program_attribs); + } + + arrays->num_texture_units = texture_units; + arrays->num_vertex_program_attribs = vertex_program_attribs; + array_count += texture_units + vertex_program_attribs; + arrays->num_arrays = array_count; + arrays->arrays = calloc(array_count, sizeof(struct array_state)); + + arrays->arrays[0].data_type = GL_FLOAT; + arrays->arrays[0].count = 3; + arrays->arrays[0].key = GL_NORMAL_ARRAY; + arrays->arrays[0].normalized = GL_TRUE; + arrays->arrays[0].old_DrawArrays_possible = GL_TRUE; + + arrays->arrays[1].data_type = GL_FLOAT; + arrays->arrays[1].count = 4; + arrays->arrays[1].key = GL_COLOR_ARRAY; + arrays->arrays[1].normalized = GL_TRUE; + arrays->arrays[1].old_DrawArrays_possible = GL_TRUE; + + arrays->arrays[2].data_type = GL_FLOAT; + arrays->arrays[2].count = 1; + arrays->arrays[2].key = GL_INDEX_ARRAY; + arrays->arrays[2].old_DrawArrays_possible = GL_TRUE; + + arrays->arrays[3].data_type = GL_UNSIGNED_BYTE; + arrays->arrays[3].count = 1; + arrays->arrays[3].key = GL_EDGE_FLAG_ARRAY; + arrays->arrays[3].old_DrawArrays_possible = GL_TRUE; + + for (i = 0; i < texture_units; i++) { + arrays->arrays[4 + i].data_type = GL_FLOAT; + arrays->arrays[4 + i].count = 4; + arrays->arrays[4 + i].key = GL_TEXTURE_COORD_ARRAY; + + arrays->arrays[4 + i].old_DrawArrays_possible = (i == 0); + arrays->arrays[4 + i].index = i; + + arrays->arrays[4 + i].header[1] = i + GL_TEXTURE0; + } + + i = 4 + texture_units; + + if (got_fog) { + arrays->arrays[i].data_type = GL_FLOAT; + arrays->arrays[i].count = 1; + arrays->arrays[i].key = GL_FOG_COORDINATE_ARRAY; + arrays->arrays[i].old_DrawArrays_possible = GL_TRUE; + i++; + } + + if (got_secondary_color) { + arrays->arrays[i].data_type = GL_FLOAT; + arrays->arrays[i].count = 3; + arrays->arrays[i].key = GL_SECONDARY_COLOR_ARRAY; + arrays->arrays[i].old_DrawArrays_possible = GL_TRUE; + arrays->arrays[i].normalized = GL_TRUE; + i++; + } + + + for (j = 0; j < vertex_program_attribs; j++) { + const unsigned idx = (vertex_program_attribs - (j + 1)); + + + arrays->arrays[idx + i].data_type = GL_FLOAT; + arrays->arrays[idx + i].count = 4; + arrays->arrays[idx + i].key = GL_VERTEX_ATTRIB_ARRAY_POINTER; + + arrays->arrays[idx + i].old_DrawArrays_possible = 0; + arrays->arrays[idx + i].index = idx; + + arrays->arrays[idx + i].header[1] = idx; + } + + i += vertex_program_attribs; + + + /* Vertex array *must* be last becuase of the way that + * emit_DrawArrays_none works. + */ + + arrays->arrays[i].data_type = GL_FLOAT; + arrays->arrays[i].count = 4; + arrays->arrays[i].key = GL_VERTEX_ARRAY; + arrays->arrays[i].old_DrawArrays_possible = GL_TRUE; + + assert((i + 1) == arrays->num_arrays); + + arrays->stack_index = 0; + arrays->stack = malloc(sizeof(struct array_stack_state) + * arrays->num_arrays); +} + + +/** + * Calculate the size of a single vertex for the "none" protocol. This is + * essentially the size of all the immediate-mode commands required to + * implement the enabled vertex arrays. + */ +static size_t +calculate_single_vertex_size_none(const struct array_state_vector *arrays) +{ + size_t single_vertex_size = 0; + unsigned i; + + + for (i = 0; i < arrays->num_arrays; i++) { + if (arrays->arrays[i].enabled) { + single_vertex_size += ((uint16_t *) arrays->arrays[i].header)[0]; + } + } + + return single_vertex_size; +} + + +/** + * Emit a single element using non-DrawArrays protocol. + */ +GLubyte * +emit_element_none(GLubyte * dst, + const struct array_state_vector * arrays, unsigned index) +{ + unsigned i; + + + for (i = 0; i < arrays->num_arrays; i++) { + if (arrays->arrays[i].enabled) { + const size_t offset = index * arrays->arrays[i].true_stride; + + /* The generic attributes can have more data than is in the + * elements. This is because a vertex array can be a 2 element, + * normalized, unsigned short, but the "closest" immediate mode + * protocol is for a 4Nus. Since the sizes are small, the + * performance impact on modern processors should be negligible. + */ + (void) memset(dst, 0, ((uint16_t *) arrays->arrays[i].header)[0]); + + (void) memcpy(dst, arrays->arrays[i].header, + arrays->arrays[i].header_size); + + dst += arrays->arrays[i].header_size; + + (void) memcpy(dst, ((GLubyte *) arrays->arrays[i].data) + offset, + arrays->arrays[i].element_size); + + dst += __GLX_PAD(arrays->arrays[i].element_size); + } + } + + return dst; +} + + +/** + * Emit a single element using "old" DrawArrays protocol from + * EXT_vertex_arrays / OpenGL 1.1. + */ +GLubyte * +emit_element_old(GLubyte * dst, + const struct array_state_vector * arrays, unsigned index) +{ + unsigned i; + + + for (i = 0; i < arrays->num_arrays; i++) { + if (arrays->arrays[i].enabled) { + const size_t offset = index * arrays->arrays[i].true_stride; + + (void) memcpy(dst, ((GLubyte *) arrays->arrays[i].data) + offset, + arrays->arrays[i].element_size); + + dst += __GLX_PAD(arrays->arrays[i].element_size); + } + } + + return dst; +} + + +struct array_state * +get_array_entry(const struct array_state_vector *arrays, + GLenum key, unsigned index) +{ + unsigned i; + + for (i = 0; i < arrays->num_arrays; i++) { + if ((arrays->arrays[i].key == key) + && (arrays->arrays[i].index == index)) { + return &arrays->arrays[i]; + } + } + + return NULL; +} + + +static GLboolean +allocate_array_info_cache(struct array_state_vector *arrays, + size_t required_size) +{ +#define MAX_HEADER_SIZE 20 + if (arrays->array_info_cache_buffer_size < required_size) { + GLubyte *temp = realloc(arrays->array_info_cache_base, + required_size + MAX_HEADER_SIZE); + + if (temp == NULL) { + return GL_FALSE; + } + + arrays->array_info_cache_base = temp; + arrays->array_info_cache = temp + MAX_HEADER_SIZE; + arrays->array_info_cache_buffer_size = required_size; + } + + arrays->array_info_cache_size = required_size; + return GL_TRUE; +} + + +/** + */ +void +fill_array_info_cache(struct array_state_vector *arrays) +{ + GLboolean old_DrawArrays_possible; + unsigned i; + + + /* Determine how many arrays are enabled. + */ + + arrays->enabled_client_array_count = 0; + old_DrawArrays_possible = arrays->old_DrawArrays_possible; + for (i = 0; i < arrays->num_arrays; i++) { + if (arrays->arrays[i].enabled) { + arrays->enabled_client_array_count++; + old_DrawArrays_possible &= arrays->arrays[i].old_DrawArrays_possible; + } + } + + if (arrays->new_DrawArrays_possible) { + assert(!arrays->new_DrawArrays_possible); + } + else if (old_DrawArrays_possible) { + const size_t required_size = arrays->enabled_client_array_count * 12; + uint32_t *info; + + + if (!allocate_array_info_cache(arrays, required_size)) { + return; + } + + + info = (uint32_t *) arrays->array_info_cache; + for (i = 0; i < arrays->num_arrays; i++) { + if (arrays->arrays[i].enabled) { + *(info++) = arrays->arrays[i].data_type; + *(info++) = arrays->arrays[i].count; + *(info++) = arrays->arrays[i].key; + } + } + + arrays->DrawArrays = emit_DrawArrays_old; + arrays->DrawElements = emit_DrawElements_old; + } + else { + arrays->DrawArrays = emit_DrawArrays_none; + arrays->DrawElements = emit_DrawElements_none; + } + + arrays->array_info_cache_valid = GL_TRUE; +} + + +/** + * Emit a \c glDrawArrays command using the "none" protocol. That is, + * emit immediate-mode commands that are equivalent to the requiested + * \c glDrawArrays command. This is used with servers that don't support + * the OpenGL 1.1 / EXT_vertex_arrays DrawArrays protocol or in cases where + * vertex state is enabled that is not compatible with that protocol. + */ +void +emit_DrawArrays_none(GLenum mode, GLint first, GLsizei count) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + const __GLXattribute *state = + (const __GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + + size_t single_vertex_size; + GLubyte *pc; + unsigned i; + static const uint16_t begin_cmd[2] = { 8, X_GLrop_Begin }; + static const uint16_t end_cmd[2] = { 4, X_GLrop_End }; + + + single_vertex_size = calculate_single_vertex_size_none(arrays); + + pc = gc->pc; + + (void) memcpy(pc, begin_cmd, 4); + *(int *) (pc + 4) = mode; + + pc += 8; + + for (i = 0; i < count; i++) { + if ((pc + single_vertex_size) >= gc->bufEnd) { + pc = __glXFlushRenderBuffer(gc, pc); + } + + pc = emit_element_none(pc, arrays, first + i); + } + + if ((pc + 4) >= gc->bufEnd) { + pc = __glXFlushRenderBuffer(gc, pc); + } + + (void) memcpy(pc, end_cmd, 4); + pc += 4; + + gc->pc = pc; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + + +/** + * Emit the header data for the GL 1.1 / EXT_vertex_arrays DrawArrays + * protocol. + * + * \param gc GLX context. + * \param arrays Array state. + * \param elements_per_request Location to store the number of elements that + * can fit in a single Render / RenderLarge + * command. + * \param total_request Total number of requests for a RenderLarge + * command. If a Render command is used, this + * will be zero. + * \param mode Drawing mode. + * \param count Number of vertices. + * + * \returns + * A pointer to the buffer for array data. + */ +static GLubyte * +emit_DrawArrays_header_old(__GLXcontext * gc, + struct array_state_vector *arrays, + size_t * elements_per_request, + unsigned int *total_requests, + GLenum mode, GLsizei count) +{ + size_t command_size; + size_t single_vertex_size; + const unsigned header_size = 16; + unsigned i; + GLubyte *pc; + + + /* Determine the size of the whole command. This includes the header, + * the ARRAY_INFO data and the array data. Once this size is calculated, + * it will be known whether a Render or RenderLarge command is needed. + */ + + single_vertex_size = 0; + for (i = 0; i < arrays->num_arrays; i++) { + if (arrays->arrays[i].enabled) { + single_vertex_size += __GLX_PAD(arrays->arrays[i].element_size); + } + } + + command_size = arrays->array_info_cache_size + header_size + + (single_vertex_size * count); + + + /* Write the header for either a Render command or a RenderLarge + * command. After the header is written, write the ARRAY_INFO data. + */ + + if (command_size > gc->maxSmallRenderCommandSize) { + /* maxSize is the maximum amount of data can be stuffed into a single + * packet. sz_xGLXRenderReq is added because bufSize is the maximum + * packet size minus sz_xGLXRenderReq. + */ + const size_t maxSize = (gc->bufSize + sz_xGLXRenderReq) + - sz_xGLXRenderLargeReq; + unsigned vertex_requests; + + + /* Calculate the number of data packets that will be required to send + * the whole command. To do this, the number of verticies that + * will fit in a single buffer must be calculated. + * + * The important value here is elements_per_request. This is the + * number of complete array elements that will fit in a single + * buffer. There may be some wasted space at the end of the buffer, + * but splitting elements across buffer boundries would be painful. + */ + + elements_per_request[0] = maxSize / single_vertex_size; + + vertex_requests = (count + elements_per_request[0] - 1) + / elements_per_request[0]; + + *total_requests = vertex_requests + 1; + + + __glXFlushRenderBuffer(gc, gc->pc); + + command_size += 4; + + pc = ((GLubyte *) arrays->array_info_cache) - (header_size + 4); + *(uint32_t *) (pc + 0) = command_size; + *(uint32_t *) (pc + 4) = X_GLrop_DrawArrays; + *(uint32_t *) (pc + 8) = count; + *(uint32_t *) (pc + 12) = arrays->enabled_client_array_count; + *(uint32_t *) (pc + 16) = mode; + + __glXSendLargeChunk(gc, 1, *total_requests, pc, + header_size + 4 + arrays->array_info_cache_size); + + pc = gc->pc; + } + else { + if ((gc->pc + command_size) >= gc->bufEnd) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + + pc = gc->pc; + *(uint16_t *) (pc + 0) = command_size; + *(uint16_t *) (pc + 2) = X_GLrop_DrawArrays; + *(uint32_t *) (pc + 4) = count; + *(uint32_t *) (pc + 8) = arrays->enabled_client_array_count; + *(uint32_t *) (pc + 12) = mode; + + pc += header_size; + + (void) memcpy(pc, arrays->array_info_cache, + arrays->array_info_cache_size); + pc += arrays->array_info_cache_size; + + *elements_per_request = count; + *total_requests = 0; + } + + + return pc; +} + + +/** + */ +void +emit_DrawArrays_old(GLenum mode, GLint first, GLsizei count) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + const __GLXattribute *state = + (const __GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + + GLubyte *pc; + size_t elements_per_request; + unsigned total_requests = 0; + unsigned i; + size_t total_sent = 0; + + + pc = emit_DrawArrays_header_old(gc, arrays, &elements_per_request, + &total_requests, mode, count); + + + /* Write the arrays. + */ + + if (total_requests == 0) { + assert(elements_per_request >= count); + + for (i = 0; i < count; i++) { + pc = emit_element_old(pc, arrays, i + first); + } + + assert(pc <= gc->bufEnd); + + gc->pc = pc; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } + else { + unsigned req; + + + for (req = 2; req <= total_requests; req++) { + if (count < elements_per_request) { + elements_per_request = count; + } + + pc = gc->pc; + for (i = 0; i < elements_per_request; i++) { + pc = emit_element_old(pc, arrays, i + first); + } + + first += elements_per_request; + + total_sent += (size_t) (pc - gc->pc); + __glXSendLargeChunk(gc, req, total_requests, gc->pc, pc - gc->pc); + + count -= elements_per_request; + } + } +} + + +void +emit_DrawElements_none(GLenum mode, GLsizei count, GLenum type, + const GLvoid * indices) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + const __GLXattribute *state = + (const __GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + static const uint16_t begin_cmd[2] = { 8, X_GLrop_Begin }; + static const uint16_t end_cmd[2] = { 4, X_GLrop_End }; + + GLubyte *pc; + size_t single_vertex_size; + unsigned i; + + + single_vertex_size = calculate_single_vertex_size_none(arrays); + + + if ((gc->pc + single_vertex_size) >= gc->bufEnd) { + gc->pc = __glXFlushRenderBuffer(gc, gc->pc); + } + + pc = gc->pc; + + (void) memcpy(pc, begin_cmd, 4); + *(int *) (pc + 4) = mode; + + pc += 8; + + for (i = 0; i < count; i++) { + unsigned index = 0; + + if ((pc + single_vertex_size) >= gc->bufEnd) { + pc = __glXFlushRenderBuffer(gc, pc); + } + + switch (type) { + case GL_UNSIGNED_INT: + index = (unsigned) (((GLuint *) indices)[i]); + break; + case GL_UNSIGNED_SHORT: + index = (unsigned) (((GLushort *) indices)[i]); + break; + case GL_UNSIGNED_BYTE: + index = (unsigned) (((GLubyte *) indices)[i]); + break; + } + pc = emit_element_none(pc, arrays, index); + } + + if ((pc + 4) >= gc->bufEnd) { + pc = __glXFlushRenderBuffer(gc, pc); + } + + (void) memcpy(pc, end_cmd, 4); + pc += 4; + + gc->pc = pc; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + + +/** + */ +void +emit_DrawElements_old(GLenum mode, GLsizei count, GLenum type, + const GLvoid * indices) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + const __GLXattribute *state = + (const __GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + + GLubyte *pc; + size_t elements_per_request; + unsigned total_requests = 0; + unsigned i; + unsigned req; + unsigned req_element = 0; + + + pc = emit_DrawArrays_header_old(gc, arrays, &elements_per_request, + &total_requests, mode, count); + + + /* Write the arrays. + */ + + req = 2; + while (count > 0) { + if (count < elements_per_request) { + elements_per_request = count; + } + + switch (type) { + case GL_UNSIGNED_INT:{ + const GLuint *ui_ptr = (const GLuint *) indices + req_element; + + for (i = 0; i < elements_per_request; i++) { + const GLint index = (GLint) * (ui_ptr++); + pc = emit_element_old(pc, arrays, index); + } + break; + } + case GL_UNSIGNED_SHORT:{ + const GLushort *us_ptr = (const GLushort *) indices + req_element; + + for (i = 0; i < elements_per_request; i++) { + const GLint index = (GLint) * (us_ptr++); + pc = emit_element_old(pc, arrays, index); + } + break; + } + case GL_UNSIGNED_BYTE:{ + const GLubyte *ub_ptr = (const GLubyte *) indices + req_element; + + for (i = 0; i < elements_per_request; i++) { + const GLint index = (GLint) * (ub_ptr++); + pc = emit_element_old(pc, arrays, index); + } + break; + } + } + + if (total_requests != 0) { + __glXSendLargeChunk(gc, req, total_requests, gc->pc, pc - gc->pc); + pc = gc->pc; + req++; + } + + count -= elements_per_request; + req_element += elements_per_request; + } + + + assert((total_requests == 0) || ((req - 1) == total_requests)); + + if (total_requests == 0) { + assert(pc <= gc->bufEnd); + + gc->pc = pc; + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } + } +} + + +/** + * Validate that the \c mode parameter to \c glDrawArrays, et. al. is valid. + * If it is not valid, then an error code is set in the GLX context. + * + * \returns + * \c GL_TRUE if the argument is valid, \c GL_FALSE if is not. + */ +static GLboolean +validate_mode(__GLXcontext * gc, GLenum mode) +{ + switch (mode) { + case GL_POINTS: + case GL_LINE_STRIP: + case GL_LINE_LOOP: + case GL_LINES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + case GL_TRIANGLES: + case GL_QUAD_STRIP: + case GL_QUADS: + case GL_POLYGON: + break; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return GL_FALSE; + } + + return GL_TRUE; +} + + +/** + * Validate that the \c count parameter to \c glDrawArrays, et. al. is valid. + * A value less than zero is invalid and will result in \c GL_INVALID_VALUE + * being set. A value of zero will not result in an error being set, but + * will result in \c GL_FALSE being returned. + * + * \returns + * \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not. + */ +static GLboolean +validate_count(__GLXcontext * gc, GLsizei count) +{ + if (count < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + } + + return (count > 0); +} + + +/** + * Validate that the \c type parameter to \c glDrawElements, et. al. is + * valid. Only \c GL_UNSIGNED_BYTE, \c GL_UNSIGNED_SHORT, and + * \c GL_UNSIGNED_INT are valid. + * + * \returns + * \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not. + */ +static GLboolean +validate_type(__GLXcontext * gc, GLenum type) +{ + switch (type) { + case GL_UNSIGNED_INT: + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_BYTE: + return GL_TRUE; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return GL_FALSE; + } +} + + +void +__indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + const __GLXattribute *state = + (const __GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + + + if (validate_mode(gc, mode) && validate_count(gc, count)) { + if (!arrays->array_info_cache_valid) { + fill_array_info_cache(arrays); + } + + arrays->DrawArrays(mode, first, count); + } +} + + +void +__indirect_glArrayElement(GLint index) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + const __GLXattribute *state = + (const __GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + + size_t single_vertex_size; + + + single_vertex_size = calculate_single_vertex_size_none(arrays); + + if ((gc->pc + single_vertex_size) >= gc->bufEnd) { + gc->pc = __glXFlushRenderBuffer(gc, gc->pc); + } + + gc->pc = emit_element_none(gc->pc, arrays, index); + + if (gc->pc > gc->limit) { + (void) __glXFlushRenderBuffer(gc, gc->pc); + } +} + + +void +__indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type, + const GLvoid * indices) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + const __GLXattribute *state = + (const __GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + + + if (validate_mode(gc, mode) && validate_count(gc, count) + && validate_type(gc, type)) { + if (!arrays->array_info_cache_valid) { + fill_array_info_cache(arrays); + } + + arrays->DrawElements(mode, count, type, indices); + } +} + + +void +__indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, + GLsizei count, GLenum type, + const GLvoid * indices) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + const __GLXattribute *state = + (const __GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + + + if (validate_mode(gc, mode) && validate_count(gc, count) + && validate_type(gc, type)) { + if (end < start) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + + if (!arrays->array_info_cache_valid) { + fill_array_info_cache(arrays); + } + + arrays->DrawElements(mode, count, type, indices); + } +} + + +void +__indirect_glMultiDrawArraysEXT(GLenum mode, GLint * first, GLsizei * count, + GLsizei primcount) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + const __GLXattribute *state = + (const __GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + GLsizei i; + + + if (validate_mode(gc, mode)) { + if (!arrays->array_info_cache_valid) { + fill_array_info_cache(arrays); + } + + for (i = 0; i < primcount; i++) { + if (validate_count(gc, count[i])) { + arrays->DrawArrays(mode, first[i], count[i]); + } + } + } +} + + +void +__indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count, + GLenum type, const GLvoid ** indices, + GLsizei primcount) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + const __GLXattribute *state = + (const __GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + GLsizei i; + + + if (validate_mode(gc, mode) && validate_type(gc, type)) { + if (!arrays->array_info_cache_valid) { + fill_array_info_cache(arrays); + } + + for (i = 0; i < primcount; i++) { + if (validate_count(gc, count[i])) { + arrays->DrawElements(mode, count[i], type, indices[i]); + } + } + } +} + + +#define COMMON_ARRAY_DATA_INIT(a, PTR, TYPE, STRIDE, COUNT, NORMALIZED, HDR_SIZE, OPCODE) \ + do { \ + (a)->data = PTR; \ + (a)->data_type = TYPE; \ + (a)->user_stride = STRIDE; \ + (a)->count = COUNT; \ + (a)->normalized = NORMALIZED; \ + \ + (a)->element_size = __glXTypeSize( TYPE ) * COUNT; \ + (a)->true_stride = (STRIDE == 0) \ + ? (a)->element_size : STRIDE; \ + \ + (a)->header_size = HDR_SIZE; \ + ((uint16_t *) (a)->header)[0] = __GLX_PAD((a)->header_size + (a)->element_size); \ + ((uint16_t *) (a)->header)[1] = OPCODE; \ + } while(0) + + +void +__indirect_glVertexPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid * pointer) +{ + static const uint16_t short_ops[5] = { + 0, 0, X_GLrop_Vertex2sv, X_GLrop_Vertex3sv, X_GLrop_Vertex4sv + }; + static const uint16_t int_ops[5] = { + 0, 0, X_GLrop_Vertex2iv, X_GLrop_Vertex3iv, X_GLrop_Vertex4iv + }; + static const uint16_t float_ops[5] = { + 0, 0, X_GLrop_Vertex2fv, X_GLrop_Vertex3fv, X_GLrop_Vertex4fv + }; + static const uint16_t double_ops[5] = { + 0, 0, X_GLrop_Vertex2dv, X_GLrop_Vertex3dv, X_GLrop_Vertex4dv + }; + uint16_t opcode; + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + struct array_state *a; + + + if (size < 2 || size > 4 || stride < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + + switch (type) { + case GL_SHORT: + opcode = short_ops[size]; + break; + case GL_INT: + opcode = int_ops[size]; + break; + case GL_FLOAT: + opcode = float_ops[size]; + break; + case GL_DOUBLE: + opcode = double_ops[size]; + break; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + + a = get_array_entry(arrays, GL_VERTEX_ARRAY, 0); + assert(a != NULL); + COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_FALSE, 4, + opcode); + + if (a->enabled) { + arrays->array_info_cache_valid = GL_FALSE; + } +} + + +void +__indirect_glNormalPointer(GLenum type, GLsizei stride, + const GLvoid * pointer) +{ + uint16_t opcode; + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + struct array_state *a; + + + if (stride < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + + switch (type) { + case GL_BYTE: + opcode = X_GLrop_Normal3bv; + break; + case GL_SHORT: + opcode = X_GLrop_Normal3sv; + break; + case GL_INT: + opcode = X_GLrop_Normal3iv; + break; + case GL_FLOAT: + opcode = X_GLrop_Normal3fv; + break; + case GL_DOUBLE: + opcode = X_GLrop_Normal3dv; + break; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + + a = get_array_entry(arrays, GL_NORMAL_ARRAY, 0); + assert(a != NULL); + COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, 3, GL_TRUE, 4, opcode); + + if (a->enabled) { + arrays->array_info_cache_valid = GL_FALSE; + } +} + + +void +__indirect_glColorPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid * pointer) +{ + static const uint16_t byte_ops[5] = { + 0, 0, 0, X_GLrop_Color3bv, X_GLrop_Color4bv + }; + static const uint16_t ubyte_ops[5] = { + 0, 0, 0, X_GLrop_Color3ubv, X_GLrop_Color4ubv + }; + static const uint16_t short_ops[5] = { + 0, 0, 0, X_GLrop_Color3sv, X_GLrop_Color4sv + }; + static const uint16_t ushort_ops[5] = { + 0, 0, 0, X_GLrop_Color3usv, X_GLrop_Color4usv + }; + static const uint16_t int_ops[5] = { + 0, 0, 0, X_GLrop_Color3iv, X_GLrop_Color4iv + }; + static const uint16_t uint_ops[5] = { + 0, 0, 0, X_GLrop_Color3uiv, X_GLrop_Color4uiv + }; + static const uint16_t float_ops[5] = { + 0, 0, 0, X_GLrop_Color3fv, X_GLrop_Color4fv + }; + static const uint16_t double_ops[5] = { + 0, 0, 0, X_GLrop_Color3dv, X_GLrop_Color4dv + }; + uint16_t opcode; + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + struct array_state *a; + + + if (size < 3 || size > 4 || stride < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + + switch (type) { + case GL_BYTE: + opcode = byte_ops[size]; + break; + case GL_UNSIGNED_BYTE: + opcode = ubyte_ops[size]; + break; + case GL_SHORT: + opcode = short_ops[size]; + break; + case GL_UNSIGNED_SHORT: + opcode = ushort_ops[size]; + break; + case GL_INT: + opcode = int_ops[size]; + break; + case GL_UNSIGNED_INT: + opcode = uint_ops[size]; + break; + case GL_FLOAT: + opcode = float_ops[size]; + break; + case GL_DOUBLE: + opcode = double_ops[size]; + break; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + + a = get_array_entry(arrays, GL_COLOR_ARRAY, 0); + assert(a != NULL); + COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_TRUE, 4, opcode); + + if (a->enabled) { + arrays->array_info_cache_valid = GL_FALSE; + } +} + + +void +__indirect_glIndexPointer(GLenum type, GLsizei stride, const GLvoid * pointer) +{ + uint16_t opcode; + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + struct array_state *a; + + + if (stride < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + + switch (type) { + case GL_UNSIGNED_BYTE: + opcode = X_GLrop_Indexubv; + break; + case GL_SHORT: + opcode = X_GLrop_Indexsv; + break; + case GL_INT: + opcode = X_GLrop_Indexiv; + break; + case GL_FLOAT: + opcode = X_GLrop_Indexfv; + break; + case GL_DOUBLE: + opcode = X_GLrop_Indexdv; + break; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + + a = get_array_entry(arrays, GL_INDEX_ARRAY, 0); + assert(a != NULL); + COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, 1, GL_FALSE, 4, opcode); + + if (a->enabled) { + arrays->array_info_cache_valid = GL_FALSE; + } +} + + +void +__indirect_glEdgeFlagPointer(GLsizei stride, const GLvoid * pointer) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + struct array_state *a; + + + if (stride < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + + + a = get_array_entry(arrays, GL_EDGE_FLAG_ARRAY, 0); + assert(a != NULL); + COMMON_ARRAY_DATA_INIT(a, pointer, GL_UNSIGNED_BYTE, stride, 1, GL_FALSE, + 4, X_GLrop_EdgeFlagv); + + if (a->enabled) { + arrays->array_info_cache_valid = GL_FALSE; + } +} + + +void +__indirect_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid * pointer) +{ + static const uint16_t short_ops[5] = { + 0, X_GLrop_TexCoord1sv, X_GLrop_TexCoord2sv, X_GLrop_TexCoord3sv, + X_GLrop_TexCoord4sv + }; + static const uint16_t int_ops[5] = { + 0, X_GLrop_TexCoord1iv, X_GLrop_TexCoord2iv, X_GLrop_TexCoord3iv, + X_GLrop_TexCoord4iv + }; + static const uint16_t float_ops[5] = { + 0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2fv, X_GLrop_TexCoord3fv, + X_GLrop_TexCoord4fv + }; + static const uint16_t double_ops[5] = { + 0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2dv, X_GLrop_TexCoord3dv, + X_GLrop_TexCoord4dv + }; + + static const uint16_t mshort_ops[5] = { + 0, X_GLrop_MultiTexCoord1svARB, X_GLrop_MultiTexCoord2svARB, + X_GLrop_MultiTexCoord3svARB, X_GLrop_MultiTexCoord4svARB + }; + static const uint16_t mint_ops[5] = { + 0, X_GLrop_MultiTexCoord1ivARB, X_GLrop_MultiTexCoord2ivARB, + X_GLrop_MultiTexCoord3ivARB, X_GLrop_MultiTexCoord4ivARB + }; + static const uint16_t mfloat_ops[5] = { + 0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2fvARB, + X_GLrop_MultiTexCoord3fvARB, X_GLrop_MultiTexCoord4fvARB + }; + static const uint16_t mdouble_ops[5] = { + 0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2dvARB, + X_GLrop_MultiTexCoord3dvARB, X_GLrop_MultiTexCoord4dvARB + }; + + uint16_t opcode; + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + struct array_state *a; + unsigned header_size; + unsigned index; + + + if (size < 1 || size > 4 || stride < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + + index = arrays->active_texture_unit; + if (index == 0) { + switch (type) { + case GL_SHORT: + opcode = short_ops[size]; + break; + case GL_INT: + opcode = int_ops[size]; + break; + case GL_FLOAT: + opcode = float_ops[size]; + break; + case GL_DOUBLE: + opcode = double_ops[size]; + break; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + + header_size = 4; + } + else { + switch (type) { + case GL_SHORT: + opcode = mshort_ops[size]; + break; + case GL_INT: + opcode = mint_ops[size]; + break; + case GL_FLOAT: + opcode = mfloat_ops[size]; + break; + case GL_DOUBLE: + opcode = mdouble_ops[size]; + break; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + + header_size = 8; + } + + a = get_array_entry(arrays, GL_TEXTURE_COORD_ARRAY, index); + assert(a != NULL); + COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_FALSE, + header_size, opcode); + + if (a->enabled) { + arrays->array_info_cache_valid = GL_FALSE; + } +} + + +void +__indirect_glSecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, + const GLvoid * pointer) +{ + uint16_t opcode; + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + struct array_state *a; + + + if (size != 3 || stride < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + + switch (type) { + case GL_BYTE: + opcode = 4126; + break; + case GL_UNSIGNED_BYTE: + opcode = 4131; + break; + case GL_SHORT: + opcode = 4127; + break; + case GL_UNSIGNED_SHORT: + opcode = 4132; + break; + case GL_INT: + opcode = 4128; + break; + case GL_UNSIGNED_INT: + opcode = 4133; + break; + case GL_FLOAT: + opcode = 4129; + break; + case GL_DOUBLE: + opcode = 4130; + break; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + + a = get_array_entry(arrays, GL_SECONDARY_COLOR_ARRAY, 0); + if (a == NULL) { + __glXSetError(gc, GL_INVALID_OPERATION); + return; + } + + COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_TRUE, 4, opcode); + + if (a->enabled) { + arrays->array_info_cache_valid = GL_FALSE; + } +} + + +void +__indirect_glFogCoordPointerEXT(GLenum type, GLsizei stride, + const GLvoid * pointer) +{ + uint16_t opcode; + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + struct array_state *a; + + + if (stride < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + + switch (type) { + case GL_FLOAT: + opcode = 4124; + break; + case GL_DOUBLE: + opcode = 4125; + break; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + + a = get_array_entry(arrays, GL_FOG_COORD_ARRAY, 0); + if (a == NULL) { + __glXSetError(gc, GL_INVALID_OPERATION); + return; + } + + COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, 1, GL_FALSE, 4, opcode); + + if (a->enabled) { + arrays->array_info_cache_valid = GL_FALSE; + } +} + + +void +__indirect_glVertexAttribPointerARB(GLuint index, GLint size, + GLenum type, GLboolean normalized, + GLsizei stride, const GLvoid * pointer) +{ + static const uint16_t short_ops[5] = { 0, 4189, 4190, 4191, 4192 }; + static const uint16_t float_ops[5] = { 0, 4193, 4194, 4195, 4196 }; + static const uint16_t double_ops[5] = { 0, 4197, 4198, 4199, 4200 }; + + uint16_t opcode; + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + struct array_state_vector *arrays = state->array_state; + struct array_state *a; + unsigned true_immediate_count; + unsigned true_immediate_size; + + + if ((size < 1) || (size > 4) || (stride < 0) + || (index > arrays->num_vertex_program_attribs)) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + + if (normalized && (type != GL_FLOAT) && (type != GL_DOUBLE)) { + switch (type) { + case GL_BYTE: + opcode = X_GLrop_VertexAttrib4NbvARB; + break; + case GL_UNSIGNED_BYTE: + opcode = X_GLrop_VertexAttrib4NubvARB; + break; + case GL_SHORT: + opcode = X_GLrop_VertexAttrib4NsvARB; + break; + case GL_UNSIGNED_SHORT: + opcode = X_GLrop_VertexAttrib4NusvARB; + break; + case GL_INT: + opcode = X_GLrop_VertexAttrib4NivARB; + break; + case GL_UNSIGNED_INT: + opcode = X_GLrop_VertexAttrib4NuivARB; + break; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + + true_immediate_count = 4; + } + else { + true_immediate_count = size; + + switch (type) { + case GL_BYTE: + opcode = X_GLrop_VertexAttrib4bvARB; + true_immediate_count = 4; + break; + case GL_UNSIGNED_BYTE: + opcode = X_GLrop_VertexAttrib4ubvARB; + true_immediate_count = 4; + break; + case GL_SHORT: + opcode = short_ops[size]; + break; + case GL_UNSIGNED_SHORT: + opcode = X_GLrop_VertexAttrib4usvARB; + true_immediate_count = 4; + break; + case GL_INT: + opcode = X_GLrop_VertexAttrib4ivARB; + true_immediate_count = 4; + break; + case GL_UNSIGNED_INT: + opcode = X_GLrop_VertexAttrib4uivARB; + true_immediate_count = 4; + break; + case GL_FLOAT: + opcode = float_ops[size]; + break; + case GL_DOUBLE: + opcode = double_ops[size]; + break; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + } + + a = get_array_entry(arrays, GL_VERTEX_ATTRIB_ARRAY_POINTER, index); + if (a == NULL) { + __glXSetError(gc, GL_INVALID_OPERATION); + return; + } + + COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, normalized, 8, + opcode); + + true_immediate_size = __glXTypeSize(type) * true_immediate_count; + ((uint16_t *) (a)->header)[0] = __GLX_PAD(a->header_size + + true_immediate_size); + + if (a->enabled) { + arrays->array_info_cache_valid = GL_FALSE; + } +} + + +/** + * I don't have 100% confidence that this is correct. The different rules + * about whether or not generic vertex attributes alias "classic" vertex + * attributes (i.e., attrib1 ?= primary color) between ARB_vertex_program, + * ARB_vertex_shader, and NV_vertex_program are a bit confusing. My + * feeling is that the client-side doesn't have to worry about it. The + * client just sends all the data to the server and lets the server deal + * with it. + */ +void +__indirect_glVertexAttribPointerNV(GLuint index, GLint size, + GLenum type, GLsizei stride, + const GLvoid * pointer) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + GLboolean normalized = GL_FALSE; + + + switch (type) { + case GL_UNSIGNED_BYTE: + if (size != 4) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + normalized = GL_TRUE; + + case GL_SHORT: + case GL_FLOAT: + case GL_DOUBLE: + __indirect_glVertexAttribPointerARB(index, size, type, + normalized, stride, pointer); + return; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return; + } +} + + +void +__indirect_glClientActiveTextureARB(GLenum texture) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + __GLXattribute *const state = + (__GLXattribute *) (gc->client_state_private); + struct array_state_vector *const arrays = state->array_state; + const GLint unit = (GLint) texture - GL_TEXTURE0; + + + if ((unit < 0) || (unit >= arrays->num_texture_units)) { + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + + arrays->active_texture_unit = unit; +} + + +/** + * Modify the enable state for the selected array + */ +GLboolean +__glXSetArrayEnable(__GLXattribute * state, GLenum key, unsigned index, + GLboolean enable) +{ + struct array_state_vector *arrays = state->array_state; + struct array_state *a; + + + /* Texture coordinate arrays have an implict index set when the + * application calls glClientActiveTexture. + */ + if (key == GL_TEXTURE_COORD_ARRAY) { + index = arrays->active_texture_unit; + } + + a = get_array_entry(arrays, key, index); + + if ((a != NULL) && (a->enabled != enable)) { + a->enabled = enable; + arrays->array_info_cache_valid = GL_FALSE; + } + + return (a != NULL); +} + + +void +__glXArrayDisableAll(__GLXattribute * state) +{ + struct array_state_vector *arrays = state->array_state; + unsigned i; + + + for (i = 0; i < arrays->num_arrays; i++) { + arrays->arrays[i].enabled = GL_FALSE; + } + + arrays->array_info_cache_valid = GL_FALSE; +} + + +/** + */ +GLboolean +__glXGetArrayEnable(const __GLXattribute * const state, + GLenum key, unsigned index, GLintptr * dest) +{ + const struct array_state_vector *arrays = state->array_state; + const struct array_state *a = + get_array_entry((struct array_state_vector *) arrays, + key, index); + + if (a != NULL) { + *dest = (GLintptr) a->enabled; + } + + return (a != NULL); +} + + +/** + */ +GLboolean +__glXGetArrayType(const __GLXattribute * const state, + GLenum key, unsigned index, GLintptr * dest) +{ + const struct array_state_vector *arrays = state->array_state; + const struct array_state *a = + get_array_entry((struct array_state_vector *) arrays, + key, index); + + if (a != NULL) { + *dest = (GLintptr) a->data_type; + } + + return (a != NULL); +} + + +/** + */ +GLboolean +__glXGetArraySize(const __GLXattribute * const state, + GLenum key, unsigned index, GLintptr * dest) +{ + const struct array_state_vector *arrays = state->array_state; + const struct array_state *a = + get_array_entry((struct array_state_vector *) arrays, + key, index); + + if (a != NULL) { + *dest = (GLintptr) a->count; + } + + return (a != NULL); +} + + +/** + */ +GLboolean +__glXGetArrayStride(const __GLXattribute * const state, + GLenum key, unsigned index, GLintptr * dest) +{ + const struct array_state_vector *arrays = state->array_state; + const struct array_state *a = + get_array_entry((struct array_state_vector *) arrays, + key, index); + + if (a != NULL) { + *dest = (GLintptr) a->user_stride; + } + + return (a != NULL); +} + + +/** + */ +GLboolean +__glXGetArrayPointer(const __GLXattribute * const state, + GLenum key, unsigned index, void **dest) +{ + const struct array_state_vector *arrays = state->array_state; + const struct array_state *a = + get_array_entry((struct array_state_vector *) arrays, + key, index); + + + if (a != NULL) { + *dest = (void *) (a->data); + } + + return (a != NULL); +} + + +/** + */ +GLboolean +__glXGetArrayNormalized(const __GLXattribute * const state, + GLenum key, unsigned index, GLintptr * dest) +{ + const struct array_state_vector *arrays = state->array_state; + const struct array_state *a = + get_array_entry((struct array_state_vector *) arrays, + key, index); + + + if (a != NULL) { + *dest = (GLintptr) a->normalized; + } + + return (a != NULL); +} + + +/** + */ +GLuint +__glXGetActiveTextureUnit(const __GLXattribute * const state) +{ + return state->array_state->active_texture_unit; +} + + +void +__glXPushArrayState(__GLXattribute * state) +{ + struct array_state_vector *arrays = state->array_state; + struct array_stack_state *stack = + &arrays->stack[(arrays->stack_index * arrays->num_arrays)]; + unsigned i; + + /* XXX are we pushing _all_ the necessary fields? */ + for (i = 0; i < arrays->num_arrays; i++) { + stack[i].data = arrays->arrays[i].data; + stack[i].data_type = arrays->arrays[i].data_type; + stack[i].user_stride = arrays->arrays[i].user_stride; + stack[i].count = arrays->arrays[i].count; + stack[i].key = arrays->arrays[i].key; + stack[i].index = arrays->arrays[i].index; + stack[i].enabled = arrays->arrays[i].enabled; + } + + arrays->active_texture_unit_stack[arrays->stack_index] = + arrays->active_texture_unit; + + arrays->stack_index++; +} + + +void +__glXPopArrayState(__GLXattribute * state) +{ + struct array_state_vector *arrays = state->array_state; + struct array_stack_state *stack; + unsigned i; + + + arrays->stack_index--; + stack = &arrays->stack[(arrays->stack_index * arrays->num_arrays)]; + + for (i = 0; i < arrays->num_arrays; i++) { + switch (stack[i].key) { + case GL_NORMAL_ARRAY: + __indirect_glNormalPointer(stack[i].data_type, + stack[i].user_stride, stack[i].data); + break; + case GL_COLOR_ARRAY: + __indirect_glColorPointer(stack[i].count, + stack[i].data_type, + stack[i].user_stride, stack[i].data); + break; + case GL_INDEX_ARRAY: + __indirect_glIndexPointer(stack[i].data_type, + stack[i].user_stride, stack[i].data); + break; + case GL_EDGE_FLAG_ARRAY: + __indirect_glEdgeFlagPointer(stack[i].user_stride, stack[i].data); + break; + case GL_TEXTURE_COORD_ARRAY: + arrays->active_texture_unit = stack[i].index; + __indirect_glTexCoordPointer(stack[i].count, + stack[i].data_type, + stack[i].user_stride, stack[i].data); + break; + case GL_SECONDARY_COLOR_ARRAY: + __indirect_glSecondaryColorPointerEXT(stack[i].count, + stack[i].data_type, + stack[i].user_stride, + stack[i].data); + break; + case GL_FOG_COORDINATE_ARRAY: + __indirect_glFogCoordPointerEXT(stack[i].data_type, + stack[i].user_stride, stack[i].data); + break; + + } + + __glXSetArrayEnable(state, stack[i].key, stack[i].index, + stack[i].enabled); + } + + arrays->active_texture_unit = + arrays->active_texture_unit_stack[arrays->stack_index]; +} diff --git a/src/glx/indirect_vertex_array.h b/src/glx/indirect_vertex_array.h new file mode 100644 index 00000000000..37380320edd --- /dev/null +++ b/src/glx/indirect_vertex_array.h @@ -0,0 +1,64 @@ +/* + * (C) Copyright IBM Corporation 2004, 2005 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef INDIRECT_VERTEX_ARRAY_H +#define INDIRECT_VERTEX_ARRAY_H + +extern const GLuint __glXTypeSize_table[16]; + +#define __glXTypeSize(e) ((((e) & ~0x0f) != 0x1400) \ + ? 0 : __glXTypeSize_table[ (e) & 0x0f ]) + +extern void __glXArrayDisableAll(__GLXattribute * state); + +extern GLboolean __glXSetArrayEnable(__GLXattribute * state, + GLenum key, unsigned index, + GLboolean enable); + +extern GLboolean __glXGetArrayEnable(const __GLXattribute * const state, + GLenum key, unsigned index, + GLintptr * dest); +extern GLboolean __glXGetArraySize(const __GLXattribute * const state, + GLenum key, unsigned index, + GLintptr * dest); +extern GLboolean __glXGetArrayType(const __GLXattribute * const state, + GLenum key, unsigned index, + GLintptr * dest); +extern GLboolean __glXGetArrayStride(const __GLXattribute * const state, + GLenum key, unsigned index, + GLintptr * dest); +extern GLboolean __glXGetArrayPointer(const __GLXattribute * const state, + GLenum key, unsigned index, + void **dest); +extern GLboolean __glXGetArrayNormalized(const __GLXattribute * const state, + GLenum key, unsigned index, + GLintptr * dest); + +extern void __glXPushArrayState(__GLXattribute * state); +extern void __glXPopArrayState(__GLXattribute * state); + +extern GLuint __glXGetActiveTextureUnit(const __GLXattribute * const state); + +#endif /* INDIRECT_VERTEX_ARRAY_H */ diff --git a/src/glx/indirect_vertex_array_priv.h b/src/glx/indirect_vertex_array_priv.h new file mode 100644 index 00000000000..56dac37c783 --- /dev/null +++ b/src/glx/indirect_vertex_array_priv.h @@ -0,0 +1,311 @@ +/* + * (C) Copyright IBM Corporation 2004, 2005 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _INDIRECT_VA_PRIVATE_ +#define _INDIRECT_VA_PRIVATE_ + +/** + * \file indirect_va_private.h + * + * \author Ian Romanick + */ + +#include + +#include "glxclient.h" +#include "indirect.h" +#include + + +/** + * State descriptor for a single array of vertex data. + */ +struct array_state +{ + /** + * Pointer to the application supplied data. + */ + const void *data; + + /** + * Enum representing the type of the application supplied data. + */ + GLenum data_type; + + /** + * Stride value supplied by the application. This value is not used + * internally. It is only kept so that it can be queried by the + * application using glGet*v. + */ + GLsizei user_stride; + + /** + * Calculated size, in bytes, of a single element in the array. This + * is calculated based on \c count and the size of the data type + * represented by \c data_type. + */ + GLsizei element_size; + + /** + * Actual byte-stride from one element to the next. This value will + * be equal to either \c user_stride or \c element_stride. + */ + GLsizei true_stride; + + /** + * Number of data values in each element. + */ + GLint count; + + /** + * "Normalized" data is on the range [0,1] (unsigned) or [-1,1] (signed). + * This is used for mapping integral types to floating point types. + */ + GLboolean normalized; + + /** + * Pre-calculated GLX protocol command header. + */ + uint32_t header[2]; + + /** + * Size of the header data. For simple data, like glColorPointerfv, + * this is 4. For complex data that requires either a count (e.g., + * glWeightfvARB), an index (e.g., glVertexAttrib1fvARB), or a + * selector enum (e.g., glMultiTexCoord2fv) this is 8. + */ + unsigned header_size; + + /** + * Set to \c GL_TRUE if this array is enabled. Otherwise, it is set + * to \c GL_FALSE. + */ + GLboolean enabled; + + /** + * For multi-arrayed data (e.g., texture coordinates, generic vertex + * program attributes, etc.), this specifies which array this is. + */ + unsigned index; + + /** + * Per-array-type key. For most arrays, this will be the GL enum for + * that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY + * for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data, + * etc.). + */ + GLenum key; + + /** + * If this array can be used with the "classic" \c glDrawArrays protocol, + * this is set to \c GL_TRUE. Otherwise, it is set to \c GL_FALSE. + */ + GLboolean old_DrawArrays_possible; +}; + + +/** + * Array state that is pushed / poped by \c glPushClientAttrib and + * \c glPopClientAttrib. + */ +struct array_stack_state +{ + /** + * Pointer to the application supplied data. + */ + const void *data; + + /** + * Enum representing the type of the application supplied data. + */ + GLenum data_type; + + /** + * Stride value supplied by the application. This value is not used + * internally. It is only kept so that it can be queried by the + * application using glGet*v. + */ + GLsizei user_stride; + + /** + * Number of data values in each element. + */ + GLint count; + + /** + * Per-array-type key. For most arrays, this will be the GL enum for + * that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY + * for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data, + * etc.). + */ + GLenum key; + + /** + * For multi-arrayed data (e.g., texture coordinates, generic vertex + * program attributes, etc.), this specifies which array this is. + */ + unsigned index; + + /** + * Set to \c GL_TRUE if this array is enabled. Otherwise, it is set + * to \c GL_FALSE. + */ + GLboolean enabled; +}; + + +/** + * Collection of all the vertex array state. + */ +struct array_state_vector +{ + /** + * Number of arrays tracked by \c ::arrays. + */ + size_t num_arrays; + + /** + * Array of vertex array state. This array contains all of the valid + * vertex arrays. If a vertex array isn't in this array, then it isn't + * valid. For example, if an implementation does not support + * EXT_fog_coord, there won't be a GL_FOG_COORD_ARRAY entry in this + * array. + */ + struct array_state *arrays; + + /** + * Number of currently enabled client-side arrays. The value of this + * field is only valid if \c array_info_cache_valid is true. + */ + size_t enabled_client_array_count; + + /** + * \name ARRAY_INFO cache. + * + * These fields track the state of the ARRAY_INFO cache. The + * \c array_info_cache_size is the size of the actual data stored in + * \c array_info_cache. \c array_info_cache_buffer_size is the size of + * the buffer. This will always be greater than or equal to + * \c array_info_cache_size. + * + * \note + * There are some bytes of extra data before \c array_info_cache that is + * used to hold the header for RenderLarge commands. This is + * \b not included in \c array_info_cache_size or + * \c array_info_cache_buffer_size. \c array_info_cache_base stores a + * pointer to the true start of the buffer (i.e., what malloc returned). + */ + /*@{ */ + size_t array_info_cache_size; + size_t array_info_cache_buffer_size; + void *array_info_cache; + void *array_info_cache_base; + /*@} */ + + + /** + * Is the cache of ARRAY_INFO data valid? The cache can become invalid + * when one of several state changes occur. Among these chages are + * modifying the array settings for an enabled array and enabling / + * disabling an array. + */ + GLboolean array_info_cache_valid; + + /** + * Is it possible to use the GL 1.1 / EXT_vertex_arrays protocol? Use + * of this protocol is disabled with really old servers (i.e., servers + * that don't support GL 1.1 or EXT_vertex_arrays) or when an environment + * variable is set. + * + * \todo + * GL 1.1 and EXT_vertex_arrays use identical protocol, but have different + * opcodes for \c glDrawArrays. For servers that advertise one or the + * other, there should be a way to select which opcode to use. + */ + GLboolean old_DrawArrays_possible; + + /** + * Is it possible to use the new GL X.X / ARB_vertex_buffer_object + * protocol? + * + * \todo + * This protocol has not yet been defined by the ARB, but is currently a + * work in progress. This field is a place-holder. + */ + GLboolean new_DrawArrays_possible; + + /** + * Active texture unit set by \c glClientActiveTexture. + * + * \sa __glXGetActiveTextureUnit + */ + unsigned active_texture_unit; + + /** + * Number of supported texture units. Even if ARB_multitexture / + * GL 1.3 are not supported, this will be at least 1. When multitexture + * is supported, this will be the value queried by calling + * \c glGetIntegerv with \c GL_MAX_TEXTURE_UNITS. + * + * \todo + * Investigate if this should be the value of \c GL_MAX_TEXTURE_COORDS + * instead (if GL 2.0 / ARB_fragment_shader / ARB_fragment_program / + * NV_fragment_program are supported). + */ + unsigned num_texture_units; + + /** + * Number of generic vertex program attribs. If GL_ARB_vertex_program + * is not supported, this will be zero. Otherwise it will be the value + * queries by calling \c glGetProgramiv with \c GL_VERTEX_PROGRAM_ARB + * and \c GL_MAX_PROGRAM_ATTRIBS_ARB. + */ + unsigned num_vertex_program_attribs; + + /** + * \n Methods for implementing various GL functions. + * + * These method pointers are only valid \c array_info_cache_valid is set. + * When each function starts, it much check \c array_info_cache_valid. + * If it is not set, it must call \c fill_array_info_cache and call + * the new method. + * + * \sa fill_array_info_cache + * + * \todo + * Write code to plug these functions directly into the dispatch table. + */ + /*@{ */ + void (*DrawArrays) (GLenum, GLint, GLsizei); + void (*DrawElements) (GLenum mode, GLsizei count, GLenum type, + const GLvoid * indices); + /*@} */ + + struct array_stack_state *stack; + unsigned active_texture_unit_stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; + unsigned stack_index; +}; + +#endif /* _INDIRECT_VA_PRIVATE_ */ diff --git a/src/glx/indirect_vertex_program.c b/src/glx/indirect_vertex_program.c new file mode 100644 index 00000000000..3313ac008a5 --- /dev/null +++ b/src/glx/indirect_vertex_program.c @@ -0,0 +1,293 @@ +/* + * (C) Copyright IBM Corporation 2005 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include "indirect.h" +#include "glxclient.h" +#include "indirect_vertex_array.h" +#include + +#if !defined __GNUC__ || __GNUC__ < 3 +# define __builtin_expect(x, y) x +#endif + +static void +do_vertex_attrib_enable(GLuint index, GLboolean val) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + + if (!__glXSetArrayEnable(state, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB, + index, val)) { + __glXSetError(gc, GL_INVALID_ENUM); + } +} + + +void +__indirect_glEnableVertexAttribArrayARB(GLuint index) +{ + do_vertex_attrib_enable(index, GL_TRUE); +} + + +void +__indirect_glDisableVertexAttribArrayARB(GLuint index) +{ + do_vertex_attrib_enable(index, GL_FALSE); +} + + +static void +get_parameter(unsigned opcode, unsigned size, GLenum target, GLuint index, + void *params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 12; + + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = __glXSetupVendorRequest(gc, + X_GLXVendorPrivateWithReply, + opcode, cmdlen); + + *((GLenum *) (pc + 0)) = target; + *((GLuint *) (pc + 4)) = index; + *((GLuint *) (pc + 8)) = 0; + + (void) __glXReadReply(dpy, size, params, GL_FALSE); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + + +void +__indirect_glGetProgramEnvParameterfvARB(GLenum target, GLuint index, + GLfloat * params) +{ + get_parameter(1296, 4, target, index, params); +} + + +void +__indirect_glGetProgramEnvParameterdvARB(GLenum target, GLuint index, + GLdouble * params) +{ + get_parameter(1297, 8, target, index, params); +} + + +void +__indirect_glGetProgramLocalParameterfvARB(GLenum target, GLuint index, + GLfloat * params) +{ + get_parameter(1305, 4, target, index, params); +} + + +void +__indirect_glGetProgramLocalParameterdvARB(GLenum target, GLuint index, + GLdouble * params) +{ + get_parameter(1306, 8, target, index, params); +} + + +void +__indirect_glGetVertexAttribPointervNV(GLuint index, GLenum pname, + GLvoid ** pointer) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + + if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB) { + __glXSetError(gc, GL_INVALID_ENUM); + } + + if (!__glXGetArrayPointer(state, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB, + index, pointer)) { + __glXSetError(gc, GL_INVALID_VALUE); + } +} + + +/** + * Get the selected attribute from the vertex array state vector. + * + * \returns + * On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned. + */ +static GLboolean +get_attrib_array_data(__GLXattribute * state, GLuint index, GLenum cap, + GLintptr * data) +{ + GLboolean retval = GL_FALSE; + const GLenum attrib = GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB; + + switch (cap) { + case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB: + retval = __glXGetArrayEnable(state, attrib, index, data); + break; + + case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB: + retval = __glXGetArraySize(state, attrib, index, data); + break; + + case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB: + retval = __glXGetArrayStride(state, attrib, index, data); + break; + + case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB: + retval = __glXGetArrayType(state, attrib, index, data); + break; + + case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB: + retval = __glXGetArrayNormalized(state, attrib, index, data); + break; + } + + + return retval; +} + + +static void +get_vertex_attrib(__GLXcontext * gc, unsigned vop, + GLuint index, GLenum pname, xReply * reply) +{ + Display *const dpy = gc->currentDpy; + GLubyte *const pc = __glXSetupVendorRequest(gc, + X_GLXVendorPrivateWithReply, + vop, 8); + + *((uint32_t *) (pc + 0)) = index; + *((uint32_t *) (pc + 4)) = pname; + + (void) _XReply(dpy, reply, 0, False); +} + + +void +__indirect_glGetVertexAttribivARB(GLuint index, GLenum pname, GLint * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + xGLXSingleReply reply; + + + get_vertex_attrib(gc, 1303, index, pname, (xReply *) & reply); + + if (reply.size != 0) { + GLintptr data; + + + if (get_attrib_array_data(state, index, pname, &data)) { + *params = (GLint) data; + } + else { + if (reply.size == 1) { + *params = (GLint) reply.pad3; + } + else { + _XRead(dpy, (void *) params, 4 * reply.size); + } + } + } + + UnlockDisplay(dpy); + SyncHandle(); +} + + +void +__indirect_glGetVertexAttribfvARB(GLuint index, GLenum pname, + GLfloat * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + xGLXSingleReply reply; + + + get_vertex_attrib(gc, 1302, index, pname, (xReply *) & reply); + + if (reply.size != 0) { + GLintptr data; + + + if (get_attrib_array_data(state, index, pname, &data)) { + *params = (GLfloat) data; + } + else { + if (reply.size == 1) { + (void) memcpy(params, &reply.pad3, sizeof(GLfloat)); + } + else { + _XRead(dpy, (void *) params, 4 * reply.size); + } + } + } + + UnlockDisplay(dpy); + SyncHandle(); +} + + +void +__indirect_glGetVertexAttribdvARB(GLuint index, GLenum pname, + GLdouble * params) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + xGLXSingleReply reply; + + + get_vertex_attrib(gc, 1301, index, pname, (xReply *) & reply); + + if (reply.size != 0) { + GLintptr data; + + + if (get_attrib_array_data(state, index, pname, &data)) { + *params = (GLdouble) data; + } + else { + if (reply.size == 1) { + (void) memcpy(params, &reply.pad3, sizeof(GLdouble)); + } + else { + _XRead(dpy, (void *) params, 8 * reply.size); + } + } + } + + UnlockDisplay(dpy); + SyncHandle(); +} diff --git a/src/glx/indirect_window_pos.c b/src/glx/indirect_window_pos.c new file mode 100644 index 00000000000..e97be3506d1 --- /dev/null +++ b/src/glx/indirect_window_pos.c @@ -0,0 +1,112 @@ +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * (C) Copyright IBM Corporation 2004 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT, IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include "indirect.h" + +void +__indirect_glWindowPos2dMESA(GLdouble x, GLdouble y) +{ + __indirect_glWindowPos3fMESA(x, y, 0.0); +} + +void +__indirect_glWindowPos2iMESA(GLint x, GLint y) +{ + __indirect_glWindowPos3fMESA(x, y, 0.0); +} + +void +__indirect_glWindowPos2fMESA(GLfloat x, GLfloat y) +{ + __indirect_glWindowPos3fMESA(x, y, 0.0); +} + +void +__indirect_glWindowPos2sMESA(GLshort x, GLshort y) +{ + __indirect_glWindowPos3fMESA(x, y, 0.0); +} + +void +__indirect_glWindowPos2dvMESA(const GLdouble * p) +{ + __indirect_glWindowPos3fMESA(p[0], p[1], 0.0); +} + +void +__indirect_glWindowPos2fvMESA(const GLfloat * p) +{ + __indirect_glWindowPos3fMESA(p[0], p[1], 0.0); +} + +void +__indirect_glWindowPos2ivMESA(const GLint * p) +{ + __indirect_glWindowPos3fMESA(p[0], p[1], 0.0); +} + +void +__indirect_glWindowPos2svMESA(const GLshort * p) +{ + __indirect_glWindowPos3fMESA(p[0], p[1], 0.0); +} + +void +__indirect_glWindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) +{ + __indirect_glWindowPos3fMESA(x, y, z); +} + +void +__indirect_glWindowPos3iMESA(GLint x, GLint y, GLint z) +{ + __indirect_glWindowPos3fMESA(x, y, z); +} + +void +__indirect_glWindowPos3sMESA(GLshort x, GLshort y, GLshort z) +{ + __indirect_glWindowPos3fMESA(x, y, z); +} + +void +__indirect_glWindowPos3dvMESA(const GLdouble * p) +{ + __indirect_glWindowPos3fMESA(p[0], p[1], p[2]); +} + +void +__indirect_glWindowPos3ivMESA(const GLint * p) +{ + __indirect_glWindowPos3fMESA(p[0], p[1], p[2]); +} + +void +__indirect_glWindowPos3svMESA(const GLshort * p) +{ + __indirect_glWindowPos3fMESA(p[0], p[1], p[2]); +} diff --git a/src/glx/mini/Makefile b/src/glx/mini/Makefile deleted file mode 100644 index 6b5a3c76d74..00000000000 --- a/src/glx/mini/Makefile +++ /dev/null @@ -1,89 +0,0 @@ -# Build the MiniGLX libGL.so library. - -TOP = ../../.. -include $(TOP)/configs/current - - -DEFINES += -DGLX_DIRECT_RENDERING -DIN_MINI_GLX -UIN_DRI_DRIVER - -C_SOURCES = \ - $(TOP)/src/mesa/main/dispatch.c \ - $(TOP)/src/mesa/glapi/glapi.c \ - $(TOP)/src/mesa/glapi/glthread.c \ - $(TOP)/src/glx/x11/glcontextmodes.c \ - miniglx.c \ - miniglx_events.c - -X86_SOURCES = $(TOP)/src/mesa/x86/glapi_x86.S - -OBJECTS = $(C_SOURCES:.c=.o) \ - $(ASM_SOURCES:.S=.o) - -INCLUDES = -I. $(INCLUDE_DIRS) - -INCLUDE_DIRS = \ - -I$(TOP)/include \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main \ - -I$(TOP)/src/mesa/glapi \ - -I$(TOP)/src/glx/x11 \ - -I$(TOP)/src/mesa/drivers/dri/common \ - $(LIBDRM_CFLAGS) \ - $(PCIACCESS_CFLAGS) - - - -##### RULES ##### - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ - -.S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ - - -##### TARGETS ##### - -default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/miniglx.conf - - -# Make libGL -$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile - @ $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - -major 1 -minor 2 $(MKLIB_OPTIONS) \ - -install $(TOP)/$(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS) \ - $(LIBDRM_LIB) $(PCIACCESS_LIB) - - -# install sample miniglx.conf -$(TOP)/$(LIB_DIR)/miniglx.conf: - $(INSTALL) example.miniglx.conf $(TOP)/$(LIB_DIR)/miniglx.conf - - -drmtest: xf86drm.o drmtest.o - rm -f drmtest && $(CC) -o drmtest xf86drm.o drmtest.o - - -depend: $(C_SOURCES) $(ASM_SOURCES) - rm -f depend - touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(ASM_SOURCES) \ - > /dev/null - - -# Emacs tags -tags: - etags `find . -name \*.[ch]` `find ../include` - - -# Dummy install target -install: - - -# Remove .o and backup files -clean: - -rm -f drmtest $(TOP)/$(LIB_DIR)/libGL.so* - -rm -f *.o *~ - -rm -f depend depend.bak - -include depend diff --git a/src/glx/mini/NOTES b/src/glx/mini/NOTES deleted file mode 100644 index 1774107d634..00000000000 --- a/src/glx/mini/NOTES +++ /dev/null @@ -1,115 +0,0 @@ - - -Getting MiniGLX up and running ------------------------------- - -It's necessary to do a bit of work to set up an environment to run miniglx. - -For the radeon driver, it's necessary to get the right set of kernel -modules installed before attempting to run any programs: - - rmmod radeon agpgart; - insmod agpgart; - insmod $(MESA)/src/kernel/radeonfb/radeonfb.o; - insmod $(MESA)/src/kernel/radeon/radeon.o; - -For all drivers, its necessary to reach the compiled libraries, and -tell MiniGLX where to find it's configuration file: - - export LD_LIBRARY_PATH=$(MESA)/lib; - export MINIGLX_CONF=$(MESA)/lib/miniglx.conf - ------------------------------------------------------------- - -MiniGLX Example Programs ------------------------- - -The following programs will work with miniglx: - - $(MESA)/tests/miniglx - $(MESA)/xdemos/glxgears - -Thanks to the miniglut stub library, most of the mesa glut demos will -work. In particular, the following have been tested. (Note there is -no keyboard or mouse interaction with these demos). - - $(MESA)/demos/gears - $(MESA)/demos/geartrain - $(MESA)/demos/morph3d - $(MESA)/demos/isosurf - $(MESA)/demos/texobj - $(MESA)/demos/texcyl - $(MESA)/demos/gloss - $(MESA)/demos/fire - $(MESA)/demos/tunnel - $(MESA)/demos/teapot - $(MESA)/samples/prim - $(MESA)/samples/olympic - $(MESA)/samples/star - $(MESA)/samples/wave - ...etc - -In fact most of the glut demos seem to work within the constraints of -having no keyboard/mouse interactivity. Furthermore, the use of the -glut wrapper means that these programs don't require recompilation to -run under MiniGLX -- the same binary works with both regular GLX and -MiniGLX. - - ------------------------------------------------------------- - -Porting GLX apps to MiniGLX ---------------------------- - -A quick list of issues encountered in porting existing GLX apps to -MiniGLX. Listed in no particular order. - -1) No input events - -MiniGLX doesn't provide an input layer, so any X11 input event -handling in the existing app will have to be redone for whatever -input devices exist on the target. - -2) No configuration, expose events - -Many GLX and Xlib programs wait on an event to ensure the window has -become visible after being mapped. MiniGLX provides no equivalent -facility. - -3) Different headers - -X11/Xlib.h, GL/GLX.h, etc must not be used if the program is being -compiled against MiniGLX. - -The equivalent header is GL/MiniGLX.h. - -4) Different library - -It may be necessary to link directly against the minGLX libGL.so. - -5) Reduced number of Xlib and GLX entrypoints. - -By definition (MiniGLX is a subset of GLX), many Xlib and GLX -entrypoints, structures and macros are not present in MiniGLX. It -will be necessary to find and eliminate all references to -non-supported entrypoints. - - ---------------------------------------------------------------- - -Bugs in radeonfb.o -- the radeon framebuffer driver. ----------------------------------------------------- - -Several bugs have been found in the radeonfb.o framebuffer driver. -Most of these are resolved in the version included in the MiniGLX -sources, but some remain: - -1) Occasionally, after entering graphics mode, colors appear 'shifted' -or 'translated', particularly in higher resolution modes. This is -definitely a bug in radeonfb.o as this can be provoked even when using -the software dri driver (fb_dri.so). Importance: High. Workaround: -Use 800x600 as it seems to be less frequent at this resolution, -otherwise, restart the application. - - - diff --git a/src/glx/mini/dispatch.c b/src/glx/mini/dispatch.c deleted file mode 100644 index ac24df9e7d4..00000000000 --- a/src/glx/mini/dispatch.c +++ /dev/null @@ -1,64 +0,0 @@ -/** - * \file miniglx/dispatch.c - * - * \brief C-based dispatch of the OpenGL entry points (glAccum(), glBegin(), - * etc). - * - * \author Brian Paul - * - * \note This code IS NOT USED if we're compiling on an x86 system and using - * the glapi_x86.S assembly code. - */ - -/* - * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "glheader.h" -#include "glapi.h" -#include "glapitable.h" - - -#if !(defined(USE_X86_ASM) || defined(USE_SPARC_ASM)) - -#define KEYWORD1 - -#define KEYWORD2 - -#define NAME(func) gl##func - -#define DISPATCH(func, args, msg) \ - const struct _glapi_table *dispatch; \ - dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\ - (dispatch->func) args - -#define RETURN_DISPATCH(func, args, msg) \ - const struct _glapi_table *dispatch; \ - dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\ - return (dispatch->func) args - - -#include "glapitemp.h" - -#endif /* USE_X86_ASM */ diff --git a/src/glx/mini/driver.h b/src/glx/mini/driver.h deleted file mode 100644 index 39c0f9b5fa6..00000000000 --- a/src/glx/mini/driver.h +++ /dev/null @@ -1,168 +0,0 @@ -/** - * \file driver.h - * \brief DRI utility functions definitions. - * - * This module acts as glue between GLX and the actual hardware driver. A DRI - * driver doesn't really \e have to use any of this - it's optional. But, some - * useful stuff is done here that otherwise would have to be duplicated in most - * drivers. - * - * Basically, these utility functions take care of some of the dirty details of - * screen initialization, context creation, context binding, DRM setup, etc. - * - * These functions are compiled into each DRI driver so libGL.so knows nothing - * about them. - * - * Look for more comments in the dri_util.c file. - * - * \author Kevin E. Martin - * \author Brian Paul - */ - -/* - * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef _driver_H_ -#define _driver_H_ - -#include "GL/gl.h" -#include "GL/internal/glcore.h" - -#include "drm.h" -#include "drm_sarea.h" - -/** - * \brief DRIDriverContext type. - */ -typedef struct DRIDriverContextRec { - const char *pciBusID; - int pciBus; - int pciDevice; - int pciFunc; - int chipset; - int bpp; - int cpp; - int agpmode; - int isPCI; - - int colorTiling; /**< \brief color tiling is enabled */ - - unsigned long FBStart; /**< \brief physical address of the framebuffer */ - unsigned long MMIOStart; /**< \brief physical address of the MMIO region */ - - int FBSize; /**< \brief size of the mmap'd framebuffer in bytes */ - int MMIOSize; /**< \brief size of the mmap'd MMIO region in bytes */ - - void *FBAddress; /**< \brief start of the mmap'd framebuffer */ - void *MMIOAddress; /**< \brief start of the mmap'd MMIO region */ - - /** - * \brief Client configuration details - * - * These are computed on the server and sent to clients as part of - * the initial handshaking. - */ - struct { - drm_handle_t hSAREA; - int SAREASize; - drm_handle_t hFrameBuffer; - int fbOrigin; - int fbSize; - int fbStride; - int virtualWidth; - int virtualHeight; - int Width; - } shared; - - /** - * \name From DRIInfoRec - */ - /*@{*/ - int drmFD; /**< \brief DRM device file descriptor */ - drm_sarea_t *pSAREA; - unsigned int serverContext; /**< \brief DRM context only active on server */ - /*@}*/ - - - /** - * \name Driver private - * - * Populated by __driInitFBDev() - */ - /*@{*/ - void *driverPrivate; - void *driverClientMsg; - int driverClientMsgSize; - /*@}*/ -} DRIDriverContext; - -/** - * \brief Interface to the DRI driver. - * - * This structure is retrieved from the loadable driver by the \e - * __driDriver symbol to access the Mini GLX specific hardware - * initialization and take down routines. - */ -typedef struct DRIDriverRec { - /** - * \brief Validate the framebuffer device mode - */ - int (*validateMode)( const DRIDriverContext *context ); - - /** - * \brief Examine mode returned by fbdev (may differ from the one - * requested), restore any hw regs clobbered by fbdev. - */ - int (*postValidateMode)( const DRIDriverContext *context ); - - /** - * \brief Initialize the framebuffer device. - */ - int (*initFBDev)( DRIDriverContext *context ); - - /** - * \brief Halt the framebuffer device. - */ - void (*haltFBDev)( DRIDriverContext *context ); - - - /** - * \brief Idle and shutdown hardware in preparation for a VT switch. - */ - int (*shutdownHardware)( const DRIDriverContext *context ); - - /** - * \brief Restore hardware state after regaining the VT. - */ - int (*restoreHardware)( const DRIDriverContext *context ); - - /** - * \brief Notify hardware driver of gain/loose focus. May be zero - * as this is of limited utility for most drivers. - */ - void (*notifyFocus)( int have_focus ); -} DRIDriver; - -#endif /* _driver_H_ */ diff --git a/src/glx/mini/example.miniglx.conf b/src/glx/mini/example.miniglx.conf deleted file mode 100644 index 62dd4f65ec4..00000000000 --- a/src/glx/mini/example.miniglx.conf +++ /dev/null @@ -1,36 +0,0 @@ -# Example miniglx configuration file (/etc/miniglx.conf) -# - -# Framebuffer device to open: Might need to change this on dual-head -# systems. -fbdevDevice=/dev/fb0 - -# Which driver? -# radeon_dri.so -- HW accelerated radeon driver -# fb_dri.so -- Software rasterizer -clientDriverName=radeon_dri.so - -# The pci bus id of the video card. Find this with scanpci, lspci or -# look in /proc/pci. -pciBusID=PCI:1:0:0 - -# Is the card PCI or AGP ? -isPCI=0 - -# Virtual screen dimensions. Can reduce this to save videocard memory -# at the expense of maximum window size available. -virtualWidth=1280 -virtualHeight=1024 - -# Screen depth. Only 16 & 32bpp supported. -bpp=32 - -# AGP Mode. Not all cards supported (1, 2 or 4) -agpmode=1 - -# Rotated monitor? -- NOTE: only works with subsetted radeon driver! -rotateMode=0 - -# Do we want to use color tiling ? -colorTiling=0 - diff --git a/src/glx/mini/miniglx.c b/src/glx/mini/miniglx.c deleted file mode 100644 index e9a10b4ac73..00000000000 --- a/src/glx/mini/miniglx.c +++ /dev/null @@ -1,2580 +0,0 @@ -/** - * \file miniglx.c - * \brief Mini GLX interface functions. - * \author Brian Paul - * - * The Mini GLX interface is a subset of the GLX interface, plus a - * minimal set of Xlib functions. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.0.1 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \mainpage Mini GLX - * - * \section miniglxIntro Introduction - * - * The Mini GLX interface facilitates OpenGL rendering on embedded devices. The - * interface is a subset of the GLX interface, plus a minimal set of Xlib-like - * functions. - * - * Programs written to the Mini GLX specification should run unchanged - * on systems with the X Window System and the GLX extension (after - * recompilation). The intention is to allow flexibility for - * prototyping and testing. - * - * The files in the src/miniglx/ directory are compiled to build the - * libGL.so library. This is the library which applications link with. - * libGL.so in turn, loads the hardware-specific device driver. - * - * - * \section miniglxDoxygen About Doxygen - * - * For a list of all files, select File List. Choose a file from - * the list for a list of all functions in the file. - * - * For a list of all functions, types, constants, etc. - * select File Members. - * - * - * \section miniglxReferences References - * - * - Mini GLX Specification, - * Tungsten Graphics, Inc. - * - OpenGL Graphics with the X Window System, Silicon Graphics, Inc., - * ftp://ftp.sgi.com/opengl/doc/opengl1.2/glx1.3.ps - * - Xlib - C Language X Interface, X Consortium Standard, X Version 11, - * Release 6.4, ftp://ftp.x.org/pub/R6.4/xc/doc/hardcopy/X11/xlib.PS.gz - * - XFree86 Man pages, The XFree86 Project, Inc., - * http://www.xfree86.org/current/manindex3.html - * - */ - -/** - * \page datatypes Notes on the XVisualInfo, Visual, and __GLXvisualConfig data types - * - * -# X (unfortunately) has two (or three) data types which - * describe visuals. Ideally, there would just be one. - * -# We need the #__GLXvisualConfig type to augment #XVisualInfo and #Visual - * because we need to describe the GLX-specific attributes of visuals. - * -# In this interface there is a one-to-one-to-one correspondence between - * the three types and they're all interconnected. - * -# The #XVisualInfo type has a pointer to a #Visual. The #Visual structure - * (aka MiniGLXVisualRec) has a pointer to the #__GLXvisualConfig. The - * #Visual structure also has a pointer pointing back to the #XVisualInfo. - * -# The #XVisualInfo structure is the only one who's contents are public. - * -# The glXChooseVisual() and XGetVisualInfo() are the only functions that - * return #XVisualInfo structures. They can be freed with XFree(), though - * there is a small memory leak. - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* for gettimeofday */ -#include -#include - -#include "miniglxP.h" -#include "dri_util.h" - -#include "imports.h" -#include "glcontextmodes.h" -#include "glapi.h" - -#include "pciaccess.h" - -static GLboolean __glXCreateContextWithConfig(__DRInativeDisplay *dpy, - int screen, int fbconfigID, void *contextID, - drm_context_t *hHWContext); - -static GLboolean __glXGetDrawableInfo(__DRInativeDisplay *dpy, int scrn, - __DRIid draw, unsigned int * index, unsigned int * stamp, - int * x, int * y, int * width, int * height, - int * numClipRects, drm_clip_rect_t ** pClipRects, - int * backX, int * backY, - int * numBackClipRects, drm_clip_rect_t ** pBackClipRects); - -static __DRIscreen * __glXFindDRIScreen(__DRInativeDisplay *dpy, int scrn); - -static GLboolean __glXWindowExists(__DRInativeDisplay *dpy, __DRIid draw); - -static int __glXGetUST( int64_t * ust ); - -static GLboolean __glXGetMscRate(__DRInativeDisplay * dpy, __DRIid drawable, - int32_t * numerator, int32_t * denominator); - -static GLboolean xf86DRI_DestroyContext(__DRInativeDisplay *dpy, int screen, - __DRIid context_id ); - -static GLboolean xf86DRI_CreateDrawable(__DRInativeDisplay *dpy, int screen, - __DRIid drawable, drm_drawable_t *hHWDrawable ); - -static GLboolean xf86DRI_DestroyDrawable(__DRInativeDisplay *dpy, int screen, - __DRIid drawable); - - -/** Wrapper around either malloc() */ -void * -_mesa_malloc(size_t bytes) -{ - return malloc(bytes); -} - -/** Wrapper around either calloc() */ -void * -_mesa_calloc(size_t bytes) -{ - return calloc(1, bytes); -} - -/** Wrapper around either free() */ -void -_mesa_free(void *ptr) -{ - free(ptr); -} - - -/** - * \brief Current GLX context. - * - * \sa glXGetCurrentContext(). - */ -static GLXContext CurrentContext = NULL; - - - -static Display *SignalDisplay = 0; - -static void SwitchVT(int sig) -{ - fprintf(stderr, "SwitchVT %d dpy %p\n", sig, SignalDisplay); - - if (SignalDisplay) { - SignalDisplay->vtSignalFlag = 1; - switch( sig ) - { - case SIGUSR1: /* vt has been released */ - SignalDisplay->haveVT = 0; - break; - case SIGUSR2: /* vt has been acquired */ - SignalDisplay->haveVT = 1; - break; - } - } -} - -/**********************************************************************/ -/** \name Framebuffer device functions */ -/**********************************************************************/ -/*@{*/ - -/** - * \brief Do the first part of setting up the framebuffer device. - * - * \param dpy the display handle. - * \param use_vt use a VT for display or not - * - * \return GL_TRUE on success, or GL_FALSE on failure. - * - * \sa This is called during XOpenDisplay(). - * - * \internal - * Gets the VT number, opens the respective console TTY device. Saves its state - * to restore when exiting and goes into graphics mode. - * - * Opens the framebuffer device and make a copy of the original variable screen - * information and gets the fixed screen information. Maps the framebuffer and - * MMIO region into the process address space. - */ -static GLboolean -OpenFBDev( Display *dpy, int use_vt ) -{ - char ttystr[1000]; - int fd, vtnumber, ttyfd; - - assert(dpy); - - if (geteuid()) { - fprintf(stderr, "error: you need to be root\n"); - return GL_FALSE; - } - - if (use_vt) { - - /* open /dev/tty0 and get the VT number */ - if ((fd = open("/dev/tty0", O_WRONLY, 0)) < 0) { - fprintf(stderr, "error opening /dev/tty0\n"); - return GL_FALSE; - } - if (ioctl(fd, VT_OPENQRY, &vtnumber) < 0 || vtnumber < 0) { - fprintf(stderr, "error: couldn't get a free vt\n"); - return GL_FALSE; - } - - fprintf(stderr, "*** got vt nr: %d\n", vtnumber); - close(fd); - - /* open the console tty */ - sprintf(ttystr, "/dev/tty%d", vtnumber); /* /dev/tty1-64 */ - dpy->ConsoleFD = open(ttystr, O_RDWR | O_NDELAY, 0); - if (dpy->ConsoleFD < 0) { - fprintf(stderr, "error couldn't open console fd\n"); - return GL_FALSE; - } - - /* save current vt number */ - { - struct vt_stat vts; - if (ioctl(dpy->ConsoleFD, VT_GETSTATE, &vts) == 0) - dpy->OriginalVT = vts.v_active; - } - - /* disconnect from controlling tty */ - ttyfd = open("/dev/tty", O_RDWR); - if (ttyfd >= 0) { - ioctl(ttyfd, TIOCNOTTY, 0); - close(ttyfd); - } - - /* some magic to restore the vt when we exit */ - { - struct vt_mode vt; - struct sigaction sig_tty; - - /* Set-up tty signal handler to catch the signal we request below */ - SignalDisplay = dpy; - memset( &sig_tty, 0, sizeof( sig_tty ) ); - sig_tty.sa_handler = SwitchVT; - sigemptyset( &sig_tty.sa_mask ); - if( sigaction( SIGUSR1, &sig_tty, &dpy->OrigSigUsr1 ) || - sigaction( SIGUSR2, &sig_tty, &dpy->OrigSigUsr2 ) ) - { - fprintf(stderr, "error: can't set up signal handler (%s)", - strerror(errno) ); - return GL_FALSE; - } - - - - vt.mode = VT_PROCESS; - vt.waitv = 0; - vt.relsig = SIGUSR1; - vt.acqsig = SIGUSR2; - if (ioctl(dpy->ConsoleFD, VT_SETMODE, &vt) < 0) { - fprintf(stderr, "error: ioctl(VT_SETMODE) failed: %s\n", - strerror(errno)); - return GL_FALSE; - } - - - if (ioctl(dpy->ConsoleFD, VT_ACTIVATE, vtnumber) != 0) - printf("ioctl VT_ACTIVATE: %s\n", strerror(errno)); - if (ioctl(dpy->ConsoleFD, VT_WAITACTIVE, vtnumber) != 0) - printf("ioctl VT_WAITACTIVE: %s\n", strerror(errno)); - - if (ioctl(dpy->ConsoleFD, VT_GETMODE, &vt) < 0) { - fprintf(stderr, "error: ioctl VT_GETMODE: %s\n", strerror(errno)); - return GL_FALSE; - } - - - - } - - /* go into graphics mode */ - if (ioctl(dpy->ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0) { - fprintf(stderr, "error: ioctl(KDSETMODE, KD_GRAPHICS) failed: %s\n", - strerror(errno)); - return GL_FALSE; - } - } - - /* open the framebuffer device */ - dpy->FrameBufferFD = open(dpy->fbdevDevice, O_RDWR); - if (dpy->FrameBufferFD < 0) { - fprintf(stderr, "Error opening /dev/fb0: %s\n", strerror(errno)); - return GL_FALSE; - } - - /* get the original variable screen info */ - if (ioctl(dpy->FrameBufferFD, FBIOGET_VSCREENINFO, &dpy->OrigVarInfo)) { - fprintf(stderr, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n", - strerror(errno)); - return GL_FALSE; - } - - /* make copy */ - dpy->VarInfo = dpy->OrigVarInfo; /* structure copy */ - - /* Turn off hw accels (otherwise mmap of mmio region will be - * refused) - */ - dpy->VarInfo.accel_flags = 0; - if (ioctl(dpy->FrameBufferFD, FBIOPUT_VSCREENINFO, &dpy->VarInfo)) { - fprintf(stderr, "error: ioctl(FBIOPUT_VSCREENINFO) failed: %s\n", - strerror(errno)); - return GL_FALSE; - } - - - - /* Get the fixed screen info */ - if (ioctl(dpy->FrameBufferFD, FBIOGET_FSCREENINFO, &dpy->FixedInfo)) { - fprintf(stderr, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n", - strerror(errno)); - return GL_FALSE; - } - - - - /* mmap the framebuffer into our address space */ - dpy->driverContext.FBStart = dpy->FixedInfo.smem_start; - dpy->driverContext.FBSize = dpy->FixedInfo.smem_len; - dpy->driverContext.shared.fbSize = dpy->FixedInfo.smem_len; - dpy->driverContext.FBAddress = (caddr_t) mmap(0, /* start */ - dpy->driverContext.shared.fbSize, /* bytes */ - PROT_READ | PROT_WRITE, /* prot */ - MAP_SHARED, /* flags */ - dpy->FrameBufferFD, /* fd */ - 0 /* offset */); - if (dpy->driverContext.FBAddress == (caddr_t) - 1) { - fprintf(stderr, "error: unable to mmap framebuffer: %s\n", - strerror(errno)); - return GL_FALSE; - } - - /* mmap the MMIO region into our address space */ - dpy->driverContext.MMIOStart = dpy->FixedInfo.mmio_start; - dpy->driverContext.MMIOSize = dpy->FixedInfo.mmio_len; - dpy->driverContext.MMIOAddress = (caddr_t) mmap(0, /* start */ - dpy->driverContext.MMIOSize, /* bytes */ - PROT_READ | PROT_WRITE, /* prot */ - MAP_SHARED, /* flags */ - dpy->FrameBufferFD, /* fd */ - dpy->FixedInfo.smem_len /* offset */); - if (dpy->driverContext.MMIOAddress == (caddr_t) - 1) { - fprintf(stderr, "error: unable to mmap mmio region: %s\n", - strerror(errno)); - return GL_FALSE; - } - - fprintf(stderr, "got MMIOAddress %p offset %d\n", - dpy->driverContext.MMIOAddress, - dpy->FixedInfo.smem_len); - - return GL_TRUE; -} - - - - -/** - * \brief Setup up the desired framebuffer device mode. - * - * \param dpy the display handle. - * - * \return GL_TRUE on success, or GL_FALSE on failure. - * - * \sa This is called during __miniglx_StartServer(). - * - * \internal - * - * Bumps the size of the window the the next supported mode. Sets the - * variable screen information according to the desired mode and asks - * the driver to validate the mode. Certifies that a DirectColor or - * TrueColor visual is used from the updated fixed screen information. - * In the case of DirectColor visuals, sets up an 'identity' colormap to - * mimic a TrueColor visual. - * - * Calls the driver hooks 'ValidateMode' and 'PostValidateMode' to - * allow the driver to make modifications to the chosen mode according - * to hardware constraints, or to save and restore videocard registers - * that may be clobbered by the fbdev driver. - * - * \todo Timings are hard-coded in the source for a set of supported modes. - */ -static GLboolean -SetupFBDev( Display *dpy ) -{ - int width, height; - - assert(dpy); - - width = dpy->driverContext.shared.virtualWidth; - height = dpy->driverContext.shared.virtualHeight; - - if (width==832) - width=800; -#if 0 - /* Bump size up to next supported mode. - */ - if (width <= 720 && height <= 480) { - width = 720; height = 480; - } - else if (width <= 960 && height <= 540) { - width = 960; height = 540; - } - else if (width <= 800 && height <= 600) { - width = 800; height = 600; - } - else if (width <= 1024 && height <= 768) { - width = 1024; height = 768; - } - else if (width <= 768 && height <= 1024) { - width = 768; height = 1024; - } - else if (width <= 1280 && height <= 1024) { - width = 1280; height = 1024; - } -#endif - - dpy->driverContext.shared.fbStride = width * (dpy->driverContext.bpp / 8); - - /* set the depth, resolution, etc */ - dpy->VarInfo = dpy->OrigVarInfo; - dpy->VarInfo.bits_per_pixel = dpy->driverContext.bpp; - dpy->VarInfo.xres_virtual = dpy->driverContext.shared.virtualWidth; - dpy->VarInfo.yres_virtual = dpy->driverContext.shared.virtualHeight; - dpy->VarInfo.xres = dpy->driverContext.shared.Width; - dpy->VarInfo.yres = height; - dpy->VarInfo.xoffset = 0; - dpy->VarInfo.yoffset = 0; - dpy->VarInfo.nonstd = 0; - dpy->VarInfo.vmode &= ~FB_VMODE_YWRAP; /* turn off scrolling */ - - if (dpy->VarInfo.bits_per_pixel == 32) { - dpy->VarInfo.red.offset = 16; - dpy->VarInfo.green.offset = 8; - dpy->VarInfo.blue.offset = 0; - dpy->VarInfo.transp.offset = 24; - dpy->VarInfo.red.length = 8; - dpy->VarInfo.green.length = 8; - dpy->VarInfo.blue.length = 8; - dpy->VarInfo.transp.length = 8; - } - else if (dpy->VarInfo.bits_per_pixel == 16) { - dpy->VarInfo.red.offset = 11; - dpy->VarInfo.green.offset = 5; - dpy->VarInfo.blue.offset = 0; - dpy->VarInfo.red.length = 5; - dpy->VarInfo.green.length = 6; - dpy->VarInfo.blue.length = 5; - dpy->VarInfo.transp.offset = 0; - dpy->VarInfo.transp.length = 0; - } - else { - fprintf(stderr, "Only 32bpp and 16bpp modes supported at the moment\n"); - return 0; - } - - if (!dpy->driver->validateMode( &dpy->driverContext )) { - fprintf(stderr, "Driver validateMode() failed\n"); - return 0; - } - - /* These should be calculated with the gtf.c program, and then we could - remove all this... AlanH. */ - if (dpy->VarInfo.xres == 1280 && - dpy->VarInfo.yres == 1024) { - /* timing values taken from /etc/fb.modes (1280x1024 @ 75Hz) */ - dpy->VarInfo.pixclock = 7408; - dpy->VarInfo.left_margin = 248; - dpy->VarInfo.right_margin = 16; - dpy->VarInfo.upper_margin = 38; - dpy->VarInfo.lower_margin = 1; - dpy->VarInfo.hsync_len = 144; - dpy->VarInfo.vsync_len = 3; - } - else if (dpy->VarInfo.xres == 1024 && - dpy->VarInfo.yres == 768) { - /* timing values taken from /etc/fb.modes (1024x768 @ 75Hz) */ - dpy->VarInfo.pixclock = 12699; - dpy->VarInfo.left_margin = 176; - dpy->VarInfo.right_margin = 16; - dpy->VarInfo.upper_margin = 28; - dpy->VarInfo.lower_margin = 1; - dpy->VarInfo.hsync_len = 96; - dpy->VarInfo.vsync_len = 3; - } - else if (dpy->VarInfo.xres == 800 && - dpy->VarInfo.yres == 600) { - /* timing values taken from /etc/fb.modes (800x600 @ 75Hz) */ - dpy->VarInfo.pixclock = 27778; - dpy->VarInfo.left_margin = 128; - dpy->VarInfo.right_margin = 24; - dpy->VarInfo.upper_margin = 22; - dpy->VarInfo.lower_margin = 1; - dpy->VarInfo.hsync_len = 72; - dpy->VarInfo.vsync_len = 2; - } - else if (dpy->VarInfo.xres == 720 && - dpy->VarInfo.yres == 480) { - dpy->VarInfo.pixclock = 37202; - dpy->VarInfo.left_margin = 88; - dpy->VarInfo.right_margin = 16; - dpy->VarInfo.upper_margin = 14; - dpy->VarInfo.lower_margin = 1; - dpy->VarInfo.hsync_len = 72; - dpy->VarInfo.vsync_len = 3; - } - else if (dpy->VarInfo.xres == 960 && - dpy->VarInfo.yres == 540) { - dpy->VarInfo.pixclock = 24273; - dpy->VarInfo.left_margin = 128; - dpy->VarInfo.right_margin = 32; - dpy->VarInfo.upper_margin = 16; - dpy->VarInfo.lower_margin = 1; - dpy->VarInfo.hsync_len = 96; - dpy->VarInfo.vsync_len = 3; - } - else if (dpy->VarInfo.xres == 768 && - dpy->VarInfo.yres == 1024) { - /* timing values for 768x1024 @ 75Hz */ - dpy->VarInfo.pixclock = 11993; - dpy->VarInfo.left_margin = 136; - dpy->VarInfo.right_margin = 32; - dpy->VarInfo.upper_margin = 41; - dpy->VarInfo.lower_margin = 1; - dpy->VarInfo.hsync_len = 80; - dpy->VarInfo.vsync_len = 3; - } - else { - /* XXX need timings for other screen sizes */ - fprintf(stderr, "XXXX screen size %d x %d not supported at this time!\n", - dpy->VarInfo.xres, dpy->VarInfo.yres); - return GL_FALSE; - } - - fprintf(stderr, "[miniglx] Setting mode: visible %dx%d virtual %dx%dx%d\n", - dpy->VarInfo.xres, dpy->VarInfo.yres, - dpy->VarInfo.xres_virtual, dpy->VarInfo.yres_virtual, - dpy->VarInfo.bits_per_pixel); - - /* set variable screen info */ - if (ioctl(dpy->FrameBufferFD, FBIOPUT_VSCREENINFO, &dpy->VarInfo)) { - fprintf(stderr, "error: ioctl(FBIOPUT_VSCREENINFO) failed: %s\n", - strerror(errno)); - return GL_FALSE; - } - - /* get the variable screen info, in case it has been modified */ - if (ioctl(dpy->FrameBufferFD, FBIOGET_VSCREENINFO, &dpy->VarInfo)) { - fprintf(stderr, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n", - strerror(errno)); - return GL_FALSE; - } - - - fprintf(stderr, "[miniglx] Readback mode: visible %dx%d virtual %dx%dx%d\n", - dpy->VarInfo.xres, dpy->VarInfo.yres, - dpy->VarInfo.xres_virtual, dpy->VarInfo.yres_virtual, - dpy->VarInfo.bits_per_pixel); - - /* Get the fixed screen info */ - if (ioctl(dpy->FrameBufferFD, FBIOGET_FSCREENINFO, &dpy->FixedInfo)) { - fprintf(stderr, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n", - strerror(errno)); - return GL_FALSE; - } - - if (dpy->FixedInfo.visual != FB_VISUAL_TRUECOLOR && - dpy->FixedInfo.visual != FB_VISUAL_DIRECTCOLOR) { - fprintf(stderr, "non-TRUECOLOR visuals not supported.\n"); - return GL_FALSE; - } - - if (dpy->FixedInfo.visual == FB_VISUAL_DIRECTCOLOR) { - struct fb_cmap cmap; - unsigned short red[256], green[256], blue[256]; - int rcols = 1 << dpy->VarInfo.red.length; - int gcols = 1 << dpy->VarInfo.green.length; - int bcols = 1 << dpy->VarInfo.blue.length; - int i; - - cmap.start = 0; - cmap.len = gcols; - cmap.red = red; - cmap.green = green; - cmap.blue = blue; - cmap.transp = NULL; - - for (i = 0; i < rcols ; i++) - red[i] = (65536/(rcols-1)) * i; - - for (i = 0; i < gcols ; i++) - green[i] = (65536/(gcols-1)) * i; - - for (i = 0; i < bcols ; i++) - blue[i] = (65536/(bcols-1)) * i; - - if (ioctl(dpy->FrameBufferFD, FBIOPUTCMAP, (void *) &cmap) < 0) { - fprintf(stderr, "ioctl(FBIOPUTCMAP) failed [%d]\n", i); - exit(1); - } - } - - /* May need to restore regs fbdev has clobbered: - */ - if (!dpy->driver->postValidateMode( &dpy->driverContext )) { - fprintf(stderr, "Driver postValidateMode() failed\n"); - return 0; - } - - return GL_TRUE; -} - - -/** - * \brief Restore the framebuffer device to state it was in before we started - * - * Undoes the work done by SetupFBDev(). - * - * \param dpy the display handle. - * - * \return GL_TRUE on success, or GL_FALSE on failure. - * - * \sa Called from XDestroyWindow(). - * - * \internal - * Restores the original variable screen info. - */ -static GLboolean -RestoreFBDev( Display *dpy ) -{ - /* restore original variable screen info */ - if (ioctl(dpy->FrameBufferFD, FBIOPUT_VSCREENINFO, &dpy->OrigVarInfo)) { - fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n", - strerror(errno)); - return GL_FALSE; - } - dpy->VarInfo = dpy->OrigVarInfo; - - return GL_TRUE; -} - - -/** - * \brief Close the framebuffer device. - * - * \param dpy the display handle. - * - * \sa Called from XCloseDisplay(). - * - * \internal - * Unmaps the framebuffer and MMIO region. Restores the text mode and the - * original virtual terminal. Closes the console and framebuffer devices. - */ -static void -CloseFBDev( Display *dpy ) -{ - struct vt_mode VT; - - munmap(dpy->driverContext.FBAddress, dpy->driverContext.FBSize); - munmap(dpy->driverContext.MMIOAddress, dpy->driverContext.MMIOSize); - - if (dpy->ConsoleFD) { - /* restore text mode */ - ioctl(dpy->ConsoleFD, KDSETMODE, KD_TEXT); - - /* set vt */ - if (ioctl(dpy->ConsoleFD, VT_GETMODE, &VT) != -1) { - VT.mode = VT_AUTO; - ioctl(dpy->ConsoleFD, VT_SETMODE, &VT); - } - - /* restore original vt */ - if (dpy->OriginalVT >= 0) { - ioctl(dpy->ConsoleFD, VT_ACTIVATE, dpy->OriginalVT); - dpy->OriginalVT = -1; - } - - close(dpy->ConsoleFD); - } - close(dpy->FrameBufferFD); -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Misc functions needed for DRI drivers */ -/**********************************************************************/ -/*@{*/ - -/** - * \brief Find the DRI screen dependent methods associated with the display. - * - * \param dpy a display handle, as returned by XOpenDisplay(). - * \param scrn the screen number. Not referenced. - * - * \returns a pointer to a __DRIscreenRec structure. - * - * \internal - * Returns the MiniGLXDisplayRec::driScreen attribute. - */ -static __DRIscreen * -__glXFindDRIScreen(__DRInativeDisplay *dpy, int scrn) -{ - (void) scrn; - return &((Display*)dpy)->driScreen; -} - -/** - * \brief Validate a drawable. - * - * \param dpy a display handle, as returned by XOpenDisplay(). - * \param draw drawable to validate. - * - * \internal - * Since Mini GLX only supports one window, compares the specified drawable with - * the MiniGLXDisplayRec::TheWindow attribute. - */ -static GLboolean -__glXWindowExists(__DRInativeDisplay *dpy, __DRIid draw) -{ - const Display * const display = (Display*)dpy; - if (display->TheWindow == (Window) draw) - return True; - else - return False; -} - -/** - * \brief Get current thread ID. - * - * \return thread ID. - * - * \internal - * Always returns 0. - */ -/*unsigned long -_glthread_GetID(void) -{ - return 0; -}*/ - -/*@}*/ - - -/** - * \brief Scan Linux /prog/bus/pci/devices file to determine hardware - * chipset based on supplied bus ID. - * - * \return probed chipset (non-zero) on success, zero otherwise. - * - * \internal - */ -static int get_chipset_from_busid( Display *dpy ) -{ - char buf[0x200]; - FILE *file; - const char *fname = "/proc/bus/pci/devices"; - int retval = 0; - - if (!(file = fopen(fname,"r"))) { - fprintf(stderr, "couldn't open %s: %s\n", fname, strerror(errno)); - return 0; - } - - while (fgets(buf, sizeof(buf)-1, file)) { - unsigned int nr, bus, dev, fn, vendor, device, encode; - nr = sscanf(buf, "%04x\t%04x%04x", &encode, - &vendor, &device); - - bus = encode >> 8; - dev = (encode & 0xFF) >> 3; - fn = encode & 0x7; - - if (nr != 3) - break; - - if (bus == dpy->driverContext.pciBus && - dev == dpy->driverContext.pciDevice && - fn == dpy->driverContext.pciFunc) { - retval = device; - break; - } - } - - fclose(file); - - if (retval) - fprintf(stderr, "[miniglx] probed chipset 0x%x\n", retval); - else - fprintf(stderr, "[miniglx] failed to probe chipset\n"); - - return retval; -} - - -/** - * \brief Read settings from a configuration file. - * - * The configuration file is usually "/etc/miniglx.conf", but can be overridden - * with the MINIGLX_CONF environment variable. - * - * The format consists in \code option = value \endcode lines. The option names - * corresponds to the fields in MiniGLXDisplayRec. - * - * \param dpy the display handle as. - * - * \return non-zero on success, zero otherwise. - * - * \internal - * Sets some defaults. Opens and parses the the Mini GLX configuration file and - * fills in the MiniGLXDisplayRec field that corresponds for each option. - */ -static int __read_config_file( Display *dpy ) -{ - FILE *file; - const char *fname; - - /* Fallback/defaults - */ - dpy->fbdevDevice = "/dev/fb0"; - dpy->clientDriverName = "fb_dri.so"; - dpy->driverContext.pciBus = 0; - dpy->driverContext.pciDevice = 0; - dpy->driverContext.pciFunc = 0; - dpy->driverContext.chipset = 0; - dpy->driverContext.pciBusID = 0; - dpy->driverContext.shared.virtualWidth = 1280; - dpy->driverContext.shared.virtualHeight = 1024; - dpy->driverContext.bpp = 32; - dpy->driverContext.cpp = 4; - dpy->rotateMode = 0; - dpy->driverContext.agpmode = 1; - dpy->driverContext.isPCI = 0; - dpy->driverContext.colorTiling = 0; - - fname = getenv("MINIGLX_CONF"); - if (!fname) fname = "/etc/miniglx.conf"; - - file = fopen(fname, "r"); - if (!file) { - fprintf(stderr, "couldn't open config file %s: %s\n", fname, strerror(errno)); - return 0; - } - - - while (!feof(file)) { - char buf[81], *opt = buf, *val, *tmp1, *tmp2; - fgets(buf, sizeof(buf), file); - - /* Parse 'opt = val' -- must be easier ways to do this. - */ - while (isspace(*opt)) opt++; - val = opt; - if (*val == '#') continue; /* comment */ - while (!isspace(*val) && *val != '=' && *val) val++; - tmp1 = val; - while (isspace(*val)) val++; - if (*val != '=') continue; - *tmp1 = 0; - val++; - while (isspace(*val)) val++; - tmp2 = val; - while (!isspace(*tmp2) && *tmp2 != '\n' && *tmp2) tmp2++; - *tmp2 = 0; - - - if (strcmp(opt, "fbdevDevice") == 0) - dpy->fbdevDevice = strdup(val); - else if (strcmp(opt, "clientDriverName") == 0) - dpy->clientDriverName = strdup(val); - else if (strcmp(opt, "rotateMode") == 0) - dpy->rotateMode = atoi(val) ? 1 : 0; - else if (strcmp(opt, "pciBusID") == 0) { - if (sscanf(val, "PCI:%d:%d:%d", - &dpy->driverContext.pciBus, - &dpy->driverContext.pciDevice, - &dpy->driverContext.pciFunc) != 3) { - fprintf(stderr, "malformed bus id: %s\n", val); - continue; - } - dpy->driverContext.pciBusID = strdup(val); - } - else if (strcmp(opt, "chipset") == 0) { - if (sscanf(val, "0x%x", &dpy->driverContext.chipset) != 1) - fprintf(stderr, "malformed chipset: %s\n", opt); - } - else if (strcmp(opt, "virtualWidth") == 0) { - if (sscanf(val, "%d", &dpy->driverContext.shared.virtualWidth) != 1) - fprintf(stderr, "malformed virtualWidth: %s\n", opt); - } - else if (strcmp(opt, "virtualHeight") == 0) { - if (sscanf(val, "%d", &dpy->driverContext.shared.virtualHeight) != 1) - fprintf(stderr, "malformed virutalHeight: %s\n", opt); - } - else if (strcmp(opt, "bpp") == 0) { - if (sscanf(val, "%d", &dpy->driverContext.bpp) != 1) - fprintf(stderr, "malformed bpp: %s\n", opt); - dpy->driverContext.cpp = dpy->driverContext.bpp / 8; - } - else if (strcmp(opt, "agpmode") == 0) { - if (sscanf(val, "%d", &dpy->driverContext.agpmode) != 1) - fprintf(stderr, "malformed agpmode: %s\n", opt); - } - else if (strcmp(opt, "isPCI") == 0) { - dpy->driverContext.isPCI = atoi(val) ? 1 : 0; - } - else if (strcmp(opt, "colorTiling") == 0) { - dpy->driverContext.colorTiling = atoi(val) ? 1 : 0; - } - } - - fclose(file); - - if (dpy->driverContext.chipset == 0 && dpy->driverContext.pciBusID != 0) - dpy->driverContext.chipset = get_chipset_from_busid( dpy ); - - return 1; -} - -/** - * Versioned name of the expected \c __driCreateNewScreen function. - * - * The version of the last incompatible loader/driver inteface change is - * appended to the name of the \c __driCreateNewScreen function. This - * prevents loaders from trying to load drivers that are too old. - * - * \todo - * Create a macro or something so that this is automatically updated. - */ -static const char createNewScreenName[] = "__driCreateNewScreen_20050727"; - - -static int InitDriver( Display *dpy ) -{ - /* - * Begin DRI setup. - * We're kind of combining the per-display and per-screen information - * which was kept separate in XFree86/DRI's libGL. - */ - dpy->dlHandle = dlopen(dpy->clientDriverName, RTLD_NOW | RTLD_GLOBAL); - if (!dpy->dlHandle) { - fprintf(stderr, "Unable to open %s: %s\n", dpy->clientDriverName, - dlerror()); - goto failed; - } - - /* Pull in Mini GLX specific hooks: - */ - dpy->driver = (struct DRIDriverRec *) dlsym(dpy->dlHandle, - "__driDriver"); - if (!dpy->driver) { - fprintf(stderr, "Couldn't find __driDriver in %s\n", - dpy->clientDriverName); - goto failed; - } - - /* Pull in standard DRI client-side driver hooks: - */ - dpy->createNewScreen = (PFNCREATENEWSCREENFUNC) - dlsym(dpy->dlHandle, createNewScreenName); - if (!dpy->createNewScreen) { - fprintf(stderr, "Couldn't find %s in %s\n", createNewScreenName, - dpy->clientDriverName); - goto failed; - } - - return GL_TRUE; - -failed: - if (dpy->dlHandle) { - dlclose(dpy->dlHandle); - dpy->dlHandle = 0; - } - return GL_FALSE; -} - - -/**********************************************************************/ -/** \name Public API functions (Xlib and GLX) */ -/**********************************************************************/ -/*@{*/ - - -/** - * \brief Initialize the graphics system. - * - * \param display_name currently ignored. It is recommended to pass it as NULL. - * \return a pointer to a #Display if the function is able to initialize - * the graphics system, NULL otherwise. - * - * Allocates a MiniGLXDisplayRec structure and fills in with information from a - * configuration file. - * - * Calls OpenFBDev() to open the framebuffer device and calls - * DRIDriverRec::initFBDev to do the client-side initialization on it. - * - * Loads the DRI driver and pulls in Mini GLX specific hooks into a - * DRIDriverRec structure, and the standard DRI \e __driCreateScreen hook. - * Asks the driver for a list of supported visuals. Performs the per-screen - * client-side initialization. Also setups the callbacks in the screen private - * information. - * - * Does the framebuffer device setup. Calls __miniglx_open_connections() to - * serve clients. - */ -Display * -__miniglx_StartServer( const char *display_name ) -{ - Display *dpy; - int use_vt = 0; - - pci_system_init(); - - dpy = (Display *)calloc(1, sizeof(Display)); - if (!dpy) - return NULL; - - dpy->IsClient = False; - - if (!__read_config_file( dpy )) { - fprintf(stderr, "Couldn't get configuration details\n"); - free(dpy); - return NULL; - } - - /* Open the fbdev device - */ - if (!OpenFBDev(dpy, use_vt)) { - fprintf(stderr, "OpenFBDev failed\n"); - free(dpy); - return NULL; - } - - if (!InitDriver(dpy)) { - fprintf(stderr, "InitDriver failed\n"); - free(dpy); - return NULL; - } - - /* Perform the initialization normally done in the X server - */ - if (!dpy->driver->initFBDev( &dpy->driverContext )) { - fprintf(stderr, "%s: __driInitFBDev failed\n", __FUNCTION__); - dlclose(dpy->dlHandle); - return GL_FALSE; - } - - /* do fbdev setup - */ - if (!SetupFBDev(dpy)) { - fprintf(stderr, "SetupFBDev failed\n"); - free(dpy); - return NULL; - } - - /* unlock here if not using VT -- JDS */ - if (!use_vt) { - if (dpy->driver->restoreHardware) - dpy->driver->restoreHardware( &dpy->driverContext ); - DRM_UNLOCK( dpy->driverContext.drmFD, - dpy->driverContext.pSAREA, - dpy->driverContext.serverContext ); - dpy->hwActive = 1; - } - - /* Ready for clients: - */ - if (!__miniglx_open_connections(dpy)) { - free(dpy); - return NULL; - } - - return dpy; -} - - -/** - * Implement \c __DRIinterfaceMethods::getProcAddress. - */ -static __DRIfuncPtr get_proc_address( const char * proc_name ) -{ - (void) proc_name; - return NULL; -} - - -/** - * Table of functions exported by the loader to the driver. - */ -static const __DRIinterfaceMethods interface_methods = { - get_proc_address, - - _gl_context_modes_create, - _gl_context_modes_destroy, - - __glXFindDRIScreen, - __glXWindowExists, - - __glXCreateContextWithConfig, - xf86DRI_DestroyContext, - - xf86DRI_CreateDrawable, - xf86DRI_DestroyDrawable, - __glXGetDrawableInfo, - - __glXGetUST, - __glXGetMscRate, -}; - - -static void * -CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc) -{ - void *psp = NULL; - drm_handle_t hSAREA; - drmAddress pSAREA; - const char *BusID; - int i; - __DRIversion ddx_version; - __DRIversion dri_version; - __DRIversion drm_version; - __DRIframebuffer framebuffer; - int fd = -1; - int status; - const char * err_msg; - const char * err_extra; - drmVersionPtr version; - drm_handle_t hFB; - drm_magic_t magic; - - - hSAREA = dpy->driverContext.shared.hSAREA; - BusID = dpy->driverContext.pciBusID; - - fd = drmOpen(NULL, BusID); - - err_msg = "open DRM"; - err_extra = strerror( -fd ); - - if (fd < 0) goto done; - - err_msg = "drmGetMagic"; - err_extra = NULL; - - if (drmGetMagic(fd, &magic)) goto done; - - dpy->authorized = False; - send_char_msg( dpy, 0, _Authorize ); - send_msg( dpy, 0, &magic, sizeof(magic)); - - /* force net buffer flush */ - while (!dpy->authorized) - handle_fd_events( dpy, 0 ); - - version = drmGetVersion(fd); - if (version) { - drm_version.major = version->version_major; - drm_version.minor = version->version_minor; - drm_version.patch = version->version_patchlevel; - drmFreeVersion(version); - } - else { - drm_version.major = -1; - drm_version.minor = -1; - drm_version.patch = -1; - } - - /* - * Get device name (like "tdfx") and the ddx version numbers. - * We'll check the version in each DRI driver's "createScreen" - * function. - */ - ddx_version.major = -1; - ddx_version.minor = 0; - ddx_version.patch = 0; - - /* - * Get the DRI X extension version. - */ - dri_version.major = 4; - dri_version.minor = 0; - dri_version.patch = 0; - - /* - * Get device-specific info. pDevPriv will point to a struct - * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) - * that has information about the screen size, depth, pitch, - * ancilliary buffers, DRM mmap handles, etc. - */ - hFB = dpy->driverContext.shared.hFrameBuffer; - framebuffer.size = dpy->driverContext.shared.fbSize; - framebuffer.stride = dpy->driverContext.shared.fbStride; - framebuffer.dev_priv_size = dpy->driverContext.driverClientMsgSize; - framebuffer.dev_priv = dpy->driverContext.driverClientMsg; - framebuffer.width = dpy->driverContext.shared.virtualWidth; - framebuffer.height = dpy->driverContext.shared.virtualHeight; - - /* - * Map the framebuffer region. - */ - status = drmMap(fd, hFB, framebuffer.size, - (drmAddressPtr)&framebuffer.base); - - err_msg = "drmMap of framebuffer"; - err_extra = strerror( -status ); - - if ( status != 0 ) goto done; - - /* - * Map the SAREA region. Further mmap regions may be setup in - * each DRI driver's "createScreen" function. - */ - status = drmMap(fd, hSAREA, SAREA_MAX, &pSAREA); - - err_msg = "drmMap of sarea"; - err_extra = strerror( -status ); - - if ( status == 0 ) { - err_msg = "InitDriver"; - err_extra = NULL; - psp = dpy->createNewScreen(dpy, scrn, psc, NULL, - & ddx_version, - & dri_version, - & drm_version, - & framebuffer, - pSAREA, - fd, - 20050727, - & interface_methods, - (__GLcontextModes **) &dpy->driver_modes); - - /* fill in dummy visual ids */ - { - __GLcontextModes *temp; - temp = (__GLcontextModes *)dpy->driver_modes; - i = 1; - while (temp) - { - temp->visualID = i++; - temp=temp->next; - } - } - } - -done: - if ( psp == NULL ) { - if ( pSAREA != MAP_FAILED ) { - (void)drmUnmap(pSAREA, SAREA_MAX); - } - - if ( framebuffer.base != MAP_FAILED ) { - (void)drmUnmap((drmAddress)framebuffer.base, framebuffer.size); - } - - if ( framebuffer.dev_priv != NULL ) { - free(framebuffer.dev_priv); - } - - if ( fd >= 0 ) { - (void)drmClose(fd); - } - - if ( err_extra != NULL ) { - fprintf(stderr, "libGL error: %s failed (%s)\n", err_msg, - err_extra); - } - else { - fprintf(stderr, "libGL error: %s failed\n", err_msg ); - } - - fprintf(stderr, "libGL error: reverting to (slow) indirect rendering\n"); - } - - return psp; -} - -/** - * \brief Initialize the graphics system. - * - * \param display_name currently ignored. It is recommended to pass it as NULL. - * \return a pointer to a #Display if the function is able to initialize - * the graphics system, NULL otherwise. - * - * Allocates a MiniGLXDisplayRec structure and fills in with information from a - * configuration file. - * - * Calls __miniglx_open_connections() to connect to the server. - * - * Loads the DRI driver and pulls in Mini GLX specific hooks into a - * DRIDriverRec structure, and the standard DRI \e __driCreateScreen hook. - * Asks the driver for a list of supported visuals. Performs the per-screen - * client-side initialization. Also setups the callbacks in the screen private - * information. - * - * \todo - * - read config file - * - what about virtualWidth, etc? - * - determine dpy->driverClientMsgSize, - * - allocate dpy->driverClientMsg - */ -Display * -XOpenDisplay( const char *display_name ) -{ - Display *dpy; - - dpy = (Display *)calloc(1, sizeof(Display)); - if (!dpy) - return NULL; - - dpy->IsClient = True; - - /* read config file - */ - if (!__read_config_file( dpy )) { - fprintf(stderr, "Couldn't get configuration details\n"); - free(dpy); - return NULL; - } - - /* Connect to the server and receive driverClientMsg - */ - if (!__miniglx_open_connections(dpy)) { - free(dpy); - return NULL; - } - - /* dlopen the driver .so file - */ - if (!InitDriver(dpy)) { - fprintf(stderr, "InitDriver failed\n"); - free(dpy); - return NULL; - } - - /* Perform the client-side initialization. - * - * Clearly there is a limit of one on the number of windows in - * existence at any time. - * - * Need to shut down DRM and free DRI data in XDestroyWindow(), too. - */ - dpy->driScreen.private = CallCreateNewScreen(dpy, 0, &dpy->driScreen); - if (!dpy->driScreen.private) { - fprintf(stderr, "%s: __driCreateScreen failed\n", __FUNCTION__); - dlclose(dpy->dlHandle); - free(dpy); - return NULL; - } - - /* Anything more to do? - */ - return dpy; -} - - -/** - * \brief Release display resources. - * - * When the application is about to exit, the resources associated with the - * graphics system can be released by calling this function. - * - * \param dpy display handle. It becomes invalid at this point. - * - * Destroys the window if any, and destroys the per-screen - * driver private information. - * Calls __miniglx_close_connections(). - * - * If a server, puts the the framebuffer back into the initial state. - * - * Finally frees the display structure. - */ -void -XCloseDisplay( Display *dpy ) -{ - glXMakeCurrent( dpy, NULL, NULL); - - if (dpy->NumWindows) - XDestroyWindow( dpy, dpy->TheWindow ); - - /* As this is done in XOpenDisplay, need to undo it here: - */ - dpy->driScreen.destroyScreen(dpy, 0, dpy->driScreen.private); - - __miniglx_close_connections( dpy ); - - if (!dpy->IsClient) { - /* put framebuffer back to initial state - */ - (*dpy->driver->haltFBDev)( &dpy->driverContext ); - RestoreFBDev(dpy); - CloseFBDev(dpy); - } - - dlclose(dpy->dlHandle); - free(dpy); -} - - -/** - * \brief Window creation. - * - * \param display a display handle, as returned by XOpenDisplay(). - * \param parent the parent window for the new window. For Mini GLX this should - * be - * \code RootWindow(display, 0) \endcode - * \param x the window abscissa. For Mini GLX, it should be zero. - * \param y the window ordinate. For Mini GLX, it should be zero. - * \param width the window width. For Mini GLX, this specifies the desired - * screen width such as 1024 or 1280. - * \param height the window height. For Mini GLX, this specifies the desired - * screen height such as 768 or 1024. - * \param border_width the border width. For Mini GLX, it should be zero. - * \param depth the window pixel depth. For Mini GLX, this should be the depth - * found in the #XVisualInfo object returned by glXChooseVisual() - * \param winclass the window class. For Mini GLX this value should be - * #InputOutput. - * \param visual the visual type. It should be the visual field of the - * #XVisualInfo object returned by glXChooseVisual(). - * \param valuemask which fields of the XSetWindowAttributes() are to be used. - * For Mini GLX this is typically the bitmask - * \code CWBackPixel | CWBorderPixel | CWColormap \endcode - * \param attributes initial window attributes. The - * XSetWindowAttributes::background_pixel, XSetWindowAttributes::border_pixel - * and XSetWindowAttributes::colormap fields should be set. - * - * \return a window handle if it succeeds or zero if it fails. - * - * \note For Mini GLX, windows are full-screen; they cover the entire frame - * buffer. Also, Mini GLX imposes a limit of one window. A second window - * cannot be created until the first one is destroyed. - * - * This function creates and initializes a ::MiniGLXWindowRec structure after - * ensuring that there is no other window created. Performs the per-drawable - * client-side initialization calling the __DRIscreenRec::createDrawable - * method. - * - */ -Window -XCreateWindow( Display *dpy, Window parent, int x, int y, - unsigned int width, unsigned int height, - unsigned int border_width, int depth, unsigned int winclass, - Visual *visual, unsigned long valuemask, - XSetWindowAttributes *attributes ) -{ - const int empty_attribute_list[1] = { None }; - - Window win; - - /* ignored */ - (void) x; - (void) y; - (void) border_width; - (void) depth; - (void) winclass; - (void) valuemask; - (void) attributes; - - if (!dpy->IsClient) { - fprintf(stderr, "Server process may not create windows (currently)\n"); - return NULL; - } - - if (dpy->NumWindows > 0) - return NULL; /* only allow one window */ - - assert(dpy->TheWindow == NULL); - - win = malloc(sizeof(struct MiniGLXWindowRec)); - if (!win) - return NULL; - - /* In rotated mode, translate incoming x,y,width,height into - * 'normal' coordinates. - */ - if (dpy->rotateMode) { - int tmp; - tmp = width; width = height; height = tmp; - tmp = x; x = y; y = tmp; - } - - /* init other per-window fields */ - win->x = x; - win->y = y; - win->w = width; - win->h = height; - win->visual = visual; /* ptr assignment */ - - win->bytesPerPixel = dpy->driverContext.cpp; - win->rowStride = dpy->driverContext.shared.virtualWidth * win->bytesPerPixel; - win->size = win->rowStride * height; - win->frontStart = dpy->driverContext.FBAddress + (win->rowStride * win->x) + (win->y * win->bytesPerPixel); - win->frontBottom = (GLubyte *) win->frontStart + (height-1) * win->rowStride; - - /* This is incorrect: the hardware driver could put the backbuffer - * just about anywhere. These fields, including the above are - * hardware dependent & don't really belong here. - */ - if (visual->mode->doubleBufferMode) { - win->backStart = (GLubyte *) win->frontStart + - win->rowStride * dpy->driverContext.shared.virtualHeight; - win->backBottom = (GLubyte *) win->backStart - + (height - 1) * win->rowStride; - win->curBottom = win->backBottom; - } - else { - /* single buffered */ - win->backStart = NULL; - win->backBottom = NULL; - win->curBottom = win->frontBottom; - } - - dpy->driScreen.createNewDrawable(dpy, visual->mode, (int) win, - &win->driDrawable, GLX_WINDOW_BIT, empty_attribute_list); - - if (!win->driDrawable.private) { - fprintf(stderr, "%s: dri.createDrawable failed\n", __FUNCTION__); - free(win); - return NULL; - } - - dpy->NumWindows++; - dpy->TheWindow = win; - - return win; -} - - -/** - * \brief Destroy window. - * - * \param display display handle. - * \param w window handle. - * - * This function calls XUnmapWindow() and frees window \p w. - * - * In case of destroying the current buffer first unbinds the GLX context - * by calling glXMakeCurrent() with no drawable. - */ -void -XDestroyWindow( Display *display, Window win ) -{ - if (display && display->IsClient && win) { - /* check if destroying the current buffer */ - Window curDraw = glXGetCurrentDrawable(); - if (win == curDraw) { - glXMakeCurrent( display, NULL, NULL); - } - - XUnmapWindow( display, win ); - - /* Destroy the drawable. */ - win->driDrawable.destroyDrawable(display, win->driDrawable.private); - free(win); - - /* unlink window from display */ - display->NumWindows--; - assert(display->NumWindows == 0); - display->TheWindow = NULL; - } -} - - - - -/** - * \brief Create color map structure. - * - * \param dpy the display handle as returned by XOpenDisplay(). - * \param w the window on whose screen you want to create a color map. This - * parameter is ignored by Mini GLX but should be the value returned by the - * \code RootWindow(display, 0) \endcode macro. - * \param visual a visual type supported on the screen. This parameter is - * ignored by Mini GLX but should be the XVisualInfo::visual returned by - * glXChooseVisual(). - * \param alloc the color map entries to be allocated. This parameter is ignored - * by Mini GLX but should be set to #AllocNone. - * - * \return the color map. - * - * This function is only provided to ease porting. Practically a no-op - - * returns a pointer to a dynamically allocated chunk of memory (one byte). - */ -Colormap -XCreateColormap( Display *dpy, Window w, Visual *visual, int alloc ) -{ - (void) dpy; - (void) w; - (void) visual; - (void) alloc; - return (Colormap) malloc(1); -} - - -/** - * \brief Destroy color map structure. - * - * \param display The display handle as returned by XOpenDisplay(). - * \param colormap the color map to destroy. - * - * This function is only provided to ease porting. Practically a no-op. - * - * Frees the memory pointed by \p colormap. - */ -void -XFreeColormap( Display *display, Colormap colormap ) -{ - (void) display; - (void) colormap; - free(colormap); -} - - -/** - * \brief Free client data. - * - * \param data the data that is to be freed. - * - * Frees the memory pointed by \p data. - */ -void -XFree( void *data ) -{ - free(data); -} - - -/** - * \brief Query available visuals. - * - * \param dpy the display handle, as returned by XOpenDisplay(). - * \param vinfo_mask a bitmask indicating which fields of the \p vinfo_template - * are to be matched. The value must be \c VisualScreenMask. - * \param vinfo_template a template whose fields indicate which visual - * attributes must be matched by the results. The XVisualInfo::screen field of - * this structure must be zero. - * \param nitens_return will hold the number of visuals returned. - * - * \return the address of an array of all available visuals. - * - * An example of using XGetVisualInfo() to get all available visuals follows: - * - * \code - * XVisualInfo vinfo_template, *results; - * int nitens_return; - * Display *dpy = XOpenDisplay(NULL); - * vinfo_template.screen = 0; - * results = XGetVisualInfo(dpy, VisualScreenMask, &vinfo_template, &nitens_return); - * \endcode - * - * Returns the list of all ::XVisualInfo available, one per - * ::__GLcontextMode stored in MiniGLXDisplayRec::modes. - */ -XVisualInfo * -XGetVisualInfo( Display *dpy, long vinfo_mask, XVisualInfo *vinfo_template, int *nitens_return ) -{ - const __GLcontextModes *mode; - XVisualInfo *results; - Visual *visResults; - int i, n=0; - - // ASSERT(vinfo_mask == VisualScreenMask); - ASSERT(vinfo_template.screen == 0); - - if (vinfo_mask == VisualIDMask) - { - for ( mode = dpy->driver_modes ; mode != NULL ; mode= mode->next ) - if (mode->visualID == vinfo_template->visualid) - n=1; - - if (n==0) - return NULL; - - results = (XVisualInfo *)calloc(1, n * sizeof(XVisualInfo)); - if (!results) { - *nitens_return = 0; - return NULL; - } - - visResults = (Visual *)calloc(1, n * sizeof(Visual)); - if (!results) { - free(results); - *nitens_return = 0; - return NULL; - } - - for ( mode = dpy->driver_modes ; mode != NULL ; mode= mode->next ) - if (mode->visualID == vinfo_template->visualid) - { - visResults[0].mode=mode; - visResults[0].visInfo = results; - visResults[0].dpy = dpy; - if (dpy->driverContext.bpp == 32) - visResults[0].pixelFormat = PF_B8G8R8A8; /* XXX: FIX ME */ - else - visResults[0].pixelFormat = PF_B5G6R5; /* XXX: FIX ME */ - - results[0].visual = visResults; - results[0].visualid = mode->visualID; -#if defined(__cplusplus) || defined(c_plusplus) - results[0].c_class = TrueColor; -#else - results[0].class = TrueColor; -#endif - results[0].depth = mode->redBits + - mode->redBits + - mode->redBits + - mode->redBits; - results[0].bits_per_rgb = dpy->driverContext.bpp; - - } - - } - else // if (vinfo_mask == VisualScreenMask) - { - n = 0; - for ( mode = dpy->driver_modes ; mode != NULL ; mode = mode->next ) - n++; - - results = (XVisualInfo *)calloc(1, n * sizeof(XVisualInfo)); - if (!results) { - *nitens_return = 0; - return NULL; - } - - visResults = (Visual *)calloc(1, n * sizeof(Visual)); - if (!results) { - free(results); - *nitens_return = 0; - return NULL; - } - - for ( mode = dpy->driver_modes, i = 0 ; mode != NULL ; mode = mode->next, i++ ) { - visResults[i].mode = mode; - visResults[i].visInfo = results + i; - visResults[i].dpy = dpy; - - if (dpy->driverContext.bpp == 32) - visResults[i].pixelFormat = PF_B8G8R8A8; /* XXX: FIX ME */ - else - visResults[i].pixelFormat = PF_B5G6R5; /* XXX: FIX ME */ - - results[i].visual = visResults + i; - results[i].visualid = mode->visualID; -#if defined(__cplusplus) || defined(c_plusplus) - results[i].c_class = TrueColor; -#else - results[i].class = TrueColor; -#endif - results[i].depth = mode->redBits + - mode->redBits + - mode->redBits + - mode->redBits; - results[i].bits_per_rgb = dpy->driverContext.bpp; - } - } - *nitens_return = n; - return results; -} - - -/** - * \brief Return a visual that matches specified attributes. - * - * \param dpy the display handle, as returned by XOpenDisplay(). - * \param screen the screen number. It is currently ignored by Mini GLX and - * should be zero. - * \param attribList a list of GLX attributes which describe the desired pixel - * format. It is terminated by the token \c None. - * - * The attributes are as follows: - * \arg GLX_USE_GL: - * This attribute should always be present in order to maintain compatibility - * with GLX. - * \arg GLX_RGBA: - * If present, only RGBA pixel formats will be considered. Otherwise, only - * color index formats are considered. - * \arg GLX_DOUBLEBUFFER: - * if present, only double-buffered pixel formats will be chosen. - * \arg GLX_RED_SIZE \e n: - * Must be followed by a non-negative integer indicating the minimum number of - * bits per red pixel component that is acceptable. - * \arg GLX_GREEN_SIZE \e n: - * Must be followed by a non-negative integer indicating the minimum number of - * bits per green pixel component that is acceptable. - * \arg GLX_BLUE_SIZE \e n: - * Must be followed by a non-negative integer indicating the minimum number of - * bits per blue pixel component that is acceptable. - * \arg GLX_ALPHA_SIZE \e n: - * Must be followed by a non-negative integer indicating the minimum number of - * bits per alpha pixel component that is acceptable. - * \arg GLX_STENCIL_SIZE \e n: - * Must be followed by a non-negative integer indicating the minimum number of - * bits per stencil value that is acceptable. - * \arg GLX_DEPTH_SIZE \e n: - * Must be followed by a non-negative integer indicating the minimum number of - * bits per depth component that is acceptable. - * \arg None: - * This token is used to terminate the attribute list. - * - * \return a pointer to an #XVisualInfo object which most closely matches the - * requirements of the attribute list. If there is no visual which matches the - * request, \c NULL will be returned. - * - * \note Visuals with accumulation buffers are not available. - * - * This function searches the list of available visual configurations in - * MiniGLXDisplayRec::configs for a configuration which best matches the GLX - * attribute list parameter. A new ::XVisualInfo object is created which - * describes the visual configuration. The match criteria is described in the - * specification. - */ -XVisualInfo* -glXChooseVisual( Display *dpy, int screen, int *attribList ) -{ - const __GLcontextModes *mode; - Visual *vis; - XVisualInfo *visInfo; - const int *attrib; - GLboolean rgbFlag = GL_FALSE, dbFlag = GL_FALSE, stereoFlag = GL_FALSE; - GLint redBits = 0, greenBits = 0, blueBits = 0, alphaBits = 0; - GLint indexBits = 0, depthBits = 0, stencilBits = 0; - GLint numSamples = 0; - int i=0; - - /* - * XXX in the future, might be interpreted as a VT - */ - ASSERT(dpy); - ASSERT(screen == 0); - - vis = (Visual *)calloc(1, sizeof(Visual)); - if (!vis) - return NULL; - - visInfo = (XVisualInfo *)malloc(sizeof(XVisualInfo)); - if (!visInfo) { - free(vis); - return NULL; - } - - visInfo->visual = vis; - vis->visInfo = visInfo; - vis->dpy = dpy; - - /* parse the attribute list */ - for (attrib = attribList; attrib && *attrib != None; attrib++) { - switch (attrib[0]) { - case GLX_DOUBLEBUFFER: - dbFlag = GL_TRUE; - break; - case GLX_RGBA: - rgbFlag = GL_TRUE; - break; - case GLX_RED_SIZE: - redBits = attrib[1]; - attrib++; - break; - case GLX_GREEN_SIZE: - greenBits = attrib[1]; - attrib++; - break; - case GLX_BLUE_SIZE: - blueBits = attrib[1]; - attrib++; - break; - case GLX_ALPHA_SIZE: - alphaBits = attrib[1]; - attrib++; - break; - case GLX_STENCIL_SIZE: - stencilBits = attrib[1]; - attrib++; - break; - case GLX_DEPTH_SIZE: - depthBits = attrib[1]; - attrib++; - break; -#if 0 - case GLX_ACCUM_RED_SIZE: - accumRedBits = attrib[1]; - attrib++; - break; - case GLX_ACCUM_GREEN_SIZE: - accumGreenBits = attrib[1]; - attrib++; - break; - case GLX_ACCUM_BLUE_SIZE: - accumBlueBits = attrib[1]; - attrib++; - break; - case GLX_ACCUM_ALPHA_SIZE: - accumAlphaBits = attrib[1]; - attrib++; - break; - case GLX_LEVEL: - /* ignored for now */ - break; -#endif - default: - /* unexpected token */ - fprintf(stderr, "unexpected token in glXChooseVisual attrib list\n"); - free(vis); - free(visInfo); - return NULL; - } - } - - /* search screen configs for suitable visual */ - (void) numSamples; - (void) indexBits; - (void) redBits; - (void) greenBits; - (void) blueBits; - (void) alphaBits; - (void) stereoFlag; - for ( mode = dpy->driver_modes ; mode != NULL ; mode = mode->next ) { - i++; - if (mode->rgbMode == rgbFlag && - mode->doubleBufferMode == dbFlag && - mode->redBits >= redBits && - mode->greenBits >= greenBits && - mode->blueBits >= blueBits && - mode->alphaBits >= alphaBits && - mode->depthBits >= depthBits && - mode->stencilBits >= stencilBits) { - /* found it */ - visInfo->visualid = i; - vis->mode = mode; - break; - } - } - if (!vis->mode) - return NULL; - - /* compute depth and bpp */ - if (rgbFlag) { - /* XXX maybe support depth 16 someday */ -#if defined(__cplusplus) || defined(c_plusplus) - visInfo->c_class = TrueColor; -#else - visInfo->class = TrueColor; -#endif - visInfo->depth = dpy->driverContext.bpp; - visInfo->bits_per_rgb = dpy->driverContext.bpp; - if (dpy->driverContext.bpp == 32) - vis->pixelFormat = PF_B8G8R8A8; - else - vis->pixelFormat = PF_B5G6R5; - } - else { - /* color index mode */ -#if defined(__cplusplus) || defined(c_plusplus) - visInfo->c_class = PseudoColor; -#else - visInfo->class = PseudoColor; -#endif - visInfo->depth = 8; - visInfo->bits_per_rgb = 8; /* bits/pixel */ - vis->pixelFormat = PF_CI8; - } - - return visInfo; -} - - -/** - * \brief Return information about GLX visuals. - * - * \param dpy the display handle, as returned by XOpenDisplay(). - * \param vis the visual to be queried, as returned by glXChooseVisual(). - * \param attrib the visual attribute to be returned. - * \param value pointer to an integer in which the result of the query will be - * stored. - * - * \return zero if no error occurs, \c GLX_INVALID_ATTRIBUTE if the attribute - * parameter is invalid, or \c GLX_BAD_VISUAL if the \p vis parameter is - * invalid. - * - * Returns the appropriate attribute of ::__GLXvisualConfig pointed by - * MiniGLXVisualRec::glxConfig of XVisualInfo::visual. - * - * \sa data types. - */ -int -glXGetConfig( Display *dpy, XVisualInfo *vis, int attrib, int *value ) -{ - const __GLcontextModes *mode = vis->visual->mode; - if (!mode) { - *value = 0; - return GLX_BAD_VISUAL; - } - - switch (attrib) { - case GLX_USE_GL: - *value = True; - return 0; - case GLX_RGBA: - *value = mode->rgbMode; - return 0; - case GLX_DOUBLEBUFFER: - *value = mode->doubleBufferMode; - return 0; - case GLX_RED_SIZE: - *value = mode->redBits; - return 0; - case GLX_GREEN_SIZE: - *value = mode->greenBits; - return 0; - case GLX_BLUE_SIZE: - *value = mode->blueBits; - return 0; - case GLX_ALPHA_SIZE: - *value = mode->alphaBits; - return 0; - case GLX_DEPTH_SIZE: - *value = mode->depthBits; - return 0; - case GLX_STENCIL_SIZE: - *value = mode->stencilBits; - return 0; - default: - *value = 0; - return GLX_BAD_ATTRIBUTE; - } - return 0; -} - - -/** - * \brief Create a new GLX rendering context. - * - * \param dpy the display handle, as returned by XOpenDisplay(). - * \param vis the visual that defines the frame buffer resources available to - * the rendering context, as returned by glXChooseVisual(). - * \param shareList If non-zero, texture objects and display lists are shared - * with the named rendering context. If zero, texture objects and display lists - * will (initially) be private to this context. They may be shared when a - * subsequent context is created. - * \param direct whether direct or indirect rendering is desired. For Mini GLX - * this value is ignored but it should be set to \c True. - * - * \return a ::GLXContext handle if it succeeds or zero if it fails due to - * invalid parameter or insufficient resources. - * - * This function creates and initializes a ::MiniGLXContextRec structure and - * calls the __DRIscreenRec::createContext method to initialize the client - * private data. - */ -GLXContext -glXCreateContext( Display *dpy, XVisualInfo *vis, - GLXContext shareList, Bool direct ) -{ - GLXContext ctx; - void *sharePriv; - - ASSERT(vis); - - ctx = (struct MiniGLXContextRec *)calloc(1, sizeof(struct MiniGLXContextRec)); - if (!ctx) - return NULL; - - ctx->vid = vis->visualid; - - if (shareList) - sharePriv = shareList->driContext.private; - else - sharePriv = NULL; - - ctx->driContext.mode = vis->visual->mode; - ctx->driContext.private = dpy->driScreen.createNewContext(dpy, vis->visual->mode, - GLX_WINDOW_BIT, sharePriv, &ctx->driContext); - - if (!ctx->driContext.private) { - free(ctx); - return NULL; - } - - return ctx; -} - - -/** - * \brief Destroy a GLX context. - * - * \param dpy the display handle, as returned by XOpenDisplay(). - * \param ctx the GLX context to be destroyed. - * - * This function frees the \p ctx parameter after unbinding the current context - * by calling the __DRIcontextRec::bindContext method with zeros and calling - * the __DRIcontextRec::destroyContext method. - */ -void -glXDestroyContext( Display *dpy, GLXContext ctx ) -{ - GLXContext glxctx = glXGetCurrentContext(); - - if (ctx) { - if (glxctx == ctx) { - /* destroying current context */ - ctx->driContext.bindContext(dpy, 0, 0, 0, 0); - CurrentContext = 0; - } - ctx->driContext.destroyContext(dpy, 0, ctx->driContext.private); - free(ctx); - } -} - - -/** - * \brief Bind a GLX context to a window or a pixmap. - * - * \param dpy the display handle, as returned by XOpenDisplay(). - * \param drawable the window or drawable to bind to the rendering context. - * This should be the value returned by XCreateWindow(). - * \param ctx the GLX context to be destroyed. - * - * \return \c True if it succeeds, \c False otherwise to indicate an invalid - * display, window or context parameter. - * - * The current rendering context may be unbound by calling glXMakeCurrent() - * with the window and context parameters set to zero. - * - * An application may create any number of rendering contexts and bind them as - * needed. Note that binding a rendering context is generally not a - * light-weight operation. Most simple OpenGL applications create only one - * rendering context. - * - * This function first unbinds any old context via - * __DRIcontextRec::unbindContext and binds the new one via - * __DRIcontextRec::bindContext. - * - * If \p drawable is zero it unbinds the GLX context by calling - * __DRIcontextRec::bindContext with zeros. - */ -Bool -glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx) -{ - if (dpy && drawable && ctx) { - GLXContext oldContext = glXGetCurrentContext(); - GLXDrawable oldDrawable = glXGetCurrentDrawable(); - /* unbind old */ - if (oldContext) { - oldContext->driContext.unbindContext(dpy, 0, - (__DRIid) oldDrawable, (__DRIid) oldDrawable, - &oldContext->driContext); - } - /* bind new */ - CurrentContext = ctx; - ctx->driContext.bindContext(dpy, 0, (__DRIid) drawable, - (__DRIid) drawable, &ctx->driContext); - ctx->drawBuffer = drawable; - ctx->curBuffer = drawable; - } - else if (ctx && dpy) { - /* unbind */ - ctx->driContext.bindContext(dpy, 0, 0, 0, 0); - } - else if (dpy) { - CurrentContext = 0; /* kw: this seems to be intended??? */ - } - - return True; -} - - -/** - * \brief Exchange front and back buffers. - * - * \param dpy the display handle, as returned by XOpenDisplay(). - * \param drawable the drawable whose buffers are to be swapped. - * - * Any pending rendering commands will be completed before the buffer swap - * takes place. - * - * Calling glXSwapBuffers() on a window which is single-buffered has no effect. - * - * This function just calls the __DRIdrawableRec::swapBuffers method to do the - * work. - */ -void -glXSwapBuffers( Display *dpy, GLXDrawable drawable ) -{ - if (!dpy || !drawable) - return; - - drawable->driDrawable.swapBuffers(dpy, drawable->driDrawable.private); -} - - -/** - * \brief Return the current context - * - * \return the current context, as specified by glXMakeCurrent(), or zero if no - * context is currently bound. - * - * \sa glXCreateContext(), glXMakeCurrent() - * - * Returns the value of the ::CurrentContext global variable. - */ -GLXContext -glXGetCurrentContext( void ) -{ - return CurrentContext; -} - - -/** - * \brief Return the current drawable. - * - * \return the current drawable, as specified by glXMakeCurrent(), or zero if - * no drawable is currently bound. - * - * This function gets the current context via glXGetCurrentContext() and - * returns the MiniGLXContextRec::drawBuffer attribute. - */ -GLXDrawable -glXGetCurrentDrawable( void ) -{ - GLXContext glxctx = glXGetCurrentContext(); - if (glxctx) - return glxctx->drawBuffer; - else - return NULL; -} - - -static GLboolean -__glXCreateContextWithConfig(__DRInativeDisplay *dpy, int screen, - int fbconfigID, void *contextID, drm_context_t *hHWContext) -{ - __DRIscreen *pDRIScreen; - __DRIscreen *psp; - - pDRIScreen = __glXFindDRIScreen(dpy, screen); - if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) { - return GL_FALSE; - } - - psp = (__DRIscreen *) pDRIScreen->private; - - if (psp->fd) { - if (drmCreateContext(psp->fd, hHWContext)) { - fprintf(stderr, ">>> drmCreateContext failed\n"); - return GL_FALSE; - } - *(void**)contextID = (void*) *hHWContext; - } - - return GL_TRUE; -} - - -static GLboolean -__glXGetDrawableInfo(__DRInativeDisplay *dpy, int scrn, - __DRIid draw, unsigned int * index, unsigned int * stamp, - int * x, int * y, int * width, int * height, - int * numClipRects, drm_clip_rect_t ** pClipRects, - int * backX, int * backY, - int * numBackClipRects, drm_clip_rect_t ** pBackClipRects) -{ - GLXDrawable drawable = (GLXDrawable) draw; - drm_clip_rect_t * cliprect; - Display* display = (Display*)dpy; - __DRIscreen *psp = display->driScreen.private; - __DRIcontext *pcp = (__DRIcontext *)CurrentContext->driContext.private; - __DRIdrawable *pdp = pcp->driDrawablePriv; - if (drawable == 0) { - return GL_FALSE; - } - - cliprect = (drm_clip_rect_t*) _mesa_malloc(sizeof(drm_clip_rect_t)); - cliprect->x1 = drawable->x; - cliprect->y1 = drawable->y; - cliprect->x2 = drawable->x + drawable->w; - cliprect->y2 = drawable->y + drawable->h; - - /* the drawable index is by client id */ - *index = display->clientID; - - *stamp = pcp->driScreenPriv->pSAREA->drawableTable[display->clientID].stamp; - drmUpdateDrawableInfo(psp->fd, pdp->hHWDrawable, DRM_DRAWABLE_CLIPRECTS, 1, cliprect); - *x = drawable->x; - *y = drawable->y; - *width = drawable->w; - *height = drawable->h; - *numClipRects = 1; - *pClipRects = cliprect; - - *backX = drawable->x; - *backY = drawable->y; - *numBackClipRects = 0; - *pBackClipRects = 0; - - return GL_TRUE; -} - - -static GLboolean -xf86DRI_DestroyContext(__DRInativeDisplay *dpy, int screen, __DRIid context_id ) -{ - return GL_TRUE; -} - - -static GLboolean -xf86DRI_CreateDrawable(__DRInativeDisplay *dpy, int screen, __DRIid drawable, - drm_drawable_t *hHWDrawable ) -{ - - Display *display = (Display *)dpy; - __DRIscreen *psp = display->driScreen.private; - int ret; - ret = drmCreateDrawable(psp->fd, hHWDrawable); - - fprintf(stderr, "drawable is %d %08X ret is %d\n", *hHWDrawable, drawable, -ret); - if (ret != 0) - return GL_FALSE; - return GL_TRUE; -} - - -static GLboolean -xf86DRI_DestroyDrawable(__DRInativeDisplay *dpy, int screen, __DRIid drawable) -{ - return GL_TRUE; -} - - -/** - * \brief Query function address. - * - * The glXGetProcAddress() function will return the address of any available - * OpenGL or Mini GLX function. - * - * \param procName name of the function to be returned. - * - * \return If \p procName is a valid function name, a pointer to that function - * will be returned. Otherwise, \c NULL will be returned. - * - * The purpose of glXGetProcAddress() is to facilitate using future extensions - * to OpenGL or Mini GLX. If a future version of the library adds new extension - * functions they'll be accessible via glXGetProcAddress(). The alternative is - * to hard-code calls to the new functions in the application but doing so will - * prevent linking the application with older versions of the library. - * - * Returns the function address by looking up its name in a static (name, - * address) pair list. - */ -void (*glXGetProcAddress(const GLubyte *procname))( void ) -{ - struct name_address { - const char *name; - const void *func; - }; - static const struct name_address functions[] = { - { "glXChooseVisual", (void *) glXChooseVisual }, - { "glXCreateContext", (void *) glXCreateContext }, - { "glXDestroyContext", (void *) glXDestroyContext }, - { "glXMakeCurrent", (void *) glXMakeCurrent }, - { "glXSwapBuffers", (void *) glXSwapBuffers }, - { "glXGetCurrentContext", (void *) glXGetCurrentContext }, - { "glXGetCurrentDrawable", (void *) glXGetCurrentDrawable }, - { "glXGetProcAddress", (void *) glXGetProcAddress }, - { "XOpenDisplay", (void *) XOpenDisplay }, - { "XCloseDisplay", (void *) XCloseDisplay }, - { "XCreateWindow", (void *) XCreateWindow }, - { "XDestroyWindow", (void *) XDestroyWindow }, - { "XMapWindow", (void *) XMapWindow }, - { "XCreateColormap", (void *) XCreateColormap }, - { "XFreeColormap", (void *) XFreeColormap }, - { "XFree", (void *) XFree }, - { "XGetVisualinfo", (void *) XGetVisualInfo }, - { "glXCreatePbuffer", (void *) glXCreatePbuffer }, - { "glXDestroyPbuffer", (void *) glXDestroyPbuffer }, - { "glXChooseFBConfig", (void *) glXChooseFBConfig }, - { "glXGetVisualFromFBConfig", (void *) glXGetVisualFromFBConfig }, - { NULL, NULL } - }; - const struct name_address *entry; - for (entry = functions; entry->name; entry++) { - if (strcmp(entry->name, (const char *) procname) == 0) { - return entry->func; - } - } - return _glapi_get_proc_address((const char *) procname); -} - -void (*glXGetProcAddressARB(const GLubyte *procName))( void ) __attribute__ ((alias ("glXGetProcAddress"))); - -/** - * \brief Query the Mini GLX version. - * - * \param dpy the display handle. It is currently ignored, but should be the - * value returned by XOpenDisplay(). - * \param major receives the major version number of Mini GLX. - * \param minor receives the minor version number of Mini GLX. - * - * \return \c True if the function succeeds, \c False if the function fails due - * to invalid parameters. - * - * \sa #MINI_GLX_VERSION_1_0. - * - * Returns the hard-coded Mini GLX version. - */ -Bool -glXQueryVersion( Display *dpy, int *major, int *minor ) -{ - (void) dpy; - *major = 1; - *minor = 0; - return True; -} - - -/** - * \brief Create a new pbuffer. - */ -GLXPbuffer -glXCreatePbuffer( Display *dpy, GLXFBConfig config, const int *attribList ) -{ - return NULL; -} - - -void -glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf ) -{ - free(pbuf); -} - - -GLXFBConfig * -glXChooseFBConfig( Display *dpy, int screen, const int *attribList, - int *nitems ) -{ - GLXFBConfig *f = (GLXFBConfig *) malloc(sizeof(GLXFBConfig)); - f->visInfo = glXChooseVisual( dpy, screen, (int *) attribList ); - if (f->visInfo) { - *nitems = 1; - return f; - } - else { - *nitems = 0; - free(f); - return NULL; - } -} - - -XVisualInfo * -glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) -{ - /* XVisualInfo and GLXFBConfig are the same structure */ - (void) dpy; - return config.visInfo; -} - -void *glXAllocateMemoryMESA(Display *dpy, int scrn, - size_t size, float readFreq, - float writeFreq, float priority) -{ - if (dpy->driScreen.private && dpy->driScreen.allocateMemory) { - return (*dpy->driScreen.allocateMemory)( dpy, scrn, size, - readFreq, writeFreq, - priority ); - } - - return NULL; -} - -void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer) -{ - if (dpy->driScreen.private && dpy->driScreen.freeMemory) { - (*dpy->driScreen.freeMemory)( dpy, scrn, pointer ); - } -} - -GLuint glXGetMemoryOffsetMESA( Display *dpy, int scrn, - const void *pointer ) -{ - if (dpy->driScreen.private && dpy->driScreen.memoryOffset) { - return (*dpy->driScreen.memoryOffset)( dpy, scrn, pointer ); - } - - return 0; -} - - -/** - * Get the unadjusted system time (UST). Currently, the UST is measured in - * microseconds since Epoc. The actual resolution of the UST may vary from - * system to system, and the units may vary from release to release. - * Drivers should not call this function directly. They should instead use - * \c glXGetProcAddress to obtain a pointer to the function. - * - * \param ust Location to store the 64-bit UST - * \returns Zero on success or a negative errno value on failure. - * - * \note - * This function was copied directly from src/glx/x11/glxcmds.c. - */ -static int __glXGetUST( int64_t * ust ) -{ - struct timeval tv; - - if ( ust == NULL ) { - return -EFAULT; - } - - if ( gettimeofday( & tv, NULL ) == 0 ) { - ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec; - return 0; - } else { - return -errno; - } -} - - -/** - * - * \bug - * This needs to be implemented for miniGlx. - */ -static GLboolean __glXGetMscRate(__DRInativeDisplay * dpy, __DRIid drawable, - int32_t * numerator, int32_t * denominator) -{ - *numerator = 0; - *denominator = 0; - return False; -} -/*@}*/ diff --git a/src/glx/mini/miniglxP.h b/src/glx/mini/miniglxP.h deleted file mode 100644 index 96ed0e81cd7..00000000000 --- a/src/glx/mini/miniglxP.h +++ /dev/null @@ -1,205 +0,0 @@ -/** - * \file miniglxP.h - * \brief Define replacements for some X data types and define the DRI-related - * data structures. - * - * \note Cut down version of glxclient.h. - * - */ - -#ifndef _mini_GLX_client_h_ -#define _mini_GLX_client_h_ - -#include -#include - -#include -#include "glheader.h" -#include "mtypes.h" - -#include "driver.h" -#include "GL/internal/dri_interface.h" - -/** - * \brief Supported pixel formats. - */ -enum PixelFormat { - PF_B8G8R8, /**< \brief 24-bit BGR */ - PF_B8G8R8A8, /**< \brief 32-bit BGRA */ - PF_B5G6R5, /**< \brief 16-bit BGR */ - PF_B5G5R5, /**< \brief 15-bit BGR */ - PF_CI8 /**< \brief 8-bit color index */ -}; - -/** - * \brief X Visual type. - * - * \sa ::Visual, \ref datatypes. - */ -struct MiniGLXVisualRec { - /** \brief GLX visual information */ - const __GLcontextModes *mode; - - /** \brief pointer back to corresponding ::XVisualInfo */ - XVisualInfo *visInfo; - - /** \brief display handle */ - Display *dpy; - - /** \brief pixel format */ - enum PixelFormat pixelFormat; -}; - - - -/** - * \brief X Window type. - * - * \sa ::Window, \ref datatypes. - */ -struct MiniGLXWindowRec { - Visual *visual; - /** \brief position (always 0,0) */ - int x, y; - /** \brief size */ - unsigned int w, h; - void *frontStart; /**< \brief start of front color buffer */ - void *backStart; /**< \brief start of back color buffer */ - size_t size; /**< \brief color buffer size, in bytes */ - GLuint bytesPerPixel; - GLuint rowStride; /**< \brief in bytes */ - GLubyte *frontBottom; /**< \brief pointer to last row */ - GLubyte *backBottom; /**< \brief pointer to last row */ - GLubyte *curBottom; /**< = frontBottom or backBottom */ - __DRIdrawable driDrawable; - GLuint ismapped; -}; - - -/** - * \brief GLXContext type. - * - * \sa ::GLXContext, \ref datatypes. - */ -struct MiniGLXContextRec { - Window drawBuffer; /**< \brief drawing buffer */ - Window curBuffer; /**< \brief current buffer */ - VisualID vid; /**< \brief visual ID */ - __DRIcontext driContext; /**< \brief context dependent methods */ -}; - -#define MINIGLX_BUF_SIZE 512 -#define MINIGLX_MAX_SERVER_FDS 10 -#define MINIGLX_MAX_CLIENT_FDS 1 -#define MINIGLX_EVENT_QUEUE_SZ 16 -#define MINIGLX_EVENT_QUEUE_MASK (MINIGLX_EVENT_QUEUE_SZ-1) - -/** - * A connection to/from the server - * - * All information is to/from the server is buffered and then dispatched by - * __miniglx_Select() to avoid blocking the server. - */ -struct MiniGLXConnection { - int fd; /**< \brief file descriptor */ - char readbuf[MINIGLX_BUF_SIZE]; /**< \brief read buffer */ - char writebuf[MINIGLX_BUF_SIZE]; /**< \brief write buffer */ - int readbuf_count; /**< \brief count of bytes waiting to be read */ - int writebuf_count; /**< \brief count of bytes waiting to be written */ -}; - - -/** - * \brief X Display type - * - * \sa ::Display, \ref datatypes. - */ -struct MiniGLXDisplayRec { - /** \brief fixed framebuffer screen info */ - struct fb_fix_screeninfo FixedInfo; - /** \brief original and current variable framebuffer screen info */ - struct fb_var_screeninfo OrigVarInfo, VarInfo; - struct sigaction OrigSigUsr1; - struct sigaction OrigSigUsr2; - int OriginalVT; - int ConsoleFD; /**< \brief console TTY device file descriptor */ - int FrameBufferFD; /**< \brief framebuffer device file descriptor */ - int NumWindows; /**< \brief number of open windows */ - Window TheWindow; /**< \brief open window - only allow one window for now */ - int rotateMode; - - - volatile int vtSignalFlag; - volatile int haveVT; /**< \brief whether the VT is hold */ - int hwActive; /**< \brief whether the hardware is active -- mimics - the variations of MiniGLXDisplayRec::haveVT */ - - - int IsClient; /**< \brief whether it's a client or the server */ - int clientID; - int nrFds; /**< \brief number of connections (usually just one for the clients) */ - struct MiniGLXConnection *fd; /**< \brief connections */ - int drmFd; /**< \brief handle to drm device */ - int authorized; /**< \brief has server authorized this process? */ - - struct { - int nr, head, tail; - XEvent queue[MINIGLX_EVENT_QUEUE_SZ]; - } eventqueue; - - /** - * \name Visuals - * - * Visuals (configs) in this screen. - */ - /*@{*/ - const __GLcontextModes *driver_modes; /**< \brief Modes filtered by driver. */ - /*@}*/ - - /** - * \name From __GLXdisplayPrivate - */ - /*@{*/ - PFNCREATENEWSCREENFUNC createNewScreen; /**< \brief \e __driCreateScreen hook */ - __DRIscreen driScreen; /**< \brief Screen dependent methods */ - void *dlHandle; /**< - * \brief handle to the client dynamic - * library - */ - /*@}*/ - - /** - * \brief Mini GLX specific driver hooks - */ - struct DRIDriverRec *driver; - struct DRIDriverContextRec driverContext; - - /** - * \name Configuration details - * - * They are read from a configuration file by __read_config_file(). - */ - /*@{*/ - const char *fbdevDevice; - const char *clientDriverName; - /*@}*/ -}; - -/** Character messages. */ -enum msgs { - _CanIHaveFocus, - _IDontWantFocus, - _YouveGotFocus, - _YouveLostFocus, - _RepaintPlease, - _Authorize, -}; -extern int send_msg( Display *dpy, int i, const void *msg, size_t sz ); -extern int send_char_msg( Display *dpy, int i, char msg ); -extern int blocking_read( Display *dpy, int connection, char *msg, size_t msg_size ); -extern int handle_fd_events( Display *dpy, int nonblock ); - -extern int __miniglx_open_connections( Display *dpy ); -extern void __miniglx_close_connections( Display *dpy ); - -#endif /* !_mini_GLX_client_h_ */ diff --git a/src/glx/mini/miniglx_events.c b/src/glx/mini/miniglx_events.c deleted file mode 100644 index a20d5847b3c..00000000000 --- a/src/glx/mini/miniglx_events.c +++ /dev/null @@ -1,983 +0,0 @@ -/** - * \file miniglx_events.c - * \brief Mini GLX client/server communication functions. - * \author Keith Whitwell - * - * The Mini GLX interface is a subset of the GLX interface, plus a - * minimal set of Xlib functions. This file adds interfaces to - * arbitrate a single cliprect between multiple direct rendering - * clients. - * - * A fairly complete client/server non-blocking communication - * mechanism. Probably overkill given that none of our messages - * currently exceed 1 byte in length and take place over the - * relatively benign channel provided by a Unix domain socket. - */ - -/* - * Mesa 3-D graphics library - * Version: 5.0 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "xf86drm.h" -#include "miniglxP.h" - - -#define MINIGLX_FIFO_NAME "/tmp/miniglx.fifo" - -/** - * \brief Allocate an XEvent structure on the event queue. - * - * \param dpy the display handle. - * - * \return Pointer to the queued event structure or NULL on failure. - * - * \internal - * If there is space on the XEvent queue, return a pointer - * to the next free event and increment the eventqueue tail value. - * Otherwise return null. - */ -static XEvent *queue_event( Display *dpy ) -{ - int incr = (dpy->eventqueue.tail + 1) & MINIGLX_EVENT_QUEUE_MASK; - if (incr == dpy->eventqueue.head) { - return 0; - } - else { - XEvent *ev = &dpy->eventqueue.queue[dpy->eventqueue.tail]; - dpy->eventqueue.tail = incr; - return ev; - } -} - -/** - * \brief Dequeue an XEvent and copy it into provided storage. - * - * \param dpy the display handle. - * \param event_return pointer to copy the queued event to. - * - * \return True or False depending on success. - * - * \internal - * If there is a queued XEvent on the queue, copy it to the provided - * pointer and increment the eventqueue head value. Otherwise return - * null. - */ -static int dequeue_event( Display *dpy, XEvent *event_return ) -{ - if (dpy->eventqueue.tail == dpy->eventqueue.head) { - return False; - } - else { - *event_return = dpy->eventqueue.queue[dpy->eventqueue.head]; - dpy->eventqueue.head += 1; - dpy->eventqueue.head &= MINIGLX_EVENT_QUEUE_MASK; - return True; - } -} - -/** - * \brief Shutdown a socket connection. - * - * \param dpy the display handle. - * \param i the index in dpy->fd of the socket connection. - * - * \internal - * Shutdown and close the file descriptor. If this is the special - * connection in fd[0], issue an error message and exit - there's been - * some sort of failure somewhere. Otherwise, let the application - * know about whats happened by issuing a DestroyNotify event. - */ -static void shut_fd( Display *dpy, int i ) -{ - if (dpy->fd[i].fd < 0) - return; - - shutdown (dpy->fd[i].fd, SHUT_RDWR); - close (dpy->fd[i].fd); - dpy->fd[i].fd = -1; - dpy->fd[i].readbuf_count = 0; - dpy->fd[i].writebuf_count = 0; - - if (i == 0) { - fprintf(stderr, "server connection lost\n"); - exit(1); - } - else { - /* Pass this to the application as a DestroyNotify event. - */ - XEvent *er = queue_event(dpy); - if (!er) return; - er->xdestroywindow.type = DestroyNotify; - er->xdestroywindow.serial = 0; - er->xdestroywindow.send_event = 0; - er->xdestroywindow.display = dpy; - er->xdestroywindow.window = (Window)i; - - drmGetLock(dpy->driverContext.drmFD, 1, 0); - drmUnlock(dpy->driverContext.drmFD, 1); - } -} - -/** - * \brief Send a message to a socket connection. - * - * \param dpy the display handle. - * \param i the index in dpy->fd of the socket connection. - * \param msg the message to send. - * \param sz the size of the message - * - * \internal - * Copy the message to the write buffer for the nominated connection. - * This will be actually sent to that file descriptor from - * __miniglx_Select(). - */ -int send_msg( Display *dpy, int i, - const void *msg, size_t sz ) -{ - int cnt = dpy->fd[i].writebuf_count; - if (MINIGLX_BUF_SIZE - cnt < sz) { - fprintf(stderr, "client %d: writebuf overflow\n", i); - return False; - } - - memcpy( dpy->fd[i].writebuf + cnt, msg, sz ); cnt += sz; - dpy->fd[i].writebuf_count = cnt; - return True; -} - -/** - * \brief Send a message to a socket connection. - * - * \param dpy the display handle. - * \param i the index in dpy->fd of the socket connection. - * \param msg the message to send. - * - * \internal - * Use send_msg() to send a one-byte message to a socket. - */ -int send_char_msg( Display *dpy, int i, char msg ) -{ - return send_msg( dpy, i, &msg, sizeof(char)); -} - - -/** - * \brief Block and receive a message from a socket connection. - * - * \param dpy the display handle. - * \param connection the index in dpy->fd of the socket connection. - * \param msg storage for the received message. - * \param msg_size the number of bytes to read. - * - * \internal - * Block and read from the connection's file descriptor - * until msg_size bytes have been received. - * - * Only called from welcome_message_part(). - */ -int blocking_read( Display *dpy, int connection, - char *msg, size_t msg_size ) -{ - int i, r; - - for (i = 0 ; i < msg_size ; i += r) { - r = read(dpy->fd[connection].fd, msg + i, msg_size - i); - if (r < 1) { - fprintf(stderr, "blocking_read: %d %s\n", r, strerror(errno)); - shut_fd(dpy,connection); - return False; - } - } - - return True; -} - -/** - * \brief Send/receive a part of the welcome message. - * - * \param dpy the display handle. - * \param i the index in dpy->fd of the socket connection. - * \param msg storage for the sent/received message. - * \param sz the number of bytes to write/read. - * - * \return True on success, or False on failure. - * - * This function is called by welcome_message_part(), to either send or receive - * (via blocking_read()) part of the welcome message, according to whether - * Display::IsClient is set. - * - * Each part of the welcome message on the wire consists of a count and then the - * actual message data with that number of bytes. - */ -static int welcome_message_part( Display *dpy, int i, void **msg, int sz ) -{ - if (dpy->IsClient) { - int sz; - if (!blocking_read( dpy, i, (char *)&sz, sizeof(sz))) return False; - if (!*msg) *msg = malloc(sz); - if (!*msg) return False; - if (!blocking_read( dpy, i, *msg, sz )) return False; - return sz; - } - else { - if (!send_msg( dpy, i, &sz, sizeof(sz))) return False; - if (!send_msg( dpy, i, *msg, sz )) return False; - } - - return True; -} - -/** - * \brief Send/receive the welcome message. - * - * \param dpy the display handle. - * \param i the index in dpy->fd of the socket connection. - * - * \return True on success, or False on failure. - * - * Using welcome_message_part(), sends/receives the client ID, the client - * configuration details in DRIDriverContext::shared, and the driver private - * message in DRIDriverContext::driverClientMsg. - */ -static int welcome_message( Display *dpy, int i ) -{ - void *tmp = &dpy->driverContext.shared; - int *clientid = dpy->IsClient ? &dpy->clientID : &i; - int size; - - if (!welcome_message_part( dpy, i, (void **)&clientid, sizeof(*clientid))) - return False; - - if (!welcome_message_part( dpy, i, &tmp, sizeof(dpy->driverContext.shared))) - return False; - - size=welcome_message_part( dpy, i, - (void **)&dpy->driverContext.driverClientMsg, - dpy->driverContext.driverClientMsgSize ); - - if (!size) - return False; - - if (dpy->IsClient) { - dpy->driverContext.driverClientMsgSize = size; - } - return True; -} - - -/** - * \brief Handle a new client connection. - * - * \param dpy the display handle. - * - * \return True on success or False on failure. - * - * Accepts the connection, sets it in non-blocking operation, and finds a free - * slot in Display::fd for it. - */ -static int handle_new_client( Display *dpy ) -{ - struct sockaddr_un client_address; - unsigned int l = sizeof(client_address); - int r, i; - - r = accept(dpy->fd[0].fd, (struct sockaddr *) &client_address, &l); - if (r < 0) { - perror ("accept()"); - shut_fd(dpy,0); - return False; - } - - if (fcntl(r, F_SETFL, O_NONBLOCK) != 0) { - perror("fcntl"); - close(r); - return False; - } - - - /* Some rough & ready adaption of the XEvent semantics. - */ - for (i = 1 ; i < dpy->nrFds ; i++) { - if (dpy->fd[i].fd < 0) { - XEvent *er = queue_event(dpy); - if (!er) { - close(r); - return False; - } - - dpy->fd[i].fd = r; - er->xcreatewindow.type = CreateNotify; - er->xcreatewindow.serial = 0; - er->xcreatewindow.send_event = 0; - er->xcreatewindow.display = dpy; - er->xcreatewindow.window = (Window)i; /* fd slot == window, now? */ - - /* Send the driver client message - this is expected as the - * first message on a new connection. The recpient already - * knows the size of the message. - */ - welcome_message( dpy, i ); - return True; - } - } - - - fprintf(stderr, "[miniglx] %s: Max nr clients exceeded\n", __FUNCTION__); - close(r); - return False; -} - -/** - * This routine "puffs out" the very basic communications between - * client and server to full-sized X Events that can be handled by the - * application. - * - * \param dpy the display handle. - * \param i the index in dpy->fd of the socket connection. - * - * \return True on success or False on failure. - * - * \internal - * Interprets the message (see msg) into a XEvent and advances the file FIFO - * buffer. - */ -static int -handle_fifo_read( Display *dpy, int i ) -{ - drm_magic_t magic; - int err; - - while (dpy->fd[i].readbuf_count) { - char id = dpy->fd[i].readbuf[0]; - XEvent *er; - int count = 1; - - if (dpy->IsClient) { - switch (id) { - /* The server has called XMapWindow on a client window */ - case _YouveGotFocus: - er = queue_event(dpy); - if (!er) return False; - er->xmap.type = MapNotify; - er->xmap.serial = 0; - er->xmap.send_event = False; - er->xmap.display = dpy; - er->xmap.event = dpy->TheWindow; - er->xmap.window = dpy->TheWindow; - er->xmap.override_redirect = False; - if (dpy->driver->notifyFocus) - dpy->driver->notifyFocus( 1 ); - break; - - /* The server has called XMapWindow on a client window */ - case _RepaintPlease: - er = queue_event(dpy); - if (!er) return False; - er->xexpose.type = Expose; - er->xexpose.serial = 0; - er->xexpose.send_event = False; - er->xexpose.display = dpy; - er->xexpose.window = dpy->TheWindow; - if (dpy->rotateMode) { - er->xexpose.x = dpy->TheWindow->y; - er->xexpose.y = dpy->TheWindow->x; - er->xexpose.width = dpy->TheWindow->h; - er->xexpose.height = dpy->TheWindow->w; - } - else { - er->xexpose.x = dpy->TheWindow->x; - er->xexpose.y = dpy->TheWindow->y; - er->xexpose.width = dpy->TheWindow->w; - er->xexpose.height = dpy->TheWindow->h; - } - er->xexpose.count = 0; - break; - - /* The server has called 'XUnmapWindow' on a client - * window. - */ - case _YouveLostFocus: - er = queue_event(dpy); - if (!er) return False; - er->xunmap.type = UnmapNotify; - er->xunmap.serial = 0; - er->xunmap.send_event = False; - er->xunmap.display = dpy; - er->xunmap.event = dpy->TheWindow; - er->xunmap.window = dpy->TheWindow; - er->xunmap.from_configure = False; - if (dpy->driver->notifyFocus) - dpy->driver->notifyFocus( 0 ); - break; - - case _Authorize: - dpy->authorized = True; - break; - - default: - fprintf(stderr, "Client received unhandled message type %d\n", id); - shut_fd(dpy, i); /* Actually shuts down the client */ - return False; - } - } - else { - switch (id) { - /* Lets the server know that the client is ready to render - * (having called 'XMapWindow' locally). - */ - case _CanIHaveFocus: - er = queue_event(dpy); - if (!er) return False; - er->xmaprequest.type = MapRequest; - er->xmaprequest.serial = 0; - er->xmaprequest.send_event = False; - er->xmaprequest.display = dpy; - er->xmaprequest.parent = 0; - er->xmaprequest.window = (Window)i; - break; - - /* Both _YouveLostFocus and _IDontWantFocus generate unmap - * events. The idea is that _YouveLostFocus lets the client - * know that it has had focus revoked by the server, whereas - * _IDontWantFocus lets the server know that the client has - * unmapped its own window. - */ - case _IDontWantFocus: - er = queue_event(dpy); - if (!er) return False; - er->xunmap.type = UnmapNotify; - er->xunmap.serial = 0; - er->xunmap.send_event = False; - er->xunmap.display = dpy; - er->xunmap.event = (Window)i; - er->xunmap.window = (Window)i; - er->xunmap.from_configure = False; - break; - - case _Authorize: - /* is full message here yet? */ - if (dpy->fd[i].readbuf_count < count + sizeof(magic)) { - count = 0; - break; - } - memcpy(&magic, dpy->fd[i].readbuf + count, sizeof(magic)); - fprintf(stderr, "Authorize - magic %d\n", magic); - - err = drmAuthMagic(dpy->driverContext.drmFD, magic); - count += sizeof(magic); - - send_char_msg( dpy, i, _Authorize ); - break; - - default: - fprintf(stderr, "Server received unhandled message type %d\n", id); - shut_fd(dpy, i); /* Generates DestroyNotify event */ - return False; - } - } - - dpy->fd[i].readbuf_count -= count; - - if (dpy->fd[i].readbuf_count) { - memmove(dpy->fd[i].readbuf, - dpy->fd[i].readbuf + count, - dpy->fd[i].readbuf_count); - } - } - - return True; -} - -/** - * Handle a VT signal - * - * \param dpy display handle. - * - * The VT switches is detected by comparing Display::haveVT and - * Display::hwActive. When loosing the VT the hardware lock is acquired, the - * hardware is shutdown via a call to DRIDriverRec::shutdownHardware(), and the - * VT released. When acquiring the VT back the hardware state is restored via a - * call to DRIDriverRec::restoreHardware() and the hardware lock released. - */ -static void __driHandleVtSignals( Display *dpy ) -{ - dpy->vtSignalFlag = 0; - - fprintf(stderr, "%s: haveVT %d hwActive %d\n", __FUNCTION__, - dpy->haveVT, dpy->hwActive); - - if (!dpy->haveVT && dpy->hwActive) { - /* Need to get lock and shutdown hardware */ - DRM_LIGHT_LOCK( dpy->driverContext.drmFD, - dpy->driverContext.pSAREA, - dpy->driverContext.serverContext ); - dpy->driver->shutdownHardware( &dpy->driverContext ); - - /* Can now give up control of the VT */ - ioctl( dpy->ConsoleFD, VT_RELDISP, 1 ); - dpy->hwActive = 0; - } - else if (dpy->haveVT && !dpy->hwActive) { - /* Get VT (wait??) */ - ioctl( dpy->ConsoleFD, VT_RELDISP, VT_ACTIVATE ); - - /* restore HW state, release lock */ - dpy->driver->restoreHardware( &dpy->driverContext ); - DRM_UNLOCK( dpy->driverContext.drmFD, - dpy->driverContext.pSAREA, - dpy->driverContext.serverContext ); - dpy->hwActive = 1; - } -} - - -#undef max -#define max(x,y) ((x) > (y) ? (x) : (y)) - -/** - * Logic for the select() call. - * - * \param dpy display handle. - * \param n highest fd in any set plus one. - * \param rfds fd set to be watched for reading, or NULL to create one. - * \param wfds fd set to be watched for writing, or NULL to create one. - * \param xfds fd set to be watched for exceptions or error, or NULL to create one. - * \param tv timeout value, or NULL for no timeout. - * - * \return number of file descriptors contained in the sets, or a negative number on failure. - * - * \note - * This all looks pretty complex, but is necessary especially on the - * server side to prevent a poorly-behaved client from causing the - * server to block in a read or write and hence not service the other - * clients. - * - * \sa - * See select_tut in the Linux manual pages for more discussion. - * - * \internal - * Creates and initializes the file descriptor sets by inspecting Display::fd - * if these aren't passed in the function call. Calls select() and fulfill the - * demands by trying to fill MiniGLXConnection::readbuf and draining - * MiniGLXConnection::writebuf. - * The server fd[0] is handled specially for new connections, by calling - * handle_new_client(). - * - */ -int -__miniglx_Select( Display *dpy, int n, fd_set *rfds, fd_set *wfds, fd_set *xfds, - struct timeval *tv ) -{ - int i; - int retval; - fd_set my_rfds, my_wfds; - struct timeval my_tv; - - if (!rfds) { - rfds = &my_rfds; - FD_ZERO(rfds); - } - - if (!wfds) { - wfds = &my_wfds; - FD_ZERO(wfds); - } - - /* Don't block if there are events queued. Review this if the - * flush in XMapWindow is changed to blocking. (Test case: - * miniglxtest). - */ - if (dpy->eventqueue.head != dpy->eventqueue.tail) { - my_tv.tv_sec = my_tv.tv_usec = 0; - tv = &my_tv; - } - - for (i = 0 ; i < dpy->nrFds; i++) { - if (dpy->fd[i].fd < 0) - continue; - - if (dpy->fd[i].writebuf_count) - FD_SET(dpy->fd[i].fd, wfds); - - if (dpy->fd[i].readbuf_count < MINIGLX_BUF_SIZE) - FD_SET(dpy->fd[i].fd, rfds); - - n = max(n, dpy->fd[i].fd + 1); - } - - if (dpy->vtSignalFlag) - __driHandleVtSignals( dpy ); - - retval = select( n, rfds, wfds, xfds, tv ); - - if (dpy->vtSignalFlag) { - int tmp = errno; - __driHandleVtSignals( dpy ); - errno = tmp; - } - - if (retval < 0) { - FD_ZERO(rfds); - FD_ZERO(wfds); - return retval; - } - - /* Handle server fd[0] specially on the server - accept new client - * connections. - */ - if (!dpy->IsClient) { - if (FD_ISSET(dpy->fd[0].fd, rfds)) { - FD_CLR(dpy->fd[0].fd, rfds); - handle_new_client( dpy ); - } - } - - /* Otherwise, try and fill readbuffer and drain writebuffer: - */ - for (i = 0 ; i < dpy->nrFds ; i++) { - if (dpy->fd[i].fd < 0) - continue; - - /* If there aren't any event slots left, don't examine - * any more file events. This will prevent lost events. - */ - if (dpy->eventqueue.head == - ((dpy->eventqueue.tail + 1) & MINIGLX_EVENT_QUEUE_MASK)) { - fprintf(stderr, "leaving event loop as event queue is full\n"); - return retval; - } - - if (FD_ISSET(dpy->fd[i].fd, wfds)) { - int r = write(dpy->fd[i].fd, - dpy->fd[i].writebuf, - dpy->fd[i].writebuf_count); - - if (r < 1) - shut_fd(dpy,i); - else { - dpy->fd[i].writebuf_count -= r; - if (dpy->fd[i].writebuf_count) { - memmove(dpy->fd[i].writebuf, - dpy->fd[i].writebuf + r, - dpy->fd[i].writebuf_count); - } - } - } - - if (FD_ISSET(dpy->fd[i].fd, rfds)) { - int r = read(dpy->fd[i].fd, - dpy->fd[i].readbuf + dpy->fd[i].readbuf_count, - MINIGLX_BUF_SIZE - dpy->fd[i].readbuf_count); - - if (r < 1) - shut_fd(dpy,i); - else { - dpy->fd[i].readbuf_count += r; - - handle_fifo_read( dpy, i ); - } - } - } - - return retval; -} - -/** - * \brief Handle socket events. - * - * \param dpy the display handle. - * \param nonblock whether to return immediately or wait for an event. - * - * \return True on success, False on failure. Aborts on critical error. - * - * \internal - * This function is the select() main loop. - */ -int handle_fd_events( Display *dpy, int nonblock ) -{ - while (1) { - struct timeval tv = {0, 0}; - int r = __miniglx_Select( dpy, 0, 0, 0, 0, nonblock ? &tv : 0 ); - if (r >= 0) - return True; - if (errno == EINTR || errno == EAGAIN) - continue; - perror ("select()"); - exit (1); - } -} - -/** - * Initializes the connections. - * - * \param dpy the display handle. - * - * \return True on success or False on failure. - * - * Allocates and initializes the Display::fd array and create a Unix socket on - * the first entry. For a server binds the socket to a filename and listen for - * connections. For a client connects to the server and waits for a welcome - * message. Sets the socket in nonblocking mode. - */ -int __miniglx_open_connections( Display *dpy ) -{ - struct sockaddr_un sa; - int i; - - dpy->nrFds = dpy->IsClient ? 1 : MINIGLX_MAX_SERVER_FDS; - dpy->fd = calloc(1, dpy->nrFds * sizeof(struct MiniGLXConnection)); - if (!dpy->fd) - return False; - - for (i = 0 ; i < dpy->nrFds ; i++) - dpy->fd[i].fd = -1; - - if (!dpy->IsClient) { - if (unlink(MINIGLX_FIFO_NAME) != 0 && errno != ENOENT) { - perror("unlink " MINIGLX_FIFO_NAME); - return False; - } - - } - - /* Create a Unix socket -- Note this is *not* a network connection! - */ - dpy->fd[0].fd = socket(PF_UNIX, SOCK_STREAM, 0); - if (dpy->fd[0].fd < 0) { - perror("socket " MINIGLX_FIFO_NAME); - return False; - } - - memset(&sa, 0, sizeof(sa)); - sa.sun_family = AF_UNIX; - strcpy(sa.sun_path, MINIGLX_FIFO_NAME); - - if (dpy->IsClient) { - /* Connect to server - */ - if (connect(dpy->fd[0].fd, (struct sockaddr *)&sa, sizeof(sa)) != 0) { - perror("connect"); - shut_fd(dpy,0); - return False; - } - - /* Wait for configuration messages from the server. - */ - welcome_message( dpy, 0 ); - } - else { - mode_t tmp = umask( 0000 ); /* open to everybody ? */ - - /* Bind socket to our filename - */ - if (bind(dpy->fd[0].fd, (struct sockaddr *)&sa, sizeof(sa)) != 0) { - perror("bind"); - shut_fd(dpy,0); - return False; - } - - umask( tmp ); - - /* Listen for connections - */ - if (listen(dpy->fd[0].fd, 5) != 0) { - perror("listen"); - shut_fd(dpy,0); - return False; - } - } - - if (fcntl(dpy->fd[0].fd, F_SETFL, O_NONBLOCK) != 0) { - perror("fcntl"); - shut_fd(dpy,0); - return False; - } - - - return True; -} - - -/** - * Frees the connections initialized by __miniglx_open_connections(). - * - * \param dpy the display handle. - */ -void __miniglx_close_connections( Display *dpy ) -{ - int i; - - for (i = 0 ; i < dpy->nrFds ; i++) { - if (dpy->fd[i].fd >= 0) { - shutdown (dpy->fd[i].fd, SHUT_RDWR); - close (dpy->fd[i].fd); - } - } - - dpy->nrFds = 0; - free(dpy->fd); -} - - -/** - * Set a drawable flag. - * - * \param dpy the display handle. - * \param w drawable (window). - * \param flag flag. - * - * Sets the specified drawable flag in the SAREA and increment its stamp while - * holding the light hardware lock. - */ -static void set_drawable_flag( Display *dpy, int w, int flag ) -{ - if (dpy->driverContext.pSAREA) { - if (dpy->hwActive) - DRM_LIGHT_LOCK( dpy->driverContext.drmFD, - dpy->driverContext.pSAREA, - dpy->driverContext.serverContext ); - - dpy->driverContext.pSAREA->drawableTable[w].stamp++; - dpy->driverContext.pSAREA->drawableTable[w].flags = flag; - - if (dpy->hwActive) - DRM_UNLOCK( dpy->driverContext.drmFD, - dpy->driverContext.pSAREA, - dpy->driverContext.serverContext ); - } -} - - - -/** - * \brief Map Window. - * - * \param dpy the display handle as returned by XOpenDisplay(). - * \param w the window handle. - * - * If called by a client, sends a request for focus to the server. If - * called by the server, will generate a MapNotify and Expose event at - * the client. - * - */ -void -XMapWindow( Display *dpy, Window w ) -{ - if (dpy->IsClient) - send_char_msg( dpy, 0, _CanIHaveFocus ); - else { - set_drawable_flag( dpy, (int)w, 1 ); - send_char_msg( dpy, (int)w, _YouveGotFocus ); - send_char_msg( dpy, (int)w, _RepaintPlease ); - dpy->TheWindow = w; - } - handle_fd_events( dpy, 0 ); /* flush write queue */ -} - -/** - * \brief Unmap Window. - * - * \param dpy the display handle as returned by XOpenDisplay(). - * \param w the window handle. - * - * Called from the client: Lets the server know that the window won't - * be updated anymore. - * - * Called from the server: Tells the specified client that it no longer - * holds the focus. - */ -void -XUnmapWindow( Display *dpy, Window w ) -{ - if (dpy->IsClient) { - send_char_msg( dpy, 0, _IDontWantFocus ); - } - else { - dpy->TheWindow = 0; - set_drawable_flag( dpy, (int)w, 0 ); - send_char_msg( dpy, (int)w, _YouveLostFocus ); - } - handle_fd_events( dpy, 0 ); /* flush write queue */ -} - - -/** - * \brief Block and wait for next X event. - * - * \param dpy the display handle as returned by XOpenDisplay(). - * \param event_return a pointer to an XEvent structure for the returned data. - * - * Wait until there is a new XEvent pending. - */ -int XNextEvent(Display *dpy, XEvent *event_return) -{ - for (;;) { - if ( dpy->eventqueue.head != dpy->eventqueue.tail ) - return dequeue_event( dpy, event_return ); - - handle_fd_events( dpy, 0 ); - } -} - -/** - * \brief Non-blocking check for next X event. - * - * \param dpy the display handle as returned by XOpenDisplay(). - * \param event_mask ignored. - * \param event_return a pointer to an XEvent structure for the returned data. - * - * Check if there is a new XEvent pending. Note that event_mask is - * ignored and any pending event will be returned. - */ -Bool XCheckMaskEvent(Display *dpy, long event_mask, XEvent *event_return) -{ - if ( dpy->eventqueue.head != dpy->eventqueue.tail ) - return dequeue_event( dpy, event_return ); - - handle_fd_events( dpy, 1 ); - - return dequeue_event( dpy, event_return ); -} diff --git a/src/glx/packrender.h b/src/glx/packrender.h new file mode 100644 index 00000000000..30f6d44bbd2 --- /dev/null +++ b/src/glx/packrender.h @@ -0,0 +1,243 @@ +#ifndef __GLX_packrender_h__ +#define __GLX_packrender_h__ + +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +#include "glxclient.h" + +/* +** The macros in this header convert the client machine's native data types to +** wire protocol data types. The header is part of the porting layer of the +** client library, and it is intended that hardware vendors will rewrite this +** header to suit their own machines. +*/ + +/* +** Pad a count of bytes to the nearest multiple of 4. The X protocol +** transfers data in 4 byte quantities, so this macro is used to +** insure the right amount of data being sent. +*/ +#define __GLX_PAD(a) (((a)+3) & ~3) + +/* +** Network size parameters +*/ +#define sz_double 8 + +/* Setup for all commands */ +#define __GLX_DECLARE_VARIABLES() \ + __GLXcontext *gc; \ + GLubyte *pc, *pixelHeaderPC; \ + GLuint compsize, cmdlen + +#define __GLX_LOAD_VARIABLES() \ + gc = __glXGetCurrentContext(); \ + pc = gc->pc; \ + /* Muffle compilers */ \ + cmdlen = 0; (void)cmdlen; \ + compsize = 0; (void)compsize; \ + pixelHeaderPC = 0; (void)pixelHeaderPC + +/* +** Variable sized command support macro. This macro is used by calls +** that are potentially larger than __GLX_SMALL_RENDER_CMD_SIZE. +** Because of their size, they may not automatically fit in the buffer. +** If the buffer can't hold the command then it is flushed so that +** the command will fit in the next buffer. +*/ +#define __GLX_BEGIN_VARIABLE(opcode,size) \ + if (pc + (size) > gc->bufEnd) { \ + pc = __glXFlushRenderBuffer(gc, pc); \ + } \ + __GLX_PUT_SHORT(0,size); \ + __GLX_PUT_SHORT(2,opcode) + +#define __GLX_BEGIN_VARIABLE_LARGE(opcode,size) \ + pc = __glXFlushRenderBuffer(gc, pc); \ + __GLX_PUT_LONG(0,size); \ + __GLX_PUT_LONG(4,opcode) + +#define __GLX_BEGIN_VARIABLE_WITH_PIXEL(opcode,size) \ + if (pc + (size) > gc->bufEnd) { \ + pc = __glXFlushRenderBuffer(gc, pc); \ + } \ + __GLX_PUT_SHORT(0,size); \ + __GLX_PUT_SHORT(2,opcode); \ + pc += __GLX_RENDER_HDR_SIZE; \ + pixelHeaderPC = pc; \ + pc += __GLX_PIXEL_HDR_SIZE + +#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(opcode,size) \ + pc = __glXFlushRenderBuffer(gc, pc); \ + __GLX_PUT_LONG(0,size); \ + __GLX_PUT_LONG(4,opcode); \ + pc += __GLX_RENDER_LARGE_HDR_SIZE; \ + pixelHeaderPC = pc; \ + pc += __GLX_PIXEL_HDR_SIZE + +#define __GLX_BEGIN_VARIABLE_WITH_PIXEL_3D(opcode,size) \ + if (pc + (size) > gc->bufEnd) { \ + pc = __glXFlushRenderBuffer(gc, pc); \ + } \ + __GLX_PUT_SHORT(0,size); \ + __GLX_PUT_SHORT(2,opcode); \ + pc += __GLX_RENDER_HDR_SIZE; \ + pixelHeaderPC = pc; \ + pc += __GLX_PIXEL_3D_HDR_SIZE + +#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL_3D(opcode,size) \ + pc = __glXFlushRenderBuffer(gc, pc); \ + __GLX_PUT_LONG(0,size); \ + __GLX_PUT_LONG(4,opcode); \ + pc += __GLX_RENDER_LARGE_HDR_SIZE; \ + pixelHeaderPC = pc; \ + pc += __GLX_PIXEL_3D_HDR_SIZE + +/* +** Fixed size command support macro. This macro is used by calls that +** are never larger than __GLX_SMALL_RENDER_CMD_SIZE. Because they +** always fit in the buffer, and because the buffer promises to +** maintain enough room for them, we don't need to check for space +** before doing the storage work. +*/ +#define __GLX_BEGIN(opcode,size) \ + __GLX_PUT_SHORT(0,size); \ + __GLX_PUT_SHORT(2,opcode) + +/* +** Finish a rendering command by advancing the pc. If the pc is now past +** the limit pointer then there is no longer room for a +** __GLX_SMALL_RENDER_CMD_SIZE sized command, which will break the +** assumptions present in the __GLX_BEGIN macro. In this case the +** rendering buffer is flushed out into the X protocol stream (which may +** or may not do I/O). +*/ +#define __GLX_END(size) \ + pc += size; \ + if (pc > gc->limit) { \ + (void) __glXFlushRenderBuffer(gc, pc); \ + } else { \ + gc->pc = pc; \ + } + +/* Array copy macros */ +#define __GLX_MEM_COPY(dest,src,bytes) \ + if (src && dest) \ + memcpy(dest, src, bytes) + +/* Single item copy macros */ +#define __GLX_PUT_CHAR(offset,a) \ + *((INT8 *) (pc + offset)) = a + +#ifndef _CRAY +#define __GLX_PUT_SHORT(offset,a) \ + *((INT16 *) (pc + offset)) = a + +#define __GLX_PUT_LONG(offset,a) \ + *((INT32 *) (pc + offset)) = a + +#define __GLX_PUT_FLOAT(offset,a) \ + *((FLOAT32 *) (pc + offset)) = a + +#else +#define __GLX_PUT_SHORT(offset,a) \ + { GLubyte *cp = (pc+offset); \ + int shift = (64-16) - ((int)(cp) >> (64-6)); \ + *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); } + +#define __GLX_PUT_LONG(offset,a) \ + { GLubyte *cp = (pc+offset); \ + int shift = (64-32) - ((int)(cp) >> (64-6)); \ + *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); } + +#define __GLX_PUT_FLOAT(offset,a) \ + gl_put_float((pc + offset),a) + +#define __GLX_PUT_DOUBLE(offset,a) \ + gl_put_double(pc + offset, a) + +extern void gl_put_float( /*GLubyte *, struct cray_single */ ); +extern void gl_put_double( /*GLubyte *, struct cray_double */ ); +#endif + +#ifndef _CRAY + +#ifdef __GLX_ALIGN64 +/* +** This can certainly be done better for a particular machine +** architecture! +*/ +#define __GLX_PUT_DOUBLE(offset,a) \ + __GLX_MEM_COPY(pc + offset, &a, 8) +#else +#define __GLX_PUT_DOUBLE(offset,a) \ + *((FLOAT64 *) (pc + offset)) = a +#endif + +#endif + +#define __GLX_PUT_CHAR_ARRAY(offset,a,alen) \ + __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT8) + +#ifndef _CRAY +#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \ + __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT16) + +#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \ + __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT32) + +#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \ + __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT32) + +#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \ + __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT64) + +#else +#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \ + gl_put_short_array((GLubyte *)(pc + offset), a, alen * __GLX_SIZE_INT16) + +#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \ + gl_put_long_array((GLubyte *)(pc + offset), (long *)a, alen * __GLX_SIZE_INT32) + +#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \ + gl_put_float_array((GLubyte *)(pc + offset), (float *)a, alen * __GLX_SIZE_FLOAT32) + +#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \ + gl_put_double_array((GLubyte *)(pc + offset), (double *)a, alen * __GLX_SIZE_FLOAT64) + +extern gl_put_short_array(GLubyte *, short *, int); +extern gl_put_long_array(GLubyte *, long *, int); +extern gl_put_float_array(GLubyte *, float *, int); +extern gl_put_double_array(GLubyte *, double *, int); + +#endif /* _CRAY */ + +#endif /* !__GLX_packrender_h__ */ diff --git a/src/glx/packsingle.h b/src/glx/packsingle.h new file mode 100644 index 00000000000..f33a873f3a7 --- /dev/null +++ b/src/glx/packsingle.h @@ -0,0 +1,213 @@ +#ifndef __GLX_packsingle_h__ +#define __GLX_packsingle_h__ + +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +#include "packrender.h" + +/* +** The macros in this header convert wire protocol data types to the client +** machine's native data types. The header is part of the porting layer of +** the client library, and it is intended that hardware vendors will rewrite +** this header to suit their own machines. +*/ + +/* +** Dummy define to make the GetReqExtra macro happy. The value is not +** used, but instead the code in __GLX_SINGLE_BEGIN issues its own store +** to req->reqType with the proper code (our extension code). +*/ +#define X_GLXSingle 0 + +/* Declare common variables used during a single command */ +#define __GLX_SINGLE_DECLARE_VARIABLES() \ + __GLXcontext *gc = __glXGetCurrentContext(); \ + GLubyte *pc, *pixelHeaderPC; \ + GLuint compsize, cmdlen; \ + Display *dpy = gc->currentDpy; \ + xGLXSingleReq *req + +#define __GLX_SINGLE_LOAD_VARIABLES() \ + pc = gc->pc; \ + /* Muffle compilers */ \ + pixelHeaderPC = 0; (void)pixelHeaderPC; \ + compsize = 0; (void)compsize; \ + cmdlen = 0; (void)cmdlen + +/* Start a single command */ +#define __GLX_SINGLE_BEGIN(opcode,bytes) \ + if (dpy) { \ + (void) __glXFlushRenderBuffer(gc, pc); \ + LockDisplay(dpy); \ + GetReqExtra(GLXSingle,bytes,req); \ + req->reqType = gc->majorOpcode; \ + req->glxCode = opcode; \ + req->contextTag = gc->currentContextTag; \ + pc = ((GLubyte *)(req) + sz_xGLXSingleReq) + +/* End a single command */ +#define __GLX_SINGLE_END() \ + UnlockDisplay(dpy); \ + SyncHandle(); \ + } + +/* Store data to sending for a single command */ +#define __GLX_SINGLE_PUT_CHAR(offset,a) \ + *((INT8 *) (pc + offset)) = a + +#ifndef CRAY +#define __GLX_SINGLE_PUT_SHORT(offset,a) \ + *((INT16 *) (pc + offset)) = a + +#define __GLX_SINGLE_PUT_LONG(offset,a) \ + *((INT32 *) (pc + offset)) = a + +#define __GLX_SINGLE_PUT_FLOAT(offset,a) \ + *((FLOAT32 *) (pc + offset)) = a + +#else +#define __GLX_SINGLE_PUT_SHORT(offset,a) \ + { GLubyte *cp = (pc+offset); \ + int shift = (64-16) - ((int)(cp) >> (64-6)); \ + *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); } + +#define __GLX_SINGLE_PUT_LONG(offset,a) \ + { GLubyte *cp = (pc+offset); \ + int shift = (64-32) - ((int)(cp) >> (64-6)); \ + *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); } + +#define __GLX_SINGLE_PUT_FLOAT(offset,a) \ + gl_put_float(pc + offset, a) +#endif + +/* Read support macros */ +#define __GLX_SINGLE_READ_XREPLY() \ + (void) _XReply(dpy, (xReply*) &reply, 0, False) + +#define __GLX_SINGLE_GET_RETVAL(a,cast) \ + a = (cast) reply.retval + +#define __GLX_SINGLE_GET_SIZE(a) \ + a = (GLint) reply.size + +#ifndef _CRAY +#define __GLX_SINGLE_GET_CHAR(p) \ + *p = *(GLbyte *)&reply.pad3; + +#define __GLX_SINGLE_GET_SHORT(p) \ + *p = *(GLshort *)&reply.pad3; + +#define __GLX_SINGLE_GET_LONG(p) \ + *p = *(GLint *)&reply.pad3; + +#define __GLX_SINGLE_GET_FLOAT(p) \ + *p = *(GLfloat *)&reply.pad3; + +#else +#define __GLX_SINGLE_GET_CHAR(p) \ + *p = reply.pad3 >> 24; + +#define __GLX_SINGLE_GET_SHORT(p) \ + {int t = reply.pad3 >> 16; \ + *p = (t & 0x8000) ? (t | ~0xffff) : (t & 0xffff);} + +#define __GLX_SINGLE_GET_LONG(p) \ + {int t = reply.pad3; \ + *p = (t & 0x80000000) ? (t | ~0xffffffff) : (t & 0xffffffff);} + +#define PAD3OFFSET 16 +#define __GLX_SINGLE_GET_FLOAT(p) \ + *p = gl_ntoh_float((GLubyte *)&reply + PAD3OFFSET); + +#define __GLX_SINGLE_GET_DOUBLE(p) \ + *p = gl_ntoh_double((GLubyte *)&reply + PAD3OFFSET); + +extern float gl_ntoh_float(GLubyte *); +extern float gl_ntoh_double(GLubyte *); +#endif + +#ifndef _CRAY + +#ifdef __GLX_ALIGN64 +#define __GLX_SINGLE_GET_DOUBLE(p) \ + __GLX_MEM_COPY(p, &reply.pad3, 8) +#else +#define __GLX_SINGLE_GET_DOUBLE(p) \ + *p = *(GLdouble *)&reply.pad3 +#endif + +#endif + +/* Get an array of typed data */ +#define __GLX_SINGLE_GET_VOID_ARRAY(a,alen) \ + { \ + GLint slop = alen*__GLX_SIZE_INT8 & 3; \ + _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \ + if (slop) _XEatData(dpy,4-slop); \ + } + +#define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen) \ + { \ + GLint slop = alen*__GLX_SIZE_INT8 & 3; \ + _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \ + if (slop) _XEatData(dpy,4-slop); \ + } + + +#define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen) \ + { \ + GLint slop = (alen*__GLX_SIZE_INT16) & 3; \ + _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16); \ + if (slop) _XEatData(dpy,4-slop); \ + } + +#define __GLX_SINGLE_GET_LONG_ARRAY(a,alen) \ + _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32); + +#ifndef _CRAY +#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \ + _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32); + +#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \ + _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64); + +#else +#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \ + gl_get_float_array(dpy,a,alen); + +#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \ + gl_get_double_array(dpy, a, alen); + +extern void gl_get_float_array(Display * dpy, float *a, int alen); +extern void gl_get_double_array(Display * dpy, double *a, int alen); +#endif + +#endif /* !__GLX_packsingle_h__ */ diff --git a/src/glx/pixel.c b/src/glx/pixel.c new file mode 100644 index 00000000000..d36ca31e7dd --- /dev/null +++ b/src/glx/pixel.c @@ -0,0 +1,461 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +#include "packrender.h" + +static const GLubyte MsbToLsbTable[256] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, +}; + +static const GLubyte LowBitsMask[9] = { + 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff, +}; + +static const GLubyte HighBitsMask[9] = { + 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff, +}; + + +/* +** Copy bitmap data from clients packed memory applying unpacking modes as the +** data is transfered into the destImage buffer. Return in modes the +** set of pixel modes that are to be done by the server. +*/ +static void +FillBitmap(__GLXcontext * gc, GLint width, GLint height, + GLenum format, const GLvoid * userdata, GLubyte * destImage) +{ + const __GLXattribute *state = gc->client_state_private; + GLint rowLength = state->storeUnpack.rowLength; + GLint alignment = state->storeUnpack.alignment; + GLint skipPixels = state->storeUnpack.skipPixels; + GLint skipRows = state->storeUnpack.skipRows; + GLint lsbFirst = state->storeUnpack.lsbFirst; + GLint elementsLeft, bitOffset, currentByte, nextByte, highBitMask; + GLint lowBitMask, i; + GLint components, groupsPerRow, rowSize, padding, elementsPerRow; + const GLubyte *start, *iter; + + if (rowLength > 0) { + groupsPerRow = rowLength; + } + else { + groupsPerRow = width; + } + components = __glElementsPerGroup(format, GL_BITMAP); + rowSize = (groupsPerRow * components + 7) >> 3; + padding = (rowSize % alignment); + if (padding) { + rowSize += alignment - padding; + } + start = ((const GLubyte *) userdata) + skipRows * rowSize + + ((skipPixels * components) >> 3); + bitOffset = (skipPixels * components) & 7; + highBitMask = LowBitsMask[8 - bitOffset]; + lowBitMask = HighBitsMask[bitOffset]; + elementsPerRow = width * components; + for (i = 0; i < height; i++) { + elementsLeft = elementsPerRow; + iter = start; + while (elementsLeft) { + /* First retrieve low bits from current byte */ + if (lsbFirst) { + currentByte = MsbToLsbTable[iter[0]]; + } + else { + currentByte = iter[0]; + } + if (bitOffset) { + /* Need to read next byte to finish current byte */ + if (elementsLeft > (8 - bitOffset)) { + if (lsbFirst) { + nextByte = MsbToLsbTable[iter[1]]; + } + else { + nextByte = iter[1]; + } + currentByte = + ((currentByte & highBitMask) << bitOffset) | + ((nextByte & lowBitMask) >> (8 - bitOffset)); + } + else { + currentByte = ((currentByte & highBitMask) << bitOffset); + } + } + if (elementsLeft >= 8) { + *destImage = currentByte; + elementsLeft -= 8; + } + else { + *destImage = currentByte & HighBitsMask[elementsLeft]; + elementsLeft = 0; + } + destImage++; + iter++; + } + start += rowSize; + } +} + +/* +** Extract array from user's data applying all pixel store modes. +** The internal packed array format used has LSB_FIRST = FALSE and +** ALIGNMENT = 1. +*/ +void +__glFillImage(__GLXcontext * gc, GLint dim, GLint width, GLint height, + GLint depth, GLenum format, GLenum type, + const GLvoid * userdata, GLubyte * newimage, GLubyte * modes) +{ + const __GLXattribute *state = gc->client_state_private; + GLint rowLength = state->storeUnpack.rowLength; + GLint imageHeight = state->storeUnpack.imageHeight; + GLint alignment = state->storeUnpack.alignment; + GLint skipPixels = state->storeUnpack.skipPixels; + GLint skipRows = state->storeUnpack.skipRows; + GLint skipImages = state->storeUnpack.skipImages; + GLint swapBytes = state->storeUnpack.swapEndian; + GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize; + GLint elementsPerRow, imageSize, rowsPerImage, h, i, j, k; + const GLubyte *start, *iter, *itera, *iterb, *iterc; + GLubyte *iter2; + + if (type == GL_BITMAP) { + FillBitmap(gc, width, height, format, userdata, newimage); + } + else { + components = __glElementsPerGroup(format, type); + if (rowLength > 0) { + groupsPerRow = rowLength; + } + else { + groupsPerRow = width; + } + if (imageHeight > 0) { + rowsPerImage = imageHeight; + } + else { + rowsPerImage = height; + } + + elementSize = __glBytesPerElement(type); + groupSize = elementSize * components; + if (elementSize == 1) + swapBytes = 0; + + rowSize = groupsPerRow * groupSize; + padding = (rowSize % alignment); + if (padding) { + rowSize += alignment - padding; + } + imageSize = rowSize * rowsPerImage; + start = ((const GLubyte *) userdata) + skipImages * imageSize + + skipRows * rowSize + skipPixels * groupSize; + iter2 = newimage; + elementsPerRow = width * components; + + if (swapBytes) { + itera = start; + for (h = 0; h < depth; h++) { + iterb = itera; + for (i = 0; i < height; i++) { + iterc = iterb; + for (j = 0; j < elementsPerRow; j++) { + for (k = 1; k <= elementSize; k++) { + iter2[k - 1] = iterc[elementSize - k]; + } + iter2 += elementSize; + iterc += elementSize; + } + iterb += rowSize; + } + itera += imageSize; + } + } + else { + itera = start; + for (h = 0; h < depth; h++) { + if (rowSize == elementsPerRow * elementSize) { + /* Ha! This is mondo easy! */ + __GLX_MEM_COPY(iter2, itera, + elementsPerRow * elementSize * height); + iter2 += elementsPerRow * elementSize * height; + } + else { + iter = itera; + for (i = 0; i < height; i++) { + __GLX_MEM_COPY(iter2, iter, elementsPerRow * elementSize); + iter2 += elementsPerRow * elementSize; + iter += rowSize; + } + } + itera += imageSize; + } + } + } + + /* Setup store modes that describe what we just did */ + if (modes) { + if (dim < 3) { + (void) memcpy(modes, __glXDefaultPixelStore + 4, 20); + } + else { + (void) memcpy(modes, __glXDefaultPixelStore + 0, 36); + } + } +} + +/* +** Empty a bitmap in LSB_FIRST=GL_FALSE and ALIGNMENT=4 format packing it +** into the clients memory using the pixel store PACK modes. +*/ +static void +EmptyBitmap(__GLXcontext * gc, GLint width, GLint height, + GLenum format, const GLubyte * sourceImage, GLvoid * userdata) +{ + const __GLXattribute *state = gc->client_state_private; + GLint rowLength = state->storePack.rowLength; + GLint alignment = state->storePack.alignment; + GLint skipPixels = state->storePack.skipPixels; + GLint skipRows = state->storePack.skipRows; + GLint lsbFirst = state->storePack.lsbFirst; + GLint components, groupsPerRow, rowSize, padding, elementsPerRow; + GLint sourceRowSize, sourcePadding, sourceSkip; + GLubyte *start, *iter; + GLint elementsLeft, bitOffset, currentByte, highBitMask, lowBitMask; + GLint writeMask, i; + GLubyte writeByte; + + components = __glElementsPerGroup(format, GL_BITMAP); + if (rowLength > 0) { + groupsPerRow = rowLength; + } + else { + groupsPerRow = width; + } + + rowSize = (groupsPerRow * components + 7) >> 3; + padding = (rowSize % alignment); + if (padding) { + rowSize += alignment - padding; + } + sourceRowSize = (width * components + 7) >> 3; + sourcePadding = (sourceRowSize % 4); + if (sourcePadding) { + sourceSkip = 4 - sourcePadding; + } + else { + sourceSkip = 0; + } + start = ((GLubyte *) userdata) + skipRows * rowSize + + ((skipPixels * components) >> 3); + bitOffset = (skipPixels * components) & 7; + highBitMask = LowBitsMask[8 - bitOffset]; + lowBitMask = HighBitsMask[bitOffset]; + elementsPerRow = width * components; + for (i = 0; i < height; i++) { + elementsLeft = elementsPerRow; + iter = start; + writeMask = highBitMask; + writeByte = 0; + while (elementsLeft) { + /* Set up writeMask (to write to current byte) */ + if (elementsLeft + bitOffset < 8) { + /* Need to trim writeMask */ + writeMask &= HighBitsMask[bitOffset + elementsLeft]; + } + + if (lsbFirst) { + currentByte = MsbToLsbTable[iter[0]]; + } + else { + currentByte = iter[0]; + } + + if (bitOffset) { + writeByte |= (sourceImage[0] >> bitOffset); + currentByte = (currentByte & ~writeMask) | + (writeByte & writeMask); + writeByte = (sourceImage[0] << (8 - bitOffset)); + } + else { + currentByte = (currentByte & ~writeMask) | + (sourceImage[0] & writeMask); + } + + if (lsbFirst) { + iter[0] = MsbToLsbTable[currentByte]; + } + else { + iter[0] = currentByte; + } + + if (elementsLeft >= 8) { + elementsLeft -= 8; + } + else { + elementsLeft = 0; + } + sourceImage++; + iter++; + writeMask = 0xff; + } + if (writeByte) { + /* Some data left over that still needs writing */ + writeMask &= lowBitMask; + if (lsbFirst) { + currentByte = MsbToLsbTable[iter[0]]; + } + else { + currentByte = iter[0]; + } + currentByte = (currentByte & ~writeMask) | (writeByte & writeMask); + if (lsbFirst) { + iter[0] = MsbToLsbTable[currentByte]; + } + else { + iter[0] = currentByte; + } + } + start += rowSize; + sourceImage += sourceSkip; + } +} + +/* +** Insert array into user's data applying all pixel store modes. +** The packed array format from the server is LSB_FIRST = FALSE, +** SWAP_BYTES = the current pixel storage pack mode, and ALIGNMENT = 4. +** Named __glEmptyImage() because it is the opposite of __glFillImage(). +*/ +/* ARGSUSED */ +void +__glEmptyImage(__GLXcontext * gc, GLint dim, GLint width, GLint height, + GLint depth, GLenum format, GLenum type, + const GLubyte * sourceImage, GLvoid * userdata) +{ + const __GLXattribute *state = gc->client_state_private; + GLint rowLength = state->storePack.rowLength; + GLint imageHeight = state->storePack.imageHeight; + GLint alignment = state->storePack.alignment; + GLint skipPixels = state->storePack.skipPixels; + GLint skipRows = state->storePack.skipRows; + GLint skipImages = state->storePack.skipImages; + GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize; + GLint elementsPerRow, sourceRowSize, sourcePadding, h, i; + GLint imageSize, rowsPerImage; + GLubyte *start, *iter, *itera; + + if (type == GL_BITMAP) { + EmptyBitmap(gc, width, height, format, sourceImage, userdata); + } + else { + components = __glElementsPerGroup(format, type); + if (rowLength > 0) { + groupsPerRow = rowLength; + } + else { + groupsPerRow = width; + } + if (imageHeight > 0) { + rowsPerImage = imageHeight; + } + else { + rowsPerImage = height; + } + elementSize = __glBytesPerElement(type); + groupSize = elementSize * components; + rowSize = groupsPerRow * groupSize; + padding = (rowSize % alignment); + if (padding) { + rowSize += alignment - padding; + } + sourceRowSize = width * groupSize; + sourcePadding = (sourceRowSize % 4); + if (sourcePadding) { + sourceRowSize += 4 - sourcePadding; + } + imageSize = sourceRowSize * rowsPerImage; + start = ((GLubyte *) userdata) + skipImages * imageSize + + skipRows * rowSize + skipPixels * groupSize; + elementsPerRow = width * components; + + itera = start; + for (h = 0; h < depth; h++) { + if ((rowSize == sourceRowSize) && (sourcePadding == 0)) { + /* Ha! This is mondo easy! */ + __GLX_MEM_COPY(itera, sourceImage, + elementsPerRow * elementSize * height); + sourceImage += elementsPerRow * elementSize * height; + } + else { + iter = itera; + for (i = 0; i < height; i++) { + __GLX_MEM_COPY(iter, sourceImage, + elementsPerRow * elementSize); + sourceImage += sourceRowSize; + iter += rowSize; + } + } + itera += imageSize; + } + } +} diff --git a/src/glx/pixelstore.c b/src/glx/pixelstore.c new file mode 100644 index 00000000000..8b51b5d8b7f --- /dev/null +++ b/src/glx/pixelstore.c @@ -0,0 +1,352 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +#include "glxclient.h" +#include "indirect.h" + +#if !defined __GNUC__ || __GNUC__ < 3 +# define __builtin_expect(x, y) x +#endif + +/** + * Send glPixelStore command to the server + * + * \param gc Current GLX context + * \param sop Either \c X_GLsop_PixelStoref or \c X_GLsop_PixelStorei + * \param pname Selector of which pixel parameter is to be set. + * \param param Value that \c pname is set to. + * + * \sa __indirect_glPixelStorei, __indirect_glPixelStoref + */ +static void +send_PixelStore(__GLXcontext * gc, unsigned sop, GLenum pname, + const void *param) +{ + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = 8; + if (__builtin_expect(dpy != NULL, 1)) { + GLubyte const *pc = __glXSetupSingleRequest(gc, sop, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&pname), 4); + (void) memcpy((void *) (pc + 4), param, 4); + UnlockDisplay(dpy); + SyncHandle(); + } + return; +} + +/* +** Specify parameters that control the storage format of pixel arrays. +*/ +void +__indirect_glPixelStoref(GLenum pname, GLfloat param) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = gc->client_state_private; + Display *dpy = gc->currentDpy; + GLuint a; + + if (!dpy) + return; + + switch (pname) { + case GL_PACK_ROW_LENGTH: + a = (GLuint) (param + 0.5); + if (((GLint) a) < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storePack.rowLength = a; + break; + case GL_PACK_IMAGE_HEIGHT: + a = (GLuint) (param + 0.5); + if (((GLint) a) < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storePack.imageHeight = a; + break; + case GL_PACK_SKIP_ROWS: + a = (GLuint) (param + 0.5); + if (((GLint) a) < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storePack.skipRows = a; + break; + case GL_PACK_SKIP_PIXELS: + a = (GLuint) (param + 0.5); + if (((GLint) a) < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storePack.skipPixels = a; + break; + case GL_PACK_SKIP_IMAGES: + a = (GLuint) (param + 0.5); + if (((GLint) a) < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storePack.skipImages = a; + break; + case GL_PACK_ALIGNMENT: + a = (GLint) (param + 0.5); + switch (a) { + case 1: + case 2: + case 4: + case 8: + state->storePack.alignment = a; + break; + default: + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + break; + case GL_PACK_SWAP_BYTES: + state->storePack.swapEndian = (param != 0); + break; + case GL_PACK_LSB_FIRST: + state->storePack.lsbFirst = (param != 0); + break; + + case GL_UNPACK_ROW_LENGTH: + a = (GLuint) (param + 0.5); + if (((GLint) a) < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storeUnpack.rowLength = a; + break; + case GL_UNPACK_IMAGE_HEIGHT: + a = (GLuint) (param + 0.5); + if (((GLint) a) < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storeUnpack.imageHeight = a; + break; + case GL_UNPACK_SKIP_ROWS: + a = (GLuint) (param + 0.5); + if (((GLint) a) < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storeUnpack.skipRows = a; + break; + case GL_UNPACK_SKIP_PIXELS: + a = (GLuint) (param + 0.5); + if (((GLint) a) < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storeUnpack.skipPixels = a; + break; + case GL_UNPACK_SKIP_IMAGES: + a = (GLuint) (param + 0.5); + if (((GLint) a) < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storeUnpack.skipImages = a; + break; + case GL_UNPACK_ALIGNMENT: + a = (GLint) (param + 0.5); + switch (a) { + case 1: + case 2: + case 4: + case 8: + state->storeUnpack.alignment = a; + break; + default: + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + break; + case GL_UNPACK_SWAP_BYTES: + state->storeUnpack.swapEndian = (param != 0); + break; + case GL_UNPACK_LSB_FIRST: + state->storeUnpack.lsbFirst = (param != 0); + break; + + /* Group all of the pixel store modes that need to be sent to the + * server here. Care must be used to only send modes to the server that + * won't affect the size of the data sent to or received from the + * server. GL_PACK_INVERT_MESA is safe in this respect, but other, + * future modes may not be. + */ + case GL_PACK_INVERT_MESA: + send_PixelStore(gc, X_GLsop_PixelStoref, pname, ¶m); + break; + + default: + __glXSetError(gc, GL_INVALID_ENUM); + break; + } +} + +void +__indirect_glPixelStorei(GLenum pname, GLint param) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = gc->client_state_private; + Display *dpy = gc->currentDpy; + + if (!dpy) + return; + + switch (pname) { + case GL_PACK_ROW_LENGTH: + if (param < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storePack.rowLength = param; + break; + case GL_PACK_IMAGE_HEIGHT: + if (param < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storePack.imageHeight = param; + break; + case GL_PACK_SKIP_ROWS: + if (param < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storePack.skipRows = param; + break; + case GL_PACK_SKIP_PIXELS: + if (param < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storePack.skipPixels = param; + break; + case GL_PACK_SKIP_IMAGES: + if (param < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storePack.skipImages = param; + break; + case GL_PACK_ALIGNMENT: + switch (param) { + case 1: + case 2: + case 4: + case 8: + state->storePack.alignment = param; + break; + default: + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + break; + case GL_PACK_SWAP_BYTES: + state->storePack.swapEndian = (param != 0); + break; + case GL_PACK_LSB_FIRST: + state->storePack.lsbFirst = (param != 0); + break; + + case GL_UNPACK_ROW_LENGTH: + if (param < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storeUnpack.rowLength = param; + break; + case GL_UNPACK_IMAGE_HEIGHT: + if (param < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storeUnpack.imageHeight = param; + break; + case GL_UNPACK_SKIP_ROWS: + if (param < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storeUnpack.skipRows = param; + break; + case GL_UNPACK_SKIP_PIXELS: + if (param < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storeUnpack.skipPixels = param; + break; + case GL_UNPACK_SKIP_IMAGES: + if (param < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + state->storeUnpack.skipImages = param; + break; + case GL_UNPACK_ALIGNMENT: + switch (param) { + case 1: + case 2: + case 4: + case 8: + state->storeUnpack.alignment = param; + break; + default: + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + break; + case GL_UNPACK_SWAP_BYTES: + state->storeUnpack.swapEndian = (param != 0); + break; + case GL_UNPACK_LSB_FIRST: + state->storeUnpack.lsbFirst = (param != 0); + break; + + /* Group all of the pixel store modes that need to be sent to the + * server here. Care must be used to only send modes to the server that + * won't affect the size of the data sent to or received from the + * server. GL_PACK_INVERT_MESA is safe in this respect, but other, + * future modes may not be. + */ + case GL_PACK_INVERT_MESA: + send_PixelStore(gc, X_GLsop_PixelStorei, pname, ¶m); + break; + + default: + __glXSetError(gc, GL_INVALID_ENUM); + break; + } +} diff --git a/src/glx/render2.c b/src/glx/render2.c new file mode 100644 index 00000000000..762950f4ac4 --- /dev/null +++ b/src/glx/render2.c @@ -0,0 +1,381 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +#include "packrender.h" +#include "indirect.h" +#include "indirect_size.h" + +/* +** This file contains routines that might need to be transported as +** GLXRender or GLXRenderLarge commands, and these commands don't +** use the pixel header. See renderpix.c for those routines. +*/ + +void +__indirect_glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble * pnts) +{ + __GLX_DECLARE_VARIABLES(); + GLint k; + + __GLX_LOAD_VARIABLES(); + k = __glMap1d_size(target); + if (k == 0) { + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + else if (stride < k || order <= 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + compsize = k * order * __GLX_SIZE_FLOAT64; + cmdlen = 28 + compsize; + if (!gc->currentDpy) + return; + + if (cmdlen <= gc->maxSmallRenderCommandSize) { + /* Use GLXRender protocol to send small command */ + __GLX_BEGIN_VARIABLE(X_GLrop_Map1d, cmdlen); + __GLX_PUT_DOUBLE(4, u1); + __GLX_PUT_DOUBLE(12, u2); + __GLX_PUT_LONG(20, target); + __GLX_PUT_LONG(24, order); + /* + ** NOTE: the doubles that follow are not aligned because of 3 + ** longs preceeding + */ + __glFillMap1d(k, order, stride, pnts, (pc + 28)); + __GLX_END(cmdlen); + } + else { + /* Use GLXRenderLarge protocol to send command */ + __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1d, cmdlen + 4); + __GLX_PUT_DOUBLE(8, u1); + __GLX_PUT_DOUBLE(16, u2); + __GLX_PUT_LONG(24, target); + __GLX_PUT_LONG(28, order); + + /* + ** NOTE: the doubles that follow are not aligned because of 3 + ** longs preceeding + */ + if (stride != k) { + GLubyte *buf; + + buf = (GLubyte *) Xmalloc(compsize); + if (!buf) { + __glXSetError(gc, GL_OUT_OF_MEMORY); + return; + } + __glFillMap1d(k, order, stride, pnts, buf); + __glXSendLargeCommand(gc, pc, 32, buf, compsize); + Xfree((char *) buf); + } + else { + /* Data is already packed. Just send it out */ + __glXSendLargeCommand(gc, pc, 32, pnts, compsize); + } + } +} + +void +__indirect_glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat * pnts) +{ + __GLX_DECLARE_VARIABLES(); + GLint k; + + __GLX_LOAD_VARIABLES(); + k = __glMap1f_size(target); + if (k == 0) { + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + else if (stride < k || order <= 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + compsize = k * order * __GLX_SIZE_FLOAT32; + cmdlen = 20 + compsize; + if (!gc->currentDpy) + return; + + /* + ** The order that arguments are packed is different from the order + ** for glMap1d. + */ + if (cmdlen <= gc->maxSmallRenderCommandSize) { + /* Use GLXRender protocol to send small command */ + __GLX_BEGIN_VARIABLE(X_GLrop_Map1f, cmdlen); + __GLX_PUT_LONG(4, target); + __GLX_PUT_FLOAT(8, u1); + __GLX_PUT_FLOAT(12, u2); + __GLX_PUT_LONG(16, order); + __glFillMap1f(k, order, stride, pnts, (GLubyte *) (pc + 20)); + __GLX_END(cmdlen); + } + else { + /* Use GLXRenderLarge protocol to send command */ + __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1f, cmdlen + 4); + __GLX_PUT_LONG(8, target); + __GLX_PUT_FLOAT(12, u1); + __GLX_PUT_FLOAT(16, u2); + __GLX_PUT_LONG(20, order); + + if (stride != k) { + GLubyte *buf; + + buf = (GLubyte *) Xmalloc(compsize); + if (!buf) { + __glXSetError(gc, GL_OUT_OF_MEMORY); + return; + } + __glFillMap1f(k, order, stride, pnts, buf); + __glXSendLargeCommand(gc, pc, 24, buf, compsize); + Xfree((char *) buf); + } + else { + /* Data is already packed. Just send it out */ + __glXSendLargeCommand(gc, pc, 24, pnts, compsize); + } + } +} + +void +__indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr, + GLint uord, GLdouble v1, GLdouble v2, GLint vstr, + GLint vord, const GLdouble * pnts) +{ + __GLX_DECLARE_VARIABLES(); + GLint k; + + __GLX_LOAD_VARIABLES(); + k = __glMap2d_size(target); + if (k == 0) { + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + compsize = k * uord * vord * __GLX_SIZE_FLOAT64; + cmdlen = 48 + compsize; + if (!gc->currentDpy) + return; + + if (cmdlen <= gc->maxSmallRenderCommandSize) { + /* Use GLXRender protocol to send small command */ + __GLX_BEGIN_VARIABLE(X_GLrop_Map2d, cmdlen); + __GLX_PUT_DOUBLE(4, u1); + __GLX_PUT_DOUBLE(12, u2); + __GLX_PUT_DOUBLE(20, v1); + __GLX_PUT_DOUBLE(28, v2); + __GLX_PUT_LONG(36, target); + __GLX_PUT_LONG(40, uord); + __GLX_PUT_LONG(44, vord); + /* + ** Pack into a u-major ordering. + ** NOTE: the doubles that follow are not aligned because of 5 + ** longs preceeding + */ + __glFillMap2d(k, uord, vord, ustr, vstr, pnts, (GLdouble *) (pc + 48)); + __GLX_END(cmdlen); + } + else { + /* Use GLXRenderLarge protocol to send command */ + __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2d, cmdlen + 4); + __GLX_PUT_DOUBLE(8, u1); + __GLX_PUT_DOUBLE(16, u2); + __GLX_PUT_DOUBLE(24, v1); + __GLX_PUT_DOUBLE(32, v2); + __GLX_PUT_LONG(40, target); + __GLX_PUT_LONG(44, uord); + __GLX_PUT_LONG(48, vord); + + /* + ** NOTE: the doubles that follow are not aligned because of 5 + ** longs preceeding + */ + if ((vstr != k) || (ustr != k * vord)) { + GLdouble *buf; + + buf = (GLdouble *) Xmalloc(compsize); + if (!buf) { + __glXSetError(gc, GL_OUT_OF_MEMORY); + return; + } + /* + ** Pack into a u-major ordering. + */ + __glFillMap2d(k, uord, vord, ustr, vstr, pnts, buf); + __glXSendLargeCommand(gc, pc, 52, buf, compsize); + Xfree((char *) buf); + } + else { + /* Data is already packed. Just send it out */ + __glXSendLargeCommand(gc, pc, 52, pnts, compsize); + } + } +} + +void +__indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr, + GLint uord, GLfloat v1, GLfloat v2, GLint vstr, GLint vord, + const GLfloat * pnts) +{ + __GLX_DECLARE_VARIABLES(); + GLint k; + + __GLX_LOAD_VARIABLES(); + k = __glMap2f_size(target); + if (k == 0) { + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + compsize = k * uord * vord * __GLX_SIZE_FLOAT32; + cmdlen = 32 + compsize; + if (!gc->currentDpy) + return; + + /* + ** The order that arguments are packed is different from the order + ** for glMap2d. + */ + if (cmdlen <= gc->maxSmallRenderCommandSize) { + /* Use GLXRender protocol to send small command */ + __GLX_BEGIN_VARIABLE(X_GLrop_Map2f, cmdlen); + __GLX_PUT_LONG(4, target); + __GLX_PUT_FLOAT(8, u1); + __GLX_PUT_FLOAT(12, u2); + __GLX_PUT_LONG(16, uord); + __GLX_PUT_FLOAT(20, v1); + __GLX_PUT_FLOAT(24, v2); + __GLX_PUT_LONG(28, vord); + /* + ** Pack into a u-major ordering. + */ + __glFillMap2f(k, uord, vord, ustr, vstr, pnts, (GLfloat *) (pc + 32)); + __GLX_END(cmdlen); + } + else { + /* Use GLXRenderLarge protocol to send command */ + __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2f, cmdlen + 4); + __GLX_PUT_LONG(8, target); + __GLX_PUT_FLOAT(12, u1); + __GLX_PUT_FLOAT(16, u2); + __GLX_PUT_LONG(20, uord); + __GLX_PUT_FLOAT(24, v1); + __GLX_PUT_FLOAT(28, v2); + __GLX_PUT_LONG(32, vord); + + if ((vstr != k) || (ustr != k * vord)) { + GLfloat *buf; + + buf = (GLfloat *) Xmalloc(compsize); + if (!buf) { + __glXSetError(gc, GL_OUT_OF_MEMORY); + return; + } + /* + ** Pack into a u-major ordering. + */ + __glFillMap2f(k, uord, vord, ustr, vstr, pnts, buf); + __glXSendLargeCommand(gc, pc, 36, buf, compsize); + Xfree((char *) buf); + } + else { + /* Data is already packed. Just send it out */ + __glXSendLargeCommand(gc, pc, 36, pnts, compsize); + } + } +} + +void +__indirect_glEnable(GLenum cap) +{ + __GLX_DECLARE_VARIABLES(); + + __GLX_LOAD_VARIABLES(); + if (!gc->currentDpy) + return; + + switch (cap) { + case GL_COLOR_ARRAY: + case GL_EDGE_FLAG_ARRAY: + case GL_INDEX_ARRAY: + case GL_NORMAL_ARRAY: + case GL_TEXTURE_COORD_ARRAY: + case GL_VERTEX_ARRAY: + case GL_SECONDARY_COLOR_ARRAY: + case GL_FOG_COORD_ARRAY: + __indirect_glEnableClientState(cap); + return; + default: + break; + } + + __GLX_BEGIN(X_GLrop_Enable, 8); + __GLX_PUT_LONG(4, cap); + __GLX_END(8); +} + +void +__indirect_glDisable(GLenum cap) +{ + __GLX_DECLARE_VARIABLES(); + + __GLX_LOAD_VARIABLES(); + if (!gc->currentDpy) + return; + + switch (cap) { + case GL_COLOR_ARRAY: + case GL_EDGE_FLAG_ARRAY: + case GL_INDEX_ARRAY: + case GL_NORMAL_ARRAY: + case GL_TEXTURE_COORD_ARRAY: + case GL_VERTEX_ARRAY: + case GL_SECONDARY_COLOR_ARRAY: + case GL_FOG_COORD_ARRAY: + __indirect_glDisableClientState(cap); + return; + default: + break; + } + + __GLX_BEGIN(X_GLrop_Disable, 8); + __GLX_PUT_LONG(4, cap); + __GLX_END(8); +} diff --git a/src/glx/renderpix.c b/src/glx/renderpix.c new file mode 100644 index 00000000000..9919bbcde3b --- /dev/null +++ b/src/glx/renderpix.c @@ -0,0 +1,218 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +/* + * (C) Copyright IBM Corporation 2005 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "packrender.h" +#include "indirect.h" + +/** + * Send a large image to the server. If necessary, a buffer is allocated + * to hold the unpacked data that is copied from the clients memory. + * + * \param gc Current GLX context + * \param compsize Size, in bytes, of the image portion + * \param dim Number of dimensions of the image + * \param width Width of the image + * \param height Height of the image, must be 1 for 1D images + * \param depth Depth of the image, must be 1 for 1D or 2D images + * \param format Format of the image + * \param type Data type of the image + * \param src Pointer to the image data + * \param pc Pointer to end of the command header + * \param modes Pointer to the pixel unpack data + * + * \todo + * Modify this function so that \c NULL images are sent using + * \c __glXSendLargeChunk instead of __glXSendLargeCommand. Doing this + * will eliminate the need to allocate a buffer for that case. + * + * \bugs + * The \c fastImageUnpack path, which is thankfully never used, is completely + * broken. + */ +void +__glXSendLargeImage(__GLXcontext * gc, GLint compsize, GLint dim, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, const GLvoid * src, + GLubyte * pc, GLubyte * modes) +{ + if (!gc->fastImageUnpack || (src == NULL)) { + /* Allocate a temporary holding buffer */ + GLubyte *buf = (GLubyte *) Xmalloc(compsize); + if (!buf) { + __glXSetError(gc, GL_OUT_OF_MEMORY); + return; + } + + /* Apply pixel store unpack modes to copy data into buf */ + if (src != NULL) { + (*gc->fillImage) (gc, dim, width, height, depth, format, type, + src, buf, modes); + } + else { + if (dim < 3) { + (void) memcpy(modes, __glXDefaultPixelStore + 4, 20); + } + else { + (void) memcpy(modes, __glXDefaultPixelStore + 0, 36); + } + } + + /* Send large command */ + __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, buf, compsize); + + /* Free buffer */ + Xfree((char *) buf); + } + else { + /* Just send the data straight as is */ + __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, pc, compsize); + } +} + +/************************************************************************/ + +/** + * Implement GLX protocol for \c glSeparableFilter2D. + * + * \bugs + * The \c fastImageUnpack path, which is thankfully never used, is completely + * broken. + */ +void +__indirect_glSeparableFilter2D(GLenum target, GLenum internalformat, + GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid * row, + const GLvoid * column) +{ + __GLX_DECLARE_VARIABLES(); + GLuint compsize2, hdrlen, totalhdrlen, image1len, image2len; + + __GLX_LOAD_VARIABLES(); + compsize = __glImageSize(width, 1, 1, format, type, 0); + compsize2 = __glImageSize(height, 1, 1, format, type, 0); + totalhdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE); + hdrlen = __GLX_PAD(__GLX_CONV_FILT_HDR_SIZE); + image1len = __GLX_PAD(compsize); + image2len = __GLX_PAD(compsize2); + cmdlen = totalhdrlen + image1len + image2len; + if (!gc->currentDpy) + return; + + if (cmdlen <= gc->maxSmallRenderCommandSize) { + /* Use GLXRender protocol to send small command */ + __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_SeparableFilter2D, cmdlen); + __GLX_PUT_LONG(0, target); + __GLX_PUT_LONG(4, internalformat); + __GLX_PUT_LONG(8, width); + __GLX_PUT_LONG(12, height); + __GLX_PUT_LONG(16, format); + __GLX_PUT_LONG(20, type); + pc += hdrlen; + if (compsize > 0) { + (*gc->fillImage) (gc, 1, width, 1, 1, format, type, + row, pc, pixelHeaderPC); + pc += image1len; + } + if (compsize2 > 0) { + (*gc->fillImage) (gc, 1, height, 1, 1, format, type, + column, pc, NULL); + pc += image2len; + } + if ((compsize == 0) && (compsize2 == 0)) { + /* Setup default store modes */ + (void) memcpy(pixelHeaderPC, __glXDefaultPixelStore + 4, 20); + } + __GLX_END(0); + } + else { + const GLint bufsize = image1len + image2len; + + /* Use GLXRenderLarge protocol to send command */ + __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_SeparableFilter2D, + cmdlen + 4); + __GLX_PUT_LONG(0, target); + __GLX_PUT_LONG(4, internalformat); + __GLX_PUT_LONG(8, width); + __GLX_PUT_LONG(12, height); + __GLX_PUT_LONG(16, format); + __GLX_PUT_LONG(20, type); + pc += hdrlen; + + if (!gc->fastImageUnpack) { + /* Allocate a temporary holding buffer */ + GLubyte *buf = (GLubyte *) Xmalloc(bufsize); + if (!buf) { + __glXSetError(gc, GL_OUT_OF_MEMORY); + return; + } + (*gc->fillImage) (gc, 1, width, 1, 1, format, type, row, buf, + pixelHeaderPC); + + (*gc->fillImage) (gc, 1, height, 1, 1, format, type, column, + buf + image1len, pixelHeaderPC); + + /* Send large command */ + __glXSendLargeCommand(gc, gc->pc, (GLint) (pc - gc->pc), buf, + bufsize); + /* Free buffer */ + Xfree((char *) buf); + } + else { + /* Just send the data straight as is */ + __glXSendLargeCommand(gc, gc->pc, (GLint) (pc - gc->pc), pc, + bufsize); + } + } +} diff --git a/src/glx/single2.c b/src/glx/single2.c new file mode 100644 index 00000000000..9ecf589ffff --- /dev/null +++ b/src/glx/single2.c @@ -0,0 +1,974 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +#include +#include +#include "glxclient.h" +#include "packsingle.h" +#include "glxextensions.h" +#include "indirect.h" +#include "indirect_vertex_array.h" +#include "glapitable.h" +#include "glapidispatch.h" +#include "glapi.h" +#ifdef USE_XCB +#include +#include +#include +#endif /* USE_XCB */ + + +/* Used for GL_ARB_transpose_matrix */ +static void +TransposeMatrixf(GLfloat m[16]) +{ + int i, j; + for (i = 0; i < 4; i++) { + for (j = 0; j < i; j++) { + GLfloat tmp = m[i * 4 + j]; + m[i * 4 + j] = m[j * 4 + i]; + m[j * 4 + i] = tmp; + } + } +} + +/* Used for GL_ARB_transpose_matrix */ +static void +TransposeMatrixb(GLboolean m[16]) +{ + int i, j; + for (i = 0; i < 4; i++) { + for (j = 0; j < i; j++) { + GLboolean tmp = m[i * 4 + j]; + m[i * 4 + j] = m[j * 4 + i]; + m[j * 4 + i] = tmp; + } + } +} + +/* Used for GL_ARB_transpose_matrix */ +static void +TransposeMatrixd(GLdouble m[16]) +{ + int i, j; + for (i = 0; i < 4; i++) { + for (j = 0; j < i; j++) { + GLdouble tmp = m[i * 4 + j]; + m[i * 4 + j] = m[j * 4 + i]; + m[j * 4 + i] = tmp; + } + } +} + +/* Used for GL_ARB_transpose_matrix */ +static void +TransposeMatrixi(GLint m[16]) +{ + int i, j; + for (i = 0; i < 4; i++) { + for (j = 0; j < i; j++) { + GLint tmp = m[i * 4 + j]; + m[i * 4 + j] = m[j * 4 + i]; + m[j * 4 + i] = tmp; + } + } +} + + +/** + * Remap a transpose-matrix enum to a non-transpose-matrix enum. Enums + * that are not transpose-matrix enums are unaffected. + */ +static GLenum +RemapTransposeEnum(GLenum e) +{ + switch (e) { + case GL_TRANSPOSE_MODELVIEW_MATRIX: + case GL_TRANSPOSE_PROJECTION_MATRIX: + case GL_TRANSPOSE_TEXTURE_MATRIX: + return e - (GL_TRANSPOSE_MODELVIEW_MATRIX - GL_MODELVIEW_MATRIX); + case GL_TRANSPOSE_COLOR_MATRIX: + return GL_COLOR_MATRIX; + default: + return e; + }; +} + + +GLenum +__indirect_glGetError(void) +{ + __GLX_SINGLE_DECLARE_VARIABLES(); + GLuint retval = GL_NO_ERROR; + xGLXGetErrorReply reply; + + if (gc->error) { + /* Use internal error first */ + retval = gc->error; + gc->error = GL_NO_ERROR; + return retval; + } + + __GLX_SINGLE_LOAD_VARIABLES(); + __GLX_SINGLE_BEGIN(X_GLsop_GetError, 0); + __GLX_SINGLE_READ_XREPLY(); + retval = reply.error; + __GLX_SINGLE_END(); + + return retval; +} + + +/** + * Get the selected attribute from the client state. + * + * \returns + * On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned. + */ +static GLboolean +get_client_data(__GLXcontext * gc, GLenum cap, GLintptr * data) +{ + GLboolean retval = GL_TRUE; + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + const GLint tex_unit = __glXGetActiveTextureUnit(state); + + + switch (cap) { + case GL_VERTEX_ARRAY: + case GL_NORMAL_ARRAY: + case GL_COLOR_ARRAY: + case GL_INDEX_ARRAY: + case GL_EDGE_FLAG_ARRAY: + case GL_SECONDARY_COLOR_ARRAY: + case GL_FOG_COORD_ARRAY: + retval = __glXGetArrayEnable(state, cap, 0, data); + break; + + case GL_VERTEX_ARRAY_SIZE: + retval = __glXGetArraySize(state, GL_VERTEX_ARRAY, 0, data); + break; + case GL_COLOR_ARRAY_SIZE: + retval = __glXGetArraySize(state, GL_COLOR_ARRAY, 0, data); + break; + case GL_SECONDARY_COLOR_ARRAY_SIZE: + retval = __glXGetArraySize(state, GL_SECONDARY_COLOR_ARRAY, 0, data); + break; + + case GL_VERTEX_ARRAY_TYPE: + retval = __glXGetArrayType(state, GL_VERTEX_ARRAY, 0, data); + break; + case GL_NORMAL_ARRAY_TYPE: + retval = __glXGetArrayType(state, GL_NORMAL_ARRAY, 0, data); + break; + case GL_INDEX_ARRAY_TYPE: + retval = __glXGetArrayType(state, GL_INDEX_ARRAY, 0, data); + break; + case GL_COLOR_ARRAY_TYPE: + retval = __glXGetArrayType(state, GL_COLOR_ARRAY, 0, data); + break; + case GL_SECONDARY_COLOR_ARRAY_TYPE: + retval = __glXGetArrayType(state, GL_SECONDARY_COLOR_ARRAY, 0, data); + break; + case GL_FOG_COORD_ARRAY_TYPE: + retval = __glXGetArrayType(state, GL_FOG_COORD_ARRAY, 0, data); + break; + + case GL_VERTEX_ARRAY_STRIDE: + retval = __glXGetArrayStride(state, GL_VERTEX_ARRAY, 0, data); + break; + case GL_NORMAL_ARRAY_STRIDE: + retval = __glXGetArrayStride(state, GL_NORMAL_ARRAY, 0, data); + break; + case GL_INDEX_ARRAY_STRIDE: + retval = __glXGetArrayStride(state, GL_INDEX_ARRAY, 0, data); + break; + case GL_EDGE_FLAG_ARRAY_STRIDE: + retval = __glXGetArrayStride(state, GL_EDGE_FLAG_ARRAY, 0, data); + break; + case GL_COLOR_ARRAY_STRIDE: + retval = __glXGetArrayStride(state, GL_COLOR_ARRAY, 0, data); + break; + case GL_SECONDARY_COLOR_ARRAY_STRIDE: + retval = __glXGetArrayStride(state, GL_SECONDARY_COLOR_ARRAY, 0, data); + break; + case GL_FOG_COORD_ARRAY_STRIDE: + retval = __glXGetArrayStride(state, GL_FOG_COORD_ARRAY, 0, data); + break; + + case GL_TEXTURE_COORD_ARRAY: + retval = + __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data); + break; + case GL_TEXTURE_COORD_ARRAY_SIZE: + retval = + __glXGetArraySize(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data); + break; + case GL_TEXTURE_COORD_ARRAY_TYPE: + retval = + __glXGetArrayType(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data); + break; + case GL_TEXTURE_COORD_ARRAY_STRIDE: + retval = + __glXGetArrayStride(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data); + break; + + case GL_MAX_ELEMENTS_VERTICES: + case GL_MAX_ELEMENTS_INDICES: + retval = GL_TRUE; + *data = ~0UL; + break; + + + case GL_PACK_ROW_LENGTH: + *data = (GLintptr) state->storePack.rowLength; + break; + case GL_PACK_IMAGE_HEIGHT: + *data = (GLintptr) state->storePack.imageHeight; + break; + case GL_PACK_SKIP_ROWS: + *data = (GLintptr) state->storePack.skipRows; + break; + case GL_PACK_SKIP_PIXELS: + *data = (GLintptr) state->storePack.skipPixels; + break; + case GL_PACK_SKIP_IMAGES: + *data = (GLintptr) state->storePack.skipImages; + break; + case GL_PACK_ALIGNMENT: + *data = (GLintptr) state->storePack.alignment; + break; + case GL_PACK_SWAP_BYTES: + *data = (GLintptr) state->storePack.swapEndian; + break; + case GL_PACK_LSB_FIRST: + *data = (GLintptr) state->storePack.lsbFirst; + break; + case GL_UNPACK_ROW_LENGTH: + *data = (GLintptr) state->storeUnpack.rowLength; + break; + case GL_UNPACK_IMAGE_HEIGHT: + *data = (GLintptr) state->storeUnpack.imageHeight; + break; + case GL_UNPACK_SKIP_ROWS: + *data = (GLintptr) state->storeUnpack.skipRows; + break; + case GL_UNPACK_SKIP_PIXELS: + *data = (GLintptr) state->storeUnpack.skipPixels; + break; + case GL_UNPACK_SKIP_IMAGES: + *data = (GLintptr) state->storeUnpack.skipImages; + break; + case GL_UNPACK_ALIGNMENT: + *data = (GLintptr) state->storeUnpack.alignment; + break; + case GL_UNPACK_SWAP_BYTES: + *data = (GLintptr) state->storeUnpack.swapEndian; + break; + case GL_UNPACK_LSB_FIRST: + *data = (GLintptr) state->storeUnpack.lsbFirst; + break; + case GL_CLIENT_ATTRIB_STACK_DEPTH: + *data = (GLintptr) (gc->attributes.stackPointer - gc->attributes.stack); + break; + case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: + *data = (GLintptr) __GL_CLIENT_ATTRIB_STACK_DEPTH; + break; + case GL_CLIENT_ACTIVE_TEXTURE: + *data = (GLintptr) (tex_unit + GL_TEXTURE0); + break; + + default: + retval = GL_FALSE; + break; + } + + + return retval; +} + + +void +__indirect_glGetBooleanv(GLenum val, GLboolean * b) +{ + const GLenum origVal = val; + __GLX_SINGLE_DECLARE_VARIABLES(); + xGLXSingleReply reply; + + val = RemapTransposeEnum(val); + + __GLX_SINGLE_LOAD_VARIABLES(); + __GLX_SINGLE_BEGIN(X_GLsop_GetBooleanv, 4); + __GLX_SINGLE_PUT_LONG(0, val); + __GLX_SINGLE_READ_XREPLY(); + __GLX_SINGLE_GET_SIZE(compsize); + + if (compsize == 0) { + /* + ** Error occured; don't modify user's buffer. + */ + } + else { + GLintptr data; + + /* + ** We still needed to send the request to the server in order to + ** find out whether it was legal to make a query (it's illegal, + ** for example, to call a query between glBegin() and glEnd()). + */ + + if (get_client_data(gc, val, &data)) { + *b = (GLboolean) data; + } + else { + /* + ** Not a local value, so use what we got from the server. + */ + if (compsize == 1) { + __GLX_SINGLE_GET_CHAR(b); + } + else { + __GLX_SINGLE_GET_CHAR_ARRAY(b, compsize); + if (val != origVal) { + /* matrix transpose */ + TransposeMatrixb(b); + } + } + } + } + __GLX_SINGLE_END(); +} + +void +__indirect_glGetDoublev(GLenum val, GLdouble * d) +{ + const GLenum origVal = val; + __GLX_SINGLE_DECLARE_VARIABLES(); + xGLXSingleReply reply; + + val = RemapTransposeEnum(val); + + __GLX_SINGLE_LOAD_VARIABLES(); + __GLX_SINGLE_BEGIN(X_GLsop_GetDoublev, 4); + __GLX_SINGLE_PUT_LONG(0, val); + __GLX_SINGLE_READ_XREPLY(); + __GLX_SINGLE_GET_SIZE(compsize); + + if (compsize == 0) { + /* + ** Error occured; don't modify user's buffer. + */ + } + else { + GLintptr data; + + /* + ** We still needed to send the request to the server in order to + ** find out whether it was legal to make a query (it's illegal, + ** for example, to call a query between glBegin() and glEnd()). + */ + + if (get_client_data(gc, val, &data)) { + *d = (GLdouble) data; + } + else { + /* + ** Not a local value, so use what we got from the server. + */ + if (compsize == 1) { + __GLX_SINGLE_GET_DOUBLE(d); + } + else { + __GLX_SINGLE_GET_DOUBLE_ARRAY(d, compsize); + if (val != origVal) { + /* matrix transpose */ + TransposeMatrixd(d); + } + } + } + } + __GLX_SINGLE_END(); +} + +void +__indirect_glGetFloatv(GLenum val, GLfloat * f) +{ + const GLenum origVal = val; + __GLX_SINGLE_DECLARE_VARIABLES(); + xGLXSingleReply reply; + + val = RemapTransposeEnum(val); + + __GLX_SINGLE_LOAD_VARIABLES(); + __GLX_SINGLE_BEGIN(X_GLsop_GetFloatv, 4); + __GLX_SINGLE_PUT_LONG(0, val); + __GLX_SINGLE_READ_XREPLY(); + __GLX_SINGLE_GET_SIZE(compsize); + + if (compsize == 0) { + /* + ** Error occured; don't modify user's buffer. + */ + } + else { + GLintptr data; + + /* + ** We still needed to send the request to the server in order to + ** find out whether it was legal to make a query (it's illegal, + ** for example, to call a query between glBegin() and glEnd()). + */ + + if (get_client_data(gc, val, &data)) { + *f = (GLfloat) data; + } + else { + /* + ** Not a local value, so use what we got from the server. + */ + if (compsize == 1) { + __GLX_SINGLE_GET_FLOAT(f); + } + else { + __GLX_SINGLE_GET_FLOAT_ARRAY(f, compsize); + if (val != origVal) { + /* matrix transpose */ + TransposeMatrixf(f); + } + } + } + } + __GLX_SINGLE_END(); +} + +void +__indirect_glGetIntegerv(GLenum val, GLint * i) +{ + const GLenum origVal = val; + __GLX_SINGLE_DECLARE_VARIABLES(); + xGLXSingleReply reply; + + val = RemapTransposeEnum(val); + + __GLX_SINGLE_LOAD_VARIABLES(); + __GLX_SINGLE_BEGIN(X_GLsop_GetIntegerv, 4); + __GLX_SINGLE_PUT_LONG(0, val); + __GLX_SINGLE_READ_XREPLY(); + __GLX_SINGLE_GET_SIZE(compsize); + + if (compsize == 0) { + /* + ** Error occured; don't modify user's buffer. + */ + } + else { + GLintptr data; + + /* + ** We still needed to send the request to the server in order to + ** find out whether it was legal to make a query (it's illegal, + ** for example, to call a query between glBegin() and glEnd()). + */ + + if (get_client_data(gc, val, &data)) { + *i = (GLint) data; + } + else { + /* + ** Not a local value, so use what we got from the server. + */ + if (compsize == 1) { + __GLX_SINGLE_GET_LONG(i); + } + else { + __GLX_SINGLE_GET_LONG_ARRAY(i, compsize); + if (val != origVal) { + /* matrix transpose */ + TransposeMatrixi(i); + } + } + } + } + __GLX_SINGLE_END(); +} + +/* +** Send all pending commands to server. +*/ +void +__indirect_glFlush(void) +{ + __GLX_SINGLE_DECLARE_VARIABLES(); + + if (!dpy) + return; + + __GLX_SINGLE_LOAD_VARIABLES(); + __GLX_SINGLE_BEGIN(X_GLsop_Flush, 0); + __GLX_SINGLE_END(); + + /* And finally flush the X protocol data */ + XFlush(dpy); +} + +void +__indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer) +{ + __GLX_SINGLE_DECLARE_VARIABLES(); + + if (!dpy) + return; + + __GLX_SINGLE_LOAD_VARIABLES(); + __GLX_SINGLE_BEGIN(X_GLsop_FeedbackBuffer, 8); + __GLX_SINGLE_PUT_LONG(0, size); + __GLX_SINGLE_PUT_LONG(4, type); + __GLX_SINGLE_END(); + + gc->feedbackBuf = buffer; +} + +void +__indirect_glSelectBuffer(GLsizei numnames, GLuint * buffer) +{ + __GLX_SINGLE_DECLARE_VARIABLES(); + + if (!dpy) + return; + + __GLX_SINGLE_LOAD_VARIABLES(); + __GLX_SINGLE_BEGIN(X_GLsop_SelectBuffer, 4); + __GLX_SINGLE_PUT_LONG(0, numnames); + __GLX_SINGLE_END(); + + gc->selectBuf = buffer; +} + +GLint +__indirect_glRenderMode(GLenum mode) +{ + __GLX_SINGLE_DECLARE_VARIABLES(); + GLint retval = 0; + xGLXRenderModeReply reply; + + if (!dpy) + return -1; + + __GLX_SINGLE_LOAD_VARIABLES(); + __GLX_SINGLE_BEGIN(X_GLsop_RenderMode, 4); + __GLX_SINGLE_PUT_LONG(0, mode); + __GLX_SINGLE_READ_XREPLY(); + __GLX_SINGLE_GET_RETVAL(retval, GLint); + + if (reply.newMode != mode) { + /* + ** Switch to new mode did not take effect, therefore an error + ** occured. When an error happens the server won't send us any + ** other data. + */ + } + else { + /* Read the feedback or selection data */ + if (gc->renderMode == GL_FEEDBACK) { + __GLX_SINGLE_GET_SIZE(compsize); + __GLX_SINGLE_GET_FLOAT_ARRAY(gc->feedbackBuf, compsize); + } + else if (gc->renderMode == GL_SELECT) { + __GLX_SINGLE_GET_SIZE(compsize); + __GLX_SINGLE_GET_LONG_ARRAY(gc->selectBuf, compsize); + } + gc->renderMode = mode; + } + __GLX_SINGLE_END(); + + return retval; +} + +void +__indirect_glFinish(void) +{ + __GLX_SINGLE_DECLARE_VARIABLES(); + xGLXSingleReply reply; + + __GLX_SINGLE_LOAD_VARIABLES(); + __GLX_SINGLE_BEGIN(X_GLsop_Finish, 0); + __GLX_SINGLE_READ_XREPLY(); + __GLX_SINGLE_END(); +} + + +/** + * Extract the major and minor version numbers from a version string. + */ +static void +version_from_string(const char *ver, int *major_version, int *minor_version) +{ + const char *end; + long major; + long minor; + + major = strtol(ver, (char **) &end, 10); + minor = strtol(end + 1, NULL, 10); + *major_version = major; + *minor_version = minor; +} + + +const GLubyte * +__indirect_glGetString(GLenum name) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + Display *dpy = gc->currentDpy; + GLubyte *s = NULL; + + if (!dpy) + return 0; + + /* + ** Return the cached copy if the string has already been fetched + */ + switch (name) { + case GL_VENDOR: + if (gc->vendor) + return gc->vendor; + break; + case GL_RENDERER: + if (gc->renderer) + return gc->renderer; + break; + case GL_VERSION: + if (gc->version) + return gc->version; + break; + case GL_EXTENSIONS: + if (gc->extensions) + return gc->extensions; + break; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return 0; + } + + /* + ** Get requested string from server + */ + + (void) __glXFlushRenderBuffer(gc, gc->pc); + s = (GLubyte *) __glXGetString(dpy, gc->majorOpcode, gc->currentContextTag, + name); + if (!s) { + /* Throw data on the floor */ + __glXSetError(gc, GL_OUT_OF_MEMORY); + } + else { + /* + ** Update local cache + */ + switch (name) { + case GL_VENDOR: + gc->vendor = s; + break; + + case GL_RENDERER: + gc->renderer = s; + break; + + case GL_VERSION:{ + int client_major; + int client_minor; + + version_from_string((char *) s, + &gc->server_major, &gc->server_minor); + __glXGetGLVersion(&client_major, &client_minor); + + if ((gc->server_major < client_major) + || ((gc->server_major == client_major) + && (gc->server_minor <= client_minor))) { + gc->version = s; + } + else { + /* Allow 7 bytes for the client-side GL version. This allows + * for upto version 999.999. I'm not holding my breath for + * that one! The extra 4 is for the ' ()\0' that will be + * added. + */ + const size_t size = 7 + strlen((char *) s) + 4; + + gc->version = Xmalloc(size); + if (gc->version == NULL) { + /* If we couldn't allocate memory for the new string, + * make a best-effort and just copy the client-side version + * to the string and use that. It probably doesn't + * matter what is done here. If there not memory available + * for a short string, the system is probably going to die + * soon anyway. + */ + snprintf((char *) s, strlen((char *) s) + 1, "%u.%u", + client_major, client_minor); + gc->version = s; + } + else { + snprintf((char *) gc->version, size, "%u.%u (%s)", + client_major, client_minor, s); + Xfree(s); + s = gc->version; + } + } + break; + } + + case GL_EXTENSIONS:{ + int major = 1; + int minor = 0; + + /* This code is currently disabled. I was reminded that some + * vendors intentionally exclude some extensions from their + * extension string that are part of the core version they + * advertise. In particular, on Nvidia drivers this means that + * the functionality is supported by the driver, but is not + * hardware accelerated. For example, a TNT will show core + * version 1.5, but most of the post-1.2 functionality is a + * software fallback. + * + * I don't want to break applications that rely on this odd + * behavior. At the same time, the code is written and tested, + * so I didn't want to throw it away. Therefore, the code is here + * but disabled. In the future, we may wish to and an environment + * variable to enable it. + */ + +#if 0 + /* Call glGetString just to make sure that gc->server_major and + * gc->server_minor are set. This version may be higher than we + * can completely support, but it may imply support for some + * extensions that we can support. + * + * For example, at the time of this writing, the client-side + * library only supports upto core GL version 1.2. However, cubic + * textures, multitexture, multisampling, and some other 1.3 + * features are supported. If the server reports back version + * 1.3, but does not report all of those extensions, we will + * enable them. + */ + (void *) glGetString(GL_VERSION); + major = gc->server_major, minor = gc->server_minor; +#endif + + __glXCalculateUsableGLExtensions(gc, (char *) s, major, minor); + XFree(s); + s = gc->extensions; + break; + } + } + } + return s; +} + +GLboolean +__indirect_glIsEnabled(GLenum cap) +{ + __GLX_SINGLE_DECLARE_VARIABLES(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + xGLXSingleReply reply; + GLboolean retval = 0; + GLintptr enable; + + if (!dpy) + return 0; + + switch (cap) { + case GL_VERTEX_ARRAY: + case GL_NORMAL_ARRAY: + case GL_COLOR_ARRAY: + case GL_INDEX_ARRAY: + case GL_EDGE_FLAG_ARRAY: + case GL_SECONDARY_COLOR_ARRAY: + case GL_FOG_COORD_ARRAY: + retval = __glXGetArrayEnable(state, cap, 0, &enable); + assert(retval); + return (GLboolean) enable; + break; + case GL_TEXTURE_COORD_ARRAY: + retval = __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY, + __glXGetActiveTextureUnit(state), &enable); + assert(retval); + return (GLboolean) enable; + break; + } + + __GLX_SINGLE_LOAD_VARIABLES(); + __GLX_SINGLE_BEGIN(X_GLsop_IsEnabled, 4); + __GLX_SINGLE_PUT_LONG(0, cap); + __GLX_SINGLE_READ_XREPLY(); + __GLX_SINGLE_GET_RETVAL(retval, GLboolean); + __GLX_SINGLE_END(); + return retval; +} + +void +__indirect_glGetPointerv(GLenum pname, void **params) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + Display *dpy = gc->currentDpy; + + if (!dpy) + return; + + switch (pname) { + case GL_VERTEX_ARRAY_POINTER: + case GL_NORMAL_ARRAY_POINTER: + case GL_COLOR_ARRAY_POINTER: + case GL_INDEX_ARRAY_POINTER: + case GL_EDGE_FLAG_ARRAY_POINTER: + __glXGetArrayPointer(state, pname - GL_VERTEX_ARRAY_POINTER + + GL_VERTEX_ARRAY, 0, params); + return; + case GL_TEXTURE_COORD_ARRAY_POINTER: + __glXGetArrayPointer(state, GL_TEXTURE_COORD_ARRAY, + __glXGetActiveTextureUnit(state), params); + return; + case GL_SECONDARY_COLOR_ARRAY_POINTER: + case GL_FOG_COORD_ARRAY_POINTER: + __glXGetArrayPointer(state, pname - GL_FOG_COORD_ARRAY_POINTER + + GL_FOG_COORD_ARRAY, 0, params); + return; + case GL_FEEDBACK_BUFFER_POINTER: + *params = (void *) gc->feedbackBuf; + return; + case GL_SELECTION_BUFFER_POINTER: + *params = (void *) gc->selectBuf; + return; + default: + __glXSetError(gc, GL_INVALID_ENUM); + return; + } +} + + + +/** + * This was previously auto-generated, but we need to special-case + * how we handle writing into the 'residences' buffer when n%4!=0. + */ +#define X_GLsop_AreTexturesResident 143 +GLboolean +__indirect_glAreTexturesResident(GLsizei n, const GLuint * textures, + GLboolean * residences) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + GLboolean retval = (GLboolean) 0; + const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { +#ifdef USE_XCB + xcb_connection_t *c = XGetXCBConnection(dpy); + (void) __glXFlushRenderBuffer(gc, gc->pc); + xcb_glx_are_textures_resident_reply_t *reply = + xcb_glx_are_textures_resident_reply(c, + xcb_glx_are_textures_resident + (c, gc->currentContextTag, n, + textures), NULL); + (void) memcpy(residences, xcb_glx_are_textures_resident_data(reply), + xcb_glx_are_textures_resident_data_length(reply) * + sizeof(GLboolean)); + retval = reply->ret_val; + free(reply); +#else + GLubyte const *pc = + __glXSetupSingleRequest(gc, X_GLsop_AreTexturesResident, cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4)); + if (n & 3) { + /* n is not a multiple of four. + * When reply_is_always_array is TRUE, __glXReadReply() will + * put a multiple of four bytes into the dest buffer. If the + * caller's buffer is not a multiple of four in size, we'll write + * out of bounds. So use a temporary buffer that's a few bytes + * larger. + */ + GLboolean *res4 = malloc((n + 3) & ~3); + retval = (GLboolean) __glXReadReply(dpy, 1, res4, GL_TRUE); + memcpy(residences, res4, n); + free(res4); + } + else { + retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE); + } + UnlockDisplay(dpy); + SyncHandle(); +#endif /* USE_XCB */ + } + return retval; +} + + +/** + * This was previously auto-generated, but we need to special-case + * how we handle writing into the 'residences' buffer when n%4!=0. + */ +#define X_GLvop_AreTexturesResidentEXT 11 +GLboolean +glAreTexturesResidentEXT(GLsizei n, const GLuint * textures, + GLboolean * residences) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + + if (gc->isDirect) { + return CALL_AreTexturesResident(GET_DISPATCH(), + (n, textures, residences)); + } + else { + __GLXcontext *const gc = __glXGetCurrentContext(); + Display *const dpy = gc->currentDpy; + GLboolean retval = (GLboolean) 0; + const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); + if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_AreTexturesResidentEXT, + cmdlen); + (void) memcpy((void *) (pc + 0), (void *) (&n), 4); + (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4)); + if (n & 3) { + /* see comments in __indirect_glAreTexturesResident() */ + GLboolean *res4 = malloc((n + 3) & ~3); + retval = (GLboolean) __glXReadReply(dpy, 1, res4, GL_TRUE); + memcpy(residences, res4, n); + free(res4); + } + else { + retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE); + } + UnlockDisplay(dpy); + SyncHandle(); + } + return retval; + } +} diff --git a/src/glx/singlepix.c b/src/glx/singlepix.c new file mode 100644 index 00000000000..f5ebf4dfdbf --- /dev/null +++ b/src/glx/singlepix.c @@ -0,0 +1,196 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +#include "packsingle.h" +#include "indirect.h" +#include "glapitable.h" +#include "glapidispatch.h" +#include "glapi.h" +#include "glthread.h" +#include "glapioffsets.h" +#include + +void +__indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type, + GLvoid * row, GLvoid * column, GLvoid * span) +{ + __GLX_SINGLE_DECLARE_VARIABLES(); + const __GLXattribute *state; + xGLXGetSeparableFilterReply reply; + GLubyte *rowBuf, *colBuf; + + if (!dpy) + return; + __GLX_SINGLE_LOAD_VARIABLES(); + state = gc->client_state_private; + + /* Send request */ + __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter, __GLX_PAD(13)); + __GLX_SINGLE_PUT_LONG(0, target); + __GLX_SINGLE_PUT_LONG(4, format); + __GLX_SINGLE_PUT_LONG(8, type); + __GLX_SINGLE_PUT_CHAR(12, state->storePack.swapEndian); + __GLX_SINGLE_READ_XREPLY(); + compsize = reply.length << 2; + + if (compsize != 0) { + GLint width, height; + GLint widthsize, heightsize; + + width = reply.width; + height = reply.height; + + widthsize = __glImageSize(width, 1, 1, format, type, 0); + heightsize = __glImageSize(height, 1, 1, format, type, 0); + + /* Allocate a holding buffer to transform the data from */ + rowBuf = (GLubyte *) Xmalloc(widthsize); + if (!rowBuf) { + /* Throw data away */ + _XEatData(dpy, compsize); + __glXSetError(gc, GL_OUT_OF_MEMORY); + UnlockDisplay(dpy); + SyncHandle(); + return; + } + else { + __GLX_SINGLE_GET_CHAR_ARRAY(((char *) rowBuf), widthsize); + __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row); + Xfree((char *) rowBuf); + } + colBuf = (GLubyte *) Xmalloc(heightsize); + if (!colBuf) { + /* Throw data away */ + _XEatData(dpy, compsize - __GLX_PAD(widthsize)); + __glXSetError(gc, GL_OUT_OF_MEMORY); + UnlockDisplay(dpy); + SyncHandle(); + return; + } + else { + __GLX_SINGLE_GET_CHAR_ARRAY(((char *) colBuf), heightsize); + __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column); + Xfree((char *) colBuf); + } + } + else { + /* + ** don't modify user's buffer. + */ + } + __GLX_SINGLE_END(); + +} + + +#define CONCAT(a,b) a ## b +#define NAME(o) CONCAT(gl_dispatch_stub_, o) + +void NAME(_gloffset_GetSeparableFilter) (GLenum target, GLenum format, + GLenum type, GLvoid * row, + GLvoid * column, GLvoid * span) +{ + __GLXcontext *const gc = __glXGetCurrentContext(); + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + CALL_GetSeparableFilter(GET_DISPATCH(), + (target, format, type, row, column, span)); + return; + } + else +#endif + { + Display *const dpy = gc->currentDpy; + const GLuint cmdlen = __GLX_PAD(13); + + if (dpy != NULL) { + const __GLXattribute *const state = gc->client_state_private; + xGLXGetSeparableFilterReply reply; + GLubyte const *pc = + __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, + X_GLvop_GetSeparableFilterEXT, cmdlen); + unsigned compsize; + + + (void) memcpy((void *) (pc + 0), (void *) (&target), 4); + (void) memcpy((void *) (pc + 4), (void *) (&format), 4); + (void) memcpy((void *) (pc + 8), (void *) (&type), 4); + *(int8_t *) (pc + 12) = state->storePack.swapEndian; + + (void) _XReply(dpy, (xReply *) & reply, 0, False); + + compsize = reply.length << 2; + + if (compsize != 0) { + const GLint width = reply.width; + const GLint height = reply.height; + const GLint widthsize = + __glImageSize(width, 1, 1, format, type, 0); + const GLint heightsize = + __glImageSize(height, 1, 1, format, type, 0); + GLubyte *const buf = + (GLubyte *) Xmalloc((widthsize > heightsize) ? widthsize : + heightsize); + + if (buf == NULL) { + /* Throw data away */ + _XEatData(dpy, compsize); + __glXSetError(gc, GL_OUT_OF_MEMORY); + + UnlockDisplay(dpy); + SyncHandle(); + return; + } + else { + int extra; + + extra = 4 - (widthsize & 3); + _XRead(dpy, (char *) buf, widthsize); + if (extra < 4) { + _XEatData(dpy, extra); + } + + __glEmptyImage(gc, 1, width, 1, 1, format, type, buf, row); + + extra = 4 - (heightsize & 3); + _XRead(dpy, (char *) buf, heightsize); + if (extra < 4) { + _XEatData(dpy, extra); + } + + __glEmptyImage(gc, 1, height, 1, 1, format, type, buf, column); + + Xfree((char *) buf); + } + } + } + } +} diff --git a/src/glx/vertarr.c b/src/glx/vertarr.c new file mode 100644 index 00000000000..398cfb1e796 --- /dev/null +++ b/src/glx/vertarr.c @@ -0,0 +1,212 @@ +/* + * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) + * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice including the dates of first publication and + * either this permission notice or a reference to + * http://oss.sgi.com/projects/FreeB/ + * shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Silicon Graphics, Inc. + * shall not be used in advertising or otherwise to promote the sale, use or + * other dealings in this Software without prior written authorization from + * Silicon Graphics, Inc. + */ + +#include "glxclient.h" +#include "indirect.h" +#include "indirect_vertex_array.h" + + +/*****************************************************************************/ + +/** + * \name Vertex array pointer bridge functions + * + * When EXT_vertex_array was moved into the core GL spec, the \c count + * parameter was lost. This libGL really only wants to implement the GL 1.1 + * version, but we need to support applications that were written to the old + * interface. These bridge functions are part of the glue that makes this + * happen. + */ +/*@{*/ +void +__indirect_glColorPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid * pointer) +{ + (void) count; + __indirect_glColorPointer(size, type, stride, pointer); +} + +void +__indirect_glEdgeFlagPointerEXT(GLsizei stride, + GLsizei count, const GLboolean * pointer) +{ + (void) count; + __indirect_glEdgeFlagPointer(stride, pointer); +} + +void +__indirect_glIndexPointerEXT(GLenum type, GLsizei stride, + GLsizei count, const GLvoid * pointer) +{ + (void) count; + __indirect_glIndexPointer(type, stride, pointer); +} + +void +__indirect_glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid * pointer) +{ + (void) count; + __indirect_glNormalPointer(type, stride, pointer); +} + +void +__indirect_glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid * pointer) +{ + (void) count; + __indirect_glTexCoordPointer(size, type, stride, pointer); +} + +void +__indirect_glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid * pointer) +{ + (void) count; + __indirect_glVertexPointer(size, type, stride, pointer); +} + +/*@}*/ + +/*****************************************************************************/ + +void +__indirect_glInterleavedArrays(GLenum format, GLsizei stride, + const GLvoid * pointer) +{ + __GLXcontext *gc = __glXGetCurrentContext(); + __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); + +#define NONE {0, 0, 0} +#define F(x) {GL_FLOAT, x, x * sizeof(GLfloat)} +#define UB4 {GL_UNSIGNED_BYTE, 4, 4 * sizeof(GLubyte)} + + /* Each row in this array describes the elements of a particular + * interleaved array mode. Each column describes, in the order in which + * they appear in the interleaved arrays, one of the four possible types + * of vertex data that can appear in an interleaved array. + */ + struct + { + /** + * The enum describing the GL type, as would be passed to the + * appropriate gl*Pointer function. + */ + GLushort type; + + /** + * Number of elements in the subarray, as would be passed (as the + * \c size parameter) to the appropriate gl*Pointer function. + */ + GLubyte count; + + /** + * True size of a single element in the subarray, as would be passed + * (as the \c stride parameter) to the appropriate gl*Pointer + * function. + */ + GLubyte size; + } + static const modes[14][4] = { + /* texture color normal vertex */ + {NONE, NONE, NONE, F(2)}, /* GL_V2F */ + {NONE, NONE, NONE, F(3)}, /* GL_V3F */ + {NONE, UB4, NONE, F(2)}, /* GL_C4UB_V2F */ + {NONE, UB4, NONE, F(3)}, /* GL_C4UB_V3F */ + {NONE, F(3), NONE, F(3)}, /* GL_C3F_V3F */ + {NONE, NONE, F(3), F(3)}, /* GL_N3F_V3F */ + {NONE, F(4), F(3), F(3)}, /* GL_C4F_N3F_V3F */ + {F(2), NONE, NONE, F(3)}, /* GL_T2F_V3F */ + {F(4), NONE, NONE, F(4)}, /* GL_T4F_V4F */ + {F(2), UB4, NONE, F(3)}, /* GL_T2F_C4UB_V3F */ + {F(2), F(3), NONE, F(3)}, /* GL_T2F_C3F_V3F */ + {F(2), NONE, F(3), F(3)}, /* GL_T2F_N3F_V3F */ + {F(2), F(4), F(3), F(3)}, /* GL_T2F_C4F_N3F_V3F */ + {F(4), F(4), F(3), F(4)}, /* GL_T4F_C4F_N3F_V4F */ + }; +#undef NONE +#undef F +#undef UB4 + + GLint trueStride, size; + int offsets[4]; + unsigned i; + const int idx = format - GL_V2F; + + + /* All valid formats are on the range [GL_V2F, GL_V2F+0x0D]. Since idx + * is just the format biased by -GL_V2F, all valid idx values are on the + * range [0, 0x0D]. + */ + if ((idx < 0) || (idx > 0x0D)) { + __glXSetError(gc, GL_INVALID_ENUM); + return; + } + + if (stride < 0) { + __glXSetError(gc, GL_INVALID_VALUE); + return; + } + + + /* If the 'count' for a subarray is non-zero, then the offset of its + * first element is at the currently accumulated 'size'. + */ + size = 0; + for (i = 0; i < 4; i++) { + offsets[i] = (modes[idx][i].count != 0) ? size : -1; + size += modes[idx][i].size; + } + + trueStride = (stride == 0) ? size : stride; + + __glXArrayDisableAll(state); + + if (offsets[0] >= 0) { + __indirect_glEnableClientState(GL_TEXTURE_COORD_ARRAY); + __indirect_glTexCoordPointer(modes[idx][0].count, GL_FLOAT, + trueStride, (const char *) pointer); + } + if (offsets[1] >= 0) { + __indirect_glEnableClientState(GL_COLOR_ARRAY); + __indirect_glColorPointer(modes[idx][1].count, modes[idx][1].type, + trueStride, + (const char *) pointer + offsets[1]); + } + if (offsets[2] >= 0) { + __indirect_glEnableClientState(GL_NORMAL_ARRAY); + __indirect_glNormalPointer(GL_FLOAT, trueStride, + (const char *) pointer + offsets[2]); + } + __indirect_glEnableClientState(GL_VERTEX_ARRAY); + __indirect_glVertexPointer(modes[idx][3].count, GL_FLOAT, + trueStride, + (const char *) pointer + offsets[3]); +} diff --git a/src/glx/x11/Makefile b/src/glx/x11/Makefile deleted file mode 100644 index e681be834f0..00000000000 --- a/src/glx/x11/Makefile +++ /dev/null @@ -1,97 +0,0 @@ -TOP = ../../.. -include $(TOP)/configs/current - -EXTRA_DEFINES = -DXF86VIDMODE -D_REENTRANT \ - -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" - -SOURCES = \ - glcontextmodes.c \ - clientattrib.c \ - compsize.c \ - eval.c \ - glxcmds.c \ - glxcurrent.c \ - glxext.c \ - glxextensions.c \ - indirect.c \ - indirect_init.c \ - indirect_size.c \ - indirect_window_pos.c \ - indirect_texture_compression.c \ - indirect_transpose_matrix.c \ - indirect_vertex_array.c \ - indirect_vertex_program.c \ - pixel.c \ - pixelstore.c \ - render2.c \ - renderpix.c \ - single2.c \ - singlepix.c \ - vertarr.c \ - xfont.c \ - glx_pbuffer.c \ - glx_query.c \ - drisw_glx.c \ - dri_common.c \ - dri_glx.c \ - XF86dri.c \ - glxhash.c \ - dri2_glx.c \ - dri2.c - -GLAPI_LIB = $(TOP)/src/mesa/libglapi.a - -OBJECTS = $(SOURCES:.c=.o) - -INCLUDES = -I. \ - -I$(TOP)/include \ - -I$(TOP)/include/GL/internal \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/glapi \ - $(LIBDRM_CFLAGS) \ - $(DRI2PROTO_CFLAGS) \ - $(X11_INCLUDES) - - -##### RULES ##### - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(EXTRA_DEFINES) $< -o $@ - -.S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(EXTRA_DEFINES) $< -o $@ - -##### TARGETS ##### - -default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) - -# Make libGL -$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) $(GLAPI_LIB) Makefile - $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - -major 1 -minor 2 $(MKLIB_OPTIONS) \ - -install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/lib$(GL_LIB).1.dylib \ - $(GL_LIB_DEPS) $(OBJECTS) $(GLAPI_LIB) - -$(GLAPI_LIB): - @$(MAKE) -C $(TOP)/src/mesa libglapi.a - -depend: $(SOURCES) Makefile - rm -f depend - touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) - - -# Emacs tags -tags: - etags `find . -name \*.[ch]` `find $(TOP)/include` - -install: $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) - $(MAKE) -C $(TOP)/src/mesa install-libgl - -# Remove .o and backup files -clean: - -rm -f $(TOP)/$(LIB_DIR)/libGL.so* - -rm -f *.o *~ - -rm -f depend depend.bak - --include depend diff --git a/src/glx/x11/XF86dri.c b/src/glx/x11/XF86dri.c deleted file mode 100644 index 248d96ac5de..00000000000 --- a/src/glx/x11/XF86dri.c +++ /dev/null @@ -1,637 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * Jens Owen - * Rickard E. (Rik) Faith - * - */ - -/* THIS IS NOT AN X CONSORTIUM STANDARD */ - -#ifdef GLX_DIRECT_RENDERING - -#define NEED_REPLIES -#include -#include -#include -#include "xf86dristr.h" - - -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 -# define PUBLIC __attribute__((visibility("default"))) -# define USED __attribute__((used)) -#else -# define PUBLIC -# define USED -#endif - - - -static XExtensionInfo _xf86dri_info_data; -static XExtensionInfo *xf86dri_info = &_xf86dri_info_data; -static char xf86dri_extension_name[] = XF86DRINAME; - -#define XF86DRICheckExtension(dpy,i,val) \ - XextCheckExtension (dpy, i, xf86dri_extension_name, val) - -/***************************************************************************** - * * - * private utility routines * - * * - *****************************************************************************/ - -static int close_display(Display * dpy, XExtCodes * extCodes); -static /* const */ XExtensionHooks xf86dri_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - close_display, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - -static -XEXT_GENERATE_FIND_DISPLAY(find_display, xf86dri_info, - xf86dri_extension_name, - &xf86dri_extension_hooks, 0, NULL) - -static -XEXT_GENERATE_CLOSE_DISPLAY(close_display, xf86dri_info) - - -/***************************************************************************** - * * - * public XFree86-DRI Extension routines * - * * - *****************************************************************************/ -#if 0 -#include -#define TRACE(msg) fprintf(stderr,"XF86DRI%s\n", msg); -#else -#define TRACE(msg) -#endif - -Bool -XF86DRIQueryExtension(Display * dpy, int *event_basep, - int *error_basep) -{ - XExtDisplayInfo *info = find_display(dpy); - - TRACE("QueryExtension..."); - if (XextHasExtension(info)) { - *event_basep = info->codes->first_event; - *error_basep = info->codes->first_error; - TRACE("QueryExtension... return True"); - return True; - } - else { - TRACE("QueryExtension... return False"); - return False; - } -} - -Bool -XF86DRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion, - int *patchVersion) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIQueryVersionReply rep; - xXF86DRIQueryVersionReq *req; - - TRACE("QueryVersion..."); - XF86DRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIQueryVersion, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIQueryVersion; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryVersion... return False"); - return False; - } - *majorVersion = rep.majorVersion; - *minorVersion = rep.minorVersion; - *patchVersion = rep.patchVersion; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryVersion... return True"); - return True; -} - -Bool -XF86DRIQueryDirectRenderingCapable(Display * dpy, int screen, - Bool * isCapable) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIQueryDirectRenderingCapableReply rep; - xXF86DRIQueryDirectRenderingCapableReq *req; - - TRACE("QueryDirectRenderingCapable..."); - XF86DRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIQueryDirectRenderingCapable, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIQueryDirectRenderingCapable; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryDirectRenderingCapable... return False"); - return False; - } - *isCapable = rep.isCapable; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryDirectRenderingCapable... return True"); - return True; -} - -Bool -XF86DRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA, - char **busIdString) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIOpenConnectionReply rep; - xXF86DRIOpenConnectionReq *req; - - TRACE("OpenConnection..."); - XF86DRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIOpenConnection, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIOpenConnection; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("OpenConnection... return False"); - return False; - } - - *hSAREA = rep.hSAREALow; - if (sizeof(drm_handle_t) == 8) { - int shift = 32; /* var to prevent warning on next line */ - *hSAREA |= ((drm_handle_t) rep.hSAREAHigh) << shift; - } - - if (rep.length) { - if (!(*busIdString = (char *) Xcalloc(rep.busIdStringLength + 1, 1))) { - _XEatData(dpy, ((rep.busIdStringLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("OpenConnection... return False"); - return False; - } - _XReadPad(dpy, *busIdString, rep.busIdStringLength); - } - else { - *busIdString = NULL; - } - UnlockDisplay(dpy); - SyncHandle(); - TRACE("OpenConnection... return True"); - return True; -} - -Bool -XF86DRIAuthConnection(Display * dpy, int screen, drm_magic_t magic) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIAuthConnectionReq *req; - xXF86DRIAuthConnectionReply rep; - - TRACE("AuthConnection..."); - XF86DRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIAuthConnection, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIAuthConnection; - req->screen = screen; - req->magic = magic; - rep.authenticated = 0; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("AuthConnection... return False"); - return False; - } - UnlockDisplay(dpy); - SyncHandle(); - TRACE("AuthConnection... return True"); - return True; -} - -Bool -XF86DRICloseConnection(Display * dpy, int screen) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRICloseConnectionReq *req; - - TRACE("CloseConnection..."); - - XF86DRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRICloseConnection, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRICloseConnection; - req->screen = screen; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CloseConnection... return True"); - return True; -} - -Bool -XF86DRIGetClientDriverName(Display * dpy, int screen, - int *ddxDriverMajorVersion, - int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, - char **clientDriverName) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIGetClientDriverNameReply rep; - xXF86DRIGetClientDriverNameReq *req; - - TRACE("GetClientDriverName..."); - XF86DRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIGetClientDriverName, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIGetClientDriverName; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetClientDriverName... return False"); - return False; - } - - *ddxDriverMajorVersion = rep.ddxDriverMajorVersion; - *ddxDriverMinorVersion = rep.ddxDriverMinorVersion; - *ddxDriverPatchVersion = rep.ddxDriverPatchVersion; - - if (rep.length) { - if (! - (*clientDriverName = - (char *) Xcalloc(rep.clientDriverNameLength + 1, 1))) { - _XEatData(dpy, ((rep.clientDriverNameLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetClientDriverName... return False"); - return False; - } - _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength); - } - else { - *clientDriverName = NULL; - } - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetClientDriverName... return True"); - return True; -} - -Bool -XF86DRICreateContextWithConfig(Display * dpy, int screen, int configID, - XID * context, drm_context_t * hHWContext) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRICreateContextReply rep; - xXF86DRICreateContextReq *req; - - TRACE("CreateContext..."); - XF86DRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRICreateContext, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRICreateContext; - req->visual = configID; - req->screen = screen; - *context = XAllocID(dpy); - req->context = *context; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateContext... return False"); - return False; - } - *hHWContext = rep.hHWContext; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateContext... return True"); - return True; -} - -Bool -XF86DRICreateContext(Display * dpy, int screen, Visual * visual, - XID * context, drm_context_t * hHWContext) -{ - return XF86DRICreateContextWithConfig(dpy, screen, visual->visualid, - context, hHWContext); -} - -Bool -XF86DRIDestroyContext(Display * dpy, int screen, XID context) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIDestroyContextReq *req; - - TRACE("DestroyContext..."); - XF86DRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIDestroyContext, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIDestroyContext; - req->screen = screen; - req->context = context; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("DestroyContext... return True"); - return True; -} - -Bool -XF86DRICreateDrawable(Display * dpy, int screen, - XID drawable, drm_drawable_t * hHWDrawable) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRICreateDrawableReply rep; - xXF86DRICreateDrawableReq *req; - - TRACE("CreateDrawable..."); - XF86DRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRICreateDrawable, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRICreateDrawable; - req->screen = screen; - req->drawable = drawable; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateDrawable... return False"); - return False; - } - *hHWDrawable = rep.hHWDrawable; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateDrawable... return True"); - return True; -} - -static int -noopErrorHandler(Display * dpy, XErrorEvent * xerr) -{ - return 0; -} - -Bool -XF86DRIDestroyDrawable(Display * dpy, int screen, XID drawable) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIDestroyDrawableReq *req; - int (*oldXErrorHandler) (Display *, XErrorEvent *); - - TRACE("DestroyDrawable..."); - XF86DRICheckExtension(dpy, info, False); - - /* This is called from the DRI driver, which used call it like this - * - * if (windowExists(drawable)) - * destroyDrawable(drawable); - * - * which is a textbook race condition - the window may disappear - * from the server between checking for its existance and - * destroying it. Instead we change the semantics of - * __DRIinterfaceMethodsRec::destroyDrawable() to succeed even if - * the windows is gone, by wrapping the destroy call in an error - * handler. */ - - XSync(dpy, False); - oldXErrorHandler = XSetErrorHandler(noopErrorHandler); - - LockDisplay(dpy); - GetReq(XF86DRIDestroyDrawable, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIDestroyDrawable; - req->screen = screen; - req->drawable = drawable; - UnlockDisplay(dpy); - SyncHandle(); - - XSetErrorHandler(oldXErrorHandler); - - TRACE("DestroyDrawable... return True"); - return True; -} - -Bool -XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, - unsigned int *index, unsigned int *stamp, - int *X, int *Y, int *W, int *H, - int *numClipRects, drm_clip_rect_t ** pClipRects, - int *backX, int *backY, - int *numBackClipRects, - drm_clip_rect_t ** pBackClipRects) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIGetDrawableInfoReply rep; - xXF86DRIGetDrawableInfoReq *req; - int total_rects; - - TRACE("GetDrawableInfo..."); - XF86DRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIGetDrawableInfo, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIGetDrawableInfo; - req->screen = screen; - req->drawable = drawable; - - if (!_XReply(dpy, (xReply *) & rep, 1, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDrawableInfo... return False"); - return False; - } - *index = rep.drawableTableIndex; - *stamp = rep.drawableTableStamp; - *X = (int) rep.drawableX; - *Y = (int) rep.drawableY; - *W = (int) rep.drawableWidth; - *H = (int) rep.drawableHeight; - *numClipRects = rep.numClipRects; - total_rects = *numClipRects; - - *backX = rep.backX; - *backY = rep.backY; - *numBackClipRects = rep.numBackClipRects; - total_rects += *numBackClipRects; - -#if 0 - /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks - * backwards compatibility (Because of the >> 2 shift) but the fix - * enables multi-threaded apps to work. - */ - if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) - - SIZEOF(xGenericReply) + - total_rects * sizeof(drm_clip_rect_t)) + - 3) & ~3) >> 2)) { - _XEatData(dpy, rep.length); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDrawableInfo... return False"); - return False; - } -#endif - - if (*numClipRects) { - int len = sizeof(drm_clip_rect_t) * (*numClipRects); - - *pClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); - if (*pClipRects) - _XRead(dpy, (char *) *pClipRects, len); - } - else { - *pClipRects = NULL; - } - - if (*numBackClipRects) { - int len = sizeof(drm_clip_rect_t) * (*numBackClipRects); - - *pBackClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); - if (*pBackClipRects) - _XRead(dpy, (char *) *pBackClipRects, len); - } - else { - *pBackClipRects = NULL; - } - - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDrawableInfo... return True"); - return True; -} - -Bool -XF86DRIGetDeviceInfo(Display * dpy, int screen, drm_handle_t * hFrameBuffer, - int *fbOrigin, int *fbSize, int *fbStride, - int *devPrivateSize, void **pDevPrivate) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIGetDeviceInfoReply rep; - xXF86DRIGetDeviceInfoReq *req; - - TRACE("GetDeviceInfo..."); - XF86DRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIGetDeviceInfo, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIGetDeviceInfo; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDeviceInfo... return False"); - return False; - } - - *hFrameBuffer = rep.hFrameBufferLow; - if (sizeof(drm_handle_t) == 8) { - int shift = 32; /* var to prevent warning on next line */ - *hFrameBuffer |= ((drm_handle_t) rep.hFrameBufferHigh) << shift; - } - - *fbOrigin = rep.framebufferOrigin; - *fbSize = rep.framebufferSize; - *fbStride = rep.framebufferStride; - *devPrivateSize = rep.devPrivateSize; - - if (rep.length) { - if (!(*pDevPrivate = (void *) Xcalloc(rep.devPrivateSize, 1))) { - _XEatData(dpy, ((rep.devPrivateSize + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDeviceInfo... return False"); - return False; - } - _XRead(dpy, (char *) *pDevPrivate, rep.devPrivateSize); - } - else { - *pDevPrivate = NULL; - } - - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDeviceInfo... return True"); - return True; -} - -Bool -XF86DRIOpenFullScreen(Display * dpy, int screen, Drawable drawable) -{ - /* This function and the underlying X protocol are deprecated. - */ - (void) dpy; - (void) screen; - (void) drawable; - return False; -} - -Bool -XF86DRICloseFullScreen(Display * dpy, int screen, Drawable drawable) -{ - /* This function and the underlying X protocol are deprecated. - */ - (void) dpy; - (void) screen; - (void) drawable; - return True; -} - -#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/x11/clientattrib.c b/src/glx/x11/clientattrib.c deleted file mode 100644 index a7dfb534860..00000000000 --- a/src/glx/x11/clientattrib.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include -#include "glxclient.h" -#include "indirect.h" -#include "indirect_vertex_array.h" - -/*****************************************************************************/ - -static void -do_enable_disable(GLenum array, GLboolean val) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - unsigned index = 0; - - if (array == GL_TEXTURE_COORD_ARRAY) { - index = __glXGetActiveTextureUnit(state); - } - - if (!__glXSetArrayEnable(state, array, index, val)) { - __glXSetError(gc, GL_INVALID_ENUM); - } -} - -void -__indirect_glEnableClientState(GLenum array) -{ - do_enable_disable(array, GL_TRUE); -} - -void -__indirect_glDisableClientState(GLenum array) -{ - do_enable_disable(array, GL_FALSE); -} - -/************************************************************************/ - -void -__indirect_glPushClientAttrib(GLuint mask) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - __GLXattribute **spp = gc->attributes.stackPointer, *sp; - - if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) { - if (!(sp = *spp)) { - sp = (__GLXattribute *) Xmalloc(sizeof(__GLXattribute)); - *spp = sp; - } - sp->mask = mask; - gc->attributes.stackPointer = spp + 1; - if (mask & GL_CLIENT_PIXEL_STORE_BIT) { - sp->storePack = state->storePack; - sp->storeUnpack = state->storeUnpack; - } - if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { - __glXPushArrayState(state); - } - } - else { - __glXSetError(gc, GL_STACK_OVERFLOW); - return; - } -} - -void -__indirect_glPopClientAttrib(void) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - __GLXattribute **spp = gc->attributes.stackPointer, *sp; - GLuint mask; - - if (spp > &gc->attributes.stack[0]) { - --spp; - sp = *spp; - assert(sp != 0); - mask = sp->mask; - gc->attributes.stackPointer = spp; - - if (mask & GL_CLIENT_PIXEL_STORE_BIT) { - state->storePack = sp->storePack; - state->storeUnpack = sp->storeUnpack; - } - if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { - __glXPopArrayState(state); - } - - sp->mask = 0; - } - else { - __glXSetError(gc, GL_STACK_UNDERFLOW); - return; - } -} - -void -__glFreeAttributeState(__GLXcontext * gc) -{ - __GLXattribute *sp, **spp; - - for (spp = &gc->attributes.stack[0]; - spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; spp++) { - sp = *spp; - if (sp) { - XFree((char *) sp); - } - else { - break; - } - } -} diff --git a/src/glx/x11/compsize.c b/src/glx/x11/compsize.c deleted file mode 100644 index 5ba6dc919e5..00000000000 --- a/src/glx/x11/compsize.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include -#include "glxclient.h" - -/* -** Return the number of elements per group of a specified format -*/ -GLint -__glElementsPerGroup(GLenum format, GLenum type) -{ - /* - ** To make row length computation valid for image extraction, - ** packed pixel types assume elements per group equals one. - */ - switch (type) { - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_SHORT_8_8_APPLE: - case GL_UNSIGNED_SHORT_8_8_REV_APPLE: - case GL_UNSIGNED_SHORT_15_1_MESA: - case GL_UNSIGNED_SHORT_1_15_REV_MESA: - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - case GL_UNSIGNED_INT_24_8_NV: - case GL_UNSIGNED_INT_24_8_MESA: - case GL_UNSIGNED_INT_8_24_REV_MESA: - return 1; - default: - break; - } - - switch (format) { - case GL_RGB: - case GL_BGR: - return 3; - case GL_422_EXT: - case GL_422_REV_EXT: - case GL_422_AVERAGE_EXT: - case GL_422_REV_AVERAGE_EXT: - case GL_YCBCR_422_APPLE: - case GL_LUMINANCE_ALPHA: - return 2; - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - return 4; - case GL_COLOR_INDEX: - case GL_STENCIL_INDEX: - case GL_DEPTH_COMPONENT: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_INTENSITY: - return 1; - default: - return 0; - } -} - -/* -** Return the number of bytes per element, based on the element type (other -** than GL_BITMAP). -*/ -GLint -__glBytesPerElement(GLenum type) -{ - switch (type) { - case GL_UNSIGNED_SHORT: - case GL_SHORT: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_SHORT_8_8_APPLE: - case GL_UNSIGNED_SHORT_8_8_REV_APPLE: - case GL_UNSIGNED_SHORT_15_1_MESA: - case GL_UNSIGNED_SHORT_1_15_REV_MESA: - return 2; - case GL_UNSIGNED_BYTE: - case GL_BYTE: - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - return 1; - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - case GL_UNSIGNED_INT_24_8_NV: - case GL_UNSIGNED_INT_24_8_MESA: - case GL_UNSIGNED_INT_8_24_REV_MESA: - return 4; - default: - return 0; - } -} - -/* -** Compute memory required for internal packed array of data of given type -** and format. -*/ -GLint -__glImageSize(GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, GLenum target) -{ - int bytes_per_row; - int components; - - switch (target) { - case GL_PROXY_TEXTURE_1D: - case GL_PROXY_TEXTURE_2D: - case GL_PROXY_TEXTURE_3D: - case GL_PROXY_TEXTURE_4D_SGIS: - case GL_PROXY_TEXTURE_CUBE_MAP: - case GL_PROXY_TEXTURE_RECTANGLE_ARB: - case GL_PROXY_HISTOGRAM: - case GL_PROXY_COLOR_TABLE: - case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: - case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: - case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: - case GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP: - return 0; - } - - if (width < 0 || height < 0 || depth < 0) { - return 0; - } - - /* - ** Zero is returned if either format or type are invalid. - */ - components = __glElementsPerGroup(format, type); - if (type == GL_BITMAP) { - if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) { - bytes_per_row = (width + 7) >> 3; - } - else { - return 0; - } - } - else { - bytes_per_row = __glBytesPerElement(type) * width; - } - - return bytes_per_row * height * depth * components; -} diff --git a/src/glx/x11/dri2.c b/src/glx/x11/dri2.c deleted file mode 100644 index 91053d3fb61..00000000000 --- a/src/glx/x11/dri2.c +++ /dev/null @@ -1,645 +0,0 @@ -/* - * Copyright © 2008 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Soft- - * ware"), to deal in the Software without restriction, including without - * limitation the rights to use, copy, modify, merge, publish, distribute, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, provided that the above copyright - * notice(s) and this permission notice appear in all copies of the Soft- - * ware and that both the above copyright notice(s) and this permission - * notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- - * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY - * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN - * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- - * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- - * MANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder shall - * not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization of - * the copyright holder. - * - * Authors: - * Kristian Høgsberg (krh@redhat.com) - */ - - -#ifdef GLX_DIRECT_RENDERING - -#define NEED_REPLIES -#include -#include -#include -#include -#include -#include "xf86drm.h" -#include "dri2.h" -#include "glxclient.h" -#include "GL/glxext.h" - -/* Allow the build to work with an older versions of dri2proto.h and - * dri2tokens.h. - */ -#if DRI2_MINOR < 1 -#undef DRI2_MINOR -#define DRI2_MINOR 1 -#define X_DRI2GetBuffersWithFormat 7 -#endif - - -static char dri2ExtensionName[] = DRI2_NAME; -static XExtensionInfo *dri2Info; -static XEXT_GENERATE_CLOSE_DISPLAY (DRI2CloseDisplay, dri2Info) - -static Bool -DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire); -static Status -DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire); - -static /* const */ XExtensionHooks dri2ExtensionHooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - DRI2CloseDisplay, /* close_display */ - DRI2WireToEvent, /* wire_to_event */ - DRI2EventToWire, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - -static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay, - dri2Info, - dri2ExtensionName, - &dri2ExtensionHooks, - 1, NULL) - -static Bool -DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - XExtDisplayInfo *glx_info = __glXFindDisplay(dpy); - static int glx_event_base; - static Bool found_glx_info = False; - - XextCheckExtension(dpy, info, dri2ExtensionName, False); - - switch ((wire->u.u.type & 0x7f) - info->codes->first_event) { - -#ifdef X_DRI2SwapBuffers - case DRI2_BufferSwapComplete: - { - GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event; - xDRI2BufferSwapComplete *awire = (xDRI2BufferSwapComplete *)wire; - aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); - aevent->type = - (glx_info->codes->first_event + GLX_BufferSwapComplete) & 0x75; - aevent->send_event = (awire->type & 0x80) != 0; - aevent->display = dpy; - aevent->drawable = awire->drawable; - switch (awire->event_type) { - case DRI2_EXCHANGE_COMPLETE: - aevent->event_type = GLX_EXCHANGE_COMPLETE_INTEL; - break; - case DRI2_BLIT_COMPLETE: - aevent->event_type = GLX_BLIT_COMPLETE_INTEL; - break; - case DRI2_FLIP_COMPLETE: - aevent->event_type = GLX_FLIP_COMPLETE_INTEL; - break; - default: - /* unknown swap completion type */ - return False; - } - aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo; - aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo; - aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo; - return True; - } -#endif - - default: - /* client doesn't support server event */ - break; - } - - return False; -} - -/* We don't actually support this. It doesn't make sense for clients to - * send each other DRI2 events. - */ -static Status -DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - - XextCheckExtension(dpy, info, dri2ExtensionName, False); - - switch (event->type) { - default: - /* client doesn't support server event */ - break; - } - - return Success; -} - -Bool -DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - - if (XextHasExtension(info)) { - *eventBase = info->codes->first_event; - *errorBase = info->codes->first_error; - return True; - } - - return False; -} - -Bool -DRI2QueryVersion(Display * dpy, int *major, int *minor) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2QueryVersionReply rep; - xDRI2QueryVersionReq *req; - - XextCheckExtension(dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReq(DRI2QueryVersion, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2QueryVersion; - req->majorVersion = DRI2_MAJOR; - req->minorVersion = DRI2_MINOR; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - *major = rep.majorVersion; - *minor = rep.minorVersion; - UnlockDisplay(dpy); - SyncHandle(); - - return True; -} - -Bool -DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2ConnectReply rep; - xDRI2ConnectReq *req; - - XextCheckExtension(dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReq(DRI2Connect, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2Connect; - req->window = window; - req->driverType = DRI2DriverDRI; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - *driverName = Xmalloc(rep.driverNameLength + 1); - if (*driverName == NULL) { - _XEatData(dpy, - ((rep.driverNameLength + 3) & ~3) + - ((rep.deviceNameLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - _XReadPad(dpy, *driverName, rep.driverNameLength); - (*driverName)[rep.driverNameLength] = '\0'; - - *deviceName = Xmalloc(rep.deviceNameLength + 1); - if (*deviceName == NULL) { - Xfree(*driverName); - _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - _XReadPad(dpy, *deviceName, rep.deviceNameLength); - (*deviceName)[rep.deviceNameLength] = '\0'; - - UnlockDisplay(dpy); - SyncHandle(); - - return True; -} - -Bool -DRI2Authenticate(Display * dpy, XID window, drm_magic_t magic) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2AuthenticateReq *req; - xDRI2AuthenticateReply rep; - - XextCheckExtension(dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReq(DRI2Authenticate, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2Authenticate; - req->window = window; - req->magic = magic; - - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - UnlockDisplay(dpy); - SyncHandle(); - - return rep.authenticated; -} - -void -DRI2CreateDrawable(Display * dpy, XID drawable) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2CreateDrawableReq *req; - - XextSimpleCheckExtension(dpy, info, dri2ExtensionName); - - LockDisplay(dpy); - GetReq(DRI2CreateDrawable, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2CreateDrawable; - req->drawable = drawable; - UnlockDisplay(dpy); - SyncHandle(); -} - -void -DRI2DestroyDrawable(Display * dpy, XID drawable) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2DestroyDrawableReq *req; - - XextSimpleCheckExtension(dpy, info, dri2ExtensionName); - - XSync(dpy, False); - - LockDisplay(dpy); - GetReq(DRI2DestroyDrawable, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2DestroyDrawable; - req->drawable = drawable; - UnlockDisplay(dpy); - SyncHandle(); -} - -DRI2Buffer * -DRI2GetBuffers(Display * dpy, XID drawable, - int *width, int *height, - unsigned int *attachments, int count, int *outCount) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2GetBuffersReply rep; - xDRI2GetBuffersReq *req; - DRI2Buffer *buffers; - xDRI2Buffer repBuffer; - CARD32 *p; - int i; - - XextCheckExtension(dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReqExtra(DRI2GetBuffers, count * 4, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2GetBuffers; - req->drawable = drawable; - req->count = count; - p = (CARD32 *) & req[1]; - for (i = 0; i < count; i++) - p[i] = attachments[i]; - - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return NULL; - } - - *width = rep.width; - *height = rep.height; - *outCount = rep.count; - - buffers = Xmalloc(rep.count * sizeof buffers[0]); - if (buffers == NULL) { - _XEatData(dpy, rep.count * sizeof repBuffer); - UnlockDisplay(dpy); - SyncHandle(); - return NULL; - } - - for (i = 0; i < rep.count; i++) { - _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer); - buffers[i].attachment = repBuffer.attachment; - buffers[i].name = repBuffer.name; - buffers[i].pitch = repBuffer.pitch; - buffers[i].cpp = repBuffer.cpp; - buffers[i].flags = repBuffer.flags; - } - - UnlockDisplay(dpy); - SyncHandle(); - - return buffers; -} - - -DRI2Buffer * -DRI2GetBuffersWithFormat(Display * dpy, XID drawable, - int *width, int *height, - unsigned int *attachments, int count, int *outCount) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2GetBuffersReply rep; - xDRI2GetBuffersReq *req; - DRI2Buffer *buffers; - xDRI2Buffer repBuffer; - CARD32 *p; - int i; - - XextCheckExtension(dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReqExtra(DRI2GetBuffers, count * (4 * 2), req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2GetBuffersWithFormat; - req->drawable = drawable; - req->count = count; - p = (CARD32 *) & req[1]; - for (i = 0; i < (count * 2); i++) - p[i] = attachments[i]; - - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return NULL; - } - - *width = rep.width; - *height = rep.height; - *outCount = rep.count; - - buffers = Xmalloc(rep.count * sizeof buffers[0]); - if (buffers == NULL) { - _XEatData(dpy, rep.count * sizeof repBuffer); - UnlockDisplay(dpy); - SyncHandle(); - return NULL; - } - - for (i = 0; i < rep.count; i++) { - _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer); - buffers[i].attachment = repBuffer.attachment; - buffers[i].name = repBuffer.name; - buffers[i].pitch = repBuffer.pitch; - buffers[i].cpp = repBuffer.cpp; - buffers[i].flags = repBuffer.flags; - } - - UnlockDisplay(dpy); - SyncHandle(); - - return buffers; -} - - -void -DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region, - CARD32 dest, CARD32 src) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2CopyRegionReq *req; - xDRI2CopyRegionReply rep; - - XextSimpleCheckExtension(dpy, info, dri2ExtensionName); - - LockDisplay(dpy); - GetReq(DRI2CopyRegion, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2CopyRegion; - req->drawable = drawable; - req->region = region; - req->dest = dest; - req->src = src; - - _XReply(dpy, (xReply *) & rep, 0, xFalse); - - UnlockDisplay(dpy); - SyncHandle(); -} - -#ifdef X_DRI2SwapBuffers -static void -load_swap_req(xDRI2SwapBuffersReq *req, CARD64 target, CARD64 divisor, - CARD64 remainder) -{ - req->target_msc_hi = target >> 32; - req->target_msc_lo = target & 0xffffffff; - req->divisor_hi = divisor >> 32; - req->divisor_lo = divisor & 0xffffffff; - req->remainder_hi = remainder >> 32; - req->remainder_lo = remainder & 0xffffffff; -} - -static CARD64 -vals_to_card64(CARD32 lo, CARD32 hi) -{ - return (CARD64)hi << 32 | lo; -} - -void DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc, - CARD64 divisor, CARD64 remainder, CARD64 *count) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2SwapBuffersReq *req; - xDRI2SwapBuffersReply rep; - - XextSimpleCheckExtension (dpy, info, dri2ExtensionName); - - LockDisplay(dpy); - GetReq(DRI2SwapBuffers, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2SwapBuffers; - req->drawable = drawable; - load_swap_req(req, target_msc, divisor, remainder); - - _XReply(dpy, (xReply *)&rep, 0, xFalse); - - *count = vals_to_card64(rep.swap_lo, rep.swap_hi); - - UnlockDisplay(dpy); - SyncHandle(); -} -#endif - -#ifdef X_DRI2GetMSC -Bool DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc, - CARD64 *sbc) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2GetMSCReq *req; - xDRI2MSCReply rep; - - XextCheckExtension (dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReq(DRI2GetMSC, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2GetMSC; - req->drawable = drawable; - - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - *ust = vals_to_card64(rep.ust_lo, rep.ust_hi); - *msc = vals_to_card64(rep.msc_lo, rep.msc_hi); - *sbc = vals_to_card64(rep.sbc_lo, rep.sbc_hi); - - UnlockDisplay(dpy); - SyncHandle(); - - return True; -} -#endif - -#ifdef X_DRI2WaitMSC -static void -load_msc_req(xDRI2WaitMSCReq *req, CARD64 target, CARD64 divisor, - CARD64 remainder) -{ - req->target_msc_hi = target >> 32; - req->target_msc_lo = target & 0xffffffff; - req->divisor_hi = divisor >> 32; - req->divisor_lo = divisor & 0xffffffff; - req->remainder_hi = remainder >> 32; - req->remainder_lo = remainder & 0xffffffff; -} - -Bool DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor, - CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2WaitMSCReq *req; - xDRI2MSCReply rep; - - XextCheckExtension (dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReq(DRI2WaitMSC, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2WaitMSC; - req->drawable = drawable; - load_msc_req(req, target_msc, divisor, remainder); - - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - *ust = ((CARD64)rep.ust_hi << 32) | (CARD64)rep.ust_lo; - *msc = ((CARD64)rep.msc_hi << 32) | (CARD64)rep.msc_lo; - *sbc = ((CARD64)rep.sbc_hi << 32) | (CARD64)rep.sbc_lo; - - UnlockDisplay(dpy); - SyncHandle(); - - return True; -} -#endif - -#ifdef X_DRI2WaitSBC -static void -load_sbc_req(xDRI2WaitSBCReq *req, CARD64 target) -{ - req->target_sbc_hi = target >> 32; - req->target_sbc_lo = target & 0xffffffff; -} - -Bool DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust, - CARD64 *msc, CARD64 *sbc) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2WaitSBCReq *req; - xDRI2MSCReply rep; - - XextCheckExtension (dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReq(DRI2WaitSBC, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2WaitSBC; - req->drawable = drawable; - load_sbc_req(req, target_sbc); - - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - *ust = ((CARD64)rep.ust_hi << 32) | rep.ust_lo; - *msc = ((CARD64)rep.msc_hi << 32) | rep.msc_lo; - *sbc = ((CARD64)rep.sbc_hi << 32) | rep.sbc_lo; - - UnlockDisplay(dpy); - SyncHandle(); - - return True; -} -#endif - -#ifdef X_DRI2SwapInterval -void DRI2SwapInterval(Display *dpy, XID drawable, int interval) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2SwapIntervalReq *req; - - XextSimpleCheckExtension (dpy, info, dri2ExtensionName); - - LockDisplay(dpy); - GetReq(DRI2SwapInterval, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2SwapInterval; - req->drawable = drawable; - req->interval = interval; - UnlockDisplay(dpy); - SyncHandle(); -} -#endif - -#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/x11/dri2.h b/src/glx/x11/dri2.h deleted file mode 100644 index 114e9f8f965..00000000000 --- a/src/glx/x11/dri2.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright © 2007,2008 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Soft- - * ware"), to deal in the Software without restriction, including without - * limitation the rights to use, copy, modify, merge, publish, distribute, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, provided that the above copyright - * notice(s) and this permission notice appear in all copies of the Soft- - * ware and that both the above copyright notice(s) and this permission - * notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- - * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY - * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN - * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- - * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- - * MANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder shall - * not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization of - * the copyright holder. - * - * Authors: - * Kristian Høgsberg (krh@redhat.com) - */ - -#ifndef _DRI2_H_ -#define _DRI2_H_ - -#include -#include - -typedef struct -{ - unsigned int attachment; - unsigned int name; - unsigned int pitch; - unsigned int cpp; - unsigned int flags; -} DRI2Buffer; - -extern Bool -DRI2QueryExtension(Display * display, int *eventBase, int *errorBase); - -extern Bool -DRI2QueryVersion(Display * display, int *major, int *minor); - -extern Bool -DRI2Connect(Display * display, XID window, - char **driverName, char **deviceName); - -extern Bool -DRI2Authenticate(Display * display, XID window, drm_magic_t magic); - -extern void -DRI2CreateDrawable(Display * display, XID drawable); - -extern void -DRI2DestroyDrawable(Display * display, XID handle); - -extern DRI2Buffer* -DRI2GetBuffers(Display * dpy, XID drawable, - int *width, int *height, - unsigned int *attachments, int count, - int *outCount); - -/** - * \note - * This function is only supported with DRI2 version 1.1 or later. - */ -extern DRI2Buffer* -DRI2GetBuffersWithFormat(Display * dpy, XID drawable, - int *width, int *height, - unsigned int *attachments, - int count, int *outCount); - -extern void -DRI2CopyRegion(Display * dpy, XID drawable, - XserverRegion region, - CARD32 dest, CARD32 src); - -extern void -DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor, - CARD64 remainder, CARD64 *count); - -extern Bool -DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc, CARD64 *sbc); - -extern Bool -DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor, - CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc); - -extern Bool -DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust, - CARD64 *msc, CARD64 *sbc); - -extern void -DRI2SwapInterval(Display *dpy, XID drawable, int interval); - -#endif diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c deleted file mode 100644 index 15a3ea59073..00000000000 --- a/src/glx/x11/dri2_glx.c +++ /dev/null @@ -1,666 +0,0 @@ -/* - * Copyright © 2008 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Soft- - * ware"), to deal in the Software without restriction, including without - * limitation the rights to use, copy, modify, merge, publish, distribute, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, provided that the above copyright - * notice(s) and this permission notice appear in all copies of the Soft- - * ware and that both the above copyright notice(s) and this permission - * notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- - * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY - * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN - * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- - * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- - * MANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder shall - * not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization of - * the copyright holder. - * - * Authors: - * Kristian Høgsberg (krh@redhat.com) - */ - -#ifdef GLX_DIRECT_RENDERING - -#include -#include -#include -#include "glapi.h" -#include "glxclient.h" -#include -#include "xf86dri.h" -#include -#include -#include -#include -#include -#include "xf86drm.h" -#include "dri2.h" -#include "dri_common.h" -#include "../../mesa/drivers/dri/common/dri_util.h" - -#undef DRI2_MINOR -#define DRI2_MINOR 1 - -typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate; -typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate; -typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate; - -struct __GLXDRIdisplayPrivateRec -{ - __GLXDRIdisplay base; - - /* - ** XFree86-DRI version information - */ - int driMajor; - int driMinor; - int driPatch; - int swapAvailable; -}; - -struct __GLXDRIcontextPrivateRec -{ - __GLXDRIcontext base; - __DRIcontext *driContext; - __GLXscreenConfigs *psc; -}; - -struct __GLXDRIdrawablePrivateRec -{ - __GLXDRIdrawable base; - __DRIbuffer buffers[5]; - int bufferCount; - int width, height; - int have_back; - int have_fake_front; - int swap_interval; -}; - -static void dri2WaitX(__GLXDRIdrawable * pdraw); - -static void -dri2DestroyContext(__GLXDRIcontext * context, - __GLXscreenConfigs * psc, Display * dpy) -{ - __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; - const __DRIcoreExtension *core = pcp->psc->core; - - (*core->destroyContext) (pcp->driContext); - - Xfree(pcp); -} - -static Bool -dri2BindContext(__GLXDRIcontext * context, - __GLXDRIdrawable * draw, __GLXDRIdrawable * read) -{ - __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; - const __DRIcoreExtension *core = pcp->psc->core; - - return (*core->bindContext) (pcp->driContext, - draw->driDrawable, read->driDrawable); -} - -static void -dri2UnbindContext(__GLXDRIcontext * context) -{ - __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; - const __DRIcoreExtension *core = pcp->psc->core; - - (*core->unbindContext) (pcp->driContext); -} - -static __GLXDRIcontext * -dri2CreateContext(__GLXscreenConfigs * psc, - const __GLcontextModes * mode, - GLXContext gc, GLXContext shareList, int renderType) -{ - __GLXDRIcontextPrivate *pcp, *pcp_shared; - __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode; - __DRIcontext *shared = NULL; - - if (shareList) { - pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext; - shared = pcp_shared->driContext; - } - - pcp = Xmalloc(sizeof *pcp); - if (pcp == NULL) - return NULL; - - pcp->psc = psc; - pcp->driContext = - (*psc->dri2->createNewContext) (psc->__driScreen, - config->driConfig, shared, pcp); - gc->__driContext = pcp->driContext; - - if (pcp->driContext == NULL) { - Xfree(pcp); - return NULL; - } - - pcp->base.destroyContext = dri2DestroyContext; - pcp->base.bindContext = dri2BindContext; - pcp->base.unbindContext = dri2UnbindContext; - - return &pcp->base; -} - -static void -dri2DestroyDrawable(__GLXDRIdrawable * pdraw) -{ - const __DRIcoreExtension *core = pdraw->psc->core; - - (*core->destroyDrawable) (pdraw->driDrawable); - DRI2DestroyDrawable(pdraw->psc->dpy, pdraw->xDrawable); - Xfree(pdraw); -} - -static __GLXDRIdrawable * -dri2CreateDrawable(__GLXscreenConfigs * psc, - XID xDrawable, - GLXDrawable drawable, const __GLcontextModes * modes) -{ - __GLXDRIdrawablePrivate *pdraw; - __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; - - pdraw = Xmalloc(sizeof(*pdraw)); - if (!pdraw) - return NULL; - - pdraw->base.destroyDrawable = dri2DestroyDrawable; - pdraw->base.xDrawable = xDrawable; - pdraw->base.drawable = drawable; - pdraw->base.psc = psc; - pdraw->bufferCount = 0; - - DRI2CreateDrawable(psc->dpy, xDrawable); - - /* Create a new drawable */ - pdraw->base.driDrawable = - (*psc->dri2->createNewDrawable) (psc->__driScreen, - config->driConfig, pdraw); - - if (!pdraw->base.driDrawable) { - DRI2DestroyDrawable(psc->dpy, xDrawable); - Xfree(pdraw); - return NULL; - } - - return &pdraw->base; -} - -static int -dri2DrawableGetMSC(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw, - int64_t *ust, int64_t *msc, int64_t *sbc) -{ - return DRI2GetMSC(psc->dpy, pdraw->xDrawable, ust, msc, sbc); -} - -static int -dri2WaitForMSC(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor, - int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc) -{ - return DRI2WaitMSC(pdraw->psc->dpy, pdraw->xDrawable, target_msc, divisor, - remainder, ust, msc, sbc); -} - -static int -dri2WaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust, - int64_t *msc, int64_t *sbc) -{ - return DRI2WaitSBC(pdraw->psc->dpy, pdraw->xDrawable, target_sbc, ust, msc, - sbc); -} - -static void -dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height) -{ - __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; - XRectangle xrect; - XserverRegion region; - - /* Check we have the right attachments */ - if (!priv->have_back) - return; - - xrect.x = x; - xrect.y = priv->height - y - height; - xrect.width = width; - xrect.height = height; - -#ifdef __DRI2_FLUSH - if (pdraw->psc->f) - (*pdraw->psc->f->flush) (pdraw->driDrawable); -#endif - - region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1); - /* should get a fence ID back from here at some point */ - DRI2CopyRegion(pdraw->psc->dpy, pdraw->xDrawable, region, - DRI2BufferFrontLeft, DRI2BufferBackLeft); - XFixesDestroyRegion(pdraw->psc->dpy, region); - - /* Refresh the fake front (if present) after we just damaged the real - * front. - */ - dri2WaitX(pdraw); -} - -static void -dri2WaitX(__GLXDRIdrawable *pdraw) -{ - __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; - XRectangle xrect; - XserverRegion region; - - /* Check we have the right attachments */ - if (!priv->have_fake_front) - return; - - xrect.x = 0; - xrect.y = 0; - xrect.width = priv->width; - xrect.height = priv->height; - -#ifdef __DRI2_FLUSH - if (pdraw->psc->f) - (*pdraw->psc->f->flush) (pdraw->driDrawable); -#endif - - region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1); - DRI2CopyRegion(pdraw->psc->dpy, pdraw->xDrawable, region, - DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft); - XFixesDestroyRegion(pdraw->psc->dpy, region); -} - -static void -dri2WaitGL(__GLXDRIdrawable * pdraw) -{ - __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; - XRectangle xrect; - XserverRegion region; - - if (!priv->have_fake_front) - return; - - xrect.x = 0; - xrect.y = 0; - xrect.width = priv->width; - xrect.height = priv->height; - -#ifdef __DRI2_FLUSH - if (pdraw->psc->f) - (*pdraw->psc->f->flush) (pdraw->driDrawable); -#endif - - region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1); - DRI2CopyRegion(pdraw->psc->dpy, pdraw->xDrawable, region, - DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); - XFixesDestroyRegion(pdraw->psc->dpy, region); -} - - -static void -dri2FlushFrontBuffer(__DRIdrawable * driDrawable, void *loaderPrivate) -{ - (void) driDrawable; - dri2WaitGL((__GLXDRIdrawable *) loaderPrivate); -} - - -static void -dri2DestroyScreen(__GLXscreenConfigs * psc) -{ - /* Free the direct rendering per screen data */ - (*psc->core->destroyScreen) (psc->__driScreen); - close(psc->fd); - psc->__driScreen = NULL; -} - -/** - * Process list of buffer received from the server - * - * Processes the list of buffers received in a reply from the server to either - * \c DRI2GetBuffers or \c DRI2GetBuffersWithFormat. - */ -static void -process_buffers(__GLXDRIdrawablePrivate * pdraw, DRI2Buffer * buffers, - unsigned count) -{ - int i; - - pdraw->bufferCount = count; - pdraw->have_fake_front = 0; - pdraw->have_back = 0; - - /* This assumes the DRI2 buffer attachment tokens matches the - * __DRIbuffer tokens. */ - for (i = 0; i < count; i++) { - pdraw->buffers[i].attachment = buffers[i].attachment; - pdraw->buffers[i].name = buffers[i].name; - pdraw->buffers[i].pitch = buffers[i].pitch; - pdraw->buffers[i].cpp = buffers[i].cpp; - pdraw->buffers[i].flags = buffers[i].flags; - if (pdraw->buffers[i].attachment == __DRI_BUFFER_FAKE_FRONT_LEFT) - pdraw->have_fake_front = 1; - if (pdraw->buffers[i].attachment == __DRI_BUFFER_BACK_LEFT) - pdraw->have_back = 1; - } - -} - -static int64_t -dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor, - int64_t remainder) -{ - __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; - __GLXdisplayPrivate *dpyPriv = __glXInitialize(priv->base.psc->dpy); - __GLXDRIdisplayPrivate *pdp = - (__GLXDRIdisplayPrivate *)dpyPriv->dri2Display; - int64_t ret; - -#ifdef __DRI2_FLUSH - if (pdraw->psc->f) - (*pdraw->psc->f->flush)(pdraw->driDrawable); -#endif - - /* Old servers can't handle swapbuffers */ - if (!pdp->swapAvailable) { - dri2CopySubBuffer(pdraw, 0, 0, priv->width, priv->height); - return 0; - } - -#ifdef X_DRI2SwapBuffers - DRI2SwapBuffers(pdraw->psc->dpy, pdraw->xDrawable, target_msc, divisor, - remainder, &ret); -#endif - -#if __DRI2_FLUSH_VERSION >= 2 - if (pdraw->psc->f) - (*pdraw->psc->f->flushInvalidate)(pdraw->driDrawable); -#endif - - return ret; -} - -static __DRIbuffer * -dri2GetBuffers(__DRIdrawable * driDrawable, - int *width, int *height, - unsigned int *attachments, int count, - int *out_count, void *loaderPrivate) -{ - __GLXDRIdrawablePrivate *pdraw = loaderPrivate; - DRI2Buffer *buffers; - - buffers = DRI2GetBuffers(pdraw->base.psc->dpy, pdraw->base.xDrawable, - width, height, attachments, count, out_count); - if (buffers == NULL) - return NULL; - - pdraw->width = *width; - pdraw->height = *height; - process_buffers(pdraw, buffers, *out_count); - - Xfree(buffers); - - return pdraw->buffers; -} - -static __DRIbuffer * -dri2GetBuffersWithFormat(__DRIdrawable * driDrawable, - int *width, int *height, - unsigned int *attachments, int count, - int *out_count, void *loaderPrivate) -{ - __GLXDRIdrawablePrivate *pdraw = loaderPrivate; - DRI2Buffer *buffers; - - buffers = DRI2GetBuffersWithFormat(pdraw->base.psc->dpy, - pdraw->base.xDrawable, - width, height, attachments, - count, out_count); - if (buffers == NULL) - return NULL; - - pdraw->width = *width; - pdraw->height = *height; - process_buffers(pdraw, buffers, *out_count); - - Xfree(buffers); - - return pdraw->buffers; -} - -static void -dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval) -{ - __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; - - DRI2SwapInterval(priv->base.psc->dpy, pdraw->xDrawable, interval); - priv->swap_interval = interval; -} - -static unsigned int -dri2GetSwapInterval(__GLXDRIdrawable *pdraw) -{ - __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; - - return priv->swap_interval; -} - -static const __DRIdri2LoaderExtension dri2LoaderExtension = { - {__DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION}, - dri2GetBuffers, - dri2FlushFrontBuffer, - dri2GetBuffersWithFormat, -}; - -static const __DRIdri2LoaderExtension dri2LoaderExtension_old = { - {__DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION}, - dri2GetBuffers, - dri2FlushFrontBuffer, - NULL, -}; - -static const __DRIextension *loader_extensions[] = { - &dri2LoaderExtension.base, - &systemTimeExtension.base, - NULL -}; - -static const __DRIextension *loader_extensions_old[] = { - &dri2LoaderExtension_old.base, - &systemTimeExtension.base, - NULL -}; - -static __GLXDRIscreen * -dri2CreateScreen(__GLXscreenConfigs * psc, int screen, - __GLXdisplayPrivate * priv) -{ - const __DRIconfig **driver_configs; - const __DRIextension **extensions; - const __GLXDRIdisplayPrivate *const pdp = (__GLXDRIdisplayPrivate *) - priv->dri2Display; - __GLXDRIscreen *psp; - char *driverName, *deviceName; - drm_magic_t magic; - int i; - - psp = Xmalloc(sizeof *psp); - if (psp == NULL) - return NULL; - - /* Initialize per screen dynamic client GLX extensions */ - psc->ext_list_first_time = GL_TRUE; - - if (!DRI2Connect(psc->dpy, RootWindow(psc->dpy, screen), - &driverName, &deviceName)) { - XFree(psp); - return NULL; - } - - psc->driver = driOpenDriver(driverName); - if (psc->driver == NULL) { - ErrorMessageF("driver pointer missing\n"); - goto handle_error; - } - - extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS); - if (extensions == NULL) { - ErrorMessageF("driver exports no extensions (%s)\n", dlerror()); - goto handle_error; - } - - for (i = 0; extensions[i]; i++) { - if (strcmp(extensions[i]->name, __DRI_CORE) == 0) - psc->core = (__DRIcoreExtension *) extensions[i]; - if (strcmp(extensions[i]->name, __DRI_DRI2) == 0) - psc->dri2 = (__DRIdri2Extension *) extensions[i]; - } - - if (psc->core == NULL || psc->dri2 == NULL) { - ErrorMessageF("core dri or dri2 extension not found\n"); - goto handle_error; - } - - psc->fd = open(deviceName, O_RDWR); - if (psc->fd < 0) { - ErrorMessageF("failed to open drm device: %s\n", strerror(errno)); - goto handle_error; - } - - if (drmGetMagic(psc->fd, &magic)) { - ErrorMessageF("failed to get magic\n"); - goto handle_error; - } - - if (!DRI2Authenticate(psc->dpy, RootWindow(psc->dpy, screen), magic)) { - ErrorMessageF("failed to authenticate magic %d\n", magic); - goto handle_error; - } - - /* If the server does not support the protocol for - * DRI2GetBuffersWithFormat, don't supply that interface to the driver. - */ - psc->__driScreen = - psc->dri2->createNewScreen(screen, psc->fd, ((pdp->driMinor < 1) - ? loader_extensions_old - : loader_extensions), - &driver_configs, psc); - - if (psc->__driScreen == NULL) { - ErrorMessageF("failed to create dri screen\n"); - goto handle_error; - } - - driBindCommonExtensions(psc); - dri2BindExtensions(psc); - - psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs); - psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs); - - psc->driver_configs = driver_configs; - - psp->destroyScreen = dri2DestroyScreen; - psp->createContext = dri2CreateContext; - psp->createDrawable = dri2CreateDrawable; - psp->swapBuffers = dri2SwapBuffers; - psp->waitGL = dri2WaitGL; - psp->waitX = dri2WaitX; - psp->getDrawableMSC = NULL; - psp->waitForMSC = NULL; - psp->waitForSBC = NULL; - psp->setSwapInterval = NULL; - psp->getSwapInterval = NULL; - - if (pdp->driMinor >= 2) { -#ifdef X_DRI2GetMSC - psp->getDrawableMSC = dri2DrawableGetMSC; -#endif -#ifdef X_DRI2WaitMSC - psp->waitForMSC = dri2WaitForMSC; - psp->waitForSBC = dri2WaitForSBC; -#endif -#ifdef X_DRI2SwapInterval - psp->setSwapInterval = dri2SetSwapInterval; - psp->getSwapInterval = dri2GetSwapInterval; -#endif - } - - /* DRI2 suports SubBuffer through DRI2CopyRegion, so it's always - * available.*/ - psp->copySubBuffer = dri2CopySubBuffer; - __glXEnableDirectExtension(psc, "GLX_MESA_copy_sub_buffer"); - - Xfree(driverName); - Xfree(deviceName); - - return psp; - -handle_error: - Xfree(driverName); - Xfree(deviceName); - XFree(psp); - - /* FIXME: clean up here */ - - return NULL; -} - -/* Called from __glXFreeDisplayPrivate. - */ -static void -dri2DestroyDisplay(__GLXDRIdisplay * dpy) -{ - Xfree(dpy); -} - -/* - * Allocate, initialize and return a __DRIdisplayPrivate object. - * This is called from __glXInitialize() when we are given a new - * display pointer. - */ -_X_HIDDEN __GLXDRIdisplay * -dri2CreateDisplay(Display * dpy) -{ - __GLXDRIdisplayPrivate *pdp; - int eventBase, errorBase; - - if (!DRI2QueryExtension(dpy, &eventBase, &errorBase)) - return NULL; - - pdp = Xmalloc(sizeof *pdp); - if (pdp == NULL) - return NULL; - - if (!DRI2QueryVersion(dpy, &pdp->driMajor, &pdp->driMinor)) { - Xfree(pdp); - return NULL; - } - - pdp->driPatch = 0; - pdp->swapAvailable = 0; -#ifdef X_DRI2SwapBuffers - if (pdp->driMinor >= 2) - pdp->swapAvailable = 1; -#endif - - pdp->base.destroyDisplay = dri2DestroyDisplay; - pdp->base.createScreen = dri2CreateScreen; - - return &pdp->base; -} - -#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/x11/dri_common.c b/src/glx/x11/dri_common.c deleted file mode 100644 index e4034161bb3..00000000000 --- a/src/glx/x11/dri_common.c +++ /dev/null @@ -1,450 +0,0 @@ -/* - * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - * Copyright © 2008 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Soft- - * ware"), to deal in the Software without restriction, including without - * limitation the rights to use, copy, modify, merge, publish, distribute, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, provided that the above copyright - * notice(s) and this permission notice appear in all copies of the Soft- - * ware and that both the above copyright notice(s) and this permission - * notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- - * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY - * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN - * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- - * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- - * MANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder shall - * not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization of - * the copyright holder. - * - * Authors: - * Kevin E. Martin - * Brian Paul - * Kristian Høgsberg (krh@redhat.com) - */ - -#ifdef GLX_DIRECT_RENDERING - -#include -#include -#include -#include "glxclient.h" -#include "glcontextmodes.h" -#include "dri_common.h" - -#ifndef RTLD_NOW -#define RTLD_NOW 0 -#endif -#ifndef RTLD_GLOBAL -#define RTLD_GLOBAL 0 -#endif - -_X_HIDDEN void -InfoMessageF(const char *f, ...) -{ - va_list args; - const char *env; - - if ((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) { - fprintf(stderr, "libGL: "); - va_start(args, f); - vfprintf(stderr, f, args); - va_end(args); - } -} - -/** - * Print error to stderr, unless LIBGL_DEBUG=="quiet". - */ -_X_HIDDEN void -ErrorMessageF(const char *f, ...) -{ - va_list args; - const char *env; - - if ((env = getenv("LIBGL_DEBUG")) && !strstr(env, "quiet")) { - fprintf(stderr, "libGL error: "); - va_start(args, f); - vfprintf(stderr, f, args); - va_end(args); - } -} - -#ifndef DEFAULT_DRIVER_DIR -/* this is normally defined in Mesa/configs/default with DRI_DRIVER_SEARCH_PATH */ -#define DEFAULT_DRIVER_DIR "/usr/local/lib/dri" -#endif - -/** - * Try to \c dlopen the named driver. - * - * This function adds the "_dri.so" suffix to the driver name and searches the - * directories specified by the \c LIBGL_DRIVERS_PATH environment variable in - * order to find the driver. - * - * \param driverName - a name like "tdfx", "i810", "mga", etc. - * - * \returns - * A handle from \c dlopen, or \c NULL if driver file not found. - */ -_X_HIDDEN void * -driOpenDriver(const char *driverName) -{ - void *glhandle, *handle; - const char *libPaths, *p, *next; - char realDriverName[200]; - int len; - - /* Attempt to make sure libGL symbols will be visible to the driver */ - glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL); - - libPaths = NULL; - if (geteuid() == getuid()) { - /* don't allow setuid apps to use LIBGL_DRIVERS_PATH */ - libPaths = getenv("LIBGL_DRIVERS_PATH"); - if (!libPaths) - libPaths = getenv("LIBGL_DRIVERS_DIR"); /* deprecated */ - } - if (libPaths == NULL) - libPaths = DEFAULT_DRIVER_DIR; - - handle = NULL; - for (p = libPaths; *p; p = next) { - next = strchr(p, ':'); - if (next == NULL) { - len = strlen(p); - next = p + len; - } - else { - len = next - p; - next++; - } - -#ifdef GLX_USE_TLS - snprintf(realDriverName, sizeof realDriverName, - "%.*s/tls/%s_dri.so", len, p, driverName); - InfoMessageF("OpenDriver: trying %s\n", realDriverName); - handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL); -#endif - - if (handle == NULL) { - snprintf(realDriverName, sizeof realDriverName, - "%.*s/%s_dri.so", len, p, driverName); - InfoMessageF("OpenDriver: trying %s\n", realDriverName); - handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL); - } - - if (handle != NULL) - break; - else - ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror()); - } - - if (!handle) - ErrorMessageF("unable to load driver: %s_dri.so\n", driverName); - - if (glhandle) - dlclose(glhandle); - - return handle; -} - -_X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension = { - {__DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION}, - __glXGetUST, - __driGetMscRateOML -}; - -#define __ATTRIB(attrib, field) \ - { attrib, offsetof(__GLcontextModes, field) } - -static const struct -{ - unsigned int attrib, offset; -} attribMap[] = { - __ATTRIB(__DRI_ATTRIB_BUFFER_SIZE, rgbBits), - __ATTRIB(__DRI_ATTRIB_LEVEL, level), - __ATTRIB(__DRI_ATTRIB_RED_SIZE, redBits), - __ATTRIB(__DRI_ATTRIB_GREEN_SIZE, greenBits), - __ATTRIB(__DRI_ATTRIB_BLUE_SIZE, blueBits), - __ATTRIB(__DRI_ATTRIB_ALPHA_SIZE, alphaBits), - __ATTRIB(__DRI_ATTRIB_DEPTH_SIZE, depthBits), - __ATTRIB(__DRI_ATTRIB_STENCIL_SIZE, stencilBits), - __ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE, accumRedBits), - __ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE, accumGreenBits), - __ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE, accumBlueBits), - __ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE, accumAlphaBits), - __ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS, sampleBuffers), - __ATTRIB(__DRI_ATTRIB_SAMPLES, samples), - __ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode), - __ATTRIB(__DRI_ATTRIB_STEREO, stereoMode), - __ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers), -#if 0 - __ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel), - __ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentIndex), - __ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed), - __ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen), - __ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue), - __ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha), - __ATTRIB(__DRI_ATTRIB_RED_MASK, redMask), - __ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask), - __ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask), - __ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask), -#endif - __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth), - __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight), - __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels), - __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth), - __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight), -#if 0 - __ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod), -#endif -__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb), - __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba), - __ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE, - bindToMipmapTexture), - __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),}; - -#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) - -static int -scalarEqual(__GLcontextModes * mode, unsigned int attrib, unsigned int value) -{ - unsigned int glxValue; - int i; - - for (i = 0; i < ARRAY_SIZE(attribMap); i++) - if (attribMap[i].attrib == attrib) { - glxValue = *(unsigned int *) ((char *) mode + attribMap[i].offset); - return glxValue == GLX_DONT_CARE || glxValue == value; - } - - return GL_TRUE; /* Is a non-existing attribute equal to value? */ -} - -static int -driConfigEqual(const __DRIcoreExtension * core, - __GLcontextModes * modes, const __DRIconfig * driConfig) -{ - unsigned int attrib, value, glxValue; - int i; - - i = 0; - while (core->indexConfigAttrib(driConfig, i++, &attrib, &value)) { - switch (attrib) { - case __DRI_ATTRIB_RENDER_TYPE: - glxValue = 0; - if (value & __DRI_ATTRIB_RGBA_BIT) { - glxValue |= GLX_RGBA_BIT; - } - else if (value & __DRI_ATTRIB_COLOR_INDEX_BIT) { - glxValue |= GLX_COLOR_INDEX_BIT; - } - if (glxValue != modes->renderType) - return GL_FALSE; - break; - - case __DRI_ATTRIB_CONFIG_CAVEAT: - if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG) - glxValue = GLX_NON_CONFORMANT_CONFIG; - else if (value & __DRI_ATTRIB_SLOW_BIT) - glxValue = GLX_SLOW_CONFIG; - else - glxValue = GLX_NONE; - if (glxValue != modes->visualRating) - return GL_FALSE; - break; - - case __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS: - glxValue = 0; - if (value & __DRI_ATTRIB_TEXTURE_1D_BIT) - glxValue |= GLX_TEXTURE_1D_BIT_EXT; - if (value & __DRI_ATTRIB_TEXTURE_2D_BIT) - glxValue |= GLX_TEXTURE_2D_BIT_EXT; - if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT) - glxValue |= GLX_TEXTURE_RECTANGLE_BIT_EXT; - if (modes->bindToTextureTargets != GLX_DONT_CARE && - glxValue != modes->bindToTextureTargets) - return GL_FALSE; - break; - - default: - if (!scalarEqual(modes, attrib, value)) - return GL_FALSE; - } - } - - return GL_TRUE; -} - -static __GLcontextModes * -createDriMode(const __DRIcoreExtension * core, - __GLcontextModes * modes, const __DRIconfig ** driConfigs) -{ - __GLXDRIconfigPrivate *config; - int i; - - for (i = 0; driConfigs[i]; i++) { - if (driConfigEqual(core, modes, driConfigs[i])) - break; - } - - if (driConfigs[i] == NULL) - return NULL; - - config = Xmalloc(sizeof *config); - if (config == NULL) - return NULL; - - config->modes = *modes; - config->driConfig = driConfigs[i]; - - return &config->modes; -} - -_X_HIDDEN __GLcontextModes * -driConvertConfigs(const __DRIcoreExtension * core, - __GLcontextModes * modes, const __DRIconfig ** configs) -{ - __GLcontextModes head, *tail, *m; - - tail = &head; - head.next = NULL; - for (m = modes; m; m = m->next) { - tail->next = createDriMode(core, m, configs); - if (tail->next == NULL) { - /* no matching dri config for m */ - continue; - } - - - tail = tail->next; - } - - _gl_context_modes_destroy(modes); - - return head.next; -} - -/* Bind DRI1 specific extensions */ -_X_HIDDEN void -driBindExtensions(__GLXscreenConfigs *psc) -{ - const __DRIextension **extensions; - int i; - - extensions = psc->core->getExtensions(psc->__driScreen); - - for (i = 0; extensions[i]; i++) { -#ifdef __DRI_SWAP_CONTROL - /* No DRI2 support for swap_control at the moment, since SwapBuffers - * is done by the X server */ - if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) { - psc->swapControl = (__DRIswapControlExtension *) extensions[i]; - __glXEnableDirectExtension(psc, "GLX_SGI_swap_control"); - __glXEnableDirectExtension(psc, "GLX_MESA_swap_control"); - } -#endif - -#ifdef __DRI_MEDIA_STREAM_COUNTER - if (strcmp(extensions[i]->name, __DRI_MEDIA_STREAM_COUNTER) == 0) { - psc->msc = (__DRImediaStreamCounterExtension *) extensions[i]; - __glXEnableDirectExtension(psc, "GLX_SGI_video_sync"); - } -#endif - -#ifdef __DRI_SWAP_BUFFER_COUNTER - /* No driver supports this at this time and the extension is - * not defined in dri_interface.h. Will enable - * GLX_OML_sync_control if implemented. */ -#endif - - /* Ignore unknown extensions */ - } -} - -/* Bind DRI2 specific extensions */ -_X_HIDDEN void -dri2BindExtensions(__GLXscreenConfigs *psc) -{ - const __DRIextension **extensions; - int i; - - extensions = psc->core->getExtensions(psc->__driScreen); - - for (i = 0; extensions[i]; i++) { -#ifdef __DRI_TEX_BUFFER - if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) { - psc->texBuffer = (__DRItexBufferExtension *) extensions[i]; - __glXEnableDirectExtension(psc, "GLX_EXT_texture_from_pixmap"); - } -#endif - - __glXEnableDirectExtension(psc, "GLX_SGI_video_sync"); - __glXEnableDirectExtension(psc, "GLX_SGI_swap_control"); - __glXEnableDirectExtension(psc, "GLX_MESA_swap_control"); - - /* FIXME: if DRI2 version supports it... */ - __glXEnableDirectExtension(psc, "INTEL_swap_event"); - -#ifdef __DRI2_FLUSH - if ((strcmp(extensions[i]->name, __DRI2_FLUSH) == 0)) { - psc->f = (__DRI2flushExtension *) extensions[i]; - /* internal driver extension, no GL extension exposed */ - } -#endif - } -} - -/* Bind extensions common to DRI1 and DRI2 */ -_X_HIDDEN void -driBindCommonExtensions(__GLXscreenConfigs *psc) -{ - const __DRIextension **extensions; - int i; - - extensions = psc->core->getExtensions(psc->__driScreen); - - for (i = 0; extensions[i]; i++) { -#ifdef __DRI_COPY_SUB_BUFFER - if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) { - psc->driCopySubBuffer = (__DRIcopySubBufferExtension *) extensions[i]; - __glXEnableDirectExtension(psc, "GLX_MESA_copy_sub_buffer"); - } -#endif - -#ifdef __DRI_ALLOCATE - if (strcmp(extensions[i]->name, __DRI_ALLOCATE) == 0) { - psc->allocate = (__DRIallocateExtension *) extensions[i]; - __glXEnableDirectExtension(psc, "GLX_MESA_allocate_memory"); - } -#endif - -#ifdef __DRI_FRAME_TRACKING - if (strcmp(extensions[i]->name, __DRI_FRAME_TRACKING) == 0) { - psc->frameTracking = (__DRIframeTrackingExtension *) extensions[i]; - __glXEnableDirectExtension(psc, "GLX_MESA_swap_frame_usage"); - } -#endif - -#ifdef __DRI_READ_DRAWABLE - if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) { - __glXEnableDirectExtension(psc, "GLX_SGI_make_current_read"); - } -#endif - - /* Ignore unknown extensions */ - } -} - -#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/x11/dri_common.h b/src/glx/x11/dri_common.h deleted file mode 100644 index bb178db7875..00000000000 --- a/src/glx/x11/dri_common.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - * Copyright © 2008 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Soft- - * ware"), to deal in the Software without restriction, including without - * limitation the rights to use, copy, modify, merge, publish, distribute, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, provided that the above copyright - * notice(s) and this permission notice appear in all copies of the Soft- - * ware and that both the above copyright notice(s) and this permission - * notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- - * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY - * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN - * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- - * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- - * MANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder shall - * not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization of - * the copyright holder. - * - * Authors: - * Kevin E. Martin - * Brian Paul - * Kristian Høgsberg (krh@redhat.com) - */ - -#ifndef _DRI_COMMON_H -#define _DRI_COMMON_H - -typedef struct __GLXDRIconfigPrivateRec __GLXDRIconfigPrivate; - -struct __GLXDRIconfigPrivateRec -{ - __GLcontextModes modes; - const __DRIconfig *driConfig; -}; - -extern __GLcontextModes *driConvertConfigs(const __DRIcoreExtension * core, - __GLcontextModes * modes, - const __DRIconfig ** configs); - -extern const __DRIsystemTimeExtension systemTimeExtension; - -extern void InfoMessageF(const char *f, ...); - -extern void ErrorMessageF(const char *f, ...); - -extern void *driOpenDriver(const char *driverName); - -extern void driBindExtensions(__GLXscreenConfigs * psc); -extern void dri2BindExtensions(__GLXscreenConfigs * psc); -extern void driBindCommonExtensions(__GLXscreenConfigs * psc); - -#endif /* _DRI_COMMON_H */ diff --git a/src/glx/x11/dri_glx.c b/src/glx/x11/dri_glx.c deleted file mode 100644 index 0ff53c324f5..00000000000 --- a/src/glx/x11/dri_glx.c +++ /dev/null @@ -1,751 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * Brian Paul - * - */ - -#ifdef GLX_DIRECT_RENDERING - -#include -#include -#include -#include "glxclient.h" -#include "xf86dri.h" -#include "dri2.h" -#include "sarea.h" -#include -#include -#include -#include "xf86drm.h" -#include "dri_common.h" - -typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate; -typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate; - -struct __GLXDRIdisplayPrivateRec -{ - __GLXDRIdisplay base; - - /* - ** XFree86-DRI version information - */ - int driMajor; - int driMinor; - int driPatch; -}; - -struct __GLXDRIcontextPrivateRec -{ - __GLXDRIcontext base; - __DRIcontext *driContext; - XID hwContextID; - __GLXscreenConfigs *psc; -}; - -/* - * Given a display pointer and screen number, determine the name of - * the DRI driver for the screen. (I.e. "r128", "tdfx", etc). - * Return True for success, False for failure. - */ -static Bool -driGetDriverName(Display * dpy, int scrNum, char **driverName) -{ - int directCapable; - Bool b; - int event, error; - int driverMajor, driverMinor, driverPatch; - - *driverName = NULL; - - if (XF86DRIQueryExtension(dpy, &event, &error)) { /* DRI1 */ - if (!XF86DRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) { - ErrorMessageF("XF86DRIQueryDirectRenderingCapable failed\n"); - return False; - } - if (!directCapable) { - ErrorMessageF("XF86DRIQueryDirectRenderingCapable returned false\n"); - return False; - } - - b = XF86DRIGetClientDriverName(dpy, scrNum, &driverMajor, &driverMinor, - &driverPatch, driverName); - if (!b) { - ErrorMessageF("Cannot determine driver name for screen %d\n", - scrNum); - return False; - } - - InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n", - driverMajor, driverMinor, driverPatch, *driverName, - scrNum); - - return True; - } - else if (DRI2QueryExtension(dpy, &event, &error)) { /* DRI2 */ - char *dev; - Bool ret = DRI2Connect(dpy, RootWindow(dpy, scrNum), driverName, &dev); - - if (ret) - Xfree(dev); - - return ret; - } - - return False; -} - -/* - * Exported function for querying the DRI driver for a given screen. - * - * The returned char pointer points to a static array that will be - * overwritten by subsequent calls. - */ -PUBLIC const char * -glXGetScreenDriver(Display * dpy, int scrNum) -{ - static char ret[32]; - char *driverName; - if (driGetDriverName(dpy, scrNum, &driverName)) { - int len; - if (!driverName) - return NULL; - len = strlen(driverName); - if (len >= 31) - return NULL; - memcpy(ret, driverName, len + 1); - Xfree(driverName); - return ret; - } - return NULL; -} - -/* - * Exported function for obtaining a driver's option list (UTF-8 encoded XML). - * - * The returned char pointer points directly into the driver. Therefore - * it should be treated as a constant. - * - * If the driver was not found or does not support configuration NULL is - * returned. - * - * Note: The driver remains opened after this function returns. - */ -PUBLIC const char * -glXGetDriverConfig(const char *driverName) -{ - void *handle = driOpenDriver(driverName); - if (handle) - return dlsym(handle, "__driConfigOptions"); - else - return NULL; -} - -#ifdef XDAMAGE_1_1_INTERFACE - -static GLboolean -has_damage_post(Display * dpy) -{ - static GLboolean inited = GL_FALSE; - static GLboolean has_damage; - - if (!inited) { - int major, minor; - - if (XDamageQueryVersion(dpy, &major, &minor) && - major == 1 && minor >= 1) { - has_damage = GL_TRUE; - } - else { - has_damage = GL_FALSE; - } - inited = GL_TRUE; - } - - return has_damage; -} - -static void -__glXReportDamage(__DRIdrawable * driDraw, - int x, int y, - drm_clip_rect_t * rects, int num_rects, - GLboolean front_buffer, void *loaderPrivate) -{ - XRectangle *xrects; - XserverRegion region; - int i; - int x_off, y_off; - __GLXDRIdrawable *glxDraw = loaderPrivate; - __GLXscreenConfigs *psc = glxDraw->psc; - Display *dpy = psc->dpy; - Drawable drawable; - - if (!has_damage_post(dpy)) - return; - - if (front_buffer) { - x_off = x; - y_off = y; - drawable = RootWindow(dpy, psc->scr); - } - else { - x_off = 0; - y_off = 0; - drawable = glxDraw->xDrawable; - } - - xrects = malloc(sizeof(XRectangle) * num_rects); - if (xrects == NULL) - return; - - for (i = 0; i < num_rects; i++) { - xrects[i].x = rects[i].x1 + x_off; - xrects[i].y = rects[i].y1 + y_off; - xrects[i].width = rects[i].x2 - rects[i].x1; - xrects[i].height = rects[i].y2 - rects[i].y1; - } - region = XFixesCreateRegion(dpy, xrects, num_rects); - free(xrects); - XDamageAdd(dpy, drawable, region); - XFixesDestroyRegion(dpy, region); -} - -static const __DRIdamageExtension damageExtension = { - {__DRI_DAMAGE, __DRI_DAMAGE_VERSION}, - __glXReportDamage, -}; - -#endif - -static GLboolean -__glXDRIGetDrawableInfo(__DRIdrawable * drawable, - unsigned int *index, unsigned int *stamp, - int *X, int *Y, int *W, int *H, - int *numClipRects, drm_clip_rect_t ** pClipRects, - int *backX, int *backY, - int *numBackClipRects, - drm_clip_rect_t ** pBackClipRects, - void *loaderPrivate) -{ - __GLXDRIdrawable *glxDraw = loaderPrivate; - __GLXscreenConfigs *psc = glxDraw->psc; - Display *dpy = psc->dpy; - - return XF86DRIGetDrawableInfo(dpy, psc->scr, glxDraw->drawable, - index, stamp, X, Y, W, H, - numClipRects, pClipRects, - backX, backY, - numBackClipRects, pBackClipRects); -} - -static const __DRIgetDrawableInfoExtension getDrawableInfoExtension = { - {__DRI_GET_DRAWABLE_INFO, __DRI_GET_DRAWABLE_INFO_VERSION}, - __glXDRIGetDrawableInfo -}; - -static const __DRIextension *loader_extensions[] = { - &systemTimeExtension.base, - &getDrawableInfoExtension.base, -#ifdef XDAMAGE_1_1_INTERFACE - &damageExtension.base, -#endif - NULL -}; - -/** - * Perform the required libGL-side initialization and call the client-side - * driver's \c __driCreateNewScreen function. - * - * \param dpy Display pointer. - * \param scrn Screen number on the display. - * \param psc DRI screen information. - * \param driDpy DRI display information. - * \param createNewScreen Pointer to the client-side driver's - * \c __driCreateNewScreen function. - * \returns A pointer to the \c __DRIscreen structure returned by - * the client-side driver on success, or \c NULL on failure. - */ -static void * -CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc, - __GLXDRIdisplayPrivate * driDpy) -{ - void *psp = NULL; - drm_handle_t hSAREA; - drmAddress pSAREA = MAP_FAILED; - char *BusID; - __DRIversion ddx_version; - __DRIversion dri_version; - __DRIversion drm_version; - __DRIframebuffer framebuffer; - int fd = -1; - int status; - - drm_magic_t magic; - drmVersionPtr version; - int newlyopened; - char *driverName; - drm_handle_t hFB; - int junk; - const __DRIconfig **driver_configs; - __GLcontextModes *visual; - - /* DRI protocol version. */ - dri_version.major = driDpy->driMajor; - dri_version.minor = driDpy->driMinor; - dri_version.patch = driDpy->driPatch; - - framebuffer.base = MAP_FAILED; - framebuffer.dev_priv = NULL; - - if (!XF86DRIOpenConnection(dpy, scrn, &hSAREA, &BusID)) { - ErrorMessageF("XF86DRIOpenConnection failed\n"); - goto handle_error; - } - - fd = drmOpenOnce(NULL, BusID, &newlyopened); - - Xfree(BusID); /* No longer needed */ - - if (fd < 0) { - ErrorMessageF("drmOpenOnce failed (%s)\n", strerror(-fd)); - goto handle_error; - } - - if (drmGetMagic(fd, &magic)) { - ErrorMessageF("drmGetMagic failed\n"); - goto handle_error; - } - - version = drmGetVersion(fd); - if (version) { - drm_version.major = version->version_major; - drm_version.minor = version->version_minor; - drm_version.patch = version->version_patchlevel; - drmFreeVersion(version); - } - else { - drm_version.major = -1; - drm_version.minor = -1; - drm_version.patch = -1; - } - - if (newlyopened && !XF86DRIAuthConnection(dpy, scrn, magic)) { - ErrorMessageF("XF86DRIAuthConnection failed\n"); - goto handle_error; - } - - /* Get device name (like "tdfx") and the ddx version numbers. - * We'll check the version in each DRI driver's "createNewScreen" - * function. */ - if (!XF86DRIGetClientDriverName(dpy, scrn, - &ddx_version.major, - &ddx_version.minor, - &ddx_version.patch, &driverName)) { - ErrorMessageF("XF86DRIGetClientDriverName failed\n"); - goto handle_error; - } - - Xfree(driverName); /* No longer needed. */ - - /* - * Get device-specific info. pDevPriv will point to a struct - * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) that - * has information about the screen size, depth, pitch, ancilliary - * buffers, DRM mmap handles, etc. - */ - if (!XF86DRIGetDeviceInfo(dpy, scrn, &hFB, &junk, - &framebuffer.size, &framebuffer.stride, - &framebuffer.dev_priv_size, - &framebuffer.dev_priv)) { - ErrorMessageF("XF86DRIGetDeviceInfo failed"); - goto handle_error; - } - - framebuffer.width = DisplayWidth(dpy, scrn); - framebuffer.height = DisplayHeight(dpy, scrn); - - /* Map the framebuffer region. */ - status = drmMap(fd, hFB, framebuffer.size, - (drmAddressPtr) & framebuffer.base); - if (status != 0) { - ErrorMessageF("drmMap of framebuffer failed (%s)", strerror(-status)); - goto handle_error; - } - - /* Map the SAREA region. Further mmap regions may be setup in - * each DRI driver's "createNewScreen" function. - */ - status = drmMap(fd, hSAREA, SAREA_MAX, &pSAREA); - if (status != 0) { - ErrorMessageF("drmMap of SAREA failed (%s)", strerror(-status)); - goto handle_error; - } - - psp = (*psc->legacy->createNewScreen) (scrn, - &ddx_version, - &dri_version, - &drm_version, - &framebuffer, - pSAREA, - fd, - loader_extensions, - &driver_configs, psc); - - if (psp == NULL) { - ErrorMessageF("Calling driver entry point failed"); - goto handle_error; - } - - psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs); - psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs); - - psc->driver_configs = driver_configs; - - /* Visuals with depth != screen depth are subject to automatic compositing - * in the X server, so DRI1 can't render to them properly. Mark them as - * non-conformant to prevent apps from picking them up accidentally. - */ - for (visual = psc->visuals; visual; visual = visual->next) { - XVisualInfo template; - XVisualInfo *visuals; - int num_visuals; - long mask; - - template.visualid = visual->visualID; - mask = VisualIDMask; - visuals = XGetVisualInfo(dpy, mask, &template, &num_visuals); - - if (visuals) { - if (num_visuals > 0 && visuals->depth != DefaultDepth(dpy, scrn)) - visual->visualRating = GLX_NON_CONFORMANT_CONFIG; - - XFree(visuals); - } - } - - return psp; - - handle_error: - if (pSAREA != MAP_FAILED) - drmUnmap(pSAREA, SAREA_MAX); - - if (framebuffer.base != MAP_FAILED) - drmUnmap((drmAddress) framebuffer.base, framebuffer.size); - - if (framebuffer.dev_priv != NULL) - Xfree(framebuffer.dev_priv); - - if (fd >= 0) - drmCloseOnce(fd); - - XF86DRICloseConnection(dpy, scrn); - - ErrorMessageF("reverting to software direct rendering\n"); - - return NULL; -} - -static void -driDestroyContext(__GLXDRIcontext * context, - __GLXscreenConfigs * psc, Display * dpy) -{ - __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; - - (*psc->core->destroyContext) (pcp->driContext); - - XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID); - Xfree(pcp); -} - -static Bool -driBindContext(__GLXDRIcontext * context, - __GLXDRIdrawable * draw, __GLXDRIdrawable * read) -{ - __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; - const __DRIcoreExtension *core = pcp->psc->core; - - return (*core->bindContext) (pcp->driContext, - draw->driDrawable, read->driDrawable); -} - -static void -driUnbindContext(__GLXDRIcontext * context) -{ - __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; - const __DRIcoreExtension *core = pcp->psc->core; - - (*core->unbindContext) (pcp->driContext); -} - -static __GLXDRIcontext * -driCreateContext(__GLXscreenConfigs * psc, - const __GLcontextModes * mode, - GLXContext gc, GLXContext shareList, int renderType) -{ - __GLXDRIcontextPrivate *pcp, *pcp_shared; - drm_context_t hwContext; - __DRIcontext *shared = NULL; - __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode; - - if (!psc || !psc->driScreen) - return NULL; - - if (shareList) { - pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext; - shared = pcp_shared->driContext; - } - - pcp = Xmalloc(sizeof *pcp); - if (pcp == NULL) - return NULL; - - pcp->psc = psc; - if (!XF86DRICreateContextWithConfig(psc->dpy, psc->scr, - mode->visualID, - &pcp->hwContextID, &hwContext)) { - Xfree(pcp); - return NULL; - } - - pcp->driContext = - (*psc->legacy->createNewContext) (psc->__driScreen, - config->driConfig, - renderType, shared, hwContext, pcp); - if (pcp->driContext == NULL) { - XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID); - Xfree(pcp); - return NULL; - } - - pcp->base.destroyContext = driDestroyContext; - pcp->base.bindContext = driBindContext; - pcp->base.unbindContext = driUnbindContext; - - return &pcp->base; -} - -static void -driDestroyDrawable(__GLXDRIdrawable * pdraw) -{ - __GLXscreenConfigs *psc = pdraw->psc; - - (*psc->core->destroyDrawable) (pdraw->driDrawable); - XF86DRIDestroyDrawable(psc->dpy, psc->scr, pdraw->drawable); - Xfree(pdraw); -} - -static __GLXDRIdrawable * -driCreateDrawable(__GLXscreenConfigs * psc, - XID xDrawable, - GLXDrawable drawable, const __GLcontextModes * modes) -{ - __GLXDRIdrawable *pdraw; - drm_drawable_t hwDrawable; - void *empty_attribute_list = NULL; - __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; - - /* Old dri can't handle GLX 1.3+ drawable constructors. */ - if (xDrawable != drawable) - return NULL; - - pdraw = Xmalloc(sizeof(*pdraw)); - if (!pdraw) - return NULL; - - pdraw->drawable = drawable; - pdraw->psc = psc; - - if (!XF86DRICreateDrawable(psc->dpy, psc->scr, drawable, &hwDrawable)) { - Xfree(pdraw); - return NULL; - } - - /* Create a new drawable */ - pdraw->driDrawable = - (*psc->legacy->createNewDrawable) (psc->__driScreen, - config->driConfig, - hwDrawable, - GLX_WINDOW_BIT, - empty_attribute_list, pdraw); - - if (!pdraw->driDrawable) { - XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable); - Xfree(pdraw); - return NULL; - } - - pdraw->destroyDrawable = driDestroyDrawable; - - return pdraw; -} - -static int64_t -driSwapBuffers(__GLXDRIdrawable * pdraw, int64_t unused1, int64_t unused2, - int64_t unused3) -{ - (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable); - return 0; -} - -static void -driCopySubBuffer(__GLXDRIdrawable * pdraw, - int x, int y, int width, int height) -{ - (*pdraw->psc->driCopySubBuffer->copySubBuffer) (pdraw->driDrawable, - x, y, width, height); -} - -static void -driDestroyScreen(__GLXscreenConfigs * psc) -{ - /* Free the direct rendering per screen data */ - if (psc->__driScreen) - (*psc->core->destroyScreen) (psc->__driScreen); - psc->__driScreen = NULL; - if (psc->driver) - dlclose(psc->driver); -} - -static __GLXDRIscreen * -driCreateScreen(__GLXscreenConfigs * psc, int screen, - __GLXdisplayPrivate * priv) -{ - __GLXDRIdisplayPrivate *pdp; - __GLXDRIscreen *psp; - const __DRIextension **extensions; - char *driverName; - int i; - - psp = Xcalloc(1, sizeof *psp); - if (psp == NULL) - return NULL; - - /* Initialize per screen dynamic client GLX extensions */ - psc->ext_list_first_time = GL_TRUE; - - if (!driGetDriverName(priv->dpy, screen, &driverName)) { - Xfree(psp); - return NULL; - } - - psc->driver = driOpenDriver(driverName); - Xfree(driverName); - if (psc->driver == NULL) { - Xfree(psp); - return NULL; - } - - extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS); - if (extensions == NULL) { - ErrorMessageF("driver exports no extensions (%s)\n", dlerror()); - Xfree(psp); - return NULL; - } - - for (i = 0; extensions[i]; i++) { - if (strcmp(extensions[i]->name, __DRI_CORE) == 0) - psc->core = (__DRIcoreExtension *) extensions[i]; - if (strcmp(extensions[i]->name, __DRI_LEGACY) == 0) - psc->legacy = (__DRIlegacyExtension *) extensions[i]; - } - - if (psc->core == NULL || psc->legacy == NULL) { - Xfree(psp); - return NULL; - } - - pdp = (__GLXDRIdisplayPrivate *) priv->driDisplay; - psc->__driScreen = CallCreateNewScreen(psc->dpy, screen, psc, pdp); - if (psc->__driScreen == NULL) { - dlclose(psc->driver); - Xfree(psp); - return NULL; - } - - driBindExtensions(psc); - driBindCommonExtensions(psc); - - if (psc->driCopySubBuffer) - psp->copySubBuffer = driCopySubBuffer; - - psp->destroyScreen = driDestroyScreen; - psp->createContext = driCreateContext; - psp->createDrawable = driCreateDrawable; - psp->swapBuffers = driSwapBuffers; - psp->waitX = NULL; - psp->waitGL = NULL; - - return psp; -} - -/* Called from __glXFreeDisplayPrivate. - */ -static void -driDestroyDisplay(__GLXDRIdisplay * dpy) -{ - Xfree(dpy); -} - -/* - * Allocate, initialize and return a __DRIdisplayPrivate object. - * This is called from __glXInitialize() when we are given a new - * display pointer. - */ -_X_HIDDEN __GLXDRIdisplay * -driCreateDisplay(Display * dpy) -{ - __GLXDRIdisplayPrivate *pdpyp; - int eventBase, errorBase; - int major, minor, patch; - - if (!XF86DRIQueryExtension(dpy, &eventBase, &errorBase)) { - return NULL; - } - - if (!XF86DRIQueryVersion(dpy, &major, &minor, &patch)) { - return NULL; - } - - pdpyp = Xmalloc(sizeof *pdpyp); - if (!pdpyp) { - return NULL; - } - - pdpyp->driMajor = major; - pdpyp->driMinor = minor; - pdpyp->driPatch = patch; - - pdpyp->base.destroyDisplay = driDestroyDisplay; - pdpyp->base.createScreen = driCreateScreen; - - return &pdpyp->base; -} - -#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/x11/drisw_glx.c b/src/glx/x11/drisw_glx.c deleted file mode 100644 index eed9a8c4723..00000000000 --- a/src/glx/x11/drisw_glx.c +++ /dev/null @@ -1,456 +0,0 @@ -/* - * Copyright 2008 George Sapountzis - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifdef GLX_DIRECT_RENDERING - -#include -#include "glxclient.h" -#include -#include "dri_common.h" - -typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate; -typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate; -typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate; - -struct __GLXDRIdisplayPrivateRec -{ - __GLXDRIdisplay base; -}; - -struct __GLXDRIcontextPrivateRec -{ - __GLXDRIcontext base; - __DRIcontext *driContext; - __GLXscreenConfigs *psc; -}; - -struct __GLXDRIdrawablePrivateRec -{ - __GLXDRIdrawable base; - - GC gc; - GC swapgc; - - XVisualInfo *visinfo; - XImage *ximage; - int bpp; -}; - -/** - * swrast loader functions - */ - -static Bool -XCreateDrawable(__GLXDRIdrawablePrivate * pdp, - Display * dpy, XID drawable, int visualid) -{ - XGCValues gcvalues; - long visMask; - XVisualInfo visTemp; - int num_visuals; - - /* create GC's */ - pdp->gc = XCreateGC(dpy, drawable, 0, NULL); - pdp->swapgc = XCreateGC(dpy, drawable, 0, NULL); - - gcvalues.function = GXcopy; - gcvalues.graphics_exposures = False; - XChangeGC(dpy, pdp->gc, GCFunction, &gcvalues); - XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues); - XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues); - - /* create XImage */ - visTemp.screen = DefaultScreen(dpy); - visTemp.visualid = visualid; - visMask = (VisualScreenMask | VisualIDMask); - pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals); - - pdp->ximage = XCreateImage(dpy, pdp->visinfo->visual, pdp->visinfo->depth, ZPixmap, 0, /* format, offset */ - NULL, /* data */ - 0, 0, /* size */ - 32, /* bitmap_pad */ - 0); /* bytes_per_line */ - - /* get the true number of bits per pixel */ - pdp->bpp = pdp->ximage->bits_per_pixel; - - return True; -} - -static void -XDestroyDrawable(__GLXDRIdrawablePrivate * pdp, Display * dpy, XID drawable) -{ - XDestroyImage(pdp->ximage); - XFree(pdp->visinfo); - - XFreeGC(dpy, pdp->gc); - XFreeGC(dpy, pdp->swapgc); -} - -static void -swrastGetDrawableInfo(__DRIdrawable * draw, - int *x, int *y, int *w, int *h, void *loaderPrivate) -{ - __GLXDRIdrawablePrivate *pdp = loaderPrivate; - __GLXDRIdrawable *pdraw = &(pdp->base); - Display *dpy = pdraw->psc->dpy; - Drawable drawable; - - Window root; - Status stat; - unsigned int bw, depth; - - drawable = pdraw->xDrawable; - - stat = XGetGeometry(dpy, drawable, &root, - x, y, (unsigned int *) w, (unsigned int *) h, - &bw, &depth); -} - -static inline int -bytes_per_line(int w, int bpp, unsigned mul) -{ - unsigned mask = mul - 1; - - return ((w * bpp + mask) & ~mask) / 8; -} - -static void -swrastPutImage(__DRIdrawable * draw, int op, - int x, int y, int w, int h, char *data, void *loaderPrivate) -{ - __GLXDRIdrawablePrivate *pdp = loaderPrivate; - __GLXDRIdrawable *pdraw = &(pdp->base); - Display *dpy = pdraw->psc->dpy; - Drawable drawable; - XImage *ximage; - GC gc; - - switch (op) { - case __DRI_SWRAST_IMAGE_OP_DRAW: - gc = pdp->gc; - break; - case __DRI_SWRAST_IMAGE_OP_SWAP: - gc = pdp->swapgc; - break; - default: - return; - } - - drawable = pdraw->xDrawable; - - ximage = pdp->ximage; - ximage->data = data; - ximage->width = w; - ximage->height = h; - ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32); - - XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h); - - ximage->data = NULL; -} - -static void -swrastGetImage(__DRIdrawable * draw, - int x, int y, int w, int h, char *data, void *loaderPrivate) -{ - __GLXDRIdrawablePrivate *pdp = loaderPrivate; - __GLXDRIdrawable *pdraw = &(pdp->base); - Display *dpy = pdraw->psc->dpy; - Drawable drawable; - XImage *ximage; - - drawable = pdraw->xDrawable; - - ximage = pdp->ximage; - ximage->data = data; - ximage->width = w; - ximage->height = h; - ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32); - - XGetSubImage(dpy, drawable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0); - - ximage->data = NULL; -} - -static const __DRIswrastLoaderExtension swrastLoaderExtension = { - {__DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION}, - swrastGetDrawableInfo, - swrastPutImage, - swrastGetImage -}; - -static const __DRIextension *loader_extensions[] = { - &systemTimeExtension.base, - &swrastLoaderExtension.base, - NULL -}; - -/** - * GLXDRI functions - */ - -static void -driDestroyContext(__GLXDRIcontext * context, - __GLXscreenConfigs * psc, Display * dpy) -{ - __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; - const __DRIcoreExtension *core = pcp->psc->core; - - (*core->destroyContext) (pcp->driContext); - - Xfree(pcp); -} - -static Bool -driBindContext(__GLXDRIcontext * context, - __GLXDRIdrawable * draw, __GLXDRIdrawable * read) -{ - __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; - const __DRIcoreExtension *core = pcp->psc->core; - - return (*core->bindContext) (pcp->driContext, - draw->driDrawable, read->driDrawable); -} - -static void -driUnbindContext(__GLXDRIcontext * context) -{ - __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; - const __DRIcoreExtension *core = pcp->psc->core; - - (*core->unbindContext) (pcp->driContext); -} - -static __GLXDRIcontext * -driCreateContext(__GLXscreenConfigs * psc, - const __GLcontextModes * mode, - GLXContext gc, GLXContext shareList, int renderType) -{ - __GLXDRIcontextPrivate *pcp, *pcp_shared; - __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode; - const __DRIcoreExtension *core; - __DRIcontext *shared = NULL; - - if (!psc || !psc->driScreen) - return NULL; - - core = psc->core; - - if (shareList) { - pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext; - shared = pcp_shared->driContext; - } - - pcp = Xmalloc(sizeof *pcp); - if (pcp == NULL) - return NULL; - - pcp->psc = psc; - pcp->driContext = - (*core->createNewContext) (psc->__driScreen, - config->driConfig, shared, pcp); - if (pcp->driContext == NULL) { - Xfree(pcp); - return NULL; - } - - pcp->base.destroyContext = driDestroyContext; - pcp->base.bindContext = driBindContext; - pcp->base.unbindContext = driUnbindContext; - - return &pcp->base; -} - -static void -driDestroyDrawable(__GLXDRIdrawable * pdraw) -{ - __GLXDRIdrawablePrivate *pdp = (__GLXDRIdrawablePrivate *) pdraw; - const __DRIcoreExtension *core = pdraw->psc->core; - - (*core->destroyDrawable) (pdraw->driDrawable); - - XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable); - Xfree(pdp); -} - -static __GLXDRIdrawable * -driCreateDrawable(__GLXscreenConfigs * psc, - XID xDrawable, - GLXDrawable drawable, const __GLcontextModes * modes) -{ - __GLXDRIdrawable *pdraw; - __GLXDRIdrawablePrivate *pdp; - __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; - const __DRIswrastExtension *swrast = psc->swrast; - - /* Old dri can't handle GLX 1.3+ drawable constructors. */ - if (xDrawable != drawable) - return NULL; - - pdp = Xmalloc(sizeof(*pdp)); - if (!pdp) - return NULL; - - pdraw = &(pdp->base); - pdraw->xDrawable = xDrawable; - pdraw->drawable = drawable; - pdraw->psc = psc; - - XCreateDrawable(pdp, psc->dpy, xDrawable, modes->visualID); - - /* Create a new drawable */ - pdraw->driDrawable = - (*swrast->createNewDrawable) (psc->__driScreen, config->driConfig, pdp); - - if (!pdraw->driDrawable) { - XDestroyDrawable(pdp, psc->dpy, xDrawable); - Xfree(pdp); - return NULL; - } - - pdraw->destroyDrawable = driDestroyDrawable; - - return pdraw; -} - -static void -driSwapBuffers(__GLXDRIdrawable * pdraw) -{ - (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable); -} - -static void -driDestroyScreen(__GLXscreenConfigs * psc) -{ - /* Free the direct rendering per screen data */ - (*psc->core->destroyScreen) (psc->__driScreen); - psc->__driScreen = NULL; - if (psc->driver) - dlclose(psc->driver); -} - -static __GLXDRIscreen * -driCreateScreen(__GLXscreenConfigs * psc, int screen, - __GLXdisplayPrivate * priv) -{ - __GLXDRIscreen *psp; - const __DRIconfig **driver_configs; - const __DRIextension **extensions; - const char *driverName = "swrast"; - int i; - - psp = Xcalloc(1, sizeof *psp); - if (psp == NULL) - return NULL; - - /* Initialize per screen dynamic client GLX extensions */ - psc->ext_list_first_time = GL_TRUE; - - psc->driver = driOpenDriver(driverName); - if (psc->driver == NULL) - goto handle_error; - - extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS); - if (extensions == NULL) { - ErrorMessageF("driver exports no extensions (%s)\n", dlerror()); - goto handle_error; - } - - for (i = 0; extensions[i]; i++) { - if (strcmp(extensions[i]->name, __DRI_CORE) == 0) - psc->core = (__DRIcoreExtension *) extensions[i]; - if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0) - psc->swrast = (__DRIswrastExtension *) extensions[i]; - } - - if (psc->core == NULL || psc->swrast == NULL) { - ErrorMessageF("core dri extension not found\n"); - goto handle_error; - } - - psc->__driScreen = - psc->swrast->createNewScreen(screen, - loader_extensions, &driver_configs, psc); - if (psc->__driScreen == NULL) { - ErrorMessageF("failed to create dri screen\n"); - goto handle_error; - } - - driBindExtensions(psc); - driBindCommonExtensions(psc); - - psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs); - psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs); - - psc->driver_configs = driver_configs; - - psp->destroyScreen = driDestroyScreen; - psp->createContext = driCreateContext; - psp->createDrawable = driCreateDrawable; - psp->swapBuffers = driSwapBuffers; - psp->waitX = NULL; - psp->waitGL = NULL; - - return psp; - - handle_error: - Xfree(psp); - - if (psc->driver) - dlclose(psc->driver); - - ErrorMessageF("reverting to indirect rendering\n"); - - return NULL; -} - -/* Called from __glXFreeDisplayPrivate. - */ -static void -driDestroyDisplay(__GLXDRIdisplay * dpy) -{ - Xfree(dpy); -} - -/* - * Allocate, initialize and return a __DRIdisplayPrivate object. - * This is called from __glXInitialize() when we are given a new - * display pointer. - */ -_X_HIDDEN __GLXDRIdisplay * -driswCreateDisplay(Display * dpy) -{ - __GLXDRIdisplayPrivate *pdpyp; - - pdpyp = Xmalloc(sizeof *pdpyp); - if (pdpyp == NULL) - return NULL; - - pdpyp->base.destroyDisplay = driDestroyDisplay; - pdpyp->base.createScreen = driCreateScreen; - - return &pdpyp->base; -} - -#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/x11/eval.c b/src/glx/x11/eval.c deleted file mode 100644 index 226fb7df2e8..00000000000 --- a/src/glx/x11/eval.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include "packrender.h" - -/* -** Routines to pack evaluator maps into the transport buffer. Maps are -** allowed to have extra arbitrary data, so these routines extract just -** the information that the GL needs. -*/ - -void -__glFillMap1f(GLint k, GLint order, GLint stride, - const GLfloat * points, GLubyte * pc) -{ - if (stride == k) { - /* Just copy the data */ - __GLX_PUT_FLOAT_ARRAY(0, points, order * k); - } - else { - GLint i; - - for (i = 0; i < order; i++) { - __GLX_PUT_FLOAT_ARRAY(0, points, k); - points += stride; - pc += k * __GLX_SIZE_FLOAT32; - } - } -} - -void -__glFillMap1d(GLint k, GLint order, GLint stride, - const GLdouble * points, GLubyte * pc) -{ - if (stride == k) { - /* Just copy the data */ - __GLX_PUT_DOUBLE_ARRAY(0, points, order * k); - } - else { - GLint i; - for (i = 0; i < order; i++) { - __GLX_PUT_DOUBLE_ARRAY(0, points, k); - points += stride; - pc += k * __GLX_SIZE_FLOAT64; - } - } -} - -void -__glFillMap2f(GLint k, GLint majorOrder, GLint minorOrder, - GLint majorStride, GLint minorStride, - const GLfloat * points, GLfloat * data) -{ - GLint i, j, x; - - if ((minorStride == k) && (majorStride == minorOrder * k)) { - /* Just copy the data */ - __GLX_MEM_COPY(data, points, majorOrder * majorStride * - __GLX_SIZE_FLOAT32); - return; - } - for (i = 0; i < majorOrder; i++) { - for (j = 0; j < minorOrder; j++) { - for (x = 0; x < k; x++) { - data[x] = points[x]; - } - points += minorStride; - data += k; - } - points += majorStride - minorStride * minorOrder; - } -} - -void -__glFillMap2d(GLint k, GLint majorOrder, GLint minorOrder, - GLint majorStride, GLint minorStride, - const GLdouble * points, GLdouble * data) -{ - int i, j, x; - - if ((minorStride == k) && (majorStride == minorOrder * k)) { - /* Just copy the data */ - __GLX_MEM_COPY(data, points, majorOrder * majorStride * - __GLX_SIZE_FLOAT64); - return; - } - -#ifdef __GLX_ALIGN64 - x = k * __GLX_SIZE_FLOAT64; -#endif - for (i = 0; i < majorOrder; i++) { - for (j = 0; j < minorOrder; j++) { -#ifdef __GLX_ALIGN64 - __GLX_MEM_COPY(data, points, x); -#else - for (x = 0; x < k; x++) { - data[x] = points[x]; - } -#endif - points += minorStride; - data += k; - } - points += majorStride - minorStride * minorOrder; - } -} diff --git a/src/glx/x11/glcontextmodes.c b/src/glx/x11/glcontextmodes.c deleted file mode 100644 index 232031c2ca8..00000000000 --- a/src/glx/x11/glcontextmodes.c +++ /dev/null @@ -1,544 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2003 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file glcontextmodes.c - * Utility routines for working with \c __GLcontextModes structures. At - * some point most or all of these functions will be moved to the Mesa - * code base. - * - * \author Ian Romanick - */ - -#if defined(IN_MINI_GLX) -#include -#else -#if defined(HAVE_DIX_CONFIG_H) -# include -#endif -#include -#include -#include "GL/glxint.h" -#endif - -/* Memory macros */ -#if defined(IN_MINI_GLX) -# include -# include -# define _mesa_malloc(b) malloc(b) -# define _mesa_free(m) free(m) -# define _mesa_memset memset -#else -# ifdef XFree86Server -# include -# include -# define _mesa_malloc(b) xalloc(b) -# define _mesa_free(m) xfree(m) -# define _mesa_memset memset -# else -# include -# define _mesa_memset memset -# define _mesa_malloc(b) Xmalloc(b) -# define _mesa_free(m) Xfree(m) -# endif /* XFree86Server */ -#endif /* !defined(IN_MINI_GLX) */ - -#include "glcontextmodes.h" - -#if !defined(IN_MINI_GLX) -#define NUM_VISUAL_TYPES 6 - -/** - * Convert an X visual type to a GLX visual type. - * - * \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.) - * to be converted. - * \return If \c visualType is a valid X visual type, a GLX visual type will - * be returned. Otherwise \c GLX_NONE will be returned. - */ -GLint -_gl_convert_from_x_visual_type(int visualType) -{ - static const int glx_visual_types[NUM_VISUAL_TYPES] = { - GLX_STATIC_GRAY, GLX_GRAY_SCALE, - GLX_STATIC_COLOR, GLX_PSEUDO_COLOR, - GLX_TRUE_COLOR, GLX_DIRECT_COLOR - }; - - return ((unsigned) visualType < NUM_VISUAL_TYPES) - ? glx_visual_types[visualType] : GLX_NONE; -} - - -/** - * Convert a GLX visual type to an X visual type. - * - * \param visualType GLX visual type (i.e., \c GLX_TRUE_COLOR, - * \c GLX_STATIC_GRAY, etc.) to be converted. - * \return If \c visualType is a valid GLX visual type, an X visual type will - * be returned. Otherwise -1 will be returned. - */ -GLint -_gl_convert_to_x_visual_type(int visualType) -{ - static const int x_visual_types[NUM_VISUAL_TYPES] = { - TrueColor, DirectColor, - PseudoColor, StaticColor, - GrayScale, StaticGray - }; - - return ((unsigned) (visualType - GLX_TRUE_COLOR) < NUM_VISUAL_TYPES) - ? x_visual_types[visualType - GLX_TRUE_COLOR] : -1; -} - - -/** - * Copy a GLX visual config structure to a GL context mode structure. All - * of the fields in \c config are copied to \c mode. Additional fields in - * \c mode that can be derrived from the fields of \c config (i.e., - * \c haveDepthBuffer) are also filled in. The remaining fields in \c mode - * that cannot be derived are set to default values. - * - * \param mode Destination GL context mode. - * \param config Source GLX visual config. - * - * \note - * The \c fbconfigID and \c visualID fields of the \c __GLcontextModes - * structure will be set to the \c vid of the \c __GLXvisualConfig structure. - */ -void -_gl_copy_visual_to_context_mode(__GLcontextModes * mode, - const __GLXvisualConfig * config) -{ - __GLcontextModes *const next = mode->next; - - (void) _mesa_memset(mode, 0, sizeof(__GLcontextModes)); - mode->next = next; - - mode->visualID = config->vid; - mode->visualType = _gl_convert_from_x_visual_type(config->class); - mode->xRenderable = GL_TRUE; - mode->fbconfigID = config->vid; - mode->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT; - - mode->rgbMode = (config->rgba != 0); - mode->renderType = (mode->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; - - mode->colorIndexMode = !(mode->rgbMode); - mode->doubleBufferMode = (config->doubleBuffer != 0); - mode->stereoMode = (config->stereo != 0); - - mode->haveAccumBuffer = ((config->accumRedSize + - config->accumGreenSize + - config->accumBlueSize + - config->accumAlphaSize) > 0); - mode->haveDepthBuffer = (config->depthSize > 0); - mode->haveStencilBuffer = (config->stencilSize > 0); - - mode->redBits = config->redSize; - mode->greenBits = config->greenSize; - mode->blueBits = config->blueSize; - mode->alphaBits = config->alphaSize; - mode->redMask = config->redMask; - mode->greenMask = config->greenMask; - mode->blueMask = config->blueMask; - mode->alphaMask = config->alphaMask; - mode->rgbBits = mode->rgbMode ? config->bufferSize : 0; - mode->indexBits = mode->colorIndexMode ? config->bufferSize : 0; - - mode->accumRedBits = config->accumRedSize; - mode->accumGreenBits = config->accumGreenSize; - mode->accumBlueBits = config->accumBlueSize; - mode->accumAlphaBits = config->accumAlphaSize; - mode->depthBits = config->depthSize; - mode->stencilBits = config->stencilSize; - - mode->numAuxBuffers = config->auxBuffers; - mode->level = config->level; - - mode->visualRating = config->visualRating; - mode->transparentPixel = config->transparentPixel; - mode->transparentRed = config->transparentRed; - mode->transparentGreen = config->transparentGreen; - mode->transparentBlue = config->transparentBlue; - mode->transparentAlpha = config->transparentAlpha; - mode->transparentIndex = config->transparentIndex; - mode->samples = config->multiSampleSize; - mode->sampleBuffers = config->nMultiSampleBuffers; - /* mode->visualSelectGroup = config->visualSelectGroup; ? */ - - mode->swapMethod = GLX_SWAP_UNDEFINED_OML; - - mode->bindToTextureRgb = (mode->rgbMode) ? GL_TRUE : GL_FALSE; - mode->bindToTextureRgba = (mode->rgbMode && mode->alphaBits) ? - GL_TRUE : GL_FALSE; - mode->bindToMipmapTexture = mode->rgbMode ? GL_TRUE : GL_FALSE; - mode->bindToTextureTargets = mode->rgbMode ? - GLX_TEXTURE_1D_BIT_EXT | GLX_TEXTURE_2D_BIT_EXT | - GLX_TEXTURE_RECTANGLE_BIT_EXT : 0; - mode->yInverted = GL_FALSE; -} - - -/** - * Get data from a GL context mode. - * - * \param mode GL context mode whose data is to be returned. - * \param attribute Attribute of \c mode that is to be returned. - * \param value_return Location to store the data member of \c mode. - * \return If \c attribute is a valid attribute of \c mode, zero is - * returned. Otherwise \c GLX_BAD_ATTRIBUTE is returned. - */ -int -_gl_get_context_mode_data(const __GLcontextModes * mode, int attribute, - int *value_return) -{ - switch (attribute) { - case GLX_USE_GL: - *value_return = GL_TRUE; - return 0; - case GLX_BUFFER_SIZE: - *value_return = mode->rgbBits; - return 0; - case GLX_RGBA: - *value_return = mode->rgbMode; - return 0; - case GLX_RED_SIZE: - *value_return = mode->redBits; - return 0; - case GLX_GREEN_SIZE: - *value_return = mode->greenBits; - return 0; - case GLX_BLUE_SIZE: - *value_return = mode->blueBits; - return 0; - case GLX_ALPHA_SIZE: - *value_return = mode->alphaBits; - return 0; - case GLX_DOUBLEBUFFER: - *value_return = mode->doubleBufferMode; - return 0; - case GLX_STEREO: - *value_return = mode->stereoMode; - return 0; - case GLX_AUX_BUFFERS: - *value_return = mode->numAuxBuffers; - return 0; - case GLX_DEPTH_SIZE: - *value_return = mode->depthBits; - return 0; - case GLX_STENCIL_SIZE: - *value_return = mode->stencilBits; - return 0; - case GLX_ACCUM_RED_SIZE: - *value_return = mode->accumRedBits; - return 0; - case GLX_ACCUM_GREEN_SIZE: - *value_return = mode->accumGreenBits; - return 0; - case GLX_ACCUM_BLUE_SIZE: - *value_return = mode->accumBlueBits; - return 0; - case GLX_ACCUM_ALPHA_SIZE: - *value_return = mode->accumAlphaBits; - return 0; - case GLX_LEVEL: - *value_return = mode->level; - return 0; - case GLX_TRANSPARENT_TYPE_EXT: - *value_return = mode->transparentPixel; - return 0; - case GLX_TRANSPARENT_RED_VALUE: - *value_return = mode->transparentRed; - return 0; - case GLX_TRANSPARENT_GREEN_VALUE: - *value_return = mode->transparentGreen; - return 0; - case GLX_TRANSPARENT_BLUE_VALUE: - *value_return = mode->transparentBlue; - return 0; - case GLX_TRANSPARENT_ALPHA_VALUE: - *value_return = mode->transparentAlpha; - return 0; - case GLX_TRANSPARENT_INDEX_VALUE: - *value_return = mode->transparentIndex; - return 0; - case GLX_X_VISUAL_TYPE: - *value_return = mode->visualType; - return 0; - case GLX_CONFIG_CAVEAT: - *value_return = mode->visualRating; - return 0; - case GLX_VISUAL_ID: - *value_return = mode->visualID; - return 0; - case GLX_DRAWABLE_TYPE: - *value_return = mode->drawableType; - return 0; - case GLX_RENDER_TYPE: - *value_return = mode->renderType; - return 0; - case GLX_X_RENDERABLE: - *value_return = mode->xRenderable; - return 0; - case GLX_FBCONFIG_ID: - *value_return = mode->fbconfigID; - return 0; - case GLX_MAX_PBUFFER_WIDTH: - *value_return = mode->maxPbufferWidth; - return 0; - case GLX_MAX_PBUFFER_HEIGHT: - *value_return = mode->maxPbufferHeight; - return 0; - case GLX_MAX_PBUFFER_PIXELS: - *value_return = mode->maxPbufferPixels; - return 0; - case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX: - *value_return = mode->optimalPbufferWidth; - return 0; - case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX: - *value_return = mode->optimalPbufferHeight; - return 0; - case GLX_SWAP_METHOD_OML: - *value_return = mode->swapMethod; - return 0; - case GLX_SAMPLE_BUFFERS_SGIS: - *value_return = mode->sampleBuffers; - return 0; - case GLX_SAMPLES_SGIS: - *value_return = mode->samples; - return 0; - case GLX_BIND_TO_TEXTURE_RGB_EXT: - *value_return = mode->bindToTextureRgb; - return 0; - case GLX_BIND_TO_TEXTURE_RGBA_EXT: - *value_return = mode->bindToTextureRgba; - return 0; - case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: - *value_return = mode->bindToMipmapTexture == GL_TRUE ? GL_TRUE : - GL_FALSE; - return 0; - case GLX_BIND_TO_TEXTURE_TARGETS_EXT: - *value_return = mode->bindToTextureTargets; - return 0; - case GLX_Y_INVERTED_EXT: - *value_return = mode->yInverted; - return 0; - - /* Applications are NOT allowed to query GLX_VISUAL_SELECT_GROUP_SGIX. - * It is ONLY for communication between the GLX client and the GLX - * server. - */ - case GLX_VISUAL_SELECT_GROUP_SGIX: - default: - return GLX_BAD_ATTRIBUTE; - } -} -#endif /* !defined(IN_MINI_GLX) */ - - -/** - * Allocate a linked list of \c __GLcontextModes structures. The fields of - * each structure will be initialized to "reasonable" default values. In - * most cases this is the default value defined by table 3.4 of the GLX - * 1.3 specification. This means that most values are either initialized to - * zero or \c GLX_DONT_CARE (which is -1). As support for additional - * extensions is added, the new values will be initialized to appropriate - * values from the extension specification. - * - * \param count Number of structures to allocate. - * \param minimum_size Minimum size of a structure to allocate. This allows - * for differences in the version of the - * \c __GLcontextModes stucture used in libGL and in a - * DRI-based driver. - * \returns A pointer to the first element in a linked list of \c count - * stuctures on success, or \c NULL on failure. - * - * \warning Use of \c minimum_size does \b not guarantee binary compatibility. - * The fundamental assumption is that if the \c minimum_size - * specified by the driver and the size of the \c __GLcontextModes - * structure in libGL is the same, then the meaning of each byte in - * the structure is the same in both places. \b Be \b careful! - * Basically this means that fields have to be added in libGL and - * then propagated to drivers. Drivers should \b never arbitrarilly - * extend the \c __GLcontextModes data-structure. - */ -__GLcontextModes * -_gl_context_modes_create(unsigned count, size_t minimum_size) -{ - const size_t size = (minimum_size > sizeof(__GLcontextModes)) - ? minimum_size : sizeof(__GLcontextModes); - __GLcontextModes *base = NULL; - __GLcontextModes **next; - unsigned i; - - next = &base; - for (i = 0; i < count; i++) { - *next = (__GLcontextModes *) _mesa_malloc(size); - if (*next == NULL) { - _gl_context_modes_destroy(base); - base = NULL; - break; - } - - (void) _mesa_memset(*next, 0, size); - (*next)->visualID = GLX_DONT_CARE; - (*next)->visualType = GLX_DONT_CARE; - (*next)->visualRating = GLX_NONE; - (*next)->transparentPixel = GLX_NONE; - (*next)->transparentRed = GLX_DONT_CARE; - (*next)->transparentGreen = GLX_DONT_CARE; - (*next)->transparentBlue = GLX_DONT_CARE; - (*next)->transparentAlpha = GLX_DONT_CARE; - (*next)->transparentIndex = GLX_DONT_CARE; - (*next)->xRenderable = GLX_DONT_CARE; - (*next)->fbconfigID = GLX_DONT_CARE; - (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML; - (*next)->bindToTextureRgb = GLX_DONT_CARE; - (*next)->bindToTextureRgba = GLX_DONT_CARE; - (*next)->bindToMipmapTexture = GLX_DONT_CARE; - (*next)->bindToTextureTargets = GLX_DONT_CARE; - (*next)->yInverted = GLX_DONT_CARE; - - next = &((*next)->next); - } - - return base; -} - - -/** - * Destroy a linked list of \c __GLcontextModes structures created by - * \c _gl_context_modes_create. - * - * \param modes Linked list of structures to be destroyed. All structres - * in the list will be freed. - */ -void -_gl_context_modes_destroy(__GLcontextModes * modes) -{ - while (modes != NULL) { - __GLcontextModes *const next = modes->next; - - _mesa_free(modes); - modes = next; - } -} - - -/** - * Find a context mode matching a Visual ID. - * - * \param modes List list of context-mode structures to be searched. - * \param vid Visual ID to be found. - * \returns A pointer to a context-mode in \c modes if \c vid was found in - * the list, or \c NULL if it was not. - */ - -__GLcontextModes * -_gl_context_modes_find_visual(__GLcontextModes * modes, int vid) -{ - __GLcontextModes *m; - - for (m = modes; m != NULL; m = m->next) - if (m->visualID == vid) - return m; - - return NULL; -} - -__GLcontextModes * -_gl_context_modes_find_fbconfig(__GLcontextModes * modes, int fbid) -{ - __GLcontextModes *m; - - for (m = modes; m != NULL; m = m->next) - if (m->fbconfigID == fbid) - return m; - - return NULL; -} - -/** - * Determine if two context-modes are the same. This is intended to be used - * by libGL implementations to compare to sets of driver generated FBconfigs. - * - * \param a Context-mode to be compared. - * \param b Context-mode to be compared. - * \returns \c GL_TRUE if the two context-modes are the same. \c GL_FALSE is - * returned otherwise. - */ -GLboolean -_gl_context_modes_are_same(const __GLcontextModes * a, - const __GLcontextModes * b) -{ - return ((a->rgbMode == b->rgbMode) && - (a->floatMode == b->floatMode) && - (a->colorIndexMode == b->colorIndexMode) && - (a->doubleBufferMode == b->doubleBufferMode) && - (a->stereoMode == b->stereoMode) && - (a->redBits == b->redBits) && - (a->greenBits == b->greenBits) && - (a->blueBits == b->blueBits) && (a->alphaBits == b->alphaBits) && -#if 0 /* For some reason these don't get set on the client-side in libGL. */ - (a->redMask == b->redMask) && - (a->greenMask == b->greenMask) && - (a->blueMask == b->blueMask) && (a->alphaMask == b->alphaMask) && -#endif - (a->rgbBits == b->rgbBits) && - (a->indexBits == b->indexBits) && - (a->accumRedBits == b->accumRedBits) && - (a->accumGreenBits == b->accumGreenBits) && - (a->accumBlueBits == b->accumBlueBits) && - (a->accumAlphaBits == b->accumAlphaBits) && - (a->depthBits == b->depthBits) && - (a->stencilBits == b->stencilBits) && - (a->numAuxBuffers == b->numAuxBuffers) && - (a->level == b->level) && - (a->pixmapMode == b->pixmapMode) && - (a->visualRating == b->visualRating) && - (a->transparentPixel == b->transparentPixel) && - ((a->transparentPixel != GLX_TRANSPARENT_RGB) || - ((a->transparentRed == b->transparentRed) && - (a->transparentGreen == b->transparentGreen) && - (a->transparentBlue == b->transparentBlue) && - (a->transparentAlpha == b->transparentAlpha))) && - ((a->transparentPixel != GLX_TRANSPARENT_INDEX) || - (a->transparentIndex == b->transparentIndex)) && - (a->sampleBuffers == b->sampleBuffers) && - (a->samples == b->samples) && - ((a->drawableType & b->drawableType) != 0) && - (a->renderType == b->renderType) && - (a->maxPbufferWidth == b->maxPbufferWidth) && - (a->maxPbufferHeight == b->maxPbufferHeight) && - (a->maxPbufferPixels == b->maxPbufferPixels) && - (a->optimalPbufferWidth == b->optimalPbufferWidth) && - (a->optimalPbufferHeight == b->optimalPbufferHeight) && - (a->swapMethod == b->swapMethod) && - (a->bindToTextureRgb == b->bindToTextureRgb) && - (a->bindToTextureRgba == b->bindToTextureRgba) && - (a->bindToMipmapTexture == b->bindToMipmapTexture) && - (a->bindToTextureTargets == b->bindToTextureTargets) && - (a->yInverted == b->yInverted)); -} diff --git a/src/glx/x11/glcontextmodes.h b/src/glx/x11/glcontextmodes.h deleted file mode 100644 index 6676ae306c2..00000000000 --- a/src/glx/x11/glcontextmodes.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2003 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file glcontextmodes.h - * \author Ian Romanick - */ - -#ifndef GLCONTEXTMODES_H -#define GLCONTEXTMODES_H - -#include "GL/internal/glcore.h" - -#if !defined(IN_MINI_GLX) -extern GLint _gl_convert_from_x_visual_type(int visualType); -extern GLint _gl_convert_to_x_visual_type(int visualType); -extern void _gl_copy_visual_to_context_mode(__GLcontextModes * mode, - const __GLXvisualConfig * config); -extern int _gl_get_context_mode_data(const __GLcontextModes * mode, - int attribute, int *value_return); -#endif /* !defined(IN_MINI_GLX) */ - -extern __GLcontextModes *_gl_context_modes_create(unsigned count, - size_t minimum_size); -extern void _gl_context_modes_destroy(__GLcontextModes * modes); -extern __GLcontextModes *_gl_context_modes_find_visual(__GLcontextModes * - modes, int vid); -extern __GLcontextModes *_gl_context_modes_find_fbconfig(__GLcontextModes * - modes, int fbid); -extern GLboolean _gl_context_modes_are_same(const __GLcontextModes * a, - const __GLcontextModes * b); - -#endif /* GLCONTEXTMODES_H */ diff --git a/src/glx/x11/glx_pbuffer.c b/src/glx/x11/glx_pbuffer.c deleted file mode 100644 index a0a02238b00..00000000000 --- a/src/glx/x11/glx_pbuffer.c +++ /dev/null @@ -1,724 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file glx_pbuffer.c - * Implementation of pbuffer related functions. - * - * \author Ian Romanick - */ - -#include -#include "glxclient.h" -#include -#include -#include -#include -#include "glxextensions.h" - -#define WARN_ONCE_GLX_1_3(a, b) { \ - static int warned=1; \ - if(warned) { \ - warn_GLX_1_3((a), b ); \ - warned=0; \ - } \ - } - -/** - * Emit a warning when clients use GLX 1.3 functions on pre-1.3 systems. - */ -static void -warn_GLX_1_3(Display *dpy, const char *function_name) -{ - __GLXdisplayPrivate *priv = __glXInitialize(dpy); - - if (priv->minorVersion < 3) { - fprintf(stderr, - "WARNING: Application calling GLX 1.3 function \"%s\" " - "when GLX 1.3 is not supported! This is an application bug!\n", - function_name); - } -} - - -/** - * Change a drawable's attribute. - * - * This function is used to implement \c glXSelectEvent and - * \c glXSelectEventSGIX. - * - * \note - * This function dynamically determines whether to use the SGIX_pbuffer - * version of the protocol or the GLX 1.3 version of the protocol. - * - * \todo - * This function needs to be modified to work with direct-rendering drivers. - */ -static void -ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable, - const CARD32 * attribs, size_t num_attribs) -{ - __GLXdisplayPrivate *priv = __glXInitialize(dpy); - CARD32 *output; - CARD8 opcode; - - if ((dpy == NULL) || (drawable == 0)) { - return; - } - - opcode = __glXSetupForCommand(dpy); - if (!opcode) - return; - - LockDisplay(dpy); - - if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { - xGLXChangeDrawableAttributesReq *req; - - GetReqExtra(GLXChangeDrawableAttributes, 8 + (8 * num_attribs), req); - output = (CARD32 *) (req + 1); - - req->reqType = opcode; - req->glxCode = X_GLXChangeDrawableAttributes; - req->drawable = drawable; - req->numAttribs = (CARD32) num_attribs; - } - else { - xGLXVendorPrivateWithReplyReq *vpreq; - - GetReqExtra(GLXVendorPrivateWithReply, 4 + (8 * num_attribs), vpreq); - output = (CARD32 *) (vpreq + 1); - - vpreq->reqType = opcode; - vpreq->glxCode = X_GLXVendorPrivateWithReply; - vpreq->vendorCode = X_GLXvop_ChangeDrawableAttributesSGIX; - - output[0] = (CARD32) drawable; - output++; - } - - (void) memcpy(output, attribs, sizeof(CARD32) * 2 * num_attribs); - - UnlockDisplay(dpy); - SyncHandle(); - - return; -} - - -/** - * Destroy a pbuffer. - * - * This function is used to implement \c glXDestroyPbuffer and - * \c glXDestroyGLXPbufferSGIX. - * - * \note - * This function dynamically determines whether to use the SGIX_pbuffer - * version of the protocol or the GLX 1.3 version of the protocol. - * - * \todo - * This function needs to be modified to work with direct-rendering drivers. - */ -static void -DestroyPbuffer(Display * dpy, GLXDrawable drawable) -{ - __GLXdisplayPrivate *priv = __glXInitialize(dpy); - CARD8 opcode; - - if ((dpy == NULL) || (drawable == 0)) { - return; - } - - opcode = __glXSetupForCommand(dpy); - if (!opcode) - return; - - LockDisplay(dpy); - - if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { - xGLXDestroyPbufferReq *req; - - GetReq(GLXDestroyPbuffer, req); - req->reqType = opcode; - req->glxCode = X_GLXDestroyPbuffer; - req->pbuffer = (GLXPbuffer) drawable; - } - else { - xGLXVendorPrivateWithReplyReq *vpreq; - CARD32 *data; - - GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq); - data = (CARD32 *) (vpreq + 1); - - data[0] = (CARD32) drawable; - - vpreq->reqType = opcode; - vpreq->glxCode = X_GLXVendorPrivateWithReply; - vpreq->vendorCode = X_GLXvop_DestroyGLXPbufferSGIX; - } - - UnlockDisplay(dpy); - SyncHandle(); - - return; -} - - -#ifdef GLX_DIRECT_RENDERING -extern __GLXDRIdrawable *GetGLXDRIDrawable(Display * dpy, - GLXDrawable drawable, - int *const scrn_num); - -static GLenum -determineTextureTarget(const int *attribs, int numAttribs) -{ - GLenum target = 0; - int i; - - for (i = 0; i < numAttribs; i++) { - if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) { - switch (attribs[2 * i + 1]) { - case GLX_TEXTURE_2D_EXT: - target = GL_TEXTURE_2D; - break; - case GLX_TEXTURE_RECTANGLE_EXT: - target = GL_TEXTURE_RECTANGLE_ARB; - break; - } - } - } - - return target; -} - - -static GLenum -determineTextureFormat(const int *attribs, int numAttribs) -{ - int i; - - for (i = 0; i < numAttribs; i++) { - if (attribs[2 * i] == GLX_TEXTURE_FORMAT_EXT) - return attribs[2 * i + 1]; - } - - return 0; -} -#endif - -/** - * Get a drawable's attribute. - * - * This function is used to implement \c glXGetSelectedEvent and - * \c glXGetSelectedEventSGIX. - * - * \note - * This function dynamically determines whether to use the SGIX_pbuffer - * version of the protocol or the GLX 1.3 version of the protocol. - * - * \todo - * The number of attributes returned is likely to be small, probably less than - * 10. Given that, this routine should try to use an array on the stack to - * capture the reply rather than always calling Xmalloc. - * - * \todo - * This function needs to be modified to work with direct-rendering drivers. - */ -static int -GetDrawableAttribute(Display * dpy, GLXDrawable drawable, - int attribute, unsigned int *value) -{ - __GLXdisplayPrivate *priv; - xGLXGetDrawableAttributesReply reply; - CARD32 *data; - CARD8 opcode; - unsigned int length; - unsigned int i; - unsigned int num_attributes; - GLboolean use_glx_1_3; - - if ((dpy == NULL) || (drawable == 0)) { - return 0; - } - - priv = __glXInitialize(dpy); - use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3)); - - *value = 0; - - - opcode = __glXSetupForCommand(dpy); - if (!opcode) - return 0; - - LockDisplay(dpy); - - if (use_glx_1_3) { - xGLXGetDrawableAttributesReq *req; - - GetReqExtra(GLXGetDrawableAttributes, 4, req); - req->reqType = opcode; - req->glxCode = X_GLXGetDrawableAttributes; - req->drawable = drawable; - } - else { - xGLXVendorPrivateWithReplyReq *vpreq; - - GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq); - data = (CARD32 *) (vpreq + 1); - data[0] = (CARD32) drawable; - - vpreq->reqType = opcode; - vpreq->glxCode = X_GLXVendorPrivateWithReply; - vpreq->vendorCode = X_GLXvop_GetDrawableAttributesSGIX; - } - - _XReply(dpy, (xReply *) & reply, 0, False); - - if (reply.type == X_Error) { - UnlockDisplay(dpy); - SyncHandle(); - return 0; - } - - length = reply.length; - if (length) { - num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2; - data = (CARD32 *) Xmalloc(length * sizeof(CARD32)); - if (data == NULL) { - /* Throw data on the floor */ - _XEatData(dpy, length); - } - else { - _XRead(dpy, (char *) data, length * sizeof(CARD32)); - - /* Search the set of returned attributes for the attribute requested by - * the caller. - */ - for (i = 0; i < num_attributes; i++) { - if (data[i * 2] == attribute) { - *value = data[(i * 2) + 1]; - break; - } - } - -#ifdef GLX_DIRECT_RENDERING - { - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); - - if (pdraw != NULL && !pdraw->textureTarget) - pdraw->textureTarget = - determineTextureTarget((const int *) data, num_attributes); - if (pdraw != NULL && !pdraw->textureFormat) - pdraw->textureFormat = - determineTextureFormat((const int *) data, num_attributes); - } -#endif - - Xfree(data); - } - } - - UnlockDisplay(dpy); - SyncHandle(); - - return 0; -} - -/** - * Create a non-pbuffer GLX drawable. - * - * \todo - * This function needs to be modified to work with direct-rendering drivers. - */ -static GLXDrawable -CreateDrawable(Display * dpy, const __GLcontextModes * fbconfig, - Drawable drawable, const int *attrib_list, CARD8 glxCode) -{ - xGLXCreateWindowReq *req; - CARD32 *data; - unsigned int i; - CARD8 opcode; - - i = 0; - if (attrib_list) { - while (attrib_list[i * 2] != None) - i++; - } - - opcode = __glXSetupForCommand(dpy); - if (!opcode) - return None; - - LockDisplay(dpy); - GetReqExtra(GLXCreateWindow, 8 * i, req); - data = (CARD32 *) (req + 1); - - req->reqType = opcode; - req->glxCode = glxCode; - req->screen = (CARD32) fbconfig->screen; - req->fbconfig = fbconfig->fbconfigID; - req->window = (CARD32) drawable; - req->glxwindow = (GLXWindow) XAllocID(dpy); - req->numAttribs = (CARD32) i; - - memcpy(data, attrib_list, 8 * i); - - UnlockDisplay(dpy); - SyncHandle(); - -#ifdef GLX_DIRECT_RENDERING - do { - /* FIXME: Maybe delay __DRIdrawable creation until the drawable - * is actually bound to a context... */ - - __GLXdisplayPrivate *const priv = __glXInitialize(dpy); - __GLXDRIdrawable *pdraw; - __GLXscreenConfigs *psc; - - psc = &priv->screenConfigs[fbconfig->screen]; - if (psc->driScreen == NULL) - break; - pdraw = psc->driScreen->createDrawable(psc, drawable, - req->glxwindow, fbconfig); - if (pdraw == NULL) { - fprintf(stderr, "failed to create drawable\n"); - break; - } - - if (__glxHashInsert(psc->drawHash, req->glxwindow, pdraw)) { - (*pdraw->destroyDrawable) (pdraw); - return None; /* FIXME: Check what we're supposed to do here... */ - } - - pdraw->textureTarget = determineTextureTarget(attrib_list, i); - pdraw->textureFormat = determineTextureFormat(attrib_list, i); - } while (0); -#endif - - return (GLXDrawable) req->glxwindow; -} - - -/** - * Destroy a non-pbuffer GLX drawable. - * - * \todo - * This function needs to be modified to work with direct-rendering drivers. - */ -static void -DestroyDrawable(Display * dpy, GLXDrawable drawable, CARD32 glxCode) -{ - xGLXDestroyPbufferReq *req; - CARD8 opcode; - - if ((dpy == NULL) || (drawable == 0)) { - return; - } - - - opcode = __glXSetupForCommand(dpy); - if (!opcode) - return; - - LockDisplay(dpy); - - GetReqExtra(GLXDestroyPbuffer, 4, req); - req->reqType = opcode; - req->glxCode = glxCode; - req->pbuffer = (GLXPbuffer) drawable; - - UnlockDisplay(dpy); - SyncHandle(); - -#ifdef GLX_DIRECT_RENDERING - { - int screen; - __GLXdisplayPrivate *const priv = __glXInitialize(dpy); - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); - __GLXscreenConfigs *psc = &priv->screenConfigs[screen]; - - if (pdraw != NULL) { - (*pdraw->destroyDrawable) (pdraw); - __glxHashDelete(psc->drawHash, drawable); - } - } -#endif - - return; -} - - -/** - * Create a pbuffer. - * - * This function is used to implement \c glXCreatePbuffer and - * \c glXCreateGLXPbufferSGIX. - * - * \note - * This function dynamically determines whether to use the SGIX_pbuffer - * version of the protocol or the GLX 1.3 version of the protocol. - * - * \todo - * This function needs to be modified to work with direct-rendering drivers. - */ -static GLXDrawable -CreatePbuffer(Display * dpy, const __GLcontextModes * fbconfig, - unsigned int width, unsigned int height, - const int *attrib_list, GLboolean size_in_attribs) -{ - __GLXdisplayPrivate *priv = __glXInitialize(dpy); - GLXDrawable id = 0; - CARD32 *data; - CARD8 opcode; - unsigned int i; - - i = 0; - if (attrib_list) { - while (attrib_list[i * 2]) - i++; - } - - opcode = __glXSetupForCommand(dpy); - if (!opcode) - return None; - - LockDisplay(dpy); - id = XAllocID(dpy); - - if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { - xGLXCreatePbufferReq *req; - unsigned int extra = (size_in_attribs) ? 0 : 2; - - GetReqExtra(GLXCreatePbuffer, (8 * (i + extra)), req); - data = (CARD32 *) (req + 1); - - req->reqType = opcode; - req->glxCode = X_GLXCreatePbuffer; - req->screen = (CARD32) fbconfig->screen; - req->fbconfig = fbconfig->fbconfigID; - req->pbuffer = (GLXPbuffer) id; - req->numAttribs = (CARD32) (i + extra); - - if (!size_in_attribs) { - data[(2 * i) + 0] = GLX_PBUFFER_WIDTH; - data[(2 * i) + 1] = width; - data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT; - data[(2 * i) + 3] = height; - data += 4; - } - } - else { - xGLXVendorPrivateReq *vpreq; - - GetReqExtra(GLXVendorPrivate, 20 + (8 * i), vpreq); - data = (CARD32 *) (vpreq + 1); - - vpreq->reqType = opcode; - vpreq->glxCode = X_GLXVendorPrivate; - vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX; - - data[0] = (CARD32) fbconfig->screen; - data[1] = (CARD32) fbconfig->fbconfigID; - data[2] = (CARD32) id; - data[3] = (CARD32) width; - data[4] = (CARD32) height; - data += 5; - } - - (void) memcpy(data, attrib_list, sizeof(CARD32) * 2 * i); - - UnlockDisplay(dpy); - SyncHandle(); - - return id; -} - - -/** - * Create a new pbuffer. - */ -PUBLIC GLXPbufferSGIX -glXCreateGLXPbufferSGIX(Display * dpy, GLXFBConfigSGIX config, - unsigned int width, unsigned int height, - int *attrib_list) -{ - return (GLXPbufferSGIX) CreatePbuffer(dpy, (__GLcontextModes *) config, - width, height, - attrib_list, GL_FALSE); -} - - -/** - * Create a new pbuffer. - */ -PUBLIC GLXPbuffer -glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int *attrib_list) -{ - int i, width, height; - - width = 0; - height = 0; - - WARN_ONCE_GLX_1_3(dpy, __func__); - - for (i = 0; attrib_list[i * 2]; i++) { - switch (attrib_list[i * 2]) { - case GLX_PBUFFER_WIDTH: - width = attrib_list[i * 2 + 1]; - break; - case GLX_PBUFFER_HEIGHT: - height = attrib_list[i * 2 + 1]; - break; - } - } - - return (GLXPbuffer) CreatePbuffer(dpy, (__GLcontextModes *) config, - width, height, attrib_list, GL_TRUE); -} - - -/** - * Destroy an existing pbuffer. - */ -PUBLIC void -glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf) -{ - DestroyPbuffer(dpy, pbuf); -} - - -/** - * Query an attribute of a drawable. - */ -PUBLIC void -glXQueryDrawable(Display * dpy, GLXDrawable drawable, - int attribute, unsigned int *value) -{ - WARN_ONCE_GLX_1_3(dpy, __func__); - GetDrawableAttribute(dpy, drawable, attribute, value); -} - - -/** - * Query an attribute of a pbuffer. - */ -PUBLIC int -glXQueryGLXPbufferSGIX(Display * dpy, GLXPbufferSGIX drawable, - int attribute, unsigned int *value) -{ - return GetDrawableAttribute(dpy, drawable, attribute, value); -} - - -/** - * Select the event mask for a drawable. - */ -PUBLIC void -glXSelectEvent(Display * dpy, GLXDrawable drawable, unsigned long mask) -{ - CARD32 attribs[2]; - - attribs[0] = (CARD32) GLX_EVENT_MASK; - attribs[1] = (CARD32) mask; - - ChangeDrawableAttribute(dpy, drawable, attribs, 1); -} - - -/** - * Get the selected event mask for a drawable. - */ -PUBLIC void -glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask) -{ - unsigned int value; - - - /* The non-sense with value is required because on LP64 platforms - * sizeof(unsigned int) != sizeof(unsigned long). On little-endian - * we could just type-cast the pointer, but why? - */ - - GetDrawableAttribute(dpy, drawable, GLX_EVENT_MASK_SGIX, &value); - *mask = value; -} - - -PUBLIC GLXPixmap -glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap, - const int *attrib_list) -{ - WARN_ONCE_GLX_1_3(dpy, __func__); - - return CreateDrawable(dpy, (__GLcontextModes *) config, - (Drawable) pixmap, attrib_list, X_GLXCreatePixmap); -} - - -PUBLIC GLXWindow -glXCreateWindow(Display * dpy, GLXFBConfig config, Window win, - const int *attrib_list) -{ - WARN_ONCE_GLX_1_3(dpy, __func__); - - return CreateDrawable(dpy, (__GLcontextModes *) config, - (Drawable) win, attrib_list, X_GLXCreateWindow); -} - - -PUBLIC void -glXDestroyPixmap(Display * dpy, GLXPixmap pixmap) -{ - WARN_ONCE_GLX_1_3(dpy, __func__); - - DestroyDrawable(dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap); -} - - -PUBLIC void -glXDestroyWindow(Display * dpy, GLXWindow win) -{ - WARN_ONCE_GLX_1_3(dpy, __func__); - - DestroyDrawable(dpy, (GLXDrawable) win, X_GLXDestroyWindow); -} - - -PUBLIC -GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX, - (Display * dpy, GLXPbufferSGIX pbuf), - (dpy, pbuf), glXDestroyPbuffer) - -PUBLIC -GLX_ALIAS_VOID(glXSelectEventSGIX, - (Display * dpy, GLXDrawable drawable, - unsigned long mask), (dpy, drawable, mask), glXSelectEvent) - -PUBLIC -GLX_ALIAS_VOID(glXGetSelectedEventSGIX, - (Display * dpy, GLXDrawable drawable, - unsigned long *mask), (dpy, drawable, mask), - glXGetSelectedEvent) - diff --git a/src/glx/x11/glx_query.c b/src/glx/x11/glx_query.c deleted file mode 100644 index efad13d376e..00000000000 --- a/src/glx/x11/glx_query.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file glx_query.c - * Generic utility functions to query internal data from the server. - * - * \author Ian Romanick - */ - -#include "glxclient.h" - -#if defined(USE_XCB) -# include -# include -# include -#endif - -#ifdef USE_XCB - -/** - * Exchange a protocol request for glXQueryServerString. - */ -char * -__glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name) -{ - xcb_connection_t *c = XGetXCBConnection(dpy); - xcb_glx_query_server_string_reply_t *reply = - xcb_glx_query_server_string_reply(c, - xcb_glx_query_server_string(c, - screen, - name), - NULL); - - /* The spec doesn't mention this, but the Xorg server replies with - * a string already terminated with '\0'. */ - uint32_t len = xcb_glx_query_server_string_string_length(reply); - char *buf = Xmalloc(len); - memcpy(buf, xcb_glx_query_server_string_string(reply), len); - free(reply); - - return buf; -} - -/** - * Exchange a protocol request for glGetString. - */ -char * -__glXGetString(Display * dpy, int opcode, CARD32 contextTag, CARD32 name) -{ - xcb_connection_t *c = XGetXCBConnection(dpy); - xcb_glx_get_string_reply_t *reply = xcb_glx_get_string_reply(c, - xcb_glx_get_string - (c, - contextTag, - name), - NULL); - - /* The spec doesn't mention this, but the Xorg server replies with - * a string already terminated with '\0'. */ - uint32_t len = xcb_glx_get_string_string_length(reply); - char *buf = Xmalloc(len); - memcpy(buf, xcb_glx_get_string_string(reply), len); - free(reply); - - return buf; -} - -#else - -/** - * GLX protocol structure for the ficticious "GXLGenericGetString" request. - * - * This is a non-existant protocol packet. It just so happens that all of - * the real protocol packets used to request a string from the server have - * an identical binary layout. The only difference between them is the - * meaning of the \c for_whom field and the value of the \c glxCode. - */ -typedef struct GLXGenericGetString -{ - CARD8 reqType; - CARD8 glxCode; - CARD16 length B16; - CARD32 for_whom B32; - CARD32 name B32; -} xGLXGenericGetStringReq; - -/* These defines are only needed to make the GetReq macro happy. - */ -#define sz_xGLXGenericGetStringReq 12 -#define X_GLXGenericGetString 0 - -/** - * Query the Server GLX string. - * This routine will allocate the necessay space for the string. - */ -static char * -__glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode, - CARD32 for_whom, CARD32 name) -{ - xGLXGenericGetStringReq *req; - xGLXSingleReply reply; - int length; - int numbytes; - char *buf; - - - LockDisplay(dpy); - - - /* All of the GLX protocol requests for getting a string from the server - * look the same. The exact meaning of the for_whom field is usually - * either the screen number (for glXQueryServerString) or the context tag - * (for GLXSingle). - */ - - GetReq(GLXGenericGetString, req); - req->reqType = opcode; - req->glxCode = glxCode; - req->for_whom = for_whom; - req->name = name; - - _XReply(dpy, (xReply *) & reply, 0, False); - - length = reply.length * 4; - numbytes = reply.size; - - buf = (char *) Xmalloc(numbytes); - if (buf != NULL) { - _XRead(dpy, buf, numbytes); - length -= numbytes; - } - - _XEatData(dpy, length); - - UnlockDisplay(dpy); - SyncHandle(); - - return buf; -} - -char * -__glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name) -{ - return __glXGetStringFromServer(dpy, opcode, - X_GLXQueryServerString, screen, name); -} - -char * -__glXGetString(Display * dpy, int opcode, CARD32 contextTag, CARD32 name) -{ - return __glXGetStringFromServer(dpy, opcode, X_GLsop_GetString, - contextTag, name); -} - -#endif /* USE_XCB */ diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h deleted file mode 100644 index e0b286b6883..00000000000 --- a/src/glx/x11/glxclient.h +++ /dev/null @@ -1,803 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -/** - * \file glxclient.h - * Direct rendering support added by Precision Insight, Inc. - * - * \author Kevin E. Martin - */ - -#ifndef _GLX_client_h_ -#define _GLX_client_h_ -#define NEED_REPLIES -#define NEED_EVENTS -#include -#include -#include -#define GLX_GLXEXT_PROTOTYPES -#include -#include -#include -#include -#include -#ifdef WIN32 -#include -#endif -#include "GL/glxint.h" -#include "GL/glxproto.h" -#include "GL/internal/glcore.h" -#include "glapi/glapitable.h" -#include "glxhash.h" -#if defined( PTHREADS ) -# include -#endif - -#include "glxextensions.h" - - -/* If we build the library with gcc's -fvisibility=hidden flag, we'll - * use the PUBLIC macro to mark functions that are to be exported. - * - * We also need to define a USED attribute, so the optimizer doesn't - * inline a static function that we later use in an alias. - ajax - */ -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 -# define PUBLIC __attribute__((visibility("default"))) -# define USED __attribute__((used)) -#else -# define PUBLIC -# define USED -#endif - - - -#define GLX_MAJOR_VERSION 1 /* current version numbers */ -#define GLX_MINOR_VERSION 4 - -#define __GLX_MAX_TEXTURE_UNITS 32 - -typedef struct __GLXscreenConfigsRec __GLXscreenConfigs; -typedef struct __GLXcontextRec __GLXcontext; -typedef struct __GLXdrawableRec __GLXdrawable; -typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate; -typedef struct _glapi_table __GLapi; - -/************************************************************************/ - -#ifdef GLX_DIRECT_RENDERING - -#define containerOf(ptr, type, member) \ - (type *)( (char *)ptr - offsetof(type,member) ) - -#include - - -/** - * Display dependent methods. This structure is initialized during the - * \c driCreateDisplay call. - */ -typedef struct __GLXDRIdisplayRec __GLXDRIdisplay; -typedef struct __GLXDRIscreenRec __GLXDRIscreen; -typedef struct __GLXDRIdrawableRec __GLXDRIdrawable; -typedef struct __GLXDRIcontextRec __GLXDRIcontext; - -#include "glxextensions.h" - -struct __GLXDRIdisplayRec -{ - /** - * Method to destroy the private DRI display data. - */ - void (*destroyDisplay) (__GLXDRIdisplay * display); - - __GLXDRIscreen *(*createScreen) (__GLXscreenConfigs * psc, int screen, - __GLXdisplayPrivate * priv); -}; - -struct __GLXDRIscreenRec { - - void (*destroyScreen)(__GLXscreenConfigs *psc); - - __GLXDRIcontext *(*createContext)(__GLXscreenConfigs *psc, - const __GLcontextModes *mode, - GLXContext gc, - GLXContext shareList, int renderType); - - __GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc, - XID drawable, - GLXDrawable glxDrawable, - const __GLcontextModes *modes); - - int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc, - int64_t divisor, int64_t remainder); - void (*copySubBuffer)(__GLXDRIdrawable *pdraw, - int x, int y, int width, int height); - void (*waitX)(__GLXDRIdrawable *pdraw); - void (*waitGL)(__GLXDRIdrawable *pdraw); - int (*getDrawableMSC)(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw, - int64_t *ust, int64_t *msc, int64_t *sbc); - int (*waitForMSC)(__GLXDRIdrawable *pdraw, int64_t target_msc, - int64_t divisor, int64_t remainder, int64_t *ust, - int64_t *msc, int64_t *sbc); - int (*waitForSBC)(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust, - int64_t *msc, int64_t *sbc); - void (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval); - int (*getSwapInterval)(__GLXDRIdrawable *pdraw); -}; - -struct __GLXDRIcontextRec -{ - void (*destroyContext) (__GLXDRIcontext * context, - __GLXscreenConfigs * psc, Display * dpy); - Bool(*bindContext) (__GLXDRIcontext * context, __GLXDRIdrawable * pdraw, - __GLXDRIdrawable * pread); - - void (*unbindContext) (__GLXDRIcontext * context); -}; - -struct __GLXDRIdrawableRec -{ - void (*destroyDrawable) (__GLXDRIdrawable * drawable); - - XID xDrawable; - XID drawable; - __GLXscreenConfigs *psc; - GLenum textureTarget; - __DRIdrawable *driDrawable; - GLenum textureFormat; /* EXT_texture_from_pixmap support */ -}; - -/* -** Function to create and DRI display data and initialize the display -** dependent methods. -*/ -extern __GLXDRIdisplay *driswCreateDisplay(Display * dpy); -extern __GLXDRIdisplay *driCreateDisplay(Display * dpy); -extern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy); - -extern void DRI_glXUseXFont(Font font, int first, int count, int listbase); - -/* -** Functions to obtain driver configuration information from a direct -** rendering client application -*/ -extern const char *glXGetScreenDriver(Display * dpy, int scrNum); - -extern const char *glXGetDriverConfig(const char *driverName); - -#endif - -/************************************************************************/ - -#define __GL_CLIENT_ATTRIB_STACK_DEPTH 16 - -typedef struct __GLXpixelStoreModeRec -{ - GLboolean swapEndian; - GLboolean lsbFirst; - GLuint rowLength; - GLuint imageHeight; - GLuint imageDepth; - GLuint skipRows; - GLuint skipPixels; - GLuint skipImages; - GLuint alignment; -} __GLXpixelStoreMode; - - -typedef struct __GLXattributeRec -{ - GLuint mask; - - /** - * Pixel storage state. Most of the pixel store mode state is kept - * here and used by the client code to manage the packing and - * unpacking of data sent to/received from the server. - */ - __GLXpixelStoreMode storePack, storeUnpack; - - /** - * Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically - * disabled? - */ - GLboolean NoDrawArraysProtocol; - - /** - * Vertex Array storage state. The vertex array component - * state is stored here and is used to manage the packing of - * DrawArrays data sent to the server. - */ - struct array_state_vector *array_state; -} __GLXattribute; - -typedef struct __GLXattributeMachineRec -{ - __GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; - __GLXattribute **stackPointer; -} __GLXattributeMachine; - -/** - * GLX state that needs to be kept on the client. One of these records - * exist for each context that has been made current by this client. - */ -struct __GLXcontextRec -{ - /** - * \name Drawing command buffer. - * - * Drawing commands are packed into this buffer before being sent as a - * single GLX protocol request. The buffer is sent when it overflows or - * is flushed by \c __glXFlushRenderBuffer. \c pc is the next location - * in the buffer to be filled. \c limit is described above in the buffer - * slop discussion. - * - * Commands that require large amounts of data to be transfered will - * also use this buffer to hold a header that describes the large - * command. - * - * These must be the first 6 fields since they are static initialized - * in the dummy context in glxext.c - */ - /*@{ */ - GLubyte *buf; - GLubyte *pc; - GLubyte *limit; - GLubyte *bufEnd; - GLint bufSize; - /*@} */ - - /** - * The XID of this rendering context. When the context is created a - * new XID is allocated. This is set to None when the context is - * destroyed but is still current to some thread. In this case the - * context will be freed on next MakeCurrent. - */ - XID xid; - - /** - * The XID of the \c shareList context. - */ - XID share_xid; - - /** - * Screen number. - */ - GLint screen; - __GLXscreenConfigs *psc; - - /** - * \c GL_TRUE if the context was created with ImportContext, which - * means the server-side context was created by another X client. - */ - GLboolean imported; - - /** - * The context tag returned by MakeCurrent when this context is made - * current. This tag is used to identify the context that a thread has - * current so that proper server context management can be done. It is - * used for all context specific commands (i.e., \c Render, \c RenderLarge, - * \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old - * context)). - */ - GLXContextTag currentContextTag; - - /** - * \name Rendering mode - * - * The rendering mode is kept on the client as well as the server. - * When \c glRenderMode is called, the buffer associated with the - * previous rendering mode (feedback or select) is filled. - */ - /*@{ */ - GLenum renderMode; - GLfloat *feedbackBuf; - GLuint *selectBuf; - /*@} */ - - /** - * This is \c GL_TRUE if the pixel unpack modes are such that an image - * can be unpacked from the clients memory by just copying. It may - * still be true that the server will have to do some work. This - * just promises that a straight copy will fetch the correct bytes. - */ - GLboolean fastImageUnpack; - - /** - * Fill newImage with the unpacked form of \c oldImage getting it - * ready for transport to the server. - */ - void (*fillImage) (__GLXcontext *, GLint, GLint, GLint, GLint, GLenum, - GLenum, const GLvoid *, GLubyte *, GLubyte *); - - /** - * Client side attribs. - */ - __GLXattributeMachine attributes; - - /** - * Client side error code. This is set when client side gl API - * routines need to set an error because of a bad enumerant or - * running out of memory, etc. - */ - GLenum error; - - /** - * Whether this context does direct rendering. - */ - Bool isDirect; - - /** - * \c dpy of current display for this context. Will be \c NULL if not - * current to any display, or if this is the "dummy context". - */ - Display *currentDpy; - - /** - * The current drawable for this context. Will be None if this - * context is not current to any drawable. currentReadable is below. - */ - GLXDrawable currentDrawable; - - /** - * \name GL Constant Strings - * - * Constant strings that describe the server implementation - * These pertain to GL attributes, not to be confused with - * GLX versioning attributes. - */ - /*@{ */ - GLubyte *vendor; - GLubyte *renderer; - GLubyte *version; - GLubyte *extensions; - /*@} */ - - /** - * Record the dpy this context was created on for later freeing - */ - Display *createDpy; - - /** - * Maximum small render command size. This is the smaller of 64k and - * the size of the above buffer. - */ - GLint maxSmallRenderCommandSize; - - /** - * Major opcode for the extension. Copied here so a lookup isn't - * needed. - */ - GLint majorOpcode; - - /** - * Pointer to the mode used to create this context. - */ - const __GLcontextModes *mode; - -#ifdef GLX_DIRECT_RENDERING - __GLXDRIcontext *driContext; - __DRIcontext *__driContext; -#endif - - /** - * The current read-drawable for this context. Will be None if this - * context is not current to any drawable. - * - * \since Internal API version 20030606. - */ - GLXDrawable currentReadable; - - /** - * Pointer to client-state data that is private to libGL. This is only - * used for indirect rendering contexts. - * - * No internal API version change was made for this change. Client-side - * drivers should NEVER use this data or even care that it exists. - */ - void *client_state_private; - - /** - * Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE. - */ - int renderType; - - /** - * \name Raw server GL version - * - * True core GL version supported by the server. This is the raw value - * returned by the server, and it may not reflect what is actually - * supported (or reported) by the client-side library. - */ - /*@{ */ - int server_major; /**< Major version number. */ - int server_minor; /**< Minor version number. */ - /*@} */ - - /** - * Thread ID we're currently current in. Zero if none. - */ - unsigned long thread_id; - - char gl_extension_bits[__GL_EXT_BYTES]; -}; - -#define __glXSetError(gc,code) \ - if (!(gc)->error) { \ - (gc)->error = code; \ - } - -extern void __glFreeAttributeState(__GLXcontext *); - -/************************************************************************/ - -/** - * The size of the largest drawing command known to the implementation - * that will use the GLXRender GLX command. In this case it is - * \c glPolygonStipple. - */ -#define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156 - -/** - * To keep the implementation fast, the code uses a "limit" pointer - * to determine when the drawing command buffer is too full to hold - * another fixed size command. This constant defines the amount of - * space that must always be available in the drawing command buffer - * at all times for the implementation to work. It is important that - * the number be just large enough, but not so large as to reduce the - * efficacy of the buffer. The "+32" is just to keep the code working - * in case somebody counts wrong. - */ -#define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32) - -/** - * This implementation uses a smaller threshold for switching - * to the RenderLarge protocol than the protcol requires so that - * large copies don't occur. - */ -#define __GLX_RENDER_CMD_SIZE_LIMIT 4096 - -/** - * One of these records exists per screen of the display. It contains - * a pointer to the config data for that screen (if the screen supports GL). - */ -struct __GLXscreenConfigsRec -{ - /** - * GLX extension string reported by the X-server. - */ - const char *serverGLXexts; - - /** - * GLX extension string to be reported to applications. This is the - * set of extensions that the application can actually use. - */ - char *effectiveGLXexts; - -#ifdef GLX_DIRECT_RENDERING - /** - * Per screen direct rendering interface functions and data. - */ - __DRIscreen *__driScreen; - const __DRIcoreExtension *core; - const __DRIlegacyExtension *legacy; - const __DRIswrastExtension *swrast; - const __DRIdri2Extension *dri2; - __glxHashTable *drawHash; - Display *dpy; - int scr, fd; - void *driver; - - __GLXDRIscreen *driScreen; - - const __DRIconfig **driver_configs; - -#ifdef __DRI_COPY_SUB_BUFFER - const __DRIcopySubBufferExtension *driCopySubBuffer; -#endif - -#ifdef __DRI_SWAP_CONTROL - const __DRIswapControlExtension *swapControl; -#endif - -#ifdef __DRI_ALLOCATE - const __DRIallocateExtension *allocate; -#endif - -#ifdef __DRI_FRAME_TRACKING - const __DRIframeTrackingExtension *frameTracking; -#endif - -#ifdef __DRI_MEDIA_STREAM_COUNTER - const __DRImediaStreamCounterExtension *msc; -#endif - -#ifdef __DRI_TEX_BUFFER - const __DRItexBufferExtension *texBuffer; -#endif - -#ifdef __DRI2_FLUSH - const __DRI2flushExtension *f; -#endif - -#endif - - /** - * Linked list of glx visuals and fbconfigs for this screen. - */ - __GLcontextModes *visuals, *configs; - - /** - * Per-screen dynamic GLX extension tracking. The \c direct_support - * field only contains enough bits for 64 extensions. Should libGL - * ever need to track more than 64 GLX extensions, we can safely grow - * this field. The \c __GLXscreenConfigs structure is not used outside - * libGL. - */ - /*@{ */ - unsigned char direct_support[8]; - GLboolean ext_list_first_time; - /*@} */ - -}; - -/** - * Per display private data. One of these records exists for each display - * that is using the OpenGL (GLX) extension. - */ -struct __GLXdisplayPrivateRec -{ - /** - * Back pointer to the display - */ - Display *dpy; - - /** - * The \c majorOpcode is common to all connections to the same server. - * It is also copied into the context structure. - */ - int majorOpcode; - - /** - * \name Server Version - * - * Major and minor version returned by the server during initialization. - */ - /*@{ */ - int majorVersion, minorVersion; - /*@} */ - - /** - * \name Storage for the servers GLX vendor and versions strings. - * - * These are the same for all screens on this display. These fields will - * be filled in on demand. - */ - /*@{ */ - const char *serverGLXvendor; - const char *serverGLXversion; - /*@} */ - - /** - * Configurations of visuals for all screens on this display. - * Also, per screen data which now includes the server \c GLX_EXTENSION - * string. - */ - __GLXscreenConfigs *screenConfigs; - -#ifdef GLX_DIRECT_RENDERING - /** - * Per display direct rendering interface functions and data. - */ - __GLXDRIdisplay *driswDisplay; - __GLXDRIdisplay *driDisplay; - __GLXDRIdisplay *dri2Display; -#endif -}; - - -extern GLubyte *__glXFlushRenderBuffer(__GLXcontext *, GLubyte *); - -extern void __glXSendLargeChunk(__GLXcontext * gc, GLint requestNumber, - GLint totalRequests, - const GLvoid * data, GLint dataLen); - -extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint, - const GLvoid *, GLint); - -/* Initialize the GLX extension for dpy */ -extern __GLXdisplayPrivate *__glXInitialize(Display *); - -extern void __glXPreferEGL(int state); - -/************************************************************************/ - -extern int __glXDebug; - -/* This is per-thread storage in an MT environment */ -#if defined( PTHREADS ) - -extern void __glXSetCurrentContext(__GLXcontext * c); - -# if defined( GLX_USE_TLS ) - -extern __thread void *__glX_tls_Context - __attribute__ ((tls_model("initial-exec"))); - -# define __glXGetCurrentContext() __glX_tls_Context - -# else - -extern __GLXcontext *__glXGetCurrentContext(void); - -# endif /* defined( GLX_USE_TLS ) */ - -#else - -extern __GLXcontext *__glXcurrentContext; -#define __glXGetCurrentContext() __glXcurrentContext -#define __glXSetCurrentContext(gc) __glXcurrentContext = gc - -#endif /* defined( PTHREADS ) */ - -extern void __glXSetCurrentContextNull(void); - -extern void __glXFreeContext(__GLXcontext *); - - -/* -** Global lock for all threads in this address space using the GLX -** extension -*/ -#if defined( PTHREADS ) -extern pthread_mutex_t __glXmutex; -#define __glXLock() pthread_mutex_lock(&__glXmutex) -#define __glXUnlock() pthread_mutex_unlock(&__glXmutex) -#else -#define __glXLock() -#define __glXUnlock() -#endif - -/* -** Setup for a command. Initialize the extension for dpy if necessary. -*/ -extern CARD8 __glXSetupForCommand(Display * dpy); - -/************************************************************************/ - -/* -** Data conversion and packing support. -*/ - -extern const GLuint __glXDefaultPixelStore[9]; - -/* Send an image to the server using RenderLarge. */ -extern void __glXSendLargeImage(__GLXcontext * gc, GLint compsize, GLint dim, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, - const GLvoid * src, GLubyte * pc, - GLubyte * modes); - -/* Return the size, in bytes, of some pixel data */ -extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum, GLenum); - -/* Return the number of elements per group of a specified format*/ -extern GLint __glElementsPerGroup(GLenum format, GLenum type); - -/* Return the number of bytes per element, based on the element type (other -** than GL_BITMAP). -*/ -extern GLint __glBytesPerElement(GLenum type); - -/* -** Fill the transport buffer with the data from the users buffer, -** applying some of the pixel store modes (unpack modes) to the data -** first. As a side effect of this call, the "modes" field is -** updated to contain the modes needed by the server to decode the -** sent data. -*/ -extern void __glFillImage(__GLXcontext *, GLint, GLint, GLint, GLint, GLenum, - GLenum, const GLvoid *, GLubyte *, GLubyte *); - -/* Copy map data with a stride into a packed buffer */ -extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *); -extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *); -extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint, - const GLfloat *, GLfloat *); -extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint, - const GLdouble *, GLdouble *); - -/* -** Empty an image out of the reply buffer into the clients memory applying -** the pack modes to pack back into the clients requested format. -*/ -extern void __glEmptyImage(__GLXcontext *, GLint, GLint, GLint, GLint, GLenum, - GLenum, const GLubyte *, GLvoid *); - - -/* -** Allocate and Initialize Vertex Array client state, and free. -*/ -extern void __glXInitVertexArrayState(__GLXcontext *); -extern void __glXFreeVertexArrayState(__GLXcontext *); - -/* -** Inform the Server of the major and minor numbers and of the client -** libraries extension string. -*/ -extern void __glXClientInfo(Display * dpy, int opcode); - -/************************************************************************/ - -/* -** Declarations that should be in Xlib -*/ -#ifdef __GL_USE_OUR_PROTOTYPES -extern void _XFlush(Display *); -extern Status _XReply(Display *, xReply *, int, Bool); -extern void _XRead(Display *, void *, long); -extern void _XSend(Display *, const void *, long); -#endif - - -extern void __glXInitializeVisualConfigFromTags(__GLcontextModes * config, - int count, const INT32 * bp, - Bool tagged_only, - Bool fbconfig_style_tags); - -extern char *__glXQueryServerString(Display * dpy, int opcode, - CARD32 screen, CARD32 name); -extern char *__glXGetString(Display * dpy, int opcode, - CARD32 screen, CARD32 name); - -extern char *__glXstrdup(const char *str); - - -extern const char __glXGLClientVersion[]; -extern const char __glXGLClientExtensions[]; - -/* Get the unadjusted system time */ -extern int __glXGetUST(int64_t * ust); - -extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, - int32_t * numerator, - int32_t * denominator); - -#ifdef GLX_DIRECT_RENDERING -GLboolean -__driGetMscRateOML(__DRIdrawable * draw, - int32_t * numerator, int32_t * denominator, void *private); - -/* So that dri2.c:DRI2WireToEvent() can access - * glx_info->codes->first_event */ -XExtDisplayInfo *__glXFindDisplay (Display *dpy); -#endif - -#endif /* !__GLX_client_h__ */ diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c deleted file mode 100644 index c3be974ea91..00000000000 --- a/src/glx/x11/glxcmds.c +++ /dev/null @@ -1,3173 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -/** - * \file glxcmds.c - * Client-side GLX interface. - */ - -#include "glxclient.h" -#include "glapi.h" -#include "glxextensions.h" -#include "glcontextmodes.h" - -#ifdef GLX_DIRECT_RENDERING -#include -#include -#include "xf86dri.h" -#endif - -#if defined(USE_XCB) -#include -#include -#include -#endif - -static const char __glXGLXClientVendorName[] = "Mesa Project and SGI"; -static const char __glXGLXClientVersion[] = "1.4"; - - -/****************************************************************************/ - -#ifdef GLX_DIRECT_RENDERING - -static Bool windowExistsFlag; -static int -windowExistsErrorHandler(Display * dpy, XErrorEvent * xerr) -{ - if (xerr->error_code == BadWindow) { - windowExistsFlag = GL_FALSE; - } - return 0; -} - -/** - * Find drawables in the local hash that have been destroyed on the - * server. - * - * \param dpy Display to destroy drawables for - * \param screen Screen number to destroy drawables for - */ -static void -GarbageCollectDRIDrawables(Display * dpy, __GLXscreenConfigs * sc) -{ - XID draw; - __GLXDRIdrawable *pdraw; - XWindowAttributes xwa; - int (*oldXErrorHandler) (Display *, XErrorEvent *); - - /* Set no-op error handler so Xlib doesn't bail out if the windows - * has alreay been destroyed on the server. */ - XSync(dpy, GL_FALSE); - oldXErrorHandler = XSetErrorHandler(windowExistsErrorHandler); - - if (__glxHashFirst(sc->drawHash, &draw, (void *) &pdraw) == 1) { - do { - windowExistsFlag = GL_TRUE; - XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */ - if (!windowExistsFlag) { - /* Destroy the local drawable data, if the drawable no - longer exists in the Xserver */ - (*pdraw->destroyDrawable) (pdraw); - __glxHashDelete(sc->drawHash, draw); - } - } while (__glxHashNext(sc->drawHash, &draw, (void *) &pdraw) == 1); - } - - XSync(dpy, GL_FALSE); - XSetErrorHandler(oldXErrorHandler); -} - -extern __GLXDRIdrawable *GetGLXDRIDrawable(Display * dpy, - GLXDrawable drawable, - int *const scrn_num); - -/** - * Get the __DRIdrawable for the drawable associated with a GLXContext - * - * \param dpy The display associated with \c drawable. - * \param drawable GLXDrawable whose __DRIdrawable part is to be retrieved. - * \param scrn_num If non-NULL, the drawables screen is stored there - * \returns A pointer to the context's __DRIdrawable on success, or NULL if - * the drawable is not associated with a direct-rendering context. - */ -_X_HIDDEN __GLXDRIdrawable * -GetGLXDRIDrawable(Display * dpy, GLXDrawable drawable, int *const scrn_num) -{ - __GLXdisplayPrivate *priv = __glXInitialize(dpy); - __GLXDRIdrawable *pdraw; - const unsigned screen_count = ScreenCount(dpy); - unsigned i; - __GLXscreenConfigs *psc; - - if (priv == NULL) - return NULL; - - for (i = 0; i < screen_count; i++) { - psc = &priv->screenConfigs[i]; - if (psc->drawHash == NULL) - continue; - - if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0) { - if (scrn_num != NULL) - *scrn_num = i; - return pdraw; - } - } - - return NULL; -} - -#endif - - -/** - * Get the GLX per-screen data structure associated with a GLX context. - * - * \param dpy Display for which the GLX per-screen information is to be - * retrieved. - * \param scrn Screen on \c dpy for which the GLX per-screen information is - * to be retrieved. - * \returns A pointer to the GLX per-screen data if \c dpy and \c scrn - * specify a valid GLX screen, or NULL otherwise. - * - * \todo Should this function validate that \c scrn is within the screen - * number range for \c dpy? - */ - -static __GLXscreenConfigs * -GetGLXScreenConfigs(Display * dpy, int scrn) -{ - __GLXdisplayPrivate *const priv = __glXInitialize(dpy); - - return (priv - && priv->screenConfigs != - NULL) ? &priv->screenConfigs[scrn] : NULL; -} - - -static int -GetGLXPrivScreenConfig(Display * dpy, int scrn, __GLXdisplayPrivate ** ppriv, - __GLXscreenConfigs ** ppsc) -{ - /* Initialize the extension, if needed . This has the added value - * of initializing/allocating the display private - */ - - if (dpy == NULL) { - return GLX_NO_EXTENSION; - } - - *ppriv = __glXInitialize(dpy); - if (*ppriv == NULL) { - return GLX_NO_EXTENSION; - } - - /* Check screen number to see if its valid */ - if ((scrn < 0) || (scrn >= ScreenCount(dpy))) { - return GLX_BAD_SCREEN; - } - - /* Check to see if the GL is supported on this screen */ - *ppsc = &((*ppriv)->screenConfigs[scrn]); - if ((*ppsc)->configs == NULL) { - /* No support for GL on this screen regardless of visual */ - return GLX_BAD_VISUAL; - } - - return Success; -} - - -/** - * Determine if a \c GLXFBConfig supplied by the application is valid. - * - * \param dpy Application supplied \c Display pointer. - * \param config Application supplied \c GLXFBConfig. - * - * \returns If the \c GLXFBConfig is valid, the a pointer to the matching - * \c __GLcontextModes structure is returned. Otherwise, \c NULL - * is returned. - */ -static __GLcontextModes * -ValidateGLXFBConfig(Display * dpy, GLXFBConfig config) -{ - __GLXdisplayPrivate *const priv = __glXInitialize(dpy); - const unsigned num_screens = ScreenCount(dpy); - unsigned i; - const __GLcontextModes *modes; - - - if (priv != NULL) { - for (i = 0; i < num_screens; i++) { - for (modes = priv->screenConfigs[i].configs; modes != NULL; - modes = modes->next) { - if (modes == (__GLcontextModes *) config) { - return (__GLcontextModes *) config; - } - } - } - } - - return NULL; -} - - -/** - * \todo It should be possible to move the allocate of \c client_state_private - * later in the function for direct-rendering contexts. Direct-rendering - * contexts don't need to track client state, so they don't need that memory - * at all. - * - * \todo Eliminate \c __glXInitVertexArrayState. Replace it with a new - * function called \c __glXAllocateClientState that allocates the memory and - * does all the initialization (including the pixel pack / unpack). - */ -static GLXContext -AllocateGLXContext(Display * dpy) -{ - GLXContext gc; - int bufSize; - CARD8 opcode; - __GLXattribute *state; - - if (!dpy) - return NULL; - - opcode = __glXSetupForCommand(dpy); - if (!opcode) { - return NULL; - } - - /* Allocate our context record */ - gc = (GLXContext) Xmalloc(sizeof(struct __GLXcontextRec)); - if (!gc) { - /* Out of memory */ - return NULL; - } - memset(gc, 0, sizeof(struct __GLXcontextRec)); - - state = Xmalloc(sizeof(struct __GLXattributeRec)); - if (state == NULL) { - /* Out of memory */ - Xfree(gc); - return NULL; - } - gc->client_state_private = state; - memset(gc->client_state_private, 0, sizeof(struct __GLXattributeRec)); - state->NoDrawArraysProtocol = (getenv("LIBGL_NO_DRAWARRAYS") != NULL); - - /* - ** Create a temporary buffer to hold GLX rendering commands. The size - ** of the buffer is selected so that the maximum number of GLX rendering - ** commands can fit in a single X packet and still have room in the X - ** packet for the GLXRenderReq header. - */ - - bufSize = (XMaxRequestSize(dpy) * 4) - sz_xGLXRenderReq; - gc->buf = (GLubyte *) Xmalloc(bufSize); - if (!gc->buf) { - Xfree(gc->client_state_private); - Xfree(gc); - return NULL; - } - gc->bufSize = bufSize; - - /* Fill in the new context */ - gc->renderMode = GL_RENDER; - - state->storePack.alignment = 4; - state->storeUnpack.alignment = 4; - - gc->attributes.stackPointer = &gc->attributes.stack[0]; - - /* - ** PERFORMANCE NOTE: A mode dependent fill image can speed things up. - ** Other code uses the fastImageUnpack bit, but it is never set - ** to GL_TRUE. - */ - gc->fastImageUnpack = GL_FALSE; - gc->fillImage = __glFillImage; - gc->pc = gc->buf; - gc->bufEnd = gc->buf + bufSize; - gc->isDirect = GL_FALSE; - if (__glXDebug) { - /* - ** Set limit register so that there will be one command per packet - */ - gc->limit = gc->buf; - } - else { - gc->limit = gc->buf + bufSize - __GLX_BUFFER_LIMIT_SIZE; - } - gc->createDpy = dpy; - gc->majorOpcode = opcode; - - /* - ** Constrain the maximum drawing command size allowed to be - ** transfered using the X_GLXRender protocol request. First - ** constrain by a software limit, then constrain by the protocl - ** limit. - */ - if (bufSize > __GLX_RENDER_CMD_SIZE_LIMIT) { - bufSize = __GLX_RENDER_CMD_SIZE_LIMIT; - } - if (bufSize > __GLX_MAX_RENDER_CMD_SIZE) { - bufSize = __GLX_MAX_RENDER_CMD_SIZE; - } - gc->maxSmallRenderCommandSize = bufSize; - return gc; -} - - -/** - * Create a new context. Exactly one of \c vis and \c fbconfig should be - * non-NULL. - * - * \param use_glx_1_3 For FBConfigs, should GLX 1.3 protocol or - * SGIX_fbconfig protocol be used? - * \param renderType For FBConfigs, what is the rendering type? - */ - -static GLXContext -CreateContext(Display * dpy, XVisualInfo * vis, - const __GLcontextModes * const fbconfig, - GLXContext shareList, - Bool allowDirect, GLXContextID contextID, - Bool use_glx_1_3, int renderType) -{ - GLXContext gc; -#ifdef GLX_DIRECT_RENDERING - int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen; - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); -#endif - - if (dpy == NULL) - return NULL; - - gc = AllocateGLXContext(dpy); - if (!gc) - return NULL; - - if (None == contextID) { - if ((vis == NULL) && (fbconfig == NULL)) - return NULL; - -#ifdef GLX_DIRECT_RENDERING - if (allowDirect && psc->driScreen) { - const __GLcontextModes *mode; - - if (fbconfig == NULL) { - mode = _gl_context_modes_find_visual(psc->visuals, vis->visualid); - if (mode == NULL) { - xError error; - - error.errorCode = BadValue; - error.resourceID = vis->visualid; - error.sequenceNumber = dpy->request; - error.type = X_Error; - error.majorCode = gc->majorOpcode; - error.minorCode = X_GLXCreateContext; - _XError(dpy, &error); - return None; - } - if (renderType == 0) { - /* Initialize renderType now */ - renderType = mode->rgbMode ? GLX_RGBA_TYPE : GLX_COLOR_INDEX_TYPE; - } - } - else { - mode = fbconfig; - } - - gc->driContext = psc->driScreen->createContext(psc, mode, gc, - shareList, - renderType); - if (gc->driContext != NULL) { - gc->screen = mode->screen; - gc->psc = psc; - gc->mode = mode; - gc->isDirect = GL_TRUE; - } - } -#endif - - LockDisplay(dpy); - if (fbconfig == NULL) { - xGLXCreateContextReq *req; - - /* Send the glXCreateContext request */ - GetReq(GLXCreateContext, req); - req->reqType = gc->majorOpcode; - req->glxCode = X_GLXCreateContext; - req->context = gc->xid = XAllocID(dpy); - req->visual = vis->visualid; - req->screen = vis->screen; - req->shareList = shareList ? shareList->xid : None; -#ifdef GLX_DIRECT_RENDERING - req->isDirect = gc->driContext != NULL; -#else - req->isDirect = 0; -#endif - } - else if (use_glx_1_3) { - xGLXCreateNewContextReq *req; - - /* Send the glXCreateNewContext request */ - GetReq(GLXCreateNewContext, req); - req->reqType = gc->majorOpcode; - req->glxCode = X_GLXCreateNewContext; - req->context = gc->xid = XAllocID(dpy); - req->fbconfig = fbconfig->fbconfigID; - req->screen = fbconfig->screen; - req->renderType = renderType; - req->shareList = shareList ? shareList->xid : None; -#ifdef GLX_DIRECT_RENDERING - req->isDirect = gc->driContext != NULL; -#else - req->isDirect = 0; -#endif - } - else { - xGLXVendorPrivateWithReplyReq *vpreq; - xGLXCreateContextWithConfigSGIXReq *req; - - /* Send the glXCreateNewContext request */ - GetReqExtra(GLXVendorPrivateWithReply, - sz_xGLXCreateContextWithConfigSGIXReq - - sz_xGLXVendorPrivateWithReplyReq, vpreq); - req = (xGLXCreateContextWithConfigSGIXReq *) vpreq; - req->reqType = gc->majorOpcode; - req->glxCode = X_GLXVendorPrivateWithReply; - req->vendorCode = X_GLXvop_CreateContextWithConfigSGIX; - req->context = gc->xid = XAllocID(dpy); - req->fbconfig = fbconfig->fbconfigID; - req->screen = fbconfig->screen; - req->renderType = renderType; - req->shareList = shareList ? shareList->xid : None; -#ifdef GLX_DIRECT_RENDERING - req->isDirect = gc->driContext != NULL; -#else - req->isDirect = 0; -#endif - } - - UnlockDisplay(dpy); - SyncHandle(); - gc->imported = GL_FALSE; - } - else { - gc->xid = contextID; - gc->imported = GL_TRUE; - } - - gc->renderType = renderType; - - return gc; -} - -PUBLIC GLXContext -glXCreateContext(Display * dpy, XVisualInfo * vis, - GLXContext shareList, Bool allowDirect) -{ - return CreateContext(dpy, vis, NULL, shareList, allowDirect, None, - False, 0); -} - -_X_HIDDEN void -__glXFreeContext(__GLXcontext * gc) -{ - if (gc->vendor) - XFree((char *) gc->vendor); - if (gc->renderer) - XFree((char *) gc->renderer); - if (gc->version) - XFree((char *) gc->version); - if (gc->extensions) - XFree((char *) gc->extensions); - __glFreeAttributeState(gc); - XFree((char *) gc->buf); - Xfree((char *) gc->client_state_private); - XFree((char *) gc); - -} - -/* -** Destroy the named context -*/ -static void -DestroyContext(Display * dpy, GLXContext gc) -{ - xGLXDestroyContextReq *req; - GLXContextID xid; - CARD8 opcode; - GLboolean imported; - - opcode = __glXSetupForCommand(dpy); - if (!opcode || !gc) { - return; - } - - __glXLock(); - xid = gc->xid; - imported = gc->imported; - gc->xid = None; - - if (gc->currentDpy) { - /* This context is bound to some thread. According to the man page, - * we should not actually delete the context until it's unbound. - * Note that we set gc->xid = None above. In MakeContextCurrent() - * we check for that and delete the context there. - */ - __glXUnlock(); - return; - } - -#ifdef GLX_DIRECT_RENDERING - /* Destroy the direct rendering context */ - if (gc->driContext) { - (*gc->driContext->destroyContext) (gc->driContext, gc->psc, dpy); - gc->driContext = NULL; - GarbageCollectDRIDrawables(dpy, gc->psc); - } -#endif - - __glXFreeVertexArrayState(gc); - - if (gc->currentDpy) { - /* Have to free later cuz it's in use now */ - __glXUnlock(); - } - else { - /* Destroy the handle if not current to anybody */ - __glXUnlock(); - __glXFreeContext(gc); - } - - if (!imported) { - /* - ** This dpy also created the server side part of the context. - ** Send the glXDestroyContext request. - */ - LockDisplay(dpy); - GetReq(GLXDestroyContext, req); - req->reqType = opcode; - req->glxCode = X_GLXDestroyContext; - req->context = xid; - UnlockDisplay(dpy); - SyncHandle(); - } -} - -PUBLIC void -glXDestroyContext(Display * dpy, GLXContext gc) -{ - DestroyContext(dpy, gc); -} - -/* -** Return the major and minor version #s for the GLX extension -*/ -PUBLIC Bool -glXQueryVersion(Display * dpy, int *major, int *minor) -{ - __GLXdisplayPrivate *priv; - - /* Init the extension. This fetches the major and minor version. */ - priv = __glXInitialize(dpy); - if (!priv) - return GL_FALSE; - - if (major) - *major = priv->majorVersion; - if (minor) - *minor = priv->minorVersion; - return GL_TRUE; -} - -/* -** Query the existance of the GLX extension -*/ -PUBLIC Bool -glXQueryExtension(Display * dpy, int *errorBase, int *eventBase) -{ - int major_op, erb, evb; - Bool rv; - - rv = XQueryExtension(dpy, GLX_EXTENSION_NAME, &major_op, &evb, &erb); - if (rv) { - if (errorBase) - *errorBase = erb; - if (eventBase) - *eventBase = evb; - } - return rv; -} - -/* -** Put a barrier in the token stream that forces the GL to finish its -** work before X can proceed. -*/ -PUBLIC void -glXWaitGL(void) -{ - xGLXWaitGLReq *req; - GLXContext gc = __glXGetCurrentContext(); - Display *dpy = gc->currentDpy; - - if (!dpy) - return; - - /* Flush any pending commands out */ - __glXFlushRenderBuffer(gc, gc->pc); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - int screen; - __GLXDRIdrawable *pdraw = - GetGLXDRIDrawable(dpy, gc->currentDrawable, &screen); - - if (pdraw != NULL) { - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); - glFlush(); - if (psc->driScreen->waitGL != NULL) - (*psc->driScreen->waitGL) (pdraw); - } - return; - } -#endif - - /* Send the glXWaitGL request */ - LockDisplay(dpy); - GetReq(GLXWaitGL, req); - req->reqType = gc->majorOpcode; - req->glxCode = X_GLXWaitGL; - req->contextTag = gc->currentContextTag; - UnlockDisplay(dpy); - SyncHandle(); -} - -/* -** Put a barrier in the token stream that forces X to finish its -** work before GL can proceed. -*/ -PUBLIC void -glXWaitX(void) -{ - xGLXWaitXReq *req; - GLXContext gc = __glXGetCurrentContext(); - Display *dpy = gc->currentDpy; - - if (!dpy) - return; - - /* Flush any pending commands out */ - __glXFlushRenderBuffer(gc, gc->pc); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - int screen; - __GLXDRIdrawable *pdraw = - GetGLXDRIDrawable(dpy, gc->currentDrawable, &screen); - - if (pdraw != NULL) { - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); - if (psc->driScreen->waitX != NULL) - (*psc->driScreen->waitX) (pdraw); - } - else - XSync(dpy, False); - return; - } -#endif - - /* - ** Send the glXWaitX request. - */ - LockDisplay(dpy); - GetReq(GLXWaitX, req); - req->reqType = gc->majorOpcode; - req->glxCode = X_GLXWaitX; - req->contextTag = gc->currentContextTag; - UnlockDisplay(dpy); - SyncHandle(); -} - -PUBLIC void -glXUseXFont(Font font, int first, int count, int listBase) -{ - xGLXUseXFontReq *req; - GLXContext gc = __glXGetCurrentContext(); - Display *dpy = gc->currentDpy; - - if (!dpy) - return; - - /* Flush any pending commands out */ - (void) __glXFlushRenderBuffer(gc, gc->pc); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - DRI_glXUseXFont(font, first, count, listBase); - return; - } -#endif - - /* Send the glXUseFont request */ - LockDisplay(dpy); - GetReq(GLXUseXFont, req); - req->reqType = gc->majorOpcode; - req->glxCode = X_GLXUseXFont; - req->contextTag = gc->currentContextTag; - req->font = font; - req->first = first; - req->count = count; - req->listBase = listBase; - UnlockDisplay(dpy); - SyncHandle(); -} - -/************************************************************************/ - -/* -** Copy the source context to the destination context using the -** attribute "mask". -*/ -PUBLIC void -glXCopyContext(Display * dpy, GLXContext source, - GLXContext dest, unsigned long mask) -{ - xGLXCopyContextReq *req; - GLXContext gc = __glXGetCurrentContext(); - GLXContextTag tag; - CARD8 opcode; - - opcode = __glXSetupForCommand(dpy); - if (!opcode) { - return; - } - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - /* NOT_DONE: This does not work yet */ - } -#endif - - /* - ** If the source is the current context, send its tag so that the context - ** can be flushed before the copy. - */ - if (source == gc && dpy == gc->currentDpy) { - tag = gc->currentContextTag; - } - else { - tag = 0; - } - - /* Send the glXCopyContext request */ - LockDisplay(dpy); - GetReq(GLXCopyContext, req); - req->reqType = opcode; - req->glxCode = X_GLXCopyContext; - req->source = source ? source->xid : None; - req->dest = dest ? dest->xid : None; - req->mask = mask; - req->contextTag = tag; - UnlockDisplay(dpy); - SyncHandle(); -} - - -/** - * Determine if a context uses direct rendering. - * - * \param dpy Display where the context was created. - * \param contextID ID of the context to be tested. - * - * \returns \c GL_TRUE if the context is direct rendering or not. - */ -static Bool -__glXIsDirect(Display * dpy, GLXContextID contextID) -{ -#if !defined(USE_XCB) - xGLXIsDirectReq *req; - xGLXIsDirectReply reply; -#endif - CARD8 opcode; - - opcode = __glXSetupForCommand(dpy); - if (!opcode) { - return GL_FALSE; - } - -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - xcb_glx_is_direct_reply_t *reply = xcb_glx_is_direct_reply(c, - xcb_glx_is_direct - (c, contextID), - NULL); - - const Bool is_direct = reply->is_direct ? True : False; - free(reply); - - return is_direct; -#else - /* Send the glXIsDirect request */ - LockDisplay(dpy); - GetReq(GLXIsDirect, req); - req->reqType = opcode; - req->glxCode = X_GLXIsDirect; - req->context = contextID; - _XReply(dpy, (xReply *) & reply, 0, False); - UnlockDisplay(dpy); - SyncHandle(); - - return reply.isDirect; -#endif /* USE_XCB */ -} - -/** - * \todo - * Shouldn't this function \b always return \c GL_FALSE when - * \c GLX_DIRECT_RENDERING is not defined? Do we really need to bother with - * the GLX protocol here at all? - */ -PUBLIC Bool -glXIsDirect(Display * dpy, GLXContext gc) -{ - if (!gc) { - return GL_FALSE; -#ifdef GLX_DIRECT_RENDERING - } - else if (gc->driContext) { - return GL_TRUE; -#endif - } - return __glXIsDirect(dpy, gc->xid); -} - -PUBLIC GLXPixmap -glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap) -{ - xGLXCreateGLXPixmapReq *req; - GLXPixmap xid; - CARD8 opcode; - - opcode = __glXSetupForCommand(dpy); - if (!opcode) { - return None; - } - - /* Send the glXCreateGLXPixmap request */ - LockDisplay(dpy); - GetReq(GLXCreateGLXPixmap, req); - req->reqType = opcode; - req->glxCode = X_GLXCreateGLXPixmap; - req->screen = vis->screen; - req->visual = vis->visualid; - req->pixmap = pixmap; - req->glxpixmap = xid = XAllocID(dpy); - UnlockDisplay(dpy); - SyncHandle(); - -#ifdef GLX_DIRECT_RENDERING - do { - /* FIXME: Maybe delay __DRIdrawable creation until the drawable - * is actually bound to a context... */ - - __GLXdisplayPrivate *const priv = __glXInitialize(dpy); - __GLXDRIdrawable *pdraw; - __GLXscreenConfigs *psc; - __GLcontextModes *modes; - - psc = &priv->screenConfigs[vis->screen]; - if (psc->driScreen == NULL) - break; - modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid); - pdraw = psc->driScreen->createDrawable(psc, pixmap, req->glxpixmap, modes); - if (pdraw == NULL) { - fprintf(stderr, "failed to create pixmap\n"); - break; - } - - if (__glxHashInsert(psc->drawHash, req->glxpixmap, pdraw)) { - (*pdraw->destroyDrawable) (pdraw); - return None; /* FIXME: Check what we're supposed to do here... */ - } - } while (0); -#endif - - return xid; -} - -/* -** Destroy the named pixmap -*/ -PUBLIC void -glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap) -{ - xGLXDestroyGLXPixmapReq *req; - CARD8 opcode; - - opcode = __glXSetupForCommand(dpy); - if (!opcode) { - return; - } - - /* Send the glXDestroyGLXPixmap request */ - LockDisplay(dpy); - GetReq(GLXDestroyGLXPixmap, req); - req->reqType = opcode; - req->glxCode = X_GLXDestroyGLXPixmap; - req->glxpixmap = glxpixmap; - UnlockDisplay(dpy); - SyncHandle(); - -#ifdef GLX_DIRECT_RENDERING - { - int screen; - __GLXdisplayPrivate *const priv = __glXInitialize(dpy); - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap, &screen); - __GLXscreenConfigs *psc = &priv->screenConfigs[screen]; - - if (pdraw != NULL) { - (*pdraw->destroyDrawable) (pdraw); - __glxHashDelete(psc->drawHash, glxpixmap); - } - } -#endif -} - -PUBLIC void -glXSwapBuffers(Display * dpy, GLXDrawable drawable) -{ - GLXContext gc; - GLXContextTag tag; - CARD8 opcode; -#ifdef USE_XCB - xcb_connection_t *c; -#else - xGLXSwapBuffersReq *req; -#endif - -#ifdef GLX_DIRECT_RENDERING - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); - - if (pdraw != NULL) { - glFlush(); - (*pdraw->psc->driScreen->swapBuffers)(pdraw, 0, 0, 0); - return; - } -#endif - - opcode = __glXSetupForCommand(dpy); - if (!opcode) { - return; - } - - /* - ** The calling thread may or may not have a current context. If it - ** does, send the context tag so the server can do a flush. - */ - gc = __glXGetCurrentContext(); - if ((gc != NULL) && (dpy == gc->currentDpy) && - ((drawable == gc->currentDrawable) - || (drawable == gc->currentReadable))) { - tag = gc->currentContextTag; - } - else { - tag = 0; - } - -#ifdef USE_XCB - c = XGetXCBConnection(dpy); - xcb_glx_swap_buffers(c, tag, drawable); - xcb_flush(c); -#else - /* Send the glXSwapBuffers request */ - LockDisplay(dpy); - GetReq(GLXSwapBuffers, req); - req->reqType = opcode; - req->glxCode = X_GLXSwapBuffers; - req->drawable = drawable; - req->contextTag = tag; - UnlockDisplay(dpy); - SyncHandle(); - XFlush(dpy); -#endif /* USE_XCB */ -} - - -/* -** Return configuration information for the given display, screen and -** visual combination. -*/ -PUBLIC int -glXGetConfig(Display * dpy, XVisualInfo * vis, int attribute, - int *value_return) -{ - __GLXdisplayPrivate *priv; - __GLXscreenConfigs *psc; - __GLcontextModes *modes; - int status; - - status = GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc); - if (status == Success) { - modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid); - - /* Lookup attribute after first finding a match on the visual */ - if (modes != NULL) { - return _gl_get_context_mode_data(modes, attribute, value_return); - } - - status = GLX_BAD_VISUAL; - } - - /* - ** If we can't find the config for this visual, this visual is not - ** supported by the OpenGL implementation on the server. - */ - if ((status == GLX_BAD_VISUAL) && (attribute == GLX_USE_GL)) { - *value_return = GL_FALSE; - status = Success; - } - - return status; -} - -/************************************************************************/ - -static void -init_fbconfig_for_chooser(__GLcontextModes * config, - GLboolean fbconfig_style_tags) -{ - memset(config, 0, sizeof(__GLcontextModes)); - config->visualID = (XID) GLX_DONT_CARE; - config->visualType = GLX_DONT_CARE; - - /* glXChooseFBConfig specifies different defaults for these two than - * glXChooseVisual. - */ - if (fbconfig_style_tags) { - config->rgbMode = GL_TRUE; - config->doubleBufferMode = GLX_DONT_CARE; - } - - config->visualRating = GLX_DONT_CARE; - config->transparentPixel = GLX_NONE; - config->transparentRed = GLX_DONT_CARE; - config->transparentGreen = GLX_DONT_CARE; - config->transparentBlue = GLX_DONT_CARE; - config->transparentAlpha = GLX_DONT_CARE; - config->transparentIndex = GLX_DONT_CARE; - - config->drawableType = GLX_WINDOW_BIT; - config->renderType = - (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; - config->xRenderable = GLX_DONT_CARE; - config->fbconfigID = (GLXFBConfigID) (GLX_DONT_CARE); - - config->swapMethod = GLX_DONT_CARE; -} - -#define MATCH_DONT_CARE( param ) \ - do { \ - if ( (a-> param != GLX_DONT_CARE) \ - && (a-> param != b-> param) ) { \ - return False; \ - } \ - } while ( 0 ) - -#define MATCH_MINIMUM( param ) \ - do { \ - if ( (a-> param != GLX_DONT_CARE) \ - && (a-> param > b-> param) ) { \ - return False; \ - } \ - } while ( 0 ) - -#define MATCH_EXACT( param ) \ - do { \ - if ( a-> param != b-> param) { \ - return False; \ - } \ - } while ( 0 ) - -/** - * Determine if two GLXFBConfigs are compatible. - * - * \param a Application specified config to test. - * \param b Server specified config to test against \c a. - */ -static Bool -fbconfigs_compatible(const __GLcontextModes * const a, - const __GLcontextModes * const b) -{ - MATCH_DONT_CARE(doubleBufferMode); - MATCH_DONT_CARE(visualType); - MATCH_DONT_CARE(visualRating); - MATCH_DONT_CARE(xRenderable); - MATCH_DONT_CARE(fbconfigID); - MATCH_DONT_CARE(swapMethod); - - MATCH_MINIMUM(rgbBits); - MATCH_MINIMUM(numAuxBuffers); - MATCH_MINIMUM(redBits); - MATCH_MINIMUM(greenBits); - MATCH_MINIMUM(blueBits); - MATCH_MINIMUM(alphaBits); - MATCH_MINIMUM(depthBits); - MATCH_MINIMUM(stencilBits); - MATCH_MINIMUM(accumRedBits); - MATCH_MINIMUM(accumGreenBits); - MATCH_MINIMUM(accumBlueBits); - MATCH_MINIMUM(accumAlphaBits); - MATCH_MINIMUM(sampleBuffers); - MATCH_MINIMUM(maxPbufferWidth); - MATCH_MINIMUM(maxPbufferHeight); - MATCH_MINIMUM(maxPbufferPixels); - MATCH_MINIMUM(samples); - - MATCH_DONT_CARE(stereoMode); - MATCH_EXACT(level); - - if (((a->drawableType & b->drawableType) == 0) - || ((a->renderType & b->renderType) == 0)) { - return False; - } - - - /* There is a bug in a few of the XFree86 DDX drivers. They contain - * visuals with a "transparent type" of 0 when they really mean GLX_NONE. - * Technically speaking, it is a bug in the DDX driver, but there is - * enough of an installed base to work around the problem here. In any - * case, 0 is not a valid value of the transparent type, so we'll treat 0 - * from the app as GLX_DONT_CARE. We'll consider GLX_NONE from the app and - * 0 from the server to be a match to maintain backward compatibility with - * the (broken) drivers. - */ - - if (a->transparentPixel != GLX_DONT_CARE && a->transparentPixel != 0) { - if (a->transparentPixel == GLX_NONE) { - if (b->transparentPixel != GLX_NONE && b->transparentPixel != 0) - return False; - } - else { - MATCH_EXACT(transparentPixel); - } - - switch (a->transparentPixel) { - case GLX_TRANSPARENT_RGB: - MATCH_DONT_CARE(transparentRed); - MATCH_DONT_CARE(transparentGreen); - MATCH_DONT_CARE(transparentBlue); - MATCH_DONT_CARE(transparentAlpha); - break; - - case GLX_TRANSPARENT_INDEX: - MATCH_DONT_CARE(transparentIndex); - break; - - default: - break; - } - } - - return True; -} - - -/* There's some trickly language in the GLX spec about how this is supposed - * to work. Basically, if a given component size is either not specified - * or the requested size is zero, it is supposed to act like PERFER_SMALLER. - * Well, that's really hard to do with the code as-is. This behavior is - * closer to correct, but still not technically right. - */ -#define PREFER_LARGER_OR_ZERO(comp) \ - do { \ - if ( ((*a)-> comp) != ((*b)-> comp) ) { \ - if ( ((*a)-> comp) == 0 ) { \ - return -1; \ - } \ - else if ( ((*b)-> comp) == 0 ) { \ - return 1; \ - } \ - else { \ - return ((*b)-> comp) - ((*a)-> comp) ; \ - } \ - } \ - } while( 0 ) - -#define PREFER_LARGER(comp) \ - do { \ - if ( ((*a)-> comp) != ((*b)-> comp) ) { \ - return ((*b)-> comp) - ((*a)-> comp) ; \ - } \ - } while( 0 ) - -#define PREFER_SMALLER(comp) \ - do { \ - if ( ((*a)-> comp) != ((*b)-> comp) ) { \ - return ((*a)-> comp) - ((*b)-> comp) ; \ - } \ - } while( 0 ) - -/** - * Compare two GLXFBConfigs. This function is intended to be used as the - * compare function passed in to qsort. - * - * \returns If \c a is a "better" config, according to the specification of - * SGIX_fbconfig, a number less than zero is returned. If \c b is - * better, then a number greater than zero is return. If both are - * equal, zero is returned. - * \sa qsort, glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX - */ -static int -fbconfig_compare(const __GLcontextModes * const *const a, - const __GLcontextModes * const *const b) -{ - /* The order of these comparisons must NOT change. It is defined by - * the GLX 1.3 spec and ARB_multisample. - */ - - PREFER_SMALLER(visualSelectGroup); - - /* The sort order for the visualRating is GLX_NONE, GLX_SLOW, and - * GLX_NON_CONFORMANT_CONFIG. It just so happens that this is the - * numerical sort order of the enums (0x8000, 0x8001, and 0x800D). - */ - PREFER_SMALLER(visualRating); - - /* This isn't quite right. It is supposed to compare the sum of the - * components the user specifically set minimums for. - */ - PREFER_LARGER_OR_ZERO(redBits); - PREFER_LARGER_OR_ZERO(greenBits); - PREFER_LARGER_OR_ZERO(blueBits); - PREFER_LARGER_OR_ZERO(alphaBits); - - PREFER_SMALLER(rgbBits); - - if (((*a)->doubleBufferMode != (*b)->doubleBufferMode)) { - /* Prefer single-buffer. - */ - return (!(*a)->doubleBufferMode) ? -1 : 1; - } - - PREFER_SMALLER(numAuxBuffers); - - PREFER_LARGER_OR_ZERO(depthBits); - PREFER_SMALLER(stencilBits); - - /* This isn't quite right. It is supposed to compare the sum of the - * components the user specifically set minimums for. - */ - PREFER_LARGER_OR_ZERO(accumRedBits); - PREFER_LARGER_OR_ZERO(accumGreenBits); - PREFER_LARGER_OR_ZERO(accumBlueBits); - PREFER_LARGER_OR_ZERO(accumAlphaBits); - - PREFER_SMALLER(visualType); - - /* None of the multisample specs say where this comparison should happen, - * so I put it near the end. - */ - PREFER_SMALLER(sampleBuffers); - PREFER_SMALLER(samples); - - /* None of the pbuffer or fbconfig specs say that this comparison needs - * to happen at all, but it seems like it should. - */ - PREFER_LARGER(maxPbufferWidth); - PREFER_LARGER(maxPbufferHeight); - PREFER_LARGER(maxPbufferPixels); - - return 0; -} - - -/** - * Selects and sorts a subset of the supplied configs based on the attributes. - * This function forms to basis of \c glXChooseVisual, \c glXChooseFBConfig, - * and \c glXChooseFBConfigSGIX. - * - * \param configs Array of pointers to possible configs. The elements of - * this array that do not meet the criteria will be set to - * NULL. The remaining elements will be sorted according to - * the various visual / FBConfig selection rules. - * \param num_configs Number of elements in the \c configs array. - * \param attribList Attributes used select from \c configs. This array is - * terminated by a \c None tag. The array can either take - * the form expected by \c glXChooseVisual (where boolean - * tags do not have a value) or by \c glXChooseFBConfig - * (where every tag has a value). - * \param fbconfig_style_tags Selects whether \c attribList is in - * \c glXChooseVisual style or - * \c glXChooseFBConfig style. - * \returns The number of valid elements left in \c configs. - * - * \sa glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX - */ -static int -choose_visual(__GLcontextModes ** configs, int num_configs, - const int *attribList, GLboolean fbconfig_style_tags) -{ - __GLcontextModes test_config; - int base; - int i; - - /* This is a fairly direct implementation of the selection method - * described by GLX_SGIX_fbconfig. Start by culling out all the - * configs that are not compatible with the selected parameter - * list. - */ - - init_fbconfig_for_chooser(&test_config, fbconfig_style_tags); - __glXInitializeVisualConfigFromTags(&test_config, 512, - (const INT32 *) attribList, - GL_TRUE, fbconfig_style_tags); - - base = 0; - for (i = 0; i < num_configs; i++) { - if (fbconfigs_compatible(&test_config, configs[i])) { - configs[base] = configs[i]; - base++; - } - } - - if (base == 0) { - return 0; - } - - if (base < num_configs) { - (void) memset(&configs[base], 0, sizeof(void *) * (num_configs - base)); - } - - /* After the incompatible configs are removed, the resulting - * list is sorted according to the rules set out in the various - * specifications. - */ - - qsort(configs, base, sizeof(__GLcontextModes *), - (int (*)(const void *, const void *)) fbconfig_compare); - return base; -} - - - - -/* -** Return the visual that best matches the template. Return None if no -** visual matches the template. -*/ -PUBLIC XVisualInfo * -glXChooseVisual(Display * dpy, int screen, int *attribList) -{ - XVisualInfo *visualList = NULL; - __GLXdisplayPrivate *priv; - __GLXscreenConfigs *psc; - __GLcontextModes test_config; - __GLcontextModes *modes; - const __GLcontextModes *best_config = NULL; - - /* - ** Get a list of all visuals, return if list is empty - */ - if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) { - return None; - } - - - /* - ** Build a template from the defaults and the attribute list - ** Free visual list and return if an unexpected token is encountered - */ - init_fbconfig_for_chooser(&test_config, GL_FALSE); - __glXInitializeVisualConfigFromTags(&test_config, 512, - (const INT32 *) attribList, - GL_TRUE, GL_FALSE); - - /* - ** Eliminate visuals that don't meet minimum requirements - ** Compute a score for those that do - ** Remember which visual, if any, got the highest score - ** If no visual is acceptable, return None - ** Otherwise, create an XVisualInfo list with just the selected X visual - ** and return this. - */ - for (modes = psc->visuals; modes != NULL; modes = modes->next) { - if (fbconfigs_compatible(&test_config, modes) - && ((best_config == NULL) - || - (fbconfig_compare - ((const __GLcontextModes * const *const) &modes, - &best_config) < 0))) { - XVisualInfo visualTemplate; - XVisualInfo *newList; - int i; - - visualTemplate.screen = screen; - visualTemplate.visualid = modes->visualID; - newList = XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask, - &visualTemplate, &i); - - if (newList) { - Xfree(visualList); - visualList = newList; - best_config = modes; - } - } - } - - return visualList; -} - - -PUBLIC const char * -glXQueryExtensionsString(Display * dpy, int screen) -{ - __GLXscreenConfigs *psc; - __GLXdisplayPrivate *priv; - - if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) { - return NULL; - } - - if (!psc->effectiveGLXexts) { - if (!psc->serverGLXexts) { - psc->serverGLXexts = - __glXQueryServerString(dpy, priv->majorOpcode, screen, - GLX_EXTENSIONS); - } - - __glXCalculateUsableExtensions(psc, -#ifdef GLX_DIRECT_RENDERING - (psc->driScreen != NULL), -#else - GL_FALSE, -#endif - priv->minorVersion); - } - - return psc->effectiveGLXexts; -} - -PUBLIC const char * -glXGetClientString(Display * dpy, int name) -{ - switch (name) { - case GLX_VENDOR: - return (__glXGLXClientVendorName); - case GLX_VERSION: - return (__glXGLXClientVersion); - case GLX_EXTENSIONS: - return (__glXGetClientExtensions()); - default: - return NULL; - } -} - -PUBLIC const char * -glXQueryServerString(Display * dpy, int screen, int name) -{ - __GLXscreenConfigs *psc; - __GLXdisplayPrivate *priv; - const char **str; - - - if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) { - return NULL; - } - - switch (name) { - case GLX_VENDOR: - str = &priv->serverGLXvendor; - break; - case GLX_VERSION: - str = &priv->serverGLXversion; - break; - case GLX_EXTENSIONS: - str = &psc->serverGLXexts; - break; - default: - return NULL; - } - - if (*str == NULL) { - *str = __glXQueryServerString(dpy, priv->majorOpcode, screen, name); - } - - return *str; -} - -void -__glXClientInfo(Display * dpy, int opcode) -{ - char *ext_str = __glXGetClientGLExtensionString(); - int size = strlen(ext_str) + 1; - -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - xcb_glx_client_info(c, - GLX_MAJOR_VERSION, GLX_MINOR_VERSION, size, ext_str); -#else - xGLXClientInfoReq *req; - - /* Send the glXClientInfo request */ - LockDisplay(dpy); - GetReq(GLXClientInfo, req); - req->reqType = opcode; - req->glxCode = X_GLXClientInfo; - req->major = GLX_MAJOR_VERSION; - req->minor = GLX_MINOR_VERSION; - - req->length += (size + 3) >> 2; - req->numbytes = size; - Data(dpy, ext_str, size); - - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - - Xfree(ext_str); -} - - -/* -** EXT_import_context -*/ - -PUBLIC Display * -glXGetCurrentDisplay(void) -{ - GLXContext gc = __glXGetCurrentContext(); - if (NULL == gc) - return NULL; - return gc->currentDpy; -} - -PUBLIC -GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (), - glXGetCurrentDisplay) - -/** - * Used internally by libGL to send \c xGLXQueryContextinfoExtReq requests - * to the X-server. - * - * \param dpy Display where \c ctx was created. - * \param ctx Context to query. - * \returns \c Success on success. \c GLX_BAD_CONTEXT if \c ctx is invalid, - * or zero if the request failed due to internal problems (i.e., - * unable to allocate temporary memory, etc.) - * - * \note - * This function dynamically determines whether to use the EXT_import_context - * version of the protocol or the GLX 1.3 version of the protocol. - */ -static int __glXQueryContextInfo(Display * dpy, GLXContext ctx) -{ - __GLXdisplayPrivate *priv = __glXInitialize(dpy); - xGLXQueryContextReply reply; - CARD8 opcode; - GLuint numValues; - int retval; - - if (ctx == NULL) { - return GLX_BAD_CONTEXT; - } - opcode = __glXSetupForCommand(dpy); - if (!opcode) { - return 0; - } - - /* Send the glXQueryContextInfoEXT request */ - LockDisplay(dpy); - - if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { - xGLXQueryContextReq *req; - - GetReq(GLXQueryContext, req); - - req->reqType = opcode; - req->glxCode = X_GLXQueryContext; - req->context = (unsigned int) (ctx->xid); - } - else { - xGLXVendorPrivateReq *vpreq; - xGLXQueryContextInfoEXTReq *req; - - GetReqExtra(GLXVendorPrivate, - sz_xGLXQueryContextInfoEXTReq - sz_xGLXVendorPrivateReq, - vpreq); - req = (xGLXQueryContextInfoEXTReq *) vpreq; - req->reqType = opcode; - req->glxCode = X_GLXVendorPrivateWithReply; - req->vendorCode = X_GLXvop_QueryContextInfoEXT; - req->context = (unsigned int) (ctx->xid); - } - - _XReply(dpy, (xReply *) & reply, 0, False); - - numValues = reply.n; - if (numValues == 0) - retval = Success; - else if (numValues > __GLX_MAX_CONTEXT_PROPS) - retval = 0; - else { - int *propList, *pProp; - int nPropListBytes; - int i; - - nPropListBytes = numValues << 3; - propList = (int *) Xmalloc(nPropListBytes); - if (NULL == propList) { - retval = 0; - } - else { - _XRead(dpy, (char *) propList, nPropListBytes); - pProp = propList; - for (i = 0; i < numValues; i++) { - switch (*pProp++) { - case GLX_SHARE_CONTEXT_EXT: - ctx->share_xid = *pProp++; - break; - case GLX_VISUAL_ID_EXT: - ctx->mode = - _gl_context_modes_find_visual(ctx->psc->visuals, *pProp++); - break; - case GLX_SCREEN: - ctx->screen = *pProp++; - break; - case GLX_FBCONFIG_ID: - ctx->mode = - _gl_context_modes_find_fbconfig(ctx->psc->configs, - *pProp++); - break; - case GLX_RENDER_TYPE: - ctx->renderType = *pProp++; - break; - default: - pProp++; - continue; - } - } - Xfree((char *) propList); - retval = Success; - } - } - UnlockDisplay(dpy); - SyncHandle(); - return retval; -} - -PUBLIC int -glXQueryContext(Display * dpy, GLXContext ctx, int attribute, int *value) -{ - int retVal; - - /* get the information from the server if we don't have it already */ -#ifdef GLX_DIRECT_RENDERING - if (!ctx->driContext && (ctx->mode == NULL)) { -#else - if (ctx->mode == NULL) { -#endif - retVal = __glXQueryContextInfo(dpy, ctx); - if (Success != retVal) - return retVal; - } - switch (attribute) { - case GLX_SHARE_CONTEXT_EXT: - *value = (int) (ctx->share_xid); - break; - case GLX_VISUAL_ID_EXT: - *value = ctx->mode ? ctx->mode->visualID : None; - break; - case GLX_SCREEN: - *value = (int) (ctx->screen); - break; - case GLX_FBCONFIG_ID: - *value = ctx->mode ? ctx->mode->fbconfigID : None; - break; - case GLX_RENDER_TYPE: - *value = (int) (ctx->renderType); - break; - default: - return GLX_BAD_ATTRIBUTE; - } - return Success; -} - -PUBLIC -GLX_ALIAS(int, glXQueryContextInfoEXT, - (Display * dpy, GLXContext ctx, int attribute, int *value), - (dpy, ctx, attribute, value), glXQueryContext) - -PUBLIC GLXContextID glXGetContextIDEXT(const GLXContext ctx) -{ - return ctx->xid; -} - -PUBLIC GLXContext -glXImportContextEXT(Display * dpy, GLXContextID contextID) -{ - GLXContext ctx; - - if (contextID == None) { - return NULL; - } - if (__glXIsDirect(dpy, contextID)) { - return NULL; - } - - ctx = CreateContext(dpy, NULL, NULL, NULL, False, contextID, False, 0); - if (NULL != ctx) { - if (Success != __glXQueryContextInfo(dpy, ctx)) { - return NULL; - } - } - return ctx; -} - -PUBLIC void -glXFreeContextEXT(Display * dpy, GLXContext ctx) -{ - DestroyContext(dpy, ctx); -} - - - -/* - * GLX 1.3 functions - these are just stubs for now! - */ - -PUBLIC GLXFBConfig * -glXChooseFBConfig(Display * dpy, int screen, - const int *attribList, int *nitems) -{ - __GLcontextModes **config_list; - int list_size; - - - config_list = (__GLcontextModes **) - glXGetFBConfigs(dpy, screen, &list_size); - - if ((config_list != NULL) && (list_size > 0) && (attribList != NULL)) { - list_size = choose_visual(config_list, list_size, attribList, GL_TRUE); - if (list_size == 0) { - XFree(config_list); - config_list = NULL; - } - } - - *nitems = list_size; - return (GLXFBConfig *) config_list; -} - - -PUBLIC GLXContext -glXCreateNewContext(Display * dpy, GLXFBConfig config, - int renderType, GLXContext shareList, Bool allowDirect) -{ - return CreateContext(dpy, NULL, (__GLcontextModes *) config, shareList, - allowDirect, None, True, renderType); -} - - -PUBLIC GLXDrawable -glXGetCurrentReadDrawable(void) -{ - GLXContext gc = __glXGetCurrentContext(); - return gc->currentReadable; -} - - -PUBLIC GLXFBConfig * -glXGetFBConfigs(Display * dpy, int screen, int *nelements) -{ - __GLXdisplayPrivate *priv = __glXInitialize(dpy); - __GLcontextModes **config = NULL; - int i; - - *nelements = 0; - if (priv && (priv->screenConfigs != NULL) - && (screen >= 0) && (screen <= ScreenCount(dpy)) - && (priv->screenConfigs[screen].configs != NULL) - && (priv->screenConfigs[screen].configs->fbconfigID != GLX_DONT_CARE)) { - unsigned num_configs = 0; - __GLcontextModes *modes; - - - for (modes = priv->screenConfigs[screen].configs; modes != NULL; - modes = modes->next) { - if (modes->fbconfigID != GLX_DONT_CARE) { - num_configs++; - } - } - - config = (__GLcontextModes **) Xmalloc(sizeof(__GLcontextModes *) - * num_configs); - if (config != NULL) { - *nelements = num_configs; - i = 0; - for (modes = priv->screenConfigs[screen].configs; modes != NULL; - modes = modes->next) { - if (modes->fbconfigID != GLX_DONT_CARE) { - config[i] = modes; - i++; - } - } - } - } - return (GLXFBConfig *) config; -} - - -PUBLIC int -glXGetFBConfigAttrib(Display * dpy, GLXFBConfig config, - int attribute, int *value) -{ - __GLcontextModes *const modes = ValidateGLXFBConfig(dpy, config); - - return (modes != NULL) - ? _gl_get_context_mode_data(modes, attribute, value) - : GLXBadFBConfig; -} - - -PUBLIC XVisualInfo * -glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig config) -{ - XVisualInfo visualTemplate; - __GLcontextModes *fbconfig = (__GLcontextModes *) config; - int count; - - /* - ** Get a list of all visuals, return if list is empty - */ - visualTemplate.visualid = fbconfig->visualID; - return XGetVisualInfo(dpy, VisualIDMask, &visualTemplate, &count); -} - - -/* -** GLX_SGI_swap_control -*/ -static int -__glXSwapIntervalSGI(int interval) -{ - xGLXVendorPrivateReq *req; - GLXContext gc = __glXGetCurrentContext(); - __GLXscreenConfigs *psc; - Display *dpy; - CARD32 *interval_ptr; - CARD8 opcode; - - if (gc == NULL) { - return GLX_BAD_CONTEXT; - } - - if (interval <= 0) { - return GLX_BAD_VALUE; - } - -#ifdef __DRI_SWAP_CONTROL - if (gc->driContext) { - __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, - gc->screen ); - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, - gc->currentDrawable, - NULL); - if (psc->swapControl != NULL && pdraw != NULL) { - psc->swapControl->setSwapInterval(pdraw->driDrawable, interval); - return 0; - } - else if (pdraw == NULL) { - return GLX_BAD_CONTEXT; - } - } -#endif - psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); - - if (gc->driContext && psc->driScreen && psc->driScreen->setSwapInterval) { - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, - gc->currentDrawable, - NULL); - psc->driScreen->setSwapInterval(pdraw, interval); - return 0; - } - - dpy = gc->currentDpy; - opcode = __glXSetupForCommand(dpy); - if (!opcode) { - return 0; - } - - /* Send the glXSwapIntervalSGI request */ - LockDisplay(dpy); - GetReqExtra(GLXVendorPrivate, sizeof(CARD32), req); - req->reqType = opcode; - req->glxCode = X_GLXVendorPrivate; - req->vendorCode = X_GLXvop_SwapIntervalSGI; - req->contextTag = gc->currentContextTag; - - interval_ptr = (CARD32 *) (req + 1); - *interval_ptr = interval; - - UnlockDisplay(dpy); - SyncHandle(); - XFlush(dpy); - - return 0; -} - - -/* -** GLX_MESA_swap_control -*/ -static int -__glXSwapIntervalMESA(unsigned int interval) -{ - GLXContext gc = __glXGetCurrentContext(); - - if (interval < 0) { - return GLX_BAD_VALUE; - } - -#ifdef __DRI_SWAP_CONTROL - if (gc != NULL && gc->driContext) { - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy, - gc->screen); - - if ((psc != NULL) && (psc->driScreen != NULL)) { - __GLXDRIdrawable *pdraw = - GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); - if (psc->swapControl != NULL && pdraw != NULL) { - psc->swapControl->setSwapInterval(pdraw->driDrawable, interval); - return 0; - } - } - } -#endif - - if (gc != NULL && gc->driContext) { - __GLXscreenConfigs *psc; - - psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); - if (psc->driScreen && psc->driScreen->setSwapInterval) { - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, - gc->currentDrawable, NULL); - psc->driScreen->setSwapInterval(pdraw, interval); - return 0; - } - } - - return GLX_BAD_CONTEXT; -} - - -static int -__glXGetSwapIntervalMESA(void) -{ -#ifdef __DRI_SWAP_CONTROL - GLXContext gc = __glXGetCurrentContext(); - - if (gc != NULL && gc->driContext) { - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy, - gc->screen); - - if ((psc != NULL) && (psc->driScreen != NULL)) { - __GLXDRIdrawable *pdraw = - GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); - if (psc->swapControl != NULL && pdraw != NULL) { - return psc->swapControl->getSwapInterval(pdraw->driDrawable); - } - } - } -#endif - if (gc != NULL && gc->driContext) { - __GLXscreenConfigs *psc; - - psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); - if (psc->driScreen && psc->driScreen->getSwapInterval) { - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, - gc->currentDrawable, NULL); - return psc->driScreen->getSwapInterval(pdraw); - } - } - - return 0; -} - - -/* -** GLX_MESA_swap_frame_usage -*/ - -static GLint -__glXBeginFrameTrackingMESA(Display * dpy, GLXDrawable drawable) -{ - int status = GLX_BAD_CONTEXT; -#ifdef __DRI_FRAME_TRACKING - int screen = 0; - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); - - if (pdraw != NULL && psc->frameTracking != NULL) - status = psc->frameTracking->frameTracking(pdraw->driDrawable, GL_TRUE); -#else - (void) dpy; - (void) drawable; -#endif - return status; -} - - -static GLint -__glXEndFrameTrackingMESA(Display * dpy, GLXDrawable drawable) -{ - int status = GLX_BAD_CONTEXT; -#ifdef __DRI_FRAME_TRACKING - int screen = 0; - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); - __GLXscreenConfigs *psc = GetGLXScreenConfigs(dpy, screen); - - if (pdraw != NULL && psc->frameTracking != NULL) - status = psc->frameTracking->frameTracking(pdraw->driDrawable, - GL_FALSE); -#else - (void) dpy; - (void) drawable; -#endif - return status; -} - - -static GLint -__glXGetFrameUsageMESA(Display * dpy, GLXDrawable drawable, GLfloat * usage) -{ - int status = GLX_BAD_CONTEXT; -#ifdef __DRI_FRAME_TRACKING - int screen = 0; - __GLXDRIdrawable *const pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); - - if (pdraw != NULL && psc->frameTracking != NULL) { - int64_t sbc, missedFrames; - float lastMissedUsage; - - status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable, - &sbc, - &missedFrames, - &lastMissedUsage, - usage); - } -#else - (void) dpy; - (void) drawable; - (void) usage; -#endif - return status; -} - - -static GLint -__glXQueryFrameTrackingMESA(Display * dpy, GLXDrawable drawable, - int64_t * sbc, int64_t * missedFrames, - GLfloat * lastMissedUsage) -{ - int status = GLX_BAD_CONTEXT; -#ifdef __DRI_FRAME_TRACKING - int screen = 0; - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); - - if (pdraw != NULL && psc->frameTracking != NULL) { - float usage; - - status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable, - sbc, missedFrames, - lastMissedUsage, - &usage); - } -#else - (void) dpy; - (void) drawable; - (void) sbc; - (void) missedFrames; - (void) lastMissedUsage; -#endif - return status; -} - - -/* -** GLX_SGI_video_sync -*/ -static int -__glXGetVideoSyncSGI(unsigned int *count) -{ - int64_t ust, msc, sbc; - int ret; - GLXContext gc = __glXGetCurrentContext(); - __GLXscreenConfigs *psc; - __GLXDRIdrawable *pdraw; - - if (!gc || !gc->driContext) - return GLX_BAD_CONTEXT; - - psc = GetGLXScreenConfigs(gc->currentDpy, gc->screen); - pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); - - /* FIXME: Looking at the GLX_SGI_video_sync spec in the extension registry, - * FIXME: there should be a GLX encoding for this call. I can find no - * FIXME: documentation for the GLX encoding. - */ -#ifdef __DRI_MEDIA_STREAM_COUNTER - if ( psc->msc && psc->driScreen ) { - ret = (*psc->msc->getDrawableMSC)(psc->__driScreen, - pdraw->driDrawable, &msc); - *count = (unsigned) msc; - - return (ret == 0) ? 0 : GLX_BAD_CONTEXT; - } -#endif - if (psc->driScreen && psc->driScreen->getDrawableMSC) { - ret = psc->driScreen->getDrawableMSC(psc, pdraw, &ust, &msc, &sbc); - *count = (unsigned) msc; - return (ret == True) ? 0 : GLX_BAD_CONTEXT; - } - - return GLX_BAD_CONTEXT; -} - -static int -__glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) -{ - GLXContext gc = __glXGetCurrentContext(); - __GLXscreenConfigs *psc; - __GLXDRIdrawable *pdraw; - int64_t ust, msc, sbc; - int ret; - - if (divisor <= 0 || remainder < 0) - return GLX_BAD_VALUE; - - if (!gc || !gc->driContext) - return GLX_BAD_CONTEXT; - - psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); - pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); - -#ifdef __DRI_MEDIA_STREAM_COUNTER - if (psc->msc != NULL && psc->driScreen ) { - ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, 0, - divisor, remainder, &msc, &sbc); - *count = (unsigned) msc; - return (ret == 0) ? 0 : GLX_BAD_CONTEXT; - } -#endif - if (psc->driScreen && psc->driScreen->waitForMSC) { - ret = psc->driScreen->waitForMSC(pdraw, 0, divisor, remainder, &ust, &msc, - &sbc); - *count = (unsigned) msc; - return (ret == True) ? 0 : GLX_BAD_CONTEXT; - } - - return GLX_BAD_CONTEXT; -} - - -/* -** GLX_SGIX_fbconfig -** Many of these functions are aliased to GLX 1.3 entry points in the -** GLX_functions table. -*/ - -PUBLIC -GLX_ALIAS(int, glXGetFBConfigAttribSGIX, - (Display * dpy, GLXFBConfigSGIX config, int attribute, int *value), - (dpy, config, attribute, value), glXGetFBConfigAttrib) - -PUBLIC GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX, - (Display * dpy, int screen, int *attrib_list, - int *nelements), (dpy, screen, attrib_list, nelements), - glXChooseFBConfig) - -PUBLIC GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX, - (Display * dpy, GLXFBConfigSGIX config), - (dpy, config), glXGetVisualFromFBConfig) - -PUBLIC GLXPixmap -glXCreateGLXPixmapWithConfigSGIX(Display * dpy, - GLXFBConfigSGIX config, - Pixmap pixmap) -{ - xGLXVendorPrivateWithReplyReq *vpreq; - xGLXCreateGLXPixmapWithConfigSGIXReq *req; - GLXPixmap xid = None; - CARD8 opcode; - const __GLcontextModes *const fbconfig = (__GLcontextModes *) config; - __GLXscreenConfigs *psc; - - - if ((dpy == NULL) || (config == NULL)) { - return None; - } - - psc = GetGLXScreenConfigs(dpy, fbconfig->screen); - if ((psc != NULL) - && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) { - opcode = __glXSetupForCommand(dpy); - if (!opcode) { - return None; - } - - /* Send the glXCreateGLXPixmapWithConfigSGIX request */ - LockDisplay(dpy); - GetReqExtra(GLXVendorPrivateWithReply, - sz_xGLXCreateGLXPixmapWithConfigSGIXReq - - sz_xGLXVendorPrivateWithReplyReq, vpreq); - req = (xGLXCreateGLXPixmapWithConfigSGIXReq *) vpreq; - req->reqType = opcode; - req->glxCode = X_GLXVendorPrivateWithReply; - req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX; - req->screen = fbconfig->screen; - req->fbconfig = fbconfig->fbconfigID; - req->pixmap = pixmap; - req->glxpixmap = xid = XAllocID(dpy); - UnlockDisplay(dpy); - SyncHandle(); - } - - return xid; -} - -PUBLIC GLXContext -glXCreateContextWithConfigSGIX(Display * dpy, - GLXFBConfigSGIX config, int renderType, - GLXContext shareList, Bool allowDirect) -{ - GLXContext gc = NULL; - const __GLcontextModes *const fbconfig = (__GLcontextModes *) config; - __GLXscreenConfigs *psc; - - - if ((dpy == NULL) || (config == NULL)) { - return None; - } - - psc = GetGLXScreenConfigs(dpy, fbconfig->screen); - if ((psc != NULL) - && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) { - gc = CreateContext(dpy, NULL, (__GLcontextModes *) config, shareList, - allowDirect, None, False, renderType); - } - - return gc; -} - - -PUBLIC GLXFBConfigSGIX -glXGetFBConfigFromVisualSGIX(Display * dpy, XVisualInfo * vis) -{ - __GLXdisplayPrivate *priv; - __GLXscreenConfigs *psc = NULL; - - if ((GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc) != Success) - && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit) - && (psc->configs->fbconfigID != GLX_DONT_CARE)) { - return (GLXFBConfigSGIX) _gl_context_modes_find_visual(psc->configs, - vis->visualid); - } - - return NULL; -} - - -/* -** GLX_SGIX_swap_group -*/ -static void -__glXJoinSwapGroupSGIX(Display * dpy, GLXDrawable drawable, - GLXDrawable member) -{ - (void) dpy; - (void) drawable; - (void) member; -} - - -/* -** GLX_SGIX_swap_barrier -*/ -static void -__glXBindSwapBarrierSGIX(Display * dpy, GLXDrawable drawable, int barrier) -{ - (void) dpy; - (void) drawable; - (void) barrier; -} - -static Bool -__glXQueryMaxSwapBarriersSGIX(Display * dpy, int screen, int *max) -{ - (void) dpy; - (void) screen; - (void) max; - return False; -} - - -/* -** GLX_OML_sync_control -*/ -static Bool -__glXGetSyncValuesOML(Display * dpy, GLXDrawable drawable, - int64_t * ust, int64_t * msc, int64_t * sbc) -{ - __GLXdisplayPrivate * const priv = __glXInitialize(dpy); - int i, ret; - __GLXDRIdrawable *pdraw; - __GLXscreenConfigs *psc; - - if (!priv) - return False; - - pdraw = GetGLXDRIDrawable(dpy, drawable, &i); - psc = &priv->screenConfigs[i]; - -#if defined(__DRI_SWAP_BUFFER_COUNTER) && defined(__DRI_MEDIA_STREAM_COUNTER) - if (pdraw && psc->sbc && psc->sbc) - return ( (pdraw && psc->sbc && psc->msc) - && ((*psc->msc->getMSC)(psc->driScreen, msc) == 0) - && ((*psc->sbc->getSBC)(pdraw->driDrawable, sbc) == 0) - && (__glXGetUST(ust) == 0) ); -#endif - if (pdraw && psc && psc->driScreen && psc->driScreen->getDrawableMSC) { - ret = psc->driScreen->getDrawableMSC(psc, pdraw, ust, msc, sbc); - return ret; - } - - return False; -} - -#ifdef GLX_DIRECT_RENDERING -_X_HIDDEN GLboolean -__driGetMscRateOML(__DRIdrawable * draw, - int32_t * numerator, int32_t * denominator, void *private) -{ -#ifdef XF86VIDMODE - __GLXscreenConfigs *psc; - XF86VidModeModeLine mode_line; - int dot_clock; - int i; - __GLXDRIdrawable *glxDraw = private; - - psc = glxDraw->psc; - if (XF86VidModeQueryVersion(psc->dpy, &i, &i) && - XF86VidModeGetModeLine(psc->dpy, psc->scr, &dot_clock, &mode_line)) { - unsigned n = dot_clock * 1000; - unsigned d = mode_line.vtotal * mode_line.htotal; - -# define V_INTERLACE 0x010 -# define V_DBLSCAN 0x020 - - if (mode_line.flags & V_INTERLACE) - n *= 2; - else if (mode_line.flags & V_DBLSCAN) - d *= 2; - - /* The OML_sync_control spec requires that if the refresh rate is a - * whole number, that the returned numerator be equal to the refresh - * rate and the denominator be 1. - */ - - if (n % d == 0) { - n /= d; - d = 1; - } - else { - static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 }; - - /* This is a poor man's way to reduce a fraction. It's far from - * perfect, but it will work well enough for this situation. - */ - - for (i = 0; f[i] != 0; i++) { - while (n % f[i] == 0 && d % f[i] == 0) { - d /= f[i]; - n /= f[i]; - } - } - } - - *numerator = n; - *denominator = d; - - return True; - } - else - return False; -#else - return False; -#endif -} -#endif - -/** - * Determine the refresh rate of the specified drawable and display. - * - * \param dpy Display whose refresh rate is to be determined. - * \param drawable Drawable whose refresh rate is to be determined. - * \param numerator Numerator of the refresh rate. - * \param demoninator Denominator of the refresh rate. - * \return If the refresh rate for the specified display and drawable could - * be calculated, True is returned. Otherwise False is returned. - * - * \note This function is implemented entirely client-side. A lot of other - * functionality is required to export GLX_OML_sync_control, so on - * XFree86 this function can be called for direct-rendering contexts - * when GLX_OML_sync_control appears in the client extension string. - */ - -_X_HIDDEN GLboolean -__glXGetMscRateOML(Display * dpy, GLXDrawable drawable, - int32_t * numerator, int32_t * denominator) -{ -#if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE ) - __GLXDRIdrawable *draw = GetGLXDRIDrawable(dpy, drawable, NULL); - - if (draw == NULL) - return False; - - return __driGetMscRateOML(draw->driDrawable, numerator, denominator, draw); -#else - (void) dpy; - (void) drawable; - (void) numerator; - (void) denominator; -#endif - return False; -} - - -static int64_t -__glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable, - int64_t target_msc, int64_t divisor, int64_t remainder) -{ - GLXContext gc = __glXGetCurrentContext(); - int screen; - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); - - if (!pdraw || !gc->driContext) /* no GLX for this */ - return -1; - - /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE - * error", but it also says "It [glXSwapBuffersMscOML] will return a value - * of -1 if the function failed because of errors detected in the input - * parameters" - */ - if (divisor < 0 || remainder < 0 || target_msc < 0) - return -1; - if (divisor > 0 && remainder >= divisor) - return -1; - -#ifdef __DRI_SWAP_BUFFER_COUNTER - if (psc->counters != NULL) - return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc, - divisor, remainder); -#endif - -#ifdef GLX_DIRECT_RENDERING - if (psc->driScreen && psc->driScreen->swapBuffers) - return (*psc->driScreen->swapBuffers)(pdraw, target_msc, divisor, - remainder); -#endif - - return -1; -} - - -static Bool -__glXWaitForMscOML(Display * dpy, GLXDrawable drawable, - int64_t target_msc, int64_t divisor, - int64_t remainder, int64_t * ust, - int64_t * msc, int64_t * sbc) -{ - int screen; - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); - __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); - int ret; - - fprintf(stderr, "waitmsc: %lld, %lld, %lld\n", target_msc, divisor, - remainder); - - /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE - * error", but the return type in the spec is Bool. - */ - if (divisor < 0 || remainder < 0 || target_msc < 0) - return False; - if (divisor > 0 && remainder >= divisor) - return False; - -#ifdef __DRI_MEDIA_STREAM_COUNTER - if (pdraw != NULL && psc->msc != NULL) { - fprintf(stderr, "dri1 msc\n"); - ret = (*psc->msc->waitForMSC) (pdraw->driDrawable, target_msc, - divisor, remainder, msc, sbc); - - /* __glXGetUST returns zero on success and non-zero on failure. - * This function returns True on success and False on failure. - */ - return ((ret == 0) && (__glXGetUST(ust) == 0)); - } -#endif - if (pdraw && psc->driScreen && psc->driScreen->waitForMSC) { - ret = psc->driScreen->waitForMSC(pdraw, target_msc, divisor, remainder, - ust, msc, sbc); - return ret; - } - - fprintf(stderr, "no drawable??\n"); - return False; -} - - -static Bool -__glXWaitForSbcOML(Display * dpy, GLXDrawable drawable, - int64_t target_sbc, int64_t * ust, - int64_t * msc, int64_t * sbc) -{ - int screen; - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); - int ret; - - /* The OML_sync_control spec says this should "generate a GLX_BAD_VALUE - * error", but the return type in the spec is Bool. - */ - if (target_sbc < 0) - return False; -#ifdef __DRI_SWAP_BUFFER_COUNTER - if (pdraw != NULL && psc->sbc != NULL) { - ret = - (*psc->sbc->waitForSBC) (pdraw->driDrawable, target_sbc, msc, sbc); - - /* __glXGetUST returns zero on success and non-zero on failure. - * This function returns True on success and False on failure. - */ - return ((ret == 0) && (__glXGetUST(ust) == 0)); - } -#endif - if (pdraw && psc->driScreen && psc->driScreen->waitForMSC) { - ret = psc->driScreen->waitForSBC(pdraw, target_sbc, ust, msc, sbc); - return ret; - } - return False; -} - - -/** - * GLX_MESA_allocate_memory - */ -/*@{*/ - -PUBLIC void * -glXAllocateMemoryMESA(Display * dpy, int scrn, - size_t size, float readFreq, - float writeFreq, float priority) -{ -#ifdef __DRI_ALLOCATE - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn); - - if (psc && psc->allocate) - return (*psc->allocate->allocateMemory) (psc->__driScreen, size, - readFreq, writeFreq, priority); - -#else - (void) dpy; - (void) scrn; - (void) size; - (void) readFreq; - (void) writeFreq; - (void) priority; -#endif /* __DRI_ALLOCATE */ - - return NULL; -} - - -PUBLIC void -glXFreeMemoryMESA(Display * dpy, int scrn, void *pointer) -{ -#ifdef __DRI_ALLOCATE - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn); - - if (psc && psc->allocate) - (*psc->allocate->freeMemory) (psc->__driScreen, pointer); - -#else - (void) dpy; - (void) scrn; - (void) pointer; -#endif /* __DRI_ALLOCATE */ -} - - -PUBLIC GLuint -glXGetMemoryOffsetMESA(Display * dpy, int scrn, const void *pointer) -{ -#ifdef __DRI_ALLOCATE - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn); - - if (psc && psc->allocate) - return (*psc->allocate->memoryOffset) (psc->__driScreen, pointer); - -#else - (void) dpy; - (void) scrn; - (void) pointer; -#endif /* GLX_DIRECT_RENDERING */ - - return ~0L; -} - -/*@}*/ - - -/** - * Mesa extension stubs. These will help reduce portability problems. - */ -/*@{*/ - -/** - * Release all buffers associated with the specified GLX drawable. - * - * \todo - * This function was intended for stand-alone Mesa. The issue there is that - * the library doesn't get any notification when a window is closed. In - * DRI there is a similar but slightly different issue. When GLX 1.3 is - * supported, there are 3 different functions to destroy a drawable. It - * should be possible to create GLX protocol (or have it determine which - * protocol to use based on the type of the drawable) to have one function - * do the work of 3. For the direct-rendering case, this function could - * just call the driver's \c __DRIdrawableRec::destroyDrawable function. - * This would reduce the frequency with which \c __driGarbageCollectDrawables - * would need to be used. This really should be done as part of the new DRI - * interface work. - * - * \sa http://oss.sgi.com/projects/ogl-sample/registry/MESA/release_buffers.txt - * __driGarbageCollectDrawables - * glXDestroyGLXPixmap - * glXDestroyPbuffer glXDestroyPixmap glXDestroyWindow - * glXDestroyGLXPbufferSGIX glXDestroyGLXVideoSourceSGIX - */ -static Bool -__glXReleaseBuffersMESA(Display * dpy, GLXDrawable d) -{ - (void) dpy; - (void) d; - return False; -} - - -PUBLIC GLXPixmap -glXCreateGLXPixmapMESA(Display * dpy, XVisualInfo * visual, - Pixmap pixmap, Colormap cmap) -{ - (void) dpy; - (void) visual; - (void) pixmap; - (void) cmap; - return 0; -} - -/*@}*/ - - -/** - * GLX_MESA_copy_sub_buffer - */ -#define X_GLXvop_CopySubBufferMESA 5154 /* temporary */ -static void -__glXCopySubBufferMESA(Display * dpy, GLXDrawable drawable, - int x, int y, int width, int height) -{ - xGLXVendorPrivateReq *req; - GLXContext gc; - GLXContextTag tag; - CARD32 *drawable_ptr; - INT32 *x_ptr, *y_ptr, *w_ptr, *h_ptr; - CARD8 opcode; - -#ifdef __DRI_COPY_SUB_BUFFER - int screen; - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); - if (pdraw != NULL) { - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); - if (psc->driScreen->copySubBuffer != NULL) { - glFlush(); - (*psc->driScreen->copySubBuffer) (pdraw, x, y, width, height); - } - - return; - } -#endif - - opcode = __glXSetupForCommand(dpy); - if (!opcode) - return; - - /* - ** The calling thread may or may not have a current context. If it - ** does, send the context tag so the server can do a flush. - */ - gc = __glXGetCurrentContext(); - if ((gc != NULL) && (dpy == gc->currentDpy) && - ((drawable == gc->currentDrawable) || - (drawable == gc->currentReadable))) { - tag = gc->currentContextTag; - } - else { - tag = 0; - } - - LockDisplay(dpy); - GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32) * 4, req); - req->reqType = opcode; - req->glxCode = X_GLXVendorPrivate; - req->vendorCode = X_GLXvop_CopySubBufferMESA; - req->contextTag = tag; - - drawable_ptr = (CARD32 *) (req + 1); - x_ptr = (INT32 *) (drawable_ptr + 1); - y_ptr = (INT32 *) (drawable_ptr + 2); - w_ptr = (INT32 *) (drawable_ptr + 3); - h_ptr = (INT32 *) (drawable_ptr + 4); - - *drawable_ptr = drawable; - *x_ptr = x; - *y_ptr = y; - *w_ptr = width; - *h_ptr = height; - - UnlockDisplay(dpy); - SyncHandle(); -} - - -/** - * GLX_EXT_texture_from_pixmap - */ -/*@{*/ -static void -__glXBindTexImageEXT(Display * dpy, - GLXDrawable drawable, int buffer, const int *attrib_list) -{ - xGLXVendorPrivateReq *req; - GLXContext gc = __glXGetCurrentContext(); - CARD32 *drawable_ptr; - INT32 *buffer_ptr; - CARD32 *num_attrib_ptr; - CARD32 *attrib_ptr; - CARD8 opcode; - unsigned int i; - - if (gc == NULL) - return; - - i = 0; - if (attrib_list) { - while (attrib_list[i * 2] != None) - i++; - } - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); - - if (pdraw != NULL) { - if (pdraw->psc->texBuffer->base.version >= 2 && - pdraw->psc->texBuffer->setTexBuffer2 != NULL) { - (*pdraw->psc->texBuffer->setTexBuffer2) (gc->__driContext, - pdraw->textureTarget, - pdraw->textureFormat, - pdraw->driDrawable); - } - else { - (*pdraw->psc->texBuffer->setTexBuffer) (gc->__driContext, - pdraw->textureTarget, - pdraw->driDrawable); - } - } - return; - } -#endif - - opcode = __glXSetupForCommand(dpy); - if (!opcode) - return; - - LockDisplay(dpy); - GetReqExtra(GLXVendorPrivate, 12 + 8 * i, req); - req->reqType = opcode; - req->glxCode = X_GLXVendorPrivate; - req->vendorCode = X_GLXvop_BindTexImageEXT; - req->contextTag = gc->currentContextTag; - - drawable_ptr = (CARD32 *) (req + 1); - buffer_ptr = (INT32 *) (drawable_ptr + 1); - num_attrib_ptr = (CARD32 *) (buffer_ptr + 1); - attrib_ptr = (CARD32 *) (num_attrib_ptr + 1); - - *drawable_ptr = drawable; - *buffer_ptr = buffer; - *num_attrib_ptr = (CARD32) i; - - i = 0; - if (attrib_list) { - while (attrib_list[i * 2] != None) { - *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 0]; - *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 1]; - i++; - } - } - - UnlockDisplay(dpy); - SyncHandle(); -} - -static void -__glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer) -{ - xGLXVendorPrivateReq *req; - GLXContext gc = __glXGetCurrentContext(); - CARD32 *drawable_ptr; - INT32 *buffer_ptr; - CARD8 opcode; - - if (gc == NULL) - return; - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) - return; -#endif - - opcode = __glXSetupForCommand(dpy); - if (!opcode) - return; - - LockDisplay(dpy); - GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32), req); - req->reqType = opcode; - req->glxCode = X_GLXVendorPrivate; - req->vendorCode = X_GLXvop_ReleaseTexImageEXT; - req->contextTag = gc->currentContextTag; - - drawable_ptr = (CARD32 *) (req + 1); - buffer_ptr = (INT32 *) (drawable_ptr + 1); - - *drawable_ptr = drawable; - *buffer_ptr = buffer; - - UnlockDisplay(dpy); - SyncHandle(); -} - -/*@}*/ - -/** - * \c strdup is actually not a standard ANSI C or POSIX routine. - * Irix will not define it if ANSI mode is in effect. - * - * \sa strdup - */ -_X_HIDDEN char * -__glXstrdup(const char *str) -{ - char *copy; - copy = (char *) Xmalloc(strlen(str) + 1); - if (!copy) - return NULL; - strcpy(copy, str); - return copy; -} - -/* -** glXGetProcAddress support -*/ - -struct name_address_pair -{ - const char *Name; - GLvoid *Address; -}; - -#define GLX_FUNCTION(f) { # f, (GLvoid *) f } -#define GLX_FUNCTION2(n,f) { # n, (GLvoid *) f } - -static const struct name_address_pair GLX_functions[] = { - /*** GLX_VERSION_1_0 ***/ - GLX_FUNCTION(glXChooseVisual), - GLX_FUNCTION(glXCopyContext), - GLX_FUNCTION(glXCreateContext), - GLX_FUNCTION(glXCreateGLXPixmap), - GLX_FUNCTION(glXDestroyContext), - GLX_FUNCTION(glXDestroyGLXPixmap), - GLX_FUNCTION(glXGetConfig), - GLX_FUNCTION(glXGetCurrentContext), - GLX_FUNCTION(glXGetCurrentDrawable), - GLX_FUNCTION(glXIsDirect), - GLX_FUNCTION(glXMakeCurrent), - GLX_FUNCTION(glXQueryExtension), - GLX_FUNCTION(glXQueryVersion), - GLX_FUNCTION(glXSwapBuffers), - GLX_FUNCTION(glXUseXFont), - GLX_FUNCTION(glXWaitGL), - GLX_FUNCTION(glXWaitX), - - /*** GLX_VERSION_1_1 ***/ - GLX_FUNCTION(glXGetClientString), - GLX_FUNCTION(glXQueryExtensionsString), - GLX_FUNCTION(glXQueryServerString), - - /*** GLX_VERSION_1_2 ***/ - GLX_FUNCTION(glXGetCurrentDisplay), - - /*** GLX_VERSION_1_3 ***/ - GLX_FUNCTION(glXChooseFBConfig), - GLX_FUNCTION(glXCreateNewContext), - GLX_FUNCTION(glXCreatePbuffer), - GLX_FUNCTION(glXCreatePixmap), - GLX_FUNCTION(glXCreateWindow), - GLX_FUNCTION(glXDestroyPbuffer), - GLX_FUNCTION(glXDestroyPixmap), - GLX_FUNCTION(glXDestroyWindow), - GLX_FUNCTION(glXGetCurrentReadDrawable), - GLX_FUNCTION(glXGetFBConfigAttrib), - GLX_FUNCTION(glXGetFBConfigs), - GLX_FUNCTION(glXGetSelectedEvent), - GLX_FUNCTION(glXGetVisualFromFBConfig), - GLX_FUNCTION(glXMakeContextCurrent), - GLX_FUNCTION(glXQueryContext), - GLX_FUNCTION(glXQueryDrawable), - GLX_FUNCTION(glXSelectEvent), - - /*** GLX_SGI_swap_control ***/ - GLX_FUNCTION2(glXSwapIntervalSGI, __glXSwapIntervalSGI), - - /*** GLX_SGI_video_sync ***/ - GLX_FUNCTION2(glXGetVideoSyncSGI, __glXGetVideoSyncSGI), - GLX_FUNCTION2(glXWaitVideoSyncSGI, __glXWaitVideoSyncSGI), - - /*** GLX_SGI_make_current_read ***/ - GLX_FUNCTION2(glXMakeCurrentReadSGI, glXMakeContextCurrent), - GLX_FUNCTION2(glXGetCurrentReadDrawableSGI, glXGetCurrentReadDrawable), - - /*** GLX_EXT_import_context ***/ - GLX_FUNCTION(glXFreeContextEXT), - GLX_FUNCTION(glXGetContextIDEXT), - GLX_FUNCTION2(glXGetCurrentDisplayEXT, glXGetCurrentDisplay), - GLX_FUNCTION(glXImportContextEXT), - GLX_FUNCTION2(glXQueryContextInfoEXT, glXQueryContext), - - /*** GLX_SGIX_fbconfig ***/ - GLX_FUNCTION2(glXGetFBConfigAttribSGIX, glXGetFBConfigAttrib), - GLX_FUNCTION2(glXChooseFBConfigSGIX, glXChooseFBConfig), - GLX_FUNCTION(glXCreateGLXPixmapWithConfigSGIX), - GLX_FUNCTION(glXCreateContextWithConfigSGIX), - GLX_FUNCTION2(glXGetVisualFromFBConfigSGIX, glXGetVisualFromFBConfig), - GLX_FUNCTION(glXGetFBConfigFromVisualSGIX), - - /*** GLX_SGIX_pbuffer ***/ - GLX_FUNCTION(glXCreateGLXPbufferSGIX), - GLX_FUNCTION(glXDestroyGLXPbufferSGIX), - GLX_FUNCTION(glXQueryGLXPbufferSGIX), - GLX_FUNCTION(glXSelectEventSGIX), - GLX_FUNCTION(glXGetSelectedEventSGIX), - - /*** GLX_SGIX_swap_group ***/ - GLX_FUNCTION2(glXJoinSwapGroupSGIX, __glXJoinSwapGroupSGIX), - - /*** GLX_SGIX_swap_barrier ***/ - GLX_FUNCTION2(glXBindSwapBarrierSGIX, __glXBindSwapBarrierSGIX), - GLX_FUNCTION2(glXQueryMaxSwapBarriersSGIX, __glXQueryMaxSwapBarriersSGIX), - - /*** GLX_MESA_allocate_memory ***/ - GLX_FUNCTION(glXAllocateMemoryMESA), - GLX_FUNCTION(glXFreeMemoryMESA), - GLX_FUNCTION(glXGetMemoryOffsetMESA), - - /*** GLX_MESA_copy_sub_buffer ***/ - GLX_FUNCTION2(glXCopySubBufferMESA, __glXCopySubBufferMESA), - - /*** GLX_MESA_pixmap_colormap ***/ - GLX_FUNCTION(glXCreateGLXPixmapMESA), - - /*** GLX_MESA_release_buffers ***/ - GLX_FUNCTION2(glXReleaseBuffersMESA, __glXReleaseBuffersMESA), - - /*** GLX_MESA_swap_control ***/ - GLX_FUNCTION2(glXSwapIntervalMESA, __glXSwapIntervalMESA), - GLX_FUNCTION2(glXGetSwapIntervalMESA, __glXGetSwapIntervalMESA), - - /*** GLX_MESA_swap_frame_usage ***/ - GLX_FUNCTION2(glXBeginFrameTrackingMESA, __glXBeginFrameTrackingMESA), - GLX_FUNCTION2(glXEndFrameTrackingMESA, __glXEndFrameTrackingMESA), - GLX_FUNCTION2(glXGetFrameUsageMESA, __glXGetFrameUsageMESA), - GLX_FUNCTION2(glXQueryFrameTrackingMESA, __glXQueryFrameTrackingMESA), - - /*** GLX_ARB_get_proc_address ***/ - GLX_FUNCTION(glXGetProcAddressARB), - - /*** GLX 1.4 ***/ - GLX_FUNCTION2(glXGetProcAddress, glXGetProcAddressARB), - - /*** GLX_OML_sync_control ***/ - GLX_FUNCTION2(glXWaitForSbcOML, __glXWaitForSbcOML), - GLX_FUNCTION2(glXWaitForMscOML, __glXWaitForMscOML), - GLX_FUNCTION2(glXSwapBuffersMscOML, __glXSwapBuffersMscOML), - GLX_FUNCTION2(glXGetMscRateOML, __glXGetMscRateOML), - GLX_FUNCTION2(glXGetSyncValuesOML, __glXGetSyncValuesOML), - - /*** GLX_EXT_texture_from_pixmap ***/ - GLX_FUNCTION2(glXBindTexImageEXT, __glXBindTexImageEXT), - GLX_FUNCTION2(glXReleaseTexImageEXT, __glXReleaseTexImageEXT), - -#ifdef GLX_DIRECT_RENDERING - /*** DRI configuration ***/ - GLX_FUNCTION(glXGetScreenDriver), - GLX_FUNCTION(glXGetDriverConfig), -#endif - - {NULL, NULL} /* end of list */ -}; - - -static const GLvoid * -get_glx_proc_address(const char *funcName) -{ - GLuint i; - - /* try static functions */ - for (i = 0; GLX_functions[i].Name; i++) { - if (strcmp(GLX_functions[i].Name, funcName) == 0) - return GLX_functions[i].Address; - } - - return NULL; -} - - -/** - * Get the address of a named GL function. This is the pre-GLX 1.4 name for - * \c glXGetProcAddress. - * - * \param procName Name of a GL or GLX function. - * \returns A pointer to the named function - * - * \sa glXGetProcAddress - */ -PUBLIC void (*glXGetProcAddressARB(const GLubyte * procName)) (void) -{ - typedef void (*gl_function) (void); - gl_function f; - - - /* Search the table of GLX and internal functions first. If that - * fails and the supplied name could be a valid core GL name, try - * searching the core GL function table. This check is done to prevent - * DRI based drivers from searching the core GL function table for - * internal API functions. - */ - - f = (gl_function) get_glx_proc_address((const char *) procName); - if ((f == NULL) && (procName[0] == 'g') && (procName[1] == 'l') - && (procName[2] != 'X')) { - f = (gl_function) _glapi_get_proc_address((const char *) procName); - } - - return f; -} - -/** - * Get the address of a named GL function. This is the GLX 1.4 name for - * \c glXGetProcAddressARB. - * - * \param procName Name of a GL or GLX function. - * \returns A pointer to the named function - * - * \sa glXGetProcAddressARB - */ -PUBLIC void (*glXGetProcAddress(const GLubyte * procName)) (void) -#if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED) - __attribute__ ((alias("glXGetProcAddressARB"))); -#else -{ - return glXGetProcAddressARB(procName); -} -#endif /* __GNUC__ */ - - -#ifdef GLX_DIRECT_RENDERING -/** - * Get the unadjusted system time (UST). Currently, the UST is measured in - * microseconds since Epoc. The actual resolution of the UST may vary from - * system to system, and the units may vary from release to release. - * Drivers should not call this function directly. They should instead use - * \c glXGetProcAddress to obtain a pointer to the function. - * - * \param ust Location to store the 64-bit UST - * \returns Zero on success or a negative errno value on failure. - * - * \sa glXGetProcAddress, PFNGLXGETUSTPROC - * - * \since Internal API version 20030317. - */ -_X_HIDDEN int -__glXGetUST(int64_t * ust) -{ - struct timeval tv; - - if (ust == NULL) { - return -EFAULT; - } - - if (gettimeofday(&tv, NULL) == 0) { - ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec; - return 0; - } - else { - return -errno; - } -} -#endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/x11/glxcurrent.c b/src/glx/x11/glxcurrent.c deleted file mode 100644 index c28360bdde9..00000000000 --- a/src/glx/x11/glxcurrent.c +++ /dev/null @@ -1,513 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -/** - * \file glxcurrent.c - * Client-side GLX interface for current context management. - */ - -#include "glxclient.h" -#include "glapi.h" -#include "indirect_init.h" - -/* -** We setup some dummy structures here so that the API can be used -** even if no context is current. -*/ - -static GLubyte dummyBuffer[__GLX_BUFFER_LIMIT_SIZE]; - -/* -** Dummy context used by small commands when there is no current context. -** All the -** gl and glx entry points are designed to operate as nop's when using -** the dummy context structure. -*/ -static __GLXcontext dummyContext = { - &dummyBuffer[0], - &dummyBuffer[0], - &dummyBuffer[0], - &dummyBuffer[__GLX_BUFFER_LIMIT_SIZE], - sizeof(dummyBuffer), -}; - - -/* -** All indirect rendering contexts will share the same indirect dispatch table. -*/ -static __GLapi *IndirectAPI = NULL; - - -/* - * Current context management and locking - */ - -#if defined( PTHREADS ) - -_X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER; - -# if defined( GLX_USE_TLS ) - -/** - * Per-thread GLX context pointer. - * - * \c __glXSetCurrentContext is written is such a way that this pointer can - * \b never be \c NULL. This is important! Because of this - * \c __glXGetCurrentContext can be implemented as trivial macro. - */ -__thread void *__glX_tls_Context __attribute__ ((tls_model("initial-exec"))) - = &dummyContext; - -_X_HIDDEN void -__glXSetCurrentContext(__GLXcontext * c) -{ - __glX_tls_Context = (c != NULL) ? c : &dummyContext; -} - -# else - -static pthread_once_t once_control = PTHREAD_ONCE_INIT; - -/** - * Per-thread data key. - * - * Once \c init_thread_data has been called, the per-thread data key will - * take a value of \c NULL. As each new thread is created the default - * value, in that thread, will be \c NULL. - */ -static pthread_key_t ContextTSD; - -/** - * Initialize the per-thread data key. - * - * This function is called \b exactly once per-process (not per-thread!) to - * initialize the per-thread data key. This is ideally done using the - * \c pthread_once mechanism. - */ -static void -init_thread_data(void) -{ - if (pthread_key_create(&ContextTSD, NULL) != 0) { - perror("pthread_key_create"); - exit(-1); - } -} - -_X_HIDDEN void -__glXSetCurrentContext(__GLXcontext * c) -{ - pthread_once(&once_control, init_thread_data); - pthread_setspecific(ContextTSD, c); -} - -_X_HIDDEN __GLXcontext * -__glXGetCurrentContext(void) -{ - void *v; - - pthread_once(&once_control, init_thread_data); - - v = pthread_getspecific(ContextTSD); - return (v == NULL) ? &dummyContext : (__GLXcontext *) v; -} - -# endif /* defined( GLX_USE_TLS ) */ - -#elif defined( THREADS ) - -#error Unknown threading method specified. - -#else - -/* not thread safe */ -_X_HIDDEN __GLXcontext *__glXcurrentContext = &dummyContext; - -#endif - - -_X_HIDDEN void -__glXSetCurrentContextNull(void) -{ - __glXSetCurrentContext(&dummyContext); -#ifdef GLX_DIRECT_RENDERING - _glapi_set_dispatch(NULL); /* no-op functions */ - _glapi_set_context(NULL); -#endif -} - - -/************************************************************************/ - -PUBLIC GLXContext -glXGetCurrentContext(void) -{ - GLXContext cx = __glXGetCurrentContext(); - - if (cx == &dummyContext) { - return NULL; - } - else { - return cx; - } -} - -PUBLIC GLXDrawable -glXGetCurrentDrawable(void) -{ - GLXContext gc = __glXGetCurrentContext(); - return gc->currentDrawable; -} - - -/************************************************************************/ - -/** - * Sends a GLX protocol message to the specified display to make the context - * and the drawables current. - * - * \param dpy Display to send the message to. - * \param opcode Major opcode value for the display. - * \param gc_id Context tag for the context to be made current. - * \param draw Drawable ID for the "draw" drawable. - * \param read Drawable ID for the "read" drawable. - * \param reply Space to store the X-server's reply. - * - * \warning - * This function assumes that \c dpy is locked with \c LockDisplay on entry. - */ -static Bool -SendMakeCurrentRequest(Display * dpy, CARD8 opcode, - GLXContextID gc_id, GLXContextTag gc_tag, - GLXDrawable draw, GLXDrawable read, - xGLXMakeCurrentReply * reply) -{ - Bool ret; - - - LockDisplay(dpy); - - if (draw == read) { - xGLXMakeCurrentReq *req; - - GetReq(GLXMakeCurrent, req); - req->reqType = opcode; - req->glxCode = X_GLXMakeCurrent; - req->drawable = draw; - req->context = gc_id; - req->oldContextTag = gc_tag; - } - else { - __GLXdisplayPrivate *priv = __glXInitialize(dpy); - - /* If the server can support the GLX 1.3 version, we should - * perfer that. Not only that, some servers support GLX 1.3 but - * not the SGI extension. - */ - - if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { - xGLXMakeContextCurrentReq *req; - - GetReq(GLXMakeContextCurrent, req); - req->reqType = opcode; - req->glxCode = X_GLXMakeContextCurrent; - req->drawable = draw; - req->readdrawable = read; - req->context = gc_id; - req->oldContextTag = gc_tag; - } - else { - xGLXVendorPrivateWithReplyReq *vpreq; - xGLXMakeCurrentReadSGIReq *req; - - GetReqExtra(GLXVendorPrivateWithReply, - sz_xGLXMakeCurrentReadSGIReq - - sz_xGLXVendorPrivateWithReplyReq, vpreq); - req = (xGLXMakeCurrentReadSGIReq *) vpreq; - req->reqType = opcode; - req->glxCode = X_GLXVendorPrivateWithReply; - req->vendorCode = X_GLXvop_MakeCurrentReadSGI; - req->drawable = draw; - req->readable = read; - req->context = gc_id; - req->oldContextTag = gc_tag; - } - } - - ret = _XReply(dpy, (xReply *) reply, 0, False); - - UnlockDisplay(dpy); - SyncHandle(); - - return ret; -} - - -#ifdef GLX_DIRECT_RENDERING -static __GLXDRIdrawable * -FetchDRIDrawable(Display * dpy, GLXDrawable glxDrawable, GLXContext gc) -{ - __GLXdisplayPrivate *const priv = __glXInitialize(dpy); - __GLXDRIdrawable *pdraw; - __GLXscreenConfigs *psc; - - if (priv == NULL) - return NULL; - - psc = &priv->screenConfigs[gc->screen]; - if (psc->drawHash == NULL) - return NULL; - - if (__glxHashLookup(psc->drawHash, glxDrawable, (void *) &pdraw) == 0) - return pdraw; - - pdraw = psc->driScreen->createDrawable(psc, glxDrawable, - glxDrawable, gc->mode); - if (__glxHashInsert(psc->drawHash, glxDrawable, pdraw)) { - (*pdraw->destroyDrawable) (pdraw); - return NULL; - } - - return pdraw; -} -#endif /* GLX_DIRECT_RENDERING */ - -static void -__glXGenerateError(Display * dpy, GLXContext gc, XID resource, - BYTE errorCode, CARD16 minorCode) -{ - xError error; - - error.errorCode = errorCode; - error.resourceID = resource; - error.sequenceNumber = dpy->request; - error.type = X_Error; - error.majorCode = gc->majorOpcode; - error.minorCode = minorCode; - _XError(dpy, &error); -} - -/** - * Make a particular context current. - * - * \note This is in this file so that it can access dummyContext. - */ -static Bool -MakeContextCurrent(Display * dpy, GLXDrawable draw, - GLXDrawable read, GLXContext gc) -{ - xGLXMakeCurrentReply reply; - const GLXContext oldGC = __glXGetCurrentContext(); - const CARD8 opcode = __glXSetupForCommand(dpy); - const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext)) - ? opcode : __glXSetupForCommand(oldGC->currentDpy); - Bool bindReturnValue; - __GLXattribute *state; - - if (!opcode || !oldOpcode) { - return GL_FALSE; - } - - /* Make sure that the new context has a nonzero ID. In the request, - * a zero context ID is used only to mean that we bind to no current - * context. - */ - if ((gc != NULL) && (gc->xid == None)) { - return GL_FALSE; - } - - if (gc == NULL && (draw != None || read != None)) { - __glXGenerateError(dpy, gc, (draw != None) ? draw : read, - BadMatch, X_GLXMakeContextCurrent); - return False; - } - if (gc != NULL && (draw == None || read == None)) { - __glXGenerateError(dpy, gc, None, BadMatch, X_GLXMakeContextCurrent); - return False; - } - - _glapi_check_multithread(); - - if (gc != NULL && gc->thread_id != 0 && gc->thread_id != _glthread_GetID()) { - __glXGenerateError(dpy, gc, gc->xid, - BadAccess, X_GLXMakeContextCurrent); - return False; - } - -#ifdef GLX_DIRECT_RENDERING - /* Bind the direct rendering context to the drawable */ - if (gc && gc->driContext) { - __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc); - __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc); - - if ((pdraw == NULL) || (pread == NULL)) { - __glXGenerateError(dpy, gc, (pdraw == NULL) ? draw : read, - GLXBadDrawable, X_GLXMakeContextCurrent); - return False; - } - - bindReturnValue = - (gc->driContext->bindContext) (gc->driContext, pdraw, pread); - } - else if (!gc && oldGC && oldGC->driContext) { - bindReturnValue = True; - } - else -#endif - { - /* Send a glXMakeCurrent request to bind the new context. */ - bindReturnValue = - SendMakeCurrentRequest(dpy, opcode, gc ? gc->xid : None, - ((dpy != oldGC->currentDpy) - || oldGC->isDirect) - ? None : oldGC->currentContextTag, draw, read, - &reply); - } - - - if (!bindReturnValue) { - return False; - } - -#ifdef GLX_DIRECT_RENDERING - if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) && - !oldGC->isDirect && oldGC != &dummyContext) { -#else - if ((dpy != oldGC->currentDpy) && oldGC != &dummyContext) { -#endif - xGLXMakeCurrentReply dummy_reply; - - /* We are either switching from one dpy to another and have to - * send a request to the previous dpy to unbind the previous - * context, or we are switching away from a indirect context to - * a direct context and have to send a request to the dpy to - * unbind the previous context. - */ - (void) SendMakeCurrentRequest(oldGC->currentDpy, oldOpcode, None, - oldGC->currentContextTag, None, None, - &dummy_reply); - } -#ifdef GLX_DIRECT_RENDERING - else if (oldGC->driContext && oldGC != gc) { - oldGC->driContext->unbindContext(oldGC->driContext); - } -#endif - - - /* Update our notion of what is current */ - __glXLock(); - if (gc == oldGC) { - /* Even though the contexts are the same the drawable might have - * changed. Note that gc cannot be the dummy, and that oldGC - * cannot be NULL, therefore if they are the same, gc is not - * NULL and not the dummy. - */ - gc->currentDrawable = draw; - gc->currentReadable = read; - } - else { - if (oldGC != &dummyContext) { - /* Old current context is no longer current to anybody */ - oldGC->currentDpy = 0; - oldGC->currentDrawable = None; - oldGC->currentReadable = None; - oldGC->currentContextTag = 0; - oldGC->thread_id = 0; - - if (oldGC->xid == None) { - /* We are switching away from a context that was - * previously destroyed, so we need to free the memory - * for the old handle. - */ -#ifdef GLX_DIRECT_RENDERING - /* Destroy the old direct rendering context */ - if (oldGC->driContext) { - oldGC->driContext->destroyContext(oldGC->driContext, - oldGC->psc, - oldGC->createDpy); - oldGC->driContext = NULL; - } -#endif - __glXFreeContext(oldGC); - } - } - if (gc) { - __glXSetCurrentContext(gc); - - gc->currentDpy = dpy; - gc->currentDrawable = draw; - gc->currentReadable = read; - gc->thread_id = _glthread_GetID(); - -#ifdef GLX_DIRECT_RENDERING - if (!gc->driContext) { -#endif - if (!IndirectAPI) - IndirectAPI = __glXNewIndirectAPI(); - _glapi_set_dispatch(IndirectAPI); - - state = (__GLXattribute *) (gc->client_state_private); - - gc->currentContextTag = reply.contextTag; - if (state->array_state == NULL) { - (void) glGetString(GL_EXTENSIONS); - (void) glGetString(GL_VERSION); - __glXInitVertexArrayState(gc); - } -#ifdef GLX_DIRECT_RENDERING - } - else { - gc->currentContextTag = -1; - } -#endif - } - else { - __glXSetCurrentContextNull(); - } - } - __glXUnlock(); - return GL_TRUE; -} - - -PUBLIC Bool -glXMakeCurrent(Display * dpy, GLXDrawable draw, GLXContext gc) -{ - return MakeContextCurrent(dpy, draw, draw, gc); -} - -PUBLIC -GLX_ALIAS(Bool, glXMakeCurrentReadSGI, - (Display * dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx), - (dpy, d, r, ctx), MakeContextCurrent) - -PUBLIC -GLX_ALIAS(Bool, glXMakeContextCurrent, - (Display * dpy, GLXDrawable d, GLXDrawable r, - GLXContext ctx), (dpy, d, r, ctx), MakeContextCurrent) diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c deleted file mode 100644 index c2de1a3fff8..00000000000 --- a/src/glx/x11/glxext.c +++ /dev/null @@ -1,1060 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -/** - * \file glxext.c - * GLX protocol interface boot-strap code. - * - * Direct rendering support added by Precision Insight, Inc. - * - * \author Kevin E. Martin - */ - -#include -#include "glxclient.h" -#include -#include -#include -#include "glxextensions.h" -#include "glcontextmodes.h" - -#ifdef USE_XCB -#include -#include -#include -#endif - - -#ifdef DEBUG -void __glXDumpDrawBuffer(__GLXcontext * ctx); -#endif - -/* -** You can set this cell to 1 to force the gl drawing stuff to be -** one command per packet -*/ -_X_HIDDEN int __glXDebug = 0; - -/* Extension required boiler plate */ - -static char *__glXExtensionName = GLX_EXTENSION_NAME; -XExtensionInfo *__glXExtensionInfo = NULL; - -static /* const */ char *error_list[] = { - "GLXBadContext", - "GLXBadContextState", - "GLXBadDrawable", - "GLXBadPixmap", - "GLXBadContextTag", - "GLXBadCurrentWindow", - "GLXBadRenderRequest", - "GLXBadLargeRequest", - "GLXUnsupportedPrivateRequest", - "GLXBadFBConfig", - "GLXBadPbuffer", - "GLXBadCurrentDrawable", - "GLXBadWindow", -}; - -static int -__glXCloseDisplay(Display * dpy, XExtCodes * codes) -{ - GLXContext gc; - - gc = __glXGetCurrentContext(); - if (dpy == gc->currentDpy) { - __glXSetCurrentContextNull(); - __glXFreeContext(gc); - } - - return XextRemoveDisplay(__glXExtensionInfo, dpy); -} - - -static -XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName, - __GLX_NUMBER_ERRORS, error_list) -static Bool -__glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire); -static Status -__glXEventToWire(Display *dpy, XEvent *event, xEvent *wire); - -static /* const */ XExtensionHooks __glXExtensionHooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - __glXCloseDisplay, /* close_display */ - __glXWireToEvent, /* wire_to_event */ - __glXEventToWire, /* event_to_wire */ - NULL, /* error */ - __glXErrorString, /* error_string */ -}; - -XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo, - __glXExtensionName, &__glXExtensionHooks, - __GLX_NUMBER_EVENTS, NULL) - -/* - * GLX events are a bit funky. We don't stuff the X event code into - * our user exposed (via XNextEvent) structure. Instead we use the GLX - * private event code namespace (and hope it doesn't conflict). Clients - * have to know that bit 15 in the event type field means they're getting - * a GLX event, and then handle the various sub-event types there, rather - * than simply checking the event code and handling it directly. - */ - -static Bool -__glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire) -{ - XExtDisplayInfo *info = __glXFindDisplay(dpy); - - XextCheckExtension(dpy, info, __glXExtensionName, False); - - switch ((wire->u.u.type & 0x7f) - info->codes->first_event) { - case GLX_PbufferClobber: - { - GLXPbufferClobberEvent *aevent = (GLXPbufferClobberEvent *)event; - xGLXPbufferClobberEvent *awire = (xGLXPbufferClobberEvent *)wire; - aevent->event_type = awire->type; - aevent->serial = awire->sequenceNumber; - aevent->event_type = awire->event_type; - aevent->draw_type = awire->draw_type; - aevent->drawable = awire->drawable; - aevent->buffer_mask = awire->buffer_mask; - aevent->aux_buffer = awire->aux_buffer; - aevent->x = awire->x; - aevent->y = awire->y; - aevent->width = awire->width; - aevent->height = awire->height; - aevent->count = awire->count; - return True; - } - /* No easy symbol to test for this, as GLX_BufferSwapComplete is - * defined in the local glx.h header, but the - * xGLXBufferSwapComplete typedef is only available in new versions - * of the external glxproto.h header, which doesn't have any - * testable versioning define. - * - * I'll use the related DRI2 define, in the hope that we won't - * receive these events unless we know how to ask for them: - */ -#ifdef X_DRI2SwapBuffers - case GLX_BufferSwapComplete: - { - GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event; - xGLXBufferSwapComplete *awire = (xGLXBufferSwapComplete *)wire; - aevent->event_type = awire->event_type; - aevent->drawable = awire->drawable; - aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo; - aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo; - aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo; - return True; - } -#endif - default: - /* client doesn't support server event */ - break; - } - - return False; -} - -/* We don't actually support this. It doesn't make sense for clients to - * send each other GLX events. - */ -static Status -__glXEventToWire(Display *dpy, XEvent *event, xEvent *wire) -{ - XExtDisplayInfo *info = __glXFindDisplay(dpy); - - XextCheckExtension(dpy, info, __glXExtensionName, False); - - switch (event->type) { - case GLX_DAMAGED: - break; - case GLX_SAVED: - break; - case GLX_EXCHANGE_COMPLETE_INTEL: - break; - case GLX_BLIT_COMPLETE_INTEL: - break; - case GLX_FLIP_COMPLETE_INTEL: - break; - default: - /* client doesn't support server event */ - break; - } - - return Success; -} - -/************************************************************************/ -/* -** Free the per screen configs data as well as the array of -** __glXScreenConfigs. -*/ -static void -FreeScreenConfigs(__GLXdisplayPrivate * priv) -{ - __GLXscreenConfigs *psc; - GLint i, screens; - - /* Free screen configuration information */ - psc = priv->screenConfigs; - screens = ScreenCount(priv->dpy); - for (i = 0; i < screens; i++, psc++) { - if (psc->configs) { - _gl_context_modes_destroy(psc->configs); - if (psc->effectiveGLXexts) - Xfree(psc->effectiveGLXexts); - psc->configs = NULL; /* NOTE: just for paranoia */ - } - if (psc->visuals) { - _gl_context_modes_destroy(psc->visuals); - psc->visuals = NULL; /* NOTE: just for paranoia */ - } - Xfree((char *) psc->serverGLXexts); - -#ifdef GLX_DIRECT_RENDERING - if (psc->driver_configs) { - unsigned int j; - for (j = 0; psc->driver_configs[j]; j++) - free((__DRIconfig *) psc->driver_configs[j]); - free(psc->driver_configs); - psc->driver_configs = NULL; - } - if (psc->driScreen) { - psc->driScreen->destroyScreen(psc); - __glxHashDestroy(psc->drawHash); - XFree(psc->driScreen); - psc->driScreen = NULL; - } -#endif - } - XFree((char *) priv->screenConfigs); - priv->screenConfigs = NULL; -} - -/* -** Release the private memory referred to in a display private -** structure. The caller will free the extension structure. -*/ -static int -__glXFreeDisplayPrivate(XExtData * extension) -{ - __GLXdisplayPrivate *priv; - - priv = (__GLXdisplayPrivate *) extension->private_data; - FreeScreenConfigs(priv); - if (priv->serverGLXvendor) { - Xfree((char *) priv->serverGLXvendor); - priv->serverGLXvendor = 0x0; /* to protect against double free's */ - } - if (priv->serverGLXversion) { - Xfree((char *) priv->serverGLXversion); - priv->serverGLXversion = 0x0; /* to protect against double free's */ - } - -#ifdef GLX_DIRECT_RENDERING - /* Free the direct rendering per display data */ - if (priv->driswDisplay) - (*priv->driswDisplay->destroyDisplay) (priv->driswDisplay); - priv->driswDisplay = NULL; - - if (priv->driDisplay) - (*priv->driDisplay->destroyDisplay) (priv->driDisplay); - priv->driDisplay = NULL; - - if (priv->dri2Display) - (*priv->dri2Display->destroyDisplay) (priv->dri2Display); - priv->dri2Display = NULL; -#endif - - Xfree((char *) priv); - return 0; -} - -/************************************************************************/ - -/* -** Query the version of the GLX extension. This procedure works even if -** the client extension is not completely set up. -*/ -static Bool -QueryVersion(Display * dpy, int opcode, int *major, int *minor) -{ -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - xcb_glx_query_version_reply_t *reply = xcb_glx_query_version_reply(c, - xcb_glx_query_version - (c, - GLX_MAJOR_VERSION, - GLX_MINOR_VERSION), - NULL); - - if (reply->major_version != GLX_MAJOR_VERSION) { - free(reply); - return GL_FALSE; - } - *major = reply->major_version; - *minor = min(reply->minor_version, GLX_MINOR_VERSION); - free(reply); - return GL_TRUE; -#else - xGLXQueryVersionReq *req; - xGLXQueryVersionReply reply; - - /* Send the glXQueryVersion request */ - LockDisplay(dpy); - GetReq(GLXQueryVersion, req); - req->reqType = opcode; - req->glxCode = X_GLXQueryVersion; - req->majorVersion = GLX_MAJOR_VERSION; - req->minorVersion = GLX_MINOR_VERSION; - _XReply(dpy, (xReply *) & reply, 0, False); - UnlockDisplay(dpy); - SyncHandle(); - - if (reply.majorVersion != GLX_MAJOR_VERSION) { - /* - ** The server does not support the same major release as this - ** client. - */ - return GL_FALSE; - } - *major = reply.majorVersion; - *minor = min(reply.minorVersion, GLX_MINOR_VERSION); - return GL_TRUE; -#endif /* USE_XCB */ -} - - -_X_HIDDEN void -__glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count, - const INT32 * bp, Bool tagged_only, - Bool fbconfig_style_tags) -{ - int i; - - if (!tagged_only) { - /* Copy in the first set of properties */ - config->visualID = *bp++; - - config->visualType = _gl_convert_from_x_visual_type(*bp++); - - config->rgbMode = *bp++; - - config->redBits = *bp++; - config->greenBits = *bp++; - config->blueBits = *bp++; - config->alphaBits = *bp++; - config->accumRedBits = *bp++; - config->accumGreenBits = *bp++; - config->accumBlueBits = *bp++; - config->accumAlphaBits = *bp++; - - config->doubleBufferMode = *bp++; - config->stereoMode = *bp++; - - config->rgbBits = *bp++; - config->depthBits = *bp++; - config->stencilBits = *bp++; - config->numAuxBuffers = *bp++; - config->level = *bp++; - - count -= __GLX_MIN_CONFIG_PROPS; - } - - /* - ** Additional properties may be in a list at the end - ** of the reply. They are in pairs of property type - ** and property value. - */ - -#define FETCH_OR_SET(tag) \ - config-> tag = ( fbconfig_style_tags ) ? *bp++ : 1 - - for (i = 0; i < count; i += 2) { - switch (*bp++) { - case GLX_RGBA: - FETCH_OR_SET(rgbMode); - break; - case GLX_BUFFER_SIZE: - config->rgbBits = *bp++; - break; - case GLX_LEVEL: - config->level = *bp++; - break; - case GLX_DOUBLEBUFFER: - FETCH_OR_SET(doubleBufferMode); - break; - case GLX_STEREO: - FETCH_OR_SET(stereoMode); - break; - case GLX_AUX_BUFFERS: - config->numAuxBuffers = *bp++; - break; - case GLX_RED_SIZE: - config->redBits = *bp++; - break; - case GLX_GREEN_SIZE: - config->greenBits = *bp++; - break; - case GLX_BLUE_SIZE: - config->blueBits = *bp++; - break; - case GLX_ALPHA_SIZE: - config->alphaBits = *bp++; - break; - case GLX_DEPTH_SIZE: - config->depthBits = *bp++; - break; - case GLX_STENCIL_SIZE: - config->stencilBits = *bp++; - break; - case GLX_ACCUM_RED_SIZE: - config->accumRedBits = *bp++; - break; - case GLX_ACCUM_GREEN_SIZE: - config->accumGreenBits = *bp++; - break; - case GLX_ACCUM_BLUE_SIZE: - config->accumBlueBits = *bp++; - break; - case GLX_ACCUM_ALPHA_SIZE: - config->accumAlphaBits = *bp++; - break; - case GLX_VISUAL_CAVEAT_EXT: - config->visualRating = *bp++; - break; - case GLX_X_VISUAL_TYPE: - config->visualType = *bp++; - break; - case GLX_TRANSPARENT_TYPE: - config->transparentPixel = *bp++; - break; - case GLX_TRANSPARENT_INDEX_VALUE: - config->transparentIndex = *bp++; - break; - case GLX_TRANSPARENT_RED_VALUE: - config->transparentRed = *bp++; - break; - case GLX_TRANSPARENT_GREEN_VALUE: - config->transparentGreen = *bp++; - break; - case GLX_TRANSPARENT_BLUE_VALUE: - config->transparentBlue = *bp++; - break; - case GLX_TRANSPARENT_ALPHA_VALUE: - config->transparentAlpha = *bp++; - break; - case GLX_VISUAL_ID: - config->visualID = *bp++; - break; - case GLX_DRAWABLE_TYPE: - config->drawableType = *bp++; - break; - case GLX_RENDER_TYPE: - config->renderType = *bp++; - break; - case GLX_X_RENDERABLE: - config->xRenderable = *bp++; - break; - case GLX_FBCONFIG_ID: - config->fbconfigID = *bp++; - break; - case GLX_MAX_PBUFFER_WIDTH: - config->maxPbufferWidth = *bp++; - break; - case GLX_MAX_PBUFFER_HEIGHT: - config->maxPbufferHeight = *bp++; - break; - case GLX_MAX_PBUFFER_PIXELS: - config->maxPbufferPixels = *bp++; - break; - case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX: - config->optimalPbufferWidth = *bp++; - break; - case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX: - config->optimalPbufferHeight = *bp++; - break; - case GLX_VISUAL_SELECT_GROUP_SGIX: - config->visualSelectGroup = *bp++; - break; - case GLX_SWAP_METHOD_OML: - config->swapMethod = *bp++; - break; - case GLX_SAMPLE_BUFFERS_SGIS: - config->sampleBuffers = *bp++; - break; - case GLX_SAMPLES_SGIS: - config->samples = *bp++; - break; - case GLX_BIND_TO_TEXTURE_RGB_EXT: - config->bindToTextureRgb = *bp++; - break; - case GLX_BIND_TO_TEXTURE_RGBA_EXT: - config->bindToTextureRgba = *bp++; - break; - case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: - config->bindToMipmapTexture = *bp++; - break; - case GLX_BIND_TO_TEXTURE_TARGETS_EXT: - config->bindToTextureTargets = *bp++; - break; - case GLX_Y_INVERTED_EXT: - config->yInverted = *bp++; - break; - case None: - i = count; - break; - default: - break; - } - } - - config->renderType = - (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; - - config->haveAccumBuffer = ((config->accumRedBits + - config->accumGreenBits + - config->accumBlueBits + - config->accumAlphaBits) > 0); - config->haveDepthBuffer = (config->depthBits > 0); - config->haveStencilBuffer = (config->stencilBits > 0); -} - -static __GLcontextModes * -createConfigsFromProperties(Display * dpy, int nvisuals, int nprops, - int screen, GLboolean tagged_only) -{ - INT32 buf[__GLX_TOTAL_CONFIG], *props; - unsigned prop_size; - __GLcontextModes *modes, *m; - int i; - - if (nprops == 0) - return NULL; - - /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */ - - /* Check number of properties */ - if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS) - return NULL; - - /* Allocate memory for our config structure */ - modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes)); - if (!modes) - return NULL; - - prop_size = nprops * __GLX_SIZE_INT32; - if (prop_size <= sizeof(buf)) - props = buf; - else - props = Xmalloc(prop_size); - - /* Read each config structure and convert it into our format */ - m = modes; - for (i = 0; i < nvisuals; i++) { - _XRead(dpy, (char *) props, prop_size); - /* Older X servers don't send this so we default it here. */ - m->drawableType = GLX_WINDOW_BIT; - __glXInitializeVisualConfigFromTags(m, nprops, props, - tagged_only, GL_TRUE); - m->screen = screen; - m = m->next; - } - - if (props != buf) - Xfree(props); - - return modes; -} - -static GLboolean -getVisualConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen) -{ - xGLXGetVisualConfigsReq *req; - __GLXscreenConfigs *psc; - xGLXGetVisualConfigsReply reply; - - LockDisplay(dpy); - - psc = priv->screenConfigs + screen; - psc->visuals = NULL; - GetReq(GLXGetVisualConfigs, req); - req->reqType = priv->majorOpcode; - req->glxCode = X_GLXGetVisualConfigs; - req->screen = screen; - - if (!_XReply(dpy, (xReply *) & reply, 0, False)) - goto out; - - psc->visuals = createConfigsFromProperties(dpy, - reply.numVisuals, - reply.numProps, - screen, GL_FALSE); - - out: - UnlockDisplay(dpy); - return psc->visuals != NULL; -} - -static GLboolean -getFBConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen) -{ - xGLXGetFBConfigsReq *fb_req; - xGLXGetFBConfigsSGIXReq *sgi_req; - xGLXVendorPrivateWithReplyReq *vpreq; - xGLXGetFBConfigsReply reply; - __GLXscreenConfigs *psc; - - psc = priv->screenConfigs + screen; - psc->serverGLXexts = - __glXQueryServerString(dpy, priv->majorOpcode, screen, GLX_EXTENSIONS); - - LockDisplay(dpy); - - psc->configs = NULL; - if (atof(priv->serverGLXversion) >= 1.3) { - GetReq(GLXGetFBConfigs, fb_req); - fb_req->reqType = priv->majorOpcode; - fb_req->glxCode = X_GLXGetFBConfigs; - fb_req->screen = screen; - } - else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) { - GetReqExtra(GLXVendorPrivateWithReply, - sz_xGLXGetFBConfigsSGIXReq + - sz_xGLXVendorPrivateWithReplyReq, vpreq); - sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq; - sgi_req->reqType = priv->majorOpcode; - sgi_req->glxCode = X_GLXVendorPrivateWithReply; - sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX; - sgi_req->screen = screen; - } - else - goto out; - - if (!_XReply(dpy, (xReply *) & reply, 0, False)) - goto out; - - psc->configs = createConfigsFromProperties(dpy, - reply.numFBConfigs, - reply.numAttribs * 2, - screen, GL_TRUE); - - out: - UnlockDisplay(dpy); - return psc->configs != NULL; -} - -/* -** Allocate the memory for the per screen configs for each screen. -** If that works then fetch the per screen configs data. -*/ -static Bool -AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv) -{ - __GLXscreenConfigs *psc; - GLint i, screens; - - /* - ** First allocate memory for the array of per screen configs. - */ - screens = ScreenCount(dpy); - psc = (__GLXscreenConfigs *) Xmalloc(screens * sizeof(__GLXscreenConfigs)); - if (!psc) { - return GL_FALSE; - } - memset(psc, 0, screens * sizeof(__GLXscreenConfigs)); - priv->screenConfigs = psc; - - priv->serverGLXversion = - __glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION); - if (priv->serverGLXversion == NULL) { - FreeScreenConfigs(priv); - return GL_FALSE; - } - - for (i = 0; i < screens; i++, psc++) { - getVisualConfigs(dpy, priv, i); - getFBConfigs(dpy, priv, i); - -#ifdef GLX_DIRECT_RENDERING - psc->scr = i; - psc->dpy = dpy; - psc->drawHash = __glxHashCreate(); - if (psc->drawHash == NULL) - continue; - - if (priv->dri2Display) - psc->driScreen = (*priv->dri2Display->createScreen) (psc, i, priv); - - if (psc->driScreen == NULL && priv->driDisplay) - psc->driScreen = (*priv->driDisplay->createScreen) (psc, i, priv); - - if (psc->driScreen == NULL && priv->driswDisplay) - psc->driScreen = (*priv->driswDisplay->createScreen) (psc, i, priv); - - if (psc->driScreen == NULL) { - __glxHashDestroy(psc->drawHash); - psc->drawHash = NULL; - } -#endif - } - SyncHandle(); - return GL_TRUE; -} - -/* -** Initialize the client side extension code. -*/ -_X_HIDDEN __GLXdisplayPrivate * -__glXInitialize(Display * dpy) -{ - XExtDisplayInfo *info = __glXFindDisplay(dpy); - XExtData **privList, *private, *found; - __GLXdisplayPrivate *dpyPriv; - XEDataObject dataObj; - int major, minor; -#ifdef GLX_DIRECT_RENDERING - Bool glx_direct, glx_accel; -#endif - - /* The one and only long long lock */ - __glXLock(); - - if (!XextHasExtension(info)) { - /* No GLX extension supported by this server. Oh well. */ - __glXUnlock(); - XMissingExtension(dpy, __glXExtensionName); - return 0; - } - - /* See if a display private already exists. If so, return it */ - dataObj.display = dpy; - privList = XEHeadOfExtensionList(dataObj); - found = XFindOnExtensionList(privList, info->codes->extension); - if (found) { - __glXUnlock(); - return (__GLXdisplayPrivate *) found->private_data; - } - - /* See if the versions are compatible */ - if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor)) { - /* The client and server do not agree on versions. Punt. */ - __glXUnlock(); - return 0; - } - - /* - ** Allocate memory for all the pieces needed for this buffer. - */ - private = (XExtData *) Xmalloc(sizeof(XExtData)); - if (!private) { - __glXUnlock(); - return 0; - } - dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate)); - if (!dpyPriv) { - __glXUnlock(); - Xfree((char *) private); - return 0; - } - - /* - ** Init the display private and then read in the screen config - ** structures from the server. - */ - dpyPriv->majorOpcode = info->codes->major_opcode; - dpyPriv->majorVersion = major; - dpyPriv->minorVersion = minor; - dpyPriv->dpy = dpy; - - dpyPriv->serverGLXvendor = 0x0; - dpyPriv->serverGLXversion = 0x0; - -#ifdef GLX_DIRECT_RENDERING - glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL); - glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL); - - /* - ** Initialize the direct rendering per display data and functions. - ** Note: This _must_ be done before calling any other DRI routines - ** (e.g., those called in AllocAndFetchScreenConfigs). - */ - if (glx_direct && glx_accel) { - dpyPriv->dri2Display = dri2CreateDisplay(dpy); - dpyPriv->driDisplay = driCreateDisplay(dpy); - } - if (glx_direct) - dpyPriv->driswDisplay = driswCreateDisplay(dpy); -#endif - - if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) { - __glXUnlock(); - Xfree((char *) dpyPriv); - Xfree((char *) private); - return 0; - } - - /* - ** Fill in the private structure. This is the actual structure that - ** hangs off of the Display structure. Our private structure is - ** referred to by this structure. Got that? - */ - private->number = info->codes->extension; - private->next = 0; - private->free_private = __glXFreeDisplayPrivate; - private->private_data = (char *) dpyPriv; - XAddToExtensionList(privList, private); - - if (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion >= 1) { - __glXClientInfo(dpy, dpyPriv->majorOpcode); - } - __glXUnlock(); - - return dpyPriv; -} - -/* -** Setup for sending a GLX command on dpy. Make sure the extension is -** initialized. Try to avoid calling __glXInitialize as its kinda slow. -*/ -_X_HIDDEN CARD8 -__glXSetupForCommand(Display * dpy) -{ - GLXContext gc; - __GLXdisplayPrivate *priv; - - /* If this thread has a current context, flush its rendering commands */ - gc = __glXGetCurrentContext(); - if (gc->currentDpy) { - /* Flush rendering buffer of the current context, if any */ - (void) __glXFlushRenderBuffer(gc, gc->pc); - - if (gc->currentDpy == dpy) { - /* Use opcode from gc because its right */ - return gc->majorOpcode; - } - else { - /* - ** Have to get info about argument dpy because it might be to - ** a different server - */ - } - } - - /* Forced to lookup extension via the slow initialize route */ - priv = __glXInitialize(dpy); - if (!priv) { - return 0; - } - return priv->majorOpcode; -} - -/** - * Flush the drawing command transport buffer. - * - * \param ctx Context whose transport buffer is to be flushed. - * \param pc Pointer to first unused buffer location. - * - * \todo - * Modify this function to use \c ctx->pc instead of the explicit - * \c pc parameter. - */ -_X_HIDDEN GLubyte * -__glXFlushRenderBuffer(__GLXcontext * ctx, GLubyte * pc) -{ - Display *const dpy = ctx->currentDpy; -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); -#else - xGLXRenderReq *req; -#endif /* USE_XCB */ - const GLint size = pc - ctx->buf; - - if ((dpy != NULL) && (size > 0)) { -#ifdef USE_XCB - xcb_glx_render(c, ctx->currentContextTag, size, - (const uint8_t *) ctx->buf); -#else - /* Send the entire buffer as an X request */ - LockDisplay(dpy); - GetReq(GLXRender, req); - req->reqType = ctx->majorOpcode; - req->glxCode = X_GLXRender; - req->contextTag = ctx->currentContextTag; - req->length += (size + 3) >> 2; - _XSend(dpy, (char *) ctx->buf, size); - UnlockDisplay(dpy); - SyncHandle(); -#endif - } - - /* Reset pointer and return it */ - ctx->pc = ctx->buf; - return ctx->pc; -} - - -/** - * Send a portion of a GLXRenderLarge command to the server. The advantage of - * this function over \c __glXSendLargeCommand is that callers can use the - * data buffer in the GLX context and may be able to avoid allocating an - * extra buffer. The disadvantage is the clients will have to do more - * GLX protocol work (i.e., calculating \c totalRequests, etc.). - * - * \sa __glXSendLargeCommand - * - * \param gc GLX context - * \param requestNumber Which part of the whole command is this? The first - * request is 1. - * \param totalRequests How many requests will there be? - * \param data Command data. - * \param dataLen Size, in bytes, of the command data. - */ -_X_HIDDEN void -__glXSendLargeChunk(__GLXcontext * gc, GLint requestNumber, - GLint totalRequests, const GLvoid * data, GLint dataLen) -{ - Display *dpy = gc->currentDpy; -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - xcb_glx_render_large(c, gc->currentContextTag, requestNumber, - totalRequests, dataLen, data); -#else - xGLXRenderLargeReq *req; - - if (requestNumber == 1) { - LockDisplay(dpy); - } - - GetReq(GLXRenderLarge, req); - req->reqType = gc->majorOpcode; - req->glxCode = X_GLXRenderLarge; - req->contextTag = gc->currentContextTag; - req->length += (dataLen + 3) >> 2; - req->requestNumber = requestNumber; - req->requestTotal = totalRequests; - req->dataBytes = dataLen; - Data(dpy, data, dataLen); - - if (requestNumber == totalRequests) { - UnlockDisplay(dpy); - SyncHandle(); - } -#endif /* USE_XCB */ -} - - -/** - * Send a command that is too large for the GLXRender protocol request. - * - * Send a large command, one that is too large for some reason to - * send using the GLXRender protocol request. One reason to send - * a large command is to avoid copying the data. - * - * \param ctx GLX context - * \param header Header data. - * \param headerLen Size, in bytes, of the header data. It is assumed that - * the header data will always be small enough to fit in - * a single X protocol packet. - * \param data Command data. - * \param dataLen Size, in bytes, of the command data. - */ -_X_HIDDEN void -__glXSendLargeCommand(__GLXcontext * ctx, - const GLvoid * header, GLint headerLen, - const GLvoid * data, GLint dataLen) -{ - GLint maxSize; - GLint totalRequests, requestNumber; - - /* - ** Calculate the maximum amount of data can be stuffed into a single - ** packet. sz_xGLXRenderReq is added because bufSize is the maximum - ** packet size minus sz_xGLXRenderReq. - */ - maxSize = (ctx->bufSize + sz_xGLXRenderReq) - sz_xGLXRenderLargeReq; - totalRequests = 1 + (dataLen / maxSize); - if (dataLen % maxSize) - totalRequests++; - - /* - ** Send all of the command, except the large array, as one request. - */ - assert(headerLen <= maxSize); - __glXSendLargeChunk(ctx, 1, totalRequests, header, headerLen); - - /* - ** Send enough requests until the whole array is sent. - */ - for (requestNumber = 2; requestNumber <= (totalRequests - 1); - requestNumber++) { - __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, maxSize); - data = (const GLvoid *) (((const GLubyte *) data) + maxSize); - dataLen -= maxSize; - assert(dataLen > 0); - } - - assert(dataLen <= maxSize); - __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, dataLen); -} - -/************************************************************************/ - -#ifdef DEBUG -_X_HIDDEN void -__glXDumpDrawBuffer(__GLXcontext * ctx) -{ - GLubyte *p = ctx->buf; - GLubyte *end = ctx->pc; - GLushort opcode, length; - - while (p < end) { - /* Fetch opcode */ - opcode = *((GLushort *) p); - length = *((GLushort *) (p + 2)); - printf("%2x: %5d: ", opcode, length); - length -= 4; - p += 4; - while (length > 0) { - printf("%08x ", *((unsigned *) p)); - p += 4; - length -= 4; - } - printf("\n"); - } -} -#endif diff --git a/src/glx/x11/glxextensions.c b/src/glx/x11/glxextensions.c deleted file mode 100644 index 56c69cbfcba..00000000000 --- a/src/glx/x11/glxextensions.c +++ /dev/null @@ -1,714 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2002, 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file glxextensions.c - * - * \author Ian Romanick - */ - -#include "glxclient.h" -#include -#include -#include -#include "glxextensions.h" - - -#define SET_BIT(m,b) (m[ (b) / 8 ] |= (1U << ((b) % 8))) -#define CLR_BIT(m,b) (m[ (b) / 8 ] &= ~(1U << ((b) % 8))) -#define IS_SET(m,b) ((m[ (b) / 8 ] & (1U << ((b) % 8))) != 0) -#define CONCAT(a,b) a ## b -#define GLX(n) "GLX_" # n, 4 + sizeof( # n ) - 1, CONCAT(n,_bit) -#define GL(n) "GL_" # n, 3 + sizeof( # n ) - 1, GL_ ## n ## _bit -#define VER(a,b) a, b -#define Y 1 -#define N 0 -#define EXT_ENABLED(bit,supported) (IS_SET( supported, bit )) - - -struct extension_info -{ - const char *const name; - unsigned name_len; - - unsigned char bit; - - /* This is the lowest version of GLX that "requires" this extension. - * For example, GLX 1.3 requires SGIX_fbconfig, SGIX_pbuffer, and - * SGI_make_current_read. If the extension is not required by any known - * version of GLX, use 0, 0. - */ - unsigned char version_major; - unsigned char version_minor; - unsigned char client_support; - unsigned char direct_support; - unsigned char client_only; /** Is the extension client-side only? */ - unsigned char direct_only; /** Is the extension for direct - * contexts only? - */ -}; - -/* *INDENT-OFF* */ -static const struct extension_info known_glx_extensions[] = { - { GLX(ARB_get_proc_address), VER(1,4), Y, N, Y, N }, - { GLX(ARB_multisample), VER(1,4), Y, Y, N, N }, - { GLX(ARB_render_texture), VER(0,0), N, N, N, N }, - { GLX(ATI_pixel_format_float), VER(0,0), N, N, N, N }, - { GLX(EXT_import_context), VER(0,0), Y, Y, N, N }, - { GLX(EXT_visual_info), VER(0,0), Y, Y, N, N }, - { GLX(EXT_visual_rating), VER(0,0), Y, Y, N, N }, - { GLX(MESA_agp_offset), VER(0,0), N, N, N, Y }, /* Deprecated */ - { GLX(MESA_allocate_memory), VER(0,0), Y, N, N, Y }, - { GLX(MESA_copy_sub_buffer), VER(0,0), Y, N, N, N }, - { GLX(MESA_pixmap_colormap), VER(0,0), N, N, N, N }, /* Deprecated */ - { GLX(MESA_release_buffers), VER(0,0), N, N, N, N }, /* Deprecated */ - { GLX(MESA_swap_control), VER(0,0), Y, N, N, Y }, - { GLX(MESA_swap_frame_usage), VER(0,0), Y, N, N, Y }, - { GLX(NV_float_buffer), VER(0,0), N, N, N, N }, - { GLX(NV_render_depth_texture), VER(0,0), N, N, N, N }, - { GLX(NV_render_texture_rectangle), VER(0,0), N, N, N, N }, - { GLX(NV_vertex_array_range), VER(0,0), N, N, N, Y }, /* Deprecated */ - { GLX(OML_swap_method), VER(0,0), Y, Y, N, N }, - { GLX(OML_sync_control), VER(0,0), Y, N, N, Y }, - { GLX(SGI_make_current_read), VER(1,3), Y, N, N, N }, - { GLX(SGI_swap_control), VER(0,0), Y, N, N, N }, - { GLX(SGI_video_sync), VER(0,0), Y, N, N, Y }, - { GLX(SGIS_blended_overlay), VER(0,0), N, N, N, N }, - { GLX(SGIS_color_range), VER(0,0), N, N, N, N }, - { GLX(SGIS_multisample), VER(0,0), Y, Y, N, N }, - { GLX(SGIX_fbconfig), VER(1,3), Y, Y, N, N }, - { GLX(SGIX_pbuffer), VER(1,3), Y, Y, N, N }, - { GLX(SGIX_swap_barrier), VER(0,0), N, N, N, N }, - { GLX(SGIX_swap_group), VER(0,0), N, N, N, N }, - { GLX(SGIX_visual_select_group), VER(0,0), Y, Y, N, N }, - { GLX(EXT_texture_from_pixmap), VER(0,0), Y, N, N, N }, - { GLX(INTEL_swap_event), VER(1,4), Y, Y, N, N }, - { NULL } -}; - -static const struct extension_info known_gl_extensions[] = { - { GL(ARB_depth_texture), VER(1,4), Y, N, N, N }, - { GL(ARB_draw_buffers), VER(0,0), Y, N, N, N }, - { GL(ARB_fragment_program), VER(0,0), Y, N, N, N }, - { GL(ARB_fragment_program_shadow), VER(0,0), Y, N, N, N }, - { GL(ARB_framebuffer_object), VER(0,0), Y, N, N, N }, - { GL(ARB_imaging), VER(0,0), Y, N, N, N }, - { GL(ARB_multisample), VER(1,3), Y, N, N, N }, - { GL(ARB_multitexture), VER(1,3), Y, N, N, N }, - { GL(ARB_occlusion_query), VER(1,5), Y, N, N, N }, - { GL(ARB_point_parameters), VER(1,4), Y, N, N, N }, - { GL(ARB_point_sprite), VER(0,0), Y, N, N, N }, - { GL(ARB_shadow), VER(1,4), Y, N, N, N }, - { GL(ARB_shadow_ambient), VER(0,0), Y, N, N, N }, - { GL(ARB_texture_border_clamp), VER(1,3), Y, N, N, N }, - { GL(ARB_texture_compression), VER(1,3), Y, N, N, N }, - { GL(ARB_texture_cube_map), VER(1,3), Y, N, N, N }, - { GL(ARB_texture_env_add), VER(1,3), Y, N, N, N }, - { GL(ARB_texture_env_combine), VER(1,3), Y, N, N, N }, - { GL(ARB_texture_env_crossbar), VER(1,4), Y, N, N, N }, - { GL(ARB_texture_env_dot3), VER(1,3), Y, N, N, N }, - { GL(ARB_texture_mirrored_repeat), VER(1,4), Y, N, N, N }, - { GL(ARB_texture_non_power_of_two), VER(1,5), Y, N, N, N }, - { GL(ARB_texture_rectangle), VER(0,0), Y, N, N, N }, - { GL(ARB_transpose_matrix), VER(1,3), Y, N, Y, N }, - { GL(ARB_vertex_buffer_object), VER(1,5), N, N, N, N }, - { GL(ARB_vertex_program), VER(0,0), Y, N, N, N }, - { GL(ARB_window_pos), VER(1,4), Y, N, N, N }, - { GL(EXT_abgr), VER(0,0), Y, N, N, N }, - { GL(EXT_bgra), VER(1,2), Y, N, N, N }, - { GL(EXT_blend_color), VER(1,4), Y, N, N, N }, - { GL(EXT_blend_equation_separate), VER(0,0), Y, N, N, N }, - { GL(EXT_blend_func_separate), VER(1,4), Y, N, N, N }, - { GL(EXT_blend_logic_op), VER(1,4), Y, N, N, N }, - { GL(EXT_blend_minmax), VER(1,4), Y, N, N, N }, - { GL(EXT_blend_subtract), VER(1,4), Y, N, N, N }, - { GL(EXT_clip_volume_hint), VER(0,0), Y, N, N, N }, - { GL(EXT_compiled_vertex_array), VER(0,0), N, N, N, N }, - { GL(EXT_convolution), VER(0,0), N, N, N, N }, - { GL(EXT_copy_texture), VER(1,1), Y, N, N, N }, - { GL(EXT_cull_vertex), VER(0,0), N, N, N, N }, - { GL(EXT_depth_bounds_test), VER(0,0), N, N, N, N }, - { GL(EXT_draw_range_elements), VER(1,2), Y, N, Y, N }, - { GL(EXT_fog_coord), VER(1,4), Y, N, N, N }, - { GL(EXT_framebuffer_blit), VER(0,0), Y, N, N, N }, - { GL(EXT_framebuffer_multisample), VER(0,0), Y, N, N, N }, - { GL(EXT_framebuffer_object), VER(0,0), Y, N, N, N }, - { GL(EXT_multi_draw_arrays), VER(1,4), Y, N, Y, N }, - { GL(EXT_packed_depth_stencil), VER(0,0), Y, N, N, N }, - { GL(EXT_packed_pixels), VER(1,2), Y, N, N, N }, - { GL(EXT_paletted_texture), VER(0,0), Y, N, N, N }, - { GL(EXT_pixel_buffer_object), VER(0,0), N, N, N, N }, - { GL(EXT_point_parameters), VER(1,4), Y, N, N, N }, - { GL(EXT_polygon_offset), VER(1,1), Y, N, N, N }, - { GL(EXT_rescale_normal), VER(1,2), Y, N, N, N }, - { GL(EXT_secondary_color), VER(1,4), Y, N, N, N }, - { GL(EXT_separate_specular_color), VER(1,2), Y, N, N, N }, - { GL(EXT_shadow_funcs), VER(1,5), Y, N, N, N }, - { GL(EXT_shared_texture_palette), VER(0,0), Y, N, N, N }, - { GL(EXT_stencil_two_side), VER(0,0), Y, N, N, N }, - { GL(EXT_stencil_wrap), VER(1,4), Y, N, N, N }, - { GL(EXT_subtexture), VER(1,1), Y, N, N, N }, - { GL(EXT_texture), VER(1,1), Y, N, N, N }, - { GL(EXT_texture3D), VER(1,2), Y, N, N, N }, - { GL(EXT_texture_compression_dxt1), VER(0,0), Y, N, N, N }, - { GL(EXT_texture_compression_s3tc), VER(0,0), Y, N, N, N }, - { GL(EXT_texture_edge_clamp), VER(1,2), Y, N, N, N }, - { GL(EXT_texture_env_add), VER(1,3), Y, N, N, N }, - { GL(EXT_texture_env_combine), VER(1,3), Y, N, N, N }, - { GL(EXT_texture_env_dot3), VER(0,0), Y, N, N, N }, - { GL(EXT_texture_filter_anisotropic), VER(0,0), Y, N, N, N }, - { GL(EXT_texture_lod), VER(1,2), Y, N, N, N }, - { GL(EXT_texture_lod_bias), VER(1,4), Y, N, N, N }, - { GL(EXT_texture_mirror_clamp), VER(0,0), Y, N, N, N }, - { GL(EXT_texture_object), VER(1,1), Y, N, N, N }, - { GL(EXT_texture_rectangle), VER(0,0), Y, N, N, N }, - { GL(EXT_vertex_array), VER(0,0), Y, N, N, N }, - { GL(3DFX_texture_compression_FXT1), VER(0,0), Y, N, N, N }, - { GL(APPLE_packed_pixels), VER(1,2), Y, N, N, N }, - { GL(APPLE_ycbcr_422), VER(0,0), Y, N, N, N }, - { GL(ATI_draw_buffers), VER(0,0), Y, N, N, N }, - { GL(ATI_text_fragment_shader), VER(0,0), Y, N, N, N }, - { GL(ATI_texture_env_combine3), VER(0,0), Y, N, N, N }, - { GL(ATI_texture_float), VER(0,0), Y, N, N, N }, - { GL(ATI_texture_mirror_once), VER(0,0), Y, N, N, N }, - { GL(ATIX_texture_env_combine3), VER(0,0), Y, N, N, N }, - { GL(HP_convolution_border_modes), VER(0,0), Y, N, N, N }, - { GL(HP_occlusion_test), VER(0,0), Y, N, N, N }, - { GL(IBM_cull_vertex), VER(0,0), Y, N, N, N }, - { GL(IBM_pixel_filter_hint), VER(0,0), Y, N, N, N }, - { GL(IBM_rasterpos_clip), VER(0,0), Y, N, N, N }, - { GL(IBM_texture_clamp_nodraw), VER(0,0), Y, N, N, N }, - { GL(IBM_texture_mirrored_repeat), VER(0,0), Y, N, N, N }, - { GL(INGR_blend_func_separate), VER(0,0), Y, N, N, N }, - { GL(INGR_interlace_read), VER(0,0), Y, N, N, N }, - { GL(MESA_pack_invert), VER(0,0), Y, N, N, N }, - { GL(MESA_ycbcr_texture), VER(0,0), Y, N, N, N }, - { GL(NV_blend_square), VER(1,4), Y, N, N, N }, - { GL(NV_copy_depth_to_color), VER(0,0), Y, N, N, N }, - { GL(NV_depth_clamp), VER(0,0), Y, N, N, N }, - { GL(NV_fog_distance), VER(0,0), Y, N, N, N }, - { GL(NV_fragment_program), VER(0,0), Y, N, N, N }, - { GL(NV_fragment_program_option), VER(0,0), Y, N, N, N }, - { GL(NV_fragment_program2), VER(0,0), Y, N, N, N }, - { GL(NV_light_max_exponent), VER(0,0), Y, N, N, N }, - { GL(NV_multisample_filter_hint), VER(0,0), Y, N, N, N }, - { GL(NV_packed_depth_stencil), VER(0,0), Y, N, N, N }, - { GL(NV_point_sprite), VER(0,0), Y, N, N, N }, - { GL(NV_texgen_reflection), VER(0,0), Y, N, N, N }, - { GL(NV_texture_compression_vtc), VER(0,0), Y, N, N, N }, - { GL(NV_texture_env_combine4), VER(0,0), Y, N, N, N }, - { GL(NV_texture_rectangle), VER(0,0), Y, N, N, N }, - { GL(NV_vertex_program), VER(0,0), Y, N, N, N }, - { GL(NV_vertex_program1_1), VER(0,0), Y, N, N, N }, - { GL(NV_vertex_program2), VER(0,0), Y, N, N, N }, - { GL(NV_vertex_program2_option), VER(0,0), Y, N, N, N }, - { GL(NV_vertex_program3), VER(0,0), Y, N, N, N }, - { GL(OES_read_format), VER(0,0), Y, N, N, N }, - { GL(OES_compressed_paletted_texture),VER(0,0), Y, N, N, N }, - { GL(SGI_color_matrix), VER(0,0), Y, N, N, N }, - { GL(SGI_color_table), VER(0,0), Y, N, N, N }, - { GL(SGI_texture_color_table), VER(0,0), Y, N, N, N }, - { GL(SGIS_generate_mipmap), VER(1,4), Y, N, N, N }, - { GL(SGIS_multisample), VER(0,0), Y, N, N, N }, - { GL(SGIS_texture_border_clamp), VER(1,3), Y, N, N, N }, - { GL(SGIS_texture_edge_clamp), VER(1,2), Y, N, N, N }, - { GL(SGIS_texture_lod), VER(1,2), Y, N, N, N }, - { GL(SGIX_blend_alpha_minmax), VER(0,0), Y, N, N, N }, - { GL(SGIX_clipmap), VER(0,0), Y, N, N, N }, - { GL(SGIX_depth_texture), VER(0,0), Y, N, N, N }, - { GL(SGIX_fog_offset), VER(0,0), Y, N, N, N }, - { GL(SGIX_shadow), VER(0,0), Y, N, N, N }, - { GL(SGIX_shadow_ambient), VER(0,0), Y, N, N, N }, - { GL(SGIX_texture_coordinate_clamp), VER(0,0), Y, N, N, N }, - { GL(SGIX_texture_lod_bias), VER(0,0), Y, N, N, N }, - { GL(SGIX_texture_range), VER(0,0), Y, N, N, N }, - { GL(SGIX_texture_scale_bias), VER(0,0), Y, N, N, N }, - { GL(SGIX_vertex_preclip), VER(0,0), Y, N, N, N }, - { GL(SGIX_vertex_preclip_hint), VER(0,0), Y, N, N, N }, - { GL(SGIX_ycrcb), VER(0,0), Y, N, N, N }, - { GL(SUN_convolution_border_modes), VER(0,0), Y, N, N, N }, - { GL(SUN_multi_draw_arrays), VER(0,0), Y, N, Y, N }, - { GL(SUN_slice_accum), VER(0,0), Y, N, N, N }, - { NULL } -}; -/* *INDENT-ON* */ - - -/* global bit-fields of available extensions and their characteristics */ -static unsigned char client_glx_support[8]; -static unsigned char client_glx_only[8]; -static unsigned char direct_glx_only[8]; -static unsigned char client_gl_support[__GL_EXT_BYTES]; -static unsigned char client_gl_only[__GL_EXT_BYTES]; - -/** - * Bits representing the set of extensions that are enabled by default in all - * direct rendering drivers. - */ -static unsigned char direct_glx_support[8]; - -/** - * Highest core GL version that can be supported for indirect rendering. - */ -static const unsigned gl_major = 1; -static const unsigned gl_minor = 4; - -/* client extensions string */ -static const char *__glXGLXClientExtensions = NULL; - -static void __glXExtensionsCtr(void); -static void __glXExtensionsCtrScreen(__GLXscreenConfigs * psc); -static void __glXProcessServerString(const struct extension_info *ext, - const char *server_string, - unsigned char *server_support); - -/** - * Set the state of a GLX extension. - * - * \param name Name of the extension. - * \param name_len Length, in characters, of the extension name. - * \param state New state (either enabled or disabled) of the extension. - * \param supported Table in which the state of the extension is to be set. - */ -static void -set_glx_extension(const struct extension_info *ext, - const char *name, unsigned name_len, GLboolean state, - unsigned char *supported) -{ - unsigned i; - - - for (i = 0; ext[i].name != NULL; i++) { - if ((name_len == ext[i].name_len) - && (strncmp(ext[i].name, name, name_len) == 0)) { - if (state) { - SET_BIT(supported, ext[i].bit); - } - else { - CLR_BIT(supported, ext[i].bit); - } - - return; - } - } -} - - -#define NUL '\0' -#define SEPARATOR ' ' - -/** - * Convert the server's extension string to a bit-field. - * - * \param server_string GLX extension string from the server. - * \param server_support Bit-field of supported extensions. - * - * \note - * This function is used to process both GLX and GL extension strings. The - * bit-fields used to track each of these have different sizes. Therefore, - * the data pointed by \c server_support must be preinitialized to zero. - */ -static void -__glXProcessServerString(const struct extension_info *ext, - const char *server_string, - unsigned char *server_support) -{ - unsigned base; - unsigned len; - - for (base = 0; server_string[base] != NUL; /* empty */ ) { - /* Determine the length of the next extension name. - */ - for (len = 0; (server_string[base + len] != SEPARATOR) - && (server_string[base + len] != NUL); len++) { - /* empty */ - } - - /* Set the bit for the extension in the server_support table. - */ - set_glx_extension(ext, &server_string[base], len, GL_TRUE, - server_support); - - - /* Advance to the next extension string. This means that we skip - * over the previous string and any trialing white-space. - */ - for (base += len; (server_string[base] == SEPARATOR) - && (server_string[base] != NUL); base++) { - /* empty */ - } - } -} - -void -__glXEnableDirectExtension(__GLXscreenConfigs * psc, const char *name) -{ - __glXExtensionsCtr(); - __glXExtensionsCtrScreen(psc); - - set_glx_extension(known_glx_extensions, - name, strlen(name), GL_TRUE, psc->direct_support); -} - -/** - * Initialize global extension support tables. - */ - -static void -__glXExtensionsCtr(void) -{ - unsigned i; - static GLboolean ext_list_first_time = GL_TRUE; - - - if (ext_list_first_time) { - ext_list_first_time = GL_FALSE; - - (void) memset(client_glx_support, 0, sizeof(client_glx_support)); - (void) memset(direct_glx_support, 0, sizeof(direct_glx_support)); - (void) memset(client_glx_only, 0, sizeof(client_glx_only)); - (void) memset(direct_glx_only, 0, sizeof(direct_glx_only)); - - (void) memset(client_gl_support, 0, sizeof(client_gl_support)); - (void) memset(client_gl_only, 0, sizeof(client_gl_only)); - - for (i = 0; known_glx_extensions[i].name != NULL; i++) { - const unsigned bit = known_glx_extensions[i].bit; - - if (known_glx_extensions[i].client_support) { - SET_BIT(client_glx_support, bit); - } - - if (known_glx_extensions[i].direct_support) { - SET_BIT(direct_glx_support, bit); - } - - if (known_glx_extensions[i].client_only) { - SET_BIT(client_glx_only, bit); - } - - if (known_glx_extensions[i].direct_only) { - SET_BIT(direct_glx_only, bit); - } - } - - for (i = 0; known_gl_extensions[i].name != NULL; i++) { - const unsigned bit = known_gl_extensions[i].bit; - - if (known_gl_extensions[i].client_support) { - SET_BIT(client_gl_support, bit); - } - - if (known_gl_extensions[i].client_only) { - SET_BIT(client_gl_only, bit); - } - } - -#if 0 - fprintf(stderr, "[%s:%u] Maximum client library version: %u.%u\n", - __func__, __LINE__, gl_major, gl_minor); -#endif - } -} - - -/** - * Make sure that per-screen direct-support table is initialized. - * - * \param psc Pointer to GLX per-screen record. - */ - -static void -__glXExtensionsCtrScreen(__GLXscreenConfigs * psc) -{ - if (psc->ext_list_first_time) { - psc->ext_list_first_time = GL_FALSE; - (void) memcpy(psc->direct_support, direct_glx_support, - sizeof(direct_glx_support)); - } -} - - -/** - * Check if a certain extension is enabled on a given screen. - * - * \param psc Pointer to GLX per-screen record. - * \param bit Bit index in the direct-support table. - * \returns If the extension bit is enabled for the screen, \c GL_TRUE is - * returned. If the extension bit is not enabled or if \c psc is - * \c NULL, then \c GL_FALSE is returned. - */ -GLboolean -__glXExtensionBitIsEnabled(__GLXscreenConfigs * psc, unsigned bit) -{ - GLboolean enabled = GL_FALSE; - - if (psc != NULL) { - __glXExtensionsCtr(); - __glXExtensionsCtrScreen(psc); - enabled = EXT_ENABLED(bit, psc->direct_support); - } - - return enabled; -} - - -/** - * Check if a certain extension is enabled in a given context. - * - */ -GLboolean -__glExtensionBitIsEnabled(const __GLXcontext * gc, unsigned bit) -{ - GLboolean enabled = GL_FALSE; - - if (gc != NULL) { - enabled = EXT_ENABLED(bit, gc->gl_extension_bits); - } - - return enabled; -} - - - -/** - * Convert a bit-field to a string of supported extensions. - */ -static char * -__glXGetStringFromTable(const struct extension_info *ext, - const unsigned char *supported) -{ - unsigned i; - unsigned ext_str_len; - char *ext_str; - char *point; - - - ext_str_len = 0; - for (i = 0; ext[i].name != NULL; i++) { - if (EXT_ENABLED(ext[i].bit, supported)) { - ext_str_len += ext[i].name_len + 1; - } - } - - ext_str = Xmalloc(ext_str_len + 1); - if (ext_str != NULL) { - point = ext_str; - - for (i = 0; ext[i].name != NULL; i++) { - if (EXT_ENABLED(ext[i].bit, supported)) { - (void) memcpy(point, ext[i].name, ext[i].name_len); - point += ext[i].name_len; - - *point = ' '; - point++; - } - } - - *point = '\0'; - } - - return ext_str; -} - - -/** - * Get the string of client library supported extensions. - */ -const char * -__glXGetClientExtensions(void) -{ - if (__glXGLXClientExtensions == NULL) { - __glXExtensionsCtr(); - __glXGLXClientExtensions = __glXGetStringFromTable(known_glx_extensions, - client_glx_support); - } - - return __glXGLXClientExtensions; -} - - -/** - * Calculate the list of application usable extensions. The resulting - * string is stored in \c psc->effectiveGLXexts. - * - * \param psc Pointer to GLX per-screen record. - * \param display_is_direct_capable True if the display is capable of - * direct rendering. - * \param minor_version GLX minor version from the server. - */ - -void -__glXCalculateUsableExtensions(__GLXscreenConfigs * psc, - GLboolean display_is_direct_capable, - int minor_version) -{ - unsigned char server_support[8]; - unsigned char usable[8]; - unsigned i; - - __glXExtensionsCtr(); - __glXExtensionsCtrScreen(psc); - - (void) memset(server_support, 0, sizeof(server_support)); - __glXProcessServerString(known_glx_extensions, - psc->serverGLXexts, server_support); - - - /* This is a hack. Some servers support GLX 1.3 but don't export - * all of the extensions implied by GLX 1.3. If the server claims - * support for GLX 1.3, enable support for the extensions that can be - * "emulated" as well. - */ - - if (minor_version >= 3) { - SET_BIT(server_support, EXT_visual_info_bit); - SET_BIT(server_support, EXT_visual_rating_bit); - SET_BIT(server_support, SGI_make_current_read_bit); - SET_BIT(server_support, SGIX_fbconfig_bit); - SET_BIT(server_support, SGIX_pbuffer_bit); - - /* This one is a little iffy. GLX 1.3 doesn't incorporate all of this - * extension. However, the only part that is not strictly client-side - * is shared. That's the glXQueryContext / glXQueryContextInfoEXT - * function. - */ - - SET_BIT(server_support, EXT_import_context_bit); - } - - - /* An extension is supported if the client-side (i.e., libGL) supports - * it and the "server" supports it. In this case that means that either - * the true server supports it or it is only for direct-rendering and - * the direct rendering driver supports it. - * - * If the display is not capable of direct rendering, then the extension - * is enabled if and only if the client-side library and the server - * support it. - */ - - if (display_is_direct_capable) { - for (i = 0; i < 8; i++) { - usable[i] = (client_glx_support[i] & client_glx_only[i]) - | (client_glx_support[i] & psc->direct_support[i] & - server_support[i]) - | (client_glx_support[i] & psc->direct_support[i] & - direct_glx_only[i]); - } - } - else { - for (i = 0; i < 8; i++) { - usable[i] = (client_glx_support[i] & client_glx_only[i]) - | (client_glx_support[i] & server_support[i]); - } - } - - psc->effectiveGLXexts = __glXGetStringFromTable(known_glx_extensions, - usable); -} - - -/** - * Calculate the list of application usable extensions. The resulting - * string is stored in \c gc->extensions. - * - * \param gc Pointer to GLX context. - * \param server_string Extension string from the server. - * \param major_version GL major version from the server. - * \param minor_version GL minor version from the server. - */ - -void -__glXCalculateUsableGLExtensions(__GLXcontext * gc, - const char *server_string, - int major_version, int minor_version) -{ - unsigned char server_support[__GL_EXT_BYTES]; - unsigned char usable[__GL_EXT_BYTES]; - unsigned i; - - - __glXExtensionsCtr(); - - (void) memset(server_support, 0, sizeof(server_support)); - __glXProcessServerString(known_gl_extensions, server_string, - server_support); - - - /* Handle lazy servers that don't export all the extensions strings that - * are part of the GL core version that they support. - */ - - for (i = 0; i < __GL_EXT_BYTES; i++) { - if ((known_gl_extensions[i].version_major != 0) - && ((major_version > known_gl_extensions[i].version_major) - || ((major_version == known_gl_extensions[i].version_major) - && (minor_version >= - known_gl_extensions[i].version_minor)))) { - SET_BIT(server_support, known_gl_extensions[i].bit); - } - } - - - /* An extension is supported if the client-side (i.e., libGL) supports - * it and the server supports it or the client-side library supports it - * and it only needs client-side support. - */ - - for (i = 0; i < __GL_EXT_BYTES; i++) { - usable[i] = (client_gl_support[i] & client_gl_only[i]) - | (client_gl_support[i] & server_support[i]); - } - - gc->extensions = (unsigned char *) - __glXGetStringFromTable(known_gl_extensions, usable); - (void) memcpy(gc->gl_extension_bits, usable, sizeof(usable)); -} - - -/** - * Calculates the maximum core GL version that can be supported for indirect - * rendering. - */ -void -__glXGetGLVersion(int *major_version, int *minor_version) -{ - __glXExtensionsCtr(); - *major_version = gl_major; - *minor_version = gl_minor; -} - - -/** - * Get a string representing the set of extensions supported by the client - * library. This is currently only used to send the list of extensions - * supported by the client to the server. - */ -char * -__glXGetClientGLExtensionString(void) -{ - __glXExtensionsCtr(); - return __glXGetStringFromTable(known_gl_extensions, client_gl_support); -} diff --git a/src/glx/x11/glxextensions.h b/src/glx/x11/glxextensions.h deleted file mode 100644 index f556b1239c9..00000000000 --- a/src/glx/x11/glxextensions.h +++ /dev/null @@ -1,292 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2002, 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file glxextensions.h - * - * \author Ian Romanick - */ - -#ifndef GLX_GLXEXTENSIONS_H -#define GLX_GLXEXTENSIONS_H - -enum -{ - ARB_get_proc_address_bit = 0, - ARB_multisample_bit, - ARB_render_texture_bit, - ATI_pixel_format_float_bit, - EXT_visual_info_bit, - EXT_visual_rating_bit, - EXT_import_context_bit, - MESA_agp_offset_bit, - MESA_allocate_memory_bit, /* Replaces MESA_agp_offset & NV_vertex_array_range */ - MESA_copy_sub_buffer_bit, - MESA_depth_float_bit, - MESA_pixmap_colormap_bit, - MESA_release_buffers_bit, - MESA_swap_control_bit, - MESA_swap_frame_usage_bit, - NV_float_buffer_bit, - NV_render_depth_texture_bit, - NV_render_texture_rectangle_bit, - NV_vertex_array_range_bit, - OML_swap_method_bit, - OML_sync_control_bit, - SGI_make_current_read_bit, - SGI_swap_control_bit, - SGI_video_sync_bit, - SGIS_blended_overlay_bit, - SGIS_color_range_bit, - SGIS_multisample_bit, - SGIX_fbconfig_bit, - SGIX_pbuffer_bit, - SGIX_swap_barrier_bit, - SGIX_swap_group_bit, - SGIX_visual_select_group_bit, - EXT_texture_from_pixmap_bit, - INTEL_swap_event_bit, -}; - -enum -{ - GL_ARB_depth_texture_bit = 0, - GL_ARB_draw_buffers_bit, - GL_ARB_fragment_program_bit, - GL_ARB_fragment_program_shadow_bit, - GL_ARB_framebuffer_object_bit, - GL_ARB_imaging_bit, - GL_ARB_multisample_bit, - GL_ARB_multitexture_bit, - GL_ARB_occlusion_query_bit, - GL_ARB_point_parameters_bit, - GL_ARB_point_sprite_bit, - GL_ARB_shadow_bit, - GL_ARB_shadow_ambient_bit, - GL_ARB_texture_border_clamp_bit, - GL_ARB_texture_cube_map_bit, - GL_ARB_texture_compression_bit, - GL_ARB_texture_env_add_bit, - GL_ARB_texture_env_combine_bit, - GL_ARB_texture_env_crossbar_bit, - GL_ARB_texture_env_dot3_bit, - GL_ARB_texture_mirrored_repeat_bit, - GL_ARB_texture_non_power_of_two_bit, - GL_ARB_texture_rectangle_bit, - GL_ARB_transpose_matrix_bit, - GL_ARB_vertex_buffer_object_bit, - GL_ARB_vertex_program_bit, - GL_ARB_window_pos_bit, - GL_EXT_abgr_bit, - GL_EXT_bgra_bit, - GL_EXT_blend_color_bit, - GL_EXT_blend_equation_separate_bit, - GL_EXT_blend_func_separate_bit, - GL_EXT_blend_logic_op_bit, - GL_EXT_blend_minmax_bit, - GL_EXT_blend_subtract_bit, - GL_EXT_clip_volume_hint_bit, - GL_EXT_compiled_vertex_array_bit, - GL_EXT_convolution_bit, - GL_EXT_copy_texture_bit, - GL_EXT_cull_vertex_bit, - GL_EXT_depth_bounds_test_bit, - GL_EXT_draw_range_elements_bit, - GL_EXT_fog_coord_bit, - GL_EXT_framebuffer_blit_bit, - GL_EXT_framebuffer_multisample_bit, - GL_EXT_framebuffer_object_bit, - GL_EXT_multi_draw_arrays_bit, - GL_EXT_packed_depth_stencil_bit, - GL_EXT_packed_pixels_bit, - GL_EXT_paletted_texture_bit, - GL_EXT_pixel_buffer_object_bit, - GL_EXT_polygon_offset_bit, - GL_EXT_rescale_normal_bit, - GL_EXT_secondary_color_bit, - GL_EXT_separate_specular_color_bit, - GL_EXT_shadow_funcs_bit, - GL_EXT_shared_texture_palette_bit, - GL_EXT_stencil_two_side_bit, - GL_EXT_stencil_wrap_bit, - GL_EXT_subtexture_bit, - GL_EXT_texture_bit, - GL_EXT_texture3D_bit, - GL_EXT_texture_compression_dxt1_bit, - GL_EXT_texture_compression_s3tc_bit, - GL_EXT_texture_edge_clamp_bit, - GL_EXT_texture_env_combine_bit, - GL_EXT_texture_env_dot3_bit, - GL_EXT_texture_filter_anisotropic_bit, - GL_EXT_texture_lod_bit, - GL_EXT_texture_lod_bias_bit, - GL_EXT_texture_mirror_clamp_bit, - GL_EXT_texture_object_bit, - GL_EXT_vertex_array_bit, - GL_3DFX_texture_compression_FXT1_bit, - GL_APPLE_packed_pixels_bit, - GL_APPLE_ycbcr_422_bit, - GL_ATI_text_fragment_shader_bit, - GL_ATI_texture_env_combine3_bit, - GL_ATI_texture_float_bit, - GL_ATI_texture_mirror_once_bit, - GL_HP_convolution_border_modes_bit, - GL_HP_occlusion_test_bit, - GL_IBM_cull_vertex_bit, - GL_IBM_pixel_filter_hint_bit, - GL_IBM_rasterpos_clip_bit, - GL_IBM_texture_clamp_nodraw_bit, - GL_INGR_interlace_read_bit, - GL_MESA_pack_invert_bit, - GL_MESA_ycbcr_texture_bit, - GL_NV_blend_square_bit, - GL_NV_copy_depth_to_color_bit, - GL_NV_depth_clamp_bit, - GL_NV_fog_distance_bit, - GL_NV_fragment_program_bit, - GL_NV_fragment_program_option_bit, - GL_NV_fragment_program2_bit, - GL_NV_light_max_exponent_bit, - GL_NV_multisample_filter_hint_bit, - GL_NV_packed_depth_stencil_bit, - GL_NV_point_sprite_bit, - GL_NV_texgen_reflection_bit, - GL_NV_texture_compression_vtc_bit, - GL_NV_texture_env_combine4_bit, - GL_NV_vertex_program_bit, - GL_NV_vertex_program1_1_bit, - GL_NV_vertex_program2_bit, - GL_NV_vertex_program2_option_bit, - GL_NV_vertex_program3_bit, - GL_OES_compressed_paletted_texture_bit, - GL_OES_read_format_bit, - GL_SGI_color_matrix_bit, - GL_SGI_color_table_bit, - GL_SGI_texture_color_table_bit, - GL_SGIS_generate_mipmap_bit, - GL_SGIS_multisample_bit, - GL_SGIS_texture_lod_bit, - GL_SGIX_blend_alpha_minmax_bit, - GL_SGIX_clipmap_bit, - GL_SGIX_depth_texture_bit, - GL_SGIX_fog_offset_bit, - GL_SGIX_shadow_bit, - GL_SGIX_texture_coordinate_clamp_bit, - GL_SGIX_texture_lod_bias_bit, - GL_SGIX_texture_range_bit, - GL_SGIX_texture_scale_bias_bit, - GL_SGIX_vertex_preclip_bit, - GL_SGIX_vertex_preclip_hint_bit, - GL_SGIX_ycrcb_bit, - GL_SUN_convolution_border_modes_bit, - GL_SUN_slice_accum_bit, - - /* This *MUST* go here. If it gets put after the duplicate values it will - * get the value after the last duplicate. - */ - __NUM_GL_EXTS, - - - /* Alias extension bits. These extensions exist in either vendor-specific - * or EXT form and were later promoted to either EXT or ARB form. In all - * cases, the meaning is *exactly* the same. That's why - * EXT_texture_env_combine is *NOT* an alias of ARB_texture_env_combine and - * EXT_texture_env_dot3 is *NOT* an alias of ARB_texture_env_dot3. Be - * careful! When in doubt, src/mesa/main/extensions.c in the Mesa tree - * is a great reference. - */ - - GL_ATI_blend_equation_separate_bit = GL_EXT_blend_equation_separate_bit, - GL_ATI_draw_buffers_bit = GL_ARB_draw_buffers_bit, - GL_ATIX_texture_env_combine3_bit = GL_ATI_texture_env_combine3_bit, - GL_EXT_point_parameters_bit = GL_ARB_point_parameters_bit, - GL_EXT_texture_env_add_bit = GL_ARB_texture_env_add_bit, - GL_EXT_texture_rectangle_bit = GL_ARB_texture_rectangle_bit, - GL_IBM_texture_mirrored_repeat_bit = GL_ARB_texture_mirrored_repeat_bit, - GL_INGR_blend_func_separate_bit = GL_EXT_blend_func_separate_bit, - GL_MESA_window_pos_bit = GL_ARB_window_pos_bit, - GL_NV_texture_rectangle_bit = GL_ARB_texture_rectangle_bit, - GL_SGIS_texture_border_clamp_bit = GL_ARB_texture_border_clamp_bit, - GL_SGIS_texture_edge_clamp_bit = GL_EXT_texture_edge_clamp_bit, - GL_SGIX_shadow_ambient_bit = GL_ARB_shadow_ambient_bit, - GL_SUN_multi_draw_arrays_bit = GL_EXT_multi_draw_arrays_bit -}; - -#define __GL_EXT_BYTES ((__NUM_GL_EXTS + 7) / 8) - -struct __GLXscreenConfigsRec; -struct __GLXcontextRec; - -extern GLboolean __glXExtensionBitIsEnabled(struct __GLXscreenConfigsRec *psc, - unsigned bit); -extern const char *__glXGetClientExtensions(void); -extern void __glXCalculateUsableExtensions(struct __GLXscreenConfigsRec *psc, - GLboolean - display_is_direct_capable, - int server_minor_version); - -extern void __glXCalculateUsableGLExtensions(struct __GLXcontextRec *gc, - const char *server_string, - int major_version, - int minor_version); -extern void __glXGetGLVersion(int *major_version, int *minor_version); -extern char *__glXGetClientGLExtensionString(void); - -extern GLboolean __glExtensionBitIsEnabled(const struct __GLXcontextRec *gc, - unsigned bit); - -extern void -__glXEnableDirectExtension(struct __GLXscreenConfigsRec *psc, - const char *name); - -/* Source-level backwards compatibility with old drivers. They won't - * find the respective functions, though. - */ -typedef void (*PFNGLXENABLEEXTENSIONPROC) (const char *name, - GLboolean force_client); -typedef void (*PFNGLXDISABLEEXTENSIONPROC) (const char *name); - -/* GLX_ALIAS should be used for functions with a non-void return type. - GLX_ALIAS_VOID is for functions with a void return type. */ -#ifdef GLX_NO_STATIC_EXTENSION_FUNCTIONS -# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) -# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) -#else -# if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED) -# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \ - return_type real_func proto_args \ - __attribute__ ((alias( # aliased_func ) )); -# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \ - GLX_ALIAS(void, real_func, proto_args, args, aliased_func) -# else -# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \ - return_type real_func proto_args \ - { return aliased_func args ; } -# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \ - void real_func proto_args \ - { aliased_func args ; } -# endif /* __GNUC__ */ -#endif /* GLX_NO_STATIC_EXTENSION_FUNCTIONS */ - -#endif /* GLX_GLXEXTENSIONS_H */ diff --git a/src/glx/x11/glxhash.c b/src/glx/x11/glxhash.c deleted file mode 100644 index b76ec323459..00000000000 --- a/src/glx/x11/glxhash.c +++ /dev/null @@ -1,473 +0,0 @@ -/* glxhash.c -- Small hash table support for integer -> integer mapping - * Taken from libdrm. - * - * Created: Sun Apr 18 09:35:45 1999 by faith@precisioninsight.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: Rickard E. (Rik) Faith - * - * DESCRIPTION - * - * This file contains a straightforward implementation of a fixed-sized - * hash table using self-organizing linked lists [Knuth73, pp. 398-399] for - * collision resolution. There are two potentially interesting things - * about this implementation: - * - * 1) The table is power-of-two sized. Prime sized tables are more - * traditional, but do not have a significant advantage over power-of-two - * sized table, especially when double hashing is not used for collision - * resolution. - * - * 2) The hash computation uses a table of random integers [Hanson97, - * pp. 39-41]. - * - * FUTURE ENHANCEMENTS - * - * With a table size of 512, the current implementation is sufficient for a - * few hundred keys. Since this is well above the expected size of the - * tables for which this implementation was designed, the implementation of - * dynamic hash tables was postponed until the need arises. A common (and - * naive) approach to dynamic hash table implementation simply creates a - * new hash table when necessary, rehashes all the data into the new table, - * and destroys the old table. The approach in [Larson88] is superior in - * two ways: 1) only a portion of the table is expanded when needed, - * distributing the expansion cost over several insertions, and 2) portions - * of the table can be locked, enabling a scalable thread-safe - * implementation. - * - * REFERENCES - * - * [Hanson97] David R. Hanson. C Interfaces and Implementations: - * Techniques for Creating Reusable Software. Reading, Massachusetts: - * Addison-Wesley, 1997. - * - * [Knuth73] Donald E. Knuth. The Art of Computer Programming. Volume 3: - * Sorting and Searching. Reading, Massachusetts: Addison-Wesley, 1973. - * - * [Larson88] Per-Ake Larson. "Dynamic Hash Tables". CACM 31(4), April - * 1988, pp. 446-457. - * - */ - -#include "glxhash.h" -#include - -#define HASH_MAIN 0 - -#include -#include -#include - -#define HASH_MAGIC 0xdeadbeef -#define HASH_DEBUG 0 -#define HASH_SIZE 512 /* Good for about 100 entries */ - /* If you change this value, you probably - have to change the HashHash hashing - function! */ - -#define HASH_ALLOC malloc -#define HASH_FREE free -#ifndef __GLIBC__ -#define HASH_RANDOM_DECL char *ps, rs[256] -#define HASH_RANDOM_INIT(seed) ps = initstate(seed, rs, sizeof(rs)) -#define HASH_RANDOM random() -#define HASH_RANDOM_DESTROY setstate(ps) -#else -#define HASH_RANDOM_DECL struct random_data rd; int32_t rv; char rs[256] -#define HASH_RANDOM_INIT(seed) \ - do { \ - (void) memset(&rd, 0, sizeof(rd)); \ - (void) initstate_r(seed, rs, sizeof(rs), &rd); \ - } while(0) -#define HASH_RANDOM ((void) random_r(&rd, &rv), rv) -#define HASH_RANDOM_DESTROY -#endif - -typedef struct __glxHashBucket -{ - unsigned long key; - void *value; - struct __glxHashBucket *next; -} __glxHashBucket, *__glxHashBucketPtr; - -typedef struct __glxHashTable *__glxHashTablePtr; -struct __glxHashTable -{ - unsigned long magic; - unsigned long hits; /* At top of linked list */ - unsigned long partials; /* Not at top of linked list */ - unsigned long misses; /* Not in table */ - __glxHashBucketPtr buckets[HASH_SIZE]; - int p0; - __glxHashBucketPtr p1; -}; - -static unsigned long -HashHash(unsigned long key) -{ - unsigned long hash = 0; - unsigned long tmp = key; - static int init = 0; - static unsigned long scatter[256]; - int i; - - if (!init) { - HASH_RANDOM_DECL; - HASH_RANDOM_INIT(37); - for (i = 0; i < 256; i++) - scatter[i] = HASH_RANDOM; - HASH_RANDOM_DESTROY; - ++init; - } - - while (tmp) { - hash = (hash << 1) + scatter[tmp & 0xff]; - tmp >>= 8; - } - - hash %= HASH_SIZE; -#if HASH_DEBUG - printf("Hash(%d) = %d\n", key, hash); -#endif - return hash; -} - -_X_HIDDEN __glxHashTable * -__glxHashCreate(void) -{ - __glxHashTablePtr table; - int i; - - table = HASH_ALLOC(sizeof(*table)); - if (!table) - return NULL; - table->magic = HASH_MAGIC; - table->hits = 0; - table->partials = 0; - table->misses = 0; - - for (i = 0; i < HASH_SIZE; i++) - table->buckets[i] = NULL; - return table; -} - -_X_HIDDEN int -__glxHashDestroy(__glxHashTable * t) -{ - __glxHashTablePtr table = (__glxHashTablePtr) t; - __glxHashBucketPtr bucket; - __glxHashBucketPtr next; - int i; - - if (table->magic != HASH_MAGIC) - return -1; /* Bad magic */ - - for (i = 0; i < HASH_SIZE; i++) { - for (bucket = table->buckets[i]; bucket;) { - next = bucket->next; - HASH_FREE(bucket); - bucket = next; - } - } - HASH_FREE(table); - return 0; -} - -/* Find the bucket and organize the list so that this bucket is at the - top. */ - -static __glxHashBucketPtr -HashFind(__glxHashTablePtr table, unsigned long key, unsigned long *h) -{ - unsigned long hash = HashHash(key); - __glxHashBucketPtr prev = NULL; - __glxHashBucketPtr bucket; - - if (h) - *h = hash; - - for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) { - if (bucket->key == key) { - if (prev) { - /* Organize */ - prev->next = bucket->next; - bucket->next = table->buckets[hash]; - table->buckets[hash] = bucket; - ++table->partials; - } - else { - ++table->hits; - } - return bucket; - } - prev = bucket; - } - ++table->misses; - return NULL; -} - -_X_HIDDEN int -__glxHashLookup(__glxHashTable * t, unsigned long key, void **value) -{ - __glxHashTablePtr table = (__glxHashTablePtr) t; - __glxHashBucketPtr bucket; - - if (!table || table->magic != HASH_MAGIC) - return -1; /* Bad magic */ - - bucket = HashFind(table, key, NULL); - if (!bucket) - return 1; /* Not found */ - *value = bucket->value; - return 0; /* Found */ -} - -_X_HIDDEN int -__glxHashInsert(__glxHashTable * t, unsigned long key, void *value) -{ - __glxHashTablePtr table = (__glxHashTablePtr) t; - __glxHashBucketPtr bucket; - unsigned long hash; - - if (table->magic != HASH_MAGIC) - return -1; /* Bad magic */ - - if (HashFind(table, key, &hash)) - return 1; /* Already in table */ - - bucket = HASH_ALLOC(sizeof(*bucket)); - if (!bucket) - return -1; /* Error */ - bucket->key = key; - bucket->value = value; - bucket->next = table->buckets[hash]; - table->buckets[hash] = bucket; -#if HASH_DEBUG - printf("Inserted %d at %d/%p\n", key, hash, bucket); -#endif - return 0; /* Added to table */ -} - -_X_HIDDEN int -__glxHashDelete(__glxHashTable * t, unsigned long key) -{ - __glxHashTablePtr table = (__glxHashTablePtr) t; - unsigned long hash; - __glxHashBucketPtr bucket; - - if (table->magic != HASH_MAGIC) - return -1; /* Bad magic */ - - bucket = HashFind(table, key, &hash); - - if (!bucket) - return 1; /* Not found */ - - table->buckets[hash] = bucket->next; - HASH_FREE(bucket); - return 0; -} - -_X_HIDDEN int -__glxHashNext(__glxHashTable * t, unsigned long *key, void **value) -{ - __glxHashTablePtr table = (__glxHashTablePtr) t; - - while (table->p0 < HASH_SIZE) { - if (table->p1) { - *key = table->p1->key; - *value = table->p1->value; - table->p1 = table->p1->next; - return 1; - } - table->p1 = table->buckets[table->p0]; - ++table->p0; - } - return 0; -} - -_X_HIDDEN int -__glxHashFirst(__glxHashTable * t, unsigned long *key, void **value) -{ - __glxHashTablePtr table = (__glxHashTablePtr) t; - - if (table->magic != HASH_MAGIC) - return -1; /* Bad magic */ - - table->p0 = 0; - table->p1 = table->buckets[0]; - return __glxHashNext(table, key, value); -} - -#if HASH_MAIN -#define DIST_LIMIT 10 -static int dist[DIST_LIMIT]; - -static void -clear_dist(void) -{ - int i; - - for (i = 0; i < DIST_LIMIT; i++) - dist[i] = 0; -} - -static int -count_entries(__glxHashBucketPtr bucket) -{ - int count = 0; - - for (; bucket; bucket = bucket->next) - ++count; - return count; -} - -static void -update_dist(int count) -{ - if (count >= DIST_LIMIT) - ++dist[DIST_LIMIT - 1]; - else - ++dist[count]; -} - -static void -compute_dist(__glxHashTablePtr table) -{ - int i; - __glxHashBucketPtr bucket; - - printf("Hits = %ld, partials = %ld, misses = %ld\n", - table->hits, table->partials, table->misses); - clear_dist(); - for (i = 0; i < HASH_SIZE; i++) { - bucket = table->buckets[i]; - update_dist(count_entries(bucket)); - } - for (i = 0; i < DIST_LIMIT; i++) { - if (i != DIST_LIMIT - 1) - printf("%5d %10d\n", i, dist[i]); - else - printf("other %10d\n", dist[i]); - } -} - -static void -check_table(__glxHashTablePtr table, unsigned long key, unsigned long value) -{ - unsigned long retval = 0; - int retcode = __glxHashLookup(table, key, &retval); - - switch (retcode) { - case -1: - printf("Bad magic = 0x%08lx:" - " key = %lu, expected = %lu, returned = %lu\n", - table->magic, key, value, retval); - break; - case 1: - printf("Not found: key = %lu, expected = %lu returned = %lu\n", - key, value, retval); - break; - case 0: - if (value != retval) - printf("Bad value: key = %lu, expected = %lu, returned = %lu\n", - key, value, retval); - break; - default: - printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n", - retcode, key, value, retval); - break; - } -} - -int -main(void) -{ - __glxHashTablePtr table; - int i; - - printf("\n***** 256 consecutive integers ****\n"); - table = __glxHashCreate(); - for (i = 0; i < 256; i++) - __glxHashInsert(table, i, i); - for (i = 0; i < 256; i++) - check_table(table, i, i); - for (i = 256; i >= 0; i--) - check_table(table, i, i); - compute_dist(table); - __glxHashDestroy(table); - - printf("\n***** 1024 consecutive integers ****\n"); - table = __glxHashCreate(); - for (i = 0; i < 1024; i++) - __glxHashInsert(table, i, i); - for (i = 0; i < 1024; i++) - check_table(table, i, i); - for (i = 1024; i >= 0; i--) - check_table(table, i, i); - compute_dist(table); - __glxHashDestroy(table); - - printf("\n***** 1024 consecutive page addresses (4k pages) ****\n"); - table = __glxHashCreate(); - for (i = 0; i < 1024; i++) - __glxHashInsert(table, i * 4096, i); - for (i = 0; i < 1024; i++) - check_table(table, i * 4096, i); - for (i = 1024; i >= 0; i--) - check_table(table, i * 4096, i); - compute_dist(table); - __glxHashDestroy(table); - - printf("\n***** 1024 random integers ****\n"); - table = __glxHashCreate(); - srandom(0xbeefbeef); - for (i = 0; i < 1024; i++) - __glxHashInsert(table, random(), i); - srandom(0xbeefbeef); - for (i = 0; i < 1024; i++) - check_table(table, random(), i); - srandom(0xbeefbeef); - for (i = 0; i < 1024; i++) - check_table(table, random(), i); - compute_dist(table); - __glxHashDestroy(table); - - printf("\n***** 5000 random integers ****\n"); - table = __glxHashCreate(); - srandom(0xbeefbeef); - for (i = 0; i < 5000; i++) - __glxHashInsert(table, random(), i); - srandom(0xbeefbeef); - for (i = 0; i < 5000; i++) - check_table(table, random(), i); - srandom(0xbeefbeef); - for (i = 0; i < 5000; i++) - check_table(table, random(), i); - compute_dist(table); - __glxHashDestroy(table); - - return 0; -} -#endif diff --git a/src/glx/x11/glxhash.h b/src/glx/x11/glxhash.h deleted file mode 100644 index 710712dd28a..00000000000 --- a/src/glx/x11/glxhash.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _GLX_HASH_H_ -#define _GLX_HASH_H_ - - -typedef struct __glxHashTable __glxHashTable; - -/* Hash table routines */ -extern __glxHashTable *__glxHashCreate(void); -extern int __glxHashDestroy(__glxHashTable * t); -extern int __glxHashLookup(__glxHashTable * t, unsigned long key, - void **value); -extern int __glxHashInsert(__glxHashTable * t, unsigned long key, - void *value); -extern int __glxHashDelete(__glxHashTable * t, unsigned long key); -extern int __glxHashFirst(__glxHashTable * t, unsigned long *key, - void **value); -extern int __glxHashNext(__glxHashTable * t, unsigned long *key, - void **value); - -#endif /* _GLX_HASH_H_ */ diff --git a/src/glx/x11/indirect.c b/src/glx/x11/indirect.c deleted file mode 100644 index 48bae1478f4..00000000000 --- a/src/glx/x11/indirect.c +++ /dev/null @@ -1,10669 +0,0 @@ -/* DO NOT EDIT - This file generated automatically by glX_proto_send.py (from Mesa) script */ - -/* - * (C) Copyright IBM Corporation 2004, 2005 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - -#include -#include "indirect.h" -#include "glxclient.h" -#include "indirect_size.h" -#include "glapitable.h" -#include "glapidispatch.h" -#include "glapi.h" -#include "glthread.h" -#include -#ifdef USE_XCB -#include -#include -#include -#endif /* USE_XCB */ - -#define __GLX_PAD(n) (((n) + 3) & ~3) - -# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) -# define FASTCALL __attribute__((fastcall)) -# else -# define FASTCALL -# endif -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define NOINLINE __attribute__((noinline)) -# else -# define NOINLINE -# endif - -#if !defined __GNUC__ || __GNUC__ < 3 -# define __builtin_expect(x, y) x -#endif - -/* If the size and opcode values are known at compile-time, this will, on - * x86 at least, emit them with a single instruction. - */ -#define emit_header(dest, op, size) \ - do { union { short s[2]; int i; } temp; \ - temp.s[0] = (size); temp.s[1] = (op); \ - *((int *)(dest)) = temp.i; } while(0) - -NOINLINE CARD32 -__glXReadReply(Display * dpy, size_t size, void *dest, - GLboolean reply_is_always_array) -{ - xGLXSingleReply reply; - - (void) _XReply(dpy, (xReply *) & reply, 0, False); - if (size != 0) { - if ((reply.length > 0) || reply_is_always_array) { - const GLint bytes = (reply_is_always_array) - ? (4 * reply.length) : (reply.size * size); - const GLint extra = 4 - (bytes & 3); - - _XRead(dpy, dest, bytes); - if (extra < 4) { - _XEatData(dpy, extra); - } - } else { - (void) memcpy(dest, &(reply.pad3), size); - } - } - - return reply.retval; -} - -NOINLINE void -__glXReadPixelReply(Display * dpy, __GLXcontext * gc, unsigned max_dim, - GLint width, GLint height, GLint depth, GLenum format, - GLenum type, void *dest, GLboolean dimensions_in_reply) -{ - xGLXSingleReply reply; - GLint size; - - (void) _XReply(dpy, (xReply *) & reply, 0, False); - - if (dimensions_in_reply) { - width = reply.pad3; - height = reply.pad4; - depth = reply.pad5; - - if ((height == 0) || (max_dim < 2)) { - height = 1; - } - if ((depth == 0) || (max_dim < 3)) { - depth = 1; - } - } - - size = reply.length * 4; - if (size != 0) { - void *buf = Xmalloc(size); - - if (buf == NULL) { - _XEatData(dpy, size); - __glXSetError(gc, GL_OUT_OF_MEMORY); - } else { - const GLint extra = 4 - (size & 3); - - _XRead(dpy, buf, size); - if (extra < 4) { - _XEatData(dpy, extra); - } - - __glEmptyImage(gc, 3, width, height, depth, format, type, - buf, dest); - Xfree(buf); - } - } -} - -#define X_GLXSingle 0 - -NOINLINE FASTCALL GLubyte * -__glXSetupSingleRequest(__GLXcontext * gc, GLint sop, GLint cmdlen) -{ - xGLXSingleReq *req; - Display *const dpy = gc->currentDpy; - - (void) __glXFlushRenderBuffer(gc, gc->pc); - LockDisplay(dpy); - GetReqExtra(GLXSingle, cmdlen, req); - req->reqType = gc->majorOpcode; - req->contextTag = gc->currentContextTag; - req->glxCode = sop; - return (GLubyte *) (req) + sz_xGLXSingleReq; -} - -NOINLINE FASTCALL GLubyte * -__glXSetupVendorRequest(__GLXcontext * gc, GLint code, GLint vop, - GLint cmdlen) -{ - xGLXVendorPrivateReq *req; - Display *const dpy = gc->currentDpy; - - (void) __glXFlushRenderBuffer(gc, gc->pc); - LockDisplay(dpy); - GetReqExtra(GLXVendorPrivate, cmdlen, req); - req->reqType = gc->majorOpcode; - req->glxCode = code; - req->vendorCode = vop; - req->contextTag = gc->currentContextTag; - return (GLubyte *) (req) + sz_xGLXVendorPrivateReq; -} - -const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; - -#define zero (__glXDefaultPixelStore+0) -#define one (__glXDefaultPixelStore+8) -#define default_pixel_store_1D (__glXDefaultPixelStore+4) -#define default_pixel_store_1D_size 20 -#define default_pixel_store_2D (__glXDefaultPixelStore+4) -#define default_pixel_store_2D_size 20 -#define default_pixel_store_3D (__glXDefaultPixelStore+0) -#define default_pixel_store_3D_size 36 -#define default_pixel_store_4D (__glXDefaultPixelStore+0) -#define default_pixel_store_4D_size 36 - -static FASTCALL NOINLINE void -generic_3_byte(GLint rop, const void *ptr) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - - emit_header(gc->pc, rop, cmdlen); - (void) memcpy((void *) (gc->pc + 4), ptr, 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -static FASTCALL NOINLINE void -generic_4_byte(GLint rop, const void *ptr) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - - emit_header(gc->pc, rop, cmdlen); - (void) memcpy((void *) (gc->pc + 4), ptr, 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -static FASTCALL NOINLINE void -generic_6_byte(GLint rop, const void *ptr) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - - emit_header(gc->pc, rop, cmdlen); - (void) memcpy((void *) (gc->pc + 4), ptr, 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -static FASTCALL NOINLINE void -generic_8_byte(GLint rop, const void *ptr) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - - emit_header(gc->pc, rop, cmdlen); - (void) memcpy((void *) (gc->pc + 4), ptr, 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -static FASTCALL NOINLINE void -generic_12_byte(GLint rop, const void *ptr) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - - emit_header(gc->pc, rop, cmdlen); - (void) memcpy((void *) (gc->pc + 4), ptr, 12); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -static FASTCALL NOINLINE void -generic_16_byte(GLint rop, const void *ptr) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - - emit_header(gc->pc, rop, cmdlen); - (void) memcpy((void *) (gc->pc + 4), ptr, 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -static FASTCALL NOINLINE void -generic_24_byte(GLint rop, const void *ptr) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - - emit_header(gc->pc, rop, cmdlen); - (void) memcpy((void *) (gc->pc + 4), ptr, 24); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -static FASTCALL NOINLINE void -generic_32_byte(GLint rop, const void *ptr) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 36; - - emit_header(gc->pc, rop, cmdlen); - (void) memcpy((void *) (gc->pc + 4), ptr, 32); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLsop_NewList 101 -void -__indirect_glNewList(GLuint list, GLenum mode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_new_list(c, gc->currentContextTag, list, mode); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_NewList, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&list), 4); - (void) memcpy((void *) (pc + 4), (void *) (&mode), 4); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_EndList 102 -void -__indirect_glEndList(void) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 0; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_end_list(c, gc->currentContextTag); -#else - (void) __glXSetupSingleRequest(gc, X_GLsop_EndList, cmdlen); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLrop_CallList 1 -void -__indirect_glCallList(GLuint list) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_CallList, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&list), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_CallLists 2 -void -__indirect_glCallLists(GLsizei n, GLenum type, const GLvoid * lists) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glCallLists_size(type); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * n)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((n >= 0) && (gc->currentDpy != NULL), 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, X_GLrop_CallLists, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&type), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (lists), - (compsize * n)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = X_GLrop_CallLists; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (pc + 12), (void *) (&type), 4); - __glXSendLargeCommand(gc, pc, 16, lists, (compsize * n)); - } - } -} - -#define X_GLsop_DeleteLists 103 -void -__indirect_glDeleteLists(GLuint list, GLsizei range) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_delete_lists(c, gc->currentContextTag, list, range); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_DeleteLists, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&list), 4); - (void) memcpy((void *) (pc + 4), (void *) (&range), 4); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GenLists 104 -GLuint -__indirect_glGenLists(GLsizei range) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - GLuint retval = (GLuint) 0; -#ifndef USE_XCB - const GLuint cmdlen = 4; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_gen_lists_reply_t *reply = - xcb_glx_gen_lists_reply(c, - xcb_glx_gen_lists(c, - gc->currentContextTag, - range), NULL); - retval = reply->ret_val; - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GenLists, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&range), 4); - retval = (GLuint) __glXReadReply(dpy, 0, NULL, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return retval; -} - -#define X_GLrop_ListBase 3 -void -__indirect_glListBase(GLuint base) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_ListBase, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&base), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Begin 4 -void -__indirect_glBegin(GLenum mode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Begin, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Bitmap 5 -void -__indirect_glBitmap(GLsizei width, GLsizei height, GLfloat xorig, - GLfloat yorig, GLfloat xmove, GLfloat ymove, - const GLubyte *bitmap) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = - (bitmap != NULL) ? __glImageSize(width, height, 1, GL_COLOR_INDEX, - GL_BITMAP, 0) : 0; - const GLuint cmdlen = 48 + __GLX_PAD(compsize); - if (__builtin_expect(gc->currentDpy != NULL, 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, X_GLrop_Bitmap, cmdlen); - (void) memcpy((void *) (gc->pc + 24), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (&height), 4); - (void) memcpy((void *) (gc->pc + 32), (void *) (&xorig), 4); - (void) memcpy((void *) (gc->pc + 36), (void *) (&yorig), 4); - (void) memcpy((void *) (gc->pc + 40), (void *) (&xmove), 4); - (void) memcpy((void *) (gc->pc + 44), (void *) (&ymove), 4); - if (compsize > 0) { - (*gc->fillImage) (gc, 2, width, height, 1, GL_COLOR_INDEX, - GL_BITMAP, bitmap, gc->pc + 48, gc->pc + 4); - } else { - (void) memcpy(gc->pc + 4, default_pixel_store_2D, - default_pixel_store_2D_size); - } - gc->pc += cmdlen; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = X_GLrop_Bitmap; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 28), (void *) (&width), 4); - (void) memcpy((void *) (pc + 32), (void *) (&height), 4); - (void) memcpy((void *) (pc + 36), (void *) (&xorig), 4); - (void) memcpy((void *) (pc + 40), (void *) (&yorig), 4); - (void) memcpy((void *) (pc + 44), (void *) (&xmove), 4); - (void) memcpy((void *) (pc + 48), (void *) (&ymove), 4); - __glXSendLargeImage(gc, compsize, 2, width, height, 1, - GL_COLOR_INDEX, GL_BITMAP, bitmap, pc + 52, - pc + 8); - } - } -} - -#define X_GLrop_Color3bv 6 -void -__indirect_glColor3b(GLbyte red, GLbyte green, GLbyte blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Color3bv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); - (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); - (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color3bv 6 -void -__indirect_glColor3bv(const GLbyte *v) -{ - generic_3_byte(X_GLrop_Color3bv, v); -} - -#define X_GLrop_Color3dv 7 -void -__indirect_glColor3d(GLdouble red, GLdouble green, GLdouble blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_Color3dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&green), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&blue), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color3dv 7 -void -__indirect_glColor3dv(const GLdouble * v) -{ - generic_24_byte(X_GLrop_Color3dv, v); -} - -#define X_GLrop_Color3fv 8 -void -__indirect_glColor3f(GLfloat red, GLfloat green, GLfloat blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Color3fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color3fv 8 -void -__indirect_glColor3fv(const GLfloat * v) -{ - generic_12_byte(X_GLrop_Color3fv, v); -} - -#define X_GLrop_Color3iv 9 -void -__indirect_glColor3i(GLint red, GLint green, GLint blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Color3iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color3iv 9 -void -__indirect_glColor3iv(const GLint * v) -{ - generic_12_byte(X_GLrop_Color3iv, v); -} - -#define X_GLrop_Color3sv 10 -void -__indirect_glColor3s(GLshort red, GLshort green, GLshort blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Color3sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&green), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&blue), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color3sv 10 -void -__indirect_glColor3sv(const GLshort * v) -{ - generic_6_byte(X_GLrop_Color3sv, v); -} - -#define X_GLrop_Color3ubv 11 -void -__indirect_glColor3ub(GLubyte red, GLubyte green, GLubyte blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Color3ubv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); - (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); - (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color3ubv 11 -void -__indirect_glColor3ubv(const GLubyte *v) -{ - generic_3_byte(X_GLrop_Color3ubv, v); -} - -#define X_GLrop_Color3uiv 12 -void -__indirect_glColor3ui(GLuint red, GLuint green, GLuint blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Color3uiv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color3uiv 12 -void -__indirect_glColor3uiv(const GLuint * v) -{ - generic_12_byte(X_GLrop_Color3uiv, v); -} - -#define X_GLrop_Color3usv 13 -void -__indirect_glColor3us(GLushort red, GLushort green, GLushort blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Color3usv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&green), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&blue), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color3usv 13 -void -__indirect_glColor3usv(const GLushort * v) -{ - generic_6_byte(X_GLrop_Color3usv, v); -} - -#define X_GLrop_Color4bv 14 -void -__indirect_glColor4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Color4bv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); - (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); - (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); - (void) memcpy((void *) (gc->pc + 7), (void *) (&alpha), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color4bv 14 -void -__indirect_glColor4bv(const GLbyte *v) -{ - generic_4_byte(X_GLrop_Color4bv, v); -} - -#define X_GLrop_Color4dv 15 -void -__indirect_glColor4d(GLdouble red, GLdouble green, GLdouble blue, - GLdouble alpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 36; - emit_header(gc->pc, X_GLrop_Color4dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&green), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&blue), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&alpha), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color4dv 15 -void -__indirect_glColor4dv(const GLdouble * v) -{ - generic_32_byte(X_GLrop_Color4dv, v); -} - -#define X_GLrop_Color4fv 16 -void -__indirect_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Color4fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&alpha), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color4fv 16 -void -__indirect_glColor4fv(const GLfloat * v) -{ - generic_16_byte(X_GLrop_Color4fv, v); -} - -#define X_GLrop_Color4iv 17 -void -__indirect_glColor4i(GLint red, GLint green, GLint blue, GLint alpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Color4iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&alpha), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color4iv 17 -void -__indirect_glColor4iv(const GLint * v) -{ - generic_16_byte(X_GLrop_Color4iv, v); -} - -#define X_GLrop_Color4sv 18 -void -__indirect_glColor4s(GLshort red, GLshort green, GLshort blue, GLshort alpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Color4sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&green), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&blue), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&alpha), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color4sv 18 -void -__indirect_glColor4sv(const GLshort * v) -{ - generic_8_byte(X_GLrop_Color4sv, v); -} - -#define X_GLrop_Color4ubv 19 -void -__indirect_glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Color4ubv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); - (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); - (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); - (void) memcpy((void *) (gc->pc + 7), (void *) (&alpha), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color4ubv 19 -void -__indirect_glColor4ubv(const GLubyte *v) -{ - generic_4_byte(X_GLrop_Color4ubv, v); -} - -#define X_GLrop_Color4uiv 20 -void -__indirect_glColor4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Color4uiv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&alpha), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color4uiv 20 -void -__indirect_glColor4uiv(const GLuint * v) -{ - generic_16_byte(X_GLrop_Color4uiv, v); -} - -#define X_GLrop_Color4usv 21 -void -__indirect_glColor4us(GLushort red, GLushort green, GLushort blue, - GLushort alpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Color4usv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&green), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&blue), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&alpha), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Color4usv 21 -void -__indirect_glColor4usv(const GLushort * v) -{ - generic_8_byte(X_GLrop_Color4usv, v); -} - -#define X_GLrop_EdgeFlagv 22 -void -__indirect_glEdgeFlag(GLboolean flag) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_EdgeFlagv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&flag), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_EdgeFlagv 22 -void -__indirect_glEdgeFlagv(const GLboolean * flag) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_EdgeFlagv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (flag), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_End 23 -void -__indirect_glEnd(void) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 4; - emit_header(gc->pc, X_GLrop_End, cmdlen); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Indexdv 24 -void -__indirect_glIndexd(GLdouble c) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Indexdv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&c), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Indexdv 24 -void -__indirect_glIndexdv(const GLdouble * c) -{ - generic_8_byte(X_GLrop_Indexdv, c); -} - -#define X_GLrop_Indexfv 25 -void -__indirect_glIndexf(GLfloat c) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Indexfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&c), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Indexfv 25 -void -__indirect_glIndexfv(const GLfloat * c) -{ - generic_4_byte(X_GLrop_Indexfv, c); -} - -#define X_GLrop_Indexiv 26 -void -__indirect_glIndexi(GLint c) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Indexiv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&c), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Indexiv 26 -void -__indirect_glIndexiv(const GLint * c) -{ - generic_4_byte(X_GLrop_Indexiv, c); -} - -#define X_GLrop_Indexsv 27 -void -__indirect_glIndexs(GLshort c) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Indexsv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&c), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Indexsv 27 -void -__indirect_glIndexsv(const GLshort * c) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Indexsv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (c), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Normal3bv 28 -void -__indirect_glNormal3b(GLbyte nx, GLbyte ny, GLbyte nz) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Normal3bv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&nx), 1); - (void) memcpy((void *) (gc->pc + 5), (void *) (&ny), 1); - (void) memcpy((void *) (gc->pc + 6), (void *) (&nz), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Normal3bv 28 -void -__indirect_glNormal3bv(const GLbyte *v) -{ - generic_3_byte(X_GLrop_Normal3bv, v); -} - -#define X_GLrop_Normal3dv 29 -void -__indirect_glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_Normal3dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&nx), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&ny), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&nz), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Normal3dv 29 -void -__indirect_glNormal3dv(const GLdouble * v) -{ - generic_24_byte(X_GLrop_Normal3dv, v); -} - -#define X_GLrop_Normal3fv 30 -void -__indirect_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Normal3fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&nx), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&ny), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&nz), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Normal3fv 30 -void -__indirect_glNormal3fv(const GLfloat * v) -{ - generic_12_byte(X_GLrop_Normal3fv, v); -} - -#define X_GLrop_Normal3iv 31 -void -__indirect_glNormal3i(GLint nx, GLint ny, GLint nz) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Normal3iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&nx), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&ny), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&nz), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Normal3iv 31 -void -__indirect_glNormal3iv(const GLint * v) -{ - generic_12_byte(X_GLrop_Normal3iv, v); -} - -#define X_GLrop_Normal3sv 32 -void -__indirect_glNormal3s(GLshort nx, GLshort ny, GLshort nz) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Normal3sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&nx), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&ny), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&nz), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Normal3sv 32 -void -__indirect_glNormal3sv(const GLshort * v) -{ - generic_6_byte(X_GLrop_Normal3sv, v); -} - -#define X_GLrop_RasterPos2dv 33 -void -__indirect_glRasterPos2d(GLdouble x, GLdouble y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_RasterPos2dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_RasterPos2dv 33 -void -__indirect_glRasterPos2dv(const GLdouble * v) -{ - generic_16_byte(X_GLrop_RasterPos2dv, v); -} - -#define X_GLrop_RasterPos2fv 34 -void -__indirect_glRasterPos2f(GLfloat x, GLfloat y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_RasterPos2fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_RasterPos2fv 34 -void -__indirect_glRasterPos2fv(const GLfloat * v) -{ - generic_8_byte(X_GLrop_RasterPos2fv, v); -} - -#define X_GLrop_RasterPos2iv 35 -void -__indirect_glRasterPos2i(GLint x, GLint y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_RasterPos2iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_RasterPos2iv 35 -void -__indirect_glRasterPos2iv(const GLint * v) -{ - generic_8_byte(X_GLrop_RasterPos2iv, v); -} - -#define X_GLrop_RasterPos2sv 36 -void -__indirect_glRasterPos2s(GLshort x, GLshort y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_RasterPos2sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&y), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_RasterPos2sv 36 -void -__indirect_glRasterPos2sv(const GLshort * v) -{ - generic_4_byte(X_GLrop_RasterPos2sv, v); -} - -#define X_GLrop_RasterPos3dv 37 -void -__indirect_glRasterPos3d(GLdouble x, GLdouble y, GLdouble z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_RasterPos3dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_RasterPos3dv 37 -void -__indirect_glRasterPos3dv(const GLdouble * v) -{ - generic_24_byte(X_GLrop_RasterPos3dv, v); -} - -#define X_GLrop_RasterPos3fv 38 -void -__indirect_glRasterPos3f(GLfloat x, GLfloat y, GLfloat z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_RasterPos3fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_RasterPos3fv 38 -void -__indirect_glRasterPos3fv(const GLfloat * v) -{ - generic_12_byte(X_GLrop_RasterPos3fv, v); -} - -#define X_GLrop_RasterPos3iv 39 -void -__indirect_glRasterPos3i(GLint x, GLint y, GLint z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_RasterPos3iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_RasterPos3iv 39 -void -__indirect_glRasterPos3iv(const GLint * v) -{ - generic_12_byte(X_GLrop_RasterPos3iv, v); -} - -#define X_GLrop_RasterPos3sv 40 -void -__indirect_glRasterPos3s(GLshort x, GLshort y, GLshort z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_RasterPos3sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&y), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&z), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_RasterPos3sv 40 -void -__indirect_glRasterPos3sv(const GLshort * v) -{ - generic_6_byte(X_GLrop_RasterPos3sv, v); -} - -#define X_GLrop_RasterPos4dv 41 -void -__indirect_glRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 36; - emit_header(gc->pc, X_GLrop_RasterPos4dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&w), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_RasterPos4dv 41 -void -__indirect_glRasterPos4dv(const GLdouble * v) -{ - generic_32_byte(X_GLrop_RasterPos4dv, v); -} - -#define X_GLrop_RasterPos4fv 42 -void -__indirect_glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_RasterPos4fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&w), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_RasterPos4fv 42 -void -__indirect_glRasterPos4fv(const GLfloat * v) -{ - generic_16_byte(X_GLrop_RasterPos4fv, v); -} - -#define X_GLrop_RasterPos4iv 43 -void -__indirect_glRasterPos4i(GLint x, GLint y, GLint z, GLint w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_RasterPos4iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&w), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_RasterPos4iv 43 -void -__indirect_glRasterPos4iv(const GLint * v) -{ - generic_16_byte(X_GLrop_RasterPos4iv, v); -} - -#define X_GLrop_RasterPos4sv 44 -void -__indirect_glRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_RasterPos4sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&y), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&z), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&w), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_RasterPos4sv 44 -void -__indirect_glRasterPos4sv(const GLshort * v) -{ - generic_8_byte(X_GLrop_RasterPos4sv, v); -} - -#define X_GLrop_Rectdv 45 -void -__indirect_glRectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 36; - emit_header(gc->pc, X_GLrop_Rectdv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x1), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y1), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&x2), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&y2), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Rectdv 45 -void -__indirect_glRectdv(const GLdouble * v1, const GLdouble * v2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 36; - emit_header(gc->pc, X_GLrop_Rectdv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (v1), 16); - (void) memcpy((void *) (gc->pc + 20), (void *) (v2), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Rectfv 46 -void -__indirect_glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Rectfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x1), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y1), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&x2), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y2), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Rectfv 46 -void -__indirect_glRectfv(const GLfloat * v1, const GLfloat * v2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Rectfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (v1), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (v2), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Rectiv 47 -void -__indirect_glRecti(GLint x1, GLint y1, GLint x2, GLint y2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Rectiv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x1), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y1), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&x2), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y2), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Rectiv 47 -void -__indirect_glRectiv(const GLint * v1, const GLint * v2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Rectiv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (v1), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (v2), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Rectsv 48 -void -__indirect_glRects(GLshort x1, GLshort y1, GLshort x2, GLshort y2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Rectsv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x1), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&y1), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x2), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&y2), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Rectsv 48 -void -__indirect_glRectsv(const GLshort * v1, const GLshort * v2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Rectsv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (v1), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v2), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord1dv 49 -void -__indirect_glTexCoord1d(GLdouble s) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_TexCoord1dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord1dv 49 -void -__indirect_glTexCoord1dv(const GLdouble * v) -{ - generic_8_byte(X_GLrop_TexCoord1dv, v); -} - -#define X_GLrop_TexCoord1fv 50 -void -__indirect_glTexCoord1f(GLfloat s) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_TexCoord1fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord1fv 50 -void -__indirect_glTexCoord1fv(const GLfloat * v) -{ - generic_4_byte(X_GLrop_TexCoord1fv, v); -} - -#define X_GLrop_TexCoord1iv 51 -void -__indirect_glTexCoord1i(GLint s) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_TexCoord1iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord1iv 51 -void -__indirect_glTexCoord1iv(const GLint * v) -{ - generic_4_byte(X_GLrop_TexCoord1iv, v); -} - -#define X_GLrop_TexCoord1sv 52 -void -__indirect_glTexCoord1s(GLshort s) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_TexCoord1sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord1sv 52 -void -__indirect_glTexCoord1sv(const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_TexCoord1sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (v), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord2dv 53 -void -__indirect_glTexCoord2d(GLdouble s, GLdouble t) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_TexCoord2dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord2dv 53 -void -__indirect_glTexCoord2dv(const GLdouble * v) -{ - generic_16_byte(X_GLrop_TexCoord2dv, v); -} - -#define X_GLrop_TexCoord2fv 54 -void -__indirect_glTexCoord2f(GLfloat s, GLfloat t) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_TexCoord2fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&t), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord2fv 54 -void -__indirect_glTexCoord2fv(const GLfloat * v) -{ - generic_8_byte(X_GLrop_TexCoord2fv, v); -} - -#define X_GLrop_TexCoord2iv 55 -void -__indirect_glTexCoord2i(GLint s, GLint t) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_TexCoord2iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&t), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord2iv 55 -void -__indirect_glTexCoord2iv(const GLint * v) -{ - generic_8_byte(X_GLrop_TexCoord2iv, v); -} - -#define X_GLrop_TexCoord2sv 56 -void -__indirect_glTexCoord2s(GLshort s, GLshort t) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_TexCoord2sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&t), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord2sv 56 -void -__indirect_glTexCoord2sv(const GLshort * v) -{ - generic_4_byte(X_GLrop_TexCoord2sv, v); -} - -#define X_GLrop_TexCoord3dv 57 -void -__indirect_glTexCoord3d(GLdouble s, GLdouble t, GLdouble r) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_TexCoord3dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&r), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord3dv 57 -void -__indirect_glTexCoord3dv(const GLdouble * v) -{ - generic_24_byte(X_GLrop_TexCoord3dv, v); -} - -#define X_GLrop_TexCoord3fv 58 -void -__indirect_glTexCoord3f(GLfloat s, GLfloat t, GLfloat r) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_TexCoord3fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&t), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&r), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord3fv 58 -void -__indirect_glTexCoord3fv(const GLfloat * v) -{ - generic_12_byte(X_GLrop_TexCoord3fv, v); -} - -#define X_GLrop_TexCoord3iv 59 -void -__indirect_glTexCoord3i(GLint s, GLint t, GLint r) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_TexCoord3iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&t), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&r), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord3iv 59 -void -__indirect_glTexCoord3iv(const GLint * v) -{ - generic_12_byte(X_GLrop_TexCoord3iv, v); -} - -#define X_GLrop_TexCoord3sv 60 -void -__indirect_glTexCoord3s(GLshort s, GLshort t, GLshort r) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_TexCoord3sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&t), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&r), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord3sv 60 -void -__indirect_glTexCoord3sv(const GLshort * v) -{ - generic_6_byte(X_GLrop_TexCoord3sv, v); -} - -#define X_GLrop_TexCoord4dv 61 -void -__indirect_glTexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 36; - emit_header(gc->pc, X_GLrop_TexCoord4dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&r), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&q), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord4dv 61 -void -__indirect_glTexCoord4dv(const GLdouble * v) -{ - generic_32_byte(X_GLrop_TexCoord4dv, v); -} - -#define X_GLrop_TexCoord4fv 62 -void -__indirect_glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_TexCoord4fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&t), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&r), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&q), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord4fv 62 -void -__indirect_glTexCoord4fv(const GLfloat * v) -{ - generic_16_byte(X_GLrop_TexCoord4fv, v); -} - -#define X_GLrop_TexCoord4iv 63 -void -__indirect_glTexCoord4i(GLint s, GLint t, GLint r, GLint q) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_TexCoord4iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&t), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&r), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&q), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord4iv 63 -void -__indirect_glTexCoord4iv(const GLint * v) -{ - generic_16_byte(X_GLrop_TexCoord4iv, v); -} - -#define X_GLrop_TexCoord4sv 64 -void -__indirect_glTexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_TexCoord4sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&t), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&r), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&q), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexCoord4sv 64 -void -__indirect_glTexCoord4sv(const GLshort * v) -{ - generic_8_byte(X_GLrop_TexCoord4sv, v); -} - -#define X_GLrop_Vertex2dv 65 -void -__indirect_glVertex2d(GLdouble x, GLdouble y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Vertex2dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Vertex2dv 65 -void -__indirect_glVertex2dv(const GLdouble * v) -{ - generic_16_byte(X_GLrop_Vertex2dv, v); -} - -#define X_GLrop_Vertex2fv 66 -void -__indirect_glVertex2f(GLfloat x, GLfloat y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Vertex2fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Vertex2fv 66 -void -__indirect_glVertex2fv(const GLfloat * v) -{ - generic_8_byte(X_GLrop_Vertex2fv, v); -} - -#define X_GLrop_Vertex2iv 67 -void -__indirect_glVertex2i(GLint x, GLint y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Vertex2iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Vertex2iv 67 -void -__indirect_glVertex2iv(const GLint * v) -{ - generic_8_byte(X_GLrop_Vertex2iv, v); -} - -#define X_GLrop_Vertex2sv 68 -void -__indirect_glVertex2s(GLshort x, GLshort y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Vertex2sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&y), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Vertex2sv 68 -void -__indirect_glVertex2sv(const GLshort * v) -{ - generic_4_byte(X_GLrop_Vertex2sv, v); -} - -#define X_GLrop_Vertex3dv 69 -void -__indirect_glVertex3d(GLdouble x, GLdouble y, GLdouble z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_Vertex3dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Vertex3dv 69 -void -__indirect_glVertex3dv(const GLdouble * v) -{ - generic_24_byte(X_GLrop_Vertex3dv, v); -} - -#define X_GLrop_Vertex3fv 70 -void -__indirect_glVertex3f(GLfloat x, GLfloat y, GLfloat z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Vertex3fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Vertex3fv 70 -void -__indirect_glVertex3fv(const GLfloat * v) -{ - generic_12_byte(X_GLrop_Vertex3fv, v); -} - -#define X_GLrop_Vertex3iv 71 -void -__indirect_glVertex3i(GLint x, GLint y, GLint z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Vertex3iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Vertex3iv 71 -void -__indirect_glVertex3iv(const GLint * v) -{ - generic_12_byte(X_GLrop_Vertex3iv, v); -} - -#define X_GLrop_Vertex3sv 72 -void -__indirect_glVertex3s(GLshort x, GLshort y, GLshort z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Vertex3sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&y), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&z), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Vertex3sv 72 -void -__indirect_glVertex3sv(const GLshort * v) -{ - generic_6_byte(X_GLrop_Vertex3sv, v); -} - -#define X_GLrop_Vertex4dv 73 -void -__indirect_glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 36; - emit_header(gc->pc, X_GLrop_Vertex4dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&w), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Vertex4dv 73 -void -__indirect_glVertex4dv(const GLdouble * v) -{ - generic_32_byte(X_GLrop_Vertex4dv, v); -} - -#define X_GLrop_Vertex4fv 74 -void -__indirect_glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Vertex4fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&w), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Vertex4fv 74 -void -__indirect_glVertex4fv(const GLfloat * v) -{ - generic_16_byte(X_GLrop_Vertex4fv, v); -} - -#define X_GLrop_Vertex4iv 75 -void -__indirect_glVertex4i(GLint x, GLint y, GLint z, GLint w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Vertex4iv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&w), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Vertex4iv 75 -void -__indirect_glVertex4iv(const GLint * v) -{ - generic_16_byte(X_GLrop_Vertex4iv, v); -} - -#define X_GLrop_Vertex4sv 76 -void -__indirect_glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Vertex4sv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&y), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&z), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&w), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Vertex4sv 76 -void -__indirect_glVertex4sv(const GLshort * v) -{ - generic_8_byte(X_GLrop_Vertex4sv, v); -} - -#define X_GLrop_ClipPlane 77 -void -__indirect_glClipPlane(GLenum plane, const GLdouble * equation) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 40; - emit_header(gc->pc, X_GLrop_ClipPlane, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (equation), 32); - (void) memcpy((void *) (gc->pc + 36), (void *) (&plane), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ColorMaterial 78 -void -__indirect_glColorMaterial(GLenum face, GLenum mode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_ColorMaterial, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&mode), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_CullFace 79 -void -__indirect_glCullFace(GLenum mode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_CullFace, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Fogf 80 -void -__indirect_glFogf(GLenum pname, GLfloat param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Fogf, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Fogfv 81 -void -__indirect_glFogfv(GLenum pname, const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glFogfv_size(pname); - const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_Fogfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Fogi 82 -void -__indirect_glFogi(GLenum pname, GLint param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Fogi, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Fogiv 83 -void -__indirect_glFogiv(GLenum pname, const GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glFogiv_size(pname); - const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_Fogiv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_FrontFace 84 -void -__indirect_glFrontFace(GLenum mode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_FrontFace, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Hint 85 -void -__indirect_glHint(GLenum target, GLenum mode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Hint, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&mode), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Lightf 86 -void -__indirect_glLightf(GLenum light, GLenum pname, GLfloat param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Lightf, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&light), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Lightfv 87 -void -__indirect_glLightfv(GLenum light, GLenum pname, const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glLightfv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_Lightfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&light), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Lighti 88 -void -__indirect_glLighti(GLenum light, GLenum pname, GLint param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Lighti, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&light), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Lightiv 89 -void -__indirect_glLightiv(GLenum light, GLenum pname, const GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glLightiv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_Lightiv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&light), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_LightModelf 90 -void -__indirect_glLightModelf(GLenum pname, GLfloat param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_LightModelf, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_LightModelfv 91 -void -__indirect_glLightModelfv(GLenum pname, const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glLightModelfv_size(pname); - const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_LightModelfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_LightModeli 92 -void -__indirect_glLightModeli(GLenum pname, GLint param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_LightModeli, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_LightModeliv 93 -void -__indirect_glLightModeliv(GLenum pname, const GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glLightModeliv_size(pname); - const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_LightModeliv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_LineStipple 94 -void -__indirect_glLineStipple(GLint factor, GLushort pattern) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_LineStipple, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&factor), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pattern), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_LineWidth 95 -void -__indirect_glLineWidth(GLfloat width) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_LineWidth, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&width), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Materialf 96 -void -__indirect_glMaterialf(GLenum face, GLenum pname, GLfloat param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Materialf, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Materialfv 97 -void -__indirect_glMaterialfv(GLenum face, GLenum pname, const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glMaterialfv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_Materialfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Materiali 98 -void -__indirect_glMateriali(GLenum face, GLenum pname, GLint param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Materiali, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Materialiv 99 -void -__indirect_glMaterialiv(GLenum face, GLenum pname, const GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glMaterialiv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_Materialiv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PointSize 100 -void -__indirect_glPointSize(GLfloat size) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_PointSize, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&size), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PolygonMode 101 -void -__indirect_glPolygonMode(GLenum face, GLenum mode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_PolygonMode, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&mode), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PolygonStipple 102 -void -__indirect_glPolygonStipple(const GLubyte *mask) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = - (mask != NULL) ? __glImageSize(32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, - 0) : 0; - const GLuint cmdlen = 24 + __GLX_PAD(compsize); - emit_header(gc->pc, X_GLrop_PolygonStipple, cmdlen); - if (compsize > 0) { - (*gc->fillImage) (gc, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, mask, - gc->pc + 24, gc->pc + 4); - } else { - (void) memcpy(gc->pc + 4, default_pixel_store_2D, - default_pixel_store_2D_size); - } - gc->pc += cmdlen; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Scissor 103 -void -__indirect_glScissor(GLint x, GLint y, GLsizei width, GLsizei height) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Scissor, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&height), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ShadeModel 104 -void -__indirect_glShadeModel(GLenum mode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_ShadeModel, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexParameterf 105 -void -__indirect_glTexParameterf(GLenum target, GLenum pname, GLfloat param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_TexParameterf, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexParameterfv 106 -void -__indirect_glTexParameterfv(GLenum target, GLenum pname, - const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glTexParameterfv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_TexParameterfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexParameteri 107 -void -__indirect_glTexParameteri(GLenum target, GLenum pname, GLint param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_TexParameteri, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexParameteriv 108 -void -__indirect_glTexParameteriv(GLenum target, GLenum pname, const GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glTexParameteriv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_TexParameteriv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -static void -__glx_TexImage_1D2D(unsigned opcode, unsigned dim, GLenum target, GLint level, - GLint internalformat, GLsizei width, GLsizei height, - GLint border, GLenum format, GLenum type, - const GLvoid * pixels) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = - __glImageSize(width, height, 1, format, type, target); - const GLuint cmdlen = 56 + __GLX_PAD(compsize); - if (__builtin_expect(gc->currentDpy != NULL, 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, opcode, cmdlen); - (void) memcpy((void *) (gc->pc + 24), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (&level), 4); - (void) memcpy((void *) (gc->pc + 32), (void *) (&internalformat), - 4); - (void) memcpy((void *) (gc->pc + 36), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 40), (void *) (&height), 4); - (void) memcpy((void *) (gc->pc + 44), (void *) (&border), 4); - (void) memcpy((void *) (gc->pc + 48), (void *) (&format), 4); - (void) memcpy((void *) (gc->pc + 52), (void *) (&type), 4); - if ((compsize > 0) && (pixels != NULL)) { - (*gc->fillImage) (gc, dim, width, height, 1, format, type, - pixels, gc->pc + 56, gc->pc + 4); - } else { - (void) memcpy(gc->pc + 4, default_pixel_store_2D, - default_pixel_store_2D_size); - } - gc->pc += cmdlen; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = opcode; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 28), (void *) (&target), 4); - (void) memcpy((void *) (pc + 32), (void *) (&level), 4); - (void) memcpy((void *) (pc + 36), (void *) (&internalformat), 4); - (void) memcpy((void *) (pc + 40), (void *) (&width), 4); - (void) memcpy((void *) (pc + 44), (void *) (&height), 4); - (void) memcpy((void *) (pc + 48), (void *) (&border), 4); - (void) memcpy((void *) (pc + 52), (void *) (&format), 4); - (void) memcpy((void *) (pc + 56), (void *) (&type), 4); - __glXSendLargeImage(gc, compsize, dim, width, height, 1, format, - type, pixels, pc + 60, pc + 8); - } - } -} - -#define X_GLrop_TexImage1D 109 -void -__indirect_glTexImage1D(GLenum target, GLint level, GLint internalformat, - GLsizei width, GLint border, GLenum format, - GLenum type, const GLvoid * pixels) -{ - __glx_TexImage_1D2D(X_GLrop_TexImage1D, 1, target, level, internalformat, - width, 1, border, format, type, pixels); -} - -#define X_GLrop_TexImage2D 110 -void -__indirect_glTexImage2D(GLenum target, GLint level, GLint internalformat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - __glx_TexImage_1D2D(X_GLrop_TexImage2D, 2, target, level, internalformat, - width, height, border, format, type, pixels); -} - -#define X_GLrop_TexEnvf 111 -void -__indirect_glTexEnvf(GLenum target, GLenum pname, GLfloat param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_TexEnvf, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexEnvfv 112 -void -__indirect_glTexEnvfv(GLenum target, GLenum pname, const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glTexEnvfv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_TexEnvfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexEnvi 113 -void -__indirect_glTexEnvi(GLenum target, GLenum pname, GLint param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_TexEnvi, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexEnviv 114 -void -__indirect_glTexEnviv(GLenum target, GLenum pname, const GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glTexEnviv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_TexEnviv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexGend 115 -void -__indirect_glTexGend(GLenum coord, GLenum pname, GLdouble param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_TexGend, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (¶m), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&coord), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&pname), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexGendv 116 -void -__indirect_glTexGendv(GLenum coord, GLenum pname, const GLdouble * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glTexGendv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 8)); - emit_header(gc->pc, X_GLrop_TexGendv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 8)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexGenf 117 -void -__indirect_glTexGenf(GLenum coord, GLenum pname, GLfloat param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_TexGenf, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexGenfv 118 -void -__indirect_glTexGenfv(GLenum coord, GLenum pname, const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glTexGenfv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_TexGenfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexGeni 119 -void -__indirect_glTexGeni(GLenum coord, GLenum pname, GLint param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_TexGeni, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_TexGeniv 120 -void -__indirect_glTexGeniv(GLenum coord, GLenum pname, const GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glTexGeniv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_TexGeniv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_InitNames 121 -void -__indirect_glInitNames(void) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 4; - emit_header(gc->pc, X_GLrop_InitNames, cmdlen); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_LoadName 122 -void -__indirect_glLoadName(GLuint name) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_LoadName, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&name), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PassThrough 123 -void -__indirect_glPassThrough(GLfloat token) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_PassThrough, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&token), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PopName 124 -void -__indirect_glPopName(void) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 4; - emit_header(gc->pc, X_GLrop_PopName, cmdlen); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PushName 125 -void -__indirect_glPushName(GLuint name) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_PushName, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&name), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_DrawBuffer 126 -void -__indirect_glDrawBuffer(GLenum mode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_DrawBuffer, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Clear 127 -void -__indirect_glClear(GLbitfield mask) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Clear, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mask), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ClearAccum 128 -void -__indirect_glClearAccum(GLfloat red, GLfloat green, GLfloat blue, - GLfloat alpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_ClearAccum, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&alpha), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ClearIndex 129 -void -__indirect_glClearIndex(GLfloat c) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_ClearIndex, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&c), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ClearColor 130 -void -__indirect_glClearColor(GLclampf red, GLclampf green, GLclampf blue, - GLclampf alpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_ClearColor, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&alpha), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ClearStencil 131 -void -__indirect_glClearStencil(GLint s) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_ClearStencil, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ClearDepth 132 -void -__indirect_glClearDepth(GLclampd depth) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_ClearDepth, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&depth), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_StencilMask 133 -void -__indirect_glStencilMask(GLuint mask) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_StencilMask, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mask), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ColorMask 134 -void -__indirect_glColorMask(GLboolean red, GLboolean green, GLboolean blue, - GLboolean alpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_ColorMask, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); - (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); - (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); - (void) memcpy((void *) (gc->pc + 7), (void *) (&alpha), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_DepthMask 135 -void -__indirect_glDepthMask(GLboolean flag) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_DepthMask, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&flag), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_IndexMask 136 -void -__indirect_glIndexMask(GLuint mask) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_IndexMask, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mask), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Accum 137 -void -__indirect_glAccum(GLenum op, GLfloat value) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_Accum, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&value), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PopAttrib 141 -void -__indirect_glPopAttrib(void) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 4; - emit_header(gc->pc, X_GLrop_PopAttrib, cmdlen); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PushAttrib 142 -void -__indirect_glPushAttrib(GLbitfield mask) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_PushAttrib, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mask), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MapGrid1d 147 -void -__indirect_glMapGrid1d(GLint un, GLdouble u1, GLdouble u2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_MapGrid1d, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&u1), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&u2), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&un), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MapGrid1f 148 -void -__indirect_glMapGrid1f(GLint un, GLfloat u1, GLfloat u2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_MapGrid1f, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&un), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&u1), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&u2), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MapGrid2d 149 -void -__indirect_glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, - GLdouble v1, GLdouble v2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 44; - emit_header(gc->pc, X_GLrop_MapGrid2d, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&u1), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&u2), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&v1), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&v2), 8); - (void) memcpy((void *) (gc->pc + 36), (void *) (&un), 4); - (void) memcpy((void *) (gc->pc + 40), (void *) (&vn), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MapGrid2f 150 -void -__indirect_glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, - GLfloat v2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_MapGrid2f, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&un), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&u1), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&u2), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&vn), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&v1), 4); - (void) memcpy((void *) (gc->pc + 24), (void *) (&v2), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_EvalCoord1dv 151 -void -__indirect_glEvalCoord1d(GLdouble u) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_EvalCoord1dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&u), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_EvalCoord1dv 151 -void -__indirect_glEvalCoord1dv(const GLdouble * u) -{ - generic_8_byte(X_GLrop_EvalCoord1dv, u); -} - -#define X_GLrop_EvalCoord1fv 152 -void -__indirect_glEvalCoord1f(GLfloat u) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_EvalCoord1fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&u), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_EvalCoord1fv 152 -void -__indirect_glEvalCoord1fv(const GLfloat * u) -{ - generic_4_byte(X_GLrop_EvalCoord1fv, u); -} - -#define X_GLrop_EvalCoord2dv 153 -void -__indirect_glEvalCoord2d(GLdouble u, GLdouble v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_EvalCoord2dv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&u), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_EvalCoord2dv 153 -void -__indirect_glEvalCoord2dv(const GLdouble * u) -{ - generic_16_byte(X_GLrop_EvalCoord2dv, u); -} - -#define X_GLrop_EvalCoord2fv 154 -void -__indirect_glEvalCoord2f(GLfloat u, GLfloat v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_EvalCoord2fv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&u), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_EvalCoord2fv 154 -void -__indirect_glEvalCoord2fv(const GLfloat * u) -{ - generic_8_byte(X_GLrop_EvalCoord2fv, u); -} - -#define X_GLrop_EvalMesh1 155 -void -__indirect_glEvalMesh1(GLenum mode, GLint i1, GLint i2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_EvalMesh1, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&i1), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&i2), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_EvalPoint1 156 -void -__indirect_glEvalPoint1(GLint i) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_EvalPoint1, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&i), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_EvalMesh2 157 -void -__indirect_glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_EvalMesh2, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&i1), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&i2), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&j1), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&j2), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_EvalPoint2 158 -void -__indirect_glEvalPoint2(GLint i, GLint j) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_EvalPoint2, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&i), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&j), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_AlphaFunc 159 -void -__indirect_glAlphaFunc(GLenum func, GLclampf ref) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_AlphaFunc, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&func), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&ref), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_BlendFunc 160 -void -__indirect_glBlendFunc(GLenum sfactor, GLenum dfactor) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_BlendFunc, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&sfactor), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&dfactor), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_LogicOp 161 -void -__indirect_glLogicOp(GLenum opcode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_LogicOp, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&opcode), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_StencilFunc 162 -void -__indirect_glStencilFunc(GLenum func, GLint ref, GLuint mask) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_StencilFunc, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&func), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&ref), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&mask), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_StencilOp 163 -void -__indirect_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_StencilOp, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&fail), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&zfail), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&zpass), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_DepthFunc 164 -void -__indirect_glDepthFunc(GLenum func) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_DepthFunc, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&func), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PixelZoom 165 -void -__indirect_glPixelZoom(GLfloat xfactor, GLfloat yfactor) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_PixelZoom, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&xfactor), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&yfactor), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PixelTransferf 166 -void -__indirect_glPixelTransferf(GLenum pname, GLfloat param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_PixelTransferf, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PixelTransferi 167 -void -__indirect_glPixelTransferi(GLenum pname, GLint param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_PixelTransferi, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PixelMapfv 168 -void -__indirect_glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat * values) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 4)); - if (mapsize < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((mapsize >= 0) && (gc->currentDpy != NULL), 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, X_GLrop_PixelMapfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&map), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&mapsize), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (values), - (mapsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = X_GLrop_PixelMapfv; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 8), (void *) (&map), 4); - (void) memcpy((void *) (pc + 12), (void *) (&mapsize), 4); - __glXSendLargeCommand(gc, pc, 16, values, (mapsize * 4)); - } - } -} - -#define X_GLrop_PixelMapuiv 169 -void -__indirect_glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint * values) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 4)); - if (mapsize < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((mapsize >= 0) && (gc->currentDpy != NULL), 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, X_GLrop_PixelMapuiv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&map), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&mapsize), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (values), - (mapsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = X_GLrop_PixelMapuiv; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 8), (void *) (&map), 4); - (void) memcpy((void *) (pc + 12), (void *) (&mapsize), 4); - __glXSendLargeCommand(gc, pc, 16, values, (mapsize * 4)); - } - } -} - -#define X_GLrop_PixelMapusv 170 -void -__indirect_glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort * values) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 2)); - if (mapsize < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((mapsize >= 0) && (gc->currentDpy != NULL), 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, X_GLrop_PixelMapusv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&map), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&mapsize), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (values), - (mapsize * 2)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = X_GLrop_PixelMapusv; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 8), (void *) (&map), 4); - (void) memcpy((void *) (pc + 12), (void *) (&mapsize), 4); - __glXSendLargeCommand(gc, pc, 16, values, (mapsize * 2)); - } - } -} - -#define X_GLrop_ReadBuffer 171 -void -__indirect_glReadBuffer(GLenum mode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_ReadBuffer, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_CopyPixels 172 -void -__indirect_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, - GLenum type) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_CopyPixels, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&height), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&type), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLsop_ReadPixels 111 -void -__indirect_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid * pixels) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const __GLXattribute *const state = gc->client_state_private; - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 28; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_read_pixels_reply_t *reply = - xcb_glx_read_pixels_reply(c, - xcb_glx_read_pixels(c, - gc-> - currentContextTag, - x, y, width, height, - format, type, - state->storePack. - swapEndian, 0), - NULL); - (void) memcpy(pixels, xcb_glx_read_pixels_data(reply), - xcb_glx_read_pixels_data_length(reply) * - sizeof(GLvoid)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_ReadPixels, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&x), 4); - (void) memcpy((void *) (pc + 4), (void *) (&y), 4); - (void) memcpy((void *) (pc + 8), (void *) (&width), 4); - (void) memcpy((void *) (pc + 12), (void *) (&height), 4); - (void) memcpy((void *) (pc + 16), (void *) (&format), 4); - (void) memcpy((void *) (pc + 20), (void *) (&type), 4); - *(int32_t *) (pc + 24) = 0; - *(int8_t *) (pc + 24) = state->storePack.swapEndian; - __glXReadPixelReply(dpy, gc, 2, width, height, 1, format, type, - pixels, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLrop_DrawPixels 173 -void -__indirect_glDrawPixels(GLsizei width, GLsizei height, GLenum format, - GLenum type, const GLvoid * pixels) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = - (pixels != NULL) ? __glImageSize(width, height, 1, format, type, - 0) : 0; - const GLuint cmdlen = 40 + __GLX_PAD(compsize); - if (__builtin_expect(gc->currentDpy != NULL, 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, X_GLrop_DrawPixels, cmdlen); - (void) memcpy((void *) (gc->pc + 24), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (&height), 4); - (void) memcpy((void *) (gc->pc + 32), (void *) (&format), 4); - (void) memcpy((void *) (gc->pc + 36), (void *) (&type), 4); - if (compsize > 0) { - (*gc->fillImage) (gc, 2, width, height, 1, format, type, - pixels, gc->pc + 40, gc->pc + 4); - } else { - (void) memcpy(gc->pc + 4, default_pixel_store_2D, - default_pixel_store_2D_size); - } - gc->pc += cmdlen; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = X_GLrop_DrawPixels; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 28), (void *) (&width), 4); - (void) memcpy((void *) (pc + 32), (void *) (&height), 4); - (void) memcpy((void *) (pc + 36), (void *) (&format), 4); - (void) memcpy((void *) (pc + 40), (void *) (&type), 4); - __glXSendLargeImage(gc, compsize, 2, width, height, 1, format, - type, pixels, pc + 44, pc + 8); - } - } -} - -#define X_GLsop_GetClipPlane 113 -void -__indirect_glGetClipPlane(GLenum plane, GLdouble * equation) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 4; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_clip_plane_reply_t *reply = - xcb_glx_get_clip_plane_reply(c, - xcb_glx_get_clip_plane(c, - gc-> - currentContextTag, - plane), NULL); - (void) memcpy(equation, xcb_glx_get_clip_plane_data(reply), - xcb_glx_get_clip_plane_data_length(reply) * - sizeof(GLdouble)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetClipPlane, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&plane), 4); - (void) __glXReadReply(dpy, 8, equation, GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetLightfv 118 -void -__indirect_glGetLightfv(GLenum light, GLenum pname, GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_lightfv_reply_t *reply = - xcb_glx_get_lightfv_reply(c, - xcb_glx_get_lightfv(c, - gc-> - currentContextTag, - light, pname), - NULL); - if (xcb_glx_get_lightfv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_lightfv_data(reply), - xcb_glx_get_lightfv_data_length(reply) * - sizeof(GLfloat)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetLightfv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&light), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetLightiv 119 -void -__indirect_glGetLightiv(GLenum light, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_lightiv_reply_t *reply = - xcb_glx_get_lightiv_reply(c, - xcb_glx_get_lightiv(c, - gc-> - currentContextTag, - light, pname), - NULL); - if (xcb_glx_get_lightiv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_lightiv_data(reply), - xcb_glx_get_lightiv_data_length(reply) * - sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetLightiv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&light), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetMapdv 120 -void -__indirect_glGetMapdv(GLenum target, GLenum query, GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_mapdv_reply_t *reply = - xcb_glx_get_mapdv_reply(c, - xcb_glx_get_mapdv(c, - gc->currentContextTag, - target, query), NULL); - if (xcb_glx_get_mapdv_data_length(reply) == 0) - (void) memcpy(v, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(v, xcb_glx_get_mapdv_data(reply), - xcb_glx_get_mapdv_data_length(reply) * - sizeof(GLdouble)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetMapdv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&query), 4); - (void) __glXReadReply(dpy, 8, v, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetMapfv 121 -void -__indirect_glGetMapfv(GLenum target, GLenum query, GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_mapfv_reply_t *reply = - xcb_glx_get_mapfv_reply(c, - xcb_glx_get_mapfv(c, - gc->currentContextTag, - target, query), NULL); - if (xcb_glx_get_mapfv_data_length(reply) == 0) - (void) memcpy(v, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(v, xcb_glx_get_mapfv_data(reply), - xcb_glx_get_mapfv_data_length(reply) * - sizeof(GLfloat)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetMapfv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&query), 4); - (void) __glXReadReply(dpy, 4, v, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetMapiv 122 -void -__indirect_glGetMapiv(GLenum target, GLenum query, GLint * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_mapiv_reply_t *reply = - xcb_glx_get_mapiv_reply(c, - xcb_glx_get_mapiv(c, - gc->currentContextTag, - target, query), NULL); - if (xcb_glx_get_mapiv_data_length(reply) == 0) - (void) memcpy(v, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(v, xcb_glx_get_mapiv_data(reply), - xcb_glx_get_mapiv_data_length(reply) * - sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetMapiv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&query), 4); - (void) __glXReadReply(dpy, 4, v, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetMaterialfv 123 -void -__indirect_glGetMaterialfv(GLenum face, GLenum pname, GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_materialfv_reply_t *reply = - xcb_glx_get_materialfv_reply(c, - xcb_glx_get_materialfv(c, - gc-> - currentContextTag, - face, pname), - NULL); - if (xcb_glx_get_materialfv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_materialfv_data(reply), - xcb_glx_get_materialfv_data_length(reply) * - sizeof(GLfloat)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetMaterialfv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&face), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetMaterialiv 124 -void -__indirect_glGetMaterialiv(GLenum face, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_materialiv_reply_t *reply = - xcb_glx_get_materialiv_reply(c, - xcb_glx_get_materialiv(c, - gc-> - currentContextTag, - face, pname), - NULL); - if (xcb_glx_get_materialiv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_materialiv_data(reply), - xcb_glx_get_materialiv_data_length(reply) * - sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetMaterialiv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&face), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetPixelMapfv 125 -void -__indirect_glGetPixelMapfv(GLenum map, GLfloat * values) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 4; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_pixel_mapfv_reply_t *reply = - xcb_glx_get_pixel_mapfv_reply(c, - xcb_glx_get_pixel_mapfv(c, - gc-> - currentContextTag, - map), NULL); - if (xcb_glx_get_pixel_mapfv_data_length(reply) == 0) - (void) memcpy(values, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(values, xcb_glx_get_pixel_mapfv_data(reply), - xcb_glx_get_pixel_mapfv_data_length(reply) * - sizeof(GLfloat)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetPixelMapfv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&map), 4); - (void) __glXReadReply(dpy, 4, values, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetPixelMapuiv 126 -void -__indirect_glGetPixelMapuiv(GLenum map, GLuint * values) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 4; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_pixel_mapuiv_reply_t *reply = - xcb_glx_get_pixel_mapuiv_reply(c, - xcb_glx_get_pixel_mapuiv(c, - gc-> - currentContextTag, - map), - NULL); - if (xcb_glx_get_pixel_mapuiv_data_length(reply) == 0) - (void) memcpy(values, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(values, xcb_glx_get_pixel_mapuiv_data(reply), - xcb_glx_get_pixel_mapuiv_data_length(reply) * - sizeof(GLuint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetPixelMapuiv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&map), 4); - (void) __glXReadReply(dpy, 4, values, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetPixelMapusv 127 -void -__indirect_glGetPixelMapusv(GLenum map, GLushort * values) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 4; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_pixel_mapusv_reply_t *reply = - xcb_glx_get_pixel_mapusv_reply(c, - xcb_glx_get_pixel_mapusv(c, - gc-> - currentContextTag, - map), - NULL); - if (xcb_glx_get_pixel_mapusv_data_length(reply) == 0) - (void) memcpy(values, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(values, xcb_glx_get_pixel_mapusv_data(reply), - xcb_glx_get_pixel_mapusv_data_length(reply) * - sizeof(GLushort)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetPixelMapusv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&map), 4); - (void) __glXReadReply(dpy, 2, values, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetPolygonStipple 128 -void -__indirect_glGetPolygonStipple(GLubyte *mask) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 4; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_polygon_stipple_reply_t *reply = - xcb_glx_get_polygon_stipple_reply(c, - xcb_glx_get_polygon_stipple(c, - gc-> - currentContextTag, - 0), - NULL); - (void) memcpy(mask, xcb_glx_get_polygon_stipple_data(reply), - xcb_glx_get_polygon_stipple_data_length(reply) * - sizeof(GLubyte)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetPolygonStipple, cmdlen); - *(int32_t *) (pc + 0) = 0; - __glXReadPixelReply(dpy, gc, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, - mask, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetTexEnvfv 130 -void -__indirect_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_tex_envfv_reply_t *reply = - xcb_glx_get_tex_envfv_reply(c, - xcb_glx_get_tex_envfv(c, - gc-> - currentContextTag, - target, pname), - NULL); - if (xcb_glx_get_tex_envfv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_tex_envfv_data(reply), - xcb_glx_get_tex_envfv_data_length(reply) * - sizeof(GLfloat)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetTexEnvfv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetTexEnviv 131 -void -__indirect_glGetTexEnviv(GLenum target, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_tex_enviv_reply_t *reply = - xcb_glx_get_tex_enviv_reply(c, - xcb_glx_get_tex_enviv(c, - gc-> - currentContextTag, - target, pname), - NULL); - if (xcb_glx_get_tex_enviv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_tex_enviv_data(reply), - xcb_glx_get_tex_enviv_data_length(reply) * - sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetTexEnviv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetTexGendv 132 -void -__indirect_glGetTexGendv(GLenum coord, GLenum pname, GLdouble * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_tex_gendv_reply_t *reply = - xcb_glx_get_tex_gendv_reply(c, - xcb_glx_get_tex_gendv(c, - gc-> - currentContextTag, - coord, pname), - NULL); - if (xcb_glx_get_tex_gendv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_tex_gendv_data(reply), - xcb_glx_get_tex_gendv_data_length(reply) * - sizeof(GLdouble)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetTexGendv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&coord), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 8, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetTexGenfv 133 -void -__indirect_glGetTexGenfv(GLenum coord, GLenum pname, GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_tex_genfv_reply_t *reply = - xcb_glx_get_tex_genfv_reply(c, - xcb_glx_get_tex_genfv(c, - gc-> - currentContextTag, - coord, pname), - NULL); - if (xcb_glx_get_tex_genfv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_tex_genfv_data(reply), - xcb_glx_get_tex_genfv_data_length(reply) * - sizeof(GLfloat)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetTexGenfv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&coord), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetTexGeniv 134 -void -__indirect_glGetTexGeniv(GLenum coord, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_tex_geniv_reply_t *reply = - xcb_glx_get_tex_geniv_reply(c, - xcb_glx_get_tex_geniv(c, - gc-> - currentContextTag, - coord, pname), - NULL); - if (xcb_glx_get_tex_geniv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_tex_geniv_data(reply), - xcb_glx_get_tex_geniv_data_length(reply) * - sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetTexGeniv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&coord), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetTexImage 135 -void -__indirect_glGetTexImage(GLenum target, GLint level, GLenum format, - GLenum type, GLvoid * pixels) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const __GLXattribute *const state = gc->client_state_private; - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 20; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_tex_image_reply_t *reply = - xcb_glx_get_tex_image_reply(c, - xcb_glx_get_tex_image(c, - gc-> - currentContextTag, - target, level, - format, type, - state-> - storePack. - swapEndian), - NULL); - (void) memcpy(pixels, xcb_glx_get_tex_image_data(reply), - xcb_glx_get_tex_image_data_length(reply) * - sizeof(GLvoid)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetTexImage, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&level), 4); - (void) memcpy((void *) (pc + 8), (void *) (&format), 4); - (void) memcpy((void *) (pc + 12), (void *) (&type), 4); - *(int32_t *) (pc + 16) = 0; - *(int8_t *) (pc + 16) = state->storePack.swapEndian; - __glXReadPixelReply(dpy, gc, 3, 0, 0, 0, format, type, pixels, - GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetTexParameterfv 136 -void -__indirect_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_tex_parameterfv_reply_t *reply = - xcb_glx_get_tex_parameterfv_reply(c, - xcb_glx_get_tex_parameterfv(c, - gc-> - currentContextTag, - target, - pname), - NULL); - if (xcb_glx_get_tex_parameterfv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_tex_parameterfv_data(reply), - xcb_glx_get_tex_parameterfv_data_length(reply) * - sizeof(GLfloat)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetTexParameterfv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetTexParameteriv 137 -void -__indirect_glGetTexParameteriv(GLenum target, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_tex_parameteriv_reply_t *reply = - xcb_glx_get_tex_parameteriv_reply(c, - xcb_glx_get_tex_parameteriv(c, - gc-> - currentContextTag, - target, - pname), - NULL); - if (xcb_glx_get_tex_parameteriv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_tex_parameteriv_data(reply), - xcb_glx_get_tex_parameteriv_data_length(reply) * - sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetTexParameteriv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetTexLevelParameterfv 138 -void -__indirect_glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, - GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 12; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_tex_level_parameterfv_reply_t *reply = - xcb_glx_get_tex_level_parameterfv_reply(c, - xcb_glx_get_tex_level_parameterfv - (c, gc->currentContextTag, - target, level, pname), - NULL); - if (xcb_glx_get_tex_level_parameterfv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, - xcb_glx_get_tex_level_parameterfv_data(reply), - xcb_glx_get_tex_level_parameterfv_data_length(reply) - * sizeof(GLfloat)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetTexLevelParameterfv, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&level), 4); - (void) memcpy((void *) (pc + 8), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetTexLevelParameteriv 139 -void -__indirect_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, - GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 12; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_tex_level_parameteriv_reply_t *reply = - xcb_glx_get_tex_level_parameteriv_reply(c, - xcb_glx_get_tex_level_parameteriv - (c, gc->currentContextTag, - target, level, pname), - NULL); - if (xcb_glx_get_tex_level_parameteriv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, - xcb_glx_get_tex_level_parameteriv_data(reply), - xcb_glx_get_tex_level_parameteriv_data_length(reply) - * sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetTexLevelParameteriv, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&level), 4); - (void) memcpy((void *) (pc + 8), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_IsList 141 -GLboolean -__indirect_glIsList(GLuint list) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - GLboolean retval = (GLboolean) 0; -#ifndef USE_XCB - const GLuint cmdlen = 4; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_is_list_reply_t *reply = - xcb_glx_is_list_reply(c, - xcb_glx_is_list(c, gc->currentContextTag, - list), NULL); - retval = reply->ret_val; - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_IsList, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&list), 4); - retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return retval; -} - -#define X_GLrop_DepthRange 174 -void -__indirect_glDepthRange(GLclampd zNear, GLclampd zFar) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_DepthRange, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&zNear), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&zFar), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Frustum 175 -void -__indirect_glFrustum(GLdouble left, GLdouble right, GLdouble bottom, - GLdouble top, GLdouble zNear, GLdouble zFar) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 52; - emit_header(gc->pc, X_GLrop_Frustum, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&left), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&right), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&bottom), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&top), 8); - (void) memcpy((void *) (gc->pc + 36), (void *) (&zNear), 8); - (void) memcpy((void *) (gc->pc + 44), (void *) (&zFar), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_LoadIdentity 176 -void -__indirect_glLoadIdentity(void) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 4; - emit_header(gc->pc, X_GLrop_LoadIdentity, cmdlen); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_LoadMatrixf 177 -void -__indirect_glLoadMatrixf(const GLfloat * m) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 68; - emit_header(gc->pc, X_GLrop_LoadMatrixf, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (m), 64); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_LoadMatrixd 178 -void -__indirect_glLoadMatrixd(const GLdouble * m) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 132; - emit_header(gc->pc, X_GLrop_LoadMatrixd, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (m), 128); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MatrixMode 179 -void -__indirect_glMatrixMode(GLenum mode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_MatrixMode, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultMatrixf 180 -void -__indirect_glMultMatrixf(const GLfloat * m) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 68; - emit_header(gc->pc, X_GLrop_MultMatrixf, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (m), 64); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultMatrixd 181 -void -__indirect_glMultMatrixd(const GLdouble * m) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 132; - emit_header(gc->pc, X_GLrop_MultMatrixd, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (m), 128); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Ortho 182 -void -__indirect_glOrtho(GLdouble left, GLdouble right, GLdouble bottom, - GLdouble top, GLdouble zNear, GLdouble zFar) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 52; - emit_header(gc->pc, X_GLrop_Ortho, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&left), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&right), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&bottom), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&top), 8); - (void) memcpy((void *) (gc->pc + 36), (void *) (&zNear), 8); - (void) memcpy((void *) (gc->pc + 44), (void *) (&zFar), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PopMatrix 183 -void -__indirect_glPopMatrix(void) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 4; - emit_header(gc->pc, X_GLrop_PopMatrix, cmdlen); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PushMatrix 184 -void -__indirect_glPushMatrix(void) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 4; - emit_header(gc->pc, X_GLrop_PushMatrix, cmdlen); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Rotated 185 -void -__indirect_glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 36; - emit_header(gc->pc, X_GLrop_Rotated, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&angle), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&z), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Rotatef 186 -void -__indirect_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Rotatef, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&angle), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&z), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Scaled 187 -void -__indirect_glScaled(GLdouble x, GLdouble y, GLdouble z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_Scaled, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Scalef 188 -void -__indirect_glScalef(GLfloat x, GLfloat y, GLfloat z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Scalef, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Translated 189 -void -__indirect_glTranslated(GLdouble x, GLdouble y, GLdouble z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_Translated, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Translatef 190 -void -__indirect_glTranslatef(GLfloat x, GLfloat y, GLfloat z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Translatef, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Viewport 191 -void -__indirect_glViewport(GLint x, GLint y, GLsizei width, GLsizei height) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Viewport, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&height), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_BindTexture 4117 -void -__indirect_glBindTexture(GLenum target, GLuint texture) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_BindTexture, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&texture), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Indexubv 194 -void -__indirect_glIndexub(GLubyte c) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Indexubv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&c), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Indexubv 194 -void -__indirect_glIndexubv(const GLubyte *c) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_Indexubv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (c), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PolygonOffset 192 -void -__indirect_glPolygonOffset(GLfloat factor, GLfloat units) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_PolygonOffset, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&factor), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&units), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_CopyTexImage1D 4119 -void -__indirect_glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, - GLint x, GLint y, GLsizei width, GLint border) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 32; - emit_header(gc->pc, X_GLrop_CopyTexImage1D, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&level), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&internalformat), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 24), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (&border), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_CopyTexImage2D 4120 -void -__indirect_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 36; - emit_header(gc->pc, X_GLrop_CopyTexImage2D, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&level), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&internalformat), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 24), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (&height), 4); - (void) memcpy((void *) (gc->pc + 32), (void *) (&border), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_CopyTexSubImage1D 4121 -void -__indirect_glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, - GLint x, GLint y, GLsizei width) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_CopyTexSubImage1D, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&level), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&xoffset), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 24), (void *) (&width), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_CopyTexSubImage2D 4122 -void -__indirect_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLint x, GLint y, GLsizei width, - GLsizei height) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 36; - emit_header(gc->pc, X_GLrop_CopyTexSubImage2D, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&level), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&xoffset), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&yoffset), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 24), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 32), (void *) (&height), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLsop_DeleteTextures 144 -void -__indirect_glDeleteTextures(GLsizei n, const GLuint * textures) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); -#endif - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_delete_textures(c, gc->currentContextTag, n, textures); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_DeleteTextures, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4)); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_DeleteTexturesEXT 12 -void -glDeleteTexturesEXT(GLsizei n, const GLuint * textures) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_DeleteTextures(GET_DISPATCH(), (n, textures)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivate, - X_GLvop_DeleteTexturesEXT, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4)); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLsop_GenTextures 145 -void -__indirect_glGenTextures(GLsizei n, GLuint * textures) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 4; -#endif - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_gen_textures_reply_t *reply = - xcb_glx_gen_textures_reply(c, - xcb_glx_gen_textures(c, - gc-> - currentContextTag, - n), NULL); - (void) memcpy(textures, xcb_glx_gen_textures_data(reply), - xcb_glx_gen_textures_data_length(reply) * - sizeof(GLuint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GenTextures, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) __glXReadReply(dpy, 4, textures, GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GenTexturesEXT 13 -void -glGenTexturesEXT(GLsizei n, GLuint * textures) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GenTextures(GET_DISPATCH(), (n, textures)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 4; - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GenTexturesEXT, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) __glXReadReply(dpy, 4, textures, GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLsop_IsTexture 146 -GLboolean -__indirect_glIsTexture(GLuint texture) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - GLboolean retval = (GLboolean) 0; -#ifndef USE_XCB - const GLuint cmdlen = 4; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_is_texture_reply_t *reply = - xcb_glx_is_texture_reply(c, - xcb_glx_is_texture(c, - gc->currentContextTag, - texture), NULL); - retval = reply->ret_val; - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_IsTexture, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&texture), 4); - retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return retval; -} - -#define X_GLvop_IsTextureEXT 14 -GLboolean -glIsTextureEXT(GLuint texture) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - return CALL_IsTexture(GET_DISPATCH(), (texture)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - GLboolean retval = (GLboolean) 0; - const GLuint cmdlen = 4; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_IsTextureEXT, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&texture), 4); - retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return retval; - } -} - -#define X_GLrop_PrioritizeTextures 4118 -void -__indirect_glPrioritizeTextures(GLsizei n, const GLuint * textures, - const GLclampf * priorities) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8 + __GLX_PAD((n * 4)) + __GLX_PAD((n * 4)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_PrioritizeTextures, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (textures), (n * 4)); - (void) memcpy((void *) (gc->pc + 8 + (n * 4)), (void *) (priorities), - (n * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -static void -__glx_TexSubImage_1D2D(unsigned opcode, unsigned dim, GLenum target, - GLint level, GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, GLenum format, - GLenum type, const GLvoid * pixels) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = - (pixels != NULL) ? __glImageSize(width, height, 1, format, type, - target) : 0; - const GLuint cmdlen = 60 + __GLX_PAD(compsize); - if (__builtin_expect(gc->currentDpy != NULL, 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, opcode, cmdlen); - (void) memcpy((void *) (gc->pc + 24), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (&level), 4); - (void) memcpy((void *) (gc->pc + 32), (void *) (&xoffset), 4); - (void) memcpy((void *) (gc->pc + 36), (void *) (&yoffset), 4); - (void) memcpy((void *) (gc->pc + 40), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 44), (void *) (&height), 4); - (void) memcpy((void *) (gc->pc + 48), (void *) (&format), 4); - (void) memcpy((void *) (gc->pc + 52), (void *) (&type), 4); - (void) memset((void *) (gc->pc + 56), 0, 4); - if (compsize > 0) { - (*gc->fillImage) (gc, dim, width, height, 1, format, type, - pixels, gc->pc + 60, gc->pc + 4); - } else { - (void) memcpy(gc->pc + 4, default_pixel_store_2D, - default_pixel_store_2D_size); - } - gc->pc += cmdlen; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = opcode; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 28), (void *) (&target), 4); - (void) memcpy((void *) (pc + 32), (void *) (&level), 4); - (void) memcpy((void *) (pc + 36), (void *) (&xoffset), 4); - (void) memcpy((void *) (pc + 40), (void *) (&yoffset), 4); - (void) memcpy((void *) (pc + 44), (void *) (&width), 4); - (void) memcpy((void *) (pc + 48), (void *) (&height), 4); - (void) memcpy((void *) (pc + 52), (void *) (&format), 4); - (void) memcpy((void *) (pc + 56), (void *) (&type), 4); - (void) memset((void *) (pc + 60), 0, 4); - __glXSendLargeImage(gc, compsize, dim, width, height, 1, format, - type, pixels, pc + 64, pc + 8); - } - } -} - -#define X_GLrop_TexSubImage1D 4099 -void -__indirect_glTexSubImage1D(GLenum target, GLint level, GLint xoffset, - GLsizei width, GLenum format, GLenum type, - const GLvoid * pixels) -{ - __glx_TexSubImage_1D2D(X_GLrop_TexSubImage1D, 1, target, level, xoffset, - 1, width, 1, format, type, pixels); -} - -#define X_GLrop_TexSubImage2D 4100 -void -__indirect_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid * pixels) -{ - __glx_TexSubImage_1D2D(X_GLrop_TexSubImage2D, 2, target, level, xoffset, - yoffset, width, height, format, type, pixels); -} - -#define X_GLrop_BlendColor 4096 -void -__indirect_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, - GLclampf alpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_BlendColor, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&alpha), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_BlendEquation 4097 -void -__indirect_glBlendEquation(GLenum mode) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_BlendEquation, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&mode), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ColorTable 2053 -void -__indirect_glColorTable(GLenum target, GLenum internalformat, GLsizei width, - GLenum format, GLenum type, const GLvoid * table) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = - (table != NULL) ? __glImageSize(width, 1, 1, format, type, - target) : 0; - const GLuint cmdlen = 44 + __GLX_PAD(compsize); - if (__builtin_expect(gc->currentDpy != NULL, 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, X_GLrop_ColorTable, cmdlen); - (void) memcpy((void *) (gc->pc + 24), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (&internalformat), - 4); - (void) memcpy((void *) (gc->pc + 32), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 36), (void *) (&format), 4); - (void) memcpy((void *) (gc->pc + 40), (void *) (&type), 4); - if (compsize > 0) { - (*gc->fillImage) (gc, 1, width, 1, 1, format, type, table, - gc->pc + 44, gc->pc + 4); - } else { - (void) memcpy(gc->pc + 4, default_pixel_store_1D, - default_pixel_store_1D_size); - } - gc->pc += cmdlen; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = X_GLrop_ColorTable; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 28), (void *) (&target), 4); - (void) memcpy((void *) (pc + 32), (void *) (&internalformat), 4); - (void) memcpy((void *) (pc + 36), (void *) (&width), 4); - (void) memcpy((void *) (pc + 40), (void *) (&format), 4); - (void) memcpy((void *) (pc + 44), (void *) (&type), 4); - __glXSendLargeImage(gc, compsize, 1, width, 1, 1, format, type, - table, pc + 48, pc + 8); - } - } -} - -#define X_GLrop_ColorTableParameterfv 2054 -void -__indirect_glColorTableParameterfv(GLenum target, GLenum pname, - const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glColorTableParameterfv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_ColorTableParameterfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ColorTableParameteriv 2055 -void -__indirect_glColorTableParameteriv(GLenum target, GLenum pname, - const GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glColorTableParameteriv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_ColorTableParameteriv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_CopyColorTable 2056 -void -__indirect_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, - GLint y, GLsizei width) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_CopyColorTable, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&internalformat), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&width), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLsop_GetColorTable 147 -void -__indirect_glGetColorTable(GLenum target, GLenum format, GLenum type, - GLvoid * table) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const __GLXattribute *const state = gc->client_state_private; - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 16; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_color_table_reply_t *reply = - xcb_glx_get_color_table_reply(c, - xcb_glx_get_color_table(c, - gc-> - currentContextTag, - target, - format, - type, - state-> - storePack. - swapEndian), - NULL); - (void) memcpy(table, xcb_glx_get_color_table_data(reply), - xcb_glx_get_color_table_data_length(reply) * - sizeof(GLvoid)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetColorTable, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&format), 4); - (void) memcpy((void *) (pc + 8), (void *) (&type), 4); - *(int32_t *) (pc + 12) = 0; - *(int8_t *) (pc + 12) = state->storePack.swapEndian; - __glXReadPixelReply(dpy, gc, 1, 0, 0, 0, format, type, table, - GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GetColorTableSGI 4098 -void -glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid * table) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetColorTable(GET_DISPATCH(), (target, format, type, table)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - const __GLXattribute *const state = gc->client_state_private; - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 16; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetColorTableSGI, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&format), 4); - (void) memcpy((void *) (pc + 8), (void *) (&type), 4); - *(int32_t *) (pc + 12) = 0; - *(int8_t *) (pc + 12) = state->storePack.swapEndian; - __glXReadPixelReply(dpy, gc, 1, 0, 0, 0, format, type, table, - GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLsop_GetColorTableParameterfv 148 -void -__indirect_glGetColorTableParameterfv(GLenum target, GLenum pname, - GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_color_table_parameterfv_reply_t *reply = - xcb_glx_get_color_table_parameterfv_reply(c, - xcb_glx_get_color_table_parameterfv - (c, - gc->currentContextTag, - target, pname), NULL); - if (xcb_glx_get_color_table_parameterfv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, - xcb_glx_get_color_table_parameterfv_data(reply), - xcb_glx_get_color_table_parameterfv_data_length - (reply) * sizeof(GLfloat)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetColorTableParameterfv, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GetColorTableParameterfvSGI 4099 -void -glGetColorTableParameterfvEXT(GLenum target, GLenum pname, GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetColorTableParameterfv(GET_DISPATCH(), - (target, pname, params)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetColorTableParameterfvSGI, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLsop_GetColorTableParameteriv 149 -void -__indirect_glGetColorTableParameteriv(GLenum target, GLenum pname, - GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_color_table_parameteriv_reply_t *reply = - xcb_glx_get_color_table_parameteriv_reply(c, - xcb_glx_get_color_table_parameteriv - (c, - gc->currentContextTag, - target, pname), NULL); - if (xcb_glx_get_color_table_parameteriv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, - xcb_glx_get_color_table_parameteriv_data(reply), - xcb_glx_get_color_table_parameteriv_data_length - (reply) * sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetColorTableParameteriv, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GetColorTableParameterivSGI 4100 -void -glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetColorTableParameteriv(GET_DISPATCH(), - (target, pname, params)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetColorTableParameterivSGI, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLrop_ColorSubTable 195 -void -__indirect_glColorSubTable(GLenum target, GLsizei start, GLsizei count, - GLenum format, GLenum type, const GLvoid * data) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = - (data != NULL) ? __glImageSize(count, 1, 1, format, type, target) : 0; - const GLuint cmdlen = 44 + __GLX_PAD(compsize); - if (__builtin_expect(gc->currentDpy != NULL, 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, X_GLrop_ColorSubTable, cmdlen); - (void) memcpy((void *) (gc->pc + 24), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (&start), 4); - (void) memcpy((void *) (gc->pc + 32), (void *) (&count), 4); - (void) memcpy((void *) (gc->pc + 36), (void *) (&format), 4); - (void) memcpy((void *) (gc->pc + 40), (void *) (&type), 4); - if (compsize > 0) { - (*gc->fillImage) (gc, 1, count, 1, 1, format, type, data, - gc->pc + 44, gc->pc + 4); - } else { - (void) memcpy(gc->pc + 4, default_pixel_store_1D, - default_pixel_store_1D_size); - } - gc->pc += cmdlen; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = X_GLrop_ColorSubTable; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 28), (void *) (&target), 4); - (void) memcpy((void *) (pc + 32), (void *) (&start), 4); - (void) memcpy((void *) (pc + 36), (void *) (&count), 4); - (void) memcpy((void *) (pc + 40), (void *) (&format), 4); - (void) memcpy((void *) (pc + 44), (void *) (&type), 4); - __glXSendLargeImage(gc, compsize, 1, count, 1, 1, format, type, - data, pc + 48, pc + 8); - } - } -} - -#define X_GLrop_CopyColorSubTable 196 -void -__indirect_glCopyColorSubTable(GLenum target, GLsizei start, GLint x, GLint y, - GLsizei width) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_CopyColorSubTable, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&start), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&width), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -static void -__glx_ConvolutionFilter_1D2D(unsigned opcode, unsigned dim, GLenum target, - GLenum internalformat, GLsizei width, - GLsizei height, GLenum format, GLenum type, - const GLvoid * image) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = - (image != NULL) ? __glImageSize(width, height, 1, format, type, - target) : 0; - const GLuint cmdlen = 48 + __GLX_PAD(compsize); - if (__builtin_expect(gc->currentDpy != NULL, 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, opcode, cmdlen); - (void) memcpy((void *) (gc->pc + 24), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (&internalformat), - 4); - (void) memcpy((void *) (gc->pc + 32), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 36), (void *) (&height), 4); - (void) memcpy((void *) (gc->pc + 40), (void *) (&format), 4); - (void) memcpy((void *) (gc->pc + 44), (void *) (&type), 4); - if (compsize > 0) { - (*gc->fillImage) (gc, dim, width, height, 1, format, type, - image, gc->pc + 48, gc->pc + 4); - } else { - (void) memcpy(gc->pc + 4, default_pixel_store_2D, - default_pixel_store_2D_size); - } - gc->pc += cmdlen; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = opcode; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 28), (void *) (&target), 4); - (void) memcpy((void *) (pc + 32), (void *) (&internalformat), 4); - (void) memcpy((void *) (pc + 36), (void *) (&width), 4); - (void) memcpy((void *) (pc + 40), (void *) (&height), 4); - (void) memcpy((void *) (pc + 44), (void *) (&format), 4); - (void) memcpy((void *) (pc + 48), (void *) (&type), 4); - __glXSendLargeImage(gc, compsize, dim, width, height, 1, format, - type, image, pc + 52, pc + 8); - } - } -} - -#define X_GLrop_ConvolutionFilter1D 4101 -void -__indirect_glConvolutionFilter1D(GLenum target, GLenum internalformat, - GLsizei width, GLenum format, GLenum type, - const GLvoid * image) -{ - __glx_ConvolutionFilter_1D2D(X_GLrop_ConvolutionFilter1D, 1, target, - internalformat, width, 1, format, type, - image); -} - -#define X_GLrop_ConvolutionFilter2D 4102 -void -__indirect_glConvolutionFilter2D(GLenum target, GLenum internalformat, - GLsizei width, GLsizei height, GLenum format, - GLenum type, const GLvoid * image) -{ - __glx_ConvolutionFilter_1D2D(X_GLrop_ConvolutionFilter2D, 2, target, - internalformat, width, height, format, type, - image); -} - -#define X_GLrop_ConvolutionParameterf 4103 -void -__indirect_glConvolutionParameterf(GLenum target, GLenum pname, - GLfloat params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_ConvolutionParameterf, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (¶ms), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ConvolutionParameterfv 4104 -void -__indirect_glConvolutionParameterfv(GLenum target, GLenum pname, - const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glConvolutionParameterfv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_ConvolutionParameterfv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ConvolutionParameteri 4105 -void -__indirect_glConvolutionParameteri(GLenum target, GLenum pname, GLint params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_ConvolutionParameteri, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (¶ms), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ConvolutionParameteriv 4106 -void -__indirect_glConvolutionParameteriv(GLenum target, GLenum pname, - const GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glConvolutionParameteriv_size(pname); - const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_ConvolutionParameteriv, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_CopyConvolutionFilter1D 4107 -void -__indirect_glCopyConvolutionFilter1D(GLenum target, GLenum internalformat, - GLint x, GLint y, GLsizei width) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_CopyConvolutionFilter1D, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&internalformat), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&width), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_CopyConvolutionFilter2D 4108 -void -__indirect_glCopyConvolutionFilter2D(GLenum target, GLenum internalformat, - GLint x, GLint y, GLsizei width, - GLsizei height) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_CopyConvolutionFilter2D, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&internalformat), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 24), (void *) (&height), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLsop_GetConvolutionFilter 150 -void -__indirect_glGetConvolutionFilter(GLenum target, GLenum format, GLenum type, - GLvoid * image) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const __GLXattribute *const state = gc->client_state_private; - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 16; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_convolution_filter_reply_t *reply = - xcb_glx_get_convolution_filter_reply(c, - xcb_glx_get_convolution_filter - (c, gc->currentContextTag, - target, format, type, - state->storePack. - swapEndian), NULL); - (void) memcpy(image, xcb_glx_get_convolution_filter_data(reply), - xcb_glx_get_convolution_filter_data_length(reply) * - sizeof(GLvoid)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetConvolutionFilter, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&format), 4); - (void) memcpy((void *) (pc + 8), (void *) (&type), 4); - *(int32_t *) (pc + 12) = 0; - *(int8_t *) (pc + 12) = state->storePack.swapEndian; - __glXReadPixelReply(dpy, gc, 2, 0, 0, 0, format, type, image, - GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GetConvolutionFilterEXT 1 -void -gl_dispatch_stub_356(GLenum target, GLenum format, GLenum type, - GLvoid * image) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetConvolutionFilter(GET_DISPATCH(), - (target, format, type, image)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - const __GLXattribute *const state = gc->client_state_private; - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 16; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetConvolutionFilterEXT, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&format), 4); - (void) memcpy((void *) (pc + 8), (void *) (&type), 4); - *(int32_t *) (pc + 12) = 0; - *(int8_t *) (pc + 12) = state->storePack.swapEndian; - __glXReadPixelReply(dpy, gc, 2, 0, 0, 0, format, type, image, - GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLsop_GetConvolutionParameterfv 151 -void -__indirect_glGetConvolutionParameterfv(GLenum target, GLenum pname, - GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_convolution_parameterfv_reply_t *reply = - xcb_glx_get_convolution_parameterfv_reply(c, - xcb_glx_get_convolution_parameterfv - (c, - gc->currentContextTag, - target, pname), NULL); - if (xcb_glx_get_convolution_parameterfv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, - xcb_glx_get_convolution_parameterfv_data(reply), - xcb_glx_get_convolution_parameterfv_data_length - (reply) * sizeof(GLfloat)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetConvolutionParameterfv, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GetConvolutionParameterfvEXT 2 -void -gl_dispatch_stub_357(GLenum target, GLenum pname, GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetConvolutionParameterfv(GET_DISPATCH(), - (target, pname, params)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetConvolutionParameterfvEXT, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLsop_GetConvolutionParameteriv 152 -void -__indirect_glGetConvolutionParameteriv(GLenum target, GLenum pname, - GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_convolution_parameteriv_reply_t *reply = - xcb_glx_get_convolution_parameteriv_reply(c, - xcb_glx_get_convolution_parameteriv - (c, - gc->currentContextTag, - target, pname), NULL); - if (xcb_glx_get_convolution_parameteriv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, - xcb_glx_get_convolution_parameteriv_data(reply), - xcb_glx_get_convolution_parameteriv_data_length - (reply) * sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetConvolutionParameteriv, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GetConvolutionParameterivEXT 3 -void -gl_dispatch_stub_358(GLenum target, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetConvolutionParameteriv(GET_DISPATCH(), - (target, pname, params)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetConvolutionParameterivEXT, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLsop_GetHistogram 154 -void -__indirect_glGetHistogram(GLenum target, GLboolean reset, GLenum format, - GLenum type, GLvoid * values) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const __GLXattribute *const state = gc->client_state_private; - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 16; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_histogram_reply_t *reply = - xcb_glx_get_histogram_reply(c, - xcb_glx_get_histogram(c, - gc-> - currentContextTag, - target, reset, - format, type, - state-> - storePack. - swapEndian), - NULL); - (void) memcpy(values, xcb_glx_get_histogram_data(reply), - xcb_glx_get_histogram_data_length(reply) * - sizeof(GLvoid)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetHistogram, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&format), 4); - (void) memcpy((void *) (pc + 8), (void *) (&type), 4); - *(int32_t *) (pc + 12) = 0; - *(int8_t *) (pc + 12) = state->storePack.swapEndian; - *(int8_t *) (pc + 13) = reset; - __glXReadPixelReply(dpy, gc, 1, 0, 0, 0, format, type, values, - GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GetHistogramEXT 5 -void -gl_dispatch_stub_361(GLenum target, GLboolean reset, GLenum format, - GLenum type, GLvoid * values) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetHistogram(GET_DISPATCH(), - (target, reset, format, type, values)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - const __GLXattribute *const state = gc->client_state_private; - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 16; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetHistogramEXT, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&format), 4); - (void) memcpy((void *) (pc + 8), (void *) (&type), 4); - *(int32_t *) (pc + 12) = 0; - *(int8_t *) (pc + 12) = state->storePack.swapEndian; - *(int8_t *) (pc + 13) = reset; - __glXReadPixelReply(dpy, gc, 1, 0, 0, 0, format, type, values, - GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLsop_GetHistogramParameterfv 155 -void -__indirect_glGetHistogramParameterfv(GLenum target, GLenum pname, - GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_histogram_parameterfv_reply_t *reply = - xcb_glx_get_histogram_parameterfv_reply(c, - xcb_glx_get_histogram_parameterfv - (c, gc->currentContextTag, - target, pname), NULL); - if (xcb_glx_get_histogram_parameterfv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, - xcb_glx_get_histogram_parameterfv_data(reply), - xcb_glx_get_histogram_parameterfv_data_length(reply) - * sizeof(GLfloat)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetHistogramParameterfv, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GetHistogramParameterfvEXT 6 -void -gl_dispatch_stub_362(GLenum target, GLenum pname, GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetHistogramParameterfv(GET_DISPATCH(), (target, pname, params)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetHistogramParameterfvEXT, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLsop_GetHistogramParameteriv 156 -void -__indirect_glGetHistogramParameteriv(GLenum target, GLenum pname, - GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_histogram_parameteriv_reply_t *reply = - xcb_glx_get_histogram_parameteriv_reply(c, - xcb_glx_get_histogram_parameteriv - (c, gc->currentContextTag, - target, pname), NULL); - if (xcb_glx_get_histogram_parameteriv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, - xcb_glx_get_histogram_parameteriv_data(reply), - xcb_glx_get_histogram_parameteriv_data_length(reply) - * sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetHistogramParameteriv, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GetHistogramParameterivEXT 7 -void -gl_dispatch_stub_363(GLenum target, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetHistogramParameteriv(GET_DISPATCH(), (target, pname, params)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetHistogramParameterivEXT, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLsop_GetMinmax 157 -void -__indirect_glGetMinmax(GLenum target, GLboolean reset, GLenum format, - GLenum type, GLvoid * values) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const __GLXattribute *const state = gc->client_state_private; - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 16; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_minmax_reply_t *reply = - xcb_glx_get_minmax_reply(c, - xcb_glx_get_minmax(c, - gc->currentContextTag, - target, reset, format, - type, - state->storePack. - swapEndian), NULL); - (void) memcpy(values, xcb_glx_get_minmax_data(reply), - xcb_glx_get_minmax_data_length(reply) * sizeof(GLvoid)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetMinmax, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&format), 4); - (void) memcpy((void *) (pc + 8), (void *) (&type), 4); - *(int32_t *) (pc + 12) = 0; - *(int8_t *) (pc + 12) = state->storePack.swapEndian; - *(int8_t *) (pc + 13) = reset; - __glXReadPixelReply(dpy, gc, 1, 2, 1, 1, format, type, values, - GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GetMinmaxEXT 8 -void -gl_dispatch_stub_364(GLenum target, GLboolean reset, GLenum format, - GLenum type, GLvoid * values) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetMinmax(GET_DISPATCH(), (target, reset, format, type, values)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - const __GLXattribute *const state = gc->client_state_private; - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 16; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetMinmaxEXT, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&format), 4); - (void) memcpy((void *) (pc + 8), (void *) (&type), 4); - *(int32_t *) (pc + 12) = 0; - *(int8_t *) (pc + 12) = state->storePack.swapEndian; - *(int8_t *) (pc + 13) = reset; - __glXReadPixelReply(dpy, gc, 1, 2, 1, 1, format, type, values, - GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLsop_GetMinmaxParameterfv 158 -void -__indirect_glGetMinmaxParameterfv(GLenum target, GLenum pname, - GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_minmax_parameterfv_reply_t *reply = - xcb_glx_get_minmax_parameterfv_reply(c, - xcb_glx_get_minmax_parameterfv - (c, gc->currentContextTag, - target, pname), NULL); - if (xcb_glx_get_minmax_parameterfv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_minmax_parameterfv_data(reply), - xcb_glx_get_minmax_parameterfv_data_length(reply) * - sizeof(GLfloat)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetMinmaxParameterfv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GetMinmaxParameterfvEXT 9 -void -gl_dispatch_stub_365(GLenum target, GLenum pname, GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetMinmaxParameterfv(GET_DISPATCH(), (target, pname, params)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetMinmaxParameterfvEXT, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLsop_GetMinmaxParameteriv 159 -void -__indirect_glGetMinmaxParameteriv(GLenum target, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_minmax_parameteriv_reply_t *reply = - xcb_glx_get_minmax_parameteriv_reply(c, - xcb_glx_get_minmax_parameteriv - (c, gc->currentContextTag, - target, pname), NULL); - if (xcb_glx_get_minmax_parameteriv_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_minmax_parameteriv_data(reply), - xcb_glx_get_minmax_parameteriv_data_length(reply) * - sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetMinmaxParameteriv, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLvop_GetMinmaxParameterivEXT 10 -void -gl_dispatch_stub_366(GLenum target, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetMinmaxParameteriv(GET_DISPATCH(), (target, pname, params)); - } else -#endif - { - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetMinmaxParameterivEXT, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; - } -} - -#define X_GLrop_Histogram 4110 -void -__indirect_glHistogram(GLenum target, GLsizei width, GLenum internalformat, - GLboolean sink) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_Histogram, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&internalformat), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&sink), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_Minmax 4111 -void -__indirect_glMinmax(GLenum target, GLenum internalformat, GLboolean sink) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_Minmax, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&internalformat), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&sink), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ResetHistogram 4112 -void -__indirect_glResetHistogram(GLenum target) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_ResetHistogram, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ResetMinmax 4113 -void -__indirect_glResetMinmax(GLenum target) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_ResetMinmax, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -static void -__glx_TexImage_3D4D(unsigned opcode, unsigned dim, GLenum target, GLint level, - GLint internalformat, GLsizei width, GLsizei height, - GLsizei depth, GLsizei extent, GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = - (pixels != NULL) ? __glImageSize(width, height, depth, format, type, - target) : 0; - const GLuint cmdlen = 84 + __GLX_PAD(compsize); - if (__builtin_expect(gc->currentDpy != NULL, 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, opcode, cmdlen); - (void) memcpy((void *) (gc->pc + 40), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 44), (void *) (&level), 4); - (void) memcpy((void *) (gc->pc + 48), (void *) (&internalformat), - 4); - (void) memcpy((void *) (gc->pc + 52), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 56), (void *) (&height), 4); - (void) memcpy((void *) (gc->pc + 60), (void *) (&depth), 4); - (void) memcpy((void *) (gc->pc + 64), (void *) (&extent), 4); - (void) memcpy((void *) (gc->pc + 68), (void *) (&border), 4); - (void) memcpy((void *) (gc->pc + 72), (void *) (&format), 4); - (void) memcpy((void *) (gc->pc + 76), (void *) (&type), 4); - (void) memcpy((void *) (gc->pc + 80), - (void *) ((pixels == NULL) ? one : zero), 4); - if (compsize > 0) { - (*gc->fillImage) (gc, dim, width, height, depth, format, type, - pixels, gc->pc + 84, gc->pc + 4); - } else { - (void) memcpy(gc->pc + 4, default_pixel_store_4D, - default_pixel_store_4D_size); - } - gc->pc += cmdlen; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = opcode; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 44), (void *) (&target), 4); - (void) memcpy((void *) (pc + 48), (void *) (&level), 4); - (void) memcpy((void *) (pc + 52), (void *) (&internalformat), 4); - (void) memcpy((void *) (pc + 56), (void *) (&width), 4); - (void) memcpy((void *) (pc + 60), (void *) (&height), 4); - (void) memcpy((void *) (pc + 64), (void *) (&depth), 4); - (void) memcpy((void *) (pc + 68), (void *) (&extent), 4); - (void) memcpy((void *) (pc + 72), (void *) (&border), 4); - (void) memcpy((void *) (pc + 76), (void *) (&format), 4); - (void) memcpy((void *) (pc + 80), (void *) (&type), 4); - (void) memcpy((void *) (pc + 84), zero, 4); - __glXSendLargeImage(gc, compsize, dim, width, height, depth, - format, type, pixels, pc + 88, pc + 8); - } - } -} - -#define X_GLrop_TexImage3D 4114 -void -__indirect_glTexImage3D(GLenum target, GLint level, GLint internalformat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum format, GLenum type, - const GLvoid * pixels) -{ - __glx_TexImage_3D4D(X_GLrop_TexImage3D, 3, target, level, internalformat, - width, height, depth, 1, border, format, type, - pixels); -} - -static void -__glx_TexSubImage_3D4D(unsigned opcode, unsigned dim, GLenum target, - GLint level, GLint xoffset, GLint yoffset, - GLint zoffset, GLint woffset, GLsizei width, - GLsizei height, GLsizei depth, GLsizei extent, - GLenum format, GLenum type, const GLvoid * pixels) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = - (pixels != NULL) ? __glImageSize(width, height, depth, format, type, - target) : 0; - const GLuint cmdlen = 92 + __GLX_PAD(compsize); - if (__builtin_expect(gc->currentDpy != NULL, 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, opcode, cmdlen); - (void) memcpy((void *) (gc->pc + 40), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 44), (void *) (&level), 4); - (void) memcpy((void *) (gc->pc + 48), (void *) (&xoffset), 4); - (void) memcpy((void *) (gc->pc + 52), (void *) (&yoffset), 4); - (void) memcpy((void *) (gc->pc + 56), (void *) (&zoffset), 4); - (void) memcpy((void *) (gc->pc + 60), (void *) (&woffset), 4); - (void) memcpy((void *) (gc->pc + 64), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 68), (void *) (&height), 4); - (void) memcpy((void *) (gc->pc + 72), (void *) (&depth), 4); - (void) memcpy((void *) (gc->pc + 76), (void *) (&extent), 4); - (void) memcpy((void *) (gc->pc + 80), (void *) (&format), 4); - (void) memcpy((void *) (gc->pc + 84), (void *) (&type), 4); - (void) memset((void *) (gc->pc + 88), 0, 4); - if (compsize > 0) { - (*gc->fillImage) (gc, dim, width, height, depth, format, type, - pixels, gc->pc + 92, gc->pc + 4); - } else { - (void) memcpy(gc->pc + 4, default_pixel_store_4D, - default_pixel_store_4D_size); - } - gc->pc += cmdlen; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = opcode; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 44), (void *) (&target), 4); - (void) memcpy((void *) (pc + 48), (void *) (&level), 4); - (void) memcpy((void *) (pc + 52), (void *) (&xoffset), 4); - (void) memcpy((void *) (pc + 56), (void *) (&yoffset), 4); - (void) memcpy((void *) (pc + 60), (void *) (&zoffset), 4); - (void) memcpy((void *) (pc + 64), (void *) (&woffset), 4); - (void) memcpy((void *) (pc + 68), (void *) (&width), 4); - (void) memcpy((void *) (pc + 72), (void *) (&height), 4); - (void) memcpy((void *) (pc + 76), (void *) (&depth), 4); - (void) memcpy((void *) (pc + 80), (void *) (&extent), 4); - (void) memcpy((void *) (pc + 84), (void *) (&format), 4); - (void) memcpy((void *) (pc + 88), (void *) (&type), 4); - (void) memset((void *) (pc + 92), 0, 4); - __glXSendLargeImage(gc, compsize, dim, width, height, depth, - format, type, pixels, pc + 96, pc + 8); - } - } -} - -#define X_GLrop_TexSubImage3D 4115 -void -__indirect_glTexSubImage3D(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLint zoffset, GLsizei width, - GLsizei height, GLsizei depth, GLenum format, - GLenum type, const GLvoid * pixels) -{ - __glx_TexSubImage_3D4D(X_GLrop_TexSubImage3D, 3, target, level, xoffset, - yoffset, zoffset, 1, width, height, depth, 1, - format, type, pixels); -} - -#define X_GLrop_CopyTexSubImage3D 4123 -void -__indirect_glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLint zoffset, GLint x, GLint y, - GLsizei width, GLsizei height) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 40; - emit_header(gc->pc, X_GLrop_CopyTexSubImage3D, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&level), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&xoffset), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&yoffset), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&zoffset), 4); - (void) memcpy((void *) (gc->pc + 24), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 32), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 36), (void *) (&height), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ActiveTextureARB 197 -void -__indirect_glActiveTextureARB(GLenum texture) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_ActiveTextureARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&texture), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord1dvARB 198 -void -__indirect_glMultiTexCoord1dARB(GLenum target, GLdouble s) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_MultiTexCoord1dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&target), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord1dvARB 198 -void -__indirect_glMultiTexCoord1dvARB(GLenum target, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_MultiTexCoord1dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (v), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&target), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord1fvARB 199 -void -__indirect_glMultiTexCoord1fARB(GLenum target, GLfloat s) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_MultiTexCoord1fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord1fvARB 199 -void -__indirect_glMultiTexCoord1fvARB(GLenum target, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_MultiTexCoord1fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord1ivARB 200 -void -__indirect_glMultiTexCoord1iARB(GLenum target, GLint s) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_MultiTexCoord1ivARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord1ivARB 200 -void -__indirect_glMultiTexCoord1ivARB(GLenum target, const GLint * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_MultiTexCoord1ivARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord1svARB 201 -void -__indirect_glMultiTexCoord1sARB(GLenum target, GLshort s) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_MultiTexCoord1svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord1svARB 201 -void -__indirect_glMultiTexCoord1svARB(GLenum target, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_MultiTexCoord1svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord2dvARB 202 -void -__indirect_glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_MultiTexCoord2dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&target), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord2dvARB 202 -void -__indirect_glMultiTexCoord2dvARB(GLenum target, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_MultiTexCoord2dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (v), 16); - (void) memcpy((void *) (gc->pc + 20), (void *) (&target), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord2fvARB 203 -void -__indirect_glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_MultiTexCoord2fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord2fvARB 203 -void -__indirect_glMultiTexCoord2fvARB(GLenum target, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_MultiTexCoord2fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord2ivARB 204 -void -__indirect_glMultiTexCoord2iARB(GLenum target, GLint s, GLint t) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_MultiTexCoord2ivARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord2ivARB 204 -void -__indirect_glMultiTexCoord2ivARB(GLenum target, const GLint * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_MultiTexCoord2ivARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord2svARB 205 -void -__indirect_glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_MultiTexCoord2svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&t), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord2svARB 205 -void -__indirect_glMultiTexCoord2svARB(GLenum target, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_MultiTexCoord2svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord3dvARB 206 -void -__indirect_glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, - GLdouble r) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 32; - emit_header(gc->pc, X_GLrop_MultiTexCoord3dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&r), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&target), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord3dvARB 206 -void -__indirect_glMultiTexCoord3dvARB(GLenum target, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 32; - emit_header(gc->pc, X_GLrop_MultiTexCoord3dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (v), 24); - (void) memcpy((void *) (gc->pc + 28), (void *) (&target), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord3fvARB 207 -void -__indirect_glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, - GLfloat r) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_MultiTexCoord3fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&r), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord3fvARB 207 -void -__indirect_glMultiTexCoord3fvARB(GLenum target, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_MultiTexCoord3fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 12); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord3ivARB 208 -void -__indirect_glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_MultiTexCoord3ivARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&r), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord3ivARB 208 -void -__indirect_glMultiTexCoord3ivARB(GLenum target, const GLint * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_MultiTexCoord3ivARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 12); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord3svARB 209 -void -__indirect_glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, - GLshort r) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_MultiTexCoord3svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&t), 2); - (void) memcpy((void *) (gc->pc + 12), (void *) (&r), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord3svARB 209 -void -__indirect_glMultiTexCoord3svARB(GLenum target, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_MultiTexCoord3svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 6); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord4dvARB 210 -void -__indirect_glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, - GLdouble r, GLdouble q) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 40; - emit_header(gc->pc, X_GLrop_MultiTexCoord4dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&s), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&r), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&q), 8); - (void) memcpy((void *) (gc->pc + 36), (void *) (&target), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord4dvARB 210 -void -__indirect_glMultiTexCoord4dvARB(GLenum target, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 40; - emit_header(gc->pc, X_GLrop_MultiTexCoord4dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (v), 32); - (void) memcpy((void *) (gc->pc + 36), (void *) (&target), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord4fvARB 211 -void -__indirect_glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, - GLfloat r, GLfloat q) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_MultiTexCoord4fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&r), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&q), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord4fvARB 211 -void -__indirect_glMultiTexCoord4fvARB(GLenum target, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_MultiTexCoord4fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord4ivARB 212 -void -__indirect_glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, - GLint q) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_MultiTexCoord4ivARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&t), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&r), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&q), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord4ivARB 212 -void -__indirect_glMultiTexCoord4ivARB(GLenum target, const GLint * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_MultiTexCoord4ivARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord4svARB 213 -void -__indirect_glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, - GLshort r, GLshort q) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_MultiTexCoord4svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&s), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&t), 2); - (void) memcpy((void *) (gc->pc + 12), (void *) (&r), 2); - (void) memcpy((void *) (gc->pc + 14), (void *) (&q), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_MultiTexCoord4svARB 213 -void -__indirect_glMultiTexCoord4svARB(GLenum target, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_MultiTexCoord4svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_SampleCoverageARB 229 -void -__indirect_glSampleCoverageARB(GLclampf value, GLboolean invert) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_SampleCoverageARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&value), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&invert), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLvop_GetProgramStringARB 1308 -void -__indirect_glGetProgramStringARB(GLenum target, GLenum pname, GLvoid * string) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetProgramStringARB, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 1, string, GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_GetProgramivARB 1307 -void -__indirect_glGetProgramivARB(GLenum target, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetProgramivARB, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLrop_ProgramEnvParameter4dvARB 4185 -void -__indirect_glProgramEnvParameter4dARB(GLenum target, GLuint index, GLdouble x, - GLdouble y, GLdouble z, GLdouble w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 44; - emit_header(gc->pc, X_GLrop_ProgramEnvParameter4dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&z), 8); - (void) memcpy((void *) (gc->pc + 36), (void *) (&w), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ProgramEnvParameter4dvARB 4185 -void -__indirect_glProgramEnvParameter4dvARB(GLenum target, GLuint index, - const GLdouble * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 44; - emit_header(gc->pc, X_GLrop_ProgramEnvParameter4dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), 32); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ProgramEnvParameter4fvARB 4184 -void -__indirect_glProgramEnvParameter4fARB(GLenum target, GLuint index, GLfloat x, - GLfloat y, GLfloat z, GLfloat w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_ProgramEnvParameter4fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 4); - (void) memcpy((void *) (gc->pc + 24), (void *) (&w), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ProgramEnvParameter4fvARB 4184 -void -__indirect_glProgramEnvParameter4fvARB(GLenum target, GLuint index, - const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_ProgramEnvParameter4fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ProgramLocalParameter4dvARB 4216 -void -__indirect_glProgramLocalParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, GLdouble z, - GLdouble w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 44; - emit_header(gc->pc, X_GLrop_ProgramLocalParameter4dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&z), 8); - (void) memcpy((void *) (gc->pc + 36), (void *) (&w), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ProgramLocalParameter4dvARB 4216 -void -__indirect_glProgramLocalParameter4dvARB(GLenum target, GLuint index, - const GLdouble * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 44; - emit_header(gc->pc, X_GLrop_ProgramLocalParameter4dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), 32); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ProgramLocalParameter4fvARB 4215 -void -__indirect_glProgramLocalParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, - GLfloat w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_ProgramLocalParameter4fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 4); - (void) memcpy((void *) (gc->pc + 24), (void *) (&w), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ProgramLocalParameter4fvARB 4215 -void -__indirect_glProgramLocalParameter4fvARB(GLenum target, GLuint index, - const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_ProgramLocalParameter4fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ProgramStringARB 4217 -void -__indirect_glProgramStringARB(GLenum target, GLenum format, GLsizei len, - const GLvoid * string) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16 + __GLX_PAD(len); - if (len < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((len >= 0) && (gc->currentDpy != NULL), 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, X_GLrop_ProgramStringARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&format), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&len), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (string), len); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = X_GLrop_ProgramStringARB; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 8), (void *) (&target), 4); - (void) memcpy((void *) (pc + 12), (void *) (&format), 4); - (void) memcpy((void *) (pc + 16), (void *) (&len), 4); - __glXSendLargeCommand(gc, pc, 20, string, len); - } - } -} - -#define X_GLrop_VertexAttrib1dvARB 4197 -void -__indirect_glVertexAttrib1dARB(GLuint index, GLdouble x) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib1dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib1dvARB 4197 -void -__indirect_glVertexAttrib1dvARB(GLuint index, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib1dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib1fvARB 4193 -void -__indirect_glVertexAttrib1fARB(GLuint index, GLfloat x) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib1fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib1fvARB 4193 -void -__indirect_glVertexAttrib1fvARB(GLuint index, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib1fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib1svARB 4189 -void -__indirect_glVertexAttrib1sARB(GLuint index, GLshort x) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib1svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib1svARB 4189 -void -__indirect_glVertexAttrib1svARB(GLuint index, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib1svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib2dvARB 4198 -void -__indirect_glVertexAttrib2dARB(GLuint index, GLdouble x, GLdouble y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_VertexAttrib2dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib2dvARB 4198 -void -__indirect_glVertexAttrib2dvARB(GLuint index, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_VertexAttrib2dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib2fvARB 4194 -void -__indirect_glVertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib2fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib2fvARB 4194 -void -__indirect_glVertexAttrib2fvARB(GLuint index, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib2fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib2svARB 4190 -void -__indirect_glVertexAttrib2sARB(GLuint index, GLshort x, GLshort y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib2svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&y), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib2svARB 4190 -void -__indirect_glVertexAttrib2svARB(GLuint index, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib2svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib3dvARB 4199 -void -__indirect_glVertexAttrib3dARB(GLuint index, GLdouble x, GLdouble y, - GLdouble z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 32; - emit_header(gc->pc, X_GLrop_VertexAttrib3dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 24), (void *) (&z), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib3dvARB 4199 -void -__indirect_glVertexAttrib3dvARB(GLuint index, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 32; - emit_header(gc->pc, X_GLrop_VertexAttrib3dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 24); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib3fvARB 4195 -void -__indirect_glVertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_VertexAttrib3fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&z), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib3fvARB 4195 -void -__indirect_glVertexAttrib3fvARB(GLuint index, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_VertexAttrib3fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 12); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib3svARB 4191 -void -__indirect_glVertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib3svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&y), 2); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib3svARB 4191 -void -__indirect_glVertexAttrib3svARB(GLuint index, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib3svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 6); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4NbvARB 4235 -void -__indirect_glVertexAttrib4NbvARB(GLuint index, const GLbyte *v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib4NbvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4NivARB 4237 -void -__indirect_glVertexAttrib4NivARB(GLuint index, const GLint * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_VertexAttrib4NivARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4NsvARB 4236 -void -__indirect_glVertexAttrib4NsvARB(GLuint index, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib4NsvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4NubvARB 4201 -void -__indirect_glVertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, - GLubyte z, GLubyte w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib4NubvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 1); - (void) memcpy((void *) (gc->pc + 9), (void *) (&y), 1); - (void) memcpy((void *) (gc->pc + 10), (void *) (&z), 1); - (void) memcpy((void *) (gc->pc + 11), (void *) (&w), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4NubvARB 4201 -void -__indirect_glVertexAttrib4NubvARB(GLuint index, const GLubyte *v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib4NubvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4NuivARB 4239 -void -__indirect_glVertexAttrib4NuivARB(GLuint index, const GLuint * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_VertexAttrib4NuivARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4NusvARB 4238 -void -__indirect_glVertexAttrib4NusvARB(GLuint index, const GLushort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib4NusvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4bvARB 4230 -void -__indirect_glVertexAttrib4bvARB(GLuint index, const GLbyte *v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib4bvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4dvARB 4200 -void -__indirect_glVertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, - GLdouble z, GLdouble w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 40; - emit_header(gc->pc, X_GLrop_VertexAttrib4dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 24), (void *) (&z), 8); - (void) memcpy((void *) (gc->pc + 32), (void *) (&w), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4dvARB 4200 -void -__indirect_glVertexAttrib4dvARB(GLuint index, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 40; - emit_header(gc->pc, X_GLrop_VertexAttrib4dvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 32); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4fvARB 4196 -void -__indirect_glVertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, - GLfloat w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_VertexAttrib4fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&z), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&w), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4fvARB 4196 -void -__indirect_glVertexAttrib4fvARB(GLuint index, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_VertexAttrib4fvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4ivARB 4231 -void -__indirect_glVertexAttrib4ivARB(GLuint index, const GLint * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_VertexAttrib4ivARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4svARB 4192 -void -__indirect_glVertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, - GLshort w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib4svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&y), 2); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 2); - (void) memcpy((void *) (gc->pc + 14), (void *) (&w), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4svARB 4192 -void -__indirect_glVertexAttrib4svARB(GLuint index, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib4svARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4ubvARB 4232 -void -__indirect_glVertexAttrib4ubvARB(GLuint index, const GLubyte *v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib4ubvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4uivARB 4234 -void -__indirect_glVertexAttrib4uivARB(GLuint index, const GLuint * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_VertexAttrib4uivARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4usvARB 4233 -void -__indirect_glVertexAttrib4usvARB(GLuint index, const GLushort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib4usvARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_BeginQueryARB 231 -void -__indirect_glBeginQueryARB(GLenum target, GLuint id) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_BeginQueryARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&id), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLsop_DeleteQueriesARB 161 -void -__indirect_glDeleteQueriesARB(GLsizei n, const GLuint * ids) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); -#endif - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_delete_queries_arb(c, gc->currentContextTag, n, ids); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_DeleteQueriesARB, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) memcpy((void *) (pc + 4), (void *) (ids), (n * 4)); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLrop_EndQueryARB 232 -void -__indirect_glEndQueryARB(GLenum target) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_EndQueryARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLsop_GenQueriesARB 162 -void -__indirect_glGenQueriesARB(GLsizei n, GLuint * ids) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 4; -#endif - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_gen_queries_arb_reply_t *reply = - xcb_glx_gen_queries_arb_reply(c, - xcb_glx_gen_queries_arb(c, - gc-> - currentContextTag, - n), NULL); - (void) memcpy(ids, xcb_glx_gen_queries_arb_data(reply), - xcb_glx_gen_queries_arb_data_length(reply) * - sizeof(GLuint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GenQueriesARB, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) __glXReadReply(dpy, 4, ids, GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetQueryObjectivARB 165 -void -__indirect_glGetQueryObjectivARB(GLuint id, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_query_objectiv_arb_reply_t *reply = - xcb_glx_get_query_objectiv_arb_reply(c, - xcb_glx_get_query_objectiv_arb - (c, gc->currentContextTag, - id, pname), NULL); - if (xcb_glx_get_query_objectiv_arb_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_query_objectiv_arb_data(reply), - xcb_glx_get_query_objectiv_arb_data_length(reply) * - sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetQueryObjectivARB, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&id), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetQueryObjectuivARB 166 -void -__indirect_glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_query_objectuiv_arb_reply_t *reply = - xcb_glx_get_query_objectuiv_arb_reply(c, - xcb_glx_get_query_objectuiv_arb - (c, gc->currentContextTag, - id, pname), NULL); - if (xcb_glx_get_query_objectuiv_arb_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_query_objectuiv_arb_data(reply), - xcb_glx_get_query_objectuiv_arb_data_length(reply) * - sizeof(GLuint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetQueryObjectuivARB, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&id), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_GetQueryivARB 164 -void -__indirect_glGetQueryivARB(GLenum target, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; -#ifndef USE_XCB - const GLuint cmdlen = 8; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_get_queryiv_arb_reply_t *reply = - xcb_glx_get_queryiv_arb_reply(c, - xcb_glx_get_queryiv_arb(c, - gc-> - currentContextTag, - target, - pname), - NULL); - if (xcb_glx_get_queryiv_arb_data_length(reply) == 0) - (void) memcpy(params, &reply->datum, sizeof(reply->datum)); - else - (void) memcpy(params, xcb_glx_get_queryiv_arb_data(reply), - xcb_glx_get_queryiv_arb_data_length(reply) * - sizeof(GLint)); - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_GetQueryivARB, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return; -} - -#define X_GLsop_IsQueryARB 163 -GLboolean -__indirect_glIsQueryARB(GLuint id) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - GLboolean retval = (GLboolean) 0; -#ifndef USE_XCB - const GLuint cmdlen = 4; -#endif - if (__builtin_expect(dpy != NULL, 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_is_query_arb_reply_t *reply = - xcb_glx_is_query_arb_reply(c, - xcb_glx_is_query_arb(c, - gc-> - currentContextTag, - id), NULL); - retval = reply->ret_val; - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_IsQueryARB, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&id), 4); - retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return retval; -} - -#define X_GLrop_DrawBuffersARB 233 -void -__indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8 + __GLX_PAD((n * 4)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((n >= 0) && (gc->currentDpy != NULL), 1)) { - if (cmdlen <= gc->maxSmallRenderCommandSize) { - if ((gc->pc + cmdlen) > gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - emit_header(gc->pc, X_GLrop_DrawBuffersARB, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (bufs), (n * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } else { - const GLint op = X_GLrop_DrawBuffersARB; - const GLuint cmdlenLarge = cmdlen + 4; - GLubyte *const pc = __glXFlushRenderBuffer(gc, gc->pc); - (void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4); - (void) memcpy((void *) (pc + 4), (void *) (&op), 4); - (void) memcpy((void *) (pc + 8), (void *) (&n), 4); - __glXSendLargeCommand(gc, pc, 12, bufs, (n * 4)); - } - } -} - -#define X_GLrop_RenderbufferStorageMultisample 4331 -void -__indirect_glRenderbufferStorageMultisample(GLenum target, GLsizei samples, - GLenum internalformat, - GLsizei width, GLsizei height) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_RenderbufferStorageMultisample, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&samples), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&internalformat), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&height), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_SampleMaskSGIS 2048 -void -__indirect_glSampleMaskSGIS(GLclampf value, GLboolean invert) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_SampleMaskSGIS, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&value), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&invert), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_SamplePatternSGIS 2049 -void -__indirect_glSamplePatternSGIS(GLenum pattern) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_SamplePatternSGIS, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pattern), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PointParameterfEXT 2065 -void -__indirect_glPointParameterfEXT(GLenum pname, GLfloat param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_PointParameterfEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PointParameterfvEXT 2066 -void -__indirect_glPointParameterfvEXT(GLenum pname, const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glPointParameterfvEXT_size(pname); - const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_PointParameterfvEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_SecondaryColor3bvEXT 4126 -void -__indirect_glSecondaryColor3bEXT(GLbyte red, GLbyte green, GLbyte blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_SecondaryColor3bvEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); - (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); - (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_SecondaryColor3bvEXT 4126 -void -__indirect_glSecondaryColor3bvEXT(const GLbyte *v) -{ - generic_3_byte(X_GLrop_SecondaryColor3bvEXT, v); -} - -#define X_GLrop_SecondaryColor3dvEXT 4130 -void -__indirect_glSecondaryColor3dEXT(GLdouble red, GLdouble green, GLdouble blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_SecondaryColor3dvEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&green), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&blue), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_SecondaryColor3dvEXT 4130 -void -__indirect_glSecondaryColor3dvEXT(const GLdouble * v) -{ - generic_24_byte(X_GLrop_SecondaryColor3dvEXT, v); -} - -#define X_GLrop_SecondaryColor3fvEXT 4129 -void -__indirect_glSecondaryColor3fEXT(GLfloat red, GLfloat green, GLfloat blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_SecondaryColor3fvEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_SecondaryColor3fvEXT 4129 -void -__indirect_glSecondaryColor3fvEXT(const GLfloat * v) -{ - generic_12_byte(X_GLrop_SecondaryColor3fvEXT, v); -} - -#define X_GLrop_SecondaryColor3ivEXT 4128 -void -__indirect_glSecondaryColor3iEXT(GLint red, GLint green, GLint blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_SecondaryColor3ivEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_SecondaryColor3ivEXT 4128 -void -__indirect_glSecondaryColor3ivEXT(const GLint * v) -{ - generic_12_byte(X_GLrop_SecondaryColor3ivEXT, v); -} - -#define X_GLrop_SecondaryColor3svEXT 4127 -void -__indirect_glSecondaryColor3sEXT(GLshort red, GLshort green, GLshort blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_SecondaryColor3svEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&green), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&blue), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_SecondaryColor3svEXT 4127 -void -__indirect_glSecondaryColor3svEXT(const GLshort * v) -{ - generic_6_byte(X_GLrop_SecondaryColor3svEXT, v); -} - -#define X_GLrop_SecondaryColor3ubvEXT 4131 -void -__indirect_glSecondaryColor3ubEXT(GLubyte red, GLubyte green, GLubyte blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_SecondaryColor3ubvEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 1); - (void) memcpy((void *) (gc->pc + 5), (void *) (&green), 1); - (void) memcpy((void *) (gc->pc + 6), (void *) (&blue), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_SecondaryColor3ubvEXT 4131 -void -__indirect_glSecondaryColor3ubvEXT(const GLubyte *v) -{ - generic_3_byte(X_GLrop_SecondaryColor3ubvEXT, v); -} - -#define X_GLrop_SecondaryColor3uivEXT 4133 -void -__indirect_glSecondaryColor3uiEXT(GLuint red, GLuint green, GLuint blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_SecondaryColor3uivEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&green), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&blue), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_SecondaryColor3uivEXT 4133 -void -__indirect_glSecondaryColor3uivEXT(const GLuint * v) -{ - generic_12_byte(X_GLrop_SecondaryColor3uivEXT, v); -} - -#define X_GLrop_SecondaryColor3usvEXT 4132 -void -__indirect_glSecondaryColor3usEXT(GLushort red, GLushort green, GLushort blue) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_SecondaryColor3usvEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&red), 2); - (void) memcpy((void *) (gc->pc + 6), (void *) (&green), 2); - (void) memcpy((void *) (gc->pc + 8), (void *) (&blue), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_SecondaryColor3usvEXT 4132 -void -__indirect_glSecondaryColor3usvEXT(const GLushort * v) -{ - generic_6_byte(X_GLrop_SecondaryColor3usvEXT, v); -} - -#define X_GLrop_FogCoorddvEXT 4125 -void -__indirect_glFogCoorddEXT(GLdouble coord) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_FogCoorddvEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_FogCoorddvEXT 4125 -void -__indirect_glFogCoorddvEXT(const GLdouble * coord) -{ - generic_8_byte(X_GLrop_FogCoorddvEXT, coord); -} - -#define X_GLrop_FogCoordfvEXT 4124 -void -__indirect_glFogCoordfEXT(GLfloat coord) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_FogCoordfvEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_FogCoordfvEXT 4124 -void -__indirect_glFogCoordfvEXT(const GLfloat * coord) -{ - generic_4_byte(X_GLrop_FogCoordfvEXT, coord); -} - -#define X_GLrop_BlendFuncSeparateEXT 4134 -void -__indirect_glBlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorAlpha, GLenum dfactorAlpha) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_BlendFuncSeparateEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&sfactorRGB), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&dfactorRGB), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&sfactorAlpha), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&dfactorAlpha), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_WindowPos3fvMESA 230 -void -__indirect_glWindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_WindowPos3fvMESA, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_WindowPos3fvMESA 230 -void -__indirect_glWindowPos3fvMESA(const GLfloat * v) -{ - generic_12_byte(X_GLrop_WindowPos3fvMESA, v); -} - -#define X_GLvop_AreProgramsResidentNV 1293 -GLboolean -__indirect_glAreProgramsResidentNV(GLsizei n, const GLuint * ids, - GLboolean * residences) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - GLboolean retval = (GLboolean) 0; - const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return 0; - } - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_AreProgramsResidentNV, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) memcpy((void *) (pc + 4), (void *) (ids), (n * 4)); - retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return retval; -} - -#define X_GLrop_BindProgramNV 4180 -void -__indirect_glBindProgramNV(GLenum target, GLuint program) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_BindProgramNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&program), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLvop_DeleteProgramsNV 1294 -void -__indirect_glDeleteProgramsNV(GLsizei n, const GLuint * programs) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivate, - X_GLvop_DeleteProgramsNV, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) memcpy((void *) (pc + 4), (void *) (programs), (n * 4)); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLrop_ExecuteProgramNV 4181 -void -__indirect_glExecuteProgramNV(GLenum target, GLuint id, - const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_ExecuteProgramNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&id), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (params), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLvop_GenProgramsNV 1295 -void -__indirect_glGenProgramsNV(GLsizei n, GLuint * programs) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 4; - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GenProgramsNV, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) __glXReadReply(dpy, 4, programs, GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_GetProgramParameterdvNV 1297 -void -__indirect_glGetProgramParameterdvNV(GLenum target, GLuint index, - GLenum pname, GLdouble * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 12; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetProgramParameterdvNV, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (pc + 8), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 8, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_GetProgramParameterfvNV 1296 -void -__indirect_glGetProgramParameterfvNV(GLenum target, GLuint index, - GLenum pname, GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 12; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetProgramParameterfvNV, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (pc + 8), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_GetProgramStringNV 1299 -void -__indirect_glGetProgramStringNV(GLuint id, GLenum pname, GLubyte *program) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetProgramStringNV, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&id), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 1, program, GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_GetProgramivNV 1298 -void -__indirect_glGetProgramivNV(GLuint id, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetProgramivNV, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&id), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_GetTrackMatrixivNV 1300 -void -__indirect_glGetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, - GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 12; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetTrackMatrixivNV, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&address), 4); - (void) memcpy((void *) (pc + 8), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_GetVertexAttribdvNV 1301 -void -__indirect_glGetVertexAttribdvNV(GLuint index, GLenum pname, - GLdouble * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetVertexAttribdvNV, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&index), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 8, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_GetVertexAttribfvNV 1302 -void -__indirect_glGetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetVertexAttribfvNV, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&index), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_GetVertexAttribivNV 1303 -void -__indirect_glGetVertexAttribivNV(GLuint index, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetVertexAttribivNV, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&index), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_IsProgramNV 1304 -GLboolean -__indirect_glIsProgramNV(GLuint program) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - GLboolean retval = (GLboolean) 0; - const GLuint cmdlen = 4; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_IsProgramNV, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&program), 4); - retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return retval; -} - -#define X_GLrop_LoadProgramNV 4183 -void -__indirect_glLoadProgramNV(GLenum target, GLuint id, GLsizei len, - const GLubyte *program) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16 + __GLX_PAD(len); - if (len < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(len >= 0, 1)) { - emit_header(gc->pc, X_GLrop_LoadProgramNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&id), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&len), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (program), len); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_ProgramParameters4dvNV 4187 -void -__indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, - const GLdouble * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16 + __GLX_PAD((num * 32)); - if (num < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(num >= 0, 1)) { - emit_header(gc->pc, X_GLrop_ProgramParameters4dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&num), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (params), (num * 32)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_ProgramParameters4fvNV 4186 -void -__indirect_glProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, - const GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16 + __GLX_PAD((num * 16)); - if (num < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(num >= 0, 1)) { - emit_header(gc->pc, X_GLrop_ProgramParameters4fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&num), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (params), (num * 16)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_RequestResidentProgramsNV 4182 -void -__indirect_glRequestResidentProgramsNV(GLsizei n, const GLuint * ids) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8 + __GLX_PAD((n * 4)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_RequestResidentProgramsNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (ids), (n * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_TrackMatrixNV 4188 -void -__indirect_glTrackMatrixNV(GLenum target, GLuint address, GLenum matrix, - GLenum transform) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_TrackMatrixNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&address), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&matrix), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&transform), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib1dvNV 4273 -void -__indirect_glVertexAttrib1dNV(GLuint index, GLdouble x) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib1dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib1dvNV 4273 -void -__indirect_glVertexAttrib1dvNV(GLuint index, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib1dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib1fvNV 4269 -void -__indirect_glVertexAttrib1fNV(GLuint index, GLfloat x) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib1fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib1fvNV 4269 -void -__indirect_glVertexAttrib1fvNV(GLuint index, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib1fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib1svNV 4265 -void -__indirect_glVertexAttrib1sNV(GLuint index, GLshort x) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib1svNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib1svNV 4265 -void -__indirect_glVertexAttrib1svNV(GLuint index, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib1svNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib2dvNV 4274 -void -__indirect_glVertexAttrib2dNV(GLuint index, GLdouble x, GLdouble y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_VertexAttrib2dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib2dvNV 4274 -void -__indirect_glVertexAttrib2dvNV(GLuint index, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_VertexAttrib2dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib2fvNV 4270 -void -__indirect_glVertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib2fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib2fvNV 4270 -void -__indirect_glVertexAttrib2fvNV(GLuint index, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib2fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib2svNV 4266 -void -__indirect_glVertexAttrib2sNV(GLuint index, GLshort x, GLshort y) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib2svNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&y), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib2svNV 4266 -void -__indirect_glVertexAttrib2svNV(GLuint index, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib2svNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib3dvNV 4275 -void -__indirect_glVertexAttrib3dNV(GLuint index, GLdouble x, GLdouble y, - GLdouble z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 32; - emit_header(gc->pc, X_GLrop_VertexAttrib3dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 24), (void *) (&z), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib3dvNV 4275 -void -__indirect_glVertexAttrib3dvNV(GLuint index, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 32; - emit_header(gc->pc, X_GLrop_VertexAttrib3dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 24); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib3fvNV 4271 -void -__indirect_glVertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_VertexAttrib3fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&z), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib3fvNV 4271 -void -__indirect_glVertexAttrib3fvNV(GLuint index, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_VertexAttrib3fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 12); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib3svNV 4267 -void -__indirect_glVertexAttrib3sNV(GLuint index, GLshort x, GLshort y, GLshort z) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib3svNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&y), 2); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib3svNV 4267 -void -__indirect_glVertexAttrib3svNV(GLuint index, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib3svNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 6); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4dvNV 4276 -void -__indirect_glVertexAttrib4dNV(GLuint index, GLdouble x, GLdouble y, - GLdouble z, GLdouble w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 40; - emit_header(gc->pc, X_GLrop_VertexAttrib4dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 24), (void *) (&z), 8); - (void) memcpy((void *) (gc->pc + 32), (void *) (&w), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4dvNV 4276 -void -__indirect_glVertexAttrib4dvNV(GLuint index, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 40; - emit_header(gc->pc, X_GLrop_VertexAttrib4dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 32); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4fvNV 4272 -void -__indirect_glVertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z, - GLfloat w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_VertexAttrib4fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&z), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&w), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4fvNV 4272 -void -__indirect_glVertexAttrib4fvNV(GLuint index, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_VertexAttrib4fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 16); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4svNV 4268 -void -__indirect_glVertexAttrib4sNV(GLuint index, GLshort x, GLshort y, GLshort z, - GLshort w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib4svNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 2); - (void) memcpy((void *) (gc->pc + 10), (void *) (&y), 2); - (void) memcpy((void *) (gc->pc + 12), (void *) (&z), 2); - (void) memcpy((void *) (gc->pc + 14), (void *) (&w), 2); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4svNV 4268 -void -__indirect_glVertexAttrib4svNV(GLuint index, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 16; - emit_header(gc->pc, X_GLrop_VertexAttrib4svNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 8); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4ubvNV 4277 -void -__indirect_glVertexAttrib4ubNV(GLuint index, GLubyte x, GLubyte y, GLubyte z, - GLubyte w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib4ubvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&x), 1); - (void) memcpy((void *) (gc->pc + 9), (void *) (&y), 1); - (void) memcpy((void *) (gc->pc + 10), (void *) (&z), 1); - (void) memcpy((void *) (gc->pc + 11), (void *) (&w), 1); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttrib4ubvNV 4277 -void -__indirect_glVertexAttrib4ubvNV(GLuint index, const GLubyte *v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_VertexAttrib4ubvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (v), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_VertexAttribs1dvNV 4210 -void -__indirect_glVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 8)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs1dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 8)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_VertexAttribs1fvNV 4206 -void -__indirect_glVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 4)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs1fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_VertexAttribs1svNV 4202 -void -__indirect_glVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 2)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs1svNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 2)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_VertexAttribs2dvNV 4211 -void -__indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 16)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs2dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 16)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_VertexAttribs2fvNV 4207 -void -__indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 8)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs2fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 8)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_VertexAttribs2svNV 4203 -void -__indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 4)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs2svNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_VertexAttribs3dvNV 4212 -void -__indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 24)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs3dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 24)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_VertexAttribs3fvNV 4208 -void -__indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 12)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs3fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 12)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_VertexAttribs3svNV 4204 -void -__indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 6)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs3svNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 6)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_VertexAttribs4dvNV 4213 -void -__indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 32)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs4dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 32)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_VertexAttribs4fvNV 4209 -void -__indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 16)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs4fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 16)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_VertexAttribs4svNV 4205 -void -__indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 8)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs4svNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 8)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_VertexAttribs4ubvNV 4214 -void -__indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte *v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12 + __GLX_PAD((n * 4)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_VertexAttribs4ubvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_PointParameteriNV 4221 -void -__indirect_glPointParameteriNV(GLenum pname, GLint param) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_PointParameteriNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (¶m), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_PointParameterivNV 4222 -void -__indirect_glPointParameterivNV(GLenum pname, const GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint compsize = __glPointParameterivNV_size(pname); - const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4)); - emit_header(gc->pc, X_GLrop_PointParameterivNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_ActiveStencilFaceEXT 4220 -void -__indirect_glActiveStencilFaceEXT(GLenum face) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_ActiveStencilFaceEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLvop_GetProgramNamedParameterdvNV 1311 -void -__indirect_glGetProgramNamedParameterdvNV(GLuint id, GLsizei len, - const GLubyte *name, - GLdouble * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8 + __GLX_PAD(len); - if (len < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((len >= 0) && (dpy != NULL), 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetProgramNamedParameterdvNV, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&id), 4); - (void) memcpy((void *) (pc + 4), (void *) (&len), 4); - (void) memcpy((void *) (pc + 8), (void *) (name), len); - (void) __glXReadReply(dpy, 8, params, GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_GetProgramNamedParameterfvNV 1310 -void -__indirect_glGetProgramNamedParameterfvNV(GLuint id, GLsizei len, - const GLubyte *name, - GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8 + __GLX_PAD(len); - if (len < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((len >= 0) && (dpy != NULL), 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetProgramNamedParameterfvNV, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&id), 4); - (void) memcpy((void *) (pc + 4), (void *) (&len), 4); - (void) memcpy((void *) (pc + 8), (void *) (name), len); - (void) __glXReadReply(dpy, 4, params, GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLrop_ProgramNamedParameter4dvNV 4219 -void -__indirect_glProgramNamedParameter4dNV(GLuint id, GLsizei len, - const GLubyte *name, GLdouble x, - GLdouble y, GLdouble z, GLdouble w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 44 + __GLX_PAD(len); - if (len < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(len >= 0, 1)) { - emit_header(gc->pc, X_GLrop_ProgramNamedParameter4dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8); - (void) memcpy((void *) (gc->pc + 12), (void *) (&y), 8); - (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 8); - (void) memcpy((void *) (gc->pc + 28), (void *) (&w), 8); - (void) memcpy((void *) (gc->pc + 36), (void *) (&id), 4); - (void) memcpy((void *) (gc->pc + 40), (void *) (&len), 4); - (void) memcpy((void *) (gc->pc + 44), (void *) (name), len); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_ProgramNamedParameter4dvNV 4219 -void -__indirect_glProgramNamedParameter4dvNV(GLuint id, GLsizei len, - const GLubyte *name, - const GLdouble * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 44 + __GLX_PAD(len); - if (len < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(len >= 0, 1)) { - emit_header(gc->pc, X_GLrop_ProgramNamedParameter4dvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (v), 32); - (void) memcpy((void *) (gc->pc + 36), (void *) (&id), 4); - (void) memcpy((void *) (gc->pc + 40), (void *) (&len), 4); - (void) memcpy((void *) (gc->pc + 44), (void *) (name), len); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_ProgramNamedParameter4fvNV 4218 -void -__indirect_glProgramNamedParameter4fNV(GLuint id, GLsizei len, - const GLubyte *name, GLfloat x, - GLfloat y, GLfloat z, GLfloat w) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28 + __GLX_PAD(len); - if (len < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(len >= 0, 1)) { - emit_header(gc->pc, X_GLrop_ProgramNamedParameter4fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&id), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&len), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&x), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&y), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&z), 4); - (void) memcpy((void *) (gc->pc + 24), (void *) (&w), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (name), len); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_ProgramNamedParameter4fvNV 4218 -void -__indirect_glProgramNamedParameter4fvNV(GLuint id, GLsizei len, - const GLubyte *name, - const GLfloat * v) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28 + __GLX_PAD(len); - if (len < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(len >= 0, 1)) { - emit_header(gc->pc, X_GLrop_ProgramNamedParameter4fvNV, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&id), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&len), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (v), 16); - (void) memcpy((void *) (gc->pc + 28), (void *) (name), len); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_BlendEquationSeparateEXT 4228 -void -__indirect_glBlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_BlendEquationSeparateEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&modeRGB), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&modeA), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_BindFramebufferEXT 4319 -void -__indirect_glBindFramebufferEXT(GLenum target, GLuint framebuffer) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_BindFramebufferEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&framebuffer), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_BindRenderbufferEXT 4316 -void -__indirect_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 12; - emit_header(gc->pc, X_GLrop_BindRenderbufferEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&renderbuffer), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLvop_CheckFramebufferStatusEXT 1427 -GLenum -__indirect_glCheckFramebufferStatusEXT(GLenum target) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - GLenum retval = (GLenum) 0; - const GLuint cmdlen = 4; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_CheckFramebufferStatusEXT, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - retval = (GLenum) __glXReadReply(dpy, 0, NULL, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return retval; -} - -#define X_GLrop_DeleteFramebuffersEXT 4320 -void -__indirect_glDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8 + __GLX_PAD((n * 4)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_DeleteFramebuffersEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (framebuffers), - (n * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_DeleteRenderbuffersEXT 4317 -void -__indirect_glDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8 + __GLX_PAD((n * 4)); - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect(n >= 0, 1)) { - emit_header(gc->pc, X_GLrop_DeleteRenderbuffersEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (renderbuffers), - (n * 4)); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - -#define X_GLrop_FramebufferRenderbufferEXT 4324 -void -__indirect_glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_FramebufferRenderbufferEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&attachment), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&renderbuffertarget), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&renderbuffer), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_FramebufferTexture1DEXT 4321 -void -__indirect_glFramebufferTexture1DEXT(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, - GLint level) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_FramebufferTexture1DEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&attachment), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&textarget), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&texture), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&level), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_FramebufferTexture2DEXT 4322 -void -__indirect_glFramebufferTexture2DEXT(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, - GLint level) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_FramebufferTexture2DEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&attachment), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&textarget), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&texture), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&level), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_FramebufferTexture3DEXT 4323 -void -__indirect_glFramebufferTexture3DEXT(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, - GLint level, GLint zoffset) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 28; - emit_header(gc->pc, X_GLrop_FramebufferTexture3DEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&attachment), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&textarget), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&texture), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&level), 4); - (void) memcpy((void *) (gc->pc + 24), (void *) (&zoffset), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLvop_GenFramebuffersEXT 1426 -void -__indirect_glGenFramebuffersEXT(GLsizei n, GLuint * framebuffers) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 4; - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GenFramebuffersEXT, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) __glXReadReply(dpy, 4, framebuffers, GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_GenRenderbuffersEXT 1423 -void -__indirect_glGenRenderbuffersEXT(GLsizei n, GLuint * renderbuffers) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 4; - if (n < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GenRenderbuffersEXT, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) __glXReadReply(dpy, 4, renderbuffers, GL_TRUE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLrop_GenerateMipmapEXT 4325 -void -__indirect_glGenerateMipmapEXT(GLenum target) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 8; - emit_header(gc->pc, X_GLrop_GenerateMipmapEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLvop_GetFramebufferAttachmentParameterivEXT 1428 -void -__indirect_glGetFramebufferAttachmentParameterivEXT(GLenum target, - GLenum attachment, - GLenum pname, - GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 12; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetFramebufferAttachmentParameterivEXT, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&attachment), 4); - (void) memcpy((void *) (pc + 8), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_GetRenderbufferParameterivEXT 1424 -void -__indirect_glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, - GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetRenderbufferParameterivEXT, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&pname), 4); - (void) __glXReadReply(dpy, 4, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -#define X_GLvop_IsFramebufferEXT 1425 -GLboolean -__indirect_glIsFramebufferEXT(GLuint framebuffer) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - GLboolean retval = (GLboolean) 0; - const GLuint cmdlen = 4; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_IsFramebufferEXT, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&framebuffer), 4); - retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return retval; -} - -#define X_GLvop_IsRenderbufferEXT 1422 -GLboolean -__indirect_glIsRenderbufferEXT(GLuint renderbuffer) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - GLboolean retval = (GLboolean) 0; - const GLuint cmdlen = 4; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_IsRenderbufferEXT, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&renderbuffer), 4); - retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return retval; -} - -#define X_GLrop_RenderbufferStorageEXT 4318 -void -__indirect_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, - GLsizei width, GLsizei height) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 20; - emit_header(gc->pc, X_GLrop_RenderbufferStorageEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&internalformat), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&width), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&height), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_BlitFramebufferEXT 4330 -void -__indirect_glBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, - GLint srcY1, GLint dstX0, GLint dstY0, - GLint dstX1, GLint dstY1, GLbitfield mask, - GLenum filter) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 44; - emit_header(gc->pc, X_GLrop_BlitFramebufferEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&srcX0), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&srcY0), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&srcX1), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&srcY1), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&dstX0), 4); - (void) memcpy((void *) (gc->pc + 24), (void *) (&dstY0), 4); - (void) memcpy((void *) (gc->pc + 28), (void *) (&dstX1), 4); - (void) memcpy((void *) (gc->pc + 32), (void *) (&dstY1), 4); - (void) memcpy((void *) (gc->pc + 36), (void *) (&mask), 4); - (void) memcpy((void *) (gc->pc + 40), (void *) (&filter), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - -#define X_GLrop_FramebufferTextureLayerEXT 237 -void -__indirect_glFramebufferTextureLayerEXT(GLenum target, GLenum attachment, - GLuint texture, GLint level, - GLint layer) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - const GLuint cmdlen = 24; - emit_header(gc->pc, X_GLrop_FramebufferTextureLayerEXT, cmdlen); - (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4); - (void) memcpy((void *) (gc->pc + 8), (void *) (&attachment), 4); - (void) memcpy((void *) (gc->pc + 12), (void *) (&texture), 4); - (void) memcpy((void *) (gc->pc + 16), (void *) (&level), 4); - (void) memcpy((void *) (gc->pc + 20), (void *) (&layer), 4); - gc->pc += cmdlen; - if (__builtin_expect(gc->pc > gc->limit, 0)) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - - -# undef FASTCALL -# undef NOINLINE diff --git a/src/glx/x11/indirect.h b/src/glx/x11/indirect.h deleted file mode 100644 index 9e73b338184..00000000000 --- a/src/glx/x11/indirect.h +++ /dev/null @@ -1,721 +0,0 @@ -/* DO NOT EDIT - This file generated automatically by glX_proto_send.py (from Mesa) script */ - -/* - * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - * (C) Copyright IBM Corporation 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT, IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined( _INDIRECT_H_ ) -# define _INDIRECT_H_ - -/** - * \file - * Prototypes for indirect rendering functions. - * - * \author Kevin E. Martin - * \author Ian Romanick - */ - -# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) && defined(__ELF__) -# define HIDDEN __attribute__((visibility("hidden"))) -# else -# define HIDDEN -# endif -# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) -# define FASTCALL __attribute__((fastcall)) -# else -# define FASTCALL -# endif -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define NOINLINE __attribute__((noinline)) -# else -# define NOINLINE -# endif - -#include "glxclient.h" - -extern HIDDEN NOINLINE CARD32 __glXReadReply( Display *dpy, size_t size, - void * dest, GLboolean reply_is_always_array ); - -extern HIDDEN NOINLINE void __glXReadPixelReply( Display *dpy, - __GLXcontext * gc, unsigned max_dim, GLint width, GLint height, - GLint depth, GLenum format, GLenum type, void * dest, - GLboolean dimensions_in_reply ); - -extern HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupSingleRequest( - __GLXcontext * gc, GLint sop, GLint cmdlen ); - -extern HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest( - __GLXcontext * gc, GLint code, GLint vop, GLint cmdlen ); - -extern HIDDEN void __indirect_glNewList(GLuint list, GLenum mode); -extern HIDDEN void __indirect_glEndList(void); -extern HIDDEN void __indirect_glCallList(GLuint list); -extern HIDDEN void __indirect_glCallLists(GLsizei n, GLenum type, const GLvoid * lists); -extern HIDDEN void __indirect_glDeleteLists(GLuint list, GLsizei range); -extern HIDDEN GLuint __indirect_glGenLists(GLsizei range); -extern HIDDEN void __indirect_glListBase(GLuint base); -extern HIDDEN void __indirect_glBegin(GLenum mode); -extern HIDDEN void __indirect_glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap); -extern HIDDEN void __indirect_glColor3b(GLbyte red, GLbyte green, GLbyte blue); -extern HIDDEN void __indirect_glColor3bv(const GLbyte * v); -extern HIDDEN void __indirect_glColor3d(GLdouble red, GLdouble green, GLdouble blue); -extern HIDDEN void __indirect_glColor3dv(const GLdouble * v); -extern HIDDEN void __indirect_glColor3f(GLfloat red, GLfloat green, GLfloat blue); -extern HIDDEN void __indirect_glColor3fv(const GLfloat * v); -extern HIDDEN void __indirect_glColor3i(GLint red, GLint green, GLint blue); -extern HIDDEN void __indirect_glColor3iv(const GLint * v); -extern HIDDEN void __indirect_glColor3s(GLshort red, GLshort green, GLshort blue); -extern HIDDEN void __indirect_glColor3sv(const GLshort * v); -extern HIDDEN void __indirect_glColor3ub(GLubyte red, GLubyte green, GLubyte blue); -extern HIDDEN void __indirect_glColor3ubv(const GLubyte * v); -extern HIDDEN void __indirect_glColor3ui(GLuint red, GLuint green, GLuint blue); -extern HIDDEN void __indirect_glColor3uiv(const GLuint * v); -extern HIDDEN void __indirect_glColor3us(GLushort red, GLushort green, GLushort blue); -extern HIDDEN void __indirect_glColor3usv(const GLushort * v); -extern HIDDEN void __indirect_glColor4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); -extern HIDDEN void __indirect_glColor4bv(const GLbyte * v); -extern HIDDEN void __indirect_glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); -extern HIDDEN void __indirect_glColor4dv(const GLdouble * v); -extern HIDDEN void __indirect_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -extern HIDDEN void __indirect_glColor4fv(const GLfloat * v); -extern HIDDEN void __indirect_glColor4i(GLint red, GLint green, GLint blue, GLint alpha); -extern HIDDEN void __indirect_glColor4iv(const GLint * v); -extern HIDDEN void __indirect_glColor4s(GLshort red, GLshort green, GLshort blue, GLshort alpha); -extern HIDDEN void __indirect_glColor4sv(const GLshort * v); -extern HIDDEN void __indirect_glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); -extern HIDDEN void __indirect_glColor4ubv(const GLubyte * v); -extern HIDDEN void __indirect_glColor4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha); -extern HIDDEN void __indirect_glColor4uiv(const GLuint * v); -extern HIDDEN void __indirect_glColor4us(GLushort red, GLushort green, GLushort blue, GLushort alpha); -extern HIDDEN void __indirect_glColor4usv(const GLushort * v); -extern HIDDEN void __indirect_glEdgeFlag(GLboolean flag); -extern HIDDEN void __indirect_glEdgeFlagv(const GLboolean * flag); -extern HIDDEN void __indirect_glEnd(void); -extern HIDDEN void __indirect_glIndexd(GLdouble c); -extern HIDDEN void __indirect_glIndexdv(const GLdouble * c); -extern HIDDEN void __indirect_glIndexf(GLfloat c); -extern HIDDEN void __indirect_glIndexfv(const GLfloat * c); -extern HIDDEN void __indirect_glIndexi(GLint c); -extern HIDDEN void __indirect_glIndexiv(const GLint * c); -extern HIDDEN void __indirect_glIndexs(GLshort c); -extern HIDDEN void __indirect_glIndexsv(const GLshort * c); -extern HIDDEN void __indirect_glNormal3b(GLbyte nx, GLbyte ny, GLbyte nz); -extern HIDDEN void __indirect_glNormal3bv(const GLbyte * v); -extern HIDDEN void __indirect_glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz); -extern HIDDEN void __indirect_glNormal3dv(const GLdouble * v); -extern HIDDEN void __indirect_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz); -extern HIDDEN void __indirect_glNormal3fv(const GLfloat * v); -extern HIDDEN void __indirect_glNormal3i(GLint nx, GLint ny, GLint nz); -extern HIDDEN void __indirect_glNormal3iv(const GLint * v); -extern HIDDEN void __indirect_glNormal3s(GLshort nx, GLshort ny, GLshort nz); -extern HIDDEN void __indirect_glNormal3sv(const GLshort * v); -extern HIDDEN void __indirect_glRasterPos2d(GLdouble x, GLdouble y); -extern HIDDEN void __indirect_glRasterPos2dv(const GLdouble * v); -extern HIDDEN void __indirect_glRasterPos2f(GLfloat x, GLfloat y); -extern HIDDEN void __indirect_glRasterPos2fv(const GLfloat * v); -extern HIDDEN void __indirect_glRasterPos2i(GLint x, GLint y); -extern HIDDEN void __indirect_glRasterPos2iv(const GLint * v); -extern HIDDEN void __indirect_glRasterPos2s(GLshort x, GLshort y); -extern HIDDEN void __indirect_glRasterPos2sv(const GLshort * v); -extern HIDDEN void __indirect_glRasterPos3d(GLdouble x, GLdouble y, GLdouble z); -extern HIDDEN void __indirect_glRasterPos3dv(const GLdouble * v); -extern HIDDEN void __indirect_glRasterPos3f(GLfloat x, GLfloat y, GLfloat z); -extern HIDDEN void __indirect_glRasterPos3fv(const GLfloat * v); -extern HIDDEN void __indirect_glRasterPos3i(GLint x, GLint y, GLint z); -extern HIDDEN void __indirect_glRasterPos3iv(const GLint * v); -extern HIDDEN void __indirect_glRasterPos3s(GLshort x, GLshort y, GLshort z); -extern HIDDEN void __indirect_glRasterPos3sv(const GLshort * v); -extern HIDDEN void __indirect_glRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w); -extern HIDDEN void __indirect_glRasterPos4dv(const GLdouble * v); -extern HIDDEN void __indirect_glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w); -extern HIDDEN void __indirect_glRasterPos4fv(const GLfloat * v); -extern HIDDEN void __indirect_glRasterPos4i(GLint x, GLint y, GLint z, GLint w); -extern HIDDEN void __indirect_glRasterPos4iv(const GLint * v); -extern HIDDEN void __indirect_glRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w); -extern HIDDEN void __indirect_glRasterPos4sv(const GLshort * v); -extern HIDDEN void __indirect_glRectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); -extern HIDDEN void __indirect_glRectdv(const GLdouble * v1, const GLdouble * v2); -extern HIDDEN void __indirect_glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); -extern HIDDEN void __indirect_glRectfv(const GLfloat * v1, const GLfloat * v2); -extern HIDDEN void __indirect_glRecti(GLint x1, GLint y1, GLint x2, GLint y2); -extern HIDDEN void __indirect_glRectiv(const GLint * v1, const GLint * v2); -extern HIDDEN void __indirect_glRects(GLshort x1, GLshort y1, GLshort x2, GLshort y2); -extern HIDDEN void __indirect_glRectsv(const GLshort * v1, const GLshort * v2); -extern HIDDEN void __indirect_glTexCoord1d(GLdouble s); -extern HIDDEN void __indirect_glTexCoord1dv(const GLdouble * v); -extern HIDDEN void __indirect_glTexCoord1f(GLfloat s); -extern HIDDEN void __indirect_glTexCoord1fv(const GLfloat * v); -extern HIDDEN void __indirect_glTexCoord1i(GLint s); -extern HIDDEN void __indirect_glTexCoord1iv(const GLint * v); -extern HIDDEN void __indirect_glTexCoord1s(GLshort s); -extern HIDDEN void __indirect_glTexCoord1sv(const GLshort * v); -extern HIDDEN void __indirect_glTexCoord2d(GLdouble s, GLdouble t); -extern HIDDEN void __indirect_glTexCoord2dv(const GLdouble * v); -extern HIDDEN void __indirect_glTexCoord2f(GLfloat s, GLfloat t); -extern HIDDEN void __indirect_glTexCoord2fv(const GLfloat * v); -extern HIDDEN void __indirect_glTexCoord2i(GLint s, GLint t); -extern HIDDEN void __indirect_glTexCoord2iv(const GLint * v); -extern HIDDEN void __indirect_glTexCoord2s(GLshort s, GLshort t); -extern HIDDEN void __indirect_glTexCoord2sv(const GLshort * v); -extern HIDDEN void __indirect_glTexCoord3d(GLdouble s, GLdouble t, GLdouble r); -extern HIDDEN void __indirect_glTexCoord3dv(const GLdouble * v); -extern HIDDEN void __indirect_glTexCoord3f(GLfloat s, GLfloat t, GLfloat r); -extern HIDDEN void __indirect_glTexCoord3fv(const GLfloat * v); -extern HIDDEN void __indirect_glTexCoord3i(GLint s, GLint t, GLint r); -extern HIDDEN void __indirect_glTexCoord3iv(const GLint * v); -extern HIDDEN void __indirect_glTexCoord3s(GLshort s, GLshort t, GLshort r); -extern HIDDEN void __indirect_glTexCoord3sv(const GLshort * v); -extern HIDDEN void __indirect_glTexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q); -extern HIDDEN void __indirect_glTexCoord4dv(const GLdouble * v); -extern HIDDEN void __indirect_glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q); -extern HIDDEN void __indirect_glTexCoord4fv(const GLfloat * v); -extern HIDDEN void __indirect_glTexCoord4i(GLint s, GLint t, GLint r, GLint q); -extern HIDDEN void __indirect_glTexCoord4iv(const GLint * v); -extern HIDDEN void __indirect_glTexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q); -extern HIDDEN void __indirect_glTexCoord4sv(const GLshort * v); -extern HIDDEN void __indirect_glVertex2d(GLdouble x, GLdouble y); -extern HIDDEN void __indirect_glVertex2dv(const GLdouble * v); -extern HIDDEN void __indirect_glVertex2f(GLfloat x, GLfloat y); -extern HIDDEN void __indirect_glVertex2fv(const GLfloat * v); -extern HIDDEN void __indirect_glVertex2i(GLint x, GLint y); -extern HIDDEN void __indirect_glVertex2iv(const GLint * v); -extern HIDDEN void __indirect_glVertex2s(GLshort x, GLshort y); -extern HIDDEN void __indirect_glVertex2sv(const GLshort * v); -extern HIDDEN void __indirect_glVertex3d(GLdouble x, GLdouble y, GLdouble z); -extern HIDDEN void __indirect_glVertex3dv(const GLdouble * v); -extern HIDDEN void __indirect_glVertex3f(GLfloat x, GLfloat y, GLfloat z); -extern HIDDEN void __indirect_glVertex3fv(const GLfloat * v); -extern HIDDEN void __indirect_glVertex3i(GLint x, GLint y, GLint z); -extern HIDDEN void __indirect_glVertex3iv(const GLint * v); -extern HIDDEN void __indirect_glVertex3s(GLshort x, GLshort y, GLshort z); -extern HIDDEN void __indirect_glVertex3sv(const GLshort * v); -extern HIDDEN void __indirect_glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w); -extern HIDDEN void __indirect_glVertex4dv(const GLdouble * v); -extern HIDDEN void __indirect_glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w); -extern HIDDEN void __indirect_glVertex4fv(const GLfloat * v); -extern HIDDEN void __indirect_glVertex4i(GLint x, GLint y, GLint z, GLint w); -extern HIDDEN void __indirect_glVertex4iv(const GLint * v); -extern HIDDEN void __indirect_glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w); -extern HIDDEN void __indirect_glVertex4sv(const GLshort * v); -extern HIDDEN void __indirect_glClipPlane(GLenum plane, const GLdouble * equation); -extern HIDDEN void __indirect_glColorMaterial(GLenum face, GLenum mode); -extern HIDDEN void __indirect_glCullFace(GLenum mode); -extern HIDDEN void __indirect_glFogf(GLenum pname, GLfloat param); -extern HIDDEN void __indirect_glFogfv(GLenum pname, const GLfloat * params); -extern HIDDEN void __indirect_glFogi(GLenum pname, GLint param); -extern HIDDEN void __indirect_glFogiv(GLenum pname, const GLint * params); -extern HIDDEN void __indirect_glFrontFace(GLenum mode); -extern HIDDEN void __indirect_glHint(GLenum target, GLenum mode); -extern HIDDEN void __indirect_glLightf(GLenum light, GLenum pname, GLfloat param); -extern HIDDEN void __indirect_glLightfv(GLenum light, GLenum pname, const GLfloat * params); -extern HIDDEN void __indirect_glLighti(GLenum light, GLenum pname, GLint param); -extern HIDDEN void __indirect_glLightiv(GLenum light, GLenum pname, const GLint * params); -extern HIDDEN void __indirect_glLightModelf(GLenum pname, GLfloat param); -extern HIDDEN void __indirect_glLightModelfv(GLenum pname, const GLfloat * params); -extern HIDDEN void __indirect_glLightModeli(GLenum pname, GLint param); -extern HIDDEN void __indirect_glLightModeliv(GLenum pname, const GLint * params); -extern HIDDEN void __indirect_glLineStipple(GLint factor, GLushort pattern); -extern HIDDEN void __indirect_glLineWidth(GLfloat width); -extern HIDDEN void __indirect_glMaterialf(GLenum face, GLenum pname, GLfloat param); -extern HIDDEN void __indirect_glMaterialfv(GLenum face, GLenum pname, const GLfloat * params); -extern HIDDEN void __indirect_glMateriali(GLenum face, GLenum pname, GLint param); -extern HIDDEN void __indirect_glMaterialiv(GLenum face, GLenum pname, const GLint * params); -extern HIDDEN void __indirect_glPointSize(GLfloat size); -extern HIDDEN void __indirect_glPolygonMode(GLenum face, GLenum mode); -extern HIDDEN void __indirect_glPolygonStipple(const GLubyte * mask); -extern HIDDEN void __indirect_glScissor(GLint x, GLint y, GLsizei width, GLsizei height); -extern HIDDEN void __indirect_glShadeModel(GLenum mode); -extern HIDDEN void __indirect_glTexParameterf(GLenum target, GLenum pname, GLfloat param); -extern HIDDEN void __indirect_glTexParameterfv(GLenum target, GLenum pname, const GLfloat * params); -extern HIDDEN void __indirect_glTexParameteri(GLenum target, GLenum pname, GLint param); -extern HIDDEN void __indirect_glTexParameteriv(GLenum target, GLenum pname, const GLint * params); -extern HIDDEN void __indirect_glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid * pixels); -extern HIDDEN void __indirect_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels); -extern HIDDEN void __indirect_glTexEnvf(GLenum target, GLenum pname, GLfloat param); -extern HIDDEN void __indirect_glTexEnvfv(GLenum target, GLenum pname, const GLfloat * params); -extern HIDDEN void __indirect_glTexEnvi(GLenum target, GLenum pname, GLint param); -extern HIDDEN void __indirect_glTexEnviv(GLenum target, GLenum pname, const GLint * params); -extern HIDDEN void __indirect_glTexGend(GLenum coord, GLenum pname, GLdouble param); -extern HIDDEN void __indirect_glTexGendv(GLenum coord, GLenum pname, const GLdouble * params); -extern HIDDEN void __indirect_glTexGenf(GLenum coord, GLenum pname, GLfloat param); -extern HIDDEN void __indirect_glTexGenfv(GLenum coord, GLenum pname, const GLfloat * params); -extern HIDDEN void __indirect_glTexGeni(GLenum coord, GLenum pname, GLint param); -extern HIDDEN void __indirect_glTexGeniv(GLenum coord, GLenum pname, const GLint * params); -extern HIDDEN void __indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer); -extern HIDDEN void __indirect_glSelectBuffer(GLsizei size, GLuint * buffer); -extern HIDDEN GLint __indirect_glRenderMode(GLenum mode); -extern HIDDEN void __indirect_glInitNames(void); -extern HIDDEN void __indirect_glLoadName(GLuint name); -extern HIDDEN void __indirect_glPassThrough(GLfloat token); -extern HIDDEN void __indirect_glPopName(void); -extern HIDDEN void __indirect_glPushName(GLuint name); -extern HIDDEN void __indirect_glDrawBuffer(GLenum mode); -extern HIDDEN void __indirect_glClear(GLbitfield mask); -extern HIDDEN void __indirect_glClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -extern HIDDEN void __indirect_glClearIndex(GLfloat c); -extern HIDDEN void __indirect_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -extern HIDDEN void __indirect_glClearStencil(GLint s); -extern HIDDEN void __indirect_glClearDepth(GLclampd depth); -extern HIDDEN void __indirect_glStencilMask(GLuint mask); -extern HIDDEN void __indirect_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -extern HIDDEN void __indirect_glDepthMask(GLboolean flag); -extern HIDDEN void __indirect_glIndexMask(GLuint mask); -extern HIDDEN void __indirect_glAccum(GLenum op, GLfloat value); -extern HIDDEN void __indirect_glDisable(GLenum cap); -extern HIDDEN void __indirect_glEnable(GLenum cap); -extern HIDDEN void __indirect_glFinish(void); -extern HIDDEN void __indirect_glFlush(void); -extern HIDDEN void __indirect_glPopAttrib(void); -extern HIDDEN void __indirect_glPushAttrib(GLbitfield mask); -extern HIDDEN void __indirect_glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points); -extern HIDDEN void __indirect_glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points); -extern HIDDEN void __indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points); -extern HIDDEN void __indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points); -extern HIDDEN void __indirect_glMapGrid1d(GLint un, GLdouble u1, GLdouble u2); -extern HIDDEN void __indirect_glMapGrid1f(GLint un, GLfloat u1, GLfloat u2); -extern HIDDEN void __indirect_glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); -extern HIDDEN void __indirect_glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); -extern HIDDEN void __indirect_glEvalCoord1d(GLdouble u); -extern HIDDEN void __indirect_glEvalCoord1dv(const GLdouble * u); -extern HIDDEN void __indirect_glEvalCoord1f(GLfloat u); -extern HIDDEN void __indirect_glEvalCoord1fv(const GLfloat * u); -extern HIDDEN void __indirect_glEvalCoord2d(GLdouble u, GLdouble v); -extern HIDDEN void __indirect_glEvalCoord2dv(const GLdouble * u); -extern HIDDEN void __indirect_glEvalCoord2f(GLfloat u, GLfloat v); -extern HIDDEN void __indirect_glEvalCoord2fv(const GLfloat * u); -extern HIDDEN void __indirect_glEvalMesh1(GLenum mode, GLint i1, GLint i2); -extern HIDDEN void __indirect_glEvalPoint1(GLint i); -extern HIDDEN void __indirect_glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); -extern HIDDEN void __indirect_glEvalPoint2(GLint i, GLint j); -extern HIDDEN void __indirect_glAlphaFunc(GLenum func, GLclampf ref); -extern HIDDEN void __indirect_glBlendFunc(GLenum sfactor, GLenum dfactor); -extern HIDDEN void __indirect_glLogicOp(GLenum opcode); -extern HIDDEN void __indirect_glStencilFunc(GLenum func, GLint ref, GLuint mask); -extern HIDDEN void __indirect_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass); -extern HIDDEN void __indirect_glDepthFunc(GLenum func); -extern HIDDEN void __indirect_glPixelZoom(GLfloat xfactor, GLfloat yfactor); -extern HIDDEN void __indirect_glPixelTransferf(GLenum pname, GLfloat param); -extern HIDDEN void __indirect_glPixelTransferi(GLenum pname, GLint param); -extern HIDDEN void __indirect_glPixelStoref(GLenum pname, GLfloat param); -extern HIDDEN void __indirect_glPixelStorei(GLenum pname, GLint param); -extern HIDDEN void __indirect_glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat * values); -extern HIDDEN void __indirect_glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint * values); -extern HIDDEN void __indirect_glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort * values); -extern HIDDEN void __indirect_glReadBuffer(GLenum mode); -extern HIDDEN void __indirect_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); -extern HIDDEN void __indirect_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * pixels); -extern HIDDEN void __indirect_glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels); -extern HIDDEN void __indirect_glGetBooleanv(GLenum pname, GLboolean * params); -extern HIDDEN void __indirect_glGetClipPlane(GLenum plane, GLdouble * equation); -extern HIDDEN void __indirect_glGetDoublev(GLenum pname, GLdouble * params); -extern HIDDEN GLenum __indirect_glGetError(void); -extern HIDDEN void __indirect_glGetFloatv(GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetIntegerv(GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetLightfv(GLenum light, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetLightiv(GLenum light, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetMapdv(GLenum target, GLenum query, GLdouble * v); -extern HIDDEN void __indirect_glGetMapfv(GLenum target, GLenum query, GLfloat * v); -extern HIDDEN void __indirect_glGetMapiv(GLenum target, GLenum query, GLint * v); -extern HIDDEN void __indirect_glGetMaterialfv(GLenum face, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetMaterialiv(GLenum face, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetPixelMapfv(GLenum map, GLfloat * values); -extern HIDDEN void __indirect_glGetPixelMapuiv(GLenum map, GLuint * values); -extern HIDDEN void __indirect_glGetPixelMapusv(GLenum map, GLushort * values); -extern HIDDEN void __indirect_glGetPolygonStipple(GLubyte * mask); -extern HIDDEN const GLubyte * __indirect_glGetString(GLenum name); -extern HIDDEN void __indirect_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetTexEnviv(GLenum target, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetTexGendv(GLenum coord, GLenum pname, GLdouble * params); -extern HIDDEN void __indirect_glGetTexGenfv(GLenum coord, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetTexGeniv(GLenum coord, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid * pixels); -extern HIDDEN void __indirect_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetTexParameteriv(GLenum target, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint * params); -extern HIDDEN GLboolean __indirect_glIsEnabled(GLenum cap); -extern HIDDEN GLboolean __indirect_glIsList(GLuint list); -extern HIDDEN void __indirect_glDepthRange(GLclampd zNear, GLclampd zFar); -extern HIDDEN void __indirect_glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -extern HIDDEN void __indirect_glLoadIdentity(void); -extern HIDDEN void __indirect_glLoadMatrixf(const GLfloat * m); -extern HIDDEN void __indirect_glLoadMatrixd(const GLdouble * m); -extern HIDDEN void __indirect_glMatrixMode(GLenum mode); -extern HIDDEN void __indirect_glMultMatrixf(const GLfloat * m); -extern HIDDEN void __indirect_glMultMatrixd(const GLdouble * m); -extern HIDDEN void __indirect_glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -extern HIDDEN void __indirect_glPopMatrix(void); -extern HIDDEN void __indirect_glPushMatrix(void); -extern HIDDEN void __indirect_glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -extern HIDDEN void __indirect_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -extern HIDDEN void __indirect_glScaled(GLdouble x, GLdouble y, GLdouble z); -extern HIDDEN void __indirect_glScalef(GLfloat x, GLfloat y, GLfloat z); -extern HIDDEN void __indirect_glTranslated(GLdouble x, GLdouble y, GLdouble z); -extern HIDDEN void __indirect_glTranslatef(GLfloat x, GLfloat y, GLfloat z); -extern HIDDEN void __indirect_glViewport(GLint x, GLint y, GLsizei width, GLsizei height); -extern HIDDEN void __indirect_glArrayElement(GLint i); -extern HIDDEN void __indirect_glBindTexture(GLenum target, GLuint texture); -extern HIDDEN void __indirect_glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); -extern HIDDEN void __indirect_glDisableClientState(GLenum array); -extern HIDDEN void __indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count); -extern HIDDEN void __indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices); -extern HIDDEN void __indirect_glEdgeFlagPointer(GLsizei stride, const GLvoid * pointer); -extern HIDDEN void __indirect_glEnableClientState(GLenum array); -extern HIDDEN void __indirect_glIndexPointer(GLenum type, GLsizei stride, const GLvoid * pointer); -extern HIDDEN void __indirect_glIndexub(GLubyte c); -extern HIDDEN void __indirect_glIndexubv(const GLubyte * c); -extern HIDDEN void __indirect_glInterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer); -extern HIDDEN void __indirect_glNormalPointer(GLenum type, GLsizei stride, const GLvoid * pointer); -extern HIDDEN void __indirect_glPolygonOffset(GLfloat factor, GLfloat units); -extern HIDDEN void __indirect_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); -extern HIDDEN void __indirect_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); -extern HIDDEN GLboolean __indirect_glAreTexturesResident(GLsizei n, const GLuint * textures, GLboolean * residences); -GLAPI GLboolean GLAPIENTRY glAreTexturesResidentEXT(GLsizei n, const GLuint * textures, GLboolean * residences); -extern HIDDEN void __indirect_glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -extern HIDDEN void __indirect_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -extern HIDDEN void __indirect_glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -extern HIDDEN void __indirect_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -extern HIDDEN void __indirect_glDeleteTextures(GLsizei n, const GLuint * textures); -GLAPI void GLAPIENTRY glDeleteTexturesEXT(GLsizei n, const GLuint * textures); -extern HIDDEN void __indirect_glGenTextures(GLsizei n, GLuint * textures); -GLAPI void GLAPIENTRY glGenTexturesEXT(GLsizei n, GLuint * textures); -extern HIDDEN void __indirect_glGetPointerv(GLenum pname, GLvoid ** params); -extern HIDDEN GLboolean __indirect_glIsTexture(GLuint texture); -GLAPI GLboolean GLAPIENTRY glIsTextureEXT(GLuint texture); -extern HIDDEN void __indirect_glPrioritizeTextures(GLsizei n, const GLuint * textures, const GLclampf * priorities); -extern HIDDEN void __indirect_glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels); -extern HIDDEN void __indirect_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels); -extern HIDDEN void __indirect_glPopClientAttrib(void); -extern HIDDEN void __indirect_glPushClientAttrib(GLbitfield mask); -extern HIDDEN void __indirect_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -extern HIDDEN void __indirect_glBlendEquation(GLenum mode); -extern HIDDEN void __indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices); -extern HIDDEN void __indirect_glColorTable(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table); -extern HIDDEN void __indirect_glColorTableParameterfv(GLenum target, GLenum pname, const GLfloat * params); -extern HIDDEN void __indirect_glColorTableParameteriv(GLenum target, GLenum pname, const GLint * params); -extern HIDDEN void __indirect_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -extern HIDDEN void __indirect_glGetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * table); -GLAPI void GLAPIENTRY glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid * table); -extern HIDDEN void __indirect_glGetColorTableParameterfv(GLenum target, GLenum pname, GLfloat * params); -GLAPI void GLAPIENTRY glGetColorTableParameterfvEXT(GLenum target, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetColorTableParameteriv(GLenum target, GLenum pname, GLint * params); -GLAPI void GLAPIENTRY glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glColorSubTable(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid * data); -extern HIDDEN void __indirect_glCopyColorSubTable(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -extern HIDDEN void __indirect_glConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * image); -extern HIDDEN void __indirect_glConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * image); -extern HIDDEN void __indirect_glConvolutionParameterf(GLenum target, GLenum pname, GLfloat params); -extern HIDDEN void __indirect_glConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat * params); -extern HIDDEN void __indirect_glConvolutionParameteri(GLenum target, GLenum pname, GLint params); -extern HIDDEN void __indirect_glConvolutionParameteriv(GLenum target, GLenum pname, const GLint * params); -extern HIDDEN void __indirect_glCopyConvolutionFilter1D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -extern HIDDEN void __indirect_glCopyConvolutionFilter2D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -extern HIDDEN void __indirect_glGetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid * image); -extern HIDDEN void gl_dispatch_stub_356(GLenum target, GLenum format, GLenum type, GLvoid * image); -extern HIDDEN void __indirect_glGetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat * params); -extern HIDDEN void gl_dispatch_stub_357(GLenum target, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetConvolutionParameteriv(GLenum target, GLenum pname, GLint * params); -extern HIDDEN void gl_dispatch_stub_358(GLenum target, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span); -extern HIDDEN void gl_dispatch_stub_359(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span); -extern HIDDEN void __indirect_glSeparableFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * row, const GLvoid * column); -extern HIDDEN void __indirect_glGetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); -extern HIDDEN void gl_dispatch_stub_361(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); -extern HIDDEN void __indirect_glGetHistogramParameterfv(GLenum target, GLenum pname, GLfloat * params); -extern HIDDEN void gl_dispatch_stub_362(GLenum target, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetHistogramParameteriv(GLenum target, GLenum pname, GLint * params); -extern HIDDEN void gl_dispatch_stub_363(GLenum target, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); -extern HIDDEN void gl_dispatch_stub_364(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); -extern HIDDEN void __indirect_glGetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat * params); -extern HIDDEN void gl_dispatch_stub_365(GLenum target, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetMinmaxParameteriv(GLenum target, GLenum pname, GLint * params); -extern HIDDEN void gl_dispatch_stub_366(GLenum target, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glHistogram(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -extern HIDDEN void __indirect_glMinmax(GLenum target, GLenum internalformat, GLboolean sink); -extern HIDDEN void __indirect_glResetHistogram(GLenum target); -extern HIDDEN void __indirect_glResetMinmax(GLenum target); -extern HIDDEN void __indirect_glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels); -extern HIDDEN void __indirect_glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels); -extern HIDDEN void __indirect_glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -extern HIDDEN void __indirect_glActiveTextureARB(GLenum texture); -extern HIDDEN void __indirect_glClientActiveTextureARB(GLenum texture); -extern HIDDEN void __indirect_glMultiTexCoord1dARB(GLenum target, GLdouble s); -extern HIDDEN void __indirect_glMultiTexCoord1dvARB(GLenum target, const GLdouble * v); -extern HIDDEN void __indirect_glMultiTexCoord1fARB(GLenum target, GLfloat s); -extern HIDDEN void __indirect_glMultiTexCoord1fvARB(GLenum target, const GLfloat * v); -extern HIDDEN void __indirect_glMultiTexCoord1iARB(GLenum target, GLint s); -extern HIDDEN void __indirect_glMultiTexCoord1ivARB(GLenum target, const GLint * v); -extern HIDDEN void __indirect_glMultiTexCoord1sARB(GLenum target, GLshort s); -extern HIDDEN void __indirect_glMultiTexCoord1svARB(GLenum target, const GLshort * v); -extern HIDDEN void __indirect_glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t); -extern HIDDEN void __indirect_glMultiTexCoord2dvARB(GLenum target, const GLdouble * v); -extern HIDDEN void __indirect_glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); -extern HIDDEN void __indirect_glMultiTexCoord2fvARB(GLenum target, const GLfloat * v); -extern HIDDEN void __indirect_glMultiTexCoord2iARB(GLenum target, GLint s, GLint t); -extern HIDDEN void __indirect_glMultiTexCoord2ivARB(GLenum target, const GLint * v); -extern HIDDEN void __indirect_glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t); -extern HIDDEN void __indirect_glMultiTexCoord2svARB(GLenum target, const GLshort * v); -extern HIDDEN void __indirect_glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r); -extern HIDDEN void __indirect_glMultiTexCoord3dvARB(GLenum target, const GLdouble * v); -extern HIDDEN void __indirect_glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r); -extern HIDDEN void __indirect_glMultiTexCoord3fvARB(GLenum target, const GLfloat * v); -extern HIDDEN void __indirect_glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r); -extern HIDDEN void __indirect_glMultiTexCoord3ivARB(GLenum target, const GLint * v); -extern HIDDEN void __indirect_glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r); -extern HIDDEN void __indirect_glMultiTexCoord3svARB(GLenum target, const GLshort * v); -extern HIDDEN void __indirect_glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -extern HIDDEN void __indirect_glMultiTexCoord4dvARB(GLenum target, const GLdouble * v); -extern HIDDEN void __indirect_glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -extern HIDDEN void __indirect_glMultiTexCoord4fvARB(GLenum target, const GLfloat * v); -extern HIDDEN void __indirect_glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q); -extern HIDDEN void __indirect_glMultiTexCoord4ivARB(GLenum target, const GLint * v); -extern HIDDEN void __indirect_glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -extern HIDDEN void __indirect_glMultiTexCoord4svARB(GLenum target, const GLshort * v); -extern HIDDEN void __indirect_glLoadTransposeMatrixdARB(const GLdouble * m); -extern HIDDEN void __indirect_glLoadTransposeMatrixfARB(const GLfloat * m); -extern HIDDEN void __indirect_glMultTransposeMatrixdARB(const GLdouble * m); -extern HIDDEN void __indirect_glMultTransposeMatrixfARB(const GLfloat * m); -extern HIDDEN void __indirect_glSampleCoverageARB(GLclampf value, GLboolean invert); -extern HIDDEN void __indirect_glCompressedTexImage1DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid * data); -extern HIDDEN void __indirect_glCompressedTexImage2DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data); -extern HIDDEN void __indirect_glCompressedTexImage3DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid * data); -extern HIDDEN void __indirect_glCompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid * data); -extern HIDDEN void __indirect_glCompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data); -extern HIDDEN void __indirect_glCompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid * data); -extern HIDDEN void __indirect_glGetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img); -extern HIDDEN void __indirect_glDisableVertexAttribArrayARB(GLuint index); -extern HIDDEN void __indirect_glEnableVertexAttribArrayARB(GLuint index); -extern HIDDEN void __indirect_glGetProgramEnvParameterdvARB(GLenum target, GLuint index, GLdouble * params); -extern HIDDEN void __indirect_glGetProgramEnvParameterfvARB(GLenum target, GLuint index, GLfloat * params); -extern HIDDEN void __indirect_glGetProgramLocalParameterdvARB(GLenum target, GLuint index, GLdouble * params); -extern HIDDEN void __indirect_glGetProgramLocalParameterfvARB(GLenum target, GLuint index, GLfloat * params); -extern HIDDEN void __indirect_glGetProgramStringARB(GLenum target, GLenum pname, GLvoid * string); -extern HIDDEN void __indirect_glGetProgramivARB(GLenum target, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble * params); -extern HIDDEN void __indirect_glGetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetVertexAttribivARB(GLuint index, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glProgramEnvParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -extern HIDDEN void __indirect_glProgramEnvParameter4dvARB(GLenum target, GLuint index, const GLdouble * params); -extern HIDDEN void __indirect_glProgramEnvParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -extern HIDDEN void __indirect_glProgramEnvParameter4fvARB(GLenum target, GLuint index, const GLfloat * params); -extern HIDDEN void __indirect_glProgramLocalParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -extern HIDDEN void __indirect_glProgramLocalParameter4dvARB(GLenum target, GLuint index, const GLdouble * params); -extern HIDDEN void __indirect_glProgramLocalParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -extern HIDDEN void __indirect_glProgramLocalParameter4fvARB(GLenum target, GLuint index, const GLfloat * params); -extern HIDDEN void __indirect_glProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid * string); -extern HIDDEN void __indirect_glVertexAttrib1dARB(GLuint index, GLdouble x); -extern HIDDEN void __indirect_glVertexAttrib1dvARB(GLuint index, const GLdouble * v); -extern HIDDEN void __indirect_glVertexAttrib1fARB(GLuint index, GLfloat x); -extern HIDDEN void __indirect_glVertexAttrib1fvARB(GLuint index, const GLfloat * v); -extern HIDDEN void __indirect_glVertexAttrib1sARB(GLuint index, GLshort x); -extern HIDDEN void __indirect_glVertexAttrib1svARB(GLuint index, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttrib2dARB(GLuint index, GLdouble x, GLdouble y); -extern HIDDEN void __indirect_glVertexAttrib2dvARB(GLuint index, const GLdouble * v); -extern HIDDEN void __indirect_glVertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y); -extern HIDDEN void __indirect_glVertexAttrib2fvARB(GLuint index, const GLfloat * v); -extern HIDDEN void __indirect_glVertexAttrib2sARB(GLuint index, GLshort x, GLshort y); -extern HIDDEN void __indirect_glVertexAttrib2svARB(GLuint index, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttrib3dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z); -extern HIDDEN void __indirect_glVertexAttrib3dvARB(GLuint index, const GLdouble * v); -extern HIDDEN void __indirect_glVertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z); -extern HIDDEN void __indirect_glVertexAttrib3fvARB(GLuint index, const GLfloat * v); -extern HIDDEN void __indirect_glVertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z); -extern HIDDEN void __indirect_glVertexAttrib3svARB(GLuint index, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttrib4NbvARB(GLuint index, const GLbyte * v); -extern HIDDEN void __indirect_glVertexAttrib4NivARB(GLuint index, const GLint * v); -extern HIDDEN void __indirect_glVertexAttrib4NsvARB(GLuint index, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -extern HIDDEN void __indirect_glVertexAttrib4NubvARB(GLuint index, const GLubyte * v); -extern HIDDEN void __indirect_glVertexAttrib4NuivARB(GLuint index, const GLuint * v); -extern HIDDEN void __indirect_glVertexAttrib4NusvARB(GLuint index, const GLushort * v); -extern HIDDEN void __indirect_glVertexAttrib4bvARB(GLuint index, const GLbyte * v); -extern HIDDEN void __indirect_glVertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -extern HIDDEN void __indirect_glVertexAttrib4dvARB(GLuint index, const GLdouble * v); -extern HIDDEN void __indirect_glVertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -extern HIDDEN void __indirect_glVertexAttrib4fvARB(GLuint index, const GLfloat * v); -extern HIDDEN void __indirect_glVertexAttrib4ivARB(GLuint index, const GLint * v); -extern HIDDEN void __indirect_glVertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -extern HIDDEN void __indirect_glVertexAttrib4svARB(GLuint index, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttrib4ubvARB(GLuint index, const GLubyte * v); -extern HIDDEN void __indirect_glVertexAttrib4uivARB(GLuint index, const GLuint * v); -extern HIDDEN void __indirect_glVertexAttrib4usvARB(GLuint index, const GLushort * v); -extern HIDDEN void __indirect_glVertexAttribPointerARB(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer); -extern HIDDEN void __indirect_glBeginQueryARB(GLenum target, GLuint id); -extern HIDDEN void __indirect_glDeleteQueriesARB(GLsizei n, const GLuint * ids); -extern HIDDEN void __indirect_glEndQueryARB(GLenum target); -extern HIDDEN void __indirect_glGenQueriesARB(GLsizei n, GLuint * ids); -extern HIDDEN void __indirect_glGetQueryObjectivARB(GLuint id, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint * params); -extern HIDDEN void __indirect_glGetQueryivARB(GLenum target, GLenum pname, GLint * params); -extern HIDDEN GLboolean __indirect_glIsQueryARB(GLuint id); -extern HIDDEN void __indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs); -extern HIDDEN void __indirect_glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -extern HIDDEN void __indirect_glSampleMaskSGIS(GLclampf value, GLboolean invert); -extern HIDDEN void __indirect_glSamplePatternSGIS(GLenum pattern); -extern HIDDEN void __indirect_glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); -extern HIDDEN void __indirect_glEdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean * pointer); -extern HIDDEN void __indirect_glIndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); -extern HIDDEN void __indirect_glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); -extern HIDDEN void __indirect_glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); -extern HIDDEN void __indirect_glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); -extern HIDDEN void __indirect_glPointParameterfEXT(GLenum pname, GLfloat param); -extern HIDDEN void __indirect_glPointParameterfvEXT(GLenum pname, const GLfloat * params); -extern HIDDEN void __indirect_glSecondaryColor3bEXT(GLbyte red, GLbyte green, GLbyte blue); -extern HIDDEN void __indirect_glSecondaryColor3bvEXT(const GLbyte * v); -extern HIDDEN void __indirect_glSecondaryColor3dEXT(GLdouble red, GLdouble green, GLdouble blue); -extern HIDDEN void __indirect_glSecondaryColor3dvEXT(const GLdouble * v); -extern HIDDEN void __indirect_glSecondaryColor3fEXT(GLfloat red, GLfloat green, GLfloat blue); -extern HIDDEN void __indirect_glSecondaryColor3fvEXT(const GLfloat * v); -extern HIDDEN void __indirect_glSecondaryColor3iEXT(GLint red, GLint green, GLint blue); -extern HIDDEN void __indirect_glSecondaryColor3ivEXT(const GLint * v); -extern HIDDEN void __indirect_glSecondaryColor3sEXT(GLshort red, GLshort green, GLshort blue); -extern HIDDEN void __indirect_glSecondaryColor3svEXT(const GLshort * v); -extern HIDDEN void __indirect_glSecondaryColor3ubEXT(GLubyte red, GLubyte green, GLubyte blue); -extern HIDDEN void __indirect_glSecondaryColor3ubvEXT(const GLubyte * v); -extern HIDDEN void __indirect_glSecondaryColor3uiEXT(GLuint red, GLuint green, GLuint blue); -extern HIDDEN void __indirect_glSecondaryColor3uivEXT(const GLuint * v); -extern HIDDEN void __indirect_glSecondaryColor3usEXT(GLushort red, GLushort green, GLushort blue); -extern HIDDEN void __indirect_glSecondaryColor3usvEXT(const GLushort * v); -extern HIDDEN void __indirect_glSecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); -extern HIDDEN void __indirect_glMultiDrawArraysEXT(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount); -extern HIDDEN void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount); -extern HIDDEN void __indirect_glFogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid * pointer); -extern HIDDEN void __indirect_glFogCoorddEXT(GLdouble coord); -extern HIDDEN void __indirect_glFogCoorddvEXT(const GLdouble * coord); -extern HIDDEN void __indirect_glFogCoordfEXT(GLfloat coord); -extern HIDDEN void __indirect_glFogCoordfvEXT(const GLfloat * coord); -extern HIDDEN void __indirect_glBlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -extern HIDDEN void __indirect_glWindowPos2dMESA(GLdouble x, GLdouble y); -extern HIDDEN void __indirect_glWindowPos2dvMESA(const GLdouble * v); -extern HIDDEN void __indirect_glWindowPos2fMESA(GLfloat x, GLfloat y); -extern HIDDEN void __indirect_glWindowPos2fvMESA(const GLfloat * v); -extern HIDDEN void __indirect_glWindowPos2iMESA(GLint x, GLint y); -extern HIDDEN void __indirect_glWindowPos2ivMESA(const GLint * v); -extern HIDDEN void __indirect_glWindowPos2sMESA(GLshort x, GLshort y); -extern HIDDEN void __indirect_glWindowPos2svMESA(const GLshort * v); -extern HIDDEN void __indirect_glWindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z); -extern HIDDEN void __indirect_glWindowPos3dvMESA(const GLdouble * v); -extern HIDDEN void __indirect_glWindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z); -extern HIDDEN void __indirect_glWindowPos3fvMESA(const GLfloat * v); -extern HIDDEN void __indirect_glWindowPos3iMESA(GLint x, GLint y, GLint z); -extern HIDDEN void __indirect_glWindowPos3ivMESA(const GLint * v); -extern HIDDEN void __indirect_glWindowPos3sMESA(GLshort x, GLshort y, GLshort z); -extern HIDDEN void __indirect_glWindowPos3svMESA(const GLshort * v); -extern HIDDEN GLboolean __indirect_glAreProgramsResidentNV(GLsizei n, const GLuint * ids, GLboolean * residences); -extern HIDDEN void __indirect_glBindProgramNV(GLenum target, GLuint program); -extern HIDDEN void __indirect_glDeleteProgramsNV(GLsizei n, const GLuint * programs); -extern HIDDEN void __indirect_glExecuteProgramNV(GLenum target, GLuint id, const GLfloat * params); -extern HIDDEN void __indirect_glGenProgramsNV(GLsizei n, GLuint * programs); -extern HIDDEN void __indirect_glGetProgramParameterdvNV(GLenum target, GLuint index, GLenum pname, GLdouble * params); -extern HIDDEN void __indirect_glGetProgramParameterfvNV(GLenum target, GLuint index, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetProgramStringNV(GLuint id, GLenum pname, GLubyte * program); -extern HIDDEN void __indirect_glGetProgramivNV(GLuint id, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid ** pointer); -extern HIDDEN void __indirect_glGetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble * params); -extern HIDDEN void __indirect_glGetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat * params); -extern HIDDEN void __indirect_glGetVertexAttribivNV(GLuint index, GLenum pname, GLint * params); -extern HIDDEN GLboolean __indirect_glIsProgramNV(GLuint program); -extern HIDDEN void __indirect_glLoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte * program); -extern HIDDEN void __indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble * params); -extern HIDDEN void __indirect_glProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, const GLfloat * params); -extern HIDDEN void __indirect_glRequestResidentProgramsNV(GLsizei n, const GLuint * ids); -extern HIDDEN void __indirect_glTrackMatrixNV(GLenum target, GLuint address, GLenum matrix, GLenum transform); -extern HIDDEN void __indirect_glVertexAttrib1dNV(GLuint index, GLdouble x); -extern HIDDEN void __indirect_glVertexAttrib1dvNV(GLuint index, const GLdouble * v); -extern HIDDEN void __indirect_glVertexAttrib1fNV(GLuint index, GLfloat x); -extern HIDDEN void __indirect_glVertexAttrib1fvNV(GLuint index, const GLfloat * v); -extern HIDDEN void __indirect_glVertexAttrib1sNV(GLuint index, GLshort x); -extern HIDDEN void __indirect_glVertexAttrib1svNV(GLuint index, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttrib2dNV(GLuint index, GLdouble x, GLdouble y); -extern HIDDEN void __indirect_glVertexAttrib2dvNV(GLuint index, const GLdouble * v); -extern HIDDEN void __indirect_glVertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y); -extern HIDDEN void __indirect_glVertexAttrib2fvNV(GLuint index, const GLfloat * v); -extern HIDDEN void __indirect_glVertexAttrib2sNV(GLuint index, GLshort x, GLshort y); -extern HIDDEN void __indirect_glVertexAttrib2svNV(GLuint index, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttrib3dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z); -extern HIDDEN void __indirect_glVertexAttrib3dvNV(GLuint index, const GLdouble * v); -extern HIDDEN void __indirect_glVertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z); -extern HIDDEN void __indirect_glVertexAttrib3fvNV(GLuint index, const GLfloat * v); -extern HIDDEN void __indirect_glVertexAttrib3sNV(GLuint index, GLshort x, GLshort y, GLshort z); -extern HIDDEN void __indirect_glVertexAttrib3svNV(GLuint index, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttrib4dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -extern HIDDEN void __indirect_glVertexAttrib4dvNV(GLuint index, const GLdouble * v); -extern HIDDEN void __indirect_glVertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -extern HIDDEN void __indirect_glVertexAttrib4fvNV(GLuint index, const GLfloat * v); -extern HIDDEN void __indirect_glVertexAttrib4sNV(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -extern HIDDEN void __indirect_glVertexAttrib4svNV(GLuint index, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttrib4ubNV(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -extern HIDDEN void __indirect_glVertexAttrib4ubvNV(GLuint index, const GLubyte * v); -extern HIDDEN void __indirect_glVertexAttribPointerNV(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); -extern HIDDEN void __indirect_glVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble * v); -extern HIDDEN void __indirect_glVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat * v); -extern HIDDEN void __indirect_glVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v); -extern HIDDEN void __indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v); -extern HIDDEN void __indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v); -extern HIDDEN void __indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v); -extern HIDDEN void __indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v); -extern HIDDEN void __indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v); -extern HIDDEN void __indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v); -extern HIDDEN void __indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte * v); -extern HIDDEN void __indirect_glPointParameteriNV(GLenum pname, GLint param); -extern HIDDEN void __indirect_glPointParameterivNV(GLenum pname, const GLint * params); -extern HIDDEN void __indirect_glActiveStencilFaceEXT(GLenum face); -extern HIDDEN void __indirect_glGetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble * params); -extern HIDDEN void __indirect_glGetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat * params); -extern HIDDEN void __indirect_glProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -extern HIDDEN void __indirect_glProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v); -extern HIDDEN void __indirect_glProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -extern HIDDEN void __indirect_glProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v); -extern HIDDEN void __indirect_glBlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA); -extern HIDDEN void __indirect_glBindFramebufferEXT(GLenum target, GLuint framebuffer); -extern HIDDEN void __indirect_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer); -extern HIDDEN GLenum __indirect_glCheckFramebufferStatusEXT(GLenum target); -extern HIDDEN void __indirect_glDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers); -extern HIDDEN void __indirect_glDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers); -extern HIDDEN void __indirect_glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -extern HIDDEN void __indirect_glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -extern HIDDEN void __indirect_glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -extern HIDDEN void __indirect_glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -extern HIDDEN void __indirect_glGenFramebuffersEXT(GLsizei n, GLuint * framebuffers); -extern HIDDEN void __indirect_glGenRenderbuffersEXT(GLsizei n, GLuint * renderbuffers); -extern HIDDEN void __indirect_glGenerateMipmapEXT(GLenum target); -extern HIDDEN void __indirect_glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint * params); -extern HIDDEN void __indirect_glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint * params); -extern HIDDEN GLboolean __indirect_glIsFramebufferEXT(GLuint framebuffer); -extern HIDDEN GLboolean __indirect_glIsRenderbufferEXT(GLuint renderbuffer); -extern HIDDEN void __indirect_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -extern HIDDEN void __indirect_glBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -extern HIDDEN void __indirect_glFramebufferTextureLayerEXT(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); - -# undef HIDDEN -# undef FASTCALL -# undef NOINLINE - -#endif /* !defined( _INDIRECT_H_ ) */ diff --git a/src/glx/x11/indirect_init.c b/src/glx/x11/indirect_init.c deleted file mode 100644 index 73ca993027b..00000000000 --- a/src/glx/x11/indirect_init.c +++ /dev/null @@ -1,785 +0,0 @@ -/* DO NOT EDIT - This file generated automatically by glX_proto_send.py (from Mesa) script */ - -/* - * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - * (C) Copyright IBM Corporation 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT, IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/** - * \file indirect_init.c - * Initialize indirect rendering dispatch table. - * - * \author Kevin E. Martin - * \author Brian Paul - * \author Ian Romanick - */ - -#include "indirect_init.h" -#include "indirect.h" -#include "glapi.h" - - -/** - * No-op function used to initialize functions that have no GLX protocol - * support. - */ -static int NoOp(void) -{ - return 0; -} - -/** - * Create and initialize a new GL dispatch table. The table is initialized - * with GLX indirect rendering protocol functions. - */ -__GLapi * __glXNewIndirectAPI( void ) -{ - __GLapi *glAPI; - GLuint entries; - - entries = _glapi_get_dispatch_table_size(); - glAPI = (__GLapi *) Xmalloc(entries * sizeof(void *)); - - /* first, set all entries to point to no-op functions */ - { - int i; - void **dispatch = (void **) glAPI; - for (i = 0; i < entries; i++) { - dispatch[i] = (void *) NoOp; - } - } - - /* now, initialize the entries we understand */ - - /* 1.0 */ - - glAPI->Accum = __indirect_glAccum; - glAPI->AlphaFunc = __indirect_glAlphaFunc; - glAPI->Begin = __indirect_glBegin; - glAPI->Bitmap = __indirect_glBitmap; - glAPI->BlendFunc = __indirect_glBlendFunc; - glAPI->CallList = __indirect_glCallList; - glAPI->CallLists = __indirect_glCallLists; - glAPI->Clear = __indirect_glClear; - glAPI->ClearAccum = __indirect_glClearAccum; - glAPI->ClearColor = __indirect_glClearColor; - glAPI->ClearDepth = __indirect_glClearDepth; - glAPI->ClearIndex = __indirect_glClearIndex; - glAPI->ClearStencil = __indirect_glClearStencil; - glAPI->ClipPlane = __indirect_glClipPlane; - glAPI->Color3b = __indirect_glColor3b; - glAPI->Color3bv = __indirect_glColor3bv; - glAPI->Color3d = __indirect_glColor3d; - glAPI->Color3dv = __indirect_glColor3dv; - glAPI->Color3f = __indirect_glColor3f; - glAPI->Color3fv = __indirect_glColor3fv; - glAPI->Color3i = __indirect_glColor3i; - glAPI->Color3iv = __indirect_glColor3iv; - glAPI->Color3s = __indirect_glColor3s; - glAPI->Color3sv = __indirect_glColor3sv; - glAPI->Color3ub = __indirect_glColor3ub; - glAPI->Color3ubv = __indirect_glColor3ubv; - glAPI->Color3ui = __indirect_glColor3ui; - glAPI->Color3uiv = __indirect_glColor3uiv; - glAPI->Color3us = __indirect_glColor3us; - glAPI->Color3usv = __indirect_glColor3usv; - glAPI->Color4b = __indirect_glColor4b; - glAPI->Color4bv = __indirect_glColor4bv; - glAPI->Color4d = __indirect_glColor4d; - glAPI->Color4dv = __indirect_glColor4dv; - glAPI->Color4f = __indirect_glColor4f; - glAPI->Color4fv = __indirect_glColor4fv; - glAPI->Color4i = __indirect_glColor4i; - glAPI->Color4iv = __indirect_glColor4iv; - glAPI->Color4s = __indirect_glColor4s; - glAPI->Color4sv = __indirect_glColor4sv; - glAPI->Color4ub = __indirect_glColor4ub; - glAPI->Color4ubv = __indirect_glColor4ubv; - glAPI->Color4ui = __indirect_glColor4ui; - glAPI->Color4uiv = __indirect_glColor4uiv; - glAPI->Color4us = __indirect_glColor4us; - glAPI->Color4usv = __indirect_glColor4usv; - glAPI->ColorMask = __indirect_glColorMask; - glAPI->ColorMaterial = __indirect_glColorMaterial; - glAPI->CopyPixels = __indirect_glCopyPixels; - glAPI->CullFace = __indirect_glCullFace; - glAPI->DeleteLists = __indirect_glDeleteLists; - glAPI->DepthFunc = __indirect_glDepthFunc; - glAPI->DepthMask = __indirect_glDepthMask; - glAPI->DepthRange = __indirect_glDepthRange; - glAPI->Disable = __indirect_glDisable; - glAPI->DrawBuffer = __indirect_glDrawBuffer; - glAPI->DrawPixels = __indirect_glDrawPixels; - glAPI->EdgeFlag = __indirect_glEdgeFlag; - glAPI->EdgeFlagv = __indirect_glEdgeFlagv; - glAPI->Enable = __indirect_glEnable; - glAPI->End = __indirect_glEnd; - glAPI->EndList = __indirect_glEndList; - glAPI->EvalCoord1d = __indirect_glEvalCoord1d; - glAPI->EvalCoord1dv = __indirect_glEvalCoord1dv; - glAPI->EvalCoord1f = __indirect_glEvalCoord1f; - glAPI->EvalCoord1fv = __indirect_glEvalCoord1fv; - glAPI->EvalCoord2d = __indirect_glEvalCoord2d; - glAPI->EvalCoord2dv = __indirect_glEvalCoord2dv; - glAPI->EvalCoord2f = __indirect_glEvalCoord2f; - glAPI->EvalCoord2fv = __indirect_glEvalCoord2fv; - glAPI->EvalMesh1 = __indirect_glEvalMesh1; - glAPI->EvalMesh2 = __indirect_glEvalMesh2; - glAPI->EvalPoint1 = __indirect_glEvalPoint1; - glAPI->EvalPoint2 = __indirect_glEvalPoint2; - glAPI->FeedbackBuffer = __indirect_glFeedbackBuffer; - glAPI->Finish = __indirect_glFinish; - glAPI->Flush = __indirect_glFlush; - glAPI->Fogf = __indirect_glFogf; - glAPI->Fogfv = __indirect_glFogfv; - glAPI->Fogi = __indirect_glFogi; - glAPI->Fogiv = __indirect_glFogiv; - glAPI->FrontFace = __indirect_glFrontFace; - glAPI->Frustum = __indirect_glFrustum; - glAPI->GenLists = __indirect_glGenLists; - glAPI->GetBooleanv = __indirect_glGetBooleanv; - glAPI->GetClipPlane = __indirect_glGetClipPlane; - glAPI->GetDoublev = __indirect_glGetDoublev; - glAPI->GetError = __indirect_glGetError; - glAPI->GetFloatv = __indirect_glGetFloatv; - glAPI->GetIntegerv = __indirect_glGetIntegerv; - glAPI->GetLightfv = __indirect_glGetLightfv; - glAPI->GetLightiv = __indirect_glGetLightiv; - glAPI->GetMapdv = __indirect_glGetMapdv; - glAPI->GetMapfv = __indirect_glGetMapfv; - glAPI->GetMapiv = __indirect_glGetMapiv; - glAPI->GetMaterialfv = __indirect_glGetMaterialfv; - glAPI->GetMaterialiv = __indirect_glGetMaterialiv; - glAPI->GetPixelMapfv = __indirect_glGetPixelMapfv; - glAPI->GetPixelMapuiv = __indirect_glGetPixelMapuiv; - glAPI->GetPixelMapusv = __indirect_glGetPixelMapusv; - glAPI->GetPolygonStipple = __indirect_glGetPolygonStipple; - glAPI->GetString = __indirect_glGetString; - glAPI->GetTexEnvfv = __indirect_glGetTexEnvfv; - glAPI->GetTexEnviv = __indirect_glGetTexEnviv; - glAPI->GetTexGendv = __indirect_glGetTexGendv; - glAPI->GetTexGenfv = __indirect_glGetTexGenfv; - glAPI->GetTexGeniv = __indirect_glGetTexGeniv; - glAPI->GetTexImage = __indirect_glGetTexImage; - glAPI->GetTexLevelParameterfv = __indirect_glGetTexLevelParameterfv; - glAPI->GetTexLevelParameteriv = __indirect_glGetTexLevelParameteriv; - glAPI->GetTexParameterfv = __indirect_glGetTexParameterfv; - glAPI->GetTexParameteriv = __indirect_glGetTexParameteriv; - glAPI->Hint = __indirect_glHint; - glAPI->IndexMask = __indirect_glIndexMask; - glAPI->Indexd = __indirect_glIndexd; - glAPI->Indexdv = __indirect_glIndexdv; - glAPI->Indexf = __indirect_glIndexf; - glAPI->Indexfv = __indirect_glIndexfv; - glAPI->Indexi = __indirect_glIndexi; - glAPI->Indexiv = __indirect_glIndexiv; - glAPI->Indexs = __indirect_glIndexs; - glAPI->Indexsv = __indirect_glIndexsv; - glAPI->InitNames = __indirect_glInitNames; - glAPI->IsEnabled = __indirect_glIsEnabled; - glAPI->IsList = __indirect_glIsList; - glAPI->LightModelf = __indirect_glLightModelf; - glAPI->LightModelfv = __indirect_glLightModelfv; - glAPI->LightModeli = __indirect_glLightModeli; - glAPI->LightModeliv = __indirect_glLightModeliv; - glAPI->Lightf = __indirect_glLightf; - glAPI->Lightfv = __indirect_glLightfv; - glAPI->Lighti = __indirect_glLighti; - glAPI->Lightiv = __indirect_glLightiv; - glAPI->LineStipple = __indirect_glLineStipple; - glAPI->LineWidth = __indirect_glLineWidth; - glAPI->ListBase = __indirect_glListBase; - glAPI->LoadIdentity = __indirect_glLoadIdentity; - glAPI->LoadMatrixd = __indirect_glLoadMatrixd; - glAPI->LoadMatrixf = __indirect_glLoadMatrixf; - glAPI->LoadName = __indirect_glLoadName; - glAPI->LogicOp = __indirect_glLogicOp; - glAPI->Map1d = __indirect_glMap1d; - glAPI->Map1f = __indirect_glMap1f; - glAPI->Map2d = __indirect_glMap2d; - glAPI->Map2f = __indirect_glMap2f; - glAPI->MapGrid1d = __indirect_glMapGrid1d; - glAPI->MapGrid1f = __indirect_glMapGrid1f; - glAPI->MapGrid2d = __indirect_glMapGrid2d; - glAPI->MapGrid2f = __indirect_glMapGrid2f; - glAPI->Materialf = __indirect_glMaterialf; - glAPI->Materialfv = __indirect_glMaterialfv; - glAPI->Materiali = __indirect_glMateriali; - glAPI->Materialiv = __indirect_glMaterialiv; - glAPI->MatrixMode = __indirect_glMatrixMode; - glAPI->MultMatrixd = __indirect_glMultMatrixd; - glAPI->MultMatrixf = __indirect_glMultMatrixf; - glAPI->NewList = __indirect_glNewList; - glAPI->Normal3b = __indirect_glNormal3b; - glAPI->Normal3bv = __indirect_glNormal3bv; - glAPI->Normal3d = __indirect_glNormal3d; - glAPI->Normal3dv = __indirect_glNormal3dv; - glAPI->Normal3f = __indirect_glNormal3f; - glAPI->Normal3fv = __indirect_glNormal3fv; - glAPI->Normal3i = __indirect_glNormal3i; - glAPI->Normal3iv = __indirect_glNormal3iv; - glAPI->Normal3s = __indirect_glNormal3s; - glAPI->Normal3sv = __indirect_glNormal3sv; - glAPI->Ortho = __indirect_glOrtho; - glAPI->PassThrough = __indirect_glPassThrough; - glAPI->PixelMapfv = __indirect_glPixelMapfv; - glAPI->PixelMapuiv = __indirect_glPixelMapuiv; - glAPI->PixelMapusv = __indirect_glPixelMapusv; - glAPI->PixelStoref = __indirect_glPixelStoref; - glAPI->PixelStorei = __indirect_glPixelStorei; - glAPI->PixelTransferf = __indirect_glPixelTransferf; - glAPI->PixelTransferi = __indirect_glPixelTransferi; - glAPI->PixelZoom = __indirect_glPixelZoom; - glAPI->PointSize = __indirect_glPointSize; - glAPI->PolygonMode = __indirect_glPolygonMode; - glAPI->PolygonStipple = __indirect_glPolygonStipple; - glAPI->PopAttrib = __indirect_glPopAttrib; - glAPI->PopMatrix = __indirect_glPopMatrix; - glAPI->PopName = __indirect_glPopName; - glAPI->PushAttrib = __indirect_glPushAttrib; - glAPI->PushMatrix = __indirect_glPushMatrix; - glAPI->PushName = __indirect_glPushName; - glAPI->RasterPos2d = __indirect_glRasterPos2d; - glAPI->RasterPos2dv = __indirect_glRasterPos2dv; - glAPI->RasterPos2f = __indirect_glRasterPos2f; - glAPI->RasterPos2fv = __indirect_glRasterPos2fv; - glAPI->RasterPos2i = __indirect_glRasterPos2i; - glAPI->RasterPos2iv = __indirect_glRasterPos2iv; - glAPI->RasterPos2s = __indirect_glRasterPos2s; - glAPI->RasterPos2sv = __indirect_glRasterPos2sv; - glAPI->RasterPos3d = __indirect_glRasterPos3d; - glAPI->RasterPos3dv = __indirect_glRasterPos3dv; - glAPI->RasterPos3f = __indirect_glRasterPos3f; - glAPI->RasterPos3fv = __indirect_glRasterPos3fv; - glAPI->RasterPos3i = __indirect_glRasterPos3i; - glAPI->RasterPos3iv = __indirect_glRasterPos3iv; - glAPI->RasterPos3s = __indirect_glRasterPos3s; - glAPI->RasterPos3sv = __indirect_glRasterPos3sv; - glAPI->RasterPos4d = __indirect_glRasterPos4d; - glAPI->RasterPos4dv = __indirect_glRasterPos4dv; - glAPI->RasterPos4f = __indirect_glRasterPos4f; - glAPI->RasterPos4fv = __indirect_glRasterPos4fv; - glAPI->RasterPos4i = __indirect_glRasterPos4i; - glAPI->RasterPos4iv = __indirect_glRasterPos4iv; - glAPI->RasterPos4s = __indirect_glRasterPos4s; - glAPI->RasterPos4sv = __indirect_glRasterPos4sv; - glAPI->ReadBuffer = __indirect_glReadBuffer; - glAPI->ReadPixels = __indirect_glReadPixels; - glAPI->Rectd = __indirect_glRectd; - glAPI->Rectdv = __indirect_glRectdv; - glAPI->Rectf = __indirect_glRectf; - glAPI->Rectfv = __indirect_glRectfv; - glAPI->Recti = __indirect_glRecti; - glAPI->Rectiv = __indirect_glRectiv; - glAPI->Rects = __indirect_glRects; - glAPI->Rectsv = __indirect_glRectsv; - glAPI->RenderMode = __indirect_glRenderMode; - glAPI->Rotated = __indirect_glRotated; - glAPI->Rotatef = __indirect_glRotatef; - glAPI->Scaled = __indirect_glScaled; - glAPI->Scalef = __indirect_glScalef; - glAPI->Scissor = __indirect_glScissor; - glAPI->SelectBuffer = __indirect_glSelectBuffer; - glAPI->ShadeModel = __indirect_glShadeModel; - glAPI->StencilFunc = __indirect_glStencilFunc; - glAPI->StencilMask = __indirect_glStencilMask; - glAPI->StencilOp = __indirect_glStencilOp; - glAPI->TexCoord1d = __indirect_glTexCoord1d; - glAPI->TexCoord1dv = __indirect_glTexCoord1dv; - glAPI->TexCoord1f = __indirect_glTexCoord1f; - glAPI->TexCoord1fv = __indirect_glTexCoord1fv; - glAPI->TexCoord1i = __indirect_glTexCoord1i; - glAPI->TexCoord1iv = __indirect_glTexCoord1iv; - glAPI->TexCoord1s = __indirect_glTexCoord1s; - glAPI->TexCoord1sv = __indirect_glTexCoord1sv; - glAPI->TexCoord2d = __indirect_glTexCoord2d; - glAPI->TexCoord2dv = __indirect_glTexCoord2dv; - glAPI->TexCoord2f = __indirect_glTexCoord2f; - glAPI->TexCoord2fv = __indirect_glTexCoord2fv; - glAPI->TexCoord2i = __indirect_glTexCoord2i; - glAPI->TexCoord2iv = __indirect_glTexCoord2iv; - glAPI->TexCoord2s = __indirect_glTexCoord2s; - glAPI->TexCoord2sv = __indirect_glTexCoord2sv; - glAPI->TexCoord3d = __indirect_glTexCoord3d; - glAPI->TexCoord3dv = __indirect_glTexCoord3dv; - glAPI->TexCoord3f = __indirect_glTexCoord3f; - glAPI->TexCoord3fv = __indirect_glTexCoord3fv; - glAPI->TexCoord3i = __indirect_glTexCoord3i; - glAPI->TexCoord3iv = __indirect_glTexCoord3iv; - glAPI->TexCoord3s = __indirect_glTexCoord3s; - glAPI->TexCoord3sv = __indirect_glTexCoord3sv; - glAPI->TexCoord4d = __indirect_glTexCoord4d; - glAPI->TexCoord4dv = __indirect_glTexCoord4dv; - glAPI->TexCoord4f = __indirect_glTexCoord4f; - glAPI->TexCoord4fv = __indirect_glTexCoord4fv; - glAPI->TexCoord4i = __indirect_glTexCoord4i; - glAPI->TexCoord4iv = __indirect_glTexCoord4iv; - glAPI->TexCoord4s = __indirect_glTexCoord4s; - glAPI->TexCoord4sv = __indirect_glTexCoord4sv; - glAPI->TexEnvf = __indirect_glTexEnvf; - glAPI->TexEnvfv = __indirect_glTexEnvfv; - glAPI->TexEnvi = __indirect_glTexEnvi; - glAPI->TexEnviv = __indirect_glTexEnviv; - glAPI->TexGend = __indirect_glTexGend; - glAPI->TexGendv = __indirect_glTexGendv; - glAPI->TexGenf = __indirect_glTexGenf; - glAPI->TexGenfv = __indirect_glTexGenfv; - glAPI->TexGeni = __indirect_glTexGeni; - glAPI->TexGeniv = __indirect_glTexGeniv; - glAPI->TexImage1D = __indirect_glTexImage1D; - glAPI->TexImage2D = __indirect_glTexImage2D; - glAPI->TexParameterf = __indirect_glTexParameterf; - glAPI->TexParameterfv = __indirect_glTexParameterfv; - glAPI->TexParameteri = __indirect_glTexParameteri; - glAPI->TexParameteriv = __indirect_glTexParameteriv; - glAPI->Translated = __indirect_glTranslated; - glAPI->Translatef = __indirect_glTranslatef; - glAPI->Vertex2d = __indirect_glVertex2d; - glAPI->Vertex2dv = __indirect_glVertex2dv; - glAPI->Vertex2f = __indirect_glVertex2f; - glAPI->Vertex2fv = __indirect_glVertex2fv; - glAPI->Vertex2i = __indirect_glVertex2i; - glAPI->Vertex2iv = __indirect_glVertex2iv; - glAPI->Vertex2s = __indirect_glVertex2s; - glAPI->Vertex2sv = __indirect_glVertex2sv; - glAPI->Vertex3d = __indirect_glVertex3d; - glAPI->Vertex3dv = __indirect_glVertex3dv; - glAPI->Vertex3f = __indirect_glVertex3f; - glAPI->Vertex3fv = __indirect_glVertex3fv; - glAPI->Vertex3i = __indirect_glVertex3i; - glAPI->Vertex3iv = __indirect_glVertex3iv; - glAPI->Vertex3s = __indirect_glVertex3s; - glAPI->Vertex3sv = __indirect_glVertex3sv; - glAPI->Vertex4d = __indirect_glVertex4d; - glAPI->Vertex4dv = __indirect_glVertex4dv; - glAPI->Vertex4f = __indirect_glVertex4f; - glAPI->Vertex4fv = __indirect_glVertex4fv; - glAPI->Vertex4i = __indirect_glVertex4i; - glAPI->Vertex4iv = __indirect_glVertex4iv; - glAPI->Vertex4s = __indirect_glVertex4s; - glAPI->Vertex4sv = __indirect_glVertex4sv; - glAPI->Viewport = __indirect_glViewport; - - /* 1.1 */ - - glAPI->AreTexturesResident = __indirect_glAreTexturesResident; - glAPI->ArrayElement = __indirect_glArrayElement; - glAPI->BindTexture = __indirect_glBindTexture; - glAPI->ColorPointer = __indirect_glColorPointer; - glAPI->CopyTexImage1D = __indirect_glCopyTexImage1D; - glAPI->CopyTexImage2D = __indirect_glCopyTexImage2D; - glAPI->CopyTexSubImage1D = __indirect_glCopyTexSubImage1D; - glAPI->CopyTexSubImage2D = __indirect_glCopyTexSubImage2D; - glAPI->DeleteTextures = __indirect_glDeleteTextures; - glAPI->DisableClientState = __indirect_glDisableClientState; - glAPI->DrawArrays = __indirect_glDrawArrays; - glAPI->DrawElements = __indirect_glDrawElements; - glAPI->EdgeFlagPointer = __indirect_glEdgeFlagPointer; - glAPI->EnableClientState = __indirect_glEnableClientState; - glAPI->GenTextures = __indirect_glGenTextures; - glAPI->GetPointerv = __indirect_glGetPointerv; - glAPI->IndexPointer = __indirect_glIndexPointer; - glAPI->Indexub = __indirect_glIndexub; - glAPI->Indexubv = __indirect_glIndexubv; - glAPI->InterleavedArrays = __indirect_glInterleavedArrays; - glAPI->IsTexture = __indirect_glIsTexture; - glAPI->NormalPointer = __indirect_glNormalPointer; - glAPI->PolygonOffset = __indirect_glPolygonOffset; - glAPI->PopClientAttrib = __indirect_glPopClientAttrib; - glAPI->PrioritizeTextures = __indirect_glPrioritizeTextures; - glAPI->PushClientAttrib = __indirect_glPushClientAttrib; - glAPI->TexCoordPointer = __indirect_glTexCoordPointer; - glAPI->TexSubImage1D = __indirect_glTexSubImage1D; - glAPI->TexSubImage2D = __indirect_glTexSubImage2D; - glAPI->VertexPointer = __indirect_glVertexPointer; - - /* 1.2 */ - - glAPI->BlendColor = __indirect_glBlendColor; - glAPI->BlendEquation = __indirect_glBlendEquation; - glAPI->ColorSubTable = __indirect_glColorSubTable; - glAPI->ColorTable = __indirect_glColorTable; - glAPI->ColorTableParameterfv = __indirect_glColorTableParameterfv; - glAPI->ColorTableParameteriv = __indirect_glColorTableParameteriv; - glAPI->ConvolutionFilter1D = __indirect_glConvolutionFilter1D; - glAPI->ConvolutionFilter2D = __indirect_glConvolutionFilter2D; - glAPI->ConvolutionParameterf = __indirect_glConvolutionParameterf; - glAPI->ConvolutionParameterfv = __indirect_glConvolutionParameterfv; - glAPI->ConvolutionParameteri = __indirect_glConvolutionParameteri; - glAPI->ConvolutionParameteriv = __indirect_glConvolutionParameteriv; - glAPI->CopyColorSubTable = __indirect_glCopyColorSubTable; - glAPI->CopyColorTable = __indirect_glCopyColorTable; - glAPI->CopyConvolutionFilter1D = __indirect_glCopyConvolutionFilter1D; - glAPI->CopyConvolutionFilter2D = __indirect_glCopyConvolutionFilter2D; - glAPI->CopyTexSubImage3D = __indirect_glCopyTexSubImage3D; - glAPI->DrawRangeElements = __indirect_glDrawRangeElements; - glAPI->GetColorTable = __indirect_glGetColorTable; - glAPI->GetColorTableParameterfv = __indirect_glGetColorTableParameterfv; - glAPI->GetColorTableParameteriv = __indirect_glGetColorTableParameteriv; - glAPI->GetConvolutionFilter = __indirect_glGetConvolutionFilter; - glAPI->GetConvolutionParameterfv = __indirect_glGetConvolutionParameterfv; - glAPI->GetConvolutionParameteriv = __indirect_glGetConvolutionParameteriv; - glAPI->GetHistogram = __indirect_glGetHistogram; - glAPI->GetHistogramParameterfv = __indirect_glGetHistogramParameterfv; - glAPI->GetHistogramParameteriv = __indirect_glGetHistogramParameteriv; - glAPI->GetMinmax = __indirect_glGetMinmax; - glAPI->GetMinmaxParameterfv = __indirect_glGetMinmaxParameterfv; - glAPI->GetMinmaxParameteriv = __indirect_glGetMinmaxParameteriv; - glAPI->GetSeparableFilter = __indirect_glGetSeparableFilter; - glAPI->Histogram = __indirect_glHistogram; - glAPI->Minmax = __indirect_glMinmax; - glAPI->ResetHistogram = __indirect_glResetHistogram; - glAPI->ResetMinmax = __indirect_glResetMinmax; - glAPI->SeparableFilter2D = __indirect_glSeparableFilter2D; - glAPI->TexImage3D = __indirect_glTexImage3D; - glAPI->TexSubImage3D = __indirect_glTexSubImage3D; - - /* 1. GL_ARB_multitexture */ - - glAPI->ActiveTextureARB = __indirect_glActiveTextureARB; - glAPI->ClientActiveTextureARB = __indirect_glClientActiveTextureARB; - glAPI->MultiTexCoord1dARB = __indirect_glMultiTexCoord1dARB; - glAPI->MultiTexCoord1dvARB = __indirect_glMultiTexCoord1dvARB; - glAPI->MultiTexCoord1fARB = __indirect_glMultiTexCoord1fARB; - glAPI->MultiTexCoord1fvARB = __indirect_glMultiTexCoord1fvARB; - glAPI->MultiTexCoord1iARB = __indirect_glMultiTexCoord1iARB; - glAPI->MultiTexCoord1ivARB = __indirect_glMultiTexCoord1ivARB; - glAPI->MultiTexCoord1sARB = __indirect_glMultiTexCoord1sARB; - glAPI->MultiTexCoord1svARB = __indirect_glMultiTexCoord1svARB; - glAPI->MultiTexCoord2dARB = __indirect_glMultiTexCoord2dARB; - glAPI->MultiTexCoord2dvARB = __indirect_glMultiTexCoord2dvARB; - glAPI->MultiTexCoord2fARB = __indirect_glMultiTexCoord2fARB; - glAPI->MultiTexCoord2fvARB = __indirect_glMultiTexCoord2fvARB; - glAPI->MultiTexCoord2iARB = __indirect_glMultiTexCoord2iARB; - glAPI->MultiTexCoord2ivARB = __indirect_glMultiTexCoord2ivARB; - glAPI->MultiTexCoord2sARB = __indirect_glMultiTexCoord2sARB; - glAPI->MultiTexCoord2svARB = __indirect_glMultiTexCoord2svARB; - glAPI->MultiTexCoord3dARB = __indirect_glMultiTexCoord3dARB; - glAPI->MultiTexCoord3dvARB = __indirect_glMultiTexCoord3dvARB; - glAPI->MultiTexCoord3fARB = __indirect_glMultiTexCoord3fARB; - glAPI->MultiTexCoord3fvARB = __indirect_glMultiTexCoord3fvARB; - glAPI->MultiTexCoord3iARB = __indirect_glMultiTexCoord3iARB; - glAPI->MultiTexCoord3ivARB = __indirect_glMultiTexCoord3ivARB; - glAPI->MultiTexCoord3sARB = __indirect_glMultiTexCoord3sARB; - glAPI->MultiTexCoord3svARB = __indirect_glMultiTexCoord3svARB; - glAPI->MultiTexCoord4dARB = __indirect_glMultiTexCoord4dARB; - glAPI->MultiTexCoord4dvARB = __indirect_glMultiTexCoord4dvARB; - glAPI->MultiTexCoord4fARB = __indirect_glMultiTexCoord4fARB; - glAPI->MultiTexCoord4fvARB = __indirect_glMultiTexCoord4fvARB; - glAPI->MultiTexCoord4iARB = __indirect_glMultiTexCoord4iARB; - glAPI->MultiTexCoord4ivARB = __indirect_glMultiTexCoord4ivARB; - glAPI->MultiTexCoord4sARB = __indirect_glMultiTexCoord4sARB; - glAPI->MultiTexCoord4svARB = __indirect_glMultiTexCoord4svARB; - - /* 3. GL_ARB_transpose_matrix */ - - glAPI->LoadTransposeMatrixdARB = __indirect_glLoadTransposeMatrixdARB; - glAPI->LoadTransposeMatrixfARB = __indirect_glLoadTransposeMatrixfARB; - glAPI->MultTransposeMatrixdARB = __indirect_glMultTransposeMatrixdARB; - glAPI->MultTransposeMatrixfARB = __indirect_glMultTransposeMatrixfARB; - - /* 5. GL_ARB_multisample */ - - glAPI->SampleCoverageARB = __indirect_glSampleCoverageARB; - - /* 12. GL_ARB_texture_compression */ - - glAPI->CompressedTexImage1DARB = __indirect_glCompressedTexImage1DARB; - glAPI->CompressedTexImage2DARB = __indirect_glCompressedTexImage2DARB; - glAPI->CompressedTexImage3DARB = __indirect_glCompressedTexImage3DARB; - glAPI->CompressedTexSubImage1DARB = __indirect_glCompressedTexSubImage1DARB; - glAPI->CompressedTexSubImage2DARB = __indirect_glCompressedTexSubImage2DARB; - glAPI->CompressedTexSubImage3DARB = __indirect_glCompressedTexSubImage3DARB; - glAPI->GetCompressedTexImageARB = __indirect_glGetCompressedTexImageARB; - - /* 26. GL_ARB_vertex_program */ - - glAPI->DisableVertexAttribArrayARB = __indirect_glDisableVertexAttribArrayARB; - glAPI->EnableVertexAttribArrayARB = __indirect_glEnableVertexAttribArrayARB; - glAPI->GetProgramEnvParameterdvARB = __indirect_glGetProgramEnvParameterdvARB; - glAPI->GetProgramEnvParameterfvARB = __indirect_glGetProgramEnvParameterfvARB; - glAPI->GetProgramLocalParameterdvARB = __indirect_glGetProgramLocalParameterdvARB; - glAPI->GetProgramLocalParameterfvARB = __indirect_glGetProgramLocalParameterfvARB; - glAPI->GetProgramStringARB = __indirect_glGetProgramStringARB; - glAPI->GetProgramivARB = __indirect_glGetProgramivARB; - glAPI->GetVertexAttribdvARB = __indirect_glGetVertexAttribdvARB; - glAPI->GetVertexAttribfvARB = __indirect_glGetVertexAttribfvARB; - glAPI->GetVertexAttribivARB = __indirect_glGetVertexAttribivARB; - glAPI->ProgramEnvParameter4dARB = __indirect_glProgramEnvParameter4dARB; - glAPI->ProgramEnvParameter4dvARB = __indirect_glProgramEnvParameter4dvARB; - glAPI->ProgramEnvParameter4fARB = __indirect_glProgramEnvParameter4fARB; - glAPI->ProgramEnvParameter4fvARB = __indirect_glProgramEnvParameter4fvARB; - glAPI->ProgramLocalParameter4dARB = __indirect_glProgramLocalParameter4dARB; - glAPI->ProgramLocalParameter4dvARB = __indirect_glProgramLocalParameter4dvARB; - glAPI->ProgramLocalParameter4fARB = __indirect_glProgramLocalParameter4fARB; - glAPI->ProgramLocalParameter4fvARB = __indirect_glProgramLocalParameter4fvARB; - glAPI->ProgramStringARB = __indirect_glProgramStringARB; - glAPI->VertexAttrib1dARB = __indirect_glVertexAttrib1dARB; - glAPI->VertexAttrib1dvARB = __indirect_glVertexAttrib1dvARB; - glAPI->VertexAttrib1fARB = __indirect_glVertexAttrib1fARB; - glAPI->VertexAttrib1fvARB = __indirect_glVertexAttrib1fvARB; - glAPI->VertexAttrib1sARB = __indirect_glVertexAttrib1sARB; - glAPI->VertexAttrib1svARB = __indirect_glVertexAttrib1svARB; - glAPI->VertexAttrib2dARB = __indirect_glVertexAttrib2dARB; - glAPI->VertexAttrib2dvARB = __indirect_glVertexAttrib2dvARB; - glAPI->VertexAttrib2fARB = __indirect_glVertexAttrib2fARB; - glAPI->VertexAttrib2fvARB = __indirect_glVertexAttrib2fvARB; - glAPI->VertexAttrib2sARB = __indirect_glVertexAttrib2sARB; - glAPI->VertexAttrib2svARB = __indirect_glVertexAttrib2svARB; - glAPI->VertexAttrib3dARB = __indirect_glVertexAttrib3dARB; - glAPI->VertexAttrib3dvARB = __indirect_glVertexAttrib3dvARB; - glAPI->VertexAttrib3fARB = __indirect_glVertexAttrib3fARB; - glAPI->VertexAttrib3fvARB = __indirect_glVertexAttrib3fvARB; - glAPI->VertexAttrib3sARB = __indirect_glVertexAttrib3sARB; - glAPI->VertexAttrib3svARB = __indirect_glVertexAttrib3svARB; - glAPI->VertexAttrib4NbvARB = __indirect_glVertexAttrib4NbvARB; - glAPI->VertexAttrib4NivARB = __indirect_glVertexAttrib4NivARB; - glAPI->VertexAttrib4NsvARB = __indirect_glVertexAttrib4NsvARB; - glAPI->VertexAttrib4NubARB = __indirect_glVertexAttrib4NubARB; - glAPI->VertexAttrib4NubvARB = __indirect_glVertexAttrib4NubvARB; - glAPI->VertexAttrib4NuivARB = __indirect_glVertexAttrib4NuivARB; - glAPI->VertexAttrib4NusvARB = __indirect_glVertexAttrib4NusvARB; - glAPI->VertexAttrib4bvARB = __indirect_glVertexAttrib4bvARB; - glAPI->VertexAttrib4dARB = __indirect_glVertexAttrib4dARB; - glAPI->VertexAttrib4dvARB = __indirect_glVertexAttrib4dvARB; - glAPI->VertexAttrib4fARB = __indirect_glVertexAttrib4fARB; - glAPI->VertexAttrib4fvARB = __indirect_glVertexAttrib4fvARB; - glAPI->VertexAttrib4ivARB = __indirect_glVertexAttrib4ivARB; - glAPI->VertexAttrib4sARB = __indirect_glVertexAttrib4sARB; - glAPI->VertexAttrib4svARB = __indirect_glVertexAttrib4svARB; - glAPI->VertexAttrib4ubvARB = __indirect_glVertexAttrib4ubvARB; - glAPI->VertexAttrib4uivARB = __indirect_glVertexAttrib4uivARB; - glAPI->VertexAttrib4usvARB = __indirect_glVertexAttrib4usvARB; - glAPI->VertexAttribPointerARB = __indirect_glVertexAttribPointerARB; - - /* 29. GL_ARB_occlusion_query */ - - glAPI->BeginQueryARB = __indirect_glBeginQueryARB; - glAPI->DeleteQueriesARB = __indirect_glDeleteQueriesARB; - glAPI->EndQueryARB = __indirect_glEndQueryARB; - glAPI->GenQueriesARB = __indirect_glGenQueriesARB; - glAPI->GetQueryObjectivARB = __indirect_glGetQueryObjectivARB; - glAPI->GetQueryObjectuivARB = __indirect_glGetQueryObjectuivARB; - glAPI->GetQueryivARB = __indirect_glGetQueryivARB; - glAPI->IsQueryARB = __indirect_glIsQueryARB; - - /* 37. GL_ARB_draw_buffers */ - - glAPI->DrawBuffersARB = __indirect_glDrawBuffersARB; - - /* 45. GL_ARB_framebuffer_object */ - - glAPI->RenderbufferStorageMultisample = __indirect_glRenderbufferStorageMultisample; - - /* 25. GL_SGIS_multisample */ - - glAPI->SampleMaskSGIS = __indirect_glSampleMaskSGIS; - glAPI->SamplePatternSGIS = __indirect_glSamplePatternSGIS; - - /* 30. GL_EXT_vertex_array */ - - glAPI->ColorPointerEXT = __indirect_glColorPointerEXT; - glAPI->EdgeFlagPointerEXT = __indirect_glEdgeFlagPointerEXT; - glAPI->IndexPointerEXT = __indirect_glIndexPointerEXT; - glAPI->NormalPointerEXT = __indirect_glNormalPointerEXT; - glAPI->TexCoordPointerEXT = __indirect_glTexCoordPointerEXT; - glAPI->VertexPointerEXT = __indirect_glVertexPointerEXT; - - /* 54. GL_EXT_point_parameters */ - - glAPI->PointParameterfEXT = __indirect_glPointParameterfEXT; - glAPI->PointParameterfvEXT = __indirect_glPointParameterfvEXT; - - /* 145. GL_EXT_secondary_color */ - - glAPI->SecondaryColor3bEXT = __indirect_glSecondaryColor3bEXT; - glAPI->SecondaryColor3bvEXT = __indirect_glSecondaryColor3bvEXT; - glAPI->SecondaryColor3dEXT = __indirect_glSecondaryColor3dEXT; - glAPI->SecondaryColor3dvEXT = __indirect_glSecondaryColor3dvEXT; - glAPI->SecondaryColor3fEXT = __indirect_glSecondaryColor3fEXT; - glAPI->SecondaryColor3fvEXT = __indirect_glSecondaryColor3fvEXT; - glAPI->SecondaryColor3iEXT = __indirect_glSecondaryColor3iEXT; - glAPI->SecondaryColor3ivEXT = __indirect_glSecondaryColor3ivEXT; - glAPI->SecondaryColor3sEXT = __indirect_glSecondaryColor3sEXT; - glAPI->SecondaryColor3svEXT = __indirect_glSecondaryColor3svEXT; - glAPI->SecondaryColor3ubEXT = __indirect_glSecondaryColor3ubEXT; - glAPI->SecondaryColor3ubvEXT = __indirect_glSecondaryColor3ubvEXT; - glAPI->SecondaryColor3uiEXT = __indirect_glSecondaryColor3uiEXT; - glAPI->SecondaryColor3uivEXT = __indirect_glSecondaryColor3uivEXT; - glAPI->SecondaryColor3usEXT = __indirect_glSecondaryColor3usEXT; - glAPI->SecondaryColor3usvEXT = __indirect_glSecondaryColor3usvEXT; - glAPI->SecondaryColorPointerEXT = __indirect_glSecondaryColorPointerEXT; - - /* 148. GL_EXT_multi_draw_arrays */ - - glAPI->MultiDrawArraysEXT = __indirect_glMultiDrawArraysEXT; - glAPI->MultiDrawElementsEXT = __indirect_glMultiDrawElementsEXT; - - /* 149. GL_EXT_fog_coord */ - - glAPI->FogCoordPointerEXT = __indirect_glFogCoordPointerEXT; - glAPI->FogCoorddEXT = __indirect_glFogCoorddEXT; - glAPI->FogCoorddvEXT = __indirect_glFogCoorddvEXT; - glAPI->FogCoordfEXT = __indirect_glFogCoordfEXT; - glAPI->FogCoordfvEXT = __indirect_glFogCoordfvEXT; - - /* 173. GL_EXT_blend_func_separate */ - - glAPI->BlendFuncSeparateEXT = __indirect_glBlendFuncSeparateEXT; - - /* 197. GL_MESA_window_pos */ - - glAPI->WindowPos2dMESA = __indirect_glWindowPos2dMESA; - glAPI->WindowPos2dvMESA = __indirect_glWindowPos2dvMESA; - glAPI->WindowPos2fMESA = __indirect_glWindowPos2fMESA; - glAPI->WindowPos2fvMESA = __indirect_glWindowPos2fvMESA; - glAPI->WindowPos2iMESA = __indirect_glWindowPos2iMESA; - glAPI->WindowPos2ivMESA = __indirect_glWindowPos2ivMESA; - glAPI->WindowPos2sMESA = __indirect_glWindowPos2sMESA; - glAPI->WindowPos2svMESA = __indirect_glWindowPos2svMESA; - glAPI->WindowPos3dMESA = __indirect_glWindowPos3dMESA; - glAPI->WindowPos3dvMESA = __indirect_glWindowPos3dvMESA; - glAPI->WindowPos3fMESA = __indirect_glWindowPos3fMESA; - glAPI->WindowPos3fvMESA = __indirect_glWindowPos3fvMESA; - glAPI->WindowPos3iMESA = __indirect_glWindowPos3iMESA; - glAPI->WindowPos3ivMESA = __indirect_glWindowPos3ivMESA; - glAPI->WindowPos3sMESA = __indirect_glWindowPos3sMESA; - glAPI->WindowPos3svMESA = __indirect_glWindowPos3svMESA; - - /* 233. GL_NV_vertex_program */ - - glAPI->AreProgramsResidentNV = __indirect_glAreProgramsResidentNV; - glAPI->BindProgramNV = __indirect_glBindProgramNV; - glAPI->DeleteProgramsNV = __indirect_glDeleteProgramsNV; - glAPI->ExecuteProgramNV = __indirect_glExecuteProgramNV; - glAPI->GenProgramsNV = __indirect_glGenProgramsNV; - glAPI->GetProgramParameterdvNV = __indirect_glGetProgramParameterdvNV; - glAPI->GetProgramParameterfvNV = __indirect_glGetProgramParameterfvNV; - glAPI->GetProgramStringNV = __indirect_glGetProgramStringNV; - glAPI->GetProgramivNV = __indirect_glGetProgramivNV; - glAPI->GetTrackMatrixivNV = __indirect_glGetTrackMatrixivNV; - glAPI->GetVertexAttribPointervNV = __indirect_glGetVertexAttribPointervNV; - glAPI->GetVertexAttribdvNV = __indirect_glGetVertexAttribdvNV; - glAPI->GetVertexAttribfvNV = __indirect_glGetVertexAttribfvNV; - glAPI->GetVertexAttribivNV = __indirect_glGetVertexAttribivNV; - glAPI->IsProgramNV = __indirect_glIsProgramNV; - glAPI->LoadProgramNV = __indirect_glLoadProgramNV; - glAPI->ProgramParameters4dvNV = __indirect_glProgramParameters4dvNV; - glAPI->ProgramParameters4fvNV = __indirect_glProgramParameters4fvNV; - glAPI->RequestResidentProgramsNV = __indirect_glRequestResidentProgramsNV; - glAPI->TrackMatrixNV = __indirect_glTrackMatrixNV; - glAPI->VertexAttrib1dNV = __indirect_glVertexAttrib1dNV; - glAPI->VertexAttrib1dvNV = __indirect_glVertexAttrib1dvNV; - glAPI->VertexAttrib1fNV = __indirect_glVertexAttrib1fNV; - glAPI->VertexAttrib1fvNV = __indirect_glVertexAttrib1fvNV; - glAPI->VertexAttrib1sNV = __indirect_glVertexAttrib1sNV; - glAPI->VertexAttrib1svNV = __indirect_glVertexAttrib1svNV; - glAPI->VertexAttrib2dNV = __indirect_glVertexAttrib2dNV; - glAPI->VertexAttrib2dvNV = __indirect_glVertexAttrib2dvNV; - glAPI->VertexAttrib2fNV = __indirect_glVertexAttrib2fNV; - glAPI->VertexAttrib2fvNV = __indirect_glVertexAttrib2fvNV; - glAPI->VertexAttrib2sNV = __indirect_glVertexAttrib2sNV; - glAPI->VertexAttrib2svNV = __indirect_glVertexAttrib2svNV; - glAPI->VertexAttrib3dNV = __indirect_glVertexAttrib3dNV; - glAPI->VertexAttrib3dvNV = __indirect_glVertexAttrib3dvNV; - glAPI->VertexAttrib3fNV = __indirect_glVertexAttrib3fNV; - glAPI->VertexAttrib3fvNV = __indirect_glVertexAttrib3fvNV; - glAPI->VertexAttrib3sNV = __indirect_glVertexAttrib3sNV; - glAPI->VertexAttrib3svNV = __indirect_glVertexAttrib3svNV; - glAPI->VertexAttrib4dNV = __indirect_glVertexAttrib4dNV; - glAPI->VertexAttrib4dvNV = __indirect_glVertexAttrib4dvNV; - glAPI->VertexAttrib4fNV = __indirect_glVertexAttrib4fNV; - glAPI->VertexAttrib4fvNV = __indirect_glVertexAttrib4fvNV; - glAPI->VertexAttrib4sNV = __indirect_glVertexAttrib4sNV; - glAPI->VertexAttrib4svNV = __indirect_glVertexAttrib4svNV; - glAPI->VertexAttrib4ubNV = __indirect_glVertexAttrib4ubNV; - glAPI->VertexAttrib4ubvNV = __indirect_glVertexAttrib4ubvNV; - glAPI->VertexAttribPointerNV = __indirect_glVertexAttribPointerNV; - glAPI->VertexAttribs1dvNV = __indirect_glVertexAttribs1dvNV; - glAPI->VertexAttribs1fvNV = __indirect_glVertexAttribs1fvNV; - glAPI->VertexAttribs1svNV = __indirect_glVertexAttribs1svNV; - glAPI->VertexAttribs2dvNV = __indirect_glVertexAttribs2dvNV; - glAPI->VertexAttribs2fvNV = __indirect_glVertexAttribs2fvNV; - glAPI->VertexAttribs2svNV = __indirect_glVertexAttribs2svNV; - glAPI->VertexAttribs3dvNV = __indirect_glVertexAttribs3dvNV; - glAPI->VertexAttribs3fvNV = __indirect_glVertexAttribs3fvNV; - glAPI->VertexAttribs3svNV = __indirect_glVertexAttribs3svNV; - glAPI->VertexAttribs4dvNV = __indirect_glVertexAttribs4dvNV; - glAPI->VertexAttribs4fvNV = __indirect_glVertexAttribs4fvNV; - glAPI->VertexAttribs4svNV = __indirect_glVertexAttribs4svNV; - glAPI->VertexAttribs4ubvNV = __indirect_glVertexAttribs4ubvNV; - - /* 262. GL_NV_point_sprite */ - - glAPI->PointParameteriNV = __indirect_glPointParameteriNV; - glAPI->PointParameterivNV = __indirect_glPointParameterivNV; - - /* 268. GL_EXT_stencil_two_side */ - - glAPI->ActiveStencilFaceEXT = __indirect_glActiveStencilFaceEXT; - - /* 282. GL_NV_fragment_program */ - - glAPI->GetProgramNamedParameterdvNV = __indirect_glGetProgramNamedParameterdvNV; - glAPI->GetProgramNamedParameterfvNV = __indirect_glGetProgramNamedParameterfvNV; - glAPI->ProgramNamedParameter4dNV = __indirect_glProgramNamedParameter4dNV; - glAPI->ProgramNamedParameter4dvNV = __indirect_glProgramNamedParameter4dvNV; - glAPI->ProgramNamedParameter4fNV = __indirect_glProgramNamedParameter4fNV; - glAPI->ProgramNamedParameter4fvNV = __indirect_glProgramNamedParameter4fvNV; - - /* 299. GL_EXT_blend_equation_separate */ - - glAPI->BlendEquationSeparateEXT = __indirect_glBlendEquationSeparateEXT; - - /* 310. GL_EXT_framebuffer_object */ - - glAPI->BindFramebufferEXT = __indirect_glBindFramebufferEXT; - glAPI->BindRenderbufferEXT = __indirect_glBindRenderbufferEXT; - glAPI->CheckFramebufferStatusEXT = __indirect_glCheckFramebufferStatusEXT; - glAPI->DeleteFramebuffersEXT = __indirect_glDeleteFramebuffersEXT; - glAPI->DeleteRenderbuffersEXT = __indirect_glDeleteRenderbuffersEXT; - glAPI->FramebufferRenderbufferEXT = __indirect_glFramebufferRenderbufferEXT; - glAPI->FramebufferTexture1DEXT = __indirect_glFramebufferTexture1DEXT; - glAPI->FramebufferTexture2DEXT = __indirect_glFramebufferTexture2DEXT; - glAPI->FramebufferTexture3DEXT = __indirect_glFramebufferTexture3DEXT; - glAPI->GenFramebuffersEXT = __indirect_glGenFramebuffersEXT; - glAPI->GenRenderbuffersEXT = __indirect_glGenRenderbuffersEXT; - glAPI->GenerateMipmapEXT = __indirect_glGenerateMipmapEXT; - glAPI->GetFramebufferAttachmentParameterivEXT = __indirect_glGetFramebufferAttachmentParameterivEXT; - glAPI->GetRenderbufferParameterivEXT = __indirect_glGetRenderbufferParameterivEXT; - glAPI->IsFramebufferEXT = __indirect_glIsFramebufferEXT; - glAPI->IsRenderbufferEXT = __indirect_glIsRenderbufferEXT; - glAPI->RenderbufferStorageEXT = __indirect_glRenderbufferStorageEXT; - - /* 316. GL_EXT_framebuffer_blit */ - - glAPI->BlitFramebufferEXT = __indirect_glBlitFramebufferEXT; - - /* 329. GL_EXT_texture_array */ - - glAPI->FramebufferTextureLayerEXT = __indirect_glFramebufferTextureLayerEXT; - - return glAPI; -} - diff --git a/src/glx/x11/indirect_init.h b/src/glx/x11/indirect_init.h deleted file mode 100644 index 72255f13014..00000000000 --- a/src/glx/x11/indirect_init.h +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * - */ - -#ifndef _INDIRECT_INIT_H_ -#define _INDIRECT_INIT_H_ - -#include "glxclient.h" - -extern __GLapi *__glXNewIndirectAPI(void); - -#endif /* _INDIRECT_INIT_H_ */ diff --git a/src/glx/x11/indirect_size.c b/src/glx/x11/indirect_size.c deleted file mode 100644 index 6356ddd49b5..00000000000 --- a/src/glx/x11/indirect_size.c +++ /dev/null @@ -1,388 +0,0 @@ -/* DO NOT EDIT - This file generated automatically by glX_proto_size.py (from Mesa) script */ - -/* - * (C) Copyright IBM Corporation 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - -#include -#include "indirect_size.h" - -# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PURE __attribute__((pure)) -# else -# define PURE -# endif - -# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) -# define FASTCALL __attribute__((fastcall)) -# else -# define FASTCALL -# endif - -# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) && defined(__ELF__) -# define INTERNAL __attribute__((visibility("internal"))) -# else -# define INTERNAL -# endif - - -#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__) -# undef HAVE_ALIAS -#endif -#ifdef HAVE_ALIAS -# define ALIAS2(from,to) \ - INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \ - __attribute__ ((alias( # to ))); -# define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size ) -#else -# define ALIAS(from,to) \ - INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \ - { return __gl ## to ## _size( e ); } -#endif - - -INTERNAL PURE FASTCALL GLint -__glCallLists_size(GLenum e) -{ - switch (e) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - return 1; - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_2_BYTES: - case GL_HALF_FLOAT: - return 2; - case GL_3_BYTES: - return 3; - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_4_BYTES: - return 4; - default: - return 0; - } -} - -INTERNAL PURE FASTCALL GLint -__glFogfv_size(GLenum e) -{ - switch (e) { - case GL_FOG_INDEX: - case GL_FOG_DENSITY: - case GL_FOG_START: - case GL_FOG_END: - case GL_FOG_MODE: - case GL_FOG_OFFSET_VALUE_SGIX: - case GL_FOG_DISTANCE_MODE_NV: - return 1; - case GL_FOG_COLOR: - return 4; - default: - return 0; - } -} - -INTERNAL PURE FASTCALL GLint -__glLightfv_size(GLenum e) -{ - switch (e) { - case GL_SPOT_EXPONENT: - case GL_SPOT_CUTOFF: - case GL_CONSTANT_ATTENUATION: - case GL_LINEAR_ATTENUATION: - case GL_QUADRATIC_ATTENUATION: - return 1; - case GL_SPOT_DIRECTION: - return 3; - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_POSITION: - return 4; - default: - return 0; - } -} - -INTERNAL PURE FASTCALL GLint -__glLightModelfv_size(GLenum e) -{ - switch (e) { - case GL_LIGHT_MODEL_LOCAL_VIEWER: - case GL_LIGHT_MODEL_TWO_SIDE: - case GL_LIGHT_MODEL_COLOR_CONTROL: -/* case GL_LIGHT_MODEL_COLOR_CONTROL_EXT:*/ - return 1; - case GL_LIGHT_MODEL_AMBIENT: - return 4; - default: - return 0; - } -} - -INTERNAL PURE FASTCALL GLint -__glMaterialfv_size(GLenum e) -{ - switch (e) { - case GL_SHININESS: - return 1; - case GL_COLOR_INDEXES: - return 3; - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_EMISSION: - case GL_AMBIENT_AND_DIFFUSE: - return 4; - default: - return 0; - } -} - -INTERNAL PURE FASTCALL GLint -__glTexParameterfv_size(GLenum e) -{ - switch (e) { - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_PRIORITY: - case GL_TEXTURE_WRAP_R: - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: -/* case GL_SHADOW_AMBIENT_SGIX:*/ - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - case GL_TEXTURE_BASE_LEVEL: - case GL_TEXTURE_MAX_LEVEL: - case GL_TEXTURE_CLIPMAP_FRAME_SGIX: - case GL_TEXTURE_LOD_BIAS_S_SGIX: - case GL_TEXTURE_LOD_BIAS_T_SGIX: - case GL_TEXTURE_LOD_BIAS_R_SGIX: - case GL_GENERATE_MIPMAP: -/* case GL_GENERATE_MIPMAP_SGIS:*/ - case GL_TEXTURE_COMPARE_SGIX: - case GL_TEXTURE_COMPARE_OPERATOR_SGIX: - case GL_TEXTURE_MAX_CLAMP_S_SGIX: - case GL_TEXTURE_MAX_CLAMP_T_SGIX: - case GL_TEXTURE_MAX_CLAMP_R_SGIX: - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - case GL_TEXTURE_LOD_BIAS: -/* case GL_TEXTURE_LOD_BIAS_EXT:*/ - case GL_TEXTURE_STORAGE_HINT_APPLE: - case GL_STORAGE_PRIVATE_APPLE: - case GL_STORAGE_CACHED_APPLE: - case GL_STORAGE_SHARED_APPLE: - case GL_DEPTH_TEXTURE_MODE: -/* case GL_DEPTH_TEXTURE_MODE_ARB:*/ - case GL_TEXTURE_COMPARE_MODE: -/* case GL_TEXTURE_COMPARE_MODE_ARB:*/ - case GL_TEXTURE_COMPARE_FUNC: -/* case GL_TEXTURE_COMPARE_FUNC_ARB:*/ - case GL_TEXTURE_UNSIGNED_REMAP_MODE_NV: - return 1; - case GL_TEXTURE_CLIPMAP_CENTER_SGIX: - case GL_TEXTURE_CLIPMAP_OFFSET_SGIX: - return 2; - case GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX: - return 3; - case GL_TEXTURE_BORDER_COLOR: - case GL_POST_TEXTURE_FILTER_BIAS_SGIX: - case GL_POST_TEXTURE_FILTER_SCALE_SGIX: - return 4; - default: - return 0; - } -} - -INTERNAL PURE FASTCALL GLint -__glTexEnvfv_size(GLenum e) -{ - switch (e) { - case GL_ALPHA_SCALE: - case GL_TEXTURE_ENV_MODE: - case GL_TEXTURE_LOD_BIAS: - case GL_COMBINE_RGB: - case GL_COMBINE_ALPHA: - case GL_RGB_SCALE: - case GL_SOURCE0_RGB: - case GL_SOURCE1_RGB: - case GL_SOURCE2_RGB: - case GL_SOURCE3_RGB_NV: - case GL_SOURCE0_ALPHA: - case GL_SOURCE1_ALPHA: - case GL_SOURCE2_ALPHA: - case GL_SOURCE3_ALPHA_NV: - case GL_OPERAND0_RGB: - case GL_OPERAND1_RGB: - case GL_OPERAND2_RGB: - case GL_OPERAND3_RGB_NV: - case GL_OPERAND0_ALPHA: - case GL_OPERAND1_ALPHA: - case GL_OPERAND2_ALPHA: - case GL_OPERAND3_ALPHA_NV: - case GL_BUMP_TARGET_ATI: - case GL_COORD_REPLACE_ARB: -/* case GL_COORD_REPLACE_NV:*/ - return 1; - case GL_TEXTURE_ENV_COLOR: - return 4; - default: - return 0; - } -} - -INTERNAL PURE FASTCALL GLint -__glTexGendv_size(GLenum e) -{ - switch (e) { - case GL_TEXTURE_GEN_MODE: - return 1; - case GL_OBJECT_PLANE: - case GL_EYE_PLANE: - return 4; - default: - return 0; - } -} - -INTERNAL PURE FASTCALL GLint -__glMap1d_size(GLenum e) -{ - switch (e) { - case GL_MAP1_INDEX: - case GL_MAP1_TEXTURE_COORD_1: - return 1; - case GL_MAP1_TEXTURE_COORD_2: - return 2; - case GL_MAP1_NORMAL: - case GL_MAP1_TEXTURE_COORD_3: - case GL_MAP1_VERTEX_3: - return 3; - case GL_MAP1_COLOR_4: - case GL_MAP1_TEXTURE_COORD_4: - case GL_MAP1_VERTEX_4: - return 4; - default: - return 0; - } -} - -INTERNAL PURE FASTCALL GLint -__glMap2d_size(GLenum e) -{ - switch (e) { - case GL_MAP2_INDEX: - case GL_MAP2_TEXTURE_COORD_1: - return 1; - case GL_MAP2_TEXTURE_COORD_2: - return 2; - case GL_MAP2_NORMAL: - case GL_MAP2_TEXTURE_COORD_3: - case GL_MAP2_VERTEX_3: - return 3; - case GL_MAP2_COLOR_4: - case GL_MAP2_TEXTURE_COORD_4: - case GL_MAP2_VERTEX_4: - return 4; - default: - return 0; - } -} - -INTERNAL PURE FASTCALL GLint -__glColorTableParameterfv_size(GLenum e) -{ - switch (e) { - case GL_COLOR_TABLE_SCALE: - case GL_COLOR_TABLE_BIAS: - return 4; - default: - return 0; - } -} - -INTERNAL PURE FASTCALL GLint -__glConvolutionParameterfv_size(GLenum e) -{ - switch (e) { - case GL_CONVOLUTION_BORDER_MODE: -/* case GL_CONVOLUTION_BORDER_MODE_EXT:*/ - return 1; - case GL_CONVOLUTION_FILTER_SCALE: -/* case GL_CONVOLUTION_FILTER_SCALE_EXT:*/ - case GL_CONVOLUTION_FILTER_BIAS: -/* case GL_CONVOLUTION_FILTER_BIAS_EXT:*/ - case GL_CONVOLUTION_BORDER_COLOR: -/* case GL_CONVOLUTION_BORDER_COLOR_HP:*/ - return 4; - default: - return 0; - } -} - -INTERNAL PURE FASTCALL GLint -__glPointParameterfvEXT_size(GLenum e) -{ - switch (e) { - case GL_POINT_SIZE_MIN: -/* case GL_POINT_SIZE_MIN_ARB:*/ -/* case GL_POINT_SIZE_MIN_SGIS:*/ - case GL_POINT_SIZE_MAX: -/* case GL_POINT_SIZE_MAX_ARB:*/ -/* case GL_POINT_SIZE_MAX_SGIS:*/ - case GL_POINT_FADE_THRESHOLD_SIZE: -/* case GL_POINT_FADE_THRESHOLD_SIZE_ARB:*/ -/* case GL_POINT_FADE_THRESHOLD_SIZE_SGIS:*/ - case GL_POINT_SPRITE_R_MODE_NV: - case GL_POINT_SPRITE_COORD_ORIGIN: - return 1; - case GL_POINT_DISTANCE_ATTENUATION: -/* case GL_POINT_DISTANCE_ATTENUATION_ARB:*/ -/* case GL_POINT_DISTANCE_ATTENUATION_SGIS:*/ - return 3; - default: - return 0; - } -} - -ALIAS(Fogiv, Fogfv) - ALIAS(Lightiv, Lightfv) - ALIAS(LightModeliv, LightModelfv) - ALIAS(Materialiv, Materialfv) - ALIAS(TexParameteriv, TexParameterfv) - ALIAS(TexEnviv, TexEnvfv) - ALIAS(TexGenfv, TexGendv) - ALIAS(TexGeniv, TexGendv) - ALIAS(Map1f, Map1d) - ALIAS(Map2f, Map2d) - ALIAS(ColorTableParameteriv, ColorTableParameterfv) - ALIAS(ConvolutionParameteriv, ConvolutionParameterfv) - ALIAS(PointParameterivNV, PointParameterfvEXT) -# undef PURE -# undef FASTCALL -# undef INTERNAL diff --git a/src/glx/x11/indirect_size.h b/src/glx/x11/indirect_size.h deleted file mode 100644 index af0919f9645..00000000000 --- a/src/glx/x11/indirect_size.h +++ /dev/null @@ -1,88 +0,0 @@ -/* DO NOT EDIT - This file generated automatically by glX_proto_size.py (from Mesa) script */ - -/* - * (C) Copyright IBM Corporation 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined( _INDIRECT_SIZE_H_ ) -# define _INDIRECT_SIZE_H_ - -/** - * \file - * Prototypes for functions used to determine the number of data elements in - * various GLX protocol messages. - * - * \author Ian Romanick - */ - -# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PURE __attribute__((pure)) -# else -# define PURE -# endif - -# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) -# define FASTCALL __attribute__((fastcall)) -# else -# define FASTCALL -# endif - -# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) && defined(__ELF__) -# define INTERNAL __attribute__((visibility("internal"))) -# else -# define INTERNAL -# endif - -extern INTERNAL PURE FASTCALL GLint __glCallLists_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glFogfv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glFogiv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glLightfv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glLightiv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glLightModelfv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glLightModeliv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glMaterialfv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glMaterialiv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glTexParameterfv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glTexParameteriv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glTexEnvfv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glTexEnviv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glTexGendv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glTexGenfv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glTexGeniv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glMap1d_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glMap1f_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glMap2d_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glMap2f_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glColorTableParameterfv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glColorTableParameteriv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glConvolutionParameterfv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glConvolutionParameteriv_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glPointParameterfvEXT_size(GLenum); -extern INTERNAL PURE FASTCALL GLint __glPointParameterivNV_size(GLenum); - -# undef PURE -# undef FASTCALL -# undef INTERNAL - -#endif /* !defined( _INDIRECT_SIZE_H_ ) */ diff --git a/src/glx/x11/indirect_texture_compression.c b/src/glx/x11/indirect_texture_compression.c deleted file mode 100644 index fa927ebdf68..00000000000 --- a/src/glx/x11/indirect_texture_compression.c +++ /dev/null @@ -1,343 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file glx_texture_compression.c - * Contains the routines required to implement GLX protocol for - * ARB_texture_compression and related extensions. - * - * \sa http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_compression.txt - * - * \author Ian Romanick - */ - -#include "packrender.h" -#include "packsingle.h" -#include "indirect.h" - -#include - - -void -__indirect_glGetCompressedTexImageARB(GLenum target, GLint level, - GLvoid * img) -{ - __GLX_SINGLE_DECLARE_VARIABLES(); - xGLXGetTexImageReply reply; - size_t image_bytes; - - __GLX_SINGLE_LOAD_VARIABLES(); - __GLX_SINGLE_BEGIN(X_GLsop_GetCompressedTexImage, 8); - __GLX_SINGLE_PUT_LONG(0, target); - __GLX_SINGLE_PUT_LONG(4, level); - __GLX_SINGLE_READ_XREPLY(); - - image_bytes = reply.width; - assert(image_bytes <= ((4 * reply.length) - 0)); - assert(image_bytes >= ((4 * reply.length) - 3)); - - if (image_bytes != 0) { - _XRead(dpy, (char *) img, image_bytes); - if (image_bytes < (4 * reply.length)) { - _XEatData(dpy, (4 * reply.length) - image_bytes); - } - } - - __GLX_SINGLE_END(); -} - - -/** - * Internal function used for \c glCompressedTexImage1D and - * \c glCompressedTexImage2D. - */ -static void -CompressedTexImage1D2D(GLenum target, GLint level, - GLenum internal_format, - GLsizei width, GLsizei height, - GLint border, GLsizei image_size, - const GLvoid * data, CARD32 rop) -{ - __GLX_DECLARE_VARIABLES(); - - __GLX_LOAD_VARIABLES(); - if (gc->currentDpy == NULL) { - return; - } - - if ((target == GL_PROXY_TEXTURE_1D) - || (target == GL_PROXY_TEXTURE_2D) - || (target == GL_PROXY_TEXTURE_CUBE_MAP)) { - compsize = 0; - } - else { - compsize = image_size; - } - - cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE + compsize); - if (cmdlen <= gc->maxSmallRenderCommandSize) { - __GLX_BEGIN_VARIABLE(rop, cmdlen); - __GLX_PUT_LONG(4, target); - __GLX_PUT_LONG(8, level); - __GLX_PUT_LONG(12, internal_format); - __GLX_PUT_LONG(16, width); - __GLX_PUT_LONG(20, height); - __GLX_PUT_LONG(24, border); - __GLX_PUT_LONG(28, image_size); - if (compsize != 0) { - __GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE, - data, image_size); - } - __GLX_END(cmdlen); - } - else { - assert(compsize != 0); - - __GLX_BEGIN_VARIABLE_LARGE(rop, cmdlen + 4); - __GLX_PUT_LONG(8, target); - __GLX_PUT_LONG(12, level); - __GLX_PUT_LONG(16, internal_format); - __GLX_PUT_LONG(20, width); - __GLX_PUT_LONG(24, height); - __GLX_PUT_LONG(28, border); - __GLX_PUT_LONG(32, image_size); - __glXSendLargeCommand(gc, gc->pc, - __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE + 4, - data, image_size); - } -} - - -/** - * Internal function used for \c glCompressedTexSubImage1D and - * \c glCompressedTexSubImage2D. - */ -static void -CompressedTexSubImage1D2D(GLenum target, GLint level, - GLsizei xoffset, GLsizei yoffset, - GLsizei width, GLsizei height, - GLenum format, GLsizei image_size, - const GLvoid * data, CARD32 rop) -{ - __GLX_DECLARE_VARIABLES(); - - __GLX_LOAD_VARIABLES(); - if (gc->currentDpy == NULL) { - return; - } - - if (target == GL_PROXY_TEXTURE_3D) { - compsize = 0; - } - else { - compsize = image_size; - } - - cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE + compsize); - if (cmdlen <= gc->maxSmallRenderCommandSize) { - __GLX_BEGIN_VARIABLE(rop, cmdlen); - __GLX_PUT_LONG(4, target); - __GLX_PUT_LONG(8, level); - __GLX_PUT_LONG(12, xoffset); - __GLX_PUT_LONG(16, yoffset); - __GLX_PUT_LONG(20, width); - __GLX_PUT_LONG(24, height); - __GLX_PUT_LONG(28, format); - __GLX_PUT_LONG(32, image_size); - if (compsize != 0) { - __GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE, - data, image_size); - } - __GLX_END(cmdlen); - } - else { - assert(compsize != 0); - - __GLX_BEGIN_VARIABLE_LARGE(rop, cmdlen + 4); - __GLX_PUT_LONG(8, target); - __GLX_PUT_LONG(12, level); - __GLX_PUT_LONG(16, xoffset); - __GLX_PUT_LONG(20, yoffset); - __GLX_PUT_LONG(24, width); - __GLX_PUT_LONG(28, height); - __GLX_PUT_LONG(32, format); - __GLX_PUT_LONG(36, image_size); - __glXSendLargeCommand(gc, gc->pc, - __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE + 4, - data, image_size); - } -} - - -void -__indirect_glCompressedTexImage1DARB(GLenum target, GLint level, - GLenum internal_format, GLsizei width, - GLint border, GLsizei image_size, - const GLvoid * data) -{ - CompressedTexImage1D2D(target, level, internal_format, width, 0, - border, image_size, data, - X_GLrop_CompressedTexImage1D); -} - - -void -__indirect_glCompressedTexImage2DARB(GLenum target, GLint level, - GLenum internal_format, - GLsizei width, GLsizei height, - GLint border, GLsizei image_size, - const GLvoid * data) -{ - CompressedTexImage1D2D(target, level, internal_format, width, height, - border, image_size, data, - X_GLrop_CompressedTexImage2D); -} - - -void -__indirect_glCompressedTexImage3DARB(GLenum target, GLint level, - GLenum internal_format, - GLsizei width, GLsizei height, - GLsizei depth, GLint border, - GLsizei image_size, const GLvoid * data) -{ - __GLX_DECLARE_VARIABLES(); - - __GLX_LOAD_VARIABLES(); - if (gc->currentDpy == NULL) { - return; - } - - cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE + image_size); - if (cmdlen <= gc->maxSmallRenderCommandSize) { - __GLX_BEGIN_VARIABLE(X_GLrop_CompressedTexImage3D, cmdlen); - __GLX_PUT_LONG(4, target); - __GLX_PUT_LONG(8, level); - __GLX_PUT_LONG(12, internal_format); - __GLX_PUT_LONG(16, width); - __GLX_PUT_LONG(20, height); - __GLX_PUT_LONG(24, depth); - __GLX_PUT_LONG(28, border); - __GLX_PUT_LONG(32, image_size); - if (image_size != 0) { - __GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE, - data, image_size); - } - __GLX_END(cmdlen); - } - else { - __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_CompressedTexImage3D, cmdlen + 4); - __GLX_PUT_LONG(8, target); - __GLX_PUT_LONG(12, level); - __GLX_PUT_LONG(16, internal_format); - __GLX_PUT_LONG(20, width); - __GLX_PUT_LONG(24, height); - __GLX_PUT_LONG(28, depth); - __GLX_PUT_LONG(32, border); - __GLX_PUT_LONG(36, image_size); - __glXSendLargeCommand(gc, gc->pc, - __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE + 4, - data, image_size); - } -} - - -void -__indirect_glCompressedTexSubImage1DARB(GLenum target, GLint level, - GLint xoffset, - GLsizei width, - GLenum format, GLsizei image_size, - const GLvoid * data) -{ - CompressedTexSubImage1D2D(target, level, xoffset, 0, width, 0, - format, image_size, data, - X_GLrop_CompressedTexSubImage1D); -} - - -void -__indirect_glCompressedTexSubImage2DARB(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLsizei image_size, - const GLvoid * data) -{ - CompressedTexSubImage1D2D(target, level, xoffset, yoffset, width, height, - format, image_size, data, - X_GLrop_CompressedTexSubImage2D); -} - - -void -__indirect_glCompressedTexSubImage3DARB(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint zoffset, GLsizei width, - GLsizei height, GLsizei depth, - GLenum format, GLsizei image_size, - const GLvoid * data) -{ - __GLX_DECLARE_VARIABLES(); - - __GLX_LOAD_VARIABLES(); - if (gc->currentDpy == NULL) { - return; - } - - cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE - + image_size); - if (cmdlen <= gc->maxSmallRenderCommandSize) { - __GLX_BEGIN_VARIABLE(X_GLrop_CompressedTexSubImage3D, cmdlen); - __GLX_PUT_LONG(4, target); - __GLX_PUT_LONG(8, level); - __GLX_PUT_LONG(12, xoffset); - __GLX_PUT_LONG(16, yoffset); - __GLX_PUT_LONG(20, zoffset); - __GLX_PUT_LONG(24, width); - __GLX_PUT_LONG(28, height); - __GLX_PUT_LONG(32, depth); - __GLX_PUT_LONG(36, format); - __GLX_PUT_LONG(40, image_size); - if (image_size != 0) { - __GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE, - data, image_size); - } - __GLX_END(cmdlen); - } - else { - __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_CompressedTexSubImage3D, cmdlen + 4); - __GLX_PUT_LONG(8, target); - __GLX_PUT_LONG(12, level); - __GLX_PUT_LONG(16, xoffset); - __GLX_PUT_LONG(20, yoffset); - __GLX_PUT_LONG(24, zoffset); - __GLX_PUT_LONG(28, width); - __GLX_PUT_LONG(32, height); - __GLX_PUT_LONG(36, depth); - __GLX_PUT_LONG(40, format); - __GLX_PUT_LONG(44, image_size); - __glXSendLargeCommand(gc, gc->pc, - __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE + 4, - data, image_size); - } -} diff --git a/src/glx/x11/indirect_transpose_matrix.c b/src/glx/x11/indirect_transpose_matrix.c deleted file mode 100644 index 618db9f5d4f..00000000000 --- a/src/glx/x11/indirect_transpose_matrix.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include "indirect.h" - -static void -TransposeMatrixf(const GLfloat s[16], GLfloat d[16]) -{ - int i, j; - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - d[i * 4 + j] = s[j * 4 + i]; - } - } -} - -static void -TransposeMatrixd(const GLdouble s[16], GLdouble d[16]) -{ - int i, j; - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - d[i * 4 + j] = s[j * 4 + i]; - } - } -} - - -void -__indirect_glLoadTransposeMatrixdARB(const GLdouble * m) -{ - GLdouble mt[16]; - - TransposeMatrixd(m, mt); - __indirect_glLoadMatrixd(mt); -} - -void -__indirect_glLoadTransposeMatrixfARB(const GLfloat * m) -{ - GLfloat mt[16]; - - TransposeMatrixf(m, mt); - __indirect_glLoadMatrixf(mt); -} - -void -__indirect_glMultTransposeMatrixdARB(const GLdouble * m) -{ - GLdouble mt[16]; - - TransposeMatrixd(m, mt); - __indirect_glMultMatrixd(mt); -} - -void -__indirect_glMultTransposeMatrixfARB(const GLfloat * m) -{ - GLfloat mt[16]; - - TransposeMatrixf(m, mt); - __indirect_glMultMatrixf(mt); -} diff --git a/src/glx/x11/indirect_vertex_array.c b/src/glx/x11/indirect_vertex_array.c deleted file mode 100644 index ad9882528ff..00000000000 --- a/src/glx/x11/indirect_vertex_array.c +++ /dev/null @@ -1,1985 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2004, 2005 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -#include "glxclient.h" -#include "indirect.h" -#include -#include "glxextensions.h" -#include "indirect_vertex_array.h" -#include "indirect_vertex_array_priv.h" - -#define __GLX_PAD(n) (((n)+3) & ~3) - -/** - * \file indirect_vertex_array.c - * Implement GLX protocol for vertex arrays and vertex buffer objects. - * - * The most important function in this fill is \c fill_array_info_cache. - * The \c array_state_vector contains a cache of the ARRAY_INFO data sent - * in the DrawArrays protocol. Certain operations, such as enabling or - * disabling an array, can invalidate this cache. \c fill_array_info_cache - * fills-in this data. Additionally, it examines the enabled state and - * other factors to determine what "version" of DrawArrays protocoal can be - * used. - * - * Current, only two versions of DrawArrays protocol are implemented. The - * first version is the "none" protocol. This is the fallback when the - * server does not support GL 1.1 / EXT_vertex_arrays. It is implemented - * by sending batches of immediate mode commands that are equivalent to the - * DrawArrays protocol. - * - * The other protocol that is currently implemented is the "old" protocol. - * This is the GL 1.1 DrawArrays protocol. The only difference between GL - * 1.1 and EXT_vertex_arrays is the opcode used for the DrawArrays command. - * This protocol is called "old" because the ARB is in the process of - * defining a new protocol, which will probably be called wither "new" or - * "vbo", to support multiple texture coordinate arrays, generic attributes, - * and vertex buffer objects. - * - * \author Ian Romanick - */ - -static void emit_DrawArrays_none(GLenum mode, GLint first, GLsizei count); -static void emit_DrawArrays_old(GLenum mode, GLint first, GLsizei count); - -static void emit_DrawElements_none(GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices); -static void emit_DrawElements_old(GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices); - - -static GLubyte *emit_element_none(GLubyte * dst, - const struct array_state_vector *arrays, - unsigned index); -static GLubyte *emit_element_old(GLubyte * dst, - const struct array_state_vector *arrays, - unsigned index); -static struct array_state *get_array_entry(const struct array_state_vector - *arrays, GLenum key, - unsigned index); -static void fill_array_info_cache(struct array_state_vector *arrays); -static GLboolean validate_mode(__GLXcontext * gc, GLenum mode); -static GLboolean validate_count(__GLXcontext * gc, GLsizei count); -static GLboolean validate_type(__GLXcontext * gc, GLenum type); - - -/** - * Table of sizes, in bytes, of a GL types. All of the type enums are be in - * the range 0x1400 - 0x140F. That includes types added by extensions (i.e., - * \c GL_HALF_FLOAT_NV). This elements of this table correspond to the - * type enums masked with 0x0f. - * - * \notes - * \c GL_HALF_FLOAT_NV is not included. Neither are \c GL_2_BYTES, - * \c GL_3_BYTES, or \c GL_4_BYTES. - */ -const GLuint __glXTypeSize_table[16] = { - 1, 1, 2, 2, 4, 4, 4, 0, 0, 0, 8, 0, 0, 0, 0, 0 -}; - - -/** - * Free the per-context array state that was allocated with - * __glXInitVertexArrayState(). - */ -void -__glXFreeVertexArrayState(__GLXcontext * gc) -{ - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - - if (arrays) { - if (arrays->stack) { - free(arrays->stack); - arrays->stack = NULL; - } - if (arrays->arrays) { - free(arrays->arrays); - arrays->arrays = NULL; - } - free(arrays); - state->array_state = NULL; - } -} - - -/** - * Initialize vertex array state of a GLX context. - * - * \param gc GLX context whose vertex array state is to be initialized. - * - * \warning - * This function may only be called after __GLXcontext::gl_extension_bits, - * __GLXcontext::server_minor, and __GLXcontext::server_major have been - * initialized. These values are used to determine what vertex arrays are - * supported. - * - * \bug - * Return values from malloc are not properly tested. - */ -void -__glXInitVertexArrayState(__GLXcontext * gc) -{ - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays; - - unsigned array_count; - int texture_units = 1, vertex_program_attribs = 0; - unsigned i, j; - - GLboolean got_fog = GL_FALSE; - GLboolean got_secondary_color = GL_FALSE; - - - arrays = calloc(1, sizeof(struct array_state_vector)); - state->array_state = arrays; - - arrays->old_DrawArrays_possible = !state->NoDrawArraysProtocol; - arrays->new_DrawArrays_possible = GL_FALSE; - arrays->DrawArrays = NULL; - - arrays->active_texture_unit = 0; - - - /* Determine how many arrays are actually needed. Only arrays that - * are supported by the server are create. For example, if the server - * supports only 2 texture units, then only 2 texture coordinate arrays - * are created. - * - * At the very least, GL_VERTEX_ARRAY, GL_NORMAL_ARRAY, - * GL_COLOR_ARRAY, GL_INDEX_ARRAY, GL_TEXTURE_COORD_ARRAY, and - * GL_EDGE_FLAG_ARRAY are supported. - */ - - array_count = 5; - - if (__glExtensionBitIsEnabled(gc, GL_EXT_fog_coord_bit) - || (gc->server_major > 1) || (gc->server_minor >= 4)) { - got_fog = GL_TRUE; - array_count++; - } - - if (__glExtensionBitIsEnabled(gc, GL_EXT_secondary_color_bit) - || (gc->server_major > 1) || (gc->server_minor >= 4)) { - got_secondary_color = GL_TRUE; - array_count++; - } - - if (__glExtensionBitIsEnabled(gc, GL_ARB_multitexture_bit) - || (gc->server_major > 1) || (gc->server_minor >= 3)) { - __indirect_glGetIntegerv(GL_MAX_TEXTURE_UNITS, &texture_units); - } - - if (__glExtensionBitIsEnabled(gc, GL_ARB_vertex_program_bit)) { - __indirect_glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, - GL_MAX_PROGRAM_ATTRIBS_ARB, - &vertex_program_attribs); - } - - arrays->num_texture_units = texture_units; - arrays->num_vertex_program_attribs = vertex_program_attribs; - array_count += texture_units + vertex_program_attribs; - arrays->num_arrays = array_count; - arrays->arrays = calloc(array_count, sizeof(struct array_state)); - - arrays->arrays[0].data_type = GL_FLOAT; - arrays->arrays[0].count = 3; - arrays->arrays[0].key = GL_NORMAL_ARRAY; - arrays->arrays[0].normalized = GL_TRUE; - arrays->arrays[0].old_DrawArrays_possible = GL_TRUE; - - arrays->arrays[1].data_type = GL_FLOAT; - arrays->arrays[1].count = 4; - arrays->arrays[1].key = GL_COLOR_ARRAY; - arrays->arrays[1].normalized = GL_TRUE; - arrays->arrays[1].old_DrawArrays_possible = GL_TRUE; - - arrays->arrays[2].data_type = GL_FLOAT; - arrays->arrays[2].count = 1; - arrays->arrays[2].key = GL_INDEX_ARRAY; - arrays->arrays[2].old_DrawArrays_possible = GL_TRUE; - - arrays->arrays[3].data_type = GL_UNSIGNED_BYTE; - arrays->arrays[3].count = 1; - arrays->arrays[3].key = GL_EDGE_FLAG_ARRAY; - arrays->arrays[3].old_DrawArrays_possible = GL_TRUE; - - for (i = 0; i < texture_units; i++) { - arrays->arrays[4 + i].data_type = GL_FLOAT; - arrays->arrays[4 + i].count = 4; - arrays->arrays[4 + i].key = GL_TEXTURE_COORD_ARRAY; - - arrays->arrays[4 + i].old_DrawArrays_possible = (i == 0); - arrays->arrays[4 + i].index = i; - - arrays->arrays[4 + i].header[1] = i + GL_TEXTURE0; - } - - i = 4 + texture_units; - - if (got_fog) { - arrays->arrays[i].data_type = GL_FLOAT; - arrays->arrays[i].count = 1; - arrays->arrays[i].key = GL_FOG_COORDINATE_ARRAY; - arrays->arrays[i].old_DrawArrays_possible = GL_TRUE; - i++; - } - - if (got_secondary_color) { - arrays->arrays[i].data_type = GL_FLOAT; - arrays->arrays[i].count = 3; - arrays->arrays[i].key = GL_SECONDARY_COLOR_ARRAY; - arrays->arrays[i].old_DrawArrays_possible = GL_TRUE; - arrays->arrays[i].normalized = GL_TRUE; - i++; - } - - - for (j = 0; j < vertex_program_attribs; j++) { - const unsigned idx = (vertex_program_attribs - (j + 1)); - - - arrays->arrays[idx + i].data_type = GL_FLOAT; - arrays->arrays[idx + i].count = 4; - arrays->arrays[idx + i].key = GL_VERTEX_ATTRIB_ARRAY_POINTER; - - arrays->arrays[idx + i].old_DrawArrays_possible = 0; - arrays->arrays[idx + i].index = idx; - - arrays->arrays[idx + i].header[1] = idx; - } - - i += vertex_program_attribs; - - - /* Vertex array *must* be last becuase of the way that - * emit_DrawArrays_none works. - */ - - arrays->arrays[i].data_type = GL_FLOAT; - arrays->arrays[i].count = 4; - arrays->arrays[i].key = GL_VERTEX_ARRAY; - arrays->arrays[i].old_DrawArrays_possible = GL_TRUE; - - assert((i + 1) == arrays->num_arrays); - - arrays->stack_index = 0; - arrays->stack = malloc(sizeof(struct array_stack_state) - * arrays->num_arrays); -} - - -/** - * Calculate the size of a single vertex for the "none" protocol. This is - * essentially the size of all the immediate-mode commands required to - * implement the enabled vertex arrays. - */ -static size_t -calculate_single_vertex_size_none(const struct array_state_vector *arrays) -{ - size_t single_vertex_size = 0; - unsigned i; - - - for (i = 0; i < arrays->num_arrays; i++) { - if (arrays->arrays[i].enabled) { - single_vertex_size += ((uint16_t *) arrays->arrays[i].header)[0]; - } - } - - return single_vertex_size; -} - - -/** - * Emit a single element using non-DrawArrays protocol. - */ -GLubyte * -emit_element_none(GLubyte * dst, - const struct array_state_vector * arrays, unsigned index) -{ - unsigned i; - - - for (i = 0; i < arrays->num_arrays; i++) { - if (arrays->arrays[i].enabled) { - const size_t offset = index * arrays->arrays[i].true_stride; - - /* The generic attributes can have more data than is in the - * elements. This is because a vertex array can be a 2 element, - * normalized, unsigned short, but the "closest" immediate mode - * protocol is for a 4Nus. Since the sizes are small, the - * performance impact on modern processors should be negligible. - */ - (void) memset(dst, 0, ((uint16_t *) arrays->arrays[i].header)[0]); - - (void) memcpy(dst, arrays->arrays[i].header, - arrays->arrays[i].header_size); - - dst += arrays->arrays[i].header_size; - - (void) memcpy(dst, ((GLubyte *) arrays->arrays[i].data) + offset, - arrays->arrays[i].element_size); - - dst += __GLX_PAD(arrays->arrays[i].element_size); - } - } - - return dst; -} - - -/** - * Emit a single element using "old" DrawArrays protocol from - * EXT_vertex_arrays / OpenGL 1.1. - */ -GLubyte * -emit_element_old(GLubyte * dst, - const struct array_state_vector * arrays, unsigned index) -{ - unsigned i; - - - for (i = 0; i < arrays->num_arrays; i++) { - if (arrays->arrays[i].enabled) { - const size_t offset = index * arrays->arrays[i].true_stride; - - (void) memcpy(dst, ((GLubyte *) arrays->arrays[i].data) + offset, - arrays->arrays[i].element_size); - - dst += __GLX_PAD(arrays->arrays[i].element_size); - } - } - - return dst; -} - - -struct array_state * -get_array_entry(const struct array_state_vector *arrays, - GLenum key, unsigned index) -{ - unsigned i; - - for (i = 0; i < arrays->num_arrays; i++) { - if ((arrays->arrays[i].key == key) - && (arrays->arrays[i].index == index)) { - return &arrays->arrays[i]; - } - } - - return NULL; -} - - -static GLboolean -allocate_array_info_cache(struct array_state_vector *arrays, - size_t required_size) -{ -#define MAX_HEADER_SIZE 20 - if (arrays->array_info_cache_buffer_size < required_size) { - GLubyte *temp = realloc(arrays->array_info_cache_base, - required_size + MAX_HEADER_SIZE); - - if (temp == NULL) { - return GL_FALSE; - } - - arrays->array_info_cache_base = temp; - arrays->array_info_cache = temp + MAX_HEADER_SIZE; - arrays->array_info_cache_buffer_size = required_size; - } - - arrays->array_info_cache_size = required_size; - return GL_TRUE; -} - - -/** - */ -void -fill_array_info_cache(struct array_state_vector *arrays) -{ - GLboolean old_DrawArrays_possible; - unsigned i; - - - /* Determine how many arrays are enabled. - */ - - arrays->enabled_client_array_count = 0; - old_DrawArrays_possible = arrays->old_DrawArrays_possible; - for (i = 0; i < arrays->num_arrays; i++) { - if (arrays->arrays[i].enabled) { - arrays->enabled_client_array_count++; - old_DrawArrays_possible &= arrays->arrays[i].old_DrawArrays_possible; - } - } - - if (arrays->new_DrawArrays_possible) { - assert(!arrays->new_DrawArrays_possible); - } - else if (old_DrawArrays_possible) { - const size_t required_size = arrays->enabled_client_array_count * 12; - uint32_t *info; - - - if (!allocate_array_info_cache(arrays, required_size)) { - return; - } - - - info = (uint32_t *) arrays->array_info_cache; - for (i = 0; i < arrays->num_arrays; i++) { - if (arrays->arrays[i].enabled) { - *(info++) = arrays->arrays[i].data_type; - *(info++) = arrays->arrays[i].count; - *(info++) = arrays->arrays[i].key; - } - } - - arrays->DrawArrays = emit_DrawArrays_old; - arrays->DrawElements = emit_DrawElements_old; - } - else { - arrays->DrawArrays = emit_DrawArrays_none; - arrays->DrawElements = emit_DrawElements_none; - } - - arrays->array_info_cache_valid = GL_TRUE; -} - - -/** - * Emit a \c glDrawArrays command using the "none" protocol. That is, - * emit immediate-mode commands that are equivalent to the requiested - * \c glDrawArrays command. This is used with servers that don't support - * the OpenGL 1.1 / EXT_vertex_arrays DrawArrays protocol or in cases where - * vertex state is enabled that is not compatible with that protocol. - */ -void -emit_DrawArrays_none(GLenum mode, GLint first, GLsizei count) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - const __GLXattribute *state = - (const __GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - - size_t single_vertex_size; - GLubyte *pc; - unsigned i; - static const uint16_t begin_cmd[2] = { 8, X_GLrop_Begin }; - static const uint16_t end_cmd[2] = { 4, X_GLrop_End }; - - - single_vertex_size = calculate_single_vertex_size_none(arrays); - - pc = gc->pc; - - (void) memcpy(pc, begin_cmd, 4); - *(int *) (pc + 4) = mode; - - pc += 8; - - for (i = 0; i < count; i++) { - if ((pc + single_vertex_size) >= gc->bufEnd) { - pc = __glXFlushRenderBuffer(gc, pc); - } - - pc = emit_element_none(pc, arrays, first + i); - } - - if ((pc + 4) >= gc->bufEnd) { - pc = __glXFlushRenderBuffer(gc, pc); - } - - (void) memcpy(pc, end_cmd, 4); - pc += 4; - - gc->pc = pc; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - - -/** - * Emit the header data for the GL 1.1 / EXT_vertex_arrays DrawArrays - * protocol. - * - * \param gc GLX context. - * \param arrays Array state. - * \param elements_per_request Location to store the number of elements that - * can fit in a single Render / RenderLarge - * command. - * \param total_request Total number of requests for a RenderLarge - * command. If a Render command is used, this - * will be zero. - * \param mode Drawing mode. - * \param count Number of vertices. - * - * \returns - * A pointer to the buffer for array data. - */ -static GLubyte * -emit_DrawArrays_header_old(__GLXcontext * gc, - struct array_state_vector *arrays, - size_t * elements_per_request, - unsigned int *total_requests, - GLenum mode, GLsizei count) -{ - size_t command_size; - size_t single_vertex_size; - const unsigned header_size = 16; - unsigned i; - GLubyte *pc; - - - /* Determine the size of the whole command. This includes the header, - * the ARRAY_INFO data and the array data. Once this size is calculated, - * it will be known whether a Render or RenderLarge command is needed. - */ - - single_vertex_size = 0; - for (i = 0; i < arrays->num_arrays; i++) { - if (arrays->arrays[i].enabled) { - single_vertex_size += __GLX_PAD(arrays->arrays[i].element_size); - } - } - - command_size = arrays->array_info_cache_size + header_size - + (single_vertex_size * count); - - - /* Write the header for either a Render command or a RenderLarge - * command. After the header is written, write the ARRAY_INFO data. - */ - - if (command_size > gc->maxSmallRenderCommandSize) { - /* maxSize is the maximum amount of data can be stuffed into a single - * packet. sz_xGLXRenderReq is added because bufSize is the maximum - * packet size minus sz_xGLXRenderReq. - */ - const size_t maxSize = (gc->bufSize + sz_xGLXRenderReq) - - sz_xGLXRenderLargeReq; - unsigned vertex_requests; - - - /* Calculate the number of data packets that will be required to send - * the whole command. To do this, the number of verticies that - * will fit in a single buffer must be calculated. - * - * The important value here is elements_per_request. This is the - * number of complete array elements that will fit in a single - * buffer. There may be some wasted space at the end of the buffer, - * but splitting elements across buffer boundries would be painful. - */ - - elements_per_request[0] = maxSize / single_vertex_size; - - vertex_requests = (count + elements_per_request[0] - 1) - / elements_per_request[0]; - - *total_requests = vertex_requests + 1; - - - __glXFlushRenderBuffer(gc, gc->pc); - - command_size += 4; - - pc = ((GLubyte *) arrays->array_info_cache) - (header_size + 4); - *(uint32_t *) (pc + 0) = command_size; - *(uint32_t *) (pc + 4) = X_GLrop_DrawArrays; - *(uint32_t *) (pc + 8) = count; - *(uint32_t *) (pc + 12) = arrays->enabled_client_array_count; - *(uint32_t *) (pc + 16) = mode; - - __glXSendLargeChunk(gc, 1, *total_requests, pc, - header_size + 4 + arrays->array_info_cache_size); - - pc = gc->pc; - } - else { - if ((gc->pc + command_size) >= gc->bufEnd) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - - pc = gc->pc; - *(uint16_t *) (pc + 0) = command_size; - *(uint16_t *) (pc + 2) = X_GLrop_DrawArrays; - *(uint32_t *) (pc + 4) = count; - *(uint32_t *) (pc + 8) = arrays->enabled_client_array_count; - *(uint32_t *) (pc + 12) = mode; - - pc += header_size; - - (void) memcpy(pc, arrays->array_info_cache, - arrays->array_info_cache_size); - pc += arrays->array_info_cache_size; - - *elements_per_request = count; - *total_requests = 0; - } - - - return pc; -} - - -/** - */ -void -emit_DrawArrays_old(GLenum mode, GLint first, GLsizei count) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - const __GLXattribute *state = - (const __GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - - GLubyte *pc; - size_t elements_per_request; - unsigned total_requests = 0; - unsigned i; - size_t total_sent = 0; - - - pc = emit_DrawArrays_header_old(gc, arrays, &elements_per_request, - &total_requests, mode, count); - - - /* Write the arrays. - */ - - if (total_requests == 0) { - assert(elements_per_request >= count); - - for (i = 0; i < count; i++) { - pc = emit_element_old(pc, arrays, i + first); - } - - assert(pc <= gc->bufEnd); - - gc->pc = pc; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } - else { - unsigned req; - - - for (req = 2; req <= total_requests; req++) { - if (count < elements_per_request) { - elements_per_request = count; - } - - pc = gc->pc; - for (i = 0; i < elements_per_request; i++) { - pc = emit_element_old(pc, arrays, i + first); - } - - first += elements_per_request; - - total_sent += (size_t) (pc - gc->pc); - __glXSendLargeChunk(gc, req, total_requests, gc->pc, pc - gc->pc); - - count -= elements_per_request; - } - } -} - - -void -emit_DrawElements_none(GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - const __GLXattribute *state = - (const __GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - static const uint16_t begin_cmd[2] = { 8, X_GLrop_Begin }; - static const uint16_t end_cmd[2] = { 4, X_GLrop_End }; - - GLubyte *pc; - size_t single_vertex_size; - unsigned i; - - - single_vertex_size = calculate_single_vertex_size_none(arrays); - - - if ((gc->pc + single_vertex_size) >= gc->bufEnd) { - gc->pc = __glXFlushRenderBuffer(gc, gc->pc); - } - - pc = gc->pc; - - (void) memcpy(pc, begin_cmd, 4); - *(int *) (pc + 4) = mode; - - pc += 8; - - for (i = 0; i < count; i++) { - unsigned index = 0; - - if ((pc + single_vertex_size) >= gc->bufEnd) { - pc = __glXFlushRenderBuffer(gc, pc); - } - - switch (type) { - case GL_UNSIGNED_INT: - index = (unsigned) (((GLuint *) indices)[i]); - break; - case GL_UNSIGNED_SHORT: - index = (unsigned) (((GLushort *) indices)[i]); - break; - case GL_UNSIGNED_BYTE: - index = (unsigned) (((GLubyte *) indices)[i]); - break; - } - pc = emit_element_none(pc, arrays, index); - } - - if ((pc + 4) >= gc->bufEnd) { - pc = __glXFlushRenderBuffer(gc, pc); - } - - (void) memcpy(pc, end_cmd, 4); - pc += 4; - - gc->pc = pc; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - - -/** - */ -void -emit_DrawElements_old(GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - const __GLXattribute *state = - (const __GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - - GLubyte *pc; - size_t elements_per_request; - unsigned total_requests = 0; - unsigned i; - unsigned req; - unsigned req_element = 0; - - - pc = emit_DrawArrays_header_old(gc, arrays, &elements_per_request, - &total_requests, mode, count); - - - /* Write the arrays. - */ - - req = 2; - while (count > 0) { - if (count < elements_per_request) { - elements_per_request = count; - } - - switch (type) { - case GL_UNSIGNED_INT:{ - const GLuint *ui_ptr = (const GLuint *) indices + req_element; - - for (i = 0; i < elements_per_request; i++) { - const GLint index = (GLint) * (ui_ptr++); - pc = emit_element_old(pc, arrays, index); - } - break; - } - case GL_UNSIGNED_SHORT:{ - const GLushort *us_ptr = (const GLushort *) indices + req_element; - - for (i = 0; i < elements_per_request; i++) { - const GLint index = (GLint) * (us_ptr++); - pc = emit_element_old(pc, arrays, index); - } - break; - } - case GL_UNSIGNED_BYTE:{ - const GLubyte *ub_ptr = (const GLubyte *) indices + req_element; - - for (i = 0; i < elements_per_request; i++) { - const GLint index = (GLint) * (ub_ptr++); - pc = emit_element_old(pc, arrays, index); - } - break; - } - } - - if (total_requests != 0) { - __glXSendLargeChunk(gc, req, total_requests, gc->pc, pc - gc->pc); - pc = gc->pc; - req++; - } - - count -= elements_per_request; - req_element += elements_per_request; - } - - - assert((total_requests == 0) || ((req - 1) == total_requests)); - - if (total_requests == 0) { - assert(pc <= gc->bufEnd); - - gc->pc = pc; - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } - } -} - - -/** - * Validate that the \c mode parameter to \c glDrawArrays, et. al. is valid. - * If it is not valid, then an error code is set in the GLX context. - * - * \returns - * \c GL_TRUE if the argument is valid, \c GL_FALSE if is not. - */ -static GLboolean -validate_mode(__GLXcontext * gc, GLenum mode) -{ - switch (mode) { - case GL_POINTS: - case GL_LINE_STRIP: - case GL_LINE_LOOP: - case GL_LINES: - case GL_TRIANGLE_STRIP: - case GL_TRIANGLE_FAN: - case GL_TRIANGLES: - case GL_QUAD_STRIP: - case GL_QUADS: - case GL_POLYGON: - break; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return GL_FALSE; - } - - return GL_TRUE; -} - - -/** - * Validate that the \c count parameter to \c glDrawArrays, et. al. is valid. - * A value less than zero is invalid and will result in \c GL_INVALID_VALUE - * being set. A value of zero will not result in an error being set, but - * will result in \c GL_FALSE being returned. - * - * \returns - * \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not. - */ -static GLboolean -validate_count(__GLXcontext * gc, GLsizei count) -{ - if (count < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - } - - return (count > 0); -} - - -/** - * Validate that the \c type parameter to \c glDrawElements, et. al. is - * valid. Only \c GL_UNSIGNED_BYTE, \c GL_UNSIGNED_SHORT, and - * \c GL_UNSIGNED_INT are valid. - * - * \returns - * \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not. - */ -static GLboolean -validate_type(__GLXcontext * gc, GLenum type) -{ - switch (type) { - case GL_UNSIGNED_INT: - case GL_UNSIGNED_SHORT: - case GL_UNSIGNED_BYTE: - return GL_TRUE; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return GL_FALSE; - } -} - - -void -__indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - const __GLXattribute *state = - (const __GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - - - if (validate_mode(gc, mode) && validate_count(gc, count)) { - if (!arrays->array_info_cache_valid) { - fill_array_info_cache(arrays); - } - - arrays->DrawArrays(mode, first, count); - } -} - - -void -__indirect_glArrayElement(GLint index) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - const __GLXattribute *state = - (const __GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - - size_t single_vertex_size; - - - single_vertex_size = calculate_single_vertex_size_none(arrays); - - if ((gc->pc + single_vertex_size) >= gc->bufEnd) { - gc->pc = __glXFlushRenderBuffer(gc, gc->pc); - } - - gc->pc = emit_element_none(gc->pc, arrays, index); - - if (gc->pc > gc->limit) { - (void) __glXFlushRenderBuffer(gc, gc->pc); - } -} - - -void -__indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - const __GLXattribute *state = - (const __GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - - - if (validate_mode(gc, mode) && validate_count(gc, count) - && validate_type(gc, type)) { - if (!arrays->array_info_cache_valid) { - fill_array_info_cache(arrays); - } - - arrays->DrawElements(mode, count, type, indices); - } -} - - -void -__indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid * indices) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - const __GLXattribute *state = - (const __GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - - - if (validate_mode(gc, mode) && validate_count(gc, count) - && validate_type(gc, type)) { - if (end < start) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - - if (!arrays->array_info_cache_valid) { - fill_array_info_cache(arrays); - } - - arrays->DrawElements(mode, count, type, indices); - } -} - - -void -__indirect_glMultiDrawArraysEXT(GLenum mode, GLint * first, GLsizei * count, - GLsizei primcount) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - const __GLXattribute *state = - (const __GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - GLsizei i; - - - if (validate_mode(gc, mode)) { - if (!arrays->array_info_cache_valid) { - fill_array_info_cache(arrays); - } - - for (i = 0; i < primcount; i++) { - if (validate_count(gc, count[i])) { - arrays->DrawArrays(mode, first[i], count[i]); - } - } - } -} - - -void -__indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count, - GLenum type, const GLvoid ** indices, - GLsizei primcount) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - const __GLXattribute *state = - (const __GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - GLsizei i; - - - if (validate_mode(gc, mode) && validate_type(gc, type)) { - if (!arrays->array_info_cache_valid) { - fill_array_info_cache(arrays); - } - - for (i = 0; i < primcount; i++) { - if (validate_count(gc, count[i])) { - arrays->DrawElements(mode, count[i], type, indices[i]); - } - } - } -} - - -#define COMMON_ARRAY_DATA_INIT(a, PTR, TYPE, STRIDE, COUNT, NORMALIZED, HDR_SIZE, OPCODE) \ - do { \ - (a)->data = PTR; \ - (a)->data_type = TYPE; \ - (a)->user_stride = STRIDE; \ - (a)->count = COUNT; \ - (a)->normalized = NORMALIZED; \ - \ - (a)->element_size = __glXTypeSize( TYPE ) * COUNT; \ - (a)->true_stride = (STRIDE == 0) \ - ? (a)->element_size : STRIDE; \ - \ - (a)->header_size = HDR_SIZE; \ - ((uint16_t *) (a)->header)[0] = __GLX_PAD((a)->header_size + (a)->element_size); \ - ((uint16_t *) (a)->header)[1] = OPCODE; \ - } while(0) - - -void -__indirect_glVertexPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid * pointer) -{ - static const uint16_t short_ops[5] = { - 0, 0, X_GLrop_Vertex2sv, X_GLrop_Vertex3sv, X_GLrop_Vertex4sv - }; - static const uint16_t int_ops[5] = { - 0, 0, X_GLrop_Vertex2iv, X_GLrop_Vertex3iv, X_GLrop_Vertex4iv - }; - static const uint16_t float_ops[5] = { - 0, 0, X_GLrop_Vertex2fv, X_GLrop_Vertex3fv, X_GLrop_Vertex4fv - }; - static const uint16_t double_ops[5] = { - 0, 0, X_GLrop_Vertex2dv, X_GLrop_Vertex3dv, X_GLrop_Vertex4dv - }; - uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - struct array_state *a; - - - if (size < 2 || size > 4 || stride < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - - switch (type) { - case GL_SHORT: - opcode = short_ops[size]; - break; - case GL_INT: - opcode = int_ops[size]; - break; - case GL_FLOAT: - opcode = float_ops[size]; - break; - case GL_DOUBLE: - opcode = double_ops[size]; - break; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - - a = get_array_entry(arrays, GL_VERTEX_ARRAY, 0); - assert(a != NULL); - COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_FALSE, 4, - opcode); - - if (a->enabled) { - arrays->array_info_cache_valid = GL_FALSE; - } -} - - -void -__indirect_glNormalPointer(GLenum type, GLsizei stride, - const GLvoid * pointer) -{ - uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - struct array_state *a; - - - if (stride < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - - switch (type) { - case GL_BYTE: - opcode = X_GLrop_Normal3bv; - break; - case GL_SHORT: - opcode = X_GLrop_Normal3sv; - break; - case GL_INT: - opcode = X_GLrop_Normal3iv; - break; - case GL_FLOAT: - opcode = X_GLrop_Normal3fv; - break; - case GL_DOUBLE: - opcode = X_GLrop_Normal3dv; - break; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - - a = get_array_entry(arrays, GL_NORMAL_ARRAY, 0); - assert(a != NULL); - COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, 3, GL_TRUE, 4, opcode); - - if (a->enabled) { - arrays->array_info_cache_valid = GL_FALSE; - } -} - - -void -__indirect_glColorPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid * pointer) -{ - static const uint16_t byte_ops[5] = { - 0, 0, 0, X_GLrop_Color3bv, X_GLrop_Color4bv - }; - static const uint16_t ubyte_ops[5] = { - 0, 0, 0, X_GLrop_Color3ubv, X_GLrop_Color4ubv - }; - static const uint16_t short_ops[5] = { - 0, 0, 0, X_GLrop_Color3sv, X_GLrop_Color4sv - }; - static const uint16_t ushort_ops[5] = { - 0, 0, 0, X_GLrop_Color3usv, X_GLrop_Color4usv - }; - static const uint16_t int_ops[5] = { - 0, 0, 0, X_GLrop_Color3iv, X_GLrop_Color4iv - }; - static const uint16_t uint_ops[5] = { - 0, 0, 0, X_GLrop_Color3uiv, X_GLrop_Color4uiv - }; - static const uint16_t float_ops[5] = { - 0, 0, 0, X_GLrop_Color3fv, X_GLrop_Color4fv - }; - static const uint16_t double_ops[5] = { - 0, 0, 0, X_GLrop_Color3dv, X_GLrop_Color4dv - }; - uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - struct array_state *a; - - - if (size < 3 || size > 4 || stride < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - - switch (type) { - case GL_BYTE: - opcode = byte_ops[size]; - break; - case GL_UNSIGNED_BYTE: - opcode = ubyte_ops[size]; - break; - case GL_SHORT: - opcode = short_ops[size]; - break; - case GL_UNSIGNED_SHORT: - opcode = ushort_ops[size]; - break; - case GL_INT: - opcode = int_ops[size]; - break; - case GL_UNSIGNED_INT: - opcode = uint_ops[size]; - break; - case GL_FLOAT: - opcode = float_ops[size]; - break; - case GL_DOUBLE: - opcode = double_ops[size]; - break; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - - a = get_array_entry(arrays, GL_COLOR_ARRAY, 0); - assert(a != NULL); - COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_TRUE, 4, opcode); - - if (a->enabled) { - arrays->array_info_cache_valid = GL_FALSE; - } -} - - -void -__indirect_glIndexPointer(GLenum type, GLsizei stride, const GLvoid * pointer) -{ - uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - struct array_state *a; - - - if (stride < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - - switch (type) { - case GL_UNSIGNED_BYTE: - opcode = X_GLrop_Indexubv; - break; - case GL_SHORT: - opcode = X_GLrop_Indexsv; - break; - case GL_INT: - opcode = X_GLrop_Indexiv; - break; - case GL_FLOAT: - opcode = X_GLrop_Indexfv; - break; - case GL_DOUBLE: - opcode = X_GLrop_Indexdv; - break; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - - a = get_array_entry(arrays, GL_INDEX_ARRAY, 0); - assert(a != NULL); - COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, 1, GL_FALSE, 4, opcode); - - if (a->enabled) { - arrays->array_info_cache_valid = GL_FALSE; - } -} - - -void -__indirect_glEdgeFlagPointer(GLsizei stride, const GLvoid * pointer) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - struct array_state *a; - - - if (stride < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - - - a = get_array_entry(arrays, GL_EDGE_FLAG_ARRAY, 0); - assert(a != NULL); - COMMON_ARRAY_DATA_INIT(a, pointer, GL_UNSIGNED_BYTE, stride, 1, GL_FALSE, - 4, X_GLrop_EdgeFlagv); - - if (a->enabled) { - arrays->array_info_cache_valid = GL_FALSE; - } -} - - -void -__indirect_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid * pointer) -{ - static const uint16_t short_ops[5] = { - 0, X_GLrop_TexCoord1sv, X_GLrop_TexCoord2sv, X_GLrop_TexCoord3sv, - X_GLrop_TexCoord4sv - }; - static const uint16_t int_ops[5] = { - 0, X_GLrop_TexCoord1iv, X_GLrop_TexCoord2iv, X_GLrop_TexCoord3iv, - X_GLrop_TexCoord4iv - }; - static const uint16_t float_ops[5] = { - 0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2fv, X_GLrop_TexCoord3fv, - X_GLrop_TexCoord4fv - }; - static const uint16_t double_ops[5] = { - 0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2dv, X_GLrop_TexCoord3dv, - X_GLrop_TexCoord4dv - }; - - static const uint16_t mshort_ops[5] = { - 0, X_GLrop_MultiTexCoord1svARB, X_GLrop_MultiTexCoord2svARB, - X_GLrop_MultiTexCoord3svARB, X_GLrop_MultiTexCoord4svARB - }; - static const uint16_t mint_ops[5] = { - 0, X_GLrop_MultiTexCoord1ivARB, X_GLrop_MultiTexCoord2ivARB, - X_GLrop_MultiTexCoord3ivARB, X_GLrop_MultiTexCoord4ivARB - }; - static const uint16_t mfloat_ops[5] = { - 0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2fvARB, - X_GLrop_MultiTexCoord3fvARB, X_GLrop_MultiTexCoord4fvARB - }; - static const uint16_t mdouble_ops[5] = { - 0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2dvARB, - X_GLrop_MultiTexCoord3dvARB, X_GLrop_MultiTexCoord4dvARB - }; - - uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - struct array_state *a; - unsigned header_size; - unsigned index; - - - if (size < 1 || size > 4 || stride < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - - index = arrays->active_texture_unit; - if (index == 0) { - switch (type) { - case GL_SHORT: - opcode = short_ops[size]; - break; - case GL_INT: - opcode = int_ops[size]; - break; - case GL_FLOAT: - opcode = float_ops[size]; - break; - case GL_DOUBLE: - opcode = double_ops[size]; - break; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - - header_size = 4; - } - else { - switch (type) { - case GL_SHORT: - opcode = mshort_ops[size]; - break; - case GL_INT: - opcode = mint_ops[size]; - break; - case GL_FLOAT: - opcode = mfloat_ops[size]; - break; - case GL_DOUBLE: - opcode = mdouble_ops[size]; - break; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - - header_size = 8; - } - - a = get_array_entry(arrays, GL_TEXTURE_COORD_ARRAY, index); - assert(a != NULL); - COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_FALSE, - header_size, opcode); - - if (a->enabled) { - arrays->array_info_cache_valid = GL_FALSE; - } -} - - -void -__indirect_glSecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, - const GLvoid * pointer) -{ - uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - struct array_state *a; - - - if (size != 3 || stride < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - - switch (type) { - case GL_BYTE: - opcode = 4126; - break; - case GL_UNSIGNED_BYTE: - opcode = 4131; - break; - case GL_SHORT: - opcode = 4127; - break; - case GL_UNSIGNED_SHORT: - opcode = 4132; - break; - case GL_INT: - opcode = 4128; - break; - case GL_UNSIGNED_INT: - opcode = 4133; - break; - case GL_FLOAT: - opcode = 4129; - break; - case GL_DOUBLE: - opcode = 4130; - break; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - - a = get_array_entry(arrays, GL_SECONDARY_COLOR_ARRAY, 0); - if (a == NULL) { - __glXSetError(gc, GL_INVALID_OPERATION); - return; - } - - COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_TRUE, 4, opcode); - - if (a->enabled) { - arrays->array_info_cache_valid = GL_FALSE; - } -} - - -void -__indirect_glFogCoordPointerEXT(GLenum type, GLsizei stride, - const GLvoid * pointer) -{ - uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - struct array_state *a; - - - if (stride < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - - switch (type) { - case GL_FLOAT: - opcode = 4124; - break; - case GL_DOUBLE: - opcode = 4125; - break; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - - a = get_array_entry(arrays, GL_FOG_COORD_ARRAY, 0); - if (a == NULL) { - __glXSetError(gc, GL_INVALID_OPERATION); - return; - } - - COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, 1, GL_FALSE, 4, opcode); - - if (a->enabled) { - arrays->array_info_cache_valid = GL_FALSE; - } -} - - -void -__indirect_glVertexAttribPointerARB(GLuint index, GLint size, - GLenum type, GLboolean normalized, - GLsizei stride, const GLvoid * pointer) -{ - static const uint16_t short_ops[5] = { 0, 4189, 4190, 4191, 4192 }; - static const uint16_t float_ops[5] = { 0, 4193, 4194, 4195, 4196 }; - static const uint16_t double_ops[5] = { 0, 4197, 4198, 4199, 4200 }; - - uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - struct array_state_vector *arrays = state->array_state; - struct array_state *a; - unsigned true_immediate_count; - unsigned true_immediate_size; - - - if ((size < 1) || (size > 4) || (stride < 0) - || (index > arrays->num_vertex_program_attribs)) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - - if (normalized && (type != GL_FLOAT) && (type != GL_DOUBLE)) { - switch (type) { - case GL_BYTE: - opcode = X_GLrop_VertexAttrib4NbvARB; - break; - case GL_UNSIGNED_BYTE: - opcode = X_GLrop_VertexAttrib4NubvARB; - break; - case GL_SHORT: - opcode = X_GLrop_VertexAttrib4NsvARB; - break; - case GL_UNSIGNED_SHORT: - opcode = X_GLrop_VertexAttrib4NusvARB; - break; - case GL_INT: - opcode = X_GLrop_VertexAttrib4NivARB; - break; - case GL_UNSIGNED_INT: - opcode = X_GLrop_VertexAttrib4NuivARB; - break; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - - true_immediate_count = 4; - } - else { - true_immediate_count = size; - - switch (type) { - case GL_BYTE: - opcode = X_GLrop_VertexAttrib4bvARB; - true_immediate_count = 4; - break; - case GL_UNSIGNED_BYTE: - opcode = X_GLrop_VertexAttrib4ubvARB; - true_immediate_count = 4; - break; - case GL_SHORT: - opcode = short_ops[size]; - break; - case GL_UNSIGNED_SHORT: - opcode = X_GLrop_VertexAttrib4usvARB; - true_immediate_count = 4; - break; - case GL_INT: - opcode = X_GLrop_VertexAttrib4ivARB; - true_immediate_count = 4; - break; - case GL_UNSIGNED_INT: - opcode = X_GLrop_VertexAttrib4uivARB; - true_immediate_count = 4; - break; - case GL_FLOAT: - opcode = float_ops[size]; - break; - case GL_DOUBLE: - opcode = double_ops[size]; - break; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - } - - a = get_array_entry(arrays, GL_VERTEX_ATTRIB_ARRAY_POINTER, index); - if (a == NULL) { - __glXSetError(gc, GL_INVALID_OPERATION); - return; - } - - COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, normalized, 8, - opcode); - - true_immediate_size = __glXTypeSize(type) * true_immediate_count; - ((uint16_t *) (a)->header)[0] = __GLX_PAD(a->header_size - + true_immediate_size); - - if (a->enabled) { - arrays->array_info_cache_valid = GL_FALSE; - } -} - - -/** - * I don't have 100% confidence that this is correct. The different rules - * about whether or not generic vertex attributes alias "classic" vertex - * attributes (i.e., attrib1 ?= primary color) between ARB_vertex_program, - * ARB_vertex_shader, and NV_vertex_program are a bit confusing. My - * feeling is that the client-side doesn't have to worry about it. The - * client just sends all the data to the server and lets the server deal - * with it. - */ -void -__indirect_glVertexAttribPointerNV(GLuint index, GLint size, - GLenum type, GLsizei stride, - const GLvoid * pointer) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - GLboolean normalized = GL_FALSE; - - - switch (type) { - case GL_UNSIGNED_BYTE: - if (size != 4) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - normalized = GL_TRUE; - - case GL_SHORT: - case GL_FLOAT: - case GL_DOUBLE: - __indirect_glVertexAttribPointerARB(index, size, type, - normalized, stride, pointer); - return; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return; - } -} - - -void -__indirect_glClientActiveTextureARB(GLenum texture) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - __GLXattribute *const state = - (__GLXattribute *) (gc->client_state_private); - struct array_state_vector *const arrays = state->array_state; - const GLint unit = (GLint) texture - GL_TEXTURE0; - - - if ((unit < 0) || (unit >= arrays->num_texture_units)) { - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - - arrays->active_texture_unit = unit; -} - - -/** - * Modify the enable state for the selected array - */ -GLboolean -__glXSetArrayEnable(__GLXattribute * state, GLenum key, unsigned index, - GLboolean enable) -{ - struct array_state_vector *arrays = state->array_state; - struct array_state *a; - - - /* Texture coordinate arrays have an implict index set when the - * application calls glClientActiveTexture. - */ - if (key == GL_TEXTURE_COORD_ARRAY) { - index = arrays->active_texture_unit; - } - - a = get_array_entry(arrays, key, index); - - if ((a != NULL) && (a->enabled != enable)) { - a->enabled = enable; - arrays->array_info_cache_valid = GL_FALSE; - } - - return (a != NULL); -} - - -void -__glXArrayDisableAll(__GLXattribute * state) -{ - struct array_state_vector *arrays = state->array_state; - unsigned i; - - - for (i = 0; i < arrays->num_arrays; i++) { - arrays->arrays[i].enabled = GL_FALSE; - } - - arrays->array_info_cache_valid = GL_FALSE; -} - - -/** - */ -GLboolean -__glXGetArrayEnable(const __GLXattribute * const state, - GLenum key, unsigned index, GLintptr * dest) -{ - const struct array_state_vector *arrays = state->array_state; - const struct array_state *a = - get_array_entry((struct array_state_vector *) arrays, - key, index); - - if (a != NULL) { - *dest = (GLintptr) a->enabled; - } - - return (a != NULL); -} - - -/** - */ -GLboolean -__glXGetArrayType(const __GLXattribute * const state, - GLenum key, unsigned index, GLintptr * dest) -{ - const struct array_state_vector *arrays = state->array_state; - const struct array_state *a = - get_array_entry((struct array_state_vector *) arrays, - key, index); - - if (a != NULL) { - *dest = (GLintptr) a->data_type; - } - - return (a != NULL); -} - - -/** - */ -GLboolean -__glXGetArraySize(const __GLXattribute * const state, - GLenum key, unsigned index, GLintptr * dest) -{ - const struct array_state_vector *arrays = state->array_state; - const struct array_state *a = - get_array_entry((struct array_state_vector *) arrays, - key, index); - - if (a != NULL) { - *dest = (GLintptr) a->count; - } - - return (a != NULL); -} - - -/** - */ -GLboolean -__glXGetArrayStride(const __GLXattribute * const state, - GLenum key, unsigned index, GLintptr * dest) -{ - const struct array_state_vector *arrays = state->array_state; - const struct array_state *a = - get_array_entry((struct array_state_vector *) arrays, - key, index); - - if (a != NULL) { - *dest = (GLintptr) a->user_stride; - } - - return (a != NULL); -} - - -/** - */ -GLboolean -__glXGetArrayPointer(const __GLXattribute * const state, - GLenum key, unsigned index, void **dest) -{ - const struct array_state_vector *arrays = state->array_state; - const struct array_state *a = - get_array_entry((struct array_state_vector *) arrays, - key, index); - - - if (a != NULL) { - *dest = (void *) (a->data); - } - - return (a != NULL); -} - - -/** - */ -GLboolean -__glXGetArrayNormalized(const __GLXattribute * const state, - GLenum key, unsigned index, GLintptr * dest) -{ - const struct array_state_vector *arrays = state->array_state; - const struct array_state *a = - get_array_entry((struct array_state_vector *) arrays, - key, index); - - - if (a != NULL) { - *dest = (GLintptr) a->normalized; - } - - return (a != NULL); -} - - -/** - */ -GLuint -__glXGetActiveTextureUnit(const __GLXattribute * const state) -{ - return state->array_state->active_texture_unit; -} - - -void -__glXPushArrayState(__GLXattribute * state) -{ - struct array_state_vector *arrays = state->array_state; - struct array_stack_state *stack = - &arrays->stack[(arrays->stack_index * arrays->num_arrays)]; - unsigned i; - - /* XXX are we pushing _all_ the necessary fields? */ - for (i = 0; i < arrays->num_arrays; i++) { - stack[i].data = arrays->arrays[i].data; - stack[i].data_type = arrays->arrays[i].data_type; - stack[i].user_stride = arrays->arrays[i].user_stride; - stack[i].count = arrays->arrays[i].count; - stack[i].key = arrays->arrays[i].key; - stack[i].index = arrays->arrays[i].index; - stack[i].enabled = arrays->arrays[i].enabled; - } - - arrays->active_texture_unit_stack[arrays->stack_index] = - arrays->active_texture_unit; - - arrays->stack_index++; -} - - -void -__glXPopArrayState(__GLXattribute * state) -{ - struct array_state_vector *arrays = state->array_state; - struct array_stack_state *stack; - unsigned i; - - - arrays->stack_index--; - stack = &arrays->stack[(arrays->stack_index * arrays->num_arrays)]; - - for (i = 0; i < arrays->num_arrays; i++) { - switch (stack[i].key) { - case GL_NORMAL_ARRAY: - __indirect_glNormalPointer(stack[i].data_type, - stack[i].user_stride, stack[i].data); - break; - case GL_COLOR_ARRAY: - __indirect_glColorPointer(stack[i].count, - stack[i].data_type, - stack[i].user_stride, stack[i].data); - break; - case GL_INDEX_ARRAY: - __indirect_glIndexPointer(stack[i].data_type, - stack[i].user_stride, stack[i].data); - break; - case GL_EDGE_FLAG_ARRAY: - __indirect_glEdgeFlagPointer(stack[i].user_stride, stack[i].data); - break; - case GL_TEXTURE_COORD_ARRAY: - arrays->active_texture_unit = stack[i].index; - __indirect_glTexCoordPointer(stack[i].count, - stack[i].data_type, - stack[i].user_stride, stack[i].data); - break; - case GL_SECONDARY_COLOR_ARRAY: - __indirect_glSecondaryColorPointerEXT(stack[i].count, - stack[i].data_type, - stack[i].user_stride, - stack[i].data); - break; - case GL_FOG_COORDINATE_ARRAY: - __indirect_glFogCoordPointerEXT(stack[i].data_type, - stack[i].user_stride, stack[i].data); - break; - - } - - __glXSetArrayEnable(state, stack[i].key, stack[i].index, - stack[i].enabled); - } - - arrays->active_texture_unit = - arrays->active_texture_unit_stack[arrays->stack_index]; -} diff --git a/src/glx/x11/indirect_vertex_array.h b/src/glx/x11/indirect_vertex_array.h deleted file mode 100644 index 37380320edd..00000000000 --- a/src/glx/x11/indirect_vertex_array.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2004, 2005 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef INDIRECT_VERTEX_ARRAY_H -#define INDIRECT_VERTEX_ARRAY_H - -extern const GLuint __glXTypeSize_table[16]; - -#define __glXTypeSize(e) ((((e) & ~0x0f) != 0x1400) \ - ? 0 : __glXTypeSize_table[ (e) & 0x0f ]) - -extern void __glXArrayDisableAll(__GLXattribute * state); - -extern GLboolean __glXSetArrayEnable(__GLXattribute * state, - GLenum key, unsigned index, - GLboolean enable); - -extern GLboolean __glXGetArrayEnable(const __GLXattribute * const state, - GLenum key, unsigned index, - GLintptr * dest); -extern GLboolean __glXGetArraySize(const __GLXattribute * const state, - GLenum key, unsigned index, - GLintptr * dest); -extern GLboolean __glXGetArrayType(const __GLXattribute * const state, - GLenum key, unsigned index, - GLintptr * dest); -extern GLboolean __glXGetArrayStride(const __GLXattribute * const state, - GLenum key, unsigned index, - GLintptr * dest); -extern GLboolean __glXGetArrayPointer(const __GLXattribute * const state, - GLenum key, unsigned index, - void **dest); -extern GLboolean __glXGetArrayNormalized(const __GLXattribute * const state, - GLenum key, unsigned index, - GLintptr * dest); - -extern void __glXPushArrayState(__GLXattribute * state); -extern void __glXPopArrayState(__GLXattribute * state); - -extern GLuint __glXGetActiveTextureUnit(const __GLXattribute * const state); - -#endif /* INDIRECT_VERTEX_ARRAY_H */ diff --git a/src/glx/x11/indirect_vertex_array_priv.h b/src/glx/x11/indirect_vertex_array_priv.h deleted file mode 100644 index 56dac37c783..00000000000 --- a/src/glx/x11/indirect_vertex_array_priv.h +++ /dev/null @@ -1,311 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2004, 2005 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _INDIRECT_VA_PRIVATE_ -#define _INDIRECT_VA_PRIVATE_ - -/** - * \file indirect_va_private.h - * - * \author Ian Romanick - */ - -#include - -#include "glxclient.h" -#include "indirect.h" -#include - - -/** - * State descriptor for a single array of vertex data. - */ -struct array_state -{ - /** - * Pointer to the application supplied data. - */ - const void *data; - - /** - * Enum representing the type of the application supplied data. - */ - GLenum data_type; - - /** - * Stride value supplied by the application. This value is not used - * internally. It is only kept so that it can be queried by the - * application using glGet*v. - */ - GLsizei user_stride; - - /** - * Calculated size, in bytes, of a single element in the array. This - * is calculated based on \c count and the size of the data type - * represented by \c data_type. - */ - GLsizei element_size; - - /** - * Actual byte-stride from one element to the next. This value will - * be equal to either \c user_stride or \c element_stride. - */ - GLsizei true_stride; - - /** - * Number of data values in each element. - */ - GLint count; - - /** - * "Normalized" data is on the range [0,1] (unsigned) or [-1,1] (signed). - * This is used for mapping integral types to floating point types. - */ - GLboolean normalized; - - /** - * Pre-calculated GLX protocol command header. - */ - uint32_t header[2]; - - /** - * Size of the header data. For simple data, like glColorPointerfv, - * this is 4. For complex data that requires either a count (e.g., - * glWeightfvARB), an index (e.g., glVertexAttrib1fvARB), or a - * selector enum (e.g., glMultiTexCoord2fv) this is 8. - */ - unsigned header_size; - - /** - * Set to \c GL_TRUE if this array is enabled. Otherwise, it is set - * to \c GL_FALSE. - */ - GLboolean enabled; - - /** - * For multi-arrayed data (e.g., texture coordinates, generic vertex - * program attributes, etc.), this specifies which array this is. - */ - unsigned index; - - /** - * Per-array-type key. For most arrays, this will be the GL enum for - * that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY - * for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data, - * etc.). - */ - GLenum key; - - /** - * If this array can be used with the "classic" \c glDrawArrays protocol, - * this is set to \c GL_TRUE. Otherwise, it is set to \c GL_FALSE. - */ - GLboolean old_DrawArrays_possible; -}; - - -/** - * Array state that is pushed / poped by \c glPushClientAttrib and - * \c glPopClientAttrib. - */ -struct array_stack_state -{ - /** - * Pointer to the application supplied data. - */ - const void *data; - - /** - * Enum representing the type of the application supplied data. - */ - GLenum data_type; - - /** - * Stride value supplied by the application. This value is not used - * internally. It is only kept so that it can be queried by the - * application using glGet*v. - */ - GLsizei user_stride; - - /** - * Number of data values in each element. - */ - GLint count; - - /** - * Per-array-type key. For most arrays, this will be the GL enum for - * that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY - * for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data, - * etc.). - */ - GLenum key; - - /** - * For multi-arrayed data (e.g., texture coordinates, generic vertex - * program attributes, etc.), this specifies which array this is. - */ - unsigned index; - - /** - * Set to \c GL_TRUE if this array is enabled. Otherwise, it is set - * to \c GL_FALSE. - */ - GLboolean enabled; -}; - - -/** - * Collection of all the vertex array state. - */ -struct array_state_vector -{ - /** - * Number of arrays tracked by \c ::arrays. - */ - size_t num_arrays; - - /** - * Array of vertex array state. This array contains all of the valid - * vertex arrays. If a vertex array isn't in this array, then it isn't - * valid. For example, if an implementation does not support - * EXT_fog_coord, there won't be a GL_FOG_COORD_ARRAY entry in this - * array. - */ - struct array_state *arrays; - - /** - * Number of currently enabled client-side arrays. The value of this - * field is only valid if \c array_info_cache_valid is true. - */ - size_t enabled_client_array_count; - - /** - * \name ARRAY_INFO cache. - * - * These fields track the state of the ARRAY_INFO cache. The - * \c array_info_cache_size is the size of the actual data stored in - * \c array_info_cache. \c array_info_cache_buffer_size is the size of - * the buffer. This will always be greater than or equal to - * \c array_info_cache_size. - * - * \note - * There are some bytes of extra data before \c array_info_cache that is - * used to hold the header for RenderLarge commands. This is - * \b not included in \c array_info_cache_size or - * \c array_info_cache_buffer_size. \c array_info_cache_base stores a - * pointer to the true start of the buffer (i.e., what malloc returned). - */ - /*@{ */ - size_t array_info_cache_size; - size_t array_info_cache_buffer_size; - void *array_info_cache; - void *array_info_cache_base; - /*@} */ - - - /** - * Is the cache of ARRAY_INFO data valid? The cache can become invalid - * when one of several state changes occur. Among these chages are - * modifying the array settings for an enabled array and enabling / - * disabling an array. - */ - GLboolean array_info_cache_valid; - - /** - * Is it possible to use the GL 1.1 / EXT_vertex_arrays protocol? Use - * of this protocol is disabled with really old servers (i.e., servers - * that don't support GL 1.1 or EXT_vertex_arrays) or when an environment - * variable is set. - * - * \todo - * GL 1.1 and EXT_vertex_arrays use identical protocol, but have different - * opcodes for \c glDrawArrays. For servers that advertise one or the - * other, there should be a way to select which opcode to use. - */ - GLboolean old_DrawArrays_possible; - - /** - * Is it possible to use the new GL X.X / ARB_vertex_buffer_object - * protocol? - * - * \todo - * This protocol has not yet been defined by the ARB, but is currently a - * work in progress. This field is a place-holder. - */ - GLboolean new_DrawArrays_possible; - - /** - * Active texture unit set by \c glClientActiveTexture. - * - * \sa __glXGetActiveTextureUnit - */ - unsigned active_texture_unit; - - /** - * Number of supported texture units. Even if ARB_multitexture / - * GL 1.3 are not supported, this will be at least 1. When multitexture - * is supported, this will be the value queried by calling - * \c glGetIntegerv with \c GL_MAX_TEXTURE_UNITS. - * - * \todo - * Investigate if this should be the value of \c GL_MAX_TEXTURE_COORDS - * instead (if GL 2.0 / ARB_fragment_shader / ARB_fragment_program / - * NV_fragment_program are supported). - */ - unsigned num_texture_units; - - /** - * Number of generic vertex program attribs. If GL_ARB_vertex_program - * is not supported, this will be zero. Otherwise it will be the value - * queries by calling \c glGetProgramiv with \c GL_VERTEX_PROGRAM_ARB - * and \c GL_MAX_PROGRAM_ATTRIBS_ARB. - */ - unsigned num_vertex_program_attribs; - - /** - * \n Methods for implementing various GL functions. - * - * These method pointers are only valid \c array_info_cache_valid is set. - * When each function starts, it much check \c array_info_cache_valid. - * If it is not set, it must call \c fill_array_info_cache and call - * the new method. - * - * \sa fill_array_info_cache - * - * \todo - * Write code to plug these functions directly into the dispatch table. - */ - /*@{ */ - void (*DrawArrays) (GLenum, GLint, GLsizei); - void (*DrawElements) (GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices); - /*@} */ - - struct array_stack_state *stack; - unsigned active_texture_unit_stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; - unsigned stack_index; -}; - -#endif /* _INDIRECT_VA_PRIVATE_ */ diff --git a/src/glx/x11/indirect_vertex_program.c b/src/glx/x11/indirect_vertex_program.c deleted file mode 100644 index 3313ac008a5..00000000000 --- a/src/glx/x11/indirect_vertex_program.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2005 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include "indirect.h" -#include "glxclient.h" -#include "indirect_vertex_array.h" -#include - -#if !defined __GNUC__ || __GNUC__ < 3 -# define __builtin_expect(x, y) x -#endif - -static void -do_vertex_attrib_enable(GLuint index, GLboolean val) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - - if (!__glXSetArrayEnable(state, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB, - index, val)) { - __glXSetError(gc, GL_INVALID_ENUM); - } -} - - -void -__indirect_glEnableVertexAttribArrayARB(GLuint index) -{ - do_vertex_attrib_enable(index, GL_TRUE); -} - - -void -__indirect_glDisableVertexAttribArrayARB(GLuint index) -{ - do_vertex_attrib_enable(index, GL_FALSE); -} - - -static void -get_parameter(unsigned opcode, unsigned size, GLenum target, GLuint index, - void *params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 12; - - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = __glXSetupVendorRequest(gc, - X_GLXVendorPrivateWithReply, - opcode, cmdlen); - - *((GLenum *) (pc + 0)) = target; - *((GLuint *) (pc + 4)) = index; - *((GLuint *) (pc + 8)) = 0; - - (void) __glXReadReply(dpy, size, params, GL_FALSE); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - - -void -__indirect_glGetProgramEnvParameterfvARB(GLenum target, GLuint index, - GLfloat * params) -{ - get_parameter(1296, 4, target, index, params); -} - - -void -__indirect_glGetProgramEnvParameterdvARB(GLenum target, GLuint index, - GLdouble * params) -{ - get_parameter(1297, 8, target, index, params); -} - - -void -__indirect_glGetProgramLocalParameterfvARB(GLenum target, GLuint index, - GLfloat * params) -{ - get_parameter(1305, 4, target, index, params); -} - - -void -__indirect_glGetProgramLocalParameterdvARB(GLenum target, GLuint index, - GLdouble * params) -{ - get_parameter(1306, 8, target, index, params); -} - - -void -__indirect_glGetVertexAttribPointervNV(GLuint index, GLenum pname, - GLvoid ** pointer) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - - if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB) { - __glXSetError(gc, GL_INVALID_ENUM); - } - - if (!__glXGetArrayPointer(state, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB, - index, pointer)) { - __glXSetError(gc, GL_INVALID_VALUE); - } -} - - -/** - * Get the selected attribute from the vertex array state vector. - * - * \returns - * On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned. - */ -static GLboolean -get_attrib_array_data(__GLXattribute * state, GLuint index, GLenum cap, - GLintptr * data) -{ - GLboolean retval = GL_FALSE; - const GLenum attrib = GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB; - - switch (cap) { - case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB: - retval = __glXGetArrayEnable(state, attrib, index, data); - break; - - case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB: - retval = __glXGetArraySize(state, attrib, index, data); - break; - - case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB: - retval = __glXGetArrayStride(state, attrib, index, data); - break; - - case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB: - retval = __glXGetArrayType(state, attrib, index, data); - break; - - case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB: - retval = __glXGetArrayNormalized(state, attrib, index, data); - break; - } - - - return retval; -} - - -static void -get_vertex_attrib(__GLXcontext * gc, unsigned vop, - GLuint index, GLenum pname, xReply * reply) -{ - Display *const dpy = gc->currentDpy; - GLubyte *const pc = __glXSetupVendorRequest(gc, - X_GLXVendorPrivateWithReply, - vop, 8); - - *((uint32_t *) (pc + 0)) = index; - *((uint32_t *) (pc + 4)) = pname; - - (void) _XReply(dpy, reply, 0, False); -} - - -void -__indirect_glGetVertexAttribivARB(GLuint index, GLenum pname, GLint * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - xGLXSingleReply reply; - - - get_vertex_attrib(gc, 1303, index, pname, (xReply *) & reply); - - if (reply.size != 0) { - GLintptr data; - - - if (get_attrib_array_data(state, index, pname, &data)) { - *params = (GLint) data; - } - else { - if (reply.size == 1) { - *params = (GLint) reply.pad3; - } - else { - _XRead(dpy, (void *) params, 4 * reply.size); - } - } - } - - UnlockDisplay(dpy); - SyncHandle(); -} - - -void -__indirect_glGetVertexAttribfvARB(GLuint index, GLenum pname, - GLfloat * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - xGLXSingleReply reply; - - - get_vertex_attrib(gc, 1302, index, pname, (xReply *) & reply); - - if (reply.size != 0) { - GLintptr data; - - - if (get_attrib_array_data(state, index, pname, &data)) { - *params = (GLfloat) data; - } - else { - if (reply.size == 1) { - (void) memcpy(params, &reply.pad3, sizeof(GLfloat)); - } - else { - _XRead(dpy, (void *) params, 4 * reply.size); - } - } - } - - UnlockDisplay(dpy); - SyncHandle(); -} - - -void -__indirect_glGetVertexAttribdvARB(GLuint index, GLenum pname, - GLdouble * params) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - xGLXSingleReply reply; - - - get_vertex_attrib(gc, 1301, index, pname, (xReply *) & reply); - - if (reply.size != 0) { - GLintptr data; - - - if (get_attrib_array_data(state, index, pname, &data)) { - *params = (GLdouble) data; - } - else { - if (reply.size == 1) { - (void) memcpy(params, &reply.pad3, sizeof(GLdouble)); - } - else { - _XRead(dpy, (void *) params, 8 * reply.size); - } - } - } - - UnlockDisplay(dpy); - SyncHandle(); -} diff --git a/src/glx/x11/indirect_window_pos.c b/src/glx/x11/indirect_window_pos.c deleted file mode 100644 index e97be3506d1..00000000000 --- a/src/glx/x11/indirect_window_pos.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - * (C) Copyright IBM Corporation 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT, IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include "indirect.h" - -void -__indirect_glWindowPos2dMESA(GLdouble x, GLdouble y) -{ - __indirect_glWindowPos3fMESA(x, y, 0.0); -} - -void -__indirect_glWindowPos2iMESA(GLint x, GLint y) -{ - __indirect_glWindowPos3fMESA(x, y, 0.0); -} - -void -__indirect_glWindowPos2fMESA(GLfloat x, GLfloat y) -{ - __indirect_glWindowPos3fMESA(x, y, 0.0); -} - -void -__indirect_glWindowPos2sMESA(GLshort x, GLshort y) -{ - __indirect_glWindowPos3fMESA(x, y, 0.0); -} - -void -__indirect_glWindowPos2dvMESA(const GLdouble * p) -{ - __indirect_glWindowPos3fMESA(p[0], p[1], 0.0); -} - -void -__indirect_glWindowPos2fvMESA(const GLfloat * p) -{ - __indirect_glWindowPos3fMESA(p[0], p[1], 0.0); -} - -void -__indirect_glWindowPos2ivMESA(const GLint * p) -{ - __indirect_glWindowPos3fMESA(p[0], p[1], 0.0); -} - -void -__indirect_glWindowPos2svMESA(const GLshort * p) -{ - __indirect_glWindowPos3fMESA(p[0], p[1], 0.0); -} - -void -__indirect_glWindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) -{ - __indirect_glWindowPos3fMESA(x, y, z); -} - -void -__indirect_glWindowPos3iMESA(GLint x, GLint y, GLint z) -{ - __indirect_glWindowPos3fMESA(x, y, z); -} - -void -__indirect_glWindowPos3sMESA(GLshort x, GLshort y, GLshort z) -{ - __indirect_glWindowPos3fMESA(x, y, z); -} - -void -__indirect_glWindowPos3dvMESA(const GLdouble * p) -{ - __indirect_glWindowPos3fMESA(p[0], p[1], p[2]); -} - -void -__indirect_glWindowPos3ivMESA(const GLint * p) -{ - __indirect_glWindowPos3fMESA(p[0], p[1], p[2]); -} - -void -__indirect_glWindowPos3svMESA(const GLshort * p) -{ - __indirect_glWindowPos3fMESA(p[0], p[1], p[2]); -} diff --git a/src/glx/x11/packrender.h b/src/glx/x11/packrender.h deleted file mode 100644 index 30f6d44bbd2..00000000000 --- a/src/glx/x11/packrender.h +++ /dev/null @@ -1,243 +0,0 @@ -#ifndef __GLX_packrender_h__ -#define __GLX_packrender_h__ - -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include "glxclient.h" - -/* -** The macros in this header convert the client machine's native data types to -** wire protocol data types. The header is part of the porting layer of the -** client library, and it is intended that hardware vendors will rewrite this -** header to suit their own machines. -*/ - -/* -** Pad a count of bytes to the nearest multiple of 4. The X protocol -** transfers data in 4 byte quantities, so this macro is used to -** insure the right amount of data being sent. -*/ -#define __GLX_PAD(a) (((a)+3) & ~3) - -/* -** Network size parameters -*/ -#define sz_double 8 - -/* Setup for all commands */ -#define __GLX_DECLARE_VARIABLES() \ - __GLXcontext *gc; \ - GLubyte *pc, *pixelHeaderPC; \ - GLuint compsize, cmdlen - -#define __GLX_LOAD_VARIABLES() \ - gc = __glXGetCurrentContext(); \ - pc = gc->pc; \ - /* Muffle compilers */ \ - cmdlen = 0; (void)cmdlen; \ - compsize = 0; (void)compsize; \ - pixelHeaderPC = 0; (void)pixelHeaderPC - -/* -** Variable sized command support macro. This macro is used by calls -** that are potentially larger than __GLX_SMALL_RENDER_CMD_SIZE. -** Because of their size, they may not automatically fit in the buffer. -** If the buffer can't hold the command then it is flushed so that -** the command will fit in the next buffer. -*/ -#define __GLX_BEGIN_VARIABLE(opcode,size) \ - if (pc + (size) > gc->bufEnd) { \ - pc = __glXFlushRenderBuffer(gc, pc); \ - } \ - __GLX_PUT_SHORT(0,size); \ - __GLX_PUT_SHORT(2,opcode) - -#define __GLX_BEGIN_VARIABLE_LARGE(opcode,size) \ - pc = __glXFlushRenderBuffer(gc, pc); \ - __GLX_PUT_LONG(0,size); \ - __GLX_PUT_LONG(4,opcode) - -#define __GLX_BEGIN_VARIABLE_WITH_PIXEL(opcode,size) \ - if (pc + (size) > gc->bufEnd) { \ - pc = __glXFlushRenderBuffer(gc, pc); \ - } \ - __GLX_PUT_SHORT(0,size); \ - __GLX_PUT_SHORT(2,opcode); \ - pc += __GLX_RENDER_HDR_SIZE; \ - pixelHeaderPC = pc; \ - pc += __GLX_PIXEL_HDR_SIZE - -#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(opcode,size) \ - pc = __glXFlushRenderBuffer(gc, pc); \ - __GLX_PUT_LONG(0,size); \ - __GLX_PUT_LONG(4,opcode); \ - pc += __GLX_RENDER_LARGE_HDR_SIZE; \ - pixelHeaderPC = pc; \ - pc += __GLX_PIXEL_HDR_SIZE - -#define __GLX_BEGIN_VARIABLE_WITH_PIXEL_3D(opcode,size) \ - if (pc + (size) > gc->bufEnd) { \ - pc = __glXFlushRenderBuffer(gc, pc); \ - } \ - __GLX_PUT_SHORT(0,size); \ - __GLX_PUT_SHORT(2,opcode); \ - pc += __GLX_RENDER_HDR_SIZE; \ - pixelHeaderPC = pc; \ - pc += __GLX_PIXEL_3D_HDR_SIZE - -#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL_3D(opcode,size) \ - pc = __glXFlushRenderBuffer(gc, pc); \ - __GLX_PUT_LONG(0,size); \ - __GLX_PUT_LONG(4,opcode); \ - pc += __GLX_RENDER_LARGE_HDR_SIZE; \ - pixelHeaderPC = pc; \ - pc += __GLX_PIXEL_3D_HDR_SIZE - -/* -** Fixed size command support macro. This macro is used by calls that -** are never larger than __GLX_SMALL_RENDER_CMD_SIZE. Because they -** always fit in the buffer, and because the buffer promises to -** maintain enough room for them, we don't need to check for space -** before doing the storage work. -*/ -#define __GLX_BEGIN(opcode,size) \ - __GLX_PUT_SHORT(0,size); \ - __GLX_PUT_SHORT(2,opcode) - -/* -** Finish a rendering command by advancing the pc. If the pc is now past -** the limit pointer then there is no longer room for a -** __GLX_SMALL_RENDER_CMD_SIZE sized command, which will break the -** assumptions present in the __GLX_BEGIN macro. In this case the -** rendering buffer is flushed out into the X protocol stream (which may -** or may not do I/O). -*/ -#define __GLX_END(size) \ - pc += size; \ - if (pc > gc->limit) { \ - (void) __glXFlushRenderBuffer(gc, pc); \ - } else { \ - gc->pc = pc; \ - } - -/* Array copy macros */ -#define __GLX_MEM_COPY(dest,src,bytes) \ - if (src && dest) \ - memcpy(dest, src, bytes) - -/* Single item copy macros */ -#define __GLX_PUT_CHAR(offset,a) \ - *((INT8 *) (pc + offset)) = a - -#ifndef _CRAY -#define __GLX_PUT_SHORT(offset,a) \ - *((INT16 *) (pc + offset)) = a - -#define __GLX_PUT_LONG(offset,a) \ - *((INT32 *) (pc + offset)) = a - -#define __GLX_PUT_FLOAT(offset,a) \ - *((FLOAT32 *) (pc + offset)) = a - -#else -#define __GLX_PUT_SHORT(offset,a) \ - { GLubyte *cp = (pc+offset); \ - int shift = (64-16) - ((int)(cp) >> (64-6)); \ - *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); } - -#define __GLX_PUT_LONG(offset,a) \ - { GLubyte *cp = (pc+offset); \ - int shift = (64-32) - ((int)(cp) >> (64-6)); \ - *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); } - -#define __GLX_PUT_FLOAT(offset,a) \ - gl_put_float((pc + offset),a) - -#define __GLX_PUT_DOUBLE(offset,a) \ - gl_put_double(pc + offset, a) - -extern void gl_put_float( /*GLubyte *, struct cray_single */ ); -extern void gl_put_double( /*GLubyte *, struct cray_double */ ); -#endif - -#ifndef _CRAY - -#ifdef __GLX_ALIGN64 -/* -** This can certainly be done better for a particular machine -** architecture! -*/ -#define __GLX_PUT_DOUBLE(offset,a) \ - __GLX_MEM_COPY(pc + offset, &a, 8) -#else -#define __GLX_PUT_DOUBLE(offset,a) \ - *((FLOAT64 *) (pc + offset)) = a -#endif - -#endif - -#define __GLX_PUT_CHAR_ARRAY(offset,a,alen) \ - __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT8) - -#ifndef _CRAY -#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \ - __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT16) - -#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \ - __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT32) - -#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \ - __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT32) - -#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \ - __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT64) - -#else -#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \ - gl_put_short_array((GLubyte *)(pc + offset), a, alen * __GLX_SIZE_INT16) - -#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \ - gl_put_long_array((GLubyte *)(pc + offset), (long *)a, alen * __GLX_SIZE_INT32) - -#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \ - gl_put_float_array((GLubyte *)(pc + offset), (float *)a, alen * __GLX_SIZE_FLOAT32) - -#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \ - gl_put_double_array((GLubyte *)(pc + offset), (double *)a, alen * __GLX_SIZE_FLOAT64) - -extern gl_put_short_array(GLubyte *, short *, int); -extern gl_put_long_array(GLubyte *, long *, int); -extern gl_put_float_array(GLubyte *, float *, int); -extern gl_put_double_array(GLubyte *, double *, int); - -#endif /* _CRAY */ - -#endif /* !__GLX_packrender_h__ */ diff --git a/src/glx/x11/packsingle.h b/src/glx/x11/packsingle.h deleted file mode 100644 index f33a873f3a7..00000000000 --- a/src/glx/x11/packsingle.h +++ /dev/null @@ -1,213 +0,0 @@ -#ifndef __GLX_packsingle_h__ -#define __GLX_packsingle_h__ - -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include "packrender.h" - -/* -** The macros in this header convert wire protocol data types to the client -** machine's native data types. The header is part of the porting layer of -** the client library, and it is intended that hardware vendors will rewrite -** this header to suit their own machines. -*/ - -/* -** Dummy define to make the GetReqExtra macro happy. The value is not -** used, but instead the code in __GLX_SINGLE_BEGIN issues its own store -** to req->reqType with the proper code (our extension code). -*/ -#define X_GLXSingle 0 - -/* Declare common variables used during a single command */ -#define __GLX_SINGLE_DECLARE_VARIABLES() \ - __GLXcontext *gc = __glXGetCurrentContext(); \ - GLubyte *pc, *pixelHeaderPC; \ - GLuint compsize, cmdlen; \ - Display *dpy = gc->currentDpy; \ - xGLXSingleReq *req - -#define __GLX_SINGLE_LOAD_VARIABLES() \ - pc = gc->pc; \ - /* Muffle compilers */ \ - pixelHeaderPC = 0; (void)pixelHeaderPC; \ - compsize = 0; (void)compsize; \ - cmdlen = 0; (void)cmdlen - -/* Start a single command */ -#define __GLX_SINGLE_BEGIN(opcode,bytes) \ - if (dpy) { \ - (void) __glXFlushRenderBuffer(gc, pc); \ - LockDisplay(dpy); \ - GetReqExtra(GLXSingle,bytes,req); \ - req->reqType = gc->majorOpcode; \ - req->glxCode = opcode; \ - req->contextTag = gc->currentContextTag; \ - pc = ((GLubyte *)(req) + sz_xGLXSingleReq) - -/* End a single command */ -#define __GLX_SINGLE_END() \ - UnlockDisplay(dpy); \ - SyncHandle(); \ - } - -/* Store data to sending for a single command */ -#define __GLX_SINGLE_PUT_CHAR(offset,a) \ - *((INT8 *) (pc + offset)) = a - -#ifndef CRAY -#define __GLX_SINGLE_PUT_SHORT(offset,a) \ - *((INT16 *) (pc + offset)) = a - -#define __GLX_SINGLE_PUT_LONG(offset,a) \ - *((INT32 *) (pc + offset)) = a - -#define __GLX_SINGLE_PUT_FLOAT(offset,a) \ - *((FLOAT32 *) (pc + offset)) = a - -#else -#define __GLX_SINGLE_PUT_SHORT(offset,a) \ - { GLubyte *cp = (pc+offset); \ - int shift = (64-16) - ((int)(cp) >> (64-6)); \ - *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); } - -#define __GLX_SINGLE_PUT_LONG(offset,a) \ - { GLubyte *cp = (pc+offset); \ - int shift = (64-32) - ((int)(cp) >> (64-6)); \ - *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); } - -#define __GLX_SINGLE_PUT_FLOAT(offset,a) \ - gl_put_float(pc + offset, a) -#endif - -/* Read support macros */ -#define __GLX_SINGLE_READ_XREPLY() \ - (void) _XReply(dpy, (xReply*) &reply, 0, False) - -#define __GLX_SINGLE_GET_RETVAL(a,cast) \ - a = (cast) reply.retval - -#define __GLX_SINGLE_GET_SIZE(a) \ - a = (GLint) reply.size - -#ifndef _CRAY -#define __GLX_SINGLE_GET_CHAR(p) \ - *p = *(GLbyte *)&reply.pad3; - -#define __GLX_SINGLE_GET_SHORT(p) \ - *p = *(GLshort *)&reply.pad3; - -#define __GLX_SINGLE_GET_LONG(p) \ - *p = *(GLint *)&reply.pad3; - -#define __GLX_SINGLE_GET_FLOAT(p) \ - *p = *(GLfloat *)&reply.pad3; - -#else -#define __GLX_SINGLE_GET_CHAR(p) \ - *p = reply.pad3 >> 24; - -#define __GLX_SINGLE_GET_SHORT(p) \ - {int t = reply.pad3 >> 16; \ - *p = (t & 0x8000) ? (t | ~0xffff) : (t & 0xffff);} - -#define __GLX_SINGLE_GET_LONG(p) \ - {int t = reply.pad3; \ - *p = (t & 0x80000000) ? (t | ~0xffffffff) : (t & 0xffffffff);} - -#define PAD3OFFSET 16 -#define __GLX_SINGLE_GET_FLOAT(p) \ - *p = gl_ntoh_float((GLubyte *)&reply + PAD3OFFSET); - -#define __GLX_SINGLE_GET_DOUBLE(p) \ - *p = gl_ntoh_double((GLubyte *)&reply + PAD3OFFSET); - -extern float gl_ntoh_float(GLubyte *); -extern float gl_ntoh_double(GLubyte *); -#endif - -#ifndef _CRAY - -#ifdef __GLX_ALIGN64 -#define __GLX_SINGLE_GET_DOUBLE(p) \ - __GLX_MEM_COPY(p, &reply.pad3, 8) -#else -#define __GLX_SINGLE_GET_DOUBLE(p) \ - *p = *(GLdouble *)&reply.pad3 -#endif - -#endif - -/* Get an array of typed data */ -#define __GLX_SINGLE_GET_VOID_ARRAY(a,alen) \ - { \ - GLint slop = alen*__GLX_SIZE_INT8 & 3; \ - _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \ - if (slop) _XEatData(dpy,4-slop); \ - } - -#define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen) \ - { \ - GLint slop = alen*__GLX_SIZE_INT8 & 3; \ - _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \ - if (slop) _XEatData(dpy,4-slop); \ - } - - -#define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen) \ - { \ - GLint slop = (alen*__GLX_SIZE_INT16) & 3; \ - _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16); \ - if (slop) _XEatData(dpy,4-slop); \ - } - -#define __GLX_SINGLE_GET_LONG_ARRAY(a,alen) \ - _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32); - -#ifndef _CRAY -#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \ - _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32); - -#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \ - _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64); - -#else -#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \ - gl_get_float_array(dpy,a,alen); - -#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \ - gl_get_double_array(dpy, a, alen); - -extern void gl_get_float_array(Display * dpy, float *a, int alen); -extern void gl_get_double_array(Display * dpy, double *a, int alen); -#endif - -#endif /* !__GLX_packsingle_h__ */ diff --git a/src/glx/x11/pixel.c b/src/glx/x11/pixel.c deleted file mode 100644 index d36ca31e7dd..00000000000 --- a/src/glx/x11/pixel.c +++ /dev/null @@ -1,461 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include "packrender.h" - -static const GLubyte MsbToLsbTable[256] = { - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, -}; - -static const GLubyte LowBitsMask[9] = { - 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff, -}; - -static const GLubyte HighBitsMask[9] = { - 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff, -}; - - -/* -** Copy bitmap data from clients packed memory applying unpacking modes as the -** data is transfered into the destImage buffer. Return in modes the -** set of pixel modes that are to be done by the server. -*/ -static void -FillBitmap(__GLXcontext * gc, GLint width, GLint height, - GLenum format, const GLvoid * userdata, GLubyte * destImage) -{ - const __GLXattribute *state = gc->client_state_private; - GLint rowLength = state->storeUnpack.rowLength; - GLint alignment = state->storeUnpack.alignment; - GLint skipPixels = state->storeUnpack.skipPixels; - GLint skipRows = state->storeUnpack.skipRows; - GLint lsbFirst = state->storeUnpack.lsbFirst; - GLint elementsLeft, bitOffset, currentByte, nextByte, highBitMask; - GLint lowBitMask, i; - GLint components, groupsPerRow, rowSize, padding, elementsPerRow; - const GLubyte *start, *iter; - - if (rowLength > 0) { - groupsPerRow = rowLength; - } - else { - groupsPerRow = width; - } - components = __glElementsPerGroup(format, GL_BITMAP); - rowSize = (groupsPerRow * components + 7) >> 3; - padding = (rowSize % alignment); - if (padding) { - rowSize += alignment - padding; - } - start = ((const GLubyte *) userdata) + skipRows * rowSize + - ((skipPixels * components) >> 3); - bitOffset = (skipPixels * components) & 7; - highBitMask = LowBitsMask[8 - bitOffset]; - lowBitMask = HighBitsMask[bitOffset]; - elementsPerRow = width * components; - for (i = 0; i < height; i++) { - elementsLeft = elementsPerRow; - iter = start; - while (elementsLeft) { - /* First retrieve low bits from current byte */ - if (lsbFirst) { - currentByte = MsbToLsbTable[iter[0]]; - } - else { - currentByte = iter[0]; - } - if (bitOffset) { - /* Need to read next byte to finish current byte */ - if (elementsLeft > (8 - bitOffset)) { - if (lsbFirst) { - nextByte = MsbToLsbTable[iter[1]]; - } - else { - nextByte = iter[1]; - } - currentByte = - ((currentByte & highBitMask) << bitOffset) | - ((nextByte & lowBitMask) >> (8 - bitOffset)); - } - else { - currentByte = ((currentByte & highBitMask) << bitOffset); - } - } - if (elementsLeft >= 8) { - *destImage = currentByte; - elementsLeft -= 8; - } - else { - *destImage = currentByte & HighBitsMask[elementsLeft]; - elementsLeft = 0; - } - destImage++; - iter++; - } - start += rowSize; - } -} - -/* -** Extract array from user's data applying all pixel store modes. -** The internal packed array format used has LSB_FIRST = FALSE and -** ALIGNMENT = 1. -*/ -void -__glFillImage(__GLXcontext * gc, GLint dim, GLint width, GLint height, - GLint depth, GLenum format, GLenum type, - const GLvoid * userdata, GLubyte * newimage, GLubyte * modes) -{ - const __GLXattribute *state = gc->client_state_private; - GLint rowLength = state->storeUnpack.rowLength; - GLint imageHeight = state->storeUnpack.imageHeight; - GLint alignment = state->storeUnpack.alignment; - GLint skipPixels = state->storeUnpack.skipPixels; - GLint skipRows = state->storeUnpack.skipRows; - GLint skipImages = state->storeUnpack.skipImages; - GLint swapBytes = state->storeUnpack.swapEndian; - GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize; - GLint elementsPerRow, imageSize, rowsPerImage, h, i, j, k; - const GLubyte *start, *iter, *itera, *iterb, *iterc; - GLubyte *iter2; - - if (type == GL_BITMAP) { - FillBitmap(gc, width, height, format, userdata, newimage); - } - else { - components = __glElementsPerGroup(format, type); - if (rowLength > 0) { - groupsPerRow = rowLength; - } - else { - groupsPerRow = width; - } - if (imageHeight > 0) { - rowsPerImage = imageHeight; - } - else { - rowsPerImage = height; - } - - elementSize = __glBytesPerElement(type); - groupSize = elementSize * components; - if (elementSize == 1) - swapBytes = 0; - - rowSize = groupsPerRow * groupSize; - padding = (rowSize % alignment); - if (padding) { - rowSize += alignment - padding; - } - imageSize = rowSize * rowsPerImage; - start = ((const GLubyte *) userdata) + skipImages * imageSize + - skipRows * rowSize + skipPixels * groupSize; - iter2 = newimage; - elementsPerRow = width * components; - - if (swapBytes) { - itera = start; - for (h = 0; h < depth; h++) { - iterb = itera; - for (i = 0; i < height; i++) { - iterc = iterb; - for (j = 0; j < elementsPerRow; j++) { - for (k = 1; k <= elementSize; k++) { - iter2[k - 1] = iterc[elementSize - k]; - } - iter2 += elementSize; - iterc += elementSize; - } - iterb += rowSize; - } - itera += imageSize; - } - } - else { - itera = start; - for (h = 0; h < depth; h++) { - if (rowSize == elementsPerRow * elementSize) { - /* Ha! This is mondo easy! */ - __GLX_MEM_COPY(iter2, itera, - elementsPerRow * elementSize * height); - iter2 += elementsPerRow * elementSize * height; - } - else { - iter = itera; - for (i = 0; i < height; i++) { - __GLX_MEM_COPY(iter2, iter, elementsPerRow * elementSize); - iter2 += elementsPerRow * elementSize; - iter += rowSize; - } - } - itera += imageSize; - } - } - } - - /* Setup store modes that describe what we just did */ - if (modes) { - if (dim < 3) { - (void) memcpy(modes, __glXDefaultPixelStore + 4, 20); - } - else { - (void) memcpy(modes, __glXDefaultPixelStore + 0, 36); - } - } -} - -/* -** Empty a bitmap in LSB_FIRST=GL_FALSE and ALIGNMENT=4 format packing it -** into the clients memory using the pixel store PACK modes. -*/ -static void -EmptyBitmap(__GLXcontext * gc, GLint width, GLint height, - GLenum format, const GLubyte * sourceImage, GLvoid * userdata) -{ - const __GLXattribute *state = gc->client_state_private; - GLint rowLength = state->storePack.rowLength; - GLint alignment = state->storePack.alignment; - GLint skipPixels = state->storePack.skipPixels; - GLint skipRows = state->storePack.skipRows; - GLint lsbFirst = state->storePack.lsbFirst; - GLint components, groupsPerRow, rowSize, padding, elementsPerRow; - GLint sourceRowSize, sourcePadding, sourceSkip; - GLubyte *start, *iter; - GLint elementsLeft, bitOffset, currentByte, highBitMask, lowBitMask; - GLint writeMask, i; - GLubyte writeByte; - - components = __glElementsPerGroup(format, GL_BITMAP); - if (rowLength > 0) { - groupsPerRow = rowLength; - } - else { - groupsPerRow = width; - } - - rowSize = (groupsPerRow * components + 7) >> 3; - padding = (rowSize % alignment); - if (padding) { - rowSize += alignment - padding; - } - sourceRowSize = (width * components + 7) >> 3; - sourcePadding = (sourceRowSize % 4); - if (sourcePadding) { - sourceSkip = 4 - sourcePadding; - } - else { - sourceSkip = 0; - } - start = ((GLubyte *) userdata) + skipRows * rowSize + - ((skipPixels * components) >> 3); - bitOffset = (skipPixels * components) & 7; - highBitMask = LowBitsMask[8 - bitOffset]; - lowBitMask = HighBitsMask[bitOffset]; - elementsPerRow = width * components; - for (i = 0; i < height; i++) { - elementsLeft = elementsPerRow; - iter = start; - writeMask = highBitMask; - writeByte = 0; - while (elementsLeft) { - /* Set up writeMask (to write to current byte) */ - if (elementsLeft + bitOffset < 8) { - /* Need to trim writeMask */ - writeMask &= HighBitsMask[bitOffset + elementsLeft]; - } - - if (lsbFirst) { - currentByte = MsbToLsbTable[iter[0]]; - } - else { - currentByte = iter[0]; - } - - if (bitOffset) { - writeByte |= (sourceImage[0] >> bitOffset); - currentByte = (currentByte & ~writeMask) | - (writeByte & writeMask); - writeByte = (sourceImage[0] << (8 - bitOffset)); - } - else { - currentByte = (currentByte & ~writeMask) | - (sourceImage[0] & writeMask); - } - - if (lsbFirst) { - iter[0] = MsbToLsbTable[currentByte]; - } - else { - iter[0] = currentByte; - } - - if (elementsLeft >= 8) { - elementsLeft -= 8; - } - else { - elementsLeft = 0; - } - sourceImage++; - iter++; - writeMask = 0xff; - } - if (writeByte) { - /* Some data left over that still needs writing */ - writeMask &= lowBitMask; - if (lsbFirst) { - currentByte = MsbToLsbTable[iter[0]]; - } - else { - currentByte = iter[0]; - } - currentByte = (currentByte & ~writeMask) | (writeByte & writeMask); - if (lsbFirst) { - iter[0] = MsbToLsbTable[currentByte]; - } - else { - iter[0] = currentByte; - } - } - start += rowSize; - sourceImage += sourceSkip; - } -} - -/* -** Insert array into user's data applying all pixel store modes. -** The packed array format from the server is LSB_FIRST = FALSE, -** SWAP_BYTES = the current pixel storage pack mode, and ALIGNMENT = 4. -** Named __glEmptyImage() because it is the opposite of __glFillImage(). -*/ -/* ARGSUSED */ -void -__glEmptyImage(__GLXcontext * gc, GLint dim, GLint width, GLint height, - GLint depth, GLenum format, GLenum type, - const GLubyte * sourceImage, GLvoid * userdata) -{ - const __GLXattribute *state = gc->client_state_private; - GLint rowLength = state->storePack.rowLength; - GLint imageHeight = state->storePack.imageHeight; - GLint alignment = state->storePack.alignment; - GLint skipPixels = state->storePack.skipPixels; - GLint skipRows = state->storePack.skipRows; - GLint skipImages = state->storePack.skipImages; - GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize; - GLint elementsPerRow, sourceRowSize, sourcePadding, h, i; - GLint imageSize, rowsPerImage; - GLubyte *start, *iter, *itera; - - if (type == GL_BITMAP) { - EmptyBitmap(gc, width, height, format, sourceImage, userdata); - } - else { - components = __glElementsPerGroup(format, type); - if (rowLength > 0) { - groupsPerRow = rowLength; - } - else { - groupsPerRow = width; - } - if (imageHeight > 0) { - rowsPerImage = imageHeight; - } - else { - rowsPerImage = height; - } - elementSize = __glBytesPerElement(type); - groupSize = elementSize * components; - rowSize = groupsPerRow * groupSize; - padding = (rowSize % alignment); - if (padding) { - rowSize += alignment - padding; - } - sourceRowSize = width * groupSize; - sourcePadding = (sourceRowSize % 4); - if (sourcePadding) { - sourceRowSize += 4 - sourcePadding; - } - imageSize = sourceRowSize * rowsPerImage; - start = ((GLubyte *) userdata) + skipImages * imageSize + - skipRows * rowSize + skipPixels * groupSize; - elementsPerRow = width * components; - - itera = start; - for (h = 0; h < depth; h++) { - if ((rowSize == sourceRowSize) && (sourcePadding == 0)) { - /* Ha! This is mondo easy! */ - __GLX_MEM_COPY(itera, sourceImage, - elementsPerRow * elementSize * height); - sourceImage += elementsPerRow * elementSize * height; - } - else { - iter = itera; - for (i = 0; i < height; i++) { - __GLX_MEM_COPY(iter, sourceImage, - elementsPerRow * elementSize); - sourceImage += sourceRowSize; - iter += rowSize; - } - } - itera += imageSize; - } - } -} diff --git a/src/glx/x11/pixelstore.c b/src/glx/x11/pixelstore.c deleted file mode 100644 index 8b51b5d8b7f..00000000000 --- a/src/glx/x11/pixelstore.c +++ /dev/null @@ -1,352 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include "glxclient.h" -#include "indirect.h" - -#if !defined __GNUC__ || __GNUC__ < 3 -# define __builtin_expect(x, y) x -#endif - -/** - * Send glPixelStore command to the server - * - * \param gc Current GLX context - * \param sop Either \c X_GLsop_PixelStoref or \c X_GLsop_PixelStorei - * \param pname Selector of which pixel parameter is to be set. - * \param param Value that \c pname is set to. - * - * \sa __indirect_glPixelStorei, __indirect_glPixelStoref - */ -static void -send_PixelStore(__GLXcontext * gc, unsigned sop, GLenum pname, - const void *param) -{ - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = 8; - if (__builtin_expect(dpy != NULL, 1)) { - GLubyte const *pc = __glXSetupSingleRequest(gc, sop, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&pname), 4); - (void) memcpy((void *) (pc + 4), param, 4); - UnlockDisplay(dpy); - SyncHandle(); - } - return; -} - -/* -** Specify parameters that control the storage format of pixel arrays. -*/ -void -__indirect_glPixelStoref(GLenum pname, GLfloat param) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = gc->client_state_private; - Display *dpy = gc->currentDpy; - GLuint a; - - if (!dpy) - return; - - switch (pname) { - case GL_PACK_ROW_LENGTH: - a = (GLuint) (param + 0.5); - if (((GLint) a) < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storePack.rowLength = a; - break; - case GL_PACK_IMAGE_HEIGHT: - a = (GLuint) (param + 0.5); - if (((GLint) a) < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storePack.imageHeight = a; - break; - case GL_PACK_SKIP_ROWS: - a = (GLuint) (param + 0.5); - if (((GLint) a) < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storePack.skipRows = a; - break; - case GL_PACK_SKIP_PIXELS: - a = (GLuint) (param + 0.5); - if (((GLint) a) < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storePack.skipPixels = a; - break; - case GL_PACK_SKIP_IMAGES: - a = (GLuint) (param + 0.5); - if (((GLint) a) < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storePack.skipImages = a; - break; - case GL_PACK_ALIGNMENT: - a = (GLint) (param + 0.5); - switch (a) { - case 1: - case 2: - case 4: - case 8: - state->storePack.alignment = a; - break; - default: - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - break; - case GL_PACK_SWAP_BYTES: - state->storePack.swapEndian = (param != 0); - break; - case GL_PACK_LSB_FIRST: - state->storePack.lsbFirst = (param != 0); - break; - - case GL_UNPACK_ROW_LENGTH: - a = (GLuint) (param + 0.5); - if (((GLint) a) < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storeUnpack.rowLength = a; - break; - case GL_UNPACK_IMAGE_HEIGHT: - a = (GLuint) (param + 0.5); - if (((GLint) a) < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storeUnpack.imageHeight = a; - break; - case GL_UNPACK_SKIP_ROWS: - a = (GLuint) (param + 0.5); - if (((GLint) a) < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storeUnpack.skipRows = a; - break; - case GL_UNPACK_SKIP_PIXELS: - a = (GLuint) (param + 0.5); - if (((GLint) a) < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storeUnpack.skipPixels = a; - break; - case GL_UNPACK_SKIP_IMAGES: - a = (GLuint) (param + 0.5); - if (((GLint) a) < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storeUnpack.skipImages = a; - break; - case GL_UNPACK_ALIGNMENT: - a = (GLint) (param + 0.5); - switch (a) { - case 1: - case 2: - case 4: - case 8: - state->storeUnpack.alignment = a; - break; - default: - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - break; - case GL_UNPACK_SWAP_BYTES: - state->storeUnpack.swapEndian = (param != 0); - break; - case GL_UNPACK_LSB_FIRST: - state->storeUnpack.lsbFirst = (param != 0); - break; - - /* Group all of the pixel store modes that need to be sent to the - * server here. Care must be used to only send modes to the server that - * won't affect the size of the data sent to or received from the - * server. GL_PACK_INVERT_MESA is safe in this respect, but other, - * future modes may not be. - */ - case GL_PACK_INVERT_MESA: - send_PixelStore(gc, X_GLsop_PixelStoref, pname, ¶m); - break; - - default: - __glXSetError(gc, GL_INVALID_ENUM); - break; - } -} - -void -__indirect_glPixelStorei(GLenum pname, GLint param) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = gc->client_state_private; - Display *dpy = gc->currentDpy; - - if (!dpy) - return; - - switch (pname) { - case GL_PACK_ROW_LENGTH: - if (param < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storePack.rowLength = param; - break; - case GL_PACK_IMAGE_HEIGHT: - if (param < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storePack.imageHeight = param; - break; - case GL_PACK_SKIP_ROWS: - if (param < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storePack.skipRows = param; - break; - case GL_PACK_SKIP_PIXELS: - if (param < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storePack.skipPixels = param; - break; - case GL_PACK_SKIP_IMAGES: - if (param < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storePack.skipImages = param; - break; - case GL_PACK_ALIGNMENT: - switch (param) { - case 1: - case 2: - case 4: - case 8: - state->storePack.alignment = param; - break; - default: - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - break; - case GL_PACK_SWAP_BYTES: - state->storePack.swapEndian = (param != 0); - break; - case GL_PACK_LSB_FIRST: - state->storePack.lsbFirst = (param != 0); - break; - - case GL_UNPACK_ROW_LENGTH: - if (param < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storeUnpack.rowLength = param; - break; - case GL_UNPACK_IMAGE_HEIGHT: - if (param < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storeUnpack.imageHeight = param; - break; - case GL_UNPACK_SKIP_ROWS: - if (param < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storeUnpack.skipRows = param; - break; - case GL_UNPACK_SKIP_PIXELS: - if (param < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storeUnpack.skipPixels = param; - break; - case GL_UNPACK_SKIP_IMAGES: - if (param < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - state->storeUnpack.skipImages = param; - break; - case GL_UNPACK_ALIGNMENT: - switch (param) { - case 1: - case 2: - case 4: - case 8: - state->storeUnpack.alignment = param; - break; - default: - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - break; - case GL_UNPACK_SWAP_BYTES: - state->storeUnpack.swapEndian = (param != 0); - break; - case GL_UNPACK_LSB_FIRST: - state->storeUnpack.lsbFirst = (param != 0); - break; - - /* Group all of the pixel store modes that need to be sent to the - * server here. Care must be used to only send modes to the server that - * won't affect the size of the data sent to or received from the - * server. GL_PACK_INVERT_MESA is safe in this respect, but other, - * future modes may not be. - */ - case GL_PACK_INVERT_MESA: - send_PixelStore(gc, X_GLsop_PixelStorei, pname, ¶m); - break; - - default: - __glXSetError(gc, GL_INVALID_ENUM); - break; - } -} diff --git a/src/glx/x11/render2.c b/src/glx/x11/render2.c deleted file mode 100644 index 762950f4ac4..00000000000 --- a/src/glx/x11/render2.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include "packrender.h" -#include "indirect.h" -#include "indirect_size.h" - -/* -** This file contains routines that might need to be transported as -** GLXRender or GLXRenderLarge commands, and these commands don't -** use the pixel header. See renderpix.c for those routines. -*/ - -void -__indirect_glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, - GLint order, const GLdouble * pnts) -{ - __GLX_DECLARE_VARIABLES(); - GLint k; - - __GLX_LOAD_VARIABLES(); - k = __glMap1d_size(target); - if (k == 0) { - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - else if (stride < k || order <= 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - compsize = k * order * __GLX_SIZE_FLOAT64; - cmdlen = 28 + compsize; - if (!gc->currentDpy) - return; - - if (cmdlen <= gc->maxSmallRenderCommandSize) { - /* Use GLXRender protocol to send small command */ - __GLX_BEGIN_VARIABLE(X_GLrop_Map1d, cmdlen); - __GLX_PUT_DOUBLE(4, u1); - __GLX_PUT_DOUBLE(12, u2); - __GLX_PUT_LONG(20, target); - __GLX_PUT_LONG(24, order); - /* - ** NOTE: the doubles that follow are not aligned because of 3 - ** longs preceeding - */ - __glFillMap1d(k, order, stride, pnts, (pc + 28)); - __GLX_END(cmdlen); - } - else { - /* Use GLXRenderLarge protocol to send command */ - __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1d, cmdlen + 4); - __GLX_PUT_DOUBLE(8, u1); - __GLX_PUT_DOUBLE(16, u2); - __GLX_PUT_LONG(24, target); - __GLX_PUT_LONG(28, order); - - /* - ** NOTE: the doubles that follow are not aligned because of 3 - ** longs preceeding - */ - if (stride != k) { - GLubyte *buf; - - buf = (GLubyte *) Xmalloc(compsize); - if (!buf) { - __glXSetError(gc, GL_OUT_OF_MEMORY); - return; - } - __glFillMap1d(k, order, stride, pnts, buf); - __glXSendLargeCommand(gc, pc, 32, buf, compsize); - Xfree((char *) buf); - } - else { - /* Data is already packed. Just send it out */ - __glXSendLargeCommand(gc, pc, 32, pnts, compsize); - } - } -} - -void -__indirect_glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat * pnts) -{ - __GLX_DECLARE_VARIABLES(); - GLint k; - - __GLX_LOAD_VARIABLES(); - k = __glMap1f_size(target); - if (k == 0) { - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - else if (stride < k || order <= 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - compsize = k * order * __GLX_SIZE_FLOAT32; - cmdlen = 20 + compsize; - if (!gc->currentDpy) - return; - - /* - ** The order that arguments are packed is different from the order - ** for glMap1d. - */ - if (cmdlen <= gc->maxSmallRenderCommandSize) { - /* Use GLXRender protocol to send small command */ - __GLX_BEGIN_VARIABLE(X_GLrop_Map1f, cmdlen); - __GLX_PUT_LONG(4, target); - __GLX_PUT_FLOAT(8, u1); - __GLX_PUT_FLOAT(12, u2); - __GLX_PUT_LONG(16, order); - __glFillMap1f(k, order, stride, pnts, (GLubyte *) (pc + 20)); - __GLX_END(cmdlen); - } - else { - /* Use GLXRenderLarge protocol to send command */ - __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1f, cmdlen + 4); - __GLX_PUT_LONG(8, target); - __GLX_PUT_FLOAT(12, u1); - __GLX_PUT_FLOAT(16, u2); - __GLX_PUT_LONG(20, order); - - if (stride != k) { - GLubyte *buf; - - buf = (GLubyte *) Xmalloc(compsize); - if (!buf) { - __glXSetError(gc, GL_OUT_OF_MEMORY); - return; - } - __glFillMap1f(k, order, stride, pnts, buf); - __glXSendLargeCommand(gc, pc, 24, buf, compsize); - Xfree((char *) buf); - } - else { - /* Data is already packed. Just send it out */ - __glXSendLargeCommand(gc, pc, 24, pnts, compsize); - } - } -} - -void -__indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr, - GLint uord, GLdouble v1, GLdouble v2, GLint vstr, - GLint vord, const GLdouble * pnts) -{ - __GLX_DECLARE_VARIABLES(); - GLint k; - - __GLX_LOAD_VARIABLES(); - k = __glMap2d_size(target); - if (k == 0) { - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - compsize = k * uord * vord * __GLX_SIZE_FLOAT64; - cmdlen = 48 + compsize; - if (!gc->currentDpy) - return; - - if (cmdlen <= gc->maxSmallRenderCommandSize) { - /* Use GLXRender protocol to send small command */ - __GLX_BEGIN_VARIABLE(X_GLrop_Map2d, cmdlen); - __GLX_PUT_DOUBLE(4, u1); - __GLX_PUT_DOUBLE(12, u2); - __GLX_PUT_DOUBLE(20, v1); - __GLX_PUT_DOUBLE(28, v2); - __GLX_PUT_LONG(36, target); - __GLX_PUT_LONG(40, uord); - __GLX_PUT_LONG(44, vord); - /* - ** Pack into a u-major ordering. - ** NOTE: the doubles that follow are not aligned because of 5 - ** longs preceeding - */ - __glFillMap2d(k, uord, vord, ustr, vstr, pnts, (GLdouble *) (pc + 48)); - __GLX_END(cmdlen); - } - else { - /* Use GLXRenderLarge protocol to send command */ - __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2d, cmdlen + 4); - __GLX_PUT_DOUBLE(8, u1); - __GLX_PUT_DOUBLE(16, u2); - __GLX_PUT_DOUBLE(24, v1); - __GLX_PUT_DOUBLE(32, v2); - __GLX_PUT_LONG(40, target); - __GLX_PUT_LONG(44, uord); - __GLX_PUT_LONG(48, vord); - - /* - ** NOTE: the doubles that follow are not aligned because of 5 - ** longs preceeding - */ - if ((vstr != k) || (ustr != k * vord)) { - GLdouble *buf; - - buf = (GLdouble *) Xmalloc(compsize); - if (!buf) { - __glXSetError(gc, GL_OUT_OF_MEMORY); - return; - } - /* - ** Pack into a u-major ordering. - */ - __glFillMap2d(k, uord, vord, ustr, vstr, pnts, buf); - __glXSendLargeCommand(gc, pc, 52, buf, compsize); - Xfree((char *) buf); - } - else { - /* Data is already packed. Just send it out */ - __glXSendLargeCommand(gc, pc, 52, pnts, compsize); - } - } -} - -void -__indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr, - GLint uord, GLfloat v1, GLfloat v2, GLint vstr, GLint vord, - const GLfloat * pnts) -{ - __GLX_DECLARE_VARIABLES(); - GLint k; - - __GLX_LOAD_VARIABLES(); - k = __glMap2f_size(target); - if (k == 0) { - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - compsize = k * uord * vord * __GLX_SIZE_FLOAT32; - cmdlen = 32 + compsize; - if (!gc->currentDpy) - return; - - /* - ** The order that arguments are packed is different from the order - ** for glMap2d. - */ - if (cmdlen <= gc->maxSmallRenderCommandSize) { - /* Use GLXRender protocol to send small command */ - __GLX_BEGIN_VARIABLE(X_GLrop_Map2f, cmdlen); - __GLX_PUT_LONG(4, target); - __GLX_PUT_FLOAT(8, u1); - __GLX_PUT_FLOAT(12, u2); - __GLX_PUT_LONG(16, uord); - __GLX_PUT_FLOAT(20, v1); - __GLX_PUT_FLOAT(24, v2); - __GLX_PUT_LONG(28, vord); - /* - ** Pack into a u-major ordering. - */ - __glFillMap2f(k, uord, vord, ustr, vstr, pnts, (GLfloat *) (pc + 32)); - __GLX_END(cmdlen); - } - else { - /* Use GLXRenderLarge protocol to send command */ - __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2f, cmdlen + 4); - __GLX_PUT_LONG(8, target); - __GLX_PUT_FLOAT(12, u1); - __GLX_PUT_FLOAT(16, u2); - __GLX_PUT_LONG(20, uord); - __GLX_PUT_FLOAT(24, v1); - __GLX_PUT_FLOAT(28, v2); - __GLX_PUT_LONG(32, vord); - - if ((vstr != k) || (ustr != k * vord)) { - GLfloat *buf; - - buf = (GLfloat *) Xmalloc(compsize); - if (!buf) { - __glXSetError(gc, GL_OUT_OF_MEMORY); - return; - } - /* - ** Pack into a u-major ordering. - */ - __glFillMap2f(k, uord, vord, ustr, vstr, pnts, buf); - __glXSendLargeCommand(gc, pc, 36, buf, compsize); - Xfree((char *) buf); - } - else { - /* Data is already packed. Just send it out */ - __glXSendLargeCommand(gc, pc, 36, pnts, compsize); - } - } -} - -void -__indirect_glEnable(GLenum cap) -{ - __GLX_DECLARE_VARIABLES(); - - __GLX_LOAD_VARIABLES(); - if (!gc->currentDpy) - return; - - switch (cap) { - case GL_COLOR_ARRAY: - case GL_EDGE_FLAG_ARRAY: - case GL_INDEX_ARRAY: - case GL_NORMAL_ARRAY: - case GL_TEXTURE_COORD_ARRAY: - case GL_VERTEX_ARRAY: - case GL_SECONDARY_COLOR_ARRAY: - case GL_FOG_COORD_ARRAY: - __indirect_glEnableClientState(cap); - return; - default: - break; - } - - __GLX_BEGIN(X_GLrop_Enable, 8); - __GLX_PUT_LONG(4, cap); - __GLX_END(8); -} - -void -__indirect_glDisable(GLenum cap) -{ - __GLX_DECLARE_VARIABLES(); - - __GLX_LOAD_VARIABLES(); - if (!gc->currentDpy) - return; - - switch (cap) { - case GL_COLOR_ARRAY: - case GL_EDGE_FLAG_ARRAY: - case GL_INDEX_ARRAY: - case GL_NORMAL_ARRAY: - case GL_TEXTURE_COORD_ARRAY: - case GL_VERTEX_ARRAY: - case GL_SECONDARY_COLOR_ARRAY: - case GL_FOG_COORD_ARRAY: - __indirect_glDisableClientState(cap); - return; - default: - break; - } - - __GLX_BEGIN(X_GLrop_Disable, 8); - __GLX_PUT_LONG(4, cap); - __GLX_END(8); -} diff --git a/src/glx/x11/renderpix.c b/src/glx/x11/renderpix.c deleted file mode 100644 index 9919bbcde3b..00000000000 --- a/src/glx/x11/renderpix.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -/* - * (C) Copyright IBM Corporation 2005 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "packrender.h" -#include "indirect.h" - -/** - * Send a large image to the server. If necessary, a buffer is allocated - * to hold the unpacked data that is copied from the clients memory. - * - * \param gc Current GLX context - * \param compsize Size, in bytes, of the image portion - * \param dim Number of dimensions of the image - * \param width Width of the image - * \param height Height of the image, must be 1 for 1D images - * \param depth Depth of the image, must be 1 for 1D or 2D images - * \param format Format of the image - * \param type Data type of the image - * \param src Pointer to the image data - * \param pc Pointer to end of the command header - * \param modes Pointer to the pixel unpack data - * - * \todo - * Modify this function so that \c NULL images are sent using - * \c __glXSendLargeChunk instead of __glXSendLargeCommand. Doing this - * will eliminate the need to allocate a buffer for that case. - * - * \bugs - * The \c fastImageUnpack path, which is thankfully never used, is completely - * broken. - */ -void -__glXSendLargeImage(__GLXcontext * gc, GLint compsize, GLint dim, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, const GLvoid * src, - GLubyte * pc, GLubyte * modes) -{ - if (!gc->fastImageUnpack || (src == NULL)) { - /* Allocate a temporary holding buffer */ - GLubyte *buf = (GLubyte *) Xmalloc(compsize); - if (!buf) { - __glXSetError(gc, GL_OUT_OF_MEMORY); - return; - } - - /* Apply pixel store unpack modes to copy data into buf */ - if (src != NULL) { - (*gc->fillImage) (gc, dim, width, height, depth, format, type, - src, buf, modes); - } - else { - if (dim < 3) { - (void) memcpy(modes, __glXDefaultPixelStore + 4, 20); - } - else { - (void) memcpy(modes, __glXDefaultPixelStore + 0, 36); - } - } - - /* Send large command */ - __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, buf, compsize); - - /* Free buffer */ - Xfree((char *) buf); - } - else { - /* Just send the data straight as is */ - __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, pc, compsize); - } -} - -/************************************************************************/ - -/** - * Implement GLX protocol for \c glSeparableFilter2D. - * - * \bugs - * The \c fastImageUnpack path, which is thankfully never used, is completely - * broken. - */ -void -__indirect_glSeparableFilter2D(GLenum target, GLenum internalformat, - GLsizei width, GLsizei height, GLenum format, - GLenum type, const GLvoid * row, - const GLvoid * column) -{ - __GLX_DECLARE_VARIABLES(); - GLuint compsize2, hdrlen, totalhdrlen, image1len, image2len; - - __GLX_LOAD_VARIABLES(); - compsize = __glImageSize(width, 1, 1, format, type, 0); - compsize2 = __glImageSize(height, 1, 1, format, type, 0); - totalhdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE); - hdrlen = __GLX_PAD(__GLX_CONV_FILT_HDR_SIZE); - image1len = __GLX_PAD(compsize); - image2len = __GLX_PAD(compsize2); - cmdlen = totalhdrlen + image1len + image2len; - if (!gc->currentDpy) - return; - - if (cmdlen <= gc->maxSmallRenderCommandSize) { - /* Use GLXRender protocol to send small command */ - __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_SeparableFilter2D, cmdlen); - __GLX_PUT_LONG(0, target); - __GLX_PUT_LONG(4, internalformat); - __GLX_PUT_LONG(8, width); - __GLX_PUT_LONG(12, height); - __GLX_PUT_LONG(16, format); - __GLX_PUT_LONG(20, type); - pc += hdrlen; - if (compsize > 0) { - (*gc->fillImage) (gc, 1, width, 1, 1, format, type, - row, pc, pixelHeaderPC); - pc += image1len; - } - if (compsize2 > 0) { - (*gc->fillImage) (gc, 1, height, 1, 1, format, type, - column, pc, NULL); - pc += image2len; - } - if ((compsize == 0) && (compsize2 == 0)) { - /* Setup default store modes */ - (void) memcpy(pixelHeaderPC, __glXDefaultPixelStore + 4, 20); - } - __GLX_END(0); - } - else { - const GLint bufsize = image1len + image2len; - - /* Use GLXRenderLarge protocol to send command */ - __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_SeparableFilter2D, - cmdlen + 4); - __GLX_PUT_LONG(0, target); - __GLX_PUT_LONG(4, internalformat); - __GLX_PUT_LONG(8, width); - __GLX_PUT_LONG(12, height); - __GLX_PUT_LONG(16, format); - __GLX_PUT_LONG(20, type); - pc += hdrlen; - - if (!gc->fastImageUnpack) { - /* Allocate a temporary holding buffer */ - GLubyte *buf = (GLubyte *) Xmalloc(bufsize); - if (!buf) { - __glXSetError(gc, GL_OUT_OF_MEMORY); - return; - } - (*gc->fillImage) (gc, 1, width, 1, 1, format, type, row, buf, - pixelHeaderPC); - - (*gc->fillImage) (gc, 1, height, 1, 1, format, type, column, - buf + image1len, pixelHeaderPC); - - /* Send large command */ - __glXSendLargeCommand(gc, gc->pc, (GLint) (pc - gc->pc), buf, - bufsize); - /* Free buffer */ - Xfree((char *) buf); - } - else { - /* Just send the data straight as is */ - __glXSendLargeCommand(gc, gc->pc, (GLint) (pc - gc->pc), pc, - bufsize); - } - } -} diff --git a/src/glx/x11/single2.c b/src/glx/x11/single2.c deleted file mode 100644 index 9ecf589ffff..00000000000 --- a/src/glx/x11/single2.c +++ /dev/null @@ -1,974 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include -#include -#include "glxclient.h" -#include "packsingle.h" -#include "glxextensions.h" -#include "indirect.h" -#include "indirect_vertex_array.h" -#include "glapitable.h" -#include "glapidispatch.h" -#include "glapi.h" -#ifdef USE_XCB -#include -#include -#include -#endif /* USE_XCB */ - - -/* Used for GL_ARB_transpose_matrix */ -static void -TransposeMatrixf(GLfloat m[16]) -{ - int i, j; - for (i = 0; i < 4; i++) { - for (j = 0; j < i; j++) { - GLfloat tmp = m[i * 4 + j]; - m[i * 4 + j] = m[j * 4 + i]; - m[j * 4 + i] = tmp; - } - } -} - -/* Used for GL_ARB_transpose_matrix */ -static void -TransposeMatrixb(GLboolean m[16]) -{ - int i, j; - for (i = 0; i < 4; i++) { - for (j = 0; j < i; j++) { - GLboolean tmp = m[i * 4 + j]; - m[i * 4 + j] = m[j * 4 + i]; - m[j * 4 + i] = tmp; - } - } -} - -/* Used for GL_ARB_transpose_matrix */ -static void -TransposeMatrixd(GLdouble m[16]) -{ - int i, j; - for (i = 0; i < 4; i++) { - for (j = 0; j < i; j++) { - GLdouble tmp = m[i * 4 + j]; - m[i * 4 + j] = m[j * 4 + i]; - m[j * 4 + i] = tmp; - } - } -} - -/* Used for GL_ARB_transpose_matrix */ -static void -TransposeMatrixi(GLint m[16]) -{ - int i, j; - for (i = 0; i < 4; i++) { - for (j = 0; j < i; j++) { - GLint tmp = m[i * 4 + j]; - m[i * 4 + j] = m[j * 4 + i]; - m[j * 4 + i] = tmp; - } - } -} - - -/** - * Remap a transpose-matrix enum to a non-transpose-matrix enum. Enums - * that are not transpose-matrix enums are unaffected. - */ -static GLenum -RemapTransposeEnum(GLenum e) -{ - switch (e) { - case GL_TRANSPOSE_MODELVIEW_MATRIX: - case GL_TRANSPOSE_PROJECTION_MATRIX: - case GL_TRANSPOSE_TEXTURE_MATRIX: - return e - (GL_TRANSPOSE_MODELVIEW_MATRIX - GL_MODELVIEW_MATRIX); - case GL_TRANSPOSE_COLOR_MATRIX: - return GL_COLOR_MATRIX; - default: - return e; - }; -} - - -GLenum -__indirect_glGetError(void) -{ - __GLX_SINGLE_DECLARE_VARIABLES(); - GLuint retval = GL_NO_ERROR; - xGLXGetErrorReply reply; - - if (gc->error) { - /* Use internal error first */ - retval = gc->error; - gc->error = GL_NO_ERROR; - return retval; - } - - __GLX_SINGLE_LOAD_VARIABLES(); - __GLX_SINGLE_BEGIN(X_GLsop_GetError, 0); - __GLX_SINGLE_READ_XREPLY(); - retval = reply.error; - __GLX_SINGLE_END(); - - return retval; -} - - -/** - * Get the selected attribute from the client state. - * - * \returns - * On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned. - */ -static GLboolean -get_client_data(__GLXcontext * gc, GLenum cap, GLintptr * data) -{ - GLboolean retval = GL_TRUE; - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - const GLint tex_unit = __glXGetActiveTextureUnit(state); - - - switch (cap) { - case GL_VERTEX_ARRAY: - case GL_NORMAL_ARRAY: - case GL_COLOR_ARRAY: - case GL_INDEX_ARRAY: - case GL_EDGE_FLAG_ARRAY: - case GL_SECONDARY_COLOR_ARRAY: - case GL_FOG_COORD_ARRAY: - retval = __glXGetArrayEnable(state, cap, 0, data); - break; - - case GL_VERTEX_ARRAY_SIZE: - retval = __glXGetArraySize(state, GL_VERTEX_ARRAY, 0, data); - break; - case GL_COLOR_ARRAY_SIZE: - retval = __glXGetArraySize(state, GL_COLOR_ARRAY, 0, data); - break; - case GL_SECONDARY_COLOR_ARRAY_SIZE: - retval = __glXGetArraySize(state, GL_SECONDARY_COLOR_ARRAY, 0, data); - break; - - case GL_VERTEX_ARRAY_TYPE: - retval = __glXGetArrayType(state, GL_VERTEX_ARRAY, 0, data); - break; - case GL_NORMAL_ARRAY_TYPE: - retval = __glXGetArrayType(state, GL_NORMAL_ARRAY, 0, data); - break; - case GL_INDEX_ARRAY_TYPE: - retval = __glXGetArrayType(state, GL_INDEX_ARRAY, 0, data); - break; - case GL_COLOR_ARRAY_TYPE: - retval = __glXGetArrayType(state, GL_COLOR_ARRAY, 0, data); - break; - case GL_SECONDARY_COLOR_ARRAY_TYPE: - retval = __glXGetArrayType(state, GL_SECONDARY_COLOR_ARRAY, 0, data); - break; - case GL_FOG_COORD_ARRAY_TYPE: - retval = __glXGetArrayType(state, GL_FOG_COORD_ARRAY, 0, data); - break; - - case GL_VERTEX_ARRAY_STRIDE: - retval = __glXGetArrayStride(state, GL_VERTEX_ARRAY, 0, data); - break; - case GL_NORMAL_ARRAY_STRIDE: - retval = __glXGetArrayStride(state, GL_NORMAL_ARRAY, 0, data); - break; - case GL_INDEX_ARRAY_STRIDE: - retval = __glXGetArrayStride(state, GL_INDEX_ARRAY, 0, data); - break; - case GL_EDGE_FLAG_ARRAY_STRIDE: - retval = __glXGetArrayStride(state, GL_EDGE_FLAG_ARRAY, 0, data); - break; - case GL_COLOR_ARRAY_STRIDE: - retval = __glXGetArrayStride(state, GL_COLOR_ARRAY, 0, data); - break; - case GL_SECONDARY_COLOR_ARRAY_STRIDE: - retval = __glXGetArrayStride(state, GL_SECONDARY_COLOR_ARRAY, 0, data); - break; - case GL_FOG_COORD_ARRAY_STRIDE: - retval = __glXGetArrayStride(state, GL_FOG_COORD_ARRAY, 0, data); - break; - - case GL_TEXTURE_COORD_ARRAY: - retval = - __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data); - break; - case GL_TEXTURE_COORD_ARRAY_SIZE: - retval = - __glXGetArraySize(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data); - break; - case GL_TEXTURE_COORD_ARRAY_TYPE: - retval = - __glXGetArrayType(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data); - break; - case GL_TEXTURE_COORD_ARRAY_STRIDE: - retval = - __glXGetArrayStride(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data); - break; - - case GL_MAX_ELEMENTS_VERTICES: - case GL_MAX_ELEMENTS_INDICES: - retval = GL_TRUE; - *data = ~0UL; - break; - - - case GL_PACK_ROW_LENGTH: - *data = (GLintptr) state->storePack.rowLength; - break; - case GL_PACK_IMAGE_HEIGHT: - *data = (GLintptr) state->storePack.imageHeight; - break; - case GL_PACK_SKIP_ROWS: - *data = (GLintptr) state->storePack.skipRows; - break; - case GL_PACK_SKIP_PIXELS: - *data = (GLintptr) state->storePack.skipPixels; - break; - case GL_PACK_SKIP_IMAGES: - *data = (GLintptr) state->storePack.skipImages; - break; - case GL_PACK_ALIGNMENT: - *data = (GLintptr) state->storePack.alignment; - break; - case GL_PACK_SWAP_BYTES: - *data = (GLintptr) state->storePack.swapEndian; - break; - case GL_PACK_LSB_FIRST: - *data = (GLintptr) state->storePack.lsbFirst; - break; - case GL_UNPACK_ROW_LENGTH: - *data = (GLintptr) state->storeUnpack.rowLength; - break; - case GL_UNPACK_IMAGE_HEIGHT: - *data = (GLintptr) state->storeUnpack.imageHeight; - break; - case GL_UNPACK_SKIP_ROWS: - *data = (GLintptr) state->storeUnpack.skipRows; - break; - case GL_UNPACK_SKIP_PIXELS: - *data = (GLintptr) state->storeUnpack.skipPixels; - break; - case GL_UNPACK_SKIP_IMAGES: - *data = (GLintptr) state->storeUnpack.skipImages; - break; - case GL_UNPACK_ALIGNMENT: - *data = (GLintptr) state->storeUnpack.alignment; - break; - case GL_UNPACK_SWAP_BYTES: - *data = (GLintptr) state->storeUnpack.swapEndian; - break; - case GL_UNPACK_LSB_FIRST: - *data = (GLintptr) state->storeUnpack.lsbFirst; - break; - case GL_CLIENT_ATTRIB_STACK_DEPTH: - *data = (GLintptr) (gc->attributes.stackPointer - gc->attributes.stack); - break; - case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: - *data = (GLintptr) __GL_CLIENT_ATTRIB_STACK_DEPTH; - break; - case GL_CLIENT_ACTIVE_TEXTURE: - *data = (GLintptr) (tex_unit + GL_TEXTURE0); - break; - - default: - retval = GL_FALSE; - break; - } - - - return retval; -} - - -void -__indirect_glGetBooleanv(GLenum val, GLboolean * b) -{ - const GLenum origVal = val; - __GLX_SINGLE_DECLARE_VARIABLES(); - xGLXSingleReply reply; - - val = RemapTransposeEnum(val); - - __GLX_SINGLE_LOAD_VARIABLES(); - __GLX_SINGLE_BEGIN(X_GLsop_GetBooleanv, 4); - __GLX_SINGLE_PUT_LONG(0, val); - __GLX_SINGLE_READ_XREPLY(); - __GLX_SINGLE_GET_SIZE(compsize); - - if (compsize == 0) { - /* - ** Error occured; don't modify user's buffer. - */ - } - else { - GLintptr data; - - /* - ** We still needed to send the request to the server in order to - ** find out whether it was legal to make a query (it's illegal, - ** for example, to call a query between glBegin() and glEnd()). - */ - - if (get_client_data(gc, val, &data)) { - *b = (GLboolean) data; - } - else { - /* - ** Not a local value, so use what we got from the server. - */ - if (compsize == 1) { - __GLX_SINGLE_GET_CHAR(b); - } - else { - __GLX_SINGLE_GET_CHAR_ARRAY(b, compsize); - if (val != origVal) { - /* matrix transpose */ - TransposeMatrixb(b); - } - } - } - } - __GLX_SINGLE_END(); -} - -void -__indirect_glGetDoublev(GLenum val, GLdouble * d) -{ - const GLenum origVal = val; - __GLX_SINGLE_DECLARE_VARIABLES(); - xGLXSingleReply reply; - - val = RemapTransposeEnum(val); - - __GLX_SINGLE_LOAD_VARIABLES(); - __GLX_SINGLE_BEGIN(X_GLsop_GetDoublev, 4); - __GLX_SINGLE_PUT_LONG(0, val); - __GLX_SINGLE_READ_XREPLY(); - __GLX_SINGLE_GET_SIZE(compsize); - - if (compsize == 0) { - /* - ** Error occured; don't modify user's buffer. - */ - } - else { - GLintptr data; - - /* - ** We still needed to send the request to the server in order to - ** find out whether it was legal to make a query (it's illegal, - ** for example, to call a query between glBegin() and glEnd()). - */ - - if (get_client_data(gc, val, &data)) { - *d = (GLdouble) data; - } - else { - /* - ** Not a local value, so use what we got from the server. - */ - if (compsize == 1) { - __GLX_SINGLE_GET_DOUBLE(d); - } - else { - __GLX_SINGLE_GET_DOUBLE_ARRAY(d, compsize); - if (val != origVal) { - /* matrix transpose */ - TransposeMatrixd(d); - } - } - } - } - __GLX_SINGLE_END(); -} - -void -__indirect_glGetFloatv(GLenum val, GLfloat * f) -{ - const GLenum origVal = val; - __GLX_SINGLE_DECLARE_VARIABLES(); - xGLXSingleReply reply; - - val = RemapTransposeEnum(val); - - __GLX_SINGLE_LOAD_VARIABLES(); - __GLX_SINGLE_BEGIN(X_GLsop_GetFloatv, 4); - __GLX_SINGLE_PUT_LONG(0, val); - __GLX_SINGLE_READ_XREPLY(); - __GLX_SINGLE_GET_SIZE(compsize); - - if (compsize == 0) { - /* - ** Error occured; don't modify user's buffer. - */ - } - else { - GLintptr data; - - /* - ** We still needed to send the request to the server in order to - ** find out whether it was legal to make a query (it's illegal, - ** for example, to call a query between glBegin() and glEnd()). - */ - - if (get_client_data(gc, val, &data)) { - *f = (GLfloat) data; - } - else { - /* - ** Not a local value, so use what we got from the server. - */ - if (compsize == 1) { - __GLX_SINGLE_GET_FLOAT(f); - } - else { - __GLX_SINGLE_GET_FLOAT_ARRAY(f, compsize); - if (val != origVal) { - /* matrix transpose */ - TransposeMatrixf(f); - } - } - } - } - __GLX_SINGLE_END(); -} - -void -__indirect_glGetIntegerv(GLenum val, GLint * i) -{ - const GLenum origVal = val; - __GLX_SINGLE_DECLARE_VARIABLES(); - xGLXSingleReply reply; - - val = RemapTransposeEnum(val); - - __GLX_SINGLE_LOAD_VARIABLES(); - __GLX_SINGLE_BEGIN(X_GLsop_GetIntegerv, 4); - __GLX_SINGLE_PUT_LONG(0, val); - __GLX_SINGLE_READ_XREPLY(); - __GLX_SINGLE_GET_SIZE(compsize); - - if (compsize == 0) { - /* - ** Error occured; don't modify user's buffer. - */ - } - else { - GLintptr data; - - /* - ** We still needed to send the request to the server in order to - ** find out whether it was legal to make a query (it's illegal, - ** for example, to call a query between glBegin() and glEnd()). - */ - - if (get_client_data(gc, val, &data)) { - *i = (GLint) data; - } - else { - /* - ** Not a local value, so use what we got from the server. - */ - if (compsize == 1) { - __GLX_SINGLE_GET_LONG(i); - } - else { - __GLX_SINGLE_GET_LONG_ARRAY(i, compsize); - if (val != origVal) { - /* matrix transpose */ - TransposeMatrixi(i); - } - } - } - } - __GLX_SINGLE_END(); -} - -/* -** Send all pending commands to server. -*/ -void -__indirect_glFlush(void) -{ - __GLX_SINGLE_DECLARE_VARIABLES(); - - if (!dpy) - return; - - __GLX_SINGLE_LOAD_VARIABLES(); - __GLX_SINGLE_BEGIN(X_GLsop_Flush, 0); - __GLX_SINGLE_END(); - - /* And finally flush the X protocol data */ - XFlush(dpy); -} - -void -__indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer) -{ - __GLX_SINGLE_DECLARE_VARIABLES(); - - if (!dpy) - return; - - __GLX_SINGLE_LOAD_VARIABLES(); - __GLX_SINGLE_BEGIN(X_GLsop_FeedbackBuffer, 8); - __GLX_SINGLE_PUT_LONG(0, size); - __GLX_SINGLE_PUT_LONG(4, type); - __GLX_SINGLE_END(); - - gc->feedbackBuf = buffer; -} - -void -__indirect_glSelectBuffer(GLsizei numnames, GLuint * buffer) -{ - __GLX_SINGLE_DECLARE_VARIABLES(); - - if (!dpy) - return; - - __GLX_SINGLE_LOAD_VARIABLES(); - __GLX_SINGLE_BEGIN(X_GLsop_SelectBuffer, 4); - __GLX_SINGLE_PUT_LONG(0, numnames); - __GLX_SINGLE_END(); - - gc->selectBuf = buffer; -} - -GLint -__indirect_glRenderMode(GLenum mode) -{ - __GLX_SINGLE_DECLARE_VARIABLES(); - GLint retval = 0; - xGLXRenderModeReply reply; - - if (!dpy) - return -1; - - __GLX_SINGLE_LOAD_VARIABLES(); - __GLX_SINGLE_BEGIN(X_GLsop_RenderMode, 4); - __GLX_SINGLE_PUT_LONG(0, mode); - __GLX_SINGLE_READ_XREPLY(); - __GLX_SINGLE_GET_RETVAL(retval, GLint); - - if (reply.newMode != mode) { - /* - ** Switch to new mode did not take effect, therefore an error - ** occured. When an error happens the server won't send us any - ** other data. - */ - } - else { - /* Read the feedback or selection data */ - if (gc->renderMode == GL_FEEDBACK) { - __GLX_SINGLE_GET_SIZE(compsize); - __GLX_SINGLE_GET_FLOAT_ARRAY(gc->feedbackBuf, compsize); - } - else if (gc->renderMode == GL_SELECT) { - __GLX_SINGLE_GET_SIZE(compsize); - __GLX_SINGLE_GET_LONG_ARRAY(gc->selectBuf, compsize); - } - gc->renderMode = mode; - } - __GLX_SINGLE_END(); - - return retval; -} - -void -__indirect_glFinish(void) -{ - __GLX_SINGLE_DECLARE_VARIABLES(); - xGLXSingleReply reply; - - __GLX_SINGLE_LOAD_VARIABLES(); - __GLX_SINGLE_BEGIN(X_GLsop_Finish, 0); - __GLX_SINGLE_READ_XREPLY(); - __GLX_SINGLE_END(); -} - - -/** - * Extract the major and minor version numbers from a version string. - */ -static void -version_from_string(const char *ver, int *major_version, int *minor_version) -{ - const char *end; - long major; - long minor; - - major = strtol(ver, (char **) &end, 10); - minor = strtol(end + 1, NULL, 10); - *major_version = major; - *minor_version = minor; -} - - -const GLubyte * -__indirect_glGetString(GLenum name) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - Display *dpy = gc->currentDpy; - GLubyte *s = NULL; - - if (!dpy) - return 0; - - /* - ** Return the cached copy if the string has already been fetched - */ - switch (name) { - case GL_VENDOR: - if (gc->vendor) - return gc->vendor; - break; - case GL_RENDERER: - if (gc->renderer) - return gc->renderer; - break; - case GL_VERSION: - if (gc->version) - return gc->version; - break; - case GL_EXTENSIONS: - if (gc->extensions) - return gc->extensions; - break; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return 0; - } - - /* - ** Get requested string from server - */ - - (void) __glXFlushRenderBuffer(gc, gc->pc); - s = (GLubyte *) __glXGetString(dpy, gc->majorOpcode, gc->currentContextTag, - name); - if (!s) { - /* Throw data on the floor */ - __glXSetError(gc, GL_OUT_OF_MEMORY); - } - else { - /* - ** Update local cache - */ - switch (name) { - case GL_VENDOR: - gc->vendor = s; - break; - - case GL_RENDERER: - gc->renderer = s; - break; - - case GL_VERSION:{ - int client_major; - int client_minor; - - version_from_string((char *) s, - &gc->server_major, &gc->server_minor); - __glXGetGLVersion(&client_major, &client_minor); - - if ((gc->server_major < client_major) - || ((gc->server_major == client_major) - && (gc->server_minor <= client_minor))) { - gc->version = s; - } - else { - /* Allow 7 bytes for the client-side GL version. This allows - * for upto version 999.999. I'm not holding my breath for - * that one! The extra 4 is for the ' ()\0' that will be - * added. - */ - const size_t size = 7 + strlen((char *) s) + 4; - - gc->version = Xmalloc(size); - if (gc->version == NULL) { - /* If we couldn't allocate memory for the new string, - * make a best-effort and just copy the client-side version - * to the string and use that. It probably doesn't - * matter what is done here. If there not memory available - * for a short string, the system is probably going to die - * soon anyway. - */ - snprintf((char *) s, strlen((char *) s) + 1, "%u.%u", - client_major, client_minor); - gc->version = s; - } - else { - snprintf((char *) gc->version, size, "%u.%u (%s)", - client_major, client_minor, s); - Xfree(s); - s = gc->version; - } - } - break; - } - - case GL_EXTENSIONS:{ - int major = 1; - int minor = 0; - - /* This code is currently disabled. I was reminded that some - * vendors intentionally exclude some extensions from their - * extension string that are part of the core version they - * advertise. In particular, on Nvidia drivers this means that - * the functionality is supported by the driver, but is not - * hardware accelerated. For example, a TNT will show core - * version 1.5, but most of the post-1.2 functionality is a - * software fallback. - * - * I don't want to break applications that rely on this odd - * behavior. At the same time, the code is written and tested, - * so I didn't want to throw it away. Therefore, the code is here - * but disabled. In the future, we may wish to and an environment - * variable to enable it. - */ - -#if 0 - /* Call glGetString just to make sure that gc->server_major and - * gc->server_minor are set. This version may be higher than we - * can completely support, but it may imply support for some - * extensions that we can support. - * - * For example, at the time of this writing, the client-side - * library only supports upto core GL version 1.2. However, cubic - * textures, multitexture, multisampling, and some other 1.3 - * features are supported. If the server reports back version - * 1.3, but does not report all of those extensions, we will - * enable them. - */ - (void *) glGetString(GL_VERSION); - major = gc->server_major, minor = gc->server_minor; -#endif - - __glXCalculateUsableGLExtensions(gc, (char *) s, major, minor); - XFree(s); - s = gc->extensions; - break; - } - } - } - return s; -} - -GLboolean -__indirect_glIsEnabled(GLenum cap) -{ - __GLX_SINGLE_DECLARE_VARIABLES(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - xGLXSingleReply reply; - GLboolean retval = 0; - GLintptr enable; - - if (!dpy) - return 0; - - switch (cap) { - case GL_VERTEX_ARRAY: - case GL_NORMAL_ARRAY: - case GL_COLOR_ARRAY: - case GL_INDEX_ARRAY: - case GL_EDGE_FLAG_ARRAY: - case GL_SECONDARY_COLOR_ARRAY: - case GL_FOG_COORD_ARRAY: - retval = __glXGetArrayEnable(state, cap, 0, &enable); - assert(retval); - return (GLboolean) enable; - break; - case GL_TEXTURE_COORD_ARRAY: - retval = __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY, - __glXGetActiveTextureUnit(state), &enable); - assert(retval); - return (GLboolean) enable; - break; - } - - __GLX_SINGLE_LOAD_VARIABLES(); - __GLX_SINGLE_BEGIN(X_GLsop_IsEnabled, 4); - __GLX_SINGLE_PUT_LONG(0, cap); - __GLX_SINGLE_READ_XREPLY(); - __GLX_SINGLE_GET_RETVAL(retval, GLboolean); - __GLX_SINGLE_END(); - return retval; -} - -void -__indirect_glGetPointerv(GLenum pname, void **params) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - Display *dpy = gc->currentDpy; - - if (!dpy) - return; - - switch (pname) { - case GL_VERTEX_ARRAY_POINTER: - case GL_NORMAL_ARRAY_POINTER: - case GL_COLOR_ARRAY_POINTER: - case GL_INDEX_ARRAY_POINTER: - case GL_EDGE_FLAG_ARRAY_POINTER: - __glXGetArrayPointer(state, pname - GL_VERTEX_ARRAY_POINTER - + GL_VERTEX_ARRAY, 0, params); - return; - case GL_TEXTURE_COORD_ARRAY_POINTER: - __glXGetArrayPointer(state, GL_TEXTURE_COORD_ARRAY, - __glXGetActiveTextureUnit(state), params); - return; - case GL_SECONDARY_COLOR_ARRAY_POINTER: - case GL_FOG_COORD_ARRAY_POINTER: - __glXGetArrayPointer(state, pname - GL_FOG_COORD_ARRAY_POINTER - + GL_FOG_COORD_ARRAY, 0, params); - return; - case GL_FEEDBACK_BUFFER_POINTER: - *params = (void *) gc->feedbackBuf; - return; - case GL_SELECTION_BUFFER_POINTER: - *params = (void *) gc->selectBuf; - return; - default: - __glXSetError(gc, GL_INVALID_ENUM); - return; - } -} - - - -/** - * This was previously auto-generated, but we need to special-case - * how we handle writing into the 'residences' buffer when n%4!=0. - */ -#define X_GLsop_AreTexturesResident 143 -GLboolean -__indirect_glAreTexturesResident(GLsizei n, const GLuint * textures, - GLboolean * residences) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - GLboolean retval = (GLboolean) 0; - const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { -#ifdef USE_XCB - xcb_connection_t *c = XGetXCBConnection(dpy); - (void) __glXFlushRenderBuffer(gc, gc->pc); - xcb_glx_are_textures_resident_reply_t *reply = - xcb_glx_are_textures_resident_reply(c, - xcb_glx_are_textures_resident - (c, gc->currentContextTag, n, - textures), NULL); - (void) memcpy(residences, xcb_glx_are_textures_resident_data(reply), - xcb_glx_are_textures_resident_data_length(reply) * - sizeof(GLboolean)); - retval = reply->ret_val; - free(reply); -#else - GLubyte const *pc = - __glXSetupSingleRequest(gc, X_GLsop_AreTexturesResident, cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4)); - if (n & 3) { - /* n is not a multiple of four. - * When reply_is_always_array is TRUE, __glXReadReply() will - * put a multiple of four bytes into the dest buffer. If the - * caller's buffer is not a multiple of four in size, we'll write - * out of bounds. So use a temporary buffer that's a few bytes - * larger. - */ - GLboolean *res4 = malloc((n + 3) & ~3); - retval = (GLboolean) __glXReadReply(dpy, 1, res4, GL_TRUE); - memcpy(residences, res4, n); - free(res4); - } - else { - retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE); - } - UnlockDisplay(dpy); - SyncHandle(); -#endif /* USE_XCB */ - } - return retval; -} - - -/** - * This was previously auto-generated, but we need to special-case - * how we handle writing into the 'residences' buffer when n%4!=0. - */ -#define X_GLvop_AreTexturesResidentEXT 11 -GLboolean -glAreTexturesResidentEXT(GLsizei n, const GLuint * textures, - GLboolean * residences) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - - if (gc->isDirect) { - return CALL_AreTexturesResident(GET_DISPATCH(), - (n, textures, residences)); - } - else { - __GLXcontext *const gc = __glXGetCurrentContext(); - Display *const dpy = gc->currentDpy; - GLboolean retval = (GLboolean) 0; - const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); - if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_AreTexturesResidentEXT, - cmdlen); - (void) memcpy((void *) (pc + 0), (void *) (&n), 4); - (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4)); - if (n & 3) { - /* see comments in __indirect_glAreTexturesResident() */ - GLboolean *res4 = malloc((n + 3) & ~3); - retval = (GLboolean) __glXReadReply(dpy, 1, res4, GL_TRUE); - memcpy(residences, res4, n); - free(res4); - } - else { - retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE); - } - UnlockDisplay(dpy); - SyncHandle(); - } - return retval; - } -} diff --git a/src/glx/x11/singlepix.c b/src/glx/x11/singlepix.c deleted file mode 100644 index f5ebf4dfdbf..00000000000 --- a/src/glx/x11/singlepix.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include "packsingle.h" -#include "indirect.h" -#include "glapitable.h" -#include "glapidispatch.h" -#include "glapi.h" -#include "glthread.h" -#include "glapioffsets.h" -#include - -void -__indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type, - GLvoid * row, GLvoid * column, GLvoid * span) -{ - __GLX_SINGLE_DECLARE_VARIABLES(); - const __GLXattribute *state; - xGLXGetSeparableFilterReply reply; - GLubyte *rowBuf, *colBuf; - - if (!dpy) - return; - __GLX_SINGLE_LOAD_VARIABLES(); - state = gc->client_state_private; - - /* Send request */ - __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter, __GLX_PAD(13)); - __GLX_SINGLE_PUT_LONG(0, target); - __GLX_SINGLE_PUT_LONG(4, format); - __GLX_SINGLE_PUT_LONG(8, type); - __GLX_SINGLE_PUT_CHAR(12, state->storePack.swapEndian); - __GLX_SINGLE_READ_XREPLY(); - compsize = reply.length << 2; - - if (compsize != 0) { - GLint width, height; - GLint widthsize, heightsize; - - width = reply.width; - height = reply.height; - - widthsize = __glImageSize(width, 1, 1, format, type, 0); - heightsize = __glImageSize(height, 1, 1, format, type, 0); - - /* Allocate a holding buffer to transform the data from */ - rowBuf = (GLubyte *) Xmalloc(widthsize); - if (!rowBuf) { - /* Throw data away */ - _XEatData(dpy, compsize); - __glXSetError(gc, GL_OUT_OF_MEMORY); - UnlockDisplay(dpy); - SyncHandle(); - return; - } - else { - __GLX_SINGLE_GET_CHAR_ARRAY(((char *) rowBuf), widthsize); - __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row); - Xfree((char *) rowBuf); - } - colBuf = (GLubyte *) Xmalloc(heightsize); - if (!colBuf) { - /* Throw data away */ - _XEatData(dpy, compsize - __GLX_PAD(widthsize)); - __glXSetError(gc, GL_OUT_OF_MEMORY); - UnlockDisplay(dpy); - SyncHandle(); - return; - } - else { - __GLX_SINGLE_GET_CHAR_ARRAY(((char *) colBuf), heightsize); - __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column); - Xfree((char *) colBuf); - } - } - else { - /* - ** don't modify user's buffer. - */ - } - __GLX_SINGLE_END(); - -} - - -#define CONCAT(a,b) a ## b -#define NAME(o) CONCAT(gl_dispatch_stub_, o) - -void NAME(_gloffset_GetSeparableFilter) (GLenum target, GLenum format, - GLenum type, GLvoid * row, - GLvoid * column, GLvoid * span) -{ - __GLXcontext *const gc = __glXGetCurrentContext(); - -#ifdef GLX_DIRECT_RENDERING - if (gc->driContext) { - CALL_GetSeparableFilter(GET_DISPATCH(), - (target, format, type, row, column, span)); - return; - } - else -#endif - { - Display *const dpy = gc->currentDpy; - const GLuint cmdlen = __GLX_PAD(13); - - if (dpy != NULL) { - const __GLXattribute *const state = gc->client_state_private; - xGLXGetSeparableFilterReply reply; - GLubyte const *pc = - __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, - X_GLvop_GetSeparableFilterEXT, cmdlen); - unsigned compsize; - - - (void) memcpy((void *) (pc + 0), (void *) (&target), 4); - (void) memcpy((void *) (pc + 4), (void *) (&format), 4); - (void) memcpy((void *) (pc + 8), (void *) (&type), 4); - *(int8_t *) (pc + 12) = state->storePack.swapEndian; - - (void) _XReply(dpy, (xReply *) & reply, 0, False); - - compsize = reply.length << 2; - - if (compsize != 0) { - const GLint width = reply.width; - const GLint height = reply.height; - const GLint widthsize = - __glImageSize(width, 1, 1, format, type, 0); - const GLint heightsize = - __glImageSize(height, 1, 1, format, type, 0); - GLubyte *const buf = - (GLubyte *) Xmalloc((widthsize > heightsize) ? widthsize : - heightsize); - - if (buf == NULL) { - /* Throw data away */ - _XEatData(dpy, compsize); - __glXSetError(gc, GL_OUT_OF_MEMORY); - - UnlockDisplay(dpy); - SyncHandle(); - return; - } - else { - int extra; - - extra = 4 - (widthsize & 3); - _XRead(dpy, (char *) buf, widthsize); - if (extra < 4) { - _XEatData(dpy, extra); - } - - __glEmptyImage(gc, 1, width, 1, 1, format, type, buf, row); - - extra = 4 - (heightsize & 3); - _XRead(dpy, (char *) buf, heightsize); - if (extra < 4) { - _XEatData(dpy, extra); - } - - __glEmptyImage(gc, 1, height, 1, 1, format, type, buf, column); - - Xfree((char *) buf); - } - } - } - } -} diff --git a/src/glx/x11/vertarr.c b/src/glx/x11/vertarr.c deleted file mode 100644 index 398cfb1e796..00000000000 --- a/src/glx/x11/vertarr.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include "glxclient.h" -#include "indirect.h" -#include "indirect_vertex_array.h" - - -/*****************************************************************************/ - -/** - * \name Vertex array pointer bridge functions - * - * When EXT_vertex_array was moved into the core GL spec, the \c count - * parameter was lost. This libGL really only wants to implement the GL 1.1 - * version, but we need to support applications that were written to the old - * interface. These bridge functions are part of the glue that makes this - * happen. - */ -/*@{*/ -void -__indirect_glColorPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid * pointer) -{ - (void) count; - __indirect_glColorPointer(size, type, stride, pointer); -} - -void -__indirect_glEdgeFlagPointerEXT(GLsizei stride, - GLsizei count, const GLboolean * pointer) -{ - (void) count; - __indirect_glEdgeFlagPointer(stride, pointer); -} - -void -__indirect_glIndexPointerEXT(GLenum type, GLsizei stride, - GLsizei count, const GLvoid * pointer) -{ - (void) count; - __indirect_glIndexPointer(type, stride, pointer); -} - -void -__indirect_glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid * pointer) -{ - (void) count; - __indirect_glNormalPointer(type, stride, pointer); -} - -void -__indirect_glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid * pointer) -{ - (void) count; - __indirect_glTexCoordPointer(size, type, stride, pointer); -} - -void -__indirect_glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid * pointer) -{ - (void) count; - __indirect_glVertexPointer(size, type, stride, pointer); -} - -/*@}*/ - -/*****************************************************************************/ - -void -__indirect_glInterleavedArrays(GLenum format, GLsizei stride, - const GLvoid * pointer) -{ - __GLXcontext *gc = __glXGetCurrentContext(); - __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); - -#define NONE {0, 0, 0} -#define F(x) {GL_FLOAT, x, x * sizeof(GLfloat)} -#define UB4 {GL_UNSIGNED_BYTE, 4, 4 * sizeof(GLubyte)} - - /* Each row in this array describes the elements of a particular - * interleaved array mode. Each column describes, in the order in which - * they appear in the interleaved arrays, one of the four possible types - * of vertex data that can appear in an interleaved array. - */ - struct - { - /** - * The enum describing the GL type, as would be passed to the - * appropriate gl*Pointer function. - */ - GLushort type; - - /** - * Number of elements in the subarray, as would be passed (as the - * \c size parameter) to the appropriate gl*Pointer function. - */ - GLubyte count; - - /** - * True size of a single element in the subarray, as would be passed - * (as the \c stride parameter) to the appropriate gl*Pointer - * function. - */ - GLubyte size; - } - static const modes[14][4] = { - /* texture color normal vertex */ - {NONE, NONE, NONE, F(2)}, /* GL_V2F */ - {NONE, NONE, NONE, F(3)}, /* GL_V3F */ - {NONE, UB4, NONE, F(2)}, /* GL_C4UB_V2F */ - {NONE, UB4, NONE, F(3)}, /* GL_C4UB_V3F */ - {NONE, F(3), NONE, F(3)}, /* GL_C3F_V3F */ - {NONE, NONE, F(3), F(3)}, /* GL_N3F_V3F */ - {NONE, F(4), F(3), F(3)}, /* GL_C4F_N3F_V3F */ - {F(2), NONE, NONE, F(3)}, /* GL_T2F_V3F */ - {F(4), NONE, NONE, F(4)}, /* GL_T4F_V4F */ - {F(2), UB4, NONE, F(3)}, /* GL_T2F_C4UB_V3F */ - {F(2), F(3), NONE, F(3)}, /* GL_T2F_C3F_V3F */ - {F(2), NONE, F(3), F(3)}, /* GL_T2F_N3F_V3F */ - {F(2), F(4), F(3), F(3)}, /* GL_T2F_C4F_N3F_V3F */ - {F(4), F(4), F(3), F(4)}, /* GL_T4F_C4F_N3F_V4F */ - }; -#undef NONE -#undef F -#undef UB4 - - GLint trueStride, size; - int offsets[4]; - unsigned i; - const int idx = format - GL_V2F; - - - /* All valid formats are on the range [GL_V2F, GL_V2F+0x0D]. Since idx - * is just the format biased by -GL_V2F, all valid idx values are on the - * range [0, 0x0D]. - */ - if ((idx < 0) || (idx > 0x0D)) { - __glXSetError(gc, GL_INVALID_ENUM); - return; - } - - if (stride < 0) { - __glXSetError(gc, GL_INVALID_VALUE); - return; - } - - - /* If the 'count' for a subarray is non-zero, then the offset of its - * first element is at the currently accumulated 'size'. - */ - size = 0; - for (i = 0; i < 4; i++) { - offsets[i] = (modes[idx][i].count != 0) ? size : -1; - size += modes[idx][i].size; - } - - trueStride = (stride == 0) ? size : stride; - - __glXArrayDisableAll(state); - - if (offsets[0] >= 0) { - __indirect_glEnableClientState(GL_TEXTURE_COORD_ARRAY); - __indirect_glTexCoordPointer(modes[idx][0].count, GL_FLOAT, - trueStride, (const char *) pointer); - } - if (offsets[1] >= 0) { - __indirect_glEnableClientState(GL_COLOR_ARRAY); - __indirect_glColorPointer(modes[idx][1].count, modes[idx][1].type, - trueStride, - (const char *) pointer + offsets[1]); - } - if (offsets[2] >= 0) { - __indirect_glEnableClientState(GL_NORMAL_ARRAY); - __indirect_glNormalPointer(GL_FLOAT, trueStride, - (const char *) pointer + offsets[2]); - } - __indirect_glEnableClientState(GL_VERTEX_ARRAY); - __indirect_glVertexPointer(modes[idx][3].count, GL_FLOAT, - trueStride, - (const char *) pointer + offsets[3]); -} diff --git a/src/glx/x11/xf86dri.h b/src/glx/x11/xf86dri.h deleted file mode 100644 index ba266003f70..00000000000 --- a/src/glx/x11/xf86dri.h +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/** - * \file xf86dri.h - * Protocol numbers and function prototypes for DRI X protocol. - * - * \author Kevin E. Martin - * \author Jens Owen - * \author Rickard E. (Rik) Faith - */ - -#ifndef _XF86DRI_H_ -#define _XF86DRI_H_ - -#include -#include - -#define X_XF86DRIQueryVersion 0 -#define X_XF86DRIQueryDirectRenderingCapable 1 -#define X_XF86DRIOpenConnection 2 -#define X_XF86DRICloseConnection 3 -#define X_XF86DRIGetClientDriverName 4 -#define X_XF86DRICreateContext 5 -#define X_XF86DRIDestroyContext 6 -#define X_XF86DRICreateDrawable 7 -#define X_XF86DRIDestroyDrawable 8 -#define X_XF86DRIGetDrawableInfo 9 -#define X_XF86DRIGetDeviceInfo 10 -#define X_XF86DRIAuthConnection 11 -#define X_XF86DRIOpenFullScreen 12 /* Deprecated */ -#define X_XF86DRICloseFullScreen 13 /* Deprecated */ - -#define XF86DRINumberEvents 0 - -#define XF86DRIClientNotLocal 0 -#define XF86DRIOperationNotSupported 1 -#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1) - -#ifndef _XF86DRI_SERVER_ - -_XFUNCPROTOBEGIN - Bool XF86DRIQueryExtension(Display * dpy, int *event_base, - int *error_base); - -Bool XF86DRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion, - int *patchVersion); - -Bool XF86DRIQueryDirectRenderingCapable(Display * dpy, int screen, - Bool * isCapable); - -Bool XF86DRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA, - char **busIDString); - -Bool XF86DRIAuthConnection(Display * dpy, int screen, drm_magic_t magic); - -Bool XF86DRICloseConnection(Display * dpy, int screen); - -Bool XF86DRIGetClientDriverName(Display * dpy, int screen, - int *ddxDriverMajorVersion, - int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, - char **clientDriverName); - -Bool XF86DRICreateContext(Display * dpy, int screen, Visual * visual, - XID * ptr_to_returned_context_id, - drm_context_t * hHWContext); - -Bool XF86DRICreateContextWithConfig(Display * dpy, int screen, int configID, - XID * ptr_to_returned_context_id, - drm_context_t * hHWContext); - -extern Bool XF86DRIDestroyContext(Display * dpy, int screen, XID context_id); - -extern Bool XF86DRICreateDrawable(Display * dpy, int screen, - XID drawable, drm_drawable_t * hHWDrawable); - -extern Bool XF86DRIDestroyDrawable(Display * dpy, int screen, XID drawable); - -Bool XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, - unsigned int *index, unsigned int *stamp, - int *X, int *Y, int *W, int *H, - int *numClipRects, drm_clip_rect_t ** pClipRects, - int *backX, int *backY, - int *numBackClipRects, - drm_clip_rect_t ** pBackClipRects); - -Bool XF86DRIGetDeviceInfo(Display * dpy, int screen, - drm_handle_t * hFrameBuffer, int *fbOrigin, - int *fbSize, int *fbStride, int *devPrivateSize, - void **pDevPrivate); - -Bool XF86DRIOpenFullScreen(Display * dpy, int screen, Drawable drawable); - -Bool XF86DRICloseFullScreen(Display * dpy, int screen, Drawable drawable); - -_XFUNCPROTOEND -#endif /* _XF86DRI_SERVER_ */ -#endif /* _XF86DRI_H_ */ diff --git a/src/glx/x11/xf86dristr.h b/src/glx/x11/xf86dristr.h deleted file mode 100644 index c8fbe9d4c70..00000000000 --- a/src/glx/x11/xf86dristr.h +++ /dev/null @@ -1,367 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * Jens Owen - * Rickard E. (Rik) Fiath - * - */ - -#ifndef _XF86DRISTR_H_ -#define _XF86DRISTR_H_ - -#include "xf86dri.h" - -#define XF86DRINAME "XFree86-DRI" - -/* The DRI version number. This was originally set to be the same of the - * XFree86 version number. However, this version is really indepedent of - * the XFree86 version. - * - * Version History: - * 4.0.0: Original - * 4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02 - * 4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02 - */ -#define XF86DRI_MAJOR_VERSION 4 -#define XF86DRI_MINOR_VERSION 1 -#define XF86DRI_PATCH_VERSION 0 - -typedef struct _XF86DRIQueryVersion -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIQueryVersion */ - CARD16 length B16; -} xXF86DRIQueryVersionReq; -#define sz_xXF86DRIQueryVersionReq 4 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 majorVersion B16; /* major version of DRI protocol */ - CARD16 minorVersion B16; /* minor version of DRI protocol */ - CARD32 patchVersion B32; /* patch version of DRI protocol */ - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIQueryVersionReply; -#define sz_xXF86DRIQueryVersionReply 32 - -typedef struct _XF86DRIQueryDirectRenderingCapable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIQueryDirectRenderingCapableReq; -#define sz_xXF86DRIQueryDirectRenderingCapableReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - BOOL isCapable; - BOOL pad2; - BOOL pad3; - BOOL pad4; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; - CARD32 pad9 B32; -} xXF86DRIQueryDirectRenderingCapableReply; -#define sz_xXF86DRIQueryDirectRenderingCapableReply 32 - -typedef struct _XF86DRIOpenConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIOpenConnection */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIOpenConnectionReq; -#define sz_xXF86DRIOpenConnectionReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hSAREALow B32; - CARD32 hSAREAHigh B32; - CARD32 busIdStringLength B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; -} xXF86DRIOpenConnectionReply; -#define sz_xXF86DRIOpenConnectionReply 32 - -typedef struct _XF86DRIAuthConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseConnection */ - CARD16 length B16; - CARD32 screen B32; - CARD32 magic B32; -} xXF86DRIAuthConnectionReq; -#define sz_xXF86DRIAuthConnectionReq 12 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 authenticated B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIAuthConnectionReply; -#define zx_xXF86DRIAuthConnectionReply 32 - -typedef struct _XF86DRICloseConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseConnection */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRICloseConnectionReq; -#define sz_xXF86DRICloseConnectionReq 8 - -typedef struct _XF86DRIGetClientDriverName -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIGetClientDriverName */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIGetClientDriverNameReq; -#define sz_xXF86DRIGetClientDriverNameReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 ddxDriverMajorVersion B32; - CARD32 ddxDriverMinorVersion B32; - CARD32 ddxDriverPatchVersion B32; - CARD32 clientDriverNameLength B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIGetClientDriverNameReply; -#define sz_xXF86DRIGetClientDriverNameReply 32 - -typedef struct _XF86DRICreateContext -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICreateContext */ - CARD16 length B16; - CARD32 screen B32; - CARD32 visual B32; - CARD32 context B32; -} xXF86DRICreateContextReq; -#define sz_xXF86DRICreateContextReq 16 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hHWContext B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRICreateContextReply; -#define sz_xXF86DRICreateContextReply 32 - -typedef struct _XF86DRIDestroyContext -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIDestroyContext */ - CARD16 length B16; - CARD32 screen B32; - CARD32 context B32; -} xXF86DRIDestroyContextReq; -#define sz_xXF86DRIDestroyContextReq 12 - -typedef struct _XF86DRICreateDrawable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICreateDrawable */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRICreateDrawableReq; -#define sz_xXF86DRICreateDrawableReq 12 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hHWDrawable B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRICreateDrawableReply; -#define sz_xXF86DRICreateDrawableReply 32 - -typedef struct _XF86DRIDestroyDrawable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIDestroyDrawable */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRIDestroyDrawableReq; -#define sz_xXF86DRIDestroyDrawableReq 12 - -typedef struct _XF86DRIGetDrawableInfo -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIGetDrawableInfo */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRIGetDrawableInfoReq; -#define sz_xXF86DRIGetDrawableInfoReq 12 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 drawableTableIndex B32; - CARD32 drawableTableStamp B32; - INT16 drawableX B16; - INT16 drawableY B16; - INT16 drawableWidth B16; - INT16 drawableHeight B16; - CARD32 numClipRects B32; - INT16 backX B16; - INT16 backY B16; - CARD32 numBackClipRects B32; -} xXF86DRIGetDrawableInfoReply; - -#define sz_xXF86DRIGetDrawableInfoReply 36 - - -typedef struct _XF86DRIGetDeviceInfo -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIGetDeviceInfo */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIGetDeviceInfoReq; -#define sz_xXF86DRIGetDeviceInfoReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hFrameBufferLow B32; - CARD32 hFrameBufferHigh B32; - CARD32 framebufferOrigin B32; - CARD32 framebufferSize B32; - CARD32 framebufferStride B32; - CARD32 devPrivateSize B32; -} xXF86DRIGetDeviceInfoReply; -#define sz_xXF86DRIGetDeviceInfoReply 32 - -typedef struct _XF86DRIOpenFullScreen -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIOpenFullScreen */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRIOpenFullScreenReq; -#define sz_xXF86DRIOpenFullScreenReq 12 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 isFullScreen B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIOpenFullScreenReply; -#define sz_xXF86DRIOpenFullScreenReply 32 - -typedef struct _XF86DRICloseFullScreen -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseFullScreen */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRICloseFullScreenReq; -#define sz_xXF86DRICloseFullScreenReq 12 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; -} xXF86DRICloseFullScreenReply; -#define sz_xXF86DRICloseFullScreenReply 32 - - -#endif /* _XF86DRISTR_H_ */ diff --git a/src/glx/x11/xfont.c b/src/glx/x11/xfont.c deleted file mode 100644 index 797fd7a4900..00000000000 --- a/src/glx/x11/xfont.c +++ /dev/null @@ -1,377 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 3.1 - * - * Copyright (C) 1999 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/* xfonts.c -- glXUseXFont() for Mesa written by - * Copyright (C) 1995 Thorsten.Ohl @ Physik.TH-Darmstadt.de - */ - -/* - This was take from Mesa and modified to work in the real GLX structure. - It provides a fully client side implementation of glXUseXFont and is - called by that routine when direct rendering is enabled. -*/ - -#ifdef GLX_DIRECT_RENDERING - -#include "glxclient.h" - -/* Some debugging info. */ - -#ifdef DEBUG -#undef _R -#undef _G -#undef _B -#include - -int debug_xfonts = 0; - -static void -dump_char_struct(XCharStruct * ch, char *prefix) -{ - printf("%slbearing = %d, rbearing = %d, width = %d\n", - prefix, ch->lbearing, ch->rbearing, ch->width); - printf("%sascent = %d, descent = %d, attributes = %u\n", - prefix, ch->ascent, ch->descent, (unsigned int) ch->attributes); -} - -static void -dump_font_struct(XFontStruct * font) -{ - printf("ascent = %d, descent = %d\n", font->ascent, font->descent); - printf("char_or_byte2 = (%u,%u)\n", - font->min_char_or_byte2, font->max_char_or_byte2); - printf("byte1 = (%u,%u)\n", font->min_byte1, font->max_byte1); - printf("all_chars_exist = %s\n", font->all_chars_exist ? "True" : "False"); - printf("default_char = %c (\\%03o)\n", - (char) (isprint(font->default_char) ? font->default_char : ' '), - font->default_char); - dump_char_struct(&font->min_bounds, "min> "); - dump_char_struct(&font->max_bounds, "max> "); -#if 0 - for (c = font->min_char_or_byte2; c <= font->max_char_or_byte2; c++) { - char prefix[8]; - sprintf(prefix, "%d> ", c); - dump_char_struct(&font->per_char[c], prefix); - } -#endif -} - -static void -dump_bitmap(unsigned int width, unsigned int height, GLubyte * bitmap) -{ - unsigned int x, y; - - printf(" "); - for (x = 0; x < 8 * width; x++) - printf("%o", 7 - (x % 8)); - putchar('\n'); - for (y = 0; y < height; y++) { - printf("%3o:", y); - for (x = 0; x < 8 * width; x++) - putchar((bitmap[width * (height - y - 1) + x / 8] & (1 << (7 - (x % - 8)))) - ? '*' : '.'); - printf(" "); - for (x = 0; x < width; x++) - printf("0x%02x, ", bitmap[width * (height - y - 1) + x]); - putchar('\n'); - } -} -#endif /* DEBUG */ - - -/* Implementation. */ - -/* Fill a BITMAP with a character C from thew current font - in the graphics context GC. WIDTH is the width in bytes - and HEIGHT is the height in bits. - - Note that the generated bitmaps must be used with - - glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE); - glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE); - glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei (GL_UNPACK_SKIP_ROWS, 0); - glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei (GL_UNPACK_ALIGNMENT, 1); - - Possible optimizations: - - * use only one reusable pixmap with the maximum dimensions. - * draw the entire font into a single pixmap (careful with - proportional fonts!). -*/ - - -/* - * Generate OpenGL-compatible bitmap. - */ -static void -fill_bitmap(Display * dpy, Window win, GC gc, - unsigned int width, unsigned int height, - int x0, int y0, unsigned int c, GLubyte * bitmap) -{ - XImage *image; - unsigned int x, y; - Pixmap pixmap; - XChar2b char2b; - - pixmap = XCreatePixmap(dpy, win, 8 * width, height, 1); - XSetForeground(dpy, gc, 0); - XFillRectangle(dpy, pixmap, gc, 0, 0, 8 * width, height); - XSetForeground(dpy, gc, 1); - - char2b.byte1 = (c >> 8) & 0xff; - char2b.byte2 = (c & 0xff); - - XDrawString16(dpy, pixmap, gc, x0, y0, &char2b, 1); - - image = XGetImage(dpy, pixmap, 0, 0, 8 * width, height, 1, XYPixmap); - if (image) { - /* Fill the bitmap (X11 and OpenGL are upside down wrt each other). */ - for (y = 0; y < height; y++) - for (x = 0; x < 8 * width; x++) - if (XGetPixel(image, x, y)) - bitmap[width * (height - y - 1) + x / 8] |= - (1 << (7 - (x % 8))); - XDestroyImage(image); - } - - XFreePixmap(dpy, pixmap); -} - -/* - * determine if a given glyph is valid and return the - * corresponding XCharStruct. - */ -static XCharStruct * -isvalid(XFontStruct * fs, int which) -{ - unsigned int rows, pages; - int byte1 = 0, byte2 = 0; - int i, valid = 1; - - rows = fs->max_byte1 - fs->min_byte1 + 1; - pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1; - - if (rows == 1) { - /* "linear" fonts */ - if ((fs->min_char_or_byte2 > which) || (fs->max_char_or_byte2 < which)) - valid = 0; - } - else { - /* "matrix" fonts */ - byte2 = which & 0xff; - byte1 = which >> 8; - if ((fs->min_char_or_byte2 > byte2) || - (fs->max_char_or_byte2 < byte2) || - (fs->min_byte1 > byte1) || (fs->max_byte1 < byte1)) - valid = 0; - } - - if (valid) { - if (fs->per_char) { - if (rows == 1) { - /* "linear" fonts */ - return (fs->per_char + (which - fs->min_char_or_byte2)); - } - else { - /* "matrix" fonts */ - i = ((byte1 - fs->min_byte1) * pages) + - (byte2 - fs->min_char_or_byte2); - return (fs->per_char + i); - } - } - else { - return (&fs->min_bounds); - } - } - return (NULL); -} - -_X_HIDDEN void -DRI_glXUseXFont(Font font, int first, int count, int listbase) -{ - GLXContext CC; - Display *dpy; - Window win; - Pixmap pixmap; - GC gc; - XGCValues values; - unsigned long valuemask; - XFontStruct *fs; - - GLint swapbytes, lsbfirst, rowlength; - GLint skiprows, skippixels, alignment; - - unsigned int max_width, max_height, max_bm_width, max_bm_height; - GLubyte *bm; - - int i; - - CC = __glXGetCurrentContext(); - dpy = CC->currentDpy; - win = CC->currentDrawable; - - fs = XQueryFont(dpy, font); - if (!fs) { - __glXSetError(CC, GL_INVALID_VALUE); - return; - } - - /* Allocate a bitmap that can fit all characters. */ - max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing; - max_height = fs->max_bounds.ascent + fs->max_bounds.descent; - max_bm_width = (max_width + 7) / 8; - max_bm_height = max_height; - - bm = (GLubyte *) Xmalloc((max_bm_width * max_bm_height) * sizeof(GLubyte)); - if (!bm) { - XFreeFontInfo(NULL, fs, 1); - __glXSetError(CC, GL_OUT_OF_MEMORY); - return; - } - -#if 0 - /* get the page info */ - pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1; - firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2; - lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2; - rows = fs->max_byte1 - fs->min_byte1 + 1; - unsigned int first_char, last_char, pages, rows; -#endif - - /* Save the current packing mode for bitmaps. */ - glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes); - glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst); - glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength); - glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows); - glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels); - glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); - - /* Enforce a standard packing mode which is compatible with - fill_bitmap() from above. This is actually the default mode, - except for the (non)alignment. */ - glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); - glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - pixmap = XCreatePixmap(dpy, win, 10, 10, 1); - values.foreground = BlackPixel(dpy, DefaultScreen(dpy)); - values.background = WhitePixel(dpy, DefaultScreen(dpy)); - values.font = fs->fid; - valuemask = GCForeground | GCBackground | GCFont; - gc = XCreateGC(dpy, pixmap, valuemask, &values); - XFreePixmap(dpy, pixmap); - -#ifdef DEBUG - if (debug_xfonts) - dump_font_struct(fs); -#endif - - for (i = 0; i < count; i++) { - unsigned int width, height, bm_width, bm_height; - GLfloat x0, y0, dx, dy; - XCharStruct *ch; - int x, y; - unsigned int c = first + i; - int list = listbase + i; - int valid; - - /* check on index validity and get the bounds */ - ch = isvalid(fs, c); - if (!ch) { - ch = &fs->max_bounds; - valid = 0; - } - else { - valid = 1; - } - -#ifdef DEBUG - if (debug_xfonts) { - char s[7]; - sprintf(s, isprint(c) ? "%c> " : "\\%03o> ", c); - dump_char_struct(ch, s); - } -#endif - - /* glBitmap()' parameters: - straight from the glXUseXFont(3) manpage. */ - width = ch->rbearing - ch->lbearing; - height = ch->ascent + ch->descent; - x0 = -ch->lbearing; - y0 = ch->descent - 1; - dx = ch->width; - dy = 0; - - /* X11's starting point. */ - x = -ch->lbearing; - y = ch->ascent; - - /* Round the width to a multiple of eight. We will use this also - for the pixmap for capturing the X11 font. This is slightly - inefficient, but it makes the OpenGL part real easy. */ - bm_width = (width + 7) / 8; - bm_height = height; - - glNewList(list, GL_COMPILE); - if (valid && (bm_width > 0) && (bm_height > 0)) { - - memset(bm, '\0', bm_width * bm_height); - fill_bitmap(dpy, win, gc, bm_width, bm_height, x, y, c, bm); - - glBitmap(width, height, x0, y0, dx, dy, bm); -#ifdef DEBUG - if (debug_xfonts) { - printf("width/height = %u/%u\n", width, height); - printf("bm_width/bm_height = %u/%u\n", bm_width, bm_height); - dump_bitmap(bm_width, bm_height, bm); - } -#endif - } - else { - glBitmap(0, 0, 0.0, 0.0, dx, dy, NULL); - } - glEndList(); - } - - Xfree(bm); - XFreeFontInfo(NULL, fs, 1); - XFreeGC(dpy, gc); - - /* Restore saved packing modes. */ - glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes); - glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst); - glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength); - glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels); - glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); -} - -#endif diff --git a/src/glx/xf86dri.h b/src/glx/xf86dri.h new file mode 100644 index 00000000000..ba266003f70 --- /dev/null +++ b/src/glx/xf86dri.h @@ -0,0 +1,124 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +Copyright 2000 VA Linux Systems, Inc. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/** + * \file xf86dri.h + * Protocol numbers and function prototypes for DRI X protocol. + * + * \author Kevin E. Martin + * \author Jens Owen + * \author Rickard E. (Rik) Faith + */ + +#ifndef _XF86DRI_H_ +#define _XF86DRI_H_ + +#include +#include + +#define X_XF86DRIQueryVersion 0 +#define X_XF86DRIQueryDirectRenderingCapable 1 +#define X_XF86DRIOpenConnection 2 +#define X_XF86DRICloseConnection 3 +#define X_XF86DRIGetClientDriverName 4 +#define X_XF86DRICreateContext 5 +#define X_XF86DRIDestroyContext 6 +#define X_XF86DRICreateDrawable 7 +#define X_XF86DRIDestroyDrawable 8 +#define X_XF86DRIGetDrawableInfo 9 +#define X_XF86DRIGetDeviceInfo 10 +#define X_XF86DRIAuthConnection 11 +#define X_XF86DRIOpenFullScreen 12 /* Deprecated */ +#define X_XF86DRICloseFullScreen 13 /* Deprecated */ + +#define XF86DRINumberEvents 0 + +#define XF86DRIClientNotLocal 0 +#define XF86DRIOperationNotSupported 1 +#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1) + +#ifndef _XF86DRI_SERVER_ + +_XFUNCPROTOBEGIN + Bool XF86DRIQueryExtension(Display * dpy, int *event_base, + int *error_base); + +Bool XF86DRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion, + int *patchVersion); + +Bool XF86DRIQueryDirectRenderingCapable(Display * dpy, int screen, + Bool * isCapable); + +Bool XF86DRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA, + char **busIDString); + +Bool XF86DRIAuthConnection(Display * dpy, int screen, drm_magic_t magic); + +Bool XF86DRICloseConnection(Display * dpy, int screen); + +Bool XF86DRIGetClientDriverName(Display * dpy, int screen, + int *ddxDriverMajorVersion, + int *ddxDriverMinorVersion, + int *ddxDriverPatchVersion, + char **clientDriverName); + +Bool XF86DRICreateContext(Display * dpy, int screen, Visual * visual, + XID * ptr_to_returned_context_id, + drm_context_t * hHWContext); + +Bool XF86DRICreateContextWithConfig(Display * dpy, int screen, int configID, + XID * ptr_to_returned_context_id, + drm_context_t * hHWContext); + +extern Bool XF86DRIDestroyContext(Display * dpy, int screen, XID context_id); + +extern Bool XF86DRICreateDrawable(Display * dpy, int screen, + XID drawable, drm_drawable_t * hHWDrawable); + +extern Bool XF86DRIDestroyDrawable(Display * dpy, int screen, XID drawable); + +Bool XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, + unsigned int *index, unsigned int *stamp, + int *X, int *Y, int *W, int *H, + int *numClipRects, drm_clip_rect_t ** pClipRects, + int *backX, int *backY, + int *numBackClipRects, + drm_clip_rect_t ** pBackClipRects); + +Bool XF86DRIGetDeviceInfo(Display * dpy, int screen, + drm_handle_t * hFrameBuffer, int *fbOrigin, + int *fbSize, int *fbStride, int *devPrivateSize, + void **pDevPrivate); + +Bool XF86DRIOpenFullScreen(Display * dpy, int screen, Drawable drawable); + +Bool XF86DRICloseFullScreen(Display * dpy, int screen, Drawable drawable); + +_XFUNCPROTOEND +#endif /* _XF86DRI_SERVER_ */ +#endif /* _XF86DRI_H_ */ diff --git a/src/glx/xf86dristr.h b/src/glx/xf86dristr.h new file mode 100644 index 00000000000..c8fbe9d4c70 --- /dev/null +++ b/src/glx/xf86dristr.h @@ -0,0 +1,367 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +Copyright 2000 VA Linux Systems, Inc. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin + * Jens Owen + * Rickard E. (Rik) Fiath + * + */ + +#ifndef _XF86DRISTR_H_ +#define _XF86DRISTR_H_ + +#include "xf86dri.h" + +#define XF86DRINAME "XFree86-DRI" + +/* The DRI version number. This was originally set to be the same of the + * XFree86 version number. However, this version is really indepedent of + * the XFree86 version. + * + * Version History: + * 4.0.0: Original + * 4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02 + * 4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02 + */ +#define XF86DRI_MAJOR_VERSION 4 +#define XF86DRI_MINOR_VERSION 1 +#define XF86DRI_PATCH_VERSION 0 + +typedef struct _XF86DRIQueryVersion +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIQueryVersion */ + CARD16 length B16; +} xXF86DRIQueryVersionReq; +#define sz_xXF86DRIQueryVersionReq 4 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD16 majorVersion B16; /* major version of DRI protocol */ + CARD16 minorVersion B16; /* minor version of DRI protocol */ + CARD32 patchVersion B32; /* patch version of DRI protocol */ + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRIQueryVersionReply; +#define sz_xXF86DRIQueryVersionReply 32 + +typedef struct _XF86DRIQueryDirectRenderingCapable +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */ + CARD16 length B16; + CARD32 screen B32; +} xXF86DRIQueryDirectRenderingCapableReq; +#define sz_xXF86DRIQueryDirectRenderingCapableReq 8 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + BOOL isCapable; + BOOL pad2; + BOOL pad3; + BOOL pad4; + CARD32 pad5 B32; + CARD32 pad6 B32; + CARD32 pad7 B32; + CARD32 pad8 B32; + CARD32 pad9 B32; +} xXF86DRIQueryDirectRenderingCapableReply; +#define sz_xXF86DRIQueryDirectRenderingCapableReply 32 + +typedef struct _XF86DRIOpenConnection +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIOpenConnection */ + CARD16 length B16; + CARD32 screen B32; +} xXF86DRIOpenConnectionReq; +#define sz_xXF86DRIOpenConnectionReq 8 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 hSAREALow B32; + CARD32 hSAREAHigh B32; + CARD32 busIdStringLength B32; + CARD32 pad6 B32; + CARD32 pad7 B32; + CARD32 pad8 B32; +} xXF86DRIOpenConnectionReply; +#define sz_xXF86DRIOpenConnectionReply 32 + +typedef struct _XF86DRIAuthConnection +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICloseConnection */ + CARD16 length B16; + CARD32 screen B32; + CARD32 magic B32; +} xXF86DRIAuthConnectionReq; +#define sz_xXF86DRIAuthConnectionReq 12 + +typedef struct +{ + BYTE type; + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 authenticated B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRIAuthConnectionReply; +#define zx_xXF86DRIAuthConnectionReply 32 + +typedef struct _XF86DRICloseConnection +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICloseConnection */ + CARD16 length B16; + CARD32 screen B32; +} xXF86DRICloseConnectionReq; +#define sz_xXF86DRICloseConnectionReq 8 + +typedef struct _XF86DRIGetClientDriverName +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIGetClientDriverName */ + CARD16 length B16; + CARD32 screen B32; +} xXF86DRIGetClientDriverNameReq; +#define sz_xXF86DRIGetClientDriverNameReq 8 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 ddxDriverMajorVersion B32; + CARD32 ddxDriverMinorVersion B32; + CARD32 ddxDriverPatchVersion B32; + CARD32 clientDriverNameLength B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRIGetClientDriverNameReply; +#define sz_xXF86DRIGetClientDriverNameReply 32 + +typedef struct _XF86DRICreateContext +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICreateContext */ + CARD16 length B16; + CARD32 screen B32; + CARD32 visual B32; + CARD32 context B32; +} xXF86DRICreateContextReq; +#define sz_xXF86DRICreateContextReq 16 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 hHWContext B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRICreateContextReply; +#define sz_xXF86DRICreateContextReply 32 + +typedef struct _XF86DRIDestroyContext +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIDestroyContext */ + CARD16 length B16; + CARD32 screen B32; + CARD32 context B32; +} xXF86DRIDestroyContextReq; +#define sz_xXF86DRIDestroyContextReq 12 + +typedef struct _XF86DRICreateDrawable +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICreateDrawable */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; +} xXF86DRICreateDrawableReq; +#define sz_xXF86DRICreateDrawableReq 12 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 hHWDrawable B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRICreateDrawableReply; +#define sz_xXF86DRICreateDrawableReply 32 + +typedef struct _XF86DRIDestroyDrawable +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIDestroyDrawable */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; +} xXF86DRIDestroyDrawableReq; +#define sz_xXF86DRIDestroyDrawableReq 12 + +typedef struct _XF86DRIGetDrawableInfo +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIGetDrawableInfo */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; +} xXF86DRIGetDrawableInfoReq; +#define sz_xXF86DRIGetDrawableInfoReq 12 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 drawableTableIndex B32; + CARD32 drawableTableStamp B32; + INT16 drawableX B16; + INT16 drawableY B16; + INT16 drawableWidth B16; + INT16 drawableHeight B16; + CARD32 numClipRects B32; + INT16 backX B16; + INT16 backY B16; + CARD32 numBackClipRects B32; +} xXF86DRIGetDrawableInfoReply; + +#define sz_xXF86DRIGetDrawableInfoReply 36 + + +typedef struct _XF86DRIGetDeviceInfo +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIGetDeviceInfo */ + CARD16 length B16; + CARD32 screen B32; +} xXF86DRIGetDeviceInfoReq; +#define sz_xXF86DRIGetDeviceInfoReq 8 + +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 hFrameBufferLow B32; + CARD32 hFrameBufferHigh B32; + CARD32 framebufferOrigin B32; + CARD32 framebufferSize B32; + CARD32 framebufferStride B32; + CARD32 devPrivateSize B32; +} xXF86DRIGetDeviceInfoReply; +#define sz_xXF86DRIGetDeviceInfoReply 32 + +typedef struct _XF86DRIOpenFullScreen +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIOpenFullScreen */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; +} xXF86DRIOpenFullScreenReq; +#define sz_xXF86DRIOpenFullScreenReq 12 + +typedef struct +{ + BYTE type; + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 isFullScreen B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRIOpenFullScreenReply; +#define sz_xXF86DRIOpenFullScreenReply 32 + +typedef struct _XF86DRICloseFullScreen +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICloseFullScreen */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; +} xXF86DRICloseFullScreenReq; +#define sz_xXF86DRICloseFullScreenReq 12 + +typedef struct +{ + BYTE type; + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; + CARD32 pad7 B32; +} xXF86DRICloseFullScreenReply; +#define sz_xXF86DRICloseFullScreenReply 32 + + +#endif /* _XF86DRISTR_H_ */ diff --git a/src/glx/xfont.c b/src/glx/xfont.c new file mode 100644 index 00000000000..797fd7a4900 --- /dev/null +++ b/src/glx/xfont.c @@ -0,0 +1,377 @@ +/* + * Mesa 3-D graphics library + * Version: 3.1 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/* xfonts.c -- glXUseXFont() for Mesa written by + * Copyright (C) 1995 Thorsten.Ohl @ Physik.TH-Darmstadt.de + */ + +/* + This was take from Mesa and modified to work in the real GLX structure. + It provides a fully client side implementation of glXUseXFont and is + called by that routine when direct rendering is enabled. +*/ + +#ifdef GLX_DIRECT_RENDERING + +#include "glxclient.h" + +/* Some debugging info. */ + +#ifdef DEBUG +#undef _R +#undef _G +#undef _B +#include + +int debug_xfonts = 0; + +static void +dump_char_struct(XCharStruct * ch, char *prefix) +{ + printf("%slbearing = %d, rbearing = %d, width = %d\n", + prefix, ch->lbearing, ch->rbearing, ch->width); + printf("%sascent = %d, descent = %d, attributes = %u\n", + prefix, ch->ascent, ch->descent, (unsigned int) ch->attributes); +} + +static void +dump_font_struct(XFontStruct * font) +{ + printf("ascent = %d, descent = %d\n", font->ascent, font->descent); + printf("char_or_byte2 = (%u,%u)\n", + font->min_char_or_byte2, font->max_char_or_byte2); + printf("byte1 = (%u,%u)\n", font->min_byte1, font->max_byte1); + printf("all_chars_exist = %s\n", font->all_chars_exist ? "True" : "False"); + printf("default_char = %c (\\%03o)\n", + (char) (isprint(font->default_char) ? font->default_char : ' '), + font->default_char); + dump_char_struct(&font->min_bounds, "min> "); + dump_char_struct(&font->max_bounds, "max> "); +#if 0 + for (c = font->min_char_or_byte2; c <= font->max_char_or_byte2; c++) { + char prefix[8]; + sprintf(prefix, "%d> ", c); + dump_char_struct(&font->per_char[c], prefix); + } +#endif +} + +static void +dump_bitmap(unsigned int width, unsigned int height, GLubyte * bitmap) +{ + unsigned int x, y; + + printf(" "); + for (x = 0; x < 8 * width; x++) + printf("%o", 7 - (x % 8)); + putchar('\n'); + for (y = 0; y < height; y++) { + printf("%3o:", y); + for (x = 0; x < 8 * width; x++) + putchar((bitmap[width * (height - y - 1) + x / 8] & (1 << (7 - (x % + 8)))) + ? '*' : '.'); + printf(" "); + for (x = 0; x < width; x++) + printf("0x%02x, ", bitmap[width * (height - y - 1) + x]); + putchar('\n'); + } +} +#endif /* DEBUG */ + + +/* Implementation. */ + +/* Fill a BITMAP with a character C from thew current font + in the graphics context GC. WIDTH is the width in bytes + and HEIGHT is the height in bits. + + Note that the generated bitmaps must be used with + + glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE); + glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE); + glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); + glPixelStorei (GL_UNPACK_SKIP_ROWS, 0); + glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0); + glPixelStorei (GL_UNPACK_ALIGNMENT, 1); + + Possible optimizations: + + * use only one reusable pixmap with the maximum dimensions. + * draw the entire font into a single pixmap (careful with + proportional fonts!). +*/ + + +/* + * Generate OpenGL-compatible bitmap. + */ +static void +fill_bitmap(Display * dpy, Window win, GC gc, + unsigned int width, unsigned int height, + int x0, int y0, unsigned int c, GLubyte * bitmap) +{ + XImage *image; + unsigned int x, y; + Pixmap pixmap; + XChar2b char2b; + + pixmap = XCreatePixmap(dpy, win, 8 * width, height, 1); + XSetForeground(dpy, gc, 0); + XFillRectangle(dpy, pixmap, gc, 0, 0, 8 * width, height); + XSetForeground(dpy, gc, 1); + + char2b.byte1 = (c >> 8) & 0xff; + char2b.byte2 = (c & 0xff); + + XDrawString16(dpy, pixmap, gc, x0, y0, &char2b, 1); + + image = XGetImage(dpy, pixmap, 0, 0, 8 * width, height, 1, XYPixmap); + if (image) { + /* Fill the bitmap (X11 and OpenGL are upside down wrt each other). */ + for (y = 0; y < height; y++) + for (x = 0; x < 8 * width; x++) + if (XGetPixel(image, x, y)) + bitmap[width * (height - y - 1) + x / 8] |= + (1 << (7 - (x % 8))); + XDestroyImage(image); + } + + XFreePixmap(dpy, pixmap); +} + +/* + * determine if a given glyph is valid and return the + * corresponding XCharStruct. + */ +static XCharStruct * +isvalid(XFontStruct * fs, int which) +{ + unsigned int rows, pages; + int byte1 = 0, byte2 = 0; + int i, valid = 1; + + rows = fs->max_byte1 - fs->min_byte1 + 1; + pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1; + + if (rows == 1) { + /* "linear" fonts */ + if ((fs->min_char_or_byte2 > which) || (fs->max_char_or_byte2 < which)) + valid = 0; + } + else { + /* "matrix" fonts */ + byte2 = which & 0xff; + byte1 = which >> 8; + if ((fs->min_char_or_byte2 > byte2) || + (fs->max_char_or_byte2 < byte2) || + (fs->min_byte1 > byte1) || (fs->max_byte1 < byte1)) + valid = 0; + } + + if (valid) { + if (fs->per_char) { + if (rows == 1) { + /* "linear" fonts */ + return (fs->per_char + (which - fs->min_char_or_byte2)); + } + else { + /* "matrix" fonts */ + i = ((byte1 - fs->min_byte1) * pages) + + (byte2 - fs->min_char_or_byte2); + return (fs->per_char + i); + } + } + else { + return (&fs->min_bounds); + } + } + return (NULL); +} + +_X_HIDDEN void +DRI_glXUseXFont(Font font, int first, int count, int listbase) +{ + GLXContext CC; + Display *dpy; + Window win; + Pixmap pixmap; + GC gc; + XGCValues values; + unsigned long valuemask; + XFontStruct *fs; + + GLint swapbytes, lsbfirst, rowlength; + GLint skiprows, skippixels, alignment; + + unsigned int max_width, max_height, max_bm_width, max_bm_height; + GLubyte *bm; + + int i; + + CC = __glXGetCurrentContext(); + dpy = CC->currentDpy; + win = CC->currentDrawable; + + fs = XQueryFont(dpy, font); + if (!fs) { + __glXSetError(CC, GL_INVALID_VALUE); + return; + } + + /* Allocate a bitmap that can fit all characters. */ + max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing; + max_height = fs->max_bounds.ascent + fs->max_bounds.descent; + max_bm_width = (max_width + 7) / 8; + max_bm_height = max_height; + + bm = (GLubyte *) Xmalloc((max_bm_width * max_bm_height) * sizeof(GLubyte)); + if (!bm) { + XFreeFontInfo(NULL, fs, 1); + __glXSetError(CC, GL_OUT_OF_MEMORY); + return; + } + +#if 0 + /* get the page info */ + pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1; + firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2; + lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2; + rows = fs->max_byte1 - fs->min_byte1 + 1; + unsigned int first_char, last_char, pages, rows; +#endif + + /* Save the current packing mode for bitmaps. */ + glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes); + glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst); + glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength); + glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows); + glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels); + glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); + + /* Enforce a standard packing mode which is compatible with + fill_bitmap() from above. This is actually the default mode, + except for the (non)alignment. */ + glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); + glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + pixmap = XCreatePixmap(dpy, win, 10, 10, 1); + values.foreground = BlackPixel(dpy, DefaultScreen(dpy)); + values.background = WhitePixel(dpy, DefaultScreen(dpy)); + values.font = fs->fid; + valuemask = GCForeground | GCBackground | GCFont; + gc = XCreateGC(dpy, pixmap, valuemask, &values); + XFreePixmap(dpy, pixmap); + +#ifdef DEBUG + if (debug_xfonts) + dump_font_struct(fs); +#endif + + for (i = 0; i < count; i++) { + unsigned int width, height, bm_width, bm_height; + GLfloat x0, y0, dx, dy; + XCharStruct *ch; + int x, y; + unsigned int c = first + i; + int list = listbase + i; + int valid; + + /* check on index validity and get the bounds */ + ch = isvalid(fs, c); + if (!ch) { + ch = &fs->max_bounds; + valid = 0; + } + else { + valid = 1; + } + +#ifdef DEBUG + if (debug_xfonts) { + char s[7]; + sprintf(s, isprint(c) ? "%c> " : "\\%03o> ", c); + dump_char_struct(ch, s); + } +#endif + + /* glBitmap()' parameters: + straight from the glXUseXFont(3) manpage. */ + width = ch->rbearing - ch->lbearing; + height = ch->ascent + ch->descent; + x0 = -ch->lbearing; + y0 = ch->descent - 1; + dx = ch->width; + dy = 0; + + /* X11's starting point. */ + x = -ch->lbearing; + y = ch->ascent; + + /* Round the width to a multiple of eight. We will use this also + for the pixmap for capturing the X11 font. This is slightly + inefficient, but it makes the OpenGL part real easy. */ + bm_width = (width + 7) / 8; + bm_height = height; + + glNewList(list, GL_COMPILE); + if (valid && (bm_width > 0) && (bm_height > 0)) { + + memset(bm, '\0', bm_width * bm_height); + fill_bitmap(dpy, win, gc, bm_width, bm_height, x, y, c, bm); + + glBitmap(width, height, x0, y0, dx, dy, bm); +#ifdef DEBUG + if (debug_xfonts) { + printf("width/height = %u/%u\n", width, height); + printf("bm_width/bm_height = %u/%u\n", bm_width, bm_height); + dump_bitmap(bm_width, bm_height, bm); + } +#endif + } + else { + glBitmap(0, 0, 0.0, 0.0, dx, dy, NULL); + } + glEndList(); + } + + Xfree(bm); + XFreeFontInfo(NULL, fs, 1); + XFreeGC(dpy, gc); + + /* Restore saved packing modes. */ + glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes); + glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst); + glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength); + glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels); + glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); +} + +#endif diff --git a/src/mesa/glapi/Makefile b/src/mesa/glapi/Makefile index bfc3db4313c..da679607d7b 100644 --- a/src/mesa/glapi/Makefile +++ b/src/mesa/glapi/Makefile @@ -13,11 +13,11 @@ OUTPUTS = glprocs.h glapitemp.h glapioffsets.h glapitable.h glapidispatch.h \ ../x86/glapi_x86.S \ ../x86-64/glapi_x86-64.S \ ../sparc/glapi_sparc.S \ - ../../glx/x11/indirect.c \ - ../../glx/x11/indirect.h \ - ../../glx/x11/indirect_init.c \ - ../../glx/x11/indirect_size.h \ - ../../glx/x11/indirect_size.c + ../../glx/indirect.c \ + ../../glx/indirect.h \ + ../../glx/indirect_init.c \ + ../../glx/indirect_size.h \ + ../../glx/indirect_size.c GLX_DIR = $(XORG_BASE)/glx @@ -110,20 +110,20 @@ glapidispatch.h $(GLX_DIR)/glapidispatch.h: gl_table.py $(COMMON) ../sparc/glapi_sparc.S: gl_SPARC_asm.py $(COMMON) $(PYTHON2) $(PYTHON_FLAGS) $< > $@ -../../glx/x11/indirect.c: glX_proto_send.py $(COMMON_GLX) +../../glx/indirect.c: glX_proto_send.py $(COMMON_GLX) $(PYTHON2) $(PYTHON_FLAGS) $< -m proto | $(INDENT) $(INDENT_FLAGS) > $@ -../../glx/x11/indirect.h: glX_proto_send.py $(COMMON_GLX) +../../glx/indirect.h: glX_proto_send.py $(COMMON_GLX) $(PYTHON2) $(PYTHON_FLAGS) $< -m init_h > $@ -../../glx/x11/indirect_init.c: glX_proto_send.py $(COMMON_GLX) +../../glx/indirect_init.c: glX_proto_send.py $(COMMON_GLX) $(PYTHON2) $(PYTHON_FLAGS) $< -m init_c > $@ -../../glx/x11/indirect_size.h $(GLX_DIR)/indirect_size.h: glX_proto_size.py $(COMMON_GLX) +../../glx/indirect_size.h $(GLX_DIR)/indirect_size.h: glX_proto_size.py $(COMMON_GLX) $(PYTHON2) $(PYTHON_FLAGS) $< -m size_h --only-set -h _INDIRECT_SIZE_H_ \ | $(INDENT) $(INDENT_FLAGS) > $@ -../../glx/x11/indirect_size.c: glX_proto_size.py $(COMMON_GLX) +../../glx/indirect_size.c: glX_proto_size.py $(COMMON_GLX) $(PYTHON2) $(PYTHON_FLAGS) $< -m size_c --only-set \ | $(INDENT) $(INDENT_FLAGS) > $@ diff --git a/src/mesa/main/dispatch.c b/src/mesa/main/dispatch.c index a6a57020cc7..b9b726b0017 100644 --- a/src/mesa/main/dispatch.c +++ b/src/mesa/main/dispatch.c @@ -32,7 +32,7 @@ * * \note * This file is also used to build the client-side libGL that loads DRI-based - * device drivers. At build-time it is symlinked to src/glx/x11. + * device drivers. At build-time it is symlinked to src/glx. * * \author Brian Paul */ -- cgit v1.2.3 From 1ebc5681545786c247aacec8198a0fccef93b5d8 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Tue, 9 Feb 2010 15:54:59 -0500 Subject: configure.ac: Enable egl demos when --enable-egl is passed --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index a273a16c891..27405bbc24c 100644 --- a/configure.ac +++ b/configure.ac @@ -924,6 +924,10 @@ if test "x$enable_egl" = xyes; then EGL_DRIVERS_DIRS="$EGL_DRIVERS_DIRS dri2" fi fi + + if test "$with_demos" = yes; then + PROGRAM_DIRS="$PROGRAM_DIRS egl" + fi fi AC_SUBST([EGL_LIB_DEPS]) AC_SUBST([EGL_DRIVERS_DIRS]) -- cgit v1.2.3 From aa0cd707af59efe322426420f68d42eb35ee922b Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Mon, 15 Feb 2010 10:44:05 -0500 Subject: configure.ac: Lower require dri2proto version to 2.1 Additions after 2.1 are implemented in a conditional way and will be supported if available. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 27405bbc24c..be06adf5e5e 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_CANONICAL_HOST dnl Versions for external dependencies LIBDRM_REQUIRED=2.4.15 LIBDRM_RADEON_REQUIRED=2.4.17 -DRI2PROTO_REQUIRED=2.2 +DRI2PROTO_REQUIRED=2.1 GLPROTO_REQUIRED=1.4.11 dnl Check for progs -- cgit v1.2.3 From 979889038ebb5b95b2e609372aaec10fd9da8172 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Feb 2010 12:46:12 -0700 Subject: configure: PTHREADS should be defined on cygwin, as well Signed-off-by: Jon TURNEY Signed-off-by: Brian Paul (cherry picked from commit c1a4f249f18a766488da0832fbf6700de93af2f8) --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index be06adf5e5e..485836a4282 100644 --- a/configure.ac +++ b/configure.ac @@ -92,6 +92,9 @@ linux*|*-gnu*|gnu*) solaris*) DEFINES="$DEFINES -DPTHREADS -DSVR4" ;; +cygwin*) + DEFINES="$DEFINES -DPTHREADS" + ;; esac dnl Add flags for gcc and g++ -- cgit v1.2.3 From 4387580e50f49d642160982208c807da858cd1ab Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 25 Feb 2010 15:49:18 -0500 Subject: Remove directfb support --- Makefile | 8 +- configs/linux-directfb | 38 - configure.ac | 2 +- docs/README.directfb | 29 - include/GL/directfbgl.h | 89 --- progs/directfb/.gitignore | 4 - progs/directfb/Makefile | 38 - progs/directfb/df_gears.c | 480 ------------ progs/directfb/df_morph3d.c | 1013 -------------------------- progs/directfb/df_reflect.c | 489 ------------- progs/directfb/multi_window.c | 240 ------ src/glut/directfb/Makefile | 87 --- src/glut/directfb/NOTES | 9 - src/glut/directfb/callback.c | 300 -------- src/glut/directfb/color.c | 39 - src/glut/directfb/cursor.c | 175 ----- src/glut/directfb/cursors.h | 306 -------- src/glut/directfb/events.c | 492 ------------- src/glut/directfb/ext.c | 202 ----- src/glut/directfb/font.c | 213 ------ src/glut/directfb/font.h | 58 -- src/glut/directfb/game.c | 153 ---- src/glut/directfb/globals.c | 63 -- src/glut/directfb/init.c | 128 ---- src/glut/directfb/internal.h | 188 ----- src/glut/directfb/menu.c | 87 --- src/glut/directfb/models.c | 599 --------------- src/glut/directfb/overlay.c | 62 -- src/glut/directfb/state.c | 219 ------ src/glut/directfb/teapot.c | 212 ------ src/glut/directfb/window.c | 597 --------------- src/mesa/drivers/directfb/Makefile | 67 -- src/mesa/drivers/directfb/idirectfbgl_mesa.c | 982 ------------------------- 33 files changed, 2 insertions(+), 7666 deletions(-) delete mode 100644 configs/linux-directfb delete mode 100644 docs/README.directfb delete mode 100644 include/GL/directfbgl.h delete mode 100644 progs/directfb/.gitignore delete mode 100644 progs/directfb/Makefile delete mode 100644 progs/directfb/df_gears.c delete mode 100644 progs/directfb/df_morph3d.c delete mode 100644 progs/directfb/df_reflect.c delete mode 100644 progs/directfb/multi_window.c delete mode 100644 src/glut/directfb/Makefile delete mode 100644 src/glut/directfb/NOTES delete mode 100644 src/glut/directfb/callback.c delete mode 100644 src/glut/directfb/color.c delete mode 100644 src/glut/directfb/cursor.c delete mode 100644 src/glut/directfb/cursors.h delete mode 100644 src/glut/directfb/events.c delete mode 100644 src/glut/directfb/ext.c delete mode 100644 src/glut/directfb/font.c delete mode 100644 src/glut/directfb/font.h delete mode 100644 src/glut/directfb/game.c delete mode 100644 src/glut/directfb/globals.c delete mode 100644 src/glut/directfb/init.c delete mode 100644 src/glut/directfb/internal.h delete mode 100644 src/glut/directfb/menu.c delete mode 100644 src/glut/directfb/models.c delete mode 100644 src/glut/directfb/overlay.c delete mode 100644 src/glut/directfb/state.c delete mode 100644 src/glut/directfb/teapot.c delete mode 100644 src/glut/directfb/window.c delete mode 100644 src/mesa/drivers/directfb/Makefile delete mode 100644 src/mesa/drivers/directfb/idirectfbgl_mesa.c (limited to 'configure.ac') diff --git a/Makefile b/Makefile index 3e92e1312ed..0527fa0d824 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ install: done -.PHONY: default doxygen clean realclean distclean install linux-directfb-install +.PHONY: default doxygen clean realclean distclean install # If there's no current configuration file $(TOP)/configs/current: @@ -109,7 +109,6 @@ linux-alpha-static \ linux-cell \ linux-cell-debug \ linux-debug \ -linux-directfb \ linux-dri \ linux-dri-debug \ linux-dri-x86 \ @@ -271,8 +270,6 @@ MAIN_FILES = \ $(DIRECTORY)/src/mesa/drivers/beos/Makefile \ $(DIRECTORY)/src/mesa/drivers/common/*.[ch] \ $(DIRECTORY)/src/mesa/drivers/common/descrip.mms \ - $(DIRECTORY)/src/mesa/drivers/directfb/*.[ch] \ - $(DIRECTORY)/src/mesa/drivers/directfb/Makefile \ $(DIRECTORY)/src/mesa/drivers/dos/*.[chS] \ $(DIRECTORY)/src/mesa/drivers/fbdev/Makefile \ $(DIRECTORY)/src/mesa/drivers/fbdev/glfbdev.c \ @@ -483,9 +480,6 @@ GLUT_FILES = \ $(DIRECTORY)/src/glut/fbdev/*[ch] \ $(DIRECTORY)/src/glut/mini/*[ch] \ $(DIRECTORY)/src/glut/mini/glut.pc.in \ - $(DIRECTORY)/src/glut/directfb/Makefile \ - $(DIRECTORY)/src/glut/directfb/NOTES \ - $(DIRECTORY)/src/glut/directfb/*[ch] DEPEND_FILES = \ $(TOP)/src/mesa/depend \ diff --git a/configs/linux-directfb b/configs/linux-directfb deleted file mode 100644 index 9ae3de96d1c..00000000000 --- a/configs/linux-directfb +++ /dev/null @@ -1,38 +0,0 @@ -# Configuration for DirectFB - -include $(TOP)/configs/default - -CONFIG_NAME = linux-directfb - -# Compiler and flags -CC = gcc -CXX = g++ - -CFLAGS = -Wall -O3 -ffast-math -fPIC -std=c99 -D_GNU_SOURCE -D_POSIX_SOURCE -D_SVID_SOURCE \ - -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -DPTHREADS - -CXXFLAGS = -Wall -O3 -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE - -# Work around aliasing bugs - developers should comment this out -CFLAGS += -fno-strict-aliasing -CXXFLAGS += -fno-strict-aliasing - -HAVE_X86 = $(shell uname -m | grep 'i[3-6]86' >/dev/null && echo yes) -ifeq ($(HAVE_X86), yes) - CFLAGS += -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM - CXXFLAGS += -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM - MESA_ASM_SOURCES = $(X86_SOURCES) - GLAPI_ASM_SOURCES = $(X86_API) -endif - -# Directories -SRC_DIRS = gallium mesa glu glut/directfb glew -GLU_DIRS = sgi -DRIVER_DIRS = directfb -PROGRAM_DIRS = demos directfb - -# Library/program dependencies -GL_LIB_DEPS = -lm -lpthread -GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -l$(GLU_LIB) -APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -l$(GLU_LIB) -l$(GLUT_LIB) - diff --git a/configure.ac b/configure.ac index 485836a4282..b4561000d22 100644 --- a/configure.ac +++ b/configure.ac @@ -395,7 +395,7 @@ fi dnl dnl Driver configuration. Options are xlib, dri and osmesa right now. -dnl More later: directfb, fbdev, ... +dnl More later: fbdev, ... dnl default_driver="xlib" diff --git a/docs/README.directfb b/docs/README.directfb deleted file mode 100644 index d66ca8d3caa..00000000000 --- a/docs/README.directfb +++ /dev/null @@ -1,29 +0,0 @@ - - Mesa DirectFB Information - - -Requirements -============ - - To build Mesa with DirectFB (DirectFBGL) support you need: - - DirectFB at least 1.0.0 (http://directfb.org) - - pkg-config at least 0.9 (http://pkgconfig.sf.net) - - -Installation -============ - Run - - make linux-directfb - - to build Mesa and DirectFBGL module, - - make install - - to install OpenGL libraries and - - cd src/mesa/drivers/directfb ; make install - - to install DirectFBGL module in the proper location. - Actually, that last command may not be needed. Please provide feedback. - diff --git a/include/GL/directfbgl.h b/include/GL/directfbgl.h deleted file mode 100644 index 984c4b14279..00000000000 --- a/include/GL/directfbgl.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - (c) Copyright 2001 convergence integrated media GmbH. - All rights reserved. - - Written by Denis Oliver Kropp and - Andreas Hundt . - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __DIRECTFBGL_H__ -#define __DIRECTFBGL_H__ - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - - -typedef struct { - int buffer_size; - int depth_size; - int stencil_size; - int aux_buffers; - - int red_size; - int green_size; - int blue_size; - int alpha_size; - - int accum_red_size; - int accum_green_size; - int accum_blue_size; - int accum_alpha_size; - - DFBBoolean double_buffer; - DFBBoolean stereo; -} DFBGLAttributes; - - -DEFINE_INTERFACE( IDirectFBGL, - - /** Context handling **/ - - /* - * Acquire the hardware lock. - */ - DFBResult (*Lock) ( - IDirectFBGL *thiz - ); - - /* - * Release the lock. - */ - DFBResult (*Unlock) ( - IDirectFBGL *thiz - ); - - /* - * Query the OpenGL attributes. - */ - DFBResult (*GetAttributes) ( - IDirectFBGL *thiz, - DFBGLAttributes *attributes - ); -) - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/progs/directfb/.gitignore b/progs/directfb/.gitignore deleted file mode 100644 index 55d65fb5b08..00000000000 --- a/progs/directfb/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -df_gears -df_morph3d -df_reflect -multi_window diff --git a/progs/directfb/Makefile b/progs/directfb/Makefile deleted file mode 100644 index 93c2a7df14b..00000000000 --- a/progs/directfb/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# progs/directfb/Makefile - -TOP = ../.. -include $(TOP)/configs/current - - -INCDIR = $(TOP)/include -I$(TOP)/progs - -LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) - -CFLAGS += $(shell pkg-config --cflags directfb) -APP_LIB_DEPS += $(shell pkg-config --libs directfb) - -LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) - -PROGS = df_gears \ - df_reflect \ - df_morph3d \ - multi_window - -##### RULES ##### - -.SUFFIXES: -.SUFFIXES: .c - -.c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ - - -##### TARGETS ##### - -default: $(PROGS) - - -clean: - -rm -f $(PROGS) - -rm -f *.o *~ - diff --git a/progs/directfb/df_gears.c b/progs/directfb/df_gears.c deleted file mode 100644 index c480767bd33..00000000000 --- a/progs/directfb/df_gears.c +++ /dev/null @@ -1,480 +0,0 @@ -/* - (c) Copyright 2001 convergence integrated media GmbH. - All rights reserved. - - Written by Denis Oliver Kropp and - Andreas Hundt . - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include -#include - -#include -#include - -#include - - -/* the super interface */ -IDirectFB *dfb; - -/* the primary surface (surface of primary layer) */ -IDirectFBSurface *primary; - -/* the GL context */ -IDirectFBGL *primary_gl; - -/* our font */ -IDirectFBFont *font; - -/* event buffer */ -IDirectFBEventBuffer *events; - -/* macro for a safe call to DirectFB functions */ -#define DFBCHECK(x...) \ - { \ - err = x; \ - if (err != DFB_OK) { \ - fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ - DirectFBErrorFatal( #x, err ); \ - } \ - } - -static int screen_width, screen_height; - -static unsigned long T0 = 0; -static GLint Frames = 0; -static GLfloat fps = 0; - -static inline unsigned long get_millis() -{ - struct timeval tv; - - gettimeofday (&tv, NULL); - return (tv.tv_sec * 1000 + tv.tv_usec / 1000); -} - - -#ifndef M_PI -#define M_PI 3.14159265 -#endif - -/** - - Draw a gear wheel. You'll probably want to call this function when - building a display list since we do a lot of trig here. - - Input: inner_radius - radius of hole at center - outer_radius - radius at center of teeth - width - width of gear - teeth - number of teeth - tooth_depth - depth of tooth - - **/ - -static void -gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, - GLint teeth, GLfloat tooth_depth) -{ - GLint i; - GLfloat r0, r1, r2; - GLfloat angle, da; - GLfloat u, v, len; - - r0 = inner_radius; - r1 = outer_radius - tooth_depth / 2.0; - r2 = outer_radius + tooth_depth / 2.0; - - da = 2.0 * M_PI / teeth / 4.0; - - glShadeModel(GL_FLAT); - - glNormal3f(0.0, 0.0, 1.0); - - /* draw front face */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); - glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); - if (i < teeth) { - glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); - } - } - glEnd(); - - /* draw front sides of teeth */ - glBegin(GL_QUADS); - da = 2.0 * M_PI / teeth / 4.0; - for (i = 0; i < teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - - glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); - glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); - glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); - } - glEnd(); - - glNormal3f(0.0, 0.0, -1.0); - - /* draw back face */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); - glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); - if (i < teeth) { - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); - glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); - } - } - glEnd(); - - /* draw back sides of teeth */ - glBegin(GL_QUADS); - da = 2.0 * M_PI / teeth / 4.0; - for (i = 0; i < teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); - glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); - glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); - glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); - } - glEnd(); - - /* draw outward faces of teeth */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i < teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - - glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); - glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); - u = r2 * cos(angle + da) - r1 * cos(angle); - v = r2 * sin(angle + da) - r1 * sin(angle); - len = sqrt(u * u + v * v); - u /= len; - v /= len; - glNormal3f(v, -u, 0.0); - glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); - glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); - glNormal3f(cos(angle), sin(angle), 0.0); - glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); - glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); - u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); - v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); - glNormal3f(v, -u, 0.0); - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); - glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); - glNormal3f(cos(angle), sin(angle), 0.0); - } - - glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); - glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); - - glEnd(); - - glShadeModel(GL_SMOOTH); - - /* draw inside radius cylinder */ - glBegin(GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0 * M_PI / teeth; - glNormal3f(-cos(angle), -sin(angle), 0.0); - glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); - glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); - } - glEnd(); - -} - -static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; -static GLfloat inc_rotx = 0, inc_roty = 0, inc_rotz = 0; -static GLint gear1, gear2, gear3; -static GLfloat angle = 0.0; - -static void -draw(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix(); - glRotatef(view_rotx, 1.0, 0.0, 0.0); - glRotatef(view_roty, 0.0, 1.0, 0.0); - glRotatef(view_rotz, 0.0, 0.0, 1.0); - - glPushMatrix(); - glTranslatef(-3.0, -2.0, 0.0); - glRotatef(angle, 0.0, 0.0, 1.0); - glCallList(gear1); - glPopMatrix(); - - glPushMatrix(); - glTranslatef(3.1, -2.0, 0.0); - glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0); - glCallList(gear2); - glPopMatrix(); - - glPushMatrix(); - glTranslatef(-3.1, 4.2, 0.0); - glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); - glCallList(gear3); - glPopMatrix(); - - glPopMatrix(); -} - -/* new window size or exposure */ -static void -reshape(int width, int height) -{ - GLfloat h = (GLfloat) height / (GLfloat) width; - - glViewport(0, 0, (GLint) width, (GLint) height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -40.0); -} - -static void -init(int argc, char *argv[]) -{ - static GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0}; - static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0}; - static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0}; - static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0}; - GLint i; - - glLightfv(GL_LIGHT0, GL_POSITION, pos); - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); - - /* make the gears */ - gear1 = glGenLists(1); - glNewList(gear1, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); - gear(1.0, 4.0, 1.0, 20, 0.7); - glEndList(); - - gear2 = glGenLists(1); - glNewList(gear2, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); - gear(0.5, 2.0, 2.0, 10, 0.7); - glEndList(); - - gear3 = glGenLists(1); - glNewList(gear3, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); - gear(1.3, 2.0, 0.5, 10, 0.7); - glEndList(); - - glEnable(GL_NORMALIZE); - - for ( i=1; iCreateInputEventBuffer( dfb, DICAPS_KEYS | DICAPS_AXES, - DFB_FALSE, &events )); - - /* set our cooperative level to DFSCL_FULLSCREEN - for exclusive access to the primary layer */ - dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN ); - - /* get the primary surface, i.e. the surface of the - primary layer we have exclusive access to */ - dsc.flags = DSDESC_CAPS; - dsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE; - - DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary )); - - /* get the size of the surface and fill it */ - DFBCHECK(primary->GetSize( primary, &screen_width, &screen_height )); - DFBCHECK(primary->FillRectangle( primary, 0, 0, - screen_width, screen_height )); - primary->Flip( primary, NULL, 0 ); - - /* create the default font and set it */ - DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font )); - DFBCHECK(primary->SetFont( primary, font )); - - /* get the GL context */ - DFBCHECK(primary->GetGL( primary, &primary_gl )); - - DFBCHECK(primary_gl->Lock( primary_gl )); - - init(argc, argv); - reshape(screen_width, screen_height); - - DFBCHECK(primary_gl->Unlock( primary_gl )); - - T0 = get_millis(); - - while (!quit) { - DFBInputEvent evt; - unsigned long t; - - DFBCHECK(primary_gl->Lock( primary_gl )); - - draw(); - - DFBCHECK(primary_gl->Unlock( primary_gl )); - - if (fps) { - char buf[64]; - - snprintf(buf, 64, "%4.1f FPS\n", fps); - - primary->SetColor( primary, 0xff, 0, 0, 0xff ); - primary->DrawString( primary, buf, -1, screen_width - 5, 5, DSTF_TOPRIGHT ); - } - - primary->Flip( primary, NULL, 0 ); - Frames++; - - - t = get_millis(); - if (t - T0 >= 2000) { - GLfloat seconds = (t - T0) / 1000.0; - - fps = Frames / seconds; - - T0 = t; - Frames = 0; - } - - - while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) { - switch (evt.type) { - case DIET_KEYPRESS: - switch (evt.key_symbol) { - case DIKS_ESCAPE: - quit = 1; - break; - case DIKS_CURSOR_UP: - inc_rotx = 5.0; - break; - case DIKS_CURSOR_DOWN: - inc_rotx = -5.0; - break; - case DIKS_CURSOR_LEFT: - inc_roty = 5.0; - break; - case DIKS_CURSOR_RIGHT: - inc_roty = -5.0; - break; - case DIKS_PAGE_UP: - inc_rotz = 5.0; - break; - case DIKS_PAGE_DOWN: - inc_rotz = -5.0; - break; - default: - ; - } - break; - case DIET_KEYRELEASE: - switch (evt.key_symbol) { - case DIKS_CURSOR_UP: - inc_rotx = 0; - break; - case DIKS_CURSOR_DOWN: - inc_rotx = 0; - break; - case DIKS_CURSOR_LEFT: - inc_roty = 0; - break; - case DIKS_CURSOR_RIGHT: - inc_roty = 0; - break; - case DIKS_PAGE_UP: - inc_rotz = 0; - break; - case DIKS_PAGE_DOWN: - inc_rotz = 0; - break; - default: - ; - } - break; - case DIET_AXISMOTION: - if (evt.flags & DIEF_AXISREL) { - switch (evt.axis) { - case DIAI_X: - view_roty += evt.axisrel / 2.0; - break; - case DIAI_Y: - view_rotx += evt.axisrel / 2.0; - break; - case DIAI_Z: - view_rotz += evt.axisrel / 2.0; - break; - default: - ; - } - } - break; - default: - ; - } - } - - angle += 2.0; - - view_rotx += inc_rotx; - view_roty += inc_roty; - view_rotz += inc_rotz; - } - - /* release our interfaces to shutdown DirectFB */ - primary_gl->Release( primary_gl ); - primary->Release( primary ); - font->Release( font ); - events->Release( events ); - dfb->Release( dfb ); - - return 0; -} - diff --git a/progs/directfb/df_morph3d.c b/progs/directfb/df_morph3d.c deleted file mode 100644 index 2730fa61569..00000000000 --- a/progs/directfb/df_morph3d.c +++ /dev/null @@ -1,1013 +0,0 @@ -/* - (c) Copyright 2001 convergence integrated media GmbH. - All rights reserved. - - Written by Denis Oliver Kropp and - Andreas Hundt . - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -/*- - * morph3d.c - Shows 3D morphing objects - * - * Converted to GLUT by brianp on 1/1/98 - * - * This program was inspired on a WindowsNT(R)'s screen saver. It was written - * from scratch and it was not based on any other source code. - * - * Porting it to xlock (the final objective of this code since the moment I - * decided to create it) was possible by comparing the original Mesa's gear - * demo with it's ported version, so thanks for Danny Sung for his indirect - * help (look at gear.c in xlock source tree). NOTE: At the moment this code - * was sent to Brian Paul for package inclusion, the XLock Version was not - * available. In fact, I'll wait it to appear on the next Mesa release (If you - * are reading this, it means THIS release) to send it for xlock package - * inclusion). It will probably there be a GLUT version too. - * - * Thanks goes also to Brian Paul for making it possible and inexpensive - * to use OpenGL at home. - * - * Since I'm not a native english speaker, my apologies for any gramatical - * mistake. - * - * My e-mail addresses are - * - * vianna@cat.cbpf.br - * and - * marcelo@venus.rdc.puc-rio.br - * - * Marcelo F. Vianna (Feb-13-1997) - */ - -/* -This document is VERY incomplete, but tries to describe the mathematics used -in the program. At this moment it just describes how the polyhedra are -generated. On futhurer versions, this document will be probabbly improved. - -Since I'm not a native english speaker, my apologies for any gramatical -mistake. - -Marcelo Fernandes Vianna -- Undergraduate in Computer Engeneering at Catholic Pontifical University -- of Rio de Janeiro (PUC-Rio) Brasil. -- e-mail: vianna@cat.cbpf.br or marcelo@venus.rdc.puc-rio.br -- Feb-13-1997 - -POLYHEDRA GENERATION - -For the purpose of this program it's not sufficient to know the polyhedra -vertexes coordinates. Since the morphing algorithm applies a nonlinear -transformation over the surfaces (faces) of the polyhedron, each face has -to be divided into smaller ones. The morphing algorithm needs to transform -each vertex of these smaller faces individually. It's a very time consoming -task. - -In order to reduce calculation overload, and since all the macro faces of -the polyhedron are transformed by the same way, the generation is made by -creating only one face of the polyhedron, morphing it and then rotating it -around the polyhedron center. - -What we need to know is the face radius of the polyhedron (the radius of -the inscribed sphere) and the angle between the center of two adjacent -faces using the center of the sphere as the angle's vertex. - -The face radius of the regular polyhedra are known values which I decided -to not waste my time calculating. Following is a table of face radius for -the regular polyhedra with edge length = 1: - - TETRAHEDRON : 1/(2*sqrt(2))/sqrt(3) - CUBE : 1/2 - OCTAHEDRON : 1/sqrt(6) - DODECAHEDRON : T^2 * sqrt((T+2)/5) / 2 -> where T=(sqrt(5)+1)/2 - ICOSAHEDRON : (3*sqrt(3)+sqrt(15))/12 - -I've not found any reference about the mentioned angles, so I needed to -calculate them, not a trivial task until I figured out how :) -Curiously these angles are the same for the tetrahedron and octahedron. -A way to obtain this value is inscribing the tetrahedron inside the cube -by matching their vertexes. So you'll notice that the remaining unmatched -vertexes are in the same straight line starting in the cube/tetrahedron -center and crossing the center of each tetrahedron's face. At this point -it's easy to obtain the bigger angle of the isosceles triangle formed by -the center of the cube and two opposite vertexes on the same cube face. -The edges of this triangle have the following lenghts: sqrt(2) for the base -and sqrt(3)/2 for the other two other edges. So the angle we want is: - +-----------------------------------------------------------+ - | 2*ARCSIN(sqrt(2)/sqrt(3)) = 109.47122063449069174 degrees | - +-----------------------------------------------------------+ -For the cube this angle is obvious, but just for formality it can be -easily obtained because we also know it's isosceles edge lenghts: -sqrt(2)/2 for the base and 1/2 for the other two edges. So the angle we -want is: - +-----------------------------------------------------------+ - | 2*ARCSIN((sqrt(2)/2)/1) = 90.000000000000000000 degrees | - +-----------------------------------------------------------+ -For the octahedron we use the same idea used for the tetrahedron, but now -we inscribe the cube inside the octahedron so that all cubes's vertexes -matches excatly the center of each octahedron's face. It's now clear that -this angle is the same of the thetrahedron one: - +-----------------------------------------------------------+ - | 2*ARCSIN(sqrt(2)/sqrt(3)) = 109.47122063449069174 degrees | - +-----------------------------------------------------------+ -For the dodecahedron it's a little bit harder because it's only relationship -with the cube is useless to us. So we need to solve the problem by another -way. The concept of Face radius also exists on 2D polygons with the name -Edge radius: - Edge Radius For Pentagon (ERp) - ERp = (1/2)/TAN(36 degrees) * VRp = 0.6881909602355867905 - (VRp is the pentagon's vertex radio). - Face Radius For Dodecahedron - FRd = T^2 * sqrt((T+2)/5) / 2 = 1.1135163644116068404 -Why we need ERp? Well, ERp and FRd segments forms a 90 degrees angle, -completing this triangle, the lesser angle is a half of the angle we are -looking for, so this angle is: - +-----------------------------------------------------------+ - | 2*ARCTAN(ERp/FRd) = 63.434948822922009981 degrees | - +-----------------------------------------------------------+ -For the icosahedron we can use the same method used for dodecahedron (well -the method used for dodecahedron may be used for all regular polyhedra) - Edge Radius For Triangle (this one is well known: 1/3 of the triangle height) - ERt = sin(60)/3 = sqrt(3)/6 = 0.2886751345948128655 - Face Radius For Icosahedron - FRi= (3*sqrt(3)+sqrt(15))/12 = 0.7557613140761707538 -So the angle is: - +-----------------------------------------------------------+ - | 2*ARCTAN(ERt/FRi) = 41.810314895778596167 degrees | - +-----------------------------------------------------------+ - -*/ - - -#include -#include -#include -#include -#include - -#include -#include - -#include - - -/* the super interface */ -IDirectFB *dfb; - -/* the primary surface (surface of primary layer) */ -IDirectFBSurface *primary; - -/* the GL context */ -IDirectFBGL *primary_gl; - -/* our font */ -IDirectFBFont *font; - -/* event buffer */ -IDirectFBEventBuffer *events; - -/* macro for a safe call to DirectFB functions */ -#define DFBCHECK(x...) \ - { \ - err = x; \ - if (err != DFB_OK) { \ - fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ - DirectFBErrorFatal( #x, err ); \ - } \ - } - -static int screen_width, screen_height; - -static unsigned long T0 = 0; -static GLint Frames = 0; -static GLfloat fps = 0; - -static inline unsigned long get_millis() -{ - struct timeval tv; - - gettimeofday (&tv, NULL); - return (tv.tv_sec * 1000 + tv.tv_usec / 1000); -} - - - -#define Scale 0.3 - -#define VectMul(X1,Y1,Z1,X2,Y2,Z2) (Y1)*(Z2)-(Z1)*(Y2),(Z1)*(X2)-(X1)*(Z2),(X1)*(Y2)-(Y1)*(X2) -#define sqr(A) ((A)*(A)) - -/* Increasing this values produces better image quality, the price is speed. */ -/* Very low values produces erroneous/incorrect plotting */ -#define tetradivisions 23 -#define cubedivisions 20 -#define octadivisions 21 -#define dodecadivisions 10 -#define icodivisions 15 - -#define tetraangle 109.47122063449069174 -#define cubeangle 90.000000000000000000 -#define octaangle 109.47122063449069174 -#define dodecaangle 63.434948822922009981 -#define icoangle 41.810314895778596167 - -#ifndef Pi -#define Pi 3.1415926535897932385 -#endif -#define SQRT2 1.4142135623730951455 -#define SQRT3 1.7320508075688771932 -#define SQRT5 2.2360679774997898051 -#define SQRT6 2.4494897427831778813 -#define SQRT15 3.8729833462074170214 -#define cossec36_2 0.8506508083520399322 -#define cos72 0.3090169943749474241 -#define sin72 0.9510565162951535721 -#define cos36 0.8090169943749474241 -#define sin36 0.5877852522924731292 - -/*************************************************************************/ - -static int mono=0; -static int smooth=1; -static GLint WindH, WindW; -static GLfloat step=0; -static GLfloat seno; -static int object; -static int edgedivisions; -static void (*draw_object)( void ); -static float Magnitude; -static float *MaterialColor[20]; - -static float front_shininess[] = {60.0}; -static float front_specular[] = { 0.7, 0.7, 0.7, 1.0 }; -static float ambient[] = { 0.0, 0.0, 0.0, 1.0 }; -static float diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; -static float position0[] = { 1.0, 1.0, 1.0, 0.0 }; -static float position1[] = {-1.0,-1.0, 1.0, 0.0 }; -static float lmodel_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; -static float lmodel_twoside[] = {GL_TRUE}; - -static float MaterialRed[] = { 0.7, 0.0, 0.0, 1.0 }; -static float MaterialGreen[] = { 0.1, 0.5, 0.2, 1.0 }; -static float MaterialBlue[] = { 0.0, 0.0, 0.7, 1.0 }; -static float MaterialCyan[] = { 0.2, 0.5, 0.7, 1.0 }; -static float MaterialYellow[] = { 0.7, 0.7, 0.0, 1.0 }; -static float MaterialMagenta[] = { 0.6, 0.2, 0.5, 1.0 }; -static float MaterialWhite[] = { 0.7, 0.7, 0.7, 1.0 }; -static float MaterialGray[] = { 0.2, 0.2, 0.2, 1.0 }; - -#define TRIANGLE(Edge, Amp, Divisions, Z) \ -{ \ - GLfloat Xf,Yf,Xa,Yb,Xf2,Yf2; \ - GLfloat Factor,Factor1,Factor2; \ - GLfloat VertX,VertY,VertZ,NeiAX,NeiAY,NeiAZ,NeiBX,NeiBY,NeiBZ; \ - GLfloat Ax,Ay,Bx; \ - int Ri,Ti; \ - GLfloat Vr=(Edge)*SQRT3/3; \ - GLfloat AmpVr2=(Amp)/sqr(Vr); \ - GLfloat Zf=(Edge)*(Z); \ - \ - Ax=(Edge)*(+0.5/(Divisions)), Ay=(Edge)*(-SQRT3/(2*Divisions)); \ - Bx=(Edge)*(-0.5/(Divisions)); \ - \ - for (Ri=1; Ri<=(Divisions); Ri++) { \ - glBegin(GL_TRIANGLE_STRIP); \ - for (Ti=0; TiFlip( primary, NULL, 0 ); - - glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); - glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); - glLightfv(GL_LIGHT0, GL_POSITION, position0); - glLightfv(GL_LIGHT1, GL_AMBIENT, ambient); - glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse); - glLightfv(GL_LIGHT1, GL_POSITION, position1); - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); - glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_LIGHT1); - glEnable(GL_DEPTH_TEST); - glEnable(GL_NORMALIZE); - - glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_shininess); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular); - - glHint(GL_FOG_HINT, GL_FASTEST); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); - glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST); - - pinit(); -} - -int main( int argc, char *argv[] ) -{ - int quit = 0; - DFBResult err; - DFBSurfaceDescription dsc; - - DFBCHECK(DirectFBInit( &argc, &argv )); - - /* create the super interface */ - DFBCHECK(DirectFBCreate( &dfb )); - - /* create an event buffer for all devices with these caps */ - DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_KEYS, DFB_FALSE, &events )); - - /* set our cooperative level to DFSCL_FULLSCREEN - for exclusive access to the primary layer */ - dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN ); - - /* get the primary surface, i.e. the surface of the - primary layer we have exclusive access to */ - dsc.flags = DSDESC_CAPS; - dsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE; - - DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary )); - - /* get the size of the surface and fill it */ - DFBCHECK(primary->GetSize( primary, &screen_width, &screen_height )); - DFBCHECK(primary->FillRectangle( primary, 0, 0, - screen_width, screen_height )); - - /* create the default font and set it */ - DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font )); - DFBCHECK(primary->SetFont( primary, font )); - - /* get the GL context */ - DFBCHECK(primary->GetGL( primary, &primary_gl )); - - DFBCHECK(primary_gl->Lock( primary_gl )); - - init(); - reshape(screen_width, screen_height); - - DFBCHECK(primary_gl->Unlock( primary_gl )); - - T0 = get_millis(); - - while (!quit) { - DFBInputEvent evt; - unsigned long t; - - primary->Clear( primary, 0, 0, 0, 0 ); - - DFBCHECK(primary_gl->Lock( primary_gl )); - - draw(); - - DFBCHECK(primary_gl->Unlock( primary_gl )); - - if (fps) { - char buf[64]; - - sprintf(buf, "%4.1f FPS\n", fps); - primary->SetColor( primary, 0xff, 0, 0, 0xff ); - primary->DrawString( primary, buf, -1, screen_width - 5, 5, DSTF_TOPRIGHT ); - } - - primary->Flip( primary, NULL, 0 ); - Frames++; - - - t = get_millis(); - if (t - T0 >= 1000) { - GLfloat seconds = (t - T0) / 1000.0; - - fps = Frames / seconds; - - T0 = t; - Frames = 0; - } - - - while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) { - switch (evt.type) { - case DIET_KEYPRESS: - switch (evt.key_symbol) { - case DIKS_ESCAPE: - quit = 1; - break; - case DIKS_1: object=1; break; - case DIKS_2: object=2; break; - case DIKS_3: object=3; break; - case DIKS_4: object=4; break; - case DIKS_5: object=5; break; - case DIKS_SPACE: mono^=1; break; - case DIKS_ENTER: smooth^=1; break; - default: - ; - } - pinit(); - break; - default: - ; - } - } - } - - /* release our interfaces to shutdown DirectFB */ - primary_gl->Release( primary_gl ); - primary->Release( primary ); - font->Release( font ); - events->Release( events ); - dfb->Release( dfb ); - - return 0; -} - diff --git a/progs/directfb/df_reflect.c b/progs/directfb/df_reflect.c deleted file mode 100644 index a0e789c3871..00000000000 --- a/progs/directfb/df_reflect.c +++ /dev/null @@ -1,489 +0,0 @@ -/* - (c) Copyright 2001 convergence integrated media GmbH. - All rights reserved. - - Written by Denis Oliver Kropp and - Andreas Hundt . - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include -#include - -#include -#include - -#include - -#include "util/showbuffer.c" -#include "util/readtex.c" - - -/* the super interface */ -IDirectFB *dfb; - -/* the primary surface (surface of primary layer) */ -IDirectFBSurface *primary; - -/* the GL context */ -IDirectFBGL *primary_gl; - -/* our font */ -IDirectFBFont *font; - -/* event buffer */ -IDirectFBEventBuffer *events; - -/* macro for a safe call to DirectFB functions */ -#define DFBCHECK(x...) \ - { \ - err = x; \ - if (err != DFB_OK) { \ - fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ - DirectFBErrorFatal( #x, err ); \ - } \ - } - -static int screen_width, screen_height; - -static unsigned long T0 = 0; -static GLint Frames = 0; -static GLfloat fps = 0; - -static inline unsigned long get_millis() -{ - struct timeval tv; - - gettimeofday (&tv, NULL); - return (tv.tv_sec * 1000 + tv.tv_usec / 1000); -} - -/*******************************/ - -#define DEG2RAD (3.14159/180.0) - -#define TABLE_TEXTURE "../images/tile.rgb" - -static GLint ImgWidth, ImgHeight; -static GLenum ImgFormat; -static GLubyte *Image = NULL; - -#define MAX_OBJECTS 2 -static GLint table_list; -static GLint objects_list[MAX_OBJECTS]; - -static GLfloat xrot, yrot; -static GLfloat spin; - -static GLint Width = 400, Height = 300; -static GLenum ShowBuffer = GL_NONE; - - -static void make_table( void ) -{ - static GLfloat table_mat[] = { 1.0, 1.0, 1.0, 0.6 }; - static GLfloat gray[] = { 0.4, 0.4, 0.4, 1.0 }; - - table_list = glGenLists(1); - glNewList( table_list, GL_COMPILE ); - - /* load table's texture */ - glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, table_mat ); -/* glMaterialfv( GL_FRONT, GL_EMISSION, gray );*/ - glMaterialfv( GL_FRONT, GL_DIFFUSE, table_mat ); - glMaterialfv( GL_FRONT, GL_AMBIENT, gray ); - - /* draw textured square for the table */ - glPushMatrix(); - glScalef( 4.0, 4.0, 4.0 ); - glBegin( GL_POLYGON ); - glNormal3f( 0.0, 1.0, 0.0 ); - glTexCoord2f( 0.0, 0.0 ); glVertex3f( -1.0, 0.0, 1.0 ); - glTexCoord2f( 1.0, 0.0 ); glVertex3f( 1.0, 0.0, 1.0 ); - glTexCoord2f( 1.0, 1.0 ); glVertex3f( 1.0, 0.0, -1.0 ); - glTexCoord2f( 0.0, 1.0 ); glVertex3f( -1.0, 0.0, -1.0 ); - glEnd(); - glPopMatrix(); - - glDisable( GL_TEXTURE_2D ); - - glEndList(); -} - - -static void make_objects( void ) -{ - GLUquadricObj *q; - - static GLfloat cyan[] = { 0.0, 1.0, 1.0, 1.0 }; - static GLfloat green[] = { 0.2, 1.0, 0.2, 1.0 }; - static GLfloat black[] = { 0.0, 0.0, 0.0, 0.0 }; - - q = gluNewQuadric(); - gluQuadricDrawStyle( q, GLU_FILL ); - gluQuadricNormals( q, GLU_SMOOTH ); - - objects_list[0] = glGenLists(1); - glNewList( objects_list[0], GL_COMPILE ); - glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, cyan ); - glMaterialfv( GL_FRONT, GL_EMISSION, black ); - gluCylinder( q, 0.5, 0.5, 1.0, 15, 1 ); - glEndList(); - - objects_list[1] = glGenLists(1); - glNewList( objects_list[1], GL_COMPILE ); - glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green ); - glMaterialfv( GL_FRONT, GL_EMISSION, black ); - gluCylinder( q, 1.5, 0.0, 2.5, 15, 1 ); - glEndList(); -} - - -static void init( void ) -{ - make_table(); - make_objects(); - - Image = LoadRGBImage( TABLE_TEXTURE, &ImgWidth, &ImgHeight, &ImgFormat ); - if (!Image) { - printf("Couldn't read %s\n", TABLE_TEXTURE); - exit(0); - } - - gluBuild2DMipmaps(GL_TEXTURE_2D, 3, ImgWidth, ImgHeight, - ImgFormat, GL_UNSIGNED_BYTE, Image); - - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - - xrot = 30.0; - yrot = 50.0; - spin = 0.0; - - glShadeModel( GL_FLAT ); - - glEnable( GL_LIGHT0 ); - glEnable( GL_LIGHTING ); - - glClearColor( 0.5, 0.5, 0.9, 0.0 ); - - glEnable( GL_NORMALIZE ); -} - - - -static void reshape(int w, int h) -{ - GLfloat yAspect = 2.5; - GLfloat xAspect = yAspect * (float) w / (float) h; - Width = w; - Height = h; - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum( -xAspect, xAspect, -yAspect, yAspect, 10.0, 30.0 ); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - - - -static void draw_objects( GLfloat eyex, GLfloat eyey, GLfloat eyez ) -{ - (void) eyex; - (void) eyey; - (void) eyez; -#ifndef USE_ZBUFFER - if (eyex<0.5) { -#endif - glPushMatrix(); - glTranslatef( 1.0, 1.5, 0.0 ); - glRotatef( spin, 1.0, 0.5, 0.0 ); - glRotatef( 0.5*spin, 0.0, 0.5, 1.0 ); - glCallList( objects_list[0] ); - glPopMatrix(); - - glPushMatrix(); - glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*spin) ), 0.0 ); - glRotatef( 0.5*spin, 0.0, 0.5, 1.0 ); - glRotatef( spin, 1.0, 0.5, 0.0 ); - glScalef( 0.5, 0.5, 0.5 ); - glCallList( objects_list[1] ); - glPopMatrix(); -#ifndef USE_ZBUFFER - } - else { - glPushMatrix(); - glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*spin) ), 0.0 ); - glRotatef( 0.5*spin, 0.0, 0.5, 1.0 ); - glRotatef( spin, 1.0, 0.5, 0.0 ); - glScalef( 0.5, 0.5, 0.5 ); - glCallList( objects_list[1] ); - glPopMatrix(); - - glPushMatrix(); - glTranslatef( 1.0, 1.5, 0.0 ); - glRotatef( spin, 1.0, 0.5, 0.0 ); - glRotatef( 0.5*spin, 0.0, 0.5, 1.0 ); - glCallList( objects_list[0] ); - glPopMatrix(); - } -#endif -} - - - -static void draw_table( void ) -{ - glCallList( table_list ); -} - - - -static void draw( void ) -{ - static GLfloat light_pos[] = { 0.0, 20.0, 0.0, 1.0 }; - GLfloat dist = 20.0; - GLfloat eyex, eyey, eyez; - - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - - - eyex = dist * cos(yrot*DEG2RAD) * cos(xrot*DEG2RAD); - eyez = dist * sin(yrot*DEG2RAD) * cos(xrot*DEG2RAD); - eyey = dist * sin(xrot*DEG2RAD); - - /* view from top */ - glPushMatrix(); - gluLookAt( eyex, eyey, eyez, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ); - - glLightfv( GL_LIGHT0, GL_POSITION, light_pos ); - - /* draw table into stencil planes */ - glDisable( GL_DEPTH_TEST ); - glEnable( GL_STENCIL_TEST ); - glStencilFunc( GL_ALWAYS, 1, 0xffffffff ); - glStencilOp( GL_REPLACE, GL_REPLACE, GL_REPLACE ); - glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); - draw_table(); - glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); - - glEnable( GL_DEPTH_TEST ); - - /* render view from below (reflected viewport) */ - /* only draw where stencil==1 */ - if (eyey>0.0) { - glPushMatrix(); - - glStencilFunc( GL_EQUAL, 1, 0xffffffff ); /* draw if ==1 */ - glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); - glScalef( 1.0, -1.0, 1.0 ); - - /* Reposition light in reflected space. */ - glLightfv(GL_LIGHT0, GL_POSITION, light_pos); - - draw_objects(eyex, eyey, eyez); - glPopMatrix(); - - /* Restore light's original unreflected position. */ - glLightfv(GL_LIGHT0, GL_POSITION, light_pos); - } - - glDisable( GL_STENCIL_TEST ); - - glEnable( GL_BLEND ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - - glEnable( GL_TEXTURE_2D ); - draw_table(); - glDisable( GL_TEXTURE_2D ); - glDisable( GL_BLEND ); - - /* view from top */ - glPushMatrix(); - - draw_objects(eyex, eyey, eyez); - - glPopMatrix(); - - glPopMatrix(); - - if (ShowBuffer == GL_DEPTH) { - ShowDepthBuffer(Width, Height, 1.0, 0.0); - } - else if (ShowBuffer == GL_STENCIL) { - ShowStencilBuffer(Width, Height, 255.0, 0.0); - } - else if (ShowBuffer == GL_ALPHA) { - ShowAlphaBuffer(Width, Height); - } -} - -/*******************************/ - -int main( int argc, char *argv[] ) -{ - int quit = 0; - DFBResult err; - DFBSurfaceDescription dsc; - - DFBCHECK(DirectFBInit( &argc, &argv )); - - /* create the super interface */ - DFBCHECK(DirectFBCreate( &dfb )); - - /* create an event buffer for all devices with these caps */ - DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_ALL, DFB_FALSE, &events )); - - /* set our cooperative level to DFSCL_FULLSCREEN - for exclusive access to the primary layer */ - dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN ); - - /* get the primary surface, i.e. the surface of the - primary layer we have exclusive access to */ - dsc.flags = DSDESC_CAPS; - dsc.caps = (DFBSurfaceCapabilities)(DSCAPS_PRIMARY | DSCAPS_DOUBLE); - - DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary )); - - /* get the size of the surface and fill it */ - DFBCHECK(primary->GetSize( primary, &screen_width, &screen_height )); - DFBCHECK(primary->FillRectangle( primary, 0, 0, - screen_width, screen_height )); - - /* create the default font and set it */ - DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font )); - DFBCHECK(primary->SetFont( primary, font )); - - /* get the GL context */ - DFBCHECK(primary->GetGL( primary, &primary_gl )); - - DFBCHECK(primary_gl->Lock( primary_gl )); - - init(); - reshape(screen_width, screen_height); - - DFBCHECK(primary_gl->Unlock( primary_gl )); - - T0 = get_millis(); - - while (!quit) { - DFBInputEvent evt; - unsigned long t; - - DFBCHECK(primary_gl->Lock( primary_gl )); - - draw(); - - DFBCHECK(primary_gl->Unlock( primary_gl )); - - if (fps) { - char buf[64]; - - sprintf(buf, "%4.1f FPS\n", fps); - primary->SetColor( primary, 0xff, 0, 0, 0xff ); - primary->DrawString( primary, buf, -1, screen_width - 5, 5, DSTF_TOPRIGHT ); - } - - primary->Flip( primary, NULL, (DFBSurfaceFlipFlags)0 ); - Frames++; - - - t = get_millis(); - if (t - T0 >= 1000) { - GLfloat seconds = (t - T0) / 1000.0; - - fps = Frames / seconds; - - T0 = t; - Frames = 0; - } - - - while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) { - switch (evt.type) { - case DIET_KEYPRESS: - switch (DFB_LOWER_CASE(evt.key_symbol)) { - case DIKS_ESCAPE: - quit = 1; - break; - case DIKS_CURSOR_UP: - xrot += 3.0; - if ( xrot > 85 ) - xrot = 85; - break; - case DIKS_CURSOR_DOWN: - xrot -= 3.0; - if ( xrot < 5 ) - xrot = 5; - break; - case DIKS_CURSOR_LEFT: - yrot += 3.0; - break; - case DIKS_CURSOR_RIGHT: - yrot -= 3.0; - break; - case DIKS_SMALL_D: - ShowBuffer = GL_DEPTH; - break; - case DIKS_SMALL_S: - ShowBuffer = GL_STENCIL; - break; - case DIKS_SMALL_A: - ShowBuffer = GL_ALPHA; - break; - default: - ShowBuffer = GL_NONE; - } - break; - case DIET_AXISMOTION: - if (evt.flags & DIEF_AXISREL) { - switch (evt.axis) { - case DIAI_X: - yrot += evt.axisrel / 2.0; - break; - case DIAI_Y: - xrot += evt.axisrel / 2.0; - break; - default: - ; - } - } - break; - default: - ; - } - } - - spin += 2.0; - yrot += 3.0; - } - - /* release our interfaces to shutdown DirectFB */ - primary_gl->Release( primary_gl ); - primary->Release( primary ); - font->Release( font ); - events->Release( events ); - dfb->Release( dfb ); - - return 0; -} - diff --git a/progs/directfb/multi_window.c b/progs/directfb/multi_window.c deleted file mode 100644 index 9bb0e4be8ef..00000000000 --- a/progs/directfb/multi_window.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - (c) Copyright 2001 convergence integrated media GmbH. - All rights reserved. - - Written by Denis Oliver Kropp and - Andreas Hundt . - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include -#include - -#include -#include - -#include -#include - - -typedef struct { - IDirectFBWindow *window; - IDirectFBSurface *surface; - IDirectFBGL *gl; - - int width; - int height; - - unsigned long last_time; - int frames; - float fps; -} Context; - -static const GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0}; - -static IDirectFB *dfb; -static IDirectFBDisplayLayer *layer; -static IDirectFBFont *font; -static IDirectFBEventBuffer *events = NULL; - -/* macro for a safe call to DirectFB functions */ -#define DFBCHECK(x...) \ - do { \ - ret = x; \ - if (ret != DFB_OK) { \ - fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ - DirectFBErrorFatal( #x, ret ); \ - } \ - } while (0) - - -static inline unsigned long get_millis() -{ - struct timeval tv; - - gettimeofday (&tv, NULL); - return (tv.tv_sec * 1000 + tv.tv_usec / 1000); -} - - -static void -setup( Context *context ) -{ - GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0}; - - context->surface->GetSize( context->surface, - &context->width, &context->height ); - - context->gl->Lock( context->gl ); - - glLightfv(GL_LIGHT0, GL_POSITION, pos); - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); - - glViewport(0, 0, context->width, context->height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(70.0, context->width / (float) context->height, 1.0, 80.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -40.0); - - context->gl->Unlock( context->gl ); -} - -static void -update( Context *context ) -{ - unsigned long t; - IDirectFBSurface *surface = context->surface; - static __u8 r = 0, g = 0, b = 0; - - - context->gl->Lock( context->gl ); - - glClearColor( r++/255.0, g++/255.0, b++/255.0, 1.0 ); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - context->gl->Unlock( context->gl ); - - if (context->fps) { - char buf[16]; - - snprintf(buf, sizeof(buf), "%.1f FPS\n", context->fps); - - surface->SetColor( surface, 0xff, 0x00, 0x00, 0xff ); - surface->DrawString( surface, buf, -1, - context->width - 5, 5, DSTF_TOPRIGHT ); - } - - surface->Flip( surface, NULL, 0 ); - - context->frames++; - - t = get_millis(); - if (t - context->last_time >= 2000) { - float seconds = (t - context->last_time) / 1000.0f; - - context->fps = context->frames / seconds; - - context->last_time = t; - context->frames = 0; - } -} - -int -main( int argc, char *argv[] ) -{ - DFBResult ret; - int i; - int quit = 0; - const int num = 2; - Context contexts[num]; - - DFBCHECK(DirectFBInit( &argc, &argv )); - - /* create the super interface */ - DFBCHECK(DirectFBCreate( &dfb )); - - DFBCHECK(dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer )); - - /* create the default font */ - DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font )); - - for (i=0; iCreateWindow( layer, &desc, &window )); - DFBCHECK(window->GetSurface( window, &surface )); - DFBCHECK(surface->GetGL( surface, &gl )); - - contexts[i].window = window; - contexts[i].surface = surface; - contexts[i].gl = gl; - - contexts[i].last_time = get_millis(); - contexts[i].frames = 0; - contexts[i].fps = 0; - - setup( &contexts[i] ); - - if (events) - DFBCHECK(window->AttachEventBuffer( window, events )); - else - DFBCHECK(window->CreateEventBuffer( window, &events )); - - DFBCHECK(surface->SetFont( surface, font )); - - window->SetOpacity( window, 0xff ); - } - - while (!quit) { - DFBWindowEvent evt; - - for (i=0; iGetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) { - switch (evt.type) { - case DWET_KEYDOWN: - switch (evt.key_symbol) { - case DIKS_ESCAPE: - quit = 1; - break; - - default: - break; - } - break; - - default: - break; - } - } - } - - events->Release( events ); - - for (i=0; iRelease( contexts[i].gl ); - contexts[i].surface->Release( contexts[i].surface ); - contexts[i].window->Release( contexts[i].window ); - } - - font->Release( font ); - layer->Release( layer ); - dfb->Release( dfb ); - - return 0; -} - diff --git a/src/glut/directfb/Makefile b/src/glut/directfb/Makefile deleted file mode 100644 index bf93d63e305..00000000000 --- a/src/glut/directfb/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -# subset glut - -TOP = ../../.. -include $(TOP)/configs/current - -MARK = $(TOP)/src/glut/glx - -GLUT_MAJOR = 3 -GLUT_MINOR = 7 -GLUT_TINY = 1 - -INCLUDES = -I$(TOP)/include -I$(MARK) $(shell pkg-config --cflags directfb) - -GLUT_LIB_DEPS += $(shell pkg-config --libs directfb) - -CORE_SOURCES = \ - callback.c \ - color.c \ - cursor.c \ - ext.c \ - events.c \ - font.c \ - game.c \ - globals.c \ - init.c \ - menu.c \ - models.c \ - overlay.c \ - state.c \ - teapot.c \ - window.c \ - - -MARK_SOURCES = \ - $(MARK)/glut_8x13.c \ - $(MARK)/glut_9x15.c \ - $(MARK)/glut_hel10.c \ - $(MARK)/glut_hel12.c \ - $(MARK)/glut_hel18.c \ - $(MARK)/glut_tr10.c \ - $(MARK)/glut_tr24.c - -SOURCES = $(CORE_SOURCES) $(MARK_SOURCES) - -OBJECTS = $(SOURCES:.c=.o) - - -##### RULES ##### - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ - -.S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ - - -##### TARGETS ##### - -default: depend $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME) - - -# Make the library -$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS) - $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \ - $(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \ - $(MKLIB_OPTIONS) $(OBJECTS) - - -# Run 'make -f Makefile.solo dep' to update the dependencies if you change -# what's included by any source file. -depend: $(SOURCES) - rm -f depend - touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) > /dev/null - -# Emacs tags -tags: - etags `find . -name \*.[ch]` `find ../include` - - -# Remove .o and backup files -clean: depend - -rm -f depend depend.bak - -rm -f *.o *~ *.o *~ *.so libglut.so.3.7 - -include depend diff --git a/src/glut/directfb/NOTES b/src/glut/directfb/NOTES deleted file mode 100644 index af917c6667d..00000000000 --- a/src/glut/directfb/NOTES +++ /dev/null @@ -1,9 +0,0 @@ -DirectFB GLUT Implementation NOTES ----------------------------------- - -* To have high performance rendering, it's really important to - use glutEnterGameMode() instead of glutCreateWindow()/glutFullScreen(). - You can also force a windowed application to game mode by setting - the environment variable "__GLUT_GAME_MODE". - - diff --git a/src/glut/directfb/callback.c b/src/glut/directfb/callback.c deleted file mode 100644 index 7c9768aac0a..00000000000 --- a/src/glut/directfb/callback.c +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include -#include - -#include "internal.h" - - -typedef void (GLUTCALLBACK *__GlutTimerCallback) ( int value ); - -typedef struct __GlutTimer_s { - struct timeval interval; - struct timeval expire; - - __GlutTimerCallback func; - int value; - - struct __GlutTimer_s *next; -} __GlutTimer; - -/*****************************************************************************/ - -static __GlutTimer *g_timers = NULL; - -/*****************************************************************************/ - - -void GLUTAPIENTRY -glutDisplayFunc( void (GLUTCALLBACK *func) (void) ) -{ - display_func = func; -} - - -void GLUTAPIENTRY -glutReshapeFunc( void (GLUTCALLBACK *func) (int width, int height) ) -{ - reshape_func = func; -} - - -void GLUTAPIENTRY -glutKeyboardFunc( void (GLUTCALLBACK *func) (unsigned char key, int x, int y) ) -{ - keyboard_func = func; -} - - -void GLUTAPIENTRY -glutMouseFunc( void (GLUTCALLBACK *func) (int button, int state, int x, int y) ) -{ - mouse_func = func; -} - - -void GLUTAPIENTRY -glutMotionFunc( void (GLUTCALLBACK *func) (int x, int y) ) -{ - motion_func = func; -} - - -void GLUTAPIENTRY -glutPassiveMotionFunc( void (GLUTCALLBACK *func) (int x, int y) ) -{ - passive_motion_func = func; -} - - -void GLUTAPIENTRY -glutEntryFunc( void (GLUTCALLBACK *func) (int state) ) -{ - entry_func = func; -} - - -void GLUTAPIENTRY -glutVisibilityFunc( void (GLUTCALLBACK *func) (int state) ) -{ - visibility_func = func; -} - - -void GLUTAPIENTRY -glutMenuStateFunc( void (GLUTCALLBACK *func) (int state) ) -{ - menu_state_func = func; -} - - -void GLUTAPIENTRY -glutSpecialFunc( void (GLUTCALLBACK *func) (int key, int x, int y) ) -{ - special_func = func; -} - - -void GLUTAPIENTRY -glutSpaceballMotionFunc( void (GLUTCALLBACK *func) (int x, int y, int z) ) -{ -} - - -void GLUTAPIENTRY -glutSpaceballRotateFunc( void (GLUTCALLBACK *func) (int x, int y, int z) ) -{ -} - - -void GLUTAPIENTRY -glutSpaceballButtonFunc( void (GLUTCALLBACK *func) (int button, int state) ) -{ -} - - -void GLUTAPIENTRY -glutButtonBoxFunc( void (GLUTCALLBACK *func) (int button, int state) ) -{ -} - - -void GLUTAPIENTRY -glutDialsFunc( void (GLUTCALLBACK *func) (int dial, int value) ) -{ -} - - -void GLUTAPIENTRY -glutTabletMotionFunc( void (GLUTCALLBACK *func) (int x, int y) ) -{ -} - - -void GLUTAPIENTRY -glutTabletButtonFunc( void (GLUTCALLBACK *func) (int button, int state, int x, int y) ) -{ -} - - -void GLUTAPIENTRY -glutMenuStatusFunc( void (GLUTCALLBACK *func) (int status, int x, int y) ) -{ -} - - -void GLUTAPIENTRY -glutOverlayDisplayFunc( void (GLUTCALLBACK *func) (void) ) -{ -} - - -void GLUTAPIENTRY -glutWindowStatusFunc( void (GLUTCALLBACK *func) (int state) ) -{ -} - - -void GLUTAPIENTRY -glutKeyboardUpFunc( void (GLUTCALLBACK *func) (unsigned char key, int x, int y) ) -{ - keyboard_up_func = func; -} - - -void GLUTAPIENTRY -glutSpecialUpFunc( void (GLUTCALLBACK *func) (int key, int x, int y) ) -{ - special_up_func = func; -} - - -void GLUTAPIENTRY -glutJoystickFunc( void (GLUTCALLBACK *func)(unsigned int buttons, int x, int y, int z), int pollInterval ) -{ - joystick_func = func; - /* FIXME: take care of pollInterval */ -} - - -void GLUTAPIENTRY -glutIdleFunc( void (GLUTCALLBACK *func) (void) ) -{ - idle_func = func; -} - - -void GLUTAPIENTRY -glutTimerFunc( unsigned int msec, void (GLUTCALLBACK *func) (int value), int value ) -{ - __GlutTimer *timer; - - if (!func) - return; - - timer = calloc( 1, sizeof(__GlutTimer) ); - if (!timer) - __glutFatalError( "out of memory" ); - - timer->interval.tv_sec = msec / 1000; - timer->interval.tv_usec = (msec % 1000) * 1000; - - gettimeofday( &timer->expire, NULL ); - timer->expire.tv_usec += timer->interval.tv_usec; - timer->expire.tv_sec += timer->interval.tv_sec + timer->expire.tv_usec/1000000; - timer->expire.tv_usec %= 1000000; - - timer->func = func; - timer->value = value; - - timer->next = g_timers; - g_timers = timer; -} - - -void -__glutHandleTimers( void ) -{ - __GlutTimer *cur; - struct timeval now; - - for (cur = g_timers; cur; cur = cur->next ) { - gettimeofday( &now, NULL ); - - if (cur->expire.tv_sec > now.tv_sec || - (cur->expire.tv_sec == now.tv_sec && - cur->expire.tv_usec >= now.tv_usec)) - { - g_idle = GL_FALSE; - - cur->func( cur->value ); - - cur->expire.tv_usec += cur->interval.tv_usec; - cur->expire.tv_sec += cur->interval.tv_sec + cur->expire.tv_usec/1000000; - cur->expire.tv_usec %= 1000000; - } - } -} - - -GLboolean -__glutGetTimeout( int *ret_msec ) -{ - __GlutTimer *cur; - struct timeval *time = NULL; - struct timeval now; - - for (cur = g_timers; cur; cur = cur->next) { - if (time == NULL || - time->tv_sec > cur->expire.tv_sec || - (time->tv_sec == cur->expire.tv_sec && - time->tv_usec > cur->expire.tv_usec)) { - time = &cur->expire; - } - } - - if (time == NULL) - return GL_FALSE; - - gettimeofday( &now, NULL ); - - *ret_msec = (time->tv_sec - now.tv_sec) * 1000 + - (time->tv_usec - now.tv_usec + 999) / 1000; - - return GL_TRUE; -} - - -void -__glutFreeTimers( void ) -{ - __GlutTimer *cur = g_timers; - - while (cur) { - __GlutTimer *next = cur->next; - free( cur ); - cur = next; - } - - g_timers = NULL; -} - diff --git a/src/glut/directfb/color.c b/src/glut/directfb/color.c deleted file mode 100644 index 26c514c6d5f..00000000000 --- a/src/glut/directfb/color.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "internal.h" - - -void GLUTAPIENTRY -glutSetColor( int index, GLfloat red, GLfloat green, GLfloat blue ) -{ -} - - -GLfloat GLUTAPIENTRY -glutGetColor( int index, int component ) -{ - return 0.0; -} - - -void GLUTAPIENTRY -glutCopyColormap( int win ) -{ -} diff --git a/src/glut/directfb/cursor.c b/src/glut/directfb/cursor.c deleted file mode 100644 index aca3fcc9215..00000000000 --- a/src/glut/directfb/cursor.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include "internal.h" - -#include "cursors.h" - - -void GLUTAPIENTRY -glutSetCursor( int type ) -{ - const unsigned char *cursor; - DFBSurfaceDescription dsc; - IDirectFBSurface *shape; - - if (!g_current || !g_current->window) - return; - - if (g_current->cursor == type) - return; - - switch (type) { - case GLUT_CURSOR_RIGHT_ARROW: - cursor = &cur_right_arrow[0]; - break; - case GLUT_CURSOR_LEFT_ARROW: - cursor = &cur_left_arrow[0]; - break; - case GLUT_CURSOR_INFO: - cursor = &cur_info[0]; - break; - case GLUT_CURSOR_DESTROY: - cursor = &cur_destroy[0]; - break; - case GLUT_CURSOR_HELP: - cursor = &cur_help[0]; - break; - case GLUT_CURSOR_CYCLE: - cursor = &cur_cycle[0]; - break; - case GLUT_CURSOR_SPRAY: - cursor = &cur_spray[0]; - break; - case GLUT_CURSOR_WAIT: - cursor = &cur_wait[0]; - break; - case GLUT_CURSOR_TEXT: - cursor = &cur_text[0]; - break; - case GLUT_CURSOR_CROSSHAIR: - cursor = &cur_crosshair[0]; - break; - case GLUT_CURSOR_UP_DOWN: - cursor = &cur_up_down[0]; - break; - case GLUT_CURSOR_LEFT_RIGHT: - cursor = &cur_left_right[0]; - break; - case GLUT_CURSOR_TOP_SIDE: - cursor = &cur_top_side[0]; - break; - case GLUT_CURSOR_BOTTOM_SIDE: - cursor = &cur_bottom_side[0]; - break; - case GLUT_CURSOR_LEFT_SIDE: - cursor = &cur_left_side[0]; - break; - case GLUT_CURSOR_RIGHT_SIDE: - cursor = &cur_right_side[0]; - break; - case GLUT_CURSOR_TOP_LEFT_CORNER: - cursor = &cur_top_left[0]; - break; - case GLUT_CURSOR_TOP_RIGHT_CORNER: - cursor = &cur_top_right[0]; - break; - case GLUT_CURSOR_BOTTOM_RIGHT_CORNER: - cursor = &cur_bottom_right[0]; - break; - case GLUT_CURSOR_BOTTOM_LEFT_CORNER: - cursor = &cur_bottom_left[0]; - break; - case GLUT_CURSOR_NONE: - cursor = NULL; - break; - default: - cursor = &cur_right_arrow[0]; - break; - } - - dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT; - dsc.width = - dsc.height = cursor ? cursor[0] : 8; - dsc.pixelformat = DSPF_ARGB; - - if (dfb->CreateSurface( dfb, &dsc, &shape )) - return; - - if (cursor) { - __u8 *src = (__u8*) &cursor[3]; - __u8 *msk = src + cursor[0]*cursor[0]/8; - void *dst; - int pitch; - int x, y; - - if (shape->Lock( shape, DSLF_WRITE, &dst, &pitch )) { - shape->Release( shape ); - return; - } - - for (y = 0; y < cursor[0]; y++) { - for (x = 0; x < cursor[0]; x++) { - ((__u32*)dst)[x] = - ((src[x>>3] & (0x80 >> (x&7))) ? 0 : 0x00ffffff) | - ((msk[x>>3] & (0x80 >> (x&7))) ? 0xff000000 : 0); - } - - dst += pitch; - src += cursor[0]/8; - msk += cursor[0]/8; - } - - shape->Unlock( shape ); - } - else { - /* Invisible cursor */ - shape->Clear( shape, 0, 0, 0, 0 ); - } - - g_current->window->SetCursorShape( g_current->window, shape, - cursor ? cursor[1] : 0, - cursor ? cursor[2] : 0 ); - g_current->cursor = type; - - shape->Release( shape ); -} - - -void GLUTAPIENTRY -glutWarpPointer( int x, int y ) -{ - if (g_current) { - if (!g_game) { - int wx, wy; - g_current->window->GetPosition( g_current->window, &wx, &wy ); - primary->WarpCursor( primary, wx+x, wy+y ); - } - else { - g_current->cx = x; - g_current->cy = y; - } - } -} - - diff --git a/src/glut/directfb/cursors.h b/src/glut/directfb/cursors.h deleted file mode 100644 index 30ab7c348e6..00000000000 --- a/src/glut/directfb/cursors.h +++ /dev/null @@ -1,306 +0,0 @@ -#ifndef __GLUT_CURSORS_H__ -#define __GLUT_CURSORS_H__ - - -static const unsigned char cur_right_arrow[] = { - 16, /* size */ - 1, 2, /* hotspot */ - /* data */ - 0x00, 0x00, 0x60, 0x00, 0x78, 0x00, 0x3e, 0x00, - 0x3f, 0x80, 0x1f, 0xe0, 0x1f, 0xf8, 0x0f, 0x80, - 0x0f, 0xc0, 0x06, 0xe0, 0x06, 0x70, 0x02, 0x38, - 0x02, 0x1c, 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, - /* mask */ - 0xe0, 0x00, 0xf8, 0x00, 0xfe, 0x00, 0x7f, 0x80, - 0x7f, 0xe0, 0x3f, 0xf8, 0x3f, 0xfc, 0x1f, 0xfc, - 0x1f, 0xe0, 0x0f, 0xf0, 0x0f, 0xf8, 0x07, 0x7c, - 0x07, 0x3e, 0x02, 0x1f, 0x00, 0x0e, 0x00, 0x04, -}; - -static const unsigned char cur_left_arrow[] = { - 16, /* size */ - 1, 15, /* hotspot */ - /* data */ - 0x00, 0x00, 0x80, 0x06, 0x00, 0x1e, 0x00, 0x7c, - 0x01, 0xfc, 0x07, 0xf8, 0x1f, 0xf8, 0x01, 0xf0, - 0x01, 0xf0, 0x02, 0x60, 0x04, 0x60, 0x08, 0x40, - 0x10, 0x40, 0x20, 0x00, 0x40, 0x00, 0x00, 0x00, - /* mask */ - 0x00, 0x07, 0x00, 0x1f, 0x00, 0x7f, 0x01, 0xfe, - 0x07, 0xfe, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xf8, - 0x03, 0xf8, 0x07, 0xf0, 0x0e, 0xf0, 0x1c, 0xe0, - 0x38, 0xe0, 0x70, 0xe0, 0xe0, 0x00, 0xc0, 0x00, -}; - -static const unsigned char cur_info[] = { - 16, /* size */ - 0, 2, /* hotspot */ - /* data */ - 0x30, 0x00, 0x3c, 0x00, 0x0f, 0x00, 0x07, 0x80, - 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x07, 0xf4, - 0x0f, 0xfe, 0x0f, 0xfa, 0x07, 0xe0, 0x03, 0xe0, - 0x00, 0x52, 0x00, 0x46, 0x00, 0x2c, 0x00, 0x18, - /* mask */ - 0xb8, 0x00, 0x3e, 0x00, 0x1f, 0x80, 0x0f, 0xc0, - 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xfc, 0x1f, 0xfe, - 0x1f, 0xfe, 0x1f, 0xfe, 0x0f, 0xfe, 0x07, 0xfe, - 0x03, 0xfe, 0x00, 0xfe, 0x00, 0x7e, 0x00, 0x3c, -}; - -static const unsigned char cur_destroy[] = { - 16, /* size */ - 12, 8, /* hotspot */ - /* data */ - 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0c, 0xcc, - 0x0c, 0xcc, 0x07, 0xf8, 0x03, 0xf0, 0x01, 0xe0, - 0x21, 0xe1, 0x61, 0xe1, 0x10, 0xc2, 0x0e, 0x1c, - 0x01, 0xe0, 0x47, 0xf8, 0x7c, 0x0f, 0x20, 0x01, - /* mask */ - 0x03, 0xf0, 0x07, 0xf8, 0x0f, 0xfc, 0x1f, 0xfe, - 0x1f, 0xfe, 0x0f, 0xfc, 0x07, 0xf8, 0x83, 0xf1, - 0xe3, 0xf1, 0xf3, 0xf3, 0x39, 0xef, 0x1e, 0x1e, - 0x01, 0xe0, 0xc7, 0xfe, 0xff, 0xff, 0x7c, 0x0f, -}; - -static const unsigned char cur_help[] = { - 16, /* size */ - 7, 8, /* hotspot */ - /* data */ - 0x83, 0xe0, 0x07, 0xf0, 0x0e, 0x38, 0x0c, 0x18, - 0x0c, 0x38, 0x0e, 0x30, 0x07, 0x00, 0x03, 0xc0, - 0x01, 0xc0, 0x01, 0x40, 0x01, 0x40, 0x07, 0x70, - 0x03, 0x60, 0x01, 0xc0, 0x00, 0x80, 0x00, 0x00, - /* mask */ - 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xf8, 0x1f, 0xfc, - 0x1e, 0x3c, 0x1e, 0x7c, 0x1f, 0x78, 0x0f, 0xf0, - 0x07, 0xe0, 0x03, 0xe0, 0x03, 0xe0, 0x07, 0xf0, - 0x0f, 0xf8, 0x07, 0xf0, 0x03, 0xe0, 0x01, 0xc0, -}; - -static const unsigned char cur_cycle[] = { - 16, /* size */ - 7, 9, /* hotspot */ - /* data */ - 0x00, 0x00, 0x07, 0xe2, 0x0f, 0xf6, 0x18, 0x3e, - 0x10, 0x12, 0x00, 0x32, 0x00, 0x7e, 0x00, 0x00, - 0x00, 0x00, 0x7e, 0x00, 0x4c, 0x00, 0x48, 0x08, - 0x7c, 0x18, 0x6f, 0xf0, 0x47, 0xe0, 0x00, 0x00, - /* mask */ - 0x07, 0xe3, 0x0f, 0xf7, 0x1f, 0xff, 0x3f, 0xff, - 0x38, 0x3f, 0x30, 0xff, 0x00, 0xff, 0x00, 0xff, - 0xff, 0x00, 0xff, 0x00, 0xfe, 0x0c, 0xfc, 0x1c, - 0xff, 0xfc, 0xff, 0xf8, 0xef, 0xf0, 0xc7, 0xe0, -}; - -static const unsigned char cur_spray[] = { - 16, /* size */ - 2, 4, /* hotspot */ - /* data */ - 0x98, 0x00, 0x02, 0x00, 0x18, 0xb0, 0x02, 0x78, - 0x18, 0x58, 0x00, 0xfc, 0x00, 0x84, 0x00, 0x9c, - 0x00, 0x94, 0x00, 0x9c, 0x00, 0x94, 0x00, 0x9c, - 0x00, 0x9c, 0x00, 0x84, 0x00, 0x84, 0x00, 0xfc, - /* mask */ - 0x30, 0x00, 0x34, 0x60, 0x35, 0xf0, 0x35, 0xf0, - 0x35, 0xf8, 0x03, 0xfc, 0x03, 0xfc, 0x03, 0xfc, - 0x03, 0xfc, 0x03, 0xfc, 0x03, 0xfc, 0x03, 0xfc, - 0x03, 0xfc, 0x03, 0xfc, 0x03, 0xfc, 0x03, 0xfc, -}; - -static const unsigned char cur_wait[] = { - 16, /* size */ - 9, 1, /* hotspot */ - /* data */ - 0x07, 0xf8, 0x07, 0xf8, 0x07, 0xf8, 0x0f, 0xfc, - 0x18, 0x86, 0x30, 0x83, 0xe0, 0x81, 0xe1, 0xc1, - 0xe1, 0xc1, 0xe0, 0x21, 0x30, 0x13, 0x18, 0x06, - 0x0f, 0xfc, 0x07, 0xf8, 0x07, 0xf8, 0x07, 0xf8, - /* mask */ - 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x1f, 0xfe, - 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, - 0x1f, 0xfe, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, -}; - -static const unsigned char cur_text[] = { - 16, /* size */ - 8, 8, /* hotspot */ - /* data */ - 0x00, 0x00, 0x0f, 0x70, 0x09, 0xc0, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x01, 0xc0, 0x07, 0x70, 0x00, 0x00, - /* mask */ - 0x0f, 0x78, 0x0f, 0xf8, 0x0f, 0xf8, 0x03, 0xe0, - 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, - 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, - 0x03, 0xe0, 0x0f, 0xf8, 0x0f, 0xf8, 0x0f, 0x78, -}; - -static const unsigned char cur_crosshair[] = { - 16, /* size */ - 7, 9, /* hotspot */ - /* data */ - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0xff, 0x7f, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, - /* mask */ - 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, - 0x01, 0xc0, 0x01, 0xc0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, - 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, -}; - -static const unsigned char cur_up_down[] = { - 16, /* size */ - 7, 8, /* hotspot */ - /* data */ - 0x00, 0x80, 0x09, 0xc0, 0x03, 0xe0, 0x07, 0xf0, - 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, - 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x07, 0xf0, - 0x03, 0xe0, 0x01, 0xc0, 0x00, 0x80, 0x00, 0x00, - /* mask */ - 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xf8, - 0x0f, 0xf8, 0x03, 0xe0, 0x03, 0xe0, 0x03, 0xe0, - 0x03, 0xe0, 0x03, 0xe0, 0x0f, 0xf8, 0x0f, 0xf8, - 0x07, 0xf0, 0x03, 0xe0, 0x01, 0xc0, 0x00, 0x00, -}; - -static const unsigned char cur_left_right[] = { - 16, /* size */ - 7, 8, /* hotspot */ - /* data */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x08, 0x18, 0x0c, 0x3f, 0xfe, 0x78, 0x0f, - 0x3f, 0xfe, 0x18, 0x0c, 0x08, 0x08, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* mask */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x18, - 0x1c, 0x1c, 0x3f, 0xfe, 0x7f, 0xff, 0x7f, 0xff, - 0x7f, 0xff, 0x3f, 0xfe, 0x1c, 0x1c, 0x0c, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -static const unsigned char cur_top_side[] = { - 16, /* size */ - 1, 8, /* hotspot */ - /* data */ - 0x00, 0x00, 0xff, 0xfe, 0x3f, 0xfe, 0x00, 0x00, - 0x00, 0x80, 0x01, 0xc0, 0x02, 0xa0, 0x04, 0x90, - 0x08, 0x88, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, - /* mask */ - 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, - 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xf8, - 0x1d, 0xdc, 0x19, 0xcc, 0x01, 0xc0, 0x01, 0xc0, - 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, -}; - -static const unsigned char cur_bottom_side[] = { - 16, /* size */ - 14, 8, /* hotspot */ - /* data */ - 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x08, 0x88, - 0x04, 0x90, 0x02, 0xa0, 0x01, 0xc0, 0x00, 0x80, - 0x00, 0x00, 0x3f, 0xfe, 0x3f, 0xfe, 0x00, 0x00, - /* mask */ - 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, - 0x01, 0xc0, 0x01, 0xc0, 0x19, 0xcc, 0x1d, 0xdc, - 0x0f, 0xf8, 0x07, 0xf0, 0x03, 0xe0, 0x01, 0xc0, - 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, -}; - -static const unsigned char cur_left_side[] = { - 16, /* size */ - 7, 15, /* hotspot */ - /* data */ - 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x01, 0x06, - 0x00, 0x86, 0x00, 0x46, 0x00, 0x26, 0x7f, 0xf6, - 0x00, 0x26, 0x00, 0x46, 0x00, 0x86, 0x01, 0x06, - 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, - /* mask */ - 0x00, 0x0f, 0x00, 0x0f, 0x03, 0x0f, 0x03, 0x8f, - 0x01, 0xcf, 0x00, 0xef, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x00, 0xef, 0x01, 0xcf, 0x03, 0x8f, - 0x03, 0x0f, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x00, -}; - -static const unsigned char cur_right_side[] = { - 16, /* size */ - 7, 2, /* hotspot */ - /* data */ - 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x80, - 0x61, 0x00, 0x62, 0x00, 0x64, 0x00, 0x6f, 0xfe, - 0x64, 0x00, 0x62, 0x00, 0x61, 0x00, 0x60, 0x80, - 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, - /* mask */ - 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0xc0, 0xf1, 0xc0, - 0xf3, 0x80, 0xf7, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf7, 0x00, 0xf3, 0x80, 0xf1, 0xc0, - 0xf0, 0xc0, 0xf0, 0x00, 0xf0, 0x00, 0x00, 0x00, -}; - -static const unsigned char cur_top_left[] = { - 16, /* size */ - 1, 15, /* hotspot */ - /* data */ - 0x00, 0x00, 0xff, 0xfe, 0x7f, 0xfe, 0x00, 0x06, - 0x00, 0x06, 0x00, 0x06, 0x1f, 0xc6, 0x00, 0xc6, - 0x01, 0x46, 0x02, 0x46, 0x04, 0x46, 0x08, 0x46, - 0x10, 0x46, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, - /* mask */ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x0f, 0x3f, 0xef, 0x3f, 0xef, 0x3f, 0xef, - 0x03, 0xef, 0x07, 0xef, 0x0e, 0xef, 0x1c, 0xef, - 0x38, 0xef, 0x30, 0xef, 0x00, 0x0f, 0x00, 0x0f, -}; - -static const unsigned char cur_top_right[] = { - 16, /* size */ - 1, 2, /* hotspot */ - /* data */ - 0x00, 0x00, 0xff, 0xfe, 0x7f, 0xfe, 0x60, 0x00, - 0x60, 0x00, 0x60, 0x00, 0x63, 0xf8, 0x63, 0x00, - 0x62, 0x80, 0x62, 0x40, 0x62, 0x20, 0x62, 0x10, - 0x62, 0x08, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, - /* mask */ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf0, 0x00, 0xf7, 0xfc, 0xf7, 0xfc, 0xf7, 0xfc, - 0xf7, 0xc0, 0xf7, 0xe0, 0xf7, 0x70, 0xf7, 0x38, - 0xf7, 0x1c, 0xf7, 0x0c, 0xf0, 0x00, 0xf0, 0x00, -}; - -static const unsigned char cur_bottom_right[] = { - 16, /* size */ - 14, 2, /* hotspot */ - /* data */ - 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x62, 0x08, - 0x62, 0x10, 0x62, 0x20, 0x62, 0x40, 0x62, 0x80, - 0x63, 0x00, 0x63, 0xf8, 0x60, 0x00, 0x60, 0x00, - 0x60, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00, - /* mask */ - 0xf0, 0x00, 0xf0, 0x00, 0xf7, 0x0c, 0xf7, 0x1c, - 0xf7, 0x38, 0xf7, 0x70, 0xf7, 0xe0, 0xf7, 0xc0, - 0xf7, 0xfc, 0xf7, 0xfc, 0xf7, 0xfc, 0xf0, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -}; - -static const unsigned char cur_bottom_left[] = { - 16, /* size */ - 14, 15, /* hotspot */ - /* data */ - 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x10, 0x46, - 0x08, 0x46, 0x04, 0x46, 0x02, 0x46, 0x01, 0x46, - 0x00, 0xc6, 0x1f, 0xc6, 0x00, 0x06, 0x00, 0x06, - 0x00, 0x06, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00, - /* mask */ - 0x00, 0x0f, 0x00, 0x0f, 0x30, 0xef, 0x38, 0xef, - 0x1c, 0xef, 0x0e, 0xef, 0x07, 0xef, 0x03, 0xef, - 0x3f, 0xef, 0x3f, 0xef, 0x3f, 0xef, 0x00, 0x0f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -}; - - -#endif /* __GLUT_CURSORS_H__ */ diff --git a/src/glut/directfb/events.c b/src/glut/directfb/events.c deleted file mode 100644 index 6ebdd166ac8..00000000000 --- a/src/glut/directfb/events.c +++ /dev/null @@ -1,492 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include "internal.h" - - -/*****************************************************************************/ - -static int g_ignore_key_repeat = 0; - -/*****************************************************************************/ - - -int GLUTAPIENTRY -glutDeviceGet( GLenum type ) -{ - switch (type) { - case GLUT_HAS_KEYBOARD: - return (keyboard != NULL); - case GLUT_HAS_MOUSE: - return (mouse != NULL); - case GLUT_NUM_MOUSE_BUTTONS: - if (mouse) { - DFBInputDeviceDescription dsc; - mouse->GetDescription( mouse, &dsc ); - return dsc.max_button+1; - } - break; - case GLUT_DEVICE_IGNORE_KEY_REPEAT: - return g_ignore_key_repeat; - case GLUT_DEVICE_KEY_REPEAT: - return (g_ignore_key_repeat) ? GLUT_KEY_REPEAT_OFF - : GLUT_KEY_REPEAT_ON; - case GLUT_HAS_JOYSTICK: - case GLUT_OWNS_JOYSTICK: - return (g_game && joystick); /* only available in game mode */ - case GLUT_JOYSTICK_BUTTONS: - if (joystick) { - DFBInputDeviceDescription dsc; - joystick->GetDescription( joystick, &dsc ); - return dsc.max_button+1; - } - break; - case GLUT_JOYSTICK_AXES: - if (joystick) { - DFBInputDeviceDescription dsc; - joystick->GetDescription( joystick, &dsc ); - return dsc.max_axis+1; - } - break; - case GLUT_JOYSTICK_POLL_RATE: - if (joystick) - return 1; /* hack */ - break; - default: - break; - } - - return 0; -} - - -int GLUTAPIENTRY -glutGetModifiers( void ) -{ - if (g_current) - return g_current->modifiers; - return 0; -} - - -void GLUTAPIENTRY -glutIgnoreKeyRepeat( int ignore ) -{ - g_ignore_key_repeat = ignore; -} - - -void GLUTAPIENTRY -glutSetKeyRepeat( int mode ) -{ - g_ignore_key_repeat = (mode == GLUT_KEY_REPEAT_OFF); -} - - -void GLUTAPIENTRY -glutForceJoystickFunc( void ) -{ - if (g_game && joystick && joystick_func) { - joystick_func( g_game->buttons, - g_game->jx, g_game->jy, g_game->jz ); - } -} - - -static int -__glutSpecialKey( DFBInputDeviceKeySymbol key ) -{ - switch (key) { - case DIKS_F1: - return GLUT_KEY_F1; - case DIKS_F2: - return GLUT_KEY_F2; - case DIKS_F3: - return GLUT_KEY_F3; - case DIKS_F4: - return GLUT_KEY_F4; - case DIKS_F5: - return GLUT_KEY_F5; - case DIKS_F6: - return GLUT_KEY_F6; - case DIKS_F7: - return GLUT_KEY_F7; - case DIKS_F8: - return GLUT_KEY_F8; - case DIKS_F9: - return GLUT_KEY_F9; - case DIKS_F10: - return GLUT_KEY_F10; - case DIKS_F11: - return GLUT_KEY_F11; - case DIKS_F12: - return GLUT_KEY_F12; - case DIKS_CURSOR_LEFT: - return GLUT_KEY_LEFT; - case DIKS_CURSOR_UP: - return GLUT_KEY_UP; - case DIKS_CURSOR_RIGHT: - return GLUT_KEY_RIGHT; - case DIKS_CURSOR_DOWN: - return GLUT_KEY_DOWN; - case DIKS_PAGE_UP: - return GLUT_KEY_PAGE_UP; - case DIKS_PAGE_DOWN: - return GLUT_KEY_PAGE_DOWN; - case DIKS_HOME: - return GLUT_KEY_HOME; - case DIKS_END: - return GLUT_KEY_END; - case DIKS_INSERT: - return GLUT_KEY_INSERT; - default: - break; - } - - return 0; -} - - -static int -__glutButton( DFBInputDeviceButtonIdentifier button ) -{ - switch (button) { - case DIBI_LEFT: - return GLUT_LEFT_BUTTON; - case DIBI_MIDDLE: - return GLUT_MIDDLE_BUTTON; - case DIBI_RIGHT: - return GLUT_RIGHT_BUTTON; - default: - break; - } - - return 0; -} - - -static int -__glutModifiers( DFBInputDeviceModifierMask mask ) -{ - return ((mask & DIMM_SHIFT) ? GLUT_ACTIVE_SHIFT : 0) | - ((mask & DIMM_CONTROL) ? GLUT_ACTIVE_CTRL : 0) | - ((mask & DIMM_ALT) ? GLUT_ACTIVE_ALT : 0); -} - - -static void -__glutWindowEvent( DFBWindowEvent *e, DFBWindowEvent *p ) -{ - __GlutWindow *window; - - window = __glutFindWindow( e->window_id ); - if (!window) /* window was destroyed */ - return; - - switch (e->type) { - case DWET_KEYDOWN: - window->modifiers = __glutModifiers( e->modifiers ); - if (g_ignore_key_repeat && p) { - if (p->type == DWET_KEYDOWN && - p->window_id == e->window_id && - p->key_symbol == e->key_symbol) - break; - } - if (DFB_KEY_IS_ASCII( e->key_symbol )) { - if (keyboard_func) { - __glutSetWindow( window ); - keyboard_func( e->key_symbol, e->x, e->y ); - } - } - else { - int key = __glutSpecialKey( e->key_symbol ); - if (key && special_func) { - __glutSetWindow( window ); - special_func( key, e->x, e->y ); - } - } - break; - case DWET_KEYUP: - window->modifiers = __glutModifiers( e->modifiers ); - if (DFB_KEY_IS_ASCII( e->key_symbol )) { - if (keyboard_up_func) { - __glutSetWindow( window ); - keyboard_up_func( e->key_symbol, e->x, e->y ); - } - } - else { - int key = __glutSpecialKey( e->key_symbol ); - if (key && special_up_func) { - __glutSetWindow( window ); - special_up_func( key, e->x, e->y ); - } - } - break; - case DWET_BUTTONDOWN: - if (mouse_func) { - __glutSetWindow( window ); - mouse_func( __glutButton( e->button ), GLUT_DOWN, e->x, e->y ); - } - break; - case DWET_BUTTONUP: - if (mouse_func) { - __glutSetWindow( window ); - mouse_func( __glutButton( e->button ), GLUT_UP, e->x, e->y ); - } - break; - case DWET_MOTION: - if (e->buttons) { - if (motion_func) { - __glutSetWindow( window ); - motion_func( e->cx, e->cy ); - } - } - else { - if (passive_motion_func) { - __glutSetWindow( window ); - passive_motion_func( e->cx, e->cy ); - } - } - break; - case DWET_ENTER: - if (entry_func) { - __glutSetWindow( window ); - entry_func( GLUT_ENTERED ); - } - break; - case DWET_LEAVE: - if (entry_func) { - __glutSetWindow( window ); - entry_func( GLUT_LEFT ); - } - break; - case DWET_SIZE: - window->reshape = GL_TRUE; - window->redisplay = GL_TRUE; - break; - default: - break; - } -} - - -static void -__glutInputEvent( DFBInputEvent *e, DFBInputEvent *p ) -{ - __glutAssert( g_game != NULL ); - - switch (e->type) { - case DIET_KEYPRESS: - g_game->modifiers = __glutModifiers( e->modifiers ); - if (g_ignore_key_repeat && p) { - if (p->type == DIET_KEYPRESS && - p->key_symbol == e->key_symbol) - break; - } - if (DFB_KEY_IS_ASCII( e->key_symbol )) { - if (keyboard_func) { - __glutSetWindow( g_game ); - keyboard_func( e->key_symbol, g_game->cx, g_game->cy ); - } - } - else { - int key = __glutSpecialKey( e->key_symbol ); - if (key && special_func) { - __glutSetWindow( g_game ); - special_func( key, g_game->cx, g_game->cy ); - } - } - break; - case DIET_KEYRELEASE: - g_game->modifiers = __glutModifiers( e->modifiers ); - if (DFB_KEY_IS_ASCII( e->key_symbol )) { - if (keyboard_up_func) { - __glutSetWindow( g_game ); - keyboard_up_func( e->key_symbol, g_game->cx, g_game->cy ); - } - } - else { - int key = __glutSpecialKey( e->key_symbol ); - if (key && special_up_func) { - __glutSetWindow( g_game ); - special_up_func( key, g_game->cx, g_game->cy ); - } - } - break; - case DIET_BUTTONPRESS: - if (e->device_id == DIDID_JOYSTICK) { - g_game->buttons = e->buttons; - if (joystick_func) { - __glutSetWindow( g_game ); - joystick_func( g_game->buttons, - g_game->jx, g_game->jy, g_game->jz ); - } - } - else { - if (mouse_func) { - __glutSetWindow( g_game ); - mouse_func( __glutButton( e->button ), - GLUT_DOWN, g_game->cx, g_game->cy ); - } - } - break; - case DIET_BUTTONRELEASE: - if (e->device_id == DIDID_JOYSTICK) { - g_game->buttons = e->buttons; - if (joystick_func) { - __glutSetWindow( g_game ); - joystick_func( g_game->buttons, - g_game->jx, g_game->jy, g_game->jz ); - } - } - else { - if (mouse_func) { - __glutSetWindow( g_game ); - mouse_func( __glutButton( e->button ), - GLUT_UP, g_game->cx, g_game->cy ); - } - } - break; - case DIET_AXISMOTION: - if (e->device_id == DIDID_JOYSTICK) { - switch (e->axis) { - case DIAI_X: - if (e->flags & DIEF_AXISABS) - g_game->jx = e->axisabs; - else if (e->flags & DIEF_AXISREL) - g_game->jx += e->axisrel; - break; - case DIAI_Y: - if (e->flags & DIEF_AXISABS) - g_game->jy = e->axisabs; - else if (e->flags & DIEF_AXISREL) - g_game->jy += e->axisrel; - break; - case DIAI_Z: - if (e->flags & DIEF_AXISABS) - g_game->jz = e->axisabs; - else if (e->flags & DIEF_AXISREL) - g_game->jz += e->axisrel; - break; - default: - break; - } - if (joystick_func) { - __glutSetWindow( g_game ); - joystick_func( g_game->buttons, - g_game->jx, g_game->jy, g_game->jz ); - } - } - else { - switch (e->axis) { - case DIAI_X: - if (e->flags & DIEF_AXISABS) - g_game->cx = e->axisabs; - else if (e->flags & DIEF_AXISREL) - g_game->cx += e->axisrel; - break; - case DIAI_Y: - if (e->flags & DIEF_AXISABS) - g_game->cy = e->axisabs; - else if (e->flags & DIEF_AXISREL) - g_game->cy += e->axisrel; - break; - default: - return; - } - if (e->buttons && motion_func) { - __glutSetWindow( g_game ); - motion_func( g_game->cx, g_game->cy ); - } - else if (!e->buttons && passive_motion_func) { - __glutSetWindow( g_game ); - passive_motion_func( g_game->cx, g_game->cy ); - } - } - break; - default: - break; - } -} - - -void GLUTAPIENTRY -glutMainLoop( void ) -{ - __glutAssert( events != NULL ); - - __glutHandleWindows(); - - while (GL_TRUE) { - DFBEvent evt, prev; - - g_idle = GL_TRUE; - - __glutHandleTimers(); - - prev.clazz = DFEC_NONE; - - while (events->GetEvent( events, &evt ) == DFB_OK) { - g_idle = GL_FALSE; - - switch (evt.clazz) { - case DFEC_WINDOW: - if (prev.clazz == DFEC_WINDOW) - __glutWindowEvent( &evt.window, &prev.window ); - else - __glutWindowEvent( &evt.window, NULL ); - break; - case DFEC_INPUT: - if (prev.clazz == DFEC_INPUT) - __glutInputEvent( &evt.input, &prev.input ); - else - __glutInputEvent( &evt.input, NULL ); - break; - default: - __glutWarning( "unexpected event class %d!\n", evt.clazz ); - break; - } - - prev = evt; - - __glutHandleTimers(); - } - - __glutHandleWindows(); - - if (g_idle) { - if (idle_func) { - idle_func(); - } - else { - int msec; - __glutSetWindow( NULL ); - if (__glutGetTimeout( &msec )) - events->WaitForEventWithTimeout( events, msec/1000, msec%1000 ); - else - events->WaitForEvent( events ); - } - } - } -} - diff --git a/src/glut/directfb/ext.c b/src/glut/directfb/ext.c deleted file mode 100644 index e37ecf5afad..00000000000 --- a/src/glut/directfb/ext.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include "internal.h" - - -static const struct { - const char *name; - const GLUTproc address; -} glut_functions[] = { - { "glutInit", (const GLUTproc) glutInit }, - { "glutInitDisplayMode", (const GLUTproc) glutInitDisplayMode }, - { "glutInitDisplayString", (const GLUTproc) glutInitDisplayString }, - { "glutInitWindowPosition", (const GLUTproc) glutInitWindowPosition }, - { "glutInitWindowSize", (const GLUTproc) glutInitWindowSize }, - { "glutMainLoop", (const GLUTproc) glutMainLoop }, - { "glutCreateWindow", (const GLUTproc) glutCreateWindow }, - { "glutCreateSubWindow", (const GLUTproc) glutCreateSubWindow }, - { "glutDestroyWindow", (const GLUTproc) glutDestroyWindow }, - { "glutPostRedisplay", (const GLUTproc) glutPostRedisplay }, - { "glutPostWindowRedisplay", (const GLUTproc) glutPostWindowRedisplay }, - { "glutSwapBuffers", (const GLUTproc) glutSwapBuffers }, - { "glutGetWindow", (const GLUTproc) glutGetWindow }, - { "glutSetWindow", (const GLUTproc) glutSetWindow }, - { "glutSetWindowTitle", (const GLUTproc) glutSetWindowTitle }, - { "glutSetIconTitle", (const GLUTproc) glutSetIconTitle }, - { "glutPositionWindow", (const GLUTproc) glutPositionWindow }, - { "glutReshapeWindow", (const GLUTproc) glutReshapeWindow }, - { "glutPopWindow", (const GLUTproc) glutPopWindow }, - { "glutPushWindow", (const GLUTproc) glutPushWindow }, - { "glutIconifyWindow", (const GLUTproc) glutIconifyWindow }, - { "glutShowWindow", (const GLUTproc) glutShowWindow }, - { "glutHideWindow", (const GLUTproc) glutHideWindow }, - { "glutFullScreen", (const GLUTproc) glutFullScreen }, - { "glutSetCursor", (const GLUTproc) glutSetCursor }, - { "glutWarpPointer", (const GLUTproc) glutWarpPointer }, - { "glutEstablishOverlay", (const GLUTproc) glutEstablishOverlay }, - { "glutRemoveOverlay", (const GLUTproc) glutRemoveOverlay }, - { "glutUseLayer", (const GLUTproc) glutUseLayer }, - { "glutPostOverlayRedisplay", (const GLUTproc) glutPostOverlayRedisplay }, - { "glutPostWindowOverlayRedisplay", (const GLUTproc) glutPostWindowOverlayRedisplay }, - { "glutShowOverlay", (const GLUTproc) glutShowOverlay }, - { "glutHideOverlay", (const GLUTproc) glutHideOverlay }, - { "glutCreateMenu", (const GLUTproc) glutCreateMenu }, - { "glutDestroyMenu", (const GLUTproc) glutDestroyMenu }, - { "glutGetMenu", (const GLUTproc) glutGetMenu }, - { "glutSetMenu", (const GLUTproc) glutSetMenu }, - { "glutAddMenuEntry", (const GLUTproc) glutAddMenuEntry }, - { "glutAddSubMenu", (const GLUTproc) glutAddSubMenu }, - { "glutChangeToMenuEntry", (const GLUTproc) glutChangeToMenuEntry }, - { "glutChangeToSubMenu", (const GLUTproc) glutChangeToSubMenu }, - { "glutRemoveMenuItem", (const GLUTproc) glutRemoveMenuItem }, - { "glutAttachMenu", (const GLUTproc) glutAttachMenu }, - { "glutDetachMenu", (const GLUTproc) glutDetachMenu }, - { "glutDisplayFunc", (const GLUTproc) glutDisplayFunc }, - { "glutReshapeFunc", (const GLUTproc) glutReshapeFunc }, - { "glutKeyboardFunc", (const GLUTproc) glutKeyboardFunc }, - { "glutMouseFunc", (const GLUTproc) glutMouseFunc }, - { "glutMotionFunc", (const GLUTproc) glutMotionFunc }, - { "glutPassiveMotionFunc", (const GLUTproc) glutPassiveMotionFunc }, - { "glutEntryFunc", (const GLUTproc) glutEntryFunc }, - { "glutVisibilityFunc", (const GLUTproc) glutVisibilityFunc }, - { "glutIdleFunc", (const GLUTproc) glutIdleFunc }, - { "glutTimerFunc", (const GLUTproc) glutTimerFunc }, - { "glutMenuStateFunc", (const GLUTproc) glutMenuStateFunc }, - { "glutSpecialFunc", (const GLUTproc) glutSpecialFunc }, - { "glutSpaceballMotionFunc", (const GLUTproc) glutSpaceballMotionFunc }, - { "glutSpaceballRotateFunc", (const GLUTproc) glutSpaceballRotateFunc }, - { "glutSpaceballButtonFunc", (const GLUTproc) glutSpaceballButtonFunc }, - { "glutButtonBoxFunc", (const GLUTproc) glutButtonBoxFunc }, - { "glutDialsFunc", (const GLUTproc) glutDialsFunc }, - { "glutTabletMotionFunc", (const GLUTproc) glutTabletMotionFunc }, - { "glutTabletButtonFunc", (const GLUTproc) glutTabletButtonFunc }, - { "glutMenuStatusFunc", (const GLUTproc) glutMenuStatusFunc }, - { "glutOverlayDisplayFunc", (const GLUTproc) glutOverlayDisplayFunc }, - { "glutWindowStatusFunc", (const GLUTproc) glutWindowStatusFunc }, - { "glutKeyboardUpFunc", (const GLUTproc) glutKeyboardUpFunc }, - { "glutSpecialUpFunc", (const GLUTproc) glutSpecialUpFunc }, - { "glutJoystickFunc", (const GLUTproc) glutJoystickFunc }, - { "glutSetColor", (const GLUTproc) glutSetColor }, - { "glutGetColor", (const GLUTproc) glutGetColor }, - { "glutCopyColormap", (const GLUTproc) glutCopyColormap }, - { "glutGet", (const GLUTproc) glutGet }, - { "glutDeviceGet", (const GLUTproc) glutDeviceGet }, - { "glutExtensionSupported", (const GLUTproc) glutExtensionSupported }, - { "glutGetModifiers", (const GLUTproc) glutGetModifiers }, - { "glutLayerGet", (const GLUTproc) glutLayerGet }, - { "glutGetProcAddress", (const GLUTproc) glutGetProcAddress }, - { "glutBitmapCharacter", (const GLUTproc) glutBitmapCharacter }, - { "glutBitmapWidth", (const GLUTproc) glutBitmapWidth }, - { "glutStrokeCharacter", (const GLUTproc) glutStrokeCharacter }, - { "glutStrokeWidth", (const GLUTproc) glutStrokeWidth }, - { "glutBitmapLength", (const GLUTproc) glutBitmapLength }, - { "glutStrokeLength", (const GLUTproc) glutStrokeLength }, - { "glutWireSphere", (const GLUTproc) glutWireSphere }, - { "glutSolidSphere", (const GLUTproc) glutSolidSphere }, - { "glutWireCone", (const GLUTproc) glutWireCone }, - { "glutSolidCone", (const GLUTproc) glutSolidCone }, - { "glutWireCube", (const GLUTproc) glutWireCube }, - { "glutSolidCube", (const GLUTproc) glutSolidCube }, - { "glutWireTorus", (const GLUTproc) glutWireTorus }, - { "glutSolidTorus", (const GLUTproc) glutSolidTorus }, - { "glutWireDodecahedron", (const GLUTproc) glutWireDodecahedron }, - { "glutSolidDodecahedron", (const GLUTproc) glutSolidDodecahedron }, - { "glutWireTeapot", (const GLUTproc) glutWireTeapot }, - { "glutSolidTeapot", (const GLUTproc) glutSolidTeapot }, - { "glutWireOctahedron", (const GLUTproc) glutWireOctahedron }, - { "glutSolidOctahedron", (const GLUTproc) glutSolidOctahedron }, - { "glutWireTetrahedron", (const GLUTproc) glutWireTetrahedron }, - { "glutSolidTetrahedron", (const GLUTproc) glutSolidTetrahedron }, - { "glutWireIcosahedron", (const GLUTproc) glutWireIcosahedron }, - { "glutSolidIcosahedron", (const GLUTproc) glutSolidIcosahedron }, -// { "glutVideoResizeGet", (const GLUTproc) glutVideoResizeGet }, -// { "glutSetupVideoResizing", (const GLUTproc) glutSetupVideoResizing }, -// { "glutStopVideoResizing", (const GLUTproc) glutStopVideoResizing }, -// { "glutVideoResize", (const GLUTproc) glutVideoResize }, -// { "glutVideoPan", (const GLUTproc) glutVideoPan }, - { "glutReportErrors", (const GLUTproc) glutReportErrors }, - { "glutIgnoreKeyRepeat", (const GLUTproc) glutIgnoreKeyRepeat }, - { "glutSetKeyRepeat", (const GLUTproc) glutSetKeyRepeat }, - { "glutForceJoystickFunc", (const GLUTproc) glutForceJoystickFunc }, - { "glutGameModeString", (const GLUTproc) glutGameModeString }, - { "glutEnterGameMode", (const GLUTproc) glutEnterGameMode }, - { "glutLeaveGameMode", (const GLUTproc) glutLeaveGameMode }, - { "glutGameModeGet", (const GLUTproc) glutGameModeGet }, -}; - - -GLUTproc GLUTAPIENTRY -glutGetProcAddress( const char *name ) -{ - int i; - - for (i = 0; i < sizeof(glut_functions)/sizeof(glut_functions[0]); i++) { - if (!strcmp( name, glut_functions[i].name )) - return glut_functions[i].address; - } - -#if DIRECTFBGL_INTERFACE_VERSION >= 1 - if (g_current) { - void *address = NULL; - g_current->gl->GetProcAddress( g_current->gl, name, &address ); - return address; - } -#endif - return NULL; -} - - -int GLUTAPIENTRY -glutExtensionSupported( const char *name ) -{ - GLubyte *extensions; - int length; - - if (!name || !*name) - return 0; - - length = strlen( name ); - extensions = (GLubyte*) glGetString( GL_EXTENSIONS ); - - while (extensions && *extensions) { - GLubyte *next; - - next = strchr( extensions, ' ' ); - if (next) { - if (length == (int)(next - extensions)) { - if (!strncmp( extensions, name, length )) - return 1; - } - extensions = next+1; - } - else { - if (!strcmp( extensions, name )) - return 1; - break; - } - } - - return 0; -} - diff --git a/src/glut/directfb/font.c b/src/glut/directfb/font.c deleted file mode 100644 index 0139cddbecd..00000000000 --- a/src/glut/directfb/font.c +++ /dev/null @@ -1,213 +0,0 @@ -/* Copyright (c) Mark J. Kilgard, 1994, 1998. - - This program is freely distributable without licensing fees - and is provided without guarantee or warrantee expressed or - implied. This program is -not- in the public domain. */ - -#include "internal.h" -#include "font.h" - - -#if defined(_WIN32) || defined (GLUT_IMPORT_LIB) - -static inline void* -__glutFont( void *font ) -{ - switch((long)font) { - case (long)GLUT_STROKE_ROMAN: - return &glutStrokeRoman; - case (long)GLUT_STROKE_MONO_ROMAN: - return &glutStrokeMonoRoman; - case (long)GLUT_BITMAP_9_BY_15: - return &glutBitmap9By15; - case (long)GLUT_BITMAP_8_BY_13: - return &glutBitmap8By13; - case (long)GLUT_BITMAP_TIMES_ROMAN_10: - return &glutBitmapTimesRoman10; - case (long)GLUT_BITMAP_TIMES_ROMAN_24: - return &glutBitmapTimesRoman24; - case (long)GLUT_BITMAP_HELVETICA_10: - return &glutBitmapHelvetica10; - case (long)GLUT_BITMAP_HELVETICA_12: - return &glutBitmapHelvetica12; - case (long)GLUT_BITMAP_HELVETICA_18: - return &glutBitmapHelvetica18; - } - - return NULL; -} - -#else - -static inline void* -__glutFont( void *font ) -{ - return font; -} - -#endif - - -void GLUTAPIENTRY -glutBitmapCharacter( GLUTbitmapFont font, int c ) -{ - const BitmapCharRec *ch; - BitmapFontPtr fontinfo; - GLint swapbytes, lsbfirst, rowlength; - GLint skiprows, skippixels, alignment; - - fontinfo = (BitmapFontPtr) __glutFont( font ); - - if (!fontinfo || c < fontinfo->first || - c >= fontinfo->first + fontinfo->num_chars) - return; - - ch = fontinfo->ch[c - fontinfo->first]; - if (ch) { - /* Save current modes. */ - glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes); - glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst); - glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength); - glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows); - glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels); - glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); - /* Little endian machines (DEC Alpha for example) could - benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE - instead of GL_FALSE, but this would require changing the - generated bitmaps too. */ - glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); - glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glBitmap(ch->width, ch->height, ch->xorig, ch->yorig, - ch->advance, 0, ch->bitmap); - /* Restore saved modes. */ - glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes); - glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst); - glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength); - glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels); - glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); - } -} - - -int GLUTAPIENTRY -glutBitmapWidth( GLUTbitmapFont font, int c ) -{ - BitmapFontPtr fontinfo; - const BitmapCharRec *ch; - - fontinfo = (BitmapFontPtr) __glutFont( font ); - - if (!fontinfo || c < fontinfo->first || - c >= fontinfo->first + fontinfo->num_chars) - return 0; - - ch = fontinfo->ch[c - fontinfo->first]; - if (ch) - return ch->advance; - - return 0; -} - - -int GLUTAPIENTRY -glutBitmapLength( GLUTbitmapFont font, const unsigned char *string ) -{ - int c, length; - BitmapFontPtr fontinfo; - const BitmapCharRec *ch; - - fontinfo = (BitmapFontPtr) __glutFont( font ); - if (!fontinfo) - return 0; - - for (length = 0; *string != '\0'; string++) { - c = *string; - if (c >= fontinfo->first && - c < fontinfo->first + fontinfo->num_chars) { - ch = fontinfo->ch[c - fontinfo->first]; - if (ch) - length += ch->advance; - } - } - - return length; -} - - -void GLUTAPIENTRY -glutStrokeCharacter( GLUTstrokeFont font, int c ) -{ - const StrokeCharRec *ch; - const StrokeRec *stroke; - const CoordRec *coord; - StrokeFontPtr fontinfo; - int i, j; - - fontinfo = (StrokeFontPtr) __glutFont( font ); - - if (!fontinfo || c < 0 || c >= fontinfo->num_chars) - return; - - ch = &(fontinfo->ch[c]); - if (ch) { - for (i = ch->num_strokes, stroke = ch->stroke; - i > 0; i--, stroke++) { - glBegin(GL_LINE_STRIP); - for (j = stroke->num_coords, coord = stroke->coord; - j > 0; j--, coord++) { - glVertex2f(coord->x, coord->y); - } - glEnd(); - } - glTranslatef(ch->right, 0.0, 0.0); - } -} - - -int GLUTAPIENTRY -glutStrokeWidth( GLUTstrokeFont font, int c ) -{ - StrokeFontPtr fontinfo; - const StrokeCharRec *ch; - - fontinfo = (StrokeFontPtr) __glutFont( font ); - - if (!fontinfo || c < 0 || c >= fontinfo->num_chars) - return 0; - - ch = &(fontinfo->ch[c]); - if (ch) - return ch->right; - - return 0; -} - - -int GLUTAPIENTRY -glutStrokeLength( GLUTstrokeFont font, const unsigned char *string ) -{ - int c, length; - StrokeFontPtr fontinfo; - const StrokeCharRec *ch; - - fontinfo = (StrokeFontPtr) __glutFont( font ); - if (!fontinfo) - return 0; - - for (length = 0; *string != '\0'; string++) { - c = *string; - if (c >= 0 && c < fontinfo->num_chars) { - ch = &(fontinfo->ch[c]); - if (ch) - length += ch->right; - } - } - - return length; -} - diff --git a/src/glut/directfb/font.h b/src/glut/directfb/font.h deleted file mode 100644 index b1e76838a0f..00000000000 --- a/src/glut/directfb/font.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) Mark J. Kilgard, 1994, 1998. */ - -/* This program is freely distributable without licensing fees - and is provided without guarantee or warrantee expressed or - implied. This program is -not- in the public domain. */ - -#ifndef __GLUT_FONT_H__ -#define __GLUT_FONT_H__ - - -typedef struct { - const GLsizei width; - const GLsizei height; - const GLfloat xorig; - const GLfloat yorig; - const GLfloat advance; - const GLubyte *bitmap; -} BitmapCharRec, *BitmapCharPtr; - -typedef struct { - const char *name; - const int num_chars; - const int first; - const BitmapCharRec * const *ch; -} BitmapFontRec, *BitmapFontPtr; - -typedef void *GLUTbitmapFont; - - -typedef struct { - float x; - float y; -} CoordRec, *CoordPtr; - -typedef struct { - int num_coords; - const CoordRec *coord; -} StrokeRec, *StrokePtr; - -typedef struct { - int num_strokes; - const StrokeRec *stroke; - float center; - float right; -} StrokeCharRec, *StrokeCharPtr; - -typedef struct { - const char *name; - int num_chars; - const StrokeCharRec *ch; - float top; - float bottom; -} StrokeFontRec, *StrokeFontPtr; - -typedef void *GLUTstrokeFont; - - -#endif /* __GLUT_FONT_H__ */ diff --git a/src/glut/directfb/game.c b/src/glut/directfb/game.c deleted file mode 100644 index 4c027a68f65..00000000000 --- a/src/glut/directfb/game.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include "internal.h" - - -/*****************************************************************************/ - -static int g_display_changed = 0; - -/*****************************************************************************/ - - -void GLUTAPIENTRY -glutGameModeString( const char *string ) -{ - int x, y, bpp; - char *tmp; - - if (!string) - return; - - tmp = strchr( string, 'x' ); - if (tmp) { - x = strtol( string, NULL, 10 ); - y = strtol( tmp+1, NULL, 10 ); - - if (x > 0 && y > 0) { - g_width = x; - g_height = y; - } - } - - tmp = strchr( string, ':' ); - if (tmp) { - bpp = strtol( tmp+1, NULL, 10 ); - - if (bpp > 0) - g_bpp = bpp; - } -} - - -int GLUTAPIENTRY -glutEnterGameMode( void ) -{ - DFBDisplayLayerConfig prev, cur; - - glutInit( NULL, NULL ); - - primary->GetConfiguration( primary, &prev ); - primary->SetCooperativeLevel( primary, DLSCL_EXCLUSIVE ); - - if (g_game) - __glutDestroyWindow( g_game ); - - g_game = __glutCreateWindow( GL_TRUE ); - if (!g_game) - return 0; - - __glutSetWindow( g_game ); - g_game->cursor = GLUT_CURSOR_NONE; - - primary->GetConfiguration( primary, &cur ); - g_display_changed = (cur.width != prev.width || - cur.height != prev.height || - cur.pixelformat != prev.pixelformat); - - return g_game->id; -} - - -void GLUTAPIENTRY -glutLeaveGameMode( void ) -{ - if (g_game) - __glutDestroyWindow( g_game ); - - primary->SetCooperativeLevel( primary, DLSCL_ADMINISTRATIVE ); -} - - -int GLUTAPIENTRY -glutGameModeGet( GLenum type ) -{ - switch (type) { - case GLUT_GAME_MODE_ACTIVE: - return (g_game != NULL); - case GLUT_GAME_MODE_POSSIBLE: - if (primary) { - DFBDisplayLayerConfig c; - c.flags = DLCONF_WIDTH | DLCONF_HEIGHT; - c.width = g_width; - c.height = g_height; - /* XXX: bpp */ - if (primary->TestConfiguration( primary, &c, 0 ) == DFB_OK) - return 1; - } - break; - case GLUT_GAME_MODE_WIDTH: - if (g_game) { - int w; - g_game->surface->GetSize( g_game->surface, &w, 0 ); - return w; - } - break; - case GLUT_GAME_MODE_HEIGHT: - if (g_game) { - int h; - g_game->surface->GetSize( g_game->surface, 0, &h ); - return h; - } - break; - case GLUT_GAME_MODE_PIXEL_DEPTH: - if (g_game) { - DFBSurfacePixelFormat f; - g_game->surface->GetPixelFormat( g_game->surface, &f ); - return DFB_COLOR_BITS_PER_PIXEL( f ); - } - break; - case GLUT_GAME_MODE_REFRESH_RATE: - return 60; /* assume 60hz */ - case GLUT_GAME_MODE_DISPLAY_CHANGED: - return g_display_changed; - default: - break; - } - - return 0; -} - - - diff --git a/src/glut/directfb/globals.c b/src/glut/directfb/globals.c deleted file mode 100644 index 2a5291137e2..00000000000 --- a/src/glut/directfb/globals.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "internal.h" - -IDirectFB *dfb = NULL; -IDirectFBDisplayLayer *primary = NULL; -IDirectFBEventBuffer *events = NULL; -IDirectFBInputDevice *keyboard = NULL; -IDirectFBInputDevice *mouse = NULL; -IDirectFBInputDevice *joystick = NULL; - -GLenum g_display_mode = 0; -GLuint g_width = DEFAULT_WIDTH; -GLuint g_height = DEFAULT_HEIGHT; -GLint g_xpos = 0; -GLint g_ypos = 0; -GLint g_bpp = 0; -GLboolean g_idle = GL_TRUE; -__GlutWindow *g_current = NULL; -__GlutWindow *g_game = NULL; - - -void (GLUTCALLBACK *display_func) (void) = 0; -void (GLUTCALLBACK *reshape_func) (int width, int height) = 0; -void (GLUTCALLBACK *keyboard_func) (unsigned char key, int x, int y) = 0; -void (GLUTCALLBACK *mouse_func) (int button, int state, int x, int y) = 0; -void (GLUTCALLBACK *motion_func) (int x, int y) = 0; -void (GLUTCALLBACK *passive_motion_func) (int x, int y) = 0; -void (GLUTCALLBACK *entry_func) (int state) = 0; -void (GLUTCALLBACK *visibility_func) (int state) = 0; -void (GLUTCALLBACK *idle_func) (void) = 0; -void (GLUTCALLBACK *menu_state_func) (int state) = 0; -void (GLUTCALLBACK *special_func) (int key, int x, int y) = 0; -void (GLUTCALLBACK *spaceball_motion_func) (int x, int y, int z) = 0; -void (GLUTCALLBACK *spaceball_rotate_func) (int x, int y, int z) = 0; -void (GLUTCALLBACK *spaceball_button_func) (int button, int state) = 0; -void (GLUTCALLBACK *button_box_func) (int button, int state) = 0; -void (GLUTCALLBACK *dials_func) (int dial, int value) = 0; -void (GLUTCALLBACK *tablet_motion_func) (int x, int y) = 0; -void (GLUTCALLBACK *tabled_button_func) (int button, int state, int x, int y) = 0; -void (GLUTCALLBACK *menu_status_func) (int status, int x, int y) = 0; -void (GLUTCALLBACK *overlay_display_func) (void) = 0; -void (GLUTCALLBACK *window_status_func) (int state) = 0; -void (GLUTCALLBACK *keyboard_up_func) (unsigned char key, int x, int y) = 0; -void (GLUTCALLBACK *special_up_func) (int key, int x, int y) = 0; -void (GLUTCALLBACK *joystick_func) (unsigned int buttons, int x, int y, int z) = 0; diff --git a/src/glut/directfb/init.c b/src/glut/directfb/init.c deleted file mode 100644 index ba1a49adf2c..00000000000 --- a/src/glut/directfb/init.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include "internal.h" - - -static void -__glutExit( void ) -{ - __glutFreeTimers(); - __glutDestroyWindows(); - - if (events) { - events->Release( events ); - events = NULL; - } - - if (joystick) { - joystick->Release( joystick ); - joystick = NULL; - } - - if (mouse) { - mouse->Release( mouse ); - mouse = NULL; - } - - if (keyboard) { - keyboard->Release( keyboard ); - keyboard = NULL; - } - - if (primary) { - primary->Release( primary ); - primary = NULL; - } - - if (dfb) { - dfb->Release( dfb ); - dfb = NULL; - } -} - - -void GLUTAPIENTRY -glutInit( int *argcp, char **argv ) -{ - DFBResult ret; - - if (dfb) - return; - - glutGet( GLUT_ELAPSED_TIME ); - - ret = DirectFBInit( argcp, argv ? &argv : NULL ); - if (ret) - DirectFBErrorFatal( "DirectFBInit()", ret ); - - ret = DirectFBCreate( &dfb ); - if (ret) - DirectFBErrorFatal( "DirectFBCreate()", ret ); - - ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &primary ); - if (ret) - DirectFBErrorFatal( "IDirectFB::GetDisplayLayer()", ret ); - - ret = dfb->CreateEventBuffer( dfb, &events ); - if (ret) - DirectFBErrorFatal( "IDirectFB::CreateEventBuffer()", ret ); - - dfb->GetInputDevice( dfb, DIDID_KEYBOARD, &keyboard ); - dfb->GetInputDevice( dfb, DIDID_MOUSE, &mouse ); - dfb->GetInputDevice( dfb, DIDID_JOYSTICK, &joystick ); - - primary->SetCooperativeLevel( primary, DLSCL_ADMINISTRATIVE ); - - atexit( __glutExit ); -} - - -void GLUTAPIENTRY -glutInitDisplayMode( unsigned int mode ) -{ - g_display_mode = mode; -} - - -void GLUTAPIENTRY -glutInitWindowPosition( int x, int y ) -{ - g_xpos = x; - g_ypos = y; -} - - -void GLUTAPIENTRY -glutInitWindowSize( int width, int height ) -{ - g_width = width; - g_height = height; -} - - -void GLUTAPIENTRY -glutInitDisplayString( const char *string ) -{ -} - diff --git a/src/glut/directfb/internal.h b/src/glut/directfb/internal.h deleted file mode 100644 index 55c4b5ce280..00000000000 --- a/src/glut/directfb/internal.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef __GLUT_INTERNAL_H__ -#define __GLUT_INTERNAL_H__ - -#include -#include - -#include -#include - -#include - -#include "GL/glut.h" - - -#define VERSION_CODE( M, m, r ) (((M) << 16) | ((m) << 8) | ((r))) - -#define DIRECTFB_VERSION_CODE VERSION_CODE( DIRECTFB_MAJOR_VERSION, \ - DIRECTFB_MINOR_VERSION, \ - DIRECTFB_MICRO_VERSION ) - - -#define DEFAULT_WIDTH 640 -#define DEFAULT_HEIGHT 480 - -/* - * Window request flags - */ -#define WINDOW_REQUEST_POSITION 0x00000001 -#define WINDOW_REQUEST_RESIZE 0x00000002 -#define WINDOW_REQUEST_RESTACK 0x00000004 -#define WINDOW_REQUEST_SHOW 0x00000008 -#define WINDOW_REQUEST_HIDE 0x00000010 -#define WINDOW_REQUEST_DESTROY 0x00000020 - -/* - * GLUT Window implementation - */ -typedef struct __GlutWindow_s { - int id; - DFBWindowID wid; - - IDirectFBWindow *window; /* NULL = fullscreen (game mode) */ - IDirectFBSurface *surface; - IDirectFBGL *gl; - - /* display mode */ - GLenum mode; - - /* cursor position in fullscreen mode */ - int cx; - int cy; - /* joystick position */ - int jx; - int jy; - int jz; - /* pressed modifiers */ - int modifiers; - /* pressed buttons */ - int buttons; - /* current cursor shape */ - int cursor; - - struct { - int flags; - int x; - int y; - int w; - int h; - int z; - } req; - - GLboolean visible; - GLboolean redisplay; - GLboolean reshape; - GLboolean visibility; - - struct __GlutWindow_s *next; - struct __GlutWindow_s *prev; -} __GlutWindow; - - -/* Global Vars */ -extern IDirectFB *dfb; -extern IDirectFBDisplayLayer *primary; -extern IDirectFBEventBuffer *events; -extern IDirectFBInputDevice *keyboard; -extern IDirectFBInputDevice *mouse; -extern IDirectFBInputDevice *joystick; - -extern GLenum g_display_mode; -extern GLuint g_width; -extern GLuint g_height; -extern GLint g_xpos; -extern GLint g_ypos; -extern GLint g_bpp; -extern GLboolean g_idle; -extern __GlutWindow *g_current; -extern __GlutWindow *g_game; - - -/* Global Funcs */ -/* window.c */ -extern __GlutWindow* __glutCreateWindow( GLboolean fullscreen ); -extern __GlutWindow* __glutFindWindow( DFBWindowID id ); -extern void __glutSetWindow( __GlutWindow *window ); -extern void __glutHandleWindows( void ); -extern void __glutDestroyWindow( __GlutWindow *window ); -extern void __glutDestroyWindows( void ); -/* callback.c */ -extern void __glutHandleTimers( void ); -extern GLboolean __glutGetTimeout( int *ret_msec ); -extern void __glutFreeTimers( void ); - - -/* Global Callbacks */ -extern void (GLUTCALLBACK *display_func) (void); -extern void (GLUTCALLBACK *reshape_func) (int width, int height); -extern void (GLUTCALLBACK *keyboard_func) (unsigned char key, int x, int y); -extern void (GLUTCALLBACK *mouse_func) (int button, int state, int x, int y); -extern void (GLUTCALLBACK *motion_func) (int x, int y); -extern void (GLUTCALLBACK *passive_motion_func) (int x, int y); -extern void (GLUTCALLBACK *entry_func) (int state); -extern void (GLUTCALLBACK *visibility_func) (int state); -extern void (GLUTCALLBACK *idle_func) (void); -extern void (GLUTCALLBACK *menu_state_func) (int state); -extern void (GLUTCALLBACK *special_func) (int key, int x, int y); -extern void (GLUTCALLBACK *spaceball_motion_func) (int x, int y, int z); -extern void (GLUTCALLBACK *spaceball_rotate_func) (int x, int y, int z); -extern void (GLUTCALLBACK *spaceball_button_func) (int button, int state); -extern void (GLUTCALLBACK *button_box_func) (int button, int state); -extern void (GLUTCALLBACK *dials_func) (int dial, int value); -extern void (GLUTCALLBACK *tablet_motion_func) (int x, int y); -extern void (GLUTCALLBACK *tabled_button_func) (int button, int state, int x, int y); -extern void (GLUTCALLBACK *menu_status_func) (int status, int x, int y); -extern void (GLUTCALLBACK *overlay_display_func) (void); -extern void (GLUTCALLBACK *window_status_func) (int state); -extern void (GLUTCALLBACK *keyboard_up_func) (unsigned char key, int x, int y); -extern void (GLUTCALLBACK *special_up_func) (int key, int x, int y); -extern void (GLUTCALLBACK *joystick_func) (unsigned int buttons, int x, int y, int z); - - -#ifdef DEBUG -# define __glutAssert( exp ) {\ - if (!(exp)) {\ - fprintf( stderr, "(!!) *** Assertion [%s] failed in %s() ***\n",\ - #exp, __FUNCTION__ ); - fflush( stderr );\ - exit( -1 );\ - }\ - } -#else -# define __glutAssert( exp ) -#endif - -#define __glutWarning( format, ... ) {\ - fprintf( stderr, "(!) GLUT: " format "!\n", ## __VA_ARGS__ );\ - fflush( stderr );\ -} - -#define __glutFatalError( format, ... ) {\ - fprintf( stderr, "(!) GLUT: " format "!\n", ## __VA_ARGS__ );\ - fprintf( stderr, "\t-> from %s() at line %d\n", __FUNCTION__, __LINE__ );\ - fflush( stderr );\ - exit( -1 );\ -} - - -#endif /* __GLUT_INTERNAL_H__ */ - diff --git a/src/glut/directfb/menu.c b/src/glut/directfb/menu.c deleted file mode 100644 index 400e966bbbe..00000000000 --- a/src/glut/directfb/menu.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "internal.h" - - -int GLUTAPIENTRY -glutCreateMenu( void (GLUTCALLBACK *func) (int) ) -{ - return 0; -} - -void GLUTAPIENTRY -glutDestroyMenu( int menu ) -{ -} - - -int GLUTAPIENTRY -glutGetMenu( void ) -{ - return 0; -} - - -void GLUTAPIENTRY -glutSetMenu( int menu ) -{ -} - - -void GLUTAPIENTRY -glutAddMenuEntry( const char *label, int value ) -{ -} - - -void GLUTAPIENTRY -glutAddSubMenu( const char *label, int submenu ) -{ -} - - -void GLUTAPIENTRY -glutChangeToMenuEntry( int item, const char *label, int value ) -{ -} - - -void GLUTAPIENTRY -glutChangeToSubMenu( int item, const char *label, int submenu ) -{ -} - - -void GLUTAPIENTRY -glutRemoveMenuItem( int item ) -{ -} - - -void GLUTAPIENTRY -glutAttachMenu( int button ) -{ -} - - -void GLUTAPIENTRY -glutDetachMenu( int button ) -{ -} diff --git a/src/glut/directfb/models.c b/src/glut/directfb/models.c deleted file mode 100644 index d96a8f50776..00000000000 --- a/src/glut/directfb/models.c +++ /dev/null @@ -1,599 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994, 1997. */ - -/** -(c) Copyright 1993, Silicon Graphics, Inc. - -ALL RIGHTS RESERVED - -Permission to use, copy, modify, and distribute this software -for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that -both the copyright notice and this permission notice appear in -supporting documentation, and that the name of Silicon -Graphics, Inc. not be used in advertising or publicity -pertaining to distribution of the software without specific, -written prior permission. - -THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU -"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR -OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF -MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO -EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE -ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER, -INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE, -SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR -NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY -OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR -PERFORMANCE OF THIS SOFTWARE. - -US Government Users Restricted Rights - -Use, duplication, or disclosure by the Government is subject to -restrictions set forth in FAR 52.227.19(c)(2) or subparagraph -(c)(1)(ii) of the Rights in Technical Data and Computer -Software clause at DFARS 252.227-7013 and/or in similar or -successor clauses in the FAR or the DOD or NASA FAR -Supplement. Unpublished-- rights reserved under the copyright -laws of the United States. Contractor/manufacturer is Silicon -Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA -94039-7311. - -OpenGL(TM) is a trademark of Silicon Graphics, Inc. -*/ - -#include -#include -#include - -#include "internal.h" - -/* Some files do not define M_PI... */ -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -static GLUquadricObj *quadObj; - -#define QUAD_OBJ_INIT() { if(!quadObj) initQuadObj(); } - -static void -initQuadObj(void) -{ - quadObj = gluNewQuadric(); - if (!quadObj) - __glutFatalError("out of memory"); -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireSphere(GLdouble radius, GLint slices, GLint stacks) -{ - QUAD_OBJ_INIT(); - gluQuadricDrawStyle(quadObj, GLU_LINE); - gluQuadricNormals(quadObj, GLU_SMOOTH); - /* If we ever changed/used the texture or orientation state - of quadObj, we'd need to change it to the defaults here - with gluQuadricTexture and/or gluQuadricOrientation. */ - gluSphere(quadObj, radius, slices, stacks); -} - -void GLUTAPIENTRY -glutSolidSphere(GLdouble radius, GLint slices, GLint stacks) -{ - QUAD_OBJ_INIT(); - gluQuadricDrawStyle(quadObj, GLU_FILL); - gluQuadricNormals(quadObj, GLU_SMOOTH); - /* If we ever changed/used the texture or orientation state - of quadObj, we'd need to change it to the defaults here - with gluQuadricTexture and/or gluQuadricOrientation. */ - gluSphere(quadObj, radius, slices, stacks); -} - -void GLUTAPIENTRY -glutWireCone(GLdouble base, GLdouble height, - GLint slices, GLint stacks) -{ - QUAD_OBJ_INIT(); - gluQuadricDrawStyle(quadObj, GLU_LINE); - gluQuadricNormals(quadObj, GLU_SMOOTH); - /* If we ever changed/used the texture or orientation state - of quadObj, we'd need to change it to the defaults here - with gluQuadricTexture and/or gluQuadricOrientation. */ - gluCylinder(quadObj, base, 0.0, height, slices, stacks); -} - -void GLUTAPIENTRY -glutSolidCone(GLdouble base, GLdouble height, - GLint slices, GLint stacks) -{ - QUAD_OBJ_INIT(); - gluQuadricDrawStyle(quadObj, GLU_FILL); - gluQuadricNormals(quadObj, GLU_SMOOTH); - /* If we ever changed/used the texture or orientation state - of quadObj, we'd need to change it to the defaults here - with gluQuadricTexture and/or gluQuadricOrientation. */ - gluCylinder(quadObj, base, 0.0, height, slices, stacks); -} - -/* ENDCENTRY */ - -static void -drawBox(GLfloat size, GLenum type) -{ - static GLfloat n[6][3] = - { - {-1.0, 0.0, 0.0}, - {0.0, 1.0, 0.0}, - {1.0, 0.0, 0.0}, - {0.0, -1.0, 0.0}, - {0.0, 0.0, 1.0}, - {0.0, 0.0, -1.0} - }; - static GLint faces[6][4] = - { - {0, 1, 2, 3}, - {3, 2, 6, 7}, - {7, 6, 5, 4}, - {4, 5, 1, 0}, - {5, 6, 2, 1}, - {7, 4, 0, 3} - }; - GLfloat v[8][3]; - GLint i; - - v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2; - v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2; - v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2; - v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2; - v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2; - v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2; - - for (i = 5; i >= 0; i--) { - glBegin(type); -/* glNormal3fv(&n[i][0]); */ - glVertex3fv(&v[faces[i][0]][0]); - glVertex3fv(&v[faces[i][1]][0]); - glVertex3fv(&v[faces[i][2]][0]); - glVertex3fv(&v[faces[i][3]][0]); - glEnd(); - } -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireCube(GLdouble size) -{ - drawBox(size, GL_LINE_LOOP); -} - -void GLUTAPIENTRY -glutSolidCube(GLdouble size) -{ - drawBox(size, GL_QUADS); -} - -/* ENDCENTRY */ - -static void -doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings) -{ - int i, j; - GLfloat theta, phi, theta1; - GLfloat cosTheta, sinTheta; - GLfloat cosTheta1, sinTheta1; - GLfloat ringDelta, sideDelta; - - ringDelta = 2.0 * M_PI / rings; - sideDelta = 2.0 * M_PI / nsides; - - theta = 0.0; - cosTheta = 1.0; - sinTheta = 0.0; - for (i = rings - 1; i >= 0; i--) { - theta1 = theta + ringDelta; - cosTheta1 = cos(theta1); - sinTheta1 = sin(theta1); - glBegin(GL_QUAD_STRIP); - phi = 0.0; - for (j = nsides; j >= 0; j--) { - GLfloat cosPhi, sinPhi, dist; - - phi += sideDelta; - cosPhi = cos(phi); - sinPhi = sin(phi); - dist = R + r * cosPhi; - -/* glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); */ - glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); -/* glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); */ - glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi); - } - glEnd(); - theta = theta1; - cosTheta = cosTheta1; - sinTheta = sinTheta1; - } -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, - GLint nsides, GLint rings) -{ -/* glPushAttrib(GL_POLYGON_BIT); */ -/* glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); */ - doughnut(innerRadius, outerRadius, nsides, rings); -/* glPopAttrib(); */ -} - -void GLUTAPIENTRY -glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, - GLint nsides, GLint rings) -{ - doughnut(innerRadius, outerRadius, nsides, rings); -} - -/* ENDCENTRY */ - -static GLfloat dodec[20][3]; - -static void -initDodecahedron(void) -{ - GLfloat alpha, beta; - - alpha = sqrt(2.0 / (3.0 + sqrt(5.0))); - beta = 1.0 + sqrt(6.0 / (3.0 + sqrt(5.0)) - - 2.0 + 2.0 * sqrt(2.0 / (3.0 + sqrt(5.0)))); - /* *INDENT-OFF* */ - dodec[0][0] = -alpha; dodec[0][1] = 0; dodec[0][2] = beta; - dodec[1][0] = alpha; dodec[1][1] = 0; dodec[1][2] = beta; - dodec[2][0] = -1; dodec[2][1] = -1; dodec[2][2] = -1; - dodec[3][0] = -1; dodec[3][1] = -1; dodec[3][2] = 1; - dodec[4][0] = -1; dodec[4][1] = 1; dodec[4][2] = -1; - dodec[5][0] = -1; dodec[5][1] = 1; dodec[5][2] = 1; - dodec[6][0] = 1; dodec[6][1] = -1; dodec[6][2] = -1; - dodec[7][0] = 1; dodec[7][1] = -1; dodec[7][2] = 1; - dodec[8][0] = 1; dodec[8][1] = 1; dodec[8][2] = -1; - dodec[9][0] = 1; dodec[9][1] = 1; dodec[9][2] = 1; - dodec[10][0] = beta; dodec[10][1] = alpha; dodec[10][2] = 0; - dodec[11][0] = beta; dodec[11][1] = -alpha; dodec[11][2] = 0; - dodec[12][0] = -beta; dodec[12][1] = alpha; dodec[12][2] = 0; - dodec[13][0] = -beta; dodec[13][1] = -alpha; dodec[13][2] = 0; - dodec[14][0] = -alpha; dodec[14][1] = 0; dodec[14][2] = -beta; - dodec[15][0] = alpha; dodec[15][1] = 0; dodec[15][2] = -beta; - dodec[16][0] = 0; dodec[16][1] = beta; dodec[16][2] = alpha; - dodec[17][0] = 0; dodec[17][1] = beta; dodec[17][2] = -alpha; - dodec[18][0] = 0; dodec[18][1] = -beta; dodec[18][2] = alpha; - dodec[19][0] = 0; dodec[19][1] = -beta; dodec[19][2] = -alpha; - /* *INDENT-ON* */ - -} - -#define DIFF3(_a,_b,_c) { \ - (_c)[0] = (_a)[0] - (_b)[0]; \ - (_c)[1] = (_a)[1] - (_b)[1]; \ - (_c)[2] = (_a)[2] - (_b)[2]; \ -} - -static void -crossprod(GLfloat v1[3], GLfloat v2[3], GLfloat prod[3]) -{ - GLfloat p[3]; /* in case prod == v1 or v2 */ - - p[0] = v1[1] * v2[2] - v2[1] * v1[2]; - p[1] = v1[2] * v2[0] - v2[2] * v1[0]; - p[2] = v1[0] * v2[1] - v2[0] * v1[1]; - prod[0] = p[0]; - prod[1] = p[1]; - prod[2] = p[2]; -} - -static void -normalize(GLfloat v[3]) -{ - GLfloat d; - - d = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); - if (d == 0.0) { -/* __glutWarning("normalize: zero length vector"); */ - v[0] = d = 1.0; - } - d = 1 / d; - v[0] *= d; - v[1] *= d; - v[2] *= d; -} - -static void -pentagon(int a, int b, int c, int d, int e, GLenum shadeType) -{ - GLfloat n0[3], d1[3], d2[3]; - - DIFF3(dodec[a], dodec[b], d1); - DIFF3(dodec[b], dodec[c], d2); - crossprod(d1, d2, n0); - normalize(n0); - - glBegin(shadeType); -/* glNormal3fv(n0); */ - glVertex3fv(&dodec[a][0]); - glVertex3fv(&dodec[b][0]); - glVertex3fv(&dodec[c][0]); - glVertex3fv(&dodec[d][0]); - glVertex3fv(&dodec[e][0]); - glEnd(); -} - -static void -dodecahedron(GLenum type) -{ - static int inited = 0; - - if (inited == 0) { - inited = 1; - initDodecahedron(); - } - pentagon(0, 1, 9, 16, 5, type); - pentagon(1, 0, 3, 18, 7, type); - pentagon(1, 7, 11, 10, 9, type); - pentagon(11, 7, 18, 19, 6, type); - pentagon(8, 17, 16, 9, 10, type); - pentagon(2, 14, 15, 6, 19, type); - pentagon(2, 13, 12, 4, 14, type); - pentagon(2, 19, 18, 3, 13, type); - pentagon(3, 0, 5, 12, 13, type); - pentagon(6, 15, 8, 10, 11, type); - pentagon(4, 17, 8, 15, 14, type); - pentagon(4, 12, 5, 16, 17, type); -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireDodecahedron(void) -{ - dodecahedron(GL_LINE_LOOP); -} - -void GLUTAPIENTRY -glutSolidDodecahedron(void) -{ - dodecahedron(GL_TRIANGLE_FAN); -} - -/* ENDCENTRY */ - -static void -recorditem(GLfloat * n1, GLfloat * n2, GLfloat * n3, - GLenum shadeType) -{ - GLfloat q0[3], q1[3]; - - DIFF3(n1, n2, q0); - DIFF3(n2, n3, q1); - crossprod(q0, q1, q1); - normalize(q1); - - glBegin(shadeType); -/* glNormal3fv(q1); */ - glVertex3fv(n1); - glVertex3fv(n2); - glVertex3fv(n3); - glEnd(); -} - -static void -subdivide(GLfloat * v0, GLfloat * v1, GLfloat * v2, - GLenum shadeType) -{ - int depth; - GLfloat w0[3], w1[3], w2[3]; - GLfloat l; - int i, j, k, n; - - depth = 1; - for (i = 0; i < depth; i++) { - for (j = 0; i + j < depth; j++) { - k = depth - i - j; - for (n = 0; n < 3; n++) { - w0[n] = (i * v0[n] + j * v1[n] + k * v2[n]) / depth; - w1[n] = ((i + 1) * v0[n] + j * v1[n] + (k - 1) * v2[n]) - / depth; - w2[n] = (i * v0[n] + (j + 1) * v1[n] + (k - 1) * v2[n]) - / depth; - } - l = sqrt(w0[0] * w0[0] + w0[1] * w0[1] + w0[2] * w0[2]); - w0[0] /= l; - w0[1] /= l; - w0[2] /= l; - l = sqrt(w1[0] * w1[0] + w1[1] * w1[1] + w1[2] * w1[2]); - w1[0] /= l; - w1[1] /= l; - w1[2] /= l; - l = sqrt(w2[0] * w2[0] + w2[1] * w2[1] + w2[2] * w2[2]); - w2[0] /= l; - w2[1] /= l; - w2[2] /= l; - recorditem(w1, w0, w2, shadeType); - } - } -} - -static void -drawtriangle(int i, GLfloat data[][3], int ndx[][3], - GLenum shadeType) -{ - GLfloat *x0, *x1, *x2; - - x0 = data[ndx[i][0]]; - x1 = data[ndx[i][1]]; - x2 = data[ndx[i][2]]; - subdivide(x0, x1, x2, shadeType); -} - -/* octahedron data: The octahedron produced is centered at the - origin and has radius 1.0 */ -static GLfloat odata[6][3] = -{ - {1.0, 0.0, 0.0}, - {-1.0, 0.0, 0.0}, - {0.0, 1.0, 0.0}, - {0.0, -1.0, 0.0}, - {0.0, 0.0, 1.0}, - {0.0, 0.0, -1.0} -}; - -static int ondex[8][3] = -{ - {0, 4, 2}, - {1, 2, 4}, - {0, 3, 4}, - {1, 4, 3}, - {0, 2, 5}, - {1, 5, 2}, - {0, 5, 3}, - {1, 3, 5} -}; - -static void -octahedron(GLenum shadeType) -{ - int i; - - for (i = 7; i >= 0; i--) { - drawtriangle(i, odata, ondex, shadeType); - } -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireOctahedron(void) -{ - octahedron(GL_LINE_LOOP); -} - -void GLUTAPIENTRY -glutSolidOctahedron(void) -{ - octahedron(GL_TRIANGLES); -} - -/* ENDCENTRY */ - -/* icosahedron data: These numbers are rigged to make an - icosahedron of radius 1.0 */ - -#define X .525731112119133606 -#define Z .850650808352039932 - -static GLfloat idata[12][3] = -{ - {-X, 0, Z}, - {X, 0, Z}, - {-X, 0, -Z}, - {X, 0, -Z}, - {0, Z, X}, - {0, Z, -X}, - {0, -Z, X}, - {0, -Z, -X}, - {Z, X, 0}, - {-Z, X, 0}, - {Z, -X, 0}, - {-Z, -X, 0} -}; - -static int index[20][3] = -{ - {0, 4, 1}, - {0, 9, 4}, - {9, 5, 4}, - {4, 5, 8}, - {4, 8, 1}, - {8, 10, 1}, - {8, 3, 10}, - {5, 3, 8}, - {5, 2, 3}, - {2, 7, 3}, - {7, 10, 3}, - {7, 6, 10}, - {7, 11, 6}, - {11, 0, 6}, - {0, 1, 6}, - {6, 1, 10}, - {9, 0, 11}, - {9, 11, 2}, - {9, 2, 5}, - {7, 2, 11}, -}; - -static void -icosahedron(GLenum shadeType) -{ - int i; - - for (i = 19; i >= 0; i--) { - drawtriangle(i, idata, index, shadeType); - } -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireIcosahedron(void) -{ - icosahedron(GL_LINE_LOOP); -} - -void GLUTAPIENTRY -glutSolidIcosahedron(void) -{ - icosahedron(GL_TRIANGLES); -} - -/* ENDCENTRY */ - -/* tetrahedron data: */ - -#define T 1.73205080756887729 - -static GLfloat tdata[4][3] = -{ - {T, T, T}, - {T, -T, -T}, - {-T, T, -T}, - {-T, -T, T} -}; - -static int tndex[4][3] = -{ - {0, 1, 3}, - {2, 1, 0}, - {3, 2, 0}, - {1, 2, 3} -}; - -static void -tetrahedron(GLenum shadeType) -{ - int i; - - for (i = 3; i >= 0; i--) - drawtriangle(i, tdata, tndex, shadeType); -} - -/* CENTRY */ -void GLUTAPIENTRY -glutWireTetrahedron(void) -{ - tetrahedron(GL_LINE_LOOP); -} - -void GLUTAPIENTRY -glutSolidTetrahedron(void) -{ - tetrahedron(GL_TRIANGLES); -} - -/* ENDCENTRY */ diff --git a/src/glut/directfb/overlay.c b/src/glut/directfb/overlay.c deleted file mode 100644 index 714be5f1a28..00000000000 --- a/src/glut/directfb/overlay.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "internal.h" - - -void GLUTAPIENTRY -glutEstablishOverlay( void ) -{ -} - - -void GLUTAPIENTRY -glutRemoveOverlay( void ) -{ -} - - -void GLUTAPIENTRY -glutUseLayer( GLenum layer ) -{ -} - - -void GLUTAPIENTRY -glutPostOverlayRedisplay( void ) -{ -} - - -void GLUTAPIENTRY -glutPostWindowOverlayRedisplay( int win ) -{ -} - - -void GLUTAPIENTRY -glutShowOverlay( void ) -{ -} - - -void GLUTAPIENTRY -glutHideOverlay( void ) -{ -} diff --git a/src/glut/directfb/state.c b/src/glut/directfb/state.c deleted file mode 100644 index 194d5bbb626..00000000000 --- a/src/glut/directfb/state.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include "GL/glu.h" - -#include "internal.h" - - -int GLUTAPIENTRY -glutGet( GLenum type ) -{ - switch (type) { - case GLUT_WINDOW_X: - if (g_current && g_current->window) { - int x; - g_current->window->GetPosition( g_current->window, &x, 0 ); - return x; - } - break; - case GLUT_WINDOW_Y: - if (g_current && g_current->window) { - int y; - g_current->window->GetPosition( g_current->window, 0, &y ); - return y; - } - break; - - case GLUT_WINDOW_WIDTH: - if (g_current) { - int w; - g_current->surface->GetSize( g_current->surface, &w, 0 ); - return w; - } - break; - case GLUT_WINDOW_HEIGHT: - if (g_current) { - int h; - g_current->surface->GetSize( g_current->surface, 0, &h ); - return h; - } - break; - - case GLUT_WINDOW_BUFFER_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.buffer_size; - } - break; - case GLUT_WINDOW_STENCIL_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.stencil_size; - } - break; - case GLUT_WINDOW_DEPTH_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.depth_size; - } - break; - case GLUT_WINDOW_RED_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.red_size; - } - break; - case GLUT_WINDOW_GREEN_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.green_size; - } - break; - case GLUT_WINDOW_BLUE_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.blue_size; - } - break; - case GLUT_WINDOW_ALPHA_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.alpha_size; - } - break; - case GLUT_WINDOW_ACCUM_RED_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.accum_red_size; - } - break; - case GLUT_WINDOW_ACCUM_GREEN_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.accum_green_size; - } - break; - case GLUT_WINDOW_ACCUM_BLUE_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.accum_blue_size; - } - break; - case GLUT_WINDOW_ACCUM_ALPHA_SIZE: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.accum_alpha_size; - } - break; - case GLUT_WINDOW_DOUBLEBUFFER: - if (g_current) { - DFBGLAttributes a; - g_current->gl->GetAttributes( g_current->gl, &a ); - return a.double_buffer; - } - break; - - case GLUT_WINDOW_RGBA: - return 1; - - case GLUT_WINDOW_CURSOR: - if (g_current) - return g_current->cursor; - break; - - case GLUT_SCREEN_WIDTH: - if (primary) { - DFBDisplayLayerConfig c; - primary->GetConfiguration( primary, &c ); - return c.width; - } - break; - case GLUT_SCREEN_HEIGHT: - if (primary) { - DFBDisplayLayerConfig c; - primary->GetConfiguration( primary, &c ); - return c.height; - } - break; - - case GLUT_INIT_DISPLAY_MODE: - return g_display_mode; - case GLUT_INIT_WINDOW_X: - return g_xpos; - case GLUT_INIT_WINDOW_Y: - return g_ypos; - case GLUT_INIT_WINDOW_WIDTH: - return g_width; - case GLUT_INIT_WINDOW_HEIGHT: - return g_height; - - case GLUT_ELAPSED_TIME: - { - static long long start = -1; - struct timeval t; - - gettimeofday( &t, NULL ); - if (start == -1) { - start = t.tv_sec * 1000ll + t.tv_usec / 1000ll; - return 0; - } - return (t.tv_sec * 1000ll + t.tv_usec / 1000ll - start); - } - break; - - default: - break; - } - - return 0; -} - - -int GLUTAPIENTRY -glutLayerGet( GLenum type ) -{ - return 0; -} - -void GLUTAPIENTRY -glutReportErrors( void ) -{ - GLenum error; - - while ((error = glGetError()) != GL_NO_ERROR) - __glutWarning( "**OpenGL Error** %s", gluErrorString( error ) ); -} - - diff --git a/src/glut/directfb/teapot.c b/src/glut/directfb/teapot.c deleted file mode 100644 index e7f1ee812fa..00000000000 --- a/src/glut/directfb/teapot.c +++ /dev/null @@ -1,212 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1994. */ - -/** -(c) Copyright 1993, Silicon Graphics, Inc. - -ALL RIGHTS RESERVED - -Permission to use, copy, modify, and distribute this software -for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that -both the copyright notice and this permission notice appear in -supporting documentation, and that the name of Silicon -Graphics, Inc. not be used in advertising or publicity -pertaining to distribution of the software without specific, -written prior permission. - -THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU -"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR -OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF -MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO -EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE -ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER, -INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE, -SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR -NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY -OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR -PERFORMANCE OF THIS SOFTWARE. - -US Government Users Restricted Rights - -Use, duplication, or disclosure by the Government is subject to -restrictions set forth in FAR 52.227.19(c)(2) or subparagraph -(c)(1)(ii) of the Rights in Technical Data and Computer -Software clause at DFARS 252.227-7013 and/or in similar or -successor clauses in the FAR or the DOD or NASA FAR -Supplement. Unpublished-- rights reserved under the copyright -laws of the United States. Contractor/manufacturer is Silicon -Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA -94039-7311. - -OpenGL(TM) is a trademark of Silicon Graphics, Inc. -*/ - -#include -#include -#include "GL/glut.h" - -/* Rim, body, lid, and bottom data must be reflected in x and - y; handle and spout data across the y axis only. */ - -static int patchdata[][16] = -{ - /* rim */ - {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15}, - /* body */ - {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27}, - {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40}, - /* lid */ - {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101, - 101, 0, 1, 2, 3,}, - {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112, - 113, 114, 115, 116, 117}, - /* bottom */ - {118, 118, 118, 118, 124, 122, 119, 121, 123, 126, - 125, 120, 40, 39, 38, 37}, - /* handle */ - {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56}, - {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 28, 65, 66, 67}, - /* spout */ - {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83}, - {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - 92, 93, 94, 95} -}; -/* *INDENT-OFF* */ - -static float cpdata[][3] = -{ - {0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7}, {0, - -0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125}, - {0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, {1.4375, - 0, 2.53125}, {1.4375, -0.805, 2.53125}, {0.805, -1.4375, - 2.53125}, {0, -1.4375, 2.53125}, {1.5, 0, 2.4}, {1.5, -0.84, - 2.4}, {0.84, -1.5, 2.4}, {0, -1.5, 2.4}, {1.75, 0, 1.875}, - {1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75, - 1.875}, {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35}, - {0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9}, {1.12, -2, - 0.9}, {0, -2, 0.9}, {-2, 0, 0.9}, {2, 0, 0.45}, {2, -1.12, - 0.45}, {1.12, -2, 0.45}, {0, -2, 0.45}, {1.5, 0, 0.225}, - {1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 0.225}, - {1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15}, {0, - -1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025}, {-1.5, - -0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025}, {-2.3, -0.3, - 2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25}, {-2.7, 0, - 2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25}, {-3, 0, - 2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8}, {-3, -0.3, 1.8}, - {-3, 0, 1.8}, {-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3, - -0.3, 1.35}, {-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3, - 1.125}, {-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2, - -0.3, 0.9}, {-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0, - 1.425}, {1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0, - 0.6}, {2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66, - 0.825}, {3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1}, - {2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4}, {2.7, - -0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4}, {2.8, 0, - 2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375}, - {3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475}, - {3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4}, - {2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4}, {0, 0, - 3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15}, {0.45, -0.8, - 3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4}, {1.4, - -0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4}, {0.4, 0, - 2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55}, {0, -0.4, - 2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55}, {0.728, -1.3, - 2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, -0.728, 2.4}, - {0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425, - -0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425, - 0}, {0, -1.5, 0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075}, - {0.84, -1.5, 0.075} -}; - -static float tex[2][2][2] = -{ - { {0, 0}, - {1, 0}}, - { {0, 1}, - {1, 1}} -}; - -/* *INDENT-ON* */ - -static void -teapot(GLint grid, GLdouble scale, GLenum type) -{ - float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3]; - long i, j, k, l; - - glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT); - glEnable(GL_AUTO_NORMAL); - glEnable(GL_NORMALIZE); - glEnable(GL_MAP2_VERTEX_3); - glEnable(GL_MAP2_TEXTURE_COORD_2); - glPushMatrix(); - glRotatef(270.0, 1.0, 0.0, 0.0); - glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale); - glTranslatef(0.0, 0.0, -1.5); - for (i = 0; i < 10; i++) { - for (j = 0; j < 4; j++) { - for (k = 0; k < 4; k++) { - for (l = 0; l < 3; l++) { - p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l]; - q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l]; - if (l == 1) - q[j][k][l] *= -1.0; - if (i < 6) { - r[j][k][l] = - cpdata[patchdata[i][j * 4 + (3 - k)]][l]; - if (l == 0) - r[j][k][l] *= -1.0; - s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l]; - if (l == 0) - s[j][k][l] *= -1.0; - if (l == 1) - s[j][k][l] *= -1.0; - } - } - } - } - glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, - &tex[0][0][0]); - glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, - &p[0][0][0]); - glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0); - glEvalMesh2(type, 0, grid, 0, grid); - glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, - &q[0][0][0]); - glEvalMesh2(type, 0, grid, 0, grid); - if (i < 6) { - glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, - &r[0][0][0]); - glEvalMesh2(type, 0, grid, 0, grid); - glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, - &s[0][0][0]); - glEvalMesh2(type, 0, grid, 0, grid); - } - } - glPopMatrix(); - glPopAttrib(); -} - -/* CENTRY */ -void GLUTAPIENTRY -glutSolidTeapot(GLdouble scale) -{ - teapot(7, scale, GL_FILL); -} - -void GLUTAPIENTRY -glutWireTeapot(GLdouble scale) -{ - teapot(10, scale, GL_LINE); -} - -/* ENDCENTRY */ diff --git a/src/glut/directfb/window.c b/src/glut/directfb/window.c deleted file mode 100644 index 62cf8bb33e0..00000000000 --- a/src/glut/directfb/window.c +++ /dev/null @@ -1,597 +0,0 @@ -/* - * Copyright (C) 2006 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include -#include - -#include "internal.h" - - -/*****************************************************************************/ - -static __GlutWindow *g_stack = NULL; - -/*****************************************************************************/ - - -__GlutWindow* -__glutCreateWindow( GLboolean fullscreen ) -{ - __GlutWindow *new; - DFBResult ret; - static int curid = 1; - - new = calloc( 1, sizeof(__GlutWindow) ); - if (!new) - __glutFatalError( "out of memory" ); - - new->id = curid++; - - if (fullscreen) { - DFBDisplayLayerConfig config; - DFBDisplayLayerConfigFlags fail = 0; - - config.flags = DLCONF_WIDTH | DLCONF_HEIGHT | - DLCONF_BUFFERMODE; - config.width = g_width; - config.height = g_height; - - if (g_display_mode & GLUT_DOUBLE) - config.buffermode = DLBM_BACKVIDEO; - else - config.buffermode = DLBM_FRONTONLY; - - if (g_bpp) { - config.flags |= DLCONF_PIXELFORMAT; - - switch (g_bpp) { - case 8: - config.pixelformat = DSPF_RGB332; - break; - case 12: - config.pixelformat = DSPF_ARGB4444; - break; - case 15: - config.pixelformat = DSPF_ARGB1555; - break; - case 16: - config.pixelformat = DSPF_RGB16; - break; - case 24: - case 32: - config.pixelformat = DSPF_RGB32; - break; - default: - config.flags &= ~DLCONF_PIXELFORMAT; - break; - } - } - - primary->TestConfiguration( primary, &config, &fail ); - config.flags &= ~fail; - primary->SetConfiguration( primary, &config ); - - ret = primary->GetSurface( primary, &new->surface ); - if (ret) { - DirectFBError( "IDirectFBDisplayLayer::GetSurface()", ret ); - free( new ); - return NULL; - } - - ret = new->surface->GetGL( new->surface, &new->gl ); - if (ret) { - DirectFBError( "IDirectFBSurface::GetGL()", ret ); - new->surface->Release( new->surface ); - free( new ); - return NULL; - } - - events->Reset( events ); - if (keyboard) - keyboard->AttachEventBuffer( keyboard, events ); - if (mouse) - mouse->AttachEventBuffer( mouse, events ); - if (joystick) - joystick->AttachEventBuffer( joystick, events ); - - new->visible = GL_TRUE; - } - else { - DFBWindowDescription dsc; - - dsc.flags = DWDESC_CAPS | DWDESC_POSX | DWDESC_POSY | - DWDESC_WIDTH | DWDESC_HEIGHT; - dsc.caps = DWCAPS_NONE; - dsc.posx = g_xpos; - dsc.posy = g_ypos; - dsc.width = g_width; - dsc.height = g_height; - - if (g_display_mode & GLUT_DOUBLE) - dsc.caps |= DWCAPS_DOUBLEBUFFER; - if (g_display_mode & GLUT_ALPHA) - dsc.caps |= DWCAPS_ALPHACHANNEL; - - ret = primary->CreateWindow( primary, &dsc, &new->window ); - if (ret) { - DirectFBError( "IDirectFBDisplayLayer::CreateWindow()", ret ); - free( new ); - return NULL; - } - - new->window->GetID( new->window, &new->wid ); - - ret = new->window->GetSurface( new->window, &new->surface ); - if (ret) { - DirectFBError( "IDirectFBWindow::GetSurface()", ret ); - new->window->Release( new->window ); - free( new ); - return NULL; - } - - ret = new->surface->GetGL( new->surface, &new->gl ); - if (ret) { - DirectFBError( "IDirectFBSurface::GetGl()", ret ); - new->surface->Release( new->surface ); - new->window->Release( new->window ); - free( new ); - return NULL; - } - - new->window->AttachEventBuffer( new->window, events ); - /* enable only handled events */ - new->window->DisableEvents( new->window, DWET_ALL ); - new->window->EnableEvents( new->window, DWET_KEYDOWN | DWET_KEYUP | - DWET_BUTTONDOWN | DWET_BUTTONUP | - DWET_ENTER | DWET_LEAVE | - DWET_MOTION | DWET_SIZE ); - - new->req.flags |= WINDOW_REQUEST_SHOW; - } - - new->mode = g_display_mode; - - new->reshape = GL_TRUE; - new->visibility = GL_TRUE; - new->redisplay = GL_TRUE; - - if (g_stack) { - new->prev = g_stack->prev; - g_stack->prev->next = new; - g_stack->prev = new; - } - else { - new->prev = new; - g_stack = new; - } - - return new; -} - - -__GlutWindow* -__glutFindWindow( DFBWindowID id ) -{ - __GlutWindow *cur; - - for (cur = g_stack; cur; cur = cur->next) { - if (cur->wid == id) - return cur; - } - - __glutFatalError( "Window %d not found", id ); - - return NULL; -} - - -void -__glutSetWindow( __GlutWindow *window ) -{ - if (g_current) { - if (g_current == window) - return; - g_current->gl->Unlock( g_current->gl ); - } - - if (window) - window->gl->Lock( window->gl ); - g_current = window; -} - - -void -__glutHandleWindows( void ) -{ - __GlutWindow *cur = g_stack; - - while (cur) { - __GlutWindow *next = cur->next; - GLboolean displayed = GL_FALSE; - - if (cur->window && cur->req.flags) { - if (cur == g_current) - cur->gl->Unlock( cur->gl ); - - if (cur->req.flags & WINDOW_REQUEST_DESTROY) { - __glutDestroyWindow( cur ); - cur = next; - continue; - } - - if (cur->req.flags & WINDOW_REQUEST_POSITION) { - cur->window->MoveTo( cur->window, - cur->req.x, cur->req.y ); - } - - if (cur->req.flags & WINDOW_REQUEST_RESIZE) { - cur->window->Resize( cur->window, - cur->req.w, cur->req.h ); - cur->reshape = GL_TRUE; - cur->redisplay = GL_TRUE; - } - - if (cur->req.flags & WINDOW_REQUEST_RESTACK) { - while (cur->req.z > 0) { - if (cur->req.z >= +1000) { - cur->window->RaiseToTop( cur->window ); - cur->req.z = 0; - break; - } - - cur->window->Raise( cur->window ); - cur->req.z--; - } - - while (cur->req.z < 0) { - if (cur->req.z <= -1000) { - cur->window->LowerToBottom( cur->window ); - cur->req.z = 0; - break; - } - - cur->window->Lower( cur->window ); - cur->req.z++; - } - } - - if (cur->req.flags & WINDOW_REQUEST_SHOW) { - cur->window->SetOpacity( cur->window, 0xff ); - cur->visible = GL_TRUE; - cur->visibility = GL_TRUE; - } - else if (cur->req.flags & WINDOW_REQUEST_HIDE) { - cur->window->SetOpacity( cur->window, 0x00 ); - cur->visible = GL_FALSE; - cur->visibility = GL_TRUE; - } - - cur->req.flags = 0; - - if (cur == g_current) - cur->gl->Lock( cur->gl ); - } - - if (cur->reshape && reshape_func) { - int w, h; - g_idle = GL_FALSE; - cur->surface->GetSize( cur->surface, &w, &h ); - __glutSetWindow( cur ); - reshape_func( w, h ); - displayed = GL_TRUE; - } - - if (cur->visibility && visibility_func) { - g_idle = GL_FALSE; - __glutSetWindow( cur ); - visibility_func( cur->visible ? GLUT_VISIBLE : GLUT_NOT_VISIBLE ); - displayed = GL_TRUE; - } - - if (cur->redisplay && display_func) { - g_idle = GL_FALSE; - __glutSetWindow( cur ); - display_func(); - displayed = GL_TRUE; - } - - if (displayed && cur->window && cur->visible) { - if (!(cur->mode & GLUT_DOUBLE)) { - cur->gl->Unlock( cur->gl ); - cur->surface->Flip( cur->surface, NULL, 0 ); - cur->gl->Lock( cur->gl ); - } - } - - cur->reshape = GL_FALSE; - cur->visibility = GL_FALSE; - cur->redisplay = GL_FALSE; - - cur = next; - } -} - - -void -__glutDestroyWindow( __GlutWindow *window ) -{ - __GlutWindow *next = window->next; - __GlutWindow *prev = window->prev; - - __glutAssert( window != NULL ); - - if (window == g_current) - g_current = NULL; - if (window == g_game) - g_game = NULL; - - window->gl->Unlock( window->gl ); - window->gl->Release( window->gl ); - window->surface->Release( window->surface ); - - if (window->window) { -#if DIRECTFB_VERSION_CODE >= VERSION_CODE(0,9,26) - window->window->DetachEventBuffer( window->window, events ); -#else - window->window->Destroy( window->window ); -#endif - window->window->Release( window->window ); - } - else { -#if DIRECTFB_VERSION_CODE >= VERSION_CODE(0,9,26) - if (joystick) - joystick->DetachEventBuffer( joystick, events ); - if (mouse) - mouse->DetachEventBuffer( mouse, events ); - if (keyboard) - keyboard->DetachEventBuffer( keyboard, events ); -#endif - events->Reset( events ); - } - - free( window ); - - if (next) - next->prev = prev; - else - g_stack->prev = prev; - - if (window == g_stack) - g_stack = next; - else - prev->next = next; -} - - -void -__glutDestroyWindows( void ) -{ - __GlutWindow *cur = g_stack; - - while (cur) { - __GlutWindow *next = cur->next; - __glutDestroyWindow( cur ); - cur = next; - } -} - - -int GLUTAPIENTRY -glutCreateWindow( const char *title ) -{ - __GlutWindow *window; - - if (getenv( "__GLUT_GAME_MODE" )) - return glutEnterGameMode(); - - glutInit( NULL, NULL ); - - window = __glutCreateWindow( GL_FALSE ); - if (!window) - return 0; - - __glutSetWindow( window ); - glutSetCursor( GLUT_CURSOR_INHERIT ); - - return window->id; -} - - -int GLUTAPIENTRY -glutCreateSubWindow( int win, int x, int y, int width, int height ) -{ - return GL_FALSE; -} - - -void GLUTAPIENTRY -glutDestroyWindow( int win ) -{ - __GlutWindow *cur; - - for (cur = g_stack; cur; cur = cur->next) { - if (cur->id == win) { - if (cur->window) - cur->window->Destroy( cur->window ); - - cur->req.flags |= WINDOW_REQUEST_DESTROY; - break; - } - } -} - - -void GLUTAPIENTRY -glutPostRedisplay( void ) -{ - if (g_current) - g_current->redisplay = GL_TRUE; -} - - -void GLUTAPIENTRY -glutPostWindowRedisplay( int win ) -{ - __GlutWindow *cur; - - for (cur = g_stack; cur; cur = cur->next) { - if (cur->id == win) { - cur->redisplay = GL_TRUE; - break; - } - } -} - - -void GLUTAPIENTRY -glutSwapBuffers( void ) -{ - if (g_current) { - g_current->gl->Unlock( g_current->gl ); - g_current->surface->Flip( g_current->surface, NULL, 0 ); - g_current->gl->Lock( g_current->gl ); - } -} - - -int GLUTAPIENTRY -glutGetWindow( void ) -{ - return (g_current) ? g_current->id : 0; -} - - -void GLUTAPIENTRY -glutSetWindow( int win ) -{ - __GlutWindow *cur; - - if (g_current && g_current->id == win) - return; - - for (cur = g_stack; cur; cur = cur->next) { - if (cur->id == win) { - __glutSetWindow( cur ); - break; - } - } -} - - -void GLUTAPIENTRY -glutSetWindowTitle( const char *title ) -{ -} - - -void GLUTAPIENTRY -glutSetIconTitle( const char *title ) -{ -} - - -void GLUTAPIENTRY -glutFullScreen( void ) -{ - if (g_current && !g_game) { - DFBDisplayLayerConfig config; - - primary->GetConfiguration( primary, &config ); - - g_current->req.flags |= WINDOW_REQUEST_POSITION | - WINDOW_REQUEST_RESIZE | - WINDOW_REQUEST_RESTACK; - g_current->req.x = 0; - g_current->req.y = 0; - g_current->req.w = config.width; - g_current->req.h = config.height; - g_current->req.z = 1000; - } -} - - -void GLUTAPIENTRY -glutPositionWindow( int x, int y ) -{ - if (g_current && !g_game) { - g_current->req.flags |= WINDOW_REQUEST_POSITION; - g_current->req.x = x; - g_current->req.y = y; - } -} - - -void GLUTAPIENTRY -glutReshapeWindow( int width, int height ) -{ - if (g_current && !g_game) { - g_current->req.flags |= WINDOW_REQUEST_RESIZE; - g_current->req.w = width; - g_current->req.h = height; - } -} - - -void GLUTAPIENTRY -glutPopWindow( void ) -{ - if (g_current && !g_game) { - g_current->req.flags |= WINDOW_REQUEST_RESTACK; - g_current->req.z--; - } -} - - -void GLUTAPIENTRY -glutPushWindow( void ) -{ - if (g_current && !g_game) { - g_current->req.flags |= WINDOW_REQUEST_RESTACK; - g_current->req.z++; - } -} - - -void GLUTAPIENTRY -glutIconifyWindow( void ) -{ -} - - -void GLUTAPIENTRY -glutShowWindow( void ) -{ - if (g_current && !g_game) { - g_current->req.flags |= WINDOW_REQUEST_SHOW; - g_current->req.flags &= ~WINDOW_REQUEST_HIDE; - } -} - - -void GLUTAPIENTRY -glutHideWindow( void ) -{ - if (g_current && !g_game) { - g_current->req.flags |= WINDOW_REQUEST_HIDE; - g_current->req.flags &= ~WINDOW_REQUEST_SHOW; - } -} - diff --git a/src/mesa/drivers/directfb/Makefile b/src/mesa/drivers/directfb/Makefile deleted file mode 100644 index 94c82a2c9c9..00000000000 --- a/src/mesa/drivers/directfb/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -# src/mesa/drivers/directfb/Makefile - -TOP = ../../../.. - -include $(TOP)/configs/current - - -INCLUDE_DIRS = \ - -I$(TOP)/include \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main \ - -I$(TOP)/src/mesa/glapi \ - -I$(TOP)/src/mesa/math \ - -I$(TOP)/src/mesa/tnl \ - -I$(TOP)/src/mesa/shader \ - -I$(TOP)/src/mesa/swrast \ - -I$(TOP)/src/mesa/swrast_setup - -DFB_CFLAGS = $(shell pkg-config --cflags directfb) -DFB_MODULEDIR = $(shell pkg-config --variable=moduledir directfb-internal) - -DIRECTFBGL_MESA_SOURCES = ../common/driverfuncs.c idirectfbgl_mesa.c - -DIRECTFBGL_MESA_OBJECTS = $(DIRECTFBGL_MESA_SOURCES:.c=.o) - -DIRECTFBGL_MESA = libidirectfbgl_mesa.so - -LIBS = $(TOP)/src/mesa/libmesa.a $(TOP)/src/mesa/libglapi.a - - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(DFB_CFLAGS) $< -o $@ - - -default: directfb-libgl directfbgl_mesa - - -# XXX this used to be in src/mesa/Makefile and is probably broken now -directfb-libgl: $(LIBS) - @ $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \ - -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) $(LIBS) \ - $(GL_LIB_DEPS) - - - -# Mesa DirectFBGL module -directfbgl_mesa: $(DIRECTFBGL_MESA_OBJECTS) - $(CC) -shared $(CFLAGS) $(DIRECTFBGL_MESA_OBJECTS) -o $(DIRECTFBGL_MESA) \ - -Wl,-soname -Wl,$(DIRECTFBGL_MESA) -L$(TOP)/$(LIB_DIR) -lGL -lm - - -install: - @if test -d $(DFB_MODULEDIR); then \ - echo "Installing DirectFBGL module."; \ - else \ - echo "*** Failed to determine DirectFB module's directory."; \ - echo "*** Installation aborted."; \ - exit 1; \ - fi; - test -d $(DFB_MODULEDIR)/interfaces/IDirectFBGL/ || mkdir $(DFB_MODULEDIR)/interfaces/IDirectFBGL/ - install -m 755 $(DIRECTFBGL_MESA) $(DFB_MODULEDIR)/interfaces/IDirectFBGL/ - - -clean: - -rm -f *.o *.so - diff --git a/src/mesa/drivers/directfb/idirectfbgl_mesa.c b/src/mesa/drivers/directfb/idirectfbgl_mesa.c deleted file mode 100644 index 85a6f036724..00000000000 --- a/src/mesa/drivers/directfb/idirectfbgl_mesa.c +++ /dev/null @@ -1,982 +0,0 @@ -/* - * Copyright (C) 2004-2007 Claudio Ciccani - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * Based on glfbdev.c, written by Brian Paul. - * - */ - -#include -#include -#include - -#include - -#include -#include - -#include - -#include -#include -#include - -#undef CLAMP -#include "main/glheader.h" -#include "main/buffers.h" -#include "main/context.h" -#include "main/extensions.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "main/imports.h" -#include "main/texformat.h" -#include "main/teximage.h" -#include "main/texstore.h" -#include "vbo/vbo.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" -#include "drivers/common/driverfuncs.h" - - -#define VERSION_CODE( M, m, r ) (((M) * 1000) + ((m) * 100) + ((r))) -#define DIRECTFB_VERSION_CODE VERSION_CODE( DIRECTFB_MAJOR_VERSION, \ - DIRECTFB_MINOR_VERSION, \ - DIRECTFB_MICRO_VERSION ) - - -static DFBResult -Probe( void *data ); - -static DFBResult -Construct( IDirectFBGL *thiz, - IDirectFBSurface *surface ); - -#include - -DIRECT_INTERFACE_IMPLEMENTATION( IDirectFBGL, Mesa ) - -/* - * private data struct of IDirectFBGL - */ -typedef struct { - int ref; /* reference counter */ - - int locked; - - IDirectFBSurface *surface; - DFBSurfacePixelFormat format; - int width; - int height; - - struct { - GLubyte *start; - GLubyte *end; - int pitch; - } video; - - GLvisual visual; - GLframebuffer framebuffer; - GLcontext context; - struct gl_renderbuffer render; -} IDirectFBGL_data; - -/******************************************************************************/ - -static pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER; -static unsigned int global_ref = 0; - -static INLINE int directfbgl_init( void ) -{ - pthread_mutexattr_t attr; - int ret; - - if (global_ref++) - return 0; - - pthread_mutexattr_init( &attr ); - pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK ); - ret = pthread_mutex_init( &global_lock, &attr ); - pthread_mutexattr_destroy( &attr ); - - return ret; -} - -static INLINE void directfbgl_finish( void ) -{ - if (--global_ref == 0) - pthread_mutex_destroy( &global_lock ); -} - -#define directfbgl_lock() pthread_mutex_lock( &global_lock ) -#define directfbgl_unlock() pthread_mutex_unlock( &global_lock ) - -/******************************************************************************/ - -static bool directfbgl_init_visual ( GLvisual *visual, - DFBSurfacePixelFormat format ); -static bool directfbgl_create_context ( GLcontext *context, - GLframebuffer *framebuffer, - GLvisual *visual, - IDirectFBGL_data *data ); -static void directfbgl_destroy_context( GLcontext *context, - GLframebuffer *framebuffer ); - -/******************************************************************************/ - - -static void -IDirectFBGL_Mesa_Destruct( IDirectFBGL *thiz ) -{ - IDirectFBGL_data *data = (IDirectFBGL_data*) thiz->priv; - - directfbgl_destroy_context( &data->context, &data->framebuffer ); - - if (data->surface) - data->surface->Release( data->surface ); - - DIRECT_DEALLOCATE_INTERFACE( thiz ); - - directfbgl_finish(); -} - -static DFBResult -IDirectFBGL_Mesa_AddRef( IDirectFBGL *thiz ) -{ - DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); - - data->ref++; - - return DFB_OK; -} - -static DFBResult -IDirectFBGL_Mesa_Release( IDirectFBGL *thiz ) -{ - DIRECT_INTERFACE_GET_DATA( IDirectFBGL ) - - if (--data->ref == 0) - IDirectFBGL_Mesa_Destruct( thiz ); - - return DFB_OK; -} - -static DFBResult -IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz ) -{ - IDirectFBSurface *surface; - int width = 0; - int height = 0; - DFBResult ret; - - DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); - - if (data->locked) { - data->locked++; - return DFB_OK; - } - - if (directfbgl_lock()) - return DFB_LOCKED; - - surface = data->surface; - surface->GetSize( surface, &width, &height ); - - ret = surface->Lock( surface, DSLF_READ | DSLF_WRITE, - (void*)&data->video.start, &data->video.pitch ); - if (ret) { - D_ERROR( "DirectFBGL/Mesa: couldn't lock surface.\n" ); - directfbgl_unlock(); - return ret; - } - data->video.end = data->video.start + (height-1) * data->video.pitch; - - data->render.Data = data->video.start; - - _mesa_make_current( &data->context, - &data->framebuffer, &data->framebuffer ); - - if (data->width != width || data->height != height) { - _mesa_resize_framebuffer( &data->context, - &data->framebuffer, width, height ); - data->width = width; - data->height = height; - } - - data->locked++; - - return DFB_OK; -} - -static DFBResult -IDirectFBGL_Mesa_Unlock( IDirectFBGL *thiz ) -{ - DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); - - if (!data->locked) - return DFB_OK; - - if (--data->locked == 0) { - _mesa_make_current( NULL, NULL, NULL ); - - data->surface->Unlock( data->surface ); - - directfbgl_unlock(); - } - - return DFB_OK; -} - -static DFBResult -IDirectFBGL_Mesa_GetAttributes( IDirectFBGL *thiz, - DFBGLAttributes *attributes ) -{ - DFBSurfaceCapabilities caps; - GLvisual *visual; - - DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); - - if (!attributes) - return DFB_INVARG; - - data->surface->GetCapabilities( data->surface, &caps ); - - visual = &data->visual; - - attributes->buffer_size = visual->rgbBits ? : visual->indexBits; - attributes->depth_size = visual->depthBits; - attributes->stencil_size = visual->stencilBits; - attributes->aux_buffers = visual->numAuxBuffers; - attributes->red_size = visual->redBits; - attributes->green_size = visual->greenBits; - attributes->blue_size = visual->blueBits; - attributes->alpha_size = visual->alphaBits; - attributes->accum_red_size = visual->accumRedBits; - attributes->accum_green_size = visual->accumGreenBits; - attributes->accum_blue_size = visual->accumBlueBits; - attributes->accum_alpha_size = visual->accumAlphaBits; - attributes->double_buffer = ((caps & DSCAPS_FLIPPING) != 0); - attributes->stereo = (visual->stereoMode != 0); - - return DFB_OK; -} - -#if DIRECTFBGL_INTERFACE_VERSION >= 1 -static DFBResult -IDirectFBGL_Mesa_GetProcAddress( IDirectFBGL *thiz, - const char *name, - void **ret_address ) -{ - DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); - - if (!name) - return DFB_INVARG; - - if (!ret_address) - return DFB_INVARG; - - *ret_address = _glapi_get_proc_address( name ); - - return (*ret_address) ? DFB_OK : DFB_UNSUPPORTED; -} -#endif - - -/* exported symbols */ - -static DFBResult -Probe( void *data ) -{ - return DFB_OK; -} - -static DFBResult -Construct( IDirectFBGL *thiz, IDirectFBSurface *surface ) -{ - DFBResult ret; - - /* Initialize global resources. */ - if (directfbgl_init()) - return DFB_INIT; - - /* Allocate interface data. */ - DIRECT_ALLOCATE_INTERFACE_DATA( thiz, IDirectFBGL ); - - /* Initialize interface data. */ - data->ref = 1; - - /* Duplicate destination surface. */ - ret = surface->GetSubSurface( surface, NULL, &data->surface ); - if (ret) { - IDirectFBGL_Mesa_Destruct( thiz ); - return ret; - } - - data->surface->GetPixelFormat( data->surface, &data->format ); - data->surface->GetSize( data->surface, &data->width, &data->height ); - - /* Configure visual. */ - if (!directfbgl_init_visual( &data->visual, data->format )) { - D_ERROR( "DirectFBGL/Mesa: failed to initialize visual.\n" ); - IDirectFBGL_Mesa_Destruct( thiz ); - return DFB_UNSUPPORTED; - } - - /* Create context. */ - if (!directfbgl_create_context( &data->context, - &data->framebuffer, - &data->visual, data )) { - D_ERROR( "DirectFBGL/Mesa: failed to create context.\n" ); - IDirectFBGL_Mesa_Destruct( thiz ); - return DFB_UNSUPPORTED; - } - - /* Assign interface pointers. */ - thiz->AddRef = IDirectFBGL_Mesa_AddRef; - thiz->Release = IDirectFBGL_Mesa_Release; - thiz->Lock = IDirectFBGL_Mesa_Lock; - thiz->Unlock = IDirectFBGL_Mesa_Unlock; - thiz->GetAttributes = IDirectFBGL_Mesa_GetAttributes; -#if DIRECTFBGL_INTERFACE_VERSION >= 1 - thiz->GetProcAddress = IDirectFBGL_Mesa_GetProcAddress; -#endif - - return DFB_OK; -} - - -/***************************** Driver functions ******************************/ - -static const GLubyte* -dfbGetString( GLcontext *ctx, GLenum pname ) -{ - return NULL; -} - -static void -dfbUpdateState( GLcontext *ctx, GLuint new_state ) -{ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); -} - -static void -dfbGetBufferSize( GLframebuffer *buffer, GLuint *width, GLuint *height ) -{ - GLcontext *ctx = _mesa_get_current_context(); - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; - - *width = (GLuint) data->width; - *height = (GLuint) data->height; -} - -/** - * We only implement this function as a mechanism to check if the - * framebuffer size has changed (and update corresponding state). - */ -static void -dfbSetViewport( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) -{ - /* Nothing to do (the surface can't be resized while it's locked). */ - return; -} - -static void -dfbClear( GLcontext *ctx, GLbitfield mask ) -{ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; - -#define BUFFER_BIT_MASK (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT | \ - BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT ) - if (mask & BUFFER_BIT_MASK && - ctx->Color.ColorMask[0][0] && - ctx->Color.ColorMask[0][1] && - ctx->Color.ColorMask[0][2] && - ctx->Color.ColorMask[0][3]) - { - DFBRegion clip; - GLubyte a, r, g, b; - - UNCLAMPED_FLOAT_TO_UBYTE( a, ctx->Color.ClearColor[ACOMP] ); - UNCLAMPED_FLOAT_TO_UBYTE( r, ctx->Color.ClearColor[RCOMP] ); - UNCLAMPED_FLOAT_TO_UBYTE( g, ctx->Color.ClearColor[GCOMP] ); - UNCLAMPED_FLOAT_TO_UBYTE( b, ctx->Color.ClearColor[BCOMP] ); - - clip.x1 = ctx->DrawBuffer->_Xmin; - clip.y1 = ctx->DrawBuffer->_Ymin; - clip.x2 = ctx->DrawBuffer->_Xmax - 1; - clip.y2 = ctx->DrawBuffer->_Ymax - 1; - data->surface->SetClip( data->surface, &clip ); - - data->surface->Unlock( data->surface ); - - data->surface->Clear( data->surface, r, g, b, a ); - - data->surface->Lock( data->surface, DSLF_READ | DSLF_WRITE, - (void*)&data->video.start, &data->video.pitch ); - data->video.end = data->video.start + (data->height-1) * data->video.pitch; - data->render.Data = data->video.start; - - mask &= ~BUFFER_BIT_MASK; - } -#undef BUFFER_BIT_MASK - - if (mask) - _swrast_Clear( ctx, mask ); -} - - -/************************ RenderBuffer functions *****************************/ - -static void -dfbDeleteRenderbuffer( struct gl_renderbuffer *render ) -{ - return; -} - -static GLboolean -dfbRenderbufferStorage( GLcontext *ctx, struct gl_renderbuffer *render, - GLenum internalFormat, GLuint width, GLuint height ) -{ - return GL_TRUE; -} - - -/***************************** Span functions ********************************/ - -/* RGB332 */ -#define NAME(PREFIX) PREFIX##_RGB332 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLubyte *P = data->video.end - (Y) * data->video.pitch + (X); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[RCOMP]) & 0xe0) ) | \ - (((S[GCOMP]) & 0xe0) >> 3) | \ - (((S[BCOMP]) ) >> 6) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0xe0) ); \ - D[GCOMP] = ((*P & 0x1c) << 3); \ - D[BCOMP] = ((*P & 0x03) << 6); \ - D[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - -/* ARGB4444 */ -#define NAME(PREFIX) PREFIX##_ARGB4444 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL_RGB(P, X, Y, S) \ - *P = ( 0xf000 | \ - (((S[RCOMP]) & 0xf0) << 4) | \ - (((S[GCOMP]) & 0xf0) ) | \ - (((S[BCOMP]) & 0xf0) >> 4) ) -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[ACOMP]) & 0xf0) << 8) | \ - (((S[RCOMP]) & 0xf0) << 4) | \ - (((S[GCOMP]) & 0xf0) ) | \ - (((S[BCOMP]) & 0xf0) >> 4) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x0f00) >> 4) | ((*P & 0x0f00) >> 8); \ - D[GCOMP] = ((*P & 0x00f0) ) | ((*P & 0x00f0) >> 4); \ - D[BCOMP] = ((*P & 0x000f) << 4) | ((*P & 0x000f) ); \ - D[ACOMP] = ((*P & 0xf000) >> 8) | ((*P & 0xf000) >> 12) - -#include "swrast/s_spantemp.h" - -/* RGB444 */ -#define NAME(PREFIX) PREFIX##_RGB444 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[RCOMP]) & 0xf0) << 4) | \ - (((S[GCOMP]) & 0xf0) ) | \ - (((S[BCOMP]) & 0xf0) >> 4) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x0f00) >> 4) | ((*P & 0x0f00) >> 8); \ - D[GCOMP] = ((*P & 0x00f0) ) | ((*P & 0x00f0) >> 4); \ - D[BCOMP] = ((*P & 0x000f) << 4) | ((*P & 0x000f) ); \ - D[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - -/* ARGB2554 */ -#define NAME(PREFIX) PREFIX##_ARGB2554 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL_RGB(P, X, Y, S) \ - *P = ( 0xc000 | \ - (((S[RCOMP]) & 0xf8) << 6) | \ - (((S[GCOMP]) & 0xf8) << 1) | \ - (((S[BCOMP]) & 0xf0) >> 4) ) -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[ACOMP]) & 0xc0) << 8) | \ - (((S[RCOMP]) & 0xf8) << 6) | \ - (((S[GCOMP]) & 0xf8) << 1) | \ - (((S[BCOMP]) & 0xf0) >> 4) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x3e00) >> 9); \ - D[GCOMP] = ((*P & 0x01f0) >> 4); \ - D[BCOMP] = ((*P & 0x000f) << 4); \ - D[ACOMP] = ((*P & 0xc000) >> 14) - -#include "swrast/s_spantemp.h" - -/* ARGB1555 */ -#define NAME(PREFIX) PREFIX##_ARGB1555 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL_RGB(P, X, Y, S) \ - *P = ( 0x8000 | \ - (((S[RCOMP]) & 0xf8) << 7) | \ - (((S[GCOMP]) & 0xf8) << 2) | \ - (((S[BCOMP]) ) >> 3) ) -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[ACOMP]) & 0x80) << 16) | \ - (((S[RCOMP]) & 0xf8) << 7) | \ - (((S[GCOMP]) & 0xf8) << 2) | \ - (((S[BCOMP]) ) >> 3) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x7c00) >> 7) | ((*P & 0x7c00) >> 12); \ - D[GCOMP] = ((*P & 0x03e0) >> 2) | ((*P & 0x03e0) >> 7); \ - D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) << 2); \ - D[ACOMP] = ((*P & 0x8000) ? 0xff : 0) - -#include "swrast/s_spantemp.h" - -/* RGB555 */ -#define NAME(PREFIX) PREFIX##_RGB555 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[RCOMP]) & 0xf8) << 7) | \ - (((S[GCOMP]) & 0xf8) << 2) | \ - (((S[BCOMP]) ) >> 3) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x7c00) >> 7) | ((*P & 0x7c00) >> 12); \ - D[GCOMP] = ((*P & 0x03e0) >> 2) | ((*P & 0x03e0) >> 7); \ - D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) << 2); \ - D[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - -/* RGB16 */ -#define NAME(PREFIX) PREFIX##_RGB16 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[RCOMP]) & 0xf8) << 8) | \ - (((S[GCOMP]) & 0xfc) << 3) | \ - (((S[BCOMP]) ) >> 3) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0xf800) >> 8) | ((*P & 0xf800) >> 13); \ - D[GCOMP] = ((*P & 0x07e0) >> 3) | ((*P & 0x07e0) >> 9); \ - D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) >> 2); \ - D[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - -/* RGB24 */ -#define NAME(PREFIX) PREFIX##_RGB24 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLubyte *P = data->video.end - (Y) * data->video.pitch + (X) * 3; -#define INC_PIXEL_PTR(P) P += 3 -#define STORE_PIXEL(P, X, Y, S) \ - P[0] = S[BCOMP]; P[1] = S[GCOMP]; P[2] = S[BCOMP] -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = P[2]; D[GCOMP] = P[1]; D[BCOMP] = P[0]; D[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - -/* RGB32 */ -#define NAME(PREFIX) PREFIX##_RGB32 -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( ((S[RCOMP]) << 16) | \ - ((S[GCOMP]) << 8) | \ - ((S[BCOMP]) ) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x00ff0000) >> 16); \ - D[GCOMP] = ((*P & 0x0000ff00) >> 8); \ - D[BCOMP] = ((*P & 0x000000ff) ); \ - D[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - -/* ARGB */ -#define NAME(PREFIX) PREFIX##_ARGB -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL_RGB(P, X, Y, S) \ - *P = ( 0xff000000 | \ - ((S[RCOMP]) << 16) | \ - ((S[GCOMP]) << 8) | \ - ((S[BCOMP]) ) ) -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( ((S[ACOMP]) << 24) | \ - ((S[RCOMP]) << 16) | \ - ((S[GCOMP]) << 8) | \ - ((S[BCOMP]) ) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x00ff0000) >> 16); \ - D[GCOMP] = ((*P & 0x0000ff00) >> 8); \ - D[BCOMP] = ((*P & 0x000000ff) ); \ - D[ACOMP] = ((*P & 0xff000000) >> 24) - -#include "swrast/s_spantemp.h" - -/* AiRGB */ -#define NAME(PREFIX) PREFIX##_AiRGB -#define FORMAT GL_RGBA8 -#define RB_TYPE GLubyte -#define SPAN_VARS \ - IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL_RGB(P, X, Y, S) \ - *P = ( ((S[RCOMP]) << 16) | \ - ((S[GCOMP]) << 8) | \ - ((S[BCOMP]) ) ) -#define STORE_PIXEL(P, X, Y, S) \ - *P = ( (((S[ACOMP]) ^ 0xff) << 24) | \ - (((S[RCOMP]) ) << 16) | \ - (((S[GCOMP]) ) << 8) | \ - (((S[BCOMP]) ) ) ) -#define FETCH_PIXEL(D, P) \ - D[RCOMP] = ((*P & 0x00ff0000) >> 16); \ - D[GCOMP] = ((*P & 0x0000ff00) >> 8); \ - D[BCOMP] = ((*P & 0x000000ff) ); \ - D[ACOMP] = (((*P & 0xff000000) >> 24) ^ 0xff) - -#include "swrast/s_spantemp.h" - - -/*****************************************************************************/ - -static bool -directfbgl_init_visual( GLvisual *visual, - DFBSurfacePixelFormat format ) -{ - GLboolean rgbFlag = GL_TRUE; - GLboolean dbFlag = GL_FALSE; - GLboolean stereoFlag = GL_FALSE; - GLint redBits = 0; - GLint blueBits = 0; - GLint greenBits = 0; - GLint alphaBits = 0; - GLint indexBits = 0; - GLint depthBits = 0; - GLint stencilBits = 0; - GLint accumRedBits = 0; - GLint accumGreenBits = 0; - GLint accumBlueBits = 0; - GLint accumAlphaBits = 0; - GLint numSamples = 0; - - /* FIXME: LUT8 support. */ - switch (format) { - case DSPF_RGB332: - redBits = 3; - greenBits = 3; - blueBits = 2; - break; - case DSPF_ARGB4444: - alphaBits = 4; - case DSPF_RGB444: - redBits = 4; - greenBits = 4; - blueBits = 4; - break; - case DSPF_ARGB2554: - alphaBits = 2; - redBits = 5; - greenBits = 5; - blueBits = 4; - break; - case DSPF_ARGB1555: - alphaBits = 1; - case DSPF_RGB555: - redBits = 5; - greenBits = 5; - blueBits = 5; - break; - case DSPF_RGB16: - redBits = 5; - greenBits = 6; - blueBits = 5; - break; - case DSPF_ARGB: - case DSPF_AiRGB: - alphaBits = 8; - case DSPF_RGB24: - case DSPF_RGB32: - redBits = 8; - greenBits = 8; - blueBits = 8; - break; - default: - D_WARN( "unsupported pixelformat" ); - return false; - } - - if (rgbFlag) { - accumRedBits = redBits; - accumGreenBits = greenBits; - accumBlueBits = blueBits; - accumAlphaBits = alphaBits; - depthBits = redBits + greenBits + blueBits; - stencilBits = alphaBits; - } else - depthBits = 8; - - return _mesa_initialize_visual( visual, - rgbFlag, dbFlag, stereoFlag, - redBits, greenBits, blueBits, alphaBits, - indexBits, depthBits, stencilBits, - accumRedBits, accumGreenBits, - accumBlueBits, accumAlphaBits, - numSamples ); -} - -static bool -directfbgl_create_context( GLcontext *context, - GLframebuffer *framebuffer, - GLvisual *visual, - IDirectFBGL_data *data ) -{ - struct dd_function_table functions; - - _mesa_initialize_window_framebuffer( framebuffer, visual ); - - _mesa_init_driver_functions( &functions ); - functions.GetString = dfbGetString; - functions.UpdateState = dfbUpdateState; - functions.GetBufferSize = dfbGetBufferSize; - functions.Viewport = dfbSetViewport; - functions.Clear = dfbClear; - - if (!_mesa_initialize_context( context, visual, NULL, - &functions, (void*) data )) { - D_DEBUG( "DirectFBGL/Mesa: _mesa_initialize_context() failed.\n" ); - _mesa_free_framebuffer_data( framebuffer ); - return false; - } - - _swrast_CreateContext( context ); - _vbo_CreateContext( context ); - _tnl_CreateContext( context ); - _swsetup_CreateContext( context ); - _swsetup_Wakeup( context ); - - _mesa_init_renderbuffer( &data->render, 0 ); - data->render.InternalFormat = GL_RGBA; - data->render._BaseFormat = GL_RGBA; - data->render.DataType = GL_UNSIGNED_BYTE; - data->render.Data = data->video.start; - data->render.Delete = dfbDeleteRenderbuffer; - data->render.AllocStorage = dfbRenderbufferStorage; - - switch (data->format) { - case DSPF_RGB332: - data->render.GetRow = get_row_RGB332; - data->render.GetValues = get_values_RGB332; - data->render.PutRow = put_row_RGB332; - data->render.PutRowRGB = put_row_rgb_RGB332; - data->render.PutMonoRow = put_mono_row_RGB332; - data->render.PutValues = put_values_RGB332; - data->render.PutMonoValues = put_mono_values_RGB332; - break; - case DSPF_ARGB4444: - data->render.GetRow = get_row_ARGB4444; - data->render.GetValues = get_values_ARGB4444; - data->render.PutRow = put_row_ARGB4444; - data->render.PutRowRGB = put_row_rgb_ARGB4444; - data->render.PutMonoRow = put_mono_row_ARGB4444; - data->render.PutValues = put_values_ARGB4444; - data->render.PutMonoValues = put_mono_values_ARGB4444; - break; - case DSPF_RGB444: - data->render.GetRow = get_row_RGB444; - data->render.GetValues = get_values_RGB444; - data->render.PutRow = put_row_RGB444; - data->render.PutRowRGB = put_row_rgb_RGB444; - data->render.PutMonoRow = put_mono_row_RGB444; - data->render.PutValues = put_values_RGB444; - data->render.PutMonoValues = put_mono_values_RGB444; - break; - case DSPF_ARGB2554: - data->render.GetRow = get_row_ARGB2554; - data->render.GetValues = get_values_ARGB2554; - data->render.PutRow = put_row_ARGB2554; - data->render.PutRowRGB = put_row_rgb_ARGB2554; - data->render.PutMonoRow = put_mono_row_ARGB2554; - data->render.PutValues = put_values_ARGB2554; - data->render.PutMonoValues = put_mono_values_ARGB2554; - break; - case DSPF_ARGB1555: - data->render.GetRow = get_row_ARGB1555; - data->render.GetValues = get_values_ARGB1555; - data->render.PutRow = put_row_ARGB1555; - data->render.PutRowRGB = put_row_rgb_ARGB1555; - data->render.PutMonoRow = put_mono_row_ARGB1555; - data->render.PutValues = put_values_ARGB1555; - data->render.PutMonoValues = put_mono_values_ARGB1555; - break; - case DSPF_RGB555: - data->render.GetRow = get_row_RGB555; - data->render.GetValues = get_values_RGB555; - data->render.PutRow = put_row_RGB555; - data->render.PutRowRGB = put_row_rgb_RGB555; - data->render.PutMonoRow = put_mono_row_RGB555; - data->render.PutValues = put_values_RGB555; - data->render.PutMonoValues = put_mono_values_RGB555; - break; - case DSPF_RGB16: - data->render.GetRow = get_row_RGB16; - data->render.GetValues = get_values_RGB16; - data->render.PutRow = put_row_RGB16; - data->render.PutRowRGB = put_row_rgb_RGB16; - data->render.PutMonoRow = put_mono_row_RGB16; - data->render.PutValues = put_values_RGB16; - data->render.PutMonoValues = put_mono_values_RGB16; - break; - case DSPF_RGB24: - data->render.GetRow = get_row_RGB24; - data->render.GetValues = get_values_RGB24; - data->render.PutRow = put_row_RGB24; - data->render.PutRowRGB = put_row_rgb_RGB24; - data->render.PutMonoRow = put_mono_row_RGB24; - data->render.PutValues = put_values_RGB24; - data->render.PutMonoValues = put_mono_values_RGB24; - break; - case DSPF_RGB32: - data->render.GetRow = get_row_RGB32; - data->render.GetValues = get_values_RGB32; - data->render.PutRow = put_row_RGB32; - data->render.PutRowRGB = put_row_rgb_RGB32; - data->render.PutMonoRow = put_mono_row_RGB32; - data->render.PutValues = put_values_RGB32; - data->render.PutMonoValues = put_mono_values_RGB32; - break; - case DSPF_ARGB: - data->render.GetRow = get_row_ARGB; - data->render.GetValues = get_values_ARGB; - data->render.PutRow = put_row_ARGB; - data->render.PutRowRGB = put_row_rgb_ARGB; - data->render.PutMonoRow = put_mono_row_ARGB; - data->render.PutValues = put_values_ARGB; - data->render.PutMonoValues = put_mono_values_ARGB; - break; - case DSPF_AiRGB: - data->render.GetRow = get_row_AiRGB; - data->render.GetValues = get_values_AiRGB; - data->render.PutRow = put_row_AiRGB; - data->render.PutRowRGB = put_row_rgb_AiRGB; - data->render.PutMonoRow = put_mono_row_AiRGB; - data->render.PutValues = put_values_AiRGB; - data->render.PutMonoValues = put_mono_values_AiRGB; - break; - default: - D_BUG( "unexpected pixelformat" ); - return false; - } - - data->render.Width = data->width; - data->render.Height = data->height; - - _mesa_add_renderbuffer( framebuffer, BUFFER_FRONT_LEFT, &data->render ); - - _mesa_add_soft_renderbuffers( framebuffer, - GL_FALSE, - visual->haveDepthBuffer, - visual->haveStencilBuffer, - visual->haveAccumBuffer, - GL_FALSE, - GL_FALSE ); - - TNL_CONTEXT( context )->Driver.RunPipeline = _tnl_run_pipeline; - - _mesa_enable_sw_extensions( context ); - - return true; -} - -static void -directfbgl_destroy_context( GLcontext *context, - GLframebuffer *framebuffer ) -{ - _swsetup_DestroyContext( context ); - _swrast_DestroyContext( context ); - _tnl_DestroyContext( context ); - _vbo_DestroyContext( context ); - //_mesa_free_framebuffer_data( framebuffer ); - _mesa_free_context_data( context ); -} - -- cgit v1.2.3 From 79aeafd3ca3680c28f6d47a21a501334844f4475 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 25 Feb 2010 16:12:58 -0500 Subject: Drop fb, ffb and gamma dri drivers --- configure.ac | 13 +- src/mesa/drivers/dri/fb/Doxyfile | 232 - src/mesa/drivers/dri/fb/Makefile | 24 - src/mesa/drivers/dri/fb/fb_dri.c | 792 --- src/mesa/drivers/dri/ffb/Makefile | 35 - src/mesa/drivers/dri/ffb/ffb_bitmap.c | 158 - src/mesa/drivers/dri/ffb/ffb_bitmap.h | 7 - src/mesa/drivers/dri/ffb/ffb_clear.c | 335 -- src/mesa/drivers/dri/ffb/ffb_clear.h | 6 - src/mesa/drivers/dri/ffb/ffb_context.h | 305 -- src/mesa/drivers/dri/ffb/ffb_dd.c | 115 - src/mesa/drivers/dri/ffb/ffb_dd.h | 36 - src/mesa/drivers/dri/ffb/ffb_depth.c | 243 - src/mesa/drivers/dri/ffb/ffb_depth.h | 7 - src/mesa/drivers/dri/ffb/ffb_fifo.h | 27 - src/mesa/drivers/dri/ffb/ffb_fog.c | 73 - src/mesa/drivers/dri/ffb/ffb_lines.c | 107 - src/mesa/drivers/dri/ffb/ffb_lines.h | 17 - src/mesa/drivers/dri/ffb/ffb_linetmp.h | 80 - src/mesa/drivers/dri/ffb/ffb_lock.h | 36 - src/mesa/drivers/dri/ffb/ffb_points.c | 91 - src/mesa/drivers/dri/ffb/ffb_points.h | 14 - src/mesa/drivers/dri/ffb/ffb_pointtmp.h | 54 - src/mesa/drivers/dri/ffb/ffb_rendertmp.h | 645 --- src/mesa/drivers/dri/ffb/ffb_span.c | 127 - src/mesa/drivers/dri/ffb/ffb_span.h | 9 - src/mesa/drivers/dri/ffb/ffb_state.c | 1222 ----- src/mesa/drivers/dri/ffb/ffb_state.h | 12 - src/mesa/drivers/dri/ffb/ffb_stencil.c | 224 - src/mesa/drivers/dri/ffb/ffb_stencil.h | 7 - src/mesa/drivers/dri/ffb/ffb_tex.c | 35 - src/mesa/drivers/dri/ffb/ffb_tex.h | 34 - src/mesa/drivers/dri/ffb/ffb_tris.c | 945 ---- src/mesa/drivers/dri/ffb/ffb_tris.h | 25 - src/mesa/drivers/dri/ffb/ffb_tritmp.h | 238 - src/mesa/drivers/dri/ffb/ffb_vb.c | 207 - src/mesa/drivers/dri/ffb/ffb_vb.h | 44 - src/mesa/drivers/dri/ffb/ffb_vbtmp.h | 150 - src/mesa/drivers/dri/ffb/ffb_vtxfmt.c | 414 -- src/mesa/drivers/dri/ffb/ffb_vtxfmt.h | 7 - src/mesa/drivers/dri/ffb/ffb_xmesa.c | 729 --- src/mesa/drivers/dri/ffb/ffb_xmesa.h | 25 - src/mesa/drivers/dri/ffb/server/ffb_dac.h | 366 -- src/mesa/drivers/dri/ffb/server/ffb_drishare.h | 47 - src/mesa/drivers/dri/ffb/server/ffb_regs.h | 508 -- src/mesa/drivers/dri/gamma/Makefile | 34 - src/mesa/drivers/dri/gamma/gamma_client.h | 6184 ---------------------- src/mesa/drivers/dri/gamma/gamma_context.c | 229 - src/mesa/drivers/dri/gamma/gamma_context.h | 401 -- src/mesa/drivers/dri/gamma/gamma_dd.c | 110 - src/mesa/drivers/dri/gamma/gamma_inithw.c | 551 -- src/mesa/drivers/dri/gamma/gamma_lock.c | 60 - src/mesa/drivers/dri/gamma/gamma_lock.h | 84 - src/mesa/drivers/dri/gamma/gamma_macros.h | 323 -- src/mesa/drivers/dri/gamma/gamma_regs.h | 658 --- src/mesa/drivers/dri/gamma/gamma_render.c | 221 - src/mesa/drivers/dri/gamma/gamma_screen.c | 147 - src/mesa/drivers/dri/gamma/gamma_screen.h | 30 - src/mesa/drivers/dri/gamma/gamma_span.c | 315 -- src/mesa/drivers/dri/gamma/gamma_state.c | 1721 ------ src/mesa/drivers/dri/gamma/gamma_tex.c | 434 -- src/mesa/drivers/dri/gamma/gamma_texmem.c | 535 -- src/mesa/drivers/dri/gamma/gamma_texstate.c | 215 - src/mesa/drivers/dri/gamma/gamma_tris.c | 660 --- src/mesa/drivers/dri/gamma/gamma_tris.h | 36 - src/mesa/drivers/dri/gamma/gamma_tritmp.h | 496 -- src/mesa/drivers/dri/gamma/gamma_vb.c | 361 -- src/mesa/drivers/dri/gamma/gamma_vb.h | 60 - src/mesa/drivers/dri/gamma/gamma_xmesa.c | 273 - src/mesa/drivers/dri/gamma/server/glint_common.h | 63 - src/mesa/drivers/dri/gamma/server/glint_dri.h | 122 - 71 files changed, 5 insertions(+), 23145 deletions(-) delete mode 100644 src/mesa/drivers/dri/fb/Doxyfile delete mode 100644 src/mesa/drivers/dri/fb/Makefile delete mode 100644 src/mesa/drivers/dri/fb/fb_dri.c delete mode 100644 src/mesa/drivers/dri/ffb/Makefile delete mode 100644 src/mesa/drivers/dri/ffb/ffb_bitmap.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_bitmap.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_clear.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_clear.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_context.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_dd.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_dd.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_depth.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_depth.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_fifo.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_fog.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_lines.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_lines.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_linetmp.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_lock.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_points.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_points.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_pointtmp.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_rendertmp.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_span.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_span.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_state.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_state.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_stencil.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_stencil.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_tex.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_tex.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_tris.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_tris.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_tritmp.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_vb.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_vb.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_vbtmp.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_vtxfmt.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_vtxfmt.h delete mode 100644 src/mesa/drivers/dri/ffb/ffb_xmesa.c delete mode 100644 src/mesa/drivers/dri/ffb/ffb_xmesa.h delete mode 100644 src/mesa/drivers/dri/ffb/server/ffb_dac.h delete mode 100644 src/mesa/drivers/dri/ffb/server/ffb_drishare.h delete mode 100644 src/mesa/drivers/dri/ffb/server/ffb_regs.h delete mode 100644 src/mesa/drivers/dri/gamma/Makefile delete mode 100644 src/mesa/drivers/dri/gamma/gamma_client.h delete mode 100644 src/mesa/drivers/dri/gamma/gamma_context.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_context.h delete mode 100644 src/mesa/drivers/dri/gamma/gamma_dd.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_inithw.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_lock.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_lock.h delete mode 100644 src/mesa/drivers/dri/gamma/gamma_macros.h delete mode 100644 src/mesa/drivers/dri/gamma/gamma_regs.h delete mode 100644 src/mesa/drivers/dri/gamma/gamma_render.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_screen.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_screen.h delete mode 100644 src/mesa/drivers/dri/gamma/gamma_span.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_state.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_tex.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_texmem.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_texstate.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_tris.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_tris.h delete mode 100644 src/mesa/drivers/dri/gamma/gamma_tritmp.h delete mode 100644 src/mesa/drivers/dri/gamma/gamma_vb.c delete mode 100644 src/mesa/drivers/dri/gamma/gamma_vb.h delete mode 100644 src/mesa/drivers/dri/gamma/gamma_xmesa.c delete mode 100644 src/mesa/drivers/dri/gamma/server/glint_common.h delete mode 100644 src/mesa/drivers/dri/gamma/server/glint_dri.h (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index b4561000d22..d108ecdad29 100644 --- a/configure.ac +++ b/configure.ac @@ -720,10 +720,9 @@ if test "$mesa_driver" = dri; then case "$host_cpu" in x86_64) - # ffb, gamma, and sis are missing because they have not be - # converted to use the new interface. i810 are missing - # because there is no x86-64 system where they could *ever* - # be used. + # sis is missing because they have not be converted to use + # the new interface. i810 are missing because there is no + # x86-64 system where they could *ever* be used. if test "x$DRI_DIRS" = "xyes"; then DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 r600 radeon \ savage tdfx unichrome swrast" @@ -739,7 +738,7 @@ if test "$mesa_driver" = dri; then sparc*) # Build only the drivers for cards that exist on sparc` if test "x$DRI_DIRS" = "xyes"; then - DRI_DIRS="mach64 r128 r200 r300 r600 radeon ffb swrast" + DRI_DIRS="mach64 r128 r200 r300 r600 radeon swrast" fi ;; esac @@ -755,8 +754,6 @@ if test "$mesa_driver" = dri; then CXXFLAGS="$CXXFLAGS -ansi -pedantic" fi - # ffb and gamma are missing because they have not been converted - # to use the new interface. if test "x$DRI_DIRS" = "xyes"; then DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon tdfx \ unichrome savage sis swrast" @@ -778,7 +775,7 @@ if test "$mesa_driver" = dri; then # default drivers if test "x$DRI_DIRS" = "xyes"; then DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \ - savage sis tdfx unichrome ffb swrast" + savage sis tdfx unichrome swrast" fi DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'` diff --git a/src/mesa/drivers/dri/fb/Doxyfile b/src/mesa/drivers/dri/fb/Doxyfile deleted file mode 100644 index 31256db834a..00000000000 --- a/src/mesa/drivers/dri/fb/Doxyfile +++ /dev/null @@ -1,232 +0,0 @@ -# Doxyfile 1.3.2-Gideon - -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = fb -PROJECT_NUMBER = $VERSION$ -OUTPUT_DIRECTORY = -OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = NO -EXTRACT_ALL = NO -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = NO -EXTRACT_LOCAL_CLASSES = YES -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = YES -SHORT_NAMES = NO -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -JAVADOC_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 8 -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ALIASES = -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -SHOW_USED_FILES = YES -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = /home/temp/Mesa/src/drv/fb -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.C \ - *.H \ - *.tlh \ - *.diff \ - *.patch \ - *.moc \ - *.xpm -RECURSIVE = yes -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = * -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -VERBATIM_HEADERS = YES -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = NO -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = YES -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = yes -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = NO -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -UML_LOOK = NO -TEMPLATE_RELATIONS = NO -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = NO -GRAPHICAL_HIERARCHY = YES -DOT_IMAGE_FORMAT = png -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -MAX_DOT_GRAPH_DEPTH = 1000 -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO -CGI_NAME = search.cgi -CGI_URL = -DOC_URL = -DOC_ABSPATH = -BIN_ABSPATH = /usr/local/bin/ -EXT_DOC_PATHS = diff --git a/src/mesa/drivers/dri/fb/Makefile b/src/mesa/drivers/dri/fb/Makefile deleted file mode 100644 index 848e2041e27..00000000000 --- a/src/mesa/drivers/dri/fb/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# src/mesa/drivers/dri/fb/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = fb_dri.so - - -DRIVER_SOURCES = \ - fb_dri.c \ - $(EGL_SOURCES) - - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - -# XXX not 100% sure this is right -#WINDOW_SYSTEM = solo - -include ../Makefile.template - diff --git a/src/mesa/drivers/dri/fb/fb_dri.c b/src/mesa/drivers/dri/fb/fb_dri.c deleted file mode 100644 index ac07e57db13..00000000000 --- a/src/mesa/drivers/dri/fb/fb_dri.c +++ /dev/null @@ -1,792 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* Minimal swrast-based dri loadable driver. - * - * Todo: - * -- Use malloced (rather than framebuffer) memory for backbuffer - * -- 32bpp is hardwared -- fix - * - * NOTES: - * -- No mechanism for cliprects or resize notification -- - * assumes this is a fullscreen device. - * -- No locking -- assumes this is the only driver accessing this - * device. - * -- Doesn't (yet) make use of any acceleration or other interfaces - * provided by fb. Would be entirely happy working against any - * fullscreen interface. - * -- HOWEVER: only a small number of pixelformats are supported, and - * the mechanism for choosing between them makes some assumptions - * that may not be valid everywhere. - */ - -#include "driver.h" -#include "drm.h" -#include "utils.h" -#include "drirenderbuffer.h" - -#include "buffers.h" -#include "main/extensions.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "vbo/vbo.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/tcontext.h" -#include "tnl/t_pipeline.h" -#include "drivers/common/driverfuncs.h" - -void fbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis); - -typedef struct { - GLcontext *glCtx; /* Mesa context */ - - struct { - __DRIcontext *context; - __DRIscreen *screen; - __DRIdrawable *drawable; /* drawable bound to this ctx */ - } dri; - -} fbContext, *fbContextPtr; - -#define FB_CONTEXT(ctx) ((fbContextPtr)(ctx->DriverCtx)) - - -static const GLubyte * -get_string(GLcontext *ctx, GLenum pname) -{ - (void) ctx; - switch (pname) { - case GL_RENDERER: - return (const GLubyte *) "Mesa dumb framebuffer"; - default: - return NULL; - } -} - - -static void -update_state( GLcontext *ctx, GLuint new_state ) -{ - /* not much to do here - pass it on */ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); -} - - -/** - * Called by ctx->Driver.GetBufferSize from in core Mesa to query the - * current framebuffer size. - */ -static void -get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height ) -{ - GET_CURRENT_CONTEXT(ctx); - fbContextPtr fbmesa = FB_CONTEXT(ctx); - - *width = fbmesa->dri.drawable->w; - *height = fbmesa->dri.drawable->h; -} - - -static void -updateFramebufferSize(GLcontext *ctx) -{ - fbContextPtr fbmesa = FB_CONTEXT(ctx); - struct gl_framebuffer *fb = ctx->WinSysDrawBuffer; - if (fbmesa->dri.drawable->w != fb->Width || - fbmesa->dri.drawable->h != fb->Height) { - driUpdateFramebufferSize(ctx, fbmesa->dri.drawable); - } -} - -static void -viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) -{ - /* XXX this should be called after we acquire the DRI lock, not here */ - updateFramebufferSize(ctx); -} - - -static void -init_core_functions( struct dd_function_table *functions ) -{ - functions->GetString = get_string; - functions->UpdateState = update_state; - functions->GetBufferSize = get_buffer_size; - functions->Viewport = viewport; - - functions->Clear = _swrast_Clear; /* could accelerate with blits */ -} - - -/* - * Generate code for span functions. - */ - -/* 24-bit BGR */ -#define NAME(PREFIX) PREFIX##_B8G8R8 -#define FORMAT GL_RGBA8 -#define SPAN_VARS \ - driRenderbuffer *drb = (driRenderbuffer *) rb; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLubyte *P = (GLubyte *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X) * 3; -#define INC_PIXEL_PTR(P) P += 3 -#define STORE_PIXEL(DST, X, Y, VALUE) \ - DST[0] = VALUE[BCOMP]; \ - DST[1] = VALUE[GCOMP]; \ - DST[2] = VALUE[RCOMP] -#define FETCH_PIXEL(DST, SRC) \ - DST[RCOMP] = SRC[2]; \ - DST[GCOMP] = SRC[1]; \ - DST[BCOMP] = SRC[0]; \ - DST[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - - -/* 32-bit BGRA */ -#define NAME(PREFIX) PREFIX##_B8G8R8A8 -#define FORMAT GL_RGBA8 -#define SPAN_VARS \ - driRenderbuffer *drb = (driRenderbuffer *) rb; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLubyte *P = (GLubyte *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X) * 4; -#define INC_PIXEL_PTR(P) P += 4 -#define STORE_PIXEL(DST, X, Y, VALUE) \ - DST[0] = VALUE[BCOMP]; \ - DST[1] = VALUE[GCOMP]; \ - DST[2] = VALUE[RCOMP]; \ - DST[3] = VALUE[ACOMP] -#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ - DST[0] = VALUE[BCOMP]; \ - DST[1] = VALUE[GCOMP]; \ - DST[2] = VALUE[RCOMP]; \ - DST[3] = 0xff -#define FETCH_PIXEL(DST, SRC) \ - DST[RCOMP] = SRC[2]; \ - DST[GCOMP] = SRC[1]; \ - DST[BCOMP] = SRC[0]; \ - DST[ACOMP] = SRC[3] - -#include "swrast/s_spantemp.h" - - -/* 16-bit BGR (XXX implement dithering someday) */ -#define NAME(PREFIX) PREFIX##_B5G6R5 -#define FORMAT GL_RGBA8 -#define SPAN_VARS \ - driRenderbuffer *drb = (driRenderbuffer *) rb; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X) * 2; -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(DST, X, Y, VALUE) \ - DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 8) | (((VALUE[GCOMP]) & 0xfc) << 3) | ((VALUE[BCOMP]) >> 3) ) -#define FETCH_PIXEL(DST, SRC) \ - DST[RCOMP] = ( (((SRC[0]) >> 8) & 0xf8) | (((SRC[0]) >> 11) & 0x7) ); \ - DST[GCOMP] = ( (((SRC[0]) >> 3) & 0xfc) | (((SRC[0]) >> 5) & 0x3) ); \ - DST[BCOMP] = ( (((SRC[0]) << 3) & 0xf8) | (((SRC[0]) ) & 0x7) ); \ - DST[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - - -/* 15-bit BGR (XXX implement dithering someday) */ -#define NAME(PREFIX) PREFIX##_B5G5R5 -#define FORMAT GL_RGBA8 -#define SPAN_VARS \ - driRenderbuffer *drb = (driRenderbuffer *) rb; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLushort *P = (GLushort *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X) * 2; -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(DST, X, Y, VALUE) \ - DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 7) | (((VALUE[GCOMP]) & 0xf8) << 2) | ((VALUE[BCOMP]) >> 3) ) -#define FETCH_PIXEL(DST, SRC) \ - DST[RCOMP] = ( (((SRC[0]) >> 7) & 0xf8) | (((SRC[0]) >> 10) & 0x7) ); \ - DST[GCOMP] = ( (((SRC[0]) >> 2) & 0xf8) | (((SRC[0]) >> 5) & 0x7) ); \ - DST[BCOMP] = ( (((SRC[0]) << 3) & 0xf8) | (((SRC[0]) ) & 0x7) ); \ - DST[ACOMP] = 0xff - -#include "swrast/s_spantemp.h" - - -/* 8-bit color index */ -#define NAME(PREFIX) PREFIX##_CI8 -#define FORMAT GL_COLOR_INDEX8_EXT -#define SPAN_VARS \ - driRenderbuffer *drb = (driRenderbuffer *) rb; -#define INIT_PIXEL_PTR(P, X, Y) \ - GLubyte *P = (GLubyte *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X); -#define INC_PIXEL_PTR(P) P += 1 -#define STORE_PIXEL(DST, X, Y, VALUE) \ - *DST = VALUE[0] -#define FETCH_PIXEL(DST, SRC) \ - DST = SRC[0] - -#include "swrast/s_spantemp.h" - - - -void -fbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis) -{ - ASSERT(drb->Base.InternalFormat == GL_RGBA); - if (drb->Base.InternalFormat == GL_RGBA) { - if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) { - drb->Base.GetRow = get_row_B5G6R5; - drb->Base.GetValues = get_values_B5G6R5; - drb->Base.PutRow = put_row_B5G6R5; - drb->Base.PutMonoRow = put_mono_row_B5G6R5; - drb->Base.PutRowRGB = put_row_rgb_B5G6R5; - drb->Base.PutValues = put_values_B5G6R5; - drb->Base.PutMonoValues = put_mono_values_B5G6R5; - } - else if (vis->redBits == 5 && vis->greenBits == 5 && vis->blueBits == 5) { - drb->Base.GetRow = get_row_B5G5R5; - drb->Base.GetValues = get_values_B5G5R5; - drb->Base.PutRow = put_row_B5G5R5; - drb->Base.PutMonoRow = put_mono_row_B5G5R5; - drb->Base.PutRowRGB = put_row_rgb_B5G5R5; - drb->Base.PutValues = put_values_B5G5R5; - drb->Base.PutMonoValues = put_mono_values_B5G5R5; - } - else if (vis->redBits == 8 && vis->greenBits == 8 && vis->blueBits == 8 - && vis->alphaBits == 8) { - drb->Base.GetRow = get_row_B8G8R8A8; - drb->Base.GetValues = get_values_B8G8R8A8; - drb->Base.PutRow = put_row_B8G8R8A8; - drb->Base.PutMonoRow = put_mono_row_B8G8R8A8; - drb->Base.PutRowRGB = put_row_rgb_B8G8R8A8; - drb->Base.PutValues = put_values_B8G8R8A8; - drb->Base.PutMonoValues = put_mono_values_B8G8R8A8; - } - else if (vis->redBits == 8 && vis->greenBits == 8 && vis->blueBits == 8 - && vis->alphaBits == 0) { - drb->Base.GetRow = get_row_B8G8R8; - drb->Base.GetValues = get_values_B8G8R8; - drb->Base.PutRow = put_row_B8G8R8; - drb->Base.PutMonoRow = put_mono_row_B8G8R8; - drb->Base.PutRowRGB = put_row_rgb_B8G8R8; - drb->Base.PutValues = put_values_B8G8R8; - drb->Base.PutMonoValues = put_mono_values_B8G8R8; - } - else if (vis->indexBits == 8) { - drb->Base.GetRow = get_row_CI8; - drb->Base.GetValues = get_values_CI8; - drb->Base.PutRow = put_row_CI8; - drb->Base.PutMonoRow = put_mono_row_CI8; - drb->Base.PutValues = put_values_CI8; - drb->Base.PutMonoValues = put_mono_values_CI8; - } - } - else { - /* hardware z/stencil/etc someday */ - } -} - - - -/* Initialize the driver specific screen private data. - */ -static GLboolean -fbInitDriver( __DRIscreen *sPriv ) -{ - sPriv->private = NULL; - return GL_TRUE; -} - -static void -fbDestroyScreen( __DRIscreen *sPriv ) -{ -} - - -/* Create the device specific context. - */ -static GLboolean -fbCreateContext( const __GLcontextModes *glVisual, - __DRIcontext *driContextPriv, - void *sharedContextPrivate) -{ - fbContextPtr fbmesa; - GLcontext *ctx, *shareCtx; - struct dd_function_table functions; - - assert(glVisual); - assert(driContextPriv); - - /* Allocate the Fb context */ - fbmesa = (fbContextPtr) calloc(1, sizeof(*fbmesa) ); - if ( !fbmesa ) - return GL_FALSE; - - /* Init default driver functions then plug in our FBdev-specific functions - */ - _mesa_init_driver_functions(&functions); - init_core_functions(&functions); - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((fbContextPtr) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - - ctx = fbmesa->glCtx = _mesa_create_context(glVisual, shareCtx, - &functions, (void *) fbmesa); - if (!fbmesa->glCtx) { - free(fbmesa); - return GL_FALSE; - } - driContextPriv->driverPrivate = fbmesa; - - /* Create module contexts */ - _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - _swsetup_Wakeup( ctx ); - - - /* use default TCL pipeline */ - { - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.RunPipeline = _tnl_run_pipeline; - } - - _mesa_enable_sw_extensions(ctx); - - return GL_TRUE; -} - - -static void -fbDestroyContext( __DRIcontext *driContextPriv ) -{ - GET_CURRENT_CONTEXT(ctx); - fbContextPtr fbmesa = (fbContextPtr) driContextPriv->driverPrivate; - fbContextPtr current = ctx ? FB_CONTEXT(ctx) : NULL; - - /* check if we're deleting the currently bound context */ - if (fbmesa == current) { - _mesa_make_current(NULL, NULL, NULL); - } - - /* Free fb context resources */ - if ( fbmesa ) { - _swsetup_DestroyContext( fbmesa->glCtx ); - _tnl_DestroyContext( fbmesa->glCtx ); - _vbo_DestroyContext( fbmesa->glCtx ); - _swrast_DestroyContext( fbmesa->glCtx ); - - /* free the Mesa context */ - fbmesa->glCtx->DriverCtx = NULL; - _mesa_destroy_context( fbmesa->glCtx ); - - free( fbmesa ); - } -} - - -/* Create and initialize the Mesa and driver specific pixmap buffer - * data. - */ -static GLboolean -fbCreateBuffer( __DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const __GLcontextModes *mesaVis, - GLboolean isPixmap ) -{ - struct gl_framebuffer *mesa_framebuffer; - - if (isPixmap) { - return GL_FALSE; /* not implemented */ - } - else { - const GLboolean swDepth = mesaVis->depthBits > 0; - const GLboolean swAlpha = mesaVis->alphaBits > 0; - const GLboolean swAccum = mesaVis->accumRedBits > 0; - const GLboolean swStencil = mesaVis->stencilBits > 0; - - mesa_framebuffer = _mesa_create_framebuffer(mesaVis); - if (!mesa_framebuffer) - return 0; - - /* XXX double-check these parameters (bpp vs cpp, etc) */ - { - driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888, - driScrnPriv->pFB, - driScrnPriv->fbBPP / 8, - driScrnPriv->fbOrigin, - driScrnPriv->fbStride, - driDrawPriv); - fbSetSpanFunctions(drb, mesaVis); - _mesa_add_renderbuffer(mesa_framebuffer, - BUFFER_FRONT_LEFT, &drb->Base); - } - if (mesaVis->doubleBufferMode) { - /* XXX what are the correct origin/stride values? */ - GLvoid *backBuf = malloc(driScrnPriv->fbStride - * driScrnPriv->fbHeight); - driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888, - backBuf, - driScrnPriv->fbBPP /8, - driScrnPriv->fbOrigin, - driScrnPriv->fbStride, - driDrawPriv); - fbSetSpanFunctions(drb, mesaVis); - _mesa_add_renderbuffer(mesa_framebuffer, - BUFFER_BACK_LEFT, &drb->Base); - } - - _mesa_add_soft_renderbuffers(mesa_framebuffer, - GL_FALSE, /* color */ - swDepth, - swStencil, - swAccum, - swAlpha, /* or always zero? */ - GL_FALSE /* aux */); - - driDrawPriv->driverPrivate = mesa_framebuffer; - - return 1; - } -} - - -static void -fbDestroyBuffer(__DRIdrawable *driDrawPriv) -{ - _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - - - -/* If the backbuffer is on a videocard, this is extraordinarily slow! - */ -static void -fbSwapBuffers( __DRIdrawable *dPriv ) -{ - struct gl_framebuffer *mesa_framebuffer = (struct gl_framebuffer *)dPriv->driverPrivate; - struct gl_renderbuffer * front_renderbuffer = mesa_framebuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer; - void *frontBuffer = front_renderbuffer->Data; - int currentPitch = ((driRenderbuffer *)front_renderbuffer)->pitch; - void *backBuffer = mesa_framebuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer->Data; - - if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { - fbContextPtr fbmesa = (fbContextPtr) dPriv->driContextPriv->driverPrivate; - GLcontext *ctx = fbmesa->glCtx; - - if (ctx->Visual.doubleBufferMode) { - int i; - int offset = 0; - char *tmp = malloc(currentPitch); - - _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */ - - ASSERT(frontBuffer); - ASSERT(backBuffer); - - for (i = 0; i < dPriv->h; i++) { - memcpy(tmp, (char *) backBuffer + offset, currentPitch); - memcpy((char *) frontBuffer + offset, tmp, currentPitch); - offset += currentPitch; - } - - free(tmp); - } - } - else { - /* XXX this shouldn't be an error but we can't handle it for now */ - _mesa_problem(NULL, "fbSwapBuffers: drawable has no context!\n"); - } -} - - -/* Force the context `c' to be the current context and associate with it - * buffer `b'. - */ -static GLboolean -fbMakeCurrent( __DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv ) -{ - if ( driContextPriv ) { - fbContextPtr newFbCtx = - (fbContextPtr) driContextPriv->driverPrivate; - - newFbCtx->dri.drawable = driDrawPriv; - - _mesa_make_current( newFbCtx->glCtx, - driDrawPriv->driverPrivate, - driReadPriv->driverPrivate); - } else { - _mesa_make_current( NULL, NULL, NULL ); - } - - return GL_TRUE; -} - - -/* Force the context `c' to be unbound from its buffer. - */ -static GLboolean -fbUnbindContext( __DRIcontext *driContextPriv ) -{ - return GL_TRUE; -} - -static struct __DriverAPIRec fbAPI = { - .InitDriver = fbInitDriver, - .DestroyScreen = fbDestroyScreen, - .CreateContext = fbCreateContext, - .DestroyContext = fbDestroyContext, - .CreateBuffer = fbCreateBuffer, - .DestroyBuffer = fbDestroyBuffer, - .SwapBuffers = fbSwapBuffers, - .MakeCurrent = fbMakeCurrent, - .UnbindContext = fbUnbindContext, -}; - - - -static int -__driValidateMode(const DRIDriverContext *ctx ) -{ - return 1; -} - -static int -__driInitFBDev( struct DRIDriverContextRec *ctx ) -{ - /* Note that drmOpen will try to load the kernel module, if needed. */ - /* we need a fbdev drm driver - it will only track maps */ - ctx->drmFD = drmOpen("radeon", NULL ); - if (ctx->drmFD < 0) { - fprintf(stderr, "[drm] drmOpen failed\n"); - return 0; - } - - ctx->shared.SAREASize = SAREA_MAX; - - if (drmAddMap( ctx->drmFD, - 0, - ctx->shared.SAREASize, - DRM_SHM, - DRM_CONTAINS_LOCK, - &ctx->shared.hSAREA) < 0) - { - fprintf(stderr, "[drm] drmAddMap failed\n"); - return 0; - } - fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n", - ctx->shared.SAREASize, - (unsigned long) ctx->shared.hSAREA); - - if (drmMap( ctx->drmFD, - ctx->shared.hSAREA, - ctx->shared.SAREASize, - (drmAddressPtr)(&ctx->pSAREA)) < 0) - { - fprintf(stderr, "[drm] drmMap failed\n"); - return 0; - } - memset(ctx->pSAREA, 0, ctx->shared.SAREASize); - fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n", - (unsigned long) ctx->shared.hSAREA, ctx->pSAREA, - ctx->shared.SAREASize); - - /* Need to AddMap the framebuffer and mmio regions here: - */ - if (drmAddMap( ctx->drmFD, - (drm_handle_t)ctx->FBStart, - ctx->FBSize, - DRM_FRAME_BUFFER, -#ifndef _EMBEDDED - 0, -#else - DRM_READ_ONLY, -#endif - &ctx->shared.hFrameBuffer) < 0) - { - fprintf(stderr, "[drm] drmAddMap framebuffer failed\n"); - return 0; - } - - fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n", - (unsigned long) ctx->shared.hFrameBuffer); - - return 1; -} - -static void -__driHaltFBDev( struct DRIDriverContextRec *ctx ) -{ -} - -struct DRIDriverRec __driDriver = { - __driValidateMode, - __driValidateMode, - __driInitFBDev, - __driHaltFBDev -}; - -static __GLcontextModes * -fbFillInModes( __DRIscreen *psp, - unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer ) -{ - __GLcontextModes * modes; - __GLcontextModes * m; - unsigned num_modes; - unsigned depth_buffer_factor; - unsigned back_buffer_factor; - GLenum fb_format; - GLenum fb_type; - - /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy - * enough to add support. Basically, if a context is created with an - * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping - * will never be used. - */ - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ - }; - - uint8_t depth_bits_array[2]; - uint8_t stencil_bits_array[2]; - - - depth_bits_array[0] = depth_bits; - depth_bits_array[1] = depth_bits; - - /* Just like with the accumulation buffer, always provide some modes - * with a stencil buffer. It will be a sw fallback, but some apps won't - * care about that. - */ - stencil_bits_array[0] = 0; - stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; - - depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1; - back_buffer_factor = (have_back_buffer) ? 2 : 1; - - num_modes = depth_buffer_factor * back_buffer_factor * 4; - - if ( pixel_bits == 16 ) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { - fb_format = GL_RGBA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - modes = (*psp->contextModes->createContextModes)( num_modes, sizeof( __GLcontextModes ) ); - m = modes; - if ( ! driFillInModes( & m, fb_format, fb_type, - depth_bits_array, stencil_bits_array, depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - GLX_TRUE_COLOR ) ) { - fprintf( stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__ ); - return NULL; - } - - if ( ! driFillInModes( & m, fb_format, fb_type, - depth_bits_array, stencil_bits_array, depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - GLX_DIRECT_COLOR ) ) { - fprintf( stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__ ); - return NULL; - } - - /* Mark the visual as slow if there are "fake" stencil bits. - */ - for ( m = modes ; m != NULL ; m = m->next ) { - if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) { - m->visualRating = GLX_SLOW_CONFIG; - } - } - - return modes; -} - - -/** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. - * - * \return A pointer to a \c __DRIscreen on success, or \c NULL on - * failure. - */ -PUBLIC -void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - __GLcontextModes ** driver_modes ) -{ - __DRIscreen *psp; - static const __DRIversion ddx_expected = { 4, 0, 0 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 1, 5, 0 }; - - - if ( ! driCheckDriDdxDrmVersions2( "fb", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { - return NULL; - } - - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &fbAPI); - if ( psp != NULL ) { - *driver_modes = fbFillInModes( psp, psp->fbBPP, - (psp->fbBPP == 16) ? 16 : 24, - (psp->fbBPP == 16) ? 0 : 8, - 1); - } - - return (void *) psp; -} - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - NULL -}; diff --git a/src/mesa/drivers/dri/ffb/Makefile b/src/mesa/drivers/dri/ffb/Makefile deleted file mode 100644 index e9da8f9066e..00000000000 --- a/src/mesa/drivers/dri/ffb/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# src/mesa/drivers/dri/ffb/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = ffb_dri.so - -# not yet -# MINIGLX_SOURCES = server/ffb_dri.c - -DRIVER_SOURCES = \ - ffb_bitmap.c \ - ffb_clear.c \ - ffb_dd.c \ - ffb_depth.c \ - ffb_fog.c \ - ffb_lines.c \ - ffb_points.c \ - ffb_span.c \ - ffb_state.c \ - ffb_stencil.c \ - ffb_tex.c \ - ffb_tris.c \ - ffb_vb.c \ - ffb_xmesa.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - - -ASM_SOURCES = - -include ../Makefile.template - diff --git a/src/mesa/drivers/dri/ffb/ffb_bitmap.c b/src/mesa/drivers/dri/ffb/ffb_bitmap.c deleted file mode 100644 index b71a552c9dc..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_bitmap.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2001 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "ffb_context.h" -#include "ffb_state.h" -#include "ffb_lock.h" -#include "ffb_bitmap.h" -#include "swrast/swrast.h" -#include "main/macros.h" - -/* Compute ceiling of integer quotient of A divided by B: */ -#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 ) - -#undef FFB_BITMAP_TRACE - -static void -ffb_bitmap(GLcontext *ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - ffb_fbcPtr ffb = fmesa->regs; - __DRIdrawable *dPriv = fmesa->driDrawable; - unsigned int ppc, pixel; - GLint row, col, row_stride; - const GLubyte *src; - char *buf; - - if (fmesa->bad_fragment_attrs != 0) - _swrast_Bitmap(ctx, px, py, width, - height, unpack, bitmap); - - pixel = (((((GLuint)(ctx->Current.RasterColor[0] * 255.0f)) & 0xff) << 0) | - ((((GLuint)(ctx->Current.RasterColor[1] * 255.0f)) & 0xff) << 8) | - ((((GLuint)(ctx->Current.RasterColor[2] * 255.0f)) & 0xff) << 16) | - ((((GLuint)(ctx->Current.RasterColor[3] * 255.0f)) & 0xff) << 24)); - -#ifdef FFB_BITMAP_TRACE - fprintf(stderr, "ffb_bitmap: ppc(%08x) fbc(%08x) cmp(%08x) pixel(%08x)\n", - fmesa->ppc, fmesa->fbc, fmesa->cmp, pixel); -#endif - - LOCK_HARDWARE(fmesa); - fmesa->hw_locked = 1; - - if (fmesa->state_dirty) - ffbSyncHardware(fmesa); - - ppc = fmesa->ppc; - - FFBFifo(fmesa, 4); - ffb->ppc = ((ppc & - ~(FFB_PPC_TBE_MASK | FFB_PPC_ZS_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK)) - | (FFB_PPC_TBE_TRANSPARENT | FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST | - (ctx->Color.BlendEnabled ? FFB_PPC_XS_CONST : FFB_PPC_XS_WID))); - ffb->constz = ((GLuint) (ctx->Current.RasterPos[2] * 0x0fffffff)); - ffb->fg = pixel; - ffb->fontinc = (0 << 16) | 32; - - buf = (char *)(fmesa->sfb32 + (dPriv->x << 2) + (dPriv->y << 13)); - - row_stride = (unpack->Alignment * CEILING(width, 8 * unpack->Alignment)); - src = (const GLubyte *) (bitmap + - (unpack->SkipRows * row_stride) + - (unpack->SkipPixels / 8)); - if (unpack->LsbFirst == GL_TRUE) { - for (row = 0; row < height; row++, src += row_stride) { - const GLubyte *row_src = src; - GLuint base_x, base_y; - - base_x = dPriv->x + px; - base_y = dPriv->y + (dPriv->h - (py + row)); - - FFBFifo(fmesa, 1); - ffb->fontxy = (base_y << 16) | base_x; - - for (col = 0; col < width; col += 32, row_src += 4) { - GLint bitnum, font_w = (width - col); - GLuint font_data; - - if (font_w > 32) - font_w = 32; - font_data = 0; - for (bitnum = 0; bitnum < 32; bitnum++) { - const GLubyte val = row_src[bitnum >> 3]; - - if (val & (1 << (bitnum & (8 - 1)))) - font_data |= (1 << (31 - bitnum)); - } - - FFBFifo(fmesa, 2); - ffb->fontw = font_w; - ffb->font = font_data; - } - } - } else { - for (row = 0; row < height; row++, src += row_stride) { - const GLubyte *row_src = src; - GLuint base_x, base_y; - - base_x = dPriv->x + px; - base_y = dPriv->y + (dPriv->h - (py + row)); - - FFBFifo(fmesa, 1); - ffb->fontxy = (base_y << 16) | base_x; - - for (col = 0; col < width; col += 32, row_src += 4) { - GLint font_w = (width - col); - - if (font_w > 32) - font_w = 32; - FFBFifo(fmesa, 2); - ffb->fontw = font_w; - ffb->font = (((unsigned int)row_src[0]) << 24 | - ((unsigned int)row_src[1]) << 16 | - ((unsigned int)row_src[2]) << 8 | - ((unsigned int)row_src[3]) << 0); - } - } - } - - FFBFifo(fmesa, 1); - ffb->ppc = ppc; - fmesa->ffbScreen->rp_active = 1; - - UNLOCK_HARDWARE(fmesa); - fmesa->hw_locked = 0; -} - -void ffbDDInitBitmapFuncs(GLcontext *ctx) -{ - ctx->Driver.Bitmap = ffb_bitmap; -} diff --git a/src/mesa/drivers/dri/ffb/ffb_bitmap.h b/src/mesa/drivers/dri/ffb/ffb_bitmap.h deleted file mode 100644 index 0ccbc57bd09..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_bitmap.h +++ /dev/null @@ -1,7 +0,0 @@ - -#ifndef _FFB_BITMAP_H -#define _FFB_BITMAP_H - -extern void ffbDDInitBitmapFuncs(GLcontext *); - -#endif /* !(_FFB_BITMAP_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_clear.c b/src/mesa/drivers/dri/ffb/ffb_clear.c deleted file mode 100644 index aa3fa0a86c5..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_clear.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2000 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "main/mtypes.h" - -#include "main/mm.h" -#include "ffb_dd.h" -#include "ffb_span.h" -#include "ffb_context.h" -#include "ffb_vb.h" -#include "ffb_clear.h" -#include "ffb_lock.h" - -#undef CLEAR_TRACE - -#define BOX_AREA(__w, __h) ((int)(__w) * (int)(__h)) - -/* Compute the page aligned box for a page mode fast fill. - * In 'ework' this returns greater than zero if there are some odd - * edges to take care of which are outside of the page aligned area. - * It will place less than zero there if the box is too small, - * indicating that a different method must be used to fill it. - */ -#define CreatorPageFillParms(ffp, x, y, w, h, px, py, pw, ph, ework) \ -do { int xdiff, ydiff; \ - int pf_bh = ffp->pagefill_height; \ - int pf_bw = ffp->pagefill_width; \ - py = ((y + (pf_bh - 1)) & ~(pf_bh - 1)); \ - ydiff = py - y; \ - px = ffp->Pf_AlignTab[x + (pf_bw - 1)]; \ - xdiff = px - x; \ - ph = ((h - ydiff) & ~(pf_bh - 1)); \ - if(ph <= 0) \ - ework = -1; \ - else { \ - pw = ffp->Pf_AlignTab[w - xdiff]; \ - if(pw <= 0) { \ - ework = -1; \ - } else { \ - ework = (((xdiff > 0) || \ - (ydiff > 0) || \ - ((w - pw) > 0) || \ - ((h - ph) > 0))) ? 1 : 0; \ - } \ - } \ -} while(0); - -struct ff_fixups { - int x, y, width, height; -}; - -/* Compute fixups of non-page aligned areas after a page fill. - * Return the number of fixups needed. - */ -static INLINE int -CreatorComputePageFillFixups(struct ff_fixups *fixups, - int x, int y, int w, int h, - int paligned_x, int paligned_y, - int paligned_w, int paligned_h) -{ - int nfixups = 0; - - /* FastFill Left */ - if(paligned_x != x) { - fixups[nfixups].x = x; - fixups[nfixups].y = paligned_y; - fixups[nfixups].width = paligned_x - x; - fixups[nfixups].height = paligned_h; - nfixups++; - } - /* FastFill Top */ - if(paligned_y != y) { - fixups[nfixups].x = x; - fixups[nfixups].y = y; - fixups[nfixups].width = w; - fixups[nfixups].height = paligned_y - y; - nfixups++; - } - /* FastFill Right */ - if((x+w) != (paligned_x+paligned_w)) { - fixups[nfixups].x = (paligned_x+paligned_w); - fixups[nfixups].y = paligned_y; - fixups[nfixups].width = (x+w) - fixups[nfixups].x; - fixups[nfixups].height = paligned_h; - nfixups++; - } - /* FastFill Bottom */ - if((y+h) != (paligned_y+paligned_h)) { - fixups[nfixups].x = x; - fixups[nfixups].y = (paligned_y+paligned_h); - fixups[nfixups].width = w; - fixups[nfixups].height = (y+h) - fixups[nfixups].y; - nfixups++; - } - return nfixups; -} - -static void -ffb_do_clear(GLcontext *ctx, __DRIdrawable *dPriv) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - FFBDRIPtr gDRIPriv = (FFBDRIPtr) fmesa->driScreen->pDevPriv; - ffb_fbcPtr ffb = fmesa->regs; - drm_clip_rect_t *box = dPriv->pClipRects; - int nc = dPriv->numClipRects; - GLint cx, cy, cw, ch; - - /* compute region after locking: */ - cx = ctx->DrawBuffer->_Xmin; - cy = ctx->DrawBuffer->_Ymin; - cw = ctx->DrawBuffer->_Xmax - cx; - ch = ctx->DrawBuffer->_Ymax - cy; - - cy = dPriv->h - cy - ch; - cx += dPriv->x; - cy += dPriv->y; - - while (nc--) { - GLint x = box[nc].x1; - GLint y = box[nc].y1; - GLint width = box[nc].x2 - x; - GLint height = box[nc].y2 - y; - int paligned_y, paligned_x; - int paligned_h, paligned_w = 0; - int extra_work; - - if (BOX_AREA(width, height) < gDRIPriv->fastfill_small_area) { - FFBFifo(fmesa, 5); - ffb->drawop = FFB_DRAWOP_RECTANGLE; - ffb->by = y; - ffb->bx = x; - ffb->bh = height; - ffb->bw = width; - continue; - } - - FFBFifo(fmesa, 1); - ffb->drawop = FFB_DRAWOP_FASTFILL; - - if (gDRIPriv->disable_pagefill || - (width < (gDRIPriv->pagefill_width<<1)) || - (height < (gDRIPriv->pagefill_height<<1))) - goto do_fastfill; - - CreatorPageFillParms(gDRIPriv, - x, y, width, height, - paligned_x, paligned_y, - paligned_w, paligned_h, extra_work); - - if (extra_work < 0 || - BOX_AREA(paligned_w, paligned_h) < gDRIPriv->pagefill_small_area) { - do_fastfill: - FFBFifo(fmesa, 10); - ffb->by = FFB_FASTFILL_COLOR_BLK; - ffb->dy = 0; - ffb->dx = 0; - ffb->bh = gDRIPriv->fastfill_height; - ffb->bw = (gDRIPriv->fastfill_width * 4); - ffb->by = FFB_FASTFILL_BLOCK; - ffb->dy = y; - ffb->dx = x; - ffb->bh = (height + (y & (gDRIPriv->fastfill_height - 1))); - ffb->bx = (width + (x & (gDRIPriv->fastfill_width - 1))); - continue; - } - - /* Ok, page fill is possible and worth it. */ - FFBFifo(fmesa, 15); - ffb->by = FFB_FASTFILL_COLOR_BLK; - ffb->dy = 0; - ffb->dx = 0; - ffb->bh = gDRIPriv->fastfill_height; - ffb->bw = gDRIPriv->fastfill_width * 4; - ffb->by = FFB_FASTFILL_BLOCK_X; - ffb->dy = 0; - ffb->dx = 0; - ffb->bh = gDRIPriv->pagefill_height; - ffb->bw = gDRIPriv->pagefill_width * 4; - ffb->by = FFB_FASTFILL_PAGE; - ffb->dy = paligned_y; - ffb->dx = paligned_x; - ffb->bh = paligned_h; - ffb->bx = paligned_w; - - if (extra_work) { - struct ff_fixups local_fixups[4]; - int nfixups; - - nfixups = CreatorComputePageFillFixups(local_fixups, - x, y, width, height, - paligned_x, paligned_y, - paligned_w, paligned_h); - FFBFifo(fmesa, 5 + (nfixups * 5)); - ffb->by = FFB_FASTFILL_COLOR_BLK; - ffb->dy = 0; - ffb->dx = 0; - ffb->bh = gDRIPriv->fastfill_height; - ffb->bw = gDRIPriv->fastfill_width * 4; - - while (--nfixups >= 0) { - int xx, yy, ww, hh; - - xx = local_fixups[nfixups].x; - yy = local_fixups[nfixups].y; - ffb->dy = yy; - ffb->dx = xx; - ww = (local_fixups[nfixups].width + - (xx & (gDRIPriv->fastfill_width - 1))); - hh = (local_fixups[nfixups].height + - (yy & (gDRIPriv->fastfill_height - 1))); - if (nfixups != 0) { - ffb->by = FFB_FASTFILL_BLOCK; - ffb->bh = hh; - ffb->bw = ww; - } else { - ffb->bh = hh; - ffb->by = FFB_FASTFILL_BLOCK; - ffb->bx = ww; - } - } - } - } -} - -void ffbDDClear(GLcontext *ctx, GLbitfield mask) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - __DRIdrawable *dPriv = fmesa->driDrawable; - unsigned int stcmask = BUFFER_BIT_STENCIL; - -#ifdef CLEAR_TRACE - fprintf(stderr, "ffbDDClear: mask(%08x) \n", mask); -#endif - if (!(fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)) - stcmask = 0; - - if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH | stcmask)) { - ffb_fbcPtr ffb = fmesa->regs; - unsigned int fbc, ppc; - - fbc = (FFB_FBC_XE_ON); - ppc = (FFB_PPC_ACE_DISABLE | FFB_PPC_DCE_DISABLE | - FFB_PPC_ABE_DISABLE | FFB_PPC_VCE_DISABLE | - FFB_PPC_APE_DISABLE | FFB_PPC_XS_WID | - FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST); - - /* Y/X enables must be both on or both off. */ - if (mask & (BUFFER_BIT_DEPTH | stcmask)) { - fbc |= (FFB_FBC_ZE_ON | FFB_FBC_YE_ON | FFB_FBC_WB_C); - } else - fbc |= FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF; - - /* All RGB enables must be both on or both off. */ - if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) { - if (mask & BUFFER_BIT_FRONT_LEFT) { - if (fmesa->back_buffer == 0) - fbc |= FFB_FBC_WB_B; - else - fbc |= FFB_FBC_WB_A; - } - if (mask & BUFFER_BIT_BACK_LEFT) { - if (fmesa->back_buffer == 0) - fbc |= FFB_FBC_WB_A; - else - fbc |= FFB_FBC_WB_B; - } - fbc |= FFB_FBC_RGBE_ON; - } else - fbc |= FFB_FBC_RGBE_OFF; - - LOCK_HARDWARE(fmesa); - - if (dPriv->numClipRects) { - FFBFifo(fmesa, 8); - ffb->fbc = fbc; - ffb->ppc = ppc; - ffb->xclip = FFB_XCLIP_TEST_ALWAYS; - ffb->cmp = 0x80808080; - ffb->rop = FFB_ROP_NEW; - - if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) - ffb->fg = fmesa->clear_pixel; - if (mask & BUFFER_BIT_DEPTH) - ffb->constz = fmesa->clear_depth; - if (mask & stcmask) - ffb->consty = fmesa->clear_stencil; - - ffb_do_clear(ctx, dPriv); - - FFBFifo(fmesa, 6); - ffb->ppc = fmesa->ppc; - ffb->fbc = fmesa->fbc; - ffb->xclip = fmesa->xclip; - ffb->cmp = fmesa->cmp; - ffb->rop = fmesa->rop; - ffb->drawop = fmesa->drawop; - if (mask & stcmask) - ffb->consty = fmesa->consty; - fmesa->ffbScreen->rp_active = 1; - } - - UNLOCK_HARDWARE(fmesa); - - mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | - BUFFER_BIT_DEPTH | stcmask); - } - - if (mask) - _swrast_Clear(ctx, mask); -} - diff --git a/src/mesa/drivers/dri/ffb/ffb_clear.h b/src/mesa/drivers/dri/ffb/ffb_clear.h deleted file mode 100644 index c3b8ce714b3..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_clear.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _FFB_CLEAR_H -#define _FFB_CLEAR_H - -extern void ffbDDClear(GLcontext *ctx, GLbitfield mask); - -#endif /* !(_FFB_CLEAR_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_context.h b/src/mesa/drivers/dri/ffb/ffb_context.h deleted file mode 100644 index 4d1d53ff59f..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_context.h +++ /dev/null @@ -1,305 +0,0 @@ - -#ifndef _FFB_CONTEXT_H -#define _FFB_CONTEXT_H - -#include "dri_util.h" -#include "drm.h" - -#include "main/mtypes.h" - -#include "ffb_xmesa.h" - -typedef struct { - GLfloat alpha; - GLfloat red; - GLfloat green; - GLfloat blue; -} ffb_color; - -#define FFB_GET_ALPHA(VTX) \ - FFB_COLOR_FROM_FLOAT((VTX)->color[0].alpha) -#define FFB_GET_RED(VTX) \ - FFB_COLOR_FROM_FLOAT((VTX)->color[0].red) -#define FFB_GET_GREEN(VTX) \ - FFB_COLOR_FROM_FLOAT((VTX)->color[0].green) -#define FFB_GET_BLUE(VTX) \ - FFB_COLOR_FROM_FLOAT((VTX)->color[0].blue) - -typedef struct { - GLfloat x, y, z; - ffb_color color[2]; -} ffb_vertex; - -#define FFB_DELAYED_VIEWPORT_VARS \ - GLfloat VP_SX = fmesa->hw_viewport[MAT_SX]; \ - GLfloat VP_TX = fmesa->hw_viewport[MAT_TX]; \ - GLfloat VP_SY = fmesa->hw_viewport[MAT_SY]; \ - GLfloat VP_TY = fmesa->hw_viewport[MAT_TY]; \ - GLfloat VP_SZ = fmesa->hw_viewport[MAT_SZ]; \ - GLfloat VP_TZ = fmesa->hw_viewport[MAT_TZ]; \ - (void) VP_SX; (void) VP_SY; (void) VP_SZ; \ - (void) VP_TX; (void) VP_TY; (void) VP_TZ - -#define FFB_GET_Z(VTX) \ - FFB_Z_FROM_FLOAT(VP_SZ * (VTX)->z + VP_TZ) -#define FFB_GET_Y(VTX) \ - FFB_XY_FROM_FLOAT(VP_SY * (VTX)->y + VP_TY) -#define FFB_GET_X(VTX) \ - FFB_XY_FROM_FLOAT(VP_SX * (VTX)->x + VP_TX) - -typedef void (*ffb_point_func)(GLcontext *, ffb_vertex *); -typedef void (*ffb_line_func)(GLcontext *, ffb_vertex *, ffb_vertex *); -typedef void (*ffb_tri_func)(GLcontext *, ffb_vertex *, ffb_vertex *, - ffb_vertex *); -typedef void (*ffb_quad_func)(GLcontext *, ffb_vertex *, ffb_vertex *, - ffb_vertex *, ffb_vertex *); - -/* Immediate mode fast-path support. */ -typedef struct { - GLfloat obj[4]; - GLfloat normal[4]; - GLfloat clip[4]; - GLuint mask; - GLfloat color[4]; - GLfloat win[4]; - GLfloat eye[4]; -} ffbTnlVertex, *ffbTnlVertexPtr; - -typedef void (*ffb_interp_func)(GLfloat t, - ffbTnlVertex *O, - const ffbTnlVertex *I, - const ffbTnlVertex *J); - -struct ffb_current_state { - GLfloat color[4]; - GLfloat normal[4]; - GLfloat specular[4]; -}; - -struct ffb_light_state { - GLfloat base_color[3]; - GLfloat base_alpha; -}; - -struct ffb_vertex_state { - struct ffb_current_state current; - struct ffb_light_state light; -}; - -struct ffb_imm_vertex { - ffbTnlVertex vertices[8]; - ffbTnlVertex *v0; - ffbTnlVertex *v1; - ffbTnlVertex *v2; - ffbTnlVertex *v3; - - void (*save_vertex)(GLcontext *ctx, ffbTnlVertex *v); - void (*flush_vertex)(GLcontext *ctx, ffbTnlVertex *v); - - ffb_interp_func interp; - - GLuint prim, format; - - GLvertexformat vtxfmt; -}; - -typedef struct ffb_context_t { - GLcontext *glCtx; - GLframebuffer *glBuffer; - - ffb_fbcPtr regs; - volatile char *sfb32; - - int hw_locked; - - int back_buffer; /* 0 = bufferA, 1 = bufferB */ - - /* Viewport matrix. */ - GLfloat hw_viewport[16]; -#define SUBPIXEL_X (-0.5F) -#define SUBPIXEL_Y (-0.5F + 0.125) - - /* Vertices in driver format. */ - ffb_vertex *verts; - - /* Rasterization functions. */ - ffb_point_func draw_point; - ffb_line_func draw_line; - ffb_tri_func draw_tri; - ffb_quad_func draw_quad; - - GLenum raster_primitive; - GLenum render_primitive; - - GLfloat backface_sign; - GLfloat depth_scale; - - GLfloat ffb_2_30_fixed_scale; - GLfloat ffb_one_over_2_30_fixed_scale; - GLfloat ffb_16_16_fixed_scale; - GLfloat ffb_one_over_16_16_fixed_scale; - GLfloat ffb_ubyte_color_scale; - GLfloat ffb_zero; - - /* Immediate mode state. */ - struct ffb_vertex_state vtx_state; - struct ffb_imm_vertex imm; - - /* Debugging knobs. */ - GLboolean debugFallbacks; - - /* This records state bits when a per-fragment attribute has - * been set which prevents us from rendering in hardware. - * - * As attributes change, some of these bits may clear as - * we move back within the chips capabilities. If they - * all clear, we return to full hw rendering. - */ - unsigned int bad_fragment_attrs; -#define FFB_BADATTR_FOG 0x00000001 /* Bad fog possible only when < FFB2 */ -#define FFB_BADATTR_BLENDFUNC 0x00000002 /* Any non-const func based upon dst alpha */ -#define FFB_BADATTR_BLENDROP 0x00000004 /* Blend enabled and LogicOP != GL_COPY */ -#define FFB_BADATTR_BLENDEQN 0x00000008 /* Blend equation other than ADD */ -#define FFB_BADATTR_STENCIL 0x00000010 /* Stencil enabled when < FFB2+ */ -#define FFB_BADATTR_TEXTURE 0x00000020 /* Texture enabled */ -#define FFB_BADATTR_SWONLY 0x00000040 /* Environment var set */ - - unsigned int state_dirty; - unsigned int state_fifo_ents; -#define FFB_STATE_FBC 0x00000001 -#define FFB_STATE_PPC 0x00000002 -#define FFB_STATE_DRAWOP 0x00000004 -#define FFB_STATE_ROP 0x00000008 -#define FFB_STATE_LPAT 0x00000010 -#define FFB_STATE_PMASK 0x00000020 -#define FFB_STATE_XPMASK 0x00000040 -#define FFB_STATE_YPMASK 0x00000080 -#define FFB_STATE_ZPMASK 0x00000100 -#define FFB_STATE_XCLIP 0x00000200 -#define FFB_STATE_CMP 0x00000400 -#define FFB_STATE_MATCHAB 0x00000800 -#define FFB_STATE_MAGNAB 0x00001000 -#define FFB_STATE_MATCHC 0x00002000 -#define FFB_STATE_MAGNC 0x00004000 -#define FFB_STATE_DCUE 0x00008000 -#define FFB_STATE_BLEND 0x00010000 -#define FFB_STATE_CLIP 0x00020000 -#define FFB_STATE_STENCIL 0x00040000 -#define FFB_STATE_APAT 0x00080000 -#define FFB_STATE_WID 0x00100000 -#define FFB_STATE_ALL 0x001fffff - - unsigned int state_all_fifo_ents; - -#define FFB_MAKE_DIRTY(FMESA, STATE_MASK, FIFO_ENTS) \ -do { if ((STATE_MASK) & ~((FMESA)->state_dirty)) { \ - (FMESA)->state_dirty |= (STATE_MASK); \ - (FMESA)->state_fifo_ents += FIFO_ENTS; \ - } \ -} while (0) - - /* General hw reg state. */ - unsigned int fbc; - unsigned int ppc; - unsigned int drawop; - unsigned int rop; - - unsigned int lpat; -#define FFB_LPAT_BAD 0xffffffff - - unsigned int wid; - unsigned int pmask; - unsigned int xpmask; - unsigned int ypmask; - unsigned int zpmask; - unsigned int xclip; - unsigned int cmp; - unsigned int matchab; - unsigned int magnab; - unsigned int matchc; - unsigned int magnc; - - /* Depth cue unit hw reg state. */ - unsigned int dcss; /* All FFB */ - unsigned int dcsf; /* All FFB */ - unsigned int dcsb; /* All FFB */ - unsigned int dczf; /* All FFB */ - unsigned int dczb; /* All FFB */ - unsigned int dcss1; /* >=FFB2 only */ - unsigned int dcss2; /* >=FFB2 only */ - unsigned int dcss3; /* >=FFB2 only */ - unsigned int dcs2; /* >=FFB2 only */ - unsigned int dcs3; /* >=FFB2 only */ - unsigned int dcs4; /* >=FFB2 only */ - unsigned int dcd2; /* >=FFB2 only */ - unsigned int dcd3; /* >=FFB2 only */ - unsigned int dcd4; /* >=FFB2 only */ - - /* Blend unit hw reg state. */ - unsigned int blendc; - unsigned int blendc1; - unsigned int blendc2; - - /* ViewPort clipping hw reg state. */ - unsigned int vclipmin; - unsigned int vclipmax; - unsigned int vclipzmin; - unsigned int vclipzmax; - struct { - unsigned int min; - unsigned int max; - } aux_clips[4]; - - /* Stencil control hw reg state. >=FFB2+ only. */ - unsigned int stencil; - unsigned int stencilctl; - unsigned int consty; /* Stencil Ref */ - - /* Area pattern (used for polygon stipples). */ - unsigned int pattern[32]; - - /* Fog state. */ - float Znear, Zfar; - - drm_context_t hHWContext; - drm_hw_lock_t *driHwLock; - int driFd; - - unsigned int clear_pixel; - unsigned int clear_depth; - unsigned int clear_stencil; - - unsigned int setupindex; - unsigned int setupnewinputs; - unsigned int new_gl_state; - - __DRIdrawable *driDrawable; - __DRIscreen *driScreen; - ffbScreenPrivate *ffbScreen; - ffb_dri_state_t *ffb_sarea; -} ffbContextRec, *ffbContextPtr; - -#define FFB_CONTEXT(ctx) ((ffbContextPtr)((ctx)->DriverCtx)) - -/* We want the depth values written during software rendering - * to match what the hardware is going to put there when we - * hw render. - * - * The Z buffer is 28 bits deep. Smooth shaded primitives - * specify a 2:30 signed fixed point Z value in the range 0.0 - * to 1.0 inclusive. - * - * So for example, when hw rendering, the largest Z value of - * 1.0 would produce a value of 0x0fffffff in the actual Z - * buffer, which is the maximum value. - * - * Mesa's depth type is a 32-bit uint, so we use the following macro - * to convert to/from FFB hw Z values. Note we also have to clear - * out the top bits as that is where the Y (stencil) buffer is stored - * and during hw Z buffer reads it is always there. (During writes - * we tell the hw to discard those top 4 bits). - */ -#define Z_TO_MESA(VAL) ((GLuint)(((VAL) & 0x0fffffff) << (32 - 28))) -#define Z_FROM_MESA(VAL) (((GLuint)((GLdouble)(VAL))) >> (32 - 28)) - -#endif /* !(_FFB_CONTEXT_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_dd.c b/src/mesa/drivers/dri/ffb/ffb_dd.c deleted file mode 100644 index 91b6d3153af..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_dd.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2000, 2001 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "main/mtypes.h" -#include "main/mm.h" -#include "ffb_dd.h" -#include "ffb_span.h" -#include "ffb_context.h" -#include "ffb_clear.h" -#include "ffb_lock.h" - -#define FFB_DATE "20021125" - -PUBLIC const char __driConfigOptions[] = { 0 }; -const GLuint __driNConfigOptions = 0; - -/* Mesa's Driver Functions */ - -static const GLubyte *ffbDDGetString(GLcontext *ctx, GLenum name) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - static char buffer[128]; - - switch (name) { - case GL_VENDOR: - return (GLubyte *) "David S. Miller"; - - case GL_RENDERER: - sprintf(buffer, "Mesa DRI FFB " FFB_DATE); - - if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2) - strncat(buffer, " FFB2", 5); - if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS) - strncat(buffer, " FFB2PLUS", 9); - if (fmesa->ffb_sarea->flags & FFB_DRI_PAC1) - strncat(buffer, " PAC1", 5); - if (fmesa->ffb_sarea->flags & FFB_DRI_PAC2) - strncat(buffer, " PAC2", 5); - -#ifdef USE_SPARC_ASM - strncat(buffer, " Sparc", 6); -#endif - - return (GLubyte *) buffer; - - default: - return NULL; - }; -} - - -static void ffbBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height) -{ - GET_CURRENT_CONTEXT(ctx); - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - LOCK_HARDWARE(fmesa); - *width = fmesa->driDrawable->w; - *height = fmesa->driDrawable->h; - UNLOCK_HARDWARE(fmesa); -} - -void ffbDDExtensionsInit(GLcontext *ctx) -{ - /* Nothing for now until we start to add - * real acceleration. -DaveM - */ - - /* XXX Need to turn off GL_EXT_blend_func_separate for one. - * XXX Also BlendEquation should be turned off too, what - * XXX EXT is that assosciated with? - */ -} - -static void ffbDDFinish(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - LOCK_HARDWARE(fmesa); - FFBWait(fmesa, fmesa->regs); - UNLOCK_HARDWARE(fmesa); -} - -void ffbDDInitDriverFuncs(GLcontext *ctx) -{ - ctx->Driver.GetBufferSize = ffbBufferSize; - ctx->Driver.GetString = ffbDDGetString; - ctx->Driver.Clear = ffbDDClear; - - ctx->Driver.Finish = ffbDDFinish; -} diff --git a/src/mesa/drivers/dri/ffb/ffb_dd.h b/src/mesa/drivers/dri/ffb/ffb_dd.h deleted file mode 100644 index 1198cda30a1..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_dd.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D. - * Copyright (C) 2000 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#ifndef _FFB_DD_H -#define _FFB_DD_H - -#include "main/context.h" - -void ffbDDInitDriverFuncs(GLcontext *ctx); -void ffbDDExtensionsInit(GLcontext *ctx); - -#endif /* !(_FFB_DD_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_depth.c b/src/mesa/drivers/dri/ffb/ffb_depth.c deleted file mode 100644 index d19385b776b..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_depth.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2000 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "main/mtypes.h" -#include "ffb_dd.h" -#include "ffb_span.h" -#include "ffb_context.h" -#include "ffb_depth.h" -#include "ffb_lock.h" - - -#undef DEPTH_TRACE - -static void FFBWriteDepthSpan( GLcontext *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - const void *values, - const GLubyte mask[] ) -{ - const GLuint *depth = (const GLuint *) values; -#ifdef DEPTH_TRACE - fprintf(stderr, "FFBWriteDepthSpan: n(%d) x(%d) y(%d)\n", - (int) n, x, y); -#endif - if (ctx->Depth.Mask) { - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - __DRIdrawable *dPriv = fmesa->driDrawable; - GLuint *zptr; - GLuint i; - - if (!fmesa->hw_locked) - LOCK_HARDWARE(fmesa); - FFBFifo(fmesa, 2); - fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_ON | - FFB_FBC_YE_OFF | FFB_FBC_RGBE_OFF); - fmesa->regs->ppc = FFB_PPC_ZS_VAR; - FFBWait(fmesa, fmesa->regs); - - y = (dPriv->h - y); - zptr = (GLuint *) - ((char *)fmesa->sfb32 + - ((dPriv->x + x) << 2) + - ((dPriv->y + y) << 13)); - - for (i = 0; i < n; i++) { - if (mask[i]) { - *zptr = Z_FROM_MESA(depth[i]); - } - zptr++; - } - - FFBFifo(fmesa, 2); - fmesa->regs->fbc = fmesa->fbc; - fmesa->regs->ppc = fmesa->ppc; - fmesa->ffbScreen->rp_active = 1; - if (!fmesa->hw_locked) - UNLOCK_HARDWARE(fmesa); - } -} - -static void FFBWriteMonoDepthSpan( GLcontext *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - const void *value, const GLubyte mask[] ) -{ - const GLuint depthVal = *((GLuint *) value); - GLuint depths[MAX_WIDTH]; - GLuint i; - for (i = 0; i < n; i++) - depths[i] = depthVal; - FFBWriteDepthSpan(ctx, rb, n, x, y, depths, mask); -} - -static void FFBWriteDepthPixels( GLcontext *ctx, - struct gl_renderbuffer *rb, - GLuint n, - const GLint x[], - const GLint y[], - const void *values, - const GLubyte mask[] ) -{ - const GLuint *depth = (const GLuint *) values; -#ifdef DEPTH_TRACE - fprintf(stderr, "FFBWriteDepthPixels: n(%d)\n", (int) n); -#endif - if (ctx->Depth.Mask) { - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - __DRIdrawable *dPriv = fmesa->driDrawable; - char *zbase; - GLuint i; - - if (!fmesa->hw_locked) - LOCK_HARDWARE(fmesa); - FFBFifo(fmesa, 2); - fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_ON | - FFB_FBC_YE_OFF | FFB_FBC_RGBE_OFF); - fmesa->regs->ppc = FFB_PPC_ZS_VAR; - fmesa->ffbScreen->rp_active = 1; - FFBWait(fmesa, fmesa->regs); - - zbase = ((char *)fmesa->sfb32 + - (dPriv->x << 2) + (dPriv->y << 13)); - - for (i = 0; i < n; i++) { - GLint y1 = (dPriv->h - y[i]); - GLint x1 = x[i]; - GLuint *zptr; - - zptr = (GLuint *) - (zbase + (x1 << 2) + (y1 << 13)); - if (mask[i]) - *zptr = Z_FROM_MESA(depth[i]); - } - - FFBFifo(fmesa, 2); - fmesa->regs->fbc = fmesa->fbc; - fmesa->regs->ppc = fmesa->ppc; - fmesa->ffbScreen->rp_active = 1; - if (!fmesa->hw_locked) - UNLOCK_HARDWARE(fmesa); - } -} - -static void FFBReadDepthSpan( GLcontext *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - void *values ) -{ - GLuint *depth = (GLuint *) values; - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - __DRIdrawable *dPriv = fmesa->driDrawable; - GLuint *zptr; - GLuint i; - -#ifdef DEPTH_TRACE - fprintf(stderr, "FFBReadDepthSpan: n(%d) x(%d) y(%d)\n", - (int) n, x, y); -#endif - if (!fmesa->hw_locked) - LOCK_HARDWARE(fmesa); - FFBFifo(fmesa, 1); - fmesa->regs->fbc = FFB_FBC_RB_C; - fmesa->ffbScreen->rp_active = 1; - FFBWait(fmesa, fmesa->regs); - - y = (dPriv->h - y); - zptr = (GLuint *) - ((char *)fmesa->sfb32 + - ((dPriv->x + x) << 2) + - ((dPriv->y + y) << 13)); - - for (i = 0; i < n; i++) { - depth[i] = Z_TO_MESA(*zptr); - zptr++; - } - - FFBFifo(fmesa, 1); - fmesa->regs->fbc = fmesa->fbc; - fmesa->ffbScreen->rp_active = 1; - if (!fmesa->hw_locked) - UNLOCK_HARDWARE(fmesa); -} - -static void FFBReadDepthPixels( GLcontext *ctx, - struct gl_renderbuffer *rb, - GLuint n, - const GLint x[], const GLint y[], - void *values ) -{ - GLuint *depth = (GLuint *) values; - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - __DRIdrawable *dPriv = fmesa->driDrawable; - char *zbase; - GLuint i; - -#ifdef DEPTH_TRACE - fprintf(stderr, "FFBReadDepthPixels: n(%d)\n", (int) n); -#endif - if (!fmesa->hw_locked) - LOCK_HARDWARE(fmesa); - FFBFifo(fmesa, 1); - fmesa->regs->fbc = FFB_FBC_RB_C; - fmesa->ffbScreen->rp_active = 1; - FFBWait(fmesa, fmesa->regs); - - zbase = ((char *)fmesa->sfb32 + - (dPriv->x << 2) + (dPriv->y << 13)); - - for (i = 0; i < n; i++) { - GLint y1 = (dPriv->h - y[i]); - GLint x1 = x[i]; - GLuint *zptr; - - zptr = (GLuint *) - (zbase + (x1 << 2) + (y1 << 13)); - depth[i] = Z_TO_MESA(*zptr); - } - - FFBFifo(fmesa, 1); - fmesa->regs->fbc = fmesa->fbc; - fmesa->ffbScreen->rp_active = 1; - if (!fmesa->hw_locked) - UNLOCK_HARDWARE(fmesa); -} - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -ffbSetDepthFunctions(driRenderbuffer *drb, const GLvisual *vis) -{ - assert(drb->Base.InternalFormat == GL_DEPTH_COMPONENT16); - drb->Base.GetRow = FFBReadDepthSpan; - drb->Base.GetValues = FFBReadDepthPixels; - drb->Base.PutRow = FFBWriteDepthSpan; - drb->Base.PutMonoRow = FFBWriteMonoDepthSpan; - drb->Base.PutValues = FFBWriteDepthPixels; - drb->Base.PutMonoValues = NULL; -} diff --git a/src/mesa/drivers/dri/ffb/ffb_depth.h b/src/mesa/drivers/dri/ffb/ffb_depth.h deleted file mode 100644 index 8a1829ed494..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_depth.h +++ /dev/null @@ -1,7 +0,0 @@ - -#ifndef _FFB_DEPTH_H -#define _FFB_DEPTH_H - -void ffbSetDepthFunctions(driRenderbuffer *drb, const GLvisual *vis); - -#endif /* !(_FFB_DEPTH_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_fifo.h b/src/mesa/drivers/dri/ffb/ffb_fifo.h deleted file mode 100644 index a175f38643d..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_fifo.h +++ /dev/null @@ -1,27 +0,0 @@ - -#ifndef _FFB_FIFO_H -#define _FFB_FIFO_H - -#define FFBFifo(__fmesa, __n) \ -do { ffbScreenPrivate *__fScrn = (__fmesa)->ffbScreen; \ - int __cur_slots = __fScrn->fifo_cache; \ - if ((__cur_slots - (__n)) < 0) { \ - ffb_fbcPtr __ffb = __fmesa->regs; \ - do { __cur_slots = (((int)__ffb->ucsr & FFB_UCSR_FIFO_MASK) - 4); \ - } while ((__cur_slots - (__n)) < 0); \ - } (__fScrn)->fifo_cache = (__cur_slots - (__n)); \ -} while(0) - -#define FFBWait(__fmesa, __ffb) \ -do { ffbScreenPrivate *__fScrn = (__fmesa)->ffbScreen; \ - if (__fScrn->rp_active) { \ - unsigned int __regval = (__ffb)->ucsr; \ - while((__regval & FFB_UCSR_ALL_BUSY) != 0) { \ - __regval = (__ffb)->ucsr; \ - } \ - __fScrn->fifo_cache = ((int)(__regval & FFB_UCSR_FIFO_MASK)) - 4; \ - __fScrn->rp_active = 0; \ - } \ -} while(0) - -#endif /* !(_FFB_FIFO_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_fog.c b/src/mesa/drivers/dri/ffb/ffb_fog.c deleted file mode 100644 index e6eca2390ee..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_fog.c +++ /dev/null @@ -1,73 +0,0 @@ - -/* FFB fog support: - * - * There are two levels of support for FOG in the Creator3D series. - * Both involve a depth cue unit and 1 or 4 slope factors and scales - * for varying the pixel intensity. - * - * Chips prior to FFB2 only have a single set of such settings, FFB2 - * and later have 4 settings. - * - * The basic depth cueing equation is: - * - * C_final = dcsf(z) * C_orig + (1 - dcsf(z)) * C_fog - * - * C_final -- The final color passed to blend unit or frame - * buffer (if blending is disabled). - * - * C_orig -- The color we start with, which comes either from - * the raster processor or cpu writes to the smart - * framebuffer aperture. - * - * C_fog -- This is the "fog" color, ie. the desired color - * at the deepest Z. - * - * dcsf(z) -- The depth cue scale as a function of Z. - * - * With pre-FFB2 chips there are four parameters to control the depth - * cue scaling. Here is a diagram: - * - * 1.0 ------------- - * | | | | - * | | | | - * Sfront XXXXX---+---+ - * | |X | | - * dcsf(z) | | X | | - * | | X| | - * Sback +---+---XXXXX - * | | | | - * 0.0 ------------- - * 0.0 Zf Zb 1.0 - * - * z - * Therefore: - * - * for Zf < z < Zb - * - * dcsf(z) = Sback + ((Sfront - Sback) / (Zf - Zb)) * (Zb - z) - * - * for z <= Zf - * - * dcsf(z) = Sfront - * - * for z >= Zb - * - * dcsf(z) = Sback - * - * With FFB2 and later, 3 more slope regions are provided, the first of - * them starts at the end of the region defined above and ends at a - * specified depth value, the next slop region starts there and ends - * at the next specified depth value, and so on. Each of the 3 slope - * regions also have scale and slope settings of their own. - * - * The C_fog color is programmed into the alpha blending unit color1 - * and color2 registers as follows: - * - * color1: -(C_fog) - * color2: C_fog - bg - * - * If alpha blending is disabled, the bg factor is zero. Note that - * the alpha blending color registers specify each of the RGB values - * as 9 bit 1:8 signed numbers in the range -1.00 to 0.ff inclusive. - * (ie. 0x100 == -1.00 and 0x0ff == +0.ff) - */ diff --git a/src/mesa/drivers/dri/ffb/ffb_lines.c b/src/mesa/drivers/dri/ffb/ffb_lines.c deleted file mode 100644 index 6dca4edd29b..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_lines.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2000, 2001 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "main/mtypes.h" -#include "main/mm.h" -#include "ffb_dd.h" -#include "ffb_span.h" -#include "ffb_context.h" -#include "ffb_vb.h" -#include "ffb_lines.h" - -#undef FFB_LINE_TRACE - -#define FFB_LINE_FLAT_BIT 0x01 -#define FFB_LINE_ALPHA_BIT 0x02 -#define MAX_FFB_LINE_FUNCS 0x04 - -static ffb_line_func ffb_line_tab[MAX_FFB_LINE_FUNCS]; - -/* If the line is not wide, we can support all of the line - * patterning and smooth shading features of OpenGL fully. - */ - -#define IND (0) -#define TAG(x) x -#include "ffb_linetmp.h" - -#define IND (FFB_LINE_FLAT_BIT) -#define TAG(x) x##_flat -#include "ffb_linetmp.h" - -#define IND (FFB_LINE_ALPHA_BIT) -#define TAG(x) x##_alpha -#include "ffb_linetmp.h" - -#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_FLAT_BIT) -#define TAG(x) x##_alpha_flat -#include "ffb_linetmp.h" - -void ffbDDLinefuncInit(void) -{ - init(); - init_flat(); - init_alpha(); - init_alpha_flat(); -} - -static void ffb_dd_line( GLcontext *ctx, GLuint e0, GLuint e1 ) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - ffb_vertex *v0 = &fmesa->verts[e0]; - ffb_vertex *v1 = &fmesa->verts[e1]; - fmesa->draw_line( ctx, v0, v1 ); -} - -void ffbChooseLineState(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint ind = 0; - - tnl->Driver.Render.Line = ffb_dd_line; - - if (flags & DD_FLATSHADE) - ind |= FFB_LINE_FLAT_BIT; - - if ((flags & DD_LINE_STIPPLE) != 0 && - fmesa->lpat == FFB_LPAT_BAD) { - fmesa->draw_line = ffb_fallback_line; - return; - } - - /* If blending or the alpha test is enabled we need to - * provide alpha components to the chip, else we can - * do without it and thus feed vertex data to the chip - * more efficiently. - */ - if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled) - ind |= FFB_LINE_ALPHA_BIT; - - fmesa->draw_line = ffb_line_tab[ind]; -} diff --git a/src/mesa/drivers/dri/ffb/ffb_lines.h b/src/mesa/drivers/dri/ffb/ffb_lines.h deleted file mode 100644 index ddb93656539..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_lines.h +++ /dev/null @@ -1,17 +0,0 @@ - -#ifndef _FFB_LINES_H -#define _FFB_LINES_H - -#include "ffb_context.h" - -#define _FFB_NEW_LINE (_DD_NEW_FLATSHADE | \ - _DD_NEW_LINE_WIDTH | \ - _DD_NEW_LINE_STIPPLE | \ - _DD_NEW_LINE_SMOOTH | \ - _NEW_COLOR) - -extern void ffbDDLinefuncInit(void); -extern void ffbChooseLineState(GLcontext *); -extern void ffb_fallback_line( GLcontext *ctx, ffb_vertex *v0, ffb_vertex *v1 ); - -#endif /* !(_FFB_LINES_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_linetmp.h b/src/mesa/drivers/dri/ffb/ffb_linetmp.h deleted file mode 100644 index 10e1375259b..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_linetmp.h +++ /dev/null @@ -1,80 +0,0 @@ - -static INLINE void TAG(ffb_line)(GLcontext *ctx, ffb_vertex *v0, - ffb_vertex *v1 ) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - ffb_fbcPtr ffb = fmesa->regs; -#if (IND & FFB_LINE_FLAT_BIT) - const GLuint const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( v1->color[0] ); -#endif - FFB_DELAYED_VIEWPORT_VARS; - -#ifdef FFB_LINE_TRACE - fprintf(stderr, "FFB: ffb_line [" -#if (IND & FFB_LINE_FLAT_BIT) - " FLAT" -#endif -#if (IND & FFB_LINE_ALPHA_BIT) - " ALPHA" -#endif - " ]\n"); -#endif - -#if (IND & FFB_LINE_FLAT_BIT) - FFBFifo(fmesa, 1); - ffb->fg = const_fg; -#ifdef FFB_LINE_TRACE - fprintf(stderr, "FFB: ffb_line confg_fg[%08x]\n", const_fg); -#endif -#endif - -#if (IND & FFB_LINE_FLAT_BIT) - /* (2 * 3) + 1 */ - FFBFifo(fmesa, 7); -#else -#if (IND & FFB_LINE_ALPHA_BIT) - /* (2 * 7) + 1 */ - FFBFifo(fmesa, 15); -#else - /* (2 * 6) + 1 */ - FFBFifo(fmesa, 13); -#endif -#endif - - /* Using DDLINE or AALINE, init the line pattern state. */ - ffb->lpat = fmesa->lpat; - -#if !(IND & FFB_LINE_FLAT_BIT) -#if (IND & FFB_LINE_ALPHA_BIT) - ffb->alpha = FFB_GET_ALPHA(v0); -#endif - ffb->red = FFB_GET_RED(v0); - ffb->green = FFB_GET_GREEN(v0); - ffb->blue = FFB_GET_BLUE(v0); -#endif - ffb->z = FFB_GET_Z(v0); - ffb->ryf = FFB_GET_Y(v0); - ffb->rxf = FFB_GET_X(v0); - -#if !(IND & FFB_LINE_FLAT_BIT) -#if (IND & FFB_LINE_ALPHA_BIT) - ffb->alpha = FFB_GET_ALPHA(v1); -#endif - ffb->red = FFB_GET_RED(v1); - ffb->green = FFB_GET_GREEN(v1); - ffb->blue = FFB_GET_BLUE(v1); -#endif - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - - fmesa->ffbScreen->rp_active = 1; -} - -static void TAG(init)(void) -{ - ffb_line_tab[IND] = TAG(ffb_line); -} - -#undef IND -#undef TAG diff --git a/src/mesa/drivers/dri/ffb/ffb_lock.h b/src/mesa/drivers/dri/ffb/ffb_lock.h deleted file mode 100644 index 1fd3eb55125..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_lock.h +++ /dev/null @@ -1,36 +0,0 @@ - -#ifndef _FFB_LOCK_H -#define _FFB_LOCK_H - -#include "ffb_context.h" - -extern void ffbXMesaUpdateState(ffbContextPtr fmesa); -#define FFB_UPDATE_STATE(fmesa) ffbXMesaUpdateState(fmesa) - -/* Lock the hardware and validate our state. This hardware can only ever - * exist on SPARC platforms. Don't bother building the real LOCK_HARDWARE and - * UNLOCK_HARDWARE code on non-SPARC platforms. The only reason the driver - * gets built on non-SPARC is to catch build breakages earlier. - */ -#if !defined(__sparc__) -#define LOCK_HARDWARE(fmesa) -#define UNLOCK_HARDWARE(fmesa) -#else -#define LOCK_HARDWARE(fmesa) \ - do { \ - DRM_CAS_RESULT(__ret); \ - DRM_CAS(fmesa->driHwLock, fmesa->hHWContext, \ - (DRM_LOCK_HELD | fmesa->hHWContext), __ret);\ - if (__ret) { \ - drmGetLock(fmesa->driFd, fmesa->hHWContext, 0); \ - FFB_UPDATE_STATE(fmesa); \ - } \ - } while (0) - - -/* Unlock the hardware. */ -#define UNLOCK_HARDWARE(fmesa) \ - DRM_UNLOCK(fmesa->driFd, fmesa->driHwLock, fmesa->hHWContext); -#endif - -#endif /* !(_FFB_LOCK_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_points.c b/src/mesa/drivers/dri/ffb/ffb_points.c deleted file mode 100644 index 5bf4f8f0707..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_points.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2000, 2001 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "main/mtypes.h" -#include "ffb_dd.h" -#include "ffb_context.h" -#include "ffb_vb.h" -#include "ffb_points.h" - - -#undef FFB_POINT_TRACE - -#define FFB_POINT_AA_BIT 0x01 - -static ffb_point_func ffb_point_tab[0x08]; - -#define IND (0) -#define TAG(x) x -#include "ffb_pointtmp.h" - -#define IND (FFB_POINT_AA_BIT) -#define TAG(x) x##_aa -#include "ffb_pointtmp.h" - -void ffbDDPointfuncInit(void) -{ - init(); - init_aa(); -} - -static void ffb_dd_points( GLcontext *ctx, GLuint first, GLuint last ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb; - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - ffb_vertex *fverts = fmesa->verts; - int i; - - if (VB->Elts == 0) { - for ( i = first ; i < last ; i++ ) { - if ( VB->ClipMask[i] == 0 ) { - fmesa->draw_point( ctx, &fverts[i] ); - } - } - } else { - for ( i = first ; i < last ; i++ ) { - GLuint e = VB->Elts[i]; - if ( VB->ClipMask[e] == 0 ) { - fmesa->draw_point( ctx, &fverts[e] ); - } - } - } -} - -void ffbChoosePointState(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint ind = 0; - - tnl->Driver.Render.Points = ffb_dd_points; - - if (flags & DD_POINT_SMOOTH) - ind |= FFB_POINT_AA_BIT; - - fmesa->draw_point = ffb_point_tab[ind]; -} diff --git a/src/mesa/drivers/dri/ffb/ffb_points.h b/src/mesa/drivers/dri/ffb/ffb_points.h deleted file mode 100644 index a7229de7f19..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_points.h +++ /dev/null @@ -1,14 +0,0 @@ - -#ifndef _FFB_POINTS_H -#define _FFB_POINTS_H - -extern void ffbDDPointfuncInit(void); - -#define _FFB_NEW_POINT (_DD_NEW_POINT_SIZE | \ - _DD_NEW_POINT_SMOOTH | \ - _NEW_COLOR) - -extern void ffbChoosePointState(GLcontext *); -extern void ffb_fallback_point( GLcontext *ctx, ffb_vertex *v0 ); - -#endif /* !(_FFB_POINTS_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_pointtmp.h b/src/mesa/drivers/dri/ffb/ffb_pointtmp.h deleted file mode 100644 index 3003de70c69..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_pointtmp.h +++ /dev/null @@ -1,54 +0,0 @@ - -static INLINE void TAG(ffb_draw_point)(GLcontext *ctx, ffb_vertex *tmp ) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - ffb_fbcPtr ffb = fmesa->regs; - FFB_DELAYED_VIEWPORT_VARS; - -#ifdef FFB_POINT_TRACE - fprintf(stderr, "FFB: ffb_point [" -#if (IND & FFB_POINT_AA_BIT) - "AA" -#endif - "] X(%f) Y(%f) Z(%f)\n", - tmp->x, tmp->y, tmp->z); -#endif - -#if (IND & FFB_POINT_AA_BIT) - FFBFifo(fmesa, 4); - - ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( tmp->color[0] ); - ffb->z = FFB_GET_Z(tmp); - ffb->y = FFB_GET_Y(tmp) + 0x8000 /* FIX ME */; - ffb->x = FFB_GET_X(tmp) + 0x8000 /* FIX ME */; -#else - { - unsigned int const_fg, const_z, h, w; - - const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( tmp->color[0] ); - const_z = Z_FROM_MESA(FFB_Z_TO_FLOAT(FFB_GET_Z(tmp))); - h = FFB_GET_Y(tmp) >> 16; - w = FFB_GET_X(tmp) >> 16; -#ifdef FFB_POINT_TRACE - fprintf(stderr, "FFB: ffb_point fg(%08x) z(%08x) h(%08x) w(%08x)\n", - const_fg, const_z, h, w); -#endif - FFBFifo(fmesa, 4); - ffb->fg = const_fg; - ffb->constz = const_z; - ffb->bh = h; - ffb->bw = w; - } -#endif - - fmesa->ffbScreen->rp_active = 1; -} - - -static void TAG(init)(void) -{ - ffb_point_tab[IND] = TAG(ffb_draw_point); -} - -#undef IND -#undef TAG diff --git a/src/mesa/drivers/dri/ffb/ffb_rendertmp.h b/src/mesa/drivers/dri/ffb/ffb_rendertmp.h deleted file mode 100644 index 64141c2c5f6..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_rendertmp.h +++ /dev/null @@ -1,645 +0,0 @@ - -#define IMPL_LOCAL_VARS \ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); \ - ffb_fbcPtr ffb = fmesa->regs; \ - const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \ - FFB_DELAYED_VIEWPORT_VARS; \ - (void) fmesa; (void) ffb; (void) elt - -#if (IND & FFB_FLAT_BIT) -#define FFB_DECLARE_CACHED_COLOR(NAME) \ - unsigned int NAME; -#define FFB_COMPUTE_CACHED_COLOR(NAME, VTX) \ - NAME = FFB_PACK_CONST_UBYTE_ARGB_COLOR((VTX)->color[0]) -#define FFB_CACHED_COLOR_SAME(NAME1, NAME2) \ - ((NAME1) == (NAME2)) -#define FFB_CACHED_COLOR_SET(NAME) \ - ffb->fg = (NAME) -#define FFB_CACHED_COLOR_UPDATE(NAME1, NAME2) \ - ffb->fg = (NAME1) = (NAME2) -#define FFB_SET_PRIM_COLOR(COLOR_VERTEX) \ - ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR((COLOR_VERTEX)->color[0]) -#define FFB_PRIM_COLOR_COST 1 -#define FFB_SET_VERTEX_COLOR(VTX) /**/ -#define FFB_VERTEX_COLOR_COST 0 -#else -#define FFB_DECLARE_CACHED_COLOR(NAME) /**/ -#define FFB_COMPUTE_CACHED_COLOR(NAME, VTX) /**/ -#define FFB_CACHED_COLOR_SAME(NAME1, NAME2) 0 -#define FFB_CACHED_COLOR_SET(NAME1) /**/ -#define FFB_CACHED_COLOR_UPDATE(NAME1, NAME2) /**/ -#define FFB_SET_PRIM_COLOR(COLOR_VERTEX) /**/ -#define FFB_PRIM_COLOR_COST 0 -#if (IND & FFB_ALPHA_BIT) -#define FFB_SET_VERTEX_COLOR(VTX) \ - ffb->alpha = FFB_GET_ALPHA(VTX); \ - ffb->red = FFB_GET_RED(VTX); \ - ffb->green = FFB_GET_GREEN(VTX); \ - ffb->blue = FFB_GET_BLUE(VTX) -#define FFB_VERTEX_COLOR_COST 4 -#else -#define FFB_SET_VERTEX_COLOR(VTX) \ - ffb->red = FFB_GET_RED(VTX); \ - ffb->green = FFB_GET_GREEN(VTX); \ - ffb->blue = FFB_GET_BLUE(VTX) -#define FFB_VERTEX_COLOR_COST 3 -#endif -#endif - -#define RESET_STIPPLE ffb->lpat = fmesa->lpat; - -#if !(IND & (FFB_TRI_CULL_BIT)) -static void TAG(ffb_vb_points)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags) -{ - GLint i; - IMPL_LOCAL_VARS; - -#ifdef FFB_RENDER_TRACE - fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n", - __FUNCTION__, start, count, flags); -#endif - ffbRenderPrimitive(ctx, GL_POINTS); - if (ctx->_TriangleCaps & DD_POINT_SMOOTH) { - for (i = start; i < count; i++) { - ffb_vertex *v0 = &fmesa->verts[ELT(i)]; - - FFBFifo(fmesa, 4); - ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR(v0->color[0]); - ffb->z = FFB_GET_Z(v0); - ffb->y = FFB_GET_Y(v0) + 0x8000 /* FIX ME */; - ffb->x = FFB_GET_X(v0) + 0x8000 /* FIX ME */; - } - } else { - for (i = start; i < count; i++) { - ffb_vertex *v0 = &fmesa->verts[ELT(i)]; - FFBFifo(fmesa, 4); - ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR(v0->color[0]); - ffb->constz = Z_FROM_MESA(FFB_Z_TO_FLOAT(FFB_GET_Z(v0))); - ffb->bh = FFB_GET_Y(v0) >> 16; - ffb->bw = FFB_GET_X(v0) >> 16; - } - } - - fmesa->ffbScreen->rp_active = 1; -} - -static void TAG(ffb_vb_lines)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags) -{ - GLint i; - IMPL_LOCAL_VARS; - -#ifdef FFB_RENDER_TRACE - fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n", - __FUNCTION__, start, count, flags); -#endif - ffbRenderPrimitive(ctx, GL_LINES); - for (i = start + 1; i < count; i += 2) { - ffb_vertex *v0 = &fmesa->verts[i - 1]; - ffb_vertex *v1 = &fmesa->verts[i - 0]; - - FFBFifo(fmesa, (1 + FFB_PRIM_COLOR_COST + - (FFB_VERTEX_COLOR_COST * 2) + 6)); - - RESET_STIPPLE; - - FFB_SET_PRIM_COLOR(v1); - - FFB_SET_VERTEX_COLOR(v0); - ffb->z = FFB_GET_Z(v0); - ffb->ryf = FFB_GET_Y(v0); - ffb->rxf = FFB_GET_X(v0); - - FFB_SET_VERTEX_COLOR(v1); - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - } -} - -static void TAG(ffb_vb_line_loop)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags) -{ - GLint i; - IMPL_LOCAL_VARS; - -#ifdef FFB_RENDER_TRACE - fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n", - __FUNCTION__, start, count, flags); -#endif - ffbRenderPrimitive(ctx, GL_LINE_LOOP); - if ((flags & PRIM_BEGIN) != 0) { - ffb_vertex *v0 = &fmesa->verts[ELT(start + 0)]; - ffb_vertex *v1 = &fmesa->verts[ELT(start + 1)]; - - FFBFifo(fmesa, (1 + FFB_PRIM_COLOR_COST + - ((FFB_VERTEX_COLOR_COST * 2) + (3 * 2)))); - - RESET_STIPPLE; - - FFB_SET_PRIM_COLOR(v1); - - FFB_SET_VERTEX_COLOR(v0); - ffb->z = FFB_GET_Z(v0); - ffb->ryf = FFB_GET_Y(v0); - ffb->rxf = FFB_GET_X(v0); - - FFB_SET_VERTEX_COLOR(v1); - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - } - for (i = start + 2; i < count; i++) { - ffb_vertex *v0 = &fmesa->verts[ELT(i)]; - - FFBFifo(fmesa, (FFB_PRIM_COLOR_COST + - (FFB_VERTEX_COLOR_COST + 3))); - - FFB_SET_PRIM_COLOR(v0); - - FFB_SET_VERTEX_COLOR(v0); - ffb->z = FFB_GET_Z(v0); - ffb->y = FFB_GET_Y(v0); - ffb->x = FFB_GET_X(v0); - } - if ((flags & PRIM_END) != 0) { - ffb_vertex *v0 = &fmesa->verts[ELT(start)]; - - FFBFifo(fmesa, (FFB_PRIM_COLOR_COST + - (FFB_VERTEX_COLOR_COST + 3))); - - FFB_SET_PRIM_COLOR(v0); - - FFB_SET_VERTEX_COLOR(v0); - ffb->z = FFB_GET_Z(v0); - ffb->y = FFB_GET_Y(v0); - ffb->x = FFB_GET_X(v0); - } - - fmesa->ffbScreen->rp_active = 1; -} - -static void TAG(ffb_vb_line_strip)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags) -{ - GLint i; - FFB_DECLARE_CACHED_COLOR(cached_fg) - IMPL_LOCAL_VARS; - -#ifdef FFB_RENDER_TRACE - fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n", - __FUNCTION__, start, count, flags); -#endif - ffbRenderPrimitive(ctx, GL_LINE_STRIP); - FFBFifo(fmesa, (1 + FFB_PRIM_COLOR_COST + - ((FFB_VERTEX_COLOR_COST * 2) + (3 * 2)))); - - RESET_STIPPLE; - - { - ffb_vertex *v0 = &fmesa->verts[ELT(start + 0)]; - ffb_vertex *v1 = &fmesa->verts[ELT(start + 1)]; - - FFB_COMPUTE_CACHED_COLOR(cached_fg, v0); - FFB_CACHED_COLOR_SET(cached_fg); - - FFB_SET_VERTEX_COLOR(v0); - ffb->z = FFB_GET_Z(v0); - ffb->ryf = FFB_GET_Y(v0); - ffb->rxf = FFB_GET_X(v0); - - FFB_SET_VERTEX_COLOR(v1); - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - } - - for (i = start + 2; i < count; i++) { - ffb_vertex *v1 = &fmesa->verts[ELT(i - 0)]; - FFB_DECLARE_CACHED_COLOR(new_fg) - - FFB_COMPUTE_CACHED_COLOR(new_fg, v1); - if (FFB_CACHED_COLOR_SAME(cached_fg, new_fg)) { - FFBFifo(fmesa, ((FFB_VERTEX_COLOR_COST * 1) + (3 * 1))); - } else { - FFBFifo(fmesa, (FFB_PRIM_COLOR_COST + - (FFB_VERTEX_COLOR_COST * 1) + (3 * 1))); - FFB_CACHED_COLOR_UPDATE(cached_fg, new_fg); - } - - FFB_SET_VERTEX_COLOR(v1); - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - } - - fmesa->ffbScreen->rp_active = 1; -} -#endif /* !(IND & (FFB_TRI_CULL_BIT)) */ - -/* OK, now things start getting fun :-) */ -#if (IND & (FFB_TRI_CULL_BIT)) -#define FFB_AREA_DECLARE GLfloat cc, ex, ey, fx, fy; -#define FFB_COMPUTE_AREA_TRI(V0, V1, V2) \ -{ ex = (V1)->x - (V0)->x; \ - ey = (V1)->y - (V0)->y; \ - fx = (V2)->x - (V0)->x; \ - fy = (V2)->y - (V0)->y; \ - cc = ex*fy-ey*fx; \ -} -#define FFB_COMPUTE_AREA_QUAD(V0, V1, V2, V3) \ -{ ex = (V2)->x - (V0)->x; \ - ey = (V2)->y - (V0)->y; \ - fx = (V3)->x - (V1)->x; \ - fy = (V3)->y - (V1)->y; \ - cc = ex*fy-ey*fx; \ -} -#else -#define FFB_AREA_DECLARE /**/ -#define FFB_COMPUTE_AREA_TRI(V0, V1, V2) do { } while(0) -#define FFB_COMPUTE_AREA_QUAD(V0, V1, V2, V3) do { } while(0) -#endif - -#if (IND & FFB_TRI_CULL_BIT) -#define FFB_CULL_TRI(CULL_ACTION) \ - if (cc * fmesa->backface_sign > fmesa->ffb_zero) { \ - CULL_ACTION \ - } -#define FFB_CULL_QUAD(CULL_ACTION) \ - if (cc * fmesa->backface_sign > fmesa->ffb_zero) { \ - CULL_ACTION \ - } -#else -#define FFB_CULL_TRI(CULL_ACTION) do { } while (0) -#define FFB_CULL_QUAD(CULL_ACTION) do { } while (0) -#endif - -static void TAG(ffb_vb_triangles)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags) -{ - GLint i; - IMPL_LOCAL_VARS; - -#ifdef FFB_RENDER_TRACE - fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n", - __FUNCTION__, start, count, flags); -#endif - ffbRenderPrimitive(ctx, GL_TRIANGLES); - for (i = start + 2; i < count; i += 3) { - ffb_vertex *v0 = &fmesa->verts[ELT(i - 2)]; - ffb_vertex *v1 = &fmesa->verts[ELT(i - 1)]; - ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)]; - FFB_AREA_DECLARE - - FFB_COMPUTE_AREA_TRI(v0, v1, v2); - FFB_CULL_TRI(continue;); - - FFBFifo(fmesa, (FFB_PRIM_COLOR_COST + - (FFB_VERTEX_COLOR_COST * 3) + 9)); - FFB_SET_PRIM_COLOR(v2); - - FFB_SET_VERTEX_COLOR(v0); - ffb->z = FFB_GET_Z(v0); - ffb->ryf = FFB_GET_Y(v0); - ffb->rxf = FFB_GET_X(v0); - - FFB_SET_VERTEX_COLOR(v1); - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - - FFB_SET_VERTEX_COLOR(v2); - ffb->z = FFB_GET_Z(v2); - ffb->y = FFB_GET_Y(v2); - ffb->x = FFB_GET_X(v2); - } - - fmesa->ffbScreen->rp_active = 1; -} - -static void TAG(ffb_vb_tri_strip)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags) -{ - GLint i; - GLint parity = 0; - IMPL_LOCAL_VARS; - -#ifdef FFB_RENDER_TRACE - fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n", - __FUNCTION__, start, count, flags); -#endif - ffbRenderPrimitive(ctx, GL_TRIANGLE_STRIP); - - i = start + 2; - goto something_clipped; - - something_clipped: - for (; i < count; i++, parity ^= 1) { - ffb_vertex *v0 = &fmesa->verts[ELT(i - 2 + parity)]; - ffb_vertex *v1 = &fmesa->verts[ELT(i - 1 - parity)]; - ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)]; - FFB_AREA_DECLARE - - FFB_COMPUTE_AREA_TRI(v0, v1, v2); - FFB_CULL_TRI(continue;); - - FFBFifo(fmesa, (FFB_PRIM_COLOR_COST + - (FFB_VERTEX_COLOR_COST * 3) + 9)); - FFB_SET_PRIM_COLOR(v2); - - FFB_SET_VERTEX_COLOR(v0); - ffb->z = FFB_GET_Z(v0); - ffb->ryf = FFB_GET_Y(v0); - ffb->rxf = FFB_GET_X(v0); - - FFB_SET_VERTEX_COLOR(v1); - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - - FFB_SET_VERTEX_COLOR(v2); - ffb->z = FFB_GET_Z(v2); - ffb->y = FFB_GET_Y(v2); - ffb->x = FFB_GET_X(v2); - - i++; - parity ^= 1; - break; - } - - for (; i < count; i++, parity ^= 1) { - ffb_vertex *v0 = &fmesa->verts[ELT(i - 2 + parity)]; - ffb_vertex *v1 = &fmesa->verts[ELT(i - 1 - parity)]; - ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)]; - FFB_AREA_DECLARE - (void) v0; (void) v1; - - FFB_COMPUTE_AREA_TRI(v0, v1, v2); - FFB_CULL_TRI(i++; parity^=1; goto something_clipped;); - - FFBFifo(fmesa, (FFB_PRIM_COLOR_COST + - (FFB_VERTEX_COLOR_COST * 1) + 3)); - FFB_SET_PRIM_COLOR(v2); - - FFB_SET_VERTEX_COLOR(v2); - ffb->z = FFB_GET_Z(v2); - ffb->y = FFB_GET_Y(v2); - ffb->x = FFB_GET_X(v2); - } - - fmesa->ffbScreen->rp_active = 1; -} - -static void TAG(ffb_vb_tri_fan)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags) -{ - GLint i; - IMPL_LOCAL_VARS; - -#ifdef FFB_RENDER_TRACE - fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n", - __FUNCTION__, start, count, flags); -#endif - ffbRenderPrimitive(ctx, GL_TRIANGLE_FAN); - - i = start + 2; - goto something_clipped; - - something_clipped: - for ( ; i < count; i++) { - ffb_vertex *v0 = &fmesa->verts[ELT(start)]; - ffb_vertex *v1 = &fmesa->verts[ELT(i - 1)]; - ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)]; - FFB_AREA_DECLARE - - FFB_COMPUTE_AREA_TRI(v0, v1, v2); - FFB_CULL_TRI(continue;); - - FFBFifo(fmesa, (FFB_PRIM_COLOR_COST + - (FFB_VERTEX_COLOR_COST * 3) + 9)); - FFB_SET_PRIM_COLOR(v2); - - FFB_SET_VERTEX_COLOR(v0); - ffb->z = FFB_GET_Z(v0); - ffb->ryf = FFB_GET_Y(v0); - ffb->rxf = FFB_GET_X(v0); - - FFB_SET_VERTEX_COLOR(v1); - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - - FFB_SET_VERTEX_COLOR(v2); - ffb->z = FFB_GET_Z(v2); - ffb->y = FFB_GET_Y(v2); - ffb->x = FFB_GET_X(v2); - - i++; - break; - } - - for (; i < count; i++) { - ffb_vertex *v0 = &fmesa->verts[ELT(start)]; - ffb_vertex *v1 = &fmesa->verts[ELT(i - 1)]; - ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)]; - FFB_AREA_DECLARE - (void) v0; (void) v1; - - FFB_COMPUTE_AREA_TRI(v0, v1, v2); - FFB_CULL_TRI(i++; goto something_clipped;); - - FFBFifo(fmesa, (FFB_PRIM_COLOR_COST + - (FFB_VERTEX_COLOR_COST * 1) + 3)); - FFB_SET_PRIM_COLOR(v2); - - FFB_SET_VERTEX_COLOR(v2); - ffb->z = FFB_GET_Z(v2); - ffb->dmyf = FFB_GET_Y(v2); - ffb->dmxf = FFB_GET_X(v2); - } - - fmesa->ffbScreen->rp_active = 1; -} - -static void TAG(ffb_vb_poly)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags) -{ - GLint i; - IMPL_LOCAL_VARS; - -#ifdef FFB_RENDER_TRACE - fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n", - __FUNCTION__, start, count, flags); -#endif - ffbRenderPrimitive(ctx, GL_POLYGON); - - /* XXX Optimize XXX */ - for (i = start + 2; i < count; i++) { - ffb_vertex *v0 = &fmesa->verts[ELT(i - 1)]; - ffb_vertex *v1 = &fmesa->verts[ELT(i)]; - ffb_vertex *v2 = &fmesa->verts[ELT(start)]; - FFB_AREA_DECLARE - - FFB_COMPUTE_AREA_TRI(v0, v1, v2); - FFB_CULL_TRI(continue;); - - FFBFifo(fmesa, (FFB_PRIM_COLOR_COST + - (FFB_VERTEX_COLOR_COST * 3) + 9)); - FFB_SET_PRIM_COLOR(v2); - - FFB_SET_VERTEX_COLOR(v0); - ffb->z = FFB_GET_Z(v0); - ffb->ryf = FFB_GET_Y(v0); - ffb->rxf = FFB_GET_X(v0); - - FFB_SET_VERTEX_COLOR(v1); - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - - FFB_SET_VERTEX_COLOR(v2); - ffb->z = FFB_GET_Z(v2); - ffb->y = FFB_GET_Y(v2); - ffb->x = FFB_GET_X(v2); - } - - fmesa->ffbScreen->rp_active = 1; -} - -static void TAG(ffb_vb_quads)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags) -{ - GLint i; - IMPL_LOCAL_VARS; - -#ifdef FFB_RENDER_TRACE - fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n", - __FUNCTION__, start, count, flags); -#endif - ffbRenderPrimitive(ctx, GL_QUADS); - - for (i = start + 3; i < count; i += 4) { - ffb_vertex *v0 = &fmesa->verts[ELT(i - 3)]; - ffb_vertex *v1 = &fmesa->verts[ELT(i - 2)]; - ffb_vertex *v2 = &fmesa->verts[ELT(i - 1)]; - ffb_vertex *v3 = &fmesa->verts[ELT(i - 0)]; - FFB_AREA_DECLARE - - FFB_COMPUTE_AREA_QUAD(v0, v1, v2, v3); - FFB_CULL_QUAD(continue;); - - FFBFifo(fmesa, (FFB_PRIM_COLOR_COST + - (FFB_VERTEX_COLOR_COST * 4) + 12)); - FFB_SET_PRIM_COLOR(v3); - - FFB_SET_VERTEX_COLOR(v0); - ffb->z = FFB_GET_Z(v0); - ffb->ryf = FFB_GET_Y(v0); - ffb->rxf = FFB_GET_X(v0); - - FFB_SET_VERTEX_COLOR(v1); - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - - FFB_SET_VERTEX_COLOR(v2); - ffb->z = FFB_GET_Z(v2); - ffb->y = FFB_GET_Y(v2); - ffb->x = FFB_GET_X(v2); - - FFB_SET_VERTEX_COLOR(v3); - ffb->z = FFB_GET_Z(v3); - ffb->dmyf = FFB_GET_Y(v3); - ffb->dmxf = FFB_GET_X(v3); - } - - fmesa->ffbScreen->rp_active = 1; -} - -static void TAG(ffb_vb_quad_strip)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags) -{ - GLint i; - IMPL_LOCAL_VARS; - -#ifdef FFB_RENDER_TRACE - fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n", - __FUNCTION__, start, count, flags); -#endif - ffbRenderPrimitive(ctx, GL_QUAD_STRIP); - - /* XXX Optimize XXX */ - for (i = start + 3; i < count; i += 2) { - ffb_vertex *v0 = &fmesa->verts[ELT(i - 1)]; - ffb_vertex *v1 = &fmesa->verts[ELT(i - 3)]; - ffb_vertex *v2 = &fmesa->verts[ELT(i - 2)]; - ffb_vertex *v3 = &fmesa->verts[ELT(i - 0)]; - FFB_AREA_DECLARE - - FFB_COMPUTE_AREA_QUAD(v0, v1, v2, v3); - FFB_CULL_QUAD(continue;); - - FFBFifo(fmesa, (FFB_PRIM_COLOR_COST + - (FFB_VERTEX_COLOR_COST * 4) + 12)); - FFB_SET_PRIM_COLOR(v3); - - FFB_DUMP_VERTEX(v0); - FFB_SET_VERTEX_COLOR(v0); - ffb->z = FFB_GET_Z(v0); - ffb->ryf = FFB_GET_Y(v0); - ffb->rxf = FFB_GET_X(v0); - - FFB_DUMP_VERTEX(v1); - FFB_SET_VERTEX_COLOR(v1); - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - - FFB_DUMP_VERTEX(v2); - FFB_SET_VERTEX_COLOR(v2); - ffb->z = FFB_GET_Z(v2); - ffb->y = FFB_GET_Y(v2); - ffb->x = FFB_GET_X(v2); - - FFB_DUMP_VERTEX(v3); - FFB_SET_VERTEX_COLOR(v3); - ffb->z = FFB_GET_Z(v3); - ffb->dmyf = FFB_GET_Y(v3); - ffb->dmxf = FFB_GET_X(v3); - } - - fmesa->ffbScreen->rp_active = 1; -} - -static void (*TAG(render_tab)[GL_POLYGON + 2])(GLcontext *, GLuint, GLuint, GLuint) = -{ -#if !(IND & (FFB_TRI_CULL_BIT)) - TAG(ffb_vb_points), - TAG(ffb_vb_lines), - TAG(ffb_vb_line_loop), - TAG(ffb_vb_line_strip), -#else - NULL, - NULL, - NULL, - NULL, -#endif - TAG(ffb_vb_triangles), - TAG(ffb_vb_tri_strip), - TAG(ffb_vb_tri_fan), - TAG(ffb_vb_quads), - TAG(ffb_vb_quad_strip), - TAG(ffb_vb_poly), - ffb_vb_noop, -}; - -#undef IND -#undef TAG - -#undef IMPL_LOCAL_VARS -#undef FFB_DECLARE_CACHED_COLOR -#undef FFB_COMPUTE_CACHED_COLOR -#undef FFB_CACHED_COLOR_SAME -#undef FFB_CACHED_COLOR_SET -#undef FFB_CACHED_COLOR_UPDATE -#undef FFB_SET_PRIM_COLOR -#undef FFB_PRIM_COLOR_COST -#undef FFB_SET_VERTEX_COLOR -#undef FFB_VERTEX_COLOR_COST -#undef RESET_STIPPLE -#undef FFB_AREA_DECLARE -#undef FFB_COMPUTE_AREA_TRI -#undef FFB_COMPUTE_AREA_QUAD -#undef FFB_CULL_TRI -#undef FFB_CULL_QUAD diff --git a/src/mesa/drivers/dri/ffb/ffb_span.c b/src/mesa/drivers/dri/ffb/ffb_span.c deleted file mode 100644 index 61901cccadd..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_span.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2000 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "main/mtypes.h" -#include "ffb_dd.h" -#include "ffb_span.h" -#include "ffb_context.h" -#include "ffb_lock.h" - -#define DBG 0 - -#define HW_LOCK() \ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); \ - if (!fmesa->hw_locked) \ - LOCK_HARDWARE(fmesa); - -#define HW_UNLOCK() \ - if (!fmesa->hw_locked) \ - UNLOCK_HARDWARE(fmesa); \ - -#define LOCAL_VARS \ - __DRIdrawable *dPriv = fmesa->driDrawable; \ - GLuint height = dPriv->h; \ - GLuint p; \ - char *buf; \ - (void) p - -#define INIT_MONO_PIXEL(p, color) \ - p = ((color[0] << 0) | \ - (color[1] << 8) | \ - (color[2] << 16)) - -/* We use WID clipping, so this test always passes. */ -#define CLIPPIXEL(__x, __y) (1) - -/* And also, due to WID clipping, we need not do anything - * special here. - */ -#define CLIPSPAN(__x,__y,__n,__x1,__n1,__i) \ - __n1 = __n; \ - __x1 = __x; \ - -#define HW_CLIPLOOP() \ -do { unsigned int fbc, ppc, cmp; \ - FFBWait(fmesa, fmesa->regs); \ - fbc = fmesa->regs->fbc; ppc = fmesa->regs->ppc; cmp = fmesa->regs->cmp; \ - fmesa->regs->fbc = ((fbc & \ - ~(FFB_FBC_WB_C | FFB_FBC_ZE_MASK | FFB_FBC_RGBE_MASK)) \ - | (FFB_FBC_ZE_OFF | FFB_FBC_RGBE_MASK)); \ - fmesa->regs->ppc = ((ppc & \ - ~(FFB_PPC_XS_MASK | FFB_PPC_ABE_MASK | FFB_PPC_DCE_MASK | \ - FFB_PPC_APE_MASK | FFB_PPC_CS_MASK)) \ - | (FFB_PPC_XS_WID | FFB_PPC_ABE_DISABLE | \ - FFB_PPC_DCE_DISABLE | FFB_PPC_APE_DISABLE | \ - FFB_PPC_CS_VAR)); \ - fmesa->regs->cmp = ((cmp & ~(0xff << 16)) | (0x80 << 16)); \ - fmesa->ffbScreen->rp_active = 1; \ - FFBWait(fmesa, fmesa->regs); \ - buf = (char *)(fmesa->sfb32 + (dPriv->x << 2) + (dPriv->y << 13));\ - if (dPriv->numClipRects) { - -#define HW_ENDCLIPLOOP() \ - } \ - fmesa->regs->fbc = fbc; \ - fmesa->regs->ppc = ppc; \ - fmesa->regs->cmp = cmp; \ - fmesa->ffbScreen->rp_active = 1; \ -} while(0) - -#define Y_FLIP(__y) (height - __y - 1) - -#define READ_RGBA(rgba,__x,__y) \ -do { GLuint p = *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)); \ - rgba[0] = (p >> 0) & 0xff; \ - rgba[1] = (p >> 8) & 0xff; \ - rgba[2] = (p >> 16) & 0xff; \ - rgba[3] = 0xff; \ -} while(0) - -#define WRITE_RGBA(__x, __y, __r, __g, __b, __a) \ - *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)) = \ - ((((__r) & 0xff) << 0) | \ - (((__g) & 0xff) << 8) | \ - (((__b) & 0xff) << 16)) - -#define WRITE_PIXEL(__x, __y, __p) \ - *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)) = (__p) - -#define TAG(x) ffb##x##_888 - -#include "spantmp.h" - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -ffbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis) -{ - assert(vis->redBits == 8); - assert(vis->greenBits == 8); - assert(vis->blueBits == 8); - ffbInitPointers_888(&drb->Base); -} diff --git a/src/mesa/drivers/dri/ffb/ffb_span.h b/src/mesa/drivers/dri/ffb/ffb_span.h deleted file mode 100644 index 37506cf30e6..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_span.h +++ /dev/null @@ -1,9 +0,0 @@ - -#ifndef _FFB_SPAN_H -#define _FFB_SPAN_H - -#include "drirenderbuffer.h" - -void ffbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis); - -#endif /* !(_FFB_SPAN_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_state.c b/src/mesa/drivers/dri/ffb/ffb_state.c deleted file mode 100644 index c09d2fef838..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_state.c +++ /dev/null @@ -1,1222 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2000, 2001 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "main/mtypes.h" -#include "main/colormac.h" -#include "main/enums.h" - -#include "vbo/vbo.h" -#include "tnl/tnl.h" -#include "tnl/t_pipeline.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" - -#include "ffb_dd.h" -#include "ffb_span.h" -#include "ffb_context.h" -#include "ffb_tris.h" -#include "ffb_state.h" - -#undef STATE_TRACE - -static unsigned int ffbComputeAlphaFunc(GLcontext *ctx) -{ - unsigned int xclip; - GLubyte alphaRef; - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDAlphaFunc: func(%s) ref(%02x)\n", - _mesa_lookup_enum_by_nr(ctx->Color.AlphaFunc), - ctx->Color.AlphaRef & 0xff); -#endif - - switch (ctx->Color.AlphaFunc) { - case GL_NEVER: xclip = FFB_XCLIP_TEST_NEVER; break; - case GL_LESS: xclip = FFB_XCLIP_TEST_LT; break; - case GL_EQUAL: xclip = FFB_XCLIP_TEST_EQ; break; - case GL_LEQUAL: xclip = FFB_XCLIP_TEST_LE; break; - case GL_GREATER: xclip = FFB_XCLIP_TEST_GT; break; - case GL_NOTEQUAL: xclip = FFB_XCLIP_TEST_NE; break; - case GL_GEQUAL: xclip = FFB_XCLIP_TEST_GE; break; - case GL_ALWAYS: xclip = FFB_XCLIP_TEST_ALWAYS; break; - - default: - return FFB_XCLIP_TEST_ALWAYS | 0x00; - } - - CLAMPED_FLOAT_TO_UBYTE(alphaRef, ctx->Color.AlphaRef); - xclip |= (alphaRef & 0xff); - - return xclip; -} - -static void ffbDDAlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - if (ctx->Color.AlphaEnabled) { - unsigned int xclip = ffbComputeAlphaFunc(ctx); - - if (fmesa->xclip != xclip) { - fmesa->xclip = xclip; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_XCLIP, 1); - } - } -} - -static void ffbDDBlendEquationSeparate(GLcontext *ctx, - GLenum modeRGB, GLenum modeA) -{ - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDBlendEquation: mode(%s)\n", - _mesa_lookup_enum_by_nr(modeRGB)); -#endif - assert( modeRGB == modeA ); - FALLBACK( ctx, (modeRGB != GL_FUNC_ADD), FFB_BADATTR_BLENDEQN); -} - -static void ffbDDBlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, - GLenum dfactorRGB, GLenum sfactorA, - GLenum dfactorA) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - unsigned int blendc = 1 << 4; - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDBlendFuncSeparate: sRGB(%s) dRGB(%s) sA(%s) dA(%s)\n", - _mesa_lookup_enum_by_nr(sfactorRGB), - _mesa_lookup_enum_by_nr(dfactorRGB), - _mesa_lookup_enum_by_nr(sfactorA), - _mesa_lookup_enum_by_nr(dfactorA)); -#endif - switch (ctx->Color.BlendSrcRGB) { - case GL_ZERO: - blendc |= (0 << 0); - break; - - case GL_ONE: - blendc |= (1 << 0); - break; - - case GL_ONE_MINUS_SRC_ALPHA: - blendc |= (2 << 0); - break; - - case GL_SRC_ALPHA: - blendc |= (3 << 0); - break; - - default: - if (ctx->Color.BlendEnabled) - FALLBACK( ctx, FFB_BADATTR_BLENDFUNC, GL_TRUE ); - return; - }; - - switch (ctx->Color.BlendDstRGB) { - case GL_ZERO: - blendc |= (0 << 2); - break; - - case GL_ONE: - blendc |= (1 << 2); - break; - - case GL_ONE_MINUS_SRC_ALPHA: - blendc |= (2 << 2); - break; - - case GL_SRC_ALPHA: - blendc |= (3 << 2); - break; - - default: - if (ctx->Color.BlendEnabled) - FALLBACK( ctx, FFB_BADATTR_BLENDFUNC, GL_TRUE ); - return; - }; - - if (ctx->Color.BlendEnabled && - ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY) { - /* We could avoid this if sfactor is GL_ONE and - * dfactor is GL_ZERO. I do not think that is even - * worthwhile to check because if someone is using - * blending they use more interesting settings and - * also it would add more state tracking to a lot - * of the code in this file. - */ - FALLBACK(ctx, FFB_BADATTR_BLENDROP, GL_TRUE); - return; - } - - FALLBACK( ctx, (FFB_BADATTR_BLENDFUNC|FFB_BADATTR_BLENDROP), GL_FALSE ); - - if (blendc != fmesa->blendc) { - fmesa->blendc = blendc; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_BLEND, 1); - } -} - -static void ffbDDDepthFunc(GLcontext *ctx, GLenum func) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - GLuint cmp; - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDDepthFunc: func(%s)\n", - _mesa_lookup_enum_by_nr(func)); -#endif - - switch (func) { - case GL_NEVER: - cmp = FFB_CMP_MAGN_NEVER; - break; - case GL_ALWAYS: - cmp = FFB_CMP_MAGN_ALWAYS; - break; - case GL_LESS: - cmp = FFB_CMP_MAGN_LT; - break; - case GL_LEQUAL: - cmp = FFB_CMP_MAGN_LE; - break; - case GL_EQUAL: - cmp = FFB_CMP_MAGN_EQ; - break; - case GL_GREATER: - cmp = FFB_CMP_MAGN_GT; - break; - case GL_GEQUAL: - cmp = FFB_CMP_MAGN_GE; - break; - case GL_NOTEQUAL: - cmp = FFB_CMP_MAGN_NE; - break; - default: - return; - }; - - if (! ctx->Depth.Test) - cmp = FFB_CMP_MAGN_ALWAYS; - - cmp <<= 16; - cmp = (fmesa->cmp & ~(0xff<<16)) | cmp; - if (cmp != fmesa->cmp) { - fmesa->cmp = cmp; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_CMP, 1); - } -} - -static void ffbDDDepthMask(GLcontext *ctx, GLboolean flag) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - GLuint fbc = fmesa->fbc; - GLboolean enabled_now; - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDDepthMask: flag(%d)\n", flag); -#endif - - if ((fbc & FFB_FBC_ZE_MASK) == FFB_FBC_ZE_OFF) - enabled_now = GL_FALSE; - else - enabled_now = GL_TRUE; - - if (flag != enabled_now) { - fbc &= ~FFB_FBC_ZE_MASK; - if (flag) { - fbc |= FFB_FBC_WB_C | FFB_FBC_ZE_ON; - } else { - fbc |= FFB_FBC_ZE_OFF; - fbc &= ~FFB_FBC_WB_C; - } - fmesa->fbc = fbc; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1); - } -} - -static void -ffbDDStencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func, - GLint ref, GLuint mask) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - unsigned int stencil, stencilctl, consty; - - /* We will properly update sw/hw state when stenciling is - * enabled. - */ - if (! ctx->Stencil._Enabled) - return; - - stencilctl = fmesa->stencilctl; - stencilctl &= ~(7 << 16); - - switch (func) { - case GL_ALWAYS: stencilctl |= (0 << 16); break; - case GL_GREATER: stencilctl |= (1 << 16); break; - case GL_EQUAL: stencilctl |= (2 << 16); break; - case GL_GEQUAL: stencilctl |= (3 << 16); break; - case GL_NEVER: stencilctl |= (4 << 16); break; - case GL_LEQUAL: stencilctl |= (5 << 16); break; - case GL_NOTEQUAL: stencilctl |= (6 << 16); break; - case GL_LESS: stencilctl |= (7 << 16); break; - - default: - return; - }; - - consty = ref & 0xf; - - stencil = fmesa->stencil; - stencil &= ~(0xf << 20); - stencil |= (mask & 0xf) << 20; - - if (fmesa->stencil != stencil || - fmesa->stencilctl != stencilctl || - fmesa->consty != consty) { - fmesa->stencil = stencil; - fmesa->stencilctl = stencilctl; - fmesa->consty = consty; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_STENCIL, 6); - } -} - -static void -ffbDDStencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - mask &= 0xf; - if (fmesa->ypmask != mask) { - fmesa->ypmask = mask; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_YPMASK, 1); - } -} - -static void -ffbDDStencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail, - GLenum zfail, GLenum zpass) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - unsigned int stencilctl; - - /* We will properly update sw/hw state when stenciling is - * enabled. - */ - if (! ctx->Stencil._Enabled) - return; - - stencilctl = fmesa->stencilctl; - stencilctl &= ~(0xfff00000); - - switch (fail) { - case GL_ZERO: stencilctl |= (0 << 28); break; - case GL_KEEP: stencilctl |= (1 << 28); break; - case GL_INVERT: stencilctl |= (2 << 28); break; - case GL_REPLACE: stencilctl |= (3 << 28); break; - case GL_INCR: stencilctl |= (4 << 28); break; - case GL_DECR: stencilctl |= (5 << 28); break; - - default: - return; - }; - - switch (zfail) { - case GL_ZERO: stencilctl |= (0 << 24); break; - case GL_KEEP: stencilctl |= (1 << 24); break; - case GL_INVERT: stencilctl |= (2 << 24); break; - case GL_REPLACE: stencilctl |= (3 << 24); break; - case GL_INCR: stencilctl |= (4 << 24); break; - case GL_DECR: stencilctl |= (5 << 24); break; - - default: - return; - }; - - switch (zpass) { - case GL_ZERO: stencilctl |= (0 << 20); break; - case GL_KEEP: stencilctl |= (1 << 20); break; - case GL_INVERT: stencilctl |= (2 << 20); break; - case GL_REPLACE: stencilctl |= (3 << 20); break; - case GL_INCR: stencilctl |= (4 << 20); break; - case GL_DECR: stencilctl |= (5 << 20); break; - - default: - return; - }; - - if (fmesa->stencilctl != stencilctl) { - fmesa->stencilctl = stencilctl; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_STENCIL, 6); - } -} - -static void ffbCalcViewportRegs(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - __DRIdrawable *dPriv = fmesa->driDrawable; - GLuint xmin, xmax, ymin, ymax, zmin, zmax; - unsigned int vcmin, vcmax; - - xmin = ctx->Viewport.X + dPriv->x; - xmax = xmin + ctx->Viewport.Width; - ymax = dPriv->y + dPriv->h - ctx->Viewport.Y; - ymin = ymax - ctx->Viewport.Height; - if (ctx->Scissor.Enabled) { - GLuint sc_xmin, sc_xmax, sc_ymin, sc_ymax; - - sc_xmin = ctx->Viewport.X + dPriv->x; - sc_xmax = sc_xmin + ctx->Viewport.Width; - sc_ymax = dPriv->y + dPriv->h - ctx->Viewport.Y; - sc_ymin = sc_ymax - ctx->Viewport.Height; - if (sc_xmin > xmin) - xmin = sc_xmin; - if (sc_xmax < xmax) - xmax = sc_xmax; - if (sc_ymin > ymin) - ymin = sc_ymin; - if (sc_ymax < ymax) - ymax = sc_ymax; - } - zmin = ((GLdouble)ctx->Viewport.Near * 0x0fffffff); - zmax = ((GLdouble)ctx->Viewport.Far * 0x0fffffff); - - vcmin = ((ymin & 0xffff) << 16) | (xmin & 0xffff); - vcmax = ((ymax & 0xffff) << 16) | (xmax & 0xffff); - if (fmesa->vclipmin != vcmin || - fmesa->vclipmax != vcmax || - fmesa->vclipzmin != zmin || - fmesa->vclipzmax != zmax) { - fmesa->vclipmin = vcmin; - fmesa->vclipmax = vcmax; - fmesa->vclipzmin = zmin; - fmesa->vclipzmax = zmax; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_CLIP, (4 + (4 * 2))); - } -} - -void ffbCalcViewport(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - const GLfloat *v = ctx->Viewport._WindowMap.m; - GLfloat *m = fmesa->hw_viewport; - __DRIdrawable *dPriv = fmesa->driDrawable; - - m[MAT_SX] = v[MAT_SX]; - m[MAT_TX] = v[MAT_TX] + dPriv->x + SUBPIXEL_X; - m[MAT_SY] = - v[MAT_SY]; - m[MAT_TY] = - v[MAT_TY] + dPriv->h + dPriv->y + SUBPIXEL_Y; - m[MAT_SZ] = v[MAT_SZ] * ((GLdouble)1.0 / (GLdouble)0x0fffffff); - m[MAT_TZ] = v[MAT_TZ] * ((GLdouble)1.0 / (GLdouble)0x0fffffff); - - fmesa->depth_scale = ((GLdouble)1.0 / (GLdouble)0x0fffffff); - - ffbCalcViewportRegs(ctx); - - fmesa->setupnewinputs |= VERT_BIT_POS; -} - -static void ffbDDViewport(GLcontext *ctx, GLint x, GLint y, - GLsizei width, GLsizei height) -{ - ffbCalcViewport(ctx); -} - -static void ffbDDDepthRange(GLcontext *ctx, GLclampd nearval, GLclampd farval) -{ - ffbCalcViewport(ctx); -} - -static void ffbDDScissor(GLcontext *ctx, GLint cx, GLint cy, - GLsizei cw, GLsizei ch) -{ - ffbCalcViewport(ctx); -} - -static void ffbDDDrawBuffer(GLcontext *ctx, GLenum buffer) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - unsigned int fbc = fmesa->fbc; - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDDrawBuffer: mode(%s)\n", - _mesa_lookup_enum_by_nr(buffer)); -#endif - fbc &= ~(FFB_FBC_WB_AB | FFB_FBC_RB_MASK); - switch (buffer) { - case GL_FRONT: - if (fmesa->back_buffer == 0) - fbc |= FFB_FBC_WB_B | FFB_FBC_RB_B; - else - fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A; - break; - - case GL_BACK: - if (fmesa->back_buffer == 0) - fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A; - else - fbc |= FFB_FBC_WB_B | FFB_FBC_RB_B; - break; - - case GL_FRONT_AND_BACK: - fbc |= FFB_FBC_WB_AB; - break; - - default: - return; - }; - - if (fbc != fmesa->fbc) { - fmesa->fbc = fbc; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1); - } -} - - -static void ffbDDReadBuffer(GLcontext *ctx, GLenum buffer) -{ - /* no-op, unless you implement h/w glRead/CopyPixels */ -} - - -/* - * Specifies buffer for sw fallbacks (spans) - */ -#if 000 -/* XXX - * This function is obsolete. It's not clear how this really effected - * span reading/writing above. The span functions should use the - * incoming driRenderbuffer (gl_renderbuffer) pointer to determine how - * to read from the specified bufer. - */ -static void ffbDDSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer, - GLuint bufferBit) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - unsigned int fbc = fmesa->fbc; - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDSetReadBuffer: mode(%s)\n", - _mesa_lookup_enum_by_nr(buffer)); -#endif - fbc &= ~(FFB_FBC_RB_MASK); - switch (bufferBit) { - case BUFFER_BIT_FRONT_LEFT: - if (fmesa->back_buffer == 0) - fbc |= FFB_FBC_RB_B; - else - fbc |= FFB_FBC_RB_A; - break; - - case BUFFER_BIT_BACK_LEFT: - if (fmesa->back_buffer == 0) - fbc |= FFB_FBC_RB_A; - else - fbc |= FFB_FBC_RB_B; - break; - - default: - _mesa_problem(ctx, "Unexpected buffer in ffbDDSetBuffer()"); - return; - }; - - if (fbc != fmesa->fbc) { - fmesa->fbc = fbc; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1); - } -} -#endif - - -static void ffbDDClearColor(GLcontext *ctx, const GLfloat color[4]) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - GLubyte c[4]; - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - - fmesa->clear_pixel = ((c[0] << 0) | - (c[1] << 8) | - (c[2] << 16)); -} - -static void ffbDDClearDepth(GLcontext *ctx, GLclampd depth) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - fmesa->clear_depth = Z_FROM_MESA(depth * 4294967295.0f); -} - -static void ffbDDClearStencil(GLcontext *ctx, GLint stencil) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - fmesa->clear_stencil = stencil & 0xf; -} - -/* XXX Actually, should I be using FBC controls for this? -DaveM */ -static void ffbDDColorMask(GLcontext *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - unsigned int new_pmask = 0x0; - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDColorMask: r(%d) g(%d) b(%d) a(%d)\n", - r, g, b, a); -#endif - if (r) - new_pmask |= 0x000000ff; - if (g) - new_pmask |= 0x0000ff00; - if (b) - new_pmask |= 0x00ff0000; - if (a) - new_pmask |= 0xff000000; - - if (fmesa->pmask != new_pmask) { - fmesa->pmask = new_pmask; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_PMASK, 1); - } -} - -static void ffbDDLogicOp(GLcontext *ctx, GLenum op) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - unsigned int rop; - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDLogicOp: op(%s)\n", - _mesa_lookup_enum_by_nr(op)); -#endif - switch (op) { - case GL_CLEAR: rop = FFB_ROP_ZERO; break; - case GL_SET: rop = FFB_ROP_ONES; break; - case GL_COPY: rop = FFB_ROP_NEW; break; - case GL_AND: rop = FFB_ROP_NEW_AND_OLD; break; - case GL_NAND: rop = FFB_ROP_NEW_AND_NOLD; break; - case GL_OR: rop = FFB_ROP_NEW_OR_OLD; break; - case GL_NOR: rop = FFB_ROP_NEW_OR_NOLD; break; - case GL_XOR: rop = FFB_ROP_NEW_XOR_OLD; break; - case GL_NOOP: rop = FFB_ROP_OLD; break; - case GL_COPY_INVERTED: rop = FFB_ROP_NNEW; break; - case GL_INVERT: rop = FFB_ROP_NOLD; break; - case GL_EQUIV: rop = FFB_ROP_NNEW_XOR_NOLD; break; - case GL_AND_REVERSE: rop = FFB_ROP_NEW_AND_NOLD; break; - case GL_AND_INVERTED: rop = FFB_ROP_NNEW_AND_OLD; break; - case GL_OR_REVERSE: rop = FFB_ROP_NEW_OR_NOLD; break; - case GL_OR_INVERTED: rop = FFB_ROP_NNEW_OR_OLD; break; - - default: - return; - }; - - rop |= fmesa->rop & ~0xff; - if (rop != fmesa->rop) { - fmesa->rop = rop; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_ROP, 1); - - if (op == GL_COPY) - FALLBACK( ctx, FFB_BADATTR_BLENDROP, GL_FALSE ); - } -} - -#if 0 -/* XXX Also need to track near/far just like 3dfx driver. - * XXX - * XXX Actually, that won't work, because the 3dfx chip works by - * XXX having 1/w coordinates fed to it for each primitive, and - * XXX it uses this to index it's 64 entry fog table. - */ -static void ffb_fog_linear(GLcontext *ctx, ffbContextPtr fmesa) -{ - GLfloat c = ctx->ProjectionMatrix.m[10]; - GLfloat d = ctx->ProjectionMatrix.m[14]; - GLfloat tz = ctx->Viewport.WindowMap.m[MAT_TZ]; - GLfloat szInv = 1.0F / ctx->Viewport.WindowMap.m[MAT_SZ]; - GLfloat fogEnd = ctx->Fog.End; - GLfloat fogScale = 1.0F / (ctx->Fog.End - ctx->Fog.Start); - GLfloat ndcz; - GLfloat eyez; - GLfloat Zzero, Zone; - unsigned int zb, zf; - - /* Compute the Z at which f reaches 0.0, this is the full - * saturation point. - * - * Thus compute Z (as seen by the chip during rendering), - * such that: - * - * 0.0 = (fogEnd - eyez) * fogScale - * - * fogScale is usually not zero, thus we are looking for: - * - * fogEnd = eyez - * - * fogEnd = -d / (c + ((Z - tz) * szInv)) - * fogEnd * (c + ((Z - tz) * szInv)) = -d - * (c + ((Z - tz) * szInv)) = -d / fogEnd - * (Z - tz) * szInv = (-d / fogEnd) - c - * (Z - tz) = ((-d / fogEnd) - c) / szInv - * Z = (((-d / fogEnd) - c) / szInv) + tz - */ - Zzero = (((-d / fogEnd) - c) / szInv) + tz; - - /* Compute the Z at which f reaches 1.0, this is where - * the incoming frag's full intensity is shown. This - * equation is: - * - * 1.0 = (fogEnd - eyez) - * - * We are looking for: - * - * 1.0 + eyez = fogEnd - * - * 1.0 + (-d / (c + ((Z - tz) * szInv))) = fogEnd - * -d / (c + ((Z - tz) * szInv)) = fogEnd - 1.0 - * -d / (FogEnd - 1.0) = (c + ((Z - tz) * szInv)) - * (-d / (fogEnd - 1.0)) - c = ((Z - tz) * szInv) - * ((-d / (fogEnd - 1.0)) - c) / szInv = (Z - tz) - * (((-d / (fogEnd - 1.0)) - c) / szInv) + tz = Z - */ - Zone = (((-d / (fogEnd - 1.0)) - c) / szInv) + tz; - - /* FFB's Zfront must be less than Zback, thus we may have - * to invert Sf/Sb to satisfy this constraint. - */ - if (Zzero < Zone) { - sf = 0.0; - sb = 1.0; - zf = Z_FROM_MESA(Zzero); - zb = Z_FROM_MESA(Zone); - } else { - sf = 1.0; - sb = 0.0; - zf = Z_FROM_MESA(Zone); - zb = Z_FROM_MESA(Zzero); - } -} -#endif - -static void ffbDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param) -{ -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDFogfv: pname(%s)\n", _mesa_lookup_enum_by_nr(pname)); -#endif -} - -static void ffbDDLineStipple(GLcontext *ctx, GLint factor, GLushort pattern) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDLineStipple: factor(%d) pattern(%04x)\n", - factor, pattern); -#endif - if (ctx->Line.StippleFlag) { - factor = ctx->Line.StippleFactor; - pattern = ctx->Line.StipplePattern; - if ((GLuint) factor > 15) { - fmesa->lpat = FFB_LPAT_BAD; - } else { - fmesa->lpat = ((factor << FFB_LPAT_SCALEVAL_SHIFT) | - (0 << FFB_LPAT_PATLEN_SHIFT) | - ((pattern & 0xffff) << FFB_LPAT_PATTERN_SHIFT)); - } - } else { - fmesa->lpat = 0; - } -} - -void ffbXformAreaPattern(ffbContextPtr fmesa, const GLubyte *mask) -{ - __DRIdrawable *dPriv = fmesa->driDrawable; - int i, lines, xoff; - - lines = 0; - i = (dPriv->y + dPriv->h) & (32 - 1); - xoff = dPriv->x & (32 - 1); - while (lines++ < 32) { - GLuint raw = - (((GLuint)mask[0] << 24) | - ((GLuint)mask[1] << 16) | - ((GLuint)mask[2] << 8) | - ((GLuint)mask[3] << 0)); - - fmesa->pattern[i] = - (raw << xoff) | (raw >> (32 - xoff)); - i = (i - 1) & (32 - 1); - mask += 4; - } - - FFB_MAKE_DIRTY(fmesa, FFB_STATE_APAT, 32); -} - -static void ffbDDPolygonStipple(GLcontext *ctx, const GLubyte *mask) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDPolygonStipple: state(%d)\n", - ctx->Polygon.StippleFlag); -#endif - ffbXformAreaPattern(fmesa, mask); -} - -static void ffbDDEnable(GLcontext *ctx, GLenum cap, GLboolean state) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - unsigned int tmp; - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDEnable: %s state(%d)\n", - _mesa_lookup_enum_by_nr(cap), state); -#endif - switch (cap) { - case GL_ALPHA_TEST: - if (state) - tmp = ffbComputeAlphaFunc(ctx); - else - tmp = FFB_XCLIP_TEST_ALWAYS; - - if (tmp != fmesa->xclip) { - fmesa->xclip = tmp; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_XCLIP, 1); - } - break; - - case GL_BLEND: - tmp = (fmesa->ppc & ~FFB_PPC_ABE_MASK); - if (state) { - tmp |= FFB_PPC_ABE_ENABLE; - } else { - tmp |= FFB_PPC_ABE_DISABLE; - } - if (fmesa->ppc != tmp) { - fmesa->ppc = tmp; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_PPC, 1); - ffbDDBlendFuncSeparate(ctx, 0, 0, 0, 0 ); - } - break; - - case GL_DEPTH_TEST: - if (state) - tmp = 0x0fffffff; - else - tmp = 0x00000000; - if (tmp != fmesa->magnc) { - unsigned int fbc = fmesa->fbc; - fbc &= ~FFB_FBC_ZE_MASK; - if (state) - fbc |= FFB_FBC_ZE_ON; - else - fbc |= FFB_FBC_ZE_OFF; - fmesa->fbc = fbc; - ffbDDDepthFunc(ctx, ctx->Depth.Func); - fmesa->magnc = tmp; - FFB_MAKE_DIRTY(fmesa, (FFB_STATE_MAGNC | FFB_STATE_FBC), 2); - } - break; - - case GL_SCISSOR_TEST: - ffbDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.Width, ctx->Scissor.Height); - break; - - case GL_STENCIL_TEST: - if (!(fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)) { - FALLBACK( ctx, FFB_BADATTR_STENCIL, state ); - } - - tmp = fmesa->fbc & ~FFB_FBC_YE_MASK; - if (state) { - ffbDDStencilFuncSeparate(ctx, GL_FRONT, - ctx->Stencil.Function[0], - ctx->Stencil.Ref[0], - ctx->Stencil.ValueMask[0]); - ffbDDStencilMaskSeparate(ctx, GL_FRONT, - ctx->Stencil.WriteMask[0]); - ffbDDStencilOpSeparate(ctx, GL_FRONT, - ctx->Stencil.FailFunc[0], - ctx->Stencil.ZFailFunc[0], - ctx->Stencil.ZPassFunc[0]); - tmp |= FFB_FBC_YE_MASK; - } else { - fmesa->stencil = 0xf0000000; - fmesa->stencilctl = 0x33300000; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_STENCIL, 6); - tmp |= FFB_FBC_YE_OFF; - } - if (tmp != fmesa->fbc) { - fmesa->fbc = tmp; - FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1); - } - break; - - case GL_FOG: - /* Until I implement the fog support... */ - FALLBACK( ctx, FFB_BADATTR_FOG, state ); - break; - - case GL_LINE_STIPPLE: - if (! state) - fmesa->lpat = 0; - else - ffbDDLineStipple(ctx, - ctx->Line.StippleFactor, - ctx->Line.StipplePattern); - break; - - case GL_POLYGON_STIPPLE: - /* Do nothing, we interrogate the state during - * reduced primitive changes. Since our caller - * will set NEW_POLYGON in the ctx NewState this - * will cause the driver rasterization functions - * to be reevaluated, which will cause us to force - * a reduced primitive change next rendering pass - * and it all works out. - */ - break; - - default: - break; - }; -} - -void ffbSyncHardware(ffbContextPtr fmesa) -{ - ffb_fbcPtr ffb = fmesa->regs; - unsigned int dirty; - int i; - - FFBFifo(fmesa, fmesa->state_fifo_ents); - - dirty = fmesa->state_dirty; - if (dirty & (FFB_STATE_FBC | FFB_STATE_PPC | FFB_STATE_DRAWOP | - FFB_STATE_ROP | FFB_STATE_LPAT | FFB_STATE_WID)) { - if (dirty & FFB_STATE_FBC) - ffb->fbc = fmesa->fbc; - if (dirty & FFB_STATE_PPC) - ffb->ppc = fmesa->ppc; - if (dirty & FFB_STATE_DRAWOP) - ffb->drawop = fmesa->drawop; - if (dirty & FFB_STATE_ROP) - ffb->rop = fmesa->rop; - if (dirty & FFB_STATE_LPAT) - ffb->rop = fmesa->lpat; - if (dirty & FFB_STATE_WID) - ffb->wid = fmesa->wid; - } - if (dirty & (FFB_STATE_PMASK | FFB_STATE_XPMASK | FFB_STATE_YPMASK | - FFB_STATE_ZPMASK | FFB_STATE_XCLIP | FFB_STATE_CMP | - FFB_STATE_MATCHAB | FFB_STATE_MAGNAB | FFB_STATE_MATCHC | - FFB_STATE_MAGNC)) { - if (dirty & FFB_STATE_PMASK) - ffb->pmask = fmesa->pmask; - if (dirty & FFB_STATE_XPMASK) - ffb->xpmask = fmesa->xpmask; - if (dirty & FFB_STATE_YPMASK) - ffb->ypmask = fmesa->ypmask; - if (dirty & FFB_STATE_ZPMASK) - ffb->zpmask = fmesa->zpmask; - if (dirty & FFB_STATE_XCLIP) - ffb->xclip = fmesa->xclip; - if (dirty & FFB_STATE_CMP) - ffb->cmp = fmesa->cmp; - if (dirty & FFB_STATE_MATCHAB) - ffb->matchab = fmesa->matchab; - if (dirty & FFB_STATE_MAGNAB) - ffb->magnab = fmesa->magnab; - if (dirty & FFB_STATE_MATCHC) - ffb->matchc = fmesa->matchc; - if (dirty & FFB_STATE_MAGNC) - ffb->magnc = fmesa->magnc; - } - - if (dirty & FFB_STATE_DCUE) { - ffb->dcss = fmesa->dcss; - ffb->dcsf = fmesa->dcsf; - ffb->dcsb = fmesa->dcsb; - ffb->dczf = fmesa->dczf; - ffb->dczb = fmesa->dczb; - if (fmesa->ffb_sarea->flags & (FFB_DRI_FFB2 | FFB_DRI_FFB2PLUS)) { - ffb->dcss1 = fmesa->dcss1; - ffb->dcss2 = fmesa->dcss2; - ffb->dcss3 = fmesa->dcss3; - ffb->dcs2 = fmesa->dcs2; - ffb->dcs3 = fmesa->dcs3; - ffb->dcs4 = fmesa->dcs4; - ffb->dcd2 = fmesa->dcd2; - ffb->dcd3 = fmesa->dcd3; - ffb->dcd4 = fmesa->dcd4; - } - } - - if (dirty & FFB_STATE_BLEND) { - ffb->blendc = fmesa->blendc; - ffb->blendc1 = fmesa->blendc1; - ffb->blendc2 = fmesa->blendc2; - } - - if (dirty & FFB_STATE_CLIP) { - ffb->vclipmin = fmesa->vclipmin; - ffb->vclipmax = fmesa->vclipmax; - ffb->vclipzmin = fmesa->vclipzmin; - ffb->vclipzmax = fmesa->vclipzmax; - for (i = 0; i < 4; i++) { - ffb->auxclip[i].min = fmesa->aux_clips[i].min; - ffb->auxclip[i].max = fmesa->aux_clips[i].max; - } - } - - if ((dirty & FFB_STATE_STENCIL) && - (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)) { - ffb->stencil = fmesa->stencil; - ffb->stencilctl = fmesa->stencilctl; - ffb->fbc = FFB_FBC_WB_C; - ffb->rawstencilctl = (fmesa->stencilctl | (1 << 19)); - ffb->fbc = fmesa->fbc; - ffb->consty = fmesa->consty; - } - - if (dirty & FFB_STATE_APAT) { - for (i = 0; i < 32; i++) - ffb->pattern[i] = fmesa->pattern[i]; - } - - fmesa->state_dirty = 0; - fmesa->state_fifo_ents = 0; - fmesa->ffbScreen->rp_active = 1; -} - -static void ffbDDUpdateState(GLcontext *ctx, GLuint newstate) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - /* When we are hw rendering, changing certain kinds of - * state does not require flushing all of our context. - */ - if (fmesa->bad_fragment_attrs == 0 && - (newstate & ~_NEW_COLOR) == 0) - return; - - _swrast_InvalidateState( ctx, newstate ); - _swsetup_InvalidateState( ctx, newstate ); - _vbo_InvalidateState( ctx, newstate ); - _tnl_InvalidateState( ctx, newstate ); - - if (newstate & _NEW_TEXTURE) - FALLBACK( ctx, FFB_BADATTR_TEXTURE, - (ctx->Texture._EnabledUnits != 0)); - -#ifdef STATE_TRACE - fprintf(stderr, "ffbDDUpdateState: newstate(%08x)\n", newstate); -#endif - - fmesa->new_gl_state |= newstate; - - /* Force a reduced primitive change next rendering - * pass. - */ - fmesa->raster_primitive = GL_POLYGON + 1; - -#if 0 - /* When the modelview matrix changes, this changes what - * the eye coordinates will be so we have to recompute - * the depth cueing parameters. - * - * XXX DD_HAVE_HARDWARE_FOG. - */ - if (ctx->Fog.Enabled && (newstate & _NEW_MODELVIEW)) - ffb_update_fog(); -#endif -} - - -void ffbDDInitStateFuncs(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - ctx->Driver.UpdateState = ffbDDUpdateState; - - ctx->Driver.Enable = ffbDDEnable; - ctx->Driver.AlphaFunc = ffbDDAlphaFunc; - ctx->Driver.BlendEquationSeparate = ffbDDBlendEquationSeparate; - ctx->Driver.BlendFuncSeparate = ffbDDBlendFuncSeparate; - ctx->Driver.DepthFunc = ffbDDDepthFunc; - ctx->Driver.DepthMask = ffbDDDepthMask; - ctx->Driver.Fogfv = ffbDDFogfv; - ctx->Driver.LineStipple = ffbDDLineStipple; - ctx->Driver.PolygonStipple = ffbDDPolygonStipple; - ctx->Driver.Scissor = ffbDDScissor; - ctx->Driver.ColorMask = ffbDDColorMask; - ctx->Driver.LogicOpcode = ffbDDLogicOp; - ctx->Driver.Viewport = ffbDDViewport; - ctx->Driver.DepthRange = ffbDDDepthRange; - - if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS) { - ctx->Driver.StencilFuncSeparate = ffbDDStencilFuncSeparate; - ctx->Driver.StencilMaskSeparate = ffbDDStencilMaskSeparate; - ctx->Driver.StencilOpSeparate = ffbDDStencilOpSeparate; - } - - ctx->Driver.DrawBuffer = ffbDDDrawBuffer; - ctx->Driver.ReadBuffer = ffbDDReadBuffer; - ctx->Driver.ClearColor = ffbDDClearColor; - ctx->Driver.ClearDepth = ffbDDClearDepth; - ctx->Driver.ClearStencil = ffbDDClearStencil; - - /* We will support color index modes later... -DaveM */ - /* - ctx->Driver.ClearIndex = 0; - ctx->Driver.IndexMask = 0; - */ -} - -void ffbDDInitContextHwState(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - int fifo_count = 0; - int i; - - fmesa->hw_locked = 0; - - fmesa->bad_fragment_attrs = 0; - fmesa->state_dirty = FFB_STATE_ALL; - fmesa->new_gl_state = ~0; - - fifo_count = 1; - fmesa->fbc = (FFB_FBC_WE_FORCEON | FFB_FBC_WM_COMBINED | - FFB_FBC_SB_BOTH | FFB_FBC_ZE_MASK | - FFB_FBC_YE_OFF | FFB_FBC_XE_OFF | - FFB_FBC_RGBE_MASK); - if (ctx->Visual.doubleBufferMode) { - /* Buffer B is the initial back buffer. */ - fmesa->back_buffer = 1; - fmesa->fbc |= FFB_FBC_WB_BC | FFB_FBC_RB_B; - } else { - fmesa->back_buffer = 0; - fmesa->fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A; - } - - fifo_count += 1; - fmesa->ppc = (FFB_PPC_ACE_DISABLE | FFB_PPC_DCE_DISABLE | - FFB_PPC_ABE_DISABLE | FFB_PPC_VCE_3D | - FFB_PPC_APE_DISABLE | FFB_PPC_TBE_OPAQUE | - FFB_PPC_ZS_CONST | FFB_PPC_YS_CONST | - FFB_PPC_XS_WID | FFB_PPC_CS_VAR); - - fifo_count += 3; - fmesa->drawop = FFB_DRAWOP_RECTANGLE; - - /* GL_COPY is the default LogicOp. */ - fmesa->rop = (FFB_ROP_NEW << 16) | (FFB_ROP_NEW << 8) | FFB_ROP_NEW; - - /* No line patterning enabled. */ - fmesa->lpat = 0x00000000; - - /* We do not know the WID value until the first context switch. */ - fifo_count += 1; - fmesa->wid = ~0; - - fifo_count += 5; - - /* ColorMask, all enabled. */ - fmesa->pmask = 0xffffffff; - - fmesa->xpmask = 0x000000ff; - fmesa->ypmask = 0x0000000f; - fmesa->zpmask = 0x0fffffff; - - /* AlphaFunc GL_ALWAYS, AlphaRef 0 */ - fmesa->xclip = FFB_XCLIP_TEST_ALWAYS | 0x00; - - /* This sets us up to use WID clipping (so the DRI clipping - * rectangle is unneeded by us). All other match and magnitude - * tests are set to pass. - */ - fifo_count += 5; - fmesa->cmp = ((FFB_CMP_MATCH_ALWAYS << 24) | /* MATCH C */ - (FFB_CMP_MAGN_ALWAYS << 16) | /* MAGN C */ - (FFB_CMP_MATCH_EQ << 8) | /* MATCH AB */ - (FFB_CMP_MAGN_ALWAYS << 0)); /* MAGN AB */ - fmesa->matchab = 0xff000000; - fmesa->magnab = 0x00000000; - fmesa->matchc = 0x00000000; - fmesa->magnc = 0x00000000; - - /* Depth cue parameters, all zeros to start. */ - fifo_count += 14; - fmesa->dcss = 0x00000000; - fmesa->dcsf = 0x00000000; - fmesa->dcsb = 0x00000000; - fmesa->dczf = 0x00000000; - fmesa->dczb = 0x00000000; - fmesa->dcss1 = 0x00000000; - fmesa->dcss2 = 0x00000000; - fmesa->dcss3 = 0x00000000; - fmesa->dcs2 = 0x00000000; - fmesa->dcs3 = 0x00000000; - fmesa->dcs4 = 0x00000000; - fmesa->dcd2 = 0x00000000; - fmesa->dcd3 = 0x00000000; - fmesa->dcd4 = 0x00000000; - - /* Alpha blending unit state. */ - fifo_count += 3; - fmesa->blendc = (1 << 0) | (0 << 2); /* src(GL_ONE) | dst(GL_ZERO) */ - fmesa->blendc1 = 0x00000000; - fmesa->blendc2 = 0x00000000; - - /* ViewPort clip state. */ - fifo_count += 4 + (4 * 2); - fmesa->vclipmin = 0x00000000; - fmesa->vclipmax = 0xffffffff; - fmesa->vclipzmin = 0x00000000; - fmesa->vclipzmax = 0x0fffffff; - for (i = 0; i < 4; i++) { - fmesa->aux_clips[0].min = 0x00000000; - fmesa->aux_clips[0].max = 0x00000000; - } - - /* Stenciling state. */ - fifo_count += 6; - fmesa->stencil = 0xf0000000; /* Stencil MASK, Y plane */ - fmesa->stencilctl = 0x33300000; /* All stencil tests disabled */ - fmesa->consty = 0x0; - - /* Area pattern, used for polygon stipples. */ - fifo_count += 32; - for (i = 0; i < 32; i++) - fmesa->pattern[i] = 0x00000000; - - fmesa->state_fifo_ents = fifo_count; - fmesa->state_all_fifo_ents = fifo_count; -} diff --git a/src/mesa/drivers/dri/ffb/ffb_state.h b/src/mesa/drivers/dri/ffb/ffb_state.h deleted file mode 100644 index 19e72085fd1..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_state.h +++ /dev/null @@ -1,12 +0,0 @@ - -#ifndef _FFB_STATE_H -#define _FFB_STATE_H - -extern void ffbDDInitStateFuncs(GLcontext *); -extern void ffbDDInitContextHwState(GLcontext *); - -extern void ffbCalcViewport(GLcontext *); -extern void ffbXformAreaPattern(ffbContextPtr, const GLubyte *); -extern void ffbSyncHardware(ffbContextPtr fmesa); - -#endif /* !(_FFB_STATE_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_stencil.c b/src/mesa/drivers/dri/ffb/ffb_stencil.c deleted file mode 100644 index 10cdfbc616e..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_stencil.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2000 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "main/mtypes.h" -#include "ffb_dd.h" -#include "ffb_span.h" -#include "ffb_context.h" -#include "ffb_stencil.h" -#include "ffb_lock.h" - -#undef STENCIL_TRACE - -static void FFBWriteStencilSpan( GLcontext *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - const void *values, const GLubyte mask[] ) -{ - const GLubyte *stencil = (const GLubyte *) values; -#ifdef STENCIL_TRACE - fprintf(stderr, "FFBWriteStencilSpan: n(%d) x(%d) y(%d)\n", - (int) n, x, y); -#endif - if (ctx->Depth.Mask) { - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - __DRIdrawable *dPriv = fmesa->driDrawable; - GLuint *zptr; - GLuint i; - - if (!fmesa->hw_locked) - LOCK_HARDWARE(fmesa); - FFBFifo(fmesa, 2); - fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_OFF | - FFB_FBC_YE_ON | FFB_FBC_RGBE_OFF); - fmesa->regs->ppc = FFB_PPC_YS_VAR; - FFBWait(fmesa, fmesa->regs); - - y = (dPriv->h - y); - zptr = (GLuint *) - ((char *)fmesa->sfb32 + - ((dPriv->x + x) << 2) + - ((dPriv->y + y) << 13)); - - for (i = 0; i < n; i++) { - if (mask[i]) - *zptr = (stencil[i] & 0xf) << 28; - zptr++; - } - - FFBFifo(fmesa, 2); - fmesa->regs->fbc = fmesa->fbc; - fmesa->regs->ppc = fmesa->ppc; - fmesa->ffbScreen->rp_active = 1; - if (!fmesa->hw_locked) - UNLOCK_HARDWARE(fmesa); - } -} - -static void FFBWriteStencilPixels( GLcontext *ctx, - struct gl_renderbuffer *rb, - GLuint n, - const GLint x[], const GLint y[], - const void *values, const GLubyte mask[] ) -{ - const GLubyte *stencil = (const GLubyte *) values; -#ifdef STENCIL_TRACE - fprintf(stderr, "FFBWriteStencilPixels: n(%d)\n", (int) n); -#endif - if (ctx->Depth.Mask) { - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - __DRIdrawable *dPriv = fmesa->driDrawable; - char *zbase; - GLuint i; - - if (!fmesa->hw_locked) - LOCK_HARDWARE(fmesa); - FFBFifo(fmesa, 2); - fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_OFF | - FFB_FBC_YE_ON | FFB_FBC_RGBE_OFF); - fmesa->regs->ppc = FFB_PPC_YS_VAR; - fmesa->ffbScreen->rp_active = 1; - FFBWait(fmesa, fmesa->regs); - - zbase = ((char *)fmesa->sfb32 + - (dPriv->x << 2) + (dPriv->y << 13)); - - for (i = 0; i < n; i++) { - GLint y1 = (dPriv->h - y[i]); - GLint x1 = x[i]; - GLuint *zptr; - - zptr = (GLuint *) - (zbase + (x1 << 2) + (y1 << 13)); - if (mask[i]) - *zptr = (stencil[i] & 0xf) << 28; - } - - FFBFifo(fmesa, 2); - fmesa->regs->fbc = fmesa->fbc; - fmesa->regs->ppc = fmesa->ppc; - fmesa->ffbScreen->rp_active = 1; - if (!fmesa->hw_locked) - UNLOCK_HARDWARE(fmesa); - } -} - -static void FFBReadStencilSpan( GLcontext *ctx, - struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - void *values) -{ - GLubyte *stencil = (GLubyte *) values; - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - __DRIdrawable *dPriv = fmesa->driDrawable; - GLuint *zptr; - GLuint i; - -#ifdef STENCIL_TRACE - fprintf(stderr, "FFBReadStencilSpan: n(%d) x(%d) y(%d)\n", - (int) n, x, y); -#endif - if (!fmesa->hw_locked) - LOCK_HARDWARE(fmesa); - FFBFifo(fmesa, 1); - fmesa->regs->fbc = FFB_FBC_RB_C; - fmesa->ffbScreen->rp_active = 1; - FFBWait(fmesa, fmesa->regs); - - y = (dPriv->h - y); - zptr = (GLuint *) - ((char *)fmesa->sfb32 + - ((dPriv->x + x) << 2) + - ((dPriv->y + y) << 13)); - - for (i = 0; i < n; i++) { - stencil[i] = (*zptr >> 28) & 0xf; - zptr++; - } - - FFBFifo(fmesa, 1); - fmesa->regs->fbc = fmesa->fbc; - fmesa->ffbScreen->rp_active = 1; - if (!fmesa->hw_locked) - UNLOCK_HARDWARE(fmesa); -} - -static void FFBReadStencilPixels( GLcontext *ctx, - struct gl_renderbuffer *rb, - GLuint n, const GLint x[], const GLint y[], - void *values ) -{ - GLubyte *stencil = (GLubyte *) values; - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - __DRIdrawable *dPriv = fmesa->driDrawable; - char *zbase; - GLuint i; - -#ifdef STENCIL_TRACE - fprintf(stderr, "FFBReadStencilPixels: n(%d)\n", (int) n); -#endif - if (!fmesa->hw_locked) - LOCK_HARDWARE(fmesa); - FFBFifo(fmesa, 1); - fmesa->regs->fbc = FFB_FBC_RB_C; - fmesa->ffbScreen->rp_active = 1; - FFBWait(fmesa, fmesa->regs); - - zbase = ((char *)fmesa->sfb32 + - (dPriv->x << 2) + (dPriv->y << 13)); - - for (i = 0; i < n; i++) { - GLint y1 = (dPriv->h - y[i]); - GLint x1 = x[i]; - GLuint *zptr; - - zptr = (GLuint *) - (zbase + (x1 << 2) + (y1 << 13)); - stencil[i] = (*zptr >> 28) & 0xf; - } - - FFBFifo(fmesa, 1); - fmesa->regs->fbc = fmesa->fbc; - fmesa->ffbScreen->rp_active = 1; - if (!fmesa->hw_locked) - UNLOCK_HARDWARE(fmesa); -} - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -ffbSetStencilFunctions(driRenderbuffer *drb, const GLvisual *vis) -{ - assert(drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT); - drb->Base.GetRow = FFBReadStencilSpan; - drb->Base.GetValues = FFBReadStencilPixels; - drb->Base.PutRow = FFBWriteStencilSpan; - /*drb->Base.PutMonoRow = FFBWriteMonoStencilSpan;*/ - drb->Base.PutValues = FFBWriteStencilPixels; - drb->Base.PutMonoValues = NULL; -} diff --git a/src/mesa/drivers/dri/ffb/ffb_stencil.h b/src/mesa/drivers/dri/ffb/ffb_stencil.h deleted file mode 100644 index 2d529980d16..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_stencil.h +++ /dev/null @@ -1,7 +0,0 @@ - -#ifndef _FFB_STENCIL_H -#define _FFB_STENCIL_H - -void ffbSetStencilFunctions(driRenderbuffer *drb, const GLvisual *vis); - -#endif /* !(_FFB_STENCIL_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_tex.c b/src/mesa/drivers/dri/ffb/ffb_tex.c deleted file mode 100644 index 95058e9069f..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_tex.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2001 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "ffb_tex.h" - -/* No texture unit, all software. */ -void ffbDDInitTexFuncs(GLcontext *ctx) -{ -} diff --git a/src/mesa/drivers/dri/ffb/ffb_tex.h b/src/mesa/drivers/dri/ffb/ffb_tex.h deleted file mode 100644 index 4032e73209d..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_tex.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D. - * Copyright (C) 2001 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#ifndef _FFB_TEX_H -#define _FFB_TEX_H - -extern void ffbDDInitTexFuncs(GLcontext *ctx); - -#endif /* !(_FFB_DD_H) */ - diff --git a/src/mesa/drivers/dri/ffb/ffb_tris.c b/src/mesa/drivers/dri/ffb/ffb_tris.c deleted file mode 100644 index 8bf5ae498fd..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_tris.c +++ /dev/null @@ -1,945 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2000, 2001 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "swrast/swrast.h" -#include "swrast/s_context.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" - -#include "ffb_context.h" -#include "ffb_tris.h" -#include "ffb_lines.h" -#include "ffb_lock.h" -#include "ffb_points.h" -#include "ffb_state.h" -#include "ffb_vb.h" - -#undef TRI_DEBUG -#undef FFB_RENDER_TRACE -#undef STATE_TRACE - -#ifdef TRI_DEBUG -static void ffb_print_vertex(const ffb_vertex *v) -{ - fprintf(stderr, "Vertex @(%p): " - "X[%f] Y[%f] Z[%f]\n", - v, v->x, v->y, v->z); - fprintf(stderr, "Vertex @(%p): " - "A[%f] R[%f] G[%f] B[%f]\n", - v, - v->color[0].alpha, - v->color[0].red, - v->color[0].green, - v->color[0].blue); -} -#define FFB_DUMP_VERTEX(V) ffb_print_vertex(V) -#else -#define FFB_DUMP_VERTEX(V) do { } while(0) -#endif - -#define FFB_ALPHA_BIT 0x01 -#define FFB_FLAT_BIT 0x02 -#define FFB_TRI_CULL_BIT 0x04 -#define MAX_FFB_RENDER_FUNCS 0x08 - -/*********************************************************************** - * Build low-level triangle/quad rasterize functions * - ***********************************************************************/ - -#define FFB_TRI_FLAT_BIT 0x01 -#define FFB_TRI_ALPHA_BIT 0x02 -/*#define FFB_TRI_CULL_BIT 0x04*/ - -static ffb_tri_func ffb_tri_tab[0x8]; -static ffb_quad_func ffb_quad_tab[0x8]; - -#define IND (0) -#define TAG(x) x -#include "ffb_tritmp.h" - -#define IND (FFB_TRI_FLAT_BIT) -#define TAG(x) x##_flat -#include "ffb_tritmp.h" - -#define IND (FFB_TRI_CULL_BIT) -#define TAG(x) x##_cull -#include "ffb_tritmp.h" - -#define IND (FFB_TRI_CULL_BIT|FFB_TRI_FLAT_BIT) -#define TAG(x) x##_cull_flat -#include "ffb_tritmp.h" - -#define IND (FFB_TRI_ALPHA_BIT) -#define TAG(x) x##_alpha -#include "ffb_tritmp.h" - -#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_FLAT_BIT) -#define TAG(x) x##_alpha_flat -#include "ffb_tritmp.h" - -#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT) -#define TAG(x) x##_alpha_cull -#include "ffb_tritmp.h" - -#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_FLAT_BIT) -#define TAG(x) x##_alpha_cull_flat -#include "ffb_tritmp.h" - -static void init_tri_tab(void) -{ - ffb_init(); - ffb_init_flat(); - ffb_init_cull(); - ffb_init_cull_flat(); - ffb_init_alpha(); - ffb_init_alpha_flat(); - ffb_init_alpha_cull(); - ffb_init_alpha_cull_flat(); -} - -/* Build a SWvertex from a hardware vertex. */ -static void ffb_translate_vertex(GLcontext *ctx, const ffb_vertex *src, - SWvertex *dst) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - GLfloat *m = ctx->Viewport._WindowMap.m; - const GLfloat sx = m[0]; - const GLfloat sy = m[5]; - const GLfloat sz = m[10]; - const GLfloat tx = m[12]; - const GLfloat ty = m[13]; - const GLfloat tz = m[14]; - - dst->attrib[FRAG_ATTRIB_WPOS][0] = sx * src->x + tx; - dst->attrib[FRAG_ATTRIB_WPOS][1] = sy * src->y + ty; - dst->attrib[FRAG_ATTRIB_WPOS][2] = sz * src->z + tz; - dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0; - - dst->color[0] = FFB_UBYTE_FROM_COLOR(src->color[0].red); - dst->color[1] = FFB_UBYTE_FROM_COLOR(src->color[0].green); - dst->color[2] = FFB_UBYTE_FROM_COLOR(src->color[0].blue); - dst->color[3] = FFB_UBYTE_FROM_COLOR(src->color[0].alpha); -} - -/*********************************************************************** - * Build fallback triangle/quad rasterize functions * - ***********************************************************************/ - -static void ffb_fallback_triangle(GLcontext *ctx, ffb_vertex *v0, - ffb_vertex *v1, ffb_vertex *v2) -{ - SWvertex v[3]; - - ffb_translate_vertex(ctx, v0, &v[0]); - ffb_translate_vertex(ctx, v1, &v[1]); - ffb_translate_vertex(ctx, v2, &v[2]); - - _swrast_Triangle(ctx, &v[0], &v[1], &v[2]); -} - -static void ffb_fallback_quad(GLcontext *ctx, - ffb_vertex *v0, ffb_vertex *v1, - ffb_vertex *v2, ffb_vertex *v3) -{ - SWvertex v[4]; - - ffb_translate_vertex(ctx, v0, &v[0]); - ffb_translate_vertex(ctx, v1, &v[1]); - ffb_translate_vertex(ctx, v2, &v[2]); - ffb_translate_vertex(ctx, v3, &v[3]); - - _swrast_Quad(ctx, &v[0], &v[1], &v[2], &v[3]); -} - -void ffb_fallback_line(GLcontext *ctx, ffb_vertex *v0, ffb_vertex *v1) -{ - SWvertex v[2]; - - ffb_translate_vertex(ctx, v0, &v[0]); - ffb_translate_vertex(ctx, v1, &v[1]); - - _swrast_Line(ctx, &v[0], &v[1]); -} - -void ffb_fallback_point(GLcontext *ctx, ffb_vertex *v0) -{ - SWvertex v[1]; - - ffb_translate_vertex(ctx, v0, &v[0]); - - _swrast_Point(ctx, &v[0]); -} - -/*********************************************************************** - * Rasterization functions for culled tris/quads * - ***********************************************************************/ - -static void ffb_nodraw_triangle(GLcontext *ctx, ffb_vertex *v0, - ffb_vertex *v1, ffb_vertex *v2) -{ - (void) (ctx && v0 && v1 && v2); -} - -static void ffb_nodraw_quad(GLcontext *ctx, - ffb_vertex *v0, ffb_vertex *v1, - ffb_vertex *v2, ffb_vertex *v3) -{ - (void) (ctx && v0 && v1 && v2 && v3); -} - -static void ffb_update_cullsign(GLcontext *ctx) -{ - GLfloat backface_sign = 1; - - switch (ctx->Polygon.CullFaceMode) { - case GL_BACK: - if (ctx->Polygon.FrontFace==GL_CCW) - backface_sign = -1; - break; - - case GL_FRONT: - if (ctx->Polygon.FrontFace!=GL_CCW) - backface_sign = -1; - break; - - default: - break; - }; - - FFB_CONTEXT(ctx)->backface_sign = backface_sign; -} - -/*********************************************************************** - * Choose triangle/quad rasterize functions * - ***********************************************************************/ - -void ffbChooseTriangleState(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint ind = 0; - - if (flags & DD_TRI_SMOOTH) { - fmesa->draw_tri = ffb_fallback_triangle; - fmesa->draw_quad = ffb_fallback_quad; - return; - } - - if (flags & DD_FLATSHADE) - ind |= FFB_TRI_FLAT_BIT; - - if (ctx->Polygon.CullFlag) { - if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { - fmesa->draw_tri = ffb_nodraw_triangle; - fmesa->draw_quad = ffb_nodraw_quad; - return; - } - - ind |= FFB_TRI_CULL_BIT; - ffb_update_cullsign(ctx); - } else - FFB_CONTEXT(ctx)->backface_sign = 0; - - /* If blending or the alpha test is enabled we need to - * provide alpha components to the chip, else we can - * do without it and thus feed vertex data to the chip - * more efficiently. - */ - if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled) - ind |= FFB_TRI_ALPHA_BIT; - - fmesa->draw_tri = ffb_tri_tab[ind]; - fmesa->draw_quad = ffb_quad_tab[ind]; -} - -static const GLenum reduced_prim[GL_POLYGON+1] = { - GL_POINTS, - GL_LINES, - GL_LINES, - GL_LINES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES -}; - -static void ffbRenderPrimitive(GLcontext *ctx, GLenum prim); -static void ffbRasterPrimitive(GLcontext *ctx, GLenum rprim); - -/*********************************************************************** - * Build render functions from dd templates * - ***********************************************************************/ - -#define FFB_OFFSET_BIT 0x01 -#define FFB_TWOSIDE_BIT 0x02 -#define FFB_UNFILLED_BIT 0x04 -#define FFB_MAX_TRIFUNC 0x08 - -static struct { - tnl_triangle_func triangle; - tnl_quad_func quad; -} rast_tab[FFB_MAX_TRIFUNC]; - -#define DO_OFFSET (IND & FFB_OFFSET_BIT) -#define DO_UNFILLED (IND & FFB_UNFILLED_BIT) -#define DO_TWOSIDE (IND & FFB_TWOSIDE_BIT) -#define DO_FLAT 0 -#define DO_QUAD 1 -#define DO_FULL_QUAD 1 -#define DO_TRI 1 -#define DO_LINE 0 -#define DO_POINTS 0 - -#define QUAD( a, b, c, d ) fmesa->draw_quad( ctx, a, b, c, d ) -#define TRI( a, b, c ) fmesa->draw_tri( ctx, a, b, c ) -#define LINE( a, b ) fmesa->draw_line( ctx, a, b ) -#define POINT( a ) fmesa->draw_point( ctx, a ) - -#define HAVE_BACK_COLORS 1 -#define HAVE_RGBA 1 -#define HAVE_SPEC 0 -#define HAVE_HW_FLATSHADE 1 -#define VERTEX ffb_vertex -#define TAB rast_tab - -#define UNFILLED_TRI unfilled_tri -#define UNFILLED_QUAD unfilled_quad -#define DEPTH_SCALE (fmesa->depth_scale) -#define VERT_X(_v) (_v->x) -#define VERT_Y(_v) (_v->y) -#define VERT_Z(_v) (_v->z) -#define AREA_IS_CCW( a ) (a < fmesa->ffb_zero) -#define GET_VERTEX(e) (&fmesa->verts[e]) -#define INSANE_VERTICES -#define VERT_SET_Z(v,val) ((v)->z = (val)) -#define VERT_Z_ADD(v,val) ((v)->z += (val)) - -#define VERT_COPY_RGBA1( _v ) _v->color[0] = _v->color[1] -#define VERT_COPY_RGBA( v0, v1 ) v0->color[0] = v1->color[0] -#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->color[0] -#define VERT_RESTORE_RGBA( idx ) v[idx]->color[0] = color[idx] - -#define LOCAL_VARS(n) \ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); \ - __DRIdrawable *dPriv = fmesa->driDrawable; \ - ffb_color color[n] = { { 0 } }; \ - (void) color; (void) dPriv; - -/*********************************************************************** - * Helpers for rendering unfilled primitives * - ***********************************************************************/ - -#define RASTERIZE(x) if (fmesa->raster_primitive != reduced_prim[x]) \ - ffbRasterPrimitive( ctx, reduced_prim[x] ) -#define RENDER_PRIMITIVE fmesa->render_primitive -#define TAG(x) x -#include "tnl_dd/t_dd_unfilled.h" - -/*********************************************************************** - * Generate GL render functions * - ***********************************************************************/ - -#define IND (0) -#define TAG(x) x -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FFB_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FFB_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FFB_TWOSIDE_BIT|FFB_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FFB_UNFILLED_BIT) -#define TAG(x) x##_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FFB_OFFSET_BIT|FFB_UNFILLED_BIT) -#define TAG(x) x##_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FFB_TWOSIDE_BIT|FFB_UNFILLED_BIT) -#define TAG(x) x##_twoside_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (FFB_TWOSIDE_BIT|FFB_OFFSET_BIT|FFB_UNFILLED_BIT) -#define TAG(x) x##_twoside_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -static void init_rast_tab( void ) -{ - init(); - init_offset(); - init_twoside(); - init_twoside_offset(); - init_unfilled(); - init_offset_unfilled(); - init_twoside_unfilled(); - init_twoside_offset_unfilled(); -} - -/**********************************************************************/ -/* Render clipped primitives */ -/**********************************************************************/ - -static void ffbRenderClippedPolygon(GLcontext *ctx, const GLuint *elts, GLuint n) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint prim = fmesa->render_primitive; - - /* Render the new vertices as an unclipped polygon. */ - { - GLuint *tmp = VB->Elts; - VB->Elts = (GLuint *)elts; - tnl->Driver.Render.PrimTabElts[GL_POLYGON](ctx, 0, n, PRIM_BEGIN|PRIM_END); - VB->Elts = tmp; - } - - /* Restore the render primitive. */ - if (prim != GL_POLYGON) - tnl->Driver.Render.PrimitiveNotify(ctx, prim); -} - -static void ffbRenderClippedLine(GLcontext *ctx, GLuint ii, GLuint jj) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line(ctx, ii, jj); -} - -/**********************************************************************/ -/* Render unclipped begin/end objects */ -/**********************************************************************/ - -static void ffb_vb_noop(GLcontext *ctx, GLuint start, GLuint count, GLuint flags) -{ - (void)(ctx && start && count && flags); -} - -#define ELT(x) x - -#define IND 0 -#define TAG(x) x -#include "ffb_rendertmp.h" - -#define IND (FFB_FLAT_BIT) -#define TAG(x) x##_flat -#include "ffb_rendertmp.h" - -#define IND (FFB_ALPHA_BIT) -#define TAG(x) x##_alpha -#include "ffb_rendertmp.h" - -#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT) -#define TAG(x) x##_flat_alpha -#include "ffb_rendertmp.h" - -#define IND (FFB_TRI_CULL_BIT) -#define TAG(x) x##_tricull -#include "ffb_rendertmp.h" - -#define IND (FFB_FLAT_BIT | FFB_TRI_CULL_BIT) -#define TAG(x) x##_flat_tricull -#include "ffb_rendertmp.h" - -#define IND (FFB_ALPHA_BIT | FFB_TRI_CULL_BIT) -#define TAG(x) x##_alpha_tricull -#include "ffb_rendertmp.h" - -#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT | FFB_TRI_CULL_BIT) -#define TAG(x) x##_flat_alpha_tricull -#include "ffb_rendertmp.h" - -#undef ELT -#define ELT(x) elt[x] - -#define IND 0 -#define TAG(x) x##_elt -#include "ffb_rendertmp.h" - -#define IND (FFB_FLAT_BIT) -#define TAG(x) x##_flat_elt -#include "ffb_rendertmp.h" - -#define IND (FFB_ALPHA_BIT) -#define TAG(x) x##_alpha_elt -#include "ffb_rendertmp.h" - -#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT) -#define TAG(x) x##_flat_alpha_elt -#include "ffb_rendertmp.h" - -#define IND (FFB_TRI_CULL_BIT) -#define TAG(x) x##_tricull_elt -#include "ffb_rendertmp.h" - -#define IND (FFB_FLAT_BIT | FFB_TRI_CULL_BIT) -#define TAG(x) x##_flat_tricull_elt -#include "ffb_rendertmp.h" - -#define IND (FFB_ALPHA_BIT | FFB_TRI_CULL_BIT) -#define TAG(x) x##_alpha_tricull_elt -#include "ffb_rendertmp.h" - -#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT | FFB_TRI_CULL_BIT) -#define TAG(x) x##_flat_alpha_tricull_elt -#include "ffb_rendertmp.h" - -static void *render_tabs[MAX_FFB_RENDER_FUNCS]; -static void *render_tabs_elt[MAX_FFB_RENDER_FUNCS]; - -static void init_render_tab(void) -{ - int i; - - render_tabs[0] = render_tab; - render_tabs[FFB_FLAT_BIT] = render_tab_flat; - render_tabs[FFB_ALPHA_BIT] = render_tab_alpha; - render_tabs[FFB_FLAT_BIT|FFB_ALPHA_BIT] = render_tab_flat_alpha; - render_tabs[FFB_TRI_CULL_BIT] = render_tab_tricull; - render_tabs[FFB_FLAT_BIT|FFB_TRI_CULL_BIT] = render_tab_flat_tricull; - render_tabs[FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] = render_tab_alpha_tricull; - render_tabs[FFB_FLAT_BIT|FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] = - render_tab_flat_alpha_tricull; - - render_tabs_elt[0] = render_tab_elt; - render_tabs_elt[FFB_FLAT_BIT] = render_tab_flat_elt; - render_tabs_elt[FFB_ALPHA_BIT] = render_tab_alpha_elt; - render_tabs_elt[FFB_FLAT_BIT|FFB_ALPHA_BIT] = render_tab_flat_alpha_elt; - render_tabs_elt[FFB_TRI_CULL_BIT] = render_tab_tricull_elt; - render_tabs_elt[FFB_FLAT_BIT|FFB_TRI_CULL_BIT] = render_tab_flat_tricull_elt; - render_tabs_elt[FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] = render_tab_alpha_tricull_elt; - render_tabs_elt[FFB_FLAT_BIT|FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] = - render_tab_flat_alpha_tricull_elt; - - for (i = 0; i < MAX_FFB_RENDER_FUNCS; i++) { - tnl_render_func *rf = render_tabs[i]; - tnl_render_func *rfe = render_tabs_elt[i]; - - if (i & FFB_TRI_CULL_BIT) { - int from_idx = (i & ~FFB_TRI_CULL_BIT); - tnl_render_func *rf_from = render_tabs[from_idx]; - tnl_render_func *rfe_from = render_tabs_elt[from_idx]; - int j; - - for (j = GL_POINTS; j < GL_TRIANGLES; j++) { - rf[j] = rf_from[j]; - rfe[j] = rfe_from[j]; - } - } - } -} - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - -#ifdef FFB_RENDER_TRACE -static void ffbPrintRenderFlags(GLuint index, GLuint render_index) -{ - fprintf(stderr, - "ffbChooseRenderState: " - "index(%s%s%s) " - "render_index(%s%s%s)\n", - ((index & FFB_TWOSIDE_BIT) ? "twoside " : ""), - ((index & FFB_OFFSET_BIT) ? "offset " : ""), - ((index & FFB_UNFILLED_BIT) ? "unfilled " : ""), - ((render_index & FFB_FLAT_BIT) ? "flat " : ""), - ((render_index & FFB_ALPHA_BIT) ? "alpha " : ""), - ((render_index & FFB_TRI_CULL_BIT) ? "tricull " : "")); -} -#endif - -void ffbChooseRenderState(GLcontext *ctx) -{ - GLuint flags = ctx->_TriangleCaps; - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint index = 0; - - /* Per-primitive fallbacks and the selection of fmesa->draw_* are - * handled elsewhere. - */ - if (flags & DD_TRI_LIGHT_TWOSIDE) - index |= FFB_TWOSIDE_BIT; - - if (flags & DD_TRI_OFFSET) - index |= FFB_OFFSET_BIT; - - if (flags & DD_TRI_UNFILLED) - index |= FFB_UNFILLED_BIT; - - tnl->Driver.Render.Triangle = rast_tab[index].triangle; - tnl->Driver.Render.Quad = rast_tab[index].quad; - - if (index == 0) { - GLuint render_index = 0; - - if (flags & DD_FLATSHADE) - render_index |= FFB_FLAT_BIT; - - if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled) - render_index |= FFB_ALPHA_BIT; - - if (ctx->Polygon.CullFlag) - render_index |= FFB_TRI_CULL_BIT; - -#ifdef FFB_RENDER_TRACE - ffbPrintRenderFlags(index, render_index); -#endif - tnl->Driver.Render.PrimTabVerts = render_tabs[render_index]; - tnl->Driver.Render.PrimTabElts = render_tabs_elt[render_index]; - } else { -#ifdef FFB_RENDER_TRACE - ffbPrintRenderFlags(index, 0); -#endif - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - } - - tnl->Driver.Render.ClippedPolygon = ffbRenderClippedPolygon; - tnl->Driver.Render.ClippedLine = ffbRenderClippedLine; -} - -static void ffbRunPipeline(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - if (fmesa->bad_fragment_attrs == 0 && - fmesa->new_gl_state) { - if (fmesa->new_gl_state & _FFB_NEW_TRIANGLE) - ffbChooseTriangleState(ctx); - if (fmesa->new_gl_state & _FFB_NEW_LINE) - ffbChooseLineState(ctx); - if (fmesa->new_gl_state & _FFB_NEW_POINT) - ffbChoosePointState(ctx); - if (fmesa->new_gl_state & _FFB_NEW_RENDER) - ffbChooseRenderState(ctx); - if (fmesa->new_gl_state & _FFB_NEW_VERTEX) - ffbChooseVertexState(ctx); - - fmesa->new_gl_state = 0; - } - - _tnl_run_pipeline(ctx); -} - -static void ffbRenderStart(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - LOCK_HARDWARE(fmesa); - fmesa->hw_locked = 1; - - if (fmesa->state_dirty != 0) - ffbSyncHardware(fmesa); -} - -static void ffbRenderFinish(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - UNLOCK_HARDWARE(fmesa); - fmesa->hw_locked = 0; -} - -/* Even when doing full software rendering we need to - * wrap render{start,finish} so that the hardware is kept - * in sync (because multipass rendering changes the write - * buffer etc.) - */ -static void ffbSWRenderStart(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - LOCK_HARDWARE(fmesa); - fmesa->hw_locked = 1; - - if (fmesa->state_dirty != 0) - ffbSyncHardware(fmesa); -} - -static void ffbSWRenderFinish(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - UNLOCK_HARDWARE(fmesa); - fmesa->hw_locked = 0; -} - -static void ffbRasterPrimitive(GLcontext *ctx, GLenum rprim) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - GLuint drawop, fbc, ppc; - int do_sw = 0; - - fmesa->raster_primitive = rprim; - - drawop = fmesa->drawop; - fbc = fmesa->fbc; - ppc = fmesa->ppc & ~(FFB_PPC_ZS_MASK | FFB_PPC_CS_MASK); - -#ifdef STATE_TRACE - fprintf(stderr, - "ffbReducedPrimitiveChange: rprim(%d) ", rprim); -#endif - switch(rprim) { - case GL_POINTS: -#ifdef STATE_TRACE - fprintf(stderr, "GL_POINTS "); -#endif - if (fmesa->draw_point == ffb_fallback_point) { - do_sw = 1; - break; - } - - if (ctx->Point.SmoothFlag) { - ppc |= (FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST); - drawop = FFB_DRAWOP_AADOT; - } else { - ppc |= (FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST); - drawop = FFB_DRAWOP_DOT; - } - break; - - case GL_LINES: -#ifdef STATE_TRACE - fprintf(stderr, "GL_LINES "); -#endif - if (fmesa->draw_line == ffb_fallback_line) { - do_sw = 1; - break; - } - - if (ctx->_TriangleCaps & DD_FLATSHADE) { - ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST; - } else { - ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR; - } - if (ctx->Line.SmoothFlag) - drawop = FFB_DRAWOP_AALINE; - else - drawop = FFB_DRAWOP_DDLINE; - break; - - case GL_TRIANGLES: -#ifdef STATE_TRACE - fprintf(stderr, "GL_POLYGON "); -#endif - if (fmesa->draw_tri == ffb_fallback_triangle) { - do_sw = 1; - break; - } - - ppc &= ~FFB_PPC_APE_MASK; - if (ctx->Polygon.StippleFlag) - ppc |= FFB_PPC_APE_ENABLE; - else - ppc |= FFB_PPC_APE_DISABLE; - - if (ctx->_TriangleCaps & DD_FLATSHADE) { - ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST; - } else { - ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR; - } - drawop = FFB_DRAWOP_TRIANGLE; - break; - - default: -#ifdef STATE_TRACE - fprintf(stderr, "unknown %d!\n", rprim); -#endif - return; - }; - -#ifdef STATE_TRACE - fprintf(stderr, "do_sw(%d) ", do_sw); -#endif - if (do_sw != 0) { - fbc &= ~(FFB_FBC_WB_C); - fbc &= ~(FFB_FBC_ZE_MASK | FFB_FBC_RGBE_MASK); - fbc |= FFB_FBC_ZE_OFF | FFB_FBC_RGBE_MASK; - ppc &= ~(FFB_PPC_XS_MASK | FFB_PPC_ABE_MASK | - FFB_PPC_DCE_MASK | FFB_PPC_APE_MASK); - ppc |= (FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR | FFB_PPC_XS_WID | - FFB_PPC_ABE_DISABLE | FFB_PPC_DCE_DISABLE | - FFB_PPC_APE_DISABLE); - } else { - fbc |= FFB_FBC_WB_C; - fbc &= ~(FFB_FBC_RGBE_MASK); - fbc |= FFB_FBC_RGBE_MASK; - ppc &= ~(FFB_PPC_ABE_MASK | FFB_PPC_XS_MASK); - if (ctx->Color.BlendEnabled) { - if ((rprim == GL_POINTS && !ctx->Point.SmoothFlag) || - (rprim != GL_POINTS && ctx->_TriangleCaps & DD_FLATSHADE)) - ppc |= FFB_PPC_ABE_ENABLE | FFB_PPC_XS_CONST; - else - ppc |= FFB_PPC_ABE_ENABLE | FFB_PPC_XS_VAR; - } else { - ppc |= FFB_PPC_ABE_DISABLE | FFB_PPC_XS_WID; - } - } -#ifdef STATE_TRACE - fprintf(stderr, "fbc(%08x) ppc(%08x)\n", fbc, ppc); -#endif - - FFBFifo(fmesa, 4); - if (fmesa->drawop != drawop) - fmesa->regs->drawop = fmesa->drawop = drawop; - if (fmesa->fbc != fbc) - fmesa->regs->fbc = fmesa->fbc = fbc; - if (fmesa->ppc != ppc) - fmesa->regs->ppc = fmesa->ppc = ppc; - if (do_sw != 0) { - fmesa->regs->cmp = - (fmesa->cmp & ~(0xff<<16)) | (0x80 << 16); - } else - fmesa->regs->cmp = fmesa->cmp; -} - -static void ffbRenderPrimitive(GLcontext *ctx, GLenum prim) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - GLuint rprim = reduced_prim[prim]; - - fmesa->render_primitive = prim; - - if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED)) - return; - - if (fmesa->raster_primitive != rprim) { - ffbRasterPrimitive( ctx, rprim ); - } -} - - - - -/**********************************************************************/ -/* Transition to/from hardware rasterization. */ -/**********************************************************************/ - -static char *fallbackStrings[] = { - "Fog enabled", - "Blend function", - "Blend ROP", - "Blend equation", - "Stencil", - "Texture", - "LIBGL_SOFTWARE_RENDERING" -}; - -static char *getFallbackString(GLuint bit) -{ - int i = 0; - - while (bit > 1) { - i++; - bit >>= 1; - } - return fallbackStrings[i]; -} - -void ffbFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint oldfallback = fmesa->bad_fragment_attrs; - - if (mode) { - fmesa->bad_fragment_attrs |= bit; - if (oldfallback == 0) { -/* FFB_FIREVERTICES(fmesa); */ - _swsetup_Wakeup( ctx ); - if (fmesa->debugFallbacks) - fprintf(stderr, "FFB begin software fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } else { - fmesa->bad_fragment_attrs &= ~bit; - if (oldfallback == bit) { - _swrast_flush( ctx ); - - tnl->Driver.Render.Start = ffbRenderStart; - tnl->Driver.Render.PrimitiveNotify = ffbRenderPrimitive; - tnl->Driver.Render.Finish = ffbRenderFinish; - fmesa->new_gl_state = ~0; - - /* Just re-choose everything: - */ - ffbChooseVertexState(ctx); - ffbChooseRenderState(ctx); - ffbChooseTriangleState(ctx); - ffbChooseLineState(ctx); - ffbChoosePointState(ctx); - - if (fmesa->debugFallbacks) - fprintf(stderr, "FFB end software fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } -} - -/**********************************************************************/ -/* Initialization. */ -/**********************************************************************/ - -void ffbDDInitRenderFuncs( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - SWcontext *swrast = SWRAST_CONTEXT(ctx); - static int firsttime = 1; - - if (firsttime) { - init_rast_tab(); - init_tri_tab(); - init_render_tab(); - firsttime = 0; - } - - tnl->Driver.RunPipeline = ffbRunPipeline; - tnl->Driver.Render.Start = ffbRenderStart; - tnl->Driver.Render.Finish = ffbRenderFinish; - tnl->Driver.Render.PrimitiveNotify = ffbRenderPrimitive; - tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - - swrast->Driver.SpanRenderStart = ffbSWRenderStart; - swrast->Driver.SpanRenderFinish = ffbSWRenderFinish; -} diff --git a/src/mesa/drivers/dri/ffb/ffb_tris.h b/src/mesa/drivers/dri/ffb/ffb_tris.h deleted file mode 100644 index 116b8e07f15..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_tris.h +++ /dev/null @@ -1,25 +0,0 @@ - -#ifndef _FFB_TRIS_H -#define _FFB_TRIS_H - -extern void ffbDDInitRenderFuncs( GLcontext *ctx ); - - -#define _FFB_NEW_RENDER (_DD_NEW_TRI_LIGHT_TWOSIDE | \ - _DD_NEW_TRI_OFFSET | \ - _DD_NEW_TRI_UNFILLED) - -extern void ffbChooseRenderState(GLcontext *ctx); - - -#define _FFB_NEW_TRIANGLE (_DD_NEW_TRI_SMOOTH | \ - _DD_NEW_FLATSHADE | \ - _NEW_POLYGON | \ - _NEW_COLOR) - -extern void ffbChooseTriangleState(GLcontext *ctx); - -extern void ffbFallback( GLcontext *ctx, GLuint bit, GLboolean mode ); -#define FALLBACK( ctx, bit, mode ) ffbFallback( ctx, bit, mode ) - -#endif /* !(_FFB_TRIS_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_tritmp.h b/src/mesa/drivers/dri/ffb/ffb_tritmp.h deleted file mode 100644 index 324a871ec42..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_tritmp.h +++ /dev/null @@ -1,238 +0,0 @@ - -static void TAG(ffb_triangle)( GLcontext *ctx, - ffb_vertex *v0, - ffb_vertex *v1, - ffb_vertex *v2 ) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - ffb_fbcPtr ffb = fmesa->regs; -#if (IND & FFB_TRI_FLAT_BIT) - GLuint const_fg; -#endif - FFB_DELAYED_VIEWPORT_VARS; - -#ifdef TRI_DEBUG - fprintf(stderr, "FFB: ffb_triangle [" -#if (IND & FFB_TRI_CULL_BIT) - " CULL" -#endif -#if (IND & FFB_TRI_FLAT_BIT) - " FLAT" -#endif -#if (IND & FFB_TRI_ALPHA_BIT) - " ALPHA" -#endif - " ]\n"); -#endif - -#if (IND & FFB_TRI_CULL_BIT) - { /* NOTE: These are not viewport transformed yet. */ - GLfloat ex = v1->x - v0->x; - GLfloat ey = v1->y - v0->y; - GLfloat fx = v2->x - v0->x; - GLfloat fy = v2->y - v0->y; - GLfloat c = ex*fy-ey*fx; - - /* Culled... */ - if (c * fmesa->backface_sign > fmesa->ffb_zero) - return; - } -#endif - -#if (IND & FFB_TRI_FLAT_BIT) - const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( v2->color[0] ); -#ifdef TRI_DEBUG - fprintf(stderr, "FFB_tri: const_fg %08x (B[%f] G[%f] R[%f])\n", - const_fg, - FFB_2_30_FIXED_TO_FLOAT(v2->color[0].blue), - FFB_2_30_FIXED_TO_FLOAT(v2->color[0].green), - FFB_2_30_FIXED_TO_FLOAT(v2->color[0].red)); -#endif -#endif - - -#if (IND & FFB_TRI_FLAT_BIT) - FFBFifo(fmesa, 1); - ffb->fg = const_fg; -#endif - -#if (IND & FFB_TRI_FLAT_BIT) - FFBFifo(fmesa, 9); -#else -#if (IND & FFB_TRI_ALPHA_BIT) - FFBFifo(fmesa, 21); -#else - FFBFifo(fmesa, 18); -#endif -#endif - - FFB_DUMP_VERTEX(v0); -#if !(IND & FFB_TRI_FLAT_BIT) -#if (IND & FFB_TRI_ALPHA_BIT) - ffb->alpha = FFB_GET_ALPHA(v0); -#endif - ffb->red = FFB_GET_RED(v0); - ffb->green = FFB_GET_GREEN(v0); - ffb->blue = FFB_GET_BLUE(v0); -#endif - ffb->z = FFB_GET_Z(v0); - ffb->ryf = FFB_GET_Y(v0); - ffb->rxf = FFB_GET_X(v0); - - FFB_DUMP_VERTEX(v1); -#if !(IND & FFB_TRI_FLAT_BIT) -#if (IND & FFB_TRI_ALPHA_BIT) - ffb->alpha = FFB_GET_ALPHA(v1); -#endif - ffb->red = FFB_GET_RED(v1); - ffb->green = FFB_GET_GREEN(v1); - ffb->blue = FFB_GET_BLUE(v1); -#endif - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - - FFB_DUMP_VERTEX(v2); -#if !(IND & FFB_TRI_FLAT_BIT) -#if (IND & FFB_TRI_ALPHA_BIT) - ffb->alpha = FFB_GET_ALPHA(v2); -#endif - ffb->red = FFB_GET_RED(v2); - ffb->green = FFB_GET_GREEN(v2); - ffb->blue = FFB_GET_BLUE(v2); -#endif - ffb->z = FFB_GET_Z(v2); - ffb->y = FFB_GET_Y(v2); - ffb->x = FFB_GET_X(v2); - - fmesa->ffbScreen->rp_active = 1; -} - - -static void TAG(ffb_quad)(GLcontext *ctx, - ffb_vertex *v0, - ffb_vertex *v1, - ffb_vertex *v2, - ffb_vertex *v3 ) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - ffb_fbcPtr ffb = fmesa->regs; -#if (IND & FFB_TRI_FLAT_BIT) - GLuint const_fg; -#endif - FFB_DELAYED_VIEWPORT_VARS; - -#ifdef TRI_DEBUG - fprintf(stderr, "FFB: ffb_quad [" -#if (IND & FFB_TRI_CULL_BIT) - " CULL" -#endif -#if (IND & FFB_TRI_FLAT_BIT) - " FLAT" -#endif -#if (IND & FFB_TRI_ALPHA_BIT) - " ALPHA" -#endif - " ]\n"); -#endif /* TRI_DEBUG */ - -#if (IND & FFB_TRI_CULL_BIT) - { /* NOTE: These are not viewport transformed yet. */ - GLfloat ex = v2->x - v0->x; - GLfloat ey = v2->y - v0->y; - GLfloat fx = v3->x - v1->x; - GLfloat fy = v3->y - v1->y; - GLfloat c = ex*fy-ey*fx; - - /* Culled... */ - if (c * fmesa->backface_sign > fmesa->ffb_zero) - return; - } -#endif - -#if (IND & FFB_TRI_FLAT_BIT) - const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( v3->color[0] ); -#ifdef TRI_DEBUG - fprintf(stderr, "FFB_quad: const_fg %08x (B[%f] G[%f] R[%f])\n", - const_fg, - FFB_2_30_FIXED_TO_FLOAT(v3->color[0].blue), - FFB_2_30_FIXED_TO_FLOAT(v3->color[0].green), - FFB_2_30_FIXED_TO_FLOAT(v3->color[0].red)); -#endif -#endif - - -#if (IND & FFB_TRI_FLAT_BIT) - FFBFifo(fmesa, 13); - ffb->fg = const_fg; -#else -#if (IND & FFB_TRI_ALPHA_BIT) - FFBFifo(fmesa, 28); -#else - FFBFifo(fmesa, 24); -#endif -#endif - - FFB_DUMP_VERTEX(v0); -#if !(IND & FFB_TRI_FLAT_BIT) -#if (IND & FFB_TRI_ALPHA_BIT) - ffb->alpha = FFB_GET_ALPHA(v0); -#endif - ffb->red = FFB_GET_RED(v0); - ffb->green = FFB_GET_GREEN(v0); - ffb->blue = FFB_GET_BLUE(v0); -#endif - ffb->z = FFB_GET_Z(v0); - ffb->ryf = FFB_GET_Y(v0); - ffb->rxf = FFB_GET_X(v0); - - FFB_DUMP_VERTEX(v1); -#if !(IND & FFB_TRI_FLAT_BIT) -#if (IND & FFB_TRI_ALPHA_BIT) - ffb->alpha = FFB_GET_ALPHA(v1); -#endif - ffb->red = FFB_GET_RED(v1); - ffb->green = FFB_GET_GREEN(v1); - ffb->blue = FFB_GET_BLUE(v1); -#endif - ffb->z = FFB_GET_Z(v1); - ffb->y = FFB_GET_Y(v1); - ffb->x = FFB_GET_X(v1); - - FFB_DUMP_VERTEX(v2); -#if !(IND & FFB_TRI_FLAT_BIT) -#if (IND & FFB_TRI_ALPHA_BIT) - ffb->alpha = FFB_GET_ALPHA(v2); -#endif - ffb->red = FFB_GET_RED(v2); - ffb->green = FFB_GET_GREEN(v2); - ffb->blue = FFB_GET_BLUE(v2); -#endif - ffb->z = FFB_GET_Z(v2); - ffb->y = FFB_GET_Y(v2); - ffb->x = FFB_GET_X(v2); - - FFB_DUMP_VERTEX(v3); -#if !(IND & FFB_TRI_FLAT_BIT) -#if (IND & FFB_TRI_ALPHA_BIT) - ffb->alpha = FFB_GET_ALPHA(v3); -#endif - ffb->red = FFB_GET_RED(v3); - ffb->green = FFB_GET_GREEN(v3); - ffb->blue = FFB_GET_BLUE(v3); -#endif - ffb->z = FFB_GET_Z(v3); - ffb->dmyf = FFB_GET_Y(v3); - ffb->dmxf = FFB_GET_X(v3); - - fmesa->ffbScreen->rp_active = 1; -} - -static void TAG(ffb_init)(void) -{ - ffb_tri_tab[IND] = TAG(ffb_triangle); - ffb_quad_tab[IND] = TAG(ffb_quad); -} - -#undef IND -#undef TAG diff --git a/src/mesa/drivers/dri/ffb/ffb_vb.c b/src/mesa/drivers/dri/ffb/ffb_vb.c deleted file mode 100644 index a53e7c74319..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_vb.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2000, 2001 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "ffb_xmesa.h" -#include "ffb_context.h" -#include "ffb_vb.h" -#include "main/imports.h" -#include "tnl/t_context.h" - -#undef VB_DEBUG - -static void ffb_copy_pv_oneside(GLcontext *ctx, GLuint edst, GLuint esrc) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - ffb_vertex *dst = &fmesa->verts[edst]; - ffb_vertex *src = &fmesa->verts[esrc]; - -#ifdef VB_DEBUG - fprintf(stderr, "ffb_copy_pv_oneside: edst(%d) esrc(%d)\n", edst, esrc); -#endif - dst->color[0].alpha = src->color[0].alpha; - dst->color[0].red = src->color[0].red; - dst->color[0].green = src->color[0].green; - dst->color[0].blue = src->color[0].blue; -} - -static void ffb_copy_pv_twoside(GLcontext *ctx, GLuint edst, GLuint esrc) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - ffb_vertex *dst = &fmesa->verts[edst]; - ffb_vertex *src = &fmesa->verts[esrc]; - -#ifdef VB_DEBUG - fprintf(stderr, "ffb_copy_pv_twoside: edst(%d) esrc(%d)\n", edst, esrc); -#endif - dst->color[0].alpha = src->color[0].alpha; - dst->color[0].red = src->color[0].red; - dst->color[0].green = src->color[0].green; - dst->color[0].blue = src->color[0].blue; - dst->color[1].alpha = src->color[1].alpha; - dst->color[1].red = src->color[1].red; - dst->color[1].green = src->color[1].green; - dst->color[1].blue = src->color[1].blue; -} - -#define FFB_VB_RGBA_BIT 0x01 -#define FFB_VB_XYZ_BIT 0x02 -#define FFB_VB_TWOSIDE_BIT 0x04 -#define FFB_VB_MAX 0x08 - -typedef void (*ffb_emit_func)(GLcontext *, GLuint, GLuint); - -static struct { - ffb_emit_func emit; - tnl_interp_func interp; -} setup_tab[FFB_VB_MAX]; - - -#define IND (FFB_VB_XYZ_BIT) -#define TAG(x) x##_w -#include "ffb_vbtmp.h" - -#define IND (FFB_VB_RGBA_BIT) -#define TAG(x) x##_g -#include "ffb_vbtmp.h" - -#define IND (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT) -#define TAG(x) x##_wg -#include "ffb_vbtmp.h" - -#define IND (FFB_VB_TWOSIDE_BIT) -#define TAG(x) x##_t -#include "ffb_vbtmp.h" - -#define IND (FFB_VB_XYZ_BIT | FFB_VB_TWOSIDE_BIT) -#define TAG(x) x##_wt -#include "ffb_vbtmp.h" - -#define IND (FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT) -#define TAG(x) x##_gt -#include "ffb_vbtmp.h" - -#define IND (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT) -#define TAG(x) x##_wgt -#include "ffb_vbtmp.h" - -static void init_setup_tab( void ) -{ - init_w(); - init_g(); - init_wg(); - init_t(); - init_wt(); - init_gt(); - init_wgt(); -} - -#ifdef VB_DEBUG -static void ffbPrintSetupFlags(char *msg, GLuint flags) -{ - fprintf(stderr, "%s(%x): %s%s%s\n", - msg, - (int)flags, - (flags & FFB_VB_XYZ_BIT) ? " xyz," : "", - (flags & FFB_VB_RGBA_BIT) ? " rgba," : "", - (flags & FFB_VB_TWOSIDE_BIT) ? " twoside," : ""); -} -#endif - -static void ffbDDBuildVertices(GLcontext *ctx, GLuint start, GLuint count, - GLuint newinputs) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - newinputs |= fmesa->setupnewinputs; - fmesa->setupnewinputs = 0; - - if (!newinputs) - return; - - if (newinputs & VERT_BIT_POS) { - setup_tab[fmesa->setupindex].emit(ctx, start, count); - } else { - GLuint ind = 0; - - if (newinputs & VERT_BIT_COLOR0) - ind |= (FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT); - - ind &= fmesa->setupindex; - - if (ind) - setup_tab[ind].emit(ctx, start, count); - } -} - -void ffbChooseVertexState( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - int ind = FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT; - - if (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE) - ind |= FFB_VB_TWOSIDE_BIT; - -#ifdef VB_DEBUG - ffbPrintSetupFlags("ffb: full setup function", ind); -#endif - - fmesa->setupindex = ind; - - tnl->Driver.Render.BuildVertices = ffbDDBuildVertices; - tnl->Driver.Render.Interp = setup_tab[ind].interp; - if (ind & FFB_VB_TWOSIDE_BIT) - tnl->Driver.Render.CopyPV = ffb_copy_pv_twoside; - else - tnl->Driver.Render.CopyPV = ffb_copy_pv_oneside; -} - -void ffbInitVB( GLcontext *ctx ) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - GLuint size = TNL_CONTEXT(ctx)->vb.Size; - - fmesa->verts = (ffb_vertex *)_mesa_align_malloc(size * sizeof(ffb_vertex), 32); - - { - static int firsttime = 1; - if (firsttime) { - init_setup_tab(); - firsttime = 0; - } - } -} - - -void ffbFreeVB( GLcontext *ctx ) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - if (fmesa->verts) { - _mesa_align_free(fmesa->verts); - fmesa->verts = 0; - } -} diff --git a/src/mesa/drivers/dri/ffb/ffb_vb.h b/src/mesa/drivers/dri/ffb/ffb_vb.h deleted file mode 100644 index 238b9940bfa..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_vb.h +++ /dev/null @@ -1,44 +0,0 @@ - -#ifndef _FFB_VB_H -#define _FFB_VB_H - -#include "main/mtypes.h" -#include "main/macros.h" -#include "tnl/t_context.h" -#include "swrast/swrast.h" - -#define __FFB_2_30_FIXED_SCALE 1073741824.0f -#define FFB_2_30_FLOAT_TO_FIXED(X) \ - (IROUND((X) * fmesa->ffb_2_30_fixed_scale)) -#define FFB_2_30_FIXED_TO_FLOAT(X) \ - (((GLfloat)(X)) * fmesa->ffb_one_over_2_30_fixed_scale) - -#define __FFB_16_16_FIXED_SCALE 65536.0f -#define FFB_16_16_FLOAT_TO_FIXED(X) \ - (IROUND((X) * fmesa->ffb_16_16_fixed_scale)) -#define FFB_16_16_FIXED_TO_FLOAT(X) \ - (((GLfloat)(X)) * fmesa->ffb_one_over_16_16_fixed_scale) - -#define FFB_Z_FROM_FLOAT(VAL) FFB_2_30_FLOAT_TO_FIXED(VAL) -#define FFB_Z_TO_FLOAT(VAL) FFB_2_30_FIXED_TO_FLOAT(VAL) -#define FFB_XY_FROM_FLOAT(VAL) FFB_16_16_FLOAT_TO_FIXED(VAL) -#define FFB_XY_TO_FLOAT(VAL) FFB_16_16_FIXED_TO_FLOAT(VAL) - -#define FFB_UBYTE_FROM_COLOR(VAL) ((IROUND((VAL) * fmesa->ffb_ubyte_color_scale))) - -#define FFB_PACK_CONST_UBYTE_ARGB_COLOR(C) \ - ((FFB_UBYTE_FROM_COLOR(C.alpha) << 24) | \ - (FFB_UBYTE_FROM_COLOR(C.blue) << 16) | \ - (FFB_UBYTE_FROM_COLOR(C.green) << 8) | \ - (FFB_UBYTE_FROM_COLOR(C.red) << 0)) - -#define FFB_COLOR_FROM_FLOAT(VAL) FFB_2_30_FLOAT_TO_FIXED(VAL) - -#define _FFB_NEW_VERTEX (_DD_NEW_TRI_LIGHT_TWOSIDE) - -extern void ffbDDSetupInit(void); -extern void ffbChooseVertexState(GLcontext *); -extern void ffbInitVB( GLcontext *ctx ); -extern void ffbFreeVB( GLcontext *ctx ); - -#endif /* !(_FFB_VB_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_vbtmp.h b/src/mesa/drivers/dri/ffb/ffb_vbtmp.h deleted file mode 100644 index c548ef3ad58..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_vbtmp.h +++ /dev/null @@ -1,150 +0,0 @@ - -static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); -#if defined(VB_DEBUG) || (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT)) - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; -#endif -#if (IND & (FFB_VB_RGBA_BIT)) - GLfloat (*col0)[4]; - GLuint col0_stride; -#if (IND & (FFB_VB_TWOSIDE_BIT)) - GLfloat (*col1)[4]; - GLuint col1_stride; -#endif -#endif -#if (IND & FFB_VB_XYZ_BIT) - GLfloat (*proj)[4] = VB->NdcPtr->data; - GLuint proj_stride = VB->NdcPtr->stride; - const GLubyte *mask = VB->ClipMask; -#endif - ffb_vertex *v = &fmesa->verts[start]; - int i; - -#ifdef VB_DEBUG - fprintf(stderr, "FFB: ffb_emit [" -#if (IND & (FFB_VB_XYZ_BIT)) - " XYZ" -#endif -#if (IND & (FFB_VB_RGBA_BIT)) - " RGBA" -#endif -#if (IND & (FFB_VB_TWOSIDE_BIT)) - " TWOSIDE" -#endif - "] start(%d) end(%d) import(%d)\n", - start, end, - VB->importable_data); -#endif - -#if (IND & (FFB_VB_RGBA_BIT)) - col0 = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data; - col0_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride; -#if (IND & (FFB_VB_TWOSIDE_BIT)) - col1 = VB->BackfaceColorPtr->data; - col1_stride = VB->BackfaceColorPtr->stride; -#endif -#endif - - { - if (start) { -#if (IND & (FFB_VB_XYZ_BIT)) - proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride); -#endif -#if (IND & (FFB_VB_RGBA_BIT)) - col0 = (GLfloat (*)[4])((GLubyte *)col0 + start * col0_stride); -#if (IND & (FFB_VB_TWOSIDE_BIT)) - col1 = (GLfloat (*)[4])((GLubyte *)col1 + start * col1_stride); -#endif -#endif - } - for (i = start; i < end; i++, v++) { -#if (IND & (FFB_VB_XYZ_BIT)) - if (mask[i] == 0) { - v->x = proj[0][0]; - v->y = proj[0][1]; - v->z = proj[0][2]; - } - proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride); -#endif -#if (IND & (FFB_VB_RGBA_BIT)) - v->color[0].alpha = CLAMP(col0[0][3], 0.0f, 1.0f); - v->color[0].red = CLAMP(col0[0][0], 0.0f, 1.0f); - v->color[0].green = CLAMP(col0[0][1], 0.0f, 1.0f); - v->color[0].blue = CLAMP(col0[0][2], 0.0f, 1.0f); - col0 = (GLfloat (*)[4])((GLubyte *)col0 + col0_stride); -#if (IND & (FFB_VB_TWOSIDE_BIT)) - v->color[1].alpha = CLAMP(col1[0][3], 0.0f, 1.0f); - v->color[1].red = CLAMP(col1[0][0], 0.0f, 1.0f); - v->color[1].green = CLAMP(col1[0][1], 0.0f, 1.0f); - v->color[1].blue = CLAMP(col1[0][2], 0.0f, 1.0f); - col1 = (GLfloat (*)[4])((GLubyte *)col1 + col1_stride); -#endif -#endif - } - } -} - -static void TAG(interp)(GLcontext *ctx, GLfloat t, - GLuint edst, GLuint eout, GLuint ein, - GLboolean force_boundary) -{ -#if (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT)) - ffbContextPtr fmesa = FFB_CONTEXT(ctx); -#endif -#if (IND & (FFB_VB_XYZ_BIT)) - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - const GLfloat *dstclip = VB->ClipPtr->data[edst]; - GLfloat oow = 1.0 / dstclip[3]; -#endif -#if (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT)) - ffb_vertex *dst = &fmesa->verts[edst]; -#endif -#if (IND & (FFB_VB_RGBA_BIT)) - ffb_vertex *in = &fmesa->verts[eout]; - ffb_vertex *out = &fmesa->verts[ein]; -#endif - -#ifdef VB_DEBUG - fprintf(stderr, "FFB: ffb_interp [" -#if (IND & (FFB_VB_XYZ_BIT)) - " XYZ" -#endif -#if (IND & (FFB_VB_RGBA_BIT)) - " RGBA" -#endif -#if (IND & (FFB_VB_TWOSIDE_BIT)) - " TWOSIDE" -#endif - "] edst(%d) eout(%d) ein(%d)\n", - edst, eout, ein); -#endif - -#if (IND & (FFB_VB_XYZ_BIT)) - dst->x = dstclip[0] * oow; - dst->y = dstclip[1] * oow; - dst->z = dstclip[2] * oow; -#endif - -#if (IND & (FFB_VB_RGBA_BIT)) - INTERP_F(t, dst->color[0].alpha, out->color[0].alpha, in->color[0].alpha); - INTERP_F(t, dst->color[0].red, out->color[0].red, in->color[0].red); - INTERP_F(t, dst->color[0].green, out->color[0].green, in->color[0].green); - INTERP_F(t, dst->color[0].blue, out->color[0].blue, in->color[0].blue); -#if (IND & (FFB_VB_TWOSIDE_BIT)) - INTERP_F(t, dst->color[1].alpha, out->color[1].alpha, in->color[1].alpha); - INTERP_F(t, dst->color[1].red, out->color[1].red, in->color[1].red); - INTERP_F(t, dst->color[1].green, out->color[1].green, in->color[1].green); - INTERP_F(t, dst->color[1].blue, out->color[1].blue, in->color[1].blue); -#endif -#endif -} - -static void TAG(init)(void) -{ - setup_tab[IND].emit = TAG(emit); - setup_tab[IND].interp = TAG(interp); -} - -#undef IND -#undef TAG diff --git a/src/mesa/drivers/dri/ffb/ffb_vtxfmt.c b/src/mesa/drivers/dri/ffb/ffb_vtxfmt.c deleted file mode 100644 index 90f44b0e911..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_vtxfmt.c +++ /dev/null @@ -1,414 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2001 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "main/glheader.h" -#include "api_noop.h" -#include "main/context.h" -#include "light.h" -#include "main/macros.h" -#include "main/imports.h" -#include "main/mtypes.h" -#include "main/simple_list.h" -#include "vtxfmt.h" -#include "ffb_xmesa.h" -#include "ffb_context.h" -#include "ffb_vb.h" -#include "tnl/tnl.h" -#include "tnl/tcontext.h" - -#include "ffb_vtxfmt.h" - -#define TNL_VERTEX ffbTnlVertex - -#define INTERP_RGBA(t, out, a, b) \ -do { \ - GLint i; \ - for ( i = 0 ; i < 4 ; i++ ) { \ - GLfloat fa = a[i]; \ - GLfloat fb = b[i]; \ - out[i] = LINTERP( t, fa, fb ); \ - } \ -} while (0) - -/* Color functions: */ - -static INLINE void ffb_recalc_base_color(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - struct gl_light *light; - - COPY_3V(fmesa->vtx_state.light.base_color, ctx->Light._BaseColor[0]); - foreach (light, &ctx->Light.EnabledList) { - ACC_3V(fmesa->vtx_state.light.base_color, - light->_MatAmbient[0]); - } - - fmesa->vtx_state.light.base_alpha = ctx->Light._BaseAlpha[0]; -} - -#define GET_CURRENT \ - GET_CURRENT_CONTEXT(ctx); \ - ffbContextPtr fmesa = FFB_CONTEXT(ctx) - -#define CURRENT_COLOR(COMP) fmesa->vtx_state.current.color[COMP] -#define CURRENT_SPECULAR(COMP) fmesa->vtx_state.current.specular[COMP] -#define COLOR_IS_FLOAT -#define RECALC_BASE_COLOR(ctx) ffb_recalc_base_color(ctx) - -#define TAG(x) ffb_##x -#include "tnl_dd/t_dd_imm_capi.h" - -/* Normal functions: */ - -struct ffb_norm_tab { - void (*normal3f_multi)(GLfloat x, GLfloat y, GLfloat z); - void (*normal3fv_multi)(const GLfloat *v); - void (*normal3f_single)(GLfloat x, GLfloat y, GLfloat z); - void (*normal3fv_single)(const GLfloat *v); -}; - -static struct ffb_norm_tab norm_tab[0x4]; - -#define HAVE_HW_LIGHTING 0 -#define GET_CURRENT_VERTEX \ - GET_CURRENT_CONTEXT(ctx); \ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); \ - ffbTnlVertexPtr v = fmesa->imm.v0 - -#define CURRENT_NORMAL fmesa->vtx_state.current.normal -#define BASE_COLOR fmesa->vtx_state.light.base_color -#define BASE_ALPHA fmesa->vtx_state.light.base_alpha -#define VERT_COLOR( COMP ) v->color[COMP] -#define VERT_COLOR_IS_FLOAT - -#define IND (0) -#define TAG(x) ffb_##x -#define PRESERVE_NORMAL_DEFS -#include "tnl_dd/t_dd_imm_napi.h" - -#define IND (NORM_RESCALE) -#define TAG(x) ffb_##x##_rescale -#define PRESERVE_NORMAL_DEFS -#include "tnl_dd/t_dd_imm_napi.h" - -#define IND (NORM_NORMALIZE) -#define TAG(x) ffb_##x##_normalize -#include "tnl_dd/t_dd_imm_napi.h" - -static void ffb_init_norm_funcs(void) -{ - ffb_init_norm(); - ffb_init_norm_rescale(); - ffb_init_norm_normalize(); -} - -static void choose_normals(void) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint index; - - if (ctx->Light.Enabled) { - if (ctx->Transform.Normalize) { - index = NORM_NORMALIZE; - } else if (!ctx->Transform.RescaleNormals && - ctx->_ModelViewInvScale != 1.0) { - index = NORM_RESCALE; - } else { - index = 0; - } - - if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev) { - SET_Normal3f(ctx->Exec, norm_tab[index].normal3f_single); - SET_Normal3fv(ctx->Exec, norm_tab[index].normal3fv_single); - } else { - SET_Normal3f(ctx->Exec, norm_tab[index].normal3f_multi); - SET_Normal3fv(ctx->Exec, norm_tab[index].normal3fv_multi); - } - } else { - SET_Normal3f(ctx->Exec, _mesa_noop_Normal3f); - SET_Normal3fv(ctx->Exec, _mesa_noop_Normal3fv); - } -} - -static void ffb_choose_Normal3f(GLfloat x, GLfloat y, GLfloat z) -{ - choose_normals(); - CALL_Normal3f(GET_DISPATCH(), (x, y, z)); -} - -static void ffb_choose_Normal3fv(const GLfloat *v) -{ - choose_normals(); - CALL_Normal3fv(GET_DISPATCH(), (v)); -} - -/* Vertex functions: */ - -#define GET_CURRENT_VERTEX \ - GET_CURRENT_CONTEXT(ctx); \ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); \ - ffbTnlVertexPtr v = fmesa->imm.v0 - -#define CURRENT_VERTEX v->obj -#define SAVE_VERTEX fmesa->imm.save_vertex(ctx, v) - -#define TAG(x) ffb_##x -#include "tnl_dd/t_dd_imm_vapi.h" - -struct ffb_vert_tab { - void (*save_vertex)(GLcontext *ctx, ffbTnlVertexPtr v); - void (*interpolate_vertex)(GLfloat t, - ffbTnlVertex *O, - const ffbTnlVertex *I, - const ffbTnlVertex *J); -}; - -static struct ffb_vert_tab vert_tab[0xf]; - -#define VTX_NORMAL 0x0 -#define VTX_RGBA 0x1 - -#define LOCAL_VARS \ - ffbContextPtr fmesa = FFB_CONTEXT(ctx) - -#define CURRENT_COLOR fmesa->vtx_state.current.color -#define COLOR_IS_FLOAT -#define FLUSH_VERTEX fmesa->imm.flush_vertex( ctx, v ); - -#define IND (VTX_NORMAL) -#define TAG(x) ffb_##x##_NORMAL -#define PRESERVE_VERTEX_DEFS -#include "tnl_dd/t_dd_imm_vertex.h" - -#define IND (VTX_RGBA) -#define TAG(x) ffb_##x##_RGBA -#include "tnl_dd/t_dd_imm_vertex.h" - -static void ffb_init_vert_funcs( void ) -{ - ffb_init_vert_NORMAL(); - ffb_init_vert_RGBA(); -} - -#define LOCAL_VARS \ - ffbContextPtr fmesa = FFB_CONTEXT(ctx) - -#define GET_INTERP_FUNC \ - ffb_interp_func interp = fmesa->imm.interp - -#define FLUSH_VERTEX fmesa->imm.flush_vertex -#define IMM_VERTEX( V ) fmesa->imm.V -#define IMM_VERTICES( n ) fmesa->imm.vertices[n] - -#define EMIT_VERTEX_USES_HWREGS - -/* XXX Implement me XXX */ -#define EMIT_VERTEX_TRI(VTX0, VTX1, VTX2) \ - do { } while (0) -#define EMIT_VERTEX_LINE(VTX0, VTX1) \ - do { } while (0) -#define EMIT_VERTEX_POINT(VTX0) \ - do { } while (0) - -#define TAG(x) ffb_##x -#include "tnl_dd/t_dd_imm_primtmp.h" - -/* Bzzt: Material changes are lost on fallback. */ -static void ffb_Materialfv(GLenum face, GLenum pname, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_noop_Materialfv( face, pname, params ); - ffb_recalc_base_color( ctx ); -} - -/* Fallback functions: */ - -static void ffb_do_fallback(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - struct ffb_current_state *current = &fmesa->vtx_state.current; - - /* Tell tnl to restore its exec vtxfmt, rehook its driver callbacks - * and revive internal state that depended on those callbacks: - */ - _tnl_wakeup_exec(ctx); - - /* Replay enough vertices that the current primitive is continued - * correctly: - */ - if (fmesa->imm.prim != PRIM_OUTSIDE_BEGIN_END ) - CALL_Begin(GET_DISPATCH(), (fmesa->imm.prim)); - - if (ctx->Light.Enabled) { - /* Catch ColorMaterial */ - CALL_Color4fv(GET_DISPATCH(), (ctx->Current.Color)); - CALL_Normal3fv(GET_DISPATCH(), (current->normal)); - } else { - CALL_Color4fv(GET_DISPATCH(), (current->color)); - } -} - -#define PRE_LOOPBACK( FUNC ) do { \ - GET_CURRENT_CONTEXT(ctx); \ - ffb_do_fallback( ctx ); \ -} while (0) - -#define TAG(x) ffb_fallback_##x -#include "vtxfmt_tmp.h" - -static void ffb_Begin(GLenum prim) -{ - GET_CURRENT_CONTEXT(ctx); - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - if (prim > GL_POLYGON) { - _mesa_error( ctx, GL_INVALID_ENUM, "glBegin" ); - return; - } - - if (fmesa->imm.prim != PRIM_OUTSIDE_BEGIN_END) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" ); - return; - } - - ctx->Driver.NeedFlush |= (FLUSH_STORED_VERTICES | - FLUSH_UPDATE_CURRENT); - - fmesa->imm.prim = prim; - fmesa->imm.v0 = &fmesa->imm.vertices[0]; - fmesa->imm.save_vertex = ffb_save_vertex_RGBA; - fmesa->imm.flush_vertex = ffb_flush_tab[prim]; - - /* XXX Lock hardware, update FBC, PPC, DRAWOP, etc. XXX */ -} - -static void ffb_End(void) -{ - GET_CURRENT_CONTEXT(ctx); - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - - if (fmesa->imm.prim == PRIM_OUTSIDE_BEGIN_END) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" ); - return; - } - - fmesa->imm.prim = PRIM_OUTSIDE_BEGIN_END; - - ctx->Driver.NeedFlush &= ~(FLUSH_STORED_VERTICES | - FLUSH_UPDATE_CURRENT); - - /* XXX Unlock hardware, etc. */ -} - -void ffbInitTnlModule(GLcontext *ctx) -{ - ffbContextPtr fmesa = FFB_CONTEXT(ctx); - GLvertexformat *vfmt = &(fmesa->imm.vtxfmt); - - /* Work in progress... */ - return; - - ffb_init_norm_funcs(); - ffb_init_vert_funcs(); - - /* start by initializing to no-op functions */ - _mesa_noop_vtxfmt_init(vfmt); - - /* Handled fully in supported states: */ - vfmt->ArrayElement = NULL; /* FIXME: ... */ - vfmt->Color3f = ffb_choose_Color3f; - vfmt->Color3fv = ffb_choose_Color3fv; - vfmt->Color3ub = ffb_choose_Color3ub; - vfmt->Color3ubv = ffb_choose_Color3ubv; - vfmt->Color4f = ffb_choose_Color4f; - vfmt->Color4fv = ffb_choose_Color4fv; - vfmt->Color4ub = ffb_choose_Color4ub; - vfmt->Color4ubv = ffb_choose_Color4ubv; - vfmt->FogCoordfvEXT = ffb_FogCoordfvEXT; - vfmt->FogCoordfEXT = ffb_FogCoordfEXT; - vfmt->Materialfv = ffb_Materialfv; - vfmt->MultiTexCoord1fARB = ffb_fallback_MultiTexCoord1fARB; - vfmt->MultiTexCoord1fvARB = ffb_fallback_MultiTexCoord1fvARB; - vfmt->MultiTexCoord2fARB = ffb_fallback_MultiTexCoord2fARB; - vfmt->MultiTexCoord2fvARB = ffb_fallback_MultiTexCoord2fvARB; - vfmt->MultiTexCoord3fARB = ffb_fallback_MultiTexCoord3fARB; - vfmt->MultiTexCoord3fvARB = ffb_fallback_MultiTexCoord3fvARB; - vfmt->MultiTexCoord4fARB = ffb_fallback_MultiTexCoord4fARB; - vfmt->MultiTexCoord4fvARB = ffb_fallback_MultiTexCoord4fvARB; - vfmt->Normal3f = ffb_choose_Normal3f; - vfmt->Normal3fv = ffb_choose_Normal3fv; - vfmt->SecondaryColor3ubEXT = ffb_SecondaryColor3ubEXT; - vfmt->SecondaryColor3ubvEXT = ffb_SecondaryColor3ubvEXT; - vfmt->SecondaryColor3fEXT = ffb_SecondaryColor3fEXT; - vfmt->SecondaryColor3fvEXT = ffb_SecondaryColor3fvEXT; - vfmt->TexCoord1f = ffb_fallback_TexCoord1f; - vfmt->TexCoord1fv = ffb_fallback_TexCoord1fv; - vfmt->TexCoord2f = ffb_fallback_TexCoord2f; - vfmt->TexCoord2fv = ffb_fallback_TexCoord2fv; - vfmt->TexCoord3f = ffb_fallback_TexCoord3f; - vfmt->TexCoord3fv = ffb_fallback_TexCoord3fv; - vfmt->TexCoord4f = ffb_fallback_TexCoord4f; - vfmt->TexCoord4fv = ffb_fallback_TexCoord4fv; - - vfmt->Vertex2f = ffb_Vertex2f; - vfmt->Vertex2fv = ffb_Vertex2fv; - vfmt->Vertex3f = ffb_Vertex3f; - vfmt->Vertex3fv = ffb_Vertex3fv; - vfmt->Vertex4f = ffb_Vertex4f; - vfmt->Vertex4fv = ffb_Vertex4fv; - - vfmt->Begin = ffb_Begin; - vfmt->End = ffb_End; - - vfmt->DrawArrays = NULL; - vfmt->DrawElements = NULL; - - /* Active but unsupported -- fallback if we receive these: - * - * All of these fallbacks can be fixed with additional code, except - * CallList, unless we build a play_immediate_noop() command which - * turns an immediate back into glBegin/glEnd commands... - */ - vfmt->CallList = ffb_fallback_CallList; - vfmt->EvalCoord1f = ffb_fallback_EvalCoord1f; - vfmt->EvalCoord1fv = ffb_fallback_EvalCoord1fv; - vfmt->EvalCoord2f = ffb_fallback_EvalCoord2f; - vfmt->EvalCoord2fv = ffb_fallback_EvalCoord2fv; - vfmt->EvalMesh1 = ffb_fallback_EvalMesh1; - vfmt->EvalMesh2 = ffb_fallback_EvalMesh2; - vfmt->EvalPoint1 = ffb_fallback_EvalPoint1; - vfmt->EvalPoint2 = ffb_fallback_EvalPoint2; - - vfmt->prefer_float_colors = GL_TRUE; - - fmesa->imm.prim = PRIM_OUTSIDE_BEGIN_END; - - /* THIS IS A HACK! */ - _mesa_install_exec_vtxfmt( ctx, vfmt ); -} diff --git a/src/mesa/drivers/dri/ffb/ffb_vtxfmt.h b/src/mesa/drivers/dri/ffb/ffb_vtxfmt.h deleted file mode 100644 index 4d9125cd156..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_vtxfmt.h +++ /dev/null @@ -1,7 +0,0 @@ - -#ifndef _FFB_VTXFMT_H -#define _FFB_VTXFMT_H - -extern void ffbInitTnlModule(GLcontext *); - -#endif /* !(_FFB_VTXFMT_H) */ diff --git a/src/mesa/drivers/dri/ffb/ffb_xmesa.c b/src/mesa/drivers/dri/ffb/ffb_xmesa.c deleted file mode 100644 index bd1044a2bff..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_xmesa.c +++ /dev/null @@ -1,729 +0,0 @@ -/* - * - * GLX Hardware Device Driver for Sun Creator/Creator3D - * Copyright (C) 2000, 2001 David S. Miller - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * David S. Miller - */ - -#include "ffb_xmesa.h" -#include "main/context.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "main/simple_list.h" -#include "main/imports.h" -#include "utils.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/t_pipeline.h" -#include "vbo/vbo.h" -#include "drivers/common/driverfuncs.h" - -#include "ffb_context.h" -#include "ffb_dd.h" -#include "ffb_span.h" -#include "ffb_depth.h" -#include "ffb_stencil.h" -#include "ffb_clear.h" -#include "ffb_vb.h" -#include "ffb_tris.h" -#include "ffb_lines.h" -#include "ffb_points.h" -#include "ffb_state.h" -#include "ffb_lock.h" -#include "ffb_vtxfmt.h" -#include "ffb_bitmap.h" - -#include "drm_sarea.h" - -#include "drirenderbuffer.h" - -static GLboolean -ffbInitDriver(__DRIscreen *sPriv) -{ - ffbScreenPrivate *ffbScreen; - FFBDRIPtr gDRIPriv = (FFBDRIPtr) sPriv->pDevPriv; - drmAddress map; - - if (getenv("LIBGL_FORCE_XSERVER")) - return GL_FALSE; - - - if (sPriv->devPrivSize != sizeof(FFBDRIRec)) { - fprintf(stderr,"\nERROR! sizeof(FFBDRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - - /* Allocate the private area. */ - ffbScreen = (ffbScreenPrivate *) MALLOC(sizeof(ffbScreenPrivate)); - if (!ffbScreen) - return GL_FALSE; - - /* Map FBC registers. */ - if (drmMap(sPriv->fd, - gDRIPriv->hFbcRegs, - gDRIPriv->sFbcRegs, - &map)) { - FREE(ffbScreen); - return GL_FALSE; - } - ffbScreen->regs = (ffb_fbcPtr) map; - - /* Map ramdac registers. */ - if (drmMap(sPriv->fd, - gDRIPriv->hDacRegs, - gDRIPriv->sDacRegs, - &map)) { - drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs); - FREE(ffbScreen); - return GL_FALSE; - } - ffbScreen->dac = (ffb_dacPtr) map; - - /* Map "Smart" framebuffer views. */ - if (drmMap(sPriv->fd, - gDRIPriv->hSfb8r, - gDRIPriv->sSfb8r, - &map)) { - drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs); - drmUnmap((drmAddress)ffbScreen->dac, gDRIPriv->sDacRegs); - FREE(ffbScreen); - return GL_FALSE; - } - ffbScreen->sfb8r = (volatile char *) map; - - if (drmMap(sPriv->fd, - gDRIPriv->hSfb32, - gDRIPriv->sSfb32, - &map)) { - drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs); - drmUnmap((drmAddress)ffbScreen->dac, gDRIPriv->sDacRegs); - drmUnmap((drmAddress)ffbScreen->sfb8r, gDRIPriv->sSfb8r); - FREE(ffbScreen); - return GL_FALSE; - } - ffbScreen->sfb32 = (volatile char *) map; - - if (drmMap(sPriv->fd, - gDRIPriv->hSfb64, - gDRIPriv->sSfb64, - &map)) { - drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs); - drmUnmap((drmAddress)ffbScreen->dac, gDRIPriv->sDacRegs); - drmUnmap((drmAddress)ffbScreen->sfb8r, gDRIPriv->sSfb8r); - drmUnmap((drmAddress)ffbScreen->sfb32, gDRIPriv->sSfb32); - FREE(ffbScreen); - return GL_FALSE; - } - ffbScreen->sfb64 = (volatile char *) map; - - ffbScreen->fifo_cache = 0; - ffbScreen->rp_active = 0; - - ffbScreen->sPriv = sPriv; - sPriv->private = (void *) ffbScreen; - - ffbDDLinefuncInit(); - ffbDDPointfuncInit(); - - return GL_TRUE; -} - - -static void -ffbDestroyScreen(__DRIscreen *sPriv) -{ - ffbScreenPrivate *ffbScreen = sPriv->private; - FFBDRIPtr gDRIPriv = (FFBDRIPtr) sPriv->pDevPriv; - - drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs); - drmUnmap((drmAddress)ffbScreen->dac, gDRIPriv->sDacRegs); - drmUnmap((drmAddress)ffbScreen->sfb8r, gDRIPriv->sSfb8r); - drmUnmap((drmAddress)ffbScreen->sfb32, gDRIPriv->sSfb32); - drmUnmap((drmAddress)ffbScreen->sfb64, gDRIPriv->sSfb64); - - FREE(ffbScreen); -} - -static const struct tnl_pipeline_stage *ffb_pipeline[] = { - &_tnl_vertex_transform_stage, - &_tnl_normal_transform_stage, - &_tnl_lighting_stage, - /* REMOVE: fog coord stage */ - &_tnl_texgen_stage, - &_tnl_texture_transform_stage, - /* REMOVE: point attenuation stage */ - &_tnl_render_stage, - 0, -}; - -/* Create and initialize the Mesa and driver specific context data */ -static GLboolean -ffbCreateContext(const __GLcontextModes *mesaVis, - __DRIcontext *driContextPriv, - void *sharedContextPrivate) -{ - ffbContextPtr fmesa; - GLcontext *ctx, *shareCtx; - __DRIscreen *sPriv; - ffbScreenPrivate *ffbScreen; - char *debug; - struct dd_function_table functions; - - /* Allocate ffb context */ - fmesa = (ffbContextPtr) CALLOC(sizeof(ffbContextRec)); - if (!fmesa) - return GL_FALSE; - - _mesa_init_driver_functions(&functions); - - /* Allocate Mesa context */ - if (sharedContextPrivate) - shareCtx = ((ffbContextPtr) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - fmesa->glCtx = _mesa_create_context(mesaVis, shareCtx, - &functions, fmesa); - if (!fmesa->glCtx) { - FREE(fmesa); - return GL_FALSE; - } - driContextPriv->driverPrivate = fmesa; - ctx = fmesa->glCtx; - - sPriv = driContextPriv->driScreenPriv; - ffbScreen = (ffbScreenPrivate *) sPriv->private; - - /* Dri stuff. */ - fmesa->hHWContext = driContextPriv->hHWContext; - fmesa->driFd = sPriv->fd; - fmesa->driHwLock = &sPriv->pSAREA->lock; - - fmesa->ffbScreen = ffbScreen; - fmesa->driScreen = sPriv; - fmesa->ffb_sarea = FFB_DRISHARE(sPriv->pSAREA); - - /* Register and framebuffer pointers. */ - fmesa->regs = ffbScreen->regs; - fmesa->sfb32 = ffbScreen->sfb32; - - ffbDDInitContextHwState(ctx); - - /* Default clear and depth colors. */ - { - GLubyte r = (GLint) (ctx->Color.ClearColor[0] * 255.0F); - GLubyte g = (GLint) (ctx->Color.ClearColor[1] * 255.0F); - GLubyte b = (GLint) (ctx->Color.ClearColor[2] * 255.0F); - - fmesa->clear_pixel = ((r << 0) | - (g << 8) | - (b << 16)); - } - fmesa->clear_depth = Z_FROM_MESA(ctx->Depth.Clear * 4294967295.0f); - fmesa->clear_stencil = ctx->Stencil.Clear & 0xf; - - /* No wide points. */ - ctx->Const.MinPointSize = 1.0; - ctx->Const.MinPointSizeAA = 1.0; - ctx->Const.MaxPointSize = 1.0; - ctx->Const.MaxPointSizeAA = 1.0; - - /* Disable wide lines as we can't antialias them correctly in - * hardware. - */ - ctx->Const.MinLineWidth = 1.0; - ctx->Const.MinLineWidthAA = 1.0; - ctx->Const.MaxLineWidth = 1.0; - ctx->Const.MaxLineWidthAA = 1.0; - ctx->Const.LineWidthGranularity = 1.0; - - ctx->Const.MaxDrawBuffers = 1; - - /* Instead of having GCC emit these constants a zillion times - * everywhere in the driver, put them here. - */ - fmesa->ffb_2_30_fixed_scale = __FFB_2_30_FIXED_SCALE; - fmesa->ffb_one_over_2_30_fixed_scale = (1.0 / __FFB_2_30_FIXED_SCALE); - fmesa->ffb_16_16_fixed_scale = __FFB_16_16_FIXED_SCALE; - fmesa->ffb_one_over_16_16_fixed_scale = (1.0 / __FFB_16_16_FIXED_SCALE); - fmesa->ffb_ubyte_color_scale = 255.0f; - fmesa->ffb_zero = 0.0f; - - fmesa->debugFallbacks = GL_FALSE; - debug = getenv("LIBGL_DEBUG"); - if (debug && strstr(debug, "fallbacks")) - fmesa->debugFallbacks = GL_TRUE; - - /* Initialize the software rasterizer and helper modules. */ - _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - - /* All of this need only be done once for a new context. */ - /* XXX these should be moved right after the - * _mesa_init_driver_functions() call above. - */ - ffbDDExtensionsInit(ctx); - ffbDDInitDriverFuncs(ctx); - ffbDDInitStateFuncs(ctx); - ffbDDInitRenderFuncs(ctx); - /*ffbDDInitTexFuncs(ctx); not needed */ - ffbDDInitBitmapFuncs(ctx); - ffbInitVB(ctx); - -#if 0 - ffbInitTnlModule(ctx); -#endif - - _tnl_destroy_pipeline(ctx); - _tnl_install_pipeline(ctx, ffb_pipeline); - - return GL_TRUE; -} - -static void -ffbDestroyContext(__DRIcontext *driContextPriv) -{ - ffbContextPtr fmesa = (ffbContextPtr) driContextPriv->driverPrivate; - - if (fmesa) { - ffbFreeVB(fmesa->glCtx); - - _swsetup_DestroyContext( fmesa->glCtx ); - _tnl_DestroyContext( fmesa->glCtx ); - _vbo_DestroyContext( fmesa->glCtx ); - _swrast_DestroyContext( fmesa->glCtx ); - - /* free the Mesa context */ - fmesa->glCtx->DriverCtx = NULL; - _mesa_destroy_context(fmesa->glCtx); - - FREE(fmesa); - } -} - -/* Create and initialize the Mesa and driver specific pixmap buffer data */ -static GLboolean -ffbCreateBuffer(__DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const __GLcontextModes *mesaVis, - GLboolean isPixmap ) -{ - /* Mesa checks for pitch > 0, but ffb doesn't use pitches */ - int bogusPitch = 1; - int bpp = 4; /* we've always got a 32bpp framebuffer */ - int offset = 0; /* always at 0 for offset */ - - if (isPixmap) { - return GL_FALSE; /* not implemented */ - } else { - GLboolean swStencil = (mesaVis->stencilBits > 0 && - mesaVis->depthBits != 24); - struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); - - { - driRenderbuffer *frontRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, bpp, offset, bogusPitch, - driDrawPriv); - ffbSetSpanFunctions(frontRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base); - } - - if (mesaVis->doubleBufferMode) { - driRenderbuffer *backRb - = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, bpp, offset, bogusPitch, - driDrawPriv); - ffbSetSpanFunctions(backRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base); - } - - if (mesaVis->depthBits == 16) { - driRenderbuffer *depthRb - = driNewRenderbuffer(MESA_FORMAT_Z16, NULL, bpp, offset, - bogusPitch, driDrawPriv); - ffbSetDepthFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - - if (mesaVis->stencilBits > 0 && !swStencil) { - driRenderbuffer *stencilRb - = driNewRenderbuffer(MESA_FORMAT_S8, NULL, bpp, offset, - bogusPitch, driDrawPriv); - ffbSetStencilFunctions(stencilRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base); - } - - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* color */ - GL_FALSE, /* depth */ - swStencil, - mesaVis->accumRedBits > 0, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - driDrawPriv->driverPrivate = (void *) fb; - - return (driDrawPriv->driverPrivate != NULL); - } -} - - -static void -ffbDestroyBuffer(__DRIdrawable *driDrawPriv) -{ - _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - - -#define USE_FAST_SWAP - -static void -ffbSwapBuffers( __DRIdrawable *dPriv ) -{ - ffbContextPtr fmesa = (ffbContextPtr) dPriv->driContextPriv->driverPrivate; - unsigned int fbc, wid, wid_reg_val, dac_db_bit; - unsigned int shadow_dac_addr, active_dac_addr; - ffb_fbcPtr ffb; - ffb_dacPtr dac; - - if (fmesa == NULL || - fmesa->glCtx->Visual.doubleBufferMode == 0) - return; - - /* Flush pending rendering commands */ - _mesa_notifySwapBuffers(fmesa->glCtx); - - ffb = fmesa->regs; - dac = fmesa->ffbScreen->dac; - - fbc = fmesa->fbc; - wid = fmesa->wid; - - /* Swap the buffer we render into and read pixels from. */ - fmesa->back_buffer ^= 1; - - /* If we are writing into both buffers, don't mess with - * the WB setting. - */ - if ((fbc & FFB_FBC_WB_AB) != FFB_FBC_WB_AB) { - if ((fbc & FFB_FBC_WB_A) != 0) - fbc = (fbc & ~FFB_FBC_WB_A) | FFB_FBC_WB_B; - else - fbc = (fbc & ~FFB_FBC_WB_B) | FFB_FBC_WB_A; - } - - /* But either way, we must flip the read buffer setting. */ - if ((fbc & FFB_FBC_RB_A) != 0) - fbc = (fbc & ~FFB_FBC_RB_A) | FFB_FBC_RB_B; - else - fbc = (fbc & ~FFB_FBC_RB_B) | FFB_FBC_RB_A; - - LOCK_HARDWARE(fmesa); - - if (fmesa->fbc != fbc) { - FFBFifo(fmesa, 1); - ffb->fbc = fmesa->fbc = fbc; - fmesa->ffbScreen->rp_active = 1; - } - - /* And swap the buffer displayed in the WID. */ - if (fmesa->ffb_sarea->flags & FFB_DRI_PAC1) { - shadow_dac_addr = FFBDAC_PAC1_SPWLUT(wid); - active_dac_addr = FFBDAC_PAC1_APWLUT(wid); - dac_db_bit = FFBDAC_PAC1_WLUT_DB; - } else { - shadow_dac_addr = FFBDAC_PAC2_SPWLUT(wid); - active_dac_addr = FFBDAC_PAC2_APWLUT(wid); - dac_db_bit = FFBDAC_PAC2_WLUT_DB; - } - - FFBWait(fmesa, ffb); - - wid_reg_val = DACCFG_READ(dac, active_dac_addr); - if (fmesa->back_buffer == 0) - wid_reg_val |= dac_db_bit; - else - wid_reg_val &= ~dac_db_bit; -#ifdef USE_FAST_SWAP - DACCFG_WRITE(dac, active_dac_addr, wid_reg_val); -#else - DACCFG_WRITE(dac, shadow_dac_addr, wid_reg_val); - - /* Schedule the window transfer. */ - DACCFG_WRITE(dac, FFBDAC_CFG_WTCTRL, - (FFBDAC_CFG_WTCTRL_TCMD | FFBDAC_CFG_WTCTRL_TE)); - - { - int limit = 1000000; - while (limit--) { - unsigned int wtctrl = DACCFG_READ(dac, FFBDAC_CFG_WTCTRL); - - if ((wtctrl & FFBDAC_CFG_WTCTRL_DS) == 0) - break; - } - } -#endif - - UNLOCK_HARDWARE(fmesa); -} - -static void ffb_init_wid(ffbContextPtr fmesa, unsigned int wid) -{ - ffb_dacPtr dac = fmesa->ffbScreen->dac; - unsigned int wid_reg_val, dac_db_bit, active_dac_addr; - unsigned int shadow_dac_addr; - - if (fmesa->ffb_sarea->flags & FFB_DRI_PAC1) { - shadow_dac_addr = FFBDAC_PAC1_SPWLUT(wid); - active_dac_addr = FFBDAC_PAC1_APWLUT(wid); - dac_db_bit = FFBDAC_PAC1_WLUT_DB; - } else { - shadow_dac_addr = FFBDAC_PAC2_SPWLUT(wid); - active_dac_addr = FFBDAC_PAC2_APWLUT(wid); - dac_db_bit = FFBDAC_PAC2_WLUT_DB; - } - - wid_reg_val = DACCFG_READ(dac, active_dac_addr); - wid_reg_val &= ~dac_db_bit; -#ifdef USE_FAST_SWAP - DACCFG_WRITE(dac, active_dac_addr, wid_reg_val); -#else - DACCFG_WRITE(dac, shadow_dac_addr, wid_reg_val); - - /* Schedule the window transfer. */ - DACCFG_WRITE(dac, FFBDAC_CFG_WTCTRL, - (FFBDAC_CFG_WTCTRL_TCMD | FFBDAC_CFG_WTCTRL_TE)); - - { - int limit = 1000000; - while (limit--) { - unsigned int wtctrl = DACCFG_READ(dac, FFBDAC_CFG_WTCTRL); - - if ((wtctrl & FFBDAC_CFG_WTCTRL_DS) == 0) - break; - } - } -#endif -} - -/* Force the context `c' to be the current context and associate with it - buffer `b' */ -static GLboolean -ffbMakeCurrent(__DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv) -{ - if (driContextPriv) { - ffbContextPtr fmesa = (ffbContextPtr) driContextPriv->driverPrivate; - int first_time; - - fmesa->driDrawable = driDrawPriv; - - _mesa_make_current(fmesa->glCtx, - (GLframebuffer *) driDrawPriv->driverPrivate, - (GLframebuffer *) driReadPriv->driverPrivate); - - first_time = 0; - if (fmesa->wid == ~0) { - first_time = 1; - if (getenv("LIBGL_SOFTWARE_RENDERING")) - FALLBACK( fmesa->glCtx, FFB_BADATTR_SWONLY, GL_TRUE ); - } - - LOCK_HARDWARE(fmesa); - if (first_time) { - fmesa->wid = fmesa->ffb_sarea->wid_table[driDrawPriv->index]; - ffb_init_wid(fmesa, fmesa->wid); - } - - fmesa->state_dirty |= FFB_STATE_ALL; - fmesa->state_fifo_ents = fmesa->state_all_fifo_ents; - ffbSyncHardware(fmesa); - UNLOCK_HARDWARE(fmesa); - - if (first_time) { - /* Also, at the first switch to a new context, - * we need to clear all the hw buffers. - */ - ffbDDClear(fmesa->glCtx, - (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | - BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)); - } - } else { - _mesa_make_current(NULL, NULL, NULL); - } - - return GL_TRUE; -} - -/* Force the context `c' to be unbound from its buffer */ -static GLboolean -ffbUnbindContext(__DRIcontext *driContextPriv) -{ - return GL_TRUE; -} - -void ffbXMesaUpdateState(ffbContextPtr fmesa) -{ - __DRIdrawable *dPriv = fmesa->driDrawable; - __DRIscreen *sPriv = fmesa->driScreen; - int stamp = dPriv->lastStamp; - - DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); - - if (dPriv->lastStamp != stamp) { - GLcontext *ctx = fmesa->glCtx; - - ffbCalcViewport(ctx); - driUpdateFramebufferSize(ctx, dPriv); - if (ctx->Polygon.StippleFlag) { - ffbXformAreaPattern(fmesa, - (const GLubyte *)ctx->PolygonStipple); - } - } -} - -static const __DRIconfig ** -ffbFillInModes( __DRIscreen *psp, - unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer ) -{ - __DRIconfig **configs; - __GLcontextModes *m; - unsigned depth_buffer_factor; - unsigned back_buffer_factor; - GLenum fb_format; - GLenum fb_type; - int i; - - /* GLX_SWAP_COPY_OML is only supported because the FFB driver doesn't - * support pageflipping at all. - */ - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML - }; - - uint8_t depth_bits_array[3]; - uint8_t stencil_bits_array[3]; - uint8_t msaa_samples_array[1]; - - depth_bits_array[0] = 0; - depth_bits_array[1] = depth_bits; - depth_bits_array[2] = depth_bits; - - /* Just like with the accumulation buffer, always provide some modes - * with a stencil buffer. It will be a sw fallback, but some apps won't - * care about that. - */ - stencil_bits_array[0] = 0; - stencil_bits_array[1] = 0; - stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits; - - msaa_samples_array[0] = 0; - - depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1; - back_buffer_factor = (have_back_buffer) ? 3 : 1; - - if ( pixel_bits == 16 ) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { - fb_format = GL_BGRA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = driCreateConfigs(fb_format, fb_type, - depth_bits_array, stencil_bits_array, - depth_buffer_factor, back_buffer_modes, - back_buffer_factor, - msaa_samples_array, 1, GL_TRUE); - if (configs == NULL) { - fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, - __LINE__); - return NULL; - } - - /* Mark the visual as slow if there are "fake" stencil bits. - */ - for (i = 0; configs[i]; i++) { - m = &configs[i]->modes; - if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { - m->visualRating = GLX_SLOW_CONFIG; - } - } - - return (const __DRIconfig **) configs; -} - - -/** - * This is the driver specific part of the createNewScreen entry point. - * - * \todo maybe fold this into intelInitDriver - * - * \return the __GLcontextModes supported by this driver - */ -static const __DRIconfig ** -ffbInitScreen(__DRIscreen *psp) -{ - static const __DRIversion ddx_expected = { 0, 1, 1 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 0, 0, 1 }; - - if ( ! driCheckDriDdxDrmVersions2( "ffb", - &psp->dri_version, & dri_expected, - &psp->ddx_version, & ddx_expected, - &psp->drm_version, & drm_expected ) ) - return NULL; - - if (!ffbInitDriver(psp)) - return NULL; - - return ffbFillInModes( psp, 32, 16, 0, GL_TRUE ); -} - -const struct __DriverAPIRec driDriverAPI = { - .InitScreen = ffbInitScreen, - .DestroyScreen = ffbDestroyScreen, - .CreateContext = ffbCreateContext, - .DestroyContext = ffbDestroyContext, - .CreateBuffer = ffbCreateBuffer, - .DestroyBuffer = ffbDestroyBuffer, - .SwapBuffers = ffbSwapBuffers, - .MakeCurrent = ffbMakeCurrent, - .UnbindContext = ffbUnbindContext, - .GetSwapInfo = NULL, - .GetDrawableMSC = NULL, - .WaitForMSC = NULL, - .WaitForSBC = NULL, - .SwapBuffersMSC = NULL -}; - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - NULL -}; diff --git a/src/mesa/drivers/dri/ffb/ffb_xmesa.h b/src/mesa/drivers/dri/ffb/ffb_xmesa.h deleted file mode 100644 index 2b1740d2219..00000000000 --- a/src/mesa/drivers/dri/ffb/ffb_xmesa.h +++ /dev/null @@ -1,25 +0,0 @@ - -#ifndef _FFB_XMESA_H_ -#define _FFB_XMESA_H_ - -#include -#include "dri_util.h" -#include "main/mtypes.h" -#include "ffb_drishare.h" -#include "ffb_regs.h" -#include "ffb_dac.h" -#include "ffb_fifo.h" - -typedef struct { - __DRIscreen *sPriv; - ffb_fbcPtr regs; - ffb_dacPtr dac; - volatile char *sfb8r; - volatile char *sfb32; - volatile char *sfb64; - - int fifo_cache; - int rp_active; -} ffbScreenPrivate; - -#endif /* !(_FFB_XMESA_H) */ diff --git a/src/mesa/drivers/dri/ffb/server/ffb_dac.h b/src/mesa/drivers/dri/ffb/server/ffb_dac.h deleted file mode 100644 index ac4a75b4598..00000000000 --- a/src/mesa/drivers/dri/ffb/server/ffb_dac.h +++ /dev/null @@ -1,366 +0,0 @@ -/* - * Acceleration for the Creator and Creator3D framebuffer - DAC register layout. - * - * Copyright (C) 2000 David S. Miller (davem@redhat.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ - -#ifndef _FFB_DAC_H -#define _FFB_DAC_H - -#define Bool int - -/* FFB utilizes two different ramdac chips: - * - * 1) BT9068 "Pacifica1", used in all FFB1 and - * FFB2 boards. - * - * 2) BT498(a) "Pacifica2", used in FFB2+ and - * AFB boards. - * - * They are mostly equivalent, except in a few key areas: - * - * 1) WID register layout - * 2) Number of CLUT tables - * 3) Presence of Window Address Mask register - * 4) Method of GAMMA correction support - */ - -/* NOTE: All addresses described in this file are DAC - * indirect addresses. - */ - -/* DAC color values are in the following format. */ -#define FFBDAC_COLOR_BLUE 0x00ff0000 -#define FFBDAC_COLOR_BLUE_SHFT 16 -#define FFBDAC_COLOR_GREEN 0x0000ff00 -#define FFBDAC_COLOR_GREEN_SHFT 8 -#define FFBDAC_COLOR_RED 0x000000ff -#define FFBDAC_COLOR_RED_SHFT 0 - -/* Cursor DAC register addresses. */ -#define FFBDAC_CUR_BITMAP_P0 0x000 /* Plane 0 cursor bitmap */ -#define FFBDAC_CUR_BITMAP_P1 0x080 /* Plane 1 cursor bitmap */ -#define FFBDAC_CUR_CTRL 0x100 /* Cursor control */ -#define FFBDAC_CUR_COLOR0 0x101 /* Cursor Color 0 */ -#define FFBDAC_CUR_COLOR1 0x102 /* Cursor Color 1 (bg) */ -#define FFBDAC_CUR_COLOR2 0x103 /* Cursor Color 2 (fg) */ -#define FFBDAC_CUR_POS 0x104 /* Active cursor position */ - -/* Cursor control register. - * WARNING: Be careful, reverse logic on these bits. - */ -#define FFBDAC_CUR_CTRL_P0 0x00000001 /* Plane0 display disable */ -#define FFBDAC_CUR_CTRL_P1 0x00000002 /* Plane1 display disable */ - -/* Active cursor position register */ -#define FFBDAC_CUR_POS_Y_SIGN 0x80000000 /* Sign of Y position */ -#define FFBDAC_CUR_POS_Y 0x0fff0000 /* Y position */ -#define FFBDAC_CUR_POS_X_SIGN 0x00008000 /* Sign of X position */ -#define FFBDAC_CUR_POS_X 0x00000fff /* X position */ - -/* Configuration and Palette DAC register addresses. */ -#define FFBDAC_CFG_PPLLCTRL 0x0000 /* Pixel PLL Control */ -#define FFBDAC_CFG_GPLLCTRL 0x0001 /* General Purpose PLL Control */ -#define FFBDAC_CFG_PFCTRL 0x1000 /* Pixel Format Control */ -#define FFBDAC_CFG_UCTRL 0x1001 /* User Control */ -#define FFBDAC_CFG_CLUP_BASE 0x2000 /* Color Lookup Palette */ -#define FFBDAC_CFG_CLUP(entry) (FFBDAC_CFG_CLUP_BASE + ((entry) * 0x100)) -#define FFBDAC_PAC2_SOVWLUT0 0x3100 /* Shadow Overlay Window Lookup 0*/ -#define FFBDAC_PAC2_SOVWLUT1 0x3101 /* Shadow Overlay Window Lookup 1*/ -#define FFBDAC_PAC2_SOVWLUT2 0x3102 /* Shadow Overlay Window Lookup 2*/ -#define FFBDAC_PAC2_SOVWLUT3 0x3103 /* Shadow Overlay Window Lookup 3*/ -#define FFBDAC_PAC2_AOVWLUT0 0x3210 /* Active Overlay Window Lookup 0*/ -#define FFBDAC_PAC2_AOVWLUT1 0x3211 /* Active Overlay Window Lookup 1*/ -#define FFBDAC_PAC2_AOVWLUT2 0x3212 /* Active Overlay Window Lookup 2*/ -#define FFBDAC_PAC2_AOVWLUT3 0x3213 /* Active Overlay Window Lookup 3*/ -#define FFBDAC_CFG_WTCTRL 0x3150 /* Window Transfer Control */ -#define FFBDAC_CFG_TMCTRL 0x3151 /* Transparent Mask Control */ -#define FFBDAC_CFG_TCOLORKEY 0x3152 /* Transparent Color Key */ -#define FFBDAC_CFG_WAMASK 0x3153 /* Window Address Mask (PAC2 only) */ -#define FFBDAC_PAC1_SPWLUT_BASE 0x3100 /* Shadow Primary Window Lookups */ -#define FFBDAC_PAC1_SPWLUT(entry) (FFBDAC_PAC1_SPWLUT_BASE + (entry)) -#define FFBDAC_PAC1_APWLUT_BASE 0x3120 /* Active Primary Window Lookups */ -#define FFBDAC_PAC1_APWLUT(entry) (FFBDAC_PAC1_APWLUT_BASE + (entry)) -#define FFBDAC_PAC2_SPWLUT_BASE 0x3200 /* Shadow Primary Window Lookups */ -#define FFBDAC_PAC2_SPWLUT(entry) (FFBDAC_PAC2_SPWLUT_BASE + (entry)) -#define FFBDAC_PAC2_APWLUT_BASE 0x3240 /* Active Primary Window Lookups */ -#define FFBDAC_PAC2_APWLUT(entry) (FFBDAC_PAC2_APWLUT_BASE + (entry)) -#define FFBDAC_CFG_SANAL 0x5000 /* Signature Analysis Control */ -#define FFBDAC_CFG_DACCTRL 0x5001 /* DAC Control */ -#define FFBDAC_CFG_TGEN 0x6000 /* Timing Generator Control */ -#define FFBDAC_CFG_VBNP 0x6001 /* Vertical Blank Negation Point */ -#define FFBDAC_CFG_VBAP 0x6002 /* Vertical Blank Assertion Point*/ -#define FFBDAC_CFG_VSNP 0x6003 /* Vertical Sync Negation Point */ -#define FFBDAC_CFG_VSAP 0x6004 /* Vertical Sync Assertion Point */ -#define FFBDAC_CFG_HSNP 0x6005 /* Horz Serration Negation Point */ -#define FFBDAC_CFG_HBNP 0x6006 /* Horz Blank Negation Point */ -#define FFBDAC_CFG_HBAP 0x6007 /* Horz Blank Assertion Point */ -#define FFBDAC_CFG_HSYNCNP 0x6008 /* Horz Sync Negation Point */ -#define FFBDAC_CFG_HSYNCAP 0x6009 /* Horz Sync Assertion Point */ -#define FFBDAC_CFG_HSCENNP 0x600A /* Horz SCEN Negation Point */ -#define FFBDAC_CFG_HSCENAP 0x600B /* Horz SCEN Assertion Point */ -#define FFBDAC_CFG_EPNP 0x600C /* Eql'zing Pulse Negation Point */ -#define FFBDAC_CFG_EINP 0x600D /* Eql'zing Intvl Negation Point */ -#define FFBDAC_CFG_EIAP 0x600E /* Eql'zing Intvl Assertion Point*/ -#define FFBDAC_CFG_TGVC 0x600F /* Timing Generator Vert Counter */ -#define FFBDAC_CFG_TGHC 0x6010 /* Timing Generator Horz Counter */ -#define FFBDAC_CFG_DID 0x8000 /* Device Identification */ -#define FFBDAC_CFG_MPDATA 0x8001 /* Monitor Port Data */ -#define FFBDAC_CFG_MPSENSE 0x8002 /* Monitor Port Sense */ - -/* Pixel PLL Control Register */ -#define FFBDAC_CFG_PPLLCTRL_M 0x0000007f /* PLL VCO Multiplicand */ -#define FFBDAC_CFG_PPLLCTRL_D 0x00000780 /* PLL VCO Divisor */ -#define FFBDAC_CFG_PPLLCTRL_PFD 0x00001800 /* Post VCO Frequency Divider */ -#define FFBDAC_CFG_PPLLCTRL_EN 0x00004000 /* Enable PLL as pixel clock src */ - -/* General Purpose PLL Control Register */ -#define FFBDAC_CFG_GPLLCTRL_M 0x0000007f /* PLL VCO Multiplicand */ -#define FFBDAC_CFG_GPLLCTRL_D 0x00000780 /* PLL VCO Divisor */ -#define FFBDAC_CFG_GPLLCTRL_PFD 0x00001800 /* Post VCO Frequency Divider */ -#define FFBDAC_CFG_GPLLCTRL_EN 0x00004000 /* Enable PLL as Gen. Purpose clk*/ - -/* Pixel Format Control Register */ -#define FFBDAC_CFG_PFCTRL_2_1 0x00000000 /* 2:1 pixel interleave format */ -#define FFBDAC_CFG_PFCTRL_4_1 0x00000001 /* 4:1 pixel interleave format */ -#define FFBDAC_CFG_PFCTRL_42_1 0x00000002 /* 4/2:1 pixel interleave format */ -#define FFBDAC_CFG_PFCTRL_82_1 0x00000003 /* 8/2:1 pixel interleave format */ - -/* User Control Register */ -#define FFBDAC_UCTRL_IPDISAB 0x00000001 /* Disable input pullup resistors*/ -#define FFBDAC_UCTRL_ABLANK 0x00000002 /* Asynchronous Blank */ -#define FFBDAC_UCTRL_DBENAB 0x00000004 /* Double-Buffer Enable */ -#define FFBDAC_UCTRL_OVENAB 0x00000008 /* Overlay Enable */ -#define FFBDAC_UCTRL_WMODE 0x00000030 /* Window Mode */ -#define FFBDAC_UCTRL_WM_COMB 0x00000000 /* Window Mode = Combined */ -#define FFBDAC_UCTRL_WM_S4 0x00000010 /* Window Mode = Seperate_4 */ -#define FFBDAC_UCTRL_WM_S8 0x00000020 /* Window Mode = Seperate_8 */ -#define FFBDAC_UCTRL_WM_RESV 0x00000030 /* Window Mode = reserved */ -#define FFBDAC_UCTRL_MANREV 0x00000f00 /* 4-bit Manufacturing Revision */ - -/* Overlay Window Lookup Registers (PAC2 only) */ -#define FFBDAC_CFG_OVWLUT_PSEL 0x0000000f /* Palette Section, Seperate_4 */ -#define FFBDAC_CFG_OVWLUT_PTBL 0x00000030 /* Palette Table */ -#define FFBDAC_CFG_OVWLUT_LKUP 0x00000100 /* 1 = Use palette, 0 = Bypass */ -#define FFBDAC_CFG_OVWLUT_OTYP 0x00000c00 /* Overlay Type */ -#define FFBDAC_CFG_OVWLUT_O_N 0x00000000 /* Overlay Type - None */ -#define FFBDAC_CFG_OVWLUT_O_T 0x00000400 /* Overlay Type - Transparent */ -#define FFBDAC_CFG_OVWLUT_O_O 0x00000800 /* Overlay Type - Opaque */ -#define FFBDAC_CFG_OVWLUT_O_R 0x00000c00 /* Overlay Type - Reserved */ -#define FFBDAC_CFG_OVWLUT_PCS 0x00003000 /* Psuedocolor Src */ -#define FFBDAC_CFG_OVWLUT_P_XO 0x00000000 /* Psuedocolor Src - XO[7:0] */ -#define FFBDAC_CFG_OVWLUT_P_R 0x00001000 /* Psuedocolor Src - R[7:0] */ -#define FFBDAC_CFG_OVWLUT_P_G 0x00002000 /* Psuedocolor Src - G[7:0] */ -#define FFBDAC_CFG_OVWLUT_P_B 0x00003000 /* Psuedocolor Src - B[7:0] */ - -/* Window Transfer Control Register */ -#define FFBDAC_CFG_WTCTRL_DS 0x00000001 /* Device Status, 1 = Busy */ -#define FFBDAC_CFG_WTCTRL_TCMD 0x00000002 /* Transfer Command - * 1 = Transfer, 0 = No Action - */ -#define FFBDAC_CFG_WTCTRL_TE 0x00000004 /* Transfer Event - * 1 = Next Frame, 0 = Next Field - */ -#define FFBDAC_CFG_WTCTRL_DRD 0x00000008 /* Drawing Data - * 1 = Local Drawing Active - * 0 = Local Drawing Idle - */ -#define FFBDAC_CFG_WTCTRL_DRS 0x00000010 /* Drawing Status - * 1 = Network Drawing Active - * 0 = Network Drawing Idle - */ - -/* Transparent Mask Control Register */ -#define FFBDAC_CFG_TMCTRL_OMSK 0x000000ff /* Overlay Mask */ - -/* Transparent Color Key Register */ -#define FFBDAC_CFG_TCOLORKEY_K 0x000000ff /* Overlay Color Key */ - -/* Window Address Mask Register (PAC2 only) */ -#define FFBDAC_CFG_WAMASK_PMSK 0x0000003f /* PWLUT select PMASK */ -#define FFBDAC_CFG_WAMASK_OMSK 0x00000300 /* OWLUT control OMASK */ - -/* (non-Overlay) Window Lookup Table Registers, PAC1 format */ -#define FFBDAC_PAC1_WLUT_DB 0x00000020 /* 0 = Buffer A, 1 = Buffer B */ -#define FFBDAC_PAC1_WLUT_C 0x0000001c /* C: Color Model Selection */ -#define FFBDAC_PAC1_WLUT_C_8P 0x00000000 /* C: 8bpp Pseudocolor */ -#define FFBDAC_PAC1_WLUT_C_8LG 0x00000004 /* C: 8bpp Linear Grey */ -#define FFBDAC_PAC1_WLUT_C_8NG 0x00000008 /* C: 8bpp Non-Linear Grey */ -#define FFBDAC_PAC1_WLUT_C_24D 0x00000010 /* C: 24bpp Directcolor */ -#define FFBDAC_PAC1_WLUT_C_24LT 0x00000014 /* C: 24bpp Linear Truecolor */ -#define FFBDAC_PAC1_WLUT_C_24NT 0x00000018 /* C: 24bpp Non-Linear Truecolor */ -#define FFBDAC_PAC1_WLUT_PCS 0x00000003 /* Pseudocolor Src */ -#define FFBDAC_PAC1_WLUT_P_XO 0x00000000 /* Pseudocolor Src - XO[7:0] */ -#define FFBDAC_PAC1_WLUT_P_R 0x00000001 /* Pseudocolor Src - R[7:0] */ -#define FFBDAC_PAC1_WLUT_P_G 0x00000002 /* Pseudocolor Src - G[7:0] */ -#define FFBDAC_PAC1_WLUT_P_B 0x00000003 /* Pseudocolor Src - B[7:0] */ - -/* (non-Overlay) Window Lookup Table Registers, PAC2 format */ -#define FFBDAC_PAC2_WLUT_PTBL 0x00000030 /* Palette Table Entry */ -#define FFBDAC_PAC2_WLUT_LKUP 0x00000100 /* 1 = Use palette, 0 = Bypass */ -#define FFBDAC_PAC2_WLUT_PCS 0x00003000 /* Pseudocolor Src */ -#define FFBDAC_PAC2_WLUT_P_XO 0x00000000 /* Pseudocolor Src - XO[7:0] */ -#define FFBDAC_PAC2_WLUT_P_R 0x00001000 /* Pseudocolor Src - R[7:0] */ -#define FFBDAC_PAC2_WLUT_P_G 0x00002000 /* Pseudocolor Src - G[7:0] */ -#define FFBDAC_PAC2_WLUT_P_B 0x00003000 /* Pseudocolor Src - B[7:0] */ -#define FFBDAC_PAC2_WLUT_DEPTH 0x00004000 /* 0 = Pseudocolor, 1 = Truecolor*/ -#define FFBDAC_PAC2_WLUT_DB 0x00008000 /* 0 = Buffer A, 1 = Buffer B */ - -/* Signature Analysis Control Register */ -#define FFBDAC_CFG_SANAL_SRR 0x000000ff /* DAC Seed/Result for Red */ -#define FFBDAC_CFG_SANAL_SRG 0x0000ff00 /* DAC Seed/Result for Green */ -#define FFBDAC_CFG_SANAL_SRB 0x00ff0000 /* DAC Seed/Result for Blue */ -#define FFBDAC_CFG_SANAL_RQST 0x01000000 /* Signature Capture Request */ -#define FFBDAC_CFG_SANAL_BSY 0x02000000 /* Signature Analysis Busy */ -#define FFBDAC_CFG_SANAL_DSM 0x04000000 /* Data Strobe Mode - * 0 = Signature Analysis Mode - * 1 = Data Strobe Mode - */ - -/* DAC Control Register */ -#define FFBDAC_CFG_DACCTRL_O2 0x00000003 /* Operand 2 Select - * 00 = Normal Operation - * 01 = Select 145mv Reference - * 10 = Select Blue DAC Output - * 11 = Reserved - */ -#define FFBDAC_CFG_DACCTRL_O1 0x0000000c /* Operand 1 Select - * 00 = Normal Operation - * 01 = Select Green DAC Output - * 10 = Select Red DAC Output - * 11 = Reserved - */ -#define FFBDAC_CFG_DACCTRL_CR 0x00000010 /* Comparator Result - * 0 = operand1 < operand2 - * 1 = operand1 > operand2 - */ -#define FFBDAC_CFG_DACCTRL_SGE 0x00000020 /* Sync-on-Green Enable */ -#define FFBDAC_CFG_DACCTRL_PE 0x00000040 /* Pedestal Enable */ -#define FFBDAC_CFG_DACCTRL_VPD 0x00000080 /* VSYNC* Pin Disable */ -#define FFBDAC_CFG_DACCTRL_SPB 0x00000100 /* Sync Polarity Bit - * 0 = VSYNC* and CSYNC* active low - * 1 = VSYNC* and CSYNC* active high - */ - -/* Timing Generator Control Register */ -#define FFBDAC_CFG_TGEN_VIDE 0x00000001 /* Video Enable */ -#define FFBDAC_CFG_TGEN_TGE 0x00000002 /* Timing Generator Enable */ -#define FFBDAC_CFG_TGEN_HSD 0x00000004 /* HSYNC* Disabled */ -#define FFBDAC_CFG_TGEN_VSD 0x00000008 /* VSYNC* Disabled */ -#define FFBDAC_CFG_TGEN_EQD 0x00000010 /* Equalization Disabled */ -#define FFBDAC_CFG_TGEN_MM 0x00000020 /* 0 = Slave, 1 = Master */ -#define FFBDAC_CFG_TGEN_IM 0x00000040 /* 1 = Interlaced Mode */ - -/* Device Identification Register, should be 0xA236E1AD for FFB bt497/bt498 */ -#define FFBDAC_CFG_DID_ONE 0x00000001 /* Always set */ -#define FFBDAC_CFG_DID_MANUF 0x00000ffe /* Manufacturer ID */ -#define FFBDAC_CFG_DID_PNUM 0x0ffff000 /* Device Part Number */ -#define FFBDAC_CFG_DID_REV 0xf0000000 /* Device Revision */ - -/* Monitor Port Data Register */ -#define FFBDAC_CFG_MPDATA_SCL 0x00000001 /* SCL Data */ -#define FFBDAC_CFG_MPDATA_SDA 0x00000002 /* SDA Data */ - -/* Monitor Port Sense Register */ -#define FFBDAC_CFG_MPSENSE_SCL 0x00000001 /* SCL Sense */ -#define FFBDAC_CFG_MPSENSE_SDA 0x00000002 /* SDA Sense */ - -/* DAC register access shorthands. */ -#define DACCUR_READ(DAC, ADDR) ((DAC)->cur = (ADDR), (DAC)->curdata) -#define DACCUR_WRITE(DAC, ADDR, VAL) ((DAC)->cur = (ADDR), (DAC)->curdata = (VAL)) -#define DACCFG_READ(DAC, ADDR) ((DAC)->cfg = (ADDR), (DAC)->cfgdata) -#define DACCFG_WRITE(DAC, ADDR, VAL) ((DAC)->cfg = (ADDR), (DAC)->cfgdata = (VAL)) - -typedef struct ffb_dac_hwstate { - unsigned int ppllctrl; - unsigned int gpllctrl; - unsigned int pfctrl; - unsigned int uctrl; - unsigned int clut[256 * 4]; /* One 256 entry clut on PAC1, 4 on PAC2 */ - unsigned int ovluts[4]; /* Overlay WLUTS, PAC2 only */ - unsigned int wtctrl; - unsigned int tmctrl; - unsigned int tcolorkey; - unsigned int wamask; - unsigned int pwluts[64]; - unsigned int dacctrl; - unsigned int tgen; - unsigned int vbnp; - unsigned int vbap; - unsigned int vsnp; - unsigned int vsap; - unsigned int hsnp; - unsigned int hbnp; - unsigned int hbap; - unsigned int hsyncnp; - unsigned int hsyncap; - unsigned int hscennp; - unsigned int hscenap; - unsigned int epnp; - unsigned int einp; - unsigned int eiap; -} ffb_dac_hwstate_t; - -typedef struct { - Bool InUse; - - /* The following fields are undefined unless InUse is TRUE. */ - int refcount; - Bool canshare; - unsigned int wlut_regval; - int buffer; /* 0 = Buffer A, 1 = Buffer B */ - int depth; /* 8 or 32 bpp */ - int greyscale; /* 1 = greyscale, 0 = color */ - int linear; /* 1 = linear, 0 = non-linear */ - int direct; /* 1 = 24bpp directcolor */ - int channel; /* 0 = X, 1 = R, 2 = G, 3 = B */ - int palette; /* Only PAC2 has multiple CLUTs */ -} ffb_wid_info_t; - -#define FFB_MAX_PWIDS 64 -typedef struct { - int num_wids; - int wid_shift; /* To get X channel value */ - ffb_wid_info_t wid_pool[FFB_MAX_PWIDS]; -} ffb_wid_pool_t; - -typedef struct ffb_dac_info { - unsigned int flags; -#define FFB_DAC_PAC1 0x00000001 /* Pacifica1 DAC, BT9068 */ -#define FFB_DAC_PAC2 0x00000002 /* Pacifica2 DAC, BT498 */ -#define FFB_DAC_ICURCTL 0x00000004 /* Inverted CUR_CTRL bits */ - - unsigned int kernel_wid; - - /* These registers need to be modified when changing DAC - * timing state, so at init time we capture their values. - */ - unsigned int ffbcfg0; - unsigned int ffbcfg2; - unsigned int ffb_passin_ctrl; /* FFB2+/AFB only */ - - ffb_dac_hwstate_t kern_dac_state; - ffb_dac_hwstate_t x_dac_state; - - ffb_wid_pool_t wid_table; -} ffb_dac_info_t; - -#endif /* _FFB_DAC_H */ diff --git a/src/mesa/drivers/dri/ffb/server/ffb_drishare.h b/src/mesa/drivers/dri/ffb/server/ffb_drishare.h deleted file mode 100644 index 69fefa3f0a1..00000000000 --- a/src/mesa/drivers/dri/ffb/server/ffb_drishare.h +++ /dev/null @@ -1,47 +0,0 @@ - -#ifndef _FFB_DRISHARE_H -#define _FFB_DRISHARE_H - -typedef struct ffb_dri_state { - int flags; -#define FFB_DRI_FFB2 0x00000001 -#define FFB_DRI_FFB2PLUS 0x00000002 -#define FFB_DRI_PAC1 0x00000004 -#define FFB_DRI_PAC2 0x00000008 - - /* Indexed by DRI drawable id. */ -#define FFB_DRI_NWIDS 64 - unsigned int wid_table[FFB_DRI_NWIDS]; -} ffb_dri_state_t; - -#define FFB_DRISHARE(SAREA) \ - ((ffb_dri_state_t *) (((char *)(SAREA)) + sizeof(drm_sarea_t))) - -typedef struct { - drm_handle_t hFbcRegs; - drmSize sFbcRegs; - - drm_handle_t hDacRegs; - drmSize sDacRegs; - - drm_handle_t hSfb8r; - drmSize sSfb8r; - - drm_handle_t hSfb32; - drmSize sSfb32; - - drm_handle_t hSfb64; - drmSize sSfb64; - - /* Fastfill/Pagefill parameters. */ - unsigned char disable_pagefill; - int fastfill_small_area; - int pagefill_small_area; - int fastfill_height; - int fastfill_width; - int pagefill_height; - int pagefill_width; - short Pf_AlignTab[0x800]; -} FFBDRIRec, *FFBDRIPtr; - -#endif /* !(_FFB_DRISHARE_H) */ diff --git a/src/mesa/drivers/dri/ffb/server/ffb_regs.h b/src/mesa/drivers/dri/ffb/server/ffb_regs.h deleted file mode 100644 index bda5840d609..00000000000 --- a/src/mesa/drivers/dri/ffb/server/ffb_regs.h +++ /dev/null @@ -1,508 +0,0 @@ -/* - * Acceleration for the Creator and Creator3D framebuffer - register layout. - * - * Copyright (C) 1998,1999,2000 Jakub Jelinek (jakub@redhat.com) - * Copyright (C) 1998 Michal Rehacek (majkl@iname.com) - * Copyright (C) 1999 David S. Miller (davem@redhat.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * JAKUB JELINEK, MICHAL REHACEK, OR DAVID MILLER BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ - -#ifndef FFBREGS_H -#define FFBREGS_H - -/* Auxilliary clips. */ -typedef struct { - volatile unsigned int min; - volatile unsigned int max; -} ffb_auxclip, *ffb_auxclipPtr; - -/* FFB register set. */ -typedef struct _ffb_fbc { - /* Next vertex registers, on the right we list which drawops - * use said register and the logical name the register has in - * that context. - */ /* DESCRIPTION DRAWOP(NAME) */ -/*0x00*/unsigned int pad1[3]; /* Reserved */ -/*0x0c*/volatile unsigned int alpha; /* ALPHA Transparency */ -/*0x10*/volatile unsigned int red; /* RED */ -/*0x14*/volatile unsigned int green; /* GREEN */ -/*0x18*/volatile unsigned int blue; /* BLUE */ -/*0x1c*/volatile unsigned int z; /* DEPTH */ -/*0x20*/volatile unsigned int y; /* Y triangle(DOYF) */ - /* aadot(DYF) */ - /* ddline(DYF) */ - /* aaline(DYF) */ -/*0x24*/volatile unsigned int x; /* X triangle(DOXF) */ - /* aadot(DXF) */ - /* ddline(DXF) */ - /* aaline(DXF) */ -/*0x28*/unsigned int pad2[2]; /* Reserved */ -/*0x30*/volatile unsigned int ryf; /* Y (alias to DOYF) ddline(RYF) */ - /* aaline(RYF) */ - /* triangle(RYF) */ -/*0x34*/volatile unsigned int rxf; /* X ddline(RXF) */ - /* aaline(RXF) */ - /* triangle(RXF) */ -/*0x38*/unsigned int pad3[2]; /* Reserved */ -/*0x40*/volatile unsigned int dmyf; /* Y (alias to DOYF) triangle(DMYF) */ -/*0x44*/volatile unsigned int dmxf; /* X triangle(DMXF) */ -/*0x48*/unsigned int pad4[2]; /* Reserved */ -/*0x50*/volatile unsigned int ebyi; /* Y (alias to RYI) polygon(EBYI) */ -/*0x54*/volatile unsigned int ebxi; /* X polygon(EBXI) */ -/*0x58*/unsigned int pad5[2]; /* Reserved */ -/*0x60*/volatile unsigned int by; /* Y brline(RYI) */ - /* fastfill(OP) */ - /* polygon(YI) */ - /* rectangle(YI) */ - /* bcopy(SRCY) */ - /* vscroll(SRCY) */ -/*0x64*/volatile unsigned int bx; /* X brline(RXI) */ - /* polygon(XI) */ - /* rectangle(XI) */ - /* bcopy(SRCX) */ - /* vscroll(SRCX) */ - /* fastfill(GO) */ -/*0x68*/volatile unsigned int dy; /* destination Y fastfill(DSTY) */ - /* bcopy(DSRY) */ - /* vscroll(DSRY) */ -/*0x6c*/volatile unsigned int dx; /* destination X fastfill(DSTX) */ - /* bcopy(DSTX) */ - /* vscroll(DSTX) */ -/*0x70*/volatile unsigned int bh; /* Y (alias to RYI) brline(DYI) */ - /* dot(DYI) */ - /* polygon(ETYI) */ - /* Height fastfill(H) */ - /* bcopy(H) */ - /* vscroll(H) */ - /* Y count fastfill(NY) */ -/*0x74*/volatile unsigned int bw; /* X dot(DXI) */ - /* brline(DXI) */ - /* polygon(ETXI) */ - /* fastfill(W) */ - /* bcopy(W) */ - /* vscroll(W) */ - /* fastfill(NX) */ -/*0x78*/unsigned int pad6[2]; /* Reserved */ -/*0x80*/unsigned int pad7[32]; /* Reserved */ - - /* Setup Unit's vertex state register */ -/*100*/ volatile unsigned int suvtx; -/*104*/ unsigned int pad8[63]; /* Reserved */ - - /* Frame Buffer Control Registers */ -/*200*/ volatile unsigned int ppc; /* Pixel Processor Control */ -/*204*/ volatile unsigned int wid; /* Current WID */ -/*208*/ volatile unsigned int fg; /* FG data */ -/*20c*/ volatile unsigned int bg; /* BG data */ -/*210*/ volatile unsigned int consty; /* Constant Y */ -/*214*/ volatile unsigned int constz; /* Constant Z */ -/*218*/ volatile unsigned int xclip; /* X Clip */ -/*21c*/ volatile unsigned int dcss; /* Depth Cue Scale Slope */ -/*220*/ volatile unsigned int vclipmin; /* Viewclip XY Min Bounds */ -/*224*/ volatile unsigned int vclipmax; /* Viewclip XY Max Bounds */ -/*228*/ volatile unsigned int vclipzmin; /* Viewclip Z Min Bounds */ -/*22c*/ volatile unsigned int vclipzmax; /* Viewclip Z Max Bounds */ -/*230*/ volatile unsigned int dcsf; /* Depth Cue Scale Front Bound */ -/*234*/ volatile unsigned int dcsb; /* Depth Cue Scale Back Bound */ -/*238*/ volatile unsigned int dczf; /* Depth Cue Z Front */ -/*23c*/ volatile unsigned int dczb; /* Depth Cue Z Back */ -/*240*/ unsigned int pad9; /* Reserved */ -/*244*/ volatile unsigned int blendc; /* Alpha Blend Control */ -/*248*/ volatile unsigned int blendc1; /* Alpha Blend Color 1 */ -/*24c*/ volatile unsigned int blendc2; /* Alpha Blend Color 2 */ -/*250*/ volatile unsigned int fbramitc; /* FB RAM Interleave Test Control */ -/*254*/ volatile unsigned int fbc; /* Frame Buffer Control */ -/*258*/ volatile unsigned int rop; /* Raster OPeration */ -/*25c*/ volatile unsigned int cmp; /* Frame Buffer Compare */ -/*260*/ volatile unsigned int matchab; /* Buffer AB Match Mask */ -/*264*/ volatile unsigned int matchc; /* Buffer C(YZ) Match Mask */ -/*268*/ volatile unsigned int magnab; /* Buffer AB Magnitude Mask */ -/*26c*/ volatile unsigned int magnc; /* Buffer C(YZ) Magnitude Mask */ -/*270*/ volatile unsigned int fbcfg0; /* Frame Buffer Config 0 */ -/*274*/ volatile unsigned int fbcfg1; /* Frame Buffer Config 1 */ -/*278*/ volatile unsigned int fbcfg2; /* Frame Buffer Config 2 */ -/*27c*/ volatile unsigned int fbcfg3; /* Frame Buffer Config 3 */ -/*280*/ volatile unsigned int ppcfg; /* Pixel Processor Config */ -/*284*/ volatile unsigned int pick; /* Picking Control */ -/*288*/ volatile unsigned int fillmode; /* FillMode */ -/*28c*/ volatile unsigned int fbramwac; /* FB RAM Write Address Control */ -/*290*/ volatile unsigned int pmask; /* RGB PlaneMask */ -/*294*/ volatile unsigned int xpmask; /* X PlaneMask */ -/*298*/ volatile unsigned int ypmask; /* Y PlaneMask */ -/*29c*/ volatile unsigned int zpmask; /* Z PlaneMask */ -/*2a0*/ ffb_auxclip auxclip[4]; /* Auxilliary Viewport Clip */ - - /* New 3dRAM III support regs */ -/*2c0*/ volatile unsigned int rawblend2; -/*2c4*/ volatile unsigned int rawpreblend; -/*2c8*/ volatile unsigned int rawstencil; -/*2cc*/ volatile unsigned int rawstencilctl; -/*2d0*/ volatile unsigned int threedram1; -/*2d4*/ volatile unsigned int threedram2; -/*2d8*/ volatile unsigned int passin; -/*2dc*/ volatile unsigned int rawclrdepth; -/*2e0*/ volatile unsigned int rawpmask; -/*2e4*/ volatile unsigned int rawcsrc; -/*2e8*/ volatile unsigned int rawmatch; -/*2ec*/ volatile unsigned int rawmagn; -/*2f0*/ volatile unsigned int rawropblend; -/*2f4*/ volatile unsigned int rawcmp; -/*2f8*/ volatile unsigned int rawwac; -/*2fc*/ volatile unsigned int fbramid; - -/*300*/ volatile unsigned int drawop; /* Draw OPeration */ -/*304*/ unsigned int pad10[2]; /* Reserved */ -/*30c*/ volatile unsigned int lpat; /* Line Pattern control */ -/*310*/ unsigned int pad11; /* Reserved */ -/*314*/ volatile unsigned int fontxy; /* XY Font coordinate */ -/*318*/ volatile unsigned int fontw; /* Font Width */ -/*31c*/ volatile unsigned int fontinc; /* Font Increment */ -/*320*/ volatile unsigned int font; /* Font bits */ -/*324*/ unsigned int pad12[3]; /* Reserved */ -/*330*/ volatile unsigned int blend2; -/*334*/ volatile unsigned int preblend; -/*338*/ volatile unsigned int stencil; -/*33c*/ volatile unsigned int stencilctl; - -/*340*/ unsigned int pad13[4]; /* Reserved */ -/*350*/ volatile unsigned int dcss1; /* Depth Cue Scale Slope 1 */ -/*354*/ volatile unsigned int dcss2; /* Depth Cue Scale Slope 2 */ -/*358*/ volatile unsigned int dcss3; /* Depth Cue Scale Slope 3 */ -/*35c*/ volatile unsigned int widpmask; -/*360*/ volatile unsigned int dcs2; -/*364*/ volatile unsigned int dcs3; -/*368*/ volatile unsigned int dcs4; -/*36c*/ unsigned int pad14; /* Reserved */ -/*370*/ volatile unsigned int dcd2; -/*374*/ volatile unsigned int dcd3; -/*378*/ volatile unsigned int dcd4; -/*37c*/ unsigned int pad15; /* Reserved */ -/*380*/ volatile unsigned int pattern[32]; /* area Pattern */ -/*400*/ unsigned int pad16[8]; /* Reserved */ -/*420*/ volatile unsigned int reset; /* chip RESET */ -/*424*/ unsigned int pad17[247]; /* Reserved */ -/*800*/ volatile unsigned int devid; /* Device ID */ -/*804*/ unsigned int pad18[63]; /* Reserved */ -/*900*/ volatile unsigned int ucsr; /* User Control & Status Register */ -/*904*/ unsigned int pad19[31]; /* Reserved */ -/*980*/ volatile unsigned int mer; /* Mode Enable Register */ -/*984*/ unsigned int pad20[1439]; /* Reserved */ -} ffb_fbc, *ffb_fbcPtr; - -/* Draw operations */ -#define FFB_DRAWOP_DOT 0x00 -#define FFB_DRAWOP_AADOT 0x01 -#define FFB_DRAWOP_BRLINECAP 0x02 -#define FFB_DRAWOP_BRLINEOPEN 0x03 -#define FFB_DRAWOP_DDLINE 0x04 -#define FFB_DRAWOP_AALINE 0x05 -#define FFB_DRAWOP_TRIANGLE 0x06 -#define FFB_DRAWOP_POLYGON 0x07 -#define FFB_DRAWOP_RECTANGLE 0x08 -#define FFB_DRAWOP_FASTFILL 0x09 -#define FFB_DRAWOP_BCOPY 0x0a /* Not implemented in any FFB, VIS is faster */ -#define FFB_DRAWOP_VSCROLL 0x0b /* Up to 12x faster than BCOPY, 3-4x faster than VIS */ - -/* FastFill operation codes. */ -#define FFB_FASTFILL_PAGE 0x01 -#define FFB_FASTFILL_BLOCK 0x02 -#define FFB_FASTFILL_COLOR_BLK 0x03 -#define FFB_FASTFILL_BLOCK_X 0x04 - -/* Spanfill Unit Line Pattern */ -#define FFB_LPAT_SCALEPTR 0xf0000000 -#define FFB_LPAT_SCALEPTR_SHIFT 28 -#define FFB_LPAT_PATPTR 0x0f000000 -#define FFB_LPAT_PATPTR_SHIFT 24 -#define FFB_LPAT_SCALEVAL 0x00f00000 -#define FFB_LPAT_SCALEVAL_SHIFT 20 -#define FFB_LPAT_PATLEN 0x000f0000 -#define FFB_LPAT_PATLEN_SHIFT 16 -#define FFB_LPAT_PATTERN 0x0000ffff -#define FFB_LPAT_PATTERN_SHIFT 0 - -/* Pixel processor control */ -/* Force WID */ -#define FFB_PPC_FW_DISABLE 0x800000 -#define FFB_PPC_FW_ENABLE 0xc00000 -#define FFB_PPC_FW_MASK 0xc00000 -/* Auxiliary clip */ -#define FFB_PPC_ACE_DISABLE 0x040000 -#define FFB_PPC_ACE_AUX_SUB 0x080000 -#define FFB_PPC_ACE_AUX_ADD 0x0c0000 -#define FFB_PPC_ACE_MASK 0x0c0000 -/* Depth cue */ -#define FFB_PPC_DCE_DISABLE 0x020000 -#define FFB_PPC_DCE_ENABLE 0x030000 -#define FFB_PPC_DCE_MASK 0x030000 -/* Alpha blend */ -#define FFB_PPC_ABE_DISABLE 0x008000 -#define FFB_PPC_ABE_ENABLE 0x00c000 -#define FFB_PPC_ABE_MASK 0x00c000 -/* View clip */ -#define FFB_PPC_VCE_DISABLE 0x001000 -#define FFB_PPC_VCE_2D 0x002000 -#define FFB_PPC_VCE_3D 0x003000 -#define FFB_PPC_VCE_MASK 0x003000 -/* Area pattern */ -#define FFB_PPC_APE_DISABLE 0x000800 -#define FFB_PPC_APE_ENABLE 0x000c00 -#define FFB_PPC_APE_MASK 0x000c00 -/* Transparent background */ -#define FFB_PPC_TBE_OPAQUE 0x000200 -#define FFB_PPC_TBE_TRANSPARENT 0x000300 -#define FFB_PPC_TBE_MASK 0x000300 -/* Z source */ -#define FFB_PPC_ZS_VAR 0x000080 -#define FFB_PPC_ZS_CONST 0x0000c0 -#define FFB_PPC_ZS_MASK 0x0000c0 -/* Y source */ -#define FFB_PPC_YS_VAR 0x000020 -#define FFB_PPC_YS_CONST 0x000030 -#define FFB_PPC_YS_MASK 0x000030 -/* X source */ -#define FFB_PPC_XS_WID 0x000004 -#define FFB_PPC_XS_VAR 0x000008 -#define FFB_PPC_XS_CONST 0x00000c -#define FFB_PPC_XS_MASK 0x00000c -/* Color (BGR) source */ -#define FFB_PPC_CS_VAR 0x000002 -#define FFB_PPC_CS_CONST 0x000003 -#define FFB_PPC_CS_MASK 0x000003 - -/* X Clip */ -#define FFB_XCLIP_XREF 0x000000ff -#define FFB_XCLIP_TEST_MASK 0x00070000 -#define FFB_XCLIP_TEST_ALWAYS 0x00000000 -#define FFB_XCLIP_TEST_GT 0x00010000 -#define FFB_XCLIP_TEST_EQ 0x00020000 -#define FFB_XCLIP_TEST_GE 0x00030000 -#define FFB_XCLIP_TEST_NEVER 0x00040000 -#define FFB_XCLIP_TEST_LE 0x00050000 -#define FFB_XCLIP_TEST_NE 0x00060000 -#define FFB_XCLIP_TEST_LT 0x00070000 - -/* FB Control register */ -/* Write buffer dest */ -#define FFB_FBC_WB_A 0x20000000 -#define FFB_FBC_WB_B 0x40000000 -#define FFB_FBC_WB_AB 0x60000000 -#define FFB_FBC_WB_C 0x80000000 -#define FFB_FBC_WB_AC 0xa0000000 -#define FFB_FBC_WB_BC 0xc0000000 -#define FFB_FBC_WB_ABC 0xe0000000 -#define FFB_FBC_WB_MASK 0xe0000000 -/* Write enable */ -#define FFB_FBC_WE_FORCEOFF 0x00100000 -#define FFB_FBC_WE_FORCEON 0x00200000 -#define FFB_FBC_WE_USE_WMASK 0x00300000 -#define FFB_FBC_WE_MASK 0x00300000 -/* Write group mode */ -#define FFB_FBC_WM_RSVD 0x00040000 -#define FFB_FBC_WM_COMBINED 0x00080000 -#define FFB_FBC_WM_SEPARATE 0x000c0000 -#define FFB_FBC_WM_MASK 0x000c0000 -/* Read buffer src */ -#define FFB_FBC_RB_A 0x00004000 -#define FFB_FBC_RB_B 0x00008000 -#define FFB_FBC_RB_C 0x0000c000 -#define FFB_FBC_RB_MASK 0x0000c000 -/* Stereo buf dest */ -#define FFB_FBC_SB_LEFT 0x00001000 -#define FFB_FBC_SB_RIGHT 0x00002000 -#define FFB_FBC_SB_BOTH 0x00003000 -#define FFB_FBC_SB_MASK 0x00003000 -/* Z plane group enable */ -#define FFB_FBC_ZE_OFF 0x00000400 -#define FFB_FBC_ZE_ON 0x00000800 -#define FFB_FBC_ZE_MASK 0x00000c00 -/* Y plane group enable */ -#define FFB_FBC_YE_OFF 0x00000100 -#define FFB_FBC_YE_ON 0x00000200 -#define FFB_FBC_YE_MASK 0x00000300 -/* X plane group enable */ -#define FFB_FBC_XE_OFF 0x00000040 -#define FFB_FBC_XE_ON 0x00000080 -#define FFB_FBC_XE_MASK 0x000000c0 -/* B plane group enable */ -#define FFB_FBC_BE_OFF 0x00000010 -#define FFB_FBC_BE_ON 0x00000020 -#define FFB_FBC_BE_MASK 0x00000030 -/* G plane group enable */ -#define FFB_FBC_GE_OFF 0x00000004 -#define FFB_FBC_GE_ON 0x00000008 -#define FFB_FBC_GE_MASK 0x0000000c -/* R plane group enable */ -#define FFB_FBC_RE_OFF 0x00000001 -#define FFB_FBC_RE_ON 0x00000002 -#define FFB_FBC_RE_MASK 0x00000003 -/* Combined */ -#define FFB_FBC_RGBE_OFF 0x00000015 -#define FFB_FBC_RGBE_ON 0x0000002a -#define FFB_FBC_RGBE_MASK 0x0000003f - -/* Raster OP */ -#define FFB_ROP_YZ_MASK 0x008f0000 -#define FFB_ROP_X_MASK 0x00008f00 -#define FFB_ROP_RGB_MASK 0x0000008f - -/* Now the rops themselves which get shifted into the - * above fields. - */ -#define FFB_ROP_EDIT_BIT 0x80 -#define FFB_ROP_ZERO 0x80 -#define FFB_ROP_NEW_AND_OLD 0x81 -#define FFB_ROP_NEW_AND_NOLD 0x82 -#define FFB_ROP_NEW 0x83 -#define FFB_ROP_NNEW_AND_OLD 0x84 -#define FFB_ROP_OLD 0x85 -#define FFB_ROP_NEW_XOR_OLD 0x86 -#define FFB_ROP_NEW_OR_OLD 0x87 -#define FFB_ROP_NNEW_AND_NOLD 0x88 -#define FFB_ROP_NNEW_XOR_NOLD 0x89 -#define FFB_ROP_NOLD 0x8a -#define FFB_ROP_NEW_OR_NOLD 0x8b -#define FFB_ROP_NNEW 0x8c -#define FFB_ROP_NNEW_OR_OLD 0x8d -#define FFB_ROP_NNEW_OR_NOLD 0x8e -#define FFB_ROP_ONES 0x8f - -/* FB Compare */ -#define FFB_CMP_MATCHC_MASK 0x8f000000 -#define FFB_CMP_MAGNC_MASK 0x00870000 -#define FFB_CMP_MATCHAB_MASK 0x0000ff00 -#define FFB_CMP_MAGNAB_MASK 0x000000ff - -/* Compare Match codes */ -#define FFB_CMP_MATCH_EDIT_BIT 0x80 -#define FFB_CMP_MATCH_ALWAYS 0x80 -#define FFB_CMP_MATCH_NEVER 0x81 -#define FFB_CMP_MATCH_EQ 0x82 -#define FFB_CMP_MATCH_NE 0x83 -#define FFB_CMP_MATCH_A_ALWAYS 0xc0 -#define FFB_CMP_MATCH_B_ALWAYS 0xa0 - -/* Compare Magnitude codes */ -#define FFB_CMP_MAGN_EDIT_BIT 0x80 -#define FFB_CMP_MAGN_ALWAYS 0x80 -#define FFB_CMP_MAGN_GT 0x81 -#define FFB_CMP_MAGN_EQ 0x82 -#define FFB_CMP_MAGN_GE 0x83 -#define FFB_CMP_MAGN_NEVER 0x84 -#define FFB_CMP_MAGN_LE 0x85 -#define FFB_CMP_MAGN_NE 0x86 -#define FFB_CMP_MAGN_LT 0x87 -#define FFB_CMP_MAGN_A_ALWAYS 0xc0 -#define FFB_CMP_MAGN_B_ALWAYS 0xa0 - -/* User Control and Status */ -#define FFB_UCSR_FIFO_MASK 0x00000fff -#define FFB_UCSR_PICK_NO_HIT 0x00020000 -#define FFB_UCSR_PICK_HIT 0x00030000 -#define FFB_UCSR_PICK_DISABLE 0x00080000 -#define FFB_UCSR_PICK_ENABLE 0x000c0000 -#define FFB_UCSR_FB_BUSY 0x01000000 -#define FFB_UCSR_RP_BUSY 0x02000000 -#define FFB_UCSR_ALL_BUSY (FFB_UCSR_RP_BUSY|FFB_UCSR_FB_BUSY) -#define FFB_UCSR_READ_ERR 0x40000000 -#define FFB_UCSR_FIFO_OVFL 0x80000000 -#define FFB_UCSR_ALL_ERRORS (FFB_UCSR_READ_ERR|FFB_UCSR_FIFO_OVFL) - -/* Mode Enable Register */ -#define FFB_MER_EIRA 0x00000080 /* Enable read-ahead, increasing */ -#define FFB_MER_EDRA 0x000000c0 /* Enable read-ahead, decreasing */ -#define FFB_MER_DRA 0x00000040 /* No read-ahead */ - -/* FBram Config 0 */ -#define FFB_FBCFG0_RFTIME 0xff800000 -#define FFB_FBCFG0_XMAX 0x007c0000 -#define FFB_FBCFG0_YMAX 0x0003ffc0 -#define FFB_FBCFG0_RES_MASK 0x00000030 -#define FFB_FBCFG0_RES_HIGH 0x00000030 /* 1920x1360 */ -#define FFB_FBCFG0_RES_STD 0x00000020 /* 1280x1024 */ -#define FFB_FBCFG0_RES_STEREO 0x00000010 /* 960x580 */ -#define FFB_FBCFG0_RES_PRTRAIT 0x00000000 /* 1280x2048 */ -#define FFB_FBCFG0_ITRLACE 0x00000000 -#define FFB_FBCFG0_SEQUENTIAL 0x00000008 -#define FFB_FBCFG0_DRENA 0x00000004 -#define FFB_FBCFG0_BPMODE 0x00000002 -#define FFB_FBCFG0_RFRSH_RST 0x00000001 - -typedef struct _ffb_dac { - volatile unsigned int cfg; - volatile unsigned int cfgdata; - volatile unsigned int cur; - volatile unsigned int curdata; -} ffb_dac, *ffb_dacPtr; - -/* Writing 2 32-bit registers at a time using 64-bit stores. -DaveM */ -#if defined(__GNUC__) && defined(USE_VIS) -/* 64-bit register writing support. - * Note: "lo" means "low address". - */ -#define FFB_WRITE64_COMMON(__regp, __lo32, __hi32, REG0, REG1) \ -do { __extension__ register unsigned int __r0 __asm__(""#REG0); \ - __extension__ register unsigned int __r1 __asm__(""#REG1); \ - __r0 = (__lo32); \ - __r1 = (__hi32); \ - __asm__ __volatile__ ("sllx\t%0, 32, %%g1\n\t" \ - "srl\t%1, 0, %1\n\t" \ - "or\t%%g1, %1, %%g1\n\t" \ - "stx\t%%g1, %2" \ - : : "r" (__r0), "r" (__r1), "m" (*(__regp)) : "g1"); \ -} while(0) - -#define FFB_WRITE64P(__regp, __srcp) \ -do { __asm__ __volatile__ ("ldx\t%0, %%g2;" \ - "stx\t%%g2, %1" \ - : : "m" (*(__srcp)), "m" (*(__regp)) \ - : "g2"); \ -} while(0) - -#define FFB_WRITE64(__regp, __lo32, __hi32) \ - FFB_WRITE64_COMMON(__regp, __lo32, __hi32, g2, g3) -#define FFB_WRITE64_2(__regp, __lo32, __hi32) \ - FFB_WRITE64_COMMON(__regp, __lo32, __hi32, g4, g5) -#define FFB_WRITE64_3(__regp, __lo32, __hi32) \ - FFB_WRITE64_COMMON(__regp, __lo32, __hi32, o4, o5) - -#else /* Do not use 64-bit writes. */ - -#define FFB_WRITE64(__regp, __lo32, __hi32) \ -do { volatile unsigned int *__p = (__regp); \ - *__p = (__lo32); \ - *(__p + 1) = (__hi32); \ -} while(0) - -#define FFB_WRITE64P(__regp, __srcp) \ -do { volatile unsigned int *__p = (__regp); \ - unsigned int *__q = (__srcp); \ - *__p = *__q; \ - *(__p + 1) = *(__q + 1); \ -} while(0) - -#define FFB_WRITE64_2(__regp, __lo32, __hi32) \ - FFB_WRITE64(__regp, __lo32, __hi32) -#define FFB_WRITE64_3(__regp, __lo32, __hi32) \ - FFB_WRITE64(__regp, __lo32, __hi32) -#endif - -#endif /* FFBREGS_H */ diff --git a/src/mesa/drivers/dri/gamma/Makefile b/src/mesa/drivers/dri/gamma/Makefile deleted file mode 100644 index 09df1578fc7..00000000000 --- a/src/mesa/drivers/dri/gamma/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# src/mesa/drivers/dri/gamma/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = gamma_dri.so - -# Not yet -# MINIGLX_SOURCES = server/gamma_dri.c - -DRIVER_SOURCES = \ - gamma_context.c \ - gamma_dd.c \ - gamma_inithw.c \ - gamma_lock.c \ - gamma_render.c \ - gamma_screen.c \ - gamma_span.c \ - gamma_state.c \ - gamma_tex.c \ - gamma_texmem.c \ - gamma_texstate.c \ - gamma_tris.c \ - gamma_vb.c \ - gamma_xmesa.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - -include ../Makefile.template - diff --git a/src/mesa/drivers/dri/gamma/gamma_client.h b/src/mesa/drivers/dri/gamma/gamma_client.h deleted file mode 100644 index 6dcf2e9438b..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_client.h +++ /dev/null @@ -1,6184 +0,0 @@ -/* Automaticallly generated -- do not edit */ -#ifndef _GLINT_CLIENT_H_ -#define _GLINT_CLIENT_H_ -/* **********************************************************************/ -/* START OF glint_extra.h INCLUSION */ -/* **********************************************************************/ - -/* glint_extra.h - * Created: Fri Apr 2 23:32:05 1999 by faith@precisioninsight.com - * Revised: Fri Apr 2 23:33:00 1999 by faith@precisioninsight.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * - */ - -#define AreaStippleEnable 0x00001 -#define LineStippleEnable 0x00002 -#define GResetLineStipple 0x00004 -#define FastFillEnable 0x00008 -#define PrimitiveLine 0x00000 -#define PrimitiveTrapezoid 0x00040 -#define PrimitivePoint 0x00080 -#define PrimitiveRectangle 0x000C0 -#define AntialiasEnable 0x00100 -#define AntialiasingQuality 0x00200 -#define UsePointTable 0x00400 -#define SyncOnBitMask 0x00800 -#define SyncOnHostData 0x01000 -#define TextureEnable 0x02000 -#define FogEnable 0x04000 -#define CoverageEnable 0x08000 -#define SubPixelCorrectionEnable 0x10000 -#define SpanOperation 0x40000 - - -/* **********************************************************************/ -/* END OF glint_extra.h INCLUSION */ -/* **********************************************************************/ - - -#define GlintResetStatus 0x0000 -#define GlintResetStatusReg 0 -#define GlintResetStatusOff 0x0000 -#define GlintResetStatusSec 0x0000 -#define GlintResetStatusSecReg 2 -#define GlintResetStatusSecOff 0x0000 - -#define GlintIntEnable 0x0008 -#define GlintIntEnableReg 0 -#define GlintIntEnableOff 0x0008 -#define GlintIntEnableSec 0x0008 -#define GlintIntEnableSecReg 2 -#define GlintIntEnableSecOff 0x0008 - -#define GlintIntFlags 0x0010 -#define GlintIntFlagsReg 0 -#define GlintIntFlagsOff 0x0010 -#define GlintIntFlagsSec 0x0010 -#define GlintIntFlagsSecReg 2 -#define GlintIntFlagsSecOff 0x0010 - -#define GlintInFIFOSpace 0x0018 -#define GlintInFIFOSpaceReg 0 -#define GlintInFIFOSpaceOff 0x0018 -#define GlintInFIFOSpaceSec 0x0018 -#define GlintInFIFOSpaceSecReg 2 -#define GlintInFIFOSpaceSecOff 0x0018 - -#define GlintOutFIFOWords 0x0020 -#define GlintOutFIFOWordsReg 0 -#define GlintOutFIFOWordsOff 0x0020 -#define GlintOutFIFOWordsSec 0x0020 -#define GlintOutFIFOWordsSecReg 2 -#define GlintOutFIFOWordsSecOff 0x0020 - -#define GlintDMAAddress 0x0028 -#define GlintDMAAddressReg 0 -#define GlintDMAAddressOff 0x0028 -#define GlintDMAAddressSec 0x0028 -#define GlintDMAAddressSecReg 2 -#define GlintDMAAddressSecOff 0x0028 - -#define GlintDMACount 0x0030 -#define GlintDMACountReg 0 -#define GlintDMACountOff 0x0030 -#define GlintDMACountSec 0x0030 -#define GlintDMACountSecReg 2 -#define GlintDMACountSecOff 0x0030 - -#define GlintErrorFlags 0x0038 -#define GlintErrorFlagsReg 0 -#define GlintErrorFlagsOff 0x0038 -#define GlintErrorFlagsSec 0x0038 -#define GlintErrorFlagsSecReg 2 -#define GlintErrorFlagsSecOff 0x0038 - -#define GlintVClkCtl 0x0040 -#define GlintVClkCtlReg 0 -#define GlintVClkCtlOff 0x0040 -#define GlintVClkCtlSec 0x0040 -#define GlintVClkCtlSecReg 2 -#define GlintVClkCtlSecOff 0x0040 - -#define GlintTestRegister 0x0048 -#define GlintTestRegisterReg 0 -#define GlintTestRegisterOff 0x0048 -#define GlintTestRegisterSec 0x0048 -#define GlintTestRegisterSecReg 2 -#define GlintTestRegisterSecOff 0x0048 - -#define GlintAperture0 0x0050 -#define GlintAperture0Reg 0 -#define GlintAperture0Off 0x0050 -#define GlintAperture0Sec 0x0050 -#define GlintAperture0SecReg 2 -#define GlintAperture0SecOff 0x0050 - -#define GlintAperture1 0x0058 -#define GlintAperture1Reg 0 -#define GlintAperture1Off 0x0058 -#define GlintAperture1Sec 0x0058 -#define GlintAperture1SecReg 2 -#define GlintAperture1SecOff 0x0058 - -#define GlintDMAControl 0x0060 -#define GlintDMAControlReg 0 -#define GlintDMAControlOff 0x0060 -#define GlintDMAControlSec 0x0060 -#define GlintDMAControlSecReg 2 -#define GlintDMAControlSecOff 0x0060 - -#define GlintFIFODis 0x0068 -#define GlintFIFODisReg 0 -#define GlintFIFODisOff 0x0068 -#define GlintFIFODisSec 0x0068 -#define GlintFIFODisSecReg 2 -#define GlintFIFODisSecOff 0x0068 - -#define GlintLBMemoryCtl 0x1000 -#define GlintLBMemoryCtlReg 1 -#define GlintLBMemoryCtlOff 0x0000 -#define GlintLBMemoryCtlSec 0x1000 -#define GlintLBMemoryCtlSecReg 3 -#define GlintLBMemoryCtlSecOff 0x0000 - -#define GlintLBMemoryEDO 0x1008 -#define GlintLBMemoryEDOReg 1 -#define GlintLBMemoryEDOOff 0x0008 -#define GlintLBMemoryEDOSec 0x1008 -#define GlintLBMemoryEDOSecReg 3 -#define GlintLBMemoryEDOSecOff 0x0008 - -#define GlintFBMemoryCtl 0x1800 -#define GlintFBMemoryCtlReg 1 -#define GlintFBMemoryCtlOff 0x0800 -#define GlintFBMemoryCtlSec 0x1800 -#define GlintFBMemoryCtlSecReg 3 -#define GlintFBMemoryCtlSecOff 0x0800 - -#define GlintFBModeSel 0x1808 -#define GlintFBModeSelReg 1 -#define GlintFBModeSelOff 0x0808 -#define GlintFBModeSelSec 0x1808 -#define GlintFBModeSelSecReg 3 -#define GlintFBModeSelSecOff 0x0808 - -#define GlintFBGCWrMask 0x1810 -#define GlintFBGCWrMaskReg 1 -#define GlintFBGCWrMaskOff 0x0810 -#define GlintFBGCWrMaskSec 0x1810 -#define GlintFBGCWrMaskSecReg 3 -#define GlintFBGCWrMaskSecOff 0x0810 - -#define GlintFBGCColorLower 0x1818 -#define GlintFBGCColorLowerReg 1 -#define GlintFBGCColorLowerOff 0x0818 -#define GlintFBGCColorLowerSec 0x1818 -#define GlintFBGCColorLowerSecReg 3 -#define GlintFBGCColorLowerSecOff 0x0818 - -#define GlintFBTXMemCtl 0x1820 -#define GlintFBTXMemCtlReg 1 -#define GlintFBTXMemCtlOff 0x0820 -#define GlintFBTXMemCtlSec 0x1820 -#define GlintFBTXMemCtlSecReg 3 -#define GlintFBTXMemCtlSecOff 0x0820 - -#define GlintFBWrMask 0x1830 -#define GlintFBWrMaskReg 1 -#define GlintFBWrMaskOff 0x0830 -#define GlintFBWrMaskSec 0x1830 -#define GlintFBWrMaskSecReg 3 -#define GlintFBWrMaskSecOff 0x0830 - -#define GlintFBGCColorUpper 0x1838 -#define GlintFBGCColorUpperReg 1 -#define GlintFBGCColorUpperOff 0x0838 -#define GlintFBGCColorUpperSec 0x1838 -#define GlintFBGCColorUpperSecReg 3 -#define GlintFBGCColorUpperSecOff 0x0838 - -#define GlintVTGHLimit 0x3000 -#define GlintVTGHLimitReg 1 -#define GlintVTGHLimitOff 0x2000 -#define GlintVTGHLimitSec 0x3000 -#define GlintVTGHLimitSecReg 3 -#define GlintVTGHLimitSecOff 0x2000 - -#define GlintVTGHSyncStart 0x3008 -#define GlintVTGHSyncStartReg 1 -#define GlintVTGHSyncStartOff 0x2008 -#define GlintVTGHSyncStartSec 0x3008 -#define GlintVTGHSyncStartSecReg 3 -#define GlintVTGHSyncStartSecOff 0x2008 - -#define GlintVTGHSyncEnd 0x3010 -#define GlintVTGHSyncEndReg 1 -#define GlintVTGHSyncEndOff 0x2010 -#define GlintVTGHSyncEndSec 0x3010 -#define GlintVTGHSyncEndSecReg 3 -#define GlintVTGHSyncEndSecOff 0x2010 - -#define GlintVTGHBlankEnd 0x3018 -#define GlintVTGHBlankEndReg 1 -#define GlintVTGHBlankEndOff 0x2018 -#define GlintVTGHBlankEndSec 0x3018 -#define GlintVTGHBlankEndSecReg 3 -#define GlintVTGHBlankEndSecOff 0x2018 - -#define GlintVTGVLimit 0x3020 -#define GlintVTGVLimitReg 1 -#define GlintVTGVLimitOff 0x2020 -#define GlintVTGVLimitSec 0x3020 -#define GlintVTGVLimitSecReg 3 -#define GlintVTGVLimitSecOff 0x2020 - -#define GlintVTGVSyncStart 0x3028 -#define GlintVTGVSyncStartReg 1 -#define GlintVTGVSyncStartOff 0x2028 -#define GlintVTGVSyncStartSec 0x3028 -#define GlintVTGVSyncStartSecReg 3 -#define GlintVTGVSyncStartSecOff 0x2028 - -#define GlintVTGVSyncEnd 0x3030 -#define GlintVTGVSyncEndReg 1 -#define GlintVTGVSyncEndOff 0x2030 -#define GlintVTGVSyncEndSec 0x3030 -#define GlintVTGVSyncEndSecReg 3 -#define GlintVTGVSyncEndSecOff 0x2030 - -#define GlintVTGVBlankEnd 0x3038 -#define GlintVTGVBlankEndReg 1 -#define GlintVTGVBlankEndOff 0x2038 -#define GlintVTGVBlankEndSec 0x3038 -#define GlintVTGVBlankEndSecReg 3 -#define GlintVTGVBlankEndSecOff 0x2038 - -#define GlintVTGHGateStart 0x3040 -#define GlintVTGHGateStartReg 1 -#define GlintVTGHGateStartOff 0x2040 -#define GlintVTGHGateStartSec 0x3040 -#define GlintVTGHGateStartSecReg 3 -#define GlintVTGHGateStartSecOff 0x2040 - -#define GlintVTGHGateEnd 0x3048 -#define GlintVTGHGateEndReg 1 -#define GlintVTGHGateEndOff 0x2048 -#define GlintVTGHGateEndSec 0x3048 -#define GlintVTGHGateEndSecReg 3 -#define GlintVTGHGateEndSecOff 0x2048 - -#define GlintVTGVGateStart 0x3050 -#define GlintVTGVGateStartReg 1 -#define GlintVTGVGateStartOff 0x2050 -#define GlintVTGVGateStartSec 0x3050 -#define GlintVTGVGateStartSecReg 3 -#define GlintVTGVGateStartSecOff 0x2050 - -#define GlintVTGVGateEnd 0x3058 -#define GlintVTGVGateEndReg 1 -#define GlintVTGVGateEndOff 0x2058 -#define GlintVTGVGateEndSec 0x3058 -#define GlintVTGVGateEndSecReg 3 -#define GlintVTGVGateEndSecOff 0x2058 - -#define GlintVTGPolarity 0x3060 -#define GlintVTGPolarityReg 1 -#define GlintVTGPolarityOff 0x2060 -#define GlintVTGPolaritySec 0x3060 -#define GlintVTGPolaritySecReg 3 -#define GlintVTGPolaritySecOff 0x2060 - -#define GlintVTGFrameRowAddr 0x3068 -#define GlintVTGFrameRowAddrReg 1 -#define GlintVTGFrameRowAddrOff 0x2068 -#define GlintVTGFrameRowAddrSec 0x3068 -#define GlintVTGFrameRowAddrSecReg 3 -#define GlintVTGFrameRowAddrSecOff 0x2068 - -#define GlintVTGVLineNumber 0x3070 -#define GlintVTGVLineNumberReg 1 -#define GlintVTGVLineNumberOff 0x2070 -#define GlintVTGVLineNumberSec 0x3070 -#define GlintVTGVLineNumberSecReg 3 -#define GlintVTGVLineNumberSecOff 0x2070 - -#define GlintVTGSerialClk 0x3078 -#define GlintVTGSerialClkReg 1 -#define GlintVTGSerialClkOff 0x2078 -#define GlintVTGSerialClkSec 0x3078 -#define GlintVTGSerialClkSecReg 3 -#define GlintVTGSerialClkSecOff 0x2078 - -#define GlintVTGModeCtl 0x3080 -#define GlintVTGModeCtlReg 1 -#define GlintVTGModeCtlOff 0x2080 -#define GlintVTGModeCtlSec 0x3080 -#define GlintVTGModeCtlSecReg 3 -#define GlintVTGModeCtlSecOff 0x2080 - -#define GlintOutputFIFO 0x2000 -#define GlintOutputFIFOReg 1 -#define GlintOutputFIFOOff 0x1000 -#define GlintOutputFIFOSec 0x2000 -#define GlintOutputFIFOSecReg 3 -#define GlintOutputFIFOSecOff 0x1000 - -#define GlintGInFIFOSpace 0x0018 -#define GlintGInFIFOSpaceReg 0 -#define GlintGInFIFOSpaceOff 0x0018 - -#define GlintGDMAAddress 0x0028 -#define GlintGDMAAddressReg 0 -#define GlintGDMAAddressOff 0x0028 - -#define GlintGDMACount 0x0030 -#define GlintGDMACountReg 0 -#define GlintGDMACountOff 0x0030 - -#define GlintGDMAControl 0x0060 -#define GlintGDMAControlReg 0 -#define GlintGDMAControlOff 0x0060 - -#define GlintGOutDMA 0x0080 -#define GlintGOutDMAReg 0 -#define GlintGOutDMAOff 0x0080 - -#define GlintGOutDMACount 0x0088 -#define GlintGOutDMACountReg 0 -#define GlintGOutDMACountOff 0x0088 - -#define GlintGResetStatus 0x0800 -#define GlintGResetStatusReg 0 -#define GlintGResetStatusOff 0x0800 - -#define GlintGIntEnable 0x0808 -#define GlintGIntEnableReg 0 -#define GlintGIntEnableOff 0x0808 - -#define GlintGIntFlags 0x0810 -#define GlintGIntFlagsReg 0 -#define GlintGIntFlagsOff 0x0810 - -#define GlintGErrorFlags 0x0838 -#define GlintGErrorFlagsReg 0 -#define GlintGErrorFlagsOff 0x0838 - -#define GlintGTestRegister 0x0848 -#define GlintGTestRegisterReg 0 -#define GlintGTestRegisterOff 0x0848 - -#define GlintGFIFODis 0x0868 -#define GlintGFIFODisReg 0 -#define GlintGFIFODisOff 0x0868 - -#define GlintGChipConfig 0x0870 -#define GlintGChipConfigReg 0 -#define GlintGChipConfigOff 0x0870 - -#define GlintGCSRAperture 0x0878 -#define GlintGCSRApertureReg 0 -#define GlintGCSRApertureOff 0x0878 - -#define GlintGPageTableAddr 0x0c00 -#define GlintGPageTableAddrReg 0 -#define GlintGPageTableAddrOff 0x0c00 - -#define GlintGPageTableLength 0x0c08 -#define GlintGPageTableLengthReg 0 -#define GlintGPageTableLengthOff 0x0c08 - -#define GlintGDelayTimer 0x0c38 -#define GlintGDelayTimerReg 0 -#define GlintGDelayTimerOff 0x0c38 - -#define GlintGCommandMode 0x0c40 -#define GlintGCommandModeReg 0 -#define GlintGCommandModeOff 0x0c40 - -#define GlintGCommandIntEnable 0x0c48 -#define GlintGCommandIntEnableReg 0 -#define GlintGCommandIntEnableOff 0x0c48 - -#define GlintGCommandIntFlags 0x0c50 -#define GlintGCommandIntFlagsReg 0 -#define GlintGCommandIntFlagsOff 0x0c50 - -#define GlintGCommandErrorFlags 0x0c58 -#define GlintGCommandErrorFlagsReg 0 -#define GlintGCommandErrorFlagsOff 0x0c58 - -#define GlintGCommandStatus 0x0c60 -#define GlintGCommandStatusReg 0 -#define GlintGCommandStatusOff 0x0c60 - -#define GlintGCommandFaultingAddr 0x0c68 -#define GlintGCommandFaultingAddrReg 0 -#define GlintGCommandFaultingAddrOff 0x0c68 - -#define GlintGVertexFaultingAddr 0x0c70 -#define GlintGVertexFaultingAddrReg 0 -#define GlintGVertexFaultingAddrOff 0x0c70 - -#define GlintGWriteFaultingAddr 0x0c88 -#define GlintGWriteFaultingAddrReg 0 -#define GlintGWriteFaultingAddrOff 0x0c88 - -#define GlintGFeedbackSelectCount 0x0c98 -#define GlintGFeedbackSelectCountReg 0 -#define GlintGFeedbackSelectCountOff 0x0c98 - -#define GlintGGammaProcessorMode 0x0cb8 -#define GlintGGammaProcessorModeReg 0 -#define GlintGGammaProcessorModeOff 0x0cb8 - -#define GlintGVGAShadow 0x0d00 -#define GlintGVGAShadowReg 0 -#define GlintGVGAShadowOff 0x0d00 - -#define GlintGMultGLINTAperture 0x0d08 -#define GlintGMultGLINTApertureReg 0 -#define GlintGMultGLINTApertureOff 0x0d08 - -#define GlintGMultGLINT1 0x0d10 -#define GlintGMultGLINT1Reg 0 -#define GlintGMultGLINT1Off 0x0d10 - -#define GlintGMultGLINT2 0x0d18 -#define GlintGMultGLINT2Reg 0 -#define GlintGMultGLINT2Off 0x0d18 - -#define GlintStartXDom 0x8000 -#define GlintStartXDomTag 0x0000 -#define GlintStartXDomReg 1 -#define GlintStartXDomOff 0x7000 -#define GlintStartXDomSec 0x8000 -#define GlintStartXDomSecReg 3 -#define GlintStartXDomSecOff 0x7000 - -#define GlintdXDom 0x8008 -#define GlintdXDomTag 0x0001 -#define GlintdXDomReg 1 -#define GlintdXDomOff 0x7008 -#define GlintdXDomSec 0x8008 -#define GlintdXDomSecReg 3 -#define GlintdXDomSecOff 0x7008 - -#define GlintStartXSub 0x8010 -#define GlintStartXSubTag 0x0002 -#define GlintStartXSubReg 1 -#define GlintStartXSubOff 0x7010 -#define GlintStartXSubSec 0x8010 -#define GlintStartXSubSecReg 3 -#define GlintStartXSubSecOff 0x7010 - -#define GlintdXSub 0x8018 -#define GlintdXSubTag 0x0003 -#define GlintdXSubReg 1 -#define GlintdXSubOff 0x7018 -#define GlintdXSubSec 0x8018 -#define GlintdXSubSecReg 3 -#define GlintdXSubSecOff 0x7018 - -#define GlintStartY 0x8020 -#define GlintStartYTag 0x0004 -#define GlintStartYReg 1 -#define GlintStartYOff 0x7020 -#define GlintStartYSec 0x8020 -#define GlintStartYSecReg 3 -#define GlintStartYSecOff 0x7020 - -#define GlintdY 0x8028 -#define GlintdYTag 0x0005 -#define GlintdYReg 1 -#define GlintdYOff 0x7028 -#define GlintdYSec 0x8028 -#define GlintdYSecReg 3 -#define GlintdYSecOff 0x7028 - -#define GlintGLINTCount 0x8030 -#define GlintGLINTCountTag 0x0006 -#define GlintGLINTCountReg 1 -#define GlintGLINTCountOff 0x7030 -#define GlintGLINTCountSec 0x8030 -#define GlintGLINTCountSecReg 3 -#define GlintGLINTCountSecOff 0x7030 - -#define GlintRender 0x8038 -#define GlintRenderTag 0x0007 -#define GlintRenderReg 1 -#define GlintRenderOff 0x7038 -#define GlintRenderSec 0x8038 -#define GlintRenderSecReg 3 -#define GlintRenderSecOff 0x7038 - -#define GlintContinueNewLine 0x8040 -#define GlintContinueNewLineTag 0x0008 -#define GlintContinueNewLineReg 1 -#define GlintContinueNewLineOff 0x7040 -#define GlintContinueNewLineSec 0x8040 -#define GlintContinueNewLineSecReg 3 -#define GlintContinueNewLineSecOff 0x7040 - -#define GlintContinueNewDom 0x8048 -#define GlintContinueNewDomTag 0x0009 -#define GlintContinueNewDomReg 1 -#define GlintContinueNewDomOff 0x7048 -#define GlintContinueNewDomSec 0x8048 -#define GlintContinueNewDomSecReg 3 -#define GlintContinueNewDomSecOff 0x7048 - -#define GlintContinueNewSub 0x8050 -#define GlintContinueNewSubTag 0x000a -#define GlintContinueNewSubReg 1 -#define GlintContinueNewSubOff 0x7050 -#define GlintContinueNewSubSec 0x8050 -#define GlintContinueNewSubSecReg 3 -#define GlintContinueNewSubSecOff 0x7050 - -#define GlintContinue 0x8058 -#define GlintContinueTag 0x000b -#define GlintContinueReg 1 -#define GlintContinueOff 0x7058 -#define GlintContinueSec 0x8058 -#define GlintContinueSecReg 3 -#define GlintContinueSecOff 0x7058 - -#define GlintFlushSpan 0x8060 -#define GlintFlushSpanTag 0x000c -#define GlintFlushSpanReg 1 -#define GlintFlushSpanOff 0x7060 -#define GlintFlushSpanSec 0x8060 -#define GlintFlushSpanSecReg 3 -#define GlintFlushSpanSecOff 0x7060 - -#define GlintBitMaskPattern 0x8068 -#define GlintBitMaskPatternTag 0x000d -#define GlintBitMaskPatternReg 1 -#define GlintBitMaskPatternOff 0x7068 -#define GlintBitMaskPatternSec 0x8068 -#define GlintBitMaskPatternSecReg 3 -#define GlintBitMaskPatternSecOff 0x7068 - -#define GlintPointTable0 0x8080 -#define GlintPointTable0Tag 0x0010 -#define GlintPointTable0Reg 1 -#define GlintPointTable0Off 0x7080 -#define GlintPointTable0Sec 0x8080 -#define GlintPointTable0SecReg 3 -#define GlintPointTable0SecOff 0x7080 - -#define GlintPointTable1 0x8088 -#define GlintPointTable1Tag 0x0011 -#define GlintPointTable1Reg 1 -#define GlintPointTable1Off 0x7088 -#define GlintPointTable1Sec 0x8088 -#define GlintPointTable1SecReg 3 -#define GlintPointTable1SecOff 0x7088 - -#define GlintPointTable2 0x8090 -#define GlintPointTable2Tag 0x0012 -#define GlintPointTable2Reg 1 -#define GlintPointTable2Off 0x7090 -#define GlintPointTable2Sec 0x8090 -#define GlintPointTable2SecReg 3 -#define GlintPointTable2SecOff 0x7090 - -#define GlintPointTable3 0x8098 -#define GlintPointTable3Tag 0x0013 -#define GlintPointTable3Reg 1 -#define GlintPointTable3Off 0x7098 -#define GlintPointTable3Sec 0x8098 -#define GlintPointTable3SecReg 3 -#define GlintPointTable3SecOff 0x7098 - -#define GlintRasterizerMode 0x80a0 -#define GlintRasterizerModeTag 0x0014 -#define GlintRasterizerModeReg 1 -#define GlintRasterizerModeOff 0x70a0 -#define GlintRasterizerModeSec 0x80a0 -#define GlintRasterizerModeSecReg 3 -#define GlintRasterizerModeSecOff 0x70a0 - -#define GlintYLimits 0x80a8 -#define GlintYLimitsTag 0x0015 -#define GlintYLimitsReg 1 -#define GlintYLimitsOff 0x70a8 -#define GlintYLimitsSec 0x80a8 -#define GlintYLimitsSecReg 3 -#define GlintYLimitsSecOff 0x70a8 - -#define GlintScanLineOwnership 0x80b0 -#define GlintScanLineOwnershipTag 0x0016 -#define GlintScanLineOwnershipReg 1 -#define GlintScanLineOwnershipOff 0x70b0 -#define GlintScanLineOwnershipSec 0x80b0 -#define GlintScanLineOwnershipSecReg 3 -#define GlintScanLineOwnershipSecOff 0x70b0 - -#define GlintWaitForCompletion 0x80b8 -#define GlintWaitForCompletionTag 0x0017 -#define GlintWaitForCompletionReg 1 -#define GlintWaitForCompletionOff 0x70b8 -#define GlintWaitForCompletionSec 0x80b8 -#define GlintWaitForCompletionSecReg 3 -#define GlintWaitForCompletionSecOff 0x70b8 - -#define GlintPixelSize 0x80c0 -#define GlintPixelSizeTag 0x0018 -#define GlintPixelSizeReg 1 -#define GlintPixelSizeOff 0x70c0 -#define GlintPixelSizeSec 0x80c0 -#define GlintPixelSizeSecReg 3 -#define GlintPixelSizeSecOff 0x70c0 - -#define GlintScissorMode 0x8180 -#define GlintScissorModeTag 0x0030 -#define GlintScissorModeReg 1 -#define GlintScissorModeOff 0x7180 -#define GlintScissorModeSec 0x8180 -#define GlintScissorModeSecReg 3 -#define GlintScissorModeSecOff 0x7180 - -#define GlintScissorMinXY 0x8188 -#define GlintScissorMinXYTag 0x0031 -#define GlintScissorMinXYReg 1 -#define GlintScissorMinXYOff 0x7188 -#define GlintScissorMinXYSec 0x8188 -#define GlintScissorMinXYSecReg 3 -#define GlintScissorMinXYSecOff 0x7188 - -#define GlintScissorMaxXY 0x8190 -#define GlintScissorMaxXYTag 0x0032 -#define GlintScissorMaxXYReg 1 -#define GlintScissorMaxXYOff 0x7190 -#define GlintScissorMaxXYSec 0x8190 -#define GlintScissorMaxXYSecReg 3 -#define GlintScissorMaxXYSecOff 0x7190 - -#define GlintScreenSize 0x8198 -#define GlintScreenSizeTag 0x0033 -#define GlintScreenSizeReg 1 -#define GlintScreenSizeOff 0x7198 -#define GlintScreenSizeSec 0x8198 -#define GlintScreenSizeSecReg 3 -#define GlintScreenSizeSecOff 0x7198 - -#define GlintAreaStippleMode 0x81a0 -#define GlintAreaStippleModeTag 0x0034 -#define GlintAreaStippleModeReg 1 -#define GlintAreaStippleModeOff 0x71a0 -#define GlintAreaStippleModeSec 0x81a0 -#define GlintAreaStippleModeSecReg 3 -#define GlintAreaStippleModeSecOff 0x71a0 - -#define GlintLineStippleMode 0x81a8 -#define GlintLineStippleModeTag 0x0035 -#define GlintLineStippleModeReg 1 -#define GlintLineStippleModeOff 0x71a8 -#define GlintLineStippleModeSec 0x81a8 -#define GlintLineStippleModeSecReg 3 -#define GlintLineStippleModeSecOff 0x71a8 - -#define GlintLoadLineStippleCounters 0x81b0 -#define GlintLoadLineStippleCountersTag 0x0036 -#define GlintLoadLineStippleCountersReg 1 -#define GlintLoadLineStippleCountersOff 0x71b0 -#define GlintLoadLineStippleCountersSec 0x81b0 -#define GlintLoadLineStippleCountersSecReg 3 -#define GlintLoadLineStippleCountersSecOff 0x71b0 - -#define GlintUpdateLineStippleCounters 0x81b8 -#define GlintUpdateLineStippleCountersTag 0x0037 -#define GlintUpdateLineStippleCountersReg 1 -#define GlintUpdateLineStippleCountersOff 0x71b8 -#define GlintUpdateLineStippleCountersSec 0x81b8 -#define GlintUpdateLineStippleCountersSecReg 3 -#define GlintUpdateLineStippleCountersSecOff 0x71b8 - -#define GlintSaveLineStippleState 0x81c0 -#define GlintSaveLineStippleStateTag 0x0038 -#define GlintSaveLineStippleStateReg 1 -#define GlintSaveLineStippleStateOff 0x71c0 -#define GlintSaveLineStippleStateSec 0x81c0 -#define GlintSaveLineStippleStateSecReg 3 -#define GlintSaveLineStippleStateSecOff 0x71c0 - -#define GlintWindowOrigin 0x81c8 -#define GlintWindowOriginTag 0x0039 -#define GlintWindowOriginReg 1 -#define GlintWindowOriginOff 0x71c8 -#define GlintWindowOriginSec 0x81c8 -#define GlintWindowOriginSecReg 3 -#define GlintWindowOriginSecOff 0x71c8 - -#define GlintAreaStipplePattern0 0x8200 -#define GlintAreaStipplePattern0Tag 0x0040 -#define GlintAreaStipplePattern0Reg 1 -#define GlintAreaStipplePattern0Off 0x7200 -#define GlintAreaStipplePattern0Sec 0x8200 -#define GlintAreaStipplePattern0SecReg 3 -#define GlintAreaStipplePattern0SecOff 0x7200 - -#define GlintAreaStipplePattern1 0x8208 -#define GlintAreaStipplePattern1Tag 0x0041 -#define GlintAreaStipplePattern1Reg 1 -#define GlintAreaStipplePattern1Off 0x7208 -#define GlintAreaStipplePattern1Sec 0x8208 -#define GlintAreaStipplePattern1SecReg 3 -#define GlintAreaStipplePattern1SecOff 0x7208 - -#define GlintAreaStipplePattern2 0x8210 -#define GlintAreaStipplePattern2Tag 0x0042 -#define GlintAreaStipplePattern2Reg 1 -#define GlintAreaStipplePattern2Off 0x7210 -#define GlintAreaStipplePattern2Sec 0x8210 -#define GlintAreaStipplePattern2SecReg 3 -#define GlintAreaStipplePattern2SecOff 0x7210 - -#define GlintAreaStipplePattern3 0x8218 -#define GlintAreaStipplePattern3Tag 0x0043 -#define GlintAreaStipplePattern3Reg 1 -#define GlintAreaStipplePattern3Off 0x7218 -#define GlintAreaStipplePattern3Sec 0x8218 -#define GlintAreaStipplePattern3SecReg 3 -#define GlintAreaStipplePattern3SecOff 0x7218 - -#define GlintAreaStipplePattern4 0x8220 -#define GlintAreaStipplePattern4Tag 0x0044 -#define GlintAreaStipplePattern4Reg 1 -#define GlintAreaStipplePattern4Off 0x7220 -#define GlintAreaStipplePattern4Sec 0x8220 -#define GlintAreaStipplePattern4SecReg 3 -#define GlintAreaStipplePattern4SecOff 0x7220 - -#define GlintAreaStipplePattern5 0x8228 -#define GlintAreaStipplePattern5Tag 0x0045 -#define GlintAreaStipplePattern5Reg 1 -#define GlintAreaStipplePattern5Off 0x7228 -#define GlintAreaStipplePattern5Sec 0x8228 -#define GlintAreaStipplePattern5SecReg 3 -#define GlintAreaStipplePattern5SecOff 0x7228 - -#define GlintAreaStipplePattern6 0x8230 -#define GlintAreaStipplePattern6Tag 0x0046 -#define GlintAreaStipplePattern6Reg 1 -#define GlintAreaStipplePattern6Off 0x7230 -#define GlintAreaStipplePattern6Sec 0x8230 -#define GlintAreaStipplePattern6SecReg 3 -#define GlintAreaStipplePattern6SecOff 0x7230 - -#define GlintAreaStipplePattern7 0x8238 -#define GlintAreaStipplePattern7Tag 0x0047 -#define GlintAreaStipplePattern7Reg 1 -#define GlintAreaStipplePattern7Off 0x7238 -#define GlintAreaStipplePattern7Sec 0x8238 -#define GlintAreaStipplePattern7SecReg 3 -#define GlintAreaStipplePattern7SecOff 0x7238 - -#define GlintAreaStipplePattern8 0x8240 -#define GlintAreaStipplePattern8Tag 0x0048 -#define GlintAreaStipplePattern8Reg 1 -#define GlintAreaStipplePattern8Off 0x7240 -#define GlintAreaStipplePattern8Sec 0x8240 -#define GlintAreaStipplePattern8SecReg 3 -#define GlintAreaStipplePattern8SecOff 0x7240 - -#define GlintAreaStipplePattern9 0x8248 -#define GlintAreaStipplePattern9Tag 0x0049 -#define GlintAreaStipplePattern9Reg 1 -#define GlintAreaStipplePattern9Off 0x7248 -#define GlintAreaStipplePattern9Sec 0x8248 -#define GlintAreaStipplePattern9SecReg 3 -#define GlintAreaStipplePattern9SecOff 0x7248 - -#define GlintAreaStipplePattern10 0x8250 -#define GlintAreaStipplePattern10Tag 0x004a -#define GlintAreaStipplePattern10Reg 1 -#define GlintAreaStipplePattern10Off 0x7250 -#define GlintAreaStipplePattern10Sec 0x8250 -#define GlintAreaStipplePattern10SecReg 3 -#define GlintAreaStipplePattern10SecOff 0x7250 - -#define GlintAreaStipplePattern11 0x8258 -#define GlintAreaStipplePattern11Tag 0x004b -#define GlintAreaStipplePattern11Reg 1 -#define GlintAreaStipplePattern11Off 0x7258 -#define GlintAreaStipplePattern11Sec 0x8258 -#define GlintAreaStipplePattern11SecReg 3 -#define GlintAreaStipplePattern11SecOff 0x7258 - -#define GlintAreaStipplePattern12 0x8260 -#define GlintAreaStipplePattern12Tag 0x004c -#define GlintAreaStipplePattern12Reg 1 -#define GlintAreaStipplePattern12Off 0x7260 -#define GlintAreaStipplePattern12Sec 0x8260 -#define GlintAreaStipplePattern12SecReg 3 -#define GlintAreaStipplePattern12SecOff 0x7260 - -#define GlintAreaStipplePattern13 0x8268 -#define GlintAreaStipplePattern13Tag 0x004d -#define GlintAreaStipplePattern13Reg 1 -#define GlintAreaStipplePattern13Off 0x7268 -#define GlintAreaStipplePattern13Sec 0x8268 -#define GlintAreaStipplePattern13SecReg 3 -#define GlintAreaStipplePattern13SecOff 0x7268 - -#define GlintAreaStipplePattern14 0x8270 -#define GlintAreaStipplePattern14Tag 0x004e -#define GlintAreaStipplePattern14Reg 1 -#define GlintAreaStipplePattern14Off 0x7270 -#define GlintAreaStipplePattern14Sec 0x8270 -#define GlintAreaStipplePattern14SecReg 3 -#define GlintAreaStipplePattern14SecOff 0x7270 - -#define GlintAreaStipplePattern15 0x8278 -#define GlintAreaStipplePattern15Tag 0x004f -#define GlintAreaStipplePattern15Reg 1 -#define GlintAreaStipplePattern15Off 0x7278 -#define GlintAreaStipplePattern15Sec 0x8278 -#define GlintAreaStipplePattern15SecReg 3 -#define GlintAreaStipplePattern15SecOff 0x7278 - -#define GlintAreaStipplePattern16 0x8280 -#define GlintAreaStipplePattern16Tag 0x0050 -#define GlintAreaStipplePattern16Reg 1 -#define GlintAreaStipplePattern16Off 0x7280 -#define GlintAreaStipplePattern16Sec 0x8280 -#define GlintAreaStipplePattern16SecReg 3 -#define GlintAreaStipplePattern16SecOff 0x7280 - -#define GlintAreaStipplePattern17 0x8288 -#define GlintAreaStipplePattern17Tag 0x0051 -#define GlintAreaStipplePattern17Reg 1 -#define GlintAreaStipplePattern17Off 0x7288 -#define GlintAreaStipplePattern17Sec 0x8288 -#define GlintAreaStipplePattern17SecReg 3 -#define GlintAreaStipplePattern17SecOff 0x7288 - -#define GlintAreaStipplePattern18 0x8290 -#define GlintAreaStipplePattern18Tag 0x0052 -#define GlintAreaStipplePattern18Reg 1 -#define GlintAreaStipplePattern18Off 0x7290 -#define GlintAreaStipplePattern18Sec 0x8290 -#define GlintAreaStipplePattern18SecReg 3 -#define GlintAreaStipplePattern18SecOff 0x7290 - -#define GlintAreaStipplePattern19 0x8298 -#define GlintAreaStipplePattern19Tag 0x0053 -#define GlintAreaStipplePattern19Reg 1 -#define GlintAreaStipplePattern19Off 0x7298 -#define GlintAreaStipplePattern19Sec 0x8298 -#define GlintAreaStipplePattern19SecReg 3 -#define GlintAreaStipplePattern19SecOff 0x7298 - -#define GlintAreaStipplePattern20 0x82a0 -#define GlintAreaStipplePattern20Tag 0x0054 -#define GlintAreaStipplePattern20Reg 1 -#define GlintAreaStipplePattern20Off 0x72a0 -#define GlintAreaStipplePattern20Sec 0x82a0 -#define GlintAreaStipplePattern20SecReg 3 -#define GlintAreaStipplePattern20SecOff 0x72a0 - -#define GlintAreaStipplePattern21 0x82a8 -#define GlintAreaStipplePattern21Tag 0x0055 -#define GlintAreaStipplePattern21Reg 1 -#define GlintAreaStipplePattern21Off 0x72a8 -#define GlintAreaStipplePattern21Sec 0x82a8 -#define GlintAreaStipplePattern21SecReg 3 -#define GlintAreaStipplePattern21SecOff 0x72a8 - -#define GlintAreaStipplePattern22 0x82b0 -#define GlintAreaStipplePattern22Tag 0x0056 -#define GlintAreaStipplePattern22Reg 1 -#define GlintAreaStipplePattern22Off 0x72b0 -#define GlintAreaStipplePattern22Sec 0x82b0 -#define GlintAreaStipplePattern22SecReg 3 -#define GlintAreaStipplePattern22SecOff 0x72b0 - -#define GlintAreaStipplePattern23 0x82b8 -#define GlintAreaStipplePattern23Tag 0x0057 -#define GlintAreaStipplePattern23Reg 1 -#define GlintAreaStipplePattern23Off 0x72b8 -#define GlintAreaStipplePattern23Sec 0x82b8 -#define GlintAreaStipplePattern23SecReg 3 -#define GlintAreaStipplePattern23SecOff 0x72b8 - -#define GlintAreaStipplePattern24 0x82c0 -#define GlintAreaStipplePattern24Tag 0x0058 -#define GlintAreaStipplePattern24Reg 1 -#define GlintAreaStipplePattern24Off 0x72c0 -#define GlintAreaStipplePattern24Sec 0x82c0 -#define GlintAreaStipplePattern24SecReg 3 -#define GlintAreaStipplePattern24SecOff 0x72c0 - -#define GlintAreaStipplePattern25 0x82c8 -#define GlintAreaStipplePattern25Tag 0x0059 -#define GlintAreaStipplePattern25Reg 1 -#define GlintAreaStipplePattern25Off 0x72c8 -#define GlintAreaStipplePattern25Sec 0x82c8 -#define GlintAreaStipplePattern25SecReg 3 -#define GlintAreaStipplePattern25SecOff 0x72c8 - -#define GlintAreaStipplePattern26 0x82d0 -#define GlintAreaStipplePattern26Tag 0x005a -#define GlintAreaStipplePattern26Reg 1 -#define GlintAreaStipplePattern26Off 0x72d0 -#define GlintAreaStipplePattern26Sec 0x82d0 -#define GlintAreaStipplePattern26SecReg 3 -#define GlintAreaStipplePattern26SecOff 0x72d0 - -#define GlintAreaStipplePattern27 0x82d8 -#define GlintAreaStipplePattern27Tag 0x005b -#define GlintAreaStipplePattern27Reg 1 -#define GlintAreaStipplePattern27Off 0x72d8 -#define GlintAreaStipplePattern27Sec 0x82d8 -#define GlintAreaStipplePattern27SecReg 3 -#define GlintAreaStipplePattern27SecOff 0x72d8 - -#define GlintAreaStipplePattern28 0x82e0 -#define GlintAreaStipplePattern28Tag 0x005c -#define GlintAreaStipplePattern28Reg 1 -#define GlintAreaStipplePattern28Off 0x72e0 -#define GlintAreaStipplePattern28Sec 0x82e0 -#define GlintAreaStipplePattern28SecReg 3 -#define GlintAreaStipplePattern28SecOff 0x72e0 - -#define GlintAreaStipplePattern29 0x82e8 -#define GlintAreaStipplePattern29Tag 0x005d -#define GlintAreaStipplePattern29Reg 1 -#define GlintAreaStipplePattern29Off 0x72e8 -#define GlintAreaStipplePattern29Sec 0x82e8 -#define GlintAreaStipplePattern29SecReg 3 -#define GlintAreaStipplePattern29SecOff 0x72e8 - -#define GlintAreaStipplePattern30 0x82f0 -#define GlintAreaStipplePattern30Tag 0x005e -#define GlintAreaStipplePattern30Reg 1 -#define GlintAreaStipplePattern30Off 0x72f0 -#define GlintAreaStipplePattern30Sec 0x82f0 -#define GlintAreaStipplePattern30SecReg 3 -#define GlintAreaStipplePattern30SecOff 0x72f0 - -#define GlintAreaStipplePattern31 0x82f8 -#define GlintAreaStipplePattern31Tag 0x005f -#define GlintAreaStipplePattern31Reg 1 -#define GlintAreaStipplePattern31Off 0x72f8 -#define GlintAreaStipplePattern31Sec 0x82f8 -#define GlintAreaStipplePattern31SecReg 3 -#define GlintAreaStipplePattern31SecOff 0x72f8 - -#define GlintRouterMode 0x8840 -#define GlintRouterModeTag 0x0108 -#define GlintRouterModeReg 1 -#define GlintRouterModeOff 0x7840 -#define GlintRouterModeSec 0x8840 -#define GlintRouterModeSecReg 3 -#define GlintRouterModeSecOff 0x7840 - -#define GlintTextureAddressMode 0x8380 -#define GlintTextureAddressModeTag 0x0070 -#define GlintTextureAddressModeReg 1 -#define GlintTextureAddressModeOff 0x7380 -#define GlintTextureAddressModeSec 0x8380 -#define GlintTextureAddressModeSecReg 3 -#define GlintTextureAddressModeSecOff 0x7380 - -#define GlintSStart 0x8388 -#define GlintSStartTag 0x0071 -#define GlintSStartReg 1 -#define GlintSStartOff 0x7388 -#define GlintSStartSec 0x8388 -#define GlintSStartSecReg 3 -#define GlintSStartSecOff 0x7388 - -#define GlintdSdx 0x8390 -#define GlintdSdxTag 0x0072 -#define GlintdSdxReg 1 -#define GlintdSdxOff 0x7390 -#define GlintdSdxSec 0x8390 -#define GlintdSdxSecReg 3 -#define GlintdSdxSecOff 0x7390 - -#define GlintdSdyDom 0x8398 -#define GlintdSdyDomTag 0x0073 -#define GlintdSdyDomReg 1 -#define GlintdSdyDomOff 0x7398 -#define GlintdSdyDomSec 0x8398 -#define GlintdSdyDomSecReg 3 -#define GlintdSdyDomSecOff 0x7398 - -#define GlintTStart 0x83a0 -#define GlintTStartTag 0x0074 -#define GlintTStartReg 1 -#define GlintTStartOff 0x73a0 -#define GlintTStartSec 0x83a0 -#define GlintTStartSecReg 3 -#define GlintTStartSecOff 0x73a0 - -#define GlintdTdx 0x83a8 -#define GlintdTdxTag 0x0075 -#define GlintdTdxReg 1 -#define GlintdTdxOff 0x73a8 -#define GlintdTdxSec 0x83a8 -#define GlintdTdxSecReg 3 -#define GlintdTdxSecOff 0x73a8 - -#define GlintdTdyDom 0x83b0 -#define GlintdTdyDomTag 0x0076 -#define GlintdTdyDomReg 1 -#define GlintdTdyDomOff 0x73b0 -#define GlintdTdyDomSec 0x83b0 -#define GlintdTdyDomSecReg 3 -#define GlintdTdyDomSecOff 0x73b0 - -#define GlintQStart 0x83b8 -#define GlintQStartTag 0x0077 -#define GlintQStartReg 1 -#define GlintQStartOff 0x73b8 -#define GlintQStartSec 0x83b8 -#define GlintQStartSecReg 3 -#define GlintQStartSecOff 0x73b8 - -#define GlintdQdx 0x83c0 -#define GlintdQdxTag 0x0078 -#define GlintdQdxReg 1 -#define GlintdQdxOff 0x73c0 -#define GlintdQdxSec 0x83c0 -#define GlintdQdxSecReg 3 -#define GlintdQdxSecOff 0x73c0 - -#define GlintdQdyDom 0x83c8 -#define GlintdQdyDomTag 0x0079 -#define GlintdQdyDomReg 1 -#define GlintdQdyDomOff 0x73c8 -#define GlintdQdyDomSec 0x83c8 -#define GlintdQdyDomSecReg 3 -#define GlintdQdyDomSecOff 0x73c8 - -#define GlintLOD 0x83d0 -#define GlintLODTag 0x007a -#define GlintLODReg 1 -#define GlintLODOff 0x73d0 -#define GlintLODSec 0x83d0 -#define GlintLODSecReg 3 -#define GlintLODSecOff 0x73d0 - -#define GlintdSdy 0x83d8 -#define GlintdSdyTag 0x007b -#define GlintdSdyReg 1 -#define GlintdSdyOff 0x73d8 -#define GlintdSdySec 0x83d8 -#define GlintdSdySecReg 3 -#define GlintdSdySecOff 0x73d8 - -#define GlintdTdy 0x83e0 -#define GlintdTdyTag 0x007c -#define GlintdTdyReg 1 -#define GlintdTdyOff 0x73e0 -#define GlintdTdySec 0x83e0 -#define GlintdTdySecReg 3 -#define GlintdTdySecOff 0x73e0 - -#define GlintdQdy 0x83e8 -#define GlintdQdyTag 0x007d -#define GlintdQdyReg 1 -#define GlintdQdyOff 0x73e8 -#define GlintdQdySec 0x83e8 -#define GlintdQdySecReg 3 -#define GlintdQdySecOff 0x73e8 - -#define GlintTextureReadMode 0x8480 -#define GlintTextureReadModeTag 0x0090 -#define GlintTextureReadModeReg 1 -#define GlintTextureReadModeOff 0x7480 -#define GlintTextureReadModeSec 0x8480 -#define GlintTextureReadModeSecReg 3 -#define GlintTextureReadModeSecOff 0x7480 - -#define GlintTextureFormat 0x8488 -#define GlintTextureFormatTag 0x0091 -#define GlintTextureFormatReg 1 -#define GlintTextureFormatOff 0x7488 -#define GlintTextureFormatSec 0x8488 -#define GlintTextureFormatSecReg 3 -#define GlintTextureFormatSecOff 0x7488 - -#define GlintTextureCacheControl 0x8490 -#define GlintTextureCacheControlTag 0x0092 -#define GlintTextureCacheControlReg 1 -#define GlintTextureCacheControlOff 0x7490 -#define GlintTextureCacheControlSec 0x8490 -#define GlintTextureCacheControlSecReg 3 -#define GlintTextureCacheControlSecOff 0x7490 - -#define GlintGLINTBorderColor 0x84a8 -#define GlintGLINTBorderColorTag 0x0095 -#define GlintGLINTBorderColorReg 1 -#define GlintGLINTBorderColorOff 0x74a8 -#define GlintGLINTBorderColorSec 0x84a8 -#define GlintGLINTBorderColorSecReg 3 -#define GlintGLINTBorderColorSecOff 0x74a8 - -#define GlintTexelLUTIndex 0x84c0 -#define GlintTexelLUTIndexTag 0x0098 -#define GlintTexelLUTIndexReg 1 -#define GlintTexelLUTIndexOff 0x74c0 -#define GlintTexelLUTIndexSec 0x84c0 -#define GlintTexelLUTIndexSecReg 3 -#define GlintTexelLUTIndexSecOff 0x74c0 - -#define GlintTexelLUTData 0x84c8 -#define GlintTexelLUTDataTag 0x0099 -#define GlintTexelLUTDataReg 1 -#define GlintTexelLUTDataOff 0x74c8 -#define GlintTexelLUTDataSec 0x84c8 -#define GlintTexelLUTDataSecReg 3 -#define GlintTexelLUTDataSecOff 0x74c8 - -#define GlintTexelLUTAddress 0x84d0 -#define GlintTexelLUTAddressTag 0x009a -#define GlintTexelLUTAddressReg 1 -#define GlintTexelLUTAddressOff 0x74d0 -#define GlintTexelLUTAddressSec 0x84d0 -#define GlintTexelLUTAddressSecReg 3 -#define GlintTexelLUTAddressSecOff 0x74d0 - -#define GlintTexelLUTTransfer 0x84d8 -#define GlintTexelLUTTransferTag 0x009b -#define GlintTexelLUTTransferReg 1 -#define GlintTexelLUTTransferOff 0x74d8 -#define GlintTexelLUTTransferSec 0x84d8 -#define GlintTexelLUTTransferSecReg 3 -#define GlintTexelLUTTransferSecOff 0x74d8 - -#define GlintTextureFilterMode 0x84e0 -#define GlintTextureFilterModeTag 0x009c -#define GlintTextureFilterModeReg 1 -#define GlintTextureFilterModeOff 0x74e0 -#define GlintTextureFilterModeSec 0x84e0 -#define GlintTextureFilterModeSecReg 3 -#define GlintTextureFilterModeSecOff 0x74e0 - -#define GlintTextureChromaUpper 0x84e8 -#define GlintTextureChromaUpperTag 0x009d -#define GlintTextureChromaUpperReg 1 -#define GlintTextureChromaUpperOff 0x74e8 -#define GlintTextureChromaUpperSec 0x84e8 -#define GlintTextureChromaUpperSecReg 3 -#define GlintTextureChromaUpperSecOff 0x74e8 - -#define GlintTextureChromaLower 0x84f0 -#define GlintTextureChromaLowerTag 0x009e -#define GlintTextureChromaLowerReg 1 -#define GlintTextureChromaLowerOff 0x74f0 -#define GlintTextureChromaLowerSec 0x84f0 -#define GlintTextureChromaLowerSecReg 3 -#define GlintTextureChromaLowerSecOff 0x74f0 - -#define GlintTxBaseAddr0 0x8500 -#define GlintTxBaseAddr0Tag 0x00a0 -#define GlintTxBaseAddr0Reg 1 -#define GlintTxBaseAddr0Off 0x7500 -#define GlintTxBaseAddr0Sec 0x8500 -#define GlintTxBaseAddr0SecReg 3 -#define GlintTxBaseAddr0SecOff 0x7500 - -#define GlintTxBaseAddr1 0x8508 -#define GlintTxBaseAddr1Tag 0x00a1 -#define GlintTxBaseAddr1Reg 1 -#define GlintTxBaseAddr1Off 0x7508 -#define GlintTxBaseAddr1Sec 0x8508 -#define GlintTxBaseAddr1SecReg 3 -#define GlintTxBaseAddr1SecOff 0x7508 - -#define GlintTxBaseAddr2 0x8510 -#define GlintTxBaseAddr2Tag 0x00a2 -#define GlintTxBaseAddr2Reg 1 -#define GlintTxBaseAddr2Off 0x7510 -#define GlintTxBaseAddr2Sec 0x8510 -#define GlintTxBaseAddr2SecReg 3 -#define GlintTxBaseAddr2SecOff 0x7510 - -#define GlintTxBaseAddr3 0x8518 -#define GlintTxBaseAddr3Tag 0x00a3 -#define GlintTxBaseAddr3Reg 1 -#define GlintTxBaseAddr3Off 0x7518 -#define GlintTxBaseAddr3Sec 0x8518 -#define GlintTxBaseAddr3SecReg 3 -#define GlintTxBaseAddr3SecOff 0x7518 - -#define GlintTxBaseAddr4 0x8520 -#define GlintTxBaseAddr4Tag 0x00a4 -#define GlintTxBaseAddr4Reg 1 -#define GlintTxBaseAddr4Off 0x7520 -#define GlintTxBaseAddr4Sec 0x8520 -#define GlintTxBaseAddr4SecReg 3 -#define GlintTxBaseAddr4SecOff 0x7520 - -#define GlintTxBaseAddr5 0x8528 -#define GlintTxBaseAddr5Tag 0x00a5 -#define GlintTxBaseAddr5Reg 1 -#define GlintTxBaseAddr5Off 0x7528 -#define GlintTxBaseAddr5Sec 0x8528 -#define GlintTxBaseAddr5SecReg 3 -#define GlintTxBaseAddr5SecOff 0x7528 - -#define GlintTxBaseAddr6 0x8530 -#define GlintTxBaseAddr6Tag 0x00a6 -#define GlintTxBaseAddr6Reg 1 -#define GlintTxBaseAddr6Off 0x7530 -#define GlintTxBaseAddr6Sec 0x8530 -#define GlintTxBaseAddr6SecReg 3 -#define GlintTxBaseAddr6SecOff 0x7530 - -#define GlintTxBaseAddr7 0x8538 -#define GlintTxBaseAddr7Tag 0x00a7 -#define GlintTxBaseAddr7Reg 1 -#define GlintTxBaseAddr7Off 0x7538 -#define GlintTxBaseAddr7Sec 0x8538 -#define GlintTxBaseAddr7SecReg 3 -#define GlintTxBaseAddr7SecOff 0x7538 - -#define GlintTxBaseAddr8 0x8540 -#define GlintTxBaseAddr8Tag 0x00a8 -#define GlintTxBaseAddr8Reg 1 -#define GlintTxBaseAddr8Off 0x7540 -#define GlintTxBaseAddr8Sec 0x8540 -#define GlintTxBaseAddr8SecReg 3 -#define GlintTxBaseAddr8SecOff 0x7540 - -#define GlintTxBaseAddr9 0x8548 -#define GlintTxBaseAddr9Tag 0x00a9 -#define GlintTxBaseAddr9Reg 1 -#define GlintTxBaseAddr9Off 0x7548 -#define GlintTxBaseAddr9Sec 0x8548 -#define GlintTxBaseAddr9SecReg 3 -#define GlintTxBaseAddr9SecOff 0x7548 - -#define GlintTxBaseAddr10 0x8550 -#define GlintTxBaseAddr10Tag 0x00aa -#define GlintTxBaseAddr10Reg 1 -#define GlintTxBaseAddr10Off 0x7550 -#define GlintTxBaseAddr10Sec 0x8550 -#define GlintTxBaseAddr10SecReg 3 -#define GlintTxBaseAddr10SecOff 0x7550 - -#define GlintTxBaseAddr11 0x8558 -#define GlintTxBaseAddr11Tag 0x00ab -#define GlintTxBaseAddr11Reg 1 -#define GlintTxBaseAddr11Off 0x7558 -#define GlintTxBaseAddr11Sec 0x8558 -#define GlintTxBaseAddr11SecReg 3 -#define GlintTxBaseAddr11SecOff 0x7558 - -#define GlintTxBaseAddr12 0x8560 -#define GlintTxBaseAddr12Tag 0x00ac -#define GlintTxBaseAddr12Reg 1 -#define GlintTxBaseAddr12Off 0x7560 -#define GlintTxBaseAddr12Sec 0x8560 -#define GlintTxBaseAddr12SecReg 3 -#define GlintTxBaseAddr12SecOff 0x7560 - -#define GlintTexelLUT0 0x8e80 -#define GlintTexelLUT0Tag 0x01d0 -#define GlintTexelLUT0Reg 1 -#define GlintTexelLUT0Off 0x7e80 -#define GlintTexelLUT0Sec 0x8e80 -#define GlintTexelLUT0SecReg 3 -#define GlintTexelLUT0SecOff 0x7e80 - -#define GlintTexelLUT1 0x8e88 -#define GlintTexelLUT1Tag 0x01d1 -#define GlintTexelLUT1Reg 1 -#define GlintTexelLUT1Off 0x7e88 -#define GlintTexelLUT1Sec 0x8e88 -#define GlintTexelLUT1SecReg 3 -#define GlintTexelLUT1SecOff 0x7e88 - -#define GlintTexelLUT2 0x8e90 -#define GlintTexelLUT2Tag 0x01d2 -#define GlintTexelLUT2Reg 1 -#define GlintTexelLUT2Off 0x7e90 -#define GlintTexelLUT2Sec 0x8e90 -#define GlintTexelLUT2SecReg 3 -#define GlintTexelLUT2SecOff 0x7e90 - -#define GlintTexelLUT3 0x8e98 -#define GlintTexelLUT3Tag 0x01d3 -#define GlintTexelLUT3Reg 1 -#define GlintTexelLUT3Off 0x7e98 -#define GlintTexelLUT3Sec 0x8e98 -#define GlintTexelLUT3SecReg 3 -#define GlintTexelLUT3SecOff 0x7e98 - -#define GlintTexelLUT4 0x8ea0 -#define GlintTexelLUT4Tag 0x01d4 -#define GlintTexelLUT4Reg 1 -#define GlintTexelLUT4Off 0x7ea0 -#define GlintTexelLUT4Sec 0x8ea0 -#define GlintTexelLUT4SecReg 3 -#define GlintTexelLUT4SecOff 0x7ea0 - -#define GlintTexelLUT5 0x8ea8 -#define GlintTexelLUT5Tag 0x01d5 -#define GlintTexelLUT5Reg 1 -#define GlintTexelLUT5Off 0x7ea8 -#define GlintTexelLUT5Sec 0x8ea8 -#define GlintTexelLUT5SecReg 3 -#define GlintTexelLUT5SecOff 0x7ea8 - -#define GlintTexelLUT6 0x8eb0 -#define GlintTexelLUT6Tag 0x01d6 -#define GlintTexelLUT6Reg 1 -#define GlintTexelLUT6Off 0x7eb0 -#define GlintTexelLUT6Sec 0x8eb0 -#define GlintTexelLUT6SecReg 3 -#define GlintTexelLUT6SecOff 0x7eb0 - -#define GlintTexelLUT7 0x8eb8 -#define GlintTexelLUT7Tag 0x01d7 -#define GlintTexelLUT7Reg 1 -#define GlintTexelLUT7Off 0x7eb8 -#define GlintTexelLUT7Sec 0x8eb8 -#define GlintTexelLUT7SecReg 3 -#define GlintTexelLUT7SecOff 0x7eb8 - -#define GlintTexelLUT8 0x8ec0 -#define GlintTexelLUT8Tag 0x01d8 -#define GlintTexelLUT8Reg 1 -#define GlintTexelLUT8Off 0x7ec0 -#define GlintTexelLUT8Sec 0x8ec0 -#define GlintTexelLUT8SecReg 3 -#define GlintTexelLUT8SecOff 0x7ec0 - -#define GlintTexelLUT9 0x8ec8 -#define GlintTexelLUT9Tag 0x01d9 -#define GlintTexelLUT9Reg 1 -#define GlintTexelLUT9Off 0x7ec8 -#define GlintTexelLUT9Sec 0x8ec8 -#define GlintTexelLUT9SecReg 3 -#define GlintTexelLUT9SecOff 0x7ec8 - -#define GlintTexelLUT10 0x8ed0 -#define GlintTexelLUT10Tag 0x01da -#define GlintTexelLUT10Reg 1 -#define GlintTexelLUT10Off 0x7ed0 -#define GlintTexelLUT10Sec 0x8ed0 -#define GlintTexelLUT10SecReg 3 -#define GlintTexelLUT10SecOff 0x7ed0 - -#define GlintTexelLUT11 0x8ed8 -#define GlintTexelLUT11Tag 0x01db -#define GlintTexelLUT11Reg 1 -#define GlintTexelLUT11Off 0x7ed8 -#define GlintTexelLUT11Sec 0x8ed8 -#define GlintTexelLUT11SecReg 3 -#define GlintTexelLUT11SecOff 0x7ed8 - -#define GlintTexelLUT12 0x8ee0 -#define GlintTexelLUT12Tag 0x01dc -#define GlintTexelLUT12Reg 1 -#define GlintTexelLUT12Off 0x7ee0 -#define GlintTexelLUT12Sec 0x8ee0 -#define GlintTexelLUT12SecReg 3 -#define GlintTexelLUT12SecOff 0x7ee0 - -#define GlintTexelLUT13 0x8ee8 -#define GlintTexelLUT13Tag 0x01dd -#define GlintTexelLUT13Reg 1 -#define GlintTexelLUT13Off 0x7ee8 -#define GlintTexelLUT13Sec 0x8ee8 -#define GlintTexelLUT13SecReg 3 -#define GlintTexelLUT13SecOff 0x7ee8 - -#define GlintTexelLUT14 0x8ef0 -#define GlintTexelLUT14Tag 0x01de -#define GlintTexelLUT14Reg 1 -#define GlintTexelLUT14Off 0x7ef0 -#define GlintTexelLUT14Sec 0x8ef0 -#define GlintTexelLUT14SecReg 3 -#define GlintTexelLUT14SecOff 0x7ef0 - -#define GlintTexelLUT15 0x8ef8 -#define GlintTexelLUT15Tag 0x01df -#define GlintTexelLUT15Reg 1 -#define GlintTexelLUT15Off 0x7ef8 -#define GlintTexelLUT15Sec 0x8ef8 -#define GlintTexelLUT15SecReg 3 -#define GlintTexelLUT15SecOff 0x7ef8 - -#define GlintTexel0 0x8600 -#define GlintTexel0Tag 0x00c0 -#define GlintTexel0Reg 1 -#define GlintTexel0Off 0x7600 -#define GlintTexel0Sec 0x8600 -#define GlintTexel0SecReg 3 -#define GlintTexel0SecOff 0x7600 - -#define GlintTexel1 0x8608 -#define GlintTexel1Tag 0x00c1 -#define GlintTexel1Reg 1 -#define GlintTexel1Off 0x7608 -#define GlintTexel1Sec 0x8608 -#define GlintTexel1SecReg 3 -#define GlintTexel1SecOff 0x7608 - -#define GlintTexel2 0x8610 -#define GlintTexel2Tag 0x00c2 -#define GlintTexel2Reg 1 -#define GlintTexel2Off 0x7610 -#define GlintTexel2Sec 0x8610 -#define GlintTexel2SecReg 3 -#define GlintTexel2SecOff 0x7610 - -#define GlintTexel3 0x8618 -#define GlintTexel3Tag 0x00c3 -#define GlintTexel3Reg 1 -#define GlintTexel3Off 0x7618 -#define GlintTexel3Sec 0x8618 -#define GlintTexel3SecReg 3 -#define GlintTexel3SecOff 0x7618 - -#define GlintTexel4 0x8620 -#define GlintTexel4Tag 0x00c4 -#define GlintTexel4Reg 1 -#define GlintTexel4Off 0x7620 -#define GlintTexel4Sec 0x8620 -#define GlintTexel4SecReg 3 -#define GlintTexel4SecOff 0x7620 - -#define GlintTexel5 0x8628 -#define GlintTexel5Tag 0x00c5 -#define GlintTexel5Reg 1 -#define GlintTexel5Off 0x7628 -#define GlintTexel5Sec 0x8628 -#define GlintTexel5SecReg 3 -#define GlintTexel5SecOff 0x7628 - -#define GlintTexel6 0x8630 -#define GlintTexel6Tag 0x00c6 -#define GlintTexel6Reg 1 -#define GlintTexel6Off 0x7630 -#define GlintTexel6Sec 0x8630 -#define GlintTexel6SecReg 3 -#define GlintTexel6SecOff 0x7630 - -#define GlintTexel7 0x8638 -#define GlintTexel7Tag 0x00c7 -#define GlintTexel7Reg 1 -#define GlintTexel7Off 0x7638 -#define GlintTexel7Sec 0x8638 -#define GlintTexel7SecReg 3 -#define GlintTexel7SecOff 0x7638 - -#define GlintInterp0 0x8640 -#define GlintInterp0Tag 0x00c8 -#define GlintInterp0Reg 1 -#define GlintInterp0Off 0x7640 -#define GlintInterp0Sec 0x8640 -#define GlintInterp0SecReg 3 -#define GlintInterp0SecOff 0x7640 - -#define GlintInterp1 0x8648 -#define GlintInterp1Tag 0x00c9 -#define GlintInterp1Reg 1 -#define GlintInterp1Off 0x7648 -#define GlintInterp1Sec 0x8648 -#define GlintInterp1SecReg 3 -#define GlintInterp1SecOff 0x7648 - -#define GlintInterp2 0x8650 -#define GlintInterp2Tag 0x00ca -#define GlintInterp2Reg 1 -#define GlintInterp2Off 0x7650 -#define GlintInterp2Sec 0x8650 -#define GlintInterp2SecReg 3 -#define GlintInterp2SecOff 0x7650 - -#define GlintInterp3 0x8658 -#define GlintInterp3Tag 0x00cb -#define GlintInterp3Reg 1 -#define GlintInterp3Off 0x7658 -#define GlintInterp3Sec 0x8658 -#define GlintInterp3SecReg 3 -#define GlintInterp3SecOff 0x7658 - -#define GlintInterp4 0x8660 -#define GlintInterp4Tag 0x00cc -#define GlintInterp4Reg 1 -#define GlintInterp4Off 0x7660 -#define GlintInterp4Sec 0x8660 -#define GlintInterp4SecReg 3 -#define GlintInterp4SecOff 0x7660 - -#define GlintTextureFilter 0x8668 -#define GlintTextureFilterTag 0x00cd -#define GlintTextureFilterReg 1 -#define GlintTextureFilterOff 0x7668 -#define GlintTextureFilterSec 0x8668 -#define GlintTextureFilterSecReg 3 -#define GlintTextureFilterSecOff 0x7668 - -#define GlintTextureColorMode 0x8680 -#define GlintTextureColorModeTag 0x00d0 -#define GlintTextureColorModeReg 1 -#define GlintTextureColorModeOff 0x7680 -#define GlintTextureColorModeSec 0x8680 -#define GlintTextureColorModeSecReg 3 -#define GlintTextureColorModeSecOff 0x7680 - -#define GlintTextureEnvColor 0x8688 -#define GlintTextureEnvColorTag 0x00d1 -#define GlintTextureEnvColorReg 1 -#define GlintTextureEnvColorOff 0x7688 -#define GlintTextureEnvColorSec 0x8688 -#define GlintTextureEnvColorSecReg 3 -#define GlintTextureEnvColorSecOff 0x7688 - -#define GlintFogMode 0x8690 -#define GlintFogModeTag 0x00d2 -#define GlintFogModeReg 1 -#define GlintFogModeOff 0x7690 -#define GlintFogModeSec 0x8690 -#define GlintFogModeSecReg 3 -#define GlintFogModeSecOff 0x7690 - -#define GlintFogColor 0x8698 -#define GlintFogColorTag 0x00d3 -#define GlintFogColorReg 1 -#define GlintFogColorOff 0x7698 -#define GlintFogColorSec 0x8698 -#define GlintFogColorSecReg 3 -#define GlintFogColorSecOff 0x7698 - -#define GlintFStart 0x86a0 -#define GlintFStartTag 0x00d4 -#define GlintFStartReg 1 -#define GlintFStartOff 0x76a0 -#define GlintFStartSec 0x86a0 -#define GlintFStartSecReg 3 -#define GlintFStartSecOff 0x76a0 - -#define GlintdFdx 0x86a8 -#define GlintdFdxTag 0x00d5 -#define GlintdFdxReg 1 -#define GlintdFdxOff 0x76a8 -#define GlintdFdxSec 0x86a8 -#define GlintdFdxSecReg 3 -#define GlintdFdxSecOff 0x76a8 - -#define GlintdFdyDom 0x86b0 -#define GlintdFdyDomTag 0x00d6 -#define GlintdFdyDomReg 1 -#define GlintdFdyDomOff 0x76b0 -#define GlintdFdyDomSec 0x86b0 -#define GlintdFdyDomSecReg 3 -#define GlintdFdyDomSecOff 0x76b0 - -#define GlintKsStart 0x86c8 -#define GlintKsStartTag 0x00d9 -#define GlintKsStartReg 1 -#define GlintKsStartOff 0x76c8 -#define GlintKsStartSec 0x86c8 -#define GlintKsStartSecReg 3 -#define GlintKsStartSecOff 0x76c8 - -#define GlintdKsdx 0x86d0 -#define GlintdKsdxTag 0x00da -#define GlintdKsdxReg 1 -#define GlintdKsdxOff 0x76d0 -#define GlintdKsdxSec 0x86d0 -#define GlintdKsdxSecReg 3 -#define GlintdKsdxSecOff 0x76d0 - -#define GlintdKsdyDom 0x86d8 -#define GlintdKsdyDomTag 0x00db -#define GlintdKsdyDomReg 1 -#define GlintdKsdyDomOff 0x76d8 -#define GlintdKsdyDomSec 0x86d8 -#define GlintdKsdyDomSecReg 3 -#define GlintdKsdyDomSecOff 0x76d8 - -#define GlintKdStart 0x86e0 -#define GlintKdStartTag 0x00dc -#define GlintKdStartReg 1 -#define GlintKdStartOff 0x76e0 -#define GlintKdStartSec 0x86e0 -#define GlintKdStartSecReg 3 -#define GlintKdStartSecOff 0x76e0 - -#define GlintdKdStart 0x86e8 -#define GlintdKdStartTag 0x00dd -#define GlintdKdStartReg 1 -#define GlintdKdStartOff 0x76e8 -#define GlintdKdStartSec 0x86e8 -#define GlintdKdStartSecReg 3 -#define GlintdKdStartSecOff 0x76e8 - -#define GlintdKddyDom 0x86f0 -#define GlintdKddyDomTag 0x00de -#define GlintdKddyDomReg 1 -#define GlintdKddyDomOff 0x76f0 -#define GlintdKddyDomSec 0x86f0 -#define GlintdKddyDomSecReg 3 -#define GlintdKddyDomSecOff 0x76f0 - -#define GlintRStart 0x8780 -#define GlintRStartTag 0x00f0 -#define GlintRStartReg 1 -#define GlintRStartOff 0x7780 -#define GlintRStartSec 0x8780 -#define GlintRStartSecReg 3 -#define GlintRStartSecOff 0x7780 - -#define GlintdRdx 0x8788 -#define GlintdRdxTag 0x00f1 -#define GlintdRdxReg 1 -#define GlintdRdxOff 0x7788 -#define GlintdRdxSec 0x8788 -#define GlintdRdxSecReg 3 -#define GlintdRdxSecOff 0x7788 - -#define GlintdRdyDom 0x8790 -#define GlintdRdyDomTag 0x00f2 -#define GlintdRdyDomReg 1 -#define GlintdRdyDomOff 0x7790 -#define GlintdRdyDomSec 0x8790 -#define GlintdRdyDomSecReg 3 -#define GlintdRdyDomSecOff 0x7790 - -#define GlintGStart 0x8798 -#define GlintGStartTag 0x00f3 -#define GlintGStartReg 1 -#define GlintGStartOff 0x7798 -#define GlintGStartSec 0x8798 -#define GlintGStartSecReg 3 -#define GlintGStartSecOff 0x7798 - -#define GlintdGdx 0x87a0 -#define GlintdGdxTag 0x00f4 -#define GlintdGdxReg 1 -#define GlintdGdxOff 0x77a0 -#define GlintdGdxSec 0x87a0 -#define GlintdGdxSecReg 3 -#define GlintdGdxSecOff 0x77a0 - -#define GlintdGdyDom 0x87a8 -#define GlintdGdyDomTag 0x00f5 -#define GlintdGdyDomReg 1 -#define GlintdGdyDomOff 0x77a8 -#define GlintdGdyDomSec 0x87a8 -#define GlintdGdyDomSecReg 3 -#define GlintdGdyDomSecOff 0x77a8 - -#define GlintBStart 0x87b0 -#define GlintBStartTag 0x00f6 -#define GlintBStartReg 1 -#define GlintBStartOff 0x77b0 -#define GlintBStartSec 0x87b0 -#define GlintBStartSecReg 3 -#define GlintBStartSecOff 0x77b0 - -#define GlintdBdx 0x87b8 -#define GlintdBdxTag 0x00f7 -#define GlintdBdxReg 1 -#define GlintdBdxOff 0x77b8 -#define GlintdBdxSec 0x87b8 -#define GlintdBdxSecReg 3 -#define GlintdBdxSecOff 0x77b8 - -#define GlintdBdyDom 0x87c0 -#define GlintdBdyDomTag 0x00f8 -#define GlintdBdyDomReg 1 -#define GlintdBdyDomOff 0x77c0 -#define GlintdBdyDomSec 0x87c0 -#define GlintdBdyDomSecReg 3 -#define GlintdBdyDomSecOff 0x77c0 - -#define GlintAStart 0x87c8 -#define GlintAStartTag 0x00f9 -#define GlintAStartReg 1 -#define GlintAStartOff 0x77c8 -#define GlintAStartSec 0x87c8 -#define GlintAStartSecReg 3 -#define GlintAStartSecOff 0x77c8 - -#define GlintdAdx 0x87d0 -#define GlintdAdxTag 0x00fa -#define GlintdAdxReg 1 -#define GlintdAdxOff 0x77d0 -#define GlintdAdxSec 0x87d0 -#define GlintdAdxSecReg 3 -#define GlintdAdxSecOff 0x77d0 - -#define GlintdAdyDom 0x87d8 -#define GlintdAdyDomTag 0x00fb -#define GlintdAdyDomReg 1 -#define GlintdAdyDomOff 0x77d8 -#define GlintdAdyDomSec 0x87d8 -#define GlintdAdyDomSecReg 3 -#define GlintdAdyDomSecOff 0x77d8 - -#define GlintColorDDAMode 0x87e0 -#define GlintColorDDAModeTag 0x00fc -#define GlintColorDDAModeReg 1 -#define GlintColorDDAModeOff 0x77e0 -#define GlintColorDDAModeSec 0x87e0 -#define GlintColorDDAModeSecReg 3 -#define GlintColorDDAModeSecOff 0x77e0 - -#define GlintConstantColor 0x87e8 -#define GlintConstantColorTag 0x00fd -#define GlintConstantColorReg 1 -#define GlintConstantColorOff 0x77e8 -#define GlintConstantColorSec 0x87e8 -#define GlintConstantColorSecReg 3 -#define GlintConstantColorSecOff 0x77e8 - -#define GlintGLINTColor 0x87f0 -#define GlintGLINTColorTag 0x00fe -#define GlintGLINTColorReg 1 -#define GlintGLINTColorOff 0x77f0 -#define GlintGLINTColorSec 0x87f0 -#define GlintGLINTColorSecReg 3 -#define GlintGLINTColorSecOff 0x77f0 - -#define GlintAlphaTestMode 0x8800 -#define GlintAlphaTestModeTag 0x0100 -#define GlintAlphaTestModeReg 1 -#define GlintAlphaTestModeOff 0x7800 -#define GlintAlphaTestModeSec 0x8800 -#define GlintAlphaTestModeSecReg 3 -#define GlintAlphaTestModeSecOff 0x7800 - -#define GlintAntialiasMode 0x8808 -#define GlintAntialiasModeTag 0x0101 -#define GlintAntialiasModeReg 1 -#define GlintAntialiasModeOff 0x7808 -#define GlintAntialiasModeSec 0x8808 -#define GlintAntialiasModeSecReg 3 -#define GlintAntialiasModeSecOff 0x7808 - -#define GlintAlphaBlendMode 0x8810 -#define GlintAlphaBlendModeTag 0x0102 -#define GlintAlphaBlendModeReg 1 -#define GlintAlphaBlendModeOff 0x7810 -#define GlintAlphaBlendModeSec 0x8810 -#define GlintAlphaBlendModeSecReg 3 -#define GlintAlphaBlendModeSecOff 0x7810 - -#define GlintChromaUpper 0x8f08 -#define GlintChromaUpperTag 0x01e1 -#define GlintChromaUpperReg 1 -#define GlintChromaUpperOff 0x7f08 -#define GlintChromaUpperSec 0x8f08 -#define GlintChromaUpperSecReg 3 -#define GlintChromaUpperSecOff 0x7f08 - -#define GlintChromaLower 0x8f10 -#define GlintChromaLowerTag 0x01e2 -#define GlintChromaLowerReg 1 -#define GlintChromaLowerOff 0x7f10 -#define GlintChromaLowerSec 0x8f10 -#define GlintChromaLowerSecReg 3 -#define GlintChromaLowerSecOff 0x7f10 - -#define GlintChromaTestMode 0x8f18 -#define GlintChromaTestModeTag 0x01e3 -#define GlintChromaTestModeReg 1 -#define GlintChromaTestModeOff 0x7f18 -#define GlintChromaTestModeSec 0x8f18 -#define GlintChromaTestModeSecReg 3 -#define GlintChromaTestModeSecOff 0x7f18 - -#define GlintDitherMode 0x8818 -#define GlintDitherModeTag 0x0103 -#define GlintDitherModeReg 1 -#define GlintDitherModeOff 0x7818 -#define GlintDitherModeSec 0x8818 -#define GlintDitherModeSecReg 3 -#define GlintDitherModeSecOff 0x7818 - -#define GlintFBSoftwareWriteMask 0x8820 -#define GlintFBSoftwareWriteMaskTag 0x0104 -#define GlintFBSoftwareWriteMaskReg 1 -#define GlintFBSoftwareWriteMaskOff 0x7820 -#define GlintFBSoftwareWriteMaskSec 0x8820 -#define GlintFBSoftwareWriteMaskSecReg 3 -#define GlintFBSoftwareWriteMaskSecOff 0x7820 - -#define GlintLogicalOpMode 0x8828 -#define GlintLogicalOpModeTag 0x0105 -#define GlintLogicalOpModeReg 1 -#define GlintLogicalOpModeOff 0x7828 -#define GlintLogicalOpModeSec 0x8828 -#define GlintLogicalOpModeSecReg 3 -#define GlintLogicalOpModeSecOff 0x7828 - -#define GlintFBWriteData 0x8830 -#define GlintFBWriteDataTag 0x0106 -#define GlintFBWriteDataReg 1 -#define GlintFBWriteDataOff 0x7830 -#define GlintFBWriteDataSec 0x8830 -#define GlintFBWriteDataSecReg 3 -#define GlintFBWriteDataSecOff 0x7830 - -#define GlintLBReadMode 0x8880 -#define GlintLBReadModeTag 0x0110 -#define GlintLBReadModeReg 1 -#define GlintLBReadModeOff 0x7880 -#define GlintLBReadModeSec 0x8880 -#define GlintLBReadModeSecReg 3 -#define GlintLBReadModeSecOff 0x7880 - -#define GlintLBReadFormat 0x8888 -#define GlintLBReadFormatTag 0x0111 -#define GlintLBReadFormatReg 1 -#define GlintLBReadFormatOff 0x7888 -#define GlintLBReadFormatSec 0x8888 -#define GlintLBReadFormatSecReg 3 -#define GlintLBReadFormatSecOff 0x7888 - -#define GlintLBSourceOffset 0x8890 -#define GlintLBSourceOffsetTag 0x0112 -#define GlintLBSourceOffsetReg 1 -#define GlintLBSourceOffsetOff 0x7890 -#define GlintLBSourceOffsetSec 0x8890 -#define GlintLBSourceOffsetSecReg 3 -#define GlintLBSourceOffsetSecOff 0x7890 - -#define GlintLBStencil 0x88a8 -#define GlintLBStencilTag 0x0115 -#define GlintLBStencilReg 1 -#define GlintLBStencilOff 0x78a8 -#define GlintLBStencilSec 0x88a8 -#define GlintLBStencilSecReg 3 -#define GlintLBStencilSecOff 0x78a8 - -#define GlintLBDepth 0x88b0 -#define GlintLBDepthTag 0x0116 -#define GlintLBDepthReg 1 -#define GlintLBDepthOff 0x78b0 -#define GlintLBDepthSec 0x88b0 -#define GlintLBDepthSecReg 3 -#define GlintLBDepthSecOff 0x78b0 - -#define GlintLBWindowBase 0x88b8 -#define GlintLBWindowBaseTag 0x0117 -#define GlintLBWindowBaseReg 1 -#define GlintLBWindowBaseOff 0x78b8 -#define GlintLBWindowBaseSec 0x88b8 -#define GlintLBWindowBaseSecReg 3 -#define GlintLBWindowBaseSecOff 0x78b8 - -#define GlintLBWriteMode 0x88c0 -#define GlintLBWriteModeTag 0x0118 -#define GlintLBWriteModeReg 1 -#define GlintLBWriteModeOff 0x78c0 -#define GlintLBWriteModeSec 0x88c0 -#define GlintLBWriteModeSecReg 3 -#define GlintLBWriteModeSecOff 0x78c0 - -#define GlintLBWriteFormat 0x88c8 -#define GlintLBWriteFormatTag 0x0119 -#define GlintLBWriteFormatReg 1 -#define GlintLBWriteFormatOff 0x78c8 -#define GlintLBWriteFormatSec 0x88c8 -#define GlintLBWriteFormatSecReg 3 -#define GlintLBWriteFormatSecOff 0x78c8 - -#define GlintTextureData 0x88e8 -#define GlintTextureDataTag 0x011d -#define GlintTextureDataReg 1 -#define GlintTextureDataOff 0x78e8 -#define GlintTextureDataSec 0x88e8 -#define GlintTextureDataSecReg 3 -#define GlintTextureDataSecOff 0x78e8 - -#define GlintTextureDownloadOffset 0x88f0 -#define GlintTextureDownloadOffsetTag 0x011e -#define GlintTextureDownloadOffsetReg 1 -#define GlintTextureDownloadOffsetOff 0x78f0 -#define GlintTextureDownloadOffsetSec 0x88f0 -#define GlintTextureDownloadOffsetSecReg 3 -#define GlintTextureDownloadOffsetSecOff 0x78f0 - -#define GlintLBWindowOffset 0x88f8 -#define GlintLBWindowOffsetTag 0x011f -#define GlintLBWindowOffsetReg 1 -#define GlintLBWindowOffsetOff 0x78f8 -#define GlintLBWindowOffsetSec 0x88f8 -#define GlintLBWindowOffsetSecReg 3 -#define GlintLBWindowOffsetSecOff 0x78f8 - -#define GlintGLINTWindow 0x8980 -#define GlintGLINTWindowTag 0x0130 -#define GlintGLINTWindowReg 1 -#define GlintGLINTWindowOff 0x7980 -#define GlintGLINTWindowSec 0x8980 -#define GlintGLINTWindowSecReg 3 -#define GlintGLINTWindowSecOff 0x7980 - -#define GlintStencilMode 0x8988 -#define GlintStencilModeTag 0x0131 -#define GlintStencilModeReg 1 -#define GlintStencilModeOff 0x7988 -#define GlintStencilModeSec 0x8988 -#define GlintStencilModeSecReg 3 -#define GlintStencilModeSecOff 0x7988 - -#define GlintStencilData 0x8990 -#define GlintStencilDataTag 0x0132 -#define GlintStencilDataReg 1 -#define GlintStencilDataOff 0x7990 -#define GlintStencilDataSec 0x8990 -#define GlintStencilDataSecReg 3 -#define GlintStencilDataSecOff 0x7990 - -#define GlintGLINTStencil 0x8998 -#define GlintGLINTStencilTag 0x0133 -#define GlintGLINTStencilReg 1 -#define GlintGLINTStencilOff 0x7998 -#define GlintGLINTStencilSec 0x8998 -#define GlintGLINTStencilSecReg 3 -#define GlintGLINTStencilSecOff 0x7998 - -#define GlintDepthMode 0x89a0 -#define GlintDepthModeTag 0x0134 -#define GlintDepthModeReg 1 -#define GlintDepthModeOff 0x79a0 -#define GlintDepthModeSec 0x89a0 -#define GlintDepthModeSecReg 3 -#define GlintDepthModeSecOff 0x79a0 - -#define GlintGLINTDepth 0x89a8 -#define GlintGLINTDepthTag 0x0135 -#define GlintGLINTDepthReg 1 -#define GlintGLINTDepthOff 0x79a8 -#define GlintGLINTDepthSec 0x89a8 -#define GlintGLINTDepthSecReg 3 -#define GlintGLINTDepthSecOff 0x79a8 - -#define GlintZStartU 0x89b0 -#define GlintZStartUTag 0x0136 -#define GlintZStartUReg 1 -#define GlintZStartUOff 0x79b0 -#define GlintZStartUSec 0x89b0 -#define GlintZStartUSecReg 3 -#define GlintZStartUSecOff 0x79b0 - -#define GlintZStartL 0x89b8 -#define GlintZStartLTag 0x0137 -#define GlintZStartLReg 1 -#define GlintZStartLOff 0x79b8 -#define GlintZStartLSec 0x89b8 -#define GlintZStartLSecReg 3 -#define GlintZStartLSecOff 0x79b8 - -#define GlintdZdxU 0x89c0 -#define GlintdZdxUTag 0x0138 -#define GlintdZdxUReg 1 -#define GlintdZdxUOff 0x79c0 -#define GlintdZdxUSec 0x89c0 -#define GlintdZdxUSecReg 3 -#define GlintdZdxUSecOff 0x79c0 - -#define GlintdZdxL 0x89c8 -#define GlintdZdxLTag 0x0139 -#define GlintdZdxLReg 1 -#define GlintdZdxLOff 0x79c8 -#define GlintdZdxLSec 0x89c8 -#define GlintdZdxLSecReg 3 -#define GlintdZdxLSecOff 0x79c8 - -#define GlintdZdyDomU 0x89d0 -#define GlintdZdyDomUTag 0x013a -#define GlintdZdyDomUReg 1 -#define GlintdZdyDomUOff 0x79d0 -#define GlintdZdyDomUSec 0x89d0 -#define GlintdZdyDomUSecReg 3 -#define GlintdZdyDomUSecOff 0x79d0 - -#define GlintdZdyDomL 0x89d8 -#define GlintdZdyDomLTag 0x013b -#define GlintdZdyDomLReg 1 -#define GlintdZdyDomLOff 0x79d8 -#define GlintdZdyDomLSec 0x89d8 -#define GlintdZdyDomLSecReg 3 -#define GlintdZdyDomLSecOff 0x79d8 - -#define GlintFastClearDepth 0x89e0 -#define GlintFastClearDepthTag 0x013c -#define GlintFastClearDepthReg 1 -#define GlintFastClearDepthOff 0x79e0 -#define GlintFastClearDepthSec 0x89e0 -#define GlintFastClearDepthSecReg 3 -#define GlintFastClearDepthSecOff 0x79e0 - -#define GlintFBReadMode 0x8a80 -#define GlintFBReadModeTag 0x0150 -#define GlintFBReadModeReg 1 -#define GlintFBReadModeOff 0x7a80 -#define GlintFBReadModeSec 0x8a80 -#define GlintFBReadModeSecReg 3 -#define GlintFBReadModeSecOff 0x7a80 - -#define GlintFBSourceOffset 0x8a88 -#define GlintFBSourceOffsetTag 0x0151 -#define GlintFBSourceOffsetReg 1 -#define GlintFBSourceOffsetOff 0x7a88 -#define GlintFBSourceOffsetSec 0x8a88 -#define GlintFBSourceOffsetSecReg 3 -#define GlintFBSourceOffsetSecOff 0x7a88 - -#define GlintFBPixelOffset 0x8a90 -#define GlintFBPixelOffsetTag 0x0152 -#define GlintFBPixelOffsetReg 1 -#define GlintFBPixelOffsetOff 0x7a90 -#define GlintFBPixelOffsetSec 0x8a90 -#define GlintFBPixelOffsetSecReg 3 -#define GlintFBPixelOffsetSecOff 0x7a90 - -#define GlintFBColor 0x8a98 -#define GlintFBColorTag 0x0153 -#define GlintFBColorReg 1 -#define GlintFBColorOff 0x7a98 -#define GlintFBColorSec 0x8a98 -#define GlintFBColorSecReg 3 -#define GlintFBColorSecOff 0x7a98 - -#define GlintFBData 0x8aa0 -#define GlintFBDataTag 0x0154 -#define GlintFBDataReg 1 -#define GlintFBDataOff 0x7aa0 -#define GlintFBDataSec 0x8aa0 -#define GlintFBDataSecReg 3 -#define GlintFBDataSecOff 0x7aa0 - -#define GlintFBSourceData 0x8aa8 -#define GlintFBSourceDataTag 0x0155 -#define GlintFBSourceDataReg 1 -#define GlintFBSourceDataOff 0x7aa8 -#define GlintFBSourceDataSec 0x8aa8 -#define GlintFBSourceDataSecReg 3 -#define GlintFBSourceDataSecOff 0x7aa8 - -#define GlintFBWindowBase 0x8ab0 -#define GlintFBWindowBaseTag 0x0156 -#define GlintFBWindowBaseReg 1 -#define GlintFBWindowBaseOff 0x7ab0 -#define GlintFBWindowBaseSec 0x8ab0 -#define GlintFBWindowBaseSecReg 3 -#define GlintFBWindowBaseSecOff 0x7ab0 - -#define GlintFBWriteMode 0x8ab8 -#define GlintFBWriteModeTag 0x0157 -#define GlintFBWriteModeReg 1 -#define GlintFBWriteModeOff 0x7ab8 -#define GlintFBWriteModeSec 0x8ab8 -#define GlintFBWriteModeSecReg 3 -#define GlintFBWriteModeSecOff 0x7ab8 - -#define GlintFBHardwareWriteMask 0x8ac0 -#define GlintFBHardwareWriteMaskTag 0x0158 -#define GlintFBHardwareWriteMaskReg 1 -#define GlintFBHardwareWriteMaskOff 0x7ac0 -#define GlintFBHardwareWriteMaskSec 0x8ac0 -#define GlintFBHardwareWriteMaskSecReg 3 -#define GlintFBHardwareWriteMaskSecOff 0x7ac0 - -#define GlintFBBlockColor 0x8ac8 -#define GlintFBBlockColorTag 0x0159 -#define GlintFBBlockColorReg 1 -#define GlintFBBlockColorOff 0x7ac8 -#define GlintFBBlockColorSec 0x8ac8 -#define GlintFBBlockColorSecReg 3 -#define GlintFBBlockColorSecOff 0x7ac8 - -#define GlintPatternRamMode 0x8af8 -#define GlintPatternRamModeTag 0x015f -#define GlintPatternRamModeReg 1 -#define GlintPatternRamModeOff 0x7af8 -#define GlintPatternRamModeSec 0x8af8 -#define GlintPatternRamModeSecReg 3 -#define GlintPatternRamModeSecOff 0x7af8 - -#define GlintPatternRamData0 0x8b00 -#define GlintPatternRamData0Tag 0x0160 -#define GlintPatternRamData0Reg 1 -#define GlintPatternRamData0Off 0x7b00 -#define GlintPatternRamData0Sec 0x8b00 -#define GlintPatternRamData0SecReg 3 -#define GlintPatternRamData0SecOff 0x7b00 - -#define GlintPatternRamData1 0x8b08 -#define GlintPatternRamData1Tag 0x0161 -#define GlintPatternRamData1Reg 1 -#define GlintPatternRamData1Off 0x7b08 -#define GlintPatternRamData1Sec 0x8b08 -#define GlintPatternRamData1SecReg 3 -#define GlintPatternRamData1SecOff 0x7b08 - -#define GlintPatternRamData2 0x8b10 -#define GlintPatternRamData2Tag 0x0162 -#define GlintPatternRamData2Reg 1 -#define GlintPatternRamData2Off 0x7b10 -#define GlintPatternRamData2Sec 0x8b10 -#define GlintPatternRamData2SecReg 3 -#define GlintPatternRamData2SecOff 0x7b10 - -#define GlintPatternRamData3 0x8b18 -#define GlintPatternRamData3Tag 0x0163 -#define GlintPatternRamData3Reg 1 -#define GlintPatternRamData3Off 0x7b18 -#define GlintPatternRamData3Sec 0x8b18 -#define GlintPatternRamData3SecReg 3 -#define GlintPatternRamData3SecOff 0x7b18 - -#define GlintPatternRamData4 0x8b20 -#define GlintPatternRamData4Tag 0x0164 -#define GlintPatternRamData4Reg 1 -#define GlintPatternRamData4Off 0x7b20 -#define GlintPatternRamData4Sec 0x8b20 -#define GlintPatternRamData4SecReg 3 -#define GlintPatternRamData4SecOff 0x7b20 - -#define GlintPatternRamData5 0x8b28 -#define GlintPatternRamData5Tag 0x0165 -#define GlintPatternRamData5Reg 1 -#define GlintPatternRamData5Off 0x7b28 -#define GlintPatternRamData5Sec 0x8b28 -#define GlintPatternRamData5SecReg 3 -#define GlintPatternRamData5SecOff 0x7b28 - -#define GlintPatternRamData6 0x8b30 -#define GlintPatternRamData6Tag 0x0166 -#define GlintPatternRamData6Reg 1 -#define GlintPatternRamData6Off 0x7b30 -#define GlintPatternRamData6Sec 0x8b30 -#define GlintPatternRamData6SecReg 3 -#define GlintPatternRamData6SecOff 0x7b30 - -#define GlintPatternRamData7 0x8b38 -#define GlintPatternRamData7Tag 0x0167 -#define GlintPatternRamData7Reg 1 -#define GlintPatternRamData7Off 0x7b38 -#define GlintPatternRamData7Sec 0x8b38 -#define GlintPatternRamData7SecReg 3 -#define GlintPatternRamData7SecOff 0x7b38 - -#define GlintPatternRamData8 0x8b40 -#define GlintPatternRamData8Tag 0x0168 -#define GlintPatternRamData8Reg 1 -#define GlintPatternRamData8Off 0x7b40 -#define GlintPatternRamData8Sec 0x8b40 -#define GlintPatternRamData8SecReg 3 -#define GlintPatternRamData8SecOff 0x7b40 - -#define GlintPatternRamData9 0x8b48 -#define GlintPatternRamData9Tag 0x0169 -#define GlintPatternRamData9Reg 1 -#define GlintPatternRamData9Off 0x7b48 -#define GlintPatternRamData9Sec 0x8b48 -#define GlintPatternRamData9SecReg 3 -#define GlintPatternRamData9SecOff 0x7b48 - -#define GlintPatternRamData10 0x8b50 -#define GlintPatternRamData10Tag 0x016a -#define GlintPatternRamData10Reg 1 -#define GlintPatternRamData10Off 0x7b50 -#define GlintPatternRamData10Sec 0x8b50 -#define GlintPatternRamData10SecReg 3 -#define GlintPatternRamData10SecOff 0x7b50 - -#define GlintPatternRamData11 0x8b58 -#define GlintPatternRamData11Tag 0x016b -#define GlintPatternRamData11Reg 1 -#define GlintPatternRamData11Off 0x7b58 -#define GlintPatternRamData11Sec 0x8b58 -#define GlintPatternRamData11SecReg 3 -#define GlintPatternRamData11SecOff 0x7b58 - -#define GlintPatternRamData12 0x8b60 -#define GlintPatternRamData12Tag 0x016c -#define GlintPatternRamData12Reg 1 -#define GlintPatternRamData12Off 0x7b60 -#define GlintPatternRamData12Sec 0x8b60 -#define GlintPatternRamData12SecReg 3 -#define GlintPatternRamData12SecOff 0x7b60 - -#define GlintPatternRamData13 0x8b68 -#define GlintPatternRamData13Tag 0x016d -#define GlintPatternRamData13Reg 1 -#define GlintPatternRamData13Off 0x7b68 -#define GlintPatternRamData13Sec 0x8b68 -#define GlintPatternRamData13SecReg 3 -#define GlintPatternRamData13SecOff 0x7b68 - -#define GlintPatternRamData14 0x8b70 -#define GlintPatternRamData14Tag 0x016e -#define GlintPatternRamData14Reg 1 -#define GlintPatternRamData14Off 0x7b70 -#define GlintPatternRamData14Sec 0x8b70 -#define GlintPatternRamData14SecReg 3 -#define GlintPatternRamData14SecOff 0x7b70 - -#define GlintPatternRamData15 0x8b78 -#define GlintPatternRamData15Tag 0x016f -#define GlintPatternRamData15Reg 1 -#define GlintPatternRamData15Off 0x7b78 -#define GlintPatternRamData15Sec 0x8b78 -#define GlintPatternRamData15SecReg 3 -#define GlintPatternRamData15SecOff 0x7b78 - -#define GlintPatternRamData16 0x8b80 -#define GlintPatternRamData16Tag 0x0170 -#define GlintPatternRamData16Reg 1 -#define GlintPatternRamData16Off 0x7b80 -#define GlintPatternRamData16Sec 0x8b80 -#define GlintPatternRamData16SecReg 3 -#define GlintPatternRamData16SecOff 0x7b80 - -#define GlintPatternRamData17 0x8b88 -#define GlintPatternRamData17Tag 0x0171 -#define GlintPatternRamData17Reg 1 -#define GlintPatternRamData17Off 0x7b88 -#define GlintPatternRamData17Sec 0x8b88 -#define GlintPatternRamData17SecReg 3 -#define GlintPatternRamData17SecOff 0x7b88 - -#define GlintPatternRamData18 0x8b90 -#define GlintPatternRamData18Tag 0x0172 -#define GlintPatternRamData18Reg 1 -#define GlintPatternRamData18Off 0x7b90 -#define GlintPatternRamData18Sec 0x8b90 -#define GlintPatternRamData18SecReg 3 -#define GlintPatternRamData18SecOff 0x7b90 - -#define GlintPatternRamData19 0x8b98 -#define GlintPatternRamData19Tag 0x0173 -#define GlintPatternRamData19Reg 1 -#define GlintPatternRamData19Off 0x7b98 -#define GlintPatternRamData19Sec 0x8b98 -#define GlintPatternRamData19SecReg 3 -#define GlintPatternRamData19SecOff 0x7b98 - -#define GlintPatternRamData20 0x8ba0 -#define GlintPatternRamData20Tag 0x0174 -#define GlintPatternRamData20Reg 1 -#define GlintPatternRamData20Off 0x7ba0 -#define GlintPatternRamData20Sec 0x8ba0 -#define GlintPatternRamData20SecReg 3 -#define GlintPatternRamData20SecOff 0x7ba0 - -#define GlintPatternRamData21 0x8ba8 -#define GlintPatternRamData21Tag 0x0175 -#define GlintPatternRamData21Reg 1 -#define GlintPatternRamData21Off 0x7ba8 -#define GlintPatternRamData21Sec 0x8ba8 -#define GlintPatternRamData21SecReg 3 -#define GlintPatternRamData21SecOff 0x7ba8 - -#define GlintPatternRamData22 0x8bb0 -#define GlintPatternRamData22Tag 0x0176 -#define GlintPatternRamData22Reg 1 -#define GlintPatternRamData22Off 0x7bb0 -#define GlintPatternRamData22Sec 0x8bb0 -#define GlintPatternRamData22SecReg 3 -#define GlintPatternRamData22SecOff 0x7bb0 - -#define GlintPatternRamData23 0x8bb8 -#define GlintPatternRamData23Tag 0x0177 -#define GlintPatternRamData23Reg 1 -#define GlintPatternRamData23Off 0x7bb8 -#define GlintPatternRamData23Sec 0x8bb8 -#define GlintPatternRamData23SecReg 3 -#define GlintPatternRamData23SecOff 0x7bb8 - -#define GlintPatternRamData24 0x8bc0 -#define GlintPatternRamData24Tag 0x0178 -#define GlintPatternRamData24Reg 1 -#define GlintPatternRamData24Off 0x7bc0 -#define GlintPatternRamData24Sec 0x8bc0 -#define GlintPatternRamData24SecReg 3 -#define GlintPatternRamData24SecOff 0x7bc0 - -#define GlintPatternRamData25 0x8bc8 -#define GlintPatternRamData25Tag 0x0179 -#define GlintPatternRamData25Reg 1 -#define GlintPatternRamData25Off 0x7bc8 -#define GlintPatternRamData25Sec 0x8bc8 -#define GlintPatternRamData25SecReg 3 -#define GlintPatternRamData25SecOff 0x7bc8 - -#define GlintPatternRamData26 0x8bd0 -#define GlintPatternRamData26Tag 0x017a -#define GlintPatternRamData26Reg 1 -#define GlintPatternRamData26Off 0x7bd0 -#define GlintPatternRamData26Sec 0x8bd0 -#define GlintPatternRamData26SecReg 3 -#define GlintPatternRamData26SecOff 0x7bd0 - -#define GlintPatternRamData27 0x8bd8 -#define GlintPatternRamData27Tag 0x017b -#define GlintPatternRamData27Reg 1 -#define GlintPatternRamData27Off 0x7bd8 -#define GlintPatternRamData27Sec 0x8bd8 -#define GlintPatternRamData27SecReg 3 -#define GlintPatternRamData27SecOff 0x7bd8 - -#define GlintPatternRamData28 0x8be0 -#define GlintPatternRamData28Tag 0x017c -#define GlintPatternRamData28Reg 1 -#define GlintPatternRamData28Off 0x7be0 -#define GlintPatternRamData28Sec 0x8be0 -#define GlintPatternRamData28SecReg 3 -#define GlintPatternRamData28SecOff 0x7be0 - -#define GlintPatternRamData29 0x8be8 -#define GlintPatternRamData29Tag 0x017d -#define GlintPatternRamData29Reg 1 -#define GlintPatternRamData29Off 0x7be8 -#define GlintPatternRamData29Sec 0x8be8 -#define GlintPatternRamData29SecReg 3 -#define GlintPatternRamData29SecOff 0x7be8 - -#define GlintPatternRamData30 0x8bf0 -#define GlintPatternRamData30Tag 0x017e -#define GlintPatternRamData30Reg 1 -#define GlintPatternRamData30Off 0x7bf0 -#define GlintPatternRamData30Sec 0x8bf0 -#define GlintPatternRamData30SecReg 3 -#define GlintPatternRamData30SecOff 0x7bf0 - -#define GlintPatternRamData31 0x8bf8 -#define GlintPatternRamData31Tag 0x017f -#define GlintPatternRamData31Reg 1 -#define GlintPatternRamData31Off 0x7bf8 -#define GlintPatternRamData31Sec 0x8bf8 -#define GlintPatternRamData31SecReg 3 -#define GlintPatternRamData31SecOff 0x7bf8 - -#define GlintFBBlockColorU 0x8c68 -#define GlintFBBlockColorUTag 0x018d -#define GlintFBBlockColorUReg 1 -#define GlintFBBlockColorUOff 0x7c68 -#define GlintFBBlockColorUSec 0x8c68 -#define GlintFBBlockColorUSecReg 3 -#define GlintFBBlockColorUSecOff 0x7c68 - -#define GlintFBBlockColorL 0x8c70 -#define GlintFBBlockColorLTag 0x018e -#define GlintFBBlockColorLReg 1 -#define GlintFBBlockColorLOff 0x7c70 -#define GlintFBBlockColorLSec 0x8c70 -#define GlintFBBlockColorLSecReg 3 -#define GlintFBBlockColorLSecOff 0x7c70 - -#define GlintSuspendUntilFrameBlank 0x8c78 -#define GlintSuspendUntilFrameBlankTag 0x018f -#define GlintSuspendUntilFrameBlankReg 1 -#define GlintSuspendUntilFrameBlankOff 0x7c78 -#define GlintSuspendUntilFrameBlankSec 0x8c78 -#define GlintSuspendUntilFrameBlankSecReg 3 -#define GlintSuspendUntilFrameBlankSecOff 0x7c78 - -#define GlintFilterMode 0x8c00 -#define GlintFilterModeTag 0x0180 -#define GlintFilterModeReg 1 -#define GlintFilterModeOff 0x7c00 -#define GlintFilterModeSec 0x8c00 -#define GlintFilterModeSecReg 3 -#define GlintFilterModeSecOff 0x7c00 - -#define GlintStatisticMode 0x8c08 -#define GlintStatisticModeTag 0x0181 -#define GlintStatisticModeReg 1 -#define GlintStatisticModeOff 0x7c08 -#define GlintStatisticModeSec 0x8c08 -#define GlintStatisticModeSecReg 3 -#define GlintStatisticModeSecOff 0x7c08 - -#define GlintMinRegion 0x8c10 -#define GlintMinRegionTag 0x0182 -#define GlintMinRegionReg 1 -#define GlintMinRegionOff 0x7c10 -#define GlintMinRegionSec 0x8c10 -#define GlintMinRegionSecReg 3 -#define GlintMinRegionSecOff 0x7c10 - -#define GlintMaxRegion 0x8c18 -#define GlintMaxRegionTag 0x0183 -#define GlintMaxRegionReg 1 -#define GlintMaxRegionOff 0x7c18 -#define GlintMaxRegionSec 0x8c18 -#define GlintMaxRegionSecReg 3 -#define GlintMaxRegionSecOff 0x7c18 - -#define GlintResetPickResult 0x8c20 -#define GlintResetPickResultTag 0x0184 -#define GlintResetPickResultReg 1 -#define GlintResetPickResultOff 0x7c20 -#define GlintResetPickResultSec 0x8c20 -#define GlintResetPickResultSecReg 3 -#define GlintResetPickResultSecOff 0x7c20 - -#define GlintMitHitRegion 0x8c28 -#define GlintMitHitRegionTag 0x0185 -#define GlintMitHitRegionReg 1 -#define GlintMitHitRegionOff 0x7c28 -#define GlintMitHitRegionSec 0x8c28 -#define GlintMitHitRegionSecReg 3 -#define GlintMitHitRegionSecOff 0x7c28 - -#define GlintMaxHitRegion 0x8c30 -#define GlintMaxHitRegionTag 0x0186 -#define GlintMaxHitRegionReg 1 -#define GlintMaxHitRegionOff 0x7c30 -#define GlintMaxHitRegionSec 0x8c30 -#define GlintMaxHitRegionSecReg 3 -#define GlintMaxHitRegionSecOff 0x7c30 - -#define GlintPickResult 0x8c38 -#define GlintPickResultTag 0x0187 -#define GlintPickResultReg 1 -#define GlintPickResultOff 0x7c38 -#define GlintPickResultSec 0x8c38 -#define GlintPickResultSecReg 3 -#define GlintPickResultSecOff 0x7c38 - -#define GlintGLINTSync 0x8c40 -#define GlintGLINTSyncTag 0x0188 -#define GlintGLINTSyncReg 1 -#define GlintGLINTSyncOff 0x7c40 -#define GlintGLINTSyncSec 0x8c40 -#define GlintGLINTSyncSecReg 3 -#define GlintGLINTSyncSecOff 0x7c40 - -#define GlintKsRStart 0x8c80 -#define GlintKsRStartTag 0x0190 -#define GlintKsRStartReg 1 -#define GlintKsRStartOff 0x7c80 -#define GlintKsRStartSec 0x8c80 -#define GlintKsRStartSecReg 3 -#define GlintKsRStartSecOff 0x7c80 - -#define GlintdKsRdx 0x8c88 -#define GlintdKsRdxTag 0x0191 -#define GlintdKsRdxReg 1 -#define GlintdKsRdxOff 0x7c88 -#define GlintdKsRdxSec 0x8c88 -#define GlintdKsRdxSecReg 3 -#define GlintdKsRdxSecOff 0x7c88 - -#define GlintdKsRdyDom 0x8c90 -#define GlintdKsRdyDomTag 0x0192 -#define GlintdKsRdyDomReg 1 -#define GlintdKsRdyDomOff 0x7c90 -#define GlintdKsRdyDomSec 0x8c90 -#define GlintdKsRdyDomSecReg 3 -#define GlintdKsRdyDomSecOff 0x7c90 - -#define GlintKsGStart 0x8c98 -#define GlintKsGStartTag 0x0193 -#define GlintKsGStartReg 1 -#define GlintKsGStartOff 0x7c98 -#define GlintKsGStartSec 0x8c98 -#define GlintKsGStartSecReg 3 -#define GlintKsGStartSecOff 0x7c98 - -#define GlintdKsGdx 0x8ca0 -#define GlintdKsGdxTag 0x0194 -#define GlintdKsGdxReg 1 -#define GlintdKsGdxOff 0x7ca0 -#define GlintdKsGdxSec 0x8ca0 -#define GlintdKsGdxSecReg 3 -#define GlintdKsGdxSecOff 0x7ca0 - -#define GlintdKsGdyDom 0x8ca8 -#define GlintdKsGdyDomTag 0x0195 -#define GlintdKsGdyDomReg 1 -#define GlintdKsGdyDomOff 0x7ca8 -#define GlintdKsGdyDomSec 0x8ca8 -#define GlintdKsGdyDomSecReg 3 -#define GlintdKsGdyDomSecOff 0x7ca8 - -#define GlintKsBStart 0x8cb0 -#define GlintKsBStartTag 0x0196 -#define GlintKsBStartReg 1 -#define GlintKsBStartOff 0x7cb0 -#define GlintKsBStartSec 0x8cb0 -#define GlintKsBStartSecReg 3 -#define GlintKsBStartSecOff 0x7cb0 - -#define GlintdKsBdx 0x8cb8 -#define GlintdKsBdxTag 0x0197 -#define GlintdKsBdxReg 1 -#define GlintdKsBdxOff 0x7cb8 -#define GlintdKsBdxSec 0x8cb8 -#define GlintdKsBdxSecReg 3 -#define GlintdKsBdxSecOff 0x7cb8 - -#define GlintdKsBdyDom 0x8cc0 -#define GlintdKsBdyDomTag 0x0198 -#define GlintdKsBdyDomReg 1 -#define GlintdKsBdyDomOff 0x7cc0 -#define GlintdKsBdyDomSec 0x8cc0 -#define GlintdKsBdyDomSecReg 3 -#define GlintdKsBdyDomSecOff 0x7cc0 - -#define GlintKdRStart 0x8d00 -#define GlintKdRStartTag 0x01a0 -#define GlintKdRStartReg 1 -#define GlintKdRStartOff 0x7d00 -#define GlintKdRStartSec 0x8d00 -#define GlintKdRStartSecReg 3 -#define GlintKdRStartSecOff 0x7d00 - -#define GlintdKdRdx 0x8d08 -#define GlintdKdRdxTag 0x01a1 -#define GlintdKdRdxReg 1 -#define GlintdKdRdxOff 0x7d08 -#define GlintdKdRdxSec 0x8d08 -#define GlintdKdRdxSecReg 3 -#define GlintdKdRdxSecOff 0x7d08 - -#define GlintdKdRdyDom 0x8d10 -#define GlintdKdRdyDomTag 0x01a2 -#define GlintdKdRdyDomReg 1 -#define GlintdKdRdyDomOff 0x7d10 -#define GlintdKdRdyDomSec 0x8d10 -#define GlintdKdRdyDomSecReg 3 -#define GlintdKdRdyDomSecOff 0x7d10 - -#define GlintKdGStart 0x8d18 -#define GlintKdGStartTag 0x01a3 -#define GlintKdGStartReg 1 -#define GlintKdGStartOff 0x7d18 -#define GlintKdGStartSec 0x8d18 -#define GlintKdGStartSecReg 3 -#define GlintKdGStartSecOff 0x7d18 - -#define GlintdKdGdx 0x8d20 -#define GlintdKdGdxTag 0x01a4 -#define GlintdKdGdxReg 1 -#define GlintdKdGdxOff 0x7d20 -#define GlintdKdGdxSec 0x8d20 -#define GlintdKdGdxSecReg 3 -#define GlintdKdGdxSecOff 0x7d20 - -#define GlintdKdGdyDom 0x8d28 -#define GlintdKdGdyDomTag 0x01a5 -#define GlintdKdGdyDomReg 1 -#define GlintdKdGdyDomOff 0x7d28 -#define GlintdKdGdyDomSec 0x8d28 -#define GlintdKdGdyDomSecReg 3 -#define GlintdKdGdyDomSecOff 0x7d28 - -#define GlintKdBStart 0x8d30 -#define GlintKdBStartTag 0x01a6 -#define GlintKdBStartReg 1 -#define GlintKdBStartOff 0x7d30 -#define GlintKdBStartSec 0x8d30 -#define GlintKdBStartSecReg 3 -#define GlintKdBStartSecOff 0x7d30 - -#define GlintdKdBdx 0x8d38 -#define GlintdKdBdxTag 0x01a7 -#define GlintdKdBdxReg 1 -#define GlintdKdBdxOff 0x7d38 -#define GlintdKdBdxSec 0x8d38 -#define GlintdKdBdxSecReg 3 -#define GlintdKdBdxSecOff 0x7d38 - -#define GlintdKdBdyDom 0x8d40 -#define GlintdKdBdyDomTag 0x01a8 -#define GlintdKdBdyDomReg 1 -#define GlintdKdBdyDomOff 0x7d40 -#define GlintdKdBdyDomSec 0x8d40 -#define GlintdKdBdyDomSecReg 3 -#define GlintdKdBdyDomSecOff 0x7d40 - -#define GlintContextDump 0x8dc0 -#define GlintContextDumpTag 0x01b8 -#define GlintContextDumpReg 1 -#define GlintContextDumpOff 0x7dc0 - -#define GlintContextRestore 0x8dc8 -#define GlintContextRestoreTag 0x01b9 -#define GlintContextRestoreReg 1 -#define GlintContextRestoreOff 0x7dc8 - -#define GlintContextData 0x8dd0 -#define GlintContextDataTag 0x01ba -#define GlintContextDataReg 1 -#define GlintContextDataOff 0x7dd0 - -#define GlintFeedbackToken 0x8f80 -#define GlintFeedbackTokenTag 0x01f0 -#define GlintFeedbackTokenReg 1 -#define GlintFeedbackTokenOff 0x7f80 - -#define GlintFeedbackX 0x8f88 -#define GlintFeedbackXTag 0x01f1 -#define GlintFeedbackXReg 1 -#define GlintFeedbackXOff 0x7f88 - -#define GlintFeedbackY 0x8f90 -#define GlintFeedbackYTag 0x01f2 -#define GlintFeedbackYReg 1 -#define GlintFeedbackYOff 0x7f90 - -#define GlintFeedbackZ 0x8f98 -#define GlintFeedbackZTag 0x01f3 -#define GlintFeedbackZReg 1 -#define GlintFeedbackZOff 0x7f98 - -#define GlintFeedbackW 0x8fa0 -#define GlintFeedbackWTag 0x01f4 -#define GlintFeedbackWReg 1 -#define GlintFeedbackWOff 0x7fa0 - -#define GlintFeedbackRed 0x8fa8 -#define GlintFeedbackRedTag 0x01f5 -#define GlintFeedbackRedReg 1 -#define GlintFeedbackRedOff 0x7fa8 - -#define GlintFeedbackGreen 0x8fb0 -#define GlintFeedbackGreenTag 0x01f6 -#define GlintFeedbackGreenReg 1 -#define GlintFeedbackGreenOff 0x7fb0 - -#define GlintFeedbackBlue 0x8fb8 -#define GlintFeedbackBlueTag 0x01f7 -#define GlintFeedbackBlueReg 1 -#define GlintFeedbackBlueOff 0x7fb8 - -#define GlintFeedbackAlpha 0x8fc0 -#define GlintFeedbackAlphaTag 0x01f8 -#define GlintFeedbackAlphaReg 1 -#define GlintFeedbackAlphaOff 0x7fc0 - -#define GlintFeedbackS 0x8fc8 -#define GlintFeedbackSTag 0x01f9 -#define GlintFeedbackSReg 1 -#define GlintFeedbackSOff 0x7fc8 - -#define GlintFeedbackT 0x8fd0 -#define GlintFeedbackTTag 0x01fa -#define GlintFeedbackTReg 1 -#define GlintFeedbackTOff 0x7fd0 - -#define GlintFeedbackR 0x8fd8 -#define GlintFeedbackRTag 0x01fb -#define GlintFeedbackRReg 1 -#define GlintFeedbackROff 0x7fd8 - -#define GlintFeedbackQ 0x8fe0 -#define GlintFeedbackQTag 0x01fc -#define GlintFeedbackQReg 1 -#define GlintFeedbackQOff 0x7fe0 - -#define GlintSelectRecord 0x8fe8 -#define GlintSelectRecordTag 0x01fd -#define GlintSelectRecordReg 1 -#define GlintSelectRecordOff 0x7fe8 - -#define GlintPassThrough 0x8ff0 -#define GlintPassThroughTag 0x01fe -#define GlintPassThroughReg 1 -#define GlintPassThroughOff 0x7ff0 - -#define GlintEndOfFeedback 0x8ff8 -#define GlintEndOfFeedbackTag 0x01ff -#define GlintEndOfFeedbackReg 1 -#define GlintEndOfFeedbackOff 0x7ff8 - -#define GlintV0FixedS 0x9000 -#define GlintV0FixedSTag 0x0200 -#define GlintV0FixedSReg 1 -#define GlintV0FixedSOff 0x8000 - -#define GlintV0FixedT 0x9008 -#define GlintV0FixedTTag 0x0201 -#define GlintV0FixedTReg 1 -#define GlintV0FixedTOff 0x8008 - -#define GlintV0FixedQ 0x9010 -#define GlintV0FixedQTag 0x0202 -#define GlintV0FixedQReg 1 -#define GlintV0FixedQOff 0x8010 - -#define GlintV0FixedKs 0x9018 -#define GlintV0FixedKsTag 0x0203 -#define GlintV0FixedKsReg 1 -#define GlintV0FixedKsOff 0x8018 - -#define GlintV0FixedKd 0x9020 -#define GlintV0FixedKdTag 0x0204 -#define GlintV0FixedKdReg 1 -#define GlintV0FixedKdOff 0x8020 - -#define GlintV0FixedR 0x9028 -#define GlintV0FixedRTag 0x0205 -#define GlintV0FixedRReg 1 -#define GlintV0FixedROff 0x8028 - -#define GlintV0FixedG 0x9030 -#define GlintV0FixedGTag 0x0206 -#define GlintV0FixedGReg 1 -#define GlintV0FixedGOff 0x8030 - -#define GlintV0FixedB 0x9038 -#define GlintV0FixedBTag 0x0207 -#define GlintV0FixedBReg 1 -#define GlintV0FixedBOff 0x8038 - -#define GlintV0FixedA 0x9040 -#define GlintV0FixedATag 0x0208 -#define GlintV0FixedAReg 1 -#define GlintV0FixedAOff 0x8040 - -#define GlintV0FixedF 0x9048 -#define GlintV0FixedFTag 0x0209 -#define GlintV0FixedFReg 1 -#define GlintV0FixedFOff 0x8048 - -#define GlintV0FixedX 0x9050 -#define GlintV0FixedXTag 0x020a -#define GlintV0FixedXReg 1 -#define GlintV0FixedXOff 0x8050 - -#define GlintV0FixedY 0x9058 -#define GlintV0FixedYTag 0x020b -#define GlintV0FixedYReg 1 -#define GlintV0FixedYOff 0x8058 - -#define GlintV0FixedZ 0x9060 -#define GlintV0FixedZTag 0x020c -#define GlintV0FixedZReg 1 -#define GlintV0FixedZOff 0x8060 - -#define GlintV1FixedS 0x9080 -#define GlintV1FixedSTag 0x0210 -#define GlintV1FixedSReg 1 -#define GlintV1FixedSOff 0x8080 - -#define GlintV1FixedT 0x9088 -#define GlintV1FixedTTag 0x0211 -#define GlintV1FixedTReg 1 -#define GlintV1FixedTOff 0x8088 - -#define GlintV1FixedQ 0x9090 -#define GlintV1FixedQTag 0x0212 -#define GlintV1FixedQReg 1 -#define GlintV1FixedQOff 0x8090 - -#define GlintV1FixedKs 0x9098 -#define GlintV1FixedKsTag 0x0213 -#define GlintV1FixedKsReg 1 -#define GlintV1FixedKsOff 0x8098 - -#define GlintV1FixedKd 0x90a0 -#define GlintV1FixedKdTag 0x0214 -#define GlintV1FixedKdReg 1 -#define GlintV1FixedKdOff 0x80a0 - -#define GlintV1FixedR 0x90a8 -#define GlintV1FixedRTag 0x0215 -#define GlintV1FixedRReg 1 -#define GlintV1FixedROff 0x80a8 - -#define GlintV1FixedG 0x90b0 -#define GlintV1FixedGTag 0x0216 -#define GlintV1FixedGReg 1 -#define GlintV1FixedGOff 0x80b0 - -#define GlintV1FixedB 0x90b8 -#define GlintV1FixedBTag 0x0217 -#define GlintV1FixedBReg 1 -#define GlintV1FixedBOff 0x80b8 - -#define GlintV1FixedA 0x90c0 -#define GlintV1FixedATag 0x0218 -#define GlintV1FixedAReg 1 -#define GlintV1FixedAOff 0x80c0 - -#define GlintV1FixedF 0x90c8 -#define GlintV1FixedFTag 0x0219 -#define GlintV1FixedFReg 1 -#define GlintV1FixedFOff 0x80c8 - -#define GlintV1FixedX 0x90d0 -#define GlintV1FixedXTag 0x021a -#define GlintV1FixedXReg 1 -#define GlintV1FixedXOff 0x80d0 - -#define GlintV1FixedY 0x90d8 -#define GlintV1FixedYTag 0x021b -#define GlintV1FixedYReg 1 -#define GlintV1FixedYOff 0x80d8 - -#define GlintV1FixedZ 0x90e0 -#define GlintV1FixedZTag 0x021c -#define GlintV1FixedZReg 1 -#define GlintV1FixedZOff 0x80e0 - -#define GlintV2FixedS 0x9100 -#define GlintV2FixedSTag 0x0220 -#define GlintV2FixedSReg 1 -#define GlintV2FixedSOff 0x8100 - -#define GlintV2FixedT 0x9108 -#define GlintV2FixedTTag 0x0221 -#define GlintV2FixedTReg 1 -#define GlintV2FixedTOff 0x8108 - -#define GlintV2FixedQ 0x9110 -#define GlintV2FixedQTag 0x0222 -#define GlintV2FixedQReg 1 -#define GlintV2FixedQOff 0x8110 - -#define GlintV2FixedKs 0x9118 -#define GlintV2FixedKsTag 0x0223 -#define GlintV2FixedKsReg 1 -#define GlintV2FixedKsOff 0x8118 - -#define GlintV2FixedKd 0x9120 -#define GlintV2FixedKdTag 0x0224 -#define GlintV2FixedKdReg 1 -#define GlintV2FixedKdOff 0x8120 - -#define GlintV2FixedR 0x9128 -#define GlintV2FixedRTag 0x0225 -#define GlintV2FixedRReg 1 -#define GlintV2FixedROff 0x8128 - -#define GlintV2FixedG 0x9130 -#define GlintV2FixedGTag 0x0226 -#define GlintV2FixedGReg 1 -#define GlintV2FixedGOff 0x8130 - -#define GlintV2FixedB 0x9138 -#define GlintV2FixedBTag 0x0227 -#define GlintV2FixedBReg 1 -#define GlintV2FixedBOff 0x8138 - -#define GlintV2FixedA 0x9140 -#define GlintV2FixedATag 0x0228 -#define GlintV2FixedAReg 1 -#define GlintV2FixedAOff 0x8140 - -#define GlintV2FixedF 0x9148 -#define GlintV2FixedFTag 0x0229 -#define GlintV2FixedFReg 1 -#define GlintV2FixedFOff 0x8148 - -#define GlintV2FixedX 0x9150 -#define GlintV2FixedXTag 0x022a -#define GlintV2FixedXReg 1 -#define GlintV2FixedXOff 0x8150 - -#define GlintV2FixedY 0x9158 -#define GlintV2FixedYTag 0x022b -#define GlintV2FixedYReg 1 -#define GlintV2FixedYOff 0x8158 - -#define GlintV2FixedZ 0x9160 -#define GlintV2FixedZTag 0x022c -#define GlintV2FixedZReg 1 -#define GlintV2FixedZOff 0x8160 - -#define GlintV0FloatS 0x9180 -#define GlintV0FloatSTag 0x0230 -#define GlintV0FloatSReg 1 -#define GlintV0FloatSOff 0x8180 - -#define GlintV0FloatT 0x9188 -#define GlintV0FloatTTag 0x0231 -#define GlintV0FloatTReg 1 -#define GlintV0FloatTOff 0x8188 - -#define GlintV0FloatQ 0x9190 -#define GlintV0FloatQTag 0x0232 -#define GlintV0FloatQReg 1 -#define GlintV0FloatQOff 0x8190 - -#define GlintV0FloatKs 0x9198 -#define GlintV0FloatKsTag 0x0233 -#define GlintV0FloatKsReg 1 -#define GlintV0FloatKsOff 0x8198 - -#define GlintV0FloatKd 0x91a0 -#define GlintV0FloatKdTag 0x0234 -#define GlintV0FloatKdReg 1 -#define GlintV0FloatKdOff 0x81a0 - -#define GlintV0FloatR 0x91a8 -#define GlintV0FloatRTag 0x0235 -#define GlintV0FloatRReg 1 -#define GlintV0FloatROff 0x81a8 - -#define GlintV0FloatG 0x91b0 -#define GlintV0FloatGTag 0x0236 -#define GlintV0FloatGReg 1 -#define GlintV0FloatGOff 0x81b0 - -#define GlintV0FloatB 0x91b8 -#define GlintV0FloatBTag 0x0237 -#define GlintV0FloatBReg 1 -#define GlintV0FloatBOff 0x81b8 - -#define GlintV0FloatA 0x91c0 -#define GlintV0FloatATag 0x0238 -#define GlintV0FloatAReg 1 -#define GlintV0FloatAOff 0x81c0 - -#define GlintV0FloatF 0x91c8 -#define GlintV0FloatFTag 0x0239 -#define GlintV0FloatFReg 1 -#define GlintV0FloatFOff 0x81c8 - -#define GlintV0FloatX 0x91d0 -#define GlintV0FloatXTag 0x023a -#define GlintV0FloatXReg 1 -#define GlintV0FloatXOff 0x81d0 - -#define GlintV0FloatY 0x91d8 -#define GlintV0FloatYTag 0x023b -#define GlintV0FloatYReg 1 -#define GlintV0FloatYOff 0x81d8 - -#define GlintV0FloatZ 0x91e0 -#define GlintV0FloatZTag 0x023c -#define GlintV0FloatZReg 1 -#define GlintV0FloatZOff 0x81e0 - -#define GlintV1FloatS 0x9200 -#define GlintV1FloatSTag 0x0240 -#define GlintV1FloatSReg 1 -#define GlintV1FloatSOff 0x8200 - -#define GlintV1FloatT 0x9208 -#define GlintV1FloatTTag 0x0241 -#define GlintV1FloatTReg 1 -#define GlintV1FloatTOff 0x8208 - -#define GlintV1FloatQ 0x9210 -#define GlintV1FloatQTag 0x0242 -#define GlintV1FloatQReg 1 -#define GlintV1FloatQOff 0x8210 - -#define GlintV1FloatKs 0x9218 -#define GlintV1FloatKsTag 0x0243 -#define GlintV1FloatKsReg 1 -#define GlintV1FloatKsOff 0x8218 - -#define GlintV1FloatKd 0x9220 -#define GlintV1FloatKdTag 0x0244 -#define GlintV1FloatKdReg 1 -#define GlintV1FloatKdOff 0x8220 - -#define GlintV1FloatR 0x9228 -#define GlintV1FloatRTag 0x0245 -#define GlintV1FloatRReg 1 -#define GlintV1FloatROff 0x8228 - -#define GlintV1FloatG 0x9230 -#define GlintV1FloatGTag 0x0246 -#define GlintV1FloatGReg 1 -#define GlintV1FloatGOff 0x8230 - -#define GlintV1FloatB 0x9238 -#define GlintV1FloatBTag 0x0247 -#define GlintV1FloatBReg 1 -#define GlintV1FloatBOff 0x8238 - -#define GlintV1FloatA 0x9240 -#define GlintV1FloatATag 0x0248 -#define GlintV1FloatAReg 1 -#define GlintV1FloatAOff 0x8240 - -#define GlintV1FloatF 0x9248 -#define GlintV1FloatFTag 0x0249 -#define GlintV1FloatFReg 1 -#define GlintV1FloatFOff 0x8248 - -#define GlintV1FloatX 0x9250 -#define GlintV1FloatXTag 0x024a -#define GlintV1FloatXReg 1 -#define GlintV1FloatXOff 0x8250 - -#define GlintV1FloatY 0x9258 -#define GlintV1FloatYTag 0x024b -#define GlintV1FloatYReg 1 -#define GlintV1FloatYOff 0x8258 - -#define GlintV1FloatZ 0x9260 -#define GlintV1FloatZTag 0x024c -#define GlintV1FloatZReg 1 -#define GlintV1FloatZOff 0x8260 - -#define GlintV2FloatS 0x9280 -#define GlintV2FloatSTag 0x0250 -#define GlintV2FloatSReg 1 -#define GlintV2FloatSOff 0x8280 - -#define GlintV2FloatT 0x9288 -#define GlintV2FloatTTag 0x0251 -#define GlintV2FloatTReg 1 -#define GlintV2FloatTOff 0x8288 - -#define GlintV2FloatQ 0x9290 -#define GlintV2FloatQTag 0x0252 -#define GlintV2FloatQReg 1 -#define GlintV2FloatQOff 0x8290 - -#define GlintV2FloatKs 0x9298 -#define GlintV2FloatKsTag 0x0253 -#define GlintV2FloatKsReg 1 -#define GlintV2FloatKsOff 0x8298 - -#define GlintV2FloatKd 0x92a0 -#define GlintV2FloatKdTag 0x0254 -#define GlintV2FloatKdReg 1 -#define GlintV2FloatKdOff 0x82a0 - -#define GlintV2FloatR 0x92a8 -#define GlintV2FloatRTag 0x0255 -#define GlintV2FloatRReg 1 -#define GlintV2FloatROff 0x82a8 - -#define GlintV2FloatG 0x92b0 -#define GlintV2FloatGTag 0x0256 -#define GlintV2FloatGReg 1 -#define GlintV2FloatGOff 0x82b0 - -#define GlintV2FloatB 0x92b8 -#define GlintV2FloatBTag 0x0257 -#define GlintV2FloatBReg 1 -#define GlintV2FloatBOff 0x82b8 - -#define GlintV2FloatA 0x92c0 -#define GlintV2FloatATag 0x0258 -#define GlintV2FloatAReg 1 -#define GlintV2FloatAOff 0x82c0 - -#define GlintV2FloatF 0x92c8 -#define GlintV2FloatFTag 0x0259 -#define GlintV2FloatFReg 1 -#define GlintV2FloatFOff 0x82c8 - -#define GlintV2FloatX 0x92d0 -#define GlintV2FloatXTag 0x025a -#define GlintV2FloatXReg 1 -#define GlintV2FloatXOff 0x82d0 - -#define GlintV2FloatY 0x92d8 -#define GlintV2FloatYTag 0x025b -#define GlintV2FloatYReg 1 -#define GlintV2FloatYOff 0x82d8 - -#define GlintV2FloatZ 0x92e0 -#define GlintV2FloatZTag 0x025c -#define GlintV2FloatZReg 1 -#define GlintV2FloatZOff 0x82e0 - -#define GlintDeltaMode 0x9300 -#define GlintDeltaModeTag 0x0260 -#define GlintDeltaModeReg 1 -#define GlintDeltaModeOff 0x8300 - -#define GlintDrawTriangle 0x9308 -#define GlintDrawTriangleTag 0x0261 -#define GlintDrawTriangleReg 1 -#define GlintDrawTriangleOff 0x8308 - -#define GlintRepeatTriangle 0x9310 -#define GlintRepeatTriangleTag 0x0262 -#define GlintRepeatTriangleReg 1 -#define GlintRepeatTriangleOff 0x8310 - -#define GlintDrawLine01 0x9318 -#define GlintDrawLine01Tag 0x0263 -#define GlintDrawLine01Reg 1 -#define GlintDrawLine01Off 0x8318 - -#define GlintDrawLine10 0x9320 -#define GlintDrawLine10Tag 0x0264 -#define GlintDrawLine10Reg 1 -#define GlintDrawLine10Off 0x8320 - -#define GlintRepeatLine 0x9328 -#define GlintRepeatLineTag 0x0265 -#define GlintRepeatLineReg 1 -#define GlintRepeatLineOff 0x8328 - -#define GlintEpilogueTag 0x9368 -#define GlintEpilogueTagTag 0x026d -#define GlintEpilogueTagReg 1 -#define GlintEpilogueTagOff 0x8368 - -#define GlintEpilogueData 0x9370 -#define GlintEpilogueDataTag 0x026e -#define GlintEpilogueDataReg 1 -#define GlintEpilogueDataOff 0x8370 - -#define GlintBroadcastMask 0x9378 -#define GlintBroadcastMaskTag 0x026f -#define GlintBroadcastMaskReg 1 -#define GlintBroadcastMaskOff 0x8378 - -#define GlintXBias 0x9480 -#define GlintXBiasTag 0x0290 -#define GlintXBiasReg 1 -#define GlintXBiasOff 0x8480 - -#define GlintYBias 0x9488 -#define GlintYBiasTag 0x0291 -#define GlintYBiasReg 1 -#define GlintYBiasOff 0x8488 - -#define GlintPointMode 0x9490 -#define GlintPointModeTag 0x0292 -#define GlintPointModeReg 1 -#define GlintPointModeOff 0x8490 - -#define GlintPointSize 0x9498 -#define GlintPointSizeTag 0x0293 -#define GlintPointSizeReg 1 -#define GlintPointSizeOff 0x8498 - -#define GlintAApointSize 0x94a0 -#define GlintAApointSizeTag 0x0294 -#define GlintAApointSizeReg 1 -#define GlintAApointSizeOff 0x84a0 - -#define GlintLineMode 0x94a8 -#define GlintLineModeTag 0x0295 -#define GlintLineModeReg 1 -#define GlintLineModeOff 0x84a8 - -#define GlintLineWidth 0x94b0 -#define GlintLineWidthTag 0x0296 -#define GlintLineWidthReg 1 -#define GlintLineWidthOff 0x84b0 - -#define GlintLineWidthOffset 0x94b8 -#define GlintLineWidthOffsetTag 0x0297 -#define GlintLineWidthOffsetReg 1 -#define GlintLineWidthOffsetOff 0x84b8 - -#define GlintAAlineWidth 0x94c0 -#define GlintAAlineWidthTag 0x0298 -#define GlintAAlineWidthReg 1 -#define GlintAAlineWidthOff 0x84c0 - -#define GlintTriangleMode 0x94c8 -#define GlintTriangleModeTag 0x0299 -#define GlintTriangleModeReg 1 -#define GlintTriangleModeOff 0x84c8 - -#define GlintRectangleMode 0x94d0 -#define GlintRectangleModeTag 0x029a -#define GlintRectangleModeReg 1 -#define GlintRectangleModeOff 0x84d0 - -#define GlintRectangleWidth 0x94d8 -#define GlintRectangleWidthTag 0x029b -#define GlintRectangleWidthReg 1 -#define GlintRectangleWidthOff 0x84d8 - -#define GlintRectangleHeight 0x94e0 -#define GlintRectangleHeightTag 0x029c -#define GlintRectangleHeightReg 1 -#define GlintRectangleHeightOff 0x84e0 - -#define GlintRectangle2DMode 0x94e8 -#define GlintRectangle2DModeTag 0x029d -#define GlintRectangle2DModeReg 1 -#define GlintRectangle2DModeOff 0x84e8 - -#define GlintRectangle2DControl 0x94f0 -#define GlintRectangle2DControlTag 0x029e -#define GlintRectangle2DControlReg 1 -#define GlintRectangle2DControlOff 0x84f0 - -#define GlintTransformMode 0x9508 -#define GlintTransformModeTag 0x02a1 -#define GlintTransformModeReg 1 -#define GlintTransformModeOff 0x8508 - -#define GlintGeometryMode 0x9510 -#define GlintGeometryModeTag 0x02a2 -#define GlintGeometryModeReg 1 -#define GlintGeometryModeOff 0x8510 - -#define GlintNormalizeMode 0x9518 -#define GlintNormalizeModeTag 0x02a3 -#define GlintNormalizeModeReg 1 -#define GlintNormalizeModeOff 0x8518 - -#define GlintLightingMode 0x9520 -#define GlintLightingModeTag 0x02a4 -#define GlintLightingModeReg 1 -#define GlintLightingModeOff 0x8520 - -#define GlintColorMaterialMode 0x9528 -#define GlintColorMaterialModeTag 0x02a5 -#define GlintColorMaterialModeReg 1 -#define GlintColorMaterialModeOff 0x8528 - -#define GlintMaterialMode 0x9530 -#define GlintMaterialModeTag 0x02a6 -#define GlintMaterialModeReg 1 -#define GlintMaterialModeOff 0x8530 - -#define GlintSelectResult 0x9580 -#define GlintSelectResultTag 0x02b0 -#define GlintSelectResultReg 1 -#define GlintSelectResultOff 0x8580 - -#define GlintBegin 0x9590 -#define GlintBeginTag 0x02b2 -#define GlintBeginReg 1 -#define GlintBeginOff 0x8590 - -#define GlintEnd 0x9598 -#define GlintEndTag 0x02b3 -#define GlintEndReg 1 -#define GlintEndOff 0x8598 - -#define GlintEdgeFlag 0x95a0 -#define GlintEdgeFlagTag 0x02b4 -#define GlintEdgeFlagReg 1 -#define GlintEdgeFlagOff 0x85a0 - -#define GlintObjectIDvalue 0x95a8 -#define GlintObjectIDvalueTag 0x02b5 -#define GlintObjectIDvalueReg 1 -#define GlintObjectIDvalueOff 0x85a8 - -#define GlintIncrementObjectID 0x95b0 -#define GlintIncrementObjectIDTag 0x02b6 -#define GlintIncrementObjectIDReg 1 -#define GlintIncrementObjectIDOff 0x85b0 - -#define GlintTransformCurrent 0x95b8 -#define GlintTransformCurrentTag 0x02b7 -#define GlintTransformCurrentReg 1 -#define GlintTransformCurrentOff 0x85b8 - -#define GlintSaveCurrent 0x95c8 -#define GlintSaveCurrentTag 0x02b9 -#define GlintSaveCurrentReg 1 -#define GlintSaveCurrentOff 0x85c8 - -#define GlintRestoreCurrent 0x95d0 -#define GlintRestoreCurrentTag 0x02ba -#define GlintRestoreCurrentReg 1 -#define GlintRestoreCurrentOff 0x85d0 - -#define GlintInitNames 0x95d8 -#define GlintInitNamesTag 0x02bb -#define GlintInitNamesReg 1 -#define GlintInitNamesOff 0x85d8 - -#define GlintPushName 0x95e0 -#define GlintPushNameTag 0x02bc -#define GlintPushNameReg 1 -#define GlintPushNameOff 0x85e0 - -#define GlintPopName 0x95e8 -#define GlintPopNameTag 0x02bd -#define GlintPopNameReg 1 -#define GlintPopNameOff 0x85e8 - -#define GlintLoadName 0x95f0 -#define GlintLoadNameTag 0x02be -#define GlintLoadNameReg 1 -#define GlintLoadNameOff 0x85f0 - -#define GlintGeomRectangle 0x96a0 -#define GlintGeomRectangleTag 0x02d4 -#define GlintGeomRectangleReg 1 -#define GlintGeomRectangleOff 0x86a0 - -#define GlintDrawRectangle2D 0x97a0 -#define GlintDrawRectangle2DTag 0x02f4 -#define GlintDrawRectangle2DReg 1 -#define GlintDrawRectangle2DOff 0x87a0 - -#define GlintNz 0x9800 -#define GlintNzTag 0x0300 -#define GlintNzReg 1 -#define GlintNzOff 0x8800 - -#define GlintNy 0x9808 -#define GlintNyTag 0x0301 -#define GlintNyReg 1 -#define GlintNyOff 0x8808 - -#define GlintNx 0x9810 -#define GlintNxTag 0x0302 -#define GlintNxReg 1 -#define GlintNxOff 0x8810 - -#define GlintCa 0x9818 -#define GlintCaTag 0x0303 -#define GlintCaReg 1 -#define GlintCaOff 0x8818 - -#define GlintCb 0x9820 -#define GlintCbTag 0x0304 -#define GlintCbReg 1 -#define GlintCbOff 0x8820 - -#define GlintCg 0x9828 -#define GlintCgTag 0x0305 -#define GlintCgReg 1 -#define GlintCgOff 0x8828 - -#define GlintCr3 0x9830 -#define GlintCr3Tag 0x0306 -#define GlintCr3Reg 1 -#define GlintCr3Off 0x8830 - -#define GlintCr4 0x9838 -#define GlintCr4Tag 0x0307 -#define GlintCr4Reg 1 -#define GlintCr4Off 0x8838 - -#define GlintTt2 0x9840 -#define GlintTt2Tag 0x0308 -#define GlintTt2Reg 1 -#define GlintTt2Off 0x8840 - -#define GlintTs2 0x9848 -#define GlintTs2Tag 0x0309 -#define GlintTs2Reg 1 -#define GlintTs2Off 0x8848 - -#define GlintVw 0x9850 -#define GlintVwTag 0x030a -#define GlintVwReg 1 -#define GlintVwOff 0x8850 - -#define GlintVz 0x9858 -#define GlintVzTag 0x030b -#define GlintVzReg 1 -#define GlintVzOff 0x8858 - -#define GlintVy 0x9860 -#define GlintVyTag 0x030c -#define GlintVyReg 1 -#define GlintVyOff 0x8860 - -#define GlintVx2 0x9868 -#define GlintVx2Tag 0x030d -#define GlintVx2Reg 1 -#define GlintVx2Off 0x8868 - -#define GlintVx3 0x9870 -#define GlintVx3Tag 0x030e -#define GlintVx3Reg 1 -#define GlintVx3Off 0x8870 - -#define GlintVx4 0x9878 -#define GlintVx4Tag 0x030f -#define GlintVx4Reg 1 -#define GlintVx4Off 0x8878 - -#define GlintFNz 0x9880 -#define GlintFNzTag 0x0310 -#define GlintFNzReg 1 -#define GlintFNzOff 0x8880 - -#define GlintFNy 0x9888 -#define GlintFNyTag 0x0311 -#define GlintFNyReg 1 -#define GlintFNyOff 0x8888 - -#define GlintFNx 0x9890 -#define GlintFNxTag 0x0312 -#define GlintFNxReg 1 -#define GlintFNxOff 0x8890 - -#define GlintPackedColor3 0x9898 -#define GlintPackedColor3Tag 0x0313 -#define GlintPackedColor3Reg 1 -#define GlintPackedColor3Off 0x8898 - -#define GlintPackedColor4 0x98a0 -#define GlintPackedColor4Tag 0x0314 -#define GlintPackedColor4Reg 1 -#define GlintPackedColor4Off 0x88a0 - -#define GlintTq4 0x98a8 -#define GlintTq4Tag 0x0315 -#define GlintTq4Reg 1 -#define GlintTq4Off 0x88a8 - -#define GlintTr4 0x98b0 -#define GlintTr4Tag 0x0316 -#define GlintTr4Reg 1 -#define GlintTr4Off 0x88b0 - -#define GlintTt4 0x98b8 -#define GlintTt4Tag 0x0317 -#define GlintTt4Reg 1 -#define GlintTt4Off 0x88b8 - -#define GlintTs4 0x98c0 -#define GlintTs4Tag 0x0318 -#define GlintTs4Reg 1 -#define GlintTs4Off 0x88c0 - -#define GlintRPw 0x98c8 -#define GlintRPwTag 0x0319 -#define GlintRPwReg 1 -#define GlintRPwOff 0x88c8 - -#define GlintRPz 0x98d0 -#define GlintRPzTag 0x031a -#define GlintRPzReg 1 -#define GlintRPzOff 0x88d0 - -#define GlintRPy 0x98d8 -#define GlintRPyTag 0x031b -#define GlintRPyReg 1 -#define GlintRPyOff 0x88d8 - -#define GlintRPx2 0x98e0 -#define GlintRPx2Tag 0x031c -#define GlintRPx2Reg 1 -#define GlintRPx2Off 0x88e0 - -#define GlintRPx3 0x98e8 -#define GlintRPx3Tag 0x031d -#define GlintRPx3Reg 1 -#define GlintRPx3Off 0x88e8 - -#define GlintRPx4 0x98f0 -#define GlintRPx4Tag 0x031e -#define GlintRPx4Reg 1 -#define GlintRPx4Off 0x88f0 - -#define GlintTs1 0x98f8 -#define GlintTs1Tag 0x031f -#define GlintTs1Reg 1 -#define GlintTs1Off 0x88f8 - -#define GlintModelViewMatrix0 0x9900 -#define GlintModelViewMatrix0Tag 0x0320 -#define GlintModelViewMatrix0Reg 1 -#define GlintModelViewMatrix0Off 0x8900 - -#define GlintModelViewMatrix1 0x9908 -#define GlintModelViewMatrix1Tag 0x0321 -#define GlintModelViewMatrix1Reg 1 -#define GlintModelViewMatrix1Off 0x8908 - -#define GlintModelViewMatrix2 0x9910 -#define GlintModelViewMatrix2Tag 0x0322 -#define GlintModelViewMatrix2Reg 1 -#define GlintModelViewMatrix2Off 0x8910 - -#define GlintModelViewMatrix3 0x9918 -#define GlintModelViewMatrix3Tag 0x0323 -#define GlintModelViewMatrix3Reg 1 -#define GlintModelViewMatrix3Off 0x8918 - -#define GlintModelViewMatrix4 0x9920 -#define GlintModelViewMatrix4Tag 0x0324 -#define GlintModelViewMatrix4Reg 1 -#define GlintModelViewMatrix4Off 0x8920 - -#define GlintModelViewMatrix5 0x9928 -#define GlintModelViewMatrix5Tag 0x0325 -#define GlintModelViewMatrix5Reg 1 -#define GlintModelViewMatrix5Off 0x8928 - -#define GlintModelViewMatrix6 0x9930 -#define GlintModelViewMatrix6Tag 0x0326 -#define GlintModelViewMatrix6Reg 1 -#define GlintModelViewMatrix6Off 0x8930 - -#define GlintModelViewMatrix7 0x9938 -#define GlintModelViewMatrix7Tag 0x0327 -#define GlintModelViewMatrix7Reg 1 -#define GlintModelViewMatrix7Off 0x8938 - -#define GlintModelViewMatrix8 0x9940 -#define GlintModelViewMatrix8Tag 0x0328 -#define GlintModelViewMatrix8Reg 1 -#define GlintModelViewMatrix8Off 0x8940 - -#define GlintModelViewMatrix9 0x9948 -#define GlintModelViewMatrix9Tag 0x0329 -#define GlintModelViewMatrix9Reg 1 -#define GlintModelViewMatrix9Off 0x8948 - -#define GlintModelViewMatrix10 0x9950 -#define GlintModelViewMatrix10Tag 0x032a -#define GlintModelViewMatrix10Reg 1 -#define GlintModelViewMatrix10Off 0x8950 - -#define GlintModelViewMatrix11 0x9958 -#define GlintModelViewMatrix11Tag 0x032b -#define GlintModelViewMatrix11Reg 1 -#define GlintModelViewMatrix11Off 0x8958 - -#define GlintModelViewMatrix12 0x9960 -#define GlintModelViewMatrix12Tag 0x032c -#define GlintModelViewMatrix12Reg 1 -#define GlintModelViewMatrix12Off 0x8960 - -#define GlintModelViewMatrix13 0x9968 -#define GlintModelViewMatrix13Tag 0x032d -#define GlintModelViewMatrix13Reg 1 -#define GlintModelViewMatrix13Off 0x8968 - -#define GlintModelViewMatrix14 0x9970 -#define GlintModelViewMatrix14Tag 0x032e -#define GlintModelViewMatrix14Reg 1 -#define GlintModelViewMatrix14Off 0x8970 - -#define GlintModelViewMatrix15 0x9978 -#define GlintModelViewMatrix15Tag 0x032f -#define GlintModelViewMatrix15Reg 1 -#define GlintModelViewMatrix15Off 0x8978 - -#define GlintModelViewProjectionMatrix0 0x9980 -#define GlintModelViewProjectionMatrix0Tag 0x0330 -#define GlintModelViewProjectionMatrix0Reg 1 -#define GlintModelViewProjectionMatrix0Off 0x8980 - -#define GlintModelViewProjectionMatrix1 0x9988 -#define GlintModelViewProjectionMatrix1Tag 0x0331 -#define GlintModelViewProjectionMatrix1Reg 1 -#define GlintModelViewProjectionMatrix1Off 0x8988 - -#define GlintModelViewProjectionMatrix2 0x9990 -#define GlintModelViewProjectionMatrix2Tag 0x0332 -#define GlintModelViewProjectionMatrix2Reg 1 -#define GlintModelViewProjectionMatrix2Off 0x8990 - -#define GlintModelViewProjectionMatrix3 0x9998 -#define GlintModelViewProjectionMatrix3Tag 0x0333 -#define GlintModelViewProjectionMatrix3Reg 1 -#define GlintModelViewProjectionMatrix3Off 0x8998 - -#define GlintModelViewProjectionMatrix4 0x99a0 -#define GlintModelViewProjectionMatrix4Tag 0x0334 -#define GlintModelViewProjectionMatrix4Reg 1 -#define GlintModelViewProjectionMatrix4Off 0x89a0 - -#define GlintModelViewProjectionMatrix5 0x99a8 -#define GlintModelViewProjectionMatrix5Tag 0x0335 -#define GlintModelViewProjectionMatrix5Reg 1 -#define GlintModelViewProjectionMatrix5Off 0x89a8 - -#define GlintModelViewProjectionMatrix6 0x99b0 -#define GlintModelViewProjectionMatrix6Tag 0x0336 -#define GlintModelViewProjectionMatrix6Reg 1 -#define GlintModelViewProjectionMatrix6Off 0x89b0 - -#define GlintModelViewProjectionMatrix7 0x99b8 -#define GlintModelViewProjectionMatrix7Tag 0x0337 -#define GlintModelViewProjectionMatrix7Reg 1 -#define GlintModelViewProjectionMatrix7Off 0x89b8 - -#define GlintModelViewProjectionMatrix8 0x99c0 -#define GlintModelViewProjectionMatrix8Tag 0x0338 -#define GlintModelViewProjectionMatrix8Reg 1 -#define GlintModelViewProjectionMatrix8Off 0x89c0 - -#define GlintModelViewProjectionMatrix9 0x99c8 -#define GlintModelViewProjectionMatrix9Tag 0x0339 -#define GlintModelViewProjectionMatrix9Reg 1 -#define GlintModelViewProjectionMatrix9Off 0x89c8 - -#define GlintModelViewProjectionMatrix10 0x99d0 -#define GlintModelViewProjectionMatrix10Tag 0x033a -#define GlintModelViewProjectionMatrix10Reg 1 -#define GlintModelViewProjectionMatrix10Off 0x89d0 - -#define GlintModelViewProjectionMatrix11 0x99d8 -#define GlintModelViewProjectionMatrix11Tag 0x033b -#define GlintModelViewProjectionMatrix11Reg 1 -#define GlintModelViewProjectionMatrix11Off 0x89d8 - -#define GlintModelViewProjectionMatrix12 0x99e0 -#define GlintModelViewProjectionMatrix12Tag 0x033c -#define GlintModelViewProjectionMatrix12Reg 1 -#define GlintModelViewProjectionMatrix12Off 0x89e0 - -#define GlintModelViewProjectionMatrix13 0x99e8 -#define GlintModelViewProjectionMatrix13Tag 0x033d -#define GlintModelViewProjectionMatrix13Reg 1 -#define GlintModelViewProjectionMatrix13Off 0x89e8 - -#define GlintModelViewProjectionMatrix14 0x99f0 -#define GlintModelViewProjectionMatrix14Tag 0x033e -#define GlintModelViewProjectionMatrix14Reg 1 -#define GlintModelViewProjectionMatrix14Off 0x89f0 - -#define GlintModelViewProjectionMatrix15 0x99f8 -#define GlintModelViewProjectionMatrix15Tag 0x033f -#define GlintModelViewProjectionMatrix15Reg 1 -#define GlintModelViewProjectionMatrix15Off 0x89f8 - -#define GlintNormalMatrix0 0x9a00 -#define GlintNormalMatrix0Tag 0x0340 -#define GlintNormalMatrix0Reg 1 -#define GlintNormalMatrix0Off 0x8a00 - -#define GlintNormalMatrix1 0x9a08 -#define GlintNormalMatrix1Tag 0x0341 -#define GlintNormalMatrix1Reg 1 -#define GlintNormalMatrix1Off 0x8a08 - -#define GlintNormalMatrix2 0x9a10 -#define GlintNormalMatrix2Tag 0x0342 -#define GlintNormalMatrix2Reg 1 -#define GlintNormalMatrix2Off 0x8a10 - -#define GlintNormalMatrix3 0x9a18 -#define GlintNormalMatrix3Tag 0x0343 -#define GlintNormalMatrix3Reg 1 -#define GlintNormalMatrix3Off 0x8a18 - -#define GlintNormalMatrix4 0x9a20 -#define GlintNormalMatrix4Tag 0x0344 -#define GlintNormalMatrix4Reg 1 -#define GlintNormalMatrix4Off 0x8a20 - -#define GlintNormalMatrix5 0x9a28 -#define GlintNormalMatrix5Tag 0x0345 -#define GlintNormalMatrix5Reg 1 -#define GlintNormalMatrix5Off 0x8a28 - -#define GlintNormalMatrix6 0x9a30 -#define GlintNormalMatrix6Tag 0x0346 -#define GlintNormalMatrix6Reg 1 -#define GlintNormalMatrix6Off 0x8a30 - -#define GlintNormalMatrix7 0x9a38 -#define GlintNormalMatrix7Tag 0x0347 -#define GlintNormalMatrix7Reg 1 -#define GlintNormalMatrix7Off 0x8a38 - -#define GlintNormalMatrix8 0x9a40 -#define GlintNormalMatrix8Tag 0x0348 -#define GlintNormalMatrix8Reg 1 -#define GlintNormalMatrix8Off 0x8a40 - -#define GlintTextureMatrix0 0x9a80 -#define GlintTextureMatrix0Tag 0x0350 -#define GlintTextureMatrix0Reg 1 -#define GlintTextureMatrix0Off 0x8a80 - -#define GlintTextureMatrix1 0x9a88 -#define GlintTextureMatrix1Tag 0x0351 -#define GlintTextureMatrix1Reg 1 -#define GlintTextureMatrix1Off 0x8a88 - -#define GlintTextureMatrix2 0x9a90 -#define GlintTextureMatrix2Tag 0x0352 -#define GlintTextureMatrix2Reg 1 -#define GlintTextureMatrix2Off 0x8a90 - -#define GlintTextureMatrix3 0x9a98 -#define GlintTextureMatrix3Tag 0x0353 -#define GlintTextureMatrix3Reg 1 -#define GlintTextureMatrix3Off 0x8a98 - -#define GlintTextureMatrix4 0x9aa0 -#define GlintTextureMatrix4Tag 0x0354 -#define GlintTextureMatrix4Reg 1 -#define GlintTextureMatrix4Off 0x8aa0 - -#define GlintTextureMatrix5 0x9aa8 -#define GlintTextureMatrix5Tag 0x0355 -#define GlintTextureMatrix5Reg 1 -#define GlintTextureMatrix5Off 0x8aa8 - -#define GlintTextureMatrix6 0x9ab0 -#define GlintTextureMatrix6Tag 0x0356 -#define GlintTextureMatrix6Reg 1 -#define GlintTextureMatrix6Off 0x8ab0 - -#define GlintTextureMatrix7 0x9ab8 -#define GlintTextureMatrix7Tag 0x0357 -#define GlintTextureMatrix7Reg 1 -#define GlintTextureMatrix7Off 0x8ab8 - -#define GlintTextureMatrix8 0x9ac0 -#define GlintTextureMatrix8Tag 0x0358 -#define GlintTextureMatrix8Reg 1 -#define GlintTextureMatrix8Off 0x8ac0 - -#define GlintTextureMatrix9 0x9ac8 -#define GlintTextureMatrix9Tag 0x0359 -#define GlintTextureMatrix9Reg 1 -#define GlintTextureMatrix9Off 0x8ac8 - -#define GlintTextureMatrix10 0x9ad0 -#define GlintTextureMatrix10Tag 0x035a -#define GlintTextureMatrix10Reg 1 -#define GlintTextureMatrix10Off 0x8ad0 - -#define GlintTextureMatrix11 0x9ad8 -#define GlintTextureMatrix11Tag 0x035b -#define GlintTextureMatrix11Reg 1 -#define GlintTextureMatrix11Off 0x8ad8 - -#define GlintTextureMatrix12 0x9ae0 -#define GlintTextureMatrix12Tag 0x035c -#define GlintTextureMatrix12Reg 1 -#define GlintTextureMatrix12Off 0x8ae0 - -#define GlintTextureMatrix13 0x9ae8 -#define GlintTextureMatrix13Tag 0x035d -#define GlintTextureMatrix13Reg 1 -#define GlintTextureMatrix13Off 0x8ae8 - -#define GlintTextureMatrix14 0x9af0 -#define GlintTextureMatrix14Tag 0x035e -#define GlintTextureMatrix14Reg 1 -#define GlintTextureMatrix14Off 0x8af0 - -#define GlintTextureMatrix15 0x9af8 -#define GlintTextureMatrix15Tag 0x035f -#define GlintTextureMatrix15Reg 1 -#define GlintTextureMatrix15Off 0x8af8 - -#define GlintTexGen0 0x9b00 -#define GlintTexGen0Tag 0x0360 -#define GlintTexGen0Reg 1 -#define GlintTexGen0Off 0x8b00 - -#define GlintTexGen1 0x9b08 -#define GlintTexGen1Tag 0x0361 -#define GlintTexGen1Reg 1 -#define GlintTexGen1Off 0x8b08 - -#define GlintTexGen2 0x9b10 -#define GlintTexGen2Tag 0x0362 -#define GlintTexGen2Reg 1 -#define GlintTexGen2Off 0x8b10 - -#define GlintTexGen3 0x9b18 -#define GlintTexGen3Tag 0x0363 -#define GlintTexGen3Reg 1 -#define GlintTexGen3Off 0x8b18 - -#define GlintTexGen4 0x9b20 -#define GlintTexGen4Tag 0x0364 -#define GlintTexGen4Reg 1 -#define GlintTexGen4Off 0x8b20 - -#define GlintTexGen5 0x9b28 -#define GlintTexGen5Tag 0x0365 -#define GlintTexGen5Reg 1 -#define GlintTexGen5Off 0x8b28 - -#define GlintTexGen6 0x9b30 -#define GlintTexGen6Tag 0x0366 -#define GlintTexGen6Reg 1 -#define GlintTexGen6Off 0x8b30 - -#define GlintTexGen7 0x9b38 -#define GlintTexGen7Tag 0x0367 -#define GlintTexGen7Reg 1 -#define GlintTexGen7Off 0x8b38 - -#define GlintTexGen8 0x9b40 -#define GlintTexGen8Tag 0x0368 -#define GlintTexGen8Reg 1 -#define GlintTexGen8Off 0x8b40 - -#define GlintTexGen9 0x9b48 -#define GlintTexGen9Tag 0x0369 -#define GlintTexGen9Reg 1 -#define GlintTexGen9Off 0x8b48 - -#define GlintTexGen10 0x9b50 -#define GlintTexGen10Tag 0x036a -#define GlintTexGen10Reg 1 -#define GlintTexGen10Off 0x8b50 - -#define GlintTexGen11 0x9b58 -#define GlintTexGen11Tag 0x036b -#define GlintTexGen11Reg 1 -#define GlintTexGen11Off 0x8b58 - -#define GlintTexGen12 0x9b60 -#define GlintTexGen12Tag 0x036c -#define GlintTexGen12Reg 1 -#define GlintTexGen12Off 0x8b60 - -#define GlintTexGen13 0x9b68 -#define GlintTexGen13Tag 0x036d -#define GlintTexGen13Reg 1 -#define GlintTexGen13Off 0x8b68 - -#define GlintTexGen14 0x9b70 -#define GlintTexGen14Tag 0x036e -#define GlintTexGen14Reg 1 -#define GlintTexGen14Off 0x8b70 - -#define GlintTexGen15 0x9b78 -#define GlintTexGen15Tag 0x036f -#define GlintTexGen15Reg 1 -#define GlintTexGen15Off 0x8b78 - -#define GlintViewPortScaleX 0x9b80 -#define GlintViewPortScaleXTag 0x0370 -#define GlintViewPortScaleXReg 1 -#define GlintViewPortScaleXOff 0x8b80 - -#define GlintViewPortScaleY 0x9b88 -#define GlintViewPortScaleYTag 0x0371 -#define GlintViewPortScaleYReg 1 -#define GlintViewPortScaleYOff 0x8b88 - -#define GlintViewPortScaleZ 0x9b90 -#define GlintViewPortScaleZTag 0x0372 -#define GlintViewPortScaleZReg 1 -#define GlintViewPortScaleZOff 0x8b90 - -#define GlintViewPortOffsetX 0x9b98 -#define GlintViewPortOffsetXTag 0x0373 -#define GlintViewPortOffsetXReg 1 -#define GlintViewPortOffsetXOff 0x8b98 - -#define GlintViewPortOffsetY 0x9ba0 -#define GlintViewPortOffsetYTag 0x0374 -#define GlintViewPortOffsetYReg 1 -#define GlintViewPortOffsetYOff 0x8ba0 - -#define GlintViewPortOffsetZ 0x9ba8 -#define GlintViewPortOffsetZTag 0x0375 -#define GlintViewPortOffsetZReg 1 -#define GlintViewPortOffsetZOff 0x8ba8 - -#define GlintFogDensity 0x9bb0 -#define GlintFogDensityTag 0x0376 -#define GlintFogDensityReg 1 -#define GlintFogDensityOff 0x8bb0 - -#define GlintFogScale 0x9bb8 -#define GlintFogScaleTag 0x0377 -#define GlintFogScaleReg 1 -#define GlintFogScaleOff 0x8bb8 - -#define GlintFogEnd 0x9bc0 -#define GlintFogEndTag 0x0378 -#define GlintFogEndReg 1 -#define GlintFogEndOff 0x8bc0 - -#define GlintPolygonOffsetFactor 0x9bc8 -#define GlintPolygonOffsetFactorTag 0x0379 -#define GlintPolygonOffsetFactorReg 1 -#define GlintPolygonOffsetFactorOff 0x8bc8 - -#define GlintPolygonOffsetBias 0x9bd0 -#define GlintPolygonOffsetBiasTag 0x037a -#define GlintPolygonOffsetBiasReg 1 -#define GlintPolygonOffsetBiasOff 0x8bd0 - -#define GlintLineClipLengthThreshold 0x9bd8 -#define GlintLineClipLengthThresholdTag 0x037b -#define GlintLineClipLengthThresholdReg 1 -#define GlintLineClipLengthThresholdOff 0x8bd8 - -#define GlintTriangleClipAreaThreshold 0x9be0 -#define GlintTriangleClipAreaThresholdTag 0x037c -#define GlintTriangleClipAreaThresholdReg 1 -#define GlintTriangleClipAreaThresholdOff 0x8be0 - -#define GlintRasterPosXIncrement 0x9be8 -#define GlintRasterPosXIncrementTag 0x037d -#define GlintRasterPosXIncrementReg 1 -#define GlintRasterPosXIncrementOff 0x8be8 - -#define GlintRasterPosYIncrement 0x9bf0 -#define GlintRasterPosYIncrementTag 0x037e -#define GlintRasterPosYIncrementReg 1 -#define GlintRasterPosYIncrementOff 0x8bf0 - -#define GlintUserClip0X 0x9c00 -#define GlintUserClip0XTag 0x0380 -#define GlintUserClip0XReg 1 -#define GlintUserClip0XOff 0x8c00 - -#define GlintUserClip0Y 0x9c08 -#define GlintUserClip0YTag 0x0381 -#define GlintUserClip0YReg 1 -#define GlintUserClip0YOff 0x8c08 - -#define GlintUserClip0Z 0x9c10 -#define GlintUserClip0ZTag 0x0382 -#define GlintUserClip0ZReg 1 -#define GlintUserClip0ZOff 0x8c10 - -#define GlintUserClip0W 0x9c18 -#define GlintUserClip0WTag 0x0383 -#define GlintUserClip0WReg 1 -#define GlintUserClip0WOff 0x8c18 - -#define GlintUserClip1X 0x9c20 -#define GlintUserClip1XTag 0x0384 -#define GlintUserClip1XReg 1 -#define GlintUserClip1XOff 0x8c20 - -#define GlintUserClip1Y 0x9c28 -#define GlintUserClip1YTag 0x0385 -#define GlintUserClip1YReg 1 -#define GlintUserClip1YOff 0x8c28 - -#define GlintUserClip1Z 0x9c30 -#define GlintUserClip1ZTag 0x0386 -#define GlintUserClip1ZReg 1 -#define GlintUserClip1ZOff 0x8c30 - -#define GlintUserClip1W 0x9c38 -#define GlintUserClip1WTag 0x0387 -#define GlintUserClip1WReg 1 -#define GlintUserClip1WOff 0x8c38 - -#define GlintUserClip2X 0x9c40 -#define GlintUserClip2XTag 0x0388 -#define GlintUserClip2XReg 1 -#define GlintUserClip2XOff 0x8c40 - -#define GlintUserClip2Y 0x9c48 -#define GlintUserClip2YTag 0x0389 -#define GlintUserClip2YReg 1 -#define GlintUserClip2YOff 0x8c48 - -#define GlintUserClip2Z 0x9c50 -#define GlintUserClip2ZTag 0x038a -#define GlintUserClip2ZReg 1 -#define GlintUserClip2ZOff 0x8c50 - -#define GlintUserClip2W 0x9c58 -#define GlintUserClip2WTag 0x038b -#define GlintUserClip2WReg 1 -#define GlintUserClip2WOff 0x8c58 - -#define GlintUserClip3X 0x9c60 -#define GlintUserClip3XTag 0x038c -#define GlintUserClip3XReg 1 -#define GlintUserClip3XOff 0x8c60 - -#define GlintUserClip3Y 0x9c68 -#define GlintUserClip3YTag 0x038d -#define GlintUserClip3YReg 1 -#define GlintUserClip3YOff 0x8c68 - -#define GlintUserClip3Z 0x9c70 -#define GlintUserClip3ZTag 0x038e -#define GlintUserClip3ZReg 1 -#define GlintUserClip3ZOff 0x8c70 - -#define GlintUserClip3W 0x9c78 -#define GlintUserClip3WTag 0x038f -#define GlintUserClip3WReg 1 -#define GlintUserClip3WOff 0x8c78 - -#define GlintUserClip4X 0x9c80 -#define GlintUserClip4XTag 0x0390 -#define GlintUserClip4XReg 1 -#define GlintUserClip4XOff 0x8c80 - -#define GlintUserClip4Y 0x9c88 -#define GlintUserClip4YTag 0x0391 -#define GlintUserClip4YReg 1 -#define GlintUserClip4YOff 0x8c88 - -#define GlintUserClip4Z 0x9c90 -#define GlintUserClip4ZTag 0x0392 -#define GlintUserClip4ZReg 1 -#define GlintUserClip4ZOff 0x8c90 - -#define GlintUserClip4W 0x9c98 -#define GlintUserClip4WTag 0x0393 -#define GlintUserClip4WReg 1 -#define GlintUserClip4WOff 0x8c98 - -#define GlintUserClip5X 0x9ca0 -#define GlintUserClip5XTag 0x0394 -#define GlintUserClip5XReg 1 -#define GlintUserClip5XOff 0x8ca0 - -#define GlintUserClip5Y 0x9ca8 -#define GlintUserClip5YTag 0x0395 -#define GlintUserClip5YReg 1 -#define GlintUserClip5YOff 0x8ca8 - -#define GlintUserClip5Z 0x9cb0 -#define GlintUserClip5ZTag 0x0396 -#define GlintUserClip5ZReg 1 -#define GlintUserClip5ZOff 0x8cb0 - -#define GlintUserClip5W 0x9cb8 -#define GlintUserClip5WTag 0x0397 -#define GlintUserClip5WReg 1 -#define GlintUserClip5WOff 0x8cb8 - -#define GlintRasterPosXOffset 0x9ce8 -#define GlintRasterPosXOffsetTag 0x039d -#define GlintRasterPosXOffsetReg 1 -#define GlintRasterPosXOffsetOff 0x8ce8 - -#define GlintRasterPosYOffset 0x9cf0 -#define GlintRasterPosYOffsetTag 0x039e -#define GlintRasterPosYOffsetReg 1 -#define GlintRasterPosYOffsetOff 0x8cf0 - -#define GlintAttenuationCutOff 0x9cf8 -#define GlintAttenuationCutOffTag 0x039f -#define GlintAttenuationCutOffReg 1 -#define GlintAttenuationCutOffOff 0x8cf8 - -#define GlintLight0Mode 0x9d00 -#define GlintLight0ModeTag 0x03a0 -#define GlintLight0ModeReg 1 -#define GlintLight0ModeOff 0x8d00 - -#define GlintLight0AmbientIntensityRed 0x9d08 -#define GlintLight0AmbientIntensityRedTag 0x03a1 -#define GlintLight0AmbientIntensityRedReg 1 -#define GlintLight0AmbientIntensityRedOff 0x8d08 - -#define GlintLight0AmbientIntensityGreen 0x9d10 -#define GlintLight0AmbientIntensityGreenTag 0x03a2 -#define GlintLight0AmbientIntensityGreenReg 1 -#define GlintLight0AmbientIntensityGreenOff 0x8d10 - -#define GlintLight0AmbientIntensityBlue 0x9d18 -#define GlintLight0AmbientIntensityBlueTag 0x03a3 -#define GlintLight0AmbientIntensityBlueReg 1 -#define GlintLight0AmbientIntensityBlueOff 0x8d18 - -#define GlintLight0DiffuseIntensityRed 0x9d20 -#define GlintLight0DiffuseIntensityRedTag 0x03a4 -#define GlintLight0DiffuseIntensityRedReg 1 -#define GlintLight0DiffuseIntensityRedOff 0x8d20 - -#define GlintLight0DiffuseIntensityGreen 0x9d28 -#define GlintLight0DiffuseIntensityGreenTag 0x03a5 -#define GlintLight0DiffuseIntensityGreenReg 1 -#define GlintLight0DiffuseIntensityGreenOff 0x8d28 - -#define GlintLight0DiffuseIntensityBlue 0x9d30 -#define GlintLight0DiffuseIntensityBlueTag 0x03a6 -#define GlintLight0DiffuseIntensityBlueReg 1 -#define GlintLight0DiffuseIntensityBlueOff 0x8d30 - -#define GlintLight0SpecularIntensityRed 0x9d38 -#define GlintLight0SpecularIntensityRedTag 0x03a7 -#define GlintLight0SpecularIntensityRedReg 1 -#define GlintLight0SpecularIntensityRedOff 0x8d38 - -#define GlintLight0SpecularIntensityGreen 0x9d40 -#define GlintLight0SpecularIntensityGreenTag 0x03a8 -#define GlintLight0SpecularIntensityGreenReg 1 -#define GlintLight0SpecularIntensityGreenOff 0x8d40 - -#define GlintLight0SpecularIntensityBlue 0x9d48 -#define GlintLight0SpecularIntensityBlueTag 0x03a9 -#define GlintLight0SpecularIntensityBlueReg 1 -#define GlintLight0SpecularIntensityBlueOff 0x8d48 - -#define GlintLight0PositionX 0x9d50 -#define GlintLight0PositionXTag 0x03aa -#define GlintLight0PositionXReg 1 -#define GlintLight0PositionXOff 0x8d50 - -#define GlintLight0PositionY 0x9d58 -#define GlintLight0PositionYTag 0x03ab -#define GlintLight0PositionYReg 1 -#define GlintLight0PositionYOff 0x8d58 - -#define GlintLight0PositionZ 0x9d60 -#define GlintLight0PositionZTag 0x03ac -#define GlintLight0PositionZReg 1 -#define GlintLight0PositionZOff 0x8d60 - -#define GlintLight0PositionW 0x9d68 -#define GlintLight0PositionWTag 0x03ad -#define GlintLight0PositionWReg 1 -#define GlintLight0PositionWOff 0x8d68 - -#define GlintLight0SpotlightDirectionX 0x9d70 -#define GlintLight0SpotlightDirectionXTag 0x03ae -#define GlintLight0SpotlightDirectionXReg 1 -#define GlintLight0SpotlightDirectionXOff 0x8d70 - -#define GlintLight0SpotlightDirectionY 0x9d78 -#define GlintLight0SpotlightDirectionYTag 0x03af -#define GlintLight0SpotlightDirectionYReg 1 -#define GlintLight0SpotlightDirectionYOff 0x8d78 - -#define GlintLight0SpotlightDirectionZ 0x9d80 -#define GlintLight0SpotlightDirectionZTag 0x03b0 -#define GlintLight0SpotlightDirectionZReg 1 -#define GlintLight0SpotlightDirectionZOff 0x8d80 - -#define GlintLight0SpotlightExponent 0x9d88 -#define GlintLight0SpotlightExponentTag 0x03b1 -#define GlintLight0SpotlightExponentReg 1 -#define GlintLight0SpotlightExponentOff 0x8d88 - -#define GlintLight0CosSpotlightCutoffAngle 0x9d90 -#define GlintLight0CosSpotlightCutoffAngleTag 0x03b2 -#define GlintLight0CosSpotlightCutoffAngleReg 1 -#define GlintLight0CosSpotlightCutoffAngleOff 0x8d90 - -#define GlintLight0ConstantAttenuation 0x9d98 -#define GlintLight0ConstantAttenuationTag 0x03b3 -#define GlintLight0ConstantAttenuationReg 1 -#define GlintLight0ConstantAttenuationOff 0x8d98 - -#define GlintLight0LinearAttenuation 0x9da0 -#define GlintLight0LinearAttenuationTag 0x03b4 -#define GlintLight0LinearAttenuationReg 1 -#define GlintLight0LinearAttenuationOff 0x8da0 - -#define GlintLight0QuadraticAttenuation 0x9da8 -#define GlintLight0QuadraticAttenuationTag 0x03b5 -#define GlintLight0QuadraticAttenuationReg 1 -#define GlintLight0QuadraticAttenuationOff 0x8da8 - -#define GlintLight1Mode 0x9db0 -#define GlintLight1ModeTag 0x03b6 -#define GlintLight1ModeReg 1 -#define GlintLight1ModeOff 0x8db0 - -#define GlintLight1AmbientIntensityRed 0x9db8 -#define GlintLight1AmbientIntensityRedTag 0x03b7 -#define GlintLight1AmbientIntensityRedReg 1 -#define GlintLight1AmbientIntensityRedOff 0x8db8 - -#define GlintLight1AmbientIntensityGreen 0x9dc0 -#define GlintLight1AmbientIntensityGreenTag 0x03b8 -#define GlintLight1AmbientIntensityGreenReg 1 -#define GlintLight1AmbientIntensityGreenOff 0x8dc0 - -#define GlintLight1AmbientIntensityBlue 0x9dc8 -#define GlintLight1AmbientIntensityBlueTag 0x03b9 -#define GlintLight1AmbientIntensityBlueReg 1 -#define GlintLight1AmbientIntensityBlueOff 0x8dc8 - -#define GlintLight1DiffuseIntensityRed 0x9dd0 -#define GlintLight1DiffuseIntensityRedTag 0x03ba -#define GlintLight1DiffuseIntensityRedReg 1 -#define GlintLight1DiffuseIntensityRedOff 0x8dd0 - -#define GlintLight1DiffuseIntensityGreen 0x9dd8 -#define GlintLight1DiffuseIntensityGreenTag 0x03bb -#define GlintLight1DiffuseIntensityGreenReg 1 -#define GlintLight1DiffuseIntensityGreenOff 0x8dd8 - -#define GlintLight1DiffuseIntensityBlue 0x9de0 -#define GlintLight1DiffuseIntensityBlueTag 0x03bc -#define GlintLight1DiffuseIntensityBlueReg 1 -#define GlintLight1DiffuseIntensityBlueOff 0x8de0 - -#define GlintLight1SpecularIntensityRed 0x9de8 -#define GlintLight1SpecularIntensityRedTag 0x03bd -#define GlintLight1SpecularIntensityRedReg 1 -#define GlintLight1SpecularIntensityRedOff 0x8de8 - -#define GlintLight1SpecularIntensityGreen 0x9df0 -#define GlintLight1SpecularIntensityGreenTag 0x03be -#define GlintLight1SpecularIntensityGreenReg 1 -#define GlintLight1SpecularIntensityGreenOff 0x8df0 - -#define GlintLight1SpecularIntensityBlue 0x9df8 -#define GlintLight1SpecularIntensityBlueTag 0x03bf -#define GlintLight1SpecularIntensityBlueReg 1 -#define GlintLight1SpecularIntensityBlueOff 0x8df8 - -#define GlintLight1PositionX 0x9e00 -#define GlintLight1PositionXTag 0x03c0 -#define GlintLight1PositionXReg 1 -#define GlintLight1PositionXOff 0x8e00 - -#define GlintLight1PositionY 0x9e08 -#define GlintLight1PositionYTag 0x03c1 -#define GlintLight1PositionYReg 1 -#define GlintLight1PositionYOff 0x8e08 - -#define GlintLight1PositionZ 0x9e10 -#define GlintLight1PositionZTag 0x03c2 -#define GlintLight1PositionZReg 1 -#define GlintLight1PositionZOff 0x8e10 - -#define GlintLight1PositionW 0x9e18 -#define GlintLight1PositionWTag 0x03c3 -#define GlintLight1PositionWReg 1 -#define GlintLight1PositionWOff 0x8e18 - -#define GlintLight1SpotlightDirectionX 0x9e20 -#define GlintLight1SpotlightDirectionXTag 0x03c4 -#define GlintLight1SpotlightDirectionXReg 1 -#define GlintLight1SpotlightDirectionXOff 0x8e20 - -#define GlintLight1SpotlightDirectionY 0x9e28 -#define GlintLight1SpotlightDirectionYTag 0x03c5 -#define GlintLight1SpotlightDirectionYReg 1 -#define GlintLight1SpotlightDirectionYOff 0x8e28 - -#define GlintLight1SpotlightDirectionZ 0x9e30 -#define GlintLight1SpotlightDirectionZTag 0x03c6 -#define GlintLight1SpotlightDirectionZReg 1 -#define GlintLight1SpotlightDirectionZOff 0x8e30 - -#define GlintLight1SpotlightExponent 0x9e38 -#define GlintLight1SpotlightExponentTag 0x03c7 -#define GlintLight1SpotlightExponentReg 1 -#define GlintLight1SpotlightExponentOff 0x8e38 - -#define GlintLight1CosSpotlightCutoffAngle 0x9e40 -#define GlintLight1CosSpotlightCutoffAngleTag 0x03c8 -#define GlintLight1CosSpotlightCutoffAngleReg 1 -#define GlintLight1CosSpotlightCutoffAngleOff 0x8e40 - -#define GlintLight1ConstantAttenuation 0x9e48 -#define GlintLight1ConstantAttenuationTag 0x03c9 -#define GlintLight1ConstantAttenuationReg 1 -#define GlintLight1ConstantAttenuationOff 0x8e48 - -#define GlintLight1LinearAttenuation 0x9e50 -#define GlintLight1LinearAttenuationTag 0x03ca -#define GlintLight1LinearAttenuationReg 1 -#define GlintLight1LinearAttenuationOff 0x8e50 - -#define GlintLight1QuadraticAttenuation 0x9e58 -#define GlintLight1QuadraticAttenuationTag 0x03cb -#define GlintLight1QuadraticAttenuationReg 1 -#define GlintLight1QuadraticAttenuationOff 0x8e58 - -#define GlintLight2Mode 0x9e60 -#define GlintLight2ModeTag 0x03cc -#define GlintLight2ModeReg 1 -#define GlintLight2ModeOff 0x8e60 - -#define GlintLight2AmbientIntensityRed 0x9e68 -#define GlintLight2AmbientIntensityRedTag 0x03cd -#define GlintLight2AmbientIntensityRedReg 1 -#define GlintLight2AmbientIntensityRedOff 0x8e68 - -#define GlintLight2AmbientIntensityGreen 0x9e70 -#define GlintLight2AmbientIntensityGreenTag 0x03ce -#define GlintLight2AmbientIntensityGreenReg 1 -#define GlintLight2AmbientIntensityGreenOff 0x8e70 - -#define GlintLight2AmbientIntensityBlue 0x9e78 -#define GlintLight2AmbientIntensityBlueTag 0x03cf -#define GlintLight2AmbientIntensityBlueReg 1 -#define GlintLight2AmbientIntensityBlueOff 0x8e78 - -#define GlintLight2DiffuseIntensityRed 0x9e80 -#define GlintLight2DiffuseIntensityRedTag 0x03d0 -#define GlintLight2DiffuseIntensityRedReg 1 -#define GlintLight2DiffuseIntensityRedOff 0x8e80 - -#define GlintLight2DiffuseIntensityGreen 0x9e88 -#define GlintLight2DiffuseIntensityGreenTag 0x03d1 -#define GlintLight2DiffuseIntensityGreenReg 1 -#define GlintLight2DiffuseIntensityGreenOff 0x8e88 - -#define GlintLight2DiffuseIntensityBlue 0x9e90 -#define GlintLight2DiffuseIntensityBlueTag 0x03d2 -#define GlintLight2DiffuseIntensityBlueReg 1 -#define GlintLight2DiffuseIntensityBlueOff 0x8e90 - -#define GlintLight2SpecularIntensityRed 0x9e98 -#define GlintLight2SpecularIntensityRedTag 0x03d3 -#define GlintLight2SpecularIntensityRedReg 1 -#define GlintLight2SpecularIntensityRedOff 0x8e98 - -#define GlintLight2SpecularIntensityGreen 0x9ea0 -#define GlintLight2SpecularIntensityGreenTag 0x03d4 -#define GlintLight2SpecularIntensityGreenReg 1 -#define GlintLight2SpecularIntensityGreenOff 0x8ea0 - -#define GlintLight2SpecularIntensityBlue 0x9ea8 -#define GlintLight2SpecularIntensityBlueTag 0x03d5 -#define GlintLight2SpecularIntensityBlueReg 1 -#define GlintLight2SpecularIntensityBlueOff 0x8ea8 - -#define GlintLight2PositionX 0x9eb0 -#define GlintLight2PositionXTag 0x03d6 -#define GlintLight2PositionXReg 1 -#define GlintLight2PositionXOff 0x8eb0 - -#define GlintLight2PositionY 0x9eb8 -#define GlintLight2PositionYTag 0x03d7 -#define GlintLight2PositionYReg 1 -#define GlintLight2PositionYOff 0x8eb8 - -#define GlintLight2PositionZ 0x9ec0 -#define GlintLight2PositionZTag 0x03d8 -#define GlintLight2PositionZReg 1 -#define GlintLight2PositionZOff 0x8ec0 - -#define GlintLight2PositionW 0x9ec8 -#define GlintLight2PositionWTag 0x03d9 -#define GlintLight2PositionWReg 1 -#define GlintLight2PositionWOff 0x8ec8 - -#define GlintLight2SpotlightDirectionX 0x9ed0 -#define GlintLight2SpotlightDirectionXTag 0x03da -#define GlintLight2SpotlightDirectionXReg 1 -#define GlintLight2SpotlightDirectionXOff 0x8ed0 - -#define GlintLight2SpotlightDirectionY 0x9ed8 -#define GlintLight2SpotlightDirectionYTag 0x03db -#define GlintLight2SpotlightDirectionYReg 1 -#define GlintLight2SpotlightDirectionYOff 0x8ed8 - -#define GlintLight2SpotlightDirectionZ 0x9ee0 -#define GlintLight2SpotlightDirectionZTag 0x03dc -#define GlintLight2SpotlightDirectionZReg 1 -#define GlintLight2SpotlightDirectionZOff 0x8ee0 - -#define GlintLight2SpotlightExponent 0x9ee8 -#define GlintLight2SpotlightExponentTag 0x03dd -#define GlintLight2SpotlightExponentReg 1 -#define GlintLight2SpotlightExponentOff 0x8ee8 - -#define GlintLight2CosSpotlightCutoffAngle 0x9ef0 -#define GlintLight2CosSpotlightCutoffAngleTag 0x03de -#define GlintLight2CosSpotlightCutoffAngleReg 1 -#define GlintLight2CosSpotlightCutoffAngleOff 0x8ef0 - -#define GlintLight2ConstantAttenuation 0x9ef8 -#define GlintLight2ConstantAttenuationTag 0x03df -#define GlintLight2ConstantAttenuationReg 1 -#define GlintLight2ConstantAttenuationOff 0x8ef8 - -#define GlintLight2LinearAttenuation 0x9f00 -#define GlintLight2LinearAttenuationTag 0x03e0 -#define GlintLight2LinearAttenuationReg 1 -#define GlintLight2LinearAttenuationOff 0x8f00 - -#define GlintLight2QuadraticAttenuation 0x9f08 -#define GlintLight2QuadraticAttenuationTag 0x03e1 -#define GlintLight2QuadraticAttenuationReg 1 -#define GlintLight2QuadraticAttenuationOff 0x8f08 - -#define GlintLight3Mode 0x9f10 -#define GlintLight3ModeTag 0x03e2 -#define GlintLight3ModeReg 1 -#define GlintLight3ModeOff 0x8f10 - -#define GlintLight3AmbientIntensityRed 0x9f18 -#define GlintLight3AmbientIntensityRedTag 0x03e3 -#define GlintLight3AmbientIntensityRedReg 1 -#define GlintLight3AmbientIntensityRedOff 0x8f18 - -#define GlintLight3AmbientIntensityGreen 0x9f20 -#define GlintLight3AmbientIntensityGreenTag 0x03e4 -#define GlintLight3AmbientIntensityGreenReg 1 -#define GlintLight3AmbientIntensityGreenOff 0x8f20 - -#define GlintLight3AmbientIntensityBlue 0x9f28 -#define GlintLight3AmbientIntensityBlueTag 0x03e5 -#define GlintLight3AmbientIntensityBlueReg 1 -#define GlintLight3AmbientIntensityBlueOff 0x8f28 - -#define GlintLight3DiffuseIntensityRed 0x9f30 -#define GlintLight3DiffuseIntensityRedTag 0x03e6 -#define GlintLight3DiffuseIntensityRedReg 1 -#define GlintLight3DiffuseIntensityRedOff 0x8f30 - -#define GlintLight3DiffuseIntensityGreen 0x9f38 -#define GlintLight3DiffuseIntensityGreenTag 0x03e7 -#define GlintLight3DiffuseIntensityGreenReg 1 -#define GlintLight3DiffuseIntensityGreenOff 0x8f38 - -#define GlintLight3DiffuseIntensityBlue 0x9f40 -#define GlintLight3DiffuseIntensityBlueTag 0x03e8 -#define GlintLight3DiffuseIntensityBlueReg 1 -#define GlintLight3DiffuseIntensityBlueOff 0x8f40 - -#define GlintLight3SpecularIntensityRed 0x9f48 -#define GlintLight3SpecularIntensityRedTag 0x03e9 -#define GlintLight3SpecularIntensityRedReg 1 -#define GlintLight3SpecularIntensityRedOff 0x8f48 - -#define GlintLight3SpecularIntensityGreen 0x9f50 -#define GlintLight3SpecularIntensityGreenTag 0x03ea -#define GlintLight3SpecularIntensityGreenReg 1 -#define GlintLight3SpecularIntensityGreenOff 0x8f50 - -#define GlintLight3SpecularIntensityBlue 0x9f58 -#define GlintLight3SpecularIntensityBlueTag 0x03eb -#define GlintLight3SpecularIntensityBlueReg 1 -#define GlintLight3SpecularIntensityBlueOff 0x8f58 - -#define GlintLight3PositionX 0x9f60 -#define GlintLight3PositionXTag 0x03ec -#define GlintLight3PositionXReg 1 -#define GlintLight3PositionXOff 0x8f60 - -#define GlintLight3PositionY 0x9f68 -#define GlintLight3PositionYTag 0x03ed -#define GlintLight3PositionYReg 1 -#define GlintLight3PositionYOff 0x8f68 - -#define GlintLight3PositionZ 0x9f70 -#define GlintLight3PositionZTag 0x03ee -#define GlintLight3PositionZReg 1 -#define GlintLight3PositionZOff 0x8f70 - -#define GlintLight3PositionW 0x9f78 -#define GlintLight3PositionWTag 0x03ef -#define GlintLight3PositionWReg 1 -#define GlintLight3PositionWOff 0x8f78 - -#define GlintLight3SpotlightDirectionX 0x9f80 -#define GlintLight3SpotlightDirectionXTag 0x03f0 -#define GlintLight3SpotlightDirectionXReg 1 -#define GlintLight3SpotlightDirectionXOff 0x8f80 - -#define GlintLight3SpotlightDirectionY 0x9f88 -#define GlintLight3SpotlightDirectionYTag 0x03f1 -#define GlintLight3SpotlightDirectionYReg 1 -#define GlintLight3SpotlightDirectionYOff 0x8f88 - -#define GlintLight3SpotlightDirectionZ 0x9f90 -#define GlintLight3SpotlightDirectionZTag 0x03f2 -#define GlintLight3SpotlightDirectionZReg 1 -#define GlintLight3SpotlightDirectionZOff 0x8f90 - -#define GlintLight3SpotlightExponent 0x9f98 -#define GlintLight3SpotlightExponentTag 0x03f3 -#define GlintLight3SpotlightExponentReg 1 -#define GlintLight3SpotlightExponentOff 0x8f98 - -#define GlintLight3CosSpotlightCutoffAngle 0x9fa0 -#define GlintLight3CosSpotlightCutoffAngleTag 0x03f4 -#define GlintLight3CosSpotlightCutoffAngleReg 1 -#define GlintLight3CosSpotlightCutoffAngleOff 0x8fa0 - -#define GlintLight3ConstantAttenuation 0x9fa8 -#define GlintLight3ConstantAttenuationTag 0x03f5 -#define GlintLight3ConstantAttenuationReg 1 -#define GlintLight3ConstantAttenuationOff 0x8fa8 - -#define GlintLight3LinearAttenuation 0x9fb0 -#define GlintLight3LinearAttenuationTag 0x03f6 -#define GlintLight3LinearAttenuationReg 1 -#define GlintLight3LinearAttenuationOff 0x8fb0 - -#define GlintLight3QuadraticAttenuation 0x9fb8 -#define GlintLight3QuadraticAttenuationTag 0x03f7 -#define GlintLight3QuadraticAttenuationReg 1 -#define GlintLight3QuadraticAttenuationOff 0x8fb8 - -#define GlintLight4Mode 0x9fc0 -#define GlintLight4ModeTag 0x03f8 -#define GlintLight4ModeReg 1 -#define GlintLight4ModeOff 0x8fc0 - -#define GlintLight4AmbientIntensityRed 0x9fc8 -#define GlintLight4AmbientIntensityRedTag 0x03f9 -#define GlintLight4AmbientIntensityRedReg 1 -#define GlintLight4AmbientIntensityRedOff 0x8fc8 - -#define GlintLight4AmbientIntensityGreen 0x9fd0 -#define GlintLight4AmbientIntensityGreenTag 0x03fa -#define GlintLight4AmbientIntensityGreenReg 1 -#define GlintLight4AmbientIntensityGreenOff 0x8fd0 - -#define GlintLight4AmbientIntensityBlue 0x9fd8 -#define GlintLight4AmbientIntensityBlueTag 0x03fb -#define GlintLight4AmbientIntensityBlueReg 1 -#define GlintLight4AmbientIntensityBlueOff 0x8fd8 - -#define GlintLight4DiffuseIntensityRed 0x9fe0 -#define GlintLight4DiffuseIntensityRedTag 0x03fc -#define GlintLight4DiffuseIntensityRedReg 1 -#define GlintLight4DiffuseIntensityRedOff 0x8fe0 - -#define GlintLight4DiffuseIntensityGreen 0x9fe8 -#define GlintLight4DiffuseIntensityGreenTag 0x03fd -#define GlintLight4DiffuseIntensityGreenReg 1 -#define GlintLight4DiffuseIntensityGreenOff 0x8fe8 - -#define GlintLight4DiffuseIntensityBlue 0x9ff0 -#define GlintLight4DiffuseIntensityBlueTag 0x03fe -#define GlintLight4DiffuseIntensityBlueReg 1 -#define GlintLight4DiffuseIntensityBlueOff 0x8ff0 - -#define GlintLight4SpecularIntensityRed 0x9ff8 -#define GlintLight4SpecularIntensityRedTag 0x03ff -#define GlintLight4SpecularIntensityRedReg 1 -#define GlintLight4SpecularIntensityRedOff 0x8ff8 - -#define GlintLight4SpecularIntensityGreen 0xa000 -#define GlintLight4SpecularIntensityGreenTag 0x0400 -#define GlintLight4SpecularIntensityGreenReg 1 -#define GlintLight4SpecularIntensityGreenOff 0x9000 - -#define GlintLight4SpecularIntensityBlue 0xa008 -#define GlintLight4SpecularIntensityBlueTag 0x0401 -#define GlintLight4SpecularIntensityBlueReg 1 -#define GlintLight4SpecularIntensityBlueOff 0x9008 - -#define GlintLight4PositionX 0xa010 -#define GlintLight4PositionXTag 0x0402 -#define GlintLight4PositionXReg 1 -#define GlintLight4PositionXOff 0x9010 - -#define GlintLight4PositionY 0xa018 -#define GlintLight4PositionYTag 0x0403 -#define GlintLight4PositionYReg 1 -#define GlintLight4PositionYOff 0x9018 - -#define GlintLight4PositionZ 0xa020 -#define GlintLight4PositionZTag 0x0404 -#define GlintLight4PositionZReg 1 -#define GlintLight4PositionZOff 0x9020 - -#define GlintLight4PositionW 0xa028 -#define GlintLight4PositionWTag 0x0405 -#define GlintLight4PositionWReg 1 -#define GlintLight4PositionWOff 0x9028 - -#define GlintLight4SpotlightDirectionX 0xa030 -#define GlintLight4SpotlightDirectionXTag 0x0406 -#define GlintLight4SpotlightDirectionXReg 1 -#define GlintLight4SpotlightDirectionXOff 0x9030 - -#define GlintLight4SpotlightDirectionY 0xa038 -#define GlintLight4SpotlightDirectionYTag 0x0407 -#define GlintLight4SpotlightDirectionYReg 1 -#define GlintLight4SpotlightDirectionYOff 0x9038 - -#define GlintLight4SpotlightDirectionZ 0xa040 -#define GlintLight4SpotlightDirectionZTag 0x0408 -#define GlintLight4SpotlightDirectionZReg 1 -#define GlintLight4SpotlightDirectionZOff 0x9040 - -#define GlintLight4SpotlightExponent 0xa048 -#define GlintLight4SpotlightExponentTag 0x0409 -#define GlintLight4SpotlightExponentReg 1 -#define GlintLight4SpotlightExponentOff 0x9048 - -#define GlintLight4CosSpotlightCutoffAngle 0xa050 -#define GlintLight4CosSpotlightCutoffAngleTag 0x040a -#define GlintLight4CosSpotlightCutoffAngleReg 1 -#define GlintLight4CosSpotlightCutoffAngleOff 0x9050 - -#define GlintLight4ConstantAttenuation 0xa058 -#define GlintLight4ConstantAttenuationTag 0x040b -#define GlintLight4ConstantAttenuationReg 1 -#define GlintLight4ConstantAttenuationOff 0x9058 - -#define GlintLight4LinearAttenuation 0xa060 -#define GlintLight4LinearAttenuationTag 0x040c -#define GlintLight4LinearAttenuationReg 1 -#define GlintLight4LinearAttenuationOff 0x9060 - -#define GlintLight4QuadraticAttenuation 0xa068 -#define GlintLight4QuadraticAttenuationTag 0x040d -#define GlintLight4QuadraticAttenuationReg 1 -#define GlintLight4QuadraticAttenuationOff 0x9068 - -#define GlintLight5Mode 0xa070 -#define GlintLight5ModeTag 0x040e -#define GlintLight5ModeReg 1 -#define GlintLight5ModeOff 0x9070 - -#define GlintLight5AmbientIntensityRed 0xa078 -#define GlintLight5AmbientIntensityRedTag 0x040f -#define GlintLight5AmbientIntensityRedReg 1 -#define GlintLight5AmbientIntensityRedOff 0x9078 - -#define GlintLight5AmbientIntensityGreen 0xa080 -#define GlintLight5AmbientIntensityGreenTag 0x0410 -#define GlintLight5AmbientIntensityGreenReg 1 -#define GlintLight5AmbientIntensityGreenOff 0x9080 - -#define GlintLight5AmbientIntensityBlue 0xa088 -#define GlintLight5AmbientIntensityBlueTag 0x0411 -#define GlintLight5AmbientIntensityBlueReg 1 -#define GlintLight5AmbientIntensityBlueOff 0x9088 - -#define GlintLight5DiffuseIntensityRed 0xa090 -#define GlintLight5DiffuseIntensityRedTag 0x0412 -#define GlintLight5DiffuseIntensityRedReg 1 -#define GlintLight5DiffuseIntensityRedOff 0x9090 - -#define GlintLight5DiffuseIntensityGreen 0xa098 -#define GlintLight5DiffuseIntensityGreenTag 0x0413 -#define GlintLight5DiffuseIntensityGreenReg 1 -#define GlintLight5DiffuseIntensityGreenOff 0x9098 - -#define GlintLight5DiffuseIntensityBlue 0xa0a0 -#define GlintLight5DiffuseIntensityBlueTag 0x0414 -#define GlintLight5DiffuseIntensityBlueReg 1 -#define GlintLight5DiffuseIntensityBlueOff 0x90a0 - -#define GlintLight5SpecularIntensityRed 0xa0a8 -#define GlintLight5SpecularIntensityRedTag 0x0415 -#define GlintLight5SpecularIntensityRedReg 1 -#define GlintLight5SpecularIntensityRedOff 0x90a8 - -#define GlintLight5SpecularIntensityGreen 0xa0b0 -#define GlintLight5SpecularIntensityGreenTag 0x0416 -#define GlintLight5SpecularIntensityGreenReg 1 -#define GlintLight5SpecularIntensityGreenOff 0x90b0 - -#define GlintLight5SpecularIntensityBlue 0xa0b8 -#define GlintLight5SpecularIntensityBlueTag 0x0417 -#define GlintLight5SpecularIntensityBlueReg 1 -#define GlintLight5SpecularIntensityBlueOff 0x90b8 - -#define GlintLight5PositionX 0xa0c0 -#define GlintLight5PositionXTag 0x0418 -#define GlintLight5PositionXReg 1 -#define GlintLight5PositionXOff 0x90c0 - -#define GlintLight5PositionY 0xa0c8 -#define GlintLight5PositionYTag 0x0419 -#define GlintLight5PositionYReg 1 -#define GlintLight5PositionYOff 0x90c8 - -#define GlintLight5PositionZ 0xa0d0 -#define GlintLight5PositionZTag 0x041a -#define GlintLight5PositionZReg 1 -#define GlintLight5PositionZOff 0x90d0 - -#define GlintLight5PositionW 0xa0d8 -#define GlintLight5PositionWTag 0x041b -#define GlintLight5PositionWReg 1 -#define GlintLight5PositionWOff 0x90d8 - -#define GlintLight5SpotlightDirectionX 0xa0e0 -#define GlintLight5SpotlightDirectionXTag 0x041c -#define GlintLight5SpotlightDirectionXReg 1 -#define GlintLight5SpotlightDirectionXOff 0x90e0 - -#define GlintLight5SpotlightDirectionY 0xa0e8 -#define GlintLight5SpotlightDirectionYTag 0x041d -#define GlintLight5SpotlightDirectionYReg 1 -#define GlintLight5SpotlightDirectionYOff 0x90e8 - -#define GlintLight5SpotlightDirectionZ 0xa0f0 -#define GlintLight5SpotlightDirectionZTag 0x041e -#define GlintLight5SpotlightDirectionZReg 1 -#define GlintLight5SpotlightDirectionZOff 0x90f0 - -#define GlintLight5SpotlightExponent 0xa0f8 -#define GlintLight5SpotlightExponentTag 0x041f -#define GlintLight5SpotlightExponentReg 1 -#define GlintLight5SpotlightExponentOff 0x90f8 - -#define GlintLight5CosSpotlightCutoffAngle 0xa100 -#define GlintLight5CosSpotlightCutoffAngleTag 0x0420 -#define GlintLight5CosSpotlightCutoffAngleReg 1 -#define GlintLight5CosSpotlightCutoffAngleOff 0x9100 - -#define GlintLight5ConstantAttenuation 0xa108 -#define GlintLight5ConstantAttenuationTag 0x0421 -#define GlintLight5ConstantAttenuationReg 1 -#define GlintLight5ConstantAttenuationOff 0x9108 - -#define GlintLight5LinearAttenuation 0xa110 -#define GlintLight5LinearAttenuationTag 0x0422 -#define GlintLight5LinearAttenuationReg 1 -#define GlintLight5LinearAttenuationOff 0x9110 - -#define GlintLight5QuadraticAttenuation 0xa118 -#define GlintLight5QuadraticAttenuationTag 0x0423 -#define GlintLight5QuadraticAttenuationReg 1 -#define GlintLight5QuadraticAttenuationOff 0x9118 - -#define GlintLight6Mode 0xa120 -#define GlintLight6ModeTag 0x0424 -#define GlintLight6ModeReg 1 -#define GlintLight6ModeOff 0x9120 - -#define GlintLight6AmbientIntensityRed 0xa128 -#define GlintLight6AmbientIntensityRedTag 0x0425 -#define GlintLight6AmbientIntensityRedReg 1 -#define GlintLight6AmbientIntensityRedOff 0x9128 - -#define GlintLight6AmbientIntensityGreen 0xa130 -#define GlintLight6AmbientIntensityGreenTag 0x0426 -#define GlintLight6AmbientIntensityGreenReg 1 -#define GlintLight6AmbientIntensityGreenOff 0x9130 - -#define GlintLight6AmbientIntensityBlue 0xa138 -#define GlintLight6AmbientIntensityBlueTag 0x0427 -#define GlintLight6AmbientIntensityBlueReg 1 -#define GlintLight6AmbientIntensityBlueOff 0x9138 - -#define GlintLight6DiffuseIntensityRed 0xa140 -#define GlintLight6DiffuseIntensityRedTag 0x0428 -#define GlintLight6DiffuseIntensityRedReg 1 -#define GlintLight6DiffuseIntensityRedOff 0x9140 - -#define GlintLight6DiffuseIntensityGreen 0xa148 -#define GlintLight6DiffuseIntensityGreenTag 0x0429 -#define GlintLight6DiffuseIntensityGreenReg 1 -#define GlintLight6DiffuseIntensityGreenOff 0x9148 - -#define GlintLight6DiffuseIntensityBlue 0xa150 -#define GlintLight6DiffuseIntensityBlueTag 0x042a -#define GlintLight6DiffuseIntensityBlueReg 1 -#define GlintLight6DiffuseIntensityBlueOff 0x9150 - -#define GlintLight6SpecularIntensityRed 0xa158 -#define GlintLight6SpecularIntensityRedTag 0x042b -#define GlintLight6SpecularIntensityRedReg 1 -#define GlintLight6SpecularIntensityRedOff 0x9158 - -#define GlintLight6SpecularIntensityGreen 0xa160 -#define GlintLight6SpecularIntensityGreenTag 0x042c -#define GlintLight6SpecularIntensityGreenReg 1 -#define GlintLight6SpecularIntensityGreenOff 0x9160 - -#define GlintLight6SpecularIntensityBlue 0xa168 -#define GlintLight6SpecularIntensityBlueTag 0x042d -#define GlintLight6SpecularIntensityBlueReg 1 -#define GlintLight6SpecularIntensityBlueOff 0x9168 - -#define GlintLight6PositionX 0xa170 -#define GlintLight6PositionXTag 0x042e -#define GlintLight6PositionXReg 1 -#define GlintLight6PositionXOff 0x9170 - -#define GlintLight6PositionY 0xa178 -#define GlintLight6PositionYTag 0x042f -#define GlintLight6PositionYReg 1 -#define GlintLight6PositionYOff 0x9178 - -#define GlintLight6PositionZ 0xa180 -#define GlintLight6PositionZTag 0x0430 -#define GlintLight6PositionZReg 1 -#define GlintLight6PositionZOff 0x9180 - -#define GlintLight6PositionW 0xa188 -#define GlintLight6PositionWTag 0x0431 -#define GlintLight6PositionWReg 1 -#define GlintLight6PositionWOff 0x9188 - -#define GlintLight6SpotlightDirectionX 0xa190 -#define GlintLight6SpotlightDirectionXTag 0x0432 -#define GlintLight6SpotlightDirectionXReg 1 -#define GlintLight6SpotlightDirectionXOff 0x9190 - -#define GlintLight6SpotlightDirectionY 0xa198 -#define GlintLight6SpotlightDirectionYTag 0x0433 -#define GlintLight6SpotlightDirectionYReg 1 -#define GlintLight6SpotlightDirectionYOff 0x9198 - -#define GlintLight6SpotlightDirectionZ 0xa1a0 -#define GlintLight6SpotlightDirectionZTag 0x0434 -#define GlintLight6SpotlightDirectionZReg 1 -#define GlintLight6SpotlightDirectionZOff 0x91a0 - -#define GlintLight6SpotlightExponent 0xa1a8 -#define GlintLight6SpotlightExponentTag 0x0435 -#define GlintLight6SpotlightExponentReg 1 -#define GlintLight6SpotlightExponentOff 0x91a8 - -#define GlintLight6CosSpotlightCutoffAngle 0xa1b0 -#define GlintLight6CosSpotlightCutoffAngleTag 0x0436 -#define GlintLight6CosSpotlightCutoffAngleReg 1 -#define GlintLight6CosSpotlightCutoffAngleOff 0x91b0 - -#define GlintLight6ConstantAttenuation 0xa1b8 -#define GlintLight6ConstantAttenuationTag 0x0437 -#define GlintLight6ConstantAttenuationReg 1 -#define GlintLight6ConstantAttenuationOff 0x91b8 - -#define GlintLight6LinearAttenuation 0xa1c0 -#define GlintLight6LinearAttenuationTag 0x0438 -#define GlintLight6LinearAttenuationReg 1 -#define GlintLight6LinearAttenuationOff 0x91c0 - -#define GlintLight6QuadraticAttenuation 0xa1c8 -#define GlintLight6QuadraticAttenuationTag 0x0439 -#define GlintLight6QuadraticAttenuationReg 1 -#define GlintLight6QuadraticAttenuationOff 0x91c8 - -#define GlintLight7Mode 0xa1d0 -#define GlintLight7ModeTag 0x043a -#define GlintLight7ModeReg 1 -#define GlintLight7ModeOff 0x91d0 - -#define GlintLight7AmbientIntensityRed 0xa1d8 -#define GlintLight7AmbientIntensityRedTag 0x043b -#define GlintLight7AmbientIntensityRedReg 1 -#define GlintLight7AmbientIntensityRedOff 0x91d8 - -#define GlintLight7AmbientIntensityGreen 0xa1e0 -#define GlintLight7AmbientIntensityGreenTag 0x043c -#define GlintLight7AmbientIntensityGreenReg 1 -#define GlintLight7AmbientIntensityGreenOff 0x91e0 - -#define GlintLight7AmbientIntensityBlue 0xa1e8 -#define GlintLight7AmbientIntensityBlueTag 0x043d -#define GlintLight7AmbientIntensityBlueReg 1 -#define GlintLight7AmbientIntensityBlueOff 0x91e8 - -#define GlintLight7DiffuseIntensityRed 0xa1f0 -#define GlintLight7DiffuseIntensityRedTag 0x043e -#define GlintLight7DiffuseIntensityRedReg 1 -#define GlintLight7DiffuseIntensityRedOff 0x91f0 - -#define GlintLight7DiffuseIntensityGreen 0xa1f8 -#define GlintLight7DiffuseIntensityGreenTag 0x043f -#define GlintLight7DiffuseIntensityGreenReg 1 -#define GlintLight7DiffuseIntensityGreenOff 0x91f8 - -#define GlintLight7DiffuseIntensityBlue 0xa200 -#define GlintLight7DiffuseIntensityBlueTag 0x0440 -#define GlintLight7DiffuseIntensityBlueReg 1 -#define GlintLight7DiffuseIntensityBlueOff 0x9200 - -#define GlintLight7SpecularIntensityRed 0xa208 -#define GlintLight7SpecularIntensityRedTag 0x0441 -#define GlintLight7SpecularIntensityRedReg 1 -#define GlintLight7SpecularIntensityRedOff 0x9208 - -#define GlintLight7SpecularIntensityGreen 0xa210 -#define GlintLight7SpecularIntensityGreenTag 0x0442 -#define GlintLight7SpecularIntensityGreenReg 1 -#define GlintLight7SpecularIntensityGreenOff 0x9210 - -#define GlintLight7SpecularIntensityBlue 0xa218 -#define GlintLight7SpecularIntensityBlueTag 0x0443 -#define GlintLight7SpecularIntensityBlueReg 1 -#define GlintLight7SpecularIntensityBlueOff 0x9218 - -#define GlintLight7PositionX 0xa220 -#define GlintLight7PositionXTag 0x0444 -#define GlintLight7PositionXReg 1 -#define GlintLight7PositionXOff 0x9220 - -#define GlintLight7PositionY 0xa228 -#define GlintLight7PositionYTag 0x0445 -#define GlintLight7PositionYReg 1 -#define GlintLight7PositionYOff 0x9228 - -#define GlintLight7PositionZ 0xa230 -#define GlintLight7PositionZTag 0x0446 -#define GlintLight7PositionZReg 1 -#define GlintLight7PositionZOff 0x9230 - -#define GlintLight7PositionW 0xa238 -#define GlintLight7PositionWTag 0x0447 -#define GlintLight7PositionWReg 1 -#define GlintLight7PositionWOff 0x9238 - -#define GlintLight7SpotlightDirectionX 0xa240 -#define GlintLight7SpotlightDirectionXTag 0x0448 -#define GlintLight7SpotlightDirectionXReg 1 -#define GlintLight7SpotlightDirectionXOff 0x9240 - -#define GlintLight7SpotlightDirectionY 0xa248 -#define GlintLight7SpotlightDirectionYTag 0x0449 -#define GlintLight7SpotlightDirectionYReg 1 -#define GlintLight7SpotlightDirectionYOff 0x9248 - -#define GlintLight7SpotlightDirectionZ 0xa250 -#define GlintLight7SpotlightDirectionZTag 0x044a -#define GlintLight7SpotlightDirectionZReg 1 -#define GlintLight7SpotlightDirectionZOff 0x9250 - -#define GlintLight7SpotlightExponent 0xa258 -#define GlintLight7SpotlightExponentTag 0x044b -#define GlintLight7SpotlightExponentReg 1 -#define GlintLight7SpotlightExponentOff 0x9258 - -#define GlintLight7CosSpotlightCutoffAngle 0xa260 -#define GlintLight7CosSpotlightCutoffAngleTag 0x044c -#define GlintLight7CosSpotlightCutoffAngleReg 1 -#define GlintLight7CosSpotlightCutoffAngleOff 0x9260 - -#define GlintLight7ConstantAttenuation 0xa268 -#define GlintLight7ConstantAttenuationTag 0x044d -#define GlintLight7ConstantAttenuationReg 1 -#define GlintLight7ConstantAttenuationOff 0x9268 - -#define GlintLight7LinearAttenuation 0xa270 -#define GlintLight7LinearAttenuationTag 0x044e -#define GlintLight7LinearAttenuationReg 1 -#define GlintLight7LinearAttenuationOff 0x9270 - -#define GlintLight7QuadraticAttenuation 0xa278 -#define GlintLight7QuadraticAttenuationTag 0x044f -#define GlintLight7QuadraticAttenuationReg 1 -#define GlintLight7QuadraticAttenuationOff 0x9278 - -#define GlintLight8Mode 0xa280 -#define GlintLight8ModeTag 0x0450 -#define GlintLight8ModeReg 1 -#define GlintLight8ModeOff 0x9280 - -#define GlintLight8AmbientIntensityRed 0xa288 -#define GlintLight8AmbientIntensityRedTag 0x0451 -#define GlintLight8AmbientIntensityRedReg 1 -#define GlintLight8AmbientIntensityRedOff 0x9288 - -#define GlintLight8AmbientIntensityGreen 0xa290 -#define GlintLight8AmbientIntensityGreenTag 0x0452 -#define GlintLight8AmbientIntensityGreenReg 1 -#define GlintLight8AmbientIntensityGreenOff 0x9290 - -#define GlintLight8AmbientIntensityBlue 0xa298 -#define GlintLight8AmbientIntensityBlueTag 0x0453 -#define GlintLight8AmbientIntensityBlueReg 1 -#define GlintLight8AmbientIntensityBlueOff 0x9298 - -#define GlintLight8DiffuseIntensityRed 0xa2a0 -#define GlintLight8DiffuseIntensityRedTag 0x0454 -#define GlintLight8DiffuseIntensityRedReg 1 -#define GlintLight8DiffuseIntensityRedOff 0x92a0 - -#define GlintLight8DiffuseIntensityGreen 0xa2a8 -#define GlintLight8DiffuseIntensityGreenTag 0x0455 -#define GlintLight8DiffuseIntensityGreenReg 1 -#define GlintLight8DiffuseIntensityGreenOff 0x92a8 - -#define GlintLight8DiffuseIntensityBlue 0xa2b0 -#define GlintLight8DiffuseIntensityBlueTag 0x0456 -#define GlintLight8DiffuseIntensityBlueReg 1 -#define GlintLight8DiffuseIntensityBlueOff 0x92b0 - -#define GlintLight8SpecularIntensityRed 0xa2b8 -#define GlintLight8SpecularIntensityRedTag 0x0457 -#define GlintLight8SpecularIntensityRedReg 1 -#define GlintLight8SpecularIntensityRedOff 0x92b8 - -#define GlintLight8SpecularIntensityGreen 0xa2c0 -#define GlintLight8SpecularIntensityGreenTag 0x0458 -#define GlintLight8SpecularIntensityGreenReg 1 -#define GlintLight8SpecularIntensityGreenOff 0x92c0 - -#define GlintLight8SpecularIntensityBlue 0xa2c8 -#define GlintLight8SpecularIntensityBlueTag 0x0459 -#define GlintLight8SpecularIntensityBlueReg 1 -#define GlintLight8SpecularIntensityBlueOff 0x92c8 - -#define GlintLight8PositionX 0xa2d0 -#define GlintLight8PositionXTag 0x045a -#define GlintLight8PositionXReg 1 -#define GlintLight8PositionXOff 0x92d0 - -#define GlintLight8PositionY 0xa2d8 -#define GlintLight8PositionYTag 0x045b -#define GlintLight8PositionYReg 1 -#define GlintLight8PositionYOff 0x92d8 - -#define GlintLight8PositionZ 0xa2e0 -#define GlintLight8PositionZTag 0x045c -#define GlintLight8PositionZReg 1 -#define GlintLight8PositionZOff 0x92e0 - -#define GlintLight8PositionW 0xa2e8 -#define GlintLight8PositionWTag 0x045d -#define GlintLight8PositionWReg 1 -#define GlintLight8PositionWOff 0x92e8 - -#define GlintLight8SpotlightDirectionX 0xa2f0 -#define GlintLight8SpotlightDirectionXTag 0x045e -#define GlintLight8SpotlightDirectionXReg 1 -#define GlintLight8SpotlightDirectionXOff 0x92f0 - -#define GlintLight8SpotlightDirectionY 0xa2f8 -#define GlintLight8SpotlightDirectionYTag 0x045f -#define GlintLight8SpotlightDirectionYReg 1 -#define GlintLight8SpotlightDirectionYOff 0x92f8 - -#define GlintLight8SpotlightDirectionZ 0xa300 -#define GlintLight8SpotlightDirectionZTag 0x0460 -#define GlintLight8SpotlightDirectionZReg 1 -#define GlintLight8SpotlightDirectionZOff 0x9300 - -#define GlintLight8SpotlightExponent 0xa308 -#define GlintLight8SpotlightExponentTag 0x0461 -#define GlintLight8SpotlightExponentReg 1 -#define GlintLight8SpotlightExponentOff 0x9308 - -#define GlintLight8CosSpotlightCutoffAngle 0xa310 -#define GlintLight8CosSpotlightCutoffAngleTag 0x0462 -#define GlintLight8CosSpotlightCutoffAngleReg 1 -#define GlintLight8CosSpotlightCutoffAngleOff 0x9310 - -#define GlintLight8ConstantAttenuation 0xa318 -#define GlintLight8ConstantAttenuationTag 0x0463 -#define GlintLight8ConstantAttenuationReg 1 -#define GlintLight8ConstantAttenuationOff 0x9318 - -#define GlintLight8LinearAttenuation 0xa320 -#define GlintLight8LinearAttenuationTag 0x0464 -#define GlintLight8LinearAttenuationReg 1 -#define GlintLight8LinearAttenuationOff 0x9320 - -#define GlintLight8QuadraticAttenuation 0xa328 -#define GlintLight8QuadraticAttenuationTag 0x0465 -#define GlintLight8QuadraticAttenuationReg 1 -#define GlintLight8QuadraticAttenuationOff 0x9328 - -#define GlintLight9Mode 0xa330 -#define GlintLight9ModeTag 0x0466 -#define GlintLight9ModeReg 1 -#define GlintLight9ModeOff 0x9330 - -#define GlintLight9AmbientIntensityRed 0xa338 -#define GlintLight9AmbientIntensityRedTag 0x0467 -#define GlintLight9AmbientIntensityRedReg 1 -#define GlintLight9AmbientIntensityRedOff 0x9338 - -#define GlintLight9AmbientIntensityGreen 0xa340 -#define GlintLight9AmbientIntensityGreenTag 0x0468 -#define GlintLight9AmbientIntensityGreenReg 1 -#define GlintLight9AmbientIntensityGreenOff 0x9340 - -#define GlintLight9AmbientIntensityBlue 0xa348 -#define GlintLight9AmbientIntensityBlueTag 0x0469 -#define GlintLight9AmbientIntensityBlueReg 1 -#define GlintLight9AmbientIntensityBlueOff 0x9348 - -#define GlintLight9DiffuseIntensityRed 0xa350 -#define GlintLight9DiffuseIntensityRedTag 0x046a -#define GlintLight9DiffuseIntensityRedReg 1 -#define GlintLight9DiffuseIntensityRedOff 0x9350 - -#define GlintLight9DiffuseIntensityGreen 0xa358 -#define GlintLight9DiffuseIntensityGreenTag 0x046b -#define GlintLight9DiffuseIntensityGreenReg 1 -#define GlintLight9DiffuseIntensityGreenOff 0x9358 - -#define GlintLight9DiffuseIntensityBlue 0xa360 -#define GlintLight9DiffuseIntensityBlueTag 0x046c -#define GlintLight9DiffuseIntensityBlueReg 1 -#define GlintLight9DiffuseIntensityBlueOff 0x9360 - -#define GlintLight9SpecularIntensityRed 0xa368 -#define GlintLight9SpecularIntensityRedTag 0x046d -#define GlintLight9SpecularIntensityRedReg 1 -#define GlintLight9SpecularIntensityRedOff 0x9368 - -#define GlintLight9SpecularIntensityGreen 0xa370 -#define GlintLight9SpecularIntensityGreenTag 0x046e -#define GlintLight9SpecularIntensityGreenReg 1 -#define GlintLight9SpecularIntensityGreenOff 0x9370 - -#define GlintLight9SpecularIntensityBlue 0xa378 -#define GlintLight9SpecularIntensityBlueTag 0x046f -#define GlintLight9SpecularIntensityBlueReg 1 -#define GlintLight9SpecularIntensityBlueOff 0x9378 - -#define GlintLight9PositionX 0xa380 -#define GlintLight9PositionXTag 0x0470 -#define GlintLight9PositionXReg 1 -#define GlintLight9PositionXOff 0x9380 - -#define GlintLight9PositionY 0xa388 -#define GlintLight9PositionYTag 0x0471 -#define GlintLight9PositionYReg 1 -#define GlintLight9PositionYOff 0x9388 - -#define GlintLight9PositionZ 0xa390 -#define GlintLight9PositionZTag 0x0472 -#define GlintLight9PositionZReg 1 -#define GlintLight9PositionZOff 0x9390 - -#define GlintLight9PositionW 0xa398 -#define GlintLight9PositionWTag 0x0473 -#define GlintLight9PositionWReg 1 -#define GlintLight9PositionWOff 0x9398 - -#define GlintLight9SpotlightDirectionX 0xa3a0 -#define GlintLight9SpotlightDirectionXTag 0x0474 -#define GlintLight9SpotlightDirectionXReg 1 -#define GlintLight9SpotlightDirectionXOff 0x93a0 - -#define GlintLight9SpotlightDirectionY 0xa3a8 -#define GlintLight9SpotlightDirectionYTag 0x0475 -#define GlintLight9SpotlightDirectionYReg 1 -#define GlintLight9SpotlightDirectionYOff 0x93a8 - -#define GlintLight9SpotlightDirectionZ 0xa3b0 -#define GlintLight9SpotlightDirectionZTag 0x0476 -#define GlintLight9SpotlightDirectionZReg 1 -#define GlintLight9SpotlightDirectionZOff 0x93b0 - -#define GlintLight9SpotlightExponent 0xa3b8 -#define GlintLight9SpotlightExponentTag 0x0477 -#define GlintLight9SpotlightExponentReg 1 -#define GlintLight9SpotlightExponentOff 0x93b8 - -#define GlintLight9CosSpotlightCutoffAngle 0xa3c0 -#define GlintLight9CosSpotlightCutoffAngleTag 0x0478 -#define GlintLight9CosSpotlightCutoffAngleReg 1 -#define GlintLight9CosSpotlightCutoffAngleOff 0x93c0 - -#define GlintLight9ConstantAttenuation 0xa3c8 -#define GlintLight9ConstantAttenuationTag 0x0479 -#define GlintLight9ConstantAttenuationReg 1 -#define GlintLight9ConstantAttenuationOff 0x93c8 - -#define GlintLight9LinearAttenuation 0xa3d0 -#define GlintLight9LinearAttenuationTag 0x047a -#define GlintLight9LinearAttenuationReg 1 -#define GlintLight9LinearAttenuationOff 0x93d0 - -#define GlintLight9QuadraticAttenuation 0xa3d8 -#define GlintLight9QuadraticAttenuationTag 0x047b -#define GlintLight9QuadraticAttenuationReg 1 -#define GlintLight9QuadraticAttenuationOff 0x93d8 - -#define GlintLight10Mode 0xa3e0 -#define GlintLight10ModeTag 0x047c -#define GlintLight10ModeReg 1 -#define GlintLight10ModeOff 0x93e0 - -#define GlintLight10AmbientIntensityRed 0xa3e8 -#define GlintLight10AmbientIntensityRedTag 0x047d -#define GlintLight10AmbientIntensityRedReg 1 -#define GlintLight10AmbientIntensityRedOff 0x93e8 - -#define GlintLight10AmbientIntensityGreen 0xa3f0 -#define GlintLight10AmbientIntensityGreenTag 0x047e -#define GlintLight10AmbientIntensityGreenReg 1 -#define GlintLight10AmbientIntensityGreenOff 0x93f0 - -#define GlintLight10AmbientIntensityBlue 0xa3f8 -#define GlintLight10AmbientIntensityBlueTag 0x047f -#define GlintLight10AmbientIntensityBlueReg 1 -#define GlintLight10AmbientIntensityBlueOff 0x93f8 - -#define GlintLight10DiffuseIntensityRed 0xa400 -#define GlintLight10DiffuseIntensityRedTag 0x0480 -#define GlintLight10DiffuseIntensityRedReg 1 -#define GlintLight10DiffuseIntensityRedOff 0x9400 - -#define GlintLight10DiffuseIntensityGreen 0xa408 -#define GlintLight10DiffuseIntensityGreenTag 0x0481 -#define GlintLight10DiffuseIntensityGreenReg 1 -#define GlintLight10DiffuseIntensityGreenOff 0x9408 - -#define GlintLight10DiffuseIntensityBlue 0xa410 -#define GlintLight10DiffuseIntensityBlueTag 0x0482 -#define GlintLight10DiffuseIntensityBlueReg 1 -#define GlintLight10DiffuseIntensityBlueOff 0x9410 - -#define GlintLight10SpecularIntensityRed 0xa418 -#define GlintLight10SpecularIntensityRedTag 0x0483 -#define GlintLight10SpecularIntensityRedReg 1 -#define GlintLight10SpecularIntensityRedOff 0x9418 - -#define GlintLight10SpecularIntensityGreen 0xa420 -#define GlintLight10SpecularIntensityGreenTag 0x0484 -#define GlintLight10SpecularIntensityGreenReg 1 -#define GlintLight10SpecularIntensityGreenOff 0x9420 - -#define GlintLight10SpecularIntensityBlue 0xa428 -#define GlintLight10SpecularIntensityBlueTag 0x0485 -#define GlintLight10SpecularIntensityBlueReg 1 -#define GlintLight10SpecularIntensityBlueOff 0x9428 - -#define GlintLight10PositionX 0xa430 -#define GlintLight10PositionXTag 0x0486 -#define GlintLight10PositionXReg 1 -#define GlintLight10PositionXOff 0x9430 - -#define GlintLight10PositionY 0xa438 -#define GlintLight10PositionYTag 0x0487 -#define GlintLight10PositionYReg 1 -#define GlintLight10PositionYOff 0x9438 - -#define GlintLight10PositionZ 0xa440 -#define GlintLight10PositionZTag 0x0488 -#define GlintLight10PositionZReg 1 -#define GlintLight10PositionZOff 0x9440 - -#define GlintLight10PositionW 0xa448 -#define GlintLight10PositionWTag 0x0489 -#define GlintLight10PositionWReg 1 -#define GlintLight10PositionWOff 0x9448 - -#define GlintLight10SpotlightDirectionX 0xa450 -#define GlintLight10SpotlightDirectionXTag 0x048a -#define GlintLight10SpotlightDirectionXReg 1 -#define GlintLight10SpotlightDirectionXOff 0x9450 - -#define GlintLight10SpotlightDirectionY 0xa458 -#define GlintLight10SpotlightDirectionYTag 0x048b -#define GlintLight10SpotlightDirectionYReg 1 -#define GlintLight10SpotlightDirectionYOff 0x9458 - -#define GlintLight10SpotlightDirectionZ 0xa460 -#define GlintLight10SpotlightDirectionZTag 0x048c -#define GlintLight10SpotlightDirectionZReg 1 -#define GlintLight10SpotlightDirectionZOff 0x9460 - -#define GlintLight10SpotlightExponent 0xa468 -#define GlintLight10SpotlightExponentTag 0x048d -#define GlintLight10SpotlightExponentReg 1 -#define GlintLight10SpotlightExponentOff 0x9468 - -#define GlintLight10CosSpotlightCutoffAngle 0xa470 -#define GlintLight10CosSpotlightCutoffAngleTag 0x048e -#define GlintLight10CosSpotlightCutoffAngleReg 1 -#define GlintLight10CosSpotlightCutoffAngleOff 0x9470 - -#define GlintLight10ConstantAttenuation 0xa478 -#define GlintLight10ConstantAttenuationTag 0x048f -#define GlintLight10ConstantAttenuationReg 1 -#define GlintLight10ConstantAttenuationOff 0x9478 - -#define GlintLight10LinearAttenuation 0xa480 -#define GlintLight10LinearAttenuationTag 0x0490 -#define GlintLight10LinearAttenuationReg 1 -#define GlintLight10LinearAttenuationOff 0x9480 - -#define GlintLight10QuadraticAttenuation 0xa488 -#define GlintLight10QuadraticAttenuationTag 0x0491 -#define GlintLight10QuadraticAttenuationReg 1 -#define GlintLight10QuadraticAttenuationOff 0x9488 - -#define GlintLight11Mode 0xa490 -#define GlintLight11ModeTag 0x0492 -#define GlintLight11ModeReg 1 -#define GlintLight11ModeOff 0x9490 - -#define GlintLight11AmbientIntensiveRed 0xa498 -#define GlintLight11AmbientIntensiveRedTag 0x0493 -#define GlintLight11AmbientIntensiveRedReg 1 -#define GlintLight11AmbientIntensiveRedOff 0x9498 - -#define GlintLight11AmbientIntensityGreen 0xa4a0 -#define GlintLight11AmbientIntensityGreenTag 0x0494 -#define GlintLight11AmbientIntensityGreenReg 1 -#define GlintLight11AmbientIntensityGreenOff 0x94a0 - -#define GlintLight11AmbientIntensityBlue 0xa4a8 -#define GlintLight11AmbientIntensityBlueTag 0x0495 -#define GlintLight11AmbientIntensityBlueReg 1 -#define GlintLight11AmbientIntensityBlueOff 0x94a8 - -#define GlintLight11DiffuseIntensityRed 0xa4b0 -#define GlintLight11DiffuseIntensityRedTag 0x0496 -#define GlintLight11DiffuseIntensityRedReg 1 -#define GlintLight11DiffuseIntensityRedOff 0x94b0 - -#define GlintLight11DiffuseIntensityGreen 0xa4b8 -#define GlintLight11DiffuseIntensityGreenTag 0x0497 -#define GlintLight11DiffuseIntensityGreenReg 1 -#define GlintLight11DiffuseIntensityGreenOff 0x94b8 - -#define GlintLight11DiffuseIntensityBlue 0xa4c0 -#define GlintLight11DiffuseIntensityBlueTag 0x0498 -#define GlintLight11DiffuseIntensityBlueReg 1 -#define GlintLight11DiffuseIntensityBlueOff 0x94c0 - -#define GlintLight11SpecularIntensityRed 0xa4c8 -#define GlintLight11SpecularIntensityRedTag 0x0499 -#define GlintLight11SpecularIntensityRedReg 1 -#define GlintLight11SpecularIntensityRedOff 0x94c8 - -#define GlintLight11SpecularIntensityGreen 0xa4d0 -#define GlintLight11SpecularIntensityGreenTag 0x049a -#define GlintLight11SpecularIntensityGreenReg 1 -#define GlintLight11SpecularIntensityGreenOff 0x94d0 - -#define GlintLight11SpecularIntensityBlue 0xa4d8 -#define GlintLight11SpecularIntensityBlueTag 0x049b -#define GlintLight11SpecularIntensityBlueReg 1 -#define GlintLight11SpecularIntensityBlueOff 0x94d8 - -#define GlintLight11PositionX 0xa4e0 -#define GlintLight11PositionXTag 0x049c -#define GlintLight11PositionXReg 1 -#define GlintLight11PositionXOff 0x94e0 - -#define GlintLight11PositionY 0xa4e8 -#define GlintLight11PositionYTag 0x049d -#define GlintLight11PositionYReg 1 -#define GlintLight11PositionYOff 0x94e8 - -#define GlintLight11PositionZ 0xa4f0 -#define GlintLight11PositionZTag 0x049e -#define GlintLight11PositionZReg 1 -#define GlintLight11PositionZOff 0x94f0 - -#define GlintLight11PositionW 0xa4f8 -#define GlintLight11PositionWTag 0x049f -#define GlintLight11PositionWReg 1 -#define GlintLight11PositionWOff 0x94f8 - -#define GlintLight11SpotlightDirectionX 0xa500 -#define GlintLight11SpotlightDirectionXTag 0x04a0 -#define GlintLight11SpotlightDirectionXReg 1 -#define GlintLight11SpotlightDirectionXOff 0x9500 - -#define GlintLight11SpotlightDirectionY 0xa508 -#define GlintLight11SpotlightDirectionYTag 0x04a1 -#define GlintLight11SpotlightDirectionYReg 1 -#define GlintLight11SpotlightDirectionYOff 0x9508 - -#define GlintLight11SpotlightDirectionZ 0xa510 -#define GlintLight11SpotlightDirectionZTag 0x04a2 -#define GlintLight11SpotlightDirectionZReg 1 -#define GlintLight11SpotlightDirectionZOff 0x9510 - -#define GlintLight11SpotlightExponent 0xa518 -#define GlintLight11SpotlightExponentTag 0x04a3 -#define GlintLight11SpotlightExponentReg 1 -#define GlintLight11SpotlightExponentOff 0x9518 - -#define GlintLight11CosSpotlightCutoffAngle 0xa520 -#define GlintLight11CosSpotlightCutoffAngleTag 0x04a4 -#define GlintLight11CosSpotlightCutoffAngleReg 1 -#define GlintLight11CosSpotlightCutoffAngleOff 0x9520 - -#define GlintLight11ConstantAttenuation 0xa528 -#define GlintLight11ConstantAttenuationTag 0x04a5 -#define GlintLight11ConstantAttenuationReg 1 -#define GlintLight11ConstantAttenuationOff 0x9528 - -#define GlintLight11LinearAttenuation 0xa530 -#define GlintLight11LinearAttenuationTag 0x04a6 -#define GlintLight11LinearAttenuationReg 1 -#define GlintLight11LinearAttenuationOff 0x9530 - -#define GlintLight11QuadraticAttenuation 0xa538 -#define GlintLight11QuadraticAttenuationTag 0x04a7 -#define GlintLight11QuadraticAttenuationReg 1 -#define GlintLight11QuadraticAttenuationOff 0x9538 - -#define GlintLight12Mode 0xa540 -#define GlintLight12ModeTag 0x04a8 -#define GlintLight12ModeReg 1 -#define GlintLight12ModeOff 0x9540 - -#define GlintLight12AmbientIntensityRed 0xa548 -#define GlintLight12AmbientIntensityRedTag 0x04a9 -#define GlintLight12AmbientIntensityRedReg 1 -#define GlintLight12AmbientIntensityRedOff 0x9548 - -#define GlintLight12AmbientIntensityGreen 0xa550 -#define GlintLight12AmbientIntensityGreenTag 0x04aa -#define GlintLight12AmbientIntensityGreenReg 1 -#define GlintLight12AmbientIntensityGreenOff 0x9550 - -#define GlintLight12AmbientIntensityBlue 0xa558 -#define GlintLight12AmbientIntensityBlueTag 0x04ab -#define GlintLight12AmbientIntensityBlueReg 1 -#define GlintLight12AmbientIntensityBlueOff 0x9558 - -#define GlintLight12DiffuseIntensityRed 0xa560 -#define GlintLight12DiffuseIntensityRedTag 0x04ac -#define GlintLight12DiffuseIntensityRedReg 1 -#define GlintLight12DiffuseIntensityRedOff 0x9560 - -#define GlintLight12DiffuseIntensityGreen 0xa568 -#define GlintLight12DiffuseIntensityGreenTag 0x04ad -#define GlintLight12DiffuseIntensityGreenReg 1 -#define GlintLight12DiffuseIntensityGreenOff 0x9568 - -#define GlintLight12DiffuseIntensityBlue 0xa570 -#define GlintLight12DiffuseIntensityBlueTag 0x04ae -#define GlintLight12DiffuseIntensityBlueReg 1 -#define GlintLight12DiffuseIntensityBlueOff 0x9570 - -#define GlintLight12SpecularIntensityRed 0xa578 -#define GlintLight12SpecularIntensityRedTag 0x04af -#define GlintLight12SpecularIntensityRedReg 1 -#define GlintLight12SpecularIntensityRedOff 0x9578 - -#define GlintLight12SpecularIntensityGreen 0xa580 -#define GlintLight12SpecularIntensityGreenTag 0x04b0 -#define GlintLight12SpecularIntensityGreenReg 1 -#define GlintLight12SpecularIntensityGreenOff 0x9580 - -#define GlintLight12SpecularIntensityBlue 0xa588 -#define GlintLight12SpecularIntensityBlueTag 0x04b1 -#define GlintLight12SpecularIntensityBlueReg 1 -#define GlintLight12SpecularIntensityBlueOff 0x9588 - -#define GlintLight12PositionX 0xa590 -#define GlintLight12PositionXTag 0x04b2 -#define GlintLight12PositionXReg 1 -#define GlintLight12PositionXOff 0x9590 - -#define GlintLight12PositionY 0xa598 -#define GlintLight12PositionYTag 0x04b3 -#define GlintLight12PositionYReg 1 -#define GlintLight12PositionYOff 0x9598 - -#define GlintLight12PositionZ 0xa5a0 -#define GlintLight12PositionZTag 0x04b4 -#define GlintLight12PositionZReg 1 -#define GlintLight12PositionZOff 0x95a0 - -#define GlintLight12PositionW 0xa5a8 -#define GlintLight12PositionWTag 0x04b5 -#define GlintLight12PositionWReg 1 -#define GlintLight12PositionWOff 0x95a8 - -#define GlintLight12SpotlightDirectionX 0xa5b0 -#define GlintLight12SpotlightDirectionXTag 0x04b6 -#define GlintLight12SpotlightDirectionXReg 1 -#define GlintLight12SpotlightDirectionXOff 0x95b0 - -#define GlintLight12SpotlightDirectionY 0xa5b8 -#define GlintLight12SpotlightDirectionYTag 0x04b7 -#define GlintLight12SpotlightDirectionYReg 1 -#define GlintLight12SpotlightDirectionYOff 0x95b8 - -#define GlintLight12SpotlightDirectionZ 0xa5c0 -#define GlintLight12SpotlightDirectionZTag 0x04b8 -#define GlintLight12SpotlightDirectionZReg 1 -#define GlintLight12SpotlightDirectionZOff 0x95c0 - -#define GlintLight12SpotlightExponent 0xa5c8 -#define GlintLight12SpotlightExponentTag 0x04b9 -#define GlintLight12SpotlightExponentReg 1 -#define GlintLight12SpotlightExponentOff 0x95c8 - -#define GlintLight12CosSpotlightCutoffAngle 0xa5d0 -#define GlintLight12CosSpotlightCutoffAngleTag 0x04ba -#define GlintLight12CosSpotlightCutoffAngleReg 1 -#define GlintLight12CosSpotlightCutoffAngleOff 0x95d0 - -#define GlintLight12ConstantAttenuation 0xa5d8 -#define GlintLight12ConstantAttenuationTag 0x04bb -#define GlintLight12ConstantAttenuationReg 1 -#define GlintLight12ConstantAttenuationOff 0x95d8 - -#define GlintLight12LinearAttenuation 0xa5e0 -#define GlintLight12LinearAttenuationTag 0x04bc -#define GlintLight12LinearAttenuationReg 1 -#define GlintLight12LinearAttenuationOff 0x95e0 - -#define GlintLight12QuadraticAttenuation 0xa5e8 -#define GlintLight12QuadraticAttenuationTag 0x04bd -#define GlintLight12QuadraticAttenuationReg 1 -#define GlintLight12QuadraticAttenuationOff 0x95e8 - -#define GlintLight13Mode 0xa5f0 -#define GlintLight13ModeTag 0x04be -#define GlintLight13ModeReg 1 -#define GlintLight13ModeOff 0x95f0 - -#define GlintLight13AmbientIntensityRed 0xa5f8 -#define GlintLight13AmbientIntensityRedTag 0x04bf -#define GlintLight13AmbientIntensityRedReg 1 -#define GlintLight13AmbientIntensityRedOff 0x95f8 - -#define GlintLight13AmbientIntensityGreen 0xa600 -#define GlintLight13AmbientIntensityGreenTag 0x04c0 -#define GlintLight13AmbientIntensityGreenReg 1 -#define GlintLight13AmbientIntensityGreenOff 0x9600 - -#define GlintLight13AmbientIntensityBlue 0xa608 -#define GlintLight13AmbientIntensityBlueTag 0x04c1 -#define GlintLight13AmbientIntensityBlueReg 1 -#define GlintLight13AmbientIntensityBlueOff 0x9608 - -#define GlintLight13DiffuseIntensityRed 0xa610 -#define GlintLight13DiffuseIntensityRedTag 0x04c2 -#define GlintLight13DiffuseIntensityRedReg 1 -#define GlintLight13DiffuseIntensityRedOff 0x9610 - -#define GlintLight13DiffuseIntensityGreen 0xa618 -#define GlintLight13DiffuseIntensityGreenTag 0x04c3 -#define GlintLight13DiffuseIntensityGreenReg 1 -#define GlintLight13DiffuseIntensityGreenOff 0x9618 - -#define GlintLight13DiffuseIntensityBlue 0xa620 -#define GlintLight13DiffuseIntensityBlueTag 0x04c4 -#define GlintLight13DiffuseIntensityBlueReg 1 -#define GlintLight13DiffuseIntensityBlueOff 0x9620 - -#define GlintLight13SpecularIntensityRed 0xa628 -#define GlintLight13SpecularIntensityRedTag 0x04c5 -#define GlintLight13SpecularIntensityRedReg 1 -#define GlintLight13SpecularIntensityRedOff 0x9628 - -#define GlintLight13SpecularIntensityGreen 0xa630 -#define GlintLight13SpecularIntensityGreenTag 0x04c6 -#define GlintLight13SpecularIntensityGreenReg 1 -#define GlintLight13SpecularIntensityGreenOff 0x9630 - -#define GlintLight13SpecularIntensityBlue 0xa638 -#define GlintLight13SpecularIntensityBlueTag 0x04c7 -#define GlintLight13SpecularIntensityBlueReg 1 -#define GlintLight13SpecularIntensityBlueOff 0x9638 - -#define GlintLight13PositionX 0xa640 -#define GlintLight13PositionXTag 0x04c8 -#define GlintLight13PositionXReg 1 -#define GlintLight13PositionXOff 0x9640 - -#define GlintLight13PositionY 0xa648 -#define GlintLight13PositionYTag 0x04c9 -#define GlintLight13PositionYReg 1 -#define GlintLight13PositionYOff 0x9648 - -#define GlintLight13PositionZ 0xa650 -#define GlintLight13PositionZTag 0x04ca -#define GlintLight13PositionZReg 1 -#define GlintLight13PositionZOff 0x9650 - -#define GlintLight13PositionW 0xa658 -#define GlintLight13PositionWTag 0x04cb -#define GlintLight13PositionWReg 1 -#define GlintLight13PositionWOff 0x9658 - -#define GlintLight13SpotlightDirectionX 0xa660 -#define GlintLight13SpotlightDirectionXTag 0x04cc -#define GlintLight13SpotlightDirectionXReg 1 -#define GlintLight13SpotlightDirectionXOff 0x9660 - -#define GlintLight13SpotlightDirectionY 0xa668 -#define GlintLight13SpotlightDirectionYTag 0x04cd -#define GlintLight13SpotlightDirectionYReg 1 -#define GlintLight13SpotlightDirectionYOff 0x9668 - -#define GlintLight13SpotlightDirectionZ 0xa670 -#define GlintLight13SpotlightDirectionZTag 0x04ce -#define GlintLight13SpotlightDirectionZReg 1 -#define GlintLight13SpotlightDirectionZOff 0x9670 - -#define GlintLight13SpotlightExponent 0xa678 -#define GlintLight13SpotlightExponentTag 0x04cf -#define GlintLight13SpotlightExponentReg 1 -#define GlintLight13SpotlightExponentOff 0x9678 - -#define GlintLight13CosSpotlightCutoffAngle 0xa680 -#define GlintLight13CosSpotlightCutoffAngleTag 0x04d0 -#define GlintLight13CosSpotlightCutoffAngleReg 1 -#define GlintLight13CosSpotlightCutoffAngleOff 0x9680 - -#define GlintLight13ConstantAttenuation 0xa688 -#define GlintLight13ConstantAttenuationTag 0x04d1 -#define GlintLight13ConstantAttenuationReg 1 -#define GlintLight13ConstantAttenuationOff 0x9688 - -#define GlintLight13LinearAttenuation 0xa690 -#define GlintLight13LinearAttenuationTag 0x04d2 -#define GlintLight13LinearAttenuationReg 1 -#define GlintLight13LinearAttenuationOff 0x9690 - -#define GlintLight13QuadraticAttenuation 0xa698 -#define GlintLight13QuadraticAttenuationTag 0x04d3 -#define GlintLight13QuadraticAttenuationReg 1 -#define GlintLight13QuadraticAttenuationOff 0x9698 - -#define GlintLight14Mode 0xa6a0 -#define GlintLight14ModeTag 0x04d4 -#define GlintLight14ModeReg 1 -#define GlintLight14ModeOff 0x96a0 - -#define GlintLight14AmbientIntensityRed 0xa6a8 -#define GlintLight14AmbientIntensityRedTag 0x04d5 -#define GlintLight14AmbientIntensityRedReg 1 -#define GlintLight14AmbientIntensityRedOff 0x96a8 - -#define GlintLight14AmbientIntensityGreen 0xa6b0 -#define GlintLight14AmbientIntensityGreenTag 0x04d6 -#define GlintLight14AmbientIntensityGreenReg 1 -#define GlintLight14AmbientIntensityGreenOff 0x96b0 - -#define GlintLight14AmbientIntensityBlue 0xa6b8 -#define GlintLight14AmbientIntensityBlueTag 0x04d7 -#define GlintLight14AmbientIntensityBlueReg 1 -#define GlintLight14AmbientIntensityBlueOff 0x96b8 - -#define GlintLight14DiffuseIntensityRed 0xa6c0 -#define GlintLight14DiffuseIntensityRedTag 0x04d8 -#define GlintLight14DiffuseIntensityRedReg 1 -#define GlintLight14DiffuseIntensityRedOff 0x96c0 - -#define GlintLight14DiffuseIntensityGreen 0xa6c8 -#define GlintLight14DiffuseIntensityGreenTag 0x04d9 -#define GlintLight14DiffuseIntensityGreenReg 1 -#define GlintLight14DiffuseIntensityGreenOff 0x96c8 - -#define GlintLight14DiffuseIntensityBlue 0xa6d0 -#define GlintLight14DiffuseIntensityBlueTag 0x04da -#define GlintLight14DiffuseIntensityBlueReg 1 -#define GlintLight14DiffuseIntensityBlueOff 0x96d0 - -#define GlintLight14SpecularIntensityRed 0xa6d8 -#define GlintLight14SpecularIntensityRedTag 0x04db -#define GlintLight14SpecularIntensityRedReg 1 -#define GlintLight14SpecularIntensityRedOff 0x96d8 - -#define GlintLight14SpecularIntensityGreen 0xa6e0 -#define GlintLight14SpecularIntensityGreenTag 0x04dc -#define GlintLight14SpecularIntensityGreenReg 1 -#define GlintLight14SpecularIntensityGreenOff 0x96e0 - -#define GlintLight14SpecularIntensityBlue 0xa6e8 -#define GlintLight14SpecularIntensityBlueTag 0x04dd -#define GlintLight14SpecularIntensityBlueReg 1 -#define GlintLight14SpecularIntensityBlueOff 0x96e8 - -#define GlintLight14PositionX 0xa6f0 -#define GlintLight14PositionXTag 0x04de -#define GlintLight14PositionXReg 1 -#define GlintLight14PositionXOff 0x96f0 - -#define GlintLight14PositionY 0xa6f8 -#define GlintLight14PositionYTag 0x04df -#define GlintLight14PositionYReg 1 -#define GlintLight14PositionYOff 0x96f8 - -#define GlintLight14PositionZ 0xa700 -#define GlintLight14PositionZTag 0x04e0 -#define GlintLight14PositionZReg 1 -#define GlintLight14PositionZOff 0x9700 - -#define GlintLight14PositionW 0xa708 -#define GlintLight14PositionWTag 0x04e1 -#define GlintLight14PositionWReg 1 -#define GlintLight14PositionWOff 0x9708 - -#define GlintLight14SpotlightDirectionX 0xa710 -#define GlintLight14SpotlightDirectionXTag 0x04e2 -#define GlintLight14SpotlightDirectionXReg 1 -#define GlintLight14SpotlightDirectionXOff 0x9710 - -#define GlintLight14SpotlightDirectionY 0xa718 -#define GlintLight14SpotlightDirectionYTag 0x04e3 -#define GlintLight14SpotlightDirectionYReg 1 -#define GlintLight14SpotlightDirectionYOff 0x9718 - -#define GlintLight14SpotlightDirectionZ 0xa720 -#define GlintLight14SpotlightDirectionZTag 0x04e4 -#define GlintLight14SpotlightDirectionZReg 1 -#define GlintLight14SpotlightDirectionZOff 0x9720 - -#define GlintLight14SpotlightExponent 0xa728 -#define GlintLight14SpotlightExponentTag 0x04e5 -#define GlintLight14SpotlightExponentReg 1 -#define GlintLight14SpotlightExponentOff 0x9728 - -#define GlintLight14CosSpotlightCutoffAngle 0xa730 -#define GlintLight14CosSpotlightCutoffAngleTag 0x04e6 -#define GlintLight14CosSpotlightCutoffAngleReg 1 -#define GlintLight14CosSpotlightCutoffAngleOff 0x9730 - -#define GlintLight14ConstantAttenuation 0xa738 -#define GlintLight14ConstantAttenuationTag 0x04e7 -#define GlintLight14ConstantAttenuationReg 1 -#define GlintLight14ConstantAttenuationOff 0x9738 - -#define GlintLight14LinearAttenuation 0xa740 -#define GlintLight14LinearAttenuationTag 0x04e8 -#define GlintLight14LinearAttenuationReg 1 -#define GlintLight14LinearAttenuationOff 0x9740 - -#define GlintLight14QuadraticAttenuation 0xa748 -#define GlintLight14QuadraticAttenuationTag 0x04e9 -#define GlintLight14QuadraticAttenuationReg 1 -#define GlintLight14QuadraticAttenuationOff 0x9748 - -#define GlintLight15Mode 0xa750 -#define GlintLight15ModeTag 0x04ea -#define GlintLight15ModeReg 1 -#define GlintLight15ModeOff 0x9750 - -#define GlintLight15AmbientIntensityRed 0xa758 -#define GlintLight15AmbientIntensityRedTag 0x04eb -#define GlintLight15AmbientIntensityRedReg 1 -#define GlintLight15AmbientIntensityRedOff 0x9758 - -#define GlintLight15AmbientIntensityGreen 0xa760 -#define GlintLight15AmbientIntensityGreenTag 0x04ec -#define GlintLight15AmbientIntensityGreenReg 1 -#define GlintLight15AmbientIntensityGreenOff 0x9760 - -#define GlintLight15AmbientIntensityBlue 0xa768 -#define GlintLight15AmbientIntensityBlueTag 0x04ed -#define GlintLight15AmbientIntensityBlueReg 1 -#define GlintLight15AmbientIntensityBlueOff 0x9768 - -#define GlintLight15DiffuseIntensityRed 0xa770 -#define GlintLight15DiffuseIntensityRedTag 0x04ee -#define GlintLight15DiffuseIntensityRedReg 1 -#define GlintLight15DiffuseIntensityRedOff 0x9770 - -#define GlintLight15DiffuseIntensityGreen 0xa778 -#define GlintLight15DiffuseIntensityGreenTag 0x04ef -#define GlintLight15DiffuseIntensityGreenReg 1 -#define GlintLight15DiffuseIntensityGreenOff 0x9778 - -#define GlintLight15DiffuseIntensityBlue 0xa780 -#define GlintLight15DiffuseIntensityBlueTag 0x04f0 -#define GlintLight15DiffuseIntensityBlueReg 1 -#define GlintLight15DiffuseIntensityBlueOff 0x9780 - -#define GlintLight15SpecularIntensityRed 0xa788 -#define GlintLight15SpecularIntensityRedTag 0x04f1 -#define GlintLight15SpecularIntensityRedReg 1 -#define GlintLight15SpecularIntensityRedOff 0x9788 - -#define GlintLight15SpecularIntensityGreen 0xa790 -#define GlintLight15SpecularIntensityGreenTag 0x04f2 -#define GlintLight15SpecularIntensityGreenReg 1 -#define GlintLight15SpecularIntensityGreenOff 0x9790 - -#define GlintLight15SpecularIntensityBlue 0xa798 -#define GlintLight15SpecularIntensityBlueTag 0x04f3 -#define GlintLight15SpecularIntensityBlueReg 1 -#define GlintLight15SpecularIntensityBlueOff 0x9798 - -#define GlintLight15PositionX 0xa7a0 -#define GlintLight15PositionXTag 0x04f4 -#define GlintLight15PositionXReg 1 -#define GlintLight15PositionXOff 0x97a0 - -#define GlintLight15PositionY 0xa7a8 -#define GlintLight15PositionYTag 0x04f5 -#define GlintLight15PositionYReg 1 -#define GlintLight15PositionYOff 0x97a8 - -#define GlintLight15PositionZ 0xa7b0 -#define GlintLight15PositionZTag 0x04f6 -#define GlintLight15PositionZReg 1 -#define GlintLight15PositionZOff 0x97b0 - -#define GlintLight15PositionW 0xa7b8 -#define GlintLight15PositionWTag 0x04f7 -#define GlintLight15PositionWReg 1 -#define GlintLight15PositionWOff 0x97b8 - -#define GlintLight15SpotlightDirectionX 0xa7c0 -#define GlintLight15SpotlightDirectionXTag 0x04f8 -#define GlintLight15SpotlightDirectionXReg 1 -#define GlintLight15SpotlightDirectionXOff 0x97c0 - -#define GlintLight15SpotlightDirectionY 0xa7c8 -#define GlintLight15SpotlightDirectionYTag 0x04f9 -#define GlintLight15SpotlightDirectionYReg 1 -#define GlintLight15SpotlightDirectionYOff 0x97c8 - -#define GlintLight15SpotlightDirectionZ 0xa7d0 -#define GlintLight15SpotlightDirectionZTag 0x04fa -#define GlintLight15SpotlightDirectionZReg 1 -#define GlintLight15SpotlightDirectionZOff 0x97d0 - -#define GlintLight15SpotlightExponent 0xa7d8 -#define GlintLight15SpotlightExponentTag 0x04fb -#define GlintLight15SpotlightExponentReg 1 -#define GlintLight15SpotlightExponentOff 0x97d8 - -#define GlintLight15CosSpotlightCutoffAngle 0xa7e0 -#define GlintLight15CosSpotlightCutoffAngleTag 0x04fc -#define GlintLight15CosSpotlightCutoffAngleReg 1 -#define GlintLight15CosSpotlightCutoffAngleOff 0x97e0 - -#define GlintLight15ConstantAttenuation 0xa7e8 -#define GlintLight15ConstantAttenuationTag 0x04fd -#define GlintLight15ConstantAttenuationReg 1 -#define GlintLight15ConstantAttenuationOff 0x97e8 - -#define GlintLight15LinearAttenuation 0xa7f0 -#define GlintLight15LinearAttenuationTag 0x04fe -#define GlintLight15LinearAttenuationReg 1 -#define GlintLight15LinearAttenuationOff 0x97f0 - -#define GlintLight15QuadraticAttenuation 0xa7f8 -#define GlintLight15QuadraticAttenuationTag 0x04ff -#define GlintLight15QuadraticAttenuationReg 1 -#define GlintLight15QuadraticAttenuationOff 0x97f8 - -#define GlintSceneAmbientColorRed 0xa800 -#define GlintSceneAmbientColorRedTag 0x0500 -#define GlintSceneAmbientColorRedReg 1 -#define GlintSceneAmbientColorRedOff 0x9800 - -#define GlintSceneAmbientColorGreen 0xa808 -#define GlintSceneAmbientColorGreenTag 0x0501 -#define GlintSceneAmbientColorGreenReg 1 -#define GlintSceneAmbientColorGreenOff 0x9808 - -#define GlintSceneAmbientColorBlue 0xa810 -#define GlintSceneAmbientColorBlueTag 0x0502 -#define GlintSceneAmbientColorBlueReg 1 -#define GlintSceneAmbientColorBlueOff 0x9810 - -#define GlintFrontAmbientColorRed 0xa880 -#define GlintFrontAmbientColorRedTag 0x0510 -#define GlintFrontAmbientColorRedReg 1 -#define GlintFrontAmbientColorRedOff 0x9880 - -#define GlintFrontAmbientColorGreen 0xa888 -#define GlintFrontAmbientColorGreenTag 0x0511 -#define GlintFrontAmbientColorGreenReg 1 -#define GlintFrontAmbientColorGreenOff 0x9888 - -#define GlintFrontAmbientColorBlue 0xa890 -#define GlintFrontAmbientColorBlueTag 0x0512 -#define GlintFrontAmbientColorBlueReg 1 -#define GlintFrontAmbientColorBlueOff 0x9890 - -#define GlintFrontDiffuseColorRed 0xa898 -#define GlintFrontDiffuseColorRedTag 0x0513 -#define GlintFrontDiffuseColorRedReg 1 -#define GlintFrontDiffuseColorRedOff 0x9898 - -#define GlintFrontDiffuseColorGreen 0xa8a0 -#define GlintFrontDiffuseColorGreenTag 0x0514 -#define GlintFrontDiffuseColorGreenReg 1 -#define GlintFrontDiffuseColorGreenOff 0x98a0 - -#define GlintFrontDiffuseColorBlue 0xa8a8 -#define GlintFrontDiffuseColorBlueTag 0x0515 -#define GlintFrontDiffuseColorBlueReg 1 -#define GlintFrontDiffuseColorBlueOff 0x98a8 - -#define GlintFrontAlpha 0xa8b0 -#define GlintFrontAlphaTag 0x0516 -#define GlintFrontAlphaReg 1 -#define GlintFrontAlphaOff 0x98b0 - -#define GlintFrontSpecularColorRed 0xa8b8 -#define GlintFrontSpecularColorRedTag 0x0517 -#define GlintFrontSpecularColorRedReg 1 -#define GlintFrontSpecularColorRedOff 0x98b8 - -#define GlintFrontSpecularColorGreen 0xa8c0 -#define GlintFrontSpecularColorGreenTag 0x0518 -#define GlintFrontSpecularColorGreenReg 1 -#define GlintFrontSpecularColorGreenOff 0x98c0 - -#define GlintFrontSpecularColorBlue 0xa8c8 -#define GlintFrontSpecularColorBlueTag 0x0519 -#define GlintFrontSpecularColorBlueReg 1 -#define GlintFrontSpecularColorBlueOff 0x98c8 - -#define GlintFrontEmissiveColorRed 0xa8d0 -#define GlintFrontEmissiveColorRedTag 0x051a -#define GlintFrontEmissiveColorRedReg 1 -#define GlintFrontEmissiveColorRedOff 0x98d0 - -#define GlintFrontEmissiveColorGreen 0xa8d8 -#define GlintFrontEmissiveColorGreenTag 0x051b -#define GlintFrontEmissiveColorGreenReg 1 -#define GlintFrontEmissiveColorGreenOff 0x98d8 - -#define GlintFrontEmissiveColorBlue 0xa8e0 -#define GlintFrontEmissiveColorBlueTag 0x051c -#define GlintFrontEmissiveColorBlueReg 1 -#define GlintFrontEmissiveColorBlueOff 0x98e0 - -#define GlintFrontSpecularExponent 0xa8e8 -#define GlintFrontSpecularExponentTag 0x051d -#define GlintFrontSpecularExponentReg 1 -#define GlintFrontSpecularExponentOff 0x98e8 - -#define GlintBackAmbientColorRed 0xa900 -#define GlintBackAmbientColorRedTag 0x0520 -#define GlintBackAmbientColorRedReg 1 -#define GlintBackAmbientColorRedOff 0x9900 - -#define GlintBackAmbientColorGreen 0xa908 -#define GlintBackAmbientColorGreenTag 0x0521 -#define GlintBackAmbientColorGreenReg 1 -#define GlintBackAmbientColorGreenOff 0x9908 - -#define GlintBackAmbientColorBlue 0xa910 -#define GlintBackAmbientColorBlueTag 0x0522 -#define GlintBackAmbientColorBlueReg 1 -#define GlintBackAmbientColorBlueOff 0x9910 - -#define GlintBackDiffuseColorRed 0xa918 -#define GlintBackDiffuseColorRedTag 0x0523 -#define GlintBackDiffuseColorRedReg 1 -#define GlintBackDiffuseColorRedOff 0x9918 - -#define GlintBackDiffuseColorGreen 0xa920 -#define GlintBackDiffuseColorGreenTag 0x0524 -#define GlintBackDiffuseColorGreenReg 1 -#define GlintBackDiffuseColorGreenOff 0x9920 - -#define GlintBackDiffuseColorBlue 0xa928 -#define GlintBackDiffuseColorBlueTag 0x0525 -#define GlintBackDiffuseColorBlueReg 1 -#define GlintBackDiffuseColorBlueOff 0x9928 - -#define GlintBackAlpha 0xa930 -#define GlintBackAlphaTag 0x0526 -#define GlintBackAlphaReg 1 -#define GlintBackAlphaOff 0x9930 - -#define GlintBackSpecularColorRed 0xa938 -#define GlintBackSpecularColorRedTag 0x0527 -#define GlintBackSpecularColorRedReg 1 -#define GlintBackSpecularColorRedOff 0x9938 - -#define GlintBackSpecularColorGreen 0xa940 -#define GlintBackSpecularColorGreenTag 0x0528 -#define GlintBackSpecularColorGreenReg 1 -#define GlintBackSpecularColorGreenOff 0x9940 - -#define GlintBackSpecularColorBlue 0xa948 -#define GlintBackSpecularColorBlueTag 0x0529 -#define GlintBackSpecularColorBlueReg 1 -#define GlintBackSpecularColorBlueOff 0x9948 - -#define GlintBackEmissiveColorRed 0xa950 -#define GlintBackEmissiveColorRedTag 0x052a -#define GlintBackEmissiveColorRedReg 1 -#define GlintBackEmissiveColorRedOff 0x9950 - -#define GlintBackEmissiveColorGreen 0xa958 -#define GlintBackEmissiveColorGreenTag 0x052b -#define GlintBackEmissiveColorGreenReg 1 -#define GlintBackEmissiveColorGreenOff 0x9958 - -#define GlintBackEmissiveColorBlue 0xa960 -#define GlintBackEmissiveColorBlueTag 0x052c -#define GlintBackEmissiveColorBlueReg 1 -#define GlintBackEmissiveColorBlueOff 0x9960 - -#define GlintBackSpecularExponent 0xa968 -#define GlintBackSpecularExponentTag 0x052d -#define GlintBackSpecularExponentReg 1 -#define GlintBackSpecularExponentOff 0x9968 - -#define GlintDMAAddr 0xa980 -#define GlintDMAAddrTag 0x0530 -#define GlintDMAAddrReg 1 -#define GlintDMAAddrOff 0x9980 - -#define GlintGammaDMACount 0xa988 -#define GlintGammaDMACountTag 0x0531 -#define GlintGammaDMACountReg 1 -#define GlintGammaDMACountOff 0x9988 - -#define GlintCommandInterrupt 0xa990 -#define GlintCommandInterruptTag 0x0532 -#define GlintCommandInterruptReg 1 -#define GlintCommandInterruptOff 0x9990 - -#define GlintDMACall 0xa998 -#define GlintDMACallTag 0x0533 -#define GlintDMACallReg 1 -#define GlintDMACallOff 0x9998 - -#define GlintDMAReturn 0xa9a0 -#define GlintDMAReturnTag 0x0534 -#define GlintDMAReturnReg 1 -#define GlintDMAReturnOff 0x99a0 - -#define GlintDMARectangularRead 0xa9a8 -#define GlintDMARectangularReadTag 0x0535 -#define GlintDMARectangularReadReg 1 -#define GlintDMARectangularReadOff 0x99a8 - -#define GlintDMARectangleReadAddress 0xa9b0 -#define GlintDMARectangleReadAddressTag 0x0536 -#define GlintDMARectangleReadAddressReg 1 -#define GlintDMARectangleReadAddressOff 0x99b0 - -#define GlintDMARectangleReadLinePitch 0xa9b8 -#define GlintDMARectangleReadLinePitchTag 0x0537 -#define GlintDMARectangleReadLinePitchReg 1 -#define GlintDMARectangleReadLinePitchOff 0x99b8 - -#define GlintDMARectangleReadTarget 0xa9c0 -#define GlintDMARectangleReadTargetTag 0x0538 -#define GlintDMARectangleReadTargetReg 1 -#define GlintDMARectangleReadTargetOff 0x99c0 - -#define GlintDMARectangleWrite 0xa9c8 -#define GlintDMARectangleWriteTag 0x0539 -#define GlintDMARectangleWriteReg 1 -#define GlintDMARectangleWriteOff 0x99c8 - -#define GlintDMARectangleWriteAddress 0xa9d0 -#define GlintDMARectangleWriteAddressTag 0x053a -#define GlintDMARectangleWriteAddressReg 1 -#define GlintDMARectangleWriteAddressOff 0x99d0 - -#define GlintDMARectangleWriteLinePitch 0xa9d8 -#define GlintDMARectangleWriteLinePitchTag 0x053b -#define GlintDMARectangleWriteLinePitchReg 1 -#define GlintDMARectangleWriteLinePitchOff 0x99d8 - -#define GlintDMAOutputAddress 0xa9e0 -#define GlintDMAOutputAddressTag 0x053c -#define GlintDMAOutputAddressReg 1 -#define GlintDMAOutputAddressOff 0x99e0 - -#define GlintDMAOutputCount 0xa9e8 -#define GlintDMAOutputCountTag 0x053d -#define GlintDMAOutputCountReg 1 -#define GlintDMAOutputCountOff 0x99e8 - -#define GlintDMAReadGLINTSource 0xa9f0 -#define GlintDMAReadGLINTSourceTag 0x053e -#define GlintDMAReadGLINTSourceReg 1 -#define GlintDMAReadGLINTSourceOff 0x99f0 - -#define GlintDMAFeedback 0xaa10 -#define GlintDMAFeedbackTag 0x0542 -#define GlintDMAFeedbackReg 1 -#define GlintDMAFeedbackOff 0x9a10 - -#define GlintTransformModeAnd 0xaa80 -#define GlintTransformModeAndTag 0x0550 -#define GlintTransformModeAndReg 1 -#define GlintTransformModeAndOff 0x9a80 - -#define GlintTransformModeOr 0xaa88 -#define GlintTransformModeOrTag 0x0551 -#define GlintTransformModeOrReg 1 -#define GlintTransformModeOrOff 0x9a88 - -#define GlintGeometryModeAnd 0xaa90 -#define GlintGeometryModeAndTag 0x0552 -#define GlintGeometryModeAndReg 1 -#define GlintGeometryModeAndOff 0x9a90 - -#define GlintGeometryModeOr 0xaa98 -#define GlintGeometryModeOrTag 0x0553 -#define GlintGeometryModeOrReg 1 -#define GlintGeometryModeOrOff 0x9a98 - -#define GlintNormalizeModeAnd 0xaaa0 -#define GlintNormalizeModeAndTag 0x0554 -#define GlintNormalizeModeAndReg 1 -#define GlintNormalizeModeAndOff 0x9aa0 - -#define GlintNormalizeModeOr 0xaaa8 -#define GlintNormalizeModeOrTag 0x0555 -#define GlintNormalizeModeOrReg 1 -#define GlintNormalizeModeOrOff 0x9aa8 - -#define GlintLightingModeAnd 0xaab0 -#define GlintLightingModeAndTag 0x0556 -#define GlintLightingModeAndReg 1 -#define GlintLightingModeAndOff 0x9ab0 - -#define GlintLightingModeOr 0xaab8 -#define GlintLightingModeOrTag 0x0557 -#define GlintLightingModeOrReg 1 -#define GlintLightingModeOrOff 0x9ab8 - -#define GlintColorMaterialModeAnd 0xaac0 -#define GlintColorMaterialModeAndTag 0x0558 -#define GlintColorMaterialModeAndReg 1 -#define GlintColorMaterialModeAndOff 0x9ac0 - -#define GlintColorMaterialModeOr 0xaac8 -#define GlintColorMaterialModeOrTag 0x0559 -#define GlintColorMaterialModeOrReg 1 -#define GlintColorMaterialModeOrOff 0x9ac8 - -#define GlintDeltaModeAnd 0xaad0 -#define GlintDeltaModeAndTag 0x055a -#define GlintDeltaModeAndReg 1 -#define GlintDeltaModeAndOff 0x9ad0 - -#define GlintDeltaModeOr 0xaad8 -#define GlintDeltaModeOrTag 0x055b -#define GlintDeltaModeOrReg 1 -#define GlintDeltaModeOrOff 0x9ad8 - -#define GlintPointModeAnd 0xaae0 -#define GlintPointModeAndTag 0x055c -#define GlintPointModeAndReg 1 -#define GlintPointModeAndOff 0x9ae0 - -#define GlintPointModeOr 0xaae8 -#define GlintPointModeOrTag 0x055d -#define GlintPointModeOrReg 1 -#define GlintPointModeOrOff 0x9ae8 - -#define GlintLineModeAnd 0xaaf0 -#define GlintLineModeAndTag 0x055e -#define GlintLineModeAndReg 1 -#define GlintLineModeAndOff 0x9af0 - -#define GlintLineModeOr 0xaaf8 -#define GlintLineModeOrTag 0x055f -#define GlintLineModeOrReg 1 -#define GlintLineModeOrOff 0x9af8 - -#define GlintTriangleModeAnd 0xab00 -#define GlintTriangleModeAndTag 0x0560 -#define GlintTriangleModeAndReg 1 -#define GlintTriangleModeAndOff 0x9b00 - -#define GlintTriangleModeOr 0xab08 -#define GlintTriangleModeOrTag 0x0561 -#define GlintTriangleModeOrReg 1 -#define GlintTriangleModeOrOff 0x9b08 - -#define GlintMaterialModeAnd 0xab10 -#define GlintMaterialModeAndTag 0x0562 -#define GlintMaterialModeAndReg 1 -#define GlintMaterialModeAndOff 0x9b10 - -#define GlintMaterialModeOr 0xab18 -#define GlintMaterialModeOrTag 0x0563 -#define GlintMaterialModeOrReg 1 -#define GlintMaterialModeOrOff 0x9b18 - -#define GlintWindowAnd 0xab80 -#define GlintWindowAndTag 0x0570 -#define GlintWindowAndReg 1 -#define GlintWindowAndOff 0x9b80 - -#define GlintWindowOr 0xab88 -#define GlintWindowOrTag 0x0571 -#define GlintWindowOrReg 1 -#define GlintWindowOrOff 0x9b88 - -#define GlintLBReadModeAnd 0xab90 -#define GlintLBReadModeAndTag 0x0572 -#define GlintLBReadModeAndReg 1 -#define GlintLBReadModeAndOff 0x9b90 - -#define GlintLBReadModeOr 0xab98 -#define GlintLBReadModeOrTag 0x0573 -#define GlintLBReadModeOrReg 1 -#define GlintLBReadModeOrOff 0x9b98 -#endif diff --git a/src/mesa/drivers/dri/gamma/gamma_context.c b/src/mesa/drivers/dri/gamma/gamma_context.c deleted file mode 100644 index 5e666c5c8c6..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_context.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - * 3DLabs Gamma driver. - * - */ -#include "gamma_context.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "vbo/vbo.h" - -#include "tnl/tnl.h" -#include "tnl/t_pipeline.h" - -#include "drivers/common/driverfuncs.h" - -#include "main/context.h" -#include "main/simple_list.h" -#include "main/imports.h" -#include "main/matrix.h" -#include "main/extensions.h" -#if defined(USE_X86_ASM) -#include "x86/common_x86_asm.h" -#endif -#include "main/simple_list.h" -#include "main/mm.h" - - -#include "gamma_vb.h" -#include "gamma_tris.h" -#include "gamma_macros.h" - -extern const struct tnl_pipeline_stage _gamma_render_stage; - -static const struct tnl_pipeline_stage *gamma_pipeline[] = { - &_tnl_vertex_transform_stage, - &_tnl_normal_transform_stage, - &_tnl_lighting_stage, - &_tnl_fog_coordinate_stage, - &_tnl_texgen_stage, - &_tnl_texture_transform_stage, - /* REMOVE: point attenuation stage */ -#if 1 - &_gamma_render_stage, /* ADD: unclipped rastersetup-to-dma */ -#endif - &_tnl_render_stage, - 0, -}; - -GLboolean gammaCreateContext( const __GLcontextModes *glVisual, - __DRIcontext *driContextPriv, - void *sharedContextPrivate) -{ - GLcontext *ctx, *shareCtx; - __DRIscreen *sPriv = driContextPriv->driScreenPriv; - gammaContextPtr gmesa; - gammaScreenPtr gammascrn; - GLINTSAREADRIPtr saPriv=(GLINTSAREADRIPtr)(((char*)sPriv->pSAREA)+ - sizeof(drm_sarea_t)); - struct dd_function_table functions; - - gmesa = (gammaContextPtr) CALLOC( sizeof(*gmesa) ); - if (!gmesa) - return GL_FALSE; - - /* Init default driver functions then plug in our gamma-specific functions - * (the texture functions are especially important) - */ - _mesa_init_driver_functions( &functions ); - gammaDDInitTextureFuncs( &functions ); - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((gammaContextPtr) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - - gmesa->glCtx = _mesa_create_context(glVisual, shareCtx, - &functions, (void *) gmesa); - if (!gmesa->glCtx) { - FREE(gmesa); - return GL_FALSE; - } - - gmesa->driContext = driContextPriv; - gmesa->driScreen = sPriv; - gmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */ - - gmesa->hHWContext = driContextPriv->hHWContext; - gmesa->driHwLock = &sPriv->pSAREA->lock; - gmesa->driFd = sPriv->fd; - gmesa->sarea = saPriv; - - gammascrn = gmesa->gammaScreen = (gammaScreenPtr)(sPriv->private); - - ctx = gmesa->glCtx; - - ctx->Const.MaxTextureLevels = GAMMA_TEX_MAXLEVELS; - ctx->Const.MaxTextureUnits = 1; /* Permedia 3 */ - ctx->Const.MaxTextureImageUnits = 1; - ctx->Const.MaxTextureCoordUnits = 1; - - ctx->Const.MinLineWidth = 0.0; - ctx->Const.MaxLineWidth = 255.0; - - ctx->Const.MinLineWidthAA = 0.0; - ctx->Const.MaxLineWidthAA = 65536.0; - - ctx->Const.MinPointSize = 0.0; - ctx->Const.MaxPointSize = 255.0; - - ctx->Const.MinPointSizeAA = 0.5; /* 4x4 quality mode */ - ctx->Const.MaxPointSizeAA = 16.0; - ctx->Const.PointSizeGranularity = 0.25; - - ctx->Const.MaxDrawBuffers = 1; - - gmesa->texHeap = mmInit( 0, gmesa->gammaScreen->textureSize ); - - make_empty_list(&gmesa->TexObjList); - make_empty_list(&gmesa->SwappedOut); - - gmesa->CurrentTexObj[0] = 0; - gmesa->CurrentTexObj[1] = 0; /* Permedia 3, second texture */ - - gmesa->RenderIndex = ~0; - - - /* Initialize the software rasterizer and helper modules. - */ - _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - - /* Install the customized pipeline: - */ - _tnl_destroy_pipeline( ctx ); - _tnl_install_pipeline( ctx, gamma_pipeline ); - - /* Configure swrast & TNL to match hardware characteristics: - */ - _swrast_allow_pixel_fog( ctx, GL_FALSE ); - _swrast_allow_vertex_fog( ctx, GL_TRUE ); - _tnl_allow_pixel_fog( ctx, GL_FALSE ); - _tnl_allow_vertex_fog( ctx, GL_TRUE ); - - gammaInitVB( ctx ); - gammaDDInitExtensions( ctx ); - /* XXX these should really go right after _mesa_init_driver_functions() */ - gammaDDInitDriverFuncs( ctx ); - gammaDDInitStateFuncs( ctx ); - gammaDDInitSpanFuncs( ctx ); - gammaDDInitTriFuncs( ctx ); - gammaDDInitState( gmesa ); - - gammaInitTextureObjects( ctx ); - - driContextPriv->driverPrivate = (void *)gmesa; - - GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext, - 1, &gmesa->bufIndex, &gmesa->bufSize, - &gmesa->buf, &gmesa->bufCount, gammascrn); - -#ifdef DO_VALIDATE - GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext, - 1, &gmesa->WCbufIndex, &gmesa->WCbufSize, - &gmesa->WCbuf, &gmesa->WCbufCount, gammascrn); -#endif - - switch (glVisual->depthBits) { - case 16: - gmesa->DeltaMode = DM_Depth16; - gmesa->depth_scale = 1.0f / 0xffff; - break; - case 24: - gmesa->DeltaMode = DM_Depth24; - gmesa->depth_scale = 1.0f / 0xffffff; - break; - case 32: - gmesa->DeltaMode = DM_Depth32; - gmesa->depth_scale = 1.0f / 0xffffffff; - break; - default: - break; - } - - gmesa->DepthSize = glVisual->depthBits; - gmesa->Flags = GAMMA_FRONT_BUFFER; - gmesa->Flags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0); - gmesa->Flags |= (gmesa->DepthSize > 0 ? GAMMA_DEPTH_BUFFER : 0); - - gmesa->EnabledFlags = GAMMA_FRONT_BUFFER; - gmesa->EnabledFlags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0); - - - if (gmesa->Flags & GAMMA_BACK_BUFFER) { - gmesa->readOffset = gmesa->drawOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp; - } else { - gmesa->readOffset = gmesa->drawOffset = 0; - } - - gammaInitHW( gmesa ); - - driContextPriv->driverPrivate = (void *)gmesa; - - return GL_TRUE; -} diff --git a/src/mesa/drivers/dri/gamma/gamma_context.h b/src/mesa/drivers/dri/gamma/gamma_context.h deleted file mode 100644 index b03dfa6fb4f..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_context.h +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - */ - -#ifndef _GAMMA_CONTEXT_H_ -#define _GAMMA_CONTEXT_H_ - -#include "dri_util.h" -#include "drm.h" -#include "drm_sarea.h" -#include "main/colormac.h" -#include "gamma_regs.h" -#include "gamma_screen.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "glint_dri.h" -#include "main/mm.h" - -typedef union { - unsigned int i; - float f; -} dmaBufRec, *dmaBuf; - -/* Flags for context */ -#define GAMMA_FRONT_BUFFER 0x00000001 -#define GAMMA_BACK_BUFFER 0x00000002 -#define GAMMA_DEPTH_BUFFER 0x00000004 -#define GAMMA_STENCIL_BUFFER 0x00000008 -#define GAMMA_ACCUM_BUFFER 0x00000010 - -#define GAMMA_MAX_TEXTURE_SIZE 2048 - -/* These are the minimum requirements and should probably be increased */ -#define MAX_MODELVIEW_STACK 16 -#define MAX_PROJECTION_STACK 2 -#define MAX_TEXTURE_STACK 2 - -extern void gammaDDUpdateHWState(GLcontext *ctx); -extern gammaScreenPtr gammaCreateScreen(__DRIscreen *sPriv); -extern void gammaDestroyScreen(__DRIscreen *sPriv); -extern GLboolean gammaCreateContext( const __GLcontextModes *glVisual, - __DRIcontext *driContextPriv, - void *sharedContextPrivate); - -#define GAMMA_UPLOAD_ALL 0xffffffff -#define GAMMA_UPLOAD_CLIPRECTS 0x00000002 -#define GAMMA_UPLOAD_ALPHA 0x00000004 -#define GAMMA_UPLOAD_BLEND 0x00000008 -#define GAMMA_UPLOAD_DEPTH 0x00000010 -#define GAMMA_UPLOAD_VIEWPORT 0x00000020 -#define GAMMA_UPLOAD_SHADE 0x00000040 -#define GAMMA_UPLOAD_CLIP 0x00000080 -#define GAMMA_UPLOAD_MASKS 0x00000100 -#define GAMMA_UPLOAD_WINDOW 0x00000200 /* defunct */ -#define GAMMA_UPLOAD_GEOMETRY 0x00000400 -#define GAMMA_UPLOAD_POLYGON 0x00000800 -#define GAMMA_UPLOAD_DITHER 0x00001000 -#define GAMMA_UPLOAD_LOGICOP 0x00002000 -#define GAMMA_UPLOAD_FOG 0x00004000 -#define GAMMA_UPLOAD_LIGHT 0x00008000 -#define GAMMA_UPLOAD_CONTEXT 0x00010000 -#define GAMMA_UPLOAD_TEX0 0x00020000 -#define GAMMA_UPLOAD_STIPPLE 0x00040000 -#define GAMMA_UPLOAD_TRANSFORM 0x00080000 -#define GAMMA_UPLOAD_LINEMODE 0x00100000 -#define GAMMA_UPLOAD_POINTMODE 0x00200000 -#define GAMMA_UPLOAD_TRIMODE 0x00400000 - -#define GAMMA_NEW_CLIP 0x00000001 -#define GAMMA_NEW_WINDOW 0x00000002 -#define GAMMA_NEW_CONTEXT 0x00000004 -#define GAMMA_NEW_TEXTURE 0x00000008 /* defunct */ -#define GAMMA_NEW_ALPHA 0x00000010 -#define GAMMA_NEW_DEPTH 0x00000020 -#define GAMMA_NEW_MASKS 0x00000040 -#define GAMMA_NEW_POLYGON 0x00000080 -#define GAMMA_NEW_CULL 0x00000100 -#define GAMMA_NEW_LOGICOP 0x00000200 -#define GAMMA_NEW_FOG 0x00000400 -#define GAMMA_NEW_LIGHT 0x00000800 -#define GAMMA_NEW_STIPPLE 0x00001000 -#define GAMMA_NEW_ALL 0xffffffff - -#define GAMMA_FALLBACK_TRI 0x00000001 -#define GAMMA_FALLBACK_TEXTURE 0x00000002 - -#define FLUSH_BATCH(gmesa) do { \ - /*FLUSH_DMA_BUFFER(gmesa);*/ \ -} while(0) - -struct gamma_context; -typedef struct gamma_context gammaContextRec; -typedef struct gamma_context *gammaContextPtr; -typedef struct gamma_texture_object_t *gammaTextureObjectPtr; - -#define VALID_GAMMA_TEXTURE_OBJECT(tobj) (tobj) - -#define GAMMA_TEX_MAXLEVELS 12 /* 2K x 2K */ - -/* For shared texture space managment, these texture objects may also - * be used as proxies for regions of texture memory containing other - * client's textures. Such proxy textures (not to be confused with GL - * proxy textures) are subject to the same LRU aging we use for our - * own private textures, and thus we have a mechanism where we can - * fairly decide between kicking out our own textures and those of - * other clients. - * - * Non-local texture objects have a valid MemBlock to describe the - * region managed by the other client, and can be identified by - * 't->globj == 0' - */ -struct gamma_texture_object_t { - struct gamma_texture_object_t *next, *prev; - - GLuint age; - struct gl_texture_object *globj; - - int Pitch; - int Height; - int texelBytes; - int totalSize; - int bound; - - struct mem_block *MemBlock; - char * BufAddr; - - GLuint min_level; - GLuint max_level; - GLuint dirty_images; - - GLint firstLevel, lastLevel; /* upload tObj->Image[0][first .. lastLevel] */ - - struct { - const struct gl_texture_image *image; - int offset; /* into BufAddr */ - int height; - int internalFormat; - } image[GAMMA_TEX_MAXLEVELS]; - - uint32_t TextureBaseAddr[GAMMA_TEX_MAXLEVELS]; - uint32_t TextureAddressMode; - uint32_t TextureColorMode; - uint32_t TextureFilterMode; - uint32_t TextureFormat; - uint32_t TextureReadMode; - uint32_t TextureBorderColor; -}; - -#define GAMMA_NO_PALETTE 0x0 -#define GAMMA_USE_PALETTE 0x1 -#define GAMMA_UPDATE_PALETTE 0x2 -#define GAMMA_FALLBACK_PALETTE 0x4 - -void gammaUpdateTextureState( GLcontext *ctx ); - -void gammaDestroyTexObj( gammaContextPtr gmesa, gammaTextureObjectPtr t ); -void gammaSwapOutTexObj( gammaContextPtr gmesa, gammaTextureObjectPtr t ); -void gammaUploadTexImages( gammaContextPtr gmesa, gammaTextureObjectPtr t ); - -void gammaResetGlobalLRU( gammaContextPtr gmesa ); -void gammaUpdateTexLRU( gammaContextPtr gmesa, gammaTextureObjectPtr t ); -void gammaTexturesGone( gammaContextPtr gmesa, - GLuint start, GLuint end, - GLuint in_use ); - -void gammaEmitHwState( gammaContextPtr gmesa ); -void gammaDDInitExtensions( GLcontext *ctx ); -void gammaDDInitDriverFuncs( GLcontext *ctx ); -void gammaDDInitSpanFuncs( GLcontext *ctx ); -void gammaDDInitState( gammaContextPtr gmesa ); -void gammaInitHW( gammaContextPtr gmesa ); -void gammaDDInitStateFuncs( GLcontext *ctx ); -void gammaDDInitTextureFuncs( struct dd_function_table *table ); -void gammaInitTextureObjects( GLcontext *ctx ); -void gammaDDInitTriFuncs( GLcontext *ctx ); - -void gammaUpdateWindow( GLcontext *ctx ); -void gammaUpdateViewportOffset( GLcontext *ctx ); - -void gammaPrintLocalLRU( gammaContextPtr gmesa ); -void gammaPrintGlobalLRU( gammaContextPtr gmesa ); - -extern void gammaFallback( gammaContextPtr gmesa, GLuint bit, GLboolean mode ); -#define FALLBACK( imesa, bit, mode ) gammaFallback( imesa, bit, mode ) - -/* Use the templated vertex formats. Only one of these is used in gamma. - */ -#define TAG(x) gamma##x -#include "tnl_dd/t_dd_vertex.h" -#undef TAG - -typedef void (*gamma_quad_func)( gammaContextPtr, - const gammaVertex *, - const gammaVertex *, - const gammaVertex *, - const gammaVertex * ); -typedef void (*gamma_tri_func)( gammaContextPtr, - const gammaVertex *, - const gammaVertex *, - const gammaVertex * ); -typedef void (*gamma_line_func)( gammaContextPtr, - const gammaVertex *, - const gammaVertex * ); -typedef void (*gamma_point_func)( gammaContextPtr, - const gammaVertex * ); - - -struct gamma_context { - GLcontext *glCtx; /* Mesa context */ - - __DRIcontext *driContext; - __DRIscreen *driScreen; - __DRIdrawable *driDrawable; - - GLuint new_gl_state; - GLuint new_state; - GLuint dirty; - - GLINTSAREADRIPtr sarea; - - /* Mirrors of some DRI state - */ - drm_context_t hHWContext; - drm_hw_lock_t *driHwLock; - int driFd; - - GLuint numClipRects; /* Cliprects for the draw buffer */ - drm_clip_rect_t *pClipRects; - - dmaBuf buf; /* DMA buffer for regular cmds */ - int bufIndex; - int bufSize; - int bufCount; - - dmaBuf WCbuf; /* DMA buffer for window changed cmds */ - int WCbufIndex; - int WCbufSize; - int WCbufCount; - - gammaScreenPtr gammaScreen; /* Screen private DRI data */ - - int drawOffset; - int readOffset; - - gamma_point_func draw_point; - gamma_line_func draw_line; - gamma_tri_func draw_tri; - gamma_quad_func draw_quad; - - GLuint Fallback; - GLuint RenderIndex; - GLuint SetupNewInputs; - GLuint SetupIndex; - - GLuint vertex_format; - GLuint vertex_size; - GLuint vertex_stride_shift; - GLubyte *verts; - - GLfloat hw_viewport[16]; - GLuint hw_primitive; - GLenum render_primitive; - - GLfloat depth_scale; - - gammaTextureObjectPtr CurrentTexObj[2]; - struct gamma_texture_object_t TexObjList; - struct gamma_texture_object_t SwappedOut; - GLenum TexEnvImageFmt[2]; - - struct mem_block *texHeap; - - unsigned int lastSwap; - int texAge; - int ctxAge; - int dirtyAge; - unsigned int lastStamp; - - - uint32_t ClearColor; - uint32_t Color; - uint32_t DitherMode; - uint32_t ClearDepth; - uint32_t FogMode; - uint32_t AreaStippleMode; - uint32_t LBReadFormat; - uint32_t LBWriteFormat; - uint32_t LineMode; - uint32_t PointMode; - uint32_t TriangleMode; - uint32_t AntialiasMode; - GLfloat ViewportScaleX; - GLfloat ViewportScaleY; - GLfloat ViewportScaleZ; - GLfloat ViewportOffsetX; - GLfloat ViewportOffsetY; - GLfloat ViewportOffsetZ; - int MatrixMode; - int DepthMode; - int TransformMode; - int LBReadMode; - int FBReadMode; - int FBWindowBase; - int LBWindowBase; - int ColorDDAMode; - int GeometryMode; - int AlphaTestMode; - int AlphaBlendMode; - int AB_FBReadMode; - int AB_FBReadMode_Save; - int DeltaMode; - int ColorMaterialMode; - int FBHardwareWriteMask; - int MaterialMode; - int NormalizeMode; - int LightingMode; - int Light0Mode; - int Light1Mode; - int Light2Mode; - int Light3Mode; - int Light4Mode; - int Light5Mode; - int Light6Mode; - int Light7Mode; - int Light8Mode; - int Light9Mode; - int Light10Mode; - int Light11Mode; - int Light12Mode; - int Light13Mode; - int Light14Mode; - int Light15Mode; - int LogicalOpMode; - int ScissorMode; - int ScissorMaxXY; - int ScissorMinXY; - int Window; /* GID part probably should be in draw priv */ - int WindowOrigin; - int x, y, w, h; /* Probably should be in drawable priv */ - int FrameCount; /* Probably should be in drawable priv */ - int NotClipped; /* Probably should be in drawable priv */ - int WindowChanged; /* Probably should be in drawabl... */ - int Flags; - int EnabledFlags; - int DepthSize; - int Begin; - GLenum ErrorValue; - int Texture1DEnabled; - int Texture2DEnabled; - - float ModelView[16]; - float Proj[16]; - float ModelViewProj[16]; - float Texture[16]; - - float ModelViewStack[(MAX_MODELVIEW_STACK-1)*16]; - int ModelViewCount; - float ProjStack[(MAX_PROJECTION_STACK-1)*16]; - int ProjCount; - float TextureStack[(MAX_TEXTURE_STACK-1)*16]; - int TextureCount; -}; - -static INLINE GLuint gammaPackColor( GLuint cpp, - GLubyte r, GLubyte g, - GLubyte b, GLubyte a ) -{ - switch ( cpp ) { - case 2: - return PACK_COLOR_565( r, g, b ); - case 4: - return PACK_COLOR_8888( a, r, g, b ); - default: - return 0; - } -} - -#define GAMMA_CONTEXT(ctx) ((gammaContextPtr)(ctx->DriverCtx)) - -#endif /* _GAMMA_CONTEXT_H_ */ diff --git a/src/mesa/drivers/dri/gamma/gamma_dd.c b/src/mesa/drivers/dri/gamma/gamma_dd.c deleted file mode 100644 index 389d2231e76..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_dd.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - */ - -#include "gamma_context.h" -#include "gamma_vb.h" -#include "gamma_lock.h" -#include "gamma_macros.h" -#if defined(USE_X86_ASM) -#include "x86/common_x86_asm.h" -#endif - -#include "main/context.h" -#include "swrast/swrast.h" - -#define GAMMA_DATE "20021125" - - -/* Return the width and height of the current color buffer. - */ -static void gammaDDGetBufferSize( GLframebuffer *buffer, - GLuint *width, GLuint *height ) -{ - GET_CURRENT_CONTEXT(ctx); - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - GAMMAHW_LOCK( gmesa ); - *width = gmesa->driDrawable->w; - *height = gmesa->driDrawable->h; - GAMMAHW_UNLOCK( gmesa ); -} - - -/* Return various strings for glGetString(). - */ -static const GLubyte *gammaDDGetString( GLcontext *ctx, GLenum name ) -{ - static char buffer[128]; - - switch ( name ) { - case GL_VENDOR: - return (GLubyte *)"VA Linux Systems, Inc."; - - case GL_RENDERER: - sprintf( buffer, "Mesa DRI Gamma " GAMMA_DATE ); - - /* Append any CPU-specific information. - */ -#ifdef USE_X86_ASM - if ( _mesa_x86_cpu_features ) { - strncat( buffer, " x86", 4 ); - } -#ifdef USE_MMX_ASM - if ( cpu_has_mmx ) { - strncat( buffer, "/MMX", 4 ); - } -#endif -#ifdef USE_3DNOW_ASM - if ( cpu_has_3dnow ) { - strncat( buffer, "/3DNow!", 7 ); - } -#endif -#ifdef USE_SSE_ASM - if ( cpu_has_xmm ) { - strncat( buffer, "/SSE", 4 ); - } -#endif -#endif - return (GLubyte *)buffer; - - default: - return NULL; - } -} - -/* Enable the extensions supported by this driver. - */ -void gammaDDInitExtensions( GLcontext *ctx ) -{ - /* None... */ -} - -/* Initialize the driver's misc functions. - */ -void gammaDDInitDriverFuncs( GLcontext *ctx ) -{ - ctx->Driver.GetBufferSize = gammaDDGetBufferSize; - ctx->Driver.GetString = gammaDDGetString; -} diff --git a/src/mesa/drivers/dri/gamma/gamma_inithw.c b/src/mesa/drivers/dri/gamma/gamma_inithw.c deleted file mode 100644 index 735acb7a576..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_inithw.c +++ /dev/null @@ -1,551 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * Kevin E. Martin - * - */ - -#include "gamma_context.h" -#include "gamma_macros.h" -#include "glint_dri.h" - -void gammaInitHW( gammaContextPtr gmesa ) -{ - GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)gmesa->driScreen->pDevPriv; - int i; - - if (gDRIPriv->numMultiDevices == 2) { - /* Set up each MX's ScanLineOwnership for OpenGL */ - CHECK_DMA_BUFFER(gmesa, 5); - WRITE(gmesa->buf, BroadcastMask, 1); - WRITE(gmesa->buf, ScanLineOwnership, 5); /* Use bottom left as [0,0] */ - WRITE(gmesa->buf, BroadcastMask, 2); - WRITE(gmesa->buf, ScanLineOwnership, 1); /* Use bottom left as [0,0] */ - /* Broadcast to both MX's */ - WRITE(gmesa->buf, BroadcastMask, 3); - FLUSH_DMA_BUFFER(gmesa); - } - - gmesa->AlphaBlendMode = (AlphaBlendModeDisable | - AB_Src_One | - AB_Dst_Zero | - AB_NoAlphaBufferPresent | - AB_ColorFmt_8888 | - AB_ColorOrder_RGB | - AB_OpenGLType | - AB_AlphaDst_FBData | - AB_ColorConversionScale | - AB_AlphaConversionScale); - - gmesa->DitherMode = DitherModeEnable | DM_ColorOrder_RGB; - - switch (gmesa->gammaScreen->cpp) { - case 2: - gmesa->DitherMode |= DM_ColorFmt_5555; - gmesa->AlphaBlendMode |= AB_ColorFmt_5555; - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PixelSize, 1); - break; - case 4: - gmesa->DitherMode |= DM_ColorFmt_8888; - gmesa->AlphaBlendMode |= AB_ColorFmt_8888; - WRITE(gmesa->buf, PixelSize, 0); - break; - } - - /* FIXME for stencil, gid, etc */ - switch (gmesa->DepthSize) { - case 16: - gmesa->LBReadFormat = - (LBRF_DepthWidth16 | - LBRF_StencilWidth8 | - LBRF_StencilPos16 | - LBRF_FrameCount8 | - LBRF_FrameCountPos24 | - LBRF_GIDWidth4 | - LBRF_GIDPos32 ); - gmesa->LBWriteFormat = - (LBRF_DepthWidth16 | - LBRF_StencilWidth8 | - LBRF_StencilPos16 | - LBRF_FrameCount8 | - LBRF_FrameCountPos24 | - LBRF_GIDWidth4 | - LBRF_GIDPos32 ); - break; - case 24: - gmesa->LBReadFormat = - (LBRF_DepthWidth24 | - LBRF_StencilWidth8 | - LBRF_StencilPos24 | - LBRF_FrameCount8 | - LBRF_FrameCountPos32 | - LBRF_GIDWidth4 | - LBRF_GIDPos36 ); - gmesa->LBWriteFormat = - (LBRF_DepthWidth24 | - LBRF_StencilWidth8 | - LBRF_StencilPos24 | - LBRF_FrameCount8 | - LBRF_FrameCountPos32 | - LBRF_GIDWidth4 | - LBRF_GIDPos36 ); - break; - case 32: - gmesa->LBReadFormat = - (LBRF_DepthWidth32 | - LBRF_StencilWidth8 | - LBRF_StencilPos32 | - LBRF_FrameCount8 | - LBRF_FrameCountPos40 | - LBRF_GIDWidth4 | - LBRF_GIDPos44 ); - gmesa->LBWriteFormat = - (LBRF_DepthWidth32 | - LBRF_StencilWidth8 | - LBRF_StencilPos32 | - LBRF_FrameCount8 | - LBRF_FrameCountPos40 | - LBRF_GIDWidth4 | - LBRF_GIDPos44 ); - break; - } - - gmesa->FBHardwareWriteMask = 0xffffffff; - gmesa->FogMode = FogModeDisable; - gmesa->ClearDepth = 0xffffffff; - gmesa->AreaStippleMode = AreaStippleModeDisable; - gmesa->x = 0; - gmesa->y = 0; - gmesa->w = 0; - gmesa->h = 0; - gmesa->FrameCount = 0; - gmesa->MatrixMode = GL_MODELVIEW; - gmesa->ModelViewCount = 0; - gmesa->ProjCount = 0; - gmesa->TextureCount = 0; - gmesa->PointMode = PM_AntialiasQuality_4x4; - gmesa->LineMode = LM_AntialiasQuality_4x4; - gmesa->TriangleMode = TM_AntialiasQuality_4x4; - gmesa->AntialiasMode = AntialiasModeDisable; - - for (i = 0; i < 16; i++) - if (i % 5 == 0) - gmesa->ModelView[i] = - gmesa->Proj[i] = - gmesa->ModelViewProj[i] = - gmesa->Texture[i] = 1.0; - else - gmesa->ModelView[i] = - gmesa->Proj[i] = - gmesa->ModelViewProj[i] = - gmesa->Texture[i] = 0.0; - - gmesa->LBReadMode = (LBReadSrcDisable | - LBReadDstDisable | - LBDataTypeDefault | - LBWindowOriginBot | - gDRIPriv->pprod); - gmesa->FBReadMode = (FBReadSrcDisable | - FBReadDstDisable | - FBDataTypeDefault | - FBWindowOriginBot | - gDRIPriv->pprod); - - if (gDRIPriv->numMultiDevices == 2) { - gmesa->LBReadMode |= LBScanLineInt2; - gmesa->FBReadMode |= FBScanLineInt2; - gmesa->LBWindowBase = gmesa->driScreen->fbWidth * - (gmesa->driScreen->fbHeight/2 - 1); - gmesa->FBWindowBase = gmesa->driScreen->fbWidth * - (gmesa->driScreen->fbHeight/2 - 1); - } else { - gmesa->LBWindowBase = gmesa->driScreen->fbWidth * - (gmesa->driScreen->fbHeight - 1); - gmesa->FBWindowBase = gmesa->driScreen->fbWidth * - (gmesa->driScreen->fbHeight - 1); - } - - gmesa->Begin = (B_AreaStippleDisable | - B_LineStippleDisable | - B_AntiAliasDisable | - B_TextureDisable | - B_FogDisable | - B_SubPixelCorrectEnable | - B_PrimType_Null); - - gmesa->ColorDDAMode = (ColorDDAEnable | - ColorDDAGouraud); - - gmesa->GeometryMode = (GM_TextureDisable | - GM_FogDisable | - GM_FogExp | - GM_FrontPolyFill | - GM_BackPolyFill | - GM_FrontFaceCCW | - GM_PolyCullDisable | - GM_PolyCullBack | - GM_ClipShortLinesDisable | - GM_ClipSmallTrisDisable | - GM_RenderMode | - GM_Feedback2D | - GM_CullFaceNormDisable | - GM_AutoFaceNormDisable | - GM_GouraudShading | - GM_UserClipNone | - GM_PolyOffsetPointDisable | - GM_PolyOffsetLineDisable | - GM_PolyOffsetFillDisable | - GM_InvertFaceNormCullDisable); - - gmesa->AlphaTestMode = (AlphaTestModeDisable | - AT_Always); - - gmesa->AB_FBReadMode_Save = gmesa->AB_FBReadMode = 0; - - gmesa->Window = (WindowEnable | /* For GID testing */ - W_PassIfEqual | - (0 << 5)); /* GID part is set from draw priv (below) */ - - gmesa->NotClipped = GL_FALSE; - gmesa->WindowChanged = GL_TRUE; - - gmesa->Texture1DEnabled = GL_FALSE; - gmesa->Texture2DEnabled = GL_FALSE; - - gmesa->DepthMode |= (DepthModeDisable | - DM_WriteMask | - DM_Less); - - gmesa->DeltaMode |= (DM_SubPixlCorrectionEnable | - DM_SmoothShadingEnable | - DM_Target500TXMX); - - gmesa->LightingMode = LightingModeDisable | LightingModeSpecularEnable; - gmesa->Light0Mode = LNM_Off; - gmesa->Light1Mode = LNM_Off; - gmesa->Light2Mode = LNM_Off; - gmesa->Light3Mode = LNM_Off; - gmesa->Light4Mode = LNM_Off; - gmesa->Light5Mode = LNM_Off; - gmesa->Light6Mode = LNM_Off; - gmesa->Light7Mode = LNM_Off; - gmesa->Light8Mode = LNM_Off; - gmesa->Light9Mode = LNM_Off; - gmesa->Light10Mode = LNM_Off; - gmesa->Light11Mode = LNM_Off; - gmesa->Light12Mode = LNM_Off; - gmesa->Light13Mode = LNM_Off; - gmesa->Light14Mode = LNM_Off; - gmesa->Light15Mode = LNM_Off; - - gmesa->LogicalOpMode = LogicalOpModeDisable; - - gmesa->MaterialMode = MaterialModeDisable; - - gmesa->ScissorMode = UserScissorDisable | ScreenScissorDisable; - - gmesa->TransformMode = XM_UseModelViewProjMatrix | - XM_TexGenModeS_None | - XM_TexGenModeT_None | - XM_TexGenModeR_None | - XM_TexGenModeQ_None; - - CHECK_DMA_BUFFER(gmesa, 20); - WRITE(gmesa->buf, LineStippleMode, 0); - WRITE(gmesa->buf, RouterMode, 0); - WRITE(gmesa->buf, TextureAddressMode, 0); - WRITE(gmesa->buf, TextureReadMode, 0); - WRITE(gmesa->buf, TextureFilterMode, 0); - WRITE(gmesa->buf, TextureColorMode, 0); - WRITE(gmesa->buf, StencilMode, 0); - WRITE(gmesa->buf, PatternRamMode, 0); - WRITE(gmesa->buf, ChromaTestMode, 0); - WRITE(gmesa->buf, StatisticMode, 0); - WRITE(gmesa->buf, AreaStippleMode, gmesa->AreaStippleMode); - WRITE(gmesa->buf, ScissorMode, gmesa->ScissorMode); - WRITE(gmesa->buf, FogMode, gmesa->FogMode); - WRITE(gmesa->buf, AntialiasMode, gmesa->AntialiasMode); - WRITE(gmesa->buf, LogicalOpMode, gmesa->LogicalOpMode); - WRITE(gmesa->buf, TriangleMode, gmesa->TriangleMode); - WRITE(gmesa->buf, PointMode, gmesa->PointMode); - WRITE(gmesa->buf, LineMode, gmesa->LineMode); - WRITE(gmesa->buf, LBWriteFormat, gmesa->LBWriteFormat); - WRITE(gmesa->buf, LBReadFormat, gmesa->LBReadFormat); - - /* Framebuffer initialization */ - CHECK_DMA_BUFFER(gmesa, 10); - WRITE(gmesa->buf, FBSourceData, 0); - WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode); - if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER) { - if (gDRIPriv->numMultiDevices == 2) { - WRITE(gmesa->buf, FBPixelOffset, - (gmesa->driScreen->fbHeight/2)*gmesa->driScreen->fbWidth); - } else { - WRITE(gmesa->buf, FBPixelOffset, - gmesa->driScreen->fbHeight*gmesa->driScreen->fbWidth); - } - } else - WRITE(gmesa->buf, FBPixelOffset, 0); - WRITE(gmesa->buf, FBSourceOffset, 0); - WRITE(gmesa->buf, FBHardwareWriteMask, 0xffffffff); - WRITE(gmesa->buf, FBSoftwareWriteMask, 0xffffffff); - WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable); - WRITE(gmesa->buf, FBWindowBase, gmesa->FBWindowBase); - WRITE(gmesa->buf, ScreenSize, ((gmesa->driScreen->fbHeight << 16) | - (gmesa->driScreen->fbWidth))); - WRITE(gmesa->buf, WindowOrigin, 0x00000000); - - /* Localbuffer initialization */ - CHECK_DMA_BUFFER(gmesa, 5); - WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode); - WRITE(gmesa->buf, LBSourceOffset, 0); - WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable); - WRITE(gmesa->buf, LBWindowOffset, 0); - WRITE(gmesa->buf, LBWindowBase, gmesa->LBWindowBase); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, Rectangle2DControl, 1); - - CHECK_DMA_BUFFER(gmesa, 11); - WRITE(gmesa->buf, DepthMode, gmesa->DepthMode); - WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode); - WRITE(gmesa->buf, FBBlockColor, 0x00000000); - WRITE(gmesa->buf, ConstantColor, 0x00000000); - WRITE(gmesa->buf, AlphaTestMode, gmesa->AlphaTestMode); - WRITE(gmesa->buf, AlphaBlendMode, gmesa->AlphaBlendMode); - WRITE(gmesa->buf, DitherMode, gmesa->DitherMode); - if (gDRIPriv->numMultiDevices == 2) - WRITE(gmesa->buf, RasterizerMode, RM_MultiGLINT | RM_BiasCoordNearHalf); - else - WRITE(gmesa->buf, RasterizerMode, RM_BiasCoordNearHalf); - WRITE(gmesa->buf, GLINTWindow, gmesa->Window); - WRITE(gmesa->buf, FastClearDepth, gmesa->ClearDepth); - WRITE(gmesa->buf, GLINTDepth, gmesa->ClearDepth); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, EdgeFlag, EdgeFlagEnable); - - CHECK_DMA_BUFFER(gmesa, 16); - WRITEF(gmesa->buf, ModelViewMatrix0, 1.0); - WRITEF(gmesa->buf, ModelViewMatrix1, 0.0); - WRITEF(gmesa->buf, ModelViewMatrix2, 0.0); - WRITEF(gmesa->buf, ModelViewMatrix3, 0.0); - WRITEF(gmesa->buf, ModelViewMatrix4, 0.0); - WRITEF(gmesa->buf, ModelViewMatrix5, 1.0); - WRITEF(gmesa->buf, ModelViewMatrix6, 0.0); - WRITEF(gmesa->buf, ModelViewMatrix7, 0.0); - WRITEF(gmesa->buf, ModelViewMatrix8, 0.0); - WRITEF(gmesa->buf, ModelViewMatrix9, 0.0); - WRITEF(gmesa->buf, ModelViewMatrix10, 1.0); - WRITEF(gmesa->buf, ModelViewMatrix11, 0.0); - WRITEF(gmesa->buf, ModelViewMatrix12, 0.0); - WRITEF(gmesa->buf, ModelViewMatrix13, 0.0); - WRITEF(gmesa->buf, ModelViewMatrix14, 0.0); - WRITEF(gmesa->buf, ModelViewMatrix15, 1.0); - - CHECK_DMA_BUFFER(gmesa, 16); - WRITEF(gmesa->buf, ModelViewProjectionMatrix0, 1.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix1, 0.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix2, 0.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix3, 0.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix4, 0.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix5, 1.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix6, 0.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix7, 0.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix8, 0.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix9, 0.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix10, 1.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix11, 0.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix12, 0.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix13, 0.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix14, 0.0); - WRITEF(gmesa->buf, ModelViewProjectionMatrix15, 1.0); - - CHECK_DMA_BUFFER(gmesa, 16); - WRITEF(gmesa->buf, TextureMatrix0, 1.0); - WRITEF(gmesa->buf, TextureMatrix1, 0.0); - WRITEF(gmesa->buf, TextureMatrix2, 0.0); - WRITEF(gmesa->buf, TextureMatrix3, 0.0); - WRITEF(gmesa->buf, TextureMatrix4, 0.0); - WRITEF(gmesa->buf, TextureMatrix5, 1.0); - WRITEF(gmesa->buf, TextureMatrix6, 0.0); - WRITEF(gmesa->buf, TextureMatrix7, 0.0); - WRITEF(gmesa->buf, TextureMatrix8, 0.0); - WRITEF(gmesa->buf, TextureMatrix9, 0.0); - WRITEF(gmesa->buf, TextureMatrix10, 1.0); - WRITEF(gmesa->buf, TextureMatrix11, 0.0); - WRITEF(gmesa->buf, TextureMatrix12, 0.0); - WRITEF(gmesa->buf, TextureMatrix13, 0.0); - WRITEF(gmesa->buf, TextureMatrix14, 0.0); - WRITEF(gmesa->buf, TextureMatrix15, 1.0); - - CHECK_DMA_BUFFER(gmesa, 16); - WRITEF(gmesa->buf, TexGen0, 0.0); - WRITEF(gmesa->buf, TexGen1, 0.0); - WRITEF(gmesa->buf, TexGen2, 0.0); - WRITEF(gmesa->buf, TexGen3, 0.0); - WRITEF(gmesa->buf, TexGen4, 0.0); - WRITEF(gmesa->buf, TexGen5, 0.0); - WRITEF(gmesa->buf, TexGen6, 0.0); - WRITEF(gmesa->buf, TexGen7, 0.0); - WRITEF(gmesa->buf, TexGen8, 0.0); - WRITEF(gmesa->buf, TexGen9, 0.0); - WRITEF(gmesa->buf, TexGen10, 0.0); - WRITEF(gmesa->buf, TexGen11, 0.0); - WRITEF(gmesa->buf, TexGen12, 0.0); - WRITEF(gmesa->buf, TexGen13, 0.0); - WRITEF(gmesa->buf, TexGen14, 0.0); - WRITEF(gmesa->buf, TexGen15, 0.0); - - CHECK_DMA_BUFFER(gmesa, 9); - WRITEF(gmesa->buf, NormalMatrix0, 1.0); - WRITEF(gmesa->buf, NormalMatrix1, 0.0); - WRITEF(gmesa->buf, NormalMatrix2, 0.0); - WRITEF(gmesa->buf, NormalMatrix3, 0.0); - WRITEF(gmesa->buf, NormalMatrix4, 1.0); - WRITEF(gmesa->buf, NormalMatrix5, 0.0); - WRITEF(gmesa->buf, NormalMatrix6, 0.0); - WRITEF(gmesa->buf, NormalMatrix7, 0.0); - WRITEF(gmesa->buf, NormalMatrix8, 1.0); - - CHECK_DMA_BUFFER(gmesa, 3); - WRITEF(gmesa->buf, FogDensity, 0.0); - WRITEF(gmesa->buf, FogEnd, 0.0); - WRITEF(gmesa->buf, FogScale, 0.0); - - CHECK_DMA_BUFFER(gmesa, 2); - WRITEF(gmesa->buf, LineClipLengthThreshold, 0.0); - WRITEF(gmesa->buf, TriangleClipAreaThreshold, 0.0); - - CHECK_DMA_BUFFER(gmesa, 5); - WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode); - WRITE(gmesa->buf, NormalizeMode, NormalizeModeDisable); - WRITE(gmesa->buf, LightingMode, gmesa->LightingMode); - WRITE(gmesa->buf, ColorMaterialMode, ColorMaterialModeDisable); - WRITE(gmesa->buf, MaterialMode, MaterialModeDisable); - - CHECK_DMA_BUFFER(gmesa, 2); - WRITE(gmesa->buf, FrontSpecularExponent, 0); /* fixed point */ - WRITE(gmesa->buf, BackSpecularExponent, 0); /* fixed point */ - - CHECK_DMA_BUFFER(gmesa, 29); - WRITEF(gmesa->buf, FrontAmbientColorRed, 0.2); - WRITEF(gmesa->buf, FrontAmbientColorGreen, 0.2); - WRITEF(gmesa->buf, FrontAmbientColorBlue, 0.2); - WRITEF(gmesa->buf, BackAmbientColorRed, 0.2); - WRITEF(gmesa->buf, BackAmbientColorGreen, 0.2); - WRITEF(gmesa->buf, BackAmbientColorBlue, 0.2); - WRITEF(gmesa->buf, FrontDiffuseColorRed, 0.8); - WRITEF(gmesa->buf, FrontDiffuseColorGreen, 0.8); - WRITEF(gmesa->buf, FrontDiffuseColorBlue, 0.8); - WRITEF(gmesa->buf, BackDiffuseColorRed, 0.8); - WRITEF(gmesa->buf, BackDiffuseColorGreen, 0.8); - WRITEF(gmesa->buf, BackDiffuseColorBlue, 0.8); - WRITEF(gmesa->buf, FrontSpecularColorRed, 0.0); - WRITEF(gmesa->buf, FrontSpecularColorGreen, 0.0); - WRITEF(gmesa->buf, FrontSpecularColorBlue, 0.0); - WRITEF(gmesa->buf, BackSpecularColorRed, 0.0); - WRITEF(gmesa->buf, BackSpecularColorGreen, 0.0); - WRITEF(gmesa->buf, BackSpecularColorBlue, 0.0); - WRITEF(gmesa->buf, FrontEmissiveColorRed, 0.0); - WRITEF(gmesa->buf, FrontEmissiveColorGreen, 0.0); - WRITEF(gmesa->buf, FrontEmissiveColorBlue, 0.0); - WRITEF(gmesa->buf, BackEmissiveColorRed, 0.0); - WRITEF(gmesa->buf, BackEmissiveColorGreen, 0.0); - WRITEF(gmesa->buf, BackEmissiveColorBlue, 0.0); - WRITEF(gmesa->buf, SceneAmbientColorRed, 0.2); - WRITEF(gmesa->buf, SceneAmbientColorGreen, 0.2); - WRITEF(gmesa->buf, SceneAmbientColorBlue, 0.2); - WRITEF(gmesa->buf, FrontAlpha, 1.0); - WRITEF(gmesa->buf, BackAlpha, 1.0); - - CHECK_DMA_BUFFER(gmesa, 7); - WRITE(gmesa->buf, PointSize, 1); - WRITEF(gmesa->buf, AApointSize, 1.0); - WRITE(gmesa->buf, LineWidth, 1); - WRITEF(gmesa->buf, AAlineWidth, 1.0); - WRITE(gmesa->buf, LineWidthOffset, 0); - WRITE(gmesa->buf, TransformMode, gmesa->TransformMode); - WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode); - - CHECK_DMA_BUFFER(gmesa, 16); - WRITE(gmesa->buf, Light0Mode, LNM_Off); - WRITE(gmesa->buf, Light1Mode, LNM_Off); - WRITE(gmesa->buf, Light2Mode, LNM_Off); - WRITE(gmesa->buf, Light3Mode, LNM_Off); - WRITE(gmesa->buf, Light4Mode, LNM_Off); - WRITE(gmesa->buf, Light5Mode, LNM_Off); - WRITE(gmesa->buf, Light6Mode, LNM_Off); - WRITE(gmesa->buf, Light7Mode, LNM_Off); - WRITE(gmesa->buf, Light8Mode, LNM_Off); - WRITE(gmesa->buf, Light9Mode, LNM_Off); - WRITE(gmesa->buf, Light10Mode, LNM_Off); - WRITE(gmesa->buf, Light11Mode, LNM_Off); - WRITE(gmesa->buf, Light12Mode, LNM_Off); - WRITE(gmesa->buf, Light13Mode, LNM_Off); - WRITE(gmesa->buf, Light14Mode, LNM_Off); - WRITE(gmesa->buf, Light15Mode, LNM_Off); - - CHECK_DMA_BUFFER(gmesa, 22); - WRITEF(gmesa->buf, Light0AmbientIntensityBlue, 0.0); - WRITEF(gmesa->buf, Light0AmbientIntensityGreen, 0.0); - WRITEF(gmesa->buf, Light0AmbientIntensityRed, 0.0); - WRITEF(gmesa->buf, Light0DiffuseIntensityBlue, 1.0); - WRITEF(gmesa->buf, Light0DiffuseIntensityGreen, 1.0); - WRITEF(gmesa->buf, Light0DiffuseIntensityRed, 1.0); - WRITEF(gmesa->buf, Light0SpecularIntensityBlue, 1.0); - WRITEF(gmesa->buf, Light0SpecularIntensityGreen, 1.0); - WRITEF(gmesa->buf, Light0SpecularIntensityRed, 1.0); - WRITEF(gmesa->buf, Light0SpotlightDirectionZ, 0.0); - WRITEF(gmesa->buf, Light0SpotlightDirectionY, 0.0); - WRITEF(gmesa->buf, Light0SpotlightDirectionX, -1.0); - WRITEF(gmesa->buf, Light0SpotlightExponent, 0.0); - WRITEF(gmesa->buf, Light0PositionZ, 0.0); - WRITEF(gmesa->buf, Light0PositionY, 0.0); - WRITEF(gmesa->buf, Light0PositionX, 1.0); - WRITEF(gmesa->buf, Light0PositionW, 0.0); - WRITEF(gmesa->buf, Light0CosSpotlightCutoffAngle, -1.0); - WRITEF(gmesa->buf, Light0ConstantAttenuation, 1.0); - WRITEF(gmesa->buf, Light0LinearAttenuation, 0.0); - WRITEF(gmesa->buf, Light0QuadraticAttenuation,0.0); - - CHECK_DMA_BUFFER(gmesa, 2); - WRITEF(gmesa->buf, XBias, 0.0); - WRITEF(gmesa->buf, YBias, 0.0); - - CHECK_DMA_BUFFER(gmesa, 6); - WRITEF(gmesa->buf, ViewPortScaleX, gmesa->driScreen->fbWidth/4); - WRITEF(gmesa->buf, ViewPortScaleY, gmesa->driScreen->fbHeight/4); - WRITEF(gmesa->buf, ViewPortScaleZ, 1.0f); - WRITEF(gmesa->buf, ViewPortOffsetX, gmesa->x); - WRITEF(gmesa->buf, ViewPortOffsetY, gmesa->y); - WRITEF(gmesa->buf, ViewPortOffsetZ, 0.0f); - - CHECK_DMA_BUFFER(gmesa, 3); - WRITEF(gmesa->buf, Nz, 1.0); - WRITEF(gmesa->buf, Ny, 0.0); - WRITEF(gmesa->buf, Nx, 0.0); - - /* Send the initialization commands to the HW */ - FLUSH_DMA_BUFFER(gmesa); -} diff --git a/src/mesa/drivers/dri/gamma/gamma_lock.c b/src/mesa/drivers/dri/gamma/gamma_lock.c deleted file mode 100644 index c58b59aa1b4..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_lock.c +++ /dev/null @@ -1,60 +0,0 @@ - -#include "gamma_context.h" -#include "gamma_lock.h" -#include "drirenderbuffer.h" - -#ifdef DEBUG_LOCKING -char *prevLockFile = NULL; -int prevLockLine = 0; -#endif - - -/* Update the hardware state. This is called if another context has - * grabbed the hardware lock, which includes the X server. This - * function also updates the driver's window state after the X server - * moves, resizes or restacks a window -- the change will be reflected - * in the drawable position and clip rects. Since the X server grabs - * the hardware lock when it changes the window state, this routine will - * automatically be called after such a change. - */ -void gammaGetLock( gammaContextPtr gmesa, GLuint flags ) -{ - __DRIdrawable *dPriv = gmesa->driDrawable; - __DRIscreen *sPriv = gmesa->driScreen; - - drmGetLock( gmesa->driFd, gmesa->hHWContext, flags ); - - /* The window might have moved, so we might need to get new clip - * rects. - * - * NOTE: This releases and regrabs the hw lock to allow the X server - * to respond to the DRI protocol request for new drawable info. - * Since the hardware state depends on having the latest drawable - * clip rects, all state checking must be done _after_ this call. - */ - DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv ); - - if ( gmesa->lastStamp != dPriv->lastStamp ) { - driUpdateFramebufferSize(gmesa->glCtx, dPriv); - gmesa->lastStamp = dPriv->lastStamp; - gmesa->new_state |= GAMMA_NEW_WINDOW | GAMMA_NEW_CLIP; - } - - gmesa->numClipRects = dPriv->numClipRects; - gmesa->pClipRects = dPriv->pClipRects; - -#if 0 - gmesa->dirty = ~0; - - if ( sarea->ctxOwner != gmesa->hHWContext ) { - sarea->ctxOwner = gmesa->hHWContext; - gmesa->dirty = GAMMA_UPLOAD_ALL; - } - - for ( i = 0 ; i < gmesa->lastTexHeap ; i++ ) { - if ( sarea->texAge[i] != gmesa->lastTexAge[i] ) { - gammaAgeTextures( gmesa, i ); - } - } -#endif -} diff --git a/src/mesa/drivers/dri/gamma/gamma_lock.h b/src/mesa/drivers/dri/gamma/gamma_lock.h deleted file mode 100644 index 2d117320da2..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_lock.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef __GAMMA_LOCK_H__ -#define __GAMMA_LOCK_H__ - -extern void gammaGetLock( gammaContextPtr gmesa, GLuint flags ); - -/* Turn DEBUG_LOCKING on to find locking conflicts. - */ -#define DEBUG_LOCKING 0 - -#if DEBUG_LOCKING -extern char *prevLockFile; -extern int prevLockLine; - -#define DEBUG_LOCK() \ - do { \ - prevLockFile = (__FILE__); \ - prevLockLine = (__LINE__); \ - } while (0) - -#define DEBUG_RESET() \ - do { \ - prevLockFile = 0; \ - prevLockLine = 0; \ - } while (0) - -#define DEBUG_CHECK_LOCK() \ - do { \ - if ( prevLockFile ) { \ - fprintf( stderr, \ - "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \ - prevLockFile, prevLockLine, __FILE__, __LINE__ ); \ - exit( 1 ); \ - } \ - } while (0) - -#else - -#define DEBUG_LOCK() -#define DEBUG_RESET() -#define DEBUG_CHECK_LOCK() - -#endif - -/* - * !!! We may want to separate locks from locks with validation. This - * could be used to improve performance for those things commands that - * do not do any drawing !!! - */ - -/* Lock the hardware and validate our state. - */ -#define LOCK_HARDWARE( gmesa ) \ - do { \ - char __ret = 0; \ - DEBUG_CHECK_LOCK(); \ - DRM_CAS( gmesa->driHwLock, gmesa->hHWContext, \ - (DRM_LOCK_HELD | gmesa->hHWContext), __ret ); \ - if ( __ret ) \ - gammaGetLock( gmesa, 0 ); \ - DEBUG_LOCK(); \ - } while (0) - -/* Unlock the hardware. - */ -#define UNLOCK_HARDWARE( gmesa ) \ - do { \ - DRM_UNLOCK( gmesa->driFd, \ - gmesa->driHwLock, \ - gmesa->hHWContext ); \ - DEBUG_RESET(); \ - } while (0) - -#define GAMMAHW_LOCK( gmesa ) \ - DRM_UNLOCK(gmesa->driFd, gmesa->driHwLock, gmesa->hHWContext); \ - DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock, \ - gmesa->driScreen->drawLockID); \ - VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa); - -#define GAMMAHW_UNLOCK( gmesa ) \ - DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock, \ - gmesa->driScreen->drawLockID); \ - VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa); - -#endif /* __GAMMA_LOCK_H__ */ diff --git a/src/mesa/drivers/dri/gamma/gamma_macros.h b/src/mesa/drivers/dri/gamma/gamma_macros.h deleted file mode 100644 index d962dcdb566..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_macros.h +++ /dev/null @@ -1,323 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * - */ - -#ifndef _GAMMA_MACROS_H_ -#define _GAMMA_MACROS_H_ - -#define DEBUG_DRMDMA -#define DEBUG_ERRORS -#define DEBUG_COMMANDS_NOT -#define DEBUG_VERBOSE_NOT -#define DEBUG_VERBOSE_EXTRA_NOT - -#define RANDOMIZE_COLORS_NOT -#define TURN_OFF_CLEARS_NOT -#define CULL_ALL_PRIMS_NOT -#define TURN_OFF_DEPTH_NOT -#define TURN_OFF_BLEND_NOT -#define FAST_CLEAR_4_NOT -#define FORCE_DEPTH32_NOT -#define DONT_SEND_DMA_NOT -#define TURN_OFF_FCP_NOT -#define TURN_OFF_TEXTURES_NOT -#define DO_VALIDATE - -#define GAMMA_DMA_BUFFER_SIZE 4096 - -#if 0 -#define GAMMA_DMA_SEND_FLAGS DRM_DMA_PRIORITY -#define GAMMA_DMA_SEND_FLAGS DRM_DMA_BLOCK -#else -/* MUST use non-blocking dma flags for drawable lock routines */ -#define GAMMA_DMA_SEND_FLAGS 0 -#endif - -#if 0 -#define GAMMA_DMA_GET_FLAGS \ - (DRM_DMA_SMALLER_OK | DRM_DMA_LARGER_OK | DRM_DMA_WAIT) -#else -#define GAMMA_DMA_GET_FLAGS DRM_DMA_WAIT -#endif - -#if defined(DEBUG_DRMDMA) || defined(DEBUG_COMMANDS) || defined(DEBUG_VERBOSE) -#include -#endif - -/* Note: The argument to DEBUG_GLCMDS() _must_ be enclosed in parenthesis */ -#ifdef DEBUG_VERBOSE -#define DEBUG_GLCMDS(s) printf s -#else -#define DEBUG_GLCMDS(s) -#endif - -/* Note: The argument to DEBUG_DMACMDS() _must_ be enclosed in parenthesis */ -#ifdef DEBUG_DRMDMA -#define DEBUG_DMACMDS(s) printf s -#else -#define DEBUG_DMACMDS(s) -#endif - -/* Note: The argument to DEBUG_WRITE() _must_ be enclosed in parenthesis */ -#ifdef DEBUG_COMMANDS -#define DEBUG_WRITE(s) printf s -#else -#define DEBUG_WRITE(s) -#endif - -/* Note: The argument to DEBUG_ERROR() _must_ be enclosed in parenthesis */ -#ifdef DEBUG_ERRORS -#define DEBUG_ERROR(s) printf s -#else -#define DEBUG_ERROR(s) -#endif - -#define WRITEV(buf,val1,val2,val3,val4) \ -do { \ - buf++->i = 0x9C008300; \ - buf++->f = val1; \ - buf++->f = val2; \ - buf++->f = val3; \ - buf++->f = val4; \ -} while (0) - -#define WRITE(buf,reg,val) \ -do { \ - buf++->i = Glint##reg##Tag; \ - buf++->i = val; \ - DEBUG_WRITE(("WRITE(buf, %s, 0x%08x);\n", #reg, (int)val)); \ -} while (0) - -#define WRITEF(buf,reg,val) \ -do { \ - buf++->i = Glint##reg##Tag; \ - buf++->f = val; \ - DEBUG_WRITE(("WRITEF(buf, %s, %f);\n", #reg, (float)val)); \ -} while (0) - -#define CHECK_WC_DMA_BUFFER(gcp,n) \ -do { \ - (gcp)->WCbufCount += (n<<1); \ -} while (0) - -#define CHECK_DMA_BUFFER(gcp,n) \ -do { \ - if ((gcp)->bufCount+(n<<1) >= (gcp)->bufSize) \ - PROCESS_DMA_BUFFER(gcp); \ - (gcp)->bufCount += (n<<1); \ -} while (0) - -#define CHECK_DMA_BUFFER2(gcp,n) \ -do { \ - if ((gcp)->bufCount+n >= (gcp)->bufSize) \ - PROCESS_DMA_BUFFER(gcp); \ - (gcp)->bufCount += n; \ -} while (0) - -#define FLUSH_DMA_BUFFER(gcp) \ -do { \ - if (gcp->bufCount) \ - PROCESS_DMA_BUFFER(gcp); \ -} while (0) - -#ifdef DONT_SEND_DMA -#define GET_DMA(fd, hHWCtx, n, idx, size) -#define SEND_DMA(fd, hHWCtx,n, idx, cnt) -#else -#define GET_DMA(fd, hHWCtx, n, idx, size) \ -do { \ - drmDMAReq dma; \ - int retcode, i; \ - \ - dma.context = (hHWCtx); \ - dma.send_count = 0; \ - dma.send_list = NULL; \ - dma.send_sizes = NULL; \ - dma.flags = GAMMA_DMA_GET_FLAGS; \ - dma.request_count = (n); \ - dma.request_size = GAMMA_DMA_BUFFER_SIZE; \ - dma.request_list = (idx); \ - dma.request_sizes = (size); \ - \ - do { \ - if ((retcode = drmDMA((fd), &dma))) { \ - DEBUG_DMACMDS(("drmDMA returned %d\n", retcode)); \ - } \ - } while (!(dma).granted_count); \ - \ - for (i = 0; i < (n); i++) { \ - (size)[i] >>= 2; /* Convert from bytes to words */ \ - } \ -} while (0) - -#define SEND_DMA(fd, hHWCtx, n, idx, cnt) \ -do { \ - drmDMAReq dma; \ - int retcode, i; \ - \ - for (i = 0; i < (n); i++) { \ - (cnt)[i] <<= 2; /* Convert from words to bytes */ \ - } \ - \ - dma.context = (hHWCtx); \ - dma.send_count = 1; \ - dma.send_list = (idx); \ - dma.send_sizes = (cnt); \ - dma.flags = GAMMA_DMA_SEND_FLAGS; \ - dma.request_count = 0; \ - dma.request_size = 0; \ - dma.request_list = NULL; \ - dma.request_sizes = NULL; \ - \ - if ((retcode = drmDMA((fd), &dma))) { \ - DEBUG_DMACMDS(("drmDMA returned %d\n", retcode)); \ - } \ - \ - for (i = 0; i < (n); i++) { \ - (cnt)[i] = 0; \ - } \ -} while (0) -#endif - -#define GET_FIRST_DMA(fd, hHWCtx, n, idx, size, buf, cnt, gPriv) \ -do { \ - int i; \ - \ - GET_DMA(fd, hHWCtx, n, idx, size); \ - \ - for (i = 0; i < (n); i++) { \ - (buf)[i] = (dmaBuf)(gPriv)->bufs->list[(idx)[i]].address; \ - (cnt)[i] = 0; \ - } \ -} while (0) - -#define PROCESS_DMA_BUFFER_TOP_HALF(gcp) \ -do { \ - SEND_DMA((gcp)->driFd, \ - (gcp)->hHWContext, 1, &(gcp)->bufIndex, &(gcp)->bufCount); \ -} while (0) - -#define PROCESS_DMA_BUFFER_BOTTOM_HALF(gcp) \ -do { \ - GET_DMA((gcp)->driFd, \ - (gcp)->hHWContext, 1, &(gcp)->bufIndex, &(gcp)->bufSize); \ - \ - (gcp)->buf = \ - (dmaBuf)(gcp)->gammaScreen->bufs->list[(gcp)->bufIndex].address; \ -} while (0) - -#define PROCESS_DMA_BUFFER(gcp) \ -do { \ - VALIDATE_DRAWABLE_INFO(gcp); \ - PROCESS_DMA_BUFFER_TOP_HALF(gcp); \ - PROCESS_DMA_BUFFER_BOTTOM_HALF(gcp); \ -} while (0) - -#ifdef DO_VALIDATE -#define VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp) \ -do { \ - /*__DRIscreen *psp = gcp->driScreen;*/ \ - __DRIdrawable *pdp = gcp->driDrawable; \ - \ - if (*(pdp->pStamp) != pdp->lastStamp) { \ - int old_index = pdp->index; \ - while (*(pdp->pStamp) != pdp->lastStamp) { \ - DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp); \ - } \ - if (pdp->index != old_index) { \ - gcp->Window &= ~W_GIDMask; \ - gcp->Window |= (pdp->index << 5); \ - CHECK_WC_DMA_BUFFER(gcp, 1); \ - WRITE(gcp->WCbuf, GLINTWindow, gcp->Window|(gcp->FrameCount<<9));\ - } \ - \ - gammaUpdateViewportOffset( gcp->glCtx); \ - \ - if (pdp->numClipRects == 1 && \ - pdp->pClipRects->x1 == pdp->x && \ - pdp->pClipRects->x2 == (pdp->x+pdp->w) && \ - pdp->pClipRects->y1 == pdp->y && \ - pdp->pClipRects->y2 == (pdp->y+pdp->h)) { \ - CHECK_WC_DMA_BUFFER(gcp, 1); \ - WRITE(gcp->WCbuf, Rectangle2DControl, 0); \ - gcp->NotClipped = GL_TRUE; \ - } else { \ - CHECK_WC_DMA_BUFFER(gcp, 1); \ - WRITE(gcp->WCbuf, Rectangle2DControl, 1); \ - gcp->NotClipped = GL_FALSE; \ - } \ - gcp->WindowChanged = GL_TRUE; \ - \ - if (gcp->WCbufCount) { \ - SEND_DMA((gcp)->gammaScreen->driScreen->fd, \ - (gcp)->hHWContext, 1, &(gcp)->WCbufIndex, \ - &(gcp)->WCbufCount); \ - (gcp)->WCbufIndex = -1; \ - } \ - } \ -} while (0) - -#define VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gcp) \ -do { \ - if ((gcp)->WCbufIndex < 0) { \ - GET_DMA((gcp)->gammaScreen->driScreen->fd, \ - (gcp)->hHWContext, 1, &(gcp)->WCbufIndex, \ - &(gcp)->WCbufSize); \ - \ - (gcp)->WCbuf = \ - (dmaBuf)(gcp)->gammaScreen->bufs-> \ - list[(gcp)->WCbufIndex].address; \ - } \ -} while (0) - -#define VALIDATE_DRAWABLE_INFO(gcp) \ -do { \ - __DRIscreen *psp = gcp->driScreen; \ -if (gcp->driDrawable) { \ - DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \ - VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp); \ - DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \ - VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gcp); \ -} \ -} while (0) -#else -#define VALIDATE_DRAWABLE_INFO(gcp) -#endif - -#define CALC_LOG2(l2,s) \ -do { \ - int __s = s; \ - l2 = 0; \ - while (__s > 1) { ++l2; __s >>= 1; } \ -} while (0) - -#endif /* _GAMMA_MACROS_H_ */ diff --git a/src/mesa/drivers/dri/gamma/gamma_regs.h b/src/mesa/drivers/dri/gamma/gamma_regs.h deleted file mode 100644 index 9e1c735019d..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_regs.h +++ /dev/null @@ -1,658 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * - */ - -#ifndef _GAMMA_REGS_H_ -#define _GAMMA_REGS_H_ - -#include "gamma_client.h" - -/**************** MX FLAGS ****************/ -/* FBReadMode */ -#define FBReadSrcDisable 0x00000000 -#define FBReadSrcEnable 0x00000200 -#define FBReadDstDisable 0x00000000 -#define FBReadDstEnable 0x00000400 -#define FBDataTypeDefault 0x00000000 -#define FBDataTypeColor 0x00008000 -#define FBWindowOriginTop 0x00000000 -#define FBWindowOriginBot 0x00010000 -#define FBScanLineInt1 0x00000000 -#define FBScanLineInt2 0x00800000 -#define FBScanLineInt4 0x01000000 -#define FBScanLineInt8 0x01800000 -#define FBSrcAddrConst 0x00000000 -#define FBSrcAddrIndex 0x10000000 -#define FBSrcAddrCoord 0x20000000 - -/* LBReadMode */ -#define LBPartialProdMask 0x000001ff -#define LBReadSrcDisable 0x00000000 -#define LBReadSrcEnable 0x00000200 -#define LBReadDstDisable 0x00000000 -#define LBReadDstEnable 0x00000400 -#define LBDataTypeDefault 0x00000000 -#define LBDataTypeStencil 0x00010000 -#define LBDataTypeDepth 0x00020000 -#define LBWindowOriginTop 0x00000000 -#define LBWindowOriginBot 0x00040000 -#define LBScanLineInt1 0x00000000 -#define LBScanLineInt2 0x00100000 -#define LBScanLineInt4 0x00200000 -#define LBScanLineInt8 0x00300000 - -/* ColorDDAMode */ -#define ColorDDADisable 0x00000000 -#define ColorDDAEnable 0x00000001 -#define ColorDDAFlat 0x00000000 -#define ColorDDAGouraud 0x00000002 -#define ColorDDAShadingMask 0x00000002 - -/* AlphaTestMode */ -#define AlphaTestModeDisable 0x00000000 -#define AlphaTestModeEnable 0x00000001 -#define AT_Never 0x00000000 -#define AT_Less 0x00000002 -#define AT_Equal 0x00000004 -#define AT_LessEqual 0x00000006 -#define AT_Greater 0x00000008 -#define AT_NotEqual 0x0000000a -#define AT_GreaterEqual 0x0000000c -#define AT_Always 0x0000000e -#define AT_CompareMask 0x0000000e -#define AT_RefValueMask 0x00000ff0 - -/* AlphaBlendMode */ -#define AlphaBlendModeDisable 0x00000000 -#define AlphaBlendModeEnable 0x00000001 -#define AB_Src_Zero 0x00000000 -#define AB_Src_One 0x00000002 -#define AB_Src_DstColor 0x00000004 -#define AB_Src_OneMinusDstColor 0x00000006 -#define AB_Src_SrcAlpha 0x00000008 -#define AB_Src_OneMinusSrcAlpha 0x0000000a -#define AB_Src_DstAlpha 0x0000000c -#define AB_Src_OneMinusDstAlpha 0x0000000e -#define AB_Src_SrcAlphaSaturate 0x00000010 -#define AB_SrcBlendMask 0x0000001e -#define AB_Dst_Zero 0x00000000 -#define AB_Dst_One 0x00000020 -#define AB_Dst_SrcColor 0x00000040 -#define AB_Dst_OneMinusSrcColor 0x00000060 -#define AB_Dst_SrcAlpha 0x00000080 -#define AB_Dst_OneMinusSrcAlpha 0x000000a0 -#define AB_Dst_DstAlpha 0x000000c0 -#define AB_Dst_OneMinusDstAlpha 0x000000e0 -#define AB_DstBlendMask 0x000000e0 -#define AB_ColorFmt_8888 0x00000000 -#define AB_ColorFmt_5555 0x00000100 -#define AB_ColorFmt_4444 0x00000200 -#define AB_ColorFmt_4444Front 0x00000300 -#define AB_ColorFmt_4444Back 0x00000400 -#define AB_ColorFmt_332Front 0x00000500 -#define AB_ColorFmt_332Back 0x00000600 -#define AB_ColorFmt_121Front 0x00000700 -#define AB_ColorFmt_121Back 0x00000800 -#define AB_ColorFmt_555Back 0x00000d00 -#define AB_ColorFmt_CI8 0x00000e00 -#define AB_ColorFmt_CI4 0x00000f00 -#define AB_AlphaBufferPresent 0x00000000 -#define AB_NoAlphaBufferPresent 0x00001000 -#define AB_ColorOrder_BGR 0x00000000 -#define AB_ColorOrder_RGB 0x00002000 -#define AB_OpenGLType 0x00000000 -#define AB_QuickDraw3DType 0x00004000 -#define AB_AlphaDst_FBData 0x00000000 -#define AB_AlphaDst_FBSourceData 0x00008000 -#define AB_ColorConversionScale 0x00000000 -#define AB_ColorConversionShift 0x00010000 -#define AB_AlphaConversionScale 0x00000000 -#define AB_AlphaConversionShift 0x00020000 - -/* AntialiasMode */ -#define AntialiasModeDisable 0x00000000 -#define AntialiasModeEnable 0x00000001 - -/* AreaStippleMode */ -#define AreaStippleModeDisable 0x00000000 -#define AreaStippleModeEnable 0x00000001 -#define ASM_X32 0x00000008 -#define ASM_Y32 0x00000040 - -/* DepthMode */ -#define DepthModeDisable 0x00000000 -#define DepthModeEnable 0x00000001 -#define DM_WriteMask 0x00000002 -#define DM_SourceFragment 0x00000000 -#define DM_SourceLBData 0x00000004 -#define DM_SourceDepthRegister 0x00000008 -#define DM_SourceLBSourceData 0x0000000c -#define DM_SourceMask 0x0000000c -#define DM_Never 0x00000000 -#define DM_Less 0x00000010 -#define DM_Equal 0x00000020 -#define DM_LessEqual 0x00000030 -#define DM_Greater 0x00000040 -#define DM_NotEqual 0x00000050 -#define DM_GreaterEqual 0x00000060 -#define DM_Always 0x00000070 -#define DM_CompareMask 0x00000070 - -/* FBWriteMode */ -#define FBWriteModeDisable 0x00000000 -#define FBWriteModeEnable 0x00000001 -#define FBW_UploadColorData 0x00000008 - -/* FogMode */ -#define FogModeDisable 0x00000000 -#define FogModeEnable 0x00000001 - -/* LBWriteMode */ -#define LBWriteModeDisable 0x00000000 -#define LBWriteModeEnable 0x00000001 -#define LBW_UploadNone 0x00000000 -#define LBW_UploadDepth 0x00000002 -#define LBW_UploadStencil 0x00000004 - -/* LBRead/Write Format */ -#define LBRF_DepthWidth15 0x03 /* only permedia */ -#define LBRF_DepthWidth16 0x00 -#define LBRF_DepthWidth24 0x01 -#define LBRF_DepthWidth32 0x02 -#define LBRF_StencilWidth0 (0 << 2) -#define LBRF_StencilWidth4 (1 << 2) -#define LBRF_StencilWidth8 (2 << 2) -#define LBRF_StencilPos16 (0 << 4) -#define LBRF_StencilPos20 (1 << 4) -#define LBRF_StencilPos24 (2 << 4) -#define LBRF_StencilPos28 (3 << 4) -#define LBRF_StencilPos32 (4 << 4) -#define LBRF_FrameCount0 (0 << 7) -#define LBRF_FrameCount4 (1 << 7) -#define LBRF_FrameCount8 (2 << 7) -#define LBRF_FrameCountPos16 (0 << 9) -#define LBRF_FrameCountPos20 (1 << 9) -#define LBRF_FrameCountPos24 (2 << 9) -#define LBRF_FrameCountPos28 (3 << 9) -#define LBRF_FrameCountPos32 (4 << 9) -#define LBRF_FrameCountPos36 (5 << 9) -#define LBRF_FrameCountPos40 (6 << 9) -#define LBRF_GIDWidth0 (0 << 12) -#define LBRF_GIDWidth4 (1 << 12) -#define LBRF_GIDPos16 (0 << 13) -#define LBRF_GIDPos20 (1 << 13) -#define LBRF_GIDPos24 (2 << 13) -#define LBRF_GIDPos28 (3 << 13) -#define LBRF_GIDPos32 (4 << 13) -#define LBRF_GIDPos36 (5 << 13) -#define LBRF_GIDPos40 (6 << 13) -#define LBRF_GIDPos44 (7 << 13) -#define LBRF_GIDPos48 (8 << 13) -#define LBRF_Compact32 (1 << 17) - -/* StencilMode */ -#define StencilDisable 0x00000000 -#define StencilEnable 0x00000001 - -/* RouterMode */ -#define R_Order_TextureDepth 0x00000000 -#define R_Order_DepthTexture 0x00000001 - -/* ScissorMode */ -#define UserScissorDisable 0x00000000 -#define UserScissorEnable 0x00000001 -#define ScreenScissorDisable 0x00000000 -#define ScreenScissorEnable 0x00000002 - -/* DitherMode */ -#define DitherModeDisable 0x00000000 -#define DitherModeEnable 0x00000001 -#define DM_DitherDisable 0x00000000 -#define DM_DitherEnable 0x00000002 -#define DM_ColorFmt_8888 0x00000000 -#define DM_ColorFmt_5555 0x00000004 -#define DM_ColorFmt_4444 0x00000008 -#define DM_ColorFmt_4444Front 0x0000000c -#define DM_ColorFmt_4444Back 0x00000010 -#define DM_ColorFmt_332Front 0x00000014 -#define DM_ColorFmt_332Back 0x00000018 -#define DM_ColorFmt_121Front 0x0000001c -#define DM_ColorFmt_121Back 0x00000020 -#define DM_ColorFmt_555Back 0x00000024 -#define DM_ColorFmt_CI8 0x00000028 -#define DM_ColorFmt_CI4 0x0000002c -#define DM_XOffsetMask 0x000000c0 -#define DM_YOffsetMask 0x00000300 -#define DM_ColorOrder_BGR 0x00000000 -#define DM_ColorOrder_RGB 0x00000400 -#define DM_AlphaDitherDefault 0x00000000 -#define DM_AlphaDitherNone 0x00004000 -#define DM_Truncate 0x00000000 -#define DM_Round 0x00008000 - -/* RasterizerMode */ -#define RM_MirrorBitMask 0x00000001 -#define RM_InvertBitMask 0x00000002 -#define RM_FractionAdjNo 0x00000000 -#define RM_FractionAdjZero 0x00000004 -#define RM_FractionAdjHalf 0x00000008 -#define RM_FractionAdjNearHalf 0x0000000c -#define RM_BiasCoordZero 0x00000000 -#define RM_BiasCoordHalf 0x00000010 -#define RM_BiasCoordNearHalf 0x00000020 -#define RM_BitMaskByteSwap_ABCD 0x00000000 -#define RM_BitMaskByteSwap_BADC 0x00000080 -#define RM_BitMaskByteSwap_CDAB 0x00000100 -#define RM_BitMaskByteSwap_DCBA 0x00000180 -#define RM_BitMaskPacked 0x00000000 -#define RM_BitMaskEveryScanline 0x00000200 -#define RM_BitMaskOffsetMask 0x00007c00 -#define RM_HostDataByteSwap_ABCD 0x00000000 -#define RM_HostDataByteSwap_BADC 0x00008000 -#define RM_HostDataByteSwap_CDAB 0x00010000 -#define RM_HostDataByteSwap_DCBA 0x00018000 -#define RM_SingleGLINT 0x00000000 -#define RM_MultiGLINT 0x00020000 -#define RM_YLimitsEnable 0x00040000 - -/* Window */ -#define WindowDisable 0x00000000 -#define WindowEnable 0x00000001 -#define W_AlwaysPass 0x00000000 -#define W_NeverPass 0x00000002 -#define W_PassIfEqual 0x00000004 -#define W_PassIfNotEqual 0x00000006 -#define W_CompareMask 0x00000006 -#define W_ForceLBUpdate 0x00000008 -#define W_LBUpdateFromSource 0x00000000 -#define W_LBUpdateFromRegisters 0x00000010 -#define W_GIDMask 0x000001e0 -#define W_FrameCountMask 0x0001fe00 -#define W_StencilFCP 0x00020000 -#define W_DepthFCP 0x00040000 -#define W_OverrideWriteFiltering 0x00080000 - -/* TextureAddressMode */ -#define TextureAddressModeDisable 0x00000000 -#define TextureAddressModeEnable 0x00000001 -#define TAM_SWrap_Clamp 0x00000000 -#define TAM_SWrap_Repeat 0x00000002 -#define TAM_SWrap_Mirror 0x00000004 -#define TAM_SWrap_Mask 0x00000006 -#define TAM_TWrap_Clamp 0x00000000 -#define TAM_TWrap_Repeat 0x00000008 -#define TAM_TWrap_Mirror 0x00000010 -#define TAM_TWrap_Mask 0x00000018 -#define TAM_Operation_2D 0x00000000 -#define TAM_Operation_3D 0x00000020 -#define TAM_InhibitDDAInit 0x00000040 -#define TAM_LODDisable 0x00000000 -#define TAM_LODEnable 0x00000080 -#define TAM_DY_Disable 0x00000000 -#define TAM_DY_Enable 0x00000100 -#define TAM_WidthMask 0x00001e00 -#define TAM_HeightMask 0x0001e000 -#define TAM_TexMapType_1D 0x00000000 -#define TAM_TexMapType_2D 0x00020000 -#define TAM_TexMapType_Mask 0x00020000 - -/* TextureReadMode */ -#define TextureReadModeDisable 0x00000000 -#define TextureReadModeEnable 0x00000001 -#define TRM_WidthMask 0x0000001e -#define TRM_HeightMask 0x000001e0 -#define TRM_Depth1 0x00000000 -#define TRM_Depth2 0x00000200 -#define TRM_Depth4 0x00000400 -#define TRM_Depth8 0x00000600 -#define TRM_Depth16 0x00000800 -#define TRM_Depth32 0x00000a00 -#define TRM_DepthMask 0x00000e00 -#define TRM_Border 0x00001000 -#define TRM_Patch 0x00002000 -#define TRM_Mag_Nearest 0x00000000 -#define TRM_Mag_Linear 0x00004000 -#define TRM_Mag_Mask 0x00004000 -#define TRM_Min_Nearest 0x00000000 -#define TRM_Min_Linear 0x00008000 -#define TRM_Min_NearestMMNearest 0x00010000 -#define TRM_Min_NearestMMLinear 0x00018000 -#define TRM_Min_LinearMMNearest 0x00020000 -#define TRM_Min_LinearMMLinear 0x00028000 -#define TRM_Min_Mask 0x00038000 -#define TRM_UWrap_Clamp 0x00000000 -#define TRM_UWrap_Repeat 0x00040000 -#define TRM_UWrap_Mirror 0x00080000 -#define TRM_UWrap_Mask 0x000c0000 -#define TRM_VWrap_Clamp 0x00000000 -#define TRM_VWrap_Repeat 0x00100000 -#define TRM_VWrap_Mirror 0x00200000 -#define TRM_VWrap_Mask 0x00300000 -#define TRM_TexMapType_1D 0x00000000 -#define TRM_TexMapType_2D 0x00400000 -#define TRM_TexMapType_Mask 0x00400000 -#define TRM_MipMapDisable 0x00000000 -#define TRM_MipMapEnable 0x00800000 -#define TRM_PrimaryCacheDisable 0x00000000 -#define TRM_PrimaryCacheEnable 0x01000000 -#define TRM_FBSourceAddr_None 0x00000000 -#define TRM_FBSourceAddr_Index 0x02000000 -#define TRM_FBSourceAddr_Coord 0x04000000 -#define TRM_BorderClamp 0x08000000 - -/* TextureColorMode */ -#define TextureColorModeDisable 0x00000000 -#define TextureColorModeEnable 0x00000001 -#define TCM_Modulate 0x00000000 -#define TCM_Decal 0x00000002 -#define TCM_Blend 0x00000004 -#define TCM_Replace 0x00000006 -#define TCM_ApplicationMask 0x0000000e -#define TCM_OpenGLType 0x00000000 -#define TCM_QuickDraw3DType 0x00000010 -#define TCM_KdDDA_Disable 0x00000000 -#define TCM_KdDDA_Enable 0x00000020 -#define TCM_KsDDA_Disable 0x00000000 -#define TCM_KsDDA_Enable 0x00000040 -#define TCM_BaseFormat_Alpha 0x00000000 -#define TCM_BaseFormat_Lum 0x00000080 -#define TCM_BaseFormat_LumAlpha 0x00000100 -#define TCM_BaseFormat_Intensity 0x00000180 -#define TCM_BaseFormat_RGB 0x00000200 -#define TCM_BaseFormat_RGBA 0x00000280 -#define TCM_BaseFormatMask 0x00000380 -#define TCM_LoadMode_None 0x00000000 -#define TCM_LoadMode_Ks 0x00000400 -#define TCM_LoadMode_Kd 0x00000800 - -/* TextureCacheControl */ -#define TCC_Invalidate 0x00000001 -#define TCC_Disable 0x00000000 -#define TCC_Enable 0x00000002 - -/* TextureFilterMode */ -#define TextureFilterModeDisable 0x00000000 -#define TextureFilterModeEnable 0x00000001 -#define TFM_AlphaMapEnable 0x00000002 -#define TFM_AlphaMapSense 0x00000004 - -/* TextureFormat */ -#define TF_LittleEndian 0x00000000 -#define TF_BigEndian 0x00000001 -#define TF_16Bit_565 0x00000000 -#define TF_16Bit_555 0x00000002 -#define TF_ColorOrder_BGR 0x00000000 -#define TF_ColorOrder_RGB 0x00000004 -#define TF_Compnents_1 0x00000000 -#define TF_Compnents_2 0x00000008 -#define TF_Compnents_3 0x00000010 -#define TF_Compnents_4 0x00000018 -#define TF_CompnentsMask 0x00000018 -#define TF_OutputFmt_Texel 0x00000000 -#define TF_OutputFmt_Color 0x00000020 -#define TF_OutputFmt_BitMask 0x00000040 -#define TF_OutputFmtMask 0x00000060 -#define TF_MirrorEnable 0x00000080 -#define TF_InvertEnable 0x00000100 -#define TF_ByteSwapEnable 0x00000200 -#define TF_LUTOffsetMask 0x0003fc00 -#define TF_OneCompFmt_Lum 0x00000000 -#define TF_OneCompFmt_Alpha 0x00040000 -#define TF_OneCompFmt_Intensity 0x00080000 -#define TF_OneCompFmt_Mask 0x000c0000 -/**************** MX FLAGS ****************/ - -/************** GAMMA FLAGS ***************/ -/* GeometryMode */ -#define GM_TextureDisable 0x00000000 -#define GM_TextureEnable 0x00000001 -#define GM_FogDisable 0x00000000 -#define GM_FogEnable 0x00000002 -#define GM_FogLinear 0x00000000 -#define GM_FogExp 0x00000004 -#define GM_FogExpSquared 0x00000008 -#define GM_FogMask 0x0000000C -#define GM_FrontPolyPoint 0x00000000 -#define GM_FrontPolyLine 0x00000010 -#define GM_FrontPolyFill 0x00000020 -#define GM_BackPolyPoint 0x00000000 -#define GM_BackPolyLine 0x00000040 -#define GM_BackPolyFill 0x00000080 -#define GM_FB_PolyMask 0x000000F0 -#define GM_FrontFaceCW 0x00000000 -#define GM_FrontFaceCCW 0x00000100 -#define GM_FFMask 0x00000100 -#define GM_PolyCullDisable 0x00000000 -#define GM_PolyCullEnable 0x00000200 -#define GM_PolyCullFront 0x00000000 -#define GM_PolyCullBack 0x00000400 -#define GM_PolyCullBoth 0x00000800 -#define GM_PolyCullMask 0x00000c00 -#define GM_ClipShortLinesDisable 0x00000000 -#define GM_ClipShortLinesEnable 0x00001000 -#define GM_ClipSmallTrisDisable 0x00000000 -#define GM_ClipSmallTrisEnable 0x00002000 -#define GM_RenderMode 0x00000000 -#define GM_SelectMode 0x00004000 -#define GM_FeedbackMode 0x00008000 -#define GM_Feedback2D 0x00000000 -#define GM_Feedback3D 0x00010000 -#define GM_Feedback3DColor 0x00020000 -#define GM_Feedback3DColorTexture 0x00030000 -#define GM_Feedback4DColorTexture 0x00040000 -#define GM_CullFaceNormDisable 0x00000000 -#define GM_CullFaceNormEnable 0x00080000 -#define GM_AutoFaceNormDisable 0x00000000 -#define GM_AutoFaceNormEnable 0x00100000 -#define GM_GouraudShading 0x00000000 -#define GM_FlatShading 0x00200000 -#define GM_ShadingMask 0x00200000 -#define GM_UserClipNone 0x00000000 -#define GM_UserClip0 0x00400000 -#define GM_UserClip1 0x00800000 -#define GM_UserClip2 0x01000000 -#define GM_UserClip3 0x02000000 -#define GM_UserClip4 0x04000000 -#define GM_UserClip5 0x08000000 -#define GM_PolyOffsetPointDisable 0x00000000 -#define GM_PolyOffsetPointEnable 0x10000000 -#define GM_PolyOffsetLineDisable 0x00000000 -#define GM_PolyOffsetLineEnable 0x20000000 -#define GM_PolyOffsetFillDisable 0x00000000 -#define GM_PolyOffsetFillEnable 0x40000000 -#define GM_InvertFaceNormCullDisable 0x00000000 -#define GM_InvertFaceNormCullEnable 0x80000000 - -/* Begin */ -#define B_AreaStippleDisable 0x00000000 -#define B_AreaStippleEnable 0x00000001 -#define B_LineStippleDisable 0x00000000 -#define B_LineStippleEnable 0x00000002 -#define B_AntiAliasDisable 0x00000000 -#define B_AntiAliasEnable 0x00000100 -#define B_TextureDisable 0x00000000 -#define B_TextureEnable 0x00002000 -#define B_FogDisable 0x00000000 -#define B_FogEnable 0x00004000 -#define B_SubPixelCorrectDisable 0x00000000 -#define B_SubPixelCorrectEnable 0x00010000 -#define B_PrimType_Null 0x00000000 -#define B_PrimType_Points 0x10000000 -#define B_PrimType_Lines 0x20000000 -#define B_PrimType_LineLoop 0x30000000 -#define B_PrimType_LineStrip 0x40000000 -#define B_PrimType_Triangles 0x50000000 -#define B_PrimType_TriangleStrip 0x60000000 -#define B_PrimType_TriangleFan 0x70000000 -#define B_PrimType_Quads 0x80000000 -#define B_PrimType_QuadStrip 0x90000000 -#define B_PrimType_Polygon 0xa0000000 -#define B_PrimType_Mask 0xf0000000 - -/* EdgeFlag */ -#define EdgeFlagDisable 0x00000000 -#define EdgeFlagEnable 0x00000001 - -/* NormalizeMode */ -#define NormalizeModeDisable 0x00000000 -#define NormalizeModeEnable 0x00000001 -#define FaceNormalDisable 0x00000000 -#define FaceNormalEnable 0x00000002 -#define InvertAutoFaceNormal 0x00000004 - -/* LightingMode */ -#define LightingModeDisable 0x00000000 -#define LightingModeEnable 0x00000001 -#define LightingModeTwoSides 0x00000004 -#define LightingModeLocalViewer 0x00000008 -#define LightingModeSpecularEnable 0x00008000 - -/* Light0Mode */ -#define Light0ModeDisable 0x00000000 -#define Light0ModeEnable 0x00000001 -#define Light0ModeSpotLight 0x00000002 -#define Light0ModeAttenuation 0x00000004 -#define Light0ModeLocal 0x00000008 - -/* Light0Mode */ -#define Light1ModeDisable 0x00000000 -#define Light1ModeEnable 0x00000001 -#define Light1ModeSpotLight 0x00000002 -#define Light1ModeAttenuation 0x00000004 -#define Light1ModeLocal 0x00000008 - -/* ColorMaterialMode */ -#define ColorMaterialModeDisable 0x00000000 -#define ColorMaterialModeEnable 0x00000001 -#define ColorMaterialModeFront 0x00000000 -#define ColorMaterialModeBack 0x00000002 -#define ColorMaterialModeFrontAndBack 0x00000004 -#define ColorMaterialModeEmission 0x00000000 -#define ColorMaterialModeAmbient 0x00000008 -#define ColorMaterialModeDiffuse 0x00000010 -#define ColorMaterialModeSpecular 0x00000018 -#define ColorMaterialModeAmbAndDiff 0x00000020 -#define ColorMaterialModeMask 0x0000003e - -/* MaterialMode */ -#define MaterialModeDisable 0x00000000 -#define MaterialModeEnable 0x00000001 -#define MaterialModeTwoSides 0x00000080 - -/* DeltaMode */ -#define DM_Target300SX 0x00000000 -#define DM_Target500TXMX 0x00000001 -#define DM_Depth16 0x00000004 -#define DM_Depth24 0x00000008 -#define DM_Depth32 0x0000000c -#define DM_FogEnable 0x00000010 -#define DM_TextureEnable 0x00000020 -#define DM_SmoothShadingEnable 0x00000040 -#define DM_DepthEnable 0x00000080 -#define DM_SpecularEnable 0x00000100 -#define DM_DiffuseEnable 0x00000200 -#define DM_SubPixlCorrectionEnable 0x00000400 -#define DM_DiamondExit 0x00000800 -#define DM_NoDraw 0x00001000 -#define DM_ClampEnable 0x00002000 -#define DM_TextureParameterAsGiven 0x00000000 -#define DM_TextureParameterClamped 0x00004000 -#define DM_TextureParameterNormalized 0x00008000 -#define DM_BiasCoords 0x00080000 -#define DM_ColorDiffuse 0x00100000 -#define DM_ColorSpecular 0x00200000 -#define DM_FlatShadingMethod 0x00400000 - -/* PointMode */ -#define PM_AntialiasDisable 0x00000000 -#define PM_AntialiasEnable 0x00000001 -#define PM_AntialiasQuality_4x4 0x00000000 -#define PM_AntialiasQuality_8x8 0x00000002 - -/* LogicalOpMode */ -#define LogicalOpModeDisable 0x00000000 -#define LogicalOpModeEnable 0x00000001 -#define LogicalOpModeMask 0x0000001e - -/* LineMode */ -#define LM_StippleDisable 0x00000000 -#define LM_StippleEnable 0x00000001 -#define LM_RepeatFactorMask 0x000003fe -#define LM_StippleMask 0x03fffc00 -#define LM_MirrorDisable 0x00000000 -#define LM_MirrorEnable 0x04000000 -#define LM_AntialiasDisable 0x00000000 -#define LM_AntialiasEnable 0x08000000 -#define LM_AntialiasQuality_4x4 0x00000000 -#define LM_AntialiasQuality_8x8 0x10000000 - -/* TriangleMode */ -#define TM_AntialiasDisable 0x00000000 -#define TM_AntialiasEnable 0x00000001 -#define TM_AntialiasQuality_4x4 0x00000000 -#define TM_AntialiasQuality_8x8 0x00000002 -#define TM_UseTriPacketInterface 0x00000004 - -/* TransformMode */ -#define XM_UseModelViewMatrix 0x00000001 -#define XM_UseModelViewProjMatrix 0x00000002 -#define XM_XformNormals 0x00000004 -#define XM_XformFaceNormals 0x00000008 -#define XM_XformTexture 0x00000010 -#define XM_XMask 0x00000013 -#define XM_TexGenModeS_None 0x00000000 -#define XM_TexGenModeS_ObjLinear 0x00000020 -#define XM_TexGenModeS_EyeLinear 0x00000040 -#define XM_TexGenModeS_SphereMap 0x00000060 -#define XM_TexGenModeT_None 0x00000000 -#define XM_TexGenModeT_ObjLinear 0x00000080 -#define XM_TexGenModeT_EyeLinear 0x00000100 -#define XM_TexGenModeT_SphereMap 0x00000180 -#define XM_TexGenModeR_None 0x00000000 -#define XM_TexGenModeR_ObjLinear 0x00000200 -#define XM_TexGenModeR_EyeLinear 0x00000400 -#define XM_TexGenModeR_SphereMap 0x00000600 -#define XM_TexGenModeQ_None 0x00000000 -#define XM_TexGenModeQ_ObjLinear 0x00000800 -#define XM_TexGenModeQ_EyeLinear 0x00001000 -#define XM_TexGenModeQQSphereMap 0x00001800 -#define XM_TexGenS 0x00002000 -#define XM_TexGenT 0x00004000 -#define XM_TexGenR 0x00008000 -#define XM_TexGenQ 0x00010000 - -/* LightNMode */ -#define LNM_Off 0x00000000 -#define LNM_On 0x00000001 -/************** GAMMA FLAGS ***************/ - -#endif /* _GAMMA_REGS_H_ */ diff --git a/src/mesa/drivers/dri/gamma/gamma_render.c b/src/mesa/drivers/dri/gamma/gamma_render.c deleted file mode 100644 index 3c2fa507a97..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_render.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - * 3DLabs Gamma driver. - * - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/imports.h" -#include "main/mtypes.h" - -#include "tnl/t_context.h" - -#include "gamma_context.h" -#include "gamma_macros.h" -#include "gamma_tris.h" -#include "gamma_vb.h" - - -/* !! Should template this eventually !! */ - -static void gamma_emit( GLcontext *ctx, GLuint start, GLuint end) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLfloat (*coord)[4]; - GLuint coord_stride; - GLfloat (*col)[4]; - GLuint col_stride; - int i; - GLuint tc0_stride = 0; - GLfloat (*tc0)[4] = 0; - GLuint tc0_size = 0; - - col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data; - col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride; - - if (ctx->Texture.Unit[0]._ReallyEnabled) { - tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0]->stride; - tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0]->data; - tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0]->size; - coord = VB->ClipPtr->data; - coord_stride = VB->ClipPtr->stride; - } else { - coord = VB->NdcPtr->data; - coord_stride = VB->NdcPtr->stride; - } - - if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 4) { - for (i=start; i < end; i++) { - CHECK_DMA_BUFFER(gmesa, 9); - WRITEF(gmesa->buf, Tq4, tc0[i][3]); - WRITEF(gmesa->buf, Tr4, tc0[i][2]); - WRITEF(gmesa->buf, Tt4, tc0[i][0]); - WRITEF(gmesa->buf, Ts4, tc0[i][1]); - WRITE(gmesa->buf, PackedColor4, *(uint32_t*)col[i]); - WRITEF(gmesa->buf, Vw, coord[i][3]); - WRITEF(gmesa->buf, Vz, coord[i][2]); - WRITEF(gmesa->buf, Vy, coord[i][1]); - WRITEF(gmesa->buf, Vx4, coord[i][0]); - } - } else if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 2) { - for (i=start; i < end; i++) { - CHECK_DMA_BUFFER(gmesa, 7); - WRITEF(gmesa->buf, Tt2, tc0[i][0]); - WRITEF(gmesa->buf, Ts2, tc0[i][1]); - WRITE(gmesa->buf, PackedColor4, *(uint32_t*)col[i]); - WRITEF(gmesa->buf, Vw, coord[i][3]); - WRITEF(gmesa->buf, Vz, coord[i][2]); - WRITEF(gmesa->buf, Vy, coord[i][1]); - WRITEF(gmesa->buf, Vx4, coord[i][0]); - } - } else { - for (i=start; i < end; i++) { - CHECK_DMA_BUFFER(gmesa, 4); - WRITE(gmesa->buf, PackedColor4, *(uint32_t*)col[i]); - WRITEF(gmesa->buf, Vz, coord[i][2]); - WRITEF(gmesa->buf, Vy, coord[i][1]); - WRITEF(gmesa->buf, Vx3, coord[i][0]); - } - } -} - -#define HAVE_POINTS 1 -#define HAVE_LINES 1 -#define HAVE_LINE_STRIPS 1 -#define HAVE_TRIANGLES 1 -#define HAVE_TRI_STRIPS 1 -#define HAVE_TRI_STRIP_1 0 -#define HAVE_TRI_FANS 1 -#define HAVE_QUADS 1 -#define HAVE_QUAD_STRIPS 1 -#define HAVE_POLYGONS 1 - -#define HAVE_ELTS 0 - - -static const GLuint hw_prim[GL_POLYGON+1] = { - B_PrimType_Points, - B_PrimType_Lines, - B_PrimType_LineLoop, - B_PrimType_LineStrip, - B_PrimType_Triangles, - B_PrimType_TriangleStrip, - B_PrimType_TriangleFan, - B_PrimType_Quads, - B_PrimType_QuadStrip, - B_PrimType_Polygon -}; - -static INLINE void gammaStartPrimitive( gammaContextPtr gmesa, GLenum prim ) -{ - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, Begin, gmesa->Begin | hw_prim[prim]); -} - -static INLINE void gammaEndPrimitive( gammaContextPtr gmesa ) -{ - GLcontext *ctx = gmesa->glCtx; - - if ( ctx->Line.SmoothFlag || - ctx->Polygon.SmoothFlag || - ctx->Point.SmoothFlag ) { - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, FlushSpan, 0); - } - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, End, 0); -} - -#define LOCAL_VARS gammaContextPtr gmesa = GAMMA_CONTEXT(ctx) -#define INIT( prim ) gammaStartPrimitive( gmesa, prim ) -#define FLUSH() gammaEndPrimitive( gmesa ) -#define GET_CURRENT_VB_MAX_VERTS() \ - (gmesa->bufSize - gmesa->bufCount) / 2 -#define GET_SUBSEQUENT_VB_MAX_VERTS() \ - GAMMA_DMA_BUFFER_SIZE / 2 - -#define ALLOC_VERTS( nr ) (void *)0 /* todo: explicit alloc */ -#define EMIT_VERTS( ctx, j, nr, buf ) (gamma_emit(ctx, j, (j)+(nr)), (void *)0) - -#define TAG(x) gamma_##x -#include "tnl_dd/t_dd_dmatmp.h" - - -/**********************************************************************/ -/* Render pipeline stage */ -/**********************************************************************/ - - -static GLboolean gamma_run_render( GLcontext *ctx, - struct tnl_pipeline_stage *stage ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint i; - tnl_render_func *tab; - - /* GH: THIS IS A HACK!!! */ - if (VB->ClipOrMask || gmesa->RenderIndex != 0) - return GL_TRUE; /* don't handle clipping here */ - - /* We don't do elts */ - if (VB->Elts || !gamma_validate_render( ctx, VB )) - return GL_TRUE; - - tab = TAG(render_tab_verts); - - tnl->Driver.Render.Start( ctx ); - - for (i = 0 ; i < VB->PrimitiveCount ; i++) - { - GLuint prim = _tnl_translate_prim(&VB->Primitive[i]); - GLuint start = VB->Primitive[i].start; - GLuint length = VB->Primitive[i].count; - - if (!length) - continue; - - tab[prim & PRIM_MODE_MASK]( ctx, start, start + length, prim); - } - - tnl->Driver.Render.Finish( ctx ); - - return GL_FALSE; /* finished the pipe */ -} - - -const struct tnl_pipeline_stage _gamma_render_stage = -{ - "gamma render", - NULL, - NULL, - NULL, - NULL, - gamma_run_render /* run */ -}; diff --git a/src/mesa/drivers/dri/gamma/gamma_screen.c b/src/mesa/drivers/dri/gamma/gamma_screen.c deleted file mode 100644 index 47862f1d77e..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_screen.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - */ - -#include "gamma_context.h" -#include "gamma_vb.h" -#include "glint_dri.h" - -#include "main/imports.h" - -gammaScreenPtr gammaCreateScreen( __DRIscreen *sPriv ) -{ - gammaScreenPtr gammaScreen; - GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)sPriv->pDevPriv; - int i; - - if (sPriv->devPrivSize != sizeof(GLINTDRIRec)) { - fprintf(stderr,"\nERROR! sizeof(GLINTDRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - -#if 0 - /* Check the DRI externsion version */ - if ( sPriv->driMajor != 3 || sPriv->driMinor != 1 ) { - __driUtilMessage( "Gamma DRI driver expected DRI version 4.0.x " - "but got version %d.%d.%d", - sPriv->driMajor, sPriv->driMinor, sPriv->driPatch ); - return NULL; - } - - /* Check that the DDX driver version is compatible */ - if ( sPriv->ddxMajor != 4 || - sPriv->ddxMinor != 0 || - sPriv->ddxPatch < 0 ) { - __driUtilMessage( "r128 DRI driver expected DDX driver version 4.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch ); - return GL_FALSE; - } - - /* Check that the DRM driver version is compatible */ - if ( sPriv->drmMajor != 2 || - sPriv->drmMinor != 1 || - sPriv->drmPatch < 0 ) { - __driUtilMessage( "r128 DRI driver expected DRM driver version 2.1.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch ); - return GL_FALSE; - } -#endif - - /* Allocate the private area */ - gammaScreen = (gammaScreenPtr) CALLOC( sizeof(*gammaScreen) ); - if ( !gammaScreen ) return NULL; - - gammaScreen->regionCount = 4; /* Magic number. Can we fix this? */ - - gammaScreen->regions = CALLOC(gammaScreen->regionCount * - sizeof(gammaRegion)); - - gammaScreen->regions[0].handle = gDRIPriv->registers0.handle; - gammaScreen->regions[0].size = gDRIPriv->registers0.size; - gammaScreen->regions[1].handle = gDRIPriv->registers1.handle; - gammaScreen->regions[1].size = gDRIPriv->registers1.size; - gammaScreen->regions[2].handle = gDRIPriv->registers2.handle; - gammaScreen->regions[2].size = gDRIPriv->registers2.size; - gammaScreen->regions[3].handle = gDRIPriv->registers3.handle; - gammaScreen->regions[3].size = gDRIPriv->registers3.size; - - /* Next, map all the regions */ - for (i = 0; i < gammaScreen->regionCount; i++) { - if (drmMap(sPriv->fd, - gammaScreen->regions[i].handle, - gammaScreen->regions[i].size, - &gammaScreen->regions[i].map)) { - while (--i > 0) { - (void)drmUnmap(gammaScreen->regions[i].map, - gammaScreen->regions[i].size); - } - return GL_FALSE; - } - } - - /* Get the list of dma buffers */ - gammaScreen->bufs = drmMapBufs(sPriv->fd); - - if (!gammaScreen->bufs) { - while (gammaScreen->regionCount > 0) { - (void)drmUnmap(gammaScreen->regions[gammaScreen->regionCount].map, - gammaScreen->regions[gammaScreen->regionCount].size); - gammaScreen->regionCount--; - } - return GL_FALSE; - } - - gammaScreen->textureSize = gDRIPriv->textureSize; - gammaScreen->logTextureGranularity = gDRIPriv->logTextureGranularity; - gammaScreen->cpp = gDRIPriv->cpp; - gammaScreen->frontOffset = gDRIPriv->frontOffset; - gammaScreen->frontPitch = gDRIPriv->frontPitch; - gammaScreen->backOffset = gDRIPriv->backOffset; - gammaScreen->backPitch = gDRIPriv->backPitch; - gammaScreen->backX = gDRIPriv->backX; - gammaScreen->backY = gDRIPriv->backY; - gammaScreen->depthOffset = gDRIPriv->depthOffset; - gammaScreen->depthPitch = gDRIPriv->depthPitch; - - gammaScreen->driScreen = sPriv; - - return gammaScreen; -} - -/* Destroy the device specific screen private data struct. - */ -void gammaDestroyScreen( __DRIscreen *sPriv ) -{ - gammaScreenPtr gammaScreen = (gammaScreenPtr)sPriv->private; - - /* First, unmap the dma buffers */ - drmUnmapBufs( gammaScreen->bufs ); - - /* Next, unmap all the regions */ - while (gammaScreen->regionCount > 0) { - (void)drmUnmap(gammaScreen->regions[gammaScreen->regionCount].map, - gammaScreen->regions[gammaScreen->regionCount].size); - gammaScreen->regionCount--; - } - FREE(gammaScreen->regions); - FREE(gammaScreen); -} diff --git a/src/mesa/drivers/dri/gamma/gamma_screen.h b/src/mesa/drivers/dri/gamma/gamma_screen.h deleted file mode 100644 index c716ea89c29..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_screen.h +++ /dev/null @@ -1,30 +0,0 @@ -typedef struct _gammaRegion { - drm_handle_t handle; - drmSize size; - drmAddress map; -} gammaRegion, *gammaRegionPtr; - -typedef struct { - - int regionCount; /* Count of register regions */ - gammaRegion *regions; /* Vector of mapped region info */ - - drmBufMapPtr bufs; /* Map of DMA buffers */ - - __DRIscreen *driScreen; /* Back pointer to DRI screen */ - - int cpp; - int frontPitch; - int frontOffset; - - int backPitch; - int backOffset; - int backX; - int backY; - - int depthOffset; - int depthPitch; - - int textureSize; - int logTextureGranularity; -} gammaScreenRec, *gammaScreenPtr; diff --git a/src/mesa/drivers/dri/gamma/gamma_span.c b/src/mesa/drivers/dri/gamma/gamma_span.c deleted file mode 100644 index 00160f760b2..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_span.c +++ /dev/null @@ -1,315 +0,0 @@ - -#include "gamma_context.h" -#include "gamma_lock.h" -#include "gamma_macros.h" -#include "main/colormac.h" - -#include "swrast/swrast.h" - -#define DBG 0 - -#define LOCAL_VARS \ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \ - gammaScreenPtr gammascrn = gmesa->gammaScreen; \ - __DRIscreen *sPriv = gmesa->driScreen; \ - __DRIdrawable *dPriv = gmesa->driDrawable; \ - GLuint pitch = sPriv->fbWidth * gammascrn->cpp; \ - GLuint height = dPriv->h; \ - char *buf = (char *)(sPriv->pFB + \ - gmesa->drawOffset + \ - (dPriv->x * gammascrn->cpp) + \ - (dPriv->y * pitch)); \ - GLuint p; \ - (void) buf; (void) p - -/* FIXME! Depth/Stencil read/writes don't work ! */ -#define LOCAL_DEPTH_VARS \ - gammaScreenPtr gammascrn = gmesa->gammaScreen; \ - __DRIdrawable *dPriv = gmesa->driDrawable; \ - __DRIscreen *sPriv = gmesa->driScreen; \ - GLuint pitch = gammascrn->depthPitch; \ - GLuint height = dPriv->h; \ - char *buf = (char *)(sPriv->pFB + \ - gammascrn->depthOffset + \ - dPriv->x * gammascrn->cpp + \ - dPriv->y * pitch) - -#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS - -#define Y_FLIP( _y ) (height - _y - 1) - -#define HW_LOCK() \ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \ - FLUSH_DMA_BUFFER(gmesa); \ - gammaGetLock( gmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT ); \ - GAMMAHW_LOCK( gmesa ); - -#define HW_UNLOCK() GAMMAHW_UNLOCK( gmesa ) - - - -/* ================================================================ - * Color buffer - */ - -/* 16 bit, RGB565 color spanline and pixel functions - */ -#define INIT_MONO_PIXEL(p, color) \ - p = PACK_COLOR_565( color[0], color[1], color[2] ) - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) | \ - (((int)g & 0xfc) << 3) | \ - (((int)b & 0xf8) >> 3)) - -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLushort *)(buf + _x*2 + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \ - rgba[0] = (p >> 8) & 0xf8; \ - rgba[1] = (p >> 3) & 0xfc; \ - rgba[2] = (p << 3) & 0xf8; \ - rgba[3] = 0xff; \ - if ( rgba[0] & 0x08 ) rgba[0] |= 0x07; \ - if ( rgba[1] & 0x04 ) rgba[1] |= 0x03; \ - if ( rgba[2] & 0x08 ) rgba[2] |= 0x07; \ - } while (0) - -#define TAG(x) gamma##x##_RGB565 -#include "spantmp.h" - - -/* 32 bit, ARGB8888 color spanline and pixel functions - */ - -#undef INIT_MONO_PIXEL -#define INIT_MONO_PIXEL(p, color) \ - p = PACK_COLOR_8888( color[3], color[0], color[1], color[2] ) - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \ - (g << 8) | \ - (r << 16) | \ - (a << 24) ) - -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLuint *)(buf + _x*4 + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ -do { \ - GLuint p = *(GLuint *)(buf + _x*4 + _y*pitch); \ - rgba[0] = (p >> 16) & 0xff; \ - rgba[1] = (p >> 8) & 0xff; \ - rgba[2] = (p >> 0) & 0xff; \ - rgba[3] = (p >> 24) & 0xff; \ -} while (0) - -#define TAG(x) gamma##x##_ARGB8888 -#include "spantmp.h" - - -/* 16 bit depthbuffer functions. - */ -#define VALUE_TYPE GLushort - -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d; - -#define READ_DEPTH( d, _x, _y ) \ - d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch); - -#define TAG(x) gamma##x##_16 -#include "depthtmp.h" - - -#if 0 /* Unused */ -/* 32 bit depthbuffer functions. - */ -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = d; - -#define READ_DEPTH( d, _x, _y ) \ - d = *(GLuint *)(buf + (_x)*4 + (_y)*pitch); - -#define TAG(x) gamma##x##_32 -#include "depthtmp.h" -#endif - - -/* 24/8 bit interleaved depth/stencil functions - */ -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH( _x, _y, d ) { \ - GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch); \ - tmp &= 0xff; \ - tmp |= (d) & 0xffffff00; \ - *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = tmp; \ -} - -#define READ_DEPTH( d, _x, _y ) \ - d = *(GLuint *)(buf + (_x)*4 + (_y)*pitch) & ~0xff; - - -#define TAG(x) gamma##x##_24_8 -#include "depthtmp.h" - -#if 0 -#define WRITE_STENCIL( _x, _y, d ) { \ - GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \ - tmp &= 0xffffff00; \ - tmp |= d & 0xff; \ - *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \ -} - -#define READ_STENCIL( d, _x, _y ) \ - d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff; - -#define TAG(x) gamma##x##_24_8 -#include "stenciltmp.h" - -static void gammaReadRGBASpan8888( const GLcontext *ctx, - GLuint n, GLint x, GLint y, - GLubyte rgba[][4]) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - gammaScreenPtr gammascrn = gmesa->gammaScreen; - uint32_t dwords1, dwords2, i = 0; - char *src = (char *)rgba[0]; - GLuint read = n * gammascrn->cpp; /* Number of bytes we are expecting */ - uint32_t data; - - FLUSH_DMA_BUFFER(gmesa); - CHECK_DMA_BUFFER(gmesa, 16); - WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode & ~(LBReadSrcEnable | LBReadDstEnable)); - WRITE(gmesa->buf, ColorDDAMode, ColorDDAEnable); - WRITE(gmesa->buf, LBWriteMode, LBWriteModeDisable); - WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode & ~FBReadSrcEnable) | FBReadDstEnable | FBDataTypeColor); - WRITE(gmesa->buf, FilterMode, 0x200); /* Pass FBColorData */ - WRITE(gmesa->buf, FBWriteMode, FBW_UploadColorData | FBWriteModeDisable); - WRITE(gmesa->buf, StartXSub, (x+n)<<16); - WRITE(gmesa->buf, StartXDom, x<<16); - WRITE(gmesa->buf, StartY, y<<16); - WRITE(gmesa->buf, GLINTCount, 1); - WRITE(gmesa->buf, dXDom, 0<<16); - WRITE(gmesa->buf, dXSub, 0<<16); - WRITE(gmesa->buf, dY, 1<<16); - WRITE(gmesa->buf, Render, PrimitiveTrapezoid); - FLUSH_DMA_BUFFER(gmesa); - -moredata: - - dwords1 = *(volatile uint32_t*)(void *)(((uint8_t*)gammascrn->regions[0].map) + (GlintOutFIFOWords)); - dwords2 = *(volatile uint32_t*)(void *)(((uint8_t*)gammascrn->regions[2].map) + (GlintOutFIFOWords)); - - if (dwords1) { - memcpy(src, (char*)gammascrn->regions[1].map + 0x1000, dwords1 << 2); - src += dwords1 << 2; - read -= dwords1 << 2; - } - if (dwords2) { - memcpy(src, (char*)gammascrn->regions[3].map + 0x1000, dwords2 << 2); - src += dwords2 << 2; - read -= dwords2 << 2; - } - - if (read) - goto moredata; - -done: - - CHECK_DMA_BUFFER(gmesa, 6); - WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode); - WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable); - WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode); - WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode); - WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable); - WRITE(gmesa->buf, FilterMode, 0x400); -} -#endif - -static void gammaSetBuffer( GLcontext *ctx, - GLframebuffer *colorBuffer, - GLuint bufferBit ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - switch ( bufferBit ) { - case BUFFER_BIT_FRONT_LEFT: - gmesa->readOffset = 0; - break; - case BUFFER_BIT_BACK_LEFT: - gmesa->readOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp; - break; - default: - _mesa_problem(ctx, "Unexpected buffer 0x%x in gammaSetBuffer()", bufferBit); - } -} - - -void gammaDDInitSpanFuncs( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx); - - swdd->SetBuffer = gammaSetBuffer; - - switch ( gmesa->gammaScreen->cpp ) { - case 2: - swdd->WriteRGBASpan = gammaWriteRGBASpan_RGB565; - swdd->WriteRGBSpan = gammaWriteRGBSpan_RGB565; - swdd->WriteMonoRGBASpan = gammaWriteMonoRGBASpan_RGB565; - swdd->WriteRGBAPixels = gammaWriteRGBAPixels_RGB565; - swdd->WriteMonoRGBAPixels = gammaWriteMonoRGBAPixels_RGB565; - swdd->ReadRGBASpan = gammaReadRGBASpan_RGB565; - swdd->ReadRGBAPixels = gammaReadRGBAPixels_RGB565; - break; - - case 4: - swdd->WriteRGBASpan = gammaWriteRGBASpan_ARGB8888; - swdd->WriteRGBSpan = gammaWriteRGBSpan_ARGB8888; - swdd->WriteMonoRGBASpan = gammaWriteMonoRGBASpan_ARGB8888; - swdd->WriteRGBAPixels = gammaWriteRGBAPixels_ARGB8888; - swdd->WriteMonoRGBAPixels = gammaWriteMonoRGBAPixels_ARGB8888; -#if 1 - swdd->ReadRGBASpan = gammaReadRGBASpan_ARGB8888; -#else - swdd->ReadRGBASpan = gammaReadRGBASpan8888; -#endif - swdd->ReadRGBAPixels = gammaReadRGBAPixels_ARGB8888; - break; - - default: - break; - } - - switch ( gmesa->glCtx->Visual.depthBits ) { - case 16: - swdd->ReadDepthSpan = gammaReadDepthSpan_16; - swdd->WriteDepthSpan = gammaWriteDepthSpan_16; - swdd->ReadDepthPixels = gammaReadDepthPixels_16; - swdd->WriteDepthPixels = gammaWriteDepthPixels_16; - break; - - case 24: - swdd->ReadDepthSpan = gammaReadDepthSpan_24_8; - swdd->WriteDepthSpan = gammaWriteDepthSpan_24_8; - swdd->ReadDepthPixels = gammaReadDepthPixels_24_8; - swdd->WriteDepthPixels = gammaWriteDepthPixels_24_8; - -#if 0 - swdd->ReadStencilSpan = gammaReadStencilSpan_24_8; - swdd->WriteStencilSpan = gammaWriteStencilSpan_24_8; - swdd->ReadStencilPixels = gammaReadStencilPixels_24_8; - swdd->WriteStencilPixels = gammaWriteStencilPixels_24_8; -#endif - break; - - default: - break; - } -} diff --git a/src/mesa/drivers/dri/gamma/gamma_state.c b/src/mesa/drivers/dri/gamma/gamma_state.c deleted file mode 100644 index c628457fbac..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_state.c +++ /dev/null @@ -1,1721 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - * 3DLabs Gamma driver - */ - -#include "gamma_context.h" -#include "gamma_macros.h" -#include "main/macros.h" -#include "glint_dri.h" -#include "main/colormac.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "vbo/vbo.h" -#include "tnl/tnl.h" - -#define ENABLELIGHTING 0 - -/* ============================================================= - * Alpha blending - */ - -static void gammaUpdateAlphaMode( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - uint32_t a = gmesa->AlphaTestMode; - uint32_t b = gmesa->AlphaBlendMode; - uint32_t f = gmesa->AB_FBReadMode_Save = 0; - GLubyte refByte = (GLint) (ctx->Color.AlphaRef * 255.0); - - a &= ~(AT_CompareMask | AT_RefValueMask); - b &= ~(AB_SrcBlendMask | AB_DstBlendMask); - - a |= refByte << 4; - - switch ( ctx->Color.AlphaFunc ) { - case GL_NEVER: - a |= AT_Never; - break; - case GL_LESS: - a |= AT_Less; - break; - case GL_EQUAL: - a |= AT_Equal; - break; - case GL_LEQUAL: - a |= AT_LessEqual; - break; - case GL_GEQUAL: - a |= AT_GreaterEqual; - break; - case GL_GREATER: - a |= AT_Greater; - break; - case GL_NOTEQUAL: - a |= AT_NotEqual; - break; - case GL_ALWAYS: - a |= AT_Always; - break; - } - - if ( ctx->Color.AlphaEnabled ) { - f |= FBReadDstEnable; - a |= AlphaTestModeEnable; - } else { - a &= ~AlphaTestModeEnable; - } - - switch ( ctx->Color.BlendSrcRGB ) { - case GL_ZERO: - b |= AB_Src_Zero; - break; - case GL_ONE: - b |= AB_Src_One; - break; - case GL_DST_COLOR: - b |= AB_Src_DstColor; - break; - case GL_ONE_MINUS_DST_COLOR: - b |= AB_Src_OneMinusDstColor; - break; - case GL_SRC_ALPHA: - b |= AB_Src_SrcAlpha; - break; - case GL_ONE_MINUS_SRC_ALPHA: - b |= AB_Src_OneMinusSrcAlpha; - break; - case GL_DST_ALPHA: - b |= AB_Src_DstAlpha; - f |= FBReadSrcEnable; - break; - case GL_ONE_MINUS_DST_ALPHA: - b |= AB_Src_OneMinusDstAlpha; - f |= FBReadSrcEnable; - break; - case GL_SRC_ALPHA_SATURATE: - b |= AB_Src_SrcAlphaSaturate; - break; - } - - switch ( ctx->Color.BlendDstRGB ) { - case GL_ZERO: - b |= AB_Dst_Zero; - break; - case GL_ONE: - b |= AB_Dst_One; - break; - case GL_SRC_COLOR: - b |= AB_Dst_SrcColor; - break; - case GL_ONE_MINUS_SRC_COLOR: - b |= AB_Dst_OneMinusSrcColor; - break; - case GL_SRC_ALPHA: - b |= AB_Dst_SrcAlpha; - break; - case GL_ONE_MINUS_SRC_ALPHA: - b |= AB_Dst_OneMinusSrcAlpha; - break; - case GL_DST_ALPHA: - b |= AB_Dst_DstAlpha; - f |= FBReadSrcEnable; - break; - case GL_ONE_MINUS_DST_ALPHA: - b |= AB_Dst_OneMinusDstAlpha; - f |= FBReadSrcEnable; - break; - } - - if ( ctx->Color.BlendEnabled ) { - f |= FBReadDstEnable; - b |= AlphaBlendModeEnable; - } else { - b &= ~AlphaBlendModeEnable; - } - - if ( gmesa->AlphaTestMode != a ) { - gmesa->AlphaTestMode = a; - gmesa->dirty |= GAMMA_UPLOAD_ALPHA; - } - if ( gmesa->AlphaBlendMode != b) { - gmesa->AlphaBlendMode = b; - gmesa->dirty |= GAMMA_UPLOAD_BLEND; - } - gmesa->AB_FBReadMode_Save = f; -} - -static void gammaDDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - (void) ref; - - FLUSH_BATCH( gmesa ); - - gmesa->new_state |= GAMMA_NEW_ALPHA; -} - -static void gammaDDBlendEquationSeparate( GLcontext *ctx, - GLenum modeRGB, GLenum modeA ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - assert( modeRGB == modeA ); - FLUSH_BATCH( gmesa ); - - gmesa->new_state |= GAMMA_NEW_ALPHA; -} - -static void gammaDDBlendFuncSeparate( GLcontext *ctx, - GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_BATCH( gmesa ); - - gmesa->new_state |= GAMMA_NEW_ALPHA; -} - - -/* ================================================================ - * Buffer clear - */ - -static void gammaDDClear( GLcontext *ctx, GLbitfield mask ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)gmesa->driScreen->pDevPriv; - GLuint temp = 0; - - FLUSH_BATCH( gmesa ); - - /* Update and emit any new state. We need to do this here to catch - * changes to the masks. - * FIXME: Just update the masks? - */ - if ( gmesa->new_state ) - gammaDDUpdateHWState( ctx ); - -#ifdef DO_VALIDATE - /* Flush any partially filled buffers */ - FLUSH_DMA_BUFFER(gmesa); - - DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock, - gmesa->driScreen->drawLockID); - VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa); -#endif - - if (mask & BUFFER_BIT_DEPTH) { - /* Turn off writes the FB */ - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, FBWriteMode, FBWriteModeDisable); - - mask &= ~BUFFER_BIT_DEPTH; - - /* - * Turn Rectangle2DControl off when the window is not clipped - * (i.e., the GID tests are not necessary). This dramatically - * increases the performance of the depth clears. - */ - if (!gmesa->NotClipped) { - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, Rectangle2DControl, 1); - } - - temp = (gmesa->LBReadMode & LBPartialProdMask) | LBWindowOriginBot; - if (gDRIPriv->numMultiDevices == 2) temp |= LBScanLineInt2; - - CHECK_DMA_BUFFER(gmesa, 5); - WRITE(gmesa->buf, LBReadMode, temp); - WRITE(gmesa->buf, DeltaMode, DM_DepthEnable); - WRITE(gmesa->buf, DepthMode, (DepthModeEnable | - DM_Always | - DM_SourceDepthRegister | - DM_WriteMask)); - WRITE(gmesa->buf, GLINTDepth, gmesa->ClearDepth); - - /* Increment the frame count */ - gmesa->FrameCount++; -#ifdef FAST_CLEAR_4 - gmesa->FrameCount &= 0x0f; -#else - gmesa->FrameCount &= 0xff; -#endif - - /* Force FCP to be written */ - WRITE(gmesa->buf, GLINTWindow, (WindowEnable | - W_PassIfEqual | - (gmesa->Window & W_GIDMask) | - W_DepthFCP | - W_LBUpdateFromRegisters | - W_OverrideWriteFiltering | - (gmesa->FrameCount << 9))); - - /* Clear part of the depth and FCP buffers */ - { - int y = gmesa->driScreen->fbHeight - gmesa->driDrawable->y - gmesa->driDrawable->h; - int x = gmesa->driDrawable->x; - int w = gmesa->driDrawable->w; - int h = gmesa->driDrawable->h; -#ifndef TURN_OFF_FCP - float hsub = h; - - if (gmesa->WindowChanged) { - gmesa->WindowChanged = GL_FALSE; - } else { -#ifdef FAST_CLEAR_4 - hsub /= 16; -#else - hsub /= 256; -#endif - - /* Handle the case where the height < # of FCPs */ - if (hsub < 1.0) { - if (gmesa->FrameCount > h) - gmesa->FrameCount = 0; - h = 1; - y += gmesa->FrameCount; - } else { - h = (gmesa->FrameCount+1)*hsub; - h -= (int)(gmesa->FrameCount*hsub); - y += gmesa->FrameCount*hsub; - } - } -#endif - if (h && w) { -#if 0 - CHECK_DMA_BUFFER(gmesa, 2); - WRITE(gmesa->buf, Rectangle2DMode, ((h & 0xfff)<<12) | - (w & 0xfff) ); - WRITE(gmesa->buf, DrawRectangle2D, ((y & 0xffff)<<16) | - (x & 0xffff) ); -#else - CHECK_DMA_BUFFER(gmesa, 8); - WRITE(gmesa->buf, StartXDom, x<<16); - WRITE(gmesa->buf, StartY, y<<16); - WRITE(gmesa->buf, StartXSub, (x+w)<<16); - WRITE(gmesa->buf, GLINTCount, h); - WRITE(gmesa->buf, dY, 1<<16); - WRITE(gmesa->buf, dXDom, 0<<16); - WRITE(gmesa->buf, dXSub, 0<<16); - WRITE(gmesa->buf, Render, 0x00000040); /* NOT_DONE */ -#endif - } - } - - CHECK_DMA_BUFFER(gmesa, 6); - WRITE(gmesa->buf, DepthMode, gmesa->DepthMode); - WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode); - WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode); - WRITE(gmesa->buf, GLINTWindow, gmesa->Window); - WRITE(gmesa->buf, FastClearDepth, gmesa->ClearDepth); - WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable); - - /* Turn on Depth FCP */ - if (gmesa->Window & W_DepthFCP) { - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, WindowOr, (gmesa->FrameCount << 9)); - } - - /* Turn off GID clipping if window is not clipped */ - if (gmesa->NotClipped) { - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, Rectangle2DControl, 0); - } - } - - if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) { - int y = gmesa->driScreen->fbHeight - gmesa->driDrawable->y - gmesa->driDrawable->h; - int x = gmesa->driDrawable->x; - int w = gmesa->driDrawable->w; - int h = gmesa->driDrawable->h; - - mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT); - - if (x < 0) { w -= -x; x = 0; } - - /* Turn on GID clipping if window is clipped */ - if (!gmesa->NotClipped) { - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, Rectangle2DControl, 1); - } - - CHECK_DMA_BUFFER(gmesa, 18); - WRITE(gmesa->buf, FBBlockColor, gmesa->ClearColor); - WRITE(gmesa->buf, ColorDDAMode, ColorDDADisable); - WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable); - WRITE(gmesa->buf, DepthMode, 0); - WRITE(gmesa->buf, DeltaMode, 0); - WRITE(gmesa->buf, AlphaBlendMode, 0); -#if 1 - WRITE(gmesa->buf, dY, 1<<16); - WRITE(gmesa->buf, dXDom, 0<<16); - WRITE(gmesa->buf, dXSub, 0<<16); - WRITE(gmesa->buf, StartXSub, (x+w)<<16); - WRITE(gmesa->buf, GLINTCount, h); - WRITE(gmesa->buf, StartXDom, x<<16); - WRITE(gmesa->buf, StartY, y<<16); - WRITE(gmesa->buf, Render, 0x00000048); /* NOT_DONE */ -#else - WRITE(gmesa->buf, Rectangle2DMode, (((h & 0xfff)<<12) | - (w & 0xfff))); - WRITE(gmesa->buf, DrawRectangle2D, (((y & 0xffff)<<16) | - (x & 0xffff))); -#endif - WRITE(gmesa->buf, DepthMode, gmesa->DepthMode); - WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode); - WRITE(gmesa->buf, AlphaBlendMode, gmesa->AlphaBlendMode); - WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode); - - /* Turn off GID clipping if window is clipped */ - if (gmesa->NotClipped) { - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, Rectangle2DControl, 0); - } - } - -#ifdef DO_VALIDATE - PROCESS_DMA_BUFFER_TOP_HALF(gmesa); - - DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock, - gmesa->driScreen->drawLockID); - VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa); - - PROCESS_DMA_BUFFER_BOTTOM_HALF(gmesa); -#endif - - if ( mask ) - _swrast_Clear( ctx, mask ); -} - -/* ============================================================= - * Depth testing - */ - -static void gammaUpdateZMode( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - uint32_t z = gmesa->DepthMode; - uint32_t delta = gmesa->DeltaMode; - uint32_t window = gmesa->Window; - uint32_t lbread = gmesa->LBReadMode; - - z &= ~DM_CompareMask; - - switch ( ctx->Depth.Func ) { - case GL_NEVER: - z |= DM_Never; - break; - case GL_ALWAYS: - z |= DM_Always; - break; - case GL_LESS: - z |= DM_Less; - break; - case GL_LEQUAL: - z |= DM_LessEqual; - break; - case GL_EQUAL: - z |= DM_Equal; - break; - case GL_GEQUAL: - z |= DM_GreaterEqual; - break; - case GL_GREATER: - z |= DM_Greater; - break; - case GL_NOTEQUAL: - z |= DM_NotEqual; - break; - } - - if ( ctx->Depth.Test ) { - z |= DepthModeEnable; - delta |= DM_DepthEnable; - window |= W_DepthFCP; - lbread |= LBReadDstEnable; - } else { - z &= ~DepthModeEnable; - delta &= ~DM_DepthEnable; - window &= ~W_DepthFCP; - lbread &= ~LBReadDstEnable; - } - - if ( ctx->Depth.Mask ) { - z |= DM_WriteMask; - } else { - z &= ~DM_WriteMask; - } - -#if 0 - if ( gmesa->DepthMode != z ){ -#endif - gmesa->DepthMode = z; - gmesa->DeltaMode = delta; - gmesa->Window = window; - gmesa->LBReadMode = lbread; - gmesa->dirty |= GAMMA_UPLOAD_DEPTH; -#if 0 - } -#endif -} - -static void gammaDDDepthFunc( GLcontext *ctx, GLenum func ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_DEPTH; -} - -static void gammaDDDepthMask( GLcontext *ctx, GLboolean flag ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_DEPTH; -} - -static void gammaDDClearDepth( GLcontext *ctx, GLclampd d ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - switch ( gmesa->DepthSize ) { - case 16: - gmesa->ClearDepth = d * 0x0000ffff; - break; - case 24: - gmesa->ClearDepth = d * 0x00ffffff; - break; - case 32: - gmesa->ClearDepth = d * 0xffffffff; - break; - } -} - -static void gammaDDFinish( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_DMA_BUFFER(gmesa); -} - -static void gammaDDFlush( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_DMA_BUFFER(gmesa); -} - -/* ============================================================= - * Fog - */ - -static void gammaUpdateFogAttrib( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - uint32_t f = gmesa->FogMode; - uint32_t g = gmesa->GeometryMode; - uint32_t d = gmesa->DeltaMode; - - if (ctx->Fog.Enabled) { - f |= FogModeEnable; - g |= GM_FogEnable; - d |= DM_FogEnable; - } else { - f &= ~FogModeEnable; - g &= ~GM_FogEnable; - d &= ~DM_FogEnable; - } - - g &= ~GM_FogMask; - - switch (ctx->Fog.Mode) { - case GL_LINEAR: - g |= GM_FogLinear; - break; - case GL_EXP: - g |= GM_FogExp; - break; - case GL_EXP2: - g |= GM_FogExpSquared; - break; - } - - if ( gmesa->FogMode != f ) { - gmesa->FogMode = f; - gmesa->dirty |= GAMMA_UPLOAD_FOG; - } - - if ( gmesa->GeometryMode != g ) { - gmesa->GeometryMode = g; - gmesa->dirty |= GAMMA_UPLOAD_GEOMETRY; - } - - if ( gmesa->DeltaMode != d ) { - gmesa->DeltaMode = d; - gmesa->dirty |= GAMMA_UPLOAD_DEPTH; - } -} - -#if 0 -static void gammaDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_FOG; -} -#endif - -/* ============================================================= - * Lines - */ -static void gammaDDLineWidth( GLcontext *ctx, GLfloat width ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - CHECK_DMA_BUFFER(gmesa, 3); - WRITE(gmesa->buf, LineWidth, (GLuint)width); - WRITEF(gmesa->buf, AAlineWidth, width); - WRITE(gmesa->buf, LineWidthOffset, (GLuint)(width-1)/2); -} - -static void gammaDDLineStipple( GLcontext *ctx, GLint factor, GLushort pattern ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - gmesa->LineMode &= ~(LM_StippleMask | LM_RepeatFactorMask); - gmesa->LineMode |= ((GLuint)(factor - 1) << 1) | ((GLuint)pattern << 10); - - gmesa->dirty |= GAMMA_UPLOAD_LINEMODE; -} - - - -/* ============================================================= - * Points - */ -static void gammaDDPointSize( GLcontext *ctx, GLfloat size ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - CHECK_DMA_BUFFER(gmesa, 2); - WRITE(gmesa->buf, PointSize, (GLuint)size); - WRITEF(gmesa->buf, AApointSize, size); -} - -/* ============================================================= - * Polygon - */ - -static void gammaUpdatePolygon( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - uint32_t g = gmesa->GeometryMode; - - g &= ~(GM_PolyOffsetFillEnable | GM_PolyOffsetPointEnable | - GM_PolyOffsetLineEnable); - - if (ctx->Polygon.OffsetFill) g |= GM_PolyOffsetFillEnable; - if (ctx->Polygon.OffsetPoint) g |= GM_PolyOffsetPointEnable; - if (ctx->Polygon.OffsetLine) g |= GM_PolyOffsetLineEnable; - - g &= ~GM_FB_PolyMask; - - switch (ctx->Polygon.FrontMode) { - case GL_FILL: - g |= GM_FrontPolyFill; - break; - case GL_LINE: - g |= GM_FrontPolyLine; - break; - case GL_POINT: - g |= GM_FrontPolyPoint; - break; - } - - switch (ctx->Polygon.BackMode) { - case GL_FILL: - g |= GM_BackPolyFill; - break; - case GL_LINE: - g |= GM_BackPolyLine; - break; - case GL_POINT: - g |= GM_BackPolyPoint; - break; - } - - if ( gmesa->GeometryMode != g ) { - gmesa->GeometryMode = g; - gmesa->dirty |= GAMMA_UPLOAD_GEOMETRY; - } - - gmesa->dirty |= GAMMA_UPLOAD_POLYGON; -} - -static void gammaDDPolygonMode( GLcontext *ctx, GLenum face, GLenum mode) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_BATCH( gmesa ); - - gmesa->new_state |= GAMMA_NEW_POLYGON; -} - -static void gammaUpdateStipple( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_BATCH( gmesa ); - - if (ctx->Polygon.StippleFlag) { - gmesa->AreaStippleMode |= AreaStippleModeEnable/* | ASM_X32 | ASM_Y32*/; - } else { - gmesa->AreaStippleMode &= ~AreaStippleModeEnable; - } - - gmesa->dirty |= GAMMA_UPLOAD_STIPPLE; -} - -static void gammaDDPolygonStipple( GLcontext *ctx, const GLubyte *mask) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_STIPPLE; -} - -/* ============================================================= - * Clipping - */ - -static void gammaUpdateClipping( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - GLint x1, y1, x2, y2; - - if ( gmesa->driDrawable ) { - x1 = gmesa->driDrawable->x + ctx->Scissor.X; - y1 = gmesa->driScreen->fbHeight - - (gmesa->driDrawable->y + - gmesa->driDrawable->h) + ctx->Scissor.Y; - x2 = x1 + ctx->Scissor.Width; - y2 = y1 + ctx->Scissor.Height; - - gmesa->ScissorMinXY = x1 | (y1 << 16); - gmesa->ScissorMaxXY = x2 | (y2 << 16); - if (ctx->Scissor.Enabled) - gmesa->ScissorMode |= UserScissorEnable; - else - gmesa->ScissorMode &= ~UserScissorEnable; - - gmesa->dirty |= GAMMA_UPLOAD_CLIP; - } -} - -static void gammaDDScissor( GLcontext *ctx, - GLint x, GLint y, GLsizei w, GLsizei h ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_CLIP; -} - -/* ============================================================= - * Culling - */ - -static void gammaUpdateCull( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - uint32_t g = gmesa->GeometryMode; - - g &= ~(GM_PolyCullMask | GM_FFMask); - - if (ctx->Polygon.FrontFace == GL_CCW) { - g |= GM_FrontFaceCCW; - } else { - g |= GM_FrontFaceCW; - } - - switch ( ctx->Polygon.CullFaceMode ) { - case GL_FRONT: - g |= GM_PolyCullFront; - break; - case GL_BACK: - g |= GM_PolyCullBack; - break; - case GL_FRONT_AND_BACK: - g |= GM_PolyCullBoth; - break; - } - - if ( ctx->Polygon.CullFlag ) { - g |= GM_PolyCullEnable; - } else { - g &= ~GM_PolyCullEnable; - } - - if ( gmesa->GeometryMode != g ) { - gmesa->GeometryMode = g; - gmesa->dirty |= GAMMA_UPLOAD_GEOMETRY; - } -} - -static void gammaDDCullFace( GLcontext *ctx, GLenum mode ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_CULL; -} - -static void gammaDDFrontFace( GLcontext *ctx, GLenum mode ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_CULL; -} - -/* ============================================================= - * Masks - */ - -static void gammaUpdateMasks( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - - GLuint mask = gammaPackColor( gmesa->gammaScreen->cpp, - ctx->Color.ColorMask[0][RCOMP], - ctx->Color.ColorMask[0][GCOMP], - ctx->Color.ColorMask[0][BCOMP], - ctx->Color.ColorMask[0][ACOMP] ); - - if (gmesa->gammaScreen->cpp == 2) mask |= mask << 16; - - if ( gmesa->FBHardwareWriteMask != mask ) { - gmesa->FBHardwareWriteMask = mask; - gmesa->dirty |= GAMMA_UPLOAD_MASKS; - } -} - -static void gammaDDColorMask( GLcontext *ctx, GLboolean r, GLboolean g, - GLboolean b, GLboolean a) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_MASKS; -} - -/* ============================================================= - * Rendering attributes - * - * We really don't want to recalculate all this every time we bind a - * texture. These things shouldn't change all that often, so it makes - * sense to break them out of the core texture state update routines. - */ - -#if ENABLELIGHTING -static void gammaDDLightfv(GLcontext *ctx, GLenum light, GLenum pname, - const GLfloat *params, GLint nParams) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - GLfloat l,x,y,z,w; - - switch(light) { - case GL_LIGHT0: - switch (pname) { - case GL_AMBIENT: - CHECK_DMA_BUFFER(gmesa, 3); - /* We don't do alpha */ - WRITEF(gmesa->buf, Light0AmbientIntensityBlue, params[2]); - WRITEF(gmesa->buf, Light0AmbientIntensityGreen, params[1]); - WRITEF(gmesa->buf, Light0AmbientIntensityRed, params[0]); - break; - case GL_DIFFUSE: - CHECK_DMA_BUFFER(gmesa, 3); - /* We don't do alpha */ - WRITEF(gmesa->buf, Light0DiffuseIntensityBlue, params[2]); - WRITEF(gmesa->buf, Light0DiffuseIntensityGreen, params[1]); - WRITEF(gmesa->buf, Light0DiffuseIntensityRed, params[0]); - break; - case GL_SPECULAR: - CHECK_DMA_BUFFER(gmesa, 3); - /* We don't do alpha */ - WRITEF(gmesa->buf, Light0SpecularIntensityBlue, params[2]); - WRITEF(gmesa->buf, Light0SpecularIntensityGreen, params[1]); - WRITEF(gmesa->buf, Light0SpecularIntensityRed, params[0]); - break; - case GL_POSITION: - /* Normalize */ - x = params[0]; y = params[1]; z = params[2]; w = params[3]; - l = sqrt(x*x + y*y + z*z + w*w); - w /= l; - x /= l; - y /= l; - z /= l; - if (params[3] != 0.0) { - gmesa->Light0Mode |= Light0ModeAttenuation; - gmesa->Light0Mode |= Light0ModeLocal; - } else { - gmesa->Light0Mode &= ~Light0ModeAttenuation; - gmesa->Light0Mode &= ~Light0ModeLocal; - } - CHECK_DMA_BUFFER(gmesa, 5); - WRITE(gmesa->buf, Light0Mode, gmesa->Light0Mode); - WRITEF(gmesa->buf, Light0PositionW, w); - WRITEF(gmesa->buf, Light0PositionZ, z); - WRITEF(gmesa->buf, Light0PositionY, y); - WRITEF(gmesa->buf, Light0PositionX, x); - break; - case GL_SPOT_DIRECTION: - CHECK_DMA_BUFFER(gmesa, 3); - /* WRITEF(gmesa->buf, Light0SpotlightDirectionW, params[3]); */ - WRITEF(gmesa->buf, Light0SpotlightDirectionZ, params[2]); - WRITEF(gmesa->buf, Light0SpotlightDirectionY, params[1]); - WRITEF(gmesa->buf, Light0SpotlightDirectionX, params[0]); - break; - case GL_SPOT_EXPONENT: - CHECK_DMA_BUFFER(gmesa, 1); - WRITEF(gmesa->buf, Light0SpotlightExponent, params[0]); - break; - case GL_SPOT_CUTOFF: - if (params[0] != 180.0) - gmesa->Light0Mode |= Light0ModeSpotLight; - else - gmesa->Light0Mode &= ~Light0ModeSpotLight; - CHECK_DMA_BUFFER(gmesa, 2); - WRITE(gmesa->buf, Light0Mode, gmesa->Light0Mode); - WRITEF(gmesa->buf, Light0CosSpotlightCutoffAngle, cos(params[0]*DEG2RAD)); - break; - case GL_CONSTANT_ATTENUATION: - CHECK_DMA_BUFFER(gmesa, 1); - WRITEF(gmesa->buf, Light0ConstantAttenuation, params[0]); - break; - case GL_LINEAR_ATTENUATION: - CHECK_DMA_BUFFER(gmesa, 1); - WRITEF(gmesa->buf, Light0LinearAttenuation, params[0]); - break; - case GL_QUADRATIC_ATTENUATION: - CHECK_DMA_BUFFER(gmesa, 1); - WRITEF(gmesa->buf, Light0QuadraticAttenuation, params[0]); - break; - } - break; - } -} - -static void gammaDDLightModelfv( GLcontext *ctx, GLenum pname, - const GLfloat *params ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - switch (pname) { - case GL_LIGHT_MODEL_AMBIENT: - CHECK_DMA_BUFFER(gmesa, 3); - /* We don't do alpha */ - WRITEF(gmesa->buf, SceneAmbientColorBlue, params[2]); - WRITEF(gmesa->buf, SceneAmbientColorGreen, params[1]); - WRITEF(gmesa->buf, SceneAmbientColorRed, params[0]); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - if (params[0] != 0.0) - gmesa->LightingMode |= LightingModeLocalViewer; - else - gmesa->LightingMode &= ~LightingModeLocalViewer; - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, LightingMode, gmesa->LightingMode); - break; - case GL_LIGHT_MODEL_TWO_SIDE: - if (params[0] == 1.0f) { - gmesa->LightingMode |= LightingModeTwoSides; - gmesa->MaterialMode |= MaterialModeTwoSides; - } else { - gmesa->LightingMode &= ~LightingModeTwoSides; - gmesa->MaterialMode &= ~MaterialModeTwoSides; - } - CHECK_DMA_BUFFER(gmesa, 2); - WRITE(gmesa->buf, LightingMode, gmesa->LightingMode); - WRITE(gmesa->buf, MaterialMode, gmesa->MaterialMode); - break; - } -} -#endif - -static void gammaDDShadeModel( GLcontext *ctx, GLenum mode ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - uint32_t g = gmesa->GeometryMode; - uint32_t c = gmesa->ColorDDAMode; - - g &= ~GM_ShadingMask; - c &= ~ColorDDAShadingMask; - - switch ( mode ) { - case GL_FLAT: - g |= GM_FlatShading; - c |= ColorDDAFlat; - break; - case GL_SMOOTH: - g |= GM_GouraudShading; - c |= ColorDDAGouraud; - break; - default: - return; - } - - if ( gmesa->ColorDDAMode != c ) { - FLUSH_BATCH( gmesa ); - gmesa->ColorDDAMode = c; - - gmesa->dirty |= GAMMA_UPLOAD_SHADE; - } - - if ( gmesa->GeometryMode != g ) { - FLUSH_BATCH( gmesa ); - gmesa->GeometryMode = g; - - gmesa->dirty |= GAMMA_UPLOAD_GEOMETRY; - } -} - -/* ============================================================= - * Miscellaneous - */ - -static void gammaDDClearColor( GLcontext *ctx, const GLfloat color[4]) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - GLubyte c[4]; - UNCLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - UNCLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - UNCLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - UNCLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - - gmesa->ClearColor = gammaPackColor( gmesa->gammaScreen->cpp, - c[0], c[1], c[2], c[3] ); - - if (gmesa->gammaScreen->cpp == 2) gmesa->ClearColor |= gmesa->ClearColor<<16; -} - - -static void gammaDDLogicalOpcode( GLcontext *ctx, GLenum opcode ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_BATCH( gmesa ); - - if ( ctx->Color.ColorLogicOpEnabled ) { - gmesa->LogicalOpMode = opcode << 1 | LogicalOpModeEnable; - } else { - gmesa->LogicalOpMode = LogicalOpModeDisable; - } - - gmesa->dirty |= GAMMA_UPLOAD_LOGICOP; -} - -static void gammaDDDrawBuffer( GLcontext *ctx, GLenum mode ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - FLUSH_BATCH( gmesa ); - - switch ( mode ) { - case GL_FRONT_LEFT: - gmesa->drawOffset = gmesa->readOffset = 0; - break; - case GL_BACK_LEFT: - gmesa->drawOffset = gmesa->readOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp; - break; - } -} - -static void gammaDDReadBuffer( GLcontext *ctx, GLenum mode ) -{ - /* XXX anything? */ -} - -/* ============================================================= - * Window position and viewport transformation - */ - -void gammaUpdateWindow( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - __DRIdrawable *dPriv = gmesa->driDrawable; - GLfloat xoffset = (GLfloat)dPriv->x; - GLfloat yoffset = gmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h; - const GLfloat *v = ctx->Viewport._WindowMap.m; - - GLfloat sx = v[MAT_SX]; - GLfloat tx = v[MAT_TX] + xoffset; - GLfloat sy = v[MAT_SY]; - GLfloat ty = v[MAT_TY] + yoffset; - GLfloat sz = v[MAT_SZ] * gmesa->depth_scale; - GLfloat tz = v[MAT_TZ] * gmesa->depth_scale; - - gmesa->dirty |= GAMMA_UPLOAD_VIEWPORT; - - gmesa->ViewportScaleX = sx; - gmesa->ViewportScaleY = sy; - gmesa->ViewportScaleZ = sz; - gmesa->ViewportOffsetX = tx; - gmesa->ViewportOffsetY = ty; - gmesa->ViewportOffsetZ = tz; -} - - - -static void gammaDDViewport( GLcontext *ctx, GLint x, GLint y, - GLsizei width, GLsizei height ) -{ - gammaUpdateWindow( ctx ); -} - -static void gammaDDDepthRange( GLcontext *ctx, GLclampd nearval, - GLclampd farval ) -{ - gammaUpdateWindow( ctx ); -} - -void gammaUpdateViewportOffset( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - __DRIdrawable *dPriv = gmesa->driDrawable; - GLfloat xoffset = (GLfloat)dPriv->x; - GLfloat yoffset = gmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h; - const GLfloat *v = ctx->Viewport._WindowMap.m; - - GLfloat tx = v[MAT_TX] + xoffset; - GLfloat ty = v[MAT_TY] + yoffset; - - if ( gmesa->ViewportOffsetX != tx || - gmesa->ViewportOffsetY != ty ) - { - gmesa->ViewportOffsetX = tx; - gmesa->ViewportOffsetY = ty; - - gmesa->new_state |= GAMMA_NEW_WINDOW; - } - - gmesa->new_state |= GAMMA_NEW_CLIP; -} - -#if 0 -/* - * Matrix - */ - -static void gammaLoadHWMatrix(GLcontext *ctx) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - const GLfloat *m; - - gmesa->TransformMode &= ~XM_XformTexture; - - switch (ctx->Transform.MatrixMode) { - case GL_MODELVIEW: - gmesa->TransformMode |= XM_UseModelViewMatrix; - m = ctx->ModelviewMatrixStack.Top->m; - CHECK_DMA_BUFFER(gmesa, 16); - WRITEF(gmesa->buf, ModelViewMatrix0, m[0]); - WRITEF(gmesa->buf, ModelViewMatrix1, m[1]); - WRITEF(gmesa->buf, ModelViewMatrix2, m[2]); - WRITEF(gmesa->buf, ModelViewMatrix3, m[3]); - WRITEF(gmesa->buf, ModelViewMatrix4, m[4]); - WRITEF(gmesa->buf, ModelViewMatrix5, m[5]); - WRITEF(gmesa->buf, ModelViewMatrix6, m[6]); - WRITEF(gmesa->buf, ModelViewMatrix7, m[7]); - WRITEF(gmesa->buf, ModelViewMatrix8, m[8]); - WRITEF(gmesa->buf, ModelViewMatrix9, m[9]); - WRITEF(gmesa->buf, ModelViewMatrix10, m[10]); - WRITEF(gmesa->buf, ModelViewMatrix11, m[11]); - WRITEF(gmesa->buf, ModelViewMatrix12, m[12]); - WRITEF(gmesa->buf, ModelViewMatrix13, m[13]); - WRITEF(gmesa->buf, ModelViewMatrix14, m[14]); - WRITEF(gmesa->buf, ModelViewMatrix15, m[15]); - break; - case GL_PROJECTION: - m = ctx->ProjectionMatrixStack.Top->m; - CHECK_DMA_BUFFER(gmesa, 16); - WRITEF(gmesa->buf, ModelViewProjectionMatrix0, m[0]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix1, m[1]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix2, m[2]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix3, m[3]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix4, m[4]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix5, m[5]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix6, m[6]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix7, m[7]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix8, m[8]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix9, m[9]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix10, m[10]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix11, m[11]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix12, m[12]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix13, m[13]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix14, m[14]); - WRITEF(gmesa->buf, ModelViewProjectionMatrix15, m[15]); - break; - case GL_TEXTURE: - m = ctx->TextureMatrixStack[0].Top->m; - CHECK_DMA_BUFFER(gmesa, 16); - gmesa->TransformMode |= XM_XformTexture; - WRITEF(gmesa->buf, TextureMatrix0, m[0]); - WRITEF(gmesa->buf, TextureMatrix1, m[1]); - WRITEF(gmesa->buf, TextureMatrix2, m[2]); - WRITEF(gmesa->buf, TextureMatrix3, m[3]); - WRITEF(gmesa->buf, TextureMatrix4, m[4]); - WRITEF(gmesa->buf, TextureMatrix5, m[5]); - WRITEF(gmesa->buf, TextureMatrix6, m[6]); - WRITEF(gmesa->buf, TextureMatrix7, m[7]); - WRITEF(gmesa->buf, TextureMatrix8, m[8]); - WRITEF(gmesa->buf, TextureMatrix9, m[9]); - WRITEF(gmesa->buf, TextureMatrix10, m[10]); - WRITEF(gmesa->buf, TextureMatrix11, m[11]); - WRITEF(gmesa->buf, TextureMatrix12, m[12]); - WRITEF(gmesa->buf, TextureMatrix13, m[13]); - WRITEF(gmesa->buf, TextureMatrix14, m[14]); - WRITEF(gmesa->buf, TextureMatrix15, m[15]); - break; - - default: - /* ERROR!!! -- how did this happen? */ - break; - } - - gmesa->dirty |= GAMMA_UPLOAD_TRANSFORM; -} -#endif - -/* ============================================================= - * State enable/disable - */ - -static void gammaDDEnable( GLcontext *ctx, GLenum cap, GLboolean state ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - switch ( cap ) { - case GL_ALPHA_TEST: - case GL_BLEND: - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_ALPHA; - break; - - case GL_CULL_FACE: - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_CULL; - break; - - case GL_DEPTH_TEST: - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_DEPTH; - break; - - case GL_DITHER: - do { - uint32_t d = gmesa->DitherMode; - FLUSH_BATCH( gmesa ); - - if ( state ) { - d |= DM_DitherEnable; - } else { - d &= ~DM_DitherEnable; - } - - if ( gmesa->DitherMode != d ) { - gmesa->DitherMode = d; - gmesa->dirty |= GAMMA_UPLOAD_DITHER; - } - } while (0); - break; - -#if 0 - case GL_FOG: - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_FOG; - break; -#endif - - case GL_INDEX_LOGIC_OP: - case GL_COLOR_LOGIC_OP: - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_LOGICOP; - break; - -#if ENABLELIGHTING - case GL_LIGHTING: - do { - uint32_t l = gmesa->LightingMode; - FLUSH_BATCH( gmesa ); - - if ( state ) { - l |= LightingModeEnable; - } else { - l &= ~LightingModeEnable; - } - - if ( gmesa->LightingMode != l ) { - gmesa->LightingMode = l; - gmesa->dirty |= GAMMA_UPLOAD_LIGHT; - } - } while (0); - break; - - case GL_COLOR_MATERIAL: - do { - uint32_t m = gmesa->MaterialMode; - FLUSH_BATCH( gmesa ); - - if ( state ) { - m |= MaterialModeEnable; - } else { - m &= ~MaterialModeEnable; - } - - if ( gmesa->MaterialMode != m ) { - gmesa->MaterialMode = m; - gmesa->dirty |= GAMMA_UPLOAD_LIGHT; - } - } while (0); - break; -#endif - - case GL_LINE_SMOOTH: - FLUSH_BATCH( gmesa ); - if ( state ) { - gmesa->AntialiasMode |= AntialiasModeEnable; - gmesa->LineMode |= LM_AntialiasEnable; - } else { - gmesa->AntialiasMode &= ~AntialiasModeEnable; - gmesa->LineMode &= ~LM_AntialiasEnable; - } - gmesa->dirty |= GAMMA_UPLOAD_LINEMODE; - break; - - case GL_POINT_SMOOTH: - FLUSH_BATCH( gmesa ); - if ( state ) { - gmesa->AntialiasMode |= AntialiasModeEnable; - gmesa->PointMode |= PM_AntialiasEnable; - } else { - gmesa->AntialiasMode &= ~AntialiasModeEnable; - gmesa->PointMode &= ~PM_AntialiasEnable; - } - gmesa->dirty |= GAMMA_UPLOAD_POINTMODE; - break; - - case GL_POLYGON_SMOOTH: - FLUSH_BATCH( gmesa ); - if ( state ) { - gmesa->AntialiasMode |= AntialiasModeEnable; - gmesa->TriangleMode |= TM_AntialiasEnable; - } else { - gmesa->AntialiasMode &= ~AntialiasModeEnable; - gmesa->TriangleMode &= ~TM_AntialiasEnable; - } - gmesa->dirty |= GAMMA_UPLOAD_TRIMODE; - break; - - case GL_SCISSOR_TEST: - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_CLIP; - break; - - case GL_POLYGON_OFFSET_FILL: - case GL_POLYGON_OFFSET_POINT: - case GL_POLYGON_OFFSET_LINE: - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_POLYGON; - break; - - case GL_LINE_STIPPLE: - FLUSH_BATCH( gmesa ); - if ( state ) - gmesa->LineMode |= LM_StippleEnable; - else - gmesa->LineMode &= ~LM_StippleEnable; - gmesa->dirty |= GAMMA_UPLOAD_LINEMODE; - break; - - case GL_POLYGON_STIPPLE: - FLUSH_BATCH( gmesa ); - gmesa->new_state |= GAMMA_NEW_STIPPLE; - break; - - default: - return; - } -} - -/* ============================================================= - * State initialization, management - */ - - -/* - * Load the current context's state into the hardware. - * - * NOTE: Be VERY careful about ensuring the context state is marked for - * upload, the only place it shouldn't be uploaded is when the setup - * state has changed in ReducedPrimitiveChange as this comes right after - * a state update. - * - * Blits of any type should always upload the context and masks after - * they are done. - */ -void gammaEmitHwState( gammaContextPtr gmesa ) -{ - if (!gmesa->driDrawable) return; - - if (!gmesa->dirty) return; - -#ifdef DO_VALIDATE - /* Flush any partially filled buffers */ - FLUSH_DMA_BUFFER(gmesa); - - DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock, - gmesa->driScreen->drawLockID); - VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa); -#endif - - if (gmesa->dirty & GAMMA_UPLOAD_VIEWPORT) { - gmesa->dirty &= ~GAMMA_UPLOAD_VIEWPORT; - CHECK_DMA_BUFFER(gmesa, 6); - WRITEF(gmesa->buf, ViewPortOffsetX, gmesa->ViewportOffsetX); - WRITEF(gmesa->buf, ViewPortOffsetY, gmesa->ViewportOffsetY); - WRITEF(gmesa->buf, ViewPortOffsetZ, gmesa->ViewportOffsetZ); - WRITEF(gmesa->buf, ViewPortScaleX, gmesa->ViewportScaleX); - WRITEF(gmesa->buf, ViewPortScaleY, gmesa->ViewportScaleY); - WRITEF(gmesa->buf, ViewPortScaleZ, gmesa->ViewportScaleZ); - } - if ( (gmesa->dirty & GAMMA_UPLOAD_POINTMODE) || - (gmesa->dirty & GAMMA_UPLOAD_LINEMODE) || - (gmesa->dirty & GAMMA_UPLOAD_TRIMODE) ) { - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, AntialiasMode, gmesa->AntialiasMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_POINTMODE) { - gmesa->dirty &= ~GAMMA_UPLOAD_POINTMODE; - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PointMode, gmesa->PointMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_LINEMODE) { - gmesa->dirty &= ~GAMMA_UPLOAD_LINEMODE; - CHECK_DMA_BUFFER(gmesa, 2); - WRITE(gmesa->buf, LineMode, gmesa->LineMode); - WRITE(gmesa->buf, LineStippleMode, gmesa->LineMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_TRIMODE) { - gmesa->dirty &= ~GAMMA_UPLOAD_TRIMODE; - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TriangleMode, gmesa->TriangleMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_FOG) { - GLchan c[3], col; - UNCLAMPED_FLOAT_TO_RGB_CHAN( c, gmesa->glCtx->Fog.Color ); - col = gammaPackColor(4, c[0], c[1], c[2], 0); - gmesa->dirty &= ~GAMMA_UPLOAD_FOG; - CHECK_DMA_BUFFER(gmesa, 5); -#if 0 - WRITE(gmesa->buf, FogMode, gmesa->FogMode); - WRITE(gmesa->buf, FogColor, col); - WRITEF(gmesa->buf, FStart, gmesa->glCtx->Fog.Start); -#endif - WRITEF(gmesa->buf, FogEnd, gmesa->glCtx->Fog.End); - WRITEF(gmesa->buf, FogDensity, gmesa->glCtx->Fog.Density); - WRITEF(gmesa->buf, FogScale, - 1.0f/(gmesa->glCtx->Fog.End - gmesa->glCtx->Fog.Start)); - } - if (gmesa->dirty & GAMMA_UPLOAD_DITHER) { - gmesa->dirty &= ~GAMMA_UPLOAD_DITHER; - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, DitherMode, gmesa->DitherMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_LOGICOP) { - gmesa->dirty &= ~GAMMA_UPLOAD_LOGICOP; - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, LogicalOpMode, gmesa->LogicalOpMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_CLIP) { - gmesa->dirty &= ~GAMMA_UPLOAD_CLIP; - CHECK_DMA_BUFFER(gmesa, 3); - WRITE(gmesa->buf, ScissorMinXY, gmesa->ScissorMinXY); - WRITE(gmesa->buf, ScissorMaxXY, gmesa->ScissorMaxXY); - WRITE(gmesa->buf, ScissorMode, gmesa->ScissorMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_MASKS) { - gmesa->dirty &= ~GAMMA_UPLOAD_MASKS; - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, FBHardwareWriteMask, gmesa->FBHardwareWriteMask); - } - if (gmesa->dirty & GAMMA_UPLOAD_ALPHA) { - gmesa->dirty &= ~GAMMA_UPLOAD_ALPHA; - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, AlphaTestMode, gmesa->AlphaTestMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_BLEND) { - gmesa->dirty &= ~GAMMA_UPLOAD_BLEND; - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, AlphaBlendMode, gmesa->AlphaBlendMode); - } - CHECK_DMA_BUFFER(gmesa, 1); - if (gmesa->glCtx->Color.BlendEnabled || gmesa->glCtx->Color.AlphaEnabled) { - WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode | gmesa->AB_FBReadMode_Save); - } else { - WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_LIGHT) { - gmesa->dirty &= ~GAMMA_UPLOAD_LIGHT; - CHECK_DMA_BUFFER(gmesa, 2); - WRITE(gmesa->buf, LightingMode, gmesa->LightingMode); - WRITE(gmesa->buf, MaterialMode, gmesa->MaterialMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_SHADE) { - gmesa->dirty &= ~GAMMA_UPLOAD_SHADE; - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_POLYGON) { - gmesa->dirty &= ~GAMMA_UPLOAD_POLYGON; - CHECK_DMA_BUFFER(gmesa, 2); - WRITEF(gmesa->buf, PolygonOffsetBias, gmesa->glCtx->Polygon.OffsetUnits); - WRITEF(gmesa->buf, PolygonOffsetFactor, gmesa->glCtx->Polygon.OffsetFactor); - } - if (gmesa->dirty & GAMMA_UPLOAD_STIPPLE) { - gmesa->dirty &= ~GAMMA_UPLOAD_STIPPLE; - CHECK_DMA_BUFFER(gmesa, 33); - WRITE(gmesa->buf, AreaStippleMode, gmesa->AreaStippleMode); - WRITE(gmesa->buf, AreaStipplePattern0, gmesa->glCtx->PolygonStipple[0]); - WRITE(gmesa->buf, AreaStipplePattern1, gmesa->glCtx->PolygonStipple[1]); - WRITE(gmesa->buf, AreaStipplePattern2, gmesa->glCtx->PolygonStipple[2]); - WRITE(gmesa->buf, AreaStipplePattern3, gmesa->glCtx->PolygonStipple[3]); - WRITE(gmesa->buf, AreaStipplePattern4, gmesa->glCtx->PolygonStipple[4]); - WRITE(gmesa->buf, AreaStipplePattern5, gmesa->glCtx->PolygonStipple[5]); - WRITE(gmesa->buf, AreaStipplePattern6, gmesa->glCtx->PolygonStipple[6]); - WRITE(gmesa->buf, AreaStipplePattern7, gmesa->glCtx->PolygonStipple[7]); - WRITE(gmesa->buf, AreaStipplePattern8, gmesa->glCtx->PolygonStipple[8]); - WRITE(gmesa->buf, AreaStipplePattern9, gmesa->glCtx->PolygonStipple[9]); - WRITE(gmesa->buf, AreaStipplePattern10, gmesa->glCtx->PolygonStipple[10]); - WRITE(gmesa->buf, AreaStipplePattern11, gmesa->glCtx->PolygonStipple[11]); - WRITE(gmesa->buf, AreaStipplePattern12, gmesa->glCtx->PolygonStipple[12]); - WRITE(gmesa->buf, AreaStipplePattern13, gmesa->glCtx->PolygonStipple[13]); - WRITE(gmesa->buf, AreaStipplePattern14, gmesa->glCtx->PolygonStipple[14]); - WRITE(gmesa->buf, AreaStipplePattern15, gmesa->glCtx->PolygonStipple[15]); - WRITE(gmesa->buf, AreaStipplePattern16, gmesa->glCtx->PolygonStipple[16]); - WRITE(gmesa->buf, AreaStipplePattern17, gmesa->glCtx->PolygonStipple[17]); - WRITE(gmesa->buf, AreaStipplePattern18, gmesa->glCtx->PolygonStipple[18]); - WRITE(gmesa->buf, AreaStipplePattern19, gmesa->glCtx->PolygonStipple[19]); - WRITE(gmesa->buf, AreaStipplePattern20, gmesa->glCtx->PolygonStipple[20]); - WRITE(gmesa->buf, AreaStipplePattern21, gmesa->glCtx->PolygonStipple[21]); - WRITE(gmesa->buf, AreaStipplePattern22, gmesa->glCtx->PolygonStipple[22]); - WRITE(gmesa->buf, AreaStipplePattern23, gmesa->glCtx->PolygonStipple[23]); - WRITE(gmesa->buf, AreaStipplePattern24, gmesa->glCtx->PolygonStipple[24]); - WRITE(gmesa->buf, AreaStipplePattern25, gmesa->glCtx->PolygonStipple[25]); - WRITE(gmesa->buf, AreaStipplePattern26, gmesa->glCtx->PolygonStipple[26]); - WRITE(gmesa->buf, AreaStipplePattern27, gmesa->glCtx->PolygonStipple[27]); - WRITE(gmesa->buf, AreaStipplePattern28, gmesa->glCtx->PolygonStipple[28]); - WRITE(gmesa->buf, AreaStipplePattern29, gmesa->glCtx->PolygonStipple[29]); - WRITE(gmesa->buf, AreaStipplePattern30, gmesa->glCtx->PolygonStipple[30]); - WRITE(gmesa->buf, AreaStipplePattern31, gmesa->glCtx->PolygonStipple[31]); - } - if (gmesa->dirty & GAMMA_UPLOAD_DEPTH) { - gmesa->dirty &= ~GAMMA_UPLOAD_DEPTH; - CHECK_DMA_BUFFER(gmesa, 4); - WRITE(gmesa->buf, DepthMode, gmesa->DepthMode); - WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode); - WRITE(gmesa->buf, GLINTWindow,gmesa->Window | (gmesa->FrameCount << 9)); - WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_GEOMETRY) { - gmesa->dirty &= ~GAMMA_UPLOAD_GEOMETRY; - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_TRANSFORM) { - gmesa->dirty &= ~GAMMA_UPLOAD_TRANSFORM; - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TransformMode, gmesa->TransformMode); - } - if (gmesa->dirty & GAMMA_UPLOAD_TEX0) { - gammaTextureObjectPtr curTex = gmesa->CurrentTexObj[0]; - gmesa->dirty &= ~GAMMA_UPLOAD_TEX0; - if (curTex) { - CHECK_DMA_BUFFER(gmesa, 21); - WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode | GM_TextureEnable); - WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode | DM_TextureEnable); - WRITE(gmesa->buf, TextureAddressMode, curTex->TextureAddressMode); - WRITE(gmesa->buf, TextureReadMode, curTex->TextureReadMode); - WRITE(gmesa->buf, TextureColorMode, curTex->TextureColorMode); - WRITE(gmesa->buf, TextureFilterMode, curTex->TextureFilterMode); - WRITE(gmesa->buf, TextureFormat, curTex->TextureFormat); - WRITE(gmesa->buf, GLINTBorderColor, curTex->TextureBorderColor); - WRITE(gmesa->buf, TxBaseAddr0, curTex->TextureBaseAddr[0]); - WRITE(gmesa->buf, TxBaseAddr1, curTex->TextureBaseAddr[1]); - WRITE(gmesa->buf, TxBaseAddr2, curTex->TextureBaseAddr[2]); - WRITE(gmesa->buf, TxBaseAddr3, curTex->TextureBaseAddr[3]); - WRITE(gmesa->buf, TxBaseAddr4, curTex->TextureBaseAddr[4]); - WRITE(gmesa->buf, TxBaseAddr5, curTex->TextureBaseAddr[5]); - WRITE(gmesa->buf, TxBaseAddr6, curTex->TextureBaseAddr[6]); - WRITE(gmesa->buf, TxBaseAddr7, curTex->TextureBaseAddr[7]); - WRITE(gmesa->buf, TxBaseAddr8, curTex->TextureBaseAddr[8]); - WRITE(gmesa->buf, TxBaseAddr9, curTex->TextureBaseAddr[9]); - WRITE(gmesa->buf, TxBaseAddr10, curTex->TextureBaseAddr[10]); - WRITE(gmesa->buf, TxBaseAddr11, curTex->TextureBaseAddr[11]); - WRITE(gmesa->buf, TextureCacheControl, (TCC_Enable | TCC_Invalidate)); - } else { - CHECK_DMA_BUFFER(gmesa, 6); - WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode); - WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode); - WRITE(gmesa->buf, TextureAddressMode, TextureAddressModeDisable); - WRITE(gmesa->buf, TextureReadMode, TextureReadModeDisable); - WRITE(gmesa->buf, TextureFilterMode, TextureFilterModeDisable); - WRITE(gmesa->buf, TextureColorMode, TextureColorModeDisable); - } - } -#ifdef DO_VALIDATE - PROCESS_DMA_BUFFER_TOP_HALF(gmesa); - - DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock, - gmesa->driScreen->drawLockID); - VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa); - - PROCESS_DMA_BUFFER_BOTTOM_HALF(gmesa); -#endif -} - -void gammaDDUpdateHWState( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - int new_state = gmesa->new_state; - - if ( new_state ) - { - FLUSH_BATCH( gmesa ); - - gmesa->new_state = 0; - - /* Update the various parts of the context's state. - */ - if ( new_state & GAMMA_NEW_ALPHA ) - gammaUpdateAlphaMode( ctx ); - - if ( new_state & GAMMA_NEW_DEPTH ) - gammaUpdateZMode( ctx ); - - if ( new_state & GAMMA_NEW_FOG ) - gammaUpdateFogAttrib( ctx ); - - if ( new_state & GAMMA_NEW_CLIP ) - gammaUpdateClipping( ctx ); - - if ( new_state & GAMMA_NEW_POLYGON ) - gammaUpdatePolygon( ctx ); - - if ( new_state & GAMMA_NEW_CULL ) - gammaUpdateCull( ctx ); - - if ( new_state & GAMMA_NEW_MASKS ) - gammaUpdateMasks( ctx ); - - if ( new_state & GAMMA_NEW_WINDOW ) - gammaUpdateWindow( ctx ); - - if ( new_state & GAMMA_NEW_STIPPLE ) - gammaUpdateStipple( ctx ); - } - - /* HACK ! */ - - gammaEmitHwState( gmesa ); -} - - -static void gammaDDUpdateState( GLcontext *ctx, GLuint new_state ) -{ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - GAMMA_CONTEXT(ctx)->new_gl_state |= new_state; -} - - -/* Initialize the context's hardware state. - */ -void gammaDDInitState( gammaContextPtr gmesa ) -{ - gmesa->new_state = 0; -} - -/* Initialize the driver's state functions. - */ -void gammaDDInitStateFuncs( GLcontext *ctx ) -{ - ctx->Driver.UpdateState = gammaDDUpdateState; - - ctx->Driver.Clear = gammaDDClear; - ctx->Driver.ClearIndex = NULL; - ctx->Driver.ClearColor = gammaDDClearColor; - ctx->Driver.DrawBuffer = gammaDDDrawBuffer; - ctx->Driver.ReadBuffer = gammaDDReadBuffer; - - ctx->Driver.IndexMask = NULL; - ctx->Driver.ColorMask = gammaDDColorMask; - - ctx->Driver.AlphaFunc = gammaDDAlphaFunc; - ctx->Driver.BlendEquationSeparate = gammaDDBlendEquationSeparate; - ctx->Driver.BlendFuncSeparate = gammaDDBlendFuncSeparate; - ctx->Driver.ClearDepth = gammaDDClearDepth; - ctx->Driver.CullFace = gammaDDCullFace; - ctx->Driver.FrontFace = gammaDDFrontFace; - ctx->Driver.DepthFunc = gammaDDDepthFunc; - ctx->Driver.DepthMask = gammaDDDepthMask; - ctx->Driver.DepthRange = gammaDDDepthRange; - ctx->Driver.Enable = gammaDDEnable; - ctx->Driver.Finish = gammaDDFinish; - ctx->Driver.Flush = gammaDDFlush; -#if 0 - ctx->Driver.Fogfv = gammaDDFogfv; -#endif - ctx->Driver.Hint = NULL; - ctx->Driver.LineWidth = gammaDDLineWidth; - ctx->Driver.LineStipple = gammaDDLineStipple; -#if ENABLELIGHTING - ctx->Driver.Lightfv = gammaDDLightfv; - ctx->Driver.LightModelfv = gammaDDLightModelfv; -#endif - ctx->Driver.LogicOpcode = gammaDDLogicalOpcode; - ctx->Driver.PointSize = gammaDDPointSize; - ctx->Driver.PolygonMode = gammaDDPolygonMode; - ctx->Driver.PolygonStipple = gammaDDPolygonStipple; - ctx->Driver.Scissor = gammaDDScissor; - ctx->Driver.ShadeModel = gammaDDShadeModel; - ctx->Driver.Viewport = gammaDDViewport; -} diff --git a/src/mesa/drivers/dri/gamma/gamma_tex.c b/src/mesa/drivers/dri/gamma/gamma_tex.c deleted file mode 100644 index bef8cf27dbc..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_tex.c +++ /dev/null @@ -1,434 +0,0 @@ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/colormac.h" -#include "main/imports.h" -#include "main/simple_list.h" -#include "main/enums.h" -#include "main/mm.h" -#include "main/texstore.h" -#include "main/teximage.h" -#include "main/texobj.h" - -#include "swrast/swrast.h" - -#include "gamma_context.h" - - -/* - * Compute the 'S2.4' lod bias factor from the floating point OpenGL bias. - */ -#if 0 -static GLuint gammaComputeLodBias(GLfloat bias) -{ - return bias; -} -#endif - -static void gammaSetTexWrapping(gammaTextureObjectPtr t, - GLenum wraps, GLenum wrapt) -{ - uint32_t t1 = t->TextureAddressMode; - uint32_t t2 = t->TextureReadMode; - - t1 &= ~(TAM_SWrap_Mask | TAM_TWrap_Mask); - t2 &= ~(TRM_UWrap_Mask | TRM_VWrap_Mask); - - if (wraps != GL_CLAMP) { - t1 |= TAM_SWrap_Repeat; - t2 |= TRM_UWrap_Repeat; - } - - if (wrapt != GL_CLAMP) { - t1 |= TAM_TWrap_Repeat; - t2 |= TRM_VWrap_Repeat; - } - - t->TextureAddressMode = t1; - t->TextureReadMode = t2; -} - - -static void gammaSetTexFilter(gammaContextPtr gmesa, - gammaTextureObjectPtr t, - GLenum minf, GLenum magf, - GLfloat bias) -{ - uint32_t t1 = t->TextureAddressMode; - uint32_t t2 = t->TextureReadMode; - - t2 &= ~(TRM_Mag_Mask | TRM_Min_Mask); - - switch (minf) { - case GL_NEAREST: - t1 &= ~TAM_LODEnable; - t2 &= ~TRM_MipMapEnable; - t2 |= TRM_Min_Nearest; - break; - case GL_LINEAR: - t1 &= ~TAM_LODEnable; - t2 &= ~TRM_MipMapEnable; - t2 |= TRM_Min_Linear; - break; - case GL_NEAREST_MIPMAP_NEAREST: - t2 |= TRM_Min_NearestMMNearest; - break; - case GL_LINEAR_MIPMAP_NEAREST: - t2 |= TRM_Min_LinearMMNearest; - break; - case GL_NEAREST_MIPMAP_LINEAR: - t2 |= TRM_Min_NearestMMLinear; - break; - case GL_LINEAR_MIPMAP_LINEAR: - t2 |= TRM_Min_LinearMMLinear; - break; - default: - break; - } - - switch (magf) { - case GL_NEAREST: - t2 |= TRM_Mag_Nearest; - break; - case GL_LINEAR: - t2 |= TRM_Mag_Linear; - break; - default: - break; - } - - t->TextureAddressMode = t1; - t->TextureReadMode = t2; -} - - -static void gammaSetTexBorderColor(gammaContextPtr gmesa, - gammaTextureObjectPtr t, - const GLfloat color[4]) -{ - GLubyte c[4]; - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - t->TextureBorderColor = PACK_COLOR_8888(c[0], c[1], c[2], c[3]); -} - - -static void gammaTexParameter( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj, - GLenum pname, const GLfloat *params ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData; - if (!t) - return; - - /* Can't do the update now as we don't know whether to flush - * vertices or not. Setting gmesa->new_state means that - * gammaUpdateTextureState() will be called before any triangles are - * rendered. If a statechange has occurred, it will be detected at - * that point, and buffered vertices flushed. - */ - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - { - GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias; - gammaSetTexFilter( gmesa, t, tObj->MinFilter, tObj->MagFilter, bias ); - } - break; - - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - gammaSetTexWrapping( t, tObj->WrapS, tObj->WrapT ); - break; - - case GL_TEXTURE_BORDER_COLOR: - gammaSetTexBorderColor( gmesa, t, tObj->BorderColor.f ); - break; - - case GL_TEXTURE_BASE_LEVEL: - case GL_TEXTURE_MAX_LEVEL: - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - /* This isn't the most efficient solution but there doesn't appear to - * be a nice alternative for Radeon. Since there's no LOD clamping, - * we just have to rely on loading the right subset of mipmap levels - * to simulate a clamped LOD. - */ - gammaSwapOutTexObj( gmesa, t ); - break; - - default: - return; - } - - if (t == gmesa->CurrentTexObj[0]) - gmesa->dirty |= GAMMA_UPLOAD_TEX0; - -#if 0 - if (t == gmesa->CurrentTexObj[1]) { - gmesa->dirty |= GAMMA_UPLOAD_TEX1; - } -#endif -} - - -static void gammaTexEnv( GLcontext *ctx, GLenum target, - GLenum pname, const GLfloat *param ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT( ctx ); - GLuint unit = ctx->Texture.CurrentUnit; - - /* Only one env color. Need a fallback if env colors are different - * and texture setup references env color in both units. - */ - switch (pname) { - case GL_TEXTURE_ENV_COLOR: { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLfloat *fc = texUnit->EnvColor; - GLuint r, g, b, a, col; - CLAMPED_FLOAT_TO_UBYTE(r, fc[0]); - CLAMPED_FLOAT_TO_UBYTE(g, fc[1]); - CLAMPED_FLOAT_TO_UBYTE(b, fc[2]); - CLAMPED_FLOAT_TO_UBYTE(a, fc[3]); - - col = ((a << 24) | - (r << 16) | - (g << 8) | - (b << 0)); - - break; - } - case GL_TEXTURE_ENV_MODE: - gmesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */ - break; - - case GL_TEXTURE_LOD_BIAS_EXT: -#if 0 /* ?!?!?! */ - { - struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current; - gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData; - (void) t; - /* XXX Looks like there's something missing here */ - } -#endif - break; - - default: - break; - } -} - -#if 0 -static void gammaTexImage1D( GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *pack, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData; - if (t) { - gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t ); - } - _mesa_store_teximage1d( ctx, target, level, internalFormat, - width, border, format, type, - pixels, pack, texObj, texImage ); -} -#endif - -#if 0 -static void gammaTexSubImage1D( GLcontext *ctx, - GLenum target, - GLint level, - GLint xoffset, - GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *pack, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData; - if (t) { - gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t ); - } - _mesa_store_texsubimage1d(ctx, target, level, xoffset, width, - format, type, pixels, pack, texObj, - texImage); -} -#endif - -static void gammaTexImage2D( GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData; - if (t) { - gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t ); - } - _mesa_store_teximage2d( ctx, target, level, internalFormat, - width, height, border, format, type, - pixels, packing, texObj, texImage ); -} - -static void gammaTexSubImage2D( GLcontext *ctx, - GLenum target, - GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData; - if (t) { - gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t ); - } - _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, - height, format, type, pixels, packing, texObj, - texImage); -} - -static void gammaBindTexture( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT( ctx ); - gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData; - - if (!t) { - GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias; - t = CALLOC_STRUCT(gamma_texture_object_t); - - /* Initialize non-image-dependent parts of the state: - */ - t->globj = tObj; - - t->TextureAddressMode = TextureAddressModeEnable | TAM_Operation_3D | - TAM_DY_Enable | TAM_LODEnable; - t->TextureReadMode = TextureReadModeEnable | TRM_PrimaryCacheEnable | - TRM_MipMapEnable | TRM_BorderClamp | TRM_Border; - t->TextureColorMode = TextureColorModeEnable; - t->TextureFilterMode = TextureFilterModeEnable; - - if (target == GL_TEXTURE_2D) { - t->TextureAddressMode |= TAM_TexMapType_2D; - t->TextureReadMode |= TRM_TexMapType_2D; - } - else if (target == GL_TEXTURE_1D) { - t->TextureAddressMode |= TAM_TexMapType_1D; - t->TextureReadMode |= TRM_TexMapType_1D; - } - - t->TextureColorMode = TextureColorModeEnable; - - t->TextureFilterMode = TextureFilterModeEnable; - -#ifdef MESA_LITTLE_ENDIAN - t->TextureFormat = (TF_LittleEndian | -#else - t->TextureFormat = (TF_BigEndian | -#endif - TF_ColorOrder_RGB | - TF_OutputFmt_Texel); - - t->dirty_images = ~0; - - tObj->DriverData = t; - make_empty_list( t ); - - gammaSetTexWrapping( t, tObj->WrapS, tObj->WrapT ); - gammaSetTexFilter( gmesa, t, tObj->MinFilter, tObj->MagFilter, bias ); - gammaSetTexBorderColor( gmesa, t, tObj->BorderColor.f ); - } -} - -static void gammaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) -{ - gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData; - - if (t) { - gammaContextPtr gmesa = GAMMA_CONTEXT( ctx ); -#if 0 - if (gmesa) - GAMMA_FIREVERTICES( gmesa ); -#endif - gammaDestroyTexObj( gmesa, t ); - tObj->DriverData = 0; - } - /* Free mipmap images and the texture object itself */ - _mesa_delete_texture_object(ctx, tObj); -} - -static GLboolean gammaIsTextureResident( GLcontext *ctx, - struct gl_texture_object *tObj ) -{ - gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData; - return t && t->MemBlock; -} - -#ifdef UNUSED -/** - * Allocate a new texture object. - * Called via ctx->Driver.NewTextureObject. - * Note: this function will be called during context creation to - * allocate the default texture objects. - * Note: we could use containment here to 'derive' the driver-specific - * texture object from the core mesa gl_texture_object. Not done at this time. - */ -static struct gl_texture_object * -gammaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - obj = _mesa_new_texture_object(ctx, name, target); - return obj; -} -#endif - -void gammaInitTextureObjects( GLcontext *ctx ) -{ - struct gl_texture_object *texObj; - GLuint tmp = ctx->Texture.CurrentUnit; - - ctx->Texture.CurrentUnit = 0; - - texObj = ctx->Texture.Unit[0].CurrentTex[TEXTURE_1D_INDEX]; - gammaBindTexture( ctx, GL_TEXTURE_1D, texObj ); - - texObj = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; - gammaBindTexture( ctx, GL_TEXTURE_2D, texObj ); - -#if 0 - ctx->Texture.CurrentUnit = 1; - - texObj = ctx->Texture.Unit[1].CurrentTex[TEXTURE_1D_INDEX]; - gammaBindTexture( ctx, GL_TEXTURE_1D, texObj ); - - texObj = ctx->Texture.Unit[1].CurrentTex[TEXTURE_2D_INDEX]; - gammaBindTexture( ctx, GL_TEXTURE_2D, texObj ); -#endif - - ctx->Texture.CurrentUnit = tmp; -} - - -void gammaDDInitTextureFuncs( struct dd_function_table *functions ) -{ - functions->TexEnv = gammaTexEnv; - functions->TexImage2D = gammaTexImage2D; - functions->TexSubImage2D = gammaTexSubImage2D; - functions->BindTexture = gammaBindTexture; - functions->DeleteTexture = gammaDeleteTexture; - functions->TexParameter = gammaTexParameter; - functions->IsTextureResident = gammaIsTextureResident; -} diff --git a/src/mesa/drivers/dri/gamma/gamma_texmem.c b/src/mesa/drivers/dri/gamma/gamma_texmem.c deleted file mode 100644 index 45a0c0148e3..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_texmem.c +++ /dev/null @@ -1,535 +0,0 @@ - -#include -#include - -#include "main/glheader.h" -#include "main/colormac.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/simple_list.h" -#include "main/enums.h" - -#include "main/mm.h" -#include "glint_dri.h" -#include "gamma_context.h" -#include "gamma_lock.h" -#include "gamma_macros.h" - -void gammaDestroyTexObj(gammaContextPtr gmesa, gammaTextureObjectPtr t) -{ - if (!t) return; - - /* This is sad - need to sync *in case* we upload a texture - * to this newly free memory... - */ - if (t->MemBlock) { - mmFreeMem(t->MemBlock); - t->MemBlock = 0; - - if (gmesa && t->age > gmesa->dirtyAge) - gmesa->dirtyAge = t->age; - } - - if (t->globj) - t->globj->DriverData = 0; - - if (gmesa) { - if (gmesa->CurrentTexObj[0] == t) { - gmesa->CurrentTexObj[0] = 0; - gmesa->dirty &= ~GAMMA_UPLOAD_TEX0; - } - -#if 0 - if (gmesa->CurrentTexObj[1] == t) { - gmesa->CurrentTexObj[1] = 0; - gmesa->dirty &= ~GAMMA_UPLOAD_TEX1; - } -#endif - } - - remove_from_list(t); - free(t); -} - - -void gammaSwapOutTexObj(gammaContextPtr gmesa, gammaTextureObjectPtr t) -{ -/* fprintf(stderr, "%s\n", __FUNCTION__); */ - - if (t->MemBlock) { - mmFreeMem(t->MemBlock); - t->MemBlock = 0; - - if (t->age > gmesa->dirtyAge) - gmesa->dirtyAge = t->age; - } - - t->dirty_images = ~0; - move_to_tail(&(gmesa->SwappedOut), t); -} - - - -/* Upload an image from mesa's internal copy. - */ -static void gammaUploadTexLevel( gammaContextPtr gmesa, gammaTextureObjectPtr t, int level ) -{ - const struct gl_texture_image *image = t->image[level].image; - int i,j; - int l2d; -#if 0 - int offset = 0; -#endif - int words, depthLog2; - - /* fprintf(stderr, "%s\n", __FUNCTION__); */ - - l2d = 5; /* 32bits per texel == 1<<5 */ - - if (level == 0) { - t->TextureAddressMode &= ~(TAM_WidthMask | TAM_HeightMask); - t->TextureAddressMode |= (image->WidthLog2 << 9) | - (image->HeightLog2 << 13); - t->TextureReadMode &= ~(TRM_WidthMask | TRM_HeightMask | - TRM_DepthMask | TRM_Border | - TRM_Patch); - t->TextureReadMode |= (image->WidthLog2 << 1) | - (image->HeightLog2 << 5) | - (l2d << 9); - t->TextureFormat &= ~(TF_CompnentsMask | TF_OneCompFmt_Mask); - } - - t->TextureBaseAddr[level] = /* ??? */ - (unsigned long)(t->image[level].offset + t->BufAddr) << 5; - - CALC_LOG2(depthLog2, 1<Width * image->Height) >> (5-depthLog2); - - CHECK_DMA_BUFFER(gmesa, 3); - WRITE(gmesa->buf, LBWindowBase, t->TextureBaseAddr[level] >> 5); - WRITE(gmesa->buf, TextureCacheControl, (TCC_Enable | TCC_Invalidate)); - WRITE(gmesa->buf, WaitForCompletion, 0); - FLUSH_DMA_BUFFER(gmesa); - - switch (t->image[level].internalFormat) { - case GL_RGB: - case 3: - { - GLubyte *src = (GLubyte *)image->Data; - - if (level == 0) - t->TextureFormat |= TF_Compnents_3; - -#if 0 /* This is the texture download code we SHOULD be using */ - /* In the routines below, but this causes an DMA overrun - WHY ? */ - while (offset < words) { - int count = gmesa->bufSize; - int i; - count -= 3; - if (count > words-offset) count = words-offset; - - gmesa->buf->i = GlintTextureDownloadOffsetTag; - gmesa->buf++; - gmesa->buf->i = offset; - gmesa->buf++; - gmesa->buf->i = (GlintTextureDataTag | ((count-1) << 16)); - gmesa->buf++; - - for (i = 0; i < count; i++) { - gmesa->buf->i = PACK_COLOR_565(src[0],src[1],src[2]); - gmesa->buf++; - src += 3; - } - - gmesa->bufCount = count+3; /* texture data + 3 values */ - offset += count; - - FLUSH_DMA_BUFFER(gmesa); - } -#else - /* The UGLY way, and SLOW !, but the above sometimes causes - * a DMA overrun error ??? FIXME ! */ - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TextureDownloadOffset, 0); - for (i = 0; i < words; i++) { - unsigned int data; - data = PACK_COLOR_565(src[0],src[1],src[2]); - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TextureData, data); - src += 3; - } - FLUSH_DMA_BUFFER(gmesa); -#endif - } - break; - - case GL_RGBA: - case 4: - { - GLubyte *src = (GLubyte *)image->Data; - - if (level == 0) - t->TextureFormat |= TF_Compnents_4; - - /* The UGLY way, and SLOW !, but the above sometimes causes - * a DMA overrun error ??? FIXME ! */ - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TextureDownloadOffset, 0); - for (i = 0; i < words; i++) { - unsigned int data; - data = PACK_COLOR_8888(src[0],src[1],src[2],src[3]); - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TextureData, data); - src += 4; - } - FLUSH_DMA_BUFFER(gmesa); - } - break; - - case GL_LUMINANCE: - { - GLubyte *src = (GLubyte *)image->Data; - - if (level == 0) - t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Lum; - - /* The UGLY way, and SLOW !, but the above sometimes causes - * a DMA overrun error ??? FIXME ! */ - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TextureDownloadOffset, 0); - for (i = 0; i < words; i++) { - unsigned int data; - data = PACK_COLOR_888(src[0],src[0],src[0]); - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TextureData, data); - src ++; - } - FLUSH_DMA_BUFFER(gmesa); - } - break; - - case GL_INTENSITY: - { - GLubyte *src = (GLubyte *)image->Data; - - if (level == 0) - t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Intensity; - - /* The UGLY way, and SLOW !, but the above sometimes causes - * a DMA overrun error ??? FIXME ! */ - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TextureDownloadOffset, 0); - for (i = 0; i < words; i++) { - unsigned int data; - data = PACK_COLOR_8888(src[0],src[0],src[0],src[0]); - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TextureData, data); - src ++; - } - FLUSH_DMA_BUFFER(gmesa); - } - break; - - case GL_LUMINANCE_ALPHA: - { - GLubyte *src = (GLubyte *)image->Data; - - if (level == 0) - t->TextureFormat |= TF_Compnents_2; - - /* The UGLY way, and SLOW !, but the above sometimes causes - * a DMA overrun error ??? FIXME ! */ - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TextureDownloadOffset, 0); - for (i = 0; i < words; i++) { - unsigned int data; - data = PACK_COLOR_8888(src[0],src[0],src[0],src[1]); - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TextureData, data); - src += 2; - } - FLUSH_DMA_BUFFER(gmesa); - } - break; - - case GL_ALPHA: - { - GLubyte *src = (GLubyte *)image->Data; - - if (level == 0) - t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Alpha; - - /* The UGLY way, and SLOW !, but the above sometimes causes - * a DMA overrun error ??? FIXME ! */ - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TextureDownloadOffset, 0); - for (i = 0; i < words; i++) { - unsigned int data; - data = PACK_COLOR_8888(255,255,255,src[0]); - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, TextureData, data); - src += 1; - } - FLUSH_DMA_BUFFER(gmesa); - } - break; - - /* TODO: Translate color indices *now*: - */ - case GL_COLOR_INDEX: - { - GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset); - GLubyte *src = (GLubyte *)image->Data; - - for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) { - for (i = 0 ; i < image->Width ; i++) { - dst[i] = src[0]; - src += 1; - } - } - } - break; - - default: - fprintf(stderr, "Not supported texture format %s\n", - _mesa_lookup_enum_by_nr(image->Format)); - } - - CHECK_DMA_BUFFER(gmesa, 2); - WRITE(gmesa->buf, WaitForCompletion, 0); - WRITE(gmesa->buf, LBWindowBase, gmesa->LBWindowBase); -} - -void gammaPrintLocalLRU( gammaContextPtr gmesa ) -{ - gammaTextureObjectPtr t; - int sz = 1 << (gmesa->gammaScreen->logTextureGranularity); - - foreach( t, &gmesa->TexObjList ) { - if (!t->globj) - fprintf(stderr, "Placeholder %d at %x sz %x\n", - t->MemBlock->ofs / sz, - t->MemBlock->ofs, - t->MemBlock->size); - else - fprintf(stderr, "Texture at %x sz %x\n", - t->MemBlock->ofs, - t->MemBlock->size); - - } -} - -void gammaPrintGlobalLRU( gammaContextPtr gmesa ) -{ - int i, j; - GAMMATextureRegionPtr list = gmesa->sarea->texList; - - for (i = 0, j = GAMMA_NR_TEX_REGIONS ; i < GAMMA_NR_TEX_REGIONS ; i++) { - fprintf(stderr, "list[%d] age %d next %d prev %d\n", - j, list[j].age, list[j].next, list[j].prev); - j = list[j].next; - if (j == GAMMA_NR_TEX_REGIONS) break; - } - - if (j != GAMMA_NR_TEX_REGIONS) - fprintf(stderr, "Loop detected in global LRU\n"); -} - - -void gammaResetGlobalLRU( gammaContextPtr gmesa ) -{ - GAMMATextureRegionPtr list = gmesa->sarea->texList; - int sz = 1 << gmesa->gammaScreen->logTextureGranularity; - int i; - - /* (Re)initialize the global circular LRU list. The last element - * in the array (GAMMA_NR_TEX_REGIONS) is the sentinal. Keeping it - * at the end of the array allows it to be addressed rationally - * when looking up objects at a particular location in texture - * memory. - */ - for (i = 0 ; (i+1) * sz <= gmesa->gammaScreen->textureSize ; i++) { - list[i].prev = i-1; - list[i].next = i+1; - list[i].age = 0; - } - - i--; - list[0].prev = GAMMA_NR_TEX_REGIONS; - list[i].prev = i-1; - list[i].next = GAMMA_NR_TEX_REGIONS; - list[GAMMA_NR_TEX_REGIONS].prev = i; - list[GAMMA_NR_TEX_REGIONS].next = 0; - gmesa->sarea->texAge = 0; -} - - -void gammaUpdateTexLRU( gammaContextPtr gmesa, gammaTextureObjectPtr t ) -{ - int i; - int logsz = gmesa->gammaScreen->logTextureGranularity; - int start = t->MemBlock->ofs >> logsz; - int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz; - GAMMATextureRegionPtr list = gmesa->sarea->texList; - - gmesa->texAge = ++gmesa->sarea->texAge; - - /* Update our local LRU - */ - move_to_head( &(gmesa->TexObjList), t ); - - /* Update the global LRU - */ - for (i = start ; i <= end ; i++) { - - list[i].in_use = 1; - list[i].age = gmesa->texAge; - - /* remove_from_list(i) - */ - list[(unsigned)list[i].next].prev = list[i].prev; - list[(unsigned)list[i].prev].next = list[i].next; - - /* insert_at_head(list, i) - */ - list[i].prev = GAMMA_NR_TEX_REGIONS; - list[i].next = list[GAMMA_NR_TEX_REGIONS].next; - list[(unsigned)list[GAMMA_NR_TEX_REGIONS].next].prev = i; - list[GAMMA_NR_TEX_REGIONS].next = i; - } -} - - -/* Called for every shared texture region which has increased in age - * since we last held the lock. - * - * Figures out which of our textures have been ejected by other clients, - * and pushes a placeholder texture onto the LRU list to represent - * the other client's textures. - */ -void gammaTexturesGone( gammaContextPtr gmesa, - GLuint offset, - GLuint size, - GLuint in_use ) -{ - gammaTextureObjectPtr t, tmp; - - foreach_s ( t, tmp, &gmesa->TexObjList ) { - - if (t->MemBlock->ofs >= offset + size || - t->MemBlock->ofs + t->MemBlock->size <= offset) - continue; - - /* It overlaps - kick it off. Need to hold onto the currently bound - * objects, however. - */ - gammaSwapOutTexObj( gmesa, t ); - } - - if (in_use) { - t = (gammaTextureObjectPtr) calloc(1,sizeof(*t)); - if (!t) return; - - t->MemBlock = mmAllocMem( gmesa->texHeap, size, 0, offset); - insert_at_head( &gmesa->TexObjList, t ); - } - - /* Reload any lost textures referenced by current vertex buffer. - */ -#if 0 - if (gmesa->vertex_buffer) { - int i, j; - - fprintf(stderr, "\n\nreload tex\n"); - - for (i = 0 ; i < gmesa->statenr ; i++) { - for (j = 0 ; j < 2 ; j++) { - gammaTextureObjectPtr t = gmesa->state_tex[j][i]; - if (t) { - if (t->MemBlock == 0) - gammaUploadTexImages( gmesa, t ); - } - } - } - - /* Hard to do this with the lock held: - */ -/* GAMMA_FIREVERTICES( gmesa ); */ - } -#endif -} - - - - - -/* This is called with the lock held. May have to eject our own and/or - * other client's texture objects to make room for the upload. - */ -void gammaUploadTexImages( gammaContextPtr gmesa, gammaTextureObjectPtr t ) -{ - int i; - int ofs; - int numLevels; - - /* /fprintf(stderr, "%s\n", __FUNCTION__); */ -#if 0 - LOCK_HARDWARE( gmesa ); -#endif - - /* Do we need to eject LRU texture objects? - */ - if (!t->MemBlock) { - while (1) - { - t->MemBlock = mmAllocMem( gmesa->texHeap, t->totalSize, 12, 0 ); - if (t->MemBlock) - break; - - if (gmesa->TexObjList.prev == gmesa->CurrentTexObj[0] || - gmesa->TexObjList.prev == gmesa->CurrentTexObj[1]) { - fprintf(stderr, "Hit bound texture in upload\n"); - gammaPrintLocalLRU( gmesa ); - return; - } - - if (gmesa->TexObjList.prev == &(gmesa->TexObjList)) { - fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize); - mmDumpMemInfo( gmesa->texHeap ); - return; - } - - gammaSwapOutTexObj( gmesa, gmesa->TexObjList.prev ); - } - - ofs = t->MemBlock->ofs; - t->BufAddr = (char *)(unsigned long)(gmesa->LBWindowBase + ofs); /* ??? */ - - if (t == gmesa->CurrentTexObj[0]) - gmesa->dirty |= GAMMA_UPLOAD_TEX0; - -#if 0 - if (t == gmesa->CurrentTexObj[1]) - gmesa->dirty |= GAMMA_UPLOAD_TEX1; -#endif - - gammaUpdateTexLRU( gmesa, t ); - } - -#if 0 - if (gmesa->dirtyAge >= GET_DISPATCH_AGE(gmesa)) - gammaWaitAgeLocked( gmesa, gmesa->dirtyAge ); -#endif - - numLevels = t->lastLevel - t->firstLevel + 1; - for (i = 0 ; i < numLevels ; i++) - if (t->dirty_images & (1<dirty_images = 0; - -#if 0 - UNLOCK_HARDWARE( gmesa ); -#endif -} diff --git a/src/mesa/drivers/dri/gamma/gamma_texstate.c b/src/mesa/drivers/dri/gamma/gamma_texstate.c deleted file mode 100644 index 46f39135dc6..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_texstate.c +++ /dev/null @@ -1,215 +0,0 @@ - -#include -#include - -#include "main/glheader.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/simple_list.h" -#include "main/enums.h" - -#include "main/mm.h" -#include "gamma_context.h" - -static void gammaSetTexImages( gammaContextPtr gmesa, - struct gl_texture_object *tObj ) -{ - GLuint height, width, pitch, i, log_pitch; - gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData; - const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel]; - GLint firstLevel, lastLevel, numLevels; - GLint log2Width, log2Height; - - /* fprintf(stderr, "%s\n", __FUNCTION__); */ - - t->texelBytes = 2; - - /* Compute which mipmap levels we really want to send to the hardware. - * This depends on the base image size, GL_TEXTURE_MIN_LOD, - * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL. - * Yes, this looks overly complicated, but it's all needed. - */ - if (tObj->MinFilter == GL_LINEAR || tObj->MinFilter == GL_NEAREST) { - firstLevel = lastLevel = tObj->BaseLevel; - } - else { - firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5); - firstLevel = MAX2(firstLevel, tObj->BaseLevel); - lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5); - lastLevel = MAX2(lastLevel, tObj->BaseLevel); - lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2); - lastLevel = MIN2(lastLevel, tObj->MaxLevel); - lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */ - } - - /* save these values */ - t->firstLevel = firstLevel; - t->lastLevel = lastLevel; - - numLevels = lastLevel - firstLevel + 1; - - log2Width = tObj->Image[0][firstLevel]->WidthLog2; - log2Height = tObj->Image[0][firstLevel]->HeightLog2; - - - /* Figure out the amount of memory required to hold all the mipmap - * levels. Choose the smallest pitch to accomodate the largest - * mipmap: - */ - width = tObj->Image[0][firstLevel]->Width * t->texelBytes; - for (pitch = 32, log_pitch=2 ; pitch < width ; pitch *= 2 ) - log_pitch++; - - /* All images must be loaded at this pitch. Count the number of - * lines required: - */ - for ( height = i = 0 ; i < numLevels ; i++ ) { - t->image[i].image = tObj->Image[0][firstLevel + i]; - t->image[i].offset = height * pitch; - t->image[i].internalFormat = baseImage->Format; - height += t->image[i].image->Height; - t->TextureBaseAddr[i] = /* ??? */ - (unsigned long)(t->image[i].offset + t->BufAddr) << 5; - - } - - t->Pitch = pitch; - t->totalSize = height*pitch; - t->max_level = i-1; - gmesa->dirty |= GAMMA_UPLOAD_TEX0 /* | GAMMA_UPLOAD_TEX1*/; - - gammaUploadTexImages( gmesa, t ); -} - -static void gammaUpdateTexEnv( GLcontext *ctx, GLuint unit ) -{ - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - const struct gl_texture_object *tObj = texUnit->_Current; - const GLuint format = tObj->Image[0][tObj->BaseLevel]->Format; - gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData; - GLuint tc; - - /* fprintf(stderr, "%s\n", __FUNCTION__); */ - - tc = t->TextureColorMode & ~(TCM_BaseFormatMask | TCM_ApplicationMask); - - switch (format) { - case GL_RGB: - tc |= TCM_BaseFormat_RGB; - break; - case GL_LUMINANCE: - tc |= TCM_BaseFormat_Lum; - break; - case GL_ALPHA: - tc |= TCM_BaseFormat_Alpha; - break; - case GL_LUMINANCE_ALPHA: - tc |= TCM_BaseFormat_LumAlpha; - break; - case GL_INTENSITY: - tc |= TCM_BaseFormat_Intensity; - break; - case GL_RGBA: - tc |= TCM_BaseFormat_RGBA; - break; - case GL_COLOR_INDEX: - break; - } - - switch (texUnit->EnvMode) { - case GL_REPLACE: - tc |= TCM_Replace; - break; - case GL_MODULATE: - tc |= TCM_Modulate; - break; - case GL_ADD: - /* do nothing ???*/ - break; - case GL_DECAL: - tc |= TCM_Decal; - break; - case GL_BLEND: - tc |= TCM_Blend; - break; - default: - fprintf(stderr, "unknown tex env mode"); - return; - } - - t->TextureColorMode = tc; -} - - - - -static void gammaUpdateTexUnit( GLcontext *ctx, GLuint unit ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - - /* fprintf(stderr, "%s\n", __FUNCTION__); */ - - if (texUnit->_ReallyEnabled == TEXTURE_2D_BIT) - { - struct gl_texture_object *tObj = texUnit->_Current; - gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData; - - /* Upload teximages (not pipelined) - */ - if (t->dirty_images) { - gammaSetTexImages( gmesa, tObj ); - if (!t->MemBlock) { - FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE ); - return; - } - } - -#if 0 - if (tObj->Image[0][tObj->BaseLevel]->Border > 0) { - FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE ); - return; - } -#endif - - /* Update state if this is a different texture object to last - * time. - */ - if (gmesa->CurrentTexObj[unit] != t) { - gmesa->dirty |= GAMMA_UPLOAD_TEX0 /* << unit */; - gmesa->CurrentTexObj[unit] = t; - gammaUpdateTexLRU( gmesa, t ); /* done too often */ - } - - /* Update texture environment if texture object image format or - * texture environment state has changed. - */ - if (tObj->Image[0][tObj->BaseLevel]->Format != gmesa->TexEnvImageFmt[unit]) { - gmesa->TexEnvImageFmt[unit] = tObj->Image[0][tObj->BaseLevel]->Format; - gammaUpdateTexEnv( ctx, unit ); - } - } - else if (texUnit->_ReallyEnabled) { - FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE ); - } - else /*if (gmesa->CurrentTexObj[unit])*/ { - gmesa->CurrentTexObj[unit] = 0; - gmesa->TexEnvImageFmt[unit] = 0; - gmesa->dirty &= ~(GAMMA_UPLOAD_TEX0< - * Keith Whitwell, - * - * 3DLabs Gamma driver. - */ - -#include "gamma_context.h" -#include "gamma_macros.h" -#include "gamma_vb.h" -#include "gamma_tris.h" - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/colormac.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" - - -/*********************************************************************** - * Build hardware rasterization functions * - ***********************************************************************/ - -#define GAMMA_RAST_ALPHA_BIT 0x01 -#define GAMMA_RAST_TEX_BIT 0x02 -#define GAMMA_RAST_FLAT_BIT 0x04 - -static gamma_point_func gamma_point_tab[0x8]; -static gamma_line_func gamma_line_tab[0x8]; -static gamma_tri_func gamma_tri_tab[0x8]; -static gamma_quad_func gamma_quad_tab[0x8]; - -#define IND (0) -#define TAG(x) x -#include "gamma_tritmp.h" - -#define IND (GAMMA_RAST_ALPHA_BIT) -#define TAG(x) x##_alpha -#include "gamma_tritmp.h" - -#define IND (GAMMA_RAST_TEX_BIT) -#define TAG(x) x##_tex -#include "gamma_tritmp.h" - -#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_TEX_BIT) -#define TAG(x) x##_alpha_tex -#include "gamma_tritmp.h" - -#define IND (GAMMA_RAST_FLAT_BIT) -#define TAG(x) x##_flat -#include "gamma_tritmp.h" - -#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_FLAT_BIT) -#define TAG(x) x##_alpha_flat -#include "gamma_tritmp.h" - -#define IND (GAMMA_RAST_TEX_BIT|GAMMA_RAST_FLAT_BIT) -#define TAG(x) x##_tex_flat -#include "gamma_tritmp.h" - -#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_TEX_BIT|GAMMA_RAST_FLAT_BIT) -#define TAG(x) x##_alpha_tex_flat -#include "gamma_tritmp.h" - - -static void init_rast_tab( void ) -{ - gamma_init(); - gamma_init_alpha(); - gamma_init_tex(); - gamma_init_alpha_tex(); - gamma_init_flat(); - gamma_init_alpha_flat(); - gamma_init_tex_flat(); - gamma_init_alpha_tex_flat(); -} - -/*********************************************************************** - * Rasterization fallback helpers * - ***********************************************************************/ - - -/* This code is hit only when a mix of accelerated and unaccelerated - * primitives are being drawn, and only for the unaccelerated - * primitives. - */ -static void -gamma_fallback_quad( gammaContextPtr gmesa, - const gammaVertex *v0, - const gammaVertex *v1, - const gammaVertex *v2, - const gammaVertex *v3 ) -{ - GLcontext *ctx = gmesa->glCtx; - SWvertex v[4]; - gamma_translate_vertex( ctx, v0, &v[0] ); - gamma_translate_vertex( ctx, v1, &v[1] ); - gamma_translate_vertex( ctx, v2, &v[2] ); - gamma_translate_vertex( ctx, v3, &v[3] ); - _swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] ); -} - -static void -gamma_fallback_tri( gammaContextPtr gmesa, - const gammaVertex *v0, - const gammaVertex *v1, - const gammaVertex *v2 ) -{ - GLcontext *ctx = gmesa->glCtx; - SWvertex v[3]; - gamma_translate_vertex( ctx, v0, &v[0] ); - gamma_translate_vertex( ctx, v1, &v[1] ); - gamma_translate_vertex( ctx, v2, &v[2] ); - _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); -} - -static void -gamma_fallback_line( gammaContextPtr gmesa, - const gammaVertex *v0, - const gammaVertex *v1 ) -{ - GLcontext *ctx = gmesa->glCtx; - SWvertex v[2]; - gamma_translate_vertex( ctx, v0, &v[0] ); - gamma_translate_vertex( ctx, v1, &v[1] ); - _swrast_Line( ctx, &v[0], &v[1] ); -} - - -#if 0 -static void -gamma_fallback_point( gammaContextPtr gmesa, - const gammaVertex *v0 ) -{ - GLcontext *ctx = gmesa->glCtx; - SWvertex v[1]; - gamma_translate_vertex( ctx, v0, &v[0] ); - _swrast_Point( ctx, &v[0] ); -} -#endif - - -/*********************************************************************** - * Choose rasterization functions * - ***********************************************************************/ - -#define _GAMMA_NEW_RASTER_STATE (_NEW_FOG | \ - _NEW_TEXTURE | \ - _DD_NEW_TRI_SMOOTH | \ - _DD_NEW_LINE_SMOOTH | \ - _DD_NEW_POINT_SMOOTH | \ - _DD_NEW_TRI_STIPPLE | \ - _DD_NEW_LINE_STIPPLE) - -#define LINE_FALLBACK (0) -#define TRI_FALLBACK (0) - -static void gammaChooseRasterState(GLcontext *ctx) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint ind = 0; - - if ( ctx->Line.SmoothFlag || - ctx->Polygon.SmoothFlag || - ctx->Point.SmoothFlag ) - gmesa->Begin |= B_AntiAliasEnable; - else - gmesa->Begin &= ~B_AntiAliasEnable; - - if ( ctx->Texture.Unit[0]._ReallyEnabled ) { - ind |= GAMMA_RAST_TEX_BIT; - gmesa->Begin |= B_TextureEnable; - } else - gmesa->Begin &= ~B_TextureEnable; - - if (flags & DD_LINE_STIPPLE) - gmesa->Begin |= B_LineStippleEnable; - else - gmesa->Begin &= ~B_LineStippleEnable; - - if (flags & DD_TRI_STIPPLE) - gmesa->Begin |= B_AreaStippleEnable; - else - gmesa->Begin &= ~B_AreaStippleEnable; - - if (ctx->Fog.Enabled) - gmesa->Begin |= B_FogEnable; - else - gmesa->Begin &= ~B_FogEnable; - - if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled) - ind |= GAMMA_RAST_ALPHA_BIT; - - if ( flags & DD_FLATSHADE ) - ind |= GAMMA_RAST_FLAT_BIT; - - gmesa->draw_line = gamma_line_tab[ind]; - gmesa->draw_tri = gamma_tri_tab[ind]; - gmesa->draw_quad = gamma_quad_tab[ind]; - gmesa->draw_point = gamma_point_tab[ind]; - - /* Hook in fallbacks for specific primitives. CURRENTLY DISABLED - */ - if (flags & LINE_FALLBACK) - gmesa->draw_line = gamma_fallback_line; - - if (flags & TRI_FALLBACK) { - gmesa->draw_tri = gamma_fallback_tri; - gmesa->draw_quad = gamma_fallback_quad; - } -} - - - - -/*********************************************************************** - * Macros for t_dd_tritmp.h to draw basic primitives * - ***********************************************************************/ - -#define TRI( a, b, c ) \ -do { \ - gmesa->draw_tri( gmesa, a, b, c ); \ -} while (0) - -#define QUAD( a, b, c, d ) \ -do { \ - gmesa->draw_quad( gmesa, a, b, c, d ); \ -} while (0) - -#define LINE( v0, v1 ) \ -do { \ - gmesa->draw_line( gmesa, v0, v1 ); \ -} while (0) - -#define POINT( v0 ) \ -do { \ - gmesa->draw_point( gmesa, v0 ); \ -} while (0) - - -/*********************************************************************** - * Build render functions from dd templates * - ***********************************************************************/ - -#define GAMMA_OFFSET_BIT 0x01 -#define GAMMA_TWOSIDE_BIT 0x02 -#define GAMMA_UNFILLED_BIT 0x04 -#define GAMMA_FALLBACK_BIT 0x08 -#define GAMMA_MAX_TRIFUNC 0x10 - - -static struct { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_quad_func quad; -} rast_tab[GAMMA_MAX_TRIFUNC]; - - -#define DO_FALLBACK (IND & GAMMA_FALLBACK_BIT) -#define DO_OFFSET 0 /* (IND & GAMMA_OFFSET_BIT) */ -#define DO_UNFILLED 0 /* (IND & GAMMA_UNFILLED_BIT) */ -#define DO_TWOSIDE (IND & GAMMA_TWOSIDE_BIT) -#define DO_FLAT 0 -#define DO_TRI 1 -#define DO_QUAD 1 -#define DO_LINE 1 -#define DO_POINTS 1 -#define DO_FULL_QUAD 1 - -#define HAVE_RGBA 1 -#define HAVE_SPEC 0 -#define HAVE_BACK_COLORS 0 -#define HAVE_HW_FLATSHADE 1 -#define VERTEX gammaVertex -#define TAB rast_tab - -#define DEPTH_SCALE 1.0 -#define UNFILLED_TRI unfilled_tri -#define UNFILLED_QUAD unfilled_quad -#define VERT_X(_v) _v->v.x -#define VERT_Y(_v) _v->v.y -#define VERT_Z(_v) _v->v.z -#define AREA_IS_CCW( a ) (a > 0) -#define GET_VERTEX(e) (gmesa->verts + (e * gmesa->vertex_size * sizeof(int))) - -#define VERT_SET_RGBA( v, c ) \ -do { \ - UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][0], (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][1], (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][2], (c)[2]); \ - UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][3], (c)[3]); \ -} while (0) -#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4] -#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4] -#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx] - -#define LOCAL_VARS(n) \ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \ - GLuint color[n] = { 0 }; \ - (void) color; - - -/*********************************************************************** - * Helpers for rendering unfilled primitives * - ***********************************************************************/ - -static const GLuint hw_prim[GL_POLYGON+1] = { - B_PrimType_Points, - B_PrimType_Lines, - B_PrimType_Lines, - B_PrimType_Lines, - B_PrimType_Triangles, - B_PrimType_Triangles, - B_PrimType_Triangles, - B_PrimType_Triangles, - B_PrimType_Triangles, - B_PrimType_Triangles -}; - -static void gammaResetLineStipple( GLcontext *ctx ); -static void gammaRasterPrimitive( GLcontext *ctx, GLuint hwprim ); -static void gammaRenderPrimitive( GLcontext *ctx, GLenum prim ); - -#define RASTERIZE(x) if (gmesa->hw_primitive != hw_prim[x]) \ - gammaRasterPrimitive( ctx, hw_prim[x] ) -#define RENDER_PRIMITIVE gmesa->render_primitive -#define TAG(x) x -#define IND GAMMA_FALLBACK_BIT -#include "tnl_dd/t_dd_unfilled.h" -#undef IND - -/*********************************************************************** - * Generate GL render functions * - ***********************************************************************/ - -#define IND (0) -#define TAG(x) x -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (GAMMA_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (GAMMA_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (GAMMA_TWOSIDE_BIT|GAMMA_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (GAMMA_UNFILLED_BIT) -#define TAG(x) x##_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (GAMMA_OFFSET_BIT|GAMMA_UNFILLED_BIT) -#define TAG(x) x##_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (GAMMA_TWOSIDE_BIT|GAMMA_UNFILLED_BIT) -#define TAG(x) x##_twoside_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (GAMMA_TWOSIDE_BIT|GAMMA_OFFSET_BIT|GAMMA_UNFILLED_BIT) -#define TAG(x) x##_twoside_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - - - -static void init_render_tab( void ) -{ - init(); - init_offset(); - init_twoside(); - init_twoside_offset(); - init_unfilled(); - init_offset_unfilled(); - init_twoside_unfilled(); - init_twoside_offset_unfilled(); -} - - -/**********************************************************************/ -/* Render unclipped begin/end objects */ -/**********************************************************************/ - -#define VERT(x) (gammaVertex *)(gammaverts + (x * size * sizeof(int))) -#define RENDER_POINTS( start, count ) \ - for ( ; start < count ; start++) \ - gmesa->draw_point( gmesa, VERT(start) ) -#define RENDER_LINE( v0, v1 ) \ - gmesa->draw_line( gmesa, VERT(v0), VERT(v1) ) -#define RENDER_TRI( v0, v1, v2 ) \ - gmesa->draw_tri( gmesa, VERT(v0), VERT(v1), VERT(v2) ) -#define RENDER_QUAD( v0, v1, v2, v3 ) \ - gmesa->draw_quad( gmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) -#define INIT(x) gammaRenderPrimitive( ctx, x ); -#undef LOCAL_VARS -#define LOCAL_VARS \ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \ - const GLuint size = gmesa->vertex_size; \ - const char *gammaverts = (char *)gmesa->verts; \ - const GLboolean stipple = ctx->Line.StippleFlag; \ - (void) stipple; -#define RESET_STIPPLE if ( stipple ) gammaResetLineStipple( ctx ); -#define RESET_OCCLUSION -#define PRESERVE_VB_DEFS -#define ELT(x) (x) -#define TAG(x) gamma_##x##_verts -#include "tnl/t_vb_rendertmp.h" - - -/**********************************************************************/ -/* Render clipped primitives */ -/**********************************************************************/ - -static void gammaRenderClippedPoly( GLcontext *ctx, const GLuint *elts, - GLuint n ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint prim = gmesa->render_primitive; - - /* Render the new vertices as an unclipped polygon. - */ - { - GLuint *tmp = VB->Elts; - VB->Elts = (GLuint *)elts; - tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END ); - VB->Elts = tmp; - } - - /* Restore the render primitive - */ - if (prim != GL_POLYGON) - tnl->Driver.Render.PrimitiveNotify( ctx, prim ); -} - -static void gammaRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line( ctx, ii, jj ); -} - - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - - - -#define _GAMMA_NEW_RENDERSTATE (_DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _DD_NEW_TRI_OFFSET) - -#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED) - -static void gammaChooseRenderState(GLcontext *ctx) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint index = 0; - - if (flags & ANY_RASTER_FLAGS) { - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= GAMMA_TWOSIDE_BIT; - if (flags & DD_TRI_OFFSET) index |= GAMMA_OFFSET_BIT; - if (flags & DD_TRI_UNFILLED) index |= GAMMA_UNFILLED_BIT; - } - - if (gmesa->RenderIndex != index) { - gmesa->RenderIndex = index; - - tnl->Driver.Render.Points = rast_tab[index].points; - tnl->Driver.Render.Line = rast_tab[index].line; - tnl->Driver.Render.Triangle = rast_tab[index].triangle; - tnl->Driver.Render.Quad = rast_tab[index].quad; - - if (gmesa->RenderIndex == 0) - tnl->Driver.Render.PrimTabVerts = gamma_render_tab_verts; - else - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedLine = gammaRenderClippedLine; - tnl->Driver.Render.ClippedPolygon = gammaRenderClippedPoly; - } -} - - -/**********************************************************************/ -/* High level hooks for t_vb_render.c */ -/**********************************************************************/ - - - -/* Determine the rasterized primitive when not drawing unfilled - * polygons. - * - * Used only for the default render stage which always decomposes - * primitives to trianges/lines/points. For the accelerated stage, - * which renders strips as strips, the equivalent calculations are - * performed in gammarender.c. - */ - -static void gammaRasterPrimitive( GLcontext *ctx, GLuint hwprim ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - if (gmesa->hw_primitive != hwprim) - gmesa->hw_primitive = hwprim; -} - -static void gammaRenderPrimitive( GLcontext *ctx, GLenum prim ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - gmesa->render_primitive = prim; -} - -static void gammaRunPipeline( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - if ( gmesa->new_state ) - gammaDDUpdateHWState( ctx ); - - if (gmesa->new_gl_state) { - if (gmesa->new_gl_state & _NEW_TEXTURE) - gammaUpdateTextureState( ctx ); - - if (!gmesa->Fallback) { - if (gmesa->new_gl_state & _GAMMA_NEW_VERTEX) - gammaChooseVertexState( ctx ); - - if (gmesa->new_gl_state & _GAMMA_NEW_RASTER_STATE) - gammaChooseRasterState( ctx ); - - if (gmesa->new_gl_state & _GAMMA_NEW_RENDERSTATE) - gammaChooseRenderState( ctx ); - } - - gmesa->new_gl_state = 0; - } - - _tnl_run_pipeline( ctx ); -} - -static void gammaRenderStart( GLcontext *ctx ) -{ - /* Check for projective texturing. Make sure all texcoord - * pointers point to something. (fix in mesa?) - */ - gammaCheckTexSizes( ctx ); -} - -static void gammaRenderFinish( GLcontext *ctx ) -{ - if (0) - _swrast_flush( ctx ); /* never needed */ -} - -static void gammaResetLineStipple( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - - /* Reset the hardware stipple counter. - */ - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, UpdateLineStippleCounters, 0); -} - - -/**********************************************************************/ -/* Transition to/from hardware rasterization. */ -/**********************************************************************/ - - -void gammaFallback( gammaContextPtr gmesa, GLuint bit, GLboolean mode ) -{ - GLcontext *ctx = gmesa->glCtx; - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint oldfallback = gmesa->Fallback; - - if (mode) { - gmesa->Fallback |= bit; - if (oldfallback == 0) { - _swsetup_Wakeup( ctx ); - _tnl_need_projected_coords( ctx, GL_TRUE ); - gmesa->RenderIndex = ~0; - } - } - else { - gmesa->Fallback &= ~bit; - if (oldfallback == bit) { - _swrast_flush( ctx ); - tnl->Driver.Render.Start = gammaRenderStart; - tnl->Driver.Render.PrimitiveNotify = gammaRenderPrimitive; - tnl->Driver.Render.Finish = gammaRenderFinish; - tnl->Driver.Render.BuildVertices = gammaBuildVertices; - tnl->Driver.Render.ResetLineStipple = gammaResetLineStipple; - gmesa->new_gl_state |= (_GAMMA_NEW_RENDERSTATE| - _GAMMA_NEW_RASTER_STATE| - _GAMMA_NEW_VERTEX); - } - } -} - - -/**********************************************************************/ -/* Initialization. */ -/**********************************************************************/ - - -void gammaDDInitTriFuncs( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - static int firsttime = 1; - - if (firsttime) { - init_rast_tab(); - init_render_tab(); - firsttime = 0; - } - - gmesa->RenderIndex = ~0; - - tnl->Driver.RunPipeline = gammaRunPipeline; - tnl->Driver.Render.Start = gammaRenderStart; - tnl->Driver.Render.Finish = gammaRenderFinish; - tnl->Driver.Render.PrimitiveNotify = gammaRenderPrimitive; - tnl->Driver.Render.ResetLineStipple = gammaResetLineStipple; - tnl->Driver.Render.BuildVertices = gammaBuildVertices; -} diff --git a/src/mesa/drivers/dri/gamma/gamma_tris.h b/src/mesa/drivers/dri/gamma/gamma_tris.h deleted file mode 100644 index 02bec286903..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_tris.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * Keith Whitwell, - * - * 3DLabs Gamma driver. - */ - -#ifndef _GAMMA_TRIS_H -#define _GAMMA_TRIS_H - -extern void gammaDDTrifuncInit(void); -extern void gammaDDChooseTriRenderState(GLcontext *); - - - -#endif /* !(_GAMMA_TRIS_H) */ diff --git a/src/mesa/drivers/dri/gamma/gamma_tritmp.h b/src/mesa/drivers/dri/gamma/gamma_tritmp.h deleted file mode 100644 index bea2508d4a2..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_tritmp.h +++ /dev/null @@ -1,496 +0,0 @@ - -static void TAG(gamma_point)( gammaContextPtr gmesa, - const gammaVertex *v0 ) -{ - uint32_t vColor; - uint32_t vBegin; - - vBegin = gmesa->Begin | B_PrimType_Points; - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, Begin, vBegin); - -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v0->v.color.alpha << 24) | - (v0->v.color.blue << 16) | - (v0->v.color.green << 8) | - (v0->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v0->v.color.blue << 16) | - (v0->v.color.green << 8) | - (v0->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif - -#if (IND & GAMMA_RAST_TEX_BIT) - CHECK_DMA_BUFFER(gmesa, 6); - WRITEF(gmesa->buf, Tt2, v0->v.u0); - WRITEF(gmesa->buf, Ts2, v0->v.v0); - WRITEF(gmesa->buf, Vw, v0->v.w); - WRITEF(gmesa->buf, Vz, v0->v.z); - WRITEF(gmesa->buf, Vy, v0->v.y); - WRITEF(gmesa->buf, Vx4, v0->v.x); -#else - CHECK_DMA_BUFFER(gmesa, 4); - WRITEF(gmesa->buf, Vw, v0->v.w); - WRITEF(gmesa->buf, Vz, v0->v.z); - WRITEF(gmesa->buf, Vy, v0->v.y); - WRITEF(gmesa->buf, Vx4, v0->v.x); -#endif - -#if !(IND & GAMMA_RAST_FLAT_BIT) - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, FlushSpan, 0); -#endif - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, End, 0); -} - -static void TAG(gamma_line)( gammaContextPtr gmesa, - const gammaVertex *v0, - const gammaVertex *v1 ) -{ - uint32_t vColor; - uint32_t vBegin; - - vBegin = gmesa->Begin | B_PrimType_Lines; - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, Begin, vBegin); - -#if !(IND & GAMMA_RAST_FLAT_BIT) -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v0->v.color.alpha << 24) | - (v0->v.color.blue << 16) | - (v0->v.color.green << 8) | - (v0->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v0->v.color.blue << 16) | - (v0->v.color.green << 8) | - (v0->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif -#else -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v1->v.color.alpha << 24) | - (v1->v.color.blue << 16) | - (v1->v.color.green << 8) | - (v1->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v1->v.color.blue << 16) | - (v1->v.color.green << 8) | - (v1->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif -#endif - -#if (IND & GAMMA_RAST_TEX_BIT) - CHECK_DMA_BUFFER(gmesa, 6); - WRITEF(gmesa->buf, Tt2, v0->v.u0); - WRITEF(gmesa->buf, Ts2, v0->v.v0); - WRITEF(gmesa->buf, Vw, v0->v.w); - WRITEF(gmesa->buf, Vz, v0->v.z); - WRITEF(gmesa->buf, Vy, v0->v.y); - WRITEF(gmesa->buf, Vx4, v0->v.x); -#else - CHECK_DMA_BUFFER(gmesa, 4); - WRITEF(gmesa->buf, Vw, v0->v.w); - WRITEF(gmesa->buf, Vz, v0->v.z); - WRITEF(gmesa->buf, Vy, v0->v.y); - WRITEF(gmesa->buf, Vx4, v0->v.x); -#endif - -#if !(IND & GAMMA_RAST_FLAT_BIT) -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v1->v.color.alpha << 24) | - (v1->v.color.blue << 16) | - (v1->v.color.green << 8) | - (v1->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v1->v.color.blue << 16) | - (v1->v.color.green << 8) | - (v1->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif -#endif - -#if (IND & GAMMA_RAST_TEX_BIT) - CHECK_DMA_BUFFER(gmesa, 6); - WRITEF(gmesa->buf, Tt2, v1->v.u0); - WRITEF(gmesa->buf, Ts2, v1->v.v0); - WRITEF(gmesa->buf, Vw, v1->v.w); - WRITEF(gmesa->buf, Vz, v1->v.z); - WRITEF(gmesa->buf, Vy, v1->v.y); - WRITEF(gmesa->buf, Vx4, v1->v.x); -#else - CHECK_DMA_BUFFER(gmesa, 4); - WRITEF(gmesa->buf, Vw, v1->v.w); - WRITEF(gmesa->buf, Vz, v1->v.z); - WRITEF(gmesa->buf, Vy, v1->v.y); - WRITEF(gmesa->buf, Vx4, v1->v.x); -#endif - -#if !(IND & GAMMA_RAST_FLAT_BIT) - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, FlushSpan, 0); -#endif - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, End, 0); -} - -static void TAG(gamma_triangle)( gammaContextPtr gmesa, - const gammaVertex *v0, - const gammaVertex *v1, - const gammaVertex *v2 ) -{ - uint32_t vColor; - uint32_t vBegin; - - vBegin = gmesa->Begin | B_PrimType_Triangles; - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, Begin, vBegin); - -#if !(IND & GAMMA_RAST_FLAT_BIT) -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v0->v.color.alpha << 24) | - (v0->v.color.blue << 16) | - (v0->v.color.green << 8) | - (v0->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v0->v.color.blue << 16) | - (v0->v.color.green << 8) | - (v0->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif -#else -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v2->v.color.alpha << 24) | - (v2->v.color.blue << 16) | - (v2->v.color.green << 8) | - (v2->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v2->v.color.blue << 16) | - (v2->v.color.green << 8) | - (v2->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif -#endif - -#if (IND & GAMMA_RAST_TEX_BIT) - CHECK_DMA_BUFFER(gmesa, 6); - WRITEF(gmesa->buf, Tt2, v0->v.u0); - WRITEF(gmesa->buf, Ts2, v0->v.v0); - WRITEF(gmesa->buf, Vw, v0->v.w); - WRITEF(gmesa->buf, Vz, v0->v.z); - WRITEF(gmesa->buf, Vy, v0->v.y); - WRITEF(gmesa->buf, Vx4, v0->v.x); -#else - CHECK_DMA_BUFFER(gmesa, 4); - WRITEF(gmesa->buf, Vw, v0->v.w); - WRITEF(gmesa->buf, Vz, v0->v.z); - WRITEF(gmesa->buf, Vy, v0->v.y); - WRITEF(gmesa->buf, Vx4, v0->v.x); -#endif - -#if !(IND & GAMMA_RAST_FLAT_BIT) -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v1->v.color.alpha << 24) | - (v1->v.color.blue << 16) | - (v1->v.color.green << 8) | - (v1->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v1->v.color.blue << 16) | - (v1->v.color.green << 8) | - (v1->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif -#endif - -#if (IND & GAMMA_RAST_TEX_BIT) - CHECK_DMA_BUFFER(gmesa, 6); - WRITEF(gmesa->buf, Tt2, v1->v.u0); - WRITEF(gmesa->buf, Ts2, v1->v.v0); - WRITEF(gmesa->buf, Vw, v1->v.w); - WRITEF(gmesa->buf, Vz, v1->v.z); - WRITEF(gmesa->buf, Vy, v1->v.y); - WRITEF(gmesa->buf, Vx4, v1->v.x); -#else - CHECK_DMA_BUFFER(gmesa, 4); - WRITEF(gmesa->buf, Vw, v1->v.w); - WRITEF(gmesa->buf, Vz, v1->v.z); - WRITEF(gmesa->buf, Vy, v1->v.y); - WRITEF(gmesa->buf, Vx4, v1->v.x); -#endif - -#if !(IND & GAMMA_RAST_FLAT_BIT) -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v2->v.color.alpha << 24) | - (v2->v.color.blue << 16) | - (v2->v.color.green << 8) | - (v2->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v2->v.color.blue << 16) | - (v2->v.color.green << 8) | - (v2->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif -#endif - -#if (IND & GAMMA_RAST_TEX_BIT) - CHECK_DMA_BUFFER(gmesa, 6); - WRITEF(gmesa->buf, Tt2, v2->v.u0); - WRITEF(gmesa->buf, Ts2, v2->v.v0); - WRITEF(gmesa->buf, Vw, v2->v.w); - WRITEF(gmesa->buf, Vz, v2->v.z); - WRITEF(gmesa->buf, Vy, v2->v.y); - WRITEF(gmesa->buf, Vx4, v2->v.x); -#else - CHECK_DMA_BUFFER(gmesa, 4); - WRITEF(gmesa->buf, Vw, v2->v.w); - WRITEF(gmesa->buf, Vz, v2->v.z); - WRITEF(gmesa->buf, Vy, v2->v.y); - WRITEF(gmesa->buf, Vx4, v2->v.x); -#endif - -#if !(IND & GAMMA_RAST_FLAT_BIT) - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, FlushSpan, 0); -#endif - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, End, 0); -} - -static void TAG(gamma_quad)( gammaContextPtr gmesa, - const gammaVertex *v0, - const gammaVertex *v1, - const gammaVertex *v2, - const gammaVertex *v3 ) -{ - uint32_t vColor; - uint32_t vBegin; - - vBegin = gmesa->Begin | B_PrimType_Quads; - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, Begin, vBegin); - -#if !(IND & GAMMA_RAST_FLAT_BIT) -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v0->v.color.alpha << 24) | - (v0->v.color.blue << 16) | - (v0->v.color.green << 8) | - (v0->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v0->v.color.blue << 16) | - (v0->v.color.green << 8) | - (v0->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif -#else -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v3->v.color.alpha << 24) | - (v3->v.color.blue << 16) | - (v3->v.color.green << 8) | - (v3->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v3->v.color.blue << 16) | - (v3->v.color.green << 8) | - (v3->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif -#endif - -#if (IND & GAMMA_RAST_TEX_BIT) - CHECK_DMA_BUFFER(gmesa, 6); - WRITEF(gmesa->buf, Tt2, v0->v.u0); - WRITEF(gmesa->buf, Ts2, v0->v.v0); - WRITEF(gmesa->buf, Vw, v0->v.w); - WRITEF(gmesa->buf, Vz, v0->v.z); - WRITEF(gmesa->buf, Vy, v0->v.y); - WRITEF(gmesa->buf, Vx4, v0->v.x); -#else - CHECK_DMA_BUFFER(gmesa, 4); - WRITEF(gmesa->buf, Vw, v0->v.w); - WRITEF(gmesa->buf, Vz, v0->v.z); - WRITEF(gmesa->buf, Vy, v0->v.y); - WRITEF(gmesa->buf, Vx4, v0->v.x); -#endif - -#if !(IND & GAMMA_RAST_FLAT_BIT) -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v1->v.color.alpha << 24) | - (v1->v.color.blue << 16) | - (v1->v.color.green << 8) | - (v1->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v1->v.color.blue << 16) | - (v1->v.color.green << 8) | - (v1->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif -#endif - -#if (IND & GAMMA_RAST_TEX_BIT) - CHECK_DMA_BUFFER(gmesa, 6); - WRITEF(gmesa->buf, Tt2, v1->v.u0); - WRITEF(gmesa->buf, Ts2, v1->v.v0); - WRITEF(gmesa->buf, Vw, v1->v.w); - WRITEF(gmesa->buf, Vz, v1->v.z); - WRITEF(gmesa->buf, Vy, v1->v.y); - WRITEF(gmesa->buf, Vx4, v1->v.x); -#else - CHECK_DMA_BUFFER(gmesa, 4); - WRITEF(gmesa->buf, Vw, v1->v.w); - WRITEF(gmesa->buf, Vz, v1->v.z); - WRITEF(gmesa->buf, Vy, v1->v.y); - WRITEF(gmesa->buf, Vx4, v1->v.x); -#endif - -#if !(IND & GAMMA_RAST_FLAT_BIT) -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v2->v.color.alpha << 24) | - (v2->v.color.blue << 16) | - (v2->v.color.green << 8) | - (v2->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v2->v.color.blue << 16) | - (v2->v.color.green << 8) | - (v2->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif -#endif - -#if (IND & GAMMA_RAST_TEX_BIT) - CHECK_DMA_BUFFER(gmesa, 6); - WRITEF(gmesa->buf, Tt2, v2->v.u0); - WRITEF(gmesa->buf, Ts2, v2->v.v0); - WRITEF(gmesa->buf, Vw, v2->v.w); - WRITEF(gmesa->buf, Vz, v2->v.z); - WRITEF(gmesa->buf, Vy, v2->v.y); - WRITEF(gmesa->buf, Vx4, v2->v.x); -#else - CHECK_DMA_BUFFER(gmesa, 4); - WRITEF(gmesa->buf, Vw, v2->v.w); - WRITEF(gmesa->buf, Vz, v2->v.z); - WRITEF(gmesa->buf, Vy, v2->v.y); - WRITEF(gmesa->buf, Vx4, v2->v.x); -#endif - -#if !(IND & GAMMA_RAST_FLAT_BIT) -#if (IND & GAMMA_RAST_ALPHA_BIT) - vColor = (v3->v.color.alpha << 24) | - (v3->v.color.blue << 16) | - (v3->v.color.green << 8) | - (v3->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor4, vColor); -#else - vColor = (v3->v.color.blue << 16) | - (v3->v.color.green << 8) | - (v3->v.color.red << 0); - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, PackedColor3, vColor); -#endif -#endif - -#if (IND & GAMMA_RAST_TEX_BIT) - CHECK_DMA_BUFFER(gmesa, 6); - WRITEF(gmesa->buf, Tt2, v3->v.u0); - WRITEF(gmesa->buf, Ts2, v3->v.v0); - WRITEF(gmesa->buf, Vw, v3->v.w); - WRITEF(gmesa->buf, Vz, v3->v.z); - WRITEF(gmesa->buf, Vy, v3->v.y); - WRITEF(gmesa->buf, Vx4, v3->v.x); -#else - CHECK_DMA_BUFFER(gmesa, 4); - WRITEF(gmesa->buf, Vw, v3->v.w); - WRITEF(gmesa->buf, Vz, v3->v.z); - WRITEF(gmesa->buf, Vy, v3->v.y); - WRITEF(gmesa->buf, Vx4, v3->v.x); -#endif - -#if !(IND & GAMMA_RAST_FLAT_BIT) - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, FlushSpan, 0); -#endif - - CHECK_DMA_BUFFER(gmesa, 1); - WRITE(gmesa->buf, End, 0); -} - -static void TAG(gamma_init)(void) -{ - gamma_point_tab[IND] = TAG(gamma_point); - gamma_line_tab[IND] = TAG(gamma_line); - gamma_tri_tab[IND] = TAG(gamma_triangle); - gamma_quad_tab[IND] = TAG(gamma_quad); -} - -#undef IND -#undef TAG diff --git a/src/mesa/drivers/dri/gamma/gamma_vb.c b/src/mesa/drivers/dri/gamma/gamma_vb.c deleted file mode 100644 index c9c1ebf62a6..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_vb.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * Keith Whitwell, - * - * 3DLabs Gamma driver. - */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/colormac.h" - -#include "swrast_setup/swrast_setup.h" -#include "tnl/t_context.h" -#include "tnl/tnl.h" - -#include "gamma_context.h" -#include "gamma_vb.h" -#include "gamma_tris.h" - - -#define GAMMA_TEX0_BIT 0x1 -#define GAMMA_RGBA_BIT 0x2 -#define GAMMA_XYZW_BIT 0x4 -#define GAMMA_PTEX_BIT 0x8 -#define GAMMA_FOG_BIT 0x10 -#define GAMMA_SPEC_BIT 0x20 -#define GAMMA_MAX_SETUP 0x40 - -static struct { - void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint ); - tnl_interp_func interp; - tnl_copy_pv_func copy_pv; - GLboolean (*check_tex_sizes)( GLcontext *ctx ); - GLuint vertex_size; - GLuint vertex_format; -} setup_tab[GAMMA_MAX_SETUP]; - -#define TINY_VERTEX_FORMAT 1 -#define NOTEX_VERTEX_FORMAT 2 -#define TEX0_VERTEX_FORMAT 3 -#define TEX1_VERTEX_FORMAT 0 -#define PROJ_TEX1_VERTEX_FORMAT 0 -#define TEX2_VERTEX_FORMAT 0 -#define TEX3_VERTEX_FORMAT 0 -#define PROJ_TEX3_VERTEX_FORMAT 0 - -#define DO_XYZW (IND & GAMMA_XYZW_BIT) -#define DO_RGBA (IND & GAMMA_RGBA_BIT) -#define DO_SPEC (IND & GAMMA_SPEC_BIT) -#define DO_FOG (IND & GAMMA_FOG_BIT) -#define DO_TEX0 (IND & GAMMA_TEX0_BIT) -#define DO_TEX1 0 -#define DO_TEX2 0 -#define DO_TEX3 0 -#define DO_PTEX (IND & GAMMA_PTEX_BIT) - -#define VERTEX gammaVertex -#define VERTEX_COLOR gamma_color_t -#define GET_VIEWPORT_MAT() 0 -#define GET_TEXSOURCE(n) n -#define GET_VERTEX_FORMAT() GAMMA_CONTEXT(ctx)->vertex_format -#define GET_VERTEX_STORE() GAMMA_CONTEXT(ctx)->verts -#define GET_VERTEX_SIZE() GAMMA_CONTEXT(ctx)->vertex_size * sizeof(GLuint) -#define INVALIDATE_STORED_VERTICES() - -#define HAVE_HW_VIEWPORT 1 -#define HAVE_HW_DIVIDE 1 -#define HAVE_RGBA_COLOR 0 /* we're BGRA */ -#define HAVE_TINY_VERTICES 1 -#define HAVE_NOTEX_VERTICES 1 -#define HAVE_TEX0_VERTICES 1 -#define HAVE_TEX1_VERTICES 0 -#define HAVE_TEX2_VERTICES 0 -#define HAVE_TEX3_VERTICES 0 -#define HAVE_PTEX_VERTICES 1 - -#define PTEX_FALLBACK() /* never needed */ - -#define INTERP_VERTEX setup_tab[GAMMA_CONTEXT(ctx)->SetupIndex].interp -#define COPY_PV_VERTEX setup_tab[GAMMA_CONTEXT(ctx)->SetupIndex].copy_pv - - - -/*********************************************************************** - * Generate pv-copying and translation functions * - ***********************************************************************/ - -#define TAG(x) gamma_##x -#include "tnl_dd/t_dd_vb.c" - -/*********************************************************************** - * Generate vertex emit and interp functions * - ***********************************************************************/ - -#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT) -#define TAG(x) x##_wg -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_SPEC_BIT) -#define TAG(x) x##_wgs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_TEX0_BIT) -#define TAG(x) x##_wgt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_TEX0_BIT|GAMMA_PTEX_BIT) -#define TAG(x) x##_wgpt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT) -#define TAG(x) x##_wgst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT|\ - GAMMA_PTEX_BIT) -#define TAG(x) x##_wgspt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT) -#define TAG(x) x##_wgf -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT) -#define TAG(x) x##_wgfs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_TEX0_BIT) -#define TAG(x) x##_wgft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_TEX0_BIT|\ - GAMMA_PTEX_BIT) -#define TAG(x) x##_wgfpt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT|\ - GAMMA_TEX0_BIT) -#define TAG(x) x##_wgfst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT|\ - GAMMA_TEX0_BIT|GAMMA_PTEX_BIT) -#define TAG(x) x##_wgfspt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_TEX0_BIT) -#define TAG(x) x##_t0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_FOG_BIT) -#define TAG(x) x##_f -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_FOG_BIT|GAMMA_TEX0_BIT) -#define TAG(x) x##_ft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_RGBA_BIT) -#define TAG(x) x##_g -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_RGBA_BIT|GAMMA_SPEC_BIT) -#define TAG(x) x##_gs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_RGBA_BIT|GAMMA_TEX0_BIT) -#define TAG(x) x##_gt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_RGBA_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT) -#define TAG(x) x##_gst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT) -#define TAG(x) x##_gf -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT) -#define TAG(x) x##_gfs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_TEX0_BIT) -#define TAG(x) x##_gft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT) -#define TAG(x) x##_gfst0 -#include "tnl_dd/t_dd_vbtmp.h" - -static void init_setup_tab( void ) -{ - init_wg(); - init_wgs(); - init_wgt0(); - init_wgpt0(); - init_wgst0(); - init_wgspt0(); - init_wgf(); - init_wgfs(); - init_wgft0(); - init_wgfpt0(); - init_wgfst0(); - init_wgfspt0(); - init_t0(); - init_f(); - init_ft0(); - init_g(); - init_gs(); - init_gt0(); - init_gst0(); - init_gf(); - init_gfs(); - init_gft0(); - init_gfst0(); -} - -void gammaCheckTexSizes( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - gammaContextPtr gmesa = GAMMA_CONTEXT( ctx ); - - if (!setup_tab[gmesa->SetupIndex].check_tex_sizes(ctx)) { - /* Invalidate stored verts - */ - gmesa->SetupNewInputs = ~0; - gmesa->SetupIndex |= GAMMA_PTEX_BIT; - - if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { - tnl->Driver.Render.Interp = setup_tab[gmesa->SetupIndex].interp; - tnl->Driver.Render.CopyPV = setup_tab[gmesa->SetupIndex].copy_pv; - } - } -} - -void gammaBuildVertices( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint newinputs ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT( ctx ); - GLuint stride = gmesa->vertex_size * sizeof(int); - GLubyte *v = ((GLubyte *)gmesa->verts + (start * stride)); - - newinputs |= gmesa->SetupNewInputs; - gmesa->SetupNewInputs = 0; - - if (!newinputs) - return; - - if (newinputs & VERT_BIT_POS) { - setup_tab[gmesa->SetupIndex].emit( ctx, start, count, v, stride ); - } else { - GLuint ind = 0; - - if (newinputs & VERT_BIT_COLOR0) - ind |= GAMMA_RGBA_BIT; - - if (newinputs & VERT_BIT_COLOR1) - ind |= GAMMA_SPEC_BIT; - - if (newinputs & VERT_BIT_TEX0) - ind |= GAMMA_TEX0_BIT; - - if (newinputs & VERT_BIT_FOG) - ind |= GAMMA_FOG_BIT; - - if (gmesa->SetupIndex & GAMMA_PTEX_BIT) - ind = ~0; - - ind &= gmesa->SetupIndex; - - if (ind) { - setup_tab[ind].emit( ctx, start, count, v, stride ); - } - } -} - -void gammaChooseVertexState( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT( ctx ); - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint ind = GAMMA_XYZW_BIT|GAMMA_RGBA_BIT; - - if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) - ind |= GAMMA_SPEC_BIT; - - if (ctx->Fog.Enabled) - ind |= GAMMA_FOG_BIT; - - if (ctx->Texture.Unit[0]._ReallyEnabled) { - _tnl_need_projected_coords( ctx, GL_FALSE ); - ind |= GAMMA_TEX0_BIT; - } else - _tnl_need_projected_coords( ctx, GL_FALSE ); - - gmesa->SetupIndex = ind; - - if (setup_tab[ind].vertex_format != gmesa->vertex_format) { - gmesa->vertex_format = setup_tab[ind].vertex_format; - gmesa->vertex_size = setup_tab[ind].vertex_size; - } - - if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) { - tnl->Driver.Render.Interp = gamma_interp_extras; - tnl->Driver.Render.CopyPV = gamma_copy_pv_extras; - } else { - tnl->Driver.Render.Interp = setup_tab[ind].interp; - tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv; - } -} - - -void gammaInitVB( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - GLuint size = TNL_CONTEXT(ctx)->vb.Size; - - gmesa->verts = (GLubyte *)_mesa_align_malloc(size * 4 * 16, 32); - - { - static int firsttime = 1; - if (firsttime) { - init_setup_tab(); - firsttime = 0; - gmesa->vertex_size = 16; /* FIXME - only one vertex setup */ - } - } -} - - -void gammaFreeVB( GLcontext *ctx ) -{ - gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); - if (gmesa->verts) { - _mesa_align_free(gmesa->verts); - gmesa->verts = 0; - } -} diff --git a/src/mesa/drivers/dri/gamma/gamma_vb.h b/src/mesa/drivers/dri/gamma/gamma_vb.h deleted file mode 100644 index 8701226f590..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_vb.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * Keith Whitwell, - * - * 3DLabs Gamma driver. - */ - -#ifndef GAMMAVB_INC -#define GAMMAVB_INC - -#include "main/mtypes.h" -#include "swrast/swrast.h" - -#define _GAMMA_NEW_VERTEX (_NEW_TEXTURE | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE) - - -extern void gammaChooseVertexState( GLcontext *ctx ); -extern void gammaCheckTexSizes( GLcontext *ctx ); -extern void gammaBuildVertices( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint newinputs ); - - -extern void gamma_import_float_colors( GLcontext *ctx ); -extern void gamma_import_float_spec_colors( GLcontext *ctx ); - -extern void gamma_translate_vertex( GLcontext *ctx, - const gammaVertex *src, - SWvertex *dst ); - -extern void gammaInitVB( GLcontext *ctx ); -extern void gammaFreeVB( GLcontext *ctx ); - -extern void gamma_print_vertex( GLcontext *ctx, const gammaVertex *v ); -extern void gammaPrintSetupFlags(char *msg, GLuint flags ); - -#endif diff --git a/src/mesa/drivers/dri/gamma/gamma_xmesa.c b/src/mesa/drivers/dri/gamma/gamma_xmesa.c deleted file mode 100644 index 622121eed46..00000000000 --- a/src/mesa/drivers/dri/gamma/gamma_xmesa.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright 2001 by Alan Hourihane. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - * 3DLabs Gamma driver - */ - -#include "gamma_context.h" -#include "gamma_macros.h" -#include "gamma_vb.h" -#include "main/context.h" -#include "main/matrix.h" -#include "glint_dri.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "vbo/vbo.h" - -static GLboolean -gammaInitDriver(__DRIscreen *sPriv) -{ - sPriv->private = (void *) gammaCreateScreen( sPriv ); - - if (!sPriv->private) { - gammaDestroyScreen( sPriv ); - return GL_FALSE; - } - - return GL_TRUE; -} - -static void -gammaDestroyContext(__DRIcontext *driContextPriv) -{ - gammaContextPtr gmesa = (gammaContextPtr)driContextPriv->driverPrivate; - - if (gmesa) { - _swsetup_DestroyContext( gmesa->glCtx ); - _tnl_DestroyContext( gmesa->glCtx ); - _vbo_DestroyContext( gmesa->glCtx ); - _swrast_DestroyContext( gmesa->glCtx ); - - gammaFreeVB( gmesa->glCtx ); - - /* free the Mesa context */ - gmesa->glCtx->DriverCtx = NULL; - _mesa_destroy_context(gmesa->glCtx); - - FREE(gmesa); - driContextPriv->driverPrivate = NULL; - } -} - - -static GLboolean -gammaCreateBuffer( __DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const __GLcontextModes *mesaVis, - GLboolean isPixmap ) -{ - if (isPixmap) { - return GL_FALSE; /* not implemented */ - } - else { - driDrawPriv->driverPrivate = (void *) - _mesa_create_framebuffer(mesaVis, - GL_FALSE, /* software depth buffer? */ - mesaVis->stencilBits > 0, - mesaVis->accumRedBits > 0, - mesaVis->alphaBits > 0 - ); - return (driDrawPriv->driverPrivate != NULL); - } -} - - -static void -gammaDestroyBuffer(__DRIdrawable *driDrawPriv) -{ - _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - -static void -gammaSwapBuffers( __DRIdrawable *dPriv ) -{ - if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { - gammaContextPtr gmesa; - __DRIscreen *driScrnPriv; - GLcontext *ctx; - - gmesa = (gammaContextPtr) dPriv->driContextPriv->driverPrivate; - ctx = gmesa->glCtx; - driScrnPriv = gmesa->driScreen; - - _mesa_notifySwapBuffers(ctx); - - VALIDATE_DRAWABLE_INFO(gmesa); - - /* Flush any partially filled buffers */ - FLUSH_DMA_BUFFER(gmesa); - - DRM_SPINLOCK(&driScrnPriv->pSAREA->drawable_lock, - driScrnPriv->drawLockID); - VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa); - - if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER) { - int src, dst, x0, y0, x1, h; - int i; - int nRect = dPriv->numClipRects; - drm_clip_rect_t *pRect = dPriv->pClipRects; - __DRIscreen *driScrnPriv = gmesa->driScreen; - GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)driScrnPriv->pDevPriv; - - CHECK_DMA_BUFFER(gmesa, 2); - WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode | - FBReadSrcEnable)); - WRITE(gmesa->buf, LBWriteMode, LBWriteModeDisable); - - for (i = 0; i < nRect; i++, pRect++) { - x0 = pRect->x1; - x1 = pRect->x2; - h = pRect->y2 - pRect->y1; - - y0 = driScrnPriv->fbHeight - (pRect->y1+h); - if (gDRIPriv->numMultiDevices == 2) - src = (y0/2)*driScrnPriv->fbWidth+x0; - else - src = y0*driScrnPriv->fbWidth+x0; - - y0 += driScrnPriv->fbHeight; - if (gDRIPriv->numMultiDevices == 2) - dst = (y0/2)*driScrnPriv->fbWidth+x0; - else - dst = y0*driScrnPriv->fbWidth+x0; - - CHECK_DMA_BUFFER(gmesa, 9); - WRITE(gmesa->buf, StartXDom, x0<<16); /* X0dest */ - WRITE(gmesa->buf, StartY, y0<<16); /* Y0dest */ - WRITE(gmesa->buf, StartXSub, x1<<16); /* X1dest */ - WRITE(gmesa->buf, GLINTCount, h); /* H */ - WRITE(gmesa->buf, dY, 1<<16); /* ydir */ - WRITE(gmesa->buf, dXDom, 0<<16); - WRITE(gmesa->buf, dXSub, 0<<16); - WRITE(gmesa->buf, FBSourceOffset, (dst-src)); - WRITE(gmesa->buf, Render, 0x00040048); /* NOT_DONE */ - } - - /* - ** NOTE: FBSourceOffset (above) is backwards from what is - ** described in the manual (i.e., dst-src instead of src-dst) - ** due to our using the bottom-left window origin instead of the - ** top-left window origin. - */ - - /* Restore FBReadMode */ - CHECK_DMA_BUFFER(gmesa, 2); - WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode | - gmesa->AB_FBReadMode)); - WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable); - } - - if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER) - PROCESS_DMA_BUFFER_TOP_HALF(gmesa); - - DRM_SPINUNLOCK(&driScrnPriv->pSAREA->drawable_lock, - driScrnPriv->drawLockID); - VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa); - - if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER) - PROCESS_DMA_BUFFER_BOTTOM_HALF(gmesa); - } else { - _mesa_problem(NULL, "gammaSwapBuffers: drawable has no context!\n"); - } -} - -static GLboolean -gammaMakeCurrent(__DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv) -{ - if (driContextPriv) { - GET_CURRENT_CONTEXT(ctx); - gammaContextPtr oldGammaCtx = ctx ? GAMMA_CONTEXT(ctx) : NULL; - gammaContextPtr newGammaCtx = (gammaContextPtr) driContextPriv->driverPrivate; - - if ( newGammaCtx != oldGammaCtx ) { - newGammaCtx->dirty = ~0; - } - - if (newGammaCtx->driDrawable != driDrawPriv) { - newGammaCtx->driDrawable = driDrawPriv; - gammaUpdateWindow ( newGammaCtx->glCtx ); - gammaUpdateViewportOffset( newGammaCtx->glCtx ); - } - -#if 0 - newGammaCtx->Window &= ~W_GIDMask; - newGammaCtx->Window |= (driDrawPriv->index << 5); - CHECK_DMA_BUFFER(newGammaCtx,1); - WRITE(newGammaCtx->buf, GLINTWindow, newGammaCtx->Window); -#endif - -newGammaCtx->new_state |= GAMMA_NEW_WINDOW; /* FIXME */ - - _mesa_make_current2( newGammaCtx->glCtx, - (GLframebuffer *) driDrawPriv->driverPrivate, - (GLframebuffer *) driReadPriv->driverPrivate ); - } else { - _mesa_make_current( 0, 0 ); - } - return GL_TRUE; -} - - -static GLboolean -gammaUnbindContext( __DRIcontext *driContextPriv ) -{ - return GL_TRUE; -} - -const struct __DriverAPIRec driDriverAPI = { - gammaInitDriver, - gammaDestroyScreen, - gammaCreateContext, - gammaDestroyContext, - gammaCreateBuffer, - gammaDestroyBuffer, - gammaSwapBuffers, - gammaMakeCurrent, - gammaUnbindContext -}; - - - -/* - * This is the bootstrap function for the driver. - * The __driCreateScreen name is the symbol that libGL.so fetches. - * Return: pointer to a __DRIscreen. - */ -void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, - int numConfigs, __GLXvisualConfig *config) -{ - __DRIscreen *psp; - psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &gammaAPI); - return (void *) psp; -} - -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - NULL -}; diff --git a/src/mesa/drivers/dri/gamma/server/glint_common.h b/src/mesa/drivers/dri/gamma/server/glint_common.h deleted file mode 100644 index 36554e4ac22..00000000000 --- a/src/mesa/drivers/dri/gamma/server/glint_common.h +++ /dev/null @@ -1,63 +0,0 @@ -/* glint_common.h -- common header definitions for Gamma 2D/3D/DRM suite - * - * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Converted to common header format: - * Jens Owen - * - * - */ - -#ifndef _GLINT_COMMON_H_ -#define _GLINT_COMMON_H_ - -/* - * WARNING: If you change any of these defines, make sure to change - * the kernel include file as well (gamma_drm.h) - */ - -/* Driver specific DRM command indices - * NOTE: these are not OS specific, but they are driver specific - */ -#define DRM_GAMMA_INIT 0x00 -#define DRM_GAMMA_COPY 0x01 - -typedef struct { - enum { - GAMMA_INIT_DMA = 0x01, - GAMMA_CLEANUP_DMA = 0x02 - } func; - int sarea_priv_offset; - int pcimode; - unsigned int mmio0; - unsigned int mmio1; - unsigned int mmio2; - unsigned int mmio3; - unsigned int buffers_offset; - int num_rast; -} drmGAMMAInit; - -extern int drmGAMMAInitDMA( int fd, drmGAMMAInit *info ); -extern int drmGAMMACleanupDMA( int fd ); - -#endif diff --git a/src/mesa/drivers/dri/gamma/server/glint_dri.h b/src/mesa/drivers/dri/gamma/server/glint_dri.h deleted file mode 100644 index df1992a5d1e..00000000000 --- a/src/mesa/drivers/dri/gamma/server/glint_dri.h +++ /dev/null @@ -1,122 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Author: - * Jens Owen - * - */ - -#ifndef _GLINT_DRI_H_ -#define _GLINT_DRI_H_ - -#include "xf86drm.h" -#include "glint_common.h" - -typedef struct { - unsigned int GDeltaMode; - unsigned int GDepthMode; - unsigned int GGeometryMode; - unsigned int GTransformMode; -} GAMMAContextRegionRec, *GAMMAContextRegionPtr; - -typedef struct { - unsigned char next, prev; /* indices to form a circular LRU */ - unsigned char in_use; /* owned by a client, or free? */ - int age; /* tracked by clients to update local LRU's */ -} GAMMATextureRegionRec, *GAMMATextureRegionPtr; - -typedef struct { - GAMMAContextRegionRec context_state; - - unsigned int dirty; - - /* Maintain an LRU of contiguous regions of texture space. If - * you think you own a region of texture memory, and it has an - * age different to the one you set, then you are mistaken and - * it has been stolen by another client. If global texAge - * hasn't changed, there is no need to walk the list. - * - * These regions can be used as a proxy for the fine-grained - * texture information of other clients - by maintaining them - * in the same lru which is used to age their own textures, - * clients have an approximate lru for the whole of global - * texture space, and can make informed decisions as to which - * areas to kick out. There is no need to choose whether to - * kick out your own texture or someone else's - simply eject - * them all in LRU order. - */ - -#define GAMMA_NR_TEX_REGIONS 64 - GAMMATextureRegionRec texList[GAMMA_NR_TEX_REGIONS+1]; - /* Last elt is sentinal */ - int texAge; /* last time texture was uploaded */ - int last_enqueue; /* last time a buffer was enqueued */ - int last_dispatch; /* age of the most recently dispatched buffer */ - int last_quiescent; /* */ - int ctxOwner; /* last context to upload state */ - - int vertex_prim; -} GLINTSAREADRIRec, *GLINTSAREADRIPtr; - -/* - * Glint specific record passed back to client driver - * via DRIGetDeviceInfo request - */ -typedef struct { - drmRegion registers0; - drmRegion registers1; - drmRegion registers2; - drmRegion registers3; - int numMultiDevices; - int pprod; - int cpp; - int frontOffset; - int frontPitch; - int backOffset; - int backPitch; - int backX; - int backY; - int depthOffset; - int depthPitch; - int textureSize; - int logTextureGranularity; -} GLINTDRIRec, *GLINTDRIPtr; - -#define GLINT_DRI_BUF_COUNT 256 -#define GLINT_DRI_BUF_SIZE 4096 - -#define GAMMA_NR_TEX_REGIONS 64 - -#define DMA_WRITE(val,reg) \ -do { \ - pGlint->buf2D++ = Glint##reg##Tag; \ - pGlint->buf2D++ = val; \ -} while (0) - -#endif /* _GLINT_DRI_H_ */ -- cgit v1.2.3 From 179d2c0e0bcf96fc40107882ccab909af8c89853 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 2 Mar 2010 15:34:17 -0800 Subject: intel: Use drm_intel_bo_alloc_tiled for region allocs. This moves the logic for how to align pitches, heights, and sizes of objects to one central location. Fixes rendering with texture tiling on i915. Note that current libdrm is required for the change for I915_TILING_NONE pitch alignment. --- configure.ac | 2 +- src/mesa/drivers/dri/intel/intel_regions.c | 39 +++++++++--------------------- 2 files changed, 12 insertions(+), 29 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index d108ecdad29..e807d4acaf8 100644 --- a/configure.ac +++ b/configure.ac @@ -804,7 +804,7 @@ AC_SUBST([DRI_LIB_DEPS]) case $DRI_DIRS in *i915*|*i965*) - PKG_CHECK_MODULES([INTEL], [libdrm_intel]) + PKG_CHECK_MODULES([INTEL], [libdrm_intel >= 2.4.19]) ;; esac diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index f63d3a40825..e3c0635e5ba 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -180,36 +180,19 @@ intel_region_alloc(struct intel_context *intel, { dri_bo *buffer; struct intel_region *region; + unsigned long flags = 0; + unsigned long aligned_pitch; - /* If we're tiled, our allocations are in 8 or 32-row blocks, so - * failure to align our height means that we won't allocate enough pages. - * - * If we're untiled, we still have to align to 2 rows high because the - * data port accesses 2x2 blocks even if the bottom row isn't to be - * rendered, so failure to align means we could walk off the end of the - * GTT and fault. - */ - if (tiling == I915_TILING_X) - height = ALIGN(height, 8); - else if (tiling == I915_TILING_Y) - height = ALIGN(height, 32); - else - height = ALIGN(height, 2); - - /* If we're untiled, we have to align to 2 rows high because the - * data port accesses 2x2 blocks even if the bottom row isn't to be - * rendered, so failure to align means we could walk off the end of the - * GTT and fault. + if (expect_accelerated_upload) + flags |= BO_ALLOC_FOR_RENDER; + + buffer = drm_intel_bo_alloc_tiled(intel->bufmgr, "region", + width, height, cpp, + &tiling, &aligned_pitch, flags); + /* We've already chosen a pitch as part of miptree layout. It had + * better be the same. */ - height = ALIGN(height, 2); - - if (expect_accelerated_upload) { - buffer = drm_intel_bo_alloc_for_render(intel->bufmgr, "region", - pitch * cpp * height, 64); - } else { - buffer = drm_intel_bo_alloc(intel->bufmgr, "region", - pitch * cpp * height, 64); - } + assert(aligned_pitch == pitch * cpp); region = intel_region_alloc_internal(intel, cpp, width, height, pitch, buffer); -- cgit v1.2.3 From 9aa3aa71386394725ce88df463d6183f62777ee5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 3 Mar 2010 15:59:37 -0800 Subject: Add version check for GCC Mesa now requires GCC 3.3.0 or later. See the following thread from the mesa3d-dev mailing list for more details: http://marc.info/?t=126748568900005&r=1&w=2 Signed-off-by: Ian Romanick --- configure.ac | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index e807d4acaf8..8ca274932cc 100644 --- a/configure.ac +++ b/configure.ac @@ -46,6 +46,28 @@ solaris*) ;; esac +dnl If we're using GCC, make sure that it is at least version 3.3.0. Older +dnl versions are explictly not supported. +if test "x$GCC" = xyes; then + AC_MSG_CHECKING([whether gcc version is sufficient]) + major=0 + minor=0 + + GCC_VERSION=`$CC -dumpversion` + if test $? -eq 0; then + major=`echo $GCC_VERSION | cut -d. -f1` + minor=`echo $GCC_VERSION | cut -d. -f1` + fi + + if test $major -lt 3 -o $major -eq 3 -a $minor -lt 3 ; then + AC_MSG_RESULT([no]) + AC_MSG_ERROR([If using GCC, version 3.3.0 or later is required.]) + else + AC_MSG_RESULT([yes]) + fi +fi + + MKDEP_OPTIONS=-fdepend dnl Ask gcc where it's keeping its secret headers if test "x$GCC" = xyes; then -- cgit v1.2.3