diff options
author | Daniel Borca <[email protected]> | 2004-07-19 08:06:00 +0000 |
---|---|---|
committer | Daniel Borca <[email protected]> | 2004-07-19 08:06:00 +0000 |
commit | 1c2a498119d3b6a194033bca6bfe5d3fb4665371 (patch) | |
tree | 000c082a406933c6c56f631b008cc5bc7ef389e5 /src/mesa/drivers/dri/tdfx/tdfx_state.c | |
parent | 25f0e8227f1f8131a1add3cdcd8eb47a1e7e8f89 (diff) |
several new bugs
Diffstat (limited to 'src/mesa/drivers/dri/tdfx/tdfx_state.c')
-rw-r--r-- | src/mesa/drivers/dri/tdfx/tdfx_state.c | 207 |
1 files changed, 115 insertions, 92 deletions
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_state.c b/src/mesa/drivers/dri/tdfx/tdfx_state.c index dffcccd9a21..7f1ce3c004d 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_state.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_state.c @@ -26,6 +26,9 @@ /* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.c,v 1.7 2002/10/30 12:52:00 alanh Exp $ */ /* + * New fixes: + * Daniel Borca <[email protected]>, 19 Jul 2004 + * * Original rewrite: * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000 * @@ -68,40 +71,19 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx ) tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); GrCmpFnc_t func; GrAlphaBlendFnc_t srcRGB, dstRGB, srcA, dstA; + GrAlphaBlendOp_t eqRGB, eqA; GrAlpha_t ref = (GLint) (ctx->Color.AlphaRef * 255.0); + + GLboolean isNapalm = TDFX_IS_NAPALM(fxMesa); + GLboolean have32bpp = (ctx->Visual.greenBits == 8); + GLboolean haveAlpha = fxMesa->haveHwAlpha; if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { fprintf( stderr, "%s()\n", __FUNCTION__ ); } if ( ctx->Color.AlphaEnabled ) { - switch ( ctx->Color.AlphaFunc ) { - case GL_NEVER: - func = GR_CMP_NEVER; - break; - case GL_LESS: - func = GR_CMP_LESS; - break; - case GL_LEQUAL: - func = GR_CMP_LEQUAL; - break; - case GL_EQUAL: - func = GR_CMP_EQUAL; - break; - case GL_GEQUAL: - func = GR_CMP_GEQUAL; - break; - case GL_GREATER: - func = GR_CMP_GREATER; - break; - case GL_NOTEQUAL: - func = GR_CMP_NOTEQUAL; - break; - case GL_ALWAYS: - default: - func = GR_CMP_ALWAYS; - break; - } + func = ctx->Color.AlphaFunc - GL_NEVER + GR_CMP_NEVER; } else { func = GR_CMP_ALWAYS; } @@ -128,14 +110,24 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx ) srcRGB = GR_BLEND_ONE_MINUS_SRC_ALPHA; break; case GL_DST_ALPHA: - srcRGB = GR_BLEND_DST_ALPHA; + srcRGB = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/; break; case GL_ONE_MINUS_DST_ALPHA: - srcRGB = GR_BLEND_ONE_MINUS_DST_ALPHA; + srcRGB = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/; break; case GL_SRC_ALPHA_SATURATE: srcRGB = GR_BLEND_ALPHA_SATURATE; break; + case GL_SRC_COLOR: + if (isNapalm) { + srcRGB = GR_BLEND_SAME_COLOR_EXT; + break; + } + case GL_ONE_MINUS_SRC_COLOR: + if (isNapalm) { + srcRGB = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT; + break; + } default: srcRGB = GR_BLEND_ONE; } @@ -147,23 +139,21 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx ) case GL_ONE: srcA = GR_BLEND_ONE; break; - case GL_DST_COLOR: - srcA = GR_BLEND_DST_ALPHA; /* Napalm only */ - break; - case GL_ONE_MINUS_DST_COLOR: - srcA = GR_BLEND_ONE_MINUS_DST_ALPHA; /* Napalm only */ - break; + case GL_SRC_COLOR: case GL_SRC_ALPHA: - srcA = GR_BLEND_SRC_ALPHA; /* Napalm only */ + srcA = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ONE/*JJJ*/; break; + case GL_ONE_MINUS_SRC_COLOR: case GL_ONE_MINUS_SRC_ALPHA: - srcA = GR_BLEND_ONE_MINUS_SRC_ALPHA; /* Napalm only */ + srcA = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ONE/*JJJ*/; break; + case GL_DST_COLOR: case GL_DST_ALPHA: - srcA = GR_BLEND_DST_ALPHA; /* Napalm only */ + srcA = (have32bpp && haveAlpha) ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/; break; + case GL_ONE_MINUS_DST_COLOR: case GL_ONE_MINUS_DST_ALPHA: - srcA = GR_BLEND_ONE_MINUS_DST_ALPHA; /* Napalm only */ + srcA = (have32bpp && haveAlpha) ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/; break; case GL_SRC_ALPHA_SATURATE: srcA = GR_BLEND_ONE; @@ -192,11 +182,21 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx ) dstRGB = GR_BLEND_ONE_MINUS_SRC_ALPHA; break; case GL_DST_ALPHA: - dstRGB = GR_BLEND_DST_ALPHA; + dstRGB = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/; break; case GL_ONE_MINUS_DST_ALPHA: - dstRGB = GR_BLEND_ONE_MINUS_DST_ALPHA; + dstRGB = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/; break; + case GL_DST_COLOR: + if (isNapalm) { + srcRGB = GR_BLEND_SAME_COLOR_EXT; + break; + } + case GL_ONE_MINUS_DST_COLOR: + if (isNapalm) { + srcRGB = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT; + break; + } default: dstRGB = GR_BLEND_ZERO; } @@ -209,32 +209,58 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx ) dstA = GR_BLEND_ONE; break; case GL_SRC_COLOR: - dstA = GR_BLEND_SRC_ALPHA; /* Napalm only */ - break; - case GL_ONE_MINUS_SRC_COLOR: - dstA = GR_BLEND_ONE_MINUS_SRC_ALPHA; /* Napalm only */ - break; case GL_SRC_ALPHA: - dstA = GR_BLEND_SRC_ALPHA; /* Napalm only */ + dstA = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ZERO/*JJJ*/; break; + case GL_ONE_MINUS_SRC_COLOR: case GL_ONE_MINUS_SRC_ALPHA: - dstA = GR_BLEND_ONE_MINUS_SRC_ALPHA; /* Napalm only */ + dstA = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ZERO/*JJJ*/; break; + case GL_DST_COLOR: case GL_DST_ALPHA: - dstA = GR_BLEND_DST_ALPHA; /* Napalm only */ + dstA = have32bpp ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/; break; + case GL_ONE_MINUS_DST_COLOR: case GL_ONE_MINUS_DST_ALPHA: - dstA = GR_BLEND_ONE_MINUS_DST_ALPHA; /* Napalm only */ + dstA = have32bpp ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/; break; default: dstA = GR_BLEND_ZERO; } + + switch ( ctx->Color.BlendEquationRGB ) { + case GL_FUNC_SUBTRACT: + eqRGB = GR_BLEND_OP_SUB; + break; + case GL_FUNC_REVERSE_SUBTRACT: + eqRGB = GR_BLEND_OP_REVSUB; + break; + case GL_FUNC_ADD: + default: + eqRGB = GR_BLEND_OP_ADD; + break; + } + + switch ( ctx->Color.BlendEquationA ) { + case GL_FUNC_SUBTRACT: + eqA = GR_BLEND_OP_SUB; + break; + case GL_FUNC_REVERSE_SUBTRACT: + eqA = GR_BLEND_OP_REVSUB; + break; + case GL_FUNC_ADD: + default: + eqA = GR_BLEND_OP_ADD; + break; + } } else { /* blend disabled */ srcRGB = GR_BLEND_ONE; dstRGB = GR_BLEND_ZERO; + eqRGB = GR_BLEND_OP_ADD; srcA = GR_BLEND_ONE; dstA = GR_BLEND_ZERO; + eqA = GR_BLEND_OP_ADD; } if ( fxMesa->Color.AlphaFunc != func ) { @@ -248,13 +274,17 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx ) if ( fxMesa->Color.BlendSrcRGB != srcRGB || fxMesa->Color.BlendDstRGB != dstRGB || + fxMesa->Color.BlendEqRGB != eqRGB || fxMesa->Color.BlendSrcA != srcA || - fxMesa->Color.BlendDstA != dstA ) + fxMesa->Color.BlendDstA != dstA || + fxMesa->Color.BlendEqA != eqA ) { fxMesa->Color.BlendSrcRGB = srcRGB; fxMesa->Color.BlendDstRGB = dstRGB; + fxMesa->Color.BlendEqRGB = eqRGB; fxMesa->Color.BlendSrcA = srcA; fxMesa->Color.BlendDstA = dstA; + fxMesa->Color.BlendEqA = eqA; fxMesa->dirty |= TDFX_UPLOAD_BLEND_FUNC; } } @@ -337,40 +367,8 @@ static void tdfxUpdateZMode( GLcontext *ctx ) bias = (FxI32) (ctx->Polygon.OffsetUnits * TDFX_DEPTH_BIAS_SCALE); if ( ctx->Depth.Test ) { - switch ( ctx->Depth.Func ) { - case GL_NEVER: - func = GR_CMP_NEVER; - break; - case GL_LESS: - func = GR_CMP_LESS; - break; - case GL_LEQUAL: - func = GR_CMP_LEQUAL; - break; - case GL_EQUAL: - func = GR_CMP_EQUAL; - break; - case GL_GEQUAL: - func = GR_CMP_GEQUAL; - break; - case GL_GREATER: - func = GR_CMP_GREATER; - break; - case GL_NOTEQUAL: - func = GR_CMP_NOTEQUAL; - break; - case GL_ALWAYS: - default: - func = GR_CMP_ALWAYS; - break; - } - - if ( ctx->Depth.Mask ) { - mask = FXTRUE; - } - else { - mask = FXFALSE; - } + func = ctx->Depth.Func - GL_NEVER + GR_CMP_NEVER; + mask = ctx->Depth.Mask; } else { /* depth testing disabled */ @@ -378,8 +376,7 @@ static void tdfxUpdateZMode( GLcontext *ctx ) mask = FXFALSE; /* zbuffer is not touched */ } - fxMesa->Depth.Clear = (FxU32) (((1 << fxMesa->glCtx->Visual.depthBits) - 1) - * ctx->Depth.Clear); + fxMesa->Depth.Clear = (FxU32) (ctx->DepthMaxF * ctx->Depth.Clear); if ( fxMesa->Depth.Bias != bias ) { fxMesa->Depth.Bias = bias; @@ -464,7 +461,7 @@ static void tdfxUpdateStencil( GLcontext *ctx ) if (fxMesa->haveHwStencil) { if (ctx->Stencil.Enabled) { - fxMesa->Stencil.Function = ctx->Stencil.Function[0] - GL_NEVER; + fxMesa->Stencil.Function = ctx->Stencil.Function[0] - GL_NEVER + GR_CMP_NEVER; fxMesa->Stencil.RefValue = ctx->Stencil.Ref[0]; fxMesa->Stencil.ValueMask = ctx->Stencil.ValueMask[0]; fxMesa->Stencil.WriteMask = ctx->Stencil.WriteMask[0]; @@ -520,7 +517,11 @@ static void tdfxUpdateFogAttrib( GLcontext *ctx ) } if ( ctx->Fog.Enabled ) { - mode = GR_FOG_WITH_TABLE_ON_Q; + if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) { + mode = GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT; + } else { + mode = GR_FOG_WITH_TABLE_ON_Q; + } } else { mode = GR_FOG_DISABLE; } @@ -532,6 +533,7 @@ static void tdfxUpdateFogAttrib( GLcontext *ctx ) if ( fxMesa->Fog.Mode != mode ) { fxMesa->Fog.Mode = mode; fxMesa->dirty |= TDFX_UPLOAD_FOG_MODE; + fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT;/*JJJ*/ } if ( fxMesa->Fog.Color != color ) { fxMesa->Fog.Color = color; @@ -569,6 +571,26 @@ static void tdfxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param ) FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_FOG; + + switch (pname) { + case GL_FOG_COORDINATE_SOURCE_EXT: { + GLenum p = (GLenum)*param; + if (p == GL_FOG_COORDINATE_EXT) { + _swrast_allow_vertex_fog(ctx, GL_TRUE); + _swrast_allow_pixel_fog(ctx, GL_FALSE); + _tnl_allow_vertex_fog( ctx, GL_TRUE); + _tnl_allow_pixel_fog( ctx, GL_FALSE); + } else { + _swrast_allow_vertex_fog(ctx, GL_FALSE); + _swrast_allow_pixel_fog(ctx, GL_TRUE); + _tnl_allow_vertex_fog( ctx, GL_FALSE); + _tnl_allow_pixel_fog( ctx, GL_TRUE); + } + break; + } + default: + ; + } } @@ -912,7 +934,7 @@ static void tdfxDDEnable( GLcontext *ctx, GLenum cap, GLboolean state ) fxMesa->new_state |= TDFX_NEW_ALPHA; FALLBACK( fxMesa, TDFX_FALLBACK_LOGICOP, (ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY)); + ctx->Color.LogicOp != GL_COPY)/*JJJ - more blending*/); break; case GL_CULL_FACE: @@ -974,15 +996,16 @@ static void tdfxDDEnable( GLcontext *ctx, GLenum cap, GLboolean state ) case GL_STENCIL_TEST: FLUSH_BATCH( fxMesa ); FALLBACK( fxMesa, TDFX_FALLBACK_STENCIL, state && !fxMesa->haveHwStencil); + fxMesa->new_state |= TDFX_NEW_STENCIL; break; - case GL_TEXTURE_1D: case GL_TEXTURE_3D: FLUSH_BATCH( fxMesa ); - FALLBACK( fxMesa, TDFX_FALLBACK_TEXTURE_1D_3D, state); /* wrong */ + FALLBACK( fxMesa, TDFX_FALLBACK_TEXTURE_MAP, state); /* wrong */ fxMesa->new_state |= TDFX_NEW_TEXTURE; break; + case GL_TEXTURE_1D: case GL_TEXTURE_2D: FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_TEXTURE; |