glBegin/EndQueryARB didn't work inside display lists
[mesa.git] / src / mesa / main / dlist.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.1
4 *
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 /**
27 * \file dlist.c
28 * Display lists management functions.
29 */
30
31 #include "glheader.h"
32 #include "imports.h"
33 #include "api_arrayelt.h"
34 #include "api_loopback.h"
35 #include "config.h"
36 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
37 #include "arbprogram.h"
38 #include "program.h"
39 #endif
40 #include "attrib.h"
41 #include "blend.h"
42 #include "buffers.h"
43 #if FEATURE_ARB_vertex_buffer_object
44 #include "bufferobj.h"
45 #endif
46 #include "clip.h"
47 #include "colormac.h"
48 #include "colortab.h"
49 #include "context.h"
50 #include "convolve.h"
51 #include "depth.h"
52 #include "dlist.h"
53 #include "enable.h"
54 #include "enums.h"
55 #include "eval.h"
56 #include "extensions.h"
57 #include "feedback.h"
58 #include "get.h"
59 #include "glapi.h"
60 #include "hash.h"
61 #include "histogram.h"
62 #include "image.h"
63 #include "light.h"
64 #include "lines.h"
65 #include "dlist.h"
66 #include "macros.h"
67 #include "matrix.h"
68 #include "occlude.h"
69 #include "pixel.h"
70 #include "points.h"
71 #include "polygon.h"
72 #include "state.h"
73 #include "texobj.h"
74 #include "teximage.h"
75 #include "texstate.h"
76 #include "mtypes.h"
77 #include "varray.h"
78 #if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
79 #include "nvprogram.h"
80 #include "program.h"
81 #endif
82
83 #include "math/m_matrix.h"
84 #include "math/m_xform.h"
85
86
87 /**
88 * Flush vertices.
89 *
90 * \param ctx GL context.
91 *
92 * Checks if dd_function_table::SaveNeedFlush is marked to flush
93 * stored (save) vertices, and calls
94 * dd_function_table::SaveFlushVertices if so.
95 */
96 #define SAVE_FLUSH_VERTICES(ctx) \
97 do { \
98 if (ctx->Driver.SaveNeedFlush) \
99 ctx->Driver.SaveFlushVertices(ctx); \
100 } while (0)
101
102
103 /**
104 * Macro to assert that the API call was made outside the
105 * glBegin()/glEnd() pair, with return value.
106 *
107 * \param ctx GL context.
108 * \param retval value to return value in case the assertion fails.
109 */
110 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \
111 do { \
112 if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \
113 ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
114 _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
115 return retval; \
116 } \
117 } while (0)
118
119 /**
120 * Macro to assert that the API call was made outside the
121 * glBegin()/glEnd() pair.
122 *
123 * \param ctx GL context.
124 */
125 #define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx) \
126 do { \
127 if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \
128 ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
129 _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
130 return; \
131 } \
132 } while (0)
133
134 /**
135 * Macro to assert that the API call was made outside the
136 * glBegin()/glEnd() pair and flush the vertices.
137 *
138 * \param ctx GL context.
139 */
140 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \
141 do { \
142 ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \
143 SAVE_FLUSH_VERTICES(ctx); \
144 } while (0)
145
146 /**
147 * Macro to assert that the API call was made outside the
148 * glBegin()/glEnd() pair and flush the vertices, with return value.
149 *
150 * \param ctx GL context.
151 * \param retval value to return value in case the assertion fails.
152 */
153 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\
154 do { \
155 ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \
156 SAVE_FLUSH_VERTICES(ctx); \
157 } while (0)
158
159
160
161 /**
162 * Display list opcodes.
163 *
164 * The fact that these identifiers are assigned consecutive
165 * integer values starting at 0 is very important, see InstSize array usage)
166 */
167 typedef enum {
168 OPCODE_ACCUM,
169 OPCODE_ALPHA_FUNC,
170 OPCODE_BIND_TEXTURE,
171 OPCODE_BITMAP,
172 OPCODE_BLEND_COLOR,
173 OPCODE_BLEND_EQUATION,
174 OPCODE_BLEND_EQUATION_SEPARATE,
175 OPCODE_BLEND_FUNC_SEPARATE,
176 OPCODE_CALL_LIST,
177 OPCODE_CALL_LIST_OFFSET,
178 OPCODE_CLEAR,
179 OPCODE_CLEAR_ACCUM,
180 OPCODE_CLEAR_COLOR,
181 OPCODE_CLEAR_DEPTH,
182 OPCODE_CLEAR_INDEX,
183 OPCODE_CLEAR_STENCIL,
184 OPCODE_CLIP_PLANE,
185 OPCODE_COLOR_MASK,
186 OPCODE_COLOR_MATERIAL,
187 OPCODE_COLOR_TABLE,
188 OPCODE_COLOR_TABLE_PARAMETER_FV,
189 OPCODE_COLOR_TABLE_PARAMETER_IV,
190 OPCODE_COLOR_SUB_TABLE,
191 OPCODE_CONVOLUTION_FILTER_1D,
192 OPCODE_CONVOLUTION_FILTER_2D,
193 OPCODE_CONVOLUTION_PARAMETER_I,
194 OPCODE_CONVOLUTION_PARAMETER_IV,
195 OPCODE_CONVOLUTION_PARAMETER_F,
196 OPCODE_CONVOLUTION_PARAMETER_FV,
197 OPCODE_COPY_COLOR_SUB_TABLE,
198 OPCODE_COPY_COLOR_TABLE,
199 OPCODE_COPY_PIXELS,
200 OPCODE_COPY_TEX_IMAGE1D,
201 OPCODE_COPY_TEX_IMAGE2D,
202 OPCODE_COPY_TEX_SUB_IMAGE1D,
203 OPCODE_COPY_TEX_SUB_IMAGE2D,
204 OPCODE_COPY_TEX_SUB_IMAGE3D,
205 OPCODE_CULL_FACE,
206 OPCODE_DEPTH_FUNC,
207 OPCODE_DEPTH_MASK,
208 OPCODE_DEPTH_RANGE,
209 OPCODE_DISABLE,
210 OPCODE_DRAW_BUFFER,
211 OPCODE_DRAW_PIXELS,
212 OPCODE_ENABLE,
213 OPCODE_EVALMESH1,
214 OPCODE_EVALMESH2,
215 OPCODE_FOG,
216 OPCODE_FRONT_FACE,
217 OPCODE_FRUSTUM,
218 OPCODE_HINT,
219 OPCODE_HISTOGRAM,
220 OPCODE_INDEX_MASK,
221 OPCODE_INIT_NAMES,
222 OPCODE_LIGHT,
223 OPCODE_LIGHT_MODEL,
224 OPCODE_LINE_STIPPLE,
225 OPCODE_LINE_WIDTH,
226 OPCODE_LIST_BASE,
227 OPCODE_LOAD_IDENTITY,
228 OPCODE_LOAD_MATRIX,
229 OPCODE_LOAD_NAME,
230 OPCODE_LOGIC_OP,
231 OPCODE_MAP1,
232 OPCODE_MAP2,
233 OPCODE_MAPGRID1,
234 OPCODE_MAPGRID2,
235 OPCODE_MATRIX_MODE,
236 OPCODE_MIN_MAX,
237 OPCODE_MULT_MATRIX,
238 OPCODE_ORTHO,
239 OPCODE_PASSTHROUGH,
240 OPCODE_PIXEL_MAP,
241 OPCODE_PIXEL_TRANSFER,
242 OPCODE_PIXEL_ZOOM,
243 OPCODE_POINT_SIZE,
244 OPCODE_POINT_PARAMETERS,
245 OPCODE_POLYGON_MODE,
246 OPCODE_POLYGON_STIPPLE,
247 OPCODE_POLYGON_OFFSET,
248 OPCODE_POP_ATTRIB,
249 OPCODE_POP_MATRIX,
250 OPCODE_POP_NAME,
251 OPCODE_PRIORITIZE_TEXTURE,
252 OPCODE_PUSH_ATTRIB,
253 OPCODE_PUSH_MATRIX,
254 OPCODE_PUSH_NAME,
255 OPCODE_RASTER_POS,
256 OPCODE_READ_BUFFER,
257 OPCODE_RESET_HISTOGRAM,
258 OPCODE_RESET_MIN_MAX,
259 OPCODE_ROTATE,
260 OPCODE_SCALE,
261 OPCODE_SCISSOR,
262 OPCODE_SELECT_TEXTURE_SGIS,
263 OPCODE_SELECT_TEXTURE_COORD_SET,
264 OPCODE_SHADE_MODEL,
265 OPCODE_STENCIL_FUNC,
266 OPCODE_STENCIL_MASK,
267 OPCODE_STENCIL_OP,
268 OPCODE_TEXENV,
269 OPCODE_TEXGEN,
270 OPCODE_TEXPARAMETER,
271 OPCODE_TEX_IMAGE1D,
272 OPCODE_TEX_IMAGE2D,
273 OPCODE_TEX_IMAGE3D,
274 OPCODE_TEX_SUB_IMAGE1D,
275 OPCODE_TEX_SUB_IMAGE2D,
276 OPCODE_TEX_SUB_IMAGE3D,
277 OPCODE_TRANSLATE,
278 OPCODE_VIEWPORT,
279 OPCODE_WINDOW_POS,
280 /* GL_ARB_multitexture */
281 OPCODE_ACTIVE_TEXTURE,
282 /* GL_SGIX/SGIS_pixel_texture */
283 OPCODE_PIXEL_TEXGEN_SGIX,
284 OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS,
285 /* GL_ARB_texture_compression */
286 OPCODE_COMPRESSED_TEX_IMAGE_1D,
287 OPCODE_COMPRESSED_TEX_IMAGE_2D,
288 OPCODE_COMPRESSED_TEX_IMAGE_3D,
289 OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
290 OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
291 OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
292 /* GL_ARB_multisample */
293 OPCODE_SAMPLE_COVERAGE,
294 /* GL_ARB_window_pos */
295 OPCODE_WINDOW_POS_ARB,
296 /* GL_NV_vertex_program */
297 OPCODE_BIND_PROGRAM_NV,
298 OPCODE_EXECUTE_PROGRAM_NV,
299 OPCODE_REQUEST_RESIDENT_PROGRAMS_NV,
300 OPCODE_LOAD_PROGRAM_NV,
301 OPCODE_PROGRAM_PARAMETER4F_NV,
302 OPCODE_TRACK_MATRIX_NV,
303 /* GL_NV_fragment_program */
304 OPCODE_PROGRAM_LOCAL_PARAMETER_ARB,
305 OPCODE_PROGRAM_NAMED_PARAMETER_NV,
306 /* GL_EXT_stencil_two_side */
307 OPCODE_ACTIVE_STENCIL_FACE_EXT,
308 /* GL_EXT_depth_bounds_test */
309 OPCODE_DEPTH_BOUNDS_EXT,
310 /* GL_ARB_vertex/fragment_program */
311 OPCODE_PROGRAM_STRING_ARB,
312 OPCODE_PROGRAM_ENV_PARAMETER_ARB,
313 /* GL_ARB_occlusion_query */
314 OPCODE_BEGIN_QUERY_ARB,
315 OPCODE_END_QUERY_ARB,
316
317 /* Vertex attributes -- fallback for when optimized display
318 * list build isn't active.
319 */
320 OPCODE_ATTR_1F,
321 OPCODE_ATTR_2F,
322 OPCODE_ATTR_3F,
323 OPCODE_ATTR_4F,
324 OPCODE_MATERIAL,
325 OPCODE_INDEX,
326 OPCODE_EDGEFLAG,
327 OPCODE_BEGIN,
328 OPCODE_END,
329 OPCODE_RECTF,
330 OPCODE_EVAL_C1,
331 OPCODE_EVAL_C2,
332 OPCODE_EVAL_P1,
333 OPCODE_EVAL_P2,
334
335
336 /* The following three are meta instructions */
337 OPCODE_ERROR, /* raise compiled-in error */
338 OPCODE_CONTINUE,
339 OPCODE_END_OF_LIST,
340 OPCODE_EXT_0
341 } OpCode;
342
343
344
345 /**
346 * Display list node.
347 *
348 * Display list instructions are stored as sequences of "nodes". Nodes
349 * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
350 * are linked together with a pointer.
351 *
352 * Each instruction in the display list is stored as a sequence of
353 * contiguous nodes in memory.
354 * Each node is the union of a variety of data types.
355 */
356 union node {
357 OpCode opcode;
358 GLboolean b;
359 GLbitfield bf;
360 GLubyte ub;
361 GLshort s;
362 GLushort us;
363 GLint i;
364 GLuint ui;
365 GLenum e;
366 GLfloat f;
367 GLvoid *data;
368 void *next; /* If prev node's opcode==OPCODE_CONTINUE */
369 };
370
371
372 /**
373 * How many nodes to allocate at a time.
374 *
375 * \note Reduced now that we hold vertices etc. elsewhere.
376 */
377 #define BLOCK_SIZE 256
378
379
380
381 /**
382 * Number of nodes of storage needed for each instruction.
383 * Sizes for dynamically allocated opcodes are stored in the context struct.
384 */
385 static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
386
387 void mesa_print_display_list( GLuint list );
388
389
390 /**********************************************************************/
391 /***** Private *****/
392 /**********************************************************************/
393
394 /*
395 * Make an empty display list. This is used by glGenLists() to
396 * reserver display list IDs.
397 */
398 static Node *make_empty_list( void )
399 {
400 Node *n = (Node *) MALLOC( sizeof(Node) );
401 n[0].opcode = OPCODE_END_OF_LIST;
402 return n;
403 }
404
405
406
407 /*
408 * Destroy all nodes in a display list.
409 * \param list - display list number
410 */
411 void _mesa_destroy_list( GLcontext *ctx, GLuint list )
412 {
413 Node *n, *block;
414 GLboolean done;
415
416 if (list==0)
417 return;
418
419 block = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
420 n = block;
421
422 done = block ? GL_FALSE : GL_TRUE;
423 while (!done) {
424
425 /* check for extension opcodes first */
426
427 GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
428 if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
429 ctx->ListExt.Opcode[i].Destroy(ctx, &n[1]);
430 n += ctx->ListExt.Opcode[i].Size;
431 }
432 else {
433 switch (n[0].opcode) {
434 /* for some commands, we need to free malloc'd memory */
435 case OPCODE_MAP1:
436 FREE(n[6].data);
437 n += InstSize[n[0].opcode];
438 break;
439 case OPCODE_MAP2:
440 FREE(n[10].data);
441 n += InstSize[n[0].opcode];
442 break;
443 case OPCODE_DRAW_PIXELS:
444 FREE( n[5].data );
445 n += InstSize[n[0].opcode];
446 break;
447 case OPCODE_BITMAP:
448 FREE( n[7].data );
449 n += InstSize[n[0].opcode];
450 break;
451 case OPCODE_COLOR_TABLE:
452 FREE( n[6].data );
453 n += InstSize[n[0].opcode];
454 break;
455 case OPCODE_COLOR_SUB_TABLE:
456 FREE( n[6].data );
457 n += InstSize[n[0].opcode];
458 break;
459 case OPCODE_CONVOLUTION_FILTER_1D:
460 FREE( n[6].data );
461 n += InstSize[n[0].opcode];
462 break;
463 case OPCODE_CONVOLUTION_FILTER_2D:
464 FREE( n[7].data );
465 n += InstSize[n[0].opcode];
466 break;
467 case OPCODE_POLYGON_STIPPLE:
468 FREE( n[1].data );
469 n += InstSize[n[0].opcode];
470 break;
471 case OPCODE_TEX_IMAGE1D:
472 FREE(n[8].data);
473 n += InstSize[n[0].opcode];
474 break;
475 case OPCODE_TEX_IMAGE2D:
476 FREE( n[9]. data );
477 n += InstSize[n[0].opcode];
478 break;
479 case OPCODE_TEX_IMAGE3D:
480 FREE( n[10]. data );
481 n += InstSize[n[0].opcode];
482 break;
483 case OPCODE_TEX_SUB_IMAGE1D:
484 FREE(n[7].data);
485 n += InstSize[n[0].opcode];
486 break;
487 case OPCODE_TEX_SUB_IMAGE2D:
488 FREE(n[9].data);
489 n += InstSize[n[0].opcode];
490 break;
491 case OPCODE_TEX_SUB_IMAGE3D:
492 FREE(n[11].data);
493 n += InstSize[n[0].opcode];
494 break;
495 case OPCODE_COMPRESSED_TEX_IMAGE_1D:
496 FREE(n[7].data);
497 n += InstSize[n[0].opcode];
498 break;
499 case OPCODE_COMPRESSED_TEX_IMAGE_2D:
500 FREE(n[8].data);
501 n += InstSize[n[0].opcode];
502 break;
503 case OPCODE_COMPRESSED_TEX_IMAGE_3D:
504 FREE(n[9].data);
505 n += InstSize[n[0].opcode];
506 break;
507 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:
508 FREE(n[7].data);
509 n += InstSize[n[0].opcode];
510 break;
511 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:
512 FREE(n[9].data);
513 n += InstSize[n[0].opcode];
514 break;
515 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:
516 FREE(n[11].data);
517 n += InstSize[n[0].opcode];
518 break;
519 #if FEATURE_NV_vertex_program
520 case OPCODE_LOAD_PROGRAM_NV:
521 FREE(n[4].data); /* program string */
522 n += InstSize[n[0].opcode];
523 break;
524 case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
525 FREE(n[2].data); /* array of program ids */
526 n += InstSize[n[0].opcode];
527 break;
528 #endif
529 #if FEATURE_NV_fragment_program
530 case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
531 FREE(n[3].data); /* parameter name */
532 n += InstSize[n[0].opcode];
533 break;
534 #endif
535 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
536 case OPCODE_PROGRAM_STRING_ARB:
537 FREE(n[4].data); /* program string */
538 n += InstSize[n[0].opcode];
539 break;
540 #endif
541 case OPCODE_CONTINUE:
542 n = (Node *) n[1].next;
543 FREE( block );
544 block = n;
545 break;
546 case OPCODE_END_OF_LIST:
547 FREE( block );
548 done = GL_TRUE;
549 break;
550 default:
551 /* Most frequent case */
552 n += InstSize[n[0].opcode];
553 break;
554 }
555 }
556 }
557
558 _mesa_HashRemove(ctx->Shared->DisplayList, list);
559 }
560
561
562
563 /*
564 * Translate the nth element of list from type to GLuint.
565 */
566 static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
567 {
568 GLbyte *bptr;
569 GLubyte *ubptr;
570 GLshort *sptr;
571 GLushort *usptr;
572 GLint *iptr;
573 GLuint *uiptr;
574 GLfloat *fptr;
575
576 switch (type) {
577 case GL_BYTE:
578 bptr = (GLbyte *) list;
579 return (GLuint) *(bptr+n);
580 case GL_UNSIGNED_BYTE:
581 ubptr = (GLubyte *) list;
582 return (GLuint) *(ubptr+n);
583 case GL_SHORT:
584 sptr = (GLshort *) list;
585 return (GLuint) *(sptr+n);
586 case GL_UNSIGNED_SHORT:
587 usptr = (GLushort *) list;
588 return (GLuint) *(usptr+n);
589 case GL_INT:
590 iptr = (GLint *) list;
591 return (GLuint) *(iptr+n);
592 case GL_UNSIGNED_INT:
593 uiptr = (GLuint *) list;
594 return (GLuint) *(uiptr+n);
595 case GL_FLOAT:
596 fptr = (GLfloat *) list;
597 return (GLuint) *(fptr+n);
598 case GL_2_BYTES:
599 ubptr = ((GLubyte *) list) + 2*n;
600 return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
601 case GL_3_BYTES:
602 ubptr = ((GLubyte *) list) + 3*n;
603 return (GLuint) *ubptr * 65536
604 + (GLuint) *(ubptr+1) * 256
605 + (GLuint) *(ubptr+2);
606 case GL_4_BYTES:
607 ubptr = ((GLubyte *) list) + 4*n;
608 return (GLuint) *ubptr * 16777216
609 + (GLuint) *(ubptr+1) * 65536
610 + (GLuint) *(ubptr+2) * 256
611 + (GLuint) *(ubptr+3);
612 default:
613 return 0;
614 }
615 }
616
617
618
619
620 /**********************************************************************/
621 /***** Public *****/
622 /**********************************************************************/
623
624 /**
625 * Do one-time initialiazations for display lists.
626 */
627 void
628 _mesa_init_lists( void )
629 {
630 static int init_flag = 0;
631
632 if (init_flag==0) {
633 InstSize[OPCODE_ACCUM] = 3;
634 InstSize[OPCODE_ALPHA_FUNC] = 3;
635 InstSize[OPCODE_BIND_TEXTURE] = 3;
636 InstSize[OPCODE_BITMAP] = 8;
637 InstSize[OPCODE_BLEND_COLOR] = 5;
638 InstSize[OPCODE_BLEND_EQUATION] = 2;
639 InstSize[OPCODE_BLEND_EQUATION_SEPARATE] = 3;
640 InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5;
641 InstSize[OPCODE_CALL_LIST] = 2;
642 InstSize[OPCODE_CALL_LIST_OFFSET] = 3;
643 InstSize[OPCODE_CLEAR] = 2;
644 InstSize[OPCODE_CLEAR_ACCUM] = 5;
645 InstSize[OPCODE_CLEAR_COLOR] = 5;
646 InstSize[OPCODE_CLEAR_DEPTH] = 2;
647 InstSize[OPCODE_CLEAR_INDEX] = 2;
648 InstSize[OPCODE_CLEAR_STENCIL] = 2;
649 InstSize[OPCODE_CLIP_PLANE] = 6;
650 InstSize[OPCODE_COLOR_MASK] = 5;
651 InstSize[OPCODE_COLOR_MATERIAL] = 3;
652 InstSize[OPCODE_COLOR_TABLE] = 7;
653 InstSize[OPCODE_COLOR_TABLE_PARAMETER_FV] = 7;
654 InstSize[OPCODE_COLOR_TABLE_PARAMETER_IV] = 7;
655 InstSize[OPCODE_COLOR_SUB_TABLE] = 7;
656 InstSize[OPCODE_CONVOLUTION_FILTER_1D] = 7;
657 InstSize[OPCODE_CONVOLUTION_FILTER_2D] = 8;
658 InstSize[OPCODE_CONVOLUTION_PARAMETER_I] = 4;
659 InstSize[OPCODE_CONVOLUTION_PARAMETER_IV] = 7;
660 InstSize[OPCODE_CONVOLUTION_PARAMETER_F] = 4;
661 InstSize[OPCODE_CONVOLUTION_PARAMETER_FV] = 7;
662 InstSize[OPCODE_COPY_PIXELS] = 6;
663 InstSize[OPCODE_COPY_COLOR_SUB_TABLE] = 6;
664 InstSize[OPCODE_COPY_COLOR_TABLE] = 6;
665 InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8;
666 InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9;
667 InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7;
668 InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
669 InstSize[OPCODE_COPY_TEX_SUB_IMAGE3D] = 10;
670 InstSize[OPCODE_CULL_FACE] = 2;
671 InstSize[OPCODE_DEPTH_FUNC] = 2;
672 InstSize[OPCODE_DEPTH_MASK] = 2;
673 InstSize[OPCODE_DEPTH_RANGE] = 3;
674 InstSize[OPCODE_DISABLE] = 2;
675 InstSize[OPCODE_DRAW_BUFFER] = 2;
676 InstSize[OPCODE_DRAW_PIXELS] = 6;
677 InstSize[OPCODE_ENABLE] = 2;
678 InstSize[OPCODE_EVALMESH1] = 4;
679 InstSize[OPCODE_EVALMESH2] = 6;
680 InstSize[OPCODE_FOG] = 6;
681 InstSize[OPCODE_FRONT_FACE] = 2;
682 InstSize[OPCODE_FRUSTUM] = 7;
683 InstSize[OPCODE_HINT] = 3;
684 InstSize[OPCODE_HISTOGRAM] = 5;
685 InstSize[OPCODE_INDEX_MASK] = 2;
686 InstSize[OPCODE_INIT_NAMES] = 1;
687 InstSize[OPCODE_LIGHT] = 7;
688 InstSize[OPCODE_LIGHT_MODEL] = 6;
689 InstSize[OPCODE_LINE_STIPPLE] = 3;
690 InstSize[OPCODE_LINE_WIDTH] = 2;
691 InstSize[OPCODE_LIST_BASE] = 2;
692 InstSize[OPCODE_LOAD_IDENTITY] = 1;
693 InstSize[OPCODE_LOAD_MATRIX] = 17;
694 InstSize[OPCODE_LOAD_NAME] = 2;
695 InstSize[OPCODE_LOGIC_OP] = 2;
696 InstSize[OPCODE_MAP1] = 7;
697 InstSize[OPCODE_MAP2] = 11;
698 InstSize[OPCODE_MAPGRID1] = 4;
699 InstSize[OPCODE_MAPGRID2] = 7;
700 InstSize[OPCODE_MATRIX_MODE] = 2;
701 InstSize[OPCODE_MIN_MAX] = 4;
702 InstSize[OPCODE_MULT_MATRIX] = 17;
703 InstSize[OPCODE_ORTHO] = 7;
704 InstSize[OPCODE_PASSTHROUGH] = 2;
705 InstSize[OPCODE_PIXEL_MAP] = 4;
706 InstSize[OPCODE_PIXEL_TRANSFER] = 3;
707 InstSize[OPCODE_PIXEL_ZOOM] = 3;
708 InstSize[OPCODE_POINT_SIZE] = 2;
709 InstSize[OPCODE_POINT_PARAMETERS] = 5;
710 InstSize[OPCODE_POLYGON_MODE] = 3;
711 InstSize[OPCODE_POLYGON_STIPPLE] = 2;
712 InstSize[OPCODE_POLYGON_OFFSET] = 3;
713 InstSize[OPCODE_POP_ATTRIB] = 1;
714 InstSize[OPCODE_POP_MATRIX] = 1;
715 InstSize[OPCODE_POP_NAME] = 1;
716 InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
717 InstSize[OPCODE_PUSH_ATTRIB] = 2;
718 InstSize[OPCODE_PUSH_MATRIX] = 1;
719 InstSize[OPCODE_PUSH_NAME] = 2;
720 InstSize[OPCODE_RASTER_POS] = 5;
721 InstSize[OPCODE_READ_BUFFER] = 2;
722 InstSize[OPCODE_RESET_HISTOGRAM] = 2;
723 InstSize[OPCODE_RESET_MIN_MAX] = 2;
724 InstSize[OPCODE_ROTATE] = 5;
725 InstSize[OPCODE_SCALE] = 4;
726 InstSize[OPCODE_SCISSOR] = 5;
727 InstSize[OPCODE_STENCIL_FUNC] = 4;
728 InstSize[OPCODE_STENCIL_MASK] = 2;
729 InstSize[OPCODE_STENCIL_OP] = 4;
730 InstSize[OPCODE_SHADE_MODEL] = 2;
731 InstSize[OPCODE_TEXENV] = 7;
732 InstSize[OPCODE_TEXGEN] = 7;
733 InstSize[OPCODE_TEXPARAMETER] = 7;
734 InstSize[OPCODE_TEX_IMAGE1D] = 9;
735 InstSize[OPCODE_TEX_IMAGE2D] = 10;
736 InstSize[OPCODE_TEX_IMAGE3D] = 11;
737 InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
738 InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
739 InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12;
740 InstSize[OPCODE_TRANSLATE] = 4;
741 InstSize[OPCODE_VIEWPORT] = 5;
742 InstSize[OPCODE_WINDOW_POS] = 5;
743 InstSize[OPCODE_CONTINUE] = 2;
744 InstSize[OPCODE_ERROR] = 3;
745 InstSize[OPCODE_END_OF_LIST] = 1;
746 /* GL_SGIX/SGIS_pixel_texture */
747 InstSize[OPCODE_PIXEL_TEXGEN_SGIX] = 2;
748 InstSize[OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS] = 3;
749 /* GL_ARB_texture_compression */
750 InstSize[OPCODE_COMPRESSED_TEX_IMAGE_1D] = 8;
751 InstSize[OPCODE_COMPRESSED_TEX_IMAGE_2D] = 9;
752 InstSize[OPCODE_COMPRESSED_TEX_IMAGE_3D] = 10;
753 InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D] = 8;
754 InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D] = 10;
755 InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D] = 12;
756 /* GL_ARB_multisample */
757 InstSize[OPCODE_SAMPLE_COVERAGE] = 3;
758 /* GL_ARB_multitexture */
759 InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
760 /* GL_ARB_window_pos */
761 InstSize[OPCODE_WINDOW_POS_ARB] = 4;
762 /* GL_NV_vertex_program */
763 InstSize[OPCODE_BIND_PROGRAM_NV] = 3;
764 InstSize[OPCODE_EXECUTE_PROGRAM_NV] = 7;
765 InstSize[OPCODE_REQUEST_RESIDENT_PROGRAMS_NV] = 2;
766 InstSize[OPCODE_LOAD_PROGRAM_NV] = 5;
767 InstSize[OPCODE_PROGRAM_PARAMETER4F_NV] = 7;
768 InstSize[OPCODE_TRACK_MATRIX_NV] = 5;
769 /* GL_NV_fragment_program */
770 InstSize[OPCODE_PROGRAM_LOCAL_PARAMETER_ARB] = 7;
771 InstSize[OPCODE_PROGRAM_NAMED_PARAMETER_NV] = 8;
772 /* GL_EXT_stencil_two_side */
773 InstSize[OPCODE_ACTIVE_STENCIL_FACE_EXT] = 2;
774 /* GL_EXT_depth_bounds_test */
775 InstSize[OPCODE_DEPTH_BOUNDS_EXT] = 3;
776 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
777 InstSize[OPCODE_PROGRAM_STRING_ARB] = 5;
778 InstSize[OPCODE_PROGRAM_ENV_PARAMETER_ARB] = 7;
779 #endif
780 #if FEATURE_ARB_occlusion_query
781 InstSize[OPCODE_BEGIN_QUERY_ARB] = 3;
782 InstSize[OPCODE_END_QUERY_ARB] = 2;
783 #endif
784 InstSize[OPCODE_ATTR_1F] = 3;
785 InstSize[OPCODE_ATTR_2F] = 4;
786 InstSize[OPCODE_ATTR_3F] = 5;
787 InstSize[OPCODE_ATTR_4F] = 6;
788 InstSize[OPCODE_MATERIAL] = 7;
789 InstSize[OPCODE_INDEX] = 2;
790 InstSize[OPCODE_EDGEFLAG] = 2;
791 InstSize[OPCODE_BEGIN] = 2;
792 InstSize[OPCODE_END] = 1;
793 InstSize[OPCODE_RECTF] = 5;
794 InstSize[OPCODE_EVAL_C1] = 2;
795 InstSize[OPCODE_EVAL_C2] = 3;
796 InstSize[OPCODE_EVAL_P1] = 2;
797 InstSize[OPCODE_EVAL_P2] = 3;
798 }
799 init_flag = 1;
800 }
801
802
803
804 /**
805 * Wrapper for _mesa_unpack_image() that handles pixel buffer objects.
806 * \todo This won't suffice when the PBO is really in VRAM/GPU memory.
807 */
808 static GLvoid *
809 unpack_image( GLsizei width, GLsizei height, GLsizei depth,
810 GLenum format, GLenum type, const GLvoid *pixels,
811 const struct gl_pixelstore_attrib *unpack )
812 {
813 if (unpack->BufferObj->Name == 0) {
814 /* no PBO */
815 return _mesa_unpack_image(width, height, depth, format, type,
816 pixels, unpack);
817 }
818 else if (_mesa_validate_pbo_access(unpack, width, height, depth, format,
819 type, pixels)) {
820 const GLubyte *src = ADD_POINTERS(unpack->BufferObj->Data, pixels);
821 return _mesa_unpack_image(width, height, depth, format, type,
822 src, unpack);
823 }
824 /* bad access! */
825 return NULL;
826 }
827
828
829 /*
830 * Allocate space for a display list instruction.
831 * \param opcode - type of instruction
832 * argcount - size in bytes of data required.
833 * \return pointer to the usable data area (not including the internal
834 * opcode).
835 */
836 void *
837 _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
838 {
839 Node *n, *newblock;
840 GLuint count = 1 + (sz + sizeof(Node) - 1) / sizeof(Node);
841
842 #ifdef DEBUG
843 if (opcode < (int) OPCODE_EXT_0) {
844 assert( count == InstSize[opcode] );
845 }
846 #endif
847
848 if (ctx->ListState.CurrentPos + count + 2 > BLOCK_SIZE) {
849 /* This block is full. Allocate a new block and chain to it */
850 n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
851 n[0].opcode = OPCODE_CONTINUE;
852 newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
853 if (!newblock) {
854 _mesa_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
855 return NULL;
856 }
857 n[1].next = (Node *) newblock;
858 ctx->ListState.CurrentBlock = newblock;
859 ctx->ListState.CurrentPos = 0;
860 }
861
862 n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
863 ctx->ListState.CurrentPos += count;
864
865 n[0].opcode = (OpCode) opcode;
866
867 return (void *)&n[1];
868 }
869
870
871 /**
872 * This function allows modules and drivers to get their own opcodes
873 * for extending display list functionality.
874 * \param ctx the rendering context
875 * \param size number of bytes for storing the new display list command
876 * \param execute function to execute the new display list command
877 * \param destroy function to destroy the new display list command
878 * \param print function to print the new display list command
879 * \return the new opcode number or -1 if error
880 */
881 GLint
882 _mesa_alloc_opcode( GLcontext *ctx,
883 GLuint size,
884 void (*execute)( GLcontext *, void * ),
885 void (*destroy)( GLcontext *, void * ),
886 void (*print)( GLcontext *, void * ) )
887 {
888 if (ctx->ListExt.NumOpcodes < MAX_DLIST_EXT_OPCODES) {
889 const GLuint i = ctx->ListExt.NumOpcodes++;
890 ctx->ListExt.Opcode[i].Size = 1 + (size + sizeof(Node) - 1)/sizeof(Node);
891 ctx->ListExt.Opcode[i].Execute = execute;
892 ctx->ListExt.Opcode[i].Destroy = destroy;
893 ctx->ListExt.Opcode[i].Print = print;
894 return i + OPCODE_EXT_0;
895 }
896 return -1;
897 }
898
899
900
901 /* Mimic the old behaviour of alloc_instruction:
902 * - sz is in units of sizeof(Node)
903 * - return value a pointer to sizeof(Node) before the actual
904 * usable data area.
905 */
906 #define ALLOC_INSTRUCTION(ctx, opcode, sz) \
907 ((Node *)_mesa_alloc_instruction(ctx, opcode, sz*sizeof(Node)) - 1)
908
909
910
911 /*
912 * Display List compilation functions
913 */
914 static void GLAPIENTRY save_Accum( GLenum op, GLfloat value )
915 {
916 GET_CURRENT_CONTEXT(ctx);
917 Node *n;
918 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
919 n = ALLOC_INSTRUCTION( ctx, OPCODE_ACCUM, 2 );
920 if (n) {
921 n[1].e = op;
922 n[2].f = value;
923 }
924 if (ctx->ExecuteFlag) {
925 (*ctx->Exec->Accum)( op, value );
926 }
927 }
928
929
930 static void GLAPIENTRY save_AlphaFunc( GLenum func, GLclampf ref )
931 {
932 GET_CURRENT_CONTEXT(ctx);
933 Node *n;
934 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
935 n = ALLOC_INSTRUCTION( ctx, OPCODE_ALPHA_FUNC, 2 );
936 if (n) {
937 n[1].e = func;
938 n[2].f = (GLfloat) ref;
939 }
940 if (ctx->ExecuteFlag) {
941 (*ctx->Exec->AlphaFunc)( func, ref );
942 }
943 }
944
945
946 static void GLAPIENTRY save_BindTexture( GLenum target, GLuint texture )
947 {
948 GET_CURRENT_CONTEXT(ctx);
949 Node *n;
950 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
951 n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_TEXTURE, 2 );
952 if (n) {
953 n[1].e = target;
954 n[2].ui = texture;
955 }
956 if (ctx->ExecuteFlag) {
957 (*ctx->Exec->BindTexture)( target, texture );
958 }
959 }
960
961
962 static void GLAPIENTRY save_Bitmap( GLsizei width, GLsizei height,
963 GLfloat xorig, GLfloat yorig,
964 GLfloat xmove, GLfloat ymove,
965 const GLubyte *pixels )
966 {
967 GET_CURRENT_CONTEXT(ctx);
968 GLvoid *image = _mesa_unpack_bitmap( width, height, pixels, &ctx->Unpack );
969 Node *n;
970 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
971 n = ALLOC_INSTRUCTION( ctx, OPCODE_BITMAP, 7 );
972 if (n) {
973 n[1].i = (GLint) width;
974 n[2].i = (GLint) height;
975 n[3].f = xorig;
976 n[4].f = yorig;
977 n[5].f = xmove;
978 n[6].f = ymove;
979 n[7].data = image;
980 }
981 else if (image) {
982 FREE(image);
983 }
984 if (ctx->ExecuteFlag) {
985 (*ctx->Exec->Bitmap)( width, height,
986 xorig, yorig, xmove, ymove, pixels );
987 }
988 }
989
990
991 static void GLAPIENTRY save_BlendEquation( GLenum mode )
992 {
993 GET_CURRENT_CONTEXT(ctx);
994 Node *n;
995 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
996 n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION, 1 );
997 if (n) {
998 n[1].e = mode;
999 }
1000 if (ctx->ExecuteFlag) {
1001 (*ctx->Exec->BlendEquation)( mode );
1002 }
1003 }
1004
1005
1006 static void GLAPIENTRY save_BlendEquationSeparateEXT( GLenum modeRGB,
1007 GLenum modeA )
1008 {
1009 GET_CURRENT_CONTEXT(ctx);
1010 Node *n;
1011 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1012 n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2 );
1013 if (n) {
1014 n[1].e = modeRGB;
1015 n[2].e = modeA;
1016 }
1017 if (ctx->ExecuteFlag) {
1018 (*ctx->Exec->BlendEquationSeparateEXT)( modeRGB, modeA );
1019 }
1020 }
1021
1022
1023 static void GLAPIENTRY save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
1024 GLenum sfactorA, GLenum dfactorA)
1025 {
1026 GET_CURRENT_CONTEXT(ctx);
1027 Node *n;
1028 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1029 n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
1030 if (n) {
1031 n[1].e = sfactorRGB;
1032 n[2].e = dfactorRGB;
1033 n[3].e = sfactorA;
1034 n[4].e = dfactorA;
1035 }
1036 if (ctx->ExecuteFlag) {
1037 (*ctx->Exec->BlendFuncSeparateEXT)( sfactorRGB, dfactorRGB,
1038 sfactorA, dfactorA);
1039 }
1040 }
1041
1042
1043 static void GLAPIENTRY save_BlendColor( GLfloat red, GLfloat green,
1044 GLfloat blue, GLfloat alpha )
1045 {
1046 GET_CURRENT_CONTEXT(ctx);
1047 Node *n;
1048 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1049 n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_COLOR, 4 );
1050 if (n) {
1051 n[1].f = red;
1052 n[2].f = green;
1053 n[3].f = blue;
1054 n[4].f = alpha;
1055 }
1056 if (ctx->ExecuteFlag) {
1057 (*ctx->Exec->BlendColor)( red, green, blue, alpha );
1058 }
1059 }
1060
1061
1062 void GLAPIENTRY _mesa_save_CallList( GLuint list )
1063 {
1064 GET_CURRENT_CONTEXT(ctx);
1065 Node *n;
1066 SAVE_FLUSH_VERTICES(ctx);
1067
1068 n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST, 1 );
1069 if (n) {
1070 n[1].ui = list;
1071 }
1072
1073 /* After this, we don't know what begin/end state we're in:
1074 */
1075 ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
1076
1077 if (ctx->ExecuteFlag) {
1078 (*ctx->Exec->CallList)( list );
1079 }
1080 }
1081
1082
1083 void GLAPIENTRY _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
1084 {
1085 GET_CURRENT_CONTEXT(ctx);
1086 GLint i;
1087 GLboolean typeErrorFlag;
1088
1089 SAVE_FLUSH_VERTICES(ctx);
1090
1091 switch (type) {
1092 case GL_BYTE:
1093 case GL_UNSIGNED_BYTE:
1094 case GL_SHORT:
1095 case GL_UNSIGNED_SHORT:
1096 case GL_INT:
1097 case GL_UNSIGNED_INT:
1098 case GL_FLOAT:
1099 case GL_2_BYTES:
1100 case GL_3_BYTES:
1101 case GL_4_BYTES:
1102 typeErrorFlag = GL_FALSE;
1103 break;
1104 default:
1105 typeErrorFlag = GL_TRUE;
1106 }
1107
1108 for (i=0;i<n;i++) {
1109 GLuint list = translate_id( i, type, lists );
1110 Node *n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST_OFFSET, 2 );
1111 if (n) {
1112 n[1].ui = list;
1113 n[2].b = typeErrorFlag;
1114 }
1115 }
1116
1117 /* After this, we don't know what begin/end state we're in:
1118 */
1119 ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
1120
1121 if (ctx->ExecuteFlag) {
1122 (*ctx->Exec->CallLists)( n, type, lists );
1123 }
1124 }
1125
1126
1127 static void GLAPIENTRY save_Clear( GLbitfield mask )
1128 {
1129 GET_CURRENT_CONTEXT(ctx);
1130 Node *n;
1131 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1132 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR, 1 );
1133 if (n) {
1134 n[1].bf = mask;
1135 }
1136 if (ctx->ExecuteFlag) {
1137 (*ctx->Exec->Clear)( mask );
1138 }
1139 }
1140
1141
1142 static void GLAPIENTRY save_ClearAccum( GLfloat red, GLfloat green,
1143 GLfloat blue, GLfloat alpha )
1144 {
1145 GET_CURRENT_CONTEXT(ctx);
1146 Node *n;
1147 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1148 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_ACCUM, 4 );
1149 if (n) {
1150 n[1].f = red;
1151 n[2].f = green;
1152 n[3].f = blue;
1153 n[4].f = alpha;
1154 }
1155 if (ctx->ExecuteFlag) {
1156 (*ctx->Exec->ClearAccum)( red, green, blue, alpha );
1157 }
1158 }
1159
1160
1161 static void GLAPIENTRY save_ClearColor( GLclampf red, GLclampf green,
1162 GLclampf blue, GLclampf alpha )
1163 {
1164 GET_CURRENT_CONTEXT(ctx);
1165 Node *n;
1166 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1167 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_COLOR, 4 );
1168 if (n) {
1169 n[1].f = red;
1170 n[2].f = green;
1171 n[3].f = blue;
1172 n[4].f = alpha;
1173 }
1174 if (ctx->ExecuteFlag) {
1175 (*ctx->Exec->ClearColor)( red, green, blue, alpha );
1176 }
1177 }
1178
1179
1180 static void GLAPIENTRY save_ClearDepth( GLclampd depth )
1181 {
1182 GET_CURRENT_CONTEXT(ctx);
1183 Node *n;
1184 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1185 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_DEPTH, 1 );
1186 if (n) {
1187 n[1].f = (GLfloat) depth;
1188 }
1189 if (ctx->ExecuteFlag) {
1190 (*ctx->Exec->ClearDepth)( depth );
1191 }
1192 }
1193
1194
1195 static void GLAPIENTRY save_ClearIndex( GLfloat c )
1196 {
1197 GET_CURRENT_CONTEXT(ctx);
1198 Node *n;
1199 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1200 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_INDEX, 1 );
1201 if (n) {
1202 n[1].f = c;
1203 }
1204 if (ctx->ExecuteFlag) {
1205 (*ctx->Exec->ClearIndex)( c );
1206 }
1207 }
1208
1209
1210 static void GLAPIENTRY save_ClearStencil( GLint s )
1211 {
1212 GET_CURRENT_CONTEXT(ctx);
1213 Node *n;
1214 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1215 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_STENCIL, 1 );
1216 if (n) {
1217 n[1].i = s;
1218 }
1219 if (ctx->ExecuteFlag) {
1220 (*ctx->Exec->ClearStencil)( s );
1221 }
1222 }
1223
1224
1225 static void GLAPIENTRY save_ClipPlane( GLenum plane, const GLdouble *equ )
1226 {
1227 GET_CURRENT_CONTEXT(ctx);
1228 Node *n;
1229 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1230 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLIP_PLANE, 5 );
1231 if (n) {
1232 n[1].e = plane;
1233 n[2].f = (GLfloat) equ[0];
1234 n[3].f = (GLfloat) equ[1];
1235 n[4].f = (GLfloat) equ[2];
1236 n[5].f = (GLfloat) equ[3];
1237 }
1238 if (ctx->ExecuteFlag) {
1239 (*ctx->Exec->ClipPlane)( plane, equ );
1240 }
1241 }
1242
1243
1244
1245 static void GLAPIENTRY save_ColorMask( GLboolean red, GLboolean green,
1246 GLboolean blue, GLboolean alpha )
1247 {
1248 GET_CURRENT_CONTEXT(ctx);
1249 Node *n;
1250 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1251 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MASK, 4 );
1252 if (n) {
1253 n[1].b = red;
1254 n[2].b = green;
1255 n[3].b = blue;
1256 n[4].b = alpha;
1257 }
1258 if (ctx->ExecuteFlag) {
1259 (*ctx->Exec->ColorMask)( red, green, blue, alpha );
1260 }
1261 }
1262
1263
1264 static void GLAPIENTRY save_ColorMaterial( GLenum face, GLenum mode )
1265 {
1266 GET_CURRENT_CONTEXT(ctx);
1267 Node *n;
1268 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1269
1270 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MATERIAL, 2 );
1271 if (n) {
1272 n[1].e = face;
1273 n[2].e = mode;
1274 }
1275 if (ctx->ExecuteFlag) {
1276 (*ctx->Exec->ColorMaterial)( face, mode );
1277 }
1278 }
1279
1280
1281 static void GLAPIENTRY save_ColorTable( GLenum target, GLenum internalFormat,
1282 GLsizei width, GLenum format, GLenum type,
1283 const GLvoid *table )
1284 {
1285 GET_CURRENT_CONTEXT(ctx);
1286 if (target == GL_PROXY_TEXTURE_1D ||
1287 target == GL_PROXY_TEXTURE_2D ||
1288 target == GL_PROXY_TEXTURE_3D ||
1289 target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
1290 /* execute immediately */
1291 (*ctx->Exec->ColorTable)( target, internalFormat, width,
1292 format, type, table );
1293 }
1294 else {
1295 GLvoid *image = unpack_image(width, 1, 1, format, type, table,
1296 &ctx->Unpack);
1297 Node *n;
1298 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1299 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE, 6 );
1300 if (n) {
1301 n[1].e = target;
1302 n[2].e = internalFormat;
1303 n[3].i = width;
1304 n[4].e = format;
1305 n[5].e = type;
1306 n[6].data = image;
1307 }
1308 else if (image) {
1309 FREE(image);
1310 }
1311 if (ctx->ExecuteFlag) {
1312 (*ctx->Exec->ColorTable)( target, internalFormat, width,
1313 format, type, table );
1314 }
1315 }
1316 }
1317
1318
1319
1320 static void GLAPIENTRY
1321 save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
1322 {
1323 GET_CURRENT_CONTEXT(ctx);
1324 Node *n;
1325
1326 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1327
1328 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6 );
1329 if (n) {
1330 n[1].e = target;
1331 n[2].e = pname;
1332 n[3].f = params[0];
1333 if (pname == GL_COLOR_TABLE_SGI ||
1334 pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1335 pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI ||
1336 pname == GL_TEXTURE_COLOR_TABLE_SGI) {
1337 n[4].f = params[1];
1338 n[5].f = params[2];
1339 n[6].f = params[3];
1340 }
1341 }
1342
1343 if (ctx->ExecuteFlag) {
1344 (*ctx->Exec->ColorTableParameterfv)( target, pname, params );
1345 }
1346 }
1347
1348
1349 static void GLAPIENTRY
1350 save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
1351 {
1352 GET_CURRENT_CONTEXT(ctx);
1353 Node *n;
1354
1355 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1356
1357 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6 );
1358 if (n) {
1359 n[1].e = target;
1360 n[2].e = pname;
1361 n[3].i = params[0];
1362 if (pname == GL_COLOR_TABLE_SGI ||
1363 pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1364 pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI ||
1365 pname == GL_TEXTURE_COLOR_TABLE_SGI) {
1366 n[4].i = params[1];
1367 n[5].i = params[2];
1368 n[6].i = params[3];
1369 }
1370 }
1371
1372 if (ctx->ExecuteFlag) {
1373 (*ctx->Exec->ColorTableParameteriv)( target, pname, params );
1374 }
1375 }
1376
1377
1378
1379 static void GLAPIENTRY save_ColorSubTable( GLenum target, GLsizei start, GLsizei count,
1380 GLenum format, GLenum type,
1381 const GLvoid *table)
1382 {
1383 GET_CURRENT_CONTEXT(ctx);
1384 GLvoid *image = unpack_image(count, 1, 1, format, type, table,
1385 &ctx->Unpack);
1386 Node *n;
1387 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1388 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_SUB_TABLE, 6 );
1389 if (n) {
1390 n[1].e = target;
1391 n[2].i = start;
1392 n[3].i = count;
1393 n[4].e = format;
1394 n[5].e = type;
1395 n[6].data = image;
1396 }
1397 else if (image) {
1398 FREE(image);
1399 }
1400 if (ctx->ExecuteFlag) {
1401 (*ctx->Exec->ColorSubTable)(target, start, count, format, type, table);
1402 }
1403 }
1404
1405
1406 static void GLAPIENTRY
1407 save_CopyColorSubTable(GLenum target, GLsizei start,
1408 GLint x, GLint y, GLsizei width)
1409 {
1410 GET_CURRENT_CONTEXT(ctx);
1411 Node *n;
1412
1413 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1414 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5 );
1415 if (n) {
1416 n[1].e = target;
1417 n[2].i = start;
1418 n[3].i = x;
1419 n[4].i = y;
1420 n[5].i = width;
1421 }
1422 if (ctx->ExecuteFlag) {
1423 (*ctx->Exec->CopyColorSubTable)(target, start, x, y, width);
1424 }
1425 }
1426
1427
1428 static void GLAPIENTRY
1429 save_CopyColorTable(GLenum target, GLenum internalformat,
1430 GLint x, GLint y, GLsizei width)
1431 {
1432 GET_CURRENT_CONTEXT(ctx);
1433 Node *n;
1434
1435 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1436 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_TABLE, 5 );
1437 if (n) {
1438 n[1].e = target;
1439 n[2].e = internalformat;
1440 n[3].i = x;
1441 n[4].i = y;
1442 n[5].i = width;
1443 }
1444 if (ctx->ExecuteFlag) {
1445 (*ctx->Exec->CopyColorTable)(target, internalformat, x, y, width);
1446 }
1447 }
1448
1449
1450 static void GLAPIENTRY
1451 save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
1452 GLenum format, GLenum type, const GLvoid *filter)
1453 {
1454 GET_CURRENT_CONTEXT(ctx);
1455 GLvoid *image = unpack_image(width, 1, 1, format, type, filter,
1456 &ctx->Unpack);
1457 Node *n;
1458 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1459 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_1D, 6 );
1460 if (n) {
1461 n[1].e = target;
1462 n[2].e = internalFormat;
1463 n[3].i = width;
1464 n[4].e = format;
1465 n[5].e = type;
1466 n[6].data = image;
1467 }
1468 else if (image) {
1469 FREE(image);
1470 }
1471 if (ctx->ExecuteFlag) {
1472 (*ctx->Exec->ConvolutionFilter1D)( target, internalFormat, width,
1473 format, type, filter );
1474 }
1475 }
1476
1477
1478 static void GLAPIENTRY
1479 save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
1480 GLsizei width, GLsizei height, GLenum format,
1481 GLenum type, const GLvoid *filter)
1482 {
1483 GET_CURRENT_CONTEXT(ctx);
1484 GLvoid *image = unpack_image(width, height, 1, format, type, filter,
1485 &ctx->Unpack);
1486 Node *n;
1487 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1488 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_2D, 7 );
1489 if (n) {
1490 n[1].e = target;
1491 n[2].e = internalFormat;
1492 n[3].i = width;
1493 n[4].i = height;
1494 n[5].e = format;
1495 n[6].e = type;
1496 n[7].data = image;
1497 }
1498 else if (image) {
1499 FREE(image);
1500 }
1501 if (ctx->ExecuteFlag) {
1502 (*ctx->Exec->ConvolutionFilter2D)( target, internalFormat, width, height,
1503 format, type, filter );
1504 }
1505 }
1506
1507
1508 static void GLAPIENTRY
1509 save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
1510 {
1511 GET_CURRENT_CONTEXT(ctx);
1512 Node *n;
1513 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1514 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3 );
1515 if (n) {
1516 n[1].e = target;
1517 n[2].e = pname;
1518 n[3].i = param;
1519 }
1520 if (ctx->ExecuteFlag) {
1521 (*ctx->Exec->ConvolutionParameteri)( target, pname, param );
1522 }
1523 }
1524
1525
1526 static void GLAPIENTRY
1527 save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
1528 {
1529 GET_CURRENT_CONTEXT(ctx);
1530 Node *n;
1531 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1532 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
1533 if (n) {
1534 n[1].e = target;
1535 n[2].e = pname;
1536 n[3].i = params[0];
1537 if (pname == GL_CONVOLUTION_BORDER_COLOR ||
1538 pname == GL_CONVOLUTION_FILTER_SCALE ||
1539 pname == GL_CONVOLUTION_FILTER_BIAS) {
1540 n[4].i = params[1];
1541 n[5].i = params[2];
1542 n[6].i = params[3];
1543 }
1544 else {
1545 n[4].i = n[5].i = n[6].i = 0;
1546 }
1547 }
1548 if (ctx->ExecuteFlag) {
1549 (*ctx->Exec->ConvolutionParameteriv)( target, pname, params );
1550 }
1551 }
1552
1553
1554 static void GLAPIENTRY
1555 save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
1556 {
1557 GET_CURRENT_CONTEXT(ctx);
1558 Node *n;
1559 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1560 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3 );
1561 if (n) {
1562 n[1].e = target;
1563 n[2].e = pname;
1564 n[3].f = param;
1565 }
1566 if (ctx->ExecuteFlag) {
1567 (*ctx->Exec->ConvolutionParameterf)( target, pname, param );
1568 }
1569 }
1570
1571
1572 static void GLAPIENTRY
1573 save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
1574 {
1575 GET_CURRENT_CONTEXT(ctx);
1576 Node *n;
1577 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1578 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6 );
1579 if (n) {
1580 n[1].e = target;
1581 n[2].e = pname;
1582 n[3].f = params[0];
1583 if (pname == GL_CONVOLUTION_BORDER_COLOR ||
1584 pname == GL_CONVOLUTION_FILTER_SCALE ||
1585 pname == GL_CONVOLUTION_FILTER_BIAS) {
1586 n[4].f = params[1];
1587 n[5].f = params[2];
1588 n[6].f = params[3];
1589 }
1590 else {
1591 n[4].f = n[5].f = n[6].f = 0.0F;
1592 }
1593 }
1594 if (ctx->ExecuteFlag) {
1595 (*ctx->Exec->ConvolutionParameterfv)( target, pname, params );
1596 }
1597 }
1598
1599
1600 static void GLAPIENTRY
1601 save_CopyPixels( GLint x, GLint y,
1602 GLsizei width, GLsizei height, GLenum type )
1603 {
1604 GET_CURRENT_CONTEXT(ctx);
1605 Node *n;
1606 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1607 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_PIXELS, 5 );
1608 if (n) {
1609 n[1].i = x;
1610 n[2].i = y;
1611 n[3].i = (GLint) width;
1612 n[4].i = (GLint) height;
1613 n[5].e = type;
1614 }
1615 if (ctx->ExecuteFlag) {
1616 (*ctx->Exec->CopyPixels)( x, y, width, height, type );
1617 }
1618 }
1619
1620
1621
1622 static void GLAPIENTRY
1623 save_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
1624 GLint x, GLint y, GLsizei width, GLint border )
1625 {
1626 GET_CURRENT_CONTEXT(ctx);
1627 Node *n;
1628 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1629 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
1630 if (n) {
1631 n[1].e = target;
1632 n[2].i = level;
1633 n[3].e = internalformat;
1634 n[4].i = x;
1635 n[5].i = y;
1636 n[6].i = width;
1637 n[7].i = border;
1638 }
1639 if (ctx->ExecuteFlag) {
1640 (*ctx->Exec->CopyTexImage1D)( target, level, internalformat,
1641 x, y, width, border );
1642 }
1643 }
1644
1645
1646 static void GLAPIENTRY
1647 save_CopyTexImage2D( GLenum target, GLint level,
1648 GLenum internalformat,
1649 GLint x, GLint y, GLsizei width,
1650 GLsizei height, GLint border )
1651 {
1652 GET_CURRENT_CONTEXT(ctx);
1653 Node *n;
1654 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1655 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
1656 if (n) {
1657 n[1].e = target;
1658 n[2].i = level;
1659 n[3].e = internalformat;
1660 n[4].i = x;
1661 n[5].i = y;
1662 n[6].i = width;
1663 n[7].i = height;
1664 n[8].i = border;
1665 }
1666 if (ctx->ExecuteFlag) {
1667 (*ctx->Exec->CopyTexImage2D)( target, level, internalformat,
1668 x, y, width, height, border );
1669 }
1670 }
1671
1672
1673
1674 static void GLAPIENTRY
1675 save_CopyTexSubImage1D( GLenum target, GLint level,
1676 GLint xoffset, GLint x, GLint y,
1677 GLsizei width )
1678 {
1679 GET_CURRENT_CONTEXT(ctx);
1680 Node *n;
1681 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1682 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
1683 if (n) {
1684 n[1].e = target;
1685 n[2].i = level;
1686 n[3].i = xoffset;
1687 n[4].i = x;
1688 n[5].i = y;
1689 n[6].i = width;
1690 }
1691 if (ctx->ExecuteFlag) {
1692 (*ctx->Exec->CopyTexSubImage1D)( target, level, xoffset, x, y, width );
1693 }
1694 }
1695
1696
1697 static void GLAPIENTRY
1698 save_CopyTexSubImage2D( GLenum target, GLint level,
1699 GLint xoffset, GLint yoffset,
1700 GLint x, GLint y,
1701 GLsizei width, GLint height )
1702 {
1703 GET_CURRENT_CONTEXT(ctx);
1704 Node *n;
1705 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1706 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
1707 if (n) {
1708 n[1].e = target;
1709 n[2].i = level;
1710 n[3].i = xoffset;
1711 n[4].i = yoffset;
1712 n[5].i = x;
1713 n[6].i = y;
1714 n[7].i = width;
1715 n[8].i = height;
1716 }
1717 if (ctx->ExecuteFlag) {
1718 (*ctx->Exec->CopyTexSubImage2D)( target, level, xoffset, yoffset,
1719 x, y, width, height );
1720 }
1721 }
1722
1723
1724 static void GLAPIENTRY
1725 save_CopyTexSubImage3D( GLenum target, GLint level,
1726 GLint xoffset, GLint yoffset, GLint zoffset,
1727 GLint x, GLint y,
1728 GLsizei width, GLint height )
1729 {
1730 GET_CURRENT_CONTEXT(ctx);
1731 Node *n;
1732 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1733 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
1734 if (n) {
1735 n[1].e = target;
1736 n[2].i = level;
1737 n[3].i = xoffset;
1738 n[4].i = yoffset;
1739 n[5].i = zoffset;
1740 n[6].i = x;
1741 n[7].i = y;
1742 n[8].i = width;
1743 n[9].i = height;
1744 }
1745 if (ctx->ExecuteFlag) {
1746 (*ctx->Exec->CopyTexSubImage3D)( target, level,
1747 xoffset, yoffset, zoffset,
1748 x, y, width, height );
1749 }
1750 }
1751
1752
1753 static void GLAPIENTRY save_CullFace( GLenum mode )
1754 {
1755 GET_CURRENT_CONTEXT(ctx);
1756 Node *n;
1757 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1758 n = ALLOC_INSTRUCTION( ctx, OPCODE_CULL_FACE, 1 );
1759 if (n) {
1760 n[1].e = mode;
1761 }
1762 if (ctx->ExecuteFlag) {
1763 (*ctx->Exec->CullFace)( mode );
1764 }
1765 }
1766
1767
1768 static void GLAPIENTRY save_DepthFunc( GLenum func )
1769 {
1770 GET_CURRENT_CONTEXT(ctx);
1771 Node *n;
1772 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1773 n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_FUNC, 1 );
1774 if (n) {
1775 n[1].e = func;
1776 }
1777 if (ctx->ExecuteFlag) {
1778 (*ctx->Exec->DepthFunc)( func );
1779 }
1780 }
1781
1782
1783 static void GLAPIENTRY save_DepthMask( GLboolean mask )
1784 {
1785 GET_CURRENT_CONTEXT(ctx);
1786 Node *n;
1787 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1788 n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_MASK, 1 );
1789 if (n) {
1790 n[1].b = mask;
1791 }
1792 if (ctx->ExecuteFlag) {
1793 (*ctx->Exec->DepthMask)( mask );
1794 }
1795 }
1796
1797
1798 static void GLAPIENTRY save_DepthRange( GLclampd nearval, GLclampd farval )
1799 {
1800 GET_CURRENT_CONTEXT(ctx);
1801 Node *n;
1802 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1803 n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_RANGE, 2 );
1804 if (n) {
1805 n[1].f = (GLfloat) nearval;
1806 n[2].f = (GLfloat) farval;
1807 }
1808 if (ctx->ExecuteFlag) {
1809 (*ctx->Exec->DepthRange)( nearval, farval );
1810 }
1811 }
1812
1813
1814 static void GLAPIENTRY save_Disable( GLenum cap )
1815 {
1816 GET_CURRENT_CONTEXT(ctx);
1817 Node *n;
1818 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1819 n = ALLOC_INSTRUCTION( ctx, OPCODE_DISABLE, 1 );
1820 if (n) {
1821 n[1].e = cap;
1822 }
1823 if (ctx->ExecuteFlag) {
1824 (*ctx->Exec->Disable)( cap );
1825 }
1826 }
1827
1828
1829 static void GLAPIENTRY save_DrawBuffer( GLenum mode )
1830 {
1831 GET_CURRENT_CONTEXT(ctx);
1832 Node *n;
1833 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1834 n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_BUFFER, 1 );
1835 if (n) {
1836 n[1].e = mode;
1837 }
1838 if (ctx->ExecuteFlag) {
1839 (*ctx->Exec->DrawBuffer)( mode );
1840 }
1841 }
1842
1843
1844 static void GLAPIENTRY save_DrawPixels( GLsizei width, GLsizei height,
1845 GLenum format, GLenum type,
1846 const GLvoid *pixels )
1847 {
1848 GET_CURRENT_CONTEXT(ctx);
1849 GLvoid *image = unpack_image(width, height, 1, format, type,
1850 pixels, &ctx->Unpack);
1851 Node *n;
1852 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1853 n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_PIXELS, 5 );
1854 if (n) {
1855 n[1].i = width;
1856 n[2].i = height;
1857 n[3].e = format;
1858 n[4].e = type;
1859 n[5].data = image;
1860 }
1861 else if (image) {
1862 FREE(image);
1863 }
1864 if (ctx->ExecuteFlag) {
1865 (*ctx->Exec->DrawPixels)( width, height, format, type, pixels );
1866 }
1867 }
1868
1869
1870
1871 static void GLAPIENTRY save_Enable( GLenum cap )
1872 {
1873 GET_CURRENT_CONTEXT(ctx);
1874 Node *n;
1875 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1876 n = ALLOC_INSTRUCTION( ctx, OPCODE_ENABLE, 1 );
1877 if (n) {
1878 n[1].e = cap;
1879 }
1880 if (ctx->ExecuteFlag) {
1881 (*ctx->Exec->Enable)( cap );
1882 }
1883 }
1884
1885
1886
1887 void GLAPIENTRY _mesa_save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
1888 {
1889 GET_CURRENT_CONTEXT(ctx);
1890 Node *n;
1891 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1892 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVALMESH1, 3 );
1893 if (n) {
1894 n[1].e = mode;
1895 n[2].i = i1;
1896 n[3].i = i2;
1897 }
1898 if (ctx->ExecuteFlag) {
1899 (*ctx->Exec->EvalMesh1)( mode, i1, i2 );
1900 }
1901 }
1902
1903
1904 void GLAPIENTRY _mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
1905 {
1906 GET_CURRENT_CONTEXT(ctx);
1907 Node *n;
1908 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1909 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVALMESH2, 5 );
1910 if (n) {
1911 n[1].e = mode;
1912 n[2].i = i1;
1913 n[3].i = i2;
1914 n[4].i = j1;
1915 n[5].i = j2;
1916 }
1917 if (ctx->ExecuteFlag) {
1918 (*ctx->Exec->EvalMesh2)( mode, i1, i2, j1, j2 );
1919 }
1920 }
1921
1922
1923
1924
1925 static void GLAPIENTRY save_Fogfv( GLenum pname, const GLfloat *params )
1926 {
1927 GET_CURRENT_CONTEXT(ctx);
1928 Node *n;
1929 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1930 n = ALLOC_INSTRUCTION( ctx, OPCODE_FOG, 5 );
1931 if (n) {
1932 n[1].e = pname;
1933 n[2].f = params[0];
1934 n[3].f = params[1];
1935 n[4].f = params[2];
1936 n[5].f = params[3];
1937 }
1938 if (ctx->ExecuteFlag) {
1939 (*ctx->Exec->Fogfv)( pname, params );
1940 }
1941 }
1942
1943
1944 static void GLAPIENTRY save_Fogf( GLenum pname, GLfloat param )
1945 {
1946 save_Fogfv(pname, &param);
1947 }
1948
1949
1950 static void GLAPIENTRY save_Fogiv(GLenum pname, const GLint *params )
1951 {
1952 GLfloat p[4];
1953 switch (pname) {
1954 case GL_FOG_MODE:
1955 case GL_FOG_DENSITY:
1956 case GL_FOG_START:
1957 case GL_FOG_END:
1958 case GL_FOG_INDEX:
1959 p[0] = (GLfloat) *params;
1960 break;
1961 case GL_FOG_COLOR:
1962 p[0] = INT_TO_FLOAT( params[0] );
1963 p[1] = INT_TO_FLOAT( params[1] );
1964 p[2] = INT_TO_FLOAT( params[2] );
1965 p[3] = INT_TO_FLOAT( params[3] );
1966 break;
1967 default:
1968 /* Error will be caught later in gl_Fogfv */
1969 ;
1970 }
1971 save_Fogfv(pname, p);
1972 }
1973
1974
1975 static void GLAPIENTRY save_Fogi(GLenum pname, GLint param )
1976 {
1977 save_Fogiv(pname, &param);
1978 }
1979
1980
1981 static void GLAPIENTRY save_FrontFace( GLenum mode )
1982 {
1983 GET_CURRENT_CONTEXT(ctx);
1984 Node *n;
1985 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1986 n = ALLOC_INSTRUCTION( ctx, OPCODE_FRONT_FACE, 1 );
1987 if (n) {
1988 n[1].e = mode;
1989 }
1990 if (ctx->ExecuteFlag) {
1991 (*ctx->Exec->FrontFace)( mode );
1992 }
1993 }
1994
1995
1996 static void GLAPIENTRY save_Frustum( GLdouble left, GLdouble right,
1997 GLdouble bottom, GLdouble top,
1998 GLdouble nearval, GLdouble farval )
1999 {
2000 GET_CURRENT_CONTEXT(ctx);
2001 Node *n;
2002 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2003 n = ALLOC_INSTRUCTION( ctx, OPCODE_FRUSTUM, 6 );
2004 if (n) {
2005 n[1].f = (GLfloat) left;
2006 n[2].f = (GLfloat) right;
2007 n[3].f = (GLfloat) bottom;
2008 n[4].f = (GLfloat) top;
2009 n[5].f = (GLfloat) nearval;
2010 n[6].f = (GLfloat) farval;
2011 }
2012 if (ctx->ExecuteFlag) {
2013 (*ctx->Exec->Frustum)( left, right, bottom, top, nearval, farval );
2014 }
2015 }
2016
2017
2018 static void GLAPIENTRY save_Hint( GLenum target, GLenum mode )
2019 {
2020 GET_CURRENT_CONTEXT(ctx);
2021 Node *n;
2022 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2023 n = ALLOC_INSTRUCTION( ctx, OPCODE_HINT, 2 );
2024 if (n) {
2025 n[1].e = target;
2026 n[2].e = mode;
2027 }
2028 if (ctx->ExecuteFlag) {
2029 (*ctx->Exec->Hint)( target, mode );
2030 }
2031 }
2032
2033
2034 static void GLAPIENTRY
2035 save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink)
2036 {
2037 GET_CURRENT_CONTEXT(ctx);
2038 Node *n;
2039
2040 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2041 n = ALLOC_INSTRUCTION( ctx, OPCODE_HISTOGRAM, 4 );
2042 if (n) {
2043 n[1].e = target;
2044 n[2].i = width;
2045 n[3].e = internalFormat;
2046 n[4].b = sink;
2047 }
2048 if (ctx->ExecuteFlag) {
2049 (*ctx->Exec->Histogram)( target, width, internalFormat, sink );
2050 }
2051 }
2052
2053
2054 static void GLAPIENTRY save_IndexMask( GLuint mask )
2055 {
2056 GET_CURRENT_CONTEXT(ctx);
2057 Node *n;
2058 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2059 n = ALLOC_INSTRUCTION( ctx, OPCODE_INDEX_MASK, 1 );
2060 if (n) {
2061 n[1].ui = mask;
2062 }
2063 if (ctx->ExecuteFlag) {
2064 (*ctx->Exec->IndexMask)( mask );
2065 }
2066 }
2067
2068
2069 static void GLAPIENTRY save_InitNames( void )
2070 {
2071 GET_CURRENT_CONTEXT(ctx);
2072 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2073 (void) ALLOC_INSTRUCTION( ctx, OPCODE_INIT_NAMES, 0 );
2074 if (ctx->ExecuteFlag) {
2075 (*ctx->Exec->InitNames)();
2076 }
2077 }
2078
2079
2080 static void GLAPIENTRY save_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
2081 {
2082 GET_CURRENT_CONTEXT(ctx);
2083 Node *n;
2084 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2085 n = ALLOC_INSTRUCTION( ctx, OPCODE_LIGHT, 6 );
2086 if (OPCODE_LIGHT) {
2087 GLint i, nParams;
2088 n[1].e = light;
2089 n[2].e = pname;
2090 switch (pname) {
2091 case GL_AMBIENT:
2092 nParams = 4;
2093 break;
2094 case GL_DIFFUSE:
2095 nParams = 4;
2096 break;
2097 case GL_SPECULAR:
2098 nParams = 4;
2099 break;
2100 case GL_POSITION:
2101 nParams = 4;
2102 break;
2103 case GL_SPOT_DIRECTION:
2104 nParams = 3;
2105 break;
2106 case GL_SPOT_EXPONENT:
2107 nParams = 1;
2108 break;
2109 case GL_SPOT_CUTOFF:
2110 nParams = 1;
2111 break;
2112 case GL_CONSTANT_ATTENUATION:
2113 nParams = 1;
2114 break;
2115 case GL_LINEAR_ATTENUATION:
2116 nParams = 1;
2117 break;
2118 case GL_QUADRATIC_ATTENUATION:
2119 nParams = 1;
2120 break;
2121 default:
2122 nParams = 0;
2123 }
2124 for (i = 0; i < nParams; i++) {
2125 n[3+i].f = params[i];
2126 }
2127 }
2128 if (ctx->ExecuteFlag) {
2129 (*ctx->Exec->Lightfv)( light, pname, params );
2130 }
2131 }
2132
2133
2134 static void GLAPIENTRY save_Lightf( GLenum light, GLenum pname, GLfloat params )
2135 {
2136 save_Lightfv(light, pname, &params);
2137 }
2138
2139
2140 static void GLAPIENTRY save_Lightiv( GLenum light, GLenum pname, const GLint *params )
2141 {
2142 GLfloat fparam[4];
2143 switch (pname) {
2144 case GL_AMBIENT:
2145 case GL_DIFFUSE:
2146 case GL_SPECULAR:
2147 fparam[0] = INT_TO_FLOAT( params[0] );
2148 fparam[1] = INT_TO_FLOAT( params[1] );
2149 fparam[2] = INT_TO_FLOAT( params[2] );
2150 fparam[3] = INT_TO_FLOAT( params[3] );
2151 break;
2152 case GL_POSITION:
2153 fparam[0] = (GLfloat) params[0];
2154 fparam[1] = (GLfloat) params[1];
2155 fparam[2] = (GLfloat) params[2];
2156 fparam[3] = (GLfloat) params[3];
2157 break;
2158 case GL_SPOT_DIRECTION:
2159 fparam[0] = (GLfloat) params[0];
2160 fparam[1] = (GLfloat) params[1];
2161 fparam[2] = (GLfloat) params[2];
2162 break;
2163 case GL_SPOT_EXPONENT:
2164 case GL_SPOT_CUTOFF:
2165 case GL_CONSTANT_ATTENUATION:
2166 case GL_LINEAR_ATTENUATION:
2167 case GL_QUADRATIC_ATTENUATION:
2168 fparam[0] = (GLfloat) params[0];
2169 break;
2170 default:
2171 /* error will be caught later in gl_Lightfv */
2172 ;
2173 }
2174 save_Lightfv( light, pname, fparam );
2175 }
2176
2177
2178 static void GLAPIENTRY save_Lighti( GLenum light, GLenum pname, GLint param )
2179 {
2180 save_Lightiv( light, pname, &param );
2181 }
2182
2183
2184 static void GLAPIENTRY save_LightModelfv( GLenum pname, const GLfloat *params )
2185 {
2186 GET_CURRENT_CONTEXT(ctx);
2187 Node *n;
2188 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2189 n = ALLOC_INSTRUCTION( ctx, OPCODE_LIGHT_MODEL, 5 );
2190 if (n) {
2191 n[1].e = pname;
2192 n[2].f = params[0];
2193 n[3].f = params[1];
2194 n[4].f = params[2];
2195 n[5].f = params[3];
2196 }
2197 if (ctx->ExecuteFlag) {
2198 (*ctx->Exec->LightModelfv)( pname, params );
2199 }
2200 }
2201
2202
2203 static void GLAPIENTRY save_LightModelf( GLenum pname, GLfloat param )
2204 {
2205 save_LightModelfv(pname, &param);
2206 }
2207
2208
2209 static void GLAPIENTRY save_LightModeliv( GLenum pname, const GLint *params )
2210 {
2211 GLfloat fparam[4];
2212 switch (pname) {
2213 case GL_LIGHT_MODEL_AMBIENT:
2214 fparam[0] = INT_TO_FLOAT( params[0] );
2215 fparam[1] = INT_TO_FLOAT( params[1] );
2216 fparam[2] = INT_TO_FLOAT( params[2] );
2217 fparam[3] = INT_TO_FLOAT( params[3] );
2218 break;
2219 case GL_LIGHT_MODEL_LOCAL_VIEWER:
2220 case GL_LIGHT_MODEL_TWO_SIDE:
2221 case GL_LIGHT_MODEL_COLOR_CONTROL:
2222 fparam[0] = (GLfloat) params[0];
2223 break;
2224 default:
2225 /* Error will be caught later in gl_LightModelfv */
2226 ;
2227 }
2228 save_LightModelfv(pname, fparam);
2229 }
2230
2231
2232 static void GLAPIENTRY save_LightModeli( GLenum pname, GLint param )
2233 {
2234 save_LightModeliv(pname, &param);
2235 }
2236
2237
2238 static void GLAPIENTRY save_LineStipple( GLint factor, GLushort pattern )
2239 {
2240 GET_CURRENT_CONTEXT(ctx);
2241 Node *n;
2242 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2243 n = ALLOC_INSTRUCTION( ctx, OPCODE_LINE_STIPPLE, 2 );
2244 if (n) {
2245 n[1].i = factor;
2246 n[2].us = pattern;
2247 }
2248 if (ctx->ExecuteFlag) {
2249 (*ctx->Exec->LineStipple)( factor, pattern );
2250 }
2251 }
2252
2253
2254 static void GLAPIENTRY save_LineWidth( GLfloat width )
2255 {
2256 GET_CURRENT_CONTEXT(ctx);
2257 Node *n;
2258 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2259 n = ALLOC_INSTRUCTION( ctx, OPCODE_LINE_WIDTH, 1 );
2260 if (n) {
2261 n[1].f = width;
2262 }
2263 if (ctx->ExecuteFlag) {
2264 (*ctx->Exec->LineWidth)( width );
2265 }
2266 }
2267
2268
2269 static void GLAPIENTRY save_ListBase( GLuint base )
2270 {
2271 GET_CURRENT_CONTEXT(ctx);
2272 Node *n;
2273 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2274 n = ALLOC_INSTRUCTION( ctx, OPCODE_LIST_BASE, 1 );
2275 if (n) {
2276 n[1].ui = base;
2277 }
2278 if (ctx->ExecuteFlag) {
2279 (*ctx->Exec->ListBase)( base );
2280 }
2281 }
2282
2283
2284 static void GLAPIENTRY save_LoadIdentity( void )
2285 {
2286 GET_CURRENT_CONTEXT(ctx);
2287 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2288 (void) ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_IDENTITY, 0 );
2289 if (ctx->ExecuteFlag) {
2290 (*ctx->Exec->LoadIdentity)();
2291 }
2292 }
2293
2294
2295 static void GLAPIENTRY save_LoadMatrixf( const GLfloat *m )
2296 {
2297 GET_CURRENT_CONTEXT(ctx);
2298 Node *n;
2299 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2300 n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_MATRIX, 16 );
2301 if (n) {
2302 GLuint i;
2303 for (i=0;i<16;i++) {
2304 n[1+i].f = m[i];
2305 }
2306 }
2307 if (ctx->ExecuteFlag) {
2308 (*ctx->Exec->LoadMatrixf)( m );
2309 }
2310 }
2311
2312
2313 static void GLAPIENTRY save_LoadMatrixd( const GLdouble *m )
2314 {
2315 GLfloat f[16];
2316 GLint i;
2317 for (i = 0; i < 16; i++) {
2318 f[i] = (GLfloat) m[i];
2319 }
2320 save_LoadMatrixf(f);
2321 }
2322
2323
2324 static void GLAPIENTRY save_LoadName( GLuint name )
2325 {
2326 GET_CURRENT_CONTEXT(ctx);
2327 Node *n;
2328 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2329 n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_NAME, 1 );
2330 if (n) {
2331 n[1].ui = name;
2332 }
2333 if (ctx->ExecuteFlag) {
2334 (*ctx->Exec->LoadName)( name );
2335 }
2336 }
2337
2338
2339 static void GLAPIENTRY save_LogicOp( GLenum opcode )
2340 {
2341 GET_CURRENT_CONTEXT(ctx);
2342 Node *n;
2343 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2344 n = ALLOC_INSTRUCTION( ctx, OPCODE_LOGIC_OP, 1 );
2345 if (n) {
2346 n[1].e = opcode;
2347 }
2348 if (ctx->ExecuteFlag) {
2349 (*ctx->Exec->LogicOp)( opcode );
2350 }
2351 }
2352
2353
2354 static void GLAPIENTRY save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
2355 GLint order, const GLdouble *points)
2356 {
2357 GET_CURRENT_CONTEXT(ctx);
2358 Node *n;
2359 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2360 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
2361 if (n) {
2362 GLfloat *pnts = _mesa_copy_map_points1d( target, stride, order, points );
2363 n[1].e = target;
2364 n[2].f = (GLfloat) u1;
2365 n[3].f = (GLfloat) u2;
2366 n[4].i = _mesa_evaluator_components(target); /* stride */
2367 n[5].i = order;
2368 n[6].data = (void *) pnts;
2369 }
2370 if (ctx->ExecuteFlag) {
2371 (*ctx->Exec->Map1d)( target, u1, u2, stride, order, points );
2372 }
2373 }
2374
2375 static void GLAPIENTRY save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
2376 GLint order, const GLfloat *points)
2377 {
2378 GET_CURRENT_CONTEXT(ctx);
2379 Node *n;
2380 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2381 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
2382 if (n) {
2383 GLfloat *pnts = _mesa_copy_map_points1f( target, stride, order, points );
2384 n[1].e = target;
2385 n[2].f = u1;
2386 n[3].f = u2;
2387 n[4].i = _mesa_evaluator_components(target); /* stride */
2388 n[5].i = order;
2389 n[6].data = (void *) pnts;
2390 }
2391 if (ctx->ExecuteFlag) {
2392 (*ctx->Exec->Map1f)( target, u1, u2, stride, order, points );
2393 }
2394 }
2395
2396
2397 static void GLAPIENTRY save_Map2d( GLenum target,
2398 GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
2399 GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
2400 const GLdouble *points )
2401 {
2402 GET_CURRENT_CONTEXT(ctx);
2403 Node *n;
2404 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2405 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
2406 if (n) {
2407 GLfloat *pnts = _mesa_copy_map_points2d( target, ustride, uorder,
2408 vstride, vorder, points );
2409 n[1].e = target;
2410 n[2].f = (GLfloat) u1;
2411 n[3].f = (GLfloat) u2;
2412 n[4].f = (GLfloat) v1;
2413 n[5].f = (GLfloat) v2;
2414 /* XXX verify these strides are correct */
2415 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
2416 n[7].i = _mesa_evaluator_components(target); /*vstride*/
2417 n[8].i = uorder;
2418 n[9].i = vorder;
2419 n[10].data = (void *) pnts;
2420 }
2421 if (ctx->ExecuteFlag) {
2422 (*ctx->Exec->Map2d)( target,
2423 u1, u2, ustride, uorder,
2424 v1, v2, vstride, vorder, points );
2425 }
2426 }
2427
2428
2429 static void GLAPIENTRY save_Map2f( GLenum target,
2430 GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
2431 GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
2432 const GLfloat *points )
2433 {
2434 GET_CURRENT_CONTEXT(ctx);
2435 Node *n;
2436 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2437 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
2438 if (n) {
2439 GLfloat *pnts = _mesa_copy_map_points2f( target, ustride, uorder,
2440 vstride, vorder, points );
2441 n[1].e = target;
2442 n[2].f = u1;
2443 n[3].f = u2;
2444 n[4].f = v1;
2445 n[5].f = v2;
2446 /* XXX verify these strides are correct */
2447 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
2448 n[7].i = _mesa_evaluator_components(target); /*vstride*/
2449 n[8].i = uorder;
2450 n[9].i = vorder;
2451 n[10].data = (void *) pnts;
2452 }
2453 if (ctx->ExecuteFlag) {
2454 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
2455 v1, v2, vstride, vorder, points );
2456 }
2457 }
2458
2459
2460 static void GLAPIENTRY save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
2461 {
2462 GET_CURRENT_CONTEXT(ctx);
2463 Node *n;
2464 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2465 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAPGRID1, 3 );
2466 if (n) {
2467 n[1].i = un;
2468 n[2].f = u1;
2469 n[3].f = u2;
2470 }
2471 if (ctx->ExecuteFlag) {
2472 (*ctx->Exec->MapGrid1f)( un, u1, u2 );
2473 }
2474 }
2475
2476
2477 static void GLAPIENTRY save_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
2478 {
2479 save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
2480 }
2481
2482
2483 static void GLAPIENTRY save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
2484 GLint vn, GLfloat v1, GLfloat v2 )
2485 {
2486 GET_CURRENT_CONTEXT(ctx);
2487 Node *n;
2488 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2489 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAPGRID2, 6 );
2490 if (n) {
2491 n[1].i = un;
2492 n[2].f = u1;
2493 n[3].f = u2;
2494 n[4].i = vn;
2495 n[5].f = v1;
2496 n[6].f = v2;
2497 }
2498 if (ctx->ExecuteFlag) {
2499 (*ctx->Exec->MapGrid2f)( un, u1, u2, vn, v1, v2 );
2500 }
2501 }
2502
2503
2504
2505 static void GLAPIENTRY save_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
2506 GLint vn, GLdouble v1, GLdouble v2 )
2507 {
2508 save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2,
2509 vn, (GLfloat) v1, (GLfloat) v2);
2510 }
2511
2512
2513 static void GLAPIENTRY save_MatrixMode( GLenum mode )
2514 {
2515 GET_CURRENT_CONTEXT(ctx);
2516 Node *n;
2517 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2518 n = ALLOC_INSTRUCTION( ctx, OPCODE_MATRIX_MODE, 1 );
2519 if (n) {
2520 n[1].e = mode;
2521 }
2522 if (ctx->ExecuteFlag) {
2523 (*ctx->Exec->MatrixMode)( mode );
2524 }
2525 }
2526
2527
2528 static void GLAPIENTRY
2529 save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
2530 {
2531 GET_CURRENT_CONTEXT(ctx);
2532 Node *n;
2533
2534 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2535 n = ALLOC_INSTRUCTION( ctx, OPCODE_MIN_MAX, 3 );
2536 if (n) {
2537 n[1].e = target;
2538 n[2].e = internalFormat;
2539 n[3].b = sink;
2540 }
2541 if (ctx->ExecuteFlag) {
2542 (*ctx->Exec->Minmax)( target, internalFormat, sink );
2543 }
2544 }
2545
2546
2547 static void GLAPIENTRY save_MultMatrixf( const GLfloat *m )
2548 {
2549 GET_CURRENT_CONTEXT(ctx);
2550 Node *n;
2551 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2552 n = ALLOC_INSTRUCTION( ctx, OPCODE_MULT_MATRIX, 16 );
2553 if (n) {
2554 GLuint i;
2555 for (i=0;i<16;i++) {
2556 n[1+i].f = m[i];
2557 }
2558 }
2559 if (ctx->ExecuteFlag) {
2560 (*ctx->Exec->MultMatrixf)( m );
2561 }
2562 }
2563
2564
2565 static void GLAPIENTRY save_MultMatrixd( const GLdouble *m )
2566 {
2567 GLfloat f[16];
2568 GLint i;
2569 for (i = 0; i < 16; i++) {
2570 f[i] = (GLfloat) m[i];
2571 }
2572 save_MultMatrixf(f);
2573 }
2574
2575
2576 static void GLAPIENTRY save_NewList( GLuint list, GLenum mode )
2577 {
2578 GET_CURRENT_CONTEXT(ctx);
2579 /* It's an error to call this function while building a display list */
2580 _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
2581 (void) list;
2582 (void) mode;
2583 }
2584
2585
2586
2587 static void GLAPIENTRY save_Ortho( GLdouble left, GLdouble right,
2588 GLdouble bottom, GLdouble top,
2589 GLdouble nearval, GLdouble farval )
2590 {
2591 GET_CURRENT_CONTEXT(ctx);
2592 Node *n;
2593 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2594 n = ALLOC_INSTRUCTION( ctx, OPCODE_ORTHO, 6 );
2595 if (n) {
2596 n[1].f = (GLfloat) left;
2597 n[2].f = (GLfloat) right;
2598 n[3].f = (GLfloat) bottom;
2599 n[4].f = (GLfloat) top;
2600 n[5].f = (GLfloat) nearval;
2601 n[6].f = (GLfloat) farval;
2602 }
2603 if (ctx->ExecuteFlag) {
2604 (*ctx->Exec->Ortho)( left, right, bottom, top, nearval, farval );
2605 }
2606 }
2607
2608
2609 static void GLAPIENTRY
2610 save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
2611 {
2612 GET_CURRENT_CONTEXT(ctx);
2613 Node *n;
2614 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2615 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_MAP, 3 );
2616 if (n) {
2617 n[1].e = map;
2618 n[2].i = mapsize;
2619 n[3].data = (void *) MALLOC( mapsize * sizeof(GLfloat) );
2620 MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
2621 }
2622 if (ctx->ExecuteFlag) {
2623 (*ctx->Exec->PixelMapfv)( map, mapsize, values );
2624 }
2625 }
2626
2627
2628 static void GLAPIENTRY
2629 save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
2630 {
2631 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2632 GLint i;
2633 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
2634 for (i=0;i<mapsize;i++) {
2635 fvalues[i] = (GLfloat) values[i];
2636 }
2637 }
2638 else {
2639 for (i=0;i<mapsize;i++) {
2640 fvalues[i] = UINT_TO_FLOAT( values[i] );
2641 }
2642 }
2643 save_PixelMapfv(map, mapsize, fvalues);
2644 }
2645
2646
2647 static void GLAPIENTRY
2648 save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
2649 {
2650 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2651 GLint i;
2652 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
2653 for (i=0;i<mapsize;i++) {
2654 fvalues[i] = (GLfloat) values[i];
2655 }
2656 }
2657 else {
2658 for (i=0;i<mapsize;i++) {
2659 fvalues[i] = USHORT_TO_FLOAT( values[i] );
2660 }
2661 }
2662 save_PixelMapfv(map, mapsize, fvalues);
2663 }
2664
2665
2666 static void GLAPIENTRY
2667 save_PixelTransferf( GLenum pname, GLfloat param )
2668 {
2669 GET_CURRENT_CONTEXT(ctx);
2670 Node *n;
2671 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2672 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TRANSFER, 2 );
2673 if (n) {
2674 n[1].e = pname;
2675 n[2].f = param;
2676 }
2677 if (ctx->ExecuteFlag) {
2678 (*ctx->Exec->PixelTransferf)( pname, param );
2679 }
2680 }
2681
2682
2683 static void GLAPIENTRY
2684 save_PixelTransferi( GLenum pname, GLint param )
2685 {
2686 save_PixelTransferf( pname, (GLfloat) param );
2687 }
2688
2689
2690 static void GLAPIENTRY
2691 save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
2692 {
2693 GET_CURRENT_CONTEXT(ctx);
2694 Node *n;
2695 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2696 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_ZOOM, 2 );
2697 if (n) {
2698 n[1].f = xfactor;
2699 n[2].f = yfactor;
2700 }
2701 if (ctx->ExecuteFlag) {
2702 (*ctx->Exec->PixelZoom)( xfactor, yfactor );
2703 }
2704 }
2705
2706
2707 static void GLAPIENTRY
2708 save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
2709 {
2710 GET_CURRENT_CONTEXT(ctx);
2711 Node *n;
2712 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2713 n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_PARAMETERS, 4 );
2714 if (n) {
2715 n[1].e = pname;
2716 n[2].f = params[0];
2717 n[3].f = params[1];
2718 n[4].f = params[2];
2719 }
2720 if (ctx->ExecuteFlag) {
2721 (*ctx->Exec->PointParameterfvEXT)( pname, params );
2722 }
2723 }
2724
2725
2726 static void GLAPIENTRY save_PointParameterfEXT( GLenum pname, GLfloat param )
2727 {
2728 save_PointParameterfvEXT(pname, &param);
2729 }
2730
2731 static void GLAPIENTRY save_PointParameteriNV( GLenum pname, GLint param )
2732 {
2733 GLfloat p = (GLfloat) param;
2734 save_PointParameterfvEXT(pname, &p);
2735 }
2736
2737 static void GLAPIENTRY save_PointParameterivNV( GLenum pname, const GLint *param )
2738 {
2739 GLfloat p = (GLfloat) param[0];
2740 save_PointParameterfvEXT(pname, &p);
2741 }
2742
2743
2744 static void GLAPIENTRY save_PointSize( GLfloat size )
2745 {
2746 GET_CURRENT_CONTEXT(ctx);
2747 Node *n;
2748 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2749 n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_SIZE, 1 );
2750 if (n) {
2751 n[1].f = size;
2752 }
2753 if (ctx->ExecuteFlag) {
2754 (*ctx->Exec->PointSize)( size );
2755 }
2756 }
2757
2758
2759 static void GLAPIENTRY save_PolygonMode( GLenum face, GLenum mode )
2760 {
2761 GET_CURRENT_CONTEXT(ctx);
2762 Node *n;
2763 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2764 n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_MODE, 2 );
2765 if (n) {
2766 n[1].e = face;
2767 n[2].e = mode;
2768 }
2769 if (ctx->ExecuteFlag) {
2770 (*ctx->Exec->PolygonMode)( face, mode );
2771 }
2772 }
2773
2774
2775 /*
2776 * Polygon stipple must have been upacked already!
2777 */
2778 static void GLAPIENTRY save_PolygonStipple( const GLubyte *pattern )
2779 {
2780 GET_CURRENT_CONTEXT(ctx);
2781 Node *n;
2782 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2783 n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_STIPPLE, 1 );
2784 if (n) {
2785 void *data;
2786 n[1].data = MALLOC( 32 * 4 );
2787 data = n[1].data; /* This needed for Acorn compiler */
2788 MEMCPY( data, pattern, 32 * 4 );
2789 }
2790 if (ctx->ExecuteFlag) {
2791 (*ctx->Exec->PolygonStipple)( (GLubyte*) pattern );
2792 }
2793 }
2794
2795
2796 static void GLAPIENTRY save_PolygonOffset( GLfloat factor, GLfloat units )
2797 {
2798 GET_CURRENT_CONTEXT(ctx);
2799 Node *n;
2800 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2801 n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_OFFSET, 2 );
2802 if (n) {
2803 n[1].f = factor;
2804 n[2].f = units;
2805 }
2806 if (ctx->ExecuteFlag) {
2807 (*ctx->Exec->PolygonOffset)( factor, units );
2808 }
2809 }
2810
2811
2812 static void GLAPIENTRY save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
2813 {
2814 GET_CURRENT_CONTEXT(ctx);
2815 save_PolygonOffset(factor, ctx->DepthMaxF * bias);
2816 }
2817
2818
2819 static void GLAPIENTRY save_PopAttrib( void )
2820 {
2821 GET_CURRENT_CONTEXT(ctx);
2822 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2823 (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_ATTRIB, 0 );
2824 if (ctx->ExecuteFlag) {
2825 (*ctx->Exec->PopAttrib)();
2826 }
2827 }
2828
2829
2830 static void GLAPIENTRY save_PopMatrix( void )
2831 {
2832 GET_CURRENT_CONTEXT(ctx);
2833 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2834 (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_MATRIX, 0 );
2835 if (ctx->ExecuteFlag) {
2836 (*ctx->Exec->PopMatrix)();
2837 }
2838 }
2839
2840
2841 static void GLAPIENTRY save_PopName( void )
2842 {
2843 GET_CURRENT_CONTEXT(ctx);
2844 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2845 (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_NAME, 0 );
2846 if (ctx->ExecuteFlag) {
2847 (*ctx->Exec->PopName)();
2848 }
2849 }
2850
2851
2852 static void GLAPIENTRY save_PrioritizeTextures( GLsizei num, const GLuint *textures,
2853 const GLclampf *priorities )
2854 {
2855 GET_CURRENT_CONTEXT(ctx);
2856 GLint i;
2857 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2858
2859 for (i=0;i<num;i++) {
2860 Node *n;
2861 n = ALLOC_INSTRUCTION( ctx, OPCODE_PRIORITIZE_TEXTURE, 2 );
2862 if (n) {
2863 n[1].ui = textures[i];
2864 n[2].f = priorities[i];
2865 }
2866 }
2867 if (ctx->ExecuteFlag) {
2868 (*ctx->Exec->PrioritizeTextures)( num, textures, priorities );
2869 }
2870 }
2871
2872
2873 static void GLAPIENTRY save_PushAttrib( GLbitfield mask )
2874 {
2875 GET_CURRENT_CONTEXT(ctx);
2876 Node *n;
2877 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2878 n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_ATTRIB, 1 );
2879 if (n) {
2880 n[1].bf = mask;
2881 }
2882 if (ctx->ExecuteFlag) {
2883 (*ctx->Exec->PushAttrib)( mask );
2884 }
2885 }
2886
2887
2888 static void GLAPIENTRY save_PushMatrix( void )
2889 {
2890 GET_CURRENT_CONTEXT(ctx);
2891 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2892 (void) ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_MATRIX, 0 );
2893 if (ctx->ExecuteFlag) {
2894 (*ctx->Exec->PushMatrix)();
2895 }
2896 }
2897
2898
2899 static void GLAPIENTRY save_PushName( GLuint name )
2900 {
2901 GET_CURRENT_CONTEXT(ctx);
2902 Node *n;
2903 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2904 n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_NAME, 1 );
2905 if (n) {
2906 n[1].ui = name;
2907 }
2908 if (ctx->ExecuteFlag) {
2909 (*ctx->Exec->PushName)( name );
2910 }
2911 }
2912
2913
2914 static void GLAPIENTRY save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
2915 {
2916 GET_CURRENT_CONTEXT(ctx);
2917 Node *n;
2918 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2919 n = ALLOC_INSTRUCTION( ctx, OPCODE_RASTER_POS, 4 );
2920 if (n) {
2921 n[1].f = x;
2922 n[2].f = y;
2923 n[3].f = z;
2924 n[4].f = w;
2925 }
2926 if (ctx->ExecuteFlag) {
2927 (*ctx->Exec->RasterPos4f)( x, y, z, w );
2928 }
2929 }
2930
2931 static void GLAPIENTRY save_RasterPos2d(GLdouble x, GLdouble y)
2932 {
2933 save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
2934 }
2935
2936 static void GLAPIENTRY save_RasterPos2f(GLfloat x, GLfloat y)
2937 {
2938 save_RasterPos4f(x, y, 0.0F, 1.0F);
2939 }
2940
2941 static void GLAPIENTRY save_RasterPos2i(GLint x, GLint y)
2942 {
2943 save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
2944 }
2945
2946 static void GLAPIENTRY save_RasterPos2s(GLshort x, GLshort y)
2947 {
2948 save_RasterPos4f(x, y, 0.0F, 1.0F);
2949 }
2950
2951 static void GLAPIENTRY save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
2952 {
2953 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
2954 }
2955
2956 static void GLAPIENTRY save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
2957 {
2958 save_RasterPos4f(x, y, z, 1.0F);
2959 }
2960
2961 static void GLAPIENTRY save_RasterPos3i(GLint x, GLint y, GLint z)
2962 {
2963 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
2964 }
2965
2966 static void GLAPIENTRY save_RasterPos3s(GLshort x, GLshort y, GLshort z)
2967 {
2968 save_RasterPos4f(x, y, z, 1.0F);
2969 }
2970
2971 static void GLAPIENTRY save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
2972 {
2973 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
2974 }
2975
2976 static void GLAPIENTRY save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
2977 {
2978 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
2979 }
2980
2981 static void GLAPIENTRY save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
2982 {
2983 save_RasterPos4f(x, y, z, w);
2984 }
2985
2986 static void GLAPIENTRY save_RasterPos2dv(const GLdouble *v)
2987 {
2988 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
2989 }
2990
2991 static void GLAPIENTRY save_RasterPos2fv(const GLfloat *v)
2992 {
2993 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2994 }
2995
2996 static void GLAPIENTRY save_RasterPos2iv(const GLint *v)
2997 {
2998 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
2999 }
3000
3001 static void GLAPIENTRY save_RasterPos2sv(const GLshort *v)
3002 {
3003 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
3004 }
3005
3006 static void GLAPIENTRY save_RasterPos3dv(const GLdouble *v)
3007 {
3008 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3009 }
3010
3011 static void GLAPIENTRY save_RasterPos3fv(const GLfloat *v)
3012 {
3013 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3014 }
3015
3016 static void GLAPIENTRY save_RasterPos3iv(const GLint *v)
3017 {
3018 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3019 }
3020
3021 static void GLAPIENTRY save_RasterPos3sv(const GLshort *v)
3022 {
3023 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3024 }
3025
3026 static void GLAPIENTRY save_RasterPos4dv(const GLdouble *v)
3027 {
3028 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3029 (GLfloat) v[2], (GLfloat) v[3]);
3030 }
3031
3032 static void GLAPIENTRY save_RasterPos4fv(const GLfloat *v)
3033 {
3034 save_RasterPos4f(v[0], v[1], v[2], v[3]);
3035 }
3036
3037 static void GLAPIENTRY save_RasterPos4iv(const GLint *v)
3038 {
3039 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3040 (GLfloat) v[2], (GLfloat) v[3]);
3041 }
3042
3043 static void GLAPIENTRY save_RasterPos4sv(const GLshort *v)
3044 {
3045 save_RasterPos4f(v[0], v[1], v[2], v[3]);
3046 }
3047
3048
3049 static void GLAPIENTRY save_PassThrough( GLfloat token )
3050 {
3051 GET_CURRENT_CONTEXT(ctx);
3052 Node *n;
3053 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3054 n = ALLOC_INSTRUCTION( ctx, OPCODE_PASSTHROUGH, 1 );
3055 if (n) {
3056 n[1].f = token;
3057 }
3058 if (ctx->ExecuteFlag) {
3059 (*ctx->Exec->PassThrough)( token );
3060 }
3061 }
3062
3063
3064 static void GLAPIENTRY save_ReadBuffer( GLenum mode )
3065 {
3066 GET_CURRENT_CONTEXT(ctx);
3067 Node *n;
3068 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3069 n = ALLOC_INSTRUCTION( ctx, OPCODE_READ_BUFFER, 1 );
3070 if (n) {
3071 n[1].e = mode;
3072 }
3073 if (ctx->ExecuteFlag) {
3074 (*ctx->Exec->ReadBuffer)( mode );
3075 }
3076 }
3077
3078
3079 static void GLAPIENTRY
3080 save_ResetHistogram(GLenum target)
3081 {
3082 GET_CURRENT_CONTEXT(ctx);
3083 Node *n;
3084 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3085 n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_HISTOGRAM, 1 );
3086 if (n) {
3087 n[1].e = target;
3088 }
3089 if (ctx->ExecuteFlag) {
3090 (*ctx->Exec->ResetHistogram)( target );
3091 }
3092 }
3093
3094
3095 static void GLAPIENTRY
3096 save_ResetMinmax(GLenum target)
3097 {
3098 GET_CURRENT_CONTEXT(ctx);
3099 Node *n;
3100 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3101 n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_MIN_MAX, 1 );
3102 if (n) {
3103 n[1].e = target;
3104 }
3105 if (ctx->ExecuteFlag) {
3106 (*ctx->Exec->ResetMinmax)( target );
3107 }
3108 }
3109
3110
3111 static void GLAPIENTRY save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
3112 {
3113 GET_CURRENT_CONTEXT(ctx);
3114 Node *n;
3115 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3116 n = ALLOC_INSTRUCTION( ctx, OPCODE_ROTATE, 4 );
3117 if (n) {
3118 n[1].f = angle;
3119 n[2].f = x;
3120 n[3].f = y;
3121 n[4].f = z;
3122 }
3123 if (ctx->ExecuteFlag) {
3124 (*ctx->Exec->Rotatef)( angle, x, y, z );
3125 }
3126 }
3127
3128
3129 static void GLAPIENTRY save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
3130 {
3131 save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
3132 }
3133
3134
3135 static void GLAPIENTRY save_Scalef( GLfloat x, GLfloat y, GLfloat z )
3136 {
3137 GET_CURRENT_CONTEXT(ctx);
3138 Node *n;
3139 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3140 n = ALLOC_INSTRUCTION( ctx, OPCODE_SCALE, 3 );
3141 if (n) {
3142 n[1].f = x;
3143 n[2].f = y;
3144 n[3].f = z;
3145 }
3146 if (ctx->ExecuteFlag) {
3147 (*ctx->Exec->Scalef)( x, y, z );
3148 }
3149 }
3150
3151
3152 static void GLAPIENTRY save_Scaled( GLdouble x, GLdouble y, GLdouble z )
3153 {
3154 save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
3155 }
3156
3157
3158 static void GLAPIENTRY save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
3159 {
3160 GET_CURRENT_CONTEXT(ctx);
3161 Node *n;
3162 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3163 n = ALLOC_INSTRUCTION( ctx, OPCODE_SCISSOR, 4 );
3164 if (n) {
3165 n[1].i = x;
3166 n[2].i = y;
3167 n[3].i = width;
3168 n[4].i = height;
3169 }
3170 if (ctx->ExecuteFlag) {
3171 (*ctx->Exec->Scissor)( x, y, width, height );
3172 }
3173 }
3174
3175
3176 static void GLAPIENTRY save_ShadeModel( GLenum mode )
3177 {
3178 GET_CURRENT_CONTEXT(ctx);
3179 Node *n;
3180 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3181 n = ALLOC_INSTRUCTION( ctx, OPCODE_SHADE_MODEL, 1 );
3182 if (n) {
3183 n[1].e = mode;
3184 }
3185 if (ctx->ExecuteFlag) {
3186 (*ctx->Exec->ShadeModel)( mode );
3187 }
3188 }
3189
3190
3191 static void GLAPIENTRY save_StencilFunc( GLenum func, GLint ref, GLuint mask )
3192 {
3193 GET_CURRENT_CONTEXT(ctx);
3194 Node *n;
3195 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3196 n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_FUNC, 3 );
3197 if (n) {
3198 n[1].e = func;
3199 n[2].i = ref;
3200 n[3].ui = mask;
3201 }
3202 if (ctx->ExecuteFlag) {
3203 (*ctx->Exec->StencilFunc)( func, ref, mask );
3204 }
3205 }
3206
3207
3208 static void GLAPIENTRY save_StencilMask( GLuint mask )
3209 {
3210 GET_CURRENT_CONTEXT(ctx);
3211 Node *n;
3212 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3213 n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_MASK, 1 );
3214 if (n) {
3215 n[1].ui = mask;
3216 }
3217 if (ctx->ExecuteFlag) {
3218 (*ctx->Exec->StencilMask)( mask );
3219 }
3220 }
3221
3222
3223 static void GLAPIENTRY save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
3224 {
3225 GET_CURRENT_CONTEXT(ctx);
3226 Node *n;
3227 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3228 n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_OP, 3 );
3229 if (n) {
3230 n[1].e = fail;
3231 n[2].e = zfail;
3232 n[3].e = zpass;
3233 }
3234 if (ctx->ExecuteFlag) {
3235 (*ctx->Exec->StencilOp)( fail, zfail, zpass );
3236 }
3237 }
3238
3239
3240 static void GLAPIENTRY save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
3241 {
3242 GET_CURRENT_CONTEXT(ctx);
3243 Node *n;
3244 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3245 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXENV, 6 );
3246 if (n) {
3247 n[1].e = target;
3248 n[2].e = pname;
3249 if (pname == GL_TEXTURE_ENV_COLOR) {
3250 n[3].f = params[0];
3251 n[4].f = params[1];
3252 n[5].f = params[2];
3253 n[6].f = params[3];
3254 }
3255 else {
3256 n[3].f = params[0];
3257 n[4].f = n[5].f = n[6].f = 0.0F;
3258 }
3259 }
3260 if (ctx->ExecuteFlag) {
3261 (*ctx->Exec->TexEnvfv)( target, pname, params );
3262 }
3263 }
3264
3265
3266 static void GLAPIENTRY save_TexEnvf( GLenum target, GLenum pname, GLfloat param )
3267 {
3268 save_TexEnvfv( target, pname, &param );
3269 }
3270
3271
3272 static void GLAPIENTRY save_TexEnvi( GLenum target, GLenum pname, GLint param )
3273 {
3274 GLfloat p[4];
3275 p[0] = (GLfloat) param;
3276 p[1] = p[2] = p[3] = 0.0;
3277 save_TexEnvfv( target, pname, p );
3278 }
3279
3280
3281 static void GLAPIENTRY save_TexEnviv( GLenum target, GLenum pname, const GLint *param )
3282 {
3283 GLfloat p[4];
3284 if (pname == GL_TEXTURE_ENV_COLOR) {
3285 p[0] = INT_TO_FLOAT( param[0] );
3286 p[1] = INT_TO_FLOAT( param[1] );
3287 p[2] = INT_TO_FLOAT( param[2] );
3288 p[3] = INT_TO_FLOAT( param[3] );
3289 }
3290 else {
3291 p[0] = (GLfloat) param[0];
3292 p[1] = p[2] = p[3] = 0.0F;
3293 }
3294 save_TexEnvfv( target, pname, p );
3295 }
3296
3297
3298 static void GLAPIENTRY save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
3299 {
3300 GET_CURRENT_CONTEXT(ctx);
3301 Node *n;
3302 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3303 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXGEN, 6 );
3304 if (n) {
3305 n[1].e = coord;
3306 n[2].e = pname;
3307 n[3].f = params[0];
3308 n[4].f = params[1];
3309 n[5].f = params[2];
3310 n[6].f = params[3];
3311 }
3312 if (ctx->ExecuteFlag) {
3313 (*ctx->Exec->TexGenfv)( coord, pname, params );
3314 }
3315 }
3316
3317
3318 static void GLAPIENTRY save_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
3319 {
3320 GLfloat p[4];
3321 p[0] = (GLfloat) params[0];
3322 p[1] = (GLfloat) params[1];
3323 p[2] = (GLfloat) params[2];
3324 p[3] = (GLfloat) params[3];
3325 save_TexGenfv(coord, pname, p);
3326 }
3327
3328
3329 static void GLAPIENTRY save_TexGend(GLenum coord, GLenum pname, GLdouble param )
3330 {
3331 GLfloat p = (GLfloat) param;
3332 save_TexGenfv( coord, pname, &p );
3333 }
3334
3335
3336 static void GLAPIENTRY save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
3337 {
3338 GLfloat p[4];
3339 p[0] = (GLfloat) params[0];
3340 p[1] = (GLfloat) params[1];
3341 p[2] = (GLfloat) params[2];
3342 p[3] = (GLfloat) params[3];
3343 save_TexGenfv( coord, pname, p );
3344 }
3345
3346
3347 static void GLAPIENTRY save_TexGenf( GLenum coord, GLenum pname, GLfloat param )
3348 {
3349 save_TexGenfv(coord, pname, &param);
3350 }
3351
3352
3353 static void GLAPIENTRY save_TexGeni( GLenum coord, GLenum pname, GLint param )
3354 {
3355 save_TexGeniv( coord, pname, &param );
3356 }
3357
3358
3359 static void GLAPIENTRY save_TexParameterfv( GLenum target,
3360 GLenum pname, const GLfloat *params )
3361 {
3362 GET_CURRENT_CONTEXT(ctx);
3363 Node *n;
3364 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3365 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXPARAMETER, 6 );
3366 if (n) {
3367 n[1].e = target;
3368 n[2].e = pname;
3369 n[3].f = params[0];
3370 n[4].f = params[1];
3371 n[5].f = params[2];
3372 n[6].f = params[3];
3373 }
3374 if (ctx->ExecuteFlag) {
3375 (*ctx->Exec->TexParameterfv)( target, pname, params );
3376 }
3377 }
3378
3379
3380 static void GLAPIENTRY save_TexParameterf( GLenum target, GLenum pname, GLfloat param )
3381 {
3382 save_TexParameterfv(target, pname, &param);
3383 }
3384
3385
3386 static void GLAPIENTRY save_TexParameteri( GLenum target, GLenum pname, GLint param )
3387 {
3388 GLfloat fparam[4];
3389 fparam[0] = (GLfloat) param;
3390 fparam[1] = fparam[2] = fparam[3] = 0.0;
3391 save_TexParameterfv(target, pname, fparam);
3392 }
3393
3394
3395 static void GLAPIENTRY save_TexParameteriv( GLenum target, GLenum pname, const GLint *params )
3396 {
3397 GLfloat fparam[4];
3398 fparam[0] = (GLfloat) params[0];
3399 fparam[1] = fparam[2] = fparam[3] = 0.0;
3400 save_TexParameterfv(target, pname, fparam);
3401 }
3402
3403
3404 static void GLAPIENTRY save_TexImage1D( GLenum target,
3405 GLint level, GLint components,
3406 GLsizei width, GLint border,
3407 GLenum format, GLenum type,
3408 const GLvoid *pixels )
3409 {
3410 GET_CURRENT_CONTEXT(ctx);
3411 if (target == GL_PROXY_TEXTURE_1D) {
3412 /* don't compile, execute immediately */
3413 (*ctx->Exec->TexImage1D)( target, level, components, width,
3414 border, format, type, pixels );
3415 }
3416 else {
3417 GLvoid *image = unpack_image(width, 1, 1, format, type,
3418 pixels, &ctx->Unpack);
3419 Node *n;
3420 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3421 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE1D, 8 );
3422 if (n) {
3423 n[1].e = target;
3424 n[2].i = level;
3425 n[3].i = components;
3426 n[4].i = (GLint) width;
3427 n[5].i = border;
3428 n[6].e = format;
3429 n[7].e = type;
3430 n[8].data = image;
3431 }
3432 else if (image) {
3433 FREE(image);
3434 }
3435 if (ctx->ExecuteFlag) {
3436 (*ctx->Exec->TexImage1D)( target, level, components, width,
3437 border, format, type, pixels );
3438 }
3439 }
3440 }
3441
3442
3443 static void GLAPIENTRY save_TexImage2D( GLenum target,
3444 GLint level, GLint components,
3445 GLsizei width, GLsizei height, GLint border,
3446 GLenum format, GLenum type,
3447 const GLvoid *pixels)
3448 {
3449 GET_CURRENT_CONTEXT(ctx);
3450 if (target == GL_PROXY_TEXTURE_2D) {
3451 /* don't compile, execute immediately */
3452 (*ctx->Exec->TexImage2D)( target, level, components, width,
3453 height, border, format, type, pixels );
3454 }
3455 else {
3456 GLvoid *image = unpack_image(width, height, 1, format, type,
3457 pixels, &ctx->Unpack);
3458 Node *n;
3459 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3460 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE2D, 9 );
3461 if (n) {
3462 n[1].e = target;
3463 n[2].i = level;
3464 n[3].i = components;
3465 n[4].i = (GLint) width;
3466 n[5].i = (GLint) height;
3467 n[6].i = border;
3468 n[7].e = format;
3469 n[8].e = type;
3470 n[9].data = image;
3471 }
3472 else if (image) {
3473 FREE(image);
3474 }
3475 if (ctx->ExecuteFlag) {
3476 (*ctx->Exec->TexImage2D)( target, level, components, width,
3477 height, border, format, type, pixels );
3478 }
3479 }
3480 }
3481
3482
3483 static void GLAPIENTRY save_TexImage3D( GLenum target,
3484 GLint level, GLint internalFormat,
3485 GLsizei width, GLsizei height, GLsizei depth,
3486 GLint border,
3487 GLenum format, GLenum type,
3488 const GLvoid *pixels )
3489 {
3490 GET_CURRENT_CONTEXT(ctx);
3491 if (target == GL_PROXY_TEXTURE_3D) {
3492 /* don't compile, execute immediately */
3493 (*ctx->Exec->TexImage3D)( target, level, internalFormat, width,
3494 height, depth, border, format, type, pixels );
3495 }
3496 else {
3497 Node *n;
3498 GLvoid *image = unpack_image(width, height, depth, format, type,
3499 pixels, &ctx->Unpack);
3500 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3501 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE3D, 10 );
3502 if (n) {
3503 n[1].e = target;
3504 n[2].i = level;
3505 n[3].i = (GLint) internalFormat;
3506 n[4].i = (GLint) width;
3507 n[5].i = (GLint) height;
3508 n[6].i = (GLint) depth;
3509 n[7].i = border;
3510 n[8].e = format;
3511 n[9].e = type;
3512 n[10].data = image;
3513 }
3514 else if (image) {
3515 FREE(image);
3516 }
3517 if (ctx->ExecuteFlag) {
3518 (*ctx->Exec->TexImage3D)( target, level, internalFormat, width,
3519 height, depth, border, format, type, pixels );
3520 }
3521 }
3522 }
3523
3524
3525 static void GLAPIENTRY save_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
3526 GLsizei width, GLenum format, GLenum type,
3527 const GLvoid *pixels )
3528 {
3529 GET_CURRENT_CONTEXT(ctx);
3530 Node *n;
3531 GLvoid *image = unpack_image(width, 1, 1, format, type,
3532 pixels, &ctx->Unpack);
3533 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3534 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
3535 if (n) {
3536 n[1].e = target;
3537 n[2].i = level;
3538 n[3].i = xoffset;
3539 n[4].i = (GLint) width;
3540 n[5].e = format;
3541 n[6].e = type;
3542 n[7].data = image;
3543 }
3544 else if (image) {
3545 FREE(image);
3546 }
3547 if (ctx->ExecuteFlag) {
3548 (*ctx->Exec->TexSubImage1D)( target, level, xoffset, width,
3549 format, type, pixels );
3550 }
3551 }
3552
3553
3554 static void GLAPIENTRY save_TexSubImage2D( GLenum target, GLint level,
3555 GLint xoffset, GLint yoffset,
3556 GLsizei width, GLsizei height,
3557 GLenum format, GLenum type,
3558 const GLvoid *pixels )
3559 {
3560 GET_CURRENT_CONTEXT(ctx);
3561 Node *n;
3562 GLvoid *image = unpack_image(width, height, 1, format, type,
3563 pixels, &ctx->Unpack);
3564 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3565 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
3566 if (n) {
3567 n[1].e = target;
3568 n[2].i = level;
3569 n[3].i = xoffset;
3570 n[4].i = yoffset;
3571 n[5].i = (GLint) width;
3572 n[6].i = (GLint) height;
3573 n[7].e = format;
3574 n[8].e = type;
3575 n[9].data = image;
3576 }
3577 else if (image) {
3578 FREE(image);
3579 }
3580 if (ctx->ExecuteFlag) {
3581 (*ctx->Exec->TexSubImage2D)( target, level, xoffset, yoffset,
3582 width, height, format, type, pixels );
3583 }
3584 }
3585
3586
3587 static void GLAPIENTRY save_TexSubImage3D( GLenum target, GLint level,
3588 GLint xoffset, GLint yoffset,GLint zoffset,
3589 GLsizei width, GLsizei height, GLsizei depth,
3590 GLenum format, GLenum type,
3591 const GLvoid *pixels )
3592 {
3593 GET_CURRENT_CONTEXT(ctx);
3594 Node *n;
3595 GLvoid *image = unpack_image(width, height, depth, format, type,
3596 pixels, &ctx->Unpack);
3597 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3598 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
3599 if (n) {
3600 n[1].e = target;
3601 n[2].i = level;
3602 n[3].i = xoffset;
3603 n[4].i = yoffset;
3604 n[5].i = zoffset;
3605 n[6].i = (GLint) width;
3606 n[7].i = (GLint) height;
3607 n[8].i = (GLint) depth;
3608 n[9].e = format;
3609 n[10].e = type;
3610 n[11].data = image;
3611 }
3612 else if (image) {
3613 FREE(image);
3614 }
3615 if (ctx->ExecuteFlag) {
3616 (*ctx->Exec->TexSubImage3D)( target, level,
3617 xoffset, yoffset, zoffset,
3618 width, height, depth, format, type, pixels );
3619 }
3620 }
3621
3622
3623 static void GLAPIENTRY save_Translatef( GLfloat x, GLfloat y, GLfloat z )
3624 {
3625 GET_CURRENT_CONTEXT(ctx);
3626 Node *n;
3627 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3628 n = ALLOC_INSTRUCTION( ctx, OPCODE_TRANSLATE, 3 );
3629 if (n) {
3630 n[1].f = x;
3631 n[2].f = y;
3632 n[3].f = z;
3633 }
3634 if (ctx->ExecuteFlag) {
3635 (*ctx->Exec->Translatef)( x, y, z );
3636 }
3637 }
3638
3639
3640 static void GLAPIENTRY save_Translated( GLdouble x, GLdouble y, GLdouble z )
3641 {
3642 save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
3643 }
3644
3645
3646
3647 static void GLAPIENTRY save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
3648 {
3649 GET_CURRENT_CONTEXT(ctx);
3650 Node *n;
3651 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3652 n = ALLOC_INSTRUCTION( ctx, OPCODE_VIEWPORT, 4 );
3653 if (n) {
3654 n[1].i = x;
3655 n[2].i = y;
3656 n[3].i = (GLint) width;
3657 n[4].i = (GLint) height;
3658 }
3659 if (ctx->ExecuteFlag) {
3660 (*ctx->Exec->Viewport)( x, y, width, height );
3661 }
3662 }
3663
3664
3665 static void GLAPIENTRY save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
3666 {
3667 GET_CURRENT_CONTEXT(ctx);
3668 Node *n;
3669 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3670 n = ALLOC_INSTRUCTION( ctx, OPCODE_WINDOW_POS, 4 );
3671 if (n) {
3672 n[1].f = x;
3673 n[2].f = y;
3674 n[3].f = z;
3675 n[4].f = w;
3676 }
3677 if (ctx->ExecuteFlag) {
3678 (*ctx->Exec->WindowPos4fMESA)( x, y, z, w );
3679 }
3680 }
3681
3682 static void GLAPIENTRY save_WindowPos2dMESA(GLdouble x, GLdouble y)
3683 {
3684 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3685 }
3686
3687 static void GLAPIENTRY save_WindowPos2fMESA(GLfloat x, GLfloat y)
3688 {
3689 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3690 }
3691
3692 static void GLAPIENTRY save_WindowPos2iMESA(GLint x, GLint y)
3693 {
3694 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3695 }
3696
3697 static void GLAPIENTRY save_WindowPos2sMESA(GLshort x, GLshort y)
3698 {
3699 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3700 }
3701
3702 static void GLAPIENTRY save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
3703 {
3704 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3705 }
3706
3707 static void GLAPIENTRY save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
3708 {
3709 save_WindowPos4fMESA(x, y, z, 1.0F);
3710 }
3711
3712 static void GLAPIENTRY save_WindowPos3iMESA(GLint x, GLint y, GLint z)
3713 {
3714 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3715 }
3716
3717 static void GLAPIENTRY save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
3718 {
3719 save_WindowPos4fMESA(x, y, z, 1.0F);
3720 }
3721
3722 static void GLAPIENTRY save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3723 {
3724 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3725 }
3726
3727 static void GLAPIENTRY save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
3728 {
3729 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3730 }
3731
3732 static void GLAPIENTRY save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
3733 {
3734 save_WindowPos4fMESA(x, y, z, w);
3735 }
3736
3737 static void GLAPIENTRY save_WindowPos2dvMESA(const GLdouble *v)
3738 {
3739 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3740 }
3741
3742 static void GLAPIENTRY save_WindowPos2fvMESA(const GLfloat *v)
3743 {
3744 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3745 }
3746
3747 static void GLAPIENTRY save_WindowPos2ivMESA(const GLint *v)
3748 {
3749 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3750 }
3751
3752 static void GLAPIENTRY save_WindowPos2svMESA(const GLshort *v)
3753 {
3754 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3755 }
3756
3757 static void GLAPIENTRY save_WindowPos3dvMESA(const GLdouble *v)
3758 {
3759 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3760 }
3761
3762 static void GLAPIENTRY save_WindowPos3fvMESA(const GLfloat *v)
3763 {
3764 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3765 }
3766
3767 static void GLAPIENTRY save_WindowPos3ivMESA(const GLint *v)
3768 {
3769 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3770 }
3771
3772 static void GLAPIENTRY save_WindowPos3svMESA(const GLshort *v)
3773 {
3774 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3775 }
3776
3777 static void GLAPIENTRY save_WindowPos4dvMESA(const GLdouble *v)
3778 {
3779 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
3780 (GLfloat) v[2], (GLfloat) v[3]);
3781 }
3782
3783 static void GLAPIENTRY save_WindowPos4fvMESA(const GLfloat *v)
3784 {
3785 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3786 }
3787
3788 static void GLAPIENTRY save_WindowPos4ivMESA(const GLint *v)
3789 {
3790 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
3791 (GLfloat) v[2], (GLfloat) v[3]);
3792 }
3793
3794 static void GLAPIENTRY save_WindowPos4svMESA(const GLshort *v)
3795 {
3796 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3797 }
3798
3799
3800
3801 /* GL_ARB_multitexture */
3802 static void GLAPIENTRY save_ActiveTextureARB( GLenum target )
3803 {
3804 GET_CURRENT_CONTEXT(ctx);
3805 Node *n;
3806 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3807 n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
3808 if (n) {
3809 n[1].e = target;
3810 }
3811 if (ctx->ExecuteFlag) {
3812 (*ctx->Exec->ActiveTextureARB)( target );
3813 }
3814 }
3815
3816
3817 /* GL_ARB_transpose_matrix */
3818
3819 static void GLAPIENTRY save_LoadTransposeMatrixdARB( const GLdouble m[16] )
3820 {
3821 GLfloat tm[16];
3822 _math_transposefd(tm, m);
3823 save_LoadMatrixf(tm);
3824 }
3825
3826
3827 static void GLAPIENTRY save_LoadTransposeMatrixfARB( const GLfloat m[16] )
3828 {
3829 GLfloat tm[16];
3830 _math_transposef(tm, m);
3831 save_LoadMatrixf(tm);
3832 }
3833
3834
3835 static void GLAPIENTRY
3836 save_MultTransposeMatrixdARB( const GLdouble m[16] )
3837 {
3838 GLfloat tm[16];
3839 _math_transposefd(tm, m);
3840 save_MultMatrixf(tm);
3841 }
3842
3843
3844 static void GLAPIENTRY
3845 save_MultTransposeMatrixfARB( const GLfloat m[16] )
3846 {
3847 GLfloat tm[16];
3848 _math_transposef(tm, m);
3849 save_MultMatrixf(tm);
3850 }
3851
3852
3853 static void GLAPIENTRY
3854 save_PixelTexGenSGIX(GLenum mode)
3855 {
3856 GET_CURRENT_CONTEXT(ctx);
3857 Node *n;
3858 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3859 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_SGIX, 1 );
3860 if (n) {
3861 n[1].e = mode;
3862 }
3863 if (ctx->ExecuteFlag) {
3864 (*ctx->Exec->PixelTexGenSGIX)( mode );
3865 }
3866 }
3867
3868
3869 /* GL_ARB_texture_compression */
3870 static void GLAPIENTRY
3871 save_CompressedTexImage1DARB(GLenum target, GLint level,
3872 GLenum internalFormat, GLsizei width,
3873 GLint border, GLsizei imageSize,
3874 const GLvoid *data)
3875 {
3876 GET_CURRENT_CONTEXT(ctx);
3877 if (target == GL_PROXY_TEXTURE_1D) {
3878 /* don't compile, execute immediately */
3879 (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat,
3880 width, border, imageSize, data);
3881 }
3882 else {
3883 Node *n;
3884 GLvoid *image;
3885 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3886 /* make copy of image */
3887 image = MALLOC(imageSize);
3888 if (!image) {
3889 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
3890 return;
3891 }
3892 MEMCPY(image, data, imageSize);
3893 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7 );
3894 if (n) {
3895 n[1].e = target;
3896 n[2].i = level;
3897 n[3].e = internalFormat;
3898 n[4].i = (GLint) width;
3899 n[5].i = border;
3900 n[6].i = imageSize;
3901 n[7].data = image;
3902 }
3903 else if (image) {
3904 FREE(image);
3905 }
3906 if (ctx->ExecuteFlag) {
3907 (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat,
3908 width, border, imageSize, data);
3909 }
3910 }
3911 }
3912
3913
3914 static void GLAPIENTRY
3915 save_CompressedTexImage2DARB(GLenum target, GLint level,
3916 GLenum internalFormat, GLsizei width,
3917 GLsizei height, GLint border, GLsizei imageSize,
3918 const GLvoid *data)
3919 {
3920 GET_CURRENT_CONTEXT(ctx);
3921 if (target == GL_PROXY_TEXTURE_2D) {
3922 /* don't compile, execute immediately */
3923 (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat,
3924 width, height, border, imageSize, data);
3925 }
3926 else {
3927 Node *n;
3928 GLvoid *image;
3929 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3930 /* make copy of image */
3931 image = MALLOC(imageSize);
3932 if (!image) {
3933 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
3934 return;
3935 }
3936 MEMCPY(image, data, imageSize);
3937 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8 );
3938 if (n) {
3939 n[1].e = target;
3940 n[2].i = level;
3941 n[3].e = internalFormat;
3942 n[4].i = (GLint) width;
3943 n[5].i = (GLint) height;
3944 n[6].i = border;
3945 n[7].i = imageSize;
3946 n[8].data = image;
3947 }
3948 else if (image) {
3949 FREE(image);
3950 }
3951 if (ctx->ExecuteFlag) {
3952 (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat,
3953 width, height, border, imageSize, data);
3954 }
3955 }
3956 }
3957
3958
3959 static void GLAPIENTRY
3960 save_CompressedTexImage3DARB(GLenum target, GLint level,
3961 GLenum internalFormat, GLsizei width,
3962 GLsizei height, GLsizei depth, GLint border,
3963 GLsizei imageSize, const GLvoid *data)
3964 {
3965 GET_CURRENT_CONTEXT(ctx);
3966 if (target == GL_PROXY_TEXTURE_3D) {
3967 /* don't compile, execute immediately */
3968 (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat,
3969 width, height, depth, border, imageSize, data);
3970 }
3971 else {
3972 Node *n;
3973 GLvoid *image;
3974 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3975 /* make copy of image */
3976 image = MALLOC(imageSize);
3977 if (!image) {
3978 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
3979 return;
3980 }
3981 MEMCPY(image, data, imageSize);
3982 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9 );
3983 if (n) {
3984 n[1].e = target;
3985 n[2].i = level;
3986 n[3].e = internalFormat;
3987 n[4].i = (GLint) width;
3988 n[5].i = (GLint) height;
3989 n[6].i = (GLint) depth;
3990 n[7].i = border;
3991 n[8].i = imageSize;
3992 n[9].data = image;
3993 }
3994 else if (image) {
3995 FREE(image);
3996 }
3997 if (ctx->ExecuteFlag) {
3998 (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat,
3999 width, height, depth, border, imageSize, data);
4000 }
4001 }
4002 }
4003
4004
4005 static void GLAPIENTRY
4006 save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
4007 GLsizei width, GLenum format,
4008 GLsizei imageSize, const GLvoid *data)
4009 {
4010 Node *n;
4011 GLvoid *image;
4012
4013 GET_CURRENT_CONTEXT(ctx);
4014 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4015
4016 /* make copy of image */
4017 image = MALLOC(imageSize);
4018 if (!image) {
4019 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
4020 return;
4021 }
4022 MEMCPY(image, data, imageSize);
4023 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7 );
4024 if (n) {
4025 n[1].e = target;
4026 n[2].i = level;
4027 n[3].i = xoffset;
4028 n[4].i = (GLint) width;
4029 n[5].e = format;
4030 n[6].i = imageSize;
4031 n[7].data = image;
4032 }
4033 else if (image) {
4034 FREE(image);
4035 }
4036 if (ctx->ExecuteFlag) {
4037 (*ctx->Exec->CompressedTexSubImage1DARB)(target, level, xoffset,
4038 width, format, imageSize, data);
4039 }
4040 }
4041
4042
4043 static void GLAPIENTRY
4044 save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
4045 GLint yoffset, GLsizei width, GLsizei height,
4046 GLenum format, GLsizei imageSize,
4047 const GLvoid *data)
4048 {
4049 Node *n;
4050 GLvoid *image;
4051
4052 GET_CURRENT_CONTEXT(ctx);
4053 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4054
4055 /* make copy of image */
4056 image = MALLOC(imageSize);
4057 if (!image) {
4058 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
4059 return;
4060 }
4061 MEMCPY(image, data, imageSize);
4062 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9 );
4063 if (n) {
4064 n[1].e = target;
4065 n[2].i = level;
4066 n[3].i = xoffset;
4067 n[4].i = yoffset;
4068 n[5].i = (GLint) width;
4069 n[6].i = (GLint) height;
4070 n[7].e = format;
4071 n[8].i = imageSize;
4072 n[9].data = image;
4073 }
4074 else if (image) {
4075 FREE(image);
4076 }
4077 if (ctx->ExecuteFlag) {
4078 (*ctx->Exec->CompressedTexSubImage2DARB)(target, level, xoffset, yoffset,
4079 width, height, format, imageSize, data);
4080 }
4081 }
4082
4083
4084 static void GLAPIENTRY
4085 save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
4086 GLint yoffset, GLint zoffset, GLsizei width,
4087 GLsizei height, GLsizei depth, GLenum format,
4088 GLsizei imageSize, const GLvoid *data)
4089 {
4090 Node *n;
4091 GLvoid *image;
4092
4093 GET_CURRENT_CONTEXT(ctx);
4094 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4095
4096 /* make copy of image */
4097 image = MALLOC(imageSize);
4098 if (!image) {
4099 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
4100 return;
4101 }
4102 MEMCPY(image, data, imageSize);
4103 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11 );
4104 if (n) {
4105 n[1].e = target;
4106 n[2].i = level;
4107 n[3].i = xoffset;
4108 n[4].i = yoffset;
4109 n[5].i = zoffset;
4110 n[6].i = (GLint) width;
4111 n[7].i = (GLint) height;
4112 n[8].i = (GLint) depth;
4113 n[9].e = format;
4114 n[10].i = imageSize;
4115 n[11].data = image;
4116 }
4117 else if (image) {
4118 FREE(image);
4119 }
4120 if (ctx->ExecuteFlag) {
4121 (*ctx->Exec->CompressedTexSubImage3DARB)(target, level, xoffset, yoffset,
4122 zoffset, width, height, depth, format, imageSize, data);
4123 }
4124 }
4125
4126
4127 /* GL_ARB_multisample */
4128 static void GLAPIENTRY
4129 save_SampleCoverageARB(GLclampf value, GLboolean invert)
4130 {
4131 GET_CURRENT_CONTEXT(ctx);
4132 Node *n;
4133 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4134 n = ALLOC_INSTRUCTION( ctx, OPCODE_SAMPLE_COVERAGE, 2 );
4135 if (n) {
4136 n[1].f = value;
4137 n[2].b = invert;
4138 }
4139 if (ctx->ExecuteFlag) {
4140 (*ctx->Exec->SampleCoverageARB)( value, invert );
4141 }
4142 }
4143
4144
4145 /* GL_SGIS_pixel_texture */
4146
4147 static void GLAPIENTRY
4148 save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
4149 {
4150 GET_CURRENT_CONTEXT(ctx);
4151 Node *n;
4152 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4153 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, 2 );
4154 if (n) {
4155 n[1].e = target;
4156 n[2].i = value;
4157 }
4158 if (ctx->ExecuteFlag) {
4159 (*ctx->Exec->PixelTexGenParameteriSGIS)( target, value );
4160 }
4161 }
4162
4163
4164 static void GLAPIENTRY
4165 save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
4166 {
4167 save_PixelTexGenParameteriSGIS(target, (GLint) value);
4168 }
4169
4170
4171 static void GLAPIENTRY
4172 save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
4173 {
4174 save_PixelTexGenParameteriSGIS(target, *value);
4175 }
4176
4177
4178 static void GLAPIENTRY
4179 save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
4180 {
4181 save_PixelTexGenParameteriSGIS(target, (GLint) *value);
4182 }
4183
4184
4185 /*
4186 * GL_NV_vertex_program
4187 */
4188 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
4189 static void GLAPIENTRY
4190 save_BindProgramNV(GLenum target, GLuint id)
4191 {
4192 GET_CURRENT_CONTEXT(ctx);
4193 Node *n;
4194 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4195 n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_PROGRAM_NV, 2 );
4196 if (n) {
4197 n[1].e = target;
4198 n[2].ui = id;
4199 }
4200 if (ctx->ExecuteFlag) {
4201 (*ctx->Exec->BindProgramNV)( target, id );
4202 }
4203 }
4204 #endif /* FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
4205
4206 #if FEATURE_NV_vertex_program
4207 static void GLAPIENTRY
4208 save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
4209 {
4210 GET_CURRENT_CONTEXT(ctx);
4211 Node *n;
4212 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4213 n = ALLOC_INSTRUCTION( ctx, OPCODE_EXECUTE_PROGRAM_NV, 6 );
4214 if (n) {
4215 n[1].e = target;
4216 n[2].ui = id;
4217 n[3].f = params[0];
4218 n[4].f = params[1];
4219 n[5].f = params[2];
4220 n[6].f = params[3];
4221 }
4222 if (ctx->ExecuteFlag) {
4223 (*ctx->Exec->ExecuteProgramNV)(target, id, params);
4224 }
4225 }
4226
4227
4228 static void GLAPIENTRY
4229 save_ProgramParameter4fNV(GLenum target, GLuint index,
4230 GLfloat x, GLfloat y,
4231 GLfloat z, GLfloat w)
4232 {
4233 GET_CURRENT_CONTEXT(ctx);
4234 Node *n;
4235 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4236 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_PARAMETER4F_NV, 6 );
4237 if (n) {
4238 n[1].e = target;
4239 n[2].ui = index;
4240 n[3].f = x;
4241 n[4].f = y;
4242 n[5].f = z;
4243 n[6].f = w;
4244 }
4245 if (ctx->ExecuteFlag) {
4246 (*ctx->Exec->ProgramParameter4fNV)(target, index, x, y, z, w);
4247 }
4248 }
4249
4250
4251 static void GLAPIENTRY
4252 save_ProgramParameter4fvNV(GLenum target, GLuint index, const GLfloat *params)
4253 {
4254 save_ProgramParameter4fNV(target, index, params[0], params[1],
4255 params[2], params[3]);
4256 }
4257
4258
4259 static void GLAPIENTRY
4260 save_ProgramParameter4dNV(GLenum target, GLuint index,
4261 GLdouble x, GLdouble y,
4262 GLdouble z, GLdouble w)
4263 {
4264 save_ProgramParameter4fNV(target, index, (GLfloat) x, (GLfloat) y,
4265 (GLfloat) z, (GLfloat) w);
4266 }
4267
4268
4269 static void GLAPIENTRY
4270 save_ProgramParameter4dvNV(GLenum target, GLuint index,
4271 const GLdouble *params)
4272 {
4273 save_ProgramParameter4fNV(target, index, (GLfloat) params[0],
4274 (GLfloat) params[1], (GLfloat) params[2],
4275 (GLfloat) params[3]);
4276 }
4277
4278
4279 static void GLAPIENTRY
4280 save_ProgramParameters4dvNV(GLenum target, GLuint index,
4281 GLuint num, const GLdouble *params)
4282 {
4283 GLuint i;
4284 for (i = 0; i < num; i++) {
4285 save_ProgramParameter4dvNV(target, index + i, params + 4 * i);
4286 }
4287 }
4288
4289
4290 static void GLAPIENTRY
4291 save_ProgramParameters4fvNV(GLenum target, GLuint index,
4292 GLuint num, const GLfloat *params)
4293 {
4294 GLuint i;
4295 for (i = 0; i < num; i++) {
4296 save_ProgramParameter4fvNV(target, index + i, params + 4 * i);
4297 }
4298 }
4299
4300
4301 static void GLAPIENTRY
4302 save_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
4303 const GLubyte *program)
4304 {
4305 GET_CURRENT_CONTEXT(ctx);
4306 Node *n;
4307 GLubyte *programCopy;
4308
4309 programCopy = (GLubyte *) _mesa_malloc(len);
4310 if (!programCopy) {
4311 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
4312 return;
4313 }
4314 _mesa_memcpy(programCopy, program, len);
4315
4316 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4317 n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_PROGRAM_NV, 4 );
4318 if (n) {
4319 n[1].e = target;
4320 n[2].ui = id;
4321 n[3].i = len;
4322 n[4].data = programCopy;
4323 }
4324 if (ctx->ExecuteFlag) {
4325 (*ctx->Exec->LoadProgramNV)(target, id, len, program);
4326 }
4327 }
4328
4329
4330 static void GLAPIENTRY
4331 save_RequestResidentProgramsNV(GLsizei num, const GLuint *ids)
4332 {
4333 GET_CURRENT_CONTEXT(ctx);
4334 Node *n;
4335 GLuint *idCopy = (GLuint *) _mesa_malloc(num * sizeof(GLuint));
4336 if (!idCopy) {
4337 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV");
4338 return;
4339 }
4340 _mesa_memcpy(idCopy, ids, num * sizeof(GLuint));
4341 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4342 n = ALLOC_INSTRUCTION( ctx, OPCODE_TRACK_MATRIX_NV, 2 );
4343 if (n) {
4344 n[1].i = num;
4345 n[2].data = idCopy;
4346 }
4347 if (ctx->ExecuteFlag) {
4348 (*ctx->Exec->RequestResidentProgramsNV)(num, ids);
4349 }
4350 }
4351
4352
4353 static void GLAPIENTRY
4354 save_TrackMatrixNV(GLenum target, GLuint address,
4355 GLenum matrix, GLenum transform)
4356 {
4357 GET_CURRENT_CONTEXT(ctx);
4358 Node *n;
4359 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4360 n = ALLOC_INSTRUCTION( ctx, OPCODE_TRACK_MATRIX_NV, 4 );
4361 if (n) {
4362 n[1].e = target;
4363 n[2].ui = address;
4364 n[3].e = matrix;
4365 n[4].e = transform;
4366 }
4367 if (ctx->ExecuteFlag) {
4368 (*ctx->Exec->TrackMatrixNV)(target, address, matrix, transform);
4369 }
4370 }
4371 #endif /* FEATURE_NV_vertex_program */
4372
4373
4374 /*
4375 * GL_NV_fragment_program
4376 */
4377 #if FEATURE_NV_fragment_program
4378 static void GLAPIENTRY
4379 save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
4380 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4381 {
4382 GET_CURRENT_CONTEXT(ctx);
4383 Node *n;
4384 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4385 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
4386 if (n) {
4387 n[1].e = target;
4388 n[2].ui = index;
4389 n[3].f = x;
4390 n[4].f = y;
4391 n[5].f = z;
4392 n[6].f = w;
4393 }
4394 if (ctx->ExecuteFlag) {
4395 (*ctx->Exec->ProgramLocalParameter4fARB)(target, index, x, y, z, w);
4396 }
4397 }
4398
4399
4400 static void GLAPIENTRY
4401 save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
4402 const GLfloat *params)
4403 {
4404 GET_CURRENT_CONTEXT(ctx);
4405 Node *n;
4406 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4407 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
4408 if (n) {
4409 n[1].e = target;
4410 n[2].ui = index;
4411 n[3].f = params[0];
4412 n[4].f = params[1];
4413 n[5].f = params[2];
4414 n[6].f = params[3];
4415 }
4416 if (ctx->ExecuteFlag) {
4417 (*ctx->Exec->ProgramLocalParameter4fvARB)(target, index, params);
4418 }
4419 }
4420
4421
4422 static void GLAPIENTRY
4423 save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
4424 GLdouble x, GLdouble y,
4425 GLdouble z, GLdouble w)
4426 {
4427 GET_CURRENT_CONTEXT(ctx);
4428 Node *n;
4429 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4430 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
4431 if (n) {
4432 n[1].e = target;
4433 n[2].ui = index;
4434 n[3].f = (GLfloat) x;
4435 n[4].f = (GLfloat) y;
4436 n[5].f = (GLfloat) z;
4437 n[6].f = (GLfloat) w;
4438 }
4439 if (ctx->ExecuteFlag) {
4440 (*ctx->Exec->ProgramLocalParameter4dARB)(target, index, x, y, z, w);
4441 }
4442 }
4443
4444
4445 static void GLAPIENTRY
4446 save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
4447 const GLdouble *params)
4448 {
4449 GET_CURRENT_CONTEXT(ctx);
4450 Node *n;
4451 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4452 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
4453 if (n) {
4454 n[1].e = target;
4455 n[2].ui = index;
4456 n[3].f = (GLfloat) params[0];
4457 n[4].f = (GLfloat) params[1];
4458 n[5].f = (GLfloat) params[2];
4459 n[6].f = (GLfloat) params[3];
4460 }
4461 if (ctx->ExecuteFlag) {
4462 (*ctx->Exec->ProgramLocalParameter4dvARB)(target, index, params);
4463 }
4464 }
4465
4466 static void GLAPIENTRY
4467 save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
4468 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4469 {
4470 GET_CURRENT_CONTEXT(ctx);
4471 Node *n;
4472 GLubyte *nameCopy = (GLubyte *) _mesa_malloc(len);
4473 if (!nameCopy) {
4474 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV");
4475 return;
4476 }
4477 _mesa_memcpy(nameCopy, name, len);
4478
4479 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4480 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6 );
4481 if (n) {
4482 n[1].ui = id;
4483 n[2].i = len;
4484 n[3].data = nameCopy;
4485 n[4].f = x;
4486 n[5].f = y;
4487 n[6].f = z;
4488 n[7].f = w;
4489 }
4490 if (ctx->ExecuteFlag) {
4491 (*ctx->Exec->ProgramNamedParameter4fNV)(id, len, name, x, y, z, w);
4492 }
4493 }
4494
4495
4496 static void GLAPIENTRY
4497 save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name,
4498 const float v[])
4499 {
4500 save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]);
4501 }
4502
4503
4504 static void GLAPIENTRY
4505 save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name,
4506 GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4507 {
4508 save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y,
4509 (GLfloat) z,(GLfloat) w);
4510 }
4511
4512
4513 static void GLAPIENTRY
4514 save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name,
4515 const double v[])
4516 {
4517 save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0],
4518 (GLfloat) v[1], (GLfloat) v[2],
4519 (GLfloat) v[3]);
4520 }
4521
4522 #endif /* FEATURE_NV_fragment_program */
4523
4524
4525
4526 /* GL_EXT_stencil_two_side */
4527 static void GLAPIENTRY save_ActiveStencilFaceEXT( GLenum face )
4528 {
4529 GET_CURRENT_CONTEXT(ctx);
4530 Node *n;
4531 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4532 n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1 );
4533 if (n) {
4534 n[1].e = face;
4535 }
4536 if (ctx->ExecuteFlag) {
4537 (*ctx->Exec->ActiveStencilFaceEXT)( face );
4538 }
4539 }
4540
4541
4542 /* GL_EXT_depth_bounds_test */
4543 static void GLAPIENTRY save_DepthBoundsEXT( GLclampd zmin, GLclampd zmax )
4544 {
4545 GET_CURRENT_CONTEXT(ctx);
4546 Node *n;
4547 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4548 n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 2 );
4549 if (n) {
4550 n[1].f = (GLfloat) zmin;
4551 n[2].f = (GLfloat) zmax;
4552 }
4553 if (ctx->ExecuteFlag) {
4554 (*ctx->Exec->DepthBoundsEXT)( zmin, zmax );
4555 }
4556 }
4557
4558
4559
4560 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
4561
4562 static void GLAPIENTRY
4563 save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
4564 const GLvoid *string)
4565 {
4566 GET_CURRENT_CONTEXT(ctx);
4567 Node *n;
4568 GLubyte *programCopy;
4569
4570 programCopy = (GLubyte *) _mesa_malloc(len);
4571 if (!programCopy) {
4572 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
4573 return;
4574 }
4575 _mesa_memcpy(programCopy, string, len);
4576
4577 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4578 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_STRING_ARB, 4 );
4579 if (n) {
4580 n[1].e = target;
4581 n[2].e = format;
4582 n[3].i = len;
4583 n[4].data = programCopy;
4584 }
4585 if (ctx->ExecuteFlag) {
4586 (*ctx->Exec->ProgramStringARB)(target, format, len, string);
4587 }
4588 }
4589
4590
4591 static void GLAPIENTRY
4592 save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
4593 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4594 {
4595 GET_CURRENT_CONTEXT(ctx);
4596 Node *n;
4597 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4598 n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6 );
4599 if (n) {
4600 n[1].e = target;
4601 n[2].ui = index;
4602 n[3].f = x;
4603 n[4].f = y;
4604 n[5].f = z;
4605 n[6].f = w;
4606 }
4607 if (ctx->ExecuteFlag) {
4608 (*ctx->Exec->ProgramEnvParameter4fARB)( target, index, x, y, z, w);
4609 }
4610 }
4611
4612
4613 static void GLAPIENTRY
4614 save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
4615 const GLfloat *params)
4616 {
4617 save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
4618 params[2], params[3]);
4619 }
4620
4621
4622 static void GLAPIENTRY
4623 save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
4624 GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4625 {
4626 save_ProgramEnvParameter4fARB(target, index,
4627 (GLfloat) x,
4628 (GLfloat) y,
4629 (GLfloat) z,
4630 (GLfloat) w);
4631 }
4632
4633
4634 static void GLAPIENTRY
4635 save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
4636 const GLdouble *params)
4637 {
4638 save_ProgramEnvParameter4fARB(target, index,
4639 (GLfloat) params[0],
4640 (GLfloat) params[1],
4641 (GLfloat) params[2],
4642 (GLfloat) params[3]);
4643 }
4644
4645 #endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
4646
4647
4648 #ifdef FEATURE_ARB_occlusion_query
4649
4650 static void GLAPIENTRY
4651 save_BeginQueryARB(GLenum target, GLuint id)
4652 {
4653 GET_CURRENT_CONTEXT(ctx);
4654 Node *n;
4655 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4656 n = ALLOC_INSTRUCTION( ctx, OPCODE_BEGIN_QUERY_ARB, 2 );
4657 if (n) {
4658 n[1].e = target;
4659 n[2].ui = id;
4660 }
4661 if (ctx->ExecuteFlag) {
4662 (*ctx->Exec->BeginQueryARB)( target, id );
4663 }
4664 }
4665
4666
4667 static void GLAPIENTRY
4668 save_EndQueryARB(GLenum target)
4669 {
4670 GET_CURRENT_CONTEXT(ctx);
4671 Node *n;
4672 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4673 n = ALLOC_INSTRUCTION( ctx, OPCODE_END_QUERY_ARB, 1 );
4674 if (n) {
4675 n[1].e = target;
4676 }
4677 if (ctx->ExecuteFlag) {
4678 (*ctx->Exec->EndQueryARB)( target );
4679 }
4680 }
4681
4682 #endif /* FEATURE_ARB_occlusion_query */
4683
4684
4685
4686 static void save_Attr1f( GLenum attr, GLfloat x )
4687 {
4688 GET_CURRENT_CONTEXT(ctx);
4689 Node *n;
4690 SAVE_FLUSH_VERTICES( ctx );
4691 n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_1F, 2 );
4692 if (n) {
4693 n[1].e = attr;
4694 n[2].f = x;
4695 }
4696
4697 ASSERT(attr < VERT_ATTRIB_MAX);
4698 ctx->ListState.ActiveAttribSize[attr] = 1;
4699 ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
4700
4701 if (ctx->ExecuteFlag) {
4702 (*ctx->Exec->VertexAttrib1fNV)( attr, x );
4703 }
4704 }
4705
4706 static void save_Attr2f( GLenum attr, GLfloat x, GLfloat y )
4707 {
4708 GET_CURRENT_CONTEXT(ctx);
4709 Node *n;
4710 SAVE_FLUSH_VERTICES( ctx );
4711 n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_2F, 3 );
4712 if (n) {
4713 n[1].e = attr;
4714 n[2].f = x;
4715 n[3].f = y;
4716 }
4717
4718 ASSERT(attr < VERT_ATTRIB_MAX);
4719 ctx->ListState.ActiveAttribSize[attr] = 2;
4720 ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
4721
4722 if (ctx->ExecuteFlag) {
4723 (*ctx->Exec->VertexAttrib2fNV)( attr, x, y );
4724 }
4725 }
4726
4727 static void save_Attr3f( GLenum attr, GLfloat x, GLfloat y, GLfloat z )
4728 {
4729 GET_CURRENT_CONTEXT(ctx);
4730 Node *n;
4731 SAVE_FLUSH_VERTICES( ctx );
4732 n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_3F, 4 );
4733 if (n) {
4734 n[1].e = attr;
4735 n[2].f = x;
4736 n[3].f = y;
4737 n[4].f = z;
4738 }
4739
4740 ASSERT(attr < VERT_ATTRIB_MAX);
4741 ctx->ListState.ActiveAttribSize[attr] = 3;
4742 ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
4743
4744 if (ctx->ExecuteFlag) {
4745 (*ctx->Exec->VertexAttrib3fNV)( attr, x, y, z );
4746 }
4747 }
4748
4749 static void save_Attr4f( GLenum attr, GLfloat x, GLfloat y, GLfloat z,
4750 GLfloat w )
4751 {
4752 GET_CURRENT_CONTEXT(ctx);
4753 Node *n;
4754 SAVE_FLUSH_VERTICES( ctx );
4755 n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_4F, 5 );
4756 if (n) {
4757 n[1].e = attr;
4758 n[2].f = x;
4759 n[3].f = y;
4760 n[4].f = z;
4761 n[5].f = w;
4762 }
4763
4764 ASSERT(attr < VERT_ATTRIB_MAX);
4765 ctx->ListState.ActiveAttribSize[attr] = 4;
4766 ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, w);
4767
4768 if (ctx->ExecuteFlag) {
4769 (*ctx->Exec->VertexAttrib4fNV)( attr, x, y, z, w );
4770 }
4771 }
4772
4773 static void GLAPIENTRY save_EvalCoord1f( GLfloat x )
4774 {
4775 GET_CURRENT_CONTEXT(ctx);
4776 Node *n;
4777 SAVE_FLUSH_VERTICES( ctx );
4778 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_C1, 1 );
4779 if (n) {
4780 n[1].f = x;
4781 }
4782 if (ctx->ExecuteFlag) {
4783 (*ctx->Exec->EvalCoord1f)( x );
4784 }
4785 }
4786
4787 static void GLAPIENTRY save_EvalCoord1fv( const GLfloat *v )
4788 {
4789 save_EvalCoord1f( v[0] );
4790 }
4791
4792 static void GLAPIENTRY save_EvalCoord2f( GLfloat x, GLfloat y )
4793 {
4794 GET_CURRENT_CONTEXT(ctx);
4795 Node *n;
4796 SAVE_FLUSH_VERTICES( ctx );
4797 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_C2, 2 );
4798 if (n) {
4799 n[1].f = x;
4800 n[2].f = y;
4801 }
4802 if (ctx->ExecuteFlag) {
4803 (*ctx->Exec->EvalCoord2f)( x, y );
4804 }
4805 }
4806
4807 static void GLAPIENTRY save_EvalCoord2fv( const GLfloat *v )
4808 {
4809 save_EvalCoord2f( v[0], v[1] );
4810 }
4811
4812
4813 static void GLAPIENTRY save_EvalPoint1( GLint x )
4814 {
4815 GET_CURRENT_CONTEXT(ctx);
4816 Node *n;
4817 SAVE_FLUSH_VERTICES( ctx );
4818 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_P1, 1 );
4819 if (n) {
4820 n[1].i = x;
4821 }
4822 if (ctx->ExecuteFlag) {
4823 (*ctx->Exec->EvalPoint1)( x );
4824 }
4825 }
4826
4827 static void GLAPIENTRY save_EvalPoint2( GLint x, GLint y )
4828 {
4829 GET_CURRENT_CONTEXT(ctx);
4830 Node *n;
4831 SAVE_FLUSH_VERTICES( ctx );
4832 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_P2, 2 );
4833 if (n) {
4834 n[1].i = x;
4835 n[2].i = y;
4836 }
4837 if (ctx->ExecuteFlag) {
4838 (*ctx->Exec->EvalPoint2)( x, y );
4839 }
4840 }
4841
4842 static void GLAPIENTRY save_Indexf( GLfloat x )
4843 {
4844 GET_CURRENT_CONTEXT(ctx);
4845 Node *n;
4846 SAVE_FLUSH_VERTICES( ctx );
4847 n = ALLOC_INSTRUCTION( ctx, OPCODE_INDEX, 1 );
4848 if (n) {
4849 n[1].f = x;
4850 }
4851
4852 ctx->ListState.ActiveIndex = 1;
4853 ctx->ListState.CurrentIndex = x;
4854
4855 if (ctx->ExecuteFlag) {
4856 (*ctx->Exec->Indexi)( (GLint) x );
4857 }
4858 }
4859
4860 static void GLAPIENTRY save_Indexfv( const GLfloat *v )
4861 {
4862 save_Indexf( v[0] );
4863 }
4864
4865 static void GLAPIENTRY save_EdgeFlag( GLboolean x )
4866 {
4867 GET_CURRENT_CONTEXT(ctx);
4868 Node *n;
4869 SAVE_FLUSH_VERTICES( ctx );
4870 n = ALLOC_INSTRUCTION( ctx, OPCODE_EDGEFLAG, 1 );
4871 if (n) {
4872 n[1].b = x;
4873 }
4874
4875 ctx->ListState.ActiveEdgeFlag = 1;
4876 ctx->ListState.CurrentEdgeFlag = x;
4877
4878 if (ctx->ExecuteFlag) {
4879 (*ctx->Exec->EdgeFlag)( x );
4880 }
4881 }
4882
4883 static void GLAPIENTRY save_EdgeFlagv( const GLboolean *v )
4884 {
4885 save_EdgeFlag( v[0] );
4886 }
4887
4888 static void GLAPIENTRY save_Materialfv( GLenum face, GLenum pname, const GLfloat *param )
4889 {
4890 GET_CURRENT_CONTEXT(ctx);
4891 Node *n;
4892 int args, i;
4893
4894 SAVE_FLUSH_VERTICES( ctx );
4895
4896 switch (face) {
4897 case GL_BACK:
4898 case GL_FRONT:
4899 case GL_FRONT_AND_BACK:
4900 break;
4901 default:
4902 _mesa_compile_error( ctx, GL_INVALID_ENUM, "material(face)" );
4903 return;
4904 }
4905
4906 switch (pname) {
4907 case GL_EMISSION:
4908 case GL_AMBIENT:
4909 case GL_DIFFUSE:
4910 case GL_SPECULAR:
4911 case GL_AMBIENT_AND_DIFFUSE:
4912 args = 4;
4913 break;
4914 case GL_SHININESS:
4915 args = 1;
4916 break;
4917 case GL_COLOR_INDEXES:
4918 args = 3;
4919 break;
4920 default:
4921 _mesa_compile_error( ctx, GL_INVALID_ENUM, "material(pname)" );
4922 return;
4923 }
4924
4925 n = ALLOC_INSTRUCTION( ctx, OPCODE_MATERIAL, 6 );
4926 if (n) {
4927 n[1].e = face;
4928 n[2].e = pname;
4929 for (i = 0 ; i < args ; i++)
4930 n[3+i].f = param[i];
4931 }
4932
4933 {
4934 GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0, 0 );
4935 for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
4936 if (bitmask & (1<<i)) {
4937 ctx->ListState.ActiveMaterialSize[i] = args;
4938 COPY_SZ_4V( ctx->ListState.CurrentMaterial[i], args, param );
4939 }
4940 }
4941
4942 if (ctx->ExecuteFlag) {
4943 (*ctx->Exec->Materialfv)( face, pname, param );
4944 }
4945 }
4946
4947 static void GLAPIENTRY save_Begin( GLenum mode )
4948 {
4949 GET_CURRENT_CONTEXT(ctx);
4950 Node *n;
4951 GLboolean error = GL_FALSE;
4952
4953 if (/*mode < GL_POINTS ||*/ mode > GL_POLYGON) {
4954 _mesa_compile_error( ctx, GL_INVALID_ENUM, "Begin (mode)");
4955 error = GL_TRUE;
4956 }
4957 else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) {
4958 /* Typically the first begin. This may raise an error on
4959 * playback, depending on whether CallList is issued from inside
4960 * a begin/end or not.
4961 */
4962 ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM;
4963 }
4964 else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) {
4965 ctx->Driver.CurrentSavePrimitive = mode;
4966 }
4967 else {
4968 _mesa_compile_error( ctx, GL_INVALID_OPERATION, "recursive begin" );
4969 error = GL_TRUE;
4970 }
4971
4972 if (!error) {
4973 /* Give the driver an opportunity to hook in an optimized
4974 * display list compiler.
4975 */
4976 if (ctx->Driver.NotifySaveBegin( ctx, mode ))
4977 return;
4978
4979 SAVE_FLUSH_VERTICES( ctx );
4980 n = ALLOC_INSTRUCTION( ctx, OPCODE_BEGIN, 1 );
4981 if (n) {
4982 n[1].e = mode;
4983 }
4984 }
4985
4986 if (ctx->ExecuteFlag) {
4987 (*ctx->Exec->Begin)( mode );
4988 }
4989 }
4990
4991 static void GLAPIENTRY save_End( void )
4992 {
4993 GET_CURRENT_CONTEXT(ctx);
4994 SAVE_FLUSH_VERTICES( ctx );
4995 (void) ALLOC_INSTRUCTION( ctx, OPCODE_END, 0 );
4996 ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
4997 if (ctx->ExecuteFlag) {
4998 (*ctx->Exec->End)( );
4999 }
5000 }
5001
5002 static void GLAPIENTRY save_Rectf( GLfloat a, GLfloat b,
5003 GLfloat c, GLfloat d )
5004 {
5005 GET_CURRENT_CONTEXT(ctx);
5006 Node *n;
5007 SAVE_FLUSH_VERTICES( ctx );
5008 n = ALLOC_INSTRUCTION( ctx, OPCODE_RECTF, 4 );
5009 if (n) {
5010 n[1].f = a;
5011 n[2].f = b;
5012 n[3].f = c;
5013 n[4].f = d;
5014 }
5015 if (ctx->ExecuteFlag) {
5016 (*ctx->Exec->Rectf)( a, b, c, d );
5017 }
5018 }
5019
5020 /*
5021 */
5022 static void GLAPIENTRY save_Vertex2f( GLfloat x, GLfloat y )
5023 {
5024 save_Attr2f( VERT_ATTRIB_POS, x, y );
5025 }
5026
5027 static void GLAPIENTRY save_Vertex2fv( const GLfloat *v )
5028 {
5029 save_Attr2f( VERT_ATTRIB_POS, v[0], v[1] );
5030 }
5031
5032 static void GLAPIENTRY save_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
5033 {
5034 save_Attr3f( VERT_ATTRIB_POS, x, y, z );
5035 }
5036
5037 static void GLAPIENTRY save_Vertex3fv( const GLfloat *v )
5038 {
5039 save_Attr3f( VERT_ATTRIB_POS, v[0], v[1], v[2] );
5040 }
5041
5042 static void GLAPIENTRY save_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
5043 {
5044 save_Attr4f( VERT_ATTRIB_POS, x, y, z, w );
5045 }
5046
5047 static void GLAPIENTRY save_Vertex4fv( const GLfloat *v )
5048 {
5049 save_Attr4f( VERT_ATTRIB_POS, v[0], v[1], v[2], v[3] );
5050 }
5051
5052 static void GLAPIENTRY save_TexCoord1f( GLfloat x )
5053 {
5054 save_Attr1f( VERT_ATTRIB_TEX0, x );
5055 }
5056
5057 static void GLAPIENTRY save_TexCoord1fv( const GLfloat *v )
5058 {
5059 save_Attr1f( VERT_ATTRIB_TEX0, v[0] );
5060 }
5061
5062 static void GLAPIENTRY save_TexCoord2f( GLfloat x, GLfloat y )
5063 {
5064 save_Attr2f( VERT_ATTRIB_TEX0, x, y );
5065 }
5066
5067 static void GLAPIENTRY save_TexCoord2fv( const GLfloat *v )
5068 {
5069 save_Attr2f( VERT_ATTRIB_TEX0, v[0], v[1] );
5070 }
5071
5072 static void GLAPIENTRY save_TexCoord3f( GLfloat x, GLfloat y, GLfloat z )
5073 {
5074 save_Attr3f( VERT_ATTRIB_TEX0, x, y, z );
5075 }
5076
5077 static void GLAPIENTRY save_TexCoord3fv( const GLfloat *v )
5078 {
5079 save_Attr3f( VERT_ATTRIB_TEX0, v[0], v[1], v[2] );
5080 }
5081
5082 static void GLAPIENTRY save_TexCoord4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
5083 {
5084 save_Attr4f( VERT_ATTRIB_TEX0, x, y, z, w );
5085 }
5086
5087 static void GLAPIENTRY save_TexCoord4fv( const GLfloat *v )
5088 {
5089 save_Attr4f( VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3] );
5090 }
5091
5092 static void GLAPIENTRY save_Normal3f( GLfloat x, GLfloat y, GLfloat z )
5093 {
5094 save_Attr3f( VERT_ATTRIB_NORMAL, x, y, z );
5095 }
5096
5097 static void GLAPIENTRY save_Normal3fv( const GLfloat *v )
5098 {
5099 save_Attr3f( VERT_ATTRIB_NORMAL, v[0], v[1], v[2] );
5100 }
5101
5102 static void GLAPIENTRY save_FogCoordfEXT( GLfloat x )
5103 {
5104 save_Attr1f( VERT_ATTRIB_FOG, x );
5105 }
5106
5107 static void GLAPIENTRY save_FogCoordfvEXT( const GLfloat *v )
5108 {
5109 save_Attr1f( VERT_ATTRIB_FOG, v[0] );
5110 }
5111
5112 static void GLAPIENTRY save_Color3f( GLfloat x, GLfloat y, GLfloat z )
5113 {
5114 save_Attr3f( VERT_ATTRIB_COLOR0, x, y, z );
5115 }
5116
5117 static void GLAPIENTRY save_Color3fv( const GLfloat *v )
5118 {
5119 save_Attr3f( VERT_ATTRIB_COLOR0, v[0], v[1], v[2] );
5120 }
5121
5122 static void GLAPIENTRY save_Color4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
5123 {
5124 save_Attr4f( VERT_ATTRIB_COLOR0, x, y, z, w );
5125 }
5126
5127 static void GLAPIENTRY save_Color4fv( const GLfloat *v )
5128 {
5129 save_Attr4f( VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3] );
5130 }
5131
5132 static void GLAPIENTRY save_SecondaryColor3fEXT( GLfloat x, GLfloat y, GLfloat z )
5133 {
5134 save_Attr3f( VERT_ATTRIB_COLOR1, x, y, z );
5135 }
5136
5137 static void GLAPIENTRY save_SecondaryColor3fvEXT( const GLfloat *v )
5138 {
5139 save_Attr3f( VERT_ATTRIB_COLOR1, v[0], v[1], v[2] );
5140 }
5141
5142
5143 /* Just call the respective ATTR for texcoord
5144 */
5145 static void GLAPIENTRY save_MultiTexCoord1f( GLenum target, GLfloat x )
5146 {
5147 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5148 save_Attr1f( attr, x );
5149 }
5150
5151 static void GLAPIENTRY save_MultiTexCoord1fv( GLenum target, const GLfloat *v )
5152 {
5153 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5154 save_Attr1f( attr, v[0] );
5155 }
5156
5157 static void GLAPIENTRY save_MultiTexCoord2f( GLenum target, GLfloat x, GLfloat y )
5158 {
5159 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5160 save_Attr2f( attr, x, y );
5161 }
5162
5163 static void GLAPIENTRY save_MultiTexCoord2fv( GLenum target, const GLfloat *v )
5164 {
5165 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5166 save_Attr2f( attr, v[0], v[1] );
5167 }
5168
5169 static void GLAPIENTRY save_MultiTexCoord3f( GLenum target, GLfloat x, GLfloat y,
5170 GLfloat z)
5171 {
5172 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5173 save_Attr3f( attr, x, y, z );
5174 }
5175
5176 static void GLAPIENTRY save_MultiTexCoord3fv( GLenum target, const GLfloat *v )
5177 {
5178 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5179 save_Attr3f( attr, v[0], v[1], v[2] );
5180 }
5181
5182 static void GLAPIENTRY save_MultiTexCoord4f( GLenum target, GLfloat x, GLfloat y,
5183 GLfloat z, GLfloat w )
5184 {
5185 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5186 save_Attr4f( attr, x, y, z, w );
5187 }
5188
5189 static void GLAPIENTRY save_MultiTexCoord4fv( GLenum target, const GLfloat *v )
5190 {
5191 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5192 save_Attr4f( attr, v[0], v[1], v[2], v[3] );
5193 }
5194
5195
5196 static void enum_error( void )
5197 {
5198 GET_CURRENT_CONTEXT( ctx );
5199 _mesa_error( ctx, GL_INVALID_ENUM, "VertexAttribfNV" );
5200 }
5201
5202 /* First level for NV_vertex_program:
5203 *
5204 * Check for errors at compile time?.
5205 */
5206 static void GLAPIENTRY save_VertexAttrib1fNV( GLuint index, GLfloat x )
5207 {
5208 if (index < VERT_ATTRIB_MAX)
5209 save_Attr1f( index, x );
5210 else
5211 enum_error();
5212 }
5213
5214 static void GLAPIENTRY save_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
5215 {
5216 if (index < VERT_ATTRIB_MAX)
5217 save_Attr1f( index, v[0] );
5218 else
5219 enum_error();
5220 }
5221
5222 static void GLAPIENTRY save_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y )
5223 {
5224 if (index < VERT_ATTRIB_MAX)
5225 save_Attr2f( index, x, y );
5226 else
5227 enum_error();
5228 }
5229
5230 static void GLAPIENTRY save_VertexAttrib2fvNV( GLuint index, const GLfloat *v )
5231 {
5232 if (index < VERT_ATTRIB_MAX)
5233 save_Attr2f( index, v[0], v[1] );
5234 else
5235 enum_error();
5236 }
5237
5238 static void GLAPIENTRY save_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y,
5239 GLfloat z )
5240 {
5241 if (index < VERT_ATTRIB_MAX)
5242 save_Attr3f( index, x, y, z );
5243 else
5244 enum_error();
5245 }
5246
5247 static void GLAPIENTRY save_VertexAttrib3fvNV( GLuint index, const GLfloat *v )
5248 {
5249 if (index < VERT_ATTRIB_MAX)
5250 save_Attr3f( index, v[0], v[1], v[2] );
5251 else
5252 enum_error();
5253 }
5254
5255 static void GLAPIENTRY save_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y,
5256 GLfloat z, GLfloat w )
5257 {
5258 if (index < VERT_ATTRIB_MAX)
5259 save_Attr4f( index, x, y, z, w );
5260 else
5261 enum_error();
5262 }
5263
5264 static void GLAPIENTRY save_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
5265 {
5266 if (index < VERT_ATTRIB_MAX)
5267 save_Attr4f( index, v[0], v[1], v[2], v[3] );
5268 else
5269 enum_error();
5270 }
5271
5272
5273
5274
5275
5276 /* KW: Compile commands
5277 *
5278 * Will appear in the list before the vertex buffer containing the
5279 * command that provoked the error. I don't see this as a problem.
5280 */
5281 void
5282 _mesa_save_error( GLcontext *ctx, GLenum error, const char *s )
5283 {
5284 Node *n;
5285 n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
5286 if (n) {
5287 n[1].e = error;
5288 n[2].data = (void *) s;
5289 }
5290 /* execute already done */
5291 }
5292
5293
5294 /*
5295 * Compile an error into current display list.
5296 */
5297 void
5298 _mesa_compile_error( GLcontext *ctx, GLenum error, const char *s )
5299 {
5300 if (ctx->CompileFlag)
5301 _mesa_save_error( ctx, error, s );
5302
5303 if (ctx->ExecuteFlag)
5304 _mesa_error( ctx, error, s );
5305 }
5306
5307
5308
5309 static GLboolean
5310 islist(GLcontext *ctx, GLuint list)
5311 {
5312 if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
5313 return GL_TRUE;
5314 }
5315 else {
5316 return GL_FALSE;
5317 }
5318 }
5319
5320
5321
5322 /**********************************************************************/
5323 /* Display list execution */
5324 /**********************************************************************/
5325
5326
5327 /*
5328 * Execute a display list. Note that the ListBase offset must have already
5329 * been added before calling this function. I.e. the list argument is
5330 * the absolute list number, not relative to ListBase.
5331 * \param list - display list number
5332 */
5333 static void GLAPIENTRY
5334 execute_list( GLcontext *ctx, GLuint list )
5335 {
5336 Node *n;
5337 GLboolean done;
5338
5339 if (list == 0 || !islist(ctx,list))
5340 return;
5341
5342 if (ctx->Driver.BeginCallList)
5343 ctx->Driver.BeginCallList( ctx, list );
5344
5345 ctx->ListState.CallDepth++;
5346
5347 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
5348
5349 done = GL_FALSE;
5350 while (!done) {
5351 OpCode opcode = n[0].opcode;
5352 int i = (int)n[0].opcode - (int)OPCODE_EXT_0;
5353
5354 if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
5355 /* this is a driver-extended opcode */
5356 ctx->ListExt.Opcode[i].Execute(ctx, &n[1]);
5357 n += ctx->ListExt.Opcode[i].Size;
5358 }
5359 else {
5360 switch (opcode) {
5361 case OPCODE_ERROR:
5362 _mesa_error( ctx, n[1].e, (const char *) n[2].data );
5363 break;
5364 case OPCODE_ACCUM:
5365 (*ctx->Exec->Accum)( n[1].e, n[2].f );
5366 break;
5367 case OPCODE_ALPHA_FUNC:
5368 (*ctx->Exec->AlphaFunc)( n[1].e, n[2].f );
5369 break;
5370 case OPCODE_BIND_TEXTURE:
5371 (*ctx->Exec->BindTexture)( n[1].e, n[2].ui );
5372 break;
5373 case OPCODE_BITMAP:
5374 {
5375 const struct gl_pixelstore_attrib save = ctx->Unpack;
5376 ctx->Unpack = ctx->DefaultPacking;
5377 (*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
5378 n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
5379 ctx->Unpack = save; /* restore */
5380 }
5381 break;
5382 case OPCODE_BLEND_COLOR:
5383 (*ctx->Exec->BlendColor)( n[1].f, n[2].f, n[3].f, n[4].f );
5384 break;
5385 case OPCODE_BLEND_EQUATION:
5386 (*ctx->Exec->BlendEquation)( n[1].e );
5387 break;
5388 case OPCODE_BLEND_EQUATION_SEPARATE:
5389 (*ctx->Exec->BlendEquationSeparateEXT)( n[1].e, n[2].e );
5390 break;
5391 case OPCODE_BLEND_FUNC_SEPARATE:
5392 (*ctx->Exec->BlendFuncSeparateEXT)(n[1].e, n[2].e, n[3].e, n[4].e);
5393 break;
5394 case OPCODE_CALL_LIST:
5395 /* Generated by glCallList(), don't add ListBase */
5396 if (ctx->ListState.CallDepth<MAX_LIST_NESTING) {
5397 execute_list( ctx, n[1].ui );
5398 }
5399 break;
5400 case OPCODE_CALL_LIST_OFFSET:
5401 /* Generated by glCallLists() so we must add ListBase */
5402 if (n[2].b) {
5403 /* user specified a bad data type at compile time */
5404 _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
5405 }
5406 else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
5407 execute_list( ctx, ctx->List.ListBase + n[1].ui );
5408 }
5409 break;
5410 case OPCODE_CLEAR:
5411 (*ctx->Exec->Clear)( n[1].bf );
5412 break;
5413 case OPCODE_CLEAR_COLOR:
5414 (*ctx->Exec->ClearColor)( n[1].f, n[2].f, n[3].f, n[4].f );
5415 break;
5416 case OPCODE_CLEAR_ACCUM:
5417 (*ctx->Exec->ClearAccum)( n[1].f, n[2].f, n[3].f, n[4].f );
5418 break;
5419 case OPCODE_CLEAR_DEPTH:
5420 (*ctx->Exec->ClearDepth)( (GLclampd) n[1].f );
5421 break;
5422 case OPCODE_CLEAR_INDEX:
5423 (*ctx->Exec->ClearIndex)( (GLfloat) n[1].ui );
5424 break;
5425 case OPCODE_CLEAR_STENCIL:
5426 (*ctx->Exec->ClearStencil)( n[1].i );
5427 break;
5428 case OPCODE_CLIP_PLANE:
5429 {
5430 GLdouble eq[4];
5431 eq[0] = n[2].f;
5432 eq[1] = n[3].f;
5433 eq[2] = n[4].f;
5434 eq[3] = n[5].f;
5435 (*ctx->Exec->ClipPlane)( n[1].e, eq );
5436 }
5437 break;
5438 case OPCODE_COLOR_MASK:
5439 (*ctx->Exec->ColorMask)( n[1].b, n[2].b, n[3].b, n[4].b );
5440 break;
5441 case OPCODE_COLOR_MATERIAL:
5442 (*ctx->Exec->ColorMaterial)( n[1].e, n[2].e );
5443 break;
5444 case OPCODE_COLOR_TABLE:
5445 {
5446 const struct gl_pixelstore_attrib save = ctx->Unpack;
5447 ctx->Unpack = ctx->DefaultPacking;
5448 (*ctx->Exec->ColorTable)( n[1].e, n[2].e, n[3].i, n[4].e,
5449 n[5].e, n[6].data );
5450 ctx->Unpack = save; /* restore */
5451 }
5452 break;
5453 case OPCODE_COLOR_TABLE_PARAMETER_FV:
5454 {
5455 GLfloat params[4];
5456 params[0] = n[3].f;
5457 params[1] = n[4].f;
5458 params[2] = n[5].f;
5459 params[3] = n[6].f;
5460 (*ctx->Exec->ColorTableParameterfv)( n[1].e, n[2].e, params );
5461 }
5462 break;
5463 case OPCODE_COLOR_TABLE_PARAMETER_IV:
5464 {
5465 GLint params[4];
5466 params[0] = n[3].i;
5467 params[1] = n[4].i;
5468 params[2] = n[5].i;
5469 params[3] = n[6].i;
5470 (*ctx->Exec->ColorTableParameteriv)( n[1].e, n[2].e, params );
5471 }
5472 break;
5473 case OPCODE_COLOR_SUB_TABLE:
5474 {
5475 const struct gl_pixelstore_attrib save = ctx->Unpack;
5476 ctx->Unpack = ctx->DefaultPacking;
5477 (*ctx->Exec->ColorSubTable)( n[1].e, n[2].i, n[3].i,
5478 n[4].e, n[5].e, n[6].data );
5479 ctx->Unpack = save; /* restore */
5480 }
5481 break;
5482 case OPCODE_CONVOLUTION_FILTER_1D:
5483 {
5484 const struct gl_pixelstore_attrib save = ctx->Unpack;
5485 ctx->Unpack = ctx->DefaultPacking;
5486 (*ctx->Exec->ConvolutionFilter1D)( n[1].e, n[2].i, n[3].i,
5487 n[4].e, n[5].e, n[6].data );
5488 ctx->Unpack = save; /* restore */
5489 }
5490 break;
5491 case OPCODE_CONVOLUTION_FILTER_2D:
5492 {
5493 const struct gl_pixelstore_attrib save = ctx->Unpack;
5494 ctx->Unpack = ctx->DefaultPacking;
5495 (*ctx->Exec->ConvolutionFilter2D)( n[1].e, n[2].i, n[3].i,
5496 n[4].i, n[5].e, n[6].e, n[7].data );
5497 ctx->Unpack = save; /* restore */
5498 }
5499 break;
5500 case OPCODE_CONVOLUTION_PARAMETER_I:
5501 (*ctx->Exec->ConvolutionParameteri)( n[1].e, n[2].e, n[3].i );
5502 break;
5503 case OPCODE_CONVOLUTION_PARAMETER_IV:
5504 {
5505 GLint params[4];
5506 params[0] = n[3].i;
5507 params[1] = n[4].i;
5508 params[2] = n[5].i;
5509 params[3] = n[6].i;
5510 (*ctx->Exec->ConvolutionParameteriv)( n[1].e, n[2].e, params );
5511 }
5512 break;
5513 case OPCODE_CONVOLUTION_PARAMETER_F:
5514 (*ctx->Exec->ConvolutionParameterf)( n[1].e, n[2].e, n[3].f );
5515 break;
5516 case OPCODE_CONVOLUTION_PARAMETER_FV:
5517 {
5518 GLfloat params[4];
5519 params[0] = n[3].f;
5520 params[1] = n[4].f;
5521 params[2] = n[5].f;
5522 params[3] = n[6].f;
5523 (*ctx->Exec->ConvolutionParameterfv)( n[1].e, n[2].e, params );
5524 }
5525 break;
5526 case OPCODE_COPY_COLOR_SUB_TABLE:
5527 (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i,
5528 n[3].i, n[4].i, n[5].i );
5529 break;
5530 case OPCODE_COPY_COLOR_TABLE:
5531 (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i,
5532 n[3].i, n[4].i, n[5].i );
5533 break;
5534 case OPCODE_COPY_PIXELS:
5535 (*ctx->Exec->CopyPixels)( n[1].i, n[2].i,
5536 (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
5537 break;
5538 case OPCODE_COPY_TEX_IMAGE1D:
5539 (*ctx->Exec->CopyTexImage1D)( n[1].e, n[2].i, n[3].e, n[4].i,
5540 n[5].i, n[6].i, n[7].i );
5541 break;
5542 case OPCODE_COPY_TEX_IMAGE2D:
5543 (*ctx->Exec->CopyTexImage2D)( n[1].e, n[2].i, n[3].e, n[4].i,
5544 n[5].i, n[6].i, n[7].i, n[8].i );
5545 break;
5546 case OPCODE_COPY_TEX_SUB_IMAGE1D:
5547 (*ctx->Exec->CopyTexSubImage1D)( n[1].e, n[2].i, n[3].i,
5548 n[4].i, n[5].i, n[6].i );
5549 break;
5550 case OPCODE_COPY_TEX_SUB_IMAGE2D:
5551 (*ctx->Exec->CopyTexSubImage2D)( n[1].e, n[2].i, n[3].i,
5552 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i );
5553 break;
5554 case OPCODE_COPY_TEX_SUB_IMAGE3D:
5555 (*ctx->Exec->CopyTexSubImage3D)( n[1].e, n[2].i, n[3].i,
5556 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i , n[9].i);
5557 break;
5558 case OPCODE_CULL_FACE:
5559 (*ctx->Exec->CullFace)( n[1].e );
5560 break;
5561 case OPCODE_DEPTH_FUNC:
5562 (*ctx->Exec->DepthFunc)( n[1].e );
5563 break;
5564 case OPCODE_DEPTH_MASK:
5565 (*ctx->Exec->DepthMask)( n[1].b );
5566 break;
5567 case OPCODE_DEPTH_RANGE:
5568 (*ctx->Exec->DepthRange)( (GLclampd) n[1].f, (GLclampd) n[2].f );
5569 break;
5570 case OPCODE_DISABLE:
5571 (*ctx->Exec->Disable)( n[1].e );
5572 break;
5573 case OPCODE_DRAW_BUFFER:
5574 (*ctx->Exec->DrawBuffer)( n[1].e );
5575 break;
5576 case OPCODE_DRAW_PIXELS:
5577 {
5578 const struct gl_pixelstore_attrib save = ctx->Unpack;
5579 ctx->Unpack = ctx->DefaultPacking;
5580 (*ctx->Exec->DrawPixels)( n[1].i, n[2].i, n[3].e, n[4].e,
5581 n[5].data );
5582 ctx->Unpack = save; /* restore */
5583 }
5584 break;
5585 case OPCODE_ENABLE:
5586 (*ctx->Exec->Enable)( n[1].e );
5587 break;
5588 case OPCODE_EVALMESH1:
5589 (*ctx->Exec->EvalMesh1)( n[1].e, n[2].i, n[3].i );
5590 break;
5591 case OPCODE_EVALMESH2:
5592 (*ctx->Exec->EvalMesh2)( n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
5593 break;
5594 case OPCODE_FOG:
5595 {
5596 GLfloat p[4];
5597 p[0] = n[2].f;
5598 p[1] = n[3].f;
5599 p[2] = n[4].f;
5600 p[3] = n[5].f;
5601 (*ctx->Exec->Fogfv)( n[1].e, p );
5602 }
5603 break;
5604 case OPCODE_FRONT_FACE:
5605 (*ctx->Exec->FrontFace)( n[1].e );
5606 break;
5607 case OPCODE_FRUSTUM:
5608 (*ctx->Exec->Frustum)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
5609 break;
5610 case OPCODE_HINT:
5611 (*ctx->Exec->Hint)( n[1].e, n[2].e );
5612 break;
5613 case OPCODE_HISTOGRAM:
5614 (*ctx->Exec->Histogram)( n[1].e, n[2].i, n[3].e, n[4].b );
5615 break;
5616 case OPCODE_INDEX_MASK:
5617 (*ctx->Exec->IndexMask)( n[1].ui );
5618 break;
5619 case OPCODE_INIT_NAMES:
5620 (*ctx->Exec->InitNames)();
5621 break;
5622 case OPCODE_LIGHT:
5623 {
5624 GLfloat p[4];
5625 p[0] = n[3].f;
5626 p[1] = n[4].f;
5627 p[2] = n[5].f;
5628 p[3] = n[6].f;
5629 (*ctx->Exec->Lightfv)( n[1].e, n[2].e, p );
5630 }
5631 break;
5632 case OPCODE_LIGHT_MODEL:
5633 {
5634 GLfloat p[4];
5635 p[0] = n[2].f;
5636 p[1] = n[3].f;
5637 p[2] = n[4].f;
5638 p[3] = n[5].f;
5639 (*ctx->Exec->LightModelfv)( n[1].e, p );
5640 }
5641 break;
5642 case OPCODE_LINE_STIPPLE:
5643 (*ctx->Exec->LineStipple)( n[1].i, n[2].us );
5644 break;
5645 case OPCODE_LINE_WIDTH:
5646 (*ctx->Exec->LineWidth)( n[1].f );
5647 break;
5648 case OPCODE_LIST_BASE:
5649 (*ctx->Exec->ListBase)( n[1].ui );
5650 break;
5651 case OPCODE_LOAD_IDENTITY:
5652 (*ctx->Exec->LoadIdentity)();
5653 break;
5654 case OPCODE_LOAD_MATRIX:
5655 if (sizeof(Node)==sizeof(GLfloat)) {
5656 (*ctx->Exec->LoadMatrixf)( &n[1].f );
5657 }
5658 else {
5659 GLfloat m[16];
5660 GLuint i;
5661 for (i=0;i<16;i++) {
5662 m[i] = n[1+i].f;
5663 }
5664 (*ctx->Exec->LoadMatrixf)( m );
5665 }
5666 break;
5667 case OPCODE_LOAD_NAME:
5668 (*ctx->Exec->LoadName)( n[1].ui );
5669 break;
5670 case OPCODE_LOGIC_OP:
5671 (*ctx->Exec->LogicOp)( n[1].e );
5672 break;
5673 case OPCODE_MAP1:
5674 {
5675 GLenum target = n[1].e;
5676 GLint ustride = _mesa_evaluator_components(target);
5677 GLint uorder = n[5].i;
5678 GLfloat u1 = n[2].f;
5679 GLfloat u2 = n[3].f;
5680 (*ctx->Exec->Map1f)( target, u1, u2, ustride, uorder,
5681 (GLfloat *) n[6].data );
5682 }
5683 break;
5684 case OPCODE_MAP2:
5685 {
5686 GLenum target = n[1].e;
5687 GLfloat u1 = n[2].f;
5688 GLfloat u2 = n[3].f;
5689 GLfloat v1 = n[4].f;
5690 GLfloat v2 = n[5].f;
5691 GLint ustride = n[6].i;
5692 GLint vstride = n[7].i;
5693 GLint uorder = n[8].i;
5694 GLint vorder = n[9].i;
5695 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
5696 v1, v2, vstride, vorder,
5697 (GLfloat *) n[10].data );
5698 }
5699 break;
5700 case OPCODE_MAPGRID1:
5701 (*ctx->Exec->MapGrid1f)( n[1].i, n[2].f, n[3].f );
5702 break;
5703 case OPCODE_MAPGRID2:
5704 (*ctx->Exec->MapGrid2f)( n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
5705 break;
5706 case OPCODE_MATRIX_MODE:
5707 (*ctx->Exec->MatrixMode)( n[1].e );
5708 break;
5709 case OPCODE_MIN_MAX:
5710 (*ctx->Exec->Minmax)(n[1].e, n[2].e, n[3].b);
5711 break;
5712 case OPCODE_MULT_MATRIX:
5713 if (sizeof(Node)==sizeof(GLfloat)) {
5714 (*ctx->Exec->MultMatrixf)( &n[1].f );
5715 }
5716 else {
5717 GLfloat m[16];
5718 GLuint i;
5719 for (i=0;i<16;i++) {
5720 m[i] = n[1+i].f;
5721 }
5722 (*ctx->Exec->MultMatrixf)( m );
5723 }
5724 break;
5725 case OPCODE_ORTHO:
5726 (*ctx->Exec->Ortho)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
5727 break;
5728 case OPCODE_PASSTHROUGH:
5729 (*ctx->Exec->PassThrough)( n[1].f );
5730 break;
5731 case OPCODE_PIXEL_MAP:
5732 (*ctx->Exec->PixelMapfv)( n[1].e, n[2].i, (GLfloat *) n[3].data );
5733 break;
5734 case OPCODE_PIXEL_TRANSFER:
5735 (*ctx->Exec->PixelTransferf)( n[1].e, n[2].f );
5736 break;
5737 case OPCODE_PIXEL_ZOOM:
5738 (*ctx->Exec->PixelZoom)( n[1].f, n[2].f );
5739 break;
5740 case OPCODE_POINT_SIZE:
5741 (*ctx->Exec->PointSize)( n[1].f );
5742 break;
5743 case OPCODE_POINT_PARAMETERS:
5744 {
5745 GLfloat params[3];
5746 params[0] = n[2].f;
5747 params[1] = n[3].f;
5748 params[2] = n[4].f;
5749 (*ctx->Exec->PointParameterfvEXT)( n[1].e, params );
5750 }
5751 break;
5752 case OPCODE_POLYGON_MODE:
5753 (*ctx->Exec->PolygonMode)( n[1].e, n[2].e );
5754 break;
5755 case OPCODE_POLYGON_STIPPLE:
5756 (*ctx->Exec->PolygonStipple)( (GLubyte *) n[1].data );
5757 break;
5758 case OPCODE_POLYGON_OFFSET:
5759 (*ctx->Exec->PolygonOffset)( n[1].f, n[2].f );
5760 break;
5761 case OPCODE_POP_ATTRIB:
5762 (*ctx->Exec->PopAttrib)();
5763 break;
5764 case OPCODE_POP_MATRIX:
5765 (*ctx->Exec->PopMatrix)();
5766 break;
5767 case OPCODE_POP_NAME:
5768 (*ctx->Exec->PopName)();
5769 break;
5770 case OPCODE_PRIORITIZE_TEXTURE:
5771 (*ctx->Exec->PrioritizeTextures)( 1, &n[1].ui, &n[2].f );
5772 break;
5773 case OPCODE_PUSH_ATTRIB:
5774 (*ctx->Exec->PushAttrib)( n[1].bf );
5775 break;
5776 case OPCODE_PUSH_MATRIX:
5777 (*ctx->Exec->PushMatrix)();
5778 break;
5779 case OPCODE_PUSH_NAME:
5780 (*ctx->Exec->PushName)( n[1].ui );
5781 break;
5782 case OPCODE_RASTER_POS:
5783 (*ctx->Exec->RasterPos4f)( n[1].f, n[2].f, n[3].f, n[4].f );
5784 break;
5785 case OPCODE_READ_BUFFER:
5786 (*ctx->Exec->ReadBuffer)( n[1].e );
5787 break;
5788 case OPCODE_RESET_HISTOGRAM:
5789 (*ctx->Exec->ResetHistogram)( n[1].e );
5790 break;
5791 case OPCODE_RESET_MIN_MAX:
5792 (*ctx->Exec->ResetMinmax)( n[1].e );
5793 break;
5794 case OPCODE_ROTATE:
5795 (*ctx->Exec->Rotatef)( n[1].f, n[2].f, n[3].f, n[4].f );
5796 break;
5797 case OPCODE_SCALE:
5798 (*ctx->Exec->Scalef)( n[1].f, n[2].f, n[3].f );
5799 break;
5800 case OPCODE_SCISSOR:
5801 (*ctx->Exec->Scissor)( n[1].i, n[2].i, n[3].i, n[4].i );
5802 break;
5803 case OPCODE_SHADE_MODEL:
5804 (*ctx->Exec->ShadeModel)( n[1].e );
5805 break;
5806 case OPCODE_STENCIL_FUNC:
5807 (*ctx->Exec->StencilFunc)( n[1].e, n[2].i, n[3].ui );
5808 break;
5809 case OPCODE_STENCIL_MASK:
5810 (*ctx->Exec->StencilMask)( n[1].ui );
5811 break;
5812 case OPCODE_STENCIL_OP:
5813 (*ctx->Exec->StencilOp)( n[1].e, n[2].e, n[3].e );
5814 break;
5815 case OPCODE_TEXENV:
5816 {
5817 GLfloat params[4];
5818 params[0] = n[3].f;
5819 params[1] = n[4].f;
5820 params[2] = n[5].f;
5821 params[3] = n[6].f;
5822 (*ctx->Exec->TexEnvfv)( n[1].e, n[2].e, params );
5823 }
5824 break;
5825 case OPCODE_TEXGEN:
5826 {
5827 GLfloat params[4];
5828 params[0] = n[3].f;
5829 params[1] = n[4].f;
5830 params[2] = n[5].f;
5831 params[3] = n[6].f;
5832 (*ctx->Exec->TexGenfv)( n[1].e, n[2].e, params );
5833 }
5834 break;
5835 case OPCODE_TEXPARAMETER:
5836 {
5837 GLfloat params[4];
5838 params[0] = n[3].f;
5839 params[1] = n[4].f;
5840 params[2] = n[5].f;
5841 params[3] = n[6].f;
5842 (*ctx->Exec->TexParameterfv)( n[1].e, n[2].e, params );
5843 }
5844 break;
5845 case OPCODE_TEX_IMAGE1D:
5846 {
5847 const struct gl_pixelstore_attrib save = ctx->Unpack;
5848 ctx->Unpack = ctx->DefaultPacking;
5849 (*ctx->Exec->TexImage1D)(
5850 n[1].e, /* target */
5851 n[2].i, /* level */
5852 n[3].i, /* components */
5853 n[4].i, /* width */
5854 n[5].e, /* border */
5855 n[6].e, /* format */
5856 n[7].e, /* type */
5857 n[8].data );
5858 ctx->Unpack = save; /* restore */
5859 }
5860 break;
5861 case OPCODE_TEX_IMAGE2D:
5862 {
5863 const struct gl_pixelstore_attrib save = ctx->Unpack;
5864 ctx->Unpack = ctx->DefaultPacking;
5865 (*ctx->Exec->TexImage2D)(
5866 n[1].e, /* target */
5867 n[2].i, /* level */
5868 n[3].i, /* components */
5869 n[4].i, /* width */
5870 n[5].i, /* height */
5871 n[6].e, /* border */
5872 n[7].e, /* format */
5873 n[8].e, /* type */
5874 n[9].data );
5875 ctx->Unpack = save; /* restore */
5876 }
5877 break;
5878 case OPCODE_TEX_IMAGE3D:
5879 {
5880 const struct gl_pixelstore_attrib save = ctx->Unpack;
5881 ctx->Unpack = ctx->DefaultPacking;
5882 (*ctx->Exec->TexImage3D)(
5883 n[1].e, /* target */
5884 n[2].i, /* level */
5885 n[3].i, /* components */
5886 n[4].i, /* width */
5887 n[5].i, /* height */
5888 n[6].i, /* depth */
5889 n[7].e, /* border */
5890 n[8].e, /* format */
5891 n[9].e, /* type */
5892 n[10].data );
5893 ctx->Unpack = save; /* restore */
5894 }
5895 break;
5896 case OPCODE_TEX_SUB_IMAGE1D:
5897 {
5898 const struct gl_pixelstore_attrib save = ctx->Unpack;
5899 ctx->Unpack = ctx->DefaultPacking;
5900 (*ctx->Exec->TexSubImage1D)( n[1].e, n[2].i, n[3].i,
5901 n[4].i, n[5].e,
5902 n[6].e, n[7].data );
5903 ctx->Unpack = save; /* restore */
5904 }
5905 break;
5906 case OPCODE_TEX_SUB_IMAGE2D:
5907 {
5908 const struct gl_pixelstore_attrib save = ctx->Unpack;
5909 ctx->Unpack = ctx->DefaultPacking;
5910 (*ctx->Exec->TexSubImage2D)( n[1].e, n[2].i, n[3].i,
5911 n[4].i, n[5].e,
5912 n[6].i, n[7].e, n[8].e, n[9].data );
5913 ctx->Unpack = save; /* restore */
5914 }
5915 break;
5916 case OPCODE_TEX_SUB_IMAGE3D:
5917 {
5918 const struct gl_pixelstore_attrib save = ctx->Unpack;
5919 ctx->Unpack = ctx->DefaultPacking;
5920 (*ctx->Exec->TexSubImage3D)( n[1].e, n[2].i, n[3].i,
5921 n[4].i, n[5].i, n[6].i, n[7].i,
5922 n[8].i, n[9].e, n[10].e,
5923 n[11].data );
5924 ctx->Unpack = save; /* restore */
5925 }
5926 break;
5927 case OPCODE_TRANSLATE:
5928 (*ctx->Exec->Translatef)( n[1].f, n[2].f, n[3].f );
5929 break;
5930 case OPCODE_VIEWPORT:
5931 (*ctx->Exec->Viewport)(n[1].i, n[2].i,
5932 (GLsizei) n[3].i, (GLsizei) n[4].i);
5933 break;
5934 case OPCODE_WINDOW_POS:
5935 (*ctx->Exec->WindowPos4fMESA)( n[1].f, n[2].f, n[3].f, n[4].f );
5936 break;
5937 case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
5938 (*ctx->Exec->ActiveTextureARB)( n[1].e );
5939 break;
5940 case OPCODE_PIXEL_TEXGEN_SGIX: /* GL_SGIX_pixel_texture */
5941 (*ctx->Exec->PixelTexGenSGIX)( n[1].e );
5942 break;
5943 case OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS: /* GL_SGIS_pixel_texture */
5944 (*ctx->Exec->PixelTexGenParameteriSGIS)( n[1].e, n[2].i );
5945 break;
5946 case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */
5947 (*ctx->Exec->CompressedTexImage1DARB)(n[1].e, n[2].i, n[3].e,
5948 n[4].i, n[5].i, n[6].i, n[7].data);
5949 break;
5950 case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */
5951 (*ctx->Exec->CompressedTexImage2DARB)(n[1].e, n[2].i, n[3].e,
5952 n[4].i, n[5].i, n[6].i, n[7].i, n[8].data);
5953 break;
5954 case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */
5955 (*ctx->Exec->CompressedTexImage3DARB)(n[1].e, n[2].i, n[3].e,
5956 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i, n[9].data);
5957 break;
5958 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */
5959 (*ctx->Exec->CompressedTexSubImage1DARB)(n[1].e, n[2].i, n[3].i,
5960 n[4].i, n[5].e, n[6].i, n[7].data);
5961 break;
5962 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */
5963 (*ctx->Exec->CompressedTexSubImage2DARB)(n[1].e, n[2].i, n[3].i,
5964 n[4].i, n[5].i, n[6].i, n[7].e, n[8].i, n[9].data);
5965 break;
5966 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */
5967 (*ctx->Exec->CompressedTexSubImage3DARB)(n[1].e, n[2].i, n[3].i,
5968 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i,
5969 n[9].e, n[10].i, n[11].data);
5970 break;
5971 case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */
5972 (*ctx->Exec->SampleCoverageARB)(n[1].f, n[2].b);
5973 break;
5974 case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */
5975 (*ctx->Exec->WindowPos3fMESA)( n[1].f, n[2].f, n[3].f );
5976 break;
5977 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
5978 case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */
5979 (*ctx->Exec->BindProgramNV)( n[1].e, n[2].ui );
5980 break;
5981 #endif
5982 #if FEATURE_NV_vertex_program
5983 case OPCODE_EXECUTE_PROGRAM_NV:
5984 {
5985 GLfloat v[4];
5986 v[0] = n[3].f;
5987 v[1] = n[4].f;
5988 v[2] = n[5].f;
5989 v[3] = n[6].f;
5990 (*ctx->Exec->ExecuteProgramNV)(n[1].e, n[2].ui, v);
5991 }
5992 break;
5993 case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
5994 (*ctx->Exec->RequestResidentProgramsNV)(n[1].ui,
5995 (GLuint *) n[2].data);
5996 break;
5997 case OPCODE_LOAD_PROGRAM_NV:
5998 (*ctx->Exec->LoadProgramNV)(n[1].e, n[2].ui, n[3].i,
5999 (const GLubyte *) n[4].data);
6000 break;
6001 case OPCODE_PROGRAM_PARAMETER4F_NV:
6002 (*ctx->Exec->ProgramParameter4fNV)(n[1].e, n[2].ui, n[3].f,
6003 n[4].f, n[5].f, n[6].f);
6004 break;
6005 case OPCODE_TRACK_MATRIX_NV:
6006 (*ctx->Exec->TrackMatrixNV)(n[1].e, n[2].ui, n[3].e, n[4].e);
6007 break;
6008 #endif
6009
6010 #if FEATURE_NV_fragment_program
6011 case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB:
6012 (*ctx->Exec->ProgramLocalParameter4fARB)(n[1].e, n[2].ui, n[3].f,
6013 n[4].f, n[5].f, n[6].f);
6014 break;
6015 case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
6016 (*ctx->Exec->ProgramNamedParameter4fNV)(n[1].ui, n[2].i,
6017 (const GLubyte *) n[3].data,
6018 n[4].f, n[5].f, n[6].f, n[7].f);
6019 break;
6020 #endif
6021
6022 case OPCODE_ACTIVE_STENCIL_FACE_EXT:
6023 (*ctx->Exec->ActiveStencilFaceEXT)(n[1].e);
6024 break;
6025 case OPCODE_DEPTH_BOUNDS_EXT:
6026 (*ctx->Exec->DepthBoundsEXT)(n[1].f, n[2].f);
6027 break;
6028 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
6029 case OPCODE_PROGRAM_STRING_ARB:
6030 (*ctx->Exec->ProgramStringARB)(n[1].e, n[2].e, n[3].i, n[4].data);
6031 break;
6032 case OPCODE_PROGRAM_ENV_PARAMETER_ARB:
6033 (*ctx->Exec->ProgramEnvParameter4fARB)(n[1].e, n[2].ui, n[3].f,
6034 n[4].f, n[5].f, n[6].f);
6035 break;
6036 #endif
6037 #if FEATURE_ARB_occlusion_query
6038 case OPCODE_BEGIN_QUERY_ARB:
6039 ctx->Exec->BeginQueryARB(n[1].e, n[2].ui);
6040 break;
6041 case OPCODE_END_QUERY_ARB:
6042 ctx->Exec->EndQueryARB(n[1].e);
6043 break;
6044 #endif
6045 case OPCODE_ATTR_1F:
6046 (*ctx->Exec->VertexAttrib1fNV)(n[1].e, n[2].f);
6047 break;
6048 case OPCODE_ATTR_2F:
6049 /* Really shouldn't have to do this - the Node structure
6050 * is convenient, but it would be better to store the data
6051 * packed appropriately so that it can be sent directly
6052 * on. With x86_64 becoming common, this will start to
6053 * matter more.
6054 */
6055 if (sizeof(Node)==sizeof(GLfloat))
6056 (*ctx->Exec->VertexAttrib2fvNV)(n[1].e, &n[2].f);
6057 else
6058 (*ctx->Exec->VertexAttrib2fNV)(n[1].e, n[2].f, n[3].f);
6059 break;
6060 case OPCODE_ATTR_3F:
6061 if (sizeof(Node)==sizeof(GLfloat))
6062 (*ctx->Exec->VertexAttrib3fvNV)(n[1].e, &n[2].f);
6063 else
6064 (*ctx->Exec->VertexAttrib3fNV)(n[1].e, n[2].f, n[3].f,
6065 n[4].f);
6066 break;
6067 case OPCODE_ATTR_4F:
6068 if (sizeof(Node)==sizeof(GLfloat))
6069 (*ctx->Exec->VertexAttrib4fvNV)(n[1].e, &n[2].f);
6070 else
6071 (*ctx->Exec->VertexAttrib4fNV)(n[1].e, n[2].f, n[3].f,
6072 n[4].f, n[5].f);
6073 break;
6074 case OPCODE_MATERIAL:
6075 if (sizeof(Node)==sizeof(GLfloat))
6076 (*ctx->Exec->Materialfv)(n[1].e, n[2].e, &n[3].f);
6077 else {
6078 GLfloat f[4];
6079 f[0] = n[3].f;
6080 f[1] = n[4].f;
6081 f[2] = n[5].f;
6082 f[3] = n[6].f;
6083 (*ctx->Exec->Materialfv)(n[1].e, n[2].e, f);
6084 }
6085 break;
6086 case OPCODE_INDEX:
6087 (*ctx->Exec->Indexi)(n[1].i);
6088 break;
6089 case OPCODE_EDGEFLAG:
6090 (*ctx->Exec->EdgeFlag)(n[1].b);
6091 break;
6092 case OPCODE_BEGIN:
6093 (*ctx->Exec->Begin)(n[1].e);
6094 break;
6095 case OPCODE_END:
6096 (*ctx->Exec->End)();
6097 break;
6098 case OPCODE_RECTF:
6099 (*ctx->Exec->Rectf)(n[1].f, n[2].f, n[3].f, n[4].f);
6100 break;
6101 case OPCODE_EVAL_C1:
6102 (*ctx->Exec->EvalCoord1f)(n[1].f);
6103 break;
6104 case OPCODE_EVAL_C2:
6105 (*ctx->Exec->EvalCoord2f)(n[1].f, n[2].f);
6106 break;
6107 case OPCODE_EVAL_P1:
6108 (*ctx->Exec->EvalPoint1)(n[1].i);
6109 break;
6110 case OPCODE_EVAL_P2:
6111 (*ctx->Exec->EvalPoint2)(n[1].i, n[2].i);
6112 break;
6113
6114
6115
6116
6117 case OPCODE_CONTINUE:
6118 n = (Node *) n[1].next;
6119 break;
6120 case OPCODE_END_OF_LIST:
6121 done = GL_TRUE;
6122 break;
6123 default:
6124 {
6125 char msg[1000];
6126 _mesa_sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
6127 _mesa_problem(ctx, msg);
6128 }
6129 done = GL_TRUE;
6130 }
6131
6132 /* increment n to point to next compiled command */
6133 if (opcode!=OPCODE_CONTINUE) {
6134 n += InstSize[opcode];
6135 }
6136 }
6137 }
6138 ctx->ListState.CallDepth--;
6139
6140 if (ctx->Driver.EndCallList)
6141 ctx->Driver.EndCallList( ctx );
6142 }
6143
6144
6145
6146
6147
6148 /**********************************************************************/
6149 /* GL functions */
6150 /**********************************************************************/
6151
6152
6153
6154
6155 /*
6156 * Test if a display list number is valid.
6157 */
6158 GLboolean GLAPIENTRY
6159 _mesa_IsList( GLuint list )
6160 {
6161 GET_CURRENT_CONTEXT(ctx);
6162 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
6163 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
6164 return islist(ctx, list);
6165 }
6166
6167
6168 /*
6169 * Delete a sequence of consecutive display lists.
6170 */
6171 void GLAPIENTRY
6172 _mesa_DeleteLists( GLuint list, GLsizei range )
6173 {
6174 GET_CURRENT_CONTEXT(ctx);
6175 GLuint i;
6176 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
6177 ASSERT_OUTSIDE_BEGIN_END(ctx);
6178
6179 if (range<0) {
6180 _mesa_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
6181 return;
6182 }
6183 for (i=list;i<list+range;i++) {
6184 _mesa_destroy_list( ctx, i );
6185 }
6186 }
6187
6188
6189
6190 /*
6191 * Return a display list number, n, such that lists n through n+range-1
6192 * are free.
6193 */
6194 GLuint GLAPIENTRY
6195 _mesa_GenLists(GLsizei range )
6196 {
6197 GET_CURRENT_CONTEXT(ctx);
6198 GLuint base;
6199 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
6200 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
6201
6202 if (range<0) {
6203 _mesa_error( ctx, GL_INVALID_VALUE, "glGenLists" );
6204 return 0;
6205 }
6206 if (range==0) {
6207 return 0;
6208 }
6209
6210 /*
6211 * Make this an atomic operation
6212 */
6213 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
6214
6215 base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
6216 if (base) {
6217 /* reserve the list IDs by with empty/dummy lists */
6218 GLint i;
6219 for (i=0; i<range; i++) {
6220 _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
6221 }
6222 }
6223
6224 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
6225
6226 return base;
6227 }
6228
6229
6230
6231 /*
6232 * Begin a new display list.
6233 */
6234 void GLAPIENTRY
6235 _mesa_NewList( GLuint list, GLenum mode )
6236 {
6237 GET_CURRENT_CONTEXT(ctx);
6238 GLint i;
6239
6240 FLUSH_CURRENT(ctx, 0); /* must be called before assert */
6241 ASSERT_OUTSIDE_BEGIN_END(ctx);
6242
6243 if (MESA_VERBOSE&VERBOSE_API)
6244 _mesa_debug(ctx, "glNewList %u %s\n", list,
6245 _mesa_lookup_enum_by_nr(mode));
6246
6247 if (list==0) {
6248 _mesa_error( ctx, GL_INVALID_VALUE, "glNewList" );
6249 return;
6250 }
6251
6252 if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
6253 _mesa_error( ctx, GL_INVALID_ENUM, "glNewList" );
6254 return;
6255 }
6256
6257 if (ctx->ListState.CurrentListPtr) {
6258 /* already compiling a display list */
6259 _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
6260 return;
6261 }
6262
6263 ctx->CompileFlag = GL_TRUE;
6264 ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
6265
6266 /* Allocate new display list */
6267 ctx->ListState.CurrentListNum = list;
6268 ctx->ListState.CurrentBlock = (Node *) CALLOC( sizeof(Node) * BLOCK_SIZE );
6269 ctx->ListState.CurrentListPtr = ctx->ListState.CurrentBlock;
6270 ctx->ListState.CurrentPos = 0;
6271
6272 /* Reset acumulated list state:
6273 */
6274 for (i = 0; i < VERT_ATTRIB_MAX; i++)
6275 ctx->ListState.ActiveAttribSize[i] = 0;
6276
6277 for (i = 0; i < MAT_ATTRIB_MAX; i++)
6278 ctx->ListState.ActiveMaterialSize[i] = 0;
6279
6280 ctx->ListState.ActiveIndex = 0;
6281 ctx->ListState.ActiveEdgeFlag = 0;
6282
6283 ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
6284 ctx->Driver.NewList( ctx, list, mode );
6285
6286 ctx->CurrentDispatch = ctx->Save;
6287 _glapi_set_dispatch( ctx->CurrentDispatch );
6288 }
6289
6290
6291
6292 /*
6293 * End definition of current display list.
6294 */
6295 void GLAPIENTRY
6296 _mesa_EndList( void )
6297 {
6298 GET_CURRENT_CONTEXT(ctx);
6299 SAVE_FLUSH_VERTICES(ctx);
6300 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
6301
6302 if (MESA_VERBOSE&VERBOSE_API)
6303 _mesa_debug(ctx, "glEndList\n");
6304
6305 /* Check that a list is under construction */
6306 if (!ctx->ListState.CurrentListPtr) {
6307 _mesa_error( ctx, GL_INVALID_OPERATION, "glEndList" );
6308 return;
6309 }
6310
6311 (void) ALLOC_INSTRUCTION( ctx, OPCODE_END_OF_LIST, 0 );
6312
6313 /* Destroy old list, if any */
6314 _mesa_destroy_list(ctx, ctx->ListState.CurrentListNum);
6315 /* Install the list */
6316 _mesa_HashInsert(ctx->Shared->DisplayList, ctx->ListState.CurrentListNum, ctx->ListState.CurrentListPtr);
6317
6318
6319 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
6320 mesa_print_display_list(ctx->ListState.CurrentListNum);
6321
6322 ctx->ListState.CurrentListNum = 0;
6323 ctx->ListState.CurrentListPtr = NULL;
6324 ctx->ExecuteFlag = GL_TRUE;
6325 ctx->CompileFlag = GL_FALSE;
6326
6327 ctx->Driver.EndList( ctx );
6328
6329 ctx->CurrentDispatch = ctx->Exec;
6330 _glapi_set_dispatch( ctx->CurrentDispatch );
6331 }
6332
6333
6334
6335 void GLAPIENTRY
6336 _mesa_CallList( GLuint list )
6337 {
6338 GLboolean save_compile_flag;
6339 GET_CURRENT_CONTEXT(ctx);
6340 FLUSH_CURRENT(ctx, 0);
6341 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
6342 /* execute the display list, and restore the CompileFlag. */
6343
6344 if (MESA_VERBOSE & VERBOSE_API)
6345 _mesa_debug(ctx, "glCallList %d\n", list);
6346
6347 if (list == 0) {
6348 _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)");
6349 return;
6350 }
6351
6352 /* mesa_print_display_list( list ); */
6353
6354 save_compile_flag = ctx->CompileFlag;
6355 if (save_compile_flag) {
6356 ctx->CompileFlag = GL_FALSE;
6357 }
6358
6359 execute_list( ctx, list );
6360 ctx->CompileFlag = save_compile_flag;
6361
6362 /* also restore API function pointers to point to "save" versions */
6363 if (save_compile_flag) {
6364 ctx->CurrentDispatch = ctx->Save;
6365 _glapi_set_dispatch( ctx->CurrentDispatch );
6366 }
6367 }
6368
6369
6370
6371 /*
6372 * Execute glCallLists: call multiple display lists.
6373 */
6374 void GLAPIENTRY
6375 _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
6376 {
6377 GET_CURRENT_CONTEXT(ctx);
6378 GLuint list;
6379 GLint i;
6380 GLboolean save_compile_flag;
6381
6382 if (MESA_VERBOSE & VERBOSE_API)
6383 _mesa_debug(ctx, "glCallLists %d\n", n);
6384
6385 switch (type) {
6386 case GL_BYTE:
6387 case GL_UNSIGNED_BYTE:
6388 case GL_SHORT:
6389 case GL_UNSIGNED_SHORT:
6390 case GL_INT:
6391 case GL_UNSIGNED_INT:
6392 case GL_FLOAT:
6393 case GL_2_BYTES:
6394 case GL_3_BYTES:
6395 case GL_4_BYTES:
6396 /* OK */
6397 break;
6398 default:
6399 _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
6400 return;
6401 }
6402
6403 /* Save the CompileFlag status, turn it off, execute display list,
6404 * and restore the CompileFlag.
6405 */
6406 save_compile_flag = ctx->CompileFlag;
6407 ctx->CompileFlag = GL_FALSE;
6408
6409 for (i=0;i<n;i++) {
6410 list = translate_id( i, type, lists );
6411 execute_list( ctx, ctx->List.ListBase + list );
6412 }
6413
6414 ctx->CompileFlag = save_compile_flag;
6415
6416 /* also restore API function pointers to point to "save" versions */
6417 if (save_compile_flag) {
6418 ctx->CurrentDispatch = ctx->Save;
6419 _glapi_set_dispatch( ctx->CurrentDispatch );
6420 }
6421 }
6422
6423
6424
6425 /*
6426 * Set the offset added to list numbers in glCallLists.
6427 */
6428 void GLAPIENTRY
6429 _mesa_ListBase( GLuint base )
6430 {
6431 GET_CURRENT_CONTEXT(ctx);
6432 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
6433 ASSERT_OUTSIDE_BEGIN_END(ctx);
6434 ctx->List.ListBase = base;
6435 }
6436
6437
6438 /* Can no longer assume ctx->Exec->Func is equal to _mesa_Func.
6439 */
6440 static void GLAPIENTRY exec_Finish( void )
6441 {
6442 GET_CURRENT_CONTEXT(ctx);
6443 FLUSH_VERTICES(ctx, 0);
6444 ctx->Exec->Finish();
6445 }
6446
6447 static void GLAPIENTRY exec_Flush( void )
6448 {
6449 GET_CURRENT_CONTEXT(ctx);
6450 FLUSH_VERTICES(ctx, 0);
6451 ctx->Exec->Flush( );
6452 }
6453
6454 static void GLAPIENTRY exec_GetBooleanv( GLenum pname, GLboolean *params )
6455 {
6456 GET_CURRENT_CONTEXT(ctx);
6457 FLUSH_VERTICES(ctx, 0);
6458 ctx->Exec->GetBooleanv( pname, params );
6459 }
6460
6461 static void GLAPIENTRY exec_GetClipPlane( GLenum plane, GLdouble *equation )
6462 {
6463 GET_CURRENT_CONTEXT(ctx);
6464 FLUSH_VERTICES(ctx, 0);
6465 ctx->Exec->GetClipPlane( plane, equation );
6466 }
6467
6468 static void GLAPIENTRY exec_GetDoublev( GLenum pname, GLdouble *params )
6469 {
6470 GET_CURRENT_CONTEXT(ctx);
6471 FLUSH_VERTICES(ctx, 0);
6472 ctx->Exec->GetDoublev( pname, params );
6473 }
6474
6475 static GLenum GLAPIENTRY exec_GetError( void )
6476 {
6477 GET_CURRENT_CONTEXT(ctx);
6478 FLUSH_VERTICES(ctx, 0);
6479 return ctx->Exec->GetError( );
6480 }
6481
6482 static void GLAPIENTRY exec_GetFloatv( GLenum pname, GLfloat *params )
6483 {
6484 GET_CURRENT_CONTEXT(ctx);
6485 FLUSH_VERTICES(ctx, 0);
6486 ctx->Exec->GetFloatv( pname, params );
6487 }
6488
6489 static void GLAPIENTRY exec_GetIntegerv( GLenum pname, GLint *params )
6490 {
6491 GET_CURRENT_CONTEXT(ctx);
6492 FLUSH_VERTICES(ctx, 0);
6493 ctx->Exec->GetIntegerv( pname, params );
6494 }
6495
6496 static void GLAPIENTRY exec_GetLightfv( GLenum light, GLenum pname, GLfloat *params )
6497 {
6498 GET_CURRENT_CONTEXT(ctx);
6499 FLUSH_VERTICES(ctx, 0);
6500 ctx->Exec->GetLightfv( light, pname, params );
6501 }
6502
6503 static void GLAPIENTRY exec_GetLightiv( GLenum light, GLenum pname, GLint *params )
6504 {
6505 GET_CURRENT_CONTEXT(ctx);
6506 FLUSH_VERTICES(ctx, 0);
6507 ctx->Exec->GetLightiv( light, pname, params );
6508 }
6509
6510 static void GLAPIENTRY exec_GetMapdv( GLenum target, GLenum query, GLdouble *v )
6511 {
6512 GET_CURRENT_CONTEXT(ctx);
6513 FLUSH_VERTICES(ctx, 0);
6514 ctx->Exec->GetMapdv( target, query, v );
6515 }
6516
6517 static void GLAPIENTRY exec_GetMapfv( GLenum target, GLenum query, GLfloat *v )
6518 {
6519 GET_CURRENT_CONTEXT(ctx);
6520 FLUSH_VERTICES(ctx, 0);
6521 ctx->Exec->GetMapfv( target, query, v );
6522 }
6523
6524 static void GLAPIENTRY exec_GetMapiv( GLenum target, GLenum query, GLint *v )
6525 {
6526 GET_CURRENT_CONTEXT(ctx);
6527 FLUSH_VERTICES(ctx, 0);
6528 ctx->Exec->GetMapiv( target, query, v );
6529 }
6530
6531 static void GLAPIENTRY exec_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
6532 {
6533 GET_CURRENT_CONTEXT(ctx);
6534 FLUSH_VERTICES(ctx, 0);
6535 ctx->Exec->GetMaterialfv( face, pname, params );
6536 }
6537
6538 static void GLAPIENTRY exec_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
6539 {
6540 GET_CURRENT_CONTEXT(ctx);
6541 FLUSH_VERTICES(ctx, 0);
6542 ctx->Exec->GetMaterialiv( face, pname, params );
6543 }
6544
6545 static void GLAPIENTRY exec_GetPixelMapfv( GLenum map, GLfloat *values )
6546 {
6547 GET_CURRENT_CONTEXT(ctx);
6548 FLUSH_VERTICES(ctx, 0);
6549 ctx->Exec->GetPixelMapfv( map, values );
6550 }
6551
6552 static void GLAPIENTRY exec_GetPixelMapuiv( GLenum map, GLuint *values )
6553 {
6554 GET_CURRENT_CONTEXT(ctx);
6555 FLUSH_VERTICES(ctx, 0);
6556 ctx->Exec->GetPixelMapuiv( map, values );
6557 }
6558
6559 static void GLAPIENTRY exec_GetPixelMapusv( GLenum map, GLushort *values )
6560 {
6561 GET_CURRENT_CONTEXT(ctx);
6562 FLUSH_VERTICES(ctx, 0);
6563 ctx->Exec->GetPixelMapusv( map, values );
6564 }
6565
6566 static void GLAPIENTRY exec_GetPolygonStipple( GLubyte *dest )
6567 {
6568 GET_CURRENT_CONTEXT(ctx);
6569 FLUSH_VERTICES(ctx, 0);
6570 ctx->Exec->GetPolygonStipple( dest );
6571 }
6572
6573 static const GLubyte * GLAPIENTRY exec_GetString( GLenum name )
6574 {
6575 GET_CURRENT_CONTEXT(ctx);
6576 FLUSH_VERTICES(ctx, 0);
6577 return ctx->Exec->GetString( name );
6578 }
6579
6580 static void GLAPIENTRY exec_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
6581 {
6582 GET_CURRENT_CONTEXT(ctx);
6583 FLUSH_VERTICES(ctx, 0);
6584 ctx->Exec->GetTexEnvfv( target, pname, params );
6585 }
6586
6587 static void GLAPIENTRY exec_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
6588 {
6589 GET_CURRENT_CONTEXT(ctx);
6590 FLUSH_VERTICES(ctx, 0);
6591 ctx->Exec->GetTexEnviv( target, pname, params );
6592 }
6593
6594 static void GLAPIENTRY exec_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
6595 {
6596 GET_CURRENT_CONTEXT(ctx);
6597 FLUSH_VERTICES(ctx, 0);
6598 ctx->Exec->GetTexGendv( coord, pname, params );
6599 }
6600
6601 static void GLAPIENTRY exec_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
6602 {
6603 GET_CURRENT_CONTEXT(ctx);
6604 FLUSH_VERTICES(ctx, 0);
6605 ctx->Exec->GetTexGenfv( coord, pname, params );
6606 }
6607
6608 static void GLAPIENTRY exec_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
6609 {
6610 GET_CURRENT_CONTEXT(ctx);
6611 FLUSH_VERTICES(ctx, 0);
6612 ctx->Exec->GetTexGeniv( coord, pname, params );
6613 }
6614
6615 static void GLAPIENTRY exec_GetTexImage( GLenum target, GLint level, GLenum format,
6616 GLenum type, GLvoid *pixels )
6617 {
6618 GET_CURRENT_CONTEXT(ctx);
6619 FLUSH_VERTICES(ctx, 0);
6620 ctx->Exec->GetTexImage( target, level, format, type, pixels );
6621 }
6622
6623 static void GLAPIENTRY exec_GetTexLevelParameterfv( GLenum target, GLint level,
6624 GLenum pname, GLfloat *params )
6625 {
6626 GET_CURRENT_CONTEXT(ctx);
6627 FLUSH_VERTICES(ctx, 0);
6628 ctx->Exec->GetTexLevelParameterfv( target, level, pname, params );
6629 }
6630
6631 static void GLAPIENTRY exec_GetTexLevelParameteriv( GLenum target, GLint level,
6632 GLenum pname, GLint *params )
6633 {
6634 GET_CURRENT_CONTEXT(ctx);
6635 FLUSH_VERTICES(ctx, 0);
6636 ctx->Exec->GetTexLevelParameteriv( target, level, pname, params );
6637 }
6638
6639 static void GLAPIENTRY exec_GetTexParameterfv( GLenum target, GLenum pname,
6640 GLfloat *params )
6641 {
6642 GET_CURRENT_CONTEXT(ctx);
6643 FLUSH_VERTICES(ctx, 0);
6644 ctx->Exec->GetTexParameterfv( target, pname, params );
6645 }
6646
6647 static void GLAPIENTRY exec_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
6648 {
6649 GET_CURRENT_CONTEXT(ctx);
6650 FLUSH_VERTICES(ctx, 0);
6651 ctx->Exec->GetTexParameteriv( target, pname, params );
6652 }
6653
6654 static GLboolean GLAPIENTRY exec_IsEnabled( GLenum cap )
6655 {
6656 GET_CURRENT_CONTEXT(ctx);
6657 FLUSH_VERTICES(ctx, 0);
6658 return ctx->Exec->IsEnabled( cap );
6659 }
6660
6661 static void GLAPIENTRY exec_PixelStoref( GLenum pname, GLfloat param )
6662 {
6663 GET_CURRENT_CONTEXT(ctx);
6664 FLUSH_VERTICES(ctx, 0);
6665 ctx->Exec->PixelStoref( pname, param );
6666 }
6667
6668 static void GLAPIENTRY exec_PixelStorei( GLenum pname, GLint param )
6669 {
6670 GET_CURRENT_CONTEXT(ctx);
6671 FLUSH_VERTICES(ctx, 0);
6672 ctx->Exec->PixelStorei( pname, param );
6673 }
6674
6675 static void GLAPIENTRY exec_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
6676 GLenum format, GLenum type, GLvoid *pixels )
6677 {
6678 GET_CURRENT_CONTEXT(ctx);
6679 FLUSH_VERTICES(ctx, 0);
6680 ctx->Exec->ReadPixels( x, y, width, height, format, type, pixels );
6681 }
6682
6683 static GLint GLAPIENTRY exec_RenderMode( GLenum mode )
6684 {
6685 GET_CURRENT_CONTEXT(ctx);
6686 FLUSH_VERTICES(ctx, 0);
6687 return ctx->Exec->RenderMode( mode );
6688 }
6689
6690 static void GLAPIENTRY exec_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer )
6691 {
6692 GET_CURRENT_CONTEXT(ctx);
6693 FLUSH_VERTICES(ctx, 0);
6694 ctx->Exec->FeedbackBuffer( size, type, buffer );
6695 }
6696
6697 static void GLAPIENTRY exec_SelectBuffer( GLsizei size, GLuint *buffer )
6698 {
6699 GET_CURRENT_CONTEXT(ctx);
6700 FLUSH_VERTICES(ctx, 0);
6701 ctx->Exec->SelectBuffer( size, buffer );
6702 }
6703
6704 static GLboolean GLAPIENTRY exec_AreTexturesResident(GLsizei n, const GLuint *texName,
6705 GLboolean *residences)
6706 {
6707 GET_CURRENT_CONTEXT(ctx);
6708 FLUSH_VERTICES(ctx, 0);
6709 return ctx->Exec->AreTexturesResident( n, texName, residences);
6710 }
6711
6712 static void GLAPIENTRY exec_ColorPointer(GLint size, GLenum type, GLsizei stride,
6713 const GLvoid *ptr)
6714 {
6715 GET_CURRENT_CONTEXT(ctx);
6716 FLUSH_VERTICES(ctx, 0);
6717 ctx->Exec->ColorPointer( size, type, stride, ptr);
6718 }
6719
6720 static void GLAPIENTRY exec_DeleteTextures( GLsizei n, const GLuint *texName)
6721 {
6722 GET_CURRENT_CONTEXT(ctx);
6723 FLUSH_VERTICES(ctx, 0);
6724 ctx->Exec->DeleteTextures( n, texName);
6725 }
6726
6727 static void GLAPIENTRY exec_DisableClientState( GLenum cap )
6728 {
6729 GET_CURRENT_CONTEXT(ctx);
6730 FLUSH_VERTICES(ctx, 0);
6731 ctx->Exec->DisableClientState( cap );
6732 }
6733
6734 static void GLAPIENTRY exec_EdgeFlagPointer(GLsizei stride, const GLvoid *vptr)
6735 {
6736 GET_CURRENT_CONTEXT(ctx);
6737 FLUSH_VERTICES(ctx, 0);
6738 ctx->Exec->EdgeFlagPointer( stride, vptr);
6739 }
6740
6741 static void GLAPIENTRY exec_EnableClientState( GLenum cap )
6742 {
6743 GET_CURRENT_CONTEXT(ctx);
6744 FLUSH_VERTICES(ctx, 0);
6745 ctx->Exec->EnableClientState( cap );
6746 }
6747
6748 static void GLAPIENTRY exec_GenTextures( GLsizei n, GLuint *texName )
6749 {
6750 GET_CURRENT_CONTEXT(ctx);
6751 FLUSH_VERTICES(ctx, 0);
6752 ctx->Exec->GenTextures( n, texName );
6753 }
6754
6755 static void GLAPIENTRY exec_GetPointerv( GLenum pname, GLvoid **params )
6756 {
6757 GET_CURRENT_CONTEXT(ctx);
6758 FLUSH_VERTICES(ctx, 0);
6759 ctx->Exec->GetPointerv( pname, params );
6760 }
6761
6762 static void GLAPIENTRY exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
6763 {
6764 GET_CURRENT_CONTEXT(ctx);
6765 FLUSH_VERTICES(ctx, 0);
6766 ctx->Exec->IndexPointer( type, stride, ptr);
6767 }
6768
6769 static void GLAPIENTRY exec_InterleavedArrays(GLenum format, GLsizei stride,
6770 const GLvoid *pointer)
6771 {
6772 GET_CURRENT_CONTEXT(ctx);
6773 FLUSH_VERTICES(ctx, 0);
6774 ctx->Exec->InterleavedArrays( format, stride, pointer);
6775 }
6776
6777 static GLboolean GLAPIENTRY exec_IsTexture( GLuint texture )
6778 {
6779 GET_CURRENT_CONTEXT(ctx);
6780 FLUSH_VERTICES(ctx, 0);
6781 return ctx->Exec->IsTexture( texture );
6782 }
6783
6784 static void GLAPIENTRY exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
6785 {
6786 GET_CURRENT_CONTEXT(ctx);
6787 FLUSH_VERTICES(ctx, 0);
6788 ctx->Exec->NormalPointer( type, stride, ptr );
6789 }
6790
6791 static void GLAPIENTRY exec_PopClientAttrib(void)
6792 {
6793 GET_CURRENT_CONTEXT(ctx);
6794 FLUSH_VERTICES(ctx, 0);
6795 ctx->Exec->PopClientAttrib();
6796 }
6797
6798 static void GLAPIENTRY exec_PushClientAttrib(GLbitfield mask)
6799 {
6800 GET_CURRENT_CONTEXT(ctx);
6801 FLUSH_VERTICES(ctx, 0);
6802 ctx->Exec->PushClientAttrib( mask);
6803 }
6804
6805 static void GLAPIENTRY exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
6806 const GLvoid *ptr)
6807 {
6808 GET_CURRENT_CONTEXT(ctx);
6809 FLUSH_VERTICES(ctx, 0);
6810 ctx->Exec->TexCoordPointer( size, type, stride, ptr);
6811 }
6812
6813 static void GLAPIENTRY exec_GetCompressedTexImageARB(GLenum target, GLint level,
6814 GLvoid *img)
6815 {
6816 GET_CURRENT_CONTEXT(ctx);
6817 FLUSH_VERTICES(ctx, 0);
6818 ctx->Exec->GetCompressedTexImageARB( target, level, img);
6819 }
6820
6821 static void GLAPIENTRY exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
6822 const GLvoid *ptr)
6823 {
6824 GET_CURRENT_CONTEXT(ctx);
6825 FLUSH_VERTICES(ctx, 0);
6826 ctx->Exec->VertexPointer( size, type, stride, ptr);
6827 }
6828
6829 static void GLAPIENTRY exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
6830 GLint x, GLint y, GLsizei width)
6831 {
6832 GET_CURRENT_CONTEXT(ctx);
6833 FLUSH_VERTICES(ctx, 0);
6834 ctx->Exec->CopyConvolutionFilter1D( target, internalFormat, x, y, width);
6835 }
6836
6837 static void GLAPIENTRY exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat,
6838 GLint x, GLint y, GLsizei width,
6839 GLsizei height)
6840 {
6841 GET_CURRENT_CONTEXT(ctx);
6842 FLUSH_VERTICES(ctx, 0);
6843 ctx->Exec->CopyConvolutionFilter2D( target, internalFormat, x, y, width,
6844 height);
6845 }
6846
6847 static void GLAPIENTRY exec_GetColorTable( GLenum target, GLenum format,
6848 GLenum type, GLvoid *data )
6849 {
6850 GET_CURRENT_CONTEXT(ctx);
6851 FLUSH_VERTICES(ctx, 0);
6852 ctx->Exec->GetColorTable( target, format, type, data );
6853 }
6854
6855 static void GLAPIENTRY exec_GetColorTableParameterfv( GLenum target, GLenum pname,
6856 GLfloat *params )
6857 {
6858 GET_CURRENT_CONTEXT(ctx);
6859 FLUSH_VERTICES(ctx, 0);
6860 ctx->Exec->GetColorTableParameterfv( target, pname, params );
6861 }
6862
6863 static void GLAPIENTRY exec_GetColorTableParameteriv( GLenum target, GLenum pname,
6864 GLint *params )
6865 {
6866 GET_CURRENT_CONTEXT(ctx);
6867 FLUSH_VERTICES(ctx, 0);
6868 ctx->Exec->GetColorTableParameteriv( target, pname, params );
6869 }
6870
6871 static void GLAPIENTRY exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
6872 GLvoid *image)
6873 {
6874 GET_CURRENT_CONTEXT(ctx);
6875 FLUSH_VERTICES(ctx, 0);
6876 ctx->Exec->GetConvolutionFilter( target, format, type, image);
6877 }
6878
6879 static void GLAPIENTRY exec_GetConvolutionParameterfv(GLenum target, GLenum pname,
6880 GLfloat *params)
6881 {
6882 GET_CURRENT_CONTEXT(ctx);
6883 FLUSH_VERTICES(ctx, 0);
6884 ctx->Exec->GetConvolutionParameterfv( target, pname, params);
6885 }
6886
6887 static void GLAPIENTRY exec_GetConvolutionParameteriv(GLenum target, GLenum pname,
6888 GLint *params)
6889 {
6890 GET_CURRENT_CONTEXT(ctx);
6891 FLUSH_VERTICES(ctx, 0);
6892 ctx->Exec->GetConvolutionParameteriv( target, pname, params);
6893 }
6894
6895 static void GLAPIENTRY exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
6896 GLenum type, GLvoid *values)
6897 {
6898 GET_CURRENT_CONTEXT(ctx);
6899 FLUSH_VERTICES(ctx, 0);
6900 ctx->Exec->GetHistogram( target, reset, format, type, values);
6901 }
6902
6903 static void GLAPIENTRY exec_GetHistogramParameterfv(GLenum target, GLenum pname,
6904 GLfloat *params)
6905 {
6906 GET_CURRENT_CONTEXT(ctx);
6907 FLUSH_VERTICES(ctx, 0);
6908 ctx->Exec->GetHistogramParameterfv( target, pname, params);
6909 }
6910
6911 static void GLAPIENTRY exec_GetHistogramParameteriv(GLenum target, GLenum pname,
6912 GLint *params)
6913 {
6914 GET_CURRENT_CONTEXT(ctx);
6915 FLUSH_VERTICES(ctx, 0);
6916 ctx->Exec->GetHistogramParameteriv( target, pname, params);
6917 }
6918
6919 static void GLAPIENTRY exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
6920 GLenum type, GLvoid *values)
6921 {
6922 GET_CURRENT_CONTEXT(ctx);
6923 FLUSH_VERTICES(ctx, 0);
6924 ctx->Exec->GetMinmax( target, reset, format, type, values);
6925 }
6926
6927 static void GLAPIENTRY exec_GetMinmaxParameterfv(GLenum target, GLenum pname,
6928 GLfloat *params)
6929 {
6930 GET_CURRENT_CONTEXT(ctx);
6931 FLUSH_VERTICES(ctx, 0);
6932 ctx->Exec->GetMinmaxParameterfv( target, pname, params);
6933 }
6934
6935 static void GLAPIENTRY exec_GetMinmaxParameteriv(GLenum target, GLenum pname,
6936 GLint *params)
6937 {
6938 GET_CURRENT_CONTEXT(ctx);
6939 FLUSH_VERTICES(ctx, 0);
6940 ctx->Exec->GetMinmaxParameteriv( target, pname, params);
6941 }
6942
6943 static void GLAPIENTRY exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
6944 GLvoid *row, GLvoid *column, GLvoid *span)
6945 {
6946 GET_CURRENT_CONTEXT(ctx);
6947 FLUSH_VERTICES(ctx, 0);
6948 ctx->Exec->GetSeparableFilter( target, format, type, row, column, span);
6949 }
6950
6951 static void GLAPIENTRY exec_SeparableFilter2D(GLenum target, GLenum internalFormat,
6952 GLsizei width, GLsizei height, GLenum format,
6953 GLenum type, const GLvoid *row,
6954 const GLvoid *column)
6955 {
6956 GET_CURRENT_CONTEXT(ctx);
6957 FLUSH_VERTICES(ctx, 0);
6958 ctx->Exec->SeparableFilter2D( target, internalFormat, width, height, format,
6959 type, row, column);
6960 }
6961
6962 static void GLAPIENTRY exec_GetPixelTexGenParameterivSGIS(GLenum target, GLint *value)
6963 {
6964 GET_CURRENT_CONTEXT(ctx);
6965 FLUSH_VERTICES(ctx, 0);
6966 ctx->Exec->GetPixelTexGenParameterivSGIS( target, value);
6967 }
6968
6969 static void GLAPIENTRY exec_GetPixelTexGenParameterfvSGIS(GLenum target, GLfloat *value)
6970 {
6971 GET_CURRENT_CONTEXT(ctx);
6972 FLUSH_VERTICES(ctx, 0);
6973 ctx->Exec->GetPixelTexGenParameterfvSGIS( target, value);
6974 }
6975
6976 static void GLAPIENTRY exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride,
6977 GLsizei count, const GLvoid *ptr)
6978 {
6979 GET_CURRENT_CONTEXT(ctx);
6980 FLUSH_VERTICES(ctx, 0);
6981 ctx->Exec->ColorPointerEXT( size, type, stride, count, ptr);
6982 }
6983
6984 static void GLAPIENTRY exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count,
6985 const GLboolean *ptr)
6986 {
6987 GET_CURRENT_CONTEXT(ctx);
6988 FLUSH_VERTICES(ctx, 0);
6989 ctx->Exec->EdgeFlagPointerEXT( stride, count, ptr);
6990 }
6991
6992 static void GLAPIENTRY exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
6993 const GLvoid *ptr)
6994 {
6995 GET_CURRENT_CONTEXT(ctx);
6996 FLUSH_VERTICES(ctx, 0);
6997 ctx->Exec->IndexPointerEXT( type, stride, count, ptr);
6998 }
6999
7000 static void GLAPIENTRY exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
7001 const GLvoid *ptr)
7002 {
7003 GET_CURRENT_CONTEXT(ctx);
7004 FLUSH_VERTICES(ctx, 0);
7005 ctx->Exec->NormalPointerEXT( type, stride, count, ptr);
7006 }
7007
7008 static void GLAPIENTRY exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
7009 GLsizei count, const GLvoid *ptr)
7010 {
7011 GET_CURRENT_CONTEXT(ctx);
7012 FLUSH_VERTICES(ctx, 0);
7013 ctx->Exec->TexCoordPointerEXT( size, type, stride, count, ptr);
7014 }
7015
7016 static void GLAPIENTRY exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
7017 GLsizei count, const GLvoid *ptr)
7018 {
7019 GET_CURRENT_CONTEXT(ctx);
7020 FLUSH_VERTICES(ctx, 0);
7021 ctx->Exec->VertexPointerEXT( size, type, stride, count, ptr);
7022 }
7023
7024 static void GLAPIENTRY exec_LockArraysEXT(GLint first, GLsizei count)
7025 {
7026 GET_CURRENT_CONTEXT(ctx);
7027 FLUSH_VERTICES(ctx, 0);
7028 ctx->Exec->LockArraysEXT( first, count);
7029 }
7030
7031 static void GLAPIENTRY exec_UnlockArraysEXT( void )
7032 {
7033 GET_CURRENT_CONTEXT(ctx);
7034 FLUSH_VERTICES(ctx, 0);
7035 ctx->Exec->UnlockArraysEXT( );
7036 }
7037
7038 static void GLAPIENTRY exec_ResizeBuffersMESA( void )
7039 {
7040 GET_CURRENT_CONTEXT(ctx);
7041 FLUSH_VERTICES(ctx, 0);
7042 ctx->Exec->ResizeBuffersMESA( );
7043 }
7044
7045
7046 static void GLAPIENTRY exec_ClientActiveTextureARB( GLenum target )
7047 {
7048 GET_CURRENT_CONTEXT(ctx);
7049 FLUSH_VERTICES(ctx, 0);
7050 ctx->Exec->ClientActiveTextureARB(target);
7051 }
7052
7053 static void GLAPIENTRY exec_SecondaryColorPointerEXT(GLint size, GLenum type,
7054 GLsizei stride, const GLvoid *ptr)
7055 {
7056 GET_CURRENT_CONTEXT(ctx);
7057 FLUSH_VERTICES(ctx, 0);
7058 ctx->Exec->SecondaryColorPointerEXT( size, type, stride, ptr);
7059 }
7060
7061 static void GLAPIENTRY exec_FogCoordPointerEXT(GLenum type, GLsizei stride,
7062 const GLvoid *ptr)
7063 {
7064 GET_CURRENT_CONTEXT(ctx);
7065 FLUSH_VERTICES(ctx, 0);
7066 ctx->Exec->FogCoordPointerEXT( type, stride, ptr);
7067 }
7068
7069 /* GL_EXT_multi_draw_arrays */
7070 static void GLAPIENTRY exec_MultiDrawArraysEXT(GLenum mode, GLint *first,
7071 GLsizei *count, GLsizei primcount)
7072 {
7073 GET_CURRENT_CONTEXT(ctx);
7074 FLUSH_VERTICES(ctx, 0);
7075 ctx->Exec->MultiDrawArraysEXT( mode, first, count, primcount );
7076 }
7077
7078 /* GL_EXT_multi_draw_arrays */
7079 static void GLAPIENTRY exec_MultiDrawElementsEXT(GLenum mode, const GLsizei *count,
7080 GLenum type, const GLvoid **indices,
7081 GLsizei primcount)
7082 {
7083 GET_CURRENT_CONTEXT(ctx);
7084 FLUSH_VERTICES(ctx, 0);
7085 ctx->Exec->MultiDrawElementsEXT(mode, count, type, indices, primcount);
7086 }
7087
7088 /* GL_IBM_multimode_draw_arrays */
7089 static void GLAPIENTRY exec_MultiModeDrawArraysIBM(const GLenum *mode, const GLint *first,
7090 const GLsizei *count, GLsizei primcount,
7091 GLint modestride)
7092 {
7093 GET_CURRENT_CONTEXT(ctx);
7094 FLUSH_VERTICES(ctx, 0);
7095 ctx->Exec->MultiModeDrawArraysIBM(mode, first, count, primcount, modestride);
7096 }
7097
7098 /* GL_IBM_multimode_draw_arrays */
7099 static void GLAPIENTRY exec_MultiModeDrawElementsIBM(const GLenum *mode,
7100 const GLsizei *count,
7101 GLenum type,
7102 const GLvoid * const *indices,
7103 GLsizei primcount, GLint modestride)
7104 {
7105 GET_CURRENT_CONTEXT(ctx);
7106 FLUSH_VERTICES(ctx, 0);
7107 ctx->Exec->MultiModeDrawElementsIBM(mode, count, type, indices, primcount,
7108 modestride);
7109 }
7110
7111
7112
7113
7114 /**
7115 * Setup the given dispatch table to point to Mesa's display list
7116 * building functions.
7117 *
7118 * This does not include any of the tnl functions - they are
7119 * initialized from _mesa_init_api_defaults and from the active vtxfmt
7120 * struct.
7121 */
7122 void
7123 _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
7124 {
7125 _mesa_init_no_op_table(table, tableSize);
7126
7127 _mesa_loopback_init_api_table( table );
7128
7129 /* GL 1.0 */
7130 table->Accum = save_Accum;
7131 table->AlphaFunc = save_AlphaFunc;
7132 table->Bitmap = save_Bitmap;
7133 table->BlendFunc = _mesa_BlendFunc; /* loops-back to BlendFuncSeparate */
7134 table->CallList = _mesa_save_CallList;
7135 table->CallLists = _mesa_save_CallLists;
7136 table->Clear = save_Clear;
7137 table->ClearAccum = save_ClearAccum;
7138 table->ClearColor = save_ClearColor;
7139 table->ClearDepth = save_ClearDepth;
7140 table->ClearIndex = save_ClearIndex;
7141 table->ClearStencil = save_ClearStencil;
7142 table->ClipPlane = save_ClipPlane;
7143 table->ColorMask = save_ColorMask;
7144 table->ColorMaterial = save_ColorMaterial;
7145 table->CopyPixels = save_CopyPixels;
7146 table->CullFace = save_CullFace;
7147 table->DeleteLists = _mesa_DeleteLists;
7148 table->DepthFunc = save_DepthFunc;
7149 table->DepthMask = save_DepthMask;
7150 table->DepthRange = save_DepthRange;
7151 table->Disable = save_Disable;
7152 table->DrawBuffer = save_DrawBuffer;
7153 table->DrawPixels = save_DrawPixels;
7154 table->Enable = save_Enable;
7155 table->EndList = _mesa_EndList;
7156 table->EvalMesh1 = _mesa_save_EvalMesh1;
7157 table->EvalMesh2 = _mesa_save_EvalMesh2;
7158 table->Finish = exec_Finish;
7159 table->Flush = exec_Flush;
7160 table->Fogf = save_Fogf;
7161 table->Fogfv = save_Fogfv;
7162 table->Fogi = save_Fogi;
7163 table->Fogiv = save_Fogiv;
7164 table->FrontFace = save_FrontFace;
7165 table->Frustum = save_Frustum;
7166 table->GenLists = _mesa_GenLists;
7167 table->GetBooleanv = exec_GetBooleanv;
7168 table->GetClipPlane = exec_GetClipPlane;
7169 table->GetDoublev = exec_GetDoublev;
7170 table->GetError = exec_GetError;
7171 table->GetFloatv = exec_GetFloatv;
7172 table->GetIntegerv = exec_GetIntegerv;
7173 table->GetLightfv = exec_GetLightfv;
7174 table->GetLightiv = exec_GetLightiv;
7175 table->GetMapdv = exec_GetMapdv;
7176 table->GetMapfv = exec_GetMapfv;
7177 table->GetMapiv = exec_GetMapiv;
7178 table->GetMaterialfv = exec_GetMaterialfv;
7179 table->GetMaterialiv = exec_GetMaterialiv;
7180 table->GetPixelMapfv = exec_GetPixelMapfv;
7181 table->GetPixelMapuiv = exec_GetPixelMapuiv;
7182 table->GetPixelMapusv = exec_GetPixelMapusv;
7183 table->GetPolygonStipple = exec_GetPolygonStipple;
7184 table->GetString = exec_GetString;
7185 table->GetTexEnvfv = exec_GetTexEnvfv;
7186 table->GetTexEnviv = exec_GetTexEnviv;
7187 table->GetTexGendv = exec_GetTexGendv;
7188 table->GetTexGenfv = exec_GetTexGenfv;
7189 table->GetTexGeniv = exec_GetTexGeniv;
7190 table->GetTexImage = exec_GetTexImage;
7191 table->GetTexLevelParameterfv = exec_GetTexLevelParameterfv;
7192 table->GetTexLevelParameteriv = exec_GetTexLevelParameteriv;
7193 table->GetTexParameterfv = exec_GetTexParameterfv;
7194 table->GetTexParameteriv = exec_GetTexParameteriv;
7195 table->Hint = save_Hint;
7196 table->IndexMask = save_IndexMask;
7197 table->InitNames = save_InitNames;
7198 table->IsEnabled = exec_IsEnabled;
7199 table->IsList = _mesa_IsList;
7200 table->LightModelf = save_LightModelf;
7201 table->LightModelfv = save_LightModelfv;
7202 table->LightModeli = save_LightModeli;
7203 table->LightModeliv = save_LightModeliv;
7204 table->Lightf = save_Lightf;
7205 table->Lightfv = save_Lightfv;
7206 table->Lighti = save_Lighti;
7207 table->Lightiv = save_Lightiv;
7208 table->LineStipple = save_LineStipple;
7209 table->LineWidth = save_LineWidth;
7210 table->ListBase = save_ListBase;
7211 table->LoadIdentity = save_LoadIdentity;
7212 table->LoadMatrixd = save_LoadMatrixd;
7213 table->LoadMatrixf = save_LoadMatrixf;
7214 table->LoadName = save_LoadName;
7215 table->LogicOp = save_LogicOp;
7216 table->Map1d = save_Map1d;
7217 table->Map1f = save_Map1f;
7218 table->Map2d = save_Map2d;
7219 table->Map2f = save_Map2f;
7220 table->MapGrid1d = save_MapGrid1d;
7221 table->MapGrid1f = save_MapGrid1f;
7222 table->MapGrid2d = save_MapGrid2d;
7223 table->MapGrid2f = save_MapGrid2f;
7224 table->MatrixMode = save_MatrixMode;
7225 table->MultMatrixd = save_MultMatrixd;
7226 table->MultMatrixf = save_MultMatrixf;
7227 table->NewList = save_NewList;
7228 table->Ortho = save_Ortho;
7229 table->PassThrough = save_PassThrough;
7230 table->PixelMapfv = save_PixelMapfv;
7231 table->PixelMapuiv = save_PixelMapuiv;
7232 table->PixelMapusv = save_PixelMapusv;
7233 table->PixelStoref = exec_PixelStoref;
7234 table->PixelStorei = exec_PixelStorei;
7235 table->PixelTransferf = save_PixelTransferf;
7236 table->PixelTransferi = save_PixelTransferi;
7237 table->PixelZoom = save_PixelZoom;
7238 table->PointSize = save_PointSize;
7239 table->PolygonMode = save_PolygonMode;
7240 table->PolygonOffset = save_PolygonOffset;
7241 table->PolygonStipple = save_PolygonStipple;
7242 table->PopAttrib = save_PopAttrib;
7243 table->PopMatrix = save_PopMatrix;
7244 table->PopName = save_PopName;
7245 table->PushAttrib = save_PushAttrib;
7246 table->PushMatrix = save_PushMatrix;
7247 table->PushName = save_PushName;
7248 table->RasterPos2d = save_RasterPos2d;
7249 table->RasterPos2dv = save_RasterPos2dv;
7250 table->RasterPos2f = save_RasterPos2f;
7251 table->RasterPos2fv = save_RasterPos2fv;
7252 table->RasterPos2i = save_RasterPos2i;
7253 table->RasterPos2iv = save_RasterPos2iv;
7254 table->RasterPos2s = save_RasterPos2s;
7255 table->RasterPos2sv = save_RasterPos2sv;
7256 table->RasterPos3d = save_RasterPos3d;
7257 table->RasterPos3dv = save_RasterPos3dv;
7258 table->RasterPos3f = save_RasterPos3f;
7259 table->RasterPos3fv = save_RasterPos3fv;
7260 table->RasterPos3i = save_RasterPos3i;
7261 table->RasterPos3iv = save_RasterPos3iv;
7262 table->RasterPos3s = save_RasterPos3s;
7263 table->RasterPos3sv = save_RasterPos3sv;
7264 table->RasterPos4d = save_RasterPos4d;
7265 table->RasterPos4dv = save_RasterPos4dv;
7266 table->RasterPos4f = save_RasterPos4f;
7267 table->RasterPos4fv = save_RasterPos4fv;
7268 table->RasterPos4i = save_RasterPos4i;
7269 table->RasterPos4iv = save_RasterPos4iv;
7270 table->RasterPos4s = save_RasterPos4s;
7271 table->RasterPos4sv = save_RasterPos4sv;
7272 table->ReadBuffer = save_ReadBuffer;
7273 table->ReadPixels = exec_ReadPixels;
7274 table->RenderMode = exec_RenderMode;
7275 table->Rotated = save_Rotated;
7276 table->Rotatef = save_Rotatef;
7277 table->Scaled = save_Scaled;
7278 table->Scalef = save_Scalef;
7279 table->Scissor = save_Scissor;
7280 table->FeedbackBuffer = exec_FeedbackBuffer;
7281 table->SelectBuffer = exec_SelectBuffer;
7282 table->ShadeModel = save_ShadeModel;
7283 table->StencilFunc = save_StencilFunc;
7284 table->StencilMask = save_StencilMask;
7285 table->StencilOp = save_StencilOp;
7286 table->TexEnvf = save_TexEnvf;
7287 table->TexEnvfv = save_TexEnvfv;
7288 table->TexEnvi = save_TexEnvi;
7289 table->TexEnviv = save_TexEnviv;
7290 table->TexGend = save_TexGend;
7291 table->TexGendv = save_TexGendv;
7292 table->TexGenf = save_TexGenf;
7293 table->TexGenfv = save_TexGenfv;
7294 table->TexGeni = save_TexGeni;
7295 table->TexGeniv = save_TexGeniv;
7296 table->TexImage1D = save_TexImage1D;
7297 table->TexImage2D = save_TexImage2D;
7298 table->TexParameterf = save_TexParameterf;
7299 table->TexParameterfv = save_TexParameterfv;
7300 table->TexParameteri = save_TexParameteri;
7301 table->TexParameteriv = save_TexParameteriv;
7302 table->Translated = save_Translated;
7303 table->Translatef = save_Translatef;
7304 table->Viewport = save_Viewport;
7305
7306 /* GL 1.1 */
7307 table->AreTexturesResident = exec_AreTexturesResident;
7308 table->AreTexturesResidentEXT = exec_AreTexturesResident;
7309 table->BindTexture = save_BindTexture;
7310 table->ColorPointer = exec_ColorPointer;
7311 table->CopyTexImage1D = save_CopyTexImage1D;
7312 table->CopyTexImage2D = save_CopyTexImage2D;
7313 table->CopyTexSubImage1D = save_CopyTexSubImage1D;
7314 table->CopyTexSubImage2D = save_CopyTexSubImage2D;
7315 table->DeleteTextures = exec_DeleteTextures;
7316 table->DisableClientState = exec_DisableClientState;
7317 table->EdgeFlagPointer = exec_EdgeFlagPointer;
7318 table->EnableClientState = exec_EnableClientState;
7319 table->GenTextures = exec_GenTextures;
7320 table->GenTexturesEXT = exec_GenTextures;
7321 table->GetPointerv = exec_GetPointerv;
7322 table->IndexPointer = exec_IndexPointer;
7323 table->InterleavedArrays = exec_InterleavedArrays;
7324 table->IsTexture = exec_IsTexture;
7325 table->IsTextureEXT = exec_IsTexture;
7326 table->NormalPointer = exec_NormalPointer;
7327 table->PopClientAttrib = exec_PopClientAttrib;
7328 table->PrioritizeTextures = save_PrioritizeTextures;
7329 table->PushClientAttrib = exec_PushClientAttrib;
7330 table->TexCoordPointer = exec_TexCoordPointer;
7331 table->TexSubImage1D = save_TexSubImage1D;
7332 table->TexSubImage2D = save_TexSubImage2D;
7333 table->VertexPointer = exec_VertexPointer;
7334
7335 /* GL 1.2 */
7336 table->CopyTexSubImage3D = save_CopyTexSubImage3D;
7337 table->TexImage3D = save_TexImage3D;
7338 table->TexSubImage3D = save_TexSubImage3D;
7339
7340 /* GL_ARB_imaging */
7341 /* Not all are supported */
7342 table->BlendColor = save_BlendColor;
7343 table->BlendEquation = save_BlendEquation;
7344 table->ColorSubTable = save_ColorSubTable;
7345 table->ColorTable = save_ColorTable;
7346 table->ColorTableParameterfv = save_ColorTableParameterfv;
7347 table->ColorTableParameteriv = save_ColorTableParameteriv;
7348 table->ConvolutionFilter1D = save_ConvolutionFilter1D;
7349 table->ConvolutionFilter2D = save_ConvolutionFilter2D;
7350 table->ConvolutionParameterf = save_ConvolutionParameterf;
7351 table->ConvolutionParameterfv = save_ConvolutionParameterfv;
7352 table->ConvolutionParameteri = save_ConvolutionParameteri;
7353 table->ConvolutionParameteriv = save_ConvolutionParameteriv;
7354 table->CopyColorSubTable = save_CopyColorSubTable;
7355 table->CopyColorTable = save_CopyColorTable;
7356 table->CopyConvolutionFilter1D = exec_CopyConvolutionFilter1D;
7357 table->CopyConvolutionFilter2D = exec_CopyConvolutionFilter2D;
7358 table->GetColorTable = exec_GetColorTable;
7359 table->GetColorTableEXT = exec_GetColorTable;
7360 table->GetColorTableParameterfv = exec_GetColorTableParameterfv;
7361 table->GetColorTableParameterfvEXT = exec_GetColorTableParameterfv;
7362 table->GetColorTableParameteriv = exec_GetColorTableParameteriv;
7363 table->GetColorTableParameterivEXT = exec_GetColorTableParameteriv;
7364 table->GetConvolutionFilter = exec_GetConvolutionFilter;
7365 table->GetConvolutionFilterEXT = exec_GetConvolutionFilter;
7366 table->GetConvolutionParameterfv = exec_GetConvolutionParameterfv;
7367 table->GetConvolutionParameterfvEXT = exec_GetConvolutionParameterfv;
7368 table->GetConvolutionParameteriv = exec_GetConvolutionParameteriv;
7369 table->GetConvolutionParameterivEXT = exec_GetConvolutionParameteriv;
7370 table->GetHistogram = exec_GetHistogram;
7371 table->GetHistogramEXT = exec_GetHistogram;
7372 table->GetHistogramParameterfv = exec_GetHistogramParameterfv;
7373 table->GetHistogramParameterfvEXT = exec_GetHistogramParameterfv;
7374 table->GetHistogramParameteriv = exec_GetHistogramParameteriv;
7375 table->GetHistogramParameterivEXT = exec_GetHistogramParameteriv;
7376 table->GetMinmax = exec_GetMinmax;
7377 table->GetMinmaxEXT = exec_GetMinmax;
7378 table->GetMinmaxParameterfv = exec_GetMinmaxParameterfv;
7379 table->GetMinmaxParameterfvEXT = exec_GetMinmaxParameterfv;
7380 table->GetMinmaxParameteriv = exec_GetMinmaxParameteriv;
7381 table->GetMinmaxParameterivEXT = exec_GetMinmaxParameteriv;
7382 table->GetSeparableFilter = exec_GetSeparableFilter;
7383 table->GetSeparableFilterEXT = exec_GetSeparableFilter;
7384 table->Histogram = save_Histogram;
7385 table->Minmax = save_Minmax;
7386 table->ResetHistogram = save_ResetHistogram;
7387 table->ResetMinmax = save_ResetMinmax;
7388 table->SeparableFilter2D = exec_SeparableFilter2D;
7389
7390 /* 2. GL_EXT_blend_color */
7391 #if 0
7392 table->BlendColorEXT = save_BlendColorEXT;
7393 #endif
7394
7395 /* 3. GL_EXT_polygon_offset */
7396 table->PolygonOffsetEXT = save_PolygonOffsetEXT;
7397
7398 /* 6. GL_EXT_texture3d */
7399 #if 0
7400 table->CopyTexSubImage3DEXT = save_CopyTexSubImage3D;
7401 table->TexImage3DEXT = save_TexImage3DEXT;
7402 table->TexSubImage3DEXT = save_TexSubImage3D;
7403 #endif
7404
7405 /* 15. GL_SGIX_pixel_texture */
7406 table->PixelTexGenSGIX = save_PixelTexGenSGIX;
7407
7408 /* 15. GL_SGIS_pixel_texture */
7409 table->PixelTexGenParameteriSGIS = save_PixelTexGenParameteriSGIS;
7410 table->PixelTexGenParameterfSGIS = save_PixelTexGenParameterfSGIS;
7411 table->PixelTexGenParameterivSGIS = save_PixelTexGenParameterivSGIS;
7412 table->PixelTexGenParameterfvSGIS = save_PixelTexGenParameterfvSGIS;
7413 table->GetPixelTexGenParameterivSGIS = exec_GetPixelTexGenParameterivSGIS;
7414 table->GetPixelTexGenParameterfvSGIS = exec_GetPixelTexGenParameterfvSGIS;
7415
7416 /* 30. GL_EXT_vertex_array */
7417 table->ColorPointerEXT = exec_ColorPointerEXT;
7418 table->EdgeFlagPointerEXT = exec_EdgeFlagPointerEXT;
7419 table->IndexPointerEXT = exec_IndexPointerEXT;
7420 table->NormalPointerEXT = exec_NormalPointerEXT;
7421 table->TexCoordPointerEXT = exec_TexCoordPointerEXT;
7422 table->VertexPointerEXT = exec_VertexPointerEXT;
7423
7424 /* 37. GL_EXT_blend_minmax */
7425 #if 0
7426 table->BlendEquationEXT = save_BlendEquationEXT;
7427 #endif
7428
7429 /* 54. GL_EXT_point_parameters */
7430 table->PointParameterfEXT = save_PointParameterfEXT;
7431 table->PointParameterfvEXT = save_PointParameterfvEXT;
7432
7433 /* 78. GL_EXT_paletted_texture */
7434 #if 0
7435 table->ColorTableEXT = save_ColorTable;
7436 table->ColorSubTableEXT = save_ColorSubTable;
7437 #endif
7438 table->GetColorTableEXT = exec_GetColorTable;
7439 table->GetColorTableParameterfvEXT = exec_GetColorTableParameterfv;
7440 table->GetColorTableParameterivEXT = exec_GetColorTableParameteriv;
7441
7442 /* 97. GL_EXT_compiled_vertex_array */
7443 table->LockArraysEXT = exec_LockArraysEXT;
7444 table->UnlockArraysEXT = exec_UnlockArraysEXT;
7445
7446 /* 145. GL_EXT_secondary_color */
7447 table->SecondaryColorPointerEXT = exec_SecondaryColorPointerEXT;
7448
7449 /* 148. GL_EXT_multi_draw_arrays */
7450 table->MultiDrawArraysEXT = exec_MultiDrawArraysEXT;
7451 table->MultiDrawElementsEXT = exec_MultiDrawElementsEXT;
7452
7453 /* 149. GL_EXT_fog_coord */
7454 table->FogCoordPointerEXT = exec_FogCoordPointerEXT;
7455
7456 /* 173. GL_EXT_blend_func_separate */
7457 table->BlendFuncSeparateEXT = save_BlendFuncSeparateEXT;
7458
7459 /* 196. GL_MESA_resize_buffers */
7460 table->ResizeBuffersMESA = exec_ResizeBuffersMESA;
7461
7462 /* 197. GL_MESA_window_pos */
7463 table->WindowPos2dMESA = save_WindowPos2dMESA;
7464 table->WindowPos2dvMESA = save_WindowPos2dvMESA;
7465 table->WindowPos2fMESA = save_WindowPos2fMESA;
7466 table->WindowPos2fvMESA = save_WindowPos2fvMESA;
7467 table->WindowPos2iMESA = save_WindowPos2iMESA;
7468 table->WindowPos2ivMESA = save_WindowPos2ivMESA;
7469 table->WindowPos2sMESA = save_WindowPos2sMESA;
7470 table->WindowPos2svMESA = save_WindowPos2svMESA;
7471 table->WindowPos3dMESA = save_WindowPos3dMESA;
7472 table->WindowPos3dvMESA = save_WindowPos3dvMESA;
7473 table->WindowPos3fMESA = save_WindowPos3fMESA;
7474 table->WindowPos3fvMESA = save_WindowPos3fvMESA;
7475 table->WindowPos3iMESA = save_WindowPos3iMESA;
7476 table->WindowPos3ivMESA = save_WindowPos3ivMESA;
7477 table->WindowPos3sMESA = save_WindowPos3sMESA;
7478 table->WindowPos3svMESA = save_WindowPos3svMESA;
7479 table->WindowPos4dMESA = save_WindowPos4dMESA;
7480 table->WindowPos4dvMESA = save_WindowPos4dvMESA;
7481 table->WindowPos4fMESA = save_WindowPos4fMESA;
7482 table->WindowPos4fvMESA = save_WindowPos4fvMESA;
7483 table->WindowPos4iMESA = save_WindowPos4iMESA;
7484 table->WindowPos4ivMESA = save_WindowPos4ivMESA;
7485 table->WindowPos4sMESA = save_WindowPos4sMESA;
7486 table->WindowPos4svMESA = save_WindowPos4svMESA;
7487
7488 /* 200. GL_IBM_multimode_draw_arrays */
7489 table->MultiModeDrawArraysIBM = exec_MultiModeDrawArraysIBM;
7490 table->MultiModeDrawElementsIBM = exec_MultiModeDrawElementsIBM;
7491
7492 #if FEATURE_NV_vertex_program
7493 /* 233. GL_NV_vertex_program */
7494 /* The following commands DO NOT go into display lists:
7495 * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV,
7496 * VertexAttribPointerNV, GetProgram*, GetVertexAttrib*
7497 */
7498 table->BindProgramNV = save_BindProgramNV;
7499 table->DeleteProgramsNV = _mesa_DeletePrograms;
7500 table->ExecuteProgramNV = save_ExecuteProgramNV;
7501 table->GenProgramsNV = _mesa_GenPrograms;
7502 table->AreProgramsResidentNV = _mesa_AreProgramsResidentNV;
7503 table->RequestResidentProgramsNV = save_RequestResidentProgramsNV;
7504 table->GetProgramParameterfvNV = _mesa_GetProgramParameterfvNV;
7505 table->GetProgramParameterdvNV = _mesa_GetProgramParameterdvNV;
7506 table->GetProgramivNV = _mesa_GetProgramivNV;
7507 table->GetProgramStringNV = _mesa_GetProgramStringNV;
7508 table->GetTrackMatrixivNV = _mesa_GetTrackMatrixivNV;
7509 table->GetVertexAttribdvNV = _mesa_GetVertexAttribdvNV;
7510 table->GetVertexAttribfvNV = _mesa_GetVertexAttribfvNV;
7511 table->GetVertexAttribivNV = _mesa_GetVertexAttribivNV;
7512 table->GetVertexAttribPointervNV = _mesa_GetVertexAttribPointervNV;
7513 table->IsProgramNV = _mesa_IsProgram;
7514 table->LoadProgramNV = save_LoadProgramNV;
7515 table->ProgramParameter4dNV = save_ProgramParameter4dNV;
7516 table->ProgramParameter4dvNV = save_ProgramParameter4dvNV;
7517 table->ProgramParameter4fNV = save_ProgramParameter4fNV;
7518 table->ProgramParameter4fvNV = save_ProgramParameter4fvNV;
7519 table->ProgramParameters4dvNV = save_ProgramParameters4dvNV;
7520 table->ProgramParameters4fvNV = save_ProgramParameters4fvNV;
7521 table->TrackMatrixNV = save_TrackMatrixNV;
7522 table->VertexAttribPointerNV = _mesa_VertexAttribPointerNV;
7523 #endif
7524
7525 /* 282. GL_NV_fragment_program */
7526 #if FEATURE_NV_fragment_program
7527 table->ProgramNamedParameter4fNV = save_ProgramNamedParameter4fNV;
7528 table->ProgramNamedParameter4dNV = save_ProgramNamedParameter4dNV;
7529 table->ProgramNamedParameter4fvNV = save_ProgramNamedParameter4fvNV;
7530 table->ProgramNamedParameter4dvNV = save_ProgramNamedParameter4dvNV;
7531 table->GetProgramNamedParameterfvNV = _mesa_GetProgramNamedParameterfvNV;
7532 table->GetProgramNamedParameterdvNV = _mesa_GetProgramNamedParameterdvNV;
7533 table->ProgramLocalParameter4dARB = save_ProgramLocalParameter4dARB;
7534 table->ProgramLocalParameter4dvARB = save_ProgramLocalParameter4dvARB;
7535 table->ProgramLocalParameter4fARB = save_ProgramLocalParameter4fARB;
7536 table->ProgramLocalParameter4fvARB = save_ProgramLocalParameter4fvARB;
7537 table->GetProgramLocalParameterdvARB = _mesa_GetProgramLocalParameterdvARB;
7538 table->GetProgramLocalParameterfvARB = _mesa_GetProgramLocalParameterfvARB;
7539 #endif
7540
7541 /* 262. GL_NV_point_sprite */
7542 table->PointParameteriNV = save_PointParameteriNV;
7543 table->PointParameterivNV = save_PointParameterivNV;
7544
7545 /* 268. GL_EXT_stencil_two_side */
7546 table->ActiveStencilFaceEXT = save_ActiveStencilFaceEXT;
7547
7548 /* ???. GL_EXT_depth_bounds_test */
7549 table->DepthBoundsEXT = save_DepthBoundsEXT;
7550
7551 /* ARB 1. GL_ARB_multitexture */
7552 table->ActiveTextureARB = save_ActiveTextureARB;
7553 table->ClientActiveTextureARB = exec_ClientActiveTextureARB;
7554
7555 /* ARB 3. GL_ARB_transpose_matrix */
7556 table->LoadTransposeMatrixdARB = save_LoadTransposeMatrixdARB;
7557 table->LoadTransposeMatrixfARB = save_LoadTransposeMatrixfARB;
7558 table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB;
7559 table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB;
7560
7561 /* ARB 5. GL_ARB_multisample */
7562 table->SampleCoverageARB = save_SampleCoverageARB;
7563
7564 /* ARB 12. GL_ARB_texture_compression */
7565 table->CompressedTexImage3DARB = save_CompressedTexImage3DARB;
7566 table->CompressedTexImage2DARB = save_CompressedTexImage2DARB;
7567 table->CompressedTexImage1DARB = save_CompressedTexImage1DARB;
7568 table->CompressedTexSubImage3DARB = save_CompressedTexSubImage3DARB;
7569 table->CompressedTexSubImage2DARB = save_CompressedTexSubImage2DARB;
7570 table->CompressedTexSubImage1DARB = save_CompressedTexSubImage1DARB;
7571 table->GetCompressedTexImageARB = exec_GetCompressedTexImageARB;
7572
7573 /* ARB 14. GL_ARB_point_parameters */
7574 /* aliased with EXT_point_parameters functions */
7575
7576 /* ARB 25. GL_ARB_window_pos */
7577 /* aliased with MESA_window_pos functions */
7578
7579 /* ARB 26. GL_ARB_vertex_program */
7580 /* ARB 27. GL_ARB_fragment_program */
7581 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
7582 /* glVertexAttrib* functions alias the NV ones, handled elsewhere */
7583 table->VertexAttribPointerARB = _mesa_VertexAttribPointerARB;
7584 table->EnableVertexAttribArrayARB = _mesa_EnableVertexAttribArrayARB;
7585 table->DisableVertexAttribArrayARB = _mesa_DisableVertexAttribArrayARB;
7586 table->ProgramStringARB = save_ProgramStringARB;
7587 table->BindProgramNV = save_BindProgramNV;
7588 table->DeleteProgramsNV = _mesa_DeletePrograms;
7589 table->GenProgramsNV = _mesa_GenPrograms;
7590 table->IsProgramNV = _mesa_IsProgram;
7591 table->GetVertexAttribdvNV = _mesa_GetVertexAttribdvNV;
7592 table->GetVertexAttribfvNV = _mesa_GetVertexAttribfvNV;
7593 table->GetVertexAttribivNV = _mesa_GetVertexAttribivNV;
7594 table->GetVertexAttribPointervNV = _mesa_GetVertexAttribPointervNV;
7595 table->ProgramEnvParameter4dARB = save_ProgramEnvParameter4dARB;
7596 table->ProgramEnvParameter4dvARB = save_ProgramEnvParameter4dvARB;
7597 table->ProgramEnvParameter4fARB = save_ProgramEnvParameter4fARB;
7598 table->ProgramEnvParameter4fvARB = save_ProgramEnvParameter4fvARB;
7599 table->ProgramLocalParameter4dARB = save_ProgramLocalParameter4dARB;
7600 table->ProgramLocalParameter4dvARB = save_ProgramLocalParameter4dvARB;
7601 table->ProgramLocalParameter4fARB = save_ProgramLocalParameter4fARB;
7602 table->ProgramLocalParameter4fvARB = save_ProgramLocalParameter4fvARB;
7603 table->GetProgramEnvParameterdvARB = _mesa_GetProgramEnvParameterdvARB;
7604 table->GetProgramEnvParameterfvARB = _mesa_GetProgramEnvParameterfvARB;
7605 table->GetProgramLocalParameterdvARB = _mesa_GetProgramLocalParameterdvARB;
7606 table->GetProgramLocalParameterfvARB = _mesa_GetProgramLocalParameterfvARB;
7607 table->GetProgramivARB = _mesa_GetProgramivARB;
7608 table->GetProgramStringARB = _mesa_GetProgramStringARB;
7609 #endif
7610
7611 /* ARB 28. GL_ARB_vertex_buffer_object */
7612 #if FEATURE_ARB_vertex_buffer_object
7613 /* None of the extension's functions get compiled */
7614 table->BindBufferARB = _mesa_BindBufferARB;
7615 table->BufferDataARB = _mesa_BufferDataARB;
7616 table->BufferSubDataARB = _mesa_BufferSubDataARB;
7617 table->DeleteBuffersARB = _mesa_DeleteBuffersARB;
7618 table->GenBuffersARB = _mesa_GenBuffersARB;
7619 table->GetBufferParameterivARB = _mesa_GetBufferParameterivARB;
7620 table->GetBufferPointervARB = _mesa_GetBufferPointervARB;
7621 table->GetBufferSubDataARB = _mesa_GetBufferSubDataARB;
7622 table->IsBufferARB = _mesa_IsBufferARB;
7623 table->MapBufferARB = _mesa_MapBufferARB;
7624 table->UnmapBufferARB = _mesa_UnmapBufferARB;
7625 #endif
7626
7627 #if FEATURE_ARB_occlusion_query
7628 table->BeginQueryARB = save_BeginQueryARB;
7629 table->EndQueryARB = save_EndQueryARB;
7630 table->GenQueriesARB = _mesa_GenQueriesARB;
7631 table->DeleteQueriesARB = _mesa_DeleteQueriesARB;
7632 table->IsQueryARB = _mesa_IsQueryARB;
7633 table->GetQueryivARB = _mesa_GetQueryivARB;
7634 table->GetQueryObjectivARB = _mesa_GetQueryObjectivARB;
7635 table->GetQueryObjectuivARB = _mesa_GetQueryObjectuivARB;
7636 #endif
7637
7638 /* 299. GL_EXT_blend_equation_separate */
7639 table->BlendEquationSeparateEXT = save_BlendEquationSeparateEXT;
7640 }
7641
7642
7643
7644 /***
7645 *** Debugging code
7646 ***/
7647 static const char *enum_string( GLenum k )
7648 {
7649 return _mesa_lookup_enum_by_nr( k );
7650 }
7651
7652
7653 /*
7654 * Print the commands in a display list. For debugging only.
7655 * TODO: many commands aren't handled yet.
7656 */
7657 static void GLAPIENTRY print_list( GLcontext *ctx, GLuint list )
7658 {
7659 Node *n;
7660 GLboolean done;
7661
7662 if (!glIsList(list)) {
7663 _mesa_printf("%u is not a display list ID\n", list);
7664 return;
7665 }
7666
7667 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
7668
7669 _mesa_printf("START-LIST %u, address %p\n", list, (void*)n );
7670
7671 done = n ? GL_FALSE : GL_TRUE;
7672 while (!done) {
7673 OpCode opcode = n[0].opcode;
7674 GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
7675
7676 if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
7677 /* this is a driver-extended opcode */
7678 ctx->ListExt.Opcode[i].Print(ctx, &n[1]);
7679 n += ctx->ListExt.Opcode[i].Size;
7680 }
7681 else {
7682 switch (opcode) {
7683 case OPCODE_ACCUM:
7684 _mesa_printf("accum %s %g\n", enum_string(n[1].e), n[2].f );
7685 break;
7686 case OPCODE_BITMAP:
7687 _mesa_printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
7688 n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
7689 break;
7690 case OPCODE_CALL_LIST:
7691 _mesa_printf("CallList %d\n", (int) n[1].ui );
7692 break;
7693 case OPCODE_CALL_LIST_OFFSET:
7694 _mesa_printf("CallList %d + offset %u = %u\n", (int) n[1].ui,
7695 ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
7696 break;
7697 case OPCODE_COLOR_TABLE_PARAMETER_FV:
7698 _mesa_printf("ColorTableParameterfv %s %s %f %f %f %f\n",
7699 enum_string(n[1].e), enum_string(n[2].e),
7700 n[3].f, n[4].f, n[5].f, n[6].f);
7701 break;
7702 case OPCODE_COLOR_TABLE_PARAMETER_IV:
7703 _mesa_printf("ColorTableParameteriv %s %s %d %d %d %d\n",
7704 enum_string(n[1].e), enum_string(n[2].e),
7705 n[3].i, n[4].i, n[5].i, n[6].i);
7706 break;
7707 case OPCODE_DISABLE:
7708 _mesa_printf("Disable %s\n", enum_string(n[1].e));
7709 break;
7710 case OPCODE_ENABLE:
7711 _mesa_printf("Enable %s\n", enum_string(n[1].e));
7712 break;
7713 case OPCODE_FRUSTUM:
7714 _mesa_printf("Frustum %g %g %g %g %g %g\n",
7715 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
7716 break;
7717 case OPCODE_LINE_STIPPLE:
7718 _mesa_printf("LineStipple %d %x\n", n[1].i, (int) n[2].us );
7719 break;
7720 case OPCODE_LOAD_IDENTITY:
7721 _mesa_printf("LoadIdentity\n");
7722 break;
7723 case OPCODE_LOAD_MATRIX:
7724 _mesa_printf("LoadMatrix\n");
7725 _mesa_printf(" %8f %8f %8f %8f\n",
7726 n[1].f, n[5].f, n[9].f, n[13].f);
7727 _mesa_printf(" %8f %8f %8f %8f\n",
7728 n[2].f, n[6].f, n[10].f, n[14].f);
7729 _mesa_printf(" %8f %8f %8f %8f\n",
7730 n[3].f, n[7].f, n[11].f, n[15].f);
7731 _mesa_printf(" %8f %8f %8f %8f\n",
7732 n[4].f, n[8].f, n[12].f, n[16].f);
7733 break;
7734 case OPCODE_MULT_MATRIX:
7735 _mesa_printf("MultMatrix (or Rotate)\n");
7736 _mesa_printf(" %8f %8f %8f %8f\n",
7737 n[1].f, n[5].f, n[9].f, n[13].f);
7738 _mesa_printf(" %8f %8f %8f %8f\n",
7739 n[2].f, n[6].f, n[10].f, n[14].f);
7740 _mesa_printf(" %8f %8f %8f %8f\n",
7741 n[3].f, n[7].f, n[11].f, n[15].f);
7742 _mesa_printf(" %8f %8f %8f %8f\n",
7743 n[4].f, n[8].f, n[12].f, n[16].f);
7744 break;
7745 case OPCODE_ORTHO:
7746 _mesa_printf("Ortho %g %g %g %g %g %g\n",
7747 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
7748 break;
7749 case OPCODE_POP_ATTRIB:
7750 _mesa_printf("PopAttrib\n");
7751 break;
7752 case OPCODE_POP_MATRIX:
7753 _mesa_printf("PopMatrix\n");
7754 break;
7755 case OPCODE_POP_NAME:
7756 _mesa_printf("PopName\n");
7757 break;
7758 case OPCODE_PUSH_ATTRIB:
7759 _mesa_printf("PushAttrib %x\n", n[1].bf );
7760 break;
7761 case OPCODE_PUSH_MATRIX:
7762 _mesa_printf("PushMatrix\n");
7763 break;
7764 case OPCODE_PUSH_NAME:
7765 _mesa_printf("PushName %d\n", (int) n[1].ui );
7766 break;
7767 case OPCODE_RASTER_POS:
7768 _mesa_printf("RasterPos %g %g %g %g\n",
7769 n[1].f, n[2].f,n[3].f,n[4].f);
7770 break;
7771 case OPCODE_ROTATE:
7772 _mesa_printf("Rotate %g %g %g %g\n",
7773 n[1].f, n[2].f, n[3].f, n[4].f );
7774 break;
7775 case OPCODE_SCALE:
7776 _mesa_printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
7777 break;
7778 case OPCODE_TRANSLATE:
7779 _mesa_printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
7780 break;
7781 case OPCODE_BIND_TEXTURE:
7782 _mesa_printf("BindTexture %s %d\n",
7783 _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui);
7784 break;
7785 case OPCODE_SHADE_MODEL:
7786 _mesa_printf("ShadeModel %s\n",
7787 _mesa_lookup_enum_by_nr(n[1].ui));
7788 break;
7789 case OPCODE_MAP1:
7790 _mesa_printf("Map1 %s %.3f %.3f %d %d\n",
7791 _mesa_lookup_enum_by_nr(n[1].ui),
7792 n[2].f, n[3].f, n[4].i, n[5].i);
7793 break;
7794 case OPCODE_MAP2:
7795 _mesa_printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
7796 _mesa_lookup_enum_by_nr(n[1].ui),
7797 n[2].f, n[3].f, n[4].f, n[5].f,
7798 n[6].i, n[7].i, n[8].i, n[9].i);
7799 break;
7800 case OPCODE_MAPGRID1:
7801 _mesa_printf("MapGrid1 %d %.3f %.3f\n",
7802 n[1].i, n[2].f, n[3].f);
7803 break;
7804 case OPCODE_MAPGRID2:
7805 _mesa_printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
7806 n[1].i, n[2].f, n[3].f,
7807 n[4].i, n[5].f, n[6].f);
7808 break;
7809 case OPCODE_EVALMESH1:
7810 _mesa_printf("EvalMesh1 %d %d\n", n[1].i, n[2].i);
7811 break;
7812 case OPCODE_EVALMESH2:
7813 _mesa_printf("EvalMesh2 %d %d %d %d\n",
7814 n[1].i, n[2].i, n[3].i, n[4].i);
7815 break;
7816
7817
7818
7819 case OPCODE_ATTR_1F:
7820 _mesa_printf("ATTR_1F attr %d: %f\n",
7821 n[1].i, n[2].f);
7822 break;
7823 case OPCODE_ATTR_2F:
7824 _mesa_printf("ATTR_2F attr %d: %f %f\n",
7825 n[1].i, n[2].f, n[3].f);
7826 break;
7827 case OPCODE_ATTR_3F:
7828 _mesa_printf("ATTR_3F attr %d: %f %f %f\n",
7829 n[1].i, n[2].f, n[3].f, n[4].f);
7830 break;
7831 case OPCODE_ATTR_4F:
7832 _mesa_printf("ATTR_4F attr %d: %f %f %f %f\n",
7833 n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
7834 break;
7835 case OPCODE_MATERIAL:
7836 _mesa_printf("MATERIAL %x %x: %f %f %f %f\n",
7837 n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f);
7838 break;
7839 case OPCODE_INDEX:
7840 _mesa_printf("INDEX: %f\n", n[1].f);
7841 break;
7842 case OPCODE_EDGEFLAG:
7843 _mesa_printf("EDGEFLAG: %d\n", n[1].i);
7844 break;
7845 case OPCODE_BEGIN:
7846 _mesa_printf("BEGIN %x\n", n[1].i);
7847 break;
7848 case OPCODE_END:
7849 _mesa_printf("END\n");
7850 break;
7851 case OPCODE_RECTF:
7852 _mesa_printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, n[4].f);
7853 break;
7854 case OPCODE_EVAL_C1:
7855 _mesa_printf("EVAL_C1 %f\n", n[1].f);
7856 break;
7857 case OPCODE_EVAL_C2:
7858 _mesa_printf("EVAL_C2 %f %f\n", n[1].f, n[2].f);
7859 break;
7860 case OPCODE_EVAL_P1:
7861 _mesa_printf("EVAL_P1 %d\n", n[1].i);
7862 break;
7863 case OPCODE_EVAL_P2:
7864 _mesa_printf("EVAL_P2 %d %d\n", n[1].i, n[2].i);
7865 break;
7866
7867
7868
7869 /*
7870 * meta opcodes/commands
7871 */
7872 case OPCODE_ERROR:
7873 _mesa_printf("Error: %s %s\n",
7874 enum_string(n[1].e), (const char *)n[2].data );
7875 break;
7876 case OPCODE_CONTINUE:
7877 _mesa_printf("DISPLAY-LIST-CONTINUE\n");
7878 n = (Node *) n[1].next;
7879 break;
7880 case OPCODE_END_OF_LIST:
7881 _mesa_printf("END-LIST %u\n", list);
7882 done = GL_TRUE;
7883 break;
7884 default:
7885 if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
7886 _mesa_printf("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
7887 opcode, (void*) n);
7888 return;
7889 }
7890 else {
7891 _mesa_printf("command %d, %u operands\n", opcode, InstSize[opcode]);
7892 }
7893 }
7894 /* increment n to point to next compiled command */
7895 if (opcode!=OPCODE_CONTINUE) {
7896 n += InstSize[opcode];
7897 }
7898 }
7899 }
7900 }
7901
7902
7903
7904 /*
7905 * Clients may call this function to help debug display list problems.
7906 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
7907 * changed, or break in the future without notice.
7908 */
7909 void mesa_print_display_list( GLuint list )
7910 {
7911 GET_CURRENT_CONTEXT(ctx);
7912 print_list( ctx, list );
7913 }
7914
7915
7916 /**********************************************************************/
7917 /***** Initialization *****/
7918 /**********************************************************************/
7919
7920
7921 void _mesa_save_vtxfmt_init( GLvertexformat *vfmt )
7922 {
7923 vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
7924 vfmt->Begin = save_Begin;
7925 vfmt->CallList = _mesa_save_CallList;
7926 vfmt->CallLists = _mesa_save_CallLists;
7927 vfmt->Color3f = save_Color3f;
7928 vfmt->Color3fv = save_Color3fv;
7929 vfmt->Color4f = save_Color4f;
7930 vfmt->Color4fv = save_Color4fv;
7931 vfmt->EdgeFlag = save_EdgeFlag;
7932 vfmt->EdgeFlagv = save_EdgeFlagv;
7933 vfmt->End = save_End;
7934 vfmt->EvalCoord1f = save_EvalCoord1f;
7935 vfmt->EvalCoord1fv = save_EvalCoord1fv;
7936 vfmt->EvalCoord2f = save_EvalCoord2f;
7937 vfmt->EvalCoord2fv = save_EvalCoord2fv;
7938 vfmt->EvalPoint1 = save_EvalPoint1;
7939 vfmt->EvalPoint2 = save_EvalPoint2;
7940 vfmt->FogCoordfEXT = save_FogCoordfEXT;
7941 vfmt->FogCoordfvEXT = save_FogCoordfvEXT;
7942 vfmt->Indexf = save_Indexf;
7943 vfmt->Indexfv = save_Indexfv;
7944 vfmt->Materialfv = save_Materialfv;
7945 vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f;
7946 vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv;
7947 vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f;
7948 vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv;
7949 vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f;
7950 vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv;
7951 vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f;
7952 vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv;
7953 vfmt->Normal3f = save_Normal3f;
7954 vfmt->Normal3fv = save_Normal3fv;
7955 vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT;
7956 vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT;
7957 vfmt->TexCoord1f = save_TexCoord1f;
7958 vfmt->TexCoord1fv = save_TexCoord1fv;
7959 vfmt->TexCoord2f = save_TexCoord2f;
7960 vfmt->TexCoord2fv = save_TexCoord2fv;
7961 vfmt->TexCoord3f = save_TexCoord3f;
7962 vfmt->TexCoord3fv = save_TexCoord3fv;
7963 vfmt->TexCoord4f = save_TexCoord4f;
7964 vfmt->TexCoord4fv = save_TexCoord4fv;
7965 vfmt->Vertex2f = save_Vertex2f;
7966 vfmt->Vertex2fv = save_Vertex2fv;
7967 vfmt->Vertex3f = save_Vertex3f;
7968 vfmt->Vertex3fv = save_Vertex3fv;
7969 vfmt->Vertex4f = save_Vertex4f;
7970 vfmt->Vertex4fv = save_Vertex4fv;
7971 vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV;
7972 vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV;
7973 vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV;
7974 vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV;
7975 vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV;
7976 vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV;
7977 vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV;
7978 vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV;
7979
7980 vfmt->EvalMesh1 = _mesa_save_EvalMesh1;
7981 vfmt->EvalMesh2 = _mesa_save_EvalMesh2;
7982 vfmt->Rectf = save_Rectf;
7983
7984 /* The driver is required to implement these as
7985 * 1) They can probably do a better job.
7986 * 2) A lot of new mechanisms would have to be added to this module
7987 * to support it. That code would probably never get used,
7988 * because of (1).
7989 */
7990 #if 0
7991 vfmt->DrawArrays = 0;
7992 vfmt->DrawElements = 0;
7993 vfmt->DrawRangeElements = 0;
7994 #endif
7995 }
7996
7997
7998
7999 void _mesa_init_display_list( GLcontext * ctx )
8000 {
8001 /* Display list */
8002 ctx->ListState.CallDepth = 0;
8003 ctx->ExecuteFlag = GL_TRUE;
8004 ctx->CompileFlag = GL_FALSE;
8005 ctx->ListState.CurrentListPtr = NULL;
8006 ctx->ListState.CurrentBlock = NULL;
8007 ctx->ListState.CurrentListNum = 0;
8008 ctx->ListState.CurrentPos = 0;
8009
8010 /* Display List group */
8011 ctx->List.ListBase = 0;
8012
8013 _mesa_save_vtxfmt_init( &ctx->ListState.ListVtxfmt );
8014 }