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