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