void _tnl_wakeup_exec( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); install_driver_callbacks(ctx); ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; /* Hook our functions into exec and compile dispatch tables. */ _mesa_install_exec_vtxfmt( ctx, &tnl->exec_vtxfmt ); /* Call all appropriate driver callbacks to revive state. */ _tnl_MakeCurrent( ctx, ctx->DrawBuffer, ctx->ReadBuffer ); /* Assume we haven't been getting state updates either: */ _tnl_InvalidateState( ctx, ~0 ); tnl->pipeline.run_input_changes = ~0; if (ctx->Light.ColorMaterialEnabled) { _mesa_update_color_material( ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); } }
/** * Copy the last specified normal, color, texcoord, edge flag, etc * from the immediate struct into the ctx->Current attribute group. */ void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, GLuint flag, GLuint count ) { if (MESA_VERBOSE&VERBOSE_IMMEDIATE) _tnl_print_vert_flags("copy to current", flag); /* XXX should be able to replace these conditions with a loop over * the 16 vertex attributes. */ if (flag & VERT_BIT_NORMAL) COPY_4FV( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], IM->Attrib[VERT_ATTRIB_NORMAL][count]); if (flag & VERT_BIT_COLOR0) { COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_COLOR0], IM->Attrib[VERT_ATTRIB_COLOR0][count]); if (ctx->Light.ColorMaterialEnabled) { _mesa_update_color_material( ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); } } if (flag & VERT_BIT_COLOR1) COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_COLOR1], IM->Attrib[VERT_ATTRIB_COLOR1][count]); if (flag & VERT_BIT_FOG) ctx->Current.Attrib[VERT_ATTRIB_FOG][0] = IM->Attrib[VERT_ATTRIB_FOG][count][0]; if (flag & VERT_BIT_SIX) COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_SIX], IM->Attrib[VERT_ATTRIB_SIX][count]); if (flag & VERT_BIT_SEVEN) COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_SEVEN], IM->Attrib[VERT_ATTRIB_SEVEN][count]); if (flag & VERT_BITS_TEX_ANY) { GLuint i; for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { if (flag & VERT_BIT_TEX(i)) { COPY_4FV( ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i], IM->Attrib[VERT_ATTRIB_TEX0 + i][count]); } } } if (flag & VERT_BIT_INDEX) ctx->Current.Index = IM->Index[count]; if (flag & VERT_BIT_EDGEFLAG) ctx->Current.EdgeFlag = IM->EdgeFlag[count]; if (flag & VERT_BIT_MATERIAL) { _mesa_update_material( ctx, IM->Material[IM->LastMaterial], IM->MaterialOrMask ); TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); } }
/** * Copy the active vertex's values to the ctx->Current fields. */ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) { struct gl_context *ctx = exec->ctx; struct vbo_context *vbo = vbo_context(ctx); GLuint i; for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) { if (exec->vtx.attrsz[i]) { /* Note: the exec->vtx.current[i] pointers point into the * ctx->Current.Attrib and ctx->Light.Material.Attrib arrays. */ GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; GLfloat tmp[4]; COPY_CLEAN_4V_TYPE_AS_FLOAT(tmp, exec->vtx.attrsz[i], exec->vtx.attrptr[i], exec->vtx.attrtype[i]); if (exec->vtx.attrtype[i] != vbo->currval[i].Type || memcmp(current, tmp, sizeof(tmp)) != 0) { memcpy(current, tmp, sizeof(tmp)); /* Given that we explicitly state size here, there is no need * for the COPY_CLEAN above, could just copy 16 bytes and be * done. The only problem is when Mesa accesses ctx->Current * directly. */ vbo->currval[i].Size = exec->vtx.attrsz[i]; vbo->currval[i]._ElementSize = vbo->currval[i].Size * sizeof(GLfloat); vbo->currval[i].Type = exec->vtx.attrtype[i]; vbo->currval[i].Integer = vbo_attrtype_to_integer_flag(exec->vtx.attrtype[i]); /* This triggers rather too much recalculation of Mesa state * that doesn't get used (eg light positions). */ if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT && i <= VBO_ATTRIB_MAT_BACK_INDEXES) ctx->NewState |= _NEW_LIGHT; ctx->NewState |= _NEW_CURRENT_ATTRIB; } } } /* Colormaterial -- this kindof sucks. */ if (ctx->Light.ColorMaterialEnabled && exec->vtx.attrsz[VBO_ATTRIB_COLOR0]) { _mesa_update_color_material(ctx, ctx->Current.Attrib[VBO_ATTRIB_COLOR0]); } }
/* * After playback, copy everything but the position from the * last vertex to the saved state */ static void _playback_copy_to_current( GLcontext *ctx, const struct vbo_save_vertex_list *node ) { struct vbo_context *vbo = vbo_context(ctx); GLfloat vertex[VBO_ATTRIB_MAX * 4], *data = vertex; GLuint i, offset; if (node->count) offset = (node->buffer_offset + (node->count-1) * node->vertex_size * sizeof(GLfloat)); else offset = node->buffer_offset; ctx->Driver.GetBufferSubData( ctx, 0, offset, node->vertex_size * sizeof(GLfloat), data, node->vertex_store->bufferobj ); data += node->attrsz[0]; /* skip vertex position */ for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) { if (node->attrsz[i]) { GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; COPY_CLEAN_4V(current, node->attrsz[i], data); vbo->currval[i].Size = node->attrsz[i]; data += node->attrsz[i]; if (i >= VBO_ATTRIB_FIRST_MATERIAL && i <= VBO_ATTRIB_LAST_MATERIAL) ctx->NewState |= _NEW_LIGHT; } } /* Colormaterial -- this kindof sucks. */ if (ctx->Light.ColorMaterialEnabled) { _mesa_update_color_material(ctx, ctx->Current.Attrib[VBO_ATTRIB_COLOR0]); } /* CurrentExecPrimitive */ if (node->prim_count) { const struct _mesa_prim *prim = &node->prim[node->prim_count - 1]; if (prim->end) ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; else ctx->Driver.CurrentExecPrimitive = prim->mode; } }
void _tnl_wakeup( GLcontext *ctx ) { /* Assume we haven't been getting state updates either: */ _tnl_InvalidateState( ctx, ~0 ); #if 0 if (ctx->Light.ColorMaterialEnabled) { _mesa_update_color_material( ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); } #endif }
static void _playback_copy_to_current( GLcontext *ctx, const struct tnl_vertex_list *node ) { TNLcontext *tnl = TNL_CONTEXT(ctx); const GLfloat *data; GLuint i; if (node->count) data = node->buffer + (node->count-1) * node->vertex_size; else data = node->buffer; for (i = _TNL_ATTRIB_POS+1 ; i <= _TNL_ATTRIB_INDEX ; i++) { if (node->attrsz[i]) { ASSIGN_4V(tnl->vtx.current[i], 0, 0, 0, 1); COPY_SZ_4V(tnl->vtx.current[i], node->attrsz[i], data); data += node->attrsz[i]; } } /* Edgeflag requires special treatment: */ if (node->attrsz[_TNL_ATTRIB_EDGEFLAG]) { ctx->Current.EdgeFlag = (data[0] == 1.0); } /* Colormaterial -- this kindof sucks. */ if (ctx->Light.ColorMaterialEnabled) { _mesa_update_color_material(ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); } if (node->have_materials) { tnl->Driver.NotifyMaterialChange( ctx ); } /* CurrentExecPrimitive */ if (node->prim_count) { GLenum mode = node->prim[node->prim_count - 1].mode; if (mode & PRIM_END) ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; else ctx->Driver.CurrentExecPrimitive = (mode & PRIM_MODE_MASK); } }
/* * Copy the active vertex's values to the ctx->Current fields. */ static void _tnl_copy_to_current( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint i; for (i = _TNL_ATTRIB_POS+1 ; i < _TNL_ATTRIB_INDEX ; i++) { if (tnl->vtx.attrsz[i]) { /* Note: the tnl->vtx.current[i] pointers points to * the ctx->Current fields. The first 16 or so, anyway. */ COPY_CLEAN_4V(tnl->vtx.current[i], tnl->vtx.attrsz[i], tnl->vtx.attrptr[i]); } } /* color index is special (it's not a float[4] so COPY_CLEAN_4V above * will trash adjacent memory!) */ if (tnl->vtx.attrsz[_TNL_ATTRIB_INDEX]) { ctx->Current.Index = tnl->vtx.attrptr[_TNL_ATTRIB_INDEX][0]; } /* Edgeflag requires additional treatment: */ if (tnl->vtx.attrsz[_TNL_ATTRIB_EDGEFLAG]) { ctx->Current.EdgeFlag = (tnl->vtx.CurrentFloatEdgeFlag == 1.0); } /* Colormaterial -- this kindof sucks. */ if (ctx->Light.ColorMaterialEnabled) { _mesa_update_color_material(ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); } if (tnl->vtx.have_materials) { tnl->Driver.NotifyMaterialChange( ctx ); } ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT; }
/** * Helper function to enable or disable state. * * \param ctx GL context. * \param cap the state to enable/disable * \param state whether to enable or disable the specified capability. * * Updates the current context and flushes the vertices as needed. For * capabilities associated with extensions it verifies that those extensions * are effectivly present before updating. Notifies the driver via * dd_function_table::Enable. */ void _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) { if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "%s %s (newstate is %x)\n", state ? "glEnable" : "glDisable", _mesa_lookup_enum_by_nr(cap), ctx->NewState); switch (cap) { case GL_ALPHA_TEST: if (ctx->Color.AlphaEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.AlphaEnabled = state; break; case GL_AUTO_NORMAL: if (ctx->Eval.AutoNormal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.AutoNormal = state; break; case GL_BLEND: if (ctx->Color.BlendEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.BlendEnabled = state; break; #if FEATURE_userclip case GL_CLIP_PLANE0: case GL_CLIP_PLANE1: case GL_CLIP_PLANE2: case GL_CLIP_PLANE3: case GL_CLIP_PLANE4: case GL_CLIP_PLANE5: { const GLuint p = cap - GL_CLIP_PLANE0; if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p)) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); if (state) { ctx->Transform.ClipPlanesEnabled |= (1 << p); if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); /* This derived state also calculated in clip.c and * from _mesa_update_state() on changes to EyeUserPlane * and ctx->ProjectionMatrix respectively. */ _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], ctx->Transform.EyeUserPlane[p], ctx->ProjectionMatrixStack.Top->inv ); } else { ctx->Transform.ClipPlanesEnabled &= ~(1 << p); } } break; #endif case GL_COLOR_MATERIAL: if (ctx->Light.ColorMaterialEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); FLUSH_CURRENT(ctx, 0); ctx->Light.ColorMaterialEnabled = state; if (state) { _mesa_update_color_material( ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); } break; case GL_CULL_FACE: if (ctx->Polygon.CullFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.CullFlag = state; break; case GL_CULL_VERTEX_EXT: CHECK_EXTENSION(EXT_cull_vertex, cap); if (ctx->Transform.CullVertexFlag == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.CullVertexFlag = state; break; case GL_DEPTH_TEST: if (ctx->Depth.Test == state) return; FLUSH_VERTICES(ctx, _NEW_DEPTH); ctx->Depth.Test = state; break; case GL_DITHER: if (ctx->NoDither) { state = GL_FALSE; /* MESA_NO_DITHER env var */ } if (ctx->Color.DitherFlag == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.DitherFlag = state; break; case GL_FOG: if (ctx->Fog.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_FOG); ctx->Fog.Enabled = state; break; case GL_HISTOGRAM: CHECK_EXTENSION(EXT_histogram, cap); if (ctx->Pixel.HistogramEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.HistogramEnabled = state; break; case GL_LIGHT0: case GL_LIGHT1: case GL_LIGHT2: case GL_LIGHT3: case GL_LIGHT4: case GL_LIGHT5: case GL_LIGHT6: case GL_LIGHT7: if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; if (state) { insert_at_tail(&ctx->Light.EnabledList, &ctx->Light.Light[cap-GL_LIGHT0]); } else { remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); } break; case GL_LIGHTING: if (ctx->Light.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); ctx->Light.Enabled = state; if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; else ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; break; case GL_LINE_SMOOTH: if (ctx->Line.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_LINE); ctx->Line.SmoothFlag = state; ctx->_TriangleCaps ^= DD_LINE_SMOOTH; break; case GL_LINE_STIPPLE: if (ctx->Line.StippleFlag == state) return; FLUSH_VERTICES(ctx, _NEW_LINE); ctx->Line.StippleFlag = state; ctx->_TriangleCaps ^= DD_LINE_STIPPLE; break; case GL_INDEX_LOGIC_OP: if (ctx->Color.IndexLogicOpEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.IndexLogicOpEnabled = state; break; case GL_COLOR_LOGIC_OP: if (ctx->Color.ColorLogicOpEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.ColorLogicOpEnabled = state; break; case GL_MAP1_COLOR_4: if (ctx->Eval.Map1Color4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Color4 = state; break; case GL_MAP1_INDEX: if (ctx->Eval.Map1Index == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Index = state; break; case GL_MAP1_NORMAL: if (ctx->Eval.Map1Normal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Normal = state; break; case GL_MAP1_TEXTURE_COORD_1: if (ctx->Eval.Map1TextureCoord1 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord1 = state; break; case GL_MAP1_TEXTURE_COORD_2: if (ctx->Eval.Map1TextureCoord2 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord2 = state; break; case GL_MAP1_TEXTURE_COORD_3: if (ctx->Eval.Map1TextureCoord3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord3 = state; break; case GL_MAP1_TEXTURE_COORD_4: if (ctx->Eval.Map1TextureCoord4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord4 = state; break; case GL_MAP1_VERTEX_3: if (ctx->Eval.Map1Vertex3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Vertex3 = state; break; case GL_MAP1_VERTEX_4: if (ctx->Eval.Map1Vertex4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Vertex4 = state; break; case GL_MAP2_COLOR_4: if (ctx->Eval.Map2Color4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Color4 = state; break; case GL_MAP2_INDEX: if (ctx->Eval.Map2Index == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Index = state; break; case GL_MAP2_NORMAL: if (ctx->Eval.Map2Normal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Normal = state; break; case GL_MAP2_TEXTURE_COORD_1: if (ctx->Eval.Map2TextureCoord1 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord1 = state; break; case GL_MAP2_TEXTURE_COORD_2: if (ctx->Eval.Map2TextureCoord2 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord2 = state; break; case GL_MAP2_TEXTURE_COORD_3: if (ctx->Eval.Map2TextureCoord3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord3 = state; break; case GL_MAP2_TEXTURE_COORD_4: if (ctx->Eval.Map2TextureCoord4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord4 = state; break; case GL_MAP2_VERTEX_3: if (ctx->Eval.Map2Vertex3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Vertex3 = state; break; case GL_MAP2_VERTEX_4: if (ctx->Eval.Map2Vertex4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Vertex4 = state; break; case GL_MINMAX: if (ctx->Pixel.MinMaxEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.MinMaxEnabled = state; break; case GL_NORMALIZE: if (ctx->Transform.Normalize == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.Normalize = state; break; case GL_POINT_SMOOTH: if (ctx->Point.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POINT); ctx->Point.SmoothFlag = state; ctx->_TriangleCaps ^= DD_POINT_SMOOTH; break; case GL_POLYGON_SMOOTH: if (ctx->Polygon.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.SmoothFlag = state; ctx->_TriangleCaps ^= DD_TRI_SMOOTH; break; case GL_POLYGON_STIPPLE: if (ctx->Polygon.StippleFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.StippleFlag = state; ctx->_TriangleCaps ^= DD_TRI_STIPPLE; break; case GL_POLYGON_OFFSET_POINT: if (ctx->Polygon.OffsetPoint == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetPoint = state; break; case GL_POLYGON_OFFSET_LINE: if (ctx->Polygon.OffsetLine == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetLine = state; break; case GL_POLYGON_OFFSET_FILL: /*case GL_POLYGON_OFFSET_EXT:*/ if (ctx->Polygon.OffsetFill == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetFill = state; break; case GL_RESCALE_NORMAL_EXT: if (ctx->Transform.RescaleNormals == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.RescaleNormals = state; break; case GL_SCISSOR_TEST: if (ctx->Scissor.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_SCISSOR); ctx->Scissor.Enabled = state; break; case GL_SHARED_TEXTURE_PALETTE_EXT: if (ctx->Texture.SharedPalette == state) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); ctx->Texture.SharedPalette = state; break; case GL_STENCIL_TEST: if (ctx->Stencil.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_STENCIL); ctx->Stencil.Enabled = state; break; case GL_TEXTURE_1D: if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { return; } break; case GL_TEXTURE_2D: if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { return; } break; case GL_TEXTURE_3D: if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) { return; } break; case GL_TEXTURE_GEN_Q: { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); if (texUnit) { GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT; if (state) newenabled |= Q_BIT; if (texUnit->TexGenEnabled == newenabled) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); texUnit->TexGenEnabled = newenabled; } } break; case GL_TEXTURE_GEN_R: { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); if (texUnit) { GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT; if (state) newenabled |= R_BIT; if (texUnit->TexGenEnabled == newenabled) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); texUnit->TexGenEnabled = newenabled; } } break; case GL_TEXTURE_GEN_S: { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); if (texUnit) { GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT; if (state) newenabled |= S_BIT; if (texUnit->TexGenEnabled == newenabled) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); texUnit->TexGenEnabled = newenabled; } } break; case GL_TEXTURE_GEN_T: { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); if (texUnit) { GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT; if (state) newenabled |= T_BIT; if (texUnit->TexGenEnabled == newenabled) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); texUnit->TexGenEnabled = newenabled; } } break; /* * CLIENT STATE!!! */ case GL_VERTEX_ARRAY: case GL_NORMAL_ARRAY: case GL_COLOR_ARRAY: case GL_INDEX_ARRAY: case GL_TEXTURE_COORD_ARRAY: case GL_EDGE_FLAG_ARRAY: case GL_FOG_COORDINATE_ARRAY_EXT: case GL_SECONDARY_COLOR_ARRAY_EXT: case GL_POINT_SIZE_ARRAY_OES: client_state( ctx, cap, state ); return; /* GL_SGI_color_table */ case GL_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table, cap); if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] = state; break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table, cap); if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] = state; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table, cap); if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] = state; break; case GL_TEXTURE_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_texture_color_table, cap); if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state; break; /* GL_EXT_convolution */ case GL_CONVOLUTION_1D: CHECK_EXTENSION(EXT_convolution, cap); if (ctx->Pixel.Convolution1DEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.Convolution1DEnabled = state; break; case GL_CONVOLUTION_2D: CHECK_EXTENSION(EXT_convolution, cap); if (ctx->Pixel.Convolution2DEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.Convolution2DEnabled = state; break; case GL_SEPARABLE_2D: CHECK_EXTENSION(EXT_convolution, cap); if (ctx->Pixel.Separable2DEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.Separable2DEnabled = state; break; /* GL_ARB_texture_cube_map */ case GL_TEXTURE_CUBE_MAP_ARB: CHECK_EXTENSION(ARB_texture_cube_map, cap); if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { return; } break; /* GL_EXT_secondary_color */ case GL_COLOR_SUM_EXT: CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap); if (ctx->Fog.ColorSumEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_FOG); ctx->Fog.ColorSumEnabled = state; break; /* GL_ARB_multisample */ case GL_MULTISAMPLE_ARB: if (ctx->Multisample.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.Enabled = state; break; case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: if (ctx->Multisample.SampleAlphaToCoverage == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleAlphaToCoverage = state; break; case GL_SAMPLE_ALPHA_TO_ONE_ARB: if (ctx->Multisample.SampleAlphaToOne == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleAlphaToOne = state; break; case GL_SAMPLE_COVERAGE_ARB: if (ctx->Multisample.SampleCoverage == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleCoverage = state; break; case GL_SAMPLE_COVERAGE_INVERT_ARB: if (ctx->Multisample.SampleCoverageInvert == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleCoverageInvert = state; break; /* GL_IBM_rasterpos_clip */ case GL_RASTER_POSITION_UNCLIPPED_IBM: CHECK_EXTENSION(IBM_rasterpos_clip, cap); if (ctx->Transform.RasterPositionUnclipped == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.RasterPositionUnclipped = state; break; /* GL_NV_point_sprite */ case GL_POINT_SPRITE_NV: CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); if (ctx->Point.PointSprite == state) return; FLUSH_VERTICES(ctx, _NEW_POINT); ctx->Point.PointSprite = state; break; #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program case GL_VERTEX_PROGRAM_ARB: CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); if (ctx->VertexProgram.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM); ctx->VertexProgram.Enabled = state; break; case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); if (ctx->VertexProgram.PointSizeEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM); ctx->VertexProgram.PointSizeEnabled = state; break; case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); if (ctx->VertexProgram.TwoSideEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM); ctx->VertexProgram.TwoSideEnabled = state; break; #endif #if FEATURE_NV_vertex_program case GL_MAP1_VERTEX_ATTRIB0_4_NV: case GL_MAP1_VERTEX_ATTRIB1_4_NV: case GL_MAP1_VERTEX_ATTRIB2_4_NV: case GL_MAP1_VERTEX_ATTRIB3_4_NV: case GL_MAP1_VERTEX_ATTRIB4_4_NV: case GL_MAP1_VERTEX_ATTRIB5_4_NV: case GL_MAP1_VERTEX_ATTRIB6_4_NV: case GL_MAP1_VERTEX_ATTRIB7_4_NV: case GL_MAP1_VERTEX_ATTRIB8_4_NV: case GL_MAP1_VERTEX_ATTRIB9_4_NV: case GL_MAP1_VERTEX_ATTRIB10_4_NV: case GL_MAP1_VERTEX_ATTRIB11_4_NV: case GL_MAP1_VERTEX_ATTRIB12_4_NV: case GL_MAP1_VERTEX_ATTRIB13_4_NV: case GL_MAP1_VERTEX_ATTRIB14_4_NV: case GL_MAP1_VERTEX_ATTRIB15_4_NV: CHECK_EXTENSION(NV_vertex_program, cap); { const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Attrib[map] = state; } break; case GL_MAP2_VERTEX_ATTRIB0_4_NV: case GL_MAP2_VERTEX_ATTRIB1_4_NV: case GL_MAP2_VERTEX_ATTRIB2_4_NV: case GL_MAP2_VERTEX_ATTRIB3_4_NV: case GL_MAP2_VERTEX_ATTRIB4_4_NV: case GL_MAP2_VERTEX_ATTRIB5_4_NV: case GL_MAP2_VERTEX_ATTRIB6_4_NV: case GL_MAP2_VERTEX_ATTRIB7_4_NV: case GL_MAP2_VERTEX_ATTRIB8_4_NV: case GL_MAP2_VERTEX_ATTRIB9_4_NV: case GL_MAP2_VERTEX_ATTRIB10_4_NV: case GL_MAP2_VERTEX_ATTRIB11_4_NV: case GL_MAP2_VERTEX_ATTRIB12_4_NV: case GL_MAP2_VERTEX_ATTRIB13_4_NV: case GL_MAP2_VERTEX_ATTRIB14_4_NV: case GL_MAP2_VERTEX_ATTRIB15_4_NV: CHECK_EXTENSION(NV_vertex_program, cap); { const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Attrib[map] = state; } break; #endif /* FEATURE_NV_vertex_program */ #if FEATURE_NV_fragment_program case GL_FRAGMENT_PROGRAM_NV: CHECK_EXTENSION(NV_fragment_program, cap); if (ctx->FragmentProgram.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM); ctx->FragmentProgram.Enabled = state; break; #endif /* FEATURE_NV_fragment_program */ /* GL_NV_texture_rectangle */ case GL_TEXTURE_RECTANGLE_NV: CHECK_EXTENSION(NV_texture_rectangle, cap); if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) { return; } break; /* GL_EXT_stencil_two_side */ case GL_STENCIL_TEST_TWO_SIDE_EXT: CHECK_EXTENSION(EXT_stencil_two_side, cap); if (ctx->Stencil.TestTwoSide == state) return; FLUSH_VERTICES(ctx, _NEW_STENCIL); ctx->Stencil.TestTwoSide = state; if (state) { ctx->Stencil._BackFace = 2; ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; } else { ctx->Stencil._BackFace = 1; ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL; } break; #if FEATURE_ARB_fragment_program case GL_FRAGMENT_PROGRAM_ARB: CHECK_EXTENSION(ARB_fragment_program, cap); if (ctx->FragmentProgram.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM); ctx->FragmentProgram.Enabled = state; break; #endif /* FEATURE_ARB_fragment_program */ /* GL_EXT_depth_bounds_test */ case GL_DEPTH_BOUNDS_TEST_EXT: CHECK_EXTENSION(EXT_depth_bounds_test, cap); if (state && ctx->DrawBuffer->Visual.depthBits == 0) { _mesa_warning(ctx, "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer"); return; } if (ctx->Depth.BoundsTest == state) return; FLUSH_VERTICES(ctx, _NEW_DEPTH); ctx->Depth.BoundsTest = state; break; #if FEATURE_ATI_fragment_shader case GL_FRAGMENT_SHADER_ATI: CHECK_EXTENSION(ATI_fragment_shader, cap); if (ctx->ATIFragmentShader.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM); ctx->ATIFragmentShader.Enabled = state; break; #endif /* GL_MESA_texture_array */ case GL_TEXTURE_1D_ARRAY_EXT: CHECK_EXTENSION(MESA_texture_array, cap); if (!enable_texture(ctx, state, TEXTURE_1D_ARRAY_BIT)) { return; } break; case GL_TEXTURE_2D_ARRAY_EXT: CHECK_EXTENSION(MESA_texture_array, cap); if (!enable_texture(ctx, state, TEXTURE_2D_ARRAY_BIT)) { return; } break; default: _mesa_error(ctx, GL_INVALID_ENUM, "%s(0x%x)", state ? "glEnable" : "glDisable", cap); return; } if (ctx->Driver.Enable) { ctx->Driver.Enable( ctx, cap, state ); } }
/** * Copy the active vertex's values to the ctx->Current fields. */ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) { struct gl_context *ctx = exec->ctx; struct vbo_context *vbo = vbo_context(ctx); GLbitfield64 enabled = exec->vtx.enabled & (~BITFIELD64_BIT(VBO_ATTRIB_POS)); while (enabled) { const int i = u_bit_scan64(&enabled); /* Note: the exec->vtx.current[i] pointers point into the * ctx->Current.Attrib and ctx->Light.Material.Attrib arrays. */ GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; fi_type tmp[8]; /* space for doubles */ int dmul = exec->vtx.attrtype[i] == GL_DOUBLE ? 2 : 1; assert(exec->vtx.attrsz[i]); if (exec->vtx.attrtype[i] == GL_DOUBLE) { memset(tmp, 0, sizeof(tmp)); memcpy(tmp, exec->vtx.attrptr[i], exec->vtx.attrsz[i] * sizeof(GLfloat)); } else { COPY_CLEAN_4V_TYPE_AS_UNION(tmp, exec->vtx.attrsz[i], exec->vtx.attrptr[i], exec->vtx.attrtype[i]); } if (exec->vtx.attrtype[i] != vbo->currval[i].Type || memcmp(current, tmp, 4 * sizeof(GLfloat) * dmul) != 0) { memcpy(current, tmp, 4 * sizeof(GLfloat) * dmul); /* Given that we explicitly state size here, there is no need * for the COPY_CLEAN above, could just copy 16 bytes and be * done. The only problem is when Mesa accesses ctx->Current * directly. */ /* Size here is in components - not bytes */ vbo->currval[i].Size = exec->vtx.attrsz[i] / dmul; vbo->currval[i]._ElementSize = vbo->currval[i].Size * sizeof(GLfloat) * dmul; vbo->currval[i].Type = exec->vtx.attrtype[i]; vbo->currval[i].Integer = vbo_attrtype_to_integer_flag(exec->vtx.attrtype[i]); vbo->currval[i].Doubles = vbo_attrtype_to_double_flag(exec->vtx.attrtype[i]); /* This triggers rather too much recalculation of Mesa state * that doesn't get used (eg light positions). */ if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT && i <= VBO_ATTRIB_MAT_BACK_INDEXES) ctx->NewState |= _NEW_LIGHT; ctx->NewState |= _NEW_CURRENT_ATTRIB; } } /* Colormaterial -- this kindof sucks. */ if (ctx->Light.ColorMaterialEnabled && exec->vtx.attrsz[VBO_ATTRIB_COLOR0]) { _mesa_update_color_material(ctx, ctx->Current.Attrib[VBO_ATTRIB_COLOR0]); } }
/** * After playback, copy everything but the position from the * last vertex to the saved state */ static void _playback_copy_to_current(struct gl_context *ctx, const struct vbo_save_vertex_list *node) { struct vbo_context *vbo = vbo_context(ctx); fi_type vertex[VBO_ATTRIB_MAX * 4]; fi_type *data; GLbitfield64 mask; GLuint offset; if (node->current_size == 0) return; if (node->current_data) { data = node->current_data; } else { data = vertex; if (node->count) offset = (node->buffer_offset + (node->count-1) * node->vertex_size * sizeof(GLfloat)); else offset = node->buffer_offset; ctx->Driver.GetBufferSubData( ctx, offset, node->vertex_size * sizeof(GLfloat), data, node->vertex_store->bufferobj ); data += node->attrsz[0]; /* skip vertex position */ } mask = node->enabled & (~BITFIELD64_BIT(VBO_ATTRIB_POS)); while (mask) { const int i = u_bit_scan64(&mask); fi_type *current = (fi_type *)vbo->currval[i].Ptr; fi_type tmp[4]; assert(node->attrsz[i]); COPY_CLEAN_4V_TYPE_AS_UNION(tmp, node->attrsz[i], data, node->attrtype[i]); if (node->attrtype[i] != vbo->currval[i].Type || memcmp(current, tmp, 4 * sizeof(GLfloat)) != 0) { memcpy(current, tmp, 4 * sizeof(GLfloat)); vbo->currval[i].Size = node->attrsz[i]; vbo->currval[i]._ElementSize = vbo->currval[i].Size * sizeof(GLfloat); vbo->currval[i].Type = node->attrtype[i]; vbo->currval[i].Integer = vbo_attrtype_to_integer_flag(node->attrtype[i]); if (i >= VBO_ATTRIB_FIRST_MATERIAL && i <= VBO_ATTRIB_LAST_MATERIAL) ctx->NewState |= _NEW_LIGHT; ctx->NewState |= _NEW_CURRENT_ATTRIB; } data += node->attrsz[i]; } /* Colormaterial -- this kindof sucks. */ if (ctx->Light.ColorMaterialEnabled) { _mesa_update_color_material(ctx, ctx->Current.Attrib[VBO_ATTRIB_COLOR0]); } /* CurrentExecPrimitive */ if (node->prim_count) { const struct _mesa_prim *prim = &node->prim[node->prim_count - 1]; if (prim->end) ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; else ctx->Driver.CurrentExecPrimitive = prim->mode; } }
/** * Helper function to enable or disable state. * * \param ctx GL context. * \param cap the state to enable/disable * \param state whether to enable or disable the specified capability. * * Updates the current context and flushes the vertices as needed. For * capabilities associated with extensions it verifies that those extensions * are effectivly present before updating. Notifies the driver via * dd_function_table::Enable. */ void _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) { if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "%s %s (newstate is %x)\n", state ? "glEnable" : "glDisable", _mesa_lookup_enum_by_nr(cap), ctx->NewState); switch (cap) { case GL_ALPHA_TEST: if (ctx->Color.AlphaEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.AlphaEnabled = state; break; case GL_AUTO_NORMAL: if (ctx->Eval.AutoNormal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.AutoNormal = state; break; case GL_BLEND: { if (state != ctx->Color.BlendEnabled) { FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.BlendEnabled = state; } } break; #if FEATURE_userclip case GL_CLIP_DISTANCE0: case GL_CLIP_DISTANCE1: case GL_CLIP_DISTANCE2: case GL_CLIP_DISTANCE3: case GL_CLIP_DISTANCE4: case GL_CLIP_DISTANCE5: case GL_CLIP_DISTANCE6: case GL_CLIP_DISTANCE7: { const GLuint p = cap - GL_CLIP_DISTANCE0; if (p >= ctx->Const.MaxClipPlanes) goto invalid_enum_error; if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p)) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); if (state) { ctx->Transform.ClipPlanesEnabled |= (1 << p); _mesa_update_clip_plane(ctx, p); } else { ctx->Transform.ClipPlanesEnabled &= ~(1 << p); } } break; #endif case GL_COLOR_MATERIAL: if (ctx->Light.ColorMaterialEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); FLUSH_CURRENT(ctx, 0); ctx->Light.ColorMaterialEnabled = state; if (state) { _mesa_update_color_material( ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR] ); } break; case GL_CULL_FACE: if (ctx->Polygon.CullFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.CullFlag = state; break; case GL_DEPTH_TEST: if (ctx->Depth.Test == state) return; FLUSH_VERTICES(ctx, _NEW_DEPTH); ctx->Depth.Test = state; break; case GL_DITHER: if (ctx->Color.DitherFlag == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.DitherFlag = state; break; case GL_FOG: if (ctx->Fog.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_FOG); ctx->Fog.Enabled = state; break; case GL_LIGHT0: case GL_LIGHT1: case GL_LIGHT2: case GL_LIGHT3: case GL_LIGHT4: case GL_LIGHT5: case GL_LIGHT6: case GL_LIGHT7: if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; if (state) { insert_at_tail(&ctx->Light.EnabledList, &ctx->Light.Light[cap-GL_LIGHT0]); } else { remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); } break; case GL_LIGHTING: if (ctx->Light.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); ctx->Light.Enabled = state; if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; else ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; break; case GL_LINE_SMOOTH: if (ctx->Line.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_LINE); ctx->Line.SmoothFlag = state; ctx->_TriangleCaps ^= DD_LINE_SMOOTH; break; case GL_LINE_STIPPLE: if (ctx->Line.StippleFlag == state) return; FLUSH_VERTICES(ctx, _NEW_LINE); ctx->Line.StippleFlag = state; ctx->_TriangleCaps ^= DD_LINE_STIPPLE; break; case GL_INDEX_LOGIC_OP: if (ctx->Color.IndexLogicOpEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.IndexLogicOpEnabled = state; break; case GL_COLOR_LOGIC_OP: if (ctx->Color.ColorLogicOpEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.ColorLogicOpEnabled = state; break; case GL_MAP1_COLOR_4: if (ctx->Eval.Map1Color4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Color4 = state; break; case GL_MAP1_INDEX: if (ctx->Eval.Map1Index == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Index = state; break; case GL_MAP1_NORMAL: if (ctx->Eval.Map1Normal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Normal = state; break; case GL_MAP1_TEXTURE_COORD_1: if (ctx->Eval.Map1TextureCoord1 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord1 = state; break; case GL_MAP1_TEXTURE_COORD_2: if (ctx->Eval.Map1TextureCoord2 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord2 = state; break; case GL_MAP1_TEXTURE_COORD_3: if (ctx->Eval.Map1TextureCoord3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord3 = state; break; case GL_MAP1_TEXTURE_COORD_4: if (ctx->Eval.Map1TextureCoord4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord4 = state; break; case GL_MAP1_VERTEX_3: if (ctx->Eval.Map1Vertex3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Vertex3 = state; break; case GL_MAP1_VERTEX_4: if (ctx->Eval.Map1Vertex4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Vertex4 = state; break; case GL_MAP2_COLOR_4: if (ctx->Eval.Map2Color4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Color4 = state; break; case GL_MAP2_INDEX: if (ctx->Eval.Map2Index == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Index = state; break; case GL_MAP2_NORMAL: if (ctx->Eval.Map2Normal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Normal = state; break; case GL_MAP2_TEXTURE_COORD_1: if (ctx->Eval.Map2TextureCoord1 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord1 = state; break; case GL_MAP2_TEXTURE_COORD_2: if (ctx->Eval.Map2TextureCoord2 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord2 = state; break; case GL_MAP2_TEXTURE_COORD_3: if (ctx->Eval.Map2TextureCoord3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord3 = state; break; case GL_MAP2_TEXTURE_COORD_4: if (ctx->Eval.Map2TextureCoord4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord4 = state; break; case GL_MAP2_VERTEX_3: if (ctx->Eval.Map2Vertex3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Vertex3 = state; break; case GL_MAP2_VERTEX_4: if (ctx->Eval.Map2Vertex4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Vertex4 = state; break; case GL_NORMALIZE: if (ctx->Transform.Normalize == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.Normalize = state; break; case GL_POINT_SMOOTH: if (ctx->Point.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POINT); ctx->Point.SmoothFlag = state; ctx->_TriangleCaps ^= DD_POINT_SMOOTH; break; case GL_POLYGON_SMOOTH: if (ctx->Polygon.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.SmoothFlag = state; ctx->_TriangleCaps ^= DD_TRI_SMOOTH; break; case GL_POLYGON_STIPPLE: if (ctx->Polygon.StippleFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.StippleFlag = state; ctx->_TriangleCaps ^= DD_TRI_STIPPLE; break; case GL_POLYGON_OFFSET_POINT: if (ctx->Polygon.OffsetPoint == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetPoint = state; break; case GL_POLYGON_OFFSET_LINE: if (ctx->Polygon.OffsetLine == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetLine = state; break; case GL_POLYGON_OFFSET_FILL: if (ctx->Polygon.OffsetFill == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetFill = state; break; case GL_RESCALE_NORMAL_EXT: if (ctx->Transform.RescaleNormals == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.RescaleNormals = state; break; case GL_SCISSOR_TEST: if (ctx->Scissor.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_SCISSOR); ctx->Scissor.Enabled = state; break; case GL_STENCIL_TEST: if (ctx->Stencil.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_STENCIL); ctx->Stencil.Enabled = state; break; case GL_TEXTURE_1D: if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { return; } break; case GL_TEXTURE_2D: if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { return; } break; case GL_TEXTURE_GEN_S: case GL_TEXTURE_GEN_T: case GL_TEXTURE_GEN_R: case GL_TEXTURE_GEN_Q: { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); if (texUnit) { GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S); GLbitfield newenabled = texUnit->TexGenEnabled & ~coordBit; if (state) newenabled |= coordBit; if (texUnit->TexGenEnabled == newenabled) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); texUnit->TexGenEnabled = newenabled; } } break; #if FEATURE_ES1 case GL_TEXTURE_GEN_STR_OES: /* disable S, T, and R at the same time */ { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); if (texUnit) { GLuint newenabled = texUnit->TexGenEnabled & ~STR_BITS; if (state) newenabled |= STR_BITS; if (texUnit->TexGenEnabled == newenabled) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); texUnit->TexGenEnabled = newenabled; } } break; #endif /* client-side state */ case GL_VERTEX_ARRAY: case GL_NORMAL_ARRAY: case GL_COLOR_ARRAY: case GL_INDEX_ARRAY: case GL_TEXTURE_COORD_ARRAY: case GL_EDGE_FLAG_ARRAY: case GL_FOG_COORDINATE_ARRAY_EXT: case GL_SECONDARY_COLOR_ARRAY_EXT: case GL_POINT_SIZE_ARRAY_OES: client_state( ctx, cap, state ); return; /* GL_ARB_texture_cube_map */ case GL_TEXTURE_CUBE_MAP_ARB: CHECK_EXTENSION(ARB_texture_cube_map, cap); if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { return; } break; /* GL_ARB_multisample */ case GL_MULTISAMPLE_ARB: if (ctx->Multisample.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.Enabled = state; break; case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: if (ctx->Multisample.SampleAlphaToCoverage == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleAlphaToCoverage = state; break; case GL_SAMPLE_ALPHA_TO_ONE_ARB: if (ctx->Multisample.SampleAlphaToOne == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleAlphaToOne = state; break; case GL_SAMPLE_COVERAGE_ARB: if (ctx->Multisample.SampleCoverage == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleCoverage = state; break; case GL_SAMPLE_COVERAGE_INVERT_ARB: if (ctx->Multisample.SampleCoverageInvert == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleCoverageInvert = state; break; /* GL_IBM_rasterpos_clip */ case GL_RASTER_POSITION_UNCLIPPED_IBM: CHECK_EXTENSION(IBM_rasterpos_clip, cap); if (ctx->Transform.RasterPositionUnclipped == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.RasterPositionUnclipped = state; break; /* GL_NV_point_sprite */ case GL_POINT_SPRITE_NV: CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); if (ctx->Point.PointSprite == state) return; FLUSH_VERTICES(ctx, _NEW_POINT); ctx->Point.PointSprite = state; break; /* GL_EXT_depth_bounds_test */ case GL_DEPTH_BOUNDS_TEST_EXT: CHECK_EXTENSION(EXT_depth_bounds_test, cap); if (ctx->Depth.BoundsTest == state) return; FLUSH_VERTICES(ctx, _NEW_DEPTH); ctx->Depth.BoundsTest = state; break; default: goto invalid_enum_error; } if (ctx->Driver.Enable) { ctx->Driver.Enable( ctx, cap, state ); } return; invalid_enum_error: _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", state ? "Enable" : "Disable", cap); }