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