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