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