f6d33dfa1a4c8055f63b2c5b618941deafda8d1a
1 /* $Id: t_imm_eval.c,v 1.13 2001/05/14 09:00:51 keithw 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.
27 * Keith Whitwell <keithw@valinux.com>
39 #include "math/m_eval.h"
41 #include "t_context.h"
42 #include "t_imm_debug.h"
43 #include "t_imm_eval.h"
44 #include "t_imm_exec.h"
45 #include "t_imm_fixup.h"
46 #include "t_imm_alloc.h"
49 static void eval_points1( GLfloat outcoord
[][4],
52 GLfloat du
, GLfloat u1
)
55 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
56 if (flags
[i
] & VERT_EVAL_ANY
) {
57 outcoord
[i
][0] = coord
[i
][0];
58 outcoord
[i
][1] = coord
[i
][1];
59 if (flags
[i
] & VERT_EVAL_P1
)
60 outcoord
[i
][0] = coord
[i
][0] * du
+ u1
;
64 static void eval_points2( GLfloat outcoord
[][4],
67 GLfloat du
, GLfloat u1
,
68 GLfloat dv
, GLfloat v1
)
71 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++) {
72 if (flags
[i
] & VERT_EVAL_ANY
) {
73 outcoord
[i
][0] = coord
[i
][0];
74 outcoord
[i
][1] = coord
[i
][1];
75 if (flags
[i
] & VERT_EVAL_P2
) {
76 outcoord
[i
][0] = coord
[i
][0] * du
+ u1
;
77 outcoord
[i
][1] = coord
[i
][1] * dv
+ v1
;
83 static const GLubyte dirty_flags
[5] = {
92 static void eval1_4f( GLvector4f
*dest
,
96 struct gl_1d_map
*map
)
98 const GLfloat u1
= map
->u1
;
99 const GLfloat du
= map
->du
;
100 GLfloat (*to
)[4] = dest
->data
;
103 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
104 if (flags
[i
] & (VERT_EVAL_C1
|VERT_EVAL_P1
)) {
105 GLfloat u
= (coord
[i
][0] - u1
) * du
;
106 ASSIGN_4V(to
[i
], 0,0,0,1);
107 _math_horner_bezier_curve(map
->Points
, to
[i
], u
,
108 dimension
, map
->Order
);
111 dest
->size
= MAX2(dest
->size
, dimension
);
112 dest
->flags
|= dirty_flags
[dimension
];
115 static void eval1_4f_ca( struct gl_client_array
*dest
,
119 struct gl_1d_map
*map
)
121 const GLfloat u1
= map
->u1
;
122 const GLfloat du
= map
->du
;
123 GLfloat (*to
)[4] = (GLfloat (*)[4])dest
->Ptr
;
126 ASSERT(dest
->Type
== GL_FLOAT
);
127 ASSERT(dest
->StrideB
== 4 * sizeof(GLfloat
));
129 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
130 if (flags
[i
] & (VERT_EVAL_C1
|VERT_EVAL_P1
)) {
131 GLfloat u
= (coord
[i
][0] - u1
) * du
;
132 ASSIGN_4V(to
[i
], 0,0,0,1);
133 _math_horner_bezier_curve(map
->Points
, to
[i
], u
,
134 dimension
, map
->Order
);
137 dest
->Size
= MAX2(dest
->Size
, (GLint
) dimension
);
141 static void eval1_1ui( GLvector1ui
*dest
,
144 struct gl_1d_map
*map
)
146 const GLfloat u1
= map
->u1
;
147 const GLfloat du
= map
->du
;
148 GLuint
*to
= dest
->data
;
151 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
152 if (flags
[i
] & (VERT_EVAL_C1
|VERT_EVAL_P1
)) {
153 GLfloat u
= (coord
[i
][0] - u1
) * du
;
155 _math_horner_bezier_curve(map
->Points
, &tmp
, u
, 1, map
->Order
);
156 to
[i
] = (GLuint
) (GLint
) tmp
;
161 static void eval1_norm( GLvector3f
*dest
,
164 struct gl_1d_map
*map
)
166 const GLfloat u1
= map
->u1
;
167 const GLfloat du
= map
->du
;
168 GLfloat (*to
)[3] = dest
->data
;
171 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
172 if (flags
[i
] & (VERT_EVAL_C1
|VERT_EVAL_P1
)) {
173 GLfloat u
= (coord
[i
][0] - u1
) * du
;
174 _math_horner_bezier_curve(map
->Points
, to
[i
], u
, 3, map
->Order
);
182 static void eval2_obj_norm( GLvector4f
*obj_ptr
,
183 GLvector3f
*norm_ptr
,
187 struct gl_2d_map
*map
)
189 const GLfloat u1
= map
->u1
;
190 const GLfloat du
= map
->du
;
191 const GLfloat v1
= map
->v1
;
192 const GLfloat dv
= map
->dv
;
193 GLfloat (*obj
)[4] = obj_ptr
->data
;
194 GLfloat (*normal
)[3] = norm_ptr
->data
;
197 /* fprintf(stderr, "%s\n", __FUNCTION__); */
199 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
200 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
201 GLfloat u
= (coord
[i
][0] - u1
) * du
;
202 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
203 GLfloat du
[4], dv
[4];
205 ASSIGN_4V(obj
[i
], 0,0,0,1);
206 _math_de_casteljau_surf(map
->Points
, obj
[i
], du
, dv
, u
, v
, dimension
,
207 map
->Uorder
, map
->Vorder
);
209 CROSS3(normal
[i
], du
, dv
);
210 NORMALIZE_3FV(normal
[i
]);
213 obj_ptr
->size
= MAX2(obj_ptr
->size
, dimension
);
214 obj_ptr
->flags
|= dirty_flags
[dimension
];
218 static void eval2_4f( GLvector4f
*dest
,
222 struct gl_2d_map
*map
)
224 const GLfloat u1
= map
->u1
;
225 const GLfloat du
= map
->du
;
226 const GLfloat v1
= map
->v1
;
227 const GLfloat dv
= map
->dv
;
228 GLfloat (*to
)[4] = dest
->data
;
231 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
232 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
233 GLfloat u
= (coord
[i
][0] - u1
) * du
;
234 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
235 /* fprintf(stderr, "coord %d: %f %f\n", i, coord[i][0], coord[i][1]); */
237 _math_horner_bezier_surf(map
->Points
, to
[i
], u
, v
, dimension
,
238 map
->Uorder
, map
->Vorder
);
241 dest
->size
= MAX2(dest
->size
, dimension
);
242 dest
->flags
|= dirty_flags
[dimension
];
245 static void eval2_4f_ca( struct gl_client_array
*dest
,
249 struct gl_2d_map
*map
)
251 const GLfloat u1
= map
->u1
;
252 const GLfloat du
= map
->du
;
253 const GLfloat v1
= map
->v1
;
254 const GLfloat dv
= map
->dv
;
255 GLfloat (*to
)[4] = (GLfloat (*)[4])dest
->Ptr
;
258 ASSERT(dest
->Type
== GL_FLOAT
);
259 ASSERT(dest
->StrideB
== 4 * sizeof(GLfloat
));
261 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
262 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
263 GLfloat u
= (coord
[i
][0] - u1
) * du
;
264 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
265 _math_horner_bezier_surf(map
->Points
, to
[i
], u
, v
, dimension
,
266 map
->Uorder
, map
->Vorder
);
269 dest
->Size
= MAX2(dest
->Size
, (GLint
) dimension
);
273 static void eval2_norm( GLvector3f
*dest
,
276 struct gl_2d_map
*map
)
278 const GLfloat u1
= map
->u1
;
279 const GLfloat du
= map
->du
;
280 const GLfloat v1
= map
->v1
;
281 const GLfloat dv
= map
->dv
;
282 GLfloat (*to
)[3] = dest
->data
;
285 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
286 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
287 GLfloat u
= (coord
[i
][0] - u1
) * du
;
288 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
289 _math_horner_bezier_surf(map
->Points
, to
[i
], u
, v
, 3,
290 map
->Uorder
, map
->Vorder
);
296 static void eval2_1ui( GLvector1ui
*dest
,
299 struct gl_2d_map
*map
)
301 const GLfloat u1
= map
->u1
;
302 const GLfloat du
= map
->du
;
303 const GLfloat v1
= map
->v1
;
304 const GLfloat dv
= map
->dv
;
305 GLuint
*to
= dest
->data
;
308 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
309 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
310 GLfloat u
= (coord
[i
][0] - u1
) * du
;
311 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
313 _math_horner_bezier_surf(map
->Points
, &tmp
, u
, v
, 1,
314 map
->Uorder
, map
->Vorder
);
316 to
[i
] = (GLuint
) (GLint
) tmp
;
325 static void copy_4f( GLfloat to
[][4], GLfloat from
[][4], GLuint count
)
327 MEMCPY( to
, from
, count
* sizeof(to
[0]));
330 static void copy_4f_stride( GLfloat to
[][4], GLfloat
*from
,
331 GLuint stride
, GLuint count
)
333 if (stride
== 4 * sizeof(GLfloat
))
334 MEMCPY( to
, from
, count
* sizeof(to
[0]));
337 /* fprintf(stderr, "%s stride %d count %d\n", __FUNCTION__, */
338 /* stride, count); */
339 for (i
= 0 ; i
< count
; i
++, STRIDE_F(from
, stride
))
340 COPY_4FV( to
[i
], from
);
344 static void copy_3f( GLfloat to
[][3], GLfloat from
[][3], GLuint count
)
346 MEMCPY( to
, from
, (count
) * sizeof(to
[0]));
350 static void copy_1ui( GLuint to
[], GLuint from
[], GLuint count
)
352 MEMCPY( to
, from
, (count
) * sizeof(to
[0]));
357 /* Translate eval enabled flags to VERT_* flags.
359 static void update_eval( GLcontext
*ctx
)
361 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
362 GLuint eval1
= 0, eval2
= 0;
364 if (ctx
->Eval
.Map1Index
)
367 if (ctx
->Eval
.Map2Index
)
370 if (ctx
->Eval
.Map1Color4
)
373 if (ctx
->Eval
.Map2Color4
)
376 if (ctx
->Eval
.Map1Normal
)
379 if (ctx
->Eval
.Map2Normal
)
382 if (ctx
->Eval
.Map1TextureCoord4
||
383 ctx
->Eval
.Map1TextureCoord3
||
384 ctx
->Eval
.Map1TextureCoord2
||
385 ctx
->Eval
.Map1TextureCoord1
)
388 if (ctx
->Eval
.Map2TextureCoord4
||
389 ctx
->Eval
.Map2TextureCoord3
||
390 ctx
->Eval
.Map2TextureCoord2
||
391 ctx
->Eval
.Map2TextureCoord1
)
394 if (ctx
->Eval
.Map1Vertex4
)
395 eval1
|= VERT_OBJ_234
;
397 if (ctx
->Eval
.Map1Vertex3
)
398 eval1
|= VERT_OBJ_23
;
400 if (ctx
->Eval
.Map2Vertex4
) {
401 if (ctx
->Eval
.AutoNormal
)
402 eval2
|= VERT_OBJ_234
| VERT_NORM
;
404 eval2
|= VERT_OBJ_234
;
406 else if (ctx
->Eval
.Map2Vertex3
) {
407 if (ctx
->Eval
.AutoNormal
)
408 eval2
|= VERT_OBJ_23
| VERT_NORM
;
410 eval2
|= VERT_OBJ_23
;
413 tnl
->eval
.EvalMap1Flags
= eval1
;
414 tnl
->eval
.EvalMap2Flags
= eval2
;
415 tnl
->eval
.EvalNewState
= 0;
419 /* This looks a lot like a pipeline stage, but for various reasons is
420 * better handled outside the pipeline, and considered the final stage
421 * of fixing up an immediate struct for execution.
423 * Really want to cache the results of this function in display lists,
424 * at least for EvalMesh commands.
426 void _tnl_eval_immediate( GLcontext
*ctx
, struct immediate
*IM
)
428 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
429 struct vertex_arrays
*tmp
= &tnl
->imm_inputs
;
430 struct immediate
*store
= tnl
->eval
.im
;
431 GLuint
*flags
= IM
->Flag
+ IM
->CopyStart
;
433 GLuint orflag
= IM
->OrFlag
;
434 GLuint any_eval1
= orflag
& (VERT_EVAL_C1
|VERT_EVAL_P1
);
435 GLuint any_eval2
= orflag
& (VERT_EVAL_C2
|VERT_EVAL_P2
);
437 GLuint purge_flags
= 0;
438 GLfloat (*coord
)[4] = IM
->Obj
+ IM
->CopyStart
;
440 if (IM
->AndFlag
& VERT_EVAL_ANY
)
441 copycount
= IM
->Start
- IM
->CopyStart
; /* just copy copied vertices */
443 copycount
= IM
->Count
- IM
->CopyStart
; /* copy all vertices */
445 /* fprintf(stderr, "%s copystart %d start %d count %d copycount %d\n", */
446 /* __FUNCTION__, IM->CopyStart, IM->Start, IM->Count, copycount); */
449 store
= tnl
->eval
.im
= _tnl_alloc_immediate( ctx
);
451 if (tnl
->eval
.EvalNewState
& _NEW_EVAL
)
455 req
|= tnl
->pipeline
.inputs
& tnl
->eval
.EvalMap1Flags
;
457 if (!ctx
->Eval
.Map1Vertex4
&& !ctx
->Eval
.Map1Vertex3
)
458 purge_flags
= (VERT_EVAL_P1
|VERT_EVAL_C1
);
460 if (orflag
& VERT_EVAL_P1
) {
461 eval_points1( store
->Obj
+ IM
->CopyStart
,
463 ctx
->Eval
.MapGrid1du
,
464 ctx
->Eval
.MapGrid1u1
);
466 coord
= store
->Obj
+ IM
->CopyStart
;
471 req
|= tnl
->pipeline
.inputs
& tnl
->eval
.EvalMap2Flags
;
473 if (!ctx
->Eval
.Map2Vertex4
&& !ctx
->Eval
.Map2Vertex3
)
474 purge_flags
|= (VERT_EVAL_P2
|VERT_EVAL_C2
);
476 if (orflag
& VERT_EVAL_P2
) {
477 eval_points2( store
->Obj
+ IM
->CopyStart
,
479 ctx
->Eval
.MapGrid2du
,
480 ctx
->Eval
.MapGrid2u1
,
481 ctx
->Eval
.MapGrid2dv
,
482 ctx
->Eval
.MapGrid2v1
);
484 coord
= store
->Obj
+ IM
->CopyStart
;
489 /* _tnl_print_vert_flags(__FUNCTION__, req); */
491 /* Perform the evaluations on active data elements.
493 if (req
& VERT_INDEX
)
495 GLuint generated
= 0;
498 copy_1ui( store
->Index
+ IM
->CopyStart
, tmp
->Index
.data
, copycount
);
500 tmp
->Index
.data
= store
->Index
+ IM
->CopyStart
;
501 tmp
->Index
.start
= store
->Index
+ IM
->CopyStart
;
503 if (ctx
->Eval
.Map1Index
&& any_eval1
) {
504 eval1_1ui( &tmp
->Index
, coord
, flags
, &ctx
->EvalMap
.Map1Index
);
505 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
508 if (ctx
->Eval
.Map2Index
&& any_eval2
) {
509 eval2_1ui( &tmp
->Index
, coord
, flags
, &ctx
->EvalMap
.Map2Index
);
510 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
513 /* Propogate values to generate correct vertices when vertex
516 if (purge_flags
& generated
)
517 _tnl_fixup_1ui( tmp
->Index
.data
, flags
, 0,
521 (VERT_EVAL_ANY
&~purge_flags
) );
526 GLuint generated
= 0;
529 copy_4f_stride( store
->Color
+ IM
->CopyStart
,
530 (GLfloat
*)tmp
->Color
.Ptr
,
534 tmp
->Color
.Ptr
= store
->Color
+ IM
->CopyStart
;
535 tmp
->Color
.StrideB
= 4 * sizeof(GLfloat
);
536 tmp
->Color
.Flags
= 0;
537 tnl
->vb
.importable_data
&= ~VERT_RGBA
;
539 if (ctx
->Eval
.Map1Color4
&& any_eval1
) {
540 eval1_4f_ca( &tmp
->Color
, coord
, flags
, 4, &ctx
->EvalMap
.Map1Color4
);
541 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
544 if (ctx
->Eval
.Map2Color4
&& any_eval2
) {
545 eval2_4f_ca( &tmp
->Color
, coord
, flags
, 4, &ctx
->EvalMap
.Map2Color4
);
546 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
549 /* Propogate values to generate correct vertices when vertex
552 if (purge_flags
& generated
)
553 _tnl_fixup_4f( store
->Color
+ IM
->CopyStart
,
558 (VERT_EVAL_ANY
&~purge_flags
) );
562 if (req
& VERT_TEX(0))
564 GLuint generated
= 0;
567 copy_4f( store
->TexCoord
[0] + IM
->CopyStart
,
568 tmp
->TexCoord
[0].data
, copycount
);
570 tmp
->TexCoord
[0].size
= 0;
572 tmp
->TexCoord
[0].data
= store
->TexCoord
[0] + IM
->CopyStart
;
573 tmp
->TexCoord
[0].start
= (GLfloat
*)tmp
->TexCoord
[0].data
;
576 if (ctx
->Eval
.Map1TextureCoord4
) {
577 eval1_4f( &tmp
->TexCoord
[0], coord
, flags
, 4,
578 &ctx
->EvalMap
.Map1Texture4
);
579 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
581 else if (ctx
->Eval
.Map1TextureCoord3
) {
582 eval1_4f( &tmp
->TexCoord
[0], coord
, flags
, 3,
583 &ctx
->EvalMap
.Map1Texture3
);
584 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
586 else if (ctx
->Eval
.Map1TextureCoord2
) {
587 eval1_4f( &tmp
->TexCoord
[0], coord
, flags
, 2,
588 &ctx
->EvalMap
.Map1Texture2
);
589 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
591 else if (ctx
->Eval
.Map1TextureCoord1
) {
592 eval1_4f( &tmp
->TexCoord
[0], coord
, flags
, 1,
593 &ctx
->EvalMap
.Map1Texture1
);
594 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
599 if (ctx
->Eval
.Map2TextureCoord4
) {
600 eval2_4f( &tmp
->TexCoord
[0], coord
, flags
, 4,
601 &ctx
->EvalMap
.Map2Texture4
);
602 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
604 else if (ctx
->Eval
.Map2TextureCoord3
) {
605 eval2_4f( &tmp
->TexCoord
[0], coord
, flags
, 3,
606 &ctx
->EvalMap
.Map2Texture3
);
607 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
609 else if (ctx
->Eval
.Map2TextureCoord2
) {
610 eval2_4f( &tmp
->TexCoord
[0], coord
, flags
, 2,
611 &ctx
->EvalMap
.Map2Texture2
);
612 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
614 else if (ctx
->Eval
.Map2TextureCoord1
) {
615 eval2_4f( &tmp
->TexCoord
[0], coord
, flags
, 1,
616 &ctx
->EvalMap
.Map2Texture1
);
617 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
621 /* Propogate values to generate correct vertices when vertex
624 if (purge_flags
& generated
)
625 _tnl_fixup_4f( tmp
->TexCoord
[0].data
, flags
, 0,
629 (VERT_EVAL_ANY
&~purge_flags
) );
635 GLuint generated
= 0;
638 /* fprintf(stderr, "%s: Copy normals\n", __FUNCTION__); */
639 copy_3f( store
->Normal
+ IM
->CopyStart
, tmp
->Normal
.data
,
643 tmp
->Normal
.data
= store
->Normal
+ IM
->CopyStart
;
644 tmp
->Normal
.start
= (GLfloat
*)tmp
->Normal
.data
;
646 if (ctx
->Eval
.Map1Normal
&& any_eval1
) {
647 eval1_norm( &tmp
->Normal
, coord
, flags
,
648 &ctx
->EvalMap
.Map1Normal
);
649 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
652 if (ctx
->Eval
.Map2Normal
&& any_eval2
) {
653 eval2_norm( &tmp
->Normal
, coord
, flags
,
654 &ctx
->EvalMap
.Map2Normal
);
655 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
658 /* Propogate values to generate correct vertices when vertex
661 if (purge_flags
& generated
)
662 _tnl_fixup_3f( tmp
->Normal
.data
, flags
, 0,
666 (VERT_EVAL_ANY
&~purge_flags
) );
671 /* In the AutoNormal case, the copy and assignment of tmp->NormalPtr
677 /* This copy may already have occurred when eliminating
680 if (coord
!= store
->Obj
+ IM
->CopyStart
)
681 copy_4f( store
->Obj
+ IM
->CopyStart
, tmp
->Obj
.data
, copycount
);
685 tmp
->Obj
.data
= store
->Obj
+ IM
->CopyStart
;
686 tmp
->Obj
.start
= (GLfloat
*)tmp
->Obj
.data
;
688 /* Note: Normal data is already prepared above.
692 if (ctx
->Eval
.Map1Vertex4
) {
693 eval1_4f( &tmp
->Obj
, coord
, flags
, 4,
694 &ctx
->EvalMap
.Map1Vertex4
);
696 else if (ctx
->Eval
.Map1Vertex3
) {
697 eval1_4f( &tmp
->Obj
, coord
, flags
, 3,
698 &ctx
->EvalMap
.Map1Vertex3
);
703 if (ctx
->Eval
.Map2Vertex4
)
705 if (ctx
->Eval
.AutoNormal
&& (req
& VERT_NORM
))
706 eval2_obj_norm( &tmp
->Obj
, &tmp
->Normal
, coord
, flags
, 4,
707 &ctx
->EvalMap
.Map2Vertex4
);
709 eval2_4f( &tmp
->Obj
, coord
, flags
, 4,
710 &ctx
->EvalMap
.Map2Vertex4
);
712 else if (ctx
->Eval
.Map2Vertex3
)
714 if (ctx
->Eval
.AutoNormal
&& (req
& VERT_NORM
))
715 eval2_obj_norm( &tmp
->Obj
, &tmp
->Normal
, coord
, flags
, 3,
716 &ctx
->EvalMap
.Map2Vertex3
);
718 eval2_4f( &tmp
->Obj
, coord
, flags
, 3,
719 &ctx
->EvalMap
.Map2Vertex3
);
725 /* Calculate new IM->Elts, IM->Primitive, IM->PrimitiveLength for
726 * the case where vertex maps are not enabled for some received eval
730 GLuint vertex
= VERT_OBJ
|(VERT_EVAL_ANY
& ~purge_flags
);
731 GLuint last_new_prim
= 0;
732 GLuint new_prim_length
= 0;
733 GLuint next_old_prim
= 0;
734 struct vertex_buffer
*VB
= &tnl
->vb
;
735 GLuint i
,j
,count
= VB
->Count
;
737 /* fprintf(stderr, "PURGING\n"); */
739 for (i
= 0, j
= 0 ; i
< count
; i
++) {
740 if (flags
[i
] & vertex
) {
744 if (i
== next_old_prim
) {
745 next_old_prim
+= VB
->PrimitiveLength
[i
];
746 VB
->PrimitiveLength
[last_new_prim
] = new_prim_length
;
747 VB
->Primitive
[j
] = VB
->Primitive
[i
];
752 VB
->Elts
= store
->Elt
;
753 _tnl_get_purged_copy_verts( ctx
, store
);
756 /* Produce new flags array:
760 GLuint count
= tnl
->vb
.Count
+ 1;
762 copy_1ui( store
->Flag
, flags
, count
);
763 tnl
->vb
.Flag
= store
->Flag
;
764 for (i
= 0 ; i
< count
; i
++)
765 store
->Flag
[i
] |= req
;
766 IM
->CopyOrFlag
|= req
; /* hack for copying. */