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