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