-/* $Id: t_pipeline.c,v 1.11 2001/01/29 20:47:39 keithw Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 5.1
*
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
* 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 <keithw@valinux.com>
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
*/
#include "glheader.h"
#include "context.h"
-#include "mem.h"
-#include "mmath.h"
+#include "imports.h"
#include "state.h"
#include "mtypes.h"
#include "t_pipeline.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;
+ struct tnl_pipeline *pipe = &tnl->pipeline;
GLuint i;
ASSERT(pipe->nr_stages == 0);
pipe->build_state_trigger |= pipe->stages[i].check_state;
}
+ MEMSET( &pipe->stages[i], 0, sizeof( **stages ));
+
pipe->nr_stages = i;
}
TNLcontext *tnl = TNL_CONTEXT(ctx);
GLuint i;
- for (i = 0 ; i < tnl->pipeline.nr_stages ; i++)
+ for (i = 0 ; i < tnl->pipeline.nr_stages ; i++)
tnl->pipeline.stages[i].destroy( &tnl->pipeline.stages[i] );
tnl->pipeline.nr_stages = 0;
void _tnl_validate_pipeline( GLcontext *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct gl_pipeline *pipe = &tnl->pipeline;
- struct gl_pipeline_stage *s = pipe->stages;
+ struct tnl_pipeline *pipe = &tnl->pipeline;
+ struct tnl_pipeline_stage *s = pipe->stages;
GLuint newstate = pipe->build_state_changes;
GLuint generated = 0;
- GLuint i;
GLuint changed_inputs = 0;
pipe->inputs = 0;
pipe->build_state_changes = 0;
- for (i = pipe->nr_stages+1 ; --i ; s++) {
+ for ( ; s->check ; s++) {
s->changed_inputs |= s->inputs & changed_inputs;
-
- if (s->check_state & newstate) {
+
+ 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
+ else
s->check(ctx, s);
}
if (s->active) {
pipe->inputs |= s->inputs & ~generated;
generated |= s->outputs;
- }
+ }
}
}
void _tnl_run_pipeline( GLcontext *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct gl_pipeline *pipe = &tnl->pipeline;
- struct gl_pipeline_stage *s = pipe->stages;
+ struct tnl_pipeline *pipe = &tnl->pipeline;
+ struct tnl_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;
+#ifdef HAVE_FAST_MATH
unsigned short __tmp;
+#endif
+
+ if (!tnl->vb.Count)
+ return;
+
+ pipe->run_state_changes = 0;
+ pipe->run_input_changes = 0;
/* Done elsewhere.
*/
ASSERT(pipe->build_state_changes == 0);
+#ifdef HAVE_FAST_MATH
START_FAST_MATH(__tmp);
+#endif
/* 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.
+ * using this value for recalculation. Inactive stages have their
+ * state and inputs examined to try to keep cached data alive over
+ * state-changes.
*/
- for (i = pipe->nr_stages+1 ; --i ; s++) {
+ for ( ; s->run ; s++) {
s->changed_inputs |= s->inputs & changed_inputs;
- if (s->run_state & changed_state) {
-/* changed_inputs |= s->check(ctx, s); */
+ if (s->run_state & changed_state)
s->changed_inputs = s->inputs;
- }
- if (s->active) {
- if (running) {
- if (s->changed_inputs)
- changed_inputs |= s->outputs;
+ if (s->active && running) {
+ if (s->changed_inputs)
+ changed_inputs |= s->outputs;
-/* fprintf(stderr, "run %s\n", s->name); */
- running = s->run( ctx, s );
- }
+ running = s->run( ctx, s );
+
+ s->changed_inputs = 0;
}
}
- END_FAST_MATH(__tmp);
- pipe->run_state_changes = 0;
- pipe->run_input_changes = 0;
+#ifdef HAVE_FAST_MATH
+ END_FAST_MATH(__tmp);
+#endif
}
* 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
*
* - 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_update_material_stage,
- &_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_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_tnl_point_attenuation_stage,
+#if defined(FEATURE_NV_vertex_program) || defined(FEATURE_ARB_vertex_program)
+ &_tnl_vertex_program_stage,
+#endif
&_tnl_render_stage,
0
};
-