source: trunk/src/opengl/mesa/dlist.c

Last change on this file was 3598, checked in by jeroen, 25 years ago

* empty log message *

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