clean-up to reduce MSVC warnings
[mesa.git] / src / mesa / main / dlist.c
1 /* $Id: dlist.c,v 1.13 1999/11/03 17:27:05 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.1
6 *
7 * Copyright (C) 1999 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 /* $XFree86: xc/lib/GL/mesa/src/dlist.c,v 1.3 1999/04/04 00:20:22 dawes Exp $ */
29
30 #ifdef PC_HEADER
31 #include "all.h"
32 #else
33 #ifndef XFree86Server
34 #include <assert.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38 #else
39 #include "GL/xf86glx.h"
40 #endif
41 #include "accum.h"
42 #include "api.h"
43 #include "alpha.h"
44 #include "attrib.h"
45 #include "bitmap.h"
46 #include "bbox.h"
47 #include "blend.h"
48 #include "clip.h"
49 #include "colortab.h"
50 #include "context.h"
51 #include "copypix.h"
52 #include "depth.h"
53 #include "drawpix.h"
54 #include "enable.h"
55 #include "enums.h"
56 #include "eval.h"
57 #include "extensions.h"
58 #include "feedback.h"
59 #include "fog.h"
60 #include "get.h"
61 #include "glmisc.h"
62 #include "hash.h"
63 #include "image.h"
64 #include "light.h"
65 #include "lines.h"
66 #include "dlist.h"
67 #include "logic.h"
68 #include "macros.h"
69 #include "masking.h"
70 #include "matrix.h"
71 #include "pipeline.h"
72 #include "pixel.h"
73 #include "points.h"
74 #include "polygon.h"
75 #include "rastpos.h"
76 #include "readpix.h"
77 #include "rect.h"
78 #include "scissor.h"
79 #include "stencil.h"
80 #include "texobj.h"
81 #include "teximage.h"
82 #include "texstate.h"
83 #include "types.h"
84 #include "varray.h"
85 #include "vb.h"
86 #include "vbfill.h"
87 #include "vbxform.h"
88 #include "winpos.h"
89 #include "xform.h"
90 #ifdef XFree86Server
91 #undef MISC_H
92 #include "GL/xf86glx.h"
93 #endif
94 #endif
95
96
97
98 /*
99 Functions which aren't compiled but executed immediately:
100 glIsList
101 glGenLists
102 glDeleteLists
103 glEndList
104 glFeedbackBuffer
105 glSelectBuffer
106 glRenderMode
107 glReadPixels
108 glPixelStore
109 glFlush
110 glFinish
111 glIsEnabled
112 glGet*
113
114 Functions which cause errors if called while compiling a display list:
115 glNewList
116 */
117
118
119
120 /*
121 * Display list instructions are stored as sequences of "nodes". Nodes
122 * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
123 * are linked together with a pointer.
124 */
125
126
127 /* How many nodes to allocate at a time:
128 * - reduced now that we hold vertices etc. elsewhere.
129 */
130 #define BLOCK_SIZE 64
131
132
133 /*
134 * Display list opcodes.
135 *
136 * The fact that these identifiers are assigned consecutive
137 * integer values starting at 0 is very important, see InstSize array usage)
138 *
139 * KW: Commented out opcodes now handled by vertex-cassettes.
140 */
141 typedef enum {
142 OPCODE_ACCUM,
143 OPCODE_ALPHA_FUNC,
144 OPCODE_BIND_TEXTURE,
145 OPCODE_BITMAP,
146 OPCODE_BLEND_COLOR,
147 OPCODE_BLEND_EQUATION,
148 OPCODE_BLEND_FUNC,
149 OPCODE_BLEND_FUNC_SEPARATE,
150 OPCODE_CALL_LIST,
151 OPCODE_CALL_LIST_OFFSET,
152 OPCODE_CLEAR,
153 OPCODE_CLEAR_ACCUM,
154 OPCODE_CLEAR_COLOR,
155 OPCODE_CLEAR_DEPTH,
156 OPCODE_CLEAR_INDEX,
157 OPCODE_CLEAR_STENCIL,
158 OPCODE_CLIP_PLANE,
159 OPCODE_COLOR_MASK,
160 OPCODE_COLOR_MATERIAL,
161 OPCODE_COLOR_TABLE,
162 OPCODE_COLOR_SUB_TABLE,
163 OPCODE_COPY_PIXELS,
164 OPCODE_COPY_TEX_IMAGE1D,
165 OPCODE_COPY_TEX_IMAGE2D,
166 OPCODE_COPY_TEX_IMAGE3D,
167 OPCODE_COPY_TEX_SUB_IMAGE1D,
168 OPCODE_COPY_TEX_SUB_IMAGE2D,
169 OPCODE_COPY_TEX_SUB_IMAGE3D,
170 OPCODE_CULL_FACE,
171 OPCODE_DEPTH_FUNC,
172 OPCODE_DEPTH_MASK,
173 OPCODE_DEPTH_RANGE,
174 OPCODE_DISABLE,
175 OPCODE_DRAW_BUFFER,
176 OPCODE_DRAW_PIXELS,
177 OPCODE_ENABLE,
178 OPCODE_EVALCOORD1,
179 OPCODE_EVALCOORD2,
180 OPCODE_EVALMESH1,
181 OPCODE_EVALMESH2,
182 OPCODE_EVALPOINT1,
183 OPCODE_EVALPOINT2,
184 OPCODE_FOG,
185 OPCODE_FRONT_FACE,
186 OPCODE_FRUSTUM,
187 OPCODE_HINT,
188 OPCODE_INDEX_MASK,
189 OPCODE_INIT_NAMES,
190 OPCODE_LIGHT,
191 OPCODE_LIGHT_MODEL,
192 OPCODE_LINE_STIPPLE,
193 OPCODE_LINE_WIDTH,
194 OPCODE_LIST_BASE,
195 OPCODE_LOAD_IDENTITY,
196 OPCODE_LOAD_MATRIX,
197 OPCODE_LOAD_NAME,
198 OPCODE_LOGIC_OP,
199 OPCODE_MAP1,
200 OPCODE_MAP2,
201 OPCODE_MAPGRID1,
202 OPCODE_MAPGRID2,
203 OPCODE_MATRIX_MODE,
204 OPCODE_MULT_MATRIX,
205 OPCODE_ORTHO,
206 OPCODE_PASSTHROUGH,
207 OPCODE_PIXEL_MAP,
208 OPCODE_PIXEL_TRANSFER,
209 OPCODE_PIXEL_ZOOM,
210 OPCODE_POINT_SIZE,
211 OPCODE_POINT_PARAMETERS,
212 OPCODE_POLYGON_MODE,
213 OPCODE_POLYGON_STIPPLE,
214 OPCODE_POLYGON_OFFSET,
215 OPCODE_POP_ATTRIB,
216 OPCODE_POP_MATRIX,
217 OPCODE_POP_NAME,
218 OPCODE_PRIORITIZE_TEXTURE,
219 OPCODE_PUSH_ATTRIB,
220 OPCODE_PUSH_MATRIX,
221 OPCODE_PUSH_NAME,
222 OPCODE_RASTER_POS,
223 OPCODE_RECTF,
224 OPCODE_READ_BUFFER,
225 OPCODE_SCALE,
226 OPCODE_SCISSOR,
227 OPCODE_SELECT_TEXTURE_SGIS,
228 OPCODE_SELECT_TEXTURE_COORD_SET,
229 OPCODE_SHADE_MODEL,
230 OPCODE_STENCIL_FUNC,
231 OPCODE_STENCIL_MASK,
232 OPCODE_STENCIL_OP,
233 OPCODE_TEXENV,
234 OPCODE_TEXGEN,
235 OPCODE_TEXPARAMETER,
236 OPCODE_TEX_IMAGE1D,
237 OPCODE_TEX_IMAGE2D,
238 OPCODE_TEX_IMAGE3D,
239 OPCODE_TEX_SUB_IMAGE1D,
240 OPCODE_TEX_SUB_IMAGE2D,
241 OPCODE_TEX_SUB_IMAGE3D,
242 OPCODE_TRANSLATE,
243 OPCODE_VIEWPORT,
244 OPCODE_WINDOW_POS,
245 /* GL_ARB_multitexture */
246 OPCODE_ACTIVE_TEXTURE,
247 OPCODE_CLIENT_ACTIVE_TEXTURE,
248 /* The following three are meta instructions */
249 OPCODE_ERROR, /* raise compiled-in error */
250 OPCODE_VERTEX_CASSETTE, /* render prebuilt vertex buffer */
251 OPCODE_CONTINUE,
252 OPCODE_END_OF_LIST
253 } OpCode;
254
255
256 /*
257 * Each instruction in the display list is stored as a sequence of
258 * contiguous nodes in memory.
259 * Each node is the union of a variety of datatypes.
260 */
261 union node {
262 OpCode opcode;
263 GLboolean b;
264 GLbitfield bf;
265 GLubyte ub;
266 GLshort s;
267 GLushort us;
268 GLint i;
269 GLuint ui;
270 GLenum e;
271 GLfloat f;
272 GLvoid *data;
273 void *next; /* If prev node's opcode==OPCODE_CONTINUE */
274 };
275
276
277
278 /* Number of nodes of storage needed for each instruction: */
279 static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
280
281 void mesa_print_display_list( GLuint list );
282
283
284 /**********************************************************************/
285 /***** Private *****/
286 /**********************************************************************/
287
288
289 /*
290 * Allocate space for a display list instruction.
291 * Input: opcode - type of instruction
292 * argcount - number of arguments following the instruction
293 * Return: pointer to first node in the instruction
294 */
295 static Node *alloc_instruction( GLcontext *ctx, OpCode opcode, GLint argcount )
296 {
297 Node *n, *newblock;
298 GLuint count = InstSize[opcode];
299
300 assert( (GLint) count == argcount+1 );
301
302 if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
303 /* This block is full. Allocate a new block and chain to it */
304 n = ctx->CurrentBlock + ctx->CurrentPos;
305 n[0].opcode = OPCODE_CONTINUE;
306 newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
307 if (!newblock) {
308 gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
309 return NULL;
310 }
311 n[1].next = (Node *) newblock;
312 ctx->CurrentBlock = newblock;
313 ctx->CurrentPos = 0;
314 }
315
316 n = ctx->CurrentBlock + ctx->CurrentPos;
317 ctx->CurrentPos += count;
318
319 n[0].opcode = opcode;
320
321 return n;
322 }
323
324
325
326 /*
327 * Make an empty display list. This is used by glGenLists() to
328 * reserver display list IDs.
329 */
330 static Node *make_empty_list( void )
331 {
332 Node *n = (Node *) MALLOC( sizeof(Node) );
333 n[0].opcode = OPCODE_END_OF_LIST;
334 return n;
335 }
336
337
338
339 /*
340 * Destroy all nodes in a display list.
341 * Input: list - display list number
342 */
343 void gl_destroy_list( GLcontext *ctx, GLuint list )
344 {
345 Node *n, *block;
346 GLboolean done;
347
348 if (list==0)
349 return;
350
351 block = (Node *) HashLookup(ctx->Shared->DisplayList, list);
352 n = block;
353
354 done = block ? GL_FALSE : GL_TRUE;
355 while (!done) {
356 switch (n[0].opcode) {
357 /* special cases first */
358 case OPCODE_VERTEX_CASSETTE:
359 if ( ! -- ((struct immediate *) n[1].data)->ref_count )
360 gl_immediate_free( (struct immediate *) n[1].data );
361 n += InstSize[n[0].opcode];
362 break;
363 case OPCODE_MAP1:
364 gl_free_control_points( ctx, n[1].e, (GLfloat *) n[6].data );
365 n += InstSize[n[0].opcode];
366 break;
367 case OPCODE_MAP2:
368 gl_free_control_points( ctx, n[1].e, (GLfloat *) n[10].data );
369 n += InstSize[n[0].opcode];
370 break;
371 case OPCODE_DRAW_PIXELS:
372 gl_free_image( (struct gl_image *) n[1].data );
373 n += InstSize[n[0].opcode];
374 break;
375 case OPCODE_BITMAP:
376 gl_free_image( (struct gl_image *) n[7].data );
377 n += InstSize[n[0].opcode];
378 break;
379 case OPCODE_COLOR_TABLE:
380 gl_free_image( (struct gl_image *) n[3].data );
381 n += InstSize[n[0].opcode];
382 break;
383 case OPCODE_COLOR_SUB_TABLE:
384 gl_free_image( (struct gl_image *) n[3].data );
385 n += InstSize[n[0].opcode];
386 break;
387 case OPCODE_POLYGON_STIPPLE:
388 FREE( n[1].data );
389 n += InstSize[n[0].opcode];
390 break;
391 case OPCODE_TEX_IMAGE1D:
392 FREE( n[8]. data );
393 n += InstSize[n[0].opcode];
394 break;
395 case OPCODE_TEX_IMAGE2D:
396 FREE( n[9].data );
397 n += InstSize[n[0].opcode];
398 break;
399 case OPCODE_TEX_IMAGE3D:
400 FREE( n[10].data );
401 n += InstSize[n[0].opcode];
402 break;
403 case OPCODE_TEX_SUB_IMAGE1D:
404 FREE( n[7].data );
405 n += InstSize[n[0].opcode];
406 break;
407 case OPCODE_TEX_SUB_IMAGE2D:
408 FREE( n[9].data );
409 n += InstSize[n[0].opcode];
410 break;
411 case OPCODE_TEX_SUB_IMAGE3D:
412 FREE( n[11].data );
413 n += InstSize[n[0].opcode];
414 break;
415 case OPCODE_CONTINUE:
416 n = (Node *) n[1].next;
417 FREE( block );
418 block = n;
419 break;
420 case OPCODE_END_OF_LIST:
421 FREE( block );
422 done = GL_TRUE;
423 break;
424 default:
425 /* Most frequent case */
426 n += InstSize[n[0].opcode];
427 break;
428 }
429 }
430
431 HashRemove(ctx->Shared->DisplayList, list);
432 }
433
434
435
436 /*
437 * Translate the nth element of list from type to GLuint.
438 */
439 static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
440 {
441 GLbyte *bptr;
442 GLubyte *ubptr;
443 GLshort *sptr;
444 GLushort *usptr;
445 GLint *iptr;
446 GLuint *uiptr;
447 GLfloat *fptr;
448
449 switch (type) {
450 case GL_BYTE:
451 bptr = (GLbyte *) list;
452 return (GLuint) *(bptr+n);
453 case GL_UNSIGNED_BYTE:
454 ubptr = (GLubyte *) list;
455 return (GLuint) *(ubptr+n);
456 case GL_SHORT:
457 sptr = (GLshort *) list;
458 return (GLuint) *(sptr+n);
459 case GL_UNSIGNED_SHORT:
460 usptr = (GLushort *) list;
461 return (GLuint) *(usptr+n);
462 case GL_INT:
463 iptr = (GLint *) list;
464 return (GLuint) *(iptr+n);
465 case GL_UNSIGNED_INT:
466 uiptr = (GLuint *) list;
467 return (GLuint) *(uiptr+n);
468 case GL_FLOAT:
469 fptr = (GLfloat *) list;
470 return (GLuint) *(fptr+n);
471 case GL_2_BYTES:
472 ubptr = ((GLubyte *) list) + 2*n;
473 return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
474 case GL_3_BYTES:
475 ubptr = ((GLubyte *) list) + 3*n;
476 return (GLuint) *ubptr * 65536
477 + (GLuint) *(ubptr+1) * 256
478 + (GLuint) *(ubptr+2);
479 case GL_4_BYTES:
480 ubptr = ((GLubyte *) list) + 4*n;
481 return (GLuint) *ubptr * 16777216
482 + (GLuint) *(ubptr+1) * 65536
483 + (GLuint) *(ubptr+2) * 256
484 + (GLuint) *(ubptr+3);
485 default:
486 return 0;
487 }
488 }
489
490
491
492
493 /**********************************************************************/
494 /***** Public *****/
495 /**********************************************************************/
496
497 void gl_init_lists( void )
498 {
499 static int init_flag = 0;
500
501 if (init_flag==0) {
502 InstSize[OPCODE_ACCUM] = 3;
503 InstSize[OPCODE_ALPHA_FUNC] = 3;
504 InstSize[OPCODE_BIND_TEXTURE] = 3;
505 InstSize[OPCODE_BITMAP] = 8;
506 InstSize[OPCODE_BLEND_COLOR] = 5;
507 InstSize[OPCODE_BLEND_EQUATION] = 2;
508 InstSize[OPCODE_BLEND_FUNC] = 3;
509 InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5;
510 InstSize[OPCODE_CALL_LIST] = 2;
511 InstSize[OPCODE_CALL_LIST_OFFSET] = 2;
512 InstSize[OPCODE_CLEAR] = 2;
513 InstSize[OPCODE_CLEAR_ACCUM] = 5;
514 InstSize[OPCODE_CLEAR_COLOR] = 5;
515 InstSize[OPCODE_CLEAR_DEPTH] = 2;
516 InstSize[OPCODE_CLEAR_INDEX] = 2;
517 InstSize[OPCODE_CLEAR_STENCIL] = 2;
518 InstSize[OPCODE_CLIP_PLANE] = 6;
519 InstSize[OPCODE_COLOR_MASK] = 5;
520 InstSize[OPCODE_COLOR_MATERIAL] = 3;
521 InstSize[OPCODE_COLOR_TABLE] = 4;
522 InstSize[OPCODE_COLOR_SUB_TABLE] = 4;
523 InstSize[OPCODE_COPY_PIXELS] = 6;
524 InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8;
525 InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9;
526 InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7;
527 InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
528 InstSize[OPCODE_COPY_TEX_SUB_IMAGE3D] = 10;
529 InstSize[OPCODE_CULL_FACE] = 2;
530 InstSize[OPCODE_DEPTH_FUNC] = 2;
531 InstSize[OPCODE_DEPTH_MASK] = 2;
532 InstSize[OPCODE_DEPTH_RANGE] = 3;
533 InstSize[OPCODE_DISABLE] = 2;
534 InstSize[OPCODE_DRAW_BUFFER] = 2;
535 InstSize[OPCODE_DRAW_PIXELS] = 2;
536 InstSize[OPCODE_ENABLE] = 2;
537 InstSize[OPCODE_EVALCOORD1] = 2;
538 InstSize[OPCODE_EVALCOORD2] = 3;
539 InstSize[OPCODE_EVALMESH1] = 4;
540 InstSize[OPCODE_EVALMESH2] = 6;
541 InstSize[OPCODE_EVALPOINT1] = 2;
542 InstSize[OPCODE_EVALPOINT2] = 3;
543 InstSize[OPCODE_FOG] = 6;
544 InstSize[OPCODE_FRONT_FACE] = 2;
545 InstSize[OPCODE_FRUSTUM] = 7;
546 InstSize[OPCODE_HINT] = 3;
547 InstSize[OPCODE_INDEX_MASK] = 2;
548 InstSize[OPCODE_INIT_NAMES] = 1;
549 InstSize[OPCODE_LIGHT] = 7;
550 InstSize[OPCODE_LIGHT_MODEL] = 6;
551 InstSize[OPCODE_LINE_STIPPLE] = 3;
552 InstSize[OPCODE_LINE_WIDTH] = 2;
553 InstSize[OPCODE_LIST_BASE] = 2;
554 InstSize[OPCODE_LOAD_IDENTITY] = 1;
555 InstSize[OPCODE_LOAD_MATRIX] = 17;
556 InstSize[OPCODE_LOAD_NAME] = 2;
557 InstSize[OPCODE_LOGIC_OP] = 2;
558 InstSize[OPCODE_MAP1] = 7;
559 InstSize[OPCODE_MAP2] = 11;
560 InstSize[OPCODE_MAPGRID1] = 4;
561 InstSize[OPCODE_MAPGRID2] = 7;
562 InstSize[OPCODE_MATRIX_MODE] = 2;
563 InstSize[OPCODE_MULT_MATRIX] = 17;
564 InstSize[OPCODE_ORTHO] = 7;
565 InstSize[OPCODE_PASSTHROUGH] = 2;
566 InstSize[OPCODE_PIXEL_MAP] = 4;
567 InstSize[OPCODE_PIXEL_TRANSFER] = 3;
568 InstSize[OPCODE_PIXEL_ZOOM] = 3;
569 InstSize[OPCODE_POINT_SIZE] = 2;
570 InstSize[OPCODE_POINT_PARAMETERS] = 5;
571 InstSize[OPCODE_POLYGON_MODE] = 3;
572 InstSize[OPCODE_POLYGON_STIPPLE] = 2;
573 InstSize[OPCODE_POLYGON_OFFSET] = 3;
574 InstSize[OPCODE_POP_ATTRIB] = 1;
575 InstSize[OPCODE_POP_MATRIX] = 1;
576 InstSize[OPCODE_POP_NAME] = 1;
577 InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
578 InstSize[OPCODE_PUSH_ATTRIB] = 2;
579 InstSize[OPCODE_PUSH_MATRIX] = 1;
580 InstSize[OPCODE_PUSH_NAME] = 2;
581 InstSize[OPCODE_RASTER_POS] = 5;
582 InstSize[OPCODE_RECTF] = 5;
583 InstSize[OPCODE_READ_BUFFER] = 2;
584 InstSize[OPCODE_SCALE] = 4;
585 InstSize[OPCODE_SCISSOR] = 5;
586 InstSize[OPCODE_STENCIL_FUNC] = 4;
587 InstSize[OPCODE_STENCIL_MASK] = 2;
588 InstSize[OPCODE_STENCIL_OP] = 4;
589 InstSize[OPCODE_SHADE_MODEL] = 2;
590 InstSize[OPCODE_TEXENV] = 7;
591 InstSize[OPCODE_TEXGEN] = 7;
592 InstSize[OPCODE_TEXPARAMETER] = 7;
593 InstSize[OPCODE_TEX_IMAGE1D] = 9;
594 InstSize[OPCODE_TEX_IMAGE2D] = 10;
595 InstSize[OPCODE_TEX_IMAGE3D] = 11;
596 InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
597 InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
598 InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12;
599 InstSize[OPCODE_TRANSLATE] = 4;
600 InstSize[OPCODE_VIEWPORT] = 5;
601 InstSize[OPCODE_WINDOW_POS] = 5;
602 InstSize[OPCODE_CONTINUE] = 2;
603 InstSize[OPCODE_ERROR] = 3;
604 InstSize[OPCODE_VERTEX_CASSETTE] = 9;
605 InstSize[OPCODE_END_OF_LIST] = 1;
606 /* GL_ARB_multitexture */
607 InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
608 InstSize[OPCODE_CLIENT_ACTIVE_TEXTURE] = 2;
609 }
610 init_flag = 1;
611 }
612
613
614 /*
615 * Display List compilation functions
616 */
617
618
619
620 static void save_Accum( GLcontext *ctx, GLenum op, GLfloat value )
621 {
622 Node *n;
623 FLUSH_VB(ctx, "dlist");
624 n = alloc_instruction( ctx, OPCODE_ACCUM, 2 );
625 if (n) {
626 n[1].e = op;
627 n[2].f = value;
628 }
629 if (ctx->ExecuteFlag) {
630 (*ctx->Exec.Accum)( ctx, op, value );
631 }
632 }
633
634
635 static void save_AlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref )
636 {
637 Node *n;
638 FLUSH_VB(ctx, "dlist");
639 n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 );
640 if (n) {
641 n[1].e = func;
642 n[2].f = (GLfloat) ref;
643 }
644 if (ctx->ExecuteFlag) {
645 (*ctx->Exec.AlphaFunc)( ctx, func, ref );
646 }
647 }
648
649 static void save_BindTexture( GLcontext *ctx, GLenum target, GLuint texture )
650 {
651 Node *n;
652 FLUSH_VB(ctx, "dlist");
653 n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 );
654 if (n) {
655 n[1].e = target;
656 n[2].ui = texture;
657 }
658 if (ctx->ExecuteFlag) {
659 (*ctx->Exec.BindTexture)( ctx, target, texture );
660 }
661 }
662
663
664 static void save_Bitmap( GLcontext *ctx,
665 GLsizei width, GLsizei height,
666 GLfloat xorig, GLfloat yorig,
667 GLfloat xmove, GLfloat ymove,
668 const GLubyte *bitmap,
669 const struct gl_pixelstore_attrib *packing )
670 {
671 Node *n;
672 FLUSH_VB(ctx, "dlist");
673 n = alloc_instruction( ctx, OPCODE_BITMAP, 7 );
674 if (n) {
675 struct gl_image *image = gl_unpack_bitmap( ctx, width, height,
676 bitmap, packing );
677 if (image) {
678 image->RefCount = 1;
679 }
680 n[1].i = (GLint) width;
681 n[2].i = (GLint) height;
682 n[3].f = xorig;
683 n[4].f = yorig;
684 n[5].f = xmove;
685 n[6].f = ymove;
686 n[7].data = (void *) image;
687 }
688 if (ctx->ExecuteFlag) {
689 (*ctx->Exec.Bitmap)( ctx, width, height,
690 xorig, yorig, xmove, ymove, bitmap, packing );
691 }
692 }
693
694
695 static void save_BlendEquation( GLcontext *ctx, GLenum mode )
696 {
697 Node *n;
698 FLUSH_VB(ctx, "dlist");
699 n = alloc_instruction( ctx, OPCODE_BLEND_EQUATION, 1 );
700 if (n) {
701 n[1].e = mode;
702 }
703 if (ctx->ExecuteFlag) {
704 (*ctx->Exec.BlendEquation)( ctx, mode );
705 }
706 }
707
708
709 static void save_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
710 {
711 Node *n;
712 FLUSH_VB(ctx, "dlist");
713 n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 );
714 if (n) {
715 n[1].e = sfactor;
716 n[2].e = dfactor;
717 }
718 if (ctx->ExecuteFlag) {
719 (*ctx->Exec.BlendFunc)( ctx, sfactor, dfactor );
720 }
721 }
722
723
724 static void save_BlendFuncSeparate( GLcontext *ctx,
725 GLenum sfactorRGB, GLenum dfactorRGB,
726 GLenum sfactorA, GLenum dfactorA)
727 {
728 Node *n;
729 FLUSH_VB(ctx, "dlist");
730 n = alloc_instruction( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
731 if (n) {
732 n[1].e = sfactorRGB;
733 n[2].e = dfactorRGB;
734 n[3].e = sfactorA;
735 n[4].e = dfactorA;
736 }
737 if (ctx->ExecuteFlag) {
738 (*ctx->Exec.BlendFuncSeparate)( ctx, sfactorRGB, dfactorRGB,
739 sfactorA, dfactorA);
740 }
741 }
742
743
744 static void save_BlendColor( GLcontext *ctx, GLfloat red, GLfloat green,
745 GLfloat blue, GLfloat alpha )
746 {
747 Node *n;
748 FLUSH_VB(ctx, "dlist");
749 n = alloc_instruction( ctx, OPCODE_BLEND_COLOR, 4 );
750 if (n) {
751 n[1].f = red;
752 n[2].f = green;
753 n[3].f = blue;
754 n[4].f = alpha;
755 }
756 if (ctx->ExecuteFlag) {
757 (*ctx->Exec.BlendColor)( ctx, red, green, blue, alpha );
758 }
759 }
760
761
762 static void save_CallList( GLcontext *ctx, GLuint list )
763 {
764 Node *n;
765 FLUSH_VB(ctx, "dlist");
766 n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 );
767 if (n) {
768 n[1].ui = list;
769 }
770 if (ctx->ExecuteFlag) {
771 (*ctx->Exec.CallList)( ctx, list );
772 }
773 }
774
775
776 static void save_CallLists( GLcontext *ctx,
777 GLsizei n, GLenum type, const GLvoid *lists )
778 {
779 GLint i;
780 FLUSH_VB(ctx, "dlist");
781
782 for (i=0;i<n;i++) {
783 GLuint list = translate_id( i, type, lists );
784 Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST_OFFSET, 1 );
785 if (n) {
786 n[1].ui = list;
787 }
788 }
789 if (ctx->ExecuteFlag) {
790 (*ctx->Exec.CallLists)( ctx, n, type, lists );
791 }
792 }
793
794
795 static void save_Clear( GLcontext *ctx, GLbitfield mask )
796 {
797 Node *n;
798 FLUSH_VB(ctx, "dlist");
799 n = alloc_instruction( ctx, OPCODE_CLEAR, 1 );
800 if (n) {
801 n[1].bf = mask;
802 }
803 if (ctx->ExecuteFlag) {
804 (*ctx->Exec.Clear)( ctx, mask );
805 }
806 }
807
808
809 static void save_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green,
810 GLfloat blue, GLfloat alpha )
811 {
812 Node *n;
813 FLUSH_VB(ctx, "dlist");
814 n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 );
815 if (n) {
816 n[1].f = red;
817 n[2].f = green;
818 n[3].f = blue;
819 n[4].f = alpha;
820 }
821 if (ctx->ExecuteFlag) {
822 (*ctx->Exec.ClearAccum)( ctx, red, green, blue, alpha );
823 }
824 }
825
826
827 static void save_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green,
828 GLclampf blue, GLclampf alpha )
829 {
830 Node *n;
831 FLUSH_VB(ctx, "dlist");
832 n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 );
833 if (n) {
834 n[1].f = red;
835 n[2].f = green;
836 n[3].f = blue;
837 n[4].f = alpha;
838 }
839 if (ctx->ExecuteFlag) {
840 (*ctx->Exec.ClearColor)( ctx, red, green, blue, alpha );
841 }
842 }
843
844
845 static void save_ClearDepth( GLcontext *ctx, GLclampd depth )
846 {
847 Node *n;
848 FLUSH_VB(ctx, "dlist");
849 n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 );
850 if (n) {
851 n[1].f = (GLfloat) depth;
852 }
853 if (ctx->ExecuteFlag) {
854 (*ctx->Exec.ClearDepth)( ctx, depth );
855 }
856 }
857
858
859 static void save_ClearIndex( GLcontext *ctx, GLfloat c )
860 {
861 Node *n;
862 FLUSH_VB(ctx, "dlist");
863 n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 );
864 if (n) {
865 n[1].f = c;
866 }
867 if (ctx->ExecuteFlag) {
868 (*ctx->Exec.ClearIndex)( ctx, c );
869 }
870 }
871
872
873 static void save_ClearStencil( GLcontext *ctx, GLint s )
874 {
875 Node *n;
876 FLUSH_VB(ctx, "dlist");
877 n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 );
878 if (n) {
879 n[1].i = s;
880 }
881 if (ctx->ExecuteFlag) {
882 (*ctx->Exec.ClearStencil)( ctx, s );
883 }
884 }
885
886
887 static void save_ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *equ )
888 {
889 Node *n;
890 FLUSH_VB(ctx, "dlist");
891 n = alloc_instruction( ctx, OPCODE_CLIP_PLANE, 5 );
892 if (n) {
893 n[1].e = plane;
894 n[2].f = equ[0];
895 n[3].f = equ[1];
896 n[4].f = equ[2];
897 n[5].f = equ[3];
898 }
899 if (ctx->ExecuteFlag) {
900 (*ctx->Exec.ClipPlane)( ctx, plane, equ );
901 }
902 }
903
904
905
906 static void save_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green,
907 GLboolean blue, GLboolean alpha )
908 {
909 Node *n;
910 FLUSH_VB(ctx, "dlist");
911 n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 );
912 if (n) {
913 n[1].b = red;
914 n[2].b = green;
915 n[3].b = blue;
916 n[4].b = alpha;
917 }
918 if (ctx->ExecuteFlag) {
919 (*ctx->Exec.ColorMask)( ctx, red, green, blue, alpha );
920 }
921 }
922
923
924 static void save_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
925 {
926 Node *n;
927 FLUSH_VB(ctx, "dlist");
928 n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 );
929 if (n) {
930 n[1].e = face;
931 n[2].e = mode;
932 }
933 if (ctx->ExecuteFlag) {
934 (*ctx->Exec.ColorMaterial)( ctx, face, mode );
935 }
936 }
937
938
939 static void save_ColorTable( GLcontext *ctx, GLenum target, GLenum internalFormat,
940 struct gl_image *table )
941 {
942 Node *n;
943 FLUSH_VB(ctx, "dlist");
944 n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 3 );
945 if (n) {
946 n[1].e = target;
947 n[2].e = internalFormat;
948 n[3].data = (GLvoid *) table;
949 if (table) {
950 /* must retain this image */
951 table->RefCount = 1;
952 }
953 }
954 if (ctx->ExecuteFlag) {
955 (*ctx->Exec.ColorTable)( ctx, target, internalFormat, table );
956 }
957 }
958
959
960 static void save_ColorSubTable( GLcontext *ctx, GLenum target,
961 GLsizei start, struct gl_image *data )
962 {
963 Node *n;
964 FLUSH_VB(ctx, "dlist");
965 n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 3 );
966 if (n) {
967 n[1].e = target;
968 n[2].i = start;
969 n[3].data = (GLvoid *) data;
970 if (data) {
971 /* must retain this image */
972 data->RefCount = 1;
973 }
974 }
975 if (ctx->ExecuteFlag) {
976 (*ctx->Exec.ColorSubTable)( ctx, target, start, data );
977 }
978 }
979
980
981
982 static void save_CopyPixels( GLcontext *ctx, GLint x, GLint y,
983 GLsizei width, GLsizei height, GLenum type )
984 {
985 Node *n;
986 FLUSH_VB(ctx, "dlist");
987 n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 );
988 if (n) {
989 n[1].i = x;
990 n[2].i = y;
991 n[3].i = (GLint) width;
992 n[4].i = (GLint) height;
993 n[5].e = type;
994 }
995 if (ctx->ExecuteFlag) {
996 (*ctx->Exec.CopyPixels)( ctx, x, y, width, height, type );
997 }
998 }
999
1000
1001
1002 static void save_CopyTexImage1D( GLcontext *ctx,
1003 GLenum target, GLint level,
1004 GLenum internalformat,
1005 GLint x, GLint y, GLsizei width,
1006 GLint border )
1007 {
1008 Node *n;
1009 FLUSH_VB(ctx, "dlist");
1010 n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
1011 if (n) {
1012 n[1].e = target;
1013 n[2].i = level;
1014 n[3].e = internalformat;
1015 n[4].i = x;
1016 n[5].i = y;
1017 n[6].i = width;
1018 n[7].i = border;
1019 }
1020 if (ctx->ExecuteFlag) {
1021 (*ctx->Exec.CopyTexImage1D)( ctx, target, level, internalformat,
1022 x, y, width, border );
1023 }
1024 }
1025
1026
1027 static void save_CopyTexImage2D( GLcontext *ctx,
1028 GLenum target, GLint level,
1029 GLenum internalformat,
1030 GLint x, GLint y, GLsizei width,
1031 GLsizei height, GLint border )
1032 {
1033 Node *n;
1034 FLUSH_VB(ctx, "dlist");
1035 n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
1036 if (n) {
1037 n[1].e = target;
1038 n[2].i = level;
1039 n[3].e = internalformat;
1040 n[4].i = x;
1041 n[5].i = y;
1042 n[6].i = width;
1043 n[7].i = height;
1044 n[8].i = border;
1045 }
1046 if (ctx->ExecuteFlag) {
1047 (*ctx->Exec.CopyTexImage2D)( ctx, target, level, internalformat,
1048 x, y, width, height, border );
1049 }
1050 }
1051
1052
1053
1054 static void save_CopyTexSubImage1D( GLcontext *ctx,
1055 GLenum target, GLint level,
1056 GLint xoffset, GLint x, GLint y,
1057 GLsizei width )
1058 {
1059 Node *n;
1060 FLUSH_VB(ctx, "dlist");
1061 n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
1062 if (n) {
1063 n[1].e = target;
1064 n[2].i = level;
1065 n[3].i = xoffset;
1066 n[4].i = x;
1067 n[5].i = y;
1068 n[6].i = width;
1069 }
1070 if (ctx->ExecuteFlag) {
1071 (*ctx->Exec.CopyTexSubImage1D)( ctx, target, level, xoffset, x, y, width );
1072 }
1073 }
1074
1075
1076 static void save_CopyTexSubImage2D( GLcontext *ctx,
1077 GLenum target, GLint level,
1078 GLint xoffset, GLint yoffset,
1079 GLint x, GLint y,
1080 GLsizei width, GLint height )
1081 {
1082 Node *n;
1083 FLUSH_VB(ctx, "dlist");
1084 n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
1085 if (n) {
1086 n[1].e = target;
1087 n[2].i = level;
1088 n[3].i = xoffset;
1089 n[4].i = yoffset;
1090 n[5].i = x;
1091 n[6].i = y;
1092 n[7].i = width;
1093 n[8].i = height;
1094 }
1095 if (ctx->ExecuteFlag) {
1096 (*ctx->Exec.CopyTexSubImage2D)( ctx, target, level, xoffset, yoffset,
1097 x, y, width, height );
1098 }
1099 }
1100
1101
1102 static void save_CopyTexSubImage3D( GLcontext *ctx,
1103 GLenum target, GLint level,
1104 GLint xoffset, GLint yoffset,
1105 GLint zoffset,
1106 GLint x, GLint y,
1107 GLsizei width, GLint height )
1108 {
1109 Node *n;
1110 FLUSH_VB(ctx, "dlist");
1111 n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
1112 if (n) {
1113 n[1].e = target;
1114 n[2].i = level;
1115 n[3].i = xoffset;
1116 n[4].i = yoffset;
1117 n[5].i = zoffset;
1118 n[6].i = x;
1119 n[7].i = y;
1120 n[8].i = width;
1121 n[9].i = height;
1122 }
1123 if (ctx->ExecuteFlag) {
1124 (*ctx->Exec.CopyTexSubImage3D)(ctx, target, level, xoffset, yoffset,
1125 zoffset, x, y, width, height );
1126 }
1127 }
1128
1129
1130 static void save_CullFace( GLcontext *ctx, GLenum mode )
1131 {
1132 Node *n;
1133 FLUSH_VB(ctx, "dlist");
1134 n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 );
1135 if (n) {
1136 n[1].e = mode;
1137 }
1138 if (ctx->ExecuteFlag) {
1139 (*ctx->Exec.CullFace)( ctx, mode );
1140 }
1141 }
1142
1143
1144 static void save_DepthFunc( GLcontext *ctx, GLenum func )
1145 {
1146 Node *n;
1147 FLUSH_VB(ctx, "dlist");
1148 n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 );
1149 if (n) {
1150 n[1].e = func;
1151 }
1152 if (ctx->ExecuteFlag) {
1153 (*ctx->Exec.DepthFunc)( ctx, func );
1154 }
1155 }
1156
1157
1158 static void save_DepthMask( GLcontext *ctx, GLboolean mask )
1159 {
1160 Node *n;
1161 FLUSH_VB(ctx, "dlist");
1162 n = alloc_instruction( ctx, OPCODE_DEPTH_MASK, 1 );
1163 if (n) {
1164 n[1].b = mask;
1165 }
1166 if (ctx->ExecuteFlag) {
1167 (*ctx->Exec.DepthMask)( ctx, mask );
1168 }
1169 }
1170
1171
1172 static void save_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval )
1173 {
1174 Node *n;
1175 FLUSH_VB(ctx, "dlist");
1176 n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 );
1177 if (n) {
1178 n[1].f = (GLfloat) nearval;
1179 n[2].f = (GLfloat) farval;
1180 }
1181 if (ctx->ExecuteFlag) {
1182 (*ctx->Exec.DepthRange)( ctx, nearval, farval );
1183 }
1184 }
1185
1186
1187 static void save_Disable( GLcontext *ctx, GLenum cap )
1188 {
1189 Node *n;
1190 FLUSH_VB(ctx, "dlist");
1191 n = alloc_instruction( ctx, OPCODE_DISABLE, 1 );
1192 if (n) {
1193 n[1].e = cap;
1194 }
1195 if (ctx->ExecuteFlag) {
1196 (*ctx->Exec.Disable)( ctx, cap );
1197 }
1198 }
1199
1200
1201 static void save_DrawBuffer( GLcontext *ctx, GLenum mode )
1202 {
1203 Node *n;
1204 FLUSH_VB(ctx, "dlist");
1205 n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 );
1206 if (n) {
1207 n[1].e = mode;
1208 }
1209 if (ctx->ExecuteFlag) {
1210 (*ctx->Exec.DrawBuffer)( ctx, mode );
1211 }
1212 }
1213
1214
1215 static void save_DrawPixels( GLcontext *ctx, struct gl_image *image )
1216 {
1217 Node *n;
1218 FLUSH_VB(ctx, "dlist");
1219 n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 1 );
1220 if (n) {
1221 n[1].data = (GLvoid *) image;
1222 }
1223 if (image) {
1224 image->RefCount = 1;
1225 }
1226 if (ctx->ExecuteFlag) {
1227 (*ctx->Exec.DrawPixels)( ctx, image );
1228 }
1229 }
1230
1231
1232
1233 static void save_Enable( GLcontext *ctx, GLenum cap )
1234 {
1235 Node *n;
1236 FLUSH_VB(ctx, "dlist");
1237 n = alloc_instruction( ctx, OPCODE_ENABLE, 1 );
1238 if (n) {
1239 n[1].e = cap;
1240 }
1241 if (ctx->ExecuteFlag) {
1242 (*ctx->Exec.Enable)( ctx, cap );
1243 }
1244 }
1245
1246
1247
1248 static void save_EvalMesh1( GLcontext *ctx,
1249 GLenum mode, GLint i1, GLint i2 )
1250 {
1251 Node *n;
1252 FLUSH_VB(ctx, "dlist");
1253 n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 );
1254 if (n) {
1255 n[1].e = mode;
1256 n[2].i = i1;
1257 n[3].i = i2;
1258 }
1259 if (ctx->ExecuteFlag) {
1260 (*ctx->Exec.EvalMesh1)( ctx, mode, i1, i2 );
1261 }
1262 }
1263
1264
1265 static void save_EvalMesh2( GLcontext *ctx,
1266 GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
1267 {
1268 Node *n;
1269 FLUSH_VB(ctx, "dlist");
1270 n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 );
1271 if (n) {
1272 n[1].e = mode;
1273 n[2].i = i1;
1274 n[3].i = i2;
1275 n[4].i = j1;
1276 n[5].i = j2;
1277 }
1278 if (ctx->ExecuteFlag) {
1279 (*ctx->Exec.EvalMesh2)( ctx, mode, i1, i2, j1, j2 );
1280 }
1281 }
1282
1283
1284
1285
1286 static void save_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
1287 {
1288 Node *n;
1289 FLUSH_VB(ctx, "dlist");
1290 n = alloc_instruction( ctx, OPCODE_FOG, 5 );
1291 if (n) {
1292 n[1].e = pname;
1293 n[2].f = params[0];
1294 n[3].f = params[1];
1295 n[4].f = params[2];
1296 n[5].f = params[3];
1297 }
1298 if (ctx->ExecuteFlag) {
1299 (*ctx->Exec.Fogfv)( ctx, pname, params );
1300 }
1301 }
1302
1303
1304 static void save_FrontFace( GLcontext *ctx, GLenum mode )
1305 {
1306 Node *n;
1307 FLUSH_VB(ctx, "dlist");
1308 n = alloc_instruction( ctx, OPCODE_FRONT_FACE, 1 );
1309 if (n) {
1310 n[1].e = mode;
1311 }
1312 if (ctx->ExecuteFlag) {
1313 (*ctx->Exec.FrontFace)( ctx, mode );
1314 }
1315 }
1316
1317
1318 static void save_Frustum( GLcontext *ctx, GLdouble left, GLdouble right,
1319 GLdouble bottom, GLdouble top,
1320 GLdouble nearval, GLdouble farval )
1321 {
1322 Node *n;
1323 FLUSH_VB(ctx, "dlist");
1324 n = alloc_instruction( ctx, OPCODE_FRUSTUM, 6 );
1325 if (n) {
1326 n[1].f = left;
1327 n[2].f = right;
1328 n[3].f = bottom;
1329 n[4].f = top;
1330 n[5].f = nearval;
1331 n[6].f = farval;
1332 }
1333 if (ctx->ExecuteFlag) {
1334 (*ctx->Exec.Frustum)( ctx, left, right, bottom, top, nearval, farval );
1335 }
1336 }
1337
1338
1339 static GLboolean save_Hint( GLcontext *ctx, GLenum target, GLenum mode )
1340 {
1341 Node *n;
1342 FLUSH_VB(ctx, "dlist");
1343 n = alloc_instruction( ctx, OPCODE_HINT, 2 );
1344 if (n) {
1345 n[1].e = target;
1346 n[2].e = mode;
1347 }
1348 if (ctx->ExecuteFlag) {
1349 return (*ctx->Exec.Hint)( ctx, target, mode );
1350 }
1351 return GL_TRUE; /* not queried */
1352 }
1353
1354
1355
1356 static void save_IndexMask( GLcontext *ctx, GLuint mask )
1357 {
1358 Node *n;
1359 FLUSH_VB(ctx, "dlist");
1360 n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 );
1361 if (n) {
1362 n[1].ui = mask;
1363 }
1364 if (ctx->ExecuteFlag) {
1365 (*ctx->Exec.IndexMask)( ctx, mask );
1366 }
1367 }
1368
1369
1370 static void save_InitNames( GLcontext *ctx )
1371 {
1372 FLUSH_VB(ctx, "dlist");
1373 (void) alloc_instruction( ctx, OPCODE_INIT_NAMES, 0 );
1374 if (ctx->ExecuteFlag) {
1375 (*ctx->Exec.InitNames)( ctx );
1376 }
1377 }
1378
1379
1380 static void save_Lightfv( GLcontext *ctx, GLenum light, GLenum pname,
1381 const GLfloat *params, GLint numparams )
1382 {
1383 Node *n;
1384 FLUSH_VB(ctx, "dlist");
1385 n = alloc_instruction( ctx, OPCODE_LIGHT, 6 );
1386 if (OPCODE_LIGHT) {
1387 GLint i;
1388 n[1].e = light;
1389 n[2].e = pname;
1390 for (i=0;i<numparams;i++) {
1391 n[3+i].f = params[i];
1392 }
1393 }
1394 if (ctx->ExecuteFlag) {
1395 (*ctx->Exec.Lightfv)( ctx, light, pname, params, numparams );
1396 }
1397 }
1398
1399
1400 static void save_LightModelfv( GLcontext *ctx,
1401 GLenum pname, const GLfloat *params )
1402 {
1403 Node *n;
1404 FLUSH_VB(ctx, "dlist");
1405 n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 );
1406 if (n) {
1407 n[1].e = pname;
1408 n[2].f = params[0];
1409 n[3].f = params[1];
1410 n[4].f = params[2];
1411 n[5].f = params[3];
1412 }
1413 if (ctx->ExecuteFlag) {
1414 (*ctx->Exec.LightModelfv)( ctx, pname, params );
1415 }
1416 }
1417
1418
1419 static void save_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
1420 {
1421 Node *n;
1422 FLUSH_VB(ctx, "dlist");
1423 n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 );
1424 if (n) {
1425 n[1].i = factor;
1426 n[2].us = pattern;
1427 }
1428 if (ctx->ExecuteFlag) {
1429 (*ctx->Exec.LineStipple)( ctx, factor, pattern );
1430 }
1431 }
1432
1433
1434 static void save_LineWidth( GLcontext *ctx, GLfloat width )
1435 {
1436 Node *n;
1437 FLUSH_VB(ctx, "dlist");
1438 n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 );
1439 if (n) {
1440 n[1].f = width;
1441 }
1442 if (ctx->ExecuteFlag) {
1443 (*ctx->Exec.LineWidth)( ctx, width );
1444 }
1445 }
1446
1447
1448 static void save_ListBase( GLcontext *ctx, GLuint base )
1449 {
1450 Node *n;
1451 FLUSH_VB(ctx, "dlist");
1452 n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 );
1453 if (n) {
1454 n[1].ui = base;
1455 }
1456 if (ctx->ExecuteFlag) {
1457 (*ctx->Exec.ListBase)( ctx, base );
1458 }
1459 }
1460
1461
1462 static void save_LoadIdentity( GLcontext *ctx )
1463 {
1464 FLUSH_VB(ctx, "dlist");
1465 (void) alloc_instruction( ctx, OPCODE_LOAD_IDENTITY, 0 );
1466 if (ctx->ExecuteFlag) {
1467 (*ctx->Exec.LoadIdentity)( ctx );
1468 }
1469 }
1470
1471
1472 static void save_LoadMatrixf( GLcontext *ctx, const GLfloat *m )
1473 {
1474 Node *n;
1475 FLUSH_VB(ctx, "dlist");
1476 n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 );
1477 if (n) {
1478 GLuint i;
1479 for (i=0;i<16;i++) {
1480 n[1+i].f = m[i];
1481 }
1482 }
1483 if (ctx->ExecuteFlag) {
1484 (*ctx->Exec.LoadMatrixf)( ctx, m );
1485 }
1486 }
1487
1488
1489 static void save_LoadName( GLcontext *ctx, GLuint name )
1490 {
1491 Node *n;
1492 FLUSH_VB(ctx, "dlist");
1493 n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 );
1494 if (n) {
1495 n[1].ui = name;
1496 }
1497 if (ctx->ExecuteFlag) {
1498 (*ctx->Exec.LoadName)( ctx, name );
1499 }
1500 }
1501
1502
1503 static void save_LogicOp( GLcontext *ctx, GLenum opcode )
1504 {
1505 Node *n;
1506 FLUSH_VB(ctx, "dlist");
1507 n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 );
1508 if (n) {
1509 n[1].e = opcode;
1510 }
1511 if (ctx->ExecuteFlag) {
1512 (*ctx->Exec.LogicOp)( ctx, opcode );
1513 }
1514 }
1515
1516
1517 static void save_Map1f( GLcontext *ctx,
1518 GLenum target, GLfloat u1, GLfloat u2, GLint stride,
1519 GLint order, const GLfloat *points, GLboolean retain )
1520 {
1521 Node *n;
1522 FLUSH_VB(ctx, "dlist");
1523 n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
1524 if (n) {
1525 n[1].e = target;
1526 n[2].f = u1;
1527 n[3].f = u2;
1528 n[4].i = stride;
1529 n[5].i = order;
1530 n[6].data = (void *) points;
1531 }
1532 if (ctx->ExecuteFlag) {
1533 (*ctx->Exec.Map1f)( ctx, target, u1, u2, stride, order, points, GL_TRUE );
1534 }
1535 (void) retain;
1536 }
1537
1538
1539 static void save_Map2f( GLcontext *ctx, GLenum target,
1540 GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
1541 GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
1542 const GLfloat *points, GLboolean retain )
1543 {
1544 Node *n;
1545 FLUSH_VB(ctx, "dlist");
1546 n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
1547 if (n) {
1548 n[1].e = target;
1549 n[2].f = u1;
1550 n[3].f = u2;
1551 n[4].f = v1;
1552 n[5].f = v2;
1553 n[6].i = ustride;
1554 n[7].i = vstride;
1555 n[8].i = uorder;
1556 n[9].i = vorder;
1557 n[10].data = (void *) points;
1558 }
1559 if (ctx->ExecuteFlag) {
1560 (*ctx->Exec.Map2f)( ctx, target,
1561 u1, u2, ustride, uorder,
1562 v1, v2, vstride, vorder, points, GL_TRUE );
1563 }
1564 (void) retain;
1565 }
1566
1567
1568 static void save_MapGrid1f( GLcontext *ctx, GLint un, GLfloat u1, GLfloat u2 )
1569 {
1570 Node *n;
1571 FLUSH_VB(ctx, "dlist");
1572 n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 );
1573 if (n) {
1574 n[1].i = un;
1575 n[2].f = u1;
1576 n[3].f = u2;
1577 }
1578 if (ctx->ExecuteFlag) {
1579 (*ctx->Exec.MapGrid1f)( ctx, un, u1, u2 );
1580 }
1581 }
1582
1583
1584 static void save_MapGrid2f( GLcontext *ctx,
1585 GLint un, GLfloat u1, GLfloat u2,
1586 GLint vn, GLfloat v1, GLfloat v2 )
1587 {
1588 Node *n;
1589 FLUSH_VB(ctx, "dlist");
1590 n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 );
1591 if (n) {
1592 n[1].i = un;
1593 n[2].f = u1;
1594 n[3].f = u2;
1595 n[4].i = vn;
1596 n[5].f = v1;
1597 n[6].f = v2;
1598 }
1599 if (ctx->ExecuteFlag) {
1600 (*ctx->Exec.MapGrid2f)( ctx, un, u1, u2, vn, v1, v2 );
1601 }
1602 }
1603
1604
1605 static void save_MatrixMode( GLcontext *ctx, GLenum mode )
1606 {
1607 Node *n;
1608 FLUSH_VB(ctx, "dlist");
1609 n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 );
1610 if (n) {
1611 n[1].e = mode;
1612 }
1613 if (ctx->ExecuteFlag) {
1614 (*ctx->Exec.MatrixMode)( ctx, mode );
1615 }
1616 }
1617
1618
1619 static void save_MultMatrixf( GLcontext *ctx, const GLfloat *m )
1620 {
1621 Node *n;
1622 FLUSH_VB(ctx, "dlist");
1623 n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 );
1624 if (n) {
1625 GLuint i;
1626 for (i=0;i<16;i++) {
1627 n[1+i].f = m[i];
1628 }
1629 }
1630 if (ctx->ExecuteFlag) {
1631 (*ctx->Exec.MultMatrixf)( ctx, m );
1632 }
1633 }
1634
1635
1636 static void save_NewList( GLcontext *ctx, GLuint list, GLenum mode )
1637 {
1638 /* It's an error to call this function while building a display list */
1639 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
1640 (void) list;
1641 (void) mode;
1642 }
1643
1644
1645
1646 static void save_Ortho( GLcontext *ctx, GLdouble left, GLdouble right,
1647 GLdouble bottom, GLdouble top,
1648 GLdouble nearval, GLdouble farval )
1649 {
1650 Node *n;
1651 FLUSH_VB(ctx, "dlist");
1652 n = alloc_instruction( ctx, OPCODE_ORTHO, 6 );
1653 if (n) {
1654 n[1].f = left;
1655 n[2].f = right;
1656 n[3].f = bottom;
1657 n[4].f = top;
1658 n[5].f = nearval;
1659 n[6].f = farval;
1660 }
1661 if (ctx->ExecuteFlag) {
1662 (*ctx->Exec.Ortho)( ctx, left, right, bottom, top, nearval, farval );
1663 }
1664 }
1665
1666
1667 static void save_PixelMapfv( GLcontext *ctx,
1668 GLenum map, GLint mapsize, const GLfloat *values )
1669 {
1670 Node *n;
1671 FLUSH_VB(ctx, "dlist");
1672 n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 );
1673 if (n) {
1674 n[1].e = map;
1675 n[2].i = mapsize;
1676 n[3].data = (void *) MALLOC( mapsize * sizeof(GLfloat) );
1677 MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
1678 }
1679 if (ctx->ExecuteFlag) {
1680 (*ctx->Exec.PixelMapfv)( ctx, map, mapsize, values );
1681 }
1682 }
1683
1684
1685 static void save_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param )
1686 {
1687 Node *n;
1688 FLUSH_VB(ctx, "dlist");
1689 n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 );
1690 if (n) {
1691 n[1].e = pname;
1692 n[2].f = param;
1693 }
1694 if (ctx->ExecuteFlag) {
1695 (*ctx->Exec.PixelTransferf)( ctx, pname, param );
1696 }
1697 }
1698
1699
1700 static void save_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor )
1701 {
1702 Node *n;
1703 FLUSH_VB(ctx, "dlist");
1704 n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 );
1705 if (n) {
1706 n[1].f = xfactor;
1707 n[2].f = yfactor;
1708 }
1709 if (ctx->ExecuteFlag) {
1710 (*ctx->Exec.PixelZoom)( ctx, xfactor, yfactor );
1711 }
1712 }
1713
1714
1715 static void save_PointParameterfvEXT( GLcontext *ctx, GLenum pname,
1716 const GLfloat *params)
1717 {
1718 Node *n;
1719 FLUSH_VB(ctx, "dlist");
1720 n = alloc_instruction( ctx, OPCODE_POINT_PARAMETERS, 4 );
1721 if (n) {
1722 n[1].e = pname;
1723 n[2].f = params[0];
1724 n[3].f = params[1];
1725 n[4].f = params[2];
1726 }
1727 if (ctx->ExecuteFlag) {
1728 (*ctx->Exec.PointParameterfvEXT)( ctx, pname, params );
1729 }
1730 }
1731
1732
1733 static void save_PointSize( GLcontext *ctx, GLfloat size )
1734 {
1735 Node *n;
1736 FLUSH_VB(ctx, "dlist");
1737 n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 );
1738 if (n) {
1739 n[1].f = size;
1740 }
1741 if (ctx->ExecuteFlag) {
1742 (*ctx->Exec.PointSize)( ctx, size );
1743 }
1744 }
1745
1746
1747 static void save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
1748 {
1749 Node *n;
1750 FLUSH_VB(ctx, "dlist");
1751 n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 );
1752 if (n) {
1753 n[1].e = face;
1754 n[2].e = mode;
1755 }
1756 if (ctx->ExecuteFlag) {
1757 (*ctx->Exec.PolygonMode)( ctx, face, mode );
1758 }
1759 }
1760
1761
1762 /*
1763 * Polygon stipple must have been upacked already!
1764 */
1765 static void save_PolygonStipple( GLcontext *ctx, const GLuint *pattern )
1766 {
1767 Node *n;
1768 FLUSH_VB(ctx, "dlist");
1769 n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 );
1770 if (n) {
1771 void *data;
1772 n[1].data = MALLOC( 32 * 4 );
1773 data = n[1].data; /* This needed for Acorn compiler */
1774 MEMCPY( data, pattern, 32 * 4 );
1775 }
1776 if (ctx->ExecuteFlag) {
1777 (*ctx->Exec.PolygonStipple)( ctx, pattern );
1778 }
1779 }
1780
1781
1782 static void save_PolygonOffset( GLcontext *ctx, GLfloat factor, GLfloat units )
1783 {
1784 Node *n;
1785 FLUSH_VB(ctx, "dlist");
1786 n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 );
1787 if (n) {
1788 n[1].f = factor;
1789 n[2].f = units;
1790 }
1791 if (ctx->ExecuteFlag) {
1792 (*ctx->Exec.PolygonOffset)( ctx, factor, units );
1793 }
1794 }
1795
1796
1797 static void save_PopAttrib( GLcontext *ctx )
1798 {
1799 FLUSH_VB(ctx, "dlist");
1800 (void) alloc_instruction( ctx, OPCODE_POP_ATTRIB, 0 );
1801 if (ctx->ExecuteFlag) {
1802 (*ctx->Exec.PopAttrib)( ctx );
1803 }
1804 }
1805
1806
1807 static void save_PopMatrix( GLcontext *ctx )
1808 {
1809 FLUSH_VB(ctx, "dlist");
1810 (void) alloc_instruction( ctx, OPCODE_POP_MATRIX, 0 );
1811 if (ctx->ExecuteFlag) {
1812 (*ctx->Exec.PopMatrix)( ctx );
1813 }
1814 }
1815
1816
1817 static void save_PopName( GLcontext *ctx )
1818 {
1819 FLUSH_VB(ctx, "dlist");
1820 (void) alloc_instruction( ctx, OPCODE_POP_NAME, 0 );
1821 if (ctx->ExecuteFlag) {
1822 (*ctx->Exec.PopName)( ctx );
1823 }
1824 }
1825
1826
1827 static void save_PrioritizeTextures( GLcontext *ctx,
1828 GLsizei num, const GLuint *textures,
1829 const GLclampf *priorities )
1830 {
1831 GLint i;
1832 FLUSH_VB(ctx, "dlist");
1833
1834 for (i=0;i<num;i++) {
1835 Node *n;
1836 n = alloc_instruction( ctx, OPCODE_PRIORITIZE_TEXTURE, 2 );
1837 if (n) {
1838 n[1].ui = textures[i];
1839 n[2].f = priorities[i];
1840 }
1841 }
1842 if (ctx->ExecuteFlag) {
1843 (*ctx->Exec.PrioritizeTextures)( ctx, num, textures, priorities );
1844 }
1845 }
1846
1847
1848 static void save_PushAttrib( GLcontext *ctx, GLbitfield mask )
1849 {
1850 Node *n;
1851 FLUSH_VB(ctx, "dlist");
1852 n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 );
1853 if (n) {
1854 n[1].bf = mask;
1855 }
1856 if (ctx->ExecuteFlag) {
1857 (*ctx->Exec.PushAttrib)( ctx, mask );
1858 }
1859 }
1860
1861
1862 static void save_PushMatrix( GLcontext *ctx )
1863 {
1864 FLUSH_VB(ctx, "dlist");
1865 (void) alloc_instruction( ctx, OPCODE_PUSH_MATRIX, 0 );
1866 if (ctx->ExecuteFlag) {
1867 (*ctx->Exec.PushMatrix)( ctx );
1868 }
1869 }
1870
1871
1872 static void save_PushName( GLcontext *ctx, GLuint name )
1873 {
1874 Node *n;
1875 FLUSH_VB(ctx, "dlist");
1876 n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 );
1877 if (n) {
1878 n[1].ui = name;
1879 }
1880 if (ctx->ExecuteFlag) {
1881 (*ctx->Exec.PushName)( ctx, name );
1882 }
1883 }
1884
1885
1886 static void save_RasterPos4f( GLcontext *ctx,
1887 GLfloat x, GLfloat y, GLfloat z, GLfloat w )
1888 {
1889 Node *n;
1890 FLUSH_VB(ctx, "dlist");
1891 n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 );
1892 if (n) {
1893 n[1].f = x;
1894 n[2].f = y;
1895 n[3].f = z;
1896 n[4].f = w;
1897 }
1898 if (ctx->ExecuteFlag) {
1899 (*ctx->Exec.RasterPos4f)( ctx, x, y, z, w );
1900 }
1901 }
1902
1903
1904 static void save_PassThrough( GLcontext *ctx, GLfloat token )
1905 {
1906 Node *n;
1907 FLUSH_VB(ctx, "dlist");
1908 n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 );
1909 if (n) {
1910 n[1].f = token;
1911 }
1912 if (ctx->ExecuteFlag) {
1913 (*ctx->Exec.PassThrough)( ctx, token );
1914 }
1915 }
1916
1917
1918 static void save_ReadBuffer( GLcontext *ctx, GLenum mode )
1919 {
1920 Node *n;
1921 FLUSH_VB(ctx, "dlist");
1922 n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 );
1923 if (n) {
1924 n[1].e = mode;
1925 }
1926 if (ctx->ExecuteFlag) {
1927 (*ctx->Exec.ReadBuffer)( ctx, mode );
1928 }
1929 }
1930
1931
1932 static void save_Rectf( GLcontext *ctx,
1933 GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
1934 {
1935 Node *n;
1936 FLUSH_VB(ctx, "dlist");
1937 n = alloc_instruction( ctx, OPCODE_RECTF, 4 );
1938 if (n) {
1939 n[1].f = x1;
1940 n[2].f = y1;
1941 n[3].f = x2;
1942 n[4].f = y2;
1943 }
1944 if (ctx->ExecuteFlag) {
1945 (*ctx->Exec.Rectf)( ctx, x1, y1, x2, y2 );
1946 }
1947 }
1948
1949
1950 static void save_Rotatef( GLcontext *ctx, GLfloat angle,
1951 GLfloat x, GLfloat y, GLfloat z )
1952 {
1953 GLfloat m[16];
1954 gl_rotation_matrix( angle, x, y, z, m );
1955 save_MultMatrixf( ctx, m ); /* save and maybe execute */
1956 }
1957
1958
1959 static void save_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
1960 {
1961 Node *n;
1962 FLUSH_VB(ctx, "dlist");
1963 n = alloc_instruction( ctx, OPCODE_SCALE, 3 );
1964 if (n) {
1965 n[1].f = x;
1966 n[2].f = y;
1967 n[3].f = z;
1968 }
1969 if (ctx->ExecuteFlag) {
1970 (*ctx->Exec.Scalef)( ctx, x, y, z );
1971 }
1972 }
1973
1974
1975 static void save_Scissor( GLcontext *ctx,
1976 GLint x, GLint y, GLsizei width, GLsizei height )
1977 {
1978 Node *n;
1979 FLUSH_VB(ctx, "dlist");
1980 n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 );
1981 if (n) {
1982 n[1].i = x;
1983 n[2].i = y;
1984 n[3].i = width;
1985 n[4].i = height;
1986 }
1987 if (ctx->ExecuteFlag) {
1988 (*ctx->Exec.Scissor)( ctx, x, y, width, height );
1989 }
1990 }
1991
1992
1993 static void save_ShadeModel( GLcontext *ctx, GLenum mode )
1994 {
1995 Node *n;
1996 FLUSH_VB(ctx, "dlist");
1997 n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 );
1998 if (n) {
1999 n[1].e = mode;
2000 }
2001 if (ctx->ExecuteFlag) {
2002 (*ctx->Exec.ShadeModel)( ctx, mode );
2003 }
2004 }
2005
2006
2007 static void save_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask )
2008 {
2009 Node *n;
2010 FLUSH_VB(ctx, "dlist");
2011 n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 );
2012 if (n) {
2013 n[1].e = func;
2014 n[2].i = ref;
2015 n[3].ui = mask;
2016 }
2017 if (ctx->ExecuteFlag) {
2018 (*ctx->Exec.StencilFunc)( ctx, func, ref, mask );
2019 }
2020 }
2021
2022
2023 static void save_StencilMask( GLcontext *ctx, GLuint mask )
2024 {
2025 Node *n;
2026 FLUSH_VB(ctx, "dlist");
2027 n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 );
2028 if (n) {
2029 n[1].ui = mask;
2030 }
2031 if (ctx->ExecuteFlag) {
2032 (*ctx->Exec.StencilMask)( ctx, mask );
2033 }
2034 }
2035
2036
2037 static void save_StencilOp( GLcontext *ctx,
2038 GLenum fail, GLenum zfail, GLenum zpass )
2039 {
2040 Node *n;
2041 FLUSH_VB(ctx, "dlist");
2042 n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 );
2043 if (n) {
2044 n[1].e = fail;
2045 n[2].e = zfail;
2046 n[3].e = zpass;
2047 }
2048 if (ctx->ExecuteFlag) {
2049 (*ctx->Exec.StencilOp)( ctx, fail, zfail, zpass );
2050 }
2051 }
2052
2053
2054
2055
2056 static void save_TexEnvfv( GLcontext *ctx,
2057 GLenum target, GLenum pname, const GLfloat *params )
2058 {
2059 Node *n;
2060 FLUSH_VB(ctx, "dlist");
2061 n = alloc_instruction( ctx, OPCODE_TEXENV, 6 );
2062 if (n) {
2063 n[1].e = target;
2064 n[2].e = pname;
2065 n[3].f = params[0];
2066 n[4].f = params[1];
2067 n[5].f = params[2];
2068 n[6].f = params[3];
2069 }
2070 if (ctx->ExecuteFlag) {
2071 (*ctx->Exec.TexEnvfv)( ctx, target, pname, params );
2072 }
2073 }
2074
2075
2076 static void save_TexGenfv( GLcontext *ctx,
2077 GLenum coord, GLenum pname, const GLfloat *params )
2078 {
2079 Node *n;
2080 FLUSH_VB(ctx, "dlist");
2081 n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 );
2082 if (n) {
2083 n[1].e = coord;
2084 n[2].e = pname;
2085 n[3].f = params[0];
2086 n[4].f = params[1];
2087 n[5].f = params[2];
2088 n[6].f = params[3];
2089 }
2090 if (ctx->ExecuteFlag) {
2091 (*ctx->Exec.TexGenfv)( ctx, coord, pname, params );
2092 }
2093 }
2094
2095
2096 static void save_TexParameterfv( GLcontext *ctx, GLenum target,
2097 GLenum pname, const GLfloat *params )
2098 {
2099 Node *n;
2100 FLUSH_VB(ctx, "dlist");
2101 n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 );
2102 if (n) {
2103 n[1].e = target;
2104 n[2].e = pname;
2105 n[3].f = params[0];
2106 n[4].f = params[1];
2107 n[5].f = params[2];
2108 n[6].f = params[3];
2109 }
2110 if (ctx->ExecuteFlag) {
2111 (*ctx->Exec.TexParameterfv)( ctx, target, pname, params );
2112 }
2113 }
2114
2115
2116 static void save_TexImage1D( GLcontext *ctx, GLenum target,
2117 GLint level, GLint components,
2118 GLsizei width, GLint border,
2119 GLenum format, GLenum type,
2120 const GLvoid *pixels )
2121 {
2122 FLUSH_VB(ctx, "dlist");
2123 if (target == GL_PROXY_TEXTURE_1D) {
2124 (*ctx->Exec.TexImage1D)( ctx, target, level, components, width,
2125 border, format, type, pixels );
2126 }
2127 else {
2128 Node *n;
2129 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
2130 pixels, &ctx->Unpack);
2131 n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 );
2132 if (n) {
2133 n[1].e = target;
2134 n[2].i = level;
2135 n[3].i = components;
2136 n[4].i = (GLint) width;
2137 n[5].i = border;
2138 n[6].e = format;
2139 n[7].e = type;
2140 n[8].data = image;
2141 }
2142 else {
2143 FREE(image);
2144 }
2145 if (ctx->ExecuteFlag) {
2146 (*ctx->Exec.TexImage1D)( ctx, target, level, components, width,
2147 border, format, type, pixels );
2148 }
2149 }
2150 }
2151
2152
2153 static void save_TexImage2D( GLcontext *ctx, GLenum target,
2154 GLint level, GLint components,
2155 GLsizei width, GLsizei height, GLint border,
2156 GLenum format, GLenum type,
2157 const GLvoid *pixels )
2158 {
2159 FLUSH_VB(ctx, "dlist");
2160 if (target == GL_PROXY_TEXTURE_2D) {
2161 (*ctx->Exec.TexImage2D)( ctx, target, level, components, width,
2162 height, border, format, type, pixels );
2163 }
2164 else {
2165 Node *n;
2166 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
2167 pixels, &ctx->Unpack);
2168 n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 );
2169 if (n) {
2170 n[1].e = target;
2171 n[2].i = level;
2172 n[3].i = components;
2173 n[4].i = (GLint) width;
2174 n[5].i = (GLint) height;
2175 n[6].i = border;
2176 n[7].e = format;
2177 n[8].e = type;
2178 n[9].data = image;
2179 }
2180 else {
2181 FREE(image);
2182 }
2183 if (ctx->ExecuteFlag) {
2184 (*ctx->Exec.TexImage2D)( ctx, target, level, components, width,
2185 height, border, format, type, pixels );
2186 }
2187 }
2188 }
2189
2190
2191 static void save_TexImage3D( GLcontext *ctx, GLenum target,
2192 GLint level, GLint components,
2193 GLsizei width, GLsizei height, GLsizei depth,
2194 GLint border,
2195 GLenum format, GLenum type,
2196 const GLvoid *pixels )
2197 {
2198 FLUSH_VB(ctx, "dlist");
2199 if (target == GL_PROXY_TEXTURE_3D) {
2200 (*ctx->Exec.TexImage3D)( ctx, target, level, components, width,
2201 height, depth, border, format, type, pixels );
2202 }
2203 else {
2204 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
2205 pixels, &ctx->Unpack);
2206 Node *n;
2207 n = alloc_instruction( ctx, OPCODE_TEX_IMAGE3D, 10 );
2208 if (n) {
2209 n[1].e = target;
2210 n[2].i = level;
2211 n[3].i = components;
2212 n[4].i = (GLint) width;
2213 n[5].i = (GLint) height;
2214 n[6].i = (GLint) depth;
2215 n[7].i = border;
2216 n[8].e = format;
2217 n[9].e = type;
2218 n[10].data = image;
2219 }
2220 else {
2221 FREE(image);
2222 }
2223 if (ctx->ExecuteFlag) {
2224 (*ctx->Exec.TexImage3D)( ctx, target, level, components, width,
2225 height, depth, border, format, type, pixels );
2226 }
2227 }
2228 }
2229
2230
2231 static void save_TexSubImage1D( GLcontext *ctx,
2232 GLenum target, GLint level, GLint xoffset,
2233 GLsizei width, GLenum format, GLenum type,
2234 const GLvoid *pixels )
2235 {
2236 Node *n;
2237 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
2238 pixels, &ctx->Unpack);
2239 FLUSH_VB(ctx, "dlist");
2240 n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
2241 if (n) {
2242 n[1].e = target;
2243 n[2].i = level;
2244 n[3].i = xoffset;
2245 n[4].i = (GLint) width;
2246 n[5].e = format;
2247 n[6].e = type;
2248 n[7].data = image;
2249 }
2250 else {
2251 FREE(image);
2252 }
2253 if (ctx->ExecuteFlag) {
2254 (*ctx->Exec.TexSubImage1D)( ctx, target, level, xoffset, width,
2255 format, type, pixels );
2256 }
2257 }
2258
2259
2260 static void save_TexSubImage2D( GLcontext *ctx,
2261 GLenum target, GLint level,
2262 GLint xoffset, GLint yoffset,
2263 GLsizei width, GLsizei height,
2264 GLenum format, GLenum type,
2265 const GLvoid *pixels )
2266 {
2267 Node *n;
2268 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
2269 pixels, &ctx->Unpack);
2270 FLUSH_VB(ctx, "dlist");
2271 n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
2272 if (n) {
2273 n[1].e = target;
2274 n[2].i = level;
2275 n[3].i = xoffset;
2276 n[4].i = yoffset;
2277 n[5].i = (GLint) width;
2278 n[6].i = (GLint) height;
2279 n[7].e = format;
2280 n[8].e = type;
2281 n[9].data = image;
2282 }
2283 else {
2284 FREE(image);
2285 }
2286 if (ctx->ExecuteFlag) {
2287 (*ctx->Exec.TexSubImage2D)( ctx, target, level, xoffset, yoffset,
2288 width, height, format, type, pixels );
2289 }
2290 }
2291
2292
2293 static void save_TexSubImage3D( GLcontext *ctx,
2294 GLenum target, GLint level,
2295 GLint xoffset, GLint yoffset,GLint zoffset,
2296 GLsizei width, GLsizei height, GLsizei depth,
2297 GLenum format, GLenum type,
2298 const GLvoid *pixels )
2299 {
2300 Node *n;
2301 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
2302 pixels, &ctx->Unpack);
2303 FLUSH_VB(ctx, "dlist");
2304 n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
2305 if (n) {
2306 n[1].e = target;
2307 n[2].i = level;
2308 n[3].i = xoffset;
2309 n[4].i = yoffset;
2310 n[5].i = zoffset;
2311 n[6].i = (GLint) width;
2312 n[7].i = (GLint) height;
2313 n[8].i = (GLint) depth;
2314 n[9].e = format;
2315 n[10].e = type;
2316 n[11].data = image;
2317 }
2318 else {
2319 FREE(image);
2320 }
2321 if (ctx->ExecuteFlag) {
2322 (*ctx->Exec.TexSubImage3D)(ctx, target, level, xoffset, yoffset, zoffset,
2323 width, height, depth, format, type, pixels );
2324 }
2325 }
2326
2327
2328 static void save_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
2329 {
2330 Node *n;
2331 FLUSH_VB(ctx, "dlist");
2332 n = alloc_instruction( ctx, OPCODE_TRANSLATE, 3 );
2333 if (n) {
2334 n[1].f = x;
2335 n[2].f = y;
2336 n[3].f = z;
2337 }
2338 if (ctx->ExecuteFlag) {
2339 (*ctx->Exec.Translatef)( ctx, x, y, z );
2340 }
2341 }
2342
2343
2344
2345 static void save_Viewport( GLcontext *ctx,
2346 GLint x, GLint y, GLsizei width, GLsizei height )
2347 {
2348 Node *n;
2349 FLUSH_VB(ctx, "dlist");
2350 n = alloc_instruction( ctx, OPCODE_VIEWPORT, 4 );
2351 if (n) {
2352 n[1].i = x;
2353 n[2].i = y;
2354 n[3].i = (GLint) width;
2355 n[4].i = (GLint) height;
2356 }
2357 if (ctx->ExecuteFlag) {
2358 (*ctx->Exec.Viewport)( ctx, x, y, width, height );
2359 }
2360 }
2361
2362
2363 static void save_WindowPos4fMESA( GLcontext *ctx,
2364 GLfloat x, GLfloat y, GLfloat z, GLfloat w )
2365 {
2366 Node *n;
2367 FLUSH_VB(ctx, "dlist");
2368 n = alloc_instruction( ctx, OPCODE_WINDOW_POS, 4 );
2369 if (n) {
2370 n[1].f = x;
2371 n[2].f = y;
2372 n[3].f = z;
2373 n[4].f = w;
2374 }
2375 if (ctx->ExecuteFlag) {
2376 (*ctx->Exec.WindowPos4fMESA)( ctx, x, y, z, w );
2377 }
2378 }
2379
2380
2381
2382
2383
2384
2385 /* GL_ARB_multitexture */
2386 static void save_ActiveTexture( GLcontext *ctx, GLenum target )
2387 {
2388 Node *n;
2389 FLUSH_VB(ctx, "dlist");
2390 n = alloc_instruction( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
2391 if (n) {
2392 n[1].e = target;
2393 }
2394 if (ctx->ExecuteFlag) {
2395 (*ctx->Exec.ActiveTexture)( ctx, target );
2396 }
2397 }
2398
2399
2400 /* GL_ARB_multitexture */
2401 static void save_ClientActiveTexture( GLcontext *ctx, GLenum target )
2402 {
2403 Node *n;
2404 FLUSH_VB(ctx, "dlist");
2405 n = alloc_instruction( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 );
2406 if (n) {
2407 n[1].e = target;
2408 }
2409 if (ctx->ExecuteFlag) {
2410 (*ctx->Exec.ClientActiveTexture)( ctx, target );
2411 }
2412 }
2413
2414
2415
2416 void gl_compile_cassette( GLcontext *ctx )
2417 {
2418 Node *n = alloc_instruction( ctx, OPCODE_VERTEX_CASSETTE, 8 );
2419 struct immediate *im = ctx->input;
2420
2421 if (!n)
2422 return;
2423
2424
2425 /* Do some easy optimizations of the cassette.
2426 */
2427 #if 0
2428 if (0 && im->v.Obj.size < 4 && im->Count > 15) {
2429 im->Bounds = (GLfloat (*)[3]) MALLOC(6 * sizeof(GLfloat));
2430 (gl_calc_bound_tab[im->v.Obj.size])( im->Bounds, &im->v.Obj );
2431 }
2432 #endif
2433
2434 n[1].data = (void *)im;
2435 n[2].ui = im->Start;
2436 n[3].ui = im->Count;
2437 n[4].ui = im->BeginState;
2438 n[5].ui = im->OrFlag;
2439 n[6].ui = im->AndFlag;
2440 n[7].ui = im->LastData;
2441 n[8].ui = im->LastPrimitive;
2442
2443 if (im->Count > VB_MAX - 4) {
2444
2445 struct immediate *new_im = gl_immediate_alloc(ctx);
2446 if (!new_im) return;
2447 SET_IMMEDIATE( ctx, new_im );
2448 gl_reset_input( ctx );
2449
2450 } else {
2451 im->Count++;;
2452 im->Start = im->Count; /* don't clear anything in reset_input */
2453 im->ref_count++;
2454
2455 im->Primitive[im->Start] = ctx->Current.Primitive;
2456 im->LastPrimitive = im->Start;
2457 im->BeginState = VERT_BEGIN_0;
2458 im->OrFlag = 0;
2459 im->AndFlag = ~0;
2460
2461 if (0)
2462 fprintf(stderr, "in compile_cassette, BeginState is %x\n",
2463 im->BeginState);
2464 }
2465 }
2466
2467 /* KW: Compile commands
2468 *
2469 * Will appear in the list before the vertex buffer containing the
2470 * command that provoked the error. I don't see this as a problem.
2471 */
2472 void gl_save_error( GLcontext *ctx, GLenum error, const char *s )
2473 {
2474 Node *n;
2475 n = alloc_instruction( ctx, OPCODE_ERROR, 2 );
2476 if (n) {
2477 n[1].e = error;
2478 n[2].data = (void *) s;
2479 }
2480 /* execute already done */
2481 }
2482
2483 /**********************************************************************/
2484 /* Display list execution */
2485 /**********************************************************************/
2486
2487
2488 /*
2489 * Execute a display list. Note that the ListBase offset must have already
2490 * been added before calling this function. I.e. the list argument is
2491 * the absolute list number, not relative to ListBase.
2492 * Input: list - display list number
2493 */
2494 static void execute_list( GLcontext *ctx, GLuint list )
2495 {
2496 static struct gl_pixelstore_attrib defaultPacking = {
2497 1, /* Alignment */
2498 0, /* RowLength */
2499 0, /* SkipPixels */
2500 0, /* SkipRows */
2501 0, /* ImageHeight */
2502 0, /* SkipImages */
2503 GL_FALSE, /* SwapBytes */
2504 GL_FALSE /* LsbFirst */
2505 };
2506 Node *n;
2507 GLboolean done;
2508 OpCode opcode;
2509
2510 if (!gl_IsList(ctx,list))
2511 return;
2512
2513 /* mesa_print_display_list( list ); */
2514
2515 ctx->CallDepth++;
2516
2517 n = (Node *) HashLookup(ctx->Shared->DisplayList, list);
2518
2519 done = GL_FALSE;
2520 while (!done) {
2521 opcode = n[0].opcode;
2522
2523 switch (opcode) {
2524 case OPCODE_ERROR:
2525 gl_error( ctx, n[1].e, (const char *) n[2].data );
2526 break;
2527 case OPCODE_VERTEX_CASSETTE: {
2528 struct immediate *IM;
2529
2530 if (ctx->NewState)
2531 gl_update_state(ctx);
2532 if (ctx->CompileCVAFlag) {
2533 ctx->CompileCVAFlag = 0;
2534 ctx->CVA.elt.pipeline_valid = 0;
2535 }
2536 if (!ctx->CVA.elt.pipeline_valid)
2537 gl_build_immediate_pipeline( ctx );
2538
2539
2540 IM = (struct immediate *) n[1].data;
2541 IM->Start = n[2].ui;
2542 IM->Count = n[3].ui;
2543 IM->BeginState = n[4].ui;
2544 IM->OrFlag = n[5].ui;
2545 IM->AndFlag = n[6].ui;
2546 IM->LastData = n[7].ui;
2547 IM->LastPrimitive = n[8].ui;
2548
2549 if ((MESA_VERBOSE & VERBOSE_DISPLAY_LIST) &&
2550 (MESA_VERBOSE & VERBOSE_IMMEDIATE))
2551 gl_print_cassette( (struct immediate *) n[1].data, 0, ~0 );
2552
2553 if (0)
2554 fprintf(stderr, "Run cassette %d, rows %d..%d, beginstate %x\n",
2555 IM->id,
2556 IM->Start, IM->Count, IM->BeginState);
2557
2558 gl_fixup_cassette( ctx, (struct immediate *) n[1].data );
2559 gl_execute_cassette( ctx, (struct immediate *) n[1].data );
2560 break;
2561 }
2562 case OPCODE_ACCUM:
2563 gl_Accum( ctx, n[1].e, n[2].f );
2564 break;
2565 case OPCODE_ALPHA_FUNC:
2566 gl_AlphaFunc( ctx, n[1].e, n[2].f );
2567 break;
2568 case OPCODE_BIND_TEXTURE:
2569 gl_BindTexture( ctx, n[1].e, n[2].ui );
2570 break;
2571 case OPCODE_BITMAP:
2572 {
2573 const struct gl_image *image = (struct gl_image *) n[7].data;
2574 const GLubyte *bitmap = image ? image->Data : NULL;
2575 gl_Bitmap( ctx, (GLsizei) n[1].i, (GLsizei) n[2].i,
2576 n[3].f, n[4].f, n[5].f, n[6].f,
2577 bitmap, &defaultPacking );
2578 }
2579 break;
2580 case OPCODE_BLEND_COLOR:
2581 gl_BlendColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
2582 break;
2583 case OPCODE_BLEND_EQUATION:
2584 gl_BlendEquation( ctx, n[1].e );
2585 break;
2586 case OPCODE_BLEND_FUNC:
2587 gl_BlendFunc( ctx, n[1].e, n[2].e );
2588 break;
2589 case OPCODE_BLEND_FUNC_SEPARATE:
2590 gl_BlendFuncSeparate( ctx, n[1].e, n[2].e, n[3].e, n[4].e );
2591 break;
2592 case OPCODE_CALL_LIST:
2593 /* Generated by glCallList(), don't add ListBase */
2594 if (ctx->CallDepth<MAX_LIST_NESTING) {
2595 execute_list( ctx, n[1].ui );
2596 }
2597 break;
2598 case OPCODE_CALL_LIST_OFFSET:
2599 /* Generated by glCallLists() so we must add ListBase */
2600 if (ctx->CallDepth<MAX_LIST_NESTING) {
2601 execute_list( ctx, ctx->List.ListBase + n[1].ui );
2602 }
2603 break;
2604 case OPCODE_CLEAR:
2605 gl_Clear( ctx, n[1].bf );
2606 break;
2607 case OPCODE_CLEAR_COLOR:
2608 gl_ClearColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
2609 break;
2610 case OPCODE_CLEAR_ACCUM:
2611 gl_ClearAccum( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
2612 break;
2613 case OPCODE_CLEAR_DEPTH:
2614 gl_ClearDepth( ctx, (GLclampd) n[1].f );
2615 break;
2616 case OPCODE_CLEAR_INDEX:
2617 gl_ClearIndex( ctx, n[1].ui );
2618 break;
2619 case OPCODE_CLEAR_STENCIL:
2620 gl_ClearStencil( ctx, n[1].i );
2621 break;
2622 case OPCODE_CLIP_PLANE:
2623 {
2624 GLfloat equ[4];
2625 equ[0] = n[2].f;
2626 equ[1] = n[3].f;
2627 equ[2] = n[4].f;
2628 equ[3] = n[5].f;
2629 gl_ClipPlane( ctx, n[1].e, equ );
2630 }
2631 break;
2632 case OPCODE_COLOR_MASK:
2633 gl_ColorMask( ctx, n[1].b, n[2].b, n[3].b, n[4].b );
2634 break;
2635 case OPCODE_COLOR_MATERIAL:
2636 gl_ColorMaterial( ctx, n[1].e, n[2].e );
2637 break;
2638 case OPCODE_COLOR_TABLE:
2639 gl_ColorTable( ctx, n[1].e, n[2].e, (struct gl_image *) n[3].data);
2640 break;
2641 case OPCODE_COLOR_SUB_TABLE:
2642 gl_ColorSubTable( ctx, n[1].e, n[2].i,
2643 (struct gl_image *) n[3].data);
2644 break;
2645 case OPCODE_COPY_PIXELS:
2646 gl_CopyPixels( ctx, n[1].i, n[2].i,
2647 (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
2648 break;
2649 case OPCODE_COPY_TEX_IMAGE1D:
2650 gl_CopyTexImage1D( ctx, n[1].e, n[2].i, n[3].e, n[4].i,
2651 n[5].i, n[6].i, n[7].i );
2652 break;
2653 case OPCODE_COPY_TEX_IMAGE2D:
2654 gl_CopyTexImage2D( ctx, n[1].e, n[2].i, n[3].e, n[4].i,
2655 n[5].i, n[6].i, n[7].i, n[8].i );
2656 break;
2657 case OPCODE_COPY_TEX_SUB_IMAGE1D:
2658 gl_CopyTexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
2659 n[5].i, n[6].i );
2660 break;
2661 case OPCODE_COPY_TEX_SUB_IMAGE2D:
2662 gl_CopyTexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
2663 n[5].i, n[6].i, n[7].i, n[8].i );
2664 break;
2665 case OPCODE_COPY_TEX_SUB_IMAGE3D:
2666 gl_CopyTexSubImage3D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
2667 n[5].i, n[6].i, n[7].i, n[8].i, n[9].i);
2668 break;
2669 case OPCODE_CULL_FACE:
2670 gl_CullFace( ctx, n[1].e );
2671 break;
2672 case OPCODE_DEPTH_FUNC:
2673 gl_DepthFunc( ctx, n[1].e );
2674 break;
2675 case OPCODE_DEPTH_MASK:
2676 gl_DepthMask( ctx, n[1].b );
2677 break;
2678 case OPCODE_DEPTH_RANGE:
2679 gl_DepthRange( ctx, (GLclampd) n[1].f, (GLclampd) n[2].f );
2680 break;
2681 case OPCODE_DISABLE:
2682 gl_Disable( ctx, n[1].e );
2683 break;
2684 case OPCODE_DRAW_BUFFER:
2685 gl_DrawBuffer( ctx, n[1].e );
2686 break;
2687 case OPCODE_DRAW_PIXELS:
2688 gl_DrawPixels( ctx, (struct gl_image *) n[1].data );
2689 break;
2690 case OPCODE_ENABLE:
2691 gl_Enable( ctx, n[1].e );
2692 break;
2693 case OPCODE_EVALMESH1:
2694 gl_EvalMesh1( ctx, n[1].e, n[2].i, n[3].i );
2695 break;
2696 case OPCODE_EVALMESH2:
2697 gl_EvalMesh2( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
2698 break;
2699 case OPCODE_FOG:
2700 {
2701 GLfloat p[4];
2702 p[0] = n[2].f;
2703 p[1] = n[3].f;
2704 p[2] = n[4].f;
2705 p[3] = n[5].f;
2706 gl_Fogfv( ctx, n[1].e, p );
2707 }
2708 break;
2709 case OPCODE_FRONT_FACE:
2710 gl_FrontFace( ctx, n[1].e );
2711 break;
2712 case OPCODE_FRUSTUM:
2713 gl_Frustum( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
2714 break;
2715 case OPCODE_HINT:
2716 gl_Hint( ctx, n[1].e, n[2].e );
2717 break;
2718 case OPCODE_INDEX_MASK:
2719 gl_IndexMask( ctx, n[1].ui );
2720 break;
2721 case OPCODE_INIT_NAMES:
2722 gl_InitNames( ctx );
2723 break;
2724 case OPCODE_LIGHT:
2725 {
2726 GLfloat p[4];
2727 p[0] = n[3].f;
2728 p[1] = n[4].f;
2729 p[2] = n[5].f;
2730 p[3] = n[6].f;
2731 gl_Lightfv( ctx, n[1].e, n[2].e, p, 4 );
2732 }
2733 break;
2734 case OPCODE_LIGHT_MODEL:
2735 {
2736 GLfloat p[4];
2737 p[0] = n[2].f;
2738 p[1] = n[3].f;
2739 p[2] = n[4].f;
2740 p[3] = n[5].f;
2741 gl_LightModelfv( ctx, n[1].e, p );
2742 }
2743 break;
2744 case OPCODE_LINE_STIPPLE:
2745 gl_LineStipple( ctx, n[1].i, n[2].us );
2746 break;
2747 case OPCODE_LINE_WIDTH:
2748 gl_LineWidth( ctx, n[1].f );
2749 break;
2750 case OPCODE_LIST_BASE:
2751 gl_ListBase( ctx, n[1].ui );
2752 break;
2753 case OPCODE_LOAD_IDENTITY:
2754 gl_LoadIdentity( ctx );
2755 break;
2756 case OPCODE_LOAD_MATRIX:
2757 if (sizeof(Node)==sizeof(GLfloat)) {
2758 gl_LoadMatrixf( ctx, &n[1].f );
2759 }
2760 else {
2761 GLfloat m[16];
2762 GLuint i;
2763 for (i=0;i<16;i++) {
2764 m[i] = n[1+i].f;
2765 }
2766 gl_LoadMatrixf( ctx, m );
2767 }
2768 break;
2769 case OPCODE_LOAD_NAME:
2770 gl_LoadName( ctx, n[1].ui );
2771 break;
2772 case OPCODE_LOGIC_OP:
2773 gl_LogicOp( ctx, n[1].e );
2774 break;
2775 case OPCODE_MAP1:
2776 gl_Map1f( ctx, n[1].e, n[2].f, n[3].f,
2777 n[4].i, n[5].i, (GLfloat *) n[6].data, GL_TRUE );
2778 break;
2779 case OPCODE_MAP2:
2780 gl_Map2f( ctx, n[1].e,
2781 n[2].f, n[3].f, /* u1, u2 */
2782 n[6].i, n[8].i, /* ustride, uorder */
2783 n[4].f, n[5].f, /* v1, v2 */
2784 n[7].i, n[9].i, /* vstride, vorder */
2785 (GLfloat *) n[10].data,
2786 GL_TRUE);
2787 break;
2788 case OPCODE_MAPGRID1:
2789 gl_MapGrid1f( ctx, n[1].i, n[2].f, n[3].f );
2790 break;
2791 case OPCODE_MAPGRID2:
2792 gl_MapGrid2f( ctx, n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
2793 break;
2794 case OPCODE_MATRIX_MODE:
2795 gl_MatrixMode( ctx, n[1].e );
2796 break;
2797 case OPCODE_MULT_MATRIX:
2798 if (sizeof(Node)==sizeof(GLfloat)) {
2799 gl_MultMatrixf( ctx, &n[1].f );
2800 }
2801 else {
2802 GLfloat m[16];
2803 GLuint i;
2804 for (i=0;i<16;i++) {
2805 m[i] = n[1+i].f;
2806 }
2807 gl_MultMatrixf( ctx, m );
2808 }
2809 break;
2810 case OPCODE_ORTHO:
2811 gl_Ortho( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
2812 break;
2813 case OPCODE_PASSTHROUGH:
2814 gl_PassThrough( ctx, n[1].f );
2815 break;
2816 case OPCODE_PIXEL_MAP:
2817 gl_PixelMapfv( ctx, n[1].e, n[2].i, (GLfloat *) n[3].data );
2818 break;
2819 case OPCODE_PIXEL_TRANSFER:
2820 gl_PixelTransferf( ctx, n[1].e, n[2].f );
2821 break;
2822 case OPCODE_PIXEL_ZOOM:
2823 gl_PixelZoom( ctx, n[1].f, n[2].f );
2824 break;
2825 case OPCODE_POINT_SIZE:
2826 gl_PointSize( ctx, n[1].f );
2827 break;
2828 case OPCODE_POINT_PARAMETERS:
2829 {
2830 GLfloat params[3];
2831 params[0] = n[2].f;
2832 params[1] = n[3].f;
2833 params[2] = n[4].f;
2834 gl_PointParameterfvEXT( ctx, n[1].e, params );
2835 }
2836 break;
2837 case OPCODE_POLYGON_MODE:
2838 gl_PolygonMode( ctx, n[1].e, n[2].e );
2839 break;
2840 case OPCODE_POLYGON_STIPPLE:
2841 gl_PolygonStipple( ctx, (GLuint *) n[1].data );
2842 break;
2843 case OPCODE_POLYGON_OFFSET:
2844 gl_PolygonOffset( ctx, n[1].f, n[2].f );
2845 break;
2846 case OPCODE_POP_ATTRIB:
2847 gl_PopAttrib( ctx );
2848 break;
2849 case OPCODE_POP_MATRIX:
2850 gl_PopMatrix( ctx );
2851 break;
2852 case OPCODE_POP_NAME:
2853 gl_PopName( ctx );
2854 break;
2855 case OPCODE_PRIORITIZE_TEXTURE:
2856 gl_PrioritizeTextures( ctx, 1, &n[1].ui, &n[2].f );
2857 break;
2858 case OPCODE_PUSH_ATTRIB:
2859 gl_PushAttrib( ctx, n[1].bf );
2860 break;
2861 case OPCODE_PUSH_MATRIX:
2862 gl_PushMatrix( ctx );
2863 break;
2864 case OPCODE_PUSH_NAME:
2865 gl_PushName( ctx, n[1].ui );
2866 break;
2867 case OPCODE_RASTER_POS:
2868 gl_RasterPos4f( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
2869 break;
2870 case OPCODE_READ_BUFFER:
2871 gl_ReadBuffer( ctx, n[1].e );
2872 break;
2873 case OPCODE_RECTF:
2874 gl_Rectf( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
2875 break;
2876 case OPCODE_SCALE:
2877 gl_Scalef( ctx, n[1].f, n[2].f, n[3].f );
2878 break;
2879 case OPCODE_SCISSOR:
2880 gl_Scissor( ctx, n[1].i, n[2].i, n[3].i, n[4].i );
2881 break;
2882 case OPCODE_SHADE_MODEL:
2883 gl_ShadeModel( ctx, n[1].e );
2884 break;
2885 case OPCODE_STENCIL_FUNC:
2886 gl_StencilFunc( ctx, n[1].e, n[2].i, n[3].ui );
2887 break;
2888 case OPCODE_STENCIL_MASK:
2889 gl_StencilMask( ctx, n[1].ui );
2890 break;
2891 case OPCODE_STENCIL_OP:
2892 gl_StencilOp( ctx, n[1].e, n[2].e, n[3].e );
2893 break;
2894 case OPCODE_TEXENV:
2895 {
2896 GLfloat params[4];
2897 params[0] = n[3].f;
2898 params[1] = n[4].f;
2899 params[2] = n[5].f;
2900 params[3] = n[6].f;
2901 gl_TexEnvfv( ctx, n[1].e, n[2].e, params );
2902 }
2903 break;
2904 case OPCODE_TEXGEN:
2905 {
2906 GLfloat params[4];
2907 params[0] = n[3].f;
2908 params[1] = n[4].f;
2909 params[2] = n[5].f;
2910 params[3] = n[6].f;
2911 gl_TexGenfv( ctx, n[1].e, n[2].e, params );
2912 }
2913 break;
2914 case OPCODE_TEXPARAMETER:
2915 {
2916 GLfloat params[4];
2917 params[0] = n[3].f;
2918 params[1] = n[4].f;
2919 params[2] = n[5].f;
2920 params[3] = n[6].f;
2921 gl_TexParameterfv( ctx, n[1].e, n[2].e, params );
2922 }
2923 break;
2924 case OPCODE_TEX_IMAGE1D:
2925 {
2926 struct gl_pixelstore_attrib save = ctx->Unpack;
2927 ctx->Unpack = defaultPacking;
2928 gl_TexImage1D( ctx,
2929 n[1].e, /* target */
2930 n[2].i, /* level */
2931 n[3].i, /* components */
2932 n[4].i, /* width */
2933 n[5].e, /* border */
2934 n[6].e, /* format */
2935 n[7].e, /* type */
2936 n[8].data );
2937 ctx->Unpack = save; /* restore */
2938 }
2939 break;
2940 case OPCODE_TEX_IMAGE2D:
2941 {
2942 struct gl_pixelstore_attrib save = ctx->Unpack;
2943 ctx->Unpack = defaultPacking;
2944 gl_TexImage2D( ctx,
2945 n[1].e, /* target */
2946 n[2].i, /* level */
2947 n[3].i, /* components */
2948 n[4].i, /* width */
2949 n[5].i, /* height */
2950 n[6].e, /* border */
2951 n[7].e, /* format */
2952 n[8].e, /* type */
2953 n[9].data );
2954 ctx->Unpack = save; /* restore */
2955 }
2956 break;
2957 case OPCODE_TEX_IMAGE3D:
2958 {
2959 struct gl_pixelstore_attrib save = ctx->Unpack;
2960 ctx->Unpack = defaultPacking;
2961 gl_TexImage3D( ctx,
2962 n[1].e, /* target */
2963 n[2].i, /* level */
2964 n[3].i, /* components */
2965 n[4].i, /* width */
2966 n[5].i, /* height */
2967 n[6].i, /* depth */
2968 n[7].e, /* border */
2969 n[8].e, /* format */
2970 n[9].e, /* type */
2971 n[10].data );
2972 ctx->Unpack = save; /* restore */
2973 }
2974 break;
2975 case OPCODE_TEX_SUB_IMAGE1D:
2976 {
2977 struct gl_pixelstore_attrib save = ctx->Unpack;
2978 ctx->Unpack = defaultPacking;
2979 gl_TexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e,
2980 n[6].e, n[7].data );
2981 ctx->Unpack = save; /* restore */
2982 }
2983 break;
2984 case OPCODE_TEX_SUB_IMAGE2D:
2985 {
2986 struct gl_pixelstore_attrib save = ctx->Unpack;
2987 ctx->Unpack = defaultPacking;
2988 (*ctx->Exec.TexSubImage2D)( ctx, n[1].e, n[2].i, n[3].i,
2989 n[4].i, n[5].e,
2990 n[6].i, n[7].e, n[8].e, n[9].data );
2991 ctx->Unpack = save; /* restore */
2992 }
2993 break;
2994 case OPCODE_TEX_SUB_IMAGE3D:
2995 {
2996 struct gl_pixelstore_attrib save = ctx->Unpack;
2997 ctx->Unpack = defaultPacking;
2998 gl_TexSubImage3D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i,
2999 n[6].i, n[7].i, n[8].i, n[9].e, n[10].e,
3000 n[11].data );
3001 ctx->Unpack = save; /* restore */
3002 }
3003 break;
3004 case OPCODE_TRANSLATE:
3005 gl_Translatef( ctx, n[1].f, n[2].f, n[3].f );
3006 break;
3007 case OPCODE_VIEWPORT:
3008 gl_Viewport( ctx,
3009 n[1].i, n[2].i, (GLsizei) n[3].i, (GLsizei) n[4].i );
3010 break;
3011 case OPCODE_WINDOW_POS:
3012 gl_WindowPos4fMESA( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
3013 break;
3014 case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
3015 gl_ActiveTexture( ctx, n[1].e );
3016 break;
3017 case OPCODE_CLIENT_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
3018 gl_ClientActiveTexture( ctx, n[1].e );
3019 break;
3020 case OPCODE_CONTINUE:
3021 n = (Node *) n[1].next;
3022 break;
3023 case OPCODE_END_OF_LIST:
3024 done = GL_TRUE;
3025 break;
3026 default:
3027 {
3028 char msg[1000];
3029 sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
3030 gl_problem( ctx, msg );
3031 }
3032 done = GL_TRUE;
3033 }
3034
3035 /* increment n to point to next compiled command */
3036 if (opcode!=OPCODE_CONTINUE) {
3037 n += InstSize[opcode];
3038 }
3039
3040 }
3041 ctx->CallDepth--;
3042 }
3043
3044
3045
3046
3047
3048 /**********************************************************************/
3049 /* GL functions */
3050 /**********************************************************************/
3051
3052
3053
3054
3055 /*
3056 * Test if a display list number is valid.
3057 */
3058 GLboolean gl_IsList( GLcontext *ctx, GLuint list )
3059 {
3060 if (list > 0 && HashLookup(ctx->Shared->DisplayList, list)) {
3061 return GL_TRUE;
3062 }
3063 else {
3064 return GL_FALSE;
3065 }
3066 }
3067
3068
3069
3070 /*
3071 * Delete a sequence of consecutive display lists.
3072 */
3073 void gl_DeleteLists( GLcontext *ctx, GLuint list, GLsizei range )
3074 {
3075 GLuint i;
3076
3077 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDeleteLists");
3078 if (range<0) {
3079 gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
3080 return;
3081 }
3082 for (i=list;i<list+range;i++) {
3083 gl_destroy_list( ctx, i );
3084 }
3085 }
3086
3087
3088
3089 /*
3090 * Return a display list number, n, such that lists n through n+range-1
3091 * are free.
3092 */
3093 GLuint gl_GenLists( GLcontext *ctx, GLsizei range )
3094 {
3095 GLuint base;
3096
3097 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glGenLists", 0);
3098 if (range<0) {
3099 gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
3100 return 0;
3101 }
3102 if (range==0) {
3103 return 0;
3104 }
3105
3106 base = HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
3107 if (base) {
3108 /* reserve the list IDs by with empty/dummy lists */
3109 GLint i;
3110 for (i=0; i<range; i++) {
3111 HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
3112 }
3113 }
3114 return base;
3115 }
3116
3117
3118
3119 /*
3120 * Begin a new display list.
3121 */
3122 void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode )
3123 {
3124 struct immediate *IM;
3125 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glNewList");
3126
3127 if (MESA_VERBOSE&VERBOSE_API)
3128 fprintf(stderr, "glNewList %u %s\n", list, gl_lookup_enum_by_nr(mode));
3129
3130 if (list==0) {
3131 gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
3132 return;
3133 }
3134
3135 if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
3136 gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
3137 return;
3138 }
3139
3140 if (ctx->CurrentListPtr) {
3141 /* already compiling a display list */
3142 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
3143 return;
3144 }
3145
3146 /* Allocate new display list */
3147 ctx->CurrentListNum = list;
3148 ctx->CurrentBlock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
3149 ctx->CurrentListPtr = ctx->CurrentBlock;
3150 ctx->CurrentPos = 0;
3151
3152 IM = gl_immediate_alloc( ctx );
3153 SET_IMMEDIATE( ctx, IM );
3154 gl_reset_input( ctx );
3155
3156 ctx->CompileFlag = GL_TRUE;
3157 ctx->CompileCVAFlag = GL_FALSE;
3158 ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
3159 ctx->API = ctx->Save; /* Switch the API function pointers */
3160 }
3161
3162
3163
3164 /*
3165 * End definition of current display list.
3166 */
3167 void gl_EndList( GLcontext *ctx )
3168 {
3169 if (MESA_VERBOSE&VERBOSE_API)
3170 fprintf(stderr, "glEndList\n");
3171
3172 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glEndList" );
3173
3174 /* Check that a list is under construction */
3175 if (!ctx->CurrentListPtr) {
3176 gl_error( ctx, GL_INVALID_OPERATION, "glEndList" );
3177 return;
3178 }
3179
3180 (void) alloc_instruction( ctx, OPCODE_END_OF_LIST, 0 );
3181
3182 /* Destroy old list, if any */
3183 gl_destroy_list(ctx, ctx->CurrentListNum);
3184 /* Install the list */
3185 HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
3186
3187
3188 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
3189 mesa_print_display_list(ctx->CurrentListNum);
3190
3191 ctx->CurrentListNum = 0;
3192 ctx->CurrentListPtr = NULL;
3193 ctx->ExecuteFlag = GL_TRUE;
3194 ctx->CompileFlag = GL_FALSE;
3195 /* ctx->CompileCVAFlag = ...; */
3196
3197 /* KW: Put back the old input pointer.
3198 */
3199 if (--ctx->input->ref_count == 0)
3200 gl_immediate_free( ctx->input );
3201
3202 SET_IMMEDIATE( ctx, ctx->VB->IM );
3203 gl_reset_input( ctx );
3204
3205 /* Haven't tracked down why this is needed.
3206 */
3207 ctx->NewState = ~0;
3208
3209 ctx->API = ctx->Exec; /* Switch the API function pointers */
3210 }
3211
3212
3213
3214 void gl_CallList( GLcontext *ctx, GLuint list )
3215 {
3216 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
3217 /* execute the display list, and restore the CompileFlag. */
3218 GLboolean save_compile_flag;
3219
3220 if (MESA_VERBOSE&VERBOSE_API) {
3221 fprintf(stderr, "glCallList %u\n", list);
3222 mesa_print_display_list( list );
3223 }
3224
3225 save_compile_flag = ctx->CompileFlag;
3226 ctx->CompileFlag = GL_FALSE;
3227
3228 FLUSH_VB( ctx, "call list" );
3229 execute_list( ctx, list );
3230 ctx->CompileFlag = save_compile_flag;
3231
3232 /* also restore API function pointers to point to "save" versions */
3233 if (save_compile_flag)
3234 ctx->API = ctx->Save;
3235 }
3236
3237
3238
3239 /*
3240 * Execute glCallLists: call multiple display lists.
3241 */
3242 void gl_CallLists( GLcontext *ctx,
3243 GLsizei n, GLenum type, const GLvoid *lists )
3244 {
3245 GLuint list;
3246 GLint i;
3247 GLboolean save_compile_flag;
3248
3249 /* Save the CompileFlag status, turn it off, execute display list,
3250 * and restore the CompileFlag.
3251 */
3252 save_compile_flag = ctx->CompileFlag;
3253 ctx->CompileFlag = GL_FALSE;
3254
3255 FLUSH_VB( ctx, "call lists" );
3256
3257 for (i=0;i<n;i++) {
3258 list = translate_id( i, type, lists );
3259 execute_list( ctx, ctx->List.ListBase + list );
3260 }
3261
3262 ctx->CompileFlag = save_compile_flag;
3263
3264 /* also restore API function pointers to point to "save" versions */
3265 if (save_compile_flag)
3266 ctx->API = ctx->Save;
3267
3268
3269 /* RESET_IMMEDIATE( ctx ); */
3270 }
3271
3272
3273
3274 /*
3275 * Set the offset added to list numbers in glCallLists.
3276 */
3277 void gl_ListBase( GLcontext *ctx, GLuint base )
3278 {
3279 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glListBase");
3280 ctx->List.ListBase = base;
3281 }
3282
3283
3284
3285
3286
3287
3288 /*
3289 * Assign all the pointers in 'table' to point to Mesa's display list
3290 * building functions.
3291 */
3292 void gl_init_dlist_pointers( struct gl_api_table *table )
3293 {
3294 table->Accum = save_Accum;
3295 table->AlphaFunc = save_AlphaFunc;
3296 table->AreTexturesResident = gl_AreTexturesResident;
3297 table->BindTexture = save_BindTexture;
3298 table->Bitmap = save_Bitmap;
3299 table->BlendColor = save_BlendColor;
3300 table->BlendEquation = save_BlendEquation;
3301 table->BlendFunc = save_BlendFunc;
3302 table->BlendFuncSeparate = save_BlendFuncSeparate;
3303 table->CallList = save_CallList;
3304 table->CallLists = save_CallLists;
3305 table->Clear = save_Clear;
3306 table->ClearAccum = save_ClearAccum;
3307 table->ClearColor = save_ClearColor;
3308 table->ClearDepth = save_ClearDepth;
3309 table->ClearIndex = save_ClearIndex;
3310 table->ClearStencil = save_ClearStencil;
3311 table->ClipPlane = save_ClipPlane;
3312 table->ColorMask = save_ColorMask;
3313 table->ColorMaterial = save_ColorMaterial;
3314 table->ColorTable = save_ColorTable;
3315 table->ColorSubTable = save_ColorSubTable;
3316 table->CopyPixels = save_CopyPixels;
3317 table->CopyTexImage1D = save_CopyTexImage1D;
3318 table->CopyTexImage2D = save_CopyTexImage2D;
3319 table->CopyTexSubImage1D = save_CopyTexSubImage1D;
3320 table->CopyTexSubImage2D = save_CopyTexSubImage2D;
3321 table->CopyTexSubImage3D = save_CopyTexSubImage3D;
3322 table->CullFace = save_CullFace;
3323 table->DeleteLists = gl_DeleteLists; /* NOT SAVED */
3324 table->DeleteTextures = gl_DeleteTextures; /* NOT SAVED */
3325 table->DepthFunc = save_DepthFunc;
3326 table->DepthMask = save_DepthMask;
3327 table->DepthRange = save_DepthRange;
3328 table->Disable = save_Disable;
3329 table->DisableClientState = gl_DisableClientState; /* NOT SAVED */
3330 table->DrawBuffer = save_DrawBuffer;
3331 table->DrawPixels = save_DrawPixels;
3332 table->Enable = save_Enable;
3333 table->Error = gl_save_error;
3334 table->EnableClientState = gl_EnableClientState; /* NOT SAVED */
3335 table->EndList = gl_EndList; /* NOT SAVED */
3336 table->EvalMesh1 = save_EvalMesh1;
3337 table->EvalMesh2 = save_EvalMesh2;
3338 table->FeedbackBuffer = gl_FeedbackBuffer; /* NOT SAVED */
3339 table->Finish = gl_Finish; /* NOT SAVED */
3340 table->Flush = gl_Flush; /* NOT SAVED */
3341 table->Fogfv = save_Fogfv;
3342 table->FrontFace = save_FrontFace;
3343 table->Frustum = save_Frustum;
3344 table->GenLists = gl_GenLists; /* NOT SAVED */
3345 table->GenTextures = gl_GenTextures; /* NOT SAVED */
3346
3347 /* NONE OF THESE COMMANDS ARE COMPILED INTO DISPLAY LISTS */
3348 table->GetBooleanv = gl_GetBooleanv;
3349 table->GetClipPlane = gl_GetClipPlane;
3350 table->GetColorTable = gl_GetColorTable;
3351 table->GetColorTableParameteriv = gl_GetColorTableParameteriv;
3352 table->GetDoublev = gl_GetDoublev;
3353 table->GetError = gl_GetError;
3354 table->GetFloatv = gl_GetFloatv;
3355 table->GetIntegerv = gl_GetIntegerv;
3356 table->GetString = gl_GetString;
3357 table->GetLightfv = gl_GetLightfv;
3358 table->GetLightiv = gl_GetLightiv;
3359 table->GetMapdv = gl_GetMapdv;
3360 table->GetMapfv = gl_GetMapfv;
3361 table->GetMapiv = gl_GetMapiv;
3362 table->GetMaterialfv = gl_GetMaterialfv;
3363 table->GetMaterialiv = gl_GetMaterialiv;
3364 table->GetPixelMapfv = gl_GetPixelMapfv;
3365 table->GetPixelMapuiv = gl_GetPixelMapuiv;
3366 table->GetPixelMapusv = gl_GetPixelMapusv;
3367 table->GetPointerv = gl_GetPointerv;
3368 table->GetPolygonStipple = gl_GetPolygonStipple;
3369 table->GetTexEnvfv = gl_GetTexEnvfv;
3370 table->GetTexEnviv = gl_GetTexEnviv;
3371 table->GetTexGendv = gl_GetTexGendv;
3372 table->GetTexGenfv = gl_GetTexGenfv;
3373 table->GetTexGeniv = gl_GetTexGeniv;
3374 table->GetTexImage = gl_GetTexImage;
3375 table->GetTexLevelParameterfv = gl_GetTexLevelParameterfv;
3376 table->GetTexLevelParameteriv = gl_GetTexLevelParameteriv;
3377 table->GetTexParameterfv = gl_GetTexParameterfv;
3378 table->GetTexParameteriv = gl_GetTexParameteriv;
3379
3380 table->Hint = save_Hint;
3381 table->IndexMask = save_IndexMask;
3382 table->InitNames = save_InitNames;
3383 table->IsEnabled = gl_IsEnabled; /* NOT SAVED */
3384 table->IsTexture = gl_IsTexture; /* NOT SAVED */
3385 table->IsList = gl_IsList; /* NOT SAVED */
3386 table->LightModelfv = save_LightModelfv;
3387 table->Lightfv = save_Lightfv;
3388 table->LineStipple = save_LineStipple;
3389 table->LineWidth = save_LineWidth;
3390 table->ListBase = save_ListBase;
3391 table->LoadIdentity = save_LoadIdentity;
3392 table->LoadMatrixf = save_LoadMatrixf;
3393 table->LoadName = save_LoadName;
3394 table->LogicOp = save_LogicOp;
3395 table->Map1f = save_Map1f;
3396 table->Map2f = save_Map2f;
3397 table->MapGrid1f = save_MapGrid1f;
3398 table->MapGrid2f = save_MapGrid2f;
3399 table->MatrixMode = save_MatrixMode;
3400 table->MultMatrixf = save_MultMatrixf;
3401 table->NewList = save_NewList;
3402 table->Ortho = save_Ortho;
3403 table->PointParameterfvEXT = save_PointParameterfvEXT;
3404 table->PassThrough = save_PassThrough;
3405 table->PixelMapfv = save_PixelMapfv;
3406 table->PixelStorei = gl_PixelStorei; /* NOT SAVED */
3407 table->PixelTransferf = save_PixelTransferf;
3408 table->PixelZoom = save_PixelZoom;
3409 table->PointSize = save_PointSize;
3410 table->PolygonMode = save_PolygonMode;
3411 table->PolygonOffset = save_PolygonOffset;
3412 table->PolygonStipple = save_PolygonStipple;
3413 table->PopAttrib = save_PopAttrib;
3414 table->PopClientAttrib = gl_PopClientAttrib; /* NOT SAVED */
3415 table->PopMatrix = save_PopMatrix;
3416 table->PopName = save_PopName;
3417 table->PrioritizeTextures = save_PrioritizeTextures;
3418 table->PushAttrib = save_PushAttrib;
3419 table->PushClientAttrib = gl_PushClientAttrib; /* NOT SAVED */
3420 table->PushMatrix = save_PushMatrix;
3421 table->PushName = save_PushName;
3422 table->RasterPos4f = save_RasterPos4f;
3423 table->ReadBuffer = save_ReadBuffer;
3424 table->ReadPixels = gl_ReadPixels; /* NOT SAVED */
3425 table->Rectf = save_Rectf;
3426 table->RenderMode = gl_RenderMode; /* NOT SAVED */
3427 table->Rotatef = save_Rotatef;
3428 table->Scalef = save_Scalef;
3429 table->Scissor = save_Scissor;
3430 table->SelectBuffer = gl_SelectBuffer; /* NOT SAVED */
3431 table->ShadeModel = save_ShadeModel;
3432 table->StencilFunc = save_StencilFunc;
3433 table->StencilMask = save_StencilMask;
3434 table->StencilOp = save_StencilOp;
3435 table->TexEnvfv = save_TexEnvfv;
3436 table->TexGenfv = save_TexGenfv;
3437 table->TexImage1D = save_TexImage1D;
3438 table->TexImage2D = save_TexImage2D;
3439 table->TexImage3D = save_TexImage3D;
3440 table->TexSubImage1D = save_TexSubImage1D;
3441 table->TexSubImage2D = save_TexSubImage2D;
3442 table->TexSubImage3D = save_TexSubImage3D;
3443 table->TexParameterfv = save_TexParameterfv;
3444 table->Translatef = save_Translatef;
3445 table->Viewport = save_Viewport;
3446
3447 /* GL_MESA_window_pos extension */
3448 table->WindowPos4fMESA = save_WindowPos4fMESA;
3449
3450 /* GL_MESA_resize_buffers extension */
3451 table->ResizeBuffersMESA = gl_ResizeBuffersMESA;
3452
3453 /* GL_ARB_multitexture */
3454 table->ActiveTexture = save_ActiveTexture;
3455 table->ClientActiveTexture = save_ClientActiveTexture;
3456 }
3457
3458
3459
3460 /***
3461 *** Debugging code
3462 ***/
3463 static const char *enum_string( GLenum k )
3464 {
3465 return gl_lookup_enum_by_nr( k );
3466 }
3467
3468
3469 /*
3470 * Print the commands in a display list. For debugging only.
3471 * TODO: many commands aren't handled yet.
3472 */
3473 static void print_list( GLcontext *ctx, FILE *f, GLuint list )
3474 {
3475 Node *n;
3476 GLboolean done;
3477 OpCode opcode;
3478
3479 if (!glIsList(list)) {
3480 fprintf(f,"%u is not a display list ID\n",list);
3481 return;
3482 }
3483
3484 n = (Node *) HashLookup(ctx->Shared->DisplayList, list);
3485
3486 fprintf( f, "START-LIST %u, address %p\n", list, (void*)n );
3487
3488 done = n ? GL_FALSE : GL_TRUE;
3489 while (!done) {
3490 opcode = n[0].opcode;
3491
3492 switch (opcode) {
3493 case OPCODE_ACCUM:
3494 fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f );
3495 break;
3496 case OPCODE_BITMAP:
3497 fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
3498 n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
3499 break;
3500 case OPCODE_CALL_LIST:
3501 fprintf(f,"CallList %d\n", (int) n[1].ui );
3502 break;
3503 case OPCODE_CALL_LIST_OFFSET:
3504 fprintf(f,"CallList %d + offset %u = %u\n", (int) n[1].ui,
3505 ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
3506 break;
3507 case OPCODE_DISABLE:
3508 fprintf(f,"Disable %s\n", enum_string(n[1].e));
3509 break;
3510 case OPCODE_ENABLE:
3511 fprintf(f,"Enable %s\n", enum_string(n[1].e));
3512 break;
3513 case OPCODE_FRUSTUM:
3514 fprintf(f,"Frustum %g %g %g %g %g %g\n",
3515 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
3516 break;
3517 case OPCODE_LINE_STIPPLE:
3518 fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us );
3519 break;
3520 case OPCODE_LOAD_IDENTITY:
3521 fprintf(f,"LoadIdentity\n");
3522 break;
3523 case OPCODE_LOAD_MATRIX:
3524 fprintf(f,"LoadMatrix\n");
3525 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
3526 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
3527 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
3528 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
3529 break;
3530 case OPCODE_MULT_MATRIX:
3531 fprintf(f,"MultMatrix (or Rotate)\n");
3532 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
3533 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
3534 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
3535 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
3536 break;
3537 case OPCODE_ORTHO:
3538 fprintf(f,"Ortho %g %g %g %g %g %g\n",
3539 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
3540 break;
3541 case OPCODE_POP_ATTRIB:
3542 fprintf(f,"PopAttrib\n");
3543 break;
3544 case OPCODE_POP_MATRIX:
3545 fprintf(f,"PopMatrix\n");
3546 break;
3547 case OPCODE_POP_NAME:
3548 fprintf(f,"PopName\n");
3549 break;
3550 case OPCODE_PUSH_ATTRIB:
3551 fprintf(f,"PushAttrib %x\n", n[1].bf );
3552 break;
3553 case OPCODE_PUSH_MATRIX:
3554 fprintf(f,"PushMatrix\n");
3555 break;
3556 case OPCODE_PUSH_NAME:
3557 fprintf(f,"PushName %d\n", (int) n[1].ui );
3558 break;
3559 case OPCODE_RASTER_POS:
3560 fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f);
3561 break;
3562 case OPCODE_RECTF:
3563 fprintf( f, "Rectf %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
3564 break;
3565 case OPCODE_SCALE:
3566 fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
3567 break;
3568 case OPCODE_TRANSLATE:
3569 fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
3570 break;
3571 case OPCODE_BIND_TEXTURE:
3572 fprintf(f,"BindTexture %s %d\n", gl_lookup_enum_by_nr(n[1].ui),
3573 n[2].ui);
3574 break;
3575 case OPCODE_SHADE_MODEL:
3576 fprintf(f,"ShadeModel %s\n", gl_lookup_enum_by_nr(n[1].ui));
3577 break;
3578
3579 /*
3580 * meta opcodes/commands
3581 */
3582 case OPCODE_ERROR:
3583 fprintf(f,"Error: %s %s\n", enum_string(n[1].e), (const char *)n[2].data );
3584 break;
3585 case OPCODE_VERTEX_CASSETTE:
3586 fprintf(f,"VERTEX-CASSETTE, id %u, rows %u..%u\n",
3587 ((struct immediate *) n[1].data)->id,
3588 n[2].ui,
3589 n[3].ui);
3590 /* gl_print_cassette( (struct immediate *) n[1].data, */
3591 /* 0, ~0 ); */
3592 break;
3593 case OPCODE_CONTINUE:
3594 fprintf(f,"DISPLAY-LIST-CONTINUE\n");
3595 n = (Node *) n[1].next;
3596 break;
3597 case OPCODE_END_OF_LIST:
3598 fprintf(f,"END-LIST %u\n", list);
3599 done = GL_TRUE;
3600 break;
3601 default:
3602 if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
3603 fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
3604 opcode, (void*) n);
3605 return;
3606 }
3607 else {
3608 fprintf(f,"command %d, %u operands\n",opcode,InstSize[opcode]);
3609 }
3610 }
3611
3612 /* increment n to point to next compiled command */
3613 if (opcode!=OPCODE_CONTINUE) {
3614 n += InstSize[opcode];
3615 }
3616 }
3617 }
3618
3619
3620
3621
3622
3623
3624
3625
3626 /*
3627 * Clients may call this function to help debug display list problems.
3628 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
3629 * changed, or break in the future without notice.
3630 */
3631 void mesa_print_display_list( GLuint list )
3632 {
3633 GET_CONTEXT;
3634 print_list( CC, stderr, list );
3635 }