Overhaul of texture image handling.
[mesa.git] / src / mesa / main / dlist.c
1 /* $Id: dlist.c,v 1.64 2001/02/06 21:42:48 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 gl_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 gl_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 gl_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 = gl_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 = gl_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 = gl_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 = gl_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 gl_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 save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
2383 {
2384 GET_CURRENT_CONTEXT(ctx);
2385 Node *n;
2386 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2387 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_MAP, 3 );
2388 if (n) {
2389 n[1].e = map;
2390 n[2].i = mapsize;
2391 n[3].data = (void *) MALLOC( mapsize * sizeof(GLfloat) );
2392 MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
2393 }
2394 if (ctx->ExecuteFlag) {
2395 (*ctx->Exec->PixelMapfv)( map, mapsize, values );
2396 }
2397 }
2398
2399
2400 static void save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
2401 {
2402 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2403 GLint i;
2404 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
2405 for (i=0;i<mapsize;i++) {
2406 fvalues[i] = (GLfloat) values[i];
2407 }
2408 }
2409 else {
2410 for (i=0;i<mapsize;i++) {
2411 fvalues[i] = UINT_TO_FLOAT( values[i] );
2412 }
2413 }
2414 save_PixelMapfv(map, mapsize, fvalues);
2415 }
2416
2417
2418 static void save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
2419 {
2420 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2421 GLint i;
2422 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
2423 for (i=0;i<mapsize;i++) {
2424 fvalues[i] = (GLfloat) values[i];
2425 }
2426 }
2427 else {
2428 for (i=0;i<mapsize;i++) {
2429 fvalues[i] = USHORT_TO_FLOAT( values[i] );
2430 }
2431 }
2432 save_PixelMapfv(map, mapsize, fvalues);
2433 }
2434
2435
2436 static void save_PixelTransferf( GLenum pname, GLfloat param )
2437 {
2438 GET_CURRENT_CONTEXT(ctx);
2439 Node *n;
2440 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2441 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TRANSFER, 2 );
2442 if (n) {
2443 n[1].e = pname;
2444 n[2].f = param;
2445 }
2446 if (ctx->ExecuteFlag) {
2447 (*ctx->Exec->PixelTransferf)( pname, param );
2448 }
2449 }
2450
2451
2452 static void save_PixelTransferi( GLenum pname, GLint param )
2453 {
2454 save_PixelTransferf( pname, (GLfloat) param );
2455 }
2456
2457
2458 static void save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
2459 {
2460 GET_CURRENT_CONTEXT(ctx);
2461 Node *n;
2462 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2463 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_ZOOM, 2 );
2464 if (n) {
2465 n[1].f = xfactor;
2466 n[2].f = yfactor;
2467 }
2468 if (ctx->ExecuteFlag) {
2469 (*ctx->Exec->PixelZoom)( xfactor, yfactor );
2470 }
2471 }
2472
2473
2474 static void save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
2475 {
2476 GET_CURRENT_CONTEXT(ctx);
2477 Node *n;
2478 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2479 n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_PARAMETERS, 4 );
2480 if (n) {
2481 n[1].e = pname;
2482 n[2].f = params[0];
2483 n[3].f = params[1];
2484 n[4].f = params[2];
2485 }
2486 if (ctx->ExecuteFlag) {
2487 (*ctx->Exec->PointParameterfvEXT)( pname, params );
2488 }
2489 }
2490
2491
2492 static void save_PointParameterfEXT( GLenum pname, GLfloat param )
2493 {
2494 save_PointParameterfvEXT(pname, &param);
2495 }
2496
2497
2498 static void save_PointSize( GLfloat size )
2499 {
2500 GET_CURRENT_CONTEXT(ctx);
2501 Node *n;
2502 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2503 n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_SIZE, 1 );
2504 if (n) {
2505 n[1].f = size;
2506 }
2507 if (ctx->ExecuteFlag) {
2508 (*ctx->Exec->PointSize)( size );
2509 }
2510 }
2511
2512
2513 static void save_PolygonMode( GLenum face, GLenum mode )
2514 {
2515 GET_CURRENT_CONTEXT(ctx);
2516 Node *n;
2517 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2518 n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_MODE, 2 );
2519 if (n) {
2520 n[1].e = face;
2521 n[2].e = mode;
2522 }
2523 if (ctx->ExecuteFlag) {
2524 (*ctx->Exec->PolygonMode)( face, mode );
2525 }
2526 }
2527
2528
2529 /*
2530 * Polygon stipple must have been upacked already!
2531 */
2532 static void save_PolygonStipple( const GLubyte *pattern )
2533 {
2534 GET_CURRENT_CONTEXT(ctx);
2535 Node *n;
2536 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2537 n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_STIPPLE, 1 );
2538 if (n) {
2539 void *data;
2540 n[1].data = MALLOC( 32 * 4 );
2541 data = n[1].data; /* This needed for Acorn compiler */
2542 MEMCPY( data, pattern, 32 * 4 );
2543 }
2544 if (ctx->ExecuteFlag) {
2545 (*ctx->Exec->PolygonStipple)( (GLubyte*) pattern );
2546 }
2547 }
2548
2549
2550 static void save_PolygonOffset( GLfloat factor, GLfloat units )
2551 {
2552 GET_CURRENT_CONTEXT(ctx);
2553 Node *n;
2554 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2555 n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_OFFSET, 2 );
2556 if (n) {
2557 n[1].f = factor;
2558 n[2].f = units;
2559 }
2560 if (ctx->ExecuteFlag) {
2561 (*ctx->Exec->PolygonOffset)( factor, units );
2562 }
2563 }
2564
2565
2566 static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
2567 {
2568 GET_CURRENT_CONTEXT(ctx);
2569 save_PolygonOffset(factor, ctx->DepthMaxF * bias);
2570 }
2571
2572
2573 static void save_PopAttrib( void )
2574 {
2575 GET_CURRENT_CONTEXT(ctx);
2576 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2577 (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_ATTRIB, 0 );
2578 if (ctx->ExecuteFlag) {
2579 (*ctx->Exec->PopAttrib)();
2580 }
2581 }
2582
2583
2584 static void save_PopMatrix( void )
2585 {
2586 GET_CURRENT_CONTEXT(ctx);
2587 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2588 (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_MATRIX, 0 );
2589 if (ctx->ExecuteFlag) {
2590 (*ctx->Exec->PopMatrix)();
2591 }
2592 }
2593
2594
2595 static void save_PopName( void )
2596 {
2597 GET_CURRENT_CONTEXT(ctx);
2598 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2599 (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_NAME, 0 );
2600 if (ctx->ExecuteFlag) {
2601 (*ctx->Exec->PopName)();
2602 }
2603 }
2604
2605
2606 static void save_PrioritizeTextures( GLsizei num, const GLuint *textures,
2607 const GLclampf *priorities )
2608 {
2609 GET_CURRENT_CONTEXT(ctx);
2610 GLint i;
2611 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2612
2613 for (i=0;i<num;i++) {
2614 Node *n;
2615 n = ALLOC_INSTRUCTION( ctx, OPCODE_PRIORITIZE_TEXTURE, 2 );
2616 if (n) {
2617 n[1].ui = textures[i];
2618 n[2].f = priorities[i];
2619 }
2620 }
2621 if (ctx->ExecuteFlag) {
2622 (*ctx->Exec->PrioritizeTextures)( num, textures, priorities );
2623 }
2624 }
2625
2626
2627 static void save_PushAttrib( GLbitfield mask )
2628 {
2629 GET_CURRENT_CONTEXT(ctx);
2630 Node *n;
2631 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2632 n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_ATTRIB, 1 );
2633 if (n) {
2634 n[1].bf = mask;
2635 }
2636 if (ctx->ExecuteFlag) {
2637 (*ctx->Exec->PushAttrib)( mask );
2638 }
2639 }
2640
2641
2642 static void save_PushMatrix( void )
2643 {
2644 GET_CURRENT_CONTEXT(ctx);
2645 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2646 (void) ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_MATRIX, 0 );
2647 if (ctx->ExecuteFlag) {
2648 (*ctx->Exec->PushMatrix)();
2649 }
2650 }
2651
2652
2653 static void save_PushName( GLuint name )
2654 {
2655 GET_CURRENT_CONTEXT(ctx);
2656 Node *n;
2657 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2658 n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_NAME, 1 );
2659 if (n) {
2660 n[1].ui = name;
2661 }
2662 if (ctx->ExecuteFlag) {
2663 (*ctx->Exec->PushName)( name );
2664 }
2665 }
2666
2667
2668 static void save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
2669 {
2670 GET_CURRENT_CONTEXT(ctx);
2671 Node *n;
2672 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2673 n = ALLOC_INSTRUCTION( ctx, OPCODE_RASTER_POS, 4 );
2674 if (n) {
2675 n[1].f = x;
2676 n[2].f = y;
2677 n[3].f = z;
2678 n[4].f = w;
2679 }
2680 if (ctx->ExecuteFlag) {
2681 (*ctx->Exec->RasterPos4f)( x, y, z, w );
2682 }
2683 }
2684
2685 static void save_RasterPos2d(GLdouble x, GLdouble y)
2686 {
2687 save_RasterPos4f(x, y, 0.0F, 1.0F);
2688 }
2689
2690 static void save_RasterPos2f(GLfloat x, GLfloat y)
2691 {
2692 save_RasterPos4f(x, y, 0.0F, 1.0F);
2693 }
2694
2695 static void save_RasterPos2i(GLint x, GLint y)
2696 {
2697 save_RasterPos4f(x, y, 0.0F, 1.0F);
2698 }
2699
2700 static void save_RasterPos2s(GLshort x, GLshort y)
2701 {
2702 save_RasterPos4f(x, y, 0.0F, 1.0F);
2703 }
2704
2705 static void save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
2706 {
2707 save_RasterPos4f(x, y, z, 1.0F);
2708 }
2709
2710 static void save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
2711 {
2712 save_RasterPos4f(x, y, z, 1.0F);
2713 }
2714
2715 static void save_RasterPos3i(GLint x, GLint y, GLint z)
2716 {
2717 save_RasterPos4f(x, y, z, 1.0F);
2718 }
2719
2720 static void save_RasterPos3s(GLshort x, GLshort y, GLshort z)
2721 {
2722 save_RasterPos4f(x, y, z, 1.0F);
2723 }
2724
2725 static void save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
2726 {
2727 save_RasterPos4f(x, y, z, w);
2728 }
2729
2730 static void save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
2731 {
2732 save_RasterPos4f(x, y, z, w);
2733 }
2734
2735 static void save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
2736 {
2737 save_RasterPos4f(x, y, z, w);
2738 }
2739
2740 static void save_RasterPos2dv(const GLdouble *v)
2741 {
2742 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2743 }
2744
2745 static void save_RasterPos2fv(const GLfloat *v)
2746 {
2747 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2748 }
2749
2750 static void save_RasterPos2iv(const GLint *v)
2751 {
2752 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2753 }
2754
2755 static void save_RasterPos2sv(const GLshort *v)
2756 {
2757 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2758 }
2759
2760 static void save_RasterPos3dv(const GLdouble *v)
2761 {
2762 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2763 }
2764
2765 static void save_RasterPos3fv(const GLfloat *v)
2766 {
2767 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2768 }
2769
2770 static void save_RasterPos3iv(const GLint *v)
2771 {
2772 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2773 }
2774
2775 static void save_RasterPos3sv(const GLshort *v)
2776 {
2777 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2778 }
2779
2780 static void save_RasterPos4dv(const GLdouble *v)
2781 {
2782 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2783 }
2784
2785 static void save_RasterPos4fv(const GLfloat *v)
2786 {
2787 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2788 }
2789
2790 static void save_RasterPos4iv(const GLint *v)
2791 {
2792 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2793 }
2794
2795 static void save_RasterPos4sv(const GLshort *v)
2796 {
2797 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2798 }
2799
2800
2801 static void save_PassThrough( GLfloat token )
2802 {
2803 GET_CURRENT_CONTEXT(ctx);
2804 Node *n;
2805 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2806 n = ALLOC_INSTRUCTION( ctx, OPCODE_PASSTHROUGH, 1 );
2807 if (n) {
2808 n[1].f = token;
2809 }
2810 if (ctx->ExecuteFlag) {
2811 (*ctx->Exec->PassThrough)( token );
2812 }
2813 }
2814
2815
2816 static void save_ReadBuffer( GLenum mode )
2817 {
2818 GET_CURRENT_CONTEXT(ctx);
2819 Node *n;
2820 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2821 n = ALLOC_INSTRUCTION( ctx, OPCODE_READ_BUFFER, 1 );
2822 if (n) {
2823 n[1].e = mode;
2824 }
2825 if (ctx->ExecuteFlag) {
2826 (*ctx->Exec->ReadBuffer)( mode );
2827 }
2828 }
2829
2830
2831 static void
2832 save_ResetHistogram(GLenum target)
2833 {
2834 GET_CURRENT_CONTEXT(ctx);
2835 Node *n;
2836 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2837 n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_HISTOGRAM, 1 );
2838 if (n) {
2839 n[1].e = target;
2840 }
2841 if (ctx->ExecuteFlag) {
2842 (*ctx->Exec->ResetHistogram)( target );
2843 }
2844 }
2845
2846
2847 static void
2848 save_ResetMinmax(GLenum target)
2849 {
2850 GET_CURRENT_CONTEXT(ctx);
2851 Node *n;
2852 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2853 n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_MIN_MAX, 1 );
2854 if (n) {
2855 n[1].e = target;
2856 }
2857 if (ctx->ExecuteFlag) {
2858 (*ctx->Exec->ResetMinmax)( target );
2859 }
2860 }
2861
2862
2863 static void save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
2864 {
2865 GET_CURRENT_CONTEXT(ctx);
2866 Node *n;
2867 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2868 n = ALLOC_INSTRUCTION( ctx, OPCODE_ROTATE, 4 );
2869 if (n) {
2870 n[1].f = angle;
2871 n[2].f = x;
2872 n[3].f = y;
2873 n[4].f = z;
2874 }
2875 if (ctx->ExecuteFlag) {
2876 (*ctx->Exec->Rotatef)( angle, x, y, z );
2877 }
2878 }
2879
2880
2881 static void save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
2882 {
2883 save_Rotatef(angle, x, y, z);
2884 }
2885
2886
2887 static void save_Scalef( GLfloat x, GLfloat y, GLfloat z )
2888 {
2889 GET_CURRENT_CONTEXT(ctx);
2890 Node *n;
2891 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2892 n = ALLOC_INSTRUCTION( ctx, OPCODE_SCALE, 3 );
2893 if (n) {
2894 n[1].f = x;
2895 n[2].f = y;
2896 n[3].f = z;
2897 }
2898 if (ctx->ExecuteFlag) {
2899 (*ctx->Exec->Scalef)( x, y, z );
2900 }
2901 }
2902
2903
2904 static void save_Scaled( GLdouble x, GLdouble y, GLdouble z )
2905 {
2906 save_Scalef(x, y, z);
2907 }
2908
2909
2910 static void save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
2911 {
2912 GET_CURRENT_CONTEXT(ctx);
2913 Node *n;
2914 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2915 n = ALLOC_INSTRUCTION( ctx, OPCODE_SCISSOR, 4 );
2916 if (n) {
2917 n[1].i = x;
2918 n[2].i = y;
2919 n[3].i = width;
2920 n[4].i = height;
2921 }
2922 if (ctx->ExecuteFlag) {
2923 (*ctx->Exec->Scissor)( x, y, width, height );
2924 }
2925 }
2926
2927
2928 static void save_ShadeModel( GLenum mode )
2929 {
2930 GET_CURRENT_CONTEXT(ctx);
2931 Node *n;
2932 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2933 n = ALLOC_INSTRUCTION( ctx, OPCODE_SHADE_MODEL, 1 );
2934 if (n) {
2935 n[1].e = mode;
2936 }
2937 if (ctx->ExecuteFlag) {
2938 (*ctx->Exec->ShadeModel)( mode );
2939 }
2940 }
2941
2942
2943 static void save_StencilFunc( GLenum func, GLint ref, GLuint mask )
2944 {
2945 GET_CURRENT_CONTEXT(ctx);
2946 Node *n;
2947 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2948 n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_FUNC, 3 );
2949 if (n) {
2950 n[1].e = func;
2951 n[2].i = ref;
2952 n[3].ui = mask;
2953 }
2954 if (ctx->ExecuteFlag) {
2955 (*ctx->Exec->StencilFunc)( func, ref, mask );
2956 }
2957 }
2958
2959
2960 static void save_StencilMask( GLuint mask )
2961 {
2962 GET_CURRENT_CONTEXT(ctx);
2963 Node *n;
2964 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2965 n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_MASK, 1 );
2966 if (n) {
2967 n[1].ui = mask;
2968 }
2969 if (ctx->ExecuteFlag) {
2970 (*ctx->Exec->StencilMask)( mask );
2971 }
2972 }
2973
2974
2975 static void save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
2976 {
2977 GET_CURRENT_CONTEXT(ctx);
2978 Node *n;
2979 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2980 n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_OP, 3 );
2981 if (n) {
2982 n[1].e = fail;
2983 n[2].e = zfail;
2984 n[3].e = zpass;
2985 }
2986 if (ctx->ExecuteFlag) {
2987 (*ctx->Exec->StencilOp)( fail, zfail, zpass );
2988 }
2989 }
2990
2991
2992 static void save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
2993 {
2994 GET_CURRENT_CONTEXT(ctx);
2995 Node *n;
2996 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2997 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXENV, 6 );
2998 if (n) {
2999 n[1].e = target;
3000 n[2].e = pname;
3001 n[3].f = params[0];
3002 n[4].f = params[1];
3003 n[5].f = params[2];
3004 n[6].f = params[3];
3005 }
3006 if (ctx->ExecuteFlag) {
3007 (*ctx->Exec->TexEnvfv)( target, pname, params );
3008 }
3009 }
3010
3011
3012 static void save_TexEnvf( GLenum target, GLenum pname, GLfloat param )
3013 {
3014 save_TexEnvfv( target, pname, &param );
3015 }
3016
3017
3018 static void save_TexEnvi( GLenum target, GLenum pname, GLint param )
3019 {
3020 GLfloat p[4];
3021 p[0] = (GLfloat) param;
3022 p[1] = p[2] = p[3] = 0.0;
3023 save_TexEnvfv( target, pname, p );
3024 }
3025
3026
3027 static void save_TexEnviv( GLenum target, GLenum pname, const GLint *param )
3028 {
3029 GLfloat p[4];
3030 p[0] = INT_TO_FLOAT( param[0] );
3031 p[1] = INT_TO_FLOAT( param[1] );
3032 p[2] = INT_TO_FLOAT( param[2] );
3033 p[3] = INT_TO_FLOAT( param[3] );
3034 save_TexEnvfv( target, pname, p );
3035 }
3036
3037
3038 static void save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
3039 {
3040 GET_CURRENT_CONTEXT(ctx);
3041 Node *n;
3042 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3043 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXGEN, 6 );
3044 if (n) {
3045 n[1].e = coord;
3046 n[2].e = pname;
3047 n[3].f = params[0];
3048 n[4].f = params[1];
3049 n[5].f = params[2];
3050 n[6].f = params[3];
3051 }
3052 if (ctx->ExecuteFlag) {
3053 (*ctx->Exec->TexGenfv)( coord, pname, params );
3054 }
3055 }
3056
3057
3058 static void save_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
3059 {
3060 GLfloat p[4];
3061 p[0] = params[0];
3062 p[1] = params[1];
3063 p[2] = params[2];
3064 p[3] = params[3];
3065 save_TexGenfv(coord, pname, p);
3066 }
3067
3068
3069 static void save_TexGend(GLenum coord, GLenum pname, GLdouble param )
3070 {
3071 GLfloat p = (GLfloat) param;
3072 save_TexGenfv( coord, pname, &p );
3073 }
3074
3075
3076 static void save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
3077 {
3078 GLfloat p[4];
3079 p[0] = params[0];
3080 p[1] = params[1];
3081 p[2] = params[2];
3082 p[3] = params[3];
3083 save_TexGenfv( coord, pname, p );
3084 }
3085
3086
3087 static void save_TexGenf( GLenum coord, GLenum pname, GLfloat param )
3088 {
3089 save_TexGenfv(coord, pname, &param);
3090 }
3091
3092
3093 static void save_TexGeni( GLenum coord, GLenum pname, GLint param )
3094 {
3095 save_TexGeniv( coord, pname, &param );
3096 }
3097
3098
3099 static void save_TexParameterfv( GLenum target,
3100 GLenum pname, const GLfloat *params )
3101 {
3102 GET_CURRENT_CONTEXT(ctx);
3103 Node *n;
3104 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3105 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXPARAMETER, 6 );
3106 if (n) {
3107 n[1].e = target;
3108 n[2].e = pname;
3109 n[3].f = params[0];
3110 n[4].f = params[1];
3111 n[5].f = params[2];
3112 n[6].f = params[3];
3113 }
3114 if (ctx->ExecuteFlag) {
3115 (*ctx->Exec->TexParameterfv)( target, pname, params );
3116 }
3117 }
3118
3119
3120 static void save_TexParameterf( GLenum target, GLenum pname, GLfloat param )
3121 {
3122 save_TexParameterfv(target, pname, &param);
3123 }
3124
3125
3126 static void save_TexParameteri( GLenum target, GLenum pname, const GLint param )
3127 {
3128 GLfloat fparam[4];
3129 fparam[0] = (GLfloat) param;
3130 fparam[1] = fparam[2] = fparam[3] = 0.0;
3131 save_TexParameterfv(target, pname, fparam);
3132 }
3133
3134
3135 static void save_TexParameteriv( GLenum target, GLenum pname, const GLint *params )
3136 {
3137 GLfloat fparam[4];
3138 fparam[0] = (GLfloat) params[0];
3139 fparam[1] = fparam[2] = fparam[3] = 0.0;
3140 save_TexParameterfv(target, pname, fparam);
3141 }
3142
3143
3144 static void save_TexImage1D( GLenum target,
3145 GLint level, GLint components,
3146 GLsizei width, GLint border,
3147 GLenum format, GLenum type,
3148 const GLvoid *pixels )
3149 {
3150 GET_CURRENT_CONTEXT(ctx);
3151 if (target == GL_PROXY_TEXTURE_1D) {
3152 /* don't compile, execute immediately */
3153 (*ctx->Exec->TexImage1D)( target, level, components, width,
3154 border, format, type, pixels );
3155 }
3156 else {
3157 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
3158 pixels, &ctx->Unpack);
3159 Node *n;
3160 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3161 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE1D, 8 );
3162 if (n) {
3163 n[1].e = target;
3164 n[2].i = level;
3165 n[3].i = components;
3166 n[4].i = (GLint) width;
3167 n[5].i = border;
3168 n[6].e = format;
3169 n[7].e = type;
3170 n[8].data = image;
3171 }
3172 else if (image) {
3173 FREE(image);
3174 }
3175 if (ctx->ExecuteFlag) {
3176 (*ctx->Exec->TexImage1D)( target, level, components, width,
3177 border, format, type, pixels );
3178 }
3179 }
3180 }
3181
3182
3183 static void save_TexImage2D( GLenum target,
3184 GLint level, GLint components,
3185 GLsizei width, GLsizei height, GLint border,
3186 GLenum format, GLenum type,
3187 const GLvoid *pixels)
3188 {
3189 GET_CURRENT_CONTEXT(ctx);
3190 if (target == GL_PROXY_TEXTURE_2D) {
3191 /* don't compile, execute immediately */
3192 (*ctx->Exec->TexImage2D)( target, level, components, width,
3193 height, border, format, type, pixels );
3194 }
3195 else {
3196 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
3197 pixels, &ctx->Unpack);
3198 Node *n;
3199 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3200 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE2D, 9 );
3201 if (n) {
3202 n[1].e = target;
3203 n[2].i = level;
3204 n[3].i = components;
3205 n[4].i = (GLint) width;
3206 n[5].i = (GLint) height;
3207 n[6].i = border;
3208 n[7].e = format;
3209 n[8].e = type;
3210 n[9].data = image;
3211 }
3212 else if (image) {
3213 FREE(image);
3214 }
3215 if (ctx->ExecuteFlag) {
3216 (*ctx->Exec->TexImage2D)( target, level, components, width,
3217 height, border, format, type, pixels );
3218 }
3219 }
3220 }
3221
3222
3223 static void save_TexImage3D( GLenum target,
3224 GLint level, GLint internalFormat,
3225 GLsizei width, GLsizei height, GLsizei depth,
3226 GLint border,
3227 GLenum format, GLenum type,
3228 const GLvoid *pixels )
3229 {
3230 GET_CURRENT_CONTEXT(ctx);
3231 if (target == GL_PROXY_TEXTURE_3D) {
3232 /* don't compile, execute immediately */
3233 (*ctx->Exec->TexImage3D)( target, level, internalFormat, width,
3234 height, depth, border, format, type, pixels );
3235 }
3236 else {
3237 Node *n;
3238 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
3239 pixels, &ctx->Unpack);
3240 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3241 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE3D, 10 );
3242 if (n) {
3243 n[1].e = target;
3244 n[2].i = level;
3245 n[3].i = internalFormat;
3246 n[4].i = (GLint) width;
3247 n[5].i = (GLint) height;
3248 n[6].i = (GLint) depth;
3249 n[7].i = border;
3250 n[8].e = format;
3251 n[9].e = type;
3252 n[10].data = image;
3253 }
3254 else if (image) {
3255 FREE(image);
3256 }
3257 if (ctx->ExecuteFlag) {
3258 (*ctx->Exec->TexImage3D)( target, level, internalFormat, width,
3259 height, depth, border, format, type, pixels );
3260 }
3261 }
3262 }
3263
3264
3265 static void save_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
3266 GLsizei width, GLenum format, GLenum type,
3267 const GLvoid *pixels )
3268 {
3269 GET_CURRENT_CONTEXT(ctx);
3270 Node *n;
3271 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
3272 pixels, &ctx->Unpack);
3273 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3274 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
3275 if (n) {
3276 n[1].e = target;
3277 n[2].i = level;
3278 n[3].i = xoffset;
3279 n[4].i = (GLint) width;
3280 n[5].e = format;
3281 n[6].e = type;
3282 n[7].data = image;
3283 }
3284 else if (image) {
3285 FREE(image);
3286 }
3287 if (ctx->ExecuteFlag) {
3288 (*ctx->Exec->TexSubImage1D)( target, level, xoffset, width,
3289 format, type, pixels );
3290 }
3291 }
3292
3293
3294 static void save_TexSubImage2D( GLenum target, GLint level,
3295 GLint xoffset, GLint yoffset,
3296 GLsizei width, GLsizei height,
3297 GLenum format, GLenum type,
3298 const GLvoid *pixels )
3299 {
3300 GET_CURRENT_CONTEXT(ctx);
3301 Node *n;
3302 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
3303 pixels, &ctx->Unpack);
3304 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3305 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
3306 if (n) {
3307 n[1].e = target;
3308 n[2].i = level;
3309 n[3].i = xoffset;
3310 n[4].i = yoffset;
3311 n[5].i = (GLint) width;
3312 n[6].i = (GLint) height;
3313 n[7].e = format;
3314 n[8].e = type;
3315 n[9].data = image;
3316 }
3317 else if (image) {
3318 FREE(image);
3319 }
3320 if (ctx->ExecuteFlag) {
3321 (*ctx->Exec->TexSubImage2D)( target, level, xoffset, yoffset,
3322 width, height, format, type, pixels );
3323 }
3324 }
3325
3326
3327 static void save_TexSubImage3D( GLenum target, GLint level,
3328 GLint xoffset, GLint yoffset,GLint zoffset,
3329 GLsizei width, GLsizei height, GLsizei depth,
3330 GLenum format, GLenum type,
3331 const GLvoid *pixels )
3332 {
3333 GET_CURRENT_CONTEXT(ctx);
3334 Node *n;
3335 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
3336 pixels, &ctx->Unpack);
3337 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3338 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
3339 if (n) {
3340 n[1].e = target;
3341 n[2].i = level;
3342 n[3].i = xoffset;
3343 n[4].i = yoffset;
3344 n[5].i = zoffset;
3345 n[6].i = (GLint) width;
3346 n[7].i = (GLint) height;
3347 n[8].i = (GLint) depth;
3348 n[9].e = format;
3349 n[10].e = type;
3350 n[11].data = image;
3351 }
3352 else if (image) {
3353 FREE(image);
3354 }
3355 if (ctx->ExecuteFlag) {
3356 (*ctx->Exec->TexSubImage3D)( target, level,
3357 xoffset, yoffset, zoffset,
3358 width, height, depth, format, type, pixels );
3359 }
3360 }
3361
3362
3363 static void save_Translatef( GLfloat x, GLfloat y, GLfloat z )
3364 {
3365 GET_CURRENT_CONTEXT(ctx);
3366 Node *n;
3367 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3368 n = ALLOC_INSTRUCTION( ctx, OPCODE_TRANSLATE, 3 );
3369 if (n) {
3370 n[1].f = x;
3371 n[2].f = y;
3372 n[3].f = z;
3373 }
3374 if (ctx->ExecuteFlag) {
3375 (*ctx->Exec->Translatef)( x, y, z );
3376 }
3377 }
3378
3379
3380 static void save_Translated( GLdouble x, GLdouble y, GLdouble z )
3381 {
3382 save_Translatef(x, y, z);
3383 }
3384
3385
3386
3387 static void save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
3388 {
3389 GET_CURRENT_CONTEXT(ctx);
3390 Node *n;
3391 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3392 n = ALLOC_INSTRUCTION( ctx, OPCODE_VIEWPORT, 4 );
3393 if (n) {
3394 n[1].i = x;
3395 n[2].i = y;
3396 n[3].i = (GLint) width;
3397 n[4].i = (GLint) height;
3398 }
3399 if (ctx->ExecuteFlag) {
3400 (*ctx->Exec->Viewport)( x, y, width, height );
3401 }
3402 }
3403
3404
3405 static void save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
3406 {
3407 GET_CURRENT_CONTEXT(ctx);
3408 Node *n;
3409 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3410 n = ALLOC_INSTRUCTION( ctx, OPCODE_WINDOW_POS, 4 );
3411 if (n) {
3412 n[1].f = x;
3413 n[2].f = y;
3414 n[3].f = z;
3415 n[4].f = w;
3416 }
3417 if (ctx->ExecuteFlag) {
3418 (*ctx->Exec->WindowPos4fMESA)( x, y, z, w );
3419 }
3420 }
3421
3422 static void save_WindowPos2dMESA(GLdouble x, GLdouble y)
3423 {
3424 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3425 }
3426
3427 static void save_WindowPos2fMESA(GLfloat x, GLfloat y)
3428 {
3429 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3430 }
3431
3432 static void save_WindowPos2iMESA(GLint x, GLint y)
3433 {
3434 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3435 }
3436
3437 static void save_WindowPos2sMESA(GLshort x, GLshort y)
3438 {
3439 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3440 }
3441
3442 static void save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
3443 {
3444 save_WindowPos4fMESA(x, y, z, 1.0F);
3445 }
3446
3447 static void save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
3448 {
3449 save_WindowPos4fMESA(x, y, z, 1.0F);
3450 }
3451
3452 static void save_WindowPos3iMESA(GLint x, GLint y, GLint z)
3453 {
3454 save_WindowPos4fMESA(x, y, z, 1.0F);
3455 }
3456
3457 static void save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
3458 {
3459 save_WindowPos4fMESA(x, y, z, 1.0F);
3460 }
3461
3462 static void save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3463 {
3464 save_WindowPos4fMESA(x, y, z, w);
3465 }
3466
3467 static void save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
3468 {
3469 save_WindowPos4fMESA(x, y, z, w);
3470 }
3471
3472 static void save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
3473 {
3474 save_WindowPos4fMESA(x, y, z, w);
3475 }
3476
3477 static void save_WindowPos2dvMESA(const GLdouble *v)
3478 {
3479 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3480 }
3481
3482 static void save_WindowPos2fvMESA(const GLfloat *v)
3483 {
3484 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3485 }
3486
3487 static void save_WindowPos2ivMESA(const GLint *v)
3488 {
3489 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3490 }
3491
3492 static void save_WindowPos2svMESA(const GLshort *v)
3493 {
3494 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3495 }
3496
3497 static void save_WindowPos3dvMESA(const GLdouble *v)
3498 {
3499 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3500 }
3501
3502 static void save_WindowPos3fvMESA(const GLfloat *v)
3503 {
3504 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3505 }
3506
3507 static void save_WindowPos3ivMESA(const GLint *v)
3508 {
3509 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3510 }
3511
3512 static void save_WindowPos3svMESA(const GLshort *v)
3513 {
3514 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3515 }
3516
3517 static void save_WindowPos4dvMESA(const GLdouble *v)
3518 {
3519 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3520 }
3521
3522 static void save_WindowPos4fvMESA(const GLfloat *v)
3523 {
3524 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3525 }
3526
3527 static void save_WindowPos4ivMESA(const GLint *v)
3528 {
3529 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3530 }
3531
3532 static void save_WindowPos4svMESA(const GLshort *v)
3533 {
3534 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3535 }
3536
3537
3538
3539 /* GL_ARB_multitexture */
3540 static void save_ActiveTextureARB( GLenum target )
3541 {
3542 GET_CURRENT_CONTEXT(ctx);
3543 Node *n;
3544 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3545 n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
3546 if (n) {
3547 n[1].e = target;
3548 }
3549 if (ctx->ExecuteFlag) {
3550 (*ctx->Exec->ActiveTextureARB)( target );
3551 }
3552 }
3553
3554
3555 /* GL_ARB_multitexture */
3556 static void save_ClientActiveTextureARB( GLenum target )
3557 {
3558 GET_CURRENT_CONTEXT(ctx);
3559 Node *n;
3560 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3561 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 );
3562 if (n) {
3563 n[1].e = target;
3564 }
3565 if (ctx->ExecuteFlag) {
3566 (*ctx->Exec->ClientActiveTextureARB)( target );
3567 }
3568 }
3569
3570
3571
3572 /* GL_ARB_transpose_matrix */
3573
3574 static void save_LoadTransposeMatrixdARB( const GLdouble m[16] )
3575 {
3576 GLfloat tm[16];
3577 _math_transposefd(tm, m);
3578 save_LoadMatrixf(tm);
3579 }
3580
3581
3582 static void save_LoadTransposeMatrixfARB( const GLfloat m[16] )
3583 {
3584 GLfloat tm[16];
3585 _math_transposef(tm, m);
3586 save_LoadMatrixf(tm);
3587 }
3588
3589
3590 static void save_MultTransposeMatrixdARB( const GLdouble m[16] )
3591 {
3592 GLfloat tm[16];
3593 _math_transposefd(tm, m);
3594 save_MultMatrixf(tm);
3595 }
3596
3597
3598 static void save_MultTransposeMatrixfARB( const GLfloat m[16] )
3599 {
3600 GLfloat tm[16];
3601 _math_transposef(tm, m);
3602 save_MultMatrixf(tm);
3603 }
3604
3605
3606 static void save_PixelTexGenSGIX(GLenum mode)
3607 {
3608 GET_CURRENT_CONTEXT(ctx);
3609 Node *n;
3610 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3611 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_SGIX, 1 );
3612 if (n) {
3613 n[1].e = mode;
3614 }
3615 if (ctx->ExecuteFlag) {
3616 (*ctx->Exec->PixelTexGenSGIX)( mode );
3617 }
3618 }
3619
3620
3621 /* GL_ARB_texture_compression */
3622 static void
3623 save_CompressedTexImage1DARB(GLenum target, GLint level,
3624 GLenum internalFormat, GLsizei width,
3625 GLint border, GLsizei imageSize,
3626 const GLvoid *data)
3627 {
3628 GET_CURRENT_CONTEXT(ctx);
3629 if (target == GL_PROXY_TEXTURE_1D) {
3630 /* don't compile, execute immediately */
3631 (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat,
3632 width, border, imageSize, data);
3633 }
3634 else {
3635 Node *n;
3636 GLvoid *image;
3637 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3638 /* make copy of image */
3639 image = MALLOC(imageSize);
3640 if (!image) {
3641 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
3642 return;
3643 }
3644 MEMCPY(image, data, imageSize);
3645 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 8 );
3646 if (n) {
3647 n[1].e = target;
3648 n[2].i = level;
3649 n[3].e = internalFormat;
3650 n[4].i = (GLint) width;
3651 n[5].i = border;
3652 n[6].i = imageSize;
3653 n[7].data = image;
3654 }
3655 else if (image) {
3656 FREE(image);
3657 }
3658 if (ctx->ExecuteFlag) {
3659 (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat,
3660 width, border, imageSize, data);
3661 }
3662 }
3663 }
3664
3665
3666 static void
3667 save_CompressedTexImage2DARB(GLenum target, GLint level,
3668 GLenum internalFormat, GLsizei width,
3669 GLsizei height, GLint border, GLsizei imageSize,
3670 const GLvoid *data)
3671 {
3672 GET_CURRENT_CONTEXT(ctx);
3673 if (target == GL_PROXY_TEXTURE_2D) {
3674 /* don't compile, execute immediately */
3675 (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat,
3676 width, height, border, imageSize, data);
3677 }
3678 else {
3679 Node *n;
3680 GLvoid *image;
3681 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3682 /* make copy of image */
3683 image = MALLOC(imageSize);
3684 if (!image) {
3685 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
3686 return;
3687 }
3688 MEMCPY(image, data, imageSize);
3689 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 9 );
3690 if (n) {
3691 n[1].e = target;
3692 n[2].i = level;
3693 n[3].e = internalFormat;
3694 n[4].i = (GLint) width;
3695 n[5].i = (GLint) height;
3696 n[6].i = border;
3697 n[7].i = imageSize;
3698 n[8].data = image;
3699 }
3700 else if (image) {
3701 FREE(image);
3702 }
3703 if (ctx->ExecuteFlag) {
3704 (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat,
3705 width, height, border, imageSize, data);
3706 }
3707 }
3708 }
3709
3710
3711 static void
3712 save_CompressedTexImage3DARB(GLenum target, GLint level,
3713 GLenum internalFormat, GLsizei width,
3714 GLsizei height, GLsizei depth, GLint border,
3715 GLsizei imageSize, const GLvoid *data)
3716 {
3717 GET_CURRENT_CONTEXT(ctx);
3718 if (target == GL_PROXY_TEXTURE_3D) {
3719 /* don't compile, execute immediately */
3720 (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat,
3721 width, height, depth, border, imageSize, data);
3722 }
3723 else {
3724 Node *n;
3725 GLvoid *image;
3726 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3727 /* make copy of image */
3728 image = MALLOC(imageSize);
3729 if (!image) {
3730 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
3731 return;
3732 }
3733 MEMCPY(image, data, imageSize);
3734 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 10 );
3735 if (n) {
3736 n[1].e = target;
3737 n[2].i = level;
3738 n[3].e = internalFormat;
3739 n[4].i = (GLint) width;
3740 n[5].i = (GLint) height;
3741 n[6].i = (GLint) depth;
3742 n[7].i = border;
3743 n[8].i = imageSize;
3744 n[9].data = image;
3745 }
3746 else if (image) {
3747 FREE(image);
3748 }
3749 if (ctx->ExecuteFlag) {
3750 (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat,
3751 width, height, depth, border, imageSize, data);
3752 }
3753 }
3754 }
3755
3756
3757 static void
3758 save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
3759 GLsizei width, GLenum format,
3760 GLsizei imageSize, const GLvoid *data)
3761 {
3762 Node *n;
3763 GLvoid *image;
3764
3765 GET_CURRENT_CONTEXT(ctx);
3766 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3767
3768 /* make copy of image */
3769 image = MALLOC(imageSize);
3770 if (!image) {
3771 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
3772 return;
3773 }
3774 MEMCPY(image, data, imageSize);
3775 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 8 );
3776 if (n) {
3777 n[1].e = target;
3778 n[2].i = level;
3779 n[3].i = xoffset;
3780 n[4].i = (GLint) width;
3781 n[5].e = format;
3782 n[6].i = imageSize;
3783 n[7].data = image;
3784 }
3785 else if (image) {
3786 FREE(image);
3787 }
3788 if (ctx->ExecuteFlag) {
3789 (*ctx->Exec->CompressedTexSubImage1DARB)(target, level, xoffset,
3790 width, format, imageSize, data);
3791 }
3792 }
3793
3794
3795 static void
3796 save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
3797 GLint yoffset, GLsizei width, GLsizei height,
3798 GLenum format, GLsizei imageSize,
3799 const GLvoid *data)
3800 {
3801 Node *n;
3802 GLvoid *image;
3803
3804 GET_CURRENT_CONTEXT(ctx);
3805 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3806
3807 /* make copy of image */
3808 image = MALLOC(imageSize);
3809 if (!image) {
3810 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
3811 return;
3812 }
3813 MEMCPY(image, data, imageSize);
3814 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 10 );
3815 if (n) {
3816 n[1].e = target;
3817 n[2].i = level;
3818 n[3].i = xoffset;
3819 n[4].i = yoffset;
3820 n[5].i = (GLint) width;
3821 n[6].i = (GLint) height;
3822 n[7].e = format;
3823 n[8].i = imageSize;
3824 n[9].data = image;
3825 }
3826 else if (image) {
3827 FREE(image);
3828 }
3829 if (ctx->ExecuteFlag) {
3830 (*ctx->Exec->CompressedTexSubImage2DARB)(target, level, xoffset, yoffset,
3831 width, height, format, imageSize, data);
3832 }
3833 }
3834
3835
3836 static void
3837 save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
3838 GLint yoffset, GLint zoffset, GLsizei width,
3839 GLsizei height, GLsizei depth, GLenum format,
3840 GLsizei imageSize, const GLvoid *data)
3841 {
3842 Node *n;
3843 GLvoid *image;
3844
3845 GET_CURRENT_CONTEXT(ctx);
3846 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3847
3848 /* make copy of image */
3849 image = MALLOC(imageSize);
3850 if (!image) {
3851 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
3852 return;
3853 }
3854 MEMCPY(image, data, imageSize);
3855 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 12 );
3856 if (n) {
3857 n[1].e = target;
3858 n[2].i = level;
3859 n[3].i = xoffset;
3860 n[4].i = yoffset;
3861 n[5].i = zoffset;
3862 n[6].i = (GLint) width;
3863 n[7].i = (GLint) height;
3864 n[8].i = (GLint) depth;
3865 n[9].e = format;
3866 n[10].i = imageSize;
3867 n[11].data = image;
3868 }
3869 else if (image) {
3870 FREE(image);
3871 }
3872 if (ctx->ExecuteFlag) {
3873 (*ctx->Exec->CompressedTexSubImage3DARB)(target, level, xoffset, yoffset,
3874 zoffset, width, height, depth, format, imageSize, data);
3875 }
3876 }
3877
3878
3879 /* GL_SGIS_pixel_texture */
3880
3881 static void save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
3882 {
3883 GET_CURRENT_CONTEXT(ctx);
3884 Node *n;
3885 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3886 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, 2 );
3887 if (n) {
3888 n[1].e = target;
3889 n[2].i = value;
3890 }
3891 if (ctx->ExecuteFlag) {
3892 (*ctx->Exec->PixelTexGenParameteriSGIS)( target, value );
3893 }
3894 }
3895
3896
3897 static void save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
3898 {
3899 save_PixelTexGenParameteriSGIS(target, (GLint) value);
3900 }
3901
3902
3903 static void save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
3904 {
3905 save_PixelTexGenParameteriSGIS(target, *value);
3906 }
3907
3908
3909 static void save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
3910 {
3911 save_PixelTexGenParameteriSGIS(target, (GLint) *value);
3912 }
3913
3914
3915 /* KW: Compile commands
3916 *
3917 * Will appear in the list before the vertex buffer containing the
3918 * command that provoked the error. I don't see this as a problem.
3919 */
3920 void gl_save_error( GLcontext *ctx, GLenum error, const char *s )
3921 {
3922 Node *n;
3923 n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
3924 if (n) {
3925 n[1].e = error;
3926 n[2].data = (void *) s;
3927 }
3928 /* execute already done */
3929 }
3930
3931
3932 static GLboolean
3933 islist(GLcontext *ctx, GLuint list)
3934 {
3935 if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
3936 return GL_TRUE;
3937 }
3938 else {
3939 return GL_FALSE;
3940 }
3941 }
3942
3943
3944
3945 /**********************************************************************/
3946 /* Display list execution */
3947 /**********************************************************************/
3948
3949
3950 /*
3951 * Execute a display list. Note that the ListBase offset must have already
3952 * been added before calling this function. I.e. the list argument is
3953 * the absolute list number, not relative to ListBase.
3954 * Input: list - display list number
3955 */
3956 static void execute_list( GLcontext *ctx, GLuint list )
3957 {
3958 Node *n;
3959 GLboolean done;
3960
3961 if (!islist(ctx,list))
3962 return;
3963
3964 if (ctx->Driver.BeginCallList)
3965 ctx->Driver.BeginCallList( ctx, list );
3966
3967 /* fprintf(stderr, "execute list %d\n", list); */
3968 /* mesa_print_display_list( list ); */
3969
3970 ctx->CallDepth++;
3971
3972 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
3973
3974 done = GL_FALSE;
3975 while (!done) {
3976 OpCode opcode = n[0].opcode;
3977 int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
3978
3979 if (i >= 0 && i < ctx->listext.nr_opcodes) {
3980 ctx->listext.opcode[i].execute(ctx, &n[1]);
3981 n += ctx->listext.opcode[i].size;
3982 }
3983 else {
3984 switch (opcode) {
3985 case OPCODE_ERROR:
3986 gl_error( ctx, n[1].e, (const char *) n[2].data );
3987 break;
3988 case OPCODE_ACCUM:
3989 (*ctx->Exec->Accum)( n[1].e, n[2].f );
3990 break;
3991 case OPCODE_ALPHA_FUNC:
3992 (*ctx->Exec->AlphaFunc)( n[1].e, n[2].f );
3993 break;
3994 case OPCODE_BIND_TEXTURE:
3995 (*ctx->Exec->BindTexture)( n[1].e, n[2].ui );
3996 break;
3997 case OPCODE_BITMAP:
3998 {
3999 struct gl_pixelstore_attrib save = ctx->Unpack;
4000 ctx->Unpack = _mesa_native_packing;
4001 (*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
4002 n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
4003 ctx->Unpack = save; /* restore */
4004 }
4005 break;
4006 case OPCODE_BLEND_COLOR:
4007 (*ctx->Exec->BlendColor)( n[1].f, n[2].f, n[3].f, n[4].f );
4008 break;
4009 case OPCODE_BLEND_EQUATION:
4010 (*ctx->Exec->BlendEquation)( n[1].e );
4011 break;
4012 case OPCODE_BLEND_FUNC:
4013 (*ctx->Exec->BlendFunc)( n[1].e, n[2].e );
4014 break;
4015 case OPCODE_BLEND_FUNC_SEPARATE:
4016 (*ctx->Exec->BlendFuncSeparateEXT)(n[1].e, n[2].e, n[3].e, n[4].e);
4017 break;
4018 case OPCODE_CALL_LIST:
4019 /* Generated by glCallList(), don't add ListBase */
4020 if (ctx->CallDepth<MAX_LIST_NESTING) {
4021 execute_list( ctx, n[1].ui );
4022 }
4023 break;
4024 case OPCODE_CALL_LIST_OFFSET:
4025 /* Generated by glCallLists() so we must add ListBase */
4026 if (ctx->CallDepth<MAX_LIST_NESTING) {
4027 execute_list( ctx, ctx->List.ListBase + n[1].ui );
4028 }
4029 break;
4030 case OPCODE_CLEAR:
4031 (*ctx->Exec->Clear)( n[1].bf );
4032 break;
4033 case OPCODE_CLEAR_COLOR:
4034 (*ctx->Exec->ClearColor)( n[1].f, n[2].f, n[3].f, n[4].f );
4035 break;
4036 case OPCODE_CLEAR_ACCUM:
4037 (*ctx->Exec->ClearAccum)( n[1].f, n[2].f, n[3].f, n[4].f );
4038 break;
4039 case OPCODE_CLEAR_DEPTH:
4040 (*ctx->Exec->ClearDepth)( (GLclampd) n[1].f );
4041 break;
4042 case OPCODE_CLEAR_INDEX:
4043 (*ctx->Exec->ClearIndex)( n[1].ui );
4044 break;
4045 case OPCODE_CLEAR_STENCIL:
4046 (*ctx->Exec->ClearStencil)( n[1].i );
4047 break;
4048 case OPCODE_CLIP_PLANE:
4049 {
4050 GLdouble eq[4];
4051 eq[0] = n[2].f;
4052 eq[1] = n[3].f;
4053 eq[2] = n[4].f;
4054 eq[3] = n[5].f;
4055 (*ctx->Exec->ClipPlane)( n[1].e, eq );
4056 }
4057 break;
4058 case OPCODE_COLOR_MASK:
4059 (*ctx->Exec->ColorMask)( n[1].b, n[2].b, n[3].b, n[4].b );
4060 break;
4061 case OPCODE_COLOR_MATERIAL:
4062 (*ctx->Exec->ColorMaterial)( n[1].e, n[2].e );
4063 break;
4064 case OPCODE_COLOR_TABLE:
4065 {
4066 struct gl_pixelstore_attrib save = ctx->Unpack;
4067 ctx->Unpack = _mesa_native_packing;
4068 (*ctx->Exec->ColorTable)( n[1].e, n[2].e, n[3].i, n[4].e,
4069 n[5].e, n[6].data );
4070 ctx->Unpack = save; /* restore */
4071 }
4072 break;
4073 case OPCODE_COLOR_TABLE_PARAMETER_FV:
4074 {
4075 GLfloat params[4];
4076 params[0] = n[3].f;
4077 params[1] = n[4].f;
4078 params[2] = n[5].f;
4079 params[3] = n[6].f;
4080 (*ctx->Exec->ColorTableParameterfv)( n[1].e, n[2].e, params );
4081 }
4082 break;
4083 case OPCODE_COLOR_TABLE_PARAMETER_IV:
4084 {
4085 GLint params[4];
4086 params[0] = n[3].i;
4087 params[1] = n[4].i;
4088 params[2] = n[5].i;
4089 params[3] = n[6].i;
4090 (*ctx->Exec->ColorTableParameteriv)( n[1].e, n[2].e, params );
4091 }
4092 break;
4093 case OPCODE_COLOR_SUB_TABLE:
4094 {
4095 struct gl_pixelstore_attrib save = ctx->Unpack;
4096 ctx->Unpack = _mesa_native_packing;
4097 (*ctx->Exec->ColorSubTable)( n[1].e, n[2].i, n[3].i,
4098 n[4].e, n[5].e, n[6].data );
4099 ctx->Unpack = save; /* restore */
4100 }
4101 break;
4102 case OPCODE_CONVOLUTION_FILTER_1D:
4103 {
4104 struct gl_pixelstore_attrib save = ctx->Unpack;
4105 ctx->Unpack = _mesa_native_packing;
4106 (*ctx->Exec->ConvolutionFilter1D)( n[1].e, n[2].i, n[3].i,
4107 n[4].e, n[5].e, n[6].data );
4108 ctx->Unpack = save; /* restore */
4109 }
4110 break;
4111 case OPCODE_CONVOLUTION_FILTER_2D:
4112 {
4113 struct gl_pixelstore_attrib save = ctx->Unpack;
4114 ctx->Unpack = _mesa_native_packing;
4115 (*ctx->Exec->ConvolutionFilter2D)( n[1].e, n[2].i, n[3].i,
4116 n[4].i, n[5].e, n[6].e, n[7].data );
4117 ctx->Unpack = save; /* restore */
4118 }
4119 break;
4120 case OPCODE_CONVOLUTION_PARAMETER_I:
4121 (*ctx->Exec->ConvolutionParameteri)( n[1].e, n[2].e, n[3].i );
4122 break;
4123 case OPCODE_CONVOLUTION_PARAMETER_IV:
4124 {
4125 GLint params[4];
4126 params[0] = n[3].i;
4127 params[1] = n[4].i;
4128 params[2] = n[5].i;
4129 params[3] = n[6].i;
4130 (*ctx->Exec->ConvolutionParameteriv)( n[1].e, n[2].e, params );
4131 }
4132 break;
4133 case OPCODE_CONVOLUTION_PARAMETER_F:
4134 (*ctx->Exec->ConvolutionParameterf)( n[1].e, n[2].e, n[3].f );
4135 break;
4136 case OPCODE_CONVOLUTION_PARAMETER_FV:
4137 {
4138 GLfloat params[4];
4139 params[0] = n[3].f;
4140 params[1] = n[4].f;
4141 params[2] = n[5].f;
4142 params[3] = n[6].f;
4143 (*ctx->Exec->ConvolutionParameterfv)( n[1].e, n[2].e, params );
4144 }
4145 break;
4146 case OPCODE_COPY_COLOR_SUB_TABLE:
4147 (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i,
4148 n[3].i, n[4].i, n[5].i );
4149 break;
4150 case OPCODE_COPY_COLOR_TABLE:
4151 (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i,
4152 n[3].i, n[4].i, n[5].i );
4153 break;
4154 case OPCODE_COPY_PIXELS:
4155 (*ctx->Exec->CopyPixels)( n[1].i, n[2].i,
4156 (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
4157 break;
4158 case OPCODE_COPY_TEX_IMAGE1D:
4159 (*ctx->Exec->CopyTexImage1D)( n[1].e, n[2].i, n[3].e, n[4].i,
4160 n[5].i, n[6].i, n[7].i );
4161 break;
4162 case OPCODE_COPY_TEX_IMAGE2D:
4163 (*ctx->Exec->CopyTexImage2D)( n[1].e, n[2].i, n[3].e, n[4].i,
4164 n[5].i, n[6].i, n[7].i, n[8].i );
4165 break;
4166 case OPCODE_COPY_TEX_SUB_IMAGE1D:
4167 (*ctx->Exec->CopyTexSubImage1D)( n[1].e, n[2].i, n[3].i,
4168 n[4].i, n[5].i, n[6].i );
4169 break;
4170 case OPCODE_COPY_TEX_SUB_IMAGE2D:
4171 (*ctx->Exec->CopyTexSubImage2D)( n[1].e, n[2].i, n[3].i,
4172 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i );
4173 break;
4174 case OPCODE_COPY_TEX_SUB_IMAGE3D:
4175 (*ctx->Exec->CopyTexSubImage3D)( n[1].e, n[2].i, n[3].i,
4176 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i , n[9].i);
4177 break;
4178 case OPCODE_CULL_FACE:
4179 (*ctx->Exec->CullFace)( n[1].e );
4180 break;
4181 case OPCODE_DEPTH_FUNC:
4182 (*ctx->Exec->DepthFunc)( n[1].e );
4183 break;
4184 case OPCODE_DEPTH_MASK:
4185 (*ctx->Exec->DepthMask)( n[1].b );
4186 break;
4187 case OPCODE_DEPTH_RANGE:
4188 (*ctx->Exec->DepthRange)( (GLclampd) n[1].f, (GLclampd) n[2].f );
4189 break;
4190 case OPCODE_DISABLE:
4191 (*ctx->Exec->Disable)( n[1].e );
4192 break;
4193 case OPCODE_DRAW_BUFFER:
4194 (*ctx->Exec->DrawBuffer)( n[1].e );
4195 break;
4196 case OPCODE_DRAW_PIXELS:
4197 {
4198 struct gl_pixelstore_attrib save = ctx->Unpack;
4199 ctx->Unpack = _mesa_native_packing;
4200 (*ctx->Exec->DrawPixels)( n[1].i, n[2].i, n[3].e, n[4].e,
4201 n[5].data );
4202 ctx->Unpack = save; /* restore */
4203 }
4204 break;
4205 case OPCODE_ENABLE:
4206 (*ctx->Exec->Enable)( n[1].e );
4207 break;
4208 case OPCODE_EVALMESH1:
4209 (*ctx->Exec->EvalMesh1)( n[1].e, n[2].i, n[3].i );
4210 break;
4211 case OPCODE_EVALMESH2:
4212 (*ctx->Exec->EvalMesh2)( n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
4213 break;
4214 case OPCODE_FOG:
4215 {
4216 GLfloat p[4];
4217 p[0] = n[2].f;
4218 p[1] = n[3].f;
4219 p[2] = n[4].f;
4220 p[3] = n[5].f;
4221 (*ctx->Exec->Fogfv)( n[1].e, p );
4222 }
4223 break;
4224 case OPCODE_FRONT_FACE:
4225 (*ctx->Exec->FrontFace)( n[1].e );
4226 break;
4227 case OPCODE_FRUSTUM:
4228 (*ctx->Exec->Frustum)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
4229 break;
4230 case OPCODE_HINT:
4231 (*ctx->Exec->Hint)( n[1].e, n[2].e );
4232 break;
4233 case OPCODE_HISTOGRAM:
4234 (*ctx->Exec->Histogram)( n[1].e, n[2].i, n[3].e, n[4].b );
4235 break;
4236 case OPCODE_INDEX_MASK:
4237 (*ctx->Exec->IndexMask)( n[1].ui );
4238 break;
4239 case OPCODE_INIT_NAMES:
4240 (*ctx->Exec->InitNames)();
4241 break;
4242 case OPCODE_LIGHT:
4243 {
4244 GLfloat p[4];
4245 p[0] = n[3].f;
4246 p[1] = n[4].f;
4247 p[2] = n[5].f;
4248 p[3] = n[6].f;
4249 (*ctx->Exec->Lightfv)( n[1].e, n[2].e, p );
4250 }
4251 break;
4252 case OPCODE_LIGHT_MODEL:
4253 {
4254 GLfloat p[4];
4255 p[0] = n[2].f;
4256 p[1] = n[3].f;
4257 p[2] = n[4].f;
4258 p[3] = n[5].f;
4259 (*ctx->Exec->LightModelfv)( n[1].e, p );
4260 }
4261 break;
4262 case OPCODE_LINE_STIPPLE:
4263 (*ctx->Exec->LineStipple)( n[1].i, n[2].us );
4264 break;
4265 case OPCODE_LINE_WIDTH:
4266 (*ctx->Exec->LineWidth)( n[1].f );
4267 break;
4268 case OPCODE_LIST_BASE:
4269 (*ctx->Exec->ListBase)( n[1].ui );
4270 break;
4271 case OPCODE_LOAD_IDENTITY:
4272 (*ctx->Exec->LoadIdentity)();
4273 break;
4274 case OPCODE_LOAD_MATRIX:
4275 if (sizeof(Node)==sizeof(GLfloat)) {
4276 (*ctx->Exec->LoadMatrixf)( &n[1].f );
4277 }
4278 else {
4279 GLfloat m[16];
4280 GLuint i;
4281 for (i=0;i<16;i++) {
4282 m[i] = n[1+i].f;
4283 }
4284 (*ctx->Exec->LoadMatrixf)( m );
4285 }
4286 break;
4287 case OPCODE_LOAD_NAME:
4288 (*ctx->Exec->LoadName)( n[1].ui );
4289 break;
4290 case OPCODE_LOGIC_OP:
4291 (*ctx->Exec->LogicOp)( n[1].e );
4292 break;
4293 case OPCODE_MAP1:
4294 {
4295 GLenum target = n[1].e;
4296 GLint ustride = _mesa_evaluator_components(target);
4297 GLint uorder = n[5].i;
4298 GLfloat u1 = n[2].f;
4299 GLfloat u2 = n[3].f;
4300 (*ctx->Exec->Map1f)( target, u1, u2, ustride, uorder,
4301 (GLfloat *) n[6].data );
4302 }
4303 break;
4304 case OPCODE_MAP2:
4305 {
4306 GLenum target = n[1].e;
4307 GLfloat u1 = n[2].f;
4308 GLfloat u2 = n[3].f;
4309 GLfloat v1 = n[4].f;
4310 GLfloat v2 = n[5].f;
4311 GLint ustride = n[6].i;
4312 GLint vstride = n[7].i;
4313 GLint uorder = n[8].i;
4314 GLint vorder = n[9].i;
4315 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
4316 v1, v2, vstride, vorder,
4317 (GLfloat *) n[10].data );
4318 }
4319 break;
4320 case OPCODE_MAPGRID1:
4321 (*ctx->Exec->MapGrid1f)( n[1].i, n[2].f, n[3].f );
4322 break;
4323 case OPCODE_MAPGRID2:
4324 (*ctx->Exec->MapGrid2f)( n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
4325 break;
4326 case OPCODE_MATRIX_MODE:
4327 (*ctx->Exec->MatrixMode)( n[1].e );
4328 break;
4329 case OPCODE_MIN_MAX:
4330 (*ctx->Exec->Minmax)(n[1].e, n[2].e, n[3].b);
4331 break;
4332 case OPCODE_MULT_MATRIX:
4333 if (sizeof(Node)==sizeof(GLfloat)) {
4334 (*ctx->Exec->MultMatrixf)( &n[1].f );
4335 }
4336 else {
4337 GLfloat m[16];
4338 GLuint i;
4339 for (i=0;i<16;i++) {
4340 m[i] = n[1+i].f;
4341 }
4342 (*ctx->Exec->MultMatrixf)( m );
4343 }
4344 break;
4345 case OPCODE_ORTHO:
4346 (*ctx->Exec->Ortho)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
4347 break;
4348 case OPCODE_PASSTHROUGH:
4349 (*ctx->Exec->PassThrough)( n[1].f );
4350 break;
4351 case OPCODE_PIXEL_MAP:
4352 (*ctx->Exec->PixelMapfv)( n[1].e, n[2].i, (GLfloat *) n[3].data );
4353 break;
4354 case OPCODE_PIXEL_TRANSFER:
4355 (*ctx->Exec->PixelTransferf)( n[1].e, n[2].f );
4356 break;
4357 case OPCODE_PIXEL_ZOOM:
4358 (*ctx->Exec->PixelZoom)( n[1].f, n[2].f );
4359 break;
4360 case OPCODE_POINT_SIZE:
4361 (*ctx->Exec->PointSize)( n[1].f );
4362 break;
4363 case OPCODE_POINT_PARAMETERS:
4364 {
4365 GLfloat params[3];
4366 params[0] = n[2].f;
4367 params[1] = n[3].f;
4368 params[2] = n[4].f;
4369 (*ctx->Exec->PointParameterfvEXT)( n[1].e, params );
4370 }
4371 break;
4372 case OPCODE_POLYGON_MODE:
4373 (*ctx->Exec->PolygonMode)( n[1].e, n[2].e );
4374 break;
4375 case OPCODE_POLYGON_STIPPLE:
4376 (*ctx->Exec->PolygonStipple)( (GLubyte *) n[1].data );
4377 break;
4378 case OPCODE_POLYGON_OFFSET:
4379 (*ctx->Exec->PolygonOffset)( n[1].f, n[2].f );
4380 break;
4381 case OPCODE_POP_ATTRIB:
4382 (*ctx->Exec->PopAttrib)();
4383 break;
4384 case OPCODE_POP_MATRIX:
4385 (*ctx->Exec->PopMatrix)();
4386 break;
4387 case OPCODE_POP_NAME:
4388 (*ctx->Exec->PopName)();
4389 break;
4390 case OPCODE_PRIORITIZE_TEXTURE:
4391 (*ctx->Exec->PrioritizeTextures)( 1, &n[1].ui, &n[2].f );
4392 break;
4393 case OPCODE_PUSH_ATTRIB:
4394 (*ctx->Exec->PushAttrib)( n[1].bf );
4395 break;
4396 case OPCODE_PUSH_MATRIX:
4397 (*ctx->Exec->PushMatrix)();
4398 break;
4399 case OPCODE_PUSH_NAME:
4400 (*ctx->Exec->PushName)( n[1].ui );
4401 break;
4402 case OPCODE_RASTER_POS:
4403 (*ctx->Exec->RasterPos4f)( n[1].f, n[2].f, n[3].f, n[4].f );
4404 break;
4405 case OPCODE_READ_BUFFER:
4406 (*ctx->Exec->ReadBuffer)( n[1].e );
4407 break;
4408 case OPCODE_RESET_HISTOGRAM:
4409 (*ctx->Exec->ResetHistogram)( n[1].e );
4410 break;
4411 case OPCODE_RESET_MIN_MAX:
4412 (*ctx->Exec->ResetMinmax)( n[1].e );
4413 break;
4414 case OPCODE_ROTATE:
4415 (*ctx->Exec->Rotatef)( n[1].f, n[2].f, n[3].f, n[4].f );
4416 break;
4417 case OPCODE_SCALE:
4418 (*ctx->Exec->Scalef)( n[1].f, n[2].f, n[3].f );
4419 break;
4420 case OPCODE_SCISSOR:
4421 (*ctx->Exec->Scissor)( n[1].i, n[2].i, n[3].i, n[4].i );
4422 break;
4423 case OPCODE_SHADE_MODEL:
4424 (*ctx->Exec->ShadeModel)( n[1].e );
4425 break;
4426 case OPCODE_STENCIL_FUNC:
4427 (*ctx->Exec->StencilFunc)( n[1].e, n[2].i, n[3].ui );
4428 break;
4429 case OPCODE_STENCIL_MASK:
4430 (*ctx->Exec->StencilMask)( n[1].ui );
4431 break;
4432 case OPCODE_STENCIL_OP:
4433 (*ctx->Exec->StencilOp)( n[1].e, n[2].e, n[3].e );
4434 break;
4435 case OPCODE_TEXENV:
4436 {
4437 GLfloat params[4];
4438 params[0] = n[3].f;
4439 params[1] = n[4].f;
4440 params[2] = n[5].f;
4441 params[3] = n[6].f;
4442 (*ctx->Exec->TexEnvfv)( n[1].e, n[2].e, params );
4443 }
4444 break;
4445 case OPCODE_TEXGEN:
4446 {
4447 GLfloat params[4];
4448 params[0] = n[3].f;
4449 params[1] = n[4].f;
4450 params[2] = n[5].f;
4451 params[3] = n[6].f;
4452 (*ctx->Exec->TexGenfv)( n[1].e, n[2].e, params );
4453 }
4454 break;
4455 case OPCODE_TEXPARAMETER:
4456 {
4457 GLfloat params[4];
4458 params[0] = n[3].f;
4459 params[1] = n[4].f;
4460 params[2] = n[5].f;
4461 params[3] = n[6].f;
4462 (*ctx->Exec->TexParameterfv)( n[1].e, n[2].e, params );
4463 }
4464 break;
4465 case OPCODE_TEX_IMAGE1D:
4466 {
4467 struct gl_pixelstore_attrib save = ctx->Unpack;
4468 ctx->Unpack = _mesa_native_packing;
4469 (*ctx->Exec->TexImage1D)(
4470 n[1].e, /* target */
4471 n[2].i, /* level */
4472 n[3].i, /* components */
4473 n[4].i, /* width */
4474 n[5].e, /* border */
4475 n[6].e, /* format */
4476 n[7].e, /* type */
4477 n[8].data );
4478 ctx->Unpack = save; /* restore */
4479 }
4480 break;
4481 case OPCODE_TEX_IMAGE2D:
4482 {
4483 struct gl_pixelstore_attrib save = ctx->Unpack;
4484 ctx->Unpack = _mesa_native_packing;
4485 (*ctx->Exec->TexImage2D)(
4486 n[1].e, /* target */
4487 n[2].i, /* level */
4488 n[3].i, /* components */
4489 n[4].i, /* width */
4490 n[5].i, /* height */
4491 n[6].e, /* border */
4492 n[7].e, /* format */
4493 n[8].e, /* type */
4494 n[9].data );
4495 ctx->Unpack = save; /* restore */
4496 }
4497 break;
4498 case OPCODE_TEX_IMAGE3D:
4499 {
4500 struct gl_pixelstore_attrib save = ctx->Unpack;
4501 ctx->Unpack = _mesa_native_packing;
4502 (*ctx->Exec->TexImage3D)(
4503 n[1].e, /* target */
4504 n[2].i, /* level */
4505 n[3].i, /* components */
4506 n[4].i, /* width */
4507 n[5].i, /* height */
4508 n[6].i, /* depth */
4509 n[7].e, /* border */
4510 n[8].e, /* format */
4511 n[9].e, /* type */
4512 n[10].data );
4513 ctx->Unpack = save; /* restore */
4514 }
4515 break;
4516 case OPCODE_TEX_SUB_IMAGE1D:
4517 {
4518 struct gl_pixelstore_attrib save = ctx->Unpack;
4519 ctx->Unpack = _mesa_native_packing;
4520 (*ctx->Exec->TexSubImage1D)( n[1].e, n[2].i, n[3].i,
4521 n[4].i, n[5].e,
4522 n[6].e, n[7].data );
4523 ctx->Unpack = save; /* restore */
4524 }
4525 break;
4526 case OPCODE_TEX_SUB_IMAGE2D:
4527 {
4528 struct gl_pixelstore_attrib save = ctx->Unpack;
4529 ctx->Unpack = _mesa_native_packing;
4530 (*ctx->Exec->TexSubImage2D)( n[1].e, n[2].i, n[3].i,
4531 n[4].i, n[5].e,
4532 n[6].i, n[7].e, n[8].e, n[9].data );
4533 ctx->Unpack = save; /* restore */
4534 }
4535 break;
4536 case OPCODE_TEX_SUB_IMAGE3D:
4537 {
4538 struct gl_pixelstore_attrib save = ctx->Unpack;
4539 ctx->Unpack = _mesa_native_packing;
4540 (*ctx->Exec->TexSubImage3D)( n[1].e, n[2].i, n[3].i,
4541 n[4].i, n[5].i, n[6].i, n[7].i,
4542 n[8].i, n[9].e, n[10].e,
4543 n[11].data );
4544 ctx->Unpack = save; /* restore */
4545 }
4546 break;
4547 case OPCODE_TRANSLATE:
4548 (*ctx->Exec->Translatef)( n[1].f, n[2].f, n[3].f );
4549 break;
4550 case OPCODE_VIEWPORT:
4551 (*ctx->Exec->Viewport)(n[1].i, n[2].i,
4552 (GLsizei) n[3].i, (GLsizei) n[4].i);
4553 break;
4554 case OPCODE_WINDOW_POS:
4555 (*ctx->Exec->WindowPos4fMESA)( n[1].f, n[2].f, n[3].f, n[4].f );
4556 break;
4557 case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
4558 (*ctx->Exec->ActiveTextureARB)( n[1].e );
4559 break;
4560 case OPCODE_CLIENT_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
4561 (*ctx->Exec->ClientActiveTextureARB)( n[1].e );
4562 break;
4563 case OPCODE_PIXEL_TEXGEN_SGIX: /* GL_SGIX_pixel_texture */
4564 (*ctx->Exec->PixelTexGenSGIX)( n[1].e );
4565 break;
4566 case OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS: /* GL_SGIS_pixel_texture */
4567 (*ctx->Exec->PixelTexGenParameteriSGIS)( n[1].e, n[2].i );
4568 break;
4569 case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */
4570 (*ctx->Exec->CompressedTexImage1DARB)(n[1].e, n[2].i, n[3].e,
4571 n[4].i, n[5].i, n[6].i, n[7].data);
4572 break;
4573 case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */
4574 (*ctx->Exec->CompressedTexImage2DARB)(n[1].e, n[2].i, n[3].e,
4575 n[4].i, n[5].i, n[6].i, n[7].i, n[8].data);
4576 break;
4577 case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */
4578 (*ctx->Exec->CompressedTexImage3DARB)(n[1].e, n[2].i, n[3].e,
4579 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i, n[9].data);
4580 break;
4581 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */
4582 (*ctx->Exec->CompressedTexSubImage1DARB)(n[1].e, n[2].i, n[3].i,
4583 n[4].i, n[5].e, n[6].i, n[7].data);
4584 break;
4585 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */
4586 (*ctx->Exec->CompressedTexSubImage2DARB)(n[1].e, n[2].i, n[3].i,
4587 n[4].i, n[5].i, n[6].i, n[7].e, n[8].i, n[9].data);
4588 break;
4589 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */
4590 (*ctx->Exec->CompressedTexSubImage3DARB)(n[1].e, n[2].i, n[3].i,
4591 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i,
4592 n[9].e, n[10].i, n[11].data);
4593 break;
4594 case OPCODE_CONTINUE:
4595 n = (Node *) n[1].next;
4596 break;
4597 case OPCODE_END_OF_LIST:
4598 done = GL_TRUE;
4599 break;
4600 default:
4601 {
4602 char msg[1000];
4603 sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
4604 gl_problem( ctx, msg );
4605 }
4606 done = GL_TRUE;
4607 }
4608
4609 /* increment n to point to next compiled command */
4610 if (opcode!=OPCODE_CONTINUE) {
4611 n += InstSize[opcode];
4612 }
4613 }
4614 }
4615 ctx->CallDepth--;
4616
4617 if (ctx->Driver.EndCallList)
4618 ctx->Driver.EndCallList( ctx );
4619 }
4620
4621
4622
4623
4624
4625 /**********************************************************************/
4626 /* GL functions */
4627 /**********************************************************************/
4628
4629
4630
4631
4632 /*
4633 * Test if a display list number is valid.
4634 */
4635 GLboolean
4636 _mesa_IsList( GLuint list )
4637 {
4638 GET_CURRENT_CONTEXT(ctx);
4639 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
4640 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
4641 return islist(ctx, list);
4642 }
4643
4644
4645 /*
4646 * Delete a sequence of consecutive display lists.
4647 */
4648 void
4649 _mesa_DeleteLists( GLuint list, GLsizei range )
4650 {
4651 GET_CURRENT_CONTEXT(ctx);
4652 GLuint i;
4653 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
4654 ASSERT_OUTSIDE_BEGIN_END(ctx);
4655
4656 if (range<0) {
4657 gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
4658 return;
4659 }
4660 for (i=list;i<list+range;i++) {
4661 gl_destroy_list( ctx, i );
4662 }
4663 }
4664
4665
4666
4667 /*
4668 * Return a display list number, n, such that lists n through n+range-1
4669 * are free.
4670 */
4671 GLuint
4672 _mesa_GenLists(GLsizei range )
4673 {
4674 GET_CURRENT_CONTEXT(ctx);
4675 GLuint base;
4676 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
4677 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
4678
4679 if (range<0) {
4680 gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
4681 return 0;
4682 }
4683 if (range==0) {
4684 return 0;
4685 }
4686
4687 /*
4688 * Make this an atomic operation
4689 */
4690 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
4691
4692 base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
4693 if (base) {
4694 /* reserve the list IDs by with empty/dummy lists */
4695 GLint i;
4696 for (i=0; i<range; i++) {
4697 _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
4698 }
4699 }
4700
4701 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
4702
4703 return base;
4704 }
4705
4706
4707
4708 /*
4709 * Begin a new display list.
4710 */
4711 void
4712 _mesa_NewList( GLuint list, GLenum mode )
4713 {
4714 GET_CURRENT_CONTEXT(ctx);
4715 FLUSH_CURRENT(ctx, 0); /* must be called before assert */
4716 ASSERT_OUTSIDE_BEGIN_END(ctx);
4717
4718 if (MESA_VERBOSE&VERBOSE_API)
4719 fprintf(stderr, "glNewList %u %s\n", list, gl_lookup_enum_by_nr(mode));
4720
4721 if (list==0) {
4722 gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
4723 return;
4724 }
4725
4726 if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
4727 gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
4728 return;
4729 }
4730
4731 if (ctx->CurrentListPtr) {
4732 /* already compiling a display list */
4733 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
4734 return;
4735 }
4736
4737 /* Allocate new display list */
4738 ctx->CurrentListNum = list;
4739 ctx->CurrentBlock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
4740 ctx->CurrentListPtr = ctx->CurrentBlock;
4741 ctx->CurrentPos = 0;
4742 ctx->CompileFlag = GL_TRUE;
4743 ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
4744
4745 ctx->Driver.NewList( ctx, list, mode );
4746
4747 ctx->CurrentDispatch = ctx->Save;
4748 _glapi_set_dispatch( ctx->CurrentDispatch );
4749 }
4750
4751
4752
4753 /*
4754 * End definition of current display list. Is the current
4755 * ASSERT_OUTSIDE_BEGIN_END strong enough to really guarentee that
4756 * we are outside begin/end calls?
4757 */
4758 void
4759 _mesa_EndList( void )
4760 {
4761 GET_CURRENT_CONTEXT(ctx);
4762 FLUSH_CURRENT(ctx, 0); /* must be called before assert */
4763 ASSERT_OUTSIDE_BEGIN_END(ctx);
4764 if (MESA_VERBOSE&VERBOSE_API)
4765 fprintf(stderr, "glEndList\n");
4766
4767 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); /* ??? */
4768
4769 /* Check that a list is under construction */
4770 if (!ctx->CurrentListPtr) {
4771 gl_error( ctx, GL_INVALID_OPERATION, "glEndList" );
4772 return;
4773 }
4774
4775 (void) ALLOC_INSTRUCTION( ctx, OPCODE_END_OF_LIST, 0 );
4776
4777 /* Destroy old list, if any */
4778 gl_destroy_list(ctx, ctx->CurrentListNum);
4779 /* Install the list */
4780 _mesa_HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
4781
4782
4783 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
4784 mesa_print_display_list(ctx->CurrentListNum);
4785
4786 ctx->CurrentListNum = 0;
4787 ctx->CurrentListPtr = NULL;
4788 ctx->ExecuteFlag = GL_TRUE;
4789 ctx->CompileFlag = GL_FALSE;
4790
4791 ctx->Driver.EndList( ctx );
4792
4793 ctx->CurrentDispatch = ctx->Exec;
4794 _glapi_set_dispatch( ctx->CurrentDispatch );
4795
4796 }
4797
4798
4799
4800 void
4801 _mesa_CallList( GLuint list )
4802 {
4803 GLboolean save_compile_flag;
4804 GET_CURRENT_CONTEXT(ctx);
4805 FLUSH_CURRENT(ctx, 0);
4806 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
4807 /* execute the display list, and restore the CompileFlag. */
4808
4809 /* mesa_print_display_list( list ); */
4810
4811 save_compile_flag = ctx->CompileFlag;
4812 if (save_compile_flag) {
4813 ctx->CompileFlag = GL_FALSE;
4814 }
4815
4816 execute_list( ctx, list );
4817 ctx->CompileFlag = save_compile_flag;
4818
4819 /* also restore API function pointers to point to "save" versions */
4820 if (save_compile_flag) {
4821 ctx->CurrentDispatch = ctx->Save;
4822 _glapi_set_dispatch( ctx->CurrentDispatch );
4823 }
4824 }
4825
4826
4827
4828 /*
4829 * Execute glCallLists: call multiple display lists.
4830 */
4831 void
4832 _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
4833 {
4834 GET_CURRENT_CONTEXT(ctx);
4835 GLuint list;
4836 GLint i;
4837 GLboolean save_compile_flag;
4838
4839 /* Save the CompileFlag status, turn it off, execute display list,
4840 * and restore the CompileFlag.
4841 */
4842 save_compile_flag = ctx->CompileFlag;
4843 ctx->CompileFlag = GL_FALSE;
4844
4845 for (i=0;i<n;i++) {
4846 list = translate_id( i, type, lists );
4847 execute_list( ctx, ctx->List.ListBase + list );
4848 }
4849
4850 ctx->CompileFlag = save_compile_flag;
4851
4852 /* also restore API function pointers to point to "save" versions */
4853 if (save_compile_flag) {
4854 ctx->CurrentDispatch = ctx->Save;
4855 _glapi_set_dispatch( ctx->CurrentDispatch );
4856 }
4857 }
4858
4859
4860
4861 /*
4862 * Set the offset added to list numbers in glCallLists.
4863 */
4864 void
4865 _mesa_ListBase( GLuint base )
4866 {
4867 GET_CURRENT_CONTEXT(ctx);
4868 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
4869 ASSERT_OUTSIDE_BEGIN_END(ctx);
4870 ctx->List.ListBase = base;
4871 }
4872
4873
4874 /* Can no longer assume ctx->Exec->Func is equal to _mesa_Func.
4875 */
4876 static void exec_Finish( void )
4877 {
4878 GET_CURRENT_CONTEXT(ctx);
4879 FLUSH_VERTICES(ctx, 0);
4880 ctx->Exec->Finish();
4881 }
4882
4883 static void exec_Flush( void )
4884 {
4885 GET_CURRENT_CONTEXT(ctx);
4886 FLUSH_VERTICES(ctx, 0);
4887 ctx->Exec->Flush( );
4888 }
4889
4890 static void exec_GetBooleanv( GLenum pname, GLboolean *params )
4891 {
4892 GET_CURRENT_CONTEXT(ctx);
4893 FLUSH_VERTICES(ctx, 0);
4894 ctx->Exec->GetBooleanv( pname, params );
4895 }
4896
4897 static void exec_GetClipPlane( GLenum plane, GLdouble *equation )
4898 {
4899 GET_CURRENT_CONTEXT(ctx);
4900 FLUSH_VERTICES(ctx, 0);
4901 ctx->Exec->GetClipPlane( plane, equation );
4902 }
4903
4904 static void exec_GetDoublev( GLenum pname, GLdouble *params )
4905 {
4906 GET_CURRENT_CONTEXT(ctx);
4907 FLUSH_VERTICES(ctx, 0);
4908 ctx->Exec->GetDoublev( pname, params );
4909 }
4910
4911 static GLenum exec_GetError( void )
4912 {
4913 GET_CURRENT_CONTEXT(ctx);
4914 FLUSH_VERTICES(ctx, 0);
4915 return ctx->Exec->GetError( );
4916 }
4917
4918 static void exec_GetFloatv( GLenum pname, GLfloat *params )
4919 {
4920 GET_CURRENT_CONTEXT(ctx);
4921 FLUSH_VERTICES(ctx, 0);
4922 ctx->Exec->GetFloatv( pname, params );
4923 }
4924
4925 static void exec_GetIntegerv( GLenum pname, GLint *params )
4926 {
4927 GET_CURRENT_CONTEXT(ctx);
4928 FLUSH_VERTICES(ctx, 0);
4929 ctx->Exec->GetIntegerv( pname, params );
4930 }
4931
4932 static void exec_GetLightfv( GLenum light, GLenum pname, GLfloat *params )
4933 {
4934 GET_CURRENT_CONTEXT(ctx);
4935 FLUSH_VERTICES(ctx, 0);
4936 ctx->Exec->GetLightfv( light, pname, params );
4937 }
4938
4939 static void exec_GetLightiv( GLenum light, GLenum pname, GLint *params )
4940 {
4941 GET_CURRENT_CONTEXT(ctx);
4942 FLUSH_VERTICES(ctx, 0);
4943 ctx->Exec->GetLightiv( light, pname, params );
4944 }
4945
4946 static void exec_GetMapdv( GLenum target, GLenum query, GLdouble *v )
4947 {
4948 GET_CURRENT_CONTEXT(ctx);
4949 FLUSH_VERTICES(ctx, 0);
4950 ctx->Exec->GetMapdv( target, query, v );
4951 }
4952
4953 static void exec_GetMapfv( GLenum target, GLenum query, GLfloat *v )
4954 {
4955 GET_CURRENT_CONTEXT(ctx);
4956 FLUSH_VERTICES(ctx, 0);
4957 ctx->Exec->GetMapfv( target, query, v );
4958 }
4959
4960 static void exec_GetMapiv( GLenum target, GLenum query, GLint *v )
4961 {
4962 GET_CURRENT_CONTEXT(ctx);
4963 FLUSH_VERTICES(ctx, 0);
4964 ctx->Exec->GetMapiv( target, query, v );
4965 }
4966
4967 static void exec_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
4968 {
4969 GET_CURRENT_CONTEXT(ctx);
4970 FLUSH_VERTICES(ctx, 0);
4971 ctx->Exec->GetMaterialfv( face, pname, params );
4972 }
4973
4974 static void exec_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
4975 {
4976 GET_CURRENT_CONTEXT(ctx);
4977 FLUSH_VERTICES(ctx, 0);
4978 ctx->Exec->GetMaterialiv( face, pname, params );
4979 }
4980
4981 static void exec_GetPixelMapfv( GLenum map, GLfloat *values )
4982 {
4983 GET_CURRENT_CONTEXT(ctx);
4984 FLUSH_VERTICES(ctx, 0);
4985 ctx->Exec->GetPixelMapfv( map, values );
4986 }
4987
4988 static void exec_GetPixelMapuiv( GLenum map, GLuint *values )
4989 {
4990 GET_CURRENT_CONTEXT(ctx);
4991 FLUSH_VERTICES(ctx, 0);
4992 ctx->Exec->GetPixelMapuiv( map, values );
4993 }
4994
4995 static void exec_GetPixelMapusv( GLenum map, GLushort *values )
4996 {
4997 GET_CURRENT_CONTEXT(ctx);
4998 FLUSH_VERTICES(ctx, 0);
4999 ctx->Exec->GetPixelMapusv( map, values );
5000 }
5001
5002 static void exec_GetPolygonStipple( GLubyte *dest )
5003 {
5004 GET_CURRENT_CONTEXT(ctx);
5005 FLUSH_VERTICES(ctx, 0);
5006 ctx->Exec->GetPolygonStipple( dest );
5007 }
5008
5009 static const GLubyte *exec_GetString( GLenum name )
5010 {
5011 GET_CURRENT_CONTEXT(ctx);
5012 FLUSH_VERTICES(ctx, 0);
5013 return ctx->Exec->GetString( name );
5014 }
5015
5016 static void exec_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
5017 {
5018 GET_CURRENT_CONTEXT(ctx);
5019 FLUSH_VERTICES(ctx, 0);
5020 ctx->Exec->GetTexEnvfv( target, pname, params );
5021 }
5022
5023 static void exec_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
5024 {
5025 GET_CURRENT_CONTEXT(ctx);
5026 FLUSH_VERTICES(ctx, 0);
5027 ctx->Exec->GetTexEnviv( target, pname, params );
5028 }
5029
5030 static void exec_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
5031 {
5032 GET_CURRENT_CONTEXT(ctx);
5033 FLUSH_VERTICES(ctx, 0);
5034 ctx->Exec->GetTexGendv( coord, pname, params );
5035 }
5036
5037 static void exec_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
5038 {
5039 GET_CURRENT_CONTEXT(ctx);
5040 FLUSH_VERTICES(ctx, 0);
5041 ctx->Exec->GetTexGenfv( coord, pname, params );
5042 }
5043
5044 static void exec_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
5045 {
5046 GET_CURRENT_CONTEXT(ctx);
5047 FLUSH_VERTICES(ctx, 0);
5048 ctx->Exec->GetTexGeniv( coord, pname, params );
5049 }
5050
5051 static void exec_GetTexImage( GLenum target, GLint level, GLenum format,
5052 GLenum type, GLvoid *pixels )
5053 {
5054 GET_CURRENT_CONTEXT(ctx);
5055 FLUSH_VERTICES(ctx, 0);
5056 ctx->Exec->GetTexImage( target, level, format, type, pixels );
5057 }
5058
5059 static void exec_GetTexLevelParameterfv( GLenum target, GLint level,
5060 GLenum pname, GLfloat *params )
5061 {
5062 GET_CURRENT_CONTEXT(ctx);
5063 FLUSH_VERTICES(ctx, 0);
5064 ctx->Exec->GetTexLevelParameterfv( target, level, pname, params );
5065 }
5066
5067 static void exec_GetTexLevelParameteriv( GLenum target, GLint level,
5068 GLenum pname, GLint *params )
5069 {
5070 GET_CURRENT_CONTEXT(ctx);
5071 FLUSH_VERTICES(ctx, 0);
5072 ctx->Exec->GetTexLevelParameteriv( target, level, pname, params );
5073 }
5074
5075 static void exec_GetTexParameterfv( GLenum target, GLenum pname,
5076 GLfloat *params )
5077 {
5078 GET_CURRENT_CONTEXT(ctx);
5079 FLUSH_VERTICES(ctx, 0);
5080 ctx->Exec->GetTexParameterfv( target, pname, params );
5081 }
5082
5083 static void exec_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
5084 {
5085 GET_CURRENT_CONTEXT(ctx);
5086 FLUSH_VERTICES(ctx, 0);
5087 ctx->Exec->GetTexParameteriv( target, pname, params );
5088 }
5089
5090 static GLboolean exec_IsEnabled( GLenum cap )
5091 {
5092 GET_CURRENT_CONTEXT(ctx);
5093 FLUSH_VERTICES(ctx, 0);
5094 return ctx->Exec->IsEnabled( cap );
5095 }
5096
5097 static void exec_PixelStoref( GLenum pname, GLfloat param )
5098 {
5099 GET_CURRENT_CONTEXT(ctx);
5100 FLUSH_VERTICES(ctx, 0);
5101 ctx->Exec->PixelStoref( pname, param );
5102 }
5103
5104 static void exec_PixelStorei( GLenum pname, GLint param )
5105 {
5106 GET_CURRENT_CONTEXT(ctx);
5107 FLUSH_VERTICES(ctx, 0);
5108 ctx->Exec->PixelStorei( pname, param );
5109 }
5110
5111 static void exec_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
5112 GLenum format, GLenum type, GLvoid *pixels )
5113 {
5114 GET_CURRENT_CONTEXT(ctx);
5115 FLUSH_VERTICES(ctx, 0);
5116 ctx->Exec->ReadPixels( x, y, width, height, format, type, pixels );
5117 }
5118
5119 static GLint exec_RenderMode( GLenum mode )
5120 {
5121 GET_CURRENT_CONTEXT(ctx);
5122 FLUSH_VERTICES(ctx, 0);
5123 return ctx->Exec->RenderMode( mode );
5124 }
5125
5126 static void exec_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer )
5127 {
5128 GET_CURRENT_CONTEXT(ctx);
5129 FLUSH_VERTICES(ctx, 0);
5130 ctx->Exec->FeedbackBuffer( size, type, buffer );
5131 }
5132
5133 static void exec_SelectBuffer( GLsizei size, GLuint *buffer )
5134 {
5135 GET_CURRENT_CONTEXT(ctx);
5136 FLUSH_VERTICES(ctx, 0);
5137 ctx->Exec->SelectBuffer( size, buffer );
5138 }
5139
5140 static GLboolean exec_AreTexturesResident(GLsizei n, const GLuint *texName,
5141 GLboolean *residences)
5142 {
5143 GET_CURRENT_CONTEXT(ctx);
5144 FLUSH_VERTICES(ctx, 0);
5145 return ctx->Exec->AreTexturesResident( n, texName, residences);
5146 }
5147
5148 static void exec_ColorPointer(GLint size, GLenum type, GLsizei stride,
5149 const GLvoid *ptr)
5150 {
5151 GET_CURRENT_CONTEXT(ctx);
5152 FLUSH_VERTICES(ctx, 0);
5153 ctx->Exec->ColorPointer( size, type, stride, ptr);
5154 }
5155
5156 static void exec_DeleteTextures( GLsizei n, const GLuint *texName)
5157 {
5158 GET_CURRENT_CONTEXT(ctx);
5159 FLUSH_VERTICES(ctx, 0);
5160 ctx->Exec->DeleteTextures( n, texName);
5161 }
5162
5163 static void exec_DisableClientState( GLenum cap )
5164 {
5165 GET_CURRENT_CONTEXT(ctx);
5166 FLUSH_VERTICES(ctx, 0);
5167 ctx->Exec->DisableClientState( cap );
5168 }
5169
5170 static void exec_EdgeFlagPointer(GLsizei stride, const void *vptr)
5171 {
5172 GET_CURRENT_CONTEXT(ctx);
5173 FLUSH_VERTICES(ctx, 0);
5174 ctx->Exec->EdgeFlagPointer( stride, vptr);
5175 }
5176
5177 static void exec_EnableClientState( GLenum cap )
5178 {
5179 GET_CURRENT_CONTEXT(ctx);
5180 FLUSH_VERTICES(ctx, 0);
5181 ctx->Exec->EnableClientState( cap );
5182 }
5183
5184 static void exec_GenTextures( GLsizei n, GLuint *texName )
5185 {
5186 GET_CURRENT_CONTEXT(ctx);
5187 FLUSH_VERTICES(ctx, 0);
5188 ctx->Exec->GenTextures( n, texName );
5189 }
5190
5191 static void exec_GetPointerv( GLenum pname, GLvoid **params )
5192 {
5193 GET_CURRENT_CONTEXT(ctx);
5194 FLUSH_VERTICES(ctx, 0);
5195 ctx->Exec->GetPointerv( pname, params );
5196 }
5197
5198 static void exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
5199 {
5200 GET_CURRENT_CONTEXT(ctx);
5201 FLUSH_VERTICES(ctx, 0);
5202 ctx->Exec->IndexPointer( type, stride, ptr);
5203 }
5204
5205 static void exec_InterleavedArrays(GLenum format, GLsizei stride,
5206 const GLvoid *pointer)
5207 {
5208 GET_CURRENT_CONTEXT(ctx);
5209 FLUSH_VERTICES(ctx, 0);
5210 ctx->Exec->InterleavedArrays( format, stride, pointer);
5211 }
5212
5213 static GLboolean exec_IsTexture( GLuint texture )
5214 {
5215 GET_CURRENT_CONTEXT(ctx);
5216 FLUSH_VERTICES(ctx, 0);
5217 return ctx->Exec->IsTexture( texture );
5218 }
5219
5220 static void exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
5221 {
5222 GET_CURRENT_CONTEXT(ctx);
5223 FLUSH_VERTICES(ctx, 0);
5224 ctx->Exec->NormalPointer( type, stride, ptr );
5225 }
5226
5227 static void exec_PopClientAttrib(void)
5228 {
5229 GET_CURRENT_CONTEXT(ctx);
5230 FLUSH_VERTICES(ctx, 0);
5231 ctx->Exec->PopClientAttrib();
5232 }
5233
5234 static void exec_PushClientAttrib(GLbitfield mask)
5235 {
5236 GET_CURRENT_CONTEXT(ctx);
5237 FLUSH_VERTICES(ctx, 0);
5238 ctx->Exec->PushClientAttrib( mask);
5239 }
5240
5241 static void exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
5242 const GLvoid *ptr)
5243 {
5244 GET_CURRENT_CONTEXT(ctx);
5245 FLUSH_VERTICES(ctx, 0);
5246 ctx->Exec->TexCoordPointer( size, type, stride, ptr);
5247 }
5248
5249 static void exec_GetCompressedTexImageARB(GLenum target, GLint level,
5250 GLvoid *img)
5251 {
5252 GET_CURRENT_CONTEXT(ctx);
5253 FLUSH_VERTICES(ctx, 0);
5254 ctx->Exec->GetCompressedTexImageARB( target, level, img);
5255 }
5256
5257 static void exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
5258 const GLvoid *ptr)
5259 {
5260 GET_CURRENT_CONTEXT(ctx);
5261 FLUSH_VERTICES(ctx, 0);
5262 ctx->Exec->VertexPointer( size, type, stride, ptr);
5263 }
5264
5265 static void exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
5266 GLint x, GLint y, GLsizei width)
5267 {
5268 GET_CURRENT_CONTEXT(ctx);
5269 FLUSH_VERTICES(ctx, 0);
5270 ctx->Exec->CopyConvolutionFilter1D( target, internalFormat, x, y, width);
5271 }
5272
5273 static void exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat,
5274 GLint x, GLint y, GLsizei width,
5275 GLsizei height)
5276 {
5277 GET_CURRENT_CONTEXT(ctx);
5278 FLUSH_VERTICES(ctx, 0);
5279 ctx->Exec->CopyConvolutionFilter2D( target, internalFormat, x, y, width,
5280 height);
5281 }
5282
5283 static void exec_GetColorTable( GLenum target, GLenum format,
5284 GLenum type, GLvoid *data )
5285 {
5286 GET_CURRENT_CONTEXT(ctx);
5287 FLUSH_VERTICES(ctx, 0);
5288 ctx->Exec->GetColorTable( target, format, type, data );
5289 }
5290
5291 static void exec_GetColorTableParameterfv( GLenum target, GLenum pname,
5292 GLfloat *params )
5293 {
5294 GET_CURRENT_CONTEXT(ctx);
5295 FLUSH_VERTICES(ctx, 0);
5296 ctx->Exec->GetColorTableParameterfv( target, pname, params );
5297 }
5298
5299 static void exec_GetColorTableParameteriv( GLenum target, GLenum pname,
5300 GLint *params )
5301 {
5302 GET_CURRENT_CONTEXT(ctx);
5303 FLUSH_VERTICES(ctx, 0);
5304 ctx->Exec->GetColorTableParameteriv( target, pname, params );
5305 }
5306
5307 static void exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
5308 GLvoid *image)
5309 {
5310 GET_CURRENT_CONTEXT(ctx);
5311 FLUSH_VERTICES(ctx, 0);
5312 ctx->Exec->GetConvolutionFilter( target, format, type, image);
5313 }
5314
5315 static void exec_GetConvolutionParameterfv(GLenum target, GLenum pname,
5316 GLfloat *params)
5317 {
5318 GET_CURRENT_CONTEXT(ctx);
5319 FLUSH_VERTICES(ctx, 0);
5320 ctx->Exec->GetConvolutionParameterfv( target, pname, params);
5321 }
5322
5323 static void exec_GetConvolutionParameteriv(GLenum target, GLenum pname,
5324 GLint *params)
5325 {
5326 GET_CURRENT_CONTEXT(ctx);
5327 FLUSH_VERTICES(ctx, 0);
5328 ctx->Exec->GetConvolutionParameteriv( target, pname, params);
5329 }
5330
5331 static void exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
5332 GLenum type, GLvoid *values)
5333 {
5334 GET_CURRENT_CONTEXT(ctx);
5335 FLUSH_VERTICES(ctx, 0);
5336 ctx->Exec->GetHistogram( target, reset, format, type, values);
5337 }
5338
5339 static void exec_GetHistogramParameterfv(GLenum target, GLenum pname,
5340 GLfloat *params)
5341 {
5342 GET_CURRENT_CONTEXT(ctx);
5343 FLUSH_VERTICES(ctx, 0);
5344 ctx->Exec->GetHistogramParameterfv( target, pname, params);
5345 }
5346
5347 static void exec_GetHistogramParameteriv(GLenum target, GLenum pname,
5348 GLint *params)
5349 {
5350 GET_CURRENT_CONTEXT(ctx);
5351 FLUSH_VERTICES(ctx, 0);
5352 ctx->Exec->GetHistogramParameteriv( target, pname, params);
5353 }
5354
5355 static void exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
5356 GLenum type, GLvoid *values)
5357 {
5358 GET_CURRENT_CONTEXT(ctx);
5359 FLUSH_VERTICES(ctx, 0);
5360 ctx->Exec->GetMinmax( target, reset, format, type, values);
5361 }
5362
5363 static void exec_GetMinmaxParameterfv(GLenum target, GLenum pname,
5364 GLfloat *params)
5365 {
5366 GET_CURRENT_CONTEXT(ctx);
5367 FLUSH_VERTICES(ctx, 0);
5368 ctx->Exec->GetMinmaxParameterfv( target, pname, params);
5369 }
5370
5371 static void exec_GetMinmaxParameteriv(GLenum target, GLenum pname,
5372 GLint *params)
5373 {
5374 GET_CURRENT_CONTEXT(ctx);
5375 FLUSH_VERTICES(ctx, 0);
5376 ctx->Exec->GetMinmaxParameteriv( target, pname, params);
5377 }
5378
5379 static void exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
5380 GLvoid *row, GLvoid *column, GLvoid *span)
5381 {
5382 GET_CURRENT_CONTEXT(ctx);
5383 FLUSH_VERTICES(ctx, 0);
5384 ctx->Exec->GetSeparableFilter( target, format, type, row, column, span);
5385 }
5386
5387 static void exec_SeparableFilter2D(GLenum target, GLenum internalFormat,
5388 GLsizei width, GLsizei height, GLenum format,
5389 GLenum type, const GLvoid *row,
5390 const GLvoid *column)
5391 {
5392 GET_CURRENT_CONTEXT(ctx);
5393 FLUSH_VERTICES(ctx, 0);
5394 ctx->Exec->SeparableFilter2D( target, internalFormat, width, height, format,
5395 type, row, column);
5396 }
5397
5398 static void exec_GetPixelTexGenParameterivSGIS(GLenum target, GLint *value)
5399 {
5400 GET_CURRENT_CONTEXT(ctx);
5401 FLUSH_VERTICES(ctx, 0);
5402 ctx->Exec->GetPixelTexGenParameterivSGIS( target, value);
5403 }
5404
5405 static void exec_GetPixelTexGenParameterfvSGIS(GLenum target, GLfloat *value)
5406 {
5407 GET_CURRENT_CONTEXT(ctx);
5408 FLUSH_VERTICES(ctx, 0);
5409 ctx->Exec->GetPixelTexGenParameterfvSGIS( target, value);
5410 }
5411
5412 static void exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride,
5413 GLsizei count, const GLvoid *ptr)
5414 {
5415 GET_CURRENT_CONTEXT(ctx);
5416 FLUSH_VERTICES(ctx, 0);
5417 ctx->Exec->ColorPointerEXT( size, type, stride, count, ptr);
5418 }
5419
5420 static void exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count,
5421 const GLboolean *ptr)
5422 {
5423 GET_CURRENT_CONTEXT(ctx);
5424 FLUSH_VERTICES(ctx, 0);
5425 ctx->Exec->EdgeFlagPointerEXT( stride, count, ptr);
5426 }
5427
5428 static void exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
5429 const GLvoid *ptr)
5430 {
5431 GET_CURRENT_CONTEXT(ctx);
5432 FLUSH_VERTICES(ctx, 0);
5433 ctx->Exec->IndexPointerEXT( type, stride, count, ptr);
5434 }
5435
5436 static void exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
5437 const GLvoid *ptr)
5438 {
5439 GET_CURRENT_CONTEXT(ctx);
5440 FLUSH_VERTICES(ctx, 0);
5441 ctx->Exec->NormalPointerEXT( type, stride, count, ptr);
5442 }
5443
5444 static void exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
5445 GLsizei count, const GLvoid *ptr)
5446 {
5447 GET_CURRENT_CONTEXT(ctx);
5448 FLUSH_VERTICES(ctx, 0);
5449 ctx->Exec->TexCoordPointerEXT( size, type, stride, count, ptr);
5450 }
5451
5452 static void exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
5453 GLsizei count, const GLvoid *ptr)
5454 {
5455 GET_CURRENT_CONTEXT(ctx);
5456 FLUSH_VERTICES(ctx, 0);
5457 ctx->Exec->VertexPointerEXT( size, type, stride, count, ptr);
5458 }
5459
5460 static void exec_LockArraysEXT(GLint first, GLsizei count)
5461 {
5462 GET_CURRENT_CONTEXT(ctx);
5463 FLUSH_VERTICES(ctx, 0);
5464 ctx->Exec->LockArraysEXT( first, count);
5465 }
5466
5467 static void exec_UnlockArraysEXT( void )
5468 {
5469 GET_CURRENT_CONTEXT(ctx);
5470 FLUSH_VERTICES(ctx, 0);
5471 ctx->Exec->UnlockArraysEXT( );
5472 }
5473
5474 static void exec_ResizeBuffersMESA( void )
5475 {
5476 GET_CURRENT_CONTEXT(ctx);
5477 FLUSH_VERTICES(ctx, 0);
5478 ctx->Exec->ResizeBuffersMESA( );
5479 }
5480
5481 static void exec_SecondaryColorPointerEXT(GLint size, GLenum type,
5482 GLsizei stride, const GLvoid *ptr)
5483 {
5484 GET_CURRENT_CONTEXT(ctx);
5485 FLUSH_VERTICES(ctx, 0);
5486 ctx->Exec->SecondaryColorPointerEXT( size, type, stride, ptr);
5487 }
5488
5489 static void exec_FogCoordPointerEXT(GLenum type, GLsizei stride,
5490 const GLvoid *ptr)
5491 {
5492 GET_CURRENT_CONTEXT(ctx);
5493 FLUSH_VERTICES(ctx, 0);
5494 ctx->Exec->FogCoordPointerEXT( type, stride, ptr);
5495 }
5496
5497
5498 /*
5499 * Assign all the pointers in <table> to point to Mesa's display list
5500 * building functions.
5501 *
5502 * This does not include any of the tnl functions - they are
5503 * initialized from _mesa_init_api_defaults and from the active vtxfmt
5504 * struct.
5505 */
5506 void
5507 _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
5508 {
5509 _mesa_init_no_op_table(table, tableSize);
5510
5511 _mesa_loopback_init_api_table( table, GL_FALSE );
5512
5513 /* GL 1.0 */
5514 table->Accum = save_Accum;
5515 table->AlphaFunc = save_AlphaFunc;
5516 table->Bitmap = save_Bitmap;
5517 table->BlendFunc = save_BlendFunc;
5518 table->CallList = _mesa_save_CallList;
5519 table->CallLists = _mesa_save_CallLists;
5520 table->Clear = save_Clear;
5521 table->ClearAccum = save_ClearAccum;
5522 table->ClearColor = save_ClearColor;
5523 table->ClearDepth = save_ClearDepth;
5524 table->ClearIndex = save_ClearIndex;
5525 table->ClearStencil = save_ClearStencil;
5526 table->ClipPlane = save_ClipPlane;
5527 table->ColorMask = save_ColorMask;
5528 table->ColorMaterial = save_ColorMaterial;
5529 table->CopyPixels = save_CopyPixels;
5530 table->CullFace = save_CullFace;
5531 table->DeleteLists = _mesa_DeleteLists;
5532 table->DepthFunc = save_DepthFunc;
5533 table->DepthMask = save_DepthMask;
5534 table->DepthRange = save_DepthRange;
5535 table->Disable = save_Disable;
5536 table->DrawBuffer = save_DrawBuffer;
5537 table->DrawPixels = save_DrawPixels;
5538 table->Enable = save_Enable;
5539 table->EndList = _mesa_EndList;
5540 table->EvalMesh1 = _mesa_save_EvalMesh1;
5541 table->EvalMesh2 = _mesa_save_EvalMesh2;
5542 table->Finish = exec_Finish;
5543 table->Flush = exec_Flush;
5544 table->Fogf = save_Fogf;
5545 table->Fogfv = save_Fogfv;
5546 table->Fogi = save_Fogi;
5547 table->Fogiv = save_Fogiv;
5548 table->FrontFace = save_FrontFace;
5549 table->Frustum = save_Frustum;
5550 table->GenLists = _mesa_GenLists;
5551 table->GetBooleanv = exec_GetBooleanv;
5552 table->GetClipPlane = exec_GetClipPlane;
5553 table->GetDoublev = exec_GetDoublev;
5554 table->GetError = exec_GetError;
5555 table->GetFloatv = exec_GetFloatv;
5556 table->GetIntegerv = exec_GetIntegerv;
5557 table->GetLightfv = exec_GetLightfv;
5558 table->GetLightiv = exec_GetLightiv;
5559 table->GetMapdv = exec_GetMapdv;
5560 table->GetMapfv = exec_GetMapfv;
5561 table->GetMapiv = exec_GetMapiv;
5562 table->GetMaterialfv = exec_GetMaterialfv;
5563 table->GetMaterialiv = exec_GetMaterialiv;
5564 table->GetPixelMapfv = exec_GetPixelMapfv;
5565 table->GetPixelMapuiv = exec_GetPixelMapuiv;
5566 table->GetPixelMapusv = exec_GetPixelMapusv;
5567 table->GetPolygonStipple = exec_GetPolygonStipple;
5568 table->GetString = exec_GetString;
5569 table->GetTexEnvfv = exec_GetTexEnvfv;
5570 table->GetTexEnviv = exec_GetTexEnviv;
5571 table->GetTexGendv = exec_GetTexGendv;
5572 table->GetTexGenfv = exec_GetTexGenfv;
5573 table->GetTexGeniv = exec_GetTexGeniv;
5574 table->GetTexImage = exec_GetTexImage;
5575 table->GetTexLevelParameterfv = exec_GetTexLevelParameterfv;
5576 table->GetTexLevelParameteriv = exec_GetTexLevelParameteriv;
5577 table->GetTexParameterfv = exec_GetTexParameterfv;
5578 table->GetTexParameteriv = exec_GetTexParameteriv;
5579 table->Hint = save_Hint;
5580 table->IndexMask = save_IndexMask;
5581 table->InitNames = save_InitNames;
5582 table->IsEnabled = exec_IsEnabled;
5583 table->IsList = _mesa_IsList;
5584 table->LightModelf = save_LightModelf;
5585 table->LightModelfv = save_LightModelfv;
5586 table->LightModeli = save_LightModeli;
5587 table->LightModeliv = save_LightModeliv;
5588 table->Lightf = save_Lightf;
5589 table->Lightfv = save_Lightfv;
5590 table->Lighti = save_Lighti;
5591 table->Lightiv = save_Lightiv;
5592 table->LineStipple = save_LineStipple;
5593 table->LineWidth = save_LineWidth;
5594 table->ListBase = save_ListBase;
5595 table->LoadIdentity = save_LoadIdentity;
5596 table->LoadMatrixd = save_LoadMatrixd;
5597 table->LoadMatrixf = save_LoadMatrixf;
5598 table->LoadName = save_LoadName;
5599 table->LogicOp = save_LogicOp;
5600 table->Map1d = save_Map1d;
5601 table->Map1f = save_Map1f;
5602 table->Map2d = save_Map2d;
5603 table->Map2f = save_Map2f;
5604 table->MapGrid1d = save_MapGrid1d;
5605 table->MapGrid1f = save_MapGrid1f;
5606 table->MapGrid2d = save_MapGrid2d;
5607 table->MapGrid2f = save_MapGrid2f;
5608 table->MatrixMode = save_MatrixMode;
5609 table->MultMatrixd = save_MultMatrixd;
5610 table->MultMatrixf = save_MultMatrixf;
5611 table->NewList = save_NewList;
5612 table->Ortho = save_Ortho;
5613 table->PassThrough = save_PassThrough;
5614 table->PixelMapfv = save_PixelMapfv;
5615 table->PixelMapuiv = save_PixelMapuiv;
5616 table->PixelMapusv = save_PixelMapusv;
5617 table->PixelStoref = exec_PixelStoref;
5618 table->PixelStorei = exec_PixelStorei;
5619 table->PixelTransferf = save_PixelTransferf;
5620 table->PixelTransferi = save_PixelTransferi;
5621 table->PixelZoom = save_PixelZoom;
5622 table->PointSize = save_PointSize;
5623 table->PolygonMode = save_PolygonMode;
5624 table->PolygonOffset = save_PolygonOffset;
5625 table->PolygonStipple = save_PolygonStipple;
5626 table->PopAttrib = save_PopAttrib;
5627 table->PopMatrix = save_PopMatrix;
5628 table->PopName = save_PopName;
5629 table->PushAttrib = save_PushAttrib;
5630 table->PushMatrix = save_PushMatrix;
5631 table->PushName = save_PushName;
5632 table->RasterPos2d = save_RasterPos2d;
5633 table->RasterPos2dv = save_RasterPos2dv;
5634 table->RasterPos2f = save_RasterPos2f;
5635 table->RasterPos2fv = save_RasterPos2fv;
5636 table->RasterPos2i = save_RasterPos2i;
5637 table->RasterPos2iv = save_RasterPos2iv;
5638 table->RasterPos2s = save_RasterPos2s;
5639 table->RasterPos2sv = save_RasterPos2sv;
5640 table->RasterPos3d = save_RasterPos3d;
5641 table->RasterPos3dv = save_RasterPos3dv;
5642 table->RasterPos3f = save_RasterPos3f;
5643 table->RasterPos3fv = save_RasterPos3fv;
5644 table->RasterPos3i = save_RasterPos3i;
5645 table->RasterPos3iv = save_RasterPos3iv;
5646 table->RasterPos3s = save_RasterPos3s;
5647 table->RasterPos3sv = save_RasterPos3sv;
5648 table->RasterPos4d = save_RasterPos4d;
5649 table->RasterPos4dv = save_RasterPos4dv;
5650 table->RasterPos4f = save_RasterPos4f;
5651 table->RasterPos4fv = save_RasterPos4fv;
5652 table->RasterPos4i = save_RasterPos4i;
5653 table->RasterPos4iv = save_RasterPos4iv;
5654 table->RasterPos4s = save_RasterPos4s;
5655 table->RasterPos4sv = save_RasterPos4sv;
5656 table->ReadBuffer = save_ReadBuffer;
5657 table->ReadPixels = exec_ReadPixels;
5658 table->RenderMode = exec_RenderMode;
5659 table->Rotated = save_Rotated;
5660 table->Rotatef = save_Rotatef;
5661 table->Scaled = save_Scaled;
5662 table->Scalef = save_Scalef;
5663 table->Scissor = save_Scissor;
5664 table->FeedbackBuffer = exec_FeedbackBuffer;
5665 table->SelectBuffer = exec_SelectBuffer;
5666 table->ShadeModel = save_ShadeModel;
5667 table->StencilFunc = save_StencilFunc;
5668 table->StencilMask = save_StencilMask;
5669 table->StencilOp = save_StencilOp;
5670 table->TexEnvf = save_TexEnvf;
5671 table->TexEnvfv = save_TexEnvfv;
5672 table->TexEnvi = save_TexEnvi;
5673 table->TexEnviv = save_TexEnviv;
5674 table->TexGend = save_TexGend;
5675 table->TexGendv = save_TexGendv;
5676 table->TexGenf = save_TexGenf;
5677 table->TexGenfv = save_TexGenfv;
5678 table->TexGeni = save_TexGeni;
5679 table->TexGeniv = save_TexGeniv;
5680 table->TexImage1D = save_TexImage1D;
5681 table->TexImage2D = save_TexImage2D;
5682 table->TexParameterf = save_TexParameterf;
5683 table->TexParameterfv = save_TexParameterfv;
5684 table->TexParameteri = save_TexParameteri;
5685 table->TexParameteriv = save_TexParameteriv;
5686 table->Translated = save_Translated;
5687 table->Translatef = save_Translatef;
5688 table->Viewport = save_Viewport;
5689
5690 /* GL 1.1 */
5691 table->AreTexturesResident = exec_AreTexturesResident;
5692 table->BindTexture = save_BindTexture;
5693 table->ColorPointer = exec_ColorPointer;
5694 table->CopyTexImage1D = save_CopyTexImage1D;
5695 table->CopyTexImage2D = save_CopyTexImage2D;
5696 table->CopyTexSubImage1D = save_CopyTexSubImage1D;
5697 table->CopyTexSubImage2D = save_CopyTexSubImage2D;
5698 table->DeleteTextures = exec_DeleteTextures;
5699 table->DisableClientState = exec_DisableClientState;
5700 table->EdgeFlagPointer = exec_EdgeFlagPointer;
5701 table->EnableClientState = exec_EnableClientState;
5702 table->GenTextures = exec_GenTextures;
5703 table->GetPointerv = exec_GetPointerv;
5704 table->IndexPointer = exec_IndexPointer;
5705 table->InterleavedArrays = exec_InterleavedArrays;
5706 table->IsTexture = exec_IsTexture;
5707 table->NormalPointer = exec_NormalPointer;
5708 table->PopClientAttrib = exec_PopClientAttrib;
5709 table->PrioritizeTextures = save_PrioritizeTextures;
5710 table->PushClientAttrib = exec_PushClientAttrib;
5711 table->TexCoordPointer = exec_TexCoordPointer;
5712 table->TexSubImage1D = save_TexSubImage1D;
5713 table->TexSubImage2D = save_TexSubImage2D;
5714 table->VertexPointer = exec_VertexPointer;
5715
5716 /* GL 1.2 */
5717 table->CopyTexSubImage3D = save_CopyTexSubImage3D;
5718 table->TexImage3D = save_TexImage3D;
5719 table->TexSubImage3D = save_TexSubImage3D;
5720
5721 /* GL_ARB_imaging */
5722 /* Not all are supported */
5723 table->BlendColor = save_BlendColor;
5724 table->BlendEquation = save_BlendEquation;
5725 table->ColorSubTable = save_ColorSubTable;
5726 table->ColorTable = save_ColorTable;
5727 table->ColorTableParameterfv = save_ColorTableParameterfv;
5728 table->ColorTableParameteriv = save_ColorTableParameteriv;
5729 table->ConvolutionFilter1D = save_ConvolutionFilter1D;
5730 table->ConvolutionFilter2D = save_ConvolutionFilter2D;
5731 table->ConvolutionParameterf = save_ConvolutionParameterf;
5732 table->ConvolutionParameterfv = save_ConvolutionParameterfv;
5733 table->ConvolutionParameteri = save_ConvolutionParameteri;
5734 table->ConvolutionParameteriv = save_ConvolutionParameteriv;
5735 table->CopyColorSubTable = save_CopyColorSubTable;
5736 table->CopyColorTable = save_CopyColorTable;
5737 table->CopyConvolutionFilter1D = exec_CopyConvolutionFilter1D;
5738 table->CopyConvolutionFilter2D = exec_CopyConvolutionFilter2D;
5739 table->GetColorTable = exec_GetColorTable;
5740 table->GetColorTableParameterfv = exec_GetColorTableParameterfv;
5741 table->GetColorTableParameteriv = exec_GetColorTableParameteriv;
5742 table->GetConvolutionFilter = exec_GetConvolutionFilter;
5743 table->GetConvolutionParameterfv = exec_GetConvolutionParameterfv;
5744 table->GetConvolutionParameteriv = exec_GetConvolutionParameteriv;
5745 table->GetHistogram = exec_GetHistogram;
5746 table->GetHistogramParameterfv = exec_GetHistogramParameterfv;
5747 table->GetHistogramParameteriv = exec_GetHistogramParameteriv;
5748 table->GetMinmax = exec_GetMinmax;
5749 table->GetMinmaxParameterfv = exec_GetMinmaxParameterfv;
5750 table->GetMinmaxParameteriv = exec_GetMinmaxParameteriv;
5751 table->GetSeparableFilter = exec_GetSeparableFilter;
5752 table->Histogram = save_Histogram;
5753 table->Minmax = save_Minmax;
5754 table->ResetHistogram = save_ResetHistogram;
5755 table->ResetMinmax = save_ResetMinmax;
5756 table->SeparableFilter2D = exec_SeparableFilter2D;
5757
5758 /* 2. GL_EXT_blend_color */
5759 #if 0
5760 table->BlendColorEXT = save_BlendColorEXT;
5761 #endif
5762
5763 /* 3. GL_EXT_polygon_offset */
5764 table->PolygonOffsetEXT = save_PolygonOffsetEXT;
5765
5766 /* 6. GL_EXT_texture3d */
5767 #if 0
5768 table->CopyTexSubImage3DEXT = save_CopyTexSubImage3D;
5769 table->TexImage3DEXT = save_TexImage3DEXT;
5770 table->TexSubImage3DEXT = save_TexSubImage3D;
5771 #endif
5772
5773 /* 15. GL_SGIX_pixel_texture */
5774 table->PixelTexGenSGIX = save_PixelTexGenSGIX;
5775
5776 /* 15. GL_SGIS_pixel_texture */
5777 table->PixelTexGenParameteriSGIS = save_PixelTexGenParameteriSGIS;
5778 table->PixelTexGenParameterfSGIS = save_PixelTexGenParameterfSGIS;
5779 table->PixelTexGenParameterivSGIS = save_PixelTexGenParameterivSGIS;
5780 table->PixelTexGenParameterfvSGIS = save_PixelTexGenParameterfvSGIS;
5781 table->GetPixelTexGenParameterivSGIS = exec_GetPixelTexGenParameterivSGIS;
5782 table->GetPixelTexGenParameterfvSGIS = exec_GetPixelTexGenParameterfvSGIS;
5783
5784 /* 30. GL_EXT_vertex_array */
5785 table->ColorPointerEXT = exec_ColorPointerEXT;
5786 table->EdgeFlagPointerEXT = exec_EdgeFlagPointerEXT;
5787 table->IndexPointerEXT = exec_IndexPointerEXT;
5788 table->NormalPointerEXT = exec_NormalPointerEXT;
5789 table->TexCoordPointerEXT = exec_TexCoordPointerEXT;
5790 table->VertexPointerEXT = exec_VertexPointerEXT;
5791
5792 /* 37. GL_EXT_blend_minmax */
5793 #if 0
5794 table->BlendEquationEXT = save_BlendEquationEXT;
5795 #endif
5796
5797 /* 54. GL_EXT_point_parameters */
5798 table->PointParameterfEXT = save_PointParameterfEXT;
5799 table->PointParameterfvEXT = save_PointParameterfvEXT;
5800
5801 /* 78. GL_EXT_paletted_texture */
5802 #if 0
5803 table->ColorTableEXT = save_ColorTable;
5804 table->ColorSubTableEXT = save_ColorSubTable;
5805 #endif
5806 table->GetColorTableEXT = exec_GetColorTable;
5807 table->GetColorTableParameterfvEXT = exec_GetColorTableParameterfv;
5808 table->GetColorTableParameterivEXT = exec_GetColorTableParameteriv;
5809
5810 /* 97. GL_EXT_compiled_vertex_array */
5811 table->LockArraysEXT = exec_LockArraysEXT;
5812 table->UnlockArraysEXT = exec_UnlockArraysEXT;
5813
5814 /* GL_ARB_multitexture */
5815 table->ActiveTextureARB = save_ActiveTextureARB;
5816 table->ClientActiveTextureARB = save_ClientActiveTextureARB;
5817
5818 /* GL_EXT_blend_func_separate */
5819 table->BlendFuncSeparateEXT = save_BlendFuncSeparateEXT;
5820
5821 /* GL_MESA_window_pos */
5822 table->WindowPos2dMESA = save_WindowPos2dMESA;
5823 table->WindowPos2dvMESA = save_WindowPos2dvMESA;
5824 table->WindowPos2fMESA = save_WindowPos2fMESA;
5825 table->WindowPos2fvMESA = save_WindowPos2fvMESA;
5826 table->WindowPos2iMESA = save_WindowPos2iMESA;
5827 table->WindowPos2ivMESA = save_WindowPos2ivMESA;
5828 table->WindowPos2sMESA = save_WindowPos2sMESA;
5829 table->WindowPos2svMESA = save_WindowPos2svMESA;
5830 table->WindowPos3dMESA = save_WindowPos3dMESA;
5831 table->WindowPos3dvMESA = save_WindowPos3dvMESA;
5832 table->WindowPos3fMESA = save_WindowPos3fMESA;
5833 table->WindowPos3fvMESA = save_WindowPos3fvMESA;
5834 table->WindowPos3iMESA = save_WindowPos3iMESA;
5835 table->WindowPos3ivMESA = save_WindowPos3ivMESA;
5836 table->WindowPos3sMESA = save_WindowPos3sMESA;
5837 table->WindowPos3svMESA = save_WindowPos3svMESA;
5838 table->WindowPos4dMESA = save_WindowPos4dMESA;
5839 table->WindowPos4dvMESA = save_WindowPos4dvMESA;
5840 table->WindowPos4fMESA = save_WindowPos4fMESA;
5841 table->WindowPos4fvMESA = save_WindowPos4fvMESA;
5842 table->WindowPos4iMESA = save_WindowPos4iMESA;
5843 table->WindowPos4ivMESA = save_WindowPos4ivMESA;
5844 table->WindowPos4sMESA = save_WindowPos4sMESA;
5845 table->WindowPos4svMESA = save_WindowPos4svMESA;
5846
5847 /* GL_MESA_resize_buffers */
5848 table->ResizeBuffersMESA = exec_ResizeBuffersMESA;
5849
5850 /* GL_ARB_transpose_matrix */
5851 table->LoadTransposeMatrixdARB = save_LoadTransposeMatrixdARB;
5852 table->LoadTransposeMatrixfARB = save_LoadTransposeMatrixfARB;
5853 table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB;
5854 table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB;
5855
5856 /* ARB 12. GL_ARB_texture_compression */
5857 table->CompressedTexImage3DARB = save_CompressedTexImage3DARB;
5858 table->CompressedTexImage2DARB = save_CompressedTexImage2DARB;
5859 table->CompressedTexImage1DARB = save_CompressedTexImage1DARB;
5860 table->CompressedTexSubImage3DARB = save_CompressedTexSubImage3DARB;
5861 table->CompressedTexSubImage2DARB = save_CompressedTexSubImage2DARB;
5862 table->CompressedTexSubImage1DARB = save_CompressedTexSubImage1DARB;
5863 table->GetCompressedTexImageARB = exec_GetCompressedTexImageARB;
5864
5865 /* GL_EXT_secondary_color */
5866 table->SecondaryColorPointerEXT = exec_SecondaryColorPointerEXT;
5867
5868 /* GL_EXT_fog_coord */
5869 table->FogCoordPointerEXT = exec_FogCoordPointerEXT;
5870 }
5871
5872
5873
5874 /***
5875 *** Debugging code
5876 ***/
5877 static const char *enum_string( GLenum k )
5878 {
5879 return gl_lookup_enum_by_nr( k );
5880 }
5881
5882
5883 /*
5884 * Print the commands in a display list. For debugging only.
5885 * TODO: many commands aren't handled yet.
5886 */
5887 static void print_list( GLcontext *ctx, FILE *f, GLuint list )
5888 {
5889 Node *n;
5890 GLboolean done;
5891
5892 if (!glIsList(list)) {
5893 fprintf(f,"%u is not a display list ID\n",list);
5894 return;
5895 }
5896
5897 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
5898
5899 fprintf( f, "START-LIST %u, address %p\n", list, (void*)n );
5900
5901 done = n ? GL_FALSE : GL_TRUE;
5902 while (!done) {
5903 OpCode opcode = n[0].opcode;
5904 int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
5905
5906 if (i >= 0 && i < ctx->listext.nr_opcodes) {
5907 ctx->listext.opcode[i].print(ctx, &n[1]);
5908 n += ctx->listext.opcode[i].size;
5909 } else {
5910 switch (opcode) {
5911 case OPCODE_ACCUM:
5912 fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f );
5913 break;
5914 case OPCODE_BITMAP:
5915 fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
5916 n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
5917 break;
5918 case OPCODE_CALL_LIST:
5919 fprintf(f,"CallList %d\n", (int) n[1].ui );
5920 break;
5921 case OPCODE_CALL_LIST_OFFSET:
5922 fprintf(f,"CallList %d + offset %u = %u\n", (int) n[1].ui,
5923 ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
5924 break;
5925 case OPCODE_COLOR_TABLE_PARAMETER_FV:
5926 fprintf(f,"ColorTableParameterfv %s %s %f %f %f %f\n",
5927 enum_string(n[1].e), enum_string(n[2].e),
5928 n[3].f, n[4].f, n[5].f, n[6].f);
5929 break;
5930 case OPCODE_COLOR_TABLE_PARAMETER_IV:
5931 fprintf(f,"ColorTableParameteriv %s %s %d %d %d %d\n",
5932 enum_string(n[1].e), enum_string(n[2].e),
5933 n[3].i, n[4].i, n[5].i, n[6].i);
5934 break;
5935 case OPCODE_DISABLE:
5936 fprintf(f,"Disable %s\n", enum_string(n[1].e));
5937 break;
5938 case OPCODE_ENABLE:
5939 fprintf(f,"Enable %s\n", enum_string(n[1].e));
5940 break;
5941 case OPCODE_FRUSTUM:
5942 fprintf(f,"Frustum %g %g %g %g %g %g\n",
5943 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
5944 break;
5945 case OPCODE_LINE_STIPPLE:
5946 fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us );
5947 break;
5948 case OPCODE_LOAD_IDENTITY:
5949 fprintf(f,"LoadIdentity\n");
5950 break;
5951 case OPCODE_LOAD_MATRIX:
5952 fprintf(f,"LoadMatrix\n");
5953 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
5954 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
5955 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
5956 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
5957 break;
5958 case OPCODE_MULT_MATRIX:
5959 fprintf(f,"MultMatrix (or Rotate)\n");
5960 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
5961 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
5962 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
5963 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
5964 break;
5965 case OPCODE_ORTHO:
5966 fprintf(f,"Ortho %g %g %g %g %g %g\n",
5967 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
5968 break;
5969 case OPCODE_POP_ATTRIB:
5970 fprintf(f,"PopAttrib\n");
5971 break;
5972 case OPCODE_POP_MATRIX:
5973 fprintf(f,"PopMatrix\n");
5974 break;
5975 case OPCODE_POP_NAME:
5976 fprintf(f,"PopName\n");
5977 break;
5978 case OPCODE_PUSH_ATTRIB:
5979 fprintf(f,"PushAttrib %x\n", n[1].bf );
5980 break;
5981 case OPCODE_PUSH_MATRIX:
5982 fprintf(f,"PushMatrix\n");
5983 break;
5984 case OPCODE_PUSH_NAME:
5985 fprintf(f,"PushName %d\n", (int) n[1].ui );
5986 break;
5987 case OPCODE_RASTER_POS:
5988 fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f);
5989 break;
5990 case OPCODE_ROTATE:
5991 fprintf(f,"Rotate %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f );
5992 break;
5993 case OPCODE_SCALE:
5994 fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
5995 break;
5996 case OPCODE_TRANSLATE:
5997 fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
5998 break;
5999 case OPCODE_BIND_TEXTURE:
6000 fprintf(f,"BindTexture %s %d\n", gl_lookup_enum_by_nr(n[1].ui),
6001 n[2].ui);
6002 break;
6003 case OPCODE_SHADE_MODEL:
6004 fprintf(f,"ShadeModel %s\n", gl_lookup_enum_by_nr(n[1].ui));
6005 break;
6006
6007 /*
6008 * meta opcodes/commands
6009 */
6010 case OPCODE_ERROR:
6011 fprintf(f,"Error: %s %s\n", enum_string(n[1].e), (const char *)n[2].data );
6012 break;
6013 case OPCODE_CONTINUE:
6014 fprintf(f,"DISPLAY-LIST-CONTINUE\n");
6015 n = (Node *) n[1].next;
6016 break;
6017 case OPCODE_END_OF_LIST:
6018 fprintf(f,"END-LIST %u\n", list);
6019 done = GL_TRUE;
6020 break;
6021 default:
6022 if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
6023 fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
6024 opcode, (void*) n);
6025 return;
6026 }
6027 else {
6028 fprintf(f,"command %d, %u operands\n",opcode,InstSize[opcode]);
6029 }
6030 }
6031 /* increment n to point to next compiled command */
6032 if (opcode!=OPCODE_CONTINUE) {
6033 n += InstSize[opcode];
6034 }
6035 }
6036 }
6037 }
6038
6039
6040
6041 /*
6042 * Clients may call this function to help debug display list problems.
6043 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
6044 * changed, or break in the future without notice.
6045 */
6046 void mesa_print_display_list( GLuint list )
6047 {
6048 GET_CURRENT_CONTEXT(ctx);
6049 print_list( ctx, stderr, list );
6050 }