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