summaryrefslogtreecommitdiff
path: root/xc/lib
diff options
context:
space:
mode:
Diffstat (limited to 'xc/lib')
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/Imakefile4
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_clear.c19
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_context.h8
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_dd.c4
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_depth.c179
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_lock.h4
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_span.c114
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_state.c114
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_state.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tris.c158
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tris.h54
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h232
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_vb.c320
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_vb.h90
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c9
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/spantmp.h236
16 files changed, 1479 insertions, 68 deletions
diff --git a/xc/lib/GL/mesa/src/drv/r128/Imakefile b/xc/lib/GL/mesa/src/drv/r128/Imakefile
index 7611bb3dd..6ca57a376 100644
--- a/xc/lib/GL/mesa/src/drv/r128/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/r128/Imakefile
@@ -25,10 +25,10 @@ MESA_INCLUDES = -I. -I.. -I../../include
INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES)
DRISRCS = r128_xmesa.c r128_cce.c r128_dd.c r128_state.c \
r128_span.c r128_depth.c r128_tex.c r128_clear.c \
- r128_swap.c
+ r128_swap.c r128_tris.c r128_vb.c
DRIOBJS = r128_xmesa.o r128_cce.o r128_dd.o r128_state.o \
r128_span.o r128_depth.o r128_tex.o r128_clear.o \
- r128_swap.o
+ r128_swap.o r128_tris.o r128_vb.o
SRCS = $(DRISRCS)
OBJS = $(DRIOBJS)
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_clear.c b/xc/lib/GL/mesa/src/drv/r128/r128_clear.c
index 96ca60c81..19aaaebfe 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_clear.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_clear.c
@@ -138,7 +138,7 @@ void r128ClearColorBuffer(r128ContextPtr r128ctx, GLboolean all,
GLint x, GLint y, GLint width, GLint height)
{
unsigned char *R128MMIO = r128ctx->r128Screen->mmio;
- int dst_bpp, xoff, yoff;
+ int dst_bpp;
switch (r128ctx->r128Screen->bpp) {
case 8:
@@ -157,19 +157,6 @@ void r128ClearColorBuffer(r128ContextPtr r128ctx, GLboolean all,
break;
}
- switch (r128ctx->glCtx->Color.DriverDrawBuffer) {
- case GL_FRONT_LEFT:
- xoff = r128ctx->r128Screen->fbX;
- yoff = r128ctx->r128Screen->fbY;
- break;
- case GL_BACK_LEFT:
- xoff = r128ctx->r128Screen->backX;
- yoff = r128ctx->r128Screen->backY;
- break;
- default:
- return;
- }
-
/* FIXME: use x, y, width, height */
/* FIXME: use R128_GMC_DST_PITCH_OFFSET_CNTL to set to the back
buffer when we should be draing to the back buffer? */
@@ -192,8 +179,8 @@ void r128ClearColorBuffer(r128ContextPtr r128ctx, GLboolean all,
| R128_AUX_CLIP_DIS); /* FIXME?? */
R128CCE(r128ctx->ClearColor);
/* FIXME: when not using the back buf, make sure clears go to front buf */
- R128CCE(((r128ctx->driDrawable->x + xoff)<< 16)
- | (r128ctx->driDrawable->y + yoff));
+ R128CCE(((r128ctx->driDrawable->x + r128ctx->bufX)<< 16)
+ | (r128ctx->driDrawable->y + r128ctx->bufY));
R128CCE((r128ctx->driDrawable->w << 16) | r128ctx->driDrawable->h);
#if 0
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_context.h b/xc/lib/GL/mesa/src/drv/r128/r128_context.h
index 2a627e8cf..3127223ef 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_context.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.h
@@ -111,15 +111,21 @@ typedef struct {
int dirty;
int needClip;
+ int RenderIndex;
points_func PointsFunc;
line_func LineFunc;
triangle_func TriangleFunc;
quad_func QuadFunc;
+ CARD32 IndirectTriangles;
+ CARD32 Fallback;
+
+ r128ContextRegs regs;
CARD32 ClearColor;
CARD32 ClearDepth;
- r128ContextRegs regs;
+ int bufX;
+ int bufY;
Display *display;
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_dd.c b/xc/lib/GL/mesa/src/drv/r128/r128_dd.c
index 04850fd6c..04745d240 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_dd.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_dd.c
@@ -36,6 +36,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_mesa.h"
#include "r128_cce.h"
#include "r128_clear.h"
+#include "r128_vb.h"
#include "r128_dd.h"
static GLbitfield r128DDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
@@ -129,4 +130,7 @@ void r128DDInitDriverFuncs(GLcontext *ctx)
ctx->Driver.DrawPixels = NULL;
ctx->Driver.Bitmap = NULL;
+
+ ctx->Driver.RegisterVB = r128DDRegisterVB;
+ ctx->Driver.UnregisterVB = r128DDUnregisterVB;
}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_depth.c b/xc/lib/GL/mesa/src/drv/r128/r128_depth.c
index c61eaadca..0c4076058 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_depth.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_depth.c
@@ -34,37 +34,206 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#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_depth.h"
+/* FIXME: only handles 16bpp depth buffer for now */
+
+#define DEPTH_DECLS \
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx); \
+ r128ScreenPtr r128scrn = r128ctx->r128Screen; \
+ int xoff = (r128ctx->driDrawable->x + \
+ r128scrn->depthX); \
+ int yoff = (r128ctx->driDrawable->y + \
+ r128scrn->depthY); \
+ int height = r128ctx->driDrawable->h; \
+ unsigned char *zbase = (r128scrn->fb + \
+ xoff * (r128scrn->bpp/8) + \
+ yoff * r128scrn->fbStride); \
+ volatile GLdepth *zptr; \
+ int i
+
+#define DEPTH_ADDR(base, _x, _y) \
+ (GLdepth*)(zbase + _x * (r128scrn->bpp/8) + \
+ (height - _y) * r128scrn->fbStride)
+
+#define DEPTH_TEST_SPAN(_op_) \
+ if (ctx->Depth.Mask) { /* Update Z buffer */ \
+ for (i = 0; i < n; i++, zptr++, m++) { \
+ if (*m) { \
+ if (z[i] _op_ *zptr) { /* pass */ \
+ *zptr = z[i]; \
+ passed++; \
+ } else { /* fail */ \
+ *m = 0; \
+ } \
+ } \
+ } \
+ } else { /* Don't update Z buffer */ \
+ for (i = 0; i < n; i++, zptr++, m++) { \
+ if (*m) { \
+ if (z[i] _op_ *zptr) { /* pass */ \
+ passed++; \
+ } else { /* fail */ \
+ *m = 0; \
+ } \
+ } \
+ } \
+ }
+
+#define DEPTH_TEST_PIXELS(_op_) \
+ if (ctx->Depth.Mask) { /* Update Z buffer */ \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ zptr = DEPTH_ADDR(zbase, x[i], y[i]); \
+ if (z[i] _op_ *zptr) *zptr = z[i]; \
+ else mask[i] = 0; \
+ } \
+ } \
+ } else { /* Don't update Z buffer */ \
+ for (i = 0; i < n; i++, zptr++, m++) { \
+ if (mask[i]) { \
+ zptr = DEPTH_ADDR(zbase, x[i], y[i]); \
+ if (z[i] _op_ *zptr) ; \
+ else mask[i] = 0; \
+ } \
+ } \
+ }
+
static void r128DDAllocDepthBuffer(GLcontext *ctx)
{
}
static GLuint r128DDDepthTestSpan(GLcontext *ctx,
- GLuint n,
- GLint x, GLint y, const GLdepth z[],
+ GLuint n, GLint x, GLint y,
+ const GLdepth z[],
GLubyte mask[])
{
- return 1;
+ DEPTH_DECLS;
+ GLubyte *m = mask;
+ int passed = 0;
+
+ zptr = DEPTH_ADDR(zbase, x, y);
+
+ LOCK_HARDWARE(r128ctx);
+ R128WaitForIdle(r128scrn);
+
+ switch (ctx->Depth.Func) {
+ case GL_LESS: DEPTH_TEST_SPAN(<) break;
+ case GL_LEQUAL: DEPTH_TEST_SPAN(<=) break;
+ case GL_GEQUAL: DEPTH_TEST_SPAN(>=) break;
+ case GL_GREATER: DEPTH_TEST_SPAN(>) break;
+ case GL_NOTEQUAL: DEPTH_TEST_SPAN(!=) break;
+ case GL_EQUAL: DEPTH_TEST_SPAN(==) break;
+ case GL_ALWAYS:
+ if (ctx->Depth.Mask) { /* Update Z buffer */
+ for (i = 0; i < n; i++, zptr++, m++) {
+ if (*m) {
+ *zptr = z[i];
+ passed++;
+ }
+ }
+ } else { /* Don't update Z buffer or mask */
+ passed = n;
+ }
+ break;
+ case GL_NEVER:
+ for (i = 0; i < n; i++) mask[i] = 0;
+ break;
+ default:
+ break;
+ }
+
+ UNLOCK_HARDWARE(r128ctx);
+
+ return passed;
}
static void r128DDDepthTestPixels(GLcontext *ctx,
GLuint n,
- const GLint x[], const GLint y[],
- const GLdepth z[], GLubyte mask[])
+ const GLint x[],
+ const GLint y[],
+ const GLdepth z[],
+ GLubyte mask[])
{
+ DEPTH_DECLS;
+ GLubyte *m = mask;
+
+ LOCK_HARDWARE(r128ctx);
+ R128WaitForIdle(r128scrn);
+
+ switch (ctx->Depth.Func) {
+ case GL_LESS: DEPTH_TEST_PIXELS(<); break;
+ case GL_LEQUAL: DEPTH_TEST_PIXELS(<=); break;
+ case GL_GEQUAL: DEPTH_TEST_PIXELS(>=); break;
+ case GL_GREATER: DEPTH_TEST_PIXELS(>); break;
+ case GL_NOTEQUAL: DEPTH_TEST_PIXELS(!=); break;
+ case GL_EQUAL: DEPTH_TEST_PIXELS(==); break;
+ case GL_ALWAYS:
+ if (ctx->Depth.Mask) { /* Update Z buffer */
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ zptr = DEPTH_ADDR(zbase, x[i], y[i]);
+ *zptr = z[i];
+ }
+ }
+ } else { /* Don't update Z buffer or mask */
+ }
+ break;
+ case GL_NEVER:
+ for (i = 0; i < n; i++) mask[i] = 0;
+ break;
+ default:
+ break;
+ }
+
+ UNLOCK_HARDWARE(r128ctx);
}
static void r128DDReadDepthSpanFloat(GLcontext *ctx,
GLuint n,
GLint x, GLint y, GLfloat depth[])
{
+ DEPTH_DECLS;
+ GLfloat scale = 1.0f / DEPTH_SCALE;
+
+ zptr = DEPTH_ADDR(zbase, x, y);
+
+ LOCK_HARDWARE(r128ctx);
+ R128WaitForIdle(r128scrn);
+
+ if (ctx->Buffer->Depth) {
+ for (i = 0; i < n; i++) depth[i] = (GLfloat)zptr[i] * scale;
+ } else {
+ for (i = 0; i < n; i++) depth[i] = 0.0f;
+ }
+
+ UNLOCK_HARDWARE(r128ctx);
}
static void r128DDReadDepthSpanInt(GLcontext *ctx,
GLuint n,
GLint x, GLint y, GLdepth depth[])
{
+ DEPTH_DECLS;
+
+ zptr = DEPTH_ADDR(zbase, x, y);
+
+ LOCK_HARDWARE(r128ctx);
+ R128WaitForIdle(r128scrn);
+
+ if (ctx->Buffer->Depth) {
+ MEMCPY(depth, zptr, n*sizeof(*depth));
+ } else {
+ for (i = 0; i < n; i++) depth[i] = 0;
+ }
+
+ UNLOCK_HARDWARE(r128ctx);
}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_lock.h b/xc/lib/GL/mesa/src/drv/r128/r128_lock.h
index 893bb4d78..2d80b0bbe 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_lock.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_lock.h
@@ -117,12 +117,12 @@ extern int prevLockLine;
#define BEGIN_CLIP_LOOP(CC) \
do { \
__DRIdrawablePrivate *dPriv = CC->driDrawable; \
- int _nc = dPriv->numClipRects; \
+ int _nc = dPriv->numClipRects; \
\
LOCK_HARDWARE(CC); \
while (_nc--) { \
if (CC->needClip) { \
- r128SetClipRects(&dPriv->pClipRects[_nc]); \
+ r128SetClipRect(CC, &dPriv->pClipRects[_nc]); \
}
#define END_CLIP_LOOP(CC) \
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_span.c b/xc/lib/GL/mesa/src/drv/r128/r128_span.c
index 3653fc2f6..f6452b1b5 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_span.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_span.c
@@ -34,6 +34,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#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"
static void r128DDWriteRGBASpan(const GLcontext *ctx,
@@ -89,32 +95,98 @@ static void r128DDReadRGBAPixels(const GLcontext *ctx,
{
}
+/* 16bpp span routines */
+
+#define DBG 0
+
+#define HW_LOCK() \
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx); \
+ r128ScreenPtr r128scrn = r128ctx->r128Screen; \
+ LOCK_HARDWARE(r128ctx); \
+ R128WaitForIdle(r128scrn);
+
+#define LOCAL_VARS \
+ __DRIdrawablePrivate *dPriv = r128ctx->driDrawable; \
+ GLuint pitch = r128scrn->fbStride; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(r128scrn->fb + \
+ (r128ctx->bufX + dPriv->x) * (r128scrn->bpp/8) + \
+ (r128ctx->bufY + dPriv->y) * pitch)
+
+#define INIT_MONO_PIXEL(p) \
+ GLushort p = R128_CONTEXT(ctx)->regs.constant_color_c;
+
+#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); \
+ }
+
+#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);
+
+
+/* For 16 bit depth visuals */
+#define Y_FLIP(_y) (height - _y)
+#define WRITE_RGBA(_x, _y, r, g, b, a) \
+ *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = ((((int)r & 0xf8) << 8) | \
+ (((int)g & 0xfc) << 3) | \
+ (((int)b & 0xf8) >> 3))
+#define WRITE_PIXEL(_x, _y, p) \
+ *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = p
+
+#define READ_RGBA(rgba, _x, _y) \
+ do { \
+ GLushort p = *(GLushort *)(buf + (_x)*2 + (_y)*pitch); \
+ rgba[0] = (p >> 8) & 0xf8; \
+ rgba[1] = (p >> 3) & 0xfc; \
+ rgba[2] = (p << 3) & 0xf8; \
+ rgba[3] = 255; /* or 0? */ \
+ } while(0)
+
+#define TAG(x) r128DD##x##565
+#include "spantmp.h"
+
+
void r128DDInitSpanFuncs(GLcontext *ctx)
{
r128ContextPtr r128ctx = R128_CONTEXT(ctx);
switch (r128ctx->r128Screen->depth) {
case 8: /* Color Index mode not supported */
- ctx->Driver.WriteCI32Span = NULL;
- ctx->Driver.WriteCI8Span = NULL;
- ctx->Driver.WriteMonoCISpan = NULL;
- ctx->Driver.WriteCI32Pixels = NULL;
- ctx->Driver.WriteMonoCIPixels = NULL;
- ctx->Driver.ReadCI32Span = NULL;
- ctx->Driver.ReadCI32Pixels = NULL;
break;
- case 15: /* FIXME? */
case 16:
- ctx->Driver.WriteRGBASpan = r128DDWriteRGBASpan;
- ctx->Driver.WriteRGBSpan = r128DDWriteRGBSpan;
- ctx->Driver.WriteMonoRGBASpan = r128DDWriteMonoRGBASpan;
- ctx->Driver.WriteRGBAPixels = r128DDWriteRGBAPixels;
- ctx->Driver.WriteMonoRGBAPixels = r128DDWriteMonoRGBAPixels;
- ctx->Driver.ReadRGBASpan = r128DDReadRGBASpan;
- ctx->Driver.ReadRGBAPixels = r128DDReadRGBAPixels;
+ ctx->Driver.WriteRGBASpan = r128DDWriteRGBASpan565;
+ ctx->Driver.WriteRGBSpan = r128DDWriteRGBSpan565;
+ ctx->Driver.WriteMonoRGBASpan = r128DDWriteMonoRGBASpan565;
+ ctx->Driver.WriteRGBAPixels = r128DDWriteRGBAPixels565;
+ ctx->Driver.WriteMonoRGBAPixels = r128DDWriteMonoRGBAPixels565;
+ ctx->Driver.ReadRGBASpan = r128DDReadRGBASpan565;
+ ctx->Driver.ReadRGBAPixels = r128DDReadRGBAPixels565;
break;
- case 24: /* FIXME? */
- case 32:
+ case 15: /* FIXME */
+ case 24: /* FIXME */
+ case 32: /* FIXME */
ctx->Driver.WriteRGBASpan = r128DDWriteRGBASpan;
ctx->Driver.WriteRGBSpan = r128DDWriteRGBSpan;
ctx->Driver.WriteMonoRGBASpan = r128DDWriteMonoRGBASpan;
@@ -124,4 +196,12 @@ void r128DDInitSpanFuncs(GLcontext *ctx)
ctx->Driver.ReadRGBAPixels = r128DDReadRGBAPixels;
break;
}
+
+ ctx->Driver.WriteCI32Span = NULL;
+ ctx->Driver.WriteCI8Span = NULL;
+ ctx->Driver.WriteMonoCISpan = NULL;
+ ctx->Driver.WriteCI32Pixels = NULL;
+ ctx->Driver.WriteMonoCIPixels = NULL;
+ ctx->Driver.ReadCI32Span = NULL;
+ ctx->Driver.ReadCI32Pixels = NULL;
}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_state.c b/xc/lib/GL/mesa/src/drv/r128/r128_state.c
index ec6f46929..8517960f9 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_state.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_state.c
@@ -40,8 +40,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_state.h"
#include "r128_reg.h"
#include "r128_cce.h"
+#include "r128_tris.h"
+#include "r128_vb.h"
-#if 1
+#if 0
/* FIXME: FOR TESTING A SIMPLE DRAWING FUNCTION */
static void pfunc(GLcontext *ctx, GLuint first, GLuint last) {}
static void lfunc(GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv) {}
@@ -103,15 +105,33 @@ static void r128DDUpdateState(GLcontext *ctx)
ctx->Driver.QuadFunc = qfunc;
}
#else
+
+#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);
- ctx->Driver.PointsFunc = r128ctx->PointsFunc;
- ctx->Driver.LineFunc = r128ctx->LineFunc;
- ctx->Driver.TriangleFunc = r128ctx->TriangleFunc;
- ctx->Driver.QuadFunc = r128ctx->QuadFunc;
- ctx->Driver.RectFunc = NULL;
+ 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;
+ }
}
#endif
@@ -140,10 +160,17 @@ static void r128DDColor(GLcontext *ctx,
{
r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+#if 1
+ r128ctx->regs.constant_color_c = (((r >> 3) << 11) |
+ ((g >> 2) << 5) |
+ ((b >> 3) << 0) |
+ ((a >> 8) << 16));
+#else
r128ctx->regs.constant_color_c = (((r >> 0) << 16) |
((g >> 0) << 8) |
((b >> 0) << 0) |
((a >> 0) << 24));
+#endif
}
static GLboolean r128DDSetBuffer(GLcontext *ctx, GLenum mode )
@@ -155,19 +182,32 @@ static GLboolean r128DDSetBuffer(GLcontext *ctx, GLenum mode )
switch (mode) {
case GL_FRONT_LEFT:
- x += r128ctx->r128Screen->fbX;
- y += r128ctx->r128Screen->fbY;
+ r128ctx->bufX = r128ctx->r128Screen->fbX;
+ r128ctx->bufY = r128ctx->r128Screen->fbY;
found = GL_TRUE;
break;
case GL_BACK_LEFT:
- x += r128ctx->r128Screen->backX;
- y += r128ctx->r128Screen->backY;
+ r128ctx->bufX = r128ctx->r128Screen->backX;
+ r128ctx->bufY = r128ctx->r128Screen->backY;
found = GL_TRUE;
break;
}
+ x += r128ctx->bufX;
+ y += r128ctx->bufY;
+
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->bufX) *
+ (r128ctx->r128Screen->bpp/8) +
+ (r128ctx->r128Screen->depthY -
+ r128ctx->bufY) *
+ r128ctx->r128Screen->fbStride);
return found;
}
@@ -438,7 +478,7 @@ static void r128DDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
}
break;
-#if 0
+#if 1
case GL_DEPTH_TEST:
if (state) t |= R128_Z_ENABLE;
else t &= ~R128_Z_ENABLE;
@@ -618,6 +658,26 @@ void r128DDInitState(r128ContextPtr r128ctx)
break;
}
+ r128ctx->dirty = R128_CLEAN;
+ r128ctx->needClip = GL_FALSE;
+
+ r128ctx->RenderIndex = 0;
+ r128ctx->PointsFunc = NULL;
+ r128ctx->LineFunc = NULL;
+ r128ctx->TriangleFunc = NULL;
+ r128ctx->QuadFunc = NULL;
+
+ r128ctx->IndirectTriangles = 0;
+ r128ctx->Fallback = 0;
+
+ if (r128ctx->glCtx->Visual->DBflag) {
+ r128ctx->bufX = r128ctx->r128Screen->backX;
+ r128ctx->bufY = r128ctx->r128Screen->backY;
+ } else {
+ r128ctx->bufX = r128ctx->r128Screen->fbX;
+ r128ctx->bufY = r128ctx->r128Screen->fbY;
+ }
+
r128ctx->ClearColor = 0x00000000;
r128ctx->ClearDepth = 0x0000ffff; /* FIXME: init to requested depth */
@@ -654,7 +714,8 @@ void r128DDInitState(r128ContextPtr r128ctx)
r128ctx->regs.sc_top_left_c = 0x00000000;
r128ctx->regs.sc_bottom_right_c = 0x1fff1fff;
- r128ctx->regs.z_offset_c = (r128ctx->r128Screen->depthX +
+ r128ctx->regs.z_offset_c = (r128ctx->r128Screen->depthX *
+ (r128ctx->r128Screen->bpp/8) +
r128ctx->r128Screen->depthY *
r128ctx->r128Screen->fbStride);
r128ctx->regs.z_pitch_c = pitch;
@@ -874,24 +935,27 @@ static void r128LoadContext(r128ContextPtr r128ctx)
}
/* This is only called when we have the lock */
-static void r128LoadCliprects(r128ContextPtr r128ctx)
+void r128SetClipRect(r128ContextPtr r128ctx, XF86DRIClipRectPtr pc)
{
- int x = r128ctx->driDrawable->x;
- int y = r128ctx->driDrawable->y;
+}
- switch (r128ctx->glCtx->Color.DriverDrawBuffer) {
- case GL_FRONT_LEFT:
- x += r128ctx->r128Screen->fbX;
- y += r128ctx->r128Screen->fbY;
- break;
- case GL_BACK_LEFT:
- x += r128ctx->r128Screen->backX;
- y += r128ctx->r128Screen->backY;
- break;
- }
+static void r128LoadCliprects(r128ContextPtr r128ctx)
+{
+ int x = r128ctx->driDrawable->x + r128ctx->bufX;
+ int y = r128ctx->driDrawable->y + r128ctx->bufY;
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->bufX) *
+ (r128ctx->r128Screen->bpp/8) +
+ (r128ctx->r128Screen->depthY -
+ r128ctx->bufY) *
+ r128ctx->r128Screen->fbStride);
}
void r128UpdateState(r128ContextPtr r128ctx)
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_state.h b/xc/lib/GL/mesa/src/drv/r128/r128_state.h
index 925c791dc..f604f6ca8 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_state.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_state.h
@@ -43,5 +43,7 @@ extern void r128DDInitStateFuncs(GLcontext *ctx);
extern void r128UpdateState(r128ContextPtr r128ctx);
extern void r128UpdateStateLocked(r128ContextPtr r128ctx);
+extern void r128SetClipRect(r128ContextPtr r128ctx, XF86DRIClipRectPtr pc);
+
#endif
#endif /* _R128_STATE_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..58e2b5980
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.c
@@ -0,0 +1,158 @@
+/* $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 */
+
+static void r128DrawTriangle(r128ContextPtr r128ctx,
+ r128_vertex *v0,
+ r128_vertex *v1,
+ r128_vertex *v2)
+{
+}
+
+static void r128DrawLine(r128ContextPtr r128ctx,
+ r128_vertex *tmp0, r128_vertex *tmp1,
+ float width)
+{
+}
+
+static void r128DrawPoint(r128ContextPtr r128ctx,
+ r128_vertex *tmp, float sz)
+{
+}
+
+#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"
+
+void r128TriangleFuncsInit(void)
+{
+ init();
+ init_flat();
+}
+
+void r128ChooseRenderState(GLcontext *ctx)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ GLuint flags = ctx->TriangleCaps;
+
+ r128ctx->IndirectTriangles = 0;
+
+ if (flags) {
+ CARD32 index = 0;
+ CARD32 shared = 0;
+ CARD32 fallback = R128_FALLBACK_BIT;
+
+#if 0
+ shared = fallback; /* Make everything a fallback */
+#endif
+
+#if 0
+ fallback = 0; /* Turn off all fallbacks */
+#endif
+
+ 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;
+
+ index = shared;
+#if 1
+ if (flags & DD_POINT_SMOOTH) index |= fallback;
+#else
+ if (flags & DD_POINT_SMOOTH) index |= R128_ANTIALIAS_BIT;
+#endif
+ 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;
+
+ index = shared;
+#if 1
+ if (flags & DD_LINE_SMOOTH) index |= fallback;
+#else
+ if (flags & DD_LINE_SMOOTH) index |= R128_ANTIALIAS_BIT;
+#endif
+ 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;
+
+ index = shared;
+#if 1
+ if (flags & DD_TRI_SMOOTH) index |= fallback;
+#else
+ if (flags & DD_TRI_SMOOTH) index |= R128_ANTIALIAS_BIT;
+#endif
+ 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..ba98eb3e7
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.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:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_TRIS_H_
+#define _R128_TRIS_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+#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 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..ff0804c4e
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h
@@ -0,0 +1,232 @@
+/* $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
+
+static void TAG(triangle)(GLcontext *ctx,
+ GLuint e0, GLuint e1, GLuint e2,
+ GLuint pv)
+{
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+ unsigned char *R128MMIO = r128ctx->r128Screen->mmio;
+ 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 = ctx->Polygon.OffsetUnits * 1.0/0x10000;
+#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_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
+
+ BEGIN_CLIP_LOOP(r128ctx);
+
+ R128CCE_BEGIN_LOCKED(15);
+ 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_END_LOCKED();
+
+ END_CLIP_LOOP(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)
+
+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;
+ }
+
+ BEGIN_CLIP_LOOP(r128ctx);
+
+ r128DrawLine(r128ctx, &tmp0, &tmp1, width);
+
+ END_CLIP_LOOP(r128ctx);
+}
+
+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 sz = ctx->Point.Size * 0.5;
+ int i;
+
+ /* Culling is disabled automatically via. the
+ * ctx->Driver.ReducedPrimitiveChange() callback.
+ */
+
+ BEGIN_CLIP_LOOP(r128ctx);
+
+ for(i = first; i <= last; i++) {
+ if(VB->ClipMask[i] == 0) {
+ r128_vertex *tmp = &r128verts[i].v;
+ r128DrawPoint(r128ctx, tmp, sz);
+ }
+ }
+
+ END_CLIP_LOOP(r128ctx);
+}
+
+#endif
+
+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..e3062a603
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c
@@ -0,0 +1,320 @@
+/* $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_vb.h"
+
+#include "stages.h"
+
+#define TEX0 \
+do { \
+ v->v.tu1 = tc0[i][0]; \
+ v->v.tv1 = tc0[i][1]; \
+} while (0)
+
+#define TEX1 \
+do { \
+ v->v.tu2 = tc1[i][0]; \
+ v->v.tv2 = 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)
+
+#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.tu1 *= oow; \
+ v->v.tv1 *= oow; \
+ } \
+ } \
+ 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.tu2 *= oow; \
+ v->v.tv2 *= oow; \
+ } \
+ } \
+} while (0)
+
+#define COORD \
+do { \
+ GLfloat *win = VB->Win.data[i]; \
+ v->v.x = win[0]; \
+ v->v.y = r128height - win[1]; \
+ v->v.z = (1.0/0x10000) * win[2]; \
+ v->v.rhw = v->v.rhw2 = win[3]; \
+} while (0)
+
+#define NOP
+
+#define SETUPFUNC(name,win,col,tex0,tex1,tex0_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; \
+ int i; \
+ \
+ (void) r128height; (void) r128ctx; \
+ \
+ gl_import_client_data(VB, VB->ctx->RenderFlags, \
+ (VB->ClipOrMask \
+ ? VEC_WRITABLE | VEC_GOOD_STRIDE \
+ : VEC_GOOD_STRIDE)); \
+ \
+ 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; \
+}
+
+
+SETUPFUNC(rs_wt0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, NOP)
+SETUPFUNC(rs_wt0t1, COORD, NOP, TEX0, TEX1, TEX0_4, NOP, NOP)
+SETUPFUNC(rs_wft0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, FOG)
+SETUPFUNC(rs_wft0t1, COORD, NOP, TEX0, TEX1, TEX0_4, NOP, FOG)
+SETUPFUNC(rs_wg, COORD, COL, NOP, NOP, NOP, NOP, NOP)
+SETUPFUNC(rs_wgs, COORD, COL, NOP, NOP, NOP, SPC, NOP)
+SETUPFUNC(rs_wgt0, COORD, COL, TEX0, NOP, TEX0_4, NOP, NOP)
+SETUPFUNC(rs_wgt0t1, COORD, COL, TEX0, TEX1, TEX0_4, NOP, NOP)
+SETUPFUNC(rs_wgst0, COORD, COL, TEX0, NOP, TEX0_4, SPC, NOP)
+SETUPFUNC(rs_wgst0t1, COORD, COL, TEX0, TEX1, TEX0_4, SPC, NOP)
+SETUPFUNC(rs_wgf, COORD, COL, NOP, NOP, NOP, NOP, FOG)
+SETUPFUNC(rs_wgfs, COORD, COL, NOP, NOP, NOP, SPC, FOG)
+SETUPFUNC(rs_wgft0, COORD, COL, TEX0, NOP, TEX0_4, NOP, FOG)
+SETUPFUNC(rs_wgft0t1, COORD, COL, TEX0, TEX1, TEX0_4, NOP, FOG)
+SETUPFUNC(rs_wgfst0, COORD, COL, TEX0, NOP, TEX0_4, SPC, FOG)
+SETUPFUNC(rs_wgfst0t1, COORD, COL, TEX0, TEX1, TEX0_4, SPC, FOG)
+
+SETUPFUNC(rs_t0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, NOP)
+SETUPFUNC(rs_t0t1, NOP, NOP, TEX0, TEX1, TEX0_4, NOP, NOP)
+SETUPFUNC(rs_f, NOP, NOP, NOP, NOP, NOP, NOP, FOG)
+SETUPFUNC(rs_ft0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, FOG)
+SETUPFUNC(rs_ft0t1, NOP, NOP, TEX0, TEX1, TEX0_4, NOP, FOG)
+SETUPFUNC(rs_g, NOP, COL, NOP, NOP, NOP, NOP, NOP)
+SETUPFUNC(rs_gs, NOP, COL, NOP, NOP, NOP, SPC, NOP)
+SETUPFUNC(rs_gt0, NOP, COL, TEX0, NOP, TEX0_4, NOP, NOP)
+SETUPFUNC(rs_gt0t1, NOP, COL, TEX0, TEX1, TEX0_4, NOP, NOP)
+SETUPFUNC(rs_gst0, NOP, COL, TEX0, NOP, TEX0_4, SPC, NOP)
+SETUPFUNC(rs_gst0t1, NOP, COL, TEX0, TEX1, TEX0_4, SPC, NOP)
+SETUPFUNC(rs_gf, NOP, COL, NOP, NOP, NOP, NOP, FOG)
+SETUPFUNC(rs_gfs, NOP, COL, NOP, NOP, NOP, SPC, FOG)
+SETUPFUNC(rs_gft0, NOP, COL, TEX0, NOP, TEX0_4, NOP, FOG)
+SETUPFUNC(rs_gft0t1, NOP, COL, TEX0, TEX1, TEX0_4, NOP, FOG)
+SETUPFUNC(rs_gfst0, NOP, COL, TEX0, NOP, TEX0_4, SPC, FOG)
+SETUPFUNC(rs_gfst0t1, NOP, COL, TEX0, TEX1, TEX0_4, SPC, FOG)
+
+static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end)
+{
+ R128_DEBUG(("r128RasterSetup(): invalid setup function\n"));
+}
+
+typedef void (*setupFunc)(struct vertex_buffer *, GLuint, GLuint);
+static setupFunc setup_func[0x80];
+
+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_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_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_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_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_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_TEX0_BIT|R128_TEX1_BIT] = rs_wgfst0t1;
+
+ /* Funcs to repair vertices */
+ setup_func[R128_TEX0_BIT] = rs_t0;
+ 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_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_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_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_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_TEX0_BIT|R128_TEX1_BIT] = rs_gfst0t1;
+}
+
+void r128ChooseRasterSetupFunc(GLcontext *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;
+
+ if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+ funcindex |= R128_SPEC_BIT;
+
+ if (ctx->FogMode == FOG_FRAGMENT)
+ funcindex |= R128_FOG_BIT;
+
+ ctx->Driver.RasterSetup = setup_func[funcindex];
+}
+
+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);
+ }
+
+ r128vb->primitive = (GLuint *)malloc(sizeof(GLuint) * r128vb->size);
+ r128vb->next_primitive = (GLuint *)malloc(sizeof(GLuint) * r128vb->size);
+ if (!r128vb->primitive || !r128vb->next_primitive) {
+ fprintf(stderr, "Cannot allocate primitive list! Exiting...\n");
+ exit(1);
+ }
+
+ VB->driver_data = r128vb;
+}
+
+void r128DDUnregisterVB(struct vertex_buffer *VB)
+{
+ r128VertexBufferPtr r128vb = R128_DRIVER_DATA(VB);
+
+ if (r128vb) {
+ if (r128vb->vert_store) free(r128vb->vert_store);
+ if (r128vb->primitive) free(r128vb->primitive);
+ if (r128vb->next_primitive) free(r128vb->next_primitive);
+ 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..96a560411
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.h
@@ -0,0 +1,90 @@
+/* $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
+
+typedef struct {
+ GLubyte b;
+ GLubyte g;
+ GLubyte r;
+ GLubyte a;
+} r128Color;
+
+typedef struct {
+ GLfloat x, y, z;
+ GLfloat rhw;
+ r128Color dif_argb;
+ r128Color spec_frgb;
+ GLfloat tu1;
+ GLfloat tv1;
+ GLfloat tu2;
+ GLfloat tv2;
+ GLfloat rhw2;
+} r128_vertex;
+
+typedef union {
+ r128_vertex v;
+ float f[16];
+} r128Vertex, *r128VertexPtr;
+
+typedef struct {
+ GLvector1ui clipped_elements;
+ r128VertexPtr verts;
+ int last_vert;
+ GLuint *primitive;
+ GLuint *next_primitive;
+ void *vert_store;
+ GLuint size;
+} *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 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
index 6db5af3fa..c0d1697c6 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c
@@ -48,6 +48,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_depth.h"
#include "r128_tex.h"
#include "r128_swap.h"
+#include "r128_tris.h"
+#include "r128_vb.h"
/* Mesa src includes */
#include "context.h"
@@ -151,6 +153,9 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
sPriv->private = (void *)r128Screen;
+ r128TriangleFuncsInit();
+ r128SetupInit();
+
return GL_TRUE;
}
@@ -280,12 +285,16 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list,
r128DDInitDepthFuncs(glCtx);
r128DDInitTextureFuncs(glCtx);
+#if 1
/* FIXME: Move to r128_tris.c */
glCtx->Driver.TriangleCaps = (DD_TRI_CULL
| DD_TRI_LIGHT_TWOSIDE
| DD_TRI_OFFSET);
glCtx->TriangleCaps |= DD_CLIP_FOG_COORD;
+ if (glCtx->VB) r128DDRegisterVB(glCtx->VB);
+#endif
+
r128DDInitState(r128ctx);
return c;
diff --git a/xc/lib/GL/mesa/src/drv/r128/spantmp.h b/xc/lib/GL/mesa/src/drv/r128/spantmp.h
new file mode 100644
index 000000000..6a1b15c88
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/spantmp.h
@@ -0,0 +1,236 @@
+#ifndef DBG
+#define DBG 0
+#endif
+
+static void TAG(WriteRGBASpan)( const GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ const GLubyte rgba[][4],
+ const GLubyte mask[] )
+{
+ HW_LOCK()
+ {
+ GLint x1;
+ GLint n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ if (DBG) fprintf(stderr, "WriteRGBASpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1);
+
+ if (mask)
+ {
+ for (;i<n1;i++,x1++)
+ if (mask[i])
+ WRITE_RGBA( x1, y,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ else
+ {
+ for (;i<n1;i++,x1++)
+ WRITE_RGBA( x1, y,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_UNLOCK();
+}
+
+static void TAG(WriteRGBSpan)( const GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ const GLubyte rgb[][3],
+ const GLubyte mask[] )
+{
+ HW_LOCK()
+ {
+ GLint x1;
+ GLint n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ if (DBG) fprintf(stderr, "WriteRGBSpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1);
+
+ if (mask)
+ {
+ for (;i<n1;i++,x1++)
+ if (mask[i])
+ WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 0 );
+ }
+ else
+ {
+ for (;i<n1;i++,x1++)
+ WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 0 );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_UNLOCK();
+}
+
+static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
+ GLuint n,
+ const GLint x[],
+ const GLint y[],
+ const GLubyte rgba[][4],
+ const GLubyte mask[] )
+{
+ HW_LOCK()
+ {
+ GLint i;
+ LOCAL_VARS;
+
+ if (DBG) fprintf(stderr, "WriteRGBAPixels\n");
+
+ HW_CLIPLOOP()
+ {
+ for (i=0;i<n;i++)
+ {
+ if (mask[i]) {
+ const int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL(x[i],fy))
+ WRITE_RGBA( x[i], fy,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_UNLOCK();
+}
+
+
+static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ const GLubyte mask[] )
+{
+ HW_LOCK()
+ {
+ GLint x1;
+ GLint n1;
+ LOCAL_VARS;
+ INIT_MONO_PIXEL(p);
+
+ y = Y_FLIP( y );
+
+ if (DBG) fprintf(stderr, "WriteMonoRGBASpan\n");
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+ for (;i<n1;i++,x1++)
+ if (mask[i])
+ WRITE_PIXEL( x1, y, p );
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_UNLOCK();
+}
+
+
+static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const GLubyte mask[] )
+{
+ HW_LOCK()
+ {
+ GLint i;
+ LOCAL_VARS;
+ INIT_MONO_PIXEL(p);
+
+ if (DBG) fprintf(stderr, "WriteMonoRGBAPixels\n");
+
+ HW_CLIPLOOP()
+ {
+ for (i=0;i<n;i++)
+ if (mask[i]) {
+ int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL( x[i], fy ))
+ WRITE_PIXEL( x[i], fy, p );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_UNLOCK();
+}
+
+
+
+/*
+ * Read a horizontal span of color pixels.
+ */
+static void TAG(ReadRGBASpan)( const GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ GLubyte rgba[][4])
+{
+ HW_LOCK()
+ {
+ GLint x1,n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+ if (DBG) fprintf(stderr, "ReadRGBASpan\n");
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+ for (;i<n1;i++)
+ READ_RGBA( rgba[i], x1+i, y );
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_UNLOCK();
+}
+
+static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4], const GLubyte mask[] )
+{
+ HW_LOCK()
+ {
+ GLint i;
+ LOCAL_VARS;
+
+ if (DBG) fprintf(stderr, "ReadRGBAPixels\n");
+
+ HW_CLIPLOOP()
+ {
+ for (i=0;i<n;i++)
+ if (mask[i]) {
+ int fy = Y_FLIP( y[i] );
+ if (CLIPPIXEL( x[i], fy ))
+ READ_RGBA( rgba[i], x[i], fy );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_UNLOCK();
+}
+
+
+
+
+#undef WRITE_PIXEL
+#undef WRITE_RGBA
+#undef READ_RGBA
+#undef TAG