summaryrefslogtreecommitdiff
path: root/xc
diff options
context:
space:
mode:
authordaryll <daryll>2000-06-12 02:33:11 +0000
committerdaryll <daryll>2000-06-12 02:33:11 +0000
commitc19b18f45c57ac421f36322223a5ac31bce6697c (patch)
tree71d23521e445ff36447ed625bb737b8673da6993 /xc
parent7ce0b968362f2e947dae21ea5dfb9bd9cc4c2b0f (diff)
Merged the tdfx-2-0 branch onto the trunktdfx-2-0-20000612-merge
Diffstat (limited to 'xc')
-rw-r--r--xc/extras/Mesa/src/FX/fxapi.c4
-rw-r--r--xc/extras/Mesa/src/FX/fxdd.c496
-rw-r--r--xc/extras/Mesa/src/FX/fxddspan.c1664
-rw-r--r--xc/extras/Mesa/src/FX/fxddtex.c287
-rw-r--r--xc/extras/Mesa/src/FX/fxdrv.h39
-rw-r--r--xc/extras/Mesa/src/FX/fxglidew.c15
-rw-r--r--xc/extras/Mesa/src/FX/fxglidew.h97
-rw-r--r--xc/extras/Mesa/src/FX/fxsetup.c322
-rw-r--r--xc/extras/Mesa/src/FX/fxtexman.c8
-rw-r--r--xc/extras/Mesa/src/FX/fxtritmp.h13
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c36
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c6
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c13
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c2
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c250
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c121
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile13
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h42
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.man30
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c59
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c265
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c254
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c52
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c45
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c768
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h181
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c2
27 files changed, 3901 insertions, 1183 deletions
diff --git a/xc/extras/Mesa/src/FX/fxapi.c b/xc/extras/Mesa/src/FX/fxapi.c
index da2b905fa..6d680bcb9 100644
--- a/xc/extras/Mesa/src/FX/fxapi.c
+++ b/xc/extras/Mesa/src/FX/fxapi.c
@@ -940,10 +940,8 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
else
fxMesa->haveTwoTMUs=GL_FALSE;
- fxMesa->haveDoubleBuffer=doubleBuffer;
fxMesa->haveAlphaBuffer=alphaBuffer;
fxMesa->haveGlobalPaletteTexture=GL_FALSE;
- fxMesa->haveZBuffer=depthSize ? 1 : 0;
fxMesa->verbose=verbose;
fxMesa->board=glbCurrentBoard;
@@ -1297,7 +1295,7 @@ void GLAPIENTRY fxMesaSwapBuffers(void)
if(fxMesaCurrentCtx) {
FLUSH_VB( fxMesaCurrentCtx->glCtx, "swap buffers" );
- if(fxMesaCurrentCtx->haveDoubleBuffer) {
+ if (fxMesaCurrentCtx->glVis->DBflag) {
grBufferSwap(fxMesaCurrentCtx->swapInterval);
diff --git a/xc/extras/Mesa/src/FX/fxdd.c b/xc/extras/Mesa/src/FX/fxdd.c
index 2705d6bc1..59a4bec93 100644
--- a/xc/extras/Mesa/src/FX/fxdd.c
+++ b/xc/extras/Mesa/src/FX/fxdd.c
@@ -52,6 +52,7 @@
#if defined(FX)
+#include <dlfcn.h>
#include "image.h"
#include "types.h"
#include "fxdrv.h"
@@ -102,34 +103,20 @@ void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder)
/***** Miscellaneous functions *****/
/**********************************************************************/
-/* Enalbe/Disable dithering */
-static void fxDDDither(GLcontext *ctx, GLboolean enable)
-{
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDDither()\n");
- }
-
- if (enable) {
- FX_grDitherMode(GR_DITHER_4x4);
- } else {
- FX_grDitherMode(GR_DITHER_DISABLE);
- }
-}
-
/* Return buffer size information */
static void fxDDBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDBufferSize(...) Start\n");
}
- *width=fxMesa->width;
- *height=fxMesa->height;
+ *width = fxMesa->width;
+ *height = fxMesa->height;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDBufferSize(...) End\n");
}
}
@@ -139,15 +126,13 @@ static void fxDDBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
static void fxDDSetColor(GLcontext *ctx, GLubyte red, GLubyte green,
GLubyte blue, GLubyte alpha )
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
GLubyte col[4];
ASSIGN_4V( col, red, green, blue, alpha );
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDSetColor(%d,%d,%d,%d)\n",red,green,blue,alpha);
}
-
- fxMesa->color=FXCOLOR4(col);
+ fxMesa->color = FXCOLOR4(col);
}
@@ -155,19 +140,14 @@ static void fxDDSetColor(GLcontext *ctx, GLubyte red, GLubyte green,
static void fxDDClearColor(GLcontext *ctx, GLubyte red, GLubyte green,
GLubyte blue, GLubyte alpha )
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
GLubyte col[4];
-
-
-
ASSIGN_4V( col, red, green, blue, 255 );
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDClearColor(%d,%d,%d,%d)\n",red,green,blue,alpha);
}
-
- fxMesa->clearC=FXCOLOR4( col );
- fxMesa->clearA=alpha;
+ fxMesa->clearC = FXCOLOR4( col );
+ fxMesa->clearA = alpha;
}
@@ -177,11 +157,18 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
- const FxU16 clearD = (FxU16) (ctx->Depth.Clear * 0xffff);
- GLbitfield softwareMask = mask & (DD_STENCIL_BIT | DD_ACCUM_BIT);
+ const FxU32 clearD = (FxU32) (ctx->Depth.Clear * fxMesa->depthClear);
+ const FxU32 clearS = (FxU32) (ctx->Stencil.Clear);
+ GLbitfield softwareMask = mask & (DD_ACCUM_BIT);
- /* we can't clear stencil or accum buffers */
- mask &= ~(DD_STENCIL_BIT | DD_ACCUM_BIT);
+ /* we can't clear accum buffers */
+ mask &= ~(DD_ACCUM_BIT);
+
+ if ((mask & DD_STENCIL_BIT) && !fxMesa->haveHwStencil) {
+ /* software stencil buffer */
+ mask &= ~(DD_STENCIL_BIT);
+ softwareMask |= DD_STENCIL_BIT;
+ }
if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDClear(%d,%d,%d,%d)\n", (int) x, (int) y,
@@ -194,16 +181,35 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
}
+
+ /* disable stencil ops if enabled (it screws up clearing) */
+ if (ctx->Stencil.Enabled)
+ FX_grDisable(GR_STENCIL_MODE_EXT);
+
+ if (fxMesa->haveHwStencil) {
+ if (mask & DD_STENCIL_BIT) {
+ FX_grStencilMask(0xff);
+ /* set stencil ref value = desired clear value */
+ FX_grStencilFunc(GR_CMP_ALWAYS, ctx->Stencil.Clear, 0xff);
+ }
+ else {
+ FX_grStencilMask(0x00);
+ }
+ }
+
/*
* This could probably be done fancier but doing each possible case
* explicitly is less error prone.
*/
- switch (mask) {
+ switch (mask & ~DD_STENCIL_BIT) {
case DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
/* back buffer & depth */
FX_grDepthMask(FXTRUE);
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
+ if (mask & DD_STENCIL_BIT)
+ FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
+ else
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
if (!ctx->Depth.Mask) {
FX_grDepthMask(FXFALSE);
}
@@ -217,17 +223,26 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
FX_grDepthMask(FXTRUE);
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
FX_grColorMask(FXFALSE,FXFALSE);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
+ if (mask & DD_STENCIL_BIT)
+ FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
+ else
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
/* clear front */
FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
+ if (mask & DD_STENCIL_BIT)
+ FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
+ else
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
break;
case DD_BACK_LEFT_BIT:
/* back buffer only */
FX_grDepthMask(FXFALSE);
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
+ if (mask & DD_STENCIL_BIT)
+ FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
+ else
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
if (ctx->Depth.Mask) {
FX_grDepthMask(FXTRUE);
}
@@ -236,7 +251,10 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
/* front buffer only */
FX_grDepthMask(FXFALSE);
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
+ if (mask & DD_STENCIL_BIT)
+ FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
+ else
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
if (ctx->Depth.Mask) {
FX_grDepthMask(FXTRUE);
}
@@ -245,9 +263,15 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
/* front and back */
FX_grDepthMask(FXFALSE);
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
+ if (mask & DD_STENCIL_BIT)
+ FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
+ else
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
+ if (mask & DD_STENCIL_BIT)
+ FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
+ else
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
if (ctx->Depth.Mask) {
FX_grDepthMask(FXTRUE);
}
@@ -256,11 +280,17 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
/* clear front */
FX_grDepthMask(FXFALSE);
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
+ if (mask & DD_STENCIL_BIT)
+ FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
+ else
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
/* clear back and depth */
FX_grDepthMask(FXTRUE);
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
+ if (mask & DD_STENCIL_BIT)
+ FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
+ else
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
if (!ctx->Depth.Mask) {
FX_grDepthMask(FXFALSE);
}
@@ -270,7 +300,10 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
FX_grColorMask(FXFALSE,FXFALSE);
FX_grDepthMask(FXTRUE);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
+ if (mask & DD_STENCIL_BIT)
+ FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
+ else
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT)
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
@@ -280,6 +313,14 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
;
}
+ if (ctx->Stencil.Enabled) {
+ /* restore stencil state to as it was before the clear */
+ FX_grEnable(GR_STENCIL_MODE_EXT);
+ FX_grStencilMask(ctx->Stencil.WriteMask);
+ FX_grStencilFunc(ctx->Stencil.Function - GL_NEVER,
+ ctx->Stencil.Ref, ctx->Stencil.ValueMask);
+ }
+
return softwareMask;
}
@@ -337,6 +378,58 @@ static void fxDDSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer,
}
+/*
+ * These functions just set new-state flags. The exact state
+ * values will be evaluated later.
+ */
+static void
+fxDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref, GLuint mask)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ (void) func; (void) ref; (void) mask;
+ fxMesa->new_state |= FX_NEW_STENCIL;
+ ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+static void
+fxDDStencilMask(GLcontext *ctx, GLuint mask)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ (void) mask;
+ fxMesa->new_state |= FX_NEW_STENCIL;
+ ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+static void
+fxDDStencilOp(GLcontext *ctx, GLenum sfail, GLenum zfail, GLenum zpass)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ (void) sfail; (void) zfail; (void) zpass;
+ fxMesa->new_state |= FX_NEW_STENCIL;
+ ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+static void
+fxDDDepthFunc(GLcontext *ctx, GLenum func)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ (void) func;
+ fxMesa->new_state |= FX_NEW_DEPTH;
+ ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+static void
+fxDDDepthMask(GLcontext *ctx, GLboolean mask)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ (void) mask;
+ fxMesa->new_state |= FX_NEW_DEPTH;
+ ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+
+
+
#ifdef XF86DRI
/* test if window coord (px,py) is visible */
static GLboolean inClipRects(fxMesaContext fxMesa, int px, int py)
@@ -353,10 +446,12 @@ static GLboolean inClipRects(fxMesaContext fxMesa, int px, int py)
#endif
-static GLboolean fxDDDrawBitmap(GLcontext *ctx, GLint px, GLint py,
- GLsizei width, GLsizei height,
- const struct gl_pixelstore_attrib *unpack,
- const GLubyte *bitmap)
+
+static GLboolean
+bitmap_R5G6B5(GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap)
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GrLfbInfo_t info;
@@ -527,11 +622,186 @@ static GLboolean fxDDDrawBitmap(GLcontext *ctx, GLint px, GLint py,
}
-static GLboolean fxDDReadPixels( GLcontext *ctx, GLint x, GLint y,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const struct gl_pixelstore_attrib *packing,
- GLvoid *dstImage )
+static GLboolean
+bitmap_R8G8B8A8(GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap)
+{
+ fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ GrLfbInfo_t info;
+ GrLfbWriteMode_t mode;
+ /*FxU16 color;*/
+ GLuint color;
+ const struct gl_pixelstore_attrib *finalUnpack;
+ struct gl_pixelstore_attrib scissoredUnpack;
+
+ /* check if there's any raster operations enabled which we can't handle */
+ if (ctx->RasterMask & (ALPHATEST_BIT |
+ BLEND_BIT |
+ DEPTH_BIT |
+ FOG_BIT |
+ LOGIC_OP_BIT |
+ SCISSOR_BIT |
+ STENCIL_BIT |
+ MASKING_BIT |
+ ALPHABUF_BIT |
+ MULTI_DRAW_BIT))
+ return GL_FALSE;
+
+ if (ctx->Scissor.Enabled) {
+ /* This is a bit tricky, but by carefully adjusting the px, py,
+ * width, height, skipPixels and skipRows values we can do
+ * scissoring without special code in the rendering loop.
+ */
+
+ /* we'll construct a new pixelstore struct */
+ finalUnpack = &scissoredUnpack;
+ scissoredUnpack = *unpack;
+ if (scissoredUnpack.RowLength == 0)
+ scissoredUnpack.RowLength = width;
+
+ /* clip left */
+ if (px < ctx->Scissor.X) {
+ scissoredUnpack.SkipPixels += (ctx->Scissor.X - px);
+ width -= (ctx->Scissor.X - px);
+ px = ctx->Scissor.X;
+ }
+ /* clip right */
+ if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) {
+ width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width));
+ }
+ /* clip bottom */
+ if (py < ctx->Scissor.Y) {
+ scissoredUnpack.SkipRows += (ctx->Scissor.Y - py);
+ height -= (ctx->Scissor.Y - py);
+ py = ctx->Scissor.Y;
+ }
+ /* clip top */
+ if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) {
+ height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height));
+ }
+
+ if (width <= 0 || height <= 0)
+ return GL_TRUE; /* totally scissored away */
+ }
+ else {
+ finalUnpack = unpack;
+ }
+
+ /* compute pixel value */
+ {
+ GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0f);
+ GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0f);
+ GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0f);
+ GLint a = (GLint) (ctx->Current.RasterColor[3] * 255.0f);
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+ color = PACK_BGRA32(r, g, b, a);
+ else
+ color = PACK_RGBA32(r, g, b, a);
+ }
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+ mode = GR_LFBWRITEMODE_8888;
+ else
+ mode = GR_LFBWRITEMODE_888;
+
+ info.size = sizeof(info);
+ if (!FX_grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ mode,
+ GR_ORIGIN_UPPER_LEFT,
+ FXFALSE,
+ &info)) {
+#ifndef FX_SILENT
+ fprintf(stderr,"fx Driver: error locking the linear frame buffer\n");
+#endif
+ return GL_TRUE;
+ }
+
+#ifdef XF86DRI
+#define INSIDE(c, x, y) inClipRects((c), (x), (y))
+#else
+#define INSIDE(c, x, y) (1)
+#endif
+
+ {
+ const GLint winX = fxMesa->x_offset;
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ GLint dstStride;
+ GLuint *dst;
+ GLint row;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+ dstStride = fxMesa->screen_width;
+ dst = (GLuint *) info.lfbPtr + (winY - py) * dstStride + (winX + px);
+ }
+ else {
+ dstStride = info.strideInBytes / 4;
+ dst = (GLuint *) info.lfbPtr + (winY - py) * dstStride + (winX + px);
+ }
+
+ /* compute dest address of bottom-left pixel in bitmap */
+ for (row = 0; row < height; row++) {
+ const GLubyte *src = (const GLubyte *) _mesa_image_address( finalUnpack,
+ bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
+ if (finalUnpack->LsbFirst) {
+ /* least significan bit first */
+ GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
+ GLint col;
+ for (col=0; col<width; col++) {
+ if (*src & mask) {
+ if (INSIDE(fxMesa, winX + px + col, winY - py - row))
+ dst[col] = color;
+ }
+ if (mask == 128U) {
+ src++;
+ mask = 1U;
+ }
+ else {
+ mask = mask << 1;
+ }
+ }
+ if (mask != 1)
+ src++;
+ }
+ else {
+ /* most significan bit first */
+ GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7);
+ GLint col;
+ for (col=0; col<width; col++) {
+ if (*src & mask) {
+ if (INSIDE(fxMesa, winX + px + col, winY - py - row))
+ dst[col] = color;
+ }
+ if (mask == 1U) {
+ src++;
+ mask = 128U;
+ }
+ else {
+ mask = mask >> 1;
+ }
+ }
+ if (mask != 128)
+ src++;
+ }
+ dst -= dstStride;
+ }
+ }
+
+#undef INSIDE
+
+ FX_grLfbUnlock(GR_LFB_WRITE_ONLY,fxMesa->currentFB);
+ return GL_TRUE;
+}
+
+
+static GLboolean
+readpixels_R5G6B5( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ GLvoid *dstImage )
{
if (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag) {
return GL_FALSE; /* can't do this */
@@ -542,6 +812,7 @@ static GLboolean fxDDReadPixels( GLcontext *ctx, GLint x, GLint y,
GLboolean result = GL_FALSE;
BEGIN_BOARD_LOCK();
+ info.size=sizeof(info);
if (grLfbLock(GR_LFB_READ_ONLY,
fxMesa->currentFB,
GR_LFBWRITEMODE_ANY,
@@ -700,7 +971,7 @@ static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name)
}
}
/* now make the GL_RENDERER string */
- sprintf(buffer, "Mesa DRI %s 20000510", hardware);
+ sprintf(buffer, "Mesa DRI %s 20000608", hardware);
return buffer;
}
case GL_VENDOR:
@@ -757,6 +1028,19 @@ static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name)
int fxDDInitFxMesaContext( fxMesaContext fxMesa )
{
+ /* Get Glide3vn function pointers */
+ {
+ void *handle;
+ handle = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);
+ if (!handle)
+ return 0;
+ grStencilFuncPtr = dlsym(handle, "grStencilFunc");
+ grStencilMaskPtr = dlsym(handle, "grStencilMask");
+ grStencilOpPtr = dlsym(handle, "grStencilOp");
+ grBufferClearExtPtr = dlsym(handle, "grBufferClearExt");
+ /* call dlclose()? */
+ }
+
FX_setupGrVertexLayout();
@@ -783,6 +1067,8 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa )
else
fxMesa->verbose=GL_FALSE;
+ fxMesa->depthClear = FX_grGetInteger(FX_ZDEPTH_MAX);
+
fxMesa->color=0xffffffff;
fxMesa->clearC=0;
fxMesa->clearA=0;
@@ -793,7 +1079,6 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa )
fxMesa->stats.memTexUpload=0;
fxMesa->tmuSrc=FX_TMU_NONE;
- fxMesa->lastUnitsMode=FX_UM_NONE;
fxTMInit(fxMesa);
/* FX units setup */
@@ -808,16 +1093,19 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa )
fxMesa->unitsState.blendSrcFuncAlpha=GR_BLEND_ONE;
fxMesa->unitsState.blendDstFuncAlpha=GR_BLEND_ZERO;
+ /*
fxMesa->unitsState.depthTestEnabled =GL_FALSE;
fxMesa->unitsState.depthMask =GL_TRUE;
fxMesa->unitsState.depthTestFunc =GR_CMP_LESS;
+ */
FX_grColorMask(FXTRUE, fxMesa->haveAlphaBuffer ? FXTRUE : FXFALSE);
- if(fxMesa->haveDoubleBuffer) {
- fxMesa->currentFB=GR_BUFFER_BACKBUFFER;
+ if (fxMesa->glVis->DBflag) {
+ fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- } else {
- fxMesa->currentFB=GR_BUFFER_FRONTBUFFER;
+ }
+ else {
+ fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
}
@@ -833,7 +1121,7 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa )
return 0;
}
- if(fxMesa->haveZBuffer)
+ if (fxMesa->glVis->DepthBits > 0)
FX_grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
#if (!FXMESA_USE_ARGB)
@@ -846,7 +1134,7 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa )
fxMesa->glCtx->Const.MaxTextureUnits=fxMesa->emulateTwoTMUs ? 2 : 1;
fxMesa->glCtx->NewState|=NEW_DRVSTATE1;
fxMesa->new_state = NEW_ALL;
-
+
fxDDSetupInit();
fxDDCvaInit();
fxDDClipInit();
@@ -876,6 +1164,10 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa )
fxMesa->glCtx->PipelineStage,
fxMesa->glCtx->NrPipelineStages);
+ /* this little bit ensures that all Glide state gets initialized */
+ fxMesa->new_state = NEW_ALL;
+ fxMesa->glCtx->Driver.RenderStart = fxSetupFXUnits;
+
/* Run the config file */
gl_context_initialize( fxMesa->glCtx );
@@ -946,8 +1238,7 @@ static GLboolean fxIsInHardware(GLcontext *ctx)
if (!ctx->Hint.AllowDrawMem)
return GL_TRUE; /* you'll take it and like it */
- if((ctx->RasterMask & (STENCIL_BIT | MULTI_DRAW_BIT)) ||
- ((ctx->Color.BlendEnabled) && (ctx->Color.BlendEquation!=GL_FUNC_ADD_EXT)) ||
+ if(((ctx->Color.BlendEnabled) && (ctx->Color.BlendEquation!=GL_FUNC_ADD_EXT)) ||
((ctx->Color.ColorLogicOpEnabled) && (ctx->Color.LogicOp!=GL_COPY)) ||
(ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) ||
(!((ctx->Color.ColorMask[RCOMP]==ctx->Color.ColorMask[GCOMP]) &&
@@ -1031,6 +1322,9 @@ static GLboolean fxIsInHardware(GLcontext *ctx)
}
}
+ if (ctx->Stencil.Enabled && !fxMesa->haveHwStencil)
+ return GL_FALSE;
+
return GL_TRUE;
}
@@ -1082,44 +1376,47 @@ static void fxDDReducedPrimitiveChange(GLcontext *ctx, GLenum prim)
}
}
+
void fxSetupDDPointers(GLcontext *ctx)
{
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxSetupDDPointers()\n");
- }
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
- ctx->Driver.UpdateState=fxDDUpdateDDPointers;
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxSetupDDPointers()\n");
+ }
+ ctx->Driver.UpdateState = fxDDUpdateDDPointers;
+ ctx->Driver.ClearIndex = NULL;
+ ctx->Driver.ClearColor = fxDDClearColor;
+ ctx->Driver.Clear = fxDDClear;
+ ctx->Driver.Index = NULL;
+ ctx->Driver.Color = fxDDSetColor;
+ ctx->Driver.SetDrawBuffer = fxDDSetDrawBuffer;
+ ctx->Driver.SetReadBuffer = fxDDSetReadBuffer;
+ ctx->Driver.GetBufferSize = fxDDBufferSize;
+ ctx->Driver.Finish = fxDDFinish;
+ ctx->Driver.Flush = NULL;
+ ctx->Driver.GetString = fxDDGetString;
+ ctx->Driver.NearFar = fxDDSetNearFar;
+ ctx->Driver.GetParameteri = fxDDGetParameteri;
ctx->Driver.WriteDepthSpan=fxDDWriteDepthSpan;
ctx->Driver.WriteDepthPixels=fxDDWriteDepthPixels;
ctx->Driver.ReadDepthSpan=fxDDReadDepthSpan;
ctx->Driver.ReadDepthPixels=fxDDReadDepthPixels;
- ctx->Driver.GetString=fxDDGetString;
-
- ctx->Driver.Dither=fxDDDither;
-
- ctx->Driver.NearFar=fxDDSetNearFar;
-
- ctx->Driver.GetParameteri=fxDDGetParameteri;
-
- ctx->Driver.ClearIndex=NULL;
- ctx->Driver.ClearColor=fxDDClearColor;
- ctx->Driver.Clear=fxDDClear;
-
- ctx->Driver.Index=NULL;
- ctx->Driver.Color=fxDDSetColor;
-
- ctx->Driver.SetDrawBuffer=fxDDSetDrawBuffer;
- ctx->Driver.SetReadBuffer=fxDDSetReadBuffer;
- ctx->Driver.GetBufferSize=fxDDBufferSize;
-
- ctx->Driver.Bitmap=fxDDDrawBitmap;
- ctx->Driver.DrawPixels=NULL;
- ctx->Driver.ReadPixels=fxDDReadPixels;
-
- ctx->Driver.Finish=fxDDFinish;
- ctx->Driver.Flush=NULL;
+ if (ctx->Visual->RedBits == 8 &&
+ ctx->Visual->GreenBits == 8 &&
+ ctx->Visual->BlueBits == 8 &&
+ ctx->Visual->AlphaBits == 8) {
+ ctx->Driver.Bitmap = bitmap_R8G8B8A8;
+ ctx->Driver.DrawPixels = NULL;
+ ctx->Driver.ReadPixels = NULL;
+ }
+ else {
+ ctx->Driver.Bitmap = bitmap_R5G6B5;
+ ctx->Driver.DrawPixels = NULL;
+ ctx->Driver.ReadPixels = readpixels_R5G6B5;
+ }
ctx->Driver.RenderStart=NULL;
ctx->Driver.RenderFinish=NULL;
@@ -1135,6 +1432,12 @@ void fxSetupDDPointers(GLcontext *ctx)
ctx->Driver.RectFunc=NULL;
+ if (fxMesa->haveHwStencil) {
+ ctx->Driver.StencilFunc = fxDDStencilFunc;
+ ctx->Driver.StencilMask = fxDDStencilMask;
+ ctx->Driver.StencilOp = fxDDStencilOp;
+ }
+
ctx->Driver.AlphaFunc=fxDDAlphaFunc;
ctx->Driver.BlendFunc=fxDDBlendFunc;
ctx->Driver.DepthFunc=fxDDDepthFunc;
@@ -1171,6 +1474,7 @@ void fxSetupDDPointers(GLcontext *ctx)
}
+
#else
diff --git a/xc/extras/Mesa/src/FX/fxddspan.c b/xc/extras/Mesa/src/FX/fxddspan.c
index c620cc3c6..2c53da8d3 100644
--- a/xc/extras/Mesa/src/FX/fxddspan.c
+++ b/xc/extras/Mesa/src/FX/fxddspan.c
@@ -46,33 +46,193 @@
/* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
+#include "fxdrv.h"
-#if defined(FX)
-#include "fxdrv.h"
-#ifdef _MSC_VER
-#ifdef _WIN32
-#pragma warning( disable : 4090 4022 )
-/* 4101 : "different 'const' qualifier"
- * 4022 : "pointer mistmatch for actual parameter 'n'
+/*
+ * Examine the cliprects to generate an array of flags to indicate
+ * which pixels in a span are visible. Note: (x,y) is a screen
+ * coordinate.
*/
-#endif
-#endif
+static void
+generate_vismask(const fxMesaContext fxMesa, GLint x, GLint y, GLint n,
+ GLubyte vismask[])
+{
+ GLboolean initialized = GL_FALSE;
+ GLint i, j;
+
+ /* turn on flags for all visible pixels */
+ for (i = 0; i < fxMesa->numClipRects; i++) {
+ const XF86DRIClipRectPtr rect = &fxMesa->pClipRects[i];
+
+ if (y >= rect->y1 && y < rect->y2) {
+ if (x >= rect->x1 && x + n <= rect->x2) {
+ /* common case, whole span inside cliprect */
+ MEMSET(vismask, 1, n);
+ return;
+ }
+ if (x < rect->x2 && x + n >= rect->x1) {
+ /* some of the span is inside the rect */
+ GLint start, end;
+ if (!initialized) {
+ MEMSET(vismask, 0, n);
+ initialized = GL_TRUE;
+ }
+ if (x < rect->x1)
+ start = rect->x1 - x;
+ else
+ start = 0;
+ if (x + n > rect->x2)
+ end = rect->x2 - x;
+ else
+ end = n;
+ assert(start >= 0);
+ assert(end <= n);
+ for (j = start; j < end; j++)
+ vismask[j] = 1;
+ }
+ }
+ }
+}
-#if !defined(FXMESA_USE_ARGB)
+/*
+ * Examine cliprects and determine if the given screen pixel is visible.
+ */
+static GLboolean
+visible_pixel(const fxMesaContext fxMesa, int scrX, int scrY)
+{
+ int i;
+ for (i = 0; i < fxMesa->numClipRects; i++) {
+ const XF86DRIClipRectPtr rect = &fxMesa->pClipRects[i];
+ if (scrX >= rect->x1 &&
+ scrX < rect->x2 &&
+ scrY >= rect->y1 &&
+ scrY < rect->y2)
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
-#if defined(FX_GLIDE3) && defined(XF86DRI)
+
+typedef enum { FBS_READ, FBS_WRITE } FBS_DIRECTION;
+/*
+ * Read or write a single span from the frame buffer.
+ * Input Parameters:
+ * fxMesa: The context
+ * target_buffer: Which buffer to read from.
+ * xpos, ypos: Starting Coordinates.
+ * xlength: Length of the span.
+ * data_size: Size of data elements: 1, 2, or 4.
+ * buffer: Pointer to the buffer to read
+ * to or write from. This needs
+ * to be turned into a pointer.
+ * direction: Read or Write.
+ */
+static void
+rw_fb_span(fxMesaContext fxMesa,
+ GrBuffer_t target_buffer,
+ FxU32 xpos,
+ FxU32 ypos,
+ FxU32 xlength,
+ FxU32 data_size,
+ void *buffer,
+ FBS_DIRECTION direction)
+{
+ GrLfbInfo_t info;
+ BEGIN_BOARD_LOCK();
+ info.size=sizeof(info);
+
+ if (grLfbLock(direction == FBS_READ ? GR_LFB_READ_ONLY : GR_LFB_WRITE_ONLY,
+ target_buffer,
+ GR_LFBWRITEMODE_ANY,
+ GR_ORIGIN_UPPER_LEFT,
+ FXFALSE,
+ &info)) {
+ const GLint winX = fxMesa->x_offset;
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+#ifdef XF86DRI
+ /* stride in data elements */
+ const GLint srcStride =
+ (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+ ? (fxMesa->screen_width)
+ : (info.strideInBytes / data_size);
+#else
+ /* stride in data elements */
+ const GLint srcStride = info.strideInBytes / data_size;
+#endif
+ GLushort *data16 = (GLushort *) info.lfbPtr
+ + (winY - ypos) * srcStride
+ + (winX + xpos);
+ GLubyte *target16 = (GLubyte *) buffer;
+ GLubyte *data8 = (GLubyte *) data16;
+ GLubyte *target8 = (GLubyte *) buffer;
+ GLuint *data32 = (GLuint *) data16;
+ GLuint *target32 = (GLuint *) buffer;
+ GLuint i, j;
+
+ for (i = j = 0; i < xlength; i += 1, j += 1) {
+ switch (data_size) {
+ case 1:
+ switch (direction) {
+ case FBS_READ:
+ *target8++ = *data8++;
+ break;
+ case FBS_WRITE:
+ *data8++ = *target8++;
+ break;
+ }
+ break;
+ case 2:
+ switch (direction) {
+ case FBS_READ:
+ *target16++ = *data16++;
+ break;
+ case FBS_WRITE:
+ *data16++ = *target16++;
+ break;
+ }
+ break;
+ case 4:
+ switch (direction) {
+ case FBS_READ:
+ *target32++ = *data32++;
+ break;
+ case FBS_WRITE:
+ *data32++ = *target32++;
+ break;
+ }
+ break;
+ }
+ }
+ grLfbUnlock(direction == FBS_READ ? GR_LFB_READ_ONLY : GR_LFB_WRITE_ONLY,
+ target_buffer);
+ }
+ END_BOARD_LOCK();
+}
+
+static FxBool
+fb_point_is_clipped(fxMesaContext fxMesa,
+ FxU32 dst_x, FxU32 dst_y)
+{
+ int i;
+ for (i=0; i<fxMesa->numClipRects; i++) {
+ if ((dst_x>=fxMesa->pClipRects[i].x1) &&
+ (dst_x<fxMesa->pClipRects[i].x2) &&
+ (dst_y>=fxMesa->pClipRects[i].y1) &&
+ (dst_y<fxMesa->pClipRects[i].y2)) {
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
- FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format,
- FxU32 src_width, FxU32 src_height, FxI32 src_stride,
- void *src_data)
+ FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format,
+ FxU32 src_width, FxU32 src_height, FxI32 src_stride,
+ void *src_data)
{
int i, x, w, srcElt;
void *data;
@@ -80,12 +240,12 @@ static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
if (src_width==1 && src_height==1) { /* Easy case writing a point */
for (i=0; i<fxMesa->numClipRects; i++) {
if ((dst_x>=fxMesa->pClipRects[i].x1) &&
- (dst_x<fxMesa->pClipRects[i].x2) &&
- (dst_y>=fxMesa->pClipRects[i].y1) &&
- (dst_y<fxMesa->pClipRects[i].y2)) {
- FX_grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format,
- 1, 1, src_stride, src_data);
- return GL_TRUE;
+ (dst_x<fxMesa->pClipRects[i].x2) &&
+ (dst_y>=fxMesa->pClipRects[i].y1) &&
+ (dst_y<fxMesa->pClipRects[i].y2)) {
+ FX_grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format,
+ 1, 1, src_stride, src_data);
+ return GL_TRUE;
}
}
} else if (src_height==1) { /* Writing a span */
@@ -97,20 +257,20 @@ static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
}
for (i=0; i<fxMesa->numClipRects; i++) {
if (dst_y>=fxMesa->pClipRects[i].y1 && dst_y<fxMesa->pClipRects[i].y2) {
- if (dst_x<fxMesa->pClipRects[i].x1) {
- x=fxMesa->pClipRects[i].x1;
- data=((char*)src_data)+srcElt*(x - dst_x);
- w=src_width-(x-dst_x);
- } else {
- x=dst_x;
- data=src_data;
- w=src_width;
- }
- if (x+w>fxMesa->pClipRects[i].x2) {
- w=fxMesa->pClipRects[i].x2-x;
- }
- FX_grLfbWriteRegion(dst_buffer, x, dst_y, src_format, w, 1,
- src_stride, data);
+ if (dst_x<fxMesa->pClipRects[i].x1) {
+ x=fxMesa->pClipRects[i].x1;
+ data=((char*)src_data)+srcElt*(x - dst_x);
+ w=src_width-(x-dst_x);
+ } else {
+ x=dst_x;
+ data=src_data;
+ w=src_width;
+ }
+ if (x+w>fxMesa->pClipRects[i].x2) {
+ w=fxMesa->pClipRects[i].x2-x;
+ }
+ FX_grLfbWriteRegion(dst_buffer, x, dst_y, src_format, w, 1,
+ src_stride, data);
}
}
} else { /* Punt on the case of arbitrary rectangles */
@@ -119,88 +279,42 @@ static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
return GL_TRUE;
}
-#else
-
-#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
- FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
-
-#endif
/* KW: Rearranged the args in the call to grLfbWriteRegion().
*/
-#define LFB_WRITE_SPAN_MESA(dst_buffer, \
- dst_x, \
- dst_y, \
- src_width, \
- src_stride, \
- src_data) \
- writeRegionClipped(fxMesa, dst_buffer, \
- dst_x, \
- dst_y, \
- GR_LFB_SRC_FMT_8888, \
- src_width, \
- 1, \
- src_stride, \
- src_data) \
-
-
-#else /* !defined(FXMESA_USE_RGBA) */
-
-#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
- FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
-
-
-#define MESACOLOR_TO_ARGB(c) ( \
- ( ((unsigned int)(c[ACOMP]))<<24 ) | \
- ( ((unsigned int)(c[RCOMP]))<<16 ) | \
- ( ((unsigned int)(c[GCOMP]))<<8 ) | \
- ( (unsigned int)(c[BCOMP])) )
-
-inline void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer,
- FxU32 dst_x,
- FxU32 dst_y,
- FxU32 src_width,
- FxI32 src_stride,
- void *src_data )
-{
- /* Covert to ARGB */
- GLubyte (*rgba)[4] = src_data;
- GLuint argb[MAX_WIDTH];
- int i;
-
- for (i = 0; i < src_width; i++)
- {
- argb[i] = MESACOLOR_TO_ARGB(rgba[i]);
- }
- writeRegionClipped( /*fxMesa,*/ NULL, dst_buffer,
- dst_x,
- dst_y,
- GR_LFB_SRC_FMT_8888,
- src_width,
- 1,
- src_stride,
- (void*)argb);
-}
-
-#endif /* !defined(FXMESA_USE_RGBA) */
+#define LFB_WRITE_SPAN_MESA(dst_buffer, \
+ dst_x, \
+ dst_y, \
+ src_width, \
+ src_stride, \
+ src_data) \
+ writeRegionClipped(fxMesa, dst_buffer, \
+ dst_x, \
+ dst_y, \
+ GR_LFB_SRC_FMT_8888, \
+ src_width, \
+ 1, \
+ src_stride, \
+ src_data) \
+
-/************************************************************************/
-/***** Span functions *****/
-/************************************************************************/
+/*
+ * 16bpp span/pixel functions
+ */
-static void fxDDWriteRGBASpan(const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte rgba[][4], const GLubyte mask[])
+static void
+write_R5G6B5_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte rgba[][4], const GLubyte mask[])
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteRGBASpan(...)\n");
+ fprintf(stderr,"fxmesa: fxDDWriteRGBASpan(...)\n");
}
x+=fxMesa->x_offset;
@@ -213,7 +327,7 @@ static void fxDDWriteRGBASpan(const GLcontext *ctx,
} else {
if (span > 0) {
LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+i-span, bottom-y,
- /* GR_LFB_SRC_FMT_8888,*/ span, /*1,*/ 0, (void *) rgba[i-span] );
+ /* GR_LFB_SRC_FMT_8888,*/ span, /*1,*/ 0, (void *) rgba[i-span] );
span = 0;
}
}
@@ -221,16 +335,16 @@ static void fxDDWriteRGBASpan(const GLcontext *ctx,
if (span > 0)
LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+n-span, bottom-y,
- /* GR_LFB_SRC_FMT_8888, */ span, /*1,*/ 0, (void *) rgba[n-span] );
+ /* GR_LFB_SRC_FMT_8888, */ span, /*1,*/ 0, (void *) rgba[n-span] );
} else
LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x, bottom-y,/* GR_LFB_SRC_FMT_8888,*/
- n,/* 1,*/ 0, (void *) rgba );
+ n,/* 1,*/ 0, (void *) rgba );
}
-static void fxDDWriteRGBSpan(const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte rgb[][3], const GLubyte mask[])
+static void
+write_R5G6B5_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte rgb[][3], const GLubyte mask[])
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
@@ -238,7 +352,7 @@ static void fxDDWriteRGBSpan(const GLcontext *ctx,
GLubyte rgba[MAX_WIDTH][4];
if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteRGBSpan()\n");
+ fprintf(stderr,"fxmesa: fxDDWriteRGBSpan()\n");
}
x+=fxMesa->x_offset;
@@ -255,7 +369,7 @@ static void fxDDWriteRGBSpan(const GLcontext *ctx,
} else {
if (span > 0) {
LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+i-span, bottom-y,
- /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba );
+ /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba );
span = 0;
}
}
@@ -263,7 +377,7 @@ static void fxDDWriteRGBSpan(const GLcontext *ctx,
if (span > 0)
LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+n-span, bottom-y,
- /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba );
+ /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba );
} else {
for (i=0;i<n;i++) {
rgba[i][RCOMP]=rgb[i][0];
@@ -273,14 +387,14 @@ static void fxDDWriteRGBSpan(const GLcontext *ctx,
}
LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x, bottom-y,/* GR_LFB_SRC_FMT_8888,*/
- n,/* 1,*/ 0, (void *) rgba );
+ n,/* 1,*/ 0, (void *) rgba );
}
}
-static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte mask[])
+static void
+write_R5G6B5_mono_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte mask[])
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
@@ -288,7 +402,7 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
GLuint data[MAX_WIDTH];
if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteMonoRGBASpan(...)\n");
+ fprintf(stderr,"fxmesa: fxDDWriteMonoRGBASpan(...)\n");
}
x+=fxMesa->x_offset;
@@ -302,8 +416,8 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
} else {
if (span > 0) {
writeRegionClipped(fxMesa, fxMesa->currentFB, x+i-span, bottom-y,
- GR_LFB_SRC_FMT_8888, span, 1, 0,
- (void *) data );
+ GR_LFB_SRC_FMT_8888, span, 1, 0,
+ (void *) data );
span = 0;
}
}
@@ -311,59 +425,31 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
if (span > 0)
writeRegionClipped(fxMesa, fxMesa->currentFB, x+n-span, bottom-y,
- GR_LFB_SRC_FMT_8888, span, 1, 0,
- (void *) data );
+ GR_LFB_SRC_FMT_8888, span, 1, 0,
+ (void *) data );
} else {
for (i=0;i<n;i++) {
data[i]=(GLuint) fxMesa->color;
}
writeRegionClipped(fxMesa, fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888,
- n, 1, 0, (void *) data );
+ n, 1, 0, (void *) data );
}
}
-#if 0
-static void fxDDReadRGBASpan(const GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLubyte rgba[][4])
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLushort data[MAX_WIDTH];
- GLuint i;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
-
- printf("read span %d, %d, %d\n", x,y,n);
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDReadRGBASpan(...)\n");
- }
-
- assert(n < MAX_WIDTH);
-
- x+=fxMesa->x_offset;
- FX_grLfbReadRegion( fxMesa->currentFB, x, bottom-y, n, 1, 0, data);
-
- for (i=0;i<n;i++) {
- GLushort pixel = data[i];
- rgba[i][RCOMP] = FX_PixelToR[pixel];
- rgba[i][GCOMP] = FX_PixelToG[pixel];
- rgba[i][BCOMP] = FX_PixelToB[pixel];
- rgba[i][ACOMP] = 255;
- }
-}
-#endif
-
-
/*
* Read a span of 16-bit RGB pixels. Note, we don't worry about cliprects
* since OpenGL says obscured pixels have undefined values.
*/
-static void read_R5G6B5_span(const GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLubyte rgba[][4])
+static void
+read_R5G6B5_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ GLubyte rgba[][4])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
GrLfbInfo_t info;
BEGIN_BOARD_LOCK();
+ info.size=sizeof(info);
if (grLfbLock(GR_LFB_READ_ONLY,
fxMesa->currentFB,
GR_LFBWRITEMODE_ANY,
@@ -374,13 +460,13 @@ static void read_R5G6B5_span(const GLcontext *ctx,
const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
#ifdef XF86DRI
const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+ ? (fxMesa->screen_width) : (info.strideInBytes / 2);
#else
const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
#endif
const GLushort *data16 = (const GLushort *) info.lfbPtr
- + (winY - y) * srcStride
- + (winX + x);
+ + (winY - y) * srcStride
+ + (winX + x);
const GLuint *data32 = (const GLuint *) data16;
GLuint i, j;
GLuint extraPixel = (n & 1);
@@ -412,91 +498,716 @@ static void read_R5G6B5_span(const GLcontext *ctx,
}
-/************************************************************************/
-/***** Pixel functions *****/
-/************************************************************************/
-
-static void fxDDWriteRGBAPixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- CONST GLubyte rgba[][4], const GLubyte mask[])
+static void
+write_R5G6B5_pixels(const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ CONST GLubyte rgba[][4], const GLubyte mask[])
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n");
+ fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n");
}
for(i=0;i<n;i++)
if(mask[i])
- LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x[i]+fxMesa->x_offset, bottom-y[i],
- 1, 1, (void *)rgba[i]);
+ LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x[i]+fxMesa->x_offset, bottom-y[i],
+ 1, 1, (void *)rgba[i]);
}
-static void fxDDWriteMonoRGBAPixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLubyte mask[])
+
+static void
+write_R5G6B5_mono_pixels(const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLubyte mask[])
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n");
+ fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n");
}
for(i=0;i<n;i++)
if(mask[i])
writeRegionClipped(fxMesa, fxMesa->currentFB,x[i]+fxMesa->x_offset,bottom-y[i],
- GR_LFB_SRC_FMT_8888,1,1,0,(void *) &fxMesa->color);
+ GR_LFB_SRC_FMT_8888,1,1,0,(void *) &fxMesa->color);
}
+static void
+read_R5G6B5_pixels(const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4], const GLubyte mask[])
+{
+ fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ GLuint i;
+ GLint bottom=fxMesa->height+fxMesa->y_offset-1;
-static void read_R5G6B5_pixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[])
+ if (MESA_VERBOSE&VERBOSE_DRIVER) {
+ fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n");
+ }
+
+ for(i=0;i<n;i++) {
+ if(mask[i]) {
+ GLushort pixel;
+ FX_grLfbReadRegion(fxMesa->currentFB,x[i],bottom-y[i],1,1,0,&pixel);
+ rgba[i][RCOMP] = FX_PixelToR[pixel];
+ rgba[i][GCOMP] = FX_PixelToG[pixel];
+ rgba[i][BCOMP] = FX_PixelToB[pixel];
+ rgba[i][ACOMP] = 255;
+ }
+ }
+}
+
+
+/*
+ * 24bpp span/pixel functions
+ */
+
+static void
+write_R8G8B8_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte rgb[][3], const GLubyte mask[])
{
- fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbWriteMode_t mode;
GrLfbInfo_t info;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+ mode = GR_LFBWRITEMODE_888;
+ else
+ mode = GR_LFBWRITEMODE_888;
+
BEGIN_BOARD_LOCK();
+ info.size = sizeof(info);
+ if (grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ mode,
+ GR_ORIGIN_UPPER_LEFT,
+ FXFALSE,
+ &info)) {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+ const GLint scrX = winX + x;
+ const GLint scrY = winY - y;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+ /*GLint dstStride = fxMesa->screen_width * 3;*/
+ GLint dstStride = info.strideInBytes / 1;
+ GLubyte *dst = (GLubyte *) info.lfbPtr
+ + (winY - y) * dstStride + (winX + x) * 1;
+ GLuint *dst32 = (GLuint *) dst;
+ GLubyte visMask[MAX_WIDTH];
+ GLuint i;
+ generate_vismask(fxMesa, scrX, scrY, n, visMask);
+ for (i = 0; i < n; i++) {
+ if (visMask[i] && (!mask || mask[i])) {
+ dst32[i] = PACK_BGRA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
+ }
+ }
+ }
+ else {
+ /* back buffer */
+ GLint dstStride = info.strideInBytes;
+ GLubyte *dst = (GLubyte *) info.lfbPtr
+ + (winY - y) * dstStride + (winX + x) * 4;
+ GLuint *dst32 = (GLuint *) dst;
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ dst32[i] = PACK_RGBA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst32[i] = PACK_RGBA32(rgb[i][2], rgb[i][1], rgb[i][0], 255);
+ }
+ }
+ }
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
+}
+
+
+
+static void
+write_R8G8B8_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte rgba[][4], const GLubyte mask[])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbWriteMode_t mode;
+ GrLfbInfo_t info;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+ mode = GR_LFBWRITEMODE_8888;
+ else
+ mode = GR_LFBWRITEMODE_888 /*565*/;
+
+ BEGIN_BOARD_LOCK();
+ info.size = sizeof(info);
+ if (grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ mode,
+ GR_ORIGIN_UPPER_LEFT,
+ FXFALSE,
+ &info)) {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+ const GLint scrX = winX + x;
+ const GLint scrY = winY - y;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+ /* XXX have to do cliprect clipping! */
+ GLint dstStride = fxMesa->screen_width * 4;
+ GLubyte *dst = (GLubyte *) info.lfbPtr
+ + (winY - y) * dstStride + (winX + x) * 4;
+ GLuint *dst32 = (GLuint *) dst;
+ GLubyte visMask[MAX_WIDTH];
+ GLuint i;
+ generate_vismask(fxMesa, scrX, scrY, n, visMask);
+ for (i = 0; i < n; i++) {
+ if (visMask[i] && (!mask || mask[i])) {
+ dst32[i] = PACK_BGRA32(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]);
+ }
+ }
+ }
+ else {
+ /* back buffer */
+ GLint dstStride = info.strideInBytes;
+ GLubyte *dst = (GLubyte *) info.lfbPtr
+ + (winY - y) * dstStride + (winX + x) * 4;
+ if (mask) {
+ const GLuint *src32 = (const GLuint *) rgba;
+ GLuint *dst32 = (GLuint *) dst;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ dst32[i] = src32[i];
+ }
+ }
+ }
+ else {
+ /* no mask, write all pixels */
+ MEMCPY(dst, rgba, 4 * n);
+ }
+ }
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
+}
+
+
+static void
+write_R8G8B8_mono_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte mask[])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLubyte rgba[MAX_WIDTH][4];
+ GLuint *data = (GLuint *) rgba;
+ GLuint i;
+
+ /* XXX this is a simple-minded implementation but good enough for now */
+ for (i = 0; i < n; i++) {
+ data[i] = (GLuint) fxMesa->color;
+ }
+ write_R8G8B8_rgba_span(ctx, n, x, y, (const GLubyte (*)[4]) rgba, mask);
+}
+
+
+static void
+read_R8G8B8_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ GLubyte rgba[][4])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbWriteMode_t mode;
+ GrLfbInfo_t info;
+
+ if (1 || fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+ mode = GR_LFBWRITEMODE_8888;
+ }
+ else {
+ mode = GR_LFBWRITEMODE_565; /*888*/ /*565*/;
+ }
+
+ BEGIN_BOARD_LOCK();
+ info.size = sizeof(info);
if (grLfbLock(GR_LFB_READ_ONLY,
fxMesa->currentFB,
- GR_LFBWRITEMODE_ANY,
+ mode, /*GR_LFBWRITEMODE_ANY,*/
GR_ORIGIN_UPPER_LEFT,
FXFALSE,
&info)) {
-#ifdef XF86DRI
- const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+ GLint srcStride = fxMesa->screen_width * 4;
+ const GLubyte *src = (const GLubyte *) info.lfbPtr
+ + (winY - y) * srcStride + (winX + x) * 4;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ rgba[i][0] = src[i * 4 + 2];
+ rgba[i][1] = src[i * 4 + 1];
+ rgba[i][2] = src[i * 4 + 0];
+ rgba[i][3] = src[i * 4 + 3];
+ }
+ }
+ else {
+ /* back buffer */
+ GLint srcStride = /*info.strideInBytes;*/ 8192 / 2; /* XXX a hack! */
+ const GLubyte *src = (const GLubyte *) info.lfbPtr
+ + (winY - y) * srcStride + (winX + x) * 4;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ rgba[i][0] = src[i * 4 + 2];
+ rgba[i][1] = src[i * 4 + 1];
+ rgba[i][2] = src[i * 4 + 0];
+ rgba[i][3] = src[i * 4 + 3];
+ }
+ }
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
+}
+
+
+static void
+write_R8G8B8_pixels(const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ CONST GLubyte rgba[][4], const GLubyte mask[])
+{
+#if 00
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ write_R8G8B8_rgba_span(ctx, 1, x[i], y[i], rgba + i, mask + i);
+ }
+
#else
- const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbWriteMode_t mode;
+ GrLfbInfo_t info;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+ mode = GR_LFBWRITEMODE_8888;
+ else
+ mode = GR_LFBWRITEMODE_888 /*565*/;
+
+ BEGIN_BOARD_LOCK();
+ info.size = sizeof(info);
+ if (grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ mode,
+ GR_ORIGIN_UPPER_LEFT,
+ FXFALSE,
+ &info)) {
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+ const GLint scrX = winX + x[i];
+ const GLint scrY = winY - y[i];
+ if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) {
+ GLint dstStride = fxMesa->screen_width * 4;
+ GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4;
+ GLuint *dst32 = (GLuint *) dst;
+ *dst32 = PACK_BGRA32(rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3]);
+ }
+ }
+ }
+ else {
+ /* back buffer */
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+ const GLint scrX = winX + x[i];
+ const GLint scrY = winY - y[i];
+ if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) {
+ GLint dstStride = info.strideInBytes;
+ GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4;
+ GLuint *dst32 = (GLuint *) dst;
+ const GLuint *src32 = (const GLuint *) rgba;
+ *dst32 = src32[i];
+ }
+ }
+ }
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
#endif
+}
+
+
+static void
+write_R8G8B8_mono_pixels(const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLubyte mask[])
+{
+}
+
+
+static void
+read_R8G8B8_pixels(const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4], const GLubyte mask[])
+{
+ printf("read_R8G8B8_pixels %d\n", n);
+}
+
+
+
+/*
+ * 32bpp span/pixel functions
+ */
+
+static void
+write_R8G8B8A8_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte rgb[][3], const GLubyte mask[])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbWriteMode_t mode;
+ GrLfbInfo_t info;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+ mode = GR_LFBWRITEMODE_8888;
+ else
+ mode = GR_LFBWRITEMODE_888 /*565*/;
+
+ BEGIN_BOARD_LOCK();
+ info.size = sizeof(info);
+ if (grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ mode,
+ GR_ORIGIN_UPPER_LEFT,
+ FXFALSE,
+ &info)) {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
const GLint winX = fxMesa->x_offset;
+ const GLint scrX = winX + x;
+ const GLint scrY = winY - y;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+ GLint dstStride = fxMesa->screen_width * 4;
+ GLubyte * dst = (GLubyte *) info.lfbPtr
+ + (winY - y) * dstStride + (winX + x) * 4;
+ GLuint *dst32 = (GLuint *) dst;
+ GLubyte visMask[MAX_WIDTH];
+ GLuint i;
+ generate_vismask(fxMesa, scrX, scrY, n, visMask);
+ for (i = 0; i < n; i++) {
+ if (visMask[i] && (!mask || mask[i])) {
+ dst32[i] = PACK_BGRA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
+ }
+ }
+ }
+ else {
+ /* back buffer */
+ GLint dstStride = info.strideInBytes;
+ GLubyte *dst = (GLubyte *) info.lfbPtr
+ + (winY - y) * dstStride + (winX + x) * 4;
+ if (mask) {
+ GLuint *dst32 = (GLuint *) dst;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ dst32[i] = PACK_RGBA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
+ }
+ }
+ }
+ else {
+ GLuint *dst32 = (GLuint *) dst;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst32[i] = PACK_RGBA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
+ }
+ }
+ }
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
+}
+
+
+/*
+ *XXX test of grLfbWriteRegion in 32bpp mode. Doesn't seem to work!
+ */
+#if 0
+static void
+write_R8G8B8A8_rgb_span2(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte rgb[][3], const GLubyte mask[])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+ GLint x2 = fxMesa->x_offset +x;
+ GLint y2 = bottom - y;
+
+ FX_grLfbWriteRegion(fxMesa->currentFB, x2, y2, GR_LFB_SRC_FMT_888,
+ n, 1, 0, rgb);
+}
+#endif
+
+
+static void
+write_R8G8B8A8_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte rgba[][4], const GLubyte mask[])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbWriteMode_t mode;
+ GrLfbInfo_t info;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+ mode = GR_LFBWRITEMODE_8888;
+ else
+ mode = GR_LFBWRITEMODE_888 /*565*/;
+
+ BEGIN_BOARD_LOCK();
+ info.size = sizeof(info);
+ if (grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ mode,
+ GR_ORIGIN_UPPER_LEFT,
+ FXFALSE,
+ &info)) {
const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- GLuint i;
- for(i=0;i<n;i++) {
- if(mask[i]) {
- const GLushort *data16 = (const GLushort *) info.lfbPtr
- + (winY - y[i]) * srcStride
- + (winX + x[i]);
- const GLushort pixel = *data16;
- rgba[i][RCOMP] = FX_PixelToR[pixel];
- rgba[i][GCOMP] = FX_PixelToG[pixel];
- rgba[i][BCOMP] = FX_PixelToB[pixel];
- rgba[i][ACOMP] = 255;
+ const GLint winX = fxMesa->x_offset;
+ const GLint scrX = winX + x;
+ const GLint scrY = winY - y;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+ GLint dstStride = fxMesa->screen_width * 4;
+ GLubyte *dst = (GLubyte *) info.lfbPtr
+ + (winY - y) * dstStride + (winX + x) * 4;
+ GLuint *dst32 = (GLuint *) dst;
+ GLubyte visMask[MAX_WIDTH];
+ GLuint i;
+ generate_vismask(fxMesa, scrX, scrY, n, visMask);
+ for (i = 0; i < n; i++) {
+ if (visMask[i] && (!mask || mask[i])) {
+ dst32[i] = PACK_BGRA32(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]);
+ }
+ }
+ }
+ else {
+ /* back buffer */
+ GLint dstStride = 8192; /* XXX a hack info.strideInBytes; */
+ GLubyte *dst = (GLubyte *) info.lfbPtr
+ + (winY - y) * dstStride + (winX + x) * 4;
+ if (mask) {
+ const GLuint *src32 = (const GLuint *) rgba;
+ GLuint *dst32 = (GLuint *) dst;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ dst32[i] = src32[i];
+ }
+ }
+ }
+ else {
+ /* no mask, write all pixels */
+ MEMCPY(dst, rgba, 4 * n);
+ }
+ }
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+ }
+ else {
+ info.strideInBytes = -1;
+ }
+ END_BOARD_LOCK();
+}
+
+
+static void
+write_R8G8B8A8_mono_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte mask[])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLubyte rgba[MAX_WIDTH][4];
+ GLuint *data = (GLuint *) rgba;
+ GLuint i;
+
+ /* XXX this is a simple-minded implementation but good enough for now */
+ for (i = 0; i < n; i++) {
+ data[i] = (GLuint) fxMesa->color;
+ }
+ write_R8G8B8A8_rgba_span(ctx, n, x, y, (const GLubyte (*)[4]) rgba, mask);
+}
+
+
+static void
+read_R8G8B8A8_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ GLubyte rgba[][4])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbWriteMode_t mode;
+ GrLfbInfo_t info;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+ mode = GR_LFBWRITEMODE_8888;
+ }
+ else {
+ mode = GR_LFBWRITEMODE_8888; /*565;*/
+ }
+
+ BEGIN_BOARD_LOCK();
+ info.size = sizeof(info);
+ if (grLfbLock(GR_LFB_READ_ONLY,
+ fxMesa->currentFB,
+ mode,
+ GR_ORIGIN_UPPER_LEFT,
+ FXFALSE,
+ &info)) {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+ GLint srcStride = fxMesa->screen_width;
+ const GLuint *src32 = (const GLuint *) info.lfbPtr
+ + (winY - y) * srcStride + (winX + x);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ const GLuint p = src32[i];
+ rgba[i][0] = (p >> 16) & 0xff;
+ rgba[i][1] = (p >> 8) & 0xff;
+ rgba[i][2] = (p >> 0) & 0xff;
+ rgba[i][3] = (p >> 24) & 0xff;
+ }
+ }
+ else {
+ /* back buffer */
+ GLint srcStride = 1024; /* XXX a hack */
+ const GLuint *src32 = (const GLuint *) info.lfbPtr
+ + (winY - y) * srcStride + (winX + x);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLuint p = src32[i];
+ rgba[i][0] = (p >> 16) & 0xff;
+ rgba[i][1] = (p >> 8) & 0xff;
+ rgba[i][2] = (p >> 0) & 0xff;
+ rgba[i][3] = (p >> 24) & 0xff;
}
}
grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
}
+ else
+ info.strideInBytes = -1;
+ END_BOARD_LOCK();
+}
+
+
+static void
+write_R8G8B8A8_pixels(const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ CONST GLubyte rgba[][4], const GLubyte mask[])
+{
+#if 00
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ write_R8G8B8A8_rgba_span(ctx, 1, x[i], y[i], rgba + i, mask + i);
+ }
+
+#else
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbWriteMode_t mode;
+ GrLfbInfo_t info;
+
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+ mode = GR_LFBWRITEMODE_8888;
+ else
+ mode = GR_LFBWRITEMODE_888 /*565*/;
+
+ BEGIN_BOARD_LOCK();
+ info.size = sizeof(info);
+ if (grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ mode,
+ GR_ORIGIN_UPPER_LEFT,
+ FXFALSE,
+ &info)) {
+ if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+ const GLint scrX = winX + x[i];
+ const GLint scrY = winY - y[i];
+ if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) {
+ GLint dstStride = fxMesa->screen_width * 4;
+ GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4;
+ GLuint *dst32 = (GLuint *) dst;
+ *dst32 = PACK_BGRA32(rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3]);
+ }
+ }
+ }
+ else {
+ /* back buffer */
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+ const GLint scrX = winX + x[i];
+ const GLint scrY = winY - y[i];
+ if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) {
+ GLint dstStride = info.strideInBytes;
+ GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4;
+ GLuint *dst32 = (GLuint *) dst;
+ const GLuint *src32 = (const GLuint *) rgba;
+ *dst32 = src32[i];
+ }
+ }
+ }
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+ }
END_BOARD_LOCK();
+#endif
+}
+
+
+static void
+write_R8G8B8A8_mono_pixels(const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLubyte mask[])
+{
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLuint i;
+ GLuint color = fxMesa->color;
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ write_R8G8B8A8_rgba_span(ctx, 1, x[i], y[i],
+ (const GLubyte (*)[4]) &color, mask + i);
+ }
+ }
+}
+
+
+
+static void
+read_R8G8B8A8_pixels(const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4], const GLubyte mask[])
+{
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ read_R8G8B8A8_span(ctx, 1, x[i], y[i], rgba + i);
+ }
+ }
+ printf("read_R8G8B8A8_pixels %d\n", n);
}
-/************************************************************************/
-/***** Depth functions *****/
-/************************************************************************/
+/*
+ * Depth buffer read/write functions.
+ */
void fxDDWriteDepthSpan(GLcontext *ctx,
GLuint n, GLint x, GLint y, const GLdepth depth[],
@@ -504,9 +1215,11 @@ void fxDDWriteDepthSpan(GLcontext *ctx,
{
fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+ GLuint depth_size = fxMesa->glVis->DepthBits;
+ GLuint stencil_size = fxMesa->glVis->StencilBits;
if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDWriteDepthSpan(...)\n");
+ fprintf(stderr, "fxmesa: fxDDWriteDepthSpan(...)\n");
}
x += fxMesa->x_offset;
@@ -515,20 +1228,77 @@ void fxDDWriteDepthSpan(GLcontext *ctx,
GLint i;
for (i = 0; i < n; i++) {
if (mask[i]) {
- GLshort d = depth[i];
- writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom - y,
- GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
+ GLshort d16;
+ GLuint d32;
+ switch (depth_size) {
+ case 16:
+ d16 = depth[i];
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom - y,
+ GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d16);
+ break;
+ case 32:
+ if (!fb_point_is_clipped(fxMesa, x+i, bottom-y)) {
+ if (stencil_size > 0) {
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ x + i, bottom - y,
+ 1,
+ sizeof(GLdepth),
+ &d32,
+ FBS_READ);
+ d32 = depth[i] & 0xFF000000;
+ break;
+ } else {
+ d32 = depth[i];
+ }
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ x + i, bottom - y,
+ 1,
+ sizeof(GLdepth),
+ &d32,
+ FBS_WRITE);
+ }
+ }
}
}
- }
- else {
+ } else {
GLushort depth16[MAX_WIDTH];
GLint i;
- for (i = 0; i < n; i++) {
- depth16[i] = depth[i];
+ GLuint d32;
+ switch (depth_size) {
+ case 16:
+ for (i = 0; i < n; i++) {
+ depth16[i] = depth[i];
+ }
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom - y,
+ GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth16);
+ break;
+ case 32:
+ for (i = 0; i < n; i++) {
+ if (fb_point_is_clipped(fxMesa, x+i, bottom-y)) {
+ if (stencil_size > 0) {
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ x + i, bottom - y,
+ 1,
+ sizeof(GLdepth),
+ &d32,
+ FBS_READ);
+ d32 = (d32 & 0xFF0000) | (depth[i] & 0x00FFFFFF);
+ } else {
+ d32 = depth[i];
+ }
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ x + i, bottom - y,
+ 1,
+ sizeof(GLdepth),
+ &d32,
+ FBS_WRITE);
+ }
+ }
}
- writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom - y,
- GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth16);
}
}
@@ -540,15 +1310,34 @@ void fxDDReadDepthSpan(GLcontext *ctx,
GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
GLushort depth16[MAX_WIDTH];
GLuint i;
+ GLuint depth_size = fxMesa->glVis->DepthBits;
+ GLuint stencil_size = fxMesa->glVis->StencilBits;
if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDReadDepthSpan(...)\n");
+ fprintf(stderr, "fxmesa: fxDDReadDepthSpan(...)\n");
}
x += fxMesa->x_offset;
- FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
- for (i = 0; i < n; i++) {
- depth[i] = depth16[i];
+ switch (depth_size) {
+ case 16:
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
+ for (i = 0; i < n; i++) {
+ depth[i] = depth16[i];
+ }
+ break;
+ case 32:
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ x, bottom - y,
+ n,
+ sizeof(GLdepth),
+ depth,
+ FBS_READ);
+ if (stencil_size > 0) {
+ for (i = 0; i < n; i++) {
+ depth[i] &= 0xFFFFFF;
+ }
+ }
}
}
@@ -561,6 +1350,9 @@ void fxDDWriteDepthPixels(GLcontext *ctx,
fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
GLuint i;
+ GLuint d32;
+ GLuint depth_size = fxMesa->glVis->DepthBits;
+ GLuint stencil_size = fxMesa->glVis->StencilBits;
if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr, "fxmesa: fxDDWriteDepthPixels(...)\n");
@@ -570,9 +1362,41 @@ void fxDDWriteDepthPixels(GLcontext *ctx,
if (mask[i]) {
int xpos = x[i] + fxMesa->x_offset;
int ypos = bottom - y[i];
- GLushort d = depth[i];
- writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos,
- GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
+ GLushort d16 = depth[i];
+ switch (depth_size) {
+ case 16:
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos,
+ GR_LFB_SRC_FMT_ZA16, 1, 1, 0,
+ (void *) &d16);
+ break;
+ case 32:
+ if (!fb_point_is_clipped(fxMesa, xpos, ypos)) {
+ if (stencil_size > 0) {
+ /*
+ * Should I sign extend this? I don't
+ * believe so, since GLdepth is unsigned.
+ */
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ xpos, ypos,
+ 1,
+ sizeof(GLdepth),
+ &d32,
+ FBS_READ);
+ d32 = (d32 &~ 0xFF000000) | (depth[i] & 0x00FFFFFF);
+ } else {
+ d32 = depth[i];
+ }
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ xpos, ypos,
+ 1,
+ sizeof(GLdepth),
+ &d32,
+ FBS_WRITE);
+ }
+ break;
+ }
}
}
}
@@ -592,51 +1416,409 @@ void fxDDReadDepthPixels(GLcontext *ctx, GLuint n,
for (i = 0; i < n; i++) {
int xpos = x[i] + fxMesa->x_offset;
int ypos = bottom - y[i];
- GLushort d;
- FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, xpos, ypos, 1, 1, 0, &d);
- depth[i] = d;
+ GLushort d16;
+ GLuint d32;
+ GLuint depth_size = fxMesa->glVis->DepthBits;
+ GLuint stencil_size = fxMesa->glVis->StencilBits;
+
+ assert((depth_size == 16) || (depth_size == 32));
+ switch (depth_size) {
+ case 16:
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, xpos, ypos, 1, 1, 0, &d16);
+ depth[i] = d16;
+ break;
+ case 32:
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ xpos, ypos,
+ 1,
+ depth_size/8,
+ &d32,
+ FBS_READ);
+ /*
+ * Get rid of the stencil bits. Should I sign
+ * extend this? I don't believe so, since GLdepth
+ * is unsigned.
+ */
+ if (stencil_size > 0) {
+ d32 &= 0xFFFFFF;
+ }
+ depth[i] = d32;
+ break;
+ default:
+ assert(0);
+ }
}
}
+/*
+ * Stencil buffer read/write functions.
+ */
+#define DEPTH_VALUE_TO_STENCIL_VALUE(d) (((d) >> 24) & 0xFF)
+#define STENCIL_VALUE_TO_DEPTH_VALUE(s,d) \
+ ((((s) & 0xFF) << 24) | ((d) & 0xFFFFFF))
+#define ASSEMBLE_STENCIL_VALUE(os, ns, mask) \
+ (((os) &~ (mask)) | ((ns) & (mask)))
-/************************************************************************/
+#if 00
+/*
+ * Read a horizontal span of stencil values from the stencil buffer.
+ */
+void
+fxDDReadStencilSpan( GLcontext *ctx,
+ GLuint n,
+ GLint x,
+ GLint y,
+ GLstencil stencil[] )
+{
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+ GLuint i;
+ int xpos = x + fxMesa->x_offset;
+ int ypos = bottom - y;
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDReadStencilSpan(...)\n");
+ }
-void fxSetupDDSpanPointers(GLcontext *ctx)
-{
- ctx->Driver.WriteRGBASpan =fxDDWriteRGBASpan;
- ctx->Driver.WriteRGBSpan =fxDDWriteRGBSpan;
- ctx->Driver.WriteMonoRGBASpan =fxDDWriteMonoRGBASpan;
- ctx->Driver.WriteRGBAPixels =fxDDWriteRGBAPixels;
- ctx->Driver.WriteMonoRGBAPixels =fxDDWriteMonoRGBAPixels;
+ for (i = 0; i < n; i++, ypos += 1) {
+ GLuint d;
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ xpos, ypos,
+ 1,
+ sizeof(GLdepth),
+ &d,
+ FBS_READ);
+ stencil[i] = DEPTH_VALUE_TO_STENCIL_VALUE(d);
+ }
+}
- ctx->Driver.WriteCI8Span =NULL;
- ctx->Driver.WriteCI32Span =NULL;
- ctx->Driver.WriteMonoCISpan =NULL;
- ctx->Driver.WriteCI32Pixels =NULL;
- ctx->Driver.WriteMonoCIPixels =NULL;
+/*
+ * Write a horizontal span of stencil values into the stencil buffer.
+ * If mask is NULL, write all stencil values.
+ * Else, only write stencil[i] if mask[i] is non-zero.
+ */
+void
+fxDDWriteStencilSpan( GLcontext *ctx,
+ GLuint n,
+ GLint x,
+ GLint y,
+ const GLstencil stencil[],
+ const GLubyte mask[] )
+{
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+ GLuint i;
+ int xpos = x + fxMesa->x_offset;
+ int ypos = bottom - y;
- /* ctx->Driver.ReadRGBASpan =fxDDReadRGBASpan;*/
- ctx->Driver.ReadRGBASpan = read_R5G6B5_span;
- ctx->Driver.ReadRGBAPixels = read_R5G6B5_pixels;
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteStencilSpan(...)\n");
+ }
- ctx->Driver.ReadCI32Span =NULL;
- ctx->Driver.ReadCI32Pixels =NULL;
+ for (i = 0; i < n; i++, ypos += 1) {
+ GLdepth d;
+ GLstencil ns;
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ xpos, ypos,
+ 1,
+ sizeof(GLdepth),
+ &d,
+ FBS_READ);
+ /*
+ * Find the old stencil value, and strip off the bits
+ * we are going to write.
+ */
+ ns = ASSEMBLE_STENCIL_VALUE(DEPTH_VALUE_TO_STENCIL_VALUE(d),
+ stencil[i],
+ mask[i]);
+ /*
+ * Now, assemble the new StenDepth value, with the old
+ * depth value, the old stencil value in the bits
+ * where mask is 0, and the new stencil value in the bits
+ * where mask is 1.
+ */
+ d = STENCIL_VALUE_TO_DEPTH_VALUE(ns, d);
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ xpos, ypos,
+ 1,
+ sizeof(GLdepth),
+ &d,
+ FBS_WRITE);
+ }
}
+/* Write an array of stencil values into the stencil buffer.
+ * If mask is NULL, write all stencil values.
+ * Else, only write stencil[i] if mask[i] is non-zero.
+ */
+void
+fxDDReadStencilPixels( GLcontext *ctx,
+ GLuint n,
+ const GLint x[],
+ const GLint y[],
+ GLstencil stencil[])
+{
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+ GLuint i;
-#else
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDReadStencilPixels(...)\n");
+ }
+ for (i = 0; i < n; i++) {
+ int xpos = x[i] + fxMesa->x_offset;
+ int ypos = bottom - y[i];
+ GLuint d;
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ xpos, ypos,
+ 1,
+ sizeof(GLdepth),
+ &d,
+ FBS_READ);
+ stencil[i] = DEPTH_VALUE_TO_STENCIL_VALUE(d);
+ }
+}
/*
- * Need this to provide at least one external definition.
+ * Read an array of stencil values from the stencil buffer.
*/
+void
+fxDDWriteStencilPixels( GLcontext *ctx,
+ GLuint n,
+ const GLint x[],
+ const GLint y[],
+ const GLstencil stencil[],
+ const GLstencil mask[])
+{
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+ GLuint i;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteStencilPixels(...)\n");
+ }
-int gl_fx_dummy_function_span(void)
+ for (i = 0; i < n; i++) {
+ int xpos = x[i] + fxMesa->x_offset;
+ int ypos = bottom - y[i];
+ GLuint d;
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ xpos, ypos,
+ 1,
+ sizeof(GLdepth),
+ &d,
+ FBS_READ);
+ d = STENCIL_VALUE_TO_DEPTH_VALUE(stencil[i], d);
+ rw_fb_span(fxMesa,
+ GR_BUFFER_AUXBUFFER,
+ xpos, ypos,
+ 1,
+ sizeof(GLdepth),
+ &d,
+ FBS_WRITE);
+ }
+}
+#endif /* disable fxddStencil* funcs */
+
+
+#define EXTRACT_S_FROM_ZS(zs) (((zs) >> 24) & 0xFF)
+#define EXTRACT_Z_FROM_ZS(zs) ((zs) & 0xffffff)
+#define BUILD_ZS(z, s) (((s) << 24) | (z))
+
+static void write_stencil_span(GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLstencil stencil[],
+ const GLubyte mask[] )
{
- return 0;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ int s;
+ void *d;
+
+ BEGIN_BOARD_LOCK();
+ info.size = sizeof(info);
+ if (grLfbLock(GR_LFB_WRITE_ONLY,
+ GR_BUFFER_AUXBUFFER,
+ GR_LFBWRITEMODE_Z32,
+ GR_ORIGIN_UPPER_LEFT,
+ FXFALSE,
+ &info)) {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+ const GLint scrX = winX + x;
+ const GLint scrY = winY - y;
+
+ GLint dstStride = info.strideInBytes;
+ GLubyte *dst = (GLubyte *) info.lfbPtr
+ + (winY - y) * dstStride + (winX + x) * 4;
+ GLuint *dst32 = (GLuint *) dst;
+ GLubyte visMask[MAX_WIDTH];
+ GLuint i;
+ generate_vismask(fxMesa, scrX, scrY, n, visMask);
+ s = dstStride;
+ d = dst32;
+ for (i = 0; i < n; i++) {
+ if (visMask[i] && (!mask || mask[i])) {
+ GLuint zs = dst32[i];
+ GLuint z = EXTRACT_Z_FROM_ZS(zs);
+ zs = BUILD_ZS(z, stencil[i]);
+ dst32[i] = /*zs;*/ stencil[i];
+ }
+ }
+ grLfbUnlock(GR_LFB_WRITE_ONLY, GR_BUFFER_AUXBUFFER);
+ }
+ else {
+ s = -1;
+ d = 0;
+ }
+ END_BOARD_LOCK();
+ /*
+ printf("write stencil span %d %p\n", s, d);
+ printf("info: size=%d lfbPtr=%p stride=%x writeMode=%x origin=%x\n",
+ info.size, info.lfbPtr, info.strideInBytes, info.writeMode, info.origin);
+ */
+}
+
+
+static void
+read_stencil_span(GLcontext *ctx, GLuint n, GLint x, GLint y,
+ GLstencil stencil[])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ /*
+ int s;
+ void *d;
+ */
+
+ BEGIN_BOARD_LOCK();
+ info.size = sizeof(info);
+ if (grLfbLock(GR_LFB_READ_ONLY,
+ GR_BUFFER_AUXBUFFER,
+ GR_LFBWRITEMODE_Z32,
+ GR_ORIGIN_UPPER_LEFT,
+ FXFALSE,
+ &info)) {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+ GLint srcStride = /*info.strideInBytes;*/ 8192 ; /* XXX a hack! */
+ const GLubyte *src = (const GLubyte *) info.lfbPtr
+ + (winY - y) * srcStride + (winX + x) * 4;
+ const GLuint *src32 = (const GLuint *) src;
+ GLuint i;
+ /*
+ s = srcStride;
+ d = src32;
+ */
+ for (i = 0; i < n; i++) {
+ stencil[i] = EXTRACT_S_FROM_ZS(src32[i]);
+ }
+ grLfbUnlock(GR_LFB_READ_ONLY, GR_BUFFER_AUXBUFFER);
+ }
+ END_BOARD_LOCK();
+ /*
+ printf("read stencil span %d %p\n", s, d);
+ printf("info: size=%d lfbPtr=%p stride=%x writeMode=%x origin=%x\n",
+ info.size, info.lfbPtr, info.strideInBytes, info.writeMode, info.origin);
+ */
+}
+
+
+static void
+write_stencil_pixels( GLcontext *ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLstencil stencil[], const GLubyte mask[])
+{
+ /* XXX optimize this */
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ write_stencil_span(ctx, 1, x[i], y[i], stencil + i, mask + i);
+ }
+ }
+}
+
+
+static void
+read_stencil_pixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[],
+ GLstencil stencil[])
+{
+ /* XXX optimize this */
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ read_stencil_span(ctx, 1, x[i], y[i], stencil + i);
+ }
}
-#endif /* FX */
+
+
+void fxSetupDDSpanPointers(GLcontext *ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (ctx->Visual->RedBits == 5 &&
+ ctx->Visual->GreenBits == 6 &&
+ ctx->Visual->BlueBits == 5 &&
+ ctx->Visual->AlphaBits == 0) {
+ /* 16bpp mode */
+ ctx->Driver.WriteRGBASpan = write_R5G6B5_rgba_span;
+ ctx->Driver.WriteRGBSpan = write_R5G6B5_rgb_span;
+ ctx->Driver.WriteMonoRGBASpan = write_R5G6B5_mono_span;
+ ctx->Driver.WriteRGBAPixels = write_R5G6B5_pixels;
+ ctx->Driver.WriteMonoRGBAPixels = write_R5G6B5_mono_pixels;
+ ctx->Driver.ReadRGBASpan = read_R5G6B5_span;
+ ctx->Driver.ReadRGBAPixels = read_R5G6B5_pixels;
+ }
+ else if (ctx->Visual->RedBits == 8 &&
+ ctx->Visual->GreenBits == 8 &&
+ ctx->Visual->BlueBits == 8 &&
+ ctx->Visual->AlphaBits == 0) {
+ /* 24bpp mode */
+ ctx->Driver.WriteRGBASpan = write_R8G8B8_rgba_span;
+ ctx->Driver.WriteRGBSpan = write_R8G8B8_rgb_span;
+ ctx->Driver.WriteMonoRGBASpan = write_R8G8B8_mono_span;
+ ctx->Driver.WriteRGBAPixels = write_R8G8B8_pixels;
+ ctx->Driver.WriteMonoRGBAPixels = write_R8G8B8_mono_pixels;
+ ctx->Driver.ReadRGBASpan = read_R8G8B8_span;
+ ctx->Driver.ReadRGBAPixels = read_R8G8B8_pixels;
+ }
+ else if (ctx->Visual->RedBits == 8 &&
+ ctx->Visual->GreenBits == 8 &&
+ ctx->Visual->BlueBits == 8 &&
+ ctx->Visual->AlphaBits == 8) {
+ /* 32bpp mode */
+ ctx->Driver.WriteRGBASpan = write_R8G8B8A8_rgba_span;
+ ctx->Driver.WriteRGBSpan = write_R8G8B8A8_rgb_span;
+ ctx->Driver.WriteMonoRGBASpan = write_R8G8B8A8_mono_span;
+ ctx->Driver.WriteRGBAPixels = write_R8G8B8A8_pixels;
+ ctx->Driver.WriteMonoRGBAPixels = write_R8G8B8A8_mono_pixels;
+ ctx->Driver.ReadRGBASpan = read_R8G8B8A8_span;
+ ctx->Driver.ReadRGBAPixels = read_R8G8B8A8_pixels;
+ }
+ else {
+ abort();
+ }
+
+ if (fxMesa->haveHwStencil) {
+ ctx->Driver.WriteStencilSpan = write_stencil_span;
+ ctx->Driver.ReadStencilSpan = read_stencil_span;
+ ctx->Driver.WriteStencilPixels = write_stencil_pixels;
+ ctx->Driver.ReadStencilPixels = read_stencil_pixels;
+ }
+
+ 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/extras/Mesa/src/FX/fxddtex.c b/xc/extras/Mesa/src/FX/fxddtex.c
index db0acb6b4..69ceebaa9 100644
--- a/xc/extras/Mesa/src/FX/fxddtex.c
+++ b/xc/extras/Mesa/src/FX/fxddtex.c
@@ -496,209 +496,68 @@ static int logbase2(int n)
/* Need different versions for different cpus.
*/
-#define INT_TRICK(l2) (0x800000 * l2)
-
-
-int fxTexGetInfo(int w, int h, GrLOD_t *lodlevel, GrAspectRatio_t *ar,
+#define INT_TRICK(l2) (0x800000 * (l2))
+int fxTexGetInfo(int w, int h, GrLOD_t *lodlevel,
+ GrAspectRatio_t *aspectratio,
float *sscale, float *tscale,
int *i_sscale, int *i_tscale,
int *wscale, int *hscale)
{
-
- static GrLOD_t lod[9]={GR_LOD_256,GR_LOD_128,GR_LOD_64,GR_LOD_32,
- GR_LOD_16,GR_LOD_8,GR_LOD_4,GR_LOD_2,GR_LOD_1};
-
- int logw,logh,ws,hs;
- GrLOD_t l;
- GrAspectRatio_t aspectratio;
- float s,t;
- int is,it;
+ int logw, logh, ar, l, is, it, ws, hs;
+ float s, t;
logw=logbase2(w);
logh=logbase2(h);
-
- switch(logw-logh) {
- case 0:
- aspectratio=GR_ASPECT_1x1;
- l=lod[8-logw];
- s=t=256.0f;
- is=it=INT_TRICK(8);
- ws=hs=1;
- break;
- case 1:
- aspectratio=GR_ASPECT_2x1;
- l=lod[8-logw];
- s=256.0f;
- t=128.0f;
- is=INT_TRICK(8);it=INT_TRICK(7);
- ws=1;
- hs=1;
- break;
- case 2:
- aspectratio=GR_ASPECT_4x1;
- l=lod[8-logw];
- s=256.0f;
- t=64.0f;
- is=INT_TRICK(8);it=INT_TRICK(6);
- ws=1;
- hs=1;
- break;
- case 3:
- aspectratio=GR_ASPECT_8x1;
- l=lod[8-logw];
- s=256.0f;
- t=32.0f;
- is=INT_TRICK(8);it=INT_TRICK(5);
- ws=1;
- hs=1;
- break;
- case 4:
- aspectratio=GR_ASPECT_8x1;
- l=lod[8-logw];
- s=256.0f;
- t=32.0f;
- is=INT_TRICK(8);it=INT_TRICK(5);
- ws=1;
- hs=2;
- break;
- case 5:
- aspectratio=GR_ASPECT_8x1;
- l=lod[8-logw];
- s=256.0f;
- t=32.0f;
- is=INT_TRICK(8);it=INT_TRICK(5);
- ws=1;
- hs=4;
- break;
- case 6:
- aspectratio=GR_ASPECT_8x1;
- l=lod[8-logw];
- s=256.0f;
- t=32.0f;
- is=INT_TRICK(8);it=INT_TRICK(5);
- ws=1;
- hs=8;
- break;
- case 7:
- aspectratio=GR_ASPECT_8x1;
- l=lod[8-logw];
- s=256.0f;
- t=32.0f;
- is=INT_TRICK(8);it=INT_TRICK(5);
- ws=1;
- hs=16;
- break;
- case 8:
- aspectratio=GR_ASPECT_8x1;
- l=lod[8-logw];
- s=256.0f;
- t=32.0f;
- is=INT_TRICK(8);it=INT_TRICK(5);
- ws=1;
- hs=32;
- break;
- case -1:
- aspectratio=GR_ASPECT_1x2;
- l=lod[8-logh];
- s=128.0f;
- t=256.0f;
- is=INT_TRICK(7);it=INT_TRICK(8);
- ws=1;
- hs=1;
- break;
- case -2:
- aspectratio=GR_ASPECT_1x4;
- l=lod[8-logh];
- s=64.0f;
- t=256.0f;
- is=INT_TRICK(6);it=INT_TRICK(8);
+ ar=logw-logh;
+ /* Hardware only allows a maximum aspect ratio of 8x1, so handle
+ |ar|>3 by scaling the image and using an 8x1 aspect ratio */
+ if (ar>=0) {
+ l=logw;
+ s=256.0;
+ is=INT_TRICK(8);
ws=1;
+ if (ar<3) {
+ t=256>>ar;
+ it=INT_TRICK(8-ar);
+ hs=1;
+ } else {
+ t=32.0;
+ it=INT_TRICK(5);
+ hs=1<<(ar-3);
+ }
+ } else {
+ l=logh;
+ t=256.0;
+ it=INT_TRICK(8);
hs=1;
- break;
- case -3:
- aspectratio=GR_ASPECT_1x8;
- l=lod[8-logh];
- s=32.0f;
- t=256.0f;
- is=INT_TRICK(5);it=INT_TRICK(8);
- ws=1;
- hs=1;
- break;
- case -4:
- aspectratio=GR_ASPECT_1x8;
- l=lod[8-logh];
- s=32.0f;
- t=256.0f;
- is=INT_TRICK(5);it=INT_TRICK(8);
- ws=2;
- hs=1;
- break;
- case -5:
- aspectratio=GR_ASPECT_1x8;
- l=lod[8-logh];
- s=32.0f;
- t=256.0f;
- is=INT_TRICK(5);it=INT_TRICK(8);
- ws=4;
- hs=1;
- break;
- case -6:
- aspectratio=GR_ASPECT_1x8;
- l=lod[8-logh];
- s=32.0f;
- t=256.0f;
- is=INT_TRICK(5);it=INT_TRICK(8);
- ws=8;
- hs=1;
- break;
- case -7:
- aspectratio=GR_ASPECT_1x8;
- l=lod[8-logh];
- s=32.0f;
- t=256.0f;
- is=INT_TRICK(5);it=INT_TRICK(8);
- ws=16;
- hs=1;
- break;
- case -8:
- aspectratio=GR_ASPECT_1x8;
- l=lod[8-logh];
- s=32.0f;
- t=256.0f;
- is=INT_TRICK(5);it=INT_TRICK(8);
- ws=32;
- hs=1;
- break;
- default:
- return 0;
- break;
+ if (-ar<3) {
+ s=256>>-ar;
+ is=INT_TRICK(8+ar);
+ ws=1;
+ } else {
+ s=32.0;
+ is=INT_TRICK(5);
+ ws=1<<(-ar-3);
+ }
}
-
- if(lodlevel)
- (*lodlevel)=l;
-
- if(ar)
- (*ar)=aspectratio;
-
- if(sscale)
- (*sscale)=s;
-
- if(tscale)
- (*tscale)=t;
-
- if(wscale)
- (*wscale)=ws;
-
- if(hscale)
- (*hscale)=hs;
-
- if (i_sscale)
- *i_sscale = is;
-
- if (i_tscale)
- *i_tscale = it;
-
-
+ if (ar<-3) ar=-3;
+ if (ar>3) ar=3;
+
+ /* The above numbers are calculated sensibly and work for Glide3, but
+ we change them to the whacky glide2 values if needed. */
+#ifdef FX_GLIDE3
+ if (lodlevel) *lodlevel=l;
+ if (aspectratio) *aspectratio=ar;
+#else
+ if (lodlevel) *lodlevel=8-l;
+ if (aspectratio) *aspectratio=3-ar;
+#endif
+ if (sscale) *sscale=s;
+ if (tscale) *tscale=t;
+ if (wscale) *wscale=ws;
+ if (hscale) *hscale=hs;
+ if (i_sscale) *i_sscale = is;
+ if (i_tscale) *i_tscale = it;
return 1;
}
@@ -758,12 +617,17 @@ void fxTexGetFormat(GLenum glformat, GrTextureFormat_t *tfmt, GLint *ifmt)
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
+ if(tfmt)
+ (*tfmt)=GR_TEXFMT_RGB_565;
+ if(ifmt)
+ (*ifmt)=GL_RGB;
+ break;
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
if(tfmt)
- (*tfmt)=GR_TEXFMT_RGB_565;
+ (*tfmt)=GR_TEXFMT_ARGB_8888;
if(ifmt)
(*ifmt)=GL_RGB;
break;
@@ -771,12 +635,17 @@ void fxTexGetFormat(GLenum glformat, GrTextureFormat_t *tfmt, GLint *ifmt)
case GL_RGBA:
case GL_RGBA2:
case GL_RGBA4:
+ if(tfmt)
+ (*tfmt)=GR_TEXFMT_ARGB_4444;
+ if(ifmt)
+ (*ifmt)=GL_RGBA;
+ break;
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
if(tfmt)
- (*tfmt)=GR_TEXFMT_ARGB_4444;
+ (*tfmt)=GR_TEXFMT_ARGB_8888;
if(ifmt)
(*ifmt)=GL_RGBA;
break;
@@ -910,23 +779,29 @@ GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
+ texelSize = 2;
+ intFormat = MESA_R5_G6_B5;
+ break;
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- texelSize = 2;
- intFormat = MESA_R5_G6_B5;
+ texelSize = 4;
+ intFormat = MESA_A8_R8_G8_B8;
break;
case 4:
case GL_RGBA:
case GL_RGBA2:
case GL_RGBA4:
+ texelSize = 2;
+ intFormat = MESA_A4_R4_G4_B4;
+ break;
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- texelSize = 2;
- intFormat = MESA_A4_R4_G4_B4;
+ texelSize = 4;
+ intFormat = MESA_A8_R8_G8_B8;
break;
case GL_RGB5_A1:
texelSize = 2;
@@ -948,6 +823,7 @@ GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
mml->data = MALLOC(dstWidth * dstHeight * texelSize);
if (!mml->data)
return GL_FALSE;
+ mml->texelSize = texelSize;
mml->glideFormat = gldformat;
mml->width = dstWidth;
mml->height = dstHeight;
@@ -1060,6 +936,14 @@ GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
texImage->Width, texImage->Height,
format, type, pixels, packing);
break;
+ case GR_TEXFMT_ARGB_8888:
+ dstStride = mml->width * 4;
+ result = _mesa_convert_texsubimage(MESA_A8_R8_G8_B8, xoffset, yoffset,
+ mml->width, mml->height, mml->data,
+ dstStride, width, height,
+ texImage->Width, texImage->Height,
+ format, type, pixels, packing);
+ break;
case GR_TEXFMT_ARGB_1555:
dstStride = mml->width * 2;
result = _mesa_convert_texsubimage(MESA_A1_R5_G5_B5, xoffset, yoffset,
@@ -1149,6 +1033,11 @@ GLvoid *fxDDGetTexImage(GLcontext *ctx, GLenum target, GLint level,
glFormat = GL_RGB;
srcStride = mml->width * 2;
break;
+ case GR_TEXFMT_ARGB_8888:
+ mesaFormat = MESA_A8_R8_G8_B8;
+ glFormat = GL_RGBA;
+ srcStride = mml->width * 4;
+ break;
case GR_TEXFMT_ARGB_4444:
mesaFormat = MESA_A4_R4_G4_B4;
glFormat = GL_RGBA;
diff --git a/xc/extras/Mesa/src/FX/fxdrv.h b/xc/extras/Mesa/src/FX/fxdrv.h
index c85c73d8e..eea75fc56 100644
--- a/xc/extras/Mesa/src/FX/fxdrv.h
+++ b/xc/extras/Mesa/src/FX/fxdrv.h
@@ -162,6 +162,7 @@ typedef struct {
#endif
#endif
+
#define FX_VB_COLOR(fxm, color) \
do { \
if (sizeof(GLint) == 4*sizeof(GLubyte)) { \
@@ -257,6 +258,20 @@ typedef struct {
#define FX_UM_ALPHA_ITERATED 0x04000000
#define FX_UM_ALPHA_CONSTANT 0x08000000
+
+#define PACK_BGRA32(R, G, B, A) \
+ ( (((GLuint) (R)) << 16) | \
+ (((GLuint) (G)) << 8) | \
+ (((GLuint) (B)) ) | \
+ (((GLuint) (A)) << 24) )
+
+#define PACK_RGBA32(R, G, B, A) \
+ ( (((GLuint) (R)) ) | \
+ (((GLuint) (G)) << 8) | \
+ (((GLuint) (B)) << 16) | \
+ (((GLuint) (A)) << 24) )
+
+
typedef void (*tfxRenderVBFunc)(GLcontext *);
/*
@@ -269,6 +284,7 @@ typedef struct MemRange_t {
typedef struct {
GLsizei width, height; /* image size */
+ GLint texelSize; /* How many bytes to a texel */
GrTextureFormat_t glideFormat; /* Glide image format */
unsigned short *data; /* Glide-formated texture image */
} tfxMipMapLevel;
@@ -339,27 +355,20 @@ extern tfxLineClipFunc fxLineClipTab[0x8];
typedef struct {
/* Alpha test */
-
GLboolean alphaTestEnabled;
GrCmpFnc_t alphaTestFunc;
GrAlpha_t alphaTestRefValue;
/* Blend function */
-
GLboolean blendEnabled;
GrAlphaBlendFnc_t blendSrcFuncRGB;
GrAlphaBlendFnc_t blendDstFuncRGB;
GrAlphaBlendFnc_t blendSrcFuncAlpha;
GrAlphaBlendFnc_t blendDstFuncAlpha;
-
- /* Depth test */
-
- GLboolean depthTestEnabled;
- GLboolean depthMask;
- GrCmpFnc_t depthTestFunc;
} tfxUnitsState;
+
/* Flags for render_index.
*/
#define FX_OFFSET 0x1
@@ -380,6 +389,7 @@ typedef struct {
#define FX_NEW_SCISSOR 0x20
#define FX_NEW_COLOR_MASK 0x40
#define FX_NEW_CULL 0x80
+#define FX_NEW_STENCIL 0x100
/* FX struct stored in VB->driver_data.
*/
@@ -421,13 +431,9 @@ extern GLubyte FX_PixelToB[0x10000];
struct tfxMesaContext {
- GuTexPalette glbPalette;
-
GLcontext *glCtx; /* the core Mesa context */
-#if !defined(XFree86Server) && !defined(GLX_DIRECT_RENDERING)
GLvisual *glVis; /* describes the color buffer */
GLframebuffer *glBuffer; /* the ancillary buffers */
-#endif
GLint board; /* the board used for this context */
GLint width, height; /* size of color buffer */
@@ -435,6 +441,7 @@ struct tfxMesaContext {
GrBuffer_t currentFB;
GLboolean bgrOrder;
+ GLuint depthClear;
GrColor_t color;
GrColor_t clearC;
GrAlpha_t clearA;
@@ -444,6 +451,8 @@ struct tfxMesaContext {
tfxUnitsState unitsState;
tfxUnitsState restoreUnitsState; /* saved during multipass */
+ GuTexPalette glbPalette;
+
GLuint tmu_source[FX_NUM_TMU];
GLuint tex_dest[MAX_TEXTURE_UNITS];
GLuint setupindex;
@@ -467,7 +476,6 @@ struct tfxMesaContext {
GLuint texBindNumber;
GLint tmuSrc;
- GLuint lastUnitsMode;
GLuint freeTexMem[FX_NUM_TMU];
MemRange *tmPool;
MemRange *tmFree[FX_NUM_TMU];
@@ -502,8 +510,7 @@ struct tfxMesaContext {
GLboolean haveTwoTMUs; /* True if we really have 2 tmu's */
GLboolean emulateTwoTMUs; /* True if we present 2 tmu's to mesa. */
GLboolean haveAlphaBuffer;
- GLboolean haveZBuffer;
- GLboolean haveDoubleBuffer;
+ GLboolean haveHwStencil;
GLboolean haveGlobalPaletteTexture;
GLint swapInterval;
GLint maxPendingSwapBuffers;
@@ -592,8 +599,6 @@ extern void fxDDTexUseGlbPalette(GLcontext *, GLboolean);
extern void fxDDEnable(GLcontext *, GLenum, GLboolean);
extern void fxDDAlphaFunc(GLcontext *, GLenum, GLclampf);
extern void fxDDBlendFunc(GLcontext *, GLenum, GLenum);
-extern void fxDDDepthMask(GLcontext *, GLboolean);
-extern void fxDDDepthFunc(GLcontext *, GLenum);
extern void fxDDRegisterVB( struct vertex_buffer *VB );
extern void fxDDUnregisterVB( struct vertex_buffer *VB );
diff --git a/xc/extras/Mesa/src/FX/fxglidew.c b/xc/extras/Mesa/src/FX/fxglidew.c
index 5155c825a..f01644a60 100644
--- a/xc/extras/Mesa/src/FX/fxglidew.c
+++ b/xc/extras/Mesa/src/FX/fxglidew.c
@@ -55,6 +55,13 @@
#include <stdlib.h>
#include <string.h>
+
+grStencilFunc_t grStencilFuncPtr = NULL;
+grStencilMask_t grStencilMaskPtr = NULL;
+grStencilOp_t grStencilOpPtr = NULL;
+grBufferClearExt_t grBufferClearExtPtr = NULL;
+
+
FxI32 FX_grGetInteger_NoLock(FxU32 pname)
{
#if !defined(FX_GLIDE3)
@@ -71,6 +78,8 @@ FxI32 FX_grGetInteger_NoLock(FxU32 pname)
case FX_TEXTURE_ALIGN:
/* This is a guess from reading the glide3 docs */
return 8;
+ case FX_ZDEPTH_MAX:
+ return 0xFFFF;
default:
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n");
@@ -90,6 +99,12 @@ FxI32 FX_grGetInteger_NoLock(FxU32 pname)
case FX_TEXTURE_ALIGN:
grname = pname;
break;
+ case FX_ZDEPTH_MAX: {
+ int zvals[2];
+
+ grGet(GR_ZDEPTH_MIN_MAX, 8, zvals);
+ return zvals[0];
+ }
default:
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n");
diff --git a/xc/extras/Mesa/src/FX/fxglidew.h b/xc/extras/Mesa/src/FX/fxglidew.h
index 6da1ea5f3..4ad2942af 100644
--- a/xc/extras/Mesa/src/FX/fxglidew.h
+++ b/xc/extras/Mesa/src/FX/fxglidew.h
@@ -47,7 +47,51 @@
#define __FX_GLIDE_WARPER__
#include <glide.h>
+#include <g3ext.h>
+/*
+ * These are glide extension definitions. These are not
+ * defined in glide.h. They should really be defined in
+ * g3ext.h, but they are not.
+ */
+#if 0
+FX_ENTRY void FX_CALL
+grStencilFunc(GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask);
+
+FX_ENTRY void FX_CALL
+grStencilMask(GrStencil_t write_mask);
+
+FX_ENTRY void FX_CALL
+grStencilOp(
+ GrStencilOp_t stencil_fail,
+ GrStencilOp_t depth_fail,
+ GrStencilOp_t depth_pass);
+
+FX_ENTRY void FX_CALL
+grBufferClearExt(
+ GrColor_t color,
+ GrAlpha_t alpha,
+ FxU32 depth,
+ GrStencil_t stencil);
+#endif
+
+
+typedef void (*grStencilFunc_t)(GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask);
+typedef void (*grStencilMask_t)(GrStencil_t write_mask);
+typedef void (*grStencilOp_t)(GrStencilOp_t stencil_fail, GrStencilOp_t depth_fail, GrStencilOp_t depth_pass);
+typedef void (*grBufferClearExt_t)(GrColor_t color, GrAlpha_t alpha, FxU32 depth, GrStencil_t stencil);
+
+extern grStencilFunc_t grStencilFuncPtr;
+extern grStencilMask_t grStencilMaskPtr;
+extern grStencilOp_t grStencilOpPtr;
+extern grBufferClearExt_t grBufferClearExtPtr;
+
+
+FX_ENTRY void FX_CALL
+grEnable(GrEnableMode_t mode);
+
+FX_ENTRY void FX_CALL
+grEnable(GrEnableMode_t mode);
/*
* General context:
*/
@@ -74,12 +118,13 @@
#define FX_PENDING_BUFFERSWAPS GR_PENDING_BUFFERSWAPS
#define FX_TEXTURE_ALIGN GR_TEXTURE_ALIGN
#endif
+#define FX_ZDEPTH_MAX 0x100
/*
* Genral warper functions for Glide2/Glide3:
*/
-extern FxI32 FX_grGetInteger(FxU32 pname);
extern FxI32 FX_grGetInteger_NoLock(FxU32 pname);
+extern FxI32 FX_grGetInteger(FxU32 pname);
/*
* Glide2 emulation on Glide3:
@@ -253,7 +298,6 @@ typedef struct
#endif
-
/*
* Glide2 functions for Glide3
*/
@@ -567,6 +611,55 @@ extern void FX_grDrawPolygonVertexList(int n, GrVertex *v);
END_CLIP_LOOP(); \
} while (0)
+#define FX_grBufferClearExt(c, a, d, s) \
+ do { \
+ BEGIN_CLIP_LOOP(); \
+ (*grBufferClearExtPtr)(c, a, d, s); \
+ END_CLIP_LOOP(); \
+ } while (0)
+
+/*
+ * Enable/Disable
+ */
+#define FX_grEnable(m) \
+ do { \
+ BEGIN_BOARD_LOCK(); \
+ grEnable(m); \
+ END_BOARD_LOCK(); \
+ } while (0)
+
+#define FX_grDisable(m) \
+ do { \
+ BEGIN_BOARD_LOCK(); \
+ grDisable(m); \
+ END_BOARD_LOCK(); \
+ } while (0)
+
+/*
+ * Stencil operations.
+ */
+#define FX_grStencilFunc(fnc, ref, mask) \
+ do { \
+ BEGIN_BOARD_LOCK(); \
+ (*grStencilFuncPtr)((fnc), (ref), (mask)); \
+ END_BOARD_LOCK(); \
+ } while (0)
+
+#define FX_grStencilMask(write_mask) \
+ do { \
+ BEGIN_BOARD_LOCK(); \
+ (*grStencilMaskPtr)(write_mask); \
+ END_BOARD_LOCK(); \
+ } while (0)
+
+
+#define FX_grStencilOp(stencil_fail, depth_fail, depth_pass) \
+ do { \
+ BEGIN_BOARD_LOCK(); \
+ (*grStencilOpPtr)((stencil_fail), (depth_fail), (depth_pass)); \
+ END_BOARD_LOCK(); \
+ } while (0)
+
#define FX_grDepthMask(m) \
do { \
BEGIN_BOARD_LOCK(); \
diff --git a/xc/extras/Mesa/src/FX/fxsetup.c b/xc/extras/Mesa/src/FX/fxsetup.c
index f1a56650b..f07a2ecec 100644
--- a/xc/extras/Mesa/src/FX/fxsetup.c
+++ b/xc/extras/Mesa/src/FX/fxsetup.c
@@ -62,16 +62,11 @@ static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset);
static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa,
struct gl_texture_object *tObj0,
struct gl_texture_object *tObj1);
-static void fxSetupTexture_NoLock(GLcontext *ctx);
-static void fxSetupTexture(GLcontext *ctx);
-static void fxSetupBlend(GLcontext *ctx);
-static void fxSetupDepthTest(GLcontext *ctx);
-static void fxSetupScissor(GLcontext *ctx);
-static void fxSetupCull(GLcontext *ctx);
static void gl_print_fx_state_flags( const char *msg, GLuint flags);
-/*static GLboolean fxMultipassBlend(struct vertex_buffer *, GLuint);*/
static GLboolean fxMultipassTexture( struct vertex_buffer *, GLuint );
+
+
static void fxTexValidate(GLcontext *ctx, struct gl_texture_object *tObj)
{
tfxTexInfo *ti=fxTMGetTexInfo(tObj);
@@ -478,11 +473,6 @@ static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset)
else
unitsmode=fxGetTexSetConfiguration(ctx,NULL,tObj);
-/* if(fxMesa->lastUnitsMode==unitsmode) */
-/* return; */
-
- fxMesa->lastUnitsMode=unitsmode;
-
fxMesa->stw_hint_state = 0;
FX_grHints_NoLock(GR_HINT_STWHINT,0);
@@ -600,7 +590,8 @@ static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset)
}
}
-static void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset) {
+static void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset)
+{
BEGIN_BOARD_LOCK();
fxSetupTextureSingleTMU_NoLock(ctx, textureset);
END_BOARD_LOCK();
@@ -765,11 +756,6 @@ static void fxSetupTextureDoubleTMU_NoLock(GLcontext *ctx)
unitsmode=fxGetTexSetConfiguration(ctx,tObj0,tObj1);
-/* if(fxMesa->lastUnitsMode==unitsmode) */
-/* return; */
-
- fxMesa->lastUnitsMode=unitsmode;
-
fxMesa->stw_hint_state |= GR_STWHINT_ST_DIFF_TMU1;
FX_grHints_NoLock(GR_HINT_STWHINT, fxMesa->stw_hint_state);
@@ -1055,8 +1041,6 @@ static void fxSetupTextureNone_NoLock(GLcontext *ctx)
localc,
GR_COMBINE_OTHER_NONE,
FXFALSE);
-
- fxMesa->lastUnitsMode=FX_UM_NONE;
}
/************************************************************************/
@@ -1107,7 +1091,8 @@ static void fxSetupTexture_NoLock(GLcontext *ctx)
}
}
-static void fxSetupTexture(GLcontext *ctx) {
+static void fxSetupTexture(GLcontext *ctx)
+{
BEGIN_BOARD_LOCK();
fxSetupTexture_NoLock(ctx);
END_BOARD_LOCK();
@@ -1240,15 +1225,19 @@ void fxDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
static void fxSetupBlend(GLcontext *ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ assert(us->blendEnabled == ctx->Color.BlendEnabled);
- if(us->blendEnabled)
- FX_grAlphaBlendFunction(us->blendSrcFuncRGB,us->blendDstFuncRGB,
- us->blendSrcFuncAlpha,us->blendDstFuncAlpha);
+ if (us->blendEnabled)
+ FX_grAlphaBlendFunction(us->blendSrcFuncRGB, us->blendDstFuncRGB,
+ us->blendSrcFuncAlpha, us->blendDstFuncAlpha);
else
- FX_grAlphaBlendFunction(GR_BLEND_ONE,GR_BLEND_ZERO,GR_BLEND_ONE,GR_BLEND_ZERO);
+ FX_grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO,
+ GR_BLEND_ONE, GR_BLEND_ZERO);
}
+
/************************************************************************/
/************************** Alpha Test SetUp ****************************/
@@ -1256,8 +1245,8 @@ static void fxSetupBlend(GLcontext *ctx)
void fxDDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
GrCmpFnc_t newfunc;
switch(func) {
@@ -1317,83 +1306,118 @@ static void fxSetupAlphaTest(GLcontext *ctx)
FX_grAlphaTestFunction(GR_CMP_ALWAYS);
}
-/************************************************************************/
-/************************** Depth Test SetUp ****************************/
-/************************************************************************/
-void fxDDDepthFunc(GLcontext *ctx, GLenum func)
+/*
+ * Evaluate all depth-test state and make the Glide calls.
+ */
+static void
+fxSetupDepthTest(GLcontext *ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
- GrCmpFnc_t dfunc;
-
- switch(func) {
- case GL_NEVER:
- dfunc=GR_CMP_NEVER;
- break;
- case GL_LESS:
- dfunc=GR_CMP_LESS;
- break;
- case GL_GEQUAL:
- dfunc=GR_CMP_GEQUAL;
- break;
- case GL_LEQUAL:
- dfunc=GR_CMP_LEQUAL;
- break;
- case GL_GREATER:
- dfunc=GR_CMP_GREATER;
- break;
- case GL_NOTEQUAL:
- dfunc=GR_CMP_NOTEQUAL;
- break;
- case GL_EQUAL:
- dfunc=GR_CMP_EQUAL;
- break;
- case GL_ALWAYS:
- dfunc=GR_CMP_ALWAYS;
- break;
- default:
- fprintf(stderr,"fx Driver: internal error in fxDDDepthFunc()\n");
- fxCloseHardware();
- exit(-1);
- break;
+ if (ctx->Depth.Test) {
+ GrCmpFnc_t dfunc;
+ switch (ctx->Depth.Func) {
+ case GL_NEVER:
+ dfunc = GR_CMP_NEVER;
+ break;
+ case GL_LESS:
+ dfunc = GR_CMP_LESS;
+ break;
+ case GL_GEQUAL:
+ dfunc = GR_CMP_GEQUAL;
+ break;
+ case GL_LEQUAL:
+ dfunc = GR_CMP_LEQUAL;
+ break;
+ case GL_GREATER:
+ dfunc = GR_CMP_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ dfunc = GR_CMP_NOTEQUAL;
+ break;
+ case GL_EQUAL:
+ dfunc = GR_CMP_EQUAL;
+ break;
+ case GL_ALWAYS:
+ dfunc = GR_CMP_ALWAYS;
+ break;
+ default:
+ gl_problem(ctx, "bad depth mode in fxSetupDepthTest");
+ dfunc = GR_CMP_ALWAYS;
+ }
+ FX_grDepthBufferFunction(dfunc);
+ FX_grDepthMask(ctx->Depth.Mask);
}
-
- if(dfunc!=us->depthTestFunc) {
- us->depthTestFunc=dfunc;
- fxMesa->new_state |= FX_NEW_DEPTH;
- ctx->Driver.RenderStart = fxSetupFXUnits;
+ else {
+ /* depth test always passes, don't update Z buffer */
+ FX_grDepthBufferFunction(GR_CMP_ALWAYS);
+ FX_grDepthMask(FXFALSE);
}
-
}
-void fxDDDepthMask(GLcontext *ctx, GLboolean flag)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
- if(flag!=us->depthMask) {
- us->depthMask=flag;
- fxMesa->new_state |= FX_NEW_DEPTH;
- ctx->Driver.RenderStart = fxSetupFXUnits;
+/*
+ * Evaluate all stencil state and make the Glide calls.
+ */
+static GrStencil_t
+fxConvertGLStencilOp(GLenum op)
+{
+ switch (op) {
+ case GL_KEEP:
+ return GR_STENCILOP_KEEP;
+ case GL_ZERO:
+ return GR_STENCILOP_ZERO;
+ case GL_REPLACE:
+ return GR_STENCILOP_REPLACE;
+ case GL_INCR:
+ return GR_STENCILOP_INCR_CLAMP;
+ case GL_DECR:
+ return GR_STENCILOP_DECR_CLAMP;
+ case GL_INVERT:
+ return GR_STENCILOP_INVERT;
+ default:
+ gl_problem(NULL, "bad stencil op in fxConvertGLStencilOp");
}
+ return GR_STENCILOP_KEEP; /* never get, silence compiler warning */
}
-static void fxSetupDepthTest(GLcontext *ctx)
+/*
+ * This function is called just before any rendering is done.
+ * It will validate the stencil parameters.
+ */
+static void
+fxSetupStencilTest(GLcontext *ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
-
- if (us->depthTestEnabled) {
- FX_grDepthBufferFunction(us->depthTestFunc);
- FX_grDepthMask(us->depthMask);
+ if (ctx->Stencil.Enabled) {
+ GrStencil_t sfail = fxConvertGLStencilOp(ctx->Stencil.FailFunc);
+ GrStencil_t zfail = fxConvertGLStencilOp(ctx->Stencil.ZFailFunc);
+ GrStencil_t zpass = fxConvertGLStencilOp(ctx->Stencil.ZPassFunc);
+ FX_grStencilOp(sfail, zfail, zpass);
+ FX_grStencilFunc(ctx->Stencil.Function - GL_NEVER,
+ ctx->Stencil.Ref, ctx->Stencil.ValueMask);
+ FX_grStencilMask(ctx->Stencil.WriteMask);
+ FX_grEnable(GR_STENCIL_MODE_EXT);
}
else {
- FX_grDepthBufferFunction(GR_CMP_ALWAYS);
- FX_grDepthMask(FXFALSE);
+ FX_grDisable(GR_STENCIL_MODE_EXT);
}
}
+
+/*
+ * Set the state so that stencil is either enabled or disabled.
+ * This is called from Mesa only. Glide is invoked at
+ * setup time, not now.
+ */
+static void
+fxDDEnableStencil(GLcontext *ctx, GLboolean state)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ (void) state;
+ fxMesa->new_state |= FX_NEW_STENCIL;
+ ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+
/************************************************************************/
/**************************** Color Mask SetUp **************************/
/************************************************************************/
@@ -1591,63 +1615,71 @@ static void fxSetupCull(GLcontext *ctx)
void fxDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDEnable(...)\n");
+ fprintf(stderr,"fxmesa: fxDDEnable(...)\n");
}
switch(cap) {
- case GL_ALPHA_TEST:
- if(state!=us->alphaTestEnabled) {
- us->alphaTestEnabled=state;
- fxMesa->new_state |= FX_NEW_ALPHA;
+ case GL_ALPHA_TEST:
+ if(state!=us->alphaTestEnabled) {
+ us->alphaTestEnabled=state;
+ fxMesa->new_state |= FX_NEW_ALPHA;
+ ctx->Driver.RenderStart = fxSetupFXUnits;
+ }
+ break;
+ case GL_BLEND:
+ if(state!=us->blendEnabled) {
+ us->blendEnabled=state;
+ fxMesa->new_state |= FX_NEW_BLEND;
+ ctx->Driver.RenderStart = fxSetupFXUnits;
+ }
+ break;
+ case GL_DEPTH_TEST:
+ fxMesa->new_state |= FX_NEW_DEPTH;
ctx->Driver.RenderStart = fxSetupFXUnits;
- }
- break;
- case GL_BLEND:
- if(state!=us->blendEnabled) {
- us->blendEnabled=state;
- fxMesa->new_state |= FX_NEW_BLEND;
+ break;
+ case GL_DITHER:
+ if (state)
+ FX_grDitherMode(GR_DITHER_4x4);
+ else
+ FX_grDitherMode(GR_DITHER_DISABLE);
+ break;
+ case GL_SCISSOR_TEST:
+ fxMesa->new_state |= FX_NEW_SCISSOR;
ctx->Driver.RenderStart = fxSetupFXUnits;
- }
- break;
- case GL_DEPTH_TEST:
- if(state!=us->depthTestEnabled) {
- us->depthTestEnabled=state;
- fxMesa->new_state |= FX_NEW_DEPTH;
+ break;
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ fxDDTexUseGlbPalette(ctx, state);
+ break;
+ case GL_FOG:
+ fxMesa->new_state |= FX_NEW_FOG;
ctx->Driver.RenderStart = fxSetupFXUnits;
- }
- break;
- case GL_SCISSOR_TEST:
- fxMesa->new_state |= FX_NEW_SCISSOR;
- ctx->Driver.RenderStart = fxSetupFXUnits;
- break;
- case GL_SHARED_TEXTURE_PALETTE_EXT:
- fxDDTexUseGlbPalette(ctx, state);
- break;
- case GL_FOG:
- fxMesa->new_state |= FX_NEW_FOG;
- ctx->Driver.RenderStart = fxSetupFXUnits;
- break;
- case GL_CULL_FACE:
- fxMesa->new_state |= FX_NEW_CULL;
- ctx->Driver.RenderStart = fxSetupFXUnits;
- break;
- case GL_LINE_SMOOTH:
- case GL_LINE_STIPPLE:
- case GL_POINT_SMOOTH:
- case GL_POLYGON_SMOOTH:
- case GL_TEXTURE_2D:
+ break;
+ case GL_CULL_FACE:
+ fxMesa->new_state |= FX_NEW_CULL;
+ ctx->Driver.RenderStart = fxSetupFXUnits;
+ break;
+ case GL_LINE_SMOOTH:
+ case GL_LINE_STIPPLE:
+ case GL_POINT_SMOOTH:
+ case GL_POLYGON_SMOOTH:
+ case GL_TEXTURE_2D:
fxMesa->new_state |= FX_NEW_TEXTURING;
ctx->Driver.RenderStart = fxSetupFXUnits;
break;
- default:
- ; /* XXX no-op? */
+ case GL_STENCIL_TEST:
+ fxMesa->new_state |= FX_NEW_STENCIL;
+ ctx->Driver.RenderStart = fxSetupFXUnits;
+ break;
+ default:
+ ; /* no-op */
}
}
+
#if 0
/*
Multipass to do GL_BLEND texture functions
@@ -1676,6 +1708,12 @@ static GLboolean fxMultipassBlend(struct vertex_buffer *VB, GLuint pass)
}
fxDDDepthMask(ctx, FALSE);
}
+ /*
+ * Disable stencil as well.
+ */
+ if (ctx->Stencil.Enabled) {
+ fxDDEnableStencil(ctx, GL_FALSE);
+ }
/* Enable Cc*Ct mode */
/* XXX Set the Constant Color ? */
fxDDEnable(ctx, GL_BLEND, GL_TRUE);
@@ -1692,6 +1730,7 @@ static GLboolean fxMultipassBlend(struct vertex_buffer *VB, GLuint pass)
fxSetupTextureSingleTMU(ctx, XXX);
fxSetupBlend(ctx);
fxSetupDepthTest(ctx);
+ fxSetupStencilText(ctx);
break;
}
@@ -1737,13 +1776,15 @@ static GLboolean fxMultipassTexture( struct vertex_buffer *VB, GLuint pass )
case GL_ALWAYS:
break;
default:
- fxDDDepthFunc( ctx, GL_EQUAL );
+ /*fxDDDepthFunc( ctx, GL_EQUAL );*/
+ FX_grDepthBufferFunction(GR_CMP_EQUAL);
break;
}
- fxDDDepthMask( ctx, GL_FALSE );
+ /*fxDDDepthMask( ctx, GL_FALSE ); */
+ FX_grDepthMask(FXFALSE);
}
-
+ fxDDEnableStencil(ctx, GL_FALSE);
if (ctx->Texture.Unit[1].EnvMode == GL_MODULATE) {
fxDDEnable( ctx, GL_BLEND, GL_TRUE );
fxDDBlendFunc( ctx, GL_DST_COLOR, GL_ZERO );
@@ -1763,6 +1804,7 @@ static GLboolean fxMultipassTexture( struct vertex_buffer *VB, GLuint pass )
fxSetupTextureSingleTMU( ctx, 0 );
fxSetupBlend( ctx );
fxSetupDepthTest( ctx );
+ fxSetupStencilTest( ctx );
break;
}
@@ -1820,10 +1862,13 @@ void fxSetupFXUnits( GLcontext *ctx )
if (newstate & FX_NEW_ALPHA)
fxSetupAlphaTest(ctx);
-
+
if (newstate & FX_NEW_DEPTH)
fxSetupDepthTest(ctx);
+ if (newstate & FX_NEW_STENCIL)
+ fxSetupStencilTest(ctx);
+
if (newstate & FX_NEW_FOG)
fxSetupFog(ctx);
@@ -1835,14 +1880,11 @@ void fxSetupFXUnits( GLcontext *ctx )
if (newstate & FX_NEW_CULL)
fxSetupCull(ctx);
-
fxMesa->new_state = 0;
/* ctx->Driver.RenderStart = 0; */
}
}
-
-
#else
diff --git a/xc/extras/Mesa/src/FX/fxtexman.c b/xc/extras/Mesa/src/FX/fxtexman.c
index 2ffaeadd7..5066efa55 100644
--- a/xc/extras/Mesa/src/FX/fxtexman.c
+++ b/xc/extras/Mesa/src/FX/fxtexman.c
@@ -545,12 +545,8 @@ void fxTMReloadSubMipMapLevel(fxMesaContext fxMesa,
fxTexGetInfo(ti->mipmapLevel[0].width, ti->mipmapLevel[0].height,
&lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- if((ti->info.format==GR_TEXFMT_INTENSITY_8) ||
- (ti->info.format==GR_TEXFMT_P_8) ||
- (ti->info.format==GR_TEXFMT_ALPHA_8))
- data=ti->mipmapLevel[level].data+((yoffset*ti->mipmapLevel[level].width)>>1);
- else
- data=ti->mipmapLevel[level].data+yoffset*ti->mipmapLevel[level].width;
+ data=ti->mipmapLevel[level].data +
+ yoffset*ti->mipmapLevel[level].width*ti->mipmapLevel[level].texelSize;
switch(tmu) {
case FX_TMU0:
diff --git a/xc/extras/Mesa/src/FX/fxtritmp.h b/xc/extras/Mesa/src/FX/fxtritmp.h
index 9e59b4fc7..6411d167a 100644
--- a/xc/extras/Mesa/src/FX/fxtritmp.h
+++ b/xc/extras/Mesa/src/FX/fxtritmp.h
@@ -307,11 +307,11 @@ static void TAG(fx_line)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint pv)
GrVertex *v2 = (GrVertex *)gWin[e2].f;
GLfloat w = ctx->Line.Width*.5;
- if (IND & FX_FLAT)
- {
- /* Flat shading seems broke. Explicitly set vertex colors to same color */
- GOURAUD2(v1,color[pv]);
- GOURAUD2(v2,color[pv]);
+ if (IND & FX_FLAT) {
+ v1->r = v2->r = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][0]);
+ v1->g = v2->g = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][1]);
+ v1->b = v2->b = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][2]);
+ v1->a = v2->a = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][3]);
}
else if (IND & FX_TWOSIDE)
{
@@ -334,8 +334,7 @@ static void TAG(fx_line)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint pv)
else
DRAW_LINE(v1,v2,w);
- if (IND & FX_FRONT_BACK)
- {
+ if (IND & FX_FRONT_BACK) {
FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
ctx->Color.ColorMask[GCOMP] ||
ctx->Color.ColorMask[BCOMP],
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c
index 2ae1001ee..47d1139a5 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c
@@ -2483,6 +2483,8 @@ void _gamma_NewList(GLuint list, GLenum mode)
void _gamma_Normal3b(GLbyte nx, GLbyte ny, GLbyte nz)
{
+ GLfloat x,y,z;
+
DEBUG_GLCMDS(("Normal3b: %d %d %d\n", nx, ny, nz));
_gamma_Normal3f((GLfloat)nx,(GLfloat)ny,(GLfloat)nz);
@@ -2490,6 +2492,8 @@ void _gamma_Normal3b(GLbyte nx, GLbyte ny, GLbyte nz)
void _gamma_Normal3bv(const GLbyte *v)
{
+ GLfloat p[3];
+
DEBUG_GLCMDS(("Normal3bv: %d %d %d\n", v[0], v[1], v[2]));
_gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
@@ -2528,6 +2532,8 @@ void _gamma_Normal3fv(const GLfloat *v)
void _gamma_Normal3i(GLint nx, GLint ny, GLint nz)
{
+ GLfloat x,y,z;
+
DEBUG_GLCMDS(("Normal3i: %d %d %d\n", (int)nx, (int)ny, (int)nz));
_gamma_Normal3f((GLfloat)nx,(GLfloat)ny,(GLfloat)nz);
@@ -2535,6 +2541,8 @@ void _gamma_Normal3i(GLint nx, GLint ny, GLint nz)
void _gamma_Normal3iv(const GLint *v)
{
+ GLfloat p[3];
+
DEBUG_GLCMDS(("Normal3iv: %d %d %d\n", (int)v[0], (int)v[1], (int)v[2]));
_gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
@@ -2542,6 +2550,8 @@ void _gamma_Normal3iv(const GLint *v)
void _gamma_Normal3s(GLshort nx, GLshort ny, GLshort nz)
{
+ GLfloat x,y,z;
+
DEBUG_GLCMDS(("Normal3s: %d %d %d\n", nx, ny, nz));
_gamma_Normal3f((GLfloat)nx,(GLfloat)ny,(GLfloat)nz);
@@ -2549,6 +2559,8 @@ void _gamma_Normal3s(GLshort nx, GLshort ny, GLshort nz)
void _gamma_Normal3sv(const GLshort *v)
{
+ GLfloat p[3];
+
DEBUG_GLCMDS(("Normal3sv: %d %d %d\n", v[0], v[1], v[2]));
_gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
@@ -4146,6 +4158,8 @@ void _gamma_Vertex2fv(const GLfloat *v)
void _gamma_Vertex2i(GLint x, GLint y)
{
+ GLfloat a,b;
+
DEBUG_GLCMDS(("Vertex2i: %d %d\n", (int)x, (int)y));
_gamma_Vertex2f((GLfloat)x,(GLfloat)y);
@@ -4153,6 +4167,8 @@ void _gamma_Vertex2i(GLint x, GLint y)
void _gamma_Vertex2iv(const GLint *v)
{
+ GLfloat p[2];
+
DEBUG_GLCMDS(("Vertex2iv: %d %d\n", (int)v[0], (int)v[1]));
_gamma_Vertex2f((GLfloat)v[0],(GLfloat)v[1]);
@@ -4160,6 +4176,8 @@ void _gamma_Vertex2iv(const GLint *v)
void _gamma_Vertex2s(GLshort x, GLshort y)
{
+ GLfloat a,b;
+
DEBUG_GLCMDS(("Vertex2s: %d %d\n", x, y));
_gamma_Vertex2f((GLfloat)x,(GLfloat)y);
@@ -4167,6 +4185,8 @@ void _gamma_Vertex2s(GLshort x, GLshort y)
void _gamma_Vertex2sv(const GLshort *v)
{
+ GLfloat p[2];
+
DEBUG_GLCMDS(("Vertex2sv: %d %d\n", v[0], v[1]));
_gamma_Vertex2f((GLfloat)v[0],(GLfloat)v[1]);
@@ -4205,6 +4225,8 @@ void _gamma_Vertex3fv(const GLfloat *v)
void _gamma_Vertex3i(GLint x, GLint y, GLint z)
{
+ GLfloat a,b,c;
+
DEBUG_GLCMDS(("Vertex3i: %d %d %d\n", (int)x, (int)y, (int)z));
_gamma_Vertex3f((GLfloat)x,(GLfloat)y,(GLfloat)z);
@@ -4212,6 +4234,8 @@ void _gamma_Vertex3i(GLint x, GLint y, GLint z)
void _gamma_Vertex3iv(const GLint *v)
{
+ GLfloat p[3];
+
DEBUG_GLCMDS(("Vertex3iv: %d %d %d\n", (int)v[0], (int)v[1], (int)v[2]));
_gamma_Vertex3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
@@ -4219,6 +4243,8 @@ void _gamma_Vertex3iv(const GLint *v)
void _gamma_Vertex3s(GLshort x, GLshort y, GLshort z)
{
+ GLfloat a,b,c;
+
DEBUG_GLCMDS(("Vertex3s: %d %d %d\n", x, y, z));
_gamma_Vertex3f((GLfloat)x,(GLfloat)y,(GLfloat)z);
@@ -4226,6 +4252,8 @@ void _gamma_Vertex3s(GLshort x, GLshort y, GLshort z)
void _gamma_Vertex3sv(const GLshort *v)
{
+ GLfloat p[3];
+
DEBUG_GLCMDS(("Vertex3sv: %d %d %d\n", v[0], v[1], v[2]));
_gamma_Vertex3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
@@ -4265,6 +4293,8 @@ void _gamma_Vertex4fv(const GLfloat *v)
void _gamma_Vertex4i(GLint x, GLint y, GLint z, GLint w)
{
+ GLfloat a,b,c,d;
+
DEBUG_GLCMDS(("Vertex4i: %d %d %d %d\n", (int)x, (int)y, (int)z, (int)w));
_gamma_Vertex4f((GLfloat)x,(GLfloat)y,(GLfloat)z,(GLfloat)w);
@@ -4272,6 +4302,8 @@ void _gamma_Vertex4i(GLint x, GLint y, GLint z, GLint w)
void _gamma_Vertex4iv(const GLint *v)
{
+ GLfloat p[4];
+
DEBUG_GLCMDS(("Vertex4iv: %d %d %d %d\n",
(int)v[0], (int)v[1], (int)v[2], (int)v[3]));
@@ -4280,6 +4312,8 @@ void _gamma_Vertex4iv(const GLint *v)
void _gamma_Vertex4s(GLshort x, GLshort y, GLshort z, GLshort w)
{
+ GLfloat a,b,c,d;
+
DEBUG_GLCMDS(("Vertex4s: %d %d %d %d\n", x, y, z, w));
_gamma_Vertex4f((GLfloat)x,(GLfloat)y,(GLfloat)z,(GLfloat)w);
@@ -4287,6 +4321,8 @@ void _gamma_Vertex4s(GLshort x, GLshort y, GLshort z, GLshort w)
void _gamma_Vertex4sv(const GLshort *v)
{
+ GLfloat p[4];
+
DEBUG_GLCMDS(("Vertex4sv: %d %d %d %d\n", v[0], v[1], v[2], v[3]));
_gamma_Vertex4f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2],(GLfloat)v[3]);
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c
index 7d74318e1..0bafa3190 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c
@@ -68,18 +68,12 @@ GLboolean tdfxInitHW(__DRIdrawablePrivate *driDrawPriv,
fxMesa->haveTwoTMUs=GL_TRUE;
/* !!! We are forcing these !!! */
- fxMesa->haveDoubleBuffer=GL_TRUE;
fxMesa->haveAlphaBuffer=GL_FALSE;
- fxMesa->haveZBuffer=GL_TRUE;
fxMesa->haveGlobalPaletteTexture=GL_FALSE;
fxMesa->glideContext = FX_grSstWinOpen_NoLock((FxU32)-1, GR_RESOLUTION_NONE,
GR_REFRESH_NONE,
-#if FXMESA_USE_ARGB
- GR_COLORFORMAT_ARGB,
-#else
GR_COLORFORMAT_ABGR,
-#endif
GR_ORIGIN_LOWER_LEFT, 2, 1);
grDRIResetSAREA();
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c
index 0a99539e8..b40f0f054 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c
@@ -107,7 +107,6 @@ void XMesaResetDriver(__DRIscreenPrivate *sPriv)
sPriv->private = NULL;
}
-
GLvisual *XMesaCreateVisual(Display *dpy,
__DRIscreenPrivate *driScrnPriv,
const XVisualInfo *visinfo,
@@ -150,6 +149,18 @@ GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis,
cPriv->hHWContext = driContextPriv->hHWContext;
cPriv->tdfxScrnPriv = sPriv;
+ /* deviceID = 0x05 = Voodoo3 */
+ /* deviceID = 0x09 = Voodoo5 (and Voodoo5?) */
+ cPriv->haveHwStencil = sPriv->deviceID == 0x9 && sPriv->cpp == 4;
+
+ cPriv->glVis=mesaVis;
+ cPriv->glBuffer=gl_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->StencilBits > 0 && !cPriv->haveHwStencil,
+ mesaVis->AccumRedBits > 0,
+ GL_FALSE /* software alpha channel */
+ );
+
cPriv->screen_width=sPriv->width;
cPriv->screen_height=sPriv->height;
cPriv->new_state = ~0;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c
index 974ee3b4f..c8ec93434 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c
@@ -749,7 +749,7 @@ DualMXWriteBitmap(ScrnInfoPtr pScrn,
DualMXLoadCoord(pScrn, x, y, x+w, h, 0, 1);
if(bg == -1) {
- /* >>>>> set fg <<<<<<<< */
+ /* === set fg === */
REPLICATE(fg);
GLINT_WAIT(3);
if (rop == GXcopy) {
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c
index 1e7fad981..b728093d7 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c
@@ -23,14 +23,16 @@
* Dirk Hohndel, <hohndel@suse.de>
* Stefan Dirsch, <sndirsch@suse.de>
* Mark Vojkovich, <mvojkovi@ucsd.edu>
+ * Michel Dänzer, <michdaen@iiic.ethz.ch>
*
* this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen and
* Siemens Nixdorf Informationssysteme
*
* Permedia 2 accelerated options.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c,v 1.17 1999/07/11 08:49:26 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c,v 1.23 2000/02/25 21:02:50 dawes Exp $ */
+#include "Xarch.h"
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
@@ -39,18 +41,26 @@
#include "xf86Pci.h"
#include "miline.h"
-#define PSZ 8
-#include "cfb.h"
-#undef PSZ
-#include "cfb16.h"
-#include "cfb24.h"
-#include "cfb32.h"
+
+#include "fb.h"
#include "glint_regs.h"
#include "glint.h"
#include "xaalocal.h" /* For replacements */
+#define DEBUG 0
+
+#if DEBUG
+# define TRACE_ENTER(str) ErrorF("pm2_accel: " str " %d\n",pScrn->scrnIndex)
+# define TRACE_EXIT(str) ErrorF("pm2_accel: " str " done\n")
+# define TRACE(str) ErrorF("pm2_accel trace: " str "\n")
+#else
+# define TRACE_ENTER(str)
+# define TRACE_EXIT(str)
+# define TRACE(str)
+#endif
+
static void Permedia2SetupForFillRectSolid(ScrnInfoPtr pScrn, int color,
int rop, unsigned int planemask);
static void Permedia2SubsequentFillRectSolid(ScrnInfoPtr pScrn, int x,
@@ -79,13 +89,7 @@ static void Permedia2SetupForSolidLine(ScrnInfoPtr pScrn, int color,
int rop, unsigned int planemask);
static void Permedia2SubsequentHorVertLine(ScrnInfoPtr pScrn, int x, int y,
int len, int dir);
-static void Permedia2SubsequentSolidBresenhamLine8bpp(ScrnInfoPtr pScrn,
- int x, int y, int dmaj, int dmin, int e,
- int len, int octant);
-static void Permedia2SubsequentSolidBresenhamLine16bpp(ScrnInfoPtr pScrn,
- int x, int y, int dmaj, int dmin, int e,
- int len, int octant);
-static void Permedia2SubsequentSolidBresenhamLine32bpp(ScrnInfoPtr pScrn,
+static void Permedia2SubsequentSolidBresenhamLine(ScrnInfoPtr pScrn,
int x, int y, int dmaj, int dmin, int e,
int len, int octant);
static void Permedia2WriteBitmap(ScrnInfoPtr pScrn, int x, int y, int w, int h,
@@ -139,6 +143,12 @@ static void Permedia2PolySegmentThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC,
#define MAX_FIFO_ENTRIES 256
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+# define STIPPLE_SWAP 1<<18 /* Mirror stipple pattern horizontally */
+#else
+# define STIPPLE_SWAP 0
+#endif
+
void
Permedia2InitializeEngine(ScrnInfoPtr pScrn)
{
@@ -146,6 +156,8 @@ Permedia2InitializeEngine(ScrnInfoPtr pScrn)
/* Initialize the Accelerator Engine to defaults */
+ TRACE_ENTER("Permedia2InitializeEngine");
+
GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ScissorMode);
GLINT_SLOW_WRITE_REG(UNIT_ENABLE, FBWriteMode);
GLINT_SLOW_WRITE_REG(0, dXSub);
@@ -183,14 +195,26 @@ Permedia2InitializeEngine(ScrnInfoPtr pScrn)
GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBSourceBase);
GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBWindowBase);
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ pGlint->RasterizerSwap = 1;
+#else
+ pGlint->RasterizerSwap = 0;
+#endif
+
switch (pScrn->bitsPerPixel) {
case 8:
pGlint->PixelWidth = 0x0; /* 8 Bits */
pGlint->TexMapFormat = pGlint->pprod;
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ pGlint->RasterizerSwap |= 3<<15; /* Swap host data */
+#endif
break;
case 16:
pGlint->PixelWidth = 0x1; /* 16 Bits */
pGlint->TexMapFormat = pGlint->pprod | 1<<19;
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ pGlint->RasterizerSwap |= 2<<15; /* Swap host data */
+#endif
break;
case 24:
pGlint->PixelWidth = 0x4; /* 24 Bits */
@@ -223,6 +247,8 @@ Permedia2InitializeEngine(ScrnInfoPtr pScrn)
GLINT_SLOW_WRITE_REG(0, StartXSub);
GLINT_SLOW_WRITE_REG(0, StartY);
GLINT_SLOW_WRITE_REG(0, GLINTCount);
+
+ TRACE_EXIT("Permedia2InitializeEngine");
}
Bool
@@ -262,17 +288,8 @@ Permedia2AccelInit(ScreenPtr pScreen)
infoPtr->PolylinesThinSolidFlags = 0;
infoPtr->SetupForSolidLine = Permedia2SetupForSolidLine;
infoPtr->SubsequentSolidHorVertLine = Permedia2SubsequentHorVertLine;
- switch(pScrn->bitsPerPixel) {
- case 8: infoPtr->SubsequentSolidBresenhamLine =
- Permedia2SubsequentSolidBresenhamLine8bpp;
- break;
- case 16: infoPtr->SubsequentSolidBresenhamLine =
- Permedia2SubsequentSolidBresenhamLine16bpp;
- break;
- case 32: infoPtr->SubsequentSolidBresenhamLine =
- Permedia2SubsequentSolidBresenhamLine32bpp;
- break;
- }
+ infoPtr->SubsequentSolidBresenhamLine =
+ Permedia2SubsequentSolidBresenhamLine;
infoPtr->PolySegmentThinSolid = Permedia2PolySegmentThinSolidWrapper;
infoPtr->PolylinesThinSolid = Permedia2PolylinesThinSolidWrapper;
infoPtr->SetupForSolidFill = Permedia2SetupForFillRectSolid;
@@ -483,6 +500,7 @@ Permedia2SetupForScreenToScreenCopy(ScrnInfoPtr pScrn,
unsigned int planemask, int transparency_color)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
+ TRACE_ENTER("Permedia2SetupForScreenToScreenCopy");
pGlint->BltScanDirection = 0;
if (xdir == 1) pGlint->BltScanDirection |= XPositive;
@@ -502,6 +520,7 @@ Permedia2SetupForScreenToScreenCopy(ScrnInfoPtr pScrn,
FBRM_DstEnable;
}
LOADROP(rop);
+ TRACE_EXIT("Permedia2SetupForScreenToScreenCopy");
}
static void
@@ -511,6 +530,7 @@ Permedia2SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
GLINTPtr pGlint = GLINTPTR(pScrn);
char align;
+ TRACE_ENTER("Permedia2SubsequentScreenToScreenCopy");
/* We can only use GXcopy for Packed modes */
if (pGlint->ROP != GXcopy) {
GLINT_WAIT(5);
@@ -528,6 +548,7 @@ Permedia2SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
}
GLINT_WRITE_REG(PrimitiveRectangle | pGlint->BltScanDirection, Render);
+ TRACE_EXIT("Permedia2SubsequentScreenToScreenCopy");
}
@@ -543,6 +564,7 @@ Permedia2PolylinesThinSolidWrapper(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
GLINTPtr pGlint = GLINTPTR(infoRec->pScrn);
pGlint->CurrentGC = pGC;
+ pGlint->CurrentDrawable = pDraw;
if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn);
XAAPolyLines(pDraw, pGC, mode, npt, pPts);
}
@@ -557,6 +579,7 @@ Permedia2PolySegmentThinSolidWrapper(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
GLINTPtr pGlint = GLINTPTR(infoRec->pScrn);
pGlint->CurrentGC = pGC;
+ pGlint->CurrentDrawable = pDraw;
if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn);
XAAPolySegment(pDraw, pGC, nseg, pSeg);
}
@@ -600,11 +623,10 @@ Permedia2SubsequentHorVertLine(ScrnInfoPtr pScrn,int x,int y,int len,int dir)
}
static void
-Permedia2SubsequentSolidBresenhamLine8bpp( ScrnInfoPtr pScrn,
+Permedia2SubsequentSolidBresenhamLine( ScrnInfoPtr pScrn,
int x, int y, int dmaj, int dmin, int e, int len, int octant)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
- cfbPrivGCPtr devPriv;
if(dmaj == dmin) {
GLINT_WAIT(6);
@@ -627,93 +649,13 @@ Permedia2SubsequentSolidBresenhamLine8bpp( ScrnInfoPtr pScrn,
return;
}
- devPriv = cfbGetGCPrivate(pGlint->CurrentGC);
-
- cfbBresS(devPriv->rop, devPriv->and, devPriv->xor,
- (unsigned long*)pGlint->FbBase, pScrn->displayWidth >> 2,
+ fbBres(pGlint->CurrentDrawable, pGlint->CurrentGC, 0,
(octant & XDECREASING) ? -1 : 1,
(octant & YDECREASING) ? -1 : 1,
(octant & YMAJOR) ? Y_AXIS : X_AXIS,
- x, y, dmin + e, dmin, dmin - dmaj, len);
+ x, y, dmin + e, dmin, -dmaj, len);
}
-static void
-Permedia2SubsequentSolidBresenhamLine16bpp( ScrnInfoPtr pScrn,
- int x, int y, int dmaj, int dmin, int e, int len, int octant)
-{
- GLINTPtr pGlint = GLINTPTR(pScrn);
- cfbPrivGCPtr devPriv;
-
- if(dmaj == dmin) {
- GLINT_WAIT(6);
- if(octant & YDECREASING) {
- GLINT_WRITE_REG(-1<<16, dY);
- } else {
- GLINT_WRITE_REG(1<<16, dY);
- }
-
- if(octant & XDECREASING) {
- GLINT_WRITE_REG(-1<<16, dXDom);
- } else {
- GLINT_WRITE_REG(1<<16, dXDom);
- }
-
- GLINT_WRITE_REG(x<<16, StartXDom);
- GLINT_WRITE_REG(y<<16, StartY);
- GLINT_WRITE_REG(len,GLINTCount);
- GLINT_WRITE_REG(PrimitiveLine, Render);
- return;
- }
-
- devPriv = cfbGetGCPrivate(pGlint->CurrentGC);
-
- cfb16BresS(devPriv->rop, devPriv->and, devPriv->xor,
- (unsigned long*)pGlint->FbBase, pScrn->displayWidth >> 1,
- (octant & XDECREASING) ? -1 : 1,
- (octant & YDECREASING) ? -1 : 1,
- (octant & YMAJOR) ? Y_AXIS : X_AXIS,
- x, y, dmin + e, dmin, dmin - dmaj, len);
-}
-
-static void
-Permedia2SubsequentSolidBresenhamLine32bpp( ScrnInfoPtr pScrn,
- int x, int y, int dmaj, int dmin, int e, int len, int octant)
-{
- GLINTPtr pGlint = GLINTPTR(pScrn);
- cfbPrivGCPtr devPriv;
-
- if(dmaj == dmin) {
- GLINT_WAIT(6);
- if(octant & YDECREASING) {
- GLINT_WRITE_REG(-1<<16, dY);
- } else {
- GLINT_WRITE_REG(1<<16, dY);
- }
-
- if(octant & XDECREASING) {
- GLINT_WRITE_REG(-1<<16, dXDom);
- } else {
- GLINT_WRITE_REG(1<<16, dXDom);
- }
-
- GLINT_WRITE_REG(x<<16, StartXDom);
- GLINT_WRITE_REG(y<<16, StartY);
- GLINT_WRITE_REG(len,GLINTCount);
- GLINT_WRITE_REG(PrimitiveLine, Render);
- return;
- }
-
- devPriv = cfbGetGCPrivate(pGlint->CurrentGC);
-
- cfb32BresS(devPriv->rop, devPriv->and, devPriv->xor,
- (unsigned long*)pGlint->FbBase, pScrn->displayWidth,
- (octant & XDECREASING) ? -1 : 1,
- (octant & YDECREASING) ? -1 : 1,
- (octant & YMAJOR) ? Y_AXIS : X_AXIS,
- x, y, dmin + e, dmin, dmin - dmaj, len);
-}
-
-
static void
Permedia2SetupForFillRectSolid24bpp(ScrnInfoPtr pScrn, int color,
int rop, unsigned int planemask)
@@ -737,6 +679,7 @@ Permedia2SetupForFillRectSolid(ScrnInfoPtr pScrn, int color,
int rop, unsigned int planemask)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
+ TRACE_ENTER("Permedia2SetupForFillRectSolid");
REPLICATE(color);
@@ -753,6 +696,7 @@ Permedia2SetupForFillRectSolid(ScrnInfoPtr pScrn, int color,
GLINT_WRITE_REG(pGlint->pprod|FBRM_DstEnable|FBRM_Packed, FBReadMode);
}
LOADROP(rop);
+ TRACE_EXIT("Permedia2SetupForFillRectSolid");
}
static void
@@ -769,6 +713,7 @@ Permedia2SubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y, int w, int h)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
int speed = 0;
+ TRACE_ENTER("Permedia2SubsequentFillRectSolid");
if (pGlint->ROP == GXcopy) {
GLINT_WAIT(3);
@@ -782,6 +727,7 @@ Permedia2SubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y, int w, int h)
speed = 0;
}
GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | speed, Render);
+ TRACE_EXIT("Permedia2SubsequentFillRectSolid");
}
static void MoveBYTE(
@@ -840,6 +786,7 @@ static void MoveDWORDS(
*(dest + 2) = *(src + 2);
}
+
static void
Permedia2SetupForMono8x8PatternFill24bpp(ScrnInfoPtr pScrn,
int patternx, int patterny,
@@ -882,6 +829,7 @@ Permedia2SetupForMono8x8PatternFill(ScrnInfoPtr pScrn,
unsigned int planemask)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
+ TRACE_ENTER("Permedia2SetupForMono8x8PatternFill");
if (bg == -1) pGlint->FrameBufferReadMode = -1;
else pGlint->FrameBufferReadMode = 0;
@@ -891,6 +839,10 @@ Permedia2SetupForMono8x8PatternFill(ScrnInfoPtr pScrn,
REPLICATE(pGlint->ForeGroundColor);
REPLICATE(pGlint->BackGroundColor);
+#if DEBUG
+ ErrorF("patternx: %x patterny: %x\n", patternx, patterny);
+#endif
+
GLINT_WAIT(13);
DO_PLANEMASK(planemask);
GLINT_WRITE_REG((patternx & 0xFF), AreaStipplePattern0);
@@ -910,6 +862,7 @@ Permedia2SetupForMono8x8PatternFill(ScrnInfoPtr pScrn,
GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
}
LOADROP(rop);
+ TRACE_EXIT("Permedia2SetupForMono8x8PatternFill");
}
static void
@@ -926,7 +879,7 @@ Permedia2SubsequentMono8x8PatternFillRect24bpp(ScrnInfoPtr pScrn,
if (pGlint->FrameBufferReadMode != -1) {
GLINT_WRITE_REG(pGlint->BackGroundColor, ConstantColor);
GLINT_WRITE_REG(patternx<<7|patterny<<12| ASM_InvertPattern |
- UNIT_ENABLE, AreaStippleMode);
+ STIPPLE_SWAP | UNIT_ENABLE, AreaStippleMode);
GLINT_WRITE_REG(AreaStippleEnable | XPositive |
YPositive | PrimitiveRectangle, Render);
}
@@ -945,6 +898,8 @@ Permedia2SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn,
{
GLINTPtr pGlint = GLINTPTR(pScrn);
+ TRACE_ENTER("Permedia2SubsequentMono8x8PatternFillRect()");
+
GLINT_WAIT(9);
Permedia2LoadCoord(pScrn, x, y, w, h);
@@ -952,14 +907,14 @@ Permedia2SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn,
if (pGlint->ROP == GXcopy) {
GLINT_WRITE_REG(pGlint->BackGroundColor, FBBlockColor);
GLINT_WRITE_REG(ASM_InvertPattern|patternx<<7|patterny<<12|
- UNIT_ENABLE, AreaStippleMode);
+ STIPPLE_SWAP | UNIT_ENABLE, AreaStippleMode);
GLINT_WRITE_REG(AreaStippleEnable | FastFillEnable |
XPositive | YPositive | PrimitiveRectangle, Render);
} else {
GLINT_WRITE_REG(pGlint->ForeGroundColor, ConstantColor);
GLINT_WRITE_REG(pGlint->BackGroundColor, Texel0);
GLINT_WRITE_REG(patternx<<7|patterny<<12|
- UNIT_ENABLE, AreaStippleMode);
+ STIPPLE_SWAP | UNIT_ENABLE, AreaStippleMode);
GLINT_WRITE_REG(AreaStippleEnable | XPositive | TextureEnable |
YPositive | PrimitiveRectangle, Render);
return;
@@ -973,9 +928,11 @@ Permedia2SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn,
GLINT_WRITE_REG(pGlint->ForeGroundColor, ConstantColor);
pGlint->FrameBufferReadMode = 0;
}
- GLINT_WRITE_REG(patternx<<7|patterny<<12|UNIT_ENABLE, AreaStippleMode);
+ GLINT_WRITE_REG(patternx<<7|patterny<<12|STIPPLE_SWAP|UNIT_ENABLE, AreaStippleMode);
GLINT_WRITE_REG(AreaStippleEnable | pGlint->FrameBufferReadMode |
XPositive | YPositive | PrimitiveRectangle, Render);
+
+ TRACE_EXIT("Permedia2SubsequentMono8x8PatternFillRect()");
}
static void
@@ -988,6 +945,7 @@ Permedia2SetupForCPUToScreenColorExpandFill(
GLINTPtr pGlint = GLINTPTR(pScrn);
int dobackground = 0;
+ TRACE_ENTER("Permedia2SetupForCPUToScreenColorExpandFill");
if (bg != -1) dobackground |= ForceBackgroundColor;
GLINT_WAIT(7);
@@ -1010,11 +968,12 @@ Permedia2SetupForCPUToScreenColorExpandFill(
} else {
GLINT_WRITE_REG(fg, FBBlockColor);
}
- GLINT_WRITE_REG(0, RasterizerMode);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
pGlint->FrameBufferReadMode = FastFillEnable;
} else {
GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
- GLINT_WRITE_REG(BitMaskPackingEachScanline|dobackground,RasterizerMode);
+ GLINT_WRITE_REG(BitMaskPackingEachScanline|dobackground|
+ pGlint->RasterizerSwap,RasterizerMode);
GLINT_WRITE_REG(fg, ConstantColor);
if (dobackground) {
pGlint->FrameBufferReadMode = TextureEnable;
@@ -1023,6 +982,7 @@ Permedia2SetupForCPUToScreenColorExpandFill(
pGlint->FrameBufferReadMode = 0;
}
LOADROP(rop);
+ TRACE_EXIT("Permedia2SetupForCPUToScreenColorExpandFill");
}
static void
@@ -1034,6 +994,7 @@ Permedia2SubsequentCPUToScreenColorExpandFill(
GLINTPtr pGlint = GLINTPTR(pScrn);
int dwords = ((w + 31) >> 5) * h;
+ TRACE_ENTER("Permedia2SubsequentCPUToScreenColorExpandFill");
GLINT_WAIT(8);
Permedia2LoadCoord(pScrn, x, y, w, h);
@@ -1047,6 +1008,7 @@ Permedia2SubsequentCPUToScreenColorExpandFill(
pGlint->FrameBufferReadMode, Render);
GLINT_WRITE_REG((dwords - 1)<<16 | 0x0D, OutputFIFO);
GLINT_WAIT(dwords);
+ TRACE_EXIT("Permedia2SubsequentCPUToScreenColorExpandFill");
}
static void
@@ -1059,6 +1021,7 @@ Permedia2SetupForScanlineCPUToScreenColorExpandFill(
GLINTPtr pGlint = GLINTPTR(pScrn);
int dobackground = 0;
+ TRACE_ENTER("Permedia2SetupForScanlineCPUToScreenColorExpandFill");
if (bg != -1) dobackground |= ForceBackgroundColor;
pGlint->BackGroundColor = bg;
pGlint->ForeGroundColor = fg;
@@ -1075,11 +1038,12 @@ Permedia2SetupForScanlineCPUToScreenColorExpandFill(
pGlint->FrameBufferReadMode = FastFillEnable;
GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
GLINT_WRITE_REG(fg, FBBlockColor);
- GLINT_WRITE_REG(0,RasterizerMode);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
} else {
GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
GLINT_WRITE_REG(fg, ConstantColor);
- GLINT_WRITE_REG(BitMaskPackingEachScanline|dobackground,RasterizerMode);
+ GLINT_WRITE_REG(BitMaskPackingEachScanline|dobackground|
+ pGlint->RasterizerSwap,RasterizerMode);
if (dobackground) {
GLINT_WRITE_REG(bg, Texel0);
pGlint->FrameBufferReadMode = TextureEnable;
@@ -1088,6 +1052,7 @@ Permedia2SetupForScanlineCPUToScreenColorExpandFill(
}
}
LOADROP(rop);
+ TRACE_EXIT("Permedia2SetupForScanlineCPUToScreenColorExpandFill");
}
static void
@@ -1098,6 +1063,8 @@ Permedia2SubsequentScanlineCPUToScreenColorExpandFill(
){
GLINTPtr pGlint = GLINTPTR(pScrn);
+ TRACE_ENTER("Permedia2SubsequentScanlineCPUToScreenColorExpandFill");
+
pGlint->dwords = ((w + 31) >> 5); /* dwords per scanline */
pGlint->cpucount = h;
@@ -1108,6 +1075,7 @@ Permedia2SubsequentScanlineCPUToScreenColorExpandFill(
GLINT_WRITE_REG(((pGlint->dwords*h)-1)<<16 | 0x0D, OutputFIFO);
GLINT_WAIT(pGlint->dwords);
pGlint->cpucount--;
+ TRACE_EXIT("Permedia2SubsequentScanlineCPUToScreenColorExpandFill");
}
static void
@@ -1137,6 +1105,8 @@ Permedia2WriteBitmap(ScrnInfoPtr pScrn,
int dwords, height, mode;
Bool SecondPass = FALSE;
+ TRACE_ENTER("Permedia2WriteBitmap");
+
w += skipleft;
x -= skipleft;
dwords = (w + 31) >> 5;
@@ -1159,15 +1129,16 @@ Permedia2WriteBitmap(ScrnInfoPtr pScrn,
if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
mode = FastFillEnable;
GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
- GLINT_WRITE_REG(0, RasterizerMode);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
} else {
mode = 0;
GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
- GLINT_WRITE_REG(BitMaskPackingEachScanline,RasterizerMode);
+ GLINT_WRITE_REG(BitMaskPackingEachScanline|
+ pGlint->RasterizerSwap,RasterizerMode);
}
if(bg == -1) {
- /* >>>>> set fg <<<<<<<< */
+ /* === set fg === */
REPLICATE(fg);
if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
GLINT_WRITE_REG(fg, FBBlockColor);
@@ -1175,8 +1146,8 @@ Permedia2WriteBitmap(ScrnInfoPtr pScrn,
GLINT_WRITE_REG(fg, ConstantColor);
}
} else if(rop == GXcopy) {
- /* >>>>> set bg <<<<<<< */
- /* >>>>> draw rect (x,y,w,h) */
+ /* === set bg === */
+ /* === draw rect (x,y,w,h) === */
REPLICATE(bg);
if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
GLINT_WRITE_REG(bg, FBBlockColor);
@@ -1184,7 +1155,7 @@ Permedia2WriteBitmap(ScrnInfoPtr pScrn,
GLINT_WRITE_REG(bg, ConstantColor);
}
GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive |mode,Render);
- /* >>>>>> set fg <<<<<< */
+ /* === set fg === */
REPLICATE(fg);
if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
GLINT_WRITE_REG(fg, FBBlockColor);
@@ -1193,7 +1164,7 @@ Permedia2WriteBitmap(ScrnInfoPtr pScrn,
}
} else {
SecondPass = TRUE;
- /* >>>>> set fg <<<<<<< */
+ /* === set fg === */
REPLICATE(fg);
if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
GLINT_WRITE_REG(fg, FBBlockColor);
@@ -1202,8 +1173,8 @@ Permedia2WriteBitmap(ScrnInfoPtr pScrn,
}
}
- /* >>>>>>>>> initiate transfer (x,y,w,h). Skipleft pixels on the
- left edge will be clipped <<<<<< */
+ /* === initiate transfer (x,y,w,h). Skipleft pixels on the
+ left edge will be clipped === */
SECOND_PASS:
GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | mode | SyncOnBitMask, Render);
@@ -1221,24 +1192,25 @@ SECOND_PASS:
if(SecondPass) {
SecondPass = FALSE;
- /* >>>>>> invert bitmask and set bg <<<<<<<< */
+ /* === invert bitmask and set bg === */
REPLICATE(bg);
GLINT_WAIT(3);
if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
- GLINT_WRITE_REG(InvertBitMask, RasterizerMode);
+ GLINT_WRITE_REG(InvertBitMask|pGlint->RasterizerSwap,RasterizerMode);
GLINT_WRITE_REG(bg, FBBlockColor);
} else {
- GLINT_WRITE_REG(InvertBitMask|BitMaskPackingEachScanline,
- RasterizerMode);
+ GLINT_WRITE_REG(InvertBitMask|BitMaskPackingEachScanline|
+ pGlint->RasterizerSwap, RasterizerMode);
GLINT_WRITE_REG(bg, ConstantColor);
}
goto SECOND_PASS;
}
GLINT_WAIT(1);
- GLINT_WRITE_REG(0, RasterizerMode);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap, RasterizerMode);
Permedia2DisableClipping(pScrn);
SET_SYNC_FLAG(infoRec);
+ TRACE_EXIT("Permedia2WriteBitmap");
}
@@ -1263,7 +1235,7 @@ Permedia2WritePixmap8bpp(
GLINT_WAIT(3);
DO_PLANEMASK(planemask);
- GLINT_WRITE_REG(0, RasterizerMode);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
if (rop == GXcopy) {
GLINT_WRITE_REG(pGlint->pprod | FBRM_Packed, FBReadMode);
} else {
@@ -1271,7 +1243,9 @@ Permedia2WritePixmap8bpp(
}
dwords = (w + 3) >> 2;
- if((!(x&3)) && (!(w&3))) FastTexLoad = TRUE;
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ if((!(x&3)) && (!(w&3))) FastTexLoad = TRUE;
+#endif
if((rop != GXcopy) || (planemask != ~0))
FastTexLoad = FALSE;
@@ -1417,9 +1391,10 @@ Permedia2WritePixmap16bpp(
unsigned short* srcpword;
Bool FastTexLoad;
+ TRACE_ENTER("Permedia2WritePixmap16bpp");
GLINT_WAIT(3);
DO_PLANEMASK(planemask);
- GLINT_WRITE_REG(0, RasterizerMode);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
if (rop == GXcopy) {
GLINT_WRITE_REG(pGlint->pprod | FBRM_Packed, FBReadMode);
} else {
@@ -1428,7 +1403,9 @@ Permedia2WritePixmap16bpp(
FastTexLoad = FALSE;
dwords = (w + 1) >> 1;
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
if((!(x&1)) && (!(w&1))) FastTexLoad = TRUE;
+#endif
if((rop != GXcopy) || (planemask != ~0))
FastTexLoad = FALSE;
@@ -1552,6 +1529,7 @@ Permedia2WritePixmap16bpp(
Permedia2DisableClipping(pScrn);
SET_SYNC_FLAG(infoRec);
+ TRACE_EXIT("Permedia2WritePixmap16bpp");
}
static void
@@ -1573,7 +1551,7 @@ Permedia2WritePixmap24bpp(
CARD32* srcp;
GLINT_WAIT(3);
- GLINT_WRITE_REG(0, RasterizerMode);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
if (rop == GXcopy) {
GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
@@ -1675,7 +1653,7 @@ Permedia2WritePixmap32bpp(
GLINT_WAIT(3);
DO_PLANEMASK(planemask);
- GLINT_WRITE_REG(0, RasterizerMode);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
if (rop == GXcopy) {
GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
} else {
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c
index 27068af1b..0604fa045 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c
@@ -28,7 +28,7 @@
*
* GLINT 500TX / MX accelerated options.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c,v 1.15 1999/07/04 06:39:02 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c,v 1.19 2000/01/21 01:12:18 dawes Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -36,11 +36,8 @@
#include "xf86PciInfo.h"
#include "xf86Pci.h"
-#define PSZ 8
-#include "cfb.h"
-#undef PSZ
-#include "cfb16.h"
-#include "cfb32.h"
+
+#include "fb.h"
#include "miline.h"
@@ -92,13 +89,7 @@ static void TXSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop,
unsigned int planemask);
static void TXSubsequentHorVertLine(ScrnInfoPtr pScrn, int x1, int y1,
int len, int dir);
-static void TXSubsequentSolidBresenhamLine8bpp(ScrnInfoPtr pScrn,
- int x, int y, int dmaj, int dmin, int e,
- int len, int octant);
-static void TXSubsequentSolidBresenhamLine16bpp(ScrnInfoPtr pScrn,
- int x, int y, int dmaj, int dmin, int e,
- int len, int octant);
-static void TXSubsequentSolidBresenhamLine32bpp(ScrnInfoPtr pScrn,
+static void TXSubsequentSolidBresenhamLine(ScrnInfoPtr pScrn,
int x, int y, int dmaj, int dmin, int e,
int len, int octant);
static void TXPolylinesThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC,
@@ -108,7 +99,7 @@ static void TXPolySegmentThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC,
#define MAX_FIFO_ENTRIES 15
-static void
+void
TXInitializeEngine(ScrnInfoPtr pScrn)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
@@ -218,17 +209,8 @@ TXAccelInit(ScreenPtr pScreen)
infoPtr->PolylinesThinSolidFlags = 0;
infoPtr->SetupForSolidLine = TXSetupForSolidLine;
infoPtr->SubsequentSolidHorVertLine = TXSubsequentHorVertLine;
- switch(pScrn->bitsPerPixel) {
- case 8: infoPtr->SubsequentSolidBresenhamLine =
- TXSubsequentSolidBresenhamLine8bpp;
- break;
- case 16: infoPtr->SubsequentSolidBresenhamLine =
- TXSubsequentSolidBresenhamLine16bpp;
- break;
- case 32: infoPtr->SubsequentSolidBresenhamLine =
- TXSubsequentSolidBresenhamLine32bpp;
- break;
- }
+ infoPtr->SubsequentSolidBresenhamLine =
+ TXSubsequentSolidBresenhamLine;
infoPtr->PolySegmentThinSolid = TXPolySegmentThinSolidWrapper;
infoPtr->PolylinesThinSolid = TXPolylinesThinSolidWrapper;
@@ -710,7 +692,7 @@ TXWriteBitmap(ScrnInfoPtr pScrn,
TXLoadCoord(pScrn, x, y, x+w, h, 0, 1);
if(bg == -1) {
- /* >>>>> set fg <<<<<<<< */
+ /* === set fg === */
REPLICATE(fg);
GLINT_WAIT(3);
if (rop == GXcopy) {
@@ -878,6 +860,7 @@ TXPolylinesThinSolidWrapper(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
GLINTPtr pGlint = GLINTPTR(infoRec->pScrn);
pGlint->CurrentGC = pGC;
+ pGlint->CurrentDrawable = pDraw;
if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn);
XAAPolyLines(pDraw, pGC, mode, npt, pPts);
}
@@ -892,6 +875,7 @@ TXPolySegmentThinSolidWrapper(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
GLINTPtr pGlint = GLINTPTR(infoRec->pScrn);
pGlint->CurrentGC = pGC;
+ pGlint->CurrentDrawable = pDraw;
if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn);
XAAPolySegment(pDraw, pGC, nseg, pSeg);
}
@@ -929,11 +913,10 @@ TXSubsequentHorVertLine(ScrnInfoPtr pScrn,int x,int y,int len,int dir)
}
static void
-TXSubsequentSolidBresenhamLine8bpp( ScrnInfoPtr pScrn,
+TXSubsequentSolidBresenhamLine( ScrnInfoPtr pScrn,
int x, int y, int dmaj, int dmin, int e, int len, int octant)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
- cfbPrivGCPtr devPriv;
int dxdom, dy;
if(dmaj == dmin) {
@@ -955,87 +938,9 @@ TXSubsequentSolidBresenhamLine8bpp( ScrnInfoPtr pScrn,
return;
}
- devPriv = cfbGetGCPrivate(pGlint->CurrentGC);
-
- cfbBresS(devPriv->rop, devPriv->and, devPriv->xor,
- (unsigned long*)pGlint->FbBase, pScrn->displayWidth >> 2,
+ fbBres(pGlint->CurrentDrawable, pGlint->CurrentGC, 0,
(octant & XDECREASING) ? -1 : 1,
(octant & YDECREASING) ? -1 : 1,
(octant & YMAJOR) ? Y_AXIS : X_AXIS,
- x, y, dmin + e, dmin, dmin - dmaj, len);
+ x, y, dmin + e, dmin, -dmaj, len);
}
-
-static void
-TXSubsequentSolidBresenhamLine16bpp( ScrnInfoPtr pScrn,
- int x, int y, int dmaj, int dmin, int e, int len, int octant)
-{
- GLINTPtr pGlint = GLINTPTR(pScrn);
- cfbPrivGCPtr devPriv;
- int dxdom, dy;
-
- if(dmaj == dmin) {
- GLINT_WAIT(7);
- if(octant & YDECREASING) {
- dy = -1;
- } else {
- dy = 1;
- }
-
- if(octant & XDECREASING) {
- dxdom = -1;
- } else {
- dxdom = 1;
- }
-
- TXLoadCoord(pScrn, x, y, 0, len, dxdom, dy);
- GLINT_WRITE_REG(PrimitiveLine, Render);
- return;
- }
-
- devPriv = cfbGetGCPrivate(pGlint->CurrentGC);
-
- cfb16BresS(devPriv->rop, devPriv->and, devPriv->xor,
- (unsigned long*)pGlint->FbBase, pScrn->displayWidth >> 1,
- (octant & XDECREASING) ? -1 : 1,
- (octant & YDECREASING) ? -1 : 1,
- (octant & YMAJOR) ? Y_AXIS : X_AXIS,
- x, y, dmin + e, dmin, dmin - dmaj, len);
-}
-
-static void
-TXSubsequentSolidBresenhamLine32bpp( ScrnInfoPtr pScrn,
- int x, int y, int dmaj, int dmin, int e, int len, int octant)
-{
- GLINTPtr pGlint = GLINTPTR(pScrn);
- cfbPrivGCPtr devPriv;
- int dxdom, dy;
-
- if(dmaj == dmin) {
- GLINT_WAIT(7);
- if(octant & YDECREASING) {
- dy = -1;
- } else {
- dy = 1;
- }
-
- if(octant & XDECREASING) {
- dxdom = -1;
- } else {
- dxdom = 1;
- }
-
- TXLoadCoord(pScrn, x, y, 0, len, dxdom, dy);
- GLINT_WRITE_REG(PrimitiveLine, Render);
- return;
- }
-
- devPriv = cfbGetGCPrivate(pGlint->CurrentGC);
-
- cfb32BresS(devPriv->rop, devPriv->and, devPriv->xor,
- (unsigned long*)pGlint->FbBase, pScrn->displayWidth,
- (octant & XDECREASING) ? -1 : 1,
- (octant & YDECREASING) ? -1 : 1,
- (octant & YMAJOR) ? Y_AXIS : X_AXIS,
- x, y, dmin + e, dmin, dmin - dmaj, len);
-}
-
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile
index 4fe4392cb..e0bb04760 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile
@@ -16,18 +16,11 @@ DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri
DRIDEFINES = $(GLX_DEFINES)
#endif
-#
-# Uncomment these only if you have the proprietary sources
-#
-PRIVSRCS = tdfx_priv.c
-PRIVOBJS = tdfx_priv.o
-PRIVDEFINES = -DPROP_3DFX
-
SRCS = tdfx_driver.c tdfx_io.c tdfx_hwcurs.c tdfx_accel.c \
- tdfx_dga.c $(DRISRCS) $(PRIVSRCS)
+ tdfx_dga.c tdfx_priv.c tdfx_sli.c $(DRISRCS)
OBJS = tdfx_driver.o tdfx_io.o tdfx_hwcurs.o tdfx_accel.o \
- tdfx_dga.o $(DRIOBJS) $(PRIVOBJS)
+ tdfx_dga.o tdfx_priv.o tdfx_sli.o $(DRIOBJS)
#if defined(XF86DriverSDK)
INCLUDES = -I. -I../../include
@@ -43,7 +36,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
$(DRIINCLUDES)
#endif
-DEFINES = $(DRIDEFINES) $(PRIVDEFINES)
+DEFINES = -DPROP_3DFX $(DRIDEFINES)
#if MakeHasPosixVariableSubstitutions
SubdirLibraryRule($(OBJS))
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h
index 10bf7e4aa..66e9c0d65 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h
@@ -35,6 +35,12 @@
struct _TDFXRec;
typedef struct _TDFXRec *TDFXPtr;
+#ifdef XF86DRI
+#define PIXMAP_CACHE_LINES 128
+#else
+#define PIXMAP_CACHE_LINES 512
+#endif
+
#ifdef PROP_3DFX
#include "tdfx_priv.h"
#else
@@ -57,6 +63,7 @@ extern void FillPrivateDRI(TDFXPtr pTDFX, TDFXDRIPtr pTDFXDRI);
#define TDFX_DEBUG_CMDS
#define TRACECURS 1
#define REGDEBUG 1
+#define TRACEREG
#endif
#ifdef TRACE
@@ -92,6 +99,14 @@ typedef char (*TDFXReadIndexedByteFunc)(TDFXPtr pTDFX, int addr,
char index);
typedef void (*TDFXWriteWordFunc)(TDFXPtr pTDFX, int addr, int value);
typedef int (*TDFXReadWordFunc)(TDFXPtr pTDFX, int addr);
+typedef void (*TDFXWriteChipIndexedByteFunc)(TDFXPtr pTDFX, int chip,
+ int addr, char index, char value);
+typedef char (*TDFXReadChipIndexedByteFunc)(TDFXPtr pTDFX, int chip,
+ int addr, char index);
+typedef void (*TDFXWriteChipWordFunc)(TDFXPtr pTDFX, int chip,
+ int addr, int value);
+typedef int (*TDFXReadChipWordFunc)(TDFXPtr pTDFX, int chip,
+ int addr);
typedef void (*TDFXSyncFunc)(ScrnInfoPtr pScrn);
typedef void (*TDFXBufferFunc)(TDFXPtr pTDFX, int which);
@@ -119,21 +134,26 @@ typedef struct TextureData_t {
struct TextureData_t *next;
} TextureData;
+#define MAXCHIPS 4
+
typedef struct _TDFXRec {
- unsigned char *MMIOBase;
+ unsigned char *MMIOBase[MAXCHIPS];
unsigned char *FbBase;
- unsigned int PIOBase;
+ unsigned char *myFbBase;
+ unsigned int PIOBase[MAXCHIPS];
long FbMapSize;
+ int pixelFormat;
int stride;
int cpp;
int maxClip;
int MaxClock;
- int Chipset;
- int LinearAddr;
- int MMIOAddr;
- EntityInfoPtr pEnt;
+ int ChipType;
pciVideoPtr PciInfo;
- PCITAG PciTag;
+ int LinearAddr[MAXCHIPS];
+ int MMIOAddr[MAXCHIPS];
+ EntityInfoPtr pEnt;
+ int numChips;
+ PCITAG PciTag[MAXCHIPS];
int HasSGRAM;
int PciCnt;
int PrevDrawState;
@@ -162,6 +182,8 @@ typedef struct _TDFXRec {
TDFXReadIndexedByteFunc readControl;
TDFXWriteWordFunc writeLong;
TDFXReadWordFunc readLong;
+ TDFXWriteChipWordFunc writeChipLong;
+ TDFXReadChipWordFunc readChipLong;
TDFXSyncFunc sync;
int syncDone;
int scanlineWidth;
@@ -197,8 +219,8 @@ typedef struct {
#define TDFX2XCUTOFF 135000
-#ifndef PCI_CHIP_VOODOOEXP
-#define PCI_CHIP_VOODOOEXP 9
+#ifndef PCI_CHIP_VOODOO5
+#define PCI_CHIP_VOODOO5 9
#endif
extern Bool TDFXAccelInit(ScreenPtr pScreen);
@@ -210,7 +232,7 @@ extern Bool TDFXDRIFinishScreenInit(ScreenPtr pScreen);
extern Bool TDFXDGAInit(ScreenPtr pScreen);
extern void TDFXCursorGrabMemory(ScreenPtr pScreen);
extern void TDFXSetLFBConfig(TDFXPtr pTDFX);
-extern void TDFXSendNOPPrivate(TDFXPtr pTDFX);
+extern void TDFXSendNOPPrivate(ScrnInfoPtr pScrn);
extern Bool TDFXSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
extern void TDFXAdjustFrame(int scrnIndex, int x, int y, int flags);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.man b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.man
new file mode 100644
index 000000000..a647ac301
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.man
@@ -0,0 +1,30 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp,v 1.1 2000/03/03 01:05:43 dawes Exp $
+.TH TDFX 4 "Version 4.0" "XFree86"
+.SH NAME
+tdfx \- 3Dfx video driver
+.SH SYNOPSIS
+.B "Section ""Device"""
+.br
+.BI " Identifier """ devname """"
+.br
+.B " Driver ""tdfx"""
+.br
+\ \ ...
+.br
+.B EndSection
+.SH DESCRIPTION
+.B tdfx
+is an XFree86 driver for 3Dfx video cards.
+THIS MAN PAGE NEEDS TO BE FILLED IN.
+.SH SUPPORTED HARDWARE
+The
+.B tdfx
+driver supports...
+.SH CONFIGURATION DETAILS
+Please refer to XF86Config(5x) for general configuration
+details. This section only covers configuration details specific to this
+driver.
+.SH "SEE ALSO"
+XFree86(1), XF86Config(5x), xf86config(1), Xserver(1), X(1)
+.SH AUTHORS
+Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c
index a02fd5308..e6db51242 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c
@@ -79,13 +79,17 @@ TDFXNeedSync(ScrnInfoPtr pScrn) {
pTDFX->syncDone=FALSE;
}
-static void
+void
TDFXFirstSync(ScrnInfoPtr pScrn) {
TDFXPtr pTDFX = TDFXPTR(pScrn);
if (!pTDFX->syncDone) {
- pTDFX->sync(pScrn);
+ if (pTDFX->directRenderingEnabled) {
+ DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
+ TDFXSwapContextPrivate(screenInfo.screens[pScrn->scrnIndex]);
+ }
pTDFX->syncDone=TRUE;
+ pTDFX->sync(pScrn);
}
}
@@ -96,12 +100,15 @@ TDFXCheckSync(ScrnInfoPtr pScrn) {
if (pTDFX->syncDone) {
pTDFX->sync(pScrn);
pTDFX->syncDone=FALSE;
+ if (pTDFX->directRenderingEnabled) {
+ TDFXLostContext(screenInfo.screens[pScrn->scrnIndex]);
+ DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
+ }
}
}
void
TDFXSelectBuffer(TDFXPtr pTDFX, int which) {
-#ifdef XF86DRI
int fmt;
TDFXMakeRoom(pTDFX, 4);
@@ -116,14 +123,20 @@ TDFXSelectBuffer(TDFXPtr pTDFX, int which) {
TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt);
break;
case TDFX_BACK:
- fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */
+ if (pTDFX->cpp==2)
+ fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */
+ else
+ fmt=((pTDFX->stride+127)/128)|(5<<16); /* Tiled 32bpp */
TDFXWriteLong(pTDFX, SST_2D_DSTBASEADDR, pTDFX->backOffset|BIT(31));
TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt);
TDFXWriteLong(pTDFX, SST_2D_SRCBASEADDR, pTDFX->backOffset|BIT(31));
TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt);
break;
case TDFX_DEPTH:
- fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */
+ if (pTDFX->cpp==2)
+ fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */
+ else
+ fmt=((pTDFX->stride+127)/128)|(5<<16); /* Tiled 32bpp */
TDFXWriteLong(pTDFX, SST_2D_DSTBASEADDR, pTDFX->depthOffset|BIT(31));
TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt);
TDFXWriteLong(pTDFX, SST_2D_SRCBASEADDR, pTDFX->depthOffset|BIT(31));
@@ -131,14 +144,27 @@ TDFXSelectBuffer(TDFXPtr pTDFX, int which) {
break;
default:
}
-#endif
}
void
TDFXSetLFBConfig(TDFXPtr pTDFX) {
- TDFXWriteLongMMIO(pTDFX, LFBMEMORYCONFIG, (pTDFX->backOffset>>12) |
- SST_RAW_LFB_ADDR_STRIDE_4K |
- ((pTDFX->stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT);
+ if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) {
+ TDFXWriteLongMMIO(pTDFX, LFBMEMORYCONFIG, (pTDFX->backOffset>>12) |
+ SST_RAW_LFB_ADDR_STRIDE_4K |
+ ((pTDFX->stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT);
+ } else {
+ int chip;
+ int stride, bits;
+ if (pTDFX->cpp==2) stride=pTDFX->stride;
+ else stride=4*pTDFX->stride/pTDFX->cpp;
+ bits=pTDFX->backOffset>>12;
+ for (chip=0; chip<pTDFX->numChips; chip++) {
+ TDFXWriteChipLongMMIO(pTDFX, chip, LFBMEMORYCONFIG, (bits&0x1FFF) |
+ SST_RAW_LFB_ADDR_STRIDE_4K |
+ ((bits&0x6000)<<10) |
+ ((stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT);
+ }
+ }
}
Bool
@@ -263,8 +289,11 @@ static void TDFXMakeRoomNoProp(TDFXPtr pTDFX, int size) {
}
}
-static void TDFXSendNOPNoProp(TDFXPtr pTDFX)
+static void TDFXSendNOPNoProp(ScrnInfoPtr pScrn)
{
+ TDFXPtr pTDFX;
+
+ pTDFX=TDFXPTR(pScrn);
TDFXMakeRoomNoProp(pTDFX, 1);
TDFXWriteLongMMIO(pTDFX, SST_2D_COMMAND, SST_2D_NOP);
}
@@ -278,7 +307,7 @@ void TDFXSync(ScrnInfoPtr pScrn)
TDFXTRACEACCEL("TDFXSync\n");
pTDFX=TDFXPTR(pScrn);
- TDFXSendNOPNoProp(pTDFX);
+ TDFXSendNOPNoProp(pScrn);
i=0;
do {
stat=TDFXReadLongMMIO(pTDFX, 0);
@@ -408,7 +437,7 @@ TDFXSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int srcX, int srcY,
}
if ((srcY>=dstY-32 && srcY<=dstY)||
(srcY>=pTDFX->prevBlitDest.y1-32 && srcY<=pTDFX->prevBlitDest.y1)) {
- TDFXSendNOP(pTDFX);
+ TDFXSendNOP(pScrn);
}
pTDFX->sync(pScrn);
@@ -606,8 +635,8 @@ TDFXNonTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int n,
SSTCP_SRCXY|SSTCP_COLORFORE|SSTCP_COMMAND);
TDFXWriteLong(pTDFX, SST_2D_CLIP1MIN, ((pbox->y1&0x1FFF)<<16) |
(pbox->x1&0x1FFF));
- TDFXWriteLong(pTDFX, SST_2D_CLIP1MAX, (((pbox->y2+1)&0x1FFF)<<16) |
- ((pbox->x2+1)&0x1FFF));
+ TDFXWriteLong(pTDFX, SST_2D_CLIP1MAX, ((pbox->y2&0x1FFF)<<16) |
+ (pbox->x2&0x1FFF));
TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, SST_2D_PIXFMT_1BPP |
SST_2D_SOURCE_PACKING_DWORD);
TDFXWriteLong(pTDFX, SST_2D_SRCXY, 0);
@@ -734,7 +763,7 @@ TDFXSubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y,
pTDFX->DrawState|=DRAW_STATE_CLIP1CHANGED;
if (srcy>=pTDFX->prevBlitDest.y1-8 && srcy<=pTDFX->prevBlitDest.y1) {
- TDFXSendNOP(pTDFX);
+ TDFXSendNOP(pScrn);
}
if (pTDFX->cpp==1) fmt=(1<<16)|pTDFX->stride;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c
index f8f0a6cb1..11ea6f3f0 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c
@@ -47,10 +47,97 @@ TDFXInitVisualConfigs(ScreenPtr pScreen)
switch (pScrn->bitsPerPixel) {
case 8:
+ case 16:
+ numConfigs = 16;
+
+ if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
+ numConfigs))) {
+ return FALSE;
+ }
+ if (!(pTDFXConfigs = (TDFXConfigPrivPtr)xnfcalloc(sizeof(TDFXConfigPrivRec),
+ numConfigs))) {
+ xfree(pConfigs);
+ return FALSE;
+ }
+ if (!(pTDFXConfigPtrs = (TDFXConfigPrivPtr*)xnfcalloc(sizeof(TDFXConfigPrivPtr),
+ numConfigs))) {
+ xfree(pConfigs);
+ xfree(pTDFXConfigs);
+ return FALSE;
+ }
+ for (i=0; i<numConfigs; i++)
+ pTDFXConfigPtrs[i] = &pTDFXConfigs[i];
+
+ i=0;
+ depth=1;
+ for (db = 0; db <=1; db++) {
+ for (depth = 0; depth<=1; depth++) {
+ for (accum = 0; accum <= 1; accum++) {
+ for (stencil = 0; stencil <= 1; stencil++) {
+ 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) {
+ 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;
+ }
+ if (db)
+ pConfigs[i].doubleBuffer = TRUE;
+ else
+ pConfigs[i].doubleBuffer = FALSE;
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = 16;
+ if (depth) {
+ if (pTDFX->cpp>2)
+ pConfigs[i].depthSize = 24;
+ else
+ pConfigs[i].depthSize = 16;
+ } else {
+ pConfigs[i].depthSize = 0;
+ }
+ if (stencil)
+ pConfigs[i].stencilSize = 8;
+ else
+ pConfigs[i].stencilSize = 0;
+ pConfigs[i].auxBuffers = 0;
+ pConfigs[i].level = 0;
+ if (stencil || 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++;
+ }
+ }
+ }
+ }
+ if (i!=numConfigs) {
+ ErrorF("Incorrect initialization of visuals\n");
+ return FALSE;
+ } else ErrorF("Created %d visuals\n", numConfigs);
+ break; /* 16bpp */
+
case 24:
case 32:
- break;
- case 16:
numConfigs = 8;
pConfigs = (__GLXvisualConfig*) xnfcalloc(sizeof(__GLXvisualConfig), numConfigs);
@@ -74,66 +161,74 @@ TDFXInitVisualConfigs(ScreenPtr pScreen)
pTDFXConfigPtrs[i] = &pTDFXConfigs[i];
i=0;
- depth=1;
- for (accum = 0; accum <= 1; accum++) {
- for (stencil = 0; stencil <= 1; stencil++) {
- for (db=0; db<=1; db++) {
- 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) {
- 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;
- }
- if (db)
- pConfigs[i].doubleBuffer = TRUE;
- else
- pConfigs[i].doubleBuffer = FALSE;
- pConfigs[i].stereo = FALSE;
- pConfigs[i].bufferSize = 16;
- if (depth)
- pConfigs[i].depthSize = 16;
- else
- pConfigs[i].depthSize = 0;
- if (stencil)
- pConfigs[i].stencilSize = 8;
- else
- pConfigs[i].stencilSize = 0;
- pConfigs[i].auxBuffers = 0;
- pConfigs[i].level = 0;
- if (stencil)
- 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++;
- }
+ for (db = 0; db <=1; db++) {
+ for (depth = 0; depth<=1; depth++) {
+ /*stencil = depth;*/ /* Z and stencil share the same memory */
+ for (accum = 0; accum <= 1; accum++) {
+ /*for (stencil = 0; stencil <=1; stencil++) {*/
+ stencil = depth;
+ 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].alphaSize = (pScrn->bitsPerPixel==32) ? 8 : 0;
+ pConfigs[i].redMask = 0x00ff0000;
+ pConfigs[i].greenMask = 0x0000ff00;
+ pConfigs[i].blueMask = 0x000000ff;
+ pConfigs[i].alphaMask = (pScrn->bitsPerPixel==32) ? 0xff000000 : 0;
+ if (accum) {
+ pConfigs[i].accumRedSize = 16;
+ pConfigs[i].accumGreenSize = 16;
+ pConfigs[i].accumBlueSize = 16;
+ pConfigs[i].accumAlphaSize = (pScrn->bitsPerPixel==32) ? 16 : 0;
+ } else {
+ pConfigs[i].accumRedSize = 0;
+ pConfigs[i].accumGreenSize = 0;
+ pConfigs[i].accumBlueSize = 0;
+ pConfigs[i].accumAlphaSize = 0;
+ }
+ if (db)
+ pConfigs[i].doubleBuffer = TRUE;
+ else
+ pConfigs[i].doubleBuffer = FALSE;
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = 16;
+ if (depth) {
+ if (pTDFX->cpp > 2)
+ pConfigs[i].depthSize = 24;
+ else
+ pConfigs[i].depthSize = 16;
+ } else {
+ pConfigs[i].depthSize = 0;
+ }
+ if (stencil)
+ pConfigs[i].stencilSize = 8;
+ else
+ 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++;
+ /*}*/
+ }
}
}
if (i!=numConfigs) {
xf86DrvMsg(pScreen->myNum, X_ERROR,
"Incorrect initialization of visuals\n");
return FALSE;
- }
+ } else ErrorF("Created %d visuals\n", numConfigs);
break;
}
pTDFX->numVisualConfigs = numConfigs;
@@ -143,6 +238,26 @@ TDFXInitVisualConfigs(ScreenPtr pScreen)
return TRUE;
}
+static void
+TDFXDoWakeupHandler(int screenNum, pointer wakeupData, unsigned long result,
+ pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ TDFXNeedSync(pScrn);
+}
+
+static void
+TDFXDoBlockHandler(int screenNum, pointer blockData, pointer pTimeout,
+ pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ TDFXCheckSync(pScrn);
+}
+
Bool TDFXDRIScreenInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
@@ -150,7 +265,15 @@ Bool TDFXDRIScreenInit(ScreenPtr pScreen)
DRIInfoPtr pDRIInfo;
TDFXDRIPtr pTDFXDRI;
- if (pScrn->bitsPerPixel != 16) return FALSE;
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ return FALSE;
+ case 16:
+ break;
+ case 24:
+ case 32:
+ if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) return FALSE;
+ }
#if XFree86LOADER
/* Check that the GLX, DRI, and DRM modules have been loaded by testing
@@ -187,11 +310,16 @@ Bool TDFXDRIScreenInit(ScreenPtr pScreen)
pDRIInfo->ddxDriverMajorVersion = TDFX_MAJOR_VERSION;
pDRIInfo->ddxDriverMinorVersion = TDFX_MINOR_VERSION;
pDRIInfo->ddxDriverPatchVersion = TDFX_PATCHLEVEL;
- pDRIInfo->frameBufferPhysicalAddress = pTDFX->LinearAddr;
+ pDRIInfo->frameBufferPhysicalAddress = pTDFX->LinearAddr[0];
pDRIInfo->frameBufferSize = pTDFX->FbMapSize;
pDRIInfo->frameBufferStride = pTDFX->stride;
pDRIInfo->ddxDrawableTableEntry = TDFX_MAX_DRAWABLES;
+ pDRIInfo->wrap.ValidateTree = 0;
+ pDRIInfo->wrap.PostValidateTree = 0;
+ pDRIInfo->wrap.BlockHandler = TDFXDoBlockHandler;
+ pDRIInfo->wrap.WakeupHandler = TDFXDoWakeupHandler;
+
if (SAREA_MAX_DRAWABLES < TDFX_MAX_DRAWABLES)
pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES;
else
@@ -261,7 +389,7 @@ Bool TDFXDRIScreenInit(ScreenPtr pScreen)
}
pTDFXDRI->regsSize=TDFXIOMAPSIZE;
- if (drmAddMap(pTDFX->drmSubFD, (drmHandle)pTDFX->MMIOAddr,
+ if (drmAddMap(pTDFX->drmSubFD, (drmHandle)pTDFX->MMIOAddr[0],
pTDFXDRI->regsSize, DRM_REGISTERS, 0, &pTDFXDRI->regs)<0) {
TDFXDRICloseScreen(pScreen);
return FALSE;
@@ -303,9 +431,7 @@ TDFXCreateContext(ScreenPtr pScreen, VisualPtr visual,
drmContext hwContext, void *pVisualConfigPriv,
DRIContextType contextStore)
{
- /*ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];*/
- /*TDFXPtr pTDFX = TDFXPTR(pScrn);*/
- /*TDFXConfigPrivPtr pTDFXConfig = (TDFXConfigPrivPtr)pVisualConfigPriv;*/
+ TDFXConfigPrivPtr pTDFXConfig = (TDFXConfigPrivPtr)pVisualConfigPriv;
TDFXDRIContextPtr ctx;
ctx=(TDFXDRIContextPtr)contextStore;
@@ -351,14 +477,21 @@ TDFXDRISwapContext(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 */
- TDFXSwapContextPrivate(pScreen);
- }
+#if 0
+ ScrnInfoPtr pScrn;
+
+ pScrn = xf86Screens[pScreen->myNum];
if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) &&
(newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */
+ TDFXCheckSync(pScrn);
TDFXLostContext(pScreen);
}
+ if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) &&
+ (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */
+ TDFXSwapContextPrivate(pScreen);
+ TDFXNeedSync(pScrn);
+ }
+#endif
}
static void
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c
index 9f1483629..8b0c2dc38 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c
@@ -153,7 +153,7 @@ DriverRec TDFX = {
TDFX_VERSION,
TDFX_DRIVER_NAME,
#if 0
- "Accelerated driver for 3dfx Voodoo Banshee and Voodoo3 cards",
+ "Accelerated driver for 3dfx cards",
#endif
TDFXIdentify,
TDFXProbe,
@@ -165,14 +165,14 @@ DriverRec TDFX = {
static SymTabRec TDFXChipsets[] = {
{ PCI_CHIP_BANSHEE, "3dfx Banshee"},
{ PCI_CHIP_VOODOO3, "3dfx Voodoo3"},
- { PCI_CHIP_VOODOOEXP, "3dfx VoodooExp"},
+ { PCI_CHIP_VOODOO5, "3dfx Voodoo5"},
{ -1, NULL }
};
static PciChipsets TDFXPciChipsets[] = {
{ PCI_CHIP_BANSHEE, PCI_CHIP_BANSHEE, RES_SHARED_VGA },
{ PCI_CHIP_VOODOO3, PCI_CHIP_VOODOO3, RES_SHARED_VGA },
- { PCI_CHIP_VOODOOEXP, PCI_CHIP_VOODOOEXP, RES_SHARED_VGA },
+ { PCI_CHIP_VOODOO5, PCI_CHIP_VOODOO5, RES_SHARED_VGA },
{ -1, -1, RES_UNDEFINED }
};
@@ -182,13 +182,15 @@ static PciChipsets TDFXPciChipsets[] = {
typedef enum {
OPTION_NOACCEL,
OPTION_SW_CURSOR,
- OPTION_USE_PIO
+ OPTION_USE_PIO,
+ OPTION_NO_SLI
} TDFXOpts;
static OptionInfoRec TDFXOptions[] = {
{ OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_USE_PIO, "UsePIO", OPTV_BOOLEAN, {0}, FALSE},
+ { OPTION_NO_SLI, "NoSLI", OPTV_BOOLEAN, {0}, FALSE},
{ -1, NULL, OPTV_NONE, {0}, FALSE}
};
@@ -415,9 +417,7 @@ TDFXProbe(DriverPtr drv, int flags) {
TDFXChipsets, TDFXPciChipsets,
devSections, numDevSections,
drv, &usedChips);
- if (devSections)
- xfree(devSections);
- devSections=NULL;
+
if (numUsed<=0) return FALSE;
if (flags & PROBE_DETECT)
@@ -445,6 +445,7 @@ TDFXProbe(DriverPtr drv, int flags) {
xf86ConfigActivePciEntity(pScrn, usedChips[i], TDFXPciChipsets, 0, 0, 0, 0, 0);
}
xfree(usedChips);
+ if (devSections) xfree(devSections);
return foundScreen;
}
@@ -458,7 +459,7 @@ TDFXCountRam(ScrnInfoPtr pScrn) {
pTDFX = TDFXPTR(pScrn);
TDFXTRACE("TDFXCountRam start\n");
memSize=0;
- if (pTDFX->PIOBase) {
+ if (pTDFX->PIOBase[0]) {
CARD32
partSize, /* size of SGRAM chips in Mbits */
nChips, /* # chips of SDRAM/SGRAM */
@@ -488,7 +489,7 @@ TDFXCountRam(ScrnInfoPtr pScrn) {
/* determine memory size from strapping pins (dramInit0 and dramInit1) */
dramInit0_strap = pTDFX->readLong(pTDFX, DRAMINIT0);
- if (pTDFX->PciInfo->chipType<=5) { /* Banshee/V3 */
+ if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) { /* Banshee/V3 */
if (memType == MEM_TYPE_SDRAM) {
memSize = 16;
} else {
@@ -510,8 +511,6 @@ TDFXCountRam(ScrnInfoPtr pScrn) {
partSize=1<<((dramInit0_strap&0x38000000)>>28);
banks=((dramInit0_strap&BIT(30))==0) ? 2 : 4;
memSize=nChips*partSize*banks;
- ErrorF("reg=%x nChips=%d partSize=%d banks=%d memSize=%d\n",
- dramInit0_strap, nChips, partSize, banks, memSize);
}
TDFXTRACEREG("dramInit0 = %x dramInit1 = %x\n", dramInit0_strap, dramInit1_strap);
TDFXTRACEREG("MemConfig %d chips %d size %d total\n", nChips, partSize, memSize);
@@ -543,6 +542,83 @@ TDFXProbeDDC(ScrnInfoPtr pScrn, int index)
}
}
+static int TDFXCfgToSize(int cfg)
+{
+ if (cfg<4) return 0x8000000<<cfg;
+ return 0x4000000>>(cfg-4);
+}
+
+static int TDFXSizeToCfg(int size)
+{
+ switch (size) {
+ case 0x40000000: return 3;
+ case 0x20000000: return 2;
+ case 0x10000000: return 1;
+ case 0x08000000: return 0;
+ case 0x04000000: return 4;
+ case 0x02000000: return 5;
+ case 0x01000000: return 6;
+ case 0x00800000: return 7;
+ case 0x00400000: return 8;
+ default:
+ return -1;
+ }
+}
+
+static void
+TDFXFindChips(ScrnInfoPtr pScrn, pciVideoPtr match)
+{
+ TDFXPtr pTDFX;
+ pciVideoPtr *ppPci;
+
+ pTDFX=TDFXPTR(pScrn);
+ pTDFX->numChips=0;
+ pTDFX->ChipType=match->chipType;
+ for (ppPci = xf86GetPciVideoInfo(); *ppPci != NULL; ppPci++) {
+ if ((*ppPci)->bus == match->bus &&
+ (*ppPci)->device == match->device) {
+ pTDFX->PciTag[pTDFX->numChips] = pciTag((*ppPci)->bus,
+ (*ppPci)->device,
+ (*ppPci)->func);
+ pTDFX->PIOBase[pTDFX->numChips] = (*ppPci)->ioBase[2]&0xFFFFFFFC;
+ pTDFX->numChips++;
+ }
+ }
+}
+
+static void
+TDFXInitChips(ScrnInfoPtr pScrn)
+{
+ TDFXPtr pTDFX;
+ int i, cfgbits, initbits;
+ int mem0base, mem1base, mem0size, mem0bits, mem1size, mem1bits;
+
+ pTDFX=TDFXPTR(pScrn);
+ cfgbits=pciReadLong(pTDFX->PciTag[0], CFG_PCI_DECODE);
+ mem0base=pciReadLong(pTDFX->PciTag[0], CFG_MEM0BASE);
+ mem1base=pciReadLong(pTDFX->PciTag[0], CFG_MEM1BASE);
+ mem0size=32*1024*1024; /* Registers are always 32MB */
+ mem1size=pScrn->videoRam*1024*2; /* Linear mapping is 2x memory */
+ mem0bits=TDFXSizeToCfg(mem0size);
+ mem1bits=TDFXSizeToCfg(mem1size)<<4;
+ cfgbits=(cfgbits&~(0xFF))|mem0bits|mem1bits;
+ for (i=0; i<pTDFX->numChips; i++) {
+ initbits=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE);
+ initbits|=BIT(10);
+ pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, initbits);
+ pTDFX->MMIOAddr[i]=mem0base+i*mem0size;
+ pciWriteLong(pTDFX->PciTag[i], CFG_MEM0BASE, 0xFFFFFFFF);
+ pciWriteLong(pTDFX->PciTag[i], CFG_MEM0BASE, pTDFX->MMIOAddr[i]);
+ pTDFX->MMIOAddr[i]&=0xFFFFFF00;
+ pTDFX->LinearAddr[i]=mem1base+i*mem1size;
+ pciWriteLong(pTDFX->PciTag[i], CFG_MEM1BASE, 0xFFFFFFFF);
+ pciWriteLong(pTDFX->PciTag[i], CFG_MEM1BASE, pTDFX->LinearAddr[i]);
+ pTDFX->LinearAddr[i]&=0xFFFFFF00;
+ pciWriteLong(pTDFX->PciTag[i], CFG_PCI_DECODE, cfgbits);
+ initbits&=~BIT(10);
+ pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, initbits);
+ }
+}
/*
* TDFXPreInit --
@@ -552,7 +628,8 @@ TDFXProbeDDC(ScrnInfoPtr pScrn, int index)
*
*/
static Bool
-TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
+TDFXPreInit(ScrnInfoPtr pScrn, int flags)
+{
TDFXPtr pTDFX;
ClockRangePtr clockRanges;
int i;
@@ -560,6 +637,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
char *mod=0, *reqSym=0;
int flags24;
rgb defaultWeight = {0, 0, 0};
+ pciVideoPtr match;
TDFXTRACE("TDFXPreInit start\n");
if (pScrn->numEntities != 1) return FALSE;
@@ -594,9 +672,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
}
}
- pTDFX->PciInfo = xf86GetPciInfoForEntity(pTDFX->pEnt->index);
- pTDFX->PciTag = pciTag(pTDFX->PciInfo->bus, pTDFX->PciInfo->device,
- pTDFX->PciInfo->func);
+ match=pTDFX->PciInfo=xf86GetPciInfoForEntity(pTDFX->pEnt->index);
+ TDFXFindChips(pScrn, match);
if (xf86RegisterResources(pTDFX->pEnt->index, 0, ResNone))
return FALSE;
@@ -610,6 +687,14 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
return FALSE;
}
+ /* The vgahw module should be loaded here when needed */
+ if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE;
+
+ xf86LoaderReqSymLists(vgahwSymbols, NULL);
+
+ /* Allocate a vgaHWRec */
+ if (!vgaHWGetHWRec(pScrn)) return FALSE;
+
/* Set pScrn->monitor */
pScrn->monitor = pScrn->confScreen->monitor;
@@ -650,14 +735,6 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
}
}
- /* The vgahw module should be loaded here when needed */
- if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE;
-
- xf86LoaderReqSymLists(vgahwSymbols, NULL);
-
- /* Allocate a vgaHWRec */
- if (!vgaHWGetHWRec(pScrn)) return FALSE;
-
/* We use a programamble clock */
pScrn->progClock = TRUE;
@@ -681,7 +758,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
pTDFX->pEnt->device->chipID);
} else {
from = X_PROBED;
- pScrn->chipset = (char *)xf86TokenToString(TDFXChipsets, pTDFX->PciInfo->chipType);
+ pScrn->chipset = (char *)xf86TokenToString(TDFXChipsets, match->chipType);
}
if (pTDFX->pEnt->device->chipRev >= 0) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
@@ -691,11 +768,11 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset);
if (pTDFX->pEnt->device->MemBase != 0) {
- pTDFX->LinearAddr = pTDFX->pEnt->device->MemBase;
+ pTDFX->LinearAddr[0] = pTDFX->pEnt->device->MemBase;
from = X_CONFIG;
} else {
- if (pTDFX->PciInfo->memBase[1] != 0) {
- pTDFX->LinearAddr = pTDFX->PciInfo->memBase[1];
+ if (match->memBase[1] != 0) {
+ pTDFX->LinearAddr[0] = match->memBase[1];
from = X_PROBED;
} else {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -708,11 +785,11 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
(unsigned long)pTDFX->LinearAddr);
if (pTDFX->pEnt->device->IOBase != 0) {
- pTDFX->MMIOAddr = pTDFX->pEnt->device->IOBase;
+ pTDFX->MMIOAddr[0] = pTDFX->pEnt->device->IOBase;
from = X_CONFIG;
} else {
- if (pTDFX->PciInfo->memBase[0]) {
- pTDFX->MMIOAddr = pTDFX->PciInfo->memBase[0];
+ if (match->memBase[0]) {
+ pTDFX->MMIOAddr[0] = match->memBase[0];
from = X_PROBED;
} else {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -724,8 +801,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at addr 0x%lX\n",
(unsigned long)pTDFX->MMIOAddr);
- if (pTDFX->PciInfo->ioBase[2]) {
- pTDFX->PIOBase = pTDFX->PciInfo->ioBase[2]&0xFFFFFFFC;
+ if (match->ioBase[2]) {
+ pTDFX->PIOBase[0] = match->ioBase[2]&0xFFFFFFFC;
} else {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"No valid PIO address in PCI config space\n");
@@ -733,7 +810,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
return FALSE;
}
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "PIO registers at addr 0x%lX\n",
- (unsigned long)pTDFX->PIOBase);
+ (unsigned long)pTDFX->PIOBase[0]);
/* We have to use PIO to probe, because we haven't mappend yet */
TDFXSetPIOAccess(pTDFX);
@@ -746,6 +823,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
from = X_CONFIG;
}
+ TDFXInitChips(pScrn);
+
/* Multiple by two because tiled access requires more address space */
pTDFX->FbMapSize = pScrn->videoRam*1024*2;
xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte Mapping %d kByte\n",
@@ -780,12 +859,12 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
pTDFX->MaxClock = pTDFX->pEnt->device->dacSpeeds[0];
from = X_CONFIG;
} else {
- switch (pTDFX->PciInfo->chipType) {
+ switch (pTDFX->ChipType) {
case PCI_CHIP_BANSHEE:
pTDFX->MaxClock = 270000;
break;
case PCI_CHIP_VOODOO3:
- switch(pTDFX->PciInfo->subsysCard) {
+ switch(match->subsysCard) {
case PCI_SUBDEVICE_ID_VOODOO3_2000:
pTDFX->MaxClock = 300000;
break;
@@ -797,7 +876,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
break;
}
break;
- case PCI_CHIP_VOODOOEXP:
+ case PCI_CHIP_VOODOO5:
pTDFX->MaxClock = 350000;
break;
}
@@ -892,21 +971,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
xf86SetDDCproperties(pScrn,xf86PrintEDID(pMon));
}
-
- /* We wont be using the VGA access after the probe */
- if (!xf86ReturnOptValBool(TDFXOptions, OPTION_USE_PIO, FALSE)) {
- resRange vgaio[] = { {ResShrIoBlock,0x3B0,0x3BB},
- {ResShrIoBlock,0x3C0,0x3DF},
- _END };
- resRange vgamem[] = {{ResShrMemBlock,0xA0000,0xAFFFF},
- {ResShrMemBlock,0xB8000,0xBFFFF},
- {ResShrMemBlock,0xB0000,0xB7FFF},
- _END };
-
- pTDFX->usePIO=FALSE;
- xf86SetOperatingState(vgaio, pTDFX->pEnt->index, ResUnusedOpr);
- xf86SetOperatingState(vgamem, pTDFX->pEnt->index, ResDisableOpr);
- } else {
+ if (xf86ReturnOptValBool(TDFXOptions, OPTION_USE_PIO, FALSE)) {
pTDFX->usePIO=TRUE;
}
@@ -916,7 +981,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
static Bool
TDFXMapMem(ScrnInfoPtr pScrn)
{
- int mmioFlags;
+ int mmioFlags, i;
TDFXPtr pTDFX;
TDFXTRACE("TDFXMapMem start\n");
@@ -924,15 +989,18 @@ TDFXMapMem(ScrnInfoPtr pScrn)
mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT;
- pTDFX->MMIOBase = xf86MapPciMem(pScrn->scrnIndex, mmioFlags,
- pTDFX->PciTag,
- pTDFX->MMIOAddr,
- TDFXIOMAPSIZE);
- if (!pTDFX->MMIOBase) return FALSE;
+ for (i=0; i<pTDFX->numChips; i++) {
+ pTDFX->MMIOBase[i] = xf86MapPciMem(pScrn->scrnIndex, mmioFlags,
+ pTDFX->PciTag[i],
+ pTDFX->MMIOAddr[i],
+ TDFXIOMAPSIZE);
+
+ if (!pTDFX->MMIOBase[i]) return FALSE;
+ }
pTDFX->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
- pTDFX->PciTag,
- pTDFX->LinearAddr,
+ pTDFX->PciTag[0],
+ pTDFX->LinearAddr[0],
pTDFX->FbMapSize);
if (!pTDFX->FbBase) return FALSE;
@@ -943,12 +1011,16 @@ static Bool
TDFXUnmapMem(ScrnInfoPtr pScrn)
{
TDFXPtr pTDFX;
+ int i;
TDFXTRACE("TDFXUnmapMem start\n");
pTDFX = TDFXPTR(pScrn);
- xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTDFX->MMIOBase, TDFXIOMAPSIZE);
- pTDFX->MMIOBase=0;
+ for (i=0; i<pTDFX->numChips; i++) {
+ xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTDFX->MMIOBase[i],
+ TDFXIOMAPSIZE);
+ pTDFX->MMIOBase[i]=0;
+ }
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTDFX->FbBase, pTDFX->FbMapSize);
pTDFX->FbBase = 0;
@@ -1220,7 +1292,7 @@ SetupGfxPLL(int freq) {
TDFXTRACE("SetupGfxPLL start\n");
pTDFX=TDFXPTR();
tdfxReg=(vgaTDFXPtr)vgaNewVideoState;
- if (pTDFX->PciInfo->chipType==PCI_CHIP_BANSHEE)
+ if (pTDFX->chipType==PCI_CHIP_BANSHEE)
tdfxReg->gfxpll=CalcPLL(freq, &f_out, 1);
else
tdfxReg->gfxpll=CalcPLL(freq, &f_out, 0);
@@ -1393,8 +1465,9 @@ TDFXModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
#endif
DoRestore(pScrn, &hwp->ModeReg, &pTDFX->ModeReg, FALSE);
#ifdef XF86DRI
- if (pTDFX->directRenderingEnabled)
+ if (pTDFX->directRenderingEnabled) {
DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
+ }
#endif
return TRUE;
@@ -1476,20 +1549,17 @@ TDFXLoadPalette24(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
#define TILE_HEIGHT 32
static int
-calcBufferStride(int xres, Bool tiled)
+calcBufferStride(int xres, Bool tiled, int cpp)
{
int strideInTiles;
if (tiled == TRUE) {
/* Calculate tile width stuff */
- strideInTiles = (xres << 1) >> 7;
- if ((xres << 1) & (TILE_WIDTH - 1))
- strideInTiles++;
+ strideInTiles = (xres+TILE_WIDTH-1)/TILE_WIDTH;
- return (strideInTiles * TILE_WIDTH);
-
+ return strideInTiles*cpp*TILE_WIDTH;
} else {
- return (xres << 1);
+ return xres*cpp;
}
} /* calcBufferStride */
@@ -1510,26 +1580,26 @@ calcBufferHeightInTiles(int yres)
} /* calcBufferHeightInTiles */
static int
-calcBufferSizeInTiles(int xres, int yres) {
+calcBufferSizeInTiles(int xres, int yres, int cpp) {
int bufSizeInTiles; /* Size of buffer in tiles */
bufSizeInTiles =
- calcBufferHeightInTiles(yres) * (calcBufferStride(xres, TRUE) >> 7);
+ calcBufferHeightInTiles(yres) * (calcBufferStride(xres, TRUE, cpp) >> 7);
return bufSizeInTiles;
} /* calcBufferSizeInTiles */
static int
-calcBufferSize(int xres, int yres, Bool tiled)
+calcBufferSize(int xres, int yres, Bool tiled, int cpp)
{
int stride, height, bufSize;
if (tiled) {
- stride = calcBufferStride(xres, tiled);
+ stride = calcBufferStride(xres, tiled, cpp);
height = TILE_HEIGHT * calcBufferHeightInTiles(yres);
} else {
- stride = xres << 1;
+ stride = xres*cpp;
height = yres;
}
@@ -1555,7 +1625,15 @@ static void allocateMemory(ScrnInfoPtr pScrn) {
/* Remove one scanline for page alignment */
memRemaining-=4095;
/* Remove the back and Z buffers */
- screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, TRUE);
+ if (pTDFX->cpp!=3) {
+ screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY,
+ TRUE, pTDFX->cpp);
+ }
+ else {
+ /* cpp==3 needs to bump up to 4 */
+ screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY,
+ TRUE, 4);
+ }
memRemaining-=screenSizeInTiles*2;
/* Give all the rest to textures, rounded down to a page */
@@ -1613,18 +1691,22 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
if (!TDFXMapMem(pScrn)) return FALSE;
pScrn->memPhysBase = (int)pTDFX->LinearAddr;
- if (!pTDFX->usePIO) {
- TDFXSetMMIOAccess(pTDFX);
- hwp->IOBase = ((hwp->readMiscOut(hwp) & 0x01) ?
- VGA_IOBASE_COLOR : VGA_IOBASE_MONO) + (unsigned long)pTDFX->MMIOBase -
- 0x300;
- } else {
- vgaHWGetIOBase(hwp);
- }
+ if (!pTDFX->usePIO) TDFXSetMMIOAccess(pTDFX);
+ vgaHWGetIOBase(hwp);
if (!vgaHWMapMem(pScrn)) return FALSE;
allocateMemory(pScrn);
+ if (pTDFX->numChips>1) {
+ if (xf86ReturnOptValBool(TDFXOptions, OPTION_NO_SLI, FALSE)) {
+ TDFXSetupSLI(pScrn, FALSE, 0);
+ } else {
+ TDFXSetupSLI(pScrn, TRUE, 0);
+ }
+ }
+
+ TDFXSetLFBConfig(pTDFX);
+
#ifdef PROP_3DFX
if (!TDFXInitPrivate(pScreen)) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to initialize private\n");
@@ -1772,7 +1854,6 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
}
if (pTDFX->directRenderingEnabled) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering enabled\n");
- TDFXSetLFBConfig(pTDFX);
} else {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n");
}
@@ -1839,6 +1920,7 @@ TDFXEnterVT(int scrnIndex, int flags) {
if (pTDFX->directRenderingEnabled) {
pScreen = screenInfo.screens[scrnIndex];
DRIUnlock(pScreen);
+ TDFXLostContext(pScreen);
}
#endif
if (!TDFXModeInit(pScrn, pScrn->currentMode)) return FALSE;
@@ -1865,6 +1947,7 @@ TDFXLeaveVT(int scrnIndex, int flags) {
pTDFX = TDFXPTR(pScrn);
if (pTDFX->directRenderingEnabled) {
DRILock(pScreen, 0);
+ TDFXSwapContextPrivate(pScreen);
}
#endif
}
@@ -2011,3 +2094,4 @@ TDFXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode,
pTDFX->writeLong(pTDFX, DACMODE, dacmode);
}
#endif
+
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c
index 62b883a16..73a8b4604 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c
@@ -39,27 +39,35 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "tdfx.h"
-#define minb(p) MMIO_IN8(pTDFX->MMIOBase, (p))
-#define moutb(p,v) MMIO_OUT8(pTDFX->MMIOBase, (p),(v))
-#define minl(p) MMIO_IN32(pTDFX->MMIOBase, (p))
-#define moutl(p,v) MMIO_OUT32(pTDFX->MMIOBase, (p),(v))
+#define minb(b, p) MMIO_IN8((b), (p))
+#define moutb(b, p,v) MMIO_OUT8((b), (p),(v))
+#define minl(b, p) MMIO_IN32((b), (p))
+#define moutl(b, p,v) MMIO_OUT32((b), (p),(v))
static void TDFXWriteControlPIO(TDFXPtr pTDFX, int addr, char index, char val) {
- outb(pTDFX->PIOBase+addr, index);
- outb(pTDFX->PIOBase+addr+1, val);
+ outb(pTDFX->PIOBase[0]+addr, index);
+ outb(pTDFX->PIOBase[0]+addr+1, val);
}
static char TDFXReadControlPIO(TDFXPtr pTDFX, int addr, char index) {
- outb(pTDFX->PIOBase+addr, index);
- return inb(pTDFX->PIOBase+addr+1);
+ outb(pTDFX->PIOBase[0]+addr, index);
+ return inb(pTDFX->PIOBase[0]+addr+1);
+}
+
+void TDFXWriteChipLongPIO(TDFXPtr pTDFX, int chip, int addr, int val) {
+ outl(pTDFX->PIOBase[chip]+addr, val);
+}
+
+int TDFXReadChipLongPIO(TDFXPtr pTDFX, int chip, int addr) {
+ return inl(pTDFX->PIOBase[chip]+addr);
}
static void TDFXWriteLongPIO(TDFXPtr pTDFX, int addr, int val) {
- outl(pTDFX->PIOBase+addr, val);
+ TDFXWriteChipLongPIO(pTDFX, 0, addr, val);
}
static int TDFXReadLongPIO(TDFXPtr pTDFX, int addr) {
- return inl(pTDFX->PIOBase+addr);
+ return TDFXReadChipLongPIO(pTDFX, 0, addr);
}
void TDFXSetPIOAccess(TDFXPtr pTDFX) {
@@ -69,24 +77,34 @@ void TDFXSetPIOAccess(TDFXPtr pTDFX) {
pTDFX->readControl=TDFXReadControlPIO;
pTDFX->writeLong=TDFXWriteLongPIO;
pTDFX->readLong=TDFXReadLongPIO;
+ pTDFX->readChipLong=TDFXReadChipLongPIO;
+ pTDFX->writeChipLong=TDFXWriteChipLongPIO;
}
static void TDFXWriteControlMMIO(TDFXPtr pTDFX, int addr, char index, char val) {
- moutb(addr, index);
- moutb(addr+1, val);
+ moutb(pTDFX->MMIOBase[0], addr, index);
+ moutb(pTDFX->MMIOBase[0], addr+1, val);
}
static char TDFXReadControlMMIO(TDFXPtr pTDFX, int addr, char index) {
- moutb(addr, index);
- return minb(addr+1);
+ moutb(pTDFX->MMIOBase[0], addr, index);
+ return minb(pTDFX->MMIOBase[0], addr+1);
+}
+
+void TDFXWriteChipLongMMIO(TDFXPtr pTDFX, int chip, int addr, int val) {
+ moutl(pTDFX->MMIOBase[chip], addr, val);
+}
+
+static int TDFXReadChipLongMMIO(TDFXPtr pTDFX, int chip, int addr) {
+ return minl(pTDFX->MMIOBase[chip], addr);
}
void TDFXWriteLongMMIO(TDFXPtr pTDFX, int addr, int val) {
- moutl(addr, val);
+ TDFXWriteChipLongMMIO(pTDFX, 0, addr, val);
}
int TDFXReadLongMMIO(TDFXPtr pTDFX, int addr) {
- return minl(addr);
+ return TDFXReadChipLongMMIO(pTDFX, 0, addr);
}
void TDFXSetMMIOAccess(TDFXPtr pTDFX) {
@@ -96,5 +114,7 @@ void TDFXSetMMIOAccess(TDFXPtr pTDFX) {
pTDFX->readControl=TDFXReadControlMMIO;
pTDFX->writeLong=TDFXWriteLongMMIO;
pTDFX->readLong=TDFXReadLongMMIO;
+ pTDFX->writeChipLong=TDFXWriteChipLongMMIO;
+ pTDFX->readChipLong=TDFXReadChipLongMMIO;
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c
index 7082547df..0d09b79dd 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c
@@ -23,28 +23,41 @@
C - D-1 : Z buffer
*/
-static void TDFXSendNOPPrivate2D(TDFXPtr pTDFX)
+void TDFXSendNOPPrivate3D(ScrnInfoPtr pScrn)
{
+ TDFXPtr pTDFX;
+
+ if (!pTDFX->syncDone) {
+ TDFXFirstSync(pScrn);
+ return;
+ }
+ pTDFX=TDFXPTR(pScrn);
TDFXAllocateSlots(pTDFX, 2);
- SET_3DPK4_HEADER(1, 0x48);
+ SET_3DPK4_HEADER(1, 0x48<<3);
WRITE_FIFO(pTDFX, 0, 0);
}
-static void TDFXSendNOPPrivate3D(TDFXPtr pTDFX)
+void TDFXSendNOPPrivate2D(ScrnInfoPtr pScrn)
{
+ TDFXPtr pTDFX;
+
+ pTDFX=TDFXPTR(pScrn);
TDFXAllocateSlots(pTDFX, 2);
SET_PKT2_HEADER(SSTCP_COMMAND);
WRITE_FIFO(pTDFX, SST_2D_COMMAND, SST_2D_NOP|SST_2D_GO);
}
-void TDFXSendNOPPrivate(TDFXPtr pTDFX)
+void TDFXSendNOPPrivate(ScrnInfoPtr pScrn)
{
- TDFXSendNOPPrivate2D(pTDFX);
- TDFXSendNOPPrivate3D(pTDFX);
+ TDFXSendNOPPrivate2D(pScrn);
+ TDFXSendNOPPrivate3D(pScrn);
}
-static void InstallFifo(TDFXPtr pTDFX)
+void InstallFifo(ScrnInfoPtr pScrn)
{
+ TDFXPtr pTDFX;
+
+ pTDFX=TDFXPTR(pScrn);
/* Install the fifo */
TDFXWriteLongMMIO(pTDFX, SST_FIFO_BASEADDR0, pTDFX->fifoOffset>>12);
TDFXWriteLongMMIO(pTDFX, SST_FIFO_BUMP0, 0);
@@ -54,7 +67,7 @@ static void InstallFifo(TDFXPtr pTDFX)
TDFXWriteLongMMIO(pTDFX, SST_FIFO_AMAX0, pTDFX->fifoOffset-4);
TDFXWriteLongMMIO(pTDFX, SST_FIFO_DEPTH0, 0);
TDFXWriteLongMMIO(pTDFX, SST_FIFO_HOLECNT0, 0);
- if (pTDFX->PciInfo->chipType == PCI_CHIP_BANSHEE)
+ if (pTDFX->ChipType == PCI_CHIP_BANSHEE)
TDFXWriteLongMMIO(pTDFX, SST_FIFO_FIFOTHRESH, (0x9<<5) | 0x2);
else
TDFXWriteLongMMIO(pTDFX, SST_FIFO_FIFOTHRESH, (0xf<<5) | 0x8);
@@ -65,14 +78,16 @@ static void InstallFifo(TDFXPtr pTDFX)
pTDFX->fifoPtr = pTDFX->fifoBase;
pTDFX->fifoSlots = (pTDFX->fifoSize>>2) - 1;
pTDFX->fifoEnd = pTDFX->fifoBase+pTDFX->fifoSlots;
- TDFXSendNOPPrivate(pTDFX);
+ TDFXSendNOPPrivate(pScrn);
}
-static void TDFXResetFifo(TDFXPtr pTDFX)
+void TDFXResetFifo(ScrnInfoPtr pScrn)
{
+ TDFXPtr pTDFX;
int oldValue;
CARD32 start_sec, end_sec, dummy;
+ pTDFX=TDFXPTR(pScrn);
ErrorF("Resetting FIFO\n");
/* Shut down the fifo */
TDFXWriteLongMMIO(pTDFX, SST_FIFO_BASESIZE0, 0);
@@ -91,7 +106,7 @@ static void TDFXResetFifo(TDFXPtr pTDFX)
xf86getsecs(&end_sec, &dummy);
} while (end_sec-start_sec<2);
TDFXWriteLongMMIO(pTDFX, MISCINIT1, oldValue);
- InstallFifo(pTDFX);
+ InstallFifo(pScrn);
}
/*
@@ -111,7 +126,7 @@ static void TDFXSyncFifo(ScrnInfoPtr pScrn)
TDFXTRACEACCEL("TDFXSyncFifo start\n");
pTDFX=TDFXPTR(pScrn);
- TDFXSendNOPPrivate(pTDFX);
+ TDFXSendNOPPrivate(pScrn);
i=0;
cnt=0;
start_sec=0;
@@ -125,7 +140,7 @@ static void TDFXSyncFifo(ScrnInfoPtr pScrn)
} else {
xf86getsecs(&end_sec, &dummy);
if (end_sec-start_sec>3) {
- TDFXResetFifo(pTDFX);
+ TDFXResetFifo(pScrn);
start_sec=0;
}
}
@@ -153,7 +168,7 @@ Bool TDFXInitPrivate(ScreenPtr pScreen)
pTDFX->fifoMirrorPtr = pTDFX->fifoMirrorBase;
#endif
pTDFX->sync=TDFXSyncFifo;
- InstallFifo(pTDFX);
+ InstallFifo(pScrn);
return TRUE;
}
@@ -213,7 +228,7 @@ void TDFXSwapContextPrivate(ScreenPtr pScreen)
(sPriv->fifoRead<pTDFX->fifoOffset) ||
(sPriv->fifoRead>(int)pTDFX->fifoOffset+pTDFX->fifoSize)) {
ErrorF("Invalid offsets passed between client and X server\n");
- ResetFifo(pTDFX);
+ ResetFifo(pScrn);
} else {
pTDFX->fifoPtr = (unsigned int *)(pTDFX->FbBase+sPriv->fifoPtr);
pTDFX->fifoRead = (unsigned int *)(pTDFX->FbBase+sPriv->fifoRead);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c
new file mode 100644
index 000000000..fd442c49d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c
@@ -0,0 +1,768 @@
+
+#include "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Pci.h"
+#include "tdfx.h"
+
+#define AACLKOUTDEL 0x2
+#define CFGSWAPALGORITHM 0x1
+
+/* #define RD_ABORT_ERROR */
+#define H3VDD
+
+static Bool TDFXDisableSLI(TDFXPtr pTDFX)
+{
+ int i;
+ int v;
+
+ for (i=0; i<pTDFX->numChips; i++) {
+ v=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE);
+ pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE,
+ v&~(CFG_SNOOP_MEMBASE0 | CFG_SNOOP_EN | CFG_SNOOP_MEMBASE0_EN |
+ CFG_SNOOP_MEMBASE1_EN | CFG_SNOOP_SLAVE |
+ CFG_SNOOP_FBIINIT_WR_EN | CFG_SWAP_ALGORITHM |
+ CFG_SWAP_QUICK));
+ v=pciReadLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL);
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL,
+ v&~(CFG_SLI_LFB_CPU_WR_EN | CFG_SLI_LFB_DPTCH_WR_EN |
+ CFG_SLI_RD_EN));
+#ifdef H3VDD
+ pTDFX->writeChipLong(pTDFX, i, SST_3D_SLICTRL, 0);
+ pTDFX->writeChipLong(pTDFX, i, SST_3D_AACTRL, 0);
+#endif
+ v=pciReadLong(pTDFX->PciTag[i], CFG_AA_LFB_CTRL);
+ pciWriteLong(pTDFX->PciTag[i], CFG_AA_LFB_CTRL,
+ v&~(CFG_AA_LFB_CPU_WR_EN | CFG_AA_LFB_DPTCH_WR_EN |
+ CFG_AA_LFB_RD_EN));
+ v=pciReadLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC);
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC,
+ (v&~CFG_VGA_VSYNC_OFFSET) |
+ (0 << CFG_VGA_VSYNC_OFFSET_PIXELS_SHIFT) |
+ (0 << CFG_VGA_VSYNC_OFFSET_CHARS_SHIFT) |
+ (0 << CFG_VGA_VSYNC_OFFSET_HXTRA_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, 0);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, 0);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, 0);
+
+ if (pTDFX->numChips>1) {
+ v=pTDFX->readChipLong(pTDFX, i, PCIINIT0);
+ pTDFX->writeChipLong(pTDFX, i, PCIINIT0,
+ (v&~(SST_PCI_DISABLE_IO|SST_PCI_DISABLE_MEM|
+ SST_PCI_RETRY_INTERVAL)) |
+ (0<<SST_PCI_RETRY_INTERVAL_SHIFT) |
+ SST_PCI_FORCE_FB_HIGH);
+ } else {
+ v=pTDFX->readChipLong(pTDFX, i, PCIINIT0);
+ pTDFX->writeChipLong(pTDFX, i, PCIINIT0,
+ (v&~(SST_PCI_DISABLE_IO|SST_PCI_DISABLE_MEM|
+ SST_PCI_RETRY_INTERVAL)) |
+ (0<<SST_PCI_RETRY_INTERVAL_SHIFT));
+ }
+
+#if 0
+ if (i>0) {
+ pTDFX->writeChipLong(pTDFX, i, DACMODE,
+ SST_DAC_DPMS_ON_VSYNC | SST_DAC_DPMS_ON_HSYNC);
+ v=pTDFX->readChipLong(pTDFX, i, VIDPROCCFG);
+ pTDFX->writeChipLong(pTDFX, i, VIDPROCCFG, v&~SST_VIDEO_PROCESSOR_EN);
+ }
+#endif
+ }
+ return TRUE;
+}
+
+Bool TDFXSetupSLI(ScrnInfoPtr pScrn, Bool sliEnable, int aaSamples)
+{
+ TDFXPtr pTDFX;
+ int i, sliLines, sliLinesLog2, nChipsLog2, v;
+ int sli_renderMask, sli_compareMask, sli_scanMask;
+ int sliAnalog, dwFormat;
+
+ pTDFX=TDFXPTR(pScrn);
+ if (pScrn->depth == 24 || pScrn->depth==32) {
+ if ((aaSamples == 4) && (pTDFX->numChips>1)) {
+ pTDFX->pixelFormat=GR_PIXFMT_AA_4_ARGB_8888;
+ } else if (aaSamples >= 2) {
+ pTDFX->pixelFormat=GR_PIXFMT_AA_2_ARGB_8888;
+ } else {
+ pTDFX->pixelFormat=GR_PIXFMT_ARGB_8888;
+ }
+ } else if (pScrn->depth == 16) {
+ if ((aaSamples == 4) && (pTDFX->numChips>1)) {
+ pTDFX->pixelFormat=GR_PIXFMT_AA_4_RGB_565;
+ } else if (aaSamples >= 2) {
+ pTDFX->pixelFormat=GR_PIXFMT_AA_2_RGB_565;
+ } else {
+ pTDFX->pixelFormat=GR_PIXFMT_RGB_565;
+ }
+ } else if (pScrn->depth == 8) {
+ pTDFX->pixelFormat=GR_PIXFMT_I_8;
+ }
+ if (!sliEnable && !aaSamples) { /* Turn off */
+ return TDFXDisableSLI(pTDFX);
+ }
+
+ if (pScrn->virtualY>768) sliLinesLog2=5;
+ else sliLinesLog2=4;
+ sliLines=1<<sliLinesLog2;
+ if (pScrn->virtualY*pScrn->virtualX>1600*1024) sliAnalog=1;
+ else sliAnalog=0;
+ /* XXX We need to avoid SLI in double scan modes somehow */
+
+ switch (pTDFX->numChips) {
+ case 1:
+ nChipsLog2=0;
+ break;
+ case 2:
+ nChipsLog2=1;
+ break;
+ case 4:
+ nChipsLog2=2;
+ break;
+ default:
+ return FALSE;
+ /* XXX Huh? Unsupported configuration */
+ }
+
+ for (i=0; i<pTDFX->numChips; i++) {
+ /* Do we want to set these differently for a VIA board? */
+ v=pTDFX->readChipLong(pTDFX, i, PCIINIT0);
+ v=(v&~(SST_PCI_RETRY_INTERVAL|SST_PCI_FORCE_FB_HIGH)) |
+ SST_PCI_READ_WS | SST_PCI_WRITE_WS |
+ SST_PCI_DISABLE_IO | SST_PCI_DISABLE_MEM |
+ (5<<SST_PCI_RETRY_INTERVAL_SHIFT);
+ pTDFX->writeChipLong(pTDFX, i, PCIINIT0,
+ (v&~(SST_PCI_RETRY_INTERVAL|SST_PCI_FORCE_FB_HIGH)) |
+ SST_PCI_READ_WS | SST_PCI_WRITE_WS |
+ SST_PCI_DISABLE_IO | SST_PCI_DISABLE_MEM |
+ (5<<SST_PCI_RETRY_INTERVAL_SHIFT));
+ v=pTDFX->readChipLong(pTDFX, i, TMUGBEINIT);
+ pTDFX->writeChipLong(pTDFX, i, TMUGBEINIT,
+ (v&~(SST_AA_CLK_DELAY | SST_AA_CLK_INVERT)) |
+ (AACLKOUTDEL<<SST_AA_CLK_DELAY_SHIFT) |
+ SST_AA_CLK_INVERT);
+
+ if (pTDFX->numChips>1) {
+ v=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE);
+ pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, v |
+ (CFGSWAPALGORITHM << CFG_SWAPBUFFER_ALGORITHM_SHIFT) |
+ CFG_SWAP_ALGORITHM | ((!i)? CFG_SWAP_MASTER : 0));
+ if (!i) {
+ v=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE);
+ pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE,
+ v | CFG_SNOOP_EN);
+ v=pciReadLong(pTDFX->PciTag[i], CFG_PCI_DECODE);
+ } else {
+ v=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE);
+ v=(v & ~CFG_SNOOP_MEMBASE0) | CFG_SNOOP_EN |
+ CFG_SNOOP_MEMBASE0_EN | CFG_SNOOP_MEMBASE1_EN |
+ CFG_SNOOP_SLAVE | CFG_SNOOP_FBIINIT_WR_EN |
+ (((pTDFX->MMIOAddr[0]>>22)&0x3ff)<<CFG_SNOOP_MEMBASE0_SHIFT) |
+ ((pTDFX->numChips>2)? CFG_SWAP_QUICK : 0);
+ pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, v);
+ v=pciReadLong(pTDFX->PciTag[i], CFG_PCI_DECODE);
+ v=(v & ~CFG_SNOOP_MEMBASE1) |
+ ((pTDFX->LinearAddr[0]>>22)&0x3ff)<<CFG_SNOOP_MEMBASE1_SHIFT;
+ pciWriteLong(pTDFX->PciTag[i], CFG_PCI_DECODE, v);
+ }
+ }
+
+ if (sliEnable && aaSamples<4) {
+ /* SLI is on and we're using less than 4 AA samples */
+ sli_renderMask = (pTDFX->numChips-1) << sliLinesLog2;
+ sli_compareMask = i << sliLinesLog2;
+ sli_scanMask = sliLines - 1;
+ v = (sli_renderMask << CFG_SLI_LFB_RENDERMASK_SHIFT) |
+ (sli_compareMask << CFG_SLI_LFB_COMPAREMASK_SHIFT) |
+ (sli_scanMask << CFG_SLI_LFB_SCANMASK_SHIFT) |
+ (nChipsLog2 << CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT) |
+ CFG_SLI_LFB_CPU_WR_EN | CFG_SLI_LFB_DPTCH_WR_EN;
+#ifndef RD_ABORT_ERROR
+ v|=CFG_SLI_RD_EN;
+#endif
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL, v);
+
+#ifdef H3VDD
+ pTDFX->writeChipLong(pTDFX, i, SST_3D_SLICTRL,
+ (sli_renderMask << SLICTL_3D_RENDERMASK_SHIFT) |
+ (sli_compareMask << SLICTL_3D_COMPAREMASK_SHIFT) |
+ (sli_scanMask << SLICTL_3D_SCANMASK_SHIFT) |
+ (nChipsLog2 << SLICTL_3D_NUMCHIPS_LOG2_SHIFT) |
+ SLICTL_3D_EN);
+#endif
+ } else if (!sliEnable && aaSamples) {
+ /* SLI is off and AA is on */
+ sli_renderMask = 0;
+ sli_compareMask = 0;
+ sli_scanMask = 0;
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL,
+ (sli_renderMask << CFG_SLI_LFB_RENDERMASK_SHIFT) |
+ (sli_compareMask << CFG_SLI_LFB_COMPAREMASK_SHIFT) |
+ (sli_scanMask << CFG_SLI_LFB_SCANMASK_SHIFT) |
+ (0x0 << CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT));
+#ifdef H3VDD
+ pTDFX->writeChipLong(pTDFX, i, SST_3D_SLICTRL,
+ (sli_renderMask << SLICTL_3D_RENDERMASK_SHIFT) |
+ (sli_compareMask << SLICTL_3D_COMPAREMASK_SHIFT) |
+ (sli_scanMask << SLICTL_3D_SCANMASK_SHIFT) |
+ (0 << SLICTL_3D_NUMCHIPS_LOG2_SHIFT));
+#endif
+ } else {
+ /* SLI is on && aaSamples=4 */
+ sli_renderMask = ((pTDFX->numChips>>1)-1) << sliLinesLog2;
+ sli_compareMask = (i>>1) << sliLinesLog2;
+ sli_scanMask = sliLines - 1;
+ v = (sli_renderMask << CFG_SLI_LFB_RENDERMASK_SHIFT) |
+ (sli_compareMask << CFG_SLI_LFB_COMPAREMASK_SHIFT) |
+ (sli_scanMask << CFG_SLI_LFB_SCANMASK_SHIFT) |
+ ((nChipsLog2-1) << CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT) |
+ CFG_SLI_LFB_CPU_WR_EN | CFG_SLI_LFB_DPTCH_WR_EN;
+#ifndef RD_ABORT_ERROR
+ v|=CFG_SLI_RD_EN;
+#endif
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL, v);
+#ifdef H3VDD
+ pTDFX->writeChipLong(pTDFX, i, SST_3D_SLICTRL,
+ (sli_renderMask << SLICTL_3D_RENDERMASK_SHIFT) |
+ (sli_compareMask << SLICTL_3D_COMPAREMASK_SHIFT) |
+ (sli_scanMask << SLICTL_3D_SCANMASK_SHIFT) |
+ ((nChipsLog2-1) << SLICTL_3D_NUMCHIPS_LOG2_SHIFT) |
+ SLICTL_3D_EN);
+#endif
+ }
+
+ TDFXSetLFBConfig(pTDFX);
+ if (pTDFX->cpp==2) dwFormat = CFG_AA_LFB_RD_FORMAT_16BPP;
+ else dwFormat = CFG_AA_LFB_RD_FORMAT_32BPP;
+ if (pTDFX->numChips==2 && !sliEnable && aaSamples==2)
+ dwFormat|=CFG_AA_LFB_RD_DIVIDE_BY_4;
+ /* Thess are wrong, because we don't know where the secondary buffers
+ are located */
+ pTDFX->writeChipLong(pTDFX, i, CFG_AA_LFB_CTRL,
+ (pScrn->videoRam<<10 /* 2nd buf */ << CFG_AA_BASEADDR_SHIFT) |
+ CFG_AA_LFB_CPU_WR_EN | CFG_AA_LFB_DPTCH_WR_EN |
+ CFG_AA_LFB_RD_EN | dwFormat |
+ ((aaSamples==4)?CFG_AA_LFB_RD_DIVIDE_BY_4:0));
+ pTDFX->writeChipLong(pTDFX, i, CFG_AA_ZBUFF_APERTURE,
+ ((pTDFX->depthOffset>>12)<<CFG_AA_DEPTH_BUFFER_BEG_SHIFT) |
+ ((pScrn->videoRam>>2)<<CFG_AA_DEPTH_BUFFER_END_SHIFT));
+
+ if (pTDFX->numChips>1 && i && (aaSamples || sliEnable)) {
+ int vsyncOffsetPixels, vsyncOffsetChars, vsyncOffsetHXtra;
+
+ if (aaSamples || (pTDFX->numChips==4 && sliEnable && aaSamples==4 &&
+ sliAnalog && i==3)) {
+ vsyncOffsetPixels=7;
+ vsyncOffsetChars=4;
+ vsyncOffsetHXtra=0;
+ } else {
+ vsyncOffsetPixels=7;
+ vsyncOffsetChars=5;
+ vsyncOffsetHXtra=0;
+ }
+ v=pciReadLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC);
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC,
+ (v&~CFG_VGA_VSYNC_OFFSET) |
+ (vsyncOffsetPixels << CFG_VGA_VSYNC_OFFSET_PIXELS_SHIFT) |
+ (vsyncOffsetChars << CFG_VGA_VSYNC_OFFSET_CHARS_SHIFT) |
+ (vsyncOffsetHXtra <<
+ CFG_VGA_VSYNC_OFFSET_HXTRA_SHIFT));
+ }
+ if (pTDFX->numChips==1 && aaSamples) {
+ /* 1 chip 2 AA */
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ CFG_VIDEO_OTHERMUX_SEL_PIPE<<CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT |
+ CFG_DIVIDE_VIDEO_BY_2);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ 0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT |
+ 0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT |
+ 0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT |
+ 0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ 0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT |
+ 0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT);
+ } else if (pTDFX->numChips==2 && !sliEnable && aaSamples==4 &&
+ !sliAnalog) {
+ /* 2 chips 4 digital AA */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ (CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==2 && !sliEnable && aaSamples==4 && sliAnalog) {
+ /* 2 chips 4 analog AA */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ (CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_DAC_HSYNC_TRISTATE |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==2 && sliEnable && !aaSamples && !sliAnalog) {
+ /* 2 chips 2 digital SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ (CFG_ENHANCED_VIDEO_EN |
+ (CFG_VIDEO_OTHERMUX_SEL_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ ((0x0<<sliLinesLog2) << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((i<<sliLinesLog2) <<
+ CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips>=2 && sliEnable && !aaSamples && sliAnalog) {
+ /* 2 or 4 chips 2/4 analog SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((i<<sliLinesLog2) <<
+ CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==2 && sliEnable && aaSamples==2 && !sliAnalog) {
+ /* 2 chips 2 AA 2 digital SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_2);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((0x1<<sliLinesLog2) <<
+ CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((i<<sliLinesLog2) <<
+ CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==2 && !sliEnable && aaSamples==2 && !sliAnalog) {
+ /* 2 chips 2 digital AA */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_2);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==2 && !sliEnable && aaSamples==2 && sliAnalog) {
+ /* 2 chips 2 analog AA */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_2);
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_DAC_HSYNC_TRISTATE |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_2);
+ }
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else if (pTDFX->numChips>=2 && sliEnable && aaSamples==2 && sliAnalog) {
+ /* 2 or 4 chips 2 AA 2 or 4 analog SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_2);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_2);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==4 && sliEnable && !aaSamples && !sliAnalog) {
+ /* 4 chips 4 digital SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ (CFG_VIDEO_OTHERMUX_SEL_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_SLI_AAFIFO_COMPARE_INV |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((0x0<<sliLinesLog2) <<
+ CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==4 && sliEnable && aaSamples==2 && !sliAnalog) {
+ /* 4 chips 2 AA 4 digital SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_SLI_AAFIFO_COMPARE_INV |
+ CFG_DIVIDE_VIDEO_BY_2);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==4 && sliEnable && aaSamples==4 && !sliAnalog) {
+ /* 4 chips 4 AA 2 digital SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else if (i==1 || i==3) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_DAC_HSYNC_TRISTATE |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((((i+1)>>2)<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ ((0x0<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((0xff<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==4 && sliEnable && aaSamples==4 && sliAnalog) {
+ /* 4 chips 4 AA 2 analog SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else if (i==1 || i==3) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_DAC_HSYNC_TRISTATE |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((((i+1)>>2)<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((((i+1)>>2)<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ }
+ if (pTDFX->numChips==4 && sliEnable && aaSamples==4 && i==3) {
+ v=pciReadLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC);
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC,
+ v | CFG_AA_LFB_RD_SLV_WAIT);
+ }
+ if (i) {
+ v=pciReadLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ v|CFG_VIDPLL_SEL);
+ v=pTDFX->readChipLong(pTDFX, i, MISCINIT1);
+ pTDFX->writeChipLong(pTDFX, i, MISCINIT1, v|SST_POWERDOWN_DAC);
+ }
+ }
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h
index bb82da4cd..c6224d78f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h
@@ -176,7 +176,184 @@
#define SST_3D_NOP 0
/* 3D Registers */
-#define SST_3D_OFFSET 0x200000
-#define SST_3D_COMMAND SST_3D_OFFSET+0x120
+#define SST_3D_OFFSET 0x200000
+#define SST_3D_COMMAND SST_3D_OFFSET+0x120
+#define SST_3D_SLICTRL SST_3D_OFFSET+0x20C
+#define SST_3D_AACTRL SST_3D_OFFSET+0x210
+#define SST_3D_CHIPMASK SST_3D_OFFSET+0x214
+
+/* NAPALM REGISTERS */
+#define CFG_MEM0BASE 16
+#define CFG_MEM1BASE 20
+#define CFG_INIT_ENABLE 64
+#define CFG_PCI_DECODE 72
+#define CFG_VIDEO_CTRL0 128
+#define CFG_VIDEO_CTRL1 132
+#define CFG_VIDEO_CTRL2 136
+#define CFG_SLI_LFB_CTRL 140
+#define CFG_AA_ZBUFF_APERTURE 144
+#define CFG_AA_LFB_CTRL 148
+#define CFG_SLI_AA_MISC 172
+
+/* Pixel Formats */
+#define GR_PIXFMT_I_8 0x0001
+#define GR_PIXFMT_AI_88 0x0002
+#define GR_PIXFMT_RGB_565 0x0003
+#define GR_PIXFMT_ARGB_1555 0x0004
+#define GR_PIXFMT_ARGB_8888 0x0005
+#define GR_PIXFMT_AA_2_RGB_565 0x0006
+#define GR_PIXFMT_AA_2_ARGB_1555 0x0007
+#define GR_PIXFMT_AA_2_ARGB_8888 0x0008
+#define GR_PIXFMT_AA_4_RGB_565 0x0009
+#define GR_PIXFMT_AA_4_ARGB_1555 0x000a
+#define GR_PIXFMT_AA_4_ARGB_8888 0x000b
+
+/* pciInit0 */
+#define SST_PCI_STALL_ENABLE BIT(0)
+#define SST_PCI_LOWTHRESH_SHIFT 2
+#define SST_PCI_LOWTHRESH (0xF << SST_PCI_LOWTHRESH_SHIFT)
+#define SST_PCI_HARDCODE_BASE BIT(7)
+#define SST_PCI_READ_WS BIT(8)
+#define SST_PCI_WRITE_WS BIT(9)
+#define SST_PCI_DISABLE_IO BIT(11)
+#define SST_PCI_DISABLE_MEM BIT(12)
+#define SST_PCI_RETRY_INTERVAL_SHIFT 13
+#define SST_PCI_RETRY_INTERVAL (0x1F << SST_PCI_RETRY_INTERVAL_SHIFT)
+#define SST_PCI_INTERRUPT_ENABLE BIT(18)
+#define SST_PCI_TIMEOUT_ENABLE BIT(19)
+#define SST_PCI_FORCE_FB_HIGH BIT(26)
+
+#define SST_AA_CLK_INVERT BIT(20)
+#define SST_AA_CLK_DELAY_SHIFT 21
+#define SST_AA_CLK_DELAY (0xF<<SST_AA_CLK_DELAY_SHIFT)
+
+#define CFG_SWAP_ALGORITHM_VSYNC (0x00)
+#define CFG_SWAP_ALGORITHM_SYNCIN (0x01)
+#define CFG_SWAPBUFFER_ALGORITHM_SHIFT (25)
+
+/* CFG_INIT_ENABLE */
+#define CFG_UPDATE_MEMBASE_LSBS BIT(10)
+#define CFG_SNOOP_EN BIT(11)
+#define CFG_SNOOP_MEMBASE0_EN BIT(12)
+#define CFG_SNOOP_MEMBASE1_EN BIT(13)
+#define CFG_SNOOP_SLAVE BIT(14)
+#define CFG_SNOOP_MEMBASE0_SHIFT 15
+#define CFG_SNOOP_MEMBASE0 (0x3FF<<CFG_SNOOP_MEMBASE0_SHIFT)
+#define CFG_SWAP_ALGORITHM BIT(25)
+#define CFG_SWAP_MASTER BIT(26)
+#define CFG_SWAP_QUICK BIT(27)
+#define CFG_MULTI_FUNCTION_DEV BIT(28)
+#define CFG_LFB_RD_CACHE_DISABLE BIT(29)
+#define CFG_SNOOP_FBIINIT_WR_EN BIT(30)
+#define CFG_SNOOP_MEMBASE0_DECODE_SHIFT 10
+#define CFG_SNOOP_MEMBASE0_DECODE (0xF<<CFG_SNOOP_MEMBASE0_DECODE_SHIFT)
+#define CFG_SNOOP_MEMBASE1_DECODE_SHIFT 14
+#define CFG_SNOOP_MEMBASE1_DECODE (0xF<<CFG_SNOOP_MEMBASE1_DECODE_SHIFT)
+#define CFG_SNOOP_MEMBASE1_SHIFT 18
+#define CFG_SNOOP_MEMBASE1 (0x3FF<<CFG_SNOOP_MEMBASE1_SHIFT)
+
+/* CFG_VIDEO_CTRL0 */
+#define CFG_ENHANCED_VIDEO_EN BIT(0)
+#define CFG_ENHANCED_VIDEO_SLV BIT(1)
+#define CFG_VIDEO_TV_OUTPUT_EN BIT(2)
+#define CFG_VIDEO_LOCALMUX_SEL BIT(3)
+#define CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY BIT(3)
+#define CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT 4
+#define CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT 6
+#define CFG_VIDEO_OTHERMUX_SEL_TRUE (0x3<<CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT)
+#define CFG_VIDEO_OTHERMUX_SEL_FALSE (0x3<<CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT)
+#define CFG_VIDEO_OTHERMUX_SEL_PIPE 0
+#define CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO 1
+#define CFG_VIDEO_OTHERMUX_SEL_AAFIFO 2
+#define CFG_SLI_FETCH_COMPARE_INV BIT(8)
+#define CFG_SLI_CRT_COMPARE_INV BIT(9)
+#define CFG_SLI_AAFIFO_COMPARE_INV BIT(10)
+#define CFG_VIDPLL_SEL BIT(11)
+#define CFG_DIVIDE_VIDEO_SHIFT 12
+#define CFG_DIVIDE_VIDEO (0x7<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_DIVIDE_VIDEO_BY_1 (0x0<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_DIVIDE_VIDEO_BY_2 (0x1<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_DIVIDE_VIDEO_BY_4 (0x2<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_DIVIDE_VIDEO_BY_8 (0x3<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_DIVIDE_VIDEO_BY_16 (0x4<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_DIVIDE_VIDEO_BY_32 (0x5<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_ALWAYS_DRIVE_AA_BUS BIT(15)
+#define CFG_VSYNC_IN_DEL_SHIFT 16
+#define CFG_VSYNC_IN_DEL (0xF<<CFG_VSYNC_IN_DEL_SHIFT)
+#define CFG_DAC_VSYNC_TRISTATE BIT(24)
+#define CFG_DAC_HSYNC_TRISTATE BIT(25)
+
+/* CFG_VIDEO_CTRL1 */
+#define CFG_SLI_RENDERMASK_FETCH_SHIFT 0
+#define CFG_SLI_RENDERMASK_FETCH (0xFF<<CFG_SLI_RENDERMASK_FETCH_SHIFT)
+#define CFG_SLI_COMPAREMASK_FETCH_SHIFT 8
+#define CFG_SLI_COMPAREMASK_FETCH (0xFF<<CFG_SLI_COMPAREMASK_FETCH_SHIFT)
+#define CFG_SLI_RENDERMASK_CRT_SHIFT 16
+#define CFG_SLI_RENDERMASK_CRT (0xFF<<CFG_SLI_RENDERMASK_CRT_SHIFT)
+#define CFG_SLI_COMPAREMASK_CRT_SHIFT 24
+#define CFG_SLI_COMPAREMASK_CRT (0xFF<<CFG_SLI_COMPAREMASK_CRT_SHIFT)
+
+/* CFG_VIDEO_CTRL2 */
+#define CFG_SLI_RENDERMASK_AAFIFO_SHIFT 0
+#define CFG_SLI_RENDERMASK_AAFIFO (0xFF<<CFG_SLI_RENDERMASK_AAFIFO_SHIFT)
+#define CFG_SLI_COMPAREMASK_AAFIFO_SHIFT 8
+#define CFG_SLI_COMPAREMASK_AAFIFO (0xFF<<CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)
+
+/* CFG_SLI_LFB_CTRL */
+#define CFG_SLI_LFB_RENDERMASK_SHIFT 0
+#define CFG_SLI_LFB_RENDERMASK (0xFF<<CFG_SLI_LFB_RENDERMASK_SHIFT)
+#define CFG_SLI_LFB_COMPAREMASK_SHIFT 8
+#define CFG_SLI_LFB_COMPAREMASK (0xFF<<CFG_SLI_LFB_COMPAREMASK_SHIFT)
+#define CFG_SLI_LFB_SCANMASK_SHIFT 16
+#define CFG_SLI_LFB_SCANMASK (0xFF<<CFG_SLI_LFB_SCANMASK_SHIFT)
+#define CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT 24
+#define CFG_SLI_LFB_NUMCHIPS_LOG2 (0x3<<CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT)
+#define CFG_SLI_LFB_CPU_WR_EN BIT(26)
+#define CFG_SLI_LFB_DPTCH_WR_EN BIT(27)
+#define CFG_SLI_RD_EN BIT(28)
+
+/* CFG_AA_ZBUFF_APERTURE */
+#define CFG_AA_DEPTH_BUFFER_BEG_SHIFT 0
+#define CFG_AA_DEPTH_BUFFER_BEG (0x7FFF<<CFG_AA_DEPTH_BUFFER_BEG_SHIFT)
+#define CFG_AA_DEPTH_BUFFER_END_SHIFT 16
+#define CFG_AA_DEPTH_BUFFER_END (0xFFFF<<CFG_AA_DEPTH_BUFFER_END_SHIFT)
+
+/* CFG_AA_LFB_CTRL */
+#define CFG_AA_BASEADDR_SHIFT 0
+#define CFG_AA_BASEADDR (0x3FFFFFF<<CFG_AA_BASEADDR_SHIFT)
+#define CFG_AA_LFB_CPU_WR_EN BIT(26)
+#define CFG_AA_LFB_DPTCH_WR_EN BIT(27)
+#define CFG_AA_LFB_RD_EN BIT(28)
+#define CFG_AA_LFB_RD_FORMAT_SHIFT 29
+#define CFG_AA_LFB_RD_FORMAT (0x3<<CFG_AA_LFB_RD_FORMAT_SHIFT)
+#define CFG_AA_LFB_RD_FORMAT_16BPP (0x0<<CFG_AA_LFB_RD_FORMAT_SHIFT)
+#define CFG_AA_LFB_RD_FORMAT_15BPP (0x1<<CFG_AA_LFB_RD_FORMAT_SHIFT)
+#define CFG_AA_LFB_RD_FORMAT_32BPP (0x2<<CFG_AA_LFB_RD_FORMAT_SHIFT)
+#define CFG_AA_LFB_RD_DIVIDE_BY_4 BIT(31)
+
+/* CFG_SLI_AA_MISC */
+#define CFG_VGA_VSYNC_OFFSET_SHIFT 0
+#define CFG_VGA_VSYNC_OFFSET (0x1ff<<CFG_VGA_VSYNC_OFFSET_SHIFT)
+#define CFG_VGA_VSYNC_OFFSET_PIXELS_SHIFT 0
+#define CFG_VGA_VSYNC_OFFSET_CHARS_SHIFT 3
+#define CFG_VGA_VSYNC_OFFSET_HXTRA_SHIFT 6
+#define CFG_HOTPLUG_SHIFT 9
+#define CFG_HOTPLUG_TRISTATE (0x0<<CFG_HOTPLUG_SHIFT)
+#define CFG_HOTPLUG_DRIVE0 (0x2<<CFG_HOTPLUG_SHIFT)
+#define CFG_HOTPLUG_DRIVE1 (0x3<<CFG_HOTPLUG_SHIFT)
+#define CFG_AA_LFB_RD_SLV_WAIT BIT(12)
+
+/* SLICTL_3D_CTRL */
+#define SLICTL_3D_RENDERMASK_SHIFT 0
+#define SLICTL_3D_RENDERMASK (0xFF<<SLICTL_3D_RENDERMASK_SHIFT)
+#define SLICTL_3D_COMPAREMASK_SHIFT 8
+#define SLICTL_3D_COMPAREMASK (0xFF<<SLICTL_3D_COMPAREMASK_SHIFT)
+#define SLICTL_3D_SCANMASK_SHIFT 16
+#define SLICTL_3D_SCANMASK (0xFF<<SLICTL_3D_SCANMASK_SHIFT)
+#define SLICTL_3D_NUMCHIPS_LOG2_SHIFT 24
+#define SLICTL_3D_NUMCHIPS_LOG2 (0x3<<SLICTL_3D_NUMCHIPS_LOG2_SHIFT)
+#define SLICTL_3D_EN BIT(26)
+
+#define SST_POWERDOWN_DAC BIT(8)
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c
index 5a3da6743..c9c6ef3df 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c
@@ -338,7 +338,7 @@ static void mgaG200EmitPipe(drm_mga_private_t * dev_priv)
(u32) (dev_priv->WarpIndex[pipe].
phys_addr | WIA_wmode_start | WIA_wagp_agp));
- PRIMADVANCE(dev_priv);
+ PRIMADVANCE( dev_priv );
}
static void mgaEmitState(drm_mga_private_t * dev_priv)