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