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