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