X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Ftnl%2Ft_pipeline.c;h=357ef1e24b5bf4914fe2b3e3b4e31d86eb314ae3;hb=205e0e3e38b99c2fb0298755d99a38f111f0b96f;hp=f1c5a255a5da65a8285926bee29697e13db8eb5c;hpb=2448fc7deeaa870d879de17158f243f239c05b15;p=mesa.git diff --git a/src/mesa/tnl/t_pipeline.c b/src/mesa/tnl/t_pipeline.c index f1c5a255a5d..357ef1e24b5 100644 --- a/src/mesa/tnl/t_pipeline.c +++ b/src/mesa/tnl/t_pipeline.c @@ -1,10 +1,8 @@ -/* $Id: t_pipeline.c,v 1.13 2001/02/16 00:35:35 keithw Exp $ */ - /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 6.5.3 * - * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -23,47 +21,39 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * Author: - * Keith Whitwell + * Authors: + * Keith Whitwell */ -#include "glheader.h" -#include "context.h" -#include "mem.h" -#include "mmath.h" -#include "state.h" -#include "mtypes.h" - -#include "math/m_translate.h" -#include "math/m_xform.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/imports.h" +#include "main/state.h" +#include "main/mtypes.h" #include "t_context.h" #include "t_pipeline.h" +#include "t_vp_build.h" +#include "t_vertex.h" - -void _tnl_install_pipeline( GLcontext *ctx, - const struct gl_pipeline_stage **stages ) +void _tnl_install_pipeline( GLcontext *ctx, + const struct tnl_pipeline_stage **stages ) { TNLcontext *tnl = TNL_CONTEXT(ctx); - struct gl_pipeline *pipe = &tnl->pipeline; GLuint i; - ASSERT(pipe->nr_stages == 0); - - pipe->run_state_changes = ~0; - pipe->run_input_changes = ~0; - pipe->build_state_changes = ~0; - pipe->build_state_trigger = 0; - pipe->inputs = 0; + tnl->pipeline.new_state = ~0; /* Create a writeable copy of each stage. */ for (i = 0 ; i < MAX_PIPELINE_STAGES && stages[i] ; i++) { - MEMCPY( &pipe->stages[i], stages[i], sizeof( **stages )); - pipe->build_state_trigger |= pipe->stages[i].check_state; + struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i]; + MEMCPY(s, stages[i], sizeof(*s)); + if (s->create) + s->create(ctx, s); } - pipe->nr_stages = i; + tnl->pipeline.nr_stages = i; } void _tnl_destroy_pipeline( GLcontext *ctx ) @@ -71,101 +61,105 @@ void _tnl_destroy_pipeline( GLcontext *ctx ) TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint i; - for (i = 0 ; i < tnl->pipeline.nr_stages ; i++) - tnl->pipeline.stages[i].destroy( &tnl->pipeline.stages[i] ); + for (i = 0 ; i < tnl->pipeline.nr_stages ; i++) { + struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i]; + if (s->destroy) + s->destroy(s); + } tnl->pipeline.nr_stages = 0; } -/* TODO: merge validate with run. - */ -void _tnl_validate_pipeline( GLcontext *ctx ) + + +static GLuint check_input_changes( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); - struct gl_pipeline *pipe = &tnl->pipeline; - struct gl_pipeline_stage *s = pipe->stages; - GLuint newstate = pipe->build_state_changes; - GLuint generated = 0; GLuint i; - GLuint changed_inputs = 0; + + for (i = 0; i <= _TNL_LAST_MAT; i++) { + if (tnl->vb.AttribPtr[i]->size != tnl->pipeline.last_attrib_size[i] || + tnl->vb.AttribPtr[i]->stride != tnl->pipeline.last_attrib_stride[i]) { + tnl->pipeline.last_attrib_size[i] = tnl->vb.AttribPtr[i]->size; + tnl->pipeline.last_attrib_stride[i] = tnl->vb.AttribPtr[i]->stride; + tnl->pipeline.input_changes |= 1<inputs = 0; - pipe->build_state_changes = 0; + if (tnl->pipeline.input_changes && + tnl->Driver.NotifyInputChanges) + tnl->Driver.NotifyInputChanges( ctx, tnl->pipeline.input_changes ); - for (i = pipe->nr_stages+1 ; --i ; s++) { + return tnl->pipeline.input_changes; +} - s->changed_inputs |= s->inputs & changed_inputs; - - if (s->check_state & newstate) { - if (s->active) { - GLuint old_outputs = s->outputs; - s->check(ctx, s); - if (!s->active) - changed_inputs |= old_outputs; - } - else - s->check(ctx, s); - } - if (s->active) { - pipe->inputs |= s->inputs & ~generated; - generated |= s->outputs; - } +static GLuint check_output_changes( GLcontext *ctx ) +{ +#if 0 + TNLcontext *tnl = TNL_CONTEXT(ctx); + + for (i = 0; i < VERT_RESULT_MAX; i++) { + if (tnl->vb.ResultPtr[i]->size != tnl->last_result_size[i] || + tnl->vb.ResultPtr[i]->stride != tnl->last_result_stride[i]) { + tnl->last_result_size[i] = tnl->vb.ResultPtr[i]->size; + tnl->last_result_stride[i] = tnl->vb.ResultPtr[i]->stride; + tnl->pipeline.output_changes |= 1<pipeline.output_changes) + tnl->Driver.NotifyOutputChanges( ctx, tnl->pipeline.output_changes ); + + return tnl->pipeline.output_changes; +#else + return ~0; +#endif +} void _tnl_run_pipeline( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); - struct gl_pipeline *pipe = &tnl->pipeline; - struct gl_pipeline_stage *s = pipe->stages; - GLuint changed_state = pipe->run_state_changes; - GLuint changed_inputs = pipe->run_input_changes; - GLboolean running = GL_TRUE; - GLuint i; unsigned short __tmp; + GLuint i; - /* Done elsewhere. - */ - ASSERT(pipe->build_state_changes == 0); + if (!tnl->vb.Count) + return; - START_FAST_MATH(__tmp); - if (ctx->Driver.PipelineStart) - ctx->Driver.PipelineStart( ctx ); - - /* If something changes in the pipeline, tag all subsequent stages - * using this value for recalculation. - * - * Even inactive stages have their state and inputs examined to try - * to keep cached data alive over state-changes. + /* Check for changed input sizes or change in stride to/from zero + * (ie const or non-const). */ - for (i = pipe->nr_stages+1 ; --i ; s++) { - s->changed_inputs |= s->inputs & changed_inputs; - - if (s->run_state & changed_state) { -/* changed_inputs |= s->check(ctx, s); */ - s->changed_inputs = s->inputs; + if (check_input_changes( ctx ) || tnl->pipeline.new_state) { + if (ctx->VertexProgram._MaintainTnlProgram) + _tnl_UpdateFixedFunctionProgram( ctx ); + + for (i = 0; i < tnl->pipeline.nr_stages ; i++) { + struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i]; + if (s->validate) + s->validate( ctx, s ); } + + tnl->pipeline.new_state = 0; + tnl->pipeline.input_changes = 0; + + /* Pipeline can only change its output in response to either a + * statechange or an input size/stride change. No other changes + * are allowed. + */ + if (check_output_changes( ctx )) + _tnl_notify_pipeline_output_change( ctx ); + } - if (s->active) { - if (running) { - if (s->changed_inputs) - changed_inputs |= s->outputs; + START_FAST_MATH(__tmp); -/* fprintf(stderr, "run %s\n", s->name); */ - running = s->run( ctx, s ); - } - } + for (i = 0; i < tnl->pipeline.nr_stages ; i++) { + struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i]; + if (!s->run( ctx, s )) + break; } - if (ctx->Driver.PipelineFinish) - ctx->Driver.PipelineFinish( ctx ); END_FAST_MATH(__tmp); - - pipe->run_state_changes = 0; - pipe->run_input_changes = 0; } @@ -174,9 +168,9 @@ void _tnl_run_pipeline( GLcontext *ctx ) * simple hardware rasterizers. For customization, I don't recommend * tampering with the internals of these stages in the way that * drivers did in Mesa 3.4. These stages are basically black boxes, - * and should be left intact. + * and should be left intact. * - * To customize the pipeline, consider: + * To customize the pipeline, consider: * * - removing redundant stages (making sure that the software rasterizer * can cope with this on fallback paths). An example is fog @@ -192,24 +186,30 @@ void _tnl_run_pipeline( GLcontext *ctx ) * * - inserting optimized (but specialized) stages ahead of the * general-purpose fallback implementation. For example, the old - * fastpath mechanism, which only works when the VERT_ELT input is + * fastpath mechanism, which only works when the VB->Elts input is * available, can be duplicated by placing the fastpath stage at the * head of this pipeline. Such specialized stages are currently * constrained to have no outputs (ie. they must either finish the * * pipeline by returning GL_FALSE from run(), or do nothing). * * Some work can be done to lift some of the restrictions in the final - * case, if it becomes necessary to do so. + * case, if it becomes necessary to do so. */ -const struct gl_pipeline_stage *_tnl_default_pipeline[] = { - &_tnl_vertex_transform_stage, - &_tnl_normal_transform_stage, - &_tnl_lighting_stage, - &_tnl_fog_coordinate_stage, - &_tnl_texgen_stage, - &_tnl_texture_transform_stage, - &_tnl_point_attenuation_stage, +const struct tnl_pipeline_stage *_tnl_default_pipeline[] = { + &_tnl_vertex_transform_stage, + &_tnl_normal_transform_stage, + &_tnl_lighting_stage, + &_tnl_texgen_stage, + &_tnl_texture_transform_stage, + &_tnl_point_attenuation_stage, + &_tnl_vertex_program_stage, + &_tnl_fog_coordinate_stage, &_tnl_render_stage, - 0 + NULL }; +const struct tnl_pipeline_stage *_tnl_vp_pipeline[] = { + &_tnl_vertex_program_stage, + &_tnl_render_stage, + NULL +};