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