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