summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@fedoraproject.org>2007-11-01 06:55:38 +0000
committerDave Airlie <airlied@fedoraproject.org>2007-11-01 06:55:38 +0000
commitdbb9f179ceb517ef64047c80e898f5ff0e01967d (patch)
treefc26a2d0ebfc927dde60ebc7c788f87e30fdfe3f
parent6bb88613c74e3606f38734e815f90e4ef508204f (diff)
downloadmesa-dbb9f179ceb517ef64047c80e898f5ff0e01967d.tar.gz
mesa-dbb9f179ceb517ef64047c80e898f5ff0e01967d.tar.xz
mesa-dbb9f179ceb517ef64047c80e898f5ff0e01967d.zip
- rebase Mesa to 7.1pre 74ced1e67f286a5e71e9877bc6844b2af5b9ab8d
-rw-r--r--.cvsignore4
-rw-r--r--mesa-6.5.2-bindcontext-paranoia.patch11
-rw-r--r--mesa-7.0-build-config.patch231
-rw-r--r--mesa-7.0-selinux-awareness.patch12
-rw-r--r--mesa-7.0-use_master-r300.patch5957
-rw-r--r--mesa-7.0.1-r200-settexoffset.patch243
-rw-r--r--mesa-7.0.1-r300-fix-writemask.patch36
-rw-r--r--mesa-7.0.1-stable-branch.patch4966
-rw-r--r--mesa-7.1-kill-glw.patch40
-rw-r--r--mesa-7.1pre-osmesa-version.patch39
-rw-r--r--mesa.spec30
-rw-r--r--sources4
12 files changed, 108 insertions, 11465 deletions
diff --git a/.cvsignore b/.cvsignore
index 5bf1add..f18d626 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -1,3 +1,3 @@
-MesaLib-7.0.1.tar.bz2
-MesaDemos-7.0.1.tar.bz2
+MesaLib-7.1pre.tar.bz2
+MesaDemos-7.1pre.tar.bz2
gl-manpages-1.0.1.tar.bz2
diff --git a/mesa-6.5.2-bindcontext-paranoia.patch b/mesa-6.5.2-bindcontext-paranoia.patch
deleted file mode 100644
index 9ea40db..0000000
--- a/mesa-6.5.2-bindcontext-paranoia.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- Mesa-6.5.2/src/mesa/drivers/dri/common/dri_util.c.jx 2006-12-02 13:14:16.000000000 -0500
-+++ Mesa-6.5.2/src/mesa/drivers/dri/common/dri_util.c 2007-04-04 12:41:08.000000000 -0400
-@@ -271,6 +271,8 @@
- __DRIdrawablePrivate *prp;
- __DRIcontextPrivate * const pcp = ctx->private;
-
-+ if (!pcp)
-+ return GL_FALSE;
-
- /* Find the _DRIdrawable which corresponds to the writing drawable. */
- pdraw = __driFindDrawable(psp->drawHash, draw);
diff --git a/mesa-7.0-build-config.patch b/mesa-7.0-build-config.patch
deleted file mode 100644
index 0dc466e..0000000
--- a/mesa-7.0-build-config.patch
+++ /dev/null
@@ -1,231 +0,0 @@
-diff -up mesa-20070725/configs/linux.build-config mesa-20070725/configs/linux
---- mesa-20070725/configs/linux.build-config 2007-07-25 09:36:03.000000000 -0400
-+++ mesa-20070725/configs/linux 2007-07-25 10:33:03.000000000 -0400
-@@ -8,7 +8,9 @@ CONFIG_NAME = linux
- CC = gcc
- CXX = g++
-
--OPT_FLAGS = -O3 -g
-+MKDEP = true
-+
-+OPT_FLAGS ?= -O3 -g
- PIC_FLAGS = -fPIC
-
- # Add '-DGLX_USE_TLS' to ARCH_FLAGS to enable TLS support. Add -m32
-diff -up mesa-20070725/configs/linux-indirect.build-config mesa-20070725/configs/linux-indirect
---- mesa-20070725/configs/linux-indirect.build-config 2007-07-25 09:36:03.000000000 -0400
-+++ mesa-20070725/configs/linux-indirect 2007-07-25 10:34:40.000000000 -0400
-@@ -15,7 +15,7 @@ CXX = g++
- #MKDEP_OPTIONS = -MF depend
-
- WARN_FLAGS = -Wall
--OPT_FLAGS = -O -g
-+OPT_FLAGS ?= -O -g
- PIC_FLAGS = -fPIC
-
- # Add '-DGLX_USE_TLS' to ARCH_FLAGS to enable TLS support.
-@@ -44,7 +44,7 @@ GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11
-
-
- # Directories
--SRC_DIRS = glx/x11 glu glut/glx glw
-+SRC_DIRS = glx/x11 glu
- DRIVER_DIRS =
- PROGRAM_DIRS =
- WINDOW_SYSTEM=dri
-diff -up mesa-20070725/configs/linux-dri.build-config mesa-20070725/configs/linux-dri
---- mesa-20070725/configs/linux-dri.build-config 2007-07-25 09:36:03.000000000 -0400
-+++ mesa-20070725/configs/linux-dri 2007-07-25 10:34:31.000000000 -0400
-@@ -12,8 +12,9 @@ CXX = g++
- #MKDEP = /usr/X11R6/bin/makedepend
- #MKDEP = gcc -M
- #MKDEP_OPTIONS = -MF depend
-+MKDEP = true
-
--OPT_FLAGS = -O -g
-+OPT_FLAGS ?= -O -g
- PIC_FLAGS = -fPIC
-
- # Add '-DGLX_USE_TLS' to ARCH_FLAGS to enable TLS support.
-@@ -25,8 +26,6 @@ DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOU
- -DGLX_DIRECT_RENDERING -DGLX_INDIRECT_RENDERING \
- -DHAVE_ALIAS -DHAVE_POSIX_MEMALIGN
-
--X11_INCLUDES = -I/usr/X11R6/include
--
- CFLAGS = -Wall -Wmissing-prototypes -std=c99 -ffast-math \
- $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) $(ASM_FLAGS)
-
-@@ -36,7 +35,7 @@ CXXFLAGS = -Wall $(OPT_FLAGS) $(PIC_FLAG
- ASM_SOURCES =
-
- # Library/program dependencies
--EXTRA_LIB_PATH=-L/usr/X11R6/lib
-+EXTRA_LIB_PATH =
-
- LIBDRM_CFLAGS = `pkg-config --cflags libdrm`
- LIBDRM_LIB = `pkg-config --libs libdrm`
-@@ -54,10 +53,10 @@ USING_EGL=0
-
- # Directories
- ifeq ($(USING_EGL), 1)
--SRC_DIRS = egl glx/x11 mesa glu glut/glx glw
-+SRC_DIRS = egl glx/x11 mesa glu glut/glx
- PROGRAM_DIRS = egl
- else
--SRC_DIRS = glx/x11 mesa glu glut/glx glw
-+SRC_DIRS = glx/x11 mesa glu
- PROGRAM_DIRS =
- endif
-
-@@ -67,4 +66,4 @@ WINDOW_SYSTEM=dri
- # gamma are missing because they have not been converted to use the new
- # interface.
- DRI_DIRS = i810 i915tex i915 i965 mach64 mga r128 r200 r300 radeon s3v \
-- savage sis tdfx trident unichrome ffb
-+ savage tdfx trident unichrome ffb # sis
-diff -up mesa-20070725/configs/linux-dri-x86.build-config mesa-20070725/configs/linux-dri-x86
---- mesa-20070725/configs/linux-dri-x86.build-config 2007-07-25 09:36:03.000000000 -0400
-+++ mesa-20070725/configs/linux-dri-x86 2007-07-25 10:33:03.000000000 -0400
-@@ -6,7 +6,7 @@ include $(TOP)/configs/linux-dri
- CONFIG_NAME = linux-dri-x86
-
- # Unnecessary on x86, generally.
--PIC_FLAGS =
-+# PIC_FLAGS =
-
- # Add -m32 to CFLAGS:
- ARCH_FLAGS = -m32
-diff -up mesa-20070725/configs/default.build-config mesa-20070725/configs/default
---- mesa-20070725/configs/default.build-config 2007-07-25 09:36:03.000000000 -0400
-+++ mesa-20070725/configs/default 2007-07-25 10:34:20.000000000 -0400
-@@ -58,8 +58,8 @@ GLW_SOURCES = GLwDrawA.c
-
-
- # Directories to build
--LIB_DIR = lib
--SRC_DIRS = mesa glu glut/glx glw
-+LIB_DIR ?= lib
-+SRC_DIRS = mesa glu
- GLU_DIRS = sgi
- DRIVER_DIRS = x11 osmesa
- # Which subdirs under $(TOP)/progs/ to enter:
-@@ -72,14 +72,14 @@ GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -l
- OSMESA_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
- GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
- GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lm
--GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lXt -lX11
-+GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lXm $(EXTRA_LIB_PATH) -lXt -lX11
- APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
-
-
-
- # Installation directories (for make install)
- INSTALL_DIR = /usr/local
--DRI_DRIVER_INSTALL_DIR = /usr/X11R6/lib/modules/dri
-+DRI_DRIVER_INSTALL_DIR = $(DRI_DRIVER_DIR)
-
- # Where libGL will look for DRI hardware drivers
- DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR)
-diff -up mesa-20070725/configs/linux-dri-ppc.build-config mesa-20070725/configs/linux-dri-ppc
---- mesa-20070725/configs/linux-dri-ppc.build-config 2007-07-25 09:36:03.000000000 -0400
-+++ mesa-20070725/configs/linux-dri-ppc 2007-07-25 10:33:03.000000000 -0400
-@@ -5,7 +5,7 @@ include $(TOP)/configs/linux-dri
-
- CONFIG_NAME = linux-dri-ppc
-
--OPT_FLAGS = -Os -mcpu=603
-+OPT_FLAGS ?= -Os -mcpu=603
- PIC_FLAGS = -fPIC
-
- ASM_FLAGS = -DUSE_PPC_ASM -DUSE_VMX_ASM
-diff -up mesa-20070725/configs/linux-osmesa16.build-config mesa-20070725/configs/linux-osmesa16
---- mesa-20070725/configs/linux-osmesa16.build-config 2007-07-25 09:36:03.000000000 -0400
-+++ mesa-20070725/configs/linux-osmesa16 2007-07-25 10:33:03.000000000 -0400
-@@ -7,8 +7,10 @@ CONFIG_NAME = linux-osmesa16
- # Compiler and flags
- CC = gcc
- CXX = g++
--CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include -DCHAN_BITS=16 -DDEFAULT_SOFTWARE_DEPTH_BITS=31
--CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
-+DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
-+OPT_FLAGS ?= -O3 -ansi -pendantic -fPIC -ffast-math
-+CFLAGS = $(OPT_FLAGS) $(DEFINES) -DCHAN_BITS=16 -DDEFAULT_SOFTWARE_DEPTH_BITS=31
-+CXXFLAGS = $(OPT_FLAGS) $(DEFINES)
-
-
- # Library names
-@@ -17,12 +19,12 @@ OSMESA_LIB_NAME = libOSMesa16.so
-
-
- # Directories
--SRC_DIRS = mesa glu
-+SRC_DIRS = mesa
- DRIVER_DIRS = osmesa
- PROGRAM_DIRS =
-
-
- # Dependencies
--OSMESA_LIB_DEPS = -lm -lpthread
-+OSMESA_LIB_DEPS = -lm -lpthread -lselinux
- GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
- APP_LIB_DEPS = -lOSMesa16
-diff -up mesa-20070725/configs/linux-osmesa32.build-config mesa-20070725/configs/linux-osmesa32
---- mesa-20070725/configs/linux-osmesa32.build-config 2007-07-25 09:36:03.000000000 -0400
-+++ mesa-20070725/configs/linux-osmesa32 2007-07-25 10:33:03.000000000 -0400
-@@ -7,8 +7,10 @@ CONFIG_NAME = linux-osmesa32
- # Compiler and flags
- CC = gcc
- CXX = g++
--CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include -DCHAN_BITS=32 -DDEFAULT_SOFTWARE_DEPTH_BITS=31
--CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
-+DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
-+OPT_FLAGS ?= -O3 -ansi -pendantic -fPIC -ffast-math
-+CFLAGS = $(OPT_FLAGS) $(DEFINES) -DCHAN_BITS=32 -DDEFAULT_SOFTWARE_DEPTH_BITS=31
-+CXXFLAGS = $(OPT_FLAGS) $(DEFINES)
-
-
- # Library names
-@@ -17,12 +19,12 @@ OSMESA_LIB_NAME = libOSMesa32.so
-
-
- # Directories
--SRC_DIRS = mesa glu
-+SRC_DIRS = mesa
- DRIVER_DIRS = osmesa
- PROGRAM_DIRS =
-
-
- # Dependencies
--OSMESA_LIB_DEPS = -lm -lpthread
-+OSMESA_LIB_DEPS = -lm -lpthread -lselinux
- GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
- APP_LIB_DEPS = -lOSMesa32
-diff -up mesa-20070725/configs/linux-osmesa.build-config mesa-20070725/configs/linux-osmesa
---- mesa-20070725/configs/linux-osmesa.build-config 2007-07-25 09:36:03.000000000 -0400
-+++ mesa-20070725/configs/linux-osmesa 2007-07-25 10:33:03.000000000 -0400
-@@ -9,17 +9,18 @@ CONFIG_NAME = linux-osmesa
- # Compiler and flags
- CC = gcc
- CXX = g++
--CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DPTHREADS
--CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
--
-+DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
-+OPT_FLAGS ?= -O3 -ansi -pendantic -fPIC -ffast-math
-+CFLAGS = $(OPT_FLAGS) $(DEFINES)
-+CXXFLAGS = $(OPT_FLAGS) $(DEFINES)
-
- # Directories
--SRC_DIRS = mesa glu
-+SRC_DIRS = mesa
- DRIVER_DIRS = osmesa
--PROGRAM_DIRS = osdemos
-+PROGRAM_DIRS =
-
-
- # Dependencies
--OSMESA_LIB_DEPS = -lm -lpthread
-+OSMESA_LIB_DEPS = -lm -lpthread -lselinux
- GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
- APP_LIB_DEPS = -lOSMesa -lGLU
diff --git a/mesa-7.0-selinux-awareness.patch b/mesa-7.0-selinux-awareness.patch
index dcce752..ab3e18e 100644
--- a/mesa-7.0-selinux-awareness.patch
+++ b/mesa-7.0-selinux-awareness.patch
@@ -132,3 +132,15 @@ diff -up Mesa-7.0/configs/linux-dri.jx Mesa-7.0/configs/linux-dri
GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
-lm -lpthread -ldl \
$(LIBDRM_LIB)
+diff -up Mesa-7.1pre/progs/osdemos/Makefile.da Mesa-7.1pre/progs/osdemos/Makefile
+--- Mesa-7.1pre/progs/osdemos/Makefile.da 2007-11-01 15:59:52.000000000 +1000
++++ Mesa-7.1pre/progs/osdemos/Makefile 2007-11-01 15:59:57.000000000 +1000
+@@ -5,7 +5,7 @@ include $(TOP)/configs/current
+
+ INCDIR = $(TOP)/include
+
+-OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -lOSMesa $(APP_LIB_DEPS)
++OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -lOSMesa $(APP_LIB_DEPS) -l selinux
+
+ OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa16 -lGLU -lGL $(APP_LIB_DEPS)
+
diff --git a/mesa-7.0-use_master-r300.patch b/mesa-7.0-use_master-r300.patch
deleted file mode 100644
index bf1d568..0000000
--- a/mesa-7.0-use_master-r300.patch
+++ /dev/null
@@ -1,5957 +0,0 @@
-diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile
-index c1d223c..4424896 100644
---- a/src/mesa/drivers/dri/r300/Makefile
-+++ b/src/mesa/drivers/dri/r300/Makefile
-@@ -41,6 +41,7 @@ DRIVER_SOURCES = \
- r300_fragprog.c \
- r300_shader.c \
- r300_emit.c \
-+ r300_swtcl.c \
- $(EGL_SOURCES)
-
- C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES)
-diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
-index d13649d..9eca41f 100644
---- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c
-+++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
-@@ -133,13 +133,15 @@ static void r300PrintStateAtom(r300ContextPtr r300, struct r300_state_atom *stat
- int i;
- int dwords = (*state->check) (r300, state);
-
-- fprintf(stderr, " emit %s/%d/%d\n", state->name, dwords,
-+ fprintf(stderr, " emit %s %d/%d\n", state->name, dwords,
- state->cmd_size);
-
-- if (RADEON_DEBUG & DEBUG_VERBOSE)
-- for (i = 0; i < dwords; i++)
-- fprintf(stderr, " %s[%d]: %08X\n",
-+ if (RADEON_DEBUG & DEBUG_VERBOSE) {
-+ for (i = 0; i < dwords; i++) {
-+ fprintf(stderr, " %s[%d]: %08x\n",
- state->name, i, state->cmd[i]);
-+ }
-+ }
- }
-
- /**
-@@ -148,28 +150,14 @@ static void r300PrintStateAtom(r300ContextPtr r300, struct r300_state_atom *stat
- * The caller must have ensured that there is enough space in the command
- * buffer.
- */
--static __inline__ void r300EmitAtoms(r300ContextPtr r300, GLboolean dirty)
-+static inline void r300EmitAtoms(r300ContextPtr r300, GLboolean dirty)
- {
- struct r300_state_atom *atom;
- uint32_t *dest;
-+ int dwords;
-
- dest = r300->cmdbuf.cmd_buf + r300->cmdbuf.count_used;
-
-- if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
-- foreach(atom, &r300->hw.atomlist) {
-- if ((atom->dirty || r300->hw.all_dirty) == dirty) {
-- int dwords = (*atom->check) (r300, atom);
--
-- if (dwords)
-- r300PrintStateAtom(r300, atom);
-- else
-- fprintf(stderr,
-- " skip state %s\n",
-- atom->name);
-- }
-- }
-- }
--
- /* Emit WAIT */
- *dest = cmdwait(R300_WAIT_3D | R300_WAIT_3D_CLEAN);
- dest++;
-@@ -193,13 +181,20 @@ static __inline__ void r300EmitAtoms(r300ContextPtr r300, GLboolean dirty)
-
- foreach(atom, &r300->hw.atomlist) {
- if ((atom->dirty || r300->hw.all_dirty) == dirty) {
-- int dwords = (*atom->check) (r300, atom);
--
-+ dwords = (*atom->check) (r300, atom);
- if (dwords) {
-+ if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
-+ r300PrintStateAtom(r300, atom);
-+ }
- memcpy(dest, atom->cmd, dwords * 4);
- dest += dwords;
- r300->cmdbuf.count_used += dwords;
- atom->dirty = GL_FALSE;
-+ } else {
-+ if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
-+ fprintf(stderr, " skip state %s\n",
-+ atom->name);
-+ }
- }
- }
- }
-@@ -245,22 +240,28 @@ void r300EmitState(r300ContextPtr r300)
- r300->hw.all_dirty = GL_FALSE;
- }
-
--#define CHECK( NM, COUNT ) \
--static int check_##NM( r300ContextPtr r300, \
-- struct r300_state_atom* atom ) \
--{ \
-- (void) atom; (void) r300; \
-- return (COUNT); \
--}
--
- #define packet0_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->packet0.count)
- #define vpu_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->vpu.count)
-
--CHECK(always, atom->cmd_size)
-- CHECK(variable, packet0_count(atom->cmd) ? (1 + packet0_count(atom->cmd)) : 0)
-- CHECK(vpu, vpu_count(atom->cmd) ? (1 + vpu_count(atom->cmd) * 4) : 0)
--#undef packet0_count
--#undef vpu_count
-+static int check_always(r300ContextPtr r300, struct r300_state_atom *atom)
-+{
-+ return atom->cmd_size;
-+}
-+
-+static int check_variable(r300ContextPtr r300, struct r300_state_atom *atom)
-+{
-+ int cnt;
-+ cnt = packet0_count(atom->cmd);
-+ return cnt ? cnt + 1 : 0;
-+}
-+
-+static int check_vpu(r300ContextPtr r300, struct r300_state_atom *atom)
-+{
-+ int cnt;
-+ cnt = vpu_count(atom->cmd);
-+ return cnt ? (cnt * 4) + 1 : 0;
-+}
-+
- #define ALLOC_STATE( ATOM, CHK, SZ, IDX ) \
- do { \
- r300->hw.ATOM.cmd_size = (SZ); \
-@@ -318,10 +319,14 @@ void r300InitCmdBuf(r300ContextPtr r300)
- r300->hw.unk21DC.cmd[0] = cmdpacket0(0x21DC, 1);
- ALLOC_STATE(unk221C, always, 2, 0);
- r300->hw.unk221C.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_221C, 1);
-- ALLOC_STATE(unk2220, always, 5, 0);
-- r300->hw.unk2220.cmd[0] = cmdpacket0(0x2220, 4);
-- ALLOC_STATE(unk2288, always, 2, 0);
-- r300->hw.unk2288.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_2288, 1);
-+ ALLOC_STATE(vap_clip, always, 5, 0);
-+ r300->hw.vap_clip.cmd[0] = cmdpacket0(R300_VAP_CLIP_X_0, 4);
-+
-+ if (has_tcl) {
-+ ALLOC_STATE(unk2288, always, 2, 0);
-+ r300->hw.unk2288.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_2288, 1);
-+ }
-+
- ALLOC_STATE(vof, always, R300_VOF_CMDSIZE, 0);
- r300->hw.vof.cmd[R300_VOF_CMD_0] =
- cmdpacket0(R300_VAP_OUTPUT_VTX_FMT_0, 2);
-diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.h b/src/mesa/drivers/dri/r300/r300_cmdbuf.h
-index bfb2eda..acb6e38 100644
---- a/src/mesa/drivers/dri/r300/r300_cmdbuf.h
-+++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.h
-@@ -52,7 +52,7 @@ extern void r300DestroyCmdBuf(r300ContextPtr r300);
- *
- * \param dwords The number of dwords we need to be free on the command buffer
- */
--static __inline__ void r300EnsureCmdBufSpace(r300ContextPtr r300,
-+static inline void r300EnsureCmdBufSpace(r300ContextPtr r300,
- int dwords, const char *caller)
- {
- assert(dwords < r300->cmdbuf.size);
-@@ -68,7 +68,7 @@ static __inline__ void r300EnsureCmdBufSpace(r300ContextPtr r300,
- * causes state reemission after a flush. This is necessary to ensure
- * correct hardware state after an unlock.
- */
--static __inline__ uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
-+static inline uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
- int dwords, const char *caller)
- {
- uint32_t *ptr;
-@@ -80,7 +80,7 @@ static __inline__ uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
- return ptr;
- }
-
--static __inline__ uint32_t *r300AllocCmdBuf(r300ContextPtr r300,
-+static inline uint32_t *r300AllocCmdBuf(r300ContextPtr r300,
- int dwords, const char *caller)
- {
- uint32_t *ptr;
-diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c
-index 9ea14ab..14e0f05 100644
---- a/src/mesa/drivers/dri/r300/r300_context.c
-+++ b/src/mesa/drivers/dri/r300/r300_context.c
-@@ -63,6 +63,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- #include "r300_ioctl.h"
- #include "r300_tex.h"
- #include "r300_emit.h"
-+#include "r300_swtcl.h"
-
- #ifdef USER_BUFFERS
- #include "r300_mem.h"
-@@ -317,15 +318,17 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
- _tnl_allow_vertex_fog(ctx, GL_TRUE);
-
- /* currently bogus data */
-- ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4;
-- ctx->Const.VertexProgram.MaxNativeInstructions =
-- VSF_MAX_FRAGMENT_LENGTH / 4;
-- ctx->Const.VertexProgram.MaxNativeAttribs = 16; /* r420 */
-- ctx->Const.VertexProgram.MaxTemps = 32;
-- ctx->Const.VertexProgram.MaxNativeTemps =
-- /*VSF_MAX_FRAGMENT_TEMPS */ 32;
-- ctx->Const.VertexProgram.MaxNativeParameters = 256; /* r420 */
-- ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;
-+ if (screen->chip_flags & RADEON_CHIPSET_TCL) {
-+ ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4;
-+ ctx->Const.VertexProgram.MaxNativeInstructions =
-+ VSF_MAX_FRAGMENT_LENGTH / 4;
-+ ctx->Const.VertexProgram.MaxNativeAttribs = 16; /* r420 */
-+ ctx->Const.VertexProgram.MaxTemps = 32;
-+ ctx->Const.VertexProgram.MaxNativeTemps =
-+ /*VSF_MAX_FRAGMENT_TEMPS */ 32;
-+ ctx->Const.VertexProgram.MaxNativeParameters = 256; /* r420 */
-+ ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;
-+ }
-
- ctx->Const.FragmentProgram.MaxNativeTemps = PFS_NUM_TEMP_REGS;
- ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* copy i915... */
-@@ -363,6 +366,8 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
- radeonInitSpanFuncs(ctx);
- r300InitCmdBuf(r300);
- r300InitState(r300);
-+ if (!(screen->chip_flags & RADEON_CHIPSET_TCL))
-+ r300InitSwtcl(ctx);
-
- TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
-
-diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
-index 4149867..be69097 100644
---- a/src/mesa/drivers/dri/r300/r300_context.h
-+++ b/src/mesa/drivers/dri/r300/r300_context.h
-@@ -49,8 +49,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- #define USER_BUFFERS
-
--//#define OPTIMIZE_ELTS
--
- struct r300_context;
- typedef struct r300_context r300ContextRec;
- typedef struct r300_context *r300ContextPtr;
-@@ -80,7 +78,7 @@ typedef struct r300_context *r300ContextPtr;
- /**
- * This function takes a float and packs it into a uint32_t
- */
--static __inline__ uint32_t r300PackFloat32(float fl)
-+static inline uint32_t r300PackFloat32(float fl)
- {
- union {
- float fl;
-@@ -97,7 +95,7 @@ static __inline__ uint32_t r300PackFloat32(float fl)
- * But it works for most things. I'll fix it later if someone
- * else with a better clue doesn't
- */
--static __inline__ uint32_t r300PackFloat24(float f)
-+static inline uint32_t r300PackFloat24(float f)
- {
- float mantissa;
- int exponent;
-@@ -149,7 +147,6 @@ struct r300_dma_region {
- int aos_offset; /* address in GART memory */
- int aos_stride; /* distance between elements, in dwords */
- int aos_size; /* number of components (1-4) */
-- int aos_reg; /* VAP register assignment */
- };
-
- struct r300_dma {
-@@ -455,7 +452,7 @@ struct r300_hw_state {
- struct r300_state_atom vic; /* vap input control (2180) */
- struct r300_state_atom unk21DC; /* (21DC) */
- struct r300_state_atom unk221C; /* (221C) */
-- struct r300_state_atom unk2220; /* (2220) */
-+ struct r300_state_atom vap_clip;
- struct r300_state_atom unk2288; /* (2288) */
- struct r300_state_atom pvs; /* pvs_cntl (22D0) */
- struct r300_state_atom gb_enable; /* (4008) */
-@@ -571,38 +568,21 @@ struct r300_vertex_shader_fragment {
- union {
- GLuint d[VSF_MAX_FRAGMENT_LENGTH];
- float f[VSF_MAX_FRAGMENT_LENGTH];
-- VERTEX_SHADER_INSTRUCTION i[VSF_MAX_FRAGMENT_LENGTH / 4];
-+ GLuint i[VSF_MAX_FRAGMENT_LENGTH];
- } body;
- };
-
--#define VSF_DEST_PROGRAM 0x0
--#define VSF_DEST_MATRIX0 0x200
--#define VSF_DEST_MATRIX1 0x204
--#define VSF_DEST_MATRIX2 0x208
--#define VSF_DEST_VECTOR0 0x20c
--#define VSF_DEST_VECTOR1 0x20d
--#define VSF_DEST_UNKNOWN1 0x400
--#define VSF_DEST_UNKNOWN2 0x406
--
- struct r300_vertex_shader_state {
- struct r300_vertex_shader_fragment program;
--
-- struct r300_vertex_shader_fragment unknown1;
-- struct r300_vertex_shader_fragment unknown2;
--
-- int program_start;
-- int unknown_ptr1; /* pointer within program space */
-- int program_end;
--
-- int param_offset;
-- int param_count;
--
-- int unknown_ptr2; /* pointer within program space */
-- int unknown_ptr3; /* pointer within program space */
- };
-
- extern int hw_tcl_on;
-
-+#define COLOR_IS_RGBA
-+#define TAG(x) r300##x
-+#include "tnl_dd/t_dd_vertex.h"
-+#undef TAG
-+
- //#define CURRENT_VERTEX_SHADER(ctx) (ctx->VertexProgram._Current)
- #define CURRENT_VERTEX_SHADER(ctx) (R300_CONTEXT(ctx)->selected_vp)
-
-@@ -783,37 +763,10 @@ struct r300_fragment_program {
-
- #define R300_MAX_AOS_ARRAYS 16
-
--#define AOS_FORMAT_USHORT 0
--#define AOS_FORMAT_FLOAT 1
--#define AOS_FORMAT_UBYTE 2
--#define AOS_FORMAT_FLOAT_COLOR 3
--
- #define REG_COORDS 0
- #define REG_COLOR0 1
- #define REG_TEX0 2
-
--struct dt {
-- GLint size;
-- GLenum type;
-- GLsizei stride;
-- void *data;
--};
--
--struct radeon_vertex_buffer {
-- int Count;
-- void *Elts;
-- int elt_size;
-- int elt_min, elt_max; /* debug */
--
-- struct dt AttribPtr[VERT_ATTRIB_MAX];
--
-- const struct _mesa_prim *Primitive;
-- GLuint PrimitiveCount;
-- GLint LockFirst;
-- GLsizei LockCount;
-- int lock_uptodate;
--};
--
- struct r300_state {
- struct r300_depthbuffer_state depth;
- struct r300_texture_state texture;
-@@ -822,18 +775,14 @@ struct r300_state {
- struct r300_pfs_compile_state pfs_compile;
- struct r300_dma_region aos[R300_MAX_AOS_ARRAYS];
- int aos_count;
-- struct radeon_vertex_buffer VB;
-
- GLuint *Elts;
- struct r300_dma_region elt_dma;
-
-- DECLARE_RENDERINPUTS(render_inputs_bitset); /* actual render inputs that R300 was configured for.
-+ struct r300_dma_region swtcl_dma;
-+ DECLARE_RENDERINPUTS(render_inputs_bitset); /* actual render inputs that R300 was configured for.
- They are the same as tnl->render_inputs for fixed pipeline */
-
-- struct {
-- int transform_offset; /* Transform matrix offset, -1 if none */
-- } vap_param; /* vertex processor parameter allocation - tells where to write parameters */
--
- struct r300_stencilbuffer_state stencil;
-
- };
-@@ -842,6 +791,62 @@ struct r300_state {
- #define R300_FALLBACK_TCL 1
- #define R300_FALLBACK_RAST 2
-
-+/* r300_swtcl.c
-+ */
-+struct r300_swtcl_info {
-+ GLuint RenderIndex;
-+
-+ /**
-+ * Size of a hardware vertex. This is calculated when \c ::vertex_attrs is
-+ * installed in the Mesa state vector.
-+ */
-+ GLuint vertex_size;
-+
-+ /**
-+ * Attributes instructing the Mesa TCL pipeline where / how to put vertex
-+ * data in the hardware buffer.
-+ */
-+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
-+
-+ /**
-+ * Number of elements of \c ::vertex_attrs that are actually used.
-+ */
-+ GLuint vertex_attr_count;
-+
-+ /**
-+ * Cached pointer to the buffer where Mesa will store vertex data.
-+ */
-+ GLubyte *verts;
-+
-+ /* Fallback rasterization functions
-+ */
-+ // r200_point_func draw_point;
-+ // r200_line_func draw_line;
-+ // r200_tri_func draw_tri;
-+
-+ GLuint hw_primitive;
-+ GLenum render_primitive;
-+ GLuint numverts;
-+
-+ /**
-+ * Offset of the 4UB color data within a hardware (swtcl) vertex.
-+ */
-+ GLuint coloroffset;
-+
-+ /**
-+ * Offset of the 3UB specular color data within a hardware (swtcl) vertex.
-+ */
-+ GLuint specoffset;
-+
-+ /**
-+ * Should Mesa project vertex data or will the hardware do it?
-+ */
-+ GLboolean needproj;
-+
-+ struct r300_dma_region indexed_verts;
-+};
-+
-+
- /**
- * \brief R300 context structure.
- */
-@@ -880,6 +885,9 @@ struct r300_context {
- GLvector4f *temp_attrib[_TNL_ATTRIB_MAX];
-
- GLboolean disable_lowimpact_fallback;
-+
-+ DECLARE_RENDERINPUTS(tnl_index_bitset); /* index of bits for last tnl_install_attrs */
-+ struct r300_swtcl_info swtcl;
- };
-
- struct r300_buffer_object {
-diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c
-index 2c26069..424bf44 100644
---- a/src/mesa/drivers/dri/r300/r300_emit.c
-+++ b/src/mesa/drivers/dri/r300/r300_emit.c
-@@ -86,16 +86,15 @@ do { \
- } while (0)
- #endif
-
--static void r300EmitVec4(GLcontext * ctx,
-- struct r300_dma_region *rvb,
-+static void r300EmitVec4(GLcontext * ctx, struct r300_dma_region *rvb,
- GLvoid * data, int stride, int count)
- {
- int i;
- int *out = (int *)(rvb->address + rvb->start);
-
- if (RADEON_DEBUG & DEBUG_VERTS)
-- fprintf(stderr, "%s count %d stride %d\n",
-- __FUNCTION__, count, stride);
-+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
-+ __FUNCTION__, count, stride, (void *)out, (void *)data);
-
- if (stride == 4)
- COPY_DWORDS(out, data, count);
-@@ -107,16 +106,15 @@ static void r300EmitVec4(GLcontext * ctx,
- }
- }
-
--static void r300EmitVec8(GLcontext * ctx,
-- struct r300_dma_region *rvb,
-+static void r300EmitVec8(GLcontext * ctx, struct r300_dma_region *rvb,
- GLvoid * data, int stride, int count)
- {
- int i;
- int *out = (int *)(rvb->address + rvb->start);
-
- if (RADEON_DEBUG & DEBUG_VERTS)
-- fprintf(stderr, "%s count %d stride %d\n",
-- __FUNCTION__, count, stride);
-+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
-+ __FUNCTION__, count, stride, (void *)out, (void *)data);
-
- if (stride == 8)
- COPY_DWORDS(out, data, count * 2);
-@@ -129,8 +127,7 @@ static void r300EmitVec8(GLcontext * ctx,
- }
- }
-
--static void r300EmitVec12(GLcontext * ctx,
-- struct r300_dma_region *rvb,
-+static void r300EmitVec12(GLcontext * ctx, struct r300_dma_region *rvb,
- GLvoid * data, int stride, int count)
- {
- int i;
-@@ -152,16 +149,15 @@ static void r300EmitVec12(GLcontext * ctx,
- }
- }
-
--static void r300EmitVec16(GLcontext * ctx,
-- struct r300_dma_region *rvb,
-+static void r300EmitVec16(GLcontext * ctx, struct r300_dma_region *rvb,
- GLvoid * data, int stride, int count)
- {
- int i;
- int *out = (int *)(rvb->address + rvb->start);
-
- if (RADEON_DEBUG & DEBUG_VERTS)
-- fprintf(stderr, "%s count %d stride %d\n",
-- __FUNCTION__, count, stride);
-+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
-+ __FUNCTION__, count, stride, (void *)out, (void *)data);
-
- if (stride == 16)
- COPY_DWORDS(out, data, count * 4);
-@@ -176,32 +172,22 @@ static void r300EmitVec16(GLcontext * ctx,
- }
- }
-
--static void r300EmitVec(GLcontext * ctx,
-- struct r300_dma_region *rvb,
-+static void r300EmitVec(GLcontext * ctx, struct r300_dma_region *rvb,
- GLvoid * data, int size, int stride, int count)
- {
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
-
-- if (RADEON_DEBUG & DEBUG_VERTS)
-- fprintf(stderr, "%s count %d size %d stride %d\n",
-- __FUNCTION__, count, size, stride);
--
-- /* Gets triggered when playing with future_hw_tcl_on ... */
-- //assert(!rvb->buf);
--
- if (stride == 0) {
- r300AllocDmaRegion(rmesa, rvb, size * 4, 4);
- count = 1;
- rvb->aos_offset = GET_START(rvb);
- rvb->aos_stride = 0;
- } else {
-- r300AllocDmaRegion(rmesa, rvb, size * count * 4, 4); /* alignment? */
-+ r300AllocDmaRegion(rmesa, rvb, size * count * 4, 4);
- rvb->aos_offset = GET_START(rvb);
- rvb->aos_stride = size;
- }
-
-- /* Emit the data
-- */
- switch (size) {
- case 1:
- r300EmitVec4(ctx, rvb, data, stride, count);
-@@ -217,95 +203,35 @@ static void r300EmitVec(GLcontext * ctx,
- break;
- default:
- assert(0);
-- _mesa_exit(-1);
-- break;
-- }
--
--}
--
--static GLuint t_type(struct dt *dt)
--{
-- switch (dt->type) {
-- case GL_UNSIGNED_BYTE:
-- return AOS_FORMAT_UBYTE;
-- case GL_SHORT:
-- return AOS_FORMAT_USHORT;
-- case GL_FLOAT:
-- return AOS_FORMAT_FLOAT;
-- default:
-- assert(0);
-- break;
-- }
--
-- return AOS_FORMAT_FLOAT;
--}
--
--static GLuint t_vir0_size(struct dt *dt)
--{
-- switch (dt->type) {
-- case GL_UNSIGNED_BYTE:
-- return 4;
-- case GL_SHORT:
-- return 7;
-- case GL_FLOAT:
-- return dt->size - 1;
-- default:
-- assert(0);
- break;
- }
--
-- return 0;
- }
-
--static GLuint t_aos_size(struct dt *dt)
--{
-- switch (dt->type) {
-- case GL_UNSIGNED_BYTE:
-- return 1;
-- case GL_SHORT:
-- return 2;
-- case GL_FLOAT:
-- return dt->size;
-- default:
-- assert(0);
-- break;
-- }
--
-- return 0;
--}
--
--static GLuint t_vir0(uint32_t * dst, struct dt *dt, int *inputs,
-- GLint * tab, GLuint nr)
-+static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
-+ int *inputs, GLint * tab, GLuint nr)
- {
- GLuint i, dw;
-
-+ /* type, inputs, stop bit, size */
- for (i = 0; i + 1 < nr; i += 2) {
-- dw = t_vir0_size(&dt[tab[i]]) | (inputs[tab[i]] << 8) |
-- (t_type(&dt[tab[i]]) << 14);
-- dw |=
-- (t_vir0_size(&dt[tab[i + 1]]) |
-- (inputs[tab[i + 1]] << 8) | (t_type(&dt[tab[i + 1]])
-- << 14)) << 16;
--
-+ dw = R300_INPUT_ROUTE_FLOAT | (inputs[tab[i]] << 8) | (attribptr[tab[i]]->size - 1);
-+ dw |= (R300_INPUT_ROUTE_FLOAT | (inputs[tab[i + 1]] << 8) | (attribptr[tab[i + 1]]->size - 1)) << 16;
- if (i + 2 == nr) {
-- dw |= (1 << (13 + 16));
-+ dw |= (R300_VAP_INPUT_ROUTE_END << 16);
- }
- dst[i >> 1] = dw;
- }
-
- if (nr & 1) {
-- dw = t_vir0_size(&dt[tab[nr - 1]]) | (inputs[tab[nr - 1]]
-- << 8) |
-- (t_type(&dt[tab[nr - 1]]) << 14);
-- dw |= 1 << 13;
--
-+ dw = R300_INPUT_ROUTE_FLOAT | (inputs[tab[nr - 1]] << 8) | (attribptr[tab[nr - 1]]->size - 1);
-+ dw |= R300_VAP_INPUT_ROUTE_END;
- dst[nr >> 1] = dw;
- }
-
- return (nr + 1) >> 1;
- }
-
--static GLuint t_swizzle(int swizzle[4])
-+static GLuint r300VAPInputRoute1Swizzle(int swizzle[4])
- {
- return (swizzle[0] << R300_INPUT_ROUTE_X_SHIFT) |
- (swizzle[1] << R300_INPUT_ROUTE_Y_SHIFT) |
-@@ -313,32 +239,32 @@ static GLuint t_swizzle(int swizzle[4])
- (swizzle[3] << R300_INPUT_ROUTE_W_SHIFT);
- }
-
--static GLuint t_vir1(uint32_t * dst, int swizzle[][4], GLuint nr)
-+GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr)
- {
- GLuint i;
-
- for (i = 0; i + 1 < nr; i += 2) {
-- dst[i >> 1] = t_swizzle(swizzle[i]) | R300_INPUT_ROUTE_ENABLE;
-- dst[i >> 1] |=
-- (t_swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE)
-- << 16;
-+ dst[i >> 1] = r300VAPInputRoute1Swizzle(swizzle[i]) | R300_INPUT_ROUTE_ENABLE;
-+ dst[i >> 1] |= (r300VAPInputRoute1Swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE) << 16;
- }
-
-- if (nr & 1)
-- dst[nr >> 1] =
-- t_swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE;
-+ if (nr & 1) {
-+ dst[nr >> 1] = r300VAPInputRoute1Swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE;
-+ }
-
- return (nr + 1) >> 1;
- }
-
--static GLuint t_emit_size(struct dt *dt)
-+GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead)
- {
-- return dt->size;
-+ /* No idea what this value means. I have seen other values written to
-+ * this register... */
-+ return 0x5555;
- }
-
--static GLuint t_vic(GLcontext * ctx, GLuint InputsRead)
-+GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead)
- {
-- r300ContextPtr r300 = R300_CONTEXT(ctx);
-+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
- GLuint i, vic_1 = 0;
-
- if (InputsRead & (1 << VERT_ATTRIB_POS))
-@@ -350,177 +276,188 @@ static GLuint t_vic(GLcontext * ctx, GLuint InputsRead)
- if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
- vic_1 |= R300_INPUT_CNTL_COLOR;
-
-- r300->state.texture.tc_count = 0;
-+ rmesa->state.texture.tc_count = 0;
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
- if (InputsRead & (1 << (VERT_ATTRIB_TEX0 + i))) {
-- r300->state.texture.tc_count++;
-+ rmesa->state.texture.tc_count++;
- vic_1 |= R300_INPUT_CNTL_TC0 << i;
- }
-
- return vic_1;
- }
-
-+GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten)
-+{
-+ GLuint ret = 0;
-+
-+ if (OutputsWritten & (1 << VERT_RESULT_HPOS))
-+ ret |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
-+
-+ if (OutputsWritten & (1 << VERT_RESULT_COL0))
-+ ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
-+
-+ if (OutputsWritten & (1 << VERT_RESULT_COL1))
-+ ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
-+
-+ if (OutputsWritten & (1 << VERT_RESULT_BFC0)
-+ || OutputsWritten & (1 << VERT_RESULT_BFC1))
-+ ret |=
-+ R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT |
-+ R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT |
-+ R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;
-+
-+#if 0
-+ if (OutputsWritten & (1 << VERT_RESULT_FOGC)) ;
-+#endif
-+
-+ if (OutputsWritten & (1 << VERT_RESULT_PSIZ))
-+ ret |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
-+
-+ return ret;
-+}
-+
-+GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten)
-+{
-+ GLuint i, ret = 0;
-+
-+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-+ if (OutputsWritten & (1 << (VERT_RESULT_TEX0 + i))) {
-+ ret |= (4 << (3 * i));
-+ }
-+ }
-+
-+ return ret;
-+}
-+
- /* Emit vertex data to GART memory
- * Route inputs to the vertex processor
- * This function should never return R300_FALLBACK_TCL when using software tcl.
- */
--
- int r300EmitArrays(GLcontext * ctx)
- {
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
-- r300ContextPtr r300 = rmesa;
-- struct radeon_vertex_buffer *VB = &rmesa->state.VB;
-+ TNLcontext *tnl = TNL_CONTEXT(ctx);
-+ struct vertex_buffer *vb = &tnl->vb;
- GLuint nr;
-- GLuint count = VB->Count;
-+ GLuint count = vb->Count;
- GLuint i;
- GLuint InputsRead = 0, OutputsWritten = 0;
- int *inputs = NULL;
- int vir_inputs[VERT_ATTRIB_MAX];
- GLint tab[VERT_ATTRIB_MAX];
- int swizzle[VERT_ATTRIB_MAX][4];
-+ struct r300_vertex_program *prog =
-+ (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
-
- if (hw_tcl_on) {
-- struct r300_vertex_program *prog =
-- (struct r300_vertex_program *)
-- CURRENT_VERTEX_SHADER(ctx);
- inputs = prog->inputs;
-- InputsRead = CURRENT_VERTEX_SHADER(ctx)->key.InputsRead;
-- OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->key.OutputsWritten;
-+ InputsRead = prog->key.InputsRead;
-+ OutputsWritten = prog->key.OutputsWritten;
- } else {
-- DECLARE_RENDERINPUTS(inputs_bitset);
-- inputs = r300->state.sw_tcl_inputs;
-+ inputs = rmesa->state.sw_tcl_inputs;
-+
-+ DECLARE_RENDERINPUTS(render_inputs_bitset);
-+ RENDERINPUTS_COPY(render_inputs_bitset, tnl->render_inputs_bitset);
-
-- RENDERINPUTS_COPY(inputs_bitset,
-- TNL_CONTEXT(ctx)->render_inputs_bitset);
-+ vb->AttribPtr[VERT_ATTRIB_POS] = vb->ClipPtr;
-
-- assert(RENDERINPUTS_TEST(inputs_bitset, _TNL_ATTRIB_POS));
-- InputsRead |= 1 << VERT_ATTRIB_POS;
-- OutputsWritten |= 1 << VERT_RESULT_HPOS;
-+ assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_POS));
-+ assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_NORMAL) == 0);
-+ //assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR0));
-
-- assert(RENDERINPUTS_TEST(inputs_bitset, _TNL_ATTRIB_NORMAL)
-- == 0);
-+ if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_POS)) {
-+ InputsRead |= 1 << VERT_ATTRIB_POS;
-+ OutputsWritten |= 1 << VERT_RESULT_HPOS;
-+ }
-
-- assert(RENDERINPUTS_TEST(inputs_bitset, _TNL_ATTRIB_COLOR0));
-- InputsRead |= 1 << VERT_ATTRIB_COLOR0;
-- OutputsWritten |= 1 << VERT_RESULT_COL0;
-+ if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR0)) {
-+ InputsRead |= 1 << VERT_ATTRIB_COLOR0;
-+ OutputsWritten |= 1 << VERT_RESULT_COL0;
-+ }
-
-- if (RENDERINPUTS_TEST(inputs_bitset, _TNL_ATTRIB_COLOR1)) {
-+ if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR1)) {
- InputsRead |= 1 << VERT_ATTRIB_COLOR1;
- OutputsWritten |= 1 << VERT_RESULT_COL1;
- }
-
-- for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
-- if (RENDERINPUTS_TEST
-- (inputs_bitset, _TNL_ATTRIB_TEX(i))) {
-+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-+ if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_TEX(i))) {
- InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i);
- OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i);
- }
-+ }
-
-- for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++)
-- if (InputsRead & (1 << i))
-+ for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) {
-+ if (InputsRead & (1 << i)) {
- inputs[i] = nr++;
-- else
-+ } else {
- inputs[i] = -1;
--
-- if (!
-- (r300->radeon.radeonScreen->
-- chip_flags & RADEON_CHIPSET_TCL)) {
-- /* Fixed, apply to vir0 only */
-- memcpy(vir_inputs, inputs,
-- VERT_ATTRIB_MAX * sizeof(int));
-- inputs = vir_inputs;
--
-- if (InputsRead & VERT_ATTRIB_POS)
-- inputs[VERT_ATTRIB_POS] = 0;
--
-- if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
-- inputs[VERT_ATTRIB_COLOR0] = 2;
--
-- if (InputsRead & (1 << VERT_ATTRIB_COLOR1))
-- inputs[VERT_ATTRIB_COLOR1] = 3;
--
-- for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++)
-- if (InputsRead & (1 << i))
-- inputs[i] = 6 + (i - VERT_ATTRIB_TEX0);
-+ }
- }
-
-- RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset,
-- inputs_bitset);
-+ /* Fixed, apply to vir0 only */
-+ memcpy(vir_inputs, inputs, VERT_ATTRIB_MAX * sizeof(int));
-+ inputs = vir_inputs;
-+ if (InputsRead & VERT_ATTRIB_POS)
-+ inputs[VERT_ATTRIB_POS] = 0;
-+ if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
-+ inputs[VERT_ATTRIB_COLOR0] = 2;
-+ if (InputsRead & (1 << VERT_ATTRIB_COLOR1))
-+ inputs[VERT_ATTRIB_COLOR1] = 3;
-+ for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++)
-+ if (InputsRead & (1 << i))
-+ inputs[i] = 6 + (i - VERT_ATTRIB_TEX0);
-+
-+ RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset, render_inputs_bitset);
- }
-+
- assert(InputsRead);
- assert(OutputsWritten);
-
-- for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++)
-- if (InputsRead & (1 << i))
-+ for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) {
-+ if (InputsRead & (1 << i)) {
- tab[nr++] = i;
-+ }
-+ }
-
-- if (nr > R300_MAX_AOS_ARRAYS)
-+ if (nr > R300_MAX_AOS_ARRAYS) {
- return R300_FALLBACK_TCL;
-+ }
-
- for (i = 0; i < nr; i++) {
-- int ci;
-- int comp_size, fix, found = 0;
-+ int ci, fix, found = 0;
-
- swizzle[i][0] = SWIZZLE_ZERO;
- swizzle[i][1] = SWIZZLE_ZERO;
- swizzle[i][2] = SWIZZLE_ZERO;
- swizzle[i][3] = SWIZZLE_ONE;
-
-- for (ci = 0; ci < VB->AttribPtr[tab[i]].size; ci++)
-+ for (ci = 0; ci < vb->AttribPtr[tab[i]]->size; ci++) {
- swizzle[i][ci] = ci;
--
--#if MESA_BIG_ENDIAN
--#define SWAP_INT(a, b) do { \
-- int __temp; \
-- __temp = a;\
-- a = b; \
-- b = __temp; \
--} while (0)
--
-- if (VB->AttribPtr[tab[i]].type == GL_UNSIGNED_BYTE) {
-- SWAP_INT(swizzle[i][0], swizzle[i][3]);
-- SWAP_INT(swizzle[i][1], swizzle[i][2]);
- }
--#endif /* MESA_BIG_ENDIAN */
-
-- if (r300IsGartMemory(rmesa, VB->AttribPtr[tab[i]].data,
-- /*(count-1)*stride */ 4)) {
-- if (VB->AttribPtr[tab[i]].stride % 4)
-+ if (r300IsGartMemory(rmesa, vb->AttribPtr[tab[i]]->data, 4)) {
-+ if (vb->AttribPtr[tab[i]]->stride % 4) {
- return R300_FALLBACK_TCL;
--
-- rmesa->state.aos[i].address =
-- VB->AttribPtr[tab[i]].data;
-+ }
-+ rmesa->state.aos[i].address = (void *)(vb->AttribPtr[tab[i]]->data);
- rmesa->state.aos[i].start = 0;
-- rmesa->state.aos[i].aos_offset =
-- r300GartOffsetFromVirtual(rmesa,
-- VB->
-- AttribPtr[tab[i]].data);
-- rmesa->state.aos[i].aos_stride =
-- VB->AttribPtr[tab[i]].stride / 4;
--
-- rmesa->state.aos[i].aos_size =
-- t_emit_size(&VB->AttribPtr[tab[i]]);
-+ rmesa->state.aos[i].aos_offset = r300GartOffsetFromVirtual(rmesa, vb->AttribPtr[tab[i]]->data);
-+ rmesa->state.aos[i].aos_stride = vb->AttribPtr[tab[i]]->stride / 4;
-+ rmesa->state.aos[i].aos_size = vb->AttribPtr[tab[i]]->size;
- } else {
-- /* TODO: r300EmitVec can only handle 4 byte vectors */
-- if (VB->AttribPtr[tab[i]].type != GL_FLOAT)
-- return R300_FALLBACK_TCL;
--
- r300EmitVec(ctx, &rmesa->state.aos[i],
-- VB->AttribPtr[tab[i]].data,
-- t_emit_size(&VB->AttribPtr[tab[i]]),
-- VB->AttribPtr[tab[i]].stride, count);
-+ vb->AttribPtr[tab[i]]->data,
-+ vb->AttribPtr[tab[i]]->size,
-+ vb->AttribPtr[tab[i]]->stride, count);
- }
-
-- rmesa->state.aos[i].aos_size =
-- t_aos_size(&VB->AttribPtr[tab[i]]);
--
-- comp_size = _mesa_sizeof_type(VB->AttribPtr[tab[i]].type);
-+ rmesa->state.aos[i].aos_size = vb->AttribPtr[tab[i]]->size;
-
-- for (fix = 0; fix <= 4 - VB->AttribPtr[tab[i]].size; fix++) {
-- if ((rmesa->state.aos[i].aos_offset -
-- comp_size * fix) % 4)
-+ for (fix = 0; fix <= 4 - vb->AttribPtr[tab[i]]->size; fix++) {
-+ if ((rmesa->state.aos[i].aos_offset - _mesa_sizeof_type(GL_FLOAT) * fix) % 4) {
- continue;
--
-+ }
- found = 1;
- break;
- }
-@@ -529,70 +466,41 @@ int r300EmitArrays(GLcontext * ctx)
- if (fix > 0) {
- WARN_ONCE("Feeling lucky?\n");
- }
--
-- rmesa->state.aos[i].aos_offset -= comp_size * fix;
--
-- for (ci = 0; ci < VB->AttribPtr[tab[i]].size; ci++)
-+ rmesa->state.aos[i].aos_offset -= _mesa_sizeof_type(GL_FLOAT) * fix;
-+ for (ci = 0; ci < vb->AttribPtr[tab[i]]->size; ci++) {
- swizzle[i][ci] += fix;
-+ }
- } else {
- WARN_ONCE
- ("Cannot handle offset %x with stride %d, comp %d\n",
- rmesa->state.aos[i].aos_offset,
- rmesa->state.aos[i].aos_stride,
-- VB->AttribPtr[tab[i]].size);
-+ vb->AttribPtr[tab[i]]->size);
- return R300_FALLBACK_TCL;
- }
- }
-
-- /* setup INPUT_ROUTE */
-- R300_STATECHANGE(r300, vir[0]);
-- ((drm_r300_cmd_header_t *) r300->hw.vir[0].cmd)->packet0.count =
-- t_vir0(&r300->hw.vir[0].cmd[R300_VIR_CNTL_0], VB->AttribPtr,
-- inputs, tab, nr);
--
-- R300_STATECHANGE(r300, vir[1]);
-- ((drm_r300_cmd_header_t *) r300->hw.vir[1].cmd)->packet0.count =
-- t_vir1(&r300->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle, nr);
--
-- /* Set up input_cntl */
-- /* I don't think this is needed for vertex buffers, but it doesn't hurt anything */
-- R300_STATECHANGE(r300, vic);
-- r300->hw.vic.cmd[R300_VIC_CNTL_0] = 0x5555; /* Hard coded value, no idea what it means */
-- r300->hw.vic.cmd[R300_VIC_CNTL_1] = t_vic(ctx, InputsRead);
--
-- /* Stage 3: VAP output */
--
-- R300_STATECHANGE(r300, vof);
--
-- r300->hw.vof.cmd[R300_VOF_CNTL_0] = 0;
-- r300->hw.vof.cmd[R300_VOF_CNTL_1] = 0;
--
-- if (OutputsWritten & (1 << VERT_RESULT_HPOS))
-- r300->hw.vof.cmd[R300_VOF_CNTL_0] |=
-- R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
--
-- if (OutputsWritten & (1 << VERT_RESULT_COL0))
-- r300->hw.vof.cmd[R300_VOF_CNTL_0] |=
-- R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
--
-- if (OutputsWritten & (1 << VERT_RESULT_COL1))
-- r300->hw.vof.cmd[R300_VOF_CNTL_0] |=
-- R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
--
-- /*if(OutputsWritten & (1 << VERT_RESULT_BFC0))
-- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT;
--
-- if(OutputsWritten & (1 << VERT_RESULT_BFC1))
-- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT; */
-- //if(OutputsWritten & (1 << VERT_RESULT_FOGC))
--
-- if (OutputsWritten & (1 << VERT_RESULT_PSIZ))
-- r300->hw.vof.cmd[R300_VOF_CNTL_0] |=
-- R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
--
-- for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
-- if (OutputsWritten & (1 << (VERT_RESULT_TEX0 + i)))
-- r300->hw.vof.cmd[R300_VOF_CNTL_1] |= (4 << (3 * i));
-+ /* Setup INPUT_ROUTE. */
-+ R300_STATECHANGE(rmesa, vir[0]);
-+ ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count =
-+ r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0],
-+ vb->AttribPtr, inputs, tab, nr);
-+ R300_STATECHANGE(rmesa, vir[1]);
-+ ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count =
-+ r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle,
-+ nr);
-+
-+ /* Setup INPUT_CNTL. */
-+ R300_STATECHANGE(rmesa, vic);
-+ rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead);
-+ rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead);
-+
-+ /* Setup OUTPUT_VTX_FMT. */
-+ R300_STATECHANGE(rmesa, vof);
-+ rmesa->hw.vof.cmd[R300_VOF_CNTL_0] =
-+ r300VAPOutputCntl0(ctx, OutputsWritten);
-+ rmesa->hw.vof.cmd[R300_VOF_CNTL_1] =
-+ r300VAPOutputCntl1(ctx, OutputsWritten);
-
- rmesa->state.aos_count = nr;
-
-@@ -625,3 +533,19 @@ void r300ReleaseArrays(GLcontext * ctx)
- r300ReleaseDmaRegion(rmesa, &rmesa->state.aos[i], __FUNCTION__);
- }
- }
-+
-+void r300EmitCacheFlush(r300ContextPtr rmesa)
-+{
-+ int cmd_reserved = 0;
-+ int cmd_written = 0;
-+
-+ drm_radeon_cmd_header_t *cmd = NULL;
-+
-+ reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
-+ e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
-+
-+ reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
-+ e32(R300_RB3D_ZCACHE_UNKNOWN_03);
-+
-+
-+}
-diff --git a/src/mesa/drivers/dri/r300/r300_emit.h b/src/mesa/drivers/dri/r300/r300_emit.h
-index 7be098f..a6d69ec 100644
---- a/src/mesa/drivers/dri/r300/r300_emit.h
-+++ b/src/mesa/drivers/dri/r300/r300_emit.h
-@@ -44,22 +44,13 @@
- #include "r300_cmdbuf.h"
- #include "radeon_reg.h"
-
--/*
-- * CP type-3 packets
-- */
--#define RADEON_CP_PACKET3_UNK1B 0xC0001B00
--#define RADEON_CP_PACKET3_INDX_BUFFER 0xC0003300
--#define RADEON_CP_PACKET3_3D_DRAW_VBUF_2 0xC0003400
--#define RADEON_CP_PACKET3_3D_DRAW_IMMD_2 0xC0003500
--#define RADEON_CP_PACKET3_3D_DRAW_INDX_2 0xC0003600
--#define RADEON_CP_PACKET3_3D_LOAD_VBPNTR 0xC0002F00
--#define RADEON_CP_PACKET3_3D_CLEAR_ZMASK 0xC0003202
--#define RADEON_CP_PACKET3_3D_CLEAR_CMASK 0xC0003802
--#define RADEON_CP_PACKET3_3D_CLEAR_HIZ 0xC0003702
--
-+/* TODO: move these defines (and the ones from DRM) into r300_reg.h and sync up
-+ * with DRM */
- #define CP_PACKET0(reg, n) (RADEON_CP_PACKET0 | ((n)<<16) | ((reg)>>2))
-+#define CP_PACKET3( pkt, n ) \
-+ (RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
-
--static __inline__ uint32_t cmdpacket0(int reg, int count)
-+static inline uint32_t cmdpacket0(int reg, int count)
- {
- drm_r300_cmd_header_t cmd;
-
-@@ -71,7 +62,7 @@ static __inline__ uint32_t cmdpacket0(int reg, int count)
- return cmd.u;
- }
-
--static __inline__ uint32_t cmdvpu(int addr, int count)
-+static inline uint32_t cmdvpu(int addr, int count)
- {
- drm_r300_cmd_header_t cmd;
-
-@@ -83,7 +74,7 @@ static __inline__ uint32_t cmdvpu(int addr, int count)
- return cmd.u;
- }
-
--static __inline__ uint32_t cmdpacket3(int packet)
-+static inline uint32_t cmdpacket3(int packet)
- {
- drm_r300_cmd_header_t cmd;
-
-@@ -93,7 +84,7 @@ static __inline__ uint32_t cmdpacket3(int packet)
- return cmd.u;
- }
-
--static __inline__ uint32_t cmdcpdelay(unsigned short count)
-+static inline uint32_t cmdcpdelay(unsigned short count)
- {
- drm_r300_cmd_header_t cmd;
-
-@@ -103,7 +94,7 @@ static __inline__ uint32_t cmdcpdelay(unsigned short count)
- return cmd.u;
- }
-
--static __inline__ uint32_t cmdwait(unsigned char flags)
-+static inline uint32_t cmdwait(unsigned char flags)
- {
- drm_r300_cmd_header_t cmd;
-
-@@ -113,7 +104,7 @@ static __inline__ uint32_t cmdwait(unsigned char flags)
- return cmd.u;
- }
-
--static __inline__ uint32_t cmdpacify(void)
-+static inline uint32_t cmdpacify(void)
- {
- drm_r300_cmd_header_t cmd;
-
-@@ -234,5 +225,15 @@ void r300UseArrays(GLcontext * ctx);
- #endif
-
- extern void r300ReleaseArrays(GLcontext * ctx);
-+extern int r300PrimitiveType(r300ContextPtr rmesa, int prim);
-+extern int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim);
-+
-+extern void r300EmitCacheFlush(r300ContextPtr rmesa);
-+
-+extern GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr);
-+extern GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead);
-+extern GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead);
-+extern GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten);
-+extern GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten);
-
- #endif
-diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c
-index 416ea7f..90f5027 100644
---- a/src/mesa/drivers/dri/r300/r300_ioctl.c
-+++ b/src/mesa/drivers/dri/r300/r300_ioctl.c
-@@ -172,11 +172,7 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
- cmd2[7].u = r300PackFloat32(ctx->Color.ClearColor[2]);
- cmd2[8].u = r300PackFloat32(ctx->Color.ClearColor[3]);
-
-- reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
-- e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
--
-- reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
-- e32(R300_RB3D_ZCACHE_UNKNOWN_03);
-+ r300EmitCacheFlush(rmesa);
- cp_wait(rmesa, R300_WAIT_3D | R300_WAIT_3D_CLEAN);
- }
-
-@@ -224,25 +220,23 @@ static void r300EmitClearState(GLcontext * ctx)
- e32(R300_INPUT_CNTL_0_COLOR);
- e32(R300_INPUT_CNTL_POS | R300_INPUT_CNTL_COLOR | R300_INPUT_CNTL_TC0);
-
-- if (!has_tcl) {
-- R300_STATECHANGE(r300, vte);
-- /* comes from fglrx startup of clear */
-- reg_start(R300_SE_VTE_CNTL, 1);
-- e32(R300_VTX_W0_FMT | R300_VPORT_X_SCALE_ENA |
-- R300_VPORT_X_OFFSET_ENA | R300_VPORT_Y_SCALE_ENA |
-- R300_VPORT_Y_OFFSET_ENA | R300_VPORT_Z_SCALE_ENA |
-- R300_VPORT_Z_OFFSET_ENA);
-- e32(0x8);
--
-- reg_start(0x21dc, 0);
-- e32(0xaaaaaaaa);
-- }
-+ R300_STATECHANGE(r300, vte);
-+ /* comes from fglrx startup of clear */
-+ reg_start(R300_SE_VTE_CNTL, 1);
-+ e32(R300_VTX_W0_FMT | R300_VPORT_X_SCALE_ENA |
-+ R300_VPORT_X_OFFSET_ENA | R300_VPORT_Y_SCALE_ENA |
-+ R300_VPORT_Y_OFFSET_ENA | R300_VPORT_Z_SCALE_ENA |
-+ R300_VPORT_Z_OFFSET_ENA);
-+ e32(0x8);
-+
-+ reg_start(0x21dc, 0);
-+ e32(0xaaaaaaaa);
-
- R300_STATECHANGE(r300, vof);
- reg_start(R300_VAP_OUTPUT_VTX_FMT_0, 1);
- e32(R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT |
- R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT);
-- e32(0x0); /* no textures */
-+ e32(0x0); /* no textures */
-
- R300_STATECHANGE(r300, txe);
- reg_start(R300_TX_ENABLE, 0);
-@@ -414,19 +408,22 @@ static void r300Clear(GLcontext * ctx, GLbitfield mask)
-
- void r300Flush(GLcontext * ctx)
- {
-- r300ContextPtr r300 = R300_CONTEXT(ctx);
-+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
-
- if (RADEON_DEBUG & DEBUG_IOCTL)
- fprintf(stderr, "%s\n", __FUNCTION__);
-
-- if (r300->cmdbuf.count_used > r300->cmdbuf.count_reemit)
-- r300FlushCmdBuf(r300, __FUNCTION__);
-+ if (rmesa->dma.flush)
-+ rmesa->dma.flush( rmesa );
-+
-+ if (rmesa->cmdbuf.count_used > rmesa->cmdbuf.count_reemit)
-+ r300FlushCmdBuf(rmesa, __FUNCTION__);
- }
-
- #ifdef USER_BUFFERS
- #include "r300_mem.h"
-
--static void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size)
-+void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size)
- {
- struct r300_dma_buffer *dmabuf;
- size = MAX2(size, RADEON_BUFFER_SIZE * 16);
-@@ -438,9 +435,12 @@ static void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size)
- rmesa->dma.flush(rmesa);
- }
-
-- if (rmesa->dma.current.buf)
-+ if (rmesa->dma.current.buf) {
-+#ifdef USER_BUFFERS
-+ r300_mem_use(rmesa, rmesa->dma.current.buf->id);
-+#endif
- r300ReleaseDmaRegion(rmesa, &rmesa->dma.current, __FUNCTION__);
--
-+ }
- if (rmesa->dma.nr_released_bufs > 4)
- r300FlushCmdBuf(rmesa, __FUNCTION__);
-
-diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.h b/src/mesa/drivers/dri/r300/r300_ioctl.h
-index 7a19a2c..e1143fb 100644
---- a/src/mesa/drivers/dri/r300/r300_ioctl.h
-+++ b/src/mesa/drivers/dri/r300/r300_ioctl.h
-@@ -56,4 +56,5 @@ extern void r300AllocDmaRegion(r300ContextPtr rmesa,
-
- extern void r300InitIoctlFuncs(struct dd_function_table *functions);
-
-+extern void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size);
- #endif /* __R300_IOCTL_H__ */
-diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h
-index 0a31f0b..1baa74c 100644
---- a/src/mesa/drivers/dri/r300/r300_reg.h
-+++ b/src/mesa/drivers/dri/r300/r300_reg.h
-@@ -116,6 +116,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
- # define R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT (1<<16) /* GUESS */
-
- #define R300_VAP_OUTPUT_VTX_FMT_1 0x2094
-+ /* each of the following is 3 bits wide, specifies number
-+ of components */
- # define R300_VAP_OUTPUT_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT 0
- # define R300_VAP_OUTPUT_VTX_FMT_1__TEX_1_COMP_CNT_SHIFT 3
- # define R300_VAP_OUTPUT_VTX_FMT_1__TEX_2_COMP_CNT_SHIFT 6
-@@ -280,9 +282,32 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- #define R300_VAP_PVS_UPLOAD_ADDRESS 0x2200
- # define R300_PVS_UPLOAD_PROGRAM 0x00000000
-+/* gap */
- # define R300_PVS_UPLOAD_PARAMETERS 0x00000200
-+/* gap */
-+# define R300_PVS_UPLOAD_CLIP_PLANE0 0x00000400
-+# define R300_PVS_UPLOAD_CLIP_PLANE1 0x00000401
-+# define R300_PVS_UPLOAD_CLIP_PLANE2 0x00000402
-+# define R300_PVS_UPLOAD_CLIP_PLANE3 0x00000403
-+# define R300_PVS_UPLOAD_CLIP_PLANE4 0x00000404
-+# define R300_PVS_UPLOAD_CLIP_PLANE5 0x00000405
- # define R300_PVS_UPLOAD_POINTSIZE 0x00000406
-
-+/*
-+ * These are obsolete defines form r300_context.h, but they might give some
-+ * clues when investigating the addresses further...
-+ */
-+#if 0
-+#define VSF_DEST_PROGRAM 0x0
-+#define VSF_DEST_MATRIX0 0x200
-+#define VSF_DEST_MATRIX1 0x204
-+#define VSF_DEST_MATRIX2 0x208
-+#define VSF_DEST_VECTOR0 0x20c
-+#define VSF_DEST_VECTOR1 0x20d
-+#define VSF_DEST_UNKNOWN1 0x400
-+#define VSF_DEST_UNKNOWN2 0x406
-+#endif
-+
- /* gap */
-
- #define R300_VAP_PVS_UPLOAD_DATA 0x2208
-@@ -299,6 +324,18 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
- # define R300_221C_NORMAL 0x00000000
- # define R300_221C_CLEAR 0x0001C000
-
-+/* These seem to be per-pixel and per-vertex X and Y clipping planes. The first
-+ * plane is per-pixel and the second plane is per-vertex.
-+ *
-+ * This was determined by experimentation alone but I believe it is correct.
-+ *
-+ * These registers are called X_QUAD0_1_FL to X_QUAD0_4_FL by glxtest.
-+ */
-+#define R300_VAP_CLIP_X_0 0x2220
-+#define R300_VAP_CLIP_X_1 0x2224
-+#define R300_VAP_CLIP_Y_0 0x2228
-+#define R300_VAP_CLIP_Y_1 0x2230
-+
- /* gap */
-
- /* Sometimes, END_OF_PKT and 0x2284=0 are the only commands sent between
-@@ -322,13 +359,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
- * The meaning of the two UNKNOWN fields is obviously not known. However,
- * experiments so far have shown that both *must* point to an instruction
- * inside the vertex program, otherwise the GPU locks up.
-+ *
- * fglrx usually sets CNTL_3_UNKNOWN to the end of the program and
-- * CNTL_1_UNKNOWN points to instruction where last write to position takes
-- * place.
-+ * R300_PVS_CNTL_1_POS_END_SHIFT points to instruction where last write to
-+ * position takes place.
-+ *
- * Most likely this is used to ignore rest of the program in cases
- * where group of verts arent visible. For some reason this "section"
- * is sometimes accepted other instruction that have no relationship with
-- *position calculations.
-+ * position calculations.
- */
- #define R300_VAP_PVS_CNTL_1 0x22D0
- # define R300_PVS_CNTL_1_PROGRAM_START_SHIFT 0
-@@ -967,7 +1006,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
- * first node is stored in NODE_2, the second node is stored in NODE_3.
- *
- * Offsets are relative to the master offset from PFS_CNTL_2.
-- * LAST_NODE is set for the last node, and only for the last node.
- */
- #define R300_PFS_NODE_0 0x4610
- #define R300_PFS_NODE_1 0x4614
-@@ -981,7 +1019,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
- # define R300_PFS_NODE_TEX_OFFSET_MASK (31 << 12)
- # define R300_PFS_NODE_TEX_END_SHIFT 17
- # define R300_PFS_NODE_TEX_END_MASK (31 << 17)
--/*# define R300_PFS_NODE_LAST_NODE (1 << 22) */
- # define R300_PFS_NODE_OUTPUT_COLOR (1 << 22)
- # define R300_PFS_NODE_OUTPUT_DEPTH (1 << 23)
-
-@@ -1591,6 +1628,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
- # define R300_EB_UNK1_SHIFT 24
- # define R300_EB_UNK1 (0x80<<24)
- # define R300_EB_UNK2 0x0810
-+#define R300_PACKET3_3D_DRAW_VBUF_2 0x00003400
- #define R300_PACKET3_3D_DRAW_INDX_2 0x00003600
-
- /* END: Packet 3 commands */
-diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c
-index cc13e9a..eee1e80 100644
---- a/src/mesa/drivers/dri/r300/r300_render.c
-+++ b/src/mesa/drivers/dri/r300/r300_render.c
-@@ -45,6 +45,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
- * obviously this does work... Further investigation is needed.
- *
- * \author Nicolai Haehnle <prefect_@gmx.net>
-+ *
-+ * \todo Add immediate implementation back? Perhaps this is useful if there are
-+ * no bugs...
- */
-
- #include "glheader.h"
-@@ -76,7 +79,7 @@ extern int future_hw_tcl_on;
- /**
- * \brief Convert a OpenGL primitive type into a R300 primitive type.
- */
--static int r300PrimitiveType(r300ContextPtr rmesa, GLcontext * ctx, int prim)
-+int r300PrimitiveType(r300ContextPtr rmesa, int prim)
- {
- switch (prim & PRIM_MODE_MASK) {
- case GL_POINTS:
-@@ -116,7 +119,7 @@ static int r300PrimitiveType(r300ContextPtr rmesa, GLcontext * ctx, int prim)
- }
- }
-
--static int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim)
-+int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim)
- {
- int verts_off = 0;
-
-@@ -168,16 +171,13 @@ static int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim)
- return num_verts - verts_off;
- }
-
--static void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts,
-- int elt_size)
-+static void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts)
- {
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- struct r300_dma_region *rvb = &rmesa->state.elt_dma;
- void *out;
-
-- assert(elt_size == 2 || elt_size == 4);
--
-- if (r300IsGartMemory(rmesa, elts, n_elts * elt_size)) {
-+ if (r300IsGartMemory(rmesa, elts, n_elts * 4)) {
- rvb->address = rmesa->radeon.radeonScreen->gartTextures.map;
- rvb->start = ((char *)elts) - rvb->address;
- rvb->aos_offset =
-@@ -189,66 +189,27 @@ static void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts,
- _mesa_exit(-1);
- }
-
-- r300AllocDmaRegion(rmesa, rvb, n_elts * elt_size, elt_size);
-+ r300AllocDmaRegion(rmesa, rvb, n_elts * 4, 4);
- rvb->aos_offset = GET_START(rvb);
-
- out = rvb->address + rvb->start;
-- memcpy(out, elts, n_elts * elt_size);
-+ memcpy(out, elts, n_elts * 4);
- }
-
- static void r300FireEB(r300ContextPtr rmesa, unsigned long addr,
-- int vertex_count, int type, int elt_size)
-+ int vertex_count, int type)
- {
- int cmd_reserved = 0;
- int cmd_written = 0;
- drm_radeon_cmd_header_t *cmd = NULL;
-- unsigned long t_addr;
-- unsigned long magic_1, magic_2;
--
-- assert(elt_size == 2 || elt_size == 4);
--
-- if (addr & (elt_size - 1)) {
-- WARN_ONCE("Badly aligned buffer\n");
-- return;
-- }
-
-- magic_1 = (addr % 32) / 4;
-- t_addr = addr & ~0x1d;
-- magic_2 = (vertex_count + 1 + (t_addr & 0x2)) / 2 + magic_1;
-+ start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_INDX_2, 0), 0);
-+ e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (vertex_count << 16) | type | R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
-
-- start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, 0);
-- if (elt_size == 4) {
-- e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES |
-- (vertex_count << 16) | type |
-- R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
-- } else {
-- e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES |
-- (vertex_count << 16) | type);
-- }
--
-- start_packet3(RADEON_CP_PACKET3_INDX_BUFFER, 2);
--#ifdef OPTIMIZE_ELTS
-- if (elt_size == 4) {
-- e32(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
-- e32(addr);
-- } else {
-- e32(R300_EB_UNK1 | (magic_1 << 16) | R300_EB_UNK2);
-- e32(t_addr);
-- }
--#else
-+ start_packet3(CP_PACKET3(R300_PACKET3_INDX_BUFFER, 2), 2);
- e32(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
- e32(addr);
--#endif
--
-- if (elt_size == 4) {
-- e32(vertex_count);
-- } else {
--#ifdef OPTIMIZE_ELTS
-- e32(magic_2);
--#else
-- e32((vertex_count + 1) / 2);
--#endif
-- }
-+ e32(vertex_count);
- }
-
- static void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset)
-@@ -263,26 +224,23 @@ static void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset)
- fprintf(stderr, "%s: nr=%d, ofs=0x%08x\n", __FUNCTION__, nr,
- offset);
-
-- start_packet3(RADEON_CP_PACKET3_3D_LOAD_VBPNTR, sz - 1);
-+ start_packet3(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, sz - 1), sz - 1);
- e32(nr);
-+
- for (i = 0; i + 1 < nr; i += 2) {
-- e32((rmesa->state.aos[i].aos_size << 0)
-- | (rmesa->state.aos[i].aos_stride << 8)
-- | (rmesa->state.aos[i + 1].aos_size << 16)
-- | (rmesa->state.aos[i + 1].aos_stride << 24)
-- );
-- e32(rmesa->state.aos[i].aos_offset +
-- offset * 4 * rmesa->state.aos[i].aos_stride);
-- e32(rmesa->state.aos[i + 1].aos_offset +
-- offset * 4 * rmesa->state.aos[i + 1].aos_stride);
-+ e32((rmesa->state.aos[i].aos_size << 0) |
-+ (rmesa->state.aos[i].aos_stride << 8) |
-+ (rmesa->state.aos[i + 1].aos_size << 16) |
-+ (rmesa->state.aos[i + 1].aos_stride << 24));
-+
-+ e32(rmesa->state.aos[i].aos_offset + offset * 4 * rmesa->state.aos[i].aos_stride);
-+ e32(rmesa->state.aos[i + 1].aos_offset + offset * 4 * rmesa->state.aos[i + 1].aos_stride);
- }
-
- if (nr & 1) {
-- e32((rmesa->state.aos[nr - 1].aos_size << 0)
-- | (rmesa->state.aos[nr - 1].aos_stride << 8)
-- );
-- e32(rmesa->state.aos[nr - 1].aos_offset +
-- offset * 4 * rmesa->state.aos[nr - 1].aos_stride);
-+ e32((rmesa->state.aos[nr - 1].aos_size << 0) |
-+ (rmesa->state.aos[nr - 1].aos_stride << 8));
-+ e32(rmesa->state.aos[nr - 1].aos_offset + offset * 4 * rmesa->state.aos[nr - 1].aos_stride);
- }
- }
-
-@@ -292,130 +250,67 @@ static void r300FireAOS(r300ContextPtr rmesa, int vertex_count, int type)
- int cmd_written = 0;
- drm_radeon_cmd_header_t *cmd = NULL;
-
-- start_packet3(RADEON_CP_PACKET3_3D_DRAW_VBUF_2, 0);
-- e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_count << 16)
-- | type);
-+ start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0), 0);
-+ e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_count << 16) | type);
- }
-
- static void r300RunRenderPrimitive(r300ContextPtr rmesa, GLcontext * ctx,
- int start, int end, int prim)
- {
- int type, num_verts;
-+ TNLcontext *tnl = TNL_CONTEXT(ctx);
-+ struct vertex_buffer *vb = &tnl->vb;
-
-- type = r300PrimitiveType(rmesa, ctx, prim);
-+ type = r300PrimitiveType(rmesa, prim);
- num_verts = r300NumVerts(rmesa, end - start, prim);
-
- if (type < 0 || num_verts <= 0)
- return;
-
-- if (rmesa->state.VB.Elts) {
-+ if (vb->Elts) {
- r300EmitAOS(rmesa, rmesa->state.aos_count, start);
- if (num_verts > 65535) {
- /* not implemented yet */
- WARN_ONCE("Too many elts\n");
- return;
- }
-- r300EmitElts(ctx, rmesa->state.VB.Elts, num_verts,
-- rmesa->state.VB.elt_size);
-- r300FireEB(rmesa, rmesa->state.elt_dma.aos_offset,
-- num_verts, type, rmesa->state.VB.elt_size);
-+ r300EmitElts(ctx, vb->Elts, num_verts);
-+ r300FireEB(rmesa, rmesa->state.elt_dma.aos_offset, num_verts, type);
- } else {
- r300EmitAOS(rmesa, rmesa->state.aos_count, start);
- r300FireAOS(rmesa, num_verts, type);
- }
- }
-
--#define CONV_VB(a, b) rvb->AttribPtr[(a)].size = vb->b->size, \
-- rvb->AttribPtr[(a)].type = GL_FLOAT, \
-- rvb->AttribPtr[(a)].stride = vb->b->stride, \
-- rvb->AttribPtr[(a)].data = vb->b->data
--
--static void radeon_vb_to_rvb(r300ContextPtr rmesa,
-- struct radeon_vertex_buffer *rvb,
-- struct vertex_buffer *vb)
--{
-- int i;
-- GLcontext *ctx;
-- ctx = rmesa->radeon.glCtx;
--
-- memset(rvb, 0, sizeof(*rvb));
--
-- rvb->Elts = vb->Elts;
-- rvb->elt_size = 4;
-- rvb->elt_min = 0;
-- rvb->elt_max = vb->Count;
--
-- rvb->Count = vb->Count;
--
-- if (hw_tcl_on) {
-- CONV_VB(VERT_ATTRIB_POS, ObjPtr);
-- } else {
-- assert(vb->ClipPtr);
-- CONV_VB(VERT_ATTRIB_POS, ClipPtr);
-- }
--
-- CONV_VB(VERT_ATTRIB_NORMAL, NormalPtr);
-- CONV_VB(VERT_ATTRIB_COLOR0, ColorPtr[0]);
-- CONV_VB(VERT_ATTRIB_COLOR1, SecondaryColorPtr[0]);
-- CONV_VB(VERT_ATTRIB_FOG, FogCoordPtr);
--
-- for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
-- CONV_VB(VERT_ATTRIB_TEX0 + i, TexCoordPtr[i]);
--
-- for (i = 0; i < MAX_VERTEX_PROGRAM_ATTRIBS; i++)
-- CONV_VB(VERT_ATTRIB_GENERIC0 + i,
-- AttribPtr[VERT_ATTRIB_GENERIC0 + i]);
--
-- rvb->Primitive = vb->Primitive;
-- rvb->PrimitiveCount = vb->PrimitiveCount;
-- rvb->LockFirst = rvb->LockCount = 0;
-- rvb->lock_uptodate = GL_FALSE;
--}
--
- static GLboolean r300RunRender(GLcontext * ctx,
- struct tnl_pipeline_stage *stage)
- {
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
-- struct radeon_vertex_buffer *VB = &rmesa->state.VB;
- int i;
-- int cmd_reserved = 0;
-- int cmd_written = 0;
-- drm_radeon_cmd_header_t *cmd = NULL;
-+ TNLcontext *tnl = TNL_CONTEXT(ctx);
-+ struct vertex_buffer *vb = &tnl->vb;
-+
-
- if (RADEON_DEBUG & DEBUG_PRIMS)
- fprintf(stderr, "%s\n", __FUNCTION__);
-
-- if (stage) {
-- TNLcontext *tnl = TNL_CONTEXT(ctx);
-- radeon_vb_to_rvb(rmesa, VB, &tnl->vb);
-- }
--
- r300UpdateShaders(rmesa);
- if (r300EmitArrays(ctx))
- return GL_TRUE;
-
- r300UpdateShaderStates(rmesa);
-
-- reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
-- e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
--
-- reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
-- e32(R300_RB3D_ZCACHE_UNKNOWN_03);
--
-+ r300EmitCacheFlush(rmesa);
- r300EmitState(rmesa);
-
-- for (i = 0; i < VB->PrimitiveCount; i++) {
-- GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
-- GLuint start = VB->Primitive[i].start;
-- GLuint end = VB->Primitive[i].start + VB->Primitive[i].count;
-+ for (i = 0; i < vb->PrimitiveCount; i++) {
-+ GLuint prim = _tnl_translate_prim(&vb->Primitive[i]);
-+ GLuint start = vb->Primitive[i].start;
-+ GLuint end = vb->Primitive[i].start + vb->Primitive[i].count;
- r300RunRenderPrimitive(rmesa, ctx, start, end, prim);
- }
-
-- reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
-- e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
--
-- reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
-- e32(R300_RB3D_ZCACHE_UNKNOWN_03);
-+ r300EmitCacheFlush(rmesa);
-
- #ifdef USER_BUFFERS
- r300UseArrays(ctx);
-@@ -463,8 +358,6 @@ static int r300Fallback(GLcontext * ctx)
- FALLBACK_IF(ctx->Point.PointSprite);
-
- if (!r300->disable_lowimpact_fallback) {
-- FALLBACK_IF(ctx->Polygon.OffsetPoint);
-- FALLBACK_IF(ctx->Polygon.OffsetLine);
- FALLBACK_IF(ctx->Polygon.StippleFlag);
- FALLBACK_IF(ctx->Multisample.Enabled);
- FALLBACK_IF(ctx->Line.StippleFlag);
-@@ -478,12 +371,17 @@ static int r300Fallback(GLcontext * ctx)
- static GLboolean r300RunNonTCLRender(GLcontext * ctx,
- struct tnl_pipeline_stage *stage)
- {
-+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
-+
- if (RADEON_DEBUG & DEBUG_PRIMS)
- fprintf(stderr, "%s\n", __FUNCTION__);
-
- if (r300Fallback(ctx) >= R300_FALLBACK_RAST)
- return GL_TRUE;
-
-+ if (!(rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
-+ return GL_TRUE;
-+
- return r300RunRender(ctx, stage);
- }
-
-diff --git a/src/mesa/drivers/dri/r300/r300_shader.c b/src/mesa/drivers/dri/r300/r300_shader.c
-index 59fe17b..5f5ac7c 100644
---- a/src/mesa/drivers/dri/r300/r300_shader.c
-+++ b/src/mesa/drivers/dri/r300/r300_shader.c
-@@ -54,6 +54,7 @@ r300ProgramStringNotify(GLcontext * ctx, GLenum target, struct gl_program *prog)
- fp->translated = GL_FALSE;
- break;
- }
-+
- /* need this for tcl fallbacks */
- _tnl_program_string(ctx, target, prog);
- }
-@@ -61,7 +62,7 @@ r300ProgramStringNotify(GLcontext * ctx, GLenum target, struct gl_program *prog)
- static GLboolean
- r300IsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog)
- {
-- return 1;
-+ return GL_TRUE;
- }
-
- void r300InitShaderFuncs(struct dd_function_table *functions)
-diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
-index e8d67f9..088216c 100644
---- a/src/mesa/drivers/dri/r300/r300_state.c
-+++ b/src/mesa/drivers/dri/r300/r300_state.c
-@@ -65,6 +65,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- #include "drirenderbuffer.h"
-
-+extern int future_hw_tcl_on;
-+extern void _tnl_UpdateFixedFunctionProgram(GLcontext * ctx);
-+
- static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
- {
- GLubyte color[4];
-@@ -79,6 +82,8 @@ static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
-
- rmesa->hw.blend_color.cmd[1] = PACK_COLOR_8888(color[3], color[0],
- color[1], color[2]);
-+ rmesa->hw.blend_color.cmd[2] = 0;
-+ rmesa->hw.blend_color.cmd[3] = 0;
- }
-
- /**
-@@ -314,20 +319,34 @@ static void r300UpdateCulling(GLcontext * ctx)
- r300ContextPtr r300 = R300_CONTEXT(ctx);
- uint32_t val = 0;
-
-- R300_STATECHANGE(r300, cul);
- if (ctx->Polygon.CullFlag) {
-- if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
-- val = R300_CULL_FRONT | R300_CULL_BACK;
-- else if (ctx->Polygon.CullFaceMode == GL_FRONT)
-+ switch (ctx->Polygon.CullFaceMode) {
-+ case GL_FRONT:
- val = R300_CULL_FRONT;
-- else
-+ break;
-+ case GL_BACK:
- val = R300_CULL_BACK;
-+ break;
-+ case GL_FRONT_AND_BACK:
-+ val = R300_CULL_FRONT | R300_CULL_BACK;
-+ break;
-+ default:
-+ break;
-+ }
-+ }
-
-- if (ctx->Polygon.FrontFace == GL_CW)
-- val |= R300_FRONT_FACE_CW;
-- else
-- val |= R300_FRONT_FACE_CCW;
-+ switch (ctx->Polygon.FrontFace) {
-+ case GL_CW:
-+ val |= R300_FRONT_FACE_CW;
-+ break;
-+ case GL_CCW:
-+ val |= R300_FRONT_FACE_CCW;
-+ break;
-+ default:
-+ break;
- }
-+
-+ R300_STATECHANGE(r300, cul);
- r300->hw.cul.cmd[R300_CUL_CULL] = val;
- }
-
-@@ -341,6 +360,20 @@ static void r300SetEarlyZState(GLcontext * ctx)
- r300ContextPtr r300 = R300_CONTEXT(ctx);
-
- R300_STATECHANGE(r300, zstencil_format);
-+ switch (ctx->Visual.depthBits) {
-+ case 16:
-+ r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_16BIT_INT_Z;
-+ break;
-+ case 24:
-+ r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_24BIT_INT_Z;
-+ break;
-+ default:
-+ fprintf(stderr, "Error: Unsupported depth %d... exiting\n", ctx->Visual.depthBits);
-+ _mesa_exit(-1);
-+ }
-+
-+ // r300->hw.zstencil_format.cmd[1] |= R300_DEPTH_FORMAT_UNK32;
-+
- if (ctx->Color.AlphaEnabled && ctx->Color.AlphaFunc != GL_ALWAYS)
- /* disable early Z */
- r300->hw.zstencil_format.cmd[2] = R300_EARLY_Z_DISABLE;
-@@ -352,6 +385,9 @@ static void r300SetEarlyZState(GLcontext * ctx)
- /* disable early Z */
- r300->hw.zstencil_format.cmd[2] = R300_EARLY_Z_DISABLE;
- }
-+
-+ r300->hw.zstencil_format.cmd[3] = 0x00000003;
-+ r300->hw.zstencil_format.cmd[4] = 0x00000000;
- }
-
- static void r300SetAlphaState(GLcontext * ctx)
-@@ -400,6 +436,7 @@ static void r300SetAlphaState(GLcontext * ctx)
-
- R300_STATECHANGE(r300, at);
- r300->hw.at.cmd[R300_AT_ALPHA_TEST] = pp_misc;
-+ r300->hw.at.cmd[R300_AT_UNKNOWN] = 0;
-
- r300SetEarlyZState(ctx);
- }
-@@ -462,97 +499,6 @@ static void r300SetDepthState(GLcontext * ctx)
- r300SetEarlyZState(ctx);
- }
-
--/**
-- * Handle glEnable()/glDisable().
-- *
-- * \note Mesa already filters redundant calls to glEnable/glDisable.
-- */
--static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
--{
-- r300ContextPtr r300 = R300_CONTEXT(ctx);
--
-- if (RADEON_DEBUG & DEBUG_STATE)
-- fprintf(stderr, "%s( %s = %s )\n", __FUNCTION__,
-- _mesa_lookup_enum_by_nr(cap),
-- state ? "GL_TRUE" : "GL_FALSE");
--
-- switch (cap) {
-- /* Fast track this one...
-- */
-- case GL_TEXTURE_1D:
-- case GL_TEXTURE_2D:
-- case GL_TEXTURE_3D:
-- break;
--
-- case GL_FOG:
-- R300_STATECHANGE(r300, fogs);
-- if (state) {
-- r300->hw.fogs.cmd[R300_FOGS_STATE] |= R300_FOG_ENABLE;
--
-- ctx->Driver.Fogfv(ctx, GL_FOG_MODE, NULL);
-- ctx->Driver.Fogfv(ctx, GL_FOG_DENSITY,
-- &ctx->Fog.Density);
-- ctx->Driver.Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
-- ctx->Driver.Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
-- ctx->Driver.Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
-- } else {
-- r300->hw.fogs.cmd[R300_FOGS_STATE] &= ~R300_FOG_ENABLE;
-- }
--
-- break;
--
-- case GL_ALPHA_TEST:
-- r300SetAlphaState(ctx);
-- break;
--
-- case GL_BLEND:
-- case GL_COLOR_LOGIC_OP:
-- r300SetBlendState(ctx);
-- break;
--
-- case GL_DEPTH_TEST:
-- r300SetDepthState(ctx);
-- break;
--
-- case GL_STENCIL_TEST:
-- if (r300->state.stencil.hw_stencil) {
-- R300_STATECHANGE(r300, zs);
-- if (state) {
-- r300->hw.zs.cmd[R300_ZS_CNTL_0] |=
-- R300_RB3D_STENCIL_ENABLE;
-- } else {
-- r300->hw.zs.cmd[R300_ZS_CNTL_0] &=
-- ~R300_RB3D_STENCIL_ENABLE;
-- }
-- } else {
--#if R200_MERGED
-- FALLBACK(&r300->radeon, RADEON_FALLBACK_STENCIL, state);
--#endif
-- }
-- break;
--
-- case GL_CULL_FACE:
-- r300UpdateCulling(ctx);
-- break;
--
-- case GL_POLYGON_OFFSET_POINT:
-- case GL_POLYGON_OFFSET_LINE:
-- break;
--
-- case GL_POLYGON_OFFSET_FILL:
-- R300_STATECHANGE(r300, occlusion_cntl);
-- if (state) {
-- r300->hw.occlusion_cntl.cmd[1] |= (3 << 0);
-- } else {
-- r300->hw.occlusion_cntl.cmd[1] &= ~(3 << 0);
-- }
-- break;
-- default:
-- radeonEnable(ctx, cap, state);
-- return;
-- }
--}
--
- static void r300UpdatePolygonMode(GLcontext * ctx)
- {
- r300ContextPtr r300 = R300_CONTEXT(ctx);
-@@ -601,6 +547,9 @@ static void r300UpdatePolygonMode(GLcontext * ctx)
- R300_STATECHANGE(r300, polygon_mode);
- r300->hw.polygon_mode.cmd[1] = hw_mode;
- }
-+
-+ r300->hw.polygon_mode.cmd[2] = 0x00000001;
-+ r300->hw.polygon_mode.cmd[3] = 0x00000000;
- }
-
- /**
-@@ -784,8 +733,8 @@ static void r300Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param)
- static void r300PointSize(GLcontext * ctx, GLfloat size)
- {
- r300ContextPtr r300 = R300_CONTEXT(ctx);
--
-- size = ctx->Point._Size;
-+ /* same size limits for AA, non-AA points */
-+ size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
-
- R300_STATECHANGE(r300, ps);
- r300->hw.ps.cmd[R300_PS_POINTSIZE] =
-@@ -800,11 +749,12 @@ static void r300LineWidth(GLcontext * ctx, GLfloat widthf)
- {
- r300ContextPtr r300 = R300_CONTEXT(ctx);
-
-- widthf = ctx->Line._Width;
--
-+ widthf = CLAMP(widthf,
-+ ctx->Const.MinPointSize,
-+ ctx->Const.MaxPointSize);
- R300_STATECHANGE(r300, lcntl);
-- r300->hw.lcntl.cmd[1] = (int)(widthf * 6.0);
-- r300->hw.lcntl.cmd[1] |= R300_LINE_CNT_VE;
-+ r300->hw.lcntl.cmd[1] =
-+ R300_LINE_CNT_HO | R300_LINE_CNT_VE | (int)(widthf * 6.0);
- }
-
- static void r300PolygonMode(GLcontext * ctx, GLenum face, GLenum mode)
-@@ -850,6 +800,7 @@ static void r300ShadeModel(GLcontext * ctx, GLenum mode)
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
-
- R300_STATECHANGE(rmesa, shade);
-+ rmesa->hw.shade.cmd[1] = 0x00000002;
- switch (mode) {
- case GL_FLAT:
- rmesa->hw.shade.cmd[2] = R300_RE_SHADE_MODEL_FLAT;
-@@ -860,6 +811,8 @@ static void r300ShadeModel(GLcontext * ctx, GLenum mode)
- default:
- return;
- }
-+ rmesa->hw.shade.cmd[3] = 0x00000000;
-+ rmesa->hw.shade.cmd[4] = 0x00000000;
- }
-
- static void r300StencilFuncSeparate(GLcontext * ctx, GLenum face,
-@@ -1460,11 +1413,9 @@ static void r300SetupRSUnit(GLcontext * ctx)
- int i;
-
- if (hw_tcl_on)
-- OutputsWritten.vp_outputs =
-- CURRENT_VERTEX_SHADER(ctx)->key.OutputsWritten;
-+ OutputsWritten.vp_outputs = CURRENT_VERTEX_SHADER(ctx)->key.OutputsWritten;
- else
-- RENDERINPUTS_COPY(OutputsWritten.index_bitset,
-- r300->state.render_inputs_bitset);
-+ RENDERINPUTS_COPY(OutputsWritten.index_bitset, r300->state.render_inputs_bitset);
-
- if (ctx->FragmentProgram._Current)
- InputsRead = ctx->FragmentProgram._Current->Base.InputsRead;
-@@ -1496,9 +1447,7 @@ static void r300SetupRSUnit(GLcontext * ctx)
- }
-
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-- r300->hw.ri.cmd[R300_RI_INTERP_0 + i] = 0
-- | R300_RS_INTERP_USED
-- | (in_texcoords << R300_RS_INTERP_SRC_SHIFT)
-+ r300->hw.ri.cmd[R300_RI_INTERP_0 + i] = 0 | R300_RS_INTERP_USED | (in_texcoords << R300_RS_INTERP_SRC_SHIFT)
- | interp_magic[i];
-
- r300->hw.rr.cmd[R300_RR_ROUTE_0 + fp_reg] = 0;
-@@ -1508,65 +1457,45 @@ static void r300SetupRSUnit(GLcontext * ctx)
- | (fp_reg << R300_RS_ROUTE_DEST_SHIFT);
- high_rr = fp_reg;
-
-- if (!R300_OUTPUTS_WRITTEN_TEST
-- (OutputsWritten, VERT_RESULT_TEX0 + i,
-- _TNL_ATTRIB_TEX(i))) {
-- /* Passing invalid data here can lock the GPU. */
-- WARN_ONCE
-- ("fragprog wants coords for tex%d, vp doesn't provide them!\n",
-- i);
-- //_mesa_print_program(&CURRENT_VERTEX_SHADER(ctx)->Base);
-- //_mesa_exit(-1);
-+ /* Passing invalid data here can lock the GPU. */
-+ if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_TEX0 + i, _TNL_ATTRIB_TEX(i))) {
-+ InputsRead &= ~(FRAG_BIT_TEX0 << i);
-+ fp_reg++;
-+ } else {
-+ WARN_ONCE("fragprog wants coords for tex%d, vp doesn't provide them!\n", i);
- }
-- InputsRead &= ~(FRAG_BIT_TEX0 << i);
-- fp_reg++;
- }
- /* Need to count all coords enabled at vof */
-- if (R300_OUTPUTS_WRITTEN_TEST
-- (OutputsWritten, VERT_RESULT_TEX0 + i, _TNL_ATTRIB_TEX(i)))
-+ if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_TEX0 + i, _TNL_ATTRIB_TEX(i))) {
- in_texcoords++;
-+ }
- }
-
- if (InputsRead & FRAG_BIT_COL0) {
-- if (!R300_OUTPUTS_WRITTEN_TEST
-- (OutputsWritten, VERT_RESULT_COL0, _TNL_ATTRIB_COLOR0)) {
-- WARN_ONCE
-- ("fragprog wants col0, vp doesn't provide it\n");
-- goto out; /* FIXME */
-- //_mesa_print_program(&CURRENT_VERTEX_SHADER(ctx)->Base);
-- //_mesa_exit(-1);
-+ if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_COL0, _TNL_ATTRIB_COLOR0)) {
-+ r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0 | R300_RS_ROUTE_0_COLOR | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
-+ InputsRead &= ~FRAG_BIT_COL0;
-+ col_interp_nr++;
-+ } else {
-+ WARN_ONCE("fragprog wants col0, vp doesn't provide it\n");
- }
--
-- r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0
-- | R300_RS_ROUTE_0_COLOR
-- | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
-- InputsRead &= ~FRAG_BIT_COL0;
-- col_interp_nr++;
- }
-- out:
-
- if (InputsRead & FRAG_BIT_COL1) {
-- if (!R300_OUTPUTS_WRITTEN_TEST
-- (OutputsWritten, VERT_RESULT_COL1, _TNL_ATTRIB_COLOR1)) {
-- WARN_ONCE
-- ("fragprog wants col1, vp doesn't provide it\n");
-- //_mesa_exit(-1);
-+ if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_COL1, _TNL_ATTRIB_COLOR1)) {
-+ r300->hw.rr.cmd[R300_RR_ROUTE_1] |= R300_RS_ROUTE_1_UNKNOWN11 | R300_RS_ROUTE_1_COLOR1 | (fp_reg++ << R300_RS_ROUTE_1_COLOR1_DEST_SHIFT);
-+ InputsRead &= ~FRAG_BIT_COL1;
-+ if (high_rr < 1)
-+ high_rr = 1;
-+ col_interp_nr++;
-+ } else {
-+ WARN_ONCE("fragprog wants col1, vp doesn't provide it\n");
- }
--
-- r300->hw.rr.cmd[R300_RR_ROUTE_1] |=
-- R300_RS_ROUTE_1_UNKNOWN11 | R300_RS_ROUTE_1_COLOR1 |
-- (fp_reg++ << R300_RS_ROUTE_1_COLOR1_DEST_SHIFT);
-- InputsRead &= ~FRAG_BIT_COL1;
-- if (high_rr < 1)
-- high_rr = 1;
-- col_interp_nr++;
- }
-
- /* Need at least one. This might still lock as the values are undefined... */
- if (in_texcoords == 0 && col_interp_nr == 0) {
-- r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0
-- | R300_RS_ROUTE_0_COLOR
-- | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
-+ r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0 | R300_RS_ROUTE_0_COLOR | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
- col_interp_nr++;
- }
-
-@@ -1575,17 +1504,13 @@ static void r300SetupRSUnit(GLcontext * ctx)
- | R300_RS_CNTL_0_UNKNOWN_18;
-
- assert(high_rr >= 0);
-- r300->hw.rr.cmd[R300_RR_CMD_0] =
-- cmdpacket0(R300_RS_ROUTE_0, high_rr + 1);
-+ r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_ROUTE_0, high_rr + 1);
- r300->hw.rc.cmd[2] = 0xC0 | high_rr;
-
- if (InputsRead)
-- WARN_ONCE("Don't know how to satisfy InputsRead=0x%08x\n",
-- InputsRead);
-+ WARN_ONCE("Don't know how to satisfy InputsRead=0x%08x\n", InputsRead);
- }
-
--#define vpucount(ptr) (((drm_r300_cmd_header_t*)(ptr))->vpu.count)
--
- #define bump_vpu_count(ptr, new_count) do{\
- drm_r300_cmd_header_t* _p=((drm_r300_cmd_header_t*)(ptr));\
- int _nc=(new_count)/4; \
-@@ -1593,9 +1518,7 @@ static void r300SetupRSUnit(GLcontext * ctx)
- if(_nc>_p->vpu.count)_p->vpu.count=_nc;\
- }while(0)
-
--void static inline setup_vertex_shader_fragment(r300ContextPtr r300, int dest, struct
-- r300_vertex_shader_fragment
-- *vsf)
-+static inline void r300SetupVertexProgramFragment(r300ContextPtr r300, int dest, struct r300_vertex_shader_fragment *vsf)
- {
- int i;
-
-@@ -1603,8 +1526,7 @@ void static inline setup_vertex_shader_fragment(r300ContextPtr r300, int dest, s
- return;
-
- if (vsf->length & 0x3) {
-- fprintf(stderr,
-- "VERTEX_SHADER_FRAGMENT must have length divisible by 4\n");
-+ fprintf(stderr, "VERTEX_SHADER_FRAGMENT must have length divisible by 4\n");
- _mesa_exit(-1);
- }
-
-@@ -1612,147 +1534,101 @@ void static inline setup_vertex_shader_fragment(r300ContextPtr r300, int dest, s
- case 0:
- R300_STATECHANGE(r300, vpi);
- for (i = 0; i < vsf->length; i++)
-- r300->hw.vpi.cmd[R300_VPI_INSTR_0 + i +
-- 4 * (dest & 0xff)] = (vsf->body.d[i]);
-- bump_vpu_count(r300->hw.vpi.cmd,
-- vsf->length + 4 * (dest & 0xff));
-+ r300->hw.vpi.cmd[R300_VPI_INSTR_0 + i + 4 * (dest & 0xff)] = (vsf->body.d[i]);
-+ bump_vpu_count(r300->hw.vpi.cmd, vsf->length + 4 * (dest & 0xff));
- break;
-
- case 2:
- R300_STATECHANGE(r300, vpp);
- for (i = 0; i < vsf->length; i++)
-- r300->hw.vpp.cmd[R300_VPP_PARAM_0 + i +
-- 4 * (dest & 0xff)] = (vsf->body.d[i]);
-- bump_vpu_count(r300->hw.vpp.cmd,
-- vsf->length + 4 * (dest & 0xff));
-+ r300->hw.vpp.cmd[R300_VPP_PARAM_0 + i + 4 * (dest & 0xff)] = (vsf->body.d[i]);
-+ bump_vpu_count(r300->hw.vpp.cmd, vsf->length + 4 * (dest & 0xff));
- break;
- case 4:
- R300_STATECHANGE(r300, vps);
- for (i = 0; i < vsf->length; i++)
-- r300->hw.vps.cmd[1 + i + 4 * (dest & 0xff)] =
-- (vsf->body.d[i]);
-- bump_vpu_count(r300->hw.vps.cmd,
-- vsf->length + 4 * (dest & 0xff));
-+ r300->hw.vps.cmd[1 + i + 4 * (dest & 0xff)] = (vsf->body.d[i]);
-+ bump_vpu_count(r300->hw.vps.cmd, vsf->length + 4 * (dest & 0xff));
- break;
- default:
-- fprintf(stderr,
-- "%s:%s don't know how to handle dest %04x\n",
-- __FILE__, __FUNCTION__, dest);
-+ fprintf(stderr, "%s:%s don't know how to handle dest %04x\n", __FILE__, __FUNCTION__, dest);
- _mesa_exit(-1);
- }
- }
-
--/* just a skeleton for now.. */
--
--/* Generate a vertex shader that simply transforms vertex and texture coordinates,
-- while leaving colors intact. Nothing fancy (like lights)
--
-- If implementing lights make a copy first, so it is easy to switch between the two versions */
--static void r300GenerateSimpleVertexShader(r300ContextPtr r300)
-+static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa)
- {
-- int i;
-+ struct r300_vertex_shader_state *prog = &(rmesa->state.vertex_shader);
- GLuint o_reg = 0;
--
-- /* Allocate parameters */
-- r300->state.vap_param.transform_offset = 0x0; /* transform matrix */
-- r300->state.vertex_shader.param_offset = 0x0;
-- r300->state.vertex_shader.param_count = 0x4; /* 4 vector values - 4x4 matrix */
--
-- r300->state.vertex_shader.program_start = 0x0;
-- r300->state.vertex_shader.unknown_ptr1 = 0x4; /* magic value ? */
-- r300->state.vertex_shader.program_end = 0x0;
--
-- r300->state.vertex_shader.unknown_ptr2 = 0x0; /* magic value */
-- r300->state.vertex_shader.unknown_ptr3 = 0x4; /* magic value */
--
-- r300->state.vertex_shader.unknown1.length = 0;
-- r300->state.vertex_shader.unknown2.length = 0;
--
--#define WRITE_OP(oper,source1,source2,source3) {\
-- r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].op=(oper); \
-- r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src[0]=(source1); \
-- r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src[1]=(source2); \
-- r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src[2]=(source3); \
-- r300->state.vertex_shader.program_end++; \
-- }
--
-- for (i = VERT_ATTRIB_POS; i < VERT_ATTRIB_MAX; i++)
-- if (r300->state.sw_tcl_inputs[i] != -1) {
-- WRITE_OP(EASY_VSF_OP(MUL, o_reg++, ALL, RESULT),
-- VSF_REG(r300->state.sw_tcl_inputs[i]),
-- VSF_ATTR_UNITY(r300->state.
-- sw_tcl_inputs[i]),
-- VSF_UNITY(r300->state.sw_tcl_inputs[i])
-- )
--
-+ int i;
-+ int inst_count = 0;
-+ int param_count = 0;
-+ int program_end = 0;
-+
-+ for (i = VERT_ATTRIB_POS; i < VERT_ATTRIB_MAX; i++) {
-+ if (rmesa->state.sw_tcl_inputs[i] != -1) {
-+ prog->program.body.i[program_end + 0] = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT);
-+ prog->program.body.i[program_end + 1] = VSF_REG(rmesa->state.sw_tcl_inputs[i]);
-+ prog->program.body.i[program_end + 2] = VSF_ATTR_UNITY(rmesa->state.sw_tcl_inputs[i]);
-+ prog->program.body.i[program_end + 3] = VSF_UNITY(rmesa->state.sw_tcl_inputs[i]);
-+ program_end += 4;
- }
-+ }
-
-- r300->state.vertex_shader.program_end--; /* r300 wants program length to be one more - no idea why */
-- r300->state.vertex_shader.program.length =
-- (r300->state.vertex_shader.program_end + 1) * 4;
-+ prog->program.length = program_end;
-
-- r300->state.vertex_shader.unknown_ptr1 = r300->state.vertex_shader.program_end; /* magic value ? */
-- r300->state.vertex_shader.unknown_ptr2 = r300->state.vertex_shader.program_end; /* magic value ? */
-- r300->state.vertex_shader.unknown_ptr3 = r300->state.vertex_shader.program_end; /* magic value ? */
-+ r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM,
-+ &(prog->program));
-+ inst_count = (prog->program.length / 4) - 1;
-
-+ R300_STATECHANGE(rmesa, pvs);
-+ rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] =
-+ (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) |
-+ (inst_count << R300_PVS_CNTL_1_POS_END_SHIFT) |
-+ (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT);
-+ rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] =
-+ (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) |
-+ (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT);
-+ rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] =
-+ (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) |
-+ (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT);
- }
-
--static void r300SetupVertexProgram(r300ContextPtr rmesa)
-+static void r300SetupRealVertexProgram(r300ContextPtr rmesa)
- {
- GLcontext *ctx = rmesa->radeon.glCtx;
-- int inst_count;
-- int param_count;
-- struct r300_vertex_program *prog =
-- (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
-+ struct r300_vertex_program *prog = (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
-+ int inst_count = 0;
-+ int param_count = 0;
-
-- ((drm_r300_cmd_header_t *) rmesa->hw.vpp.cmd)->vpu.count = 0;
-+ /* FIXME: r300SetupVertexProgramFragment */
- R300_STATECHANGE(rmesa, vpp);
- param_count =
-- r300VertexProgUpdateParams(ctx, (struct r300_vertex_program_cont *)
-- ctx->VertexProgram._Current /*prog */ ,
-+ r300VertexProgUpdateParams(ctx,
-+ (struct r300_vertex_program_cont *)
-+ ctx->VertexProgram._Current,
- (float *)&rmesa->hw.vpp.
- cmd[R300_VPP_PARAM_0]);
- bump_vpu_count(rmesa->hw.vpp.cmd, param_count);
- param_count /= 4;
-
-- /* Reset state, in case we don't use something */
-- ((drm_r300_cmd_header_t *) rmesa->hw.vpi.cmd)->vpu.count = 0;
-- ((drm_r300_cmd_header_t *) rmesa->hw.vps.cmd)->vpu.count = 0;
--
-- setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM, &(prog->program));
--
--#if 0
-- setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1,
-- &(rmesa->state.vertex_shader.unknown1));
-- setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2,
-- &(rmesa->state.vertex_shader.unknown2));
--#endif
--
-- inst_count = prog->program.length / 4 - 1;
-+ r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM, &(prog->program));
-+ inst_count = (prog->program.length / 4) - 1;
-
- R300_STATECHANGE(rmesa, pvs);
- rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] =
-- (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT)
-- | (inst_count /*pos_end */ << R300_PVS_CNTL_1_POS_END_SHIFT)
-- | (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT);
-+ (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) |
-+ (inst_count << R300_PVS_CNTL_1_POS_END_SHIFT) |
-+ (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT);
- rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] =
-- (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT)
-- | (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT);
-+ (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) |
-+ (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT);
- rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] =
-- (0 /*rmesa->state.vertex_shader.unknown_ptr2 */ <<
-- R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT)
-- | (inst_count /*rmesa->state.vertex_shader.unknown_ptr3 */ <<
-- 0);
--
-- /* This is done for vertex shader fragments, but also needs to be done for vap_pvs,
-- so I leave it as a reminder */
--#if 0
-- reg_start(R300_VAP_PVS_WAITIDLE, 0);
-- e32(0x00000000);
--#endif
-+ (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) |
-+ (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT);
- }
-
--static void r300SetupVertexShader(r300ContextPtr rmesa)
-+static void r300SetupVertexProgram(r300ContextPtr rmesa)
- {
- GLcontext *ctx = rmesa->radeon.glCtx;
-
-@@ -1765,50 +1641,108 @@ static void r300SetupVertexShader(r300ContextPtr rmesa)
- 0x400 area might have something to do with pixel shaders as it appears right after pfs programming.
- 0x406 is set to { 0.0, 0.0, 1.0, 0.0 } most of the time but should change with smooth points and in other rare cases. */
- //setup_vertex_shader_fragment(rmesa, 0x406, &unk4);
-- if (hw_tcl_on
-- && ((struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx))->
-- translated) {
-- r300SetupVertexProgram(rmesa);
-- return;
-+ if (hw_tcl_on && ((struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx))->translated) {
-+ r300SetupRealVertexProgram(rmesa);
-+ } else {
-+ /* FIXME: This needs to be replaced by vertex shader generation code. */
-+ r300SetupDefaultVertexProgram(rmesa);
- }
-
-- /* This needs to be replaced by vertex shader generation code */
-- r300GenerateSimpleVertexShader(rmesa);
--
-- setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM,
-- &(rmesa->state.vertex_shader.program));
-
-+ /* FIXME: This is done for vertex shader fragments, but also needs to be
-+ * done for vap_pvs, so I leave it as a reminder. */
- #if 0
-- setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1,
-- &(rmesa->state.vertex_shader.unknown1));
-- setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2,
-- &(rmesa->state.vertex_shader.unknown2));
-+ reg_start(R300_VAP_PVS_WAITIDLE, 0);
-+ e32(0x00000000);
- #endif
-+}
-
-- R300_STATECHANGE(rmesa, pvs);
-- rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] =
-- (rmesa->state.vertex_shader.
-- program_start << R300_PVS_CNTL_1_PROGRAM_START_SHIFT)
-- | (rmesa->state.vertex_shader.
-- unknown_ptr1 << R300_PVS_CNTL_1_POS_END_SHIFT)
-- | (rmesa->state.vertex_shader.
-- program_end << R300_PVS_CNTL_1_PROGRAM_END_SHIFT);
-- rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] =
-- (rmesa->state.vertex_shader.
-- param_offset << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT)
-- | (rmesa->state.vertex_shader.
-- param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT);
-- rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] =
-- (rmesa->state.vertex_shader.
-- unknown_ptr2 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT)
-- | (rmesa->state.vertex_shader.unknown_ptr3 << 0);
-+/**
-+ * Enable/Disable states.
-+ *
-+ * \note Mesa already filters redundant calls to this function.
-+ */
-+static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
-+{
-+ r300ContextPtr r300 = R300_CONTEXT(ctx);
-
-- /* This is done for vertex shader fragments, but also needs to be done for vap_pvs,
-- so I leave it as a reminder */
--#if 0
-- reg_start(R300_VAP_PVS_WAITIDLE, 0);
-- e32(0x00000000);
-+ if (RADEON_DEBUG & DEBUG_STATE)
-+ fprintf(stderr, "%s( %s = %s )\n", __FUNCTION__,
-+ _mesa_lookup_enum_by_nr(cap),
-+ state ? "GL_TRUE" : "GL_FALSE");
-+
-+ switch (cap) {
-+ /* Fast track this one...
-+ */
-+ case GL_TEXTURE_1D:
-+ case GL_TEXTURE_2D:
-+ case GL_TEXTURE_3D:
-+ break;
-+
-+ case GL_FOG:
-+ R300_STATECHANGE(r300, fogs);
-+ if (state) {
-+ r300->hw.fogs.cmd[R300_FOGS_STATE] |= R300_FOG_ENABLE;
-+
-+ r300Fogfv(ctx, GL_FOG_MODE, NULL);
-+ r300Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density);
-+ r300Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
-+ r300Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
-+ r300Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
-+ } else {
-+ r300->hw.fogs.cmd[R300_FOGS_STATE] &= ~R300_FOG_ENABLE;
-+ }
-+
-+ break;
-+
-+ case GL_ALPHA_TEST:
-+ r300SetAlphaState(ctx);
-+ break;
-+
-+ case GL_BLEND:
-+ case GL_COLOR_LOGIC_OP:
-+ r300SetBlendState(ctx);
-+ break;
-+
-+ case GL_DEPTH_TEST:
-+ r300SetDepthState(ctx);
-+ break;
-+
-+ case GL_STENCIL_TEST:
-+ if (r300->state.stencil.hw_stencil) {
-+ R300_STATECHANGE(r300, zs);
-+ if (state) {
-+ r300->hw.zs.cmd[R300_ZS_CNTL_0] |=
-+ R300_RB3D_STENCIL_ENABLE;
-+ } else {
-+ r300->hw.zs.cmd[R300_ZS_CNTL_0] &=
-+ ~R300_RB3D_STENCIL_ENABLE;
-+ }
-+ } else {
-+#if R200_MERGED
-+ FALLBACK(&r300->radeon, RADEON_FALLBACK_STENCIL, state);
- #endif
-+ }
-+ break;
-+
-+ case GL_CULL_FACE:
-+ r300UpdateCulling(ctx);
-+ break;
-+
-+ case GL_POLYGON_OFFSET_POINT:
-+ case GL_POLYGON_OFFSET_LINE:
-+ case GL_POLYGON_OFFSET_FILL:
-+ R300_STATECHANGE(r300, occlusion_cntl);
-+ if (state) {
-+ r300->hw.occlusion_cntl.cmd[1] |= (3 << 0);
-+ } else {
-+ r300->hw.occlusion_cntl.cmd[1] &= ~(3 << 0);
-+ }
-+ break;
-+ default:
-+ radeonEnable(ctx, cap, state);
-+ return;
-+ }
- }
-
- /**
-@@ -1825,12 +1759,6 @@ static void r300ResetHwState(r300ContextPtr r300)
- if (RADEON_DEBUG & DEBUG_STATE)
- fprintf(stderr, "%s\n", __FUNCTION__);
-
-- /* This is a place to initialize registers which
-- have bitfields accessed by different functions
-- and not all bits are used */
--
-- /* go and compute register values from GL state */
--
- r300UpdateWindow(ctx);
-
- r300ColorMask(ctx,
-@@ -1860,13 +1788,11 @@ static void r300ResetHwState(r300ContextPtr r300)
- r300AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef);
- r300Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled);
-
-- /* Initialize magic registers
-- TODO : learn what they really do, or get rid of
-- those we don't have to touch */
- if (!has_tcl)
- r300->hw.vap_cntl.cmd[1] = 0x0014045a;
- else
- r300->hw.vap_cntl.cmd[1] = 0x0030045A; //0x0030065a /* Dangerous */
-+
- r300->hw.vte.cmd[1] = R300_VPORT_X_SCALE_ENA
- | R300_VPORT_X_OFFSET_ENA
- | R300_VPORT_Y_SCALE_ENA
-@@ -1877,10 +1803,12 @@ static void r300ResetHwState(r300ContextPtr r300)
-
- r300->hw.unk2134.cmd[1] = 0x00FFFFFF;
- r300->hw.unk2134.cmd[2] = 0x00000000;
-- if (_mesa_little_endian())
-- r300->hw.vap_cntl_status.cmd[1] = R300_VC_NO_SWAP;
-- else
-- r300->hw.vap_cntl_status.cmd[1] = R300_VC_32BIT_SWAP;
-+
-+#ifdef MESA_LITTLE_ENDIAN
-+ r300->hw.vap_cntl_status.cmd[1] = R300_VC_NO_SWAP;
-+#else
-+ r300->hw.vap_cntl_status.cmd[1] = R300_VC_32BIT_SWAP;
-+#endif
-
- /* disable VAP/TCL on non-TCL capable chips */
- if (!has_tcl)
-@@ -1890,16 +1818,22 @@ static void r300ResetHwState(r300ContextPtr r300)
-
- r300->hw.unk221C.cmd[1] = R300_221C_NORMAL;
-
-- r300->hw.unk2220.cmd[1] = r300PackFloat32(1.0);
-- r300->hw.unk2220.cmd[2] = r300PackFloat32(1.0);
-- r300->hw.unk2220.cmd[3] = r300PackFloat32(1.0);
-- r300->hw.unk2220.cmd[4] = r300PackFloat32(1.0);
-+ r300->hw.vap_clip.cmd[1] = r300PackFloat32(1.0); /* X */
-+ r300->hw.vap_clip.cmd[2] = r300PackFloat32(1.0); /* X */
-+ r300->hw.vap_clip.cmd[3] = r300PackFloat32(1.0); /* Y */
-+ r300->hw.vap_clip.cmd[4] = r300PackFloat32(1.0); /* Y */
-
-- /* what about other chips than r300 or rv350??? */
-- if (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R300)
-- r300->hw.unk2288.cmd[1] = R300_2288_R300;
-- else
-- r300->hw.unk2288.cmd[1] = R300_2288_RV350;
-+ /* XXX: Other families? */
-+ if (has_tcl) {
-+ switch (r300->radeon.radeonScreen->chip_family) {
-+ case CHIP_FAMILY_R300:
-+ r300->hw.unk2288.cmd[1] = R300_2288_R300;
-+ break;
-+ default:
-+ r300->hw.unk2288.cmd[1] = R300_2288_RV350;
-+ break;
-+ }
-+ }
-
- r300->hw.gb_enable.cmd[1] = R300_GB_POINT_STUFF_ENABLE
- | R300_GB_LINE_STUFF_ENABLE
-@@ -1907,26 +1841,35 @@ static void r300ResetHwState(r300ContextPtr r300)
-
- r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_0] = 0x66666666;
- r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_1] = 0x06666666;
-- if ((r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R300) ||
-- (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R350))
-- r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] =
-- R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_R300 |
-- R300_GB_TILE_SIZE_16;
-- else if (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV410)
-- r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] =
-- R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_RV410 |
-- R300_GB_TILE_SIZE_16;
-- else if (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R420)
-- r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] =
-- R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_R420 |
-- R300_GB_TILE_SIZE_16;
-- else
-- r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] =
-- R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_RV300 |
-- R300_GB_TILE_SIZE_16;
-- /* set to 0 when fog is disabled? */
-+
-+ /* XXX: Other families? */
-+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] =
-+ R300_GB_TILE_ENABLE | R300_GB_TILE_SIZE_16;
-+ switch (r300->radeon.radeonScreen->chip_family) {
-+ case CHIP_FAMILY_R300:
-+ case CHIP_FAMILY_R350:
-+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] |=
-+ R300_GB_TILE_PIPE_COUNT_R300;
-+ break;
-+ case CHIP_FAMILY_RV410:
-+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] |=
-+ R300_GB_TILE_PIPE_COUNT_RV410;
-+ break;
-+ case CHIP_FAMILY_R420:
-+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] |=
-+ R300_GB_TILE_PIPE_COUNT_R420;
-+ break;
-+ default:
-+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] |=
-+ R300_GB_TILE_PIPE_COUNT_RV300;
-+ break;
-+ }
-+
-+ /* XXX: set to 0 when fog is disabled? */
- r300->hw.gb_misc.cmd[R300_GB_MISC_SELECT] = R300_GB_FOG_SELECT_1_1_W;
-- r300->hw.gb_misc.cmd[R300_GB_MISC_AA_CONFIG] = R300_AA_DISABLE; /* No antialiasing */
-+
-+ /* XXX: Enable anti-aliasing? */
-+ r300->hw.gb_misc.cmd[R300_GB_MISC_AA_CONFIG] = R300_AA_DISABLE;
-
- r300->hw.unk4200.cmd[1] = r300PackFloat32(0.0);
- r300->hw.unk4200.cmd[2] = r300PackFloat32(0.0);
-@@ -1935,31 +1878,28 @@ static void r300ResetHwState(r300ContextPtr r300)
-
- r300->hw.unk4214.cmd[1] = 0x00050005;
-
-- r300PointSize(ctx, 0.0);
-+ r300PointSize(ctx, 1.0);
-
- r300->hw.unk4230.cmd[1] = 0x18000006;
- r300->hw.unk4230.cmd[2] = 0x00020006;
- r300->hw.unk4230.cmd[3] = r300PackFloat32(1.0 / 192.0);
-
-- r300LineWidth(ctx, 0.0);
-+ r300LineWidth(ctx, 1.0);
-
- r300->hw.unk4260.cmd[1] = 0;
- r300->hw.unk4260.cmd[2] = r300PackFloat32(0.0);
- r300->hw.unk4260.cmd[3] = r300PackFloat32(1.0);
-
-- r300->hw.shade.cmd[1] = 0x00000002;
- r300ShadeModel(ctx, ctx->Light.ShadeModel);
-- r300->hw.shade.cmd[3] = 0x00000000;
-- r300->hw.shade.cmd[4] = 0x00000000;
-
- r300PolygonMode(ctx, GL_FRONT, ctx->Polygon.FrontMode);
- r300PolygonMode(ctx, GL_BACK, ctx->Polygon.BackMode);
-- r300->hw.polygon_mode.cmd[2] = 0x00000001;
-- r300->hw.polygon_mode.cmd[3] = 0x00000000;
- r300->hw.zbias_cntl.cmd[1] = 0x00000000;
-
- r300PolygonOffset(ctx, ctx->Polygon.OffsetFactor,
- ctx->Polygon.OffsetUnits);
-+ r300Enable(ctx, GL_POLYGON_OFFSET_POINT, ctx->Polygon.OffsetPoint);
-+ r300Enable(ctx, GL_POLYGON_OFFSET_LINE, ctx->Polygon.OffsetLine);
- r300Enable(ctx, GL_POLYGON_OFFSET_FILL, ctx->Polygon.OffsetFill);
-
- r300->hw.unk42C0.cmd[1] = 0x4B7FFFFF;
-@@ -1977,21 +1917,18 @@ static void r300ResetHwState(r300ContextPtr r300)
- r300->hw.unk46A4.cmd[5] = 0x00000001;
-
- r300Enable(ctx, GL_FOG, ctx->Fog.Enabled);
-- ctx->Driver.Fogfv(ctx, GL_FOG_MODE, NULL);
-- ctx->Driver.Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density);
-- ctx->Driver.Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
-- ctx->Driver.Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
-- ctx->Driver.Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
-- ctx->Driver.Fogfv(ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL);
-+ r300Fogfv(ctx, GL_FOG_MODE, NULL);
-+ r300Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density);
-+ r300Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
-+ r300Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
-+ r300Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
-+ r300Fogfv(ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL);
-
-- r300->hw.at.cmd[R300_AT_UNKNOWN] = 0;
- r300->hw.unk4BD8.cmd[1] = 0;
-
- r300->hw.unk4E00.cmd[1] = 0;
-
- r300BlendColor(ctx, ctx->Color.BlendColor);
-- r300->hw.blend_color.cmd[2] = 0;
-- r300->hw.blend_color.cmd[3] = 0;
-
- /* Again, r300ClearBuffer uses this */
- r300->hw.cb.cmd[R300_CB_OFFSET] =
-@@ -2022,32 +1959,13 @@ static void r300ResetHwState(r300ContextPtr r300)
- r300->hw.unk4EA0.cmd[1] = 0x00000000;
- r300->hw.unk4EA0.cmd[2] = 0xffffffff;
-
-- switch (ctx->Visual.depthBits) {
-- case 16:
-- r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_16BIT_INT_Z;
-- break;
-- case 24:
-- r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_24BIT_INT_Z;
-- break;
-- default:
-- fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
-- ctx->Visual.depthBits);
-- _mesa_exit(-1);
--
-- }
-- /* z compress? */
-- //r300->hw.zstencil_format.cmd[1] |= R300_DEPTH_FORMAT_UNK32;
--
-- r300->hw.zstencil_format.cmd[3] = 0x00000003;
-- r300->hw.zstencil_format.cmd[4] = 0x00000000;
--
- r300->hw.zb.cmd[R300_ZB_OFFSET] =
- r300->radeon.radeonScreen->depthOffset +
- r300->radeon.radeonScreen->fbLocation;
- r300->hw.zb.cmd[R300_ZB_PITCH] = r300->radeon.radeonScreen->depthPitch;
-
- if (r300->radeon.sarea->tiling_enabled) {
-- /* Turn off when clearing buffers ? */
-+ /* XXX: Turn off when clearing buffers ? */
- r300->hw.zb.cmd[R300_ZB_PITCH] |= R300_DEPTH_TILE_ENABLE;
-
- if (ctx->Visual.depthBits == 24)
-@@ -2070,14 +1988,10 @@ static void r300ResetHwState(r300ContextPtr r300)
- r300->hw.vps.cmd[R300_VPS_POINTSIZE] = r300PackFloat32(1.0);
- r300->hw.vps.cmd[R300_VPS_ZERO_3] = 0;
- }
--//END: TODO
-+
- r300->hw.all_dirty = GL_TRUE;
- }
-
--
--extern void _tnl_UpdateFixedFunctionProgram(GLcontext * ctx);
--
--extern int future_hw_tcl_on;
- void r300UpdateShaders(r300ContextPtr rmesa)
- {
- GLcontext *ctx;
-@@ -2117,7 +2031,6 @@ void r300UpdateShaders(r300ContextPtr rmesa)
- }
- r300UpdateStateParameters(ctx, _NEW_PROGRAM);
- }
--
- }
-
- static void r300SetupPixelShader(r300ContextPtr rmesa)
-@@ -2136,62 +2049,61 @@ static void r300SetupPixelShader(r300ContextPtr rmesa)
- __FUNCTION__);
- return;
- }
--#define OUTPUT_FIELD(st, reg, field) \
-- R300_STATECHANGE(rmesa, st); \
-- for(i=0;i<=fp->alu_end;i++) \
-- rmesa->hw.st.cmd[R300_FPI_INSTR_0+i]=fp->alu.inst[i].field;\
-- rmesa->hw.st.cmd[R300_FPI_CMD_0]=cmdpacket0(reg, fp->alu_end+1);
-
-- OUTPUT_FIELD(fpi[0], R300_PFS_INSTR0_0, inst0);
-- OUTPUT_FIELD(fpi[1], R300_PFS_INSTR1_0, inst1);
-- OUTPUT_FIELD(fpi[2], R300_PFS_INSTR2_0, inst2);
-- OUTPUT_FIELD(fpi[3], R300_PFS_INSTR3_0, inst3);
--#undef OUTPUT_FIELD
-+ R300_STATECHANGE(rmesa, fpi[0]);
-+ rmesa->hw.fpi[0].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR0_0, fp->alu_end + 1);
-+ for (i = 0; i <= fp->alu_end; i++) {
-+ rmesa->hw.fpi[0].cmd[R300_FPI_INSTR_0 + i] = fp->alu.inst[i].inst0;
-+ }
-+
-+ R300_STATECHANGE(rmesa, fpi[1]);
-+ rmesa->hw.fpi[1].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR1_0, fp->alu_end + 1);
-+ for (i = 0; i <= fp->alu_end; i++) {
-+ rmesa->hw.fpi[1].cmd[R300_FPI_INSTR_0 + i] = fp->alu.inst[i].inst1;
-+ }
-+
-+ R300_STATECHANGE(rmesa, fpi[2]);
-+ rmesa->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR2_0, fp->alu_end + 1);
-+ for (i = 0; i <= fp->alu_end; i++) {
-+ rmesa->hw.fpi[2].cmd[R300_FPI_INSTR_0 + i] = fp->alu.inst[i].inst2;
-+ }
-+
-+ R300_STATECHANGE(rmesa, fpi[3]);
-+ rmesa->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR3_0, fp->alu_end + 1);
-+ for (i = 0; i <= fp->alu_end; i++) {
-+ rmesa->hw.fpi[3].cmd[R300_FPI_INSTR_0 + i] = fp->alu.inst[i].inst3;
-+ }
-
- R300_STATECHANGE(rmesa, fp);
-+ rmesa->hw.fp.cmd[R300_FP_CNTL0] = fp->cur_node | (fp->first_node_has_tex << 3);
-+ rmesa->hw.fp.cmd[R300_FP_CNTL1] = fp->max_temp_idx;
-+ rmesa->hw.fp.cmd[R300_FP_CNTL2] =
-+ (fp->alu_offset << R300_PFS_CNTL_ALU_OFFSET_SHIFT) |
-+ (fp->alu_end << R300_PFS_CNTL_ALU_END_SHIFT) |
-+ (fp->tex_offset << R300_PFS_CNTL_TEX_OFFSET_SHIFT) |
-+ (fp->tex_end << R300_PFS_CNTL_TEX_END_SHIFT);
- /* I just want to say, the way these nodes are stored.. weird.. */
- for (i = 0, k = (4 - (fp->cur_node + 1)); i < 4; i++, k++) {
- if (i < (fp->cur_node + 1)) {
- rmesa->hw.fp.cmd[R300_FP_NODE0 + k] =
-- (fp->node[i].
-- alu_offset << R300_PFS_NODE_ALU_OFFSET_SHIFT)
-- | (fp->node[i].
-- alu_end << R300_PFS_NODE_ALU_END_SHIFT)
-- | (fp->node[i].
-- tex_offset << R300_PFS_NODE_TEX_OFFSET_SHIFT)
-- | (fp->node[i].
-- tex_end << R300_PFS_NODE_TEX_END_SHIFT)
-- | fp->node[i].flags; /* ( (k==3) ? R300_PFS_NODE_LAST_NODE : 0); */
-+ (fp->node[i].alu_offset << R300_PFS_NODE_ALU_OFFSET_SHIFT) |
-+ (fp->node[i].alu_end << R300_PFS_NODE_ALU_END_SHIFT) |
-+ (fp->node[i].tex_offset << R300_PFS_NODE_TEX_OFFSET_SHIFT) |
-+ (fp->node[i].tex_end << R300_PFS_NODE_TEX_END_SHIFT) |
-+ fp->node[i].flags;
- } else {
- rmesa->hw.fp.cmd[R300_FP_NODE0 + (3 - i)] = 0;
- }
- }
-
-- /* PFS_CNTL_0 */
-- rmesa->hw.fp.cmd[R300_FP_CNTL0] =
-- fp->cur_node | (fp->first_node_has_tex << 3);
-- /* PFS_CNTL_1 */
-- rmesa->hw.fp.cmd[R300_FP_CNTL1] = fp->max_temp_idx;
-- /* PFS_CNTL_2 */
-- rmesa->hw.fp.cmd[R300_FP_CNTL2] =
-- (fp->alu_offset << R300_PFS_CNTL_ALU_OFFSET_SHIFT)
-- | (fp->alu_end << R300_PFS_CNTL_ALU_END_SHIFT)
-- | (fp->tex_offset << R300_PFS_CNTL_TEX_OFFSET_SHIFT)
-- | (fp->tex_end << R300_PFS_CNTL_TEX_END_SHIFT);
--
- R300_STATECHANGE(rmesa, fpp);
-+ rmesa->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(R300_PFS_PARAM_0_X, fp->const_nr * 4);
- for (i = 0; i < fp->const_nr; i++) {
-- rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 0] =
-- r300PackFloat24(fp->constant[i][0]);
-- rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 1] =
-- r300PackFloat24(fp->constant[i][1]);
-- rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 2] =
-- r300PackFloat24(fp->constant[i][2]);
-- rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 3] =
-- r300PackFloat24(fp->constant[i][3]);
-- }
-- rmesa->hw.fpp.cmd[R300_FPP_CMD_0] =
-- cmdpacket0(R300_PFS_PARAM_0_X, fp->const_nr * 4);
-+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 0] = r300PackFloat24(fp->constant[i][0]);
-+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 1] = r300PackFloat24(fp->constant[i][1]);
-+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 2] = r300PackFloat24(fp->constant[i][2]);
-+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 3] = r300PackFloat24(fp->constant[i][3]);
-+ }
- }
-
- void r300UpdateShaderStates(r300ContextPtr rmesa)
-@@ -2205,7 +2117,7 @@ void r300UpdateShaderStates(r300ContextPtr rmesa)
- r300SetupTextures(ctx);
-
- if ((rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
-- r300SetupVertexShader(rmesa);
-+ r300SetupVertexProgram(rmesa);
- r300SetupRSUnit(ctx);
- }
-
-diff --git a/src/mesa/drivers/dri/r300/r300_state.h b/src/mesa/drivers/dri/r300/r300_state.h
-index 21a49b7..365f7ec 100644
---- a/src/mesa/drivers/dri/r300/r300_state.h
-+++ b/src/mesa/drivers/dri/r300/r300_state.h
-@@ -37,8 +37,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- #include "r300_context.h"
-
-+#define R300_NEWPRIM( rmesa ) \
-+ do { \
-+ if ( rmesa->dma.flush ) \
-+ rmesa->dma.flush( rmesa ); \
-+ } while (0)
-+
- #define R300_STATECHANGE(r300, atom) \
- do { \
-+ R300_NEWPRIM(r300); \
- r300->hw.atom.dirty = GL_TRUE; \
- r300->hw.is_dirty = GL_TRUE; \
- } while(0)
-diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c
-new file mode 100644
-index 0000000..c949f33
---- /dev/null
-+++ b/src/mesa/drivers/dri/r300/r300_swtcl.c
-@@ -0,0 +1,711 @@
-+/**************************************************************************
-+
-+Copyright (C) 2007 Dave Airlie
-+
-+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 OWNER(S) 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:
-+ * Dave Airlie <airlied@linux.ie>
-+ */
-+
-+/* derived from r200 swtcl path */
-+
-+
-+
-+#include "glheader.h"
-+#include "mtypes.h"
-+#include "colormac.h"
-+#include "enums.h"
-+#include "image.h"
-+#include "imports.h"
-+#include "macros.h"
-+
-+#include "swrast/s_context.h"
-+#include "swrast/s_fog.h"
-+#include "swrast_setup/swrast_setup.h"
-+#include "math/m_translate.h"
-+#include "tnl/tnl.h"
-+#include "tnl/t_context.h"
-+#include "tnl/t_pipeline.h"
-+
-+#include "r300_context.h"
-+#include "r300_swtcl.h"
-+#include "r300_state.h"
-+#include "r300_ioctl.h"
-+#include "r300_emit.h"
-+#include "r300_mem.h"
-+
-+static void flush_last_swtcl_prim( r300ContextPtr rmesa );
-+
-+
-+void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset);
-+void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr);
-+#define EMIT_ATTR( ATTR, STYLE ) \
-+do { \
-+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = (ATTR); \
-+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = (STYLE); \
-+ rmesa->swtcl.vertex_attr_count++; \
-+} while (0)
-+
-+#define EMIT_PAD( N ) \
-+do { \
-+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = 0; \
-+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = EMIT_PAD; \
-+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].offset = (N); \
-+ rmesa->swtcl.vertex_attr_count++; \
-+} while (0)
-+
-+/* this differs from the VIR0 in emit.c - TODO merge them using another option */
-+static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
-+ int *inputs, GLint * tab, GLuint nr)
-+{
-+ GLuint i, dw;
-+
-+ /* type, inputs, stop bit, size */
-+ for (i = 0; i + 1 < nr; i += 2) {
-+ dw = (inputs[tab[i]] << 8) | 0x3;
-+ dw |= ((inputs[tab[i + 1]] << 8) | 0x3) << 16;
-+ if (i + 2 == nr) {
-+ dw |= (R300_VAP_INPUT_ROUTE_END << 16);
-+ }
-+ dst[i >> 1] = dw;
-+ }
-+
-+ if (nr & 1) {
-+ dw = (inputs[tab[nr - 1]] << 8) | 0x3;
-+ dw |= R300_VAP_INPUT_ROUTE_END;
-+ dst[nr >> 1] = dw;
-+ }
-+
-+ return (nr + 1) >> 1;
-+}
-+
-+static void r300SetVertexFormat( GLcontext *ctx )
-+{
-+ r300ContextPtr rmesa = R300_CONTEXT( ctx );
-+ TNLcontext *tnl = TNL_CONTEXT(ctx);
-+ struct vertex_buffer *VB = &tnl->vb;
-+ DECLARE_RENDERINPUTS(index_bitset);
-+ GLuint InputsRead = 0, OutputsWritten = 0;
-+ int vap_fmt_0 = 0;
-+ int vap_vte_cntl = 0;
-+ int offset = 0;
-+ int vte = 0;
-+ GLint inputs[VERT_ATTRIB_MAX];
-+ GLint tab[VERT_ATTRIB_MAX];
-+ int swizzle[VERT_ATTRIB_MAX][4];
-+ GLuint i, nr;
-+
-+ DECLARE_RENDERINPUTS(render_inputs_bitset);
-+ RENDERINPUTS_COPY(render_inputs_bitset, tnl->render_inputs_bitset);
-+ RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
-+ RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset, render_inputs_bitset);
-+
-+ /* Important:
-+ */
-+ if ( VB->NdcPtr != NULL ) {
-+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
-+ }
-+ else {
-+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->ClipPtr;
-+ }
-+
-+ assert( VB->AttribPtr[VERT_ATTRIB_POS] != NULL );
-+ rmesa->swtcl.vertex_attr_count = 0;
-+
-+ /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
-+ * build up a hardware vertex.
-+ */
-+ if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POS)) {
-+ vap_vte_cntl |= R300_VTX_W0_FMT;
-+ InputsRead |= 1 << VERT_ATTRIB_POS;
-+ OutputsWritten |= 1 << VERT_RESULT_HPOS;
-+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F );
-+ } else
-+ EMIT_PAD(4 * sizeof(float));
-+
-+ offset = 4;
-+
-+ if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) {
-+ EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F );
-+ vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
-+ offset += 1;
-+ }
-+
-+ if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR0)) {
-+ rmesa->swtcl.coloroffset = offset;
-+ InputsRead |= 1 << VERT_ATTRIB_COLOR0;
-+ OutputsWritten |= 1 << VERT_RESULT_COL0;
-+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F );
-+ }
-+
-+ offset += 4;
-+
-+ rmesa->swtcl.specoffset = 0;
-+ if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) {
-+ rmesa->swtcl.specoffset = offset;
-+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F );
-+ InputsRead |= 1 << VERT_ATTRIB_COLOR1;
-+ OutputsWritten |= 1 << VERT_RESULT_COL1;
-+ }
-+
-+ if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) {
-+ int i;
-+
-+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-+ if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
-+ InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i);
-+ OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i);
-+ EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_4F );
-+ }
-+ }
-+ }
-+
-+ for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) {
-+ if (InputsRead & (1 << i)) {
-+ inputs[i] = nr++;
-+ } else {
-+ inputs[i] = -1;
-+ }
-+ }
-+
-+ /* Fixed, apply to vir0 only */
-+ if (InputsRead & (1 << VERT_ATTRIB_POS))
-+ inputs[VERT_ATTRIB_POS] = 0;
-+ if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
-+ inputs[VERT_ATTRIB_COLOR0] = 2;
-+ if (InputsRead & (1 << VERT_ATTRIB_COLOR1))
-+ inputs[VERT_ATTRIB_COLOR1] = 3;
-+ for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++)
-+ if (InputsRead & (1 << i))
-+ inputs[i] = 6 + (i - VERT_ATTRIB_TEX0);
-+
-+ for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) {
-+ if (InputsRead & (1 << i)) {
-+ tab[nr++] = i;
-+ }
-+ }
-+
-+ for (i = 0; i < nr; i++) {
-+ int ci;
-+
-+ swizzle[i][0] = SWIZZLE_ZERO;
-+ swizzle[i][1] = SWIZZLE_ZERO;
-+ swizzle[i][2] = SWIZZLE_ZERO;
-+ swizzle[i][3] = SWIZZLE_ONE;
-+
-+ for (ci = 0; ci < VB->AttribPtr[tab[i]]->size; ci++) {
-+ swizzle[i][ci] = ci;
-+ }
-+ }
-+
-+ R300_NEWPRIM(rmesa);
-+ R300_STATECHANGE(rmesa, vir[0]);
-+ ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count =
-+ r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0],
-+ VB->AttribPtr, inputs, tab, nr);
-+ R300_STATECHANGE(rmesa, vir[1]);
-+ ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count =
-+ r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle,
-+ nr);
-+
-+ R300_STATECHANGE(rmesa, vic);
-+ rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead);
-+ rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead);
-+
-+ R300_STATECHANGE(rmesa, vof);
-+ rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = r300VAPOutputCntl0(ctx, OutputsWritten);
-+ rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = r300VAPOutputCntl1(ctx, OutputsWritten);
-+
-+ rmesa->swtcl.vertex_size =
-+ _tnl_install_attrs( ctx,
-+ rmesa->swtcl.vertex_attrs,
-+ rmesa->swtcl.vertex_attr_count,
-+ NULL, 0 );
-+
-+ rmesa->swtcl.vertex_size /= 4;
-+
-+ RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset );
-+
-+ vte = rmesa->hw.vte.cmd[1];
-+ R300_STATECHANGE(rmesa, vte);
-+ rmesa->hw.vte.cmd[1] = vte;
-+ rmesa->hw.vte.cmd[2] = rmesa->swtcl.vertex_size;
-+}
-+
-+
-+/* Flush vertices in the current dma region.
-+ */
-+static void flush_last_swtcl_prim( r300ContextPtr rmesa )
-+{
-+ if (RADEON_DEBUG & DEBUG_IOCTL)
-+ fprintf(stderr, "%s\n", __FUNCTION__);
-+
-+ rmesa->dma.flush = NULL;
-+
-+ if (rmesa->dma.current.buf) {
-+ struct r300_dma_region *current = &rmesa->dma.current;
-+ GLuint current_offset = GET_START(current);
-+
-+ assert (current->start +
-+ rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
-+ current->ptr);
-+
-+ if (rmesa->dma.current.start != rmesa->dma.current.ptr) {
-+
-+ r300EnsureCmdBufSpace( rmesa, rmesa->hw.max_state_size + (12*sizeof(int)), __FUNCTION__);
-+
-+ r300EmitState(rmesa);
-+
-+ r300EmitVertexAOS( rmesa,
-+ rmesa->swtcl.vertex_size,
-+ current_offset);
-+
-+ r300EmitVbufPrim( rmesa,
-+ rmesa->swtcl.hw_primitive,
-+ rmesa->swtcl.numverts);
-+
-+ r300EmitCacheFlush(rmesa);
-+ }
-+
-+ rmesa->swtcl.numverts = 0;
-+ current->start = current->ptr;
-+ }
-+}
-+
-+/* Alloc space in the current dma region.
-+ */
-+static void *
-+r300AllocDmaLowVerts( r300ContextPtr rmesa, int nverts, int vsize )
-+{
-+ GLuint bytes = vsize * nverts;
-+
-+ if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end )
-+ r300RefillCurrentDmaRegion( rmesa, bytes);
-+
-+ if (!rmesa->dma.flush) {
-+ rmesa->radeon.glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
-+ rmesa->dma.flush = flush_last_swtcl_prim;
-+ }
-+
-+ ASSERT( vsize == rmesa->swtcl.vertex_size * 4 );
-+ ASSERT( rmesa->dma.flush == flush_last_swtcl_prim );
-+ ASSERT( rmesa->dma.current.start +
-+ rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
-+ rmesa->dma.current.ptr );
-+
-+ {
-+ GLubyte *head = (GLubyte *) (rmesa->dma.current.address + rmesa->dma.current.ptr);
-+ rmesa->dma.current.ptr += bytes;
-+ rmesa->swtcl.numverts += nverts;
-+ return head;
-+ }
-+}
-+
-+static GLuint reduced_prim[] = {
-+ GL_POINTS,
-+ GL_LINES,
-+ GL_LINES,
-+ GL_LINES,
-+ GL_TRIANGLES,
-+ GL_TRIANGLES,
-+ GL_TRIANGLES,
-+ GL_TRIANGLES,
-+ GL_TRIANGLES,
-+ GL_TRIANGLES,
-+};
-+
-+static void r300RasterPrimitive( GLcontext *ctx, GLuint prim );
-+static void r300RenderPrimitive( GLcontext *ctx, GLenum prim );
-+//static void r300ResetLineStipple( GLcontext *ctx );
-+
-+/***********************************************************************
-+ * Emit primitives as inline vertices *
-+ ***********************************************************************/
-+
-+
-+#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 0
-+#define HAVE_QUAD_STRIPS 0
-+#define HAVE_POLYGONS 1
-+#define HAVE_ELTS 1
-+
-+#undef LOCAL_VARS
-+#undef ALLOC_VERTS
-+#define CTX_ARG r300ContextPtr rmesa
-+#define GET_VERTEX_DWORDS() rmesa->swtcl.vertex_size
-+#define ALLOC_VERTS( n, size ) r300AllocDmaLowVerts( rmesa, n, size * 4 )
-+#define LOCAL_VARS \
-+ r300ContextPtr rmesa = R300_CONTEXT(ctx); \
-+ const char *r300verts = (char *)rmesa->swtcl.verts;
-+#define VERT(x) (r300Vertex *)(r300verts + ((x) * vertsize * sizeof(int)))
-+#define VERTEX r300Vertex
-+#define DO_DEBUG_VERTS (1 && (RADEON_DEBUG & DEBUG_VERTS))
-+#define PRINT_VERTEX(x)
-+#undef TAG
-+#define TAG(x) r300_##x
-+#include "tnl_dd/t_dd_triemit.h"
-+
-+
-+
-+/***********************************************************************
-+ * Macros for t_dd_tritmp.h to draw basic primitives *
-+ ***********************************************************************/
-+
-+#define QUAD( a, b, c, d ) r300_quad( rmesa, a, b, c, d )
-+#define TRI( a, b, c ) r300_triangle( rmesa, a, b, c )
-+#define LINE( a, b ) r300_line( rmesa, a, b )
-+#define POINT( a ) r300_point( rmesa, a )
-+
-+/***********************************************************************
-+ * Build render functions from dd templates *
-+ ***********************************************************************/
-+
-+#define R300_TWOSIDE_BIT 0x01
-+#define R300_UNFILLED_BIT 0x02
-+#define R300_MAX_TRIFUNC 0x04
-+
-+static struct {
-+ tnl_points_func points;
-+ tnl_line_func line;
-+ tnl_triangle_func triangle;
-+ tnl_quad_func quad;
-+} rast_tab[R300_MAX_TRIFUNC];
-+
-+#define DO_FALLBACK 0
-+#define DO_UNFILLED (IND & R300_UNFILLED_BIT)
-+#define DO_TWOSIDE (IND & R300_TWOSIDE_BIT)
-+#define DO_FLAT 0
-+#define DO_OFFSET 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 1
-+#define HAVE_BACK_COLORS 0
-+#define HAVE_HW_FLATSHADE 1
-+#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) (rmesa->swtcl.verts + (e*rmesa->swtcl.vertex_size*sizeof(int)))
-+
-+/* Only used to pull back colors into vertices (ie, we know color is
-+ * floating point).
-+ */
-+#define R300_COLOR( dst, src ) \
-+do { \
-+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]); \
-+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]); \
-+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]); \
-+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[3], (src)[3]); \
-+} while (0)
-+
-+#define VERT_SET_RGBA( v, c ) if (coloroffset) R300_COLOR( v->ub4[coloroffset], c )
-+#define VERT_COPY_RGBA( v0, v1 ) if (coloroffset) v0->ui[coloroffset] = v1->ui[coloroffset]
-+#define VERT_SAVE_RGBA( idx ) if (coloroffset) color[idx] = v[idx]->ui[coloroffset]
-+#define VERT_RESTORE_RGBA( idx ) if (coloroffset) v[idx]->ui[coloroffset] = color[idx]
-+
-+#define R300_SPEC( dst, src ) \
-+do { \
-+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]); \
-+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]); \
-+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]); \
-+} while (0)
-+
-+#define VERT_SET_SPEC( v, c ) if (specoffset) R300_SPEC( v->ub4[specoffset], c )
-+#define VERT_COPY_SPEC( v0, v1 ) if (specoffset) COPY_3V(v0->ub4[specoffset], v1->ub4[specoffset])
-+#define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset]
-+#define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx]
-+
-+#undef LOCAL_VARS
-+#undef TAG
-+#undef INIT
-+
-+#define LOCAL_VARS(n) \
-+ r300ContextPtr rmesa = R300_CONTEXT(ctx); \
-+ GLuint color[n], spec[n]; \
-+ GLuint coloroffset = rmesa->swtcl.coloroffset; \
-+ GLuint specoffset = rmesa->swtcl.specoffset; \
-+ (void) color; (void) spec; (void) coloroffset; (void) specoffset;
-+
-+/***********************************************************************
-+ * Helpers for rendering unfilled primitives *
-+ ***********************************************************************/
-+
-+#define RASTERIZE(x) r300RasterPrimitive( ctx, reduced_prim[x] )
-+#define RENDER_PRIMITIVE rmesa->swtcl.render_primitive
-+#undef TAG
-+#define TAG(x) x
-+#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 (R300_TWOSIDE_BIT)
-+#define TAG(x) x##_twoside
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (R300_UNFILLED_BIT)
-+#define TAG(x) x##_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (R300_TWOSIDE_BIT|R300_UNFILLED_BIT)
-+#define TAG(x) x##_twoside_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+
-+
-+static void init_rast_tab( void )
-+{
-+ init();
-+ init_twoside();
-+ init_unfilled();
-+ init_twoside_unfilled();
-+}
-+
-+/**********************************************************************/
-+/* Render unclipped begin/end objects */
-+/**********************************************************************/
-+
-+#define RENDER_POINTS( start, count ) \
-+ for ( ; start < count ; start++) \
-+ r300_point( rmesa, VERT(start) )
-+#define RENDER_LINE( v0, v1 ) \
-+ r300_line( rmesa, VERT(v0), VERT(v1) )
-+#define RENDER_TRI( v0, v1, v2 ) \
-+ r300_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) )
-+#define RENDER_QUAD( v0, v1, v2, v3 ) \
-+ r300_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
-+#define INIT(x) do { \
-+ r300RenderPrimitive( ctx, x ); \
-+} while (0)
-+#undef LOCAL_VARS
-+#define LOCAL_VARS \
-+ r300ContextPtr rmesa = R300_CONTEXT(ctx); \
-+ const GLuint vertsize = rmesa->swtcl.vertex_size; \
-+ const char *r300verts = (char *)rmesa->swtcl.verts; \
-+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
-+ const GLboolean stipple = ctx->Line.StippleFlag; \
-+ (void) elt; (void) stipple;
-+#define RESET_STIPPLE //if ( stipple ) r200ResetLineStipple( ctx );
-+#define RESET_OCCLUSION
-+#define PRESERVE_VB_DEFS
-+#define ELT(x) (x)
-+#define TAG(x) r300_##x##_verts
-+#include "tnl/t_vb_rendertmp.h"
-+#undef ELT
-+#undef TAG
-+#define TAG(x) r300_##x##_elts
-+#define ELT(x) elt[x]
-+#include "tnl/t_vb_rendertmp.h"
-+
-+
-+
-+
-+/**********************************************************************/
-+/* Choose render functions */
-+/**********************************************************************/
-+static void r300ChooseRenderState( GLcontext *ctx )
-+{
-+ TNLcontext *tnl = TNL_CONTEXT(ctx);
-+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
-+ GLuint index = 0;
-+ GLuint flags = ctx->_TriangleCaps;
-+
-+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R300_TWOSIDE_BIT;
-+ if (flags & DD_TRI_UNFILLED) index |= R300_UNFILLED_BIT;
-+
-+ if (index != rmesa->swtcl.RenderIndex) {
-+ tnl->Driver.Render.Points = rast_tab[index].points;
-+ tnl->Driver.Render.Line = rast_tab[index].line;
-+ tnl->Driver.Render.ClippedLine = rast_tab[index].line;
-+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
-+ tnl->Driver.Render.Quad = rast_tab[index].quad;
-+
-+ if (index == 0) {
-+ tnl->Driver.Render.PrimTabVerts = r300_render_tab_verts;
-+ tnl->Driver.Render.PrimTabElts = r300_render_tab_elts;
-+ tnl->Driver.Render.ClippedPolygon = r300_fast_clipped_poly;
-+ } else {
-+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
-+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
-+ tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
-+ }
-+
-+ rmesa->swtcl.RenderIndex = index;
-+ }
-+}
-+
-+
-+static void r300RenderStart(GLcontext *ctx)
-+{
-+ r300ContextPtr rmesa = R300_CONTEXT( ctx );
-+ // fprintf(stderr, "%s\n", __FUNCTION__);
-+
-+ r300ChooseRenderState(ctx);
-+ r300SetVertexFormat(ctx);
-+
-+ r300UpdateShaderStates(rmesa);
-+
-+ r300EmitCacheFlush(rmesa);
-+
-+ if (rmesa->dma.flush != 0 &&
-+ rmesa->dma.flush != flush_last_swtcl_prim)
-+ rmesa->dma.flush( rmesa );
-+
-+}
-+
-+static void r300RenderFinish(GLcontext *ctx)
-+{
-+}
-+
-+static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim )
-+{
-+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
-+
-+ if (rmesa->swtcl.hw_primitive != hwprim) {
-+ R300_NEWPRIM( rmesa );
-+ rmesa->swtcl.hw_primitive = hwprim;
-+ }
-+}
-+
-+static void r300RenderPrimitive(GLcontext *ctx, GLenum prim)
-+{
-+
-+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
-+ rmesa->swtcl.render_primitive = prim;
-+
-+ if ((prim == GL_TRIANGLES) && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
-+ return;
-+
-+ r300RasterPrimitive( ctx, reduced_prim[prim] );
-+ // fprintf(stderr, "%s\n", __FUNCTION__);
-+
-+}
-+
-+static void r300ResetLineStipple(GLcontext *ctx)
-+{
-+
-+
-+}
-+
-+void r300InitSwtcl(GLcontext *ctx)
-+{
-+ TNLcontext *tnl = TNL_CONTEXT(ctx);
-+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
-+ static int firsttime = 1;
-+
-+ if (firsttime) {
-+ init_rast_tab();
-+ firsttime = 0;
-+ }
-+
-+ tnl->Driver.Render.Start = r300RenderStart;
-+ tnl->Driver.Render.Finish = r300RenderFinish;
-+ tnl->Driver.Render.PrimitiveNotify = r300RenderPrimitive;
-+ tnl->Driver.Render.ResetLineStipple = r300ResetLineStipple;
-+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
-+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
-+ tnl->Driver.Render.Interp = _tnl_interp;
-+
-+ /* FIXME: what are these numbers? */
-+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
-+ 48 * sizeof(GLfloat) );
-+
-+ rmesa->swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf;
-+ rmesa->swtcl.RenderIndex = ~0;
-+ rmesa->swtcl.render_primitive = GL_TRIANGLES;
-+ rmesa->swtcl.hw_primitive = 0;
-+
-+ _tnl_invalidate_vertex_state( ctx, ~0 );
-+ _tnl_invalidate_vertices( ctx, ~0 );
-+ RENDERINPUTS_ZERO( rmesa->tnl_index_bitset );
-+
-+ _tnl_need_projected_coords( ctx, GL_FALSE );
-+ r300ChooseRenderState(ctx);
-+
-+ _mesa_validate_all_lighting_tables( ctx );
-+
-+ tnl->Driver.NotifyMaterialChange =
-+ _mesa_validate_all_lighting_tables;
-+}
-+
-+void r300DestroySwtcl(GLcontext *ctx)
-+{
-+}
-+
-+void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset)
-+{
-+ int cmd_reserved = 0;
-+ int cmd_written = 0;
-+
-+ drm_radeon_cmd_header_t *cmd = NULL;
-+ if (RADEON_DEBUG & DEBUG_VERTS)
-+ fprintf(stderr, "%s: vertex_size %d, offset 0x%x \n",
-+ __FUNCTION__, vertex_size, offset);
-+
-+ start_packet3(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 2), 2);
-+ e32(1);
-+ e32(vertex_size | (vertex_size << 8));
-+ e32(offset);
-+}
-+
-+void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr)
-+{
-+
-+ int cmd_reserved = 0;
-+ int cmd_written = 0;
-+ int type, num_verts;
-+ drm_radeon_cmd_header_t *cmd = NULL;
-+
-+ type = r300PrimitiveType(rmesa, primitive);
-+ num_verts = r300NumVerts(rmesa, vertex_nr, primitive);
-+
-+ start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0), 0);
-+ e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (num_verts << 16) | type);
-+}
-diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.h b/src/mesa/drivers/dri/r300/r300_swtcl.h
-new file mode 100644
-index 0000000..2ea6ced
---- /dev/null
-+++ b/src/mesa/drivers/dri/r300/r300_swtcl.h
-@@ -0,0 +1,45 @@
-+/*
-+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
-+
-+The Weather Channel (TM) funded Tungsten Graphics to develop the
-+initial release of the Radeon 8500 driver under the XFree86 license.
-+This notice must be preserved.
-+
-+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 COPYRIGHT OWNER(S) 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:
-+ * Keith Whitwell <keith@tungstengraphics.com> - original r200 code
-+ * Dave Airlie <airlied@linux.ie>
-+ */
-+
-+#ifndef __R300_SWTCL_H__
-+#define __R300_SWTCL_H__
-+
-+#include "mtypes.h"
-+#include "swrast/swrast.h"
-+#include "r300_context.h"
-+
-+extern void r300InitSwtcl( GLcontext *ctx );
-+extern void r300DestroySwtcl( GLcontext *ctx );
-+
-+#endif
-diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c
-index 2a21c61..1805cec 100644
---- a/src/mesa/drivers/dri/r300/r300_tex.c
-+++ b/src/mesa/drivers/dri/r300/r300_tex.c
-@@ -294,27 +294,20 @@ static const struct gl_texture_format *r300Choose8888TexFormat(GLenum srcFormat,
- const GLubyte littleEndian = *((const GLubyte *)&ui);
-
- if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
-- (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE
-- && !littleEndian) || (srcFormat == GL_ABGR_EXT
-- && srcType == GL_UNSIGNED_INT_8_8_8_8_REV)
-- || (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE
-- && littleEndian)) {
-+ (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
-+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
-+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian)) {
- return &_mesa_texformat_rgba8888;
-- } else
-- if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV)
-- || (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE
-- && littleEndian) || (srcFormat == GL_ABGR_EXT
-- && srcType == GL_UNSIGNED_INT_8_8_8_8)
-- || (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE
-- && !littleEndian)) {
-+ } else if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
-+ (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
-+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
-+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian)) {
- return &_mesa_texformat_rgba8888_rev;
-- } else if (srcFormat == GL_BGRA &&
-- ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
-- srcType == GL_UNSIGNED_INT_8_8_8_8)) {
-+ } else if (srcFormat == GL_BGRA && ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
-+ srcType == GL_UNSIGNED_INT_8_8_8_8)) {
- return &_mesa_texformat_argb8888_rev;
-- } else if (srcFormat == GL_BGRA &&
-- ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
-- srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
-+ } else if (srcFormat == GL_BGRA && ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
-+ srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
- return &_mesa_texformat_argb8888;
- } else
- return _dri_texformat_argb8888;
-@@ -563,34 +556,31 @@ r300ValidateClientStorage(GLcontext * ctx, GLenum target,
- return 0;
- }
-
-- {
-- GLint srcRowStride = _mesa_image_row_stride(packing, srcWidth,
-- format, type);
-+ GLint srcRowStride = _mesa_image_row_stride(packing, srcWidth,
-+ format, type);
-
-- if (RADEON_DEBUG & DEBUG_TEXTURE)
-- fprintf(stderr, "%s: srcRowStride %d/%x\n",
-- __FUNCTION__, srcRowStride, srcRowStride);
-+ if (RADEON_DEBUG & DEBUG_TEXTURE)
-+ fprintf(stderr, "%s: srcRowStride %d/%x\n",
-+ __FUNCTION__, srcRowStride, srcRowStride);
-
-- /* Could check this later in upload, pitch restrictions could be
-- * relaxed, but would need to store the image pitch somewhere,
-- * as packing details might change before image is uploaded:
-- */
-- if (!r300IsGartMemory(rmesa, pixels, srcHeight * srcRowStride)
-- || (srcRowStride & 63))
-- return 0;
-+ /* Could check this later in upload, pitch restrictions could be
-+ * relaxed, but would need to store the image pitch somewhere,
-+ * as packing details might change before image is uploaded:
-+ */
-+ if (!r300IsGartMemory(rmesa, pixels, srcHeight * srcRowStride)
-+ || (srcRowStride & 63))
-+ return 0;
-
-- /* Have validated that _mesa_transfer_teximage would be a straight
-- * memcpy at this point. NOTE: future calls to TexSubImage will
-- * overwrite the client data. This is explicitly mentioned in the
-- * extension spec.
-- */
-- texImage->Data = (void *)pixels;
-- texImage->IsClientData = GL_TRUE;
-- texImage->RowStride =
-- srcRowStride / texImage->TexFormat->TexelBytes;
-+ /* Have validated that _mesa_transfer_teximage would be a straight
-+ * memcpy at this point. NOTE: future calls to TexSubImage will
-+ * overwrite the client data. This is explicitly mentioned in the
-+ * extension spec.
-+ */
-+ texImage->Data = (void *)pixels;
-+ texImage->IsClientData = GL_TRUE;
-+ texImage->RowStride = srcRowStride / texImage->TexFormat->TexelBytes;
-
-- return 1;
-- }
-+ return 1;
- }
-
- static void r300TexImage1D(GLcontext * ctx, GLenum target, GLint level,
-diff --git a/src/mesa/drivers/dri/r300/r300_texmem.c b/src/mesa/drivers/dri/r300/r300_texmem.c
-index e2e8355..723601a 100644
---- a/src/mesa/drivers/dri/r300/r300_texmem.c
-+++ b/src/mesa/drivers/dri/r300/r300_texmem.c
-@@ -63,29 +63,16 @@ SOFTWARE.
- */
- void r300DestroyTexObj(r300ContextPtr rmesa, r300TexObjPtr t)
- {
-+ int i;
-+
- if (RADEON_DEBUG & DEBUG_TEXTURE) {
- fprintf(stderr, "%s( %p, %p )\n", __FUNCTION__,
- (void *)t, (void *)t->base.tObj);
- }
-
-- if (rmesa != NULL) {
-- unsigned i;
--
-- for (i = 0; i < rmesa->radeon.glCtx->Const.MaxTextureUnits; i++) {
-- if (t == rmesa->state.texture.unit[i].texobj) {
-- rmesa->state.texture.unit[i].texobj = NULL;
-- /* This code below is meant to shorten state
-- pushed to the hardware by not programming
-- unneeded units.
--
-- This does not appear to be worthwhile on R300 */
--#if 0
-- remove_from_list(&rmesa->hw.tex[i]);
-- make_empty_list(&rmesa->hw.tex[i]);
-- remove_from_list(&rmesa->hw.cube[i]);
-- make_empty_list(&rmesa->hw.cube[i]);
--#endif
-- }
-+ for (i = 0; i < rmesa->radeon.glCtx->Const.MaxTextureUnits; i++) {
-+ if (rmesa->state.texture.unit[i].texobj == t) {
-+ rmesa->state.texture.unit[i].texobj = NULL;
- }
- }
- }
-@@ -518,7 +505,7 @@ int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t, GLuint face)
- t->base.lastLevel);
- }
-
-- if (!t || t->base.totalSize == 0)
-+ if (t->base.totalSize == 0)
- return 0;
-
- if (RADEON_DEBUG & DEBUG_SYNC) {
-diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c
-index 8203189..1d2909f 100644
---- a/src/mesa/drivers/dri/r300/r300_texstate.c
-+++ b/src/mesa/drivers/dri/r300/r300_texstate.c
-@@ -54,7 +54,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- #define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5 \
- || ((f) >= MESA_FORMAT_RGBA_FLOAT32 && \
- (f) <= MESA_FORMAT_INTENSITY_FLOAT16)) \
-- && tx_table_le[f].flag )
-+ && tx_table[f].flag )
-
- #define _ASSIGN(entry, format) \
- [ MESA_FORMAT_ ## entry ] = { format, 0, 1}
-@@ -70,53 +70,19 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- static const struct tx_table {
- GLuint format, filter, flag;
--} tx_table_be[] = {
-- /* *INDENT-OFF* */
-- _ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8)),
-- _ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
-- _ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(W, Z, Y, X, W8Z8Y8X8)),
-- _ASSIGN(ARGB8888_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
-- _ASSIGN(RGB888, 0xffffffff),
-- _ASSIGN(RGB565, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
-- _ASSIGN(RGB565_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
-- _ASSIGN(ARGB4444, R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4)),
-- _ASSIGN(ARGB4444_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4)),
-- _ASSIGN(ARGB1555, R300_EASY_TX_FORMAT(X, Y, Z, W, W1Z5Y5X5)),
-- _ASSIGN(ARGB1555_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W1Z5Y5X5)),
-- _ASSIGN(AL88, R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8)),
-- _ASSIGN(AL88_REV, R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8)),
-- _ASSIGN(RGB332, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z3Y3X2)),
-- _ASSIGN(A8, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X8)),
-- _ASSIGN(L8, R300_EASY_TX_FORMAT(X, X, X, ONE, X8)),
-- _ASSIGN(I8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
-- _ASSIGN(CI8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
-- _ASSIGN(YCBCR, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8)|R300_TX_FORMAT_YUV_MODE ),
-- _ASSIGN(YCBCR_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8)|R300_TX_FORMAT_YUV_MODE),
-- _ASSIGN(RGB_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1)),
-- _ASSIGN(RGBA_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1)),
-- _ASSIGN(RGBA_DXT3, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3)),
-- _ASSIGN(RGBA_DXT5, R300_EASY_TX_FORMAT(Y, Z, W, X, DXT5)),
-- _ASSIGN(RGBA_FLOAT32, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R32G32B32A32)),
-- _ASSIGN(RGBA_FLOAT16, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R16G16B16A16)),
-- _ASSIGN(RGB_FLOAT32, 0xffffffff),
-- _ASSIGN(RGB_FLOAT16, 0xffffffff),
-- _ASSIGN(ALPHA_FLOAT32, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I32)),
-- _ASSIGN(ALPHA_FLOAT16, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I16)),
-- _ASSIGN(LUMINANCE_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I32)),
-- _ASSIGN(LUMINANCE_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I16)),
-- _ASSIGN(LUMINANCE_ALPHA_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I32A32)),
-- _ASSIGN(LUMINANCE_ALPHA_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I16A16)),
-- _ASSIGN(INTENSITY_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, X, FL_I32)),
-- _ASSIGN(INTENSITY_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, X, FL_I16)),
-- /* *INDENT-ON* */
--};
--
--static const struct tx_table tx_table_le[] = {
-+} tx_table[] = {
- /* *INDENT-OFF* */
-+#ifdef MESA_LITTLE_ENDIAN
- _ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
- _ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8)),
- _ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
- _ASSIGN(ARGB8888_REV, R300_EASY_TX_FORMAT(W, Z, Y, X, W8Z8Y8X8)),
-+#else
-+ _ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8)),
-+ _ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
-+ _ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(W, Z, Y, X, W8Z8Y8X8)),
-+ _ASSIGN(ARGB8888_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
-+#endif
- _ASSIGN(RGB888, R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8)),
- _ASSIGN(RGB565, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
- _ASSIGN(RGB565_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
-@@ -131,8 +97,8 @@ static const struct tx_table tx_table_le[] = {
- _ASSIGN(L8, R300_EASY_TX_FORMAT(X, X, X, ONE, X8)),
- _ASSIGN(I8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
- _ASSIGN(CI8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
-- _ASSIGN(YCBCR, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8)|R300_TX_FORMAT_YUV_MODE ),
-- _ASSIGN(YCBCR_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8)|R300_TX_FORMAT_YUV_MODE),
-+ _ASSIGN(YCBCR, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8) | R300_TX_FORMAT_YUV_MODE),
-+ _ASSIGN(YCBCR_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8) | R300_TX_FORMAT_YUV_MODE),
- _ASSIGN(RGB_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1)),
- _ASSIGN(RGBA_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1)),
- _ASSIGN(RGBA_DXT3, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3)),
-@@ -178,22 +144,10 @@ static void r300SetTexImages(r300ContextPtr rmesa,
-
- /* Set the hardware texture format
- */
-- if (!t->image_override && VALID_FORMAT(baseImage->TexFormat->MesaFormat)) {
-- if (_mesa_little_endian()) {
-- t->format =
-- tx_table_le[baseImage->TexFormat->MesaFormat].
-- format;
-- t->filter |=
-- tx_table_le[baseImage->TexFormat->MesaFormat].
-- filter;
-- } else {
-- t->format =
-- tx_table_be[baseImage->TexFormat->MesaFormat].
-- format;
-- t->filter |=
-- tx_table_be[baseImage->TexFormat->MesaFormat].
-- filter;
-- }
-+ if (!t->image_override
-+ && VALID_FORMAT(baseImage->TexFormat->MesaFormat)) {
-+ t->format = tx_table[baseImage->TexFormat->MesaFormat].format;
-+ t->filter |= tx_table[baseImage->TexFormat->MesaFormat].filter;
- } else if (!t->image_override) {
- _mesa_problem(NULL, "unexpected texture format in %s",
- __FUNCTION__);
-@@ -526,11 +480,11 @@ static GLboolean r300UpdateTexture(GLcontext * ctx, int unit)
- */
-
- rmesa->state.texture.unit[unit].texobj->base.bound &=
-- ~(1UL << unit);
-+ ~(1 << unit);
- }
-
- rmesa->state.texture.unit[unit].texobj = t;
-- t->base.bound |= (1UL << unit);
-+ t->base.bound |= (1 << unit);
- t->dirty_state |= 1 << unit;
- driUpdateTextureLRU((driTextureObject *) t); /* XXX: should be locked! */
- }
-@@ -538,15 +492,15 @@ static GLboolean r300UpdateTexture(GLcontext * ctx, int unit)
- return !t->border_fallback;
- }
-
--void r300SetTexOffset(__DRIcontext *pDRICtx, GLint texname,
-+void r300SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
- unsigned long long offset, GLint depth, GLuint pitch)
- {
- r300ContextPtr rmesa =
-- (r300ContextPtr)((__DRIcontextPrivate*)pDRICtx->private)->driverPrivate;
-+ (r300ContextPtr) ((__DRIcontextPrivate *) pDRICtx->private)->
-+ driverPrivate;
- struct gl_texture_object *tObj =
-- _mesa_lookup_texture(rmesa->radeon.glCtx, texname);
-+ _mesa_lookup_texture(rmesa->radeon.glCtx, texname);
- r300TexObjPtr t;
-- int idx;
-
- if (!tObj)
- return;
-@@ -563,24 +517,24 @@ void r300SetTexOffset(__DRIcontext *pDRICtx, GLint texname,
-
- switch (depth) {
- case 32:
-- idx = 2;
-+ t->format = R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
-+ t->filter |= tx_table[2].filter;
- t->pitch_reg /= 4;
- break;
- case 24:
- default:
-- idx = 4;
-+ t->format = R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8);
-+ t->filter |= tx_table[4].filter;
- t->pitch_reg /= 4;
- break;
- case 16:
-- idx = 5;
-+ t->format = R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5);
-+ t->filter |= tx_table[5].filter;
- t->pitch_reg /= 2;
- break;
- }
-
- t->pitch_reg--;
--
-- t->format = tx_table_le[idx].format;
-- t->filter |= tx_table_le[idx].filter;
- }
-
- static GLboolean r300UpdateTextureUnit(GLcontext * ctx, int unit)
-diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c
-index 1d90ade..7d4e8c9 100644
---- a/src/mesa/drivers/dri/r300/r300_vertprog.c
-+++ b/src/mesa/drivers/dri/r300/r300_vertprog.c
-@@ -29,6 +29,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
- * \file
- *
- * \author Aapo Tahkola <aet@rasterburn.org>
-+ *
-+ * \author Oliver McFadden <z3ro.geek@gmail.com>
-+ *
-+ * For a description of the vertex program instruction set see r300_reg.h.
- */
-
- #include "glheader.h"
-@@ -55,54 +59,58 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
- #error Cannot change these!
- #endif
-
--#define SCALAR_FLAG (1<<31)
--#define FLAG_MASK (1<<31)
--#define OP_MASK (0xf) /* we are unlikely to have more than 15 */
--#define OPN(operator, ip) {#operator, OPCODE_##operator, ip}
--
--static struct {
-- char *name;
-- int opcode;
-- unsigned long ip; /* number of input operands and flags */
--} op_names[] = {
-- /* *INDENT-OFF* */
-- OPN(ABS, 1),
-- OPN(ADD, 2),
-- OPN(ARL, 1 | SCALAR_FLAG),
-- OPN(DP3, 2),
-- OPN(DP4, 2),
-- OPN(DPH, 2),
-- OPN(DST, 2),
-- OPN(EX2, 1 | SCALAR_FLAG),
-- OPN(EXP, 1 | SCALAR_FLAG),
-- OPN(FLR, 1),
-- OPN(FRC, 1),
-- OPN(LG2, 1 | SCALAR_FLAG),
-- OPN(LIT, 1),
-- OPN(LOG, 1 | SCALAR_FLAG),
-- OPN(MAD, 3),
-- OPN(MAX, 2),
-- OPN(MIN, 2),
-- OPN(MOV, 1),
-- OPN(MUL, 2),
-- OPN(POW, 2 | SCALAR_FLAG),
-- OPN(RCP, 1 | SCALAR_FLAG),
-- OPN(RSQ, 1 | SCALAR_FLAG),
-- OPN(SGE, 2),
-- OPN(SLT, 2),
-- OPN(SUB, 2),
-- OPN(SWZ, 1),
-- OPN(XPD, 2),
-- OPN(RCC, 0), //extra
-- OPN(PRINT, 0),
-- OPN(END, 0)
-- /* *INDENT-ON* */
--};
--
--#undef OPN
-+/* TODO: Get rid of t_src_class call */
-+#define CMP_SRCS(a, b) ((a.RelAddr != b.RelAddr) || (a.Index != b.Index && \
-+ ((t_src_class(a.File) == VSF_IN_CLASS_PARAM && \
-+ t_src_class(b.File) == VSF_IN_CLASS_PARAM) || \
-+ (t_src_class(a.File) == VSF_IN_CLASS_ATTR && \
-+ t_src_class(b.File) == VSF_IN_CLASS_ATTR)))) \
-+
-+#define ZERO_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \
-+ SWIZZLE_ZERO, SWIZZLE_ZERO, \
-+ SWIZZLE_ZERO, SWIZZLE_ZERO, \
-+ t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4))
-+
-+#define ZERO_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
-+ SWIZZLE_ZERO, SWIZZLE_ZERO, \
-+ SWIZZLE_ZERO, SWIZZLE_ZERO, \
-+ t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
-+
-+#define ZERO_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
-+ SWIZZLE_ZERO, SWIZZLE_ZERO, \
-+ SWIZZLE_ZERO, SWIZZLE_ZERO, \
-+ t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
-+
-+#define ONE_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \
-+ SWIZZLE_ONE, SWIZZLE_ONE, \
-+ SWIZZLE_ONE, SWIZZLE_ONE, \
-+ t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4))
-+
-+#define ONE_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
-+ SWIZZLE_ONE, SWIZZLE_ONE, \
-+ SWIZZLE_ONE, SWIZZLE_ONE, \
-+ t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
-+
-+#define ONE_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
-+ SWIZZLE_ONE, SWIZZLE_ONE, \
-+ SWIZZLE_ONE, SWIZZLE_ONE, \
-+ t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
-+
-+/* DP4 version seems to trigger some hw peculiarity */
-+//#define PREFER_DP4
-+
-+#define FREE_TEMPS() \
-+ do { \
-+ if(u_temp_i < vp->num_temporaries) { \
-+ WARN_ONCE("Ran out of temps, num temps %d, us %d\n", vp->num_temporaries, u_temp_i); \
-+ vp->native = GL_FALSE; \
-+ } \
-+ u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \
-+ } while (0)
-
- int r300VertexProgUpdateParams(GLcontext * ctx,
-- struct r300_vertex_program_cont *vp, float *dst)
-+ struct r300_vertex_program_cont *vp,
-+ float *dst)
- {
- int pi;
- struct gl_vertex_program *mesa_vp = &vp->mesa_program;
-@@ -222,7 +230,7 @@ static unsigned long t_src_class(enum register_file file)
- }
- }
-
--static __inline unsigned long t_swizzle(GLubyte swizzle)
-+static inline unsigned long t_swizzle(GLubyte swizzle)
- {
- /* this is in fact a NOP as the Mesa SWIZZLE_* are all identical to VSF_IN_COMPONENT_* */
- return swizzle;
-@@ -234,8 +242,8 @@ static void vp_dump_inputs(struct r300_vertex_program *vp, char *caller)
- int i;
-
- if (vp == NULL) {
-- fprintf(stderr, "vp null in call to %s from %s\n", __FUNCTION__,
-- caller);
-+ fprintf(stderr, "vp null in call to %s from %s\n",
-+ __FUNCTION__, caller);
- return;
- }
-
-@@ -276,6 +284,8 @@ static unsigned long t_src_index(struct r300_vertex_program *vp,
- }
- }
-
-+/* these two functions should probably be merged... */
-+
- static unsigned long t_src(struct r300_vertex_program *vp,
- struct prog_src_register *src)
- {
-@@ -294,7 +304,9 @@ static unsigned long t_src(struct r300_vertex_program *vp,
- static unsigned long t_src_scalar(struct r300_vertex_program *vp,
- struct prog_src_register *src)
- {
--
-+ /* src->NegateBase uses the NEGATE_ flags from program_instruction.h,
-+ * which equal our VSF_FLAGS_ values, so it's safe to just pass it here.
-+ */
- return MAKE_VSF_SOURCE(t_src_index(vp, src),
- t_swizzle(GET_SWZ(src->Swizzle, 0)),
- t_swizzle(GET_SWZ(src->Swizzle, 0)),
-@@ -306,128 +318,741 @@ static unsigned long t_src_scalar(struct r300_vertex_program *vp,
- (src->RelAddr << 4);
- }
-
--static unsigned long t_opcode(enum prog_opcode opcode)
-+static GLboolean valid_dst(struct r300_vertex_program *vp,
-+ struct prog_dst_register *dst)
- {
-+ if (dst->File == PROGRAM_OUTPUT && vp->outputs[dst->Index] == -1) {
-+ return GL_FALSE;
-+ } else if (dst->File == PROGRAM_ADDRESS) {
-+ assert(dst->Index == 0);
-+ }
-
-- switch (opcode) {
-- /* *INDENT-OFF* */
-- case OPCODE_ARL: return R300_VPI_OUT_OP_ARL;
-- case OPCODE_DST: return R300_VPI_OUT_OP_DST;
-- case OPCODE_EX2: return R300_VPI_OUT_OP_EX2;
-- case OPCODE_EXP: return R300_VPI_OUT_OP_EXP;
-- case OPCODE_FRC: return R300_VPI_OUT_OP_FRC;
-- case OPCODE_LG2: return R300_VPI_OUT_OP_LG2;
-- case OPCODE_LOG: return R300_VPI_OUT_OP_LOG;
-- case OPCODE_MAX: return R300_VPI_OUT_OP_MAX;
-- case OPCODE_MIN: return R300_VPI_OUT_OP_MIN;
-- case OPCODE_MUL: return R300_VPI_OUT_OP_MUL;
-- case OPCODE_RCP: return R300_VPI_OUT_OP_RCP;
-- case OPCODE_RSQ: return R300_VPI_OUT_OP_RSQ;
-- case OPCODE_SGE: return R300_VPI_OUT_OP_SGE;
-- case OPCODE_SLT: return R300_VPI_OUT_OP_SLT;
-- case OPCODE_DP4: return R300_VPI_OUT_OP_DOT;
-- /* *INDENT-ON* */
-+ return GL_TRUE;
-+}
-
-- default:
-- fprintf(stderr, "%s: Should not be called with opcode %d!",
-- __FUNCTION__, opcode);
-- }
-- _mesa_exit(-1);
-- return 0;
-+/*
-+ * Instruction Inputs Output Description
-+ * ----------- ------ ------ --------------------------------
-+ * ABS v v absolute value
-+ * ADD v,v v add
-+ * ARL s a address register load
-+ * DP3 v,v ssss 3-component dot product
-+ * DP4 v,v ssss 4-component dot product
-+ * DPH v,v ssss homogeneous dot product
-+ * DST v,v v distance vector
-+ * EX2 s ssss exponential base 2
-+ * EXP s v exponential base 2 (approximate)
-+ * FLR v v floor
-+ * FRC v v fraction
-+ * LG2 s ssss logarithm base 2
-+ * LIT v v compute light coefficients
-+ * LOG s v logarithm base 2 (approximate)
-+ * MAD v,v,v v multiply and add
-+ * MAX v,v v maximum
-+ * MIN v,v v minimum
-+ * MOV v v move
-+ * MUL v,v v multiply
-+ * POW s,s ssss exponentiate
-+ * RCP s ssss reciprocal
-+ * RSQ s ssss reciprocal square root
-+ * SGE v,v v set on greater than or equal
-+ * SLT v,v v set on less than
-+ * SUB v,v v subtract
-+ * SWZ v v extended swizzle
-+ * XPD v,v v cross product
-+ *
-+ * Table X.5: Summary of vertex program instructions. "v" indicates a
-+ * floating-point vector input or output, "s" indicates a floating-point
-+ * scalar input, "ssss" indicates a scalar output replicated across a
-+ * 4-component result vector, and "a" indicates a single address register
-+ * component.
-+ */
-+
-+static GLuint *t_opcode_abs(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ //MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
-+
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] =
-+ MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)),
-+ t_src_class(src[0].File),
-+ (!src[0].
-+ NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
-+ (src[0].RelAddr << 4);
-+ inst[3] = 0;
-+
-+ return inst;
- }
-
--static unsigned long op_operands(enum prog_opcode opcode)
-+static GLuint *t_opcode_add(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
- {
-- int i;
-+ unsigned long hw_op;
-
-- /* Can we trust mesas opcodes to be in order ? */
-- for (i = 0; i < sizeof(op_names) / sizeof(*op_names); i++)
-- if (op_names[i].opcode == opcode)
-- return op_names[i].ip;
-+#if 1
-+ hw_op = (src[0].File == PROGRAM_TEMPORARY
-+ && src[1].File ==
-+ PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-+ R300_VPI_OUT_OP_MAD;
-+
-+ inst[0] =
-+ MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+ inst[1] = ONE_SRC_0;
-+ inst[2] = t_src(vp, &src[0]);
-+ inst[3] = t_src(vp, &src[1]);
-+#else
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = t_src(vp, &src[1]);
-+ inst[3] = ZERO_SRC_1;
-
-- fprintf(stderr, "op %d not found in op_names\n", opcode);
-- _mesa_exit(-1);
-- return 0;
-+#endif
-+
-+ return inst;
- }
-
--static GLboolean valid_dst(struct r300_vertex_program *vp,
-- struct prog_dst_register *dst)
-+static GLuint *t_opcode_arl(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
- {
-- if (dst->File == PROGRAM_OUTPUT && vp->outputs[dst->Index] == -1) {
-- return GL_FALSE;
-- } else if (dst->File == PROGRAM_ADDRESS) {
-- assert(dst->Index == 0);
-- }
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_ARL, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-
-- return GL_TRUE;
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+
-+ return inst;
- }
-
--/* TODO: Get rid of t_src_class call */
--#define CMP_SRCS(a, b) ((a.RelAddr != b.RelAddr) || (a.Index != b.Index && \
-- ((t_src_class(a.File) == VSF_IN_CLASS_PARAM && \
-- t_src_class(b.File) == VSF_IN_CLASS_PARAM) || \
-- (t_src_class(a.File) == VSF_IN_CLASS_ATTR && \
-- t_src_class(b.File) == VSF_IN_CLASS_ATTR)))) \
-+static GLuint *t_opcode_dp3(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO}
-+
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] =
-+ MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
-+ SWIZZLE_ZERO, t_src_class(src[0].File),
-+ src[0].
-+ NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
-+ (src[0].RelAddr << 4);
-+
-+ inst[2] =
-+ MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
-+ SWIZZLE_ZERO, t_src_class(src[1].File),
-+ src[1].
-+ NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
-+ (src[1].RelAddr << 4);
-+
-+ inst[3] = ZERO_SRC_1;
-+
-+ return inst;
-+}
-
--#define ZERO_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \
-- SWIZZLE_ZERO, SWIZZLE_ZERO, \
-- SWIZZLE_ZERO, SWIZZLE_ZERO, \
-- t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4))
-+static GLuint *t_opcode_dp4(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-
--#define ZERO_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
-- SWIZZLE_ZERO, SWIZZLE_ZERO, \
-- SWIZZLE_ZERO, SWIZZLE_ZERO, \
-- t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = t_src(vp, &src[1]);
-+ inst[3] = ZERO_SRC_1;
-
--#define ZERO_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
-- SWIZZLE_ZERO, SWIZZLE_ZERO, \
-- SWIZZLE_ZERO, SWIZZLE_ZERO, \
-- t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
-+ return inst;
-+}
-
--#define ONE_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \
-- SWIZZLE_ONE, SWIZZLE_ONE, \
-- SWIZZLE_ONE, SWIZZLE_ONE, \
-- t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4))
-+static GLuint *t_opcode_dph(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W}
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] =
-+ MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
-+ VSF_IN_COMPONENT_ONE, t_src_class(src[0].File),
-+ src[0].
-+ NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
-+ (src[0].RelAddr << 4);
-+ inst[2] = t_src(vp, &src[1]);
-+ inst[3] = ZERO_SRC_1;
-+
-+ return inst;
-+}
-
--#define ONE_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
-- SWIZZLE_ONE, SWIZZLE_ONE, \
-- SWIZZLE_ONE, SWIZZLE_ONE, \
-- t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
-+static GLuint *t_opcode_dst(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_DST, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-
--#define ONE_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
-- SWIZZLE_ONE, SWIZZLE_ONE, \
-- SWIZZLE_ONE, SWIZZLE_ONE, \
-- t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = t_src(vp, &src[1]);
-+ inst[3] = ZERO_SRC_1;
-
--/* DP4 version seems to trigger some hw peculiarity */
--//#define PREFER_DP4
-+ return inst;
-+}
-
--#define FREE_TEMPS() \
-- do { \
-- if(u_temp_i < vp->num_temporaries) { \
-- WARN_ONCE("Ran out of temps, num temps %d, us %d\n", vp->num_temporaries, u_temp_i); \
-- vp->native = GL_FALSE; \
-- } \
-- u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \
-- } while (0)
-+static GLuint *t_opcode_ex2(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_EX2, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-
--static void r300TranslateVertexShader(struct r300_vertex_program *vp,
-- struct prog_instruction *vpi)
-+ inst[1] = t_src_scalar(vp, &src[0]);
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_exp(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_EXP, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = t_src_scalar(vp, &src[0]);
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_flr(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3], int *u_temp_i)
-+{
-+ /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W}
-+ ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */
-+
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, *u_temp_i,
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ VSF_OUT_CLASS_TMP);
-+
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+ inst += 4;
-+
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] =
-+ MAKE_VSF_SOURCE(*u_temp_i, VSF_IN_COMPONENT_X,
-+ VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z,
-+ VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP,
-+ /* Not 100% sure about this */
-+ (!src[0].
-+ NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE
-+ /*VSF_FLAG_ALL */ );
-+
-+ inst[3] = ZERO_SRC_0;
-+ (*u_temp_i)--;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_frc(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_lg2(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ // LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X}
-+
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_LG2, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] =
-+ MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
-+ t_src_class(src[0].File),
-+ src[0].
-+ NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
-+ (src[0].RelAddr << 4);
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_lit(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ //LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W}
-+
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_LIT, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+ /* NOTE: Users swizzling might not work. */
-+ inst[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-+ VSF_IN_COMPONENT_ZERO, // z
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
-+ t_src_class(src[0].File),
-+ src[0].
-+ NegateBase ? VSF_FLAG_ALL :
-+ VSF_FLAG_NONE) | (src[0].RelAddr << 4);
-+ inst[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-+ VSF_IN_COMPONENT_ZERO, // z
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-+ t_src_class(src[0].File),
-+ src[0].
-+ NegateBase ? VSF_FLAG_ALL :
-+ VSF_FLAG_NONE) | (src[0].RelAddr << 4);
-+ inst[3] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-+ VSF_IN_COMPONENT_ZERO, // z
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-+ t_src_class(src[0].File),
-+ src[0].
-+ NegateBase ? VSF_FLAG_ALL :
-+ VSF_FLAG_NONE) | (src[0].RelAddr << 4);
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_log(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_LOG, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = t_src_scalar(vp, &src[0]);
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_mad(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
- {
-- int i, cur_reg = 0;
-- VERTEX_SHADER_INSTRUCTION *o_inst;
-- unsigned long operands;
-- int are_srcs_scalar;
- unsigned long hw_op;
-- /* Initial value should be last tmp reg that hw supports.
-- Strangely enough r300 doesnt mind even though these would be out of range.
-- Smart enough to realize that it doesnt need it? */
-- int u_temp_i = VSF_MAX_FRAGMENT_TEMPS - 1;
-- struct prog_src_register src[3];
-
-- vp->pos_end = 0; /* Not supported yet */
-- vp->program.length = 0;
-- /*vp->num_temporaries=mesa_vp->Base.NumTemporaries; */
-+ hw_op = (src[0].File == PROGRAM_TEMPORARY
-+ && src[1].File == PROGRAM_TEMPORARY
-+ && src[2].File ==
-+ PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-+ R300_VPI_OUT_OP_MAD;
-+
-+ inst[0] =
-+ MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = t_src(vp, &src[1]);
-+ inst[3] = t_src(vp, &src[2]);
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_max(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = t_src(vp, &src[1]);
-+ inst[3] = ZERO_SRC_1;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_min(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_MIN, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = t_src(vp, &src[1]);
-+ inst[3] = ZERO_SRC_1;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_mov(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
-+
-+#if 1
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+#else
-+ hw_op =
-+ (src[0].File ==
-+ PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-+ R300_VPI_OUT_OP_MAD;
-+
-+ inst[0] =
-+ MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = ONE_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+#endif
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_mul(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ unsigned long hw_op;
-+
-+ // HW mul can take third arg but appears to have some other limitations.
-+
-+ hw_op = (src[0].File == PROGRAM_TEMPORARY
-+ && src[1].File ==
-+ PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-+ R300_VPI_OUT_OP_MAD;
-+
-+ inst[0] =
-+ MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = t_src(vp, &src[1]);
-+
-+ inst[3] = ZERO_SRC_1;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_pow(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_POW, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+ inst[1] = t_src_scalar(vp, &src[0]);
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = t_src_scalar(vp, &src[1]);
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_rcp(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_RCP, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = t_src_scalar(vp, &src[0]);
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_rsq(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_RSQ, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = t_src_scalar(vp, &src[0]);
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_sge(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_SGE, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = t_src(vp, &src[1]);
-+ inst[3] = ZERO_SRC_1;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_slt(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_SLT, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = t_src(vp, &src[1]);
-+ inst[3] = ZERO_SRC_1;
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_sub(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ unsigned long hw_op;
-+
-+ //ADD RESULT 1.X Y Z W TMP 0{} {X Y Z W} PARAM 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
-+
-+#if 1
-+ hw_op = (src[0].File == PROGRAM_TEMPORARY
-+ && src[1].File ==
-+ PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-+ R300_VPI_OUT_OP_MAD;
-+
-+ inst[0] =
-+ MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = ONE_SRC_0;
-+ inst[3] =
-+ MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
-+ t_src_class(src[1].File),
-+ (!src[1].
-+ NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
-+ (src[1].RelAddr << 4);
-+#else
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] =
-+ MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
-+ t_src_class(src[1].File),
-+ (!src[1].
-+ NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
-+ (src[1].RelAddr << 4);
-+ inst[3] = 0;
-+#endif
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_swz(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3])
-+{
-+ //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
-+
-+#if 1
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+#else
-+ hw_op =
-+ (src[0].File ==
-+ PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-+ R300_VPI_OUT_OP_MAD;
-+
-+ inst[0] =
-+ MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+ inst[1] = t_src(vp, &src[0]);
-+ inst[2] = ONE_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+#endif
-+
-+ return inst;
-+}
-+
-+static GLuint *t_opcode_xpd(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi, GLuint * inst,
-+ struct prog_src_register src[3], int *u_temp_i)
-+{
-+ /* mul r0, r1.yzxw, r2.zxyw
-+ mad r0, -r2.yzxw, r1.zxyw, r0
-+ NOTE: might need MAD_2
-+ */
-+
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, *u_temp_i,
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ VSF_OUT_CLASS_TMP);
-+
-+ inst[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-+ t_src_class(src[0].File),
-+ src[0].
-+ NegateBase ? VSF_FLAG_ALL :
-+ VSF_FLAG_NONE) | (src[0].RelAddr << 4);
-+
-+ inst[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
-+ t_src_class(src[1].File),
-+ src[1].
-+ NegateBase ? VSF_FLAG_ALL :
-+ VSF_FLAG_NONE) | (src[1].RelAddr << 4);
-+
-+ inst[3] = ZERO_SRC_1;
-+ inst += 4;
-+ (*u_temp_i)--;
-+
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, t_dst_index(vp, &vpi->DstReg),
-+ t_dst_mask(vpi->DstReg.WriteMask),
-+ t_dst_class(vpi->DstReg.File));
-+
-+ inst[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
-+ t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
-+ t_src_class(src[1].File),
-+ (!src[1].
-+ NegateBase) ? VSF_FLAG_ALL :
-+ VSF_FLAG_NONE) | (src[1].RelAddr << 4);
-+
-+ inst[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
-+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-+ t_src_class(src[0].File),
-+ src[0].
-+ NegateBase ? VSF_FLAG_ALL :
-+ VSF_FLAG_NONE) | (src[0].RelAddr << 4);
-+
-+ inst[3] =
-+ MAKE_VSF_SOURCE(*u_temp_i + 1, VSF_IN_COMPONENT_X,
-+ VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z,
-+ VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP,
-+ VSF_FLAG_NONE);
-+
-+ return inst;
-+}
-+
-+static void t_inputs_outputs(struct r300_vertex_program *vp)
-+{
-+ int i;
-+ int cur_reg = 0;
-
- for (i = 0; i < VERT_ATTRIB_MAX; i++)
- vp->inputs[i] = -1;
-@@ -437,39 +1062,71 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
-
- assert(vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS));
-
-- /* Assign outputs */
-- if (vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS))
-+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS)) {
- vp->outputs[VERT_RESULT_HPOS] = cur_reg++;
-+ }
-
-- if (vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ))
-+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ)) {
- vp->outputs[VERT_RESULT_PSIZ] = cur_reg++;
-+ }
-
-- if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL0))
-+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL0)) {
- vp->outputs[VERT_RESULT_COL0] = cur_reg++;
-+ }
-
-- if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL1))
-- vp->outputs[VERT_RESULT_COL1] = cur_reg++;
--
--#if 0 /* Not supported yet */
-- if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0))
-- vp->outputs[VERT_RESULT_BFC0] = cur_reg++;
-+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL1)) {
-+ vp->outputs[VERT_RESULT_COL1] =
-+ vp->outputs[VERT_RESULT_COL0] + 1;
-+ cur_reg = vp->outputs[VERT_RESULT_COL1] + 1;
-+ }
-
-- if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1))
-- vp->outputs[VERT_RESULT_BFC1] = cur_reg++;
-+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) {
-+ vp->outputs[VERT_RESULT_BFC0] =
-+ vp->outputs[VERT_RESULT_COL0] + 2;
-+ cur_reg = vp->outputs[VERT_RESULT_BFC0] + 2;
-+ }
-
-- if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC))
-+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) {
-+ vp->outputs[VERT_RESULT_BFC1] =
-+ vp->outputs[VERT_RESULT_COL0] + 3;
-+ cur_reg = vp->outputs[VERT_RESULT_BFC1] + 1;
-+ }
-+#if 0
-+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) {
- vp->outputs[VERT_RESULT_FOGC] = cur_reg++;
-+ }
- #endif
-
-- for (i = VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++)
-- if (vp->key.OutputsWritten & (1 << i))
-+ for (i = VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++) {
-+ if (vp->key.OutputsWritten & (1 << i)) {
- vp->outputs[i] = cur_reg++;
-+ }
-+ }
-+}
-+
-+static void r300TranslateVertexShader(struct r300_vertex_program *vp,
-+ struct prog_instruction *vpi)
-+{
-+ int i;
-+ GLuint *inst;
-+ unsigned long num_operands;
-+ /* Initial value should be last tmp reg that hw supports.
-+ Strangely enough r300 doesnt mind even though these would be out of range.
-+ Smart enough to realize that it doesnt need it? */
-+ int u_temp_i = VSF_MAX_FRAGMENT_TEMPS - 1;
-+ struct prog_src_register src[3];
-
-+ vp->pos_end = 0; /* Not supported yet */
-+ vp->program.length = 0;
-+ /*vp->num_temporaries=mesa_vp->Base.NumTemporaries; */
- vp->translated = GL_TRUE;
- vp->native = GL_TRUE;
-
-- o_inst = vp->program.body.i;
-- for (; vpi->Opcode != OPCODE_END; vpi++, o_inst++) {
-+ t_inputs_outputs(vp);
-+
-+ for (inst = vp->program.body.i; vpi->Opcode != OPCODE_END;
-+ vpi++, inst += 4) {
-+
- FREE_TEMPS();
-
- if (!valid_dst(vp, &vpi->DstReg)) {
-@@ -478,61 +1135,62 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
- vpi->DstReg.Index = u_temp_i;
- }
-
-- operands = op_operands(vpi->Opcode);
-- are_srcs_scalar = operands & SCALAR_FLAG;
-- operands &= OP_MASK;
-+ num_operands = _mesa_num_inst_src_regs(vpi->Opcode);
-
-- for (i = 0; i < operands; i++)
-+ /* copy the sources (src) from mesa into a local variable... is this needed? */
-+ for (i = 0; i < num_operands; i++) {
- src[i] = vpi->SrcReg[i];
-+ }
-
-- if (operands == 3) { /* TODO: scalars */
-+ if (num_operands == 3) { /* TODO: scalars */
- if (CMP_SRCS(src[1], src[2])
- || CMP_SRCS(src[0], src[2])) {
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i,
-- VSF_FLAG_ALL,
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
-+ u_temp_i, VSF_FLAG_ALL,
- VSF_OUT_CLASS_TMP);
-
-- o_inst->src[0] =
-- MAKE_VSF_SOURCE(t_src_index(vp, &src[2]),
-+ inst[1] =
-+ MAKE_VSF_SOURCE(t_src_index
-+ (vp, &src[2]),
- SWIZZLE_X, SWIZZLE_Y,
- SWIZZLE_Z, SWIZZLE_W,
-- t_src_class(src[2].File),
-- VSF_FLAG_NONE) | (src[2].
-- RelAddr <<
-- 4);
-+ t_src_class(src[2].
-+ File),
-+ VSF_FLAG_NONE) |
-+ (src[2].RelAddr << 4);
-
-- o_inst->src[1] = ZERO_SRC_2;
-- o_inst->src[2] = ZERO_SRC_2;
-- o_inst++;
-+ inst[2] = ZERO_SRC_2;
-+ inst[3] = ZERO_SRC_2;
-+ inst += 4;
-
- src[2].File = PROGRAM_TEMPORARY;
- src[2].Index = u_temp_i;
- src[2].RelAddr = 0;
- u_temp_i--;
- }
--
- }
-
-- if (operands >= 2) {
-+ if (num_operands >= 2) {
- if (CMP_SRCS(src[1], src[0])) {
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i,
-- VSF_FLAG_ALL,
-+ inst[0] =
-+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
-+ u_temp_i, VSF_FLAG_ALL,
- VSF_OUT_CLASS_TMP);
-
-- o_inst->src[0] =
-- MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-+ inst[1] =
-+ MAKE_VSF_SOURCE(t_src_index
-+ (vp, &src[0]),
- SWIZZLE_X, SWIZZLE_Y,
- SWIZZLE_Z, SWIZZLE_W,
-- t_src_class(src[0].File),
-- VSF_FLAG_NONE) | (src[0].
-- RelAddr <<
-- 4);
-+ t_src_class(src[0].
-+ File),
-+ VSF_FLAG_NONE) |
-+ (src[0].RelAddr << 4);
-
-- o_inst->src[1] = ZERO_SRC_0;
-- o_inst->src[2] = ZERO_SRC_0;
-- o_inst++;
-+ inst[2] = ZERO_SRC_0;
-+ inst[3] = ZERO_SRC_0;
-+ inst += 4;
-
- src[0].File = PROGRAM_TEMPORARY;
- src[0].Index = u_temp_i;
-@@ -541,517 +1199,103 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
- }
- }
-
-- /* These ops need special handling. */
- switch (vpi->Opcode) {
-- case OPCODE_POW:
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_POW,
-- t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
-- o_inst->src[0] = t_src_scalar(vp, &src[0]);
-- o_inst->src[1] = ZERO_SRC_0;
-- o_inst->src[2] = t_src_scalar(vp, &src[1]);
-- goto next;
--
-- case OPCODE_MOV: //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
-- case OPCODE_SWZ:
--#if 1
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
-- t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] = ZERO_SRC_0;
-- o_inst->src[2] = ZERO_SRC_0;
--#else
-- hw_op =
-- (src[0].File ==
-- PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-- R300_VPI_OUT_OP_MAD;
--
-- o_inst->op =
-- MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] = ONE_SRC_0;
-- o_inst->src[2] = ZERO_SRC_0;
--#endif
--
-- goto next;
--
-+ case OPCODE_ABS:
-+ inst = t_opcode_abs(vp, vpi, inst, src);
-+ break;
- case OPCODE_ADD:
--#if 1
-- hw_op = (src[0].File == PROGRAM_TEMPORARY &&
-- src[1].File ==
-- PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-- R300_VPI_OUT_OP_MAD;
--
-- o_inst->op =
-- MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
-- o_inst->src[0] = ONE_SRC_0;
-- o_inst->src[1] = t_src(vp, &src[0]);
-- o_inst->src[2] = t_src(vp, &src[1]);
--#else
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
-- t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] = t_src(vp, &src[1]);
-- o_inst->src[2] = ZERO_SRC_1;
--
--#endif
-- goto next;
--
-- case OPCODE_MAD:
-- hw_op = (src[0].File == PROGRAM_TEMPORARY &&
-- src[1].File == PROGRAM_TEMPORARY &&
-- src[2].File ==
-- PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-- R300_VPI_OUT_OP_MAD;
--
-- o_inst->op =
-- MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] = t_src(vp, &src[1]);
-- o_inst->src[2] = t_src(vp, &src[2]);
-- goto next;
--
-- case OPCODE_MUL: /* HW mul can take third arg but appears to have some other limitations. */
-- hw_op = (src[0].File == PROGRAM_TEMPORARY &&
-- src[1].File ==
-- PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-- R300_VPI_OUT_OP_MAD;
--
-- o_inst->op =
-- MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] = t_src(vp, &src[1]);
--
-- o_inst->src[2] = ZERO_SRC_1;
-- goto next;
--
-- case OPCODE_DP3: //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO}
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_DOT,
-- t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
--
-- o_inst->src[0] =
-- MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 0)),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 1)),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 2)),
-- SWIZZLE_ZERO,
-- t_src_class(src[0].File),
-- src[0].
-- NegateBase ? VSF_FLAG_XYZ :
-- VSF_FLAG_NONE) | (src[0].
-- RelAddr << 4);
--
-- o_inst->src[1] =
-- MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
-- t_swizzle(GET_SWZ
-- (src[1].Swizzle, 0)),
-- t_swizzle(GET_SWZ
-- (src[1].Swizzle, 1)),
-- t_swizzle(GET_SWZ
-- (src[1].Swizzle, 2)),
-- SWIZZLE_ZERO,
-- t_src_class(src[1].File),
-- src[1].
-- NegateBase ? VSF_FLAG_XYZ :
-- VSF_FLAG_NONE) | (src[1].
-- RelAddr << 4);
--
-- o_inst->src[2] = ZERO_SRC_1;
-- goto next;
--
-- case OPCODE_SUB: //ADD RESULT 1.X Y Z W TMP 0{} {X Y Z W} PARAM 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
--#if 1
-- hw_op = (src[0].File == PROGRAM_TEMPORARY &&
-- src[1].File ==
-- PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-- R300_VPI_OUT_OP_MAD;
--
-- o_inst->op =
-- MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] = ONE_SRC_0;
-- o_inst->src[2] =
-- MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
-- t_swizzle(GET_SWZ
-- (src[1].Swizzle, 0)),
-- t_swizzle(GET_SWZ
-- (src[1].Swizzle, 1)),
-- t_swizzle(GET_SWZ
-- (src[1].Swizzle, 2)),
-- t_swizzle(GET_SWZ
-- (src[1].Swizzle, 3)),
-- t_src_class(src[1].File),
-- (!src[1].
-- NegateBase) ? VSF_FLAG_ALL :
-- VSF_FLAG_NONE) | (src[1].
-- RelAddr << 4);
--#else
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
-- t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
--
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] =
-- MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
-- t_swizzle(GET_SWZ
-- (src[1].Swizzle, 0)),
-- t_swizzle(GET_SWZ
-- (src[1].Swizzle, 1)),
-- t_swizzle(GET_SWZ
-- (src[1].Swizzle, 2)),
-- t_swizzle(GET_SWZ
-- (src[1].Swizzle, 3)),
-- t_src_class(src[1].File),
-- (!src[1].
-- NegateBase) ? VSF_FLAG_ALL :
-- VSF_FLAG_NONE) | (src[1].
-- RelAddr << 4);
-- o_inst->src[2] = 0;
--#endif
-- goto next;
--
-- case OPCODE_ABS: //MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_MAX,
-- t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
--
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] =
-- MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 0)),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 1)),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 2)),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 3)),
-- t_src_class(src[0].File),
-- (!src[0].
-- NegateBase) ? VSF_FLAG_ALL :
-- VSF_FLAG_NONE) | (src[0].
-- RelAddr << 4);
-- o_inst->src[2] = 0;
-- goto next;
--
-+ inst = t_opcode_add(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_ARL:
-+ inst = t_opcode_arl(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_DP3:
-+ inst = t_opcode_dp3(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_DP4:
-+ inst = t_opcode_dp4(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_DPH:
-+ inst = t_opcode_dph(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_DST:
-+ inst = t_opcode_dst(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_EX2:
-+ inst = t_opcode_ex2(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_EXP:
-+ inst = t_opcode_exp(vp, vpi, inst, src);
-+ break;
- case OPCODE_FLR:
-- /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W}
-- ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */
--
-- o_inst->op = MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, u_temp_i,
-- t_dst_mask(vpi->DstReg.
-- WriteMask),
-- VSF_OUT_CLASS_TMP);
--
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] = ZERO_SRC_0;
-- o_inst->src[2] = ZERO_SRC_0;
-- o_inst++;
--
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
-- t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
--
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] = MAKE_VSF_SOURCE(u_temp_i,
-- VSF_IN_COMPONENT_X,
-- VSF_IN_COMPONENT_Y,
-- VSF_IN_COMPONENT_Z,
-- VSF_IN_COMPONENT_W,
-- VSF_IN_CLASS_TMP,
-- /* Not 100% sure about this */
-- (!src[0].
-- NegateBase) ?
-- VSF_FLAG_ALL :
-- VSF_FLAG_NONE
-- /*VSF_FLAG_ALL */ );
--
-- o_inst->src[2] = ZERO_SRC_0;
-- u_temp_i--;
-- goto next;
--
-- case OPCODE_LG2: // LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X}
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_LG2,
-- t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
--
-- o_inst->src[0] =
-- MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 0)),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 0)),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 0)),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 0)),
-- t_src_class(src[0].File),
-- src[0].
-- NegateBase ? VSF_FLAG_ALL :
-- VSF_FLAG_NONE) | (src[0].
-- RelAddr << 4);
-- o_inst->src[1] = ZERO_SRC_0;
-- o_inst->src[2] = ZERO_SRC_0;
-- goto next;
--
-- case OPCODE_LIT: //LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W}
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_LIT,
-- t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
-- /* NOTE: Users swizzling might not work. */
-- o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-- t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-- VSF_IN_COMPONENT_ZERO, // z
-- t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
-- t_src_class(src[0].
-- File),
-- src[0].
-- NegateBase ?
-- VSF_FLAG_ALL :
-- VSF_FLAG_NONE) |
-- (src[0].RelAddr << 4);
-- o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
-- t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-- VSF_IN_COMPONENT_ZERO, // z
-- t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-- t_src_class(src[0].
-- File),
-- src[0].
-- NegateBase ?
-- VSF_FLAG_ALL :
-- VSF_FLAG_NONE) |
-- (src[0].RelAddr << 4);
-- o_inst->src[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
-- t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-- VSF_IN_COMPONENT_ZERO, // z
-- t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-- t_src_class(src[0].
-- File),
-- src[0].
-- NegateBase ?
-- VSF_FLAG_ALL :
-- VSF_FLAG_NONE) |
-- (src[0].RelAddr << 4);
-- goto next;
--
-- case OPCODE_DPH: //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W}
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_DOT,
-- t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
--
-- o_inst->src[0] =
-- MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 0)),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 1)),
-- t_swizzle(GET_SWZ
-- (src[0].Swizzle, 2)),
-- VSF_IN_COMPONENT_ONE,
-- t_src_class(src[0].File),
-- src[0].
-- NegateBase ? VSF_FLAG_XYZ :
-- VSF_FLAG_NONE) | (src[0].
-- RelAddr << 4);
-- o_inst->src[1] = t_src(vp, &src[1]);
-- o_inst->src[2] = ZERO_SRC_1;
-- goto next;
--
-- case OPCODE_XPD:
-- /* mul r0, r1.yzxw, r2.zxyw
-- mad r0, -r2.yzxw, r1.zxyw, r0
-- NOTE: might need MAD_2
-- */
--
-- o_inst->op = MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, u_temp_i,
-- t_dst_mask(vpi->DstReg.
-- WriteMask),
-- VSF_OUT_CLASS_TMP);
--
-- o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
-- t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
-- t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-- t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-- t_src_class(src[0].
-- File),
-- src[0].
-- NegateBase ?
-- VSF_FLAG_ALL :
-- VSF_FLAG_NONE) |
-- (src[0].RelAddr << 4);
--
-- o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
-- t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
-- t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
-- t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
-- t_src_class(src[1].
-- File),
-- src[1].
-- NegateBase ?
-- VSF_FLAG_ALL :
-- VSF_FLAG_NONE) |
-- (src[1].RelAddr << 4);
--
-- o_inst->src[2] = ZERO_SRC_1;
-- o_inst++;
-- u_temp_i--;
--
-- o_inst->op =
-- MAKE_VSF_OP(R300_VPI_OUT_OP_MAD,
-- t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
--
-- o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
-- t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
-- t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
-- t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
-- t_src_class(src[1].
-- File),
-- (!src[1].
-- NegateBase) ?
-- VSF_FLAG_ALL :
-- VSF_FLAG_NONE) |
-- (src[1].RelAddr << 4);
--
-- o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
-- t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-- t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
-- t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-- t_src_class(src[0].
-- File),
-- src[0].
-- NegateBase ?
-- VSF_FLAG_ALL :
-- VSF_FLAG_NONE) |
-- (src[0].RelAddr << 4);
--
-- o_inst->src[2] = MAKE_VSF_SOURCE(u_temp_i + 1,
-- VSF_IN_COMPONENT_X,
-- VSF_IN_COMPONENT_Y,
-- VSF_IN_COMPONENT_Z,
-- VSF_IN_COMPONENT_W,
-- VSF_IN_CLASS_TMP,
-- VSF_FLAG_NONE);
--
-- goto next;
--
-- case OPCODE_RCC:
-- fprintf(stderr, "Dont know how to handle op %d yet\n",
-- vpi->Opcode);
-- _mesa_exit(-1);
-+ inst =
-+ t_opcode_flr(vp, vpi, inst, src, /* FIXME */
-+ &u_temp_i);
-+ break;
-+ case OPCODE_FRC:
-+ inst = t_opcode_frc(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_LG2:
-+ inst = t_opcode_lg2(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_LIT:
-+ inst = t_opcode_lit(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_LOG:
-+ inst = t_opcode_log(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_MAD:
-+ inst = t_opcode_mad(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_MAX:
-+ inst = t_opcode_max(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_MIN:
-+ inst = t_opcode_min(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_MOV:
-+ inst = t_opcode_mov(vp, vpi, inst, src);
- break;
-- case OPCODE_END:
-+ case OPCODE_MUL:
-+ inst = t_opcode_mul(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_POW:
-+ inst = t_opcode_pow(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_RCP:
-+ inst = t_opcode_rcp(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_RSQ:
-+ inst = t_opcode_rsq(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_SGE:
-+ inst = t_opcode_sge(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_SLT:
-+ inst = t_opcode_slt(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_SUB:
-+ inst = t_opcode_sub(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_SWZ:
-+ inst = t_opcode_swz(vp, vpi, inst, src);
-+ break;
-+ case OPCODE_XPD:
-+ inst =
-+ t_opcode_xpd(vp, vpi, inst, src, /* FIXME */
-+ &u_temp_i);
- break;
- default:
-+ assert(0);
- break;
- }
--
-- o_inst->op =
-- MAKE_VSF_OP(t_opcode(vpi->Opcode),
-- t_dst_index(vp, &vpi->DstReg),
-- t_dst_mask(vpi->DstReg.WriteMask),
-- t_dst_class(vpi->DstReg.File));
--
-- if (are_srcs_scalar) {
-- switch (operands) {
-- case 1:
-- o_inst->src[0] = t_src_scalar(vp, &src[0]);
-- o_inst->src[1] = ZERO_SRC_0;
-- o_inst->src[2] = ZERO_SRC_0;
-- break;
--
-- case 2:
-- o_inst->src[0] = t_src_scalar(vp, &src[0]);
-- o_inst->src[1] = t_src_scalar(vp, &src[1]);
-- o_inst->src[2] = ZERO_SRC_1;
-- break;
--
-- case 3:
-- o_inst->src[0] = t_src_scalar(vp, &src[0]);
-- o_inst->src[1] = t_src_scalar(vp, &src[1]);
-- o_inst->src[2] = t_src_scalar(vp, &src[2]);
-- break;
--
-- default:
-- fprintf(stderr,
-- "scalars and op RCC not handled yet");
-- _mesa_exit(-1);
-- break;
-- }
-- } else {
-- switch (operands) {
-- case 1:
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] = ZERO_SRC_0;
-- o_inst->src[2] = ZERO_SRC_0;
-- break;
--
-- case 2:
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] = t_src(vp, &src[1]);
-- o_inst->src[2] = ZERO_SRC_1;
-- break;
--
-- case 3:
-- o_inst->src[0] = t_src(vp, &src[0]);
-- o_inst->src[1] = t_src(vp, &src[1]);
-- o_inst->src[2] = t_src(vp, &src[2]);
-- break;
--
-- default:
-- fprintf(stderr,
-- "scalars and op RCC not handled yet");
-- _mesa_exit(-1);
-- break;
-- }
-- }
-- next:;
- }
-
-- /* Will most likely segfault before we get here... fix later. */
-- if (o_inst - vp->program.body.i >= VSF_MAX_FRAGMENT_LENGTH / 4) {
-+ vp->program.length = (inst - vp->program.body.i);
-+ if (vp->program.length >= VSF_MAX_FRAGMENT_LENGTH) {
- vp->program.length = 0;
- vp->native = GL_FALSE;
-- return;
- }
-- vp->program.length = (o_inst - vp->program.body.i) * 4;
- #if 0
- fprintf(stderr, "hw program:\n");
- for (i = 0; i < vp->program.length; i++)
-@@ -1065,7 +1309,8 @@ static void position_invariant(struct gl_program *prog)
- struct gl_program_parameter_list *paramList;
- int i;
-
-- gl_state_index tokens[STATE_LENGTH] = { STATE_MVP_MATRIX, 0, 0, 0, 0 };
-+ gl_state_index tokens[STATE_LENGTH] =
-+ { STATE_MVP_MATRIX, 0, 0, 0, 0 };
-
- /* tokens[4] = matrix modifier */
- #ifdef PREFER_DP4
-@@ -1159,8 +1404,8 @@ static void insert_wpos(struct r300_vertex_program *vp,
- prog->NumInstructions - 1);
- /* END */
- _mesa_copy_instructions(&vpi[prog->NumInstructions + 1],
-- &prog->Instructions[prog->NumInstructions - 1],
-- 1);
-+ &prog->Instructions[prog->NumInstructions -
-+ 1], 1);
- vpi_insert = &vpi[prog->NumInstructions - 1];
-
- vpi_insert[i].Opcode = OPCODE_MOV;
-@@ -1206,8 +1451,8 @@ static void pos_as_texcoord(struct r300_vertex_program *vp,
- prog->NumTemporaries++;
-
- for (vpi = prog->Instructions; vpi->Opcode != OPCODE_END; vpi++) {
-- if (vpi->DstReg.File == PROGRAM_OUTPUT &&
-- vpi->DstReg.Index == VERT_RESULT_HPOS) {
-+ if (vpi->DstReg.File == PROGRAM_OUTPUT
-+ && vpi->DstReg.Index == VERT_RESULT_HPOS) {
- vpi->DstReg.File = PROGRAM_TEMPORARY;
- vpi->DstReg.Index = tempregi;
- }
-@@ -1223,20 +1468,18 @@ static struct r300_vertex_program *build_program(struct r300_vertex_program_key
-
- vp = _mesa_calloc(sizeof(*vp));
- _mesa_memcpy(&vp->key, wanted_key, sizeof(vp->key));
--
- vp->wpos_idx = wpos_idx;
-
- if (mesa_vp->IsPositionInvariant) {
- position_invariant(&mesa_vp->Base);
- }
-
-- if (wpos_idx > -1)
-+ if (wpos_idx > -1) {
- pos_as_texcoord(vp, &mesa_vp->Base);
-+ }
-
- assert(mesa_vp->Base.NumInstructions);
--
- vp->num_temporaries = mesa_vp->Base.NumTemporaries;
--
- r300TranslateVertexShader(vp, mesa_vp->Base.Instructions);
-
- return vp;
-@@ -1252,11 +1495,10 @@ void r300SelectVertexShader(r300ContextPtr r300)
- struct r300_vertex_program *vp;
- GLint wpos_idx;
-
-- vpc = (struct r300_vertex_program_cont *)ctx->VertexProgram._Current;
-+ vpc =
-+ (struct r300_vertex_program_cont *)ctx->VertexProgram._Current;
- InputsRead = ctx->FragmentProgram._Current->Base.InputsRead;
-
-- wanted_key.OutputsWritten |= 1 << VERT_RESULT_HPOS;
--
- wpos_idx = -1;
- if (InputsRead & FRAG_BIT_WPOS) {
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
-@@ -1271,28 +1513,35 @@ void r300SelectVertexShader(r300ContextPtr r300)
- InputsRead |= (FRAG_BIT_TEX0 << i);
- wpos_idx = i;
- }
-+ wanted_key.InputsRead = vpc->mesa_program.Base.InputsRead;
-+ wanted_key.OutputsWritten = vpc->mesa_program.Base.OutputsWritten;
-+
-+ wanted_key.OutputsWritten |= 1 << VERT_RESULT_HPOS;
-
-- if (InputsRead & FRAG_BIT_COL0)
-+ if (InputsRead & FRAG_BIT_COL0) {
- wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL0;
-+ }
-
-- if ((InputsRead & FRAG_BIT_COL1) /*||
-- (InputsRead & FRAG_BIT_FOGC) */ )
-+ if ((InputsRead & FRAG_BIT_COL1)) {
- wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL1;
-+ }
-
-- for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
-- if (InputsRead & (FRAG_BIT_TEX0 << i))
-+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-+ if (InputsRead & (FRAG_BIT_TEX0 << i)) {
- wanted_key.OutputsWritten |=
- 1 << (VERT_RESULT_TEX0 + i);
-+ }
-+ }
-
-- wanted_key.InputsRead = vpc->mesa_program.Base.InputsRead;
- if (vpc->mesa_program.IsPositionInvariant) {
- /* we wan't position don't we ? */
- wanted_key.InputsRead |= (1 << VERT_ATTRIB_POS);
-+ wanted_key.OutputsWritten |= (1 << VERT_RESULT_HPOS);
- }
-
- for (vp = vpc->progs; vp; vp = vp->next)
-- if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key)) ==
-- 0) {
-+ if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key))
-+ == 0) {
- r300->selected_vp = vp;
- return;
- }
-diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.h b/src/mesa/drivers/dri/r300/r300_vertprog.h
-index 252d5a9..3df0eee 100644
---- a/src/mesa/drivers/dri/r300/r300_vertprog.h
-+++ b/src/mesa/drivers/dri/r300/r300_vertprog.h
-@@ -3,11 +3,6 @@
-
- #include "r300_reg.h"
-
--typedef struct {
-- GLuint op;
-- GLuint src[3];
--} VERTEX_SHADER_INSTRUCTION;
--
- #define VSF_FLAG_X 1
- #define VSF_FLAG_Y 2
- #define VSF_FLAG_Z 4
-diff --git a/src/mesa/drivers/dri/r300/radeon_lock.h b/src/mesa/drivers/dri/r300/radeon_lock.h
-index c47adc9..a344837 100644
---- a/src/mesa/drivers/dri/r300/radeon_lock.h
-+++ b/src/mesa/drivers/dri/r300/radeon_lock.h
-@@ -42,9 +42,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- #ifndef __RADEON_LOCK_H__
- #define __RADEON_LOCK_H__
-
--#if 0
--#include "r200_ioctl.h"
--#endif
- #include "radeon_context.h"
-
- extern void radeonGetLock(radeonContextPtr rmesa, GLuint flags);
diff --git a/mesa-7.0.1-r200-settexoffset.patch b/mesa-7.0.1-r200-settexoffset.patch
deleted file mode 100644
index edf33e6..0000000
--- a/mesa-7.0.1-r200-settexoffset.patch
+++ /dev/null
@@ -1,243 +0,0 @@
-4f96000e294fa0d6ba6f5915ff508017d9c26d50
-diff --git a/src/mesa/drivers/dri/r200/r200_context.h b/src/mesa/drivers/dri/r200/r200_context.h
-index bec09e8..c80180b 100644
---- a/src/mesa/drivers/dri/r200/r200_context.h
-+++ b/src/mesa/drivers/dri/r200/r200_context.h
-@@ -179,6 +179,7 @@ struct r200_tex_obj {
-
- drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
- /* Six, for the cube faces */
-+ GLboolean image_override; /* Image overridden by GLX_EXT_tfp */
-
- GLuint pp_txfilter; /* hardware register values */
- GLuint pp_txformat;
-diff --git a/src/mesa/drivers/dri/r200/r200_tex.h b/src/mesa/drivers/dri/r200/r200_tex.h
-index e6c0e00..10ff8e8 100644
---- a/src/mesa/drivers/dri/r200/r200_tex.h
-+++ b/src/mesa/drivers/dri/r200/r200_tex.h
-@@ -35,6 +35,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- #ifndef __R200_TEX_H__
- #define __R200_TEX_H__
-
-+extern void r200SetTexOffset(__DRIcontext *pDRICtx, GLint texname,
-+ unsigned long long offset, GLint depth,
-+ GLuint pitch);
-+
- extern void r200UpdateTextureState( GLcontext *ctx );
-
- extern int r200UploadTexImages( r200ContextPtr rmesa, r200TexObjPtr t, GLuint face );
-diff --git a/src/mesa/drivers/dri/r200/r200_texmem.c b/src/mesa/drivers/dri/r200/r200_texmem.c
-index d926313..183c4ca 100644
---- a/src/mesa/drivers/dri/r200/r200_texmem.c
-+++ b/src/mesa/drivers/dri/r200/r200_texmem.c
-@@ -181,7 +181,8 @@ static void r200UploadRectSubImage( r200ContextPtr rmesa,
- /* In this case, could also use GART texturing. This is
- * currently disabled, but has been tested & works.
- */
-- t->pp_txoffset = r200GartOffsetFromVirtual( rmesa, texImage->Data );
-+ if ( !t->image_override )
-+ t->pp_txoffset = r200GartOffsetFromVirtual( rmesa, texImage->Data );
- t->pp_txpitch = texImage->RowStride * texFormat->TexelBytes - 32;
-
- if (R200_DEBUG & DEBUG_TEXTURE)
-@@ -467,7 +468,7 @@ int r200UploadTexImages( r200ContextPtr rmesa, r200TexObjPtr t, GLuint face )
- t->base.firstLevel, t->base.lastLevel );
- }
-
-- if ( !t || t->base.totalSize == 0 )
-+ if ( !t || t->base.totalSize == 0 || t->image_override )
- return 0;
-
- if (R200_DEBUG & DEBUG_SYNC) {
-diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c
-index ae02ec4..93c0fb7 100644
---- a/src/mesa/drivers/dri/r200/r200_texstate.c
-+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
-@@ -37,6 +37,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- #include "context.h"
- #include "macros.h"
- #include "texformat.h"
-+#include "texobj.h"
- #include "enums.h"
-
- #include "r200_context.h"
-@@ -72,10 +73,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- #define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5) \
- && (tx_table_le[f].format != 0xffffffff) )
-
--static const struct {
-+struct tx_table {
- GLuint format, filter;
--}
--tx_table_be[] =
-+};
-+
-+static const struct tx_table tx_table_be[] =
- {
- [ MESA_FORMAT_RGBA8888 ] = { R200_TXFORMAT_ABGR8888 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
- _ALPHA_REV(RGBA8888),
-@@ -104,16 +106,13 @@ tx_table_be[] =
- _ALPHA(RGBA_DXT5),
- };
-
--static const struct {
-- GLuint format, filter;
--}
--tx_table_le[] =
-+static const struct tx_table tx_table_le[] =
- {
- _ALPHA(RGBA8888),
- [ MESA_FORMAT_RGBA8888_REV ] = { R200_TXFORMAT_ABGR8888 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
- _ALPHA(ARGB8888),
- _ALPHA_REV(ARGB8888),
-- _INVALID(RGB888),
-+ [ MESA_FORMAT_RGB888 ] = { R200_TXFORMAT_ARGB8888, 0 },
- _COLOR(RGB565),
- _COLOR_REV(RGB565),
- _ALPHA(ARGB4444),
-@@ -160,30 +159,23 @@ static void r200SetTexImages( r200ContextPtr rmesa,
- GLint i, texelBytes;
- GLint numLevels;
- GLint log2Width, log2Height, log2Depth;
-- const GLuint ui = 1;
-- const GLubyte littleEndian = *((const GLubyte *) &ui);
-
- /* Set the hardware texture format
- */
-+ if ( !t->image_override ) {
-+ if ( VALID_FORMAT( baseImage->TexFormat->MesaFormat ) ) {
-+ t->pp_txformat &= ~(R200_TXFORMAT_FORMAT_MASK |
-+ R200_TXFORMAT_ALPHA_IN_MAP);
-+ t->pp_txfilter &= ~R200_YUV_TO_RGB;
-
-- t->pp_txformat &= ~(R200_TXFORMAT_FORMAT_MASK |
-- R200_TXFORMAT_ALPHA_IN_MAP);
-- t->pp_txfilter &= ~R200_YUV_TO_RGB;
--
-- if ( VALID_FORMAT( baseImage->TexFormat->MesaFormat ) ) {
-- if (littleEndian) {
- t->pp_txformat |= tx_table_le[ baseImage->TexFormat->MesaFormat ].format;
- t->pp_txfilter |= tx_table_le[ baseImage->TexFormat->MesaFormat ].filter;
- }
- else {
-- t->pp_txformat |= tx_table_be[ baseImage->TexFormat->MesaFormat ].format;
-- t->pp_txfilter |= tx_table_be[ baseImage->TexFormat->MesaFormat ].filter;
-+ _mesa_problem(NULL, "unexpected texture format in %s", __FUNCTION__);
-+ return;
- }
- }
-- else {
-- _mesa_problem(NULL, "unexpected texture format in %s", __FUNCTION__);
-- return;
-- }
-
- texelBytes = baseImage->TexFormat->TexelBytes;
-
-@@ -380,11 +372,13 @@ static void r200SetTexImages( r200ContextPtr rmesa,
- * requires 64-byte aligned pitches, and we may/may not need the
- * blitter. NPOT only!
- */
-- if (baseImage->IsCompressed)
-- t->pp_txpitch = (tObj->Image[0][t->base.firstLevel]->Width + 63) & ~(63);
-- else
-- t->pp_txpitch = ((tObj->Image[0][t->base.firstLevel]->Width * texelBytes) + 63) & ~(63);
-- t->pp_txpitch -= 32;
-+ if ( !t->image_override ) {
-+ if (baseImage->IsCompressed)
-+ t->pp_txpitch = (tObj->Image[0][t->base.firstLevel]->Width + 63) & ~(63);
-+ else
-+ t->pp_txpitch = ((tObj->Image[0][t->base.firstLevel]->Width * texelBytes) + 63) & ~(63);
-+ t->pp_txpitch -= 32;
-+ }
-
- t->dirty_state = TEX_ALL;
-
-@@ -979,6 +973,46 @@ static GLboolean r200UpdateTextureEnv( GLcontext *ctx, int unit, int slot, GLuin
- return GL_TRUE;
- }
-
-+void r200SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
-+ unsigned long long offset, GLint depth, GLuint pitch)
-+{
-+ r200ContextPtr rmesa =
-+ (r200ContextPtr) ((__DRIcontextPrivate *) pDRICtx->private)->
-+ driverPrivate;
-+ struct gl_texture_object *tObj =
-+ _mesa_lookup_texture(rmesa->glCtx, texname);
-+ r200TexObjPtr t;
-+
-+ if (!tObj)
-+ return;
-+
-+ t = (r200TexObjPtr) tObj->DriverData;
-+
-+ t->image_override = GL_TRUE;
-+
-+ if (!offset)
-+ return;
-+
-+ t->pp_txoffset = offset;
-+ t->pp_txpitch = pitch - 32;
-+
-+ switch (depth) {
-+ case 32:
-+ t->pp_txformat = tx_table_le[2].format;
-+ t->pp_txfilter |= tx_table_le[2].filter;
-+ break;
-+ case 24:
-+ default:
-+ t->pp_txformat = tx_table_le[4].format;
-+ t->pp_txfilter |= tx_table_le[4].filter;
-+ break;
-+ case 16:
-+ t->pp_txformat = tx_table_le[5].format;
-+ t->pp_txfilter |= tx_table_le[5].filter;
-+ break;
-+ }
-+}
-+
- #define REF_COLOR 1
- #define REF_ALPHA 2
-
-@@ -1560,7 +1594,7 @@ static GLboolean enable_tex_2d( GLcontext *ctx, int unit )
- R200_FIREVERTICES( rmesa );
- r200SetTexImages( rmesa, tObj );
- r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, 0 );
-- if ( !t->base.memBlock )
-+ if ( !t->base.memBlock && !t->image_override )
- return GL_FALSE;
- }
-
-@@ -1668,7 +1702,9 @@ static GLboolean enable_tex_rect( GLcontext *ctx, int unit )
- R200_FIREVERTICES( rmesa );
- r200SetTexImages( rmesa, tObj );
- r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, 0 );
-- if ( !t->base.memBlock && !rmesa->prefer_gart_client_texturing )
-+ if ( !t->base.memBlock &&
-+ !t->image_override &&
-+ !rmesa->prefer_gart_client_texturing )
- return GL_FALSE;
- }
-
-diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
-index aa7fb63..682cf3a 100644
---- a/src/mesa/drivers/dri/radeon/radeon_screen.c
-+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
-@@ -53,6 +53,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- #include "r200_context.h"
- #include "r200_ioctl.h"
- #include "r200_span.h"
-+#include "r200_tex.h"
- #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
- #include "r300_context.h"
- #include "r300_fragprog.h"
-@@ -973,7 +974,8 @@ static const struct __DriverAPIRec r200API = {
- .WaitForMSC = driWaitForMSC32,
- .WaitForSBC = NULL,
- .SwapBuffersMSC = NULL,
-- .CopySubBuffer = r200CopySubBuffer
-+ .CopySubBuffer = r200CopySubBuffer,
-+ .setTexOffset = r200SetTexOffset
- };
- #endif
-
diff --git a/mesa-7.0.1-r300-fix-writemask.patch b/mesa-7.0.1-r300-fix-writemask.patch
deleted file mode 100644
index 931a077..0000000
--- a/mesa-7.0.1-r300-fix-writemask.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From 32699696e31234c8d4e4b08f255ba2134ec12db5 Mon Sep 17 00:00:00 2001
-From: Jerome Glisse <glisse@freedesktop.org>
-Date: Sun, 7 Oct 2007 22:49:56 +0200
-Subject: [PATCH] r300: fragprog tex instruction now take writemask into acount.
-
----
- src/mesa/drivers/dri/r300/r300_fragprog.c | 6 +++++-
- 1 files changed, 5 insertions(+), 1 deletions(-)
-
-diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c
-index cce8e68..78ed44b 100644
---- a/src/mesa/drivers/dri/r300/r300_fragprog.c
-+++ b/src/mesa/drivers/dri/r300/r300_fragprog.c
-@@ -951,6 +951,10 @@ static void emit_tex(struct r300_fragment_program *fp,
- if (REG_GET_TYPE(dest) == REG_TYPE_OUTPUT) {
- rdest = dest;
- dest = get_temp_reg_tex(fp);
-+ } else if (fpi->DstReg.WriteMask != WRITEMASK_XYZW) {
-+ /* in case write mask isn't XYZW */
-+ rdest = dest;
-+ dest = get_temp_reg_tex(fp);
- }
- hwdest =
- t_hw_dst(fp, dest, GL_TRUE,
-@@ -1016,7 +1020,7 @@ static void emit_tex(struct r300_fragment_program *fp,
-
- /* Copy from temp to output if needed */
- if (REG_GET_VALID(rdest)) {
-- emit_arith(fp, PFS_OP_MAD, rdest, WRITEMASK_XYZW, dest,
-+ emit_arith(fp, PFS_OP_MAD, rdest, fpi->DstReg.WriteMask, dest,
- pfs_one, pfs_zero, 0);
- free_temp(fp, dest);
- }
---
-1.5.2.4
-
diff --git a/mesa-7.0.1-stable-branch.patch b/mesa-7.0.1-stable-branch.patch
deleted file mode 100644
index 63f46ca..0000000
--- a/mesa-7.0.1-stable-branch.patch
+++ /dev/null
@@ -1,4966 +0,0 @@
-Adam Jackson (1):
- Unbreak Linux builds with -fvisibility=hidden.
-
-Andreas Micheler (1):
- faster write_rgba_span_front()
-
-Brian (69):
- added md5 sums
- fix even-sized point positioning (bug 11874)
- Merge branch 'mesa_7_0_branch' of git+ssh://brianp@git.freedesktop.org/git/mesa/mesa into mesa_7_0_branch
- fix bug 9962 (vbo splitting) as in trunk
- initial 7.0.2 notes
- fix swizzle error test (bug 11881)
- fix potential NULL dereference (bug 11880)
- remove SHELL line, replace -e test with new logic (Daniel Stone)
- fix potential NULL dereference (bug 11879)
- move free() after dereference (bug 11878)
- fix byte swap bug for GLuint stencil indexes (bug 11909)
- fix link to 7.0.1 relnotes
- Implement mutex/locking around texture object reference counting.
- free any render/framebuffers left in hash tables when freeing shared state
- Add PCI IDs for the G33, Q33, and Q35 chipsets.
- added more i915/945 chipsets
- fix blending/banding bug
- Fix a few more problems with freeing FBOs/textures during context destruction.
- added some temporary texobj ref counting debug output
- more tex obj ref count debugging (temporary)
- Added _mesa_free_attrib_data() to free anything left in the attribute stack upon context destruction.
- copy Target in _mesa_copy_texture_object()
- Rewrite quite a bit of the code for glPush/PopAttrib() for texture state.
- more debug output (context destroy, fb destroy)
- log deleting/binding of FBOs
- Remove recent texobj refcount debug/logging code.
- don't map buffer in _mesa_validate_DrawElements() unless needed
- refactor bounds checking code
- remove unneeded CallStack array
- remove CallDepth++/-- accidentally removed in prev commit
- new __gluInvertMatrix() function (Mesa bug 6748)
- Fixed bugs 6748, 12141
- s/movaps/movups/ (see bug 12216)
- fix i965 bugs, x86-64 bugs
- sync with trunk, fixing bug 12239
- Use temporary matrix in __gluInvertMatrixd() to fix aliasing problem (see bugs 12269, 6748)
- updated VC7 project files
- clean-up (see bug 12317)
- fix comment
- Update depth test state when binding new framebuffer object
- In _mesa_make_current(), don't unbind FBOs from the old context.
- fix indirect rendering crash
- updated with pkg-config info
- added DSTDIR, pkg-config items
- added .pc.in files to tarballs
- Fix state.texgen parsing error (bug 12313).
- added program_error2() function for better error reporting
- fix ARB fp/vp parsing bug 12313
- fix copypixels overlap test bug (#12417)
- fix glCopyPixel/glPixelZoom bug 12417)
- updated link
- From trunk: mesa: bind VBO_ATTRIB_XXX to correct input array when executing a display list. fix #10604
- fix bug 10604
- Added bluegene-xlc-osmesa config (Alexander Neundorf)
- fixes for bluegene-xlc-osmesa config
- added bluegene-xlc-osmesa, fortran fixes
- fix for __IBMC__
- fix -D_BSD_SOURC
- fix DrawRangeElements error msg
- Restore old _TriangleCaps code to fix Blender problem (bug 12164)
- fix blend bug 12164
- bump versions to 7.0.2
- for Miniglx, use git sources
- prep for 7.0.2 release
- update the DRM/DRI instructions
- fix VBO-split infinite loop (bug 12164)
- updated glext.h license info (Khronos), plus other clean-ups
- replace 'brick' with correct program name in printfs
- fix fog, rescale_normals bugs (from gallium branch)
-
-Christoph Kubisch (1):
- updated VC7 project files
-
-Colin McDonald (1):
- fixed problem with big glDrawArrays (see bug 12141)
-
-Dan Nicholson (4):
- DESTDIR support.
- pkg-config support
- add support for LDFLAGS env var
- Ignore more generated files in progs/
-
-Dan Torop (1):
- fix spantmp2 READ_RGBA inline asm (#11931)
-
-Dave Airlie (1):
- i965: fix vblank on 965gm laptops by bringing in code from i915
-
-Michel Dänzer (3):
- i915tex: Make sure pitch is aligned properly for render-to-texture.
- i915tex: Unreference texture buffers on context destruction.
- i915tex: Work around texture pitch related performance drops on i915 at least.
-
-Mrc Gran (1):
- fix force_s3tc_enable option
-
-Roland Bär (1):
- [i965] Bug #11812: Fix fwrite return value checks in AUB file code.
-
-Roland Scheidegger (6):
- suppress warning about ncon visuals (bug #6689)
- fix another occurence of movaps which might not be aligned
- unbreak 3d textures (typo when setting tex layout)
- make sure optimized fog params get updated
- fog: fix issues with negative fog coords (may fix #10529)
- minor fog calc cleanup
-
-Wang Zhenyu (1):
- i915tex: Add support for 945GME
-
-Xiang, Haihao (14):
- i965: flush batch buffer when getting the maximum. This makes
- i965: samplers group in fours in WM_STATE. fix bug#9415
- i965: check NULL pointer. fix bug#12193
- i965: store read drawable info in intel_context. Some OpenGL
- i965: Take the upper limitation on LOD into account.
- fix bug#11009
- i965: limit on LOD Bias, fix#11987
- i965: take the secondary color into account when drawing
- i965: fix #11378
- i965: fix bug#11925
- i965: The cube map texture coordinates must be devided by the
- i965: handle all unfilled mode in clip stage. fix bug #12453
- mesa: make sure the gotten value isn't greater than the
- Brian's fix for bug9829
-
-Zou Nan hai (2):
- fix a bug in 965 ARB_occlusion_query,
- fix fd.o bug #12217, recalcuate urb when clip plane size change
-
-diff --git a/Makefile b/Makefile
-index 3cab262..e05e0e6 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,7 +1,5 @@
- # Top-level Mesa makefile
-
--SHELL = /bin/bash
--
- TOP = .
-
- SUBDIRS = src progs
-@@ -70,6 +68,7 @@ aix-gcc \
- aix-static \
- beos \
- bluegene-osmesa \
-+bluegene-xlc-osmesa \
- darwin \
- darwin-static \
- darwin-static-x86ppc \
-@@ -156,7 +155,7 @@ sunos5-v9 \
- sunos5-v9-static \
- sunos5-v9-cc-g++ \
- ultrix-gcc:
-- @ if [ -e configs/current ] ; then \
-+ @ if test -f configs/current || test -L configs/current ; then \
- echo "Please run 'make realclean' before changing configs" ; \
- exit 1 ; \
- fi
-@@ -166,10 +165,10 @@ ultrix-gcc:
-
- # Rules for making release tarballs
-
--DIRECTORY = Mesa-7.0.1
--LIB_NAME = MesaLib-7.0.1
--DEMO_NAME = MesaDemos-7.0.1
--GLUT_NAME = MesaGLUT-7.0.1
-+DIRECTORY = Mesa-7.0.2-rc1
-+LIB_NAME = MesaLib-7.0.2-rc1
-+DEMO_NAME = MesaDemos-7.0.2-rc1
-+GLUT_NAME = MesaGLUT-7.0.2-rc1
-
- MAIN_FILES = \
- $(DIRECTORY)/Makefile* \
-@@ -213,6 +212,7 @@ MAIN_FILES = \
- $(DIRECTORY)/src/mesa/Makefile* \
- $(DIRECTORY)/src/mesa/sources \
- $(DIRECTORY)/src/mesa/descrip.mms \
-+ $(DIRECTORY)/src/mesa/gl.pc.in \
- $(DIRECTORY)/src/mesa/depend \
- $(DIRECTORY)/src/mesa/main/*.[chS] \
- $(DIRECTORY)/src/mesa/main/descrip.mms \
-@@ -320,6 +320,7 @@ DRI_FILES = \
- SGI_GLU_FILES = \
- $(DIRECTORY)/src/glu/Makefile \
- $(DIRECTORY)/src/glu/descrip.mms \
-+ $(DIRECTORY)/src/glu/glu.pc.in \
- $(DIRECTORY)/src/glu/sgi/Makefile \
- $(DIRECTORY)/src/glu/sgi/Makefile.mgw \
- $(DIRECTORY)/src/glu/sgi/Makefile.win \
-@@ -396,6 +397,7 @@ GLUT_FILES = \
- $(DIRECTORY)/include/GL/glutf90.h \
- $(DIRECTORY)/src/glut/glx/Makefile* \
- $(DIRECTORY)/src/glut/glx/depend \
-+ $(DIRECTORY)/src/glut/glx/glut.pc.in \
- $(DIRECTORY)/src/glut/glx/*def \
- $(DIRECTORY)/src/glut/glx/descrip.mms \
- $(DIRECTORY)/src/glut/glx/mms_depend \
-@@ -418,6 +420,7 @@ DEPEND_FILES = \
- $(TOP)/src/mesa/depend \
- $(TOP)/src/glx/x11/depend \
- $(TOP)/src/glw/depend \
-+ $(TOP)/src/glw/glw.pc.in \
- $(TOP)/src/glut/glx/depend \
- $(TOP)/src/glu/sgi/depend
-
-diff --git a/bin/mklib b/bin/mklib
-index 8334595..499e789 100755
---- a/bin/mklib
-+++ b/bin/mklib
-@@ -34,6 +34,7 @@ MINOR=0
- PATCH=""
- DEPS=""
- LINK=""
-+LDFLAGS=""
- CPLUSPLUS=0
- STATIC=0
- DLOPEN=0
-@@ -63,6 +64,7 @@ do
- echo ' -LDIR search in DIR for library dependencies'
- echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
- echo ' Not observed on all systems at this time.'
-+ echo ' -ldflags OPT specify any additional linker flags in OPT'
- echo ' -cplusplus link with C++ runtime'
- echo ' -static make a static library (default is dynamic/shared)'
- echo ' -dlopen make a shared library suitable for dynamic loading'
-@@ -94,6 +96,10 @@ do
- shift 1;
- LINK=$1
- ;;
-+ '-ldflags')
-+ shift 1;
-+ LDFLAGS=$1
-+ ;;
- -l*)
- DEPS="$DEPS $1"
- ;;
-@@ -216,7 +222,7 @@ case $ARCH in
-
- rm -f ${LIBNAME}
- # make lib
-- ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
-+ ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
- # finish up
- FINAL_LIBS="${LIBNAME}"
- elif [ $STATIC = 1 ] ; then
-@@ -274,7 +280,7 @@ case $ARCH in
- rm -f ${LIBNAME}.so
-
- # make lib
-- ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
-+ ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
- # make usual symlinks
- ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
- ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
-@@ -346,10 +352,10 @@ case $ARCH in
- #echo "mklib: linker is" ${LINK} ${OPTS}
- if [ $NOPREFIX = 1 ] ; then
- rm -f ${LIBNAME}
-- ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
-+ ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
- else
- rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
-- ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
-+ ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
- ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
- fi
- FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
-@@ -373,7 +379,7 @@ case $ARCH in
- echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
- OPTS="-shared"
- rm -f ${LIBNAME}
-- ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
-+ ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
- FINAL_LIBS=${LIBNAME}
- elif [ $STATIC = 1 ] ; then
- STLIB="lib${LIBNAME}.a"
-@@ -387,7 +393,7 @@ case $ARCH in
- OPTS="-shared -Wl,-soname,${SHLIB}"
- echo "mklib: Making FreeBSD shared library: " ${SHLIB}
- rm -f ${SHLIB}
-- ${LINK} ${OPTS} -o ${SHLIB} ${OBJECTS} ${DEPS}
-+ ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
- ln -sf ${SHLIB} "lib${LIBNAME}.so"
- FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
- fi
-@@ -445,7 +451,7 @@ case $ARCH in
- fi
-
- echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
-- ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
-+ ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
- FINAL_LIBS=${LIBNAME}
- fi
- ;;
-@@ -521,9 +527,9 @@ case $ARCH in
- # On AIX a shared library is linked differently when
- # you want to dlopen the file
- if [ $DLOPEN = "1" ] ; then
-- cc -G ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
-+ cc -G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
- else
-- cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
-+ cc ${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
- ar ${X64} -r ${LIBNAME} ${OFILE}
- fi
-
-@@ -605,7 +611,7 @@ case $ARCH in
- fi
-
- echo "mklib: Making Darwin shared library: " ${LIBNAME}
-- ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
-+ ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
- ln -s ${LIBNAME} ${LINKNAME}
- FINAL_LIBS="${LIBNAME} ${LINKNAME}"
- fi
-@@ -682,7 +688,7 @@ case $ARCH in
- rm -f ${LIBNAME}.so.${MAJOR}
- rm -f ${LIBNAME}.so
- # make lib
-- ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
-+ ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
- # make usual symlinks
- ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
- ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
-@@ -754,7 +760,7 @@ case $ARCH in
- rm -f ${LIBNAME}.a
-
- # make lib
-- ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
-+ ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
- # make usual symlinks
- ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
- # finish up
-diff --git a/configs/bluegene-xlc-osmesa b/configs/bluegene-xlc-osmesa
-new file mode 100644
-index 0000000..b0c762d
---- /dev/null
-+++ b/configs/bluegene-xlc-osmesa
-@@ -0,0 +1,29 @@
-+# Configuration for building only libOSMesa on BlueGene using the IBM xlc compiler
-+# This doesn't really have a lot of dependencies, so it should be usable
-+# on similar systems too.
-+# It uses static linking and disables multithreading.
-+
-+include $(TOP)/configs/default
-+
-+CONFIG_NAME = bluegene-osmesa
-+
-+# Compiler and flags
-+CC = /opt/ibmcmp/vacpp/bg/8.0/bin/blrts_xlc
-+CXX = /opt/ibmcmp/vacpp/bg/8.0/bin/blrts_xlC
-+CFLAGS = -O3 -pedantic -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
-+CXXFLAGS = -O3 -pedantic -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
-+
-+MKLIB_OPTIONS = -static
-+
-+OSMESA_LIB_NAME = libOSMesa.a
-+
-+# Directories
-+SRC_DIRS = mesa glu
-+DRIVER_DIRS = osmesa
-+PROGRAM_DIRS = osdemos
-+
-+
-+# Dependencies
-+OSMESA_LIB_DEPS = -lm
-+GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
-+APP_LIB_DEPS = -lOSMesa -lGLU -lm
-diff --git a/configs/default b/configs/default
-index 81f0338..2a08c16 100644
---- a/configs/default
-+++ b/configs/default
-@@ -10,7 +10,7 @@ CONFIG_NAME = default
- # Version info
- MESA_MAJOR=7
- MESA_MINOR=0
--MESA_TINY=1
-+MESA_TINY=2
-
- # external projects. This should be useless now that we use libdrm.
- DRM_SOURCE_PATH=$(TOP)/../drm
-@@ -20,6 +20,7 @@ CC = cc
- CXX = CC
- CFLAGS = -O
- CXXFLAGS = -O
-+LDFLAGS =
- GLU_CFLAGS =
-
- # Misc tools and flags
-diff --git a/docs/download.html b/docs/download.html
-index 5c3989e..84451b8 100644
---- a/docs/download.html
-+++ b/docs/download.html
-@@ -9,7 +9,7 @@
- <H1>Downloading</H1>
-
- <p>
--Last stable release: <b>7.0.1</b>
-+Last stable release: <b>7.0.2</b>
- </p>
-
- <p>
-diff --git a/docs/fbdev-dri.html b/docs/fbdev-dri.html
-index c7f59bb..0d9e52c 100644
---- a/docs/fbdev-dri.html
-+++ b/docs/fbdev-dri.html
-@@ -28,6 +28,12 @@ Xlib interfaces allowing some degree of application portability between
- the X and X-less environments.
- </p>
-
-+<p>
-+Some of the files needed for building this configuration are not included
-+in the normal Mesa releases so you'll need to get the latest sources
-+sources from the <a href="repository.html">git repository</a>.
-+</p>
-+
-
- <h1>2. Compilation</h1>
-
-diff --git a/docs/install.html b/docs/install.html
-index 804dee5..4cd0d4c 100644
---- a/docs/install.html
-+++ b/docs/install.html
-@@ -57,50 +57,31 @@ the DRI hardware drivers.
-
- <li>
- <p>
--DRM kernel modules and header files from the
--<a href="http://dri.sf.net/" target="_parent">DRI</a> project.
-+For Mesa 7.0.2 <a href="http://dri.freedesktop.org/libdrm/">
-+DRM version 2.3</a> is required.
- </p>
--
- <p>
--If you don't already have the DRM file, you can get the sources from
--CVS by doing:
--<pre>
--cvs -z3 -d:pserver:anonymous@anoncvs.freedesktop.org:/cvs/dri co drm
--</pre>
--<p>
--See the <a href="http://dri.freedesktop.org/wiki/Building" target="_parent">
--DRI Building Instructions</a> for the steps to build the DRM modules. Mesa
--6.5 requires at least libdrm 2.0.1 or greater.
--</p>
--<p>
--You can verify that the DRM files have been properly installed by
--running <code>pkg-config --modversion libdrm</code>
--
--</li>
--
--<li>
--Recent /usr/include/GL/glxproto.h file.
--<p>You'll need this if you get any errors about _GLXvop_BindTexImageEXT
--being undefined.
-+To check if you already have it, run:
-+<br>
-+<code>pkg-config --modversion libdrm</code>
- </p>
- <p>
--Download/install the
--<a href="http://gitweb.freedesktop.org/?p=xorg/proto/glproto.git">glproto</a>
--module from X.org git, or grab the
--<A href="http://webcvs.freedesktop.org/*checkout*/xorg/proto/GL/glxproto.h?rev=1.9&content-type=text%2Fplain">glxproto.h file</a> and put it in the
--Mesa/include/GL/ directory.
-+You can download and install a <a href="http://dri.freedesktop.org/libdrm/">
-+tarball release</a> or get the code from git with:
-+<br>
-+<code>git clone git://anongit.freedesktop.org/git/mesa/drm</code>
-+<br>
-+Then revert to the drm-2.3.0 tag with:
-+<br>
-+<code>git-reset --hard drm-2.3.0</code>
- </p>
--
- </li>
-
--<li>DRI-enabled X server.
--<p>Visit
--<a href="http://www.xfree86.org" target="_parent">XFree86</a>
--or
-+<li>
-+Relatively recent
- <a href="http://freedesktop.org/wiki/Software_2fXserver" target="_parent">
--X.org</a>
--for more information.
--</p>
-+X.org</a> release.
-+Mesa depends on a number of X header and library files.
- </li>
-
- </ol>
-@@ -287,7 +268,15 @@ already installed, you'll have to choose different directories, like
- To install Mesa's headers and libraries, run <code>make install</code>.
- But first, check the Mesa/configs/default file and examine the values
- of the <b>INSTALL_DIR</b> and <b>DRI_DRIVER_INSTALL_DIR</b> variables.
--Change them if needed, then run <code>make install</code>
-+Change them if needed, then run <code>make install</code>.
-+</p>
-+
-+<p>
-+The variable
-+<b>DESTDIR</b> may also be used to install the contents to a temporary
-+staging directory.
-+This can be useful for package management.
-+For example: <code>make install DESTDIR=/somepath/</code>
- </p>
-
- <p>
-@@ -298,6 +287,26 @@ This is a handy way to compare multiple OpenGL implementations.
- </p>
-
-
-+<H3>1.5 pkg-config support</H3>
-+
-+<p>
-+Running <code>make install</code> will install package configuration files
-+for the pkg-config utility.
-+</p>
-+
-+<p>
-+When compiling your OpenGL application you can use pkg-config to determine
-+the proper compiler and linker flags.
-+</p>
-+
-+<p>
-+For example, compiling and linking a GLUT application can be done with:
-+</p>
-+<pre>
-+ gcc `pkg-config --cflags --libs glut` mydemo.c -o mydemo
-+</pre>
-+
-+<br>
-
- <a name="windows">
- <H2>2. Windows Compilation and Installation</H1>
-diff --git a/docs/license.html b/docs/license.html
-index 944a5dd..44b980d 100644
---- a/docs/license.html
-+++ b/docs/license.html
-@@ -86,29 +86,32 @@ and their respective licenses.
- <H1>Mesa Component Licenses</H1>
-
- <pre>
--Component Location Primary Author License
------------------------------------------------------------------------------
--Main Mesa code src/mesa/ Brian Paul Mesa (MIT)
-+Component Location License
-+------------------------------------------------------------------
-+Main Mesa code src/mesa/ Mesa (MIT)
-
--Device drivers src/mesa/drivers/* See drivers See drivers
-+Device drivers src/mesa/drivers/* MIT, generally
-
--Ext headers include/GL/glext.h SGI SGI Free B
-+Ext headers include/GL/glext.h Khronos
- include/GL/glxext.h
-
--GLUT src/glut/ Mark Kilgard Mark's copyright
-+GLUT src/glut/ Mark Kilgard's copyright
-
--Mesa GLU library src/glu/mesa/ Brian Paul GNU-LGPL
-+SGI GLU library src/glu/sgi/ SGI Free B
-
--SGI GLU library src/glu/sgi/ SGI SGI Free B
-+demo programs progs/demos/ see source files
-
--demo programs progs/demos/ various see source files
-+X demos progs/xdemos/ see source files
-
--X demos progs/xdemos/ Brian Paul see source files
-+SGI demos progs/samples/ SGI license
-
--SGI demos progs/samples/ SGI SGI copyright
--
--RedBook demos progs/redbook/ SGI SGI copyright
-+RedBook demos progs/redbook/ SGI license
- </pre>
-
-+<p>
-+In general, consult the source files for license terms.
-+</p>
-+
-+
- </body>
- </html>
-diff --git a/docs/modelers.html b/docs/modelers.html
-index b93f4d8..aae9686 100644
---- a/docs/modelers.html
-+++ b/docs/modelers.html
-@@ -28,7 +28,7 @@
- </li><li><a href="http://innovation3d.sourceforge.net/" target="_parent">Innovation3D</a>
- - 3D modeling program
- </li><li><a href="http://mesa3d.sourceforge.net/notfound.html" target="_parent">KWRL</a> - VRML browser
-- </li><li><a href="http://www.vermontel.com/%7Ecmorley/vrml.html" target="_parent">LibVRML97/Lookat</a>
-+ </li><li><a href="http://www.openvrml.org/" target="_parent">LibVRML97/Lookat</a>
- - VRML viewer
- </li><li><a href="http://aig.cs.man.ac.uk/systems/Maverik/" target="_parent">Maverik</a>
- - VR graphics and interaction system
-diff --git a/docs/news.html b/docs/news.html
-index 1f66d4e..8694ce4 100644
---- a/docs/news.html
-+++ b/docs/news.html
-@@ -11,9 +11,16 @@
- <H1>News</H1>
-
-
-+<h2>September ??, 2007</h2>
-+<p>
-+<a href="relnotes-7.0.2.html">Mesa 7.0.2</a> is released.
-+This is a bug-fix release.
-+</p>
-+
-+
- <h2>August 3, 2007</h2>
- <p>
--<a href="relnotes-7.0.html">Mesa 7.0.1</a> is released.
-+<a href="relnotes-7.0.1.html">Mesa 7.0.1</a> is released.
- This is a bug-fix release.
- </p>
-
-diff --git a/docs/relnotes-7.0.1.html b/docs/relnotes-7.0.1.html
-index 47ee162..02713ad 100644
---- a/docs/relnotes-7.0.1.html
-+++ b/docs/relnotes-7.0.1.html
-@@ -17,6 +17,15 @@ Mesa 7.0.1 is a stable release with bug fixes since version 7.0.
-
- <h2>MD5 checksums</h2>
- <pre>
-+db55141a44b902fcc61d9265b7862c06 MesaLib-7.0.1.tar.gz
-+c056abd763e899114bf745c9eedbf9ad MesaLib-7.0.1.tar.bz2
-+ecc2637547fae2b38271ae362d013afa MesaLib-7.0.1.zip
-+b85a4a5be4e829f4a1165e4514b13183 MesaDemos-7.0.1.tar.gz
-+3b66b3268df12ca8a6c4e0c4c457912c MesaDemos-7.0.1.tar.bz2
-+b1c18006f16e44e80fea66774c59b391 MesaDemos-7.0.1.zip
-+b87a69986839ae43ce12fc8e3dc1ebb4 MesaGLUT-7.0.1.tar.gz
-+25f30d0c1651997b4412366ba0572f7f MesaGLUT-7.0.1.tar.bz2
-+676ee6682a6ce78a5540554fd975c03e MesaGLUT-7.0.1.zip
- </pre>
-
-
-diff --git a/docs/relnotes-7.0.2.html b/docs/relnotes-7.0.2.html
-new file mode 100644
-index 0000000..46040e1
---- /dev/null
-+++ b/docs/relnotes-7.0.2.html
-@@ -0,0 +1,84 @@
-+<HTML>
-+
-+<TITLE>Mesa Release Notes</TITLE>
-+
-+<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
-+
-+<BODY>
-+
-+<body bgcolor="#eeeeee">
-+
-+<H1>Mesa 7.0.2 Release Notes / (TBD) 2007</H1>
-+
-+<p>
-+Mesa 7.0.2 is a stable release with bug fixes since version 7.0.
-+</p>
-+
-+
-+<h2>MD5 checksums</h2>
-+<pre>
-+</pre>
-+
-+
-+<h2>New features</h2>
-+<ul>
-+<li>Updated Windows VC7 project files
-+<li>Added DESTDIR variable for 'make install'
-+<li>Added pkg-config files for gl, glu, glut and glw libraries
-+<li>Added bluegene-xlc-osmesa config
-+</ul>
-+
-+<h2>Bug fixes</h2>
-+<ul>
-+<li>Fixed a vertex buffer wrapping issue (bug 9962)
-+<li>Added mutex protection around texture object reference counters
-+<li>Added checking/support for additional chips in the i915/i945 family
-+(see 11978)
-+<li>Fixed a blending/banding issue (bug 11931)
-+<li>Fixed a GLU matrix inversion bug (#6748)
-+<li>Fixed problem with large glDrawArrays calls and indirect rendering (bug 12141)
-+<li>Fixed an assortment of i965 driver bugs
-+<li>Fixed and x86-64 vertex transformation bug (12216)
-+<li>Fixed X server crash caused by multiple indirect rendering clients
-+<li>Parsing of state.texgen in ARB vertex/fragment programs didn't work (bug 12313)
-+<li>Fixed a glCopyPixels/glPixelZoom bug (12417)
-+<li>Fixed a bug when using glMaterial in display lists (bug 10604)
-+<li>Fixed a few GLUT/Fortran issues (Bill Mitchell)
-+<li>Fixed Blender crash bug (12164)
-+</ul>
-+
-+
-+<h2>Changes</h2>
-+<ul>
-+</ul>
-+
-+
-+<h2>To Do (someday) items</h2>
-+<ul>
-+<li>Switch to freeglut
-+<li>Fix linux-glide target/driver.
-+<li>Improved lambda and derivative calculation for frag progs.
-+</ul>
-+
-+
-+<h2>Driver Status</h2>
-+
-+<pre>
-+Driver Status
-+---------------------- ----------------------
-+DRI drivers varies with the driver
-+XMesa/GLX (on Xlib) implements OpenGL 2.1
-+OSMesa (off-screen) implements OpenGL 2.1
-+Windows/Win32 implements OpenGL 2.1
-+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
-+SVGA unsupported
-+Wind River UGL unsupported
-+DJGPP unsupported
-+GGI unsupported
-+BeOS unsupported
-+Allegro unsupported
-+D3D unsupported
-+</pre>
-+
-+</body>
-+</html>
-diff --git a/docs/relnotes.html b/docs/relnotes.html
-index 9a978d9..7464f5c 100644
---- a/docs/relnotes.html
-+++ b/docs/relnotes.html
-@@ -20,6 +20,7 @@ The release notes summarize what's new or changed in each Mesa release.
- </p>
-
- <UL>
-+<LI><A HREF="relnotes-7.0.2.html">7.0.2 release notes</A>
- <LI><A HREF="relnotes-7.0.1.html">7.0.1 release notes</A>
- <LI><A HREF="relnotes-7.0.html">7.0 release notes</A>
- <LI><A HREF="relnotes-6.5.3.html">6.5.3 release notes</A>
-diff --git a/include/GL/glu.h b/include/GL/glu.h
-index d82103d..7db4b70 100644
---- a/include/GL/glu.h
-+++ b/include/GL/glu.h
-@@ -44,22 +44,17 @@
- #define GLAPIENTRYP GLAPIENTRY *
- #endif
-
--#ifdef GLAPI
--#undef GLAPI
--#endif
--
--# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32)
--# define GLAPI __declspec(dllexport)
--# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
--# define GLAPI __declspec(dllimport)
--# else /* for use with static link lib build of Win32 edition only */
--# define GLAPI extern
--# endif /* _STATIC_MESA support */
--
--
--#ifndef GLAPI
--#define GLAPI
--#endif
-+#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32)
-+# undef GLAPI
-+# define GLAPI __declspec(dllexport)
-+#elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL)
-+/* tag specifying we're building for DLL runtime support */
-+# undef GLAPI
-+# define GLAPI __declspec(dllimport)
-+#elif !defined(GLAPI)
-+/* for use with static link lib build of Win32 edition only */
-+# define GLAPI extern
-+#endif /* _STATIC_MESA support */
-
- #ifdef __cplusplus
- extern "C" {
-diff --git a/progs/demos/Makefile b/progs/demos/Makefile
-index cf96828..798de25 100644
---- a/progs/demos/Makefile
-+++ b/progs/demos/Makefile
-@@ -74,7 +74,7 @@ PROGS = \
-
- # make executable from .c file:
- .c: $(LIB_DEP) readtex.o
-- $(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@
-+ $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@
-
-
- ##### TARGETS #####
-@@ -118,35 +118,35 @@ extfuncs.h: $(TOP)/progs/util/extfuncs.h
-
-
- reflect: reflect.o showbuffer.o readtex.o
-- $(CC) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) -o $@
-+ $(CC) $(LDFLAGS) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) -o $@
-
- reflect.o: reflect.c showbuffer.h
- $(CC) -c -I$(INCDIR) $(CFLAGS) reflect.c
-
-
- shadowtex: shadowtex.o showbuffer.o
-- $(CC) shadowtex.o showbuffer.o $(APP_LIB_DEPS) -o $@
-+ $(CC) $(LDFLAGS) shadowtex.o showbuffer.o $(APP_LIB_DEPS) -o $@
-
- shadowtex.o: shadowtex.c showbuffer.h
- $(CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c
-
-
- gloss: gloss.o trackball.o readtex.o
-- $(CC) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
-+ $(CC) $(LDFLAGS) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
-
- gloss.o: gloss.c trackball.h
- $(CC) -c -I$(INCDIR) $(CFLAGS) gloss.c
-
-
- engine: engine.o trackball.o readtex.o
-- $(CC) engine.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
-+ $(CC) $(LDFLAGS) engine.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
-
- engine.o: engine.c trackball.h
- $(CC) -c -I$(INCDIR) $(CFLAGS) engine.c
-
-
- fslight: fslight.o
-- $(CC) fslight.o $(APP_LIB_DEPS) -o $@
-+ $(CC) $(LDFLAGS) fslight.o $(APP_LIB_DEPS) -o $@
-
- fslight.o: fslight.c extfuncs.h
- $(CC) -c -I$(INCDIR) $(CFLAGS) fslight.c
-diff --git a/progs/fbdev/.gitignore b/progs/fbdev/.gitignore
-new file mode 100644
-index 0000000..b9ddf55
---- /dev/null
-+++ b/progs/fbdev/.gitignore
-@@ -0,0 +1 @@
-+glfbdevtest
-diff --git a/progs/fbdev/Makefile b/progs/fbdev/Makefile
-index 0a0c779..92bfd04 100644
---- a/progs/fbdev/Makefile
-+++ b/progs/fbdev/Makefile
-@@ -22,7 +22,7 @@ INCLUDES = \
- .SUFFIXES: .c
-
- .c:
-- $(CC) $(INCLUDES) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
-+ $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
-
- .c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
-diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
-index 37fa312..a5ca1f3 100644
---- a/progs/glsl/Makefile
-+++ b/progs/glsl/Makefile
-@@ -25,7 +25,7 @@ PROGS = \
-
- # make executable from .c file:
- .c: $(LIB_DEP)
-- $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
-+ $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
-
-
- ##### TARGETS #####
-@@ -57,7 +57,7 @@ mandelbrot.c: extfuncs.h
- toyball.c: extfuncs.h
-
- texdemo1: texdemo1.o readtex.o
-- $(CC) -I$(INCDIR) $(CFLAGS) texdemo1.o readtex.o $(APP_LIB_DEPS) -o $@
-+ $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o $(APP_LIB_DEPS) -o $@
-
- texdemo1.o: texdemo1.c readtex.h extfuncs.h
- $(CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c
-diff --git a/progs/glsl/bump.c b/progs/glsl/bump.c
-index a6846ac..11f87ab 100644
---- a/progs/glsl/bump.c
-+++ b/progs/glsl/bump.c
-@@ -247,7 +247,7 @@ LoadAndCompileShader(GLuint shader, const char *text)
- GLchar log[1000];
- GLsizei len;
- glGetShaderInfoLog_func(shader, 1000, &len, log);
-- fprintf(stderr, "brick: problem compiling shader: %s\n", log);
-+ fprintf(stderr, "bump: problem compiling shader: %s\n", log);
- exit(1);
- }
- else {
-@@ -267,12 +267,12 @@ ReadShader(GLuint shader, const char *filename)
- char *buffer = (char*) malloc(max);
- FILE *f = fopen(filename, "r");
- if (!f) {
-- fprintf(stderr, "brick: Unable to open shader file %s\n", filename);
-+ fprintf(stderr, "bump: Unable to open shader file %s\n", filename);
- exit(1);
- }
-
- n = fread(buffer, 1, max, f);
-- printf("brick: read %d bytes from shader file %s\n", n, filename);
-+ printf("bump: read %d bytes from shader file %s\n", n, filename);
- if (n > 0) {
- buffer[n] = 0;
- LoadAndCompileShader(shader, buffer);
-diff --git a/progs/glsl/mandelbrot.c b/progs/glsl/mandelbrot.c
-index 7a2bad6..e7b2b04 100644
---- a/progs/glsl/mandelbrot.c
-+++ b/progs/glsl/mandelbrot.c
-@@ -172,7 +172,7 @@ LoadAndCompileShader(GLuint shader, const char *text)
- GLchar log[1000];
- GLsizei len;
- glGetShaderInfoLog_func(shader, 1000, &len, log);
-- fprintf(stderr, "brick: problem compiling shader: %s\n", log);
-+ fprintf(stderr, "mandelbrot: problem compiling shader: %s\n", log);
- exit(1);
- }
- else {
-@@ -192,12 +192,12 @@ ReadShader(GLuint shader, const char *filename)
- char *buffer = (char*) malloc(max);
- FILE *f = fopen(filename, "r");
- if (!f) {
-- fprintf(stderr, "brick: Unable to open shader file %s\n", filename);
-+ fprintf(stderr, "mandelbrot: Unable to open shader file %s\n", filename);
- exit(1);
- }
-
- n = fread(buffer, 1, max, f);
-- printf("brick: read %d bytes from shader file %s\n", n, filename);
-+ printf("mandelbrot: read %d bytes from shader file %s\n", n, filename);
- if (n > 0) {
- buffer[n] = 0;
- LoadAndCompileShader(shader, buffer);
-diff --git a/progs/glsl/noise.c b/progs/glsl/noise.c
-index a26a805..adccd1a 100644
---- a/progs/glsl/noise.c
-+++ b/progs/glsl/noise.c
-@@ -188,7 +188,7 @@ LoadAndCompileShader(GLuint shader, const char *text)
- GLchar log[1000];
- GLsizei len;
- glGetShaderInfoLog_func(shader, 1000, &len, log);
-- fprintf(stderr, "brick: problem compiling shader: %s\n", log);
-+ fprintf(stderr, "noise: problem compiling shader: %s\n", log);
- exit(1);
- }
- else {
-diff --git a/progs/glsl/toyball.c b/progs/glsl/toyball.c
-index cef52c0..3aa0961 100644
---- a/progs/glsl/toyball.c
-+++ b/progs/glsl/toyball.c
-@@ -185,7 +185,7 @@ LoadAndCompileShader(GLuint shader, const char *text)
- GLchar log[1000];
- GLsizei len;
- glGetShaderInfoLog_func(shader, 1000, &len, log);
-- fprintf(stderr, "brick: problem compiling shader: %s\n", log);
-+ fprintf(stderr, "toyball: problem compiling shader: %s\n", log);
- exit(1);
- }
- else {
-@@ -205,12 +205,12 @@ ReadShader(GLuint shader, const char *filename)
- char *buffer = (char*) malloc(max);
- FILE *f = fopen(filename, "r");
- if (!f) {
-- fprintf(stderr, "brick: Unable to open shader file %s\n", filename);
-+ fprintf(stderr, "toyball: Unable to open shader file %s\n", filename);
- exit(1);
- }
-
- n = fread(buffer, 1, max, f);
-- printf("brick: read %d bytes from shader file %s\n", n, filename);
-+ printf("toyball: read %d bytes from shader file %s\n", n, filename);
- if (n > 0) {
- buffer[n] = 0;
- LoadAndCompileShader(shader, buffer);
-diff --git a/progs/miniglx/.gitignore b/progs/miniglx/.gitignore
-new file mode 100644
-index 0000000..f630f59
---- /dev/null
-+++ b/progs/miniglx/.gitignore
-@@ -0,0 +1,6 @@
-+manytex
-+miniglxsample
-+miniglxtest
-+sample_server
-+sample_server2
-+texline
-diff --git a/progs/osdemos/.gitignore b/progs/osdemos/.gitignore
-new file mode 100644
-index 0000000..5c78f12
---- /dev/null
-+++ b/progs/osdemos/.gitignore
-@@ -0,0 +1,8 @@
-+osdemo
-+osdemo16
-+osdemo32
-+ostest1
-+readtex.c
-+readtex.h
-+showbuffer.c
-+showbuffer.h
-diff --git a/progs/osdemos/Makefile b/progs/osdemos/Makefile
-index f8cba9e..7e65774 100644
---- a/progs/osdemos/Makefile
-+++ b/progs/osdemos/Makefile
-@@ -26,7 +26,7 @@ PROGS = \
-
- # make executable from .c file:
- .c: $(LIB_DEP) readtex.o
-- $(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@
-+ $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@
-
-
- ##### TARGETS #####
-@@ -56,19 +56,19 @@ showbuffer.o: showbuffer.c showbuffer.h
-
- # special case: need the -lOSMesa library:
- osdemo: osdemo.c
-- $(CC) -I$(INCDIR) $(CFLAGS) osdemo.c $(OSMESA_LIBS) -o $@
-+ $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) osdemo.c $(OSMESA_LIBS) -o $@
-
- # special case: need the -lOSMesa library:
- ostest1: ostest1.c
-- $(CC) -I$(INCDIR) $(CFLAGS) ostest1.c $(OSMESA_LIBS) -o $@
-+ $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) ostest1.c $(OSMESA_LIBS) -o $@
-
- # another special case: need the -lOSMesa16 library:
- osdemo16: osdemo16.c
-- $(CC) -I$(INCDIR) $(CFLAGS) osdemo16.c $(OSMESA16_LIBS) -o $@
-+ $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) osdemo16.c $(OSMESA16_LIBS) -o $@
-
- # another special case: need the -lOSMesa32 library:
- osdemo32: osdemo32.c
-- $(CC) -I$(INCDIR) $(CFLAGS) osdemo32.c $(OSMESA32_LIBS) -o $@
-+ $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) osdemo32.c $(OSMESA32_LIBS) -o $@
-
-
-
-diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile
-index febc744..078f191 100644
---- a/progs/redbook/Makefile
-+++ b/progs/redbook/Makefile
-@@ -24,7 +24,7 @@ PROGS = aaindex aapoly aargb accanti accpersp alpha alpha3D anti \
- .SUFFIXES: .c
-
- .c: $(LIB_DEP)
-- $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
-+ $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
-
-
-
-diff --git a/src/glu/Makefile b/src/glu/Makefile
-index 5ddc509..836baa6 100644
---- a/src/glu/Makefile
-+++ b/src/glu/Makefile
-@@ -13,9 +13,19 @@ default: $(TOP)/configs/current
- (cd $$dir ; $(MAKE)) ; \
- done
-
--install:
-- $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
-- $(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(INSTALL_DIR)/$(LIB_DIR)
-+# GLU pkg-config file
-+pcedit = sed \
-+ -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
-+ -e 's,@LIB_DIR@,$(LIB_DIR),' \
-+ -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),'
-+glu.pc: glu.pc.in
-+ $(pcedit) $< > $@
-+
-+install: glu.pc
-+ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
-+ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
-+ $(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
-+ $(INSTALL) -m 644 glu.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
-
- clean:
- @for dir in $(SUBDIRS) ; do \
-diff --git a/src/glu/glu.pc.in b/src/glu/glu.pc.in
-new file mode 100644
-index 0000000..5d6e52a
---- /dev/null
-+++ b/src/glu/glu.pc.in
-@@ -0,0 +1,11 @@
-+prefix=@INSTALL_DIR@
-+exec_prefix=${prefix}
-+libdir=${exec_prefix}/@LIB_DIR@
-+includedir=${prefix}/include
-+
-+Name: glu
-+Description: Mesa OpenGL Utility library
-+Requires: gl
-+Version: @VERSION@
-+Libs: -L${libdir} -lGLU
-+Cflags: -I${includedir}
-diff --git a/src/glu/sgi/Makefile b/src/glu/sgi/Makefile
-index 2ce6ac0..bb1c0a8 100644
---- a/src/glu/sgi/Makefile
-+++ b/src/glu/sgi/Makefile
-@@ -136,7 +136,7 @@ $(TOP)/$(LIB_DIR):
-
- # Make the library:
- $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME): $(OBJECTS)
-- $(TOP)/bin/mklib -o $(GLU_LIB) -linker '$(CXX)' \
-+ $(TOP)/bin/mklib -o $(GLU_LIB) -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
- -major $(GLU_MAJOR) -minor $(GLU_MINOR) -patch $(GLU_TINY) \
- -cplusplus $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
- $(GLU_LIB_DEPS) $(OBJECTS)
-diff --git a/src/glu/sgi/libutil/project.c b/src/glu/sgi/libutil/project.c
-index 2b20ad4..356b46b 100644
---- a/src/glu/sgi/libutil/project.c
-+++ b/src/glu/sgi/libutil/project.c
-@@ -168,74 +168,57 @@ static void __gluMultMatrixVecd(const GLdouble matrix[16], const GLdouble in[4],
- }
-
- /*
--** inverse = invert(src)
--** New, faster implementation by Shan Hao Bo, April 2006.
-+** Invert 4x4 matrix.
-+** Contributed by David Moore (See Mesa bug #6748)
- */
--static int __gluInvertMatrixd(const GLdouble src[16], GLdouble inverse[16])
-+static int __gluInvertMatrixd(const GLdouble m[16], GLdouble invOut[16])
- {
-- int i, j, k;
-- double t;
-- GLdouble temp[4][4];
--
-- for (i=0; i<4; i++) {
-- for (j=0; j<4; j++) {
-- temp[i][j] = src[i*4+j];
-- }
-- }
-- __gluMakeIdentityd(inverse);
--
-- for (i = 0; i < 4; i++) {
-- if (temp[i][i] == 0.0f) {
-- /*
-- ** Look for non-zero element in column
-- */
-- for (j = i + 1; j < 4; j++) {
-- if (temp[j][i] != 0.0f) {
-- break;
-- }
-- }
--
-- if (j != 4) {
-- /*
-- ** Swap rows.
-- */
-- for (k = 0; k < 4; k++) {
-- t = temp[i][k];
-- temp[i][k] = temp[j][k];
-- temp[j][k] = t;
--
-- t = inverse[i*4+k];
-- inverse[i*4+k] = inverse[j*4+k];
-- inverse[j*4+k] = t;
-- }
-- }
-- else {
-- /*
-- ** No non-zero pivot. The matrix is singular,
--which shouldn't
-- ** happen. This means the user gave us a bad
--matrix.
-- */
-- return GL_FALSE;
-- }
-- }
--
-- t = 1.0f / temp[i][i];
-- for (k = 0; k < 4; k++) {
-- temp[i][k] *= t;
-- inverse[i*4+k] *= t;
-- }
-- for (j = 0; j < 4; j++) {
-- if (j != i) {
-- t = temp[j][i];
-- for (k = 0; k < 4; k++) {
-- temp[j][k] -= temp[i][k]*t;
-- inverse[j*4+k] -= inverse[i*4+k]*t;
-- }
-- }
-- }
-- }
-- return GL_TRUE;
-+ double inv[16], det;
-+ int i;
-+
-+ inv[0] = m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15]
-+ + m[9]*m[7]*m[14] + m[13]*m[6]*m[11] - m[13]*m[7]*m[10];
-+ inv[4] = -m[4]*m[10]*m[15] + m[4]*m[11]*m[14] + m[8]*m[6]*m[15]
-+ - m[8]*m[7]*m[14] - m[12]*m[6]*m[11] + m[12]*m[7]*m[10];
-+ inv[8] = m[4]*m[9]*m[15] - m[4]*m[11]*m[13] - m[8]*m[5]*m[15]
-+ + m[8]*m[7]*m[13] + m[12]*m[5]*m[11] - m[12]*m[7]*m[9];
-+ inv[12] = -m[4]*m[9]*m[14] + m[4]*m[10]*m[13] + m[8]*m[5]*m[14]
-+ - m[8]*m[6]*m[13] - m[12]*m[5]*m[10] + m[12]*m[6]*m[9];
-+ inv[1] = -m[1]*m[10]*m[15] + m[1]*m[11]*m[14] + m[9]*m[2]*m[15]
-+ - m[9]*m[3]*m[14] - m[13]*m[2]*m[11] + m[13]*m[3]*m[10];
-+ inv[5] = m[0]*m[10]*m[15] - m[0]*m[11]*m[14] - m[8]*m[2]*m[15]
-+ + m[8]*m[3]*m[14] + m[12]*m[2]*m[11] - m[12]*m[3]*m[10];
-+ inv[9] = -m[0]*m[9]*m[15] + m[0]*m[11]*m[13] + m[8]*m[1]*m[15]
-+ - m[8]*m[3]*m[13] - m[12]*m[1]*m[11] + m[12]*m[3]*m[9];
-+ inv[13] = m[0]*m[9]*m[14] - m[0]*m[10]*m[13] - m[8]*m[1]*m[14]
-+ + m[8]*m[2]*m[13] + m[12]*m[1]*m[10] - m[12]*m[2]*m[9];
-+ inv[2] = m[1]*m[6]*m[15] - m[1]*m[7]*m[14] - m[5]*m[2]*m[15]
-+ + m[5]*m[3]*m[14] + m[13]*m[2]*m[7] - m[13]*m[3]*m[6];
-+ inv[6] = -m[0]*m[6]*m[15] + m[0]*m[7]*m[14] + m[4]*m[2]*m[15]
-+ - m[4]*m[3]*m[14] - m[12]*m[2]*m[7] + m[12]*m[3]*m[6];
-+ inv[10] = m[0]*m[5]*m[15] - m[0]*m[7]*m[13] - m[4]*m[1]*m[15]
-+ + m[4]*m[3]*m[13] + m[12]*m[1]*m[7] - m[12]*m[3]*m[5];
-+ inv[14] = -m[0]*m[5]*m[14] + m[0]*m[6]*m[13] + m[4]*m[1]*m[14]
-+ - m[4]*m[2]*m[13] - m[12]*m[1]*m[6] + m[12]*m[2]*m[5];
-+ inv[3] = -m[1]*m[6]*m[11] + m[1]*m[7]*m[10] + m[5]*m[2]*m[11]
-+ - m[5]*m[3]*m[10] - m[9]*m[2]*m[7] + m[9]*m[3]*m[6];
-+ inv[7] = m[0]*m[6]*m[11] - m[0]*m[7]*m[10] - m[4]*m[2]*m[11]
-+ + m[4]*m[3]*m[10] + m[8]*m[2]*m[7] - m[8]*m[3]*m[6];
-+ inv[11] = -m[0]*m[5]*m[11] + m[0]*m[7]*m[9] + m[4]*m[1]*m[11]
-+ - m[4]*m[3]*m[9] - m[8]*m[1]*m[7] + m[8]*m[3]*m[5];
-+ inv[15] = m[0]*m[5]*m[10] - m[0]*m[6]*m[9] - m[4]*m[1]*m[10]
-+ + m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5];
-+
-+ det = m[0]*inv[0] + m[1]*inv[4] + m[2]*inv[8] + m[3]*inv[12];
-+ if (det == 0)
-+ return GL_FALSE;
-+
-+ det = 1.0 / det;
-+
-+ for (i = 0; i < 16; i++)
-+ invOut[i] = inv[i] * det;
-+
-+ return GL_TRUE;
- }
-
- static void __gluMultMatricesd(const GLdouble a[16], const GLdouble b[16],
-diff --git a/src/glw/Makefile b/src/glw/Makefile
-index 5228cbb..727c583 100644
---- a/src/glw/Makefile
-+++ b/src/glw/Makefile
-@@ -25,11 +25,21 @@ OBJECTS = $(GLW_SOURCES:.c=.o)
-
- default: $(TOP)/$(LIB_DIR)/$(GLW_LIB_NAME)
-
--install:
-- $(INSTALL) -d $(INSTALL_DIR)/include/GL
-- $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
-- $(INSTALL) -m 644 *.h $(INSTALL_DIR)/include/GL
-- $(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(INSTALL_DIR)/$(LIB_DIR)
-+# GLU pkg-config file
-+pcedit = sed \
-+ -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
-+ -e 's,@LIB_DIR@,$(LIB_DIR),' \
-+ -e 's,@VERSION@,$(MAJOR).$(MINOR).$(TINY),'
-+glw.pc: glw.pc.in
-+ $(pcedit) $< > $@
-+
-+install: glw.pc
-+ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
-+ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
-+ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
-+ $(INSTALL) -m 644 *.h $(DESTDIR)$(INSTALL_DIR)/include/GL
-+ $(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
-+ $(INSTALL) -m 644 glw.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
-
- clean:
- -rm depend depend.bak
-@@ -38,7 +48,7 @@ clean:
-
- # Make the library
- $(TOP)/$(LIB_DIR)/$(GLW_LIB_NAME): $(OBJECTS)
-- $(TOP)/bin/mklib -o $(GLW_LIB) -linker '$(CC)' \
-+ $(TOP)/bin/mklib -o $(GLW_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
- -major $(MAJOR) -minor $(MINOR) -patch $(TINY) \
- $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
- $(GLW_LIB_DEPS) $(OBJECTS)
-diff --git a/src/glw/glw.pc.in b/src/glw/glw.pc.in
-new file mode 100644
-index 0000000..951e2dc
---- /dev/null
-+++ b/src/glw/glw.pc.in
-@@ -0,0 +1,11 @@
-+prefix=@INSTALL_DIR@
-+exec_prefix=${prefix}
-+libdir=${exec_prefix}/@LIB_DIR@
-+includedir=${prefix}/include
-+
-+Name: glw
-+Description: Mesa OpenGL widget library
-+Requires: gl
-+Version: @VERSION@
-+Libs: -L${libdir} -lGLU
-+Cflags: -I${includedir}
-diff --git a/src/glx/x11/Makefile b/src/glx/x11/Makefile
-index 296747e..9f0943a 100644
---- a/src/glx/x11/Makefile
-+++ b/src/glx/x11/Makefile
-@@ -64,7 +64,7 @@ default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
-
- # Make libGL
- $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile
-- $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
-+ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
- -major 1 -minor 2 $(MKLIB_OPTIONS) \
- -install $(TOP)/$(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS)
-
-diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c
-index af3a516..8fe1033 100644
---- a/src/glx/x11/glxext.c
-+++ b/src/glx/x11/glxext.c
-@@ -672,8 +672,11 @@ filter_modes( __GLcontextModes ** server_modes,
- if ( do_delete && (m->visualID != 0) ) {
- do_delete = GL_FALSE;
-
-- fprintf(stderr, "libGL warning: 3D driver claims to not support "
-- "visual 0x%02x\n", m->visualID);
-+ /* don't warn for this visual (Novell #247471 / X.Org #6689) */
-+ if (m->visualRating != GLX_NON_CONFORMANT_CONFIG) {
-+ fprintf(stderr, "libGL warning: 3D driver claims to not "
-+ "support visual 0x%02x\n", m->visualID);
-+ }
- }
-
- if ( do_delete ) {
-diff --git a/src/glx/x11/indirect_vertex_array.c b/src/glx/x11/indirect_vertex_array.c
-index 90ec277..120fd82 100644
---- a/src/glx/x11/indirect_vertex_array.c
-+++ b/src/glx/x11/indirect_vertex_array.c
-@@ -527,7 +527,7 @@ static GLubyte *
- emit_DrawArrays_header_old( __GLXcontext * gc,
- struct array_state_vector * arrays,
- size_t * elements_per_request,
-- size_t * total_requests,
-+ unsigned int * total_requests,
- GLenum mode, GLsizei count )
- {
- size_t command_size;
-@@ -640,7 +640,7 @@ emit_DrawArrays_old( GLenum mode, GLint first, GLsizei count )
-
- GLubyte * pc;
- size_t elements_per_request;
-- size_t total_requests = 0;
-+ unsigned total_requests = 0;
- unsigned i;
- size_t total_sent = 0;
-
-@@ -770,9 +770,10 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
-
- GLubyte * pc;
- size_t elements_per_request;
-- size_t total_requests = 0;
-+ unsigned total_requests = 0;
- unsigned i;
- unsigned req;
-+ unsigned req_element=0;
-
-
- pc = emit_DrawArrays_header_old( gc, arrays, & elements_per_request,
-@@ -790,7 +791,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
-
- switch( type ) {
- case GL_UNSIGNED_INT: {
-- const GLuint * ui_ptr = (const GLuint *) indices;
-+ const GLuint * ui_ptr = (const GLuint *) indices + req_element;
-
- for ( i = 0 ; i < elements_per_request ; i++ ) {
- const GLint index = (GLint) *(ui_ptr++);
-@@ -799,7 +800,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
- break;
- }
- case GL_UNSIGNED_SHORT: {
-- const GLushort * us_ptr = (const GLushort *) indices;
-+ const GLushort * us_ptr = (const GLushort *) indices + req_element;
-
- for ( i = 0 ; i < elements_per_request ; i++ ) {
- const GLint index = (GLint) *(us_ptr++);
-@@ -808,7 +809,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
- break;
- }
- case GL_UNSIGNED_BYTE: {
-- const GLubyte * ub_ptr = (const GLubyte *) indices;
-+ const GLubyte * ub_ptr = (const GLubyte *) indices + req_element;
-
- for ( i = 0 ; i < elements_per_request ; i++ ) {
- const GLint index = (GLint) *(ub_ptr++);
-@@ -826,6 +827,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
- }
-
- count -= elements_per_request;
-+ req_element += elements_per_request;
- }
-
-
-diff --git a/src/mesa/Makefile b/src/mesa/Makefile
-index eadd7f2..9f3406a 100644
---- a/src/mesa/Makefile
-+++ b/src/mesa/Makefile
-@@ -65,7 +65,7 @@ linux-solo: depend subdirs libmesa.a
- # Stand-alone Mesa libGL, no built-in drivers (DirectFB)
-
- libgl-core: $(CORE_OBJECTS)
-- @ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
-+ @ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS) \
- -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
- -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) $(CORE_OBJECTS) \
- $(GL_LIB_DEPS)
-@@ -78,7 +78,7 @@ directfb: depend subdirs libgl-core
- # fbdev Mesa driver (libGL.so)
-
- fbdev: $(CORE_OBJECTS) $(FBDEV_DRIVER_OBJECTS) $(COMMON_DRIVER_OBJECTS)
-- @ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
-+ @ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
- -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
- -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
- $(CORE_OBJECTS) $(FBDEV_DRIVER_OBJECTS) \
-@@ -111,7 +111,7 @@ osmesa-only: depend subdirs $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME)
-
- # Make the GL library
- $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(STAND_ALONE_OBJECTS)
-- @ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
-+ @ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
- -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \
- -install $(TOP)/$(LIB_DIR) \
- $(MKLIB_OPTIONS) $(GL_LIB_DEPS) $(STAND_ALONE_OBJECTS)
-@@ -121,11 +121,13 @@ $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(STAND_ALONE_OBJECTS)
- $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OSMESA_DRIVER_OBJECTS) $(OSMESA16_OBJECTS)
- @ if [ "${DRIVER_DIRS}" = "osmesa" ] ; then \
- $(TOP)/bin/mklib -o $(OSMESA_LIB) -linker '$(CC)' \
-+ -ldflags '$(LDFLAGS)' \
- -major 6 -minor 5 -patch 3 \
- -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
- $(OSMESA_LIB_DEPS) $(OSMESA16_OBJECTS) ; \
- else \
- $(TOP)/bin/mklib -o $(OSMESA_LIB) -linker '$(CC)' \
-+ -ldflags '$(LDFLAGS)' \
- -major 6 -minor 5 -patch 3 \
- -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
- $(OSMESA_LIB_DEPS) $(OSMESA_DRIVER_OBJECTS) ; \
-@@ -133,6 +135,15 @@ $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OSMESA_DRIVER_OBJECTS) $(OSMESA16_OBJECT
-
-
- ######################################################################
-+# libGL pkg-config file
-+pcedit = sed \
-+ -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
-+ -e 's,@LIB_DIR@,$(LIB_DIR),' \
-+ -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),'
-+gl.pc: gl.pc.in
-+ $(pcedit) $< > $@
-+
-+######################################################################
- # Generic stuff
-
- depend: $(ALL_SOURCES)
-@@ -147,23 +158,25 @@ subdirs:
- @ (cd x86-64 ; $(MAKE))
-
-
--install: default
-- $(INSTALL) -d $(INSTALL_DIR)/include/GL
-- $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
-- $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL
-+install: default gl.pc
-+ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
-+ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
-+ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
-+ $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(DESTDIR)$(INSTALL_DIR)/include/GL
- @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \
-- $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
-+ $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \
- fi
-+ $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
- @if [ -e $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME) ]; then \
-- $(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(INSTALL_DIR)/$(LIB_DIR); \
-+ $(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \
- fi
- @if [ "${DRIVER_DIRS}" = "dri" ] ; then \
- cd drivers/dri ; $(MAKE) install ; \
- fi
-
- ## NOT INSTALLED YET:
--## $(INSTALL) -d $(INSTALL_DIR)/include/GLES
--## $(INSTALL) -m 644 include/GLES/*.h $(INSTALL_DIR)/include/GLES
-+## $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GLES
-+## $(INSTALL) -m 644 include/GLES/*.h $(DESTDIR)$(INSTALL_DIR)/include/GLES
-
-
- # Emacs tags
-diff --git a/src/mesa/drivers/beos/Makefile b/src/mesa/drivers/beos/Makefile
-index 1897d6a..9c7d6af 100644
---- a/src/mesa/drivers/beos/Makefile
-+++ b/src/mesa/drivers/beos/Makefile
-@@ -179,7 +179,8 @@ $(TOP)/$(LIB_DIR):
- mkdir $(TOP)/$(LIB_DIR)
-
- $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) $(MESA_MODULES) $(GLU_MODULES)
-- @$(TOP)/bin/mklib -o $(GL_LIB) -install $(TOP)/$(LIB_DIR) -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
-+ @$(TOP)/bin/mklib -o $(GL_LIB) -ldflags '$(LDFLAGS)' -install $(TOP)/$(LIB_DIR) \
-+ -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
- $(MKLIB_OPTIONS) $(GL_LIB_DEPS) $(OBJECTS) $(MESA_MODULES) $(GLU_MODULES)
-
- # $(GLU_OBJECTS):
-diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template
-index 6f2314e..9e84dbc 100644
---- a/src/mesa/drivers/dri/Makefile.template
-+++ b/src/mesa/drivers/dri/Makefile.template
-@@ -74,7 +74,7 @@ default: depend symlinks $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
-
-
- $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
-- $(TOP)/bin/mklib -noprefix -o $@ \
-+ $(TOP)/bin/mklib -ldflags '$(LDFLAGS)' -noprefix -o $@ \
- $(OBJECTS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS)
-
-
-@@ -100,8 +100,8 @@ clean:
-
-
- install: $(LIBNAME)
-- $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR)
-- $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR)
-+ $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
-+ $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
-
-
- include depend
-diff --git a/src/mesa/drivers/dri/common/spantmp2.h b/src/mesa/drivers/dri/common/spantmp2.h
-index 50f3cf5..53f5f84 100644
---- a/src/mesa/drivers/dri/common/spantmp2.h
-+++ b/src/mesa/drivers/dri/common/spantmp2.h
-@@ -114,7 +114,7 @@
- do { \
- GLuint p = *(volatile GLuint *) GET_PTR(_x, _y); \
- __asm__ __volatile__( "bswap %0; rorl $8, %0" \
-- : "=r" (p) : "r" (p) ); \
-+ : "=r" (p) : "0" (p) ); \
- ((GLuint *)rgba)[0] = p; \
- } while (0)
- # elif defined( MESA_BIG_ENDIAN )
-diff --git a/src/mesa/drivers/dri/glcore/Makefile b/src/mesa/drivers/dri/glcore/Makefile
-index a9e9697..968190a 100644
---- a/src/mesa/drivers/dri/glcore/Makefile
-+++ b/src/mesa/drivers/dri/glcore/Makefile
-@@ -61,7 +61,8 @@ default: depend $(TOP)/$(LIB_DIR)/$(LIBNAME)
-
-
- $(TOP)/$(LIB_DIR)/$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile
-- CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(LIBNAME) -noprefix -install $(TOP)/$(LIB_DIR) \
-+ CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(LIBNAME) -noprefix \
-+ -ldflags '$(LDFLAGS)' -install $(TOP)/$(LIB_DIR) \
- $(OBJECTS) $(WINLIB) $(LIB_DEPS) $(WINOBJ) $(MESA_MODULES)
-
-
-diff --git a/src/mesa/drivers/dri/i810/i810screen.c b/src/mesa/drivers/dri/i810/i810screen.c
-index f64c10a..f8cf050 100644
---- a/src/mesa/drivers/dri/i810/i810screen.c
-+++ b/src/mesa/drivers/dri/i810/i810screen.c
-@@ -288,8 +288,8 @@ i810InitDriver(__DRIscreenPrivate *sPriv)
- i810Screen->depth.handle,
- i810Screen->depth.size,
- (drmAddress *)&i810Screen->depth.map) != 0) {
-- FREE(i810Screen);
- drmUnmap(i810Screen->back.map, i810Screen->back.size);
-+ FREE(i810Screen);
- sPriv->private = NULL;
- __driUtilMessage("i810InitDriver: drmMap (2) failed");
- return GL_FALSE;
-diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c
-index 9f0c949..a19d4b6 100644
---- a/src/mesa/drivers/dri/i915/i915_texstate.c
-+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
-@@ -491,12 +491,19 @@ static void i915SetTexImages( i915ContextPtr i915,
- abort();
- }
-
--
-- if (i915->intel.intelScreen->deviceID == PCI_CHIP_I945_G ||
-- i915->intel.intelScreen->deviceID == PCI_CHIP_I945_GM)
-- i945LayoutTextureImages( i915, tObj );
-- else
-- i915LayoutTextureImages( i915, tObj );
-+ switch (i915->intel.intelScreen->deviceID) {
-+ case PCI_CHIP_I945_G:
-+ case PCI_CHIP_I945_GM:
-+ case PCI_CHIP_I945_GME:
-+ case PCI_CHIP_G33_G:
-+ case PCI_CHIP_Q33_G:
-+ case PCI_CHIP_Q35_G:
-+ i945LayoutTextureImages( i915, tObj );
-+ break;
-+ default:
-+ i915LayoutTextureImages( i915, tObj );
-+ break;
-+ }
-
- t->Setup[I915_TEXREG_MS3] =
- (((tObj->Image[0][t->intel.base.firstLevel]->Height - 1) << MS3_HEIGHT_SHIFT) |
-diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
-index e1e7cdb..bb5ce64 100644
---- a/src/mesa/drivers/dri/i915/intel_context.c
-+++ b/src/mesa/drivers/dri/i915/intel_context.c
-@@ -123,6 +123,14 @@ const GLubyte *intelGetString( GLcontext *ctx, GLenum name )
- chipset = "Intel(R) 945G"; break;
- case PCI_CHIP_I945_GM:
- chipset = "Intel(R) 945GM"; break;
-+ case PCI_CHIP_I945_GME:
-+ chipset = "Intel(R) 945GME"; break;
-+ case PCI_CHIP_G33_G:
-+ chipset = "Intel(R) G33"; break;
-+ case PCI_CHIP_Q35_G:
-+ chipset = "Intel(R) Q35"; break;
-+ case PCI_CHIP_Q33_G:
-+ chipset = "Intel(R) Q33"; break;
- default:
- chipset = "Unknown Intel Chipset"; break;
- }
-diff --git a/src/mesa/drivers/dri/i915/intel_context.h b/src/mesa/drivers/dri/i915/intel_context.h
-index 05195e7..50e6178 100644
---- a/src/mesa/drivers/dri/i915/intel_context.h
-+++ b/src/mesa/drivers/dri/i915/intel_context.h
-@@ -454,6 +454,10 @@ extern int INTEL_DEBUG;
- #define PCI_CHIP_I915_GM 0x2592
- #define PCI_CHIP_I945_G 0x2772
- #define PCI_CHIP_I945_GM 0x27A2
-+#define PCI_CHIP_I945_GME 0x27AE
-+#define PCI_CHIP_G33_G 0x29C2
-+#define PCI_CHIP_Q35_G 0x29B2
-+#define PCI_CHIP_Q33_G 0x29D2
-
-
- /* ================================================================
-diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c
-index 67e176a..ca8610b 100644
---- a/src/mesa/drivers/dri/i915/intel_screen.c
-+++ b/src/mesa/drivers/dri/i915/intel_screen.c
-@@ -514,6 +514,10 @@ static GLboolean intelCreateContext( const __GLcontextModes *mesaVis,
- case PCI_CHIP_I915_GM:
- case PCI_CHIP_I945_G:
- case PCI_CHIP_I945_GM:
-+ case PCI_CHIP_I945_GME:
-+ case PCI_CHIP_G33_G:
-+ case PCI_CHIP_Q35_G:
-+ case PCI_CHIP_Q33_G:
- return i915CreateContext( mesaVis, driContextPriv,
- sharedContextPrivate );
-
-diff --git a/src/mesa/drivers/dri/i915/intel_tex.c b/src/mesa/drivers/dri/i915/intel_tex.c
-index 98ddc79..5bd2806 100644
---- a/src/mesa/drivers/dri/i915/intel_tex.c
-+++ b/src/mesa/drivers/dri/i915/intel_tex.c
-@@ -677,7 +677,11 @@ static void intelUploadTexImage( intelContextPtr intel,
- /* Time for another vtbl entry:
- */
- else if (intel->intelScreen->deviceID == PCI_CHIP_I945_G ||
-- intel->intelScreen->deviceID == PCI_CHIP_I945_GM) {
-+ intel->intelScreen->deviceID == PCI_CHIP_I945_GM ||
-+ intel->intelScreen->deviceID == PCI_CHIP_I945_GME ||
-+ intel->intelScreen->deviceID == PCI_CHIP_G33_G ||
-+ intel->intelScreen->deviceID == PCI_CHIP_Q33_G ||
-+ intel->intelScreen->deviceID == PCI_CHIP_Q35_G) {
- GLuint row_len = image->Width * image->TexFormat->TexelBytes;
- GLubyte *dst = (GLubyte *)(t->BufAddr + offset);
- GLubyte *src = (GLubyte *)image->Data;
-diff --git a/src/mesa/drivers/dri/i915tex/i830_vtbl.c b/src/mesa/drivers/dri/i915tex/i830_vtbl.c
-index e432648..5555b74 100644
---- a/src/mesa/drivers/dri/i915tex/i830_vtbl.c
-+++ b/src/mesa/drivers/dri/i915tex/i830_vtbl.c
-@@ -519,6 +519,16 @@ i830_emit_state(struct intel_context *intel)
- static void
- i830_destroy_context(struct intel_context *intel)
- {
-+ GLuint i;
-+ struct i830_context *i830 = i830_context(&intel->ctx);
-+
-+ for (i = 0; i < I830_TEX_UNITS; i++) {
-+ if (i830->state.tex_buffer[i] != NULL) {
-+ driBOUnReference(i830->state.tex_buffer[i]);
-+ i830->state.tex_buffer[i] = NULL;
-+ }
-+ }
-+
- _tnl_free_vertices(&intel->ctx);
- }
-
-diff --git a/src/mesa/drivers/dri/i915tex/i915_metaops.c b/src/mesa/drivers/dri/i915tex/i915_metaops.c
-index 3ab62bc..397ff75 100644
---- a/src/mesa/drivers/dri/i915tex/i915_metaops.c
-+++ b/src/mesa/drivers/dri/i915tex/i915_metaops.c
-@@ -95,7 +95,7 @@ meta_depth_replace(struct intel_context *intel)
- i915->meta.Ctx[I915_CTXREG_LIS6] |= (S6_DEPTH_TEST_ENABLE |
- S6_DEPTH_WRITE_ENABLE);
-
-- /* ctx->Driver.DepthFunc( ctx, GL_REPLACE )
-+ /* ctx->Driver.DepthFunc( ctx, GL_ALWAYS )
- */
- i915->meta.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_FUNC_MASK;
- i915->meta.Ctx[I915_CTXREG_LIS6] |=
-diff --git a/src/mesa/drivers/dri/i915tex/i915_tex_layout.c b/src/mesa/drivers/dri/i915tex/i915_tex_layout.c
-index 9f40706..7b761a7 100644
---- a/src/mesa/drivers/dri/i915tex/i915_tex_layout.c
-+++ b/src/mesa/drivers/dri/i915tex/i915_tex_layout.c
-@@ -113,7 +113,7 @@ i915_miptree_layout(struct intel_mipmap_tree * mt)
- */
- for (level = mt->first_level; level <= MAX2(8, mt->last_level);
- level++) {
-- intel_miptree_set_level_info(mt, level, 1, 0, mt->total_height,
-+ intel_miptree_set_level_info(mt, level, depth, 0, mt->total_height,
- width, height, depth);
-
-
-diff --git a/src/mesa/drivers/dri/i915tex/i915_vtbl.c b/src/mesa/drivers/dri/i915tex/i915_vtbl.c
-index ad333b4..e911fc4 100644
---- a/src/mesa/drivers/dri/i915tex/i915_vtbl.c
-+++ b/src/mesa/drivers/dri/i915tex/i915_vtbl.c
-@@ -430,6 +430,16 @@ i915_emit_state(struct intel_context *intel)
- static void
- i915_destroy_context(struct intel_context *intel)
- {
-+ GLuint i;
-+ struct i915_context *i915 = i915_context(&intel->ctx);
-+
-+ for (i = 0; i < I915_TEX_UNITS; i++) {
-+ if (i915->state.tex_buffer[i] != NULL) {
-+ driBOUnReference(i915->state.tex_buffer[i]);
-+ i915->state.tex_buffer[i] = NULL;
-+ }
-+ }
-+
- _tnl_free_vertices(&intel->ctx);
- }
-
-diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c
-index 15d02f8..78fb720 100644
---- a/src/mesa/drivers/dri/i915tex/intel_buffers.c
-+++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c
-@@ -1124,6 +1124,15 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
- ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
- }
-
-+ /*
-+ * Update depth test state
-+ */
-+ if (ctx->Depth.Test && fb->Visual.depthBits > 0) {
-+ ctx->Driver.Enable(ctx, GL_DEPTH_TEST, GL_TRUE);
-+ }
-+ else {
-+ ctx->Driver.Enable(ctx, GL_DEPTH_TEST, GL_FALSE);
-+ }
-
- /**
- ** Release old regions, reference new regions
-diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c
-index 093b3b4..40ea756 100644
---- a/src/mesa/drivers/dri/i915tex/intel_context.c
-+++ b/src/mesa/drivers/dri/i915tex/intel_context.c
-@@ -130,6 +130,18 @@ intelGetString(GLcontext * ctx, GLenum name)
- case PCI_CHIP_I945_GM:
- chipset = "Intel(R) 945GM";
- break;
-+ case PCI_CHIP_I945_GME:
-+ chipset = "Intel(R) 945GME";
-+ break;
-+ case PCI_CHIP_G33_G:
-+ chipset = "Intel(R) G33";
-+ break;
-+ case PCI_CHIP_Q35_G:
-+ chipset = "Intel(R) Q35";
-+ break;
-+ case PCI_CHIP_Q33_G:
-+ chipset = "Intel(R) Q33";
-+ break;
- default:
- chipset = "Unknown Intel Chipset";
- break;
-diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h
-index bcbbb12..5fc8eb3 100644
---- a/src/mesa/drivers/dri/i915tex/intel_context.h
-+++ b/src/mesa/drivers/dri/i915tex/intel_context.h
-@@ -385,6 +385,10 @@ extern int INTEL_DEBUG;
- #define PCI_CHIP_I915_GM 0x2592
- #define PCI_CHIP_I945_G 0x2772
- #define PCI_CHIP_I945_GM 0x27A2
-+#define PCI_CHIP_I945_GME 0x27AE
-+#define PCI_CHIP_G33_G 0x29C2
-+#define PCI_CHIP_Q35_G 0x29B2
-+#define PCI_CHIP_Q33_G 0x29D2
-
-
- /* ================================================================
-diff --git a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c
-index 8e83028..564eb9e 100644
---- a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c
-+++ b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c
-@@ -79,6 +79,10 @@ intel_miptree_create(struct intel_context *intel,
- switch (intel->intelScreen->deviceID) {
- case PCI_CHIP_I945_G:
- case PCI_CHIP_I945_GM:
-+ case PCI_CHIP_I945_GME:
-+ case PCI_CHIP_G33_G:
-+ case PCI_CHIP_Q33_G:
-+ case PCI_CHIP_Q35_G:
- ok = i945_miptree_layout(mt);
- break;
- case PCI_CHIP_I915_G:
-@@ -93,9 +97,28 @@ intel_miptree_create(struct intel_context *intel,
- break;
- }
-
-- if (ok)
-+ if (ok) {
-+ if (!mt->compressed) {
-+ /* XXX: Align pitch to multiple of 64 bytes for now to allow
-+ * render-to-texture to work in all cases. This should probably be
-+ * replaced at some point by some scheme to only do this when really
-+ * necessary.
-+ */
-+ mt->pitch = (mt->pitch * cpp + 63) & ~63;
-+
-+ /* XXX: At least the i915 seems very upset when the pitch is a multiple
-+ * of 1024 and sometimes 512 bytes - performance can drop by several
-+ * times. Go to the next multiple of 64 for now.
-+ */
-+ if (!(mt->pitch & 511))
-+ mt->pitch += 64;
-+
-+ mt->pitch /= cpp;
-+ }
-+
- mt->region = intel_region_alloc(intel->intelScreen,
- mt->cpp, mt->pitch, mt->total_height);
-+ }
-
- if (!mt->region) {
- free(mt);
-diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.c b/src/mesa/drivers/dri/i915tex/intel_screen.c
-index 5e6df81..2acdead 100644
---- a/src/mesa/drivers/dri/i915tex/intel_screen.c
-+++ b/src/mesa/drivers/dri/i915tex/intel_screen.c
-@@ -752,6 +752,10 @@ intelCreateContext(const __GLcontextModes * mesaVis,
- case PCI_CHIP_I915_GM:
- case PCI_CHIP_I945_G:
- case PCI_CHIP_I945_GM:
-+ case PCI_CHIP_I945_GME:
-+ case PCI_CHIP_G33_G:
-+ case PCI_CHIP_Q35_G:
-+ case PCI_CHIP_Q33_G:
- return i915CreateContext(mesaVis, driContextPriv, sharedContextPrivate);
-
- default:
-diff --git a/src/mesa/drivers/dri/i965/brw_aub.c b/src/mesa/drivers/dri/i965/brw_aub.c
-index f851a5b..c549f7a 100644
---- a/src/mesa/drivers/dri/i965/brw_aub.c
-+++ b/src/mesa/drivers/dri/i965/brw_aub.c
-@@ -80,7 +80,7 @@ static void init_aubfile( FILE *aub_file )
- fh.hour = (nr>>16) & 0xff;
- fh.comment_length = 0x0;
-
-- if (fwrite(&fh, sizeof(fh), 1, aub_file) < 0)
-+ if (fwrite(&fh, sizeof(fh), 1, aub_file) < 1)
- FAIL;
-
- /* Setup the GTT starting at main memory address zero (!):
-@@ -96,12 +96,12 @@ static void init_aubfile( FILE *aub_file )
- bh.address = PGETBL_CTL;
- bh.length = 0x4;
-
-- if (fwrite(&bh, sizeof(bh), 1, aub_file) < 0)
-+ if (fwrite(&bh, sizeof(bh), 1, aub_file) < 1)
- FAIL;
-
- data = 0x0 | PGETBL_ENABLED;
-
-- if (fwrite(&data, sizeof(data), 1, aub_file) < 0)
-+ if (fwrite(&data, sizeof(data), 1, aub_file) < 1)
- FAIL;
- }
-
-@@ -128,7 +128,7 @@ static void init_aub_gtt( struct brw_context *brw,
- bh.address = start_offset / 4096 * 4;
- bh.length = size / 4096 * 4;
-
-- if (fwrite(&bh, sizeof(bh), 1, aub_file) < 0)
-+ if (fwrite(&bh, sizeof(bh), 1, aub_file) < 1)
- FAIL;
-
- for (i = 0; i < size / 4096; i++) {
-@@ -136,7 +136,7 @@ static void init_aub_gtt( struct brw_context *brw,
-
- brw->next_free_page += 4096;
-
-- if (fwrite(&data, sizeof(data), 1, aub_file) < 0)
-+ if (fwrite(&data, sizeof(data), 1, aub_file) < 1)
- FAIL;
- }
-
-@@ -149,10 +149,10 @@ static void write_block_header( FILE *aub_file,
- {
- sz = (sz + 3) & ~3;
-
-- if (fwrite(bh, sizeof(*bh), 1, aub_file) < 0)
-+ if (fwrite(bh, sizeof(*bh), 1, aub_file) < 1)
- FAIL;
-
-- if (fwrite(data, sz, 1, aub_file) < 0)
-+ if (fwrite(data, sz, 1, aub_file) < 1)
- FAIL;
-
- fflush(aub_file);
-@@ -162,7 +162,7 @@ static void write_block_header( FILE *aub_file,
- static void write_dump_bmp( FILE *aub_file,
- struct aub_dump_bmp *db )
- {
-- if (fwrite(db, sizeof(*db), 1, aub_file) < 0)
-+ if (fwrite(db, sizeof(*db), 1, aub_file) < 1)
- FAIL;
-
- fflush(aub_file);
-diff --git a/src/mesa/drivers/dri/i965/brw_clip.c b/src/mesa/drivers/dri/i965/brw_clip.c
-index 3bec153..8287fd9 100644
---- a/src/mesa/drivers/dri/i965/brw_clip.c
-+++ b/src/mesa/drivers/dri/i965/brw_clip.c
-@@ -212,6 +212,10 @@ static void upload_clip_prog( struct brw_context *brw )
- }
- }
-
-+ if (brw->attribs.Polygon->BackMode != GL_FILL ||
-+ brw->attribs.Polygon->FrontMode != GL_FILL)
-+ key.do_unfilled = 1;
-+
- /* Most cases the fixed function units will handle. Cases where
- * one or more polygon faces are unfilled will require help:
- */
-diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c
-index 3f0aaa1..5bf0ed5 100644
---- a/src/mesa/drivers/dri/i965/brw_curbe.c
-+++ b/src/mesa/drivers/dri/i965/brw_curbe.c
-@@ -90,7 +90,7 @@ static void calculate_curbe_offsets( struct brw_context *brw )
- */
- if (nr_fp_regs > brw->curbe.wm_size ||
- nr_vp_regs > brw->curbe.vs_size ||
-- nr_clip_regs > brw->curbe.clip_size ||
-+ nr_clip_regs != brw->curbe.clip_size ||
- (total_regs < brw->curbe.total_size / 4 &&
- brw->curbe.total_size > 16)) {
-
-diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
-index c7798b1..f796472 100644
---- a/src/mesa/drivers/dri/i965/brw_draw.c
-+++ b/src/mesa/drivers/dri/i965/brw_draw.c
-@@ -330,6 +330,7 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
- else {
- /* Otherwise, explicitly do the cliprects at this point:
- */
-+ GLuint nprims = 0;
- for (j = 0; j < brw->intel.numClipRects; j++) {
- brw_emit_cliprect(brw, &brw->intel.pClipRects[j]);
-
-@@ -337,6 +338,11 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
- */
- for (i = 0; i < nr_prims; i++) {
- brw_emit_prim(brw, &prim[i]);
-+
-+ if (++nprims == VBO_MAX_PRIM) {
-+ intel_batchbuffer_flush(brw->intel.batch);
-+ nprims = 0;
-+ }
- }
- }
- }
-diff --git a/src/mesa/drivers/dri/i965/brw_sf_emit.c b/src/mesa/drivers/dri/i965/brw_sf_emit.c
-index cbaf018..2ea9816 100644
---- a/src/mesa/drivers/dri/i965/brw_sf_emit.c
-+++ b/src/mesa/drivers/dri/i965/brw_sf_emit.c
-@@ -582,7 +582,9 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
- (1<<_3DPRIM_TRIFAN_NOSTIPPLE)));
- jmp = brw_JMPI(p, ip, ip, brw_imm_w(0));
- {
-+ brw_push_insn_state(p);
- brw_emit_tri_setup( c );
-+ brw_pop_insn_state(p);
- /* note - thread killed in subroutine */
- }
- brw_land_fwd_jump(p, jmp);
-@@ -596,7 +598,9 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
- (1<<_3DPRIM_LINESTRIP_CONT_BF)));
- jmp = brw_JMPI(p, ip, ip, brw_imm_w(0));
- {
-+ brw_push_insn_state(p);
- brw_emit_line_setup( c );
-+ brw_pop_insn_state(p);
- /* note - thread killed in subroutine */
- }
- brw_land_fwd_jump(p, jmp);
-diff --git a/src/mesa/drivers/dri/i965/brw_vs_tnl.c b/src/mesa/drivers/dri/i965/brw_vs_tnl.c
-index 35adc48..14483b3 100644
---- a/src/mesa/drivers/dri/i965/brw_vs_tnl.c
-+++ b/src/mesa/drivers/dri/i965/brw_vs_tnl.c
-@@ -1000,13 +1000,19 @@ static void build_lighting( struct tnl_program *p )
- STATE_POSITION);
- struct ureg V = get_eye_position(p);
- struct ureg dist = get_temp(p);
-+ struct ureg tmpPpli = get_temp(p);
-
- VPpli = get_temp(p);
- half = get_temp(p);
--
-+
-+ /* In homogeneous object coordinates
-+ */
-+ emit_op1(p, OPCODE_RCP, dist, 0, swizzle1(Ppli, W));
-+ emit_op2(p, OPCODE_MUL, tmpPpli, 0, Ppli, dist);
-+
- /* Calulate VPpli vector
- */
-- emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V);
-+ emit_op2(p, OPCODE_SUB, VPpli, 0, tmpPpli, V);
-
- /* Normalize VPpli. The dist value also used in
- * attenuation below.
-@@ -1038,6 +1044,7 @@ static void build_lighting( struct tnl_program *p )
- emit_normalize_vec3(p, half, half);
-
- release_temp(p, dist);
-+ release_temp(p, tmpPpli);
- }
-
- /* Calculate dot products:
-diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c
-index ff97d87..dc57fd2 100644
---- a/src/mesa/drivers/dri/i965/brw_wm_fp.c
-+++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c
-@@ -525,7 +525,57 @@ static void precalc_tex( struct brw_wm_compile *c,
- struct prog_src_register coord;
- struct prog_dst_register tmpcoord;
-
-- if (inst->TexSrcTarget == TEXTURE_RECT_INDEX) {
-+ if (inst->TexSrcTarget == TEXTURE_CUBE_INDEX) {
-+ struct prog_instruction *out;
-+ struct prog_dst_register tmp0 = get_temp(c);
-+ struct prog_src_register tmp0src = src_reg_from_dst(tmp0);
-+ struct prog_dst_register tmp1 = get_temp(c);
-+ struct prog_src_register tmp1src = src_reg_from_dst(tmp1);
-+ struct prog_src_register src0 = inst->SrcReg[0];
-+
-+ tmpcoord = get_temp(c);
-+ coord = src_reg_from_dst(tmpcoord);
-+
-+ out = emit_op(c, OPCODE_MOV,
-+ tmpcoord,
-+ 0, 0, 0,
-+ src0,
-+ src_undef(),
-+ src_undef());
-+ out->SrcReg[0].NegateBase = 0;
-+ out->SrcReg[0].Abs = 1;
-+
-+ emit_op(c, OPCODE_MAX,
-+ tmp0,
-+ 0, 0, 0,
-+ src_swizzle1(coord, X),
-+ src_swizzle1(coord, Y),
-+ src_undef());
-+
-+ emit_op(c, OPCODE_MAX,
-+ tmp1,
-+ 0, 0, 0,
-+ tmp0src,
-+ src_swizzle1(coord, Z),
-+ src_undef());
-+
-+ emit_op(c, OPCODE_RCP,
-+ tmp0,
-+ 0, 0, 0,
-+ tmp1src,
-+ src_undef(),
-+ src_undef());
-+
-+ emit_op(c, OPCODE_MUL,
-+ tmpcoord,
-+ 0, 0, 0,
-+ src0,
-+ tmp0src,
-+ src_undef());
-+
-+ release_temp(c, tmp0);
-+ release_temp(c, tmp1);
-+ } else if (inst->TexSrcTarget == TEXTURE_RECT_INDEX) {
- struct prog_src_register scale =
- search_or_add_param5( c,
- STATE_INTERNAL,
-diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
-index 93d4cfc..794c7d9 100644
---- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
-+++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
-@@ -173,12 +173,12 @@ static void brw_update_sampler_state( struct gl_texture_unit *texUnit,
- * message (sample_c). So need to recompile WM program when
- * shadow comparison is enabled on each/any texture unit.
- */
-- sampler->ss0.shadow_function = intel_translate_compare_func(texObj->CompareFunc);
-+ sampler->ss0.shadow_function = intel_translate_shadow_compare_func(texObj->CompareFunc);
- }
-
- /* Set LOD bias:
- */
-- sampler->ss0.lod_bias = S_FIXED(texUnit->LodBias + texObj->LodBias, 6);
-+ sampler->ss0.lod_bias = S_FIXED(CLAMP(texUnit->LodBias + texObj->LodBias, -16, 15), 6);
-
- sampler->ss0.lod_preclamp = 1; /* OpenGL mode */
- sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */
-@@ -192,8 +192,8 @@ static void brw_update_sampler_state( struct gl_texture_unit *texUnit,
- */
- sampler->ss0.base_level = U_FIXED(0, 1);
-
-- sampler->ss1.max_lod = U_FIXED(MAX2(texObj->MaxLod, 0), 6);
-- sampler->ss1.min_lod = U_FIXED(MAX2(texObj->MinLod, 0), 6);
-+ sampler->ss1.max_lod = U_FIXED(MIN2(MAX2(texObj->MaxLod, 0), 13), 6);
-+ sampler->ss1.min_lod = U_FIXED(MIN2(MAX2(texObj->MinLod, 0), 13), 6);
-
- sampler->ss2.default_color_pointer = sdc_gs_offset >> 5;
- }
-diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c
-index ff5cb31..5b4f2ab 100644
---- a/src/mesa/drivers/dri/i965/brw_wm_state.c
-+++ b/src/mesa/drivers/dri/i965/brw_wm_state.c
-@@ -117,7 +117,7 @@ static void upload_wm_unit(struct brw_context *brw )
- wm.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
-
- /* CACHE_NEW_SAMPLER */
-- wm.wm4.sampler_count = brw->wm.sampler_count;
-+ wm.wm4.sampler_count = (brw->wm.sampler_count + 1) / 4;
- wm.wm4.sampler_state_pointer = brw->wm.sampler_gs_offset >> 5;
-
- /* BRW_NEW_FRAGMENT_PROGRAM */
-diff --git a/src/mesa/drivers/dri/i965/intel_buffers.c b/src/mesa/drivers/dri/i965/intel_buffers.c
-index d155c03..de6a867 100644
---- a/src/mesa/drivers/dri/i965/intel_buffers.c
-+++ b/src/mesa/drivers/dri/i965/intel_buffers.c
-@@ -31,7 +31,9 @@
- #include "intel_regions.h"
- #include "intel_batchbuffer.h"
- #include "context.h"
-+#include "utils.h"
- #include "framebuffer.h"
-+#include "vblank.h"
- #include "macros.h"
- #include "swrast/swrast.h"
-
-@@ -190,8 +192,40 @@ void intelWindowMoved( struct intel_context *intel )
- }
- }
-
-+ {
-+ if (intel->intelScreen->driScrnPriv->ddxMinor >= 7) {
-+ volatile drmI830Sarea *sarea = intel->sarea;
-+ drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w,
-+ .y1 = dPriv->y, .y2 = dPriv->y + dPriv->h
-+ };
-+ drm_clip_rect_t pipeA_rect = { .x1 = sarea->pipeA_x,
-+ .x2 = sarea->pipeA_x + sarea->pipeA_w,
-+ .y1 = sarea->pipeA_y,
-+ .y2 = sarea->pipeA_y + sarea->pipeA_h };
-+ drm_clip_rect_t pipeB_rect = { .x1 = sarea->pipeB_x,
-+ .x2 = sarea->pipeB_x + sarea->pipeB_w,
-+ .y1 = sarea->pipeB_y,
-+ .y2 = sarea->pipeB_y + sarea->pipeB_h };
-+ GLint areaA = driIntersectArea( drw_rect, pipeA_rect );
-+ GLint areaB = driIntersectArea( drw_rect, pipeB_rect );
-+ GLuint flags = intel->vblank_flags;
-+
-+ if (areaB > areaA || (areaA > 0 && areaB > 0)) {
-+ flags = intel->vblank_flags | VBLANK_FLAG_SECONDARY;
-+ } else {
-+ flags = intel->vblank_flags & ~VBLANK_FLAG_SECONDARY;
-+ }
-+
-+ if (flags != intel->vblank_flags) {
-+ intel->vblank_flags = flags;
-+ driGetCurrentVBlank(dPriv, intel->vblank_flags, &intel->vbl_seq);
-+ }
-+ } else {
-+ intel->vblank_flags &= ~VBLANK_FLAG_SECONDARY;
-+ }
-+ }
- _mesa_resize_framebuffer(&intel->ctx,
-- (GLframebuffer*)dPriv->driverPrivate,
-+ (GLframebuffer*)dPriv->driverPrivate,
- dPriv->w, dPriv->h);
-
- /* Set state we know depends on drawable parameters:
-diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c
-index 10eb9a2..33efed4 100644
---- a/src/mesa/drivers/dri/i965/intel_context.c
-+++ b/src/mesa/drivers/dri/i965/intel_context.c
-@@ -262,7 +262,7 @@ intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
- };
- intel->stats_wm++;
- intelFinish(&intel->ctx);
-- drmCommandRead(intel->driFd, DRM_I830_MMIO, &io, sizeof(io));
-+ drmCommandWrite(intel->driFd, DRM_I830_MMIO, &io, sizeof(io));
- }
-
- static void
-@@ -276,7 +276,7 @@ intelEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
- .data = &tmp
- };
- intelFinish(&intel->ctx);
-- drmCommandRead(intel->driFd, DRM_I830_MMIO, &io, sizeof(io));
-+ drmCommandWrite(intel->driFd, DRM_I830_MMIO, &io, sizeof(io));
- q->Result = tmp - q->Result;
- q->Ready = GL_TRUE;
- intel->stats_wm--;
-@@ -487,7 +487,7 @@ GLboolean intelInitContext( struct intel_context *intel,
- _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
- _mesa_enable_extension( ctx, "GL_S3_s3tc" );
- }
-- else if (driQueryOptionb (&intelScreen->optionCache, "force_s3tc_enable")) {
-+ else if (driQueryOptionb (&intel->optionCache, "force_s3tc_enable")) {
- _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
- }
-
-@@ -567,6 +567,10 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
- if (driContextPriv) {
- struct intel_context *intel = (struct intel_context *) driContextPriv->driverPrivate;
-
-+ if (intel->driReadDrawable != driReadPriv) {
-+ intel->driReadDrawable = driReadPriv;
-+ }
-+
- if ( intel->driDrawable != driDrawPriv ) {
- /* Shouldn't the readbuffer be stored also? */
- driDrawableInitVBlank( driDrawPriv, intel->vblank_flags,
-diff --git a/src/mesa/drivers/dri/i965/intel_context.h b/src/mesa/drivers/dri/i965/intel_context.h
-index 808512f..9f69f23 100644
---- a/src/mesa/drivers/dri/i965/intel_context.h
-+++ b/src/mesa/drivers/dri/i965/intel_context.h
-@@ -234,6 +234,7 @@ struct intel_context
- int driFd;
-
- __DRIdrawablePrivate *driDrawable;
-+ __DRIdrawablePrivate *driReadDrawable;
- __DRIscreenPrivate *driScreen;
- intelScreenPrivate *intelScreen;
- volatile drmI830Sarea *sarea;
-@@ -463,7 +464,7 @@ extern void intelInitStateFuncs( struct dd_function_table *functions );
- #define BLENDFACT_INV_CONST_ALPHA 0x0f
- #define BLENDFACT_MASK 0x0f
-
--
-+extern int intel_translate_shadow_compare_func( GLenum func );
- extern int intel_translate_compare_func( GLenum func );
- extern int intel_translate_stencil_op( GLenum op );
- extern int intel_translate_blend_factor( GLenum factor );
-diff --git a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c
-index 421fcc5..df9d688 100644
---- a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c
-+++ b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c
-@@ -168,12 +168,15 @@ do_blit_bitmap( GLcontext *ctx,
- {
- struct intel_context *intel = intel_context(ctx);
- struct intel_region *dst = intel_drawbuf_region(intel);
--
-+ GLfloat tmpColor[4];
-+
- union {
- GLuint ui;
- GLubyte ub[4];
- } color;
-
-+ if (!dst)
-+ return GL_FALSE;
-
- if (unpack->BufferObj->Name) {
- bitmap = map_pbo(ctx, width, height, unpack, bitmap);
-@@ -181,10 +184,16 @@ do_blit_bitmap( GLcontext *ctx,
- return GL_TRUE; /* even though this is an error, we're done */
- }
-
-- UNCLAMPED_FLOAT_TO_CHAN(color.ub[0], ctx->Current.RasterColor[2]);
-- UNCLAMPED_FLOAT_TO_CHAN(color.ub[1], ctx->Current.RasterColor[1]);
-- UNCLAMPED_FLOAT_TO_CHAN(color.ub[2], ctx->Current.RasterColor[0]);
-- UNCLAMPED_FLOAT_TO_CHAN(color.ub[3], ctx->Current.RasterColor[3]);
-+ COPY_4V(tmpColor, ctx->Current.RasterColor);
-+
-+ if (NEED_SECONDARY_COLOR(ctx)) {
-+ ADD_3V(tmpColor, tmpColor, ctx->Current.RasterSecondaryColor);
-+ }
-+
-+ UNCLAMPED_FLOAT_TO_CHAN(color.ub[0], tmpColor[2]);
-+ UNCLAMPED_FLOAT_TO_CHAN(color.ub[1], tmpColor[1]);
-+ UNCLAMPED_FLOAT_TO_CHAN(color.ub[2], tmpColor[0]);
-+ UNCLAMPED_FLOAT_TO_CHAN(color.ub[3], tmpColor[3]);
-
- /* Does zoom apply to bitmaps?
- */
-diff --git a/src/mesa/drivers/dri/i965/intel_pixel_copy.c b/src/mesa/drivers/dri/i965/intel_pixel_copy.c
-index 58dc495..3bdf2fb 100644
---- a/src/mesa/drivers/dri/i965/intel_pixel_copy.c
-+++ b/src/mesa/drivers/dri/i965/intel_pixel_copy.c
-@@ -231,6 +231,7 @@ do_blit_copypixels(GLcontext * ctx,
-
- if (intel->driDrawable->numClipRects) {
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
-+ __DRIdrawablePrivate *dReadPriv = intel->driReadDrawable;
- drm_clip_rect_t *box = dPriv->pClipRects;
- drm_clip_rect_t dest_rect;
- GLint nbox = dPriv->numClipRects;
-@@ -262,8 +263,8 @@ do_blit_copypixels(GLcontext * ctx,
- srcy = dPriv->h - srcy - height;
- dstx += dPriv->x;
- dsty += dPriv->y;
-- srcx += dPriv->x;
-- srcy += dPriv->y;
-+ srcx += dReadPriv->x;
-+ srcy += dReadPriv->y;
-
- /* Clip against the source region. This is the only source
- * clipping we do. Dst is clipped with cliprects below.
-diff --git a/src/mesa/drivers/dri/i965/intel_state.c b/src/mesa/drivers/dri/i965/intel_state.c
-index ec6e046..701b30c 100644
---- a/src/mesa/drivers/dri/i965/intel_state.c
-+++ b/src/mesa/drivers/dri/i965/intel_state.c
-@@ -38,6 +38,31 @@
- #include "intel_regions.h"
- #include "swrast/swrast.h"
-
-+int intel_translate_shadow_compare_func( GLenum func )
-+{
-+ switch(func) {
-+ case GL_NEVER:
-+ return COMPAREFUNC_ALWAYS;
-+ case GL_LESS:
-+ return COMPAREFUNC_LEQUAL;
-+ case GL_LEQUAL:
-+ return COMPAREFUNC_LESS;
-+ case GL_GREATER:
-+ return COMPAREFUNC_GEQUAL;
-+ case GL_GEQUAL:
-+ return COMPAREFUNC_GREATER;
-+ case GL_NOTEQUAL:
-+ return COMPAREFUNC_EQUAL;
-+ case GL_EQUAL:
-+ return COMPAREFUNC_NOTEQUAL;
-+ case GL_ALWAYS:
-+ return COMPAREFUNC_NEVER;
-+ }
-+
-+ fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, func);
-+ return COMPAREFUNC_NEVER;
-+}
-+
- int intel_translate_compare_func( GLenum func )
- {
- switch(func) {
-diff --git a/src/mesa/drivers/dri/i965/server/i830_common.h b/src/mesa/drivers/dri/i965/server/i830_common.h
-index f320378..fe2b8e8 100644
---- a/src/mesa/drivers/dri/i965/server/i830_common.h
-+++ b/src/mesa/drivers/dri/i965/server/i830_common.h
-@@ -119,6 +119,16 @@ typedef struct {
- unsigned int depth_tiled;
- unsigned int rotated_tiled;
- unsigned int rotated2_tiled;
-+
-+ int pipeA_x;
-+ int pipeA_y;
-+ int pipeA_w;
-+ int pipeA_h;
-+ int pipeB_x;
-+ int pipeB_y;
-+ int pipeB_w;
-+ int pipeB_h;
-+
- } drmI830Sarea;
-
- /* Flags for perf_boxes
-diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c
-index 4d25d32..7c73877 100644
---- a/src/mesa/drivers/dri/unichrome/via_context.c
-+++ b/src/mesa/drivers/dri/unichrome/via_context.c
-@@ -733,14 +733,15 @@ void viaXMesaWindowMoved(struct via_context *vmesa)
- {
- __DRIdrawablePrivate *const drawable = vmesa->driDrawable;
- __DRIdrawablePrivate *const readable = vmesa->driReadable;
-- struct via_renderbuffer *const draw_buffer =
-- (struct via_renderbuffer *) drawable->driverPrivate;
-- struct via_renderbuffer *const read_buffer =
-- (struct via_renderbuffer *) readable->driverPrivate;
-+ struct via_renderbuffer * draw_buffer;
-+ struct via_renderbuffer * read_buffer;
- GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3;
-
- if (!drawable)
- return;
-+
-+ draw_buffer = (struct via_renderbuffer *) drawable->driverPrivate;
-+ read_buffer = (struct via_renderbuffer *) readable->driverPrivate;
-
- switch (vmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
- case BUFFER_BIT_BACK_LEFT:
-diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c
-index 5b67439..c1d26a3 100644
---- a/src/mesa/drivers/windows/gdi/wmesa.c
-+++ b/src/mesa/drivers/windows/gdi/wmesa.c
-@@ -458,23 +458,84 @@ static void write_rgba_span_front(const GLcontext *ctx,
- const GLubyte rgba[][4],
- const GLubyte mask[] )
- {
-- WMesaContext pwc = wmesa_context(ctx);
-- GLuint i;
--
-- (void) ctx;
-- y=FLIP(y);
-- if (mask) {
-- for (i=0; i<n; i++)
-- if (mask[i])
-- SetPixel(pwc->hDC, x+i, y, RGB(rgba[i][RCOMP], rgba[i][GCOMP],
-- rgba[i][BCOMP]));
-- }
-- else {
-- for (i=0; i<n; i++)
-- SetPixel(pwc->hDC, x+i, y, RGB(rgba[i][RCOMP], rgba[i][GCOMP],
-- rgba[i][BCOMP]));
-- }
--
-+ WMesaContext pwc = wmesa_context(ctx);
-+ WMesaFramebuffer pwfb = wmesa_lookup_framebuffer(pwc->hDC);
-+ CONST BITMAPINFO bmi=
-+ {
-+ {
-+ sizeof(BITMAPINFOHEADER),
-+ n, 1, 1, 32, BI_RGB, 0, 1, 1, 0, 0
-+ }
-+ };
-+ HBITMAP bmp=0;
-+ HDC mdc=0;
-+ typedef union
-+ {
-+ unsigned i;
-+ struct {
-+ unsigned b:8, g:8, r:8, a:8;
-+ };
-+ } BGRA;
-+ BGRA *bgra, c;
-+ int i;
-+
-+ if (n < 16) { // the value 16 is just guessed
-+ y=FLIP(y);
-+ if (mask) {
-+ for (i=0; i<n; i++)
-+ if (mask[i])
-+ SetPixel(pwc->hDC, x+i, y,
-+ RGB(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]));
-+ }
-+ else {
-+ for (i=0; i<n; i++)
-+ SetPixel(pwc->hDC, x+i, y,
-+ RGB(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]));
-+ }
-+ }
-+ else {
-+ if (!pwfb) {
-+ _mesa_problem(NULL, "wmesa: write_rgba_span_front on unknown hdc");
-+ return;
-+ }
-+ bgra=malloc(n*sizeof(BGRA));
-+ if (!bgra) {
-+ _mesa_problem(NULL, "wmesa: write_rgba_span_front: out of memory");
-+ return;
-+ }
-+ c.a=0;
-+ if (mask) {
-+ for (i=0; i<n; i++) {
-+ if (mask[i]) {
-+ c.r=rgba[i][RCOMP];
-+ c.g=rgba[i][GCOMP];
-+ c.b=rgba[i][BCOMP];
-+ c.a=rgba[i][ACOMP];
-+ bgra[i]=c;
-+ }
-+ else
-+ bgra[i].i=0;
-+ }
-+ }
-+ else {
-+ for (i=0; i<n; i++) {
-+ c.r=rgba[i][RCOMP];
-+ c.g=rgba[i][GCOMP];
-+ c.b=rgba[i][BCOMP];
-+ c.a=rgba[i][ACOMP];
-+ bgra[i]=c;
-+ }
-+ }
-+ bmp=CreateBitmap(n, 1, 1, 32, bgra);
-+ mdc=CreateCompatibleDC(pwfb->hDC);
-+ SelectObject(mdc, bmp);
-+ y=FLIP(y);
-+ BitBlt(pwfb->hDC, x, y, n, 1, mdc, 0, 0, SRCCOPY);
-+ SelectObject(mdc, 0);
-+ DeleteObject(bmp);
-+ DeleteDC(mdc);
-+ free(bgra);
-+ }
- }
-
- /* Write a horizontal span of RGB color pixels with a boolean mask. */
-diff --git a/src/mesa/gl.pc.in b/src/mesa/gl.pc.in
-new file mode 100644
-index 0000000..4b144ff
---- /dev/null
-+++ b/src/mesa/gl.pc.in
-@@ -0,0 +1,11 @@
-+prefix=@INSTALL_DIR@
-+exec_prefix=${prefix}
-+libdir=${exec_prefix}/@LIB_DIR@
-+includedir=${prefix}/include
-+
-+Name: gl
-+Description: Mesa OpenGL library
-+Requires:
-+Version: @VERSION@
-+Libs: -L${libdir} -lGL
-+Cflags: -I${includedir}
-diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
-index 841c6a5..4544843 100644
---- a/src/mesa/main/api_validate.c
-+++ b/src/mesa/main/api_validate.c
-@@ -1,6 +1,6 @@
- /*
- * Mesa 3-D graphics library
-- * Version: 7.0.1
-+ * Version: 7.0.2
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
-@@ -30,6 +30,55 @@
- #include "state.h"
-
-
-+/**
-+ * Find the max index in the given element/index buffer
-+ */
-+static GLuint
-+max_buffer_index(GLcontext *ctx, GLuint count, GLenum type,
-+ const void *indices,
-+ struct gl_buffer_object *elementBuf)
-+{
-+ const GLubyte *map = NULL;
-+ GLuint max = 0;
-+ GLint i;
-+
-+ if (elementBuf->Name) {
-+ /* elements are in a user-defined buffer object. need to map it */
-+ map = ctx->Driver.MapBuffer(ctx,
-+ GL_ELEMENT_ARRAY_BUFFER_ARB,
-+ GL_READ_ONLY,
-+ elementBuf);
-+ /* Actual address is the sum of pointers */
-+ indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices);
-+ }
-+
-+ if (type == GL_UNSIGNED_INT) {
-+ for (i = 0; i < count; i++)
-+ if (((GLuint *) indices)[i] > max)
-+ max = ((GLuint *) indices)[i];
-+ }
-+ else if (type == GL_UNSIGNED_SHORT) {
-+ for (i = 0; i < count; i++)
-+ if (((GLushort *) indices)[i] > max)
-+ max = ((GLushort *) indices)[i];
-+ }
-+ else {
-+ ASSERT(type == GL_UNSIGNED_BYTE);
-+ for (i = 0; i < count; i++)
-+ if (((GLubyte *) indices)[i] > max)
-+ max = ((GLubyte *) indices)[i];
-+ }
-+
-+ if (map) {
-+ ctx->Driver.UnmapBuffer(ctx,
-+ GL_ELEMENT_ARRAY_BUFFER_ARB,
-+ ctx->Array.ElementArrayBufferObj);
-+ }
-+
-+ return max;
-+}
-+
-+
- GLboolean
- _mesa_validate_DrawElements(GLcontext *ctx,
- GLenum mode, GLsizei count, GLenum type,
-@@ -61,20 +110,15 @@ _mesa_validate_DrawElements(GLcontext *ctx,
-
- /* Always need vertex positions */
- if (!ctx->Array.ArrayObj->Vertex.Enabled
-- && !(ctx->VertexProgram._Enabled && ctx->Array.ArrayObj->VertexAttrib[0].Enabled))
-+ && !(ctx->VertexProgram._Enabled
-+ && ctx->Array.ArrayObj->VertexAttrib[0].Enabled))
- return GL_FALSE;
-
- /* Vertex buffer object tests */
- if (ctx->Array.ElementArrayBufferObj->Name) {
-- GLuint indexBytes;
--
- /* use indices in the buffer object */
-- if (!ctx->Array.ElementArrayBufferObj->Data) {
-- _mesa_warning(ctx, "DrawElements with empty vertex elements buffer!");
-- return GL_FALSE;
-- }
-+ GLuint indexBytes;
-
-- /* make sure count doesn't go outside buffer bounds */
- if (type == GL_UNSIGNED_INT) {
- indexBytes = count * sizeof(GLuint);
- }
-@@ -86,19 +130,11 @@ _mesa_validate_DrawElements(GLcontext *ctx,
- indexBytes = count * sizeof(GLushort);
- }
-
-- if ((GLubyte *) indices + indexBytes >
-- ctx->Array.ElementArrayBufferObj->Data +
-- ctx->Array.ElementArrayBufferObj->Size) {
-+ /* make sure count doesn't go outside buffer bounds */
-+ if (indexBytes > ctx->Array.ElementArrayBufferObj->Size) {
- _mesa_warning(ctx, "glDrawElements index out of buffer bounds");
- return GL_FALSE;
- }
--
-- /* Actual address is the sum of pointers. Indices may be used below. */
-- if (ctx->Const.CheckArrayBounds) {
-- indices = (const GLvoid *)
-- ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data,
-- (const GLubyte *) indices);
-- }
- }
- else {
- /* not using a VBO */
-@@ -108,24 +144,8 @@ _mesa_validate_DrawElements(GLcontext *ctx,
-
- if (ctx->Const.CheckArrayBounds) {
- /* find max array index */
-- GLuint max = 0;
-- GLint i;
-- if (type == GL_UNSIGNED_INT) {
-- for (i = 0; i < count; i++)
-- if (((GLuint *) indices)[i] > max)
-- max = ((GLuint *) indices)[i];
-- }
-- else if (type == GL_UNSIGNED_SHORT) {
-- for (i = 0; i < count; i++)
-- if (((GLushort *) indices)[i] > max)
-- max = ((GLushort *) indices)[i];
-- }
-- else {
-- ASSERT(type == GL_UNSIGNED_BYTE);
-- for (i = 0; i < count; i++)
-- if (((GLubyte *) indices)[i] > max)
-- max = ((GLubyte *) indices)[i];
-- }
-+ GLuint max = max_buffer_index(ctx, count, type, indices,
-+ ctx->Array.ElementArrayBufferObj);
- if (max >= ctx->Array._MaxElement) {
- /* the max element is out of bounds of one or more enabled arrays */
- return GL_FALSE;
-@@ -172,41 +192,41 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
-
- /* Always need vertex positions */
- if (!ctx->Array.ArrayObj->Vertex.Enabled
-- && !(ctx->VertexProgram._Enabled && ctx->Array.ArrayObj->VertexAttrib[0].Enabled))
-+ && !(ctx->VertexProgram._Enabled
-+ && ctx->Array.ArrayObj->VertexAttrib[0].Enabled))
- return GL_FALSE;
-
- /* Vertex buffer object tests */
- if (ctx->Array.ElementArrayBufferObj->Name) {
-- /* XXX re-use code from above? */
-+ /* use indices in the buffer object */
-+ GLuint indexBytes;
-+
-+ if (type == GL_UNSIGNED_INT) {
-+ indexBytes = count * sizeof(GLuint);
-+ }
-+ else if (type == GL_UNSIGNED_BYTE) {
-+ indexBytes = count * sizeof(GLubyte);
-+ }
-+ else {
-+ ASSERT(type == GL_UNSIGNED_SHORT);
-+ indexBytes = count * sizeof(GLushort);
-+ }
-+
-+ /* make sure count doesn't go outside buffer bounds */
-+ if (indexBytes > ctx->Array.ElementArrayBufferObj->Size) {
-+ _mesa_warning(ctx, "glDrawRangeElements index out of buffer bounds");
-+ return GL_FALSE;
-+ }
- }
- else {
-- /* not using VBO */
-+ /* not using a VBO */
- if (!indices)
- return GL_FALSE;
- }
-
- if (ctx->Const.CheckArrayBounds) {
-- /* Find max array index.
-- * We don't trust the user's start and end values.
-- */
-- GLuint max = 0;
-- GLint i;
-- if (type == GL_UNSIGNED_INT) {
-- for (i = 0; i < count; i++)
-- if (((GLuint *) indices)[i] > max)
-- max = ((GLuint *) indices)[i];
-- }
-- else if (type == GL_UNSIGNED_SHORT) {
-- for (i = 0; i < count; i++)
-- if (((GLushort *) indices)[i] > max)
-- max = ((GLushort *) indices)[i];
-- }
-- else {
-- ASSERT(type == GL_UNSIGNED_BYTE);
-- for (i = 0; i < count; i++)
-- if (((GLubyte *) indices)[i] > max)
-- max = ((GLubyte *) indices)[i];
-- }
-+ GLuint max = max_buffer_index(ctx, count, type, indices,
-+ ctx->Array.ElementArrayBufferObj);
- if (max >= ctx->Array._MaxElement) {
- /* the max element is out of bounds of one or more enabled arrays */
- return GL_FALSE;
-@@ -241,7 +261,8 @@ _mesa_validate_DrawArrays(GLcontext *ctx,
- _mesa_update_state(ctx);
-
- /* Always need vertex positions */
-- if (!ctx->Array.ArrayObj->Vertex.Enabled && !ctx->Array.ArrayObj->VertexAttrib[0].Enabled)
-+ if (!ctx->Array.ArrayObj->Vertex.Enabled
-+ && !ctx->Array.ArrayObj->VertexAttrib[0].Enabled)
- return GL_FALSE;
-
- if (ctx->Const.CheckArrayBounds) {
-diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
-index 0b821cf..427a6b0 100644
---- a/src/mesa/main/attrib.c
-+++ b/src/mesa/main/attrib.c
-@@ -1,6 +1,6 @@
- /*
- * Mesa 3-D graphics library
-- * Version: 6.5.3
-+ * Version: 7.0.2
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
-@@ -52,6 +52,32 @@
-
-
- /**
-+ * Special struct for saving/restoring texture state (GL_TEXTURE_BIT)
-+ */
-+struct texture_state
-+{
-+ struct gl_texture_attrib Texture; /**< The usual context state */
-+
-+ /** to save per texture object state (wrap modes, filters, etc): */
-+ struct gl_texture_object Saved1D[MAX_TEXTURE_UNITS];
-+ struct gl_texture_object Saved2D[MAX_TEXTURE_UNITS];
-+ struct gl_texture_object Saved3D[MAX_TEXTURE_UNITS];
-+ struct gl_texture_object SavedCube[MAX_TEXTURE_UNITS];
-+ struct gl_texture_object SavedRect[MAX_TEXTURE_UNITS];
-+
-+ /**
-+ * To save references to texture objects (so they don't get accidentally
-+ * deleted while saved in the attribute stack).
-+ */
-+ struct gl_texture_object *SavedRef1D[MAX_TEXTURE_UNITS];
-+ struct gl_texture_object *SavedRef2D[MAX_TEXTURE_UNITS];
-+ struct gl_texture_object *SavedRef3D[MAX_TEXTURE_UNITS];
-+ struct gl_texture_object *SavedRefCube[MAX_TEXTURE_UNITS];
-+ struct gl_texture_object *SavedRefRect[MAX_TEXTURE_UNITS];
-+};
-+
-+
-+/**
- * Allocate a new attribute state node. These nodes have a
- * "kind" value and a pointer to a struct of state data.
- */
-@@ -335,40 +361,48 @@ _mesa_PushAttrib(GLbitfield mask)
- }
-
- if (mask & GL_TEXTURE_BIT) {
-- struct gl_texture_attrib *attr;
-+ struct texture_state *texstate = CALLOC_STRUCT( texture_state );
- GLuint u;
-
-+ if (!texstate) {
-+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)");
-+ goto end;
-+ }
-+
- _mesa_lock_context_textures(ctx);
-- /* Bump the texture object reference counts so that they don't
-- * inadvertantly get deleted.
-+
-+ /* copy/save the bulk of texture state here */
-+ _mesa_memcpy(&texstate->Texture, &ctx->Texture, sizeof(ctx->Texture));
-+
-+ /* Save references to the currently bound texture objects so they don't
-+ * accidentally get deleted while referenced in the attribute stack.
- */
- for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
-- ctx->Texture.Unit[u].Current1D->RefCount++;
-- ctx->Texture.Unit[u].Current2D->RefCount++;
-- ctx->Texture.Unit[u].Current3D->RefCount++;
-- ctx->Texture.Unit[u].CurrentCubeMap->RefCount++;
-- ctx->Texture.Unit[u].CurrentRect->RefCount++;
-+ _mesa_reference_texobj(&texstate->SavedRef1D[u], ctx->Texture.Unit[u].Current1D);
-+ _mesa_reference_texobj(&texstate->SavedRef2D[u], ctx->Texture.Unit[u].Current2D);
-+ _mesa_reference_texobj(&texstate->SavedRef3D[u], ctx->Texture.Unit[u].Current3D);
-+ _mesa_reference_texobj(&texstate->SavedRefCube[u], ctx->Texture.Unit[u].CurrentCubeMap);
-+ _mesa_reference_texobj(&texstate->SavedRefRect[u], ctx->Texture.Unit[u].CurrentRect);
- }
-- attr = MALLOC_STRUCT( gl_texture_attrib );
-- MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) );
-- /* copy state of the currently bound texture objects */
-+
-+ /* copy state/contents of the currently bound texture objects */
- for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
-- _mesa_copy_texture_object(&attr->Unit[u].Saved1D,
-- attr->Unit[u].Current1D);
-- _mesa_copy_texture_object(&attr->Unit[u].Saved2D,
-- attr->Unit[u].Current2D);
-- _mesa_copy_texture_object(&attr->Unit[u].Saved3D,
-- attr->Unit[u].Current3D);
-- _mesa_copy_texture_object(&attr->Unit[u].SavedCubeMap,
-- attr->Unit[u].CurrentCubeMap);
-- _mesa_copy_texture_object(&attr->Unit[u].SavedRect,
-- attr->Unit[u].CurrentRect);
-+ _mesa_copy_texture_object(&texstate->Saved1D[u],
-+ ctx->Texture.Unit[u].Current1D);
-+ _mesa_copy_texture_object(&texstate->Saved2D[u],
-+ ctx->Texture.Unit[u].Current2D);
-+ _mesa_copy_texture_object(&texstate->Saved3D[u],
-+ ctx->Texture.Unit[u].Current3D);
-+ _mesa_copy_texture_object(&texstate->SavedCube[u],
-+ ctx->Texture.Unit[u].CurrentCubeMap);
-+ _mesa_copy_texture_object(&texstate->SavedRect[u],
-+ ctx->Texture.Unit[u].CurrentRect);
- }
-
- _mesa_unlock_context_textures(ctx);
-
- newnode = new_attrib_node( GL_TEXTURE_BIT );
-- newnode->data = attr;
-+ newnode->data = texstate;
- newnode->next = head;
- head = newnode;
- }
-@@ -404,6 +438,7 @@ _mesa_PushAttrib(GLbitfield mask)
- head = newnode;
- }
-
-+end:
- ctx->AttribStack[ctx->AttribStackDepth] = head;
- ctx->AttribStackDepth++;
- }
-@@ -613,14 +648,19 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
- }
-
-
-+/**
-+ * Pop/restore texture attribute/group state.
-+ */
- static void
--pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
-+pop_texture_group(GLcontext *ctx, struct texture_state *texstate)
- {
- GLuint u;
-
-+ _mesa_lock_context_textures(ctx);
-+
- for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
-- const struct gl_texture_unit *unit = &texAttrib->Unit[u];
-- GLuint i;
-+ const struct gl_texture_unit *unit = &texstate->Texture.Unit[u];
-+ GLuint tgt;
-
- _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u);
- _mesa_set_enable(ctx, GL_TEXTURE_1D,
-@@ -713,41 +753,44 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
- 1 << unit->Combine.ScaleShiftA);
- }
-
-- /* Restore texture object state */
-- for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
-- GLenum target = 0;
-+ /* Restore texture object state for each target */
-+ for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
- const struct gl_texture_object *obj = NULL;
- GLfloat bordColor[4];
-+ GLenum target;
-
-- switch (i) {
-- case 0:
-- target = GL_TEXTURE_1D;
-- obj = &unit->Saved1D;
-+ switch (tgt) {
-+ case TEXTURE_1D_INDEX:
-+ obj = &texstate->Saved1D[u];
-+ ASSERT(obj->Target == GL_TEXTURE_1D);
- break;
-- case 1:
-- target = GL_TEXTURE_2D;
-- obj = &unit->Saved2D;
-+ case TEXTURE_2D_INDEX:
-+ obj = &texstate->Saved2D[u];
-+ ASSERT(obj->Target == GL_TEXTURE_2D);
- break;
-- case 2:
-- target = GL_TEXTURE_3D;
-- obj = &unit->Saved3D;
-+ case TEXTURE_3D_INDEX:
-+ obj = &texstate->Saved3D[u];
-+ ASSERT(obj->Target == GL_TEXTURE_3D);
- break;
-- case 3:
-+ case TEXTURE_CUBE_INDEX:
- if (!ctx->Extensions.ARB_texture_cube_map)
- continue;
-- target = GL_TEXTURE_CUBE_MAP_ARB;
-- obj = &unit->SavedCubeMap;
-+ obj = &texstate->SavedCube[u];
-+ ASSERT(obj->Target == GL_TEXTURE_CUBE_MAP_ARB);
- break;
-- case 4:
-+ case TEXTURE_RECT_INDEX:
- if (!ctx->Extensions.NV_texture_rectangle)
- continue;
-- target = GL_TEXTURE_RECTANGLE_NV;
-- obj = &unit->SavedRect;
-+ obj = &texstate->SavedRect[u];
-+ ASSERT(obj->Target == GL_TEXTURE_RECTANGLE_NV);
- break;
- default:
-- ; /* silence warnings */
-+ _mesa_problem(ctx, "bad texture index in pop_texture_group");
-+ continue;
- }
-
-+ target = obj->Target;
-+
- _mesa_BindTexture(target, obj->Name);
-
- bordColor[0] = CHAN_TO_FLOAT(obj->BorderColor[0]);
-@@ -782,23 +825,19 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
- _mesa_TexParameterf(target, GL_SHADOW_AMBIENT_SGIX,
- obj->ShadowAmbient);
- }
--
- }
-- }
-- _mesa_ActiveTextureARB(GL_TEXTURE0_ARB
-- + texAttrib->CurrentUnit);
-
-- /* "un-bump" the texture object reference counts. We did that so they
-- * wouldn't inadvertantly get deleted while they were still referenced
-- * inside the attribute state stack.
-- */
-- for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
-- ctx->Texture.Unit[u].Current1D->RefCount--;
-- ctx->Texture.Unit[u].Current2D->RefCount--;
-- ctx->Texture.Unit[u].Current3D->RefCount--;
-- ctx->Texture.Unit[u].CurrentCubeMap->RefCount--;
-- ctx->Texture.Unit[u].CurrentRect->RefCount--;
-+ /* remove saved references to the texture objects */
-+ _mesa_reference_texobj(&texstate->SavedRef1D[u], NULL);
-+ _mesa_reference_texobj(&texstate->SavedRef2D[u], NULL);
-+ _mesa_reference_texobj(&texstate->SavedRef3D[u], NULL);
-+ _mesa_reference_texobj(&texstate->SavedRefCube[u], NULL);
-+ _mesa_reference_texobj(&texstate->SavedRefRect[u], NULL);
- }
-+
-+ _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + texstate->Texture.CurrentUnit);
-+
-+ _mesa_unlock_context_textures(ctx);
- }
-
-
-@@ -1177,9 +1216,9 @@ _mesa_PopAttrib(void)
- case GL_TEXTURE_BIT:
- /* Take care of texture object reference counters */
- {
-- const struct gl_texture_attrib *texture;
-- texture = (const struct gl_texture_attrib *) attr->data;
-- pop_texture_group(ctx, texture);
-+ struct texture_state *texstate
-+ = (struct texture_state *) attr->data;
-+ pop_texture_group(ctx, texstate);
- ctx->NewState |= _NEW_TEXTURE;
- }
- break;
-@@ -1401,6 +1440,41 @@ _mesa_PopClientAttrib(void)
- }
-
-
-+void
-+_mesa_free_attrib_data(GLcontext *ctx)
-+{
-+ while (ctx->AttribStackDepth > 0) {
-+ struct gl_attrib_node *attr, *next;
-+
-+ ctx->AttribStackDepth--;
-+ attr = ctx->AttribStack[ctx->AttribStackDepth];
-+
-+ while (attr) {
-+ if (attr->kind == GL_TEXTURE_BIT) {
-+ struct texture_state *texstate = (struct texture_state*)attr->data;
-+ GLuint u;
-+ /* clear references to the saved texture objects */
-+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
-+ _mesa_reference_texobj(&texstate->SavedRef1D[u], NULL);
-+ _mesa_reference_texobj(&texstate->SavedRef2D[u], NULL);
-+ _mesa_reference_texobj(&texstate->SavedRef3D[u], NULL);
-+ _mesa_reference_texobj(&texstate->SavedRefCube[u], NULL);
-+ _mesa_reference_texobj(&texstate->SavedRefRect[u], NULL);
-+ }
-+ }
-+ else {
-+ /* any other chunks of state that requires special handling? */
-+ }
-+
-+ next = attr->next;
-+ _mesa_free(attr->data);
-+ _mesa_free(attr);
-+ attr = next;
-+ }
-+ }
-+}
-+
-+
- void _mesa_init_attrib( GLcontext *ctx )
- {
- /* Renderer and client attribute stacks */
-diff --git a/src/mesa/main/attrib.h b/src/mesa/main/attrib.h
-index 09d7519..ea28859 100644
---- a/src/mesa/main/attrib.h
-+++ b/src/mesa/main/attrib.h
-@@ -58,10 +58,14 @@ _mesa_PopClientAttrib( void );
- extern void
- _mesa_init_attrib( GLcontext *ctx );
-
-+extern void
-+_mesa_free_attrib_data( GLcontext *ctx );
-+
- #else
-
- /** No-op */
- #define _mesa_init_attrib( c ) ((void)0)
-+#define _mesa_free_attrib_data( c ) ((void)0)
-
- #endif
-
-diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
-index e067840..754b1a7 100644
---- a/src/mesa/main/context.c
-+++ b/src/mesa/main/context.c
-@@ -6,7 +6,7 @@
-
- /*
- * Mesa 3-D graphics library
-- * Version: 7.0
-+ * Version: 7.0.2
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
-@@ -467,17 +467,12 @@ alloc_shared_state( GLcontext *ctx )
- if (!ss->DefaultRect)
- goto cleanup;
-
-- /* Effectively bind the default textures to all texture units */
-- ss->Default1D->RefCount += MAX_TEXTURE_IMAGE_UNITS;
-- ss->Default2D->RefCount += MAX_TEXTURE_IMAGE_UNITS;
-- ss->Default3D->RefCount += MAX_TEXTURE_IMAGE_UNITS;
-- ss->DefaultCubeMap->RefCount += MAX_TEXTURE_IMAGE_UNITS;
-- ss->DefaultRect->RefCount += MAX_TEXTURE_IMAGE_UNITS;
-+ /* sanity check */
-+ assert(ss->Default1D->RefCount == 1);
-
- _glthread_INIT_MUTEX(ss->TexMutex);
- ss->TextureStateStamp = 0;
-
--
- #if FEATURE_EXT_framebuffer_object
- ss->FrameBuffers = _mesa_NewHashTable();
- if (!ss->FrameBuffers)
-@@ -487,10 +482,9 @@ alloc_shared_state( GLcontext *ctx )
- goto cleanup;
- #endif
-
--
- return GL_TRUE;
-
-- cleanup:
-+cleanup:
- /* Ran out of memory at some point. Free everything and return NULL */
- if (ss->DisplayList)
- _mesa_DeleteHashTable(ss->DisplayList);
-@@ -634,6 +628,33 @@ delete_shader_cb(GLuint id, void *data, void *userData)
- }
- }
-
-+/**
-+ * Callback for deleting a framebuffer object. Called by _mesa_HashDeleteAll()
-+ */
-+static void
-+delete_framebuffer_cb(GLuint id, void *data, void *userData)
-+{
-+ struct gl_framebuffer *fb = (struct gl_framebuffer *) data;
-+ /* The fact that the framebuffer is in the hashtable means its refcount
-+ * is one, but we're removing from the hashtable now. So clear refcount.
-+ */
-+ /*assert(fb->RefCount == 1);*/
-+ fb->RefCount = 0;
-+ fb->Delete(fb);
-+}
-+
-+/**
-+ * Callback for deleting a renderbuffer object. Called by _mesa_HashDeleteAll()
-+ */
-+static void
-+delete_renderbuffer_cb(GLuint id, void *data, void *userData)
-+{
-+ struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data;
-+ rb->RefCount = 0; /* see comment for FBOs above */
-+ rb->Delete(rb);
-+}
-+
-+
-
- /**
- * Deallocate a shared state object and all children structures.
-@@ -656,20 +677,6 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
- _mesa_HashDeleteAll(ss->DisplayList, delete_displaylist_cb, ctx);
- _mesa_DeleteHashTable(ss->DisplayList);
-
-- /*
-- * Free texture objects
-- */
-- ASSERT(ctx->Driver.DeleteTexture);
-- /* the default textures */
-- ctx->Driver.DeleteTexture(ctx, ss->Default1D);
-- ctx->Driver.DeleteTexture(ctx, ss->Default2D);
-- ctx->Driver.DeleteTexture(ctx, ss->Default3D);
-- ctx->Driver.DeleteTexture(ctx, ss->DefaultCubeMap);
-- ctx->Driver.DeleteTexture(ctx, ss->DefaultRect);
-- /* all other textures */
-- _mesa_HashDeleteAll(ss->TexObjects, delete_texture_cb, ctx);
-- _mesa_DeleteHashTable(ss->TexObjects);
--
- #if defined(FEATURE_NV_vertex_program) || defined(FEATURE_NV_fragment_program)
- _mesa_HashDeleteAll(ss->Programs, delete_program_cb, ctx);
- _mesa_DeleteHashTable(ss->Programs);
-@@ -701,10 +708,27 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
- #endif
-
- #if FEATURE_EXT_framebuffer_object
-+ _mesa_HashDeleteAll(ss->FrameBuffers, delete_framebuffer_cb, ctx);
- _mesa_DeleteHashTable(ss->FrameBuffers);
-+ _mesa_HashDeleteAll(ss->RenderBuffers, delete_renderbuffer_cb, ctx);
- _mesa_DeleteHashTable(ss->RenderBuffers);
- #endif
-
-+ /*
-+ * Free texture objects (after FBOs since some textures might have
-+ * been bound to FBOs).
-+ */
-+ ASSERT(ctx->Driver.DeleteTexture);
-+ /* the default textures */
-+ ctx->Driver.DeleteTexture(ctx, ss->Default1D);
-+ ctx->Driver.DeleteTexture(ctx, ss->Default2D);
-+ ctx->Driver.DeleteTexture(ctx, ss->Default3D);
-+ ctx->Driver.DeleteTexture(ctx, ss->DefaultCubeMap);
-+ ctx->Driver.DeleteTexture(ctx, ss->DefaultRect);
-+ /* all other textures */
-+ _mesa_HashDeleteAll(ss->TexObjects, delete_texture_cb, ctx);
-+ _mesa_DeleteHashTable(ss->TexObjects);
-+
- _glthread_DESTROY_MUTEX(ss->Mutex);
-
- _mesa_free(ss);
-@@ -1157,18 +1181,20 @@ _mesa_create_context(const GLvisual *visual,
- void
- _mesa_free_context_data( GLcontext *ctx )
- {
-- /* if we're destroying the current context, unbind it first */
-- if (ctx == _mesa_get_current_context()) {
-- _mesa_make_current(NULL, NULL, NULL);
-- }
-- else {
-- /* unreference WinSysDraw/Read buffers */
-- _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer);
-- _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer);
-- _mesa_unreference_framebuffer(&ctx->DrawBuffer);
-- _mesa_unreference_framebuffer(&ctx->ReadBuffer);
-+ if (!_mesa_get_current_context()){
-+ /* No current context, but we may need one in order to delete
-+ * texture objs, etc. So temporarily bind the context now.
-+ */
-+ _mesa_make_current(ctx, NULL, NULL);
- }
-
-+ /* unreference WinSysDraw/Read buffers */
-+ _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer);
-+ _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer);
-+ _mesa_unreference_framebuffer(&ctx->DrawBuffer);
-+ _mesa_unreference_framebuffer(&ctx->ReadBuffer);
-+
-+ _mesa_free_attrib_data(ctx);
- _mesa_free_lighting_data( ctx );
- _mesa_free_eval_data( ctx );
- _mesa_free_texture_data( ctx );
-@@ -1200,6 +1226,11 @@ _mesa_free_context_data( GLcontext *ctx )
-
- if (ctx->Extensions.String)
- _mesa_free((void *) ctx->Extensions.String);
-+
-+ /* unbind the context if it's currently bound */
-+ if (ctx == _mesa_get_current_context()) {
-+ _mesa_make_current(NULL, NULL, NULL);
-+ }
- }
-
-
-@@ -1431,8 +1462,6 @@ void
- _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
- GLframebuffer *readBuffer )
- {
-- GET_CURRENT_CONTEXT(oldCtx);
--
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(newCtx, "_mesa_make_current()\n");
-
-@@ -1457,13 +1486,6 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
- _glapi_set_context((void *) newCtx);
- ASSERT(_mesa_get_current_context() == newCtx);
-
-- if (oldCtx) {
-- _mesa_unreference_framebuffer(&oldCtx->WinSysDrawBuffer);
-- _mesa_unreference_framebuffer(&oldCtx->WinSysReadBuffer);
-- _mesa_unreference_framebuffer(&oldCtx->DrawBuffer);
-- _mesa_unreference_framebuffer(&oldCtx->ReadBuffer);
-- }
--
- if (!newCtx) {
- _glapi_set_dispatch(NULL); /* none current */
- }
-diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
-index 7813c7a..844db6b 100644
---- a/src/mesa/main/dlist.c
-+++ b/src/mesa/main/dlist.c
-@@ -1,6 +1,6 @@
- /*
- * Mesa 3-D graphics library
-- * Version: 7.0.1
-+ * Version: 7.0.2
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
-@@ -5737,7 +5737,7 @@ execute_list(GLcontext *ctx, GLuint list)
- if (!dlist)
- return;
-
-- ctx->ListState.CallStack[ctx->ListState.CallDepth++] = dlist;
-+ ctx->ListState.CallDepth++;
-
- if (ctx->Driver.BeginCallList)
- ctx->Driver.BeginCallList(ctx, dlist);
-@@ -6629,7 +6629,7 @@ execute_list(GLcontext *ctx, GLuint list)
- if (ctx->Driver.EndCallList)
- ctx->Driver.EndCallList(ctx);
-
-- ctx->ListState.CallStack[ctx->ListState.CallDepth--] = NULL;
-+ ctx->ListState.CallDepth--;
- }
-
-
-diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
-index 0e14345..1c6167b 100644
---- a/src/mesa/main/enable.c
-+++ b/src/mesa/main/enable.c
-@@ -364,6 +364,10 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
- case GL_LIGHTING:
- if (ctx->Light.Enabled == state)
- return;
-+ if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
-+ ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
-+ else
-+ ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
- FLUSH_VERTICES(ctx, _NEW_LIGHT);
- ctx->Light.Enabled = state;
- break;
-@@ -372,12 +376,14 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
- return;
- FLUSH_VERTICES(ctx, _NEW_LINE);
- ctx->Line.SmoothFlag = state;
-+ ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
- break;
- case GL_LINE_STIPPLE:
- if (ctx->Line.StippleFlag == state)
- return;
- FLUSH_VERTICES(ctx, _NEW_LINE);
- ctx->Line.StippleFlag = state;
-+ ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
- break;
- case GL_INDEX_LOGIC_OP:
- if (ctx->Color.IndexLogicOpEnabled == state)
-@@ -516,18 +522,21 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
- return;
- FLUSH_VERTICES(ctx, _NEW_POINT);
- ctx->Point.SmoothFlag = state;
-+ ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
- break;
- case GL_POLYGON_SMOOTH:
- if (ctx->Polygon.SmoothFlag == state)
- return;
- FLUSH_VERTICES(ctx, _NEW_POLYGON);
- ctx->Polygon.SmoothFlag = state;
-+ ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
- break;
- case GL_POLYGON_STIPPLE:
- if (ctx->Polygon.StippleFlag == state)
- return;
- FLUSH_VERTICES(ctx, _NEW_POLYGON);
- ctx->Polygon.StippleFlag = state;
-+ ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
- break;
- case GL_POLYGON_OFFSET_POINT:
- if (ctx->Polygon.OffsetPoint == state)
-@@ -877,6 +886,10 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
- return;
- FLUSH_VERTICES(ctx, _NEW_STENCIL);
- ctx->Stencil.TestTwoSide = state;
-+ if (state)
-+ ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;
-+ else
-+ ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL;
- break;
-
- #if FEATURE_ARB_fragment_program
-diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
-index eac2f78..8e7d66c 100644
---- a/src/mesa/main/fbobject.c
-+++ b/src/mesa/main/fbobject.c
-@@ -150,22 +150,18 @@ _mesa_remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att)
- {
- if (att->Type == GL_TEXTURE) {
- ASSERT(att->Texture);
-- att->Texture->RefCount--;
-- if (att->Texture->RefCount == 0) {
-- ctx->Driver.DeleteTexture(ctx, att->Texture);
-+ if (ctx->Driver.FinishRenderTexture) {
-+ /* tell driver we're done rendering to this texobj */
-+ ctx->Driver.FinishRenderTexture(ctx, att);
- }
-- else {
-- /* tell driver that we're done rendering to this texture. */
-- if (ctx->Driver.FinishRenderTexture) {
-- ctx->Driver.FinishRenderTexture(ctx, att);
-- }
-- }
-- att->Texture = NULL;
-+ _mesa_reference_texobj(&att->Texture, NULL); /* unbind */
-+ ASSERT(!att->Texture);
- }
- if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) {
- ASSERT(att->Renderbuffer);
- ASSERT(!att->Texture);
-- _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
-+ _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); /* unbind */
-+ ASSERT(!att->Renderbuffer);
- }
- att->Type = GL_NONE;
- att->Complete = GL_TRUE;
-@@ -191,8 +187,8 @@ _mesa_set_texture_attachment(GLcontext *ctx,
- /* new attachment */
- _mesa_remove_attachment(ctx, att);
- att->Type = GL_TEXTURE;
-- att->Texture = texObj;
-- texObj->RefCount++;
-+ assert(!att->Texture);
-+ _mesa_reference_texobj(&att->Texture, texObj);
- }
-
- /* always update these fields */
-@@ -983,6 +979,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
- return;
- }
- _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb);
-+ ASSERT(newFb->RefCount == 1);
- }
- }
- else {
-@@ -1006,8 +1003,10 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
- if (bindDrawBuf) {
- /* check if old FB had any texture attachments */
- check_end_texture_render(ctx, ctx->DrawBuffer);
-- /* check if time to delete this framebuffer */
-+
-+ /* bind new drawing buffer */
- _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb);
-+
- if (newFb->Name != 0) {
- /* check if newly bound framebuffer has any texture attachments */
- check_begin_texture_render(ctx, newFb);
-diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
-index 1fd31a5..8aeb369 100644
---- a/src/mesa/main/framebuffer.c
-+++ b/src/mesa/main/framebuffer.c
-@@ -38,6 +38,7 @@
- #include "fbobject.h"
- #include "framebuffer.h"
- #include "renderbuffer.h"
-+#include "texobj.h"
-
-
-
-@@ -190,17 +191,11 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb)
- _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
- }
- if (att->Texture) {
-- /* render to texture */
-- att->Texture->RefCount--;
-- if (att->Texture->RefCount == 0) {
-- GET_CURRENT_CONTEXT(ctx);
-- if (ctx) {
-- ctx->Driver.DeleteTexture(ctx, att->Texture);
-- }
-- }
-+ _mesa_reference_texobj(&att->Texture, NULL);
- }
-+ ASSERT(!att->Renderbuffer);
-+ ASSERT(!att->Texture);
- att->Type = GL_NONE;
-- att->Texture = NULL;
- }
-
- /* unbind _Depth/_StencilBuffer to decr ref counts */
-diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h
-index fd41275..2d2da49 100644
---- a/src/mesa/main/glheader.h
-+++ b/src/mesa/main/glheader.h
-@@ -237,7 +237,7 @@
- #endif
-
-
--#if !defined __GNUC__ || __GNUC__ < 3
-+#if (!defined(__GNUC__) || __GNUC__ < 3) && !defined(__IBMC__)
- # define __builtin_expect(x, y) x
- #endif
-
-diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
-index 803f478..d7a96f7 100644
---- a/src/mesa/main/image.c
-+++ b/src/mesa/main/image.c
-@@ -3794,7 +3794,7 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
- GLint *dst = (GLint *) dest;
- GLuint i;
- for (i=0;i<n;i++) {
-- *dst++ = (GLint) source[i];
-+ dst[i] = (GLint) source[i];
- }
- if (dstPacking->SwapBytes) {
- _mesa_swap4( (GLuint *) dst, n );
-diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
-index 6e05761..6dd334e 100644
---- a/src/mesa/main/light.c
-+++ b/src/mesa/main/light.c
-@@ -53,6 +53,11 @@ _mesa_ShadeModel( GLenum mode )
-
- FLUSH_VERTICES(ctx, _NEW_LIGHT);
- ctx->Light.ShadeModel = mode;
-+ if (mode == GL_FLAT)
-+ ctx->_TriangleCaps |= DD_FLATSHADE;
-+ else
-+ ctx->_TriangleCaps &= ~DD_FLATSHADE;
-+
- if (ctx->Driver.ShadeModel)
- ctx->Driver.ShadeModel( ctx, mode );
- }
-@@ -441,6 +446,10 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params )
- return;
- FLUSH_VERTICES(ctx, _NEW_LIGHT);
- ctx->Light.Model.TwoSide = newbool;
-+ if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
-+ ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
-+ else
-+ ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
- break;
- case GL_LIGHT_MODEL_COLOR_CONTROL:
- if (params[0] == (GLfloat) GL_SINGLE_COLOR)
-diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c
-index dc7195d..b464c4f 100644
---- a/src/mesa/main/lines.c
-+++ b/src/mesa/main/lines.c
-@@ -59,6 +59,11 @@ _mesa_LineWidth( GLfloat width )
- ctx->Const.MinLineWidth,
- ctx->Const.MaxLineWidth);
-
-+ if (width != 1.0F)
-+ ctx->_TriangleCaps |= DD_LINE_WIDTH;
-+ else
-+ ctx->_TriangleCaps &= ~DD_LINE_WIDTH;
-+
- if (ctx->Driver.LineWidth)
- ctx->Driver.LineWidth(ctx, width);
- }
-diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
-index 71215d5..d00f2ef 100644
---- a/src/mesa/main/mtypes.h
-+++ b/src/mesa/main/mtypes.h
-@@ -1523,12 +1523,6 @@ struct gl_texture_unit
-
- struct gl_texture_object *_Current; /**< Points to really enabled tex obj */
-
-- struct gl_texture_object Saved1D; /**< only used by glPush/PopAttrib */
-- struct gl_texture_object Saved2D;
-- struct gl_texture_object Saved3D;
-- struct gl_texture_object SavedCubeMap;
-- struct gl_texture_object SavedRect;
--
- /* GL_SGI_texture_color_table */
- struct gl_color_table ColorTable;
- struct gl_color_table ProxyColorTable;
-@@ -2848,7 +2842,6 @@ struct mesa_display_list
- */
- struct gl_dlist_state
- {
-- struct mesa_display_list *CallStack[MAX_LIST_NESTING];
- GLuint CallDepth; /**< Current recursion calling depth */
-
- struct mesa_display_list *CurrentList;
-diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c
-index 408b68a..8825bb1 100644
---- a/src/mesa/main/points.c
-+++ b/src/mesa/main/points.c
-@@ -123,9 +123,15 @@ _mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params)
- return;
- FLUSH_VERTICES(ctx, _NEW_POINT);
- COPY_3V(ctx->Point.Params, params);
-+
- ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 ||
- ctx->Point.Params[1] != 0.0 ||
- ctx->Point.Params[2] != 0.0);
-+
-+ if (ctx->Point._Attenuated)
-+ ctx->_TriangleCaps |= DD_POINT_ATTEN;
-+ else
-+ ctx->_TriangleCaps &= ~DD_POINT_ATTEN;
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM,
-diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c
-index fd02e5a..564250b 100644
---- a/src/mesa/main/polygon.c
-+++ b/src/mesa/main/polygon.c
-@@ -167,6 +167,11 @@ _mesa_PolygonMode( GLenum face, GLenum mode )
- return;
- }
-
-+ if (ctx->Polygon.FrontMode == GL_FILL && ctx->Polygon.BackMode == GL_FILL)
-+ ctx->_TriangleCaps &= ~DD_TRI_UNFILLED;
-+ else
-+ ctx->_TriangleCaps |= DD_TRI_UNFILLED;
-+
- if (ctx->Driver.PolygonMode)
- ctx->Driver.PolygonMode(ctx, face, mode);
- }
-diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
-index 96ee512..767161f 100644
---- a/src/mesa/main/state.c
-+++ b/src/mesa/main/state.c
-@@ -821,6 +821,16 @@ _mesa_init_exec_table(struct _glapi_table *exec)
- /*@{*/
-
-
-+static void
-+update_separate_specular( GLcontext *ctx )
-+{
-+ if (NEED_SECONDARY_COLOR(ctx))
-+ ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
-+ else
-+ ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
-+}
-+
-+
- /**
- * Update state dependent on vertex arrays.
- */
-@@ -1045,6 +1055,26 @@ update_color(GLcontext *ctx)
- }
-
-
-+/*
-+ * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET
-+ * in ctx->_TriangleCaps if needed.
-+ */
-+static void
-+update_polygon( GLcontext *ctx )
-+{
-+ ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET);
-+
-+ if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
-+ ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
-+
-+ /* Any Polygon offsets enabled? */
-+ if (ctx->Polygon.OffsetPoint ||
-+ ctx->Polygon.OffsetLine ||
-+ ctx->Polygon.OffsetFill) {
-+ ctx->_TriangleCaps |= DD_TRI_OFFSET;
-+ }
-+}
-+
-
- /**
- * Update the ctx->_TriangleCaps bitfield.
-@@ -1052,6 +1082,7 @@ update_color(GLcontext *ctx)
- * This function must be called after other update_*() functions since
- * there are dependencies on some other derived values.
- */
-+#if 0
- static void
- update_tricaps(GLcontext *ctx, GLbitfield new_state)
- {
-@@ -1117,6 +1148,7 @@ update_tricaps(GLcontext *ctx, GLbitfield new_state)
- if (ctx->Stencil._TestTwoSide)
- ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;
- }
-+#endif
-
-
- /**
-@@ -1154,6 +1186,9 @@ _mesa_update_state_locked( GLcontext *ctx )
- if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
- _mesa_update_draw_buffer_bounds( ctx );
-
-+ if (new_state & _NEW_POLYGON)
-+ update_polygon( ctx );
-+
- if (new_state & _NEW_LIGHT)
- _mesa_update_lighting( ctx );
-
-@@ -1163,6 +1198,9 @@ _mesa_update_state_locked( GLcontext *ctx )
- if (new_state & _IMAGE_NEW_TRANSFER_STATE)
- _mesa_update_pixel( ctx, new_state );
-
-+ if (new_state & _DD_NEW_SEPARATE_SPECULAR)
-+ update_separate_specular( ctx );
-+
- if (new_state & (_NEW_ARRAY | _NEW_PROGRAM))
- update_arrays( ctx );
-
-@@ -1172,9 +1210,11 @@ _mesa_update_state_locked( GLcontext *ctx )
- if (new_state & _NEW_COLOR)
- update_color( ctx );
-
-+#if 0
- if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT
- | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR))
- update_tricaps( ctx, new_state );
-+#endif
-
- if (ctx->FragmentProgram._MaintainTexEnvProgram) {
- if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG))
-diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
-index 1a46c10..a6904f4 100644
---- a/src/mesa/main/texenvprogram.c
-+++ b/src/mesa/main/texenvprogram.c
-@@ -38,7 +38,7 @@
- * According to Glean's texCombine test, no more than 21 instructions
- * are needed. Allow a few extra just in case.
- */
--#define MAX_INSTRUCTIONS 24
-+#define MAX_INSTRUCTIONS ((MAX_TEXTURE_UNITS * 6) + 10) /* see bug 9829 */
-
- #define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM)
-
-diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
-index 56d816e..7b36154 100644
---- a/src/mesa/main/texobj.c
-+++ b/src/mesa/main/texobj.c
-@@ -156,6 +156,11 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
-
- (void) ctx;
-
-+ /* Set Target to an invalid value. With some assertions elsewhere
-+ * we can try to detect possible use of deleted textures.
-+ */
-+ texObj->Target = 0x99;
-+
- _mesa_free_colortable_data(&texObj->Palette);
-
- /* free the texture images */
-@@ -188,6 +193,7 @@ void
- _mesa_copy_texture_object( struct gl_texture_object *dest,
- const struct gl_texture_object *src )
- {
-+ dest->Target = src->Target;
- dest->Name = src->Name;
- dest->Priority = src->Priority;
- dest->BorderColor[0] = src->BorderColor[0];
-@@ -220,6 +226,92 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
-
-
- /**
-+ * Check if the given texture object is valid by examining its Target field.
-+ * For debugging only.
-+ */
-+static GLboolean
-+valid_texture_object(const struct gl_texture_object *tex)
-+{
-+ switch (tex->Target) {
-+ case 0:
-+ case GL_TEXTURE_1D:
-+ case GL_TEXTURE_2D:
-+ case GL_TEXTURE_3D:
-+ case GL_TEXTURE_CUBE_MAP_ARB:
-+ case GL_TEXTURE_RECTANGLE_NV:
-+ return GL_TRUE;
-+ case 0x99:
-+ _mesa_problem(NULL, "invalid reference to a deleted texture object");
-+ return GL_FALSE;
-+ default:
-+ _mesa_problem(NULL, "invalid texture object Target value");
-+ return GL_FALSE;
-+ }
-+}
-+
-+
-+/**
-+ * Reference (or unreference) a texture object.
-+ * If '*ptr', decrement *ptr's refcount (and delete if it becomes zero).
-+ * If 'tex' is non-null, increment its refcount.
-+ */
-+void
-+_mesa_reference_texobj(struct gl_texture_object **ptr,
-+ struct gl_texture_object *tex)
-+{
-+ assert(ptr);
-+ if (*ptr == tex) {
-+ /* no change */
-+ return;
-+ }
-+
-+ if (*ptr) {
-+ /* Unreference the old texture */
-+ GLboolean deleteFlag = GL_FALSE;
-+ struct gl_texture_object *oldTex = *ptr;
-+
-+ assert(valid_texture_object(oldTex));
-+
-+ _glthread_LOCK_MUTEX(oldTex->Mutex);
-+ ASSERT(oldTex->RefCount > 0);
-+ oldTex->RefCount--;
-+
-+ deleteFlag = (oldTex->RefCount == 0);
-+ _glthread_UNLOCK_MUTEX(oldTex->Mutex);
-+
-+ if (deleteFlag) {
-+ GET_CURRENT_CONTEXT(ctx);
-+ if (ctx)
-+ ctx->Driver.DeleteTexture(ctx, oldTex);
-+ else
-+ _mesa_problem(NULL, "Unable to delete texture, no context");
-+ }
-+
-+ *ptr = NULL;
-+ }
-+ assert(!*ptr);
-+
-+ if (tex) {
-+ /* reference new texture */
-+ assert(valid_texture_object(tex));
-+ _glthread_LOCK_MUTEX(tex->Mutex);
-+ if (tex->RefCount == 0) {
-+ /* this texture's being deleted (look just above) */
-+ /* Not sure this can every really happen. Warn if it does. */
-+ _mesa_problem(NULL, "referencing deleted texture object");
-+ *ptr = NULL;
-+ }
-+ else {
-+ tex->RefCount++;
-+ *ptr = tex;
-+ }
-+ _glthread_UNLOCK_MUTEX(tex->Mutex);
-+ }
-+}
-+
-+
-+
-+/**
- * Report why a texture object is incomplete.
- *
- * \param t texture object.
-@@ -620,8 +712,7 @@ unbind_texobj_from_fbo(GLcontext *ctx, struct gl_texture_object *texObj)
-
- /**
- * Check if the given texture object is bound to any texture image units and
-- * unbind it if so.
-- * XXX all RefCount accesses should be protected by a mutex.
-+ * unbind it if so (revert to default textures).
- */
- static void
- unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj)
-@@ -630,34 +721,20 @@ unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj)
-
- for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) {
- struct gl_texture_unit *unit = &ctx->Texture.Unit[u];
-- struct gl_texture_object **curr = NULL;
--
- if (texObj == unit->Current1D) {
-- curr = &unit->Current1D;
-- unit->Current1D = ctx->Shared->Default1D;
-+ _mesa_reference_texobj(&unit->Current1D, ctx->Shared->Default1D);
- }
- else if (texObj == unit->Current2D) {
-- curr = &unit->Current2D;
-- unit->Current2D = ctx->Shared->Default2D;
-+ _mesa_reference_texobj(&unit->Current2D, ctx->Shared->Default2D);
- }
- else if (texObj == unit->Current3D) {
-- curr = &unit->Current3D;
-- unit->Current3D = ctx->Shared->Default3D;
-+ _mesa_reference_texobj(&unit->Current3D, ctx->Shared->Default3D);
- }
- else if (texObj == unit->CurrentCubeMap) {
-- curr = &unit->CurrentCubeMap;
-- unit->CurrentCubeMap = ctx->Shared->DefaultCubeMap;
-+ _mesa_reference_texobj(&unit->CurrentCubeMap, ctx->Shared->DefaultCubeMap);
- }
- else if (texObj == unit->CurrentRect) {
-- curr = &unit->CurrentRect;
-- unit->CurrentRect = ctx->Shared->DefaultRect;
-- }
--
-- if (curr) {
-- (*curr)->RefCount++;
-- texObj->RefCount--;
-- if (texObj == unit->_Current)
-- unit->_Current = *curr;
-+ _mesa_reference_texobj(&unit->CurrentRect, ctx->Shared->DefaultRect);
- }
- }
- }
-@@ -693,8 +770,6 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
- = _mesa_lookup_texture(ctx, textures[i]);
-
- if (delObj) {
-- GLboolean deleted;
--
- _mesa_lock_texture(ctx, delObj);
-
- /* Check if texture is bound to any framebuffer objects.
-@@ -704,10 +779,12 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
- unbind_texobj_from_fbo(ctx, delObj);
-
- /* Check if this texture is currently bound to any texture units.
-- * If so, unbind it and decrement the reference count.
-+ * If so, unbind it.
- */
- unbind_texobj_from_texunits(ctx, delObj);
-
-+ _mesa_unlock_texture(ctx, delObj);
-+
- ctx->NewState |= _NEW_TEXTURE;
-
- /* The texture _name_ is now free for re-use.
-@@ -717,23 +794,10 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
- _mesa_HashRemove(ctx->Shared->TexObjects, delObj->Name);
- _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
-
-- /* The actual texture object will not be freed until it's no
-- * longer bound in any context.
-- * XXX all RefCount accesses should be protected by a mutex.
-+ /* Unreference the texobj. If refcount hits zero, the texture
-+ * will be deleted.
- */
-- delObj->RefCount--;
-- deleted = (delObj->RefCount == 0);
-- _mesa_unlock_texture(ctx, delObj);
--
-- /* We know that refcount went to zero above, so this is
-- * the only pointer left to delObj, so we don't have to
-- * worry about locking any more:
-- */
-- if (deleted) {
-- ASSERT(delObj->Name != 0); /* Never delete default tex objs */
-- ASSERT(ctx->Driver.DeleteTexture);
-- (*ctx->Driver.DeleteTexture)(ctx, delObj);
-- }
-+ _mesa_reference_texobj(&delObj, NULL);
- }
- }
- }
-@@ -761,7 +825,6 @@ _mesa_BindTexture( GLenum target, GLuint texName )
- GET_CURRENT_CONTEXT(ctx);
- const GLuint unit = ctx->Texture.CurrentUnit;
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-- struct gl_texture_object *oldTexObj;
- struct gl_texture_object *newTexObj = NULL;
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
-@@ -770,48 +833,6 @@ _mesa_BindTexture( GLenum target, GLuint texName )
- _mesa_lookup_enum_by_nr(target), (GLint) texName);
-
- /*
-- * Get pointer to currently bound texture object (oldTexObj)
-- */
-- switch (target) {
-- case GL_TEXTURE_1D:
-- oldTexObj = texUnit->Current1D;
-- break;
-- case GL_TEXTURE_2D:
-- oldTexObj = texUnit->Current2D;
-- break;
-- case GL_TEXTURE_3D:
-- oldTexObj = texUnit->Current3D;
-- break;
-- case GL_TEXTURE_CUBE_MAP_ARB:
-- if (!ctx->Extensions.ARB_texture_cube_map) {
-- _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
-- return;
-- }
-- oldTexObj = texUnit->CurrentCubeMap;
-- break;
-- case GL_TEXTURE_RECTANGLE_NV:
-- if (!ctx->Extensions.NV_texture_rectangle) {
-- _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
-- return;
-- }
-- oldTexObj = texUnit->CurrentRect;
-- break;
-- default:
-- _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
-- return;
-- }
--
-- if (oldTexObj->Name == texName) {
-- /* XXX this might be wrong. If the texobj is in use by another
-- * context and a texobj parameter was changed, this might be our
-- * only chance to update this context's hardware state.
-- * Note that some applications re-bind the same texture a lot so we
-- * want to handle that case quickly.
-- */
-- return; /* rebinding the same texture- no change */
-- }
--
-- /*
- * Get pointer to new texture object (newTexObj)
- */
- if (texName == 0) {
-@@ -879,28 +900,30 @@ _mesa_BindTexture( GLenum target, GLuint texName )
- newTexObj->Target = target;
- }
-
-- /* XXX all RefCount accesses should be protected by a mutex. */
-- newTexObj->RefCount++;
-+ assert(valid_texture_object(newTexObj));
-
-- /* do the actual binding, but first flush outstanding vertices:
-- */
-+ /* flush before changing binding */
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
-
-+ /* Do the actual binding. The refcount on the previously bound
-+ * texture object will be decremented. It'll be deleted if the
-+ * count hits zero.
-+ */
- switch (target) {
- case GL_TEXTURE_1D:
-- texUnit->Current1D = newTexObj;
-+ _mesa_reference_texobj(&texUnit->Current1D, newTexObj);
- break;
- case GL_TEXTURE_2D:
-- texUnit->Current2D = newTexObj;
-+ _mesa_reference_texobj(&texUnit->Current2D, newTexObj);
- break;
- case GL_TEXTURE_3D:
-- texUnit->Current3D = newTexObj;
-+ _mesa_reference_texobj(&texUnit->Current3D, newTexObj);
- break;
- case GL_TEXTURE_CUBE_MAP_ARB:
-- texUnit->CurrentCubeMap = newTexObj;
-+ _mesa_reference_texobj(&texUnit->CurrentCubeMap, newTexObj);
- break;
- case GL_TEXTURE_RECTANGLE_NV:
-- texUnit->CurrentRect = newTexObj;
-+ _mesa_reference_texobj(&texUnit->CurrentRect, newTexObj);
- break;
- default:
- _mesa_problem(ctx, "bad target in BindTexture");
-@@ -910,18 +933,6 @@ _mesa_BindTexture( GLenum target, GLuint texName )
- /* Pass BindTexture call to device driver */
- if (ctx->Driver.BindTexture)
- (*ctx->Driver.BindTexture)( ctx, target, newTexObj );
--
-- /* Decrement the reference count on the old texture and check if it's
-- * time to delete it.
-- */
-- /* XXX all RefCount accesses should be protected by a mutex. */
-- oldTexObj->RefCount--;
-- ASSERT(oldTexObj->RefCount >= 0);
-- if (oldTexObj->RefCount == 0) {
-- ASSERT(oldTexObj->Name != 0);
-- ASSERT(ctx->Driver.DeleteTexture);
-- (*ctx->Driver.DeleteTexture)( ctx, oldTexObj );
-- }
- }
-
-
-diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
-index ec7cf8c..9577e5e 100644
---- a/src/mesa/main/texobj.h
-+++ b/src/mesa/main/texobj.h
-@@ -58,6 +58,10 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
- const struct gl_texture_object *src );
-
- extern void
-+_mesa_reference_texobj(struct gl_texture_object **ptr,
-+ struct gl_texture_object *tex);
-+
-+extern void
- _mesa_test_texobj_completeness( const GLcontext *ctx,
- struct gl_texture_object *obj );
-
-diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
-index 1b45eae..a5966e7 100644
---- a/src/mesa/main/texstate.c
-+++ b/src/mesa/main/texstate.c
-@@ -63,31 +63,6 @@ static const struct gl_tex_env_combine_state default_combine_state = {
- };
-
-
--/**
-- * Copy a texture binding. Helper used by _mesa_copy_texture_state().
-- */
--static void
--copy_texture_binding(const GLcontext *ctx,
-- struct gl_texture_object **dst,
-- struct gl_texture_object *src)
--{
-- /* only copy if names differ (per OpenGL SI) */
-- if ((*dst)->Name != src->Name) {
-- /* unbind/delete dest binding which we're changing */
-- (*dst)->RefCount--;
-- if ((*dst)->RefCount == 0) {
-- /* time to delete this texture object */
-- ASSERT((*dst)->Name != 0);
-- ASSERT(ctx->Driver.DeleteTexture);
-- /* XXX cast-away const, unfortunately */
-- (*ctx->Driver.DeleteTexture)((GLcontext *) ctx, *dst);
-- }
-- /* make new binding, incrementing ref count */
-- *dst = src;
-- src->RefCount++;
-- }
--}
--
-
- /**
- * Used by glXCopyContext to copy texture state from one context to another.
-@@ -144,16 +119,16 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst )
- /* copy texture object bindings, not contents of texture objects */
- _mesa_lock_context_textures(dst);
-
-- copy_texture_binding(src, &dst->Texture.Unit[i].Current1D,
-- src->Texture.Unit[i].Current1D);
-- copy_texture_binding(src, &dst->Texture.Unit[i].Current2D,
-- src->Texture.Unit[i].Current2D);
-- copy_texture_binding(src, &dst->Texture.Unit[i].Current3D,
-- src->Texture.Unit[i].Current3D);
-- copy_texture_binding(src, &dst->Texture.Unit[i].CurrentCubeMap,
-- src->Texture.Unit[i].CurrentCubeMap);
-- copy_texture_binding(src, &dst->Texture.Unit[i].CurrentRect,
-- src->Texture.Unit[i].CurrentRect);
-+ _mesa_reference_texobj(&dst->Texture.Unit[i].Current1D,
-+ src->Texture.Unit[i].Current1D);
-+ _mesa_reference_texobj(&dst->Texture.Unit[i].Current2D,
-+ src->Texture.Unit[i].Current2D);
-+ _mesa_reference_texobj(&dst->Texture.Unit[i].Current3D,
-+ src->Texture.Unit[i].Current3D);
-+ _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentCubeMap,
-+ src->Texture.Unit[i].CurrentCubeMap);
-+ _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentRect,
-+ src->Texture.Unit[i].CurrentRect);
-
- _mesa_unlock_context_textures(dst);
- }
-@@ -3032,6 +3007,8 @@ alloc_proxy_textures( GLcontext *ctx )
- if (!ctx->Texture.ProxyRect)
- goto cleanup;
-
-+ assert(ctx->Texture.Proxy1D->RefCount == 1);
-+
- return GL_TRUE;
-
- cleanup:
-@@ -3087,11 +3064,12 @@ init_texture_unit( GLcontext *ctx, GLuint unit )
- ASSIGN_4V( texUnit->EyePlaneR, 0.0, 0.0, 0.0, 0.0 );
- ASSIGN_4V( texUnit->EyePlaneQ, 0.0, 0.0, 0.0, 0.0 );
-
-- texUnit->Current1D = ctx->Shared->Default1D;
-- texUnit->Current2D = ctx->Shared->Default2D;
-- texUnit->Current3D = ctx->Shared->Default3D;
-- texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap;
-- texUnit->CurrentRect = ctx->Shared->DefaultRect;
-+ /* initialize current texture object ptrs to the shared default objects */
-+ _mesa_reference_texobj(&texUnit->Current1D, ctx->Shared->Default1D);
-+ _mesa_reference_texobj(&texUnit->Current2D, ctx->Shared->Default2D);
-+ _mesa_reference_texobj(&texUnit->Current3D, ctx->Shared->Default3D);
-+ _mesa_reference_texobj(&texUnit->CurrentCubeMap, ctx->Shared->DefaultCubeMap);
-+ _mesa_reference_texobj(&texUnit->CurrentRect, ctx->Shared->DefaultRect);
- }
-
-
-@@ -3106,21 +3084,20 @@ _mesa_init_texture(GLcontext *ctx)
- assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS);
- assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS);
-
-- /* Effectively bind the default textures to all texture units */
-- ctx->Shared->Default1D->RefCount += MAX_TEXTURE_UNITS;
-- ctx->Shared->Default2D->RefCount += MAX_TEXTURE_UNITS;
-- ctx->Shared->Default3D->RefCount += MAX_TEXTURE_UNITS;
-- ctx->Shared->DefaultCubeMap->RefCount += MAX_TEXTURE_UNITS;
-- ctx->Shared->DefaultRect->RefCount += MAX_TEXTURE_UNITS;
--
- /* Texture group */
- ctx->Texture.CurrentUnit = 0; /* multitexture */
- ctx->Texture._EnabledUnits = 0;
-- for (i=0; i<MAX_TEXTURE_UNITS; i++)
-- init_texture_unit( ctx, i );
- ctx->Texture.SharedPalette = GL_FALSE;
- _mesa_init_colortable(&ctx->Texture.Palette);
-
-+ for (i = 0; i < MAX_TEXTURE_UNITS; i++)
-+ init_texture_unit( ctx, i );
-+
-+ /* After we're done initializing the context's texture state the default
-+ * texture objects' refcounts should be at least MAX_TEXTURE_UNITS + 1.
-+ */
-+ assert(ctx->Shared->Default1D->RefCount >= MAX_TEXTURE_UNITS + 1);
-+
- _mesa_TexEnvProgramCacheInit( ctx );
-
- /* Allocate proxy textures */
-@@ -3132,12 +3109,22 @@ _mesa_init_texture(GLcontext *ctx)
-
-
- /**
-- * Free dynamically-allocted texture data attached to the given context.
-+ * Free dynamically-allocated texture data attached to the given context.
- */
- void
- _mesa_free_texture_data(GLcontext *ctx)
- {
-- GLuint i;
-+ GLuint u;
-+
-+ /* unreference current textures */
-+ for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) {
-+ struct gl_texture_unit *unit = ctx->Texture.Unit + u;
-+ _mesa_reference_texobj(&unit->Current1D, NULL);
-+ _mesa_reference_texobj(&unit->Current2D, NULL);
-+ _mesa_reference_texobj(&unit->Current3D, NULL);
-+ _mesa_reference_texobj(&unit->CurrentCubeMap, NULL);
-+ _mesa_reference_texobj(&unit->CurrentRect, NULL);
-+ }
-
- /* Free proxy texture objects */
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1D );
-@@ -3146,8 +3133,8 @@ _mesa_free_texture_data(GLcontext *ctx)
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyCubeMap );
- (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyRect );
-
-- for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
-- _mesa_free_colortable_data( &ctx->Texture.Unit[i].ColorTable );
-+ for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++)
-+ _mesa_free_colortable_data( &ctx->Texture.Unit[u].ColorTable );
-
- _mesa_TexEnvProgramCacheDestroy( ctx );
- }
-diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h
-index 2c84579..2d3c68b 100644
---- a/src/mesa/main/version.h
-+++ b/src/mesa/main/version.h
-@@ -1,6 +1,6 @@
- /*
- * Mesa 3-D graphics library
-- * Version: 7.0.1
-+ * Version: 7.0.2
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
-@@ -30,8 +30,8 @@
- /* Mesa version */
- #define MESA_MAJOR 7
- #define MESA_MINOR 0
--#define MESA_PATCH 1
--#define MESA_VERSION_STRING "7.0.1"
-+#define MESA_PATCH 2
-+#define MESA_VERSION_STRING "7.0.2"
-
- /* To make version comparison easy */
- #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
-index 5027264..6a87a17 100644
---- a/src/mesa/shader/arbprogparse.c
-+++ b/src/mesa/shader/arbprogparse.c
-@@ -624,6 +624,41 @@ program_error(GLcontext *ctx, GLint position, const char *descrip)
- }
-
-
-+/**
-+ * As above, but with an extra string parameter for more info.
-+ */
-+static void
-+program_error2(GLcontext *ctx, GLint position, const char *descrip,
-+ const char *var)
-+{
-+ if (descrip) {
-+ const char *prefix = "glProgramString(", *suffix = ")";
-+ char *str = (char *) _mesa_malloc(_mesa_strlen(descrip) +
-+ _mesa_strlen(": ") +
-+ _mesa_strlen(var) +
-+ _mesa_strlen(prefix) +
-+ _mesa_strlen(suffix) + 1);
-+ if (str) {
-+ _mesa_sprintf(str, "%s%s: %s%s", prefix, descrip, var, suffix);
-+ _mesa_error(ctx, GL_INVALID_OPERATION, str);
-+ _mesa_free(str);
-+ }
-+ }
-+ {
-+ char *str = (char *) _mesa_malloc(_mesa_strlen(descrip) +
-+ _mesa_strlen(": ") +
-+ _mesa_strlen(var) + 1);
-+ if (str) {
-+ _mesa_sprintf(str, "%s: %s", descrip, var);
-+ }
-+ _mesa_set_program_error(ctx, position, str);
-+ if (str) {
-+ _mesa_free(str);
-+ }
-+ }
-+}
-+
-+
-
- /**
- * constructs an integer from 4 GLubytes in LE format
-@@ -1217,10 +1252,10 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
- state_tokens[1] = coord;
-
- /* EYE or OBJECT */
-- type = *(*inst++);
-+ type = *(*inst)++;
-
- /* 0 - s, 1 - t, 2 - r, 3 - q */
-- coord = *(*inst++);
-+ coord = *(*inst)++;
-
- if (type == TEX_GEN_EYE) {
- switch (coord) {
-@@ -1236,6 +1271,9 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
- case COMPONENT_W:
- state_tokens[2] = STATE_TEXGEN_EYE_Q;
- break;
-+ default:
-+ _mesa_problem(ctx, "bad texgen component in "
-+ "parse_state_single_item()");
- }
- }
- else {
-@@ -1252,6 +1290,9 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
- case COMPONENT_W:
- state_tokens[2] = STATE_TEXGEN_OBJECT_Q;
- break;
-+ default:
-+ _mesa_problem(ctx, "bad texgen component in "
-+ "parse_state_single_item()");
- }
- }
- }
-@@ -1274,7 +1315,7 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst,
- break;
-
- case STATE_POINT:
-- switch (*(*inst++)) {
-+ switch (*(*inst)++) {
- case POINT_SIZE:
- state_tokens[0] = STATE_POINT_SIZE;
- break;
-@@ -1678,18 +1719,14 @@ parse_attrib (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head
- struct arb_program *Program)
- {
- GLuint found;
-- char *error_msg;
- struct var_cache *attrib_var;
-
- attrib_var = parse_string (inst, vc_head, Program, &found);
- Program->Position = parse_position (inst);
- if (found) {
-- error_msg = (char *)
-- _mesa_malloc (_mesa_strlen ((char *) attrib_var->name) + 40);
-- _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s",
-- attrib_var->name);
-- program_error(ctx, Program->Position, error_msg);
-- _mesa_free (error_msg);
-+ program_error2(ctx, Program->Position,
-+ "Duplicate variable declaration",
-+ (char *) attrib_var->name);
- return 1;
- }
-
-@@ -1867,12 +1904,9 @@ parse_param (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head,
- Program->Position = parse_position (inst);
-
- if (found) {
-- char *error_msg = (char *)
-- _mesa_malloc (_mesa_strlen ((char *) param_var->name) + 40);
-- _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s",
-- param_var->name);
-- program_error (ctx, Program->Position, error_msg);
-- _mesa_free (error_msg);
-+ program_error2(ctx, Program->Position,
-+ "Duplicate variable declaration",
-+ (char *) param_var->name);
- return 1;
- }
-
-@@ -1967,12 +2001,9 @@ parse_temp (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head,
- temp_var = parse_string (inst, vc_head, Program, &found);
- Program->Position = parse_position (inst);
- if (found) {
-- char *error_msg = (char *)
-- _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40);
-- _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s",
-- temp_var->name);
-- program_error(ctx, Program->Position, error_msg);
-- _mesa_free (error_msg);
-+ program_error2(ctx, Program->Position,
-+ "Duplicate variable declaration",
-+ (char *) temp_var->name);
- return 1;
- }
-
-@@ -2013,12 +2044,9 @@ parse_output (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head
- output_var = parse_string (inst, vc_head, Program, &found);
- Program->Position = parse_position (inst);
- if (found) {
-- char *error_msg = (char *)
-- _mesa_malloc (_mesa_strlen ((char *) output_var->name) + 40);
-- _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s",
-- output_var->name);
-- program_error (ctx, Program->Position, error_msg);
-- _mesa_free (error_msg);
-+ program_error2(ctx, Program->Position,
-+ "Duplicate variable declaration",
-+ (char *) output_var->name);
- return 1;
- }
-
-@@ -2044,12 +2072,9 @@ parse_alias (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head,
- Program->Position = parse_position (inst);
-
- if (found) {
-- char *error_msg = (char *)
-- _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40);
-- _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s",
-- temp_var->name);
-- program_error(ctx, Program->Position, error_msg);
-- _mesa_free (error_msg);
-+ program_error2(ctx, Program->Position,
-+ "Duplicate variable declaration",
-+ (char *) temp_var->name);
- return 1;
- }
-
-@@ -2059,12 +2084,9 @@ parse_alias (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head,
-
- if (!found)
- {
-- char *error_msg = (char *)
-- _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40);
-- _mesa_sprintf (error_msg, "Alias value %s is not defined",
-- temp_var->alias_binding->name);
-- program_error (ctx, Program->Position, error_msg);
-- _mesa_free (error_msg);
-+ program_error2(ctx, Program->Position,
-+ "Undefined alias value",
-+ (char *) temp_var->alias_binding->name);
- return 1;
- }
-
-@@ -2087,12 +2109,9 @@ parse_address (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_hea
- temp_var = parse_string (inst, vc_head, Program, &found);
- Program->Position = parse_position (inst);
- if (found) {
-- char *error_msg = (char *)
-- _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40);
-- _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s",
-- temp_var->name);
-- program_error (ctx, Program->Position, error_msg);
-- _mesa_free (error_msg);
-+ program_error2(ctx, Program->Position,
-+ "Duplicate variable declaration",
-+ (char *) temp_var->name);
- return 1;
- }
-
-@@ -2445,8 +2464,9 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst,
- Program->Position = parse_position (inst);
-
- if (!found) {
-- program_error(ctx, Program->Position,
-- "2: Undefined variable"); /* src->name */
-+ program_error2(ctx, Program->Position,
-+ "Undefined variable",
-+ (char *) src->name);
- return 1;
- }
-
-diff --git a/src/mesa/shader/atifragshader.c b/src/mesa/shader/atifragshader.c
-index 4727c1a..854c911 100644
---- a/src/mesa/shader/atifragshader.c
-+++ b/src/mesa/shader/atifragshader.c
-@@ -440,7 +440,7 @@ _mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle)
- _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(coord)");
- return;
- }
-- if ((swizzle < GL_SWIZZLE_STR_ATI) && (swizzle > GL_SWIZZLE_STQ_DQ_ATI)) {
-+ if (!(swizzle >= GL_SWIZZLE_STR_ATI) && (swizzle <= GL_SWIZZLE_STQ_DQ_ATI)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(swizzle)");
- return;
- }
-@@ -513,7 +513,7 @@ _mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle)
- _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(interp)");
- return;
- }
-- if ((swizzle < GL_SWIZZLE_STR_ATI) && (swizzle > GL_SWIZZLE_STQ_DQ_ATI)) {
-+ if (!(swizzle >= GL_SWIZZLE_STR_ATI) && (swizzle <= GL_SWIZZLE_STQ_DQ_ATI)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(swizzle)");
- return;
- }
-diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c
-index 975a617..d37d7fb 100644
---- a/src/mesa/shader/prog_statevars.c
-+++ b/src/mesa/shader/prog_statevars.c
-@@ -507,6 +507,8 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH])
- switch (state[1]) {
- case STATE_TEXRECT_SCALE:
- return _NEW_TEXTURE;
-+ case STATE_FOG_PARAMS_OPTIMIZED:
-+ return _NEW_FOG;
- default:
- /* unknown state indexes are silently ignored and
- * no flag set, since it is handled by the driver.
-diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
-index b794e30..06d24b4 100644
---- a/src/mesa/shader/shader_api.c
-+++ b/src/mesa/shader/shader_api.c
-@@ -378,7 +378,7 @@ _mesa_attach_shader(GLcontext *ctx, GLuint program, GLuint shader)
- struct gl_shader_program *shProg
- = _mesa_lookup_shader_program(ctx, program);
- struct gl_shader *sh = _mesa_lookup_shader(ctx, shader);
-- const GLuint n = shProg->NumShaders;
-+ GLuint n;
- GLuint i;
-
- if (!shProg || !sh) {
-@@ -387,6 +387,8 @@ _mesa_attach_shader(GLcontext *ctx, GLuint program, GLuint shader)
- return;
- }
-
-+ n = shProg->NumShaders;
-+
- for (i = 0; i < n; i++) {
- if (shProg->Shaders[i] == sh) {
- /* already attached */
-@@ -548,7 +550,7 @@ _mesa_detach_shader(GLcontext *ctx, GLuint program, GLuint shader)
- {
- struct gl_shader_program *shProg
- = _mesa_lookup_shader_program(ctx, program);
-- const GLuint n = shProg->NumShaders;
-+ GLuint n;
- GLuint i, j;
-
- if (!shProg) {
-@@ -557,6 +559,8 @@ _mesa_detach_shader(GLcontext *ctx, GLuint program, GLuint shader)
- return;
- }
-
-+ n = shProg->NumShaders;
-+
- for (i = 0; i < n; i++) {
- if (shProg->Shaders[i]->Name == shader) {
- /* found it */
-diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
-index 012839c..ac7fa21 100644
---- a/src/mesa/swrast/s_copypix.c
-+++ b/src/mesa/swrast/s_copypix.c
-@@ -1,6 +1,6 @@
- /*
- * Mesa 3-D graphics library
-- * Version: 6.5.3
-+ * Version: 7.0.2
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
-@@ -71,13 +71,20 @@ regions_overlap(GLint srcx, GLint srcy,
- }
- else {
- /* add one pixel of slop when zooming, just to be safe */
-- if ((srcx > dstx + (width * zoomX) + 1) || (srcx + width + 1 < dstx)) {
-+ if (srcx > (dstx + ((zoomX > 0.0F) ? (width * zoomX + 1.0F) : 0.0F))) {
-+ /* src is completely right of dest */
-+ return GL_FALSE;
-+ }
-+ else if (srcx + width + 1.0F < dstx + ((zoomX > 0.0F) ? 0.0F : (width * zoomX))) {
-+ /* src is completely left of dest */
- return GL_FALSE;
- }
- else if ((srcy < dsty) && (srcy + height < dsty + (height * zoomY))) {
-+ /* src is completely below dest */
- return GL_FALSE;
- }
- else if ((srcy > dsty) && (srcy + height > dsty + (height * zoomY))) {
-+ /* src is completely above dest */
- return GL_FALSE;
- }
- else {
-diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h
-index dddc2f7..9436464 100644
---- a/src/mesa/swrast/s_pointtemp.h
-+++ b/src/mesa/swrast/s_pointtemp.h
-@@ -217,9 +217,9 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
- }
- else {
- /* even size */
-- xmin = (GLint) vert->win[0] - iRadius + 1;
-+ xmin = (GLint) vert->win[0] - iRadius;
- xmax = xmin + iSize - 1;
-- ymin = (GLint) vert->win[1] - iRadius + 1;
-+ ymin = (GLint) vert->win[1] - iRadius;
- ymax = ymin + iSize - 1;
- }
- #endif /*SMOOTH*/
-diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
-index 097d2c7..5814400 100644
---- a/src/mesa/swrast/s_span.c
-+++ b/src/mesa/swrast/s_span.c
-@@ -61,8 +61,11 @@ _swrast_span_default_z( GLcontext *ctx, SWspan *span )
- const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
- if (ctx->DrawBuffer->Visual.depthBits <= 16)
- span->z = FloatToFixed(ctx->Current.RasterPos[2] * depthMax + 0.5F);
-- else
-- span->z = (GLint) (ctx->Current.RasterPos[2] * depthMax + 0.5F);
-+ else {
-+ GLfloat tmpf = ctx->Current.RasterPos[2] * depthMax;
-+ tmpf = MIN2(tmpf, depthMax);
-+ span->z = (GLint) tmpf;
-+ }
- span->zStep = 0;
- span->interpMask |= SPAN_Z;
- }
-diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
-index 5b2b2ae..ff50d91 100644
---- a/src/mesa/tnl/t_draw.c
-+++ b/src/mesa/tnl/t_draw.c
-@@ -1,9 +1,8 @@
--
- /*
- * Mesa 3-D graphics library
-- * Version: 6.5
-+ * Version: 7.0.2
- *
-- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
-+ * Copyright (C) 1999-2007 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"),
-@@ -368,7 +367,7 @@ void _tnl_draw_prims( GLcontext *ctx,
- _tnl_draw_prims );
- return;
- }
-- else if (max_index >= max) {
-+ else if (max_index > max) {
- /* The software TNL pipeline has a fixed amount of storage for
- * vertices and it is necessary to split incoming drawing commands
- * if they exceed that limit.
-diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c
-index 5440ff7..d8bca38 100644
---- a/src/mesa/tnl/t_vb_fog.c
-+++ b/src/mesa/tnl/t_vb_fog.c
-@@ -41,7 +41,6 @@
-
- struct fog_stage_data {
- GLvector4f fogcoord; /* has actual storage allocated */
-- GLvector4f input; /* points into VB->EyePtr Z values */
- };
-
- #define FOG_STAGE_DATA(stage) ((struct fog_stage_data *)stage->privatePtr)
-@@ -91,7 +90,8 @@ init_static_data( void )
- * evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function.
- * Fog coordinates are distances from the eye (typically between the
- * near and far clip plane distances).
-- * Note the fog (eye Z) coords may be negative so we use ABS(z) below.
-+ * Note that fogcoords may be negative, if eye z is source absolute
-+ * value must be taken earlier.
- * Fog blend factors are in the range [0,1].
- */
- static void
-@@ -114,7 +114,7 @@ compute_fog_blend_factors(GLcontext *ctx, GLvector4f *out, const GLvector4f *in)
- else
- d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
- for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
-- const GLfloat z = FABSF(*v);
-+ const GLfloat z = *v;
- GLfloat f = (end - z) * d;
- data[i][0] = CLAMP(f, 0.0F, 1.0F);
- }
-@@ -122,14 +122,14 @@ compute_fog_blend_factors(GLcontext *ctx, GLvector4f *out, const GLvector4f *in)
- case GL_EXP:
- d = ctx->Fog.Density;
- for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride)) {
-- const GLfloat z = FABSF(*v);
-+ const GLfloat z = *v;
- NEG_EXP( data[i][0], d * z );
- }
- break;
- case GL_EXP2:
- d = ctx->Fog.Density*ctx->Fog.Density;
- for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
-- const GLfloat z = FABSF(*v);
-+ const GLfloat z = *v;
- NEG_EXP( data[i][0], d * z * z );
- }
- break;
-@@ -153,6 +153,8 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
-
-
- if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) {
-+ GLuint i;
-+ GLfloat *coord;
- /* Fog is computed from vertex or fragment Z values */
- /* source = VB->ObjPtr or VB->EyePtr coords */
- /* dest = VB->AttribPtr[_TNL_ATTRIB_FOG] = fog stage private storage */
-@@ -167,11 +169,10 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
- */
- input = &store->fogcoord;
-
-- /* NOTE: negate plane here so we get positive fog coords! */
-- plane[0] = -m[2];
-- plane[1] = -m[6];
-- plane[2] = -m[10];
-- plane[3] = -m[14];
-+ plane[0] = m[2];
-+ plane[1] = m[6];
-+ plane[2] = m[10];
-+ plane[3] = m[14];
- /* Full eye coords weren't required, just calculate the
- * eye Z values.
- */
-@@ -180,18 +181,29 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
- VB->ObjPtr, plane );
-
- input->count = VB->ObjPtr->count;
-+
-+ /* make sure coords are really positive
-+ NOTE should avoid going through array twice */
-+ coord = input->start;
-+ for (i = 0; i < input->count; i++) {
-+ *coord = FABSF(*coord);
-+ STRIDE_F(coord, input->stride);
-+ }
- }
- else {
-- /* fog coordinates = eye Z coordinates (use ABS later) */
-- input = &store->input;
-+ /* fog coordinates = eye Z coordinates - need to copy for ABS */
-+ input = &store->fogcoord;
-
- if (VB->EyePtr->size < 2)
- _mesa_vector4f_clean_elem( VB->EyePtr, VB->Count, 2 );
-
-- input->data = (GLfloat (*)[4]) &(VB->EyePtr->data[0][2]);
-- input->start = VB->EyePtr->start+2;
-- input->stride = VB->EyePtr->stride;
-+ input->stride = 4 * sizeof(GLfloat);
- input->count = VB->EyePtr->count;
-+ coord = VB->EyePtr->start;
-+ for (i = 0 ; i < VB->EyePtr->count; i++) {
-+ input->data[i][0] = FABSF(coord[2]);
-+ STRIDE_F(coord, VB->EyePtr->stride);
-+ }
- }
- }
- else {
-@@ -234,7 +246,6 @@ alloc_fog_data(GLcontext *ctx, struct tnl_pipeline_stage *stage)
- return GL_FALSE;
-
- _mesa_vector4f_alloc( &store->fogcoord, 0, tnl->vb.Size, 32 );
-- _mesa_vector4f_init( &store->input, 0, NULL );
-
- if (!inited)
- init_static_data();
-diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c
-index dff062a..6a6db06 100644
---- a/src/mesa/tnl/t_vp_build.c
-+++ b/src/mesa/tnl/t_vp_build.c
-@@ -1,8 +1,8 @@
- /*
- * Mesa 3-D graphics library
-- * Version: 6.5
-+ * Version: 7.1
- *
-- * Copyright (C) 2006 Tungsten Graphics All Rights Reserved.
-+ * Copyright (C) 2007 Tungsten Graphics 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"),
-@@ -33,11 +33,11 @@
- #include "glheader.h"
- #include "macros.h"
- #include "enums.h"
--#include "program.h"
--#include "prog_instruction.h"
--#include "prog_parameter.h"
--#include "prog_print.h"
--#include "prog_statevars.h"
-+#include "shader/program.h"
-+#include "shader/prog_instruction.h"
-+#include "shader/prog_parameter.h"
-+#include "shader/prog_print.h"
-+#include "shader/prog_statevars.h"
- #include "t_context.h" /* NOTE: very light dependency on this */
- #include "t_vp_build.h"
-
-@@ -457,9 +457,13 @@ static void register_matrix_param5( struct tnl_program *p,
- }
-
-
-+/**
-+ * Convert a ureg source register to a prog_src_register.
-+ */
- static void emit_arg( struct prog_src_register *src,
- struct ureg reg )
- {
-+ assert(reg.file != PROGRAM_OUTPUT);
- src->File = reg.file;
- src->Index = reg.idx;
- src->Swizzle = reg.swz;
-@@ -469,9 +473,18 @@ static void emit_arg( struct prog_src_register *src,
- src->RelAddr = 0;
- }
-
-+/**
-+ * Convert a ureg dest register to a prog_dst_register.
-+ */
- static void emit_dst( struct prog_dst_register *dst,
- struct ureg reg, GLuint mask )
- {
-+ /* Check for legal output register type. UNDEFINED will occur in
-+ * instruction that don't produce a result (like END).
-+ */
-+ assert(reg.file == PROGRAM_TEMPORARY ||
-+ reg.file == PROGRAM_OUTPUT ||
-+ reg.file == PROGRAM_UNDEFINED);
- dst->File = reg.file;
- dst->Index = reg.idx;
- /* allow zero as a shorthand for xyzw */
-@@ -686,7 +699,7 @@ static struct ureg get_eye_normal( struct tnl_program *p )
- struct ureg rescale = register_param2(p, STATE_INTERNAL,
- STATE_NORMAL_SCALE);
-
-- emit_op2( p, OPCODE_MUL, p->eye_normal, 0, normal,
-+ emit_op2( p, OPCODE_MUL, p->eye_normal, 0, p->eye_normal,
- swizzle1(rescale, X));
- }
- }
-@@ -956,13 +969,19 @@ static void build_lighting( struct tnl_program *p )
- STATE_POSITION);
- struct ureg V = get_eye_position(p);
- struct ureg dist = get_temp(p);
-+ struct ureg tmpPpli = get_temp(p);
-
- VPpli = get_temp(p);
- half = get_temp(p);
-
-- /* Calulate VPpli vector
-+ /* In homogeneous object coordinates
-+ */
-+ emit_op1(p, OPCODE_RCP, dist, 0, swizzle1(Ppli, W));
-+ emit_op2(p, OPCODE_MUL, tmpPpli, 0, Ppli, dist);
-+
-+ /* Calculate VPpli vector
- */
-- emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V);
-+ emit_op2(p, OPCODE_SUB, VPpli, 0, tmpPpli, V);
-
- /* Normalize VPpli. The dist value also used in
- * attenuation below.
-@@ -994,6 +1013,7 @@ static void build_lighting( struct tnl_program *p )
- emit_normalize_vec3(p, half, half);
-
- release_temp(p, dist);
-+ release_temp(p, tmpPpli);
- }
-
- /* Calculate dot products:
-@@ -1103,7 +1123,7 @@ static void build_fog( struct tnl_program *p )
- {
- struct ureg fog = register_output(p, VERT_RESULT_FOGC);
- struct ureg input;
--
-+
- if (p->state->fog_source_is_depth) {
- input = swizzle1(get_eye_position(p), Z);
- }
-@@ -1111,39 +1131,48 @@ static void build_fog( struct tnl_program *p )
- input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
- }
-
-- if (p->state->tnl_do_vertex_fog) {
-+ if (p->state->fog_mode && p->state->tnl_do_vertex_fog) {
- struct ureg params = register_param2(p, STATE_INTERNAL,
- STATE_FOG_PARAMS_OPTIMIZED);
- struct ureg tmp = get_temp(p);
-+ GLboolean useabs = (p->state->fog_mode != FOG_EXP2);
-+
-+ if (useabs) {
-+ emit_op1(p, OPCODE_ABS, tmp, 0, input);
-+ }
-
- switch (p->state->fog_mode) {
- case FOG_LINEAR: {
- struct ureg id = get_identity_param(p);
-- emit_op3(p, OPCODE_MAD, tmp, 0, input, swizzle1(params,X), swizzle1(params,Y));
-+ emit_op3(p, OPCODE_MAD, tmp, 0, useabs ? tmp : input,
-+ swizzle1(params,X), swizzle1(params,Y));
- emit_op2(p, OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */
- emit_op2(p, OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W));
- break;
- }
- case FOG_EXP:
-- emit_op1(p, OPCODE_ABS, tmp, 0, input);
-- emit_op2(p, OPCODE_MUL, tmp, 0, tmp, swizzle1(params,Z));
-+ emit_op2(p, OPCODE_MUL, tmp, 0, useabs ? tmp : input,
-+ swizzle1(params,Z));
- emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp));
- break;
- case FOG_EXP2:
- emit_op2(p, OPCODE_MUL, tmp, 0, input, swizzle1(params,W));
-- emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp);
-+ emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp);
- emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp));
- break;
- }
--
-+
- release_temp(p, tmp);
- }
- else {
- /* results = incoming fog coords (compute fog per-fragment later)
- *
- * KW: Is it really necessary to do anything in this case?
-+ * BP: Yes, we always need to compute the absolute value, unless
-+ * we want to push that down into the fragment program...
- */
-- emit_op1(p, OPCODE_MOV, fog, WRITEMASK_X, input);
-+ GLboolean useabs = GL_TRUE;
-+ emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, WRITEMASK_X, input);
- }
- }
-
-diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
-index 8940551..697d00e 100644
---- a/src/mesa/vbo/vbo_save_draw.c
-+++ b/src/mesa/vbo/vbo_save_draw.c
-@@ -132,9 +132,11 @@ static void vbo_bind_vertex_list( GLcontext *ctx,
- }
-
- for (attr = 0; attr < VBO_ATTRIB_MAX; attr++) {
-- if (node->attrsz[attr]) {
-+ GLuint src = map[attr];
-+
-+ if (node->attrsz[src]) {
- arrays[attr].Ptr = (const GLubyte *)data;
-- arrays[attr].Size = node->attrsz[attr];
-+ arrays[attr].Size = node->attrsz[src];
- arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat);
- arrays[attr].Stride = node->vertex_size * sizeof(GLfloat);
- arrays[attr].Type = GL_FLOAT;
-diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c
-index e142dde..b71a935 100644
---- a/src/mesa/vbo/vbo_split_copy.c
-+++ b/src/mesa/vbo/vbo_split_copy.c
-@@ -129,6 +129,13 @@ static GLuint attr_size( const struct gl_client_array *array )
- */
- static GLboolean check_flush( struct copy_context *copy )
- {
-+ GLenum mode = copy->dstprim[copy->dstprim_nr].mode;
-+
-+ if (GL_TRIANGLE_STRIP == mode &&
-+ copy->dstelt_nr & 1) { /* see bug9962 */
-+ return GL_FALSE;
-+ }
-+
- if (copy->dstbuf_nr + 4 > copy->dstbuf_size)
- return GL_TRUE;
-
-@@ -458,7 +465,7 @@ static void replay_init( struct copy_context *copy )
- dst->StrideB = copy->vertex_size;
- dst->Ptr = copy->dstbuf + offset;
- dst->Enabled = GL_TRUE;
-- dst->Normalized = GL_TRUE;
-+ dst->Normalized = src->Normalized;
- dst->BufferObj = ctx->Array.NullBufferObj;
- dst->_MaxElement = copy->dstbuf_size; /* may be less! */
-
-diff --git a/src/mesa/x86-64/xform4.S b/src/mesa/x86-64/xform4.S
-index 65328f6..f512b3a 100644
---- a/src/mesa/x86-64/xform4.S
-+++ b/src/mesa/x86-64/xform4.S
-@@ -1,10 +1,8 @@
--/* $Id: xform4.S,v 1.2 2006/04/17 18:58:24 krh Exp $ */
--
- /*
- * Mesa 3-D graphics library
-- * Version: 3.5
-+ * Version: 7.0.1
- *
-- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
-+ * Copyright (C) 1999-2007 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"),
-@@ -64,7 +62,7 @@ _mesa_x86_64_transform_points4_general:
-
- p4_general_loop:
-
-- movaps (%rdx), %xmm8 /* ox | oy | oz | ow */
-+ movups (%rdx), %xmm8 /* ox | oy | oz | ow */
- prefetchw 16(%rdi)
-
- pshufd $0x00, %xmm8, %xmm0 /* ox | ox | ox | ox */
-@@ -149,7 +147,7 @@ _mesa_x86_64_transform_points4_3d:
-
- p4_3d_loop:
-
-- movaps (%rdx), %xmm8 /* ox | oy | oz | ow */
-+ movups (%rdx), %xmm8 /* ox | oy | oz | ow */
- prefetchw 16(%rdi)
-
- pshufd $0x00, %xmm8, %xmm0 /* ox | ox | ox | ox */
diff --git a/mesa-7.1-kill-glw.patch b/mesa-7.1-kill-glw.patch
new file mode 100644
index 0000000..77f909c
--- /dev/null
+++ b/mesa-7.1-kill-glw.patch
@@ -0,0 +1,40 @@
+diff -up Mesa-7.1pre/configs/default.da Mesa-7.1pre/configs/default
+--- Mesa-7.1pre/configs/default.da 2007-11-01 16:24:30.000000000 +1000
++++ Mesa-7.1pre/configs/default 2007-11-01 16:24:37.000000000 +1000
+@@ -60,7 +60,7 @@ GLW_SOURCES = GLwDrawA.c
+
+ # Directories to build
+ LIB_DIR = lib
+-SRC_DIRS = mesa glu glut/glx glw
++SRC_DIRS = mesa glu glut/glx
+ GLU_DIRS = sgi
+ DRIVER_DIRS = x11 osmesa
+ # Which subdirs under $(TOP)/progs/ to enter:
+diff -up Mesa-7.1pre/configs/linux-indirect.da Mesa-7.1pre/configs/linux-indirect
+--- Mesa-7.1pre/configs/linux-indirect.da 2007-11-01 16:23:32.000000000 +1000
++++ Mesa-7.1pre/configs/linux-indirect 2007-11-01 16:23:39.000000000 +1000
+@@ -47,7 +47,7 @@ GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11
+
+
+ # Directories
+-SRC_DIRS = glx/x11 glu glut/glx glw
++SRC_DIRS = glx/x11 glu
+ DRIVER_DIRS =
+ PROGRAM_DIRS =
+ WINDOW_SYSTEM=dri
+diff -up Mesa-7.1pre/configs/linux-dri.da Mesa-7.1pre/configs/linux-dri
+--- Mesa-7.1pre/configs/linux-dri.da 2007-11-01 16:24:00.000000000 +1000
++++ Mesa-7.1pre/configs/linux-dri 2007-11-01 16:24:12.000000000 +1000
+@@ -60,10 +60,10 @@ USING_EGL=0
+
+ # Directories
+ ifeq ($(USING_EGL), 1)
+-SRC_DIRS = egl glx/x11 mesa glu glut/glx glw
++SRC_DIRS = egl glx/x11 mesa glu glut/glx
+ PROGRAM_DIRS = egl xdemos
+ else
+-SRC_DIRS = glx/x11 mesa glu glut/glx glw
++SRC_DIRS = glx/x11 mesa glu glut/glx
+ PROGRAM_DIRS = xdemos
+ endif
+
diff --git a/mesa-7.1pre-osmesa-version.patch b/mesa-7.1pre-osmesa-version.patch
new file mode 100644
index 0000000..8e4767e
--- /dev/null
+++ b/mesa-7.1pre-osmesa-version.patch
@@ -0,0 +1,39 @@
+From 8a156f47fc6547d5ed0fb8031f332cbf9e16948d Mon Sep 17 00:00:00 2001
+From: Dave Airlie <airlied@redhat.com>
+Date: Thu, 1 Nov 2007 16:16:52 +1000
+Subject: [PATCH] mesa: keep OSMESA version at 6.5.3
+
+---
+ src/mesa/Makefile | 9 +++++----
+ 1 files changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/src/mesa/Makefile b/src/mesa/Makefile
+index 77bb7be..e2a09ed 100644
+--- a/src/mesa/Makefile
++++ b/src/mesa/Makefile
+@@ -117,17 +117,18 @@ $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(STAND_ALONE_OBJECTS)
+ $(MKLIB_OPTIONS) $(GL_LIB_DEPS) $(STAND_ALONE_OBJECTS)
+
+ # Make the OSMesa library
++# Note: version is kept at 6.5.3 to simplify app/linking issues
+ $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OSMESA_DRIVER_OBJECTS) $(OSMESA16_OBJECTS)
+ @ if [ "${DRIVER_DIRS}" = "osmesa" ] ; then \
+ $(TOP)/bin/mklib -o $(OSMESA_LIB) -linker '$(CC)' \
+- -ldflags '$(LDFLAGS)' -major $(MESA_MAJOR) \
+- -minor $(MESA_MINOR) -patch $(MESA_TINY) \
++ -ldflags '$(LDFLAGS)' -major 6 \
++ -minor 5 -patch 3 \
+ -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
+ $(OSMESA_LIB_DEPS) $(OSMESA16_OBJECTS) ; \
+ else \
+ $(TOP)/bin/mklib -o $(OSMESA_LIB) -linker '$(CC)' \
+- -ldflags '$(LDFLAGS)' -major $(MESA_MAJOR) \
+- -minor $(MESA_MINOR) -patch $(GL_TINY) \
++ -ldflags '$(LDFLAGS)' -major 6 \
++ -minor 5 -patch 3 \
+ -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
+ $(OSMESA_LIB_DEPS) $(OSMESA_DRIVER_OBJECTS) ; \
+ fi
+--
+1.5.3.4
+
diff --git a/mesa.spec b/mesa.spec
index 6cdfd99..3d8a7b3 100644
--- a/mesa.spec
+++ b/mesa.spec
@@ -31,31 +31,27 @@
Summary: Mesa graphics libraries
Name: mesa
-Version: 7.0.1
-Release: 7%{?dist}
+Version: 7.1pre
+Release: 0%{?dist}
License: MIT
Group: System Environment/Libraries
URL: http://www.mesa3d.org
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Source0: http://internap.dl.sourceforge.net/sourceforge/mesa3d/MesaLib-%{version}.tar.bz2
-Source1: http://internap.dl.sourceforge.net/sourceforge/mesa3d/MesaDemos-%{version}.tar.bz2
+Source0: http://internap.dl.sourceforge.net/sourceforge/mesa3d/MesaLib-7.1pre.tar.bz2
+Source1: http://internap.dl.sourceforge.net/sourceforge/mesa3d/MesaDemos-7.1pre.tar.bz2
Source2: %{manpages}.tar.bz2
-Patch0: mesa-7.0-build-config.patch
+Patch1: mesa-7.1-kill-glw.patch
+Patch2: mesa-7.1pre-osmesa-version.patch
Patch4: mesa-6.5-dont-libglut-me-harder-ok-thx-bye.patch
Patch5: mesa-6.5.2-xserver-1.1-source-compat.patch
Patch18: mesa-7.0-selinux-awareness.patch
-Patch23: mesa-6.5.2-bindcontext-paranoia.patch
Patch25: mesa-7.0-symlinks-before-depend.patch
-Patch26: mesa-7.0.1-stable-branch.patch
-Patch27: mesa-7.0-use_master-r300.patch
-Patch28: mesa-7.0.1-r300-fix-writemask.patch
-Patch29: mesa-7.0.1-r200-settexoffset.patch
BuildRequires: pkgconfig
%if %{with_dri}
-BuildRequires: libdrm-devel >= 2.3.0-1
+BuildRequires: libdrm-devel >= 2.4.0-0
%endif
BuildRequires: libXxf86vm-devel
BuildRequires: expat-devel >= 2.0
@@ -173,16 +169,12 @@ This package provides some demo applications for testing Mesa.
%setup -q -n Mesa-%{version} -b1 -b2
chmod a-x progs/demos/glslnoise.c
-%patch0 -p1 -b .build-config
+%patch1 -p1 -b .kill-glw
+%patch2 -p1 -b .osmesa-version
%patch4 -p0 -b .dont-libglut-me-harder-ok-thx-bye
%patch5 -p1 -b .xserver-1.1-compat
%patch18 -p1 -b .selinux-awareness
-%patch23 -p1 -b .bindcontext
%patch25 -p1 -b .makej
-%patch26 -p1 -b .stable
-%patch27 -p1 -b .r300
-%patch28 -p1 -b .r300-writemask
-%patch29 -p1 -b .r200-settexoffset
# WARNING: The following files are copyright "Mark J. Kilgard" under the GLUT
# license and are not open source/free software, so we remove them.
@@ -364,6 +356,7 @@ rm -rf $RPM_BUILD_ROOT
%{_bindir}/arbocclude
%{_bindir}/bounce
%{_bindir}/clearspd
+%{_bindir}/copypix
%{_bindir}/cubemap
%{_bindir}/drawpix
%{_bindir}/engine
@@ -412,6 +405,9 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/mesa-demos-data
%changelog
+* Thu Nov 01 2007 Dave Airlie <airlied@redhat.com> 7.1pre-0
+- rebase Mesa to 7.1pre 74ced1e67f286a5e71e9877bc6844b2af5b9ab8d
+
* Thu Oct 18 2007 Dave Airlie <airlied@redhat.com> 7.0.1-7
- mesa-7.0.1-stable-branch.patch - Updated with more fixes from stable
- mesa-7.0.1-r300-fix-writemask.patch - fix r300 fragprog writemask
diff --git a/sources b/sources
index e5f1a90..ee440e0 100644
--- a/sources
+++ b/sources
@@ -1,3 +1,3 @@
-c056abd763e899114bf745c9eedbf9ad MesaLib-7.0.1.tar.bz2
-3b66b3268df12ca8a6c4e0c4c457912c MesaDemos-7.0.1.tar.bz2
+715651003893bfd3f48d78dde6d45e55 MesaLib-7.1pre.tar.bz2
+68942584edd6f3160129fd341c28a123 MesaDemos-7.1pre.tar.bz2
6ae05158e678f4594343f32c2ca50515 gl-manpages-1.0.1.tar.bz2