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