summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xc/config/cf/host.def11
-rw-r--r--xc/config/cf/xfree86.cf7
-rw-r--r--xc/extras/Mesa/src/context.c10
-rw-r--r--xc/include/GL/gl.h2294
-rw-r--r--xc/include/GL/glx.h3
-rw-r--r--xc/include/GL/glxtokens.h3
-rw-r--r--xc/lib/GL/Imakefile17
-rw-r--r--xc/lib/GL/dri/drm/Imakefile9
-rw-r--r--xc/lib/GL/mesa/src/drv/Imakefile4
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/Imakefile325
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_cce.c389
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_cce.h142
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_ccevb.h224
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_clear.c248
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_clear.h47
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_context.c203
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_context.h219
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_dd.c182
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_dd.h44
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c551
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_fastpath.h48
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h155
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_init.h92
-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_pipeline.c126
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h43
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_screen.c258
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_screen.h129
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_span.c329
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_span.h44
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_state.c1309
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_state.h50
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_swap.c125
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_swap.h43
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tex.c1852
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tex.h82
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_texobj.h87
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tris.c548
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tris.h76
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h327
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_vb.c470
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_vb.h150
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c257
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_xmesa.h44
-rw-r--r--xc/programs/Xserver/GL/dri/dri.c8
-rw-r--r--xc/programs/Xserver/Imakefile2
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml7
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile21
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h113
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c102
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c111
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c1242
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h116
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h54
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c447
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h600
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h77
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/Imakefile31
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile14
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel2
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux12
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c2
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h14
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h14
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c309
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c214
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c908
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h111
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c737
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h226
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c31
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c7
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c199
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h14
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h80
78 files changed, 15115 insertions, 2473 deletions
diff --git a/xc/config/cf/host.def b/xc/config/cf/host.def
index c4b69ffed..8b164f632 100644
--- a/xc/config/cf/host.def
+++ b/xc/config/cf/host.def
@@ -2,7 +2,7 @@
#define DefaultGcc2i386Opt -O2
#define LibraryCDebugFlags -O2
#define BuildServersOnly YES
-#define XF86CardDrivers vga tdfx i810 mga
+#define XF86CardDrivers vga tdfx i810 mga r128
#define LinuxDistribution LinuxRedHat
#define GccWarningOptions -Wall -Wpointer-arith -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations \
@@ -17,9 +17,16 @@
/* #define GlxBuiltInTdfx YES */
/* #define GlxBuiltInI810 YES */
/* #define GlxBuiltInMga YES */
+/* #define GlxBuiltInR128 YES */
/* #define DoLoadableServer NO */
-#define SharedLibFont NO
+/* Optionally turn this on to change the place where you install the build */
+/* #define ProjectRoot /usr/XF86-main */
+
+/* Optionally turn this on to force the kernel modules to build */
+/* #define BuildXF86DRM YES */
+
+#define SharedLibFont NO
#define XnestServer NO
#define XVirtualFramebufferServer NO
#define XprtServer NO
diff --git a/xc/config/cf/xfree86.cf b/xc/config/cf/xfree86.cf
index 77e5e454d..e90ba8e4c 100644
--- a/xc/config/cf/xfree86.cf
+++ b/xc/config/cf/xfree86.cf
@@ -512,12 +512,15 @@ IPLAN2P8_DEFS = -DUSE_IPLAN2P8
# ifndef GlxBuiltInTdfx
# define GlxBuiltInTdfx NO
# endif
+# ifndef GlxBuiltInR128
+# define GlxBuiltInR128 NO
+# endif
-# if GlxBuiltInTdfx
+# if GlxBuiltInTdfx || GlxBuiltInR128
# define GlxDriverUsesMesa YES
# endif
-# if GlxBuiltInGamma || GlxBuiltInMesa || GlxBuiltInTdfx
+# if GlxBuiltInGamma || GlxBuiltInMesa || GlxBuiltInTdfx || GlxBuiltInR128
# define GlxUseBuiltInDRIDriver YES
# define DRIDynLoadDefines /**/
# else
diff --git a/xc/extras/Mesa/src/context.c b/xc/extras/Mesa/src/context.c
index 67ca90e3c..04c3e1c05 100644
--- a/xc/extras/Mesa/src/context.c
+++ b/xc/extras/Mesa/src/context.c
@@ -338,10 +338,18 @@ _mesa_create_visual( GLboolean rgbFlag,
vis->DepthMax = 1;
vis->DepthMaxF = 1.0F;
}
- else {
+ else if (depthBits < 32) {
vis->DepthMax = (1 << depthBits) - 1;
vis->DepthMaxF = (GLfloat) vis->DepthMax;
}
+ else {
+ /* Special case since shift values greater than or equal to the
+ * number of bits in the left hand expression's type are
+ * undefined.
+ */
+ vis->DepthMax = 0xffffffff;
+ vis->DepthMaxF = (GLfloat) vis->DepthMax;
+ }
return vis;
}
diff --git a/xc/include/GL/gl.h b/xc/include/GL/gl.h
deleted file mode 100644
index dd2e9c140..000000000
--- a/xc/include/GL/gl.h
+++ /dev/null
@@ -1,2294 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#ifndef __gl_h_
-#define __gl_h_
-
-#if defined(USE_MGL_NAMESPACE)
-#include "gl_mangle.h"
-#endif
-
-
-#if defined(__BEOS__)
-#include <stdlib.h> /* to get some BeOS-isms */
-#endif
-
-
-#if !defined(OPENSTEP) && (defined(NeXT) || defined(NeXT_PDO))
-#define OPENSTEP
-#endif
-
-
-/*
- * XXX move as many of these pragma's and MS Windows-isms into
- * the new src/glheader.h file.
- */
-
-#if defined(_WIN32) && !defined(__WIN32__)
-# define __WIN32__
-#endif
-
-#if !defined(OPENSTEP) && (defined(__WIN32__) || defined(__CYGWIN32__))
-# pragma warning( disable : 4068 ) /* unknown pragma */
-# pragma warning( disable : 4710 ) /* function 'foo' not inlined */
-# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
-# pragma warning( disable : 4127 ) /* conditional expression is constant */
-# if defined(MESA_MINWARN)
-# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
-# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
-# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
-# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
-# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
-# endif
-# if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
-# define GLAPI __declspec(dllexport)
-# define WGLAPI __declspec(dllexport)
-# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
-# define GLAPI __declspec(dllimport)
-# define WGLAPI __declspec(dllimport)
-# else /* for use with static link lib build of Win32 edition only */
-# define GLAPI extern
-# define WGLAPI __declspec(dllimport)
-# endif /* _STATIC_MESA support */
-# define GLAPIENTRY __stdcall
-# define GLAPIENTRYP __stdcall *
-# define GLCALLBACK __stdcall
-# define GLCALLBACKP __stdcall *
-# if defined(__CYGWIN32__)
-# define GLCALLBACKPCAST *
-# else
-# define GLCALLBACKPCAST __stdcall *
-# endif
-# define GLWINAPI __stdcall
-# define GLWINAPIV __cdecl
-#else
-/* non-Windows compilation */
-# define GLAPI extern
-# define GLAPIENTRY
-# define GLAPIENTRYP *
-# define GLCALLBACK
-# define GLCALLBACKP *
-# define GLCALLBACKPCAST *
-# define GLWINAPI
-# define GLWINAPIV
-#endif /* WIN32 / CYGWIN32 bracket */
-
-/* compatability guard so we don't need to change client code */
-
-#if defined(_WIN32) && !defined(_WINDEF_) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP)
-# define CALLBACK GLCALLBACK
-typedef int (GLAPIENTRY *PROC)();
-typedef void *HGLRC;
-typedef void *HDC;
-typedef unsigned long COLORREF;
-#endif
-
-#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP)
-# define WGL_FONT_LINES 0
-# define WGL_FONT_POLYGONS 1
-#ifndef _GNU_H_WINDOWS32_FUNCTIONS
-# ifdef UNICODE
-# define wglUseFontBitmaps wglUseFontBitmapsW
-# define wglUseFontOutlines wglUseFontOutlinesW
-# else
-# define wglUseFontBitmaps wglUseFontBitmapsA
-# define wglUseFontOutlines wglUseFontOutlinesA
-# endif /* !UNICODE */
-#endif /* _GNU_H_WINDOWS32_FUNCTIONS */
-typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR;
-typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT;
-typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
-#include <gl/mesa_wgl.h>
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#ifdef macintosh
- #pragma enumsalwaysint on
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-#endif
-
-
-
-#define GL_VERSION_1_1 1
-#define GL_VERSION_1_2 1
-#define GL_HAS_GLEXT 1
-
-
-
-/*
- *
- * Datatypes
- *
- */
-#ifdef CENTERLINE_CLPP
-#define signed
-#endif
-typedef unsigned int GLenum;
-typedef unsigned char GLboolean;
-typedef unsigned int GLbitfield;
-typedef void GLvoid;
-typedef signed char GLbyte; /* 1-byte signed */
-typedef short GLshort; /* 2-byte signed */
-typedef int GLint; /* 4-byte signed */
-typedef unsigned char GLubyte; /* 1-byte unsigned */
-typedef unsigned short GLushort; /* 2-byte unsigned */
-typedef unsigned int GLuint; /* 4-byte unsigned */
-typedef int GLsizei; /* 4-byte signed */
-typedef float GLfloat; /* single precision float */
-typedef float GLclampf; /* single precision float in [0,1] */
-typedef double GLdouble; /* double precision float */
-typedef double GLclampd; /* double precision float in [0,1] */
-
-
-
-/*
- *
- * Constants
- *
- */
-
-/* Boolean values */
-#define GL_FALSE 0x0
-#define GL_TRUE 0x1
-
-/* Data types */
-#define GL_BYTE 0x1400
-#define GL_UNSIGNED_BYTE 0x1401
-#define GL_SHORT 0x1402
-#define GL_UNSIGNED_SHORT 0x1403
-#define GL_INT 0x1404
-#define GL_UNSIGNED_INT 0x1405
-#define GL_FLOAT 0x1406
-#define GL_DOUBLE 0x140A
-#define GL_2_BYTES 0x1407
-#define GL_3_BYTES 0x1408
-#define GL_4_BYTES 0x1409
-
-/* Primitives */
-#define GL_POINTS 0x0000
-#define GL_LINES 0x0001
-#define GL_LINE_LOOP 0x0002
-#define GL_LINE_STRIP 0x0003
-#define GL_TRIANGLES 0x0004
-#define GL_TRIANGLE_STRIP 0x0005
-#define GL_TRIANGLE_FAN 0x0006
-#define GL_QUADS 0x0007
-#define GL_QUAD_STRIP 0x0008
-#define GL_POLYGON 0x0009
-
-/* Vertex Arrays */
-#define GL_VERTEX_ARRAY 0x8074
-#define GL_NORMAL_ARRAY 0x8075
-#define GL_COLOR_ARRAY 0x8076
-#define GL_INDEX_ARRAY 0x8077
-#define GL_TEXTURE_COORD_ARRAY 0x8078
-#define GL_EDGE_FLAG_ARRAY 0x8079
-#define GL_VERTEX_ARRAY_SIZE 0x807A
-#define GL_VERTEX_ARRAY_TYPE 0x807B
-#define GL_VERTEX_ARRAY_STRIDE 0x807C
-#define GL_NORMAL_ARRAY_TYPE 0x807E
-#define GL_NORMAL_ARRAY_STRIDE 0x807F
-#define GL_COLOR_ARRAY_SIZE 0x8081
-#define GL_COLOR_ARRAY_TYPE 0x8082
-#define GL_COLOR_ARRAY_STRIDE 0x8083
-#define GL_INDEX_ARRAY_TYPE 0x8085
-#define GL_INDEX_ARRAY_STRIDE 0x8086
-#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
-#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
-#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
-#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C
-#define GL_VERTEX_ARRAY_POINTER 0x808E
-#define GL_NORMAL_ARRAY_POINTER 0x808F
-#define GL_COLOR_ARRAY_POINTER 0x8090
-#define GL_INDEX_ARRAY_POINTER 0x8091
-#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
-#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093
-#define GL_V2F 0x2A20
-#define GL_V3F 0x2A21
-#define GL_C4UB_V2F 0x2A22
-#define GL_C4UB_V3F 0x2A23
-#define GL_C3F_V3F 0x2A24
-#define GL_N3F_V3F 0x2A25
-#define GL_C4F_N3F_V3F 0x2A26
-#define GL_T2F_V3F 0x2A27
-#define GL_T4F_V4F 0x2A28
-#define GL_T2F_C4UB_V3F 0x2A29
-#define GL_T2F_C3F_V3F 0x2A2A
-#define GL_T2F_N3F_V3F 0x2A2B
-#define GL_T2F_C4F_N3F_V3F 0x2A2C
-#define GL_T4F_C4F_N3F_V4F 0x2A2D
-
-/* Matrix Mode */
-#define GL_MATRIX_MODE 0x0BA0
-#define GL_MODELVIEW 0x1700
-#define GL_PROJECTION 0x1701
-#define GL_TEXTURE 0x1702
-
-/* Points */
-#define GL_POINT_SMOOTH 0x0B10
-#define GL_POINT_SIZE 0x0B11
-#define GL_POINT_SIZE_GRANULARITY 0x0B13
-#define GL_POINT_SIZE_RANGE 0x0B12
-
-/* Lines */
-#define GL_LINE_SMOOTH 0x0B20
-#define GL_LINE_STIPPLE 0x0B24
-#define GL_LINE_STIPPLE_PATTERN 0x0B25
-#define GL_LINE_STIPPLE_REPEAT 0x0B26
-#define GL_LINE_WIDTH 0x0B21
-#define GL_LINE_WIDTH_GRANULARITY 0x0B23
-#define GL_LINE_WIDTH_RANGE 0x0B22
-
-/* Polygons */
-#define GL_POINT 0x1B00
-#define GL_LINE 0x1B01
-#define GL_FILL 0x1B02
-#define GL_CW 0x0900
-#define GL_CCW 0x0901
-#define GL_FRONT 0x0404
-#define GL_BACK 0x0405
-#define GL_POLYGON_MODE 0x0B40
-#define GL_POLYGON_SMOOTH 0x0B41
-#define GL_POLYGON_STIPPLE 0x0B42
-#define GL_EDGE_FLAG 0x0B43
-#define GL_CULL_FACE 0x0B44
-#define GL_CULL_FACE_MODE 0x0B45
-#define GL_FRONT_FACE 0x0B46
-#define GL_POLYGON_OFFSET_FACTOR 0x8038
-#define GL_POLYGON_OFFSET_UNITS 0x2A00
-#define GL_POLYGON_OFFSET_POINT 0x2A01
-#define GL_POLYGON_OFFSET_LINE 0x2A02
-#define GL_POLYGON_OFFSET_FILL 0x8037
-
-/* Display Lists */
-#define GL_COMPILE 0x1300
-#define GL_COMPILE_AND_EXECUTE 0x1301
-#define GL_LIST_BASE 0x0B32
-#define GL_LIST_INDEX 0x0B33
-#define GL_LIST_MODE 0x0B30
-
-/* Depth buffer */
-#define GL_NEVER 0x0200
-#define GL_LESS 0x0201
-#define GL_EQUAL 0x0202
-#define GL_LEQUAL 0x0203
-#define GL_GREATER 0x0204
-#define GL_NOTEQUAL 0x0205
-#define GL_GEQUAL 0x0206
-#define GL_ALWAYS 0x0207
-#define GL_DEPTH_TEST 0x0B71
-#define GL_DEPTH_BITS 0x0D56
-#define GL_DEPTH_CLEAR_VALUE 0x0B73
-#define GL_DEPTH_FUNC 0x0B74
-#define GL_DEPTH_RANGE 0x0B70
-#define GL_DEPTH_WRITEMASK 0x0B72
-#define GL_DEPTH_COMPONENT 0x1902
-
-/* Lighting */
-#define GL_LIGHTING 0x0B50
-#define GL_LIGHT0 0x4000
-#define GL_LIGHT1 0x4001
-#define GL_LIGHT2 0x4002
-#define GL_LIGHT3 0x4003
-#define GL_LIGHT4 0x4004
-#define GL_LIGHT5 0x4005
-#define GL_LIGHT6 0x4006
-#define GL_LIGHT7 0x4007
-#define GL_SPOT_EXPONENT 0x1205
-#define GL_SPOT_CUTOFF 0x1206
-#define GL_CONSTANT_ATTENUATION 0x1207
-#define GL_LINEAR_ATTENUATION 0x1208
-#define GL_QUADRATIC_ATTENUATION 0x1209
-#define GL_AMBIENT 0x1200
-#define GL_DIFFUSE 0x1201
-#define GL_SPECULAR 0x1202
-#define GL_SHININESS 0x1601
-#define GL_EMISSION 0x1600
-#define GL_POSITION 0x1203
-#define GL_SPOT_DIRECTION 0x1204
-#define GL_AMBIENT_AND_DIFFUSE 0x1602
-#define GL_COLOR_INDEXES 0x1603
-#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
-#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
-#define GL_LIGHT_MODEL_AMBIENT 0x0B53
-#define GL_FRONT_AND_BACK 0x0408
-#define GL_SHADE_MODEL 0x0B54
-#define GL_FLAT 0x1D00
-#define GL_SMOOTH 0x1D01
-#define GL_COLOR_MATERIAL 0x0B57
-#define GL_COLOR_MATERIAL_FACE 0x0B55
-#define GL_COLOR_MATERIAL_PARAMETER 0x0B56
-#define GL_NORMALIZE 0x0BA1
-
-/* User clipping planes */
-#define GL_CLIP_PLANE0 0x3000
-#define GL_CLIP_PLANE1 0x3001
-#define GL_CLIP_PLANE2 0x3002
-#define GL_CLIP_PLANE3 0x3003
-#define GL_CLIP_PLANE4 0x3004
-#define GL_CLIP_PLANE5 0x3005
-
-/* Accumulation buffer */
-#define GL_ACCUM_RED_BITS 0x0D58
-#define GL_ACCUM_GREEN_BITS 0x0D59
-#define GL_ACCUM_BLUE_BITS 0x0D5A
-#define GL_ACCUM_ALPHA_BITS 0x0D5B
-#define GL_ACCUM_CLEAR_VALUE 0x0B80
-#define GL_ACCUM 0x0100
-#define GL_ADD 0x0104
-#define GL_LOAD 0x0101
-#define GL_MULT 0x0103
-#define GL_RETURN 0x0102
-
-/* Alpha testing */
-#define GL_ALPHA_TEST 0x0BC0
-#define GL_ALPHA_TEST_REF 0x0BC2
-#define GL_ALPHA_TEST_FUNC 0x0BC1
-
-/* Blending */
-#define GL_BLEND 0x0BE2
-#define GL_BLEND_SRC 0x0BE1
-#define GL_BLEND_DST 0x0BE0
-#define GL_ZERO 0x0
-#define GL_ONE 0x1
-#define GL_SRC_COLOR 0x0300
-#define GL_ONE_MINUS_SRC_COLOR 0x0301
-#define GL_DST_COLOR 0x0306
-#define GL_ONE_MINUS_DST_COLOR 0x0307
-#define GL_SRC_ALPHA 0x0302
-#define GL_ONE_MINUS_SRC_ALPHA 0x0303
-#define GL_DST_ALPHA 0x0304
-#define GL_ONE_MINUS_DST_ALPHA 0x0305
-#define GL_SRC_ALPHA_SATURATE 0x0308
-#define GL_CONSTANT_COLOR 0x8001
-#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
-#define GL_CONSTANT_ALPHA 0x8003
-#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
-
-/* Render Mode */
-#define GL_FEEDBACK 0x1C01
-#define GL_RENDER 0x1C00
-#define GL_SELECT 0x1C02
-
-/* Feedback */
-#define GL_2D 0x0600
-#define GL_3D 0x0601
-#define GL_3D_COLOR 0x0602
-#define GL_3D_COLOR_TEXTURE 0x0603
-#define GL_4D_COLOR_TEXTURE 0x0604
-#define GL_POINT_TOKEN 0x0701
-#define GL_LINE_TOKEN 0x0702
-#define GL_LINE_RESET_TOKEN 0x0707
-#define GL_POLYGON_TOKEN 0x0703
-#define GL_BITMAP_TOKEN 0x0704
-#define GL_DRAW_PIXEL_TOKEN 0x0705
-#define GL_COPY_PIXEL_TOKEN 0x0706
-#define GL_PASS_THROUGH_TOKEN 0x0700
-#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0
-#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1
-#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2
-
-/* Selection */
-#define GL_SELECTION_BUFFER_POINTER 0x0DF3
-#define GL_SELECTION_BUFFER_SIZE 0x0DF4
-
-/* Fog */
-#define GL_FOG 0x0B60
-#define GL_FOG_MODE 0x0B65
-#define GL_FOG_DENSITY 0x0B62
-#define GL_FOG_COLOR 0x0B66
-#define GL_FOG_INDEX 0x0B61
-#define GL_FOG_START 0x0B63
-#define GL_FOG_END 0x0B64
-#define GL_LINEAR 0x2601
-#define GL_EXP 0x0800
-#define GL_EXP2 0x0801
-
-/* Logic Ops */
-#define GL_LOGIC_OP 0x0BF1
-#define GL_INDEX_LOGIC_OP 0x0BF1
-#define GL_COLOR_LOGIC_OP 0x0BF2
-#define GL_LOGIC_OP_MODE 0x0BF0
-#define GL_CLEAR 0x1500
-#define GL_SET 0x150F
-#define GL_COPY 0x1503
-#define GL_COPY_INVERTED 0x150C
-#define GL_NOOP 0x1505
-#define GL_INVERT 0x150A
-#define GL_AND 0x1501
-#define GL_NAND 0x150E
-#define GL_OR 0x1507
-#define GL_NOR 0x1508
-#define GL_XOR 0x1506
-#define GL_EQUIV 0x1509
-#define GL_AND_REVERSE 0x1502
-#define GL_AND_INVERTED 0x1504
-#define GL_OR_REVERSE 0x150B
-#define GL_OR_INVERTED 0x150D
-
-/* Stencil */
-#define GL_STENCIL_TEST 0x0B90
-#define GL_STENCIL_WRITEMASK 0x0B98
-#define GL_STENCIL_BITS 0x0D57
-#define GL_STENCIL_FUNC 0x0B92
-#define GL_STENCIL_VALUE_MASK 0x0B93
-#define GL_STENCIL_REF 0x0B97
-#define GL_STENCIL_FAIL 0x0B94
-#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
-#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
-#define GL_STENCIL_CLEAR_VALUE 0x0B91
-#define GL_STENCIL_INDEX 0x1901
-#define GL_KEEP 0x1E00
-#define GL_REPLACE 0x1E01
-#define GL_INCR 0x1E02
-#define GL_DECR 0x1E03
-
-/* Buffers, Pixel Drawing/Reading */
-#define GL_NONE 0x0
-#define GL_LEFT 0x0406
-#define GL_RIGHT 0x0407
-/*GL_FRONT 0x0404 */
-/*GL_BACK 0x0405 */
-/*GL_FRONT_AND_BACK 0x0408 */
-#define GL_FRONT_LEFT 0x0400
-#define GL_FRONT_RIGHT 0x0401
-#define GL_BACK_LEFT 0x0402
-#define GL_BACK_RIGHT 0x0403
-#define GL_AUX0 0x0409
-#define GL_AUX1 0x040A
-#define GL_AUX2 0x040B
-#define GL_AUX3 0x040C
-#define GL_COLOR_INDEX 0x1900
-#define GL_RED 0x1903
-#define GL_GREEN 0x1904
-#define GL_BLUE 0x1905
-#define GL_ALPHA 0x1906
-#define GL_LUMINANCE 0x1909
-#define GL_LUMINANCE_ALPHA 0x190A
-#define GL_ALPHA_BITS 0x0D55
-#define GL_RED_BITS 0x0D52
-#define GL_GREEN_BITS 0x0D53
-#define GL_BLUE_BITS 0x0D54
-#define GL_INDEX_BITS 0x0D51
-#define GL_SUBPIXEL_BITS 0x0D50
-#define GL_AUX_BUFFERS 0x0C00
-#define GL_READ_BUFFER 0x0C02
-#define GL_DRAW_BUFFER 0x0C01
-#define GL_DOUBLEBUFFER 0x0C32
-#define GL_STEREO 0x0C33
-#define GL_BITMAP 0x1A00
-#define GL_COLOR 0x1800
-#define GL_DEPTH 0x1801
-#define GL_STENCIL 0x1802
-#define GL_DITHER 0x0BD0
-#define GL_RGB 0x1907
-#define GL_RGBA 0x1908
-
-/* Implementation limits */
-#define GL_MAX_LIST_NESTING 0x0B31
-#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35
-#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
-#define GL_MAX_NAME_STACK_DEPTH 0x0D37
-#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
-#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
-#define GL_MAX_EVAL_ORDER 0x0D30
-#define GL_MAX_LIGHTS 0x0D31
-#define GL_MAX_CLIP_PLANES 0x0D32
-#define GL_MAX_TEXTURE_SIZE 0x0D33
-#define GL_MAX_PIXEL_MAP_TABLE 0x0D34
-#define GL_MAX_VIEWPORT_DIMS 0x0D3A
-#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B
-
-/* Gets */
-#define GL_ATTRIB_STACK_DEPTH 0x0BB0
-#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1
-#define GL_COLOR_CLEAR_VALUE 0x0C22
-#define GL_COLOR_WRITEMASK 0x0C23
-#define GL_CURRENT_INDEX 0x0B01
-#define GL_CURRENT_COLOR 0x0B00
-#define GL_CURRENT_NORMAL 0x0B02
-#define GL_CURRENT_RASTER_COLOR 0x0B04
-#define GL_CURRENT_RASTER_DISTANCE 0x0B09
-#define GL_CURRENT_RASTER_INDEX 0x0B05
-#define GL_CURRENT_RASTER_POSITION 0x0B07
-#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06
-#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08
-#define GL_CURRENT_TEXTURE_COORDS 0x0B03
-#define GL_INDEX_CLEAR_VALUE 0x0C20
-#define GL_INDEX_MODE 0x0C30
-#define GL_INDEX_WRITEMASK 0x0C21
-#define GL_MODELVIEW_MATRIX 0x0BA6
-#define GL_MODELVIEW_STACK_DEPTH 0x0BA3
-#define GL_NAME_STACK_DEPTH 0x0D70
-#define GL_PROJECTION_MATRIX 0x0BA7
-#define GL_PROJECTION_STACK_DEPTH 0x0BA4
-#define GL_RENDER_MODE 0x0C40
-#define GL_RGBA_MODE 0x0C31
-#define GL_TEXTURE_MATRIX 0x0BA8
-#define GL_TEXTURE_STACK_DEPTH 0x0BA5
-#define GL_VIEWPORT 0x0BA2
-
-/* Evaluators */
-#define GL_AUTO_NORMAL 0x0D80
-#define GL_MAP1_COLOR_4 0x0D90
-#define GL_MAP1_GRID_DOMAIN 0x0DD0
-#define GL_MAP1_GRID_SEGMENTS 0x0DD1
-#define GL_MAP1_INDEX 0x0D91
-#define GL_MAP1_NORMAL 0x0D92
-#define GL_MAP1_TEXTURE_COORD_1 0x0D93
-#define GL_MAP1_TEXTURE_COORD_2 0x0D94
-#define GL_MAP1_TEXTURE_COORD_3 0x0D95
-#define GL_MAP1_TEXTURE_COORD_4 0x0D96
-#define GL_MAP1_VERTEX_3 0x0D97
-#define GL_MAP1_VERTEX_4 0x0D98
-#define GL_MAP2_COLOR_4 0x0DB0
-#define GL_MAP2_GRID_DOMAIN 0x0DD2
-#define GL_MAP2_GRID_SEGMENTS 0x0DD3
-#define GL_MAP2_INDEX 0x0DB1
-#define GL_MAP2_NORMAL 0x0DB2
-#define GL_MAP2_TEXTURE_COORD_1 0x0DB3
-#define GL_MAP2_TEXTURE_COORD_2 0x0DB4
-#define GL_MAP2_TEXTURE_COORD_3 0x0DB5
-#define GL_MAP2_TEXTURE_COORD_4 0x0DB6
-#define GL_MAP2_VERTEX_3 0x0DB7
-#define GL_MAP2_VERTEX_4 0x0DB8
-#define GL_COEFF 0x0A00
-#define GL_DOMAIN 0x0A02
-#define GL_ORDER 0x0A01
-
-/* Hints */
-#define GL_FOG_HINT 0x0C54
-#define GL_LINE_SMOOTH_HINT 0x0C52
-#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
-#define GL_POINT_SMOOTH_HINT 0x0C51
-#define GL_POLYGON_SMOOTH_HINT 0x0C53
-#define GL_DONT_CARE 0x1100
-#define GL_FASTEST 0x1101
-#define GL_NICEST 0x1102
-
-/* Scissor box */
-#define GL_SCISSOR_TEST 0x0C11
-#define GL_SCISSOR_BOX 0x0C10
-
-/* Pixel Mode / Transfer */
-#define GL_MAP_COLOR 0x0D10
-#define GL_MAP_STENCIL 0x0D11
-#define GL_INDEX_SHIFT 0x0D12
-#define GL_INDEX_OFFSET 0x0D13
-#define GL_RED_SCALE 0x0D14
-#define GL_RED_BIAS 0x0D15
-#define GL_GREEN_SCALE 0x0D18
-#define GL_GREEN_BIAS 0x0D19
-#define GL_BLUE_SCALE 0x0D1A
-#define GL_BLUE_BIAS 0x0D1B
-#define GL_ALPHA_SCALE 0x0D1C
-#define GL_ALPHA_BIAS 0x0D1D
-#define GL_DEPTH_SCALE 0x0D1E
-#define GL_DEPTH_BIAS 0x0D1F
-#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1
-#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0
-#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2
-#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3
-#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4
-#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5
-#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6
-#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7
-#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8
-#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9
-#define GL_PIXEL_MAP_S_TO_S 0x0C71
-#define GL_PIXEL_MAP_I_TO_I 0x0C70
-#define GL_PIXEL_MAP_I_TO_R 0x0C72
-#define GL_PIXEL_MAP_I_TO_G 0x0C73
-#define GL_PIXEL_MAP_I_TO_B 0x0C74
-#define GL_PIXEL_MAP_I_TO_A 0x0C75
-#define GL_PIXEL_MAP_R_TO_R 0x0C76
-#define GL_PIXEL_MAP_G_TO_G 0x0C77
-#define GL_PIXEL_MAP_B_TO_B 0x0C78
-#define GL_PIXEL_MAP_A_TO_A 0x0C79
-#define GL_PACK_ALIGNMENT 0x0D05
-#define GL_PACK_LSB_FIRST 0x0D01
-#define GL_PACK_ROW_LENGTH 0x0D02
-#define GL_PACK_SKIP_PIXELS 0x0D04
-#define GL_PACK_SKIP_ROWS 0x0D03
-#define GL_PACK_SWAP_BYTES 0x0D00
-#define GL_UNPACK_ALIGNMENT 0x0CF5
-#define GL_UNPACK_LSB_FIRST 0x0CF1
-#define GL_UNPACK_ROW_LENGTH 0x0CF2
-#define GL_UNPACK_SKIP_PIXELS 0x0CF4
-#define GL_UNPACK_SKIP_ROWS 0x0CF3
-#define GL_UNPACK_SWAP_BYTES 0x0CF0
-#define GL_ZOOM_X 0x0D16
-#define GL_ZOOM_Y 0x0D17
-
-/* Texture mapping */
-#define GL_TEXTURE_ENV 0x2300
-#define GL_TEXTURE_ENV_MODE 0x2200
-#define GL_TEXTURE_1D 0x0DE0
-#define GL_TEXTURE_2D 0x0DE1
-#define GL_TEXTURE_WRAP_S 0x2802
-#define GL_TEXTURE_WRAP_T 0x2803
-#define GL_TEXTURE_MAG_FILTER 0x2800
-#define GL_TEXTURE_MIN_FILTER 0x2801
-#define GL_TEXTURE_ENV_COLOR 0x2201
-#define GL_TEXTURE_GEN_S 0x0C60
-#define GL_TEXTURE_GEN_T 0x0C61
-#define GL_TEXTURE_GEN_MODE 0x2500
-#define GL_TEXTURE_BORDER_COLOR 0x1004
-#define GL_TEXTURE_WIDTH 0x1000
-#define GL_TEXTURE_HEIGHT 0x1001
-#define GL_TEXTURE_BORDER 0x1005
-#define GL_TEXTURE_COMPONENTS 0x1003
-#define GL_TEXTURE_RED_SIZE 0x805C
-#define GL_TEXTURE_GREEN_SIZE 0x805D
-#define GL_TEXTURE_BLUE_SIZE 0x805E
-#define GL_TEXTURE_ALPHA_SIZE 0x805F
-#define GL_TEXTURE_LUMINANCE_SIZE 0x8060
-#define GL_TEXTURE_INTENSITY_SIZE 0x8061
-#define GL_NEAREST_MIPMAP_NEAREST 0x2700
-#define GL_NEAREST_MIPMAP_LINEAR 0x2702
-#define GL_LINEAR_MIPMAP_NEAREST 0x2701
-#define GL_LINEAR_MIPMAP_LINEAR 0x2703
-#define GL_OBJECT_LINEAR 0x2401
-#define GL_OBJECT_PLANE 0x2501
-#define GL_EYE_LINEAR 0x2400
-#define GL_EYE_PLANE 0x2502
-#define GL_SPHERE_MAP 0x2402
-#define GL_DECAL 0x2101
-#define GL_MODULATE 0x2100
-#define GL_NEAREST 0x2600
-#define GL_REPEAT 0x2901
-#define GL_CLAMP 0x2900
-#define GL_S 0x2000
-#define GL_T 0x2001
-#define GL_R 0x2002
-#define GL_Q 0x2003
-#define GL_TEXTURE_GEN_R 0x0C62
-#define GL_TEXTURE_GEN_Q 0x0C63
-
-/* GL 1.1 texturing */
-#define GL_PROXY_TEXTURE_1D 0x8063
-#define GL_PROXY_TEXTURE_2D 0x8064
-#define GL_TEXTURE_PRIORITY 0x8066
-#define GL_TEXTURE_RESIDENT 0x8067
-#define GL_TEXTURE_BINDING_1D 0x8068
-#define GL_TEXTURE_BINDING_2D 0x8069
-#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
-
-/* GL 1.2 texturing */
-#define GL_PACK_SKIP_IMAGES 0x806B
-#define GL_PACK_IMAGE_HEIGHT 0x806C
-#define GL_UNPACK_SKIP_IMAGES 0x806D
-#define GL_UNPACK_IMAGE_HEIGHT 0x806E
-#define GL_TEXTURE_3D 0x806F
-#define GL_PROXY_TEXTURE_3D 0x8070
-#define GL_TEXTURE_DEPTH 0x8071
-#define GL_TEXTURE_WRAP_R 0x8072
-#define GL_MAX_3D_TEXTURE_SIZE 0x8073
-#define GL_TEXTURE_BINDING_3D 0x806A
-
-/* Internal texture formats (GL 1.1) */
-#define GL_ALPHA4 0x803B
-#define GL_ALPHA8 0x803C
-#define GL_ALPHA12 0x803D
-#define GL_ALPHA16 0x803E
-#define GL_LUMINANCE4 0x803F
-#define GL_LUMINANCE8 0x8040
-#define GL_LUMINANCE12 0x8041
-#define GL_LUMINANCE16 0x8042
-#define GL_LUMINANCE4_ALPHA4 0x8043
-#define GL_LUMINANCE6_ALPHA2 0x8044
-#define GL_LUMINANCE8_ALPHA8 0x8045
-#define GL_LUMINANCE12_ALPHA4 0x8046
-#define GL_LUMINANCE12_ALPHA12 0x8047
-#define GL_LUMINANCE16_ALPHA16 0x8048
-#define GL_INTENSITY 0x8049
-#define GL_INTENSITY4 0x804A
-#define GL_INTENSITY8 0x804B
-#define GL_INTENSITY12 0x804C
-#define GL_INTENSITY16 0x804D
-#define GL_R3_G3_B2 0x2A10
-#define GL_RGB4 0x804F
-#define GL_RGB5 0x8050
-#define GL_RGB8 0x8051
-#define GL_RGB10 0x8052
-#define GL_RGB12 0x8053
-#define GL_RGB16 0x8054
-#define GL_RGBA2 0x8055
-#define GL_RGBA4 0x8056
-#define GL_RGB5_A1 0x8057
-#define GL_RGBA8 0x8058
-#define GL_RGB10_A2 0x8059
-#define GL_RGBA12 0x805A
-#define GL_RGBA16 0x805B
-
-/* Utility */
-#define GL_VENDOR 0x1F00
-#define GL_RENDERER 0x1F01
-#define GL_VERSION 0x1F02
-#define GL_EXTENSIONS 0x1F03
-
-/* Errors */
-#define GL_NO_ERROR 0x0
-#define GL_INVALID_VALUE 0x0501
-#define GL_INVALID_ENUM 0x0500
-#define GL_INVALID_OPERATION 0x0502
-#define GL_STACK_OVERFLOW 0x0503
-#define GL_STACK_UNDERFLOW 0x0504
-#define GL_OUT_OF_MEMORY 0x0505
-
-
-/* OpenGL 1.2 */
-#define GL_RESCALE_NORMAL 0x803A
-#define GL_CLAMP_TO_EDGE 0x812F
-#define GL_MAX_ELEMENTS_VERTICES 0x80E8
-#define GL_MAX_ELEMENTS_INDICES 0x80E9
-#define GL_BGR 0x80E0
-#define GL_BGRA 0x80E1
-#define GL_UNSIGNED_BYTE_3_3_2 0x8032
-#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
-#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
-#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
-#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
-#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
-#define GL_UNSIGNED_INT_8_8_8_8 0x8035
-#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
-#define GL_UNSIGNED_INT_10_10_10_2 0x8036
-#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
-#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
-#define GL_SINGLE_COLOR 0x81F9
-#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
-#define GL_TEXTURE_MIN_LOD 0x813A
-#define GL_TEXTURE_MAX_LOD 0x813B
-#define GL_TEXTURE_BASE_LEVEL 0x813C
-#define GL_TEXTURE_MAX_LEVEL 0x813D
-#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
-#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
-#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
-#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
-#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
-#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
-
-
-
-/*
- * OpenGL 1.2 imaging subset (NOT IMPLEMENTED BY MESA)
- */
-/* GL_EXT_color_table */
-#define GL_COLOR_TABLE 0x80D0
-#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1
-#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2
-#define GL_PROXY_COLOR_TABLE 0x80D3
-#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
-#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
-#define GL_COLOR_TABLE_SCALE 0x80D6
-#define GL_COLOR_TABLE_BIAS 0x80D7
-#define GL_COLOR_TABLE_FORMAT 0x80D8
-#define GL_COLOR_TABLE_WIDTH 0x80D9
-#define GL_COLOR_TABLE_RED_SIZE 0x80DA
-#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB
-#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC
-#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD
-#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE
-#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF
-/* GL_EXT_convolution and GL_HP_convolution_border_modes */
-#define GL_CONVOLUTION_1D 0x8010
-#define GL_CONVOLUTION_2D 0x8011
-#define GL_SEPARABLE_2D 0x8012
-#define GL_CONVOLUTION_BORDER_MODE 0x8013
-#define GL_CONVOLUTION_FILTER_SCALE 0x8014
-#define GL_CONVOLUTION_FILTER_BIAS 0x8015
-#define GL_REDUCE 0x8016
-#define GL_CONVOLUTION_FORMAT 0x8017
-#define GL_CONVOLUTION_WIDTH 0x8018
-#define GL_CONVOLUTION_HEIGHT 0x8019
-#define GL_MAX_CONVOLUTION_WIDTH 0x801A
-#define GL_MAX_CONVOLUTION_HEIGHT 0x801B
-#define GL_POST_CONVOLUTION_RED_SCALE 0x801C
-#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D
-#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E
-#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F
-#define GL_POST_CONVOLUTION_RED_BIAS 0x8020
-#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021
-#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022
-#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023
-#define GL_CONSTANT_BORDER 0x8151
-#define GL_REPLICATE_BORDER 0x8153
-#define GL_CONVOLUTION_BORDER_COLOR 0x8154
-/* GL_SGI_color_matrix */
-#define GL_COLOR_MATRIX 0x80B1
-#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2
-#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3
-#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4
-#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5
-#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6
-#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7
-#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8
-#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9
-#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA
-#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB
-/* GL_EXT_histogram */
-#define GL_HISTOGRAM 0x8024
-#define GL_PROXY_HISTOGRAM 0x8025
-#define GL_HISTOGRAM_WIDTH 0x8026
-#define GL_HISTOGRAM_FORMAT 0x8027
-#define GL_HISTOGRAM_RED_SIZE 0x8028
-#define GL_HISTOGRAM_GREEN_SIZE 0x8029
-#define GL_HISTOGRAM_BLUE_SIZE 0x802A
-#define GL_HISTOGRAM_ALPHA_SIZE 0x802B
-#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C
-#define GL_HISTOGRAM_SINK 0x802D
-#define GL_MINMAX 0x802E
-#define GL_MINMAX_FORMAT 0x802F
-#define GL_MINMAX_SINK 0x8030
-#define GL_TABLE_TOO_LARGE 0x8031
-/* GL_EXT_blend_color, GL_EXT_blend_minmax */
-#define GL_BLEND_EQUATION 0x8009
-#define GL_MIN 0x8007
-#define GL_MAX 0x8008
-#define GL_FUNC_ADD 0x8006
-#define GL_FUNC_SUBTRACT 0x800A
-#define GL_FUNC_REVERSE_SUBTRACT 0x800B
-#define GL_BLEND_COLOR 0x8005
-
-
-/* glPush/PopAttrib bits */
-#define GL_CURRENT_BIT 0x00000001
-#define GL_POINT_BIT 0x00000002
-#define GL_LINE_BIT 0x00000004
-#define GL_POLYGON_BIT 0x00000008
-#define GL_POLYGON_STIPPLE_BIT 0x00000010
-#define GL_PIXEL_MODE_BIT 0x00000020
-#define GL_LIGHTING_BIT 0x00000040
-#define GL_FOG_BIT 0x00000080
-#define GL_DEPTH_BUFFER_BIT 0x00000100
-#define GL_ACCUM_BUFFER_BIT 0x00000200
-#define GL_STENCIL_BUFFER_BIT 0x00000400
-#define GL_VIEWPORT_BIT 0x00000800
-#define GL_TRANSFORM_BIT 0x00001000
-#define GL_ENABLE_BIT 0x00002000
-#define GL_COLOR_BUFFER_BIT 0x00004000
-#define GL_HINT_BIT 0x00008000
-#define GL_EVAL_BIT 0x00010000
-#define GL_LIST_BIT 0x00020000
-#define GL_TEXTURE_BIT 0x00040000
-#define GL_SCISSOR_BIT 0x00080000
-#define GL_ALL_ATTRIB_BITS 0x000FFFFF
-
-
-#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
-#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
-#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF
-
-
-
-
-
-#if defined(__BEOS__) || defined(__QUICKDRAW__)
-#pragma export on
-#endif
-
-
-/*
- * Miscellaneous
- */
-
-GLAPI void GLAPIENTRY glClearIndex( GLfloat c );
-
-GLAPI void GLAPIENTRY glClearColor( GLclampf red,
- GLclampf green,
- GLclampf blue,
- GLclampf alpha );
-
-GLAPI void GLAPIENTRY glClear( GLbitfield mask );
-
-GLAPI void GLAPIENTRY glIndexMask( GLuint mask );
-
-GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green,
- GLboolean blue, GLboolean alpha );
-
-GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref );
-
-GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor );
-
-GLAPI void GLAPIENTRY glLogicOp( GLenum opcode );
-
-GLAPI void GLAPIENTRY glCullFace( GLenum mode );
-
-GLAPI void GLAPIENTRY glFrontFace( GLenum mode );
-
-GLAPI void GLAPIENTRY glPointSize( GLfloat size );
-
-GLAPI void GLAPIENTRY glLineWidth( GLfloat width );
-
-GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern );
-
-GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode );
-
-GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units );
-
-GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask );
-
-GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask );
-
-GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag );
-
-GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag );
-
-GLAPI void GLAPIENTRY glScissor( GLint x, GLint y,
- GLsizei width, GLsizei height);
-
-GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation );
-
-GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation );
-
-GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode );
-
-GLAPI void GLAPIENTRY glReadBuffer( GLenum mode );
-
-GLAPI void GLAPIENTRY glEnable( GLenum cap );
-
-GLAPI void GLAPIENTRY glDisable( GLenum cap );
-
-GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap );
-
-
-GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); /* 1.1 */
-
-GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); /* 1.1 */
-
-
-GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params );
-
-GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params );
-
-GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params );
-
-GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params );
-
-
-GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask );
-
-GLAPI void GLAPIENTRY glPopAttrib( void );
-
-
-GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); /* 1.1 */
-
-GLAPI void GLAPIENTRY glPopClientAttrib( void ); /* 1.1 */
-
-
-GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode );
-
-GLAPI GLenum GLAPIENTRY glGetError( void );
-
-GLAPI const GLubyte* GLAPIENTRY glGetString( GLenum name );
-
-GLAPI void GLAPIENTRY glFinish( void );
-
-GLAPI void GLAPIENTRY glFlush( void );
-
-GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode );
-
-
-
-/*
- * Depth Buffer
- */
-
-GLAPI void GLAPIENTRY glClearDepth( GLclampd depth );
-
-GLAPI void GLAPIENTRY glDepthFunc( GLenum func );
-
-GLAPI void GLAPIENTRY glDepthMask( GLboolean flag );
-
-GLAPI void GLAPIENTRY glDepthRange( GLclampd near_val, GLclampd far_val );
-
-
-/*
- * Accumulation Buffer
- */
-
-GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green,
- GLfloat blue, GLfloat alpha );
-
-GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value );
-
-
-
-/*
- * Transformation
- */
-
-GLAPI void GLAPIENTRY glMatrixMode( GLenum mode );
-
-GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right,
- GLdouble bottom, GLdouble top,
- GLdouble near_val, GLdouble far_val );
-
-GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right,
- GLdouble bottom, GLdouble top,
- GLdouble near_val, GLdouble far_val );
-
-GLAPI void GLAPIENTRY glViewport( GLint x, GLint y,
- GLsizei width, GLsizei height );
-
-GLAPI void GLAPIENTRY glPushMatrix( void );
-
-GLAPI void GLAPIENTRY glPopMatrix( void );
-
-GLAPI void GLAPIENTRY glLoadIdentity( void );
-
-GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m );
-GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m );
-
-GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m );
-GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m );
-
-GLAPI void GLAPIENTRY glRotated( GLdouble angle,
- GLdouble x, GLdouble y, GLdouble z );
-GLAPI void GLAPIENTRY glRotatef( GLfloat angle,
- GLfloat x, GLfloat y, GLfloat z );
-
-GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z );
-GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z );
-
-GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z );
-GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z );
-
-
-
-/*
- * Display Lists
- */
-
-GLAPI GLboolean GLAPIENTRY glIsList( GLuint list );
-
-GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range );
-
-GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range );
-
-GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode );
-
-GLAPI void GLAPIENTRY glEndList( void );
-
-GLAPI void GLAPIENTRY glCallList( GLuint list );
-
-GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type,
- const GLvoid *lists );
-
-GLAPI void GLAPIENTRY glListBase( GLuint base );
-
-
-
-/*
- * Drawing Functions
- */
-
-GLAPI void GLAPIENTRY glBegin( GLenum mode );
-
-GLAPI void GLAPIENTRY glEnd( void );
-
-
-GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y );
-GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y );
-GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y );
-GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y );
-
-GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z );
-GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z );
-GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z );
-GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z );
-
-GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w );
-GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w );
-GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w );
-GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w );
-
-GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glVertex2iv( const GLint *v );
-GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v );
-
-GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glVertex3iv( const GLint *v );
-GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v );
-
-GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glVertex4iv( const GLint *v );
-GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v );
-
-
-GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz );
-GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz );
-GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz );
-GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz );
-GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz );
-
-GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v );
-GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glNormal3iv( const GLint *v );
-GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v );
-
-
-GLAPI void GLAPIENTRY glIndexd( GLdouble c );
-GLAPI void GLAPIENTRY glIndexf( GLfloat c );
-GLAPI void GLAPIENTRY glIndexi( GLint c );
-GLAPI void GLAPIENTRY glIndexs( GLshort c );
-GLAPI void GLAPIENTRY glIndexub( GLubyte c ); /* 1.1 */
-
-GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c );
-GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c );
-GLAPI void GLAPIENTRY glIndexiv( const GLint *c );
-GLAPI void GLAPIENTRY glIndexsv( const GLshort *c );
-GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); /* 1.1 */
-
-GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue );
-GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue );
-GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue );
-GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue );
-GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue );
-GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue );
-GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue );
-GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue );
-
-GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green,
- GLbyte blue, GLbyte alpha );
-GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green,
- GLdouble blue, GLdouble alpha );
-GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green,
- GLfloat blue, GLfloat alpha );
-GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green,
- GLint blue, GLint alpha );
-GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green,
- GLshort blue, GLshort alpha );
-GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green,
- GLubyte blue, GLubyte alpha );
-GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green,
- GLuint blue, GLuint alpha );
-GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green,
- GLushort blue, GLushort alpha );
-
-
-GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v );
-GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glColor3iv( const GLint *v );
-GLAPI void GLAPIENTRY glColor3sv( const GLshort *v );
-GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v );
-GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v );
-GLAPI void GLAPIENTRY glColor3usv( const GLushort *v );
-
-GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v );
-GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glColor4iv( const GLint *v );
-GLAPI void GLAPIENTRY glColor4sv( const GLshort *v );
-GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v );
-GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v );
-GLAPI void GLAPIENTRY glColor4usv( const GLushort *v );
-
-
-GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s );
-GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s );
-GLAPI void GLAPIENTRY glTexCoord1i( GLint s );
-GLAPI void GLAPIENTRY glTexCoord1s( GLshort s );
-
-GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t );
-GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t );
-GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t );
-GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t );
-
-GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r );
-GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r );
-GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r );
-GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r );
-
-GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q );
-GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q );
-GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q );
-GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q );
-
-GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v );
-GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v );
-
-GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v );
-GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v );
-
-GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v );
-GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v );
-
-GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v );
-GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v );
-
-
-GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y );
-GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y );
-GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y );
-GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y );
-
-GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z );
-GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z );
-GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z );
-GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z );
-
-GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w );
-GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w );
-GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w );
-GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w );
-
-GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v );
-GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v );
-
-GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v );
-GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v );
-
-GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v );
-GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v );
-GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v );
-GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v );
-
-
-GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 );
-GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 );
-GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 );
-GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 );
-
-
-GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 );
-GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 );
-GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 );
-GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 );
-
-
-
-/*
- * Vertex Arrays (1.1)
- */
-
-GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type,
- GLsizei stride, const GLvoid *ptr );
-
-GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride,
- const GLvoid *ptr );
-
-GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type,
- GLsizei stride, const GLvoid *ptr );
-
-GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride,
- const GLvoid *ptr );
-
-GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type,
- GLsizei stride, const GLvoid *ptr );
-
-GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr );
-
-GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, void **params );
-
-GLAPI void GLAPIENTRY glArrayElement( GLint i );
-
-GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count );
-
-GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count,
- GLenum type, const GLvoid *indices );
-
-GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride,
- const GLvoid *pointer );
-
-
-/*
- * Lighting
- */
-
-GLAPI void GLAPIENTRY glShadeModel( GLenum mode );
-
-GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param );
-GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param );
-GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname,
- const GLfloat *params );
-GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname,
- const GLint *params );
-
-GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname,
- GLfloat *params );
-GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname,
- GLint *params );
-
-GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param );
-GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param );
-GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params );
-GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params );
-
-GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param );
-GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param );
-GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params );
-GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params );
-
-GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params );
-GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params );
-
-GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode );
-
-
-
-
-/*
- * Raster functions
- */
-
-GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor );
-
-GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param );
-GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param );
-
-GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param );
-GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param );
-
-GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLint mapsize,
- const GLfloat *values );
-GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLint mapsize,
- const GLuint *values );
-GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLint mapsize,
- const GLushort *values );
-
-GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values );
-GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values );
-GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values );
-
-GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height,
- GLfloat xorig, GLfloat yorig,
- GLfloat xmove, GLfloat ymove,
- const GLubyte *bitmap );
-
-GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- GLvoid *pixels );
-
-GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const GLvoid *pixels );
-
-GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y,
- GLsizei width, GLsizei height,
- GLenum type );
-
-
-
-/*
- * Stenciling
- */
-
-GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask );
-
-GLAPI void GLAPIENTRY glStencilMask( GLuint mask );
-
-GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass );
-
-GLAPI void GLAPIENTRY glClearStencil( GLint s );
-
-
-
-/*
- * Texture mapping
- */
-
-GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param );
-GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param );
-GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param );
-
-GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params );
-GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params );
-GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params );
-
-GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params );
-GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params );
-GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params );
-
-
-GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param );
-GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param );
-
-GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params );
-GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params );
-
-GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params );
-GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params );
-
-
-GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param );
-GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param );
-
-GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname,
- const GLfloat *params );
-GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname,
- const GLint *params );
-
-GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target,
- GLenum pname, GLfloat *params);
-GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target,
- GLenum pname, GLint *params );
-
-GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level,
- GLenum pname, GLfloat *params );
-GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level,
- GLenum pname, GLint *params );
-
-
-GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level,
- GLint internalFormat,
- GLsizei width, GLint border,
- GLenum format, GLenum type,
- const GLvoid *pixels );
-
-GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level,
- GLint internalFormat,
- GLsizei width, GLsizei height,
- GLint border, GLenum format, GLenum type,
- const GLvoid *pixels );
-
-GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level,
- GLenum format, GLenum type,
- GLvoid *pixels );
-
-
-
-/* 1.1 functions */
-
-GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures );
-
-GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures);
-
-GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture );
-
-GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n,
- const GLuint *textures,
- const GLclampf *priorities );
-
-GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n,
- const GLuint *textures,
- GLboolean *residences );
-
-GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture );
-
-
-GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level,
- GLint xoffset,
- GLsizei width, GLenum format,
- GLenum type, const GLvoid *pixels );
-
-
-GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const GLvoid *pixels );
-
-
-GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level,
- GLenum internalformat,
- GLint x, GLint y,
- GLsizei width, GLint border );
-
-
-GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level,
- GLenum internalformat,
- GLint x, GLint y,
- GLsizei width, GLsizei height,
- GLint border );
-
-
-GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level,
- GLint xoffset, GLint x, GLint y,
- GLsizei width );
-
-
-GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint x, GLint y,
- GLsizei width, GLsizei height );
-
-
-
-
-/*
- * Evaluators
- */
-
-GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2,
- GLint stride,
- GLint order, const GLdouble *points );
-GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2,
- GLint stride,
- GLint order, const GLfloat *points );
-
-GLAPI void GLAPIENTRY glMap2d( GLenum target,
- GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
- GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
- const GLdouble *points );
-GLAPI void GLAPIENTRY glMap2f( GLenum target,
- GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
- GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
- const GLfloat *points );
-
-GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v );
-GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v );
-GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v );
-
-GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u );
-GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u );
-
-GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u );
-GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u );
-
-GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v );
-GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v );
-
-GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u );
-GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u );
-
-GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 );
-GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 );
-
-GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2,
- GLint vn, GLdouble v1, GLdouble v2 );
-GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2,
- GLint vn, GLfloat v1, GLfloat v2 );
-
-GLAPI void GLAPIENTRY glEvalPoint1( GLint i );
-
-GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j );
-
-GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 );
-
-GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 );
-
-
-
-/*
- * Fog
- */
-
-GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param );
-
-GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param );
-
-GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params );
-
-GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params );
-
-
-
-/*
- * Selection and Feedback
- */
-
-GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer );
-
-GLAPI void GLAPIENTRY glPassThrough( GLfloat token );
-
-GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer );
-
-GLAPI void GLAPIENTRY glInitNames( void );
-
-GLAPI void GLAPIENTRY glLoadName( GLuint name );
-
-GLAPI void GLAPIENTRY glPushName( GLuint name );
-
-GLAPI void GLAPIENTRY glPopName( void );
-
-
-
-/* 1.2 functions */
-GLAPI void GLAPIENTRY glDrawRangeElements( GLenum mode, GLuint start,
- GLuint end, GLsizei count, GLenum type, const GLvoid *indices );
-
-GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level,
- GLint internalFormat,
- GLsizei width, GLsizei height,
- GLsizei depth, GLint border,
- GLenum format, GLenum type,
- const GLvoid *pixels );
-
-GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint zoffset, GLsizei width,
- GLsizei height, GLsizei depth,
- GLenum format,
- GLenum type, const GLvoid *pixels);
-
-GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint zoffset, GLint x,
- GLint y, GLsizei width,
- GLsizei height );
-
-
-/* 1.2 imaging extension functions */
-
-GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat,
- GLsizei width, GLenum format,
- GLenum type, const GLvoid *table );
-
-GLAPI void GLAPIENTRY glColorSubTable( GLenum target,
- GLsizei start, GLsizei count,
- GLenum format, GLenum type,
- const GLvoid *data );
-
-GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname,
- const GLint *params);
-
-GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname,
- const GLfloat *params);
-
-GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start,
- GLint x, GLint y, GLsizei width );
-
-GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat,
- GLint x, GLint y, GLsizei width );
-
-GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format,
- GLenum type, GLvoid *table );
-
-GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname,
- GLfloat *params );
-
-GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname,
- GLint *params );
-
-GLAPI void GLAPIENTRY glBlendEquation( GLenum mode );
-
-GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green,
- GLclampf blue, GLclampf alpha );
-
-GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width,
- GLenum internalformat, GLboolean sink );
-
-GLAPI void GLAPIENTRY glResetHistogram( GLenum target );
-
-GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset,
- GLenum format, GLenum type,
- GLvoid *values );
-
-GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname,
- GLfloat *params );
-
-GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname,
- GLint *params );
-
-GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat,
- GLboolean sink );
-
-GLAPI void GLAPIENTRY glResetMinmax( GLenum target );
-
-GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset,
- GLenum format, GLenum types,
- GLvoid *values );
-
-GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname,
- GLfloat *params );
-
-GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname,
- GLint *params );
-
-GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target,
- GLenum internalformat, GLsizei width, GLenum format, GLenum type,
- const GLvoid *image );
-
-GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target,
- GLenum internalformat, GLsizei width, GLsizei height, GLenum format,
- GLenum type, const GLvoid *image );
-
-GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname,
- GLfloat params );
-
-GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname,
- const GLfloat *params );
-
-GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname,
- GLint params );
-
-GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname,
- const GLint *params );
-
-GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target,
- GLenum internalformat, GLint x, GLint y, GLsizei width );
-
-GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target,
- GLenum internalformat, GLint x, GLint y, GLsizei width,
- GLsizei height);
-
-GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format,
- GLenum type, GLvoid *image );
-
-GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname,
- GLfloat *params );
-
-GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname,
- GLint *params );
-
-GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target,
- GLenum internalformat, GLsizei width, GLsizei height, GLenum format,
- GLenum type, const GLvoid *row, const GLvoid *column );
-
-GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format,
- GLenum type, GLvoid *row, GLvoid *column, GLvoid *span );
-
-
-
-
-/*
- * XXX these extensions may eventually be moved into glext.h
- */
-
-
-/*
- * GL_EXT_abgr (number 1)
- */
-#ifndef GL_EXT_abgr
-#define GL_EXT_abgr 1
-
-#define GL_ABGR_EXT 0x8000
-
-#endif /* GL_EXT_abgr */
-
-
-
-/*
- * GL_EXT_blend_color (number 2)
- */
-#ifndef GL_EXT_blend_color
-#define GL_EXT_blend_color 1
-
-#define GL_CONSTANT_COLOR_EXT 0x8001
-#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002
-#define GL_CONSTANT_ALPHA_EXT 0x8003
-#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004
-#define GL_BLEND_COLOR_EXT 0x8005
-
-GLAPI void GLAPIENTRY glBlendColorEXT( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha );
-
-#endif /* GL_EXT_blend_color */
-
-
-
-/*
- * GL_EXT_polygon_offset (number 3)
- */
-#ifndef GL_EXT_polygon_offset
-#define GL_EXT_polygon_offset 1
-
-#define GL_POLYGON_OFFSET_EXT 0x8037
-#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038
-#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039
-
-GLAPI void GLAPIENTRY glPolygonOffsetEXT( GLfloat factor, GLfloat bias );
-
-#endif /* GL_EXT_polygon_offset */
-
-
-
-/*
- * GL_EXT_texture3D (number 6)
- */
-#ifndef GL_EXT_texture3D
-#define GL_EXT_texture3D 1
-
-#define GL_PACK_SKIP_IMAGES_EXT 0x806B
-#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C
-#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D
-#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E
-#define GL_TEXTURE_3D_EXT 0x806F
-#define GL_PROXY_TEXTURE_3D_EXT 0x8070
-#define GL_TEXTURE_DEPTH_EXT 0x8071
-#define GL_TEXTURE_WRAP_R_EXT 0x8072
-#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073
-#define GL_TEXTURE_3D_BINDING_EXT 0x806A
-
-GLAPI void GLAPIENTRY glTexImage3DEXT( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels );
-
-GLAPI void GLAPIENTRY glTexSubImage3DEXT( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
-
-GLAPI void GLAPIENTRY glCopyTexSubImage3DEXT( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height );
-
-#endif /* GL_EXT_texture3D */
-
-
-
-/*
- * GL_EXT_texture_object (number 20)
- */
-#ifndef GL_EXT_texture_object
-#define GL_EXT_texture_object 1
-
-#define GL_TEXTURE_PRIORITY_EXT 0x8066
-#define GL_TEXTURE_RESIDENT_EXT 0x8067
-#define GL_TEXTURE_1D_BINDING_EXT 0x8068
-#define GL_TEXTURE_2D_BINDING_EXT 0x8069
-
-GLAPI void GLAPIENTRY glGenTexturesEXT( GLsizei n, GLuint *textures );
-
-GLAPI void GLAPIENTRY glDeleteTexturesEXT( GLsizei n, const GLuint *textures);
-
-GLAPI void GLAPIENTRY glBindTextureEXT( GLenum target, GLuint texture );
-
-GLAPI void GLAPIENTRY glPrioritizeTexturesEXT( GLsizei n, const GLuint *textures, const GLclampf *priorities );
-
-GLAPI GLboolean GLAPIENTRY glAreTexturesResidentEXT( GLsizei n, const GLuint *textures, GLboolean *residences );
-
-GLAPI GLboolean GLAPIENTRY glIsTextureEXT( GLuint texture );
-
-#endif /* GL_EXT_texture_object */
-
-
-
-/*
- * GL_EXT_rescale_normal (number 27)
- */
-#ifndef GL_EXT_rescale_normal
-#define GL_EXT_rescale_normal 1
-
-#define GL_RESCALE_NORMAL_EXT 0x803A
-
-#endif /* GL_EXT_rescale_normal */
-
-
-
-/*
- * GL_EXT_vertex_array (number 30)
- */
-#ifndef GL_EXT_vertex_array
-#define GL_EXT_vertex_array 1
-
-#define GL_VERTEX_ARRAY_EXT 0x8074
-#define GL_NORMAL_ARRAY_EXT 0x8075
-#define GL_COLOR_ARRAY_EXT 0x8076
-#define GL_INDEX_ARRAY_EXT 0x8077
-#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078
-#define GL_EDGE_FLAG_ARRAY_EXT 0x8079
-#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A
-#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B
-#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C
-#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D
-#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E
-#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F
-#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080
-#define GL_COLOR_ARRAY_SIZE_EXT 0x8081
-#define GL_COLOR_ARRAY_TYPE_EXT 0x8082
-#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083
-#define GL_COLOR_ARRAY_COUNT_EXT 0x8084
-#define GL_INDEX_ARRAY_TYPE_EXT 0x8085
-#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086
-#define GL_INDEX_ARRAY_COUNT_EXT 0x8087
-#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088
-#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089
-#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A
-#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B
-#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C
-#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D
-#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E
-#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F
-#define GL_COLOR_ARRAY_POINTER_EXT 0x8090
-#define GL_INDEX_ARRAY_POINTER_EXT 0x8091
-#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092
-#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093
-
-GLAPI void GLAPIENTRY glVertexPointerEXT( GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr );
-
-GLAPI void GLAPIENTRY glNormalPointerEXT( GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr );
-
-GLAPI void GLAPIENTRY glColorPointerEXT( GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr );
-
-GLAPI void GLAPIENTRY glIndexPointerEXT( GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr );
-
-GLAPI void GLAPIENTRY glTexCoordPointerEXT( GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr );
-
-GLAPI void GLAPIENTRY glEdgeFlagPointerEXT( GLsizei stride, GLsizei count, const GLboolean *ptr );
-
-GLAPI void GLAPIENTRY glGetPointervEXT( GLenum pname, void **params );
-
-GLAPI void GLAPIENTRY glArrayElementEXT( GLint i );
-
-GLAPI void GLAPIENTRY glDrawArraysEXT( GLenum mode, GLint first, GLsizei count );
-
-#endif /* GL_EXT_vertex_array */
-
-
-
-/*
- * GL_SGIS_texture_edge_clamp (number 35)
- */
-#ifndef GL_SGIS_texture_edge_clamp
-#define GL_SGIS_texture_edge_clamp 1
-
-#define GL_CLAMP_TO_EDGE_SGIS 0x812F
-
-#endif /* GL_SGIS_texture_edge_clamp */
-
-
-
-/*
- * GL_EXT_blend_minmax (number 37)
- */
-#ifndef GL_EXT_blend_minmax
-#define GL_EXT_blend_minmax 1
-
-#define GL_FUNC_ADD_EXT 0x8006
-#define GL_MIN_EXT 0x8007
-#define GL_MAX_EXT 0x8008
-#define GL_BLEND_EQUATION_EXT 0x8009
-
-GLAPI void GLAPIENTRY glBlendEquationEXT( GLenum mode );
-
-#endif /* GL_EXT_blend_minmax */
-
-
-
-/*
- * GL_EXT_blend_subtract (number 38) (requires GL_EXT_blend_max )
- */
-#ifndef GL_EXT_blend_subtract
-#define GL_EXT_blend_subtract 1
-
-#define GL_FUNC_SUBTRACT_EXT 0x800A
-#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B
-
-#endif /* GL_EXT_blend_subtract */
-
-
-
-/*
- * GL_EXT_blend_logic_op (number 39)
- */
-#ifndef GL_EXT_blend_logic_op
-#define GL_EXT_blend_logic_op 1
-
-/* No new tokens or functions */
-
-#endif /* GL_EXT_blend_logic_op */
-
-
-
-/*
- * GL_EXT_point_parameters (number 54)
- */
-#ifndef GL_EXT_point_parameters
-#define GL_EXT_point_parameters 1
-
-#define GL_POINT_SIZE_MIN_EXT 0x8126
-#define GL_POINT_SIZE_MAX_EXT 0x8127
-#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
-#define GL_DISTANCE_ATTENUATION_EXT 0x8129
-
-GLAPI void GLAPIENTRY glPointParameterfEXT( GLenum pname, GLfloat param );
-GLAPI void GLAPIENTRY glPointParameterfvEXT( GLenum pname, const GLfloat *params );
-
-#endif /* GL_EXT_point_parameters */
-
-
-
-/*
- * GL_EXT_paletted_texture (number 78)
- */
-#ifndef GL_EXT_paletted_texture
-#define GL_EXT_paletted_texture 1
-
-#define GL_TABLE_TOO_LARGE_EXT 0x8031
-#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8
-#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9
-#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA
-#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB
-#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC
-#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD
-#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE
-#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF
-#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
-#define GL_COLOR_INDEX1_EXT 0x80E2
-#define GL_COLOR_INDEX2_EXT 0x80E3
-#define GL_COLOR_INDEX4_EXT 0x80E4
-#define GL_COLOR_INDEX8_EXT 0x80E5
-#define GL_COLOR_INDEX12_EXT 0x80E6
-#define GL_COLOR_INDEX16_EXT 0x80E7
-
-GLAPI void GLAPIENTRY glColorTableEXT( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table );
-
-GLAPI void GLAPIENTRY glColorSubTableEXT( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data );
-
-GLAPI void GLAPIENTRY glGetColorTableEXT( GLenum target, GLenum format, GLenum type, GLvoid *table );
-
-GLAPI void GLAPIENTRY glGetColorTableParameterfvEXT( GLenum target, GLenum pname, GLfloat *params );
-
-GLAPI void GLAPIENTRY glGetColorTableParameterivEXT( GLenum target, GLenum pname, GLint *params );
-
-#endif /* GL_EXT_paletted_texture */
-
-
-
-/*
- * GL_EXT_clip_volume_hint (number 79)
- */
-#ifndef GL_EXT_clip_volume_hint
-#define GL_EXT_clip_volume_hint 1
-
-#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F
-
-#endif /* GL_EXT_clip_volume_hint */
-
-
-
-/*
- * GL_EXT_compiled_vertex_array (number 97)
- */
-#ifndef GL_EXT_compiled_vertex_array
-#define GL_EXT_compiled_vertex_array 1
-
-#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8
-#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9
-
-GLAPI void GLAPIENTRY glLockArraysEXT( GLint first, GLsizei count );
-GLAPI void GLAPIENTRY glUnlockArraysEXT( void );
-
-#endif /* GL_EXT_compiled_vertex_array */
-
-
-
-/*
- * GL_EXT_shared_texture_palette (number 141) (req's GL_EXT_paletted_texture)
- */
-#ifndef GL_EXT_shared_texture_palette
-#define GL_EXT_shared_texture_palette 1
-
-#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
-
-#endif /* GL_EXT_shared_texture_palette */
-
-
-
-/*
- * GL_EXT_stencil_wrap (number 176)
- */
-#ifndef GL_EXT_stencil_wrap
-#define GL_EXT_stencil_wrap 1
-
-#define GL_INCR_WRAP_EXT 0x8507
-#define GL_DECR_WRAP_EXT 0x8508
-
-#endif /* GL_EXT_stencil_wrap */
-
-
-
-/*
- * GL_NV_texgen_reflection (number 179)
- */
-#ifndef GL_NV_texgen_reflection
-#define GL_NV_texgen_reflection 1
-
-#define GL_NORMAL_MAP_NV 0x8511
-#define GL_REFLECTION_MAP_NV 0x8512
-
-#endif /* GL_NV_texgen_reflection */
-
-
-
-/*
- * GL_EXT_texture_env_add (number 185)
- */
-#ifndef GL_EXT_texture_env_add
-#define GL_EXT_texture_env_add 1
-
-/* No new tokens or functions */
-
-#endif /* GL_EXT_texture_env_add */
-
-
-
-/*
- * GL_ARB_multitexture (ARB 0)
- */
-#ifndef GL_ARB_multitexture
-#define GL_ARB_multitexture 1
-
-#define GL_TEXTURE0_ARB 0x84C0
-#define GL_TEXTURE1_ARB 0x84C1
-#define GL_TEXTURE2_ARB 0x84C2
-#define GL_TEXTURE3_ARB 0x84C3
-#define GL_TEXTURE4_ARB 0x84C4
-#define GL_TEXTURE5_ARB 0x84C5
-#define GL_TEXTURE6_ARB 0x84C6
-#define GL_TEXTURE7_ARB 0x84C7
-#define GL_TEXTURE8_ARB 0x84C8
-#define GL_TEXTURE9_ARB 0x84C9
-#define GL_TEXTURE10_ARB 0x84CA
-#define GL_TEXTURE11_ARB 0x84CB
-#define GL_TEXTURE12_ARB 0x84CC
-#define GL_TEXTURE13_ARB 0x84CD
-#define GL_TEXTURE14_ARB 0x84CE
-#define GL_TEXTURE15_ARB 0x84CF
-#define GL_TEXTURE16_ARB 0x84D0
-#define GL_TEXTURE17_ARB 0x84D1
-#define GL_TEXTURE18_ARB 0x84D2
-#define GL_TEXTURE19_ARB 0x84D3
-#define GL_TEXTURE20_ARB 0x84D4
-#define GL_TEXTURE21_ARB 0x84D5
-#define GL_TEXTURE22_ARB 0x84D6
-#define GL_TEXTURE23_ARB 0x84D7
-#define GL_TEXTURE24_ARB 0x84D8
-#define GL_TEXTURE25_ARB 0x84D9
-#define GL_TEXTURE26_ARB 0x84DA
-#define GL_TEXTURE27_ARB 0x84DB
-#define GL_TEXTURE28_ARB 0x84DC
-#define GL_TEXTURE29_ARB 0x84DD
-#define GL_TEXTURE30_ARB 0x84DE
-#define GL_TEXTURE31_ARB 0x84DF
-#define GL_ACTIVE_TEXTURE_ARB 0x84E0
-#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
-#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
-
-GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture);
-GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture);
-GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s);
-GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v);
-GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s);
-GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v);
-GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s);
-GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v);
-GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s);
-GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v);
-GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t);
-GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v);
-GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t);
-GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v);
-GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t);
-GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v);
-GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t);
-GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v);
-GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r);
-GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v);
-GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r);
-GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v);
-GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r);
-GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v);
-GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r);
-GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v);
-GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
-GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v);
-GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v);
-GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q);
-GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v);
-GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
-GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v);
-
-#endif /* GL_ARB_multitexture */
-
-
-
-/*
- * GL_MESA_window_pos (197)
- */
-#ifndef GL_MESA_window_pos
-#define GL_MESA_window_pos 1
-
-GLAPI void GLAPIENTRY glWindowPos2iMESA( GLint x, GLint y );
-GLAPI void GLAPIENTRY glWindowPos2sMESA( GLshort x, GLshort y );
-GLAPI void GLAPIENTRY glWindowPos2fMESA( GLfloat x, GLfloat y );
-GLAPI void GLAPIENTRY glWindowPos2dMESA( GLdouble x, GLdouble y );
-GLAPI void GLAPIENTRY glWindowPos2ivMESA( const GLint *p );
-GLAPI void GLAPIENTRY glWindowPos2svMESA( const GLshort *p );
-GLAPI void GLAPIENTRY glWindowPos2fvMESA( const GLfloat *p );
-GLAPI void GLAPIENTRY glWindowPos2dvMESA( const GLdouble *p );
-GLAPI void GLAPIENTRY glWindowPos3iMESA( GLint x, GLint y, GLint z );
-GLAPI void GLAPIENTRY glWindowPos3sMESA( GLshort x, GLshort y, GLshort z );
-GLAPI void GLAPIENTRY glWindowPos3fMESA( GLfloat x, GLfloat y, GLfloat z );
-GLAPI void GLAPIENTRY glWindowPos3dMESA( GLdouble x, GLdouble y, GLdouble z );
-GLAPI void GLAPIENTRY glWindowPos3ivMESA( const GLint *p );
-GLAPI void GLAPIENTRY glWindowPos3svMESA( const GLshort *p );
-GLAPI void GLAPIENTRY glWindowPos3fvMESA( const GLfloat *p );
-GLAPI void GLAPIENTRY glWindowPos3dvMESA( const GLdouble *p );
-GLAPI void GLAPIENTRY glWindowPos4iMESA( GLint x, GLint y, GLint z, GLint w );
-GLAPI void GLAPIENTRY glWindowPos4sMESA( GLshort x, GLshort y, GLshort z, GLshort w );
-GLAPI void GLAPIENTRY glWindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w );
-GLAPI void GLAPIENTRY glWindowPos4dMESA( GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void GLAPIENTRY glWindowPos4ivMESA( const GLint *p );
-GLAPI void GLAPIENTRY glWindowPos4svMESA( const GLshort *p );
-GLAPI void GLAPIENTRY glWindowPos4fvMESA( const GLfloat *p );
-GLAPI void GLAPIENTRY glWindowPos4dvMESA( const GLdouble *p );
-
-#endif /* GL_MESA_window_pos */
-
-
-
-/*
- * GL_MESA_resize_bufffers (196)
- */
-#ifndef GL_MESA_resize_bufffers
-#define GL_MESA_resize_buffers 1
-
-GLAPI void GLAPIENTRY glResizeBuffersMESA( void );
-
-#endif /* GL_MESA_resize_bufffers */
-
-
-
-#if defined(__BEOS__) || defined(__QUICKDRAW__)
-#pragma export off
-#endif
-
-
-#ifdef macintosh
- #pragma enumsalwaysint reset
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __gl_h_ */
diff --git a/xc/include/GL/glx.h b/xc/include/GL/glx.h
index b752f5f09..e4712b95f 100644
--- a/xc/include/GL/glx.h
+++ b/xc/include/GL/glx.h
@@ -33,9 +33,6 @@
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** $Date: 2000/04/20 16:36:37 $ $Revision: 1.7 $
-** $Header: /home/ajax/dri-backup/xc/xc/include/GL/glx.h,v 1.7 2000/04/20 16:36:37 brianp Exp $
*/
#include <X11/Xlib.h>
diff --git a/xc/include/GL/glxtokens.h b/xc/include/GL/glxtokens.h
index 4779c1329..4efa20a71 100644
--- a/xc/include/GL/glxtokens.h
+++ b/xc/include/GL/glxtokens.h
@@ -33,9 +33,6 @@
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** $Date: 2000/04/20 16:36:37 $ $Revision: 1.4 $
-** $Header: /home/ajax/dri-backup/xc/xc/include/GL/glxtokens.h,v 1.4 2000/04/20 16:36:37 brianp Exp $
*/
#ifdef __cplusplus
diff --git a/xc/lib/GL/Imakefile b/xc/lib/GL/Imakefile
index 1a6349767..79a9c4b7d 100644
--- a/xc/lib/GL/Imakefile
+++ b/xc/lib/GL/Imakefile
@@ -134,6 +134,22 @@ REQUIREDLIBS += -lglide3x
GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src
+#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
+
+ DRVOBJS = $(R128OBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS)
+ DRVUOBJS = $(R128UOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS)
+ DRVDOBJS = $(R128DOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS)
+ DRVPOBJS = $(R128POBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS)
+ DRVDONES = $(R128DONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES)
+
+ GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src
+
#elif GlxBuiltInMesa
#ifndef GlxDriverUsesMesa
@@ -237,5 +253,6 @@ DRIVERSUBDIRS = mesa/dri mesa/include/GL mesa/src
MakeSubdirs($(DRIVERSUBDIRS))
DependSubdirs($(DRIVERSUBDIRS))
+InstallSubdirs($(DRIVERSUBDIRS))
#endif
diff --git a/xc/lib/GL/dri/drm/Imakefile b/xc/lib/GL/dri/drm/Imakefile
index 4fd493e1d..bf69a58cb 100644
--- a/xc/lib/GL/dri/drm/Imakefile
+++ b/xc/lib/GL/dri/drm/Imakefile
@@ -12,8 +12,10 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
DEFINES = $(ALLOC_DEFINES)
INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) -I.
- SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c
- OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o
+ SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c \
+ xf86drmR128.c
+ OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o \
+ xf86drmR128.o
#if defined(LinuxArchitecture)
OS_SUBDIR = linux
@@ -27,6 +29,9 @@ LinkSourceFile(xf86drm.h,$(XF86OSSRC))
LinkSourceFile(drm.h,$(XF86OSSRC)/$(OS_SUBDIR)/drm/kernel)
LinkSourceFile(mga_drm.h,$(XF86OSSRC)/$(OS_SUBDIR)/drm/kernel)
LinkSourceFile(i810_drm.h,$(XF86OSSRC)/$(OS_SUBDIR)/drm/kernel)
+LinkSourceFile(xf86drmR128.c,$(XF86OSSRC)/$(OS_SUBDIR)/drm)
+LinkSourceFile(xf86drmR128.h,$(XF86OSSRC))
+LinkSourceFile(r128_drm.h,$(XF86OSSRC)/$(OS_SUBDIR)/drm/kernel)
#include <Library.tmpl>
diff --git a/xc/lib/GL/mesa/src/drv/Imakefile b/xc/lib/GL/mesa/src/drv/Imakefile
index 306bf16dc..ed30e7196 100644
--- a/xc/lib/GL/mesa/src/drv/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/Imakefile
@@ -22,6 +22,9 @@ DRIVER += common mga
#if GlxBuiltInI810
DRIVER += common i810
#endif
+#if GlxBuiltInR128
+DRIVER += r128
+#endif
SUBDIRS = $(DRIVER)
#else
@@ -32,6 +35,7 @@ SUBDIRS += tdfx
SUBDIRS += common
SUBDIRS += mga
SUBDIRS += i810
+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..dd9d92305
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/Imakefile
@@ -0,0 +1,325 @@
+XCOMM $XFree86$
+
+#include <Threads.tmpl>
+
+#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../../../dri \
+ -I$(TOP)/include \
+ -I$(TOP)/include/GL \
+ -I$(XF86OSSRC) \
+ -I$(XF86COMSRC) \
+ -I$(SERVERSRC)/GL/dri \
+ -I$(XF86DRIVERSRC)/r128 \
+ -I../../../include \
+ -I../.. \
+ -I../../X \
+ -I../common
+#endif
+
+LinkSourceFile(mm.c, ../common)
+LinkSourceFile(mm.h, ../common)
+LinkSourceFile(hwlog.c, ../common)
+LinkSourceFile(hwlog.h, ../common)
+
+MESA_INCLUDES = -I. -I.. -I../../include
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES)
+ INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ R128SRCS = r128_cce.c \
+ r128_clear.c \
+ r128_context.c \
+ r128_dd.c \
+ r128_fastpath.c \
+ r128_pipeline.c \
+ r128_screen.c \
+ r128_span.c \
+ r128_state.c \
+ r128_swap.c \
+ r128_tex.c \
+ r128_tris.c \
+ r128_vb.c \
+ r128_xmesa.c
+
+ R128OBJS = r128_cce.o \
+ r128_clear.o \
+ r128_context.o \
+ r128_dd.o \
+ r128_fastpath.o \
+ r128_pipeline.o \
+ r128_screen.o \
+ r128_span.o \
+ r128_state.o \
+ r128_swap.o \
+ r128_tex.o \
+ r128_tris.o \
+ r128_vb.o \
+ r128_xmesa.o
+
+#if !GlxUseBuiltInDRIDriver
+ DRISRCS = ../../../dri/dri_mesa.c \
+ ../../../../dri/dri_tmm.c
+
+ DRIOBJS = ../../../dri/dri_mesa.o \
+ ../../../../dri/dri_tmm.o
+
+ DRMSRCS = ../../../../dri/drm/xf86drm.c \
+ ../../../../dri/drm/xf86drmHash.c \
+ ../../../../dri/drm/xf86drmRandom.c \
+ ../../../../dri/drm/xf86drmSL.c \
+ ../../../../dri/drm/xf86drmR128.c
+
+ DRMOBJS = ../../../../dri/drm/xf86drm.o \
+ ../../../../dri/drm/xf86drmHash.o \
+ ../../../../dri/drm/xf86drmRandom.o \
+ ../../../../dri/drm/xf86drmSL.o \
+ ../../../../dri/drm/xf86drmR128.o
+
+ MESASRCS = ../../aatriangle.c \
+ ../../accum.c \
+ ../../alpha.c \
+ ../../alphabuf.c \
+ ../../attrib.c \
+ ../../bbox.c \
+ ../../bitmap.c \
+ ../../blend.c \
+ ../../buffers.c \
+ ../../clip.c \
+ ../../colortab.c \
+ ../../config.c \
+ ../../context.c \
+ ../../copypix.c \
+ ../../cva.c \
+ ../../debug_xform.c \
+ ../../depth.c \
+ ../../dlist.c \
+ ../../drawpix.c \
+ ../../enable.c \
+ ../../enums.c \
+ ../../eval.c \
+ ../../extensions.c \
+ ../../feedback.c \
+ ../../fog.c \
+ ../../get.c \
+ ../../glapi.c \
+ ../../glapinoop.c \
+ ../../glthread.c \
+ ../../hash.c \
+ ../../image.c \
+ ../../imaging.c \
+ ../../light.c \
+ ../../lines.c \
+ ../../logic.c \
+ ../../masking.c \
+ ../../matrix.c \
+ ../../mem.c \
+ ../../mmath.c \
+ ../../pb.c \
+ ../../pipeline.c \
+ ../../pixel.c \
+ ../../pixeltex.c \
+ ../../points.c \
+ ../../polygon.c \
+ ../../quads.c \
+ ../../rastpos.c \
+ ../../readpix.c \
+ ../../rect.c \
+ ../../scissor.c \
+ ../../shade.c \
+ ../../span.c \
+ ../../stages.c \
+ ../../state.c \
+ ../../stencil.c \
+ ../../teximage.c \
+ ../../texobj.c \
+ ../../texstate.c \
+ ../../texture.c \
+ ../../texutil.c \
+ ../../translate.c \
+ ../../triangle.c \
+ ../../varray.c \
+ ../../vb.c \
+ ../../vbcull.c \
+ ../../vbfill.c \
+ ../../vbindirect.c \
+ ../../vbrender.c \
+ ../../vbxform.c \
+ ../../vector.c \
+ ../../vertices.c \
+ ../../winpos.c \
+ ../../xform.c \
+ ../../zoom.c \
+ ../../X86/common_x86.c
+
+ MESAOBJS = ../../aatriangle.o \
+ ../../accum.o \
+ ../../alpha.o \
+ ../../alphabuf.o \
+ ../../attrib.o \
+ ../../bbox.o \
+ ../../bitmap.o \
+ ../../blend.o \
+ ../../buffers.o \
+ ../../clip.o \
+ ../../colortab.o \
+ ../../config.o \
+ ../../context.o \
+ ../../copypix.o \
+ ../../cva.o \
+ ../../debug_xform.o \
+ ../../depth.o \
+ ../../dlist.o \
+ ../../drawpix.o \
+ ../../enable.o \
+ ../../enums.o \
+ ../../eval.o \
+ ../../extensions.o \
+ ../../feedback.o \
+ ../../fog.o \
+ ../../get.o \
+ ../../hash.o \
+ ../../hint.o \
+ ../../image.o \
+ ../../imaging.o \
+ ../../light.o \
+ ../../lines.o \
+ ../../logic.o \
+ ../../masking.o \
+ ../../matrix.o \
+ ../../mem.o \
+ ../../mmath.o \
+ ../../pb.o \
+ ../../pipeline.o \
+ ../../pixel.o \
+ ../../pixeltex.o \
+ ../../points.o \
+ ../../polygon.o \
+ ../../quads.o \
+ ../../rastpos.o \
+ ../../readpix.o \
+ ../../rect.o \
+ ../../scissor.o \
+ ../../shade.o \
+ ../../span.o \
+ ../../stages.o \
+ ../../state.o \
+ ../../stencil.o \
+ ../../teximage.o \
+ ../../texobj.o \
+ ../../texstate.o \
+ ../../texture.o \
+ ../../texutil.o \
+ ../../translate.o \
+ ../../triangle.o \
+ ../../varray.o \
+ ../../vb.o \
+ ../../vbcull.o \
+ ../../vbfill.o \
+ ../../vbindirect.o \
+ ../../vbrender.o \
+ ../../vbxform.o \
+ ../../vector.o \
+ ../../vertices.o \
+ ../../winpos.o \
+ ../../xform.o \
+ ../../zoom.o
+
+#ifdef i386Architecture
+ X86_SRCS = ../../X86/x86.c \
+ ../../X86/x86a.S \
+ ../../X86/common_x86.c \
+ ../../X86/common_x86asm.S \
+ ../../X86/vertex.S
+
+ X86_OBJS = ../../X86/x86.o \
+ ../../X86/x86a.o \
+ ../../X86/common_x86.o \
+ ../../X86/common_x86asm.o \
+ ../../X86/vertex.o
+
+ MMX_SRCS = ../../X86/mmx_blend.S
+
+ MMX_OBJS = ../../X86/mmx_blend.o
+
+XCOMM Disabling 3Dnow code for the time being.
+#if 0
+ 3DNOW_SRCS = ../../X86/3dnow.c \
+ ../../X86/3dnow_norm_raw.S \
+ ../../X86/3dnow_xform_masked1.S \
+ ../../X86/3dnow_xform_masked2.S \
+ ../../X86/3dnow_xform_masked3.S \
+ ../../X86/3dnow_xform_masked4.S \
+ ../../X86/3dnow_xform_raw1.S \
+ ../../X86/3dnow_xform_raw2.S \
+ ../../X86/3dnow_xform_raw3.S \
+ ../../X86/3dnow_xform_raw4.S \
+ ../../X86/vertex_3dnow.S
+
+ 3DNOW_OBJS = ../../X86/3dnow.o \
+ ../../X86/3dnow_norm_raw.o \
+ ../../X86/3dnow_xform_masked1.o \
+ ../../X86/3dnow_xform_masked2.o \
+ ../../X86/3dnow_xform_masked3.o \
+ ../../X86/3dnow_xform_masked4.o \
+ ../../X86/3dnow_xform_raw1.o \
+ ../../X86/3dnow_xform_raw2.o \
+ ../../X86/3dnow_xform_raw3.o \
+ ../../X86/3dnow_xform_raw4.o \
+ ../../X86/vertex_3dnow.o
+#endif
+
+#endif
+#endif
+
+ ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS)
+ ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS)
+
+ COMMONSRCS = mm.c hwlog.c
+ COMMONOBJS = mm.o hwlog.o
+
+ SRCS = $(DRISRCS) $(DRMSRCS) $(MESASRCS) $(ASMSRCS) \
+ $(COMMONSRCS) $(R128SRCS)
+ OBJS = $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) $(ASMOBJS) \
+ $(COMMONOBJS) $(R128OBJS)
+
+REQUIREDLIBS += -lm
+#if !GlxBuiltInMga
+REQUIREDLIBS += -L../../../.. -lGL
+#endif
+
+#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)/dri,.)
+#endif
+
+DependTarget()
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_cce.c b/xc/lib/GL/mesa/src/drv/r128/r128_cce.c
new file mode 100644
index 000000000..e949dd37c
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_cce.c
@@ -0,0 +1,389 @@
+/* $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_reg.h"
+#include "r128_cce.h"
+
+#if USE_USER_SPACE_RING
+
+#define USE_IOCTLS 0
+#define DO_SECURITY_CHECK 1
+#define R128_TIMEOUT 2000000
+
+#if DEBUG
+static void r128RingStatus(r128ScreenPtr pScrn)
+{
+ unsigned char *R128MMIO = pScrn->mmio;
+
+ R128_DEBUG(("GUI_STAT = 0x%08x\n",
+ (unsigned int)INREG(R128_GUI_STAT)));
+ R128_DEBUG(("PM4_STAT = 0x%08x\n",
+ (unsigned int)INREG(R128_PM4_STAT)));
+ R128_DEBUG(("PM4_BUFFER_DL_WPTR = 0x%08x\n",
+ (unsigned int)INREG(R128_PM4_BUFFER_DL_WPTR)));
+ R128_DEBUG(("PM4_BUFFER_DL_RPTR = 0x%08x\n",
+ (unsigned int)INREG(R128_PM4_BUFFER_DL_RPTR)));
+ R128_DEBUG(("ringWrite = 0x%08x\n", pScrn->SAREA->ringWrite));
+ R128_DEBUG(("*ringReadPtr = 0x%08x\n", *pScrn->ringReadPtr));
+}
+#endif
+
+/* FIXME: Requires access to secure registers */
+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);
+}
+
+/* FIXME: Requires access to secure registers */
+static 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;
+ }
+}
+
+/* FIXME: Requires access to secure registers */
+static void r128EngineReset(r128ScreenPtr pScrn)
+{
+#if USE_IOCTLS
+#if DEBUG
+ r128RingStatus(pScrn);
+#endif
+
+ (void)drmR128EngineReset(pScrn->driScreen->fd);
+#else
+ unsigned char *R128MMIO = pScrn->mmio;
+ CARD32 clock_cntl_index;
+ CARD32 mclk_cntl;
+ CARD32 gen_reset_cntl;
+
+#if DEBUG
+ r128RingStatus(pScrn);
+#endif
+
+ 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);
+
+ /* Reset the ring buffer status */
+ if (R128CCE_USE_RING_BUFFER(pScrn->CCEMode)) {
+ OUTREG(R128_PM4_BUFFER_DL_WPTR, 0);
+ OUTREG(R128_PM4_BUFFER_DL_RPTR, 0);
+ pScrn->SAREA->ringWrite = 0;
+ *pScrn->ringReadPtr = 0;
+ }
+#endif
+ fprintf(stderr, "Error: Rage 128 timed out... exiting\n");
+ exit(-1);
+}
+
+#define r128CCEWaitForFifo(pScrn, entries) \
+do { \
+ if (pScrn->CCEFifoSlots < entries) \
+ r128CCEWaitForFifoFunction(pScrn, entries); \
+ pScrn->CCEFifoSlots -= entries; \
+} while (0)
+
+/* Wait for at least `entries' slots are free. The actual number of
+ slots available is stored in info->CCEFifoSize. */
+static 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;
+ }
+ R128_DEBUG(("Reseting Engine: PM4_STAT = 0x%08x\n",
+ (unsigned int)INREG(R128_PM4_STAT)));
+ r128EngineReset(pScrn);
+ }
+}
+
+/* Wait until the CCE is completely idle: the FIFO has drained and the
+ CCE is idle. */
+void r128CCEWaitForIdle(r128ScreenPtr pScrn)
+{
+#if USE_IOCTLS
+ if (drmR128WaitForIdle(pScrn->driScreen->fd) < 0) {
+ fprintf(stderr, "Error: Rage 128 timed out... exiting\n");
+ exit(-1);
+ }
+#else
+ unsigned char *R128MMIO = pScrn->mmio;
+ int i;
+
+ if (R128CCE_USE_RING_BUFFER(pScrn->CCEMode)) {
+ OUTREGP(R128_PM4_BUFFER_DL_WPTR,
+ R128_PM4_BUFFER_DL_DONE, ~R128_PM4_BUFFER_DL_DONE);
+
+ for (;;) {
+ for (i = 0; i < R128_TIMEOUT; i++) {
+ if (*pScrn->ringReadPtr == pScrn->SAREA->ringWrite) {
+ int pm4stat = INREG(R128_PM4_STAT);
+ if ((pm4stat & R128_PM4_FIFOCNT_MASK) == pScrn->CCEFifoSize
+ && !(pm4stat & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE)))
+ return;
+ }
+ }
+ R128_DEBUG(("Reseting Engine: PM4_STAT = 0x%08x\n",
+ (unsigned int)INREG(R128_PM4_STAT)));
+ r128EngineReset(pScrn);
+ }
+ } else {
+ 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;
+ }
+ }
+ R128_DEBUG(("Reseting Engine: PM4_STAT = 0x%08x\n",
+ (unsigned int)INREG(R128_PM4_STAT)));
+ r128EngineReset(pScrn);
+ }
+ }
+#endif
+}
+
+/* Send a packet to the CCE via the PIO registers */
+static void r128CCESubmitPacketPIO(r128ContextPtr r128ctx,
+ CARD32 *buf, int count)
+{
+ unsigned char *R128MMIO = r128ctx->r128Screen->mmio;
+#if DO_SECURITY_CHECK
+ CARD32 tmp = 0;
+ int psize = 0;
+ int writing = 1;
+ int addr = R128_PM4_FIFO_DATA_EVEN;
+#endif
+
+#if DO_SECURITY_CHECK
+ while (count > 0) {
+ tmp = *buf++;
+ if (!psize) {
+ writing = 1;
+
+ if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET0) {
+ if ((tmp & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2)) {
+ if ((tmp & R128_CCE_PACKET0_REG_MASK) !=
+ (R128_PM4_VC_FPU_SETUP >> 2)) {
+ writing = 0;
+ }
+ }
+ psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2;
+ } else if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET1) {
+ if ((tmp & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2)) {
+ if ((tmp & R128_CCE_PACKET1_REG0_MASK) !=
+ (R128_PM4_VC_FPU_SETUP >> 2)) {
+ writing = 0;
+ }
+ } else if ((tmp & R128_CCE_PACKET1_REG1_MASK) <=
+ (0x1004 << 9)) {
+ if ((tmp & R128_CCE_PACKET1_REG1_MASK) !=
+ (R128_PM4_VC_FPU_SETUP << 9)) {
+ writing = 0;
+ }
+ }
+ psize = 3;
+ } else {
+ psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2;
+ }
+ }
+ psize--;
+
+ if (writing) {
+ r128CCEWaitForFifo(r128ctx->r128Screen, 1);
+ OUTREG(addr, tmp);
+ addr ^= 0x0004;
+ }
+
+ count--;
+ }
+
+ if (addr == R128_PM4_FIFO_DATA_ODD) {
+ r128CCEWaitForFifo(r128ctx->r128Screen, 1);
+ OUTREG(addr, R128_CCE_PACKET2);
+ }
+#else
+ while (count > 1) {
+ r128CCEWaitForFifo(r128ctx->r128Screen, 2);
+ OUTREG(R128_PM4_FIFO_DATA_EVEN, *buf++);
+ OUTREG(R128_PM4_FIFO_DATA_ODD, *buf++);
+ count -= 2;
+ }
+
+ if (count) {
+ r128CCEWaitForFifo(r128ctx->r128Screen, 2);
+ OUTREG(R128_PM4_FIFO_DATA_EVEN, *buf);
+ OUTREG(R128_PM4_FIFO_DATA_ODD, R128_CCE_PACKET2);
+ }
+#endif
+}
+
+/* Send a packet to the CCE via the ring */
+static void r128CCESubmitPacketRing(r128ContextPtr r128ctx,
+ CARD32 *buf, int count)
+{
+ r128ScreenPtr r128scrn = r128ctx->r128Screen;
+ unsigned char *R128MMIO = r128ctx->r128Screen->mmio;
+ int ringWrite = r128scrn->SAREA->ringWrite;
+ int *ringWritePtr = r128scrn->ringStartPtr + ringWrite;
+ int timeout;
+#if DO_SECURITY_CHECK
+ CARD32 tmp = 0;
+ int psize = 0;
+ int writing = 1;
+#endif
+
+ if (count > r128scrn->ringEntries) {
+ /* FIXME */
+ return;
+ }
+
+ while (count > 0) {
+#if DO_SECURITY_CHECK
+ tmp = *buf++;
+ if (!psize) {
+ writing = 1;
+
+ if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET0) {
+ if ((tmp & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2)) {
+ if ((tmp & R128_CCE_PACKET0_REG_MASK) !=
+ (R128_PM4_VC_FPU_SETUP >> 2)) {
+ writing = 0;
+ }
+ }
+ psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2;
+ } else if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET1) {
+ if ((tmp & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2)) {
+ if ((tmp & R128_CCE_PACKET1_REG0_MASK) !=
+ (R128_PM4_VC_FPU_SETUP >> 2)) {
+ writing = 0;
+ }
+ } else if ((tmp & R128_CCE_PACKET1_REG1_MASK) <=
+ (0x1004 << 9)) {
+ if ((tmp & R128_CCE_PACKET1_REG1_MASK) !=
+ (R128_PM4_VC_FPU_SETUP << 9)) {
+ writing = 0;
+ }
+ }
+ psize = 3;
+ } else {
+ psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2;
+ }
+ }
+ psize--;
+
+ if (writing) {
+ ringWrite++;
+ *ringWritePtr++ = tmp;
+ }
+#else
+ ringWrite++;
+ *ringWritePtr++ = *buf++;
+#endif
+ if (ringWrite >= r128scrn->ringEntries) {
+ ringWrite = 0;
+ ringWritePtr = r128scrn->ringStartPtr;
+ }
+ timeout = 0;
+ while (ringWrite == *r128scrn->ringReadPtr) {
+ (void)INREG(R128_PM4_BUFFER_DL_RPTR);
+ if (timeout++ >= R128_TIMEOUT) r128EngineReset(r128scrn);
+ }
+
+ count--;
+ }
+
+ if (ringWrite < 32) {
+ memcpy(r128scrn->ringEndPtr,
+ r128scrn->ringStartPtr,
+ ringWrite * sizeof(int));
+ }
+
+ r128scrn->SAREA->ringWrite = ringWrite;
+ OUTREG(R128_PM4_BUFFER_DL_WPTR, ringWrite);
+}
+
+void r128CCESubmitPackets(r128ContextPtr r128ctx, CARD32 *buf, int count)
+{
+#if USE_IOCTLS
+ if (drmR128SubmitPackets(r128ctx->r128Screen->driScreen->fd,
+ r128ctx->CCEbuf, r128ctx->CCEcount,
+ 0) < 0) {
+ r128EngineReset(r128ctx->r128Screen);
+ fprintf(stderr, "Error: Illegal CCE packet... exiting\n");
+ exit(-1);
+ }
+#else
+ if (R128CCE_USE_RING_BUFFER(r128ctx->r128Screen->CCEMode))
+ r128CCESubmitPacketRing(r128ctx, buf, count);
+ else
+ r128CCESubmitPacketPIO(r128ctx, buf, count);
+#endif
+}
+
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_cce.h b/xc/lib/GL/mesa/src/drv/r128/r128_cce.h
new file mode 100644
index 000000000..162686cb7
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_cce.h
@@ -0,0 +1,142 @@
+/* $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_CCE_H_
+#define _R128_CCE_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include "r128_dri.h"
+#include "r128_reg.h"
+
+#include "xf86drmR128.h"
+
+typedef union {
+ float f;
+ int i;
+} floatTOint;
+
+#define R128_DEFAULT_TOTAL_CCE_TIMEOUT 1000000 /* usecs */
+
+/* Insert an integer value into the CCE ring buffer. */
+#define R128CCE(v) \
+ do { \
+ r128ctx->CCEbuf[r128ctx->CCEcount] = (v); \
+ r128ctx->CCEcount++; \
+ } while (0)
+
+/* Insert an floating point value into the CCE ring buffer. */
+#define R128CCEF(v) \
+ do { \
+ floatTOint fTi; \
+ fTi.f = (v); \
+ r128ctx->CCEbuf[r128ctx->CCEcount] = fTi.i; \
+ r128ctx->CCEcount++; \
+ } while (0)
+
+#if USE_USER_SPACE_RING
+
+#define R128CCE_SUBMIT_PACKETS() \
+ do { \
+ r128CCESubmitPackets(r128ctx, r128ctx->CCEbuf, r128ctx->CCEcount); \
+ r128ctx->CCEcount = 0; \
+ } while (0)
+
+#define R128CCE_WAIT_FOR_IDLE(r128ctx) \
+ r128CCEWaitForIdle(r128ctx->r128Screen)
+
+#else /* if !USE_USER_SPACE_RING */
+
+#define R128CCE_SUBMIT_PACKETS() \
+ do { \
+ CARD32 *_buf; \
+ int _c = r128ctx->CCEcount; \
+ int _fd = r128ctx->r128Screen->driScreen->fd; \
+ int _to = 0; \
+ int _ret; \
+ \
+ do { \
+ _buf = r128ctx->CCEbuf + (r128ctx->CCEcount - _c); \
+ _ret = drmR128SubmitPackets(_fd, _buf, &_c, 0); \
+ } while (_ret < 0 && _ret == -EBUSY && _to++ < r128ctx->CCEtimeout); \
+ if (_ret < 0) { \
+ (void)drmR128EngineReset(_fd); \
+ fprintf(stderr, "Error: Could not submit packet... exiting\n"); \
+ exit(-1); \
+ } \
+ r128ctx->CCEcount = 0; \
+ } while (0)
+
+#define R128CCE_WAIT_FOR_IDLE(r128ctx) \
+ do { \
+ int _fd = r128ctx->r128Screen->driScreen->fd; \
+ int _to = 0; \
+ int _ret; \
+ \
+ (void)drmR128EngineFlush(_fd); \
+ do { \
+ _ret = drmR128CCEWaitForIdle(_fd); \
+ } while (_ret < 0 && _ret == -EBUSY && _to++ < r128ctx->CCEtimeout); \
+ if (_ret < 0) { \
+ (void)drmR128EngineReset(_fd); \
+ fprintf(stderr, "Error: Rage 128 timed out... exiting\n"); \
+ exit(-1); \
+ } \
+ } while (0)
+
+#endif
+
+#define R128CCE_WAIT_FOR_IDLE_LOCK(r128ctx) \
+ do { \
+ LOCK_HARDWARE(r128ctx); \
+ R128CCE_WAIT_FOR_IDLE(r128ctx); \
+ UNLOCK_HARDWARE(r128ctx); \
+ } while (0)
+
+
+/* Insert a type-[0123] packet header into the ring buffer */
+#define R128CCE0(p,r,n) R128CCE((p) | ((n) << 16) | ((r) >> 2))
+#define R128CCE1(p,r1,r2) R128CCE((p) | (((r2) >> 2) << 11) | ((r1) >> 2))
+#define R128CCE2(p) R128CCE((p))
+#define R128CCE3(p,n) R128CCE((p) | ((n) << 16))
+
+
+#if USE_USER_SPACE_RING
+extern void r128CCEWaitForIdle(r128ScreenPtr pScrn);
+extern void r128CCESubmitPackets(r128ContextPtr r128ctx,
+ CARD32 *buf, int count);
+#endif
+
+#endif
+#endif /* _R128_CCE_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_ccevb.h b/xc/lib/GL/mesa/src/drv/r128/r128_ccevb.h
new file mode 100644
index 000000000..2084b8672
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_ccevb.h
@@ -0,0 +1,224 @@
+/* $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_CCEVB_H_
+#define _R128_CCEVB_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include "xf86drmR128.h"
+
+typedef struct {
+ CARD32 *buf; /* Pointer to current VB */
+ int index; /* Index of current VB */
+ int start; /* in bytes from the beginning of the VB map */
+ int size; /* in vertices */
+ int count; /* in vertices */
+ drmR128PrimType prim; /* Primitive type for vertices in VB */
+ int done; /* VB has been sent to ring */
+} r128CCEVertBuf, *r128CCEVertBufPtr;
+
+
+
+/* Flush the CPU's write-combining cache */
+/* FIXME: This code is both processor and compiler specific */
+#define R128_FLUSH_WC_MEMORY() \
+ do { \
+ int xchangeDummy; \
+ \
+ __asm__ volatile("push %%eax ;" \
+ "xchg %%eax, %0 ;" \
+ "pop %%eax" : : "m" (xchangeDummy)); \
+ __asm__ volatile("push %%eax ;" \
+ "push %%ebx ;" \
+ "push %%ecx ;" \
+ "push %%edx ;" \
+ "movl $0,%%eax ;" \
+ "cpuid ;" \
+ "pop %%edx ;" \
+ "pop %%ecx ;" \
+ "pop %%ebx ;" \
+ "pop %%eax" : /* no outputs */ : /* no inputs */); \
+ } while (0)
+
+
+/* Get a new VB from the pool of vertex buffers in AGP space */
+/* NOTE: By default the primitive type for a VB is set to individual tris */
+#define R128CCE_GET_NEW_VB(r128ctx) \
+ do { \
+ r128CCEVertBufPtr vb = &r128ctx->vb; \
+ int to = 0; \
+ int fd = r128ctx->r128Screen->driScreen->fd; \
+ int num; \
+ int index; \
+ int size; \
+ \
+ vb->buf = NULL; \
+ \
+ LOCK_HARDWARE(r128ctx); \
+ while (!vb->buf && to++ < r128ctx->CCEtimeout) { \
+ /* Ask the kernel a new vertex buffer */ \
+ num = drmR128GetVertexBuffers(fd, 1, &index, &size); \
+ \
+ if (num > 0) { \
+ vb->buf = (CARD32 *)(r128ctx->r128Screen-> \
+ vbBufs->list[index].address); \
+ vb->index = index; \
+ vb->start = index*r128ctx->r128Screen->vbBufSize; \
+ vb->size = size/sizeof(r128_vertex); \
+ vb->count = 0; \
+ vb->prim = DRM_R128_PRIM_TRI_LIST; \
+ vb->done = GL_FALSE; \
+ } \
+ } \
+ UNLOCK_HARDWARE(r128ctx); \
+ \
+ if (!vb->buf) { \
+ (void)drmR128EngineReset(fd); \
+ fprintf(stderr, "Error: Could not get new VB... exiting\n"); \
+ exit(-1); \
+ } \
+ } while (0)
+
+/* Submit a VB to the hardware for processing */
+/* NOTE: This macro is only called while holding the hardware lock */
+#define R128CCE_SUBMIT_VB(r128ctx) \
+ do { \
+ int index = r128ctx->vb.index; \
+ int size = r128ctx->vb.count; \
+ int fd = r128ctx->r128Screen->driScreen->fd; \
+ int to = 0; \
+ int ret; \
+ CARD32 prim; \
+ \
+ switch (r128ctx->vb.prim) { \
+ case DRM_R128_PRIM_NONE: \
+ prim = R128_CCE_VC_CNTL_PRIM_TYPE_NONE; \
+ break; \
+ case DRM_R128_PRIM_POINT: \
+ prim = R128_CCE_VC_CNTL_PRIM_TYPE_POINT; \
+ break; \
+ case DRM_R128_PRIM_LINE: \
+ prim = R128_CCE_VC_CNTL_PRIM_TYPE_LINE; \
+ break; \
+ case DRM_R128_PRIM_POLY_LINE: \
+ prim = R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE; \
+ break; \
+ case DRM_R128_PRIM_TRI_LIST: \
+ prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST; \
+ break; \
+ case DRM_R128_PRIM_TRI_FAN: \
+ prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN; \
+ break; \
+ case DRM_R128_PRIM_TRI_STRIP: \
+ prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP; \
+ break; \
+ case DRM_R128_PRIM_TRI_TYPE2: \
+ prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2; \
+ break; \
+ default: \
+ prim = R128_CCE_VC_CNTL_PRIM_TYPE_NONE; \
+ break; \
+ } \
+ \
+ /* Send the vertex buffer to the hardware */ \
+ BEGIN_CLIP_LOOP(r128ctx); \
+ \
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM, 3); \
+ R128CCE(r128ctx->r128Screen->vbOffset + r128ctx->vb.start); \
+ R128CCE(r128ctx->vb.count); \
+ R128CCE(R128_FULL_VERTEX_FORMAT); \
+ R128CCE(prim | R128_CCE_VC_CNTL_PRIM_WALK_LIST | \
+ (r128ctx->vb.count << R128_CCE_VC_CNTL_NUM_SHIFT)); \
+ R128CCE_SUBMIT_PACKETS(); \
+ \
+ END_CLIP_LOOP(r128ctx); \
+ \
+ /* Tell the kernel to release the vertex buffer */ \
+ do { \
+ ret = drmR128FlushVertexBuffers(fd, 1, &index, &size, \
+ r128ctx->vb.prim); \
+ } while (ret < 0 && ret == -EBUSY && to++ < r128ctx->CCEtimeout); \
+ if (ret < 0) { \
+ (void)drmR128EngineReset(fd); \
+ fprintf(stderr, "Error: Could not flush VB... exiting\n"); \
+ exit(-1); \
+ } \
+ \
+ r128ctx->vb.done = GL_TRUE; \
+ } while (0)
+
+/* Flush the vertex buffer (assuming we already hold the lock) */
+#define R128CCE_FLUSH_VB(r128ctx) \
+ do { \
+ if (r128ctx->vb.count && !r128ctx->vb.done) { \
+ /* FIXME: Is this _really_ needed? */ \
+ if (!R128CCE_USE_RING_BUFFER(r128ctx->r128Screen->CCEMode)) \
+ R128CCE_WAIT_FOR_IDLE(r128ctx); \
+ \
+ R128CCE_SUBMIT_VB(r128ctx); \
+ } \
+ } while (0)
+
+/* Flush the vertex buffer */
+#define R128CCE_FLUSH_VB_LOCK(r128ctx) \
+ do { \
+ LOCK_HARDWARE(r128ctx); \
+ R128CCE_FLUSH_VB(r128ctx); \
+ UNLOCK_HARDWARE(r128ctx); \
+ } while (0)
+
+/* Reserve space in a VB to store `n' vertices, and set the pointer `p'
+ to point to the next vertex in the current VB. If adding these
+ vertices to the VB would exceed the size of the VB, then flush the
+ current VB, get a new one from the pool of VBs, reserve space in the
+ new VB for the `n' vertices, and set the pointer `p' to point to the
+ first vertex in the new VB. */
+#define R128CCE_ALLOC_VB_SPACE(r128ctx, p, n) \
+ do { \
+ r128CCEVertBufPtr vb = &r128ctx->vb; \
+ \
+ if (vb->done) R128CCE_GET_NEW_VB(r128ctx); \
+ \
+ if (vb->count + (n) > vb->size) { \
+ R128CCE_FLUSH_VB_LOCK(r128ctx); \
+ R128CCE_GET_NEW_VB(r128ctx); \
+ } \
+ \
+ (p) = (r128_vertex *)vb->buf + vb->count; \
+ vb->count += (n); \
+ } while (0)
+
+#endif
+#endif /* _R128_CCEVB_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_clear.c b/xc/lib/GL/mesa/src/drv/r128/r128_clear.c
new file mode 100644
index 000000000..9ab0581b0
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_clear.c
@@ -0,0 +1,248 @@
+/* $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_reg.h"
+#include "r128_cce.h"
+#include "r128_state.h"
+#include "r128_vb.h"
+#include "r128_clear.h"
+
+/* Clear the depth buffer */
+void r128ClearDepthBuffer(r128ContextPtr r128ctx, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch)
+{
+ __DRIdrawablePrivate *dPriv = r128ctx->driDrawable;
+ int nc;
+ XF86DRIClipRectPtr c;
+ int dst_bpp;
+ CARD32 write_mask;
+
+ if (!(r128ctx->regs.tex_cntl_c & R128_Z_WRITE_ENABLE)) return;
+
+ switch (r128ctx->regs.z_sten_cntl_c & R128_Z_PIX_WIDTH_MASK) {
+ case R128_Z_PIX_WIDTH_16:
+ write_mask = 0x0000ffff;
+ dst_bpp = R128_GMC_DST_16BPP;
+ break;
+ case R128_Z_PIX_WIDTH_24:
+ write_mask = 0x00ffffff;
+ dst_bpp = R128_GMC_DST_32BPP;
+ break;
+ case R128_Z_PIX_WIDTH_32:
+ write_mask = 0xffffffff;
+ dst_bpp = R128_GMC_DST_32BPP;
+ break;
+ default: return;
+ }
+
+ cx += dPriv->x;
+ cy = dPriv->y + dPriv->h - cy - ch;
+
+ LOCK_HARDWARE(r128ctx);
+
+ /* Flush any outstanding vertex buffers */
+ R128CCE_FLUSH_VB(r128ctx);
+
+ /* Init the clip rects here in case they changed during the
+ LOCK_HARDWARE macro */
+ c = dPriv->pClipRects;
+ nc = dPriv->numClipRects;
+
+ /* Set the write mask so that we _only_ clear the Z buffer */
+ R128CCE0(R128_CCE_PACKET0, R128_DP_WRITE_MASK, 0);
+ R128CCE(write_mask);
+
+ /* Temporarily disable Z and stencil buffer and texture mapping modes */
+ R128CCE0(R128_CCE_PACKET0, R128_TEX_CNTL_C, 0);
+ R128CCE(r128ctx->regs.tex_cntl_c & ~(R128_Z_ENABLE |
+ R128_STENCIL_ENABLE |
+ R128_TEXMAP_ENABLE));
+
+ /* Cycle through the clip rects */
+ while (nc--) {
+ int x = c[nc].x1;
+ int y = c[nc].y1;
+ int w = c[nc].x2 - x;
+ int h = c[nc].y2 - y;
+
+ if (!all) {
+ if (x < cx) w -= cx - x, x = cx;
+ if (y < cy) h -= cy - y, y = cy;
+
+ if (x + w > cx + cw) w = cx + cw - x;
+ if (y + h > cy + ch) h = cy + ch - y;
+
+ if (w <= 0 || h <= 0) continue;
+ }
+
+ x += r128ctx->r128Screen->depthX;
+ y += r128ctx->r128Screen->depthY;
+
+ R128CCE3(R128_CCE_PACKET3_CNTL_PAINT_MULTI, 3);
+ R128CCE(R128_GMC_BRUSH_SOLID_COLOR
+ | dst_bpp
+ | R128_GMC_SRC_DATATYPE_COLOR
+ | R128_ROP3_P
+ | R128_GMC_3D_FCN_EN /* FIXME?? */
+ | R128_GMC_CLR_CMP_CNTL_DIS /* FIXME?? */
+ | R128_AUX_CLIP_DIS /* FIXME?? */
+ | R128_GMC_WR_MSK_DIS); /* FIXME?? */
+ R128CCE(r128ctx->ClearDepth);
+ R128CCE((x << 16) | y);
+ R128CCE((w << 16) | h);
+ }
+
+#if 0
+ /* Set the write mask so that we _only_ clear the Z buffer */
+ R128CCE0(R128_CCE_PACKET0, R128_DP_WRITE_MASK, 0);
+ R128CCE(0xffffffff);
+
+ /* Restore Z and stencil buffer and texture mapping modes */
+ R128CCE0(R128_CCE_PACKET0, R128_TEX_CNTL_C, 0);
+ R128CCE(r128ctx->regs.tex_cntl_c);
+#else
+ /* FIXME: We should be able to optimize this by restoring only the
+ registers that change (above) */
+ /* NOTE: The restore of TEX_CNTL_C and R128_DP_WRITE_MASK is handled by
+ vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_ALL_DIRTY;
+#endif
+
+ R128CCE_SUBMIT_PACKETS();
+
+ UNLOCK_HARDWARE(r128ctx);
+}
+
+/* Clear a color buffer */
+void r128ClearColorBuffer(r128ContextPtr r128ctx, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch,
+ GLint drawX, GLint drawY)
+{
+ __DRIdrawablePrivate *dPriv = r128ctx->driDrawable;
+ int nc;
+ XF86DRIClipRectPtr c;
+ int dst_bpp;
+
+ switch (r128ctx->r128Screen->bpp) {
+ case 8:
+ dst_bpp = R128_GMC_DST_8BPP_CI;
+ break;
+ case 16:
+ if (r128ctx->r128Screen->depth == 15) dst_bpp = R128_GMC_DST_15BPP;
+ else dst_bpp = R128_GMC_DST_16BPP;
+ break;
+ case 24:
+ dst_bpp = R128_GMC_DST_24BPP;
+ break;
+ case 32:
+ default:
+ dst_bpp = R128_GMC_DST_32BPP;
+ break;
+ }
+
+ cx += dPriv->x;
+ cy = dPriv->y + dPriv->h - cy - ch;
+
+ LOCK_HARDWARE(r128ctx);
+
+ /* Flush any outstanding vertex buffers */
+ R128CCE_FLUSH_VB(r128ctx);
+
+ /* Init the clip rects here in case they changed during the
+ LOCK_HARDWARE macro */
+ c = dPriv->pClipRects;
+ nc = dPriv->numClipRects;
+
+ /* Temporarily disable Z and stencil buffer and texture mapping modes */
+ R128CCE0(R128_CCE_PACKET0, R128_TEX_CNTL_C, 0);
+ R128CCE(r128ctx->regs.tex_cntl_c & ~(R128_Z_ENABLE |
+ R128_STENCIL_ENABLE |
+ R128_TEXMAP_ENABLE));
+
+ /* Cycle through the clip rects */
+ while (nc--) {
+ int x = c[nc].x1;
+ int y = c[nc].y1;
+ int w = c[nc].x2 - x;
+ int h = c[nc].y2 - y;
+
+ if (!all) {
+ if (x < cx) w -= cx - x, x = cx;
+ if (y < cy) h -= cy - y, y = cy;
+
+ if (x + w > cx + cw) w = cx + cw - x;
+ if (y + h > cy + ch) h = cy + ch - h;
+
+ if (w <= 0 || h <= 0) continue;
+ }
+
+ x += drawX;
+ y += drawY;
+
+ R128CCE3(R128_CCE_PACKET3_CNTL_PAINT_MULTI, 3);
+ R128CCE(R128_GMC_BRUSH_SOLID_COLOR
+ | dst_bpp
+ | R128_GMC_SRC_DATATYPE_COLOR
+ | R128_ROP3_P
+ | R128_GMC_3D_FCN_EN /* FIXME?? */
+ | R128_GMC_CLR_CMP_CNTL_DIS /* FIXME?? */
+ | R128_AUX_CLIP_DIS); /* FIXME?? */
+ R128CCE(r128ctx->ClearColor);
+ R128CCE((x << 16) | y);
+ R128CCE((w << 16) | h);
+ }
+
+#if 0
+ /* Restore Z and stencil buffer and texture mapping modes */
+ R128CCE0(R128_CCE_PACKET0, R128_TEX_CNTL_C, 0);
+ R128CCE(r128ctx->regs.tex_cntl_c);
+#else
+ /* FIXME: We should be able to optimize this by restoring only the
+ registers that change (above) */
+ /* NOTE: The restore of TEX_CNTL_C is handled by
+ vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_ALL_DIRTY;
+#endif
+
+ R128CCE_SUBMIT_PACKETS();
+
+ UNLOCK_HARDWARE(r128ctx);
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_clear.h b/xc/lib/GL/mesa/src/drv/r128/r128_clear.h
new file mode 100644
index 000000000..7018b05b4
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_clear.h
@@ -0,0 +1,47 @@
+/* $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_CLEAR_H_
+#define _R128_CLEAR_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void r128ClearDepthBuffer(r128ContextPtr r128ctx, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height);
+extern void r128ClearColorBuffer(r128ContextPtr r128ctx, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height,
+ GLint drawX, GLint drawY);
+
+#endif
+#endif /* _R128_CLEAR_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_context.c b/xc/lib/GL/mesa/src/drv/r128/r128_context.c
new file mode 100644
index 000000000..01573f559
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.c
@@ -0,0 +1,203 @@
+/* $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 <stdlib.h>
+
+#include "r128_init.h"
+#include "r128_mesa.h"
+#include "r128_xmesa.h"
+#include "r128_context.h"
+#include "r128_cce.h"
+#include "r128_dd.h"
+#include "r128_state.h"
+#include "r128_span.h"
+#include "r128_tex.h"
+#include "r128_vb.h"
+#include "r128_pipeline.h"
+
+#include "context.h"
+#include "simple_list.h"
+
+/* Create the device specific context */
+GLboolean r128CreateContext(Display *dpy, GLvisual *glVisual,
+ __DRIcontextPrivate *driContextPriv)
+{
+ r128ContextPtr r128ctx;
+ r128ScreenPtr r128scrn;
+ GLcontext *glCtx = driContextPriv->mesaContext;
+ int i;
+ char *v;
+
+ r128ctx = (r128ContextPtr)Xmalloc(sizeof(*r128ctx));
+ if (!r128ctx) return GL_FALSE;
+
+ /* Initialize r128Context */
+ r128ctx->glCtx = glCtx;
+ r128ctx->display = dpy;
+ r128ctx->driContext = driContextPriv;
+ r128ctx->driDrawable = NULL; /* Set by XMesaMakeCurrent */
+
+ if (getenv("LIBGL_SOFTWARE_RENDERING"))
+ r128ctx->SWonly = GL_TRUE;
+ else
+ r128ctx->SWonly = GL_FALSE;
+ if (getenv("LIBGL_NO_SOFTWARE_FALLBACKS"))
+ r128ctx->SWfallbackDisable = GL_TRUE;
+ else
+ r128ctx->SWfallbackDisable = GL_FALSE;
+ r128scrn = r128ctx->r128Screen =
+ (r128ScreenPtr)(driContextPriv->driScreenPriv->private);
+
+ r128ctx->CurrentTexObj[0] = NULL;
+ r128ctx->CurrentTexObj[1] = NULL;
+ make_empty_list(&r128ctx->SwappedOut);
+ for (i = 0; i < r128scrn->NRTexHeaps; i++) {
+ make_empty_list(&r128ctx->TexObjList[i]);
+ r128ctx->texHeap[i] = mmInit(0, r128scrn->texSize[i]);
+ r128ctx->lastTexAge[i] = -1;
+ }
+
+ r128ctx->lastSwapAge = 0;
+
+ r128ctx->useFastPath = GL_FALSE;
+
+ r128ctx->vb.start = 0;
+ r128ctx->vb.count = 0;
+ r128ctx->vb.size = 0;
+ r128ctx->vb.index = 0;
+ r128ctx->vb.buf = NULL;
+ r128ctx->vb.done = GL_TRUE;
+
+ if (r128scrn->IsPCI || getenv("LIBGL_DISABLE_VERTEX_BUFFERS"))
+ r128ctx->disableVB = GL_TRUE;
+ else
+ r128ctx->disableVB = GL_FALSE;
+
+ r128ctx->CCEbuf = (CARD32 *)malloc(sizeof(*r128ctx->CCEbuf) *
+ r128scrn->ringEntries);
+ r128ctx->CCEcount = 0;
+
+ if ((v = getenv("LIBGL_CCE_TIMEOUT")))
+ r128ctx->CCEtimeout = strtoul(v, NULL, 10);
+ else
+ r128ctx->CCEtimeout = (R128_DEFAULT_TOTAL_CCE_TIMEOUT /
+ R128_DEFAULT_CCE_TIMEOUT);
+ if (r128ctx->CCEtimeout <= 0) r128ctx->CCEtimeout = 1;
+
+ /* Initialize GLcontext */
+ glCtx->DriverCtx = (void *)r128ctx;
+
+ r128DDInitExtensions(glCtx);
+
+ r128DDInitDriverFuncs(glCtx);
+ r128DDInitStateFuncs(glCtx);
+ r128DDInitSpanFuncs(glCtx);
+ r128DDInitTextureFuncs(glCtx);
+
+ glCtx->Driver.TriangleCaps = (DD_TRI_CULL
+ | DD_TRI_LIGHT_TWOSIDE
+ | DD_TRI_OFFSET);
+#if 0
+ /* FIXME */
+ glCtx->TriangleCaps |= DD_CLIP_FOG_COORD;
+#endif
+
+ /* Reset Mesa's current 2D texture pointers to the driver's textures */
+ glCtx->Shared->DefaultD[2][0].DriverData = NULL;
+ glCtx->Shared->DefaultD[2][1].DriverData = NULL;
+
+ /* If Mesa has current a vertex buffer, make sure the driver's VB
+ data is up to date */
+ if (glCtx->VB) r128DDRegisterVB(glCtx->VB);
+
+ /* Register the fast path */
+ if (glCtx->NrPipelineStages)
+ glCtx->NrPipelineStages =
+ r128RegisterPipelineStages(glCtx->PipelineStage,
+ glCtx->PipelineStage,
+ glCtx->NrPipelineStages);
+
+ r128DDInitState(r128ctx);
+
+ driContextPriv->driverPrivate = (void *)r128ctx;
+
+ return GL_TRUE;
+}
+
+/* Destroy the device specific context */
+void r128DestroyContext(r128ContextPtr r128ctx)
+{
+ if (r128ctx) {
+ r128TexObjPtr t, next_t;
+ int i;
+
+ free(r128ctx->CCEbuf);
+
+ for (i = 0; i < r128ctx->r128Screen->NRTexHeaps; i++) {
+ foreach_s (t, next_t, &r128ctx->TexObjList[i])
+ r128DestroyTexObj(r128ctx, t);
+ }
+
+ foreach_s (t, next_t, &r128ctx->SwappedOut)
+ r128DestroyTexObj(r128ctx, t);
+
+ gl_destroy_context(r128ctx->glCtx);
+ Xfree(r128ctx);
+ }
+}
+
+/* Load the device specific context into the hardware. The actual
+ setting of the hardware state is done in the r128UpdateHWState(). */
+r128ContextPtr r128MakeCurrent(r128ContextPtr oldCtx,
+ r128ContextPtr newCtx,
+ __DRIdrawablePrivate *dPriv)
+{
+ if (oldCtx) {
+ if (!R128CCE_USE_RING_BUFFER(newCtx->r128Screen->CCEMode))
+ newCtx->dirty |= R128_REQUIRE_QUIESCENCE;
+ if (oldCtx != newCtx) {
+ newCtx->dirty |= R128_UPDATE_CONTEXT;
+ newCtx->dirty_context |= R128_CTX_ALL_DIRTY;
+ }
+ if (oldCtx->driDrawable != dPriv)
+ newCtx->dirty |= R128_UPDATE_WINPOS;
+ } else {
+ newCtx->dirty |= R128_UPDATE_CONTEXT;
+ newCtx->dirty_context |= R128_CTX_ALL_DIRTY;
+ }
+
+ newCtx->driDrawable = dPriv;
+
+ return newCtx;
+}
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..189a22cbe
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.h
@@ -0,0 +1,219 @@
+/* $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
+
+#include "r128_texobj.h"
+#include "r128_fastpath.h"
+#include "r128_ccevb.h"
+
+/* Flags for what needs to be updated before a new primitive is rendered */
+#define R128_CLEAN 0x0000
+#define R128_REQUIRE_QUIESCENCE 0x0001
+#define R128_UPDATE_CONTEXT 0x0002
+#define R128_UPDATE_WINPOS 0x0004
+#define R128_UPDATE_TEX0IMAGES 0x0008
+#define R128_UPDATE_TEX1IMAGES 0x0010
+#define R128_UPDATE_TEXSTATE 0x0020
+#define R128_ALL_DIRTY 0xffff
+
+/* Flags for what context state needs to be updated */
+#define R128_CTX_CLEAN 0x0000
+#define R128_CTX_MISC 0x0001
+#define R128_CTX_ENGINESTATE 0x0002
+#define R128_CTX_TEX0STATE 0x0004
+#define R128_CTX_TEX1STATE 0x0008
+#define R128_CTX_TEXENVSTATE 0x0010
+#define R128_CTX_FOGSTATE 0x0020
+#define R128_CTX_FOGTABLE 0x0040
+#define R128_CTX_ZSTENSTATE 0x0080
+#define R128_CTX_SCISSORS 0x0100
+#define R128_CTX_ALPHASTATE 0x0200
+#define R128_CTX_SETUPSTATE 0x0400
+#define R128_CTX_WIN_Z_POS 0x0800
+#define R128_CTX_FLUSH_PIX_CACHE 0x1000
+#define R128_CTX_ALL_DIRTY 0xffff
+
+/* Flags for software fallback cases */
+#define R128_FALLBACK_TEXTURE 0x0001
+#define R128_FALLBACK_DRAW_BUFFER 0x0002
+#define R128_FALLBACK_READ_BUFFER 0x0004
+#define R128_FALLBACK_COLORMASK 0x0008
+#define R128_FALLBACK_STIPPLE 0x0010
+
+/* NOTE: The groups below need to be kept together so that a single
+ memcpy can be used to transfer data to the ring buffer */
+typedef struct {
+ CARD32 scale_3d_cntl; /* 0x1a00 */
+
+ CARD32 aux_sc_cntl; /* 0x1660 */
+ CARD32 aux1_sc_left;
+ CARD32 aux1_sc_right;
+ CARD32 aux1_sc_top;
+ CARD32 aux1_sc_bottom;
+ CARD32 aux2_sc_left;
+ CARD32 aux2_sc_right;
+ CARD32 aux2_sc_top;
+ CARD32 aux2_sc_bottom;
+ CARD32 aux3_sc_left;
+ CARD32 aux3_sc_right;
+ CARD32 aux3_sc_top;
+ CARD32 aux3_sc_bottom; /* 0x1690 */
+
+ 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_offset[R128_TEX_MAXLEVELS]; /* 0x1ce4 */
+
+ CARD32 sec_tex_cntl_c; /* 0x1d00 */
+ CARD32 sec_tex_combine_cntl_c;
+ CARD32 sec_tex_offset[R128_TEX_MAXLEVELS];
+ 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 */
+
+ CARD32 window_xy_offset; /* 0x1bcc */
+
+ CARD32 dp_write_mask; /* 0x16cc */
+
+ CARD32 pc_gui_ctlstat; /* 0x1748 */
+} r128ContextRegs;
+
+typedef struct {
+ GLcontext *glCtx; /* Mesa context */
+ int dirty; /* Hardware state to be updated */
+ int dirty_context; /* Context state to be updated */
+
+ int SWonly; /* Force software-only rendering */
+ int SWfallbackDisable; /* Disable software fallbacks */
+
+ r128TexObjPtr CurrentTexObj[2]; /* Ptr to current texture
+ object associated with
+ each texture unit */
+ /* List of tex swapped in per heap*/
+ r128TexObj TexObjList[R128_NR_TEX_HEAPS];
+ r128TexObj SwappedOut; /* List of textures swapped out */
+ memHeap_t *texHeap[R128_NR_TEX_HEAPS]; /* Global tex heaps */
+ /* Last known global tex heap ages */
+ int lastTexAge[R128_NR_TEX_HEAPS];
+
+ CARD32 lastSwapAge; /* Last known swap age */
+
+ GLenum FogMode; /* Current fog equation */
+
+ int Scissor;
+ XF86DRIClipRectRec ScissorRect; /* Current software scissor */
+
+ int useFastPath; /* Currently using Fast Path code */
+ int SetupIndex; /* Raster setup function index */
+ int SetupDone; /* Partial raster setup done? */
+ int RenderIndex; /* Render state function index */
+ r128InterpFunc interp; /* Current vert interp function */
+
+ r128CCEVertBuf vb; /* VB currently being filled */
+ int disableVB; /* Disable the use of vertex buffers */
+
+ points_func PointsFunc; /* Current Points, Line, Triangle */
+ line_func LineFunc; /* and Quad rendering functions */
+ triangle_func TriangleFunc;
+ quad_func QuadFunc;
+
+ CARD32 IndirectTriangles; /* Flags for point, line,
+ tri and quad software
+ fallbacks */
+ CARD32 Fallback; /* Need software fallback */
+
+ r128ContextRegs regs; /* Hardware state */
+ CARD32 Color; /* Current draw color */
+ CARD32 ClearColor; /* Color used to clear color buffer */
+ CARD32 ClearDepth; /* Value used to clear depth buffer */
+
+ int drawX; /* x-offset to current draw buffer */
+ int drawY; /* y-offset to current draw buffer */
+
+ int readX; /* x-offset to current read buffer */
+ int readY; /* y-offset to current read buffer */
+
+ CARD32 *CCEbuf; /* buffer to submit to CCE */
+ int CCEcount; /* number of dwords in CCEbuf */
+
+ int CCEtimeout; /* number of times to loop
+ before exiting */
+
+ Display *display; /* X server display */
+
+ __DRIcontextPrivate *driContext; /* DRI context */
+ __DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */
+
+ r128ScreenPtr r128Screen; /* Screen private DRI data */
+} r128ContextRec, *r128ContextPtr;
+
+#define R128_MESACTX(r128ctx) ((r128ctx)->glCtx)
+#define R128_DRIDRAWABLE(r128ctx) ((r128ctx)->driDrawable)
+#define R128_DRISCREEN(r128ctx) ((r128ctx)->r128Screen->driScreen)
+
+extern GLboolean r128CreateContext(Display *dpy, GLvisual *glVisual,
+ __DRIcontextPrivate *driContextPriv);
+extern void r128DestroyContext(r128ContextPtr r128ctx);
+extern r128ContextPtr r128MakeCurrent(r128ContextPtr oldCtx,
+ r128ContextPtr newCtx,
+ __DRIdrawablePrivate *dPriv);
+
+#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..0ed7ae471
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_dd.c
@@ -0,0 +1,182 @@
+/* $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_cce.h"
+#include "r128_clear.h"
+#include "r128_state.h"
+#include "r128_vb.h"
+#include "r128_pipeline.h"
+#include "r128_dd.h"
+
+/* Driver entry point for clearing color and ancillary buffers */
+static GLbitfield r128DDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ if (r128ctx->SWonly) {
+ /* FIXME: Provide software fallback for this case?? */
+ }
+
+ if (mask & DD_FRONT_LEFT_BIT) {
+ r128ClearColorBuffer(r128ctx, all, x, y, width, height,
+ r128ctx->r128Screen->fbX,
+ r128ctx->r128Screen->fbY);
+ mask &= ~DD_FRONT_LEFT_BIT;
+ }
+
+ if (mask & DD_BACK_LEFT_BIT) {
+ r128ClearColorBuffer(r128ctx, all, x, y, width, height,
+ r128ctx->r128Screen->backX,
+ r128ctx->r128Screen->backY);
+ mask &= ~DD_BACK_LEFT_BIT;
+ }
+
+ if (mask & DD_DEPTH_BIT) {
+ r128ClearDepthBuffer(r128ctx, all, x, y, width, height);
+ mask &= ~DD_DEPTH_BIT;
+ }
+
+#if 0
+ /* FIXME: Add stencil support */
+ if (mask & DD_STENCIL_BIT) {
+ r128ClearStencilBuffer(r128ctx, all, x, y, width, height);
+ mask &= ~DD_STENCIL_BIT;
+ }
+#endif
+
+ return mask;
+}
+
+/* Return the current color buffer size */
+static void r128DDGetBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ *width = r128ctx->driDrawable->w;
+ *height = r128ctx->driDrawable->h;
+}
+
+/* Return various strings for glGetString() */
+static const GLubyte *r128DDGetString(GLcontext *ctx, GLenum name)
+{
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *)"Precision Insight, Inc.";
+ case GL_RENDERER:
+ return (GLubyte *)"Mesa DRI Rage128 20000320";
+ default:
+ return NULL;
+ }
+}
+
+/* Send all commands to the hardware. If vertex buffers or indirect
+ buffers are in use, then we need to make sure they are sent to the
+ hardware. All commands that are normally sent to the ring are
+ already considered `flushed'. */
+static void r128DDFlush(GLcontext *ctx)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+}
+
+/* Make sure all commands have been sent to the hardware and have
+ completed processing. */
+static void r128DDFinish(GLcontext *ctx)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ r128DDFlush(ctx);
+ R128CCE_WAIT_FOR_IDLE_LOCK(r128ctx);
+}
+
+/* Return various parameters requested by Mesa */
+static GLint r128DDGetParameteri(const GLcontext *ctx, GLint param)
+{
+ switch (param) {
+#if 0
+ /* FIXME: Support for these needs to be added to Mesa */
+ case DD_MAX_TEXTURE_SIZE: return 1024;
+ case DD_MAX_TEXTURES: return 2;
+#endif
+#if 0
+ case DD_HAVE_HARDWARE_FOG: return 1; /* FIXME: Add HW fog support */
+#endif
+ default: return 0;
+ }
+}
+
+/* Initialize the extensions supported by this driver */
+void r128DDInitExtensions(GLcontext *ctx)
+{
+ /* FIXME: Are there other extensions to enable/disable??? */
+ gl_extensions_disable(ctx, "GL_EXT_shared_texture_palette");
+ gl_extensions_disable(ctx, "GL_EXT_paletted_texture");
+ gl_extensions_disable(ctx, "GL_EXT_point_parameters");
+ gl_extensions_disable(ctx, "ARB_imaging");
+ gl_extensions_disable(ctx, "GL_EXT_blend_minmax");
+ gl_extensions_disable(ctx, "GL_EXT_blend_logic_op");
+ gl_extensions_disable(ctx, "GL_EXT_blend_subtract");
+ gl_extensions_disable(ctx, "GL_INGR_blend_func_separate");
+
+ if (getenv("LIBGL_NO_MULTITEXTURE"))
+ gl_extensions_disable(ctx, "GL_ARB_multitexture");
+}
+
+/* Initialize the driver's misc functions */
+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.GetParameteri = r128DDGetParameteri;
+
+ ctx->Driver.DrawPixels = NULL;
+ ctx->Driver.Bitmap = NULL;
+
+ ctx->Driver.RegisterVB = r128DDRegisterVB;
+ ctx->Driver.UnregisterVB = r128DDUnregisterVB;
+ ctx->Driver.BuildPrecalcPipeline = r128DDBuildPrecalcPipeline;
+}
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_fastpath.c b/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c
new file mode 100644
index 000000000..330e5a23d
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c
@@ -0,0 +1,551 @@
+/* $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_vb.h"
+#include "r128_tris.h"
+#include "r128_fastpath.h"
+
+#include "mmath.h"
+#include "cva.h"
+#include "vertices.h"
+
+/* FIXME: These routines were copied from the i810 driver, and were only
+ slightly modified for the Rage 128. They still need to be optmizied
+ and cleaned up. Also, support for USE_RHW2 needs to be added. */
+
+typedef struct r128_fast_table {
+ r128BuildVerticesFunc build_vertices;
+ r128InterpFunc interp;
+} r128FastPathTable;
+
+#define POINT(x) r128DrawPointVB(r128ctx, &vert[x].v, psize)
+#define LINE(x,y) r128DrawLineVB(r128ctx, &vert[x].v, &vert[y].v, lwidth)
+#define TRI(x,y,z) r128DrawTriangleVB(r128ctx, &vert[x].v, &vert[y].v, &vert[z].v)
+
+/* Direct, and no clipping required. The clip funcs have not been
+ written yet, so this is only useful for the fast path. */
+#define RENDER_POINTS(start, count) \
+do { \
+ GLuint e; \
+ for (e = start; e <= count; e++) \
+ POINT(elt[e]); \
+} while (0)
+
+#define RENDER_LINE(i1, i) \
+do { \
+ GLuint e1 = elt[i1], e = elt[i]; \
+ LINE(e1, e); \
+} while (0)
+
+#define RENDER_TRI(i2, i1, i, pv, parity) \
+do { \
+ GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
+ if (parity) { \
+ GLuint tmp = e2; \
+ e2 = e1; \
+ e1 = tmp; \
+ } \
+ TRI(e2, e1, e); \
+} while (0)
+
+#define RENDER_QUAD(i3, i2, i1, i, pv) \
+do { \
+ GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
+ TRI(e3, e2, e); \
+ TRI(e2, e1, e); \
+} while (0)
+
+#define LOCAL_VARS \
+ r128VertexPtr vert = R128_DRIVER_DATA(VB)->verts; \
+ const GLuint *elt = VB->EltPtr->data; \
+ GLcontext *ctx = VB->ctx; \
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx); \
+ const GLfloat lwidth = ctx->Line.Width; \
+ const GLfloat psize = ctx->Point.Size; \
+ (void) lwidth; (void)psize; (void) vert;
+
+#define TAG(x) x##_r128_smooth_indirect
+#include "render_tmp.h"
+
+
+
+#define NEGATIVE(f) (f < 0)
+#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
+#define LINTERP(T, A, B) ((A) + (T) * ((B) - (A)))
+
+
+#define INTERP_RGBA(t, out, a, b) \
+do { \
+ int i; \
+ for (i = 0; i < 4; i++) { \
+ GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a[i]); \
+ GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b[i]); \
+ GLfloat fo = LINTERP(t, fa, fb); \
+ FLOAT_COLOR_TO_UBYTE_COLOR(out[i], fo); \
+ } \
+} while (0)
+
+
+#define CLIP(SGN, V, PLANE) \
+do { \
+ if (mask & PLANE) { \
+ GLuint *indata = inlist[in]; \
+ GLuint *outdata = inlist[in ^= 1]; \
+ GLuint nr = n; \
+ GLfloat *J = verts[indata[nr-1]].f; \
+ GLfloat dpJ = (SGN J[V]) + J[3]; \
+ \
+ inlist[0] = vlist1; \
+ for (i = n = 0 ; i < nr ; i++) { \
+ GLuint elt_i = indata[i]; \
+ GLfloat *I = verts[elt_i].f; \
+ GLfloat dpI = (SGN I[V]) + I[3]; \
+ \
+ if (DIFFERENT_SIGNS(dpI, dpJ)) { \
+ GLfloat *O = verts[next_vert].f; \
+ GLfloat t, *in, *out; \
+ \
+ if (NEGATIVE(dpI)) { \
+ t = dpI / (dpI - dpJ); \
+ in = I; \
+ out = J; \
+ } else { \
+ t = dpJ / (dpJ - dpI); \
+ in = J; \
+ out = I; \
+ } \
+ \
+ interp(t, O, in, out); \
+ \
+ clipmask[next_vert] = 0; \
+ outdata[n++] = next_vert++; \
+ } \
+ \
+ clipmask[elt_i] |= PLANE; /* don't set up */ \
+ \
+ if (!NEGATIVE(dpI)) { \
+ outdata[n++] = elt_i; \
+ clipmask[elt_i] &= ~PLANE; /* set up after all */ \
+ } \
+ \
+ J = I; \
+ dpJ = dpI; \
+ } \
+ \
+ if (n < 3) return; \
+ } \
+} while (0)
+
+#define LINE_CLIP(x,y,z,w,PLANE) \
+do { \
+ if (mask & PLANE) { \
+ GLfloat dpI = DOT4V(I,x,y,z,w); \
+ GLfloat dpJ = DOT4V(J,x,y,z,w); \
+ \
+ if (DIFFERENT_SIGNS(dpI, dpJ)) { \
+ GLfloat *O = verts[next_vert].f; \
+ GLfloat t = dpI / (dpI - dpJ); \
+ \
+ interp(t, O, I, J); \
+ \
+ clipmask[next_vert] = 0; \
+ \
+ if (NEGATIVE(dpI)) { \
+ clipmask[elts[0]] |= PLANE; \
+ I = O; \
+ elts[0] = next_vert++; \
+ } else { \
+ clipmask[elts[1]] |= PLANE; \
+ J = O; \
+ elts[1] = next_vert++; \
+ } \
+ } else if (NEGATIVE(dpI)) return; \
+ } \
+} while (0)
+
+
+static void r128TriClip(GLuint **p_elts,
+ r128Vertex *verts,
+ GLubyte *clipmask,
+ GLuint *p_next_vert,
+ GLubyte mask,
+ r128InterpFunc interp)
+{
+ GLuint *elts = *p_elts;
+ GLuint next_vert = *p_next_vert;
+ GLuint in = 0;
+ GLuint n = 3;
+ GLuint vlist1[VB_MAX_CLIPPED_VERTS];
+ GLuint vlist2[VB_MAX_CLIPPED_VERTS];
+ GLuint *inlist[2];
+ GLuint *out;
+ GLuint i;
+
+ inlist[0] = elts;
+ inlist[1] = vlist2;
+
+ CLIP(-,0,CLIP_RIGHT_BIT);
+ CLIP(+,0,CLIP_LEFT_BIT);
+ CLIP(-,1,CLIP_TOP_BIT);
+ CLIP(+,1,CLIP_BOTTOM_BIT);
+ CLIP(-,2,CLIP_FAR_BIT);
+ CLIP(+,2,CLIP_NEAR_BIT);
+
+ /* Convert the planar polygon to a list of triangles */
+ out = inlist[in];
+
+ for (i = 2 ; i < n ; i++) {
+ elts[0] = out[0];
+ elts[1] = out[i-1];
+ elts[2] = out[i];
+ elts += 3;
+ }
+
+ *p_next_vert = next_vert;
+ *p_elts = elts;
+}
+
+
+static void r128LineClip(GLuint **p_elts,
+ r128Vertex *verts,
+ GLubyte *clipmask,
+ GLuint *p_next_vert,
+ GLubyte mask,
+ r128InterpFunc interp)
+{
+ GLuint *elts = *p_elts;
+ GLfloat *I = verts[elts[0]].f;
+ GLfloat *J = verts[elts[1]].f;
+ GLuint next_vert = *p_next_vert;
+
+ LINE_CLIP(1,0,0,-1,CLIP_LEFT_BIT);
+ LINE_CLIP(-1,0,0,1,CLIP_RIGHT_BIT);
+ LINE_CLIP(0,1,0,-1,CLIP_TOP_BIT);
+ LINE_CLIP(0,-1,0,1,CLIP_BOTTOM_BIT);
+ LINE_CLIP(0,0,1,-1,CLIP_FAR_BIT);
+ LINE_CLIP(0,0,-1,1,CLIP_NEAR_BIT);
+
+ *p_next_vert = next_vert;
+ *p_elts += 2;
+}
+
+
+
+#define CLIP_POINT(e) \
+do { \
+ if (mask[e]) *out++ = e; \
+} while (0)
+
+#define CLIP_LINE(e1, e0) \
+do { \
+ GLubyte ormask = mask[e0] | mask[e1]; \
+ out[0] = e1; \
+ out[1] = e0; \
+ out += 2; \
+ if (ormask) { \
+ out-=2; \
+ if (!(mask[e0] & mask[e1])) { \
+ r128LineClip(&out, verts, mask, &next_vert, ormask, interp); \
+ } \
+ } \
+} while (0)
+
+#define CLIP_TRIANGLE(e2, e1, e0) \
+do { \
+ GLubyte ormask; \
+ out[0] = e2; \
+ out[1] = e1; \
+ out[2] = e0; \
+ out += 3; \
+ ormask = mask[e2] | mask[e1] | mask[e0]; \
+ if (ormask) { \
+ out -= 3; \
+ if (!(mask[e2] & mask[e1] & mask[e0])) { \
+ r128TriClip(&out, verts, mask, &next_vert, ormask, interp); \
+ } \
+ } \
+} while (0)
+
+
+
+/* Build a table of functions to clip each primitive type. These
+ * produce a list of elements in the appropriate 'reduced' primitive,
+ * ie (points, lines, triangles) containing all the clipped and
+ * unclipped primitives from the original list.
+ */
+#define LOCAL_VARS \
+ r128ContextPtr r128ctx = R128_CONTEXT(VB->ctx); \
+ r128VertexBufferPtr r128VB = R128_DRIVER_DATA(VB); \
+ GLuint *elt = VB->EltPtr->data; \
+ r128Vertex *verts = r128VB->verts; \
+ GLuint next_vert = r128VB->last_vert; \
+ GLuint *out = r128VB->clipped_elements.data; \
+ GLubyte *mask = VB->ClipMask; \
+ r128InterpFunc interp = r128ctx->interp; \
+ (void) interp; (void) verts;
+
+#define POSTFIX \
+ r128VB->clipped_elements.count = out - r128VB->clipped_elements.data; \
+ r128VB->last_vert = next_vert;
+
+
+#define INIT(x)
+
+#define RENDER_POINTS(start, count) \
+do { \
+ GLuint i; \
+ for (i = start; i < count; i++) \
+ CLIP_POINT(elt[i]); \
+} while (0)
+
+#define RENDER_LINE(i1, i0) \
+do { \
+ CLIP_LINE(elt[i1], elt[i0]); \
+} while (0)
+
+#define RENDER_TRI(i2, i1, i0, pv, parity) \
+do { \
+ GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
+ if (parity) e2 = elt[i1], e1 = elt[i2]; \
+ CLIP_TRIANGLE(e2, e1, e0); \
+} while (0)
+
+#define RENDER_QUAD(i3, i2, i1, i0, pv) \
+do { \
+ CLIP_TRIANGLE(elt[i3], elt[i2], elt[i0]); \
+ CLIP_TRIANGLE(elt[i2], elt[i1], elt[i0]); \
+} while (0)
+
+#define TAG(x) r128_clip_##x##_elt
+#include "render_tmp.h"
+
+
+/* Pack rgba and/or texture into the remaining half of a 32 byte vertex.
+ */
+#define CLIP_UBYTE_COLOR 4
+#define CLIP_UBYTE_B 0
+#define CLIP_UBYTE_G 1
+#define CLIP_UBYTE_R 2
+#define CLIP_UBYTE_A 3
+#define CLIP_S0 6
+#define CLIP_T0 7
+#define CLIP_S1 8
+#define CLIP_T1 9
+
+#define TYPE (0)
+#define TAG(x) x
+#include "r128_fasttmp.h"
+
+#define TYPE (R128_RGBA_BIT)
+#define TAG(x) x##_RGBA
+#include "r128_fasttmp.h"
+
+#define TYPE (R128_TEX0_BIT)
+#define TAG(x) x##_TEX0
+#include "r128_fasttmp.h"
+
+#define TYPE (R128_RGBA_BIT | R128_TEX0_BIT)
+#define TAG(x) x##_RGBA_TEX0
+#include "r128_fasttmp.h"
+
+#define TYPE (R128_RGBA_BIT | R128_TEX0_BIT | R128_TEX1_BIT)
+#define TAG(x) x##_RGBA_TEX0_TEX1
+#include "r128_fasttmp.h"
+
+/* This one *could* get away with sneaking TEX1 into the color and
+ * specular slots, thus fitting inside a cache line. Would be even
+ * better to switch to a smaller vertex.
+ */
+#define TYPE (R128_TEX0_BIT | R128_TEX1_BIT)
+#define TAG(x) x##_TEX0_TEX1
+#include "r128_fasttmp.h"
+
+
+
+/* Render elements directly from original list of vertices. */
+static void r128RenderElementsDirect(struct vertex_buffer *VB)
+{
+ GLcontext *ctx = VB->ctx;
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ GLenum prim = ctx->CVA.elt_mode;
+ GLuint nr = VB->EltPtr->count;
+ render_func func = render_tab_r128_smooth_indirect[prim];
+ GLuint p = 0;
+
+ if (r128ctx->dirty) r128UpdateHWState(r128ctx);
+
+ do {
+ func(VB, 0, nr, 0);
+ } while (ctx->Driver.MultipassFunc &&
+ ctx->Driver.MultipassFunc(VB, ++p));
+}
+
+/* Project vertices from clip to device space */
+static void r128ProjectVertices(struct vertex_buffer *VB)
+{
+ GLcontext *ctx = VB->ctx;
+ GLmatrix *mat = &ctx->Viewport.WindowMap;
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ r128VertexBufferPtr r128VB = R128_DRIVER_DATA(VB);
+ GLfloat m[16];
+
+ m[MAT_SX] = mat->m[MAT_SX];
+ m[MAT_TX] = mat->m[MAT_TX];
+ m[MAT_SY] = -mat->m[MAT_SY];
+ m[MAT_TY] = -mat->m[MAT_TY] + r128ctx->driDrawable->h;
+ m[MAT_SZ] = mat->m[MAT_SZ];
+ m[MAT_TZ] = mat->m[MAT_TZ];
+
+ switch (ctx->Visual->DepthBits) {
+ case 16: m[MAT_SZ] /= 65536.0; m[MAT_TZ] /= 65536.0; break;
+ case 24: m[MAT_SZ] /= 16777216.0; m[MAT_TZ] /= 16777216.0; break;
+ case 32: m[MAT_SZ] /= 4294967296.0; m[MAT_TZ] /= 4294967296.0; break;
+ default: m[MAT_SZ] /= 65536.0; m[MAT_TZ] /= 65536.0; break;
+ }
+
+#if USE_RHW2
+ /* FIXME: Handle RHW2?? */
+ gl_project_v16(r128VB->verts[VB->CopyStart].f,
+ r128VB->verts[r128VB->last_vert].f,
+ m,
+ 16 * 4);
+#else
+ gl_project_v16(r128VB->verts[VB->CopyStart].f,
+ r128VB->verts[r128VB->last_vert].f,
+ m,
+ 16 * 4);
+#endif
+}
+
+/* Project clipped vertices from clip to device space */
+static void r128ProjectClippedVertices(struct vertex_buffer *VB)
+{
+ GLcontext *ctx = VB->ctx;
+ GLmatrix *mat = &ctx->Viewport.WindowMap;
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ r128VertexBufferPtr r128VB = R128_DRIVER_DATA(VB);
+ GLfloat m[16];
+
+ m[MAT_SX] = mat->m[MAT_SX];
+ m[MAT_TX] = mat->m[MAT_TX];
+ m[MAT_SY] = -mat->m[MAT_SY];
+ m[MAT_TY] = -mat->m[MAT_TY] + r128ctx->driDrawable->h;
+ m[MAT_SZ] = mat->m[MAT_SZ];
+ m[MAT_TZ] = mat->m[MAT_TZ];
+
+ switch (ctx->Visual->DepthBits) {
+ case 16: m[MAT_SZ] /= 65536.0; m[MAT_TZ] /= 65536.0; break;
+ case 24: m[MAT_SZ] /= 16777216.0; m[MAT_TZ] /= 16777216.0; break;
+ case 32: m[MAT_SZ] /= 4294967296.0; m[MAT_TZ] /= 4294967296.0; break;
+ default: m[MAT_SZ] /= 65536.0; m[MAT_TZ] /= 65536.0; break;
+ }
+
+#if USE_RHW2
+ /* FIXME: Handle RHW2?? */
+ gl_project_clipped_v16(r128VB->verts[VB->CopyStart].f,
+ r128VB->verts[r128VB->last_vert].f,
+ m,
+ 16 * 4,
+ VB->ClipMask + VB->CopyStart);
+#else
+ gl_project_clipped_v16(r128VB->verts[VB->CopyStart].f,
+ r128VB->verts[r128VB->last_vert].f,
+ m,
+ 16 * 4,
+ VB->ClipMask + VB->CopyStart);
+#endif
+}
+
+static r128FastPathTable r128FastTab[0x80];
+
+/* Initialize the table of fast path support functions */
+void r128FastPathInit(void)
+{
+ r128_clip_render_init_elt();
+ render_init_r128_smooth_indirect();
+
+ r128_init_fastpath(&r128FastTab[0]);
+ r128_init_fastpath_RGBA(&r128FastTab[R128_RGBA_BIT]);
+ r128_init_fastpath_TEX0(&r128FastTab[R128_TEX0_BIT]);
+ r128_init_fastpath_RGBA_TEX0(&r128FastTab[R128_RGBA_BIT|R128_TEX0_BIT]);
+ r128_init_fastpath_TEX0_TEX1(&r128FastTab[R128_TEX0_BIT|R128_TEX1_BIT]);
+ r128_init_fastpath_RGBA_TEX0_TEX1(&r128FastTab[R128_RGBA_BIT|R128_TEX0_BIT|
+ R128_TEX1_BIT]);
+}
+
+#define VALID_SETUP (R128_RGBA_BIT | R128_TEX0_BIT | R128_TEX1_BIT)
+
+void r128FastPath(struct vertex_buffer *VB)
+{
+ GLcontext *ctx = VB->ctx;
+ GLenum prim = ctx->CVA.elt_mode;
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ r128FastPathTable *tab = &r128FastTab[r128ctx->SetupIndex & VALID_SETUP];
+ GLuint do_cliptest = 1;
+
+ gl_prepare_arrays_cva(VB); /* still need this */
+
+ /* Reserve enough space for the pathological case */
+ if (VB->EltPtr->count * 12 > R128_DRIVER_DATA(VB)->size) {
+ r128ResizeVB(VB, VB->EltPtr->count * 12);
+ do_cliptest = 1;
+ }
+
+ tab->build_vertices(VB, do_cliptest); /* object->clip space */
+
+ if (r128ctx->dirty) r128UpdateHWState(r128ctx);
+
+ if (VB->ClipOrMask) {
+ if (!VB->ClipAndMask) {
+ render_func *clip = r128_clip_render_tab_elt;
+
+ r128ctx->interp = tab->interp;
+ clip[prim](VB, 0, VB->EltPtr->count, 0); /* build new elts */
+ ctx->CVA.elt_mode = gl_reduce_prim[prim];
+ VB->EltPtr = &(R128_DRIVER_DATA(VB)->clipped_elements);
+ r128ProjectClippedVertices(VB); /* clip->device space */
+ r128RenderElementsDirect(VB); /* render using new list */
+ }
+ } else {
+ r128ProjectVertices(VB); /* clip->device space */
+ r128RenderElementsDirect(VB); /* render using orig list */
+ }
+
+ /* This indicates that there is no cached data to reuse */
+ VB->pipeline->data_valid = 0;
+ VB->pipeline->new_state = 0;
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.h b/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.h
new file mode 100644
index 000000000..47bb92049
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.h
@@ -0,0 +1,48 @@
+/* $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_FASTPATH_H_
+#define _R128_FASTPATH_H_
+
+typedef void (*r128BuildVerticesFunc)(struct vertex_buffer *VB,
+ GLuint do_cliptest);
+typedef void (*r128InterpFunc)(GLfloat t,
+ GLfloat *result,
+ const GLfloat *in,
+ const GLfloat *out);
+
+extern void r128FastPathInit(void);
+extern void r128FastPath(struct vertex_buffer *VB);
+
+#endif /* _R128_FASTPATH_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h b/xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h
new file mode 100644
index 000000000..e76dd52b4
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h
@@ -0,0 +1,155 @@
+/* $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>
+ *
+ */
+
+/* FIXME: These routines were copied from the i810 driver, and were only
+ slightly modified for the Rage 128. They still need to be optmizied
+ and cleaned up. Also, support for USE_RHW2 needs to be added. */
+
+/* The first part of setup is applied to all vertices, clipped or
+ * unclipped. This data w!ill be used for clipping, and then all
+ * vertices with a zero clipmask will be projected to device space.
+ *
+ * This could be split into several loops, but - it seems that the
+ * large stride of the fxVertices makes cache issues the big
+ * performance factor, and that multiple loops mean multiple cache
+ * misses....
+ */
+static void TAG(r128_setup_full)(struct vertex_buffer *VB, GLuint do_cliptest)
+{
+ GLcontext *ctx = VB->ctx;
+ r128VertexBufferPtr r128VB = R128_DRIVER_DATA(VB);
+ const GLfloat *m = ctx->ModelProjectMatrix.m;
+ GLuint start = VB->CopyStart;
+ GLuint count = VB->Count;
+ GLuint i;
+
+ gl_xform_points3_v16_general(r128VB->verts[start].f,
+ m,
+ VB->ObjPtr->start,
+ VB->ObjPtr->stride,
+ count - start);
+
+ if (do_cliptest) {
+ VB->ClipAndMask = ~0;
+ VB->ClipOrMask = 0;
+ gl_cliptest_points4_v16(r128VB->verts[start].f,
+ r128VB->verts[count].f,
+ &(VB->ClipOrMask),
+ &(VB->ClipAndMask),
+ VB->ClipMask + start);
+ }
+
+ /* These branches are all resolved at compile time. Hopefully all
+ * the pointers are valid addresses even when not enabled.
+ */
+ if (TYPE) {
+ GLubyte *color = VB->ColorPtr->start;
+ GLfloat *tex0_data = VB->TexCoordPtr[0]->start;
+ GLfloat *tex1_data = VB->TexCoordPtr[1]->start;
+
+ GLuint color_stride = VB->ColorPtr->stride;
+ GLuint tex0_stride = VB->TexCoordPtr[0]->stride;
+ GLuint tex1_stride = VB->TexCoordPtr[1]->stride;
+
+ GLfloat *f = r128VB->verts[start].f;
+
+ for (i = start ; i < count ; i++, f += 16) {
+ if (TYPE & R128_RGBA_BIT) {
+ GLubyte *b = (GLubyte *)&f[CLIP_UBYTE_COLOR];
+ GLubyte *col = color; color += color_stride;
+ b[CLIP_UBYTE_R] = col[0];
+ b[CLIP_UBYTE_G] = col[1];
+ b[CLIP_UBYTE_B] = col[2];
+ b[CLIP_UBYTE_A] = col[3];
+ }
+ if (TYPE & R128_TEX0_BIT) {
+ f[CLIP_S0] = tex0_data[0];
+ f[CLIP_T0] = tex0_data[1];
+ STRIDE_F(tex0_data, tex0_stride);
+ }
+ if (TYPE & R128_TEX1_BIT) {
+ f[CLIP_S1] = tex1_data[0];
+ f[CLIP_T1] = tex1_data[1];
+ STRIDE_F(tex1_data, tex1_stride);
+ }
+ }
+ }
+
+ r128VB->clipped_elements.count = start;
+ r128VB->last_vert = count;
+}
+
+
+/* Changed to just put the interp func instead of the whole clip
+ * routine into the header. Less code and better chance of doing some
+ * of this stuff in assembly.
+ */
+static void TAG(r128_interp_vert)(GLfloat t,
+ GLfloat *O,
+ const GLfloat *I,
+ const GLfloat *J)
+{
+ O[0] = LINTERP(t, I[0], J[0]);
+ O[1] = LINTERP(t, I[1], J[1]);
+ O[2] = LINTERP(t, I[2], J[2]);
+ O[3] = LINTERP(t, I[3], J[3]);
+
+ if (TYPE & R128_RGBA_BIT) {
+ INTERP_RGBA(t,
+ ((GLubyte *)&(O[4])),
+ ((GLubyte *)&(I[4])),
+ ((GLubyte *)&(J[4])));
+ }
+
+ if (TYPE & R128_TEX0_BIT) {
+ O[6] = LINTERP(t, I[6], J[6]);
+ O[7] = LINTERP(t, I[7], J[7]);
+ }
+
+ if (TYPE & R128_TEX1_BIT) {
+ O[8] = LINTERP(t, I[8], J[8]);
+ O[9] = LINTERP(t, I[9], J[9]);
+ }
+}
+
+
+static void TAG(r128_init_fastpath)(r128FastPathTable *tab)
+{
+ tab->build_vertices = TAG(r128_setup_full);
+ tab->interp = TAG(r128_interp_vert);
+}
+
+#undef TYPE
+#undef TAG
+#undef SIZE
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..fcaf70a51
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_init.h
@@ -0,0 +1,92 @@
+/* $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 "xf86drm.h"
+#include "dri_tmm.h"
+#include "dri_mesaint.h"
+
+#include "r128_screen.h"
+#include "r128_context.h"
+
+/* NOTE: The vertex buffer code is currently unstable because of the
+ switches between CCE and MMIO mode in the X server. Fixing the X
+ server to use the CCE should fix this problem. So, for now, it is
+ recommended that you do not use it. */
+
+#define DEBUG 1
+#define DEBUG_LOCKING 1
+#define USE_FAST_PATH 1
+#define USE_USER_SPACE_RING 0
+
+
+#if DEBUG
+
+#include <stdio.h>
+#define R128_DEBUG(p) \
+ do { \
+ printf p ; \
+ fflush(stdout); \
+ } while (0)
+
+extern int R128_DEBUG_FLAGS;
+
+#define DEBUG_VERBOSE_2D 0x0001
+#define DEBUG_VERBOSE_CCE 0x0008
+#define DEBUG_VERBOSE_OUTREG 0x0010
+#define DEBUG_ALWAYS_SYNC 0x0040
+#define DEBUG_VERBOSE_MSG 0x0080
+#define DEBUG_NO_OUTRING 0x0100
+#define DEBUG_NO_OUTREG 0x0200
+#define DEBUG_VERBOSE_API 0x0400
+#define DEBUG_VALIDATE_RING 0x0800
+#define DEBUG_VERBOSE_LRU 0x1000
+#define DEBUG_VERBOSE_DRI 0x2000
+#define DEBUG_VERBOSE_IOCTL 0x4000
+
+#else
+
+#define R128_DEBUG_FLAGS 0
+
+#endif
+
+#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..7fd81f807
--- /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
+
+/* Turn DEBUG_LOCKING on to find locking conflicts (see r128_init.h) */
+#if DEBUG_LOCKING
+extern char *prevLockFile;
+extern int prevLockLine;
+
+#define DEBUG_LOCK() \
+ do { \
+ prevLockFile = (__FILE__); \
+ prevLockLine = (__LINE__); \
+ } while (0)
+
+#define DEBUG_RESET() \
+ do { \
+ prevLockFile = 0; \
+ prevLockLine = 0; \
+ } while (0)
+
+#define DEBUG_CHECK_LOCK() \
+ do { \
+ if (prevLockFile) { \
+ fprintf(stderr, \
+ "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
+ prevLockFile, prevLockLine, __FILE__, __LINE__); \
+ exit(1); \
+ } \
+ } while (0)
+
+#else
+
+#define DEBUG_LOCK()
+#define DEBUG_RESET()
+#define DEBUG_CHECK_LOCK()
+
+#endif
+
+/*
+ * !!! We may want to separate locks from locks with validation. This
+ * could be used to improve performance for those things commands that
+ * do not do any drawing !!!
+ */
+
+/* Lock the hardware 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) { \
+ /* We lost the context, so we need to request the lock from \
+ the kernel and update our state. */ \
+ drmGetLock(sPriv->fd, cPriv->hHWContext, 0); \
+ XMesaUpdateState(cPriv); \
+ } \
+ 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.
+ */
+#define BEGIN_CLIP_LOOP(CC) \
+ do { \
+ __DRIdrawablePrivate *_dPriv = CC->driDrawable; \
+ XF86DRIClipRectPtr _pc = _dPriv->pClipRects; \
+ int _nc, _sc; \
+ \
+ for (_nc = _dPriv->numClipRects; _nc > 0; _nc -= 3, _pc += 3) { \
+ _sc = (_nc <= 3) ? _nc : 3; \
+ r128SetClipRects(CC, _pc, _sc)
+
+/* FIXME: This should be a function call to turn off aux clipping */
+#define END_CLIP_LOOP(CC) \
+ R128CCE0(R128_CCE_PACKET0, R128_AUX_SC_CNTL, 0); \
+ R128CCE(0x00000000); \
+ R128CCE_SUBMIT_PACKETS(); \
+ } \
+ } 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_pipeline.c b/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c
new file mode 100644
index 000000000..55487ffcd
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c
@@ -0,0 +1,126 @@
+/* $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_vb.h"
+#include "r128_fastpath.h"
+#include "r128_pipeline.h"
+
+#include "types.h"
+
+static struct gl_pipeline_stage r128FastStage = {
+ "R128 Fast Path",
+ (PIPE_OP_VERT_XFORM |
+ PIPE_OP_RAST_SETUP_0 |
+ PIPE_OP_RAST_SETUP_1 |
+ PIPE_OP_RENDER),
+ PIPE_PRECALC,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ r128FastPath
+};
+
+/* Build the PRECALC pipeline with our stage, if possible. Otherwise,
+ return GL_FALSE */
+GLboolean r128DDBuildPrecalcPipeline(GLcontext *ctx)
+{
+#if USE_FAST_PATH
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ struct gl_pipeline *pipe = &ctx->CVA.pre;
+
+ if (r128ctx->RenderIndex == 0 &&
+ !(ctx->Enabled & (TEXTURE0_3D |
+ TEXTURE1_3D |
+ ENABLE_TEXMAT0 |
+ ENABLE_TEXMAT1 |
+ ENABLE_TEXGEN0 |
+ ENABLE_TEXGEN1 |
+ ENABLE_USERCLIP |
+ ENABLE_LIGHT |
+ ENABLE_FOG)) &&
+ (ctx->Array.Flags & (VERT_OBJ_234 |
+ VERT_TEX0_4 |
+ VERT_TEX1_4 |
+ VERT_ELT)) == (VERT_OBJ_23 |
+ VERT_ELT)) {
+ pipe->stages[0] = &r128FastStage;
+ pipe->stages[1] = 0;
+ pipe->new_inputs = ctx->RenderFlags & VERT_DATA;
+ pipe->ops = pipe->stages[0]->ops;
+
+ r128ctx->useFastPath = GL_TRUE;
+ return GL_TRUE;
+ }
+
+ if (r128ctx->useFastPath) {
+ r128ctx->useFastPath = GL_FALSE;
+
+ ctx->CVA.VB->ClipOrMask = 0;
+ ctx->CVA.VB->ClipAndMask = CLIP_ALL_BITS;
+ ctx->Array.NewArrayState |= ctx->Array.Summary;
+ }
+#endif
+
+ return GL_FALSE;
+}
+
+/* Register the pipeline with our stages included */
+GLuint r128RegisterPipelineStages(struct gl_pipeline_stage *out,
+ const struct gl_pipeline_stage *in,
+ GLuint nr)
+{
+#if USE_FAST_PATH
+ int i;
+
+ for (i = 0; i < nr; i++) {
+ out[i] = in[i];
+ switch (in[i].ops) {
+ case PIPE_OP_RAST_SETUP_0:
+ out[i].cva_state_change = (NEW_LIGHTING |
+ NEW_TEXTURING |
+ NEW_RASTER_OPS);
+ out[i].state_change = ~0;
+ out[i].check = r128CheckPartialRasterSetup;
+ out[i].run = r128PartialRasterSetup;
+ break;
+
+ case PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1:
+ out[i].run = r128DoRasterSetup;
+ break;
+ }
+ }
+#endif
+
+ return nr;
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h b/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h
new file mode 100644
index 000000000..280e6b943
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.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_PIPELINE_H_
+#define _R128_PIPELINE_H_
+
+extern GLboolean r128DDBuildPrecalcPipeline(GLcontext *ctx);
+extern GLuint r128RegisterPipelineStages(struct gl_pipeline_stage *out,
+ const struct gl_pipeline_stage *in,
+ GLuint nr);
+
+#endif /* _R128_PIPELINE_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..b385271f4
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_screen.c
@@ -0,0 +1,258 @@
+/* $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_dri.h"
+#include "r128_reg.h"
+
+#include "r128_init.h"
+#include "r128_context.h"
+#include "r128_xmesa.h"
+#include "r128_cce.h"
+#include "r128_tris.h"
+#include "r128_vb.h"
+#include "r128_fastpath.h"
+
+#include <sys/mman.h>
+
+/* Create the device specific screen private data struct */
+r128ScreenPtr r128CreateScreen(__DRIscreenPrivate *sPriv)
+{
+ r128ScreenPtr r128Screen;
+ R128DRIPtr r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv;
+
+ /* Allocate the private area */
+ r128Screen = (r128ScreenPtr)Xmalloc(sizeof(*r128Screen));
+ if (!r128Screen) return NULL;
+
+ /* This is first since which regions we map depends on whether or
+ not we are using a PCI card */
+ r128Screen->IsPCI = r128DRIPriv->IsPCI;
+
+ 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 NULL;
+ }
+
+ if (!r128Screen->IsPCI) {
+ r128Screen->ringRgn.handle = r128DRIPriv->ringHandle;
+ r128Screen->ringRgn.size = r128DRIPriv->ringMapSize;
+ if (drmMap(sPriv->fd,
+ r128Screen->ringRgn.handle,
+ r128Screen->ringRgn.size,
+ (drmAddressPtr)&r128Screen->ring)) {
+ drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size);
+ Xfree(r128Screen);
+ return NULL;
+ }
+
+ r128Screen->ringReadRgn.handle = r128DRIPriv->ringReadPtrHandle;
+ r128Screen->ringReadRgn.size = r128DRIPriv->ringReadMapSize;
+ if (drmMap(sPriv->fd,
+ r128Screen->ringReadRgn.handle,
+ r128Screen->ringReadRgn.size,
+ (drmAddressPtr)&r128Screen->ringReadPtr)) {
+ drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size);
+ drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size);
+ Xfree(r128Screen);
+ return NULL;
+ }
+
+ r128Screen->vbRgn.handle = r128DRIPriv->vbHandle;
+ r128Screen->vbRgn.size = r128DRIPriv->vbMapSize;
+ r128Screen->vbOffset = r128DRIPriv->vbOffset;
+ if (drmMap(sPriv->fd,
+ r128Screen->vbRgn.handle,
+ r128Screen->vbRgn.size,
+ (drmAddressPtr)&r128Screen->vb)) {
+ drmUnmap((drmAddress)r128Screen->ringReadPtr,
+ r128Screen->ringReadRgn.size);
+ drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size);
+ drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size);
+ Xfree(r128Screen);
+ return NULL;
+ }
+ r128Screen->vbOffset = r128DRIPriv->vbOffset;
+ r128Screen->vbBufSize = r128DRIPriv->vbBufSize;
+
+ r128Screen->indRgn.handle = r128DRIPriv->indHandle;
+ r128Screen->indRgn.size = r128DRIPriv->indMapSize;
+ if (drmMap(sPriv->fd,
+ r128Screen->indRgn.handle,
+ r128Screen->indRgn.size,
+ (drmAddressPtr)&r128Screen->ind)) {
+ drmUnmap((drmAddress)r128Screen->vb, r128Screen->vbRgn.size);
+ drmUnmap((drmAddress)r128Screen->ringReadPtr,
+ r128Screen->ringReadRgn.size);
+ drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size);
+ drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size);
+ Xfree(r128Screen);
+ return NULL;
+ }
+
+ r128Screen->agpTexRgn.handle = r128DRIPriv->agpTexHandle;
+ r128Screen->agpTexRgn.size = r128DRIPriv->agpTexMapSize;
+ if (drmMap(sPriv->fd,
+ r128Screen->agpTexRgn.handle,
+ r128Screen->agpTexRgn.size,
+ (drmAddressPtr)&r128Screen->agpTex)) {
+ drmUnmap((drmAddress)r128Screen->ind, r128Screen->indRgn.size);
+ drmUnmap((drmAddress)r128Screen->vb, r128Screen->vbRgn.size);
+ drmUnmap((drmAddress)r128Screen->ringReadPtr,
+ r128Screen->ringReadRgn.size);
+ drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size);
+ drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size);
+ Xfree(r128Screen);
+ return NULL;
+ }
+ r128Screen->agpTexOffset = r128DRIPriv->agpTexOffset;
+
+ if (!(r128Screen->vbBufs = drmMapBufs(sPriv->fd))) {
+ drmUnmap((drmAddress)r128Screen->agpTex,
+ r128Screen->agpTexRgn.size);
+ drmUnmap((drmAddress)r128Screen->ind, r128Screen->indRgn.size);
+ drmUnmap((drmAddress)r128Screen->vb, r128Screen->vbRgn.size);
+ drmUnmap((drmAddress)r128Screen->ringReadPtr,
+ r128Screen->ringReadRgn.size);
+ drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size);
+ drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size);
+ Xfree(r128Screen);
+ return NULL;
+ }
+ }
+
+ r128Screen->deviceID = r128DRIPriv->deviceID;
+
+ r128Screen->width = r128DRIPriv->width;
+ r128Screen->height = r128DRIPriv->height;
+ r128Screen->depth = r128DRIPriv->depth;
+ r128Screen->bpp = r128DRIPriv->bpp;
+ r128Screen->pixel_code = (r128Screen->bpp != 16 ?
+ r128Screen->bpp :
+ r128Screen->depth);
+
+ r128Screen->fb = sPriv->pFB;
+ r128Screen->fbOffset = sPriv->fbOrigin;
+ r128Screen->fbStride = sPriv->fbStride;
+ r128Screen->fbSize = sPriv->fbSize;
+
+ r128Screen->fbX = r128DRIPriv->fbX;
+ r128Screen->fbY = r128DRIPriv->fbY;
+ r128Screen->backX = r128DRIPriv->backX;
+ r128Screen->backY = r128DRIPriv->backY;
+ r128Screen->depthX = r128DRIPriv->depthX;
+ r128Screen->depthY = r128DRIPriv->depthY;
+
+ r128Screen->texOffset[R128_LOCAL_TEX_HEAP] = (r128DRIPriv->textureY *
+ r128Screen->fbStride +
+ r128DRIPriv->textureX *
+ (r128Screen->bpp/8));
+ r128Screen->texSize[R128_LOCAL_TEX_HEAP] = r128DRIPriv->textureSize;
+ r128Screen->log2TexGran[R128_LOCAL_TEX_HEAP] = r128DRIPriv->log2TexGran;
+
+ if (r128Screen->IsPCI) {
+ r128Screen->texOffset[R128_AGP_TEX_HEAP] = 0;
+ r128Screen->texSize[R128_AGP_TEX_HEAP] = 0;
+ r128Screen->log2TexGran[R128_AGP_TEX_HEAP] = 0;
+ r128Screen->NRTexHeaps = R128_NR_TEX_HEAPS-1;
+ } else {
+ r128Screen->texOffset[R128_AGP_TEX_HEAP] = 0;
+ r128Screen->texSize[R128_AGP_TEX_HEAP] =
+ r128DRIPriv->agpTexMapSize;
+ r128Screen->log2TexGran[R128_AGP_TEX_HEAP] =
+ r128DRIPriv->log2AGPTexGran;
+ r128Screen->NRTexHeaps = R128_NR_TEX_HEAPS;
+ }
+
+#if 1
+ /* FIXME: For testing only */
+ if (getenv("LIBGL_SHOW_BUFFERS")) {
+ r128Screen->backX = 0;
+ r128Screen->backY = r128DRIPriv->height/2;
+ r128Screen->depthX = r128DRIPriv->width/2;
+ r128Screen->depthY = r128DRIPriv->height/2;
+ }
+#endif
+
+ r128Screen->CCEMode = r128DRIPriv->CCEMode;
+ r128Screen->CCEFifoSize = r128DRIPriv->CCEFifoSize;
+
+ r128Screen->ringEntries = r128DRIPriv->ringSize/sizeof(CARD32);
+ if (!r128Screen->IsPCI) {
+ r128Screen->ringStartPtr = (int *)r128Screen->ring;
+ r128Screen->ringEndPtr = (int *)(r128Screen->ring
+ + r128DRIPriv->ringSize);
+ }
+
+ r128Screen->MMIOFifoSlots = 0;
+ r128Screen->CCEFifoSlots = 0;
+
+ r128Screen->CCEFifoAddr = R128_PM4_FIFO_DATA_EVEN;
+
+ r128Screen->SAREA = (R128SAREAPrivPtr)((char *)sPriv->pSAREA +
+ sizeof(XF86DRISAREARec));
+
+ r128Screen->driScreen = sPriv;
+
+ r128FastPathInit();
+ r128TriangleFuncsInit();
+ r128SetupInit();
+
+ return r128Screen;
+}
+
+/* Destroy the device specific screen private data struct */
+void r128DestroyScreen(__DRIscreenPrivate *sPriv)
+{
+ r128ScreenPtr r128Screen = (r128ScreenPtr)sPriv->private;
+
+ if (!r128Screen->IsPCI) {
+ drmUnmapBufs(r128Screen->vbBufs);
+
+ drmUnmap((drmAddress)r128Screen->agpTex, r128Screen->agpTexRgn.size);
+ drmUnmap((drmAddress)r128Screen->ind, r128Screen->indRgn.size);
+ drmUnmap((drmAddress)r128Screen->vb, r128Screen->vbRgn.size);
+ drmUnmap((drmAddress)r128Screen->ringReadPtr,
+ r128Screen->ringReadRgn.size);
+ drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size);
+ }
+ drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size);
+
+ Xfree(r128Screen);
+ sPriv->private = NULL;
+}
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..02deb64e9
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_screen.h
@@ -0,0 +1,129 @@
+/* $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
+
+#include "r128_sarea.h"
+
+typedef struct {
+ drmHandle handle; /* Handle to the DRM region */
+ drmSize size; /* Size of the DRM region */
+} r128RegionRec, *r128RegionPtr;
+
+typedef struct {
+ /* MMIO register data */
+ r128RegionRec mmioRgn;
+ unsigned char *mmio;
+
+ /* CCE ring buffer data */
+ r128RegionRec ringRgn;
+ unsigned char *ring;
+
+ /* CCE ring read pointer data */
+ r128RegionRec ringReadRgn;
+
+ /* CCE vertex buffer data */
+ r128RegionRec vbRgn;
+ unsigned char *vb;
+ int vbOffset;
+ int vbBufSize;
+ drmBufMapPtr vbBufs;
+
+ /* CCE indirect buffer data */
+ r128RegionRec indRgn;
+ unsigned char *ind;
+
+ /* CCE AGP Texture data */
+ r128RegionRec agpTexRgn;
+ unsigned char *agpTex;
+ int agpTexOffset;
+
+ /* Frame buffer data */
+ unsigned char *fb;
+ unsigned long fbOffset;
+ int fbStride;
+ int fbSize;
+
+ int IsPCI; /* Current card is a PCI card */
+
+ int CCEMode; /* CCE mode that server/clients use */
+ int CCEFifoSize; /* Size of the CCE command FIFO */
+
+ /* CCE ring buffer data */
+ int ringEntries;
+
+ volatile int *ringReadPtr; /* Pointer to current read addr */
+ int *ringStartPtr; /* Pointer to end of ring buffer */
+ int *ringEndPtr; /* Pointer to end of ring buffer */
+
+ /* DRI screen private data */
+ int deviceID; /* PCI device ID */
+ int width; /* Width in pixels of display */
+ int height; /* Height in scanlines of display */
+ int depth; /* Depth of display (8, 15, 16, 24) */
+ int bpp; /* Bit depth of disp (8, 16, 24, 32) */
+ int pixel_code; /* 8, 15, 16, 24, 32 */
+
+ int fbX; /* Start of frame buffer */
+ int fbY;
+ int backX; /* Start of shared back buffer */
+ int backY;
+ int depthX; /* Start of shared depth buffer */
+ int depthY;
+
+ /* Shared texture data */
+ int NRTexHeaps;
+ int texOffset[R128_NR_TEX_HEAPS];
+ int texSize[R128_NR_TEX_HEAPS];
+ int log2TexGran[R128_NR_TEX_HEAPS];
+
+ int MMIOFifoSlots; /* Free slots in the FIFO (64 max) */
+ int CCEFifoSlots; /* Free slots in the CCE FIFO */
+
+ int CCEFifoAddr; /* MMIO offset to write next CCE
+ value (only used when CCE is
+ in PIO mode). */
+ R128SAREAPrivPtr SAREA; /* Pointer to SAREA private data */
+
+ __DRIscreenPrivate *driScreen;
+} r128ScreenRec, *r128ScreenPtr;
+
+r128ScreenPtr r128CreateScreen(__DRIscreenPrivate *sPriv);
+void r128DestroyScreen(__DRIscreenPrivate *sPriv);
+
+#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..b5d1774fd
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_span.c
@@ -0,0 +1,329 @@
+/* $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>
+ * Keith Whitwell <keith@precisioninsight.com>
+ * Gareth Hughes <gareth@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"
+#include "r128_cce.h"
+#include "r128_span.h"
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx); \
+ r128ScreenPtr r128scrn = r128ctx->r128Screen; \
+ __DRIdrawablePrivate *dPriv = r128ctx->driDrawable; \
+ GLuint pitch = r128scrn->fbStride; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(r128scrn->fb + \
+ (r128ctx->drawX + dPriv->x) * (r128scrn->bpp/8) + \
+ (r128ctx->drawY + dPriv->y) * pitch); \
+ char *read_buf = (char *)(r128scrn->fb + \
+ (r128ctx->readX + dPriv->x) * (r128scrn->bpp/8)+\
+ (r128ctx->readY + dPriv->y) * pitch); \
+ GLushort p; \
+ (void) read_buf; (void) buf; (void) p
+
+#define LOCAL_DEPTH_VARS \
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx); \
+ r128ScreenPtr r128scrn = r128ctx->r128Screen; \
+ __DRIdrawablePrivate *dPriv = r128ctx->driDrawable; \
+ GLuint pitch = r128scrn->fbStride; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(r128scrn->fb + \
+ (r128scrn->depthX + dPriv->x) * (r128scrn->bpp/8) + \
+ (r128scrn->depthY + dPriv->y) * pitch); \
+ (void) buf
+
+#define INIT_MONO_PIXEL(p) \
+ p = R128_CONTEXT(ctx)->Color
+
+#define CLIPPIXEL(_x, _y) \
+ ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
+
+
+#define CLIPSPAN(_x, _y, _n, _x1, _n1, _i) \
+ if (( _y < miny) || (_y >= maxy)) { \
+ _n1 = 0, _x1 = x; \
+ } else { \
+ _n1 = _n; \
+ _x1 = _x; \
+ if (_x1 < minx) _i += (minx - _x1), _x1 = minx; \
+ if (_x1 + _n1 >= maxx) n1 -= (_x1 + n1 - maxx) + 1; \
+ }
+
+#define Y_FLIP(_y) (height - _y - 1)
+
+
+#define HW_LOCK() \
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx); \
+ LOCK_HARDWARE(r128ctx); \
+ R128CCE_WAIT_FOR_IDLE(r128ctx);
+
+#define HW_CLIPLOOP() \
+ do { \
+ __DRIdrawablePrivate *dPriv = r128ctx->driDrawable; \
+ int _nc = dPriv->numClipRects; \
+ \
+ while (_nc--) { \
+ int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
+ int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
+ int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
+ int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
+
+#define HW_ENDCLIPLOOP() \
+ } \
+ } while (0)
+
+#define HW_UNLOCK() \
+ UNLOCK_HARDWARE(r128ctx)
+
+
+
+/* 16 bit, RGB565 color spanline and pixel functions */
+#define WRITE_RGBA(_x, _y, r, g, b, a) \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) | \
+ (((int)g & 0xfc) << 3) | \
+ (((int)b & 0xf8) >> 3) )
+
+#define WRITE_PIXEL(_x, _y, p) \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = p
+
+#define READ_RGBA(rgba, _x, _y) \
+ do { \
+ GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \
+ rgba[0] = (p >> 8) & 0xf8; \
+ rgba[1] = (p >> 3) & 0xfc; \
+ rgba[2] = (p << 3) & 0xf8; \
+ rgba[3] = 0xff; \
+ } while (0)
+
+#define TAG(x) r128##x##_RGB565
+#include "spantmp.h"
+
+
+
+/* 15 bit, ARGB1555 color spanline and pixel functions */
+#define WRITE_RGBA(_x, _y, r, g, b, a) \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = (((r & 0xf8) << 7) | \
+ ((g & 0xf8) << 2) | \
+ ((b & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+
+#define WRITE_PIXEL(_x, _y, p) \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = p
+
+#define READ_RGBA(rgba, _x, _y) \
+ do { \
+ GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \
+ rgba[0] = (p >> 7) & 0xf8; \
+ rgba[1] = (p >> 2) & 0xf8; \
+ rgba[2] = (p << 3) & 0xf8; \
+ rgba[3] = (p & 0x8000) ? 0xff : 0; \
+ } while (0)
+
+#define TAG(x) r128##x##_ARGB1555
+#include "spantmp.h"
+
+
+
+/* 16 bit depthbuffer functions */
+#define WRITE_DEPTH(_x, _y, d) \
+ *(GLdepth *)(buf + _x*2 + _y*pitch) = d
+
+#define READ_DEPTH(d, _x, _y) \
+ d = *(GLdepth *)(buf + _x*2 + _y*pitch)
+
+#define TAG(x) r128##x##_16
+#include "depthtmp.h"
+
+
+
+/* 24 bit, RGB888 color spanline and pixel functions */
+#define WRITE_RGBA(_x, _y, r, g, b, a) \
+ *(GLuint *)(buf + _x*3 + _y*pitch) = ((r << 16) | \
+ (g << 8) | \
+ (b << 0))
+
+#define WRITE_PIXEL(_x, _y, p) \
+ *(GLuint *)(buf + _x*3 + _y*pitch) = p
+
+#define READ_RGBA(rgba, _x, _y) \
+ do { \
+ GLuint p = *(GLuint *)(read_buf + _x*3 + _y*pitch); \
+ rgba[0] = (p >> 16) & 0xff; \
+ rgba[1] = (p >> 8) & 0xff; \
+ rgba[2] = (p >> 0) & 0xff; \
+ rgba[3] = 0xff; \
+ } while (0)
+
+#define TAG(x) r128##x##_RGB888
+#include "spantmp.h"
+
+
+
+/* 24 bit depthbuffer functions */
+#define WRITE_DEPTH(_x, _y, d) \
+ *(GLdepth *)(buf + _x*3 + _y*pitch) = d
+
+#define READ_DEPTH(d, _x, _y) \
+ d = *(GLdepth *)(buf + _x*3 + _y*pitch)
+
+#define TAG(x) r128##x##_24
+#include "depthtmp.h"
+
+
+
+/* 32 bit, ARGB8888 color spanline and pixel functions */
+#define WRITE_RGBA(_x, _y, r, g, b, a) \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = ((r << 16) | \
+ (g << 8) | \
+ (b << 0) | \
+ (a << 24) )
+
+#define WRITE_PIXEL(_x, _y, p) \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = p
+
+#define READ_RGBA(rgba, _x, _y) \
+ do { \
+ GLuint p = *(GLuint *)(read_buf + _x*4 + _y*pitch); \
+ rgba[0] = (p >> 16) & 0xff; \
+ rgba[1] = (p >> 8) & 0xff; \
+ rgba[2] = (p >> 0) & 0xff; \
+ rgba[3] = (p >> 24) & 0xff; \
+ } while (0)
+
+#define TAG(x) r128##x##_ARGB8888
+#include "spantmp.h"
+
+
+
+/* 32 bit depthbuffer functions */
+#define WRITE_DEPTH(_x, _y, d) \
+ *(GLdepth *)(buf + _x*4 + _y*pitch) = d
+
+#define READ_DEPTH(d, _x, _y) \
+ d = *(GLdepth *)(buf + _x*4 + _y*pitch)
+
+#define TAG(x) r128##x##_32
+#include "depthtmp.h"
+
+
+
+void r128DDInitSpanFuncs(GLcontext *ctx)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ switch (r128ctx->r128Screen->pixel_code) {
+ case 8: /* Color Index mode not supported */
+ break;
+
+ case 15:
+ ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_ARGB1555;
+ ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_ARGB1555;
+ ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_ARGB1555;
+ ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_ARGB1555;
+ ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_ARGB1555;
+ ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_ARGB1555;
+ ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_ARGB1555;
+
+ ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_16;
+ ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_16;
+ ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_16;
+ ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_16;
+ break;
+
+ case 16:
+ ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_RGB565;
+ ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_RGB565;
+ ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_RGB565;
+ ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_RGB565;
+ ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_RGB565;
+ ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_RGB565;
+ ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_RGB565;
+
+ ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_16;
+ ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_16;
+ ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_16;
+ ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_16;
+ break;
+
+ case 24:
+ ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_RGB888;
+ ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_RGB888;
+ ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_RGB888;
+ ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_RGB888;
+ ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_RGB888;
+ ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_RGB888;
+ ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_RGB888;
+
+ ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_24;
+ ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_24;
+ ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_24;
+ ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_24;
+ break;
+
+ case 32:
+ ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_ARGB8888;
+ ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_ARGB8888;
+ ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_ARGB8888;
+ ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_ARGB8888;
+ ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_ARGB8888;
+ ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_ARGB8888;
+ ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_ARGB8888;
+
+ ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_32;
+ ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_32;
+ ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_32;
+ ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_32;
+ break;
+
+ default:
+ break;
+ }
+
+ ctx->Driver.WriteCI8Span = NULL;
+ ctx->Driver.WriteCI32Span = NULL;
+ ctx->Driver.WriteMonoCISpan = NULL;
+ ctx->Driver.WriteCI32Pixels = NULL;
+ ctx->Driver.WriteMonoCIPixels = NULL;
+ ctx->Driver.ReadCI32Span = NULL;
+ ctx->Driver.ReadCI32Pixels = NULL;
+}
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..f83a4da9f
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_span.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>
+ * Gareth Hughes <gareth@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..3d1ceaa24
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_state.c
@@ -0,0 +1,1309 @@
+/* $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"
+#include "r128_cce.h"
+#include "r128_tris.h"
+#include "r128_vb.h"
+#include "r128_tex.h"
+
+#include "mmath.h"
+
+#define INTERESTED (~(NEW_MODELVIEW | \
+ NEW_PROJECTION | \
+ NEW_TEXTURE_MATRIX | \
+ NEW_USER_CLIP | \
+ NEW_CLIENT_STATE | \
+ NEW_TEXTURE_ENABLE))
+
+static void r128DDUpdateState(GLcontext *ctx)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) {
+ fprintf(stderr, "r128DDUpdateState(%p)\n", ctx);
+ }
+
+ if (ctx->NewState & INTERESTED) {
+ r128ChooseRenderState(ctx);
+ r128ChooseRasterSetupFunc(ctx);
+ }
+
+ if (!r128ctx->Fallback) {
+ ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
+ ctx->IndirectTriangles |= r128ctx->IndirectTriangles;
+
+ ctx->Driver.PointsFunc = r128ctx->PointsFunc;
+ ctx->Driver.LineFunc = r128ctx->LineFunc;
+ ctx->Driver.TriangleFunc = r128ctx->TriangleFunc;
+ ctx->Driver.QuadFunc = r128ctx->QuadFunc;
+ ctx->Driver.RectFunc = NULL;
+ }
+}
+
+static void r128DDUpdateHWState(GLcontext *ctx)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ /* FIXME: state is being updated too often */
+ if (r128ctx->dirty)
+ r128UpdateHWState(r128ctx);
+}
+
+static void r128DDReducedPrimitiveChange(GLcontext *ctx, GLenum prim)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ /* FIXME: Also need to flush between tris and tristrips/fans when we
+ support them directly */
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+}
+
+static void r128DDClearColor(GLcontext *ctx,
+ GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ r128ctx->ClearColor = r128PackColor(r128ctx->r128Screen->depth,
+ r, g, b, a);
+}
+
+static void r128DDColor(GLcontext *ctx,
+ GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ r128ctx->Color = r128PackColor(r128ctx->r128Screen->depth, r, g, b, a);
+}
+
+static GLboolean r128DDSetDrawBuffer(GLcontext *ctx, GLenum mode)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ int x = r128ctx->driDrawable->x;
+ int y = r128ctx->driDrawable->y;
+ int found;
+
+ r128ctx->Fallback &= ~R128_FALLBACK_DRAW_BUFFER;
+
+ switch (mode) {
+ case GL_FRONT_LEFT:
+ r128ctx->drawX = r128ctx->r128Screen->fbX;
+ r128ctx->drawY = r128ctx->r128Screen->fbY;
+ found = GL_TRUE;
+ break;
+ case GL_BACK_LEFT:
+ r128ctx->drawX = r128ctx->r128Screen->backX;
+ r128ctx->drawY = r128ctx->r128Screen->backY;
+ found = GL_TRUE;
+ break;
+ default:
+ r128ctx->Fallback |= R128_FALLBACK_DRAW_BUFFER;
+ found = GL_FALSE;
+ break;
+ }
+
+ x += r128ctx->drawX;
+ y += r128ctx->drawY;
+
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.window_xy_offset = ((y << R128_WINDOW_Y_SHIFT) |
+ (x << R128_WINDOW_X_SHIFT));
+
+ /* Recalculate the Z buffer offset since we might be drawing to the
+ back buffer and window_xy_offset affects both color buffer and
+ depth drawing */
+ r128ctx->regs.z_offset_c = ((r128ctx->r128Screen->depthX -
+ r128ctx->drawX) *
+ (r128ctx->r128Screen->bpp/8) +
+ (r128ctx->r128Screen->depthY -
+ r128ctx->drawY) *
+ r128ctx->r128Screen->fbStride);
+
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_WIN_Z_POS;
+ return found;
+}
+
+static void r128DDSetReadBuffer(GLcontext *ctx,
+ GLframebuffer *colorBuffer,
+ GLenum mode)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ r128ctx->Fallback &= ~R128_FALLBACK_READ_BUFFER;
+
+ switch (mode) {
+ case GL_FRONT_LEFT:
+ r128ctx->readX = r128ctx->r128Screen->fbX;
+ r128ctx->readY = r128ctx->r128Screen->fbY;
+ break;
+ case GL_BACK_LEFT:
+ r128ctx->readX = r128ctx->r128Screen->backX;
+ r128ctx->readY = r128ctx->r128Screen->backY;
+ break;
+ default:
+ r128ctx->Fallback |= R128_FALLBACK_READ_BUFFER;
+ break;
+ }
+}
+
+static GLboolean r128DDColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ GLuint mask = r128PackColor(r128ctx->r128Screen->pixel_code,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP]);
+
+ if (r128ctx->regs.plane_3d_mask_c != mask) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.plane_3d_mask_c = mask;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_MISC;
+ }
+
+ return GL_TRUE;
+}
+
+static void r128DDDither(GLcontext *ctx, GLboolean enable)
+{
+}
+
+static void r128DDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ CARD32 a = r128ctx->regs.misc_3d_state_cntl_reg;
+
+ a &= ~(R128_ALPHA_TEST_MASK | R128_REF_ALPHA_MASK);
+ a |= ctx->Color.AlphaRef & R128_REF_ALPHA_MASK;
+
+ switch (func) {
+ case GL_NEVER: a |= R128_ALPHA_TEST_NEVER; break;
+ case GL_LESS: a |= R128_ALPHA_TEST_LESS; break;
+ case GL_LEQUAL: a |= R128_ALPHA_TEST_LESSEQUAL; break;
+ case GL_EQUAL: a |= R128_ALPHA_TEST_EQUAL; break;
+ case GL_GEQUAL: a |= R128_ALPHA_TEST_GREATEREQUAL; break;
+ case GL_GREATER: a |= R128_ALPHA_TEST_GREATER; break;
+ case GL_NOTEQUAL: a |= R128_ALPHA_TEST_NEQUAL; break;
+ case GL_ALWAYS: a |= R128_ALPHA_TEST_ALWAYS;
+ break;
+ default:
+ /* ERROR!!! */
+ return;
+ }
+
+ if (r128ctx->regs.misc_3d_state_cntl_reg != a) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.misc_3d_state_cntl_reg = a;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_ALPHASTATE;
+ }
+}
+
+static void r128DDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ CARD32 b = r128ctx->regs.misc_3d_state_cntl_reg;
+
+ b &= ~(R128_ALPHA_BLEND_SRC_MASK | R128_ALPHA_BLEND_DST_MASK);
+
+ switch (sfactor) {
+ case GL_ZERO: b |= R128_ALPHA_BLEND_SRC_ZERO;
+ break;
+ case GL_ONE: b |= R128_ALPHA_BLEND_SRC_ONE;
+ break;
+ case GL_DST_COLOR: b |= R128_ALPHA_BLEND_SRC_DESTCOLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR: b |= R128_ALPHA_BLEND_SRC_INVDESTCOLOR;
+ break;
+ case GL_SRC_ALPHA: b |= R128_ALPHA_BLEND_SRC_SRCALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA: b |= R128_ALPHA_BLEND_SRC_INVSRCALPHA;
+ break;
+ case GL_DST_ALPHA: b |= R128_ALPHA_BLEND_SRC_DESTALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA: b |= R128_ALPHA_BLEND_SRC_INVDESTALPHA;
+ break;
+ case GL_SRC_ALPHA_SATURATE: b |= R128_ALPHA_BLEND_SRC_SRCALPHASAT;
+ break;
+#if 0
+ /* FIXME: These are not supported directly by the Rage 128.
+ They could be emulated using something like the TexEnv
+ modes. */
+ case GL_CONSTANT_COLOR: b |= 0;
+ break;
+ case GL_ONE_MINUS_CONSTANT_COLOR: b |= 0;
+ break;
+ case GL_CONSTANT_ALPHA: b |= 0;
+ break;
+ case GL_ONE_MINUS_CONSTANT_ALPHA: b |= 0;
+ break;
+#endif
+ default:
+ /* ERROR!!! */
+ return;
+ }
+
+ switch (dfactor) {
+ case GL_ZERO: b |= R128_ALPHA_BLEND_DST_ZERO;
+ break;
+ case GL_ONE: b |= R128_ALPHA_BLEND_DST_ONE;
+ break;
+ case GL_SRC_COLOR: b |= R128_ALPHA_BLEND_DST_SRCCOLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR: b |= R128_ALPHA_BLEND_DST_INVSRCCOLOR;
+ break;
+ case GL_SRC_ALPHA: b |= R128_ALPHA_BLEND_DST_SRCALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA: b |= R128_ALPHA_BLEND_DST_INVSRCALPHA;
+ break;
+ case GL_DST_ALPHA: b |= R128_ALPHA_BLEND_DST_DESTALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA: b |= R128_ALPHA_BLEND_DST_INVDESTALPHA;
+ break;
+#if 0
+ /* FIXME: These are not supported directly by the Rage 128.
+ They could be emulated using something like the TexEnv
+ modes. */
+ case GL_CONSTANT_COLOR: b |= 0;
+ break;
+ case GL_ONE_MINUS_CONSTANT_COLOR: b |= 0;
+ break;
+ case GL_CONSTANT_ALPHA: b |= 0;
+ break;
+ case GL_ONE_MINUS_CONSTANT_ALPHA: b |= 0;
+ break;
+#endif
+ default:
+ /* ERROR!!! */
+ return;
+ }
+
+ if (r128ctx->regs.misc_3d_state_cntl_reg != b) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.misc_3d_state_cntl_reg = b;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_ALPHASTATE;
+ }
+}
+
+static void r128DDBlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA,
+ GLenum dfactorA)
+{
+ if (sfactorRGB != sfactorA || dfactorRGB != dfactorA) {
+ /* ERROR!!! */
+ return;
+ }
+
+ r128DDBlendFunc(ctx, sfactorRGB, dfactorRGB);
+}
+
+static void r128DDClearDepth(GLcontext *ctx, GLclampd d)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ switch (r128ctx->regs.z_sten_cntl_c & R128_Z_PIX_WIDTH_MASK) {
+ case R128_Z_PIX_WIDTH_16: r128ctx->ClearDepth = d * 0x0000ffff; break;
+ case R128_Z_PIX_WIDTH_24: r128ctx->ClearDepth = d * 0x00ffffff; break;
+ case R128_Z_PIX_WIDTH_32: r128ctx->ClearDepth = d * 0xffffffff; break;
+ default: return;
+ }
+}
+
+static void r128DDCullFace(GLcontext *ctx, GLenum mode)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ CARD32 f = r128ctx->regs.pm4_vc_fpu_setup;
+
+ if (!ctx->Polygon.CullFlag) return;
+
+ f &= ~(R128_BACKFACE_MASK | R128_FRONTFACE_MASK);
+
+ switch (mode) {
+ case GL_FRONT: f |= R128_BACKFACE_SOLID; break;
+ case GL_BACK: f |= R128_FRONTFACE_SOLID; break;
+ case GL_FRONT_AND_BACK: break;
+ default: return;
+ }
+
+ if (r128ctx->regs.pm4_vc_fpu_setup != f) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.pm4_vc_fpu_setup = f;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_SETUPSTATE;
+ }
+}
+
+static void r128DDFrontFace(GLcontext *ctx, GLenum mode)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ CARD32 f = r128ctx->regs.pm4_vc_fpu_setup;
+
+ f &= ~R128_FRONT_DIR_MASK;
+
+ switch (mode) {
+ case GL_CW: f |= R128_FRONT_DIR_CW; break;
+ case GL_CCW: f |= R128_FRONT_DIR_CCW; break;
+ default: return;
+ }
+
+ if (r128ctx->regs.pm4_vc_fpu_setup != f) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.pm4_vc_fpu_setup = f;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_SETUPSTATE;
+ }
+}
+
+static void r128DDDepthFunc(GLcontext *ctx, GLenum func)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ CARD32 z = r128ctx->regs.z_sten_cntl_c;
+
+ z &= ~R128_Z_TEST_MASK;
+
+ switch (func) {
+ case GL_NEVER: z |= R128_Z_TEST_NEVER; break;
+ case GL_LESS: z |= R128_Z_TEST_LESS; break;
+ case GL_LEQUAL: z |= R128_Z_TEST_LESSEQUAL; break;
+ case GL_EQUAL: z |= R128_Z_TEST_EQUAL; break;
+ case GL_GEQUAL: z |= R128_Z_TEST_GREATEREQUAL; break;
+ case GL_GREATER: z |= R128_Z_TEST_GREATER; break;
+ case GL_NOTEQUAL: z |= R128_Z_TEST_NEQUAL; break;
+ case GL_ALWAYS: z |= R128_Z_TEST_ALWAYS; break;
+ default: return;
+ }
+
+ if (r128ctx->regs.z_sten_cntl_c != z) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.z_sten_cntl_c = z;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_ZSTENSTATE;
+ }
+}
+
+static void r128DDDepthMask(GLcontext *ctx, GLboolean flag)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ CARD32 t = r128ctx->regs.tex_cntl_c;
+
+ if (flag) t |= R128_Z_WRITE_ENABLE;
+ else t &= ~R128_Z_WRITE_ENABLE;
+
+ if (r128ctx->regs.tex_cntl_c != t) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.tex_cntl_c = t;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_ENGINESTATE;
+ }
+}
+
+static void r128DDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ CARD32 t = r128ctx->regs.tex_cntl_c;
+ CARD32 f = r128ctx->regs.pm4_vc_fpu_setup;
+
+ if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) {
+ fprintf(stderr, "r128DDEnable( %p, 0x%x = %s )\n",
+ ctx, cap, state ? "GL_TRUE" : "GL_FALSE");
+ }
+
+ switch (cap) {
+ case GL_ALPHA_TEST:
+ if (state) t |= R128_ALPHA_TEST_ENABLE;
+ else t &= ~R128_ALPHA_TEST_ENABLE;
+ break;
+
+ case GL_AUTO_NORMAL: return;
+
+ case GL_BLEND:
+ if (state) t |= R128_ALPHA_ENABLE;
+ else t &= ~R128_ALPHA_ENABLE;
+ break;
+
+ case GL_CLIP_PLANE0:
+ case GL_CLIP_PLANE1:
+ case GL_CLIP_PLANE2:
+ case GL_CLIP_PLANE3:
+ case GL_CLIP_PLANE4:
+ case GL_CLIP_PLANE5:
+ case GL_COLOR_MATERIAL: return;
+
+ case GL_CULL_FACE:
+ f &= ~(R128_BACKFACE_MASK | R128_FRONTFACE_MASK);
+ if (state) {
+ switch (ctx->Polygon.CullFaceMode) {
+ case GL_FRONT: f |= R128_BACKFACE_SOLID; break;
+ case GL_BACK: f |= R128_FRONTFACE_SOLID; break;
+ case GL_FRONT_AND_BACK: break;
+ default: return;
+ }
+ } else {
+ f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID;
+ }
+ break;
+
+ case GL_DEPTH_TEST:
+ if (state) t |= R128_Z_ENABLE;
+ else t &= ~R128_Z_ENABLE;
+ break;
+
+ case GL_DITHER:
+ if (state) t |= R128_DITHER_ENABLE;
+ else t &= ~R128_DITHER_ENABLE;
+ break;
+
+ case GL_FOG:
+ if (state) t |= R128_FOG_ENABLE;
+ else t &= ~R128_FOG_ENABLE;
+ break;
+
+ case GL_LIGHT0:
+ case GL_LIGHT1:
+ case GL_LIGHT2:
+ case GL_LIGHT3:
+ case GL_LIGHT4:
+ case GL_LIGHT5:
+ case GL_LIGHT6:
+ case GL_LIGHT7:
+ case GL_LIGHTING:
+ case GL_LINE_SMOOTH:
+ case GL_LINE_STIPPLE:
+ case GL_INDEX_LOGIC_OP:
+ case GL_COLOR_LOGIC_OP:
+ case GL_MAP1_COLOR_4:
+ case GL_MAP1_INDEX:
+ case GL_MAP1_NORMAL:
+ case GL_MAP1_TEXTURE_COORD_1:
+ case GL_MAP1_TEXTURE_COORD_2:
+ case GL_MAP1_TEXTURE_COORD_3:
+ case GL_MAP1_TEXTURE_COORD_4:
+ case GL_MAP1_VERTEX_3:
+ case GL_MAP1_VERTEX_4:
+ case GL_MAP2_COLOR_4:
+ case GL_MAP2_INDEX:
+ case GL_MAP2_NORMAL:
+ case GL_MAP2_TEXTURE_COORD_1:
+ case GL_MAP2_TEXTURE_COORD_2:
+ case GL_MAP2_TEXTURE_COORD_3:
+ case GL_MAP2_TEXTURE_COORD_4:
+ case GL_MAP2_VERTEX_3:
+ case GL_MAP2_VERTEX_4:
+ case GL_NORMALIZE:
+ case GL_POINT_SMOOTH:
+ case GL_POLYGON_SMOOTH:
+ case GL_POLYGON_STIPPLE:
+ case GL_POLYGON_OFFSET_POINT:
+ case GL_POLYGON_OFFSET_LINE:
+ case GL_POLYGON_OFFSET_FILL:
+ case GL_RESCALE_NORMAL_EXT: return;
+
+ case GL_SCISSOR_TEST:
+ /* FIXME: Hook up the software scissor */
+#if 0
+ r128ctx->Scissor = state;
+#endif
+ break;
+
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ case GL_STENCIL_TEST: return;
+
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ /* This is handled in r128UpdateTex[01]State() */
+ r128ctx->dirty |= R128_UPDATE_TEXSTATE;
+ break;
+
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_GEN_Q:
+ case GL_TEXTURE_GEN_R:
+ case GL_TEXTURE_GEN_S:
+ case GL_TEXTURE_GEN_T: return;
+
+ /* Client state */
+ case GL_VERTEX_ARRAY:
+ case GL_NORMAL_ARRAY:
+ case GL_COLOR_ARRAY:
+ case GL_INDEX_ARRAY:
+ case GL_TEXTURE_COORD_ARRAY:
+ case GL_EDGE_FLAG_ARRAY: return;
+
+ default: return;
+ }
+
+ if (r128ctx->regs.tex_cntl_c != t) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.tex_cntl_c = t;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_ENGINESTATE;
+ }
+ if (r128ctx->regs.pm4_vc_fpu_setup != f) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.pm4_vc_fpu_setup = f;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_SETUPSTATE;
+ }
+
+}
+
+static void r128DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ GLubyte c[4];
+ CARD32 col;
+ floatTOint fog;
+ GLenum mode;
+
+ if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) {
+ fprintf(stderr, "r128DDFogfv(%p, 0x%x)\n", ctx, pname);
+ }
+
+ switch (pname) {
+ case GL_FOG_MODE:
+ mode = (GLenum)(GLint)*param;
+ if (r128ctx->FogMode != mode) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->FogMode = mode;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_FOGTABLE;
+ }
+ break;
+
+ case GL_FOG_DENSITY:
+ fog.f = *param;
+ if (r128ctx->regs.fog_3d_table_density != fog.i) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.fog_3d_table_density = fog.i;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_FOGSTATE;
+ }
+ break;
+
+ case GL_FOG_START:
+ fog.f = *param;
+ if (r128ctx->regs.fog_3d_table_start != fog.i) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.fog_3d_table_start = fog.i;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_FOGSTATE;
+ }
+ break;
+
+ case GL_FOG_END:
+ fog.f = *param;
+ if (r128ctx->regs.fog_3d_table_end != fog.i) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.fog_3d_table_end = fog.i;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_FOGSTATE;
+ }
+ break;
+
+ case GL_FOG_COLOR:
+ FLOAT_RGBA_TO_UBYTE_RGBA(c, ctx->Fog.Color);
+ col = r128PackColor(32, c[0], c[1], c[2], c[3]);
+ if (r128ctx->regs.fog_color_c != col) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.fog_color_c = col;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_FOGSTATE;
+ }
+ break;
+
+ default:
+ return;
+ }
+}
+
+static void r128DDScissor(GLcontext *ctx,
+ GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ r128ctx->ScissorRect.x1 = x;
+ r128ctx->ScissorRect.y1 = r128ctx->driDrawable->h - (y + h);
+ r128ctx->ScissorRect.x2 = x + w;
+ r128ctx->ScissorRect.y2 = r128ctx->driDrawable->h - y;
+}
+
+/* Initialize the driver's state functions */
+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.SetDrawBuffer = r128DDSetDrawBuffer;
+ ctx->Driver.SetReadBuffer = r128DDSetReadBuffer;
+
+ ctx->Driver.IndexMask = NULL;
+ ctx->Driver.ColorMask = r128DDColorMask;
+ ctx->Driver.LogicOp = NULL;
+ ctx->Driver.Dither = r128DDDither;
+
+ ctx->Driver.NearFar = NULL;
+
+ 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 = r128DDReducedPrimitiveChange;
+ ctx->Driver.MultipassFunc = NULL;
+
+ ctx->Driver.AlphaFunc = r128DDAlphaFunc;
+ ctx->Driver.BlendEquation = NULL;
+ ctx->Driver.BlendFunc = r128DDBlendFunc;
+ ctx->Driver.BlendFuncSeparate = r128DDBlendFuncSeparate;
+ ctx->Driver.ClearDepth = r128DDClearDepth;
+ ctx->Driver.CullFace = r128DDCullFace;
+ ctx->Driver.FrontFace = r128DDFrontFace;
+ ctx->Driver.DepthFunc = r128DDDepthFunc;
+ ctx->Driver.DepthMask = r128DDDepthMask;
+ ctx->Driver.DepthRange = NULL;
+ ctx->Driver.Enable = r128DDEnable;
+ ctx->Driver.Fogfv = r128DDFogfv;
+ ctx->Driver.Hint = NULL;
+ ctx->Driver.Lightfv = NULL;
+ ctx->Driver.LightModelfv = NULL;
+ ctx->Driver.PolygonMode = NULL;
+ ctx->Driver.Scissor = r128DDScissor;
+ ctx->Driver.ShadeModel = NULL;
+ ctx->Driver.ClearStencil = NULL;
+ ctx->Driver.StencilFunc = NULL;
+ ctx->Driver.StencilMask = NULL;
+ ctx->Driver.StencilOp = NULL;
+ ctx->Driver.Viewport = NULL;
+}
+
+/* Initialize the context's hardware state */
+void r128DDInitState(r128ContextPtr r128ctx)
+{
+ int dst_bpp, depth_bpp, pitch, i;
+ CARD32 depthClear;
+
+ pitch = r128ctx->r128Screen->fbStride / r128ctx->r128Screen->bpp;
+
+ switch (r128ctx->r128Screen->pixel_code) {
+ case 8: dst_bpp = R128_GMC_DST_8BPP_CI; break;
+ case 15: dst_bpp = R128_GMC_DST_15BPP; break;
+ case 16: dst_bpp = R128_GMC_DST_16BPP; break;
+ case 24: dst_bpp = R128_GMC_DST_24BPP; break;
+ case 32: dst_bpp = R128_GMC_DST_32BPP; break;
+ default:
+ fprintf(stderr, "Error: Unsupported pixel depth %d... exiting\n",
+ r128ctx->r128Screen->pixel_code);
+ exit(-1);
+ }
+
+ /* FIXME: Figure out how to use 16bpp depth buffer in 32bpp mode */
+ switch (r128ctx->glCtx->Visual->DepthBits) {
+ case 16: depthClear = 0x0000ffff; depth_bpp = R128_Z_PIX_WIDTH_16; break;
+ case 24: depthClear = 0x00ffffff; depth_bpp = R128_Z_PIX_WIDTH_24; break;
+ case 32: depthClear = 0xffffffff; depth_bpp = R128_Z_PIX_WIDTH_32; break;
+ default:
+ fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
+ r128ctx->r128Screen->bpp);
+ exit(-1);
+ break;
+ }
+
+ r128ctx->dirty = R128_ALL_DIRTY;
+ r128ctx->dirty_context = R128_CTX_ALL_DIRTY;
+
+ r128ctx->RenderIndex = R128_FALLBACK_BIT;
+ r128ctx->PointsFunc = NULL;
+ r128ctx->LineFunc = NULL;
+ r128ctx->TriangleFunc = NULL;
+ r128ctx->QuadFunc = NULL;
+
+ r128ctx->IndirectTriangles = 0;
+ r128ctx->Fallback = 0;
+
+ if (r128ctx->glCtx->Visual->DBflag) {
+ r128ctx->drawX = r128ctx->r128Screen->backX;
+ r128ctx->drawY = r128ctx->r128Screen->backY;
+ r128ctx->readX = r128ctx->r128Screen->backX;
+ r128ctx->readY = r128ctx->r128Screen->backY;
+ } else {
+ r128ctx->drawX = r128ctx->r128Screen->fbX;
+ r128ctx->drawY = r128ctx->r128Screen->fbY;
+ r128ctx->readX = r128ctx->r128Screen->fbX;
+ r128ctx->readY = r128ctx->r128Screen->fbY;
+ }
+
+ r128ctx->ClearColor = 0x00000000;
+ r128ctx->ClearDepth = depthClear;
+
+ r128ctx->regs.scale_3d_cntl =
+ R128_SCALE_DITHER_TABLE |
+ R128_TEX_CACHE_SIZE_FULL |
+ R128_DITHER_INIT_RESET |
+ R128_SCALE_3D_TEXMAP_SHADE |
+ R128_SCALE_PIX_REPLICATE |
+ /* R128_TEX_CACHE_SPLIT | */
+ R128_ALPHA_COMB_ADD_CLAMP |
+ R128_FOG_TABLE |
+ R128_ALPHA_BLEND_SRC_ONE |
+ R128_ALPHA_BLEND_DST_ZERO |
+ R128_ALPHA_TEST_ALWAYS |
+ R128_COMPOSITE_SHADOW_CMP_EQUAL |
+ R128_TEX_MAP_ALPHA_IN_TEXTURE |
+ R128_TEX_CACHE_LINE_SIZE_8QW;
+
+ r128ctx->regs.dst_pitch_offset_c = pitch << R128_PITCH_SHIFT;
+
+ r128ctx->regs.dp_gui_master_cntl =
+ R128_GMC_DST_PITCH_OFFSET_CNTL |
+ R128_GMC_DST_CLIPPING |
+ R128_GMC_BRUSH_SOLID_COLOR |
+ dst_bpp |
+ R128_GMC_SRC_DATATYPE_COLOR |
+ R128_GMC_BYTE_MSB_TO_LSB |
+ R128_GMC_CONVERSION_TEMP_6500 |
+ R128_ROP3_S |
+ R128_DP_SRC_SOURCE_MEMORY |
+ R128_GMC_3D_FCN_EN |
+ R128_GMC_CLR_CMP_CNTL_DIS |
+ R128_AUX_CLIP_DIS |
+ R128_GMC_WR_MSK_DIS;
+
+ r128ctx->regs.sc_top_left_c = 0x00000000;
+ r128ctx->regs.sc_bottom_right_c = 0x1fff1fff;
+
+ r128ctx->regs.aux_sc_cntl = 0x00000000;
+
+ r128ctx->regs.aux1_sc_left = 0x00000000;
+ r128ctx->regs.aux1_sc_right = 0x00001fff;
+ r128ctx->regs.aux1_sc_top = 0x00000000;
+ r128ctx->regs.aux1_sc_bottom = 0x00001fff;
+
+ r128ctx->regs.aux2_sc_left = 0x00000000;
+ r128ctx->regs.aux2_sc_right = 0x00001fff;
+ r128ctx->regs.aux2_sc_top = 0x00000000;
+ r128ctx->regs.aux2_sc_bottom = 0x00001fff;
+
+ r128ctx->regs.aux3_sc_left = 0x00000000;
+ r128ctx->regs.aux3_sc_right = 0x00001fff;
+ r128ctx->regs.aux3_sc_top = 0x00000000;
+ r128ctx->regs.aux3_sc_bottom = 0x00001fff;
+
+ r128ctx->regs.z_offset_c = (r128ctx->r128Screen->depthX *
+ (r128ctx->r128Screen->bpp/8) +
+ r128ctx->r128Screen->depthY *
+ r128ctx->r128Screen->fbStride);
+ r128ctx->regs.z_pitch_c = pitch;
+
+ r128ctx->regs.z_sten_cntl_c =
+ depth_bpp |
+ R128_Z_TEST_LESS |
+ R128_STENCIL_TEST_ALWAYS |
+ R128_STENCIL_S_FAIL_KEEP |
+ R128_STENCIL_ZPASS_KEEP |
+ R128_STENCIL_ZFAIL_KEEP;
+
+ r128ctx->regs.tex_cntl_c =
+ R128_Z_WRITE_ENABLE |
+ R128_SHADE_ENABLE |
+ R128_DITHER_ENABLE |
+ R128_ALPHA_IN_TEX_COMPLETE_A |
+ R128_LIGHT_DIS |
+ R128_ALPHA_LIGHT_DIS |
+ R128_TEX_CACHE_FLUSH |
+ (0x0f << R128_LOD_BIAS_SHIFT);
+
+ r128ctx->regs.misc_3d_state_cntl_reg =
+ R128_MISC_SCALE_3D_TEXMAP_SHADE |
+ R128_MISC_SCALE_PIX_REPLICATE |
+ R128_ALPHA_COMB_ADD_CLAMP |
+ R128_FOG_TABLE |
+ R128_ALPHA_BLEND_SRC_ONE |
+ R128_ALPHA_BLEND_DST_ZERO |
+ R128_ALPHA_TEST_ALWAYS;
+
+ r128ctx->regs.texture_clr_cmp_clr_c = 0x00000000;
+ r128ctx->regs.texture_clr_cmp_msk_c = 0xffffffff;
+
+ r128ctx->regs.prim_tex_cntl_c =
+ R128_MIN_BLEND_NEAREST |
+ R128_MAG_BLEND_NEAREST |
+ R128_MIP_MAP_DISABLE |
+ R128_TEX_CLAMP_S_WRAP |
+ R128_TEX_CLAMP_T_WRAP;
+
+ r128ctx->regs.prim_texture_combine_cntl_c =
+ R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_COPY |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA;
+
+ r128ctx->regs.tex_size_pitch_c =
+ (0 << R128_TEX_PITCH_SHIFT) |
+ (0 << R128_TEX_SIZE_SHIFT) |
+ (0 << R128_TEX_HEIGHT_SHIFT) |
+ (0 << R128_TEX_MIN_SIZE_SHIFT) |
+ (0 << R128_SEC_TEX_PITCH_SHIFT) |
+ (0 << R128_SEC_TEX_SIZE_SHIFT) |
+ (0 << R128_SEC_TEX_HEIGHT_SHIFT) |
+ (0 << R128_SEC_TEX_MIN_SIZE_SHIFT);
+
+ for (i = 0; i < R128_TEX_MAXLEVELS; i++)
+ r128ctx->regs.prim_tex_offset[i] = 0x00000000;
+
+ r128ctx->regs.sec_tex_cntl_c =
+ R128_SEC_SELECT_PRIM_ST;
+
+ r128ctx->regs.sec_tex_combine_cntl_c =
+ R128_COMB_DIS |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_DIS |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA;
+
+ for (i = 0; i < R128_TEX_MAXLEVELS; i++)
+ r128ctx->regs.sec_tex_offset[i] = 0x00000000;
+
+ r128ctx->regs.constant_color_c = 0x00ffffff;
+ r128ctx->regs.prim_texture_border_color_c = 0x00ffffff;
+ r128ctx->regs.sec_texture_border_color_c = 0x00ffffff;
+ r128ctx->regs.sten_ref_mask_c = 0xffff0000;
+ r128ctx->regs.plane_3d_mask_c = 0xffffffff;
+
+ r128ctx->regs.setup_cntl =
+ R128_COLOR_GOURAUD |
+ R128_PRIM_TYPE_TRI |
+#if 1
+ /* FIXME: Let r128 multiply? */
+ R128_TEXTURE_ST_MULT_W |
+#else
+ /* FIXME: Or, pre multiply? */
+ R128_TEXTURE_ST_DIRECT |
+#endif
+ R128_STARTING_VERTEX_1 |
+ R128_ENDING_VERTEX_3 |
+ R128_SU_POLY_LINE_NOT_LAST |
+ R128_SUB_PIX_4BITS;
+
+ r128ctx->regs.pm4_vc_fpu_setup =
+ R128_FRONT_DIR_CCW |
+ R128_BACKFACE_SOLID |
+ R128_FRONTFACE_SOLID |
+ R128_FPU_COLOR_GOURAUD |
+ R128_FPU_SUB_PIX_4BITS |
+ R128_FPU_MODE_3D |
+ R128_TRAP_BITS_DISABLE |
+ R128_XFACTOR_2 |
+ R128_YFACTOR_2 |
+ R128_FLAT_SHADE_VERTEX_OGL |
+ R128_FPU_ROUND_TRUNCATE |
+ R128_WM_SEL_8DW;
+
+ r128ctx->FogMode = GL_EXP;
+ r128ctx->regs.fog_color_c = 0x00808080;
+ r128ctx->regs.fog_3d_table_start = 0x00000000;
+ r128ctx->regs.fog_3d_table_end = 0xffffffff;
+ r128ctx->regs.fog_3d_table_density = 0x00000000;
+
+ r128ctx->regs.window_xy_offset = 0x00000000;
+
+ r128ctx->regs.dp_write_mask = 0xffffffff;
+
+ r128ctx->regs.pc_gui_ctlstat = R128_PC_FLUSH_GUI;
+
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_ALL_DIRTY;
+}
+
+/* Upload the fog table for the current fog mode */
+static void r128UploadFogTable(r128ContextPtr r128ctx)
+{
+ int i;
+
+ R128CCE0(R128_CCE_PACKET0, R128_FOG_TABLE_INDEX, 0);
+ R128CCE(0x00000000);
+
+ R128CCE0(R128_CCE_PACKET0_ONE_REG_WR, R128_FOG_TABLE_DATA, 255);
+
+ switch (r128ctx->FogMode) {
+ case GL_LINEAR:
+ for (i = 0; i < 256; i++) {
+ R128CCE(255 - i);
+ }
+ break;
+ case GL_EXP:
+ for (i = 0; i < 256; i++) {
+ R128CCE(255 - FLOAT_TO_UBYTE(exp(i - 255)));
+ }
+ break;
+ case GL_EXP2:
+ for (i = 0; i < 256; i++) {
+ R128CCE(255 - FLOAT_TO_UBYTE(exp((i - 255) * (i - 255))));
+ }
+ break;
+ }
+}
+
+/* Load the current context's state into the hardware */
+/* NOTE: This function is only called while holding the hardware lock */
+static void r128LoadContext(r128ContextPtr r128ctx)
+{
+ int i;
+ int tex_size_pitch_done = GL_FALSE;
+
+ if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) {
+ fprintf(stderr, "r128LoadContext(%p)\n", r128ctx->glCtx);
+ }
+
+#if 0
+ r128ctx->dirty_context = R128_CTX_ALL_DIRTY;
+#endif
+
+#if 1
+ /* FIXME: Why do these need to be updated even when they don't change? */
+ r128ctx->dirty_context |= (R128_CTX_MISC |
+ R128_CTX_ENGINESTATE |
+ R128_CTX_ALPHASTATE);
+#endif
+
+#if 1
+ /* FIXME: Is this _really_ needed? */
+ if (r128ctx->dirty_context)
+ if (!R128CCE_USE_RING_BUFFER(r128ctx->r128Screen->CCEMode))
+ R128CCE_WAIT_FOR_IDLE(r128ctx);
+#endif
+
+ if (r128ctx->dirty_context & R128_CTX_MISC) {
+ R128CCE1(R128_CCE_PACKET1, R128_SCALE_3D_CNTL, R128_DP_WRITE_MASK);
+ R128CCE(r128ctx->regs.scale_3d_cntl);
+ R128CCE(r128ctx->regs.dp_write_mask);
+
+ R128CCE0(R128_CCE_PACKET0, R128_DST_PITCH_OFFSET_C, 1);
+ R128CCE(r128ctx->regs.dst_pitch_offset_c);
+ R128CCE(r128ctx->regs.dp_gui_master_cntl);
+
+ R128CCE0(R128_CCE_PACKET0, R128_TEXTURE_CLR_CMP_CLR_C, 1);
+ R128CCE(r128ctx->regs.texture_clr_cmp_clr_c);
+ R128CCE(r128ctx->regs.texture_clr_cmp_msk_c);
+
+ R128CCE0(R128_CCE_PACKET0, R128_STEN_REF_MASK_C, 1);
+ R128CCE(r128ctx->regs.sten_ref_mask_c);
+ R128CCE(r128ctx->regs.plane_3d_mask_c);
+ }
+
+ if (r128ctx->dirty_context & R128_CTX_ENGINESTATE) {
+ R128CCE0(R128_CCE_PACKET0, R128_TEX_CNTL_C, 0);
+ R128CCE(r128ctx->regs.tex_cntl_c);
+ }
+
+ if (r128ctx->dirty_context & R128_CTX_TEX0STATE) {
+ R128CCE0(R128_CCE_PACKET0, R128_PRIM_TEX_CNTL_C, 2+R128_TEX_MAXLEVELS);
+ R128CCE(r128ctx->regs.prim_tex_cntl_c);
+ R128CCE(r128ctx->regs.prim_texture_combine_cntl_c);
+ R128CCE(r128ctx->regs.tex_size_pitch_c);
+ for (i = 0; i < R128_TEX_MAXLEVELS; i++)
+ R128CCE(r128ctx->regs.prim_tex_offset[i]);
+
+ R128CCE0(R128_CCE_PACKET0, R128_PRIM_TEXTURE_BORDER_COLOR_C, 0);
+ R128CCE(r128ctx->regs.prim_texture_border_color_c);
+
+ tex_size_pitch_done = GL_TRUE;
+ }
+
+ if (r128ctx->dirty_context & R128_CTX_TEX1STATE) {
+ if (!tex_size_pitch_done) {
+ R128CCE0(R128_CCE_PACKET0, R128_TEX_SIZE_PITCH_C, 0);
+ R128CCE(r128ctx->regs.tex_size_pitch_c);
+ }
+
+ R128CCE0(R128_CCE_PACKET0, R128_SEC_TEX_CNTL_C, 1+R128_TEX_MAXLEVELS);
+ R128CCE(r128ctx->regs.sec_tex_cntl_c);
+ R128CCE(r128ctx->regs.sec_tex_combine_cntl_c);
+ for (i = 0; i < R128_TEX_MAXLEVELS; i++)
+ R128CCE(r128ctx->regs.sec_tex_offset[i]);
+
+ R128CCE0(R128_CCE_PACKET0, R128_SEC_TEXTURE_BORDER_COLOR_C, 0);
+ R128CCE(r128ctx->regs.sec_texture_border_color_c);
+ }
+
+ if (r128ctx->dirty_context & R128_CTX_TEXENVSTATE) {
+ R128CCE0(R128_CCE_PACKET0, R128_CONSTANT_COLOR_C, 0);
+ R128CCE(r128ctx->regs.constant_color_c);
+ }
+
+ if (r128ctx->dirty_context & R128_CTX_FOGSTATE) {
+ R128CCE0(R128_CCE_PACKET0, R128_FOG_3D_TABLE_START, 1);
+ R128CCE(r128ctx->regs.fog_3d_table_start);
+ R128CCE(r128ctx->regs.fog_3d_table_end);
+
+ R128CCE1(R128_CCE_PACKET1,
+ R128_FOG_COLOR_C, R128_FOG_3D_TABLE_DENSITY);
+ R128CCE(r128ctx->regs.fog_color_c);
+ R128CCE(r128ctx->regs.fog_3d_table_density);
+ }
+
+ if (r128ctx->dirty_context & R128_CTX_FOGTABLE) {
+ r128UploadFogTable(r128ctx);
+ }
+
+ if (r128ctx->dirty_context & R128_CTX_ZSTENSTATE) {
+ R128CCE0(R128_CCE_PACKET0, R128_Z_STEN_CNTL_C, 0);
+ R128CCE(r128ctx->regs.z_sten_cntl_c);
+ }
+
+ if (r128ctx->dirty_context & R128_CTX_SCISSORS) {
+ R128CCE0(R128_CCE_PACKET0, R128_SC_TOP_LEFT_C, 1);
+ R128CCE(r128ctx->regs.sc_top_left_c);
+ R128CCE(r128ctx->regs.sc_bottom_right_c);
+ }
+
+ if (r128ctx->dirty_context & (R128_CTX_ALPHASTATE |
+ R128_CTX_FOGSTATE)) {
+ R128CCE0(R128_CCE_PACKET0, R128_MISC_3D_STATE_CNTL_REG, 0);
+ R128CCE(r128ctx->regs.misc_3d_state_cntl_reg);
+ }
+
+ if (r128ctx->dirty_context & R128_CTX_SETUPSTATE) {
+ R128CCE1(R128_CCE_PACKET1, R128_SETUP_CNTL, R128_PM4_VC_FPU_SETUP);
+ R128CCE(r128ctx->regs.setup_cntl);
+ R128CCE(r128ctx->regs.pm4_vc_fpu_setup);
+ }
+
+ if (r128ctx->dirty_context & R128_CTX_WIN_Z_POS) {
+ R128CCE0(R128_CCE_PACKET0, R128_WINDOW_XY_OFFSET, 0);
+ R128CCE(r128ctx->regs.window_xy_offset);
+
+ R128CCE0(R128_CCE_PACKET0, R128_Z_OFFSET_C, 1);
+ R128CCE(r128ctx->regs.z_offset_c);
+ R128CCE(r128ctx->regs.z_pitch_c);
+ }
+
+#if 0
+ if (r128ctx->dirty_context & R128_CTX_FLUSH_PIX_CACHE) {
+ R128CCE0(R128_CCE_PACKET0, R128_PC_GUI_CTLSTAT, 0);
+ R128CCE(r128ctx->regs.pc_gui_ctlstat);
+ }
+#endif
+
+ R128CCE_SUBMIT_PACKETS();
+
+ /* Turn off the texture cache flushing */
+ r128ctx->regs.tex_cntl_c &= ~R128_TEX_CACHE_FLUSH;
+
+ /* Turn off the pixel cache flushing */
+ r128ctx->regs.pc_gui_ctlstat &= ~R128_PC_FLUSH_ALL;
+
+ r128ctx->dirty_context = R128_CTX_CLEAN;
+}
+
+/* Set the hardware clip rects for drawing to the current color buffer */
+/* NOTE: This function is only called while holding the hardware lock */
+void r128SetClipRects(r128ContextPtr r128ctx,
+ XF86DRIClipRectPtr pc, int nc)
+{
+ if (!pc) return;
+
+ /* Clear any previous auxiliary scissors */
+ r128ctx->regs.aux_sc_cntl = 0x00000000;
+
+ switch (nc) {
+ case 3:
+ R128CCE0(R128_CCE_PACKET0, R128_AUX3_SC_LEFT, 3);
+ R128CCE(pc[2].x1 + r128ctx->drawX);
+ R128CCE(pc[2].x2-1 + r128ctx->drawX);
+ R128CCE(pc[2].y1 + r128ctx->drawY);
+ R128CCE(pc[2].y2-1 + r128ctx->drawY);
+
+ r128ctx->regs.aux_sc_cntl |= R128_AUX3_SC_EN | R128_AUX3_SC_MODE_OR;
+
+ case 2:
+ R128CCE0(R128_CCE_PACKET0, R128_AUX2_SC_LEFT, 3);
+ R128CCE(pc[1].x1 + r128ctx->drawX);
+ R128CCE(pc[1].x2-1 + r128ctx->drawX);
+ R128CCE(pc[1].y1 + r128ctx->drawY);
+ R128CCE(pc[1].y2-1 + r128ctx->drawY);
+
+ r128ctx->regs.aux_sc_cntl |= R128_AUX2_SC_EN | R128_AUX2_SC_MODE_OR;
+
+ case 1:
+ R128CCE0(R128_CCE_PACKET0, R128_AUX1_SC_LEFT, 3);
+ R128CCE(pc[0].x1 + r128ctx->drawX);
+ R128CCE(pc[0].x2-1 + r128ctx->drawX);
+ R128CCE(pc[0].y1 + r128ctx->drawY);
+ R128CCE(pc[0].y2-1 + r128ctx->drawY);
+
+ r128ctx->regs.aux_sc_cntl |= R128_AUX1_SC_EN | R128_AUX1_SC_MODE_OR;
+ break;
+
+ default:
+ return;
+ }
+
+ R128CCE0(R128_CCE_PACKET0, R128_AUX_SC_CNTL, 0);
+ R128CCE(r128ctx->regs.aux_sc_cntl);
+
+ R128CCE_SUBMIT_PACKETS();
+}
+
+/* Update the driver's notion of the window position */
+/* NOTE: This function is only called while holding the hardware lock */
+static void r128UpdateWindowPosition(r128ContextPtr r128ctx)
+{
+ int x = r128ctx->driDrawable->x + r128ctx->drawX;
+ int y = r128ctx->driDrawable->y + r128ctx->drawY;
+
+#if 0
+ /* FIXME: Is this _really_ needed? */
+ R128CCE_FLUSH_VB(r128ctx);
+#endif
+ r128ctx->regs.window_xy_offset = ((y << R128_WINDOW_Y_SHIFT) |
+ (x << R128_WINDOW_X_SHIFT));
+
+ /* Recalculate the Z buffer offset since we might be drawing to the
+ back buffer and window_xy_offset affects both color buffer and
+ depth drawing */
+ r128ctx->regs.z_offset_c = ((r128ctx->r128Screen->depthX -
+ r128ctx->drawX) *
+ (r128ctx->r128Screen->bpp/8) +
+ (r128ctx->r128Screen->depthY -
+ r128ctx->drawY) *
+ r128ctx->r128Screen->fbStride);
+
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_WIN_Z_POS;
+}
+
+/* Update the hardware state */
+/* NOTE: This function is only called while holding the hardware lock */
+static void r128UpdateHWStateLocked(r128ContextPtr r128ctx)
+{
+ if (r128ctx->dirty & R128_REQUIRE_QUIESCENCE)
+ R128CCE_WAIT_FOR_IDLE(r128ctx);
+
+ /* Update any state that might have changed recently */
+
+ /* Update the clip rects */
+ if (r128ctx->dirty & R128_UPDATE_WINPOS)
+ r128UpdateWindowPosition(r128ctx);
+
+ /* Update texture state and then upload the images */
+ /* Note: Texture images can only be updated after the state has been set */
+ if (r128ctx->dirty & R128_UPDATE_TEXSTATE)
+ r128UpdateTextureState(r128ctx);
+ if (r128ctx->dirty & R128_UPDATE_TEX0IMAGES)
+ r128UploadTexImages(r128ctx, r128ctx->CurrentTexObj[0]);
+ if (r128ctx->dirty & R128_UPDATE_TEX1IMAGES)
+ r128UploadTexImages(r128ctx, r128ctx->CurrentTexObj[1]);
+
+ /* Load the state into the hardware */
+ /* Note: This must be done after all other state has been set */
+ if (r128ctx->dirty & R128_UPDATE_CONTEXT)
+ r128LoadContext(r128ctx);
+
+ r128ctx->dirty = R128_CLEAN;
+}
+
+/* Update the hardware state */
+void r128UpdateHWState(r128ContextPtr r128ctx)
+{
+ LOCK_HARDWARE(r128ctx);
+ r128UpdateHWStateLocked(r128ctx);
+ UNLOCK_HARDWARE(r128ctx);
+}
+
+/* Update the driver's state */
+/* NOTE: This function is only called while holding the hardware lock */
+void r128UpdateState(r128ContextPtr r128ctx, int winMoved)
+{
+ R128SAREAPrivPtr sarea = r128ctx->r128Screen->SAREA;
+ int i;
+
+ if (sarea->ctxOwner != r128ctx->driContext->hHWContext) {
+ sarea->ctxOwner = r128ctx->driContext->hHWContext;
+ r128ctx->dirty_context = R128_CTX_ALL_DIRTY;
+ r128LoadContext(r128ctx);
+ }
+
+ for (i = 0; i < r128ctx->r128Screen->NRTexHeaps; i++)
+ r128AgeTextures(r128ctx, i);
+
+ if (winMoved) r128ctx->dirty |= R128_UPDATE_WINPOS;
+}
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..f847452f0
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_state.h
@@ -0,0 +1,50 @@
+/* $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, int winMoved);
+extern void r128UpdateHWState(r128ContextPtr r128ctx);
+
+extern void r128SetClipRects(r128ContextPtr r128ctx,
+ XF86DRIClipRectPtr pc, int nc);
+
+#endif
+#endif /* _R128_STATE_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_swap.c b/xc/lib/GL/mesa/src/drv/r128/r128_swap.c
new file mode 100644
index 000000000..6b347023d
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_swap.c
@@ -0,0 +1,125 @@
+/* $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_reg.h"
+#include "r128_cce.h"
+#include "r128_state.h"
+#include "r128_vb.h"
+#include "r128_swap.h"
+
+/* Copy the back color buffer to the front color buffer */
+void r128SwapBuffers(r128ContextPtr r128ctx)
+{
+ unsigned char *R128MMIO = r128ctx->r128Screen->mmio;
+ __DRIdrawablePrivate *dPriv = r128ctx->driDrawable;
+ int nc;
+ XF86DRIClipRectPtr c;
+ int dst_bpp;
+ CARD32 swapAge;
+
+ if (r128ctx->SWonly) {
+ /* FIXME: Provide software fallback for this case?? */
+ }
+
+ switch (r128ctx->r128Screen->bpp) {
+ case 8:
+ dst_bpp = R128_GMC_DST_8BPP_CI;
+ break;
+ case 16:
+ if (r128ctx->r128Screen->depth == 15) dst_bpp = R128_GMC_DST_15BPP;
+ else dst_bpp = R128_GMC_DST_16BPP;
+ break;
+ case 24:
+ dst_bpp = R128_GMC_DST_24BPP;
+ break;
+ case 32:
+ default:
+ dst_bpp = R128_GMC_DST_32BPP;
+ break;
+ }
+
+ LOCK_HARDWARE(r128ctx);
+
+ /* Flush any outstanding vertex buffers */
+ R128CCE_FLUSH_VB(r128ctx);
+
+ /* Throttle the frame rate -- only allow one pending swap buffers
+ request at a time */
+ while (r128ctx->lastSwapAge > (swapAge = INREG(R128_SWAP_AGE_REG)));
+
+ /* Init the clip rects here in case they changed during the
+ LOCK_HARDWARE macro */
+ c = dPriv->pClipRects;
+ nc = dPriv->numClipRects;
+
+ /* Cycle through the clip rects */
+ while (nc--) {
+ int fx = c[nc].x1;
+ int fy = c[nc].y1;
+ int fw = c[nc].x2 - fx;
+ int fh = c[nc].y2 - fy;
+ int bx = fx + r128ctx->r128Screen->backX;
+ int by = fy + r128ctx->r128Screen->backY;
+
+ fx += r128ctx->r128Screen->fbX;
+ fy += r128ctx->r128Screen->fbY;
+
+ R128CCE3(R128_CCE_PACKET3_CNTL_BITBLT_MULTI, 3);
+ R128CCE(R128_GMC_BRUSH_NONE
+ | R128_GMC_SRC_DATATYPE_COLOR
+ | R128_DP_SRC_SOURCE_MEMORY
+ | dst_bpp
+ | R128_ROP3_S);
+ R128CCE((bx << 16) | by);
+ R128CCE((fx << 16) | fy);
+ R128CCE((fw << 16) | fh);
+ }
+
+ ++swapAge;
+ R128CCE0(R128_CCE_PACKET0, R128_SWAP_AGE_REG, 0);
+ R128CCE(swapAge);
+ r128ctx->lastSwapAge = swapAge;
+
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_ALL_DIRTY;
+
+ R128CCE_SUBMIT_PACKETS();
+
+ UNLOCK_HARDWARE(r128ctx);
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_swap.h b/xc/lib/GL/mesa/src/drv/r128/r128_swap.h
new file mode 100644
index 000000000..32851041c
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_swap.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_SWAP_H_
+#define _R128_SWAP_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void r128SwapBuffers(r128ContextPtr r128ctx);
+
+#endif
+#endif /* _R128_SWAP_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..6a82a527e
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tex.c
@@ -0,0 +1,1852 @@
+/* $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>
+ * Gareth Hughes <gareth@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"
+#include "r128_cce.h"
+#include "r128_vb.h"
+#include "r128_tex.h"
+
+#include "mmath.h"
+#include "simple_list.h"
+
+static void r128SetTexWrap(r128TexObjPtr t, GLenum srwap, GLenum twrap);
+static void r128SetTexFilter(r128TexObjPtr t, GLenum minf, GLenum magf);
+static void r128SetTexBorderColor(r128TexObjPtr t, GLubyte c[4]);
+
+/* Allocate and initialize hardware state associated with texture `t' */
+/* NOTE: This function is only called while holding the hardware lock */
+static r128TexObjPtr r128CreateTexObj(r128ContextPtr r128ctx,
+ struct gl_texture_object *tObj)
+{
+ r128TexObjPtr t;
+ struct gl_texture_image *image;
+ int log2Pitch, log2Height, log2Size, log2MinSize;
+ int totalSize;
+ int i;
+
+ image = tObj->Image[0];
+ if (!image) return NULL; /* ERROR!!! */
+
+ t = (r128TexObjPtr)calloc(1,sizeof(*t));
+ if (!t) return NULL; /* ERROR!!! */
+
+ if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API)
+ fprintf(stderr, "r128CreateTexObj(%p)\n", tObj);
+
+ switch (image->Format) {
+ case GL_RGBA:
+ case GL_ALPHA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ if (r128ctx->r128Screen->bpp == 32) {
+ t->texelBytes = 4;
+ t->textureFormat = R128_DATATYPE_ARGB8888;
+ } else {
+ t->texelBytes = 2;
+ t->textureFormat = R128_DATATYPE_ARGB4444;
+ }
+ break;
+
+ case GL_RGB:
+ if (r128ctx->r128Screen->bpp == 32) {
+ t->texelBytes = 4;
+ t->textureFormat = R128_DATATYPE_ARGB8888;
+ } else {
+ t->texelBytes = 2;
+ t->textureFormat = R128_DATATYPE_RGB565;
+ }
+ break;
+
+ case GL_LUMINANCE:
+ if (r128ctx->r128Screen->bpp == 32) {
+ t->texelBytes = 4;
+ t->textureFormat = R128_DATATYPE_ARGB8888;
+ } else {
+ t->texelBytes = 2;
+ /* Use this to get true greys */
+ t->textureFormat = R128_DATATYPE_ARGB1555;
+ }
+ break;
+
+ case GL_COLOR_INDEX:
+ t->texelBytes = 1;
+ t->textureFormat = R128_DATATYPE_CI8;
+ break;
+
+ default:
+ /* ERROR!!! */
+ fprintf(stderr, "r128CreateTexObj: bad image->Format\n");
+ free(t);
+ return NULL;
+ }
+
+ /* Calculate dimensions in log domain */
+ for (i = 1, log2Height = 0; i < image->Height; i *= 2) log2Height++;
+ for (i = 1, log2Pitch = 0; i < image->Width; i *= 2) log2Pitch++;
+ if (image->Width > image->Height) log2Size = log2Pitch;
+ else log2Size = log2Height;
+
+ t->dirty_images = 0;
+
+ /* Calculate mipmap offsets and dimensions */
+ totalSize = 0;
+ for (i = 0; i <= log2Size && tObj->Image[i]; i++) {
+ t->image[i].offset = totalSize;
+ t->image[i].width = tObj->Image[i]->Width;
+ t->image[i].height = tObj->Image[i]->Height;
+ t->dirty_images |= 1 << i;
+ totalSize += (tObj->Image[i]->Height *
+ tObj->Image[i]->Width *
+ t->texelBytes);
+
+ /* Offsets must be 32-byte aligned for host data blits */
+ totalSize = (totalSize + 31) & ~31;
+ }
+ log2MinSize = log2Size - i + 1;
+
+ t->totalSize = totalSize;
+ t->internFormat = image->IntFormat;
+
+ t->bound = 0;
+ t->heap = 0; /* This is set in r128UploadTexImages */
+ t->tObj = tObj;
+
+ t->memBlock = NULL;
+ t->bufAddr = NULL;
+
+ t->regs.tex_cntl = t->textureFormat;
+ t->regs.size_pitch = ((log2Pitch << R128_TEX_PITCH_SHIFT) |
+ (log2Size << R128_TEX_SIZE_SHIFT) |
+ (log2Height << R128_TEX_HEIGHT_SHIFT) |
+ (log2MinSize << R128_TEX_MIN_SIZE_SHIFT));
+ t->regs.border_color = 0x00000000;
+
+ if (log2MinSize == log2Size ||
+ log2MinSize != 0)
+ t->regs.tex_cntl |= R128_MIP_MAP_DISABLE;
+
+ r128SetTexWrap(t, tObj->WrapS, tObj->WrapT);
+ r128SetTexFilter(t, tObj->MinFilter, tObj->MagFilter);
+ r128SetTexBorderColor(t, tObj->BorderColor);
+
+ tObj->DriverData = t;
+
+ make_empty_list(t);
+
+ return t;
+}
+
+/* Destroy hardware state associated with texture `t' */
+/* NOTE: This function can be called while holding the hardware lock and
+ while not holding the lock*/
+void r128DestroyTexObj(r128ContextPtr r128ctx, r128TexObjPtr t)
+{
+ if (!t) return;
+
+ if (t->memBlock) {
+ mmFreeMem(t->memBlock);
+ t->memBlock = NULL;
+ }
+
+ if (t->tObj) t->tObj->DriverData = NULL;
+ if (t->bound) r128ctx->CurrentTexObj[t->bound-1] = NULL;
+
+ remove_from_list(t);
+ free(t);
+}
+
+/* Keep track of swapped out texture objects */
+/* NOTE: This function is only called while holding the hardware lock */
+static void r128SwapOutTexObj(r128ContextPtr r128ctx, r128TexObjPtr t)
+{
+ if (t->memBlock) {
+ mmFreeMem(t->memBlock);
+ t->memBlock = NULL;
+ }
+
+ t->dirty_images = ~0;
+ move_to_tail(&r128ctx->SwappedOut, t);
+}
+
+/* Print out debugging information about texture LRU */
+void r128PrintLocalLRU(r128ContextPtr r128ctx, int heap)
+{
+ r128TexObjPtr t;
+ int sz = 1 << (r128ctx->r128Screen->log2TexGran[heap]);
+
+ foreach(t, &r128ctx->TexObjList[heap]) {
+ if (!t->tObj) {
+ fprintf(stderr, "Placeholder %d at 0x%x sz 0x%x\n",
+ t->memBlock->ofs / sz,
+ t->memBlock->ofs,
+ t->memBlock->size);
+ } else {
+ fprintf(stderr, "Texture (bound %d) at 0x%x sz 0x%x\n",
+ t->bound,
+ t->memBlock->ofs,
+ t->memBlock->size);
+ }
+ }
+}
+
+void r128PrintGlobalLRU(r128ContextPtr r128ctx, int heap)
+{
+ R128TexRegion *list = r128ctx->r128Screen->SAREA->texList[heap];
+ int i, j;
+
+ for (i = 0, j = R128_NR_TEX_REGIONS ; i < R128_NR_TEX_REGIONS ; i++) {
+ fprintf(stderr, "list[%d] age %d next %d prev %d\n",
+ j, list[j].age, list[j].next, list[j].prev);
+ j = list[j].next;
+ if (j == R128_NR_TEX_REGIONS) break;
+ }
+
+ if (j != R128_NR_TEX_REGIONS) {
+ fprintf(stderr, "Loop detected in global LRU\n");
+ }
+}
+
+/* Reset the global texture LRU */
+/* NOTE: This function is only called while holding the hardware lock */
+static void r128ResetGlobalLRU(r128ContextPtr r128ctx, int heap)
+{
+ R128TexRegion *list = r128ctx->r128Screen->SAREA->texList[heap];
+ int log2sz = 1 << r128ctx->r128Screen->log2TexGran[heap];
+ int i;
+
+ /*
+ * (Re)initialize the global circular LRU list. The last element in
+ * the array (R128_NR_TEX_REGIONS) is the sentinal. Keeping it at
+ * the end of the array allows it to be addressed rationally when
+ * looking up objects at a particular location in texture memory.
+ */
+
+ for (i = 0; (i+1) * log2sz <= r128ctx->r128Screen->texSize[heap]; i++) {
+ list[i].prev = i-1;
+ list[i].next = i+1;
+ list[i].age = 0;
+ }
+
+ i--;
+ list[0].prev = R128_NR_TEX_REGIONS;
+ list[i].prev = i-1;
+ list[i].next = R128_NR_TEX_REGIONS;
+ list[R128_NR_TEX_REGIONS].prev = i;
+ list[R128_NR_TEX_REGIONS].next = 0;
+ r128ctx->r128Screen->SAREA->texAge[heap] = 0;
+}
+
+/* Update the local and glock texture LRUs */
+/* NOTE: This function is only called while holding the hardware lock */
+static void r128UpdateTexLRU(r128ContextPtr r128ctx, r128TexObjPtr t)
+{
+ int heap = t->heap;
+ R128TexRegion *list = r128ctx->r128Screen->SAREA->texList[heap];
+ int log2sz = r128ctx->r128Screen->log2TexGran[heap];
+
+ int start = t->memBlock->ofs >> log2sz;
+ int end = (t->memBlock->ofs + t->memBlock->size-1) >> log2sz;
+ int i;
+
+ r128ctx->lastTexAge[heap] = ++r128ctx->r128Screen->SAREA->texAge[heap];
+
+ /* Update our local LRU */
+ move_to_head(&r128ctx->TexObjList[heap], t);
+
+ /* Update the global LRU */
+ for (i = start ; i <= end ; i++) {
+ list[i].in_use = 1;
+ list[i].age = r128ctx->lastTexAge[heap];
+
+ /* remove_from_list(i) */
+ list[(CARD32)list[i].next].prev = list[i].prev;
+ list[(CARD32)list[i].prev].next = list[i].next;
+
+ /* insert_at_head(list, i) */
+ list[i].prev = R128_NR_TEX_REGIONS;
+ list[i].next = list[R128_NR_TEX_REGIONS].next;
+ list[(CARD32)list[R128_NR_TEX_REGIONS].next].prev = i;
+ list[R128_NR_TEX_REGIONS].next = i;
+ }
+}
+
+/* Update our notion of what textures have been changed since we last
+ held the lock. This pertains to both our local textures and the
+ textures belonging to other clients. Keep track of other client's
+ textures by pushing a placeholder texture onto the LRU list -- these
+ are denoted by (tObj == NULL). */
+/* NOTE: This function is only called while holding the hardware lock */
+static void r128TexturesGone(r128ContextPtr r128ctx, int heap,
+ int offset, int size, int in_use)
+{
+ r128TexObjPtr t, tmp;
+
+ foreach_s (t, tmp, &r128ctx->TexObjList[heap]) {
+ if (t->memBlock->ofs >= offset + size ||
+ t->memBlock->ofs + t->memBlock->size <= offset)
+ continue;
+
+ /* It overlaps - kick it out. Need to hold onto the currently
+ bound objects, however. */
+ if (t->bound) r128SwapOutTexObj(r128ctx, t);
+ else r128DestroyTexObj(r128ctx, t);
+ }
+
+ if (in_use) {
+ t = (r128TexObjPtr) calloc(1,sizeof(*t));
+ if (!t) return;
+
+ t->memBlock = mmAllocMem(r128ctx->texHeap[heap], size, 0, offset);
+ insert_at_head(&r128ctx->TexObjList[heap], t);
+ }
+}
+
+/* Update our client's shared texture state. If another client has
+ modified a region in which we have textures, then we need to figure
+ out which of our textures has been removed, and update our global
+ LRU. */
+void r128AgeTextures(r128ContextPtr r128ctx, int heap)
+{
+ R128SAREAPrivPtr sarea = r128ctx->r128Screen->SAREA;
+
+ if (sarea->texAge[heap] != r128ctx->lastTexAge[heap]) {
+ int log2sz = 1 << r128ctx->r128Screen->log2TexGran[heap];
+ int nr = 0;
+ int idx;
+
+ for (idx = sarea->texList[heap][R128_NR_TEX_REGIONS].prev;
+ idx != R128_NR_TEX_REGIONS && nr < R128_NR_TEX_REGIONS;
+ idx = sarea->texList[heap][idx].prev, nr++) {
+
+ /* If switching texturing schemes, then the SAREA might not
+ have been properly cleared, so we need to reset the
+ global texture LRU. */
+ if (idx * log2sz > r128ctx->r128Screen->texSize[heap]) {
+ nr = R128_NR_TEX_REGIONS;
+ break;
+ }
+
+ if (sarea->texList[heap][idx].age > r128ctx->lastTexAge[heap])
+ r128TexturesGone(r128ctx, heap, idx * log2sz, log2sz,
+ sarea->texList[heap][idx].in_use);
+ }
+
+ if (nr == R128_NR_TEX_REGIONS) {
+ r128TexturesGone(r128ctx, heap,
+ 0, r128ctx->r128Screen->texSize[heap], 0);
+ r128ResetGlobalLRU(r128ctx, heap);
+ }
+
+ r128ctx->dirty |= R128_UPDATE_TEX0IMAGES;
+ r128ctx->dirty |= R128_UPDATE_TEX1IMAGES;
+ r128ctx->lastTexAge[heap] = sarea->texAge[heap];
+ }
+}
+
+/* Convert a block of Mesa-formatted texture to an 8bpp hardware format */
+static void r128ConvertTexture8bpp(r128ContextPtr r128ctx,
+ struct gl_texture_image *image,
+ int x, int y, int width, int height,
+ int pitch)
+{
+ CARD8 *src;
+ CARD32 pix;
+ int i, j;
+
+ switch (image->Format) {
+ case GL_RGB:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3;
+ for (j = width >> 2; j; j--) {
+ pix = ((R128PACKCOLOR332( src[0], src[1], src[2]) ) |
+ (R128PACKCOLOR332( src[3], src[4], src[5]) << 8) |
+ (R128PACKCOLOR332( src[6], src[7], src[8]) << 16) |
+ (R128PACKCOLOR332( src[9], src[10], src[11]) << 24));
+ R128CCE(pix);
+ src += 12;
+ }
+ }
+ break;
+
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_INTENSITY:
+ case GL_COLOR_INDEX:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+ for (j = width >> 2; j; j--) {
+ pix = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
+ R128CCE(pix);
+ src += 4;
+ }
+ }
+ break;
+
+ default:
+ fprintf(stderr, "r128ConvertTexture8bpp: unsupported format 0x%x\n",
+ image->Format);
+ }
+}
+
+/* Convert a block of Mesa-formatted texture to a 16bpp hardware format */
+static void r128ConvertTexture16bpp(r128ContextPtr r128ctx,
+ struct gl_texture_image *image,
+ int x, int y, int width, int height,
+ int pitch)
+{
+ CARD8 *src;
+ CARD32 pix;
+ int i, j;
+
+ switch (image->Format) {
+ case GL_RGB:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3;
+ for (j = width >> 1; j; j--) {
+ pix = ((R128PACKCOLOR565(src[0], src[1], src[2]) ) |
+ (R128PACKCOLOR565(src[3], src[4], src[5]) << 16));
+ R128CCE(pix);
+ src += 6;
+ }
+ }
+ break;
+
+ case GL_RGBA:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 4;
+ for (j = width >> 1; j; j--) {
+ pix =
+ ((R128PACKCOLOR4444(src[0], src[1], src[2], src[3]) ) |
+ (R128PACKCOLOR4444(src[4], src[5], src[6], src[7])<<16));
+ R128CCE(pix);
+ src += 8;
+ }
+ }
+ break;
+
+ case GL_ALPHA:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+ for (j = width >> 1; j; j--) {
+ pix = ((R128PACKCOLOR4444(0xff, 0xff, 0xff, src[0]) ) |
+ (R128PACKCOLOR4444(0xff, 0xff, 0xff, src[1]) << 16));
+ R128CCE(pix);
+ src += 2;
+ }
+ }
+ break;
+
+ case GL_LUMINANCE:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+ for (j = width >> 1; j; j--) {
+ pix = ((R128PACKCOLOR1555(src[0], src[0], src[0], 0xff) ) |
+ (R128PACKCOLOR1555(src[1], src[1], src[1], 0xff)<<16));
+ R128CCE(pix);
+ src += 2;
+ }
+ }
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 2;
+ for (j = width >> 1; j; j--) {
+ pix =
+ ((R128PACKCOLOR4444(src[0], src[0], src[0], src[1]) ) |
+ (R128PACKCOLOR4444(src[2], src[2], src[2], src[3])<<16));
+ R128CCE(pix);
+ src += 4;
+ }
+ }
+ break;
+
+ case GL_INTENSITY:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+ for (j = width >> 1; j; j--) {
+ pix =
+ ((R128PACKCOLOR4444(src[0], src[0], src[0], src[0]) ) |
+ (R128PACKCOLOR4444(src[1], src[1], src[1], src[1])<<16));
+ R128CCE(pix);
+ src += 2;
+ }
+ }
+ break;
+
+ default:
+ fprintf(stderr, "r128ConvertTexture16bpp: unsupported format 0x%x\n",
+ image->Format);
+ }
+}
+
+/* Convert a block of Mesa-formatted texture to a 32bpp hardware format */
+static void r128ConvertTexture32bpp(r128ContextPtr r128ctx,
+ struct gl_texture_image *image,
+ int x, int y, int width, int height,
+ int pitch)
+{
+ CARD8 *src;
+ CARD32 pix;
+ int i, j;
+
+ switch (image->Format) {
+ case GL_RGB:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3;
+ for (j = width; j; j--) {
+ pix = R128PACKCOLOR8888(src[0], src[1], src[2], 0xff);
+ R128CCE(pix);
+ src += 3;
+ }
+ }
+ break;
+
+ case GL_RGBA:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 4;
+ for (j = width; j; j--) {
+ pix = R128PACKCOLOR8888(src[0], src[1], src[2], src[3]);
+ R128CCE(pix);
+ src += 4;
+ }
+ }
+ break;
+
+ case GL_ALPHA:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+ for (j = width; j; j--) {
+ pix = R128PACKCOLOR8888(0xff, 0xff, 0xff, src[0]);
+ R128CCE(pix);
+ src += 1;
+ }
+ }
+ break;
+
+ case GL_LUMINANCE:
+ for (i = 0 ; i < height ; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+ for (j = width; j; j--) {
+ pix = R128PACKCOLOR8888(src[0], src[0], src[0], 0xff);
+ R128CCE(pix);
+ src += 1;
+ }
+ }
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 2;
+ for (j = width; j; j-- ) {
+ pix = R128PACKCOLOR8888(src[0], src[0], src[0], src[1]);
+ R128CCE(pix);
+ src += 2;
+ }
+ }
+ break;
+
+ case GL_INTENSITY:
+ for (i = 0; i < height; i++) {
+ src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+ for (j = width; j; j--) {
+ pix = R128PACKCOLOR8888(src[0], src[0], src[0], src[0]);
+ R128CCE(pix);
+ src += 1;
+ }
+ }
+ break;
+
+ default:
+ fprintf(stderr, "r128ConvertTexture32bpp: unsupported format 0x%x\n",
+ image->Format);
+ }
+}
+
+/* Upload the texture image associated with texture `t' at level `level'
+ at the address relative to `start'. */
+/* NOTE: This function is only called while holding the hardware lock */
+static void r128UploadSubImage(r128ContextPtr r128ctx,
+ r128TexObjPtr t, int level,
+ int x, int y, int width, int height)
+{
+ struct gl_texture_image *image;
+ int texelsPerDword = 0;
+ int imageWidth, imageHeight;
+ int remaining, rows;
+ int format, pitch, dwords;
+ CARD32 offset;
+
+ /* Ensure we have a valid texture to upload */
+ if (level < 0 || level > R128_TEX_MAXLEVELS) return;
+ if (!(image = t->tObj->Image[level])) return;
+
+ /* FIXME: support RGB888 (i.e., 24bpp) textures? */
+ switch (t->texelBytes) {
+ case 1: texelsPerDword = 4; break;
+ case 2: texelsPerDword = 2; break;
+ case 4: texelsPerDword = 1; break;
+ }
+
+ imageWidth = image->Width;
+ imageHeight = image->Height;
+
+ format = t->textureFormat >> 16;
+
+ /* The texel upload routines have a minimum width, so force the size
+ if needed */
+ if (imageWidth < texelsPerDword) {
+ int factor;
+
+ factor = texelsPerDword / imageWidth;
+ imageWidth = texelsPerDword;
+ imageHeight /= factor;
+ if (imageHeight == 0) {
+ /* In this case, the texel converter will actually walk a
+ texel or two off the end of the image, but normal malloc
+ alignment should prevent it from ever causing a fault. */
+ imageHeight = 1;
+ }
+ }
+
+ /* We can't upload to a pitch less than 8 texels so we will need to
+ linearly upload all modified rows for textures smaller than this.
+ This makes the x/y/width/height different for the blitter and the
+ texture walker. */
+ if (imageWidth >= 8) {
+ /* The texture walker and the blitter look identical */
+ pitch = imageWidth >> 3;
+ } else {
+ int factor;
+ int y2;
+ int start, end;
+
+ start = (y * imageWidth) & ~7;
+ end = (y + height) * imageWidth;
+
+ if (end - start < 8) {
+ /* Handle the case where the total number of texels uploaded
+ is < 8 */
+ x = 0;
+ y = start / 8;
+ width = end - start;
+ height = 1;
+ } else {
+ /* Upload some number of full 8 texel blit rows */
+ factor = 8 / imageWidth;
+
+ y2 = y + height - 1;
+ y /= factor;
+ y2 /= factor;
+
+ x = 0;
+ width = 8;
+ height = y2 - y + 1;
+ }
+
+ /* Fixed pitch of 8 */
+ pitch = 1;
+ }
+
+ dwords = width * height / texelsPerDword;
+ offset = (CARD32)(t->bufAddr + t->image[level].offset);
+
+ /* Fix offset for AGP textures */
+ if (t->heap == R128_AGP_TEX_HEAP)
+ offset += R128_AGP_TEX_OFFSET + r128ctx->r128Screen->agpTexOffset;
+
+ if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) {
+ fprintf(stderr, "r128UploadSubImage: %d,%d of %d,%d at %d,%d\n",
+ width, height, image->Width, image->Height, x, y);
+ fprintf(stderr, " blit ofs: 0x%08x pitch: 0x%x dwords: %d "
+ "level: %d format: %x\n",
+ (int)offset, pitch, dwords, level, format);
+ }
+
+#define R128_MAX_BLIT_DWORDS 8192
+ /* Subdivide the texture if required */
+ if (dwords < R128_MAX_BLIT_DWORDS) {
+ rows = height;
+ } else {
+ rows = (R128_MAX_BLIT_DWORDS * texelsPerDword) / (2 * width);
+ }
+
+ /* Flush the pixel cache, and mark the contents as Read Invalid */
+ R128CCE0(R128_CCE_PACKET0, R128_PC_GUI_CTLSTAT, 0);
+ R128CCE(r128ctx->regs.pc_gui_ctlstat |
+ R128_PC_RI_GUI |
+ R128_PC_FLUSH_GUI);
+ R128CCE_SUBMIT_PACKETS();
+
+ /* Build the CCE host data blit header */
+ R128CCE3(R128_CCE_PACKET3_CNTL_HOSTDATA_BLT, 0);
+
+ /* DP_GUI_MASTER_CNTL */
+ R128CCE(R128_GMC_DST_PITCH_OFFSET_CNTL |
+ R128_GMC_BRUSH_NONE |
+ (format << 8) |
+ R128_GMC_SRC_DATATYPE_COLOR |
+ R128_ROP3_S |
+ R128_DP_SRC_SOURCE_HOST_DATA |
+ R128_GMC_CLR_CMP_CNTL_DIS |
+ R128_AUX_CLIP_DIS |
+ R128_GMC_WR_MSK_DIS );
+
+ /* DST_OFFSET_PITCH - fixed at the moment until we get better ring
+ control */
+ R128CCE((pitch << 21) | (offset>>5));
+
+ /* FRGD_COLOR, BKGD_COLOR */
+ R128CCE(0xffffffff);
+ R128CCE(0xffffffff);
+
+ for (remaining = height; remaining > 0; remaining -= rows, y += rows) {
+ height = (remaining >= rows) ? rows : remaining;
+ dwords = width * height / texelsPerDword;
+
+ if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) {
+ fprintf(stderr, " blitting: %d,%d at %d,%d - %d dwords\n",
+ width, height, x, y, dwords);
+ }
+
+ r128ctx->CCEbuf[0] &= ~R128_CCE_PACKET_COUNT_MASK;
+ r128ctx->CCEbuf[0] |= (dwords + 6) << 16;
+
+ /* Blit coords, size */
+ R128CCE((y << 16) | x);
+ R128CCE((height << 16) | width);
+ R128CCE(dwords);
+
+ /* Actually do the texture conversion */
+ switch (t->texelBytes) {
+ case 1:
+ r128ConvertTexture8bpp(r128ctx, image,
+ x, y, width, height, width);
+ break;
+ case 2:
+ r128ConvertTexture16bpp(r128ctx, image,
+ x, y, width, height, width);
+ break;
+ case 4:
+ r128ConvertTexture32bpp(r128ctx,
+ image, x, y, width, height, width);
+ break;
+ }
+
+ /* Flush the pixel cache */
+ R128CCE0(R128_CCE_PACKET0, R128_PC_GUI_CTLSTAT, 0 );
+ R128CCE(r128ctx->regs.pc_gui_ctlstat | R128_PC_FLUSH_GUI);
+
+ /* Save the partial blit header */
+ R128CCE_SUBMIT_PACKETS();
+ r128ctx->CCEcount = 5;
+ }
+
+ /* Clean up CCE ring buffer */
+ r128ctx->CCEcount = 0;
+}
+
+/* Upload the texture images associated with texture `t'. This might
+ require removing our own and/or other client's texture objects to
+ make room for these images. */
+/* NOTE: This function is only called while holding the hardware lock */
+int r128UploadTexImages(r128ContextPtr r128ctx, r128TexObjPtr t)
+{
+ int i;
+ int minLevel;
+ int maxLevel;
+ int heap;
+
+ if (!t) return 0;
+
+ /* Choose the heap appropriately */
+ heap = t->heap = R128_LOCAL_TEX_HEAP;
+ if (!r128ctx->r128Screen->IsPCI &&
+ t->totalSize > r128ctx->r128Screen->texSize[heap])
+ heap = t->heap = R128_AGP_TEX_HEAP;
+
+ /* Do we need to eject LRU texture objects? */
+ if (!t->memBlock) {
+ /* Allocate a memory block on a 4k boundary (1<<12 == 4096) */
+ t->memBlock = mmAllocMem(r128ctx->texHeap[heap], t->totalSize, 12, 0);
+
+ /* Try AGP before kicking anything out of local mem */
+ if (!t->memBlock && heap == R128_LOCAL_TEX_HEAP) {
+ t->memBlock = mmAllocMem(r128ctx->texHeap[R128_AGP_TEX_HEAP],
+ t->totalSize, 12, 0);
+
+ if (t->memBlock) heap = t->heap = R128_AGP_TEX_HEAP;
+ }
+
+ /* Kick out textures until the requested texture fits */
+ while (!t->memBlock) {
+ if (r128ctx->TexObjList[heap].prev->bound) {
+ fprintf(stderr,
+ "r128UploadTexImages: ran into bound texture\n");
+ return -1;
+ }
+ if (r128ctx->TexObjList[heap].prev ==
+ &(r128ctx->TexObjList[heap])) {
+ if (r128ctx->r128Screen->IsPCI) {
+ fprintf(stderr, "r128UploadTexImages: upload texture "
+ "failure on local texture heaps, sz=%d\n",
+ t->totalSize);
+ return -1;
+ } else if (heap == R128_LOCAL_TEX_HEAP) {
+ heap = t->heap = R128_AGP_TEX_HEAP;
+ continue;
+ } else {
+ fprintf(stderr, "r128UploadTexImages: upload texture "
+ "failure on both local and AGP texture heaps, "
+ "sz=%d\n",
+ t->totalSize);
+ return -1;
+ }
+ }
+
+ r128DestroyTexObj(r128ctx, r128ctx->TexObjList[heap].prev);
+
+ t->memBlock = mmAllocMem(r128ctx->texHeap[heap],
+ t->totalSize, 12, 0);
+ }
+
+ /* Set the base offset of the texture image */
+ t->bufAddr = (unsigned char *)r128ctx->r128Screen->texOffset[heap];
+ t->bufAddr += t->memBlock->ofs;
+
+ maxLevel = ((t->regs.size_pitch & R128_TEX_SIZE_MASK) >>
+ R128_TEX_SIZE_SHIFT);
+ minLevel = ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >>
+ R128_TEX_MIN_SIZE_SHIFT);
+
+ /* Update the hardware's texture image addresses */
+ switch (t->bound) {
+ case 1:
+ /* Set texture offsets */
+ if (t->regs.tex_cntl & R128_MIP_MAP_DISABLE) {
+ for (i = 0; i < R128_TEX_MAXLEVELS; i++)
+ r128ctx->regs.prim_tex_offset[i] = (CARD32)t->bufAddr;
+ } else {
+ for (i = maxLevel; i >= minLevel; i--)
+ r128ctx->regs.prim_tex_offset[i] =
+ t->image[maxLevel-i].offset + (CARD32)t->bufAddr;
+ }
+ /* Fix AGP texture offsets */
+ if (heap == R128_AGP_TEX_HEAP)
+ for (i = 0; i < R128_TEX_MAXLEVELS; i++)
+ r128ctx->regs.prim_tex_offset[i] +=
+ R128_AGP_TEX_OFFSET +
+ r128ctx->r128Screen->agpTexOffset;
+ /* Force loading the new state into the hardware */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_TEX0STATE;
+ break;
+
+ case 2:
+ /* Set texture offsets */
+ if (t->regs.tex_cntl & R128_MIP_MAP_DISABLE) {
+ for (i = 0; i < R128_TEX_MAXLEVELS; i++)
+ r128ctx->regs.sec_tex_offset[i] = (CARD32)t->bufAddr;
+ } else {
+ for (i = maxLevel; i >= minLevel; i--)
+ r128ctx->regs.sec_tex_offset[i] =
+ t->image[maxLevel-i].offset + (CARD32)t->bufAddr;
+ }
+ /* Fix AGP texture offsets */
+ if (heap == R128_AGP_TEX_HEAP)
+ for (i = 0; i < R128_TEX_MAXLEVELS; i++)
+ r128ctx->regs.sec_tex_offset[i] +=
+ R128_AGP_TEX_OFFSET +
+ r128ctx->r128Screen->agpTexOffset;
+ /* Force loading the new state into the hardware */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_TEX1STATE;
+ break;
+
+ default:
+ return -1;
+ }
+ }
+
+ /* Let the world know we've used this memory recently */
+ r128UpdateTexLRU(r128ctx, t);
+
+ /* Upload any images that are new */
+ if (t->dirty_images) {
+ int num_levels = (((t->regs.size_pitch & R128_TEX_SIZE_MASK) >>
+ R128_TEX_SIZE_SHIFT) -
+ ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >>
+ R128_TEX_MIN_SIZE_SHIFT));
+
+ for (i = 0; i <= num_levels; i++) {
+ if (t->dirty_images & (1<<i)) {
+ r128UploadSubImage(r128ctx, t, i, 0, 0,
+ t->image[i].width, t->image[i].height);
+ }
+ }
+
+ r128ctx->regs.tex_cntl_c |= R128_TEX_CACHE_FLUSH;
+
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_ENGINESTATE;
+ }
+
+ t->dirty_images = 0;
+ return 0;
+}
+
+/* Update the hardware state for texture unit 0 */
+/* NOTE: This function is only called while holding the hardware lock */
+static void r128UpdateTex0State(r128ContextPtr r128ctx)
+{
+ GLcontext *ctx = r128ctx->glCtx;
+ r128TexObjPtr t;
+ struct gl_texture_object *tObj;
+ int i;
+ CARD32 tex_size_pitch, tex_combine_cntl;
+
+ /* Only update the hardware texture state if the texture is current,
+ complete and enabled. */
+ if (!(tObj = ctx->Texture.Unit[0].Current)) return;
+ if ((tObj != ctx->Texture.Unit[0].CurrentD[2]) &&
+ (tObj != ctx->Texture.Unit[0].CurrentD[1])) return;
+ if (!tObj->Complete) return;
+
+ /* If neither tex0 nor tex1 is enabled, then disable tex0. However,
+ if tex1 is enabled but tex0 is disabled, then we need to enable
+ tex0 and have it to copy the input (see how tex_combine_cntl is
+ setup below). */
+ if (!(ctx->Texture.Enabled & (ENABLE_TEX0 | ENABLE_TEX1))) {
+ r128ctx->regs.tex_cntl_c &= ~R128_TEXMAP_ENABLE;
+ return;
+ }
+
+ /* If this is the first time the texture has been used, then create
+ a new texture object for it. */
+ t = tObj->DriverData;
+ if (!t) t = r128CreateTexObj(r128ctx, tObj);
+ if (!t) return;
+
+ if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API)
+ fprintf(stderr, "r128UpdateTex0State(%p, 0x%08x)\n",
+ tObj, (int)t->dirty_images);
+
+ /* Force any texture images to be loaded into the hardware */
+ if (t->dirty_images) r128ctx->dirty |= R128_UPDATE_TEX0IMAGES;
+
+ /* Bind texture to texture 0 unit */
+ r128ctx->CurrentTexObj[0] = t;
+ t->bound = 1;
+
+ if (t->memBlock) r128UpdateTexLRU(r128ctx, t);
+
+ /* Set the texture environment state */
+ switch (ctx->Texture.Unit[0].EnvMode) {
+ case GL_REPLACE:
+ switch (tObj->Image[0]->Format) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ tex_combine_cntl = (R128_COMB_DIS |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_DIS |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ tex_combine_cntl = (R128_COMB_DIS |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_ALPHA:
+ tex_combine_cntl = (R128_COMB_COPY_INP |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_DIS |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_BLEND:
+ switch (tObj->Image[0]->Format) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ switch (r128ctx->regs.constant_color_c &
+ R128_CONSTANT_COLOR_MASK) {
+ case R128_CONSTANT_COLOR_ZERO:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_NTEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case R128_CONSTANT_COLOR_ONE:
+ default:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+ break;
+ }
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ switch (r128ctx->regs.constant_color_c &
+ R128_CONSTANT_COLOR_MASK) {
+ case R128_CONSTANT_COLOR_ZERO:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_NTEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case R128_CONSTANT_COLOR_ONE:
+ default:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+ break;
+ }
+ break;
+ case GL_ALPHA:
+ tex_combine_cntl = (R128_COMB_COPY_INP |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_INTENSITY:
+ switch (r128ctx->regs.constant_color_c &
+ R128_CONSTANT_COLOR_MASK) {
+ case R128_CONSTANT_COLOR_ZERO:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_NTEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_NTEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case R128_CONSTANT_COLOR_ONE:
+ default:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+ break;
+ }
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_MODULATE:
+ switch (tObj->Image[0]->Format) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_ALPHA:
+ tex_combine_cntl = (R128_COMB_COPY_INP |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_DECAL:
+ switch (tObj->Image[0]->Format) {
+ case GL_RGBA:
+ tex_combine_cntl = (R128_COMB_BLEND_TEXTURE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_RGB:
+ tex_combine_cntl = (R128_COMB_DIS |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ /* Undefined behaviour - just copy the input */
+ tex_combine_cntl = (R128_COMB_COPY_INP |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_ADD:
+ switch (tObj->Image[0]->Format) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ tex_combine_cntl = (R128_COMB_ADD |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ tex_combine_cntl = (R128_COMB_ADD |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_ALPHA:
+ tex_combine_cntl = (R128_COMB_COPY_INP |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ default:
+ return;
+ }
+
+ /* If tex0 is disabled, then make sure it just copies the input */
+ if (!(ctx->Texture.Enabled & ENABLE_TEX0))
+ tex_combine_cntl = (R128_COMB_COPY_INP |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_INT_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_INT_ALPHA);
+
+ /* Enable tex0 */
+ r128ctx->regs.tex_cntl_c |= R128_TEXMAP_ENABLE;
+
+ tex_size_pitch = r128ctx->regs.tex_size_pitch_c;
+ tex_size_pitch &= ~R128_TEX_SIZE_PITCH_MASK;
+ tex_size_pitch |= t->regs.size_pitch << R128_TEX_SIZE_PITCH_SHIFT;
+
+ /* Set the primary texture state in r128ctx->regs */
+ r128ctx->regs.prim_tex_cntl_c = t->regs.tex_cntl;
+ r128ctx->regs.prim_texture_combine_cntl_c = tex_combine_cntl;
+ r128ctx->regs.tex_size_pitch_c = tex_size_pitch;
+ r128ctx->regs.prim_texture_border_color_c = t->regs.border_color;
+
+ /* Set texture offsets */
+ if (t->regs.tex_cntl & R128_MIP_MAP_DISABLE) {
+ for (i = 0; i < R128_TEX_MAXLEVELS; i++)
+ r128ctx->regs.prim_tex_offset[i] = (CARD32)t->bufAddr;
+ } else {
+ int maxLevel = ((t->regs.size_pitch & R128_TEX_SIZE_MASK) >>
+ R128_TEX_SIZE_SHIFT);
+ int minLevel = ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >>
+ R128_TEX_MIN_SIZE_SHIFT);
+ for (i = maxLevel; i >= minLevel; i--)
+ r128ctx->regs.prim_tex_offset[i] =
+ t->image[maxLevel-i].offset + (CARD32)t->bufAddr;
+ }
+ /* Fix AGP texture offsets */
+ if (t->heap == R128_AGP_TEX_HEAP)
+ for (i = 0; i < R128_TEX_MAXLEVELS; i++)
+ r128ctx->regs.prim_tex_offset[i] +=
+ R128_AGP_TEX_OFFSET + r128ctx->r128Screen->agpTexOffset;
+
+ /* Force loading the new state into the hardware */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_TEX0STATE | R128_CTX_ENGINESTATE;
+}
+
+/* Update the hardware state for texture unit 1 */
+/* NOTE: This function is only called while holding the hardware lock */
+static void r128UpdateTex1State(r128ContextPtr r128ctx)
+{
+ GLcontext *ctx = r128ctx->glCtx;
+ r128TexObjPtr t;
+ struct gl_texture_object *tObj;
+ int i;
+ CARD32 tex_size_pitch, tex_combine_cntl, tex_cntl;
+
+ /* Only update the hardware texture state if the texture is current,
+ complete and enabled. */
+ if (!(tObj = ctx->Texture.Unit[1].Current)) return;
+ if ((tObj != ctx->Texture.Unit[1].CurrentD[2]) &&
+ (tObj != ctx->Texture.Unit[1].CurrentD[1])) return;
+ if (!tObj->Complete) return;
+
+ /* If tex1 is not enabled, then disable it */
+ if (!(ctx->Texture.Enabled & ENABLE_TEX1)) {
+ r128ctx->regs.tex_cntl_c &= ~R128_SEC_TEXMAP_ENABLE;
+ return;
+ }
+
+ /* If this is the first time the texture has been used, then create
+ a new texture object for it. */
+ t = tObj->DriverData;
+ if (!t) t = r128CreateTexObj(r128ctx, tObj);
+ if (!t) return;
+
+ if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API)
+ fprintf(stderr, "r128UpdateTex1State(%p, 0x%08x)\n",
+ tObj, (int)t->dirty_images);
+
+ /* Force any texture images to be loaded into the hardware */
+ if (t->dirty_images) r128ctx->dirty |= R128_UPDATE_TEX1IMAGES;
+
+ /* Bind texture to texture 1 unit */
+ r128ctx->CurrentTexObj[1] = t;
+ t->bound = 2;
+
+ if (t->memBlock) r128UpdateTexLRU(r128ctx, t);
+
+ /* Set the texture environment state */
+ switch (ctx->Texture.Unit[1].EnvMode) {
+ case GL_REPLACE:
+ switch (tObj->Image[0]->Format) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ tex_combine_cntl = (R128_COMB_DIS |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_DIS |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ tex_combine_cntl = (R128_COMB_DIS |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_ALPHA:
+ tex_combine_cntl = (R128_COMB_COPY_INP |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_DIS |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_BLEND:
+ switch (tObj->Image[0]->Format) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ switch ( r128ctx->regs.constant_color_c & R128_CONSTANT_COLOR_MASK ) {
+ case R128_CONSTANT_COLOR_ZERO:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_NTEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case R128_CONSTANT_COLOR_ONE:
+ default:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+ break;
+ }
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ switch (r128ctx->regs.constant_color_c &
+ R128_CONSTANT_COLOR_MASK) {
+ case R128_CONSTANT_COLOR_ZERO:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_NTEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA );
+ break;
+ case R128_CONSTANT_COLOR_ONE:
+ default:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA );
+ r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+ break;
+ }
+ break;
+ case GL_ALPHA:
+ tex_combine_cntl = (R128_COMB_COPY_INP |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_INTENSITY:
+ switch (r128ctx->regs.constant_color_c &
+ R128_CONSTANT_COLOR_MASK) {
+ case R128_CONSTANT_COLOR_ZERO:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_NTEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_NTEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case R128_CONSTANT_COLOR_ONE:
+ default:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+ break;
+ }
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_MODULATE:
+ switch (tObj->Image[0]->Format) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ tex_combine_cntl = (R128_COMB_MODULATE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_ALPHA:
+ tex_combine_cntl = (R128_COMB_COPY_INP |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_DECAL:
+ switch (tObj->Image[0]->Format) {
+ case GL_RGBA:
+ tex_combine_cntl = (R128_COMB_BLEND_TEXTURE |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_RGB:
+ tex_combine_cntl = (R128_COMB_DIS |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ /* Undefined behaviour - just copy the input */
+ tex_combine_cntl = (R128_COMB_COPY_INP |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_ADD:
+ switch (tObj->Image[0]->Format) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ tex_combine_cntl = (R128_COMB_ADD |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ tex_combine_cntl = (R128_COMB_ADD |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_COPY_INP |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_ALPHA:
+ tex_combine_cntl = (R128_COMB_COPY_INP |
+ R128_COLOR_FACTOR_TEX |
+ R128_INPUT_FACTOR_PREV_COLOR |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ default:
+ return;
+ }
+
+ /* Enable tex1 */
+ r128ctx->regs.tex_cntl_c |= R128_SEC_TEXMAP_ENABLE;
+
+ tex_size_pitch = r128ctx->regs.tex_size_pitch_c;
+ tex_size_pitch &= ~R128_SEC_TEX_SIZE_PITCH_MASK;
+ tex_size_pitch |= t->regs.size_pitch << R128_SEC_TEX_SIZE_PITCH_SHIFT;
+
+ tex_cntl = t->regs.tex_cntl | R128_SEC_SELECT_SEC_ST;
+
+ /* Set the secondary texture state in r128ctx->regs */
+ r128ctx->regs.sec_tex_cntl_c = tex_cntl;
+ r128ctx->regs.sec_tex_combine_cntl_c = tex_combine_cntl;
+ r128ctx->regs.tex_size_pitch_c = tex_size_pitch;
+ r128ctx->regs.sec_texture_border_color_c = t->regs.border_color;
+
+ /* Set texture offsets */
+ if (t->regs.tex_cntl & R128_MIP_MAP_DISABLE) {
+ for (i = 0; i < R128_TEX_MAXLEVELS; i++)
+ r128ctx->regs.sec_tex_offset[i] = (CARD32)t->bufAddr;
+ } else {
+ int maxLevel = ((t->regs.size_pitch & R128_TEX_SIZE_MASK) >>
+ R128_TEX_SIZE_SHIFT);
+ int minLevel = ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >>
+ R128_TEX_MIN_SIZE_SHIFT);
+ for (i = maxLevel; i >= minLevel; i--)
+ r128ctx->regs.sec_tex_offset[i] =
+ t->image[maxLevel-i].offset + (CARD32)t->bufAddr;
+ }
+ /* Fix AGP texture offsets */
+ if (t->heap == R128_AGP_TEX_HEAP)
+ for (i = 0; i < R128_TEX_MAXLEVELS; i++)
+ r128ctx->regs.sec_tex_offset[i] +=
+ R128_AGP_TEX_OFFSET + r128ctx->r128Screen->agpTexOffset;
+
+ /* Force loading the new state into the hardware */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_TEX1STATE | R128_CTX_ENGINESTATE;
+}
+
+/* Update the hardware texture state */
+/* NOTE: This function is only called while holding the hardware lock */
+void r128UpdateTextureState(r128ContextPtr r128ctx)
+{
+ /* Clear the GL_BLEND texturing fallback */
+ r128ctx->Fallback &= ~R128_FALLBACK_TEXTURE;
+
+ /* Unbind any currently bound textures */
+ if (r128ctx->CurrentTexObj[0]) r128ctx->CurrentTexObj[0]->bound = 0;
+ if (r128ctx->CurrentTexObj[1]) r128ctx->CurrentTexObj[1]->bound = 0;
+ r128ctx->CurrentTexObj[0] = NULL;
+ r128ctx->CurrentTexObj[1] = NULL;
+
+ /* Update the texture unit 0/1 state */
+ r128UpdateTex0State(r128ctx);
+ r128UpdateTex1State(r128ctx);
+}
+
+/* Set the texture wrap mode */
+static void r128SetTexWrap(r128TexObjPtr t, GLenum swrap, GLenum twrap)
+{
+ t->regs.tex_cntl &= ~(R128_TEX_CLAMP_S_MASK | R128_TEX_CLAMP_T_MASK);
+
+ switch (swrap) {
+ case GL_CLAMP: t->regs.tex_cntl |= R128_TEX_CLAMP_S_CLAMP; break;
+ case GL_REPEAT: t->regs.tex_cntl |= R128_TEX_CLAMP_S_WRAP; break;
+ default: /* ERROR!! */ return;
+ }
+
+ switch (twrap) {
+ case GL_CLAMP: t->regs.tex_cntl |= R128_TEX_CLAMP_T_CLAMP; break;
+ case GL_REPEAT: t->regs.tex_cntl |= R128_TEX_CLAMP_T_WRAP; break;
+ default: /* ERROR!! */ return;
+ }
+}
+
+/* Set the texture filter mode */
+static void r128SetTexFilter(r128TexObjPtr t, GLenum minf, GLenum magf)
+{
+ t->regs.tex_cntl &= ~(R128_MIN_BLEND_MASK | R128_MAG_BLEND_MASK);
+
+ switch (minf) {
+ case GL_NEAREST:
+ t->regs.tex_cntl |= R128_MIN_BLEND_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->regs.tex_cntl |= R128_MIN_BLEND_LINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ t->regs.tex_cntl |= R128_MIN_BLEND_MIPNEAREST;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t->regs.tex_cntl |= R128_MIN_BLEND_LINEARMIPNEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ t->regs.tex_cntl |= R128_MIN_BLEND_MIPLINEAR;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t->regs.tex_cntl |= R128_MIN_BLEND_LINEARMIPLINEAR;
+ break;
+ default: /* ERROR!! */ return;
+ }
+
+ switch (magf) {
+ case GL_NEAREST:
+ t->regs.tex_cntl |= R128_MAG_BLEND_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->regs.tex_cntl |= R128_MAG_BLEND_LINEAR;
+ break;
+ }
+}
+
+/* Set the texture border color */
+static void r128SetTexBorderColor(r128TexObjPtr t, GLubyte c[4])
+{
+ t->regs.border_color = r128PackColor(32, c[0], c[1], c[2], c[3]);
+}
+
+/* Set the texture environment state */
+static void r128DDTexEnv(GLcontext *ctx, GLenum target, GLenum pname,
+ const GLfloat *param)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit;
+ GLubyte c[4];
+ CARD32 col;
+
+ /* FIXME: Add texture LOD bias extension */
+
+ switch (pname) {
+ case GL_TEXTURE_ENV_MODE:
+ /* TexEnv modes are handled in UpdateTextureState */
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->dirty |= R128_UPDATE_TEXSTATE;
+ break;
+ case GL_TEXTURE_ENV_COLOR:
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ FLOAT_RGBA_TO_UBYTE_RGBA(texUnit->EnvColor, c);
+ col = r128PackColor(32, c[0], c[1], c[2], c[3]);
+ if (r128ctx->regs.constant_color_c != col) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128ctx->regs.constant_color_c = col;
+
+ /* FIXME: Load into hardware now??? */
+ r128ctx->dirty |= R128_UPDATE_CONTEXT;
+ r128ctx->dirty_context |= R128_CTX_TEXENVSTATE;
+ }
+ break;
+ default:
+ return;
+ }
+}
+
+/* Upload a new texture image */
+static void r128DDTexImage(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj, GLint level,
+ GLint internalFormat,
+ const struct gl_texture_image *image)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ r128TexObjPtr t;
+
+ if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API)
+ fprintf(stderr, "r128DDTexImage(%p, level %d)\n", tObj, level);
+
+ if ((target != GL_TEXTURE_2D) && (target != GL_TEXTURE_1D)) return;
+ if (level >= R128_TEX_MAXLEVELS) return;
+
+ t = (r128TexObjPtr)tObj->DriverData;
+ if (t) {
+ if (t->bound) R128CCE_FLUSH_VB_LOCK(r128ctx);
+
+ /* Destroy the old texture, and upload a new one. The actual
+ uploading of the texture image occurs in the UploadSubImage
+ function. */
+ r128DestroyTexObj(r128ctx, t);
+ r128ctx->dirty |= R128_UPDATE_TEXSTATE;
+ }
+}
+
+/* Upload a new texture sub-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)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ r128TexObjPtr t;
+
+ if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API)
+ fprintf(stderr, "r128DDTexSubImage(%p, level %d) "
+ "size: %d,%d of %d,%d\n",
+ tObj, level, width, height, image->Width, image->Height);
+
+ if ((target != GL_TEXTURE_2D) && (target != GL_TEXTURE_1D)) return;
+ if (level >= R128_TEX_MAXLEVELS) return;
+
+ t = (r128TexObjPtr)tObj->DriverData;
+ if (t) {
+ if (t->bound) R128CCE_FLUSH_VB_LOCK(r128ctx);
+
+ LOCK_HARDWARE(r128ctx);
+ r128UploadSubImage(r128ctx, t, level,
+ xoffset, yoffset, width, height);
+ UNLOCK_HARDWARE(r128ctx);
+
+ /* Update the context state */
+ r128ctx->regs.tex_cntl_c |= R128_TEX_CACHE_FLUSH;
+
+ r128ctx->dirty |= (R128_UPDATE_CONTEXT |
+ R128_UPDATE_TEXSTATE);
+ r128ctx->dirty_context |= (R128_CTX_ENGINESTATE |
+ R128_CTX_TEX0STATE |
+ R128_CTX_TEX1STATE);
+ }
+}
+
+/* Set the texture parameter state */
+static void r128DDTexParameter(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData;
+
+ if (!t) return;
+ if ((target != GL_TEXTURE_2D) && (target != GL_TEXTURE_1D)) return;
+
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ if (t->bound) R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128SetTexFilter(t, tObj->MinFilter, tObj->MagFilter);
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ if (t->bound) R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128SetTexWrap(t, tObj->WrapS, tObj->WrapT);
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ if (t->bound) R128CCE_FLUSH_VB_LOCK(r128ctx);
+ r128SetTexBorderColor(t, tObj->BorderColor);
+ break;
+
+ default:
+ return;
+ }
+
+ r128ctx->dirty |= R128_UPDATE_TEXSTATE;
+}
+
+/* Bind a texture to the currently active texture unit */
+static void r128DDBindTexture(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+
+ /* Unbind the old texture */
+ if (r128ctx->CurrentTexObj[ctx->Texture.CurrentUnit]) {
+ r128ctx->CurrentTexObj[ctx->Texture.CurrentUnit]->bound = 0;
+ r128ctx->CurrentTexObj[ctx->Texture.CurrentUnit] = NULL;
+ }
+
+ /* The actualy binding occurs in the Tex[01]UpdateState function */
+ r128ctx->dirty |= R128_UPDATE_TEXSTATE;
+}
+
+/* Remove texture from AGP/local texture memory */
+static void r128DDDeleteTexture(GLcontext *ctx,
+ struct gl_texture_object *tObj)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData;
+
+ if (t) {
+ if (t->bound) {
+ R128CCE_FLUSH_VB_LOCK(r128ctx);
+
+ r128ctx->CurrentTexObj[t->bound-1] = 0;
+ r128ctx->dirty |= R128_UPDATE_TEXSTATE;
+ }
+
+ r128DestroyTexObj(r128ctx, t);
+ tObj->DriverData = NULL;
+ }
+}
+
+/* Determine if a texture is currently residing in either AGP/local
+ texture memory */
+static GLboolean r128DDIsTextureResident(GLcontext *ctx,
+ struct gl_texture_object *tObj)
+{
+ r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData;
+
+ return t && t->memBlock;
+}
+
+/* Initialize the driver's texture functions */
+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.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..20893110c
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tex.h
@@ -0,0 +1,82 @@
+/* $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>
+ * Gareth Hughes <gareth@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_TEX_H_
+#define _R128_TEX_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void r128AgeTextures(r128ContextPtr r128ctx, int heap);
+extern int r128UploadTexImages(r128ContextPtr r128ctx, r128TexObjPtr t);
+extern void r128UpdateTextureState(r128ContextPtr r128ctx);
+extern void r128DestroyTexObj(r128ContextPtr r128ctx, r128TexObjPtr t);
+
+extern void r128DDInitTextureFuncs(GLcontext *ctx);
+
+#define R128PACKCOLOR332(r, g, b) \
+ (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
+
+#define R128PACKCOLOR1555(r, g, b, a) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+
+#define R128PACKCOLOR565(r, g, b) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+#define R128PACKCOLOR888(r, g, b) \
+ (((r) << 16) | ((g) << 8) | (b))
+
+#define R128PACKCOLOR8888(r, g, b, a) \
+ (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+
+#define R128PACKCOLOR4444(r, g, b, a) \
+ ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
+
+static __inline__ CARD32 r128PackColor(GLuint depth,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a)
+{
+ switch (depth) {
+ case 8: return R128PACKCOLOR332(r, g, b);
+ case 15: return R128PACKCOLOR1555(r, g, b, a);
+ case 16: return R128PACKCOLOR565(r, g, b);
+ case 24: return R128PACKCOLOR888(r, g, b);
+ case 32: return R128PACKCOLOR8888(r, g, b, a);
+ default: return 0;
+ }
+}
+
+#endif
+#endif /* _R128_TEX_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_texobj.h b/xc/lib/GL/mesa/src/drv/r128/r128_texobj.h
new file mode 100644
index 000000000..588b768ed
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_texobj.h
@@ -0,0 +1,87 @@
+/* $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>
+ * Gareth Hughes <gareth@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_TEXOBJ_H_
+#define _R128_TEXOBJ_H_
+
+#include "mm.h"
+
+#define R128_TEX_MAXLEVELS 11
+
+/* Setup registers for each texture */
+typedef struct {
+ CARD32 tex_cntl;
+ CARD32 size_pitch;
+ CARD32 border_color;
+} r128TextureRegs;
+
+/* Individual texture image information */
+typedef struct {
+ int offset; /* Offset into locally shared texture space (i.e.,
+ relative to bufAddr (below) */
+ int width; /* Width of texture image */
+ int height; /* Height of texture image */
+} r128TexImage;
+
+typedef struct r128_tex_obj r128TexObj, *r128TexObjPtr;
+
+/* Texture object in locally shared texture space */
+struct r128_tex_obj {
+ r128TexObjPtr next, prev;
+
+ struct gl_texture_object *tObj; /* Mesa texture object */
+
+ PMemBlock memBlock; /* Memory block containing texture */
+ unsigned char *bufAddr; /* Offset to start of locally
+ shared texture block */
+
+ CARD32 dirty_images; /* Flags for whether or not
+ images need to be uploaded to
+ local or AGP texture space */
+ int bound; /* Texture unit currently bound to */
+ int heap; /* Texture heap currently stored in */
+ r128TexImage image[R128_TEX_MAXLEVELS]; /* Image data for all
+ mipmap levels */
+ int totalSize; /* Total size of the texture
+ including all mipmap levels */
+ int internFormat; /* Internal GL format used to store
+ texture on card */
+ int textureFormat; /* Actual hardware format */
+ int texelBytes; /* Number of bytes per texel */
+
+ r128TextureRegs regs; /* Setup regs for texture */
+};
+
+#endif /* _R128_TEXOBJ_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tris.c b/xc/lib/GL/mesa/src/drv/r128/r128_tris.c
new file mode 100644
index 000000000..1c1b45daf
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.c
@@ -0,0 +1,548 @@
+/* $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_reg.h"
+#include "r128_cce.h"
+#include "r128_vb.h"
+#include "r128_tris.h"
+#include "r128_state.h"
+
+static triangle_func tri_tab[0x40]; /* only 0x20 actually used */
+static quad_func quad_tab[0x40]; /* only 0x20 actually used */
+static line_func line_tab[0x40]; /* less than 0x20 used */
+static points_func points_tab[0x40]; /* less than 0x20 used */
+
+/* Draw a triangle from the vertices in the vertex buffer */
+void r128DrawTriangleVB(r128ContextPtr r128ctx,
+ r128_vertex *v0,
+ r128_vertex *v1,
+ r128_vertex *v2)
+{
+ r128_vertex *vbptr;
+
+ if (r128ctx->disableVB) {
+ r128DrawTriangle(r128ctx, v0, v1, v2);
+ return;
+ }
+
+ R128CCE_ALLOC_VB_SPACE(r128ctx, vbptr, 3);
+
+ *vbptr++ = *v0;
+ *vbptr++ = *v1;
+ *vbptr++ = *v2;
+}
+
+/* Draw a triangle */
+void r128DrawTriangle(r128ContextPtr r128ctx,
+ r128_vertex *v0,
+ r128_vertex *v1,
+ r128_vertex *v2)
+{
+ LOCK_HARDWARE(r128ctx);
+ BEGIN_CLIP_LOOP(r128ctx);
+
+#if USE_RHW2
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 34);
+#else
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 31);
+#endif
+ R128CCE(R128_FULL_VERTEX_FORMAT);
+ R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST |
+ R128_CCE_VC_CNTL_PRIM_WALK_RING |
+ (3 << R128_CCE_VC_CNTL_NUM_SHIFT));
+
+ R128CCE_SEND_VERTEX(v0);
+ R128CCE_SEND_VERTEX(v1);
+ R128CCE_SEND_VERTEX(v2);
+
+ R128CCE_SUBMIT_PACKETS();
+
+ END_CLIP_LOOP(r128ctx);
+ UNLOCK_HARDWARE(r128ctx);
+}
+
+/* Draw a line from the vertices in the vertex buffer */
+void r128DrawLineVB(r128ContextPtr r128ctx,
+ r128_vertex *v0, r128_vertex *v1,
+ float width)
+{
+ float dx, dy, ix, iy;
+ r128_vertex *vbptr;
+
+ /* FIXME: Use r128's line primitive for width 1 lines */
+ if (r128ctx->disableVB) {
+ r128DrawLine(r128ctx, v0, v1, width);
+ return;
+ }
+
+ R128CCE_ALLOC_VB_SPACE(r128ctx, vbptr, 3);
+
+ dx = v0->x - v1->x;
+ dy = v0->y - v1->y;
+
+ ix = width * 0.5; iy = 0;
+ if (dx*dx > dy*dy) {
+ iy = ix; ix = 0;
+ }
+
+ *vbptr = *v0; vbptr->x = v0->x - ix; vbptr->y = v0->y - iy;
+ *++vbptr = *v1; vbptr->x = v1->x + ix; vbptr->y = v1->y + iy;
+ *++vbptr = *v0; vbptr->x = v0->x + ix; vbptr->y = v0->y + iy;
+ *++vbptr = *v0; vbptr->x = v0->x - ix; vbptr->y = v0->y - iy;
+ *++vbptr = *v1; vbptr->x = v1->x - ix; vbptr->y = v1->y - iy;
+ *++vbptr = *v1; vbptr->x = v1->x + ix; vbptr->y = v1->y + iy;
+}
+
+/* Draw a line */
+void r128DrawLine(r128ContextPtr r128ctx,
+ r128_vertex *v0, r128_vertex *v1,
+ float width)
+{
+ LOCK_HARDWARE(r128ctx);
+ if (width != 1) {
+ float dx, dy, ix, iy;
+
+ dx = v0->x - v1->x;
+ dy = v0->y - v1->y;
+
+ ix = width * 0.5; iy = 0;
+ if (dx*dx > dy*dy) {
+ iy = ix; ix = 0;
+ }
+
+ BEGIN_CLIP_LOOP(r128ctx);
+
+#if USE_RHW2
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 67);
+#else
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 61);
+#endif
+ R128CCE(R128_FULL_VERTEX_FORMAT);
+ R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST |
+ R128_CCE_VC_CNTL_PRIM_WALK_RING |
+ (6 << R128_CCE_VC_CNTL_NUM_SHIFT));
+
+ R128CCEF(v0->x - ix);
+ R128CCEF(v0->y - iy);
+ R128CCEF(v0->z);
+ R128CCEF(v0->rhw);
+ R128CCE(*(int *)&v0->dif_argb);
+ R128CCE(*(int *)&v0->spec_frgb);
+ R128CCEF(v0->tu0);
+ R128CCEF(v0->tv0);
+ R128CCEF(v0->tu1);
+ R128CCEF(v0->tv1);
+#if USE_RHW2
+ R128CCEF(v0->rhw2);
+#endif
+
+ R128CCEF(v1->x + ix);
+ R128CCEF(v1->y + iy);
+ R128CCEF(v1->z);
+ R128CCEF(v1->rhw);
+ R128CCE(*(int *)&v1->dif_argb);
+ R128CCE(*(int *)&v1->spec_frgb);
+ R128CCEF(v1->tu0);
+ R128CCEF(v1->tv0);
+ R128CCEF(v1->tu1);
+ R128CCEF(v1->tv1);
+#if USE_RHW2
+ R128CCEF(v1->rhw2);
+#endif
+
+ R128CCEF(v0->x + ix);
+ R128CCEF(v0->y + iy);
+ R128CCEF(v0->z);
+ R128CCEF(v0->rhw);
+ R128CCE(*(int *)&v0->dif_argb);
+ R128CCE(*(int *)&v0->spec_frgb);
+ R128CCEF(v0->tu0);
+ R128CCEF(v0->tv0);
+ R128CCEF(v0->tu1);
+ R128CCEF(v0->tv1);
+#if USE_RHW2
+ R128CCEF(v0->rhw2);
+#endif
+
+ R128CCEF(v0->x - ix);
+ R128CCEF(v0->y - iy);
+ R128CCEF(v0->z);
+ R128CCEF(v0->rhw);
+ R128CCE(*(int *)&v0->dif_argb);
+ R128CCE(*(int *)&v0->spec_frgb);
+ R128CCEF(v0->tu0);
+ R128CCEF(v0->tv0);
+ R128CCEF(v0->tu1);
+ R128CCEF(v0->tv1);
+#if USE_RHW2
+ R128CCEF(v0->rhw2);
+#endif
+
+ R128CCEF(v1->x - ix);
+ R128CCEF(v1->y - iy);
+ R128CCEF(v1->z);
+ R128CCEF(v1->rhw);
+ R128CCE(*(int *)&v1->dif_argb);
+ R128CCE(*(int *)&v1->spec_frgb);
+ R128CCEF(v1->tu0);
+ R128CCEF(v1->tv0);
+ R128CCEF(v1->tu1);
+ R128CCEF(v1->tv1);
+#if USE_RHW2
+ R128CCEF(v1->rhw2);
+#endif
+
+ R128CCEF(v1->x + ix);
+ R128CCEF(v1->y + iy);
+ R128CCEF(v1->z);
+ R128CCEF(v1->rhw);
+ R128CCE(*(int *)&v1->dif_argb);
+ R128CCE(*(int *)&v1->spec_frgb);
+ R128CCEF(v1->tu0);
+ R128CCEF(v1->tv0);
+ R128CCEF(v1->tu1);
+ R128CCEF(v1->tv1);
+#if USE_RHW2
+ R128CCEF(v1->rhw2);
+#endif
+
+ R128CCE_SUBMIT_PACKETS();
+
+ END_CLIP_LOOP(r128ctx);
+ } else {
+ BEGIN_CLIP_LOOP(r128ctx);
+
+#if USE_RHW2
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 23);
+#else
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 21);
+#endif
+ R128CCE(R128_FULL_VERTEX_FORMAT);
+ R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_LINE |
+ R128_CCE_VC_CNTL_PRIM_WALK_RING |
+ (2 << R128_CCE_VC_CNTL_NUM_SHIFT));
+
+ R128CCE_SEND_VERTEX(v0);
+ R128CCE_SEND_VERTEX(v1);
+
+ R128CCE_SUBMIT_PACKETS();
+
+ END_CLIP_LOOP(r128ctx);
+ }
+ UNLOCK_HARDWARE(r128ctx);
+}
+
+/* Draw a point from the vertices in the vertex buffer */
+void r128DrawPointVB(r128ContextPtr r128ctx,
+ r128_vertex *v0, float size)
+{
+ r128_vertex *vbptr;
+
+ /* FIXME: Use r128's point primitive for diameter 1 points */
+ if (r128ctx->disableVB) {
+ r128DrawPoint(r128ctx, v0, size);
+ return;
+ }
+
+ R128CCE_ALLOC_VB_SPACE(r128ctx, vbptr, 3);
+
+ *vbptr = *v0; vbptr->x = v0->x - size; vbptr->y = v0->y - size;
+ *++vbptr = *v0; vbptr->x = v0->x + size; vbptr->y = v0->y - size;
+ *++vbptr = *v0; vbptr->x = v0->x + size; vbptr->y = v0->y + size;
+ *++vbptr = *v0; vbptr->x = v0->x + size; vbptr->y = v0->y + size;
+ *++vbptr = *v0; vbptr->x = v0->x - size; vbptr->y = v0->y + size;
+ *++vbptr = *v0; vbptr->x = v0->x - size; vbptr->y = v0->y - size;
+}
+
+/* Draw a point */
+void r128DrawPoint(r128ContextPtr r128ctx,
+ r128_vertex *v0, float size)
+{
+ LOCK_HARDWARE(r128ctx);
+ if (size != 0.5) {
+ BEGIN_CLIP_LOOP(r128ctx);
+
+#if USE_RHW2
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 67);
+#else
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 61);
+#endif
+ R128CCE(R128_FULL_VERTEX_FORMAT);
+ R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST |
+ R128_CCE_VC_CNTL_PRIM_WALK_RING |
+ (6 << R128_CCE_VC_CNTL_NUM_SHIFT));
+
+ R128CCEF(v0->x - size);
+ R128CCEF(v0->y - size);
+ R128CCEF(v0->z);
+ R128CCEF(v0->rhw);
+ R128CCE(*(int *)&v0->dif_argb);
+ R128CCE(*(int *)&v0->spec_frgb);
+ R128CCEF(v0->tu0);
+ R128CCEF(v0->tv0);
+ R128CCEF(v0->tu1);
+ R128CCEF(v0->tv1);
+#if USE_RHW2
+ R128CCEF(v0->rhw2);
+#endif
+
+ R128CCEF(v0->x + size);
+ R128CCEF(v0->y - size);
+ R128CCEF(v0->z);
+ R128CCEF(v0->rhw);
+ R128CCE(*(int *)&v0->dif_argb);
+ R128CCE(*(int *)&v0->spec_frgb);
+ R128CCEF(v0->tu0);
+ R128CCEF(v0->tv0);
+ R128CCEF(v0->tu1);
+ R128CCEF(v0->tv1);
+#if USE_RHW2
+ R128CCEF(v0->rhw2);
+#endif
+
+ R128CCEF(v0->x + size);
+ R128CCEF(v0->y + size);
+ R128CCEF(v0->z);
+ R128CCEF(v0->rhw);
+ R128CCE(*(int *)&v0->dif_argb);
+ R128CCE(*(int *)&v0->spec_frgb);
+ R128CCEF(v0->tu0);
+ R128CCEF(v0->tv0);
+ R128CCEF(v0->tu1);
+ R128CCEF(v0->tv1);
+#if USE_RHW2
+ R128CCEF(v0->rhw2);
+#endif
+
+ R128CCEF(v0->x + size);
+ R128CCEF(v0->y + size);
+ R128CCEF(v0->z);
+ R128CCEF(v0->rhw);
+ R128CCE(*(int *)&v0->dif_argb);
+ R128CCE(*(int *)&v0->spec_frgb);
+ R128CCEF(v0->tu0);
+ R128CCEF(v0->tv0);
+ R128CCEF(v0->tu1);
+ R128CCEF(v0->tv1);
+#if USE_RHW2
+ R128CCEF(v0->rhw2);
+#endif
+
+ R128CCEF(v0->x - size);
+ R128CCEF(v0->y + size);
+ R128CCEF(v0->z);
+ R128CCEF(v0->rhw);
+ R128CCE(*(int *)&v0->dif_argb);
+ R128CCE(*(int *)&v0->spec_frgb);
+ R128CCEF(v0->tu0);
+ R128CCEF(v0->tv0);
+ R128CCEF(v0->tu1);
+ R128CCEF(v0->tv1);
+#if USE_RHW2
+ R128CCEF(v0->rhw2);
+#endif
+
+ R128CCEF(v0->x - size);
+ R128CCEF(v0->y - size);
+ R128CCEF(v0->z);
+ R128CCEF(v0->rhw);
+ R128CCE(*(int *)&v0->dif_argb);
+ R128CCE(*(int *)&v0->spec_frgb);
+ R128CCEF(v0->tu0);
+ R128CCEF(v0->tv0);
+ R128CCEF(v0->tu1);
+ R128CCEF(v0->tv1);
+#if USE_RHW2
+ R128CCEF(v0->rhw2);
+#endif
+
+ R128CCE_SUBMIT_PACKETS();
+
+ END_CLIP_LOOP(r128ctx);
+ } else {
+ BEGIN_CLIP_LOOP(r128ctx);
+
+#if USE_RHW2
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 12);
+#else
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 11);
+#endif
+ R128CCE(R128_FULL_VERTEX_FORMAT);
+ R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_POINT |
+ R128_CCE_VC_CNTL_PRIM_WALK_RING |
+ (1 << R128_CCE_VC_CNTL_NUM_SHIFT));
+
+ R128CCE_SEND_VERTEX(v0);
+
+ R128CCE_SUBMIT_PACKETS();
+
+ END_CLIP_LOOP(r128ctx);
+ }
+ UNLOCK_HARDWARE(r128ctx);
+}
+
+#define R128_COLOR(to, from) \
+do { \
+ (to)[0] = (from)[2]; \
+ (to)[1] = (from)[1]; \
+ (to)[2] = (from)[0]; \
+ (to)[3] = (from)[3]; \
+} while (0)
+
+#define IND (0)
+#define TAG(x) x
+#include "r128_tritmp.h"
+
+#define IND (R128_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "r128_tritmp.h"
+
+#define IND (R128_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "r128_tritmp.h"
+
+#define IND (R128_OFFSET_BIT | R128_FLAT_BIT)
+#define TAG(x) x##_offset_flat
+#include "r128_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "r128_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT | R128_FLAT_BIT)
+#define TAG(x) x##_twoside_flat
+#include "r128_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT | R128_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "r128_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT | R128_OFFSET_BIT | R128_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_flat
+#include "r128_tritmp.h"
+
+/* Initialize the table of points, line and triangle drawing functions */
+void r128TriangleFuncsInit(void)
+{
+ init();
+ init_flat();
+ init_offset();
+ init_offset_flat();
+ init_twoside();
+ init_twoside_flat();
+ init_twoside_offset();
+ init_twoside_offset_flat();
+}
+
+/* Setup the Point, Line, Triangle and Quad functions based on the
+ current rendering state. Wherever possible, use the hardware to
+ render the primitive. Otherwise, fallback to software rendering. */
+void r128ChooseRenderState(GLcontext *ctx)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ GLuint flags = ctx->TriangleCaps;
+
+ if (r128ctx->Fallback) return;
+
+ if (r128ctx->SWonly) {
+ r128ctx->IndirectTriangles = DD_SW_RASTERIZE;
+ r128ctx->PointsFunc = NULL;
+ r128ctx->LineFunc = NULL;
+ r128ctx->TriangleFunc = NULL;
+ r128ctx->QuadFunc = NULL;
+ return;
+ } else {
+ r128ctx->IndirectTriangles = 0;
+ }
+
+ if (flags) {
+ CARD32 index = 0;
+ CARD32 shared = 0;
+ CARD32 fallback = R128_FALLBACK_BIT;
+
+ if (r128ctx->SWfallbackDisable) fallback = 0; /* No fallbacks */
+ if (r128ctx->SWonly) shared = fallback; /* Everything's a fallback */
+
+ if (flags & DD_FLATSHADE) shared |= R128_FLAT_BIT;
+ if (flags & DD_MULTIDRAW) shared |= fallback;
+ if (flags & DD_SELECT) shared |= R128_FALLBACK_BIT;
+ if (flags & DD_FEEDBACK) shared |= R128_FALLBACK_BIT;
+
+ /* Setup PointFunc */
+ index = shared;
+ if (flags & DD_POINT_SMOOTH) index |= fallback;
+ if (flags & DD_POINT_ATTEN) index |= fallback;
+
+ r128ctx->RenderIndex = index;
+ r128ctx->PointsFunc = points_tab[index];
+ if (index & R128_FALLBACK_BIT)
+ r128ctx->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
+
+ /* Setup LineFunc */
+ index = shared;
+ if (flags & DD_LINE_SMOOTH) index |= fallback;
+ if (flags & DD_LINE_STIPPLE) index |= fallback;
+
+ r128ctx->RenderIndex |= index;
+ r128ctx->LineFunc = line_tab[index];
+ if (index & R128_FALLBACK_BIT)
+ r128ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
+
+ /* Setup TriangleFunc and QuadFunc */
+ index = shared;
+ if (flags & DD_TRI_SMOOTH) index |= fallback;
+ if (flags & DD_TRI_OFFSET) index |= R128_OFFSET_BIT;
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R128_TWOSIDE_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= fallback;
+ if (flags & DD_TRI_STIPPLE) index |= fallback;
+
+ r128ctx->RenderIndex |= index;
+ r128ctx->TriangleFunc = tri_tab[index];
+ r128ctx->QuadFunc = quad_tab[index];
+ if (index & R128_FALLBACK_BIT)
+ r128ctx->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
+ DD_QUAD_SW_RASTERIZE);
+ } else if (r128ctx->RenderIndex) {
+ r128ctx->RenderIndex = 0;
+ r128ctx->PointsFunc = points_tab[0];
+ r128ctx->LineFunc = line_tab[0];
+ r128ctx->TriangleFunc = tri_tab[0];
+ r128ctx->QuadFunc = quad_tab[0];
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tris.h b/xc/lib/GL/mesa/src/drv/r128/r128_tris.h
new file mode 100644
index 000000000..0980f2791
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.h
@@ -0,0 +1,76 @@
+/* $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_TRIS_H_
+#define _R128_TRIS_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include "r128_vb.h"
+
+#define R128_ANTIALIAS_BIT 0x00 /* ignored for now, no fallback */
+#define R128_FLAT_BIT 0x01
+#define R128_OFFSET_BIT 0x02
+#define R128_TWOSIDE_BIT 0x04
+#define R128_NODRAW_BIT 0x08
+#define R128_FALLBACK_BIT 0x10
+#define R128_FEEDBACK_BIT 0x20
+#define R128_SELECT_BIT 0x40
+#define R128_POINT_PARAM_BIT 0x80 /* not needed? */
+
+extern void r128DrawTriangleVB(r128ContextPtr r128ctx,
+ r128_vertex *v0,
+ r128_vertex *v1,
+ r128_vertex *v2);
+extern void r128DrawLineVB(r128ContextPtr r128ctx,
+ r128_vertex *tmp0, r128_vertex *tmp1,
+ float width);
+extern void r128DrawPointVB(r128ContextPtr r128ctx,
+ r128_vertex *tmp, float size);
+
+extern void r128DrawTriangle(r128ContextPtr r128ctx,
+ r128_vertex *v0,
+ r128_vertex *v1,
+ r128_vertex *v2);
+extern void r128DrawLine(r128ContextPtr r128ctx,
+ r128_vertex *tmp0, r128_vertex *tmp1,
+ float width);
+extern void r128DrawPoint(r128ContextPtr r128ctx,
+ r128_vertex *tmp, float size);
+
+extern void r128ChooseRenderState(GLcontext *ctx);
+extern void r128TriangleFuncsInit(void);
+
+#endif
+#endif /* _R128_TRIS_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h b/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h
new file mode 100644
index 000000000..833bd832a
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h
@@ -0,0 +1,327 @@
+/* $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>
+ *
+ */
+
+#if !defined(TAG) || !defined(IND)
+ this is an error
+#endif
+
+/* Draw a single triangle. Note that the device-dependent vertex data
+ might need to be changed based on the render state. */
+static void TAG(triangle)(GLcontext *ctx,
+ GLuint e0, GLuint e1, GLuint e2,
+ GLuint pv)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ struct vertex_buffer *VB = ctx->VB;
+ r128VertexPtr r128verts = R128_DRIVER_DATA(VB)->verts;
+ const r128_vertex *v0 = &r128verts[e0].v;
+ const r128_vertex *v1 = &r128verts[e1].v;
+ const r128_vertex *v2 = &r128verts[e2].v;
+
+#if (IND & R128_OFFSET_BIT)
+ GLfloat offset;
+#endif
+
+#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT))
+ int c0 = *(int *)&r128verts[pv].v.dif_argb;
+ int c1 = c0;
+ int c2 = c0;
+#endif
+
+#if (IND & R128_OFFSET_BIT)
+ switch (ctx->Visual->DepthBits) {
+ case 16: offset = ctx->Polygon.OffsetUnits / 65536.0; break;
+ case 24: offset = ctx->Polygon.OffsetUnits / 16777216.0; break;
+ case 32: offset = ctx->Polygon.OffsetUnits / 4294967296.0; break;
+ default: offset = ctx->Polygon.OffsetUnits / 65536.0; break;
+ }
+#endif
+
+#if (IND & (R128_TWOSIDE_BIT | R128_OFFSET_BIT))
+ {
+ GLfloat ex = v0->x - v2->x;
+ GLfloat ey = v0->y - v2->y;
+ GLfloat fx = v1->x - v2->x;
+ GLfloat fy = v1->y - v2->y;
+ GLfloat c = ex*fy - ey*fx;
+
+#if (IND & R128_TWOSIDE_BIT)
+ {
+ GLuint facing = (c > 0.0) ^ ctx->Polygon.FrontBit;
+ GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
+ if (IND & R128_FLAT_BIT) {
+ R128_COLOR((char *)&c0, vbcolor[pv]);
+ c2 = c1 = c0;
+ } else {
+ R128_COLOR((char *)&c0, vbcolor[e0]);
+ R128_COLOR((char *)&c1, vbcolor[e1]);
+ R128_COLOR((char *)&c2, vbcolor[e2]);
+ }
+ }
+#endif
+
+#if (IND & R128_OFFSET_BIT)
+ {
+ if (c * c > 1e-16) {
+ GLfloat factor = ctx->Polygon.OffsetFactor;
+ GLfloat ez = v0->z - v2->z;
+ GLfloat fz = v1->z - v2->z;
+ GLfloat a = ey*fz - ez*fy;
+ GLfloat b = ez*fx - ex*fz;
+ GLfloat ic = 1.0 / c;
+ GLfloat ac = a * ic;
+ GLfloat bc = b * ic;
+ if (ac < 0.0f) ac = -ac;
+ if (bc < 0.0f) bc = -bc;
+ offset += MAX2(ac, bc) * factor;
+ }
+ }
+#endif
+ }
+#endif
+
+ LOCK_HARDWARE(r128ctx);
+ if (r128ctx->regs.tex_cntl_c & (R128_TEXMAP_ENABLE |
+ R128_SEC_TEXMAP_ENABLE)) {
+ BEGIN_CLIP_LOOP(r128ctx);
+
+#if USE_RHW2
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 34);
+#else
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 31);
+#endif
+ R128CCE(R128_FULL_VERTEX_FORMAT);
+ R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST |
+ R128_CCE_VC_CNTL_PRIM_WALK_RING |
+ (3 << R128_CCE_VC_CNTL_NUM_SHIFT));
+
+ R128CCEF(v0->x);
+ R128CCEF(v0->y);
+#if (IND & R128_OFFSET_BIT)
+ R128CCEF(v0->z + offset);
+#else
+ R128CCEF(v0->z);
+#endif
+ R128CCEF(v0->rhw);
+
+#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT))
+ R128CCE(c0);
+#else
+ R128CCE(*(int *)&v0->dif_argb);
+#endif
+ R128CCE(*(int *)&v0->spec_frgb);
+
+ R128CCEF(v0->tu0);
+ R128CCEF(v0->tv0);
+ R128CCEF(v0->tu1);
+ R128CCEF(v0->tv1);
+#if USE_RHW2
+ R128CCEF(v0->rhw2);
+#endif
+
+ R128CCEF(v1->x);
+ R128CCEF(v1->y);
+#if (IND & R128_OFFSET_BIT)
+ R128CCEF(v1->z + offset);
+#else
+ R128CCEF(v1->z);
+#endif
+ R128CCEF(v1->rhw);
+
+#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT))
+ R128CCE(c1);
+#else
+ R128CCE(*(int *)&v1->dif_argb);
+#endif
+ R128CCE(*(int *)&v1->spec_frgb);
+
+ R128CCEF(v1->tu0);
+ R128CCEF(v1->tv0);
+ R128CCEF(v1->tu1);
+ R128CCEF(v1->tv1);
+#if USE_RHW2
+ R128CCEF(v1->rhw2);
+#endif
+
+ R128CCEF(v2->x);
+ R128CCEF(v2->y);
+#if (IND & R128_OFFSET_BIT)
+ R128CCEF(v2->z + offset);
+#else
+ R128CCEF(v2->z);
+#endif
+ R128CCEF(v2->rhw);
+
+#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT))
+ R128CCE(c2);
+#else
+ R128CCE(*(int *)&v2->dif_argb);
+#endif
+ R128CCE(*(int *)&v2->spec_frgb);
+
+ R128CCEF(v2->tu0);
+ R128CCEF(v2->tv0);
+ R128CCEF(v2->tu1);
+ R128CCEF(v2->tv1);
+#if USE_RHW2
+ R128CCEF(v2->rhw2);
+#endif
+
+ R128CCE_SUBMIT_PACKETS();
+
+ END_CLIP_LOOP(r128ctx);
+ } else {
+ BEGIN_CLIP_LOOP(r128ctx);
+
+ R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 13);
+ R128CCE(R128_CCE_VC_FRMT_DIFFUSE_ARGB);
+ R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST |
+ R128_CCE_VC_CNTL_PRIM_WALK_RING |
+ (3 << R128_CCE_VC_CNTL_NUM_SHIFT));
+
+ R128CCEF(v0->x);
+ R128CCEF(v0->y);
+#if (IND & R128_OFFSET_BIT)
+ R128CCEF(v0->z + offset);
+#else
+ R128CCEF(v0->z);
+#endif
+
+#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT))
+ R128CCE(c0);
+#else
+ R128CCE(*(int *)&v0->dif_argb);
+#endif
+
+ R128CCEF(v1->x);
+ R128CCEF(v1->y);
+#if (IND & R128_OFFSET_BIT)
+ R128CCEF(v1->z + offset);
+#else
+ R128CCEF(v1->z);
+#endif
+
+#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT))
+ R128CCE(c1);
+#else
+ R128CCE(*(int *)&v1->dif_argb);
+#endif
+
+ R128CCEF(v2->x);
+ R128CCEF(v2->y);
+#if (IND & R128_OFFSET_BIT)
+ R128CCEF(v2->z + offset);
+#else
+ R128CCEF(v2->z);
+#endif
+
+#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT))
+ R128CCE(c2);
+#else
+ R128CCE(*(int *)&v2->dif_argb);
+#endif
+
+ R128CCE_SUBMIT_PACKETS();
+
+ END_CLIP_LOOP(r128ctx);
+ }
+ UNLOCK_HARDWARE(r128ctx);
+}
+
+static void TAG(quad)(GLcontext *ctx,
+ GLuint v0, GLuint v1, GLuint v2, GLuint v3,
+ GLuint pv)
+{
+ TAG(triangle)(ctx, v0, v1, v3, pv);
+ TAG(triangle)(ctx, v1, v2, v3, pv);
+}
+
+#if ((IND & ~R128_FLAT_BIT) == 0)
+
+/* Draw a single line. Note that the device-dependent vertex data might
+ need to be changed based on the render state. */
+static void TAG(line)(GLcontext *ctx,
+ GLuint v0, GLuint v1,
+ GLuint pv)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ r128VertexPtr r128verts = R128_DRIVER_DATA(ctx->VB)->verts;
+ r128_vertex tmp0 = r128verts[v0].v;
+ r128_vertex tmp1 = r128verts[v1].v;
+ float width = ctx->Line.Width;
+
+ if (IND & R128_FLAT_BIT) {
+ *(int *)&tmp1.dif_argb =
+ *(int *)&tmp0.dif_argb =
+ *(int *)&r128verts[pv].v.dif_argb;
+ }
+
+ r128DrawLine(r128ctx, &tmp0, &tmp1, width);
+}
+
+/* Draw a set of points. Note that the device-dependent vertex data
+ might need to be changed based on the render state. */
+static void TAG(points)(GLcontext *ctx,
+ GLuint first, GLuint last)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ struct vertex_buffer *VB = ctx->VB;
+ r128VertexPtr r128verts = R128_DRIVER_DATA(VB)->verts;
+ GLfloat size = ctx->Point.Size * 0.5;
+ int i;
+
+ for(i = first; i <= last; i++) {
+ if(VB->ClipMask[i] == 0) {
+ r128_vertex *tmp = &r128verts[i].v;
+ r128DrawPoint(r128ctx, tmp, size);
+ }
+ }
+}
+
+#endif
+
+/* Initialize the table of primitives to render. */
+static void TAG(init)(void)
+{
+ tri_tab[IND] = TAG(triangle);
+ quad_tab[IND] = TAG(quad);
+
+#if ((IND & ~R128_FLAT_BIT) == 0)
+ line_tab[IND] = TAG(line);
+ points_tab[IND] = TAG(points);
+#endif
+}
+
+#undef IND
+#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_vb.c b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c
new file mode 100644
index 000000000..f14ec21bd
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c
@@ -0,0 +1,470 @@
+/* $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_reg.h"
+#include "r128_cce.h"
+#include "r128_state.h"
+#include "r128_vb.h"
+
+#include "stages.h"
+
+#define TEX0 \
+do { \
+ v->v.tu0 = tc0[i][0]; \
+ v->v.tv0 = tc0[i][1]; \
+} while (0)
+
+#define TEX1 \
+do { \
+ v->v.tu1 = tc1[i][0]; \
+ v->v.tv1 = tc1[i][1]; \
+} while (0)
+
+#define SPC \
+do { \
+ GLubyte *spec = &(VB->Spec[0][i][0]); \
+ v->v.spec_frgb.r = spec[0]; \
+ v->v.spec_frgb.g = spec[1]; \
+ v->v.spec_frgb.b = spec[2]; \
+} while (0)
+
+#define FOG \
+do { \
+ GLubyte *spec = &(VB->Spec[0][i][0]); \
+ v->v.spec_frgb.a = spec[3]; \
+} while (0)
+
+#define COL \
+do { \
+ GLubyte *col = &(VB->Color[0]->data[i][0]); \
+ v->v.dif_argb.a = col[3]; \
+ v->v.dif_argb.r = col[0]; \
+ v->v.dif_argb.g = col[1]; \
+ v->v.dif_argb.b = col[2]; \
+} while (0)
+
+#if 1
+/* FIXME: These are handled by the Rage 128 */
+#define TEX0_4
+#define TEX1_4
+#else
+#define TEX0_4 \
+do { \
+ if (VB->TexCoordPtr[0]->size == 4) { \
+ GLfloat (*tc)[4] = VB->TexCoordPtr[0]->data; \
+ v = &(R128_DRIVER_DATA(VB)->verts[start]); \
+ for (i = start; i < end; i++, v++) { \
+ float oow = 1.0 / tc[i][3]; \
+ v->v.rhw *= tc[i][3]; \
+ v->v.tu0 *= oow; \
+ v->v.tv0 *= oow; \
+ } \
+ } \
+} while (0)
+
+#if USE_RHW2
+#define TEX1_4 \
+do { \
+ if (VB->TexCoordPtr[1]->size == 4) { \
+ GLfloat (*tc)[4] = VB->TexCoordPtr[1]->data; \
+ v = &(R128_DRIVER_DATA(VB)->verts[start]); \
+ for (i = start; i < end; i++, v++) { \
+ float oow = 1.0 / tc[i][3]; \
+ v->v.rhw2 *= tc[i][3]; \
+ v->v.tu1 *= oow; \
+ v->v.tv1 *= oow; \
+ } \
+ } \
+} while (0)
+#else
+#define TEX1_4
+#endif
+#endif
+
+#if USE_RHW2
+#define COORD \
+do { \
+ GLfloat *win = VB->Win.data[i]; \
+ v->v.x = win[0]; \
+ v->v.y = r128height - win[1]; \
+ v->v.z = scale * win[2]; \
+ v->v.rhw = v->v.rhw2 = win[3]; \
+} while (0)
+#else
+#define COORD \
+do { \
+ GLfloat *win = VB->Win.data[i]; \
+ v->v.x = win[0]; \
+ v->v.y = r128height - win[1]; \
+ v->v.z = scale * win[2]; \
+ v->v.rhw = win[3]; \
+} while (0)
+#endif
+
+#define NOP
+
+/* Setup the r128 vertex buffer entries */
+#define SETUPFUNC(name,win,col,tex0,tex1,tex0_4,tex1_4,spec,fog) \
+static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \
+{ \
+ r128ContextPtr r128ctx = R128_CONTEXT(VB->ctx); \
+ __DRIdrawablePrivate *dPriv = r128ctx->driDrawable; \
+ r128VertexPtr v; \
+ GLfloat (*tc0)[4]; \
+ GLfloat (*tc1)[4]; \
+ GLfloat r128height = dPriv->h; \
+ GLfloat scale; \
+ int i; \
+ \
+ (void) r128height; (void) r128ctx; \
+ \
+ gl_import_client_data(VB, VB->ctx->RenderFlags, \
+ (VB->ClipOrMask \
+ ? VEC_WRITABLE | VEC_GOOD_STRIDE \
+ : VEC_GOOD_STRIDE)); \
+ \
+ switch (VB->ctx->Visual->DepthBits) { \
+ case 16: scale = 1.0 / 65536.0; break; \
+ case 24: scale = 1.0 / 16777216.0; break; \
+ case 32: scale = 1.0 / 4294967296.0; break; \
+ default: scale = 1.0 / 65536.0; break; \
+ } \
+ \
+ tc0 = VB->TexCoordPtr[0]->data; \
+ tc1 = VB->TexCoordPtr[1]->data; \
+ \
+ v = &(R128_DRIVER_DATA(VB)->verts[start]); \
+ \
+ if (VB->ClipOrMask == 0) \
+ for (i = start; i < end; i++, v++) { \
+ win; \
+ col; \
+ spec; \
+ fog; \
+ tex0; \
+ tex1; \
+ } \
+ else \
+ for (i = start; i < end; i++, v++) { \
+ if (VB->ClipMask[i] == 0) { \
+ win; \
+ spec; \
+ fog; \
+ tex0; \
+ tex1; \
+ } \
+ col; \
+ } \
+ tex0_4; \
+ tex1_4; \
+}
+
+
+SETUPFUNC(rs_wt0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, NOP, NOP)
+SETUPFUNC(rs_wt1, COORD, NOP, NOP, TEX1, NOP, TEX1_4, NOP, NOP)
+SETUPFUNC(rs_wt0t1, COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
+SETUPFUNC(rs_wft0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, NOP, FOG)
+SETUPFUNC(rs_wft1, COORD, NOP, NOP, TEX1, NOP, TEX1_4, NOP, FOG)
+SETUPFUNC(rs_wft0t1, COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
+SETUPFUNC(rs_wg, COORD, COL, NOP, NOP, NOP, NOP, NOP, NOP)
+SETUPFUNC(rs_wgs, COORD, COL, NOP, NOP, NOP, NOP, SPC, NOP)
+SETUPFUNC(rs_wgt0, COORD, COL, TEX0, NOP, TEX0_4, NOP, NOP, NOP)
+SETUPFUNC(rs_wgt1, COORD, COL, NOP, TEX1, NOP, TEX1_4, NOP, NOP)
+SETUPFUNC(rs_wgt0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
+SETUPFUNC(rs_wgst0, COORD, COL, TEX0, NOP, TEX0_4, NOP, SPC, NOP)
+SETUPFUNC(rs_wgst1, COORD, COL, NOP, TEX1, NOP, TEX1_4, SPC, NOP)
+SETUPFUNC(rs_wgst0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, NOP)
+SETUPFUNC(rs_wgf, COORD, COL, NOP, NOP, NOP, NOP, NOP, FOG)
+SETUPFUNC(rs_wgfs, COORD, COL, NOP, NOP, NOP, NOP, SPC, FOG)
+SETUPFUNC(rs_wgft0, COORD, COL, TEX0, NOP, TEX0_4, NOP, NOP, FOG)
+SETUPFUNC(rs_wgft1, COORD, COL, NOP, TEX1, NOP, TEX1_4, NOP, FOG)
+SETUPFUNC(rs_wgft0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
+SETUPFUNC(rs_wgfst0, COORD, COL, TEX0, NOP, TEX0_4, NOP, SPC, FOG)
+SETUPFUNC(rs_wgfst1 , COORD, COL, NOP, TEX1, NOP, TEX1_4, SPC, FOG)
+SETUPFUNC(rs_wgfst0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, FOG)
+
+SETUPFUNC(rs_t0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, NOP, NOP)
+SETUPFUNC(rs_t1, NOP, NOP, NOP, TEX1, NOP, TEX1_4, NOP, NOP)
+SETUPFUNC(rs_t0t1, NOP, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
+SETUPFUNC(rs_f, NOP, NOP, NOP, NOP, NOP, NOP, NOP, FOG)
+SETUPFUNC(rs_ft0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, NOP, FOG)
+SETUPFUNC(rs_ft1, NOP, NOP, NOP, TEX1, NOP, TEX1_4, NOP, FOG)
+SETUPFUNC(rs_ft0t1, NOP, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
+SETUPFUNC(rs_g, NOP, COL, NOP, NOP, NOP, NOP, NOP, NOP)
+SETUPFUNC(rs_gs, NOP, COL, NOP, NOP, NOP, NOP, SPC, NOP)
+SETUPFUNC(rs_gt0, NOP, COL, TEX0, NOP, TEX0_4, NOP, NOP, NOP)
+SETUPFUNC(rs_gt1, NOP, COL, NOP, TEX1, NOP, TEX1_4, NOP, NOP)
+SETUPFUNC(rs_gt0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
+SETUPFUNC(rs_gst0, NOP, COL, TEX0, NOP, TEX0_4, NOP, SPC, NOP)
+SETUPFUNC(rs_gst1, NOP, COL, NOP, TEX1, NOP, TEX1_4, SPC, NOP)
+SETUPFUNC(rs_gst0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, NOP)
+SETUPFUNC(rs_gf, NOP, COL, NOP, NOP, NOP, NOP, NOP, FOG)
+SETUPFUNC(rs_gfs, NOP, COL, NOP, NOP, NOP, NOP, SPC, FOG)
+SETUPFUNC(rs_gft0, NOP, COL, TEX0, NOP, TEX0_4, NOP, NOP, FOG)
+SETUPFUNC(rs_gft1, NOP, COL, NOP, TEX1, NOP, TEX1_4, NOP, FOG)
+SETUPFUNC(rs_gft0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
+SETUPFUNC(rs_gfst0, NOP, COL, TEX0, NOP, TEX0_4, NOP, SPC, FOG)
+SETUPFUNC(rs_gfst1, NOP, COL, NOP, TEX1, NOP, TEX1_4, SPC, FOG)
+SETUPFUNC(rs_gfst0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, FOG)
+
+static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end)
+{
+ fprintf(stderr, "r128RasterSetup(): invalid setup function\n");
+}
+
+typedef void (*setupFunc)(struct vertex_buffer *, GLuint, GLuint);
+static setupFunc setup_func[0x80];
+
+/* Initialize the table of vertex buffer setup functions */
+void r128SetupInit(void)
+{
+ int i;
+
+ for (i = 0; i < 0x80; i++) setup_func[i] = rs_invalid;
+
+ /* Funcs to build vertices from scratch */
+ setup_func[R128_WIN_BIT|R128_TEX0_BIT] = rs_wt0;
+ setup_func[R128_WIN_BIT|R128_TEX1_BIT] = rs_wt1;
+ setup_func[R128_WIN_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wt0t1;
+ setup_func[R128_WIN_BIT|R128_FOG_BIT|R128_TEX0_BIT] = rs_wft0;
+ setup_func[R128_WIN_BIT|R128_FOG_BIT|R128_TEX1_BIT] = rs_wft1;
+ setup_func[R128_WIN_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wft0t1;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT] = rs_wg;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT] = rs_wgs;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX0_BIT] = rs_wgt0;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX1_BIT] = rs_wgt1;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgt0t1;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_wgst0;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX1_BIT] = rs_wgst1;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgst0t1;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT] = rs_wgf;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT] = rs_wgfs;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT] = rs_wgft0;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX1_BIT] = rs_wgft1;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgft0t1;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_wgfst0;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX1_BIT] = rs_wgfst1;
+ setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgfst0t1;
+
+ /* Funcs to repair vertices */
+ setup_func[R128_TEX0_BIT] = rs_t0;
+ setup_func[R128_TEX1_BIT] = rs_t1;
+ setup_func[R128_TEX0_BIT|R128_TEX1_BIT] = rs_t0t1;
+ setup_func[R128_FOG_BIT] = rs_f;
+ setup_func[R128_FOG_BIT|R128_TEX0_BIT] = rs_ft0;
+ setup_func[R128_FOG_BIT|R128_TEX1_BIT] = rs_ft1;
+ setup_func[R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_ft0t1;
+ setup_func[R128_RGBA_BIT] = rs_g;
+ setup_func[R128_RGBA_BIT|R128_SPEC_BIT] = rs_gs;
+ setup_func[R128_RGBA_BIT|R128_TEX0_BIT] = rs_gt0;
+ setup_func[R128_RGBA_BIT|R128_TEX1_BIT] = rs_gt1;
+ setup_func[R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gt0t1;
+ setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_gst0;
+ setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX1_BIT] = rs_gst1;
+ setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gst0t1;
+ setup_func[R128_RGBA_BIT|R128_FOG_BIT] = rs_gf;
+ setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT] = rs_gfs;
+ setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT] = rs_gft0;
+ setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_TEX1_BIT] = rs_gft1;
+ setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gft0t1;
+ setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_gfst0;
+ setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX1_BIT] = rs_gfst1;
+ setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gfst0t1;
+}
+
+/* Initialize the vertex buffer setup functions based on the current
+ rendering state */
+void r128ChooseRasterSetupFunc(GLcontext *ctx)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ int funcIndex = R128_WIN_BIT | R128_RGBA_BIT;
+
+ if (ctx->Texture.Enabled & 0xf) {
+ if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE)
+ funcIndex &= ~R128_RGBA_BIT;
+ funcIndex |= R128_TEX0_BIT;
+ }
+
+ if (ctx->Texture.Enabled & 0xf0)
+ funcIndex |= R128_TEX1_BIT;
+
+ /* FIXME: Verify this works properly */
+ if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+ funcIndex |= R128_SPEC_BIT;
+
+ if (ctx->FogMode == FOG_FRAGMENT)
+ funcIndex |= R128_FOG_BIT;
+
+ r128ctx->SetupIndex = funcIndex;
+ ctx->Driver.RasterSetup = setup_func[funcIndex];
+}
+
+/* Check to see if any updates of the vertex buffer entries are needed */
+void r128CheckPartialRasterSetup(GLcontext *ctx,
+ struct gl_pipeline_stage *s)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ int tmp = r128ctx->SetupDone;
+
+ s->type = 0;
+ r128ctx->SetupDone = GL_FALSE;
+
+ if ((ctx->Array.Summary & VERT_OBJ_ANY) == 0) return;
+ if (ctx->IndirectTriangles) return;
+
+ r128ctx->SetupDone = tmp;
+}
+
+/* Update the vertex buffer entries, if necessary */
+void r128PartialRasterSetup(struct vertex_buffer *VB)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(VB->ctx);
+ int new = VB->pipeline->new_outputs;
+ int available = VB->pipeline->outputs;
+ int index = 0;
+
+ if (new & VERT_WIN) {
+ new = available;
+ index |= R128_WIN_BIT | R128_FOG_BIT;
+ }
+
+ if (new & VERT_RGBA) index |= R128_RGBA_BIT | R128_SPEC_BIT;
+ if (new & VERT_TEX0_ANY) index |= R128_TEX0_BIT;
+ if (new & VERT_TEX1_ANY) index |= R128_TEX1_BIT;
+#if 0
+ /* FIXME */
+ if (new & VERT_FOG_COORD) index |= R128_FOG_BIT;
+#endif
+
+ r128ctx->SetupDone &= ~index;
+ index &= r128ctx->SetupIndex;
+ r128ctx->SetupDone |= index;
+
+ if (index) setup_func[index & ~R128_ALPHA_BIT](VB, VB->Start, VB->Count);
+}
+
+/* Perform the raster setup for the fast path, if using CVA */
+void r128DoRasterSetup(struct vertex_buffer *VB)
+{
+ GLcontext *ctx = VB->ctx;
+
+ if (VB->Type == VB_CVA_PRECALC) r128PartialRasterSetup(VB);
+ else if (ctx->Driver.RasterSetup) ctx->Driver.RasterSetup(VB,
+ VB->CopyStart,
+ VB->Count);
+}
+
+/* Resize an existing vertex buffer */
+void r128ResizeVB(struct vertex_buffer *VB, GLuint size)
+{
+ r128VertexBufferPtr r128vb = R128_DRIVER_DATA(VB);
+
+ while (r128vb->size < size)
+ r128vb->size *= 2;
+
+ free(r128vb->vert_store);
+ r128vb->vert_store = malloc(sizeof(r128Vertex) * r128vb->size + 31);
+ if (!r128vb->vert_store) {
+ fprintf(stderr, "Cannot allocate vertex store! Exiting...\n");
+ exit(1);
+ }
+
+ r128vb->verts = (r128VertexPtr)(((CARD32)r128vb->vert_store + 31) & ~31);
+
+ gl_vector1ui_free(&r128vb->clipped_elements);
+ gl_vector1ui_alloc(&r128vb->clipped_elements,
+ VEC_WRITABLE, r128vb->size, 32);
+ if (!r128vb->clipped_elements.start) {
+ fprintf(stderr, "Cannot allocate clipped elements! Exiting...\n");
+ exit(1);
+ }
+
+ free(VB->ClipMask);
+ VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * r128vb->size);
+ if (!VB->ClipMask) {
+ fprintf(stderr, "Cannot allocate clipmask! Exiting...\n");
+ exit(1);
+ }
+}
+
+/* Create a new device-dependent vertex buffer */
+void r128DDRegisterVB(struct vertex_buffer *VB)
+{
+ r128VertexBufferPtr r128vb;
+
+ r128vb = (r128VertexBufferPtr)calloc(1, sizeof(*r128vb));
+
+ r128vb->size = VB->Size * 2;
+ r128vb->vert_store = malloc(sizeof(r128Vertex) * r128vb->size + 31);
+ if (!r128vb->vert_store) {
+ fprintf(stderr, "Cannot allocate vertex store! Exiting...\n");
+ exit(1);
+ }
+
+ r128vb->verts = (r128VertexPtr)(((CARD32)r128vb->vert_store + 31) & ~31);
+
+ gl_vector1ui_alloc(&r128vb->clipped_elements,
+ VEC_WRITABLE, r128vb->size, 32);
+ if (!r128vb->clipped_elements.start) {
+ fprintf(stderr, "Cannot allocate clipped elements! Exiting...\n");
+ exit(1);
+ }
+
+ free(VB->ClipMask);
+ VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * r128vb->size);
+ if (!VB->ClipMask) {
+ fprintf(stderr, "Cannot allocate clipmask! Exiting...\n");
+ exit(1);
+ }
+
+ VB->driver_data = r128vb;
+}
+
+/* Destroy a device-dependent vertex buffer */
+void r128DDUnregisterVB(struct vertex_buffer *VB)
+{
+ r128VertexBufferPtr r128vb = R128_DRIVER_DATA(VB);
+
+ if (r128vb) {
+ if (r128vb->vert_store) free(r128vb->vert_store);
+ gl_vector1ui_free(&r128vb->clipped_elements);
+ free(r128vb);
+ VB->driver_data = 0;
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_vb.h b/xc/lib/GL/mesa/src/drv/r128/r128_vb.h
new file mode 100644
index 000000000..4f7c11d7f
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.h
@@ -0,0 +1,150 @@
+/* $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_VB_H_
+#define _R128_VB_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+#define USE_RHW2 0
+
+/* FIXME: This is endian-specific */
+typedef struct {
+ GLubyte b;
+ GLubyte g;
+ GLubyte r;
+ GLubyte a;
+} r128Color;
+
+typedef struct {
+ GLfloat x, y, z; /* Coordinates in screen space */
+ GLfloat rhw; /* Reciprocal homogeneous w */
+ r128Color dif_argb; /* Diffuse color */
+ r128Color spec_frgb; /* Specular color (alpha is fog) */
+ GLfloat tu0, tv0; /* Texture 0 coordinates */
+ GLfloat tu1, tv1; /* Texture 1 coordinates */
+#if USE_RHW2
+ GLfloat rhw2; /* Reciprocal homogeneous w */
+#endif
+} r128_vertex;
+
+#if USE_RHW2
+/* Format of vertices in r128_vertex struct */
+#define R128_FULL_VERTEX_FORMAT \
+ R128_CCE_VC_FRMT_RHW | \
+ R128_CCE_VC_FRMT_DIFFUSE_ARGB | \
+ R128_CCE_VC_FRMT_SPEC_FRGB | \
+ R128_CCE_VC_FRMT_S_T | \
+ R128_CCE_VC_FRMT_S2_T2 | \
+ R128_CCE_VC_FRMT_RHW2
+
+/* Send a single vertex to the ring buffer */
+#define R128CCE_SEND_VERTEX(v) \
+ do { \
+ R128CCEF((v)->x); \
+ R128CCEF((v)->y); \
+ R128CCEF((v)->z); \
+ R128CCEF((v)->rhw); \
+ R128CCE(*(int *)&(v)->dif_argb); \
+ R128CCE(*(int *)&(v)->spec_frgb); \
+ R128CCEF((v)->tu0); \
+ R128CCEF((v)->tv0); \
+ R128CCEF((v)->tu1); \
+ R128CCEF((v)->tv1); \
+ R128CCEF((v)->rhw2); \
+ } while (0)
+
+#else /* !USE_RHW2 */
+
+/* Format of vertices in r128_vertex struct */
+#define R128_FULL_VERTEX_FORMAT \
+ R128_CCE_VC_FRMT_RHW | \
+ R128_CCE_VC_FRMT_DIFFUSE_ARGB | \
+ R128_CCE_VC_FRMT_SPEC_FRGB | \
+ R128_CCE_VC_FRMT_S_T | \
+ R128_CCE_VC_FRMT_S2_T2
+
+/* Send a single vertex to the ring buffer */
+#define R128CCE_SEND_VERTEX(v) \
+ do { \
+ R128CCEF((v)->x); \
+ R128CCEF((v)->y); \
+ R128CCEF((v)->z); \
+ R128CCEF((v)->rhw); \
+ R128CCE(*(int *)&(v)->dif_argb); \
+ R128CCE(*(int *)&(v)->spec_frgb); \
+ R128CCEF((v)->tu0); \
+ R128CCEF((v)->tv0); \
+ R128CCEF((v)->tu1); \
+ R128CCEF((v)->tv1); \
+ } while (0)
+#endif
+
+/* FIXME: We currently only have assembly for 16-stride vertices */
+typedef union {
+ r128_vertex v;
+ float f[16];
+} r128Vertex, *r128VertexPtr;
+
+/* Vertex buffer for use when on the fast path */
+typedef struct {
+ GLuint size; /* Number of vertices in store */
+ void *vert_store; /* Storage for vertex buffer */
+ r128VertexPtr verts; /* Aligned start of verts in storage */
+ int last_vert; /* Index of last vertex used */
+ GLvector1ui clipped_elements; /* List of clipped elements */
+} *r128VertexBufferPtr;
+
+#define R128_DRIVER_DATA(vb) ((r128VertexBufferPtr)((vb)->driver_data))
+
+#define R128_SPEC_BIT 0x01
+#define R128_FOG_BIT 0x02
+#define R128_ALPHA_BIT 0x04 /* GL_BLEND, not used */
+#define R128_TEX1_BIT 0x08
+#define R128_TEX0_BIT 0x10
+#define R128_RGBA_BIT 0x20
+#define R128_WIN_BIT 0x40
+
+extern void r128SetupInit(void);
+extern void r128ChooseRasterSetupFunc(GLcontext *ctx);
+extern void r128CheckPartialRasterSetup(GLcontext *ctx,
+ struct gl_pipeline_stage *s);
+extern void r128PartialRasterSetup(struct vertex_buffer *VB);
+extern void r128DoRasterSetup(struct vertex_buffer *VB);
+extern void r128ResizeVB(struct vertex_buffer *VB, GLuint size);
+extern void r128DDRegisterVB(struct vertex_buffer *VB);
+extern void r128DDUnregisterVB(struct vertex_buffer *VB);
+
+#endif
+#endif /* _R128_VB_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..60d528813
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c
@@ -0,0 +1,257 @@
+/* $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 Mesa driver includes */
+#include "r128_init.h"
+#include "r128_context.h"
+#include "r128_xmesa.h"
+#include "r128_state.h"
+#include "r128_tex.h"
+#include "r128_swap.h"
+
+/* Mesa src includes */
+#include "context.h"
+#include "simple_list.h"
+#include "mmath.h"
+
+#ifndef R128_DEBUG_FLAGS
+int R128_DEBUG_FLAGS = (0
+#if 0
+ | DEBUG_ALWAYS_SYNC
+ | DEBUG_VERBOSE_CCE
+ | DEBUG_VERBOSE_OUTREG
+ | DEBUG_VERBOSE_MSG
+ | DEBUG_NO_OUTRING
+ | DEBUG_NO_OUTREG
+ | DEBUG_VERBOSE_API
+ | DEBUG_VERBOSE_2D
+ | DEBUG_VERBOSE_DRI
+ | DEBUG_VALIDATE_RING
+ | DEBUG_VERBOSE_IOCTL
+#endif
+ );
+#endif
+
+#if DEBUG_LOCKING
+char *prevLockFile = NULL;
+int prevLockLine = 0;
+#endif
+
+static r128ContextPtr r128Context = NULL;
+
+
+/* Initialize the driver specific screen private data */
+GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
+{
+ sPriv->private = (void *)r128CreateScreen(sPriv);
+ if (!sPriv->private) {
+ r128DestroyScreen(sPriv);
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+/* Reset the driver specific screen private data */
+void XMesaResetDriver(__DRIscreenPrivate *sPriv)
+{
+ r128DestroyScreen(sPriv);
+}
+
+/* Create and initialize the Mesa and driver specific visual data */
+GLvisual *XMesaCreateVisual(Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ const XVisualInfo *visinfo,
+ const __GLXvisualConfig *config)
+{
+ /* Drivers may change the args to _mesa_create_visual() in order to
+ * setup special visuals.
+ */
+ return _mesa_create_visual(config->rgba,
+ config->doubleBuffer,
+ config->stereo,
+ _mesa_bitcount(visinfo->red_mask),
+ _mesa_bitcount(visinfo->green_mask),
+ _mesa_bitcount(visinfo->blue_mask),
+ config->alphaSize,
+ 0, /* index bits */
+ config->depthSize,
+ config->stencilSize,
+ config->accumRedSize,
+ config->accumGreenSize,
+ config->accumBlueSize,
+ config->accumAlphaSize,
+ 0 /* num samples */);
+}
+
+/* Create and initialize the Mesa and driver specific context data */
+GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis,
+ __DRIcontextPrivate *driContextPriv)
+{
+ return r128CreateContext(dpy, mesaVis, driContextPriv);
+}
+
+/* Destroy the Mesa and driver specific context data */
+void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ r128ContextPtr r128ctx = (r128ContextPtr)driContextPriv->driverPrivate;
+
+ if (r128ctx == (void *)r128Context) r128Context = NULL;
+ r128DestroyContext(r128ctx);
+}
+
+/* Create and initialize the Mesa and driver specific pixmap buffer data */
+GLframebuffer *XMesaCreateWindowBuffer(Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ GLvisual *mesaVis)
+{
+ return gl_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->StencilBits > 0,
+ mesaVis->AccumRedBits > 0,
+ mesaVis->AlphaBits > 0
+ );
+}
+
+/* Create and initialize the Mesa and driver specific pixmap buffer data */
+GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ GLvisual *mesaVis)
+{
+#if 0
+ /* Different drivers may have different combinations of hardware and
+ * software ancillary buffers.
+ */
+ return gl_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->StencilBits > 0,
+ mesaVis->AccumRedBits > 0,
+ mesaVis->AlphaBits > 0);
+#else
+ return NULL; /* not implemented yet */
+#endif
+}
+
+/* Copy the back color buffer to the front color buffer */
+void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
+{
+ /* FIXME: This assumes buffer is currently bound to a context. This
+ needs to be able to swap buffers when not currently bound. Also,
+ this needs to swap according to buffer, and NOT according to
+ context! */
+ if (r128Context == NULL) return;
+
+ /* Only swap buffers when a back buffer exists */
+ if (R128_MESACTX(r128Context)->Visual->DBflag) {
+ FLUSH_VB(R128_MESACTX(r128Context), "swap buffers");
+ r128SwapBuffers(r128Context);
+ }
+}
+
+/* Force the context `c' to be the current context and associate with it
+ buffer `b' */
+GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (driContextPriv) {
+ r128ContextPtr r128ctx = (r128ContextPtr)driContextPriv->driverPrivate;
+
+ if (r128Context &&
+ r128ctx == (void *)r128Context &&
+ driDrawPriv == R128_DRIDRAWABLE(r128Context))
+ return GL_TRUE;
+
+ r128Context = r128MakeCurrent(r128Context, r128ctx, driDrawPriv);
+
+ gl_make_current2(R128_MESACTX(r128Context),
+ driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer);
+
+ if (!R128_MESACTX(r128Context)->Viewport.Width) {
+ gl_Viewport(R128_MESACTX(r128Context), 0, 0,
+ driDrawPriv->w, driDrawPriv->h);
+ }
+ } else {
+ gl_make_current(0,0);
+ r128Context = NULL;
+ }
+
+ return GL_TRUE;
+}
+
+/* Force the context `c' to be unbound from its buffer */
+GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv)
+{
+ return GL_TRUE;
+}
+
+/* Update the hardware state. This is called if another context has
+ grabbed the hardware lock, which includes the X server. This
+ function also updates the driver's window state after the X server
+ moves, resizes or restacks a window -- the change will be reflected
+ in the drawable position and clip rects. Since the X server grabs
+ the hardware lock when it changes the window state, this routine will
+ automatically be called after such a change. */
+/* NOTE: This routine is only called while holding the hardware lock. */
+void XMesaUpdateState(__DRIcontextPrivate *driContextPriv)
+{
+ r128ContextPtr r128ctx = driContextPriv->driverPrivate;
+ __DRIscreenPrivate *sPriv = R128_DRISCREEN(r128ctx);
+ __DRIdrawablePrivate *dPriv = R128_DRIDRAWABLE(r128ctx);
+ int stamp = dPriv->lastStamp;
+
+ /* The window might have moved, so we might need to get new clip
+ rects.
+
+ NOTE: This releases and regrabs the hw lock to allow the X server
+ to respond to the DRI protocol request for new drawable info.
+ Since the hardware state depends on having the latest drawable
+ clip rects, all state checking must be done _after_ this call. */
+ XMESA_VALIDATE_DRAWABLE_INFO(r128ctx->display, sPriv, dPriv);
+
+ r128UpdateState(r128ctx, (stamp != dPriv->lastStamp));
+}
+
+/* This function is called by libGL.so as soon as libGL.so is loaded.
+ * This is where we'd register new extension functions with the dispatcher.
+ */
+void __driRegisterExtensions(void)
+{
+}
+
+#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..ca6fc127b
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.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_XMESA_H_
+#define _R128_XMESA_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void XMesaUpdateState(__DRIcontextPrivate *driContextPriv);
+extern void __driRegisterExtensions(void);
+
+#endif
+#endif /* _R128_XMESA_H_ */
diff --git a/xc/programs/Xserver/GL/dri/dri.c b/xc/programs/Xserver/GL/dri/dri.c
index a4b2684d5..652ecb822 100644
--- a/xc/programs/Xserver/GL/dri/dri.c
+++ b/xc/programs/Xserver/GL/dri/dri.c
@@ -115,7 +115,7 @@ DRIScreenInit(
fd = drmOpen(pDRIInfo->drmDriverName, NULL);
if (fd < 0) {
/* failed to open DRM */
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = 0;
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
return FALSE;
}
@@ -128,7 +128,7 @@ DRIScreenInit(
pDRIPriv = (DRIScreenPrivPtr) xalloc(sizeof(DRIScreenPrivRec));
if (!pDRIPriv) {
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = 0;
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
return FALSE;
}
@@ -140,6 +140,7 @@ DRIScreenInit(
if (drmSetBusid(pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString) < 0) {
pDRIPriv->directRenderingSupport = FALSE;
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
drmClose(pDRIPriv->drmFD);
return FALSE;
}
@@ -158,6 +159,7 @@ DRIScreenInit(
&pDRIPriv->hSAREA) < 0)
{
pDRIPriv->directRenderingSupport = FALSE;
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
drmClose(pDRIPriv->drmFD);
return FALSE;
}
@@ -171,6 +173,7 @@ DRIScreenInit(
(drmAddressPtr)(&pDRIPriv->pSAREA)) < 0)
{
pDRIPriv->directRenderingSupport = FALSE;
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
drmClose(pDRIPriv->drmFD);
return FALSE;
}
@@ -185,6 +188,7 @@ DRIScreenInit(
&pDRIPriv->hFrameBuffer) < 0)
{
pDRIPriv->directRenderingSupport = FALSE;
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize);
drmClose(pDRIPriv->drmFD);
return FALSE;
diff --git a/xc/programs/Xserver/Imakefile b/xc/programs/Xserver/Imakefile
index 45300d897..0305b16ce 100644
--- a/xc/programs/Xserver/Imakefile
+++ b/xc/programs/Xserver/Imakefile
@@ -619,7 +619,7 @@ XF86IDRVOBJS = $(XF86SRC)/input/drvConf.o
XF86IDRVLIBS = $(XF86IDRIVERLIB)
XF86SCANLIB = $(XF86SRC)/scanpci/LibraryTargetName(scanpci)
XF86LIBS = $(XF86INIT) $(XF86COMLIB) $(XF86RACLIB) $(XF86PARSLIB) \
- $(XF86OSLIB) $(XF86INT10LIB)
+ $(XF86OSLIB) $(XF86INT10LIB) $(XF86DDCLIB)
#else
XF86LIBS = $(XF86INIT) $(XF86COMLIB) $(XF86PARSLIB) $(XF86OSLIB)
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml
index 0a30e3474..21f1fb789 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml
@@ -1,7 +1,6 @@
<!doctype linuxdoc system>
<!-- Created: Sun Mar 12 13:00:00 2000 by brian@precisioninsight.com -->
-<!-- Revised: Thu Mar 23 10:00:00 2000 by brian@precisioninsight.com -->
-<!-- $Id: DRIcomp.sgml,v 1.6 2000/04/05 18:32:45 brianp Exp $ -->
+<!-- Revised: Wed May 17 22:42:18 2000 by martin@valinux.com -->
<article>
@@ -9,7 +8,7 @@
<author>
<htmlurl url="http://www.precisioninsight.com/"
name="Precision Insight, Inc.">
- <date>$Date: 2000/04/05 18:32:45 $
+ <date>Last modified on: 17 May 2000
<toc>
@@ -485,5 +484,3 @@
<!-- Local Variables: -->
<!-- fill-column: 72 -->
<!-- End: -->
-
-
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile
index e3f7178bf..8f0f33a35 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile
@@ -6,9 +6,16 @@ XCOMM
#define IHaveModules
#include <Server.tmpl>
-SRCS = r128_driver.c r128_cursor.c r128_accel.c # r128_i2c.c
+#if BuildXF86DRI
+DRISRCS = r128_dri.c
+DRIOBJS = r128_dri.o
+DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri
+DRIDEFINES = $(GLX_DEFINES)
+#endif
+
+SRCS = r128_driver.c r128_cursor.c r128_accel.c $(DRISRCS) # r128_i2c.c
-OBJS = r128_driver.o r128_cursor.o r128_accel.o # r128_i2c.o
+OBJS = r128_driver.o r128_cursor.o r128_accel.o $(DRIOBJS) # r128_i2c.o
#if defined(XF86DriverSDK)
INCLUDES = -I. -I../../include
@@ -22,9 +29,12 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
-I$(XF86SRC)/ddc -I$(XF86SRC)/i2c -I$(XF86OSSRC)/vbe \
-I$(XF86SRC)/int10 -I$(SERVERSRC)/Xext \
-I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
- -I$(EXTINCSRC) -I$(XF86SRC)/xf24_32bpp
+ -I$(EXTINCSRC) -I$(XF86SRC)/xf24_32bpp \
+ $(DRIINCLUDES)
#endif
+DEFINES = $(DRIDEFINES)
+
#if MakeHasPosixVariableSubstitutions
SubdirLibraryRule($(OBJS))
#endif
@@ -49,5 +59,10 @@ InstallDriverSDKNonExecFile(r128_cursor.c,$(DRIVERSDKDIR)/drivers/r128)
InstallDriverSDKNonExecFile(r128_driver.c,$(DRIVERSDKDIR)/drivers/r128)
InstallDriverSDKNonExecFile(r128_reg.h,$(DRIVERSDKDIR)/drivers/r128)
+InstallDriverSDKNonExecFile(r128_dri.c,$(DRIVERSDKDIR)/drivers/r128)
+InstallDriverSDKNonExecFile(r128_dri.h,$(DRIVERSDKDIR)/drivers/r128)
+InstallDriverSDKNonExecFile(r128_dripriv.h,$(DRIVERSDKDIR)/drivers/r128)
+InstallDriverSDKNonExecFile(r128_sarea.h,$(DRIVERSDKDIR)/drivers/r128)
+
InstallDriverSDKObjectModule(r128,$(DRIVERSDKMODULEDIR),drivers)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h
index d5d120153..acb04f96e 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h
@@ -1,8 +1,8 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h,v 1.8 2000/02/23 04:47:18 martin Exp $ */
/**************************************************************************
-Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+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
@@ -40,6 +40,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R128_TIMEOUT 2000000 /* Fall out of wait loops after this count */
#define R128_MMIOSIZE 0x80000
+ /* R128_NAME is used for the server-side
+ ddx driver, the client-side DRI driver,
+ and the kernel-level DRM driver. */
#define R128_NAME "r128"
#define R128_VERSION_MAJOR 3
#define R128_VERSION_MINOR 0
@@ -157,7 +160,7 @@ typedef struct {
unsigned char *FB; /* Map of frame buffer */
CARD32 MemCntl;
- CARD32 BusCntl;
+ CARD32 BusCntl;
unsigned long FbMapSize; /* Size of frame buffer, in bytes */
int Flags; /* Saved copy of mode flags */
@@ -168,6 +171,8 @@ typedef struct {
R128SaveRec ModeReg; /* Current mode */
Bool (*CloseScreen)(int, ScreenPtr);
+ Bool PaletteSavedOnVT; /* Palette saved on last VT switch */
+
I2CBusPtr i2c;
XAAInfoRecPtr accel;
xf86CursorInfoPtr cursor;
@@ -199,8 +204,98 @@ typedef struct {
int scanline_words;
int scanline_direct;
int scanline_bpp; /* Only used for ImageWrite */
+
+#ifdef XF86DRI
+ Bool directRenderingEnabled;
+ DRIInfoPtr pDRIInfo;
+ int drmFD;
+ int numVisualConfigs;
+ __GLXvisualConfig *pVisualConfigs;
+ R128ConfigPrivPtr pVisualConfigsPriv;
+
+ drmHandle fbHandle;
+
+ drmSize registerSize;
+ drmHandle registerHandle;
+
+ Bool IsPCI; /* Current card is a PCI card */
+
+ drmSize agpSize;
+ drmHandle agpMemHandle; /* Handle from drmAgpAlloc */
+ unsigned long agpOffset;
+ unsigned char *AGP; /* Map */
+ int agpMode;
+
+ Bool CCEInUse; /* CCE is currently active */
+ int CCEMode; /* CCE mode that server/clients use */
+ int CCEFifoSize; /* Size of the CCE command FIFO */
+ Bool CCESecure; /* CCE security enabled */
+ int CCEusecTimeout; /* CCE timeout in usecs */
+ Bool CCE2D; /* CCE is used for X server 2D prims */
+
+ /* CCE ring buffer data */
+ unsigned long ringStart; /* Offset into AGP space */
+ drmHandle ringHandle; /* Handle from drmAddMap */
+ drmSize ringMapSize; /* Size of map */
+ int ringSize; /* Size of ring (in MB) */
+ unsigned char *ring; /* Map */
+ int ringSizeLog2QW;
+
+ unsigned long ringReadOffset; /* Offset into AGP space */
+ drmHandle ringReadPtrHandle; /* Handle from drmAddMap */
+ drmSize ringReadMapSize; /* Size of map */
+ unsigned char *ringReadPtr; /* Map */
+
+ /* CCE vertex buffer data */
+ unsigned long vbStart; /* Offset into AGP space */
+ drmHandle vbHandle; /* Handle from drmAddMap */
+ drmSize vbMapSize; /* Size of map */
+ int vbSize; /* Size of vert bufs (in MB) */
+ unsigned char *vb; /* Map */
+ int vbBufSize; /* Size of individual vert buf */
+ int vbNumBufs; /* Number of vert bufs */
+ drmBufMapPtr vbBufs; /* Buffer map */
+
+ /* CCE indirect buffer data */
+ unsigned long indStart; /* Offset into AGP space */
+ drmHandle indHandle; /* Handle from drmAddMap */
+ drmSize indMapSize; /* Size of map */
+ int indSize; /* Size of indirect bufs (in MB) */
+ unsigned char *ind; /* Map */
+
+ /* CCE AGP Texture data */
+ unsigned long agpTexStart; /* Offset into AGP space */
+ drmHandle agpTexHandle; /* Handle from drmAddMap */
+ drmSize agpTexMapSize; /* Size of map */
+ int agpTexSize; /* Size of AGP tex space (in MB) */
+ unsigned char *agpTex; /* Map */
+ int log2AGPTexGran;
+
+ /* DRI screen private data */
+ int fbX;
+ int fbY;
+ int backX;
+ int backY;
+ int depthX;
+ int depthY;
+ int textureX;
+ int textureY;
+ int textureSize;
+ int log2TexGran;
+#endif
} R128InfoRec, *R128InfoPtr;
+#define R128WaitForFifo(pScrn, entries) \
+do { \
+ if (info->fifo_slots < entries) R128WaitForFifoFunction(pScrn, entries); \
+ info->fifo_slots -= entries; \
+} while (0)
+
+extern void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries);
+extern void R128WaitForIdle(ScrnInfoPtr pScrn);
+extern void R128EngineReset(ScrnInfoPtr pScrn);
+extern void R128EngineFlush(ScrnInfoPtr pScrn);
+
extern int INPLL(ScrnInfoPtr pScrn, int addr);
extern void R128WaitForVerticalSync(ScrnInfoPtr pScrn);
@@ -208,4 +303,16 @@ extern Bool R128AccelInit(ScreenPtr pScreen);
extern void R128EngineInit(ScrnInfoPtr pScrn);
extern Bool R128CursorInit(ScreenPtr pScreen);
+extern int R128MinBits(int val);
+
+#ifdef XF86DRI
+extern Bool R128DRIScreenInit(ScreenPtr pScreen);
+extern void R128DRICloseScreen(ScreenPtr pScreen);
+extern Bool R128DRIFinishScreenInit(ScreenPtr pScreen);
+extern void R128CCEStart(ScrnInfoPtr pScrn);
+extern void R128CCEStop(ScrnInfoPtr pScrn);
+extern void R128CCEResetRing(ScrnInfoPtr pScrn);
+extern void R128CCEWaitForIdle(ScrnInfoPtr pScrn);
+#endif
+
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c
index 5b0223661..f42569767 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c
@@ -1,8 +1,8 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c,v 1.7 2000/02/23 04:47:18 martin Exp $ */
/**************************************************************************
-Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+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
@@ -95,6 +95,19 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* DDC support */
#include "xf86DDC.h"
+ /* DRI support */
+#ifdef XF86DRI
+#include "GL/glxint.h"
+#include "xf86drm.h"
+#include "sarea.h"
+#define _XF86DRI_SERVER_
+#include "xf86dri.h"
+#include "dri.h"
+#include "r128_dri.h"
+#include "r128_dripriv.h"
+#include "r128_sarea.h"
+#endif
+
/* Driver data structures */
#include "r128.h"
#include "r128_reg.h"
@@ -122,7 +135,7 @@ static struct {
};
/* Flush all dirty data in the Pixel Cache to memory. */
-static void R128EngineFlush(ScrnInfoPtr pScrn)
+void R128EngineFlush(ScrnInfoPtr pScrn)
{
int i;
R128MMIO_VARS();
@@ -134,11 +147,12 @@ static void R128EngineFlush(ScrnInfoPtr pScrn)
}
/* Reset graphics card to known state. */
-static void R128EngineReset(ScrnInfoPtr pScrn)
+void R128EngineReset(ScrnInfoPtr pScrn)
{
- CARD32 clock_cntl_index;
- CARD32 mclk_cntl;
- CARD32 gen_reset_cntl;
+ R128InfoPtr info = R128PTR(pScrn);
+ CARD32 clock_cntl_index;
+ CARD32 mclk_cntl;
+ CARD32 gen_reset_cntl;
R128MMIO_VARS();
R128EngineFlush(pScrn);
@@ -158,17 +172,15 @@ static void R128EngineReset(ScrnInfoPtr pScrn)
OUTPLL(R128_MCLK_CNTL, mclk_cntl);
OUTREG(R128_CLOCK_CNTL_INDEX, clock_cntl_index);
OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl);
-}
-#define R128WaitForFifo(pScrn, entries) \
-do { \
- if (info->fifo_slots < entries) R128WaitForFifoFunction(pScrn, entries); \
- info->fifo_slots -= entries; \
-} while (0)
+#ifdef XF86DRI
+ if (R128CCE_USE_RING_BUFFER(info->CCEMode)) R128CCEResetRing(pScrn);
+#endif
+}
/* The FIFO has 64 slots. This routines waits until at least `entries' of
these slots are empty. */
-static void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries)
+void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries)
{
R128InfoPtr info = R128PTR(pScrn);
int i;
@@ -186,15 +198,19 @@ static void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"FIFO timed out, resetting engine...\n");
R128EngineReset(pScrn);
+#if XF86DRI
+ if (info->CCE2D) R128CCEStart(pScrn);
+#endif
}
}
/* Wait for the graphics engine to be completely idle: the FIFO has
drained, the Pixel Cache is flushed, and the engine is idle. This is a
standard "sync" function that will make the hardware "quiescent". */
-static void R128WaitForIdle(ScrnInfoPtr pScrn)
+void R128WaitForIdle(ScrnInfoPtr pScrn)
{
- int i;
+ R128InfoPtr info = R128PTR(pScrn);
+ int i;
R128MMIO_VARS();
R128WaitForFifoFunction(pScrn, 64);
@@ -213,6 +229,9 @@ static void R128WaitForIdle(ScrnInfoPtr pScrn)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Idle timed out, resetting engine...\n");
R128EngineReset(pScrn);
+#if XF86DRI
+ if (info->CCE2D) R128CCEStart(pScrn);
+#endif
}
}
@@ -966,19 +985,33 @@ void R128EngineInit(ScrnInfoPtr pScrn)
OUTREG(R128_DP_SRC_BKGD_CLR, 0x00000000);
OUTREG(R128_DP_WRITE_MASK, 0xffffffff);
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ OUTREGP(R128_DP_DATATYPE,
+ R128_HOST_BIG_ENDIAN_EN, ~R128_HOST_BIG_ENDIAN_EN);
+#else
+ OUTREGP(R128_DP_DATATYPE, 0, ~R128_HOST_BIG_ENDIAN_EN);
+#endif
+
R128WaitForIdle(pScrn);
}
-/* Initialize XAA for supported acceleration and also initialize the
- graphics hardware for acceleration. */
-Bool R128AccelInit(ScreenPtr pScreen)
+#ifdef XF86DRI
+ /* FIXME: When direct rendering is enabled, we should use the CCE to
+ draw 2D commands */
+static void R128CCEAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- R128InfoPtr info = R128PTR(pScrn);
- XAAInfoRecPtr a;
+ a->Flags = 0;
+
+ /* Sync */
+ a->Sync = R128CCEWaitForIdle;
+
+}
+#endif
+
+static void R128MMIOAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a)
+{
+ R128InfoPtr info = R128PTR(pScrn);
- if (!(a = info->accel = XAACreateInfoRec())) return FALSE;
-
a->Flags = (PIXMAP_CACHE
| OFFSCREEN_PIXMAPS
| LINEAR_FRAMEBUFFER);
@@ -1065,7 +1098,26 @@ Bool R128AccelInit(ScreenPtr pScreen)
| SCANLINE_PAD_DWORD
| SYNC_AFTER_IMAGE_WRITE);
#endif
-
+}
+
+/* Initialize XAA for supported acceleration and also initialize the
+ graphics hardware for acceleration. */
+Bool R128AccelInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr info = R128PTR(pScrn);
+ XAAInfoRecPtr a;
+
+ if (!(a = info->accel = XAACreateInfoRec())) return FALSE;
+
+#ifdef XF86DRI
+ /* FIXME: When direct rendering is enabled, we should use the CCE to
+ draw 2D commands */
+ if (info->CCE2D) R128CCEAccelInit(pScrn, a);
+ else
+#endif
+ R128MMIOAccelInit(pScrn, a);
+
R128EngineInit(pScrn);
return XAAInit(pScreen, a);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c
index a96872702..2667443d9 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c
@@ -1,8 +1,8 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c,v 1.6 2000/03/06 22:59:26 dawes Exp $ */
/**************************************************************************
-Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+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
@@ -60,6 +60,19 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* DDC support */
#include "xf86DDC.h"
+ /* DRI support */
+#ifdef XF86DRI
+#include "GL/glxint.h"
+#include "xf86drm.h"
+#include "sarea.h"
+#define _XF86DRI_SERVER_
+#include "xf86dri.h"
+#include "dri.h"
+#include "r128_dri.h"
+#include "r128_dripriv.h"
+#include "r128_sarea.h"
+#endif
+
/* Driver data structures */
#include "r128.h"
#include "r128_reg.h"
@@ -92,16 +105,19 @@ static void R128SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
(xorigin,yorigin). */
static void R128SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
{
- R128InfoPtr info = R128PTR(pScrn);
- int xorigin = 0;
- int yorigin = 0;
- int total_y = pScrn->frameY1 - pScrn->frameY0;
+ R128InfoPtr info = R128PTR(pScrn);
+ xf86CursorInfoPtr cursor = info->cursor;
+ int xorigin = 0;
+ int yorigin = 0;
+ int total_y = pScrn->frameY1 - pScrn->frameY0;
R128MMIO_VARS();
- if (x < 0) xorigin = -x;
- if (y < 0) yorigin = -y;
- if (y > total_y) y = total_y;
- if (info->Flags & V_DBLSCAN) y *= 2;
+ if (x < 0) xorigin = -x;
+ if (y < 0) yorigin = -y;
+ if (y > total_y) y = total_y;
+ if (info->Flags & V_DBLSCAN) y *= 2;
+ if (xorigin >= cursor->MaxWidth) xorigin = cursor->MaxWidth - 1;
+ if (yorigin >= cursor->MaxHeight) yorigin = cursor->MaxHeight - 1;
OUTREG(R128_CUR_HORZ_VERT_OFF, R128_CUR_LOCK | (xorigin << 16) | yorigin);
OUTREG(R128_CUR_HORZ_VERT_POSN, (R128_CUR_LOCK
@@ -126,47 +142,58 @@ static void R128LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *image)
#if X_BYTE_ORDER == X_BIG_ENDIAN
switch(info->pixel_bytes) {
- case 4:
- case 3:
- for (y = 0; y < 64; y++) {
- P_SWAP32(d,s);
- d++; s++;
- P_SWAP32(d,s);
- d++; s++;
- P_SWAP32(d,s);
- d++; s++;
- P_SWAP32(d,s);
- d++; s++;
- }
- break;
- case 2:
- for (y = 0; y < 64; y++) {
- P_SWAP16(d,s);
- d++; s++;
- P_SWAP16(d,s);
- d++; s++;
- P_SWAP16(d,s);
- d++; s++;
- P_SWAP16(d,s);
- d++; s++;
- }
- break;
- default:
- for (y = 0; y < 64; y++) {
+ case 4:
+ case 3:
+ for (y = 0; y < 64; y++) {
+ P_SWAP32(d,s);
+ d++; s++;
+ P_SWAP32(d,s);
+ d++; s++;
+ P_SWAP32(d,s);
+ d++; s++;
+ P_SWAP32(d,s);
+ d++; s++;
+ }
+ break;
+ case 2:
+ for (y = 0; y < 64; y++) {
+ P_SWAP16(d,s);
+ d++; s++;
+ P_SWAP16(d,s);
+ d++; s++;
+ P_SWAP16(d,s);
+ d++; s++;
+ P_SWAP16(d,s);
+ d++; s++;
+ }
+ break;
+ default:
+ for (y = 0; y < 64; y++) {
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
- }
+ }
}
#else
- for (y = 0; y < 64; y++) {
+ for (y = 0; y < 64; y++) {
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
}
#endif
+
+ /* Set the area after the cursor to be all transparent so that we
+ won't display corrupted cursors on the screen */
+ for (y = 0; y < 64; y++) {
+ *d++ = 0xffffffff; /* The AND bits */
+ *d++ = 0xffffffff;
+ *d++ = 0x00000000; /* The XOR bits */
+ *d++ = 0x00000000;
+ }
+
+
OUTREG(R128_CRTC_GEN_CNTL, save);
}
@@ -204,6 +231,7 @@ Bool R128CursorInit(ScreenPtr pScreen)
FBAreaPtr fbarea;
int width;
int height;
+ int size;
if (!(cursor = info->cursor = xf86CreateCursorInfoRec())) return FALSE;
@@ -227,8 +255,9 @@ Bool R128CursorInit(ScreenPtr pScreen)
cursor->ShowCursor = R128ShowCursor;
cursor->UseHWCursor = R128UseHWCursor;
+ size = (cursor->MaxWidth/4) * cursor->MaxHeight;
width = pScrn->displayWidth;
- height = (1024 + 1023) / pScrn->displayWidth;
+ height = (size*2 + 1023) / pScrn->displayWidth;
fbarea = xf86AllocateOffscreenArea(pScreen,
width,
height,
@@ -246,7 +275,7 @@ Bool R128CursorInit(ScreenPtr pScreen)
info->cursor_start = R128_ALIGN((fbarea->box.x1
+ width * fbarea->box.y1)
* info->pixel_bytes, 16);
- info->cursor_end = info->cursor_start + 1024;
+ info->cursor_end = info->cursor_start + size;
}
R128TRACE(("R128CursorInit (0x%08x-0x%08x)\n",
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
new file mode 100644
index 000000000..cb647d6b6
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
@@ -0,0 +1,1242 @@
+/* $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>
+ * Rickard E. Faith <faith@precisioninsight.com>
+ * Daryll Strauss <daryll@precisioninsight.com>
+ *
+ */
+
+
+ /* X and server generic header files */
+#include "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86RAC.h"
+#include "xf86cmap.h"
+#include "xf86fbman.h"
+
+ /* Backing store, software cursor, and
+ colormap initialization */
+#include "mibstore.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+ /* CFB support */
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb16.h"
+#include "cfb24.h"
+#include "cfb32.h"
+#include "cfb24_32.h"
+
+ /* XAA and Cursor Support */
+#include "xaa.h"
+#include "xf86Cursor.h"
+
+ /* PCI support */
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+ /* DDC support */
+#include "xf86DDC.h"
+
+ /* DRI support */
+#include "GL/glxint.h"
+#include "GL/glxtokens.h"
+#include "xf86drm.h"
+#include "xf86drmR128.h"
+#include "sarea.h"
+#define _XF86DRI_SERVER_
+#include "xf86dri.h"
+#include "dri.h"
+#include "r128_dri.h"
+#include "r128_sarea.h"
+#include "r128_dripriv.h"
+
+ /* Driver data structures */
+#include "r128.h"
+#include "r128_reg.h"
+
+#define R128_WATERMARK_L 16
+#define R128_WATERMARK_M 8
+#define R128_WATERMARK_N 8
+#define R128_WATERMARK_K 128
+
+static int CCEFifoSlots = 0;
+
+#define R128CCEWaitForFifo(pScrn, entries) \
+do { \
+ if (CCEFifoSlots < entries) R128WaitForFifoFunction(pScrn, entries); \
+ CCEFifoSlots -= entries; \
+} while (0)
+
+/* Wait for at least `entries' slots are free. The actual number of
+ slots available is stored in info->CCEFifoSize. */
+static void R128CCEWaitForFifoFunction(ScrnInfoPtr pScrn, int entries)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+ int i;
+
+ for (;;) {
+ for (i = 0; i < R128_TIMEOUT; i++) {
+ CCEFifoSlots = INREG(R128_PM4_STAT) & R128_PM4_FIFOCNT_MASK;
+ if (CCEFifoSlots >= entries) return;
+ }
+ R128EngineReset(pScrn);
+ if (info->CCE2D) R128CCEStart(pScrn);
+ }
+}
+
+/* Wait until the CCE is completely idle: the FIFO has drained and the
+ CCE is idle. */
+void R128CCEWaitForIdle(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+ int i;
+
+ if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return;
+
+ if (R128CCE_USE_RING_BUFFER(info->CCEMode)) {
+ volatile CARD32 *r128RingReadPtr =
+ (volatile CARD32 *)(info->ringReadPtr);
+ R128SAREAPrivPtr pSAREAPriv;
+
+ OUTREGP(R128_PM4_BUFFER_DL_WPTR,
+ R128_PM4_BUFFER_DL_DONE, ~R128_PM4_BUFFER_DL_DONE);
+
+ pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScrn->pScreen);
+
+ for (;;) {
+ for (i = 0; i < R128_TIMEOUT; i++) {
+ if (*r128RingReadPtr == pSAREAPriv->ringWrite) {
+ int pm4stat = INREG(R128_PM4_STAT);
+ if ((pm4stat & R128_PM4_FIFOCNT_MASK) >= info->CCEFifoSize
+ && !(pm4stat & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE)))
+ return;
+ }
+ }
+ R128EngineReset(pScrn);
+ if (info->CCE2D) R128CCEStart(pScrn);
+ }
+ } else {
+ R128CCEWaitForFifoFunction(pScrn, info->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);
+ if (info->CCE2D) R128CCEStart(pScrn);
+ }
+ }
+}
+
+/* Reset the ring buffer status, if the engine was reset */
+void R128CCEResetRing(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+ R128SAREAPrivPtr pSAREAPriv;
+ volatile CARD32 *r128RingReadPtr;
+
+ if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return;
+
+ r128RingReadPtr = (volatile CARD32 *)(info->ringReadPtr);
+ pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScrn->pScreen);
+
+ OUTREG(R128_PM4_BUFFER_DL_WPTR, 0);
+ OUTREG(R128_PM4_BUFFER_DL_RPTR, 0);
+ pSAREAPriv->ringWrite = 0;
+ *r128RingReadPtr = 0;
+
+ /* Resetting the ring turns off the CCE */
+ info->CCEInUse = FALSE;
+}
+
+/* Start the CCE, but only if it is not already in use and the requested
+ mode is a CCE mode. The mode is stored in info->CCEMode. */
+void R128CCEStart(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+
+ if (info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return;
+
+ R128WaitForIdle(pScrn);
+ OUTREG(R128_PM4_BUFFER_CNTL, info->CCEMode | info->ringSizeLog2QW);
+ (void)INREG(R128_PM4_BUFFER_ADDR); /* as per the sample code */
+ OUTREG(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN);
+ info->CCEInUse = TRUE;
+}
+
+/* Stop the CCE, but only if it is in use and the requested mode is not
+ the non-CCE mode. This function also flushes any outstanding
+ requests before switching modes.*/
+void R128CCEStop(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+
+ if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return;
+
+ R128CCEWaitForIdle(pScrn);
+ OUTREG(R128_PM4_MICRO_CNTL, 0);
+ OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4);
+ R128EngineReset(pScrn);
+ info->CCEInUse = FALSE;
+}
+
+/* Initialize the visual configs that are supported by the hardware.
+ These are combined with the visual configs that the indirect
+ rendering core supports, and the intersection is exported to the
+ client. */
+static Bool R128InitVisualConfigs(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+ int numConfigs = 0;
+ __GLXvisualConfig *pConfigs = 0;
+ R128ConfigPrivPtr pR128Configs = 0;
+ R128ConfigPrivPtr *pR128ConfigPtrs = 0;
+ int i, accum, stencil;
+
+ switch (pR128->pixel_code) {
+ case 8: /* 8bpp mode is not support */
+ case 15: /* FIXME */
+ case 24: /* FIXME */
+ return FALSE;
+
+#define R128_USE_ACCUM 1
+#define R128_USE_STENCIL 0 /* Only in 24 depth mode */
+
+ case 16:
+ numConfigs = 1;
+ if (R128_USE_ACCUM) numConfigs *= 2;
+
+ if (!(pConfigs
+ = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
+ numConfigs))) {
+ return FALSE;
+ }
+ if (!(pR128Configs
+ = (R128ConfigPrivPtr)xnfcalloc(sizeof(R128ConfigPrivRec),
+ numConfigs))) {
+ xfree(pConfigs);
+ return FALSE;
+ }
+ if (!(pR128ConfigPtrs
+ = (R128ConfigPrivPtr*)xnfcalloc(sizeof(R128ConfigPrivPtr),
+ numConfigs))) {
+ xfree(pConfigs);
+ xfree(pR128Configs);
+ return FALSE;
+ }
+
+ i = 0;
+ for (accum = 0; accum <= R128_USE_ACCUM; accum++) {
+ pR128ConfigPtrs[i] = &pR128Configs[i];
+
+ pConfigs[i].vid = -1;
+ pConfigs[i].class = -1;
+ pConfigs[i].rgba = TRUE;
+ pConfigs[i].redSize = 5;
+ pConfigs[i].greenSize = 6;
+ pConfigs[i].blueSize = 5;
+ pConfigs[i].redMask = 0x0000F800;
+ pConfigs[i].greenMask = 0x000007E0;
+ pConfigs[i].blueMask = 0x0000001F;
+
+ pConfigs[i].alphaMask = 0;
+ if (accum) { /* Simulated in software */
+ pConfigs[i].accumRedSize = 16;
+ pConfigs[i].accumGreenSize = 16;
+ pConfigs[i].accumBlueSize = 16;
+ pConfigs[i].accumAlphaSize = 0;
+ } else {
+ pConfigs[i].accumRedSize = 0;
+ pConfigs[i].accumGreenSize = 0;
+ pConfigs[i].accumBlueSize = 0;
+ pConfigs[i].accumAlphaSize = 0;
+ }
+ pConfigs[i].doubleBuffer = TRUE;
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = 16;
+ pConfigs[i].depthSize = 16;
+ pConfigs[i].stencilSize = 0;
+ pConfigs[i].auxBuffers = 0;
+ pConfigs[i].level = 0;
+ if (accum)
+ pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ else
+ pConfigs[i].visualRating = GLX_NONE_EXT;
+ pConfigs[i].transparentPixel = 0;
+ pConfigs[i].transparentRed = 0;
+ pConfigs[i].transparentGreen = 0;
+ pConfigs[i].transparentBlue = 0;
+ pConfigs[i].transparentAlpha = 0;
+ pConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ break;
+ case 32:
+ numConfigs = 1;
+ if (R128_USE_ACCUM) numConfigs *= 2;
+ if (R128_USE_STENCIL) numConfigs *= 2;
+
+ if (!(pConfigs
+ = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
+ numConfigs))) {
+ return FALSE;
+ }
+ if (!(pR128Configs
+ = (R128ConfigPrivPtr)xnfcalloc(sizeof(R128ConfigPrivRec),
+ numConfigs))) {
+ xfree(pConfigs);
+ return FALSE;
+ }
+ if (!(pR128ConfigPtrs
+ = (R128ConfigPrivPtr*)xnfcalloc(sizeof(R128ConfigPrivPtr),
+ numConfigs))) {
+ xfree(pConfigs);
+ xfree(pR128Configs);
+ return FALSE;
+ }
+
+ i = 0;
+ for (accum = 0; accum <= R128_USE_ACCUM; accum++) {
+ for (stencil = 0; stencil <= R128_USE_STENCIL; stencil++) {
+ pR128ConfigPtrs[i] = &pR128Configs[i];
+
+ pConfigs[i].vid = -1;
+ pConfigs[i].class = -1;
+ pConfigs[i].rgba = TRUE;
+ pConfigs[i].redSize = 8;
+ pConfigs[i].greenSize = 8;
+ pConfigs[i].blueSize = 8;
+ pConfigs[i].redMask = 0x00FF0000;
+ pConfigs[i].greenMask = 0x0000FF00;
+ pConfigs[i].blueMask = 0x000000FF;
+
+ pConfigs[i].alphaMask = 0;
+ if (accum) { /* Simulated in software */
+ pConfigs[i].accumRedSize = 16;
+ pConfigs[i].accumGreenSize = 16;
+ pConfigs[i].accumBlueSize = 16;
+ pConfigs[i].accumAlphaSize = 0;
+ } else {
+ pConfigs[i].accumRedSize = 0;
+ pConfigs[i].accumGreenSize = 0;
+ pConfigs[i].accumBlueSize = 0;
+ pConfigs[i].accumAlphaSize = 0;
+ }
+ pConfigs[i].doubleBuffer = TRUE;
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = 24;
+ if (stencil) {
+ pConfigs[i].depthSize = 24;
+ pConfigs[i].stencilSize = 8;
+ } else {
+ pConfigs[i].depthSize = 32;
+ pConfigs[i].stencilSize = 0;
+ }
+ pConfigs[i].auxBuffers = 0;
+ pConfigs[i].level = 0;
+ if (accum)
+ pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ else
+ pConfigs[i].visualRating = GLX_NONE_EXT;
+ pConfigs[i].transparentPixel = 0;
+ pConfigs[i].transparentRed = 0;
+ pConfigs[i].transparentGreen = 0;
+ pConfigs[i].transparentBlue = 0;
+ pConfigs[i].transparentAlpha = 0;
+ pConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ break;
+ }
+
+ pR128->numVisualConfigs = numConfigs;
+ pR128->pVisualConfigs = pConfigs;
+ pR128->pVisualConfigsPriv = pR128Configs;
+ GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pR128ConfigPtrs);
+ return TRUE;
+}
+
+/* Create the Rage 128-specific context information */
+static Bool R128CreateContext(ScreenPtr pScreen, VisualPtr visual,
+ drmContext hwContext, void *pVisualConfigPriv,
+ DRIContextType contextStore)
+{
+ /* Nothing yet */
+ return TRUE;
+}
+
+/* Destroy the Rage 128-specific context information */
+static void R128DestroyContext(ScreenPtr pScreen, drmContext hwContext,
+ DRIContextType contextStore)
+{
+ /* Nothing yet */
+}
+
+/* Called when the X server is woken up to allow the last client's
+ context to be saved and the X server's context to be loaded. This is
+ not necessary for the Rage 128 since the client detects when it's
+ context is not currently loaded and then load's it itself. Since the
+ registers to start and stop the CCE are privileged, only the X server
+ can start/stop the engine. */
+static void R128EnterServer(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+
+ if (pR128->accel) pR128->accel->NeedToSync = TRUE;
+
+#if 1
+ if (!pR128->CCE2D) R128CCEStop(pScrn);
+#else
+ if (pR128->CCE2D) R128CCEWaitForIdle(pScrn);
+ else R128CCEStop(pScrn);
+#endif
+}
+
+/* Called when the X server goes to sleep to allow the X server's
+ context to be saved and the last client's context to be loaded. This
+ is not necessary for the Rage 128 since the client detects when it's
+ context is not currently loaded and then load's it itself. Since the
+ registers to start and stop the CCE are privileged, only the X server
+ can start/stop the engine. */
+static void R128LeaveServer(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+
+#if 1
+ if (!pR128->CCE2D) R128CCEStart(pScrn);
+#else
+ if (pR128->CCE2D) R128CCEWaitForIdle(pScrn);
+ else R128CCEStart(pScrn);
+#endif
+}
+
+/* Contexts can be swapped by the X server if necessary. This callback
+ is currently only used to perform any functions necessary when
+ entering or leaving the X server, and in the future might not be
+ necessary. */
+static void R128DRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
+ DRIContextType oldContextType, void *oldContext,
+ DRIContextType newContextType, void *newContext)
+{
+ if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) &&
+ (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */
+ R128EnterServer(pScreen);
+ }
+ if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) &&
+ (newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */
+ R128LeaveServer(pScreen);
+ }
+}
+
+/* Initialize the state of the back and depth buffers. */
+static void R128DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
+{
+ /* FIXME: This routine needs to have acceleration turned on */
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+ BoxPtr pbox;
+ int nbox;
+ int depth;
+
+ /* FIXME: Use accel when CCE 2D code is written */
+ if (pR128->CCE2D) return;
+
+ /* FIXME: This should be based on the __GLXvisualConfig info */
+ switch (pScrn->bitsPerPixel) {
+ case 8: depth = 0x000000ff; break;
+ case 16: depth = 0x0000ffff; break;
+ case 24: depth = 0x00ffffff; break;
+ case 32: depth = 0xffffffff; break;
+ default: depth = 0x00000000; break;
+ }
+
+ /* FIXME: Copy XAAPaintWindow() and use REGION_TRANSLATE() */
+ /* FIXME: Only initialize the back and depth buffers for contexts
+ that request them */
+
+ pbox = REGION_RECTS(prgn);
+ nbox = REGION_NUM_RECTS(prgn);
+
+ (*pR128->accel->SetupForSolidFill)(pScrn, 0, GXcopy, -1);
+ for (; nbox; nbox--, pbox++) {
+ (*pR128->accel->SubsequentSolidFillRect)(pScrn,
+ pbox->x1 + pR128->fbX,
+ pbox->y1 + pR128->fbY,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ (*pR128->accel->SubsequentSolidFillRect)(pScrn,
+ pbox->x1 + pR128->backX,
+ pbox->y1 + pR128->backY,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ }
+
+ (*pR128->accel->SetupForSolidFill)(pScrn, depth, GXcopy, -1);
+ for (; nbox; nbox--, pbox++)
+ (*pR128->accel->SubsequentSolidFillRect)(pScrn,
+ pbox->x1 + pR128->depthX,
+ pbox->y1 + pR128->depthY,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+
+ pR128->accel->NeedToSync = TRUE;
+}
+
+/* Copy the back and depth buffers when the X server moves a window. */
+static void R128DRIMoveBuffers(WindowPtr pWin, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc, CARD32 index)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+
+ /* FIXME: This routine needs to have acceleration turned on */
+ /* FIXME: Copy XAACopyWindow() and use REGION_TRANSLATE() */
+ /* FIXME: Only initialize the back and depth buffers for contexts
+ that request them */
+
+ /* FIXME: Use accel when CCE 2D code is written */
+ if (pR128->CCE2D) return;
+}
+
+/* Initialize the AGP state. Request memory for use in AGP space, and
+ initialize the Rage 128 registers to point to that memory. */
+static Bool R128DRIAgpInit(R128InfoPtr pR128, ScreenPtr pScreen)
+{
+ unsigned char *R128MMIO = pR128->MMIO;
+ unsigned long mode;
+ unsigned int vendor, device;
+ int ret;
+ unsigned long cntl;
+ int s, l;
+ int flags;
+
+ if (drmAgpAcquire(pR128->drmFD) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not available\n");
+ return FALSE;
+ }
+
+ /* Modify the mode if the default mode is
+ not appropriate for this particular
+ combination of graphics card and AGP
+ chipset. */
+
+ mode = drmAgpGetMode(pR128->drmFD); /* Default mode */
+ vendor = drmAgpVendorId(pR128->drmFD);
+ device = drmAgpDeviceId(pR128->drmFD);
+
+ mode &= ~R128_AGP_MODE_MASK;
+ switch (pR128->agpMode) {
+ case 2: mode |= R128_AGP_2X_MODE;
+ case 1: default: mode |= R128_AGP_1X_MODE;
+ }
+
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n",
+ mode, vendor, device,
+ pR128->PciInfo->vendor,
+ pR128->PciInfo->chipType);
+
+ if (drmAgpEnable(pR128->drmFD, mode) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n");
+ drmAgpRelease(pR128->drmFD);
+ return FALSE;
+ }
+
+ pR128->agpOffset = 0;
+
+ if ((ret = drmAgpAlloc(pR128->drmFD, pR128->agpSize*1024*1024, 0, NULL,
+ &pR128->agpMemHandle)) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Out of memory (%d)\n", ret);
+ drmAgpRelease(pR128->drmFD);
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] %d kB allocated with handle 0x%08x\n",
+ pR128->agpSize*1024, pR128->agpMemHandle);
+
+ if (drmAgpBind(pR128->drmFD, pR128->agpMemHandle, pR128->agpOffset) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not bind\n");
+ drmAgpFree(pR128->drmFD, pR128->agpMemHandle);
+ drmAgpRelease(pR128->drmFD);
+ return FALSE;
+ }
+
+ /* Initialize the CCE ring buffer data */
+ pR128->ringStart = pR128->agpOffset;
+ pR128->ringMapSize = pR128->ringSize*1024*1024 + 4096;
+ pR128->ringSizeLog2QW = R128MinBits(pR128->ringSize*1024*1024/8) - 1;
+
+ pR128->ringReadOffset = pR128->ringStart + pR128->ringMapSize;
+ pR128->ringReadMapSize = 4096;
+
+ /* Reserve space for the vertex buffer */
+ pR128->vbStart = pR128->ringReadOffset + pR128->ringReadMapSize;
+ pR128->vbMapSize = pR128->vbSize*1024*1024;
+
+ /* Reserve space for the indirect buffer */
+ pR128->indStart = pR128->vbStart + pR128->vbMapSize;
+ pR128->indMapSize = pR128->indSize*1024*1024;
+
+ /* Reserve the rest for AGP textures */
+ pR128->agpTexStart = pR128->indStart + pR128->indMapSize;
+ s = (pR128->agpSize*1024*1024 - pR128->agpTexStart);
+ l = R128MinBits((s-1) / R128_NR_TEX_REGIONS);
+ if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
+ pR128->agpTexMapSize = (s >> l) << l;
+ pR128->log2AGPTexGran = l;
+
+ if (pR128->CCESecure) flags = DRM_READ_ONLY;
+ else flags = 0;
+
+ if (drmAddMap(pR128->drmFD, pR128->ringStart, pR128->ringMapSize,
+ DRM_AGP, flags, &pR128->ringHandle) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not add ring mapping\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] ring handle = 0x%08lx\n", pR128->ringHandle);
+
+ if (drmMap(pR128->drmFD, pR128->ringHandle, pR128->ringMapSize,
+ (drmAddressPtr)&pR128->ring) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not map ring\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] Ring mapped at 0x%08lx\n",
+ (unsigned long)pR128->ring);
+
+ if (drmAddMap(pR128->drmFD, pR128->ringReadOffset, pR128->ringReadMapSize,
+ DRM_AGP, flags, &pR128->ringReadPtrHandle) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not add ring read ptr mapping\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] ring read ptr handle = 0x%08lx\n",
+ pR128->ringReadPtrHandle);
+
+ if (drmMap(pR128->drmFD, pR128->ringReadPtrHandle, pR128->ringReadMapSize,
+ (drmAddressPtr)&pR128->ringReadPtr) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not map ring read ptr\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] Ring read ptr mapped at 0x%08lx\n",
+ (unsigned long)pR128->ringReadPtr);
+
+ if (drmAddMap(pR128->drmFD, pR128->vbStart, pR128->vbMapSize,
+ DRM_AGP, 0, &pR128->vbHandle) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not add vertex buffers mapping\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] vertex buffers handle = 0x%08lx\n", pR128->vbHandle);
+
+ if (drmMap(pR128->drmFD, pR128->vbHandle, pR128->vbMapSize,
+ (drmAddressPtr)&pR128->vb) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not map vertex buffers\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] Vertex buffers mapped at 0x%08lx\n",
+ (unsigned long)pR128->vb);
+
+ if (drmAddMap(pR128->drmFD, pR128->indStart, pR128->indMapSize,
+ DRM_AGP, flags, &pR128->indHandle) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not add indirect buffers mapping\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] indirect buffers handle = 0x%08lx\n", pR128->indHandle);
+
+ if (drmMap(pR128->drmFD, pR128->indHandle, pR128->indMapSize,
+ (drmAddressPtr)&pR128->ind) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not map indirect buffers\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] Indirect buffers mapped at 0x%08lx\n",
+ (unsigned long)pR128->ind);
+
+ if (drmAddMap(pR128->drmFD, pR128->agpTexStart, pR128->agpTexMapSize,
+ DRM_AGP, 0, &pR128->agpTexHandle) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not add AGP texture map mapping\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] AGP texture map handle = 0x%08lx\n",
+ pR128->agpTexHandle);
+
+ if (drmMap(pR128->drmFD, pR128->agpTexHandle, pR128->agpTexMapSize,
+ (drmAddressPtr)&pR128->agpTex) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not map AGP texture map\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] AGP Texture map mapped at 0x%08lx\n",
+ (unsigned long)pR128->agpTex);
+
+ /* Initialize Rage 128's AGP registers */
+ cntl = INREG(R128_AGP_CNTL);
+ cntl &= ~R128_AGP_APER_SIZE_MASK;
+ switch (pR128->agpSize) {
+ case 256: cntl |= R128_AGP_APER_SIZE_256MB; break;
+ case 128: cntl |= R128_AGP_APER_SIZE_128MB; break;
+ case 64: cntl |= R128_AGP_APER_SIZE_64MB; break;
+ case 32: cntl |= R128_AGP_APER_SIZE_32MB; break;
+ case 16: cntl |= R128_AGP_APER_SIZE_16MB; break;
+ case 8: cntl |= R128_AGP_APER_SIZE_8MB; break;
+ case 4: cntl |= R128_AGP_APER_SIZE_4MB; break;
+ default:
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Illegal aperture size %d kB\n",
+ pR128->agpSize*1024);
+ return FALSE;
+ }
+ OUTREG(R128_AGP_BASE, pR128->ringHandle); /* Ring buf is at AGP offset 0 */
+ OUTREG(R128_AGP_CNTL, cntl);
+
+ return TRUE;
+}
+
+/* Add a map for the MMIO registers that will be accessed by any
+ DRI-based clients. */
+static Bool R128DRIMapInit(R128InfoPtr pR128, ScreenPtr pScreen)
+{
+ int flags;
+
+ if (pR128->CCESecure) flags = DRM_READ_ONLY;
+ else flags = 0;
+
+ /* Map registers */
+ pR128->registerSize = R128_MMIOSIZE;
+ if (drmAddMap(pR128->drmFD, pR128->MMIOAddr, pR128->registerSize,
+ DRM_REGISTERS, flags, &pR128->registerHandle) < 0) {
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] register handle = 0x%08lx\n", pR128->registerHandle);
+
+ return TRUE;
+}
+
+/* Initialize the ring buffer state for use in the X server and any
+ DRI-based clients. */
+static void R128DRICCEInitRingBuffer(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+ unsigned long addr;
+
+ /* FIXME: When we use the CCE for the X server, we should move this
+ function (and the support functions above) to r128_accel.c */
+
+ /* The manual (p. 2) says this address is
+ in "VM space". This means it's an
+ offset from the start of AGP space. */
+ OUTREG(R128_PM4_BUFFER_OFFSET, info->ringStart | 0x02000000);
+
+ OUTREG(R128_PM4_BUFFER_DL_WPTR, 0);
+ OUTREG(R128_PM4_BUFFER_DL_RPTR, 0);
+
+ /* DL_RPTR_ADDR is a physical address.
+ This should be in the SAREA. */
+ *(volatile long unsigned *)(info->ringReadPtr) = 0;
+ OUTREG(R128_PM4_BUFFER_DL_RPTR_ADDR, (info->ringReadPtrHandle));
+
+ /* Set watermark control */
+ OUTREG(R128_PM4_BUFFER_WM_CNTL,
+ ((R128_WATERMARK_L/4) << R128_WMA_SHIFT)
+ | ((R128_WATERMARK_M/4) << R128_WMB_SHIFT)
+ | ((R128_WATERMARK_N/4) << R128_WMC_SHIFT)
+ | ((R128_WATERMARK_K/64) << R128_WB_WM_SHIFT));
+
+ addr = INREG(R128_PM4_BUFFER_ADDR); /* Force read. Why? Because it's
+ in the examples... */
+
+#if 0
+ R128CCEWaitForIdle(pScrn);
+#endif
+
+ /* Turn on bus mastering */
+ info->BusCntl &= ~R128_BUS_MASTER_DIS;
+ OUTREGP(R128_BUS_CNTL, 0, ~R128_BUS_MASTER_DIS);
+}
+
+/* Initialize the kernel data structures. */
+static int R128DRIKernelInit(R128InfoPtr pR128, ScreenPtr pScreen)
+{
+ drmR128Init drmInfo;
+
+ drmInfo.sarea_priv_offset = sizeof(XF86DRISAREARec);
+ drmInfo.is_pci = pR128->IsPCI;
+ drmInfo.cce_mode = pR128->CCEMode;
+ drmInfo.cce_fifo_size = pR128->CCEFifoSize;
+ drmInfo.cce_secure = pR128->CCESecure;
+ drmInfo.ring_size = pR128->ringSize*1024*1024;
+ drmInfo.usec_timeout = pR128->CCEusecTimeout;
+
+ drmInfo.fb_offset = pR128->LinearAddr;
+ drmInfo.agp_ring_offset = pR128->ringHandle;
+ drmInfo.agp_read_ptr_offset = pR128->ringReadPtrHandle;
+ drmInfo.agp_vertbufs_offset = pR128->vbHandle;
+ drmInfo.agp_indbufs_offset = pR128->indHandle;
+ drmInfo.agp_textures_offset = pR128->agpTexHandle;
+ drmInfo.mmio_offset = pR128->registerHandle;
+
+ if (drmR128InitCCE(pR128->drmFD, &drmInfo) < 0) return FALSE;
+
+ return TRUE;
+}
+
+/* Add a map for the vertex buffers that will be accessed by any
+ DRI-based clients. */
+static Bool R128DRIBufInit(R128InfoPtr pR128, ScreenPtr pScreen)
+{
+ /* Initialize vertex buffers */
+ if ((pR128->vbNumBufs = drmAddBufs(pR128->drmFD,
+ pR128->vbMapSize / pR128->vbBufSize,
+ pR128->vbBufSize,
+ DRM_AGP_BUFFER,
+ pR128->vbStart)) <= 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Could not create vertex buffers list\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Added %d %d byte vertex buffers\n",
+ pR128->vbNumBufs, pR128->vbBufSize);
+
+ if (drmMarkBufs(pR128->drmFD, 0.133333, 0.266666)) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Failed to mark vertex buffers list\n");
+ return FALSE;
+ }
+
+ if (!(pR128->vbBufs = drmMapBufs(pR128->drmFD))) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Failed to map vertex buffers list\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Mapped %d vertex buffers\n",
+ pR128->vbBufs->count);
+
+ return TRUE;
+}
+
+/* Load the microcode for the CCE */
+static void R128DRILoadMicrocode(ScrnInfoPtr pScrn)
+{
+ unsigned char *R128MMIO = R128PTR(pScrn)->MMIO;
+ int i;
+ unsigned long R128Microcode[] = {
+ /* CCE microcode (from ATI) */
+ 0, 276838400, 0, 268449792, 2, 142, 2, 145, 0, 1076765731, 0, 1617039951,
+ 0, 774592877, 0, 1987540286, 0, 2307490946U, 0, 599558925, 0, 589505315, 0,
+ 596487092, 0, 589505315, 1, 11544576, 1, 206848, 1, 311296, 1, 198656, 2,
+ 912273422, 11, 262144, 0, 0, 1, 33559837, 1, 7438, 1, 14809, 1, 6615, 12,
+ 28, 1, 6614, 12, 28, 2, 23, 11, 18874368, 0, 16790922, 1, 409600, 9, 30, 1,
+ 147854772, 16, 420483072, 3, 8192, 0, 10240, 1, 198656, 1, 15630, 1, 51200,
+ 10, 34858, 9, 42, 1, 33559823, 2, 10276, 1, 15717, 1, 15718, 2, 43, 1,
+ 15936948, 1, 570480831, 1, 14715071, 12, 322123831, 1, 33953125, 12, 55, 1,
+ 33559908, 1, 15718, 2, 46, 4, 2099258, 1, 526336, 1, 442623, 4, 4194365, 1,
+ 509952, 1, 459007, 3, 0, 12, 92, 2, 46, 12, 176, 1, 15734, 1, 206848, 1,
+ 18432, 1, 133120, 1, 100670734, 1, 149504, 1, 165888, 1, 15975928, 1,
+ 1048576, 6, 3145806, 1, 15715, 16, 2150645232U, 2, 268449859, 2, 10307, 12,
+ 176, 1, 15734, 1, 15735, 1, 15630, 1, 15631, 1, 5253120, 6, 3145810, 16,
+ 2150645232U, 1, 15864, 2, 82, 1, 343310, 1, 1064207, 2, 3145813, 1, 15728,
+ 1, 7817, 1, 15729, 3, 15730, 12, 92, 2, 98, 1, 16168, 1, 16167, 1, 16002,
+ 1, 16008, 1, 15974, 1, 15975, 1, 15990, 1, 15976, 1, 15977, 1, 15980, 0,
+ 15981, 1, 10240, 1, 5253120, 1, 15720, 1, 198656, 6, 110, 1, 180224, 1,
+ 103824738, 2, 112, 2, 3145839, 0, 536885440, 1, 114880, 14, 125, 12,
+ 206975, 1, 33559995, 12, 198784, 0, 33570236, 1, 15803, 0, 15804, 3,
+ 294912, 1, 294912, 3, 442370, 1, 11544576, 0, 811612160, 1, 12593152, 1,
+ 11536384, 1, 14024704, 7, 310382726, 0, 10240, 1, 14796, 1, 14797, 1,
+ 14793, 1, 14794, 0, 14795, 1, 268679168, 1, 9437184, 1, 268449792, 1,
+ 198656, 1, 9452827, 1, 1075854602, 1, 1075854603, 1, 557056, 1, 114880, 14,
+ 159, 12, 198784, 1, 1109409213, 12, 198783, 1, 1107312059, 12, 198784, 1,
+ 1109409212, 2, 162, 1, 1075854781, 1, 1073757627, 1, 1075854780, 1, 540672,
+ 1, 10485760, 6, 3145894, 16, 274741248, 9, 168, 3, 4194304, 3, 4209949, 0,
+ 0, 0, 256, 14, 174, 1, 114857, 1, 33560007, 12, 176, 0, 10240, 1, 114858,
+ 1, 33560018, 1, 114857, 3, 33560007, 1, 16008, 1, 114874, 1, 33560360, 1,
+ 114875, 1, 33560154, 0, 15963, 0, 256, 0, 4096, 1, 409611, 9, 188, 0,
+ 10240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0
+ };
+
+ R128WaitForIdle(pScrn);
+
+ OUTREG(R128_PM4_MICROCODE_ADDR, 0);
+ for (i = 0; i < 256; i += 1) {
+ OUTREG(R128_PM4_MICROCODE_DATAH, R128Microcode[i*2]);
+ OUTREG(R128_PM4_MICROCODE_DATAL, R128Microcode[i*2 + 1]);
+ }
+}
+
+/* Initialize the CCE state, and start the CCE (if used by the X server) */
+static void R128DRICCEInit(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+
+ /* CCEMode is initialized in r128_driver.c */
+ switch (info->CCEMode) {
+ case R128_PM4_NONPM4: info->CCEFifoSize = 0; break;
+ case R128_PM4_192PIO: info->CCEFifoSize = 192; break;
+ case R128_PM4_192BM: info->CCEFifoSize = 192; break;
+ case R128_PM4_128PIO_64INDBM: info->CCEFifoSize = 128; break;
+ case R128_PM4_128BM_64INDBM: info->CCEFifoSize = 128; break;
+ case R128_PM4_64PIO_128INDBM: info->CCEFifoSize = 64; break;
+ case R128_PM4_64BM_128INDBM: info->CCEFifoSize = 64; break;
+ case R128_PM4_64PIO_64VCBM_64INDBM: info->CCEFifoSize = 64; break;
+ case R128_PM4_64BM_64VCBM_64INDBM: info->CCEFifoSize = 64; break;
+ case R128_PM4_64PIO_64VCPIO_64INDPIO: info->CCEFifoSize = 64; break;
+ }
+
+ if (info->CCE2D) {
+ /* Make sure the CCE is on for the X server */
+ R128CCEStart(pScrn);
+ } else {
+ /* Make sure the CCE is off for the X server */
+ OUTREG(R128_PM4_MICRO_CNTL, 0);
+ OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4);
+ }
+}
+
+/* Initialize the screen-specific data structures for the DRI and the
+ Rage 128. This is the main entry point to the device-specific
+ initialization code. It calls device-independent DRI functions to
+ create the DRI data structures and initialize the DRI state. */
+Bool R128DRIScreenInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+ DRIInfoPtr pDRIInfo;
+ R128DRIPtr pR128DRI;
+
+ switch (pR128->pixel_code) {
+ case 8:
+ /* These modes are not supported (yet). */
+ case 15:
+ case 24:
+ return FALSE;
+
+ /* Only 16 and 32 color depths are supports currently. */
+ case 16:
+ case 32:
+ break;
+ }
+
+ /* Create the DRI data structure, and fill it in before calling the
+ DRIScreenInit(). */
+ if (!(pDRIInfo = DRICreateInfoRec())) return FALSE;
+
+ pR128->pDRIInfo = pDRIInfo;
+ pDRIInfo->drmDriverName = R128_NAME;
+ pDRIInfo->clientDriverName = R128_NAME;
+ pDRIInfo->busIdString = xalloc(64);
+ sprintf(pDRIInfo->busIdString,
+ "PCI:%d:%d:%d",
+ pR128->PciInfo->bus,
+ pR128->PciInfo->device,
+ pR128->PciInfo->func);
+ pDRIInfo->ddxDriverMajorVersion = R128_VERSION_MAJOR;
+ pDRIInfo->ddxDriverMinorVersion = R128_VERSION_MINOR;
+ pDRIInfo->ddxDriverPatchVersion = R128_VERSION_PATCH;
+ pDRIInfo->frameBufferPhysicalAddress = pR128->LinearAddr;
+ pDRIInfo->frameBufferSize = pR128->FbMapSize;
+ pDRIInfo->frameBufferStride = (pScrn->displayWidth
+ * pR128->pixel_bytes);
+ pDRIInfo->ddxDrawableTableEntry = R128_MAX_DRAWABLES;
+ pDRIInfo->maxDrawableTableEntry = (SAREA_MAX_DRAWABLES
+ < R128_MAX_DRAWABLES
+ ? SAREA_MAX_DRAWABLES
+ : R128_MAX_DRAWABLES);
+
+#ifdef NOT_DONE
+ /* FIXME: Need to extend DRI protocol to pass this size back to
+ * client for SAREA mapping that includes a device private record
+ */
+ pDRIInfo->SAREASize =
+ ((sizeof(XF86DRISAREARec) + 0xfff) & 0x1000); /* round to page */
+ /* + shared memory device private rec */
+#else
+ /* For now the mapping works by using a fixed size defined
+ * in the SAREA header
+ */
+ if (sizeof(XF86DRISAREARec)+sizeof(R128SAREAPriv)>SAREA_MAX) {
+ ErrorF("Data does not fit in SAREA\n");
+ return FALSE;
+ }
+ pDRIInfo->SAREASize = SAREA_MAX;
+#endif
+
+ if (!(pR128DRI = (R128DRIPtr)xnfcalloc(sizeof(R128DRIRec),1))) {
+ DRIDestroyInfoRec(pR128->pDRIInfo);
+ pR128->pDRIInfo = NULL;
+ return FALSE;
+ }
+ pDRIInfo->devPrivate = pR128DRI;
+ pDRIInfo->devPrivateSize = sizeof(R128DRIRec);
+ pDRIInfo->contextSize = sizeof(R128DRIContextRec);
+
+ pDRIInfo->CreateContext = R128CreateContext;
+ pDRIInfo->DestroyContext = R128DestroyContext;
+ pDRIInfo->SwapContext = R128DRISwapContext;
+ pDRIInfo->InitBuffers = R128DRIInitBuffers;
+ pDRIInfo->MoveBuffers = R128DRIMoveBuffers;
+ pDRIInfo->bufferRequests = DRI_ALL_WINDOWS;
+
+ if (!DRIScreenInit(pScreen, pDRIInfo, &pR128->drmFD)) {
+ xfree(pDRIInfo->devPrivate);
+ pDRIInfo->devPrivate = NULL;
+ DRIDestroyInfoRec(pDRIInfo);
+ pDRIInfo = NULL;
+ return FALSE;
+ }
+
+ /* Initialize AGP */
+ if (!pR128->IsPCI && !R128DRIAgpInit(pR128, pScreen)) {
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ /* DRIScreenInit doesn't add all the
+ common mappings. Add additional
+ mappings here. */
+ if (!R128DRIMapInit(pR128, pScreen)) {
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ /* Initialize the ring buffer */
+ if (!pR128->IsPCI) R128DRICCEInitRingBuffer(pScrn);
+
+ /* Initialize the kernel data structures */
+ if (!R128DRIKernelInit(pR128, pScreen)) {
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ /* Initialize vertex buffers list */
+ if (!pR128->IsPCI && !R128DRIBufInit(pR128, pScreen)) {
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ /* FIXME: When are these mappings unmapped? */
+
+ if (!R128InitVisualConfigs(pScreen)) {
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Visual configs initialized\n");
+
+ /* Load the CCE Microcode */
+ R128DRILoadMicrocode(pScrn);
+
+ /* Reset the Graphics Engine */
+ R128EngineReset(pScrn);
+
+ return TRUE;
+}
+
+/* Finish initializing the device-dependent DRI state, and call
+ DRIFinishScreenInit() to complete the device-independent DRI
+ initialization. */
+Bool R128DRIFinishScreenInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+ R128SAREAPrivPtr pSAREAPriv;
+ R128DRIPtr pR128DRI;
+
+ /* Init and start the CCE */
+ R128DRICCEInit(pScrn);
+
+ pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScreen);
+ memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
+
+ pR128->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT;
+ /* pR128->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */
+
+ pR128DRI = (R128DRIPtr)pR128->pDRIInfo->devPrivate;
+ pR128DRI->registerHandle = pR128->registerHandle;
+ pR128DRI->registerSize = pR128->registerSize;
+
+ pR128DRI->ringHandle = pR128->ringHandle;
+ pR128DRI->ringMapSize = pR128->ringMapSize;
+ pR128DRI->ringSize = pR128->ringSize*1024*1024;
+
+ pR128DRI->ringReadPtrHandle = pR128->ringReadPtrHandle;
+ pR128DRI->ringReadMapSize = pR128->ringReadMapSize;
+
+ pR128DRI->vbHandle = pR128->vbHandle;
+ pR128DRI->vbMapSize = pR128->vbMapSize;
+ pR128DRI->vbOffset = pR128->vbStart;
+ pR128DRI->vbBufSize = pR128->vbBufSize;
+
+ pR128DRI->indHandle = pR128->indHandle;
+ pR128DRI->indMapSize = pR128->indMapSize;
+
+ pR128DRI->agpTexHandle = pR128->agpTexHandle;
+ pR128DRI->agpTexMapSize = pR128->agpTexMapSize;
+ pR128DRI->log2AGPTexGran = pR128->log2AGPTexGran;
+ pR128DRI->agpTexOffset = pR128->agpTexStart;
+
+ pR128DRI->deviceID = pR128->Chipset;
+ pR128DRI->width = pScrn->virtualX;
+ pR128DRI->height = pScrn->virtualY;
+ pR128DRI->depth = pScrn->depth;
+ pR128DRI->bpp = pScrn->bitsPerPixel;
+
+ pR128DRI->fbX = pR128->fbX;
+ pR128DRI->fbY = pR128->fbY;
+ pR128DRI->backX = pR128->backX;
+ pR128DRI->backY = pR128->backY;
+ pR128DRI->depthX = pR128->depthX;
+ pR128DRI->depthY = pR128->depthY;
+ pR128DRI->textureX = pR128->textureX;
+ pR128DRI->textureY = pR128->textureY;
+ pR128DRI->textureSize = pR128->textureSize;
+ pR128DRI->log2TexGran = pR128->log2TexGran;
+
+ pR128DRI->IsPCI = pR128->IsPCI;
+
+ pR128DRI->CCEMode = pR128->CCEMode;
+ pR128DRI->CCEFifoSize = pR128->CCEFifoSize;
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "0x%08lx %d\n",
+ pR128DRI->registerHandle, pR128DRI->registerSize);
+ return DRIFinishScreenInit(pScreen);
+}
+
+/* The screen is being closed, so clean up any state and free any
+ resources used by the DRI. */
+void R128DRICloseScreen(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+
+ /* Stop the CCE if it is still in use */
+ if (pR128->CCE2D) R128CCEStop(pScrn);
+
+ /* De-allocate vertex buffers */
+ if (pR128->vbBufs) {
+ drmUnmapBufs(pR128->vbBufs);
+ pR128->vbBufs = NULL;
+ }
+
+ /* De-allocate all kernel resources */
+ drmR128CleanupCCE(pR128->drmFD);
+
+ /* De-allocate all AGP resources */
+ if (pR128->agpTex) {
+ drmUnmap(pR128->agpTex, pR128->agpTexMapSize);
+ pR128->agpTex = NULL;
+ }
+ if (pR128->ind) {
+ drmUnmap(pR128->ind, pR128->indMapSize);
+ pR128->ind = NULL;
+ }
+ if (pR128->vb) {
+ drmUnmap(pR128->vb, pR128->vbMapSize);
+ pR128->vb = NULL;
+ }
+ if (pR128->ringReadPtr) {
+ drmUnmap(pR128->ringReadPtr, pR128->ringReadMapSize);
+ pR128->ringReadPtr = NULL;
+ }
+ if (pR128->ring) {
+ drmUnmap(pR128->ring, pR128->ringMapSize);
+ pR128->ring = NULL;
+ }
+ if (pR128->agpMemHandle) {
+ drmAgpUnbind(pR128->drmFD, pR128->agpMemHandle);
+ drmAgpFree(pR128->drmFD, pR128->agpMemHandle);
+ pR128->agpMemHandle = 0;
+ drmAgpRelease(pR128->drmFD);
+ }
+
+ /* De-allocate all DRI resources */
+ DRICloseScreen(pScreen);
+
+ /* De-allocate all DRI data structures */
+ if (pR128->pDRIInfo) {
+ if (pR128->pDRIInfo->devPrivate) {
+ xfree(pR128->pDRIInfo->devPrivate);
+ pR128->pDRIInfo->devPrivate = NULL;
+ }
+ DRIDestroyInfoRec(pR128->pDRIInfo);
+ pR128->pDRIInfo = NULL;
+ }
+ if (pR128->pVisualConfigs) {
+ xfree(pR128->pVisualConfigs);
+ pR128->pVisualConfigs = NULL;
+ }
+ if (pR128->pVisualConfigsPriv) {
+ xfree(pR128->pVisualConfigsPriv);
+ pR128->pVisualConfigsPriv = NULL;
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h
new file mode 100644
index 000000000..533aadb2f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h
@@ -0,0 +1,116 @@
+/* $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>
+ * Rickard E. Faith <faith@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_DRI_
+#define _R128_DRI_
+
+#include <xf86drm.h>
+
+/* DRI Driver defaults */
+#define R128_DEFAULT_CCE_PIO_MODE R128_PM4_64PIO_64VCBM_64INDBM
+#define R128_DEFAULT_CCE_BM_MODE R128_PM4_64BM_64VCBM_64INDBM
+#define R128_DEFAULT_AGP_MODE 2
+#define R128_DEFAULT_AGP_SIZE 8 /* MB (must be a power of 2 and > 4MB) */
+#define R128_DEFAULT_RING_SIZE 1 /* MB (must be page aligned) */
+#define R128_DEFAULT_VB_SIZE 1 /* MB (must be page aligned) */
+#define R128_DEFAULT_IND_SIZE 1 /* MB (must be page aligned) */
+#define R128_DEFAULT_AGP_TEX_SIZE 1 /* MB (must be page aligned) */
+
+#define R128_DEFAULT_VB_BUF_SIZE 16384 /* bytes */
+#define R128_DEFAULT_CCE_TIMEOUT 10000 /* usecs */
+
+#define R128_AGP_MAX_MODE 2
+
+#define R128CCE_USE_RING_BUFFER(m) \
+(((m) == R128_PM4_192BM) || \
+ ((m) == R128_PM4_128BM_64INDBM) || \
+ ((m) == R128_PM4_64BM_128INDBM) || \
+ ((m) == R128_PM4_64BM_64VCBM_64INDBM))
+
+typedef struct {
+ /* MMIO register data */
+ drmHandle registerHandle;
+ drmSize registerSize;
+
+ /* CCE ring buffer data */
+ drmHandle ringHandle;
+ drmSize ringMapSize;
+ int ringSize;
+
+ /* CCE ring read pointer data */
+ drmHandle ringReadPtrHandle;
+ drmSize ringReadMapSize;
+
+ /* CCE vertex buffer data */
+ drmHandle vbHandle;
+ drmSize vbMapSize;
+ int vbOffset;
+ int vbBufSize;
+
+ /* CCE indirect buffer data */
+ drmHandle indHandle;
+ drmSize indMapSize;
+
+ /* CCE AGP Texture data */
+ drmHandle agpTexHandle;
+ drmSize agpTexMapSize;
+ int log2AGPTexGran;
+ int agpTexOffset;
+
+ /* DRI screen private data */
+ int deviceID; /* PCI device ID */
+ int width; /* Width in pixels of display */
+ int height; /* Height in scanlines of display */
+ int depth; /* Depth of display (8, 15, 16, 24) */
+ int bpp; /* Bit depth of display (8, 16, 24, 32) */
+
+ int fbX; /* Start of frame buffer */
+ int fbY;
+ int backX; /* Start of shared back buffer */
+ int backY;
+ int depthX; /* Start of shared depth buffer */
+ int depthY;
+ int textureX; /* Start of texture data in frame buffer */
+ int textureY;
+ int textureSize;
+ int log2TexGran;
+
+ int IsPCI; /* Current card is a PCI card */
+
+ int CCEMode; /* CCE mode that server/clients use */
+ int CCEFifoSize; /* Size of the CCE command FIFO */
+} R128DRIRec, *R128DRIPtr;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h
new file mode 100644
index 000000000..acec5e269
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h
@@ -0,0 +1,54 @@
+/* $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:
+ * Rickard E. Faith <faith@precisioninsight.com>
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_DRIPRIV_H_
+#define _R128_DRIPRIV_H_
+
+#define R128_MAX_DRAWABLES 256
+
+extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **configprivs);
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} R128ConfigPrivRec, *R128ConfigPrivPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} R128DRIContextRec, *R128DRIContextPtr;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c
index b5da4cb6e..f30d86aa8 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c
@@ -1,8 +1,8 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c,v 1.26 2000/03/06 23:17:44 martin Exp $ */
/**************************************************************************
-Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+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
@@ -107,6 +107,19 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* VESA support */
#include "vbe.h"
+ /* DRI support */
+#ifdef XF86DRI
+#include "GL/glxint.h"
+#include "xf86drm.h"
+#include "sarea.h"
+#define _XF86DRI_SERVER_
+#include "xf86dri.h"
+#include "dri.h"
+#include "r128_dri.h"
+#include "r128_dripriv.h"
+#include "r128_sarea.h"
+#endif
+
/* Driver data structures */
#include "r128.h"
#include "r128_reg.h"
@@ -176,17 +189,41 @@ typedef enum {
OPTION_HW_CURSOR,
OPTION_DAC_6BIT,
OPTION_DAC_8BIT,
+#ifdef XF86DRI
+ OPTION_IS_PCI,
+ OPTION_CCE_PIO,
+ OPTION_NO_SECURITY,
+ OPTION_USEC_TIMEOUT,
+ OPTION_AGP_MODE,
+ OPTION_AGP_SIZE,
+ OPTION_RING_SIZE,
+ OPTION_VERT_SIZE,
+ OPTION_VBUF_SIZE,
+ OPTION_USE_CCE_2D,
+#endif
OPTION_FBDEV
} R128Opts;
static OptionInfoRec R128Options[] = {
- { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, TRUE },
- { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE },
- { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
+ { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, TRUE },
+ { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE },
+#ifdef XF86DRI
+ { OPTION_IS_PCI, "ForcePCIMode", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_CCE_PIO, "CCEPIOMode", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_NO_SECURITY, "CCENoSecurity", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_USEC_TIMEOUT, "CCEusecTimeout", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_AGP_MODE, "AGPMode", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_RING_SIZE, "RingSize", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_VERT_SIZE, "VBListSize", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_VBUF_SIZE, "VBSize", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_USE_CCE_2D, "UseCCEfor2D", OPTV_BOOLEAN, {0}, FALSE },
+#endif
+ { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
};
R128RAMRec R128RAM[] = { /* Memory Specifications
@@ -299,6 +336,38 @@ static const char *ramdacSymbols[] = {
NULL
};
+#ifdef XF86DRI
+static const char *drmSymbols[] = {
+ "drmAddBufs",
+ "drmAddMap",
+ "drmAvailable",
+ "drmCtlAddCommand",
+ "drmCtlInstHandler",
+ "drmGetInterruptFromBusID",
+ "drmMapBufs",
+ "drmMarkBufs",
+ "drmUnmapBufs",
+ NULL
+};
+
+static const char *driSymbols[] = {
+ "DRIGetDrawableIndex",
+ "DRIFinishScreenInit",
+ "DRIDestroyInfoRec",
+ "DRICloseScreen",
+ "DRIDestroyInfoRec",
+ "DRIScreenInit",
+ "DRIDestroyInfoRec",
+ "DRICreateInfoRec",
+ "DRILock",
+ "DRIUnlock",
+ "DRIGetSAREAPrivate",
+ "DRIGetContext",
+ "GlxSetVisualConfigs",
+ NULL
+};
+#endif
+
static MODULESETUPPROTO(R128Setup);
static XF86ModuleVersionInfo R128VersRec =
@@ -347,6 +416,10 @@ static pointer R128Setup(pointer module, pointer opts, int *errmaj,
xaaSymbols,
xf8_32bppSymbols,
ramdacSymbols,
+#ifdef XF86DRI
+ drmSymbols,
+ driSymbols,
+#endif
fbdevHWSymbols,
vbeSymbols,
0 /* ddcsymbols */,
@@ -518,7 +591,7 @@ static void R128Unblank(ScrnInfoPtr pScrn)
}
/* Compute log base 2 of val. */
-static int R128MinBits(int val)
+int R128MinBits(int val)
{
int bits;
@@ -779,6 +852,7 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn)
int offset = 0; /* RAM Type */
MessageType from;
unsigned char *R128MMIO;
+
/* Chipset */
from = X_PROBED;
if (dev->chipset && *dev->chipset) {
@@ -876,7 +950,7 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn)
switch (info->MemCntl & 0x3) {
case 0: /* SDR SGRAM 1:1 */
switch (info->Chipset) {
- case PCI_CHIP_RAGE128RE:
+ case PCI_CHIP_RAGE128RE:
case PCI_CHIP_RAGE128RF: offset = 0; break; /* 128-bit SDR SGRAM 1:1 */
case PCI_CHIP_RAGE128RK:
case PCI_CHIP_RAGE128RL:
@@ -895,12 +969,28 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn)
pScrn->videoRam);
from = X_CONFIG;
pScrn->videoRam = dev->videoRam;
- }
+ }
pScrn->videoRam &= ~1023;
info->FbMapSize = pScrn->videoRam * 1024;
xf86DrvMsg(pScrn->scrnIndex, from,
"VideoRAM: %d kByte (%s)\n", pScrn->videoRam, info->ram->name);
+#ifdef XF86DRI
+ /* AGP/PCI */
+ if (xf86ReturnOptValBool(R128Options, OPTION_IS_PCI, FALSE)) {
+ info->IsPCI = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forced into PCI-only mode\n");
+ } else {
+ switch (info->Chipset) {
+ case PCI_CHIP_RAGE128RE:
+ case PCI_CHIP_RAGE128RK: info->IsPCI = TRUE; break;
+ case PCI_CHIP_RAGE128RF:
+ case PCI_CHIP_RAGE128RL:
+ case PCI_CHIP_RAGE128PF:
+ default: info->IsPCI = FALSE; break;
+ }
+ }
+#endif
return TRUE;
}
@@ -1053,6 +1143,143 @@ static Bool R128PreInitInt10(ScrnInfoPtr pScrn)
return TRUE;
}
+#ifdef XF86DRI
+static Bool R128PreInitDRI(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+
+ if (info->IsPCI) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CCE in PIO mode\n");
+ info->CCEMode = R128_DEFAULT_CCE_PIO_MODE;
+ } else if (xf86ReturnOptValBool(R128Options, OPTION_CCE_PIO, FALSE)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CCE in PIO mode\n");
+ info->CCEMode = R128_DEFAULT_CCE_PIO_MODE;
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CCE in BM mode\n");
+ info->CCEMode = R128_DEFAULT_CCE_BM_MODE;
+ }
+
+ if (xf86ReturnOptValBool(R128Options, OPTION_USE_CCE_2D, FALSE)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using CCE for 2D\n");
+ info->CCE2D = TRUE;
+ } else {
+ info->CCE2D = FALSE;
+ }
+
+ if (xf86ReturnOptValBool(R128Options, OPTION_NO_SECURITY, FALSE)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "WARNING!!! CCE Security checks disabled!!! **********\n");
+ info->CCESecure = FALSE;
+ } else {
+ info->CCESecure = TRUE;
+ }
+
+ info->agpMode = R128_DEFAULT_AGP_MODE;
+ info->agpSize = R128_DEFAULT_AGP_SIZE;
+ info->ringSize = R128_DEFAULT_RING_SIZE;
+ info->vbSize = R128_DEFAULT_VB_SIZE;
+ info->indSize = R128_DEFAULT_IND_SIZE;
+ info->agpTexSize = R128_DEFAULT_AGP_TEX_SIZE;
+
+ info->vbBufSize = R128_DEFAULT_VB_BUF_SIZE;
+
+ info->CCEusecTimeout = R128_DEFAULT_CCE_TIMEOUT;
+
+ if (!info->IsPCI) {
+ if (xf86GetOptValInteger(R128Options,
+ OPTION_AGP_MODE, &(info->agpMode))) {
+ if (info->agpMode < 1 || info->agpMode > R128_AGP_MAX_MODE) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Illegal AGP Mode: %d\n", info->agpMode);
+ return FALSE;
+ }
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using AGP %dx mode\n", info->agpMode);
+ }
+
+ if (xf86GetOptValInteger(R128Options,
+ OPTION_AGP_SIZE, (int *)&(info->agpSize))) {
+ switch (info->agpSize) {
+ case 4:
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+ case 128:
+ case 256:
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Illegal AGP size: %d MB\n", info->agpSize);
+ return FALSE;
+ }
+ }
+
+ if (xf86GetOptValInteger(R128Options,
+ OPTION_RING_SIZE, &(info->ringSize))) {
+ if (info->ringSize < 1 || info->ringSize >= info->agpSize) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Illegal ring buffer size: %d MB\n",
+ info->ringSize);
+ return FALSE;
+ }
+ }
+
+ if (xf86GetOptValInteger(R128Options,
+ OPTION_VERT_SIZE, &(info->vbSize))) {
+ if (info->vbSize < 1 || info->vbSize >= info->agpSize) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Illegal vertex buffers list size: %d MB\n",
+ info->vbSize);
+ return FALSE;
+ }
+ }
+
+ if (xf86GetOptValInteger(R128Options,
+ OPTION_VBUF_SIZE, &(info->vbBufSize))) {
+ int numBufs = info->vbSize*1024*1024/info->vbBufSize;
+ if (numBufs < 2 || numBufs > 512) { /* FIXME: 512 is arbitrary */
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Illegal individual vertex buffer size: %d bytes\n",
+ info->vbBufSize);
+ return FALSE;
+ }
+ }
+
+ if (info->ringSize + info->vbSize + info->indSize + info->agpTexSize >
+ info->agpSize) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Buffers are too big for requested AGP space\n");
+ return FALSE;
+ }
+
+ info->agpTexSize = info->agpSize - (info->ringSize +
+ info->vbSize +
+ info->indSize);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using %d MB AGP aperture\n", info->agpSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using %d MB for the ring buffer\n", info->ringSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using %d MB for vertex buffers\n", info->vbSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using %d MB for indirect buffers\n", info->indSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using %d MB for AGP textures\n", info->agpTexSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using %d byte vertex buffers\n", info->vbBufSize);
+ }
+
+ if (xf86GetOptValInteger(R128Options, OPTION_USEC_TIMEOUT,
+ &(info->CCEusecTimeout))) {
+ /* This option checked by the R128 DRM kernel module */
+ }
+
+ return TRUE;
+}
+#endif
+
extern xf86MonPtr ConfiguredMonitor;
static void
@@ -1152,6 +1379,10 @@ static Bool R128PreInit(ScrnInfoPtr pScrn, int flags)
if (!R128PreInitAccel(pScrn)) goto fail;
+#ifdef XF86DRI
+ if (!R128PreInitDRI(pScrn)) goto fail;
+#endif
+
return TRUE;
fail:
@@ -1231,9 +1462,20 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
R128TRACE(("R128ScreenInit %x %d\n", pScrn->memPhysBase, pScrn->fbOffset));
+#ifdef XF86DRI
+ /* Turn off the CCE for now. */
+ info->CCEInUse = FALSE;
+#endif
+
if (!R128MapMem(pScrn)) return FALSE;
pScrn->fbOffset = 0;
-
+#ifdef XF86DRI
+ info->fbX = 0;
+ info->fbY = 0;
+#endif
+
+ info->PaletteSavedOnVT = FALSE;
+
R128Save(pScrn);
if (info->FBDev) {
if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) return FALSE;
@@ -1251,6 +1493,18 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
pScrn->rgbBits,
pScrn->defaultVisual)) return FALSE;
+#ifdef XF86DRI
+ /* Setup DRI after visuals have been
+ established, but before cfbScreenInit is
+ called. cfbScreenInit will eventually
+ call the driver's InitGLXVisuals call
+ back. */
+ if (!xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE))
+ info->directRenderingEnabled = R128DRIScreenInit(pScreen);
+ else
+ info->directRenderingEnabled = FALSE;
+#endif
+
#ifdef USE_FB
if (!fbScreenInit (pScreen, info->FB,
pScrn->virtualX, pScrn->virtualY,
@@ -1358,6 +1612,101 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
}
}
+#ifdef XF86DRI
+ /* Allocate frame buffer space for the
+ shared back and depth buffers as well
+ as for local textures. */
+ if (info->directRenderingEnabled) {
+ FBAreaPtr fbarea;
+ int width_bytes = pScrn->displayWidth * info->pixel_bytes;
+ int maxy = info->FbMapSize / width_bytes;
+ int l;
+
+ /* Allocate the shared back buffer */
+ if ((fbarea = xf86AllocateOffscreenArea(pScreen,
+ pScrn->virtualX,
+ pScrn->virtualY,
+ 32, NULL, NULL, NULL))) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved back buffer from (%d,%d) to (%d,%d)\n",
+ fbarea->box.x1, fbarea->box.y1,
+ fbarea->box.x2, fbarea->box.y2);
+
+ info->backX = fbarea->box.x1;
+ info->backY = fbarea->box.y1;
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve back buffer\n");
+ info->backX = -1;
+ info->backY = -1;
+ }
+
+ /* Allocate the shared depth buffer */
+ if ((fbarea = xf86AllocateOffscreenArea(pScreen,
+ pScrn->virtualX,
+ pScrn->virtualY,
+ 32, NULL, NULL, NULL))) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved depth buffer from (%d,%d) to (%d,%d)\n",
+ fbarea->box.x1, fbarea->box.y1,
+ fbarea->box.x2, fbarea->box.y2);
+
+ info->depthX = fbarea->box.x1;
+ info->depthY = fbarea->box.y1;
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve depth buffer\n");
+ info->depthX = -1;
+ info->depthY = -1;
+ }
+
+ /* Allocate local texture space */
+ if (((maxy - MemBox.y2 - 1) * width_bytes) >
+ (pScrn->virtualX * pScrn->virtualY * 2 * info->pixel_bytes)) {
+ info->textureX = 0;
+ info->textureY = MemBox.y2 + 1;
+ info->textureSize = (maxy - MemBox.y2 - 1) * width_bytes;
+
+ l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS);
+ if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
+
+ info->log2TexGran = l;
+ info->textureSize = (info->textureSize >> l) << l;
+
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n",
+ info->textureSize/1024,
+ info->textureX, info->textureY,
+ pScrn->displayWidth, maxy);
+ } else if ((fbarea = xf86AllocateOffscreenArea(pScreen,
+ pScrn->virtualX,
+ pScrn->virtualY * 2,
+ 32,
+ NULL, NULL, NULL))) {
+ info->textureX = fbarea->box.x1;
+ info->textureY = fbarea->box.y1;
+ info->textureSize = ((fbarea->box.y2 - fbarea->box.y1) *
+ (fbarea->box.x2 - fbarea->box.x1) *
+ info->pixel_bytes);
+
+ l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS);
+ if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
+
+ info->log2TexGran = l;
+ info->textureSize = (info->textureSize >> l) << l;
+
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n",
+ info->textureSize/1024,
+ fbarea->box.x1, fbarea->box.y1,
+ fbarea->box.x2, fbarea->box.y2);
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Unable to reserve texture space in frame buffer\n");
+ info->textureX = -1;
+ info->textureY = -1;
+ }
+ }
+#endif
+
/* Backing store setup */
miInitializeBackingStore(pScreen);
xf86SetBackingStore(pScreen);
@@ -1453,6 +1802,21 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
if (serverGeneration == 1)
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+#ifdef XF86DRI
+ /* DRI finalization */
+ if (info->directRenderingEnabled) {
+ /* Now that mi, cfb, drm and others have
+ done their thing, complete the DRI
+ setup. */
+ info->directRenderingEnabled = R128DRIFinishScreenInit(pScreen);
+ }
+ if (info->directRenderingEnabled) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering enabled\n");
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering disabled\n");
+ }
+#endif
+
return TRUE;
}
@@ -1473,7 +1837,7 @@ static void R128RestoreCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr restore)
OUTREG(R128_GEN_INT_CNTL, restore->gen_int_cntl);
OUTREG(R128_CAP0_TRIG_CNTL, restore->cap0_trig_cntl);
OUTREG(R128_CAP1_TRIG_CNTL, restore->cap1_trig_cntl);
- OUTREG(R128_BUS_CNTL, restore->bus_cntl);
+ OUTREG(R128_BUS_CNTL, restore->bus_cntl);
}
/* Write CRTC registers. */
@@ -1603,7 +1967,7 @@ static void R128SaveCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr save)
save->gen_int_cntl = INREG(R128_GEN_INT_CNTL);
save->cap0_trig_cntl = INREG(R128_CAP0_TRIG_CNTL);
save->cap1_trig_cntl = INREG(R128_CAP1_TRIG_CNTL);
- save->bus_cntl = INREG(R128_BUS_CNTL);
+ save->bus_cntl = INREG(R128_BUS_CNTL);
}
/* Read CRTC registers. */
@@ -2025,7 +2389,7 @@ static Bool R128Init(ScrnInfoPtr pScrn, DisplayModePtr mode, R128SavePtr save)
R128InitPLLRegisters(pScrn, save, mode, &info->pll, dot_clock);
if (!R128InitDDARegisters(pScrn, save, mode, &info->pll, info))
return FALSE;
- R128InitPalette(save, info);
+ if (!info->PaletteSavedOnVT) R128InitPalette(save, info);
R128TRACE(("R128Init returns %p\n", save));
return TRUE;
@@ -2037,6 +2401,7 @@ static Bool R128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
R128InfoPtr info = R128PTR(pScrn);
if (!R128Init(pScrn, mode, &info->ModeReg)) return FALSE;
+ /* FIXME? DRILock/DRIUnlock here? */
R128Blank(pScrn);
R128RestoreMode(pScrn, &info->ModeReg);
R128Unblank(pScrn);
@@ -2096,14 +2461,43 @@ static void R128AdjustFrame(int scrnIndex, int x, int y, int flags)
mode. */
static Bool R128EnterVT(int scrnIndex, int flags)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ R128InfoPtr info = R128PTR(pScrn);
R128TRACE(("R128EnterVT\n"));
+#ifdef XF86DRI
+ if (R128PTR(pScrn)->directRenderingEnabled) {
+ R128CCEStart(pScrn);
+ DRIUnlock(pScrn->pScreen);
+ }
+#endif
if (!R128ModeInit(pScrn, pScrn->currentMode)) return FALSE;
+ info->PaletteSavedOnVT = FALSE;
R128AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
return TRUE;
}
+/* Called when VT switching away from the X server. Restore the original
+ text mode. */
+static void R128LeaveVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ R128InfoPtr info = R128PTR(pScrn);
+ R128SavePtr save = &info->ModeReg;
+
+ R128TRACE(("R128LeaveVT\n"));
+#ifdef XF86DRI
+ if (R128PTR(pScrn)->directRenderingEnabled) {
+ DRILock(pScrn->pScreen, 0);
+ R128CCEStop(pScrn);
+ }
+#endif
+ R128SavePalette(pScrn, save);
+ info->PaletteSavedOnVT = TRUE;
+ R128Restore(pScrn);
+}
+
static Bool
R128EnterVTFBDev(int scrnIndex, int flags)
{
@@ -2116,8 +2510,6 @@ R128EnterVTFBDev(int scrnIndex, int flags)
return TRUE;
}
-/* Called when VT switching away from the X server. Restore the original
- text mode. */
static void R128LeaveVTFBDev(int scrnIndex, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
@@ -2127,14 +2519,6 @@ static void R128LeaveVTFBDev(int scrnIndex, int flags)
fbdevHWLeaveVT(scrnIndex,flags);
}
-static void R128LeaveVT(int scrnIndex, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-
- R128TRACE(("R128LeaveVT\n"));
- R128Restore(pScrn);
-}
-
/* Called at the end of each server generation. Restore the original text
mode, unmap video memory, and unwrap and call the saved CloseScreen
function. */
@@ -2144,6 +2528,15 @@ static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen)
R128InfoPtr info = R128PTR(pScrn);
R128TRACE(("R128CloseScreen\n"));
+
+#ifdef XF86DRI
+ /* Disable direct rendering */
+ if (info->directRenderingEnabled) {
+ R128DRICloseScreen(pScreen);
+ info->directRenderingEnabled = FALSE;
+ }
+#endif
+
if (pScrn->vtSema) {
R128Restore(pScrn);
R128UnmapMem(pScrn);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h
index 86652affa..cb5c9b7a3 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h
@@ -1,8 +1,8 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h,v 1.6 2000/02/23 04:47:19 martin Exp $ */
/**************************************************************************
-Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+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
@@ -159,9 +159,20 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_AGP_APER_OFFSET 0x0178
#define R128_AGP_BASE 0x0170
#define R128_AGP_CNTL 0x0174
+# define R128_AGP_APER_SIZE_256MB (0x00 << 0)
+# define R128_AGP_APER_SIZE_128MB (0x20 << 0)
+# define R128_AGP_APER_SIZE_64MB (0x30 << 0)
+# define R128_AGP_APER_SIZE_32MB (0x38 << 0)
+# define R128_AGP_APER_SIZE_16MB (0x3c << 0)
+# define R128_AGP_APER_SIZE_8MB (0x3e << 0)
+# define R128_AGP_APER_SIZE_4MB (0x3f << 0)
+# define R128_AGP_APER_SIZE_MASK (0x3f << 0)
#define R128_AGP_COMMAND 0x0f58 /* PCI */
#define R128_AGP_PLL_CNTL 0x0010 /* PLL */
#define R128_AGP_STATUS 0x0f54 /* PCI */
+# define R128_AGP_1X_MODE 0x01
+# define R128_AGP_2X_MODE 0x02
+# define R128_AGP_MODE_MASK 0x03
#define R128_AMCGPIO_A_REG 0x01a0
#define R128_AMCGPIO_EN_REG 0x01a8
#define R128_AMCGPIO_MASK 0x0194
@@ -169,6 +180,15 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_ATTRDR 0x03c1 /* VGA */
#define R128_ATTRDW 0x03c0 /* VGA */
#define R128_ATTRX 0x03c0 /* VGA */
+# define R128_AUX1_SC_EN (1 << 0)
+# define R128_AUX1_SC_MODE_OR (0 << 1)
+# define R128_AUX1_SC_MODE_NAND (1 << 1)
+# define R128_AUX2_SC_EN (1 << 2)
+# define R128_AUX2_SC_MODE_OR (0 << 3)
+# define R128_AUX2_SC_MODE_NAND (1 << 3)
+# define R128_AUX3_SC_EN (1 << 4)
+# define R128_AUX3_SC_MODE_OR (0 << 5)
+# define R128_AUX3_SC_MODE_NAND (1 << 5)
#define R128_AUX_SC_CNTL 0x1660
#define R128_AUX1_SC_BOTTOM 0x1670
#define R128_AUX1_SC_LEFT 0x1664
@@ -257,11 +277,12 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_BRUSH_SCALE 0x1470
#define R128_BRUSH_Y_X 0x1474
#define R128_BUS_CNTL 0x0030
-# define R128_BUS_RD_DISCARD_EN (1 << 24)
-# define R128_BUS_RD_ABORT_EN (1 << 25)
-# define R128_BUS_MSTR_DISCONNECT_EN (1 << 28)
-# define R128_BUS_WRT_BURST (1 << 29)
-# define R128_BUS_READ_BURST (1 << 30)
+# define R128_BUS_MASTER_DIS (1 << 6)
+# define R128_BUS_RD_DISCARD_EN (1 << 24)
+# define R128_BUS_RD_ABORT_EN (1 << 25)
+# define R128_BUS_MSTR_DISCONNECT_EN (1 << 28)
+# define R128_BUS_WRT_BURST (1 << 29)
+# define R128_BUS_READ_BURST (1 << 30)
#define R128_BUS_CNTL1 0x0034
#define R128_CACHE_CNTL 0x1724
@@ -297,6 +318,9 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_CONFIG_REG_APER_SIZE 0x0110
#define R128_CONFIG_XSTRAP 0x00e4
#define R128_CONSTANT_COLOR_C 0x1d34
+# define R128_CONSTANT_COLOR_MASK 0x00ffffff
+# define R128_CONSTANT_COLOR_ONE 0x00ffffff
+# define R128_CONSTANT_COLOR_ZERO 0x00000000
#define R128_CRC_CMDFIFO_ADDR 0x0740
#define R128_CRC_CMDFIFO_DOUT 0x0744
#define R128_CRTC_CRNT_FRAME 0x0214
@@ -360,8 +384,13 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_DEFAULT_SC_BOTTOM_RIGHT 0x16e8
# define R128_DEFAULT_SC_RIGHT_MAX (0x1fff << 0)
# define R128_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16)
-#define R128_DESTINATION_3D_CLR_CMP_MSK 0x1824
+#define R128_FOG_3D_TABLE_START 0x1810
+#define R128_FOG_3D_TABLE_END 0x1814
+#define R128_FOG_3D_TABLE_DENSITY 0x181c
+#define R128_FOG_TABLE_INDEX 0x1a14
+#define R128_FOG_TABLE_DATA 0x1a18
#define R128_DESTINATION_3D_CLR_CMP_VAL 0x1820
+#define R128_DESTINATION_3D_CLR_CMP_MSK 0x1824
#define R128_DEVICE_ID 0x0f02 /* PCI */
#define R128_DP_BRUSH_BKGD_CLR 0x1478
#define R128_DP_BRUSH_FRGD_CLR 0x147c
@@ -373,6 +402,7 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
# define R128_DST_Y_DIR_TOP_TO_BOTTOM (1 << 15)
# define R128_DST_X_DIR_LEFT_TO_RIGHT (1 << 31)
#define R128_DP_DATATYPE 0x16c4
+# define R128_HOST_BIG_ENDIAN_EN (1 << 29)
#define R128_DP_GUI_MASTER_CNTL 0x146c
# define R128_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0)
# define R128_GMC_DST_PITCH_OFFSET_CNTL (1 << 1)
@@ -388,6 +418,19 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
# define R128_GMC_BRUSH_8x8_COLOR (10 << 4)
# define R128_GMC_BRUSH_1X8_COLOR (12 << 4)
# define R128_GMC_BRUSH_SOLID_COLOR (13 << 4)
+# define R128_GMC_BRUSH_NONE (15 << 4)
+# define R128_GMC_DST_8BPP_CI (2 << 8)
+# define R128_GMC_DST_15BPP (3 << 8)
+# define R128_GMC_DST_16BPP (4 << 8)
+# define R128_GMC_DST_24BPP (5 << 8)
+# define R128_GMC_DST_32BPP (6 << 8)
+# define R128_GMC_DST_8BPP_RGB (7 << 8)
+# define R128_GMC_DST_Y8 (8 << 8)
+# define R128_GMC_DST_RGB8 (9 << 8)
+# define R128_GMC_DST_VYUY (11 << 8)
+# define R128_GMC_DST_YVYU (12 << 8)
+# define R128_GMC_DST_AYUV444 (14 << 8)
+# define R128_GMC_DST_ARGB4444 (15 << 8)
# define R128_GMC_DST_DATATYPE_MASK (0x0f << 8)
# define R128_GMC_DST_DATATYPE_SHIFT 8
# define R128_GMC_SRC_DATATYPE_MASK (3 << 12)
@@ -395,8 +438,11 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
# define R128_GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12)
# define R128_GMC_SRC_DATATYPE_COLOR (3 << 12)
# define R128_GMC_BYTE_PIX_ORDER (1 << 14)
+# define R128_GMC_BYTE_MSB_TO_LSB (0 << 14)
# define R128_GMC_BYTE_LSB_TO_MSB (1 << 14)
# define R128_GMC_CONVERSION_TEMP (1 << 15)
+# define R128_GMC_CONVERSION_TEMP_6500 (0 << 15)
+# define R128_GMC_CONVERSION_TEMP_9300 (1 << 15)
# define R128_GMC_ROP3_MASK (0xff << 16)
# define R128_DP_SRC_SOURCE_MASK (7 << 24)
# define R128_DP_SRC_SOURCE_MEMORY (2 << 24)
@@ -404,7 +450,7 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
# define R128_GMC_3D_FCN_EN (1 << 27)
# define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28)
# define R128_AUX_CLIP_DIS (1 << 29)
-# define R128_GMC_WR_MSK_DS (1 << 30)
+# define R128_GMC_WR_MSK_DIS (1 << 30)
# define R128_GMC_LD_BRUSH_Y_X (1 << 31)
# define R128_ROP3_ZERO 0x00000000
# define R128_ROP3_DSa 0x00880000
@@ -456,6 +502,7 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_DST_PITCH 0x1408
#define R128_DST_PITCH_OFFSET 0x142c
#define R128_DST_PITCH_OFFSET_C 0x1c80
+# define R128_PITCH_SHIFT 21
#define R128_DST_WIDTH 0x140c
#define R128_DST_WIDTH_HEIGHT 0x1598
#define R128_DST_WIDTH_X 0x1588
@@ -573,7 +620,6 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_MEM_VGA_RP_SEL 0x003c
#define R128_MEM_VGA_WP_SEL 0x0038
#define R128_MIN_GRANT 0x0f3e /* PCI */
-#define R128_MISC_3D_STATE_CNTL_REG 0x1CA0
#define R128_MM_DATA 0x0004
#define R128_MM_INDEX 0x0000
#define R128_MPLL_CNTL 0x000e /* PLL */
@@ -592,7 +638,10 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_PC_DEBUG_MODE 0x1760
#define R128_PC_GUI_CTLSTAT 0x1748
#define R128_PC_GUI_MODE 0x1744
+# define R128_PC_IGNORE_UNIFY (1 << 5)
#define R128_PC_NGUI_CTLSTAT 0x0184
+# define R128_PC_FLUSH_GUI (3 << 0)
+# define R128_PC_RI_GUI (1 << 2)
# define R128_PC_FLUSH_ALL 0x00ff
# define R128_PC_BUSY (1 << 31)
#define R128_PC_NGUI_MODE 0x0180
@@ -689,6 +738,537 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_XDLL_CNTL 0x000c /* PLL */
#define R128_XPLL_CNTL 0x000b /* PLL */
+ /* Registers for CCE and Microcode Engine */
+#define R128_PM4_MICROCODE_ADDR 0x07d4
+#define R128_PM4_MICROCODE_RADDR 0x07d8
+#define R128_PM4_MICROCODE_DATAH 0x07dc
+#define R128_PM4_MICROCODE_DATAL 0x07e0
+
+#define R128_PM4_BUFFER_OFFSET 0x0700
+#define R128_PM4_BUFFER_CNTL 0x0704
+# define R128_PM4_NONPM4 (0 << 28)
+# define R128_PM4_192PIO (1 << 28)
+# define R128_PM4_192BM (2 << 28)
+# define R128_PM4_128PIO_64INDBM (3 << 28)
+# define R128_PM4_128BM_64INDBM (4 << 28)
+# define R128_PM4_64PIO_128INDBM (5 << 28)
+# define R128_PM4_64BM_128INDBM (6 << 28)
+# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28)
+# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28)
+# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28)
+#define R128_PM4_BUFFER_WM_CNTL 0x0708
+# define R128_WMA_SHIFT 0
+# define R128_WMB_SHIFT 8
+# define R128_WMC_SHIFT 16
+# define R128_WB_WM_SHIFT 24
+#define R128_PM4_BUFFER_DL_RPTR_ADDR 0x070c
+#define R128_PM4_BUFFER_DL_RPTR 0x0710
+#define R128_PM4_BUFFER_DL_WPTR 0x0714
+# define R128_PM4_BUFFER_DL_DONE (1 << 31)
+#define R128_PM4_VC_FPU_SETUP 0x071c
+# define R128_FRONT_DIR_CW (0 << 0)
+# define R128_FRONT_DIR_CCW (1 << 0)
+# define R128_FRONT_DIR_MASK (1 << 0)
+# define R128_BACKFACE_CULL (0 << 1)
+# define R128_BACKFACE_POINTS (1 << 1)
+# define R128_BACKFACE_LINES (2 << 1)
+# define R128_BACKFACE_SOLID (3 << 1)
+# define R128_BACKFACE_MASK (3 << 1)
+# define R128_FRONTFACE_CULL (0 << 3)
+# define R128_FRONTFACE_POINTS (1 << 3)
+# define R128_FRONTFACE_LINES (2 << 3)
+# define R128_FRONTFACE_SOLID (3 << 3)
+# define R128_FRONTFACE_MASK (3 << 3)
+# define R128_FPU_COLOR_SOLID (0 << 5)
+# define R128_FPU_COLOR_FLAT (1 << 5)
+# define R128_FPU_COLOR_GOURAUD (2 << 5)
+# define R128_FPU_COLOR_GOURAUD2 (3 << 5)
+# define R128_FPU_SUB_PIX_2BITS (0 << 7)
+# define R128_FPU_SUB_PIX_4BITS (1 << 7)
+# define R128_FPU_MODE_2D (0 << 8)
+# define R128_FPU_MODE_3D (1 << 8)
+# define R128_TRAP_BITS_DISABLE (1 << 9)
+# define R128_EDGE_ANTIALIAS (1 << 10)
+# define R128_SUPERSAMPLE (1 << 11)
+# define R128_XFACTOR_2 (0 << 12)
+# define R128_XFACTOR_4 (1 << 12)
+# define R128_YFACTOR_2 (0 << 13)
+# define R128_YFACTOR_4 (1 << 13)
+# define R128_FLAT_SHADE_VERTEX_D3D (0 << 14)
+# define R128_FLAT_SHADE_VERTEX_OGL (1 << 14)
+# define R128_FPU_ROUND_TRUNCATE (0 << 15)
+# define R128_FPU_ROUND_NEAREST (1 << 15)
+# define R128_WM_SEL_8DW (0 << 16)
+# define R128_WM_SEL_16DW (1 << 16)
+# define R128_WM_SEL_32DW (2 << 16)
+#define R128_PM4_STAT 0x07b8
+# define R128_PM4_FIFOCNT_MASK 0x0fff
+# define R128_PM4_BUSY (1 << 16)
+# define R128_PM4_GUI_ACTIVE (1 << 31)
+#define R128_PM4_BUFFER_ADDR 0x07f0
+#define R128_PM4_MICRO_CNTL 0x07fc
+# define R128_PM4_MICRO_FREERUN (1 << 30)
+#define R128_PM4_FIFO_DATA_EVEN 0x1000
+#define R128_PM4_FIFO_DATA_ODD 0x1004
+
#define R128_SCALE_3D_CNTL 0x1a00
+# define R128_SCALE_DITHER_ERR_DIFF (0 << 1)
+# define R128_SCALE_DITHER_TABLE (1 << 1)
+# define R128_TEX_CACHE_SIZE_FULL (0 << 2)
+# define R128_TEX_CACHE_SIZE_HALF (1 << 2)
+# define R128_DITHER_INIT_CURR (0 << 3)
+# define R128_DITHER_INIT_RESET (1 << 3)
+# define R128_ROUND_24BIT (1 << 4)
+# define R128_TEX_CACHE_DISABLE (1 << 5)
+# define R128_SCALE_3D_NOOP (0 << 6)
+# define R128_SCALE_3D_SCALE (1 << 6)
+# define R128_SCALE_3D_TEXMAP_SHADE (2 << 6)
+# define R128_SCALE_PIX_BLEND (0 << 8)
+# define R128_SCALE_PIX_REPLICATE (1 << 8)
+# define R128_TEX_CACHE_SPLIT (1 << 9)
+# define R128_APPLE_YUV_MODE (1 << 10)
+# define R128_TEX_CACHE_PALLETE_MODE (1 << 11)
+# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12)
+# define R128_ALPHA_COMB_ADD_NCLAMP (1 << 12)
+# define R128_ALPHA_COMB_SUB_DST_SRC_CLAMP (2 << 12)
+# define R128_ALPHA_COMB_SUB_DST_SRC_NCLAMP (3 << 12)
+# define R128_FOG_TABLE (1 << 14)
+# define R128_SIGNED_DST_CLAMP (1 << 15)
+# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16)
+# define R128_ALPHA_BLEND_SRC_ONE (1 << 16)
+# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16)
+# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16)
+# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16)
+# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16)
+# define R128_ALPHA_BLEND_SRC_DSTALPHA (6 << 16)
+# define R128_ALPHA_BLEND_SRC_INVDSTALPHA (7 << 16)
+# define R128_ALPHA_BLEND_SRC_DSTCOLOR (8 << 16)
+# define R128_ALPHA_BLEND_SRC_INVDSTCOLOR (9 << 16)
+# define R128_ALPHA_BLEND_SRC_SAT (10 << 16)
+# define R128_ALPHA_BLEND_SRC_BLEND (11 << 16)
+# define R128_ALPHA_BLEND_SRC_INVBLEND (12 << 16)
+# define R128_ALPHA_BLEND_DST_ZERO (0 << 20)
+# define R128_ALPHA_BLEND_DST_ONE (1 << 20)
+# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20)
+# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20)
+# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20)
+# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20)
+# define R128_ALPHA_BLEND_DST_DSTALPHA (6 << 20)
+# define R128_ALPHA_BLEND_DST_INVDSTALPHA (7 << 20)
+# define R128_ALPHA_BLEND_DST_DSTCOLOR (8 << 20)
+# define R128_ALPHA_BLEND_DST_INVDSTCOLOR (9 << 20)
+# define R128_ALPHA_TEST_NEVER (0 << 24)
+# define R128_ALPHA_TEST_LESS (1 << 24)
+# define R128_ALPHA_TEST_LESSEQUAL (2 << 24)
+# define R128_ALPHA_TEST_EQUAL (3 << 24)
+# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24)
+# define R128_ALPHA_TEST_GREATER (5 << 24)
+# define R128_ALPHA_TEST_NEQUAL (6 << 24)
+# define R128_ALPHA_TEST_ALWAYS (7 << 24)
+# define R128_COMPOSITE_SHADOW_CMP_EQUAL (0 << 28)
+# define R128_COMPOSITE_SHADOW_CMP_NEQUAL (1 << 28)
+# define R128_COMPOSITE_SHADOW (1 << 29)
+# define R128_TEX_MAP_ALPHA_IN_TEXTURE (1 << 30)
+# define R128_TEX_CACHE_LINE_SIZE_8QW (0 << 31)
+# define R128_TEX_CACHE_LINE_SIZE_4QW (1 << 31)
+
+#define R128_SETUP_CNTL 0x1bc4
+# define R128_DONT_START_TRIANGLE (1 << 0)
+# define R128_Z_BIAS (0 << 1)
+# define R128_DONT_START_ANY_ON (1 << 2)
+# define R128_COLOR_SOLID_COLOR (0 << 3)
+# define R128_COLOR_FLAT_VERT_1 (1 << 3)
+# define R128_COLOR_FLAT_VERT_2 (2 << 3)
+# define R128_COLOR_FLAT_VERT_3 (3 << 3)
+# define R128_COLOR_GOURAUD (4 << 3)
+# define R128_PRIM_TYPE_TRI (0 << 7)
+# define R128_PRIM_TYPE_LINE (1 << 7)
+# define R128_PRIM_TYPE_POINT (2 << 7)
+# define R128_PRIM_TYPE_POLY_EDGE (3 << 7)
+# define R128_TEXTURE_ST_MULT_W (0 << 9)
+# define R128_TEXTURE_ST_DIRECT (1 << 9)
+# define R128_STARTING_VERTEX_1 (1 << 14)
+# define R128_STARTING_VERTEX_2 (2 << 14)
+# define R128_STARTING_VERTEX_3 (3 << 14)
+# define R128_ENDING_VERTEX_1 (1 << 16)
+# define R128_ENDING_VERTEX_2 (2 << 16)
+# define R128_ENDING_VERTEX_3 (3 << 16)
+# define R128_SU_POLY_LINE_LAST (0 << 18)
+# define R128_SU_POLY_LINE_NOT_LAST (1 << 18)
+# define R128_SUB_PIX_2BITS (0 << 19)
+# define R128_SUB_PIX_4BITS (1 << 19)
+# define R128_SET_UP_CONTINUE (1 << 31)
+
+#define R128_WINDOW_XY_OFFSET 0x1bcc
+# define R128_WINDOW_Y_SHIFT 4
+# define R128_WINDOW_X_SHIFT 20
+
+#define R128_Z_OFFSET_C 0x1c90
+#define R128_Z_PITCH_C 0x1c94
+#define R128_Z_STEN_CNTL_C 0x1c98
+# define R128_Z_PIX_WIDTH_16 (0 << 1)
+# define R128_Z_PIX_WIDTH_24 (1 << 1)
+# define R128_Z_PIX_WIDTH_32 (2 << 1)
+# define R128_Z_PIX_WIDTH_MASK (3 << 1)
+# define R128_Z_TEST_NEVER (0 << 4)
+# define R128_Z_TEST_LESS (1 << 4)
+# define R128_Z_TEST_LESSEQUAL (2 << 4)
+# define R128_Z_TEST_EQUAL (3 << 4)
+# define R128_Z_TEST_GREATEREQUAL (4 << 4)
+# define R128_Z_TEST_GREATER (5 << 4)
+# define R128_Z_TEST_NEQUAL (6 << 4)
+# define R128_Z_TEST_ALWAYS (7 << 4)
+# define R128_Z_TEST_MASK (7 << 4)
+# define R128_STENCIL_TEST_NEVER (0 << 12)
+# define R128_STENCIL_TEST_LESS (1 << 12)
+# define R128_STENCIL_TEST_LESSEQUAL (2 << 12)
+# define R128_STENCIL_TEST_EQUAL (3 << 12)
+# define R128_STENCIL_TEST_GREATEREQUAL (4 << 12)
+# define R128_STENCIL_TEST_GREATER (5 << 12)
+# define R128_STENCIL_TEST_NEQUAL (6 << 12)
+# define R128_STENCIL_TEST_ALWAYS (7 << 12)
+# define R128_STENCIL_S_FAIL_KEEP (0 << 16)
+# define R128_STENCIL_S_FAIL_ZERO (1 << 16)
+# define R128_STENCIL_S_FAIL_REPLACE (2 << 16)
+# define R128_STENCIL_S_FAIL_INC (3 << 16)
+# define R128_STENCIL_S_FAIL_DEC (4 << 16)
+# define R128_STENCIL_S_FAIL_INV (5 << 16)
+# define R128_STENCIL_ZPASS_KEEP (0 << 20)
+# define R128_STENCIL_ZPASS_ZERO (1 << 20)
+# define R128_STENCIL_ZPASS_REPLACE (2 << 20)
+# define R128_STENCIL_ZPASS_INC (3 << 20)
+# define R128_STENCIL_ZPASS_DEC (4 << 20)
+# define R128_STENCIL_ZPASS_INV (5 << 20)
+# define R128_STENCIL_ZFAIL_KEEP (0 << 24)
+# define R128_STENCIL_ZFAIL_ZERO (1 << 24)
+# define R128_STENCIL_ZFAIL_REPLACE (2 << 24)
+# define R128_STENCIL_ZFAIL_INC (3 << 24)
+# define R128_STENCIL_ZFAIL_DEC (4 << 24)
+# define R128_STENCIL_ZFAIL_INV (5 << 24)
+#define R128_TEX_CNTL_C 0x1c9c
+# define R128_Z_ENABLE (1 << 0)
+# define R128_Z_WRITE_ENABLE (1 << 1)
+# define R128_STENCIL_ENABLE (1 << 3)
+# define R128_SHADE_ENABLE (0 << 4)
+# define R128_TEXMAP_ENABLE (1 << 4)
+# define R128_SEC_TEXMAP_ENABLE (1 << 5)
+# define R128_FOG_ENABLE (1 << 7)
+# define R128_DITHER_ENABLE (1 << 8)
+# define R128_ALPHA_ENABLE (1 << 9)
+# define R128_ALPHA_TEST_ENABLE (1 << 10)
+# define R128_SPEC_LIGHT_ENABLE (1 << 11)
+# define R128_TEX_CHROMA_KEY_ENABLE (1 << 12)
+# define R128_ALPHA_IN_TEX_COMPLETE_A (0 << 13)
+# define R128_ALPHA_IN_TEX_LSB_A (1 << 13)
+# define R128_LIGHT_DIS (0 << 14)
+# define R128_LIGHT_COPY (1 << 14)
+# define R128_LIGHT_MODULATE (2 << 14)
+# define R128_LIGHT_ADD (3 << 14)
+# define R128_LIGHT_BLEND_CONSTANT (4 << 14)
+# define R128_LIGHT_BLEND_TEXTURE (5 << 14)
+# define R128_LIGHT_BLEND_VERTEX (6 << 14)
+# define R128_LIGHT_BLEND_CONST_COLOR (7 << 14)
+# define R128_ALPHA_LIGHT_DIS (0 << 18)
+# define R128_ALPHA_LIGHT_COPY (1 << 18)
+# define R128_ALPHA_LIGHT_MODULATE (2 << 18)
+# define R128_ALPHA_LIGHT_ADD (3 << 18)
+# define R128_ANTI_ALIAS (1 << 21)
+# define R128_TEX_CACHE_FLUSH (1 << 23)
+# define R128_LOD_BIAS_SHIFT 24
+#define R128_MISC_3D_STATE_CNTL_REG 0x1ca0
+# define R128_REF_ALPHA_MASK 0xff
+# define R128_MISC_SCALE_3D_NOOP (0 << 8)
+# define R128_MISC_SCALE_3D_SCALE (1 << 8)
+# define R128_MISC_SCALE_3D_TEXMAP_SHADE (2 << 8)
+# define R128_MISC_SCALE_PIX_BLEND (0 << 10)
+# define R128_MISC_SCALE_PIX_REPLICATE (1 << 10)
+# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12)
+# define R128_ALPHA_COMB_ADD_NO_CLAMP (1 << 12)
+# define R128_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12)
+# define R128_ALPHA_COMB_SUB_SRC_DST_NO_CLAMP (3 << 12)
+# define R128_FOG_VERTEX (0 << 14)
+# define R128_FOG_TABLE (1 << 14)
+# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16)
+# define R128_ALPHA_BLEND_SRC_ONE (1 << 16)
+# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16)
+# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16)
+# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16)
+# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16)
+# define R128_ALPHA_BLEND_SRC_DESTALPHA (6 << 16)
+# define R128_ALPHA_BLEND_SRC_INVDESTALPHA (7 << 16)
+# define R128_ALPHA_BLEND_SRC_DESTCOLOR (8 << 16)
+# define R128_ALPHA_BLEND_SRC_INVDESTCOLOR (9 << 16)
+# define R128_ALPHA_BLEND_SRC_SRCALPHASAT (10 << 16)
+# define R128_ALPHA_BLEND_SRC_BOTHSRCALPHA (11 << 16)
+# define R128_ALPHA_BLEND_SRC_BOTHINVSRCALPHA (12 << 16)
+# define R128_ALPHA_BLEND_SRC_MASK (15 << 16)
+# define R128_ALPHA_BLEND_DST_ZERO (0 << 20)
+# define R128_ALPHA_BLEND_DST_ONE (1 << 20)
+# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20)
+# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20)
+# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20)
+# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20)
+# define R128_ALPHA_BLEND_DST_DESTALPHA (6 << 20)
+# define R128_ALPHA_BLEND_DST_INVDESTALPHA (7 << 20)
+# define R128_ALPHA_BLEND_DST_DESTCOLOR (8 << 20)
+# define R128_ALPHA_BLEND_DST_INVDESTCOLOR (9 << 20)
+# define R128_ALPHA_BLEND_DST_SRCALPHASAT (10 << 20)
+# define R128_ALPHA_BLEND_DST_MASK (15 << 20)
+# define R128_ALPHA_TEST_NEVER (0 << 24)
+# define R128_ALPHA_TEST_LESS (1 << 24)
+# define R128_ALPHA_TEST_LESSEQUAL (2 << 24)
+# define R128_ALPHA_TEST_EQUAL (3 << 24)
+# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24)
+# define R128_ALPHA_TEST_GREATER (5 << 24)
+# define R128_ALPHA_TEST_NEQUAL (6 << 24)
+# define R128_ALPHA_TEST_ALWAYS (7 << 24)
+# define R128_ALPHA_TEST_MASK (7 << 24)
+#define R128_TEXTURE_CLR_CMP_CLR_C 0x1ca4
+#define R128_TEXTURE_CLR_CMP_MSK_C 0x1ca8
+#define R128_FOG_COLOR_C 0x1cac
+# define R128_FOG_BLUE_SHIFT 0
+# define R128_FOG_GREEN_SHIFT 8
+# define R128_FOG_RED_SHIFT 16
+#define R128_PRIM_TEX_CNTL_C 0x1cb0
+# define R128_MIN_BLEND_NEAREST (0 << 1)
+# define R128_MIN_BLEND_LINEAR (1 << 1)
+# define R128_MIN_BLEND_MIPNEAREST (2 << 1)
+# define R128_MIN_BLEND_MIPLINEAR (3 << 1)
+# define R128_MIN_BLEND_LINEARMIPNEAREST (4 << 1)
+# define R128_MIN_BLEND_LINEARMIPLINEAR (5 << 1)
+# define R128_MIN_BLEND_MASK (7 << 1)
+# define R128_MAG_BLEND_NEAREST (0 << 4)
+# define R128_MAG_BLEND_LINEAR (1 << 4)
+# define R128_MAG_BLEND_MASK (7 << 4)
+# define R128_MIP_MAP_DISABLE (1 << 7)
+# define R128_TEX_CLAMP_S_WRAP (0 << 8)
+# define R128_TEX_CLAMP_S_MIRROR (1 << 8)
+# define R128_TEX_CLAMP_S_CLAMP (2 << 8)
+# define R128_TEX_CLAMP_S_BORDER_COLOR (3 << 8)
+# define R128_TEX_CLAMP_S_MASK (3 << 8)
+# define R128_TEX_WRAP_S (1 << 10)
+# define R128_TEX_CLAMP_T_WRAP (0 << 11)
+# define R128_TEX_CLAMP_T_MIRROR (1 << 11)
+# define R128_TEX_CLAMP_T_CLAMP (2 << 11)
+# define R128_TEX_CLAMP_T_BORDER_COLOR (3 << 11)
+# define R128_TEX_CLAMP_T_MASK (3 << 11)
+# define R128_TEX_WRAP_T (1 << 13)
+# define R128_TEX_PERSPECTIVE_DISABLE (1 << 14)
+# define R128_DATATYPE_VQ (0 << 16)
+# define R128_DATATYPE_CI4 (1 << 16)
+# define R128_DATATYPE_CI8 (2 << 16)
+# define R128_DATATYPE_ARGB1555 (3 << 16)
+# define R128_DATATYPE_RGB565 (4 << 16)
+# define R128_DATATYPE_RGB888 (5 << 16)
+# define R128_DATATYPE_ARGB8888 (6 << 16)
+# define R128_DATATYPE_RGB332 (7 << 16)
+# define R128_DATATYPE_Y8 (8 << 16)
+# define R128_DATATYPE_RGB8 (9 << 16)
+# define R128_DATATYPE_CI16 (10 << 16)
+# define R128_DATATYPE_YUV422 (11 << 16)
+# define R128_DATATYPE_YUV422_2 (12 << 16)
+# define R128_DATATYPE_AYUV444 (14 << 16)
+# define R128_DATATYPE_ARGB4444 (15 << 16)
+# define R128_PALLETE_EITHER (0 << 20)
+# define R128_PALLETE_1 (1 << 20)
+# define R128_PALLETE_2 (2 << 20)
+# define R128_PSEUDOCOLOR_DT_RGB565 (0 << 24)
+# define R128_PSEUDOCOLOR_DT_ARGB1555 (1 << 24)
+# define R128_PSEUDOCOLOR_DT_ARGB4444 (2 << 24)
+#define R128_PRIM_TEXTURE_COMBINE_CNTL_C 0x1cb4
+# define R128_COMB_DIS (0 << 0)
+# define R128_COMB_COPY (1 << 0)
+# define R128_COMB_COPY_INP (2 << 0)
+# define R128_COMB_MODULATE (3 << 0)
+# define R128_COMB_MODULATE2X (4 << 0)
+# define R128_COMB_MODULATE4X (5 << 0)
+# define R128_COMB_ADD (6 << 0)
+# define R128_COMB_ADD_SIGNED (7 << 0)
+# define R128_COMB_BLEND_VERTEX (8 << 0)
+# define R128_COMB_BLEND_TEXTURE (9 << 0)
+# define R128_COMB_BLEND_CONST (10 << 0)
+# define R128_COMB_BLEND_PREMULT (11 << 0)
+# define R128_COMB_BLEND_PREV (12 << 0)
+# define R128_COMB_BLEND_PREMULT_INV (13 << 0)
+# define R128_COMB_ADD_SIGNED2X (14 << 0)
+# define R128_COMB_BLEND_CONST_COLOR (15 << 0)
+# define R128_COMB_MASK (15 << 0)
+# define R128_COLOR_FACTOR_TEX (4 << 4)
+# define R128_COLOR_FACTOR_NTEX (5 << 4)
+# define R128_COLOR_FACTOR_ALPHA (6 << 4)
+# define R128_COLOR_FACTOR_NALPHA (7 << 4)
+# define R128_COLOR_FACTOR_MASK (15 << 4)
+# define R128_INPUT_FACTOR_CONST_COLOR (2 << 10)
+# define R128_INPUT_FACTOR_CONST_ALPHA (3 << 10)
+# define R128_INPUT_FACTOR_INT_COLOR (4 << 10)
+# define R128_INPUT_FACTOR_INT_ALPHA (5 << 10)
+# define R128_INPUT_FACTOR_MASK (15 << 10)
+# define R128_COMB_ALPHA_DIS (0 << 14)
+# define R128_COMB_ALPHA_COPY (1 << 14)
+# define R128_COMB_ALPHA_COPY_INP (2 << 14)
+# define R128_COMB_ALPHA_MODULATE (3 << 14)
+# define R128_COMB_ALPHA_MODULATE2X (4 << 14)
+# define R128_COMB_ALPHA_MODULATE4X (5 << 14)
+# define R128_COMB_ALPHA_ADD (6 << 14)
+# define R128_COMB_ALPHA_ADD_SIGNED (7 << 14)
+# define R128_COMB_ALPHA_ADD_SIGNED2X (14 << 14)
+# define R128_COMB_ALPHA_MASK (15 << 14)
+# define R128_ALPHA_FACTOR_TEX_ALPHA (6 << 18)
+# define R128_ALPHA_FACTOR_NTEX_ALPHA (7 << 18)
+# define R128_ALPHA_FACTOR_MASK (15 << 18)
+# define R128_INP_FACTOR_A_CONST_ALPHA (1 << 25)
+# define R128_INP_FACTOR_A_INT_ALPHA (2 << 25)
+# define R128_INP_FACTOR_A_MASK (7 << 25)
+#define R128_TEX_SIZE_PITCH_C 0x1cb8
+# define R128_TEX_PITCH_SHIFT 0
+# define R128_TEX_SIZE_SHIFT 4
+# define R128_TEX_HEIGHT_SHIFT 8
+# define R128_TEX_MIN_SIZE_SHIFT 12
+# define R128_SEC_TEX_PITCH_SHIFT 16
+# define R128_SEC_TEX_SIZE_SHIFT 20
+# define R128_SEC_TEX_HEIGHT_SHIFT 24
+# define R128_SEC_TEX_MIN_SIZE_SHIFT 28
+# define R128_TEX_PITCH_MASK (0x0f << 0)
+# define R128_TEX_SIZE_MASK (0x0f << 4)
+# define R128_TEX_HEIGHT_MASK (0x0f << 8)
+# define R128_TEX_MIN_SIZE_MASK (0x0f << 12)
+# define R128_SEC_TEX_PITCH_MASK (0x0f << 16)
+# define R128_SEC_TEX_SIZE_MASK (0x0f << 20)
+# define R128_SEC_TEX_HEIGHT_MASK (0x0f << 24)
+# define R128_SEC_TEX_MIN_SIZE_MASK (0x0f << 28)
+# define R128_TEX_SIZE_PITCH_SHIFT 0
+# define R128_SEC_TEX_SIZE_PITCH_SHIFT 16
+# define R128_TEX_SIZE_PITCH_MASK (0xffff << 0)
+# define R128_SEC_TEX_SIZE_PITCH_MASK (0xffff << 16)
+#define R128_PRIM_TEX_0_OFFSET_C 0x1cbc
+#define R128_PRIM_TEX_1_OFFSET_C 0x1cc0
+#define R128_PRIM_TEX_2_OFFSET_C 0x1cc4
+#define R128_PRIM_TEX_3_OFFSET_C 0x1cc8
+#define R128_PRIM_TEX_4_OFFSET_C 0x1ccc
+#define R128_PRIM_TEX_5_OFFSET_C 0x1cd0
+#define R128_PRIM_TEX_6_OFFSET_C 0x1cd4
+#define R128_PRIM_TEX_7_OFFSET_C 0x1cd8
+#define R128_PRIM_TEX_8_OFFSET_C 0x1cdc
+#define R128_PRIM_TEX_9_OFFSET_C 0x1ce0
+#define R128_PRIM_TEX_10_OFFSET_C 0x1ce4
+# define R128_TEX_NO_TILE (0 << 30)
+# define R128_TEX_TILED_BY_HOST (1 << 30)
+# define R128_TEX_TILED_BY_STORAGE (2 << 30)
+# define R128_TEX_TILED_BY_STORAGE2 (3 << 30)
+
+#define R128_SEC_TEX_CNTL_C 0x1d00
+# define R128_SEC_SELECT_PRIM_ST (0 << 0)
+# define R128_SEC_SELECT_SEC_ST (1 << 0)
+#define R128_SEC_TEX_COMBINE_CNTL_C 0x1d04
+# define R128_INPUT_FACTOR_PREV_COLOR (8 << 10)
+# define R128_INPUT_FACTOR_PREV_ALPHA (9 << 10)
+# define R128_INP_FACTOR_A_PREV_ALPHA (4 << 25)
+#define R128_SEC_TEX_0_OFFSET_C 0x1d08
+#define R128_SEC_TEX_1_OFFSET_C 0x1d0c
+#define R128_SEC_TEX_2_OFFSET_C 0x1d10
+#define R128_SEC_TEX_3_OFFSET_C 0x1d14
+#define R128_SEC_TEX_4_OFFSET_C 0x1d18
+#define R128_SEC_TEX_5_OFFSET_C 0x1d1c
+#define R128_SEC_TEX_6_OFFSET_C 0x1d20
+#define R128_SEC_TEX_7_OFFSET_C 0x1d24
+#define R128_SEC_TEX_8_OFFSET_C 0x1d28
+#define R128_SEC_TEX_9_OFFSET_C 0x1d2c
+#define R128_SEC_TEX_10_OFFSET_C 0x1d30
+#define R128_CONSTANT_COLOR_C 0x1d34
+# define R128_CONSTANT_BLUE_SHIFT 0
+# define R128_CONSTANT_GREEN_SHIFT 8
+# define R128_CONSTANT_RED_SHIFT 16
+# define R128_CONSTANT_ALPHA_SHIFT 24
+#define R128_PRIM_TEXTURE_BORDER_COLOR_C 0x1d38
+# define R128_PRIM_TEX_BORDER_BLUE_SHIFT 0
+# define R128_PRIM_TEX_BORDER_GREEN_SHIFT 8
+# define R128_PRIM_TEX_BORDER_RED_SHIFT 16
+# define R128_PRIM_TEX_BORDER_ALPHA_SHIFT 24
+#define R128_SEC_TEXTURE_BORDER_COLOR_C 0x1d3c
+# define R128_SEC_TEX_BORDER_BLUE_SHIFT 0
+# define R128_SEC_TEX_BORDER_GREEN_SHIFT 8
+# define R128_SEC_TEX_BORDER_RED_SHIFT 16
+# define R128_SEC_TEX_BORDER_ALPHA_SHIFT 24
+#define R128_STEN_REF_MASK_C 0x1d40
+# define R128_STEN_REFERENCE_SHIFT 0
+# define R128_STEN_MASK_SHIFT 16
+# define R128_STEN_WRITE_MASK_SHIFT 24
+#define R128_PLANE_3D_MASK_C 0x1d44
+
+
+ /* Constants */
+#define R128_AGP_TEX_OFFSET 0x02000000
+
+#define R128_VB_AGE_REG R128_GUI_SCRATCH_REG0
+#define R128_SWAP_AGE_REG R128_GUI_SCRATCH_REG1
+
+ /* CCE packet types */
+#define R128_CCE_PACKET0 0x00000000
+#define R128_CCE_PACKET0_ONE_REG_WR 0x00008000
+#define R128_CCE_PACKET1 0x40000000
+#define R128_CCE_PACKET2 0x80000000
+#define R128_CCE_PACKET3_NOP 0xC0001000
+#define R128_CCE_PACKET3_PAINT 0xC0001100
+#define R128_CCE_PACKET3_BITBLT 0xC0001200
+#define R128_CCE_PACKET3_SMALLTEXT 0xC0001300
+#define R128_CCE_PACKET3_HOSTDATA_BLT 0xC0001400
+#define R128_CCE_PACKET3_POLYLINE 0xC0001500
+#define R128_CCE_PACKET3_SCALING 0xC0001600
+#define R128_CCE_PACKET3_TRANS_SCALING 0xC0001700
+#define R128_CCE_PACKET3_POLYSCANLINES 0xC0001800
+#define R128_CCE_PACKET3_NEXT_CHAR 0xC0001900
+#define R128_CCE_PACKET3_PAINT_MULTI 0xC0001A00
+#define R128_CCE_PACKET3_BITBLT_MULTI 0xC0001B00
+#define R128_CCE_PACKET3_PLY_NEXTSCAN 0xC0001D00
+#define R128_CCE_PACKET3_SET_SCISSORS 0xC0001E00
+#define R128_CCE_PACKET3_SET_MODE24BPP 0xC0001F00
+#define R128_CCE_PACKET3_CNTL_PAINT 0xC0009100
+#define R128_CCE_PACKET3_CNTL_BITBLT 0xC0009200
+#define R128_CCE_PACKET3_CNTL_SMALLTEXT 0xC0009300
+#define R128_CCE_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400
+#define R128_CCE_PACKET3_CNTL_POLYLINE 0xC0009500
+#define R128_CCE_PACKET3_CNTL_SCALING 0xC0009600
+#define R128_CCE_PACKET3_CNTL_TRANS_SCALING 0xC0009700
+#define R128_CCE_PACKET3_CNTL_POLYSCANLINES 0xC0009800
+#define R128_CCE_PACKET3_CNTL_NEXT_CHAR 0xC0009900
+#define R128_CCE_PACKET3_CNTL_PAINT_MULTI 0xC0009A00
+#define R128_CCE_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00
+#define R128_CCE_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00
+#define R128_CCE_PACKET3_3D_SAVE_CONTEXT 0xC0002000
+#define R128_CCE_PACKET3_3D_PLAY_CONTEXT 0xC0002100
+#define R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300
+#define R128_CCE_PACKET3_3D_RNDR_GEN_PRIM 0xC0002500
+#define R128_CCE_PACKET3_LOAD_PALETTE 0xC0002C00
+#define R128_CCE_PACKET3_PURGE 0xC0002D00
+#define R128_CCE_PACKET3_NEXT_VERTEX_BUNDLE 0xC0002E00
+# define R128_CCE_PACKET_MASK 0xC0000000
+# define R128_CCE_PACKET_COUNT_MASK 0x3fff0000
+# define R128_CCE_PACKET0_REG_MASK 0x000007ff
+# define R128_CCE_PACKET1_REG0_MASK 0x000007ff
+# define R128_CCE_PACKET1_REG1_MASK 0x003ff800
+
+#define R128_CCE_VC_FRMT_RHW 0x00000001
+#define R128_CCE_VC_FRMT_DIFFUSE_BGR 0x00000002
+#define R128_CCE_VC_FRMT_DIFFUSE_A 0x00000004
+#define R128_CCE_VC_FRMT_DIFFUSE_ARGB 0x00000008
+#define R128_CCE_VC_FRMT_SPEC_BGR 0x00000010
+#define R128_CCE_VC_FRMT_SPEC_F 0x00000020
+#define R128_CCE_VC_FRMT_SPEC_FRGB 0x00000040
+#define R128_CCE_VC_FRMT_S_T 0x00000080
+#define R128_CCE_VC_FRMT_S2_T2 0x00000100
+#define R128_CCE_VC_FRMT_RHW2 0x00000200
+
+#define R128_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000
+#define R128_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001
+#define R128_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002
+#define R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003
+#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004
+#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005
+#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006
+#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007
+#define R128_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010
+#define R128_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020
+#define R128_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030
+#define R128_CCE_VC_CNTL_NUM_SHIFT 16
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h
new file mode 100644
index 000000000..c5d99df34
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h
@@ -0,0 +1,77 @@
+/* $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_SAREA_H_
+#define _R128_SAREA_H_
+
+/* There are 2 heaps (local/AGP). Each region within a heap is a
+ minimum of 64k, and there are at most 64 of them per heap. */
+#define R128_LOCAL_TEX_HEAP 0
+#define R128_AGP_TEX_HEAP 1
+#define R128_NR_TEX_HEAPS 2
+#define R128_NR_TEX_REGIONS 64
+#define R128_LOG_TEX_GRANULARITY 16
+
+typedef struct {
+ unsigned char next, prev; /* indices to form a circular LRU */
+ unsigned char in_use; /* owned by a client, or free? */
+ int age; /* tracked by clients to update local LRU's */
+} R128TexRegion;
+
+typedef struct {
+ /* Maintain an LRU of contiguous regions of texture space. If you
+ * think you own a region of texture memory, and it has an age
+ * different to the one you set, then you are mistaken and it has
+ * been stolen by another client. If global texAge hasn't changed,
+ * there is no need to walk the list.
+ *
+ * These regions can be used as a proxy for the fine-grained texture
+ * information of other clients - by maintaining them in the same
+ * lru which is used to age their own textures, clients have an
+ * approximate lru for the whole of global texture space, and can
+ * make informed decisions as to which areas to kick out. There is
+ * no need to choose whether to kick out your own texture or someone
+ * else's - simply eject them all in LRU order.
+ */
+ /* Last elt is sentinal */
+ R128TexRegion texList[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1];
+ /* last time texture was uploaded */
+ int texAge[R128_NR_TEX_HEAPS];
+
+ int ctxOwner; /* last context to upload state */
+
+ int ringWrite; /* current ring buffer write index */
+} R128SAREAPriv, *R128SAREAPrivPtr;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/Imakefile
index 89e248d7b..c42f5b2b7 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/Imakefile,v 3.29 1999/08/14 10:50:04 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/Imakefile,v 3.37 2000/02/22 01:02:34 mvojkovi Exp $
@@ -10,12 +10,21 @@ XCOMM $XConsortium: Imakefile /main/9 1996/10/25 15:38:46 kaleb $
#define IHaveSubdirs
-#if defined(i386Architecture) || \
+#if defined(i386Architecture) || defined(ia64Architecture) || \
(defined(LinuxArchitecture) && defined(AlphaArchitecture)) || \
+ (defined(FreeBSDArchitecture) && defined(AlphaArchitecture)) || \
defined(PpcArchitecture) || defined(SparcArchitecture)
BUS_SUBDIR = bus
#endif
+#if defined(QNX4Architecture)
+OS_SUBDIR = qnx4
+#endif
+
+#if defined(NTOArchitecture)
+OS_SUBDIR = nto
+#endif
+
#if defined(ArcArchitecture)
OS_SUBDIR = bsd
#endif
@@ -30,7 +39,11 @@ OS_SUBDIR = sysv
#if defined(SVR4Architecture)
# if defined(SunArchitecture)
+# if OSMinorVersion < 8
OS_SUBDIR = solx86
+# else
+OS_SUBDIR = sol8_x86
+# endif
# elif defined(PmaxOSArchitecture)
OS_SUBDIR = pmax
# elif defined(DguxArchitecture)
@@ -48,7 +61,7 @@ OS_SUBDIR = linux
OS_SUBDIR = lynxos
#endif
-#if defined(i386BsdArchitecture)
+#if defined(i386BsdArchitecture) || defined(AlphaBsdArchitecture)
# if defined(BSD386Architecture)
OS_SUBDIR = bsdi
# else
@@ -85,16 +98,17 @@ OS_SUBDIR = sco
#endif
#if BuildXF86DRI && !DoLoadableServer
-DRM_SRC = $(OS_SUBDIR)/drm/?*.o
+DRM_SRC = $(OS_SUBDIR)/drm/?*.c
DRM_OBJ = $(OS_SUBDIR)/drm/?*.o
+DRM_DONES = $(OS_SUBDIR)/drm/DONE
#endif
-SUBDIRS = $(OS_SUBDIR) $(BUS_SUBDIR) misc
+SUBDIRS = $(OS_SUBDIR) $(BUS_SUBDIR) misc vbe
-SRCS = $(OS_SUBDIR)/?*.c $(BUS_SUBDIR)/?*.c misc/?*.c $(DRM_SRC)
-OBJS = $(OS_SUBDIR)/?*.o $(BUS_SUBDIR)/?*.o misc/?*.o $(DRM_OBJ)
+SRCS = $(OS_SUBDIR)/?*.c $(BUS_SUBDIR)/?*.c misc/?*.c vbe/?*.c $(DRM_SRC)
+OBJS = $(OS_SUBDIR)/?*.o $(BUS_SUBDIR)/?*.o misc/?*.o vbe/?*.o $(DRM_OBJ)
-DONES = $(OS_SUBDIR)/DONE $(BUS_SUBDIR)/DONE misc/DONE
+DONES = $(OS_SUBDIR)/DONE $(BUS_SUBDIR)/DONE misc/DONE vbe/DONE $(DRM_DONES)
#if HasParallelMake
MakeMutex($(SUBDIRS) $(OBJS) $(DONES))
@@ -114,7 +128,6 @@ ForceSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
-
InstallDriverSDKNonExecFile(xf86_OSproc.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(xf86_ansic.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(xf86_libc.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile
index 2c0ce97db..fdaecb972 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile
@@ -13,14 +13,16 @@ MOBJ = drmmodule.o
MTRR_DEFINES = -DHAS_MTRR_SUPPORT
#endif
-SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c xf86drmI810.c xf86drmMga.c $(MSRC)
-OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o xf86drmI810.o xf86drmMga.o $(MOBJ)
+SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c xf86drmI810.c xf86drmMga.c xf86drmR128.c $(MSRC)
+OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o xf86drmI810.o xf86drmMga.o xf86drmR128.o $(MOBJ)
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC) -I$(EXTINCSRC) -I../.. -Ikernel
DEFINES = $(MTRR_DEFINES) $(GLX_DEFINES)
+#if DoLoadableServer
+
ModuleObjectRule()
LibraryModuleTarget(drm,$(OBJS))
NormalLintTarget($(SRCS))
@@ -29,6 +31,14 @@ NormalLintTarget($(SRCS))
InstallLibraryModule(drm,$(MODULEDIR),linux)
#endif
+#else
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+#endif
+
+
#define IHaveSubdirs
SUBDIRS = kernel
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel
index 2ea6c7215..a169473af 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel
@@ -49,3 +49,5 @@ i810.o: i810_drv.o i810_context.o $(L_TARGET)
mga.o: mga_drv.o mga_context.o mga_dma.o mga_bufs.o $(L_TARGET)
$(LD) $(LD_RFLAG) -r -o $@ mga_drv.o mga_bufs.o mga_dma.o mga_context.o mga_state.o -L. -ldrm
+r128.o: r128_drv.o r128_context.o $(L_TARGET)
+ $(LD) $(LD_RFLAG) -r -o $@ r128_drv.o r128_context.o -L. -ldrm
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux
index 1db7a81fa..368c3c850 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux
@@ -1,8 +1,7 @@
# Makefile -- For the Direct Rendering Manager module (drm)
# Created: Mon Jan 4 09:26:53 1999 by faith@precisioninsight.com
-# Revised: Sun Feb 13 23:15:59 2000 by kevin@precisioninsight.com
#
-# Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+# Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -33,7 +32,7 @@
# **** End of SMP/MODVERSIONS detection
-MODS= gamma.o tdfx.o
+MODS= gamma.o tdfx.o r128.o
LIBS= libdrm.a
PROGS= drmstat
@@ -47,6 +46,9 @@ GAMMAHEADERS= gamma_drv.h $(DRMHEADERS)
TDFXOBJS= tdfx_drv.o tdfx_context.o
TDFXHEADERS= tdfx_drv.h $(DRMHEADERS)
+R128OBJS= r128_drv.o r128_dma.o r128_bufs.o r128_context.o
+R128HEADERS= r128_drv.h r128_drm.h $(DRMHEADERS)
+
PROGOBJS= drmstat.po xf86drm.po xf86drmHash.po xf86drmRandom.po sigio.po
PROGHEADERS= xf86drm.h $(DRMHEADERS)
@@ -153,6 +155,9 @@ gamma.o: $(GAMMAOBJS) $(LIBS)
tdfx.o: $(TDFXOBJS) $(LIBS)
$(LD) -r $^ -o $@
+r128.o: $(R128OBJS) $(LIBS)
+ $(LD) -r $^ -o $@
+
ifeq ($(AGP),1)
mga.o: $(MGAOBJS) $(LIBS)
$(LD) -r $^ -o $@
@@ -182,6 +187,7 @@ ChangeLog:
$(DRMOBJS): $(DRMHEADERS)
$(GAMMAOBJS): $(GAMMAHEADERS)
$(TDFXOBJS): $(TDFXHEADERS)
+$(R128OBJS): $(R128HEADERS)
ifeq ($(AGP),1)
$(MGAOBJS): $(MGAHEADERS)
$(I810OBJS): $(I810HEADERS)
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c
index c2da9ec7e..14fb8b53f 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c
@@ -239,6 +239,8 @@ int drm_agp_bind(struct inode *inode, struct file *filp, unsigned int cmd,
page = (request.offset + PAGE_SIZE - 1) / PAGE_SIZE;
if ((retcode = drm_bind_agp(entry->memory, page))) return retcode;
entry->bound = dev->agp->base + (page << PAGE_SHIFT);
+ DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n",
+ dev->agp->base, entry->bound);
return 0;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h
index ae4c65ca3..25e4cce49 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h
@@ -1,8 +1,7 @@
/* drm.h -- Header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
- * Revised: Mon Feb 14 00:15:23 2000 by kevin@precisioninsight.com
*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -71,9 +70,10 @@ typedef struct drm_clip_rect {
unsigned short y2;
} drm_clip_rect_t;
-/* Seperate include files for the i810/mga specific structures */
+/* Seperate include files for the i810/mga/r128 specific structures */
#include "mga_drm.h"
#include "i810_drm.h"
+#include "r128_drm.h"
typedef struct drm_version {
int version_major; /* Major version */
@@ -349,4 +349,12 @@ typedef struct drm_agp_info {
#define DRM_IOCTL_I810_FLUSH DRM_IO ( 0x43)
#define DRM_IOCTL_I810_GETAGE DRM_IO ( 0x44)
+/* Rage 128 specific ioctls */
+#define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t)
+#define DRM_IOCTL_R128_RESET DRM_IO( 0x41)
+#define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42)
+#define DRM_IOCTL_R128_CCEIDL DRM_IO( 0x43)
+#define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t)
+#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t)
+
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h
index f8e78eabd..43670e28a 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h
@@ -1,8 +1,7 @@
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:34:30 2000 by kevin@precisioninsight.com
*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -228,8 +227,8 @@ typedef struct drm_magic_entry {
} drm_magic_entry_t;
typedef struct drm_magic_head {
- struct drm_magic_entry *head;
- struct drm_magic_entry *tail;
+ struct drm_magic_entry *head;
+ struct drm_magic_entry *tail;
} drm_magic_head_t;
typedef struct drm_vma_entry {
@@ -262,16 +261,15 @@ typedef struct drm_buf {
DRM_LIST_RECLAIM = 5
} list; /* Which list we're on */
-
- void *dev_private;
- int dev_priv_size;
-
#if DRM_DMA_HISTOGRAM
cycles_t time_queued; /* Queued to kernel DMA queue */
cycles_t time_dispatched; /* Dispatched to hardware */
cycles_t time_completed; /* Completed by hardware */
cycles_t time_freed; /* Back on freelist */
#endif
+
+ int dev_priv_size; /* Size of buffer private stoarge */
+ void *dev_private; /* Per-buffer private storage */
} drm_buf_t;
#if DRM_DMA_HISTOGRAM
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c
index db98fd6a4..392abceb9 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c
@@ -1,8 +1,7 @@
/* proc.c -- /proc support for DRM -*- linux-c -*-
* Created: Mon Jan 11 09:48:47 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:41:04 2000 by kevin@precisioninsight.com
*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -400,6 +399,7 @@ static int _drm_vma_info(char *buf, char **start, off_t offset, int len,
pgprot & _PAGE_GLOBAL ? 'g' : 'l' );
#endif
DRM_PROC_PRINT("\n");
+#if 0
for (i = vma->vm_start; i < vma->vm_end; i += PAGE_SIZE) {
pgd = pgd_offset(vma->vm_mm, i);
pmd = pmd_offset(pgd, i);
@@ -420,6 +420,7 @@ static int _drm_vma_info(char *buf, char **start, off_t offset, int len,
DRM_PROC_PRINT(" 0x%08lx\n", i);
}
}
+#endif
}
return len;
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c
new file mode 100644
index 000000000..bad6c5714
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c
@@ -0,0 +1,309 @@
+/* r128_bufs.c -- IOCTLs to manage buffers -*- linux-c -*-
+ * Created: Wed Apr 12 16:19:08 2000 by kevin@precisioninsight.com
+ *
+ * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Kevin E. Martin <kevin@precisioninsight.com>
+ * Rickard E. (Rik) Faith <faith@precisioninsight.com>
+ * Jeff Hartmann <jhartmann@precisioninsight.com>
+ *
+ * $XFree86$
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "r128_drv.h"
+#include "linux/un.h"
+
+
+#ifdef DRM_AGP
+int r128_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_desc_t request;
+ drm_buf_entry_t *entry;
+ drm_buf_t *buf;
+ unsigned long offset;
+ unsigned long agp_offset;
+ int count;
+ int order;
+ int size;
+ int alignment;
+ int page_order;
+ int total;
+ int byte_count;
+ int i;
+
+ if (!dma) return -EINVAL;
+
+ copy_from_user_ret(&request,
+ (drm_buf_desc_t *)arg,
+ sizeof(request),
+ -EFAULT);
+
+ count = request.count;
+ order = drm_order(request.size);
+ size = 1 << order;
+
+ alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size):size;
+ page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
+ total = PAGE_SIZE << page_order;
+
+ byte_count = 0;
+ agp_offset = dev->agp->base + request.agp_start;
+
+ DRM_DEBUG("count: %d\n", count);
+ DRM_DEBUG("order: %d\n", order);
+ DRM_DEBUG("size: %d\n", size);
+ DRM_DEBUG("agp_offset: %ld\n", agp_offset);
+ DRM_DEBUG("alignment: %d\n", alignment);
+ DRM_DEBUG("page_order: %d\n", page_order);
+ DRM_DEBUG("total: %d\n", total);
+
+ if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL;
+ if (dev->queue_count) return -EBUSY; /* Not while in use */
+
+ spin_lock(&dev->count_lock);
+ if (dev->buf_use) {
+ spin_unlock(&dev->count_lock);
+ return -EBUSY;
+ }
+ atomic_inc(&dev->buf_alloc);
+ spin_unlock(&dev->count_lock);
+
+ down(&dev->struct_sem);
+ entry = &dma->bufs[order];
+ if (entry->buf_count) {
+ up(&dev->struct_sem);
+ atomic_dec(&dev->buf_alloc);
+ return -ENOMEM; /* May only call once for each order */
+ }
+
+ entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+ DRM_MEM_BUFS);
+ if (!entry->buflist) {
+ up(&dev->struct_sem);
+ atomic_dec(&dev->buf_alloc);
+ return -ENOMEM;
+ }
+ memset(entry->buflist, 0, count * sizeof(*entry->buflist));
+
+ entry->buf_size = size;
+ entry->page_order = page_order;
+ offset = 0;
+
+ for (offset = 0;
+ entry->buf_count < count;
+ offset += alignment, ++entry->buf_count) {
+ buf = &entry->buflist[entry->buf_count];
+ buf->idx = dma->buf_count + entry->buf_count;
+ buf->total = alignment;
+ buf->order = order;
+ buf->used = 0;
+ buf->offset = (dma->byte_count + offset);
+ buf->address = (void *)(agp_offset + offset);
+ buf->next = NULL;
+ buf->waiting = 0;
+ buf->pending = 0;
+ init_waitqueue_head(&buf->dma_wait);
+ buf->pid = 0;
+
+ buf->dev_priv_size = sizeof(drm_r128_buf_priv_t);
+ buf->dev_private = drm_alloc(sizeof(drm_r128_buf_priv_t),
+ DRM_MEM_BUFS);
+ memset(buf->dev_private, 0, buf->dev_priv_size);
+
+#if DRM_DMA_HISTOGRAM
+ buf->time_queued = 0;
+ buf->time_dispatched = 0;
+ buf->time_completed = 0;
+ buf->time_freed = 0;
+#endif
+
+ byte_count += PAGE_SIZE << page_order;
+
+ DRM_DEBUG("buffer %d @ %p\n",
+ entry->buf_count, buf->address);
+ }
+
+ DRM_DEBUG("byte_count: %d\n", byte_count);
+
+ dma->buflist = drm_realloc(dma->buflist,
+ dma->buf_count * sizeof(*dma->buflist),
+ (dma->buf_count + entry->buf_count)
+ * sizeof(*dma->buflist),
+ DRM_MEM_BUFS);
+ for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++)
+ dma->buflist[i] = &entry->buflist[i - dma->buf_count];
+
+ dma->buf_count += entry->buf_count;
+ dma->byte_count += byte_count;
+
+ drm_freelist_create(&entry->freelist, entry->buf_count);
+ for (i = 0; i < entry->buf_count; i++) {
+ drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]);
+ }
+
+ up(&dev->struct_sem);
+
+ request.count = entry->buf_count;
+ request.size = size;
+
+ copy_to_user_ret((drm_buf_desc_t *)arg,
+ &request,
+ sizeof(request),
+ -EFAULT);
+
+ dma->flags = _DRM_DMA_USE_AGP;
+
+ atomic_dec(&dev->buf_alloc);
+ return 0;
+}
+#endif
+
+int r128_addbufs(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ drm_buf_desc_t request;
+
+ if (!dev_priv || dev_priv->is_pci) return -EINVAL;
+
+ copy_from_user_ret(&request,
+ (drm_buf_desc_t *)arg,
+ sizeof(request),
+ -EFAULT);
+
+#ifdef DRM_AGP
+ if (request.flags & _DRM_AGP_BUFFER)
+ return r128_addbufs_agp(inode, filp, cmd, arg);
+ else
+#endif
+ return -EINVAL;
+}
+
+int r128_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+ int retcode = 0;
+ const int zero = 0;
+ unsigned long virtual;
+ unsigned long address;
+ drm_buf_map_t request;
+ int i;
+
+ if (!dma || !dev_priv || dev_priv->is_pci) return -EINVAL;
+
+ DRM_DEBUG("\n");
+
+ spin_lock(&dev->count_lock);
+ if (atomic_read(&dev->buf_alloc)) {
+ spin_unlock(&dev->count_lock);
+ return -EBUSY;
+ }
+ ++dev->buf_use; /* Can't allocate more after this call */
+ spin_unlock(&dev->count_lock);
+
+ copy_from_user_ret(&request,
+ (drm_buf_map_t *)arg,
+ sizeof(request),
+ -EFAULT);
+
+ if (request.count >= dma->buf_count) {
+ if (dma->flags & _DRM_DMA_USE_AGP) {
+ drm_map_t *map;
+
+ map = dev_priv->agp_vertbufs;
+ if (!map) {
+ retcode = -EINVAL;
+ goto done;
+ }
+
+ down(&current->mm->mmap_sem);
+ virtual = do_mmap(filp, 0, map->size,
+ PROT_READ|PROT_WRITE,
+ MAP_SHARED,
+ (unsigned long)map->offset);
+ up(&current->mm->mmap_sem);
+ } else {
+ down(&current->mm->mmap_sem);
+ virtual = do_mmap(filp, 0, dma->byte_count,
+ PROT_READ|PROT_WRITE, MAP_SHARED, 0);
+ up(&current->mm->mmap_sem);
+ }
+ if (virtual > -1024UL) {
+ /* Real error */
+ retcode = (signed long)virtual;
+ goto done;
+ }
+ request.virtual = (void *)virtual;
+
+ for (i = 0; i < dma->buf_count; i++) {
+ if (copy_to_user(&request.list[i].idx,
+ &dma->buflist[i]->idx,
+ sizeof(request.list[0].idx))) {
+ retcode = -EFAULT;
+ goto done;
+ }
+ if (copy_to_user(&request.list[i].total,
+ &dma->buflist[i]->total,
+ sizeof(request.list[0].total))) {
+ retcode = -EFAULT;
+ goto done;
+ }
+ if (copy_to_user(&request.list[i].used,
+ &zero,
+ sizeof(zero))) {
+ retcode = -EFAULT;
+ goto done;
+ }
+ address = virtual + dma->buflist[i]->offset;
+ if (copy_to_user(&request.list[i].address,
+ &address,
+ sizeof(address))) {
+ retcode = -EFAULT;
+ goto done;
+ }
+ }
+ }
+ done:
+ request.count = dma->buf_count;
+ DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode);
+
+ copy_to_user_ret((drm_buf_map_t *)arg,
+ &request,
+ sizeof(request),
+ -EFAULT);
+
+ return retcode;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c
new file mode 100644
index 000000000..d288fd284
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c
@@ -0,0 +1,214 @@
+/* r128_context.c -- IOCTLs for r128 contexts -*- linux-c -*-
+ * Created: Mon Dec 13 09:51:35 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Rickard E. (Rik) Faith <faith@precisioninsight.com>
+ *
+ * $XFree86$
+ *
+ */
+
+#include <linux/sched.h>
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "r128_drv.h"
+
+extern drm_ctx_t r128_res_ctx;
+
+static int r128_alloc_queue(drm_device_t *dev)
+{
+#if 0
+ static int context = 0;
+#endif
+
+ return drm_ctxbitmap_next(dev);
+}
+
+int r128_context_switch(drm_device_t *dev, int old, int new)
+{
+ char buf[64];
+
+ atomic_inc(&dev->total_ctx);
+
+ if (test_and_set_bit(0, &dev->context_flag)) {
+ DRM_ERROR("Reentering -- FIXME\n");
+ return -EBUSY;
+ }
+
+#if DRM_DMA_HISTOGRAM
+ dev->ctx_start = get_cycles();
+#endif
+
+ DRM_DEBUG("Context switch from %d to %d\n", old, new);
+
+ if (new == dev->last_context) {
+ clear_bit(0, &dev->context_flag);
+ return 0;
+ }
+
+ if (drm_flags & DRM_FLAG_NOCTX) {
+ r128_context_switch_complete(dev, new);
+ } else {
+ sprintf(buf, "C %d %d\n", old, new);
+ drm_write_string(dev, buf);
+ }
+
+ return 0;
+}
+
+int r128_context_switch_complete(drm_device_t *dev, int new)
+{
+ dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
+ dev->last_switch = jiffies;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("Lock isn't held after context switch\n");
+ }
+
+ /* If a context switch is ever initiated
+ when the kernel holds the lock, release
+ that lock here. */
+#if DRM_DMA_HISTOGRAM
+ atomic_inc(&dev->histo.ctx[drm_histogram_slot(get_cycles()
+ - dev->ctx_start)]);
+
+#endif
+ clear_bit(0, &dev->context_flag);
+ wake_up(&dev->context_wait);
+
+ return 0;
+}
+
+
+int r128_resctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_ctx_res_t res;
+ drm_ctx_t ctx;
+ int i;
+
+ DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
+ copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT);
+ if (res.count >= DRM_RESERVED_CONTEXTS) {
+ memset(&ctx, 0, sizeof(ctx));
+ for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
+ ctx.handle = i;
+ copy_to_user_ret(&res.contexts[i],
+ &i,
+ sizeof(i),
+ -EFAULT);
+ }
+ }
+ res.count = DRM_RESERVED_CONTEXTS;
+ copy_to_user_ret((drm_ctx_res_t *)arg, &res, sizeof(res), -EFAULT);
+ return 0;
+}
+
+
+int r128_addctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ if ((ctx.handle = r128_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) {
+ /* Skip kernel's context and get a new one. */
+ ctx.handle = r128_alloc_queue(dev);
+ }
+ DRM_DEBUG("%d\n", ctx.handle);
+ if (ctx.handle == -1) {
+ DRM_DEBUG("Not enough free contexts.\n");
+ /* Should this return -EBUSY instead? */
+ return -ENOMEM;
+ }
+
+ copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT);
+ return 0;
+}
+
+int r128_modctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT);
+ if (ctx.flags==_DRM_CONTEXT_PRESERVED)
+ r128_res_ctx.handle=ctx.handle;
+ return 0;
+}
+
+int r128_getctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT);
+ /* This is 0, because we don't hanlde any context flags */
+ ctx.flags = 0;
+ copy_to_user_ret((drm_ctx_t*)arg, &ctx, sizeof(ctx), -EFAULT);
+ return 0;
+}
+
+int r128_switchctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ DRM_DEBUG("%d\n", ctx.handle);
+ return r128_context_switch(dev, dev->last_context, ctx.handle);
+}
+
+int r128_newctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ DRM_DEBUG("%d\n", ctx.handle);
+ r128_context_switch_complete(dev, ctx.handle);
+
+ return 0;
+}
+
+int r128_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ DRM_DEBUG("%d\n", ctx.handle);
+ drm_ctxbitmap_free(dev, ctx.handle);
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c
new file mode 100644
index 000000000..860c41885
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c
@@ -0,0 +1,908 @@
+/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*-
+ * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
+ *
+ * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ * $XFree86$
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "r128_drv.h"
+
+#include <linux/interrupt.h> /* For task queue support */
+#include <linux/delay.h>
+
+
+
+#define DO_REMAP(_m) (_m)->handle = drm_ioremap((_m)->offset, (_m)->size)
+
+#define DO_REMAPFREE(_m) \
+ do { \
+ if ((_m)->handle && (_m)->size) \
+ drm_ioremapfree((_m)->handle, (_m)->size); \
+ } while (0)
+
+#define DO_FIND_MAP(_m, _o) \
+ do { \
+ int _i; \
+ for (_i = 0; _i < dev->map_count; _i++) { \
+ if (dev->maplist[_i]->offset == _o) { \
+ _m = dev->maplist[_i]; \
+ break; \
+ } \
+ } \
+ } while (0)
+
+
+#define R128_MAX_VBUF_AGE 0x10000000
+#define R128_VB_AGE_REG R128_GUI_SCRATCH_REG0
+
+int R128_READ_PLL(drm_device_t *dev, int addr)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+
+ R128_WRITE8(R128_CLOCK_CNTL_INDEX, addr & 0x1f);
+ return R128_READ(R128_CLOCK_CNTL_DATA);
+}
+
+static void r128_flush_write_combine(void)
+{
+ int xchangeDummy;
+
+ __asm__ volatile("push %%eax ;"
+ "xchg %%eax, %0 ;"
+ "pop %%eax" : : "m" (xchangeDummy));
+ __asm__ volatile("push %%eax ;"
+ "push %%ebx ;"
+ "push %%ecx ;"
+ "push %%edx ;"
+ "movl $0,%%eax ;"
+ "cpuid ;"
+ "pop %%edx ;"
+ "pop %%ecx ;"
+ "pop %%ebx ;"
+ "pop %%eax" : /* no outputs */ : /* no inputs */ );
+}
+
+static int r128_do_cleanup_cce(drm_device_t *dev)
+{
+ if (dev->dev_private) {
+ drm_r128_private_t *dev_priv = dev->dev_private;
+
+ if (!dev_priv->is_pci) {
+ DO_REMAPFREE(dev_priv->agp_ring);
+ DO_REMAPFREE(dev_priv->agp_read_ptr);
+ DO_REMAPFREE(dev_priv->agp_vertbufs);
+ DO_REMAPFREE(dev_priv->agp_indbufs);
+ DO_REMAPFREE(dev_priv->agp_textures);
+ }
+
+ drm_free(dev->dev_private, sizeof(drm_r128_private_t),
+ DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+ }
+
+ return 0;
+}
+
+static int r128_do_init_cce(drm_device_t *dev, drm_r128_init_t *init)
+{
+ drm_r128_private_t *dev_priv;
+ int i;
+
+ dev_priv = drm_alloc(sizeof(drm_r128_private_t), DRM_MEM_DRIVER);
+ if (dev_priv == NULL) return -ENOMEM;
+ dev->dev_private = (void *)dev_priv;
+
+ memset(dev_priv, 0, sizeof(drm_r128_private_t));
+
+ dev_priv->is_pci = init->is_pci;
+
+ dev_priv->usec_timeout = init->usec_timeout;
+ if (dev_priv->usec_timeout < 1 ||
+ dev_priv->usec_timeout > R128_MAX_USEC_TIMEOUT) {
+ drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+ return -EINVAL;
+ }
+
+ dev_priv->cce_mode = init->cce_mode;
+ dev_priv->cce_fifo_size = init->cce_fifo_size;
+ dev_priv->cce_is_bm_mode =
+ ((init->cce_mode == R128_PM4_192BM) ||
+ (init->cce_mode == R128_PM4_128BM_64INDBM) ||
+ (init->cce_mode == R128_PM4_64BM_128INDBM) ||
+ (init->cce_mode == R128_PM4_64BM_64VCBM_64INDBM));
+ dev_priv->cce_secure = init->cce_secure;
+
+ if (dev_priv->cce_is_bm_mode && dev_priv->is_pci) {
+ drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+ return -EINVAL;
+ }
+
+ for (i = 0; i < dev->map_count; i++) {
+ if (dev->maplist[i]->type == _DRM_SHM) {
+ dev_priv->sarea = dev->maplist[i];
+ break;
+ }
+ }
+
+ DO_FIND_MAP(dev_priv->fb, init->fb_offset);
+ if (!dev_priv->is_pci) {
+ DO_FIND_MAP(dev_priv->agp_ring, init->agp_ring_offset);
+ DO_FIND_MAP(dev_priv->agp_read_ptr, init->agp_read_ptr_offset);
+ DO_FIND_MAP(dev_priv->agp_vertbufs, init->agp_vertbufs_offset);
+ DO_FIND_MAP(dev_priv->agp_indbufs, init->agp_indbufs_offset);
+ DO_FIND_MAP(dev_priv->agp_textures, init->agp_textures_offset);
+ }
+ DO_FIND_MAP(dev_priv->mmio, init->mmio_offset);
+
+ dev_priv->sarea_priv =
+ (drm_r128_sarea_t *)((u8 *)dev_priv->sarea->handle +
+ init->sarea_priv_offset);
+
+ if (!dev_priv->is_pci) {
+ DO_REMAP(dev_priv->agp_ring);
+ DO_REMAP(dev_priv->agp_read_ptr);
+ DO_REMAP(dev_priv->agp_vertbufs);
+#if 0
+ DO_REMAP(dev_priv->agp_indirectbufs);
+ DO_REMAP(dev_priv->agp_textures);
+#endif
+
+ dev_priv->ring_size = init->ring_size;
+ dev_priv->ring_sizel2qw = drm_order(init->ring_size/8);
+ dev_priv->ring_entries = init->ring_size/sizeof(u32);
+ dev_priv->ring_read_ptr = ((__volatile__ u32 *)
+ dev_priv->agp_read_ptr->handle);
+ dev_priv->ring_start = (u32 *)dev_priv->agp_ring->handle;
+ dev_priv->ring_end = ((u32 *)dev_priv->agp_ring->handle
+ + dev_priv->ring_entries);
+ }
+
+ dev_priv->submit_age = 0;
+ R128_WRITE(R128_VB_AGE_REG, dev_priv->submit_age);
+
+ return 0;
+}
+
+int r128_init_cce(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_r128_init_t init;
+
+ copy_from_user_ret(&init, (drm_r128_init_t *)arg, sizeof(init),
+ -EFAULT);
+
+ switch (init.func) {
+ case R128_INIT_CCE:
+ return r128_do_init_cce(dev, &init);
+ case R128_CLEANUP_CCE:
+ return r128_do_cleanup_cce(dev);
+ }
+
+ return -EINVAL;
+}
+
+static void r128_mark_vertbufs_done(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
+ int i;
+
+ for (i = 0; i < dma->buf_count; i++) {
+ drm_buf_t *buf = dma->buflist[i];
+ drm_r128_buf_priv_t *buf_priv = buf->dev_private;
+ buf_priv->age = 0;
+ }
+}
+
+static int r128_do_pixcache_flush(drm_device_t *dev)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ u32 tmp;
+ int i;
+
+ tmp = R128_READ(R128_PC_NGUI_CTLSTAT) | R128_PC_FLUSH_ALL;
+ R128_WRITE(R128_PC_NGUI_CTLSTAT, tmp);
+
+ for (i = 0; i < dev_priv->usec_timeout; i++) {
+ if (!(R128_READ(R128_PC_NGUI_CTLSTAT) & R128_PC_BUSY))
+ return 0;
+ udelay(1);
+ }
+
+ return -EBUSY;
+}
+
+static int r128_do_wait_for_fifo(drm_device_t *dev, int entries)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int i;
+
+ for (i = 0; i < dev_priv->usec_timeout; i++) {
+ int slots = R128_READ(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK;
+ if (slots >= entries) return 0;
+ udelay(1);
+ }
+ return -EBUSY;
+}
+
+static int r128_do_wait_for_idle(drm_device_t *dev)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int i, ret;
+
+ if (!(ret = r128_do_wait_for_fifo(dev, 64))) return ret;
+
+ for (i = 0; i < dev_priv->usec_timeout; i++) {
+ if (!(R128_READ(R128_GUI_STAT) & R128_GUI_ACTIVE)) {
+ (void)r128_do_pixcache_flush(dev);
+ return 0;
+ }
+ udelay(1);
+ }
+ return -EBUSY;
+}
+
+int r128_do_engine_reset(drm_device_t *dev)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ u32 clock_cntl_index, mclk_cntl, gen_reset_cntl;
+
+ (void)r128_do_pixcache_flush(dev);
+
+ clock_cntl_index = R128_READ(R128_CLOCK_CNTL_INDEX);
+ mclk_cntl = R128_READ_PLL(dev, R128_MCLK_CNTL);
+
+ R128_WRITE_PLL(R128_MCLK_CNTL,
+ mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CPP);
+
+ gen_reset_cntl = R128_READ(R128_GEN_RESET_CNTL);
+
+ R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl | R128_SOFT_RESET_GUI);
+ (void)R128_READ(R128_GEN_RESET_CNTL);
+ R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl & ~R128_SOFT_RESET_GUI);
+ (void)R128_READ(R128_GEN_RESET_CNTL);
+
+ R128_WRITE_PLL(R128_MCLK_CNTL, mclk_cntl);
+ R128_WRITE(R128_CLOCK_CNTL_INDEX, clock_cntl_index);
+ R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl);
+
+ /* For CCE ring buffer only */
+ if (dev_priv->cce_is_bm_mode) {
+ R128_WRITE(R128_PM4_BUFFER_DL_WPTR, 0);
+ R128_WRITE(R128_PM4_BUFFER_DL_RPTR, 0);
+ *dev_priv->ring_read_ptr = 0;
+ dev_priv->sarea_priv->ring_write = 0;
+ }
+
+ /* Reset the CCE mode */
+ (void)r128_do_wait_for_idle(dev);
+ R128_WRITE(R128_PM4_BUFFER_CNTL,
+ dev_priv->cce_mode | dev_priv->ring_sizel2qw);
+ (void)R128_READ(R128_PM4_BUFFER_ADDR); /* as per the sample code */
+ R128_WRITE(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN);
+
+ r128_mark_vertbufs_done(dev);
+ return 0;
+}
+
+int r128_eng_reset(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||
+ dev->lock.pid != current->pid) {
+ DRM_ERROR("r128_eng_reset called without holding the lock\n");
+ return -EINVAL;
+ }
+
+ return r128_do_engine_reset(dev);
+}
+
+static int r128_do_engine_flush(drm_device_t *dev)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ u32 tmp;
+
+ tmp = R128_READ(R128_PM4_BUFFER_DL_WPTR);
+ R128_WRITE(R128_PM4_BUFFER_DL_WPTR, tmp | R128_PM4_BUFFER_DL_DONE);
+
+ return 0;
+}
+
+int r128_eng_flush(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||
+ dev->lock.pid != current->pid) {
+ DRM_ERROR("r128_eng_flush called without holding the lock\n");
+ return -EINVAL;
+ }
+
+ return r128_do_engine_flush(dev);
+}
+
+static int r128_do_cce_wait_for_fifo(drm_device_t *dev, int entries)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int i;
+
+ for (i = 0; i < dev_priv->usec_timeout; i++) {
+ int slots = R128_READ(R128_PM4_STAT) & R128_PM4_FIFOCNT_MASK;
+ if (slots >= entries) return 0;
+ udelay(1);
+ }
+ return -EBUSY;
+}
+
+int r128_do_cce_wait_for_idle(drm_device_t *dev)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int i;
+
+ if (dev_priv->cce_is_bm_mode) {
+ for (i = 0; i < dev_priv->usec_timeout; i++) {
+ if (*dev_priv->ring_read_ptr == dev_priv->sarea_priv->ring_write) {
+ int pm4stat = R128_READ(R128_PM4_STAT);
+ if ((pm4stat & R128_PM4_FIFOCNT_MASK) >= dev_priv->cce_fifo_size &&
+ !(pm4stat & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) {
+ return r128_do_pixcache_flush(dev);
+ }
+ }
+ udelay(1);
+ }
+ return -EBUSY;
+ } else {
+ int ret = r128_do_cce_wait_for_fifo(dev, dev_priv->cce_fifo_size);
+ if (ret < 0) return ret;
+
+ for (i = 0; i < dev_priv->usec_timeout; i++) {
+ int pm4stat = R128_READ(R128_PM4_STAT);
+ if (!(pm4stat & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) {
+ return r128_do_pixcache_flush(dev);
+ }
+ udelay(1);
+ }
+ return -EBUSY;
+ }
+}
+
+int r128_cce_idle(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||
+ dev->lock.pid != current->pid) {
+ DRM_ERROR("r128_wait_idle called without holding the lock\n");
+ return -EINVAL;
+ }
+
+ return r128_do_cce_wait_for_idle(dev);
+}
+
+static int r128_submit_packets_ring_secure(drm_device_t *dev,
+ u32 *commands, int *count)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int write = dev_priv->sarea_priv->ring_write;
+ int *write_ptr = dev_priv->ring_start + write;
+ int c = *count;
+ u32 tmp = 0;
+ int psize = 0;
+ int writing = 1;
+ int timeout;
+
+ while (c > 0) {
+ tmp = *commands++;
+ if (!psize) {
+ writing = 1;
+
+ if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET0) {
+ if ((tmp & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2)) {
+ if ((tmp & R128_CCE_PACKET0_REG_MASK) !=
+ (R128_PM4_VC_FPU_SETUP >> 2)) {
+ writing = 0;
+ }
+ }
+ psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2;
+ } else if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET1) {
+ if ((tmp & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2)) {
+ if ((tmp & R128_CCE_PACKET1_REG0_MASK) !=
+ (R128_PM4_VC_FPU_SETUP >> 2)) {
+ writing = 0;
+ }
+ } else if ((tmp & R128_CCE_PACKET1_REG1_MASK) <=
+ (0x1004 << 9)) {
+ if ((tmp & R128_CCE_PACKET1_REG1_MASK) !=
+ (R128_PM4_VC_FPU_SETUP << 9)) {
+ writing = 0;
+ }
+ }
+ psize = 3;
+ } else {
+ psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2;
+ }
+ }
+ psize--;
+
+ if (writing) {
+ write++;
+ *write_ptr++ = tmp;
+ }
+ if (write >= dev_priv->ring_entries) {
+ write = 0;
+ write_ptr = dev_priv->ring_start;
+ }
+ timeout = 0;
+ while (write == *dev_priv->ring_read_ptr) {
+ (void)R128_READ(R128_PM4_BUFFER_DL_RPTR);
+ if (timeout++ >= dev_priv->usec_timeout)
+ return -EBUSY;
+ udelay(1);
+ }
+ c--;
+ }
+
+ if (write < 32)
+ memcpy(dev_priv->ring_end,
+ dev_priv->ring_start,
+ write * sizeof(u32));
+
+ /* Make sure WC cache has been flushed */
+ r128_flush_write_combine();
+
+ dev_priv->sarea_priv->ring_write = write;
+ R128_WRITE(R128_PM4_BUFFER_DL_WPTR, write);
+
+ *count = 0;
+
+ return 0;
+}
+
+static int r128_submit_packets_pio_secure(drm_device_t *dev,
+ u32 *commands, int *count)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ u32 tmp = 0;
+ int psize = 0;
+ int writing = 1;
+ int addr = R128_PM4_FIFO_DATA_EVEN;
+ int ret;
+
+ while (*count > 0) {
+ tmp = *commands++;
+ if (!psize) {
+ writing = 1;
+
+ if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET0) {
+ if ((tmp & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2)) {
+ if ((tmp & R128_CCE_PACKET0_REG_MASK) !=
+ (R128_PM4_VC_FPU_SETUP >> 2)) {
+ writing = 0;
+ }
+ }
+ psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2;
+ } else if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET1) {
+ if ((tmp & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2)) {
+ if ((tmp & R128_CCE_PACKET1_REG0_MASK) !=
+ (R128_PM4_VC_FPU_SETUP >> 2)) {
+ writing = 0;
+ }
+ } else if ((tmp & R128_CCE_PACKET1_REG1_MASK) <=
+ (0x1004 << 9)) {
+ if ((tmp & R128_CCE_PACKET1_REG1_MASK) !=
+ (R128_PM4_VC_FPU_SETUP << 9)) {
+ writing = 0;
+ }
+ }
+ psize = 3;
+ } else {
+ psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2;
+ }
+ }
+ psize--;
+
+ if (writing) {
+ if ((ret = r128_do_cce_wait_for_fifo(dev, 1)) < 0)
+ return ret;
+ R128_WRITE(addr, tmp);
+ addr ^= 0x0004;
+ }
+
+ *count -= 1;
+ }
+
+ if (addr == R128_PM4_FIFO_DATA_ODD) {
+ if ((ret = r128_do_cce_wait_for_fifo(dev, 1)) < 0) return ret;
+ R128_WRITE(addr, R128_CCE_PACKET2);
+ }
+
+ return 0;
+}
+
+static int r128_submit_packets_ring(drm_device_t *dev,
+ u32 *commands, int *count)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int write = dev_priv->sarea_priv->ring_write;
+ int *write_ptr = dev_priv->ring_start + write;
+ int c = *count;
+ int timeout;
+
+ while (c > 0) {
+ write++;
+ *write_ptr++ = *commands++;
+ if (write >= dev_priv->ring_entries) {
+ write = 0;
+ write_ptr = dev_priv->ring_start;
+ }
+ timeout = 0;
+ while (write == *dev_priv->ring_read_ptr) {
+ (void)R128_READ(R128_PM4_BUFFER_DL_RPTR);
+ if (timeout++ >= dev_priv->usec_timeout)
+ return -EBUSY;
+ udelay(1);
+ }
+ c--;
+ }
+
+ if (write < 32)
+ memcpy(dev_priv->ring_end,
+ dev_priv->ring_start,
+ write * sizeof(u32));
+
+ /* Make sure WC cache has been flushed */
+ r128_flush_write_combine();
+
+ dev_priv->sarea_priv->ring_write = write;
+ R128_WRITE(R128_PM4_BUFFER_DL_WPTR, write);
+
+ *count = 0;
+
+ return 0;
+}
+
+static int r128_submit_packets_pio(drm_device_t *dev,
+ u32 *commands, int *count)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int ret;
+
+ while (*count > 1) {
+ if ((ret = r128_do_cce_wait_for_fifo(dev, 2)) < 0) return ret;
+ R128_WRITE(R128_PM4_FIFO_DATA_EVEN, *commands++);
+ R128_WRITE(R128_PM4_FIFO_DATA_ODD, *commands++);
+ *count -= 2;
+ }
+
+ if (*count) {
+ if ((ret = r128_do_cce_wait_for_fifo(dev, 2)) < 0) return ret;
+ R128_WRITE(R128_PM4_FIFO_DATA_EVEN, *commands++);
+ R128_WRITE(R128_PM4_FIFO_DATA_ODD, R128_CCE_PACKET2);
+ *count = 0;
+ }
+
+ return 0;
+}
+
+static int r128_do_submit_packets(drm_device_t *dev, u32 *buffer, int count)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int c = count;
+ int ret;
+
+ if (dev_priv->cce_is_bm_mode) {
+ int left = 0;
+
+ if (c >= dev_priv->ring_entries) {
+ c = dev_priv->ring_entries-1;
+ left = count - c;
+ }
+
+ /* Since this is only used by the kernel we can use the
+ insecure ring buffer submit packet routine */
+ ret = r128_submit_packets_ring(dev, buffer, &c);
+
+ c += left;
+ } else {
+ /* Since this is only used by the kernel we can use the
+ insecure PIO submit packet routine */
+ ret = r128_submit_packets_pio(dev, buffer, &c);
+ }
+
+ if (ret < 0) return ret;
+ else return c;
+}
+
+int r128_submit_pkt(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ drm_r128_packet_t packet;
+ u32 *buffer;
+ int c;
+ int size;
+ int ret = 0;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||
+ dev->lock.pid != current->pid) {
+ DRM_ERROR("r128_submit_pkt called without holding the lock\n");
+ return -EINVAL;
+ }
+
+ copy_from_user_ret(&packet, (drm_r128_packet_t *)arg, sizeof(packet),
+ -EFAULT);
+
+ c = packet.count;
+ size = c * sizeof(*buffer);
+
+ if (dev_priv->cce_is_bm_mode) {
+ int left = 0;
+
+ if (c >= dev_priv->ring_entries) {
+ c = dev_priv->ring_entries-1;
+ size = c * sizeof(*buffer);
+ left = packet.count - c;
+ }
+
+ if ((buffer = kmalloc(size, 0)) == NULL) return -ENOMEM;
+ copy_from_user_ret(buffer, packet.buffer, size, -EFAULT);
+
+ if (dev_priv->cce_secure)
+ ret = r128_submit_packets_ring_secure(dev, buffer, &c);
+ else
+ ret = r128_submit_packets_ring(dev, buffer, &c);
+
+ c += left;
+ } else {
+ if ((buffer = kmalloc(size, 0)) == NULL) return -ENOMEM;
+ copy_from_user_ret(buffer, packet.buffer, size, -EFAULT);
+
+ if (dev_priv->cce_secure)
+ ret = r128_submit_packets_pio_secure(dev, buffer, &c);
+ else
+ ret = r128_submit_packets_pio(dev, buffer, &c);
+ }
+
+ kfree(buffer);
+
+ packet.count = c;
+ copy_to_user_ret((drm_r128_packet_t *)arg, &packet, sizeof(packet),
+ -EFAULT);
+
+ if (ret) return ret;
+ else if (c > 0) return -EAGAIN;
+
+ return 0;
+}
+
+static int r128_send_vertbufs(drm_device_t *dev, drm_r128_vertex_t *v)
+{
+ drm_device_dma_t *dma = dev->dma;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ drm_r128_buf_priv_t *buf_priv;
+ drm_buf_t *buf;
+ int i, ret;
+ u32 cce[2];
+
+ /* Make sure we have valid data */
+ for (i = 0; i < v->send_count; i++) {
+ int idx = v->send_indices[i];
+
+ if (idx < 0 || idx >= dma->buf_count) {
+ DRM_ERROR("Index %d (of %d max)\n",
+ idx, dma->buf_count - 1);
+ return -EINVAL;
+ }
+ buf = dma->buflist[idx];
+ if (buf->pid != current->pid) {
+ DRM_ERROR("Process %d using buffer owned by %d\n",
+ current->pid, buf->pid);
+ return -EINVAL;
+ }
+ if (buf->pending) {
+ DRM_ERROR("Sending pending buffer:"
+ " buffer %d, offset %d\n",
+ v->send_indices[i], i);
+ return -EINVAL;
+ }
+ }
+
+ /* Wait for idle, if we've wrapped to make sure that all pending
+ buffers have been processed */
+ if (dev_priv->submit_age == R128_MAX_VBUF_AGE) {
+ if ((ret = r128_do_cce_wait_for_idle(dev)) < 0) return ret;
+ dev_priv->submit_age = 0;
+ r128_mark_vertbufs_done(dev);
+ }
+
+ /* Make sure WC cache has been flushed (if in PIO mode) */
+ if (!dev_priv->cce_is_bm_mode) r128_flush_write_combine();
+
+ /* FIXME: Add support for sending vertex buffer to the CCE here
+ instead of in client code. The v->prim holds the primitive
+ type that should be drawn. Loop over the list buffers in
+ send_indices[] and submit a packet for each VB.
+
+ This will require us to loop over the clip rects here as
+ well, which implies that we extend the kernel driver to allow
+ cliprects to be stored here. Note that the cliprects could
+ possibly come from the X server instead of the client, but
+ this will require additional changes to the DRI to allow for
+ this optimization. */
+
+ /* Submit a CCE packet that writes submit_age to R128_VB_AGE_REG */
+ cce[0] = R128CCE0(R128_CCE_PACKET0, R128_VB_AGE_REG, 0);
+ cce[1] = dev_priv->submit_age;
+ if ((ret = r128_do_submit_packets(dev, cce, 2)) < 0) {
+ /* Until we add support for sending VBs to the CCE in
+ this routine, we can recover from this error. After
+ we add that support, we won't be able to easily
+ recover, so we will probably have to implement
+ another mechanism for handling timeouts from packets
+ submitted directly by the kernel. */
+ return ret;
+ }
+
+ /* Now that the submit packet request has succeeded, we can mark
+ the buffers as pending */
+ for (i = 0; i < v->send_count; i++) {
+ buf = dma->buflist[v->send_indices[i]];
+ buf->pending = 1;
+
+ buf_priv = buf->dev_private;
+ buf_priv->age = dev_priv->submit_age;
+ }
+
+ dev_priv->submit_age++;
+
+ return 0;
+}
+
+static drm_buf_t *r128_freelist_get(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ drm_r128_buf_priv_t *buf_priv;
+ drm_buf_t *buf;
+ int i, t;
+
+ /* FIXME: Optimize -- use freelist code */
+
+ for (i = 0; i < dma->buf_count; i++) {
+ buf = dma->buflist[i];
+ buf_priv = buf->dev_private;
+ if (buf->pid == 0) return buf;
+ }
+
+ for (t = 0; t < dev_priv->usec_timeout; t++) {
+ u32 done_age = R128_READ(R128_VB_AGE_REG);
+
+ for (i = 0; i < dma->buf_count; i++) {
+ buf = dma->buflist[i];
+ buf_priv = buf->dev_private;
+ if (buf->pending && buf_priv->age <= done_age) {
+ /* The buffer has been processed, so it
+ can now be used */
+ buf->pending = 0;
+ return buf;
+ }
+ }
+ udelay(1);
+ }
+
+ return NULL;
+}
+
+
+static int r128_get_vertbufs(drm_device_t *dev, drm_r128_vertex_t *v)
+{
+ drm_buf_t *buf;
+ int i;
+
+ for (i = v->granted_count; i < v->request_count; i++) {
+ buf = r128_freelist_get(dev);
+ if (!buf) break;
+ buf->pid = current->pid;
+ copy_to_user_ret(&v->request_indices[i],
+ &buf->idx,
+ sizeof(buf->idx),
+ -EFAULT);
+ copy_to_user_ret(&v->request_sizes[i],
+ &buf->total,
+ sizeof(buf->total),
+ -EFAULT);
+ ++v->granted_count;
+ }
+ return 0;
+}
+
+int r128_vertex_buf(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+ int retcode = 0;
+ drm_r128_vertex_t v;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||
+ dev->lock.pid != current->pid) {
+ DRM_ERROR("r128_vertex_buf called without holding the lock\n");
+ return -EINVAL;
+ }
+
+ if (!dev_priv || dev_priv->is_pci) {
+ DRM_ERROR("r128_vertex_buf called with a PCI card\n");
+ return -EINVAL;
+ }
+
+ copy_from_user_ret(&v, (drm_r128_vertex_t *)arg, sizeof(v), -EFAULT);
+ DRM_DEBUG("%d: %d send, %d req\n",
+ current->pid, v.send_count, v.request_count);
+
+ if (v.send_count < 0 || v.send_count > dma->buf_count) {
+ DRM_ERROR("Process %d trying to send %d buffers (of %d max)\n",
+ current->pid, v.send_count, dma->buf_count);
+ return -EINVAL;
+ }
+ if (v.request_count < 0 || v.request_count > dma->buf_count) {
+ DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
+ current->pid, v.request_count, dma->buf_count);
+ return -EINVAL;
+ }
+
+ if (v.send_count) {
+ retcode = r128_send_vertbufs(dev, &v);
+ }
+
+ v.granted_count = 0;
+
+ if (!retcode && v.request_count) {
+ retcode = r128_get_vertbufs(dev, &v);
+ }
+
+ DRM_DEBUG("%d returning, granted = %d\n",
+ current->pid, v.granted_count);
+ copy_to_user_ret((drm_r128_vertex_t *)arg, &v, sizeof(v), -EFAULT);
+
+ return retcode;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h
new file mode 100644
index 000000000..fa90d72db
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h
@@ -0,0 +1,111 @@
+/* r128_drm.h -- Public header for the r128 driver -*- linux-c -*-
+ * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
+ *
+ * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ * $XFree86$
+ */
+
+#ifndef _R128_DRM_H_
+#define _R128_DRM_H_
+
+/* WARNING: If you change any of these defines, make sure to change the
+ * defines in the Xserver file (xf86drmR128.h)
+ */
+typedef struct drm_r128_init {
+ enum {
+ R128_INIT_CCE = 0x01,
+ R128_CLEANUP_CCE = 0x02
+ } func;
+ int sarea_priv_offset;
+ int is_pci;
+ int cce_mode;
+ int cce_fifo_size;
+ int cce_secure;
+ int ring_size;
+ int usec_timeout;
+
+ int fb_offset;
+ int agp_ring_offset;
+ int agp_read_ptr_offset;
+ int agp_vertbufs_offset;
+ int agp_indbufs_offset;
+ int agp_textures_offset;
+ int mmio_offset;
+} drm_r128_init_t;
+
+typedef struct drm_r128_packet {
+ unsigned long *buffer;
+ int count;
+ int flags;
+} drm_r128_packet_t;
+
+typedef enum drm_r128_prim {
+ _DRM_R128_PRIM_NONE = 0x0001,
+ _DRM_R128_PRIM_POINT = 0x0002,
+ _DRM_R128_PRIM_LINE = 0x0004,
+ _DRM_R128_PRIM_POLY_LINE = 0x0008,
+ _DRM_R128_PRIM_TRI_LIST = 0x0010,
+ _DRM_R128_PRIM_TRI_FAN = 0x0020,
+ _DRM_R128_PRIM_TRI_STRIP = 0x0040,
+ _DRM_R128_PRIM_TRI_TYPE2 = 0x0080
+} drm_r128_prim_t;
+
+typedef struct drm_r128_vertex {
+ /* Indices here refer to the offset into
+ buflist in drm_buf_get_t. */
+ int send_count; /* Number of buffers to send */
+ int *send_indices; /* List of handles to buffers */
+ int *send_sizes; /* Lengths of data to send */
+ drm_r128_prim_t prim; /* Primitive type */
+ int request_count; /* Number of buffers requested */
+ int *request_indices; /* Buffer information */
+ int *request_sizes;
+ int granted_count; /* Number of buffers granted */
+} drm_r128_vertex_t;
+
+/* WARNING: If you change any of these defines, make sure to change the
+ * defines in the Xserver file (r128_sarea.h)
+ */
+#define R128_LOCAL_TEX_HEAP 0
+#define R128_AGP_TEX_HEAP 1
+#define R128_NR_TEX_HEAPS 2
+#define R128_NR_TEX_REGIONS 64
+#define R128_LOG_TEX_GRANULARITY 16
+
+typedef struct drm_tex_region {
+ unsigned char next, prev;
+ unsigned char in_use;
+ int age;
+} drm_tex_region_t;
+
+typedef struct drm_r128_sarea {
+ drm_tex_region_t tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1];
+ int tex_age[R128_NR_TEX_HEAPS];
+ int ctx_owner;
+ int ring_write;
+} drm_r128_sarea_t;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c
new file mode 100644
index 000000000..45ade1def
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c
@@ -0,0 +1,737 @@
+/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*-
+ * Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@precisioninsight.com>
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ * $XFree86$
+ *
+ */
+
+#define EXPORT_SYMTAB
+#include "drmP.h"
+#include "r128_drv.h"
+EXPORT_SYMBOL(r128_init);
+EXPORT_SYMBOL(r128_cleanup);
+
+#define R128_NAME "r128"
+#define R128_DESC "r128"
+#define R128_DATE "20000422"
+#define R128_MAJOR 0
+#define R128_MINOR 0
+#define R128_PATCHLEVEL 5
+
+static drm_device_t r128_device;
+drm_ctx_t r128_res_ctx;
+
+static struct file_operations r128_fops = {
+ open: r128_open,
+ flush: drm_flush,
+ release: r128_release,
+ ioctl: r128_ioctl,
+ mmap: drm_mmap,
+ read: drm_read,
+ fasync: drm_fasync,
+ poll: drm_poll,
+};
+
+static struct miscdevice r128_misc = {
+ minor: MISC_DYNAMIC_MINOR,
+ name: R128_NAME,
+ fops: &r128_fops,
+};
+
+static drm_ioctl_desc_t r128_ioctls[] = {
+ [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { r128_version, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_busid, 0, 1 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_block, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { r128_addbufs, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { drm_markbufs, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { r128_mapbufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 1, 0 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { r128_addctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { r128_rmctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { r128_modctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { r128_getctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { r128_switchctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { r128_newctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { r128_resctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { r128_lock, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { r128_unlock, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 },
+
+#ifdef DRM_AGP
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { drm_agp_acquire, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { drm_agp_release, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { drm_agp_enable, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { drm_agp_info, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { drm_agp_alloc, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { drm_agp_free, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 },
+#endif
+
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_INIT)] = { r128_init_cce, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_RESET)] = { r128_eng_reset, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_FLUSH)] = { r128_eng_flush, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_PACKET)] = { r128_submit_pkt, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_CCEIDL)] = { r128_cce_idle, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_VERTEX)] = { r128_vertex_buf, 1, 0 },
+};
+#define R128_IOCTL_COUNT DRM_ARRAY_SIZE(r128_ioctls)
+
+#ifdef MODULE
+int init_module(void);
+void cleanup_module(void);
+static char *r128 = NULL;
+
+MODULE_AUTHOR("Precision Insight, Inc., Cedar Park, Texas.");
+MODULE_DESCRIPTION("r128");
+MODULE_PARM(r128, "s");
+
+/* init_module is called when insmod is used to load the module */
+
+int init_module(void)
+{
+ return r128_init();
+}
+
+/* cleanup_module is called when rmmod is used to unload the module */
+
+void cleanup_module(void)
+{
+ r128_cleanup();
+}
+#endif
+
+#ifndef MODULE
+/* r128_setup is called by the kernel to parse command-line options passed
+ * via the boot-loader (e.g., LILO). It calls the insmod option routine,
+ * drm_parse_drm.
+ *
+ * This is not currently supported, since it requires changes to
+ * linux/init/main.c. */
+
+
+void __init r128_setup(char *str, int *ints)
+{
+ if (ints[0] != 0) {
+ DRM_ERROR("Illegal command line format, ignored\n");
+ return;
+ }
+ drm_parse_options(str);
+}
+#endif
+
+static int r128_setup(drm_device_t *dev)
+{
+ int i;
+
+ atomic_set(&dev->ioctl_count, 0);
+ atomic_set(&dev->vma_count, 0);
+ dev->buf_use = 0;
+ atomic_set(&dev->buf_alloc, 0);
+
+ drm_dma_setup(dev);
+
+ atomic_set(&dev->total_open, 0);
+ atomic_set(&dev->total_close, 0);
+ atomic_set(&dev->total_ioctl, 0);
+ atomic_set(&dev->total_irq, 0);
+ atomic_set(&dev->total_ctx, 0);
+ atomic_set(&dev->total_locks, 0);
+ atomic_set(&dev->total_unlocks, 0);
+ atomic_set(&dev->total_contends, 0);
+ atomic_set(&dev->total_sleeps, 0);
+
+ for (i = 0; i < DRM_HASH_SIZE; i++) {
+ dev->magiclist[i].head = NULL;
+ dev->magiclist[i].tail = NULL;
+ }
+ dev->maplist = NULL;
+ dev->map_count = 0;
+ dev->vmalist = NULL;
+ dev->lock.hw_lock = NULL;
+ init_waitqueue_head(&dev->lock.lock_queue);
+ dev->queue_count = 0;
+ dev->queue_reserved = 0;
+ dev->queue_slots = 0;
+ dev->queuelist = NULL;
+ dev->irq = 0;
+ dev->context_flag = 0;
+ dev->interrupt_flag = 0;
+ dev->dma_flag = 0;
+ dev->last_context = 0;
+ dev->last_switch = 0;
+ dev->last_checked = 0;
+ init_timer(&dev->timer);
+ init_waitqueue_head(&dev->context_wait);
+
+ dev->ctx_start = 0;
+ dev->lck_start = 0;
+
+ dev->buf_rp = dev->buf;
+ dev->buf_wp = dev->buf;
+ dev->buf_end = dev->buf + DRM_BSZ;
+ dev->buf_async = NULL;
+ init_waitqueue_head(&dev->buf_readers);
+ init_waitqueue_head(&dev->buf_writers);
+
+ r128_res_ctx.handle=-1;
+
+ DRM_DEBUG("\n");
+
+ /* The kernel's context could be created here, but is now created
+ in drm_dma_enqueue. This is more resource-efficient for
+ hardware that does not do DMA, but may mean that
+ drm_select_queue fails between the time the interrupt is
+ initialized and the time the queues are initialized. */
+
+ return 0;
+}
+
+
+static int r128_takedown(drm_device_t *dev)
+{
+ int i;
+ drm_magic_entry_t *pt, *next;
+ drm_map_t *map;
+ drm_vma_entry_t *vma, *vma_next;
+
+ DRM_DEBUG("\n");
+
+ down(&dev->struct_sem);
+ del_timer(&dev->timer);
+
+ if (dev->devname) {
+ drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER);
+ dev->devname = NULL;
+ }
+
+ if (dev->unique) {
+ drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER);
+ dev->unique = NULL;
+ dev->unique_len = 0;
+ }
+ /* Clear pid list */
+ for (i = 0; i < DRM_HASH_SIZE; i++) {
+ for (pt = dev->magiclist[i].head; pt; pt = next) {
+ next = pt->next;
+ drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
+ }
+ dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
+ }
+
+#ifdef DRM_AGP
+ /* Clear AGP information */
+ if (dev->agp) {
+ drm_agp_mem_t *entry;
+ drm_agp_mem_t *nexte;
+
+ /* Remove AGP resources, but leave dev->agp
+ intact until r128_cleanup is called. */
+ for (entry = dev->agp->memory; entry; entry = nexte) {
+ nexte = entry->next;
+ if (entry->bound) drm_unbind_agp(entry->memory);
+ drm_free_agp(entry->memory, entry->pages);
+ drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
+ }
+ dev->agp->memory = NULL;
+
+ if (dev->agp->acquired && drm_agp.release)
+ (*drm_agp.release)();
+
+ dev->agp->acquired = 0;
+ dev->agp->enabled = 0;
+ }
+#endif
+
+ /* Clear vma list (only built for debugging) */
+ if (dev->vmalist) {
+ for (vma = dev->vmalist; vma; vma = vma_next) {
+ vma_next = vma->next;
+ drm_free(vma, sizeof(*vma), DRM_MEM_VMAS);
+ }
+ dev->vmalist = NULL;
+ }
+
+ /* Clear map area and mtrr information */
+ if (dev->maplist) {
+ for (i = 0; i < dev->map_count; i++) {
+ map = dev->maplist[i];
+ switch (map->type) {
+ case _DRM_REGISTERS:
+ case _DRM_FRAME_BUFFER:
+#ifdef CONFIG_MTRR
+ if (map->mtrr >= 0) {
+ int retcode;
+ retcode = mtrr_del(map->mtrr,
+ map->offset,
+ map->size);
+ DRM_DEBUG("mtrr_del = %d\n", retcode);
+ }
+#endif
+ drm_ioremapfree(map->handle, map->size);
+ break;
+ case _DRM_SHM:
+ drm_free_pages((unsigned long)map->handle,
+ drm_order(map->size)
+ - PAGE_SHIFT,
+ DRM_MEM_SAREA);
+ break;
+ case _DRM_AGP:
+ /* Do nothing here, because this is all
+ handled in the AGP/GART driver. */
+ break;
+ }
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ }
+ drm_free(dev->maplist,
+ dev->map_count * sizeof(*dev->maplist),
+ DRM_MEM_MAPS);
+ dev->maplist = NULL;
+ dev->map_count = 0;
+ }
+
+ drm_dma_takedown(dev);
+
+ dev->queue_count = 0;
+ if (dev->lock.hw_lock) {
+ dev->lock.hw_lock = NULL; /* SHM removed */
+ dev->lock.pid = 0;
+ wake_up_interruptible(&dev->lock.lock_queue);
+ }
+ up(&dev->struct_sem);
+
+ return 0;
+}
+
+/* r128_init is called via init_module at module load time, or via
+ * linux/init/main.c (this is not currently supported). */
+
+int r128_init(void)
+{
+ int retcode;
+ drm_device_t *dev = &r128_device;
+
+ DRM_DEBUG("\n");
+
+ memset((void *)dev, 0, sizeof(*dev));
+ dev->count_lock = SPIN_LOCK_UNLOCKED;
+ sema_init(&dev->struct_sem, 1);
+
+#ifdef MODULE
+ drm_parse_options(r128);
+#endif
+
+ if ((retcode = misc_register(&r128_misc))) {
+ DRM_ERROR("Cannot register \"%s\"\n", R128_NAME);
+ return retcode;
+ }
+ dev->device = MKDEV(MISC_MAJOR, r128_misc.minor);
+ dev->name = R128_NAME;
+
+ drm_mem_init();
+ drm_proc_init(dev);
+
+#ifdef DRM_AGP
+ dev->agp = drm_agp_init();
+
+#ifdef CONFIG_MTRR
+ dev->agp->agp_mtrr = mtrr_add(dev->agp->agp_info.aper_base,
+ dev->agp->agp_info.aper_size*1024*1024,
+ MTRR_TYPE_WRCOMB,
+ 1);
+#endif
+#endif
+
+ if((retcode = drm_ctxbitmap_init(dev))) {
+ DRM_ERROR("Cannot allocate memory for context bitmap.\n");
+ drm_proc_cleanup();
+ misc_deregister(&r128_misc);
+ r128_takedown(dev);
+ return retcode;
+ }
+
+ DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
+ R128_NAME,
+ R128_MAJOR,
+ R128_MINOR,
+ R128_PATCHLEVEL,
+ R128_DATE,
+ r128_misc.minor);
+
+ return 0;
+}
+
+/* r128_cleanup is called via cleanup_module at module unload time. */
+
+void r128_cleanup(void)
+{
+ drm_device_t *dev = &r128_device;
+
+ DRM_DEBUG("\n");
+
+ drm_proc_cleanup();
+ if (misc_deregister(&r128_misc)) {
+ DRM_ERROR("Cannot unload module\n");
+ } else {
+ DRM_INFO("Module unloaded\n");
+ }
+ drm_ctxbitmap_cleanup(dev);
+ r128_takedown(dev);
+#ifdef DRM_AGP
+ if (dev->agp) {
+ /* FIXME -- free other information, too */
+ drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
+ dev->agp = NULL;
+ }
+#endif
+}
+
+int r128_version(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_version_t version;
+ int len;
+
+ copy_from_user_ret(&version,
+ (drm_version_t *)arg,
+ sizeof(version),
+ -EFAULT);
+
+#define DRM_COPY(name,value) \
+ len = strlen(value); \
+ if (len > name##_len) len = name##_len; \
+ name##_len = strlen(value); \
+ if (len && name) { \
+ copy_to_user_ret(name, value, len, -EFAULT); \
+ }
+
+ version.version_major = R128_MAJOR;
+ version.version_minor = R128_MINOR;
+ version.version_patchlevel = R128_PATCHLEVEL;
+
+ DRM_COPY(version.name, R128_NAME);
+ DRM_COPY(version.date, R128_DATE);
+ DRM_COPY(version.desc, R128_DESC);
+
+ copy_to_user_ret((drm_version_t *)arg,
+ &version,
+ sizeof(version),
+ -EFAULT);
+ return 0;
+}
+
+int r128_open(struct inode *inode, struct file *filp)
+{
+ drm_device_t *dev = &r128_device;
+ int retcode = 0;
+
+ DRM_DEBUG("open_count = %d\n", dev->open_count);
+ if (!(retcode = drm_open_helper(inode, filp, dev))) {
+ MOD_INC_USE_COUNT;
+ atomic_inc(&dev->total_open);
+ spin_lock(&dev->count_lock);
+ if (!dev->open_count++) {
+ spin_unlock(&dev->count_lock);
+ return r128_setup(dev);
+ }
+ spin_unlock(&dev->count_lock);
+ }
+ return retcode;
+}
+
+int r128_release(struct inode *inode, struct file *filp)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ int retcode = 0;
+
+ DRM_DEBUG("open_count = %d\n", dev->open_count);
+ if (!(retcode = drm_release(inode, filp))) {
+ MOD_DEC_USE_COUNT;
+ atomic_inc(&dev->total_close);
+ spin_lock(&dev->count_lock);
+ if (!--dev->open_count) {
+ if (atomic_read(&dev->ioctl_count) || dev->blocked) {
+ DRM_ERROR("Device busy: %d %d\n",
+ atomic_read(&dev->ioctl_count),
+ dev->blocked);
+ spin_unlock(&dev->count_lock);
+ return -EBUSY;
+ }
+ spin_unlock(&dev->count_lock);
+ return r128_takedown(dev);
+ }
+ spin_unlock(&dev->count_lock);
+ }
+ return retcode;
+}
+
+/* r128_ioctl is called whenever a process performs an ioctl on /dev/drm. */
+
+int r128_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ int nr = DRM_IOCTL_NR(cmd);
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ int retcode = 0;
+ drm_ioctl_desc_t *ioctl;
+ drm_ioctl_t *func;
+
+ atomic_inc(&dev->ioctl_count);
+ atomic_inc(&dev->total_ioctl);
+ ++priv->ioctl_count;
+
+ DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n",
+ current->pid, cmd, nr, dev->device, priv->authenticated);
+
+ if (nr >= R128_IOCTL_COUNT) {
+ retcode = -EINVAL;
+ } else {
+ ioctl = &r128_ioctls[nr];
+ func = ioctl->func;
+
+ if (!func) {
+ DRM_DEBUG("no function\n");
+ retcode = -EINVAL;
+ } else if ((ioctl->root_only && !capable(CAP_SYS_ADMIN))
+ || (ioctl->auth_needed && !priv->authenticated)) {
+ retcode = -EACCES;
+ } else {
+ retcode = (func)(inode, filp, cmd, arg);
+ }
+ }
+
+ atomic_dec(&dev->ioctl_count);
+ return retcode;
+}
+
+int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ DECLARE_WAITQUEUE(entry, current);
+ int ret = 0;
+ drm_lock_t lock;
+#if DRM_DMA_HISTOGRAM
+ cycles_t start;
+
+ dev->lck_start = start = get_cycles();
+#endif
+
+ copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+
+ if (lock.context == DRM_KERNEL_CONTEXT) {
+ DRM_ERROR("Process %d using kernel context %d\n",
+ current->pid, lock.context);
+ return -EINVAL;
+ }
+
+ DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
+ lock.context, current->pid, dev->lock.hw_lock->lock,
+ lock.flags);
+
+#if 0
+ /* dev->queue_count == 0 right now for
+ r128. FIXME? */
+ if (lock.context < 0 || lock.context >= dev->queue_count)
+ return -EINVAL;
+#endif
+
+ if (!ret) {
+#if 0
+ if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)
+ != lock.context) {
+ long j = jiffies - dev->lock.lock_time;
+
+ if (lock.context == r128_res_ctx.handle &&
+ j >= 0 && j < DRM_LOCK_SLICE) {
+ /* Can't take lock if we just had it and
+ there is contention. */
+ DRM_DEBUG("%d (pid %d) delayed j=%d dev=%d jiffies=%d\n",
+ lock.context, current->pid, j,
+ dev->lock.lock_time, jiffies);
+ current->state = TASK_INTERRUPTIBLE;
+ current->policy |= SCHED_YIELD;
+ schedule_timeout(DRM_LOCK_SLICE-j);
+ DRM_DEBUG("jiffies=%d\n", jiffies);
+ }
+ }
+#endif
+ add_wait_queue(&dev->lock.lock_queue, &entry);
+ for (;;) {
+ if (!dev->lock.hw_lock) {
+ /* Device has been unregistered */
+ ret = -EINTR;
+ break;
+ }
+ if (drm_lock_take(&dev->lock.hw_lock->lock,
+ lock.context)) {
+ dev->lock.pid = current->pid;
+ dev->lock.lock_time = jiffies;
+ atomic_inc(&dev->total_locks);
+ break; /* Got lock */
+ }
+
+ /* Contention */
+ atomic_inc(&dev->total_sleeps);
+ current->state = TASK_INTERRUPTIBLE;
+#if 1
+ current->policy |= SCHED_YIELD;
+#endif
+ schedule();
+ if (signal_pending(current)) {
+ ret = -ERESTARTSYS;
+ break;
+ }
+ }
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev->lock.lock_queue, &entry);
+ }
+
+#if 0
+ if (!ret && dev->last_context != lock.context &&
+ lock.context != r128_res_ctx.handle &&
+ dev->last_context != r128_res_ctx.handle) {
+ add_wait_queue(&dev->context_wait, &entry);
+ current->state = TASK_INTERRUPTIBLE;
+ /* PRE: dev->last_context != lock.context */
+ r128_context_switch(dev, dev->last_context, lock.context);
+ /* POST: we will wait for the context
+ switch and will dispatch on a later call
+ when dev->last_context == lock.context
+ NOTE WE HOLD THE LOCK THROUGHOUT THIS
+ TIME! */
+ current->policy |= SCHED_YIELD;
+ schedule();
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev->context_wait, &entry);
+ if (signal_pending(current)) {
+ ret = -EINTR;
+ } else if (dev->last_context != lock.context) {
+ DRM_ERROR("Context mismatch: %d %d\n",
+ dev->last_context, lock.context);
+ }
+ }
+#endif
+
+ if (!ret) {
+ if (lock.flags & _DRM_LOCK_READY) {
+ /* Wait for space in DMA/FIFO */
+ }
+ if (lock.flags & _DRM_LOCK_QUIESCENT) {
+ /* Make hardware quiescent */
+#if 0
+ r128_quiescent(dev);
+#endif
+ }
+ }
+
+#if 0
+ DRM_ERROR("pid = %5d, old counter = %5ld\n",
+ current->pid, current->counter);
+#endif
+ if (lock.context != r128_res_ctx.handle) {
+ current->counter = 5;
+ current->priority = DEF_PRIORITY/4;
+ }
+#if 0
+ while (current->counter > 25)
+ current->counter >>= 1; /* decrease time slice */
+ DRM_ERROR("pid = %5d, new counter = %5ld\n",
+ current->pid, current->counter);
+#endif
+ DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
+
+#if DRM_DMA_HISTOGRAM
+ atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]);
+#endif
+
+ return ret;
+}
+
+
+int r128_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_lock_t lock;
+
+ copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+
+ if (lock.context == DRM_KERNEL_CONTEXT) {
+ DRM_ERROR("Process %d using kernel context %d\n",
+ current->pid, lock.context);
+ return -EINVAL;
+ }
+
+ DRM_DEBUG("%d frees lock (%d holds)\n",
+ lock.context,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+ atomic_inc(&dev->total_unlocks);
+ if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock))
+ atomic_inc(&dev->total_contends);
+ drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT);
+ /* FIXME: Try to send data to card here */
+ if (!dev->context_flag) {
+ if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ DRM_ERROR("\n");
+ }
+ }
+
+#if 0
+ current->policy |= SCHED_YIELD;
+ current->state = TASK_INTERRUPTIBLE;
+ schedule_timeout(1000);
+#endif
+
+ if (lock.context != r128_res_ctx.handle) {
+ current->counter = 5;
+ current->priority = DEF_PRIORITY;
+ }
+#if 0
+ current->state = TASK_INTERRUPTIBLE;
+ schedule_timeout(10);
+#endif
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h
new file mode 100644
index 000000000..3b888c493
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h
@@ -0,0 +1,226 @@
+/* r128_drv.h -- Private header for r128 driver -*- linux-c -*-
+ * Created: Mon Dec 13 09:51:11 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@precisioninsight.com>
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ * $XFree86$
+ *
+ */
+
+#ifndef _R128_DRV_H_
+#define _R128_DRV_H_
+
+typedef struct drm_r128_private {
+ int is_pci;
+
+ int cce_mode;
+ int cce_fifo_size;
+ int cce_is_bm_mode;
+ int cce_secure;
+
+ drm_r128_sarea_t *sarea_priv;
+
+ __volatile__ u32 *ring_read_ptr;
+
+ u32 *ring_start;
+ u32 *ring_end;
+ int ring_size;
+ int ring_sizel2qw;
+ int ring_entries;
+
+ int submit_age;
+
+ int usec_timeout;
+
+ drm_map_t *sarea;
+ drm_map_t *fb;
+ drm_map_t *agp_ring;
+ drm_map_t *agp_read_ptr;
+ drm_map_t *agp_vertbufs;
+ drm_map_t *agp_indbufs;
+ drm_map_t *agp_textures;
+ drm_map_t *mmio;
+} drm_r128_private_t;
+
+typedef struct drm_r128_buf_priv {
+ u32 age;
+} drm_r128_buf_priv_t;
+
+ /* r128_drv.c */
+extern int r128_init(void);
+extern void r128_cleanup(void);
+extern int r128_version(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_open(struct inode *inode, struct file *filp);
+extern int r128_release(struct inode *inode, struct file *filp);
+extern int r128_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_lock(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_unlock(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
+ /* r128_dma.c */
+extern int r128_init_cce(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_eng_reset(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_eng_flush(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_submit_pkt(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_cce_idle(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_vertex_buf(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
+ /* r128_bufs.c */
+extern int r128_addbufs(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_mapbufs(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
+ /* r128_context.c */
+extern int r128_resctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_addctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_modctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_getctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_switchctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_newctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_rmctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
+extern int r128_context_switch(drm_device_t *dev, int old, int new);
+extern int r128_context_switch_complete(drm_device_t *dev, int new);
+
+
+/* Register definitions, register access macros and drmAddMap constants
+ * for Rage 128 kernel driver.
+ */
+
+#define R128_PC_NGUI_CTLSTAT 0x0184
+# define R128_PC_FLUSH_ALL 0x00ff
+# define R128_PC_BUSY (1 << 31)
+
+#define R128_CLOCK_CNTL_INDEX 0x0008
+#define R128_CLOCK_CNTL_DATA 0x000c
+# define R128_PLL_WR_EN (1 << 7)
+
+#define R128_MCLK_CNTL 0x000f
+# define R128_FORCE_GCP (1 << 16)
+# define R128_FORCE_PIPE3D_CPP (1 << 17)
+
+#define R128_GEN_RESET_CNTL 0x00f0
+# define R128_SOFT_RESET_GUI (1 << 0)
+
+#define R128_PM4_BUFFER_CNTL 0x0704
+# define R128_PM4_NONPM4 (0 << 28)
+# define R128_PM4_192PIO (1 << 28)
+# define R128_PM4_192BM (2 << 28)
+# define R128_PM4_128PIO_64INDBM (3 << 28)
+# define R128_PM4_128BM_64INDBM (4 << 28)
+# define R128_PM4_64PIO_128INDBM (5 << 28)
+# define R128_PM4_64BM_128INDBM (6 << 28)
+# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28)
+# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28)
+# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28)
+
+
+#define R128_PM4_BUFFER_DL_RPTR 0x0710
+#define R128_PM4_BUFFER_DL_WPTR 0x0714
+# define R128_PM4_BUFFER_DL_DONE (1 << 31)
+
+#define R128_PM4_VC_FPU_SETUP 0x071c
+
+#define R128_PM4_STAT 0x07b8
+# define R128_PM4_FIFOCNT_MASK 0x0fff
+# define R128_PM4_BUSY (1 << 16)
+# define R128_PM4_GUI_ACTIVE (1 << 31)
+
+#define R128_PM4_BUFFER_ADDR 0x07f0
+#define R128_PM4_MICRO_CNTL 0x07fc
+# define R128_PM4_MICRO_FREERUN (1 << 30)
+
+#define R128_PM4_FIFO_DATA_EVEN 0x1000
+#define R128_PM4_FIFO_DATA_ODD 0x1004
+
+#define R128_GUI_SCRATCH_REG0 0x15e0
+#define R128_GUI_SCRATCH_REG1 0x15e4
+#define R128_GUI_SCRATCH_REG2 0x15e8
+#define R128_GUI_SCRATCH_REG3 0x15ec
+#define R128_GUI_SCRATCH_REG4 0x15f0
+#define R128_GUI_SCRATCH_REG5 0x15f4
+
+#define R128_GUI_STAT 0x1740
+# define R128_GUI_FIFOCNT_MASK 0x0fff
+# define R128_GUI_ACTIVE (1 << 31)
+
+
+/* CCE command packets */
+#define R128_CCE_PACKET0 0x00000000
+#define R128_CCE_PACKET1 0x40000000
+#define R128_CCE_PACKET2 0x80000000
+# define R128_CCE_PACKET_MASK 0xC0000000
+# define R128_CCE_PACKET_COUNT_MASK 0x3fff0000
+# define R128_CCE_PACKET0_REG_MASK 0x000007ff
+# define R128_CCE_PACKET1_REG0_MASK 0x000007ff
+# define R128_CCE_PACKET1_REG1_MASK 0x003ff800
+
+
+#define R128_MAX_USEC_TIMEOUT 100000 /* 100 ms */
+
+
+#define R128_BASE(reg) ((u32)(dev_priv->mmio->handle))
+#define R128_ADDR(reg) (R128_BASE(reg) + reg)
+
+#define R128_DEREF(reg) *(__volatile__ int *)R128_ADDR(reg)
+#define R128_READ(reg) R128_DEREF(reg)
+#define R128_WRITE(reg,val) do { R128_DEREF(reg) = val; } while (0)
+
+#define R128_DEREF8(reg) *(__volatile__ char *)R128_ADDR(reg)
+#define R128_READ8(reg) R128_DEREF8(reg)
+#define R128_WRITE8(reg,val) do { R128_DEREF8(reg) = val; } while (0)
+
+#define R128_WRITE_PLL(addr,val) \
+do { \
+ R128_WRITE8(R128_CLOCK_CNTL_INDEX, ((addr) & 0x1f) | R128_PLL_WR_EN); \
+ R128_WRITE(R128_CLOCK_CNTL_DATA, (val)); \
+} while (0)
+
+extern int R128_READ_PLL(drm_device_t *dev, int addr);
+
+#define R128CCE0(p,r,n) ((p) | ((n) << 16) | ((r) >> 2))
+#define R128CCE1(p,r1,r2) ((p) | (((r2) >> 2) << 11) | ((r1) >> 2))
+#define R128CCE2(p) ((p))
+#define R128CCE3(p,n) ((p) | ((n) << 16))
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c
index 389f2faee..9c2cea56a 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c
@@ -1,8 +1,7 @@
/* vm.c -- Memory mapping for DRM -*- linux-c -*-
* Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com
- * Revised: Mon Feb 14 00:16:45 2000 by kevin@precisioninsight.com
*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -246,6 +245,18 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
/* Check for valid size. */
if (map->size != vma->vm_end - vma->vm_start) return -EINVAL;
+ if (!capable(CAP_SYS_ADMIN) && (map->flags & _DRM_READ_ONLY)) {
+ vma->vm_flags &= VM_MAYWRITE;
+#if defined(__i386__)
+ pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW;
+#else
+ /* Ye gads this is ugly. With more thought
+ we could move this up higher and use
+ `protection_map' instead. */
+ vma->vm_page_prot = __pgprot(pte_val(pte_wrprotect(
+ __pte(pgprot_val(vma->vm_page_prot)))));
+#endif
+ }
switch (map->type) {
case _DRM_FRAME_BUFFER:
@@ -265,6 +276,10 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
vma->vm_end - vma->vm_start,
vma->vm_page_prot))
return -EAGAIN;
+ DRM_DEBUG(" Type = %d; start = 0x%lx, end = 0x%lx,"
+ " offset = 0x%lx\n",
+ map->type,
+ vma->vm_start, vma->vm_end, VM_OFFSET(vma));
vma->vm_ops = &drm_vm_ops;
break;
case _DRM_SHM:
@@ -277,19 +292,7 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
return -EINVAL; /* This should never happen. */
}
vma->vm_flags |= VM_LOCKED | VM_SHM; /* Don't swap */
- if (map->flags & _DRM_READ_ONLY) {
-#if defined(__i386__)
- pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW;
-#else
- /* Ye gads this is ugly. With more thought
- we could move this up higher and use
- `protection_map' instead. */
- vma->vm_page_prot = __pgprot(pte_val(pte_wrprotect(
- __pte(pgprot_val(vma->vm_page_prot)))));
-#endif
- }
-
#if LINUX_VERSION_CODE < 0x020203 /* KERNEL_VERSION(2,2,3) */
/* In Linux 2.2.3 and above, this is
handled in do_mmap() in mm/mmap.c. */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c
index 3b66c19a8..2e3c9b431 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c
@@ -1,8 +1,7 @@
/* xf86drm.c -- User-level interface to DRM device
* Created: Tue Jan 5 08:16:21 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:43:32 2000 by kevin@precisioninsight.com
*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,6 +23,8 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
+ * Author: Rickard E. (Rik) Faith <faith@precisioninsight.com>
+ *
* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c,v 1.10 2000/02/23 04:47:23 martin Exp $
*
*/
@@ -143,7 +144,7 @@ static int drm_open(const char *file)
return -errno;
}
-/* drmAvailable looks for /proc/drm, and returns 1 if it is present. */
+/* drmAvailable looks for /proc/dri, and returns 1 if it is present. */
int drmAvailable(void)
{
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c
new file mode 100644
index 000000000..99f267f3d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c
@@ -0,0 +1,199 @@
+/* xf86drmR128.c -- User-level interface to Rage 128 DRM device
+ * Created: Sun Apr 9 18:13:54 2000 by kevin@precisioninsight.com
+ *
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ * $XFree86$
+ *
+ */
+
+#ifdef XFree86Server
+# include "xf86.h"
+# include "xf86_OSproc.h"
+# include "xf86_ansic.h"
+# include "xf86Priv.h"
+# define _DRM_MALLOC xalloc
+# define _DRM_FREE xfree
+# ifndef XFree86LOADER
+# include <sys/stat.h>
+# include <sys/mman.h>
+# endif
+#else
+# include <stdio.h>
+# include <stdlib.h>
+# include <unistd.h>
+# include <string.h>
+# include <ctype.h>
+# include <fcntl.h>
+# include <errno.h>
+# include <signal.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <sys/ioctl.h>
+# include <sys/mman.h>
+# include <sys/time.h>
+# ifdef DRM_USE_MALLOC
+# define _DRM_MALLOC malloc
+# define _DRM_FREE free
+extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
+extern int xf86RemoveSIGIOHandler(int fd);
+# else
+# include <Xlibint.h>
+# define _DRM_MALLOC Xmalloc
+# define _DRM_FREE Xfree
+# endif
+#endif
+
+/* Not all systems have MAP_FAILED defined */
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#include <sys/sysmacros.h> /* for makedev() */
+#include "xf86drm.h"
+#include "xf86drmR128.h"
+#include "drm.h"
+
+int drmR128InitCCE(int fd, drmR128Init *info)
+{
+ drm_r128_init_t init;
+
+ memset(&init, 0, sizeof(drm_r128_init_t));
+
+ init.func = R128_INIT_CCE;
+ init.sarea_priv_offset = info->sarea_priv_offset;
+ init.is_pci = info->is_pci;
+ init.cce_mode = info->cce_mode;
+ init.cce_fifo_size = info->cce_fifo_size;
+ init.cce_secure = info->cce_secure;
+ init.ring_size = info->ring_size;
+ init.usec_timeout = info->usec_timeout;
+
+ init.fb_offset = info->fb_offset;
+ init.agp_ring_offset = info->agp_ring_offset;
+ init.agp_read_ptr_offset = info->agp_read_ptr_offset;
+ init.agp_vertbufs_offset = info->agp_vertbufs_offset;
+ init.agp_indbufs_offset = info->agp_indbufs_offset;
+ init.agp_textures_offset = info->agp_textures_offset;
+ init.mmio_offset = info->mmio_offset;
+
+ if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno;
+
+ return 0;
+}
+
+int drmR128CleanupCCE(int fd)
+{
+ drm_r128_init_t init;
+
+ memset(&init, 0, sizeof(drm_r128_init_t));
+
+ init.func = R128_CLEANUP_CCE;
+
+ if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno;
+
+ return 0;
+}
+
+int drmR128EngineReset(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_R128_RESET, NULL)) return -errno;
+
+ return 0;
+}
+
+int drmR128EngineFlush(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_R128_FLUSH, NULL)) return -errno;
+
+ return 0;
+}
+
+int drmR128CCEWaitForIdle(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_R128_CCEIDL, NULL)) return -errno;
+
+ return 0;
+}
+
+int drmR128SubmitPackets(int fd, CARD32 *buffer, int *count, int flags)
+{
+ drm_r128_packet_t packet;
+ int ret;
+
+ memset(&packet, 0, sizeof(drm_r128_packet_t));
+
+ packet.count = *count;
+ packet.flags = flags;
+
+ while (packet.count > 0) {
+ packet.buffer = buffer + (*count - packet.count);
+ ret = ioctl(fd, DRM_IOCTL_R128_PACKET, &packet);
+ if (ret < 0 && ret != -EAGAIN) {
+ *count = packet.count;
+ return -errno;
+ }
+ }
+
+ *count = 0;
+ return 0;
+}
+
+int drmR128GetVertexBuffers(int fd, int count, int *indices, int *sizes)
+{
+ drm_r128_vertex_t v;
+
+ v.send_count = 0;
+ v.send_indices = NULL;
+ v.send_sizes = NULL;
+ v.prim = DRM_R128_PRIM_NONE;
+ v.request_count = count;
+ v.request_indices = indices;
+ v.request_sizes = sizes;
+ v.granted_count = 0;
+
+ if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v)) return -errno;
+
+ return v.granted_count;
+}
+
+int drmR128FlushVertexBuffers(int fd, int count, int *indices,
+ int *sizes, drmR128PrimType prim)
+{
+ drm_r128_vertex_t v;
+
+ v.send_count = count;
+ v.send_indices = indices;
+ v.send_sizes = sizes;
+ v.prim = prim;
+ v.request_count = 0;
+ v.request_indices = NULL;
+ v.request_sizes = NULL;
+ v.granted_count = 0;
+
+ if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v) < 0) return -errno;
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h
index ae4c65ca3..25e4cce49 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h
@@ -1,8 +1,7 @@
/* drm.h -- Header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
- * Revised: Mon Feb 14 00:15:23 2000 by kevin@precisioninsight.com
*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -71,9 +70,10 @@ typedef struct drm_clip_rect {
unsigned short y2;
} drm_clip_rect_t;
-/* Seperate include files for the i810/mga specific structures */
+/* Seperate include files for the i810/mga/r128 specific structures */
#include "mga_drm.h"
#include "i810_drm.h"
+#include "r128_drm.h"
typedef struct drm_version {
int version_major; /* Major version */
@@ -349,4 +349,12 @@ typedef struct drm_agp_info {
#define DRM_IOCTL_I810_FLUSH DRM_IO ( 0x43)
#define DRM_IOCTL_I810_GETAGE DRM_IO ( 0x44)
+/* Rage 128 specific ioctls */
+#define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t)
+#define DRM_IOCTL_R128_RESET DRM_IO( 0x41)
+#define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42)
+#define DRM_IOCTL_R128_CCEIDL DRM_IO( 0x43)
+#define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t)
+#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t)
+
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h
index 0fd1141b5..372ba595e 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h
@@ -1,8 +1,7 @@
/* xf86drm.h -- OS-independent header for DRM user-level library interface
* Created: Tue Jan 5 08:17:23 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:46:21 2000 by kevin@precisioninsight.com
*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,6 +23,8 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
+ * Author: Rickard E. (Rik) Faith <faith@precisioninsight.com>
+ *
* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h,v 1.7 2000/02/23 04:47:21 martin Exp $
*
*/
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h
new file mode 100644
index 000000000..46898a53c
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h
@@ -0,0 +1,80 @@
+/* xf86drm.h -- OS-independent header for DRM user-level library interface
+ * Created: Sun Apr 9 18:16:28 2000 by kevin@precisioninsight.com
+ *
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ * $XFree86$
+ *
+ */
+
+#ifndef _XF86DRI_R128_H_
+#define _XF86DRI_R128_H_
+
+/* WARNING: If you change any of these defines, make sure to change
+ * the kernel include file as well (r128_drm.h)
+ */
+
+typedef struct _drmR128Init {
+ int sarea_priv_offset;
+ int is_pci;
+ int cce_mode;
+ int cce_fifo_size;
+ int cce_secure;
+ int ring_size;
+ int usec_timeout;
+
+ int fb_offset;
+ int agp_ring_offset;
+ int agp_read_ptr_offset;
+ int agp_vertbufs_offset;
+ int agp_indbufs_offset;
+ int agp_textures_offset;
+ int mmio_offset;
+} drmR128Init;
+
+typedef enum {
+ DRM_R128_PRIM_NONE = 0x0001,
+ DRM_R128_PRIM_POINT = 0x0002,
+ DRM_R128_PRIM_LINE = 0x0004,
+ DRM_R128_PRIM_POLY_LINE = 0x0008,
+ DRM_R128_PRIM_TRI_LIST = 0x0010,
+ DRM_R128_PRIM_TRI_FAN = 0x0020,
+ DRM_R128_PRIM_TRI_STRIP = 0x0040,
+ DRM_R128_PRIM_TRI_TYPE2 = 0x0080
+} drmR128PrimType;
+
+
+extern int drmR128InitCCE(int fd, drmR128Init *info);
+extern int drmR128CleanupCCE(int fd);
+extern int drmR128EngineReset(int fd);
+extern int drmR128EngineFlush(int fd);
+extern int drmR128CCEWaitForIdle(int fd);
+extern int drmR128SubmitPackets(int fd, CARD32 *buffer, int *count, int flags);
+extern int drmR128GetVertexBuffers(int fd, int count, int *indices,
+ int *sizes);
+extern int drmR128FlushVertexBuffers(int fd, int count, int *indices,
+ int *sizes, drmR128PrimType prim);
+
+#endif