1 /* $Id: t_imm_fixup.c,v 1.30 2001/12/15 02:13:32 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
29 * Keith Whitwell <keithw@valinux.com>
45 #include "math/m_matrix.h"
46 #include "math/m_xform.h"
48 #include "t_context.h"
49 #include "t_imm_alloc.h"
50 #include "t_imm_debug.h"
51 #include "t_imm_elt.h"
52 #include "t_imm_fixup.h"
53 #include "t_imm_exec.h"
54 #include "t_pipeline.h"
57 static const GLuint increment
[GL_POLYGON
+2] = { 1,2,1,1,3,1,1,4,2,1,1 };
58 static const GLuint intro
[GL_POLYGON
+2] = { 0,0,2,2,0,2,2,0,2,2,0 };
61 _tnl_fixup_4f( GLfloat data
[][4], GLuint flag
[], GLuint start
, GLuint match
)
66 if ((flag
[++i
] & match
) == 0) {
67 COPY_4FV(data
[i
], data
[i
-1]);
68 if (flag
[i
] & VERT_END_VB
) break;
74 _tnl_fixup_3f( float data
[][3], GLuint flag
[], GLuint start
, GLuint match
)
80 if ((flag
[++i
] & match
) == 0) {
81 /* fprintf(stderr, "_tnl_fixup_3f copy to %p values %f %f %f\n", */
86 COPY_3V(data
[i
], data
[i
-1]);
87 if (flag
[i
] & VERT_END_VB
) break;
94 _tnl_fixup_1ui( GLuint
*data
, GLuint flag
[], GLuint start
, GLuint match
)
99 if ((flag
[++i
] & match
) == 0) {
101 if (flag
[i
] & VERT_END_VB
) break;
109 _tnl_fixup_1f( GLfloat
*data
, GLuint flag
[], GLuint start
, GLuint match
)
114 if ((flag
[++i
] & match
) == 0) {
116 if (flag
[i
] & VERT_END_VB
) break;
123 _tnl_fixup_1ub( GLubyte
*data
, GLuint flag
[], GLuint start
, GLuint match
)
128 if ((flag
[++i
] & match
) == 0) {
130 if (flag
[i
] & VERT_END_VB
) break;
138 fixup_first_4f( GLfloat data
[][4], GLuint flag
[], GLuint match
,
139 GLuint start
, GLfloat
*dflt
)
142 match
|= VERT_END_VB
;
144 while ((flag
[++i
]&match
) == 0)
145 COPY_4FV(data
[i
], dflt
);
149 fixup_first_3f( GLfloat data
[][3], GLuint flag
[], GLuint match
,
150 GLuint start
, GLfloat
*dflt
)
153 match
|= VERT_END_VB
;
155 /* fprintf(stderr, "fixup_first_3f default: %f %f %f start: %d\n", */
156 /* dflt[0], dflt[1], dflt[2], start); */
158 while ((flag
[++i
]&match
) == 0)
159 COPY_3FV(data
[i
], dflt
);
164 fixup_first_1ui( GLuint data
[], GLuint flag
[], GLuint match
,
165 GLuint start
, GLuint dflt
)
168 match
|= VERT_END_VB
;
170 while ((flag
[++i
]&match
) == 0)
175 fixup_first_1f( GLfloat data
[], GLuint flag
[], GLuint match
,
176 GLuint start
, GLfloat dflt
)
179 match
|= VERT_END_VB
;
181 while ((flag
[++i
]&match
) == 0)
187 fixup_first_1ub( GLubyte data
[], GLuint flag
[], GLuint match
,
188 GLuint start
, GLubyte dflt
)
191 match
|= VERT_END_VB
;
193 while ((flag
[++i
]&match
) == 0)
198 * Copy vertex attributes from the ctx->Current group into the immediate
199 * struct at the given position according to copyMask.
201 static void copy_from_current( GLcontext
*ctx
, struct immediate
*IM
,
202 GLuint pos
, GLuint copyMask
)
204 if (MESA_VERBOSE
&VERBOSE_IMMEDIATE
)
205 _tnl_print_vert_flags("copy from current", copyMask
);
207 if (copyMask
& VERT_NORMAL_BIT
) {
208 COPY_3V(IM
->Normal
[pos
], ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
]);
211 if (copyMask
& VERT_COLOR0_BIT
) {
212 COPY_4FV( IM
->Color
[pos
], ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
]);
215 if (copyMask
& VERT_COLOR1_BIT
)
216 COPY_4FV( IM
->SecondaryColor
[pos
], ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
]);
218 if (copyMask
& VERT_FOG_BIT
)
219 IM
->FogCoord
[pos
] = ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
221 if (copyMask
& VERT_INDEX_BIT
)
222 IM
->Index
[pos
] = ctx
->Current
.Index
;
224 if (copyMask
& VERT_EDGEFLAG_BIT
)
225 IM
->EdgeFlag
[pos
] = ctx
->Current
.EdgeFlag
;
227 if (copyMask
& VERT_TEX_ANY
) {
229 for (i
= 0 ; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
230 if (copyMask
& VERT_TEX(i
))
231 COPY_4FV(IM
->TexCoord
[i
][pos
], ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ i
]);
237 void _tnl_fixup_input( GLcontext
*ctx
, struct immediate
*IM
)
239 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
240 GLuint start
= IM
->CopyStart
;
241 GLuint andflag
= IM
->CopyAndFlag
;
242 GLuint orflag
= IM
->CopyOrFlag
| IM
->Evaluated
;
245 IM
->CopyTexSize
= IM
->TexSize
;
247 /* fprintf(stderr, "Fixup input, Start: %u Count: %u LastData: %u\n", */
248 /* IM->Start, IM->Count, IM->LastData); */
249 /* _tnl_print_vert_flags("Orflag", orflag); */
250 /* _tnl_print_vert_flags("Andflag", andflag); */
253 fixup
= ~andflag
& VERT_FIXUP
;
255 if (!ctx
->CompileFlag
)
256 fixup
&= tnl
->pipeline
.inputs
;
258 if (!ctx
->ExecuteFlag
)
261 if ((orflag
& (VERT_OBJ_BIT
|VERT_EVAL_ANY
)) == 0)
265 GLuint copy
= fixup
& ~IM
->Flag
[start
];
268 /* Equivalent to a lazy copy-from-current when setting up the
271 if (ctx
->ExecuteFlag
&& copy
)
272 copy_from_current( ctx
, IM
, start
, copy
);
274 if (MESA_VERBOSE
&VERBOSE_IMMEDIATE
)
275 _tnl_print_vert_flags("fixup", fixup
);
277 if (fixup
& VERT_TEX_ANY
) {
279 for (i
= 0 ; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
280 if (fixup
& VERT_TEX(i
)) {
281 if (orflag
& VERT_TEX(i
))
282 _tnl_fixup_4f( IM
->TexCoord
[i
], IM
->Flag
, start
,
285 fixup_first_4f( IM
->TexCoord
[i
], IM
->Flag
, VERT_END_VB
, start
,
286 IM
->TexCoord
[i
][start
]);
292 if (fixup
& VERT_EDGEFLAG_BIT
) {
293 if (orflag
& VERT_EDGEFLAG_BIT
)
294 _tnl_fixup_1ub( IM
->EdgeFlag
, IM
->Flag
, start
, VERT_EDGEFLAG_BIT
);
296 fixup_first_1ub( IM
->EdgeFlag
, IM
->Flag
, VERT_END_VB
, start
,
297 IM
->EdgeFlag
[start
] );
300 if (fixup
& VERT_INDEX_BIT
) {
301 if (orflag
& VERT_INDEX_BIT
)
302 _tnl_fixup_1ui( IM
->Index
, IM
->Flag
, start
, VERT_INDEX_BIT
);
304 fixup_first_1ui( IM
->Index
, IM
->Flag
, VERT_END_VB
, start
,
308 if (fixup
& VERT_COLOR0_BIT
) {
309 if (orflag
& VERT_COLOR0_BIT
)
310 _tnl_fixup_4f( IM
->Color
, IM
->Flag
, start
, VERT_COLOR0_BIT
);
311 /* No need for else case as the drivers understand stride
312 * zero here. (TODO - propogate this)
316 if (fixup
& VERT_COLOR1_BIT
) {
317 if (orflag
& VERT_COLOR1_BIT
)
318 _tnl_fixup_4f( IM
->SecondaryColor
, IM
->Flag
, start
,
321 fixup_first_4f( IM
->SecondaryColor
, IM
->Flag
, VERT_END_VB
, start
,
322 IM
->SecondaryColor
[start
] );
325 if (fixup
& VERT_FOG_BIT
) {
326 if (orflag
& VERT_FOG_BIT
)
327 _tnl_fixup_1f( IM
->FogCoord
, IM
->Flag
, start
, VERT_FOG_BIT
);
329 fixup_first_1f( IM
->FogCoord
, IM
->Flag
, VERT_END_VB
, start
,
330 IM
->FogCoord
[start
] );
333 if (fixup
& VERT_NORMAL_BIT
) {
334 if (orflag
& VERT_NORMAL_BIT
)
335 _tnl_fixup_3f( IM
->Normal
, IM
->Flag
, start
, VERT_NORMAL_BIT
);
337 fixup_first_3f( IM
->Normal
, IM
->Flag
, VERT_END_VB
, start
,
342 /* Prune possible half-filled slot.
344 IM
->Flag
[IM
->LastData
+1] &= ~VERT_END_VB
;
345 IM
->Flag
[IM
->Count
] |= VERT_END_VB
;
350 if (IM
->MaterialOrMask
& ~IM
->MaterialAndMask
) {
351 GLuint vulnerable
= IM
->MaterialOrMask
;
352 GLuint i
= IM
->Start
;
355 while (!(IM
->Flag
[i
] & VERT_MATERIAL
))
358 vulnerable
&= ~IM
->MaterialMask
[i
];
359 _mesa_copy_material_pairs( IM
->Material
[i
],
364 } while (vulnerable
);
371 static void copy_material( struct immediate
*next
,
372 struct immediate
*prev
,
373 GLuint dst
, GLuint src
)
375 if (next
->Material
== 0) {
376 next
->Material
= (GLmaterial (*)[2]) MALLOC( sizeof(GLmaterial
) *
378 next
->MaterialMask
= (GLuint
*) MALLOC( sizeof(GLuint
) * IMM_SIZE
);
381 next
->MaterialMask
[dst
] = prev
->MaterialOrMask
;
382 MEMCPY(next
->Material
[dst
], prev
->Material
[src
], 2*sizeof(GLmaterial
));
385 static GLboolean is_fan_like
[GL_POLYGON
+1] = {
388 GL_TRUE
, /* line loop */
392 GL_TRUE
, /* tri fan */
395 GL_TRUE
/* polygon */
399 /* Copy the untransformed data from the shared vertices of a primitive
400 * that wraps over two immediate structs. This is done prior to
401 * set_immediate so that prev and next may point to the same
402 * structure. In general it's difficult to avoid this copy on long
405 * Have to be careful with the transitions between display list
406 * replay, compile and normal execute modes.
408 void _tnl_copy_immediate_vertices( GLcontext
*ctx
, struct immediate
*next
)
410 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
411 struct immediate
*prev
= tnl
->ExecCopySource
;
412 struct vertex_arrays
*inputs
= &tnl
->imm_inputs
;
413 GLuint count
= tnl
->ExecCopyCount
;
414 GLuint
*elts
= tnl
->ExecCopyElts
;
415 GLuint offset
= IMM_MAX_COPIED_VERTS
- count
;
419 ASSERT(tnl
->ExecCopyCount
== 0);
423 next
->CopyStart
= next
->Start
- count
;
425 if ((prev
->CopyOrFlag
& VERT_DATA
) == VERT_ELT
&&
426 ctx
->Array
.LockCount
&&
427 ctx
->Array
.Vertex
.Enabled
)
429 /* Copy Elt values only
431 for (i
= 0 ; i
< count
; i
++)
433 GLuint src
= elts
[i
+offset
];
434 GLuint dst
= next
->CopyStart
+i
;
435 next
->Elt
[dst
] = prev
->Elt
[src
];
436 next
->Flag
[dst
] = VERT_ELT
;
438 /* fprintf(stderr, "ADDING VERT_ELT!\n"); */
439 next
->CopyOrFlag
|= VERT_ELT
;
440 next
->CopyAndFlag
&= VERT_ELT
;
443 GLuint copy
= tnl
->pipeline
.inputs
& (prev
->CopyOrFlag
|prev
->Evaluated
);
446 if (is_fan_like
[ctx
->Driver
.CurrentExecPrimitive
]) {
447 flag
= ((prev
->CopyOrFlag
|prev
->Evaluated
) & VERT_FIXUP
);
448 next
->CopyOrFlag
|= flag
;
451 /* Don't let an early 'glColor', etc. poison the elt path.
453 flag
= ((prev
->OrFlag
|prev
->Evaluated
) & VERT_FIXUP
);
456 next
->TexSize
|= tnl
->ExecCopyTexSize
;
457 next
->CopyAndFlag
&= flag
;
460 /* _tnl_print_vert_flags("copy vertex components", copy); */
461 /* _tnl_print_vert_flags("prev copyorflag", prev->CopyOrFlag); */
462 /* _tnl_print_vert_flags("flag", flag); */
464 /* Copy whole vertices
466 for (i
= 0 ; i
< count
; i
++)
468 GLuint src
= elts
[i
+offset
];
469 GLuint isrc
= src
- prev
->CopyStart
;
470 GLuint dst
= next
->CopyStart
+i
;
472 /* Values subject to eval must be copied out of the 'inputs'
473 * struct. (Copied rows should not be evaluated twice).
475 * Note these pointers are null when inactive.
477 COPY_4FV( next
->Obj
[dst
], inputs
->Obj
.data
[isrc
] );
479 if (copy
& VERT_NORMAL_BIT
) {
480 /* fprintf(stderr, "copy vert norm %d to %d (%p): %f %f %f\n", */
482 /* next->Normal[dst], */
483 /* inputs->Normal.data[isrc][0], */
484 /* inputs->Normal.data[isrc][1], */
485 /* inputs->Normal.data[isrc][2]); */
486 COPY_3FV( next
->Normal
[dst
], inputs
->Normal
.data
[isrc
] );
489 if (copy
& VERT_COLOR0_BIT
)
490 COPY_4FV( next
->Color
[dst
],
491 ((GLfloat (*)[4])inputs
->Color
.Ptr
)[isrc
] );
493 if (copy
& VERT_INDEX_BIT
)
494 next
->Index
[dst
] = inputs
->Index
.data
[isrc
];
496 if (copy
& VERT_TEX_ANY
) {
498 for (i
= 0 ; i
< prev
->MaxTextureUnits
; i
++) {
499 if (copy
& VERT_TEX(i
))
500 COPY_4FV( next
->TexCoord
[i
][dst
],
501 inputs
->TexCoord
[i
].data
[isrc
] );
505 /* Remaining values should be the same in the 'input' struct and the
506 * original immediate.
508 if (copy
& (VERT_ELT
|VERT_EDGEFLAG_BIT
|VERT_COLOR1_BIT
|VERT_FOG_BIT
|
511 if (prev
->Flag
[src
] & VERT_MATERIAL
)
512 copy_material(next
, prev
, dst
, src
);
514 next
->Elt
[dst
] = prev
->Elt
[src
];
515 next
->EdgeFlag
[dst
] = prev
->EdgeFlag
[src
];
516 COPY_4FV( next
->SecondaryColor
[dst
], prev
->SecondaryColor
[src
] );
517 next
->FogCoord
[dst
] = prev
->FogCoord
[src
];
520 next
->Flag
[dst
] = flag
;
521 next
->CopyOrFlag
|= prev
->Flag
[src
] & (VERT_FIXUP
|
527 if (--tnl
->ExecCopySource
->ref_count
== 0)
528 _tnl_free_immediate( tnl
->ExecCopySource
);
530 tnl
->ExecCopySource
= 0;
531 tnl
->ExecCopyCount
= 0;
536 /* Revive a compiled immediate struct - propogate new 'Current'
537 * values. Often this is redundant because the current values were
538 * known and fixed up at compile time (or in the first execution of
541 void _tnl_fixup_compiled_cassette( GLcontext
*ctx
, struct immediate
*IM
)
543 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
545 GLuint start
= IM
->Start
;
547 /* fprintf(stderr, "%s\n", __FUNCTION__); */
550 IM
->CopyOrFlag
= IM
->OrFlag
;
551 IM
->CopyAndFlag
= IM
->AndFlag
;
552 IM
->CopyTexSize
= IM
->TexSize
| tnl
->ExecCopyTexSize
;
554 _tnl_copy_immediate_vertices( ctx
, IM
);
556 if (ctx
->Driver
.CurrentExecPrimitive
== GL_POLYGON
+1) {
557 ASSERT(IM
->CopyStart
== IM
->Start
);
560 /* Naked array elements can be copied into the first cassette in a
561 * display list. Need to translate them away:
563 if (IM
->CopyOrFlag
& VERT_ELT
) {
564 GLuint copy
= tnl
->pipeline
.inputs
& ~ctx
->Array
._Enabled
;
567 ASSERT(IM
->CopyStart
< IM
->Start
);
569 _tnl_translate_array_elts( ctx
, IM
, IM
->CopyStart
, IM
->Start
);
571 for (i
= IM
->CopyStart
; i
< IM
->Start
; i
++)
572 copy_from_current( ctx
, IM
, i
, copy
);
574 _tnl_copy_to_current( ctx
, IM
, ctx
->Array
._Enabled
, IM
->Start
);
577 fixup
= tnl
->pipeline
.inputs
& ~IM
->Flag
[start
] & VERT_FIXUP
;
579 /* _tnl_print_vert_flags("fixup compiled", fixup); */
582 if (fixup
& VERT_TEX_ANY
) {
584 for (i
= 0 ; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
585 if (fixup
& VERT_TEX(i
))
586 fixup_first_4f( IM
->TexCoord
[i
], IM
->Flag
, VERT_TEX(i
), start
,
587 ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ i
] );
591 if (fixup
& VERT_EDGEFLAG_BIT
)
592 fixup_first_1ub(IM
->EdgeFlag
, IM
->Flag
, VERT_EDGEFLAG_BIT
, start
,
593 ctx
->Current
.EdgeFlag
);
595 if (fixup
& VERT_INDEX_BIT
)
596 fixup_first_1ui(IM
->Index
, IM
->Flag
, VERT_INDEX_BIT
, start
,
597 ctx
->Current
.Index
);
599 if (fixup
& VERT_COLOR0_BIT
) {
600 if (IM
->CopyOrFlag
& VERT_COLOR0_BIT
)
601 fixup_first_4f(IM
->Color
, IM
->Flag
, VERT_COLOR0_BIT
, start
,
602 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
604 fixup
&= ~VERT_COLOR0_BIT
;
607 if (fixup
& VERT_COLOR1_BIT
)
608 fixup_first_4f(IM
->SecondaryColor
, IM
->Flag
, VERT_COLOR1_BIT
, start
,
609 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
] );
611 if (fixup
& VERT_FOG_BIT
)
612 fixup_first_1f(IM
->FogCoord
, IM
->Flag
, VERT_FOG_BIT
, start
,
613 ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0] );
615 if (fixup
& VERT_NORMAL_BIT
) {
616 fixup_first_3f(IM
->Normal
, IM
->Flag
, VERT_NORMAL_BIT
, start
,
617 ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
] );
620 IM
->CopyOrFlag
|= fixup
;
626 if (IM
->MaterialOrMask
& ~IM
->MaterialAndMask
) {
627 GLuint vulnerable
= IM
->MaterialOrMask
;
628 GLuint i
= IM
->Start
;
631 while (!(IM
->Flag
[i
] & VERT_MATERIAL
))
634 vulnerable
&= ~IM
->MaterialMask
[i
];
635 _mesa_copy_material_pairs( IM
->Material
[i
],
640 } while (vulnerable
);
649 static void copy_none( TNLcontext
*tnl
, GLuint start
, GLuint count
, GLuint ovf
)
651 (void) (start
&& ovf
&& tnl
&& count
);
654 static void copy_last( TNLcontext
*tnl
, GLuint start
, GLuint count
, GLuint ovf
)
656 (void) start
; (void) ovf
;
657 tnl
->ExecCopyCount
= 1;
658 tnl
->ExecCopyElts
[2] = count
-1;
661 static void copy_first_and_last( TNLcontext
*tnl
, GLuint start
, GLuint count
,
665 tnl
->ExecCopyCount
= 2;
666 tnl
->ExecCopyElts
[1] = start
;
667 tnl
->ExecCopyElts
[2] = count
-1;
670 static void copy_last_two( TNLcontext
*tnl
, GLuint start
, GLuint count
,
674 tnl
->ExecCopyCount
= 2+ovf
;
675 tnl
->ExecCopyElts
[0] = count
-3;
676 tnl
->ExecCopyElts
[1] = count
-2;
677 tnl
->ExecCopyElts
[2] = count
-1;
680 static void copy_overflow( TNLcontext
*tnl
, GLuint start
, GLuint count
,
684 tnl
->ExecCopyCount
= ovf
;
685 tnl
->ExecCopyElts
[0] = count
-3;
686 tnl
->ExecCopyElts
[1] = count
-2;
687 tnl
->ExecCopyElts
[2] = count
-1;
691 typedef void (*copy_func
)( TNLcontext
*tnl
, GLuint start
, GLuint count
,
694 static copy_func copy_tab
[GL_POLYGON
+2] =
713 /* Figure out what vertices need to be copied next time.
716 _tnl_get_exec_copy_verts( GLcontext
*ctx
, struct immediate
*IM
)
719 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
720 GLuint last
= IM
->LastPrimitive
;
721 GLuint prim
= ctx
->Driver
.CurrentExecPrimitive
;
722 GLuint pincr
= increment
[prim
];
723 GLuint pintro
= intro
[prim
];
726 /* fprintf(stderr, "_tnl_get_exec_copy_verts %s\n", */
727 /* _mesa_lookup_enum_by_nr(prim)); */
729 ASSERT(tnl
->ExecCopySource
== 0);
731 if (prim
== GL_POLYGON
+1) {
732 tnl
->ExecCopyCount
= 0;
733 tnl
->ExecCopyTexSize
= 0;
736 /* Remember this immediate as the one to copy from.
739 tnl
->ExecCopySource
= IM
;
740 tnl
->ExecCopyCount
= 0;
741 tnl
->ExecCopyTexSize
= IM
->CopyTexSize
;
743 if (IM
->LastPrimitive
!= IM
->CopyStart
)
746 tnl
->ExecParity
^= IM
->PrimitiveLength
[IM
->LastPrimitive
] & 1;
749 if (pincr
!= 1 && (IM
->Count
- last
- pintro
))
750 ovf
= (IM
->Count
- last
- pintro
) % pincr
;
752 if (last
< IM
->Count
)
753 copy_tab
[prim
]( tnl
, last
, IM
->Count
, ovf
);
758 /* Recalculate ExecCopyElts, ExecParity, etc.
761 _tnl_get_purged_copy_verts( GLcontext
*ctx
, struct immediate
*IM
)
763 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
765 if (ctx
->Driver
.CurrentExecPrimitive
!= GL_POLYGON
+1) {
766 GLuint last
= IM
->LastPrimitive
;
767 GLenum prim
= IM
->Primitive
[last
];
768 GLuint pincr
= increment
[prim
];
769 GLuint pintro
= intro
[prim
];
772 tnl
->ExecCopyCount
= 0;
773 if (IM
->LastPrimitive
!= IM
->CopyStart
)
776 tnl
->ExecParity
^= IM
->PrimitiveLength
[IM
->LastPrimitive
] & 1;
778 if (pincr
!= 1 && (IM
->Count
- last
- pintro
))
779 ovf
= (IM
->Count
- last
- pintro
) % pincr
;
781 if (last
< IM
->Count
)
782 copy_tab
[prim
]( tnl
, last
, IM
->Count
, ovf
);
784 for (i
= 0 ; i
< tnl
->ExecCopyCount
; i
++)
785 tnl
->ExecCopyElts
[i
] = IM
->Elt
[tnl
->ExecCopyElts
[i
]];
790 void _tnl_upgrade_current_data( GLcontext
*ctx
,
794 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
795 struct vertex_buffer
*VB
= &tnl
->vb
;
796 struct immediate
*IM
= (struct immediate
*)VB
->import_source
;
800 /* _tnl_print_vert_flags("_tnl_upgrade_client_data", required); */
802 if ((required
& VERT_COLOR0_BIT
) && (VB
->ColorPtr
[0]->Flags
& CA_CLIENT_DATA
)) {
803 struct gl_client_array
*tmp
= &tnl
->imm_inputs
.Color
;
804 GLuint start
= IM
->CopyStart
;
806 tmp
->Ptr
= IM
->Color
+ start
;
807 tmp
->StrideB
= 4 * sizeof(GLfloat
);
810 COPY_4FV( IM
->Color
[start
], ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
]);
813 ASSERT(IM->Flag[IM->LastData+1] & VERT_END_VB);
816 fixup_first_4f( IM
->Color
, IM
->Flag
, VERT_END_VB
, start
,
819 VB
->importable_data
&= ~VERT_COLOR0_BIT
;