1 | /* $Id: pipeline.c,v 1.3 2000-05-23 20:40:43 jeroen Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Mesa 3-D graphics library
|
---|
5 | * Version: 3.3
|
---|
6 | *
|
---|
7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
10 | * copy of this software and associated documentation files (the "Software"),
|
---|
11 | * to deal in the Software without restriction, including without limitation
|
---|
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
13 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
14 | * Software is furnished to do so, subject to the following conditions:
|
---|
15 | *
|
---|
16 | * The above copyright notice and this permission notice shall be included
|
---|
17 | * in all copies or substantial portions of the Software.
|
---|
18 | *
|
---|
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
25 | */
|
---|
26 |
|
---|
27 | /* Dynamic pipelines, support for CVA.
|
---|
28 | * Copyright (C) 1999 Keith Whitwell.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #include "glheader.h"
|
---|
32 | #include "bbox.h"
|
---|
33 | #include "clip.h"
|
---|
34 | #include "types.h"
|
---|
35 | #include "context.h"
|
---|
36 | #include "cva.h"
|
---|
37 | #include "pipeline.h"
|
---|
38 | #include "vbcull.h"
|
---|
39 | #include "vbindirect.h"
|
---|
40 | #include "vbrender.h"
|
---|
41 | #include "vbxform.h"
|
---|
42 | #include "fog.h"
|
---|
43 | #include "light.h"
|
---|
44 | #include "mmath.h"
|
---|
45 | #include "shade.h"
|
---|
46 | #include "stages.h"
|
---|
47 | #include "translate.h"
|
---|
48 | #include "state.h"
|
---|
49 | #include "xform.h"
|
---|
50 | #include "mem.h"
|
---|
51 |
|
---|
52 | #ifndef MESA_VERBOSE
|
---|
53 | int MESA_VERBOSE = 0
|
---|
54 | /* | VERBOSE_PIPELINE */
|
---|
55 | /* | VERBOSE_IMMEDIATE */
|
---|
56 | /* | VERBOSE_VARRAY */
|
---|
57 | /* | VERBOSE_TEXTURE */
|
---|
58 | /* | VERBOSE_API */
|
---|
59 | /* | VERBOSE_DRIVER */
|
---|
60 | /* | VERBOSE_STATE */
|
---|
61 | /* | VERBOSE_CULL */
|
---|
62 | /* | VERBOSE_DISPLAY_LIST */
|
---|
63 | /* | VERBOSE_LIGHTING */
|
---|
64 | ;
|
---|
65 | #endif
|
---|
66 |
|
---|
67 | #ifndef MESA_DEBUG_FLAGS
|
---|
68 | int MESA_DEBUG_FLAGS = 0
|
---|
69 | /* | DEBUG_ALWAYS_FLUSH */
|
---|
70 | ;
|
---|
71 | #endif
|
---|
72 |
|
---|
73 |
|
---|
74 |
|
---|
75 | void gl_print_pipe_ops( const char *msg, GLuint flags )
|
---|
76 | {
|
---|
77 | fprintf(stderr,
|
---|
78 | "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s\n",
|
---|
79 | msg,
|
---|
80 | flags,
|
---|
81 | (flags & PIPE_OP_CVA_PREPARE) ? "cva-prepare, " : "",
|
---|
82 | (flags & PIPE_OP_VERT_XFORM) ? "vert-xform, " : "",
|
---|
83 | (flags & PIPE_OP_NORM_XFORM) ? "norm-xform, " : "",
|
---|
84 | (flags & PIPE_OP_LIGHT) ? "light, " : "",
|
---|
85 | (flags & PIPE_OP_FOG) ? "fog, " : "",
|
---|
86 | (flags & PIPE_OP_TEX0) ? "tex-0, " : "",
|
---|
87 | (flags & PIPE_OP_TEX1) ? "tex-1, " : "",
|
---|
88 | (flags & PIPE_OP_RAST_SETUP_0) ? "rast-0, " : "",
|
---|
89 | (flags & PIPE_OP_RAST_SETUP_1) ? "rast-1, " : "",
|
---|
90 | (flags & PIPE_OP_RENDER) ? "render, " : "");
|
---|
91 |
|
---|
92 | }
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 | /* Have to reset only those parts of the vb which are being recalculated.
|
---|
97 | */
|
---|
98 | void gl_reset_cva_vb( struct vertex_buffer *VB, GLuint stages )
|
---|
99 | {
|
---|
100 | GLcontext *ctx = VB->ctx;
|
---|
101 |
|
---|
102 | if (MESA_VERBOSE&VERBOSE_PIPELINE)
|
---|
103 | gl_print_pipe_ops( "reset cva vb", stages );
|
---|
104 |
|
---|
105 | if (ctx->Driver.ResetCvaVB)
|
---|
106 | ctx->Driver.ResetCvaVB( VB, stages );
|
---|
107 |
|
---|
108 | if (stages & PIPE_OP_VERT_XFORM)
|
---|
109 | {
|
---|
110 | if (VB->ClipOrMask & CLIP_USER_BIT)
|
---|
111 | MEMSET(VB->UserClipMask, 0, VB->Count);
|
---|
112 |
|
---|
113 | VB->ClipOrMask = 0;
|
---|
114 | VB->ClipAndMask = CLIP_ALL_BITS;
|
---|
115 | VB->CullMode = 0;
|
---|
116 | VB->CullFlag[0] = VB->CullFlag[1] = 0;
|
---|
117 | VB->Culled = 0;
|
---|
118 | }
|
---|
119 |
|
---|
120 | if (stages & PIPE_OP_NORM_XFORM) {
|
---|
121 | VB->NormalPtr = &ctx->CVA.v.Normal;
|
---|
122 | }
|
---|
123 |
|
---|
124 | if (stages & PIPE_OP_LIGHT)
|
---|
125 | {
|
---|
126 | VB->ColorPtr = VB->Color[0] = VB->Color[1] = &ctx->CVA.v.Color;
|
---|
127 | VB->IndexPtr = VB->Index[0] = VB->Index[1] = &ctx->CVA.v.Index;
|
---|
128 | }
|
---|
129 | else if (stages & PIPE_OP_FOG)
|
---|
130 | {
|
---|
131 | if (ctx->Light.Enabled) {
|
---|
132 | VB->Color[0] = VB->LitColor[0];
|
---|
133 | VB->Color[1] = VB->LitColor[1];
|
---|
134 | VB->Index[0] = VB->LitIndex[0];
|
---|
135 | VB->Index[1] = VB->LitIndex[1];
|
---|
136 | } else {
|
---|
137 | VB->Color[0] = VB->Color[1] = &ctx->CVA.v.Color;
|
---|
138 | VB->Index[0] = VB->Index[1] = &ctx->CVA.v.Index;
|
---|
139 | }
|
---|
140 | VB->ColorPtr = VB->Color[0];
|
---|
141 | VB->IndexPtr = VB->Index[0];
|
---|
142 | }
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 |
|
---|
147 |
|
---|
148 | static const char *pipeline_name[3] = {
|
---|
149 | 0,
|
---|
150 | "Immediate",
|
---|
151 | "CVA Precalc",
|
---|
152 | };
|
---|
153 |
|
---|
154 |
|
---|
155 |
|
---|
156 | static void pipeline_ctr( struct gl_pipeline *p, GLcontext *ctx, GLuint type )
|
---|
157 | {
|
---|
158 | GLuint i;
|
---|
159 | (void) ctx;
|
---|
160 |
|
---|
161 | p->state_change = 0;
|
---|
162 | p->cva_state_change = 0;
|
---|
163 | p->inputs = 0;
|
---|
164 | p->outputs = 0;
|
---|
165 | p->type = type;
|
---|
166 | p->ops = 0;
|
---|
167 |
|
---|
168 | for (i = 0 ; i < gl_default_nr_stages ; i++)
|
---|
169 | p->state_change |= gl_default_pipeline[i].state_change;
|
---|
170 | }
|
---|
171 |
|
---|
172 |
|
---|
173 | void gl_pipeline_init( GLcontext *ctx )
|
---|
174 | {
|
---|
175 | if (ctx->Driver.RegisterPipelineStages)
|
---|
176 | ctx->NrPipelineStages =
|
---|
177 | ctx->Driver.RegisterPipelineStages( ctx->PipelineStage,
|
---|
178 | gl_default_pipeline,
|
---|
179 | gl_default_nr_stages );
|
---|
180 | else
|
---|
181 | {
|
---|
182 | MEMCPY( ctx->PipelineStage,
|
---|
183 | gl_default_pipeline,
|
---|
184 | sizeof(*gl_default_pipeline) * gl_default_nr_stages );
|
---|
185 |
|
---|
186 | ctx->NrPipelineStages = gl_default_nr_stages;
|
---|
187 | }
|
---|
188 |
|
---|
189 | pipeline_ctr( &ctx->CVA.elt, ctx, PIPE_IMMEDIATE);
|
---|
190 | pipeline_ctr( &ctx->CVA.pre, ctx, PIPE_PRECALC );
|
---|
191 | }
|
---|
192 |
|
---|
193 |
|
---|
194 |
|
---|
195 |
|
---|
196 |
|
---|
197 |
|
---|
198 | #define MINIMAL_VERT_DATA (VERT_DATA&~(VERT_TEX0_4|VERT_TEX1_4|VERT_EVAL_ANY))
|
---|
199 |
|
---|
200 | #define VERT_CURRENT_DATA (VERT_TEX0_1234|VERT_TEX1_1234|VERT_RGBA| \
|
---|
201 | VERT_INDEX|VERT_EDGE|VERT_NORM| \
|
---|
202 | VERT_MATERIAL)
|
---|
203 |
|
---|
204 | /* Called prior to every recomputation of the CVA precalc data, except where
|
---|
205 | * the driver is able to calculate the pipeline unassisted.
|
---|
206 | */
|
---|
207 | static void build_full_precalc_pipeline( GLcontext *ctx )
|
---|
208 | {
|
---|
209 | struct gl_pipeline_stage *pipeline = ctx->PipelineStage;
|
---|
210 | struct gl_cva *cva = &ctx->CVA;
|
---|
211 | struct gl_pipeline *pre = &cva->pre;
|
---|
212 | struct gl_pipeline_stage **stages = pre->stages;
|
---|
213 | GLuint i;
|
---|
214 | GLuint newstate = pre->new_state;
|
---|
215 | GLuint changed_ops = 0;
|
---|
216 | GLuint oldoutputs = pre->outputs;
|
---|
217 | GLuint oldinputs = pre->inputs;
|
---|
218 | GLuint fallback = (VERT_CURRENT_DATA & ctx->Current.Flag &
|
---|
219 | ~ctx->Array.Summary);
|
---|
220 | GLuint changed_outputs = (ctx->Array.NewArrayState |
|
---|
221 | (fallback & cva->orflag));
|
---|
222 | GLuint available = fallback | ctx->Array.Flags;
|
---|
223 |
|
---|
224 | pre->cva_state_change = 0;
|
---|
225 | pre->ops = 0;
|
---|
226 | pre->outputs = 0;
|
---|
227 | pre->inputs = 0;
|
---|
228 | pre->forbidden_inputs = 0;
|
---|
229 | pre->fallback = 0;
|
---|
230 |
|
---|
231 | if (ctx->Array.Summary & VERT_ELT)
|
---|
232 | cva->orflag &= VERT_MATERIAL;
|
---|
233 |
|
---|
234 | cva->orflag &= ~(ctx->Array.Summary & ~VERT_OBJ_ANY);
|
---|
235 | available &= ~cva->orflag;
|
---|
236 |
|
---|
237 | pre->outputs = available;
|
---|
238 | pre->inputs = available;
|
---|
239 |
|
---|
240 | if (MESA_VERBOSE & VERBOSE_PIPELINE) {
|
---|
241 | fprintf(stderr, ": Rebuild pipeline\n");
|
---|
242 | gl_print_vert_flags("orflag", cva->orflag);
|
---|
243 | }
|
---|
244 |
|
---|
245 |
|
---|
246 |
|
---|
247 | /* If something changes in the pipeline, tag all subsequent stages
|
---|
248 | * using this value for recalcuation. Also used to build the full
|
---|
249 | * pipeline by setting newstate and newinputs to ~0.
|
---|
250 | *
|
---|
251 | * Because all intermediate values are buffered, the new inputs
|
---|
252 | * are enough to fully specify what needs to be calculated, and a
|
---|
253 | * single pass identifies all stages requiring recalculation.
|
---|
254 | */
|
---|
255 | for (i = 0 ; i < ctx->NrPipelineStages ; i++)
|
---|
256 | {
|
---|
257 | pipeline[i].check(ctx, &pipeline[i]);
|
---|
258 |
|
---|
259 | if (pipeline[i].type & PIPE_PRECALC)
|
---|
260 | {
|
---|
261 | if ((newstate & pipeline[i].cva_state_change) ||
|
---|
262 | (changed_outputs & pipeline[i].inputs) ||
|
---|
263 | !pipeline[i].inputs)
|
---|
264 | {
|
---|
265 | changed_ops |= pipeline[i].ops;
|
---|
266 | changed_outputs |= pipeline[i].outputs;
|
---|
267 | pipeline[i].active &= ~PIPE_PRECALC;
|
---|
268 |
|
---|
269 | if ((pipeline[i].inputs & ~available) == 0 &&
|
---|
270 | (pipeline[i].ops & pre->ops) == 0)
|
---|
271 | {
|
---|
272 | pipeline[i].active |= PIPE_PRECALC;
|
---|
273 | *stages++ = &pipeline[i];
|
---|
274 | }
|
---|
275 | }
|
---|
276 |
|
---|
277 | /* Incompatible with multiple stages structs implementing
|
---|
278 | * the same stage.
|
---|
279 | */
|
---|
280 | available &= ~pipeline[i].outputs;
|
---|
281 | pre->outputs &= ~pipeline[i].outputs;
|
---|
282 |
|
---|
283 | if (pipeline[i].active & PIPE_PRECALC) {
|
---|
284 | pre->ops |= pipeline[i].ops;
|
---|
285 | pre->outputs |= pipeline[i].outputs;
|
---|
286 | available |= pipeline[i].outputs;
|
---|
287 | pre->forbidden_inputs |= pipeline[i].pre_forbidden_inputs;
|
---|
288 | }
|
---|
289 | }
|
---|
290 | else if (pipeline[i].active & PIPE_PRECALC)
|
---|
291 | {
|
---|
292 | pipeline[i].active &= ~PIPE_PRECALC;
|
---|
293 | changed_outputs |= pipeline[i].outputs;
|
---|
294 | changed_ops |= pipeline[i].ops;
|
---|
295 | }
|
---|
296 | }
|
---|
297 |
|
---|
298 | *stages = 0;
|
---|
299 |
|
---|
300 | pre->new_outputs = pre->outputs & (changed_outputs | ~oldoutputs);
|
---|
301 | pre->new_inputs = pre->inputs & ~oldinputs;
|
---|
302 | pre->fallback = pre->inputs & fallback;
|
---|
303 | pre->forbidden_inputs |= pre->inputs & fallback;
|
---|
304 |
|
---|
305 | pre->changed_ops = changed_ops;
|
---|
306 |
|
---|
307 | if (ctx->Driver.OptimizePrecalcPipeline)
|
---|
308 | ctx->Driver.OptimizePrecalcPipeline( ctx, pre );
|
---|
309 | }
|
---|
310 |
|
---|
311 | void gl_build_precalc_pipeline( GLcontext *ctx )
|
---|
312 | {
|
---|
313 | struct gl_pipeline *pre = &ctx->CVA.pre;
|
---|
314 | struct gl_pipeline *elt = &ctx->CVA.elt;
|
---|
315 |
|
---|
316 | if (!ctx->Driver.BuildPrecalcPipeline ||
|
---|
317 | !ctx->Driver.BuildPrecalcPipeline( ctx ))
|
---|
318 | build_full_precalc_pipeline( ctx );
|
---|
319 |
|
---|
320 | pre->data_valid = 0;
|
---|
321 | pre->pipeline_valid = 1;
|
---|
322 | elt->pipeline_valid = 0;
|
---|
323 |
|
---|
324 | ctx->CVA.orflag = 0;
|
---|
325 |
|
---|
326 | if (MESA_VERBOSE&VERBOSE_PIPELINE)
|
---|
327 | gl_print_pipeline( ctx, pre );
|
---|
328 | }
|
---|
329 |
|
---|
330 |
|
---|
331 | static void build_full_immediate_pipeline( GLcontext *ctx )
|
---|
332 | {
|
---|
333 | struct gl_pipeline_stage *pipeline = ctx->PipelineStage;
|
---|
334 | struct gl_cva *cva = &ctx->CVA;
|
---|
335 | struct gl_pipeline *pre = &cva->pre;
|
---|
336 | struct gl_pipeline *elt = &cva->elt;
|
---|
337 | struct gl_pipeline_stage **stages = elt->stages;
|
---|
338 | GLuint i;
|
---|
339 | GLuint newstate = elt->new_state;
|
---|
340 | GLuint active_ops = 0;
|
---|
341 | GLuint available = cva->orflag | MINIMAL_VERT_DATA;
|
---|
342 | GLuint generated = 0;
|
---|
343 | GLuint is_elt = 0;
|
---|
344 |
|
---|
345 | if (pre->data_valid && ctx->CompileCVAFlag) {
|
---|
346 | is_elt = 1;
|
---|
347 | active_ops = cva->pre.ops;
|
---|
348 | available |= pre->outputs | VERT_PRECALC_DATA;
|
---|
349 | }
|
---|
350 |
|
---|
351 |
|
---|
352 | elt->outputs = 0; /* not used */
|
---|
353 | elt->inputs = 0;
|
---|
354 |
|
---|
355 | for (i = 0 ; i < ctx->NrPipelineStages ; i++) {
|
---|
356 | pipeline[i].active &= ~PIPE_IMMEDIATE;
|
---|
357 |
|
---|
358 | if ((pipeline[i].state_change & newstate) ||
|
---|
359 | (pipeline[i].elt_forbidden_inputs & available))
|
---|
360 | {
|
---|
361 | pipeline[i].check(ctx, &pipeline[i]);
|
---|
362 | }
|
---|
363 |
|
---|
364 | if ((pipeline[i].type & PIPE_IMMEDIATE) &&
|
---|
365 | (pipeline[i].ops & active_ops) == 0 &&
|
---|
366 | (pipeline[i].elt_forbidden_inputs & available) == 0
|
---|
367 | )
|
---|
368 | {
|
---|
369 | if (pipeline[i].inputs & ~available)
|
---|
370 | elt->forbidden_inputs |= pipeline[i].inputs & ~available;
|
---|
371 | else
|
---|
372 | {
|
---|
373 | elt->inputs |= pipeline[i].inputs & ~generated;
|
---|
374 | elt->forbidden_inputs |= pipeline[i].elt_forbidden_inputs;
|
---|
375 | pipeline[i].active |= PIPE_IMMEDIATE;
|
---|
376 | *stages++ = &pipeline[i];
|
---|
377 | generated |= pipeline[i].outputs;
|
---|
378 | available |= pipeline[i].outputs;
|
---|
379 | active_ops |= pipeline[i].ops;
|
---|
380 | }
|
---|
381 | }
|
---|
382 | }
|
---|
383 |
|
---|
384 | *stages = 0;
|
---|
385 |
|
---|
386 | elt->copy_transformed_data = 1;
|
---|
387 | elt->replay_copied_vertices = 0;
|
---|
388 |
|
---|
389 | if (is_elt) {
|
---|
390 | cva->merge = elt->inputs & pre->outputs;
|
---|
391 | elt->ops = active_ops & ~pre->ops;
|
---|
392 | }
|
---|
393 | }
|
---|
394 |
|
---|
395 |
|
---|
396 |
|
---|
397 | void gl_build_immediate_pipeline( GLcontext *ctx )
|
---|
398 | {
|
---|
399 | struct gl_pipeline *elt = &ctx->CVA.elt;
|
---|
400 |
|
---|
401 | if (!ctx->Driver.BuildEltPipeline ||
|
---|
402 | !ctx->Driver.BuildEltPipeline( ctx )) {
|
---|
403 | build_full_immediate_pipeline( ctx );
|
---|
404 | }
|
---|
405 |
|
---|
406 | elt->pipeline_valid = 1;
|
---|
407 | ctx->CVA.orflag = 0;
|
---|
408 |
|
---|
409 | if (MESA_VERBOSE&VERBOSE_PIPELINE)
|
---|
410 | gl_print_pipeline( ctx, elt );
|
---|
411 | }
|
---|
412 |
|
---|
413 | #define INTERESTED ~(NEW_DRIVER_STATE|NEW_CLIENT_STATE|NEW_TEXTURE_ENABLE)
|
---|
414 |
|
---|
415 | void gl_update_pipelines( GLcontext *ctx )
|
---|
416 | {
|
---|
417 | GLuint newstate = ctx->NewState;
|
---|
418 | struct gl_cva *cva = &ctx->CVA;
|
---|
419 |
|
---|
420 | newstate &= INTERESTED;
|
---|
421 |
|
---|
422 | if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_STATE))
|
---|
423 | gl_print_enable_flags("enabled", ctx->Enabled);
|
---|
424 |
|
---|
425 | if (newstate ||
|
---|
426 | cva->lock_changed ||
|
---|
427 | cva->orflag != cva->last_orflag ||
|
---|
428 | ctx->Array.Flags != cva->last_array_flags)
|
---|
429 | {
|
---|
430 | GLuint flags = VERT_WIN;
|
---|
431 |
|
---|
432 | if (ctx->Visual->RGBAflag)
|
---|
433 | flags |= VERT_RGBA;
|
---|
434 | else
|
---|
435 | flags |= VERT_INDEX;
|
---|
436 |
|
---|
437 | if (ctx->Texture.Enabled & 0xf) {
|
---|
438 | if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE)
|
---|
439 | flags &= ~VERT_RGBA;
|
---|
440 |
|
---|
441 | flags |= VERT_TEX0_ANY;
|
---|
442 | }
|
---|
443 |
|
---|
444 | if (ctx->Texture.Enabled & 0xf0)
|
---|
445 | flags |= VERT_TEX1_ANY;
|
---|
446 |
|
---|
447 | if (ctx->Polygon.Unfilled)
|
---|
448 | flags |= VERT_EDGE;
|
---|
449 |
|
---|
450 | if (ctx->RenderMode==GL_FEEDBACK)
|
---|
451 | {
|
---|
452 | flags = (VERT_WIN|VERT_RGBA|VERT_INDEX|
|
---|
453 | VERT_NORM|VERT_EDGE|
|
---|
454 | VERT_TEX0_ANY|VERT_TEX1_ANY);
|
---|
455 | }
|
---|
456 |
|
---|
457 | ctx->RenderFlags = flags;
|
---|
458 |
|
---|
459 | cva->elt.new_state |= newstate;
|
---|
460 | cva->elt.pipeline_valid = 0;
|
---|
461 |
|
---|
462 | cva->pre.new_state |= newstate;
|
---|
463 | cva->pre.forbidden_inputs = 0;
|
---|
464 | cva->pre.pipeline_valid = 0;
|
---|
465 | cva->lock_changed = 0;
|
---|
466 | }
|
---|
467 |
|
---|
468 | if (ctx->Array.NewArrayState != cva->last_array_new_state)
|
---|
469 | cva->pre.pipeline_valid = 0;
|
---|
470 |
|
---|
471 | cva->pre.data_valid = 0;
|
---|
472 | cva->last_array_new_state = ctx->Array.NewArrayState;
|
---|
473 | cva->last_orflag = cva->orflag;
|
---|
474 | cva->last_array_flags = ctx->Array.Flags;
|
---|
475 | }
|
---|
476 |
|
---|
477 | void gl_run_pipeline( struct vertex_buffer *VB )
|
---|
478 | {
|
---|
479 | struct gl_pipeline *pipe = VB->pipeline;
|
---|
480 | struct gl_pipeline_stage **stages = pipe->stages;
|
---|
481 | unsigned short x;
|
---|
482 |
|
---|
483 | pipe->data_valid = 1; /* optimized stages might want to reset this. */
|
---|
484 |
|
---|
485 | START_FAST_MATH(x);
|
---|
486 |
|
---|
487 | for ( VB->Culled = 0; *stages && !VB->Culled ; stages++ )
|
---|
488 | (*stages)->run( VB );
|
---|
489 |
|
---|
490 | END_FAST_MATH(x);
|
---|
491 |
|
---|
492 | pipe->new_state = 0;
|
---|
493 | }
|
---|
494 |
|
---|
495 | void gl_print_vert_flags( const char *name, GLuint flags )
|
---|
496 | {
|
---|
497 | fprintf(stderr,
|
---|
498 | "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
|
---|
499 | name,
|
---|
500 | flags,
|
---|
501 | (flags & VERT_OBJ_ANY) ? "vertices (obj), " : "",
|
---|
502 | (flags & VERT_ELT) ? "array-elt, " : "",
|
---|
503 | (flags & VERT_RGBA) ? "colors, " : "",
|
---|
504 | (flags & VERT_NORM) ? "normals, " : "",
|
---|
505 | (flags & VERT_INDEX) ? "index, " : "",
|
---|
506 | (flags & VERT_EDGE) ? "edgeflag, " : "",
|
---|
507 | (flags & VERT_MATERIAL) ? "material, " : "",
|
---|
508 | (flags & VERT_TEX0_ANY) ? "texcoord0, " : "",
|
---|
509 | (flags & VERT_TEX1_ANY) ? "texcoord1, " : "",
|
---|
510 | (flags & VERT_EVAL_ANY) ? "eval-coord, " : "",
|
---|
511 | (flags & VERT_EYE) ? "eye, " : "",
|
---|
512 | (flags & VERT_WIN) ? "win, " : "",
|
---|
513 | (flags & VERT_PRECALC_DATA) ? "precalc data, " : "",
|
---|
514 | (flags & VERT_SETUP_FULL) ? "driver-data, " : "",
|
---|
515 | (flags & VERT_SETUP_PART) ? "partial-driver-data, " : ""
|
---|
516 | );
|
---|
517 | }
|
---|
518 |
|
---|
519 | void gl_print_tri_caps( const char *name, GLuint flags )
|
---|
520 | {
|
---|
521 | fprintf(stderr,
|
---|
522 | "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
|
---|
523 | name,
|
---|
524 | flags,
|
---|
525 | (flags & DD_FEEDBACK) ? "feedback, " : "",
|
---|
526 | (flags & DD_SELECT) ? "select, " : "",
|
---|
527 | (flags & DD_FLATSHADE) ? "flat-shade, " : "",
|
---|
528 | (flags & DD_MULTIDRAW) ? "multidraw, " : "",
|
---|
529 | (flags & DD_SEPERATE_SPECULAR) ? "seperate-specular, " : "",
|
---|
530 | (flags & DD_TRI_LIGHT_TWOSIDE) ? "tri-light-twoside, " : "",
|
---|
531 | (flags & DD_TRI_UNFILLED) ? "tri-unfilled, " : "",
|
---|
532 | (flags & DD_TRI_STIPPLE) ? "tri-stipple, " : "",
|
---|
533 | (flags & DD_TRI_OFFSET) ? "tri-offset, " : "",
|
---|
534 | (flags & DD_TRI_CULL) ? "tri-bf-cull, " : "",
|
---|
535 | (flags & DD_LINE_SMOOTH) ? "line-smooth, " : "",
|
---|
536 | (flags & DD_LINE_STIPPLE) ? "line-stipple, " : "",
|
---|
537 | (flags & DD_LINE_WIDTH) ? "line-wide, " : "",
|
---|
538 | (flags & DD_POINT_SMOOTH) ? "point-smooth, " : "",
|
---|
539 | (flags & DD_POINT_SIZE) ? "point-size, " : "",
|
---|
540 | (flags & DD_POINT_ATTEN) ? "point-atten, " : "",
|
---|
541 | (flags & DD_LIGHTING_CULL) ? "lighting-cull, " : "",
|
---|
542 | (flags & DD_POINT_SW_RASTERIZE) ? "sw-points, " : "",
|
---|
543 | (flags & DD_LINE_SW_RASTERIZE) ? "sw-lines, " : "",
|
---|
544 | (flags & DD_TRI_SW_RASTERIZE) ? "sw-tris, " : "",
|
---|
545 | (flags & DD_QUAD_SW_RASTERIZE) ? "sw-quads, " : "",
|
---|
546 | (flags & DD_TRI_CULL_FRONT_BACK) ? "cull-all, " : ""
|
---|
547 | );
|
---|
548 | }
|
---|
549 |
|
---|
550 |
|
---|
551 | void gl_print_pipeline( GLcontext *ctx, struct gl_pipeline *p )
|
---|
552 | {
|
---|
553 | struct gl_pipeline_stage *pipeline = ctx->PipelineStage;
|
---|
554 | GLuint i;
|
---|
555 |
|
---|
556 | fprintf(stderr,"Type: %s\n", pipeline_name[p->type]);
|
---|
557 |
|
---|
558 | if (!p->pipeline_valid) {
|
---|
559 | printf("--> Not up to date!!!\n");
|
---|
560 | return;
|
---|
561 | }
|
---|
562 |
|
---|
563 | gl_print_vert_flags("Inputs", p->inputs);
|
---|
564 | gl_print_vert_flags("Forbidden", p->forbidden_inputs);
|
---|
565 | gl_print_vert_flags("Outputs", p->outputs);
|
---|
566 |
|
---|
567 | if (0)
|
---|
568 | for (i = 0 ; i < ctx->NrPipelineStages ; i++)
|
---|
569 | if (pipeline[i].active & p->type) {
|
---|
570 | fprintf(stderr,"%u: %s\n", i, pipeline[i].name);
|
---|
571 |
|
---|
572 | gl_print_vert_flags("\tinputs", pipeline[i].inputs);
|
---|
573 | gl_print_vert_flags("\toutputs", pipeline[i].outputs);
|
---|
574 |
|
---|
575 | if (p->type == PIPE_PRECALC && pipeline[i].pre_forbidden_inputs)
|
---|
576 | gl_print_vert_flags("\tforbidden",
|
---|
577 | pipeline[i].pre_forbidden_inputs);
|
---|
578 |
|
---|
579 | if (p->type == PIPE_IMMEDIATE && pipeline[i].elt_forbidden_inputs)
|
---|
580 | gl_print_vert_flags("\tforbidden",
|
---|
581 | pipeline[i].elt_forbidden_inputs);
|
---|
582 |
|
---|
583 | }
|
---|
584 |
|
---|
585 |
|
---|
586 | if (1) {
|
---|
587 | struct gl_pipeline_stage **stages = p->stages;
|
---|
588 | fprintf(stderr,"\nStages requiring precalculation:\n");
|
---|
589 | for ( i=0 ; stages[i] ; i++) {
|
---|
590 | fprintf(stderr, "%u: %s\n", i, stages[i]->name);
|
---|
591 | gl_print_vert_flags("\tinputs", stages[i]->inputs);
|
---|
592 | gl_print_vert_flags("\toutputs", stages[i]->outputs);
|
---|
593 | if (p->type == PIPE_PRECALC && pipeline[i].pre_forbidden_inputs)
|
---|
594 | gl_print_vert_flags("\tforbidden",
|
---|
595 | pipeline[i].pre_forbidden_inputs);
|
---|
596 |
|
---|
597 | if (p->type == PIPE_IMMEDIATE && pipeline[i].elt_forbidden_inputs)
|
---|
598 | gl_print_vert_flags("\tforbidden",
|
---|
599 | pipeline[i].elt_forbidden_inputs);
|
---|
600 | }
|
---|
601 | }
|
---|
602 | }
|
---|
603 |
|
---|
604 |
|
---|
605 |
|
---|
606 | void gl_print_active_pipeline( GLcontext *ctx, struct gl_pipeline *p )
|
---|
607 | {
|
---|
608 | struct gl_pipeline_stage **stages = p->stages;
|
---|
609 | GLuint i;
|
---|
610 |
|
---|
611 | (void) ctx;
|
---|
612 |
|
---|
613 | fprintf(stderr,"Type: %s\n", pipeline_name[p->type]);
|
---|
614 |
|
---|
615 | if (!p->pipeline_valid) {
|
---|
616 | printf("--> Not up to date!!!\n");
|
---|
617 | return;
|
---|
618 | }
|
---|
619 |
|
---|
620 | gl_print_vert_flags("Inputs", p->inputs);
|
---|
621 | gl_print_vert_flags("Forbidden", p->forbidden_inputs);
|
---|
622 | gl_print_vert_flags("Outputs", p->outputs);
|
---|
623 |
|
---|
624 | for ( i=0 ; stages[i] ; i++) {
|
---|
625 | fprintf(stderr, "%u: %s\n", i, stages[i]->name);
|
---|
626 |
|
---|
627 | gl_print_vert_flags("\tinputs", stages[i]->inputs);
|
---|
628 | gl_print_vert_flags("\toutputs", stages[i]->outputs);
|
---|
629 |
|
---|
630 | if (p->type == PIPE_PRECALC && stages[i]->pre_forbidden_inputs)
|
---|
631 | gl_print_vert_flags("\tforbidden",
|
---|
632 | stages[i]->pre_forbidden_inputs);
|
---|
633 | }
|
---|
634 | }
|
---|
635 |
|
---|
636 |
|
---|