fix for eval regression
[mesa.git] / src / mesa / main / dlist.c
1 /* $Id: dlist.c,v 1.44 2000/07/10 13:22:01 keithw Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28 #ifdef PC_HEADER
29 #include "all.h"
30 #else
31 #include "glheader.h"
32 #include "accum.h"
33 #include "attrib.h"
34 #include "bitmap.h"
35 #include "bbox.h"
36 #include "blend.h"
37 #include "buffers.h"
38 #include "clip.h"
39 #include "colortab.h"
40 #include "context.h"
41 #include "copypix.h"
42 #include "cva.h"
43 #include "depth.h"
44 #include "enable.h"
45 #include "enums.h"
46 #include "eval.h"
47 #include "extensions.h"
48 #include "feedback.h"
49 #include "get.h"
50 #include "glapi.h"
51 #include "hash.h"
52 #include "image.h"
53 #include "imaging.h"
54 #include "light.h"
55 #include "lines.h"
56 #include "dlist.h"
57 #include "macros.h"
58 #include "matrix.h"
59 #include "mem.h"
60 #include "pipeline.h"
61 #include "pixel.h"
62 #include "pixeltex.h"
63 #include "points.h"
64 #include "polygon.h"
65 #include "readpix.h"
66 #include "rect.h"
67 #include "state.h"
68 #include "texobj.h"
69 #include "teximage.h"
70 #include "texstate.h"
71 #include "types.h"
72 #include "varray.h"
73 #include "vb.h"
74 #include "vbfill.h"
75 #include "vbxform.h"
76 #include "xform.h"
77 #endif
78
79
80
81 /*
82 Functions which aren't compiled but executed immediately:
83 glIsList
84 glGenLists
85 glDeleteLists
86 glEndList
87 glFeedbackBuffer
88 glSelectBuffer
89 glRenderMode
90 glReadPixels
91 glPixelStore
92 glFlush
93 glFinish
94 glIsEnabled
95 glGet*
96
97 Functions which cause errors if called while compiling a display list:
98 glNewList
99 */
100
101
102
103 /*
104 * Display list instructions are stored as sequences of "nodes". Nodes
105 * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
106 * are linked together with a pointer.
107 */
108
109
110 /* How many nodes to allocate at a time:
111 * - reduced now that we hold vertices etc. elsewhere.
112 */
113 #define BLOCK_SIZE 64
114
115
116 /*
117 * Display list opcodes.
118 *
119 * The fact that these identifiers are assigned consecutive
120 * integer values starting at 0 is very important, see InstSize array usage)
121 *
122 * KW: Commented out opcodes now handled by vertex-cassettes.
123 */
124 typedef enum {
125 OPCODE_ACCUM,
126 OPCODE_ALPHA_FUNC,
127 OPCODE_BIND_TEXTURE,
128 OPCODE_BITMAP,
129 OPCODE_BLEND_COLOR,
130 OPCODE_BLEND_EQUATION,
131 OPCODE_BLEND_FUNC,
132 OPCODE_BLEND_FUNC_SEPARATE,
133 OPCODE_CALL_LIST,
134 OPCODE_CALL_LIST_OFFSET,
135 OPCODE_CLEAR,
136 OPCODE_CLEAR_ACCUM,
137 OPCODE_CLEAR_COLOR,
138 OPCODE_CLEAR_DEPTH,
139 OPCODE_CLEAR_INDEX,
140 OPCODE_CLEAR_STENCIL,
141 OPCODE_CLIP_PLANE,
142 OPCODE_COLOR_MASK,
143 OPCODE_COLOR_MATERIAL,
144 OPCODE_COLOR_TABLE,
145 OPCODE_COLOR_TABLE_PARAMETER_FV,
146 OPCODE_COLOR_TABLE_PARAMETER_IV,
147 OPCODE_COLOR_SUB_TABLE,
148 OPCODE_CONVOLUTION_FILTER_1D,
149 OPCODE_CONVOLUTION_FILTER_2D,
150 OPCODE_CONVOLUTION_PARAMETER_I,
151 OPCODE_CONVOLUTION_PARAMETER_IV,
152 OPCODE_CONVOLUTION_PARAMETER_F,
153 OPCODE_CONVOLUTION_PARAMETER_FV,
154 OPCODE_COPY_COLOR_SUB_TABLE,
155 OPCODE_COPY_COLOR_TABLE,
156 OPCODE_COPY_PIXELS,
157 OPCODE_COPY_TEX_IMAGE1D,
158 OPCODE_COPY_TEX_IMAGE2D,
159 OPCODE_COPY_TEX_SUB_IMAGE1D,
160 OPCODE_COPY_TEX_SUB_IMAGE2D,
161 OPCODE_COPY_TEX_SUB_IMAGE3D,
162 OPCODE_CULL_FACE,
163 OPCODE_DEPTH_FUNC,
164 OPCODE_DEPTH_MASK,
165 OPCODE_DEPTH_RANGE,
166 OPCODE_DISABLE,
167 OPCODE_DRAW_BUFFER,
168 OPCODE_DRAW_PIXELS,
169 OPCODE_ENABLE,
170 OPCODE_EVALCOORD1,
171 OPCODE_EVALCOORD2,
172 OPCODE_EVALMESH1,
173 OPCODE_EVALMESH2,
174 OPCODE_EVALPOINT1,
175 OPCODE_EVALPOINT2,
176 OPCODE_FOG,
177 OPCODE_FRONT_FACE,
178 OPCODE_FRUSTUM,
179 OPCODE_HINT,
180 OPCODE_HINT_PGI,
181 OPCODE_HISTOGRAM,
182 OPCODE_INDEX_MASK,
183 OPCODE_INIT_NAMES,
184 OPCODE_LIGHT,
185 OPCODE_LIGHT_MODEL,
186 OPCODE_LINE_STIPPLE,
187 OPCODE_LINE_WIDTH,
188 OPCODE_LIST_BASE,
189 OPCODE_LOAD_IDENTITY,
190 OPCODE_LOAD_MATRIX,
191 OPCODE_LOAD_NAME,
192 OPCODE_LOGIC_OP,
193 OPCODE_MAP1,
194 OPCODE_MAP2,
195 OPCODE_MAPGRID1,
196 OPCODE_MAPGRID2,
197 OPCODE_MATRIX_MODE,
198 OPCODE_MIN_MAX,
199 OPCODE_MULT_MATRIX,
200 OPCODE_ORTHO,
201 OPCODE_PASSTHROUGH,
202 OPCODE_PIXEL_MAP,
203 OPCODE_PIXEL_TRANSFER,
204 OPCODE_PIXEL_ZOOM,
205 OPCODE_POINT_SIZE,
206 OPCODE_POINT_PARAMETERS,
207 OPCODE_POLYGON_MODE,
208 OPCODE_POLYGON_STIPPLE,
209 OPCODE_POLYGON_OFFSET,
210 OPCODE_POP_ATTRIB,
211 OPCODE_POP_MATRIX,
212 OPCODE_POP_NAME,
213 OPCODE_PRIORITIZE_TEXTURE,
214 OPCODE_PUSH_ATTRIB,
215 OPCODE_PUSH_MATRIX,
216 OPCODE_PUSH_NAME,
217 OPCODE_RASTER_POS,
218 OPCODE_RECTF,
219 OPCODE_READ_BUFFER,
220 OPCODE_RESET_HISTOGRAM,
221 OPCODE_RESET_MIN_MAX,
222 OPCODE_SCALE,
223 OPCODE_SCISSOR,
224 OPCODE_SELECT_TEXTURE_SGIS,
225 OPCODE_SELECT_TEXTURE_COORD_SET,
226 OPCODE_SHADE_MODEL,
227 OPCODE_STENCIL_FUNC,
228 OPCODE_STENCIL_MASK,
229 OPCODE_STENCIL_OP,
230 OPCODE_TEXENV,
231 OPCODE_TEXGEN,
232 OPCODE_TEXPARAMETER,
233 OPCODE_TEX_IMAGE1D,
234 OPCODE_TEX_IMAGE2D,
235 OPCODE_TEX_IMAGE3D,
236 OPCODE_TEX_SUB_IMAGE1D,
237 OPCODE_TEX_SUB_IMAGE2D,
238 OPCODE_TEX_SUB_IMAGE3D,
239 OPCODE_TRANSLATE,
240 OPCODE_VIEWPORT,
241 OPCODE_WINDOW_POS,
242 /* GL_ARB_multitexture */
243 OPCODE_ACTIVE_TEXTURE,
244 OPCODE_CLIENT_ACTIVE_TEXTURE,
245 /* GL_SGIX/SGIS_pixel_texture */
246 OPCODE_PIXEL_TEXGEN_SGIX,
247 OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS,
248 /* GL_ARB_texture_compression */
249 OPCODE_COMPRESSED_TEX_IMAGE_1D,
250 OPCODE_COMPRESSED_TEX_IMAGE_2D,
251 OPCODE_COMPRESSED_TEX_IMAGE_3D,
252 OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
253 OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
254 OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
255 /* The following three are meta instructions */
256 OPCODE_ERROR, /* raise compiled-in error */
257 OPCODE_VERTEX_CASSETTE, /* render prebuilt vertex buffer */
258 OPCODE_CONTINUE,
259 OPCODE_END_OF_LIST
260 } OpCode;
261
262
263 /*
264 * Each instruction in the display list is stored as a sequence of
265 * contiguous nodes in memory.
266 * Each node is the union of a variety of datatypes.
267 */
268 union node {
269 OpCode opcode;
270 GLboolean b;
271 GLbitfield bf;
272 GLubyte ub;
273 GLshort s;
274 GLushort us;
275 GLint i;
276 GLuint ui;
277 GLenum e;
278 GLfloat f;
279 GLvoid *data;
280 void *next; /* If prev node's opcode==OPCODE_CONTINUE */
281 };
282
283
284
285 /* Number of nodes of storage needed for each instruction: */
286 static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
287
288 void mesa_print_display_list( GLuint list );
289
290
291 /**********************************************************************/
292 /***** Private *****/
293 /**********************************************************************/
294
295
296 /*
297 * Allocate space for a display list instruction.
298 * Input: opcode - type of instruction
299 * argcount - number of arguments following the instruction
300 * Return: pointer to first node in the instruction
301 */
302 static Node *alloc_instruction( GLcontext *ctx, OpCode opcode, GLint argcount )
303 {
304 Node *n, *newblock;
305 GLuint count = InstSize[opcode];
306
307 assert( (GLint) count == argcount+1 );
308
309 if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
310 /* This block is full. Allocate a new block and chain to it */
311 n = ctx->CurrentBlock + ctx->CurrentPos;
312 n[0].opcode = OPCODE_CONTINUE;
313 newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
314 if (!newblock) {
315 gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
316 return NULL;
317 }
318 n[1].next = (Node *) newblock;
319 ctx->CurrentBlock = newblock;
320 ctx->CurrentPos = 0;
321 }
322
323 n = ctx->CurrentBlock + ctx->CurrentPos;
324 ctx->CurrentPos += count;
325
326 n[0].opcode = opcode;
327
328 return n;
329 }
330
331
332
333 /*
334 * Make an empty display list. This is used by glGenLists() to
335 * reserver display list IDs.
336 */
337 static Node *make_empty_list( void )
338 {
339 Node *n = (Node *) MALLOC( sizeof(Node) );
340 n[0].opcode = OPCODE_END_OF_LIST;
341 return n;
342 }
343
344
345
346 /*
347 * Destroy all nodes in a display list.
348 * Input: list - display list number
349 */
350 void gl_destroy_list( GLcontext *ctx, GLuint list )
351 {
352 Node *n, *block;
353 GLboolean done;
354
355 if (list==0)
356 return;
357
358 block = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
359 n = block;
360
361 done = block ? GL_FALSE : GL_TRUE;
362 while (!done) {
363 switch (n[0].opcode) {
364 /* special cases first */
365 case OPCODE_VERTEX_CASSETTE:
366 if ( ! -- ((struct immediate *) n[1].data)->ref_count )
367 gl_immediate_free( (struct immediate *) n[1].data );
368 n += InstSize[n[0].opcode];
369 break;
370 case OPCODE_MAP1:
371 FREE(n[6].data);
372 n += InstSize[n[0].opcode];
373 break;
374 case OPCODE_MAP2:
375 FREE(n[10].data);
376 n += InstSize[n[0].opcode];
377 break;
378 case OPCODE_DRAW_PIXELS:
379 FREE( n[5].data );
380 n += InstSize[n[0].opcode];
381 break;
382 case OPCODE_BITMAP:
383 FREE( n[7].data );
384 n += InstSize[n[0].opcode];
385 break;
386 case OPCODE_COLOR_TABLE:
387 FREE( n[6].data );
388 n += InstSize[n[0].opcode];
389 break;
390 case OPCODE_COLOR_SUB_TABLE:
391 FREE( n[6].data );
392 n += InstSize[n[0].opcode];
393 break;
394 case OPCODE_CONVOLUTION_FILTER_1D:
395 FREE( n[6].data );
396 n += InstSize[n[0].opcode];
397 break;
398 case OPCODE_CONVOLUTION_FILTER_2D:
399 FREE( n[7].data );
400 n += InstSize[n[0].opcode];
401 break;
402 case OPCODE_POLYGON_STIPPLE:
403 FREE( n[1].data );
404 n += InstSize[n[0].opcode];
405 break;
406 case OPCODE_TEX_IMAGE1D:
407 FREE(n[8].data);
408 n += InstSize[n[0].opcode];
409 break;
410 case OPCODE_TEX_IMAGE2D:
411 FREE( n[9]. data );
412 n += InstSize[n[0].opcode];
413 break;
414 case OPCODE_TEX_IMAGE3D:
415 FREE( n[10]. data );
416 n += InstSize[n[0].opcode];
417 break;
418 case OPCODE_TEX_SUB_IMAGE1D:
419 FREE(n[7].data);
420 n += InstSize[n[0].opcode];
421 break;
422 case OPCODE_TEX_SUB_IMAGE2D:
423 FREE(n[9].data);
424 n += InstSize[n[0].opcode];
425 break;
426 case OPCODE_TEX_SUB_IMAGE3D:
427 FREE(n[11].data);
428 n += InstSize[n[0].opcode];
429 break;
430 case OPCODE_COMPRESSED_TEX_IMAGE_1D:
431 FREE(n[7].data);
432 n += InstSize[n[0].opcode];
433 break;
434 case OPCODE_COMPRESSED_TEX_IMAGE_2D:
435 FREE(n[8].data);
436 n += InstSize[n[0].opcode];
437 break;
438 case OPCODE_COMPRESSED_TEX_IMAGE_3D:
439 FREE(n[9].data);
440 n += InstSize[n[0].opcode];
441 break;
442 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:
443 FREE(n[7].data);
444 n += InstSize[n[0].opcode];
445 break;
446 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:
447 FREE(n[9].data);
448 n += InstSize[n[0].opcode];
449 break;
450 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:
451 FREE(n[11].data);
452 n += InstSize[n[0].opcode];
453 break;
454 case OPCODE_CONTINUE:
455 n = (Node *) n[1].next;
456 FREE( block );
457 block = n;
458 break;
459 case OPCODE_END_OF_LIST:
460 FREE( block );
461 done = GL_TRUE;
462 break;
463 default:
464 /* Most frequent case */
465 n += InstSize[n[0].opcode];
466 break;
467 }
468 }
469
470 _mesa_HashRemove(ctx->Shared->DisplayList, list);
471 }
472
473
474
475 /*
476 * Translate the nth element of list from type to GLuint.
477 */
478 static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
479 {
480 GLbyte *bptr;
481 GLubyte *ubptr;
482 GLshort *sptr;
483 GLushort *usptr;
484 GLint *iptr;
485 GLuint *uiptr;
486 GLfloat *fptr;
487
488 switch (type) {
489 case GL_BYTE:
490 bptr = (GLbyte *) list;
491 return (GLuint) *(bptr+n);
492 case GL_UNSIGNED_BYTE:
493 ubptr = (GLubyte *) list;
494 return (GLuint) *(ubptr+n);
495 case GL_SHORT:
496 sptr = (GLshort *) list;
497 return (GLuint) *(sptr+n);
498 case GL_UNSIGNED_SHORT:
499 usptr = (GLushort *) list;
500 return (GLuint) *(usptr+n);
501 case GL_INT:
502 iptr = (GLint *) list;
503 return (GLuint) *(iptr+n);
504 case GL_UNSIGNED_INT:
505 uiptr = (GLuint *) list;
506 return (GLuint) *(uiptr+n);
507 case GL_FLOAT:
508 fptr = (GLfloat *) list;
509 return (GLuint) *(fptr+n);
510 case GL_2_BYTES:
511 ubptr = ((GLubyte *) list) + 2*n;
512 return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
513 case GL_3_BYTES:
514 ubptr = ((GLubyte *) list) + 3*n;
515 return (GLuint) *ubptr * 65536
516 + (GLuint) *(ubptr+1) * 256
517 + (GLuint) *(ubptr+2);
518 case GL_4_BYTES:
519 ubptr = ((GLubyte *) list) + 4*n;
520 return (GLuint) *ubptr * 16777216
521 + (GLuint) *(ubptr+1) * 65536
522 + (GLuint) *(ubptr+2) * 256
523 + (GLuint) *(ubptr+3);
524 default:
525 return 0;
526 }
527 }
528
529
530
531
532 /**********************************************************************/
533 /***** Public *****/
534 /**********************************************************************/
535
536 void gl_init_lists( void )
537 {
538 static int init_flag = 0;
539
540 if (init_flag==0) {
541 InstSize[OPCODE_ACCUM] = 3;
542 InstSize[OPCODE_ALPHA_FUNC] = 3;
543 InstSize[OPCODE_BIND_TEXTURE] = 3;
544 InstSize[OPCODE_BITMAP] = 8;
545 InstSize[OPCODE_BLEND_COLOR] = 5;
546 InstSize[OPCODE_BLEND_EQUATION] = 2;
547 InstSize[OPCODE_BLEND_FUNC] = 3;
548 InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5;
549 InstSize[OPCODE_CALL_LIST] = 2;
550 InstSize[OPCODE_CALL_LIST_OFFSET] = 2;
551 InstSize[OPCODE_CLEAR] = 2;
552 InstSize[OPCODE_CLEAR_ACCUM] = 5;
553 InstSize[OPCODE_CLEAR_COLOR] = 5;
554 InstSize[OPCODE_CLEAR_DEPTH] = 2;
555 InstSize[OPCODE_CLEAR_INDEX] = 2;
556 InstSize[OPCODE_CLEAR_STENCIL] = 2;
557 InstSize[OPCODE_CLIP_PLANE] = 6;
558 InstSize[OPCODE_COLOR_MASK] = 5;
559 InstSize[OPCODE_COLOR_MATERIAL] = 3;
560 InstSize[OPCODE_COLOR_TABLE] = 7;
561 InstSize[OPCODE_COLOR_TABLE_PARAMETER_FV] = 7;
562 InstSize[OPCODE_COLOR_TABLE_PARAMETER_IV] = 7;
563 InstSize[OPCODE_COLOR_SUB_TABLE] = 7;
564 InstSize[OPCODE_CONVOLUTION_FILTER_1D] = 7;
565 InstSize[OPCODE_CONVOLUTION_FILTER_2D] = 8;
566 InstSize[OPCODE_CONVOLUTION_PARAMETER_I] = 4;
567 InstSize[OPCODE_CONVOLUTION_PARAMETER_IV] = 7;
568 InstSize[OPCODE_CONVOLUTION_PARAMETER_F] = 4;
569 InstSize[OPCODE_CONVOLUTION_PARAMETER_FV] = 7;
570 InstSize[OPCODE_COPY_PIXELS] = 6;
571 InstSize[OPCODE_COPY_COLOR_SUB_TABLE] = 6;
572 InstSize[OPCODE_COPY_COLOR_TABLE] = 6;
573 InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8;
574 InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9;
575 InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7;
576 InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
577 InstSize[OPCODE_COPY_TEX_SUB_IMAGE3D] = 10;
578 InstSize[OPCODE_CULL_FACE] = 2;
579 InstSize[OPCODE_DEPTH_FUNC] = 2;
580 InstSize[OPCODE_DEPTH_MASK] = 2;
581 InstSize[OPCODE_DEPTH_RANGE] = 3;
582 InstSize[OPCODE_DISABLE] = 2;
583 InstSize[OPCODE_DRAW_BUFFER] = 2;
584 InstSize[OPCODE_DRAW_PIXELS] = 6;
585 InstSize[OPCODE_ENABLE] = 2;
586 InstSize[OPCODE_EVALCOORD1] = 2;
587 InstSize[OPCODE_EVALCOORD2] = 3;
588 InstSize[OPCODE_EVALMESH1] = 4;
589 InstSize[OPCODE_EVALMESH2] = 6;
590 InstSize[OPCODE_EVALPOINT1] = 2;
591 InstSize[OPCODE_EVALPOINT2] = 3;
592 InstSize[OPCODE_FOG] = 6;
593 InstSize[OPCODE_FRONT_FACE] = 2;
594 InstSize[OPCODE_FRUSTUM] = 7;
595 InstSize[OPCODE_HINT] = 3;
596 InstSize[OPCODE_HINT_PGI] = 3;
597 InstSize[OPCODE_HISTOGRAM] = 5;
598 InstSize[OPCODE_INDEX_MASK] = 2;
599 InstSize[OPCODE_INIT_NAMES] = 1;
600 InstSize[OPCODE_LIGHT] = 7;
601 InstSize[OPCODE_LIGHT_MODEL] = 6;
602 InstSize[OPCODE_LINE_STIPPLE] = 3;
603 InstSize[OPCODE_LINE_WIDTH] = 2;
604 InstSize[OPCODE_LIST_BASE] = 2;
605 InstSize[OPCODE_LOAD_IDENTITY] = 1;
606 InstSize[OPCODE_LOAD_MATRIX] = 17;
607 InstSize[OPCODE_LOAD_NAME] = 2;
608 InstSize[OPCODE_LOGIC_OP] = 2;
609 InstSize[OPCODE_MAP1] = 7;
610 InstSize[OPCODE_MAP2] = 11;
611 InstSize[OPCODE_MAPGRID1] = 4;
612 InstSize[OPCODE_MAPGRID2] = 7;
613 InstSize[OPCODE_MATRIX_MODE] = 2;
614 InstSize[OPCODE_MIN_MAX] = 4;
615 InstSize[OPCODE_MULT_MATRIX] = 17;
616 InstSize[OPCODE_ORTHO] = 7;
617 InstSize[OPCODE_PASSTHROUGH] = 2;
618 InstSize[OPCODE_PIXEL_MAP] = 4;
619 InstSize[OPCODE_PIXEL_TRANSFER] = 3;
620 InstSize[OPCODE_PIXEL_ZOOM] = 3;
621 InstSize[OPCODE_POINT_SIZE] = 2;
622 InstSize[OPCODE_POINT_PARAMETERS] = 5;
623 InstSize[OPCODE_POLYGON_MODE] = 3;
624 InstSize[OPCODE_POLYGON_STIPPLE] = 2;
625 InstSize[OPCODE_POLYGON_OFFSET] = 3;
626 InstSize[OPCODE_POP_ATTRIB] = 1;
627 InstSize[OPCODE_POP_MATRIX] = 1;
628 InstSize[OPCODE_POP_NAME] = 1;
629 InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
630 InstSize[OPCODE_PUSH_ATTRIB] = 2;
631 InstSize[OPCODE_PUSH_MATRIX] = 1;
632 InstSize[OPCODE_PUSH_NAME] = 2;
633 InstSize[OPCODE_RASTER_POS] = 5;
634 InstSize[OPCODE_RECTF] = 5;
635 InstSize[OPCODE_READ_BUFFER] = 2;
636 InstSize[OPCODE_RESET_HISTOGRAM] = 2;
637 InstSize[OPCODE_RESET_MIN_MAX] = 2;
638 InstSize[OPCODE_SCALE] = 4;
639 InstSize[OPCODE_SCISSOR] = 5;
640 InstSize[OPCODE_STENCIL_FUNC] = 4;
641 InstSize[OPCODE_STENCIL_MASK] = 2;
642 InstSize[OPCODE_STENCIL_OP] = 4;
643 InstSize[OPCODE_SHADE_MODEL] = 2;
644 InstSize[OPCODE_TEXENV] = 7;
645 InstSize[OPCODE_TEXGEN] = 7;
646 InstSize[OPCODE_TEXPARAMETER] = 7;
647 InstSize[OPCODE_TEX_IMAGE1D] = 9;
648 InstSize[OPCODE_TEX_IMAGE2D] = 10;
649 InstSize[OPCODE_TEX_IMAGE3D] = 11;
650 InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
651 InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
652 InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12;
653 InstSize[OPCODE_TRANSLATE] = 4;
654 InstSize[OPCODE_VIEWPORT] = 5;
655 InstSize[OPCODE_WINDOW_POS] = 5;
656 InstSize[OPCODE_CONTINUE] = 2;
657 InstSize[OPCODE_ERROR] = 3;
658 InstSize[OPCODE_VERTEX_CASSETTE] = 9;
659 InstSize[OPCODE_END_OF_LIST] = 1;
660 /* GL_SGIX/SGIS_pixel_texture */
661 InstSize[OPCODE_PIXEL_TEXGEN_SGIX] = 2;
662 InstSize[OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS] = 3;
663 /* GL_ARB_texture_compression */
664 InstSize[OPCODE_COMPRESSED_TEX_IMAGE_1D] = 8;
665 InstSize[OPCODE_COMPRESSED_TEX_IMAGE_2D] = 9;
666 InstSize[OPCODE_COMPRESSED_TEX_IMAGE_3D] = 10;
667 InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D] = 8;
668 InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D] = 10;
669 InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D] = 12;
670 /* GL_ARB_multitexture */
671 InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
672 InstSize[OPCODE_CLIENT_ACTIVE_TEXTURE] = 2;
673 }
674 init_flag = 1;
675 }
676
677
678 /*
679 * Display List compilation functions
680 */
681
682
683
684 static void save_Accum( GLenum op, GLfloat value )
685 {
686 GET_CURRENT_CONTEXT(ctx);
687 Node *n;
688 FLUSH_VB(ctx, "dlist");
689 n = alloc_instruction( ctx, OPCODE_ACCUM, 2 );
690 if (n) {
691 n[1].e = op;
692 n[2].f = value;
693 }
694 if (ctx->ExecuteFlag) {
695 (*ctx->Exec->Accum)( op, value );
696 }
697 }
698
699
700 static void save_AlphaFunc( GLenum func, GLclampf ref )
701 {
702 GET_CURRENT_CONTEXT(ctx);
703 Node *n;
704 FLUSH_VB(ctx, "dlist");
705 n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 );
706 if (n) {
707 n[1].e = func;
708 n[2].f = (GLfloat) ref;
709 }
710 if (ctx->ExecuteFlag) {
711 (*ctx->Exec->AlphaFunc)( func, ref );
712 }
713 }
714
715
716 static void save_Begin( GLenum mode )
717 {
718 _mesa_Begin(mode); /* special case */
719 }
720
721
722 static void save_BindTexture( GLenum target, GLuint texture )
723 {
724 GET_CURRENT_CONTEXT(ctx);
725 Node *n;
726 FLUSH_VB(ctx, "dlist");
727 n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 );
728 if (n) {
729 n[1].e = target;
730 n[2].ui = texture;
731 }
732 if (ctx->ExecuteFlag) {
733 (*ctx->Exec->BindTexture)( target, texture );
734 }
735 }
736
737
738 static void save_Bitmap( GLsizei width, GLsizei height,
739 GLfloat xorig, GLfloat yorig,
740 GLfloat xmove, GLfloat ymove,
741 const GLubyte *pixels )
742 {
743 GET_CURRENT_CONTEXT(ctx);
744 GLvoid *image = _mesa_unpack_bitmap( width, height, pixels, &ctx->Unpack );
745 Node *n;
746 FLUSH_VB(ctx, "dlist");
747 n = alloc_instruction( ctx, OPCODE_BITMAP, 7 );
748 if (n) {
749 n[1].i = (GLint) width;
750 n[2].i = (GLint) height;
751 n[3].f = xorig;
752 n[4].f = yorig;
753 n[5].f = xmove;
754 n[6].f = ymove;
755 n[7].data = image;
756 }
757 else if (image) {
758 FREE(image);
759 }
760 if (ctx->ExecuteFlag) {
761 (*ctx->Exec->Bitmap)( width, height,
762 xorig, yorig, xmove, ymove, pixels );
763 }
764 }
765
766
767 static void save_BlendEquation( GLenum mode )
768 {
769 GET_CURRENT_CONTEXT(ctx);
770 Node *n;
771 FLUSH_VB(ctx, "dlist");
772 n = alloc_instruction( ctx, OPCODE_BLEND_EQUATION, 1 );
773 if (n) {
774 n[1].e = mode;
775 }
776 if (ctx->ExecuteFlag) {
777 (*ctx->Exec->BlendEquation)( mode );
778 }
779 }
780
781
782 static void save_BlendFunc( GLenum sfactor, GLenum dfactor )
783 {
784 GET_CURRENT_CONTEXT(ctx);
785 Node *n;
786 FLUSH_VB(ctx, "dlist");
787 n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 );
788 if (n) {
789 n[1].e = sfactor;
790 n[2].e = dfactor;
791 }
792 if (ctx->ExecuteFlag) {
793 (*ctx->Exec->BlendFunc)( sfactor, dfactor );
794 }
795 }
796
797
798 static void save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
799 GLenum sfactorA, GLenum dfactorA)
800 {
801 GET_CURRENT_CONTEXT(ctx);
802 Node *n;
803 FLUSH_VB(ctx, "dlist");
804 n = alloc_instruction( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
805 if (n) {
806 n[1].e = sfactorRGB;
807 n[2].e = dfactorRGB;
808 n[3].e = sfactorA;
809 n[4].e = dfactorA;
810 }
811 if (ctx->ExecuteFlag) {
812 (*ctx->Exec->BlendFuncSeparateEXT)( sfactorRGB, dfactorRGB,
813 sfactorA, dfactorA);
814 }
815 }
816
817
818 static void save_BlendColor( GLfloat red, GLfloat green,
819 GLfloat blue, GLfloat alpha )
820 {
821 GET_CURRENT_CONTEXT(ctx);
822 Node *n;
823 FLUSH_VB(ctx, "dlist");
824 n = alloc_instruction( ctx, OPCODE_BLEND_COLOR, 4 );
825 if (n) {
826 n[1].f = red;
827 n[2].f = green;
828 n[3].f = blue;
829 n[4].f = alpha;
830 }
831 if (ctx->ExecuteFlag) {
832 (*ctx->Exec->BlendColor)( red, green, blue, alpha );
833 }
834 }
835
836
837 static void save_CallList( GLuint list )
838 {
839 GET_CURRENT_CONTEXT(ctx);
840 Node *n;
841 FLUSH_VB(ctx, "dlist");
842 n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 );
843 if (n) {
844 n[1].ui = list;
845 }
846 if (ctx->ExecuteFlag) {
847 (*ctx->Exec->CallList)( list );
848 }
849 }
850
851
852 static void save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
853 {
854 GET_CURRENT_CONTEXT(ctx);
855 GLint i;
856 FLUSH_VB(ctx, "dlist");
857
858 for (i=0;i<n;i++) {
859 GLuint list = translate_id( i, type, lists );
860 Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST_OFFSET, 1 );
861 if (n) {
862 n[1].ui = list;
863 }
864 }
865 if (ctx->ExecuteFlag) {
866 (*ctx->Exec->CallLists)( n, type, lists );
867 }
868 }
869
870
871 static void save_Clear( GLbitfield mask )
872 {
873 GET_CURRENT_CONTEXT(ctx);
874 Node *n;
875 FLUSH_VB(ctx, "dlist");
876 n = alloc_instruction( ctx, OPCODE_CLEAR, 1 );
877 if (n) {
878 n[1].bf = mask;
879 }
880 if (ctx->ExecuteFlag) {
881 (*ctx->Exec->Clear)( mask );
882 }
883 }
884
885
886 static void save_ClearAccum( GLfloat red, GLfloat green,
887 GLfloat blue, GLfloat alpha )
888 {
889 GET_CURRENT_CONTEXT(ctx);
890 Node *n;
891 FLUSH_VB(ctx, "dlist");
892 n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 );
893 if (n) {
894 n[1].f = red;
895 n[2].f = green;
896 n[3].f = blue;
897 n[4].f = alpha;
898 }
899 if (ctx->ExecuteFlag) {
900 (*ctx->Exec->ClearAccum)( red, green, blue, alpha );
901 }
902 }
903
904
905 static void save_ClearColor( GLclampf red, GLclampf green,
906 GLclampf blue, GLclampf alpha )
907 {
908 GET_CURRENT_CONTEXT(ctx);
909 Node *n;
910 FLUSH_VB(ctx, "dlist");
911 n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 );
912 if (n) {
913 n[1].f = red;
914 n[2].f = green;
915 n[3].f = blue;
916 n[4].f = alpha;
917 }
918 if (ctx->ExecuteFlag) {
919 (*ctx->Exec->ClearColor)( red, green, blue, alpha );
920 }
921 }
922
923
924 static void save_ClearDepth( GLclampd depth )
925 {
926 GET_CURRENT_CONTEXT(ctx);
927 Node *n;
928 FLUSH_VB(ctx, "dlist");
929 n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 );
930 if (n) {
931 n[1].f = (GLfloat) depth;
932 }
933 if (ctx->ExecuteFlag) {
934 (*ctx->Exec->ClearDepth)( depth );
935 }
936 }
937
938
939 static void save_ClearIndex( GLfloat c )
940 {
941 GET_CURRENT_CONTEXT(ctx);
942 Node *n;
943 FLUSH_VB(ctx, "dlist");
944 n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 );
945 if (n) {
946 n[1].f = c;
947 }
948 if (ctx->ExecuteFlag) {
949 (*ctx->Exec->ClearIndex)( c );
950 }
951 }
952
953
954 static void save_ClearStencil( GLint s )
955 {
956 GET_CURRENT_CONTEXT(ctx);
957 Node *n;
958 FLUSH_VB(ctx, "dlist");
959 n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 );
960 if (n) {
961 n[1].i = s;
962 }
963 if (ctx->ExecuteFlag) {
964 (*ctx->Exec->ClearStencil)( s );
965 }
966 }
967
968
969 static void save_ClipPlane( GLenum plane, const GLdouble *equ )
970 {
971 GET_CURRENT_CONTEXT(ctx);
972 Node *n;
973 FLUSH_VB(ctx, "dlist");
974 n = alloc_instruction( ctx, OPCODE_CLIP_PLANE, 5 );
975 if (n) {
976 n[1].e = plane;
977 n[2].f = equ[0];
978 n[3].f = equ[1];
979 n[4].f = equ[2];
980 n[5].f = equ[3];
981 }
982 if (ctx->ExecuteFlag) {
983 (*ctx->Exec->ClipPlane)( plane, equ );
984 }
985 }
986
987
988
989 static void save_ColorMask( GLboolean red, GLboolean green,
990 GLboolean blue, GLboolean alpha )
991 {
992 GET_CURRENT_CONTEXT(ctx);
993 Node *n;
994 FLUSH_VB(ctx, "dlist");
995 n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 );
996 if (n) {
997 n[1].b = red;
998 n[2].b = green;
999 n[3].b = blue;
1000 n[4].b = alpha;
1001 }
1002 if (ctx->ExecuteFlag) {
1003 (*ctx->Exec->ColorMask)( red, green, blue, alpha );
1004 }
1005 }
1006
1007
1008 static void save_ColorMaterial( GLenum face, GLenum mode )
1009 {
1010 GET_CURRENT_CONTEXT(ctx);
1011 Node *n;
1012 FLUSH_VB(ctx, "dlist");
1013 n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 );
1014 if (n) {
1015 n[1].e = face;
1016 n[2].e = mode;
1017 }
1018 if (ctx->ExecuteFlag) {
1019 (*ctx->Exec->ColorMaterial)( face, mode );
1020 }
1021 }
1022
1023
1024 static void save_ColorTable( GLenum target, GLenum internalFormat,
1025 GLsizei width, GLenum format, GLenum type,
1026 const GLvoid *table )
1027 {
1028 GET_CURRENT_CONTEXT(ctx);
1029 if (target == GL_PROXY_TEXTURE_1D ||
1030 target == GL_PROXY_TEXTURE_2D ||
1031 target == GL_PROXY_TEXTURE_3D) {
1032 /* execute immediately */
1033 (*ctx->Exec->ColorTable)( target, internalFormat, width,
1034 format, type, table );
1035 }
1036 else {
1037 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, table,
1038 &ctx->Unpack);
1039 Node *n;
1040 FLUSH_VB(ctx, "dlist");
1041 n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 6 );
1042 if (n) {
1043 n[1].e = target;
1044 n[2].e = internalFormat;
1045 n[3].i = width;
1046 n[4].e = format;
1047 n[5].e = type;
1048 n[6].data = image;
1049 }
1050 else if (image) {
1051 FREE(image);
1052 }
1053 if (ctx->ExecuteFlag) {
1054 (*ctx->Exec->ColorTable)( target, internalFormat, width,
1055 format, type, table );
1056 }
1057 }
1058 }
1059
1060
1061
1062 static void
1063 save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
1064 {
1065 GET_CURRENT_CONTEXT(ctx);
1066 Node *n;
1067
1068 ASSERT_OUTSIDE_BEGIN_END(ctx, "glColorTableParameterfv");
1069 FLUSH_VB(ctx, "dlist");
1070
1071 n = alloc_instruction( ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6 );
1072 if (n) {
1073 n[1].e = target;
1074 n[2].e = pname;
1075 n[3].f = params[0];
1076 if (pname == GL_COLOR_TABLE_SGI ||
1077 pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1078 pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) {
1079 n[4].f = params[1];
1080 n[5].f = params[2];
1081 n[6].f = params[3];
1082 }
1083 }
1084
1085 if (ctx->ExecuteFlag) {
1086 (*ctx->Exec->ColorTableParameterfv)( target, pname, params );
1087 }
1088 }
1089
1090
1091 static void
1092 save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
1093 {
1094 GET_CURRENT_CONTEXT(ctx);
1095 Node *n;
1096
1097 ASSERT_OUTSIDE_BEGIN_END(ctx, "glColorTableParameterfv");
1098 FLUSH_VB(ctx, "dlist");
1099
1100 n = alloc_instruction( ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6 );
1101 if (n) {
1102 n[1].e = target;
1103 n[2].e = pname;
1104 n[3].i = params[0];
1105 if (pname == GL_COLOR_TABLE_SGI ||
1106 pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1107 pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) {
1108 n[4].i = params[1];
1109 n[5].i = params[2];
1110 n[6].i = params[3];
1111 }
1112 }
1113
1114 if (ctx->ExecuteFlag) {
1115 (*ctx->Exec->ColorTableParameteriv)( target, pname, params );
1116 }
1117 }
1118
1119
1120
1121 static void save_ColorSubTable( GLenum target, GLsizei start, GLsizei count,
1122 GLenum format, GLenum type,
1123 const GLvoid *table)
1124 {
1125 GET_CURRENT_CONTEXT(ctx);
1126 GLvoid *image = _mesa_unpack_image(count, 1, 1, format, type, table,
1127 &ctx->Unpack);
1128 Node *n;
1129 FLUSH_VB(ctx, "dlist");
1130 n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 6 );
1131 if (n) {
1132 n[1].e = target;
1133 n[2].i = start;
1134 n[3].i = count;
1135 n[4].e = format;
1136 n[5].e = type;
1137 n[6].data = image;
1138 }
1139 else if (image) {
1140 FREE(image);
1141 }
1142 if (ctx->ExecuteFlag) {
1143 (*ctx->Exec->ColorSubTable)(target, start, count, format, type, table);
1144 }
1145 }
1146
1147
1148 static void
1149 save_CopyColorSubTable(GLenum target, GLsizei start,
1150 GLint x, GLint y, GLsizei width)
1151 {
1152 GET_CURRENT_CONTEXT(ctx);
1153 Node *n;
1154
1155 FLUSH_VB(ctx, "dlist");
1156 n = alloc_instruction( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 6 );
1157 if (n) {
1158 n[1].e = target;
1159 n[2].i = start;
1160 n[3].i = x;
1161 n[4].i = y;
1162 n[5].i = width;
1163 }
1164 if (ctx->ExecuteFlag) {
1165 (*ctx->Exec->CopyColorSubTable)(target, start, x, y, width);
1166 }
1167 }
1168
1169
1170 static void
1171 save_CopyColorTable(GLenum target, GLenum internalformat,
1172 GLint x, GLint y, GLsizei width)
1173 {
1174 GET_CURRENT_CONTEXT(ctx);
1175 Node *n;
1176
1177 FLUSH_VB(ctx, "dlist");
1178 n = alloc_instruction( ctx, OPCODE_COPY_COLOR_TABLE, 6 );
1179 if (n) {
1180 n[1].e = target;
1181 n[2].e = internalformat;
1182 n[3].i = x;
1183 n[4].i = y;
1184 n[5].i = width;
1185 }
1186 if (ctx->ExecuteFlag) {
1187 (*ctx->Exec->CopyColorTable)(target, internalformat, x, y, width);
1188 }
1189 }
1190
1191
1192 static void
1193 save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
1194 GLenum format, GLenum type, const GLvoid *filter)
1195 {
1196 GET_CURRENT_CONTEXT(ctx);
1197 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, filter,
1198 &ctx->Unpack);
1199 Node *n;
1200 FLUSH_VB(ctx, "dlist");
1201 n = alloc_instruction( ctx, OPCODE_CONVOLUTION_FILTER_1D, 6 );
1202 if (n) {
1203 n[1].e = target;
1204 n[2].e = internalFormat;
1205 n[3].i = width;
1206 n[4].e = format;
1207 n[5].e = type;
1208 n[6].data = image;
1209 }
1210 else if (image) {
1211 FREE(image);
1212 }
1213 if (ctx->ExecuteFlag) {
1214 (*ctx->Exec->ConvolutionFilter1D)( target, internalFormat, width,
1215 format, type, filter );
1216 }
1217 }
1218
1219
1220 static void
1221 save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
1222 GLsizei width, GLsizei height, GLenum format,
1223 GLenum type, const GLvoid *filter)
1224 {
1225 GET_CURRENT_CONTEXT(ctx);
1226 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, filter,
1227 &ctx->Unpack);
1228 Node *n;
1229 FLUSH_VB(ctx, "dlist");
1230 n = alloc_instruction( ctx, OPCODE_CONVOLUTION_FILTER_2D, 7 );
1231 if (n) {
1232 n[1].e = target;
1233 n[2].e = internalFormat;
1234 n[3].i = width;
1235 n[4].i = height;
1236 n[5].e = format;
1237 n[6].e = type;
1238 n[7].data = image;
1239 }
1240 else if (image) {
1241 FREE(image);
1242 }
1243 if (ctx->ExecuteFlag) {
1244 (*ctx->Exec->ConvolutionFilter2D)( target, internalFormat, width, height,
1245 format, type, filter );
1246 }
1247 }
1248
1249
1250 static void
1251 save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
1252 {
1253 GET_CURRENT_CONTEXT(ctx);
1254 Node *n;
1255 FLUSH_VB(ctx, "dlist");
1256 n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3 );
1257 if (n) {
1258 n[1].e = target;
1259 n[2].e = pname;
1260 n[3].i = param;
1261 }
1262 if (ctx->ExecuteFlag) {
1263 (*ctx->Exec->ConvolutionParameteri)( target, pname, param );
1264 }
1265 }
1266
1267
1268 static void
1269 save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
1270 {
1271 GET_CURRENT_CONTEXT(ctx);
1272 Node *n;
1273 FLUSH_VB(ctx, "dlist");
1274 n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
1275 if (n) {
1276 n[1].e = target;
1277 n[2].e = pname;
1278 n[3].i = params[0];
1279 if (pname == GL_CONVOLUTION_BORDER_COLOR ||
1280 pname == GL_CONVOLUTION_FILTER_SCALE ||
1281 pname == GL_CONVOLUTION_FILTER_BIAS) {
1282 n[4].i = params[1];
1283 n[5].i = params[2];
1284 n[6].i = params[3];
1285 }
1286 else {
1287 n[4].i = n[5].i = n[6].i = 0;
1288 }
1289 }
1290 if (ctx->ExecuteFlag) {
1291 (*ctx->Exec->ConvolutionParameteriv)( target, pname, params );
1292 }
1293 }
1294
1295
1296 static void
1297 save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
1298 {
1299 GET_CURRENT_CONTEXT(ctx);
1300 Node *n;
1301 FLUSH_VB(ctx, "dlist");
1302 n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3 );
1303 if (n) {
1304 n[1].e = target;
1305 n[2].e = pname;
1306 n[3].f = param;
1307 }
1308 if (ctx->ExecuteFlag) {
1309 (*ctx->Exec->ConvolutionParameterf)( target, pname, param );
1310 }
1311 }
1312
1313
1314 static void
1315 save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
1316 {
1317 GET_CURRENT_CONTEXT(ctx);
1318 Node *n;
1319 FLUSH_VB(ctx, "dlist");
1320 n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
1321 if (n) {
1322 n[1].e = target;
1323 n[2].e = pname;
1324 n[3].f = params[0];
1325 if (pname == GL_CONVOLUTION_BORDER_COLOR ||
1326 pname == GL_CONVOLUTION_FILTER_SCALE ||
1327 pname == GL_CONVOLUTION_FILTER_BIAS) {
1328 n[4].f = params[1];
1329 n[5].f = params[2];
1330 n[6].f = params[3];
1331 }
1332 else {
1333 n[4].f = n[5].f = n[6].f = 0.0F;
1334 }
1335 }
1336 if (ctx->ExecuteFlag) {
1337 (*ctx->Exec->ConvolutionParameterfv)( target, pname, params );
1338 }
1339 }
1340
1341
1342 static void save_CopyPixels( GLint x, GLint y,
1343 GLsizei width, GLsizei height, GLenum type )
1344 {
1345 GET_CURRENT_CONTEXT(ctx);
1346 Node *n;
1347 FLUSH_VB(ctx, "dlist");
1348 n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 );
1349 if (n) {
1350 n[1].i = x;
1351 n[2].i = y;
1352 n[3].i = (GLint) width;
1353 n[4].i = (GLint) height;
1354 n[5].e = type;
1355 }
1356 if (ctx->ExecuteFlag) {
1357 (*ctx->Exec->CopyPixels)( x, y, width, height, type );
1358 }
1359 }
1360
1361
1362
1363 static void
1364 save_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
1365 GLint x, GLint y, GLsizei width, GLint border )
1366 {
1367 GET_CURRENT_CONTEXT(ctx);
1368 Node *n;
1369 FLUSH_VB(ctx, "dlist");
1370 n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
1371 if (n) {
1372 n[1].e = target;
1373 n[2].i = level;
1374 n[3].e = internalformat;
1375 n[4].i = x;
1376 n[5].i = y;
1377 n[6].i = width;
1378 n[7].i = border;
1379 }
1380 if (ctx->ExecuteFlag) {
1381 (*ctx->Exec->CopyTexImage1D)( target, level, internalformat,
1382 x, y, width, border );
1383 }
1384 }
1385
1386
1387 static void
1388 save_CopyTexImage2D( GLenum target, GLint level,
1389 GLenum internalformat,
1390 GLint x, GLint y, GLsizei width,
1391 GLsizei height, GLint border )
1392 {
1393 GET_CURRENT_CONTEXT(ctx);
1394 Node *n;
1395 FLUSH_VB(ctx, "dlist");
1396 n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
1397 if (n) {
1398 n[1].e = target;
1399 n[2].i = level;
1400 n[3].e = internalformat;
1401 n[4].i = x;
1402 n[5].i = y;
1403 n[6].i = width;
1404 n[7].i = height;
1405 n[8].i = border;
1406 }
1407 if (ctx->ExecuteFlag) {
1408 (*ctx->Exec->CopyTexImage2D)( target, level, internalformat,
1409 x, y, width, height, border );
1410 }
1411 }
1412
1413
1414
1415 static void
1416 save_CopyTexSubImage1D( GLenum target, GLint level,
1417 GLint xoffset, GLint x, GLint y,
1418 GLsizei width )
1419 {
1420 GET_CURRENT_CONTEXT(ctx);
1421 Node *n;
1422 FLUSH_VB(ctx, "dlist");
1423 n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
1424 if (n) {
1425 n[1].e = target;
1426 n[2].i = level;
1427 n[3].i = xoffset;
1428 n[4].i = x;
1429 n[5].i = y;
1430 n[6].i = width;
1431 }
1432 if (ctx->ExecuteFlag) {
1433 (*ctx->Exec->CopyTexSubImage1D)( target, level, xoffset, x, y, width );
1434 }
1435 }
1436
1437
1438 static void
1439 save_CopyTexSubImage2D( GLenum target, GLint level,
1440 GLint xoffset, GLint yoffset,
1441 GLint x, GLint y,
1442 GLsizei width, GLint height )
1443 {
1444 GET_CURRENT_CONTEXT(ctx);
1445 Node *n;
1446 FLUSH_VB(ctx, "dlist");
1447 n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
1448 if (n) {
1449 n[1].e = target;
1450 n[2].i = level;
1451 n[3].i = xoffset;
1452 n[4].i = yoffset;
1453 n[5].i = x;
1454 n[6].i = y;
1455 n[7].i = width;
1456 n[8].i = height;
1457 }
1458 if (ctx->ExecuteFlag) {
1459 (*ctx->Exec->CopyTexSubImage2D)( target, level, xoffset, yoffset,
1460 x, y, width, height );
1461 }
1462 }
1463
1464
1465 static void
1466 save_CopyTexSubImage3D( GLenum target, GLint level,
1467 GLint xoffset, GLint yoffset, GLint zoffset,
1468 GLint x, GLint y,
1469 GLsizei width, GLint height )
1470 {
1471 GET_CURRENT_CONTEXT(ctx);
1472 Node *n;
1473 FLUSH_VB(ctx, "dlist");
1474 n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
1475 if (n) {
1476 n[1].e = target;
1477 n[2].i = level;
1478 n[3].i = xoffset;
1479 n[4].i = yoffset;
1480 n[5].i = zoffset;
1481 n[6].i = x;
1482 n[7].i = y;
1483 n[8].i = width;
1484 n[9].i = height;
1485 }
1486 if (ctx->ExecuteFlag) {
1487 (*ctx->Exec->CopyTexSubImage3D)( target, level,
1488 xoffset, yoffset, zoffset,
1489 x, y, width, height );
1490 }
1491 }
1492
1493
1494 static void save_CullFace( GLenum mode )
1495 {
1496 GET_CURRENT_CONTEXT(ctx);
1497 Node *n;
1498 FLUSH_VB(ctx, "dlist");
1499 n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 );
1500 if (n) {
1501 n[1].e = mode;
1502 }
1503 if (ctx->ExecuteFlag) {
1504 (*ctx->Exec->CullFace)( mode );
1505 }
1506 }
1507
1508
1509 static void save_DepthFunc( GLenum func )
1510 {
1511 GET_CURRENT_CONTEXT(ctx);
1512 Node *n;
1513 FLUSH_VB(ctx, "dlist");
1514 n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 );
1515 if (n) {
1516 n[1].e = func;
1517 }
1518 if (ctx->ExecuteFlag) {
1519 (*ctx->Exec->DepthFunc)( func );
1520 }
1521 }
1522
1523
1524 static void save_DepthMask( GLboolean mask )
1525 {
1526 GET_CURRENT_CONTEXT(ctx);
1527 Node *n;
1528 FLUSH_VB(ctx, "dlist");
1529 n = alloc_instruction( ctx, OPCODE_DEPTH_MASK, 1 );
1530 if (n) {
1531 n[1].b = mask;
1532 }
1533 if (ctx->ExecuteFlag) {
1534 (*ctx->Exec->DepthMask)( mask );
1535 }
1536 }
1537
1538
1539 static void save_DepthRange( GLclampd nearval, GLclampd farval )
1540 {
1541 GET_CURRENT_CONTEXT(ctx);
1542 Node *n;
1543 FLUSH_VB(ctx, "dlist");
1544 n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 );
1545 if (n) {
1546 n[1].f = (GLfloat) nearval;
1547 n[2].f = (GLfloat) farval;
1548 }
1549 if (ctx->ExecuteFlag) {
1550 (*ctx->Exec->DepthRange)( nearval, farval );
1551 }
1552 }
1553
1554
1555 static void save_Disable( GLenum cap )
1556 {
1557 GET_CURRENT_CONTEXT(ctx);
1558 Node *n;
1559 FLUSH_VB(ctx, "dlist");
1560 n = alloc_instruction( ctx, OPCODE_DISABLE, 1 );
1561 if (n) {
1562 n[1].e = cap;
1563 }
1564 if (ctx->ExecuteFlag) {
1565 (*ctx->Exec->Disable)( cap );
1566 }
1567 }
1568
1569
1570 static void save_DrawBuffer( GLenum mode )
1571 {
1572 GET_CURRENT_CONTEXT(ctx);
1573 Node *n;
1574 FLUSH_VB(ctx, "dlist");
1575 n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 );
1576 if (n) {
1577 n[1].e = mode;
1578 }
1579 if (ctx->ExecuteFlag) {
1580 (*ctx->Exec->DrawBuffer)( mode );
1581 }
1582 }
1583
1584
1585 static void save_DrawPixels( GLsizei width, GLsizei height,
1586 GLenum format, GLenum type,
1587 const GLvoid *pixels )
1588 {
1589 GET_CURRENT_CONTEXT(ctx);
1590 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
1591 pixels, &ctx->Unpack);
1592 Node *n;
1593 FLUSH_VB(ctx, "dlist");
1594 n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 5 );
1595 if (n) {
1596 n[1].i = width;
1597 n[2].i = height;
1598 n[3].e = format;
1599 n[4].e = type;
1600 n[5].data = image;
1601 }
1602 else if (image) {
1603 FREE(image);
1604 }
1605 if (ctx->ExecuteFlag) {
1606 (*ctx->Exec->DrawPixels)( width, height, format, type, pixels );
1607 }
1608 }
1609
1610
1611
1612 static void save_Enable( GLenum cap )
1613 {
1614 GET_CURRENT_CONTEXT(ctx);
1615 Node *n;
1616 FLUSH_VB(ctx, "dlist");
1617 n = alloc_instruction( ctx, OPCODE_ENABLE, 1 );
1618 if (n) {
1619 n[1].e = cap;
1620 }
1621 if (ctx->ExecuteFlag) {
1622 (*ctx->Exec->Enable)( cap );
1623 }
1624 }
1625
1626
1627
1628 static void save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
1629 {
1630 GET_CURRENT_CONTEXT(ctx);
1631 Node *n;
1632 FLUSH_VB(ctx, "dlist");
1633 n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 );
1634 if (n) {
1635 n[1].e = mode;
1636 n[2].i = i1;
1637 n[3].i = i2;
1638 }
1639 if (ctx->ExecuteFlag) {
1640 (*ctx->Exec->EvalMesh1)( mode, i1, i2 );
1641 }
1642 }
1643
1644
1645 static void save_EvalMesh2(
1646 GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
1647 {
1648 GET_CURRENT_CONTEXT(ctx);
1649 Node *n;
1650 FLUSH_VB(ctx, "dlist");
1651 n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 );
1652 if (n) {
1653 n[1].e = mode;
1654 n[2].i = i1;
1655 n[3].i = i2;
1656 n[4].i = j1;
1657 n[5].i = j2;
1658 }
1659 if (ctx->ExecuteFlag) {
1660 (*ctx->Exec->EvalMesh2)( mode, i1, i2, j1, j2 );
1661 }
1662 }
1663
1664
1665
1666
1667 static void save_Fogfv( GLenum pname, const GLfloat *params )
1668 {
1669 GET_CURRENT_CONTEXT(ctx);
1670 Node *n;
1671 FLUSH_VB(ctx, "dlist");
1672 n = alloc_instruction( ctx, OPCODE_FOG, 5 );
1673 if (n) {
1674 n[1].e = pname;
1675 n[2].f = params[0];
1676 n[3].f = params[1];
1677 n[4].f = params[2];
1678 n[5].f = params[3];
1679 }
1680 if (ctx->ExecuteFlag) {
1681 (*ctx->Exec->Fogfv)( pname, params );
1682 }
1683 }
1684
1685
1686 static void save_Fogf( GLenum pname, GLfloat param )
1687 {
1688 save_Fogfv(pname, &param);
1689 }
1690
1691
1692 static void save_Fogiv(GLenum pname, const GLint *params )
1693 {
1694 GLfloat p[4];
1695 switch (pname) {
1696 case GL_FOG_MODE:
1697 case GL_FOG_DENSITY:
1698 case GL_FOG_START:
1699 case GL_FOG_END:
1700 case GL_FOG_INDEX:
1701 p[0] = (GLfloat) *params;
1702 break;
1703 case GL_FOG_COLOR:
1704 p[0] = INT_TO_FLOAT( params[0] );
1705 p[1] = INT_TO_FLOAT( params[1] );
1706 p[2] = INT_TO_FLOAT( params[2] );
1707 p[3] = INT_TO_FLOAT( params[3] );
1708 break;
1709 default:
1710 /* Error will be caught later in gl_Fogfv */
1711 ;
1712 }
1713 save_Fogfv(pname, p);
1714 }
1715
1716
1717 static void save_Fogi(GLenum pname, GLint param )
1718 {
1719 save_Fogiv(pname, &param);
1720 }
1721
1722
1723 static void save_FrontFace( GLenum mode )
1724 {
1725 GET_CURRENT_CONTEXT(ctx);
1726 Node *n;
1727 FLUSH_VB(ctx, "dlist");
1728 n = alloc_instruction( ctx, OPCODE_FRONT_FACE, 1 );
1729 if (n) {
1730 n[1].e = mode;
1731 }
1732 if (ctx->ExecuteFlag) {
1733 (*ctx->Exec->FrontFace)( mode );
1734 }
1735 }
1736
1737
1738 static void save_Frustum( GLdouble left, GLdouble right,
1739 GLdouble bottom, GLdouble top,
1740 GLdouble nearval, GLdouble farval )
1741 {
1742 GET_CURRENT_CONTEXT(ctx);
1743 Node *n;
1744 FLUSH_VB(ctx, "dlist");
1745 n = alloc_instruction( ctx, OPCODE_FRUSTUM, 6 );
1746 if (n) {
1747 n[1].f = left;
1748 n[2].f = right;
1749 n[3].f = bottom;
1750 n[4].f = top;
1751 n[5].f = nearval;
1752 n[6].f = farval;
1753 }
1754 if (ctx->ExecuteFlag) {
1755 (*ctx->Exec->Frustum)( left, right, bottom, top, nearval, farval );
1756 }
1757 }
1758
1759
1760 static void save_Hint( GLenum target, GLenum mode )
1761 {
1762 GET_CURRENT_CONTEXT(ctx);
1763 Node *n;
1764 FLUSH_VB(ctx, "dlist");
1765 n = alloc_instruction( ctx, OPCODE_HINT, 2 );
1766 if (n) {
1767 n[1].e = target;
1768 n[2].e = mode;
1769 }
1770 if (ctx->ExecuteFlag) {
1771 (*ctx->Exec->Hint)( target, mode );
1772 }
1773 }
1774
1775
1776 /* GL_PGI_misc_hints*/
1777 static void save_HintPGI( GLenum target, GLint mode )
1778 {
1779 GET_CURRENT_CONTEXT(ctx);
1780 Node *n;
1781 FLUSH_VB(ctx, "dlist");
1782 n = alloc_instruction( ctx, OPCODE_HINT_PGI, 2 );
1783 if (n) {
1784 n[1].e = target;
1785 n[2].i = mode;
1786 }
1787 if (ctx->ExecuteFlag) {
1788 (*ctx->Exec->HintPGI)( target, mode );
1789 }
1790 }
1791
1792
1793 static void
1794 save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink)
1795 {
1796 GET_CURRENT_CONTEXT(ctx);
1797 Node *n;
1798
1799 FLUSH_VB(ctx, "dlist");
1800 n = alloc_instruction( ctx, OPCODE_HISTOGRAM, 4 );
1801 if (n) {
1802 n[1].e = target;
1803 n[2].i = width;
1804 n[3].e = internalFormat;
1805 n[4].b = sink;
1806 }
1807 if (ctx->ExecuteFlag) {
1808 (*ctx->Exec->Histogram)( target, width, internalFormat, sink );
1809 }
1810 }
1811
1812
1813 static void save_IndexMask( GLuint mask )
1814 {
1815 GET_CURRENT_CONTEXT(ctx);
1816 Node *n;
1817 FLUSH_VB(ctx, "dlist");
1818 n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 );
1819 if (n) {
1820 n[1].ui = mask;
1821 }
1822 if (ctx->ExecuteFlag) {
1823 (*ctx->Exec->IndexMask)( mask );
1824 }
1825 }
1826
1827
1828 static void save_InitNames( void )
1829 {
1830 GET_CURRENT_CONTEXT(ctx);
1831 FLUSH_VB(ctx, "dlist");
1832 (void) alloc_instruction( ctx, OPCODE_INIT_NAMES, 0 );
1833 if (ctx->ExecuteFlag) {
1834 (*ctx->Exec->InitNames)();
1835 }
1836 }
1837
1838
1839 static void save_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
1840 {
1841 GET_CURRENT_CONTEXT(ctx);
1842 Node *n;
1843 FLUSH_VB(ctx, "dlist");
1844 n = alloc_instruction( ctx, OPCODE_LIGHT, 6 );
1845 if (OPCODE_LIGHT) {
1846 GLint i, nParams;
1847 n[1].e = light;
1848 n[2].e = pname;
1849 switch (pname) {
1850 case GL_AMBIENT:
1851 nParams = 4;
1852 break;
1853 case GL_DIFFUSE:
1854 nParams = 4;
1855 break;
1856 case GL_SPECULAR:
1857 nParams = 4;
1858 break;
1859 case GL_POSITION:
1860 nParams = 4;
1861 break;
1862 case GL_SPOT_DIRECTION:
1863 nParams = 3;
1864 break;
1865 case GL_SPOT_EXPONENT:
1866 nParams = 1;
1867 break;
1868 case GL_SPOT_CUTOFF:
1869 nParams = 1;
1870 break;
1871 case GL_CONSTANT_ATTENUATION:
1872 nParams = 1;
1873 break;
1874 case GL_LINEAR_ATTENUATION:
1875 nParams = 1;
1876 break;
1877 case GL_QUADRATIC_ATTENUATION:
1878 nParams = 1;
1879 break;
1880 default:
1881 nParams = 0;
1882 }
1883 for (i = 0; i < nParams; i++) {
1884 n[3+i].f = params[i];
1885 }
1886 }
1887 if (ctx->ExecuteFlag) {
1888 (*ctx->Exec->Lightfv)( light, pname, params );
1889 }
1890 }
1891
1892
1893 static void save_Lightf( GLenum light, GLenum pname, GLfloat params )
1894 {
1895 save_Lightfv(light, pname, &params);
1896 }
1897
1898
1899 static void save_Lightiv( GLenum light, GLenum pname, const GLint *params )
1900 {
1901 GLfloat fparam[4];
1902 switch (pname) {
1903 case GL_AMBIENT:
1904 case GL_DIFFUSE:
1905 case GL_SPECULAR:
1906 fparam[0] = INT_TO_FLOAT( params[0] );
1907 fparam[1] = INT_TO_FLOAT( params[1] );
1908 fparam[2] = INT_TO_FLOAT( params[2] );
1909 fparam[3] = INT_TO_FLOAT( params[3] );
1910 break;
1911 case GL_POSITION:
1912 fparam[0] = (GLfloat) params[0];
1913 fparam[1] = (GLfloat) params[1];
1914 fparam[2] = (GLfloat) params[2];
1915 fparam[3] = (GLfloat) params[3];
1916 break;
1917 case GL_SPOT_DIRECTION:
1918 fparam[0] = (GLfloat) params[0];
1919 fparam[1] = (GLfloat) params[1];
1920 fparam[2] = (GLfloat) params[2];
1921 break;
1922 case GL_SPOT_EXPONENT:
1923 case GL_SPOT_CUTOFF:
1924 case GL_CONSTANT_ATTENUATION:
1925 case GL_LINEAR_ATTENUATION:
1926 case GL_QUADRATIC_ATTENUATION:
1927 fparam[0] = (GLfloat) params[0];
1928 break;
1929 default:
1930 /* error will be caught later in gl_Lightfv */
1931 ;
1932 }
1933 save_Lightfv( light, pname, fparam );
1934 }
1935
1936
1937 static void save_Lighti( GLenum light, GLenum pname, GLint param )
1938 {
1939 save_Lightiv( light, pname, &param );
1940 }
1941
1942
1943 static void save_LightModelfv( GLenum pname, const GLfloat *params )
1944 {
1945 GET_CURRENT_CONTEXT(ctx);
1946 Node *n;
1947 FLUSH_VB(ctx, "dlist");
1948 n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 );
1949 if (n) {
1950 n[1].e = pname;
1951 n[2].f = params[0];
1952 n[3].f = params[1];
1953 n[4].f = params[2];
1954 n[5].f = params[3];
1955 }
1956 if (ctx->ExecuteFlag) {
1957 (*ctx->Exec->LightModelfv)( pname, params );
1958 }
1959 }
1960
1961
1962 static void save_LightModelf( GLenum pname, GLfloat param )
1963 {
1964 save_LightModelfv(pname, &param);
1965 }
1966
1967
1968 static void save_LightModeliv( GLenum pname, const GLint *params )
1969 {
1970 GLfloat fparam[4];
1971 switch (pname) {
1972 case GL_LIGHT_MODEL_AMBIENT:
1973 fparam[0] = INT_TO_FLOAT( params[0] );
1974 fparam[1] = INT_TO_FLOAT( params[1] );
1975 fparam[2] = INT_TO_FLOAT( params[2] );
1976 fparam[3] = INT_TO_FLOAT( params[3] );
1977 break;
1978 case GL_LIGHT_MODEL_LOCAL_VIEWER:
1979 case GL_LIGHT_MODEL_TWO_SIDE:
1980 case GL_LIGHT_MODEL_COLOR_CONTROL:
1981 fparam[0] = (GLfloat) params[0];
1982 break;
1983 default:
1984 /* Error will be caught later in gl_LightModelfv */
1985 ;
1986 }
1987 save_LightModelfv(pname, fparam);
1988 }
1989
1990
1991 static void save_LightModeli( GLenum pname, GLint param )
1992 {
1993 save_LightModeliv(pname, &param);
1994 }
1995
1996
1997 static void save_LineStipple( GLint factor, GLushort pattern )
1998 {
1999 GET_CURRENT_CONTEXT(ctx);
2000 Node *n;
2001 FLUSH_VB(ctx, "dlist");
2002 n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 );
2003 if (n) {
2004 n[1].i = factor;
2005 n[2].us = pattern;
2006 }
2007 if (ctx->ExecuteFlag) {
2008 (*ctx->Exec->LineStipple)( factor, pattern );
2009 }
2010 }
2011
2012
2013 static void save_LineWidth( GLfloat width )
2014 {
2015 GET_CURRENT_CONTEXT(ctx);
2016 Node *n;
2017 FLUSH_VB(ctx, "dlist");
2018 n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 );
2019 if (n) {
2020 n[1].f = width;
2021 }
2022 if (ctx->ExecuteFlag) {
2023 (*ctx->Exec->LineWidth)( width );
2024 }
2025 }
2026
2027
2028 static void save_ListBase( GLuint base )
2029 {
2030 GET_CURRENT_CONTEXT(ctx);
2031 Node *n;
2032 FLUSH_VB(ctx, "dlist");
2033 n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 );
2034 if (n) {
2035 n[1].ui = base;
2036 }
2037 if (ctx->ExecuteFlag) {
2038 (*ctx->Exec->ListBase)( base );
2039 }
2040 }
2041
2042
2043 static void save_LoadIdentity( void )
2044 {
2045 GET_CURRENT_CONTEXT(ctx);
2046 FLUSH_VB(ctx, "dlist");
2047 (void) alloc_instruction( ctx, OPCODE_LOAD_IDENTITY, 0 );
2048 if (ctx->ExecuteFlag) {
2049 (*ctx->Exec->LoadIdentity)();
2050 }
2051 }
2052
2053
2054 static void save_LoadMatrixf( const GLfloat *m )
2055 {
2056 GET_CURRENT_CONTEXT(ctx);
2057 Node *n;
2058 FLUSH_VB(ctx, "dlist");
2059 n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 );
2060 if (n) {
2061 GLuint i;
2062 for (i=0;i<16;i++) {
2063 n[1+i].f = m[i];
2064 }
2065 }
2066 if (ctx->ExecuteFlag) {
2067 (*ctx->Exec->LoadMatrixf)( m );
2068 }
2069 }
2070
2071
2072 static void save_LoadMatrixd( const GLdouble *m )
2073 {
2074 GLfloat f[16];
2075 GLint i;
2076 for (i = 0; i < 16; i++) {
2077 f[i] = m[i];
2078 }
2079 save_LoadMatrixf(f);
2080 }
2081
2082
2083 static void save_LoadName( GLuint name )
2084 {
2085 GET_CURRENT_CONTEXT(ctx);
2086 Node *n;
2087 FLUSH_VB(ctx, "dlist");
2088 n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 );
2089 if (n) {
2090 n[1].ui = name;
2091 }
2092 if (ctx->ExecuteFlag) {
2093 (*ctx->Exec->LoadName)( name );
2094 }
2095 }
2096
2097
2098 static void save_LogicOp( GLenum opcode )
2099 {
2100 GET_CURRENT_CONTEXT(ctx);
2101 Node *n;
2102 FLUSH_VB(ctx, "dlist");
2103 n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 );
2104 if (n) {
2105 n[1].e = opcode;
2106 }
2107 if (ctx->ExecuteFlag) {
2108 (*ctx->Exec->LogicOp)( opcode );
2109 }
2110 }
2111
2112
2113 static void save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
2114 GLint order, const GLdouble *points)
2115 {
2116 GET_CURRENT_CONTEXT(ctx);
2117 Node *n;
2118 FLUSH_VB(ctx, "dlist");
2119 n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
2120 if (n) {
2121 GLfloat *pnts = gl_copy_map_points1d( target, stride, order, points );
2122 n[1].e = target;
2123 n[2].f = u1;
2124 n[3].f = u2;
2125 n[4].i = _mesa_evaluator_components(target); /* stride */
2126 n[5].i = order;
2127 n[6].data = (void *) pnts;
2128 }
2129 if (ctx->ExecuteFlag) {
2130 (*ctx->Exec->Map1d)( target, u1, u2, stride, order, points );
2131 }
2132 }
2133
2134 static void save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
2135 GLint order, const GLfloat *points)
2136 {
2137 GET_CURRENT_CONTEXT(ctx);
2138 Node *n;
2139 FLUSH_VB(ctx, "dlist");
2140 n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
2141 if (n) {
2142 GLfloat *pnts = gl_copy_map_points1f( target, stride, order, points );
2143 n[1].e = target;
2144 n[2].f = u1;
2145 n[3].f = u2;
2146 n[4].i = _mesa_evaluator_components(target); /* stride */
2147 n[5].i = order;
2148 n[6].data = (void *) pnts;
2149 }
2150 if (ctx->ExecuteFlag) {
2151 (*ctx->Exec->Map1f)( target, u1, u2, stride, order, points );
2152 }
2153 }
2154
2155
2156 static void save_Map2d( GLenum target,
2157 GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
2158 GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
2159 const GLdouble *points )
2160 {
2161 GET_CURRENT_CONTEXT(ctx);
2162 Node *n;
2163 FLUSH_VB(ctx, "dlist");
2164 n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
2165 if (n) {
2166 GLfloat *pnts = gl_copy_map_points2d( target, ustride, uorder,
2167 vstride, vorder, points );
2168 n[1].e = target;
2169 n[2].f = u1;
2170 n[3].f = u2;
2171 n[4].f = v1;
2172 n[5].f = v2;
2173 /* XXX verify these strides are correct */
2174 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
2175 n[7].i = _mesa_evaluator_components(target); /*vstride*/
2176 n[8].i = uorder;
2177 n[9].i = vorder;
2178 n[10].data = (void *) pnts;
2179 }
2180 if (ctx->ExecuteFlag) {
2181 (*ctx->Exec->Map2d)( target,
2182 u1, u2, ustride, uorder,
2183 v1, v2, vstride, vorder, points );
2184 }
2185 }
2186
2187
2188 static void save_Map2f( GLenum target,
2189 GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
2190 GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
2191 const GLfloat *points )
2192 {
2193 GET_CURRENT_CONTEXT(ctx);
2194 Node *n;
2195 FLUSH_VB(ctx, "dlist");
2196 n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
2197 if (n) {
2198 GLfloat *pnts = gl_copy_map_points2f( target, ustride, uorder,
2199 vstride, vorder, points );
2200 n[1].e = target;
2201 n[2].f = u1;
2202 n[3].f = u2;
2203 n[4].f = v1;
2204 n[5].f = v2;
2205 /* XXX verify these strides are correct */
2206 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
2207 n[7].i = _mesa_evaluator_components(target); /*vstride*/
2208 n[8].i = uorder;
2209 n[9].i = vorder;
2210 n[10].data = (void *) pnts;
2211 }
2212 if (ctx->ExecuteFlag) {
2213 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
2214 v1, v2, vstride, vorder, points );
2215 }
2216 }
2217
2218
2219 static void save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
2220 {
2221 GET_CURRENT_CONTEXT(ctx);
2222 Node *n;
2223 FLUSH_VB(ctx, "dlist");
2224 n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 );
2225 if (n) {
2226 n[1].i = un;
2227 n[2].f = u1;
2228 n[3].f = u2;
2229 }
2230 if (ctx->ExecuteFlag) {
2231 (*ctx->Exec->MapGrid1f)( un, u1, u2 );
2232 }
2233 }
2234
2235
2236 static void save_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
2237 {
2238 save_MapGrid1f(un, u1, u2);
2239 }
2240
2241
2242 static void save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
2243 GLint vn, GLfloat v1, GLfloat v2 )
2244 {
2245 GET_CURRENT_CONTEXT(ctx);
2246 Node *n;
2247 FLUSH_VB(ctx, "dlist");
2248 n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 );
2249 if (n) {
2250 n[1].i = un;
2251 n[2].f = u1;
2252 n[3].f = u2;
2253 n[4].i = vn;
2254 n[5].f = v1;
2255 n[6].f = v2;
2256 }
2257 if (ctx->ExecuteFlag) {
2258 (*ctx->Exec->MapGrid2f)( un, u1, u2, vn, v1, v2 );
2259 }
2260 }
2261
2262
2263
2264 static void save_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
2265 GLint vn, GLdouble v1, GLdouble v2 )
2266 {
2267 save_MapGrid2f(un, u1, u2, vn, v1, v2);
2268 }
2269
2270
2271 static void save_MatrixMode( GLenum mode )
2272 {
2273 GET_CURRENT_CONTEXT(ctx);
2274 Node *n;
2275 FLUSH_VB(ctx, "dlist");
2276 n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 );
2277 if (n) {
2278 n[1].e = mode;
2279 }
2280 if (ctx->ExecuteFlag) {
2281 (*ctx->Exec->MatrixMode)( mode );
2282 }
2283 }
2284
2285
2286 static void
2287 save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
2288 {
2289 GET_CURRENT_CONTEXT(ctx);
2290 Node *n;
2291
2292 FLUSH_VB(ctx, "dlist");
2293 n = alloc_instruction( ctx, OPCODE_MIN_MAX, 3 );
2294 if (n) {
2295 n[1].e = target;
2296 n[2].e = internalFormat;
2297 n[3].b = sink;
2298 }
2299 if (ctx->ExecuteFlag) {
2300 (*ctx->Exec->Minmax)( target, internalFormat, sink );
2301 }
2302 }
2303
2304
2305 static void save_MultMatrixf( const GLfloat *m )
2306 {
2307 GET_CURRENT_CONTEXT(ctx);
2308 Node *n;
2309 FLUSH_VB(ctx, "dlist");
2310 n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 );
2311 if (n) {
2312 GLuint i;
2313 for (i=0;i<16;i++) {
2314 n[1+i].f = m[i];
2315 }
2316 }
2317 if (ctx->ExecuteFlag) {
2318 (*ctx->Exec->MultMatrixf)( m );
2319 }
2320 }
2321
2322
2323 static void save_MultMatrixd( const GLdouble *m )
2324 {
2325 GLfloat f[16];
2326 GLint i;
2327 for (i = 0; i < 16; i++) {
2328 f[i] = m[i];
2329 }
2330 save_MultMatrixf(f);
2331 }
2332
2333
2334 static void save_NewList( GLuint list, GLenum mode )
2335 {
2336 GET_CURRENT_CONTEXT(ctx);
2337 /* It's an error to call this function while building a display list */
2338 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
2339 (void) list;
2340 (void) mode;
2341 }
2342
2343
2344
2345 static void save_Ortho( GLdouble left, GLdouble right,
2346 GLdouble bottom, GLdouble top,
2347 GLdouble nearval, GLdouble farval )
2348 {
2349 GET_CURRENT_CONTEXT(ctx);
2350 Node *n;
2351 FLUSH_VB(ctx, "dlist");
2352 n = alloc_instruction( ctx, OPCODE_ORTHO, 6 );
2353 if (n) {
2354 n[1].f = left;
2355 n[2].f = right;
2356 n[3].f = bottom;
2357 n[4].f = top;
2358 n[5].f = nearval;
2359 n[6].f = farval;
2360 }
2361 if (ctx->ExecuteFlag) {
2362 (*ctx->Exec->Ortho)( left, right, bottom, top, nearval, farval );
2363 }
2364 }
2365
2366
2367 static void save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
2368 {
2369 GET_CURRENT_CONTEXT(ctx);
2370 Node *n;
2371 FLUSH_VB(ctx, "dlist");
2372 n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 );
2373 if (n) {
2374 n[1].e = map;
2375 n[2].i = mapsize;
2376 n[3].data = (void *) MALLOC( mapsize * sizeof(GLfloat) );
2377 MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
2378 }
2379 if (ctx->ExecuteFlag) {
2380 (*ctx->Exec->PixelMapfv)( map, mapsize, values );
2381 }
2382 }
2383
2384
2385 static void save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
2386 {
2387 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2388 GLint i;
2389 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
2390 for (i=0;i<mapsize;i++) {
2391 fvalues[i] = (GLfloat) values[i];
2392 }
2393 }
2394 else {
2395 for (i=0;i<mapsize;i++) {
2396 fvalues[i] = UINT_TO_FLOAT( values[i] );
2397 }
2398 }
2399 save_PixelMapfv(map, mapsize, fvalues);
2400 }
2401
2402
2403 static void save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
2404 {
2405 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2406 GLint i;
2407 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
2408 for (i=0;i<mapsize;i++) {
2409 fvalues[i] = (GLfloat) values[i];
2410 }
2411 }
2412 else {
2413 for (i=0;i<mapsize;i++) {
2414 fvalues[i] = USHORT_TO_FLOAT( values[i] );
2415 }
2416 }
2417 save_PixelMapfv(map, mapsize, fvalues);
2418 }
2419
2420
2421 static void save_PixelTransferf( GLenum pname, GLfloat param )
2422 {
2423 GET_CURRENT_CONTEXT(ctx);
2424 Node *n;
2425 FLUSH_VB(ctx, "dlist");
2426 n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 );
2427 if (n) {
2428 n[1].e = pname;
2429 n[2].f = param;
2430 }
2431 if (ctx->ExecuteFlag) {
2432 (*ctx->Exec->PixelTransferf)( pname, param );
2433 }
2434 }
2435
2436
2437 static void save_PixelTransferi( GLenum pname, GLint param )
2438 {
2439 save_PixelTransferf( pname, (GLfloat) param );
2440 }
2441
2442
2443 static void save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
2444 {
2445 GET_CURRENT_CONTEXT(ctx);
2446 Node *n;
2447 FLUSH_VB(ctx, "dlist");
2448 n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 );
2449 if (n) {
2450 n[1].f = xfactor;
2451 n[2].f = yfactor;
2452 }
2453 if (ctx->ExecuteFlag) {
2454 (*ctx->Exec->PixelZoom)( xfactor, yfactor );
2455 }
2456 }
2457
2458
2459 static void save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
2460 {
2461 GET_CURRENT_CONTEXT(ctx);
2462 Node *n;
2463 FLUSH_VB(ctx, "dlist");
2464 n = alloc_instruction( ctx, OPCODE_POINT_PARAMETERS, 4 );
2465 if (n) {
2466 n[1].e = pname;
2467 n[2].f = params[0];
2468 n[3].f = params[1];
2469 n[4].f = params[2];
2470 }
2471 if (ctx->ExecuteFlag) {
2472 (*ctx->Exec->PointParameterfvEXT)( pname, params );
2473 }
2474 }
2475
2476
2477 static void save_PointParameterfEXT( GLenum pname, GLfloat param )
2478 {
2479 save_PointParameterfvEXT(pname, &param);
2480 }
2481
2482
2483 static void save_PointSize( GLfloat size )
2484 {
2485 GET_CURRENT_CONTEXT(ctx);
2486 Node *n;
2487 FLUSH_VB(ctx, "dlist");
2488 n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 );
2489 if (n) {
2490 n[1].f = size;
2491 }
2492 if (ctx->ExecuteFlag) {
2493 (*ctx->Exec->PointSize)( size );
2494 }
2495 }
2496
2497
2498 static void save_PolygonMode( GLenum face, GLenum mode )
2499 {
2500 GET_CURRENT_CONTEXT(ctx);
2501 Node *n;
2502 FLUSH_VB(ctx, "dlist");
2503 n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 );
2504 if (n) {
2505 n[1].e = face;
2506 n[2].e = mode;
2507 }
2508 if (ctx->ExecuteFlag) {
2509 (*ctx->Exec->PolygonMode)( face, mode );
2510 }
2511 }
2512
2513
2514 /*
2515 * Polygon stipple must have been upacked already!
2516 */
2517 static void save_PolygonStipple( const GLubyte *pattern )
2518 {
2519 GET_CURRENT_CONTEXT(ctx);
2520 Node *n;
2521 FLUSH_VB(ctx, "dlist");
2522 n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 );
2523 if (n) {
2524 void *data;
2525 n[1].data = MALLOC( 32 * 4 );
2526 data = n[1].data; /* This needed for Acorn compiler */
2527 MEMCPY( data, pattern, 32 * 4 );
2528 }
2529 if (ctx->ExecuteFlag) {
2530 (*ctx->Exec->PolygonStipple)( (GLubyte*) pattern );
2531 }
2532 }
2533
2534
2535 static void save_PolygonOffset( GLfloat factor, GLfloat units )
2536 {
2537 GET_CURRENT_CONTEXT(ctx);
2538 Node *n;
2539 FLUSH_VB(ctx, "dlist");
2540 n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 );
2541 if (n) {
2542 n[1].f = factor;
2543 n[2].f = units;
2544 }
2545 if (ctx->ExecuteFlag) {
2546 (*ctx->Exec->PolygonOffset)( factor, units );
2547 }
2548 }
2549
2550
2551 static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
2552 {
2553 GET_CURRENT_CONTEXT(ctx);
2554 save_PolygonOffset(factor, ctx->Visual->DepthMaxF * bias);
2555 }
2556
2557
2558 static void save_PopAttrib( void )
2559 {
2560 GET_CURRENT_CONTEXT(ctx);
2561 FLUSH_VB(ctx, "dlist");
2562 (void) alloc_instruction( ctx, OPCODE_POP_ATTRIB, 0 );
2563 if (ctx->ExecuteFlag) {
2564 (*ctx->Exec->PopAttrib)();
2565 }
2566 }
2567
2568
2569 static void save_PopMatrix( void )
2570 {
2571 GET_CURRENT_CONTEXT(ctx);
2572 FLUSH_VB(ctx, "dlist");
2573 (void) alloc_instruction( ctx, OPCODE_POP_MATRIX, 0 );
2574 if (ctx->ExecuteFlag) {
2575 (*ctx->Exec->PopMatrix)();
2576 }
2577 }
2578
2579
2580 static void save_PopName( void )
2581 {
2582 GET_CURRENT_CONTEXT(ctx);
2583 FLUSH_VB(ctx, "dlist");
2584 (void) alloc_instruction( ctx, OPCODE_POP_NAME, 0 );
2585 if (ctx->ExecuteFlag) {
2586 (*ctx->Exec->PopName)();
2587 }
2588 }
2589
2590
2591 static void save_PrioritizeTextures( GLsizei num, const GLuint *textures,
2592 const GLclampf *priorities )
2593 {
2594 GET_CURRENT_CONTEXT(ctx);
2595 GLint i;
2596 FLUSH_VB(ctx, "dlist");
2597
2598 for (i=0;i<num;i++) {
2599 Node *n;
2600 n = alloc_instruction( ctx, OPCODE_PRIORITIZE_TEXTURE, 2 );
2601 if (n) {
2602 n[1].ui = textures[i];
2603 n[2].f = priorities[i];
2604 }
2605 }
2606 if (ctx->ExecuteFlag) {
2607 (*ctx->Exec->PrioritizeTextures)( num, textures, priorities );
2608 }
2609 }
2610
2611
2612 static void save_PushAttrib( GLbitfield mask )
2613 {
2614 GET_CURRENT_CONTEXT(ctx);
2615 Node *n;
2616 FLUSH_VB(ctx, "dlist");
2617 n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 );
2618 if (n) {
2619 n[1].bf = mask;
2620 }
2621 if (ctx->ExecuteFlag) {
2622 (*ctx->Exec->PushAttrib)( mask );
2623 }
2624 }
2625
2626
2627 static void save_PushMatrix( void )
2628 {
2629 GET_CURRENT_CONTEXT(ctx);
2630 FLUSH_VB(ctx, "dlist");
2631 (void) alloc_instruction( ctx, OPCODE_PUSH_MATRIX, 0 );
2632 if (ctx->ExecuteFlag) {
2633 (*ctx->Exec->PushMatrix)();
2634 }
2635 }
2636
2637
2638 static void save_PushName( GLuint name )
2639 {
2640 GET_CURRENT_CONTEXT(ctx);
2641 Node *n;
2642 FLUSH_VB(ctx, "dlist");
2643 n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 );
2644 if (n) {
2645 n[1].ui = name;
2646 }
2647 if (ctx->ExecuteFlag) {
2648 (*ctx->Exec->PushName)( name );
2649 }
2650 }
2651
2652
2653 static void save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
2654 {
2655 GET_CURRENT_CONTEXT(ctx);
2656 Node *n;
2657 FLUSH_VB(ctx, "dlist");
2658 n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 );
2659 if (n) {
2660 n[1].f = x;
2661 n[2].f = y;
2662 n[3].f = z;
2663 n[4].f = w;
2664 }
2665 if (ctx->ExecuteFlag) {
2666 (*ctx->Exec->RasterPos4f)( x, y, z, w );
2667 }
2668 }
2669
2670 static void save_RasterPos2d(GLdouble x, GLdouble y)
2671 {
2672 save_RasterPos4f(x, y, 0.0F, 1.0F);
2673 }
2674
2675 static void save_RasterPos2f(GLfloat x, GLfloat y)
2676 {
2677 save_RasterPos4f(x, y, 0.0F, 1.0F);
2678 }
2679
2680 static void save_RasterPos2i(GLint x, GLint y)
2681 {
2682 save_RasterPos4f(x, y, 0.0F, 1.0F);
2683 }
2684
2685 static void save_RasterPos2s(GLshort x, GLshort y)
2686 {
2687 save_RasterPos4f(x, y, 0.0F, 1.0F);
2688 }
2689
2690 static void save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
2691 {
2692 save_RasterPos4f(x, y, z, 1.0F);
2693 }
2694
2695 static void save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
2696 {
2697 save_RasterPos4f(x, y, z, 1.0F);
2698 }
2699
2700 static void save_RasterPos3i(GLint x, GLint y, GLint z)
2701 {
2702 save_RasterPos4f(x, y, z, 1.0F);
2703 }
2704
2705 static void save_RasterPos3s(GLshort x, GLshort y, GLshort z)
2706 {
2707 save_RasterPos4f(x, y, z, 1.0F);
2708 }
2709
2710 static void save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
2711 {
2712 save_RasterPos4f(x, y, z, w);
2713 }
2714
2715 static void save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
2716 {
2717 save_RasterPos4f(x, y, z, w);
2718 }
2719
2720 static void save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
2721 {
2722 save_RasterPos4f(x, y, z, w);
2723 }
2724
2725 static void save_RasterPos2dv(const GLdouble *v)
2726 {
2727 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2728 }
2729
2730 static void save_RasterPos2fv(const GLfloat *v)
2731 {
2732 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2733 }
2734
2735 static void save_RasterPos2iv(const GLint *v)
2736 {
2737 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2738 }
2739
2740 static void save_RasterPos2sv(const GLshort *v)
2741 {
2742 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2743 }
2744
2745 static void save_RasterPos3dv(const GLdouble *v)
2746 {
2747 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2748 }
2749
2750 static void save_RasterPos3fv(const GLfloat *v)
2751 {
2752 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2753 }
2754
2755 static void save_RasterPos3iv(const GLint *v)
2756 {
2757 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2758 }
2759
2760 static void save_RasterPos3sv(const GLshort *v)
2761 {
2762 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2763 }
2764
2765 static void save_RasterPos4dv(const GLdouble *v)
2766 {
2767 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2768 }
2769
2770 static void save_RasterPos4fv(const GLfloat *v)
2771 {
2772 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2773 }
2774
2775 static void save_RasterPos4iv(const GLint *v)
2776 {
2777 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2778 }
2779
2780 static void save_RasterPos4sv(const GLshort *v)
2781 {
2782 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2783 }
2784
2785
2786 static void save_PassThrough( GLfloat token )
2787 {
2788 GET_CURRENT_CONTEXT(ctx);
2789 Node *n;
2790 FLUSH_VB(ctx, "dlist");
2791 n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 );
2792 if (n) {
2793 n[1].f = token;
2794 }
2795 if (ctx->ExecuteFlag) {
2796 (*ctx->Exec->PassThrough)( token );
2797 }
2798 }
2799
2800
2801 static void save_ReadBuffer( GLenum mode )
2802 {
2803 GET_CURRENT_CONTEXT(ctx);
2804 Node *n;
2805 FLUSH_VB(ctx, "dlist");
2806 n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 );
2807 if (n) {
2808 n[1].e = mode;
2809 }
2810 if (ctx->ExecuteFlag) {
2811 (*ctx->Exec->ReadBuffer)( mode );
2812 }
2813 }
2814
2815
2816 static void save_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
2817 {
2818 GET_CURRENT_CONTEXT(ctx);
2819 Node *n;
2820 FLUSH_VB(ctx, "dlist");
2821 n = alloc_instruction( ctx, OPCODE_RECTF, 4 );
2822 if (n) {
2823 n[1].f = x1;
2824 n[2].f = y1;
2825 n[3].f = x2;
2826 n[4].f = y2;
2827 }
2828 if (ctx->ExecuteFlag) {
2829 (*ctx->Exec->Rectf)( x1, y1, x2, y2 );
2830 }
2831 }
2832
2833 static void save_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
2834 {
2835 save_Rectf(x1, y1, x2, y2);
2836 }
2837
2838 static void save_Rectdv(const GLdouble *v1, const GLdouble *v2)
2839 {
2840 save_Rectf(v1[0], v1[1], v2[0], v2[1]);
2841 }
2842
2843 static void save_Rectfv( const GLfloat *v1, const GLfloat *v2 )
2844 {
2845 save_Rectf(v1[0], v1[1], v2[0], v2[1]);
2846 }
2847
2848 static void save_Recti(GLint x1, GLint y1, GLint x2, GLint y2)
2849 {
2850 save_Rectf(x1, y1, x2, y2);
2851 }
2852
2853 static void save_Rectiv(const GLint *v1, const GLint *v2)
2854 {
2855 save_Rectf(v1[0], v1[1], v2[0], v2[1]);
2856 }
2857
2858 static void save_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
2859 {
2860 save_Rectf(x1, y1, x2, y2);
2861 }
2862
2863 static void save_Rectsv(const GLshort *v1, const GLshort *v2)
2864 {
2865 save_Rectf(v1[0], v1[1], v2[0], v2[1]);
2866 }
2867
2868
2869 static void
2870 save_ResetHistogram(GLenum target)
2871 {
2872 GET_CURRENT_CONTEXT(ctx);
2873 Node *n;
2874 FLUSH_VB(ctx, "dlist");
2875 n = alloc_instruction( ctx, OPCODE_RESET_HISTOGRAM, 1 );
2876 if (n) {
2877 n[1].e = target;
2878 }
2879 if (ctx->ExecuteFlag) {
2880 (*ctx->Exec->ResetHistogram)( target );
2881 }
2882 }
2883
2884
2885 static void
2886 save_ResetMinmax(GLenum target)
2887 {
2888 GET_CURRENT_CONTEXT(ctx);
2889 Node *n;
2890 FLUSH_VB(ctx, "dlist");
2891 n = alloc_instruction( ctx, OPCODE_RESET_MIN_MAX, 1 );
2892 if (n) {
2893 n[1].e = target;
2894 }
2895 if (ctx->ExecuteFlag) {
2896 (*ctx->Exec->ResetMinmax)( target );
2897 }
2898 }
2899
2900
2901 static void save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
2902 {
2903 GLfloat m[16];
2904 gl_rotation_matrix( angle, x, y, z, m );
2905 save_MultMatrixf( m ); /* save and maybe execute */
2906 }
2907
2908
2909 static void save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
2910 {
2911 save_Rotatef(angle, x, y, z);
2912 }
2913
2914
2915 static void save_Scalef( GLfloat x, GLfloat y, GLfloat z )
2916 {
2917 GET_CURRENT_CONTEXT(ctx);
2918 Node *n;
2919 FLUSH_VB(ctx, "dlist");
2920 n = alloc_instruction( ctx, OPCODE_SCALE, 3 );
2921 if (n) {
2922 n[1].f = x;
2923 n[2].f = y;
2924 n[3].f = z;
2925 }
2926 if (ctx->ExecuteFlag) {
2927 (*ctx->Exec->Scalef)( x, y, z );
2928 }
2929 }
2930
2931
2932 static void save_Scaled( GLdouble x, GLdouble y, GLdouble z )
2933 {
2934 save_Scalef(x, y, z);
2935 }
2936
2937
2938 static void save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
2939 {
2940 GET_CURRENT_CONTEXT(ctx);
2941 Node *n;
2942 FLUSH_VB(ctx, "dlist");
2943 n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 );
2944 if (n) {
2945 n[1].i = x;
2946 n[2].i = y;
2947 n[3].i = width;
2948 n[4].i = height;
2949 }
2950 if (ctx->ExecuteFlag) {
2951 (*ctx->Exec->Scissor)( x, y, width, height );
2952 }
2953 }
2954
2955
2956 static void save_ShadeModel( GLenum mode )
2957 {
2958 GET_CURRENT_CONTEXT(ctx);
2959 Node *n;
2960 FLUSH_VB(ctx, "dlist");
2961 n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 );
2962 if (n) {
2963 n[1].e = mode;
2964 }
2965 if (ctx->ExecuteFlag) {
2966 (*ctx->Exec->ShadeModel)( mode );
2967 }
2968 }
2969
2970
2971 static void save_StencilFunc( GLenum func, GLint ref, GLuint mask )
2972 {
2973 GET_CURRENT_CONTEXT(ctx);
2974 Node *n;
2975 FLUSH_VB(ctx, "dlist");
2976 n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 );
2977 if (n) {
2978 n[1].e = func;
2979 n[2].i = ref;
2980 n[3].ui = mask;
2981 }
2982 if (ctx->ExecuteFlag) {
2983 (*ctx->Exec->StencilFunc)( func, ref, mask );
2984 }
2985 }
2986
2987
2988 static void save_StencilMask( GLuint mask )
2989 {
2990 GET_CURRENT_CONTEXT(ctx);
2991 Node *n;
2992 FLUSH_VB(ctx, "dlist");
2993 n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 );
2994 if (n) {
2995 n[1].ui = mask;
2996 }
2997 if (ctx->ExecuteFlag) {
2998 (*ctx->Exec->StencilMask)( mask );
2999 }
3000 }
3001
3002
3003 static void save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
3004 {
3005 GET_CURRENT_CONTEXT(ctx);
3006 Node *n;
3007 FLUSH_VB(ctx, "dlist");
3008 n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 );
3009 if (n) {
3010 n[1].e = fail;
3011 n[2].e = zfail;
3012 n[3].e = zpass;
3013 }
3014 if (ctx->ExecuteFlag) {
3015 (*ctx->Exec->StencilOp)( fail, zfail, zpass );
3016 }
3017 }
3018
3019
3020 static void save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
3021 {
3022 GET_CURRENT_CONTEXT(ctx);
3023 Node *n;
3024 FLUSH_VB(ctx, "dlist");
3025 n = alloc_instruction( ctx, OPCODE_TEXENV, 6 );
3026 if (n) {
3027 n[1].e = target;
3028 n[2].e = pname;
3029 n[3].f = params[0];
3030 n[4].f = params[1];
3031 n[5].f = params[2];
3032 n[6].f = params[3];
3033 }
3034 if (ctx->ExecuteFlag) {
3035 (*ctx->Exec->TexEnvfv)( target, pname, params );
3036 }
3037 }
3038
3039
3040 static void save_TexEnvf( GLenum target, GLenum pname, GLfloat param )
3041 {
3042 save_TexEnvfv( target, pname, &param );
3043 }
3044
3045
3046 static void save_TexEnvi( GLenum target, GLenum pname, GLint param )
3047 {
3048 GLfloat p[4];
3049 p[0] = (GLfloat) param;
3050 p[1] = p[2] = p[3] = 0.0;
3051 save_TexEnvfv( target, pname, p );
3052 }
3053
3054
3055 static void save_TexEnviv( GLenum target, GLenum pname, const GLint *param )
3056 {
3057 GLfloat p[4];
3058 p[0] = INT_TO_FLOAT( param[0] );
3059 p[1] = INT_TO_FLOAT( param[1] );
3060 p[2] = INT_TO_FLOAT( param[2] );
3061 p[3] = INT_TO_FLOAT( param[3] );
3062 save_TexEnvfv( target, pname, p );
3063 }
3064
3065
3066 static void save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
3067 {
3068 GET_CURRENT_CONTEXT(ctx);
3069 Node *n;
3070 FLUSH_VB(ctx, "dlist");
3071 n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 );
3072 if (n) {
3073 n[1].e = coord;
3074 n[2].e = pname;
3075 n[3].f = params[0];
3076 n[4].f = params[1];
3077 n[5].f = params[2];
3078 n[6].f = params[3];
3079 }
3080 if (ctx->ExecuteFlag) {
3081 (*ctx->Exec->TexGenfv)( coord, pname, params );
3082 }
3083 }
3084
3085
3086 static void save_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
3087 {
3088 GLfloat p[4];
3089 p[0] = params[0];
3090 p[1] = params[1];
3091 p[2] = params[2];
3092 p[3] = params[3];
3093 save_TexGenfv(coord, pname, p);
3094 }
3095
3096
3097 static void save_TexGend(GLenum coord, GLenum pname, GLdouble param )
3098 {
3099 GLfloat p = (GLfloat) param;
3100 save_TexGenfv( coord, pname, &p );
3101 }
3102
3103
3104 static void save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
3105 {
3106 GLfloat p[4];
3107 p[0] = params[0];
3108 p[1] = params[1];
3109 p[2] = params[2];
3110 p[3] = params[3];
3111 save_TexGenfv( coord, pname, p );
3112 }
3113
3114
3115 static void save_TexGenf( GLenum coord, GLenum pname, GLfloat param )
3116 {
3117 save_TexGenfv(coord, pname, &param);
3118 }
3119
3120
3121 static void save_TexGeni( GLenum coord, GLenum pname, GLint param )
3122 {
3123 save_TexGeniv( coord, pname, &param );
3124 }
3125
3126
3127 static void save_TexParameterfv( GLenum target,
3128 GLenum pname, const GLfloat *params )
3129 {
3130 GET_CURRENT_CONTEXT(ctx);
3131 Node *n;
3132 FLUSH_VB(ctx, "dlist");
3133 n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 );
3134 if (n) {
3135 n[1].e = target;
3136 n[2].e = pname;
3137 n[3].f = params[0];
3138 n[4].f = params[1];
3139 n[5].f = params[2];
3140 n[6].f = params[3];
3141 }
3142 if (ctx->ExecuteFlag) {
3143 (*ctx->Exec->TexParameterfv)( target, pname, params );
3144 }
3145 }
3146
3147
3148 static void save_TexParameterf( GLenum target, GLenum pname, GLfloat param )
3149 {
3150 save_TexParameterfv(target, pname, &param);
3151 }
3152
3153
3154 static void save_TexParameteri( GLenum target, GLenum pname, const GLint param )
3155 {
3156 GLfloat fparam[4];
3157 fparam[0] = (GLfloat) param;
3158 fparam[1] = fparam[2] = fparam[3] = 0.0;
3159 save_TexParameterfv(target, pname, fparam);
3160 }
3161
3162
3163 static void save_TexParameteriv( GLenum target, GLenum pname, const GLint *params )
3164 {
3165 GLfloat fparam[4];
3166 fparam[0] = (GLfloat) params[0];
3167 fparam[1] = fparam[2] = fparam[3] = 0.0;
3168 save_TexParameterfv(target, pname, fparam);
3169 }
3170
3171
3172 static void save_TexImage1D( GLenum target,
3173 GLint level, GLint components,
3174 GLsizei width, GLint border,
3175 GLenum format, GLenum type,
3176 const GLvoid *pixels )
3177 {
3178 GET_CURRENT_CONTEXT(ctx);
3179 if (target == GL_PROXY_TEXTURE_1D) {
3180 /* don't compile, execute immediately */
3181 (*ctx->Exec->TexImage1D)( target, level, components, width,
3182 border, format, type, pixels );
3183 }
3184 else {
3185 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
3186 pixels, &ctx->Unpack);
3187 Node *n;
3188 FLUSH_VB(ctx, "dlist");
3189 n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 );
3190 if (n) {
3191 n[1].e = target;
3192 n[2].i = level;
3193 n[3].i = components;
3194 n[4].i = (GLint) width;
3195 n[5].i = border;
3196 n[6].e = format;
3197 n[7].e = type;
3198 n[8].data = image;
3199 }
3200 else if (image) {
3201 FREE(image);
3202 }
3203 if (ctx->ExecuteFlag) {
3204 (*ctx->Exec->TexImage1D)( target, level, components, width,
3205 border, format, type, pixels );
3206 }
3207 }
3208 }
3209
3210
3211 static void save_TexImage2D( GLenum target,
3212 GLint level, GLint components,
3213 GLsizei width, GLsizei height, GLint border,
3214 GLenum format, GLenum type,
3215 const GLvoid *pixels)
3216 {
3217 GET_CURRENT_CONTEXT(ctx);
3218 if (target == GL_PROXY_TEXTURE_2D) {
3219 /* don't compile, execute immediately */
3220 (*ctx->Exec->TexImage2D)( target, level, components, width,
3221 height, border, format, type, pixels );
3222 }
3223 else {
3224 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
3225 pixels, &ctx->Unpack);
3226 Node *n;
3227 FLUSH_VB(ctx, "dlist");
3228 n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 );
3229 if (n) {
3230 n[1].e = target;
3231 n[2].i = level;
3232 n[3].i = components;
3233 n[4].i = (GLint) width;
3234 n[5].i = (GLint) height;
3235 n[6].i = border;
3236 n[7].e = format;
3237 n[8].e = type;
3238 n[9].data = image;
3239 }
3240 else if (image) {
3241 FREE(image);
3242 }
3243 if (ctx->ExecuteFlag) {
3244 (*ctx->Exec->TexImage2D)( target, level, components, width,
3245 height, border, format, type, pixels );
3246 }
3247 }
3248 }
3249
3250
3251 static void save_TexImage3D( GLenum target,
3252 GLint level, GLint internalFormat,
3253 GLsizei width, GLsizei height, GLsizei depth,
3254 GLint border,
3255 GLenum format, GLenum type,
3256 const GLvoid *pixels )
3257 {
3258 GET_CURRENT_CONTEXT(ctx);
3259 if (target == GL_PROXY_TEXTURE_3D) {
3260 /* don't compile, execute immediately */
3261 (*ctx->Exec->TexImage3D)( target, level, internalFormat, width,
3262 height, depth, border, format, type, pixels );
3263 }
3264 else {
3265 Node *n;
3266 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
3267 pixels, &ctx->Unpack);
3268 FLUSH_VB(ctx, "dlist");
3269 n = alloc_instruction( ctx, OPCODE_TEX_IMAGE3D, 10 );
3270 if (n) {
3271 n[1].e = target;
3272 n[2].i = level;
3273 n[3].i = internalFormat;
3274 n[4].i = (GLint) width;
3275 n[5].i = (GLint) height;
3276 n[6].i = (GLint) depth;
3277 n[7].i = border;
3278 n[8].e = format;
3279 n[9].e = type;
3280 n[10].data = image;
3281 }
3282 else if (image) {
3283 FREE(image);
3284 }
3285 if (ctx->ExecuteFlag) {
3286 (*ctx->Exec->TexImage3D)( target, level, internalFormat, width,
3287 height, depth, border, format, type, pixels );
3288 }
3289 }
3290 }
3291
3292
3293 static void save_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
3294 GLsizei width, GLenum format, GLenum type,
3295 const GLvoid *pixels )
3296 {
3297 GET_CURRENT_CONTEXT(ctx);
3298 Node *n;
3299 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
3300 pixels, &ctx->Unpack);
3301 FLUSH_VB(ctx, "dlist");
3302 n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
3303 if (n) {
3304 n[1].e = target;
3305 n[2].i = level;
3306 n[3].i = xoffset;
3307 n[4].i = (GLint) width;
3308 n[5].e = format;
3309 n[6].e = type;
3310 n[7].data = image;
3311 }
3312 else if (image) {
3313 FREE(image);
3314 }
3315 if (ctx->ExecuteFlag) {
3316 (*ctx->Exec->TexSubImage1D)( target, level, xoffset, width,
3317 format, type, pixels );
3318 }
3319 }
3320
3321
3322 static void save_TexSubImage2D( GLenum target, GLint level,
3323 GLint xoffset, GLint yoffset,
3324 GLsizei width, GLsizei height,
3325 GLenum format, GLenum type,
3326 const GLvoid *pixels )
3327 {
3328 GET_CURRENT_CONTEXT(ctx);
3329 Node *n;
3330 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
3331 pixels, &ctx->Unpack);
3332 FLUSH_VB(ctx, "dlist");
3333 n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
3334 if (n) {
3335 n[1].e = target;
3336 n[2].i = level;
3337 n[3].i = xoffset;
3338 n[4].i = yoffset;
3339 n[5].i = (GLint) width;
3340 n[6].i = (GLint) height;
3341 n[7].e = format;
3342 n[8].e = type;
3343 n[9].data = image;
3344 }
3345 else if (image) {
3346 FREE(image);
3347 }
3348 if (ctx->ExecuteFlag) {
3349 (*ctx->Exec->TexSubImage2D)( target, level, xoffset, yoffset,
3350 width, height, format, type, pixels );
3351 }
3352 }
3353
3354
3355 static void save_TexSubImage3D( GLenum target, GLint level,
3356 GLint xoffset, GLint yoffset,GLint zoffset,
3357 GLsizei width, GLsizei height, GLsizei depth,
3358 GLenum format, GLenum type,
3359 const GLvoid *pixels )
3360 {
3361 GET_CURRENT_CONTEXT(ctx);
3362 Node *n;
3363 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
3364 pixels, &ctx->Unpack);
3365 FLUSH_VB(ctx, "dlist");
3366 n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
3367 if (n) {
3368 n[1].e = target;
3369 n[2].i = level;
3370 n[3].i = xoffset;
3371 n[4].i = yoffset;
3372 n[5].i = zoffset;
3373 n[6].i = (GLint) width;
3374 n[7].i = (GLint) height;
3375 n[8].i = (GLint) depth;
3376 n[9].e = format;
3377 n[10].e = type;
3378 n[11].data = image;
3379 }
3380 else if (image) {
3381 FREE(image);
3382 }
3383 if (ctx->ExecuteFlag) {
3384 (*ctx->Exec->TexSubImage3D)( target, level,
3385 xoffset, yoffset, zoffset,
3386 width, height, depth, format, type, pixels );
3387 }
3388 }
3389
3390
3391 static void save_Translatef( GLfloat x, GLfloat y, GLfloat z )
3392 {
3393 GET_CURRENT_CONTEXT(ctx);
3394 Node *n;
3395 FLUSH_VB(ctx, "dlist");
3396 n = alloc_instruction( ctx, OPCODE_TRANSLATE, 3 );
3397 if (n) {
3398 n[1].f = x;
3399 n[2].f = y;
3400 n[3].f = z;
3401 }
3402 if (ctx->ExecuteFlag) {
3403 (*ctx->Exec->Translatef)( x, y, z );
3404 }
3405 }
3406
3407
3408 static void save_Translated( GLdouble x, GLdouble y, GLdouble z )
3409 {
3410 save_Translatef(x, y, z);
3411 }
3412
3413
3414
3415 static void save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
3416 {
3417 GET_CURRENT_CONTEXT(ctx);
3418 Node *n;
3419 FLUSH_VB(ctx, "dlist");
3420 n = alloc_instruction( ctx, OPCODE_VIEWPORT, 4 );
3421 if (n) {
3422 n[1].i = x;
3423 n[2].i = y;
3424 n[3].i = (GLint) width;
3425 n[4].i = (GLint) height;
3426 }
3427 if (ctx->ExecuteFlag) {
3428 (*ctx->Exec->Viewport)( x, y, width, height );
3429 }
3430 }
3431
3432
3433 static void save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
3434 {
3435 GET_CURRENT_CONTEXT(ctx);
3436 Node *n;
3437 FLUSH_VB(ctx, "dlist");
3438 n = alloc_instruction( ctx, OPCODE_WINDOW_POS, 4 );
3439 if (n) {
3440 n[1].f = x;
3441 n[2].f = y;
3442 n[3].f = z;
3443 n[4].f = w;
3444 }
3445 if (ctx->ExecuteFlag) {
3446 (*ctx->Exec->WindowPos4fMESA)( x, y, z, w );
3447 }
3448 }
3449
3450 static void save_WindowPos2dMESA(GLdouble x, GLdouble y)
3451 {
3452 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3453 }
3454
3455 static void save_WindowPos2fMESA(GLfloat x, GLfloat y)
3456 {
3457 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3458 }
3459
3460 static void save_WindowPos2iMESA(GLint x, GLint y)
3461 {
3462 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3463 }
3464
3465 static void save_WindowPos2sMESA(GLshort x, GLshort y)
3466 {
3467 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3468 }
3469
3470 static void save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
3471 {
3472 save_WindowPos4fMESA(x, y, z, 1.0F);
3473 }
3474
3475 static void save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
3476 {
3477 save_WindowPos4fMESA(x, y, z, 1.0F);
3478 }
3479
3480 static void save_WindowPos3iMESA(GLint x, GLint y, GLint z)
3481 {
3482 save_WindowPos4fMESA(x, y, z, 1.0F);
3483 }
3484
3485 static void save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
3486 {
3487 save_WindowPos4fMESA(x, y, z, 1.0F);
3488 }
3489
3490 static void save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3491 {
3492 save_WindowPos4fMESA(x, y, z, w);
3493 }
3494
3495 static void save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
3496 {
3497 save_WindowPos4fMESA(x, y, z, w);
3498 }
3499
3500 static void save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
3501 {
3502 save_WindowPos4fMESA(x, y, z, w);
3503 }
3504
3505 static void save_WindowPos2dvMESA(const GLdouble *v)
3506 {
3507 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3508 }
3509
3510 static void save_WindowPos2fvMESA(const GLfloat *v)
3511 {
3512 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3513 }
3514
3515 static void save_WindowPos2ivMESA(const GLint *v)
3516 {
3517 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3518 }
3519
3520 static void save_WindowPos2svMESA(const GLshort *v)
3521 {
3522 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3523 }
3524
3525 static void save_WindowPos3dvMESA(const GLdouble *v)
3526 {
3527 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3528 }
3529
3530 static void save_WindowPos3fvMESA(const GLfloat *v)
3531 {
3532 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3533 }
3534
3535 static void save_WindowPos3ivMESA(const GLint *v)
3536 {
3537 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3538 }
3539
3540 static void save_WindowPos3svMESA(const GLshort *v)
3541 {
3542 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3543 }
3544
3545 static void save_WindowPos4dvMESA(const GLdouble *v)
3546 {
3547 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3548 }
3549
3550 static void save_WindowPos4fvMESA(const GLfloat *v)
3551 {
3552 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3553 }
3554
3555 static void save_WindowPos4ivMESA(const GLint *v)
3556 {
3557 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3558 }
3559
3560 static void save_WindowPos4svMESA(const GLshort *v)
3561 {
3562 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3563 }
3564
3565
3566
3567 /* GL_ARB_multitexture */
3568 static void save_ActiveTextureARB( GLenum target )
3569 {
3570 GET_CURRENT_CONTEXT(ctx);
3571 Node *n;
3572 FLUSH_VB(ctx, "dlist");
3573 n = alloc_instruction( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
3574 if (n) {
3575 n[1].e = target;
3576 }
3577 if (ctx->ExecuteFlag) {
3578 (*ctx->Exec->ActiveTextureARB)( target );
3579 }
3580 }
3581
3582
3583 /* GL_ARB_multitexture */
3584 static void save_ClientActiveTextureARB( GLenum target )
3585 {
3586 GET_CURRENT_CONTEXT(ctx);
3587 Node *n;
3588 FLUSH_VB(ctx, "dlist");
3589 n = alloc_instruction( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 );
3590 if (n) {
3591 n[1].e = target;
3592 }
3593 if (ctx->ExecuteFlag) {
3594 (*ctx->Exec->ClientActiveTextureARB)( target );
3595 }
3596 }
3597
3598
3599
3600 /* GL_ARB_transpose_matrix */
3601
3602 static void save_LoadTransposeMatrixdARB( const GLdouble m[16] )
3603 {
3604 GLdouble tm[16];
3605 gl_matrix_transposed(tm, m);
3606 save_LoadMatrixd(tm);
3607 }
3608
3609
3610 static void save_LoadTransposeMatrixfARB( const GLfloat m[16] )
3611 {
3612 GLfloat tm[16];
3613 gl_matrix_transposef(tm, m);
3614 save_LoadMatrixf(tm);
3615 }
3616
3617
3618 static void save_MultTransposeMatrixdARB( const GLdouble m[16] )
3619 {
3620 GLdouble tm[16];
3621 gl_matrix_transposed(tm, m);
3622 save_MultMatrixd(tm);
3623 }
3624
3625
3626 static void save_MultTransposeMatrixfARB( const GLfloat m[16] )
3627 {
3628 GLfloat tm[16];
3629 gl_matrix_transposef(tm, m);
3630 save_MultMatrixf(tm);
3631 }
3632
3633
3634 static void save_PixelTexGenSGIX(GLenum mode)
3635 {
3636 GET_CURRENT_CONTEXT(ctx);
3637 Node *n;
3638 FLUSH_VB(ctx, "dlist");
3639 n = alloc_instruction( ctx, OPCODE_PIXEL_TEXGEN_SGIX, 1 );
3640 if (n) {
3641 n[1].e = mode;
3642 }
3643 if (ctx->ExecuteFlag) {
3644 (*ctx->Exec->PixelTexGenSGIX)( mode );
3645 }
3646 }
3647
3648
3649 /* GL_ARB_texture_compression */
3650 static void
3651 save_CompressedTexImage1DARB(GLenum target, GLint level,
3652 GLenum internalFormat, GLsizei width,
3653 GLint border, GLsizei imageSize,
3654 const GLvoid *data)
3655 {
3656 GET_CURRENT_CONTEXT(ctx);
3657 if (target == GL_PROXY_TEXTURE_1D) {
3658 /* don't compile, execute immediately */
3659 (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat,
3660 width, border, imageSize, data);
3661 }
3662 else {
3663 Node *n;
3664 GLvoid *image;
3665 FLUSH_VB(ctx, "dlist");
3666 /* make copy of image */
3667 image = MALLOC(imageSize);
3668 if (!image) {
3669 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
3670 return;
3671 }
3672 MEMCPY(image, data, imageSize);
3673 n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 8 );
3674 if (n) {
3675 n[1].e = target;
3676 n[2].i = level;
3677 n[3].e = internalFormat;
3678 n[4].i = (GLint) width;
3679 n[5].i = border;
3680 n[6].i = imageSize;
3681 n[7].data = image;
3682 }
3683 else if (image) {
3684 FREE(image);
3685 }
3686 if (ctx->ExecuteFlag) {
3687 (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat,
3688 width, border, imageSize, data);
3689 }
3690 }
3691 }
3692
3693
3694 static void
3695 save_CompressedTexImage2DARB(GLenum target, GLint level,
3696 GLenum internalFormat, GLsizei width,
3697 GLsizei height, GLint border, GLsizei imageSize,
3698 const GLvoid *data)
3699 {
3700 GET_CURRENT_CONTEXT(ctx);
3701 if (target == GL_PROXY_TEXTURE_2D) {
3702 /* don't compile, execute immediately */
3703 (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat,
3704 width, height, border, imageSize, data);
3705 }
3706 else {
3707 Node *n;
3708 GLvoid *image;
3709 FLUSH_VB(ctx, "dlist");
3710 /* make copy of image */
3711 image = MALLOC(imageSize);
3712 if (!image) {
3713 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
3714 return;
3715 }
3716 MEMCPY(image, data, imageSize);
3717 n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 9 );
3718 if (n) {
3719 n[1].e = target;
3720 n[2].i = level;
3721 n[3].e = internalFormat;
3722 n[4].i = (GLint) width;
3723 n[5].i = (GLint) height;
3724 n[6].i = border;
3725 n[7].i = imageSize;
3726 n[8].data = image;
3727 }
3728 else if (image) {
3729 FREE(image);
3730 }
3731 if (ctx->ExecuteFlag) {
3732 (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat,
3733 width, height, border, imageSize, data);
3734 }
3735 }
3736 }
3737
3738
3739 static void
3740 save_CompressedTexImage3DARB(GLenum target, GLint level,
3741 GLenum internalFormat, GLsizei width,
3742 GLsizei height, GLsizei depth, GLint border,
3743 GLsizei imageSize, const GLvoid *data)
3744 {
3745 GET_CURRENT_CONTEXT(ctx);
3746 if (target == GL_PROXY_TEXTURE_3D) {
3747 /* don't compile, execute immediately */
3748 (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat,
3749 width, height, depth, border, imageSize, data);
3750 }
3751 else {
3752 Node *n;
3753 GLvoid *image;
3754 FLUSH_VB(ctx, "dlist");
3755 /* make copy of image */
3756 image = MALLOC(imageSize);
3757 if (!image) {
3758 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
3759 return;
3760 }
3761 MEMCPY(image, data, imageSize);
3762 n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 10 );
3763 if (n) {
3764 n[1].e = target;
3765 n[2].i = level;
3766 n[3].e = internalFormat;
3767 n[4].i = (GLint) width;
3768 n[5].i = (GLint) height;
3769 n[6].i = (GLint) depth;
3770 n[7].i = border;
3771 n[8].i = imageSize;
3772 n[9].data = image;
3773 }
3774 else if (image) {
3775 FREE(image);
3776 }
3777 if (ctx->ExecuteFlag) {
3778 (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat,
3779 width, height, depth, border, imageSize, data);
3780 }
3781 }
3782 }
3783
3784
3785 static void
3786 save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
3787 GLsizei width, GLenum format,
3788 GLsizei imageSize, const GLvoid *data)
3789 {
3790 Node *n;
3791 GLvoid *image;
3792
3793 GET_CURRENT_CONTEXT(ctx);
3794 FLUSH_VB(ctx, "dlist");
3795
3796 /* make copy of image */
3797 image = MALLOC(imageSize);
3798 if (!image) {
3799 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
3800 return;
3801 }
3802 MEMCPY(image, data, imageSize);
3803 n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 8 );
3804 if (n) {
3805 n[1].e = target;
3806 n[2].i = level;
3807 n[3].i = xoffset;
3808 n[4].i = (GLint) width;
3809 n[5].e = format;
3810 n[6].i = imageSize;
3811 n[7].data = image;
3812 }
3813 else if (image) {
3814 FREE(image);
3815 }
3816 if (ctx->ExecuteFlag) {
3817 (*ctx->Exec->CompressedTexSubImage1DARB)(target, level, xoffset,
3818 width, format, imageSize, data);
3819 }
3820 }
3821
3822
3823 static void
3824 save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
3825 GLint yoffset, GLsizei width, GLsizei height,
3826 GLenum format, GLsizei imageSize,
3827 const GLvoid *data)
3828 {
3829 Node *n;
3830 GLvoid *image;
3831
3832 GET_CURRENT_CONTEXT(ctx);
3833 FLUSH_VB(ctx, "dlist");
3834
3835 /* make copy of image */
3836 image = MALLOC(imageSize);
3837 if (!image) {
3838 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
3839 return;
3840 }
3841 MEMCPY(image, data, imageSize);
3842 n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 10 );
3843 if (n) {
3844 n[1].e = target;
3845 n[2].i = level;
3846 n[3].i = xoffset;
3847 n[4].i = yoffset;
3848 n[5].i = (GLint) width;
3849 n[6].i = (GLint) height;
3850 n[7].e = format;
3851 n[8].i = imageSize;
3852 n[9].data = image;
3853 }
3854 else if (image) {
3855 FREE(image);
3856 }
3857 if (ctx->ExecuteFlag) {
3858 (*ctx->Exec->CompressedTexSubImage2DARB)(target, level, xoffset, yoffset,
3859 width, height, format, imageSize, data);
3860 }
3861 }
3862
3863
3864 static void
3865 save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
3866 GLint yoffset, GLint zoffset, GLsizei width,
3867 GLsizei height, GLsizei depth, GLenum format,
3868 GLsizei imageSize, const GLvoid *data)
3869 {
3870 Node *n;
3871 GLvoid *image;
3872
3873 GET_CURRENT_CONTEXT(ctx);
3874 FLUSH_VB(ctx, "dlist");
3875
3876 /* make copy of image */
3877 image = MALLOC(imageSize);
3878 if (!image) {
3879 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
3880 return;
3881 }
3882 MEMCPY(image, data, imageSize);
3883 n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 12 );
3884 if (n) {
3885 n[1].e = target;
3886 n[2].i = level;
3887 n[3].i = xoffset;
3888 n[4].i = yoffset;
3889 n[5].i = zoffset;
3890 n[6].i = (GLint) width;
3891 n[7].i = (GLint) height;
3892 n[8].i = (GLint) depth;
3893 n[9].e = format;
3894 n[10].i = imageSize;
3895 n[11].data = image;
3896 }
3897 else if (image) {
3898 FREE(image);
3899 }
3900 if (ctx->ExecuteFlag) {
3901 (*ctx->Exec->CompressedTexSubImage3DARB)(target, level, xoffset, yoffset,
3902 zoffset, width, height, depth, format, imageSize, data);
3903 }
3904 }
3905
3906
3907 /* GL_SGIS_pixel_texture */
3908
3909 static void save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
3910 {
3911 GET_CURRENT_CONTEXT(ctx);
3912 Node *n;
3913 FLUSH_VB(ctx, "dlist");
3914 n = alloc_instruction( ctx, OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, 2 );
3915 if (n) {
3916 n[1].e = target;
3917 n[2].i = value;
3918 }
3919 if (ctx->ExecuteFlag) {
3920 (*ctx->Exec->PixelTexGenParameteriSGIS)( target, value );
3921 }
3922 }
3923
3924
3925 static void save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
3926 {
3927 save_PixelTexGenParameteriSGIS(target, (GLint) value);
3928 }
3929
3930
3931 static void save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
3932 {
3933 save_PixelTexGenParameteriSGIS(target, *value);
3934 }
3935
3936
3937 static void save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
3938 {
3939 save_PixelTexGenParameteriSGIS(target, (GLint) *value);
3940 }
3941
3942 void gl_compile_cassette( GLcontext *ctx )
3943 {
3944 Node *n = alloc_instruction( ctx, OPCODE_VERTEX_CASSETTE, 8 );
3945 struct immediate *im = ctx->input;
3946
3947 if (!n)
3948 return;
3949
3950
3951 /* Do some easy optimizations of the cassette.
3952 */
3953 #if 0
3954 if (0 && im->v.Obj.size < 4 && im->Count > 15) {
3955 im->Bounds = (GLfloat (*)[3]) MALLOC(6 * sizeof(GLfloat));
3956 (gl_calc_bound_tab[im->v.Obj.size])( im->Bounds, &im->v.Obj );
3957 }
3958 #endif
3959
3960 n[1].data = (void *)im;
3961 n[2].ui = im->Start;
3962 n[3].ui = im->Count;
3963 n[4].ui = im->BeginState;
3964 n[5].ui = im->OrFlag;
3965 n[6].ui = im->AndFlag;
3966 n[7].ui = im->LastData;
3967 n[8].ui = im->LastPrimitive;
3968
3969 if (im->Count > VB_MAX - 4) {
3970
3971 struct immediate *new_im = gl_immediate_alloc(ctx);
3972 if (!new_im) return;
3973 SET_IMMEDIATE( ctx, new_im );
3974 gl_reset_input( ctx );
3975
3976 } else {
3977 im->Count++;;
3978 im->Start = im->Count; /* don't clear anything in reset_input */
3979 im->ref_count++;
3980
3981 im->Primitive[im->Start] = ctx->Current.Primitive;
3982 im->LastPrimitive = im->Start;
3983 im->BeginState = VERT_BEGIN_0;
3984 im->OrFlag = 0;
3985 im->AndFlag = ~0;
3986
3987 if (0)
3988 fprintf(stderr, "in compile_cassette, BeginState is %x\n",
3989 im->BeginState);
3990 }
3991 }
3992
3993 /* KW: Compile commands
3994 *
3995 * Will appear in the list before the vertex buffer containing the
3996 * command that provoked the error. I don't see this as a problem.
3997 */
3998 void gl_save_error( GLcontext *ctx, GLenum error, const char *s )
3999 {
4000 Node *n;
4001 n = alloc_instruction( ctx, OPCODE_ERROR, 2 );
4002 if (n) {
4003 n[1].e = error;
4004 n[2].data = (void *) s;
4005 }
4006 /* execute already done */
4007 }
4008
4009
4010 static GLboolean
4011 islist(GLcontext *ctx, GLuint list)
4012 {
4013 if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
4014 return GL_TRUE;
4015 }
4016 else {
4017 return GL_FALSE;
4018 }
4019 }
4020
4021
4022
4023 /**********************************************************************/
4024 /* Display list execution */
4025 /**********************************************************************/
4026
4027
4028 /*
4029 * Execute a display list. Note that the ListBase offset must have already
4030 * been added before calling this function. I.e. the list argument is
4031 * the absolute list number, not relative to ListBase.
4032 * Input: list - display list number
4033 */
4034 static void execute_list( GLcontext *ctx, GLuint list )
4035 {
4036 Node *n;
4037 GLboolean done;
4038 OpCode opcode;
4039
4040 if (!islist(ctx,list))
4041 return;
4042
4043 /* mesa_print_display_list( list ); */
4044
4045 ctx->CallDepth++;
4046
4047 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
4048
4049 done = GL_FALSE;
4050 while (!done) {
4051 opcode = n[0].opcode;
4052
4053 switch (opcode) {
4054 case OPCODE_ERROR:
4055 gl_error( ctx, n[1].e, (const char *) n[2].data );
4056 break;
4057 case OPCODE_VERTEX_CASSETTE: {
4058 struct immediate *IM;
4059
4060 if (ctx->NewState)
4061 gl_update_state(ctx);
4062 if (ctx->CompileCVAFlag) {
4063 ctx->CompileCVAFlag = 0;
4064 ctx->CVA.elt.pipeline_valid = 0;
4065 }
4066 if (!ctx->CVA.elt.pipeline_valid)
4067 gl_build_immediate_pipeline( ctx );
4068
4069
4070 IM = (struct immediate *) n[1].data;
4071 IM->Start = n[2].ui;
4072 IM->Count = n[3].ui;
4073 IM->BeginState = n[4].ui;
4074 IM->OrFlag = n[5].ui;
4075 IM->AndFlag = n[6].ui;
4076 IM->LastData = n[7].ui;
4077 IM->LastPrimitive = n[8].ui;
4078
4079 if ((MESA_VERBOSE & VERBOSE_DISPLAY_LIST) &&
4080 (MESA_VERBOSE & VERBOSE_IMMEDIATE))
4081 gl_print_cassette( (struct immediate *) n[1].data );
4082
4083 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) {
4084 fprintf(stderr, "Run cassette %d, rows %d..%d, beginstate %x ",
4085 IM->id,
4086 IM->Start, IM->Count, IM->BeginState);
4087 gl_print_vert_flags("orflag", IM->OrFlag);
4088 }
4089
4090 gl_fixup_cassette( ctx, (struct immediate *) n[1].data );
4091 gl_execute_cassette( ctx, (struct immediate *) n[1].data );
4092 break;
4093 }
4094 case OPCODE_ACCUM:
4095 (*ctx->Exec->Accum)( n[1].e, n[2].f );
4096 break;
4097 case OPCODE_ALPHA_FUNC:
4098 (*ctx->Exec->AlphaFunc)( n[1].e, n[2].f );
4099 break;
4100 case OPCODE_BIND_TEXTURE:
4101 (*ctx->Exec->BindTexture)( n[1].e, n[2].ui );
4102 break;
4103 case OPCODE_BITMAP:
4104 {
4105 struct gl_pixelstore_attrib save = ctx->Unpack;
4106 ctx->Unpack = _mesa_native_packing;
4107 (*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
4108 n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
4109 ctx->Unpack = save; /* restore */
4110 }
4111 break;
4112 case OPCODE_BLEND_COLOR:
4113 (*ctx->Exec->BlendColor)( n[1].f, n[2].f, n[3].f, n[4].f );
4114 break;
4115 case OPCODE_BLEND_EQUATION:
4116 (*ctx->Exec->BlendEquation)( n[1].e );
4117 break;
4118 case OPCODE_BLEND_FUNC:
4119 (*ctx->Exec->BlendFunc)( n[1].e, n[2].e );
4120 break;
4121 case OPCODE_BLEND_FUNC_SEPARATE:
4122 (*ctx->Exec->BlendFuncSeparateEXT)(n[1].e, n[2].e, n[3].e, n[4].e);
4123 break;
4124 case OPCODE_CALL_LIST:
4125 /* Generated by glCallList(), don't add ListBase */
4126 if (ctx->CallDepth<MAX_LIST_NESTING) {
4127 execute_list( ctx, n[1].ui );
4128 }
4129 break;
4130 case OPCODE_CALL_LIST_OFFSET:
4131 /* Generated by glCallLists() so we must add ListBase */
4132 if (ctx->CallDepth<MAX_LIST_NESTING) {
4133 execute_list( ctx, ctx->List.ListBase + n[1].ui );
4134 }
4135 break;
4136 case OPCODE_CLEAR:
4137 (*ctx->Exec->Clear)( n[1].bf );
4138 break;
4139 case OPCODE_CLEAR_COLOR:
4140 (*ctx->Exec->ClearColor)( n[1].f, n[2].f, n[3].f, n[4].f );
4141 break;
4142 case OPCODE_CLEAR_ACCUM:
4143 (*ctx->Exec->ClearAccum)( n[1].f, n[2].f, n[3].f, n[4].f );
4144 break;
4145 case OPCODE_CLEAR_DEPTH:
4146 (*ctx->Exec->ClearDepth)( (GLclampd) n[1].f );
4147 break;
4148 case OPCODE_CLEAR_INDEX:
4149 (*ctx->Exec->ClearIndex)( n[1].ui );
4150 break;
4151 case OPCODE_CLEAR_STENCIL:
4152 (*ctx->Exec->ClearStencil)( n[1].i );
4153 break;
4154 case OPCODE_CLIP_PLANE:
4155 {
4156 GLdouble eq[4];
4157 eq[0] = n[2].f;
4158 eq[1] = n[3].f;
4159 eq[2] = n[4].f;
4160 eq[3] = n[5].f;
4161 (*ctx->Exec->ClipPlane)( n[1].e, eq );
4162 }
4163 break;
4164 case OPCODE_COLOR_MASK:
4165 (*ctx->Exec->ColorMask)( n[1].b, n[2].b, n[3].b, n[4].b );
4166 break;
4167 case OPCODE_COLOR_MATERIAL:
4168 (*ctx->Exec->ColorMaterial)( n[1].e, n[2].e );
4169 break;
4170 case OPCODE_COLOR_TABLE:
4171 {
4172 struct gl_pixelstore_attrib save = ctx->Unpack;
4173 ctx->Unpack = _mesa_native_packing;
4174 (*ctx->Exec->ColorTable)( n[1].e, n[2].e, n[3].i, n[4].e,
4175 n[5].e, n[6].data );
4176 ctx->Unpack = save; /* restore */
4177 }
4178 break;
4179 case OPCODE_COLOR_TABLE_PARAMETER_FV:
4180 {
4181 GLfloat params[4];
4182 params[0] = n[3].f;
4183 params[1] = n[4].f;
4184 params[2] = n[5].f;
4185 params[3] = n[6].f;
4186 (*ctx->Exec->ColorTableParameterfv)( n[1].e, n[2].e, params );
4187 }
4188 break;
4189 case OPCODE_COLOR_TABLE_PARAMETER_IV:
4190 {
4191 GLint params[4];
4192 params[0] = n[3].i;
4193 params[1] = n[4].i;
4194 params[2] = n[5].i;
4195 params[3] = n[6].i;
4196 (*ctx->Exec->ColorTableParameteriv)( n[1].e, n[2].e, params );
4197 }
4198 break;
4199 case OPCODE_COLOR_SUB_TABLE:
4200 {
4201 struct gl_pixelstore_attrib save = ctx->Unpack;
4202 ctx->Unpack = _mesa_native_packing;
4203 (*ctx->Exec->ColorSubTable)( n[1].e, n[2].i, n[3].i,
4204 n[4].e, n[5].e, n[6].data );
4205 ctx->Unpack = save; /* restore */
4206 }
4207 break;
4208 case OPCODE_CONVOLUTION_FILTER_1D:
4209 {
4210 struct gl_pixelstore_attrib save = ctx->Unpack;
4211 ctx->Unpack = _mesa_native_packing;
4212 (*ctx->Exec->ConvolutionFilter1D)( n[1].e, n[2].i, n[3].i,
4213 n[4].e, n[5].e, n[6].data );
4214 ctx->Unpack = save; /* restore */
4215 }
4216 break;
4217 case OPCODE_CONVOLUTION_FILTER_2D:
4218 {
4219 struct gl_pixelstore_attrib save = ctx->Unpack;
4220 ctx->Unpack = _mesa_native_packing;
4221 (*ctx->Exec->ConvolutionFilter2D)( n[1].e, n[2].i, n[3].i,
4222 n[4].i, n[5].e, n[6].e, n[7].data );
4223 ctx->Unpack = save; /* restore */
4224 }
4225 break;
4226 case OPCODE_CONVOLUTION_PARAMETER_I:
4227 (*ctx->Exec->ConvolutionParameteri)( n[1].e, n[2].e, n[3].i );
4228 break;
4229 case OPCODE_CONVOLUTION_PARAMETER_IV:
4230 {
4231 GLint params[4];
4232 params[0] = n[3].i;
4233 params[1] = n[4].i;
4234 params[2] = n[5].i;
4235 params[3] = n[6].i;
4236 (*ctx->Exec->ConvolutionParameteriv)( n[1].e, n[2].e, params );
4237 }
4238 break;
4239 case OPCODE_CONVOLUTION_PARAMETER_F:
4240 (*ctx->Exec->ConvolutionParameterf)( n[1].e, n[2].e, n[3].f );
4241 break;
4242 case OPCODE_CONVOLUTION_PARAMETER_FV:
4243 {
4244 GLfloat params[4];
4245 params[0] = n[3].f;
4246 params[1] = n[4].f;
4247 params[2] = n[5].f;
4248 params[3] = n[6].f;
4249 (*ctx->Exec->ConvolutionParameterfv)( n[1].e, n[2].e, params );
4250 }
4251 break;
4252 case OPCODE_COPY_COLOR_SUB_TABLE:
4253 (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i,
4254 n[3].i, n[4].i, n[5].i );
4255 break;
4256 case OPCODE_COPY_COLOR_TABLE:
4257 (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i,
4258 n[3].i, n[4].i, n[5].i );
4259 break;
4260 case OPCODE_COPY_PIXELS:
4261 (*ctx->Exec->CopyPixels)( n[1].i, n[2].i,
4262 (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
4263 break;
4264 case OPCODE_COPY_TEX_IMAGE1D:
4265 (*ctx->Exec->CopyTexImage1D)( n[1].e, n[2].i, n[3].e, n[4].i,
4266 n[5].i, n[6].i, n[7].i );
4267 break;
4268 case OPCODE_COPY_TEX_IMAGE2D:
4269 (*ctx->Exec->CopyTexImage2D)( n[1].e, n[2].i, n[3].e, n[4].i,
4270 n[5].i, n[6].i, n[7].i, n[8].i );
4271 break;
4272 case OPCODE_COPY_TEX_SUB_IMAGE1D:
4273 (*ctx->Exec->CopyTexSubImage1D)( n[1].e, n[2].i, n[3].i,
4274 n[4].i, n[5].i, n[6].i );
4275 break;
4276 case OPCODE_COPY_TEX_SUB_IMAGE2D:
4277 (*ctx->Exec->CopyTexSubImage2D)( n[1].e, n[2].i, n[3].i,
4278 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i );
4279 break;
4280 case OPCODE_COPY_TEX_SUB_IMAGE3D:
4281 (*ctx->Exec->CopyTexSubImage3D)( n[1].e, n[2].i, n[3].i,
4282 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i , n[9].i);
4283 break;
4284 case OPCODE_CULL_FACE:
4285 (*ctx->Exec->CullFace)( n[1].e );
4286 break;
4287 case OPCODE_DEPTH_FUNC:
4288 (*ctx->Exec->DepthFunc)( n[1].e );
4289 break;
4290 case OPCODE_DEPTH_MASK:
4291 (*ctx->Exec->DepthMask)( n[1].b );
4292 break;
4293 case OPCODE_DEPTH_RANGE:
4294 (*ctx->Exec->DepthRange)( (GLclampd) n[1].f, (GLclampd) n[2].f );
4295 break;
4296 case OPCODE_DISABLE:
4297 (*ctx->Exec->Disable)( n[1].e );
4298 break;
4299 case OPCODE_DRAW_BUFFER:
4300 (*ctx->Exec->DrawBuffer)( n[1].e );
4301 break;
4302 case OPCODE_DRAW_PIXELS:
4303 {
4304 struct gl_pixelstore_attrib save = ctx->Unpack;
4305 ctx->Unpack = _mesa_native_packing;
4306 (*ctx->Exec->DrawPixels)( n[1].i, n[2].i, n[3].e, n[4].e,
4307 n[5].data );
4308 ctx->Unpack = save; /* restore */
4309 }
4310 break;
4311 case OPCODE_ENABLE:
4312 (*ctx->Exec->Enable)( n[1].e );
4313 break;
4314 case OPCODE_EVALMESH1:
4315 (*ctx->Exec->EvalMesh1)( n[1].e, n[2].i, n[3].i );
4316 break;
4317 case OPCODE_EVALMESH2:
4318 (*ctx->Exec->EvalMesh2)( n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
4319 break;
4320 case OPCODE_FOG:
4321 {
4322 GLfloat p[4];
4323 p[0] = n[2].f;
4324 p[1] = n[3].f;
4325 p[2] = n[4].f;
4326 p[3] = n[5].f;
4327 (*ctx->Exec->Fogfv)( n[1].e, p );
4328 }
4329 break;
4330 case OPCODE_FRONT_FACE:
4331 (*ctx->Exec->FrontFace)( n[1].e );
4332 break;
4333 case OPCODE_FRUSTUM:
4334 (*ctx->Exec->Frustum)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
4335 break;
4336 case OPCODE_HINT:
4337 (*ctx->Exec->Hint)( n[1].e, n[2].e );
4338 break;
4339 case OPCODE_HINT_PGI:
4340 (*ctx->Exec->HintPGI)( n[1].e, n[2].i );
4341 break;
4342 case OPCODE_HISTOGRAM:
4343 (*ctx->Exec->Histogram)( n[1].e, n[2].i, n[3].e, n[4].b );
4344 break;
4345 case OPCODE_INDEX_MASK:
4346 (*ctx->Exec->IndexMask)( n[1].ui );
4347 break;
4348 case OPCODE_INIT_NAMES:
4349 (*ctx->Exec->InitNames)();
4350 break;
4351 case OPCODE_LIGHT:
4352 {
4353 GLfloat p[4];
4354 p[0] = n[3].f;
4355 p[1] = n[4].f;
4356 p[2] = n[5].f;
4357 p[3] = n[6].f;
4358 (*ctx->Exec->Lightfv)( n[1].e, n[2].e, p );
4359 }
4360 break;
4361 case OPCODE_LIGHT_MODEL:
4362 {
4363 GLfloat p[4];
4364 p[0] = n[2].f;
4365 p[1] = n[3].f;
4366 p[2] = n[4].f;
4367 p[3] = n[5].f;
4368 (*ctx->Exec->LightModelfv)( n[1].e, p );
4369 }
4370 break;
4371 case OPCODE_LINE_STIPPLE:
4372 (*ctx->Exec->LineStipple)( n[1].i, n[2].us );
4373 break;
4374 case OPCODE_LINE_WIDTH:
4375 (*ctx->Exec->LineWidth)( n[1].f );
4376 break;
4377 case OPCODE_LIST_BASE:
4378 (*ctx->Exec->ListBase)( n[1].ui );
4379 break;
4380 case OPCODE_LOAD_IDENTITY:
4381 (*ctx->Exec->LoadIdentity)();
4382 break;
4383 case OPCODE_LOAD_MATRIX:
4384 if (sizeof(Node)==sizeof(GLfloat)) {
4385 (*ctx->Exec->LoadMatrixf)( &n[1].f );
4386 }
4387 else {
4388 GLfloat m[16];
4389 GLuint i;
4390 for (i=0;i<16;i++) {
4391 m[i] = n[1+i].f;
4392 }
4393 (*ctx->Exec->LoadMatrixf)( m );
4394 }
4395 break;
4396 case OPCODE_LOAD_NAME:
4397 (*ctx->Exec->LoadName)( n[1].ui );
4398 break;
4399 case OPCODE_LOGIC_OP:
4400 (*ctx->Exec->LogicOp)( n[1].e );
4401 break;
4402 case OPCODE_MAP1:
4403 {
4404 GLenum target = n[1].e;
4405 GLint ustride = _mesa_evaluator_components(target);
4406 GLint uorder = n[5].i;
4407 GLfloat u1 = n[2].f;
4408 GLfloat u2 = n[3].f;
4409 (*ctx->Exec->Map1f)( target, u1, u2, ustride, uorder,
4410 (GLfloat *) n[6].data );
4411 }
4412 break;
4413 case OPCODE_MAP2:
4414 {
4415 GLenum target = n[1].e;
4416 GLfloat u1 = n[2].f;
4417 GLfloat u2 = n[3].f;
4418 GLfloat v1 = n[4].f;
4419 GLfloat v2 = n[5].f;
4420 GLint ustride = n[6].i;
4421 GLint vstride = n[7].i;
4422 GLint uorder = n[8].i;
4423 GLint vorder = n[9].i;
4424 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
4425 v1, v2, vstride, vorder,
4426 (GLfloat *) n[10].data );
4427 }
4428 break;
4429 case OPCODE_MAPGRID1:
4430 (*ctx->Exec->MapGrid1f)( n[1].i, n[2].f, n[3].f );
4431 break;
4432 case OPCODE_MAPGRID2:
4433 (*ctx->Exec->MapGrid2f)( n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
4434 break;
4435 case OPCODE_MATRIX_MODE:
4436 (*ctx->Exec->MatrixMode)( n[1].e );
4437 break;
4438 case OPCODE_MIN_MAX:
4439 (*ctx->Exec->Minmax)(n[1].e, n[2].e, n[3].b);
4440 break;
4441 case OPCODE_MULT_MATRIX:
4442 if (sizeof(Node)==sizeof(GLfloat)) {
4443 (*ctx->Exec->MultMatrixf)( &n[1].f );
4444 }
4445 else {
4446 GLfloat m[16];
4447 GLuint i;
4448 for (i=0;i<16;i++) {
4449 m[i] = n[1+i].f;
4450 }
4451 (*ctx->Exec->MultMatrixf)( m );
4452 }
4453 break;
4454 case OPCODE_ORTHO:
4455 (*ctx->Exec->Ortho)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
4456 break;
4457 case OPCODE_PASSTHROUGH:
4458 (*ctx->Exec->PassThrough)( n[1].f );
4459 break;
4460 case OPCODE_PIXEL_MAP:
4461 (*ctx->Exec->PixelMapfv)( n[1].e, n[2].i, (GLfloat *) n[3].data );
4462 break;
4463 case OPCODE_PIXEL_TRANSFER:
4464 (*ctx->Exec->PixelTransferf)( n[1].e, n[2].f );
4465 break;
4466 case OPCODE_PIXEL_ZOOM:
4467 (*ctx->Exec->PixelZoom)( n[1].f, n[2].f );
4468 break;
4469 case OPCODE_POINT_SIZE:
4470 (*ctx->Exec->PointSize)( n[1].f );
4471 break;
4472 case OPCODE_POINT_PARAMETERS:
4473 {
4474 GLfloat params[3];
4475 params[0] = n[2].f;
4476 params[1] = n[3].f;
4477 params[2] = n[4].f;
4478 (*ctx->Exec->PointParameterfvEXT)( n[1].e, params );
4479 }
4480 break;
4481 case OPCODE_POLYGON_MODE:
4482 (*ctx->Exec->PolygonMode)( n[1].e, n[2].e );
4483 break;
4484 case OPCODE_POLYGON_STIPPLE:
4485 (*ctx->Exec->PolygonStipple)( (GLubyte *) n[1].data );
4486 break;
4487 case OPCODE_POLYGON_OFFSET:
4488 (*ctx->Exec->PolygonOffset)( n[1].f, n[2].f );
4489 break;
4490 case OPCODE_POP_ATTRIB:
4491 (*ctx->Exec->PopAttrib)();
4492 break;
4493 case OPCODE_POP_MATRIX:
4494 (*ctx->Exec->PopMatrix)();
4495 break;
4496 case OPCODE_POP_NAME:
4497 (*ctx->Exec->PopName)();
4498 break;
4499 case OPCODE_PRIORITIZE_TEXTURE:
4500 (*ctx->Exec->PrioritizeTextures)( 1, &n[1].ui, &n[2].f );
4501 break;
4502 case OPCODE_PUSH_ATTRIB:
4503 (*ctx->Exec->PushAttrib)( n[1].bf );
4504 break;
4505 case OPCODE_PUSH_MATRIX:
4506 (*ctx->Exec->PushMatrix)();
4507 break;
4508 case OPCODE_PUSH_NAME:
4509 (*ctx->Exec->PushName)( n[1].ui );
4510 break;
4511 case OPCODE_RASTER_POS:
4512 (*ctx->Exec->RasterPos4f)( n[1].f, n[2].f, n[3].f, n[4].f );
4513 break;
4514 case OPCODE_READ_BUFFER:
4515 (*ctx->Exec->ReadBuffer)( n[1].e );
4516 break;
4517 case OPCODE_RECTF:
4518 (*ctx->Exec->Rectf)( n[1].f, n[2].f, n[3].f, n[4].f );
4519 FLUSH_VB( ctx, "dlist rectf" );
4520 break;
4521 case OPCODE_RESET_HISTOGRAM:
4522 (*ctx->Exec->ResetHistogram)( n[1].e );
4523 break;
4524 case OPCODE_RESET_MIN_MAX:
4525 (*ctx->Exec->ResetMinmax)( n[1].e );
4526 break;
4527 case OPCODE_SCALE:
4528 (*ctx->Exec->Scalef)( n[1].f, n[2].f, n[3].f );
4529 break;
4530 case OPCODE_SCISSOR:
4531 (*ctx->Exec->Scissor)( n[1].i, n[2].i, n[3].i, n[4].i );
4532 break;
4533 case OPCODE_SHADE_MODEL:
4534 (*ctx->Exec->ShadeModel)( n[1].e );
4535 break;
4536 case OPCODE_STENCIL_FUNC:
4537 (*ctx->Exec->StencilFunc)( n[1].e, n[2].i, n[3].ui );
4538 break;
4539 case OPCODE_STENCIL_MASK:
4540 (*ctx->Exec->StencilMask)( n[1].ui );
4541 break;
4542 case OPCODE_STENCIL_OP:
4543 (*ctx->Exec->StencilOp)( n[1].e, n[2].e, n[3].e );
4544 break;
4545 case OPCODE_TEXENV:
4546 {
4547 GLfloat params[4];
4548 params[0] = n[3].f;
4549 params[1] = n[4].f;
4550 params[2] = n[5].f;
4551 params[3] = n[6].f;
4552 (*ctx->Exec->TexEnvfv)( n[1].e, n[2].e, params );
4553 }
4554 break;
4555 case OPCODE_TEXGEN:
4556 {
4557 GLfloat params[4];
4558 params[0] = n[3].f;
4559 params[1] = n[4].f;
4560 params[2] = n[5].f;
4561 params[3] = n[6].f;
4562 (*ctx->Exec->TexGenfv)( n[1].e, n[2].e, params );
4563 }
4564 break;
4565 case OPCODE_TEXPARAMETER:
4566 {
4567 GLfloat params[4];
4568 params[0] = n[3].f;
4569 params[1] = n[4].f;
4570 params[2] = n[5].f;
4571 params[3] = n[6].f;
4572 (*ctx->Exec->TexParameterfv)( n[1].e, n[2].e, params );
4573 }
4574 break;
4575 case OPCODE_TEX_IMAGE1D:
4576 {
4577 struct gl_pixelstore_attrib save = ctx->Unpack;
4578 ctx->Unpack = _mesa_native_packing;
4579 (*ctx->Exec->TexImage1D)(
4580 n[1].e, /* target */
4581 n[2].i, /* level */
4582 n[3].i, /* components */
4583 n[4].i, /* width */
4584 n[5].e, /* border */
4585 n[6].e, /* format */
4586 n[7].e, /* type */
4587 n[8].data );
4588 ctx->Unpack = save; /* restore */
4589 }
4590 break;
4591 case OPCODE_TEX_IMAGE2D:
4592 {
4593 struct gl_pixelstore_attrib save = ctx->Unpack;
4594 ctx->Unpack = _mesa_native_packing;
4595 (*ctx->Exec->TexImage2D)(
4596 n[1].e, /* target */
4597 n[2].i, /* level */
4598 n[3].i, /* components */
4599 n[4].i, /* width */
4600 n[5].i, /* height */
4601 n[6].e, /* border */
4602 n[7].e, /* format */
4603 n[8].e, /* type */
4604 n[9].data );
4605 ctx->Unpack = save; /* restore */
4606 }
4607 break;
4608 case OPCODE_TEX_IMAGE3D:
4609 {
4610 struct gl_pixelstore_attrib save = ctx->Unpack;
4611 ctx->Unpack = _mesa_native_packing;
4612 (*ctx->Exec->TexImage3D)(
4613 n[1].e, /* target */
4614 n[2].i, /* level */
4615 n[3].i, /* components */
4616 n[4].i, /* width */
4617 n[5].i, /* height */
4618 n[6].i, /* depth */
4619 n[7].e, /* border */
4620 n[8].e, /* format */
4621 n[9].e, /* type */
4622 n[10].data );
4623 ctx->Unpack = save; /* restore */
4624 }
4625 break;
4626 case OPCODE_TEX_SUB_IMAGE1D:
4627 {
4628 struct gl_pixelstore_attrib save = ctx->Unpack;
4629 ctx->Unpack = _mesa_native_packing;
4630 (*ctx->Exec->TexSubImage1D)( n[1].e, n[2].i, n[3].i,
4631 n[4].i, n[5].e,
4632 n[6].e, n[7].data );
4633 ctx->Unpack = save; /* restore */
4634 }
4635 break;
4636 case OPCODE_TEX_SUB_IMAGE2D:
4637 {
4638 struct gl_pixelstore_attrib save = ctx->Unpack;
4639 ctx->Unpack = _mesa_native_packing;
4640 (*ctx->Exec->TexSubImage2D)( n[1].e, n[2].i, n[3].i,
4641 n[4].i, n[5].e,
4642 n[6].i, n[7].e, n[8].e, n[9].data );
4643 ctx->Unpack = save; /* restore */
4644 }
4645 break;
4646 case OPCODE_TEX_SUB_IMAGE3D:
4647 {
4648 struct gl_pixelstore_attrib save = ctx->Unpack;
4649 ctx->Unpack = _mesa_native_packing;
4650 (*ctx->Exec->TexSubImage3D)( n[1].e, n[2].i, n[3].i,
4651 n[4].i, n[5].i, n[6].i, n[7].i,
4652 n[8].i, n[9].e, n[10].e,
4653 n[11].data );
4654 ctx->Unpack = save; /* restore */
4655 }
4656 break;
4657 case OPCODE_TRANSLATE:
4658 (*ctx->Exec->Translatef)( n[1].f, n[2].f, n[3].f );
4659 break;
4660 case OPCODE_VIEWPORT:
4661 (*ctx->Exec->Viewport)(n[1].i, n[2].i,
4662 (GLsizei) n[3].i, (GLsizei) n[4].i);
4663 break;
4664 case OPCODE_WINDOW_POS:
4665 (*ctx->Exec->WindowPos4fMESA)( n[1].f, n[2].f, n[3].f, n[4].f );
4666 break;
4667 case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
4668 (*ctx->Exec->ActiveTextureARB)( n[1].e );
4669 break;
4670 case OPCODE_CLIENT_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
4671 (*ctx->Exec->ClientActiveTextureARB)( n[1].e );
4672 break;
4673 case OPCODE_PIXEL_TEXGEN_SGIX: /* GL_SGIX_pixel_texture */
4674 (*ctx->Exec->PixelTexGenSGIX)( n[1].e );
4675 break;
4676 case OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS: /* GL_SGIS_pixel_texture */
4677 (*ctx->Exec->PixelTexGenParameteriSGIS)( n[1].e, n[2].i );
4678 break;
4679 case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */
4680 (*ctx->Exec->CompressedTexImage1DARB)(n[1].e, n[2].i, n[3].e,
4681 n[4].i, n[5].i, n[6].i, n[7].data);
4682 break;
4683 case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */
4684 (*ctx->Exec->CompressedTexImage2DARB)(n[1].e, n[2].i, n[3].e,
4685 n[4].i, n[5].i, n[6].i, n[7].i, n[8].data);
4686 break;
4687 case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */
4688 (*ctx->Exec->CompressedTexImage3DARB)(n[1].e, n[2].i, n[3].e,
4689 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i, n[9].data);
4690 break;
4691 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */
4692 (*ctx->Exec->CompressedTexSubImage1DARB)(n[1].e, n[2].i, n[3].i,
4693 n[4].i, n[5].e, n[6].i, n[7].data);
4694 break;
4695 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */
4696 (*ctx->Exec->CompressedTexSubImage2DARB)(n[1].e, n[2].i, n[3].i,
4697 n[4].i, n[5].i, n[6].i, n[7].e, n[8].i, n[9].data);
4698 break;
4699 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */
4700 (*ctx->Exec->CompressedTexSubImage3DARB)(n[1].e, n[2].i, n[3].i,
4701 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i,
4702 n[9].e, n[10].i, n[11].data);
4703 break;
4704 case OPCODE_CONTINUE:
4705 n = (Node *) n[1].next;
4706 break;
4707 case OPCODE_END_OF_LIST:
4708 done = GL_TRUE;
4709 break;
4710 default:
4711 {
4712 char msg[1000];
4713 sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
4714 gl_problem( ctx, msg );
4715 }
4716 done = GL_TRUE;
4717 }
4718
4719 /* increment n to point to next compiled command */
4720 if (opcode!=OPCODE_CONTINUE) {
4721 n += InstSize[opcode];
4722 }
4723
4724 }
4725 ctx->CallDepth--;
4726 }
4727
4728
4729
4730
4731
4732 /**********************************************************************/
4733 /* GL functions */
4734 /**********************************************************************/
4735
4736
4737
4738
4739 /*
4740 * Test if a display list number is valid.
4741 */
4742 GLboolean
4743 _mesa_IsList( GLuint list )
4744 {
4745 GET_CURRENT_CONTEXT(ctx);
4746 return islist(ctx, list);
4747 }
4748
4749
4750 /*
4751 * Delete a sequence of consecutive display lists.
4752 */
4753 void
4754 _mesa_DeleteLists( GLuint list, GLsizei range )
4755 {
4756 GET_CURRENT_CONTEXT(ctx);
4757 GLuint i;
4758
4759 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDeleteLists");
4760 if (range<0) {
4761 gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
4762 return;
4763 }
4764 for (i=list;i<list+range;i++) {
4765 gl_destroy_list( ctx, i );
4766 }
4767 }
4768
4769
4770
4771 /*
4772 * Return a display list number, n, such that lists n through n+range-1
4773 * are free.
4774 */
4775 GLuint
4776 _mesa_GenLists(GLsizei range )
4777 {
4778 GET_CURRENT_CONTEXT(ctx);
4779 GLuint base;
4780
4781 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glGenLists", 0);
4782 if (range<0) {
4783 gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
4784 return 0;
4785 }
4786 if (range==0) {
4787 return 0;
4788 }
4789
4790 /*
4791 * Make this an atomic operation
4792 */
4793 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
4794
4795 base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
4796 if (base) {
4797 /* reserve the list IDs by with empty/dummy lists */
4798 GLint i;
4799 for (i=0; i<range; i++) {
4800 _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
4801 }
4802 }
4803
4804 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
4805
4806 return base;
4807 }
4808
4809
4810
4811 /*
4812 * Begin a new display list.
4813 */
4814 void
4815 _mesa_NewList( GLuint list, GLenum mode )
4816 {
4817 GET_CURRENT_CONTEXT(ctx);
4818 struct immediate *IM;
4819 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glNewList");
4820
4821 if (MESA_VERBOSE&VERBOSE_API)
4822 fprintf(stderr, "glNewList %u %s\n", list, gl_lookup_enum_by_nr(mode));
4823
4824 if (list==0) {
4825 gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
4826 return;
4827 }
4828
4829 if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
4830 gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
4831 return;
4832 }
4833
4834 if (ctx->CurrentListPtr) {
4835 /* already compiling a display list */
4836 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
4837 return;
4838 }
4839
4840 /* Allocate new display list */
4841 ctx->CurrentListNum = list;
4842 ctx->CurrentBlock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
4843 ctx->CurrentListPtr = ctx->CurrentBlock;
4844 ctx->CurrentPos = 0;
4845
4846 IM = gl_immediate_alloc( ctx );
4847 SET_IMMEDIATE( ctx, IM );
4848 gl_reset_input( ctx );
4849
4850 ctx->CompileFlag = GL_TRUE;
4851 ctx->CompileCVAFlag = GL_FALSE;
4852 ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
4853
4854 ctx->CurrentDispatch = ctx->Save;
4855 _glapi_set_dispatch( ctx->CurrentDispatch );
4856 }
4857
4858
4859
4860 /*
4861 * End definition of current display list.
4862 */
4863 void
4864 _mesa_EndList( void )
4865 {
4866 GET_CURRENT_CONTEXT(ctx);
4867 if (MESA_VERBOSE&VERBOSE_API)
4868 fprintf(stderr, "glEndList\n");
4869
4870 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glEndList" );
4871
4872 /* Check that a list is under construction */
4873 if (!ctx->CurrentListPtr) {
4874 gl_error( ctx, GL_INVALID_OPERATION, "glEndList" );
4875 return;
4876 }
4877
4878 (void) alloc_instruction( ctx, OPCODE_END_OF_LIST, 0 );
4879
4880 /* Destroy old list, if any */
4881 gl_destroy_list(ctx, ctx->CurrentListNum);
4882 /* Install the list */
4883 _mesa_HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
4884
4885
4886 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
4887 mesa_print_display_list(ctx->CurrentListNum);
4888
4889 ctx->CurrentListNum = 0;
4890 ctx->CurrentListPtr = NULL;
4891 ctx->ExecuteFlag = GL_TRUE;
4892 ctx->CompileFlag = GL_FALSE;
4893 /* ctx->CompileCVAFlag = ...; */
4894
4895 /* KW: Put back the old input pointer.
4896 */
4897 if (--ctx->input->ref_count == 0)
4898 gl_immediate_free( ctx->input );
4899
4900 SET_IMMEDIATE( ctx, ctx->VB->IM );
4901 gl_reset_input( ctx );
4902
4903 /* Haven't tracked down why this is needed.
4904 */
4905 ctx->NewState = ~0;
4906
4907 ctx->CurrentDispatch = ctx->Exec;
4908 _glapi_set_dispatch( ctx->CurrentDispatch );
4909 }
4910
4911
4912
4913 void
4914 _mesa_CallList( GLuint list )
4915 {
4916 GET_CURRENT_CONTEXT(ctx);
4917 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
4918 /* execute the display list, and restore the CompileFlag. */
4919 GLboolean save_compile_flag;
4920
4921 if (MESA_VERBOSE&VERBOSE_API) {
4922 fprintf(stderr, "glCallList %u\n", list);
4923 mesa_print_display_list( list );
4924 }
4925
4926 save_compile_flag = ctx->CompileFlag;
4927 ctx->CompileFlag = GL_FALSE;
4928
4929 FLUSH_VB( ctx, "call list" );
4930 execute_list( ctx, list );
4931 ctx->CompileFlag = save_compile_flag;
4932
4933 /* also restore API function pointers to point to "save" versions */
4934 if (save_compile_flag) {
4935 ctx->CurrentDispatch = ctx->Save;
4936 _glapi_set_dispatch( ctx->CurrentDispatch );
4937 }
4938 }
4939
4940
4941
4942 /*
4943 * Execute glCallLists: call multiple display lists.
4944 */
4945 void
4946 _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
4947 {
4948 GET_CURRENT_CONTEXT(ctx);
4949 GLuint list;
4950 GLint i;
4951 GLboolean save_compile_flag;
4952
4953 /* Save the CompileFlag status, turn it off, execute display list,
4954 * and restore the CompileFlag.
4955 */
4956 save_compile_flag = ctx->CompileFlag;
4957 ctx->CompileFlag = GL_FALSE;
4958
4959 FLUSH_VB( ctx, "call lists" );
4960
4961 for (i=0;i<n;i++) {
4962 list = translate_id( i, type, lists );
4963 execute_list( ctx, ctx->List.ListBase + list );
4964 }
4965
4966 ctx->CompileFlag = save_compile_flag;
4967
4968 /* also restore API function pointers to point to "save" versions */
4969 if (save_compile_flag) {
4970 ctx->CurrentDispatch = ctx->Save;
4971 _glapi_set_dispatch( ctx->CurrentDispatch );
4972 }
4973 }
4974
4975
4976
4977 /*
4978 * Set the offset added to list numbers in glCallLists.
4979 */
4980 void
4981 _mesa_ListBase( GLuint base )
4982 {
4983 GET_CURRENT_CONTEXT(ctx);
4984 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glListBase");
4985 ctx->List.ListBase = base;
4986 }
4987
4988
4989
4990
4991 /*
4992 * Assign all the pointers in <table> to point to Mesa's display list
4993 * building functions.
4994 */
4995 void
4996 _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
4997 {
4998 _mesa_init_no_op_table(table, tableSize);
4999
5000 /* GL 1.0 */
5001 table->Accum = save_Accum;
5002 table->AlphaFunc = save_AlphaFunc;
5003 table->Begin = save_Begin;
5004 table->Bitmap = save_Bitmap;
5005 table->BlendFunc = save_BlendFunc;
5006 table->CallList = save_CallList;
5007 table->CallLists = save_CallLists;
5008 table->Clear = save_Clear;
5009 table->ClearAccum = save_ClearAccum;
5010 table->ClearColor = save_ClearColor;
5011 table->ClearDepth = save_ClearDepth;
5012 table->ClearIndex = save_ClearIndex;
5013 table->ClearStencil = save_ClearStencil;
5014 table->ClipPlane = save_ClipPlane;
5015 table->Color3b = _mesa_Color3b;
5016 table->Color3bv = _mesa_Color3bv;
5017 table->Color3d = _mesa_Color3d;
5018 table->Color3dv = _mesa_Color3dv;
5019 table->Color3f = _mesa_Color3f;
5020 table->Color3fv = _mesa_Color3fv;
5021 table->Color3i = _mesa_Color3i;
5022 table->Color3iv = _mesa_Color3iv;
5023 table->Color3s = _mesa_Color3s;
5024 table->Color3sv = _mesa_Color3sv;
5025 table->Color3ub = _mesa_Color3ub;
5026 table->Color3ubv = _mesa_Color3ubv;
5027 table->Color3ui = _mesa_Color3ui;
5028 table->Color3uiv = _mesa_Color3uiv;
5029 table->Color3us = _mesa_Color3us;
5030 table->Color3usv = _mesa_Color3usv;
5031 table->Color4b = _mesa_Color4b;
5032 table->Color4bv = _mesa_Color4bv;
5033 table->Color4d = _mesa_Color4d;
5034 table->Color4dv = _mesa_Color4dv;
5035 table->Color4f = _mesa_Color4f;
5036 table->Color4fv = _mesa_Color4fv;
5037 table->Color4i = _mesa_Color4i;
5038 table->Color4iv = _mesa_Color4iv;
5039 table->Color4s = _mesa_Color4s;
5040 table->Color4sv = _mesa_Color4sv;
5041 table->Color4ub = _mesa_Color4ub;
5042 table->Color4ubv = _mesa_Color4ubv;
5043 table->Color4ui = _mesa_Color4ui;
5044 table->Color4uiv = _mesa_Color4uiv;
5045 table->Color4us = _mesa_Color4us;
5046 table->Color4usv = _mesa_Color4usv;
5047 table->ColorMask = save_ColorMask;
5048 table->ColorMaterial = save_ColorMaterial;
5049 table->CopyPixels = save_CopyPixels;
5050 table->CullFace = save_CullFace;
5051 table->DeleteLists = _mesa_DeleteLists;
5052 table->DepthFunc = save_DepthFunc;
5053 table->DepthMask = save_DepthMask;
5054 table->DepthRange = save_DepthRange;
5055 table->Disable = save_Disable;
5056 table->DrawBuffer = save_DrawBuffer;
5057 table->DrawPixels = save_DrawPixels;
5058 table->EdgeFlag = _mesa_EdgeFlag;
5059 table->EdgeFlagv = _mesa_EdgeFlagv;
5060 table->Enable = save_Enable;
5061 table->End = _mesa_End;
5062 table->EndList = _mesa_EndList;
5063 table->EvalCoord1d = _mesa_EvalCoord1d;
5064 table->EvalCoord1dv = _mesa_EvalCoord1dv;
5065 table->EvalCoord1f = _mesa_EvalCoord1f;
5066 table->EvalCoord1fv = _mesa_EvalCoord1fv;
5067 table->EvalCoord2d = _mesa_EvalCoord2d;
5068 table->EvalCoord2dv = _mesa_EvalCoord2dv;
5069 table->EvalCoord2f = _mesa_EvalCoord2f;
5070 table->EvalCoord2fv = _mesa_EvalCoord2fv;
5071 table->EvalMesh1 = save_EvalMesh1;
5072 table->EvalMesh2 = save_EvalMesh2;
5073 table->EvalPoint1 = _mesa_EvalPoint1;
5074 table->EvalPoint2 = _mesa_EvalPoint2;
5075 table->FeedbackBuffer = _mesa_FeedbackBuffer;
5076 table->Finish = _mesa_Finish;
5077 table->Flush = _mesa_Flush;
5078 table->Fogf = save_Fogf;
5079 table->Fogfv = save_Fogfv;
5080 table->Fogi = save_Fogi;
5081 table->Fogiv = save_Fogiv;
5082 table->FrontFace = save_FrontFace;
5083 table->Frustum = save_Frustum;
5084 table->GenLists = _mesa_GenLists;
5085 table->GetBooleanv = _mesa_GetBooleanv;
5086 table->GetClipPlane = _mesa_GetClipPlane;
5087 table->GetDoublev = _mesa_GetDoublev;
5088 table->GetError = _mesa_GetError;
5089 table->GetFloatv = _mesa_GetFloatv;
5090 table->GetIntegerv = _mesa_GetIntegerv;
5091 table->GetLightfv = _mesa_GetLightfv;
5092 table->GetLightiv = _mesa_GetLightiv;
5093 table->GetMapdv = _mesa_GetMapdv;
5094 table->GetMapfv = _mesa_GetMapfv;
5095 table->GetMapiv = _mesa_GetMapiv;
5096 table->GetMaterialfv = _mesa_GetMaterialfv;
5097 table->GetMaterialiv = _mesa_GetMaterialiv;
5098 table->GetPixelMapfv = _mesa_GetPixelMapfv;
5099 table->GetPixelMapuiv = _mesa_GetPixelMapuiv;
5100 table->GetPixelMapusv = _mesa_GetPixelMapusv;
5101 table->GetPolygonStipple = _mesa_GetPolygonStipple;
5102 table->GetString = _mesa_GetString;
5103 table->GetTexEnvfv = _mesa_GetTexEnvfv;
5104 table->GetTexEnviv = _mesa_GetTexEnviv;
5105 table->GetTexGendv = _mesa_GetTexGendv;
5106 table->GetTexGenfv = _mesa_GetTexGenfv;
5107 table->GetTexGeniv = _mesa_GetTexGeniv;
5108 table->GetTexImage = _mesa_GetTexImage;
5109 table->GetTexLevelParameterfv = _mesa_GetTexLevelParameterfv;
5110 table->GetTexLevelParameteriv = _mesa_GetTexLevelParameteriv;
5111 table->GetTexParameterfv = _mesa_GetTexParameterfv;
5112 table->GetTexParameteriv = _mesa_GetTexParameteriv;
5113 table->Hint = save_Hint;
5114 table->IndexMask = save_IndexMask;
5115 table->Indexd = _mesa_Indexd;
5116 table->Indexdv = _mesa_Indexdv;
5117 table->Indexf = _mesa_Indexf;
5118 table->Indexfv = _mesa_Indexfv;
5119 table->Indexi = _mesa_Indexi;
5120 table->Indexiv = _mesa_Indexiv;
5121 table->Indexs = _mesa_Indexs;
5122 table->Indexsv = _mesa_Indexsv;
5123 table->InitNames = save_InitNames;
5124 table->IsEnabled = _mesa_IsEnabled;
5125 table->IsList = _mesa_IsList;
5126 table->LightModelf = save_LightModelf;
5127 table->LightModelfv = save_LightModelfv;
5128 table->LightModeli = save_LightModeli;
5129 table->LightModeliv = save_LightModeliv;
5130 table->Lightf = save_Lightf;
5131 table->Lightfv = save_Lightfv;
5132 table->Lighti = save_Lighti;
5133 table->Lightiv = save_Lightiv;
5134 table->LineStipple = save_LineStipple;
5135 table->LineWidth = save_LineWidth;
5136 table->ListBase = save_ListBase;
5137 table->LoadIdentity = save_LoadIdentity;
5138 table->LoadMatrixd = save_LoadMatrixd;
5139 table->LoadMatrixf = save_LoadMatrixf;
5140 table->LoadName = save_LoadName;
5141 table->LogicOp = save_LogicOp;
5142 table->Map1d = save_Map1d;
5143 table->Map1f = save_Map1f;
5144 table->Map2d = save_Map2d;
5145 table->Map2f = save_Map2f;
5146 table->MapGrid1d = save_MapGrid1d;
5147 table->MapGrid1f = save_MapGrid1f;
5148 table->MapGrid2d = save_MapGrid2d;
5149 table->MapGrid2f = save_MapGrid2f;
5150 table->Materialf = _mesa_Materialf;
5151 table->Materialfv = _mesa_Materialfv;
5152 table->Materiali = _mesa_Materiali;
5153 table->Materialiv = _mesa_Materialiv;
5154 table->MatrixMode = save_MatrixMode;
5155 table->MultMatrixd = save_MultMatrixd;
5156 table->MultMatrixf = save_MultMatrixf;
5157 table->NewList = save_NewList;
5158 table->Normal3b = _mesa_Normal3b;
5159 table->Normal3bv = _mesa_Normal3bv;
5160 table->Normal3d = _mesa_Normal3d;
5161 table->Normal3dv = _mesa_Normal3dv;
5162 table->Normal3f = _mesa_Normal3f;
5163 table->Normal3fv = _mesa_Normal3fv;
5164 table->Normal3i = _mesa_Normal3i;
5165 table->Normal3iv = _mesa_Normal3iv;
5166 table->Normal3s = _mesa_Normal3s;
5167 table->Normal3sv = _mesa_Normal3sv;
5168 table->Ortho = save_Ortho;
5169 table->PassThrough = save_PassThrough;
5170 table->PixelMapfv = save_PixelMapfv;
5171 table->PixelMapuiv = save_PixelMapuiv;
5172 table->PixelMapusv = save_PixelMapusv;
5173 table->PixelStoref = _mesa_PixelStoref;
5174 table->PixelStorei = _mesa_PixelStorei;
5175 table->PixelTransferf = save_PixelTransferf;
5176 table->PixelTransferi = save_PixelTransferi;
5177 table->PixelZoom = save_PixelZoom;
5178 table->PointSize = save_PointSize;
5179 table->PolygonMode = save_PolygonMode;
5180 table->PolygonOffset = save_PolygonOffset;
5181 table->PolygonStipple = save_PolygonStipple;
5182 table->PopAttrib = save_PopAttrib;
5183 table->PopMatrix = save_PopMatrix;
5184 table->PopName = save_PopName;
5185 table->PushAttrib = save_PushAttrib;
5186 table->PushMatrix = save_PushMatrix;
5187 table->PushName = save_PushName;
5188 table->RasterPos2d = save_RasterPos2d;
5189 table->RasterPos2dv = save_RasterPos2dv;
5190 table->RasterPos2f = save_RasterPos2f;
5191 table->RasterPos2fv = save_RasterPos2fv;
5192 table->RasterPos2i = save_RasterPos2i;
5193 table->RasterPos2iv = save_RasterPos2iv;
5194 table->RasterPos2s = save_RasterPos2s;
5195 table->RasterPos2sv = save_RasterPos2sv;
5196 table->RasterPos3d = save_RasterPos3d;
5197 table->RasterPos3dv = save_RasterPos3dv;
5198 table->RasterPos3f = save_RasterPos3f;
5199 table->RasterPos3fv = save_RasterPos3fv;
5200 table->RasterPos3i = save_RasterPos3i;
5201 table->RasterPos3iv = save_RasterPos3iv;
5202 table->RasterPos3s = save_RasterPos3s;
5203 table->RasterPos3sv = save_RasterPos3sv;
5204 table->RasterPos4d = save_RasterPos4d;
5205 table->RasterPos4dv = save_RasterPos4dv;
5206 table->RasterPos4f = save_RasterPos4f;
5207 table->RasterPos4fv = save_RasterPos4fv;
5208 table->RasterPos4i = save_RasterPos4i;
5209 table->RasterPos4iv = save_RasterPos4iv;
5210 table->RasterPos4s = save_RasterPos4s;
5211 table->RasterPos4sv = save_RasterPos4sv;
5212 table->ReadBuffer = save_ReadBuffer;
5213 table->ReadPixels = _mesa_ReadPixels;
5214 table->Rectd = save_Rectd;
5215 table->Rectdv = save_Rectdv;
5216 table->Rectf = save_Rectf;
5217 table->Rectfv = save_Rectfv;
5218 table->Recti = save_Recti;
5219 table->Rectiv = save_Rectiv;
5220 table->Rects = save_Rects;
5221 table->Rectsv = save_Rectsv;
5222 table->RenderMode = _mesa_RenderMode;
5223 table->Rotated = save_Rotated;
5224 table->Rotatef = save_Rotatef;
5225 table->Scaled = save_Scaled;
5226 table->Scalef = save_Scalef;
5227 table->Scissor = save_Scissor;
5228 table->SelectBuffer = _mesa_SelectBuffer;
5229 table->ShadeModel = save_ShadeModel;
5230 table->StencilFunc = save_StencilFunc;
5231 table->StencilMask = save_StencilMask;
5232 table->StencilOp = save_StencilOp;
5233 table->TexCoord1d = _mesa_TexCoord1d;
5234 table->TexCoord1dv = _mesa_TexCoord1dv;
5235 table->TexCoord1f = _mesa_TexCoord1f;
5236 table->TexCoord1fv = _mesa_TexCoord1fv;
5237 table->TexCoord1i = _mesa_TexCoord1i;
5238 table->TexCoord1iv = _mesa_TexCoord1iv;
5239 table->TexCoord1s = _mesa_TexCoord1s;
5240 table->TexCoord1sv = _mesa_TexCoord1sv;
5241 table->TexCoord2d = _mesa_TexCoord2d;
5242 table->TexCoord2dv = _mesa_TexCoord2dv;
5243 table->TexCoord2f = _mesa_TexCoord2f;
5244 table->TexCoord2fv = _mesa_TexCoord2fv;
5245 table->TexCoord2i = _mesa_TexCoord2i;
5246 table->TexCoord2iv = _mesa_TexCoord2iv;
5247 table->TexCoord2s = _mesa_TexCoord2s;
5248 table->TexCoord2sv = _mesa_TexCoord2sv;
5249 table->TexCoord3d = _mesa_TexCoord3d;
5250 table->TexCoord3dv = _mesa_TexCoord3dv;
5251 table->TexCoord3f = _mesa_TexCoord3f;
5252 table->TexCoord3fv = _mesa_TexCoord3fv;
5253 table->TexCoord3i = _mesa_TexCoord3i;
5254 table->TexCoord3iv = _mesa_TexCoord3iv;
5255 table->TexCoord3s = _mesa_TexCoord3s;
5256 table->TexCoord3sv = _mesa_TexCoord3sv;
5257 table->TexCoord4d = _mesa_TexCoord4d;
5258 table->TexCoord4dv = _mesa_TexCoord4dv;
5259 table->TexCoord4f = _mesa_TexCoord4f;
5260 table->TexCoord4fv = _mesa_TexCoord4fv;
5261 table->TexCoord4i = _mesa_TexCoord4i;
5262 table->TexCoord4iv = _mesa_TexCoord4iv;
5263 table->TexCoord4s = _mesa_TexCoord4s;
5264 table->TexCoord4sv = _mesa_TexCoord4sv;
5265 table->TexEnvf = save_TexEnvf;
5266 table->TexEnvfv = save_TexEnvfv;
5267 table->TexEnvi = save_TexEnvi;
5268 table->TexEnviv = save_TexEnviv;
5269 table->TexGend = save_TexGend;
5270 table->TexGendv = save_TexGendv;
5271 table->TexGenf = save_TexGenf;
5272 table->TexGenfv = save_TexGenfv;
5273 table->TexGeni = save_TexGeni;
5274 table->TexGeniv = save_TexGeniv;
5275 table->TexImage1D = save_TexImage1D;
5276 table->TexImage2D = save_TexImage2D;
5277 table->TexParameterf = save_TexParameterf;
5278 table->TexParameterfv = save_TexParameterfv;
5279 table->TexParameteri = save_TexParameteri;
5280 table->TexParameteriv = save_TexParameteriv;
5281 table->Translated = save_Translated;
5282 table->Translatef = save_Translatef;
5283 table->Vertex2d = _mesa_Vertex2d;
5284 table->Vertex2dv = _mesa_Vertex2dv;
5285 table->Vertex2f = _mesa_Vertex2f;
5286 table->Vertex2fv = _mesa_Vertex2fv;
5287 table->Vertex2i = _mesa_Vertex2i;
5288 table->Vertex2iv = _mesa_Vertex2iv;
5289 table->Vertex2s = _mesa_Vertex2s;
5290 table->Vertex2sv = _mesa_Vertex2sv;
5291 table->Vertex3d = _mesa_Vertex3d;
5292 table->Vertex3dv = _mesa_Vertex3dv;
5293 table->Vertex3f = _mesa_Vertex3f;
5294 table->Vertex3fv = _mesa_Vertex3fv;
5295 table->Vertex3i = _mesa_Vertex3i;
5296 table->Vertex3iv = _mesa_Vertex3iv;
5297 table->Vertex3s = _mesa_Vertex3s;
5298 table->Vertex3sv = _mesa_Vertex3sv;
5299 table->Vertex4d = _mesa_Vertex4d;
5300 table->Vertex4dv = _mesa_Vertex4dv;
5301 table->Vertex4f = _mesa_Vertex4f;
5302 table->Vertex4fv = _mesa_Vertex4fv;
5303 table->Vertex4i = _mesa_Vertex4i;
5304 table->Vertex4iv = _mesa_Vertex4iv;
5305 table->Vertex4s = _mesa_Vertex4s;
5306 table->Vertex4sv = _mesa_Vertex4sv;
5307 table->Viewport = save_Viewport;
5308
5309 /* GL 1.1 */
5310 table->AreTexturesResident = _mesa_AreTexturesResident;
5311 table->ArrayElement = _mesa_ArrayElement;
5312 table->BindTexture = save_BindTexture;
5313 table->ColorPointer = _mesa_ColorPointer;
5314 table->CopyTexImage1D = save_CopyTexImage1D;
5315 table->CopyTexImage2D = save_CopyTexImage2D;
5316 table->CopyTexSubImage1D = save_CopyTexSubImage1D;
5317 table->CopyTexSubImage2D = save_CopyTexSubImage2D;
5318 table->DeleteTextures = _mesa_DeleteTextures;
5319 table->DisableClientState = _mesa_DisableClientState;
5320 table->DrawArrays = _mesa_DrawArrays;
5321 table->DrawElements = _mesa_DrawElements;
5322 table->EdgeFlagPointer = _mesa_EdgeFlagPointer;
5323 table->EnableClientState = _mesa_EnableClientState;
5324 table->GenTextures = _mesa_GenTextures;
5325 table->GetPointerv = _mesa_GetPointerv;
5326 table->IndexPointer = _mesa_IndexPointer;
5327 table->Indexub = _mesa_Indexub;
5328 table->Indexubv = _mesa_Indexubv;
5329 table->InterleavedArrays = _mesa_InterleavedArrays;
5330 table->IsTexture = _mesa_IsTexture;
5331 table->NormalPointer = _mesa_NormalPointer;
5332 table->PopClientAttrib = _mesa_PopClientAttrib;
5333 table->PrioritizeTextures = save_PrioritizeTextures;
5334 table->PushClientAttrib = _mesa_PushClientAttrib;
5335 table->TexCoordPointer = _mesa_TexCoordPointer;
5336 table->TexSubImage1D = save_TexSubImage1D;
5337 table->TexSubImage2D = save_TexSubImage2D;
5338 table->VertexPointer = _mesa_VertexPointer;
5339
5340 /* GL 1.2 */
5341 table->CopyTexSubImage3D = save_CopyTexSubImage3D;
5342 table->DrawRangeElements = _mesa_DrawRangeElements;
5343 table->TexImage3D = save_TexImage3D;
5344 table->TexSubImage3D = save_TexSubImage3D;
5345
5346 /* GL_ARB_imaging */
5347 /* Not all are supported */
5348 table->BlendColor = save_BlendColor;
5349 table->BlendEquation = save_BlendEquation;
5350 table->ColorSubTable = save_ColorSubTable;
5351 table->ColorTable = save_ColorTable;
5352 table->ColorTableParameterfv = save_ColorTableParameterfv;
5353 table->ColorTableParameteriv = save_ColorTableParameteriv;
5354 table->ConvolutionFilter1D = save_ConvolutionFilter1D;
5355 table->ConvolutionFilter2D = save_ConvolutionFilter2D;
5356 table->ConvolutionParameterf = save_ConvolutionParameterf;
5357 table->ConvolutionParameterfv = save_ConvolutionParameterfv;
5358 table->ConvolutionParameteri = save_ConvolutionParameteri;
5359 table->ConvolutionParameteriv = save_ConvolutionParameteriv;
5360 table->CopyColorSubTable = save_CopyColorSubTable;
5361 table->CopyColorTable = save_CopyColorTable;
5362 table->CopyConvolutionFilter1D = _mesa_CopyConvolutionFilter1D;
5363 table->CopyConvolutionFilter2D = _mesa_CopyConvolutionFilter2D;
5364 table->GetColorTable = _mesa_GetColorTable;
5365 table->GetColorTableParameterfv = _mesa_GetColorTableParameterfv;
5366 table->GetColorTableParameteriv = _mesa_GetColorTableParameteriv;
5367 table->GetConvolutionFilter = _mesa_GetConvolutionFilter;
5368 table->GetConvolutionParameterfv = _mesa_GetConvolutionParameterfv;
5369 table->GetConvolutionParameteriv = _mesa_GetConvolutionParameteriv;
5370 table->GetHistogram = _mesa_GetHistogram;
5371 table->GetHistogramParameterfv = _mesa_GetHistogramParameterfv;
5372 table->GetHistogramParameteriv = _mesa_GetHistogramParameteriv;
5373 table->GetMinmax = _mesa_GetMinmax;
5374 table->GetMinmaxParameterfv = _mesa_GetMinmaxParameterfv;
5375 table->GetMinmaxParameteriv = _mesa_GetMinmaxParameteriv;
5376 table->GetSeparableFilter = _mesa_GetSeparableFilter;
5377 table->Histogram = save_Histogram;
5378 table->Minmax = save_Minmax;
5379 table->ResetHistogram = save_ResetHistogram;
5380 table->ResetMinmax = save_ResetMinmax;
5381 table->SeparableFilter2D = _mesa_SeparableFilter2D;
5382
5383 /* 2. GL_EXT_blend_color */
5384 #if 0
5385 table->BlendColorEXT = save_BlendColorEXT;
5386 #endif
5387
5388 /* 3. GL_EXT_polygon_offset */
5389 table->PolygonOffsetEXT = save_PolygonOffsetEXT;
5390
5391 /* 6. GL_EXT_texture3d */
5392 #if 0
5393 table->CopyTexSubImage3DEXT = save_CopyTexSubImage3D;
5394 table->TexImage3DEXT = save_TexImage3DEXT;
5395 table->TexSubImage3DEXT = save_TexSubImage3D;
5396 #endif
5397
5398 /* 15. GL_SGIX_pixel_texture */
5399 table->PixelTexGenSGIX = save_PixelTexGenSGIX;
5400
5401 /* 15. GL_SGIS_pixel_texture */
5402 table->PixelTexGenParameteriSGIS = save_PixelTexGenParameteriSGIS;
5403 table->PixelTexGenParameterfSGIS = save_PixelTexGenParameterfSGIS;
5404 table->PixelTexGenParameterivSGIS = save_PixelTexGenParameterivSGIS;
5405 table->PixelTexGenParameterfvSGIS = save_PixelTexGenParameterfvSGIS;
5406 table->GetPixelTexGenParameterivSGIS = _mesa_GetPixelTexGenParameterivSGIS;
5407 table->GetPixelTexGenParameterfvSGIS = _mesa_GetPixelTexGenParameterfvSGIS;
5408
5409 /* 30. GL_EXT_vertex_array */
5410 table->ColorPointerEXT = _mesa_ColorPointerEXT;
5411 table->EdgeFlagPointerEXT = _mesa_EdgeFlagPointerEXT;
5412 table->IndexPointerEXT = _mesa_IndexPointerEXT;
5413 table->NormalPointerEXT = _mesa_NormalPointerEXT;
5414 table->TexCoordPointerEXT = _mesa_TexCoordPointerEXT;
5415 table->VertexPointerEXT = _mesa_VertexPointerEXT;
5416
5417 /* 37. GL_EXT_blend_minmax */
5418 #if 0
5419 table->BlendEquationEXT = save_BlendEquationEXT;
5420 #endif
5421
5422 /* 54. GL_EXT_point_parameters */
5423 table->PointParameterfEXT = save_PointParameterfEXT;
5424 table->PointParameterfvEXT = save_PointParameterfvEXT;
5425
5426 /* 77. GL_PGI_misc_hints */
5427 table->HintPGI = save_HintPGI;
5428
5429 /* 78. GL_EXT_paletted_texture */
5430 #if 0
5431 table->ColorTableEXT = save_ColorTable;
5432 table->ColorSubTableEXT = save_ColorSubTable;
5433 #endif
5434 table->GetColorTableEXT = _mesa_GetColorTable;
5435 table->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv;
5436 table->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv;
5437
5438 /* 97. GL_EXT_compiled_vertex_array */
5439 table->LockArraysEXT = _mesa_LockArraysEXT;
5440 table->UnlockArraysEXT = _mesa_UnlockArraysEXT;
5441
5442 /* GL_ARB_multitexture */
5443 table->ActiveTextureARB = save_ActiveTextureARB;
5444 table->ClientActiveTextureARB = save_ClientActiveTextureARB;
5445 table->MultiTexCoord1dARB = _mesa_MultiTexCoord1dARB;
5446 table->MultiTexCoord1dvARB = _mesa_MultiTexCoord1dvARB;
5447 table->MultiTexCoord1fARB = _mesa_MultiTexCoord1fARB;
5448 table->MultiTexCoord1fvARB = _mesa_MultiTexCoord1fvARB;
5449 table->MultiTexCoord1iARB = _mesa_MultiTexCoord1iARB;
5450 table->MultiTexCoord1ivARB = _mesa_MultiTexCoord1ivARB;
5451 table->MultiTexCoord1sARB = _mesa_MultiTexCoord1sARB;
5452 table->MultiTexCoord1svARB = _mesa_MultiTexCoord1svARB;
5453 table->MultiTexCoord2dARB = _mesa_MultiTexCoord2dARB;
5454 table->MultiTexCoord2dvARB = _mesa_MultiTexCoord2dvARB;
5455 table->MultiTexCoord2fARB = _mesa_MultiTexCoord2fARB;
5456 table->MultiTexCoord2fvARB = _mesa_MultiTexCoord2fvARB;
5457 table->MultiTexCoord2iARB = _mesa_MultiTexCoord2iARB;
5458 table->MultiTexCoord2ivARB = _mesa_MultiTexCoord2ivARB;
5459 table->MultiTexCoord2sARB = _mesa_MultiTexCoord2sARB;
5460 table->MultiTexCoord2svARB = _mesa_MultiTexCoord2svARB;
5461 table->MultiTexCoord3dARB = _mesa_MultiTexCoord3dARB;
5462 table->MultiTexCoord3dvARB = _mesa_MultiTexCoord3dvARB;
5463 table->MultiTexCoord3fARB = _mesa_MultiTexCoord3fARB;
5464 table->MultiTexCoord3fvARB = _mesa_MultiTexCoord3fvARB;
5465 table->MultiTexCoord3iARB = _mesa_MultiTexCoord3iARB;
5466 table->MultiTexCoord3ivARB = _mesa_MultiTexCoord3ivARB;
5467 table->MultiTexCoord3sARB = _mesa_MultiTexCoord3sARB;
5468 table->MultiTexCoord3svARB = _mesa_MultiTexCoord3svARB;
5469 table->MultiTexCoord4dARB = _mesa_MultiTexCoord4dARB;
5470 table->MultiTexCoord4dvARB = _mesa_MultiTexCoord4dvARB;
5471 table->MultiTexCoord4fARB = _mesa_MultiTexCoord4fARB;
5472 table->MultiTexCoord4fvARB = _mesa_MultiTexCoord4fvARB;
5473 table->MultiTexCoord4iARB = _mesa_MultiTexCoord4iARB;
5474 table->MultiTexCoord4ivARB = _mesa_MultiTexCoord4ivARB;
5475 table->MultiTexCoord4sARB = _mesa_MultiTexCoord4sARB;
5476 table->MultiTexCoord4svARB = _mesa_MultiTexCoord4svARB;
5477
5478 /* GL_EXT_blend_func_separate */
5479 table->BlendFuncSeparateEXT = save_BlendFuncSeparateEXT;
5480
5481 /* GL_MESA_window_pos */
5482 table->WindowPos2dMESA = save_WindowPos2dMESA;
5483 table->WindowPos2dvMESA = save_WindowPos2dvMESA;
5484 table->WindowPos2fMESA = save_WindowPos2fMESA;
5485 table->WindowPos2fvMESA = save_WindowPos2fvMESA;
5486 table->WindowPos2iMESA = save_WindowPos2iMESA;
5487 table->WindowPos2ivMESA = save_WindowPos2ivMESA;
5488 table->WindowPos2sMESA = save_WindowPos2sMESA;
5489 table->WindowPos2svMESA = save_WindowPos2svMESA;
5490 table->WindowPos3dMESA = save_WindowPos3dMESA;
5491 table->WindowPos3dvMESA = save_WindowPos3dvMESA;
5492 table->WindowPos3fMESA = save_WindowPos3fMESA;
5493 table->WindowPos3fvMESA = save_WindowPos3fvMESA;
5494 table->WindowPos3iMESA = save_WindowPos3iMESA;
5495 table->WindowPos3ivMESA = save_WindowPos3ivMESA;
5496 table->WindowPos3sMESA = save_WindowPos3sMESA;
5497 table->WindowPos3svMESA = save_WindowPos3svMESA;
5498 table->WindowPos4dMESA = save_WindowPos4dMESA;
5499 table->WindowPos4dvMESA = save_WindowPos4dvMESA;
5500 table->WindowPos4fMESA = save_WindowPos4fMESA;
5501 table->WindowPos4fvMESA = save_WindowPos4fvMESA;
5502 table->WindowPos4iMESA = save_WindowPos4iMESA;
5503 table->WindowPos4ivMESA = save_WindowPos4ivMESA;
5504 table->WindowPos4sMESA = save_WindowPos4sMESA;
5505 table->WindowPos4svMESA = save_WindowPos4svMESA;
5506
5507 /* GL_MESA_resize_buffers */
5508 table->ResizeBuffersMESA = _mesa_ResizeBuffersMESA;
5509
5510 /* GL_ARB_transpose_matrix */
5511 table->LoadTransposeMatrixdARB = save_LoadTransposeMatrixdARB;
5512 table->LoadTransposeMatrixfARB = save_LoadTransposeMatrixfARB;
5513 table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB;
5514 table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB;
5515
5516 /* ARB 12. GL_ARB_texture_compression */
5517 table->CompressedTexImage3DARB = save_CompressedTexImage3DARB;
5518 table->CompressedTexImage2DARB = save_CompressedTexImage2DARB;
5519 table->CompressedTexImage1DARB = save_CompressedTexImage1DARB;
5520 table->CompressedTexSubImage3DARB = save_CompressedTexSubImage3DARB;
5521 table->CompressedTexSubImage2DARB = save_CompressedTexSubImage2DARB;
5522 table->CompressedTexSubImage1DARB = save_CompressedTexSubImage1DARB;
5523 table->GetCompressedTexImageARB = _mesa_GetCompressedTexImageARB;
5524 }
5525
5526
5527
5528 /***
5529 *** Debugging code
5530 ***/
5531 static const char *enum_string( GLenum k )
5532 {
5533 return gl_lookup_enum_by_nr( k );
5534 }
5535
5536
5537 /*
5538 * Print the commands in a display list. For debugging only.
5539 * TODO: many commands aren't handled yet.
5540 */
5541 static void print_list( GLcontext *ctx, FILE *f, GLuint list )
5542 {
5543 Node *n;
5544 GLboolean done;
5545 OpCode opcode;
5546
5547 if (!glIsList(list)) {
5548 fprintf(f,"%u is not a display list ID\n",list);
5549 return;
5550 }
5551
5552 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
5553
5554 fprintf( f, "START-LIST %u, address %p\n", list, (void*)n );
5555
5556 done = n ? GL_FALSE : GL_TRUE;
5557 while (!done) {
5558 opcode = n[0].opcode;
5559
5560 switch (opcode) {
5561 case OPCODE_ACCUM:
5562 fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f );
5563 break;
5564 case OPCODE_BITMAP:
5565 fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
5566 n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
5567 break;
5568 case OPCODE_CALL_LIST:
5569 fprintf(f,"CallList %d\n", (int) n[1].ui );
5570 break;
5571 case OPCODE_CALL_LIST_OFFSET:
5572 fprintf(f,"CallList %d + offset %u = %u\n", (int) n[1].ui,
5573 ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
5574 break;
5575 case OPCODE_COLOR_TABLE_PARAMETER_FV:
5576 fprintf(f,"ColorTableParameterfv %s %s %f %f %f %f\n",
5577 enum_string(n[1].e), enum_string(n[2].e),
5578 n[3].f, n[4].f, n[5].f, n[6].f);
5579 break;
5580 case OPCODE_COLOR_TABLE_PARAMETER_IV:
5581 fprintf(f,"ColorTableParameteriv %s %s %d %d %d %d\n",
5582 enum_string(n[1].e), enum_string(n[2].e),
5583 n[3].i, n[4].i, n[5].i, n[6].i);
5584 break;
5585 case OPCODE_DISABLE:
5586 fprintf(f,"Disable %s\n", enum_string(n[1].e));
5587 break;
5588 case OPCODE_ENABLE:
5589 fprintf(f,"Enable %s\n", enum_string(n[1].e));
5590 break;
5591 case OPCODE_FRUSTUM:
5592 fprintf(f,"Frustum %g %g %g %g %g %g\n",
5593 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
5594 break;
5595 case OPCODE_LINE_STIPPLE:
5596 fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us );
5597 break;
5598 case OPCODE_LOAD_IDENTITY:
5599 fprintf(f,"LoadIdentity\n");
5600 break;
5601 case OPCODE_LOAD_MATRIX:
5602 fprintf(f,"LoadMatrix\n");
5603 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
5604 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
5605 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
5606 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
5607 break;
5608 case OPCODE_MULT_MATRIX:
5609 fprintf(f,"MultMatrix (or Rotate)\n");
5610 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
5611 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
5612 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
5613 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
5614 break;
5615 case OPCODE_ORTHO:
5616 fprintf(f,"Ortho %g %g %g %g %g %g\n",
5617 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
5618 break;
5619 case OPCODE_POP_ATTRIB:
5620 fprintf(f,"PopAttrib\n");
5621 break;
5622 case OPCODE_POP_MATRIX:
5623 fprintf(f,"PopMatrix\n");
5624 break;
5625 case OPCODE_POP_NAME:
5626 fprintf(f,"PopName\n");
5627 break;
5628 case OPCODE_PUSH_ATTRIB:
5629 fprintf(f,"PushAttrib %x\n", n[1].bf );
5630 break;
5631 case OPCODE_PUSH_MATRIX:
5632 fprintf(f,"PushMatrix\n");
5633 break;
5634 case OPCODE_PUSH_NAME:
5635 fprintf(f,"PushName %d\n", (int) n[1].ui );
5636 break;
5637 case OPCODE_RASTER_POS:
5638 fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f);
5639 break;
5640 case OPCODE_RECTF:
5641 fprintf( f, "Rectf %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
5642 break;
5643 case OPCODE_SCALE:
5644 fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
5645 break;
5646 case OPCODE_TRANSLATE:
5647 fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
5648 break;
5649 case OPCODE_BIND_TEXTURE:
5650 fprintf(f,"BindTexture %s %d\n", gl_lookup_enum_by_nr(n[1].ui),
5651 n[2].ui);
5652 break;
5653 case OPCODE_SHADE_MODEL:
5654 fprintf(f,"ShadeModel %s\n", gl_lookup_enum_by_nr(n[1].ui));
5655 break;
5656
5657 /*
5658 * meta opcodes/commands
5659 */
5660 case OPCODE_ERROR:
5661 fprintf(f,"Error: %s %s\n", enum_string(n[1].e), (const char *)n[2].data );
5662 break;
5663 case OPCODE_VERTEX_CASSETTE:
5664 fprintf(f,"VERTEX-CASSETTE, id %u, rows %u..%u\n",
5665 ((struct immediate *) n[1].data)->id,
5666 n[2].ui,
5667 n[3].ui);
5668 gl_print_cassette( (struct immediate *) n[1].data );
5669 break;
5670 case OPCODE_CONTINUE:
5671 fprintf(f,"DISPLAY-LIST-CONTINUE\n");
5672 n = (Node *) n[1].next;
5673 break;
5674 case OPCODE_END_OF_LIST:
5675 fprintf(f,"END-LIST %u\n", list);
5676 done = GL_TRUE;
5677 break;
5678 default:
5679 if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
5680 fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
5681 opcode, (void*) n);
5682 return;
5683 }
5684 else {
5685 fprintf(f,"command %d, %u operands\n",opcode,InstSize[opcode]);
5686 }
5687 }
5688
5689 /* increment n to point to next compiled command */
5690 if (opcode!=OPCODE_CONTINUE) {
5691 n += InstSize[opcode];
5692 }
5693 }
5694 }
5695
5696
5697
5698 /*
5699 * Clients may call this function to help debug display list problems.
5700 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
5701 * changed, or break in the future without notice.
5702 */
5703 void mesa_print_display_list( GLuint list )
5704 {
5705 GET_CURRENT_CONTEXT(ctx);
5706 print_list( ctx, stderr, list );
5707 }