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