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