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