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