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