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