init secondary color to (0,0,0,1). remove some redundant initializations.
[mesa.git] / src / mesa / main / dlist.c
1 /**
2 * \file dlist.c
3 * Display lists management functions.
4 */
5
6 /*
7 * Mesa 3-D graphics library
8 * Version: 6.0
9 *
10 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30
31 #include "glheader.h"
32 #include "imports.h"
33 #include "api_arrayelt.h"
34 #include "api_loopback.h"
35 #include "config.h"
36 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
37 #include "arbprogram.h"
38 #include "program.h"
39 #endif
40 #include "attrib.h"
41 #include "blend.h"
42 #include "buffers.h"
43 #if FEATURE_ARB_vertex_buffer_object
44 #include "bufferobj.h"
45 #endif
46 #include "clip.h"
47 #include "colormac.h"
48 #include "colortab.h"
49 #include "context.h"
50 #include "convolve.h"
51 #include "depth.h"
52 #include "dlist.h"
53 #include "enable.h"
54 #include "enums.h"
55 #include "eval.h"
56 #include "extensions.h"
57 #include "feedback.h"
58 #include "get.h"
59 #include "glapi.h"
60 #include "hash.h"
61 #include "histogram.h"
62 #include "image.h"
63 #include "light.h"
64 #include "lines.h"
65 #include "dlist.h"
66 #include "macros.h"
67 #include "matrix.h"
68 #include "pixel.h"
69 #include "points.h"
70 #include "polygon.h"
71 #include "state.h"
72 #include "texobj.h"
73 #include "teximage.h"
74 #include "texstate.h"
75 #include "mtypes.h"
76 #include "varray.h"
77 #if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
78 #include "nvprogram.h"
79 #include "program.h"
80 #endif
81
82 #include "math/m_matrix.h"
83 #include "math/m_xform.h"
84
85
86 /**
87 * Flush vertices.
88 *
89 * \param ctx GL context.
90 *
91 * Checks if dd_function_table::SaveNeedFlush is marked to flush
92 * stored (save) vertices, and calls
93 * dd_function_table::SaveFlushVertices if so.
94 */
95 #define SAVE_FLUSH_VERTICES(ctx) \
96 do { \
97 if (ctx->Driver.SaveNeedFlush) \
98 ctx->Driver.SaveFlushVertices(ctx); \
99 } while (0)
100
101
102 /**
103 * Macro to assert that the API call was made outside the
104 * glBegin()/glEnd() pair, with return value.
105 *
106 * \param ctx GL context.
107 * \param retval value to return value in case the assertion fails.
108 */
109 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \
110 do { \
111 if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \
112 ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
113 _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
114 return retval; \
115 } \
116 } while (0)
117
118 /**
119 * Macro to assert that the API call was made outside the
120 * glBegin()/glEnd() pair.
121 *
122 * \param ctx GL context.
123 */
124 #define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx) \
125 do { \
126 if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \
127 ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
128 _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
129 return; \
130 } \
131 } while (0)
132
133 /**
134 * Macro to assert that the API call was made outside the
135 * glBegin()/glEnd() pair and flush the vertices.
136 *
137 * \param ctx GL context.
138 */
139 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \
140 do { \
141 ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \
142 SAVE_FLUSH_VERTICES(ctx); \
143 } while (0)
144
145 /**
146 * Macro to assert that the API call was made outside the
147 * glBegin()/glEnd() pair and flush the vertices, with return value.
148 *
149 * \param ctx GL context.
150 * \param retval value to return value in case the assertion fails.
151 */
152 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\
153 do { \
154 ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \
155 SAVE_FLUSH_VERTICES(ctx); \
156 } while (0)
157
158
159
160 /**
161 * Display list opcodes.
162 *
163 * The fact that these identifiers are assigned consecutive
164 * integer values starting at 0 is very important, see InstSize array usage)
165 */
166 typedef enum {
167 OPCODE_ACCUM,
168 OPCODE_ALPHA_FUNC,
169 OPCODE_BIND_TEXTURE,
170 OPCODE_BITMAP,
171 OPCODE_BLEND_COLOR,
172 OPCODE_BLEND_EQUATION,
173 OPCODE_BLEND_EQUATION_SEPARATE,
174 OPCODE_BLEND_FUNC_SEPARATE,
175 OPCODE_CALL_LIST,
176 OPCODE_CALL_LIST_OFFSET,
177 OPCODE_CLEAR,
178 OPCODE_CLEAR_ACCUM,
179 OPCODE_CLEAR_COLOR,
180 OPCODE_CLEAR_DEPTH,
181 OPCODE_CLEAR_INDEX,
182 OPCODE_CLEAR_STENCIL,
183 OPCODE_CLIP_PLANE,
184 OPCODE_COLOR_MASK,
185 OPCODE_COLOR_MATERIAL,
186 OPCODE_COLOR_TABLE,
187 OPCODE_COLOR_TABLE_PARAMETER_FV,
188 OPCODE_COLOR_TABLE_PARAMETER_IV,
189 OPCODE_COLOR_SUB_TABLE,
190 OPCODE_CONVOLUTION_FILTER_1D,
191 OPCODE_CONVOLUTION_FILTER_2D,
192 OPCODE_CONVOLUTION_PARAMETER_I,
193 OPCODE_CONVOLUTION_PARAMETER_IV,
194 OPCODE_CONVOLUTION_PARAMETER_F,
195 OPCODE_CONVOLUTION_PARAMETER_FV,
196 OPCODE_COPY_COLOR_SUB_TABLE,
197 OPCODE_COPY_COLOR_TABLE,
198 OPCODE_COPY_PIXELS,
199 OPCODE_COPY_TEX_IMAGE1D,
200 OPCODE_COPY_TEX_IMAGE2D,
201 OPCODE_COPY_TEX_SUB_IMAGE1D,
202 OPCODE_COPY_TEX_SUB_IMAGE2D,
203 OPCODE_COPY_TEX_SUB_IMAGE3D,
204 OPCODE_CULL_FACE,
205 OPCODE_DEPTH_FUNC,
206 OPCODE_DEPTH_MASK,
207 OPCODE_DEPTH_RANGE,
208 OPCODE_DISABLE,
209 OPCODE_DRAW_BUFFER,
210 OPCODE_DRAW_PIXELS,
211 OPCODE_ENABLE,
212 OPCODE_EVALMESH1,
213 OPCODE_EVALMESH2,
214 OPCODE_FOG,
215 OPCODE_FRONT_FACE,
216 OPCODE_FRUSTUM,
217 OPCODE_HINT,
218 OPCODE_HISTOGRAM,
219 OPCODE_INDEX_MASK,
220 OPCODE_INIT_NAMES,
221 OPCODE_LIGHT,
222 OPCODE_LIGHT_MODEL,
223 OPCODE_LINE_STIPPLE,
224 OPCODE_LINE_WIDTH,
225 OPCODE_LIST_BASE,
226 OPCODE_LOAD_IDENTITY,
227 OPCODE_LOAD_MATRIX,
228 OPCODE_LOAD_NAME,
229 OPCODE_LOGIC_OP,
230 OPCODE_MAP1,
231 OPCODE_MAP2,
232 OPCODE_MAPGRID1,
233 OPCODE_MAPGRID2,
234 OPCODE_MATRIX_MODE,
235 OPCODE_MIN_MAX,
236 OPCODE_MULT_MATRIX,
237 OPCODE_ORTHO,
238 OPCODE_PASSTHROUGH,
239 OPCODE_PIXEL_MAP,
240 OPCODE_PIXEL_TRANSFER,
241 OPCODE_PIXEL_ZOOM,
242 OPCODE_POINT_SIZE,
243 OPCODE_POINT_PARAMETERS,
244 OPCODE_POLYGON_MODE,
245 OPCODE_POLYGON_STIPPLE,
246 OPCODE_POLYGON_OFFSET,
247 OPCODE_POP_ATTRIB,
248 OPCODE_POP_MATRIX,
249 OPCODE_POP_NAME,
250 OPCODE_PRIORITIZE_TEXTURE,
251 OPCODE_PUSH_ATTRIB,
252 OPCODE_PUSH_MATRIX,
253 OPCODE_PUSH_NAME,
254 OPCODE_RASTER_POS,
255 OPCODE_READ_BUFFER,
256 OPCODE_RESET_HISTOGRAM,
257 OPCODE_RESET_MIN_MAX,
258 OPCODE_ROTATE,
259 OPCODE_SCALE,
260 OPCODE_SCISSOR,
261 OPCODE_SELECT_TEXTURE_SGIS,
262 OPCODE_SELECT_TEXTURE_COORD_SET,
263 OPCODE_SHADE_MODEL,
264 OPCODE_STENCIL_FUNC,
265 OPCODE_STENCIL_MASK,
266 OPCODE_STENCIL_OP,
267 OPCODE_TEXENV,
268 OPCODE_TEXGEN,
269 OPCODE_TEXPARAMETER,
270 OPCODE_TEX_IMAGE1D,
271 OPCODE_TEX_IMAGE2D,
272 OPCODE_TEX_IMAGE3D,
273 OPCODE_TEX_SUB_IMAGE1D,
274 OPCODE_TEX_SUB_IMAGE2D,
275 OPCODE_TEX_SUB_IMAGE3D,
276 OPCODE_TRANSLATE,
277 OPCODE_VIEWPORT,
278 OPCODE_WINDOW_POS,
279 /* GL_ARB_multitexture */
280 OPCODE_ACTIVE_TEXTURE,
281 /* GL_SGIX/SGIS_pixel_texture */
282 OPCODE_PIXEL_TEXGEN_SGIX,
283 OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS,
284 /* GL_ARB_texture_compression */
285 OPCODE_COMPRESSED_TEX_IMAGE_1D,
286 OPCODE_COMPRESSED_TEX_IMAGE_2D,
287 OPCODE_COMPRESSED_TEX_IMAGE_3D,
288 OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
289 OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
290 OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
291 /* GL_ARB_multisample */
292 OPCODE_SAMPLE_COVERAGE,
293 /* GL_ARB_window_pos */
294 OPCODE_WINDOW_POS_ARB,
295 /* GL_NV_vertex_program */
296 OPCODE_BIND_PROGRAM_NV,
297 OPCODE_EXECUTE_PROGRAM_NV,
298 OPCODE_REQUEST_RESIDENT_PROGRAMS_NV,
299 OPCODE_LOAD_PROGRAM_NV,
300 OPCODE_PROGRAM_PARAMETER4F_NV,
301 OPCODE_TRACK_MATRIX_NV,
302 /* GL_NV_fragment_program */
303 OPCODE_PROGRAM_LOCAL_PARAMETER_ARB,
304 OPCODE_PROGRAM_NAMED_PARAMETER_NV,
305 /* GL_EXT_stencil_two_side */
306 OPCODE_ACTIVE_STENCIL_FACE_EXT,
307 /* GL_EXT_depth_bounds_test */
308 OPCODE_DEPTH_BOUNDS_EXT,
309 /* GL_ARB_vertex/fragment_program */
310 OPCODE_PROGRAM_STRING_ARB,
311 OPCODE_PROGRAM_ENV_PARAMETER_ARB,
312
313
314 /* Vertex attributes -- fallback for when optimized display
315 * list build isn't active.
316 */
317 OPCODE_ATTR_1F,
318 OPCODE_ATTR_2F,
319 OPCODE_ATTR_3F,
320 OPCODE_ATTR_4F,
321 OPCODE_MATERIAL,
322 OPCODE_INDEX,
323 OPCODE_EDGEFLAG,
324 OPCODE_BEGIN,
325 OPCODE_END,
326 OPCODE_RECTF,
327 OPCODE_EVAL_C1,
328 OPCODE_EVAL_C2,
329 OPCODE_EVAL_P1,
330 OPCODE_EVAL_P2,
331
332
333 /* The following three are meta instructions */
334 OPCODE_ERROR, /* raise compiled-in error */
335 OPCODE_CONTINUE,
336 OPCODE_END_OF_LIST,
337 OPCODE_DRV_0
338 } OpCode;
339
340
341
342 /**
343 * Display list node.
344 *
345 * Display list instructions are stored as sequences of "nodes". Nodes
346 * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
347 * are linked together with a pointer.
348 *
349 * Each instruction in the display list is stored as a sequence of
350 * contiguous nodes in memory.
351 * Each node is the union of a variety of data types.
352 */
353 union node {
354 OpCode opcode;
355 GLboolean b;
356 GLbitfield bf;
357 GLubyte ub;
358 GLshort s;
359 GLushort us;
360 GLint i;
361 GLuint ui;
362 GLenum e;
363 GLfloat f;
364 GLvoid *data;
365 void *next; /* If prev node's opcode==OPCODE_CONTINUE */
366 };
367
368
369 /**
370 * How many nodes to allocate at a time.
371 *
372 * \note Reduced now that we hold vertices etc. elsewhere.
373 */
374 #define BLOCK_SIZE 256
375
376
377
378 /**
379 * Number of nodes of storage needed for each instruction.
380 * Sizes for dynamically allocated opcodes are stored in the context struct.
381 */
382 static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
383
384 void mesa_print_display_list( GLuint list );
385
386
387 /**********************************************************************/
388 /***** Private *****/
389 /**********************************************************************/
390
391 /*
392 * Make an empty display list. This is used by glGenLists() to
393 * reserver display list IDs.
394 */
395 static Node *make_empty_list( void )
396 {
397 Node *n = (Node *) MALLOC( sizeof(Node) );
398 n[0].opcode = OPCODE_END_OF_LIST;
399 return n;
400 }
401
402
403
404 /*
405 * Destroy all nodes in a display list.
406 * \param list - display list number
407 */
408 void _mesa_destroy_list( GLcontext *ctx, GLuint list )
409 {
410 Node *n, *block;
411 GLboolean done;
412
413 if (list==0)
414 return;
415
416 block = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
417 n = block;
418
419 done = block ? GL_FALSE : GL_TRUE;
420 while (!done) {
421
422 /* check for extension opcodes first */
423
424 GLint i = (GLint) n[0].opcode - (GLint) OPCODE_DRV_0;
425 if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
426 ctx->listext.opcode[i].destroy(ctx, &n[1]);
427 n += ctx->listext.opcode[i].size;
428 }
429 else {
430 switch (n[0].opcode) {
431 /* for some commands, we need to free malloc'd memory */
432 case OPCODE_MAP1:
433 FREE(n[6].data);
434 n += InstSize[n[0].opcode];
435 break;
436 case OPCODE_MAP2:
437 FREE(n[10].data);
438 n += InstSize[n[0].opcode];
439 break;
440 case OPCODE_DRAW_PIXELS:
441 FREE( n[5].data );
442 n += InstSize[n[0].opcode];
443 break;
444 case OPCODE_BITMAP:
445 FREE( n[7].data );
446 n += InstSize[n[0].opcode];
447 break;
448 case OPCODE_COLOR_TABLE:
449 FREE( n[6].data );
450 n += InstSize[n[0].opcode];
451 break;
452 case OPCODE_COLOR_SUB_TABLE:
453 FREE( n[6].data );
454 n += InstSize[n[0].opcode];
455 break;
456 case OPCODE_CONVOLUTION_FILTER_1D:
457 FREE( n[6].data );
458 n += InstSize[n[0].opcode];
459 break;
460 case OPCODE_CONVOLUTION_FILTER_2D:
461 FREE( n[7].data );
462 n += InstSize[n[0].opcode];
463 break;
464 case OPCODE_POLYGON_STIPPLE:
465 FREE( n[1].data );
466 n += InstSize[n[0].opcode];
467 break;
468 case OPCODE_TEX_IMAGE1D:
469 FREE(n[8].data);
470 n += InstSize[n[0].opcode];
471 break;
472 case OPCODE_TEX_IMAGE2D:
473 FREE( n[9]. data );
474 n += InstSize[n[0].opcode];
475 break;
476 case OPCODE_TEX_IMAGE3D:
477 FREE( n[10]. data );
478 n += InstSize[n[0].opcode];
479 break;
480 case OPCODE_TEX_SUB_IMAGE1D:
481 FREE(n[7].data);
482 n += InstSize[n[0].opcode];
483 break;
484 case OPCODE_TEX_SUB_IMAGE2D:
485 FREE(n[9].data);
486 n += InstSize[n[0].opcode];
487 break;
488 case OPCODE_TEX_SUB_IMAGE3D:
489 FREE(n[11].data);
490 n += InstSize[n[0].opcode];
491 break;
492 case OPCODE_COMPRESSED_TEX_IMAGE_1D:
493 FREE(n[7].data);
494 n += InstSize[n[0].opcode];
495 break;
496 case OPCODE_COMPRESSED_TEX_IMAGE_2D:
497 FREE(n[8].data);
498 n += InstSize[n[0].opcode];
499 break;
500 case OPCODE_COMPRESSED_TEX_IMAGE_3D:
501 FREE(n[9].data);
502 n += InstSize[n[0].opcode];
503 break;
504 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:
505 FREE(n[7].data);
506 n += InstSize[n[0].opcode];
507 break;
508 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:
509 FREE(n[9].data);
510 n += InstSize[n[0].opcode];
511 break;
512 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:
513 FREE(n[11].data);
514 n += InstSize[n[0].opcode];
515 break;
516 #if FEATURE_NV_vertex_program
517 case OPCODE_LOAD_PROGRAM_NV:
518 FREE(n[4].data); /* program string */
519 n += InstSize[n[0].opcode];
520 break;
521 case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
522 FREE(n[2].data); /* array of program ids */
523 n += InstSize[n[0].opcode];
524 break;
525 #endif
526 #if FEATURE_NV_fragment_program
527 case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
528 FREE(n[3].data); /* parameter name */
529 n += InstSize[n[0].opcode];
530 break;
531 #endif
532 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
533 case OPCODE_PROGRAM_STRING_ARB:
534 FREE(n[4].data); /* program string */
535 n += InstSize[n[0].opcode];
536 break;
537 #endif
538 case OPCODE_CONTINUE:
539 n = (Node *) n[1].next;
540 FREE( block );
541 block = n;
542 break;
543 case OPCODE_END_OF_LIST:
544 FREE( block );
545 done = GL_TRUE;
546 break;
547 default:
548 /* Most frequent case */
549 n += InstSize[n[0].opcode];
550 break;
551 }
552 }
553 }
554
555 _mesa_HashRemove(ctx->Shared->DisplayList, list);
556 }
557
558
559
560 /*
561 * Translate the nth element of list from type to GLuint.
562 */
563 static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
564 {
565 GLbyte *bptr;
566 GLubyte *ubptr;
567 GLshort *sptr;
568 GLushort *usptr;
569 GLint *iptr;
570 GLuint *uiptr;
571 GLfloat *fptr;
572
573 switch (type) {
574 case GL_BYTE:
575 bptr = (GLbyte *) list;
576 return (GLuint) *(bptr+n);
577 case GL_UNSIGNED_BYTE:
578 ubptr = (GLubyte *) list;
579 return (GLuint) *(ubptr+n);
580 case GL_SHORT:
581 sptr = (GLshort *) list;
582 return (GLuint) *(sptr+n);
583 case GL_UNSIGNED_SHORT:
584 usptr = (GLushort *) list;
585 return (GLuint) *(usptr+n);
586 case GL_INT:
587 iptr = (GLint *) list;
588 return (GLuint) *(iptr+n);
589 case GL_UNSIGNED_INT:
590 uiptr = (GLuint *) list;
591 return (GLuint) *(uiptr+n);
592 case GL_FLOAT:
593 fptr = (GLfloat *) list;
594 return (GLuint) *(fptr+n);
595 case GL_2_BYTES:
596 ubptr = ((GLubyte *) list) + 2*n;
597 return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
598 case GL_3_BYTES:
599 ubptr = ((GLubyte *) list) + 3*n;
600 return (GLuint) *ubptr * 65536
601 + (GLuint) *(ubptr+1) * 256
602 + (GLuint) *(ubptr+2);
603 case GL_4_BYTES:
604 ubptr = ((GLubyte *) list) + 4*n;
605 return (GLuint) *ubptr * 16777216
606 + (GLuint) *(ubptr+1) * 65536
607 + (GLuint) *(ubptr+2) * 256
608 + (GLuint) *(ubptr+3);
609 default:
610 return 0;
611 }
612 }
613
614
615
616
617 /**********************************************************************/
618 /***** Public *****/
619 /**********************************************************************/
620
621 void _mesa_init_lists( void )
622 {
623 static int init_flag = 0;
624
625 if (init_flag==0) {
626 InstSize[OPCODE_ACCUM] = 3;
627 InstSize[OPCODE_ALPHA_FUNC] = 3;
628 InstSize[OPCODE_BIND_TEXTURE] = 3;
629 InstSize[OPCODE_BITMAP] = 8;
630 InstSize[OPCODE_BLEND_COLOR] = 5;
631 InstSize[OPCODE_BLEND_EQUATION] = 2;
632 InstSize[OPCODE_BLEND_EQUATION_SEPARATE] = 3;
633 InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5;
634 InstSize[OPCODE_CALL_LIST] = 2;
635 InstSize[OPCODE_CALL_LIST_OFFSET] = 3;
636 InstSize[OPCODE_CLEAR] = 2;
637 InstSize[OPCODE_CLEAR_ACCUM] = 5;
638 InstSize[OPCODE_CLEAR_COLOR] = 5;
639 InstSize[OPCODE_CLEAR_DEPTH] = 2;
640 InstSize[OPCODE_CLEAR_INDEX] = 2;
641 InstSize[OPCODE_CLEAR_STENCIL] = 2;
642 InstSize[OPCODE_CLIP_PLANE] = 6;
643 InstSize[OPCODE_COLOR_MASK] = 5;
644 InstSize[OPCODE_COLOR_MATERIAL] = 3;
645 InstSize[OPCODE_COLOR_TABLE] = 7;
646 InstSize[OPCODE_COLOR_TABLE_PARAMETER_FV] = 7;
647 InstSize[OPCODE_COLOR_TABLE_PARAMETER_IV] = 7;
648 InstSize[OPCODE_COLOR_SUB_TABLE] = 7;
649 InstSize[OPCODE_CONVOLUTION_FILTER_1D] = 7;
650 InstSize[OPCODE_CONVOLUTION_FILTER_2D] = 8;
651 InstSize[OPCODE_CONVOLUTION_PARAMETER_I] = 4;
652 InstSize[OPCODE_CONVOLUTION_PARAMETER_IV] = 7;
653 InstSize[OPCODE_CONVOLUTION_PARAMETER_F] = 4;
654 InstSize[OPCODE_CONVOLUTION_PARAMETER_FV] = 7;
655 InstSize[OPCODE_COPY_PIXELS] = 6;
656 InstSize[OPCODE_COPY_COLOR_SUB_TABLE] = 6;
657 InstSize[OPCODE_COPY_COLOR_TABLE] = 6;
658 InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8;
659 InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9;
660 InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7;
661 InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
662 InstSize[OPCODE_COPY_TEX_SUB_IMAGE3D] = 10;
663 InstSize[OPCODE_CULL_FACE] = 2;
664 InstSize[OPCODE_DEPTH_FUNC] = 2;
665 InstSize[OPCODE_DEPTH_MASK] = 2;
666 InstSize[OPCODE_DEPTH_RANGE] = 3;
667 InstSize[OPCODE_DISABLE] = 2;
668 InstSize[OPCODE_DRAW_BUFFER] = 2;
669 InstSize[OPCODE_DRAW_PIXELS] = 6;
670 InstSize[OPCODE_ENABLE] = 2;
671 InstSize[OPCODE_EVALMESH1] = 4;
672 InstSize[OPCODE_EVALMESH2] = 6;
673 InstSize[OPCODE_FOG] = 6;
674 InstSize[OPCODE_FRONT_FACE] = 2;
675 InstSize[OPCODE_FRUSTUM] = 7;
676 InstSize[OPCODE_HINT] = 3;
677 InstSize[OPCODE_HISTOGRAM] = 5;
678 InstSize[OPCODE_INDEX_MASK] = 2;
679 InstSize[OPCODE_INIT_NAMES] = 1;
680 InstSize[OPCODE_LIGHT] = 7;
681 InstSize[OPCODE_LIGHT_MODEL] = 6;
682 InstSize[OPCODE_LINE_STIPPLE] = 3;
683 InstSize[OPCODE_LINE_WIDTH] = 2;
684 InstSize[OPCODE_LIST_BASE] = 2;
685 InstSize[OPCODE_LOAD_IDENTITY] = 1;
686 InstSize[OPCODE_LOAD_MATRIX] = 17;
687 InstSize[OPCODE_LOAD_NAME] = 2;
688 InstSize[OPCODE_LOGIC_OP] = 2;
689 InstSize[OPCODE_MAP1] = 7;
690 InstSize[OPCODE_MAP2] = 11;
691 InstSize[OPCODE_MAPGRID1] = 4;
692 InstSize[OPCODE_MAPGRID2] = 7;
693 InstSize[OPCODE_MATRIX_MODE] = 2;
694 InstSize[OPCODE_MIN_MAX] = 4;
695 InstSize[OPCODE_MULT_MATRIX] = 17;
696 InstSize[OPCODE_ORTHO] = 7;
697 InstSize[OPCODE_PASSTHROUGH] = 2;
698 InstSize[OPCODE_PIXEL_MAP] = 4;
699 InstSize[OPCODE_PIXEL_TRANSFER] = 3;
700 InstSize[OPCODE_PIXEL_ZOOM] = 3;
701 InstSize[OPCODE_POINT_SIZE] = 2;
702 InstSize[OPCODE_POINT_PARAMETERS] = 5;
703 InstSize[OPCODE_POLYGON_MODE] = 3;
704 InstSize[OPCODE_POLYGON_STIPPLE] = 2;
705 InstSize[OPCODE_POLYGON_OFFSET] = 3;
706 InstSize[OPCODE_POP_ATTRIB] = 1;
707 InstSize[OPCODE_POP_MATRIX] = 1;
708 InstSize[OPCODE_POP_NAME] = 1;
709 InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
710 InstSize[OPCODE_PUSH_ATTRIB] = 2;
711 InstSize[OPCODE_PUSH_MATRIX] = 1;
712 InstSize[OPCODE_PUSH_NAME] = 2;
713 InstSize[OPCODE_RASTER_POS] = 5;
714 InstSize[OPCODE_READ_BUFFER] = 2;
715 InstSize[OPCODE_RESET_HISTOGRAM] = 2;
716 InstSize[OPCODE_RESET_MIN_MAX] = 2;
717 InstSize[OPCODE_ROTATE] = 5;
718 InstSize[OPCODE_SCALE] = 4;
719 InstSize[OPCODE_SCISSOR] = 5;
720 InstSize[OPCODE_STENCIL_FUNC] = 4;
721 InstSize[OPCODE_STENCIL_MASK] = 2;
722 InstSize[OPCODE_STENCIL_OP] = 4;
723 InstSize[OPCODE_SHADE_MODEL] = 2;
724 InstSize[OPCODE_TEXENV] = 7;
725 InstSize[OPCODE_TEXGEN] = 7;
726 InstSize[OPCODE_TEXPARAMETER] = 7;
727 InstSize[OPCODE_TEX_IMAGE1D] = 9;
728 InstSize[OPCODE_TEX_IMAGE2D] = 10;
729 InstSize[OPCODE_TEX_IMAGE3D] = 11;
730 InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
731 InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
732 InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12;
733 InstSize[OPCODE_TRANSLATE] = 4;
734 InstSize[OPCODE_VIEWPORT] = 5;
735 InstSize[OPCODE_WINDOW_POS] = 5;
736 InstSize[OPCODE_CONTINUE] = 2;
737 InstSize[OPCODE_ERROR] = 3;
738 InstSize[OPCODE_END_OF_LIST] = 1;
739 /* GL_SGIX/SGIS_pixel_texture */
740 InstSize[OPCODE_PIXEL_TEXGEN_SGIX] = 2;
741 InstSize[OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS] = 3;
742 /* GL_ARB_texture_compression */
743 InstSize[OPCODE_COMPRESSED_TEX_IMAGE_1D] = 8;
744 InstSize[OPCODE_COMPRESSED_TEX_IMAGE_2D] = 9;
745 InstSize[OPCODE_COMPRESSED_TEX_IMAGE_3D] = 10;
746 InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D] = 8;
747 InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D] = 10;
748 InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D] = 12;
749 /* GL_ARB_multisample */
750 InstSize[OPCODE_SAMPLE_COVERAGE] = 3;
751 /* GL_ARB_multitexture */
752 InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
753 /* GL_ARB_window_pos */
754 InstSize[OPCODE_WINDOW_POS_ARB] = 4;
755 /* GL_NV_vertex_program */
756 InstSize[OPCODE_BIND_PROGRAM_NV] = 3;
757 InstSize[OPCODE_EXECUTE_PROGRAM_NV] = 7;
758 InstSize[OPCODE_REQUEST_RESIDENT_PROGRAMS_NV] = 2;
759 InstSize[OPCODE_LOAD_PROGRAM_NV] = 5;
760 InstSize[OPCODE_PROGRAM_PARAMETER4F_NV] = 7;
761 InstSize[OPCODE_TRACK_MATRIX_NV] = 5;
762 /* GL_NV_fragment_program */
763 InstSize[OPCODE_PROGRAM_LOCAL_PARAMETER_ARB] = 7;
764 InstSize[OPCODE_PROGRAM_NAMED_PARAMETER_NV] = 8;
765 /* GL_EXT_stencil_two_side */
766 InstSize[OPCODE_ACTIVE_STENCIL_FACE_EXT] = 2;
767 /* GL_EXT_depth_bounds_test */
768 InstSize[OPCODE_DEPTH_BOUNDS_EXT] = 3;
769 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
770 InstSize[OPCODE_PROGRAM_STRING_ARB] = 5;
771 InstSize[OPCODE_PROGRAM_ENV_PARAMETER_ARB] = 7;
772 #endif
773 InstSize[OPCODE_ATTR_1F] = 3;
774 InstSize[OPCODE_ATTR_2F] = 4;
775 InstSize[OPCODE_ATTR_3F] = 5;
776 InstSize[OPCODE_ATTR_4F] = 6;
777 InstSize[OPCODE_MATERIAL] = 7;
778 InstSize[OPCODE_INDEX] = 2;
779 InstSize[OPCODE_EDGEFLAG] = 2;
780 InstSize[OPCODE_BEGIN] = 2;
781 InstSize[OPCODE_END] = 1;
782 InstSize[OPCODE_RECTF] = 5;
783 InstSize[OPCODE_EVAL_C1] = 2;
784 InstSize[OPCODE_EVAL_C2] = 3;
785 InstSize[OPCODE_EVAL_P1] = 2;
786 InstSize[OPCODE_EVAL_P2] = 3;
787 }
788 init_flag = 1;
789 }
790
791
792 /*
793 * Allocate space for a display list instruction.
794 * \param opcode - type of instruction
795 * argcount - size in bytes of data required.
796 * \return pointer to the usable data area (not including the internal
797 * opcode).
798 */
799 void *
800 _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
801 {
802 Node *n, *newblock;
803 GLuint count = 1 + (sz + sizeof(Node) - 1) / sizeof(Node);
804
805 #ifdef DEBUG
806 if (opcode < (int) OPCODE_DRV_0) {
807 assert( count == InstSize[opcode] );
808 }
809 #endif
810
811 if (ctx->ListState.CurrentPos + count + 2 > BLOCK_SIZE) {
812 /* This block is full. Allocate a new block and chain to it */
813 n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
814 n[0].opcode = OPCODE_CONTINUE;
815 newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
816 if (!newblock) {
817 _mesa_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
818 return NULL;
819 }
820 n[1].next = (Node *) newblock;
821 ctx->ListState.CurrentBlock = newblock;
822 ctx->ListState.CurrentPos = 0;
823 }
824
825 n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
826 ctx->ListState.CurrentPos += count;
827
828 n[0].opcode = (OpCode) opcode;
829
830 return (void *)&n[1];
831 }
832
833
834 /* Allow modules and drivers to get their own opcodes.
835 */
836 int
837 _mesa_alloc_opcode( GLcontext *ctx,
838 GLuint sz,
839 void (*execute)( GLcontext *, void * ),
840 void (*destroy)( GLcontext *, void * ),
841 void (*print)( GLcontext *, void * ) )
842 {
843 if (ctx->listext.nr_opcodes < GL_MAX_EXT_OPCODES) {
844 GLuint i = ctx->listext.nr_opcodes++;
845 ctx->listext.opcode[i].size = 1 + (sz + sizeof(Node) - 1)/sizeof(Node);
846 ctx->listext.opcode[i].execute = execute;
847 ctx->listext.opcode[i].destroy = destroy;
848 ctx->listext.opcode[i].print = print;
849 return i + OPCODE_DRV_0;
850 }
851 return -1;
852 }
853
854
855
856 /* Mimic the old behaviour of alloc_instruction:
857 * - sz is in units of sizeof(Node)
858 * - return value a pointer to sizeof(Node) before the actual
859 * usable data area.
860 */
861 #define ALLOC_INSTRUCTION(ctx, opcode, sz) \
862 ((Node *)_mesa_alloc_instruction(ctx, opcode, sz*sizeof(Node)) - 1)
863
864
865
866 /*
867 * Display List compilation functions
868 */
869 static void GLAPIENTRY save_Accum( GLenum op, GLfloat value )
870 {
871 GET_CURRENT_CONTEXT(ctx);
872 Node *n;
873 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
874 n = ALLOC_INSTRUCTION( ctx, OPCODE_ACCUM, 2 );
875 if (n) {
876 n[1].e = op;
877 n[2].f = value;
878 }
879 if (ctx->ExecuteFlag) {
880 (*ctx->Exec->Accum)( op, value );
881 }
882 }
883
884
885 static void GLAPIENTRY save_AlphaFunc( GLenum func, GLclampf ref )
886 {
887 GET_CURRENT_CONTEXT(ctx);
888 Node *n;
889 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
890 n = ALLOC_INSTRUCTION( ctx, OPCODE_ALPHA_FUNC, 2 );
891 if (n) {
892 n[1].e = func;
893 n[2].f = (GLfloat) ref;
894 }
895 if (ctx->ExecuteFlag) {
896 (*ctx->Exec->AlphaFunc)( func, ref );
897 }
898 }
899
900
901 static void GLAPIENTRY save_BindTexture( GLenum target, GLuint texture )
902 {
903 GET_CURRENT_CONTEXT(ctx);
904 Node *n;
905 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
906 n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_TEXTURE, 2 );
907 if (n) {
908 n[1].e = target;
909 n[2].ui = texture;
910 }
911 if (ctx->ExecuteFlag) {
912 (*ctx->Exec->BindTexture)( target, texture );
913 }
914 }
915
916
917 static void GLAPIENTRY save_Bitmap( GLsizei width, GLsizei height,
918 GLfloat xorig, GLfloat yorig,
919 GLfloat xmove, GLfloat ymove,
920 const GLubyte *pixels )
921 {
922 GET_CURRENT_CONTEXT(ctx);
923 GLvoid *image = _mesa_unpack_bitmap( width, height, pixels, &ctx->Unpack );
924 Node *n;
925 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
926 n = ALLOC_INSTRUCTION( ctx, OPCODE_BITMAP, 7 );
927 if (n) {
928 n[1].i = (GLint) width;
929 n[2].i = (GLint) height;
930 n[3].f = xorig;
931 n[4].f = yorig;
932 n[5].f = xmove;
933 n[6].f = ymove;
934 n[7].data = image;
935 }
936 else if (image) {
937 FREE(image);
938 }
939 if (ctx->ExecuteFlag) {
940 (*ctx->Exec->Bitmap)( width, height,
941 xorig, yorig, xmove, ymove, pixels );
942 }
943 }
944
945
946 static void GLAPIENTRY save_BlendEquation( GLenum mode )
947 {
948 GET_CURRENT_CONTEXT(ctx);
949 Node *n;
950 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
951 n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION, 1 );
952 if (n) {
953 n[1].e = mode;
954 }
955 if (ctx->ExecuteFlag) {
956 (*ctx->Exec->BlendEquation)( mode );
957 }
958 }
959
960
961 static void GLAPIENTRY save_BlendEquationSeparateEXT( GLenum modeRGB,
962 GLenum modeA )
963 {
964 GET_CURRENT_CONTEXT(ctx);
965 Node *n;
966 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
967 n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2 );
968 if (n) {
969 n[1].e = modeRGB;
970 n[2].e = modeA;
971 }
972 if (ctx->ExecuteFlag) {
973 (*ctx->Exec->BlendEquationSeparateEXT)( modeRGB, modeA );
974 }
975 }
976
977
978 static void GLAPIENTRY save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
979 GLenum sfactorA, GLenum dfactorA)
980 {
981 GET_CURRENT_CONTEXT(ctx);
982 Node *n;
983 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
984 n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
985 if (n) {
986 n[1].e = sfactorRGB;
987 n[2].e = dfactorRGB;
988 n[3].e = sfactorA;
989 n[4].e = dfactorA;
990 }
991 if (ctx->ExecuteFlag) {
992 (*ctx->Exec->BlendFuncSeparateEXT)( sfactorRGB, dfactorRGB,
993 sfactorA, dfactorA);
994 }
995 }
996
997
998 static void GLAPIENTRY save_BlendColor( GLfloat red, GLfloat green,
999 GLfloat blue, GLfloat alpha )
1000 {
1001 GET_CURRENT_CONTEXT(ctx);
1002 Node *n;
1003 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1004 n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_COLOR, 4 );
1005 if (n) {
1006 n[1].f = red;
1007 n[2].f = green;
1008 n[3].f = blue;
1009 n[4].f = alpha;
1010 }
1011 if (ctx->ExecuteFlag) {
1012 (*ctx->Exec->BlendColor)( red, green, blue, alpha );
1013 }
1014 }
1015
1016
1017 void GLAPIENTRY _mesa_save_CallList( GLuint list )
1018 {
1019 GET_CURRENT_CONTEXT(ctx);
1020 Node *n;
1021 SAVE_FLUSH_VERTICES(ctx);
1022
1023 n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST, 1 );
1024 if (n) {
1025 n[1].ui = list;
1026 }
1027
1028 /* After this, we don't know what begin/end state we're in:
1029 */
1030 ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
1031
1032 if (ctx->ExecuteFlag) {
1033 (*ctx->Exec->CallList)( list );
1034 }
1035 }
1036
1037
1038 void GLAPIENTRY _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
1039 {
1040 GET_CURRENT_CONTEXT(ctx);
1041 GLint i;
1042 GLboolean typeErrorFlag;
1043
1044 SAVE_FLUSH_VERTICES(ctx);
1045
1046 switch (type) {
1047 case GL_BYTE:
1048 case GL_UNSIGNED_BYTE:
1049 case GL_SHORT:
1050 case GL_UNSIGNED_SHORT:
1051 case GL_INT:
1052 case GL_UNSIGNED_INT:
1053 case GL_FLOAT:
1054 case GL_2_BYTES:
1055 case GL_3_BYTES:
1056 case GL_4_BYTES:
1057 typeErrorFlag = GL_FALSE;
1058 break;
1059 default:
1060 typeErrorFlag = GL_TRUE;
1061 }
1062
1063 for (i=0;i<n;i++) {
1064 GLuint list = translate_id( i, type, lists );
1065 Node *n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST_OFFSET, 2 );
1066 if (n) {
1067 n[1].ui = list;
1068 n[2].b = typeErrorFlag;
1069 }
1070 }
1071
1072 /* After this, we don't know what begin/end state we're in:
1073 */
1074 ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
1075
1076 if (ctx->ExecuteFlag) {
1077 (*ctx->Exec->CallLists)( n, type, lists );
1078 }
1079 }
1080
1081
1082 static void GLAPIENTRY save_Clear( GLbitfield mask )
1083 {
1084 GET_CURRENT_CONTEXT(ctx);
1085 Node *n;
1086 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1087 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR, 1 );
1088 if (n) {
1089 n[1].bf = mask;
1090 }
1091 if (ctx->ExecuteFlag) {
1092 (*ctx->Exec->Clear)( mask );
1093 }
1094 }
1095
1096
1097 static void GLAPIENTRY save_ClearAccum( GLfloat red, GLfloat green,
1098 GLfloat blue, GLfloat alpha )
1099 {
1100 GET_CURRENT_CONTEXT(ctx);
1101 Node *n;
1102 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1103 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_ACCUM, 4 );
1104 if (n) {
1105 n[1].f = red;
1106 n[2].f = green;
1107 n[3].f = blue;
1108 n[4].f = alpha;
1109 }
1110 if (ctx->ExecuteFlag) {
1111 (*ctx->Exec->ClearAccum)( red, green, blue, alpha );
1112 }
1113 }
1114
1115
1116 static void GLAPIENTRY save_ClearColor( GLclampf red, GLclampf green,
1117 GLclampf blue, GLclampf alpha )
1118 {
1119 GET_CURRENT_CONTEXT(ctx);
1120 Node *n;
1121 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1122 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_COLOR, 4 );
1123 if (n) {
1124 n[1].f = red;
1125 n[2].f = green;
1126 n[3].f = blue;
1127 n[4].f = alpha;
1128 }
1129 if (ctx->ExecuteFlag) {
1130 (*ctx->Exec->ClearColor)( red, green, blue, alpha );
1131 }
1132 }
1133
1134
1135 static void GLAPIENTRY save_ClearDepth( GLclampd depth )
1136 {
1137 GET_CURRENT_CONTEXT(ctx);
1138 Node *n;
1139 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1140 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_DEPTH, 1 );
1141 if (n) {
1142 n[1].f = (GLfloat) depth;
1143 }
1144 if (ctx->ExecuteFlag) {
1145 (*ctx->Exec->ClearDepth)( depth );
1146 }
1147 }
1148
1149
1150 static void GLAPIENTRY save_ClearIndex( GLfloat c )
1151 {
1152 GET_CURRENT_CONTEXT(ctx);
1153 Node *n;
1154 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1155 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_INDEX, 1 );
1156 if (n) {
1157 n[1].f = c;
1158 }
1159 if (ctx->ExecuteFlag) {
1160 (*ctx->Exec->ClearIndex)( c );
1161 }
1162 }
1163
1164
1165 static void GLAPIENTRY save_ClearStencil( GLint s )
1166 {
1167 GET_CURRENT_CONTEXT(ctx);
1168 Node *n;
1169 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1170 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_STENCIL, 1 );
1171 if (n) {
1172 n[1].i = s;
1173 }
1174 if (ctx->ExecuteFlag) {
1175 (*ctx->Exec->ClearStencil)( s );
1176 }
1177 }
1178
1179
1180 static void GLAPIENTRY save_ClipPlane( GLenum plane, const GLdouble *equ )
1181 {
1182 GET_CURRENT_CONTEXT(ctx);
1183 Node *n;
1184 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1185 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLIP_PLANE, 5 );
1186 if (n) {
1187 n[1].e = plane;
1188 n[2].f = (GLfloat) equ[0];
1189 n[3].f = (GLfloat) equ[1];
1190 n[4].f = (GLfloat) equ[2];
1191 n[5].f = (GLfloat) equ[3];
1192 }
1193 if (ctx->ExecuteFlag) {
1194 (*ctx->Exec->ClipPlane)( plane, equ );
1195 }
1196 }
1197
1198
1199
1200 static void GLAPIENTRY save_ColorMask( GLboolean red, GLboolean green,
1201 GLboolean blue, GLboolean alpha )
1202 {
1203 GET_CURRENT_CONTEXT(ctx);
1204 Node *n;
1205 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1206 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MASK, 4 );
1207 if (n) {
1208 n[1].b = red;
1209 n[2].b = green;
1210 n[3].b = blue;
1211 n[4].b = alpha;
1212 }
1213 if (ctx->ExecuteFlag) {
1214 (*ctx->Exec->ColorMask)( red, green, blue, alpha );
1215 }
1216 }
1217
1218
1219 static void GLAPIENTRY save_ColorMaterial( GLenum face, GLenum mode )
1220 {
1221 GET_CURRENT_CONTEXT(ctx);
1222 Node *n;
1223 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1224
1225 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MATERIAL, 2 );
1226 if (n) {
1227 n[1].e = face;
1228 n[2].e = mode;
1229 }
1230 if (ctx->ExecuteFlag) {
1231 (*ctx->Exec->ColorMaterial)( face, mode );
1232 }
1233 }
1234
1235
1236 static void GLAPIENTRY save_ColorTable( GLenum target, GLenum internalFormat,
1237 GLsizei width, GLenum format, GLenum type,
1238 const GLvoid *table )
1239 {
1240 GET_CURRENT_CONTEXT(ctx);
1241 if (target == GL_PROXY_TEXTURE_1D ||
1242 target == GL_PROXY_TEXTURE_2D ||
1243 target == GL_PROXY_TEXTURE_3D ||
1244 target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
1245 /* execute immediately */
1246 (*ctx->Exec->ColorTable)( target, internalFormat, width,
1247 format, type, table );
1248 }
1249 else {
1250 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, table,
1251 &ctx->Unpack);
1252 Node *n;
1253 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1254 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE, 6 );
1255 if (n) {
1256 n[1].e = target;
1257 n[2].e = internalFormat;
1258 n[3].i = width;
1259 n[4].e = format;
1260 n[5].e = type;
1261 n[6].data = image;
1262 }
1263 else if (image) {
1264 FREE(image);
1265 }
1266 if (ctx->ExecuteFlag) {
1267 (*ctx->Exec->ColorTable)( target, internalFormat, width,
1268 format, type, table );
1269 }
1270 }
1271 }
1272
1273
1274
1275 static void GLAPIENTRY
1276 save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
1277 {
1278 GET_CURRENT_CONTEXT(ctx);
1279 Node *n;
1280
1281 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1282
1283 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6 );
1284 if (n) {
1285 n[1].e = target;
1286 n[2].e = pname;
1287 n[3].f = params[0];
1288 if (pname == GL_COLOR_TABLE_SGI ||
1289 pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1290 pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI ||
1291 pname == GL_TEXTURE_COLOR_TABLE_SGI) {
1292 n[4].f = params[1];
1293 n[5].f = params[2];
1294 n[6].f = params[3];
1295 }
1296 }
1297
1298 if (ctx->ExecuteFlag) {
1299 (*ctx->Exec->ColorTableParameterfv)( target, pname, params );
1300 }
1301 }
1302
1303
1304 static void GLAPIENTRY
1305 save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
1306 {
1307 GET_CURRENT_CONTEXT(ctx);
1308 Node *n;
1309
1310 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1311
1312 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6 );
1313 if (n) {
1314 n[1].e = target;
1315 n[2].e = pname;
1316 n[3].i = params[0];
1317 if (pname == GL_COLOR_TABLE_SGI ||
1318 pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1319 pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI ||
1320 pname == GL_TEXTURE_COLOR_TABLE_SGI) {
1321 n[4].i = params[1];
1322 n[5].i = params[2];
1323 n[6].i = params[3];
1324 }
1325 }
1326
1327 if (ctx->ExecuteFlag) {
1328 (*ctx->Exec->ColorTableParameteriv)( target, pname, params );
1329 }
1330 }
1331
1332
1333
1334 static void GLAPIENTRY save_ColorSubTable( GLenum target, GLsizei start, GLsizei count,
1335 GLenum format, GLenum type,
1336 const GLvoid *table)
1337 {
1338 GET_CURRENT_CONTEXT(ctx);
1339 GLvoid *image = _mesa_unpack_image(count, 1, 1, format, type, table,
1340 &ctx->Unpack);
1341 Node *n;
1342 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1343 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_SUB_TABLE, 6 );
1344 if (n) {
1345 n[1].e = target;
1346 n[2].i = start;
1347 n[3].i = count;
1348 n[4].e = format;
1349 n[5].e = type;
1350 n[6].data = image;
1351 }
1352 else if (image) {
1353 FREE(image);
1354 }
1355 if (ctx->ExecuteFlag) {
1356 (*ctx->Exec->ColorSubTable)(target, start, count, format, type, table);
1357 }
1358 }
1359
1360
1361 static void GLAPIENTRY
1362 save_CopyColorSubTable(GLenum target, GLsizei start,
1363 GLint x, GLint y, GLsizei width)
1364 {
1365 GET_CURRENT_CONTEXT(ctx);
1366 Node *n;
1367
1368 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1369 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5 );
1370 if (n) {
1371 n[1].e = target;
1372 n[2].i = start;
1373 n[3].i = x;
1374 n[4].i = y;
1375 n[5].i = width;
1376 }
1377 if (ctx->ExecuteFlag) {
1378 (*ctx->Exec->CopyColorSubTable)(target, start, x, y, width);
1379 }
1380 }
1381
1382
1383 static void GLAPIENTRY
1384 save_CopyColorTable(GLenum target, GLenum internalformat,
1385 GLint x, GLint y, GLsizei width)
1386 {
1387 GET_CURRENT_CONTEXT(ctx);
1388 Node *n;
1389
1390 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1391 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_TABLE, 5 );
1392 if (n) {
1393 n[1].e = target;
1394 n[2].e = internalformat;
1395 n[3].i = x;
1396 n[4].i = y;
1397 n[5].i = width;
1398 }
1399 if (ctx->ExecuteFlag) {
1400 (*ctx->Exec->CopyColorTable)(target, internalformat, x, y, width);
1401 }
1402 }
1403
1404
1405 static void GLAPIENTRY
1406 save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
1407 GLenum format, GLenum type, const GLvoid *filter)
1408 {
1409 GET_CURRENT_CONTEXT(ctx);
1410 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, filter,
1411 &ctx->Unpack);
1412 Node *n;
1413 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1414 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_1D, 6 );
1415 if (n) {
1416 n[1].e = target;
1417 n[2].e = internalFormat;
1418 n[3].i = width;
1419 n[4].e = format;
1420 n[5].e = type;
1421 n[6].data = image;
1422 }
1423 else if (image) {
1424 FREE(image);
1425 }
1426 if (ctx->ExecuteFlag) {
1427 (*ctx->Exec->ConvolutionFilter1D)( target, internalFormat, width,
1428 format, type, filter );
1429 }
1430 }
1431
1432
1433 static void GLAPIENTRY
1434 save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
1435 GLsizei width, GLsizei height, GLenum format,
1436 GLenum type, const GLvoid *filter)
1437 {
1438 GET_CURRENT_CONTEXT(ctx);
1439 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, filter,
1440 &ctx->Unpack);
1441 Node *n;
1442 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1443 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_2D, 7 );
1444 if (n) {
1445 n[1].e = target;
1446 n[2].e = internalFormat;
1447 n[3].i = width;
1448 n[4].i = height;
1449 n[5].e = format;
1450 n[6].e = type;
1451 n[7].data = image;
1452 }
1453 else if (image) {
1454 FREE(image);
1455 }
1456 if (ctx->ExecuteFlag) {
1457 (*ctx->Exec->ConvolutionFilter2D)( target, internalFormat, width, height,
1458 format, type, filter );
1459 }
1460 }
1461
1462
1463 static void GLAPIENTRY
1464 save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
1465 {
1466 GET_CURRENT_CONTEXT(ctx);
1467 Node *n;
1468 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1469 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3 );
1470 if (n) {
1471 n[1].e = target;
1472 n[2].e = pname;
1473 n[3].i = param;
1474 }
1475 if (ctx->ExecuteFlag) {
1476 (*ctx->Exec->ConvolutionParameteri)( target, pname, param );
1477 }
1478 }
1479
1480
1481 static void GLAPIENTRY
1482 save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
1483 {
1484 GET_CURRENT_CONTEXT(ctx);
1485 Node *n;
1486 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1487 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
1488 if (n) {
1489 n[1].e = target;
1490 n[2].e = pname;
1491 n[3].i = params[0];
1492 if (pname == GL_CONVOLUTION_BORDER_COLOR ||
1493 pname == GL_CONVOLUTION_FILTER_SCALE ||
1494 pname == GL_CONVOLUTION_FILTER_BIAS) {
1495 n[4].i = params[1];
1496 n[5].i = params[2];
1497 n[6].i = params[3];
1498 }
1499 else {
1500 n[4].i = n[5].i = n[6].i = 0;
1501 }
1502 }
1503 if (ctx->ExecuteFlag) {
1504 (*ctx->Exec->ConvolutionParameteriv)( target, pname, params );
1505 }
1506 }
1507
1508
1509 static void GLAPIENTRY
1510 save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
1511 {
1512 GET_CURRENT_CONTEXT(ctx);
1513 Node *n;
1514 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1515 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3 );
1516 if (n) {
1517 n[1].e = target;
1518 n[2].e = pname;
1519 n[3].f = param;
1520 }
1521 if (ctx->ExecuteFlag) {
1522 (*ctx->Exec->ConvolutionParameterf)( target, pname, param );
1523 }
1524 }
1525
1526
1527 static void GLAPIENTRY
1528 save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
1529 {
1530 GET_CURRENT_CONTEXT(ctx);
1531 Node *n;
1532 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1533 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6 );
1534 if (n) {
1535 n[1].e = target;
1536 n[2].e = pname;
1537 n[3].f = params[0];
1538 if (pname == GL_CONVOLUTION_BORDER_COLOR ||
1539 pname == GL_CONVOLUTION_FILTER_SCALE ||
1540 pname == GL_CONVOLUTION_FILTER_BIAS) {
1541 n[4].f = params[1];
1542 n[5].f = params[2];
1543 n[6].f = params[3];
1544 }
1545 else {
1546 n[4].f = n[5].f = n[6].f = 0.0F;
1547 }
1548 }
1549 if (ctx->ExecuteFlag) {
1550 (*ctx->Exec->ConvolutionParameterfv)( target, pname, params );
1551 }
1552 }
1553
1554
1555 static void GLAPIENTRY
1556 save_CopyPixels( GLint x, GLint y,
1557 GLsizei width, GLsizei height, GLenum type )
1558 {
1559 GET_CURRENT_CONTEXT(ctx);
1560 Node *n;
1561 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1562 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_PIXELS, 5 );
1563 if (n) {
1564 n[1].i = x;
1565 n[2].i = y;
1566 n[3].i = (GLint) width;
1567 n[4].i = (GLint) height;
1568 n[5].e = type;
1569 }
1570 if (ctx->ExecuteFlag) {
1571 (*ctx->Exec->CopyPixels)( x, y, width, height, type );
1572 }
1573 }
1574
1575
1576
1577 static void GLAPIENTRY
1578 save_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
1579 GLint x, GLint y, GLsizei width, GLint border )
1580 {
1581 GET_CURRENT_CONTEXT(ctx);
1582 Node *n;
1583 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1584 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
1585 if (n) {
1586 n[1].e = target;
1587 n[2].i = level;
1588 n[3].e = internalformat;
1589 n[4].i = x;
1590 n[5].i = y;
1591 n[6].i = width;
1592 n[7].i = border;
1593 }
1594 if (ctx->ExecuteFlag) {
1595 (*ctx->Exec->CopyTexImage1D)( target, level, internalformat,
1596 x, y, width, border );
1597 }
1598 }
1599
1600
1601 static void GLAPIENTRY
1602 save_CopyTexImage2D( GLenum target, GLint level,
1603 GLenum internalformat,
1604 GLint x, GLint y, GLsizei width,
1605 GLsizei height, GLint border )
1606 {
1607 GET_CURRENT_CONTEXT(ctx);
1608 Node *n;
1609 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1610 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
1611 if (n) {
1612 n[1].e = target;
1613 n[2].i = level;
1614 n[3].e = internalformat;
1615 n[4].i = x;
1616 n[5].i = y;
1617 n[6].i = width;
1618 n[7].i = height;
1619 n[8].i = border;
1620 }
1621 if (ctx->ExecuteFlag) {
1622 (*ctx->Exec->CopyTexImage2D)( target, level, internalformat,
1623 x, y, width, height, border );
1624 }
1625 }
1626
1627
1628
1629 static void GLAPIENTRY
1630 save_CopyTexSubImage1D( GLenum target, GLint level,
1631 GLint xoffset, GLint x, GLint y,
1632 GLsizei width )
1633 {
1634 GET_CURRENT_CONTEXT(ctx);
1635 Node *n;
1636 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1637 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
1638 if (n) {
1639 n[1].e = target;
1640 n[2].i = level;
1641 n[3].i = xoffset;
1642 n[4].i = x;
1643 n[5].i = y;
1644 n[6].i = width;
1645 }
1646 if (ctx->ExecuteFlag) {
1647 (*ctx->Exec->CopyTexSubImage1D)( target, level, xoffset, x, y, width );
1648 }
1649 }
1650
1651
1652 static void GLAPIENTRY
1653 save_CopyTexSubImage2D( GLenum target, GLint level,
1654 GLint xoffset, GLint yoffset,
1655 GLint x, GLint y,
1656 GLsizei width, GLint height )
1657 {
1658 GET_CURRENT_CONTEXT(ctx);
1659 Node *n;
1660 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1661 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
1662 if (n) {
1663 n[1].e = target;
1664 n[2].i = level;
1665 n[3].i = xoffset;
1666 n[4].i = yoffset;
1667 n[5].i = x;
1668 n[6].i = y;
1669 n[7].i = width;
1670 n[8].i = height;
1671 }
1672 if (ctx->ExecuteFlag) {
1673 (*ctx->Exec->CopyTexSubImage2D)( target, level, xoffset, yoffset,
1674 x, y, width, height );
1675 }
1676 }
1677
1678
1679 static void GLAPIENTRY
1680 save_CopyTexSubImage3D( GLenum target, GLint level,
1681 GLint xoffset, GLint yoffset, GLint zoffset,
1682 GLint x, GLint y,
1683 GLsizei width, GLint height )
1684 {
1685 GET_CURRENT_CONTEXT(ctx);
1686 Node *n;
1687 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1688 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
1689 if (n) {
1690 n[1].e = target;
1691 n[2].i = level;
1692 n[3].i = xoffset;
1693 n[4].i = yoffset;
1694 n[5].i = zoffset;
1695 n[6].i = x;
1696 n[7].i = y;
1697 n[8].i = width;
1698 n[9].i = height;
1699 }
1700 if (ctx->ExecuteFlag) {
1701 (*ctx->Exec->CopyTexSubImage3D)( target, level,
1702 xoffset, yoffset, zoffset,
1703 x, y, width, height );
1704 }
1705 }
1706
1707
1708 static void GLAPIENTRY save_CullFace( GLenum mode )
1709 {
1710 GET_CURRENT_CONTEXT(ctx);
1711 Node *n;
1712 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1713 n = ALLOC_INSTRUCTION( ctx, OPCODE_CULL_FACE, 1 );
1714 if (n) {
1715 n[1].e = mode;
1716 }
1717 if (ctx->ExecuteFlag) {
1718 (*ctx->Exec->CullFace)( mode );
1719 }
1720 }
1721
1722
1723 static void GLAPIENTRY save_DepthFunc( GLenum func )
1724 {
1725 GET_CURRENT_CONTEXT(ctx);
1726 Node *n;
1727 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1728 n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_FUNC, 1 );
1729 if (n) {
1730 n[1].e = func;
1731 }
1732 if (ctx->ExecuteFlag) {
1733 (*ctx->Exec->DepthFunc)( func );
1734 }
1735 }
1736
1737
1738 static void GLAPIENTRY save_DepthMask( GLboolean mask )
1739 {
1740 GET_CURRENT_CONTEXT(ctx);
1741 Node *n;
1742 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1743 n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_MASK, 1 );
1744 if (n) {
1745 n[1].b = mask;
1746 }
1747 if (ctx->ExecuteFlag) {
1748 (*ctx->Exec->DepthMask)( mask );
1749 }
1750 }
1751
1752
1753 static void GLAPIENTRY save_DepthRange( GLclampd nearval, GLclampd farval )
1754 {
1755 GET_CURRENT_CONTEXT(ctx);
1756 Node *n;
1757 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1758 n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_RANGE, 2 );
1759 if (n) {
1760 n[1].f = (GLfloat) nearval;
1761 n[2].f = (GLfloat) farval;
1762 }
1763 if (ctx->ExecuteFlag) {
1764 (*ctx->Exec->DepthRange)( nearval, farval );
1765 }
1766 }
1767
1768
1769 static void GLAPIENTRY save_Disable( GLenum cap )
1770 {
1771 GET_CURRENT_CONTEXT(ctx);
1772 Node *n;
1773 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1774 n = ALLOC_INSTRUCTION( ctx, OPCODE_DISABLE, 1 );
1775 if (n) {
1776 n[1].e = cap;
1777 }
1778 if (ctx->ExecuteFlag) {
1779 (*ctx->Exec->Disable)( cap );
1780 }
1781 }
1782
1783
1784 static void GLAPIENTRY save_DrawBuffer( GLenum mode )
1785 {
1786 GET_CURRENT_CONTEXT(ctx);
1787 Node *n;
1788 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1789 n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_BUFFER, 1 );
1790 if (n) {
1791 n[1].e = mode;
1792 }
1793 if (ctx->ExecuteFlag) {
1794 (*ctx->Exec->DrawBuffer)( mode );
1795 }
1796 }
1797
1798
1799 static void GLAPIENTRY save_DrawPixels( GLsizei width, GLsizei height,
1800 GLenum format, GLenum type,
1801 const GLvoid *pixels )
1802 {
1803 GET_CURRENT_CONTEXT(ctx);
1804 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
1805 pixels, &ctx->Unpack);
1806 Node *n;
1807 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1808 n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_PIXELS, 5 );
1809 if (n) {
1810 n[1].i = width;
1811 n[2].i = height;
1812 n[3].e = format;
1813 n[4].e = type;
1814 n[5].data = image;
1815 }
1816 else if (image) {
1817 FREE(image);
1818 }
1819 if (ctx->ExecuteFlag) {
1820 (*ctx->Exec->DrawPixels)( width, height, format, type, pixels );
1821 }
1822 }
1823
1824
1825
1826 static void GLAPIENTRY save_Enable( GLenum cap )
1827 {
1828 GET_CURRENT_CONTEXT(ctx);
1829 Node *n;
1830 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1831 n = ALLOC_INSTRUCTION( ctx, OPCODE_ENABLE, 1 );
1832 if (n) {
1833 n[1].e = cap;
1834 }
1835 if (ctx->ExecuteFlag) {
1836 (*ctx->Exec->Enable)( cap );
1837 }
1838 }
1839
1840
1841
1842 void GLAPIENTRY _mesa_save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
1843 {
1844 GET_CURRENT_CONTEXT(ctx);
1845 Node *n;
1846 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1847 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVALMESH1, 3 );
1848 if (n) {
1849 n[1].e = mode;
1850 n[2].i = i1;
1851 n[3].i = i2;
1852 }
1853 if (ctx->ExecuteFlag) {
1854 (*ctx->Exec->EvalMesh1)( mode, i1, i2 );
1855 }
1856 }
1857
1858
1859 void GLAPIENTRY _mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
1860 {
1861 GET_CURRENT_CONTEXT(ctx);
1862 Node *n;
1863 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1864 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVALMESH2, 5 );
1865 if (n) {
1866 n[1].e = mode;
1867 n[2].i = i1;
1868 n[3].i = i2;
1869 n[4].i = j1;
1870 n[5].i = j2;
1871 }
1872 if (ctx->ExecuteFlag) {
1873 (*ctx->Exec->EvalMesh2)( mode, i1, i2, j1, j2 );
1874 }
1875 }
1876
1877
1878
1879
1880 static void GLAPIENTRY save_Fogfv( GLenum pname, const GLfloat *params )
1881 {
1882 GET_CURRENT_CONTEXT(ctx);
1883 Node *n;
1884 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1885 n = ALLOC_INSTRUCTION( ctx, OPCODE_FOG, 5 );
1886 if (n) {
1887 n[1].e = pname;
1888 n[2].f = params[0];
1889 n[3].f = params[1];
1890 n[4].f = params[2];
1891 n[5].f = params[3];
1892 }
1893 if (ctx->ExecuteFlag) {
1894 (*ctx->Exec->Fogfv)( pname, params );
1895 }
1896 }
1897
1898
1899 static void GLAPIENTRY save_Fogf( GLenum pname, GLfloat param )
1900 {
1901 save_Fogfv(pname, &param);
1902 }
1903
1904
1905 static void GLAPIENTRY save_Fogiv(GLenum pname, const GLint *params )
1906 {
1907 GLfloat p[4];
1908 switch (pname) {
1909 case GL_FOG_MODE:
1910 case GL_FOG_DENSITY:
1911 case GL_FOG_START:
1912 case GL_FOG_END:
1913 case GL_FOG_INDEX:
1914 p[0] = (GLfloat) *params;
1915 break;
1916 case GL_FOG_COLOR:
1917 p[0] = INT_TO_FLOAT( params[0] );
1918 p[1] = INT_TO_FLOAT( params[1] );
1919 p[2] = INT_TO_FLOAT( params[2] );
1920 p[3] = INT_TO_FLOAT( params[3] );
1921 break;
1922 default:
1923 /* Error will be caught later in gl_Fogfv */
1924 ;
1925 }
1926 save_Fogfv(pname, p);
1927 }
1928
1929
1930 static void GLAPIENTRY save_Fogi(GLenum pname, GLint param )
1931 {
1932 save_Fogiv(pname, &param);
1933 }
1934
1935
1936 static void GLAPIENTRY save_FrontFace( GLenum mode )
1937 {
1938 GET_CURRENT_CONTEXT(ctx);
1939 Node *n;
1940 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1941 n = ALLOC_INSTRUCTION( ctx, OPCODE_FRONT_FACE, 1 );
1942 if (n) {
1943 n[1].e = mode;
1944 }
1945 if (ctx->ExecuteFlag) {
1946 (*ctx->Exec->FrontFace)( mode );
1947 }
1948 }
1949
1950
1951 static void GLAPIENTRY save_Frustum( GLdouble left, GLdouble right,
1952 GLdouble bottom, GLdouble top,
1953 GLdouble nearval, GLdouble farval )
1954 {
1955 GET_CURRENT_CONTEXT(ctx);
1956 Node *n;
1957 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1958 n = ALLOC_INSTRUCTION( ctx, OPCODE_FRUSTUM, 6 );
1959 if (n) {
1960 n[1].f = (GLfloat) left;
1961 n[2].f = (GLfloat) right;
1962 n[3].f = (GLfloat) bottom;
1963 n[4].f = (GLfloat) top;
1964 n[5].f = (GLfloat) nearval;
1965 n[6].f = (GLfloat) farval;
1966 }
1967 if (ctx->ExecuteFlag) {
1968 (*ctx->Exec->Frustum)( left, right, bottom, top, nearval, farval );
1969 }
1970 }
1971
1972
1973 static void GLAPIENTRY save_Hint( GLenum target, GLenum mode )
1974 {
1975 GET_CURRENT_CONTEXT(ctx);
1976 Node *n;
1977 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1978 n = ALLOC_INSTRUCTION( ctx, OPCODE_HINT, 2 );
1979 if (n) {
1980 n[1].e = target;
1981 n[2].e = mode;
1982 }
1983 if (ctx->ExecuteFlag) {
1984 (*ctx->Exec->Hint)( target, mode );
1985 }
1986 }
1987
1988
1989 static void GLAPIENTRY
1990 save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink)
1991 {
1992 GET_CURRENT_CONTEXT(ctx);
1993 Node *n;
1994
1995 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1996 n = ALLOC_INSTRUCTION( ctx, OPCODE_HISTOGRAM, 4 );
1997 if (n) {
1998 n[1].e = target;
1999 n[2].i = width;
2000 n[3].e = internalFormat;
2001 n[4].b = sink;
2002 }
2003 if (ctx->ExecuteFlag) {
2004 (*ctx->Exec->Histogram)( target, width, internalFormat, sink );
2005 }
2006 }
2007
2008
2009 static void GLAPIENTRY save_IndexMask( GLuint mask )
2010 {
2011 GET_CURRENT_CONTEXT(ctx);
2012 Node *n;
2013 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2014 n = ALLOC_INSTRUCTION( ctx, OPCODE_INDEX_MASK, 1 );
2015 if (n) {
2016 n[1].ui = mask;
2017 }
2018 if (ctx->ExecuteFlag) {
2019 (*ctx->Exec->IndexMask)( mask );
2020 }
2021 }
2022
2023
2024 static void GLAPIENTRY save_InitNames( void )
2025 {
2026 GET_CURRENT_CONTEXT(ctx);
2027 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2028 (void) ALLOC_INSTRUCTION( ctx, OPCODE_INIT_NAMES, 0 );
2029 if (ctx->ExecuteFlag) {
2030 (*ctx->Exec->InitNames)();
2031 }
2032 }
2033
2034
2035 static void GLAPIENTRY save_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
2036 {
2037 GET_CURRENT_CONTEXT(ctx);
2038 Node *n;
2039 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2040 n = ALLOC_INSTRUCTION( ctx, OPCODE_LIGHT, 6 );
2041 if (OPCODE_LIGHT) {
2042 GLint i, nParams;
2043 n[1].e = light;
2044 n[2].e = pname;
2045 switch (pname) {
2046 case GL_AMBIENT:
2047 nParams = 4;
2048 break;
2049 case GL_DIFFUSE:
2050 nParams = 4;
2051 break;
2052 case GL_SPECULAR:
2053 nParams = 4;
2054 break;
2055 case GL_POSITION:
2056 nParams = 4;
2057 break;
2058 case GL_SPOT_DIRECTION:
2059 nParams = 3;
2060 break;
2061 case GL_SPOT_EXPONENT:
2062 nParams = 1;
2063 break;
2064 case GL_SPOT_CUTOFF:
2065 nParams = 1;
2066 break;
2067 case GL_CONSTANT_ATTENUATION:
2068 nParams = 1;
2069 break;
2070 case GL_LINEAR_ATTENUATION:
2071 nParams = 1;
2072 break;
2073 case GL_QUADRATIC_ATTENUATION:
2074 nParams = 1;
2075 break;
2076 default:
2077 nParams = 0;
2078 }
2079 for (i = 0; i < nParams; i++) {
2080 n[3+i].f = params[i];
2081 }
2082 }
2083 if (ctx->ExecuteFlag) {
2084 (*ctx->Exec->Lightfv)( light, pname, params );
2085 }
2086 }
2087
2088
2089 static void GLAPIENTRY save_Lightf( GLenum light, GLenum pname, GLfloat params )
2090 {
2091 save_Lightfv(light, pname, &params);
2092 }
2093
2094
2095 static void GLAPIENTRY save_Lightiv( GLenum light, GLenum pname, const GLint *params )
2096 {
2097 GLfloat fparam[4];
2098 switch (pname) {
2099 case GL_AMBIENT:
2100 case GL_DIFFUSE:
2101 case GL_SPECULAR:
2102 fparam[0] = INT_TO_FLOAT( params[0] );
2103 fparam[1] = INT_TO_FLOAT( params[1] );
2104 fparam[2] = INT_TO_FLOAT( params[2] );
2105 fparam[3] = INT_TO_FLOAT( params[3] );
2106 break;
2107 case GL_POSITION:
2108 fparam[0] = (GLfloat) params[0];
2109 fparam[1] = (GLfloat) params[1];
2110 fparam[2] = (GLfloat) params[2];
2111 fparam[3] = (GLfloat) params[3];
2112 break;
2113 case GL_SPOT_DIRECTION:
2114 fparam[0] = (GLfloat) params[0];
2115 fparam[1] = (GLfloat) params[1];
2116 fparam[2] = (GLfloat) params[2];
2117 break;
2118 case GL_SPOT_EXPONENT:
2119 case GL_SPOT_CUTOFF:
2120 case GL_CONSTANT_ATTENUATION:
2121 case GL_LINEAR_ATTENUATION:
2122 case GL_QUADRATIC_ATTENUATION:
2123 fparam[0] = (GLfloat) params[0];
2124 break;
2125 default:
2126 /* error will be caught later in gl_Lightfv */
2127 ;
2128 }
2129 save_Lightfv( light, pname, fparam );
2130 }
2131
2132
2133 static void GLAPIENTRY save_Lighti( GLenum light, GLenum pname, GLint param )
2134 {
2135 save_Lightiv( light, pname, &param );
2136 }
2137
2138
2139 static void GLAPIENTRY save_LightModelfv( GLenum pname, const GLfloat *params )
2140 {
2141 GET_CURRENT_CONTEXT(ctx);
2142 Node *n;
2143 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2144 n = ALLOC_INSTRUCTION( ctx, OPCODE_LIGHT_MODEL, 5 );
2145 if (n) {
2146 n[1].e = pname;
2147 n[2].f = params[0];
2148 n[3].f = params[1];
2149 n[4].f = params[2];
2150 n[5].f = params[3];
2151 }
2152 if (ctx->ExecuteFlag) {
2153 (*ctx->Exec->LightModelfv)( pname, params );
2154 }
2155 }
2156
2157
2158 static void GLAPIENTRY save_LightModelf( GLenum pname, GLfloat param )
2159 {
2160 save_LightModelfv(pname, &param);
2161 }
2162
2163
2164 static void GLAPIENTRY save_LightModeliv( GLenum pname, const GLint *params )
2165 {
2166 GLfloat fparam[4];
2167 switch (pname) {
2168 case GL_LIGHT_MODEL_AMBIENT:
2169 fparam[0] = INT_TO_FLOAT( params[0] );
2170 fparam[1] = INT_TO_FLOAT( params[1] );
2171 fparam[2] = INT_TO_FLOAT( params[2] );
2172 fparam[3] = INT_TO_FLOAT( params[3] );
2173 break;
2174 case GL_LIGHT_MODEL_LOCAL_VIEWER:
2175 case GL_LIGHT_MODEL_TWO_SIDE:
2176 case GL_LIGHT_MODEL_COLOR_CONTROL:
2177 fparam[0] = (GLfloat) params[0];
2178 break;
2179 default:
2180 /* Error will be caught later in gl_LightModelfv */
2181 ;
2182 }
2183 save_LightModelfv(pname, fparam);
2184 }
2185
2186
2187 static void GLAPIENTRY save_LightModeli( GLenum pname, GLint param )
2188 {
2189 save_LightModeliv(pname, &param);
2190 }
2191
2192
2193 static void GLAPIENTRY save_LineStipple( GLint factor, GLushort pattern )
2194 {
2195 GET_CURRENT_CONTEXT(ctx);
2196 Node *n;
2197 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2198 n = ALLOC_INSTRUCTION( ctx, OPCODE_LINE_STIPPLE, 2 );
2199 if (n) {
2200 n[1].i = factor;
2201 n[2].us = pattern;
2202 }
2203 if (ctx->ExecuteFlag) {
2204 (*ctx->Exec->LineStipple)( factor, pattern );
2205 }
2206 }
2207
2208
2209 static void GLAPIENTRY save_LineWidth( GLfloat width )
2210 {
2211 GET_CURRENT_CONTEXT(ctx);
2212 Node *n;
2213 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2214 n = ALLOC_INSTRUCTION( ctx, OPCODE_LINE_WIDTH, 1 );
2215 if (n) {
2216 n[1].f = width;
2217 }
2218 if (ctx->ExecuteFlag) {
2219 (*ctx->Exec->LineWidth)( width );
2220 }
2221 }
2222
2223
2224 static void GLAPIENTRY save_ListBase( GLuint base )
2225 {
2226 GET_CURRENT_CONTEXT(ctx);
2227 Node *n;
2228 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2229 n = ALLOC_INSTRUCTION( ctx, OPCODE_LIST_BASE, 1 );
2230 if (n) {
2231 n[1].ui = base;
2232 }
2233 if (ctx->ExecuteFlag) {
2234 (*ctx->Exec->ListBase)( base );
2235 }
2236 }
2237
2238
2239 static void GLAPIENTRY save_LoadIdentity( void )
2240 {
2241 GET_CURRENT_CONTEXT(ctx);
2242 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2243 (void) ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_IDENTITY, 0 );
2244 if (ctx->ExecuteFlag) {
2245 (*ctx->Exec->LoadIdentity)();
2246 }
2247 }
2248
2249
2250 static void GLAPIENTRY save_LoadMatrixf( const GLfloat *m )
2251 {
2252 GET_CURRENT_CONTEXT(ctx);
2253 Node *n;
2254 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2255 n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_MATRIX, 16 );
2256 if (n) {
2257 GLuint i;
2258 for (i=0;i<16;i++) {
2259 n[1+i].f = m[i];
2260 }
2261 }
2262 if (ctx->ExecuteFlag) {
2263 (*ctx->Exec->LoadMatrixf)( m );
2264 }
2265 }
2266
2267
2268 static void GLAPIENTRY save_LoadMatrixd( const GLdouble *m )
2269 {
2270 GLfloat f[16];
2271 GLint i;
2272 for (i = 0; i < 16; i++) {
2273 f[i] = (GLfloat) m[i];
2274 }
2275 save_LoadMatrixf(f);
2276 }
2277
2278
2279 static void GLAPIENTRY save_LoadName( GLuint name )
2280 {
2281 GET_CURRENT_CONTEXT(ctx);
2282 Node *n;
2283 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2284 n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_NAME, 1 );
2285 if (n) {
2286 n[1].ui = name;
2287 }
2288 if (ctx->ExecuteFlag) {
2289 (*ctx->Exec->LoadName)( name );
2290 }
2291 }
2292
2293
2294 static void GLAPIENTRY save_LogicOp( GLenum opcode )
2295 {
2296 GET_CURRENT_CONTEXT(ctx);
2297 Node *n;
2298 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2299 n = ALLOC_INSTRUCTION( ctx, OPCODE_LOGIC_OP, 1 );
2300 if (n) {
2301 n[1].e = opcode;
2302 }
2303 if (ctx->ExecuteFlag) {
2304 (*ctx->Exec->LogicOp)( opcode );
2305 }
2306 }
2307
2308
2309 static void GLAPIENTRY save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
2310 GLint order, const GLdouble *points)
2311 {
2312 GET_CURRENT_CONTEXT(ctx);
2313 Node *n;
2314 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2315 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
2316 if (n) {
2317 GLfloat *pnts = _mesa_copy_map_points1d( target, stride, order, points );
2318 n[1].e = target;
2319 n[2].f = (GLfloat) u1;
2320 n[3].f = (GLfloat) u2;
2321 n[4].i = _mesa_evaluator_components(target); /* stride */
2322 n[5].i = order;
2323 n[6].data = (void *) pnts;
2324 }
2325 if (ctx->ExecuteFlag) {
2326 (*ctx->Exec->Map1d)( target, u1, u2, stride, order, points );
2327 }
2328 }
2329
2330 static void GLAPIENTRY save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
2331 GLint order, const GLfloat *points)
2332 {
2333 GET_CURRENT_CONTEXT(ctx);
2334 Node *n;
2335 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2336 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
2337 if (n) {
2338 GLfloat *pnts = _mesa_copy_map_points1f( target, stride, order, points );
2339 n[1].e = target;
2340 n[2].f = u1;
2341 n[3].f = u2;
2342 n[4].i = _mesa_evaluator_components(target); /* stride */
2343 n[5].i = order;
2344 n[6].data = (void *) pnts;
2345 }
2346 if (ctx->ExecuteFlag) {
2347 (*ctx->Exec->Map1f)( target, u1, u2, stride, order, points );
2348 }
2349 }
2350
2351
2352 static void GLAPIENTRY save_Map2d( GLenum target,
2353 GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
2354 GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
2355 const GLdouble *points )
2356 {
2357 GET_CURRENT_CONTEXT(ctx);
2358 Node *n;
2359 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2360 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
2361 if (n) {
2362 GLfloat *pnts = _mesa_copy_map_points2d( target, ustride, uorder,
2363 vstride, vorder, points );
2364 n[1].e = target;
2365 n[2].f = (GLfloat) u1;
2366 n[3].f = (GLfloat) u2;
2367 n[4].f = (GLfloat) v1;
2368 n[5].f = (GLfloat) v2;
2369 /* XXX verify these strides are correct */
2370 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
2371 n[7].i = _mesa_evaluator_components(target); /*vstride*/
2372 n[8].i = uorder;
2373 n[9].i = vorder;
2374 n[10].data = (void *) pnts;
2375 }
2376 if (ctx->ExecuteFlag) {
2377 (*ctx->Exec->Map2d)( target,
2378 u1, u2, ustride, uorder,
2379 v1, v2, vstride, vorder, points );
2380 }
2381 }
2382
2383
2384 static void GLAPIENTRY save_Map2f( GLenum target,
2385 GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
2386 GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
2387 const GLfloat *points )
2388 {
2389 GET_CURRENT_CONTEXT(ctx);
2390 Node *n;
2391 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2392 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
2393 if (n) {
2394 GLfloat *pnts = _mesa_copy_map_points2f( target, ustride, uorder,
2395 vstride, vorder, points );
2396 n[1].e = target;
2397 n[2].f = u1;
2398 n[3].f = u2;
2399 n[4].f = v1;
2400 n[5].f = v2;
2401 /* XXX verify these strides are correct */
2402 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
2403 n[7].i = _mesa_evaluator_components(target); /*vstride*/
2404 n[8].i = uorder;
2405 n[9].i = vorder;
2406 n[10].data = (void *) pnts;
2407 }
2408 if (ctx->ExecuteFlag) {
2409 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
2410 v1, v2, vstride, vorder, points );
2411 }
2412 }
2413
2414
2415 static void GLAPIENTRY save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
2416 {
2417 GET_CURRENT_CONTEXT(ctx);
2418 Node *n;
2419 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2420 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAPGRID1, 3 );
2421 if (n) {
2422 n[1].i = un;
2423 n[2].f = u1;
2424 n[3].f = u2;
2425 }
2426 if (ctx->ExecuteFlag) {
2427 (*ctx->Exec->MapGrid1f)( un, u1, u2 );
2428 }
2429 }
2430
2431
2432 static void GLAPIENTRY save_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
2433 {
2434 save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
2435 }
2436
2437
2438 static void GLAPIENTRY save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
2439 GLint vn, GLfloat v1, GLfloat v2 )
2440 {
2441 GET_CURRENT_CONTEXT(ctx);
2442 Node *n;
2443 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2444 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAPGRID2, 6 );
2445 if (n) {
2446 n[1].i = un;
2447 n[2].f = u1;
2448 n[3].f = u2;
2449 n[4].i = vn;
2450 n[5].f = v1;
2451 n[6].f = v2;
2452 }
2453 if (ctx->ExecuteFlag) {
2454 (*ctx->Exec->MapGrid2f)( un, u1, u2, vn, v1, v2 );
2455 }
2456 }
2457
2458
2459
2460 static void GLAPIENTRY save_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
2461 GLint vn, GLdouble v1, GLdouble v2 )
2462 {
2463 save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2,
2464 vn, (GLfloat) v1, (GLfloat) v2);
2465 }
2466
2467
2468 static void GLAPIENTRY save_MatrixMode( GLenum mode )
2469 {
2470 GET_CURRENT_CONTEXT(ctx);
2471 Node *n;
2472 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2473 n = ALLOC_INSTRUCTION( ctx, OPCODE_MATRIX_MODE, 1 );
2474 if (n) {
2475 n[1].e = mode;
2476 }
2477 if (ctx->ExecuteFlag) {
2478 (*ctx->Exec->MatrixMode)( mode );
2479 }
2480 }
2481
2482
2483 static void GLAPIENTRY
2484 save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
2485 {
2486 GET_CURRENT_CONTEXT(ctx);
2487 Node *n;
2488
2489 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2490 n = ALLOC_INSTRUCTION( ctx, OPCODE_MIN_MAX, 3 );
2491 if (n) {
2492 n[1].e = target;
2493 n[2].e = internalFormat;
2494 n[3].b = sink;
2495 }
2496 if (ctx->ExecuteFlag) {
2497 (*ctx->Exec->Minmax)( target, internalFormat, sink );
2498 }
2499 }
2500
2501
2502 static void GLAPIENTRY save_MultMatrixf( const GLfloat *m )
2503 {
2504 GET_CURRENT_CONTEXT(ctx);
2505 Node *n;
2506 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2507 n = ALLOC_INSTRUCTION( ctx, OPCODE_MULT_MATRIX, 16 );
2508 if (n) {
2509 GLuint i;
2510 for (i=0;i<16;i++) {
2511 n[1+i].f = m[i];
2512 }
2513 }
2514 if (ctx->ExecuteFlag) {
2515 (*ctx->Exec->MultMatrixf)( m );
2516 }
2517 }
2518
2519
2520 static void GLAPIENTRY save_MultMatrixd( const GLdouble *m )
2521 {
2522 GLfloat f[16];
2523 GLint i;
2524 for (i = 0; i < 16; i++) {
2525 f[i] = (GLfloat) m[i];
2526 }
2527 save_MultMatrixf(f);
2528 }
2529
2530
2531 static void GLAPIENTRY save_NewList( GLuint list, GLenum mode )
2532 {
2533 GET_CURRENT_CONTEXT(ctx);
2534 /* It's an error to call this function while building a display list */
2535 _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
2536 (void) list;
2537 (void) mode;
2538 }
2539
2540
2541
2542 static void GLAPIENTRY save_Ortho( GLdouble left, GLdouble right,
2543 GLdouble bottom, GLdouble top,
2544 GLdouble nearval, GLdouble farval )
2545 {
2546 GET_CURRENT_CONTEXT(ctx);
2547 Node *n;
2548 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2549 n = ALLOC_INSTRUCTION( ctx, OPCODE_ORTHO, 6 );
2550 if (n) {
2551 n[1].f = (GLfloat) left;
2552 n[2].f = (GLfloat) right;
2553 n[3].f = (GLfloat) bottom;
2554 n[4].f = (GLfloat) top;
2555 n[5].f = (GLfloat) nearval;
2556 n[6].f = (GLfloat) farval;
2557 }
2558 if (ctx->ExecuteFlag) {
2559 (*ctx->Exec->Ortho)( left, right, bottom, top, nearval, farval );
2560 }
2561 }
2562
2563
2564 static void GLAPIENTRY
2565 save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
2566 {
2567 GET_CURRENT_CONTEXT(ctx);
2568 Node *n;
2569 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2570 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_MAP, 3 );
2571 if (n) {
2572 n[1].e = map;
2573 n[2].i = mapsize;
2574 n[3].data = (void *) MALLOC( mapsize * sizeof(GLfloat) );
2575 MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
2576 }
2577 if (ctx->ExecuteFlag) {
2578 (*ctx->Exec->PixelMapfv)( map, mapsize, values );
2579 }
2580 }
2581
2582
2583 static void GLAPIENTRY
2584 save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
2585 {
2586 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2587 GLint i;
2588 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
2589 for (i=0;i<mapsize;i++) {
2590 fvalues[i] = (GLfloat) values[i];
2591 }
2592 }
2593 else {
2594 for (i=0;i<mapsize;i++) {
2595 fvalues[i] = UINT_TO_FLOAT( values[i] );
2596 }
2597 }
2598 save_PixelMapfv(map, mapsize, fvalues);
2599 }
2600
2601
2602 static void GLAPIENTRY
2603 save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
2604 {
2605 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2606 GLint i;
2607 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
2608 for (i=0;i<mapsize;i++) {
2609 fvalues[i] = (GLfloat) values[i];
2610 }
2611 }
2612 else {
2613 for (i=0;i<mapsize;i++) {
2614 fvalues[i] = USHORT_TO_FLOAT( values[i] );
2615 }
2616 }
2617 save_PixelMapfv(map, mapsize, fvalues);
2618 }
2619
2620
2621 static void GLAPIENTRY
2622 save_PixelTransferf( GLenum pname, GLfloat param )
2623 {
2624 GET_CURRENT_CONTEXT(ctx);
2625 Node *n;
2626 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2627 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TRANSFER, 2 );
2628 if (n) {
2629 n[1].e = pname;
2630 n[2].f = param;
2631 }
2632 if (ctx->ExecuteFlag) {
2633 (*ctx->Exec->PixelTransferf)( pname, param );
2634 }
2635 }
2636
2637
2638 static void GLAPIENTRY
2639 save_PixelTransferi( GLenum pname, GLint param )
2640 {
2641 save_PixelTransferf( pname, (GLfloat) param );
2642 }
2643
2644
2645 static void GLAPIENTRY
2646 save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
2647 {
2648 GET_CURRENT_CONTEXT(ctx);
2649 Node *n;
2650 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2651 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_ZOOM, 2 );
2652 if (n) {
2653 n[1].f = xfactor;
2654 n[2].f = yfactor;
2655 }
2656 if (ctx->ExecuteFlag) {
2657 (*ctx->Exec->PixelZoom)( xfactor, yfactor );
2658 }
2659 }
2660
2661
2662 static void GLAPIENTRY
2663 save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
2664 {
2665 GET_CURRENT_CONTEXT(ctx);
2666 Node *n;
2667 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2668 n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_PARAMETERS, 4 );
2669 if (n) {
2670 n[1].e = pname;
2671 n[2].f = params[0];
2672 n[3].f = params[1];
2673 n[4].f = params[2];
2674 }
2675 if (ctx->ExecuteFlag) {
2676 (*ctx->Exec->PointParameterfvEXT)( pname, params );
2677 }
2678 }
2679
2680
2681 static void GLAPIENTRY save_PointParameterfEXT( GLenum pname, GLfloat param )
2682 {
2683 save_PointParameterfvEXT(pname, &param);
2684 }
2685
2686 static void GLAPIENTRY save_PointParameteriNV( GLenum pname, GLint param )
2687 {
2688 GLfloat p = (GLfloat) param;
2689 save_PointParameterfvEXT(pname, &p);
2690 }
2691
2692 static void GLAPIENTRY save_PointParameterivNV( GLenum pname, const GLint *param )
2693 {
2694 GLfloat p = (GLfloat) param[0];
2695 save_PointParameterfvEXT(pname, &p);
2696 }
2697
2698
2699 static void GLAPIENTRY save_PointSize( GLfloat size )
2700 {
2701 GET_CURRENT_CONTEXT(ctx);
2702 Node *n;
2703 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2704 n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_SIZE, 1 );
2705 if (n) {
2706 n[1].f = size;
2707 }
2708 if (ctx->ExecuteFlag) {
2709 (*ctx->Exec->PointSize)( size );
2710 }
2711 }
2712
2713
2714 static void GLAPIENTRY save_PolygonMode( GLenum face, GLenum mode )
2715 {
2716 GET_CURRENT_CONTEXT(ctx);
2717 Node *n;
2718 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2719 n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_MODE, 2 );
2720 if (n) {
2721 n[1].e = face;
2722 n[2].e = mode;
2723 }
2724 if (ctx->ExecuteFlag) {
2725 (*ctx->Exec->PolygonMode)( face, mode );
2726 }
2727 }
2728
2729
2730 /*
2731 * Polygon stipple must have been upacked already!
2732 */
2733 static void GLAPIENTRY save_PolygonStipple( const GLubyte *pattern )
2734 {
2735 GET_CURRENT_CONTEXT(ctx);
2736 Node *n;
2737 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2738 n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_STIPPLE, 1 );
2739 if (n) {
2740 void *data;
2741 n[1].data = MALLOC( 32 * 4 );
2742 data = n[1].data; /* This needed for Acorn compiler */
2743 MEMCPY( data, pattern, 32 * 4 );
2744 }
2745 if (ctx->ExecuteFlag) {
2746 (*ctx->Exec->PolygonStipple)( (GLubyte*) pattern );
2747 }
2748 }
2749
2750
2751 static void GLAPIENTRY save_PolygonOffset( GLfloat factor, GLfloat units )
2752 {
2753 GET_CURRENT_CONTEXT(ctx);
2754 Node *n;
2755 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2756 n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_OFFSET, 2 );
2757 if (n) {
2758 n[1].f = factor;
2759 n[2].f = units;
2760 }
2761 if (ctx->ExecuteFlag) {
2762 (*ctx->Exec->PolygonOffset)( factor, units );
2763 }
2764 }
2765
2766
2767 static void GLAPIENTRY save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
2768 {
2769 GET_CURRENT_CONTEXT(ctx);
2770 save_PolygonOffset(factor, ctx->DepthMaxF * bias);
2771 }
2772
2773
2774 static void GLAPIENTRY save_PopAttrib( void )
2775 {
2776 GET_CURRENT_CONTEXT(ctx);
2777 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2778 (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_ATTRIB, 0 );
2779 if (ctx->ExecuteFlag) {
2780 (*ctx->Exec->PopAttrib)();
2781 }
2782 }
2783
2784
2785 static void GLAPIENTRY save_PopMatrix( void )
2786 {
2787 GET_CURRENT_CONTEXT(ctx);
2788 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2789 (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_MATRIX, 0 );
2790 if (ctx->ExecuteFlag) {
2791 (*ctx->Exec->PopMatrix)();
2792 }
2793 }
2794
2795
2796 static void GLAPIENTRY save_PopName( void )
2797 {
2798 GET_CURRENT_CONTEXT(ctx);
2799 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2800 (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_NAME, 0 );
2801 if (ctx->ExecuteFlag) {
2802 (*ctx->Exec->PopName)();
2803 }
2804 }
2805
2806
2807 static void GLAPIENTRY save_PrioritizeTextures( GLsizei num, const GLuint *textures,
2808 const GLclampf *priorities )
2809 {
2810 GET_CURRENT_CONTEXT(ctx);
2811 GLint i;
2812 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2813
2814 for (i=0;i<num;i++) {
2815 Node *n;
2816 n = ALLOC_INSTRUCTION( ctx, OPCODE_PRIORITIZE_TEXTURE, 2 );
2817 if (n) {
2818 n[1].ui = textures[i];
2819 n[2].f = priorities[i];
2820 }
2821 }
2822 if (ctx->ExecuteFlag) {
2823 (*ctx->Exec->PrioritizeTextures)( num, textures, priorities );
2824 }
2825 }
2826
2827
2828 static void GLAPIENTRY save_PushAttrib( GLbitfield mask )
2829 {
2830 GET_CURRENT_CONTEXT(ctx);
2831 Node *n;
2832 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2833 n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_ATTRIB, 1 );
2834 if (n) {
2835 n[1].bf = mask;
2836 }
2837 if (ctx->ExecuteFlag) {
2838 (*ctx->Exec->PushAttrib)( mask );
2839 }
2840 }
2841
2842
2843 static void GLAPIENTRY save_PushMatrix( void )
2844 {
2845 GET_CURRENT_CONTEXT(ctx);
2846 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2847 (void) ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_MATRIX, 0 );
2848 if (ctx->ExecuteFlag) {
2849 (*ctx->Exec->PushMatrix)();
2850 }
2851 }
2852
2853
2854 static void GLAPIENTRY save_PushName( GLuint name )
2855 {
2856 GET_CURRENT_CONTEXT(ctx);
2857 Node *n;
2858 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2859 n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_NAME, 1 );
2860 if (n) {
2861 n[1].ui = name;
2862 }
2863 if (ctx->ExecuteFlag) {
2864 (*ctx->Exec->PushName)( name );
2865 }
2866 }
2867
2868
2869 static void GLAPIENTRY save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
2870 {
2871 GET_CURRENT_CONTEXT(ctx);
2872 Node *n;
2873 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2874 n = ALLOC_INSTRUCTION( ctx, OPCODE_RASTER_POS, 4 );
2875 if (n) {
2876 n[1].f = x;
2877 n[2].f = y;
2878 n[3].f = z;
2879 n[4].f = w;
2880 }
2881 if (ctx->ExecuteFlag) {
2882 (*ctx->Exec->RasterPos4f)( x, y, z, w );
2883 }
2884 }
2885
2886 static void GLAPIENTRY save_RasterPos2d(GLdouble x, GLdouble y)
2887 {
2888 save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
2889 }
2890
2891 static void GLAPIENTRY save_RasterPos2f(GLfloat x, GLfloat y)
2892 {
2893 save_RasterPos4f(x, y, 0.0F, 1.0F);
2894 }
2895
2896 static void GLAPIENTRY save_RasterPos2i(GLint x, GLint y)
2897 {
2898 save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
2899 }
2900
2901 static void GLAPIENTRY save_RasterPos2s(GLshort x, GLshort y)
2902 {
2903 save_RasterPos4f(x, y, 0.0F, 1.0F);
2904 }
2905
2906 static void GLAPIENTRY save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
2907 {
2908 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
2909 }
2910
2911 static void GLAPIENTRY save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
2912 {
2913 save_RasterPos4f(x, y, z, 1.0F);
2914 }
2915
2916 static void GLAPIENTRY save_RasterPos3i(GLint x, GLint y, GLint z)
2917 {
2918 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
2919 }
2920
2921 static void GLAPIENTRY save_RasterPos3s(GLshort x, GLshort y, GLshort z)
2922 {
2923 save_RasterPos4f(x, y, z, 1.0F);
2924 }
2925
2926 static void GLAPIENTRY save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
2927 {
2928 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
2929 }
2930
2931 static void GLAPIENTRY save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
2932 {
2933 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
2934 }
2935
2936 static void GLAPIENTRY save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
2937 {
2938 save_RasterPos4f(x, y, z, w);
2939 }
2940
2941 static void GLAPIENTRY save_RasterPos2dv(const GLdouble *v)
2942 {
2943 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
2944 }
2945
2946 static void GLAPIENTRY save_RasterPos2fv(const GLfloat *v)
2947 {
2948 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2949 }
2950
2951 static void GLAPIENTRY save_RasterPos2iv(const GLint *v)
2952 {
2953 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
2954 }
2955
2956 static void GLAPIENTRY save_RasterPos2sv(const GLshort *v)
2957 {
2958 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2959 }
2960
2961 static void GLAPIENTRY save_RasterPos3dv(const GLdouble *v)
2962 {
2963 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
2964 }
2965
2966 static void GLAPIENTRY save_RasterPos3fv(const GLfloat *v)
2967 {
2968 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2969 }
2970
2971 static void GLAPIENTRY save_RasterPos3iv(const GLint *v)
2972 {
2973 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
2974 }
2975
2976 static void GLAPIENTRY save_RasterPos3sv(const GLshort *v)
2977 {
2978 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2979 }
2980
2981 static void GLAPIENTRY save_RasterPos4dv(const GLdouble *v)
2982 {
2983 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
2984 (GLfloat) v[2], (GLfloat) v[3]);
2985 }
2986
2987 static void GLAPIENTRY save_RasterPos4fv(const GLfloat *v)
2988 {
2989 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2990 }
2991
2992 static void GLAPIENTRY save_RasterPos4iv(const GLint *v)
2993 {
2994 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
2995 (GLfloat) v[2], (GLfloat) v[3]);
2996 }
2997
2998 static void GLAPIENTRY save_RasterPos4sv(const GLshort *v)
2999 {
3000 save_RasterPos4f(v[0], v[1], v[2], v[3]);
3001 }
3002
3003
3004 static void GLAPIENTRY save_PassThrough( GLfloat token )
3005 {
3006 GET_CURRENT_CONTEXT(ctx);
3007 Node *n;
3008 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3009 n = ALLOC_INSTRUCTION( ctx, OPCODE_PASSTHROUGH, 1 );
3010 if (n) {
3011 n[1].f = token;
3012 }
3013 if (ctx->ExecuteFlag) {
3014 (*ctx->Exec->PassThrough)( token );
3015 }
3016 }
3017
3018
3019 static void GLAPIENTRY save_ReadBuffer( GLenum mode )
3020 {
3021 GET_CURRENT_CONTEXT(ctx);
3022 Node *n;
3023 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3024 n = ALLOC_INSTRUCTION( ctx, OPCODE_READ_BUFFER, 1 );
3025 if (n) {
3026 n[1].e = mode;
3027 }
3028 if (ctx->ExecuteFlag) {
3029 (*ctx->Exec->ReadBuffer)( mode );
3030 }
3031 }
3032
3033
3034 static void GLAPIENTRY
3035 save_ResetHistogram(GLenum target)
3036 {
3037 GET_CURRENT_CONTEXT(ctx);
3038 Node *n;
3039 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3040 n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_HISTOGRAM, 1 );
3041 if (n) {
3042 n[1].e = target;
3043 }
3044 if (ctx->ExecuteFlag) {
3045 (*ctx->Exec->ResetHistogram)( target );
3046 }
3047 }
3048
3049
3050 static void GLAPIENTRY
3051 save_ResetMinmax(GLenum target)
3052 {
3053 GET_CURRENT_CONTEXT(ctx);
3054 Node *n;
3055 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3056 n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_MIN_MAX, 1 );
3057 if (n) {
3058 n[1].e = target;
3059 }
3060 if (ctx->ExecuteFlag) {
3061 (*ctx->Exec->ResetMinmax)( target );
3062 }
3063 }
3064
3065
3066 static void GLAPIENTRY save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
3067 {
3068 GET_CURRENT_CONTEXT(ctx);
3069 Node *n;
3070 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3071 n = ALLOC_INSTRUCTION( ctx, OPCODE_ROTATE, 4 );
3072 if (n) {
3073 n[1].f = angle;
3074 n[2].f = x;
3075 n[3].f = y;
3076 n[4].f = z;
3077 }
3078 if (ctx->ExecuteFlag) {
3079 (*ctx->Exec->Rotatef)( angle, x, y, z );
3080 }
3081 }
3082
3083
3084 static void GLAPIENTRY save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
3085 {
3086 save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
3087 }
3088
3089
3090 static void GLAPIENTRY save_Scalef( GLfloat x, GLfloat y, GLfloat z )
3091 {
3092 GET_CURRENT_CONTEXT(ctx);
3093 Node *n;
3094 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3095 n = ALLOC_INSTRUCTION( ctx, OPCODE_SCALE, 3 );
3096 if (n) {
3097 n[1].f = x;
3098 n[2].f = y;
3099 n[3].f = z;
3100 }
3101 if (ctx->ExecuteFlag) {
3102 (*ctx->Exec->Scalef)( x, y, z );
3103 }
3104 }
3105
3106
3107 static void GLAPIENTRY save_Scaled( GLdouble x, GLdouble y, GLdouble z )
3108 {
3109 save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
3110 }
3111
3112
3113 static void GLAPIENTRY save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
3114 {
3115 GET_CURRENT_CONTEXT(ctx);
3116 Node *n;
3117 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3118 n = ALLOC_INSTRUCTION( ctx, OPCODE_SCISSOR, 4 );
3119 if (n) {
3120 n[1].i = x;
3121 n[2].i = y;
3122 n[3].i = width;
3123 n[4].i = height;
3124 }
3125 if (ctx->ExecuteFlag) {
3126 (*ctx->Exec->Scissor)( x, y, width, height );
3127 }
3128 }
3129
3130
3131 static void GLAPIENTRY save_ShadeModel( GLenum mode )
3132 {
3133 GET_CURRENT_CONTEXT(ctx);
3134 Node *n;
3135 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3136 n = ALLOC_INSTRUCTION( ctx, OPCODE_SHADE_MODEL, 1 );
3137 if (n) {
3138 n[1].e = mode;
3139 }
3140 if (ctx->ExecuteFlag) {
3141 (*ctx->Exec->ShadeModel)( mode );
3142 }
3143 }
3144
3145
3146 static void GLAPIENTRY save_StencilFunc( GLenum func, GLint ref, GLuint mask )
3147 {
3148 GET_CURRENT_CONTEXT(ctx);
3149 Node *n;
3150 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3151 n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_FUNC, 3 );
3152 if (n) {
3153 n[1].e = func;
3154 n[2].i = ref;
3155 n[3].ui = mask;
3156 }
3157 if (ctx->ExecuteFlag) {
3158 (*ctx->Exec->StencilFunc)( func, ref, mask );
3159 }
3160 }
3161
3162
3163 static void GLAPIENTRY save_StencilMask( GLuint mask )
3164 {
3165 GET_CURRENT_CONTEXT(ctx);
3166 Node *n;
3167 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3168 n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_MASK, 1 );
3169 if (n) {
3170 n[1].ui = mask;
3171 }
3172 if (ctx->ExecuteFlag) {
3173 (*ctx->Exec->StencilMask)( mask );
3174 }
3175 }
3176
3177
3178 static void GLAPIENTRY save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
3179 {
3180 GET_CURRENT_CONTEXT(ctx);
3181 Node *n;
3182 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3183 n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_OP, 3 );
3184 if (n) {
3185 n[1].e = fail;
3186 n[2].e = zfail;
3187 n[3].e = zpass;
3188 }
3189 if (ctx->ExecuteFlag) {
3190 (*ctx->Exec->StencilOp)( fail, zfail, zpass );
3191 }
3192 }
3193
3194
3195 static void GLAPIENTRY save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
3196 {
3197 GET_CURRENT_CONTEXT(ctx);
3198 Node *n;
3199 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3200 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXENV, 6 );
3201 if (n) {
3202 n[1].e = target;
3203 n[2].e = pname;
3204 n[3].f = params[0];
3205 n[4].f = params[1];
3206 n[5].f = params[2];
3207 n[6].f = params[3];
3208 }
3209 if (ctx->ExecuteFlag) {
3210 (*ctx->Exec->TexEnvfv)( target, pname, params );
3211 }
3212 }
3213
3214
3215 static void GLAPIENTRY save_TexEnvf( GLenum target, GLenum pname, GLfloat param )
3216 {
3217 save_TexEnvfv( target, pname, &param );
3218 }
3219
3220
3221 static void GLAPIENTRY save_TexEnvi( GLenum target, GLenum pname, GLint param )
3222 {
3223 GLfloat p[4];
3224 p[0] = (GLfloat) param;
3225 p[1] = p[2] = p[3] = 0.0;
3226 save_TexEnvfv( target, pname, p );
3227 }
3228
3229
3230 static void GLAPIENTRY save_TexEnviv( GLenum target, GLenum pname, const GLint *param )
3231 {
3232 GLfloat p[4];
3233 p[0] = INT_TO_FLOAT( param[0] );
3234 p[1] = INT_TO_FLOAT( param[1] );
3235 p[2] = INT_TO_FLOAT( param[2] );
3236 p[3] = INT_TO_FLOAT( param[3] );
3237 save_TexEnvfv( target, pname, p );
3238 }
3239
3240
3241 static void GLAPIENTRY save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
3242 {
3243 GET_CURRENT_CONTEXT(ctx);
3244 Node *n;
3245 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3246 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXGEN, 6 );
3247 if (n) {
3248 n[1].e = coord;
3249 n[2].e = pname;
3250 n[3].f = params[0];
3251 n[4].f = params[1];
3252 n[5].f = params[2];
3253 n[6].f = params[3];
3254 }
3255 if (ctx->ExecuteFlag) {
3256 (*ctx->Exec->TexGenfv)( coord, pname, params );
3257 }
3258 }
3259
3260
3261 static void GLAPIENTRY save_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
3262 {
3263 GLfloat p[4];
3264 p[0] = (GLfloat) params[0];
3265 p[1] = (GLfloat) params[1];
3266 p[2] = (GLfloat) params[2];
3267 p[3] = (GLfloat) params[3];
3268 save_TexGenfv(coord, pname, p);
3269 }
3270
3271
3272 static void GLAPIENTRY save_TexGend(GLenum coord, GLenum pname, GLdouble param )
3273 {
3274 GLfloat p = (GLfloat) param;
3275 save_TexGenfv( coord, pname, &p );
3276 }
3277
3278
3279 static void GLAPIENTRY save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
3280 {
3281 GLfloat p[4];
3282 p[0] = (GLfloat) params[0];
3283 p[1] = (GLfloat) params[1];
3284 p[2] = (GLfloat) params[2];
3285 p[3] = (GLfloat) params[3];
3286 save_TexGenfv( coord, pname, p );
3287 }
3288
3289
3290 static void GLAPIENTRY save_TexGenf( GLenum coord, GLenum pname, GLfloat param )
3291 {
3292 save_TexGenfv(coord, pname, &param);
3293 }
3294
3295
3296 static void GLAPIENTRY save_TexGeni( GLenum coord, GLenum pname, GLint param )
3297 {
3298 save_TexGeniv( coord, pname, &param );
3299 }
3300
3301
3302 static void GLAPIENTRY save_TexParameterfv( GLenum target,
3303 GLenum pname, const GLfloat *params )
3304 {
3305 GET_CURRENT_CONTEXT(ctx);
3306 Node *n;
3307 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3308 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXPARAMETER, 6 );
3309 if (n) {
3310 n[1].e = target;
3311 n[2].e = pname;
3312 n[3].f = params[0];
3313 n[4].f = params[1];
3314 n[5].f = params[2];
3315 n[6].f = params[3];
3316 }
3317 if (ctx->ExecuteFlag) {
3318 (*ctx->Exec->TexParameterfv)( target, pname, params );
3319 }
3320 }
3321
3322
3323 static void GLAPIENTRY save_TexParameterf( GLenum target, GLenum pname, GLfloat param )
3324 {
3325 save_TexParameterfv(target, pname, &param);
3326 }
3327
3328
3329 static void GLAPIENTRY save_TexParameteri( GLenum target, GLenum pname, GLint param )
3330 {
3331 GLfloat fparam[4];
3332 fparam[0] = (GLfloat) param;
3333 fparam[1] = fparam[2] = fparam[3] = 0.0;
3334 save_TexParameterfv(target, pname, fparam);
3335 }
3336
3337
3338 static void GLAPIENTRY save_TexParameteriv( GLenum target, GLenum pname, const GLint *params )
3339 {
3340 GLfloat fparam[4];
3341 fparam[0] = (GLfloat) params[0];
3342 fparam[1] = fparam[2] = fparam[3] = 0.0;
3343 save_TexParameterfv(target, pname, fparam);
3344 }
3345
3346
3347 static void GLAPIENTRY save_TexImage1D( GLenum target,
3348 GLint level, GLint components,
3349 GLsizei width, GLint border,
3350 GLenum format, GLenum type,
3351 const GLvoid *pixels )
3352 {
3353 GET_CURRENT_CONTEXT(ctx);
3354 if (target == GL_PROXY_TEXTURE_1D) {
3355 /* don't compile, execute immediately */
3356 (*ctx->Exec->TexImage1D)( target, level, components, width,
3357 border, format, type, pixels );
3358 }
3359 else {
3360 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
3361 pixels, &ctx->Unpack);
3362 Node *n;
3363 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3364 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE1D, 8 );
3365 if (n) {
3366 n[1].e = target;
3367 n[2].i = level;
3368 n[3].i = components;
3369 n[4].i = (GLint) width;
3370 n[5].i = border;
3371 n[6].e = format;
3372 n[7].e = type;
3373 n[8].data = image;
3374 }
3375 else if (image) {
3376 FREE(image);
3377 }
3378 if (ctx->ExecuteFlag) {
3379 (*ctx->Exec->TexImage1D)( target, level, components, width,
3380 border, format, type, pixels );
3381 }
3382 }
3383 }
3384
3385
3386 static void GLAPIENTRY save_TexImage2D( GLenum target,
3387 GLint level, GLint components,
3388 GLsizei width, GLsizei height, GLint border,
3389 GLenum format, GLenum type,
3390 const GLvoid *pixels)
3391 {
3392 GET_CURRENT_CONTEXT(ctx);
3393 if (target == GL_PROXY_TEXTURE_2D) {
3394 /* don't compile, execute immediately */
3395 (*ctx->Exec->TexImage2D)( target, level, components, width,
3396 height, border, format, type, pixels );
3397 }
3398 else {
3399 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
3400 pixels, &ctx->Unpack);
3401 Node *n;
3402 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3403 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE2D, 9 );
3404 if (n) {
3405 n[1].e = target;
3406 n[2].i = level;
3407 n[3].i = components;
3408 n[4].i = (GLint) width;
3409 n[5].i = (GLint) height;
3410 n[6].i = border;
3411 n[7].e = format;
3412 n[8].e = type;
3413 n[9].data = image;
3414 }
3415 else if (image) {
3416 FREE(image);
3417 }
3418 if (ctx->ExecuteFlag) {
3419 (*ctx->Exec->TexImage2D)( target, level, components, width,
3420 height, border, format, type, pixels );
3421 }
3422 }
3423 }
3424
3425
3426 static void GLAPIENTRY save_TexImage3D( GLenum target,
3427 GLint level, GLint internalFormat,
3428 GLsizei width, GLsizei height, GLsizei depth,
3429 GLint border,
3430 GLenum format, GLenum type,
3431 const GLvoid *pixels )
3432 {
3433 GET_CURRENT_CONTEXT(ctx);
3434 if (target == GL_PROXY_TEXTURE_3D) {
3435 /* don't compile, execute immediately */
3436 (*ctx->Exec->TexImage3D)( target, level, internalFormat, width,
3437 height, depth, border, format, type, pixels );
3438 }
3439 else {
3440 Node *n;
3441 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
3442 pixels, &ctx->Unpack);
3443 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3444 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE3D, 10 );
3445 if (n) {
3446 n[1].e = target;
3447 n[2].i = level;
3448 n[3].i = (GLint) internalFormat;
3449 n[4].i = (GLint) width;
3450 n[5].i = (GLint) height;
3451 n[6].i = (GLint) depth;
3452 n[7].i = border;
3453 n[8].e = format;
3454 n[9].e = type;
3455 n[10].data = image;
3456 }
3457 else if (image) {
3458 FREE(image);
3459 }
3460 if (ctx->ExecuteFlag) {
3461 (*ctx->Exec->TexImage3D)( target, level, internalFormat, width,
3462 height, depth, border, format, type, pixels );
3463 }
3464 }
3465 }
3466
3467
3468 static void GLAPIENTRY save_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
3469 GLsizei width, GLenum format, GLenum type,
3470 const GLvoid *pixels )
3471 {
3472 GET_CURRENT_CONTEXT(ctx);
3473 Node *n;
3474 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
3475 pixels, &ctx->Unpack);
3476 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3477 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
3478 if (n) {
3479 n[1].e = target;
3480 n[2].i = level;
3481 n[3].i = xoffset;
3482 n[4].i = (GLint) width;
3483 n[5].e = format;
3484 n[6].e = type;
3485 n[7].data = image;
3486 }
3487 else if (image) {
3488 FREE(image);
3489 }
3490 if (ctx->ExecuteFlag) {
3491 (*ctx->Exec->TexSubImage1D)( target, level, xoffset, width,
3492 format, type, pixels );
3493 }
3494 }
3495
3496
3497 static void GLAPIENTRY save_TexSubImage2D( GLenum target, GLint level,
3498 GLint xoffset, GLint yoffset,
3499 GLsizei width, GLsizei height,
3500 GLenum format, GLenum type,
3501 const GLvoid *pixels )
3502 {
3503 GET_CURRENT_CONTEXT(ctx);
3504 Node *n;
3505 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
3506 pixels, &ctx->Unpack);
3507 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3508 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
3509 if (n) {
3510 n[1].e = target;
3511 n[2].i = level;
3512 n[3].i = xoffset;
3513 n[4].i = yoffset;
3514 n[5].i = (GLint) width;
3515 n[6].i = (GLint) height;
3516 n[7].e = format;
3517 n[8].e = type;
3518 n[9].data = image;
3519 }
3520 else if (image) {
3521 FREE(image);
3522 }
3523 if (ctx->ExecuteFlag) {
3524 (*ctx->Exec->TexSubImage2D)( target, level, xoffset, yoffset,
3525 width, height, format, type, pixels );
3526 }
3527 }
3528
3529
3530 static void GLAPIENTRY save_TexSubImage3D( GLenum target, GLint level,
3531 GLint xoffset, GLint yoffset,GLint zoffset,
3532 GLsizei width, GLsizei height, GLsizei depth,
3533 GLenum format, GLenum type,
3534 const GLvoid *pixels )
3535 {
3536 GET_CURRENT_CONTEXT(ctx);
3537 Node *n;
3538 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
3539 pixels, &ctx->Unpack);
3540 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3541 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
3542 if (n) {
3543 n[1].e = target;
3544 n[2].i = level;
3545 n[3].i = xoffset;
3546 n[4].i = yoffset;
3547 n[5].i = zoffset;
3548 n[6].i = (GLint) width;
3549 n[7].i = (GLint) height;
3550 n[8].i = (GLint) depth;
3551 n[9].e = format;
3552 n[10].e = type;
3553 n[11].data = image;
3554 }
3555 else if (image) {
3556 FREE(image);
3557 }
3558 if (ctx->ExecuteFlag) {
3559 (*ctx->Exec->TexSubImage3D)( target, level,
3560 xoffset, yoffset, zoffset,
3561 width, height, depth, format, type, pixels );
3562 }
3563 }
3564
3565
3566 static void GLAPIENTRY save_Translatef( GLfloat x, GLfloat y, GLfloat z )
3567 {
3568 GET_CURRENT_CONTEXT(ctx);
3569 Node *n;
3570 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3571 n = ALLOC_INSTRUCTION( ctx, OPCODE_TRANSLATE, 3 );
3572 if (n) {
3573 n[1].f = x;
3574 n[2].f = y;
3575 n[3].f = z;
3576 }
3577 if (ctx->ExecuteFlag) {
3578 (*ctx->Exec->Translatef)( x, y, z );
3579 }
3580 }
3581
3582
3583 static void GLAPIENTRY save_Translated( GLdouble x, GLdouble y, GLdouble z )
3584 {
3585 save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
3586 }
3587
3588
3589
3590 static void GLAPIENTRY save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
3591 {
3592 GET_CURRENT_CONTEXT(ctx);
3593 Node *n;
3594 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3595 n = ALLOC_INSTRUCTION( ctx, OPCODE_VIEWPORT, 4 );
3596 if (n) {
3597 n[1].i = x;
3598 n[2].i = y;
3599 n[3].i = (GLint) width;
3600 n[4].i = (GLint) height;
3601 }
3602 if (ctx->ExecuteFlag) {
3603 (*ctx->Exec->Viewport)( x, y, width, height );
3604 }
3605 }
3606
3607
3608 static void GLAPIENTRY save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
3609 {
3610 GET_CURRENT_CONTEXT(ctx);
3611 Node *n;
3612 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3613 n = ALLOC_INSTRUCTION( ctx, OPCODE_WINDOW_POS, 4 );
3614 if (n) {
3615 n[1].f = x;
3616 n[2].f = y;
3617 n[3].f = z;
3618 n[4].f = w;
3619 }
3620 if (ctx->ExecuteFlag) {
3621 (*ctx->Exec->WindowPos4fMESA)( x, y, z, w );
3622 }
3623 }
3624
3625 static void GLAPIENTRY save_WindowPos2dMESA(GLdouble x, GLdouble y)
3626 {
3627 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3628 }
3629
3630 static void GLAPIENTRY save_WindowPos2fMESA(GLfloat x, GLfloat y)
3631 {
3632 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3633 }
3634
3635 static void GLAPIENTRY save_WindowPos2iMESA(GLint x, GLint y)
3636 {
3637 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3638 }
3639
3640 static void GLAPIENTRY save_WindowPos2sMESA(GLshort x, GLshort y)
3641 {
3642 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3643 }
3644
3645 static void GLAPIENTRY save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
3646 {
3647 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3648 }
3649
3650 static void GLAPIENTRY save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
3651 {
3652 save_WindowPos4fMESA(x, y, z, 1.0F);
3653 }
3654
3655 static void GLAPIENTRY save_WindowPos3iMESA(GLint x, GLint y, GLint z)
3656 {
3657 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3658 }
3659
3660 static void GLAPIENTRY save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
3661 {
3662 save_WindowPos4fMESA(x, y, z, 1.0F);
3663 }
3664
3665 static void GLAPIENTRY save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3666 {
3667 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3668 }
3669
3670 static void GLAPIENTRY save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
3671 {
3672 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3673 }
3674
3675 static void GLAPIENTRY save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
3676 {
3677 save_WindowPos4fMESA(x, y, z, w);
3678 }
3679
3680 static void GLAPIENTRY save_WindowPos2dvMESA(const GLdouble *v)
3681 {
3682 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3683 }
3684
3685 static void GLAPIENTRY save_WindowPos2fvMESA(const GLfloat *v)
3686 {
3687 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3688 }
3689
3690 static void GLAPIENTRY save_WindowPos2ivMESA(const GLint *v)
3691 {
3692 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3693 }
3694
3695 static void GLAPIENTRY save_WindowPos2svMESA(const GLshort *v)
3696 {
3697 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3698 }
3699
3700 static void GLAPIENTRY save_WindowPos3dvMESA(const GLdouble *v)
3701 {
3702 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3703 }
3704
3705 static void GLAPIENTRY save_WindowPos3fvMESA(const GLfloat *v)
3706 {
3707 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3708 }
3709
3710 static void GLAPIENTRY save_WindowPos3ivMESA(const GLint *v)
3711 {
3712 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3713 }
3714
3715 static void GLAPIENTRY save_WindowPos3svMESA(const GLshort *v)
3716 {
3717 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3718 }
3719
3720 static void GLAPIENTRY save_WindowPos4dvMESA(const GLdouble *v)
3721 {
3722 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
3723 (GLfloat) v[2], (GLfloat) v[3]);
3724 }
3725
3726 static void GLAPIENTRY save_WindowPos4fvMESA(const GLfloat *v)
3727 {
3728 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3729 }
3730
3731 static void GLAPIENTRY save_WindowPos4ivMESA(const GLint *v)
3732 {
3733 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
3734 (GLfloat) v[2], (GLfloat) v[3]);
3735 }
3736
3737 static void GLAPIENTRY save_WindowPos4svMESA(const GLshort *v)
3738 {
3739 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3740 }
3741
3742
3743
3744 /* GL_ARB_multitexture */
3745 static void GLAPIENTRY save_ActiveTextureARB( GLenum target )
3746 {
3747 GET_CURRENT_CONTEXT(ctx);
3748 Node *n;
3749 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3750 n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
3751 if (n) {
3752 n[1].e = target;
3753 }
3754 if (ctx->ExecuteFlag) {
3755 (*ctx->Exec->ActiveTextureARB)( target );
3756 }
3757 }
3758
3759
3760 /* GL_ARB_transpose_matrix */
3761
3762 static void GLAPIENTRY save_LoadTransposeMatrixdARB( const GLdouble m[16] )
3763 {
3764 GLfloat tm[16];
3765 _math_transposefd(tm, m);
3766 save_LoadMatrixf(tm);
3767 }
3768
3769
3770 static void GLAPIENTRY save_LoadTransposeMatrixfARB( const GLfloat m[16] )
3771 {
3772 GLfloat tm[16];
3773 _math_transposef(tm, m);
3774 save_LoadMatrixf(tm);
3775 }
3776
3777
3778 static void GLAPIENTRY
3779 save_MultTransposeMatrixdARB( const GLdouble m[16] )
3780 {
3781 GLfloat tm[16];
3782 _math_transposefd(tm, m);
3783 save_MultMatrixf(tm);
3784 }
3785
3786
3787 static void GLAPIENTRY
3788 save_MultTransposeMatrixfARB( const GLfloat m[16] )
3789 {
3790 GLfloat tm[16];
3791 _math_transposef(tm, m);
3792 save_MultMatrixf(tm);
3793 }
3794
3795
3796 static void GLAPIENTRY
3797 save_PixelTexGenSGIX(GLenum mode)
3798 {
3799 GET_CURRENT_CONTEXT(ctx);
3800 Node *n;
3801 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3802 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_SGIX, 1 );
3803 if (n) {
3804 n[1].e = mode;
3805 }
3806 if (ctx->ExecuteFlag) {
3807 (*ctx->Exec->PixelTexGenSGIX)( mode );
3808 }
3809 }
3810
3811
3812 /* GL_ARB_texture_compression */
3813 static void GLAPIENTRY
3814 save_CompressedTexImage1DARB(GLenum target, GLint level,
3815 GLenum internalFormat, GLsizei width,
3816 GLint border, GLsizei imageSize,
3817 const GLvoid *data)
3818 {
3819 GET_CURRENT_CONTEXT(ctx);
3820 if (target == GL_PROXY_TEXTURE_1D) {
3821 /* don't compile, execute immediately */
3822 (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat,
3823 width, border, imageSize, data);
3824 }
3825 else {
3826 Node *n;
3827 GLvoid *image;
3828 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3829 /* make copy of image */
3830 image = MALLOC(imageSize);
3831 if (!image) {
3832 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
3833 return;
3834 }
3835 MEMCPY(image, data, imageSize);
3836 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7 );
3837 if (n) {
3838 n[1].e = target;
3839 n[2].i = level;
3840 n[3].e = internalFormat;
3841 n[4].i = (GLint) width;
3842 n[5].i = border;
3843 n[6].i = imageSize;
3844 n[7].data = image;
3845 }
3846 else if (image) {
3847 FREE(image);
3848 }
3849 if (ctx->ExecuteFlag) {
3850 (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat,
3851 width, border, imageSize, data);
3852 }
3853 }
3854 }
3855
3856
3857 static void GLAPIENTRY
3858 save_CompressedTexImage2DARB(GLenum target, GLint level,
3859 GLenum internalFormat, GLsizei width,
3860 GLsizei height, GLint border, GLsizei imageSize,
3861 const GLvoid *data)
3862 {
3863 GET_CURRENT_CONTEXT(ctx);
3864 if (target == GL_PROXY_TEXTURE_2D) {
3865 /* don't compile, execute immediately */
3866 (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat,
3867 width, height, border, imageSize, data);
3868 }
3869 else {
3870 Node *n;
3871 GLvoid *image;
3872 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3873 /* make copy of image */
3874 image = MALLOC(imageSize);
3875 if (!image) {
3876 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
3877 return;
3878 }
3879 MEMCPY(image, data, imageSize);
3880 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8 );
3881 if (n) {
3882 n[1].e = target;
3883 n[2].i = level;
3884 n[3].e = internalFormat;
3885 n[4].i = (GLint) width;
3886 n[5].i = (GLint) height;
3887 n[6].i = border;
3888 n[7].i = imageSize;
3889 n[8].data = image;
3890 }
3891 else if (image) {
3892 FREE(image);
3893 }
3894 if (ctx->ExecuteFlag) {
3895 (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat,
3896 width, height, border, imageSize, data);
3897 }
3898 }
3899 }
3900
3901
3902 static void GLAPIENTRY
3903 save_CompressedTexImage3DARB(GLenum target, GLint level,
3904 GLenum internalFormat, GLsizei width,
3905 GLsizei height, GLsizei depth, GLint border,
3906 GLsizei imageSize, const GLvoid *data)
3907 {
3908 GET_CURRENT_CONTEXT(ctx);
3909 if (target == GL_PROXY_TEXTURE_3D) {
3910 /* don't compile, execute immediately */
3911 (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat,
3912 width, height, depth, border, imageSize, data);
3913 }
3914 else {
3915 Node *n;
3916 GLvoid *image;
3917 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3918 /* make copy of image */
3919 image = MALLOC(imageSize);
3920 if (!image) {
3921 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
3922 return;
3923 }
3924 MEMCPY(image, data, imageSize);
3925 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9 );
3926 if (n) {
3927 n[1].e = target;
3928 n[2].i = level;
3929 n[3].e = internalFormat;
3930 n[4].i = (GLint) width;
3931 n[5].i = (GLint) height;
3932 n[6].i = (GLint) depth;
3933 n[7].i = border;
3934 n[8].i = imageSize;
3935 n[9].data = image;
3936 }
3937 else if (image) {
3938 FREE(image);
3939 }
3940 if (ctx->ExecuteFlag) {
3941 (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat,
3942 width, height, depth, border, imageSize, data);
3943 }
3944 }
3945 }
3946
3947
3948 static void GLAPIENTRY
3949 save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
3950 GLsizei width, GLenum format,
3951 GLsizei imageSize, const GLvoid *data)
3952 {
3953 Node *n;
3954 GLvoid *image;
3955
3956 GET_CURRENT_CONTEXT(ctx);
3957 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3958
3959 /* make copy of image */
3960 image = MALLOC(imageSize);
3961 if (!image) {
3962 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
3963 return;
3964 }
3965 MEMCPY(image, data, imageSize);
3966 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7 );
3967 if (n) {
3968 n[1].e = target;
3969 n[2].i = level;
3970 n[3].i = xoffset;
3971 n[4].i = (GLint) width;
3972 n[5].e = format;
3973 n[6].i = imageSize;
3974 n[7].data = image;
3975 }
3976 else if (image) {
3977 FREE(image);
3978 }
3979 if (ctx->ExecuteFlag) {
3980 (*ctx->Exec->CompressedTexSubImage1DARB)(target, level, xoffset,
3981 width, format, imageSize, data);
3982 }
3983 }
3984
3985
3986 static void GLAPIENTRY
3987 save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
3988 GLint yoffset, GLsizei width, GLsizei height,
3989 GLenum format, GLsizei imageSize,
3990 const GLvoid *data)
3991 {
3992 Node *n;
3993 GLvoid *image;
3994
3995 GET_CURRENT_CONTEXT(ctx);
3996 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3997
3998 /* make copy of image */
3999 image = MALLOC(imageSize);
4000 if (!image) {
4001 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
4002 return;
4003 }
4004 MEMCPY(image, data, imageSize);
4005 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9 );
4006 if (n) {
4007 n[1].e = target;
4008 n[2].i = level;
4009 n[3].i = xoffset;
4010 n[4].i = yoffset;
4011 n[5].i = (GLint) width;
4012 n[6].i = (GLint) height;
4013 n[7].e = format;
4014 n[8].i = imageSize;
4015 n[9].data = image;
4016 }
4017 else if (image) {
4018 FREE(image);
4019 }
4020 if (ctx->ExecuteFlag) {
4021 (*ctx->Exec->CompressedTexSubImage2DARB)(target, level, xoffset, yoffset,
4022 width, height, format, imageSize, data);
4023 }
4024 }
4025
4026
4027 static void GLAPIENTRY
4028 save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
4029 GLint yoffset, GLint zoffset, GLsizei width,
4030 GLsizei height, GLsizei depth, GLenum format,
4031 GLsizei imageSize, const GLvoid *data)
4032 {
4033 Node *n;
4034 GLvoid *image;
4035
4036 GET_CURRENT_CONTEXT(ctx);
4037 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4038
4039 /* make copy of image */
4040 image = MALLOC(imageSize);
4041 if (!image) {
4042 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
4043 return;
4044 }
4045 MEMCPY(image, data, imageSize);
4046 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11 );
4047 if (n) {
4048 n[1].e = target;
4049 n[2].i = level;
4050 n[3].i = xoffset;
4051 n[4].i = yoffset;
4052 n[5].i = zoffset;
4053 n[6].i = (GLint) width;
4054 n[7].i = (GLint) height;
4055 n[8].i = (GLint) depth;
4056 n[9].e = format;
4057 n[10].i = imageSize;
4058 n[11].data = image;
4059 }
4060 else if (image) {
4061 FREE(image);
4062 }
4063 if (ctx->ExecuteFlag) {
4064 (*ctx->Exec->CompressedTexSubImage3DARB)(target, level, xoffset, yoffset,
4065 zoffset, width, height, depth, format, imageSize, data);
4066 }
4067 }
4068
4069
4070 /* GL_ARB_multisample */
4071 static void GLAPIENTRY
4072 save_SampleCoverageARB(GLclampf value, GLboolean invert)
4073 {
4074 GET_CURRENT_CONTEXT(ctx);
4075 Node *n;
4076 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4077 n = ALLOC_INSTRUCTION( ctx, OPCODE_SAMPLE_COVERAGE, 2 );
4078 if (n) {
4079 n[1].f = value;
4080 n[2].b = invert;
4081 }
4082 if (ctx->ExecuteFlag) {
4083 (*ctx->Exec->SampleCoverageARB)( value, invert );
4084 }
4085 }
4086
4087
4088 /* GL_SGIS_pixel_texture */
4089
4090 static void GLAPIENTRY
4091 save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
4092 {
4093 GET_CURRENT_CONTEXT(ctx);
4094 Node *n;
4095 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4096 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, 2 );
4097 if (n) {
4098 n[1].e = target;
4099 n[2].i = value;
4100 }
4101 if (ctx->ExecuteFlag) {
4102 (*ctx->Exec->PixelTexGenParameteriSGIS)( target, value );
4103 }
4104 }
4105
4106
4107 static void GLAPIENTRY
4108 save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
4109 {
4110 save_PixelTexGenParameteriSGIS(target, (GLint) value);
4111 }
4112
4113
4114 static void GLAPIENTRY
4115 save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
4116 {
4117 save_PixelTexGenParameteriSGIS(target, *value);
4118 }
4119
4120
4121 static void GLAPIENTRY
4122 save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
4123 {
4124 save_PixelTexGenParameteriSGIS(target, (GLint) *value);
4125 }
4126
4127
4128 /*
4129 * GL_NV_vertex_program
4130 */
4131 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
4132 static void GLAPIENTRY
4133 save_BindProgramNV(GLenum target, GLuint id)
4134 {
4135 GET_CURRENT_CONTEXT(ctx);
4136 Node *n;
4137 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4138 n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_PROGRAM_NV, 2 );
4139 if (n) {
4140 n[1].e = target;
4141 n[2].ui = id;
4142 }
4143 if (ctx->ExecuteFlag) {
4144 (*ctx->Exec->BindProgramNV)( target, id );
4145 }
4146 }
4147 #endif /* FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
4148
4149 #if FEATURE_NV_vertex_program
4150 static void GLAPIENTRY
4151 save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
4152 {
4153 GET_CURRENT_CONTEXT(ctx);
4154 Node *n;
4155 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4156 n = ALLOC_INSTRUCTION( ctx, OPCODE_EXECUTE_PROGRAM_NV, 6 );
4157 if (n) {
4158 n[1].e = target;
4159 n[2].ui = id;
4160 n[3].f = params[0];
4161 n[4].f = params[1];
4162 n[5].f = params[2];
4163 n[6].f = params[3];
4164 }
4165 if (ctx->ExecuteFlag) {
4166 (*ctx->Exec->ExecuteProgramNV)(target, id, params);
4167 }
4168 }
4169
4170
4171 static void GLAPIENTRY
4172 save_ProgramParameter4fNV(GLenum target, GLuint index,
4173 GLfloat x, GLfloat y,
4174 GLfloat z, GLfloat w)
4175 {
4176 GET_CURRENT_CONTEXT(ctx);
4177 Node *n;
4178 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4179 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_PARAMETER4F_NV, 6 );
4180 if (n) {
4181 n[1].e = target;
4182 n[2].ui = index;
4183 n[3].f = x;
4184 n[4].f = y;
4185 n[5].f = z;
4186 n[6].f = w;
4187 }
4188 if (ctx->ExecuteFlag) {
4189 (*ctx->Exec->ProgramParameter4fNV)(target, index, x, y, z, w);
4190 }
4191 }
4192
4193
4194 static void GLAPIENTRY
4195 save_ProgramParameter4fvNV(GLenum target, GLuint index, const GLfloat *params)
4196 {
4197 save_ProgramParameter4fNV(target, index, params[0], params[1],
4198 params[2], params[3]);
4199 }
4200
4201
4202 static void GLAPIENTRY
4203 save_ProgramParameter4dNV(GLenum target, GLuint index,
4204 GLdouble x, GLdouble y,
4205 GLdouble z, GLdouble w)
4206 {
4207 save_ProgramParameter4fNV(target, index, (GLfloat) x, (GLfloat) y,
4208 (GLfloat) z, (GLfloat) w);
4209 }
4210
4211
4212 static void GLAPIENTRY
4213 save_ProgramParameter4dvNV(GLenum target, GLuint index,
4214 const GLdouble *params)
4215 {
4216 save_ProgramParameter4fNV(target, index, (GLfloat) params[0],
4217 (GLfloat) params[1], (GLfloat) params[2],
4218 (GLfloat) params[3]);
4219 }
4220
4221
4222 static void GLAPIENTRY
4223 save_ProgramParameters4dvNV(GLenum target, GLuint index,
4224 GLuint num, const GLdouble *params)
4225 {
4226 GLuint i;
4227 for (i = 0; i < num; i++) {
4228 save_ProgramParameter4dvNV(target, index + i, params + 4 * i);
4229 }
4230 }
4231
4232
4233 static void GLAPIENTRY
4234 save_ProgramParameters4fvNV(GLenum target, GLuint index,
4235 GLuint num, const GLfloat *params)
4236 {
4237 GLuint i;
4238 for (i = 0; i < num; i++) {
4239 save_ProgramParameter4fvNV(target, index + i, params + 4 * i);
4240 }
4241 }
4242
4243
4244 static void GLAPIENTRY
4245 save_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
4246 const GLubyte *program)
4247 {
4248 GET_CURRENT_CONTEXT(ctx);
4249 Node *n;
4250 GLubyte *programCopy;
4251
4252 programCopy = (GLubyte *) _mesa_malloc(len);
4253 if (!programCopy) {
4254 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
4255 return;
4256 }
4257 _mesa_memcpy(programCopy, program, len);
4258
4259 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4260 n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_PROGRAM_NV, 4 );
4261 if (n) {
4262 n[1].e = target;
4263 n[2].ui = id;
4264 n[3].i = len;
4265 n[4].data = programCopy;
4266 }
4267 if (ctx->ExecuteFlag) {
4268 (*ctx->Exec->LoadProgramNV)(target, id, len, program);
4269 }
4270 }
4271
4272
4273 static void GLAPIENTRY
4274 save_RequestResidentProgramsNV(GLsizei num, const GLuint *ids)
4275 {
4276 GET_CURRENT_CONTEXT(ctx);
4277 Node *n;
4278 GLuint *idCopy = (GLuint *) _mesa_malloc(num * sizeof(GLuint));
4279 if (!idCopy) {
4280 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV");
4281 return;
4282 }
4283 _mesa_memcpy(idCopy, ids, num * sizeof(GLuint));
4284 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4285 n = ALLOC_INSTRUCTION( ctx, OPCODE_TRACK_MATRIX_NV, 2 );
4286 if (n) {
4287 n[1].i = num;
4288 n[2].data = idCopy;
4289 }
4290 if (ctx->ExecuteFlag) {
4291 (*ctx->Exec->RequestResidentProgramsNV)(num, ids);
4292 }
4293 }
4294
4295
4296 static void GLAPIENTRY
4297 save_TrackMatrixNV(GLenum target, GLuint address,
4298 GLenum matrix, GLenum transform)
4299 {
4300 GET_CURRENT_CONTEXT(ctx);
4301 Node *n;
4302 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4303 n = ALLOC_INSTRUCTION( ctx, OPCODE_TRACK_MATRIX_NV, 4 );
4304 if (n) {
4305 n[1].e = target;
4306 n[2].ui = address;
4307 n[3].e = matrix;
4308 n[4].e = transform;
4309 }
4310 if (ctx->ExecuteFlag) {
4311 (*ctx->Exec->TrackMatrixNV)(target, address, matrix, transform);
4312 }
4313 }
4314 #endif /* FEATURE_NV_vertex_program */
4315
4316
4317 /*
4318 * GL_NV_fragment_program
4319 */
4320 #if FEATURE_NV_fragment_program
4321 static void GLAPIENTRY
4322 save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
4323 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4324 {
4325 GET_CURRENT_CONTEXT(ctx);
4326 Node *n;
4327 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4328 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
4329 if (n) {
4330 n[1].e = target;
4331 n[2].ui = index;
4332 n[3].f = x;
4333 n[4].f = y;
4334 n[5].f = z;
4335 n[6].f = w;
4336 }
4337 if (ctx->ExecuteFlag) {
4338 (*ctx->Exec->ProgramLocalParameter4fARB)(target, index, x, y, z, w);
4339 }
4340 }
4341
4342
4343 static void GLAPIENTRY
4344 save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
4345 const GLfloat *params)
4346 {
4347 GET_CURRENT_CONTEXT(ctx);
4348 Node *n;
4349 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4350 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
4351 if (n) {
4352 n[1].e = target;
4353 n[2].ui = index;
4354 n[3].f = params[0];
4355 n[4].f = params[1];
4356 n[5].f = params[2];
4357 n[6].f = params[3];
4358 }
4359 if (ctx->ExecuteFlag) {
4360 (*ctx->Exec->ProgramLocalParameter4fvARB)(target, index, params);
4361 }
4362 }
4363
4364
4365 static void GLAPIENTRY
4366 save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
4367 GLdouble x, GLdouble y,
4368 GLdouble z, GLdouble w)
4369 {
4370 GET_CURRENT_CONTEXT(ctx);
4371 Node *n;
4372 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4373 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
4374 if (n) {
4375 n[1].e = target;
4376 n[2].ui = index;
4377 n[3].f = (GLfloat) x;
4378 n[4].f = (GLfloat) y;
4379 n[5].f = (GLfloat) z;
4380 n[6].f = (GLfloat) w;
4381 }
4382 if (ctx->ExecuteFlag) {
4383 (*ctx->Exec->ProgramLocalParameter4dARB)(target, index, x, y, z, w);
4384 }
4385 }
4386
4387
4388 static void GLAPIENTRY
4389 save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
4390 const GLdouble *params)
4391 {
4392 GET_CURRENT_CONTEXT(ctx);
4393 Node *n;
4394 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4395 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
4396 if (n) {
4397 n[1].e = target;
4398 n[2].ui = index;
4399 n[3].f = (GLfloat) params[0];
4400 n[4].f = (GLfloat) params[1];
4401 n[5].f = (GLfloat) params[2];
4402 n[6].f = (GLfloat) params[3];
4403 }
4404 if (ctx->ExecuteFlag) {
4405 (*ctx->Exec->ProgramLocalParameter4dvARB)(target, index, params);
4406 }
4407 }
4408
4409 static void GLAPIENTRY
4410 save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
4411 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4412 {
4413 GET_CURRENT_CONTEXT(ctx);
4414 Node *n;
4415 GLubyte *nameCopy = (GLubyte *) _mesa_malloc(len);
4416 if (!nameCopy) {
4417 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV");
4418 return;
4419 }
4420 _mesa_memcpy(nameCopy, name, len);
4421
4422 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4423 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6 );
4424 if (n) {
4425 n[1].ui = id;
4426 n[2].i = len;
4427 n[3].data = nameCopy;
4428 n[4].f = x;
4429 n[5].f = y;
4430 n[6].f = z;
4431 n[7].f = w;
4432 }
4433 if (ctx->ExecuteFlag) {
4434 (*ctx->Exec->ProgramNamedParameter4fNV)(id, len, name, x, y, z, w);
4435 }
4436 }
4437
4438
4439 static void GLAPIENTRY
4440 save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name,
4441 const float v[])
4442 {
4443 save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]);
4444 }
4445
4446
4447 static void GLAPIENTRY
4448 save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name,
4449 GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4450 {
4451 save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y,
4452 (GLfloat) z,(GLfloat) w);
4453 }
4454
4455
4456 static void GLAPIENTRY
4457 save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name,
4458 const double v[])
4459 {
4460 save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0],
4461 (GLfloat) v[1], (GLfloat) v[2],
4462 (GLfloat) v[3]);
4463 }
4464
4465 #endif /* FEATURE_NV_fragment_program */
4466
4467
4468
4469 /* GL_EXT_stencil_two_side */
4470 static void GLAPIENTRY save_ActiveStencilFaceEXT( GLenum face )
4471 {
4472 GET_CURRENT_CONTEXT(ctx);
4473 Node *n;
4474 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4475 n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1 );
4476 if (n) {
4477 n[1].e = face;
4478 }
4479 if (ctx->ExecuteFlag) {
4480 (*ctx->Exec->ActiveStencilFaceEXT)( face );
4481 }
4482 }
4483
4484
4485 /* GL_EXT_depth_bounds_test */
4486 static void GLAPIENTRY save_DepthBoundsEXT( GLclampd zmin, GLclampd zmax )
4487 {
4488 GET_CURRENT_CONTEXT(ctx);
4489 Node *n;
4490 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4491 n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 2 );
4492 if (n) {
4493 n[1].f = (GLfloat) zmin;
4494 n[2].f = (GLfloat) zmax;
4495 }
4496 if (ctx->ExecuteFlag) {
4497 (*ctx->Exec->DepthBoundsEXT)( zmin, zmax );
4498 }
4499 }
4500
4501
4502
4503 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
4504
4505 static void GLAPIENTRY
4506 save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
4507 const GLvoid *string)
4508 {
4509 GET_CURRENT_CONTEXT(ctx);
4510 Node *n;
4511 GLubyte *programCopy;
4512
4513 programCopy = (GLubyte *) _mesa_malloc(len);
4514 if (!programCopy) {
4515 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
4516 return;
4517 }
4518 _mesa_memcpy(programCopy, string, len);
4519
4520 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4521 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_STRING_ARB, 4 );
4522 if (n) {
4523 n[1].e = target;
4524 n[2].e = format;
4525 n[3].i = len;
4526 n[4].data = programCopy;
4527 }
4528 if (ctx->ExecuteFlag) {
4529 (*ctx->Exec->ProgramStringARB)(target, format, len, string);
4530 }
4531 }
4532
4533
4534 static void GLAPIENTRY
4535 save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
4536 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4537 {
4538 GET_CURRENT_CONTEXT(ctx);
4539 Node *n;
4540 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4541 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6 );
4542 if (n) {
4543 n[1].e = target;
4544 n[2].ui = index;
4545 n[3].f = x;
4546 n[4].f = y;
4547 n[5].f = z;
4548 n[6].f = w;
4549 }
4550 if (ctx->ExecuteFlag) {
4551 (*ctx->Exec->ProgramEnvParameter4fARB)( target, index, x, y, z, w);
4552 }
4553 }
4554
4555
4556 static void GLAPIENTRY
4557 save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
4558 const GLfloat *params)
4559 {
4560 save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
4561 params[2], params[3]);
4562 }
4563
4564
4565 static void GLAPIENTRY
4566 save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
4567 GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4568 {
4569 save_ProgramEnvParameter4fARB(target, index,
4570 (GLfloat) x,
4571 (GLfloat) y,
4572 (GLfloat) z,
4573 (GLfloat) w);
4574 }
4575
4576
4577 static void GLAPIENTRY
4578 save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
4579 const GLdouble *params)
4580 {
4581 save_ProgramEnvParameter4fARB(target, index,
4582 (GLfloat) params[0],
4583 (GLfloat) params[1],
4584 (GLfloat) params[2],
4585 (GLfloat) params[3]);
4586 }
4587
4588 #endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
4589
4590
4591
4592
4593 static void save_Attr1f( GLenum attr, GLfloat x )
4594 {
4595 GET_CURRENT_CONTEXT(ctx);
4596 Node *n;
4597 SAVE_FLUSH_VERTICES( ctx );
4598 n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_1F, 2 );
4599 if (n) {
4600 n[1].e = attr;
4601 n[2].f = x;
4602 }
4603
4604 ctx->ListState.ActiveAttribSize[attr] = 1;
4605 ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
4606
4607 if (ctx->ExecuteFlag) {
4608 (*ctx->Exec->VertexAttrib1fNV)( attr, x );
4609 }
4610 }
4611
4612 static void save_Attr2f( GLenum attr, GLfloat x, GLfloat y )
4613 {
4614 GET_CURRENT_CONTEXT(ctx);
4615 Node *n;
4616 SAVE_FLUSH_VERTICES( ctx );
4617 n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_2F, 3 );
4618 if (n) {
4619 n[1].e = attr;
4620 n[2].f = x;
4621 n[3].f = y;
4622 }
4623
4624 ctx->ListState.ActiveAttribSize[attr] = 2;
4625 ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
4626
4627 if (ctx->ExecuteFlag) {
4628 (*ctx->Exec->VertexAttrib2fNV)( attr, x, y );
4629 }
4630 }
4631
4632 static void save_Attr3f( GLenum attr, GLfloat x, GLfloat y, GLfloat z )
4633 {
4634 GET_CURRENT_CONTEXT(ctx);
4635 Node *n;
4636 SAVE_FLUSH_VERTICES( ctx );
4637 n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_3F, 4 );
4638 if (n) {
4639 n[1].e = attr;
4640 n[2].f = x;
4641 n[3].f = y;
4642 n[4].f = z;
4643 }
4644
4645 ctx->ListState.ActiveAttribSize[attr] = 3;
4646 ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
4647
4648 if (ctx->ExecuteFlag) {
4649 (*ctx->Exec->VertexAttrib3fNV)( attr, x, y, z );
4650 }
4651 }
4652
4653 static void save_Attr4f( GLenum attr, GLfloat x, GLfloat y, GLfloat z,
4654 GLfloat w )
4655 {
4656 GET_CURRENT_CONTEXT(ctx);
4657 Node *n;
4658 SAVE_FLUSH_VERTICES( ctx );
4659 n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_4F, 5 );
4660 if (n) {
4661 n[1].e = attr;
4662 n[2].f = x;
4663 n[3].f = y;
4664 n[4].f = z;
4665 n[5].f = w;
4666 }
4667
4668 ctx->ListState.ActiveAttribSize[attr] = 4;
4669 ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, w);
4670
4671 if (ctx->ExecuteFlag) {
4672 (*ctx->Exec->VertexAttrib4fNV)( attr, x, y, z, w );
4673 }
4674 }
4675
4676 static void GLAPIENTRY save_EvalCoord1f( GLfloat x )
4677 {
4678 GET_CURRENT_CONTEXT(ctx);
4679 Node *n;
4680 SAVE_FLUSH_VERTICES( ctx );
4681 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_C1, 1 );
4682 if (n) {
4683 n[1].f = x;
4684 }
4685 if (ctx->ExecuteFlag) {
4686 (*ctx->Exec->EvalCoord1f)( x );
4687 }
4688 }
4689
4690 static void GLAPIENTRY save_EvalCoord1fv( const GLfloat *v )
4691 {
4692 save_EvalCoord1f( v[0] );
4693 }
4694
4695 static void GLAPIENTRY save_EvalCoord2f( GLfloat x, GLfloat y )
4696 {
4697 GET_CURRENT_CONTEXT(ctx);
4698 Node *n;
4699 SAVE_FLUSH_VERTICES( ctx );
4700 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_C2, 2 );
4701 if (n) {
4702 n[1].f = x;
4703 n[2].f = y;
4704 }
4705 if (ctx->ExecuteFlag) {
4706 (*ctx->Exec->EvalCoord2f)( x, y );
4707 }
4708 }
4709
4710 static void GLAPIENTRY save_EvalCoord2fv( const GLfloat *v )
4711 {
4712 save_EvalCoord2f( v[0], v[1] );
4713 }
4714
4715
4716 static void GLAPIENTRY save_EvalPoint1( GLint x )
4717 {
4718 GET_CURRENT_CONTEXT(ctx);
4719 Node *n;
4720 SAVE_FLUSH_VERTICES( ctx );
4721 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_P1, 1 );
4722 if (n) {
4723 n[1].i = x;
4724 }
4725 if (ctx->ExecuteFlag) {
4726 (*ctx->Exec->EvalPoint1)( x );
4727 }
4728 }
4729
4730 static void GLAPIENTRY save_EvalPoint2( GLint x, GLint y )
4731 {
4732 GET_CURRENT_CONTEXT(ctx);
4733 Node *n;
4734 SAVE_FLUSH_VERTICES( ctx );
4735 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_P2, 2 );
4736 if (n) {
4737 n[1].i = x;
4738 n[2].i = y;
4739 }
4740 if (ctx->ExecuteFlag) {
4741 (*ctx->Exec->EvalPoint2)( x, y );
4742 }
4743 }
4744
4745 static void GLAPIENTRY save_Indexf( GLfloat x )
4746 {
4747 GET_CURRENT_CONTEXT(ctx);
4748 Node *n;
4749 SAVE_FLUSH_VERTICES( ctx );
4750 n = ALLOC_INSTRUCTION( ctx, OPCODE_INDEX, 1 );
4751 if (n) {
4752 n[1].f = x;
4753 }
4754
4755 ctx->ListState.ActiveIndex = 1;
4756 ctx->ListState.CurrentIndex = x;
4757
4758 if (ctx->ExecuteFlag) {
4759 (*ctx->Exec->Indexi)( (GLint) x );
4760 }
4761 }
4762
4763 static void GLAPIENTRY save_Indexfv( const GLfloat *v )
4764 {
4765 save_Indexf( v[0] );
4766 }
4767
4768 static void GLAPIENTRY save_EdgeFlag( GLboolean x )
4769 {
4770 GET_CURRENT_CONTEXT(ctx);
4771 Node *n;
4772 SAVE_FLUSH_VERTICES( ctx );
4773 n = ALLOC_INSTRUCTION( ctx, OPCODE_EDGEFLAG, 1 );
4774 if (n) {
4775 n[1].b = x;
4776 }
4777
4778 ctx->ListState.ActiveEdgeFlag = 1;
4779 ctx->ListState.CurrentEdgeFlag = x;
4780
4781 if (ctx->ExecuteFlag) {
4782 (*ctx->Exec->EdgeFlag)( x );
4783 }
4784 }
4785
4786 static void GLAPIENTRY save_EdgeFlagv( const GLboolean *v )
4787 {
4788 save_EdgeFlag( v[0] );
4789 }
4790
4791 static void GLAPIENTRY save_Materialfv( GLenum face, GLenum pname, const GLfloat *param )
4792 {
4793 GET_CURRENT_CONTEXT(ctx);
4794 Node *n;
4795 int args, i;
4796
4797 SAVE_FLUSH_VERTICES( ctx );
4798
4799 switch (face) {
4800 case GL_BACK:
4801 case GL_FRONT:
4802 case GL_FRONT_AND_BACK:
4803 break;
4804 default:
4805 _mesa_compile_error( ctx, GL_INVALID_ENUM, "material(face)" );
4806 return;
4807 }
4808
4809 switch (pname) {
4810 case GL_EMISSION:
4811 case GL_AMBIENT:
4812 case GL_DIFFUSE:
4813 case GL_SPECULAR:
4814 case GL_AMBIENT_AND_DIFFUSE:
4815 args = 4;
4816 break;
4817 case GL_SHININESS:
4818 args = 1;
4819 break;
4820 case GL_COLOR_INDEXES:
4821 args = 3;
4822 break;
4823 default:
4824 _mesa_compile_error( ctx, GL_INVALID_ENUM, "material(pname)" );
4825 return;
4826 }
4827
4828 n = ALLOC_INSTRUCTION( ctx, OPCODE_MATERIAL, 6 );
4829 if (n) {
4830 n[1].e = face;
4831 n[2].e = pname;
4832 for (i = 0 ; i < args ; i++)
4833 n[3+i].f = param[i];
4834 }
4835
4836 {
4837 GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0, 0 );
4838 for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
4839 if (bitmask & (1<<i)) {
4840 ctx->ListState.ActiveMaterialSize[i] = args;
4841 COPY_SZ_4V( ctx->ListState.CurrentMaterial[i], args, param );
4842 }
4843 }
4844
4845 if (ctx->ExecuteFlag) {
4846 (*ctx->Exec->Materialfv)( face, pname, param );
4847 }
4848 }
4849
4850 static void GLAPIENTRY save_Begin( GLenum mode )
4851 {
4852 GET_CURRENT_CONTEXT(ctx);
4853 Node *n;
4854 GLboolean error = GL_FALSE;
4855
4856 if (mode < GL_POINTS || mode > GL_POLYGON) {
4857 _mesa_compile_error( ctx, GL_INVALID_ENUM, "Begin (mode)");
4858 error = GL_TRUE;
4859 }
4860 else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) {
4861 /* Typically the first begin. This may raise an error on
4862 * playback, depending on whether CallList is issued from inside
4863 * a begin/end or not.
4864 */
4865 ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM;
4866 }
4867 else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) {
4868 ctx->Driver.CurrentSavePrimitive = mode;
4869 }
4870 else {
4871 _mesa_compile_error( ctx, GL_INVALID_OPERATION, "recursive begin" );
4872 error = GL_TRUE;
4873 }
4874
4875 if (!error) {
4876 /* Give the driver an opportunity to hook in an optimized
4877 * display list compiler.
4878 */
4879 if (ctx->Driver.NotifySaveBegin( ctx, mode ))
4880 return;
4881
4882 SAVE_FLUSH_VERTICES( ctx );
4883 n = ALLOC_INSTRUCTION( ctx, OPCODE_BEGIN, 1 );
4884 if (n) {
4885 n[1].e = mode;
4886 }
4887 }
4888
4889 if (ctx->ExecuteFlag) {
4890 (*ctx->Exec->Begin)( mode );
4891 }
4892 }
4893
4894 static void GLAPIENTRY save_End( void )
4895 {
4896 GET_CURRENT_CONTEXT(ctx);
4897 SAVE_FLUSH_VERTICES( ctx );
4898 (void) ALLOC_INSTRUCTION( ctx, OPCODE_END, 0 );
4899 ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
4900 if (ctx->ExecuteFlag) {
4901 (*ctx->Exec->End)( );
4902 }
4903 }
4904
4905 static void GLAPIENTRY save_Rectf( GLfloat a, GLfloat b,
4906 GLfloat c, GLfloat d )
4907 {
4908 GET_CURRENT_CONTEXT(ctx);
4909 Node *n;
4910 SAVE_FLUSH_VERTICES( ctx );
4911 n = ALLOC_INSTRUCTION( ctx, OPCODE_RECTF, 4 );
4912 if (n) {
4913 n[1].f = a;
4914 n[2].f = b;
4915 n[3].f = c;
4916 n[4].f = d;
4917 }
4918 if (ctx->ExecuteFlag) {
4919 (*ctx->Exec->Rectf)( a, b, c, d );
4920 }
4921 }
4922
4923 /*
4924 */
4925 static void GLAPIENTRY save_Vertex2f( GLfloat x, GLfloat y )
4926 {
4927 save_Attr2f( VERT_ATTRIB_POS, x, y );
4928 }
4929
4930 static void GLAPIENTRY save_Vertex2fv( const GLfloat *v )
4931 {
4932 save_Attr2f( VERT_ATTRIB_POS, v[0], v[1] );
4933 }
4934
4935 static void GLAPIENTRY save_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
4936 {
4937 save_Attr3f( VERT_ATTRIB_POS, x, y, z );
4938 }
4939
4940 static void GLAPIENTRY save_Vertex3fv( const GLfloat *v )
4941 {
4942 save_Attr3f( VERT_ATTRIB_POS, v[0], v[1], v[2] );
4943 }
4944
4945 static void GLAPIENTRY save_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
4946 {
4947 save_Attr4f( VERT_ATTRIB_POS, x, y, z, w );
4948 }
4949
4950 static void GLAPIENTRY save_Vertex4fv( const GLfloat *v )
4951 {
4952 save_Attr4f( VERT_ATTRIB_POS, v[0], v[1], v[2], v[3] );
4953 }
4954
4955 static void GLAPIENTRY save_TexCoord1f( GLfloat x )
4956 {
4957 save_Attr1f( VERT_ATTRIB_TEX0, x );
4958 }
4959
4960 static void GLAPIENTRY save_TexCoord1fv( const GLfloat *v )
4961 {
4962 save_Attr1f( VERT_ATTRIB_TEX0, v[0] );
4963 }
4964
4965 static void GLAPIENTRY save_TexCoord2f( GLfloat x, GLfloat y )
4966 {
4967 save_Attr2f( VERT_ATTRIB_TEX0, x, y );
4968 }
4969
4970 static void GLAPIENTRY save_TexCoord2fv( const GLfloat *v )
4971 {
4972 save_Attr2f( VERT_ATTRIB_TEX0, v[0], v[1] );
4973 }
4974
4975 static void GLAPIENTRY save_TexCoord3f( GLfloat x, GLfloat y, GLfloat z )
4976 {
4977 save_Attr3f( VERT_ATTRIB_TEX0, x, y, z );
4978 }
4979
4980 static void GLAPIENTRY save_TexCoord3fv( const GLfloat *v )
4981 {
4982 save_Attr3f( VERT_ATTRIB_TEX0, v[0], v[1], v[2] );
4983 }
4984
4985 static void GLAPIENTRY save_TexCoord4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
4986 {
4987 save_Attr4f( VERT_ATTRIB_TEX0, x, y, z, w );
4988 }
4989
4990 static void GLAPIENTRY save_TexCoord4fv( const GLfloat *v )
4991 {
4992 save_Attr4f( VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3] );
4993 }
4994
4995 static void GLAPIENTRY save_Normal3f( GLfloat x, GLfloat y, GLfloat z )
4996 {
4997 save_Attr3f( VERT_ATTRIB_NORMAL, x, y, z );
4998 }
4999
5000 static void GLAPIENTRY save_Normal3fv( const GLfloat *v )
5001 {
5002 save_Attr3f( VERT_ATTRIB_NORMAL, v[0], v[1], v[2] );
5003 }
5004
5005 static void GLAPIENTRY save_FogCoordfEXT( GLfloat x )
5006 {
5007 save_Attr1f( VERT_ATTRIB_FOG, x );
5008 }
5009
5010 static void GLAPIENTRY save_FogCoordfvEXT( const GLfloat *v )
5011 {
5012 save_Attr1f( VERT_ATTRIB_FOG, v[0] );
5013 }
5014
5015 static void GLAPIENTRY save_Color3f( GLfloat x, GLfloat y, GLfloat z )
5016 {
5017 save_Attr3f( VERT_ATTRIB_COLOR0, x, y, z );
5018 }
5019
5020 static void GLAPIENTRY save_Color3fv( const GLfloat *v )
5021 {
5022 save_Attr3f( VERT_ATTRIB_COLOR0, v[0], v[1], v[2] );
5023 }
5024
5025 static void GLAPIENTRY save_Color4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
5026 {
5027 save_Attr4f( VERT_ATTRIB_COLOR0, x, y, z, w );
5028 }
5029
5030 static void GLAPIENTRY save_Color4fv( const GLfloat *v )
5031 {
5032 save_Attr4f( VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3] );
5033 }
5034
5035 static void GLAPIENTRY save_SecondaryColor3fEXT( GLfloat x, GLfloat y, GLfloat z )
5036 {
5037 save_Attr3f( VERT_ATTRIB_COLOR1, x, y, z );
5038 }
5039
5040 static void GLAPIENTRY save_SecondaryColor3fvEXT( const GLfloat *v )
5041 {
5042 save_Attr3f( VERT_ATTRIB_COLOR1, v[0], v[1], v[2] );
5043 }
5044
5045
5046 /* Just call the respective ATTR for texcoord
5047 */
5048 static void GLAPIENTRY save_MultiTexCoord1f( GLenum target, GLfloat x )
5049 {
5050 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5051 save_Attr1f( attr, x );
5052 }
5053
5054 static void GLAPIENTRY save_MultiTexCoord1fv( GLenum target, const GLfloat *v )
5055 {
5056 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5057 save_Attr1f( attr, v[0] );
5058 }
5059
5060 static void GLAPIENTRY save_MultiTexCoord2f( GLenum target, GLfloat x, GLfloat y )
5061 {
5062 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5063 save_Attr2f( attr, x, y );
5064 }
5065
5066 static void GLAPIENTRY save_MultiTexCoord2fv( GLenum target, const GLfloat *v )
5067 {
5068 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5069 save_Attr2f( attr, v[0], v[1] );
5070 }
5071
5072 static void GLAPIENTRY save_MultiTexCoord3f( GLenum target, GLfloat x, GLfloat y,
5073 GLfloat z)
5074 {
5075 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5076 save_Attr3f( attr, x, y, z );
5077 }
5078
5079 static void GLAPIENTRY save_MultiTexCoord3fv( GLenum target, const GLfloat *v )
5080 {
5081 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5082 save_Attr3f( attr, v[0], v[1], v[2] );
5083 }
5084
5085 static void GLAPIENTRY save_MultiTexCoord4f( GLenum target, GLfloat x, GLfloat y,
5086 GLfloat z, GLfloat w )
5087 {
5088 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5089 save_Attr4f( attr, x, y, z, w );
5090 }
5091
5092 static void GLAPIENTRY save_MultiTexCoord4fv( GLenum target, const GLfloat *v )
5093 {
5094 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5095 save_Attr4f( attr, v[0], v[1], v[2], v[3] );
5096 }
5097
5098
5099 static void enum_error( void )
5100 {
5101 GET_CURRENT_CONTEXT( ctx );
5102 _mesa_error( ctx, GL_INVALID_ENUM, "VertexAttribfNV" );
5103 }
5104
5105 /* First level for NV_vertex_program:
5106 *
5107 * Check for errors at compile time?.
5108 */
5109 static void GLAPIENTRY save_VertexAttrib1fNV( GLuint index, GLfloat x )
5110 {
5111 if (index < VERT_ATTRIB_MAX)
5112 save_Attr1f( index, x );
5113 else
5114 enum_error();
5115 }
5116
5117 static void GLAPIENTRY save_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
5118 {
5119 if (index < VERT_ATTRIB_MAX)
5120 save_Attr1f( index, v[0] );
5121 else
5122 enum_error();
5123 }
5124
5125 static void GLAPIENTRY save_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y )
5126 {
5127 if (index < VERT_ATTRIB_MAX)
5128 save_Attr2f( index, x, y );
5129 else
5130 enum_error();
5131 }
5132
5133 static void GLAPIENTRY save_VertexAttrib2fvNV( GLuint index, const GLfloat *v )
5134 {
5135 if (index < VERT_ATTRIB_MAX)
5136 save_Attr2f( index, v[0], v[1] );
5137 else
5138 enum_error();
5139 }
5140
5141 static void GLAPIENTRY save_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y,
5142 GLfloat z )
5143 {
5144 if (index < VERT_ATTRIB_MAX)
5145 save_Attr3f( index, x, y, z );
5146 else
5147 enum_error();
5148 }
5149
5150 static void GLAPIENTRY save_VertexAttrib3fvNV( GLuint index, const GLfloat *v )
5151 {
5152 if (index < VERT_ATTRIB_MAX)
5153 save_Attr3f( index, v[0], v[1], v[2] );
5154 else
5155 enum_error();
5156 }
5157
5158 static void GLAPIENTRY save_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y,
5159 GLfloat z, GLfloat w )
5160 {
5161 if (index < VERT_ATTRIB_MAX)
5162 save_Attr4f( index, x, y, z, w );
5163 else
5164 enum_error();
5165 }
5166
5167 static void GLAPIENTRY save_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
5168 {
5169 if (index < VERT_ATTRIB_MAX)
5170 save_Attr4f( index, v[0], v[1], v[2], v[3] );
5171 else
5172 enum_error();
5173 }
5174
5175
5176
5177
5178
5179 /* KW: Compile commands
5180 *
5181 * Will appear in the list before the vertex buffer containing the
5182 * command that provoked the error. I don't see this as a problem.
5183 */
5184 void
5185 _mesa_save_error( GLcontext *ctx, GLenum error, const char *s )
5186 {
5187 Node *n;
5188 n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
5189 if (n) {
5190 n[1].e = error;
5191 n[2].data = (void *) s;
5192 }
5193 /* execute already done */
5194 }
5195
5196
5197 /*
5198 * Compile an error into current display list.
5199 */
5200 void
5201 _mesa_compile_error( GLcontext *ctx, GLenum error, const char *s )
5202 {
5203 if (ctx->CompileFlag)
5204 _mesa_save_error( ctx, error, s );
5205
5206 if (ctx->ExecuteFlag)
5207 _mesa_error( ctx, error, s );
5208 }
5209
5210
5211
5212 static GLboolean
5213 islist(GLcontext *ctx, GLuint list)
5214 {
5215 if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
5216 return GL_TRUE;
5217 }
5218 else {
5219 return GL_FALSE;
5220 }
5221 }
5222
5223
5224
5225 /**********************************************************************/
5226 /* Display list execution */
5227 /**********************************************************************/
5228
5229
5230 /*
5231 * Execute a display list. Note that the ListBase offset must have already
5232 * been added before calling this function. I.e. the list argument is
5233 * the absolute list number, not relative to ListBase.
5234 * \param list - display list number
5235 */
5236 static void GLAPIENTRY
5237 execute_list( GLcontext *ctx, GLuint list )
5238 {
5239 Node *n;
5240 GLboolean done;
5241
5242 if (list == 0 || !islist(ctx,list))
5243 return;
5244
5245 if (ctx->Driver.BeginCallList)
5246 ctx->Driver.BeginCallList( ctx, list );
5247
5248 ctx->ListState.CallDepth++;
5249
5250 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
5251
5252 done = GL_FALSE;
5253 while (!done) {
5254 OpCode opcode = n[0].opcode;
5255 int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
5256
5257 if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
5258 ctx->listext.opcode[i].execute(ctx, &n[1]);
5259 n += ctx->listext.opcode[i].size;
5260 }
5261 else {
5262 switch (opcode) {
5263 case OPCODE_ERROR:
5264 _mesa_error( ctx, n[1].e, (const char *) n[2].data );
5265 break;
5266 case OPCODE_ACCUM:
5267 (*ctx->Exec->Accum)( n[1].e, n[2].f );
5268 break;
5269 case OPCODE_ALPHA_FUNC:
5270 (*ctx->Exec->AlphaFunc)( n[1].e, n[2].f );
5271 break;
5272 case OPCODE_BIND_TEXTURE:
5273 (*ctx->Exec->BindTexture)( n[1].e, n[2].ui );
5274 break;
5275 case OPCODE_BITMAP:
5276 {
5277 struct gl_pixelstore_attrib save = ctx->Unpack;
5278 ctx->Unpack = _mesa_native_packing;
5279 (*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
5280 n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
5281 ctx->Unpack = save; /* restore */
5282 }
5283 break;
5284 case OPCODE_BLEND_COLOR:
5285 (*ctx->Exec->BlendColor)( n[1].f, n[2].f, n[3].f, n[4].f );
5286 break;
5287 case OPCODE_BLEND_EQUATION:
5288 (*ctx->Exec->BlendEquation)( n[1].e );
5289 break;
5290 case OPCODE_BLEND_EQUATION_SEPARATE:
5291 (*ctx->Exec->BlendEquationSeparateEXT)( n[1].e, n[2].e );
5292 break;
5293 case OPCODE_BLEND_FUNC_SEPARATE:
5294 (*ctx->Exec->BlendFuncSeparateEXT)(n[1].e, n[2].e, n[3].e, n[4].e);
5295 break;
5296 case OPCODE_CALL_LIST:
5297 /* Generated by glCallList(), don't add ListBase */
5298 if (ctx->ListState.CallDepth<MAX_LIST_NESTING) {
5299 execute_list( ctx, n[1].ui );
5300 }
5301 break;
5302 case OPCODE_CALL_LIST_OFFSET:
5303 /* Generated by glCallLists() so we must add ListBase */
5304 if (n[2].b) {
5305 /* user specified a bad data type at compile time */
5306 _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
5307 }
5308 else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
5309 execute_list( ctx, ctx->List.ListBase + n[1].ui );
5310 }
5311 break;
5312 case OPCODE_CLEAR:
5313 (*ctx->Exec->Clear)( n[1].bf );
5314 break;
5315 case OPCODE_CLEAR_COLOR:
5316 (*ctx->Exec->ClearColor)( n[1].f, n[2].f, n[3].f, n[4].f );
5317 break;
5318 case OPCODE_CLEAR_ACCUM:
5319 (*ctx->Exec->ClearAccum)( n[1].f, n[2].f, n[3].f, n[4].f );
5320 break;
5321 case OPCODE_CLEAR_DEPTH:
5322 (*ctx->Exec->ClearDepth)( (GLclampd) n[1].f );
5323 break;
5324 case OPCODE_CLEAR_INDEX:
5325 (*ctx->Exec->ClearIndex)( (GLfloat) n[1].ui );
5326 break;
5327 case OPCODE_CLEAR_STENCIL:
5328 (*ctx->Exec->ClearStencil)( n[1].i );
5329 break;
5330 case OPCODE_CLIP_PLANE:
5331 {
5332 GLdouble eq[4];
5333 eq[0] = n[2].f;
5334 eq[1] = n[3].f;
5335 eq[2] = n[4].f;
5336 eq[3] = n[5].f;
5337 (*ctx->Exec->ClipPlane)( n[1].e, eq );
5338 }
5339 break;
5340 case OPCODE_COLOR_MASK:
5341 (*ctx->Exec->ColorMask)( n[1].b, n[2].b, n[3].b, n[4].b );
5342 break;
5343 case OPCODE_COLOR_MATERIAL:
5344 (*ctx->Exec->ColorMaterial)( n[1].e, n[2].e );
5345 break;
5346 case OPCODE_COLOR_TABLE:
5347 {
5348 struct gl_pixelstore_attrib save = ctx->Unpack;
5349 ctx->Unpack = _mesa_native_packing;
5350 (*ctx->Exec->ColorTable)( n[1].e, n[2].e, n[3].i, n[4].e,
5351 n[5].e, n[6].data );
5352 ctx->Unpack = save; /* restore */
5353 }
5354 break;
5355 case OPCODE_COLOR_TABLE_PARAMETER_FV:
5356 {
5357 GLfloat params[4];
5358 params[0] = n[3].f;
5359 params[1] = n[4].f;
5360 params[2] = n[5].f;
5361 params[3] = n[6].f;
5362 (*ctx->Exec->ColorTableParameterfv)( n[1].e, n[2].e, params );
5363 }
5364 break;
5365 case OPCODE_COLOR_TABLE_PARAMETER_IV:
5366 {
5367 GLint params[4];
5368 params[0] = n[3].i;
5369 params[1] = n[4].i;
5370 params[2] = n[5].i;
5371 params[3] = n[6].i;
5372 (*ctx->Exec->ColorTableParameteriv)( n[1].e, n[2].e, params );
5373 }
5374 break;
5375 case OPCODE_COLOR_SUB_TABLE:
5376 {
5377 struct gl_pixelstore_attrib save = ctx->Unpack;
5378 ctx->Unpack = _mesa_native_packing;
5379 (*ctx->Exec->ColorSubTable)( n[1].e, n[2].i, n[3].i,
5380 n[4].e, n[5].e, n[6].data );
5381 ctx->Unpack = save; /* restore */
5382 }
5383 break;
5384 case OPCODE_CONVOLUTION_FILTER_1D:
5385 {
5386 struct gl_pixelstore_attrib save = ctx->Unpack;
5387 ctx->Unpack = _mesa_native_packing;
5388 (*ctx->Exec->ConvolutionFilter1D)( n[1].e, n[2].i, n[3].i,
5389 n[4].e, n[5].e, n[6].data );
5390 ctx->Unpack = save; /* restore */
5391 }
5392 break;
5393 case OPCODE_CONVOLUTION_FILTER_2D:
5394 {
5395 struct gl_pixelstore_attrib save = ctx->Unpack;
5396 ctx->Unpack = _mesa_native_packing;
5397 (*ctx->Exec->ConvolutionFilter2D)( n[1].e, n[2].i, n[3].i,
5398 n[4].i, n[5].e, n[6].e, n[7].data );
5399 ctx->Unpack = save; /* restore */
5400 }
5401 break;
5402 case OPCODE_CONVOLUTION_PARAMETER_I:
5403 (*ctx->Exec->ConvolutionParameteri)( n[1].e, n[2].e, n[3].i );
5404 break;
5405 case OPCODE_CONVOLUTION_PARAMETER_IV:
5406 {
5407 GLint params[4];
5408 params[0] = n[3].i;
5409 params[1] = n[4].i;
5410 params[2] = n[5].i;
5411 params[3] = n[6].i;
5412 (*ctx->Exec->ConvolutionParameteriv)( n[1].e, n[2].e, params );
5413 }
5414 break;
5415 case OPCODE_CONVOLUTION_PARAMETER_F:
5416 (*ctx->Exec->ConvolutionParameterf)( n[1].e, n[2].e, n[3].f );
5417 break;
5418 case OPCODE_CONVOLUTION_PARAMETER_FV:
5419 {
5420 GLfloat params[4];
5421 params[0] = n[3].f;
5422 params[1] = n[4].f;
5423 params[2] = n[5].f;
5424 params[3] = n[6].f;
5425 (*ctx->Exec->ConvolutionParameterfv)( n[1].e, n[2].e, params );
5426 }
5427 break;
5428 case OPCODE_COPY_COLOR_SUB_TABLE:
5429 (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i,
5430 n[3].i, n[4].i, n[5].i );
5431 break;
5432 case OPCODE_COPY_COLOR_TABLE:
5433 (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i,
5434 n[3].i, n[4].i, n[5].i );
5435 break;
5436 case OPCODE_COPY_PIXELS:
5437 (*ctx->Exec->CopyPixels)( n[1].i, n[2].i,
5438 (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
5439 break;
5440 case OPCODE_COPY_TEX_IMAGE1D:
5441 (*ctx->Exec->CopyTexImage1D)( n[1].e, n[2].i, n[3].e, n[4].i,
5442 n[5].i, n[6].i, n[7].i );
5443 break;
5444 case OPCODE_COPY_TEX_IMAGE2D:
5445 (*ctx->Exec->CopyTexImage2D)( n[1].e, n[2].i, n[3].e, n[4].i,
5446 n[5].i, n[6].i, n[7].i, n[8].i );
5447 break;
5448 case OPCODE_COPY_TEX_SUB_IMAGE1D:
5449 (*ctx->Exec->CopyTexSubImage1D)( n[1].e, n[2].i, n[3].i,
5450 n[4].i, n[5].i, n[6].i );
5451 break;
5452 case OPCODE_COPY_TEX_SUB_IMAGE2D:
5453 (*ctx->Exec->CopyTexSubImage2D)( n[1].e, n[2].i, n[3].i,
5454 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i );
5455 break;
5456 case OPCODE_COPY_TEX_SUB_IMAGE3D:
5457 (*ctx->Exec->CopyTexSubImage3D)( n[1].e, n[2].i, n[3].i,
5458 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i , n[9].i);
5459 break;
5460 case OPCODE_CULL_FACE:
5461 (*ctx->Exec->CullFace)( n[1].e );
5462 break;
5463 case OPCODE_DEPTH_FUNC:
5464 (*ctx->Exec->DepthFunc)( n[1].e );
5465 break;
5466 case OPCODE_DEPTH_MASK:
5467 (*ctx->Exec->DepthMask)( n[1].b );
5468 break;
5469 case OPCODE_DEPTH_RANGE:
5470 (*ctx->Exec->DepthRange)( (GLclampd) n[1].f, (GLclampd) n[2].f );
5471 break;
5472 case OPCODE_DISABLE:
5473 (*ctx->Exec->Disable)( n[1].e );
5474 break;
5475 case OPCODE_DRAW_BUFFER:
5476 (*ctx->Exec->DrawBuffer)( n[1].e );
5477 break;
5478 case OPCODE_DRAW_PIXELS:
5479 {
5480 struct gl_pixelstore_attrib save = ctx->Unpack;
5481 ctx->Unpack = _mesa_native_packing;
5482 (*ctx->Exec->DrawPixels)( n[1].i, n[2].i, n[3].e, n[4].e,
5483 n[5].data );
5484 ctx->Unpack = save; /* restore */
5485 }
5486 break;
5487 case OPCODE_ENABLE:
5488 (*ctx->Exec->Enable)( n[1].e );
5489 break;
5490 case OPCODE_EVALMESH1:
5491 (*ctx->Exec->EvalMesh1)( n[1].e, n[2].i, n[3].i );
5492 break;
5493 case OPCODE_EVALMESH2:
5494 (*ctx->Exec->EvalMesh2)( n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
5495 break;
5496 case OPCODE_FOG:
5497 {
5498 GLfloat p[4];
5499 p[0] = n[2].f;
5500 p[1] = n[3].f;
5501 p[2] = n[4].f;
5502 p[3] = n[5].f;
5503 (*ctx->Exec->Fogfv)( n[1].e, p );
5504 }
5505 break;
5506 case OPCODE_FRONT_FACE:
5507 (*ctx->Exec->FrontFace)( n[1].e );
5508 break;
5509 case OPCODE_FRUSTUM:
5510 (*ctx->Exec->Frustum)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
5511 break;
5512 case OPCODE_HINT:
5513 (*ctx->Exec->Hint)( n[1].e, n[2].e );
5514 break;
5515 case OPCODE_HISTOGRAM:
5516 (*ctx->Exec->Histogram)( n[1].e, n[2].i, n[3].e, n[4].b );
5517 break;
5518 case OPCODE_INDEX_MASK:
5519 (*ctx->Exec->IndexMask)( n[1].ui );
5520 break;
5521 case OPCODE_INIT_NAMES:
5522 (*ctx->Exec->InitNames)();
5523 break;
5524 case OPCODE_LIGHT:
5525 {
5526 GLfloat p[4];
5527 p[0] = n[3].f;
5528 p[1] = n[4].f;
5529 p[2] = n[5].f;
5530 p[3] = n[6].f;
5531 (*ctx->Exec->Lightfv)( n[1].e, n[2].e, p );
5532 }
5533 break;
5534 case OPCODE_LIGHT_MODEL:
5535 {
5536 GLfloat p[4];
5537 p[0] = n[2].f;
5538 p[1] = n[3].f;
5539 p[2] = n[4].f;
5540 p[3] = n[5].f;
5541 (*ctx->Exec->LightModelfv)( n[1].e, p );
5542 }
5543 break;
5544 case OPCODE_LINE_STIPPLE:
5545 (*ctx->Exec->LineStipple)( n[1].i, n[2].us );
5546 break;
5547 case OPCODE_LINE_WIDTH:
5548 (*ctx->Exec->LineWidth)( n[1].f );
5549 break;
5550 case OPCODE_LIST_BASE:
5551 (*ctx->Exec->ListBase)( n[1].ui );
5552 break;
5553 case OPCODE_LOAD_IDENTITY:
5554 (*ctx->Exec->LoadIdentity)();
5555 break;
5556 case OPCODE_LOAD_MATRIX:
5557 if (sizeof(Node)==sizeof(GLfloat)) {
5558 (*ctx->Exec->LoadMatrixf)( &n[1].f );
5559 }
5560 else {
5561 GLfloat m[16];
5562 GLuint i;
5563 for (i=0;i<16;i++) {
5564 m[i] = n[1+i].f;
5565 }
5566 (*ctx->Exec->LoadMatrixf)( m );
5567 }
5568 break;
5569 case OPCODE_LOAD_NAME:
5570 (*ctx->Exec->LoadName)( n[1].ui );
5571 break;
5572 case OPCODE_LOGIC_OP:
5573 (*ctx->Exec->LogicOp)( n[1].e );
5574 break;
5575 case OPCODE_MAP1:
5576 {
5577 GLenum target = n[1].e;
5578 GLint ustride = _mesa_evaluator_components(target);
5579 GLint uorder = n[5].i;
5580 GLfloat u1 = n[2].f;
5581 GLfloat u2 = n[3].f;
5582 (*ctx->Exec->Map1f)( target, u1, u2, ustride, uorder,
5583 (GLfloat *) n[6].data );
5584 }
5585 break;
5586 case OPCODE_MAP2:
5587 {
5588 GLenum target = n[1].e;
5589 GLfloat u1 = n[2].f;
5590 GLfloat u2 = n[3].f;
5591 GLfloat v1 = n[4].f;
5592 GLfloat v2 = n[5].f;
5593 GLint ustride = n[6].i;
5594 GLint vstride = n[7].i;
5595 GLint uorder = n[8].i;
5596 GLint vorder = n[9].i;
5597 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
5598 v1, v2, vstride, vorder,
5599 (GLfloat *) n[10].data );
5600 }
5601 break;
5602 case OPCODE_MAPGRID1:
5603 (*ctx->Exec->MapGrid1f)( n[1].i, n[2].f, n[3].f );
5604 break;
5605 case OPCODE_MAPGRID2:
5606 (*ctx->Exec->MapGrid2f)( n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
5607 break;
5608 case OPCODE_MATRIX_MODE:
5609 (*ctx->Exec->MatrixMode)( n[1].e );
5610 break;
5611 case OPCODE_MIN_MAX:
5612 (*ctx->Exec->Minmax)(n[1].e, n[2].e, n[3].b);
5613 break;
5614 case OPCODE_MULT_MATRIX:
5615 if (sizeof(Node)==sizeof(GLfloat)) {
5616 (*ctx->Exec->MultMatrixf)( &n[1].f );
5617 }
5618 else {
5619 GLfloat m[16];
5620 GLuint i;
5621 for (i=0;i<16;i++) {
5622 m[i] = n[1+i].f;
5623 }
5624 (*ctx->Exec->MultMatrixf)( m );
5625 }
5626 break;
5627 case OPCODE_ORTHO:
5628 (*ctx->Exec->Ortho)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
5629 break;
5630 case OPCODE_PASSTHROUGH:
5631 (*ctx->Exec->PassThrough)( n[1].f );
5632 break;
5633 case OPCODE_PIXEL_MAP:
5634 (*ctx->Exec->PixelMapfv)( n[1].e, n[2].i, (GLfloat *) n[3].data );
5635 break;
5636 case OPCODE_PIXEL_TRANSFER:
5637 (*ctx->Exec->PixelTransferf)( n[1].e, n[2].f );
5638 break;
5639 case OPCODE_PIXEL_ZOOM:
5640 (*ctx->Exec->PixelZoom)( n[1].f, n[2].f );
5641 break;
5642 case OPCODE_POINT_SIZE:
5643 (*ctx->Exec->PointSize)( n[1].f );
5644 break;
5645 case OPCODE_POINT_PARAMETERS:
5646 {
5647 GLfloat params[3];
5648 params[0] = n[2].f;
5649 params[1] = n[3].f;
5650 params[2] = n[4].f;
5651 (*ctx->Exec->PointParameterfvEXT)( n[1].e, params );
5652 }
5653 break;
5654 case OPCODE_POLYGON_MODE:
5655 (*ctx->Exec->PolygonMode)( n[1].e, n[2].e );
5656 break;
5657 case OPCODE_POLYGON_STIPPLE:
5658 (*ctx->Exec->PolygonStipple)( (GLubyte *) n[1].data );
5659 break;
5660 case OPCODE_POLYGON_OFFSET:
5661 (*ctx->Exec->PolygonOffset)( n[1].f, n[2].f );
5662 break;
5663 case OPCODE_POP_ATTRIB:
5664 (*ctx->Exec->PopAttrib)();
5665 break;
5666 case OPCODE_POP_MATRIX:
5667 (*ctx->Exec->PopMatrix)();
5668 break;
5669 case OPCODE_POP_NAME:
5670 (*ctx->Exec->PopName)();
5671 break;
5672 case OPCODE_PRIORITIZE_TEXTURE:
5673 (*ctx->Exec->PrioritizeTextures)( 1, &n[1].ui, &n[2].f );
5674 break;
5675 case OPCODE_PUSH_ATTRIB:
5676 (*ctx->Exec->PushAttrib)( n[1].bf );
5677 break;
5678 case OPCODE_PUSH_MATRIX:
5679 (*ctx->Exec->PushMatrix)();
5680 break;
5681 case OPCODE_PUSH_NAME:
5682 (*ctx->Exec->PushName)( n[1].ui );
5683 break;
5684 case OPCODE_RASTER_POS:
5685 (*ctx->Exec->RasterPos4f)( n[1].f, n[2].f, n[3].f, n[4].f );
5686 break;
5687 case OPCODE_READ_BUFFER:
5688 (*ctx->Exec->ReadBuffer)( n[1].e );
5689 break;
5690 case OPCODE_RESET_HISTOGRAM:
5691 (*ctx->Exec->ResetHistogram)( n[1].e );
5692 break;
5693 case OPCODE_RESET_MIN_MAX:
5694 (*ctx->Exec->ResetMinmax)( n[1].e );
5695 break;
5696 case OPCODE_ROTATE:
5697 (*ctx->Exec->Rotatef)( n[1].f, n[2].f, n[3].f, n[4].f );
5698 break;
5699 case OPCODE_SCALE:
5700 (*ctx->Exec->Scalef)( n[1].f, n[2].f, n[3].f );
5701 break;
5702 case OPCODE_SCISSOR:
5703 (*ctx->Exec->Scissor)( n[1].i, n[2].i, n[3].i, n[4].i );
5704 break;
5705 case OPCODE_SHADE_MODEL:
5706 (*ctx->Exec->ShadeModel)( n[1].e );
5707 break;
5708 case OPCODE_STENCIL_FUNC:
5709 (*ctx->Exec->StencilFunc)( n[1].e, n[2].i, n[3].ui );
5710 break;
5711 case OPCODE_STENCIL_MASK:
5712 (*ctx->Exec->StencilMask)( n[1].ui );
5713 break;
5714 case OPCODE_STENCIL_OP:
5715 (*ctx->Exec->StencilOp)( n[1].e, n[2].e, n[3].e );
5716 break;
5717 case OPCODE_TEXENV:
5718 {
5719 GLfloat params[4];
5720 params[0] = n[3].f;
5721 params[1] = n[4].f;
5722 params[2] = n[5].f;
5723 params[3] = n[6].f;
5724 (*ctx->Exec->TexEnvfv)( n[1].e, n[2].e, params );
5725 }
5726 break;
5727 case OPCODE_TEXGEN:
5728 {
5729 GLfloat params[4];
5730 params[0] = n[3].f;
5731 params[1] = n[4].f;
5732 params[2] = n[5].f;
5733 params[3] = n[6].f;
5734 (*ctx->Exec->TexGenfv)( n[1].e, n[2].e, params );
5735 }
5736 break;
5737 case OPCODE_TEXPARAMETER:
5738 {
5739 GLfloat params[4];
5740 params[0] = n[3].f;
5741 params[1] = n[4].f;
5742 params[2] = n[5].f;
5743 params[3] = n[6].f;
5744 (*ctx->Exec->TexParameterfv)( n[1].e, n[2].e, params );
5745 }
5746 break;
5747 case OPCODE_TEX_IMAGE1D:
5748 {
5749 struct gl_pixelstore_attrib save = ctx->Unpack;
5750 ctx->Unpack = _mesa_native_packing;
5751 (*ctx->Exec->TexImage1D)(
5752 n[1].e, /* target */
5753 n[2].i, /* level */
5754 n[3].i, /* components */
5755 n[4].i, /* width */
5756 n[5].e, /* border */
5757 n[6].e, /* format */
5758 n[7].e, /* type */
5759 n[8].data );
5760 ctx->Unpack = save; /* restore */
5761 }
5762 break;
5763 case OPCODE_TEX_IMAGE2D:
5764 {
5765 struct gl_pixelstore_attrib save = ctx->Unpack;
5766 ctx->Unpack = _mesa_native_packing;
5767 (*ctx->Exec->TexImage2D)(
5768 n[1].e, /* target */
5769 n[2].i, /* level */
5770 n[3].i, /* components */
5771 n[4].i, /* width */
5772 n[5].i, /* height */
5773 n[6].e, /* border */
5774 n[7].e, /* format */
5775 n[8].e, /* type */
5776 n[9].data );
5777 ctx->Unpack = save; /* restore */
5778 }
5779 break;
5780 case OPCODE_TEX_IMAGE3D:
5781 {
5782 struct gl_pixelstore_attrib save = ctx->Unpack;
5783 ctx->Unpack = _mesa_native_packing;
5784 (*ctx->Exec->TexImage3D)(
5785 n[1].e, /* target */
5786 n[2].i, /* level */
5787 n[3].i, /* components */
5788 n[4].i, /* width */
5789 n[5].i, /* height */
5790 n[6].i, /* depth */
5791 n[7].e, /* border */
5792 n[8].e, /* format */
5793 n[9].e, /* type */
5794 n[10].data );
5795 ctx->Unpack = save; /* restore */
5796 }
5797 break;
5798 case OPCODE_TEX_SUB_IMAGE1D:
5799 {
5800 struct gl_pixelstore_attrib save = ctx->Unpack;
5801 ctx->Unpack = _mesa_native_packing;
5802 (*ctx->Exec->TexSubImage1D)( n[1].e, n[2].i, n[3].i,
5803 n[4].i, n[5].e,
5804 n[6].e, n[7].data );
5805 ctx->Unpack = save; /* restore */
5806 }
5807 break;
5808 case OPCODE_TEX_SUB_IMAGE2D:
5809 {
5810 struct gl_pixelstore_attrib save = ctx->Unpack;
5811 ctx->Unpack = _mesa_native_packing;
5812 (*ctx->Exec->TexSubImage2D)( n[1].e, n[2].i, n[3].i,
5813 n[4].i, n[5].e,
5814 n[6].i, n[7].e, n[8].e, n[9].data );
5815 ctx->Unpack = save; /* restore */
5816 }
5817 break;
5818 case OPCODE_TEX_SUB_IMAGE3D:
5819 {
5820 struct gl_pixelstore_attrib save = ctx->Unpack;
5821 ctx->Unpack = _mesa_native_packing;
5822 (*ctx->Exec->TexSubImage3D)( n[1].e, n[2].i, n[3].i,
5823 n[4].i, n[5].i, n[6].i, n[7].i,
5824 n[8].i, n[9].e, n[10].e,
5825 n[11].data );
5826 ctx->Unpack = save; /* restore */
5827 }
5828 break;
5829 case OPCODE_TRANSLATE:
5830 (*ctx->Exec->Translatef)( n[1].f, n[2].f, n[3].f );
5831 break;
5832 case OPCODE_VIEWPORT:
5833 (*ctx->Exec->Viewport)(n[1].i, n[2].i,
5834 (GLsizei) n[3].i, (GLsizei) n[4].i);
5835 break;
5836 case OPCODE_WINDOW_POS:
5837 (*ctx->Exec->WindowPos4fMESA)( n[1].f, n[2].f, n[3].f, n[4].f );
5838 break;
5839 case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
5840 (*ctx->Exec->ActiveTextureARB)( n[1].e );
5841 break;
5842 case OPCODE_PIXEL_TEXGEN_SGIX: /* GL_SGIX_pixel_texture */
5843 (*ctx->Exec->PixelTexGenSGIX)( n[1].e );
5844 break;
5845 case OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS: /* GL_SGIS_pixel_texture */
5846 (*ctx->Exec->PixelTexGenParameteriSGIS)( n[1].e, n[2].i );
5847 break;
5848 case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */
5849 (*ctx->Exec->CompressedTexImage1DARB)(n[1].e, n[2].i, n[3].e,
5850 n[4].i, n[5].i, n[6].i, n[7].data);
5851 break;
5852 case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */
5853 (*ctx->Exec->CompressedTexImage2DARB)(n[1].e, n[2].i, n[3].e,
5854 n[4].i, n[5].i, n[6].i, n[7].i, n[8].data);
5855 break;
5856 case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */
5857 (*ctx->Exec->CompressedTexImage3DARB)(n[1].e, n[2].i, n[3].e,
5858 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i, n[9].data);
5859 break;
5860 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */
5861 (*ctx->Exec->CompressedTexSubImage1DARB)(n[1].e, n[2].i, n[3].i,
5862 n[4].i, n[5].e, n[6].i, n[7].data);
5863 break;
5864 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */
5865 (*ctx->Exec->CompressedTexSubImage2DARB)(n[1].e, n[2].i, n[3].i,
5866 n[4].i, n[5].i, n[6].i, n[7].e, n[8].i, n[9].data);
5867 break;
5868 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */
5869 (*ctx->Exec->CompressedTexSubImage3DARB)(n[1].e, n[2].i, n[3].i,
5870 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i,
5871 n[9].e, n[10].i, n[11].data);
5872 break;
5873 case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */
5874 (*ctx->Exec->SampleCoverageARB)(n[1].f, n[2].b);
5875 break;
5876 case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */
5877 (*ctx->Exec->WindowPos3fMESA)( n[1].f, n[2].f, n[3].f );
5878 break;
5879 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
5880 case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */
5881 (*ctx->Exec->BindProgramNV)( n[1].e, n[2].ui );
5882 break;
5883 #endif
5884 #if FEATURE_NV_vertex_program
5885 case OPCODE_EXECUTE_PROGRAM_NV:
5886 {
5887 GLfloat v[4];
5888 v[0] = n[3].f;
5889 v[1] = n[4].f;
5890 v[2] = n[5].f;
5891 v[3] = n[6].f;
5892 (*ctx->Exec->ExecuteProgramNV)(n[1].e, n[2].ui, v);
5893 }
5894 break;
5895 case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
5896 (*ctx->Exec->RequestResidentProgramsNV)(n[1].ui,
5897 (GLuint *) n[2].data);
5898 break;
5899 case OPCODE_LOAD_PROGRAM_NV:
5900 (*ctx->Exec->LoadProgramNV)(n[1].e, n[2].ui, n[3].i,
5901 (const GLubyte *) n[4].data);
5902 break;
5903 case OPCODE_PROGRAM_PARAMETER4F_NV:
5904 (*ctx->Exec->ProgramParameter4fNV)(n[1].e, n[2].ui, n[3].f,
5905 n[4].f, n[5].f, n[6].f);
5906 break;
5907 case OPCODE_TRACK_MATRIX_NV:
5908 (*ctx->Exec->TrackMatrixNV)(n[1].e, n[2].ui, n[3].e, n[4].e);
5909 break;
5910 #endif
5911
5912 #if FEATURE_NV_fragment_program
5913 case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB:
5914 (*ctx->Exec->ProgramLocalParameter4fARB)(n[1].e, n[2].ui, n[3].f,
5915 n[4].f, n[5].f, n[6].f);
5916 break;
5917 case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
5918 (*ctx->Exec->ProgramNamedParameter4fNV)(n[1].ui, n[2].i,
5919 (const GLubyte *) n[3].data,
5920 n[4].f, n[5].f, n[6].f, n[7].f);
5921 break;
5922 #endif
5923
5924 case OPCODE_ACTIVE_STENCIL_FACE_EXT:
5925 (*ctx->Exec->ActiveStencilFaceEXT)(n[1].e);
5926 break;
5927 case OPCODE_DEPTH_BOUNDS_EXT:
5928 (*ctx->Exec->DepthBoundsEXT)(n[1].f, n[2].f);
5929 break;
5930 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
5931 case OPCODE_PROGRAM_STRING_ARB:
5932 (*ctx->Exec->ProgramStringARB)(n[1].e, n[2].e, n[3].i, n[4].data);
5933 break;
5934 case OPCODE_PROGRAM_ENV_PARAMETER_ARB:
5935 (*ctx->Exec->ProgramEnvParameter4fARB)(n[1].e, n[2].ui, n[3].f,
5936 n[4].f, n[5].f, n[6].f);
5937 break;
5938 #endif
5939
5940 case OPCODE_ATTR_1F:
5941 (*ctx->Exec->VertexAttrib1fNV)(n[1].e, n[2].f);
5942 break;
5943 case OPCODE_ATTR_2F:
5944 (*ctx->Exec->VertexAttrib2fvNV)(n[1].e, &n[2].f);
5945 break;
5946 case OPCODE_ATTR_3F:
5947 (*ctx->Exec->VertexAttrib3fvNV)(n[1].e, &n[2].f);
5948 break;
5949 case OPCODE_ATTR_4F:
5950 (*ctx->Exec->VertexAttrib4fvNV)(n[1].e, &n[2].f);
5951 break;
5952 case OPCODE_MATERIAL:
5953 (*ctx->Exec->Materialfv)(n[1].e, n[2].e, &n[3].f);
5954 break;
5955 case OPCODE_INDEX:
5956 (*ctx->Exec->Indexi)(n[1].i);
5957 break;
5958 case OPCODE_EDGEFLAG:
5959 (*ctx->Exec->EdgeFlag)(n[1].b);
5960 break;
5961 case OPCODE_BEGIN:
5962 (*ctx->Exec->Begin)(n[1].e);
5963 break;
5964 case OPCODE_END:
5965 (*ctx->Exec->End)();
5966 break;
5967 case OPCODE_RECTF:
5968 (*ctx->Exec->Rectf)(n[1].f, n[2].f, n[3].f, n[4].f);
5969 break;
5970 case OPCODE_EVAL_C1:
5971 (*ctx->Exec->EvalCoord1f)(n[1].f);
5972 break;
5973 case OPCODE_EVAL_C2:
5974 (*ctx->Exec->EvalCoord2fv)(&n[1].f);
5975 break;
5976 case OPCODE_EVAL_P1:
5977 (*ctx->Exec->EvalPoint1)(n[1].i);
5978 break;
5979 case OPCODE_EVAL_P2:
5980 (*ctx->Exec->EvalPoint2)(n[1].i, n[2].i);
5981 break;
5982
5983
5984
5985
5986 case OPCODE_CONTINUE:
5987 n = (Node *) n[1].next;
5988 break;
5989 case OPCODE_END_OF_LIST:
5990 done = GL_TRUE;
5991 break;
5992 default:
5993 {
5994 char msg[1000];
5995 _mesa_sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
5996 _mesa_problem(ctx, msg);
5997 }
5998 done = GL_TRUE;
5999 }
6000
6001 /* increment n to point to next compiled command */
6002 if (opcode!=OPCODE_CONTINUE) {
6003 n += InstSize[opcode];
6004 }
6005 }
6006 }
6007 ctx->ListState.CallDepth--;
6008
6009 if (ctx->Driver.EndCallList)
6010 ctx->Driver.EndCallList( ctx );
6011 }
6012
6013
6014
6015
6016
6017 /**********************************************************************/
6018 /* GL functions */
6019 /**********************************************************************/
6020
6021
6022
6023
6024 /*
6025 * Test if a display list number is valid.
6026 */
6027 GLboolean GLAPIENTRY
6028 _mesa_IsList( GLuint list )
6029 {
6030 GET_CURRENT_CONTEXT(ctx);
6031 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
6032 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
6033 return islist(ctx, list);
6034 }
6035
6036
6037 /*
6038 * Delete a sequence of consecutive display lists.
6039 */
6040 void GLAPIENTRY
6041 _mesa_DeleteLists( GLuint list, GLsizei range )
6042 {
6043 GET_CURRENT_CONTEXT(ctx);
6044 GLuint i;
6045 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
6046 ASSERT_OUTSIDE_BEGIN_END(ctx);
6047
6048 if (range<0) {
6049 _mesa_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
6050 return;
6051 }
6052 for (i=list;i<list+range;i++) {
6053 _mesa_destroy_list( ctx, i );
6054 }
6055 }
6056
6057
6058
6059 /*
6060 * Return a display list number, n, such that lists n through n+range-1
6061 * are free.
6062 */
6063 GLuint GLAPIENTRY
6064 _mesa_GenLists(GLsizei range )
6065 {
6066 GET_CURRENT_CONTEXT(ctx);
6067 GLuint base;
6068 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
6069 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
6070
6071 if (range<0) {
6072 _mesa_error( ctx, GL_INVALID_VALUE, "glGenLists" );
6073 return 0;
6074 }
6075 if (range==0) {
6076 return 0;
6077 }
6078
6079 /*
6080 * Make this an atomic operation
6081 */
6082 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
6083
6084 base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
6085 if (base) {
6086 /* reserve the list IDs by with empty/dummy lists */
6087 GLint i;
6088 for (i=0; i<range; i++) {
6089 _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
6090 }
6091 }
6092
6093 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
6094
6095 return base;
6096 }
6097
6098
6099
6100 /*
6101 * Begin a new display list.
6102 */
6103 void GLAPIENTRY
6104 _mesa_NewList( GLuint list, GLenum mode )
6105 {
6106 GET_CURRENT_CONTEXT(ctx);
6107 GLint i;
6108
6109 FLUSH_CURRENT(ctx, 0); /* must be called before assert */
6110 ASSERT_OUTSIDE_BEGIN_END(ctx);
6111
6112 if (MESA_VERBOSE&VERBOSE_API)
6113 _mesa_debug(ctx, "glNewList %u %s\n", list,
6114 _mesa_lookup_enum_by_nr(mode));
6115
6116 if (list==0) {
6117 _mesa_error( ctx, GL_INVALID_VALUE, "glNewList" );
6118 return;
6119 }
6120
6121 if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
6122 _mesa_error( ctx, GL_INVALID_ENUM, "glNewList" );
6123 return;
6124 }
6125
6126 if (ctx->ListState.CurrentListPtr) {
6127 /* already compiling a display list */
6128 _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
6129 return;
6130 }
6131
6132 ctx->CompileFlag = GL_TRUE;
6133 ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
6134
6135 /* Allocate new display list */
6136 ctx->ListState.CurrentListNum = list;
6137 ctx->ListState.CurrentBlock = (Node *) CALLOC( sizeof(Node) * BLOCK_SIZE );
6138 ctx->ListState.CurrentListPtr = ctx->ListState.CurrentBlock;
6139 ctx->ListState.CurrentPos = 0;
6140
6141 /* Reset acumulated list state:
6142 */
6143 for (i = 0; i < VERT_ATTRIB_MAX; i++)
6144 ctx->ListState.ActiveAttribSize[i] = 0;
6145
6146 for (i = 0; i < MAT_ATTRIB_MAX; i++)
6147 ctx->ListState.ActiveMaterialSize[i] = 0;
6148
6149 ctx->ListState.ActiveIndex = 0;
6150 ctx->ListState.ActiveEdgeFlag = 0;
6151
6152 ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
6153 ctx->Driver.NewList( ctx, list, mode );
6154
6155 ctx->CurrentDispatch = ctx->Save;
6156 _glapi_set_dispatch( ctx->CurrentDispatch );
6157 }
6158
6159
6160
6161 /*
6162 * End definition of current display list.
6163 */
6164 void GLAPIENTRY
6165 _mesa_EndList( void )
6166 {
6167 GET_CURRENT_CONTEXT(ctx);
6168 SAVE_FLUSH_VERTICES(ctx);
6169 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
6170
6171 if (MESA_VERBOSE&VERBOSE_API)
6172 _mesa_debug(ctx, "glEndList\n");
6173
6174 /* Check that a list is under construction */
6175 if (!ctx->ListState.CurrentListPtr) {
6176 _mesa_error( ctx, GL_INVALID_OPERATION, "glEndList" );
6177 return;
6178 }
6179
6180 (void) ALLOC_INSTRUCTION( ctx, OPCODE_END_OF_LIST, 0 );
6181
6182 /* Destroy old list, if any */
6183 _mesa_destroy_list(ctx, ctx->ListState.CurrentListNum);
6184 /* Install the list */
6185 _mesa_HashInsert(ctx->Shared->DisplayList, ctx->ListState.CurrentListNum, ctx->ListState.CurrentListPtr);
6186
6187
6188 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
6189 mesa_print_display_list(ctx->ListState.CurrentListNum);
6190
6191 ctx->ListState.CurrentListNum = 0;
6192 ctx->ListState.CurrentListPtr = NULL;
6193 ctx->ExecuteFlag = GL_TRUE;
6194 ctx->CompileFlag = GL_FALSE;
6195
6196 ctx->Driver.EndList( ctx );
6197
6198 ctx->CurrentDispatch = ctx->Exec;
6199 _glapi_set_dispatch( ctx->CurrentDispatch );
6200 }
6201
6202
6203
6204 void GLAPIENTRY
6205 _mesa_CallList( GLuint list )
6206 {
6207 GLboolean save_compile_flag;
6208 GET_CURRENT_CONTEXT(ctx);
6209 FLUSH_CURRENT(ctx, 0);
6210 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
6211 /* execute the display list, and restore the CompileFlag. */
6212
6213 if (MESA_VERBOSE & VERBOSE_API)
6214 _mesa_debug(ctx, "glCallList %d\n", list);
6215
6216 if (list == 0) {
6217 _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)");
6218 return;
6219 }
6220
6221 /* mesa_print_display_list( list ); */
6222
6223 save_compile_flag = ctx->CompileFlag;
6224 if (save_compile_flag) {
6225 ctx->CompileFlag = GL_FALSE;
6226 }
6227
6228 execute_list( ctx, list );
6229 ctx->CompileFlag = save_compile_flag;
6230
6231 /* also restore API function pointers to point to "save" versions */
6232 if (save_compile_flag) {
6233 ctx->CurrentDispatch = ctx->Save;
6234 _glapi_set_dispatch( ctx->CurrentDispatch );
6235 }
6236 }
6237
6238
6239
6240 /*
6241 * Execute glCallLists: call multiple display lists.
6242 */
6243 void GLAPIENTRY
6244 _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
6245 {
6246 GET_CURRENT_CONTEXT(ctx);
6247 GLuint list;
6248 GLint i;
6249 GLboolean save_compile_flag;
6250
6251 if (MESA_VERBOSE & VERBOSE_API)
6252 _mesa_debug(ctx, "glCallLists %d\n", n);
6253
6254 switch (type) {
6255 case GL_BYTE:
6256 case GL_UNSIGNED_BYTE:
6257 case GL_SHORT:
6258 case GL_UNSIGNED_SHORT:
6259 case GL_INT:
6260 case GL_UNSIGNED_INT:
6261 case GL_FLOAT:
6262 case GL_2_BYTES:
6263 case GL_3_BYTES:
6264 case GL_4_BYTES:
6265 /* OK */
6266 break;
6267 default:
6268 _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
6269 return;
6270 }
6271
6272 /* Save the CompileFlag status, turn it off, execute display list,
6273 * and restore the CompileFlag.
6274 */
6275 save_compile_flag = ctx->CompileFlag;
6276 ctx->CompileFlag = GL_FALSE;
6277
6278 for (i=0;i<n;i++) {
6279 list = translate_id( i, type, lists );
6280 execute_list( ctx, ctx->List.ListBase + list );
6281 }
6282
6283 ctx->CompileFlag = save_compile_flag;
6284
6285 /* also restore API function pointers to point to "save" versions */
6286 if (save_compile_flag) {
6287 ctx->CurrentDispatch = ctx->Save;
6288 _glapi_set_dispatch( ctx->CurrentDispatch );
6289 }
6290 }
6291
6292
6293
6294 /*
6295 * Set the offset added to list numbers in glCallLists.
6296 */
6297 void GLAPIENTRY
6298 _mesa_ListBase( GLuint base )
6299 {
6300 GET_CURRENT_CONTEXT(ctx);
6301 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
6302 ASSERT_OUTSIDE_BEGIN_END(ctx);
6303 ctx->List.ListBase = base;
6304 }
6305
6306
6307 /* Can no longer assume ctx->Exec->Func is equal to _mesa_Func.
6308 */
6309 static void GLAPIENTRY exec_Finish( void )
6310 {
6311 GET_CURRENT_CONTEXT(ctx);
6312 FLUSH_VERTICES(ctx, 0);
6313 ctx->Exec->Finish();
6314 }
6315
6316 static void GLAPIENTRY exec_Flush( void )
6317 {
6318 GET_CURRENT_CONTEXT(ctx);
6319 FLUSH_VERTICES(ctx, 0);
6320 ctx->Exec->Flush( );
6321 }
6322
6323 static void GLAPIENTRY exec_GetBooleanv( GLenum pname, GLboolean *params )
6324 {
6325 GET_CURRENT_CONTEXT(ctx);
6326 FLUSH_VERTICES(ctx, 0);
6327 ctx->Exec->GetBooleanv( pname, params );
6328 }
6329
6330 static void GLAPIENTRY exec_GetClipPlane( GLenum plane, GLdouble *equation )
6331 {
6332 GET_CURRENT_CONTEXT(ctx);
6333 FLUSH_VERTICES(ctx, 0);
6334 ctx->Exec->GetClipPlane( plane, equation );
6335 }
6336
6337 static void GLAPIENTRY exec_GetDoublev( GLenum pname, GLdouble *params )
6338 {
6339 GET_CURRENT_CONTEXT(ctx);
6340 FLUSH_VERTICES(ctx, 0);
6341 ctx->Exec->GetDoublev( pname, params );
6342 }
6343
6344 static GLenum GLAPIENTRY exec_GetError( void )
6345 {
6346 GET_CURRENT_CONTEXT(ctx);
6347 FLUSH_VERTICES(ctx, 0);
6348 return ctx->Exec->GetError( );
6349 }
6350
6351 static void GLAPIENTRY exec_GetFloatv( GLenum pname, GLfloat *params )
6352 {
6353 GET_CURRENT_CONTEXT(ctx);
6354 FLUSH_VERTICES(ctx, 0);
6355 ctx->Exec->GetFloatv( pname, params );
6356 }
6357
6358 static void GLAPIENTRY exec_GetIntegerv( GLenum pname, GLint *params )
6359 {
6360 GET_CURRENT_CONTEXT(ctx);
6361 FLUSH_VERTICES(ctx, 0);
6362 ctx->Exec->GetIntegerv( pname, params );
6363 }
6364
6365 static void GLAPIENTRY exec_GetLightfv( GLenum light, GLenum pname, GLfloat *params )
6366 {
6367 GET_CURRENT_CONTEXT(ctx);
6368 FLUSH_VERTICES(ctx, 0);
6369 ctx->Exec->GetLightfv( light, pname, params );
6370 }
6371
6372 static void GLAPIENTRY exec_GetLightiv( GLenum light, GLenum pname, GLint *params )
6373 {
6374 GET_CURRENT_CONTEXT(ctx);
6375 FLUSH_VERTICES(ctx, 0);
6376 ctx->Exec->GetLightiv( light, pname, params );
6377 }
6378
6379 static void GLAPIENTRY exec_GetMapdv( GLenum target, GLenum query, GLdouble *v )
6380 {
6381 GET_CURRENT_CONTEXT(ctx);
6382 FLUSH_VERTICES(ctx, 0);
6383 ctx->Exec->GetMapdv( target, query, v );
6384 }
6385
6386 static void GLAPIENTRY exec_GetMapfv( GLenum target, GLenum query, GLfloat *v )
6387 {
6388 GET_CURRENT_CONTEXT(ctx);
6389 FLUSH_VERTICES(ctx, 0);
6390 ctx->Exec->GetMapfv( target, query, v );
6391 }
6392
6393 static void GLAPIENTRY exec_GetMapiv( GLenum target, GLenum query, GLint *v )
6394 {
6395 GET_CURRENT_CONTEXT(ctx);
6396 FLUSH_VERTICES(ctx, 0);
6397 ctx->Exec->GetMapiv( target, query, v );
6398 }
6399
6400 static void GLAPIENTRY exec_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
6401 {
6402 GET_CURRENT_CONTEXT(ctx);
6403 FLUSH_VERTICES(ctx, 0);
6404 ctx->Exec->GetMaterialfv( face, pname, params );
6405 }
6406
6407 static void GLAPIENTRY exec_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
6408 {
6409 GET_CURRENT_CONTEXT(ctx);
6410 FLUSH_VERTICES(ctx, 0);
6411 ctx->Exec->GetMaterialiv( face, pname, params );
6412 }
6413
6414 static void GLAPIENTRY exec_GetPixelMapfv( GLenum map, GLfloat *values )
6415 {
6416 GET_CURRENT_CONTEXT(ctx);
6417 FLUSH_VERTICES(ctx, 0);
6418 ctx->Exec->GetPixelMapfv( map, values );
6419 }
6420
6421 static void GLAPIENTRY exec_GetPixelMapuiv( GLenum map, GLuint *values )
6422 {
6423 GET_CURRENT_CONTEXT(ctx);
6424 FLUSH_VERTICES(ctx, 0);
6425 ctx->Exec->GetPixelMapuiv( map, values );
6426 }
6427
6428 static void GLAPIENTRY exec_GetPixelMapusv( GLenum map, GLushort *values )
6429 {
6430 GET_CURRENT_CONTEXT(ctx);
6431 FLUSH_VERTICES(ctx, 0);
6432 ctx->Exec->GetPixelMapusv( map, values );
6433 }
6434
6435 static void GLAPIENTRY exec_GetPolygonStipple( GLubyte *dest )
6436 {
6437 GET_CURRENT_CONTEXT(ctx);
6438 FLUSH_VERTICES(ctx, 0);
6439 ctx->Exec->GetPolygonStipple( dest );
6440 }
6441
6442 static const GLubyte * GLAPIENTRY exec_GetString( GLenum name )
6443 {
6444 GET_CURRENT_CONTEXT(ctx);
6445 FLUSH_VERTICES(ctx, 0);
6446 return ctx->Exec->GetString( name );
6447 }
6448
6449 static void GLAPIENTRY exec_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
6450 {
6451 GET_CURRENT_CONTEXT(ctx);
6452 FLUSH_VERTICES(ctx, 0);
6453 ctx->Exec->GetTexEnvfv( target, pname, params );
6454 }
6455
6456 static void GLAPIENTRY exec_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
6457 {
6458 GET_CURRENT_CONTEXT(ctx);
6459 FLUSH_VERTICES(ctx, 0);
6460 ctx->Exec->GetTexEnviv( target, pname, params );
6461 }
6462
6463 static void GLAPIENTRY exec_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
6464 {
6465 GET_CURRENT_CONTEXT(ctx);
6466 FLUSH_VERTICES(ctx, 0);
6467 ctx->Exec->GetTexGendv( coord, pname, params );
6468 }
6469
6470 static void GLAPIENTRY exec_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
6471 {
6472 GET_CURRENT_CONTEXT(ctx);
6473 FLUSH_VERTICES(ctx, 0);
6474 ctx->Exec->GetTexGenfv( coord, pname, params );
6475 }
6476
6477 static void GLAPIENTRY exec_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
6478 {
6479 GET_CURRENT_CONTEXT(ctx);
6480 FLUSH_VERTICES(ctx, 0);
6481 ctx->Exec->GetTexGeniv( coord, pname, params );
6482 }
6483
6484 static void GLAPIENTRY exec_GetTexImage( GLenum target, GLint level, GLenum format,
6485 GLenum type, GLvoid *pixels )
6486 {
6487 GET_CURRENT_CONTEXT(ctx);
6488 FLUSH_VERTICES(ctx, 0);
6489 ctx->Exec->GetTexImage( target, level, format, type, pixels );
6490 }
6491
6492 static void GLAPIENTRY exec_GetTexLevelParameterfv( GLenum target, GLint level,
6493 GLenum pname, GLfloat *params )
6494 {
6495 GET_CURRENT_CONTEXT(ctx);
6496 FLUSH_VERTICES(ctx, 0);
6497 ctx->Exec->GetTexLevelParameterfv( target, level, pname, params );
6498 }
6499
6500 static void GLAPIENTRY exec_GetTexLevelParameteriv( GLenum target, GLint level,
6501 GLenum pname, GLint *params )
6502 {
6503 GET_CURRENT_CONTEXT(ctx);
6504 FLUSH_VERTICES(ctx, 0);
6505 ctx->Exec->GetTexLevelParameteriv( target, level, pname, params );
6506 }
6507
6508 static void GLAPIENTRY exec_GetTexParameterfv( GLenum target, GLenum pname,
6509 GLfloat *params )
6510 {
6511 GET_CURRENT_CONTEXT(ctx);
6512 FLUSH_VERTICES(ctx, 0);
6513 ctx->Exec->GetTexParameterfv( target, pname, params );
6514 }
6515
6516 static void GLAPIENTRY exec_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
6517 {
6518 GET_CURRENT_CONTEXT(ctx);
6519 FLUSH_VERTICES(ctx, 0);
6520 ctx->Exec->GetTexParameteriv( target, pname, params );
6521 }
6522
6523 static GLboolean GLAPIENTRY exec_IsEnabled( GLenum cap )
6524 {
6525 GET_CURRENT_CONTEXT(ctx);
6526 FLUSH_VERTICES(ctx, 0);
6527 return ctx->Exec->IsEnabled( cap );
6528 }
6529
6530 static void GLAPIENTRY exec_PixelStoref( GLenum pname, GLfloat param )
6531 {
6532 GET_CURRENT_CONTEXT(ctx);
6533 FLUSH_VERTICES(ctx, 0);
6534 ctx->Exec->PixelStoref( pname, param );
6535 }
6536
6537 static void GLAPIENTRY exec_PixelStorei( GLenum pname, GLint param )
6538 {
6539 GET_CURRENT_CONTEXT(ctx);
6540 FLUSH_VERTICES(ctx, 0);
6541 ctx->Exec->PixelStorei( pname, param );
6542 }
6543
6544 static void GLAPIENTRY exec_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
6545 GLenum format, GLenum type, GLvoid *pixels )
6546 {
6547 GET_CURRENT_CONTEXT(ctx);
6548 FLUSH_VERTICES(ctx, 0);
6549 ctx->Exec->ReadPixels( x, y, width, height, format, type, pixels );
6550 }
6551
6552 static GLint GLAPIENTRY exec_RenderMode( GLenum mode )
6553 {
6554 GET_CURRENT_CONTEXT(ctx);
6555 FLUSH_VERTICES(ctx, 0);
6556 return ctx->Exec->RenderMode( mode );
6557 }
6558
6559 static void GLAPIENTRY exec_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer )
6560 {
6561 GET_CURRENT_CONTEXT(ctx);
6562 FLUSH_VERTICES(ctx, 0);
6563 ctx->Exec->FeedbackBuffer( size, type, buffer );
6564 }
6565
6566 static void GLAPIENTRY exec_SelectBuffer( GLsizei size, GLuint *buffer )
6567 {
6568 GET_CURRENT_CONTEXT(ctx);
6569 FLUSH_VERTICES(ctx, 0);
6570 ctx->Exec->SelectBuffer( size, buffer );
6571 }
6572
6573 static GLboolean GLAPIENTRY exec_AreTexturesResident(GLsizei n, const GLuint *texName,
6574 GLboolean *residences)
6575 {
6576 GET_CURRENT_CONTEXT(ctx);
6577 FLUSH_VERTICES(ctx, 0);
6578 return ctx->Exec->AreTexturesResident( n, texName, residences);
6579 }
6580
6581 static void GLAPIENTRY exec_ColorPointer(GLint size, GLenum type, GLsizei stride,
6582 const GLvoid *ptr)
6583 {
6584 GET_CURRENT_CONTEXT(ctx);
6585 FLUSH_VERTICES(ctx, 0);
6586 ctx->Exec->ColorPointer( size, type, stride, ptr);
6587 }
6588
6589 static void GLAPIENTRY exec_DeleteTextures( GLsizei n, const GLuint *texName)
6590 {
6591 GET_CURRENT_CONTEXT(ctx);
6592 FLUSH_VERTICES(ctx, 0);
6593 ctx->Exec->DeleteTextures( n, texName);
6594 }
6595
6596 static void GLAPIENTRY exec_DisableClientState( GLenum cap )
6597 {
6598 GET_CURRENT_CONTEXT(ctx);
6599 FLUSH_VERTICES(ctx, 0);
6600 ctx->Exec->DisableClientState( cap );
6601 }
6602
6603 static void GLAPIENTRY exec_EdgeFlagPointer(GLsizei stride, const GLvoid *vptr)
6604 {
6605 GET_CURRENT_CONTEXT(ctx);
6606 FLUSH_VERTICES(ctx, 0);
6607 ctx->Exec->EdgeFlagPointer( stride, vptr);
6608 }
6609
6610 static void GLAPIENTRY exec_EnableClientState( GLenum cap )
6611 {
6612 GET_CURRENT_CONTEXT(ctx);
6613 FLUSH_VERTICES(ctx, 0);
6614 ctx->Exec->EnableClientState( cap );
6615 }
6616
6617 static void GLAPIENTRY exec_GenTextures( GLsizei n, GLuint *texName )
6618 {
6619 GET_CURRENT_CONTEXT(ctx);
6620 FLUSH_VERTICES(ctx, 0);
6621 ctx->Exec->GenTextures( n, texName );
6622 }
6623
6624 static void GLAPIENTRY exec_GetPointerv( GLenum pname, GLvoid **params )
6625 {
6626 GET_CURRENT_CONTEXT(ctx);
6627 FLUSH_VERTICES(ctx, 0);
6628 ctx->Exec->GetPointerv( pname, params );
6629 }
6630
6631 static void GLAPIENTRY exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
6632 {
6633 GET_CURRENT_CONTEXT(ctx);
6634 FLUSH_VERTICES(ctx, 0);
6635 ctx->Exec->IndexPointer( type, stride, ptr);
6636 }
6637
6638 static void GLAPIENTRY exec_InterleavedArrays(GLenum format, GLsizei stride,
6639 const GLvoid *pointer)
6640 {
6641 GET_CURRENT_CONTEXT(ctx);
6642 FLUSH_VERTICES(ctx, 0);
6643 ctx->Exec->InterleavedArrays( format, stride, pointer);
6644 }
6645
6646 static GLboolean GLAPIENTRY exec_IsTexture( GLuint texture )
6647 {
6648 GET_CURRENT_CONTEXT(ctx);
6649 FLUSH_VERTICES(ctx, 0);
6650 return ctx->Exec->IsTexture( texture );
6651 }
6652
6653 static void GLAPIENTRY exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
6654 {
6655 GET_CURRENT_CONTEXT(ctx);
6656 FLUSH_VERTICES(ctx, 0);
6657 ctx->Exec->NormalPointer( type, stride, ptr );
6658 }
6659
6660 static void GLAPIENTRY exec_PopClientAttrib(void)
6661 {
6662 GET_CURRENT_CONTEXT(ctx);
6663 FLUSH_VERTICES(ctx, 0);
6664 ctx->Exec->PopClientAttrib();
6665 }
6666
6667 static void GLAPIENTRY exec_PushClientAttrib(GLbitfield mask)
6668 {
6669 GET_CURRENT_CONTEXT(ctx);
6670 FLUSH_VERTICES(ctx, 0);
6671 ctx->Exec->PushClientAttrib( mask);
6672 }
6673
6674 static void GLAPIENTRY exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
6675 const GLvoid *ptr)
6676 {
6677 GET_CURRENT_CONTEXT(ctx);
6678 FLUSH_VERTICES(ctx, 0);
6679 ctx->Exec->TexCoordPointer( size, type, stride, ptr);
6680 }
6681
6682 static void GLAPIENTRY exec_GetCompressedTexImageARB(GLenum target, GLint level,
6683 GLvoid *img)
6684 {
6685 GET_CURRENT_CONTEXT(ctx);
6686 FLUSH_VERTICES(ctx, 0);
6687 ctx->Exec->GetCompressedTexImageARB( target, level, img);
6688 }
6689
6690 static void GLAPIENTRY exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
6691 const GLvoid *ptr)
6692 {
6693 GET_CURRENT_CONTEXT(ctx);
6694 FLUSH_VERTICES(ctx, 0);
6695 ctx->Exec->VertexPointer( size, type, stride, ptr);
6696 }
6697
6698 static void GLAPIENTRY exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
6699 GLint x, GLint y, GLsizei width)
6700 {
6701 GET_CURRENT_CONTEXT(ctx);
6702 FLUSH_VERTICES(ctx, 0);
6703 ctx->Exec->CopyConvolutionFilter1D( target, internalFormat, x, y, width);
6704 }
6705
6706 static void GLAPIENTRY exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat,
6707 GLint x, GLint y, GLsizei width,
6708 GLsizei height)
6709 {
6710 GET_CURRENT_CONTEXT(ctx);
6711 FLUSH_VERTICES(ctx, 0);
6712 ctx->Exec->CopyConvolutionFilter2D( target, internalFormat, x, y, width,
6713 height);
6714 }
6715
6716 static void GLAPIENTRY exec_GetColorTable( GLenum target, GLenum format,
6717 GLenum type, GLvoid *data )
6718 {
6719 GET_CURRENT_CONTEXT(ctx);
6720 FLUSH_VERTICES(ctx, 0);
6721 ctx->Exec->GetColorTable( target, format, type, data );
6722 }
6723
6724 static void GLAPIENTRY exec_GetColorTableParameterfv( GLenum target, GLenum pname,
6725 GLfloat *params )
6726 {
6727 GET_CURRENT_CONTEXT(ctx);
6728 FLUSH_VERTICES(ctx, 0);
6729 ctx->Exec->GetColorTableParameterfv( target, pname, params );
6730 }
6731
6732 static void GLAPIENTRY exec_GetColorTableParameteriv( GLenum target, GLenum pname,
6733 GLint *params )
6734 {
6735 GET_CURRENT_CONTEXT(ctx);
6736 FLUSH_VERTICES(ctx, 0);
6737 ctx->Exec->GetColorTableParameteriv( target, pname, params );
6738 }
6739
6740 static void GLAPIENTRY exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
6741 GLvoid *image)
6742 {
6743 GET_CURRENT_CONTEXT(ctx);
6744 FLUSH_VERTICES(ctx, 0);
6745 ctx->Exec->GetConvolutionFilter( target, format, type, image);
6746 }
6747
6748 static void GLAPIENTRY exec_GetConvolutionParameterfv(GLenum target, GLenum pname,
6749 GLfloat *params)
6750 {
6751 GET_CURRENT_CONTEXT(ctx);
6752 FLUSH_VERTICES(ctx, 0);
6753 ctx->Exec->GetConvolutionParameterfv( target, pname, params);
6754 }
6755
6756 static void GLAPIENTRY exec_GetConvolutionParameteriv(GLenum target, GLenum pname,
6757 GLint *params)
6758 {
6759 GET_CURRENT_CONTEXT(ctx);
6760 FLUSH_VERTICES(ctx, 0);
6761 ctx->Exec->GetConvolutionParameteriv( target, pname, params);
6762 }
6763
6764 static void GLAPIENTRY exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
6765 GLenum type, GLvoid *values)
6766 {
6767 GET_CURRENT_CONTEXT(ctx);
6768 FLUSH_VERTICES(ctx, 0);
6769 ctx->Exec->GetHistogram( target, reset, format, type, values);
6770 }
6771
6772 static void GLAPIENTRY exec_GetHistogramParameterfv(GLenum target, GLenum pname,
6773 GLfloat *params)
6774 {
6775 GET_CURRENT_CONTEXT(ctx);
6776 FLUSH_VERTICES(ctx, 0);
6777 ctx->Exec->GetHistogramParameterfv( target, pname, params);
6778 }
6779
6780 static void GLAPIENTRY exec_GetHistogramParameteriv(GLenum target, GLenum pname,
6781 GLint *params)
6782 {
6783 GET_CURRENT_CONTEXT(ctx);
6784 FLUSH_VERTICES(ctx, 0);
6785 ctx->Exec->GetHistogramParameteriv( target, pname, params);
6786 }
6787
6788 static void GLAPIENTRY exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
6789 GLenum type, GLvoid *values)
6790 {
6791 GET_CURRENT_CONTEXT(ctx);
6792 FLUSH_VERTICES(ctx, 0);
6793 ctx->Exec->GetMinmax( target, reset, format, type, values);
6794 }
6795
6796 static void GLAPIENTRY exec_GetMinmaxParameterfv(GLenum target, GLenum pname,
6797 GLfloat *params)
6798 {
6799 GET_CURRENT_CONTEXT(ctx);
6800 FLUSH_VERTICES(ctx, 0);
6801 ctx->Exec->GetMinmaxParameterfv( target, pname, params);
6802 }
6803
6804 static void GLAPIENTRY exec_GetMinmaxParameteriv(GLenum target, GLenum pname,
6805 GLint *params)
6806 {
6807 GET_CURRENT_CONTEXT(ctx);
6808 FLUSH_VERTICES(ctx, 0);
6809 ctx->Exec->GetMinmaxParameteriv( target, pname, params);
6810 }
6811
6812 static void GLAPIENTRY exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
6813 GLvoid *row, GLvoid *column, GLvoid *span)
6814 {
6815 GET_CURRENT_CONTEXT(ctx);
6816 FLUSH_VERTICES(ctx, 0);
6817 ctx->Exec->GetSeparableFilter( target, format, type, row, column, span);
6818 }
6819
6820 static void GLAPIENTRY exec_SeparableFilter2D(GLenum target, GLenum internalFormat,
6821 GLsizei width, GLsizei height, GLenum format,
6822 GLenum type, const GLvoid *row,
6823 const GLvoid *column)
6824 {
6825 GET_CURRENT_CONTEXT(ctx);
6826 FLUSH_VERTICES(ctx, 0);
6827 ctx->Exec->SeparableFilter2D( target, internalFormat, width, height, format,
6828 type, row, column);
6829 }
6830
6831 static void GLAPIENTRY exec_GetPixelTexGenParameterivSGIS(GLenum target, GLint *value)
6832 {
6833 GET_CURRENT_CONTEXT(ctx);
6834 FLUSH_VERTICES(ctx, 0);
6835 ctx->Exec->GetPixelTexGenParameterivSGIS( target, value);
6836 }
6837
6838 static void GLAPIENTRY exec_GetPixelTexGenParameterfvSGIS(GLenum target, GLfloat *value)
6839 {
6840 GET_CURRENT_CONTEXT(ctx);
6841 FLUSH_VERTICES(ctx, 0);
6842 ctx->Exec->GetPixelTexGenParameterfvSGIS( target, value);
6843 }
6844
6845 static void GLAPIENTRY exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride,
6846 GLsizei count, const GLvoid *ptr)
6847 {
6848 GET_CURRENT_CONTEXT(ctx);
6849 FLUSH_VERTICES(ctx, 0);
6850 ctx->Exec->ColorPointerEXT( size, type, stride, count, ptr);
6851 }
6852
6853 static void GLAPIENTRY exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count,
6854 const GLboolean *ptr)
6855 {
6856 GET_CURRENT_CONTEXT(ctx);
6857 FLUSH_VERTICES(ctx, 0);
6858 ctx->Exec->EdgeFlagPointerEXT( stride, count, ptr);
6859 }
6860
6861 static void GLAPIENTRY exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
6862 const GLvoid *ptr)
6863 {
6864 GET_CURRENT_CONTEXT(ctx);
6865 FLUSH_VERTICES(ctx, 0);
6866 ctx->Exec->IndexPointerEXT( type, stride, count, ptr);
6867 }
6868
6869 static void GLAPIENTRY exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
6870 const GLvoid *ptr)
6871 {
6872 GET_CURRENT_CONTEXT(ctx);
6873 FLUSH_VERTICES(ctx, 0);
6874 ctx->Exec->NormalPointerEXT( type, stride, count, ptr);
6875 }
6876
6877 static void GLAPIENTRY exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
6878 GLsizei count, const GLvoid *ptr)
6879 {
6880 GET_CURRENT_CONTEXT(ctx);
6881 FLUSH_VERTICES(ctx, 0);
6882 ctx->Exec->TexCoordPointerEXT( size, type, stride, count, ptr);
6883 }
6884
6885 static void GLAPIENTRY exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
6886 GLsizei count, const GLvoid *ptr)
6887 {
6888 GET_CURRENT_CONTEXT(ctx);
6889 FLUSH_VERTICES(ctx, 0);
6890 ctx->Exec->VertexPointerEXT( size, type, stride, count, ptr);
6891 }
6892
6893 static void GLAPIENTRY exec_LockArraysEXT(GLint first, GLsizei count)
6894 {
6895 GET_CURRENT_CONTEXT(ctx);
6896 FLUSH_VERTICES(ctx, 0);
6897 ctx->Exec->LockArraysEXT( first, count);
6898 }
6899
6900 static void GLAPIENTRY exec_UnlockArraysEXT( void )
6901 {
6902 GET_CURRENT_CONTEXT(ctx);
6903 FLUSH_VERTICES(ctx, 0);
6904 ctx->Exec->UnlockArraysEXT( );
6905 }
6906
6907 static void GLAPIENTRY exec_ResizeBuffersMESA( void )
6908 {
6909 GET_CURRENT_CONTEXT(ctx);
6910 FLUSH_VERTICES(ctx, 0);
6911 ctx->Exec->ResizeBuffersMESA( );
6912 }
6913
6914
6915 static void GLAPIENTRY exec_ClientActiveTextureARB( GLenum target )
6916 {
6917 GET_CURRENT_CONTEXT(ctx);
6918 FLUSH_VERTICES(ctx, 0);
6919 ctx->Exec->ClientActiveTextureARB(target);
6920 }
6921
6922 static void GLAPIENTRY exec_SecondaryColorPointerEXT(GLint size, GLenum type,
6923 GLsizei stride, const GLvoid *ptr)
6924 {
6925 GET_CURRENT_CONTEXT(ctx);
6926 FLUSH_VERTICES(ctx, 0);
6927 ctx->Exec->SecondaryColorPointerEXT( size, type, stride, ptr);
6928 }
6929
6930 static void GLAPIENTRY exec_FogCoordPointerEXT(GLenum type, GLsizei stride,
6931 const GLvoid *ptr)
6932 {
6933 GET_CURRENT_CONTEXT(ctx);
6934 FLUSH_VERTICES(ctx, 0);
6935 ctx->Exec->FogCoordPointerEXT( type, stride, ptr);
6936 }
6937
6938 /* GL_EXT_multi_draw_arrays */
6939 static void GLAPIENTRY exec_MultiDrawArraysEXT(GLenum mode, GLint *first,
6940 GLsizei *count, GLsizei primcount)
6941 {
6942 GET_CURRENT_CONTEXT(ctx);
6943 FLUSH_VERTICES(ctx, 0);
6944 ctx->Exec->MultiDrawArraysEXT( mode, first, count, primcount );
6945 }
6946
6947 /* GL_EXT_multi_draw_arrays */
6948 static void GLAPIENTRY exec_MultiDrawElementsEXT(GLenum mode, const GLsizei *count,
6949 GLenum type, const GLvoid **indices,
6950 GLsizei primcount)
6951 {
6952 GET_CURRENT_CONTEXT(ctx);
6953 FLUSH_VERTICES(ctx, 0);
6954 ctx->Exec->MultiDrawElementsEXT(mode, count, type, indices, primcount);
6955 }
6956
6957 /* GL_IBM_multimode_draw_arrays */
6958 static void GLAPIENTRY exec_MultiModeDrawArraysIBM(const GLenum *mode, const GLint *first,
6959 const GLsizei *count, GLsizei primcount,
6960 GLint modestride)
6961 {
6962 GET_CURRENT_CONTEXT(ctx);
6963 FLUSH_VERTICES(ctx, 0);
6964 ctx->Exec->MultiModeDrawArraysIBM(mode, first, count, primcount, modestride);
6965 }
6966
6967 /* GL_IBM_multimode_draw_arrays */
6968 static void GLAPIENTRY exec_MultiModeDrawElementsIBM(const GLenum *mode,
6969 const GLsizei *count,
6970 GLenum type,
6971 const GLvoid * const *indices,
6972 GLsizei primcount, GLint modestride)
6973 {
6974 GET_CURRENT_CONTEXT(ctx);
6975 FLUSH_VERTICES(ctx, 0);
6976 ctx->Exec->MultiModeDrawElementsIBM(mode, count, type, indices, primcount,
6977 modestride);
6978 }
6979
6980
6981
6982
6983 /**
6984 * Setup the given dispatch table to point to Mesa's display list
6985 * building functions.
6986 *
6987 * This does not include any of the tnl functions - they are
6988 * initialized from _mesa_init_api_defaults and from the active vtxfmt
6989 * struct.
6990 */
6991 void
6992 _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
6993 {
6994 _mesa_init_no_op_table(table, tableSize);
6995
6996 _mesa_loopback_init_api_table( table );
6997
6998 /* GL 1.0 */
6999 table->Accum = save_Accum;
7000 table->AlphaFunc = save_AlphaFunc;
7001 table->Bitmap = save_Bitmap;
7002 table->CallList = _mesa_save_CallList;
7003 table->CallLists = _mesa_save_CallLists;
7004 table->Clear = save_Clear;
7005 table->ClearAccum = save_ClearAccum;
7006 table->ClearColor = save_ClearColor;
7007 table->ClearDepth = save_ClearDepth;
7008 table->ClearIndex = save_ClearIndex;
7009 table->ClearStencil = save_ClearStencil;
7010 table->ClipPlane = save_ClipPlane;
7011 table->ColorMask = save_ColorMask;
7012 table->ColorMaterial = save_ColorMaterial;
7013 table->CopyPixels = save_CopyPixels;
7014 table->CullFace = save_CullFace;
7015 table->DeleteLists = _mesa_DeleteLists;
7016 table->DepthFunc = save_DepthFunc;
7017 table->DepthMask = save_DepthMask;
7018 table->DepthRange = save_DepthRange;
7019 table->Disable = save_Disable;
7020 table->DrawBuffer = save_DrawBuffer;
7021 table->DrawPixels = save_DrawPixels;
7022 table->Enable = save_Enable;
7023 table->EndList = _mesa_EndList;
7024 table->EvalMesh1 = _mesa_save_EvalMesh1;
7025 table->EvalMesh2 = _mesa_save_EvalMesh2;
7026 table->Finish = exec_Finish;
7027 table->Flush = exec_Flush;
7028 table->Fogf = save_Fogf;
7029 table->Fogfv = save_Fogfv;
7030 table->Fogi = save_Fogi;
7031 table->Fogiv = save_Fogiv;
7032 table->FrontFace = save_FrontFace;
7033 table->Frustum = save_Frustum;
7034 table->GenLists = _mesa_GenLists;
7035 table->GetBooleanv = exec_GetBooleanv;
7036 table->GetClipPlane = exec_GetClipPlane;
7037 table->GetDoublev = exec_GetDoublev;
7038 table->GetError = exec_GetError;
7039 table->GetFloatv = exec_GetFloatv;
7040 table->GetIntegerv = exec_GetIntegerv;
7041 table->GetLightfv = exec_GetLightfv;
7042 table->GetLightiv = exec_GetLightiv;
7043 table->GetMapdv = exec_GetMapdv;
7044 table->GetMapfv = exec_GetMapfv;
7045 table->GetMapiv = exec_GetMapiv;
7046 table->GetMaterialfv = exec_GetMaterialfv;
7047 table->GetMaterialiv = exec_GetMaterialiv;
7048 table->GetPixelMapfv = exec_GetPixelMapfv;
7049 table->GetPixelMapuiv = exec_GetPixelMapuiv;
7050 table->GetPixelMapusv = exec_GetPixelMapusv;
7051 table->GetPolygonStipple = exec_GetPolygonStipple;
7052 table->GetString = exec_GetString;
7053 table->GetTexEnvfv = exec_GetTexEnvfv;
7054 table->GetTexEnviv = exec_GetTexEnviv;
7055 table->GetTexGendv = exec_GetTexGendv;
7056 table->GetTexGenfv = exec_GetTexGenfv;
7057 table->GetTexGeniv = exec_GetTexGeniv;
7058 table->GetTexImage = exec_GetTexImage;
7059 table->GetTexLevelParameterfv = exec_GetTexLevelParameterfv;
7060 table->GetTexLevelParameteriv = exec_GetTexLevelParameteriv;
7061 table->GetTexParameterfv = exec_GetTexParameterfv;
7062 table->GetTexParameteriv = exec_GetTexParameteriv;
7063 table->Hint = save_Hint;
7064 table->IndexMask = save_IndexMask;
7065 table->InitNames = save_InitNames;
7066 table->IsEnabled = exec_IsEnabled;
7067 table->IsList = _mesa_IsList;
7068 table->LightModelf = save_LightModelf;
7069 table->LightModelfv = save_LightModelfv;
7070 table->LightModeli = save_LightModeli;
7071 table->LightModeliv = save_LightModeliv;
7072 table->Lightf = save_Lightf;
7073 table->Lightfv = save_Lightfv;
7074 table->Lighti = save_Lighti;
7075 table->Lightiv = save_Lightiv;
7076 table->LineStipple = save_LineStipple;
7077 table->LineWidth = save_LineWidth;
7078 table->ListBase = save_ListBase;
7079 table->LoadIdentity = save_LoadIdentity;
7080 table->LoadMatrixd = save_LoadMatrixd;
7081 table->LoadMatrixf = save_LoadMatrixf;
7082 table->LoadName = save_LoadName;
7083 table->LogicOp = save_LogicOp;
7084 table->Map1d = save_Map1d;
7085 table->Map1f = save_Map1f;
7086 table->Map2d = save_Map2d;
7087 table->Map2f = save_Map2f;
7088 table->MapGrid1d = save_MapGrid1d;
7089 table->MapGrid1f = save_MapGrid1f;
7090 table->MapGrid2d = save_MapGrid2d;
7091 table->MapGrid2f = save_MapGrid2f;
7092 table->MatrixMode = save_MatrixMode;
7093 table->MultMatrixd = save_MultMatrixd;
7094 table->MultMatrixf = save_MultMatrixf;
7095 table->NewList = save_NewList;
7096 table->Ortho = save_Ortho;
7097 table->PassThrough = save_PassThrough;
7098 table->PixelMapfv = save_PixelMapfv;
7099 table->PixelMapuiv = save_PixelMapuiv;
7100 table->PixelMapusv = save_PixelMapusv;
7101 table->PixelStoref = exec_PixelStoref;
7102 table->PixelStorei = exec_PixelStorei;
7103 table->PixelTransferf = save_PixelTransferf;
7104 table->PixelTransferi = save_PixelTransferi;
7105 table->PixelZoom = save_PixelZoom;
7106 table->PointSize = save_PointSize;
7107 table->PolygonMode = save_PolygonMode;
7108 table->PolygonOffset = save_PolygonOffset;
7109 table->PolygonStipple = save_PolygonStipple;
7110 table->PopAttrib = save_PopAttrib;
7111 table->PopMatrix = save_PopMatrix;
7112 table->PopName = save_PopName;
7113 table->PushAttrib = save_PushAttrib;
7114 table->PushMatrix = save_PushMatrix;
7115 table->PushName = save_PushName;
7116 table->RasterPos2d = save_RasterPos2d;
7117 table->RasterPos2dv = save_RasterPos2dv;
7118 table->RasterPos2f = save_RasterPos2f;
7119 table->RasterPos2fv = save_RasterPos2fv;
7120 table->RasterPos2i = save_RasterPos2i;
7121 table->RasterPos2iv = save_RasterPos2iv;
7122 table->RasterPos2s = save_RasterPos2s;
7123 table->RasterPos2sv = save_RasterPos2sv;
7124 table->RasterPos3d = save_RasterPos3d;
7125 table->RasterPos3dv = save_RasterPos3dv;
7126 table->RasterPos3f = save_RasterPos3f;
7127 table->RasterPos3fv = save_RasterPos3fv;
7128 table->RasterPos3i = save_RasterPos3i;
7129 table->RasterPos3iv = save_RasterPos3iv;
7130 table->RasterPos3s = save_RasterPos3s;
7131 table->RasterPos3sv = save_RasterPos3sv;
7132 table->RasterPos4d = save_RasterPos4d;
7133 table->RasterPos4dv = save_RasterPos4dv;
7134 table->RasterPos4f = save_RasterPos4f;
7135 table->RasterPos4fv = save_RasterPos4fv;
7136 table->RasterPos4i = save_RasterPos4i;
7137 table->RasterPos4iv = save_RasterPos4iv;
7138 table->RasterPos4s = save_RasterPos4s;
7139 table->RasterPos4sv = save_RasterPos4sv;
7140 table->ReadBuffer = save_ReadBuffer;
7141 table->ReadPixels = exec_ReadPixels;
7142 table->RenderMode = exec_RenderMode;
7143 table->Rotated = save_Rotated;
7144 table->Rotatef = save_Rotatef;
7145 table->Scaled = save_Scaled;
7146 table->Scalef = save_Scalef;
7147 table->Scissor = save_Scissor;
7148 table->FeedbackBuffer = exec_FeedbackBuffer;
7149 table->SelectBuffer = exec_SelectBuffer;
7150 table->ShadeModel = save_ShadeModel;
7151 table->StencilFunc = save_StencilFunc;
7152 table->StencilMask = save_StencilMask;
7153 table->StencilOp = save_StencilOp;
7154 table->TexEnvf = save_TexEnvf;
7155 table->TexEnvfv = save_TexEnvfv;
7156 table->TexEnvi = save_TexEnvi;
7157 table->TexEnviv = save_TexEnviv;
7158 table->TexGend = save_TexGend;
7159 table->TexGendv = save_TexGendv;
7160 table->TexGenf = save_TexGenf;
7161 table->TexGenfv = save_TexGenfv;
7162 table->TexGeni = save_TexGeni;
7163 table->TexGeniv = save_TexGeniv;
7164 table->TexImage1D = save_TexImage1D;
7165 table->TexImage2D = save_TexImage2D;
7166 table->TexParameterf = save_TexParameterf;
7167 table->TexParameterfv = save_TexParameterfv;
7168 table->TexParameteri = save_TexParameteri;
7169 table->TexParameteriv = save_TexParameteriv;
7170 table->Translated = save_Translated;
7171 table->Translatef = save_Translatef;
7172 table->Viewport = save_Viewport;
7173
7174 /* GL 1.1 */
7175 table->AreTexturesResident = exec_AreTexturesResident;
7176 table->AreTexturesResidentEXT = exec_AreTexturesResident;
7177 table->BindTexture = save_BindTexture;
7178 table->ColorPointer = exec_ColorPointer;
7179 table->CopyTexImage1D = save_CopyTexImage1D;
7180 table->CopyTexImage2D = save_CopyTexImage2D;
7181 table->CopyTexSubImage1D = save_CopyTexSubImage1D;
7182 table->CopyTexSubImage2D = save_CopyTexSubImage2D;
7183 table->DeleteTextures = exec_DeleteTextures;
7184 table->DisableClientState = exec_DisableClientState;
7185 table->EdgeFlagPointer = exec_EdgeFlagPointer;
7186 table->EnableClientState = exec_EnableClientState;
7187 table->GenTextures = exec_GenTextures;
7188 table->GenTexturesEXT = exec_GenTextures;
7189 table->GetPointerv = exec_GetPointerv;
7190 table->IndexPointer = exec_IndexPointer;
7191 table->InterleavedArrays = exec_InterleavedArrays;
7192 table->IsTexture = exec_IsTexture;
7193 table->IsTextureEXT = exec_IsTexture;
7194 table->NormalPointer = exec_NormalPointer;
7195 table->PopClientAttrib = exec_PopClientAttrib;
7196 table->PrioritizeTextures = save_PrioritizeTextures;
7197 table->PushClientAttrib = exec_PushClientAttrib;
7198 table->TexCoordPointer = exec_TexCoordPointer;
7199 table->TexSubImage1D = save_TexSubImage1D;
7200 table->TexSubImage2D = save_TexSubImage2D;
7201 table->VertexPointer = exec_VertexPointer;
7202
7203 /* GL 1.2 */
7204 table->CopyTexSubImage3D = save_CopyTexSubImage3D;
7205 table->TexImage3D = save_TexImage3D;
7206 table->TexSubImage3D = save_TexSubImage3D;
7207
7208 /* GL_ARB_imaging */
7209 /* Not all are supported */
7210 table->BlendColor = save_BlendColor;
7211 table->BlendEquation = save_BlendEquation;
7212 table->ColorSubTable = save_ColorSubTable;
7213 table->ColorTable = save_ColorTable;
7214 table->ColorTableParameterfv = save_ColorTableParameterfv;
7215 table->ColorTableParameteriv = save_ColorTableParameteriv;
7216 table->ConvolutionFilter1D = save_ConvolutionFilter1D;
7217 table->ConvolutionFilter2D = save_ConvolutionFilter2D;
7218 table->ConvolutionParameterf = save_ConvolutionParameterf;
7219 table->ConvolutionParameterfv = save_ConvolutionParameterfv;
7220 table->ConvolutionParameteri = save_ConvolutionParameteri;
7221 table->ConvolutionParameteriv = save_ConvolutionParameteriv;
7222 table->CopyColorSubTable = save_CopyColorSubTable;
7223 table->CopyColorTable = save_CopyColorTable;
7224 table->CopyConvolutionFilter1D = exec_CopyConvolutionFilter1D;
7225 table->CopyConvolutionFilter2D = exec_CopyConvolutionFilter2D;
7226 table->GetColorTable = exec_GetColorTable;
7227 table->GetColorTableEXT = exec_GetColorTable;
7228 table->GetColorTableParameterfv = exec_GetColorTableParameterfv;
7229 table->GetColorTableParameterfvEXT = exec_GetColorTableParameterfv;
7230 table->GetColorTableParameteriv = exec_GetColorTableParameteriv;
7231 table->GetColorTableParameterivEXT = exec_GetColorTableParameteriv;
7232 table->GetConvolutionFilter = exec_GetConvolutionFilter;
7233 table->GetConvolutionFilterEXT = exec_GetConvolutionFilter;
7234 table->GetConvolutionParameterfv = exec_GetConvolutionParameterfv;
7235 table->GetConvolutionParameterfvEXT = exec_GetConvolutionParameterfv;
7236 table->GetConvolutionParameteriv = exec_GetConvolutionParameteriv;
7237 table->GetConvolutionParameterivEXT = exec_GetConvolutionParameteriv;
7238 table->GetHistogram = exec_GetHistogram;
7239 table->GetHistogramEXT = exec_GetHistogram;
7240 table->GetHistogramParameterfv = exec_GetHistogramParameterfv;
7241 table->GetHistogramParameterfvEXT = exec_GetHistogramParameterfv;
7242 table->GetHistogramParameteriv = exec_GetHistogramParameteriv;
7243 table->GetHistogramParameterivEXT = exec_GetHistogramParameteriv;
7244 table->GetMinmax = exec_GetMinmax;
7245 table->GetMinmaxEXT = exec_GetMinmax;
7246 table->GetMinmaxParameterfv = exec_GetMinmaxParameterfv;
7247 table->GetMinmaxParameterfvEXT = exec_GetMinmaxParameterfv;
7248 table->GetMinmaxParameteriv = exec_GetMinmaxParameteriv;
7249 table->GetMinmaxParameterivEXT = exec_GetMinmaxParameteriv;
7250 table->GetSeparableFilter = exec_GetSeparableFilter;
7251 table->GetSeparableFilterEXT = exec_GetSeparableFilter;
7252 table->Histogram = save_Histogram;
7253 table->Minmax = save_Minmax;
7254 table->ResetHistogram = save_ResetHistogram;
7255 table->ResetMinmax = save_ResetMinmax;
7256 table->SeparableFilter2D = exec_SeparableFilter2D;
7257
7258 /* 2. GL_EXT_blend_color */
7259 #if 0
7260 table->BlendColorEXT = save_BlendColorEXT;
7261 #endif
7262
7263 /* 3. GL_EXT_polygon_offset */
7264 table->PolygonOffsetEXT = save_PolygonOffsetEXT;
7265
7266 /* 6. GL_EXT_texture3d */
7267 #if 0
7268 table->CopyTexSubImage3DEXT = save_CopyTexSubImage3D;
7269 table->TexImage3DEXT = save_TexImage3DEXT;
7270 table->TexSubImage3DEXT = save_TexSubImage3D;
7271 #endif
7272
7273 /* 15. GL_SGIX_pixel_texture */
7274 table->PixelTexGenSGIX = save_PixelTexGenSGIX;
7275
7276 /* 15. GL_SGIS_pixel_texture */
7277 table->PixelTexGenParameteriSGIS = save_PixelTexGenParameteriSGIS;
7278 table->PixelTexGenParameterfSGIS = save_PixelTexGenParameterfSGIS;
7279 table->PixelTexGenParameterivSGIS = save_PixelTexGenParameterivSGIS;
7280 table->PixelTexGenParameterfvSGIS = save_PixelTexGenParameterfvSGIS;
7281 table->GetPixelTexGenParameterivSGIS = exec_GetPixelTexGenParameterivSGIS;
7282 table->GetPixelTexGenParameterfvSGIS = exec_GetPixelTexGenParameterfvSGIS;
7283
7284 /* 30. GL_EXT_vertex_array */
7285 table->ColorPointerEXT = exec_ColorPointerEXT;
7286 table->EdgeFlagPointerEXT = exec_EdgeFlagPointerEXT;
7287 table->IndexPointerEXT = exec_IndexPointerEXT;
7288 table->NormalPointerEXT = exec_NormalPointerEXT;
7289 table->TexCoordPointerEXT = exec_TexCoordPointerEXT;
7290 table->VertexPointerEXT = exec_VertexPointerEXT;
7291
7292 /* 37. GL_EXT_blend_minmax */
7293 #if 0
7294 table->BlendEquationEXT = save_BlendEquationEXT;
7295 #endif
7296
7297 /* 54. GL_EXT_point_parameters */
7298 table->PointParameterfEXT = save_PointParameterfEXT;
7299 table->PointParameterfvEXT = save_PointParameterfvEXT;
7300
7301 /* 78. GL_EXT_paletted_texture */
7302 #if 0
7303 table->ColorTableEXT = save_ColorTable;
7304 table->ColorSubTableEXT = save_ColorSubTable;
7305 #endif
7306 table->GetColorTableEXT = exec_GetColorTable;
7307 table->GetColorTableParameterfvEXT = exec_GetColorTableParameterfv;
7308 table->GetColorTableParameterivEXT = exec_GetColorTableParameteriv;
7309
7310 /* 97. GL_EXT_compiled_vertex_array */
7311 table->LockArraysEXT = exec_LockArraysEXT;
7312 table->UnlockArraysEXT = exec_UnlockArraysEXT;
7313
7314 /* 145. GL_EXT_secondary_color */
7315 table->SecondaryColorPointerEXT = exec_SecondaryColorPointerEXT;
7316
7317 /* 148. GL_EXT_multi_draw_arrays */
7318 table->MultiDrawArraysEXT = exec_MultiDrawArraysEXT;
7319 table->MultiDrawElementsEXT = exec_MultiDrawElementsEXT;
7320
7321 /* 149. GL_EXT_fog_coord */
7322 table->FogCoordPointerEXT = exec_FogCoordPointerEXT;
7323
7324 /* 173. GL_EXT_blend_func_separate */
7325 table->BlendFuncSeparateEXT = save_BlendFuncSeparateEXT;
7326
7327 /* 196. GL_MESA_resize_buffers */
7328 table->ResizeBuffersMESA = exec_ResizeBuffersMESA;
7329
7330 /* 197. GL_MESA_window_pos */
7331 table->WindowPos2dMESA = save_WindowPos2dMESA;
7332 table->WindowPos2dvMESA = save_WindowPos2dvMESA;
7333 table->WindowPos2fMESA = save_WindowPos2fMESA;
7334 table->WindowPos2fvMESA = save_WindowPos2fvMESA;
7335 table->WindowPos2iMESA = save_WindowPos2iMESA;
7336 table->WindowPos2ivMESA = save_WindowPos2ivMESA;
7337 table->WindowPos2sMESA = save_WindowPos2sMESA;
7338 table->WindowPos2svMESA = save_WindowPos2svMESA;
7339 table->WindowPos3dMESA = save_WindowPos3dMESA;
7340 table->WindowPos3dvMESA = save_WindowPos3dvMESA;
7341 table->WindowPos3fMESA = save_WindowPos3fMESA;
7342 table->WindowPos3fvMESA = save_WindowPos3fvMESA;
7343 table->WindowPos3iMESA = save_WindowPos3iMESA;
7344 table->WindowPos3ivMESA = save_WindowPos3ivMESA;
7345 table->WindowPos3sMESA = save_WindowPos3sMESA;
7346 table->WindowPos3svMESA = save_WindowPos3svMESA;
7347 table->WindowPos4dMESA = save_WindowPos4dMESA;
7348 table->WindowPos4dvMESA = save_WindowPos4dvMESA;
7349 table->WindowPos4fMESA = save_WindowPos4fMESA;
7350 table->WindowPos4fvMESA = save_WindowPos4fvMESA;
7351 table->WindowPos4iMESA = save_WindowPos4iMESA;
7352 table->WindowPos4ivMESA = save_WindowPos4ivMESA;
7353 table->WindowPos4sMESA = save_WindowPos4sMESA;
7354 table->WindowPos4svMESA = save_WindowPos4svMESA;
7355
7356 /* 200. GL_IBM_multimode_draw_arrays */
7357 table->MultiModeDrawArraysIBM = exec_MultiModeDrawArraysIBM;
7358 table->MultiModeDrawElementsIBM = exec_MultiModeDrawElementsIBM;
7359
7360 #if FEATURE_NV_vertex_program
7361 /* 233. GL_NV_vertex_program */
7362 /* The following commands DO NOT go into display lists:
7363 * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV,
7364 * VertexAttribPointerNV, GetProgram*, GetVertexAttrib*
7365 */
7366 table->BindProgramNV = save_BindProgramNV;
7367 table->DeleteProgramsNV = _mesa_DeletePrograms;
7368 table->ExecuteProgramNV = save_ExecuteProgramNV;
7369 table->GenProgramsNV = _mesa_GenPrograms;
7370 table->AreProgramsResidentNV = _mesa_AreProgramsResidentNV;
7371 table->RequestResidentProgramsNV = save_RequestResidentProgramsNV;
7372 table->GetProgramParameterfvNV = _mesa_GetProgramParameterfvNV;
7373 table->GetProgramParameterdvNV = _mesa_GetProgramParameterdvNV;
7374 table->GetProgramivNV = _mesa_GetProgramivNV;
7375 table->GetProgramStringNV = _mesa_GetProgramStringNV;
7376 table->GetTrackMatrixivNV = _mesa_GetTrackMatrixivNV;
7377 table->GetVertexAttribdvNV = _mesa_GetVertexAttribdvNV;
7378 table->GetVertexAttribfvNV = _mesa_GetVertexAttribfvNV;
7379 table->GetVertexAttribivNV = _mesa_GetVertexAttribivNV;
7380 table->GetVertexAttribPointervNV = _mesa_GetVertexAttribPointervNV;
7381 table->IsProgramNV = _mesa_IsProgram;
7382 table->LoadProgramNV = save_LoadProgramNV;
7383 table->ProgramParameter4dNV = save_ProgramParameter4dNV;
7384 table->ProgramParameter4dvNV = save_ProgramParameter4dvNV;
7385 table->ProgramParameter4fNV = save_ProgramParameter4fNV;
7386 table->ProgramParameter4fvNV = save_ProgramParameter4fvNV;
7387 table->ProgramParameters4dvNV = save_ProgramParameters4dvNV;
7388 table->ProgramParameters4fvNV = save_ProgramParameters4fvNV;
7389 table->TrackMatrixNV = save_TrackMatrixNV;
7390 table->VertexAttribPointerNV = _mesa_VertexAttribPointerNV;
7391 #endif
7392
7393 /* 282. GL_NV_fragment_program */
7394 #if FEATURE_NV_fragment_program
7395 table->ProgramNamedParameter4fNV = save_ProgramNamedParameter4fNV;
7396 table->ProgramNamedParameter4dNV = save_ProgramNamedParameter4dNV;
7397 table->ProgramNamedParameter4fvNV = save_ProgramNamedParameter4fvNV;
7398 table->ProgramNamedParameter4dvNV = save_ProgramNamedParameter4dvNV;
7399 table->GetProgramNamedParameterfvNV = _mesa_GetProgramNamedParameterfvNV;
7400 table->GetProgramNamedParameterdvNV = _mesa_GetProgramNamedParameterdvNV;
7401 table->ProgramLocalParameter4dARB = save_ProgramLocalParameter4dARB;
7402 table->ProgramLocalParameter4dvARB = save_ProgramLocalParameter4dvARB;
7403 table->ProgramLocalParameter4fARB = save_ProgramLocalParameter4fARB;
7404 table->ProgramLocalParameter4fvARB = save_ProgramLocalParameter4fvARB;
7405 table->GetProgramLocalParameterdvARB = _mesa_GetProgramLocalParameterdvARB;
7406 table->GetProgramLocalParameterfvARB = _mesa_GetProgramLocalParameterfvARB;
7407 #endif
7408
7409 /* 262. GL_NV_point_sprite */
7410 table->PointParameteriNV = save_PointParameteriNV;
7411 table->PointParameterivNV = save_PointParameterivNV;
7412
7413 /* 268. GL_EXT_stencil_two_side */
7414 table->ActiveStencilFaceEXT = save_ActiveStencilFaceEXT;
7415
7416 /* ???. GL_EXT_depth_bounds_test */
7417 table->DepthBoundsEXT = save_DepthBoundsEXT;
7418
7419 /* ARB 1. GL_ARB_multitexture */
7420 table->ActiveTextureARB = save_ActiveTextureARB;
7421 table->ClientActiveTextureARB = exec_ClientActiveTextureARB;
7422
7423 /* ARB 3. GL_ARB_transpose_matrix */
7424 table->LoadTransposeMatrixdARB = save_LoadTransposeMatrixdARB;
7425 table->LoadTransposeMatrixfARB = save_LoadTransposeMatrixfARB;
7426 table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB;
7427 table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB;
7428
7429 /* ARB 5. GL_ARB_multisample */
7430 table->SampleCoverageARB = save_SampleCoverageARB;
7431
7432 /* ARB 12. GL_ARB_texture_compression */
7433 table->CompressedTexImage3DARB = save_CompressedTexImage3DARB;
7434 table->CompressedTexImage2DARB = save_CompressedTexImage2DARB;
7435 table->CompressedTexImage1DARB = save_CompressedTexImage1DARB;
7436 table->CompressedTexSubImage3DARB = save_CompressedTexSubImage3DARB;
7437 table->CompressedTexSubImage2DARB = save_CompressedTexSubImage2DARB;
7438 table->CompressedTexSubImage1DARB = save_CompressedTexSubImage1DARB;
7439 table->GetCompressedTexImageARB = exec_GetCompressedTexImageARB;
7440
7441 /* ARB 14. GL_ARB_point_parameters */
7442 /* aliased with EXT_point_parameters functions */
7443
7444 /* ARB 25. GL_ARB_window_pos */
7445 /* aliased with MESA_window_pos functions */
7446
7447 /* ARB 26. GL_ARB_vertex_program */
7448 /* ARB 27. GL_ARB_fragment_program */
7449 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
7450 /* glVertexAttrib* functions alias the NV ones, handled elsewhere */
7451 table->VertexAttribPointerARB = _mesa_VertexAttribPointerARB;
7452 table->EnableVertexAttribArrayARB = _mesa_EnableVertexAttribArrayARB;
7453 table->DisableVertexAttribArrayARB = _mesa_DisableVertexAttribArrayARB;
7454 table->ProgramStringARB = save_ProgramStringARB;
7455 table->BindProgramNV = save_BindProgramNV;
7456 table->DeleteProgramsNV = _mesa_DeletePrograms;
7457 table->GenProgramsNV = _mesa_GenPrograms;
7458 table->IsProgramNV = _mesa_IsProgram;
7459 table->GetVertexAttribdvNV = _mesa_GetVertexAttribdvNV;
7460 table->GetVertexAttribfvNV = _mesa_GetVertexAttribfvNV;
7461 table->GetVertexAttribivNV = _mesa_GetVertexAttribivNV;
7462 table->GetVertexAttribPointervNV = _mesa_GetVertexAttribPointervNV;
7463 table->ProgramEnvParameter4dARB = save_ProgramEnvParameter4dARB;
7464 table->ProgramEnvParameter4dvARB = save_ProgramEnvParameter4dvARB;
7465 table->ProgramEnvParameter4fARB = save_ProgramEnvParameter4fARB;
7466 table->ProgramEnvParameter4fvARB = save_ProgramEnvParameter4fvARB;
7467 table->ProgramLocalParameter4dARB = save_ProgramLocalParameter4dARB;
7468 table->ProgramLocalParameter4dvARB = save_ProgramLocalParameter4dvARB;
7469 table->ProgramLocalParameter4fARB = save_ProgramLocalParameter4fARB;
7470 table->ProgramLocalParameter4fvARB = save_ProgramLocalParameter4fvARB;
7471 table->GetProgramEnvParameterdvARB = _mesa_GetProgramEnvParameterdvARB;
7472 table->GetProgramEnvParameterfvARB = _mesa_GetProgramEnvParameterfvARB;
7473 table->GetProgramLocalParameterdvARB = _mesa_GetProgramLocalParameterdvARB;
7474 table->GetProgramLocalParameterfvARB = _mesa_GetProgramLocalParameterfvARB;
7475 table->GetProgramivARB = _mesa_GetProgramivARB;
7476 table->GetProgramStringARB = _mesa_GetProgramStringARB;
7477 #endif
7478
7479 /* ARB 28. GL_ARB_vertex_buffer_object */
7480 #if FEATURE_ARB_vertex_buffer_object
7481 /* None of the extension's functions get compiled */
7482 table->BindBufferARB = _mesa_BindBufferARB;
7483 table->BufferDataARB = _mesa_BufferDataARB;
7484 table->BufferSubDataARB = _mesa_BufferSubDataARB;
7485 table->DeleteBuffersARB = _mesa_DeleteBuffersARB;
7486 table->GenBuffersARB = _mesa_GenBuffersARB;
7487 table->GetBufferParameterivARB = _mesa_GetBufferParameterivARB;
7488 table->GetBufferPointervARB = _mesa_GetBufferPointervARB;
7489 table->GetBufferSubDataARB = _mesa_GetBufferSubDataARB;
7490 table->IsBufferARB = _mesa_IsBufferARB;
7491 table->MapBufferARB = _mesa_MapBufferARB;
7492 table->UnmapBufferARB = _mesa_UnmapBufferARB;
7493 #endif
7494
7495 /* 299. GL_EXT_blend_equation_separate */
7496 table->BlendEquationSeparateEXT = save_BlendEquationSeparateEXT;
7497 }
7498
7499
7500
7501 /***
7502 *** Debugging code
7503 ***/
7504 static const char *enum_string( GLenum k )
7505 {
7506 return _mesa_lookup_enum_by_nr( k );
7507 }
7508
7509
7510 /*
7511 * Print the commands in a display list. For debugging only.
7512 * TODO: many commands aren't handled yet.
7513 */
7514 static void GLAPIENTRY print_list( GLcontext *ctx, GLuint list )
7515 {
7516 Node *n;
7517 GLboolean done;
7518
7519 if (!glIsList(list)) {
7520 _mesa_printf("%u is not a display list ID\n", list);
7521 return;
7522 }
7523
7524 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
7525
7526 _mesa_printf("START-LIST %u, address %p\n", list, (void*)n );
7527
7528 done = n ? GL_FALSE : GL_TRUE;
7529 while (!done) {
7530 OpCode opcode = n[0].opcode;
7531 GLint i = (GLint) n[0].opcode - (GLint) OPCODE_DRV_0;
7532
7533 if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
7534 ctx->listext.opcode[i].print(ctx, &n[1]);
7535 n += ctx->listext.opcode[i].size;
7536 }
7537 else {
7538 switch (opcode) {
7539 case OPCODE_ACCUM:
7540 _mesa_printf("accum %s %g\n", enum_string(n[1].e), n[2].f );
7541 break;
7542 case OPCODE_BITMAP:
7543 _mesa_printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
7544 n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
7545 break;
7546 case OPCODE_CALL_LIST:
7547 _mesa_printf("CallList %d\n", (int) n[1].ui );
7548 break;
7549 case OPCODE_CALL_LIST_OFFSET:
7550 _mesa_printf("CallList %d + offset %u = %u\n", (int) n[1].ui,
7551 ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
7552 break;
7553 case OPCODE_COLOR_TABLE_PARAMETER_FV:
7554 _mesa_printf("ColorTableParameterfv %s %s %f %f %f %f\n",
7555 enum_string(n[1].e), enum_string(n[2].e),
7556 n[3].f, n[4].f, n[5].f, n[6].f);
7557 break;
7558 case OPCODE_COLOR_TABLE_PARAMETER_IV:
7559 _mesa_printf("ColorTableParameteriv %s %s %d %d %d %d\n",
7560 enum_string(n[1].e), enum_string(n[2].e),
7561 n[3].i, n[4].i, n[5].i, n[6].i);
7562 break;
7563 case OPCODE_DISABLE:
7564 _mesa_printf("Disable %s\n", enum_string(n[1].e));
7565 break;
7566 case OPCODE_ENABLE:
7567 _mesa_printf("Enable %s\n", enum_string(n[1].e));
7568 break;
7569 case OPCODE_FRUSTUM:
7570 _mesa_printf("Frustum %g %g %g %g %g %g\n",
7571 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
7572 break;
7573 case OPCODE_LINE_STIPPLE:
7574 _mesa_printf("LineStipple %d %x\n", n[1].i, (int) n[2].us );
7575 break;
7576 case OPCODE_LOAD_IDENTITY:
7577 _mesa_printf("LoadIdentity\n");
7578 break;
7579 case OPCODE_LOAD_MATRIX:
7580 _mesa_printf("LoadMatrix\n");
7581 _mesa_printf(" %8f %8f %8f %8f\n",
7582 n[1].f, n[5].f, n[9].f, n[13].f);
7583 _mesa_printf(" %8f %8f %8f %8f\n",
7584 n[2].f, n[6].f, n[10].f, n[14].f);
7585 _mesa_printf(" %8f %8f %8f %8f\n",
7586 n[3].f, n[7].f, n[11].f, n[15].f);
7587 _mesa_printf(" %8f %8f %8f %8f\n",
7588 n[4].f, n[8].f, n[12].f, n[16].f);
7589 break;
7590 case OPCODE_MULT_MATRIX:
7591 _mesa_printf("MultMatrix (or Rotate)\n");
7592 _mesa_printf(" %8f %8f %8f %8f\n",
7593 n[1].f, n[5].f, n[9].f, n[13].f);
7594 _mesa_printf(" %8f %8f %8f %8f\n",
7595 n[2].f, n[6].f, n[10].f, n[14].f);
7596 _mesa_printf(" %8f %8f %8f %8f\n",
7597 n[3].f, n[7].f, n[11].f, n[15].f);
7598 _mesa_printf(" %8f %8f %8f %8f\n",
7599 n[4].f, n[8].f, n[12].f, n[16].f);
7600 break;
7601 case OPCODE_ORTHO:
7602 _mesa_printf("Ortho %g %g %g %g %g %g\n",
7603 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
7604 break;
7605 case OPCODE_POP_ATTRIB:
7606 _mesa_printf("PopAttrib\n");
7607 break;
7608 case OPCODE_POP_MATRIX:
7609 _mesa_printf("PopMatrix\n");
7610 break;
7611 case OPCODE_POP_NAME:
7612 _mesa_printf("PopName\n");
7613 break;
7614 case OPCODE_PUSH_ATTRIB:
7615 _mesa_printf("PushAttrib %x\n", n[1].bf );
7616 break;
7617 case OPCODE_PUSH_MATRIX:
7618 _mesa_printf("PushMatrix\n");
7619 break;
7620 case OPCODE_PUSH_NAME:
7621 _mesa_printf("PushName %d\n", (int) n[1].ui );
7622 break;
7623 case OPCODE_RASTER_POS:
7624 _mesa_printf("RasterPos %g %g %g %g\n",
7625 n[1].f, n[2].f,n[3].f,n[4].f);
7626 break;
7627 case OPCODE_ROTATE:
7628 _mesa_printf("Rotate %g %g %g %g\n",
7629 n[1].f, n[2].f, n[3].f, n[4].f );
7630 break;
7631 case OPCODE_SCALE:
7632 _mesa_printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
7633 break;
7634 case OPCODE_TRANSLATE:
7635 _mesa_printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
7636 break;
7637 case OPCODE_BIND_TEXTURE:
7638 _mesa_printf("BindTexture %s %d\n",
7639 _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui);
7640 break;
7641 case OPCODE_SHADE_MODEL:
7642 _mesa_printf("ShadeModel %s\n",
7643 _mesa_lookup_enum_by_nr(n[1].ui));
7644 break;
7645 case OPCODE_MAP1:
7646 _mesa_printf("Map1 %s %.3f %.3f %d %d\n",
7647 _mesa_lookup_enum_by_nr(n[1].ui),
7648 n[2].f, n[3].f, n[4].i, n[5].i);
7649 break;
7650 case OPCODE_MAP2:
7651 _mesa_printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
7652 _mesa_lookup_enum_by_nr(n[1].ui),
7653 n[2].f, n[3].f, n[4].f, n[5].f,
7654 n[6].i, n[7].i, n[8].i, n[9].i);
7655 break;
7656 case OPCODE_MAPGRID1:
7657 _mesa_printf("MapGrid1 %d %.3f %.3f\n",
7658 n[1].i, n[2].f, n[3].f);
7659 break;
7660 case OPCODE_MAPGRID2:
7661 _mesa_printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
7662 n[1].i, n[2].f, n[3].f,
7663 n[4].i, n[5].f, n[6].f);
7664 break;
7665 case OPCODE_EVALMESH1:
7666 _mesa_printf("EvalMesh1 %d %d\n", n[1].i, n[2].i);
7667 break;
7668 case OPCODE_EVALMESH2:
7669 _mesa_printf("EvalMesh2 %d %d %d %d\n",
7670 n[1].i, n[2].i, n[3].i, n[4].i);
7671 break;
7672
7673 /*
7674 * meta opcodes/commands
7675 */
7676 case OPCODE_ERROR:
7677 _mesa_printf("Error: %s %s\n",
7678 enum_string(n[1].e), (const char *)n[2].data );
7679 break;
7680 case OPCODE_CONTINUE:
7681 _mesa_printf("DISPLAY-LIST-CONTINUE\n");
7682 n = (Node *) n[1].next;
7683 break;
7684 case OPCODE_END_OF_LIST:
7685 _mesa_printf("END-LIST %u\n", list);
7686 done = GL_TRUE;
7687 break;
7688 default:
7689 if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
7690 _mesa_printf("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
7691 opcode, (void*) n);
7692 return;
7693 }
7694 else {
7695 _mesa_printf("command %d, %u operands\n", opcode, InstSize[opcode]);
7696 }
7697 }
7698 /* increment n to point to next compiled command */
7699 if (opcode!=OPCODE_CONTINUE) {
7700 n += InstSize[opcode];
7701 }
7702 }
7703 }
7704 }
7705
7706
7707
7708 /*
7709 * Clients may call this function to help debug display list problems.
7710 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
7711 * changed, or break in the future without notice.
7712 */
7713 void mesa_print_display_list( GLuint list )
7714 {
7715 GET_CURRENT_CONTEXT(ctx);
7716 print_list( ctx, list );
7717 }
7718
7719
7720 /**********************************************************************/
7721 /***** Initialization *****/
7722 /**********************************************************************/
7723
7724
7725 void _mesa_save_vtxfmt_init( GLvertexformat *vfmt )
7726 {
7727 vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
7728 vfmt->Begin = save_Begin;
7729 vfmt->CallList = _mesa_save_CallList;
7730 vfmt->CallLists = _mesa_save_CallLists;
7731 vfmt->Color3f = save_Color3f;
7732 vfmt->Color3fv = save_Color3fv;
7733 vfmt->Color4f = save_Color4f;
7734 vfmt->Color4fv = save_Color4fv;
7735 vfmt->EdgeFlag = save_EdgeFlag;
7736 vfmt->EdgeFlagv = save_EdgeFlagv;
7737 vfmt->End = save_End;
7738 vfmt->EvalCoord1f = save_EvalCoord1f;
7739 vfmt->EvalCoord1fv = save_EvalCoord1fv;
7740 vfmt->EvalCoord2f = save_EvalCoord2f;
7741 vfmt->EvalCoord2fv = save_EvalCoord2fv;
7742 vfmt->EvalPoint1 = save_EvalPoint1;
7743 vfmt->EvalPoint2 = save_EvalPoint2;
7744 vfmt->FogCoordfEXT = save_FogCoordfEXT;
7745 vfmt->FogCoordfvEXT = save_FogCoordfvEXT;
7746 vfmt->Indexf = save_Indexf;
7747 vfmt->Indexfv = save_Indexfv;
7748 vfmt->Materialfv = save_Materialfv;
7749 vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f;
7750 vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv;
7751 vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f;
7752 vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv;
7753 vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f;
7754 vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv;
7755 vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f;
7756 vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv;
7757 vfmt->Normal3f = save_Normal3f;
7758 vfmt->Normal3fv = save_Normal3fv;
7759 vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT;
7760 vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT;
7761 vfmt->TexCoord1f = save_TexCoord1f;
7762 vfmt->TexCoord1fv = save_TexCoord1fv;
7763 vfmt->TexCoord2f = save_TexCoord2f;
7764 vfmt->TexCoord2fv = save_TexCoord2fv;
7765 vfmt->TexCoord3f = save_TexCoord3f;
7766 vfmt->TexCoord3fv = save_TexCoord3fv;
7767 vfmt->TexCoord4f = save_TexCoord4f;
7768 vfmt->TexCoord4fv = save_TexCoord4fv;
7769 vfmt->Vertex2f = save_Vertex2f;
7770 vfmt->Vertex2fv = save_Vertex2fv;
7771 vfmt->Vertex3f = save_Vertex3f;
7772 vfmt->Vertex3fv = save_Vertex3fv;
7773 vfmt->Vertex4f = save_Vertex4f;
7774 vfmt->Vertex4fv = save_Vertex4fv;
7775 vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV;
7776 vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV;
7777 vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV;
7778 vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV;
7779 vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV;
7780 vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV;
7781 vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV;
7782 vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV;
7783
7784 vfmt->EvalMesh1 = _mesa_save_EvalMesh1;
7785 vfmt->EvalMesh2 = _mesa_save_EvalMesh2;
7786 vfmt->Rectf = save_Rectf;
7787
7788 /* The driver is required to implement these as
7789 * 1) They can probably do a better job.
7790 * 2) A lot of new mechanisms would have to be added to this module
7791 * to support it. That code would probably never get used,
7792 * because of (1).
7793 */
7794 #if 0
7795 vfmt->DrawArrays = 0;
7796 vfmt->DrawElements = 0;
7797 vfmt->DrawRangeElements = 0;
7798 #endif
7799 }
7800
7801
7802
7803 void _mesa_init_display_list( GLcontext * ctx )
7804 {
7805 /* Display list */
7806 ctx->ListState.CallDepth = 0;
7807 ctx->ExecuteFlag = GL_TRUE;
7808 ctx->CompileFlag = GL_FALSE;
7809 ctx->ListState.CurrentListPtr = NULL;
7810 ctx->ListState.CurrentBlock = NULL;
7811 ctx->ListState.CurrentListNum = 0;
7812 ctx->ListState.CurrentPos = 0;
7813
7814 /* Display List group */
7815 ctx->List.ListBase = 0;
7816
7817 _mesa_save_vtxfmt_init( &ctx->ListState.ListVtxfmt );
7818 }