diff options
author | Brian Paul <[email protected]> | 2004-04-23 14:16:46 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2004-04-23 14:16:46 +0000 |
commit | 6d460af6af77a0d5a5b568bcd6094b98e249ba93 (patch) | |
tree | 08656028582b357d5c9730c521cc3e1770604c50 /src/mesa/main | |
parent | 384800fe12e368f3489111de4572dbc8846a7dea (diff) |
Added ctx->Vertex/FragmentProgram._Enable flags. Set when vertex/fragment
program is enabled AND the currently bound program is valid.
Check _Enable instead of Enable to prevent things from blowing up
when someone calls glEnable(GL_VERTEX_PROGRAM_ARB) without actually
defining a program.
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/api_noop.c | 4 | ||||
-rw-r--r-- | src/mesa/main/api_validate.c | 7 | ||||
-rw-r--r-- | src/mesa/main/context.h | 8 | ||||
-rw-r--r-- | src/mesa/main/drawpix.c | 9 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 10 | ||||
-rw-r--r-- | src/mesa/main/rastpos.c | 2 | ||||
-rw-r--r-- | src/mesa/main/state.c | 53 | ||||
-rw-r--r-- | src/mesa/main/texstate.c | 4 |
8 files changed, 57 insertions, 40 deletions
diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c index e7f185a272c..2f38526bbda 100644 --- a/src/mesa/main/api_noop.c +++ b/src/mesa/main/api_noop.c @@ -704,7 +704,7 @@ void GLAPIENTRY _mesa_noop_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) */ if (!ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3 && - !(ctx->VertexProgram.Enabled && ctx->Eval.Map1Attrib[VERT_ATTRIB_POS])) + !(ctx->VertexProgram._Enabled && ctx->Eval.Map1Attrib[VERT_ATTRIB_POS])) return; du = ctx->Eval.MapGrid1du; @@ -739,7 +739,7 @@ void GLAPIENTRY _mesa_noop_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, */ if (!ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3 && - !(ctx->VertexProgram.Enabled && ctx->Eval.Map2Attrib[VERT_ATTRIB_POS])) + !(ctx->VertexProgram._Enabled && ctx->Eval.Map2Attrib[VERT_ATTRIB_POS])) return; du = ctx->Eval.MapGrid2du; diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 4e09c2855a5..d1c8f42e747 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -1,7 +1,6 @@ - /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 6.1 * * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. * @@ -62,7 +61,7 @@ _mesa_validate_DrawElements(GLcontext *ctx, /* Always need vertex positions */ if (!ctx->Array.Vertex.Enabled - && !(ctx->VertexProgram.Enabled && ctx->Array.VertexAttrib[0].Enabled)) + && !(ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[0].Enabled)) return GL_FALSE; /* Vertex buffer object tests */ @@ -168,7 +167,7 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode, /* Always need vertex positions */ if (!ctx->Array.Vertex.Enabled - && !(ctx->VertexProgram.Enabled && ctx->Array.VertexAttrib[0].Enabled)) + && !(ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[0].Enabled)) return GL_FALSE; if (ctx->Const.CheckArrayBounds) { diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index e55b383dec6..c59a8b21186 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -21,9 +21,9 @@ /* * Mesa 3-D graphics library - * Version: 4.1 + * Version: 6.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -375,9 +375,9 @@ do { \ (((CTX)->Light.Enabled && \ (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) \ || (CTX)->Fog.ColorSumEnabled \ - || ((CTX)->VertexProgram.Enabled && \ + || ((CTX)->VertexProgram._Enabled && \ ((CTX)->VertexProgram.Current->InputsRead & VERT_BIT_COLOR1)) \ - || ((CTX)->FragmentProgram.Enabled && \ + || ((CTX)->FragmentProgram._Enabled && \ ((CTX)->FragmentProgram.Current->InputsRead & FRAG_BIT_COL1)) \ ) diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c index fc7dd32b06b..6f7cae9ef55 100644 --- a/src/mesa/main/drawpix.c +++ b/src/mesa/main/drawpix.c @@ -45,8 +45,7 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (ctx->FragmentProgram.Enabled - && !ctx->FragmentProgram.Current->Instructions) { + if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) { _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels (invalid fragment program)"); return; @@ -103,8 +102,7 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, GLint destx, desty; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (ctx->FragmentProgram.Enabled - && !ctx->FragmentProgram.Current->Instructions) { + if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) { _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyPixels (invalid fragment program)"); return; @@ -184,8 +182,7 @@ _mesa_Bitmap( GLsizei width, GLsizei height, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (ctx->FragmentProgram.Enabled - && !ctx->FragmentProgram.Current->Instructions) { + if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap (invalid fragment program)"); return; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 4d78264bde9..d021ffc4ff4 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1628,10 +1628,11 @@ struct program_state { */ struct vertex_program_state { - GLboolean Enabled; /**< GL_VERTEX_PROGRAM_NV */ - GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */ - GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */ - struct vertex_program *Current; /**< ptr to currently bound program */ + GLboolean Enabled; /**< GL_VERTEX_PROGRAM_NV */ + GLboolean _Enabled; /**< Really enabled? */ + GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */ + GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */ + struct vertex_program *Current; /**< ptr to currently bound program */ GLenum TrackMatrix[MAX_NV_VERTEX_PROGRAM_PARAMS / 4]; GLenum TrackMatrixTransform[MAX_NV_VERTEX_PROGRAM_PARAMS / 4]; @@ -1658,6 +1659,7 @@ struct vertex_program_state struct fragment_program_state { GLboolean Enabled; /* GL_VERTEX_PROGRAM_NV */ + GLboolean _Enabled; /* Really enabled? */ struct fragment_program *Current; /* ptr to currently bound program */ struct fp_machine Machine; /* machine state */ GLfloat Parameters[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4]; /* Env params */ diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c index a73781e8e60..b6c3d9090be 100644 --- a/src/mesa/main/rastpos.c +++ b/src/mesa/main/rastpos.c @@ -418,7 +418,7 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) if (ctx->NewState) _mesa_update_state( ctx ); - if (ctx->VertexProgram.Enabled) { + if (ctx->VertexProgram._Enabled) { /* XXX implement this */ _mesa_problem(ctx, "Vertex programs not implemented for glRasterPos"); return; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index b8a67d0ee38..c894241a739 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1,11 +1,3 @@ -/** - * \file state.c - * State management. - * - * This file manages recalculation of derived values in the __GLcontextRec. - * Also, this is where we initialize the API dispatch table. - */ - /* * Mesa 3-D graphics library * Version: 6.1 @@ -31,6 +23,14 @@ */ +/** + * \file state.c + * State management. + * + * This file manages recalculation of derived values in the __GLcontextRec. + * Also, this is where we initialize the API dispatch table. + */ + #include "glheader.h" #include "accum.h" #include "api_loopback.h" @@ -762,7 +762,7 @@ update_arrays( GLcontext *ctx ) /* find min of _MaxElement values for all enabled arrays */ /* 0 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled) { min = ctx->Array.VertexAttrib[VERT_ATTRIB_POS]._MaxElement; } @@ -775,14 +775,14 @@ update_arrays( GLcontext *ctx ) } /* 1 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_WEIGHT]._MaxElement); } /* no conventional vertex weight array */ /* 2 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL]._MaxElement); } @@ -791,7 +791,7 @@ update_arrays( GLcontext *ctx ) } /* 3 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR0]._MaxElement); } @@ -800,7 +800,7 @@ update_arrays( GLcontext *ctx ) } /* 4 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR1]._MaxElement); } @@ -809,7 +809,7 @@ update_arrays( GLcontext *ctx ) } /* 5 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_FOG].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_FOG]._MaxElement); } @@ -818,20 +818,20 @@ update_arrays( GLcontext *ctx ) } /* 6 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_SIX].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_SIX]._MaxElement); } /* 7 */ - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[VERT_ATTRIB_SEVEN].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_SEVEN]._MaxElement); } /* 8..15 */ for (i = VERT_ATTRIB_TEX0; i < VERT_ATTRIB_MAX; i++) { - if (ctx->VertexProgram.Enabled + if (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[i].Enabled) { min = MIN2(min, ctx->Array.VertexAttrib[i]._MaxElement); } @@ -854,6 +854,22 @@ update_arrays( GLcontext *ctx ) } +/** + * Update derived vertex/fragment program state. + */ +static void +update_program(GLcontext *ctx) +{ + /* For now, just set the _Enabled (really enabled) flags. + * In the future we may have to check other state to be sure we really + * have a runable program or shader. + */ + ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled + && ctx->VertexProgram.Current->Instructions; + ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled + && ctx->FragmentProgram.Current->Instructions; +} + /* * If __GLcontextRec::NewState is non-zero then this function \b must be called @@ -875,6 +891,9 @@ void _mesa_update_state( GLcontext *ctx ) if (MESA_VERBOSE & VERBOSE_STATE) _mesa_print_state("_mesa_update_state", new_state); + if (new_state & _NEW_PROGRAM) + update_program( ctx ); + if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) _mesa_update_modelview_project( ctx, new_state ); diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 38dd4442a72..54835c9dda2 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -2935,7 +2935,7 @@ update_texture_state( GLcontext *ctx ) texUnit->_GenFlags = 0; /* Get the bitmask of texture enables */ - if (ctx->FragmentProgram.Enabled && ctx->FragmentProgram.Current) { + if (ctx->FragmentProgram._Enabled) { enableBits = ctx->FragmentProgram.Current->TexturesUsed[unit]; } else { @@ -3099,7 +3099,7 @@ update_texture_state( GLcontext *ctx ) /* Fragment programs may need texture coordinates but not the * corresponding texture images. */ - if (ctx->FragmentProgram.Enabled && ctx->FragmentProgram.Current) { + if (ctx->FragmentProgram._Enabled) { ctx->Texture._EnabledCoordUnits |= (ctx->FragmentProgram.Current->InputsRead >> FRAG_ATTRIB_TEX0); } |