diff options
Diffstat (limited to 'xc/lib/GL/mesa/src/drv/r200/r200_state.c')
-rw-r--r-- | xc/lib/GL/mesa/src/drv/r200/r200_state.c | 111 |
1 files changed, 61 insertions, 50 deletions
diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_state.c b/xc/lib/GL/mesa/src/drv/r200/r200_state.c index 6efa0f6da..3ad2d2f13 100644 --- a/xc/lib/GL/mesa/src/drv/r200/r200_state.c +++ b/xc/lib/GL/mesa/src/drv/r200/r200_state.c @@ -32,20 +32,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * Keith Whitwell <keith@tungstengraphics.com> */ -#include "r200_context.h" -#include "r200_ioctl.h" -#include "r200_state.h" -#include "r200_tcl.h" -#include "r200_tex.h" -#include "r200_swtcl.h" -#include "r200_vtxfmt.h" - -#include "mem.h" +#include "glheader.h" +#include "imports.h" +#include "api_arrayelt.h" #include "mmath.h" #include "enums.h" #include "colormac.h" -#include "light.h" -#include "api_arrayelt.h" #include "swrast/swrast.h" #include "array_cache/acache.h" @@ -54,19 +46,31 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "swrast_setup/swrast_setup.h" +#include "r200_context.h" +#include "r200_ioctl.h" +#include "r200_state.h" +#include "r200_tcl.h" +#include "r200_tex.h" +#include "r200_swtcl.h" +#include "r200_vtxfmt.h" + + /* ============================================================= * Alpha blending */ -static void r200AlphaFunc( GLcontext *ctx, GLenum func, GLchan ref ) +static void r200AlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); int pp_misc = rmesa->hw.ctx.cmd[CTX_PP_MISC]; + GLubyte refByte; + + CLAMPED_FLOAT_TO_UBYTE(refByte, ref); R200_STATECHANGE( rmesa, ctx ); pp_misc &= ~(R200_ALPHA_TEST_OP_MASK | R200_REF_ALPHA_MASK); - pp_misc |= (ref & R200_REF_ALPHA_MASK); + pp_misc |= (refByte & R200_REF_ALPHA_MASK); switch ( func ) { case GL_NEVER: @@ -1200,7 +1204,7 @@ static void r200UpdateClipPlanes( GLcontext *ctx ) GLuint p; for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { - if (ctx->Transform.ClipEnabled[p]) { + if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { GLint *ip = (GLint *)ctx->Transform._ClipUserPlane[p]; R200_STATECHANGE( rmesa, ucp[p] ); @@ -1221,8 +1225,8 @@ static void r200StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); - GLuint refmask = ((ctx->Stencil.Ref << R200_STENCIL_REF_SHIFT) | - (ctx->Stencil.ValueMask << R200_STENCIL_MASK_SHIFT)); + GLuint refmask = ((ctx->Stencil.Ref[0] << R200_STENCIL_REF_SHIFT) | + (ctx->Stencil.ValueMask[0] << R200_STENCIL_MASK_SHIFT)); R200_STATECHANGE( rmesa, ctx ); R200_STATECHANGE( rmesa, msk ); @@ -1231,7 +1235,7 @@ static void r200StencilFunc( GLcontext *ctx, GLenum func, rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] &= ~(R200_STENCIL_REF_MASK| R200_STENCIL_VALUE_MASK); - switch ( ctx->Stencil.Function ) { + switch ( ctx->Stencil.Function[0] ) { case GL_NEVER: rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_TEST_NEVER; break; @@ -1268,7 +1272,7 @@ static void r200StencilMask( GLcontext *ctx, GLuint mask ) R200_STATECHANGE( rmesa, msk ); rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] &= ~R200_STENCIL_WRITE_MASK; rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] |= - (ctx->Stencil.WriteMask << R200_STENCIL_WRITEMASK_SHIFT); + (ctx->Stencil.WriteMask[0] << R200_STENCIL_WRITEMASK_SHIFT); } static void r200StencilOp( GLcontext *ctx, GLenum fail, @@ -1281,7 +1285,7 @@ static void r200StencilOp( GLcontext *ctx, GLenum fail, R200_STENCIL_ZFAIL_MASK | R200_STENCIL_ZPASS_MASK); - switch ( ctx->Stencil.FailFunc ) { + switch ( ctx->Stencil.FailFunc[0] ) { case GL_KEEP: rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_FAIL_KEEP; break; @@ -1308,7 +1312,7 @@ static void r200StencilOp( GLcontext *ctx, GLenum fail, break; } - switch ( ctx->Stencil.ZFailFunc ) { + switch ( ctx->Stencil.ZFailFunc[0] ) { case GL_KEEP: rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZFAIL_KEEP; break; @@ -1335,7 +1339,7 @@ static void r200StencilOp( GLcontext *ctx, GLenum fail, break; } - switch ( ctx->Stencil.ZPassFunc ) { + switch ( ctx->Stencil.ZPassFunc[0] ) { case GL_KEEP: rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZPASS_KEEP; break; @@ -1370,7 +1374,7 @@ static void r200ClearStencil( GLcontext *ctx, GLint s ) rmesa->state.stencil.clear = ((GLuint) ctx->Stencil.Clear | (0xff << R200_STENCIL_MASK_SHIFT) | - (ctx->Stencil.WriteMask << R200_STENCIL_WRITEMASK_SHIFT)); + (ctx->Stencil.WriteMask[0] << R200_STENCIL_WRITEMASK_SHIFT)); } @@ -1481,11 +1485,17 @@ void r200UpdateViewportOffset( GLcontext *ctx ) * Miscellaneous */ -static void r200ClearColor( GLcontext *ctx, const GLchan c[4] ) +static void r200ClearColor( GLcontext *ctx, const GLfloat c[4] ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); + GLubyte color[4]; + CLAMPED_FLOAT_TO_UBYTE(color[0], c[0]); + CLAMPED_FLOAT_TO_UBYTE(color[1], c[1]); + CLAMPED_FLOAT_TO_UBYTE(color[2], c[2]); + CLAMPED_FLOAT_TO_UBYTE(color[3], c[3]); rmesa->state.color.clear = r200PackColor( rmesa->r200Screen->cpp, - c[0], c[1], c[2], c[3] ); + color[0], color[1], + color[2], color[3] ); } @@ -1558,7 +1568,7 @@ void r200SetCliprects( r200ContextPtr rmesa, GLenum mode ) } -static void r200SetDrawBuffer( GLcontext *ctx, GLenum mode ) +static void r200DrawBuffer( GLcontext *ctx, GLenum mode ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); @@ -1568,34 +1578,29 @@ static void r200SetDrawBuffer( GLcontext *ctx, GLenum mode ) R200_FIREVERTICES(rmesa); /* don't pipeline cliprect changes */ - switch ( mode ) { - case GL_FRONT_LEFT: + /* + * _DrawDestMask is easier to cope with than <mode>. + */ + switch ( ctx->Color._DrawDestMask ) { + case FRONT_LEFT_BIT: FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_FALSE ); - if ( rmesa->doPageFlip && rmesa->sarea->pfCurrentPage == 1 ) { - rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset; - rmesa->state.color.drawPitch = rmesa->r200Screen->backPitch; - } else { - rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset; - rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch; - } r200SetCliprects( rmesa, GL_FRONT_LEFT ); break; - case GL_BACK_LEFT: + case BACK_LEFT_BIT: FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_FALSE ); - if ( rmesa->doPageFlip && rmesa->sarea->pfCurrentPage == 1 ) { - rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset; - rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch; - } else { - rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset; - rmesa->state.color.drawPitch = rmesa->r200Screen->backPitch; - } r200SetCliprects( rmesa, GL_BACK_LEFT ); break; default: + /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } + /* We want to update the s/w rast state too so that r200SetBuffer() + * gets called. + */ + _swrast_DrawBuffer(ctx, mode); + R200_STATECHANGE( rmesa, ctx ); rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = (rmesa->state.color.drawOffset & R200_COLOROFFSET_MASK); @@ -1603,6 +1608,11 @@ static void r200SetDrawBuffer( GLcontext *ctx, GLenum mode ) } +static void r200ReadBuffer( GLcontext *ctx, GLenum mode ) +{ + /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */ +} + /* ============================================================= * State enable/disable */ @@ -1932,7 +1942,7 @@ static void upload_matrix( r200ContextPtr rmesa, GLfloat *src, int idx ) R200_DB_STATECHANGE( rmesa, &rmesa->hw.mat[idx] ); } -static void upload_matrix_t( r200ContextPtr rmesa, GLfloat *src, int idx ) +static void upload_matrix_t( r200ContextPtr rmesa, const GLfloat *src, int idx ) { float *dest = ((float *)R200_DB_STATE( mat[idx] ))+MAT_ELT_0; memcpy(dest, src, 16*sizeof(float)); @@ -1958,7 +1968,7 @@ static void update_texturematrix( GLcontext *ctx ) if (!ctx->Texture.Unit[unit]._ReallyEnabled) continue; - if (ctx->TextureMatrix[unit].type != MATRIX_IDENTITY) { + if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) { rmesa->TexMatEnabled |= (R200_TEXGEN_TEXMAT_0_ENABLE| R200_TEXMAT_0_ENABLE) << unit; @@ -1970,11 +1980,11 @@ static void update_texturematrix( GLcontext *ctx ) */ _math_matrix_mul_matrix( &rmesa->tmpmat, &rmesa->TexGenMatrix[unit], - &ctx->TextureMatrix[unit] ); + ctx->TextureMatrixStack[unit].Top ); upload_matrix( rmesa, rmesa->tmpmat.m, R200_MTX_TEX0+unit ); } else { - upload_matrix( rmesa, ctx->TextureMatrix[unit].m, + upload_matrix( rmesa, ctx->TextureMatrixStack[unit].Top->m, R200_MTX_TEX0+unit ); } } @@ -2020,8 +2030,8 @@ void r200ValidateState( GLcontext *ctx ) /* Need these for lighting (shouldn't upload otherwise) */ if (new_state & (_NEW_MODELVIEW)) { - upload_matrix( rmesa, ctx->ModelView.m, R200_MTX_MV ); - upload_matrix_t( rmesa, ctx->ModelView.inv, R200_MTX_IMV ); + upload_matrix( rmesa, ctx->ModelviewMatrixStack.Top->m, R200_MTX_MV ); + upload_matrix_t( rmesa, ctx->ModelviewMatrixStack.Top->inv, R200_MTX_IMV ); } /* Does this need to be triggered on eg. modelview for @@ -2038,7 +2048,7 @@ void r200ValidateState( GLcontext *ctx ) /* emit all active clip planes if projection matrix changes. */ if (new_state & (_NEW_PROJECTION)) { - if (ctx->Transform._AnyClip) + if (ctx->Transform.ClipPlanesEnabled) r200UpdateClipPlanes( ctx ); } @@ -2093,7 +2103,8 @@ void r200InitStateFuncs( GLcontext *ctx ) ctx->Driver.UpdateState = r200InvalidateState; ctx->Driver.LightingSpaceChange = r200LightingSpaceChange; - ctx->Driver.SetDrawBuffer = r200SetDrawBuffer; + ctx->Driver.DrawBuffer = r200DrawBuffer; + ctx->Driver.ReadBuffer = r200ReadBuffer; ctx->Driver.AlphaFunc = r200AlphaFunc; ctx->Driver.BlendEquation = r200BlendEquation; |