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