From d294f79190a5b25ef0fbbbf3ac94b15c9402d009 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 3 Nov 2004 17:29:39 +0000 Subject: enable GL_EXT_fog_coord. Calculate fog factors and submit them instead of fog coords (it seems the chip cannot do fog factor computation when not using fragment depth as fog coord source). vtxfmt uses fallback for now (most code present but some magic would be needed if replaying vertices is necessary later on). --- src/mesa/drivers/dri/r200/r200_state.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src/mesa/drivers/dri/r200/r200_state.c') diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index 825c036e27..7701256edf 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -468,10 +468,37 @@ static void r200Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *param ) rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~R200_FOG_COLOR_MASK; rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= i; break; - case GL_FOG_COORDINATE_SOURCE_EXT: - /* What to do? - */ + case GL_FOG_COORD_SRC: { + GLuint fmt_0 = rmesa->hw.vtx.cmd[VTX_VTXFMT_0]; + GLuint out_0 = rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0]; + GLuint fog = rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR]; + + fog &= ~R200_FOG_USE_MASK; + if ( ctx->Fog.FogCoordinateSource == GL_FOG_COORD ) { + fog |= R200_FOG_USE_VTX_FOG; + fmt_0 |= R200_VTX_DISCRETE_FOG; + out_0 |= R200_VTX_DISCRETE_FOG; + } + else { + fog |= R200_FOG_USE_SPEC_ALPHA; + fmt_0 &= ~R200_VTX_DISCRETE_FOG; + out_0 &= ~R200_VTX_DISCRETE_FOG; + } + + if ( fog != rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] ) { + R200_STATECHANGE( rmesa, ctx ); + rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] = fog; + } + + if ( (fmt_0 != rmesa->hw.vtx.cmd[VTX_VTXFMT_0]) + || (out_0 != rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0])) { + R200_STATECHANGE( rmesa, vtx ); + rmesa->hw.vtx.cmd[VTX_VTXFMT_0] = fmt_0; + rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] = out_0; + } + break; + } default: return; } -- cgit v1.2.3