1 /* $Id: t_imm_eval.c,v 1.16 2001/08/14 00:52:47 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 /* du[0] = du[0]*obj[i][3] - du[3]*obj[i][0]; */
210 /* du[1] = du[1]*obj[i][3] - du[3]*obj[i][1]; */
211 /* du[2] = du[2]*obj[i][3] - du[3]*obj[i][2]; */
213 /* dv[0] = dv[0]*obj[i][3] - dv[3]*obj[i][0]; */
214 /* dv[1] = dv[1]*obj[i][3] - dv[3]*obj[i][1]; */
215 /* dv[2] = dv[2]*obj[i][3] - dv[3]*obj[i][2]; */
217 CROSS3(normal
[i
], du
, dv
);
218 NORMALIZE_3FV(normal
[i
]);
221 obj_ptr
->size
= MAX2(obj_ptr
->size
, dimension
);
222 obj_ptr
->flags
|= dirty_flags
[dimension
];
226 static void eval2_4f( GLvector4f
*dest
,
230 struct gl_2d_map
*map
)
232 const GLfloat u1
= map
->u1
;
233 const GLfloat du
= map
->du
;
234 const GLfloat v1
= map
->v1
;
235 const GLfloat dv
= map
->dv
;
236 GLfloat (*to
)[4] = dest
->data
;
239 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
240 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
241 GLfloat u
= (coord
[i
][0] - u1
) * du
;
242 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
243 /* fprintf(stderr, "coord %d: %f %f\n", i, coord[i][0], coord[i][1]); */
245 _math_horner_bezier_surf(map
->Points
, to
[i
], u
, v
, dimension
,
246 map
->Uorder
, map
->Vorder
);
249 dest
->size
= MAX2(dest
->size
, dimension
);
250 dest
->flags
|= dirty_flags
[dimension
];
253 static void eval2_4f_ca( struct gl_client_array
*dest
,
257 struct gl_2d_map
*map
)
259 const GLfloat u1
= map
->u1
;
260 const GLfloat du
= map
->du
;
261 const GLfloat v1
= map
->v1
;
262 const GLfloat dv
= map
->dv
;
263 GLfloat (*to
)[4] = (GLfloat (*)[4])dest
->Ptr
;
266 ASSERT(dest
->Type
== GL_FLOAT
);
267 ASSERT(dest
->StrideB
== 4 * sizeof(GLfloat
));
269 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
270 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
271 GLfloat u
= (coord
[i
][0] - u1
) * du
;
272 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
273 _math_horner_bezier_surf(map
->Points
, to
[i
], u
, v
, dimension
,
274 map
->Uorder
, map
->Vorder
);
277 dest
->Size
= MAX2(dest
->Size
, (GLint
) dimension
);
281 static void eval2_norm( GLvector3f
*dest
,
284 struct gl_2d_map
*map
)
286 const GLfloat u1
= map
->u1
;
287 const GLfloat du
= map
->du
;
288 const GLfloat v1
= map
->v1
;
289 const GLfloat dv
= map
->dv
;
290 GLfloat (*to
)[3] = dest
->data
;
293 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
294 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
295 GLfloat u
= (coord
[i
][0] - u1
) * du
;
296 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
297 _math_horner_bezier_surf(map
->Points
, to
[i
], u
, v
, 3,
298 map
->Uorder
, map
->Vorder
);
304 static void eval2_1ui( GLvector1ui
*dest
,
307 struct gl_2d_map
*map
)
309 const GLfloat u1
= map
->u1
;
310 const GLfloat du
= map
->du
;
311 const GLfloat v1
= map
->v1
;
312 const GLfloat dv
= map
->dv
;
313 GLuint
*to
= dest
->data
;
316 for (i
= 0 ; !(flags
[i
] & VERT_END_VB
) ; i
++)
317 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
318 GLfloat u
= (coord
[i
][0] - u1
) * du
;
319 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
321 _math_horner_bezier_surf(map
->Points
, &tmp
, u
, v
, 1,
322 map
->Uorder
, map
->Vorder
);
324 to
[i
] = (GLuint
) (GLint
) tmp
;
333 static void copy_4f( GLfloat to
[][4], GLfloat from
[][4], GLuint count
)
335 MEMCPY( to
, from
, count
* sizeof(to
[0]));
338 static void copy_4f_stride( GLfloat to
[][4], GLfloat
*from
,
339 GLuint stride
, GLuint count
)
341 if (stride
== 4 * sizeof(GLfloat
))
342 MEMCPY( to
, from
, count
* sizeof(to
[0]));
345 /* fprintf(stderr, "%s stride %d count %d\n", __FUNCTION__, */
346 /* stride, count); */
347 for (i
= 0 ; i
< count
; i
++, STRIDE_F(from
, stride
))
348 COPY_4FV( to
[i
], from
);
352 static void copy_3f( GLfloat to
[][3], GLfloat from
[][3], GLuint count
)
355 /* MEMCPY( to, from, (count) * sizeof(to[0])); */
356 for (i
= 0 ; i
< count
; i
++) {
357 /* fprintf(stderr, "copy norm %d from %p: %f %f %f\n", i, */
359 /* from[i][0], from[i][1], from[i][2]); */
360 COPY_3FV(to
[i
], from
[i
]);
365 static void copy_1ui( GLuint to
[], GLuint from
[], GLuint count
)
367 MEMCPY( to
, from
, (count
) * sizeof(to
[0]));
372 /* Translate eval enabled flags to VERT_* flags.
374 static void update_eval( GLcontext
*ctx
)
376 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
377 GLuint eval1
= 0, eval2
= 0;
379 if (ctx
->Eval
.Map1Index
)
382 if (ctx
->Eval
.Map2Index
)
385 if (ctx
->Eval
.Map1Color4
)
388 if (ctx
->Eval
.Map2Color4
)
391 if (ctx
->Eval
.Map1Normal
)
394 if (ctx
->Eval
.Map2Normal
)
397 if (ctx
->Eval
.Map1TextureCoord4
||
398 ctx
->Eval
.Map1TextureCoord3
||
399 ctx
->Eval
.Map1TextureCoord2
||
400 ctx
->Eval
.Map1TextureCoord1
)
403 if (ctx
->Eval
.Map2TextureCoord4
||
404 ctx
->Eval
.Map2TextureCoord3
||
405 ctx
->Eval
.Map2TextureCoord2
||
406 ctx
->Eval
.Map2TextureCoord1
)
409 if (ctx
->Eval
.Map1Vertex4
)
410 eval1
|= VERT_OBJ_234
;
412 if (ctx
->Eval
.Map1Vertex3
)
413 eval1
|= VERT_OBJ_23
;
415 if (ctx
->Eval
.Map2Vertex4
) {
416 if (ctx
->Eval
.AutoNormal
)
417 eval2
|= VERT_OBJ_234
| VERT_NORM
;
419 eval2
|= VERT_OBJ_234
;
421 else if (ctx
->Eval
.Map2Vertex3
) {
422 if (ctx
->Eval
.AutoNormal
)
423 eval2
|= VERT_OBJ_23
| VERT_NORM
;
425 eval2
|= VERT_OBJ_23
;
428 tnl
->eval
.EvalMap1Flags
= eval1
;
429 tnl
->eval
.EvalMap2Flags
= eval2
;
430 tnl
->eval
.EvalNewState
= 0;
434 /* This looks a lot like a pipeline stage, but for various reasons is
435 * better handled outside the pipeline, and considered the final stage
436 * of fixing up an immediate struct for execution.
438 * Really want to cache the results of this function in display lists,
439 * at least for EvalMesh commands.
441 void _tnl_eval_immediate( GLcontext
*ctx
, struct immediate
*IM
)
443 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
444 struct vertex_arrays
*tmp
= &tnl
->imm_inputs
;
445 struct immediate
*store
= tnl
->eval
.im
;
446 GLuint
*flags
= IM
->Flag
+ IM
->CopyStart
;
448 GLuint orflag
= IM
->OrFlag
;
449 GLuint any_eval1
= orflag
& (VERT_EVAL_C1
|VERT_EVAL_P1
);
450 GLuint any_eval2
= orflag
& (VERT_EVAL_C2
|VERT_EVAL_P2
);
452 GLuint purge_flags
= 0;
453 GLfloat (*coord
)[4] = IM
->Obj
+ IM
->CopyStart
;
455 if (IM
->AndFlag
& VERT_EVAL_ANY
)
456 copycount
= IM
->Start
- IM
->CopyStart
; /* just copy copied vertices */
458 copycount
= IM
->Count
- IM
->CopyStart
; /* copy all vertices */
460 /* fprintf(stderr, "%s copystart %d start %d count %d copycount %d\n", */
461 /* __FUNCTION__, IM->CopyStart, IM->Start, IM->Count, copycount); */
464 store
= tnl
->eval
.im
= _tnl_alloc_immediate( ctx
);
466 if (tnl
->eval
.EvalNewState
& _NEW_EVAL
)
470 req
|= tnl
->pipeline
.inputs
& tnl
->eval
.EvalMap1Flags
;
472 if (!ctx
->Eval
.Map1Vertex4
&& !ctx
->Eval
.Map1Vertex3
)
473 purge_flags
= (VERT_EVAL_P1
|VERT_EVAL_C1
);
475 if (orflag
& VERT_EVAL_P1
) {
476 eval_points1( store
->Obj
+ IM
->CopyStart
,
478 ctx
->Eval
.MapGrid1du
,
479 ctx
->Eval
.MapGrid1u1
);
481 coord
= store
->Obj
+ IM
->CopyStart
;
486 req
|= tnl
->pipeline
.inputs
& tnl
->eval
.EvalMap2Flags
;
488 if (!ctx
->Eval
.Map2Vertex4
&& !ctx
->Eval
.Map2Vertex3
)
489 purge_flags
|= (VERT_EVAL_P2
|VERT_EVAL_C2
);
491 if (orflag
& VERT_EVAL_P2
) {
492 eval_points2( store
->Obj
+ IM
->CopyStart
,
494 ctx
->Eval
.MapGrid2du
,
495 ctx
->Eval
.MapGrid2u1
,
496 ctx
->Eval
.MapGrid2dv
,
497 ctx
->Eval
.MapGrid2v1
);
499 coord
= store
->Obj
+ IM
->CopyStart
;
504 /* _tnl_print_vert_flags(__FUNCTION__, req); */
506 /* Perform the evaluations on active data elements.
508 if (req
& VERT_INDEX
)
510 GLuint generated
= 0;
513 copy_1ui( store
->Index
+ IM
->CopyStart
, tmp
->Index
.data
, copycount
);
515 tmp
->Index
.data
= store
->Index
+ IM
->CopyStart
;
516 tmp
->Index
.start
= store
->Index
+ IM
->CopyStart
;
518 if (ctx
->Eval
.Map1Index
&& any_eval1
) {
519 eval1_1ui( &tmp
->Index
, coord
, flags
, &ctx
->EvalMap
.Map1Index
);
520 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
523 if (ctx
->Eval
.Map2Index
&& any_eval2
) {
524 eval2_1ui( &tmp
->Index
, coord
, flags
, &ctx
->EvalMap
.Map2Index
);
525 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
531 GLuint generated
= 0;
534 copy_4f_stride( store
->Color
+ IM
->CopyStart
,
535 (GLfloat
*)tmp
->Color
.Ptr
,
539 tmp
->Color
.Ptr
= store
->Color
+ IM
->CopyStart
;
540 tmp
->Color
.StrideB
= 4 * sizeof(GLfloat
);
541 tmp
->Color
.Flags
= 0;
542 tnl
->vb
.importable_data
&= ~VERT_RGBA
;
544 if (ctx
->Eval
.Map1Color4
&& any_eval1
) {
545 eval1_4f_ca( &tmp
->Color
, coord
, flags
, 4, &ctx
->EvalMap
.Map1Color4
);
546 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
549 if (ctx
->Eval
.Map2Color4
&& any_eval2
) {
550 eval2_4f_ca( &tmp
->Color
, coord
, flags
, 4, &ctx
->EvalMap
.Map2Color4
);
551 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
556 if (req
& VERT_TEX(0))
558 GLuint generated
= 0;
561 copy_4f( store
->TexCoord
[0] + IM
->CopyStart
,
562 tmp
->TexCoord
[0].data
, copycount
);
564 tmp
->TexCoord
[0].size
= 0;
566 tmp
->TexCoord
[0].data
= store
->TexCoord
[0] + IM
->CopyStart
;
567 tmp
->TexCoord
[0].start
= (GLfloat
*)tmp
->TexCoord
[0].data
;
570 if (ctx
->Eval
.Map1TextureCoord4
) {
571 eval1_4f( &tmp
->TexCoord
[0], coord
, flags
, 4,
572 &ctx
->EvalMap
.Map1Texture4
);
573 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
575 else if (ctx
->Eval
.Map1TextureCoord3
) {
576 eval1_4f( &tmp
->TexCoord
[0], coord
, flags
, 3,
577 &ctx
->EvalMap
.Map1Texture3
);
578 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
580 else if (ctx
->Eval
.Map1TextureCoord2
) {
581 eval1_4f( &tmp
->TexCoord
[0], coord
, flags
, 2,
582 &ctx
->EvalMap
.Map1Texture2
);
583 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
585 else if (ctx
->Eval
.Map1TextureCoord1
) {
586 eval1_4f( &tmp
->TexCoord
[0], coord
, flags
, 1,
587 &ctx
->EvalMap
.Map1Texture1
);
588 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
593 if (ctx
->Eval
.Map2TextureCoord4
) {
594 eval2_4f( &tmp
->TexCoord
[0], coord
, flags
, 4,
595 &ctx
->EvalMap
.Map2Texture4
);
596 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
598 else if (ctx
->Eval
.Map2TextureCoord3
) {
599 eval2_4f( &tmp
->TexCoord
[0], coord
, flags
, 3,
600 &ctx
->EvalMap
.Map2Texture3
);
601 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
603 else if (ctx
->Eval
.Map2TextureCoord2
) {
604 eval2_4f( &tmp
->TexCoord
[0], coord
, flags
, 2,
605 &ctx
->EvalMap
.Map2Texture2
);
606 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
608 else if (ctx
->Eval
.Map2TextureCoord1
) {
609 eval2_4f( &tmp
->TexCoord
[0], coord
, flags
, 1,
610 &ctx
->EvalMap
.Map2Texture1
);
611 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
619 GLuint generated
= 0;
622 /* fprintf(stderr, "%s: Copy normals\n", __FUNCTION__); */
623 copy_3f( store
->Normal
+ IM
->CopyStart
, tmp
->Normal
.data
,
627 tmp
->Normal
.data
= store
->Normal
+ IM
->CopyStart
;
628 tmp
->Normal
.start
= (GLfloat
*)tmp
->Normal
.data
;
630 if (ctx
->Eval
.Map1Normal
&& any_eval1
) {
631 eval1_norm( &tmp
->Normal
, coord
, flags
,
632 &ctx
->EvalMap
.Map1Normal
);
633 generated
|= VERT_EVAL_C1
|VERT_EVAL_P1
;
636 if (ctx
->Eval
.Map2Normal
&& any_eval2
) {
637 eval2_norm( &tmp
->Normal
, coord
, flags
,
638 &ctx
->EvalMap
.Map2Normal
);
639 generated
|= VERT_EVAL_C2
|VERT_EVAL_P2
;
645 /* In the AutoNormal case, the copy and assignment of tmp->NormalPtr
651 /* This copy may already have occurred when eliminating
654 if (coord
!= store
->Obj
+ IM
->CopyStart
)
655 copy_4f( store
->Obj
+ IM
->CopyStart
, tmp
->Obj
.data
, copycount
);
659 tmp
->Obj
.data
= store
->Obj
+ IM
->CopyStart
;
660 tmp
->Obj
.start
= (GLfloat
*)tmp
->Obj
.data
;
662 /* Note: Normal data is already prepared above.
666 if (ctx
->Eval
.Map1Vertex4
) {
667 eval1_4f( &tmp
->Obj
, coord
, flags
, 4,
668 &ctx
->EvalMap
.Map1Vertex4
);
670 else if (ctx
->Eval
.Map1Vertex3
) {
671 eval1_4f( &tmp
->Obj
, coord
, flags
, 3,
672 &ctx
->EvalMap
.Map1Vertex3
);
677 if (ctx
->Eval
.Map2Vertex4
)
679 if (ctx
->Eval
.AutoNormal
&& (req
& VERT_NORM
))
680 eval2_obj_norm( &tmp
->Obj
, &tmp
->Normal
, coord
, flags
, 4,
681 &ctx
->EvalMap
.Map2Vertex4
);
683 eval2_4f( &tmp
->Obj
, coord
, flags
, 4,
684 &ctx
->EvalMap
.Map2Vertex4
);
686 else if (ctx
->Eval
.Map2Vertex3
)
688 if (ctx
->Eval
.AutoNormal
&& (req
& VERT_NORM
))
689 eval2_obj_norm( &tmp
->Obj
, &tmp
->Normal
, coord
, flags
, 3,
690 &ctx
->EvalMap
.Map2Vertex3
);
692 eval2_4f( &tmp
->Obj
, coord
, flags
, 3,
693 &ctx
->EvalMap
.Map2Vertex3
);
699 /* Calculate new IM->Elts, IM->Primitive, IM->PrimitiveLength for
700 * the case where vertex maps are not enabled for some received
701 * eval coordinates. In this case those slots in the immediate
705 GLuint vertex
= VERT_OBJ
|(VERT_EVAL_ANY
& ~purge_flags
);
706 GLuint last_new_prim
= 0;
707 GLuint new_prim_length
= 0;
708 GLuint next_old_prim
= 0;
709 struct vertex_buffer
*VB
= &tnl
->vb
;
710 GLuint i
,j
,count
= VB
->Count
;
712 /* fprintf(stderr, "PURGING\n"); */
714 for (i
= 0, j
= 0 ; i
< count
; i
++) {
715 if (flags
[i
] & vertex
) {
719 if (i
== next_old_prim
) {
720 next_old_prim
+= VB
->PrimitiveLength
[i
];
721 VB
->PrimitiveLength
[last_new_prim
] = new_prim_length
;
722 VB
->Primitive
[j
] = VB
->Primitive
[i
];
727 VB
->Elts
= store
->Elt
;
728 _tnl_get_purged_copy_verts( ctx
, store
);
731 /* Produce new flags array:
735 GLuint count
= tnl
->vb
.Count
+ 1;
737 copy_1ui( store
->Flag
, flags
, count
);
738 tnl
->vb
.Flag
= store
->Flag
;
739 for (i
= 0 ; i
< count
; i
++)
740 store
->Flag
[i
] |= req
;
741 IM
->Evaluated
= req
; /* hack for copying. */