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