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