diff options
author | Keith Whitwell <[email protected]> | 2004-12-29 12:39:50 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2004-12-29 12:39:50 +0000 |
commit | 13ae06cf36f9d04c0a04cdc19196f400d7a8c642 (patch) | |
tree | ccd2bc240d06f74bd4d9776eb51ed72a1e5bca82 /src/mesa/drivers/dri/unichrome/via_state.c | |
parent | 7b05b70c2af9f76222a40941b393b5f04ce83048 (diff) |
Large update
- Remove via duplicates of shared template files
- Update driver to work with current versions of the above
- Rework dma accounting
- Rework emitting to dma to use a consistent set of macros
The handling of cliprects in the driver is still pretty questionable.
Diffstat (limited to 'src/mesa/drivers/dri/unichrome/via_state.c')
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_state.c | 518 |
1 files changed, 491 insertions, 27 deletions
diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c index aef23ff6911..92d76dd9b44 100644 --- a/src/mesa/drivers/dri/unichrome/via_state.c +++ b/src/mesa/drivers/dri/unichrome/via_state.c @@ -67,6 +67,458 @@ static GLuint ROP[16] = { HC_HROP_WHITE /* GL_SET 1 */ }; + + +static void via_emit_state(viaContextPtr vmesa) +{ + GLcontext *ctx = vmesa->glCtx; + GLuint i = 0; + GLuint j = 0; + RING_VARS; + + if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); + + viaCheckDma(vmesa, 0x110); + + BEGIN_RING(5); + OUT_RING( HC_HEADER2 ); + OUT_RING( (HC_ParaType_NotTex << 16) ); + OUT_RING( ((HC_SubA_HEnable << 24) | vmesa->regEnable) ); + OUT_RING( ((HC_SubA_HFBBMSKL << 24) | vmesa->regHFBBMSKL) ); + OUT_RING( ((HC_SubA_HROP << 24) | vmesa->regHROP) ); + ADVANCE_RING(); + + if (vmesa->have_hw_stencil) { + GLuint pitch, format, offset; + + format = HC_HZWBFM_24; + offset = vmesa->depth.offset; + pitch = vmesa->depth.pitch; + + BEGIN_RING(6); + OUT_RING( ((HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF)) ); + OUT_RING( ((HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24)) ); + OUT_RING( ((HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK | + format | pitch) ); + OUT_RING( ((HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD) ); + OUT_RING( ((HC_SubA_HSTREF << 24) | vmesa->regHSTREF) ); + OUT_RING( ((HC_SubA_HSTMD << 24) | vmesa->regHSTMD) ); + ADVANCE_RING(); + } + else if (vmesa->hasDepth) { + GLuint pitch, format, offset; + + if (vmesa->depthBits == 16) { + /* We haven't support 16bit depth yet */ + format = HC_HZWBFM_16; + /*format = HC_HZWBFM_32;*/ + if (VIA_DEBUG) fprintf(stderr, "z format = 16\n"); + } + else { + format = HC_HZWBFM_32; + if (VIA_DEBUG) fprintf(stderr, "z format = 32\n"); + } + + + offset = vmesa->depth.offset; + pitch = vmesa->depth.pitch; + + BEGIN_RING(4); + OUT_RING( ((HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF)) ); + OUT_RING( ((HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24)) ); + OUT_RING( ((HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK | + format | pitch) ); + OUT_RING( ((HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD) ); + ADVANCE_RING(); + } + + if (ctx->Color.AlphaEnabled) { + BEGIN_RING(1); + OUT_RING( ((HC_SubA_HATMD << 24) | vmesa->regHATMD) ); + ADVANCE_RING(); + i++; + } + + if (ctx->Color.BlendEnabled) { + BEGIN_RING(11); + OUT_RING( ((HC_SubA_HABLCsat << 24) | vmesa->regHABLCsat) ); + OUT_RING( ((HC_SubA_HABLCop << 24) | vmesa->regHABLCop) ); + OUT_RING( ((HC_SubA_HABLAsat << 24) | vmesa->regHABLAsat) ); + OUT_RING( ((HC_SubA_HABLAop << 24) | vmesa->regHABLAop) ); + OUT_RING( ((HC_SubA_HABLRCa << 24) | vmesa->regHABLRCa) ); + OUT_RING( ((HC_SubA_HABLRFCa << 24) | vmesa->regHABLRFCa) ); + OUT_RING( ((HC_SubA_HABLRCbias << 24) | vmesa->regHABLRCbias) ); + OUT_RING( ((HC_SubA_HABLRCb << 24) | vmesa->regHABLRCb) ); + OUT_RING( ((HC_SubA_HABLRFCb << 24) | vmesa->regHABLRFCb) ); + OUT_RING( ((HC_SubA_HABLRAa << 24) | vmesa->regHABLRAa) ); + OUT_RING( ((HC_SubA_HABLRAb << 24) | vmesa->regHABLRAb) ); + ADVANCE_RING(); + } + + if (ctx->Fog.Enabled) { + BEGIN_RING(3); + OUT_RING( ((HC_SubA_HFogLF << 24) | vmesa->regHFogLF) ); + OUT_RING( ((HC_SubA_HFogCL << 24) | vmesa->regHFogCL) ); + OUT_RING( ((HC_SubA_HFogCH << 24) | vmesa->regHFogCH) ); + ADVANCE_RING(); + } + + if (ctx->Line.StippleFlag) { + BEGIN_RING(2); + OUT_RING( ((HC_SubA_HLP << 24) | ctx->Line.StipplePattern) ); + OUT_RING( ((HC_SubA_HLPRF << 24) | ctx->Line.StippleFactor) ); + ADVANCE_RING(); + } + else { + BEGIN_RING(2); + OUT_RING( ((HC_SubA_HLP << 24) | 0xFFFF) ); + OUT_RING( ((HC_SubA_HLPRF << 24) | 0x1) ); + ADVANCE_RING(); + } + + BEGIN_RING(1); + OUT_RING( ((HC_SubA_HPixGC << 24) | 0x0) ); + ADVANCE_RING(); + + QWORD_PAD_RING(); + + + if (ctx->Texture._EnabledUnits) { + + struct gl_texture_unit *texUnit0 = &ctx->Texture.Unit[0]; + struct gl_texture_unit *texUnit1 = &ctx->Texture.Unit[1]; + + { + viaTextureObjectPtr t = (viaTextureObjectPtr)texUnit0->_Current->DriverData; + GLuint nDummyValue = 0; + + BEGIN_RING( 8 ); + OUT_RING( HC_HEADER2 ); + OUT_RING( (HC_ParaType_Tex << 16) | (HC_SubType_TexGeneral << 24) ); + + if (ctx->Texture._EnabledUnits > 1) { + if (VIA_DEBUG) fprintf(stderr, "multi texture\n"); + nDummyValue = (HC_SubA_HTXSMD << 24) | (1 << 3); + + if (t && t->needClearCache) { + OUT_RING( nDummyValue | HC_HTXCHCLR_MASK ); + OUT_RING( nDummyValue ); + } + else { + OUT_RING( nDummyValue ); + OUT_RING( nDummyValue ); + } + } + else { + if (VIA_DEBUG) fprintf(stderr, "single texture\n"); + nDummyValue = (HC_SubA_HTXSMD << 24) | 0; + + if (t && t->needClearCache) { + OUT_RING( nDummyValue | HC_HTXCHCLR_MASK ); + OUT_RING( nDummyValue ); + } + else { + OUT_RING( nDummyValue ); + OUT_RING( nDummyValue ); + } + } + OUT_RING( HC_HEADER2 ); + OUT_RING( HC_ParaType_NotTex << 16 ); + OUT_RING( (HC_SubA_HEnable << 24) | vmesa->regEnable ); + OUT_RING( (HC_SubA_HEnable << 24) | vmesa->regEnable ); + ADVANCE_RING(); + } + + if (texUnit0->Enabled) { + struct gl_texture_object *texObj = texUnit0->_Current; + viaTextureObjectPtr t = (viaTextureObjectPtr)texObj->DriverData; + GLuint numLevels = t->lastLevel - t->firstLevel + 1; + if (VIA_DEBUG) { + fprintf(stderr, "texture0 enabled\n"); + fprintf(stderr, "texture level %d\n", t->actualLevel); + } + if (numLevels == 8) { + BEGIN_RING(27); + OUT_RING( HC_HEADER2 ); + OUT_RING( (HC_ParaType_Tex << 16) | (0 << 24) ); + OUT_RING( t->regTexFM ); + OUT_RING( (HC_SubA_HTXnL0OS << 24) | + ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel ); + OUT_RING( t->regTexWidthLog2[0] ); + OUT_RING( t->regTexWidthLog2[1] ); + OUT_RING( t->regTexHeightLog2[0] ); + OUT_RING( t->regTexHeightLog2[1] ); + OUT_RING( t->regTexBaseH[0] ); + OUT_RING( t->regTexBaseH[1] ); + OUT_RING( t->regTexBaseH[2] ); + OUT_RING( t->regTexBaseAndPitch[0].baseL ); + OUT_RING( t->regTexBaseAndPitch[0].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[1].baseL ); + OUT_RING( t->regTexBaseAndPitch[1].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[2].baseL ); + OUT_RING( t->regTexBaseAndPitch[2].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[3].baseL ); + OUT_RING( t->regTexBaseAndPitch[3].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[4].baseL ); + OUT_RING( t->regTexBaseAndPitch[4].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[5].baseL ); + OUT_RING( t->regTexBaseAndPitch[5].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[6].baseL ); + OUT_RING( t->regTexBaseAndPitch[6].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[7].baseL ); + OUT_RING( t->regTexBaseAndPitch[7].pitchLog2 ); + ADVANCE_RING(); + } + else if (numLevels > 1) { + + BEGIN_RING(12 + numLevels * 2); + OUT_RING( HC_HEADER2 ); + OUT_RING( (HC_ParaType_Tex << 16) | (0 << 24) ); + OUT_RING( t->regTexFM ); + OUT_RING( (HC_SubA_HTXnL0OS << 24) | + ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel ); + OUT_RING( t->regTexWidthLog2[0] ); + OUT_RING( t->regTexHeightLog2[0] ); + + if (numLevels > 6) { + OUT_RING( t->regTexWidthLog2[1] ); + OUT_RING( t->regTexHeightLog2[1] ); + } + + OUT_RING( t->regTexBaseH[0] ); + + if (numLevels > 3) { + OUT_RING( t->regTexBaseH[1] ); + } + if (numLevels > 6) { + OUT_RING( t->regTexBaseH[2] ); + } + if (numLevels > 9) { + OUT_RING( t->regTexBaseH[3] ); + } + + for (j = 0; j < numLevels; j++) { + OUT_RING( t->regTexBaseAndPitch[j].baseL ); + OUT_RING( t->regTexBaseAndPitch[j].pitchLog2 ); + } + + ADVANCE_RING_VARIABLE(); + } + else { + + BEGIN_RING(9); + OUT_RING( HC_HEADER2 ); + OUT_RING( (HC_ParaType_Tex << 16) | (0 << 24) ); + OUT_RING( t->regTexFM ); + OUT_RING( (HC_SubA_HTXnL0OS << 24) | + ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel ); + OUT_RING( t->regTexWidthLog2[0] ); + OUT_RING( t->regTexHeightLog2[0] ); + OUT_RING( t->regTexBaseH[0] ); + OUT_RING( t->regTexBaseAndPitch[0].baseL ); + OUT_RING( t->regTexBaseAndPitch[0].pitchLog2 ); + ADVANCE_RING(); + } + + BEGIN_RING(12); + OUT_RING( (HC_SubA_HTXnTB << 24) | vmesa->regHTXnTB_0 ); + OUT_RING( (HC_SubA_HTXnMPMD << 24) | vmesa->regHTXnMPMD_0 ); + OUT_RING( (HC_SubA_HTXnTBLCsat << 24) | vmesa->regHTXnTBLCsat_0 ); + OUT_RING( (HC_SubA_HTXnTBLCop << 24) | vmesa->regHTXnTBLCop_0 ); + OUT_RING( (HC_SubA_HTXnTBLMPfog << 24) | vmesa->regHTXnTBLMPfog_0 ); + OUT_RING( (HC_SubA_HTXnTBLAsat << 24) | vmesa->regHTXnTBLAsat_0 ); + OUT_RING( (HC_SubA_HTXnTBLRCb << 24) | vmesa->regHTXnTBLRCb_0 ); + OUT_RING( (HC_SubA_HTXnTBLRAa << 24) | vmesa->regHTXnTBLRAa_0 ); + OUT_RING( (HC_SubA_HTXnTBLRFog << 24) | vmesa->regHTXnTBLRFog_0 ); + OUT_RING( (HC_SubA_HTXnTBLRCa << 24) | vmesa->regHTXnTBLRCa_0 ); + OUT_RING( (HC_SubA_HTXnTBLRCc << 24) | vmesa->regHTXnTBLRCc_0 ); + OUT_RING( (HC_SubA_HTXnTBLRCbias << 24) | vmesa->regHTXnTBLRCbias_0 ); + ADVANCE_RING(); + + if (t->regTexFM == HC_HTXnFM_Index8) { + struct gl_color_table *table = &texObj->Palette; + GLfloat *tableF = (GLfloat *)table->Table; + + BEGIN_RING(2 + table->Size); + OUT_RING( HC_HEADER2 ); + OUT_RING( (HC_ParaType_Palette << 16) | (0 << 24) ); + for (j = 0; j < table->Size; j++) + OUT_RING( tableF[j] ); + ADVANCE_RING(); + + } + + QWORD_PAD_RING(); + } + + if (texUnit1->Enabled) { + struct gl_texture_object *texObj = texUnit1->_Current; + viaTextureObjectPtr t = (viaTextureObjectPtr)texObj->DriverData; + GLuint numLevels = t->lastLevel - t->firstLevel + 1; + if (VIA_DEBUG) { + fprintf(stderr, "texture1 enabled\n"); + fprintf(stderr, "texture level %d\n", t->actualLevel); + } + if (numLevels == 8) { + BEGIN_RING(27); + OUT_RING( HC_HEADER2 ); + OUT_RING( (HC_ParaType_Tex << 16) | (1 << 24) ); + OUT_RING( t->regTexFM ); + OUT_RING( (HC_SubA_HTXnL0OS << 24) | + ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel ); + OUT_RING( t->regTexWidthLog2[0] ); + OUT_RING( t->regTexWidthLog2[1] ); + OUT_RING( t->regTexHeightLog2[0] ); + OUT_RING( t->regTexHeightLog2[1] ); + OUT_RING( t->regTexBaseH[0] ); + OUT_RING( t->regTexBaseH[1] ); + OUT_RING( t->regTexBaseH[2] ); + OUT_RING( t->regTexBaseAndPitch[0].baseL ); + OUT_RING( t->regTexBaseAndPitch[0].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[1].baseL ); + OUT_RING( t->regTexBaseAndPitch[1].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[2].baseL ); + OUT_RING( t->regTexBaseAndPitch[2].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[3].baseL ); + OUT_RING( t->regTexBaseAndPitch[3].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[4].baseL ); + OUT_RING( t->regTexBaseAndPitch[4].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[5].baseL ); + OUT_RING( t->regTexBaseAndPitch[5].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[6].baseL ); + OUT_RING( t->regTexBaseAndPitch[6].pitchLog2 ); + OUT_RING( t->regTexBaseAndPitch[7].baseL ); + OUT_RING( t->regTexBaseAndPitch[7].pitchLog2 ); + ADVANCE_RING(); + } + else if (numLevels > 1) { + BEGIN_RING(12 + numLevels * 2); + OUT_RING( HC_HEADER2 ); + OUT_RING( (HC_ParaType_Tex << 16) | (1 << 24) ); + OUT_RING( t->regTexFM ); + OUT_RING( (HC_SubA_HTXnL0OS << 24) | + ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel ); + OUT_RING( t->regTexWidthLog2[0] ); + OUT_RING( t->regTexHeightLog2[0] ); + + if (numLevels > 6) { + OUT_RING( t->regTexWidthLog2[1] ); + OUT_RING( t->regTexHeightLog2[1] ); + i += 2; + } + + OUT_RING( t->regTexBaseH[0] ); + + if (numLevels > 3) { + OUT_RING( t->regTexBaseH[1] ); + } + if (numLevels > 6) { + OUT_RING( t->regTexBaseH[2] ); + } + if (numLevels > 9) { + OUT_RING( t->regTexBaseH[3] ); + } + + for (j = 0; j < numLevels; j++) { + OUT_RING( t->regTexBaseAndPitch[j].baseL ); + OUT_RING( t->regTexBaseAndPitch[j].pitchLog2 ); + } + ADVANCE_RING_VARIABLE(); + } + else { + BEGIN_RING(9); + OUT_RING( HC_HEADER2 ); + OUT_RING( (HC_ParaType_Tex << 16) | (1 << 24) ); + OUT_RING( t->regTexFM ); + OUT_RING( (HC_SubA_HTXnL0OS << 24) | + ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel ); + OUT_RING( t->regTexWidthLog2[0] ); + OUT_RING( t->regTexHeightLog2[0] ); + OUT_RING( t->regTexBaseH[0] ); + OUT_RING( t->regTexBaseAndPitch[0].baseL ); + OUT_RING( t->regTexBaseAndPitch[0].pitchLog2 ); + ADVANCE_RING(); + } + + BEGIN_RING(9); + OUT_RING( (HC_SubA_HTXnTB << 24) | vmesa->regHTXnTB_1 ); + OUT_RING( (HC_SubA_HTXnMPMD << 24) | vmesa->regHTXnMPMD_1 ); + OUT_RING( (HC_SubA_HTXnTBLCsat << 24) | vmesa->regHTXnTBLCsat_1 ); + OUT_RING( (HC_SubA_HTXnTBLCop << 24) | vmesa->regHTXnTBLCop_1 ); + OUT_RING( (HC_SubA_HTXnTBLMPfog << 24) | vmesa->regHTXnTBLMPfog_1 ); + OUT_RING( (HC_SubA_HTXnTBLAsat << 24) | vmesa->regHTXnTBLAsat_1 ); + OUT_RING( (HC_SubA_HTXnTBLRCb << 24) | vmesa->regHTXnTBLRCb_1 ); + OUT_RING( (HC_SubA_HTXnTBLRAa << 24) | vmesa->regHTXnTBLRAa_1 ); + OUT_RING( (HC_SubA_HTXnTBLRFog << 24) | vmesa->regHTXnTBLRFog_1 ); + ADVANCE_RING(); + + if (t->regTexFM == HC_HTXnFM_Index8) { + struct gl_color_table *table = &texObj->Palette; + GLfloat *tableF = (GLfloat *)table->Table; + + BEGIN_RING(2 + table->Size); + OUT_RING( HC_HEADER2 ); + OUT_RING( (HC_ParaType_Palette << 16) | (1 << 24) ); + for (j = 0; j < table->Size; j++) { + OUT_RING( tableF[j] ); + } + ADVANCE_RING(); + } + + QWORD_PAD_RING(); + } + } + + + if (ctx->Polygon.StippleFlag) { + GLuint *stipple = &ctx->PolygonStipple[0]; + + BEGIN_RING(38); + OUT_RING( HC_HEADER2 ); + OUT_RING( ((HC_ParaType_Palette << 16) | (HC_SubType_Stipple << 24)) ); + OUT_RING( stipple[31] ); + OUT_RING( stipple[30] ); + OUT_RING( stipple[29] ); + OUT_RING( stipple[28] ); + OUT_RING( stipple[27] ); + OUT_RING( stipple[26] ); + OUT_RING( stipple[25] ); + OUT_RING( stipple[24] ); + OUT_RING( stipple[23] ); + OUT_RING( stipple[22] ); + OUT_RING( stipple[21] ); + OUT_RING( stipple[20] ); + OUT_RING( stipple[19] ); + OUT_RING( stipple[18] ); + OUT_RING( stipple[17] ); + OUT_RING( stipple[16] ); + OUT_RING( stipple[15] ); + OUT_RING( stipple[14] ); + OUT_RING( stipple[13] ); + OUT_RING( stipple[12] ); + OUT_RING( stipple[11] ); + OUT_RING( stipple[10] ); + OUT_RING( stipple[9] ); + OUT_RING( stipple[8] ); + OUT_RING( stipple[7] ); + OUT_RING( stipple[6] ); + OUT_RING( stipple[5] ); + OUT_RING( stipple[4] ); + OUT_RING( stipple[3] ); + OUT_RING( stipple[2] ); + OUT_RING( stipple[1] ); + OUT_RING( stipple[0] ); + OUT_RING( HC_HEADER2 ); + OUT_RING( (HC_ParaType_NotTex << 16) ); + OUT_RING( ((HC_SubA_HSPXYOS << 24) | (0x20 - (vmesa->driDrawable->h & 0x1F))) ); + OUT_RING( ((HC_SubA_HSPXYOS << 24) | (0x20 - (vmesa->driDrawable->h & 0x1F))) ); + ADVANCE_RING(); + } + + if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); +} + + static __inline__ GLuint viaPackColor(GLuint format, GLubyte r, GLubyte g, GLubyte b, GLubyte a) @@ -164,7 +616,7 @@ static void viaScissor(GLcontext *ctx, GLint x, GLint y, if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); if (ctx->Scissor.Enabled) { - VIA_FIREVERTICES(vmesa); /* don't pipeline cliprect changes */ + VIA_FLUSH_DMA(vmesa); /* don't pipeline cliprect changes */ } vmesa->scissorRect.x1 = x; @@ -189,7 +641,7 @@ static void viaDrawBuffer(GLcontext *ctx, GLenum mode) viaContextPtr vmesa = VIA_CONTEXT(ctx); if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); if (mode == GL_FRONT) { - VIA_FIREVERTICES(vmesa); + VIA_FLUSH_DMA(vmesa); vmesa->drawMap = (char *)vmesa->driScreen->pFB; vmesa->readMap = (char *)vmesa->driScreen->pFB; vmesa->drawPitch = vmesa->front.pitch; @@ -199,7 +651,7 @@ static void viaDrawBuffer(GLcontext *ctx, GLenum mode) return; } else if (mode == GL_BACK) { - VIA_FIREVERTICES(vmesa); + VIA_FLUSH_DMA(vmesa); vmesa->drawMap = vmesa->back.map; vmesa->readMap = vmesa->back.map; vmesa->drawPitch = vmesa->back.pitch; @@ -907,6 +1359,8 @@ static void viaChoosePolygonState(GLcontext *ctx) { viaContextPtr vmesa = VIA_CONTEXT(ctx); + /* KW: FIXME: this should be in viaRasterPrimitive (somehow) + */ if (ctx->Polygon.SmoothFlag) { vmesa->regEnable |= HC_HenAA_MASK; } @@ -1052,26 +1506,25 @@ static void viaChooseTriangle(GLcontext *ctx) if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); } -static void viaChooseState(GLcontext *ctx, GLuint newState) +void viaValidateState( GLcontext *ctx ) { viaContextPtr vmesa = VIA_CONTEXT(ctx); struct gl_texture_unit *texUnit0 = &ctx->Texture.Unit[0]; struct gl_texture_unit *texUnit1 = &ctx->Texture.Unit[1]; if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); - if (VIA_DEBUG) fprintf(stderr, "newState = %x\n", newState); - - if (!(newState & (_NEW_COLOR | - _NEW_TEXTURE | - _NEW_DEPTH | - _NEW_FOG | - _NEW_LIGHT | - _NEW_LINE | - _NEW_POLYGON | - _NEW_POLYGONSTIPPLE | - _NEW_STENCIL))) - return; - vmesa->newState |= newState; +#if 0 + if (!(vmesa->newState & (_NEW_COLOR | + _NEW_TEXTURE | + _NEW_DEPTH | + _NEW_FOG | + _NEW_LIGHT | + _NEW_LINE | + _NEW_POLYGON | + _NEW_POLYGONSTIPPLE | + _NEW_STENCIL))) + return; +#endif if (texUnit0->_ReallyEnabled || texUnit1->_ReallyEnabled || ctx->Fog.Enabled) { vmesa->regCmdB |= HC_HVPMSK_Cs; @@ -1080,42 +1533,53 @@ static void viaChooseState(GLcontext *ctx, GLuint newState) vmesa->regCmdB &= ~ HC_HVPMSK_Cs; } - if (newState & _NEW_TEXTURE) + if (vmesa->newState & _NEW_TEXTURE) { viaChooseTextureState(ctx); + viaUpdateTextureState(ctx); /* May modify vmesa->Fallback */ + } - if (newState & _NEW_COLOR) + if (vmesa->newState & _NEW_COLOR) viaChooseColorState(ctx); - if (newState & _NEW_DEPTH) + if (vmesa->newState & _NEW_DEPTH) viaChooseDepthState(ctx); - if (newState & _NEW_FOG) + if (vmesa->newState & _NEW_FOG) viaChooseFogState(ctx); - if (newState & _NEW_LIGHT) + if (vmesa->newState & _NEW_LIGHT) viaChooseLightState(ctx); - if (newState & _NEW_LINE) + if (vmesa->newState & _NEW_LINE) viaChooseLineState(ctx); - if (newState & (_NEW_POLYGON | _NEW_POLYGONSTIPPLE)) + if (vmesa->newState & (_NEW_POLYGON | _NEW_POLYGONSTIPPLE)) { viaChoosePolygonState(ctx); + viaChooseTriangle(ctx); + } - if (newState & _NEW_STENCIL) + if (vmesa->newState & _NEW_STENCIL) viaChooseStencilState(ctx); - viaChooseTriangle(ctx); + if (!vmesa->Fallback) { + via_emit_state(vmesa); + vmesa->newState = 0; + } if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); } static void viaInvalidateState(GLcontext *ctx, GLuint newState) { + viaContextPtr vmesa = VIA_CONTEXT(ctx); + + VIA_FINISH_PRIM( vmesa ); + vmesa->newState |= newState; + _swrast_InvalidateState(ctx, newState); _swsetup_InvalidateState(ctx, newState); _ac_InvalidateState(ctx, newState); _tnl_InvalidateState(ctx, newState); - viaChooseState(ctx, newState); } void viaInitStateFuncs(GLcontext *ctx) |