summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkem <kem>2000-02-09 18:05:07 +0000
committerkem <kem>2000-02-09 18:05:07 +0000
commite1d07e3aad2cf1968d5e8165f1fd05af55916dcb (patch)
tree20922f1763ff3c119cba414eab54bc9c3217a701
parent8aaf4119edd7e4554d2755773552216185b64a5e (diff)
Added the initial r128 client-side DRI driver.
This driver is not yet functional.
-rw-r--r--xc/lib/GL/Imakefile16
-rw-r--r--xc/lib/GL/mesa/src/drv/Imakefile4
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/Imakefile56
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_context.h128
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_dd.c94
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_dd.h44
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_depth.c78
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_depth.h43
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_init.h52
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_lock.h134
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_mesa.h43
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_screen.c149
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_screen.h109
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_span.c127
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_span.h43
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_state.c469
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_state.h46
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tex.c94
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tex.h43
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c402
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_xmesa.h43
21 files changed, 2217 insertions, 0 deletions
diff --git a/xc/lib/GL/Imakefile b/xc/lib/GL/Imakefile
index da415bfb6..f6529d2a6 100644
--- a/xc/lib/GL/Imakefile
+++ b/xc/lib/GL/Imakefile
@@ -68,6 +68,22 @@ DependSubdirs($(SUBDIRS))
DRVPOBJS = $(TDFXPOBJS) $(MESAPOBJS)
DRVDONES = $(TDFXDONES) $(MESADONES)
REQUIREDLIBS += -lglide3x
+#elif GlxBuiltInR128
+ R128OBJS = mesa/src/drv/r128/?*.o
+ R128UOBJS = mesa/src/drv/r128/unshared/?*.o
+ R128DOBJS = mesa/src/drv/r128/debugger/?*.o
+ R128POBJS = mesa/src/drv/r128/profiled/?*.o
+ R128DONES = mesa/src/drv/r128/DONE
+ MESAOBJS = mesa/src/?*.o mesa/src/X86/?*.o
+ MESAUOBJS = mesa/src/unshared/?*.o mesa/src/X86/unshared/?*.o
+ MESADOBJS = mesa/src/debugger/?*.o mesa/src/X86/debugger/?*.o
+ MESAPOBJS = mesa/src/profiled/?*.o mesa/src/X86/profiled/?*.o
+ MESADONES = mesa/src/DONE mesa/src/X86/DONE
+ DRVOBJS = $(R128OBJS) $(MESAOBJS)
+ DRVUOBJS = $(R128UOBJS) $(MESAUOBJS)
+ DRVDOBJS = $(R128DOBJS) $(MESADOBJS)
+ DRVPOBJS = $(R128POBJS) $(MESAPOBJS)
+ DRVDONES = $(R128DONES) $(MESADONES)
#elif GlxBuiltInMesa
#ifndef GlxDriverUsesMesa
DRVOBJS = mesa/src/?*.o mesa/src/X/?*.o
diff --git a/xc/lib/GL/mesa/src/drv/Imakefile b/xc/lib/GL/mesa/src/drv/Imakefile
index 238ebda17..c6a660240 100644
--- a/xc/lib/GL/mesa/src/drv/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/Imakefile
@@ -17,11 +17,15 @@ DRIVER += gamma
#if GlxBuiltInTdfx
DRIVER += tdfx
#endif
+#if GlxBuiltInR128
+DRIVER += r128
+#endif
SUBDIRS = $(DRIVER)
#else
SUBDIRS += gamma
SUBDIRS += tdfx
+SUBDIRS += r128
#endif
MakeSubdirs($(SUBDIRS))
diff --git a/xc/lib/GL/mesa/src/drv/r128/Imakefile b/xc/lib/GL/mesa/src/drv/r128/Imakefile
new file mode 100644
index 000000000..f3881a7f5
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/Imakefile
@@ -0,0 +1,56 @@
+XCOMM $XFree86$
+
+#define DoNormalLib NormalLibGlx
+#define DoSharedLib SharedLibGlx
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DDRIVERTS
+ DRI_INCLUDES = -I../../../../dri -I../../../../glx \
+ -I$(TOP)/include -I$(TOP)/include/GL \
+ -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \
+ -I$(XF86DRIVERSRC)/r128 \
+ -I../../../include -I../.. -I../../X
+#endif
+
+MESA_INCLUDES = -I. -I.. -I../../include
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES)
+ INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES)
+ DRISRCS = r128_xmesa.c r128_screen.c r128_dd.c r128_state.c \
+ r128_span.c r128_depth.c r128_tex.c
+ DRIOBJS = r128_xmesa.o r128_screen.o r128_dd.o r128_state.o \
+ r128_span.o r128_depth.o r128_tex.o
+
+ SRCS = $(DRISRCS)
+ OBJS = $(DRIOBJS)
+
+#if !GlxUseBuiltInDRIDriver
+#undef DoNormalLib NormalLibGlx
+#undef DoExtraLib SharedLibGlx
+#undef DoDebugLib DebugLibGlx
+#undef DoProfileLib ProfileLibGlx
+#endif
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = r128_dri.so
+ALL_OBJS = $(OBJS)
+ALL_DEPS = DONE
+SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),.)
+#endif
+
+DependTarget()
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_context.h b/xc/lib/GL/mesa/src/drv/r128/r128_context.h
new file mode 100644
index 000000000..2eff9a3a1
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.h
@@ -0,0 +1,128 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_CONTEXT_H_
+#define _R128_CONTEXT_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+#define R128_CLEAN 0x0000
+#define R128_REQUIRE_QUIESCENCE 0x0001
+#define R128_START_CCE 0x0002
+#define R128_UPDATE_CONTEXT 0x0004
+#define R128_UPDATE_CLIPRECTS 0x0008
+#define R128_ALL_DIRTY 0xffff
+
+typedef struct {
+ CARD32 scale_3d_cntl; /* 0x1a00 */
+
+ CARD32 dst_pitch_offset_c; /* 0x1c80 */
+ CARD32 dp_gui_master_cntl;
+ CARD32 sc_top_left_c;
+ CARD32 sc_bottom_right_c;
+ CARD32 z_offset_c;
+ CARD32 z_pitch_c;
+ CARD32 z_sten_cntl_c;
+ CARD32 tex_cntl_c;
+ CARD32 misc_3d_state_cntl_reg;
+ CARD32 texture_clr_cmp_clr_c;
+ CARD32 texture_clr_cmp_msk_c;
+ CARD32 fog_color_c;
+ CARD32 prim_tex_cntl_c;
+ CARD32 prim_texture_combine_cntl_c;
+ CARD32 tex_size_pitch_c;
+ CARD32 prim_tex_0_offset_c;
+ CARD32 prim_tex_1_offset_c;
+ CARD32 prim_tex_2_offset_c;
+ CARD32 prim_tex_3_offset_c;
+ CARD32 prim_tex_4_offset_c;
+ CARD32 prim_tex_5_offset_c;
+ CARD32 prim_tex_6_offset_c;
+ CARD32 prim_tex_7_offset_c;
+ CARD32 prim_tex_8_offset_c;
+ CARD32 prim_tex_9_offset_c;
+ CARD32 prim_tex_10_offset_c; /* 0x1ce4 */
+
+ CARD32 sec_tex_cntl_c; /* 0x1d00 */
+ CARD32 sec_tex_combine_cntl_c;
+ CARD32 sec_tex_0_offset_c;
+ CARD32 sec_tex_1_offset_c;
+ CARD32 sec_tex_2_offset_c;
+ CARD32 sec_tex_3_offset_c;
+ CARD32 sec_tex_4_offset_c;
+ CARD32 sec_tex_5_offset_c;
+ CARD32 sec_tex_6_offset_c;
+ CARD32 sec_tex_7_offset_c;
+ CARD32 sec_tex_8_offset_c;
+ CARD32 sec_tex_9_offset_c;
+ CARD32 sec_tex_10_offset_c;
+ CARD32 constant_color_c;
+ CARD32 prim_texture_border_color_c;
+ CARD32 sec_texture_border_color_c;
+ CARD32 sten_ref_mask_c;
+ CARD32 plane_3d_mask_c; /* 0x1d44 */
+
+ CARD32 setup_cntl; /* 0x1bc4 */
+ CARD32 pm4_vc_fpu_setup; /* 0x071c */
+
+ CARD32 fog_3d_table_start; /* 0x1810 */
+ CARD32 fog_3d_table_end;
+ CARD32 fog_3d_table_density; /* 0x181c */
+} r128ContextRegs;
+
+typedef struct {
+ XMesaContext xmCtx;
+ GLcontext *glCtx;
+ int dirty;
+ int needClip;
+
+ points_func PointsFunc;
+ line_func LineFunc;
+ triangle_func TriangleFunc;
+ quad_func QuadFunc;
+
+ r128ContextRegs regs;
+
+ Display *display;
+
+ __DRIcontextPrivate *driContext;
+ __DRIdrawablePrivate *driDrawable;
+
+ r128ScreenPtr r128Screen;
+} r128ContextRec, *r128ContextPtr;
+
+extern r128ContextPtr r128Context;
+
+#endif
+#endif /* _R128_CONTEXT_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_dd.c b/xc/lib/GL/mesa/src/drv/r128/r128_dd.c
new file mode 100644
index 000000000..37454735e
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_dd.c
@@ -0,0 +1,94 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#include "r128_init.h"
+#include "r128_mesa.h"
+#include "r128_dd.h"
+
+/* FIXME: This will be moved to r128_clear.c when it is ready */
+static GLbitfield r128DDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height)
+{
+ return 0;
+}
+
+static void r128DDGetBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ *width = r128ctx->driDrawable->w;
+ *height = r128ctx->driDrawable->h;
+}
+
+static const GLubyte *r128DDGetString(GLcontext *ctx, GLenum name)
+{
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *)"ATI Technologies Inc. and Precision Insight Inc.";
+ case GL_RENDERER:
+ return (GLubyte *)"DRI-ATI Rage 128";
+ default:
+ return NULL;
+ }
+}
+
+static void r128DDFinish(GLcontext *ctx)
+{
+}
+
+static void r128DDFlush(GLcontext *ctx)
+{
+}
+
+void r128DDInitExtensions(GLcontext *ctx)
+{
+}
+
+void r128DDInitDriverFuncs(GLcontext *ctx)
+{
+ ctx->Driver.Clear = r128DDClear;
+
+ ctx->Driver.GetBufferSize = r128DDGetBufferSize;
+ ctx->Driver.GetString = r128DDGetString;
+ ctx->Driver.Finish = r128DDFinish;
+ ctx->Driver.Flush = r128DDFlush;
+
+ ctx->Driver.Error = NULL;
+
+ ctx->Driver.DrawPixels = NULL;
+ ctx->Driver.Bitmap = NULL;
+
+ ctx->Driver.ClearDepth = NULL;
+ ctx->Driver.ClearStencil = NULL;
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_dd.h b/xc/lib/GL/mesa/src/drv/r128/r128_dd.h
new file mode 100644
index 000000000..91aa02586
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_dd.h
@@ -0,0 +1,44 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_DD_H_
+#define _R128_DD_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void r128DDInitExtensions(GLcontext *ctx);
+extern void r128DDInitDriverFuncs(GLcontext *ctx);
+
+#endif
+#endif /* _R128_DD_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_depth.c b/xc/lib/GL/mesa/src/drv/r128/r128_depth.c
new file mode 100644
index 000000000..c61eaadca
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_depth.c
@@ -0,0 +1,78 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#include "r128_init.h"
+#include "r128_mesa.h"
+#include "r128_depth.h"
+
+static void r128DDAllocDepthBuffer(GLcontext *ctx)
+{
+}
+
+static GLuint r128DDDepthTestSpan(GLcontext *ctx,
+ GLuint n,
+ GLint x, GLint y, const GLdepth z[],
+ GLubyte mask[])
+{
+ return 1;
+}
+
+static void r128DDDepthTestPixels(GLcontext *ctx,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const GLdepth z[], GLubyte mask[])
+{
+}
+
+static void r128DDReadDepthSpanFloat(GLcontext *ctx,
+ GLuint n,
+ GLint x, GLint y, GLfloat depth[])
+{
+}
+
+static void r128DDReadDepthSpanInt(GLcontext *ctx,
+ GLuint n,
+ GLint x, GLint y, GLdepth depth[])
+{
+}
+
+
+void r128DDInitDepthFuncs(GLcontext *ctx)
+{
+ ctx->Driver.AllocDepthBuffer = r128DDAllocDepthBuffer;
+ ctx->Driver.DepthTestSpan = r128DDDepthTestSpan;
+ ctx->Driver.DepthTestPixels = r128DDDepthTestPixels;
+ ctx->Driver.ReadDepthSpanFloat = r128DDReadDepthSpanFloat;
+ ctx->Driver.ReadDepthSpanInt = r128DDReadDepthSpanInt;
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_depth.h b/xc/lib/GL/mesa/src/drv/r128/r128_depth.h
new file mode 100644
index 000000000..fa35afc16
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_depth.h
@@ -0,0 +1,43 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_DEPTH_H_
+#define _R128_DEPTH_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void r128DDInitDepthFuncs(GLcontext *ctx);
+
+#endif
+#endif /* _R128_DEPTH_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_init.h b/xc/lib/GL/mesa/src/drv/r128/r128_init.h
new file mode 100644
index 000000000..e56e8418f
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_init.h
@@ -0,0 +1,52 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_INIT_H_
+#define _R128_INIT_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <X11/Xlibint.h>
+
+#include "types.h"
+#include "xmesaP.h"
+#include "xf86drm.h"
+#include "dri_tmm.h"
+#include "dri_mesaint.h"
+
+#include "r128_screen.h"
+#include "r128_context.h"
+
+#endif
+#endif /* _R128_INIT_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_lock.h b/xc/lib/GL/mesa/src/drv/r128/r128_lock.h
new file mode 100644
index 000000000..893bb4d78
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_lock.h
@@ -0,0 +1,134 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_LOCK_H_
+#define _R128_LOCK_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+/*
+ * You can turn this on to find locking conflicts.
+#define DEBUG_LOCKING
+*/
+#ifdef DEBUG_LOCKING
+extern char *prevLockFile;
+extern int prevLockLine;
+
+#define DEBUG_LOCK() \
+ do { \
+ prevLockFile = (__FILE__); \
+ prevLockLine = (__LINE__); \
+ } while (0)
+
+#define DEBUG_RESET() \
+ do { \
+ prevLockFile = 0; \
+ prevLockLine = 0; \
+ } while (0)
+
+#define DEBUG_CHECK_LOCK() \
+ do { \
+ if (prevLockFile) { \
+ fprintf(stderr, \
+ "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
+ prevLockFile, prevLockLine, __FILE__, __LINE__); \
+ exit(1); \
+ } \
+ } while (0)
+
+#else
+
+#define DEBUG_LOCK()
+#define DEBUG_RESET()
+#define DEBUG_CHECK_LOCK()
+
+#endif
+
+/*
+ * !!! We may want to separate locks from locks with validation. This
+ * could be used to improve performance for those things commands that
+ * do not do any drawing !!!
+ */
+
+/* Lock the hardware using the current context */
+#define LOCK_HARDWARE(CC) \
+ do { \
+ char __ret = 0; \
+ __DRIcontextPrivate *cPriv = CC->driContext; \
+ __DRIscreenPrivate *sPriv = CC->r128Screen->driScreen; \
+ \
+ DEBUG_CHECK_LOCK(); \
+ DRM_CAS(&sPriv->pSAREA->lock, cPriv->hHWContext, \
+ DRM_LOCK_HELD|cPriv->hHWContext, __ret); \
+ if (__ret) { \
+ drmGetLock(sPriv->fd, cPriv->hHWContext, 0); \
+ XMesaUpdateState(CC->xmCtx); \
+ } \
+ DEBUG_LOCK(); \
+ } while (0)
+
+/* Unlock the hardware using the current context */
+#define UNLOCK_HARDWARE(CC) \
+ do { \
+ __DRIcontextPrivate *cPriv = CC->driContext; \
+ __DRIscreenPrivate *sPriv = CC->r128Screen->driScreen; \
+ \
+ DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, cPriv->hHWContext); \
+ DEBUG_RESET(); \
+ } while (0)
+
+/*
+ * This pair of macros makes a loop over the drawing operations, so it
+ * is not self contained and does not have the nice single statement
+ * semantics of most macros.
+ */
+/* FIXME: The Rage128 has multiple clip rects -- optimize! */
+#define BEGIN_CLIP_LOOP(CC) \
+ do { \
+ __DRIdrawablePrivate *dPriv = CC->driDrawable; \
+ int _nc = dPriv->numClipRects; \
+ \
+ LOCK_HARDWARE(CC); \
+ while (_nc--) { \
+ if (CC->needClip) { \
+ r128SetClipRects(&dPriv->pClipRects[_nc]); \
+ }
+
+#define END_CLIP_LOOP(CC) \
+ } \
+ UNLOCK_HARDWARE(CC); \
+ } while (0)
+
+#endif
+#endif /* _R128_LOCK_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_mesa.h b/xc/lib/GL/mesa/src/drv/r128/r128_mesa.h
new file mode 100644
index 000000000..3a697b466
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_mesa.h
@@ -0,0 +1,43 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_MESA_H_
+#define _R128_MESA_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+#define R128_CONTEXT(ctx) ((r128ContextPtr)(ctx->DriverCtx))
+
+#endif
+#endif /* _R128_MESA_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_screen.c b/xc/lib/GL/mesa/src/drv/r128/r128_screen.c
new file mode 100644
index 000000000..6e4078c4e
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_screen.c
@@ -0,0 +1,149 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#include "r128_init.h"
+#include "r128_mesa.h"
+#include "r128_state.h"
+#include "r128_reg.h"
+
+static int INPLL(r128ScreenPtr pScrn, int addr)
+{
+ unsigned char *R128MMIO = pScrn->mmio;
+
+ OUTREG8(R128_CLOCK_CNTL_INDEX, addr & 0x1f);
+ return INREG(R128_CLOCK_CNTL_DATA);
+}
+
+void R128EngineFlush(r128ScreenPtr pScrn)
+{
+ unsigned char *R128MMIO = pScrn->mmio;
+ int i;
+
+ OUTREGP(R128_PC_NGUI_CTLSTAT, R128_PC_FLUSH_ALL, ~R128_PC_FLUSH_ALL);
+ for (i = 0; i < R128_TIMEOUT; i++) {
+ if (!(INREG(R128_PC_NGUI_CTLSTAT) & R128_PC_BUSY)) break;
+ }
+}
+
+void R128EngineReset(r128ScreenPtr pScrn)
+{
+ unsigned char *R128MMIO = pScrn->mmio;
+ CARD32 clock_cntl_index;
+ CARD32 mclk_cntl;
+ CARD32 gen_reset_cntl;
+
+ R128EngineFlush(pScrn);
+
+ clock_cntl_index = INREG(R128_CLOCK_CNTL_INDEX);
+ mclk_cntl = INPLL(pScrn, R128_MCLK_CNTL);
+
+ OUTPLL(R128_MCLK_CNTL, mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CPP);
+
+ gen_reset_cntl = INREG(R128_GEN_RESET_CNTL);
+
+ OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl | R128_SOFT_RESET_GUI);
+ INREG(R128_GEN_RESET_CNTL);
+ OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl & ~R128_SOFT_RESET_GUI);
+ INREG(R128_GEN_RESET_CNTL);
+
+ OUTPLL(R128_MCLK_CNTL, mclk_cntl);
+ OUTREG(R128_CLOCK_CNTL_INDEX, clock_cntl_index);
+ OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl);
+}
+
+void R128WaitForFifoFunction(r128ScreenPtr pScrn, int entries)
+{
+ unsigned char *R128MMIO = pScrn->mmio;
+ int i;
+
+ for (;;) {
+ for (i = 0; i < R128_TIMEOUT; i++) {
+ pScrn->MMIOFifoSlots = (INREG(R128_GUI_STAT)
+ & R128_GUI_FIFOCNT_MASK);
+ if (pScrn->MMIOFifoSlots >= entries) return;
+ }
+ R128EngineReset(pScrn);
+ }
+}
+
+void R128WaitForIdle(r128ScreenPtr pScrn)
+{
+ unsigned char *R128MMIO = pScrn->mmio;
+ int i;
+
+ R128WaitForFifoFunction(pScrn, 64);
+
+ for (;;) {
+ for (i = 0; i < R128_TIMEOUT; i++) {
+ if (!(INREG(R128_GUI_STAT) & R128_GUI_ACTIVE)) {
+ R128EngineFlush(pScrn);
+ return;
+ }
+ }
+ R128EngineReset(pScrn);
+ }
+}
+
+void R128CCEWaitForFifoFunction(r128ScreenPtr pScrn, int entries)
+{
+ unsigned char *R128MMIO = pScrn->mmio;
+ int i;
+
+ for (;;) {
+ for (i = 0; i < R128_TIMEOUT; i++) {
+ pScrn->CCEFifoSlots = INREG(R128_PM4_STAT) & R128_PM4_FIFOCNT_MASK;
+ if (pScrn->CCEFifoSlots >= entries) return;
+ }
+ R128EngineReset(pScrn);
+ }
+}
+
+void R128CCEWaitForIdle(r128ScreenPtr pScrn)
+{
+ unsigned char *R128MMIO = pScrn->mmio;
+ int i;
+
+ R128CCEWaitForFifoFunction(pScrn, pScrn->CCEFifoSize);
+
+ for (;;) {
+ for (i = 0; i < R128_TIMEOUT; i++) {
+ if (!(INREG(R128_PM4_STAT)
+ & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) {
+ R128EngineFlush(pScrn);
+ return;
+ }
+ }
+ R128EngineReset(pScrn);
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_screen.h b/xc/lib/GL/mesa/src/drv/r128/r128_screen.h
new file mode 100644
index 000000000..9b59aad02
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_screen.h
@@ -0,0 +1,109 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_SCREEN_H_
+#define _R128_SCREEN_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+#define R128_TIMEOUT 2000000
+
+typedef struct {
+ drmHandle handle;
+ drmSize size;
+} r128RegionRec, *r128RegionPtr;
+
+typedef struct {
+ r128RegionRec mmioRgn;
+ unsigned char *mmio;
+
+ r128RegionRec agpRgn;
+ unsigned char *agp;
+
+ int deviceID;
+
+ int width;
+ int height;
+ int depth;
+ int bpp;
+
+ unsigned char *fb;
+ unsigned long fbOffset;
+ int fbStride;
+ int fbSize;
+
+ unsigned long backOffset;
+ unsigned long depthOffset;
+ unsigned long textureOffset;
+ int textureSize;
+
+ int CCEMode;
+ int CCEFifoSize;
+
+ unsigned long ringStart;
+ int ringSize;
+ int *ringWritePtr;
+ int *ringReadPtr;
+
+ int MMIOFifoSlots;
+ int CCEFifoSlots;
+
+ __DRIscreenPrivate *driScreen;
+} r128ScreenRec, *r128ScreenPtr;
+
+#define R128WaitForFifo(pScrn, entries) \
+do { \
+ if (pScrn->MMIOFifoSlots < entries) \
+ R128WaitForFifoFunction(pScrn, entries); \
+ pScrn->MMIOFifoSlots -= entries; \
+} while (0)
+
+#define R128CCEWaitForFifo(pScrn, entries) \
+do { \
+ if (pScrn->CCEFifoSlots < entries) \
+ R128CCEWaitForFifoFunction(pScrn, entries); \
+ pScrn->CCEFifoSlots -= entries; \
+} while (0)
+
+extern void R128EngineFlush(r128ScreenPtr pScrn);
+extern void R128EngineReset(r128ScreenPtr pScrn);
+
+extern void R128WaitForFifoFunction(r128ScreenPtr pScrn, int entries);
+extern void R128WaitForIdle(r128ScreenPtr pScrn);
+
+extern void R128CCEWaitForFifoFunction(r128ScreenPtr pScrn, int entries);
+extern void R128CCEWaitForIdle(r128ScreenPtr pScrn);
+
+#endif
+#endif /* _R128_SCREEN_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_span.c b/xc/lib/GL/mesa/src/drv/r128/r128_span.c
new file mode 100644
index 000000000..3653fc2f6
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_span.c
@@ -0,0 +1,127 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#include "r128_init.h"
+#include "r128_mesa.h"
+#include "r128_span.h"
+
+static void r128DDWriteRGBASpan(const GLcontext *ctx,
+ GLuint n,
+ GLint x, GLint y,
+ const GLubyte rgba[][4],
+ const GLubyte mask[])
+{
+}
+
+static void r128DDWriteRGBSpan(const GLcontext *ctx,
+ GLuint n,
+ GLint x, GLint y,
+ const GLubyte rgb[][3],
+ const GLubyte mask[])
+{
+}
+
+static void r128DDWriteMonoRGBASpan(const GLcontext *ctx,
+ GLuint n,
+ GLint x, GLint y,
+ const GLubyte mask[])
+{
+}
+
+static void r128DDWriteRGBAPixels(const GLcontext *ctx,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const GLubyte rgba[][4],
+ const GLubyte mask[])
+{
+}
+
+static void r128DDWriteMonoRGBAPixels(const GLcontext *ctx,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const GLubyte mask[])
+{
+}
+
+static void r128DDReadRGBASpan(const GLcontext *ctx,
+ GLuint n,
+ GLint x, GLint y,
+ GLubyte rgba[][4])
+{
+}
+
+static void r128DDReadRGBAPixels(const GLcontext *ctx,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ GLubyte rgba[][4],
+ const GLubyte mask[])
+{
+}
+
+void r128DDInitSpanFuncs(GLcontext *ctx)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ switch (r128ctx->r128Screen->depth) {
+ case 8: /* Color Index mode not supported */
+ ctx->Driver.WriteCI32Span = NULL;
+ ctx->Driver.WriteCI8Span = NULL;
+ ctx->Driver.WriteMonoCISpan = NULL;
+ ctx->Driver.WriteCI32Pixels = NULL;
+ ctx->Driver.WriteMonoCIPixels = NULL;
+ ctx->Driver.ReadCI32Span = NULL;
+ ctx->Driver.ReadCI32Pixels = NULL;
+ break;
+ case 15: /* FIXME? */
+ case 16:
+ ctx->Driver.WriteRGBASpan = r128DDWriteRGBASpan;
+ ctx->Driver.WriteRGBSpan = r128DDWriteRGBSpan;
+ ctx->Driver.WriteMonoRGBASpan = r128DDWriteMonoRGBASpan;
+ ctx->Driver.WriteRGBAPixels = r128DDWriteRGBAPixels;
+ ctx->Driver.WriteMonoRGBAPixels = r128DDWriteMonoRGBAPixels;
+ ctx->Driver.ReadRGBASpan = r128DDReadRGBASpan;
+ ctx->Driver.ReadRGBAPixels = r128DDReadRGBAPixels;
+ break;
+ case 24: /* FIXME? */
+ case 32:
+ ctx->Driver.WriteRGBASpan = r128DDWriteRGBASpan;
+ ctx->Driver.WriteRGBSpan = r128DDWriteRGBSpan;
+ ctx->Driver.WriteMonoRGBASpan = r128DDWriteMonoRGBASpan;
+ ctx->Driver.WriteRGBAPixels = r128DDWriteRGBAPixels;
+ ctx->Driver.WriteMonoRGBAPixels = r128DDWriteMonoRGBAPixels;
+ ctx->Driver.ReadRGBASpan = r128DDReadRGBASpan;
+ ctx->Driver.ReadRGBAPixels = r128DDReadRGBAPixels;
+ break;
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_span.h b/xc/lib/GL/mesa/src/drv/r128/r128_span.h
new file mode 100644
index 000000000..9974afb35
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_span.h
@@ -0,0 +1,43 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_SPAN_H_
+#define _R128_SPAN_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void r128DDInitSpanFuncs(GLcontext *ctx);
+
+#endif
+#endif /* _R128_SPAN_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_state.c b/xc/lib/GL/mesa/src/drv/r128/r128_state.c
new file mode 100644
index 000000000..5ae86a628
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_state.c
@@ -0,0 +1,469 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#include "r128_init.h"
+#include "r128_mesa.h"
+#include "r128_xmesa.h"
+#include "r128_context.h"
+#include "r128_lock.h"
+#include "r128_state.h"
+#include "r128_reg.h"
+
+#if 1
+/* FIXME: FOR TESTING A SIMPLE DRAWING FUNCTION */
+static void pfunc(GLcontext *ctx, GLuint first, GLuint last) {}
+static void lfunc(GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv) {}
+static void tfunc(GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint pv)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ unsigned char *R128MMIO = r128ctx->r128Screen->mmio;
+ static int x, y;
+
+ x = ctx->VB->Win.data[v1][0];
+ y = ctx->VB->Win.data[v1][1];
+
+ LOCK_HARDWARE(r128ctx);
+
+#if 0
+ /* This is handled in r128UpdateState (below) */
+ R128WaitForIdle(r128ctx->r128Screen);
+ OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_192_DWORD_CCE_PIO);
+ (void)INREG(R128_PM4_BUFFER_ADDR);
+ OUTREG(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN);
+#endif
+
+ OUTREG(R128_PM4_FIFO_DATA_EVEN, R128_CCE_PACKET3_CNTL_PAINT | (3 << 16));
+ OUTREG(R128_PM4_FIFO_DATA_ODD, (R128_GMC_BRUSH_SOLID_COLOR
+ | R128_GMC_SRC_DATATYPE_COLOR
+ | (6 << 8) /* GMC_DST_DATATYPE(6=32bpp) */
+ | R128_ROP3_P));
+ OUTREG(R128_PM4_FIFO_DATA_EVEN, (random() / (double)RAND_MAX) * 16777216);
+ OUTREG(R128_PM4_FIFO_DATA_ODD, x | (y<<16));
+ OUTREG(R128_PM4_FIFO_DATA_EVEN, (x+10)|((y+10)<<16));
+ OUTREG(R128_PM4_FIFO_DATA_ODD, R128_CCE_PACKET2);
+
+#if 0
+ /* This is handled in the X server (R128SwapContextPrivate) */
+ R128CCEWaitForIdle(r128ctx->r128Screen);
+ OUTREGP(R128_PM4_BUFFER_DL_WPTR,
+ R128_PM4_BUFFER_DL_DONE, ~R128_PM4_BUFFER_DL_DONE);
+ OUTREG(R128_PM4_MICRO_CNTL, 0);
+ OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4);
+#endif
+
+ UNLOCK_HARDWARE(r128ctx);
+}
+static void qfunc(GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint v4, GLuint pv)
+{
+ tfunc(ctx, v1, v2, v4, pv);
+ tfunc(ctx, v2, v3, v4, pv);
+}
+
+static void r128DDUpdateState(GLcontext *ctx)
+{
+ ctx->Driver.PointsFunc = pfunc;
+ ctx->Driver.LineFunc = lfunc;
+ ctx->Driver.TriangleFunc = tfunc;
+ ctx->Driver.QuadFunc = qfunc;
+}
+#else
+static void r128DDUpdateState(GLcontext *ctx)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ ctx->Driver.PointsFunc = r128ctx->PointsFunc;
+ ctx->Driver.LineFunc = r128ctx->LineFunc;
+ ctx->Driver.TriangleFunc = r128ctx->TriangleFunc;
+ ctx->Driver.QuadFunc = r128ctx->QuadFunc;
+ ctx->Driver.RectFunc = NULL;
+}
+#endif
+
+static void r128DDUpdateHWState(GLcontext *ctx)
+{
+}
+
+static void r128DDClearColor(GLcontext *ctx,
+ GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+{
+}
+
+static void r128DDColor(GLcontext *ctx,
+ GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+{
+}
+
+static GLboolean r128DDSetBuffer(GLcontext *ctx, GLenum mode )
+{
+ if (mode == GL_FRONT_LEFT) {
+ return GL_TRUE;
+ } else if (mode == GL_BACK_LEFT) {
+ return GL_TRUE;
+ } else {
+ return GL_FALSE;
+ }
+}
+
+static GLboolean r128DDColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
+{
+ return GL_TRUE;
+}
+
+static GLint r128DDGetParameteri(const GLcontext *ctx, GLint param)
+{
+ return 0;
+}
+
+static void r128DDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
+{
+}
+
+static void r128DDBlendEquation(GLcontext *ctx, GLenum mode)
+{
+}
+
+static void r128DDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
+{
+}
+
+static void r128DDBlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA,
+ GLenum dfactorA)
+{
+}
+
+static void r128DDDepthFunc(GLcontext *ctx, GLenum func)
+{
+}
+
+static void r128DDDepthMask(GLcontext *ctx, GLboolean flag)
+{
+}
+
+static void r128DDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
+{
+ switch (cap) {
+ default:
+ break;
+ }
+}
+
+static void r128DDLightModelfv(GLcontext *ctx, GLenum pname,
+ const GLfloat *param)
+{
+}
+
+static void r128DDScissor(GLcontext *ctx,
+ GLint x, GLint y, GLsizei w, GLsizei h)
+{
+}
+
+void r128DDInitStateFuncs(GLcontext *ctx)
+{
+ ctx->Driver.UpdateState = r128DDUpdateState;
+
+ ctx->Driver.ClearIndex = NULL;
+ ctx->Driver.ClearColor = r128DDClearColor;
+ ctx->Driver.Index = NULL;
+ ctx->Driver.Color = r128DDColor;
+ ctx->Driver.SetBuffer = r128DDSetBuffer;
+
+ ctx->Driver.IndexMask = NULL;
+ ctx->Driver.ColorMask = r128DDColorMask;
+ ctx->Driver.LogicOp = NULL;
+ ctx->Driver.Dither = NULL;
+
+ ctx->Driver.NearFar = NULL;
+ ctx->Driver.GetParameteri = r128DDGetParameteri;
+
+ ctx->Driver.RenderStart = r128DDUpdateHWState;
+ ctx->Driver.RenderFinish = NULL;
+ ctx->Driver.RasterSetup = NULL;
+
+ ctx->Driver.RenderVBClippedTab = NULL;
+ ctx->Driver.RenderVBCulledTab = NULL;
+ ctx->Driver.RenderVBRawTab = NULL;
+
+ ctx->Driver.ReducedPrimitiveChange = NULL;
+ ctx->Driver.MultipassFunc = NULL;
+
+ ctx->Driver.AlphaFunc = r128DDAlphaFunc;
+ ctx->Driver.BlendEquation = r128DDBlendEquation;
+ ctx->Driver.BlendFunc = r128DDBlendFunc;
+ ctx->Driver.BlendFuncSeparate = r128DDBlendFuncSeparate;
+ ctx->Driver.CullFace = NULL;
+ ctx->Driver.FrontFace = NULL;
+ ctx->Driver.DepthFunc = r128DDDepthFunc;
+ ctx->Driver.DepthMask = r128DDDepthMask;
+ ctx->Driver.DepthRange = NULL;
+ ctx->Driver.Enable = r128DDEnable;
+ ctx->Driver.Fogfv = NULL;
+ ctx->Driver.Hint = NULL;
+ ctx->Driver.Lightfv = NULL;
+ ctx->Driver.LightModelfv = r128DDLightModelfv;
+ ctx->Driver.LogicOpcode = NULL;
+ ctx->Driver.PolygonMode = NULL;
+ ctx->Driver.Scissor = r128DDScissor;
+ ctx->Driver.ShadeModel = NULL;
+ ctx->Driver.StencilFunc = NULL;
+ ctx->Driver.StencilMask = NULL;
+ ctx->Driver.StencilOp = NULL;
+ ctx->Driver.Viewport = NULL;
+}
+
+void r128DDInitState(r128ContextPtr r128ctx)
+{
+#if 0
+ int dst_bpp, pitch;
+
+ pitch = r128ctx->r128Screen->fbStride * r128ctx->r128Screen->bpp/8;
+
+ switch (r128ctx->r128Screen->bpp) {
+ case 8:
+ dst_bpp = DST_8BPP;
+ break;
+ case 16:
+ if (r128ctx->r128Screen->depth == 15) dst_bpp = DST_15BPP;
+ else dst_bpp = DST_16BPP;
+ break;
+ case 24:
+ dst_bpp = DST_24BPP;
+ break;
+ case 32:
+ dst_bpp = DST_32BPP;
+ break;
+ }
+
+ r128ctx->regs.scale_3d_cntl =
+ SCALE_3D_CNTL_SCALE_DITHER_ERR_DIFF |
+ SCALE_3D_CNTL_TEX_CACHE_SIZE_FULL |
+ SCALE_3D_CNTL_DITHER_INIT_RESET |
+ SCALE_3D_CNTL_ROUND_EN_OFF |
+ SCALE_3D_CNTL_TEX_CACHE_DIS_OFF |
+ SCALE_3D_CNTL_SCALE_3D_FN_TMAP_SHADE |
+ SCALE_3D_CNTL_SCALE_PIX_REP_BLEND |
+ SCALE_3D_CNTL_TEX_CACHE_SPLIT_OFF |
+ SCALE_3D_CNTL_APPLE_YUV_MODE_OFF |
+ SCALE_3D_CNTL_TEX_CACHE_PAL_MODE_OFF |
+ SCALE_3D_CNTL_ALPHA_COMB_FNC_ADD_CLAMP |
+ SCALE_3D_CNTL_FOG_TABLE_EN_ON |
+ SCALE_3D_CNTL_SIGNED_DST_CLAMP_OFF |
+ SCALE_3D_CNTL_ALPHA_BLEND_SRC_ONE |
+ SCALE_3D_CNTL_ALPHA_BLEND_DST_ZERO |
+ SCALE_3D_CNTL_ALPHA_TEST_OP_ALWAYS |
+ SCALE_3D_CNTL_COMPOSITE_SHADOW_CMP_EQUAL |
+ SCALE_3D_CNTL_COMPOSITE_SHADOW_EN_OFF |
+ SCALE_3D_CNTL_TEX_MAP_AEN_ON |
+ SCALE_3D_CNTL_TEX_CACHE_LINE_SIZE_8QW;
+
+ r128->regs.dst_pitch_offset_c = pitch << 21;
+
+ r128->regs.dp_gui_master_cntl =
+ GMC_SRC_PITCH_OFFSET_DEFAULT |
+ GMC_DST_PITCH_OFFSET_LEAVE |
+ GMC_SRC_CLIP_DEFAULT |
+ GMC_DST_CLIP_DEFAULT |
+ GMC_BRUSH_SOLIDCOLOR |
+ (dst_bpp << 8) |
+ GMC_SRC_DSTCOLOR |
+ GMC_BYTE_ORDER_MSB_TO_LSB |
+ GMC_DP_CONVERSION_TEMP_6500 |
+ ROP3_SRCCOPY |
+ GMC_DP_SRC_RECT |
+ GMC_3D_FCN_EN_SET |
+ GMC_DST_CLR_CMP_FCN_CLEAR |
+ GMC_AUX_CLIP_CLEAR |
+ GMC_WRITE_MASK_SET;
+
+ r128->regs.sc_top_left_c = 0x00000000;
+ r128->regs.sc_bottom_right_c = 0x1FFF1FFF;
+ r128->regs.z_offset_c = 0x00000000;
+ r128->regs.z_pitch_c = pitch;
+
+ r128->regs.z_sten_cntl_c =
+ Z_STEN_CNTL_Z_PIX_WIDTH_16 |
+ Z_STEN_CNTL_Z_TEST_LESSEQUAL |
+ Z_STEN_CNTL_STENCIL_TEST_ALWAYS |
+ Z_STEN_CNTL_STENCIL_S_FAIL_OP_KEEP |
+ Z_STEN_CNTL_STENCIL_ZPASS_OP_KEEP |
+ Z_STEN_CNTL_STENCIL_ZFAIL_OP_KEEP;
+
+ r128->regs.tex_cntl_c =
+ TEX_CNTL_Z_EN_OFF |
+ TEX_CNTL_Z_MASK_EN |
+ TEX_CNTL_STENCIL_EN_OFF |
+ TEX_CNTL_TEX_EN_SHADE |
+ TEX_CNTL_SECONDARY_TEX_EN_OFF |
+ TEX_CNTL_FOG_EN_OFF |
+ TEX_CNTL_DITHRE_EN_OFF |
+ TEX_CNTL_ALPHA_EN_OFF |
+ TEX_CNTL_ALPHA_TEST_EN_OFF |
+ TEX_CNTL_SPEC_LIGHT_EN_OFF |
+ TEX_CNTL_TEX_CHROMA_KEY_EN_OFF |
+ TEX_CNTL_AMASK_EN_OFF |
+ TEX_CNTL_LIGHT_FN_DIS |
+ TEX_CNTL_ALPHA_LIGHT_FN_DIS |
+ TEX_CNTL_TEX_CACHE_FLUSH_OFF |
+ (0xfL << 24);
+
+ r128->regs.misc_3d_state_cntl_reg =
+ MISC_3D_STATE_SCALE_3D_FN_TMAP_SHADE |
+ MISC_3D_STATE_SCALE_PIX_REP_REPLICATE |
+ MISC_3D_STATE_ALPHA_COMB_FNC_ADD_CLAMP |
+ MISC_3D_STATE_FOG_TABLE_EN_TABLE_FOG |
+ MISC_3D_STATE_ALPHA_BLEND_SRC_ONE |
+ MISC_3D_STATE_ALPHA_BLEND_DST_ZERO |
+ MISC_3D_STATE_ALPHA_TEST_OP_ALWAYS;
+
+ r128->regs.texture_clr_cmp_clr_c = 0x00000000;
+ r128->regs.texture_clr_cmp_msk_c = 0xffffffff;
+ r128->regs.fog_color_c = 0x00808080;
+
+ r128->regs.prim_tex_cntl_c =
+ PRIM_TEX_CNTL_PRIM_MIN_BLEND_FN_NEAREST |
+ PRIM_TEX_CNTL_PRIM_MAG_BLEND_FN_NEAREST |
+ PRIM_TEX_CNTL_MIP_MAP_DIS_ON |
+ PRIM_TEX_CNTL_PRIM_TEX_CLAMP_MODE_S_WRAP |
+ PRIM_TEX_CNTL_PRIM_TEX_WRAP_S_OFF |
+ PRIM_TEX_CNTL_PRIM_TEX_CLAMP_MODE_T_WRAP |
+ PRIM_TEX_CNTL_PRIM_TEX_WRAP_T_OFF |
+ PRIM_TEX_CNTL_PRIM_TEX_PERSPECTIVE_DIS_OFF;
+
+ r128->regs.prim_texture_combine_cntl_c =
+ TEX_COMBINE_CNTL_COMB_FNC_MODULATE |
+ TEX_COMBINE_CNTL_COLOR_FACTOR_TEX |
+ TEX_COMBINE_CNTL_INPUT_FACTOR_INT_COLOR |
+ TEX_COMBINE_CNTL_COMB_FNC_ALPHA_COPY |
+ TEX_COMBINE_CNTL_ALPHA_FACTOR_TEX_ALPHA |
+ TEX_COMBINE_CNTL_INP_FACTOR_ALPHA_INT_ALPHA;
+
+ r128->regs.tex_size_pitch_c = 0x00000000;
+ r128->regs.prim_tex_0_offset_c = 0x00000000;
+ r128->regs.prim_tex_1_offset_c = 0x00000000;
+ r128->regs.prim_tex_2_offset_c = 0x00000000;
+ r128->regs.prim_tex_3_offset_c = 0x00000000;
+ r128->regs.prim_tex_4_offset_c = 0x00000000;
+ r128->regs.prim_tex_5_offset_c = 0x00000000;
+ r128->regs.prim_tex_6_offset_c = 0x00000000;
+ r128->regs.prim_tex_7_offset_c = 0x00000000;
+ r128->regs.prim_tex_8_offset_c = 0x00000000;
+ r128->regs.prim_tex_9_offset_c = 0x00000000;
+ r128->regs.prim_tex_10_offset_c = 0x00000000;
+
+ r128->regs.sec_tex_cntl_c =
+ SEC_TEX_CNTL_SEC_SRC_SEL_ST_0;
+
+ r128->regs.sec_tex_combine_cntl_c =
+ TEX_COMBINE_CNTL_COMB_FNC_DIS |
+ TEX_COMBINE_CNTL_COLOR_FACTOR_TEX |
+ TEX_COMBINE_CNTL_INPUT_FACTOR_PREV_COLOR |
+ TEX_COMBINE_CNTL_COMB_FNC_ALPHA_DIS |
+ TEX_COMBINE_CNTL_ALPHA_FACTOR_TEX_ALPHA |
+ TEX_COMBINE_CNTL_INP_FACTOR_ALPHA_PREV_ALPHA;
+
+ r128->regs.sec_tex_0_offset_c = 0x00000000;
+ r128->regs.sec_tex_1_offset_c = 0x00000000;
+ r128->regs.sec_tex_2_offset_c = 0x00000000;
+ r128->regs.sec_tex_3_offset_c = 0x00000000;
+ r128->regs.sec_tex_4_offset_c = 0x00000000;
+ r128->regs.sec_tex_5_offset_c = 0x00000000;
+ r128->regs.sec_tex_6_offset_c = 0x00000000;
+ r128->regs.sec_tex_7_offset_c = 0x00000000;
+ r128->regs.sec_tex_8_offset_c = 0x00000000;
+ r128->regs.sec_tex_9_offset_c = 0x00000000;
+ r128->regs.sec_tex_10_offset_c = 0x00000000;
+
+ r128->regs.constant_color_c = 0x00ffffff;
+ r128->regs.prim_texture_border_color_c = 0x00ffffff;
+ r128->regs.sec_texture_border_color_c = 0x00ffffff;
+ r128->regs.sten_ref_mask_c = 0xffff0000;
+ r128->regs.plane_3d_mask_c = 0xffffffff;
+
+ r128->regs.setup_cntl =
+ SETUP_CNTL_DONT_START_TRI_OFF |
+ SETUP_CNTL_DONT_START_ANY_OFF |
+ SETUP_CNTL_COLOR_FNC_GOURAUD |
+ SETUP_CNTL_PRIM_TYPE_SELECT_TRI |
+ SETUP_CNTL_TEXTURE_ST_FORMAT_MULT_W |
+ SETUP_CNTL_STARTING_VERTEX_SELECT_1 |
+ SETUP_CNTL_ENDING_VERTEX_SELECT_3 |
+ SETUP_CNTL_SU_POLY_LINE_NOT_LAST |
+ SETUP_CNTL_SUB_PIX_AMOUNT_4BITS;
+
+ r128->regs.pm4_vc_fpu_setup =
+ PM4_VC_FPU_SETUP_FRONT_DIR_CW |
+ PM4_VC_FPU_SETUP_BACKFACE_CULLING_FN_CULL |
+ PM4_VC_FPU_SETUP_FRONTFACE_CULLING_FN_REV_SOLID |
+ PM4_VC_FPU_SETUP_PM4_COLOR_FCN_GOURAUD |
+ PM4_VC_FPU_SETUP_PM4_SUB_PIX_AMOUNT_4BITS |
+ PM4_VC_FPU_SETUP_FPU_MODE_3D |
+ PM4_VC_FPU_SETUP_TRAP_DISABLE_ON |
+ PM4_VC_FPU_SETUP_EDGE_ANTIALIAS_OFF |
+ PM4_VC_FPU_SETUP_SUPERSAMPLE_OFF |
+ PM4_VC_FPU_SETUP_XFACTOR_2 |
+ PM4_VC_FPU_SETUP_YFACTOR_2 |
+ PM4_VC_FPU_SETUP_FLAT_SHADE_VERTEX_D3D |
+ PM4_VC_FPU_SETUP_FPU_ROUND_EN_OFF |
+ PM4_VC_FPU_SETUP_VC_WM_SEL_8DW;
+
+ r128->regs.fog_3d_table_start = 0x00000000;
+ r128->regs.fog_3d_table_end = 0xffffffff;
+ r128->regs.fog_3d_table_density = 0x00000000;
+#endif
+}
+
+void r128UpdateState(r128ContextPtr r128ctx)
+{
+ unsigned char *R128MMIO = r128ctx->r128Screen->mmio;
+
+ if (r128ctx->dirty & R128_REQUIRE_QUIESCENCE) {
+ R128WaitForIdle(r128ctx->r128Screen); /* FIXME */
+ }
+
+ if (r128ctx->dirty & R128_START_CCE) {
+ OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_192_DWORD_CCE_PIO);
+ (void)INREG(R128_PM4_BUFFER_ADDR);
+ OUTREG(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN);
+ }
+
+ if (r128ctx->dirty & R128_UPDATE_CONTEXT) {
+ }
+
+ if (r128ctx->dirty & R128_UPDATE_CLIPRECTS) {
+ }
+
+ r128ctx->dirty = R128_CLEAN;
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_state.h b/xc/lib/GL/mesa/src/drv/r128/r128_state.h
new file mode 100644
index 000000000..b81bc9901
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_state.h
@@ -0,0 +1,46 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_STATE_H_
+#define _R128_STATE_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void r128DDInitState(r128ContextPtr r128ctx);
+extern void r128DDInitStateFuncs(GLcontext *ctx);
+
+extern void r128UpdateState(r128ContextPtr r128ctx);
+
+#endif
+#endif /* _R128_STATE_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tex.c b/xc/lib/GL/mesa/src/drv/r128/r128_tex.c
new file mode 100644
index 000000000..75b08e527
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tex.c
@@ -0,0 +1,94 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#include "r128_init.h"
+#include "r128_mesa.h"
+#include "r128_tex.h"
+
+static void r128DDTexEnv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+{
+}
+
+static void r128DDTexImage(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj, GLint level,
+ GLint internalFormat,
+ const struct gl_texture_image *image)
+{
+}
+
+static void r128DDTexSubImage(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLint internalFormat,
+ const struct gl_texture_image *image)
+{
+}
+
+static void r128DDTexParameter(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params)
+{
+}
+
+static void r128DDBindTexture(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj)
+{
+}
+
+static void r128DDDeleteTexture(GLcontext *ctx,
+ struct gl_texture_object *tObj)
+{
+}
+
+static GLboolean r128DDIsTextureResident(GLcontext *ctx,
+ struct gl_texture_object *t)
+{
+ return GL_TRUE;
+}
+
+void r128DDInitTextureFuncs(GLcontext *ctx)
+{
+ ctx->Driver.TexEnv = r128DDTexEnv;
+ ctx->Driver.TexImage = r128DDTexImage;
+ ctx->Driver.TexSubImage = r128DDTexSubImage;
+ ctx->Driver.TexParameter = r128DDTexParameter;
+ ctx->Driver.BindTexture = r128DDBindTexture;
+ ctx->Driver.DeleteTexture = r128DDDeleteTexture;
+ ctx->Driver.UpdateTexturePalette = NULL;
+ ctx->Driver.UseGlobalTexturePalette = NULL;
+ ctx->Driver.ActiveTexture = NULL;
+ ctx->Driver.IsTextureResident = r128DDIsTextureResident;
+ ctx->Driver.PrioritizeTexture = NULL;
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tex.h b/xc/lib/GL/mesa/src/drv/r128/r128_tex.h
new file mode 100644
index 000000000..6543435a5
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tex.h
@@ -0,0 +1,43 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_TEX_H_
+#define _R128_TEX_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void r128DDInitTextureFuncs(GLcontext *ctx);
+
+#endif
+#endif /* _R128_TEX_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c b/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c
new file mode 100644
index 000000000..b884713b2
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c
@@ -0,0 +1,402 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifdef GLX_DIRECT_RENDERING
+
+/* r128 DDX driver includes */
+#include "r128_dri.h"
+
+/* r128 Mesa driver includes */
+#include "r128_init.h"
+#include "r128_context.h"
+#include "r128_xmesa.h"
+#include "r128_dd.h"
+#include "r128_state.h"
+#include "r128_span.h"
+#include "r128_depth.h"
+#include "r128_tex.h"
+
+/* Mesa src includes */
+#include "context.h"
+#if 0
+#include "vbxform.h"
+#include "matrix.h"
+#endif
+
+#ifdef DEBUG_LOCKING
+char *prevLockFile = NULL;
+int prevLockLine = 0;
+#endif
+
+r128ContextPtr r128Context = NULL;
+
+static int count_bits(unsigned int n)
+{
+ int bits = 0;
+
+ while (n > 0) {
+ if (n & 1) bits++;
+ n >>= 1;
+ }
+ return bits;
+}
+
+GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
+{
+ r128ScreenPtr r128Screen;
+ R128DRIPtr r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv;
+
+ /* Allocate the private area */
+ r128Screen = (r128ScreenPtr)Xmalloc(sizeof(*r128Screen));
+ if (!r128Screen) return GL_FALSE;
+
+ r128Screen->mmioRgn.handle = r128DRIPriv->registerHandle;
+ r128Screen->mmioRgn.size = r128DRIPriv->registerSize;
+ if (drmMap(sPriv->fd,
+ r128Screen->mmioRgn.handle,
+ r128Screen->mmioRgn.size,
+ (drmAddressPtr)&r128Screen->mmio)) {
+ Xfree(r128Screen);
+ return GL_FALSE;
+ }
+
+ r128Screen->agpRgn.handle = r128DRIPriv->agpHandle;
+ r128Screen->agpRgn.size = r128DRIPriv->agpSize;
+ if (drmMap(sPriv->fd,
+ r128Screen->agpRgn.handle,
+ r128Screen->agpRgn.size,
+ (drmAddressPtr)&r128Screen->agp)) {
+ drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size);
+ Xfree(r128Screen);
+ return GL_FALSE;
+ }
+
+ r128Screen->deviceID = r128DRIPriv->deviceID;
+
+ r128Screen->width = r128DRIPriv->width;
+ r128Screen->height = r128DRIPriv->height;
+ r128Screen->depth = r128DRIPriv->depth;
+ r128Screen->bpp = r128DRIPriv->bpp;
+
+ r128Screen->fb = sPriv->pFB;
+ r128Screen->fbOffset = sPriv->fbOrigin;
+ r128Screen->fbStride = sPriv->fbStride;
+ r128Screen->fbSize = sPriv->fbSize;
+
+ r128Screen->backOffset = r128DRIPriv->backOffset;
+ r128Screen->depthOffset = r128DRIPriv->depthOffset;
+ r128Screen->textureOffset = r128DRIPriv->textureOffset;
+ r128Screen->textureSize = r128DRIPriv->textureSize;
+
+ r128Screen->ringStart = r128DRIPriv->ringStart;
+ r128Screen->ringSize = r128DRIPriv->ringSize;
+ r128Screen->ringWritePtr = &r128DRIPriv->ringWrite;
+ r128Screen->ringReadPtr = (int *)(r128Screen->agp
+ + r128DRIPriv->ringReadOffset);
+
+ r128Screen->CCEFifoSize = r128DRIPriv->CCEFifoSize;
+
+ r128Screen->CCEMode = r128DRIPriv->CCEMode;
+
+ r128Screen->driScreen = sPriv;
+
+ sPriv->private = (void *)r128Screen;
+
+ return GL_TRUE;
+}
+
+void XMesaResetDriver(__DRIscreenPrivate *sPriv)
+{
+ r128ScreenPtr r128Screen = (r128ScreenPtr)sPriv->private;
+
+ drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size);
+ drmUnmap((drmAddress)r128Screen->agp, r128Screen->agpRgn.size);
+
+ Xfree(r128Screen);
+ sPriv->private = NULL;
+}
+
+XMesaVisual XMesaCreateVisual(XMesaDisplay *display,
+ XMesaVisualInfo visinfo,
+ GLboolean rgb_flag,
+ GLboolean alpha_flag,
+ GLboolean db_flag,
+ GLboolean stereo_flag,
+ GLboolean ximage_flag,
+ GLint depth_size,
+ GLint stencil_size,
+ GLint accum_size,
+ GLint level)
+{
+ XMesaVisual v;
+
+ /* FIXME: Only RGB visuals are currently supported */
+ if (!rgb_flag) return NULL;
+
+ v = (XMesaVisual)Xmalloc(sizeof(*v));
+ if (!v) return NULL;
+
+ v->visinfo = (XVisualInfo *)Xmalloc(sizeof(*visinfo));
+ if(!v->visinfo) {
+ Xfree(v);
+ return NULL;
+ }
+ memcpy(v->visinfo, visinfo, sizeof(*visinfo));
+
+ v->display = display;
+ v->level = level;
+
+ v->gl_visual = (GLvisual *)Xmalloc(sizeof(v->gl_visual));
+ if (!v->gl_visual) {
+ Xfree(v->visinfo);
+ XFree(v);
+ return NULL;
+ }
+
+ v->gl_visual->RGBAflag = rgb_flag;
+ v->gl_visual->DBflag = db_flag;
+ v->gl_visual->StereoFlag = stereo_flag;
+
+ v->gl_visual->RedBits = count_bits(visinfo->red_mask);
+ v->gl_visual->GreenBits = count_bits(visinfo->green_mask);
+ v->gl_visual->BlueBits = count_bits(visinfo->blue_mask);
+ v->gl_visual->AlphaBits = 0; /* Not currently supported */
+
+ v->gl_visual->AccumBits = accum_size;
+ v->gl_visual->DepthBits = depth_size;
+ v->gl_visual->StencilBits = stencil_size;
+
+ return v;
+}
+
+void XMesaDestroyVisual(XMesaVisual v)
+{
+ Xfree(v->gl_visual);
+ Xfree(v->visinfo);
+ Xfree(v);
+}
+
+XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list,
+ __DRIcontextPrivate *driContextPriv)
+{
+ XMesaContext c;
+ r128ContextPtr r128ctx;
+ GLcontext *shareCtx, *glCtx;
+
+ c = (XMesaContext)Xmalloc(sizeof(*c));
+ if (!c) {
+ return NULL;
+ }
+
+ r128ctx = (r128ContextPtr)Xmalloc(sizeof(*r128ctx));
+ if (!r128ctx) {
+ Xfree(c);
+ return NULL;
+ }
+
+ /* Initialize XMesaContext */
+ c->display = v->display;
+ c->xm_visual = v;
+ c->xm_buffer = NULL; /* Set by MakeCurrent */
+ c->driContextPriv = driContextPriv;
+ c->private = (void *)r128ctx;
+
+ if (share_list)
+ shareCtx = ((r128ContextPtr)(share_list->private))->glCtx;
+ else
+ shareCtx = NULL;
+
+ /* Initialize r128Context */
+ r128ctx->xmCtx = c;
+ r128ctx->glCtx = gl_create_context(v->gl_visual,
+ shareCtx,
+ (void *)r128ctx,
+ GL_TRUE);
+ r128ctx->display = v->display;
+ r128ctx->driContext = driContextPriv;
+ r128ctx->driDrawable = NULL; /* Set by XMesaMakeCurrent */
+ r128ctx->dirty = R128_ALL_DIRTY;
+ r128ctx->needClip = GL_TRUE;
+ r128ctx->r128Screen =
+ (r128ScreenPtr)(driContextPriv->driScreenPriv->private);
+
+ /* Initialize GLcontext */
+ glCtx = r128ctx->glCtx;
+
+ r128DDInitExtensions(glCtx);
+
+ r128DDInitDriverFuncs(glCtx);
+ r128DDInitStateFuncs(glCtx);
+ r128DDInitSpanFuncs(glCtx);
+ r128DDInitDepthFuncs(glCtx);
+ r128DDInitTextureFuncs(glCtx);
+
+ /* FIXME: Move to r128_tris.c */
+ glCtx->Driver.TriangleCaps = (DD_TRI_CULL
+ | DD_TRI_LIGHT_TWOSIDE
+ | DD_TRI_OFFSET);
+ glCtx->TriangleCaps |= DD_CLIP_FOG_COORD;
+
+ r128DDInitState(r128ctx);
+
+ return c;
+}
+
+void XMesaDestroyContext(XMesaContext c)
+{
+ r128ContextPtr r128ctx = (r128ContextPtr)c->private;
+
+ if (r128ctx) {
+ gl_destroy_context(r128ctx->glCtx);
+ Xfree(r128ctx);
+ c->private = NULL;
+ }
+
+ if (c->private == (void *)r128Context) {
+ r128Context = NULL;
+ }
+}
+
+XMesaBuffer XMesaCreateWindowBuffer(XMesaVisual v,
+ XMesaWindow w,
+ __DRIdrawablePrivate *driDrawPriv)
+{
+ XMesaBuffer xm_buf;
+
+ xm_buf = (XMesaBuffer)Xmalloc(sizeof(*xm_buf));
+ xm_buf->gl_buffer = gl_create_framebuffer(v->gl_visual);
+ xm_buf->driDrawPriv = driDrawPriv;
+
+ return xm_buf;
+}
+
+XMesaBuffer XMesaCreatePixmapBuffer(XMesaVisual v,
+ XMesaPixmap p,
+ XMesaColormap c,
+ __DRIdrawablePrivate *driDrawPriv)
+{
+ XMesaBuffer xm_buf;
+
+ xm_buf = (XMesaBuffer)Xmalloc(sizeof(*xm_buf));
+ xm_buf->gl_buffer = gl_create_framebuffer(v->gl_visual);
+ xm_buf->driDrawPriv = driDrawPriv;
+
+ return xm_buf;
+}
+
+void XMesaDestroyBuffer(XMesaBuffer b)
+{
+ gl_destroy_framebuffer(b->gl_buffer);
+ Xfree(b);
+}
+
+void XMesaSwapBuffers(XMesaBuffer b)
+{
+ /*
+ ** FIXME: This assumes buffer is currently bound to a context.
+ ** This needs to be able to swap buffers when not currently bound.
+ */
+ if (r128Context == NULL) return;
+
+#if 0
+ r128SwapBuffers(r128Context);
+#endif
+}
+
+GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b)
+{
+ if (c) {
+ r128ContextPtr oldCtx = r128Context;
+
+ if (r128Context
+ && c->private == (void *)r128Context
+ && b->driDrawPriv == r128Context->driDrawable) return GL_TRUE;
+
+ r128Context = (r128ContextPtr)c->private;
+
+ if (oldCtx) {
+ r128Context->dirty = R128_REQUIRE_QUIESCENCE | R128_START_CCE;
+ if (oldCtx != r128Context)
+ r128Context->dirty |= R128_UPDATE_CONTEXT;
+ if (oldCtx->driDrawable != b->driDrawPriv)
+ r128Context->dirty |= R128_UPDATE_CLIPRECTS;
+ } else {
+ r128Context->dirty = R128_ALL_DIRTY;
+ }
+
+ r128Context->driDrawable = b->driDrawPriv;
+
+ gl_make_current(r128Context->glCtx, b->gl_buffer);
+
+ if (!r128Context->glCtx->Viewport.Width) {
+ gl_Viewport(r128Context->glCtx, 0, 0,
+ b->driDrawPriv->w, b->driDrawPriv->h);
+ }
+ } else {
+ gl_make_current(0,0);
+ r128Context = NULL;
+ }
+
+ return GL_TRUE;
+}
+
+void XMesaUpdateState(XMesaContext c)
+{
+ r128ContextPtr r128ctx = (r128ContextPtr)c->private;
+ __DRIdrawablePrivate *dPriv = r128ctx->driDrawable;
+ __DRIscreenPrivate *sPriv = r128ctx->r128Screen->driScreen;
+ int stamp = dPriv->lastStamp;
+
+ /*
+ * The window might have moved, so we might need to get new
+ * cliprects.
+ *
+ * NOTE: This releases and regrabs the hw lock, so all state
+ * checking must be done *after* this call.
+ */
+ XMESA_VALIDATE_DRAWABLE_INFO(r128ctx->display, sPriv, dPriv);
+
+ r128ctx->dirty |= R128_ALL_DIRTY; /* FIXME: Optimize this!! */
+
+ if (stamp != dPriv->lastStamp) { /* FIXME: handle window moves */
+ r128ctx->dirty |= R128_UPDATE_CLIPRECTS;
+#if 0
+ r128MoveWindow(r128ctx);
+#endif
+ }
+
+ if (r128ctx->dirty) r128UpdateState(r128ctx);
+}
+
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.h b/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.h
new file mode 100644
index 000000000..5277485e6
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.h
@@ -0,0 +1,43 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_XMESA_H_
+#define _R128_XMESA_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void XMesaUpdateState(XMesaContext c);
+
+#endif
+#endif /* _R128_XMESA_H_ */