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