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