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