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