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