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