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