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