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