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