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