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