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