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