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