} while (0)
-static void viaBlit(viaContextPtr vmesa, GLuint bpp,GLuint srcBase,
- GLuint srcPitch,GLuint dstBase,GLuint dstPitch,
- GLuint w,GLuint h,int xdir,int ydir, GLuint blitMode,
+static void viaBlit(viaContextPtr vmesa, GLuint bpp,
+ GLuint srcBase, GLuint srcPitch,
+ GLuint dstBase, GLuint dstPitch,
+ GLuint w, GLuint h,
+ GLuint blitMode,
GLuint color, GLuint nMask )
{
- GLuint dwGEMode = 0, srcY=0, srcX, dstY=0, dstX;
- GLuint cmd;
+ GLuint dwGEMode, srcX, dstX, cmd;
RING_VARS;
if (VIA_DEBUG)
- fprintf(stderr, "%s bpp %d src %x/%x dst %x/%x w %d h %d dir %d,%d mode: %x color: 0x%08x mask 0x%08x\n",
- __FUNCTION__, bpp, srcBase, srcPitch, dstBase, dstPitch, w,h, xdir, ydir, blitMode, color, nMask);
+ fprintf(stderr, "%s bpp %d src %x/%x dst %x/%x w %d h %d mode: %x color: 0x%08x mask 0x%08x\n",
+ __FUNCTION__, bpp, srcBase, srcPitch, dstBase, dstPitch, w,h, blitMode, color, nMask);
if (!w || !h)
return;
- srcX = srcBase & 31;
- dstX = dstBase & 31;
switch (bpp) {
case 16:
- dwGEMode |= VIA_GEM_16bpp;
- srcX >>= 1;
- dstX >>= 1;
+ dwGEMode = VIA_GEM_16bpp;
+ srcX = (srcBase & 0x1f) >> 1;
+ dstX = (dstBase & 0x1f) >> 1;
break;
case 32:
- dwGEMode |= VIA_GEM_32bpp;
- srcX >>= 2;
- dstX >>= 2;
+ dwGEMode = VIA_GEM_32bpp;
+ srcX = (srcBase & 0x1f) >> 2;
+ dstX = (dstBase & 0x1f) >> 2;
break;
default:
- dwGEMode |= VIA_GEM_8bpp;
- break;
- }
-
-
- cmd = 0;
-
- if (xdir < 0) {
- cmd |= VIA_GEC_DECX;
- srcX += (w - 1);
- dstX += (w - 1);
- }
- if (ydir < 0) {
- cmd |= VIA_GEC_DECY;
- srcY += (h - 1);
- dstY += (h - 1);
+ return;
}
switch(blitMode) {
case VIA_BLIT_FILL:
- BEGIN_RING((2 + 9) * 2);
- SetReg2DAGP(VIA_REG_GEMODE, dwGEMode);
- SetReg2DAGP( VIA_REG_FGCOLOR, color);
- cmd |= VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | (VIA_BLIT_FILL << 24);
+ cmd = VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | (VIA_BLIT_FILL << 24);
break;
case VIA_BLIT_COPY:
- BEGIN_RING((2 + 9) * 2);
- SetReg2DAGP(VIA_REG_GEMODE, dwGEMode);
- SetReg2DAGP( VIA_REG_KEYCONTROL, 0x0);
- cmd |= VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
+ cmd = VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
+ break;
+ default:
+ return;
}
+ BEGIN_RING(22);
+ SetReg2DAGP( VIA_REG_GEMODE, dwGEMode);
+ SetReg2DAGP( VIA_REG_FGCOLOR, color);
SetReg2DAGP( 0x2C, nMask);
- SetReg2DAGP( VIA_REG_SRCBASE, (srcBase & ~31) >> 3);
- SetReg2DAGP( VIA_REG_DSTBASE, (dstBase & ~31) >> 3);
+ SetReg2DAGP( VIA_REG_SRCBASE, (srcBase & ~0x1f) >> 3);
+ SetReg2DAGP( VIA_REG_DSTBASE, (dstBase & ~0x1f) >> 3);
SetReg2DAGP( VIA_REG_PITCH, VIA_PITCH_ENABLE |
- (srcPitch >> 3) | (((dstPitch) >> 3) << 16));
- SetReg2DAGP( VIA_REG_SRCPOS, ((srcY << 16) | srcX));
- SetReg2DAGP( VIA_REG_DSTPOS, ((dstY << 16) | dstX));
+ (srcPitch >> 3) | ((dstPitch >> 3) << 16));
+ SetReg2DAGP( VIA_REG_SRCPOS, srcX);
+ SetReg2DAGP( VIA_REG_DSTPOS, dstX);
SetReg2DAGP( VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
SetReg2DAGP( VIA_REG_GECMD, cmd);
SetReg2DAGP( 0x2C, 0x00000000);
offset, buffer->pitch,
offset, buffer->pitch,
w, h,
- 0, 0,
VIA_BLIT_FILL, pixel, mask);
}
}
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
- const GLuint colorMask = *((GLuint *)&ctx->Color.ColorMask);
int flag = 0;
GLuint i = 0;
GLuint clear_depth_mask = 0xf << 28;
VIA_FLUSH_DMA(vmesa);
- if ((mask & DD_FRONT_LEFT_BIT) && colorMask == ~0) {
+ if (mask & DD_FRONT_LEFT_BIT) {
flag |= VIA_FRONT;
mask &= ~DD_FRONT_LEFT_BIT;
}
- if ((mask & DD_BACK_LEFT_BIT) && colorMask == ~0) {
+ if (mask & DD_BACK_LEFT_BIT) {
flag |= VIA_BACK;
mask &= ~DD_BACK_LEFT_BIT;
}
mask &= ~DD_STENCIL_BIT;
}
else {
- fprintf(stderr, "XXX: Clear stencil writemask %x -- need triangles (or a ROP?)\n",
- ctx->Stencil.WriteMask[0]);
- /* Fixme - clear with triangles */
+ if (VIA_DEBUG)
+ fprintf(stderr, "XXX: Clear stencil writemask %x -- need triangles (or a ROP?)\n",
+ ctx->Stencil.WriteMask[0]);
}
}
}
}
if (flag & VIA_FRONT) {
- viaFillBuffer(vmesa, &vmesa->front, boxes, nr, vmesa->ClearColor, 0);
+ viaFillBuffer(vmesa, &vmesa->front, boxes, nr, vmesa->ClearColor, vmesa->ClearMask);
}
if (flag & VIA_BACK) {
- viaFillBuffer(vmesa, &vmesa->back, boxes, nr, vmesa->ClearColor, 0); /* FIXME: masks */
+ viaFillBuffer(vmesa, &vmesa->back, boxes, nr, vmesa->ClearColor, vmesa->ClearMask);
}
if (flag & VIA_DEPTH) {
src, back->pitch,
dest, front->pitch,
w, h,
- 0,0,VIA_BLIT_COPY, 0, 0);
+ VIA_BLIT_COPY, 0, 0);
}
}
}
+#define WRITEMASK_ALPHA_SHIFT 31
+#define WRITEMASK_RED_SHIFT 30
+#define WRITEMASK_GREEN_SHIFT 29
+#define WRITEMASK_BLUE_SHIFT 28
+
+static void viaColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
+{
+ viaContextPtr vmesa = VIA_CONTEXT( ctx );
+
+ if (VIA_DEBUG)
+ fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a);
+
+ vmesa->ClearMask = (((!r) << WRITEMASK_RED_SHIFT) |
+ ((!g) << WRITEMASK_GREEN_SHIFT) |
+ ((!b) << WRITEMASK_BLUE_SHIFT) |
+ ((!a) << WRITEMASK_ALPHA_SHIFT));
+}
+
/* =============================================================
*/
vmesa->regHROP = HC_HROP_P;
vmesa->regHFBBMSKL = (*(GLuint *)&ctx->Color.ColorMask[0]) & 0xFFFFFF;
- vmesa->regHROP |= ((*(GLuint *)&ctx->Color.ColorMask[0]) >> 24) & 0xFF;
+ vmesa->regHROP |= ctx->Color.ColorMask[3];
- if ((GLuint)((GLuint *)&ctx->Color.ColorMask[0]) & 0xFF000000)
+ if (ctx->Color.ColorMask[3])
vmesa->regEnable |= HC_HenAW_MASK;
else
- vmesa->regEnable &= (~HC_HenAW_MASK);
+ vmesa->regEnable &= ~HC_HenAW_MASK;
+
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
ctx->Driver.BlendEquationSeparate = viaBlendEquationSeparate;
ctx->Driver.BlendFuncSeparate = viaBlendFuncSeparate;
ctx->Driver.ClearColor = viaClearColor;
+ ctx->Driver.ColorMask = viaColorMask;
ctx->Driver.DrawBuffer = viaDrawBuffer;
ctx->Driver.RenderMode = viaRenderMode;
ctx->Driver.Scissor = viaScissor;