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