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