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