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