Fixed a couple of bugs that crept into last commit
[mesa.git] / src / mesa / main / dlist.c
1 /* $Id: dlist.c,v 1.54 2000/11/24 15:21:59 keithw Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999-2000 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 "enable.h"
46 #include "enums.h"
47 #include "eval.h"
48 #include "extensions.h"
49 #include "feedback.h"
50 #include "get.h"
51 #include "glapi.h"
52 #include "hash.h"
53 #include "histogram.h"
54 #include "image.h"
55 #include "light.h"
56 #include "lines.h"
57 #include "dlist.h"
58 #include "macros.h"
59 #include "matrix.h"
60 #include "mem.h"
61 #include "pixel.h"
62 #include "pixeltex.h"
63 #include "points.h"
64 #include "polygon.h"
65 #include "readpix.h"
66 #include "state.h"
67 #include "texobj.h"
68 #include "teximage.h"
69 #include "texstate.h"
70 #include "mtypes.h"
71 #include "varray.h"
72
73 #include "math/m_matrix.h"
74 #include "math/m_xform.h"
75
76 #endif
77
78
79
80 /*
81 Functions which aren't compiled but executed immediately:
82 glIsList
83 glGenLists
84 glDeleteLists
85 glEndList
86 glFeedbackBuffer
87 glSelectBuffer
88 glRenderMode
89 glReadPixels
90 glPixelStore
91 glFlush
92 glFinish
93 glIsEnabled
94 glGet*
95
96 Functions which cause errors if called while compiling a display list:
97 glNewList
98 */
99
100
101
102 /*
103 * Display list instructions are stored as sequences of "nodes". Nodes
104 * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
105 * are linked together with a pointer.
106 */
107
108
109 /* How many nodes to allocate at a time:
110 * - reduced now that we hold vertices etc. elsewhere.
111 */
112 #define BLOCK_SIZE 64
113
114
115 /*
116 * Display list opcodes.
117 *
118 * The fact that these identifiers are assigned consecutive
119 * integer values starting at 0 is very important, see InstSize array usage)
120 *
121 */
122 typedef enum {
123 OPCODE_ACCUM,
124 OPCODE_ALPHA_FUNC,
125 OPCODE_BIND_TEXTURE,
126 OPCODE_BITMAP,
127 OPCODE_BLEND_COLOR,
128 OPCODE_BLEND_EQUATION,
129 OPCODE_BLEND_FUNC,
130 OPCODE_BLEND_FUNC_SEPARATE,
131 OPCODE_CALL_LIST,
132 OPCODE_CALL_LIST_OFFSET,
133 OPCODE_CLEAR,
134 OPCODE_CLEAR_ACCUM,
135 OPCODE_CLEAR_COLOR,
136 OPCODE_CLEAR_DEPTH,
137 OPCODE_CLEAR_INDEX,
138 OPCODE_CLEAR_STENCIL,
139 OPCODE_CLIP_PLANE,
140 OPCODE_COLOR_MASK,
141 OPCODE_COLOR_MATERIAL,
142 OPCODE_COLOR_TABLE,
143 OPCODE_COLOR_TABLE_PARAMETER_FV,
144 OPCODE_COLOR_TABLE_PARAMETER_IV,
145 OPCODE_COLOR_SUB_TABLE,
146 OPCODE_CONVOLUTION_FILTER_1D,
147 OPCODE_CONVOLUTION_FILTER_2D,
148 OPCODE_CONVOLUTION_PARAMETER_I,
149 OPCODE_CONVOLUTION_PARAMETER_IV,
150 OPCODE_CONVOLUTION_PARAMETER_F,
151 OPCODE_CONVOLUTION_PARAMETER_FV,
152 OPCODE_COPY_COLOR_SUB_TABLE,
153 OPCODE_COPY_COLOR_TABLE,
154 OPCODE_COPY_PIXELS,
155 OPCODE_COPY_TEX_IMAGE1D,
156 OPCODE_COPY_TEX_IMAGE2D,
157 OPCODE_COPY_TEX_SUB_IMAGE1D,
158 OPCODE_COPY_TEX_SUB_IMAGE2D,
159 OPCODE_COPY_TEX_SUB_IMAGE3D,
160 OPCODE_CULL_FACE,
161 OPCODE_DEPTH_FUNC,
162 OPCODE_DEPTH_MASK,
163 OPCODE_DEPTH_RANGE,
164 OPCODE_DISABLE,
165 OPCODE_DRAW_BUFFER,
166 OPCODE_DRAW_PIXELS,
167 OPCODE_ENABLE,
168 OPCODE_EVALCOORD1,
169 OPCODE_EVALCOORD2,
170 OPCODE_EVALMESH1,
171 OPCODE_EVALMESH2,
172 OPCODE_EVALPOINT1,
173 OPCODE_EVALPOINT2,
174 OPCODE_FOG,
175 OPCODE_FRONT_FACE,
176 OPCODE_FRUSTUM,
177 OPCODE_HINT,
178 OPCODE_HINT_PGI,
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_HINT_PGI] = 3;
567 InstSize[OPCODE_HISTOGRAM] = 5;
568 InstSize[OPCODE_INDEX_MASK] = 2;
569 InstSize[OPCODE_INIT_NAMES] = 1;
570 InstSize[OPCODE_LIGHT] = 7;
571 InstSize[OPCODE_LIGHT_MODEL] = 6;
572 InstSize[OPCODE_LINE_STIPPLE] = 3;
573 InstSize[OPCODE_LINE_WIDTH] = 2;
574 InstSize[OPCODE_LIST_BASE] = 2;
575 InstSize[OPCODE_LOAD_IDENTITY] = 1;
576 InstSize[OPCODE_LOAD_MATRIX] = 17;
577 InstSize[OPCODE_LOAD_NAME] = 2;
578 InstSize[OPCODE_LOGIC_OP] = 2;
579 InstSize[OPCODE_MAP1] = 7;
580 InstSize[OPCODE_MAP2] = 11;
581 InstSize[OPCODE_MAPGRID1] = 4;
582 InstSize[OPCODE_MAPGRID2] = 7;
583 InstSize[OPCODE_MATRIX_MODE] = 2;
584 InstSize[OPCODE_MIN_MAX] = 4;
585 InstSize[OPCODE_MULT_MATRIX] = 17;
586 InstSize[OPCODE_ORTHO] = 7;
587 InstSize[OPCODE_PASSTHROUGH] = 2;
588 InstSize[OPCODE_PIXEL_MAP] = 4;
589 InstSize[OPCODE_PIXEL_TRANSFER] = 3;
590 InstSize[OPCODE_PIXEL_ZOOM] = 3;
591 InstSize[OPCODE_POINT_SIZE] = 2;
592 InstSize[OPCODE_POINT_PARAMETERS] = 5;
593 InstSize[OPCODE_POLYGON_MODE] = 3;
594 InstSize[OPCODE_POLYGON_STIPPLE] = 2;
595 InstSize[OPCODE_POLYGON_OFFSET] = 3;
596 InstSize[OPCODE_POP_ATTRIB] = 1;
597 InstSize[OPCODE_POP_MATRIX] = 1;
598 InstSize[OPCODE_POP_NAME] = 1;
599 InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
600 InstSize[OPCODE_PUSH_ATTRIB] = 2;
601 InstSize[OPCODE_PUSH_MATRIX] = 1;
602 InstSize[OPCODE_PUSH_NAME] = 2;
603 InstSize[OPCODE_RASTER_POS] = 5;
604 InstSize[OPCODE_READ_BUFFER] = 2;
605 InstSize[OPCODE_RESET_HISTOGRAM] = 2;
606 InstSize[OPCODE_RESET_MIN_MAX] = 2;
607 InstSize[OPCODE_ROTATE] = 5;
608 InstSize[OPCODE_SCALE] = 4;
609 InstSize[OPCODE_SCISSOR] = 5;
610 InstSize[OPCODE_STENCIL_FUNC] = 4;
611 InstSize[OPCODE_STENCIL_MASK] = 2;
612 InstSize[OPCODE_STENCIL_OP] = 4;
613 InstSize[OPCODE_SHADE_MODEL] = 2;
614 InstSize[OPCODE_TEXENV] = 7;
615 InstSize[OPCODE_TEXGEN] = 7;
616 InstSize[OPCODE_TEXPARAMETER] = 7;
617 InstSize[OPCODE_TEX_IMAGE1D] = 9;
618 InstSize[OPCODE_TEX_IMAGE2D] = 10;
619 InstSize[OPCODE_TEX_IMAGE3D] = 11;
620 InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
621 InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
622 InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12;
623 InstSize[OPCODE_TRANSLATE] = 4;
624 InstSize[OPCODE_VIEWPORT] = 5;
625 InstSize[OPCODE_WINDOW_POS] = 5;
626 InstSize[OPCODE_CONTINUE] = 2;
627 InstSize[OPCODE_ERROR] = 3;
628 InstSize[OPCODE_END_OF_LIST] = 1;
629 /* GL_SGIX/SGIS_pixel_texture */
630 InstSize[OPCODE_PIXEL_TEXGEN_SGIX] = 2;
631 InstSize[OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS] = 3;
632 /* GL_ARB_texture_compression */
633 InstSize[OPCODE_COMPRESSED_TEX_IMAGE_1D] = 8;
634 InstSize[OPCODE_COMPRESSED_TEX_IMAGE_2D] = 9;
635 InstSize[OPCODE_COMPRESSED_TEX_IMAGE_3D] = 10;
636 InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D] = 8;
637 InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D] = 10;
638 InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D] = 12;
639 /* GL_ARB_multitexture */
640 InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
641 InstSize[OPCODE_CLIENT_ACTIVE_TEXTURE] = 2;
642 }
643 init_flag = 1;
644 }
645
646
647 /*
648 * Allocate space for a display list instruction.
649 * Input: opcode - type of instruction
650 * argcount - size in bytes of data required.
651 * Return: pointer to the usable data area (not including the internal
652 * opcode).
653 */
654 void *
655 _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
656 {
657 Node *n, *newblock;
658 GLuint count = 1 + (sz + sizeof(Node) - 1) / sizeof(Node);
659
660 #ifdef DEBUG
661 if (opcode < (int) OPCODE_DRV_0) {
662 assert( (GLint) count == InstSize[opcode] );
663 }
664 #endif
665
666 if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
667 /* This block is full. Allocate a new block and chain to it */
668 n = ctx->CurrentBlock + ctx->CurrentPos;
669 n[0].opcode = OPCODE_CONTINUE;
670 newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
671 if (!newblock) {
672 gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
673 return NULL;
674 }
675 n[1].next = (Node *) newblock;
676 ctx->CurrentBlock = newblock;
677 ctx->CurrentPos = 0;
678 }
679
680 n = ctx->CurrentBlock + ctx->CurrentPos;
681 ctx->CurrentPos += count;
682
683 n[0].opcode = (OpCode) opcode;
684
685 return (void *)&n[1];
686 }
687
688
689 /* Allow modules and drivers to get their own opcodes.
690 */
691 int
692 _mesa_alloc_opcode( GLcontext *ctx,
693 GLuint sz,
694 void (*execute)( GLcontext *, void * ),
695 void (*destroy)( GLcontext *, void * ),
696 void (*print)( GLcontext *, void * ) )
697 {
698 if (ctx->listext.nr_opcodes < GL_MAX_EXT_OPCODES) {
699 GLuint i = ctx->listext.nr_opcodes++;
700 ctx->listext.opcode[i].size = 1 + (sz + sizeof(Node) - 1)/sizeof(Node);
701 ctx->listext.opcode[i].execute = execute;
702 ctx->listext.opcode[i].destroy = destroy;
703 ctx->listext.opcode[i].print = print;
704 return i + OPCODE_DRV_0;
705 }
706 return -1;
707 }
708
709
710
711 /* Mimic the old behaviour of alloc_instruction:
712 * - sz is in units of sizeof(Node)
713 * - return value a pointer to sizeof(Node) before the actual
714 * usable data area.
715 */
716 #define ALLOC_INSTRUCTION(ctx, opcode, sz) \
717 ((Node *)_mesa_alloc_instruction(ctx, opcode, sz*sizeof(Node)) - 1)
718
719
720
721 /*
722 * Display List compilation functions
723 */
724 static void save_Accum( GLenum op, GLfloat value )
725 {
726 GET_CURRENT_CONTEXT(ctx);
727 Node *n;
728 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
729 n = ALLOC_INSTRUCTION( ctx, OPCODE_ACCUM, 2 );
730 if (n) {
731 n[1].e = op;
732 n[2].f = value;
733 }
734 if (ctx->ExecuteFlag) {
735 (*ctx->Exec->Accum)( op, value );
736 }
737 }
738
739
740 static void save_AlphaFunc( GLenum func, GLclampf ref )
741 {
742 GET_CURRENT_CONTEXT(ctx);
743 Node *n;
744 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
745 n = ALLOC_INSTRUCTION( ctx, OPCODE_ALPHA_FUNC, 2 );
746 if (n) {
747 n[1].e = func;
748 n[2].f = (GLfloat) ref;
749 }
750 if (ctx->ExecuteFlag) {
751 (*ctx->Exec->AlphaFunc)( func, ref );
752 }
753 }
754
755
756 static void save_BindTexture( GLenum target, GLuint texture )
757 {
758 GET_CURRENT_CONTEXT(ctx);
759 Node *n;
760 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
761 n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_TEXTURE, 2 );
762 if (n) {
763 n[1].e = target;
764 n[2].ui = texture;
765 }
766 if (ctx->ExecuteFlag) {
767 (*ctx->Exec->BindTexture)( target, texture );
768 }
769 }
770
771
772 static void save_Bitmap( GLsizei width, GLsizei height,
773 GLfloat xorig, GLfloat yorig,
774 GLfloat xmove, GLfloat ymove,
775 const GLubyte *pixels )
776 {
777 GET_CURRENT_CONTEXT(ctx);
778 GLvoid *image = _mesa_unpack_bitmap( width, height, pixels, &ctx->Unpack );
779 Node *n;
780 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
781 n = ALLOC_INSTRUCTION( ctx, OPCODE_BITMAP, 7 );
782 if (n) {
783 n[1].i = (GLint) width;
784 n[2].i = (GLint) height;
785 n[3].f = xorig;
786 n[4].f = yorig;
787 n[5].f = xmove;
788 n[6].f = ymove;
789 n[7].data = image;
790 }
791 else if (image) {
792 FREE(image);
793 }
794 if (ctx->ExecuteFlag) {
795 (*ctx->Exec->Bitmap)( width, height,
796 xorig, yorig, xmove, ymove, pixels );
797 }
798 }
799
800
801 static void save_BlendEquation( GLenum mode )
802 {
803 GET_CURRENT_CONTEXT(ctx);
804 Node *n;
805 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
806 n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION, 1 );
807 if (n) {
808 n[1].e = mode;
809 }
810 if (ctx->ExecuteFlag) {
811 (*ctx->Exec->BlendEquation)( mode );
812 }
813 }
814
815
816 static void save_BlendFunc( GLenum sfactor, GLenum dfactor )
817 {
818 GET_CURRENT_CONTEXT(ctx);
819 Node *n;
820 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
821 n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_FUNC, 2 );
822 if (n) {
823 n[1].e = sfactor;
824 n[2].e = dfactor;
825 }
826 if (ctx->ExecuteFlag) {
827 (*ctx->Exec->BlendFunc)( sfactor, dfactor );
828 }
829 }
830
831
832 static void save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
833 GLenum sfactorA, GLenum dfactorA)
834 {
835 GET_CURRENT_CONTEXT(ctx);
836 Node *n;
837 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
838 n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
839 if (n) {
840 n[1].e = sfactorRGB;
841 n[2].e = dfactorRGB;
842 n[3].e = sfactorA;
843 n[4].e = dfactorA;
844 }
845 if (ctx->ExecuteFlag) {
846 (*ctx->Exec->BlendFuncSeparateEXT)( sfactorRGB, dfactorRGB,
847 sfactorA, dfactorA);
848 }
849 }
850
851
852 static void save_BlendColor( GLfloat red, GLfloat green,
853 GLfloat blue, GLfloat alpha )
854 {
855 GET_CURRENT_CONTEXT(ctx);
856 Node *n;
857 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
858 n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_COLOR, 4 );
859 if (n) {
860 n[1].f = red;
861 n[2].f = green;
862 n[3].f = blue;
863 n[4].f = alpha;
864 }
865 if (ctx->ExecuteFlag) {
866 (*ctx->Exec->BlendColor)( red, green, blue, alpha );
867 }
868 }
869
870
871 static void save_CallList( GLuint list )
872 {
873 GET_CURRENT_CONTEXT(ctx);
874 Node *n;
875 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
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 static void save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
887 {
888 GET_CURRENT_CONTEXT(ctx);
889 GLint i;
890 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
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 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
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 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
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 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
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 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
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 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
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 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
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 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
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 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
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 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
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 /* execute immediately */
1067 (*ctx->Exec->ColorTable)( target, internalFormat, width,
1068 format, type, table );
1069 }
1070 else {
1071 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, table,
1072 &ctx->Unpack);
1073 Node *n;
1074 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1075 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE, 6 );
1076 if (n) {
1077 n[1].e = target;
1078 n[2].e = internalFormat;
1079 n[3].i = width;
1080 n[4].e = format;
1081 n[5].e = type;
1082 n[6].data = image;
1083 }
1084 else if (image) {
1085 FREE(image);
1086 }
1087 if (ctx->ExecuteFlag) {
1088 (*ctx->Exec->ColorTable)( target, internalFormat, width,
1089 format, type, table );
1090 }
1091 }
1092 }
1093
1094
1095
1096 static void
1097 save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
1098 {
1099 GET_CURRENT_CONTEXT(ctx);
1100 Node *n;
1101
1102 ASSERT_OUTSIDE_BEGIN_END(ctx, "glColorTableParameterfv");
1103 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
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_BEGIN_END(ctx, "glColorTableParameterfv");
1132 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1133
1134 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6 );
1135 if (n) {
1136 n[1].e = target;
1137 n[2].e = pname;
1138 n[3].i = params[0];
1139 if (pname == GL_COLOR_TABLE_SGI ||
1140 pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1141 pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) {
1142 n[4].i = params[1];
1143 n[5].i = params[2];
1144 n[6].i = params[3];
1145 }
1146 }
1147
1148 if (ctx->ExecuteFlag) {
1149 (*ctx->Exec->ColorTableParameteriv)( target, pname, params );
1150 }
1151 }
1152
1153
1154
1155 static void save_ColorSubTable( GLenum target, GLsizei start, GLsizei count,
1156 GLenum format, GLenum type,
1157 const GLvoid *table)
1158 {
1159 GET_CURRENT_CONTEXT(ctx);
1160 GLvoid *image = _mesa_unpack_image(count, 1, 1, format, type, table,
1161 &ctx->Unpack);
1162 Node *n;
1163 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1164 n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_SUB_TABLE, 6 );
1165 if (n) {
1166 n[1].e = target;
1167 n[2].i = start;
1168 n[3].i = count;
1169 n[4].e = format;
1170 n[5].e = type;
1171 n[6].data = image;
1172 }
1173 else if (image) {
1174 FREE(image);
1175 }
1176 if (ctx->ExecuteFlag) {
1177 (*ctx->Exec->ColorSubTable)(target, start, count, format, type, table);
1178 }
1179 }
1180
1181
1182 static void
1183 save_CopyColorSubTable(GLenum target, GLsizei start,
1184 GLint x, GLint y, GLsizei width)
1185 {
1186 GET_CURRENT_CONTEXT(ctx);
1187 Node *n;
1188
1189 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1190 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 6 );
1191 if (n) {
1192 n[1].e = target;
1193 n[2].i = start;
1194 n[3].i = x;
1195 n[4].i = y;
1196 n[5].i = width;
1197 }
1198 if (ctx->ExecuteFlag) {
1199 (*ctx->Exec->CopyColorSubTable)(target, start, x, y, width);
1200 }
1201 }
1202
1203
1204 static void
1205 save_CopyColorTable(GLenum target, GLenum internalformat,
1206 GLint x, GLint y, GLsizei width)
1207 {
1208 GET_CURRENT_CONTEXT(ctx);
1209 Node *n;
1210
1211 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1212 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_TABLE, 6 );
1213 if (n) {
1214 n[1].e = target;
1215 n[2].e = internalformat;
1216 n[3].i = x;
1217 n[4].i = y;
1218 n[5].i = width;
1219 }
1220 if (ctx->ExecuteFlag) {
1221 (*ctx->Exec->CopyColorTable)(target, internalformat, x, y, width);
1222 }
1223 }
1224
1225
1226 static void
1227 save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
1228 GLenum format, GLenum type, const GLvoid *filter)
1229 {
1230 GET_CURRENT_CONTEXT(ctx);
1231 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, filter,
1232 &ctx->Unpack);
1233 Node *n;
1234 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1235 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_1D, 6 );
1236 if (n) {
1237 n[1].e = target;
1238 n[2].e = internalFormat;
1239 n[3].i = width;
1240 n[4].e = format;
1241 n[5].e = type;
1242 n[6].data = image;
1243 }
1244 else if (image) {
1245 FREE(image);
1246 }
1247 if (ctx->ExecuteFlag) {
1248 (*ctx->Exec->ConvolutionFilter1D)( target, internalFormat, width,
1249 format, type, filter );
1250 }
1251 }
1252
1253
1254 static void
1255 save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
1256 GLsizei width, GLsizei height, GLenum format,
1257 GLenum type, const GLvoid *filter)
1258 {
1259 GET_CURRENT_CONTEXT(ctx);
1260 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, filter,
1261 &ctx->Unpack);
1262 Node *n;
1263 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1264 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_2D, 7 );
1265 if (n) {
1266 n[1].e = target;
1267 n[2].e = internalFormat;
1268 n[3].i = width;
1269 n[4].i = height;
1270 n[5].e = format;
1271 n[6].e = type;
1272 n[7].data = image;
1273 }
1274 else if (image) {
1275 FREE(image);
1276 }
1277 if (ctx->ExecuteFlag) {
1278 (*ctx->Exec->ConvolutionFilter2D)( target, internalFormat, width, height,
1279 format, type, filter );
1280 }
1281 }
1282
1283
1284 static void
1285 save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
1286 {
1287 GET_CURRENT_CONTEXT(ctx);
1288 Node *n;
1289 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1290 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3 );
1291 if (n) {
1292 n[1].e = target;
1293 n[2].e = pname;
1294 n[3].i = param;
1295 }
1296 if (ctx->ExecuteFlag) {
1297 (*ctx->Exec->ConvolutionParameteri)( target, pname, param );
1298 }
1299 }
1300
1301
1302 static void
1303 save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
1304 {
1305 GET_CURRENT_CONTEXT(ctx);
1306 Node *n;
1307 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1308 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
1309 if (n) {
1310 n[1].e = target;
1311 n[2].e = pname;
1312 n[3].i = params[0];
1313 if (pname == GL_CONVOLUTION_BORDER_COLOR ||
1314 pname == GL_CONVOLUTION_FILTER_SCALE ||
1315 pname == GL_CONVOLUTION_FILTER_BIAS) {
1316 n[4].i = params[1];
1317 n[5].i = params[2];
1318 n[6].i = params[3];
1319 }
1320 else {
1321 n[4].i = n[5].i = n[6].i = 0;
1322 }
1323 }
1324 if (ctx->ExecuteFlag) {
1325 (*ctx->Exec->ConvolutionParameteriv)( target, pname, params );
1326 }
1327 }
1328
1329
1330 static void
1331 save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
1332 {
1333 GET_CURRENT_CONTEXT(ctx);
1334 Node *n;
1335 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1336 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3 );
1337 if (n) {
1338 n[1].e = target;
1339 n[2].e = pname;
1340 n[3].f = param;
1341 }
1342 if (ctx->ExecuteFlag) {
1343 (*ctx->Exec->ConvolutionParameterf)( target, pname, param );
1344 }
1345 }
1346
1347
1348 static void
1349 save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
1350 {
1351 GET_CURRENT_CONTEXT(ctx);
1352 Node *n;
1353 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1354 n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
1355 if (n) {
1356 n[1].e = target;
1357 n[2].e = pname;
1358 n[3].f = params[0];
1359 if (pname == GL_CONVOLUTION_BORDER_COLOR ||
1360 pname == GL_CONVOLUTION_FILTER_SCALE ||
1361 pname == GL_CONVOLUTION_FILTER_BIAS) {
1362 n[4].f = params[1];
1363 n[5].f = params[2];
1364 n[6].f = params[3];
1365 }
1366 else {
1367 n[4].f = n[5].f = n[6].f = 0.0F;
1368 }
1369 }
1370 if (ctx->ExecuteFlag) {
1371 (*ctx->Exec->ConvolutionParameterfv)( target, pname, params );
1372 }
1373 }
1374
1375
1376 static void save_CopyPixels( GLint x, GLint y,
1377 GLsizei width, GLsizei height, GLenum type )
1378 {
1379 GET_CURRENT_CONTEXT(ctx);
1380 Node *n;
1381 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1382 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_PIXELS, 5 );
1383 if (n) {
1384 n[1].i = x;
1385 n[2].i = y;
1386 n[3].i = (GLint) width;
1387 n[4].i = (GLint) height;
1388 n[5].e = type;
1389 }
1390 if (ctx->ExecuteFlag) {
1391 (*ctx->Exec->CopyPixels)( x, y, width, height, type );
1392 }
1393 }
1394
1395
1396
1397 static void
1398 save_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
1399 GLint x, GLint y, GLsizei width, GLint border )
1400 {
1401 GET_CURRENT_CONTEXT(ctx);
1402 Node *n;
1403 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1404 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
1405 if (n) {
1406 n[1].e = target;
1407 n[2].i = level;
1408 n[3].e = internalformat;
1409 n[4].i = x;
1410 n[5].i = y;
1411 n[6].i = width;
1412 n[7].i = border;
1413 }
1414 if (ctx->ExecuteFlag) {
1415 (*ctx->Exec->CopyTexImage1D)( target, level, internalformat,
1416 x, y, width, border );
1417 }
1418 }
1419
1420
1421 static void
1422 save_CopyTexImage2D( GLenum target, GLint level,
1423 GLenum internalformat,
1424 GLint x, GLint y, GLsizei width,
1425 GLsizei height, GLint border )
1426 {
1427 GET_CURRENT_CONTEXT(ctx);
1428 Node *n;
1429 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1430 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
1431 if (n) {
1432 n[1].e = target;
1433 n[2].i = level;
1434 n[3].e = internalformat;
1435 n[4].i = x;
1436 n[5].i = y;
1437 n[6].i = width;
1438 n[7].i = height;
1439 n[8].i = border;
1440 }
1441 if (ctx->ExecuteFlag) {
1442 (*ctx->Exec->CopyTexImage2D)( target, level, internalformat,
1443 x, y, width, height, border );
1444 }
1445 }
1446
1447
1448
1449 static void
1450 save_CopyTexSubImage1D( GLenum target, GLint level,
1451 GLint xoffset, GLint x, GLint y,
1452 GLsizei width )
1453 {
1454 GET_CURRENT_CONTEXT(ctx);
1455 Node *n;
1456 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1457 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
1458 if (n) {
1459 n[1].e = target;
1460 n[2].i = level;
1461 n[3].i = xoffset;
1462 n[4].i = x;
1463 n[5].i = y;
1464 n[6].i = width;
1465 }
1466 if (ctx->ExecuteFlag) {
1467 (*ctx->Exec->CopyTexSubImage1D)( target, level, xoffset, x, y, width );
1468 }
1469 }
1470
1471
1472 static void
1473 save_CopyTexSubImage2D( GLenum target, GLint level,
1474 GLint xoffset, GLint yoffset,
1475 GLint x, GLint y,
1476 GLsizei width, GLint height )
1477 {
1478 GET_CURRENT_CONTEXT(ctx);
1479 Node *n;
1480 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1481 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
1482 if (n) {
1483 n[1].e = target;
1484 n[2].i = level;
1485 n[3].i = xoffset;
1486 n[4].i = yoffset;
1487 n[5].i = x;
1488 n[6].i = y;
1489 n[7].i = width;
1490 n[8].i = height;
1491 }
1492 if (ctx->ExecuteFlag) {
1493 (*ctx->Exec->CopyTexSubImage2D)( target, level, xoffset, yoffset,
1494 x, y, width, height );
1495 }
1496 }
1497
1498
1499 static void
1500 save_CopyTexSubImage3D( GLenum target, GLint level,
1501 GLint xoffset, GLint yoffset, GLint zoffset,
1502 GLint x, GLint y,
1503 GLsizei width, GLint height )
1504 {
1505 GET_CURRENT_CONTEXT(ctx);
1506 Node *n;
1507 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1508 n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
1509 if (n) {
1510 n[1].e = target;
1511 n[2].i = level;
1512 n[3].i = xoffset;
1513 n[4].i = yoffset;
1514 n[5].i = zoffset;
1515 n[6].i = x;
1516 n[7].i = y;
1517 n[8].i = width;
1518 n[9].i = height;
1519 }
1520 if (ctx->ExecuteFlag) {
1521 (*ctx->Exec->CopyTexSubImage3D)( target, level,
1522 xoffset, yoffset, zoffset,
1523 x, y, width, height );
1524 }
1525 }
1526
1527
1528 static void save_CullFace( GLenum mode )
1529 {
1530 GET_CURRENT_CONTEXT(ctx);
1531 Node *n;
1532 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1533 n = ALLOC_INSTRUCTION( ctx, OPCODE_CULL_FACE, 1 );
1534 if (n) {
1535 n[1].e = mode;
1536 }
1537 if (ctx->ExecuteFlag) {
1538 (*ctx->Exec->CullFace)( mode );
1539 }
1540 }
1541
1542
1543 static void save_DepthFunc( GLenum func )
1544 {
1545 GET_CURRENT_CONTEXT(ctx);
1546 Node *n;
1547 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1548 n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_FUNC, 1 );
1549 if (n) {
1550 n[1].e = func;
1551 }
1552 if (ctx->ExecuteFlag) {
1553 (*ctx->Exec->DepthFunc)( func );
1554 }
1555 }
1556
1557
1558 static void save_DepthMask( GLboolean mask )
1559 {
1560 GET_CURRENT_CONTEXT(ctx);
1561 Node *n;
1562 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1563 n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_MASK, 1 );
1564 if (n) {
1565 n[1].b = mask;
1566 }
1567 if (ctx->ExecuteFlag) {
1568 (*ctx->Exec->DepthMask)( mask );
1569 }
1570 }
1571
1572
1573 static void save_DepthRange( GLclampd nearval, GLclampd farval )
1574 {
1575 GET_CURRENT_CONTEXT(ctx);
1576 Node *n;
1577 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1578 n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_RANGE, 2 );
1579 if (n) {
1580 n[1].f = (GLfloat) nearval;
1581 n[2].f = (GLfloat) farval;
1582 }
1583 if (ctx->ExecuteFlag) {
1584 (*ctx->Exec->DepthRange)( nearval, farval );
1585 }
1586 }
1587
1588
1589 static void save_Disable( GLenum cap )
1590 {
1591 GET_CURRENT_CONTEXT(ctx);
1592 Node *n;
1593 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1594 n = ALLOC_INSTRUCTION( ctx, OPCODE_DISABLE, 1 );
1595 if (n) {
1596 n[1].e = cap;
1597 }
1598 if (ctx->ExecuteFlag) {
1599 (*ctx->Exec->Disable)( cap );
1600 }
1601 }
1602
1603
1604 static void save_DrawBuffer( GLenum mode )
1605 {
1606 GET_CURRENT_CONTEXT(ctx);
1607 Node *n;
1608 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1609 n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_BUFFER, 1 );
1610 if (n) {
1611 n[1].e = mode;
1612 }
1613 if (ctx->ExecuteFlag) {
1614 (*ctx->Exec->DrawBuffer)( mode );
1615 }
1616 }
1617
1618
1619 static void save_DrawPixels( GLsizei width, GLsizei height,
1620 GLenum format, GLenum type,
1621 const GLvoid *pixels )
1622 {
1623 GET_CURRENT_CONTEXT(ctx);
1624 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
1625 pixels, &ctx->Unpack);
1626 Node *n;
1627 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1628 n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_PIXELS, 5 );
1629 if (n) {
1630 n[1].i = width;
1631 n[2].i = height;
1632 n[3].e = format;
1633 n[4].e = type;
1634 n[5].data = image;
1635 }
1636 else if (image) {
1637 FREE(image);
1638 }
1639 if (ctx->ExecuteFlag) {
1640 (*ctx->Exec->DrawPixels)( width, height, format, type, pixels );
1641 }
1642 }
1643
1644
1645
1646 static void save_Enable( GLenum cap )
1647 {
1648 GET_CURRENT_CONTEXT(ctx);
1649 Node *n;
1650 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1651 n = ALLOC_INSTRUCTION( ctx, OPCODE_ENABLE, 1 );
1652 if (n) {
1653 n[1].e = cap;
1654 }
1655 if (ctx->ExecuteFlag) {
1656 (*ctx->Exec->Enable)( cap );
1657 }
1658 }
1659
1660
1661
1662 void _mesa_save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
1663 {
1664 GET_CURRENT_CONTEXT(ctx);
1665 Node *n;
1666 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1667 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVALMESH1, 3 );
1668 if (n) {
1669 n[1].e = mode;
1670 n[2].i = i1;
1671 n[3].i = i2;
1672 }
1673 if (ctx->ExecuteFlag) {
1674 (*ctx->Exec->EvalMesh1)( mode, i1, i2 );
1675 }
1676 }
1677
1678
1679 void _mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
1680 {
1681 GET_CURRENT_CONTEXT(ctx);
1682 Node *n;
1683 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1684 n = ALLOC_INSTRUCTION( ctx, OPCODE_EVALMESH2, 5 );
1685 if (n) {
1686 n[1].e = mode;
1687 n[2].i = i1;
1688 n[3].i = i2;
1689 n[4].i = j1;
1690 n[5].i = j2;
1691 }
1692 if (ctx->ExecuteFlag) {
1693 (*ctx->Exec->EvalMesh2)( mode, i1, i2, j1, j2 );
1694 }
1695 }
1696
1697
1698
1699
1700 static void save_Fogfv( GLenum pname, const GLfloat *params )
1701 {
1702 GET_CURRENT_CONTEXT(ctx);
1703 Node *n;
1704 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1705 n = ALLOC_INSTRUCTION( ctx, OPCODE_FOG, 5 );
1706 if (n) {
1707 n[1].e = pname;
1708 n[2].f = params[0];
1709 n[3].f = params[1];
1710 n[4].f = params[2];
1711 n[5].f = params[3];
1712 }
1713 if (ctx->ExecuteFlag) {
1714 (*ctx->Exec->Fogfv)( pname, params );
1715 }
1716 }
1717
1718
1719 static void save_Fogf( GLenum pname, GLfloat param )
1720 {
1721 save_Fogfv(pname, &param);
1722 }
1723
1724
1725 static void save_Fogiv(GLenum pname, const GLint *params )
1726 {
1727 GLfloat p[4];
1728 switch (pname) {
1729 case GL_FOG_MODE:
1730 case GL_FOG_DENSITY:
1731 case GL_FOG_START:
1732 case GL_FOG_END:
1733 case GL_FOG_INDEX:
1734 p[0] = (GLfloat) *params;
1735 break;
1736 case GL_FOG_COLOR:
1737 p[0] = INT_TO_FLOAT( params[0] );
1738 p[1] = INT_TO_FLOAT( params[1] );
1739 p[2] = INT_TO_FLOAT( params[2] );
1740 p[3] = INT_TO_FLOAT( params[3] );
1741 break;
1742 default:
1743 /* Error will be caught later in gl_Fogfv */
1744 ;
1745 }
1746 save_Fogfv(pname, p);
1747 }
1748
1749
1750 static void save_Fogi(GLenum pname, GLint param )
1751 {
1752 save_Fogiv(pname, &param);
1753 }
1754
1755
1756 static void save_FrontFace( GLenum mode )
1757 {
1758 GET_CURRENT_CONTEXT(ctx);
1759 Node *n;
1760 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1761 n = ALLOC_INSTRUCTION( ctx, OPCODE_FRONT_FACE, 1 );
1762 if (n) {
1763 n[1].e = mode;
1764 }
1765 if (ctx->ExecuteFlag) {
1766 (*ctx->Exec->FrontFace)( mode );
1767 }
1768 }
1769
1770
1771 static void save_Frustum( GLdouble left, GLdouble right,
1772 GLdouble bottom, GLdouble top,
1773 GLdouble nearval, GLdouble farval )
1774 {
1775 GET_CURRENT_CONTEXT(ctx);
1776 Node *n;
1777 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1778 n = ALLOC_INSTRUCTION( ctx, OPCODE_FRUSTUM, 6 );
1779 if (n) {
1780 n[1].f = left;
1781 n[2].f = right;
1782 n[3].f = bottom;
1783 n[4].f = top;
1784 n[5].f = nearval;
1785 n[6].f = farval;
1786 }
1787 if (ctx->ExecuteFlag) {
1788 (*ctx->Exec->Frustum)( left, right, bottom, top, nearval, farval );
1789 }
1790 }
1791
1792
1793 static void save_Hint( GLenum target, GLenum mode )
1794 {
1795 GET_CURRENT_CONTEXT(ctx);
1796 Node *n;
1797 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1798 n = ALLOC_INSTRUCTION( ctx, OPCODE_HINT, 2 );
1799 if (n) {
1800 n[1].e = target;
1801 n[2].e = mode;
1802 }
1803 if (ctx->ExecuteFlag) {
1804 (*ctx->Exec->Hint)( target, mode );
1805 }
1806 }
1807
1808
1809 /* GL_PGI_misc_hints*/
1810 static void save_HintPGI( GLenum target, GLint mode )
1811 {
1812 GET_CURRENT_CONTEXT(ctx);
1813 Node *n;
1814 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1815 n = ALLOC_INSTRUCTION( ctx, OPCODE_HINT_PGI, 2 );
1816 if (n) {
1817 n[1].e = target;
1818 n[2].i = mode;
1819 }
1820 if (ctx->ExecuteFlag) {
1821 (*ctx->Exec->HintPGI)( target, mode );
1822 }
1823 }
1824
1825
1826 static void
1827 save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink)
1828 {
1829 GET_CURRENT_CONTEXT(ctx);
1830 Node *n;
1831
1832 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1833 n = ALLOC_INSTRUCTION( ctx, OPCODE_HISTOGRAM, 4 );
1834 if (n) {
1835 n[1].e = target;
1836 n[2].i = width;
1837 n[3].e = internalFormat;
1838 n[4].b = sink;
1839 }
1840 if (ctx->ExecuteFlag) {
1841 (*ctx->Exec->Histogram)( target, width, internalFormat, sink );
1842 }
1843 }
1844
1845
1846 static void save_IndexMask( GLuint mask )
1847 {
1848 GET_CURRENT_CONTEXT(ctx);
1849 Node *n;
1850 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1851 n = ALLOC_INSTRUCTION( ctx, OPCODE_INDEX_MASK, 1 );
1852 if (n) {
1853 n[1].ui = mask;
1854 }
1855 if (ctx->ExecuteFlag) {
1856 (*ctx->Exec->IndexMask)( mask );
1857 }
1858 }
1859
1860
1861 static void save_InitNames( void )
1862 {
1863 GET_CURRENT_CONTEXT(ctx);
1864 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1865 (void) ALLOC_INSTRUCTION( ctx, OPCODE_INIT_NAMES, 0 );
1866 if (ctx->ExecuteFlag) {
1867 (*ctx->Exec->InitNames)();
1868 }
1869 }
1870
1871
1872 static void save_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
1873 {
1874 GET_CURRENT_CONTEXT(ctx);
1875 Node *n;
1876 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1877 n = ALLOC_INSTRUCTION( ctx, OPCODE_LIGHT, 6 );
1878 if (OPCODE_LIGHT) {
1879 GLint i, nParams;
1880 n[1].e = light;
1881 n[2].e = pname;
1882 switch (pname) {
1883 case GL_AMBIENT:
1884 nParams = 4;
1885 break;
1886 case GL_DIFFUSE:
1887 nParams = 4;
1888 break;
1889 case GL_SPECULAR:
1890 nParams = 4;
1891 break;
1892 case GL_POSITION:
1893 nParams = 4;
1894 break;
1895 case GL_SPOT_DIRECTION:
1896 nParams = 3;
1897 break;
1898 case GL_SPOT_EXPONENT:
1899 nParams = 1;
1900 break;
1901 case GL_SPOT_CUTOFF:
1902 nParams = 1;
1903 break;
1904 case GL_CONSTANT_ATTENUATION:
1905 nParams = 1;
1906 break;
1907 case GL_LINEAR_ATTENUATION:
1908 nParams = 1;
1909 break;
1910 case GL_QUADRATIC_ATTENUATION:
1911 nParams = 1;
1912 break;
1913 default:
1914 nParams = 0;
1915 }
1916 for (i = 0; i < nParams; i++) {
1917 n[3+i].f = params[i];
1918 }
1919 }
1920 if (ctx->ExecuteFlag) {
1921 (*ctx->Exec->Lightfv)( light, pname, params );
1922 }
1923 }
1924
1925
1926 static void save_Lightf( GLenum light, GLenum pname, GLfloat params )
1927 {
1928 save_Lightfv(light, pname, &params);
1929 }
1930
1931
1932 static void save_Lightiv( GLenum light, GLenum pname, const GLint *params )
1933 {
1934 GLfloat fparam[4];
1935 switch (pname) {
1936 case GL_AMBIENT:
1937 case GL_DIFFUSE:
1938 case GL_SPECULAR:
1939 fparam[0] = INT_TO_FLOAT( params[0] );
1940 fparam[1] = INT_TO_FLOAT( params[1] );
1941 fparam[2] = INT_TO_FLOAT( params[2] );
1942 fparam[3] = INT_TO_FLOAT( params[3] );
1943 break;
1944 case GL_POSITION:
1945 fparam[0] = (GLfloat) params[0];
1946 fparam[1] = (GLfloat) params[1];
1947 fparam[2] = (GLfloat) params[2];
1948 fparam[3] = (GLfloat) params[3];
1949 break;
1950 case GL_SPOT_DIRECTION:
1951 fparam[0] = (GLfloat) params[0];
1952 fparam[1] = (GLfloat) params[1];
1953 fparam[2] = (GLfloat) params[2];
1954 break;
1955 case GL_SPOT_EXPONENT:
1956 case GL_SPOT_CUTOFF:
1957 case GL_CONSTANT_ATTENUATION:
1958 case GL_LINEAR_ATTENUATION:
1959 case GL_QUADRATIC_ATTENUATION:
1960 fparam[0] = (GLfloat) params[0];
1961 break;
1962 default:
1963 /* error will be caught later in gl_Lightfv */
1964 ;
1965 }
1966 save_Lightfv( light, pname, fparam );
1967 }
1968
1969
1970 static void save_Lighti( GLenum light, GLenum pname, GLint param )
1971 {
1972 save_Lightiv( light, pname, &param );
1973 }
1974
1975
1976 static void save_LightModelfv( GLenum pname, const GLfloat *params )
1977 {
1978 GET_CURRENT_CONTEXT(ctx);
1979 Node *n;
1980 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
1981 n = ALLOC_INSTRUCTION( ctx, OPCODE_LIGHT_MODEL, 5 );
1982 if (n) {
1983 n[1].e = pname;
1984 n[2].f = params[0];
1985 n[3].f = params[1];
1986 n[4].f = params[2];
1987 n[5].f = params[3];
1988 }
1989 if (ctx->ExecuteFlag) {
1990 (*ctx->Exec->LightModelfv)( pname, params );
1991 }
1992 }
1993
1994
1995 static void save_LightModelf( GLenum pname, GLfloat param )
1996 {
1997 save_LightModelfv(pname, &param);
1998 }
1999
2000
2001 static void save_LightModeliv( GLenum pname, const GLint *params )
2002 {
2003 GLfloat fparam[4];
2004 switch (pname) {
2005 case GL_LIGHT_MODEL_AMBIENT:
2006 fparam[0] = INT_TO_FLOAT( params[0] );
2007 fparam[1] = INT_TO_FLOAT( params[1] );
2008 fparam[2] = INT_TO_FLOAT( params[2] );
2009 fparam[3] = INT_TO_FLOAT( params[3] );
2010 break;
2011 case GL_LIGHT_MODEL_LOCAL_VIEWER:
2012 case GL_LIGHT_MODEL_TWO_SIDE:
2013 case GL_LIGHT_MODEL_COLOR_CONTROL:
2014 fparam[0] = (GLfloat) params[0];
2015 break;
2016 default:
2017 /* Error will be caught later in gl_LightModelfv */
2018 ;
2019 }
2020 save_LightModelfv(pname, fparam);
2021 }
2022
2023
2024 static void save_LightModeli( GLenum pname, GLint param )
2025 {
2026 save_LightModeliv(pname, &param);
2027 }
2028
2029
2030 static void save_LineStipple( GLint factor, GLushort pattern )
2031 {
2032 GET_CURRENT_CONTEXT(ctx);
2033 Node *n;
2034 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2035 n = ALLOC_INSTRUCTION( ctx, OPCODE_LINE_STIPPLE, 2 );
2036 if (n) {
2037 n[1].i = factor;
2038 n[2].us = pattern;
2039 }
2040 if (ctx->ExecuteFlag) {
2041 (*ctx->Exec->LineStipple)( factor, pattern );
2042 }
2043 }
2044
2045
2046 static void save_LineWidth( GLfloat width )
2047 {
2048 GET_CURRENT_CONTEXT(ctx);
2049 Node *n;
2050 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2051 n = ALLOC_INSTRUCTION( ctx, OPCODE_LINE_WIDTH, 1 );
2052 if (n) {
2053 n[1].f = width;
2054 }
2055 if (ctx->ExecuteFlag) {
2056 (*ctx->Exec->LineWidth)( width );
2057 }
2058 }
2059
2060
2061 static void save_ListBase( GLuint base )
2062 {
2063 GET_CURRENT_CONTEXT(ctx);
2064 Node *n;
2065 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2066 n = ALLOC_INSTRUCTION( ctx, OPCODE_LIST_BASE, 1 );
2067 if (n) {
2068 n[1].ui = base;
2069 }
2070 if (ctx->ExecuteFlag) {
2071 (*ctx->Exec->ListBase)( base );
2072 }
2073 }
2074
2075
2076 static void save_LoadIdentity( void )
2077 {
2078 GET_CURRENT_CONTEXT(ctx);
2079 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2080 (void) ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_IDENTITY, 0 );
2081 if (ctx->ExecuteFlag) {
2082 (*ctx->Exec->LoadIdentity)();
2083 }
2084 }
2085
2086
2087 static void save_LoadMatrixf( const GLfloat *m )
2088 {
2089 GET_CURRENT_CONTEXT(ctx);
2090 Node *n;
2091 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2092 n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_MATRIX, 16 );
2093 if (n) {
2094 GLuint i;
2095 for (i=0;i<16;i++) {
2096 n[1+i].f = m[i];
2097 }
2098 }
2099 if (ctx->ExecuteFlag) {
2100 (*ctx->Exec->LoadMatrixf)( m );
2101 }
2102 }
2103
2104
2105 static void save_LoadMatrixd( const GLdouble *m )
2106 {
2107 GLfloat f[16];
2108 GLint i;
2109 for (i = 0; i < 16; i++) {
2110 f[i] = m[i];
2111 }
2112 save_LoadMatrixf(f);
2113 }
2114
2115
2116 static void save_LoadName( GLuint name )
2117 {
2118 GET_CURRENT_CONTEXT(ctx);
2119 Node *n;
2120 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2121 n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_NAME, 1 );
2122 if (n) {
2123 n[1].ui = name;
2124 }
2125 if (ctx->ExecuteFlag) {
2126 (*ctx->Exec->LoadName)( name );
2127 }
2128 }
2129
2130
2131 static void save_LogicOp( GLenum opcode )
2132 {
2133 GET_CURRENT_CONTEXT(ctx);
2134 Node *n;
2135 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2136 n = ALLOC_INSTRUCTION( ctx, OPCODE_LOGIC_OP, 1 );
2137 if (n) {
2138 n[1].e = opcode;
2139 }
2140 if (ctx->ExecuteFlag) {
2141 (*ctx->Exec->LogicOp)( opcode );
2142 }
2143 }
2144
2145
2146 static void save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
2147 GLint order, const GLdouble *points)
2148 {
2149 GET_CURRENT_CONTEXT(ctx);
2150 Node *n;
2151 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2152 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
2153 if (n) {
2154 GLfloat *pnts = gl_copy_map_points1d( target, stride, order, points );
2155 n[1].e = target;
2156 n[2].f = u1;
2157 n[3].f = u2;
2158 n[4].i = _mesa_evaluator_components(target); /* stride */
2159 n[5].i = order;
2160 n[6].data = (void *) pnts;
2161 }
2162 if (ctx->ExecuteFlag) {
2163 (*ctx->Exec->Map1d)( target, u1, u2, stride, order, points );
2164 }
2165 }
2166
2167 static void save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
2168 GLint order, const GLfloat *points)
2169 {
2170 GET_CURRENT_CONTEXT(ctx);
2171 Node *n;
2172 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2173 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
2174 if (n) {
2175 GLfloat *pnts = gl_copy_map_points1f( target, stride, order, points );
2176 n[1].e = target;
2177 n[2].f = u1;
2178 n[3].f = u2;
2179 n[4].i = _mesa_evaluator_components(target); /* stride */
2180 n[5].i = order;
2181 n[6].data = (void *) pnts;
2182 }
2183 if (ctx->ExecuteFlag) {
2184 (*ctx->Exec->Map1f)( target, u1, u2, stride, order, points );
2185 }
2186 }
2187
2188
2189 static void save_Map2d( GLenum target,
2190 GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
2191 GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
2192 const GLdouble *points )
2193 {
2194 GET_CURRENT_CONTEXT(ctx);
2195 Node *n;
2196 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2197 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
2198 if (n) {
2199 GLfloat *pnts = gl_copy_map_points2d( target, ustride, uorder,
2200 vstride, vorder, points );
2201 n[1].e = target;
2202 n[2].f = u1;
2203 n[3].f = u2;
2204 n[4].f = v1;
2205 n[5].f = v2;
2206 /* XXX verify these strides are correct */
2207 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
2208 n[7].i = _mesa_evaluator_components(target); /*vstride*/
2209 n[8].i = uorder;
2210 n[9].i = vorder;
2211 n[10].data = (void *) pnts;
2212 }
2213 if (ctx->ExecuteFlag) {
2214 (*ctx->Exec->Map2d)( target,
2215 u1, u2, ustride, uorder,
2216 v1, v2, vstride, vorder, points );
2217 }
2218 }
2219
2220
2221 static void save_Map2f( GLenum target,
2222 GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
2223 GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
2224 const GLfloat *points )
2225 {
2226 GET_CURRENT_CONTEXT(ctx);
2227 Node *n;
2228 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2229 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
2230 if (n) {
2231 GLfloat *pnts = gl_copy_map_points2f( target, ustride, uorder,
2232 vstride, vorder, points );
2233 n[1].e = target;
2234 n[2].f = u1;
2235 n[3].f = u2;
2236 n[4].f = v1;
2237 n[5].f = v2;
2238 /* XXX verify these strides are correct */
2239 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
2240 n[7].i = _mesa_evaluator_components(target); /*vstride*/
2241 n[8].i = uorder;
2242 n[9].i = vorder;
2243 n[10].data = (void *) pnts;
2244 }
2245 if (ctx->ExecuteFlag) {
2246 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
2247 v1, v2, vstride, vorder, points );
2248 }
2249 }
2250
2251
2252 static void save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
2253 {
2254 GET_CURRENT_CONTEXT(ctx);
2255 Node *n;
2256 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2257 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAPGRID1, 3 );
2258 if (n) {
2259 n[1].i = un;
2260 n[2].f = u1;
2261 n[3].f = u2;
2262 }
2263 if (ctx->ExecuteFlag) {
2264 (*ctx->Exec->MapGrid1f)( un, u1, u2 );
2265 }
2266 }
2267
2268
2269 static void save_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
2270 {
2271 save_MapGrid1f(un, u1, u2);
2272 }
2273
2274
2275 static void save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
2276 GLint vn, GLfloat v1, GLfloat v2 )
2277 {
2278 GET_CURRENT_CONTEXT(ctx);
2279 Node *n;
2280 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2281 n = ALLOC_INSTRUCTION( ctx, OPCODE_MAPGRID2, 6 );
2282 if (n) {
2283 n[1].i = un;
2284 n[2].f = u1;
2285 n[3].f = u2;
2286 n[4].i = vn;
2287 n[5].f = v1;
2288 n[6].f = v2;
2289 }
2290 if (ctx->ExecuteFlag) {
2291 (*ctx->Exec->MapGrid2f)( un, u1, u2, vn, v1, v2 );
2292 }
2293 }
2294
2295
2296
2297 static void save_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
2298 GLint vn, GLdouble v1, GLdouble v2 )
2299 {
2300 save_MapGrid2f(un, u1, u2, vn, v1, v2);
2301 }
2302
2303
2304 static void save_MatrixMode( GLenum mode )
2305 {
2306 GET_CURRENT_CONTEXT(ctx);
2307 Node *n;
2308 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2309 n = ALLOC_INSTRUCTION( ctx, OPCODE_MATRIX_MODE, 1 );
2310 if (n) {
2311 n[1].e = mode;
2312 }
2313 if (ctx->ExecuteFlag) {
2314 (*ctx->Exec->MatrixMode)( mode );
2315 }
2316 }
2317
2318
2319 static void
2320 save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
2321 {
2322 GET_CURRENT_CONTEXT(ctx);
2323 Node *n;
2324
2325 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2326 n = ALLOC_INSTRUCTION( ctx, OPCODE_MIN_MAX, 3 );
2327 if (n) {
2328 n[1].e = target;
2329 n[2].e = internalFormat;
2330 n[3].b = sink;
2331 }
2332 if (ctx->ExecuteFlag) {
2333 (*ctx->Exec->Minmax)( target, internalFormat, sink );
2334 }
2335 }
2336
2337
2338 static void save_MultMatrixf( const GLfloat *m )
2339 {
2340 GET_CURRENT_CONTEXT(ctx);
2341 Node *n;
2342 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2343 n = ALLOC_INSTRUCTION( ctx, OPCODE_MULT_MATRIX, 16 );
2344 if (n) {
2345 GLuint i;
2346 for (i=0;i<16;i++) {
2347 n[1+i].f = m[i];
2348 }
2349 }
2350 if (ctx->ExecuteFlag) {
2351 (*ctx->Exec->MultMatrixf)( m );
2352 }
2353 }
2354
2355
2356 static void save_MultMatrixd( const GLdouble *m )
2357 {
2358 GLfloat f[16];
2359 GLint i;
2360 for (i = 0; i < 16; i++) {
2361 f[i] = m[i];
2362 }
2363 save_MultMatrixf(f);
2364 }
2365
2366
2367 static void save_NewList( GLuint list, GLenum mode )
2368 {
2369 GET_CURRENT_CONTEXT(ctx);
2370 /* It's an error to call this function while building a display list */
2371 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
2372 (void) list;
2373 (void) mode;
2374 }
2375
2376
2377
2378 static void save_Ortho( GLdouble left, GLdouble right,
2379 GLdouble bottom, GLdouble top,
2380 GLdouble nearval, GLdouble farval )
2381 {
2382 GET_CURRENT_CONTEXT(ctx);
2383 Node *n;
2384 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2385 n = ALLOC_INSTRUCTION( ctx, OPCODE_ORTHO, 6 );
2386 if (n) {
2387 n[1].f = left;
2388 n[2].f = right;
2389 n[3].f = bottom;
2390 n[4].f = top;
2391 n[5].f = nearval;
2392 n[6].f = farval;
2393 }
2394 if (ctx->ExecuteFlag) {
2395 (*ctx->Exec->Ortho)( left, right, bottom, top, nearval, farval );
2396 }
2397 }
2398
2399
2400 static void save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
2401 {
2402 GET_CURRENT_CONTEXT(ctx);
2403 Node *n;
2404 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2405 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_MAP, 3 );
2406 if (n) {
2407 n[1].e = map;
2408 n[2].i = mapsize;
2409 n[3].data = (void *) MALLOC( mapsize * sizeof(GLfloat) );
2410 MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
2411 }
2412 if (ctx->ExecuteFlag) {
2413 (*ctx->Exec->PixelMapfv)( map, mapsize, values );
2414 }
2415 }
2416
2417
2418 static void save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
2419 {
2420 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2421 GLint i;
2422 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
2423 for (i=0;i<mapsize;i++) {
2424 fvalues[i] = (GLfloat) values[i];
2425 }
2426 }
2427 else {
2428 for (i=0;i<mapsize;i++) {
2429 fvalues[i] = UINT_TO_FLOAT( values[i] );
2430 }
2431 }
2432 save_PixelMapfv(map, mapsize, fvalues);
2433 }
2434
2435
2436 static void save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
2437 {
2438 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2439 GLint i;
2440 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
2441 for (i=0;i<mapsize;i++) {
2442 fvalues[i] = (GLfloat) values[i];
2443 }
2444 }
2445 else {
2446 for (i=0;i<mapsize;i++) {
2447 fvalues[i] = USHORT_TO_FLOAT( values[i] );
2448 }
2449 }
2450 save_PixelMapfv(map, mapsize, fvalues);
2451 }
2452
2453
2454 static void save_PixelTransferf( GLenum pname, GLfloat param )
2455 {
2456 GET_CURRENT_CONTEXT(ctx);
2457 Node *n;
2458 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2459 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TRANSFER, 2 );
2460 if (n) {
2461 n[1].e = pname;
2462 n[2].f = param;
2463 }
2464 if (ctx->ExecuteFlag) {
2465 (*ctx->Exec->PixelTransferf)( pname, param );
2466 }
2467 }
2468
2469
2470 static void save_PixelTransferi( GLenum pname, GLint param )
2471 {
2472 save_PixelTransferf( pname, (GLfloat) param );
2473 }
2474
2475
2476 static void save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
2477 {
2478 GET_CURRENT_CONTEXT(ctx);
2479 Node *n;
2480 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2481 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_ZOOM, 2 );
2482 if (n) {
2483 n[1].f = xfactor;
2484 n[2].f = yfactor;
2485 }
2486 if (ctx->ExecuteFlag) {
2487 (*ctx->Exec->PixelZoom)( xfactor, yfactor );
2488 }
2489 }
2490
2491
2492 static void save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
2493 {
2494 GET_CURRENT_CONTEXT(ctx);
2495 Node *n;
2496 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2497 n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_PARAMETERS, 4 );
2498 if (n) {
2499 n[1].e = pname;
2500 n[2].f = params[0];
2501 n[3].f = params[1];
2502 n[4].f = params[2];
2503 }
2504 if (ctx->ExecuteFlag) {
2505 (*ctx->Exec->PointParameterfvEXT)( pname, params );
2506 }
2507 }
2508
2509
2510 static void save_PointParameterfEXT( GLenum pname, GLfloat param )
2511 {
2512 save_PointParameterfvEXT(pname, &param);
2513 }
2514
2515
2516 static void save_PointSize( GLfloat size )
2517 {
2518 GET_CURRENT_CONTEXT(ctx);
2519 Node *n;
2520 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2521 n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_SIZE, 1 );
2522 if (n) {
2523 n[1].f = size;
2524 }
2525 if (ctx->ExecuteFlag) {
2526 (*ctx->Exec->PointSize)( size );
2527 }
2528 }
2529
2530
2531 static void save_PolygonMode( GLenum face, GLenum mode )
2532 {
2533 GET_CURRENT_CONTEXT(ctx);
2534 Node *n;
2535 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2536 n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_MODE, 2 );
2537 if (n) {
2538 n[1].e = face;
2539 n[2].e = mode;
2540 }
2541 if (ctx->ExecuteFlag) {
2542 (*ctx->Exec->PolygonMode)( face, mode );
2543 }
2544 }
2545
2546
2547 /*
2548 * Polygon stipple must have been upacked already!
2549 */
2550 static void save_PolygonStipple( const GLubyte *pattern )
2551 {
2552 GET_CURRENT_CONTEXT(ctx);
2553 Node *n;
2554 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2555 n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_STIPPLE, 1 );
2556 if (n) {
2557 void *data;
2558 n[1].data = MALLOC( 32 * 4 );
2559 data = n[1].data; /* This needed for Acorn compiler */
2560 MEMCPY( data, pattern, 32 * 4 );
2561 }
2562 if (ctx->ExecuteFlag) {
2563 (*ctx->Exec->PolygonStipple)( (GLubyte*) pattern );
2564 }
2565 }
2566
2567
2568 static void save_PolygonOffset( GLfloat factor, GLfloat units )
2569 {
2570 GET_CURRENT_CONTEXT(ctx);
2571 Node *n;
2572 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2573 n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_OFFSET, 2 );
2574 if (n) {
2575 n[1].f = factor;
2576 n[2].f = units;
2577 }
2578 if (ctx->ExecuteFlag) {
2579 (*ctx->Exec->PolygonOffset)( factor, units );
2580 }
2581 }
2582
2583
2584 static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
2585 {
2586 GET_CURRENT_CONTEXT(ctx);
2587 save_PolygonOffset(factor, ctx->Visual.DepthMaxF * bias);
2588 }
2589
2590
2591 static void save_PopAttrib( void )
2592 {
2593 GET_CURRENT_CONTEXT(ctx);
2594 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2595 (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_ATTRIB, 0 );
2596 if (ctx->ExecuteFlag) {
2597 (*ctx->Exec->PopAttrib)();
2598 }
2599 }
2600
2601
2602 static void save_PopMatrix( void )
2603 {
2604 GET_CURRENT_CONTEXT(ctx);
2605 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2606 (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_MATRIX, 0 );
2607 if (ctx->ExecuteFlag) {
2608 (*ctx->Exec->PopMatrix)();
2609 }
2610 }
2611
2612
2613 static void save_PopName( void )
2614 {
2615 GET_CURRENT_CONTEXT(ctx);
2616 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2617 (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_NAME, 0 );
2618 if (ctx->ExecuteFlag) {
2619 (*ctx->Exec->PopName)();
2620 }
2621 }
2622
2623
2624 static void save_PrioritizeTextures( GLsizei num, const GLuint *textures,
2625 const GLclampf *priorities )
2626 {
2627 GET_CURRENT_CONTEXT(ctx);
2628 GLint i;
2629 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2630
2631 for (i=0;i<num;i++) {
2632 Node *n;
2633 n = ALLOC_INSTRUCTION( ctx, OPCODE_PRIORITIZE_TEXTURE, 2 );
2634 if (n) {
2635 n[1].ui = textures[i];
2636 n[2].f = priorities[i];
2637 }
2638 }
2639 if (ctx->ExecuteFlag) {
2640 (*ctx->Exec->PrioritizeTextures)( num, textures, priorities );
2641 }
2642 }
2643
2644
2645 static void save_PushAttrib( GLbitfield mask )
2646 {
2647 GET_CURRENT_CONTEXT(ctx);
2648 Node *n;
2649 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2650 n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_ATTRIB, 1 );
2651 if (n) {
2652 n[1].bf = mask;
2653 }
2654 if (ctx->ExecuteFlag) {
2655 (*ctx->Exec->PushAttrib)( mask );
2656 }
2657 }
2658
2659
2660 static void save_PushMatrix( void )
2661 {
2662 GET_CURRENT_CONTEXT(ctx);
2663 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2664 (void) ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_MATRIX, 0 );
2665 if (ctx->ExecuteFlag) {
2666 (*ctx->Exec->PushMatrix)();
2667 }
2668 }
2669
2670
2671 static void save_PushName( GLuint name )
2672 {
2673 GET_CURRENT_CONTEXT(ctx);
2674 Node *n;
2675 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2676 n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_NAME, 1 );
2677 if (n) {
2678 n[1].ui = name;
2679 }
2680 if (ctx->ExecuteFlag) {
2681 (*ctx->Exec->PushName)( name );
2682 }
2683 }
2684
2685
2686 static void save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
2687 {
2688 GET_CURRENT_CONTEXT(ctx);
2689 Node *n;
2690 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2691 n = ALLOC_INSTRUCTION( ctx, OPCODE_RASTER_POS, 4 );
2692 if (n) {
2693 n[1].f = x;
2694 n[2].f = y;
2695 n[3].f = z;
2696 n[4].f = w;
2697 }
2698 if (ctx->ExecuteFlag) {
2699 (*ctx->Exec->RasterPos4f)( x, y, z, w );
2700 }
2701 }
2702
2703 static void save_RasterPos2d(GLdouble x, GLdouble y)
2704 {
2705 save_RasterPos4f(x, y, 0.0F, 1.0F);
2706 }
2707
2708 static void save_RasterPos2f(GLfloat x, GLfloat y)
2709 {
2710 save_RasterPos4f(x, y, 0.0F, 1.0F);
2711 }
2712
2713 static void save_RasterPos2i(GLint x, GLint y)
2714 {
2715 save_RasterPos4f(x, y, 0.0F, 1.0F);
2716 }
2717
2718 static void save_RasterPos2s(GLshort x, GLshort y)
2719 {
2720 save_RasterPos4f(x, y, 0.0F, 1.0F);
2721 }
2722
2723 static void save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
2724 {
2725 save_RasterPos4f(x, y, z, 1.0F);
2726 }
2727
2728 static void save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
2729 {
2730 save_RasterPos4f(x, y, z, 1.0F);
2731 }
2732
2733 static void save_RasterPos3i(GLint x, GLint y, GLint z)
2734 {
2735 save_RasterPos4f(x, y, z, 1.0F);
2736 }
2737
2738 static void save_RasterPos3s(GLshort x, GLshort y, GLshort z)
2739 {
2740 save_RasterPos4f(x, y, z, 1.0F);
2741 }
2742
2743 static void save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
2744 {
2745 save_RasterPos4f(x, y, z, w);
2746 }
2747
2748 static void save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
2749 {
2750 save_RasterPos4f(x, y, z, w);
2751 }
2752
2753 static void save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
2754 {
2755 save_RasterPos4f(x, y, z, w);
2756 }
2757
2758 static void save_RasterPos2dv(const GLdouble *v)
2759 {
2760 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2761 }
2762
2763 static void save_RasterPos2fv(const GLfloat *v)
2764 {
2765 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2766 }
2767
2768 static void save_RasterPos2iv(const GLint *v)
2769 {
2770 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2771 }
2772
2773 static void save_RasterPos2sv(const GLshort *v)
2774 {
2775 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2776 }
2777
2778 static void save_RasterPos3dv(const GLdouble *v)
2779 {
2780 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2781 }
2782
2783 static void save_RasterPos3fv(const GLfloat *v)
2784 {
2785 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2786 }
2787
2788 static void save_RasterPos3iv(const GLint *v)
2789 {
2790 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2791 }
2792
2793 static void save_RasterPos3sv(const GLshort *v)
2794 {
2795 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2796 }
2797
2798 static void save_RasterPos4dv(const GLdouble *v)
2799 {
2800 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2801 }
2802
2803 static void save_RasterPos4fv(const GLfloat *v)
2804 {
2805 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2806 }
2807
2808 static void save_RasterPos4iv(const GLint *v)
2809 {
2810 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2811 }
2812
2813 static void save_RasterPos4sv(const GLshort *v)
2814 {
2815 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2816 }
2817
2818
2819 static void save_PassThrough( GLfloat token )
2820 {
2821 GET_CURRENT_CONTEXT(ctx);
2822 Node *n;
2823 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2824 n = ALLOC_INSTRUCTION( ctx, OPCODE_PASSTHROUGH, 1 );
2825 if (n) {
2826 n[1].f = token;
2827 }
2828 if (ctx->ExecuteFlag) {
2829 (*ctx->Exec->PassThrough)( token );
2830 }
2831 }
2832
2833
2834 static void save_ReadBuffer( GLenum mode )
2835 {
2836 GET_CURRENT_CONTEXT(ctx);
2837 Node *n;
2838 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2839 n = ALLOC_INSTRUCTION( ctx, OPCODE_READ_BUFFER, 1 );
2840 if (n) {
2841 n[1].e = mode;
2842 }
2843 if (ctx->ExecuteFlag) {
2844 (*ctx->Exec->ReadBuffer)( mode );
2845 }
2846 }
2847
2848
2849 static void
2850 save_ResetHistogram(GLenum target)
2851 {
2852 GET_CURRENT_CONTEXT(ctx);
2853 Node *n;
2854 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2855 n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_HISTOGRAM, 1 );
2856 if (n) {
2857 n[1].e = target;
2858 }
2859 if (ctx->ExecuteFlag) {
2860 (*ctx->Exec->ResetHistogram)( target );
2861 }
2862 }
2863
2864
2865 static void
2866 save_ResetMinmax(GLenum target)
2867 {
2868 GET_CURRENT_CONTEXT(ctx);
2869 Node *n;
2870 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2871 n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_MIN_MAX, 1 );
2872 if (n) {
2873 n[1].e = target;
2874 }
2875 if (ctx->ExecuteFlag) {
2876 (*ctx->Exec->ResetMinmax)( target );
2877 }
2878 }
2879
2880
2881 static void save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
2882 {
2883 GET_CURRENT_CONTEXT(ctx);
2884 Node *n;
2885 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2886 n = ALLOC_INSTRUCTION( ctx, OPCODE_ROTATE, 4 );
2887 if (n) {
2888 n[1].f = angle;
2889 n[2].f = x;
2890 n[3].f = y;
2891 n[4].f = z;
2892 }
2893 if (ctx->ExecuteFlag) {
2894 (*ctx->Exec->Rotatef)( angle, x, y, z );
2895 }
2896 }
2897
2898
2899 static void save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
2900 {
2901 save_Rotatef(angle, x, y, z);
2902 }
2903
2904
2905 static void save_Scalef( GLfloat x, GLfloat y, GLfloat z )
2906 {
2907 GET_CURRENT_CONTEXT(ctx);
2908 Node *n;
2909 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2910 n = ALLOC_INSTRUCTION( ctx, OPCODE_SCALE, 3 );
2911 if (n) {
2912 n[1].f = x;
2913 n[2].f = y;
2914 n[3].f = z;
2915 }
2916 if (ctx->ExecuteFlag) {
2917 (*ctx->Exec->Scalef)( x, y, z );
2918 }
2919 }
2920
2921
2922 static void save_Scaled( GLdouble x, GLdouble y, GLdouble z )
2923 {
2924 save_Scalef(x, y, z);
2925 }
2926
2927
2928 static void save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
2929 {
2930 GET_CURRENT_CONTEXT(ctx);
2931 Node *n;
2932 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2933 n = ALLOC_INSTRUCTION( ctx, OPCODE_SCISSOR, 4 );
2934 if (n) {
2935 n[1].i = x;
2936 n[2].i = y;
2937 n[3].i = width;
2938 n[4].i = height;
2939 }
2940 if (ctx->ExecuteFlag) {
2941 (*ctx->Exec->Scissor)( x, y, width, height );
2942 }
2943 }
2944
2945
2946 static void save_ShadeModel( GLenum mode )
2947 {
2948 GET_CURRENT_CONTEXT(ctx);
2949 Node *n;
2950 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2951 n = ALLOC_INSTRUCTION( ctx, OPCODE_SHADE_MODEL, 1 );
2952 if (n) {
2953 n[1].e = mode;
2954 }
2955 if (ctx->ExecuteFlag) {
2956 (*ctx->Exec->ShadeModel)( mode );
2957 }
2958 }
2959
2960
2961 static void save_StencilFunc( GLenum func, GLint ref, GLuint mask )
2962 {
2963 GET_CURRENT_CONTEXT(ctx);
2964 Node *n;
2965 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2966 n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_FUNC, 3 );
2967 if (n) {
2968 n[1].e = func;
2969 n[2].i = ref;
2970 n[3].ui = mask;
2971 }
2972 if (ctx->ExecuteFlag) {
2973 (*ctx->Exec->StencilFunc)( func, ref, mask );
2974 }
2975 }
2976
2977
2978 static void save_StencilMask( GLuint mask )
2979 {
2980 GET_CURRENT_CONTEXT(ctx);
2981 Node *n;
2982 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2983 n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_MASK, 1 );
2984 if (n) {
2985 n[1].ui = mask;
2986 }
2987 if (ctx->ExecuteFlag) {
2988 (*ctx->Exec->StencilMask)( mask );
2989 }
2990 }
2991
2992
2993 static void save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
2994 {
2995 GET_CURRENT_CONTEXT(ctx);
2996 Node *n;
2997 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
2998 n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_OP, 3 );
2999 if (n) {
3000 n[1].e = fail;
3001 n[2].e = zfail;
3002 n[3].e = zpass;
3003 }
3004 if (ctx->ExecuteFlag) {
3005 (*ctx->Exec->StencilOp)( fail, zfail, zpass );
3006 }
3007 }
3008
3009
3010 static void save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
3011 {
3012 GET_CURRENT_CONTEXT(ctx);
3013 Node *n;
3014 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3015 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXENV, 6 );
3016 if (n) {
3017 n[1].e = target;
3018 n[2].e = pname;
3019 n[3].f = params[0];
3020 n[4].f = params[1];
3021 n[5].f = params[2];
3022 n[6].f = params[3];
3023 }
3024 if (ctx->ExecuteFlag) {
3025 (*ctx->Exec->TexEnvfv)( target, pname, params );
3026 }
3027 }
3028
3029
3030 static void save_TexEnvf( GLenum target, GLenum pname, GLfloat param )
3031 {
3032 save_TexEnvfv( target, pname, &param );
3033 }
3034
3035
3036 static void save_TexEnvi( GLenum target, GLenum pname, GLint param )
3037 {
3038 GLfloat p[4];
3039 p[0] = (GLfloat) param;
3040 p[1] = p[2] = p[3] = 0.0;
3041 save_TexEnvfv( target, pname, p );
3042 }
3043
3044
3045 static void save_TexEnviv( GLenum target, GLenum pname, const GLint *param )
3046 {
3047 GLfloat p[4];
3048 p[0] = INT_TO_FLOAT( param[0] );
3049 p[1] = INT_TO_FLOAT( param[1] );
3050 p[2] = INT_TO_FLOAT( param[2] );
3051 p[3] = INT_TO_FLOAT( param[3] );
3052 save_TexEnvfv( target, pname, p );
3053 }
3054
3055
3056 static void save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
3057 {
3058 GET_CURRENT_CONTEXT(ctx);
3059 Node *n;
3060 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3061 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXGEN, 6 );
3062 if (n) {
3063 n[1].e = coord;
3064 n[2].e = pname;
3065 n[3].f = params[0];
3066 n[4].f = params[1];
3067 n[5].f = params[2];
3068 n[6].f = params[3];
3069 }
3070 if (ctx->ExecuteFlag) {
3071 (*ctx->Exec->TexGenfv)( coord, pname, params );
3072 }
3073 }
3074
3075
3076 static void save_TexGeniv(GLenum coord, GLenum pname, const GLint *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_TexGend(GLenum coord, GLenum pname, GLdouble param )
3088 {
3089 GLfloat p = (GLfloat) param;
3090 save_TexGenfv( coord, pname, &p );
3091 }
3092
3093
3094 static void save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
3095 {
3096 GLfloat p[4];
3097 p[0] = params[0];
3098 p[1] = params[1];
3099 p[2] = params[2];
3100 p[3] = params[3];
3101 save_TexGenfv( coord, pname, p );
3102 }
3103
3104
3105 static void save_TexGenf( GLenum coord, GLenum pname, GLfloat param )
3106 {
3107 save_TexGenfv(coord, pname, &param);
3108 }
3109
3110
3111 static void save_TexGeni( GLenum coord, GLenum pname, GLint param )
3112 {
3113 save_TexGeniv( coord, pname, &param );
3114 }
3115
3116
3117 static void save_TexParameterfv( GLenum target,
3118 GLenum pname, const GLfloat *params )
3119 {
3120 GET_CURRENT_CONTEXT(ctx);
3121 Node *n;
3122 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3123 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXPARAMETER, 6 );
3124 if (n) {
3125 n[1].e = target;
3126 n[2].e = pname;
3127 n[3].f = params[0];
3128 n[4].f = params[1];
3129 n[5].f = params[2];
3130 n[6].f = params[3];
3131 }
3132 if (ctx->ExecuteFlag) {
3133 (*ctx->Exec->TexParameterfv)( target, pname, params );
3134 }
3135 }
3136
3137
3138 static void save_TexParameterf( GLenum target, GLenum pname, GLfloat param )
3139 {
3140 save_TexParameterfv(target, pname, &param);
3141 }
3142
3143
3144 static void save_TexParameteri( GLenum target, GLenum pname, const GLint param )
3145 {
3146 GLfloat fparam[4];
3147 fparam[0] = (GLfloat) param;
3148 fparam[1] = fparam[2] = fparam[3] = 0.0;
3149 save_TexParameterfv(target, pname, fparam);
3150 }
3151
3152
3153 static void save_TexParameteriv( GLenum target, GLenum pname, const GLint *params )
3154 {
3155 GLfloat fparam[4];
3156 fparam[0] = (GLfloat) params[0];
3157 fparam[1] = fparam[2] = fparam[3] = 0.0;
3158 save_TexParameterfv(target, pname, fparam);
3159 }
3160
3161
3162 static void save_TexImage1D( GLenum target,
3163 GLint level, GLint components,
3164 GLsizei width, GLint border,
3165 GLenum format, GLenum type,
3166 const GLvoid *pixels )
3167 {
3168 GET_CURRENT_CONTEXT(ctx);
3169 if (target == GL_PROXY_TEXTURE_1D) {
3170 /* don't compile, execute immediately */
3171 (*ctx->Exec->TexImage1D)( target, level, components, width,
3172 border, format, type, pixels );
3173 }
3174 else {
3175 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
3176 pixels, &ctx->Unpack);
3177 Node *n;
3178 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3179 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE1D, 8 );
3180 if (n) {
3181 n[1].e = target;
3182 n[2].i = level;
3183 n[3].i = components;
3184 n[4].i = (GLint) width;
3185 n[5].i = border;
3186 n[6].e = format;
3187 n[7].e = type;
3188 n[8].data = image;
3189 }
3190 else if (image) {
3191 FREE(image);
3192 }
3193 if (ctx->ExecuteFlag) {
3194 (*ctx->Exec->TexImage1D)( target, level, components, width,
3195 border, format, type, pixels );
3196 }
3197 }
3198 }
3199
3200
3201 static void save_TexImage2D( GLenum target,
3202 GLint level, GLint components,
3203 GLsizei width, GLsizei height, GLint border,
3204 GLenum format, GLenum type,
3205 const GLvoid *pixels)
3206 {
3207 GET_CURRENT_CONTEXT(ctx);
3208 if (target == GL_PROXY_TEXTURE_2D) {
3209 /* don't compile, execute immediately */
3210 (*ctx->Exec->TexImage2D)( target, level, components, width,
3211 height, border, format, type, pixels );
3212 }
3213 else {
3214 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
3215 pixels, &ctx->Unpack);
3216 Node *n;
3217 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3218 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE2D, 9 );
3219 if (n) {
3220 n[1].e = target;
3221 n[2].i = level;
3222 n[3].i = components;
3223 n[4].i = (GLint) width;
3224 n[5].i = (GLint) height;
3225 n[6].i = border;
3226 n[7].e = format;
3227 n[8].e = type;
3228 n[9].data = image;
3229 }
3230 else if (image) {
3231 FREE(image);
3232 }
3233 if (ctx->ExecuteFlag) {
3234 (*ctx->Exec->TexImage2D)( target, level, components, width,
3235 height, border, format, type, pixels );
3236 }
3237 }
3238 }
3239
3240
3241 static void save_TexImage3D( GLenum target,
3242 GLint level, GLint internalFormat,
3243 GLsizei width, GLsizei height, GLsizei depth,
3244 GLint border,
3245 GLenum format, GLenum type,
3246 const GLvoid *pixels )
3247 {
3248 GET_CURRENT_CONTEXT(ctx);
3249 if (target == GL_PROXY_TEXTURE_3D) {
3250 /* don't compile, execute immediately */
3251 (*ctx->Exec->TexImage3D)( target, level, internalFormat, width,
3252 height, depth, border, format, type, pixels );
3253 }
3254 else {
3255 Node *n;
3256 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
3257 pixels, &ctx->Unpack);
3258 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3259 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE3D, 10 );
3260 if (n) {
3261 n[1].e = target;
3262 n[2].i = level;
3263 n[3].i = internalFormat;
3264 n[4].i = (GLint) width;
3265 n[5].i = (GLint) height;
3266 n[6].i = (GLint) depth;
3267 n[7].i = border;
3268 n[8].e = format;
3269 n[9].e = type;
3270 n[10].data = image;
3271 }
3272 else if (image) {
3273 FREE(image);
3274 }
3275 if (ctx->ExecuteFlag) {
3276 (*ctx->Exec->TexImage3D)( target, level, internalFormat, width,
3277 height, depth, border, format, type, pixels );
3278 }
3279 }
3280 }
3281
3282
3283 static void save_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
3284 GLsizei width, GLenum format, GLenum type,
3285 const GLvoid *pixels )
3286 {
3287 GET_CURRENT_CONTEXT(ctx);
3288 Node *n;
3289 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
3290 pixels, &ctx->Unpack);
3291 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3292 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
3293 if (n) {
3294 n[1].e = target;
3295 n[2].i = level;
3296 n[3].i = xoffset;
3297 n[4].i = (GLint) width;
3298 n[5].e = format;
3299 n[6].e = type;
3300 n[7].data = image;
3301 }
3302 else if (image) {
3303 FREE(image);
3304 }
3305 if (ctx->ExecuteFlag) {
3306 (*ctx->Exec->TexSubImage1D)( target, level, xoffset, width,
3307 format, type, pixels );
3308 }
3309 }
3310
3311
3312 static void save_TexSubImage2D( GLenum target, GLint level,
3313 GLint xoffset, GLint yoffset,
3314 GLsizei width, GLsizei height,
3315 GLenum format, GLenum type,
3316 const GLvoid *pixels )
3317 {
3318 GET_CURRENT_CONTEXT(ctx);
3319 Node *n;
3320 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
3321 pixels, &ctx->Unpack);
3322 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3323 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
3324 if (n) {
3325 n[1].e = target;
3326 n[2].i = level;
3327 n[3].i = xoffset;
3328 n[4].i = yoffset;
3329 n[5].i = (GLint) width;
3330 n[6].i = (GLint) height;
3331 n[7].e = format;
3332 n[8].e = type;
3333 n[9].data = image;
3334 }
3335 else if (image) {
3336 FREE(image);
3337 }
3338 if (ctx->ExecuteFlag) {
3339 (*ctx->Exec->TexSubImage2D)( target, level, xoffset, yoffset,
3340 width, height, format, type, pixels );
3341 }
3342 }
3343
3344
3345 static void save_TexSubImage3D( GLenum target, GLint level,
3346 GLint xoffset, GLint yoffset,GLint zoffset,
3347 GLsizei width, GLsizei height, GLsizei depth,
3348 GLenum format, GLenum type,
3349 const GLvoid *pixels )
3350 {
3351 GET_CURRENT_CONTEXT(ctx);
3352 Node *n;
3353 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
3354 pixels, &ctx->Unpack);
3355 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3356 n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
3357 if (n) {
3358 n[1].e = target;
3359 n[2].i = level;
3360 n[3].i = xoffset;
3361 n[4].i = yoffset;
3362 n[5].i = zoffset;
3363 n[6].i = (GLint) width;
3364 n[7].i = (GLint) height;
3365 n[8].i = (GLint) depth;
3366 n[9].e = format;
3367 n[10].e = type;
3368 n[11].data = image;
3369 }
3370 else if (image) {
3371 FREE(image);
3372 }
3373 if (ctx->ExecuteFlag) {
3374 (*ctx->Exec->TexSubImage3D)( target, level,
3375 xoffset, yoffset, zoffset,
3376 width, height, depth, format, type, pixels );
3377 }
3378 }
3379
3380
3381 static void save_Translatef( GLfloat x, GLfloat y, GLfloat z )
3382 {
3383 GET_CURRENT_CONTEXT(ctx);
3384 Node *n;
3385 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3386 n = ALLOC_INSTRUCTION( ctx, OPCODE_TRANSLATE, 3 );
3387 if (n) {
3388 n[1].f = x;
3389 n[2].f = y;
3390 n[3].f = z;
3391 }
3392 if (ctx->ExecuteFlag) {
3393 (*ctx->Exec->Translatef)( x, y, z );
3394 }
3395 }
3396
3397
3398 static void save_Translated( GLdouble x, GLdouble y, GLdouble z )
3399 {
3400 save_Translatef(x, y, z);
3401 }
3402
3403
3404
3405 static void save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
3406 {
3407 GET_CURRENT_CONTEXT(ctx);
3408 Node *n;
3409 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3410 n = ALLOC_INSTRUCTION( ctx, OPCODE_VIEWPORT, 4 );
3411 if (n) {
3412 n[1].i = x;
3413 n[2].i = y;
3414 n[3].i = (GLint) width;
3415 n[4].i = (GLint) height;
3416 }
3417 if (ctx->ExecuteFlag) {
3418 (*ctx->Exec->Viewport)( x, y, width, height );
3419 }
3420 }
3421
3422
3423 static void save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
3424 {
3425 GET_CURRENT_CONTEXT(ctx);
3426 Node *n;
3427 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3428 n = ALLOC_INSTRUCTION( ctx, OPCODE_WINDOW_POS, 4 );
3429 if (n) {
3430 n[1].f = x;
3431 n[2].f = y;
3432 n[3].f = z;
3433 n[4].f = w;
3434 }
3435 if (ctx->ExecuteFlag) {
3436 (*ctx->Exec->WindowPos4fMESA)( x, y, z, w );
3437 }
3438 }
3439
3440 static void save_WindowPos2dMESA(GLdouble x, GLdouble y)
3441 {
3442 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3443 }
3444
3445 static void save_WindowPos2fMESA(GLfloat x, GLfloat y)
3446 {
3447 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3448 }
3449
3450 static void save_WindowPos2iMESA(GLint x, GLint y)
3451 {
3452 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3453 }
3454
3455 static void save_WindowPos2sMESA(GLshort x, GLshort y)
3456 {
3457 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3458 }
3459
3460 static void save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
3461 {
3462 save_WindowPos4fMESA(x, y, z, 1.0F);
3463 }
3464
3465 static void save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
3466 {
3467 save_WindowPos4fMESA(x, y, z, 1.0F);
3468 }
3469
3470 static void save_WindowPos3iMESA(GLint x, GLint y, GLint z)
3471 {
3472 save_WindowPos4fMESA(x, y, z, 1.0F);
3473 }
3474
3475 static void save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
3476 {
3477 save_WindowPos4fMESA(x, y, z, 1.0F);
3478 }
3479
3480 static void save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3481 {
3482 save_WindowPos4fMESA(x, y, z, w);
3483 }
3484
3485 static void save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
3486 {
3487 save_WindowPos4fMESA(x, y, z, w);
3488 }
3489
3490 static void save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
3491 {
3492 save_WindowPos4fMESA(x, y, z, w);
3493 }
3494
3495 static void save_WindowPos2dvMESA(const GLdouble *v)
3496 {
3497 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3498 }
3499
3500 static void save_WindowPos2fvMESA(const GLfloat *v)
3501 {
3502 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3503 }
3504
3505 static void save_WindowPos2ivMESA(const GLint *v)
3506 {
3507 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3508 }
3509
3510 static void save_WindowPos2svMESA(const GLshort *v)
3511 {
3512 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3513 }
3514
3515 static void save_WindowPos3dvMESA(const GLdouble *v)
3516 {
3517 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3518 }
3519
3520 static void save_WindowPos3fvMESA(const GLfloat *v)
3521 {
3522 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3523 }
3524
3525 static void save_WindowPos3ivMESA(const GLint *v)
3526 {
3527 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3528 }
3529
3530 static void save_WindowPos3svMESA(const GLshort *v)
3531 {
3532 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3533 }
3534
3535 static void save_WindowPos4dvMESA(const GLdouble *v)
3536 {
3537 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3538 }
3539
3540 static void save_WindowPos4fvMESA(const GLfloat *v)
3541 {
3542 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3543 }
3544
3545 static void save_WindowPos4ivMESA(const GLint *v)
3546 {
3547 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3548 }
3549
3550 static void save_WindowPos4svMESA(const GLshort *v)
3551 {
3552 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3553 }
3554
3555
3556
3557 /* GL_ARB_multitexture */
3558 static void save_ActiveTextureARB( GLenum target )
3559 {
3560 GET_CURRENT_CONTEXT(ctx);
3561 Node *n;
3562 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3563 n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
3564 if (n) {
3565 n[1].e = target;
3566 }
3567 if (ctx->ExecuteFlag) {
3568 (*ctx->Exec->ActiveTextureARB)( target );
3569 }
3570 }
3571
3572
3573 /* GL_ARB_multitexture */
3574 static void save_ClientActiveTextureARB( GLenum target )
3575 {
3576 GET_CURRENT_CONTEXT(ctx);
3577 Node *n;
3578 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3579 n = ALLOC_INSTRUCTION( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 );
3580 if (n) {
3581 n[1].e = target;
3582 }
3583 if (ctx->ExecuteFlag) {
3584 (*ctx->Exec->ClientActiveTextureARB)( target );
3585 }
3586 }
3587
3588
3589
3590 /* GL_ARB_transpose_matrix */
3591
3592 static void save_LoadTransposeMatrixdARB( const GLdouble m[16] )
3593 {
3594 GLfloat tm[16];
3595 _math_transposefd(tm, m);
3596 save_LoadMatrixf(tm);
3597 }
3598
3599
3600 static void save_LoadTransposeMatrixfARB( const GLfloat m[16] )
3601 {
3602 GLfloat tm[16];
3603 _math_transposef(tm, m);
3604 save_LoadMatrixf(tm);
3605 }
3606
3607
3608 static void save_MultTransposeMatrixdARB( const GLdouble m[16] )
3609 {
3610 GLfloat tm[16];
3611 _math_transposefd(tm, m);
3612 save_MultMatrixf(tm);
3613 }
3614
3615
3616 static void save_MultTransposeMatrixfARB( const GLfloat m[16] )
3617 {
3618 GLfloat tm[16];
3619 _math_transposef(tm, m);
3620 save_MultMatrixf(tm);
3621 }
3622
3623
3624 static void save_PixelTexGenSGIX(GLenum mode)
3625 {
3626 GET_CURRENT_CONTEXT(ctx);
3627 Node *n;
3628 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3629 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_SGIX, 1 );
3630 if (n) {
3631 n[1].e = mode;
3632 }
3633 if (ctx->ExecuteFlag) {
3634 (*ctx->Exec->PixelTexGenSGIX)( mode );
3635 }
3636 }
3637
3638
3639 /* GL_ARB_texture_compression */
3640 static void
3641 save_CompressedTexImage1DARB(GLenum target, GLint level,
3642 GLenum internalFormat, GLsizei width,
3643 GLint border, GLsizei imageSize,
3644 const GLvoid *data)
3645 {
3646 GET_CURRENT_CONTEXT(ctx);
3647 if (target == GL_PROXY_TEXTURE_1D) {
3648 /* don't compile, execute immediately */
3649 (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat,
3650 width, border, imageSize, data);
3651 }
3652 else {
3653 Node *n;
3654 GLvoid *image;
3655 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3656 /* make copy of image */
3657 image = MALLOC(imageSize);
3658 if (!image) {
3659 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
3660 return;
3661 }
3662 MEMCPY(image, data, imageSize);
3663 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 8 );
3664 if (n) {
3665 n[1].e = target;
3666 n[2].i = level;
3667 n[3].e = internalFormat;
3668 n[4].i = (GLint) width;
3669 n[5].i = border;
3670 n[6].i = imageSize;
3671 n[7].data = image;
3672 }
3673 else if (image) {
3674 FREE(image);
3675 }
3676 if (ctx->ExecuteFlag) {
3677 (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat,
3678 width, border, imageSize, data);
3679 }
3680 }
3681 }
3682
3683
3684 static void
3685 save_CompressedTexImage2DARB(GLenum target, GLint level,
3686 GLenum internalFormat, GLsizei width,
3687 GLsizei height, GLint border, GLsizei imageSize,
3688 const GLvoid *data)
3689 {
3690 GET_CURRENT_CONTEXT(ctx);
3691 if (target == GL_PROXY_TEXTURE_2D) {
3692 /* don't compile, execute immediately */
3693 (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat,
3694 width, height, border, imageSize, data);
3695 }
3696 else {
3697 Node *n;
3698 GLvoid *image;
3699 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3700 /* make copy of image */
3701 image = MALLOC(imageSize);
3702 if (!image) {
3703 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
3704 return;
3705 }
3706 MEMCPY(image, data, imageSize);
3707 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 9 );
3708 if (n) {
3709 n[1].e = target;
3710 n[2].i = level;
3711 n[3].e = internalFormat;
3712 n[4].i = (GLint) width;
3713 n[5].i = (GLint) height;
3714 n[6].i = border;
3715 n[7].i = imageSize;
3716 n[8].data = image;
3717 }
3718 else if (image) {
3719 FREE(image);
3720 }
3721 if (ctx->ExecuteFlag) {
3722 (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat,
3723 width, height, border, imageSize, data);
3724 }
3725 }
3726 }
3727
3728
3729 static void
3730 save_CompressedTexImage3DARB(GLenum target, GLint level,
3731 GLenum internalFormat, GLsizei width,
3732 GLsizei height, GLsizei depth, GLint border,
3733 GLsizei imageSize, const GLvoid *data)
3734 {
3735 GET_CURRENT_CONTEXT(ctx);
3736 if (target == GL_PROXY_TEXTURE_3D) {
3737 /* don't compile, execute immediately */
3738 (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat,
3739 width, height, depth, border, imageSize, data);
3740 }
3741 else {
3742 Node *n;
3743 GLvoid *image;
3744 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3745 /* make copy of image */
3746 image = MALLOC(imageSize);
3747 if (!image) {
3748 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
3749 return;
3750 }
3751 MEMCPY(image, data, imageSize);
3752 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 10 );
3753 if (n) {
3754 n[1].e = target;
3755 n[2].i = level;
3756 n[3].e = internalFormat;
3757 n[4].i = (GLint) width;
3758 n[5].i = (GLint) height;
3759 n[6].i = (GLint) depth;
3760 n[7].i = border;
3761 n[8].i = imageSize;
3762 n[9].data = image;
3763 }
3764 else if (image) {
3765 FREE(image);
3766 }
3767 if (ctx->ExecuteFlag) {
3768 (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat,
3769 width, height, depth, border, imageSize, data);
3770 }
3771 }
3772 }
3773
3774
3775 static void
3776 save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
3777 GLsizei width, GLenum format,
3778 GLsizei imageSize, const GLvoid *data)
3779 {
3780 Node *n;
3781 GLvoid *image;
3782
3783 GET_CURRENT_CONTEXT(ctx);
3784 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3785
3786 /* make copy of image */
3787 image = MALLOC(imageSize);
3788 if (!image) {
3789 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
3790 return;
3791 }
3792 MEMCPY(image, data, imageSize);
3793 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 8 );
3794 if (n) {
3795 n[1].e = target;
3796 n[2].i = level;
3797 n[3].i = xoffset;
3798 n[4].i = (GLint) width;
3799 n[5].e = format;
3800 n[6].i = imageSize;
3801 n[7].data = image;
3802 }
3803 else if (image) {
3804 FREE(image);
3805 }
3806 if (ctx->ExecuteFlag) {
3807 (*ctx->Exec->CompressedTexSubImage1DARB)(target, level, xoffset,
3808 width, format, imageSize, data);
3809 }
3810 }
3811
3812
3813 static void
3814 save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
3815 GLint yoffset, GLsizei width, GLsizei height,
3816 GLenum format, GLsizei imageSize,
3817 const GLvoid *data)
3818 {
3819 Node *n;
3820 GLvoid *image;
3821
3822 GET_CURRENT_CONTEXT(ctx);
3823 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3824
3825 /* make copy of image */
3826 image = MALLOC(imageSize);
3827 if (!image) {
3828 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
3829 return;
3830 }
3831 MEMCPY(image, data, imageSize);
3832 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 10 );
3833 if (n) {
3834 n[1].e = target;
3835 n[2].i = level;
3836 n[3].i = xoffset;
3837 n[4].i = yoffset;
3838 n[5].i = (GLint) width;
3839 n[6].i = (GLint) height;
3840 n[7].e = format;
3841 n[8].i = imageSize;
3842 n[9].data = image;
3843 }
3844 else if (image) {
3845 FREE(image);
3846 }
3847 if (ctx->ExecuteFlag) {
3848 (*ctx->Exec->CompressedTexSubImage2DARB)(target, level, xoffset, yoffset,
3849 width, height, format, imageSize, data);
3850 }
3851 }
3852
3853
3854 static void
3855 save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
3856 GLint yoffset, GLint zoffset, GLsizei width,
3857 GLsizei height, GLsizei depth, GLenum format,
3858 GLsizei imageSize, const GLvoid *data)
3859 {
3860 Node *n;
3861 GLvoid *image;
3862
3863 GET_CURRENT_CONTEXT(ctx);
3864 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3865
3866 /* make copy of image */
3867 image = MALLOC(imageSize);
3868 if (!image) {
3869 gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
3870 return;
3871 }
3872 MEMCPY(image, data, imageSize);
3873 n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 12 );
3874 if (n) {
3875 n[1].e = target;
3876 n[2].i = level;
3877 n[3].i = xoffset;
3878 n[4].i = yoffset;
3879 n[5].i = zoffset;
3880 n[6].i = (GLint) width;
3881 n[7].i = (GLint) height;
3882 n[8].i = (GLint) depth;
3883 n[9].e = format;
3884 n[10].i = imageSize;
3885 n[11].data = image;
3886 }
3887 else if (image) {
3888 FREE(image);
3889 }
3890 if (ctx->ExecuteFlag) {
3891 (*ctx->Exec->CompressedTexSubImage3DARB)(target, level, xoffset, yoffset,
3892 zoffset, width, height, depth, format, imageSize, data);
3893 }
3894 }
3895
3896
3897 /* GL_SGIS_pixel_texture */
3898
3899 static void save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
3900 {
3901 GET_CURRENT_CONTEXT(ctx);
3902 Node *n;
3903 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
3904 n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, 2 );
3905 if (n) {
3906 n[1].e = target;
3907 n[2].i = value;
3908 }
3909 if (ctx->ExecuteFlag) {
3910 (*ctx->Exec->PixelTexGenParameteriSGIS)( target, value );
3911 }
3912 }
3913
3914
3915 static void save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
3916 {
3917 save_PixelTexGenParameteriSGIS(target, (GLint) value);
3918 }
3919
3920
3921 static void save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
3922 {
3923 save_PixelTexGenParameteriSGIS(target, *value);
3924 }
3925
3926
3927 static void save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
3928 {
3929 save_PixelTexGenParameteriSGIS(target, (GLint) *value);
3930 }
3931
3932
3933 /* KW: Compile commands
3934 *
3935 * Will appear in the list before the vertex buffer containing the
3936 * command that provoked the error. I don't see this as a problem.
3937 */
3938 void gl_save_error( GLcontext *ctx, GLenum error, const char *s )
3939 {
3940 Node *n;
3941 n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
3942 if (n) {
3943 n[1].e = error;
3944 n[2].data = (void *) s;
3945 }
3946 /* execute already done */
3947 }
3948
3949
3950 static GLboolean
3951 islist(GLcontext *ctx, GLuint list)
3952 {
3953 if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
3954 return GL_TRUE;
3955 }
3956 else {
3957 return GL_FALSE;
3958 }
3959 }
3960
3961
3962
3963 /**********************************************************************/
3964 /* Display list execution */
3965 /**********************************************************************/
3966
3967
3968 /*
3969 * Execute a display list. Note that the ListBase offset must have already
3970 * been added before calling this function. I.e. the list argument is
3971 * the absolute list number, not relative to ListBase.
3972 * Input: list - display list number
3973 */
3974 static void execute_list( GLcontext *ctx, GLuint list )
3975 {
3976 Node *n;
3977 GLboolean done;
3978
3979 if (!islist(ctx,list))
3980 return;
3981
3982 /* mesa_print_display_list( list ); */
3983
3984 ctx->CallDepth++;
3985
3986 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
3987
3988 done = GL_FALSE;
3989 while (!done) {
3990 OpCode opcode = n[0].opcode;
3991 int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
3992
3993 if (i >= 0 && i < ctx->listext.nr_opcodes) {
3994 ctx->listext.opcode[i].execute(ctx, &n[1]);
3995 n += ctx->listext.opcode[i].size;
3996 }
3997 else {
3998 switch (opcode) {
3999 case OPCODE_ERROR:
4000 gl_error( ctx, n[1].e, (const char *) n[2].data );
4001 break;
4002 case OPCODE_ACCUM:
4003 (*ctx->Exec->Accum)( n[1].e, n[2].f );
4004 break;
4005 case OPCODE_ALPHA_FUNC:
4006 (*ctx->Exec->AlphaFunc)( n[1].e, n[2].f );
4007 break;
4008 case OPCODE_BIND_TEXTURE:
4009 (*ctx->Exec->BindTexture)( n[1].e, n[2].ui );
4010 break;
4011 case OPCODE_BITMAP:
4012 {
4013 struct gl_pixelstore_attrib save = ctx->Unpack;
4014 ctx->Unpack = _mesa_native_packing;
4015 (*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
4016 n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
4017 ctx->Unpack = save; /* restore */
4018 }
4019 break;
4020 case OPCODE_BLEND_COLOR:
4021 (*ctx->Exec->BlendColor)( n[1].f, n[2].f, n[3].f, n[4].f );
4022 break;
4023 case OPCODE_BLEND_EQUATION:
4024 (*ctx->Exec->BlendEquation)( n[1].e );
4025 break;
4026 case OPCODE_BLEND_FUNC:
4027 (*ctx->Exec->BlendFunc)( n[1].e, n[2].e );
4028 break;
4029 case OPCODE_BLEND_FUNC_SEPARATE:
4030 (*ctx->Exec->BlendFuncSeparateEXT)(n[1].e, n[2].e, n[3].e, n[4].e);
4031 break;
4032 case OPCODE_CALL_LIST:
4033 /* Generated by glCallList(), don't add ListBase */
4034 if (ctx->CallDepth<MAX_LIST_NESTING) {
4035 execute_list( ctx, n[1].ui );
4036 }
4037 break;
4038 case OPCODE_CALL_LIST_OFFSET:
4039 /* Generated by glCallLists() so we must add ListBase */
4040 if (ctx->CallDepth<MAX_LIST_NESTING) {
4041 execute_list( ctx, ctx->List.ListBase + n[1].ui );
4042 }
4043 break;
4044 case OPCODE_CLEAR:
4045 (*ctx->Exec->Clear)( n[1].bf );
4046 break;
4047 case OPCODE_CLEAR_COLOR:
4048 (*ctx->Exec->ClearColor)( n[1].f, n[2].f, n[3].f, n[4].f );
4049 break;
4050 case OPCODE_CLEAR_ACCUM:
4051 (*ctx->Exec->ClearAccum)( n[1].f, n[2].f, n[3].f, n[4].f );
4052 break;
4053 case OPCODE_CLEAR_DEPTH:
4054 (*ctx->Exec->ClearDepth)( (GLclampd) n[1].f );
4055 break;
4056 case OPCODE_CLEAR_INDEX:
4057 (*ctx->Exec->ClearIndex)( n[1].ui );
4058 break;
4059 case OPCODE_CLEAR_STENCIL:
4060 (*ctx->Exec->ClearStencil)( n[1].i );
4061 break;
4062 case OPCODE_CLIP_PLANE:
4063 {
4064 GLdouble eq[4];
4065 eq[0] = n[2].f;
4066 eq[1] = n[3].f;
4067 eq[2] = n[4].f;
4068 eq[3] = n[5].f;
4069 (*ctx->Exec->ClipPlane)( n[1].e, eq );
4070 }
4071 break;
4072 case OPCODE_COLOR_MASK:
4073 (*ctx->Exec->ColorMask)( n[1].b, n[2].b, n[3].b, n[4].b );
4074 break;
4075 case OPCODE_COLOR_MATERIAL:
4076 (*ctx->Exec->ColorMaterial)( n[1].e, n[2].e );
4077 break;
4078 case OPCODE_COLOR_TABLE:
4079 {
4080 struct gl_pixelstore_attrib save = ctx->Unpack;
4081 ctx->Unpack = _mesa_native_packing;
4082 (*ctx->Exec->ColorTable)( n[1].e, n[2].e, n[3].i, n[4].e,
4083 n[5].e, n[6].data );
4084 ctx->Unpack = save; /* restore */
4085 }
4086 break;
4087 case OPCODE_COLOR_TABLE_PARAMETER_FV:
4088 {
4089 GLfloat params[4];
4090 params[0] = n[3].f;
4091 params[1] = n[4].f;
4092 params[2] = n[5].f;
4093 params[3] = n[6].f;
4094 (*ctx->Exec->ColorTableParameterfv)( n[1].e, n[2].e, params );
4095 }
4096 break;
4097 case OPCODE_COLOR_TABLE_PARAMETER_IV:
4098 {
4099 GLint params[4];
4100 params[0] = n[3].i;
4101 params[1] = n[4].i;
4102 params[2] = n[5].i;
4103 params[3] = n[6].i;
4104 (*ctx->Exec->ColorTableParameteriv)( n[1].e, n[2].e, params );
4105 }
4106 break;
4107 case OPCODE_COLOR_SUB_TABLE:
4108 {
4109 struct gl_pixelstore_attrib save = ctx->Unpack;
4110 ctx->Unpack = _mesa_native_packing;
4111 (*ctx->Exec->ColorSubTable)( n[1].e, n[2].i, n[3].i,
4112 n[4].e, n[5].e, n[6].data );
4113 ctx->Unpack = save; /* restore */
4114 }
4115 break;
4116 case OPCODE_CONVOLUTION_FILTER_1D:
4117 {
4118 struct gl_pixelstore_attrib save = ctx->Unpack;
4119 ctx->Unpack = _mesa_native_packing;
4120 (*ctx->Exec->ConvolutionFilter1D)( n[1].e, n[2].i, n[3].i,
4121 n[4].e, n[5].e, n[6].data );
4122 ctx->Unpack = save; /* restore */
4123 }
4124 break;
4125 case OPCODE_CONVOLUTION_FILTER_2D:
4126 {
4127 struct gl_pixelstore_attrib save = ctx->Unpack;
4128 ctx->Unpack = _mesa_native_packing;
4129 (*ctx->Exec->ConvolutionFilter2D)( n[1].e, n[2].i, n[3].i,
4130 n[4].i, n[5].e, n[6].e, n[7].data );
4131 ctx->Unpack = save; /* restore */
4132 }
4133 break;
4134 case OPCODE_CONVOLUTION_PARAMETER_I:
4135 (*ctx->Exec->ConvolutionParameteri)( n[1].e, n[2].e, n[3].i );
4136 break;
4137 case OPCODE_CONVOLUTION_PARAMETER_IV:
4138 {
4139 GLint params[4];
4140 params[0] = n[3].i;
4141 params[1] = n[4].i;
4142 params[2] = n[5].i;
4143 params[3] = n[6].i;
4144 (*ctx->Exec->ConvolutionParameteriv)( n[1].e, n[2].e, params );
4145 }
4146 break;
4147 case OPCODE_CONVOLUTION_PARAMETER_F:
4148 (*ctx->Exec->ConvolutionParameterf)( n[1].e, n[2].e, n[3].f );
4149 break;
4150 case OPCODE_CONVOLUTION_PARAMETER_FV:
4151 {
4152 GLfloat params[4];
4153 params[0] = n[3].f;
4154 params[1] = n[4].f;
4155 params[2] = n[5].f;
4156 params[3] = n[6].f;
4157 (*ctx->Exec->ConvolutionParameterfv)( n[1].e, n[2].e, params );
4158 }
4159 break;
4160 case OPCODE_COPY_COLOR_SUB_TABLE:
4161 (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i,
4162 n[3].i, n[4].i, n[5].i );
4163 break;
4164 case OPCODE_COPY_COLOR_TABLE:
4165 (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i,
4166 n[3].i, n[4].i, n[5].i );
4167 break;
4168 case OPCODE_COPY_PIXELS:
4169 (*ctx->Exec->CopyPixels)( n[1].i, n[2].i,
4170 (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
4171 break;
4172 case OPCODE_COPY_TEX_IMAGE1D:
4173 (*ctx->Exec->CopyTexImage1D)( n[1].e, n[2].i, n[3].e, n[4].i,
4174 n[5].i, n[6].i, n[7].i );
4175 break;
4176 case OPCODE_COPY_TEX_IMAGE2D:
4177 (*ctx->Exec->CopyTexImage2D)( n[1].e, n[2].i, n[3].e, n[4].i,
4178 n[5].i, n[6].i, n[7].i, n[8].i );
4179 break;
4180 case OPCODE_COPY_TEX_SUB_IMAGE1D:
4181 (*ctx->Exec->CopyTexSubImage1D)( n[1].e, n[2].i, n[3].i,
4182 n[4].i, n[5].i, n[6].i );
4183 break;
4184 case OPCODE_COPY_TEX_SUB_IMAGE2D:
4185 (*ctx->Exec->CopyTexSubImage2D)( n[1].e, n[2].i, n[3].i,
4186 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i );
4187 break;
4188 case OPCODE_COPY_TEX_SUB_IMAGE3D:
4189 (*ctx->Exec->CopyTexSubImage3D)( n[1].e, n[2].i, n[3].i,
4190 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i , n[9].i);
4191 break;
4192 case OPCODE_CULL_FACE:
4193 (*ctx->Exec->CullFace)( n[1].e );
4194 break;
4195 case OPCODE_DEPTH_FUNC:
4196 (*ctx->Exec->DepthFunc)( n[1].e );
4197 break;
4198 case OPCODE_DEPTH_MASK:
4199 (*ctx->Exec->DepthMask)( n[1].b );
4200 break;
4201 case OPCODE_DEPTH_RANGE:
4202 (*ctx->Exec->DepthRange)( (GLclampd) n[1].f, (GLclampd) n[2].f );
4203 break;
4204 case OPCODE_DISABLE:
4205 (*ctx->Exec->Disable)( n[1].e );
4206 break;
4207 case OPCODE_DRAW_BUFFER:
4208 (*ctx->Exec->DrawBuffer)( n[1].e );
4209 break;
4210 case OPCODE_DRAW_PIXELS:
4211 {
4212 struct gl_pixelstore_attrib save = ctx->Unpack;
4213 ctx->Unpack = _mesa_native_packing;
4214 (*ctx->Exec->DrawPixels)( n[1].i, n[2].i, n[3].e, n[4].e,
4215 n[5].data );
4216 ctx->Unpack = save; /* restore */
4217 }
4218 break;
4219 case OPCODE_ENABLE:
4220 (*ctx->Exec->Enable)( n[1].e );
4221 break;
4222 case OPCODE_EVALMESH1:
4223 (*ctx->Exec->EvalMesh1)( n[1].e, n[2].i, n[3].i );
4224 break;
4225 case OPCODE_EVALMESH2:
4226 (*ctx->Exec->EvalMesh2)( n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
4227 break;
4228 case OPCODE_FOG:
4229 {
4230 GLfloat p[4];
4231 p[0] = n[2].f;
4232 p[1] = n[3].f;
4233 p[2] = n[4].f;
4234 p[3] = n[5].f;
4235 (*ctx->Exec->Fogfv)( n[1].e, p );
4236 }
4237 break;
4238 case OPCODE_FRONT_FACE:
4239 (*ctx->Exec->FrontFace)( n[1].e );
4240 break;
4241 case OPCODE_FRUSTUM:
4242 (*ctx->Exec->Frustum)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
4243 break;
4244 case OPCODE_HINT:
4245 (*ctx->Exec->Hint)( n[1].e, n[2].e );
4246 break;
4247 case OPCODE_HINT_PGI:
4248 (*ctx->Exec->HintPGI)( n[1].e, n[2].i );
4249 break;
4250 case OPCODE_HISTOGRAM:
4251 (*ctx->Exec->Histogram)( n[1].e, n[2].i, n[3].e, n[4].b );
4252 break;
4253 case OPCODE_INDEX_MASK:
4254 (*ctx->Exec->IndexMask)( n[1].ui );
4255 break;
4256 case OPCODE_INIT_NAMES:
4257 (*ctx->Exec->InitNames)();
4258 break;
4259 case OPCODE_LIGHT:
4260 {
4261 GLfloat p[4];
4262 p[0] = n[3].f;
4263 p[1] = n[4].f;
4264 p[2] = n[5].f;
4265 p[3] = n[6].f;
4266 (*ctx->Exec->Lightfv)( n[1].e, n[2].e, p );
4267 }
4268 break;
4269 case OPCODE_LIGHT_MODEL:
4270 {
4271 GLfloat p[4];
4272 p[0] = n[2].f;
4273 p[1] = n[3].f;
4274 p[2] = n[4].f;
4275 p[3] = n[5].f;
4276 (*ctx->Exec->LightModelfv)( n[1].e, p );
4277 }
4278 break;
4279 case OPCODE_LINE_STIPPLE:
4280 (*ctx->Exec->LineStipple)( n[1].i, n[2].us );
4281 break;
4282 case OPCODE_LINE_WIDTH:
4283 (*ctx->Exec->LineWidth)( n[1].f );
4284 break;
4285 case OPCODE_LIST_BASE:
4286 (*ctx->Exec->ListBase)( n[1].ui );
4287 break;
4288 case OPCODE_LOAD_IDENTITY:
4289 (*ctx->Exec->LoadIdentity)();
4290 break;
4291 case OPCODE_LOAD_MATRIX:
4292 if (sizeof(Node)==sizeof(GLfloat)) {
4293 (*ctx->Exec->LoadMatrixf)( &n[1].f );
4294 }
4295 else {
4296 GLfloat m[16];
4297 GLuint i;
4298 for (i=0;i<16;i++) {
4299 m[i] = n[1+i].f;
4300 }
4301 (*ctx->Exec->LoadMatrixf)( m );
4302 }
4303 break;
4304 case OPCODE_LOAD_NAME:
4305 (*ctx->Exec->LoadName)( n[1].ui );
4306 break;
4307 case OPCODE_LOGIC_OP:
4308 (*ctx->Exec->LogicOp)( n[1].e );
4309 break;
4310 case OPCODE_MAP1:
4311 {
4312 GLenum target = n[1].e;
4313 GLint ustride = _mesa_evaluator_components(target);
4314 GLint uorder = n[5].i;
4315 GLfloat u1 = n[2].f;
4316 GLfloat u2 = n[3].f;
4317 (*ctx->Exec->Map1f)( target, u1, u2, ustride, uorder,
4318 (GLfloat *) n[6].data );
4319 }
4320 break;
4321 case OPCODE_MAP2:
4322 {
4323 GLenum target = n[1].e;
4324 GLfloat u1 = n[2].f;
4325 GLfloat u2 = n[3].f;
4326 GLfloat v1 = n[4].f;
4327 GLfloat v2 = n[5].f;
4328 GLint ustride = n[6].i;
4329 GLint vstride = n[7].i;
4330 GLint uorder = n[8].i;
4331 GLint vorder = n[9].i;
4332 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
4333 v1, v2, vstride, vorder,
4334 (GLfloat *) n[10].data );
4335 }
4336 break;
4337 case OPCODE_MAPGRID1:
4338 (*ctx->Exec->MapGrid1f)( n[1].i, n[2].f, n[3].f );
4339 break;
4340 case OPCODE_MAPGRID2:
4341 (*ctx->Exec->MapGrid2f)( n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
4342 break;
4343 case OPCODE_MATRIX_MODE:
4344 (*ctx->Exec->MatrixMode)( n[1].e );
4345 break;
4346 case OPCODE_MIN_MAX:
4347 (*ctx->Exec->Minmax)(n[1].e, n[2].e, n[3].b);
4348 break;
4349 case OPCODE_MULT_MATRIX:
4350 if (sizeof(Node)==sizeof(GLfloat)) {
4351 (*ctx->Exec->MultMatrixf)( &n[1].f );
4352 }
4353 else {
4354 GLfloat m[16];
4355 GLuint i;
4356 for (i=0;i<16;i++) {
4357 m[i] = n[1+i].f;
4358 }
4359 (*ctx->Exec->MultMatrixf)( m );
4360 }
4361 break;
4362 case OPCODE_ORTHO:
4363 (*ctx->Exec->Ortho)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
4364 break;
4365 case OPCODE_PASSTHROUGH:
4366 (*ctx->Exec->PassThrough)( n[1].f );
4367 break;
4368 case OPCODE_PIXEL_MAP:
4369 (*ctx->Exec->PixelMapfv)( n[1].e, n[2].i, (GLfloat *) n[3].data );
4370 break;
4371 case OPCODE_PIXEL_TRANSFER:
4372 (*ctx->Exec->PixelTransferf)( n[1].e, n[2].f );
4373 break;
4374 case OPCODE_PIXEL_ZOOM:
4375 (*ctx->Exec->PixelZoom)( n[1].f, n[2].f );
4376 break;
4377 case OPCODE_POINT_SIZE:
4378 (*ctx->Exec->PointSize)( n[1].f );
4379 break;
4380 case OPCODE_POINT_PARAMETERS:
4381 {
4382 GLfloat params[3];
4383 params[0] = n[2].f;
4384 params[1] = n[3].f;
4385 params[2] = n[4].f;
4386 (*ctx->Exec->PointParameterfvEXT)( n[1].e, params );
4387 }
4388 break;
4389 case OPCODE_POLYGON_MODE:
4390 (*ctx->Exec->PolygonMode)( n[1].e, n[2].e );
4391 break;
4392 case OPCODE_POLYGON_STIPPLE:
4393 (*ctx->Exec->PolygonStipple)( (GLubyte *) n[1].data );
4394 break;
4395 case OPCODE_POLYGON_OFFSET:
4396 (*ctx->Exec->PolygonOffset)( n[1].f, n[2].f );
4397 break;
4398 case OPCODE_POP_ATTRIB:
4399 (*ctx->Exec->PopAttrib)();
4400 break;
4401 case OPCODE_POP_MATRIX:
4402 (*ctx->Exec->PopMatrix)();
4403 break;
4404 case OPCODE_POP_NAME:
4405 (*ctx->Exec->PopName)();
4406 break;
4407 case OPCODE_PRIORITIZE_TEXTURE:
4408 (*ctx->Exec->PrioritizeTextures)( 1, &n[1].ui, &n[2].f );
4409 break;
4410 case OPCODE_PUSH_ATTRIB:
4411 (*ctx->Exec->PushAttrib)( n[1].bf );
4412 break;
4413 case OPCODE_PUSH_MATRIX:
4414 (*ctx->Exec->PushMatrix)();
4415 break;
4416 case OPCODE_PUSH_NAME:
4417 (*ctx->Exec->PushName)( n[1].ui );
4418 break;
4419 case OPCODE_RASTER_POS:
4420 (*ctx->Exec->RasterPos4f)( n[1].f, n[2].f, n[3].f, n[4].f );
4421 break;
4422 case OPCODE_READ_BUFFER:
4423 (*ctx->Exec->ReadBuffer)( n[1].e );
4424 break;
4425 case OPCODE_RESET_HISTOGRAM:
4426 (*ctx->Exec->ResetHistogram)( n[1].e );
4427 break;
4428 case OPCODE_RESET_MIN_MAX:
4429 (*ctx->Exec->ResetMinmax)( n[1].e );
4430 break;
4431 case OPCODE_ROTATE:
4432 (*ctx->Exec->Rotatef)( n[1].f, n[2].f, n[3].f, n[4].f );
4433 break;
4434 case OPCODE_SCALE:
4435 (*ctx->Exec->Scalef)( n[1].f, n[2].f, n[3].f );
4436 break;
4437 case OPCODE_SCISSOR:
4438 (*ctx->Exec->Scissor)( n[1].i, n[2].i, n[3].i, n[4].i );
4439 break;
4440 case OPCODE_SHADE_MODEL:
4441 (*ctx->Exec->ShadeModel)( n[1].e );
4442 break;
4443 case OPCODE_STENCIL_FUNC:
4444 (*ctx->Exec->StencilFunc)( n[1].e, n[2].i, n[3].ui );
4445 break;
4446 case OPCODE_STENCIL_MASK:
4447 (*ctx->Exec->StencilMask)( n[1].ui );
4448 break;
4449 case OPCODE_STENCIL_OP:
4450 (*ctx->Exec->StencilOp)( n[1].e, n[2].e, n[3].e );
4451 break;
4452 case OPCODE_TEXENV:
4453 {
4454 GLfloat params[4];
4455 params[0] = n[3].f;
4456 params[1] = n[4].f;
4457 params[2] = n[5].f;
4458 params[3] = n[6].f;
4459 (*ctx->Exec->TexEnvfv)( n[1].e, n[2].e, params );
4460 }
4461 break;
4462 case OPCODE_TEXGEN:
4463 {
4464 GLfloat params[4];
4465 params[0] = n[3].f;
4466 params[1] = n[4].f;
4467 params[2] = n[5].f;
4468 params[3] = n[6].f;
4469 (*ctx->Exec->TexGenfv)( n[1].e, n[2].e, params );
4470 }
4471 break;
4472 case OPCODE_TEXPARAMETER:
4473 {
4474 GLfloat params[4];
4475 params[0] = n[3].f;
4476 params[1] = n[4].f;
4477 params[2] = n[5].f;
4478 params[3] = n[6].f;
4479 (*ctx->Exec->TexParameterfv)( n[1].e, n[2].e, params );
4480 }
4481 break;
4482 case OPCODE_TEX_IMAGE1D:
4483 {
4484 struct gl_pixelstore_attrib save = ctx->Unpack;
4485 ctx->Unpack = _mesa_native_packing;
4486 (*ctx->Exec->TexImage1D)(
4487 n[1].e, /* target */
4488 n[2].i, /* level */
4489 n[3].i, /* components */
4490 n[4].i, /* width */
4491 n[5].e, /* border */
4492 n[6].e, /* format */
4493 n[7].e, /* type */
4494 n[8].data );
4495 ctx->Unpack = save; /* restore */
4496 }
4497 break;
4498 case OPCODE_TEX_IMAGE2D:
4499 {
4500 struct gl_pixelstore_attrib save = ctx->Unpack;
4501 ctx->Unpack = _mesa_native_packing;
4502 (*ctx->Exec->TexImage2D)(
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].e, /* border */
4509 n[7].e, /* format */
4510 n[8].e, /* type */
4511 n[9].data );
4512 ctx->Unpack = save; /* restore */
4513 }
4514 break;
4515 case OPCODE_TEX_IMAGE3D:
4516 {
4517 struct gl_pixelstore_attrib save = ctx->Unpack;
4518 ctx->Unpack = _mesa_native_packing;
4519 (*ctx->Exec->TexImage3D)(
4520 n[1].e, /* target */
4521 n[2].i, /* level */
4522 n[3].i, /* components */
4523 n[4].i, /* width */
4524 n[5].i, /* height */
4525 n[6].i, /* depth */
4526 n[7].e, /* border */
4527 n[8].e, /* format */
4528 n[9].e, /* type */
4529 n[10].data );
4530 ctx->Unpack = save; /* restore */
4531 }
4532 break;
4533 case OPCODE_TEX_SUB_IMAGE1D:
4534 {
4535 struct gl_pixelstore_attrib save = ctx->Unpack;
4536 ctx->Unpack = _mesa_native_packing;
4537 (*ctx->Exec->TexSubImage1D)( n[1].e, n[2].i, n[3].i,
4538 n[4].i, n[5].e,
4539 n[6].e, n[7].data );
4540 ctx->Unpack = save; /* restore */
4541 }
4542 break;
4543 case OPCODE_TEX_SUB_IMAGE2D:
4544 {
4545 struct gl_pixelstore_attrib save = ctx->Unpack;
4546 ctx->Unpack = _mesa_native_packing;
4547 (*ctx->Exec->TexSubImage2D)( n[1].e, n[2].i, n[3].i,
4548 n[4].i, n[5].e,
4549 n[6].i, n[7].e, n[8].e, n[9].data );
4550 ctx->Unpack = save; /* restore */
4551 }
4552 break;
4553 case OPCODE_TEX_SUB_IMAGE3D:
4554 {
4555 struct gl_pixelstore_attrib save = ctx->Unpack;
4556 ctx->Unpack = _mesa_native_packing;
4557 (*ctx->Exec->TexSubImage3D)( n[1].e, n[2].i, n[3].i,
4558 n[4].i, n[5].i, n[6].i, n[7].i,
4559 n[8].i, n[9].e, n[10].e,
4560 n[11].data );
4561 ctx->Unpack = save; /* restore */
4562 }
4563 break;
4564 case OPCODE_TRANSLATE:
4565 (*ctx->Exec->Translatef)( n[1].f, n[2].f, n[3].f );
4566 break;
4567 case OPCODE_VIEWPORT:
4568 (*ctx->Exec->Viewport)(n[1].i, n[2].i,
4569 (GLsizei) n[3].i, (GLsizei) n[4].i);
4570 break;
4571 case OPCODE_WINDOW_POS:
4572 (*ctx->Exec->WindowPos4fMESA)( n[1].f, n[2].f, n[3].f, n[4].f );
4573 break;
4574 case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
4575 (*ctx->Exec->ActiveTextureARB)( n[1].e );
4576 break;
4577 case OPCODE_CLIENT_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
4578 (*ctx->Exec->ClientActiveTextureARB)( n[1].e );
4579 break;
4580 case OPCODE_PIXEL_TEXGEN_SGIX: /* GL_SGIX_pixel_texture */
4581 (*ctx->Exec->PixelTexGenSGIX)( n[1].e );
4582 break;
4583 case OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS: /* GL_SGIS_pixel_texture */
4584 (*ctx->Exec->PixelTexGenParameteriSGIS)( n[1].e, n[2].i );
4585 break;
4586 case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */
4587 (*ctx->Exec->CompressedTexImage1DARB)(n[1].e, n[2].i, n[3].e,
4588 n[4].i, n[5].i, n[6].i, n[7].data);
4589 break;
4590 case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */
4591 (*ctx->Exec->CompressedTexImage2DARB)(n[1].e, n[2].i, n[3].e,
4592 n[4].i, n[5].i, n[6].i, n[7].i, n[8].data);
4593 break;
4594 case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */
4595 (*ctx->Exec->CompressedTexImage3DARB)(n[1].e, n[2].i, n[3].e,
4596 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i, n[9].data);
4597 break;
4598 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */
4599 (*ctx->Exec->CompressedTexSubImage1DARB)(n[1].e, n[2].i, n[3].i,
4600 n[4].i, n[5].e, n[6].i, n[7].data);
4601 break;
4602 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */
4603 (*ctx->Exec->CompressedTexSubImage2DARB)(n[1].e, n[2].i, n[3].i,
4604 n[4].i, n[5].i, n[6].i, n[7].e, n[8].i, n[9].data);
4605 break;
4606 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */
4607 (*ctx->Exec->CompressedTexSubImage3DARB)(n[1].e, n[2].i, n[3].i,
4608 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i,
4609 n[9].e, n[10].i, n[11].data);
4610 break;
4611 case OPCODE_CONTINUE:
4612 n = (Node *) n[1].next;
4613 break;
4614 case OPCODE_END_OF_LIST:
4615 done = GL_TRUE;
4616 break;
4617 default:
4618 {
4619 char msg[1000];
4620 sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
4621 gl_problem( ctx, msg );
4622 }
4623 done = GL_TRUE;
4624 }
4625
4626 /* increment n to point to next compiled command */
4627 if (opcode!=OPCODE_CONTINUE) {
4628 n += InstSize[opcode];
4629 }
4630 }
4631 }
4632 ctx->CallDepth--;
4633 }
4634
4635
4636
4637
4638
4639 /**********************************************************************/
4640 /* GL functions */
4641 /**********************************************************************/
4642
4643
4644
4645
4646 /*
4647 * Test if a display list number is valid.
4648 */
4649 GLboolean
4650 _mesa_IsList( GLuint list )
4651 {
4652 GET_CURRENT_CONTEXT(ctx);
4653 return islist(ctx, list);
4654 }
4655
4656
4657 /*
4658 * Delete a sequence of consecutive display lists.
4659 */
4660 void
4661 _mesa_DeleteLists( GLuint list, GLsizei range )
4662 {
4663 GET_CURRENT_CONTEXT(ctx);
4664 GLuint i;
4665
4666 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDeleteLists");
4667 if (range<0) {
4668 gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
4669 return;
4670 }
4671 for (i=list;i<list+range;i++) {
4672 gl_destroy_list( ctx, i );
4673 }
4674 }
4675
4676
4677
4678 /*
4679 * Return a display list number, n, such that lists n through n+range-1
4680 * are free.
4681 */
4682 GLuint
4683 _mesa_GenLists(GLsizei range )
4684 {
4685 GET_CURRENT_CONTEXT(ctx);
4686 GLuint base;
4687
4688 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glGenLists", 0);
4689 if (range<0) {
4690 gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
4691 return 0;
4692 }
4693 if (range==0) {
4694 return 0;
4695 }
4696
4697 /*
4698 * Make this an atomic operation
4699 */
4700 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
4701
4702 base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
4703 if (base) {
4704 /* reserve the list IDs by with empty/dummy lists */
4705 GLint i;
4706 for (i=0; i<range; i++) {
4707 _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
4708 }
4709 }
4710
4711 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
4712
4713 return base;
4714 }
4715
4716
4717
4718 /*
4719 * Begin a new display list.
4720 */
4721 void
4722 _mesa_NewList( GLuint list, GLenum mode )
4723 {
4724 GET_CURRENT_CONTEXT(ctx);
4725 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glNewList");
4726 FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
4727
4728 if (MESA_VERBOSE&VERBOSE_API)
4729 fprintf(stderr, "glNewList %u %s\n", list, gl_lookup_enum_by_nr(mode));
4730
4731 if (list==0) {
4732 gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
4733 return;
4734 }
4735
4736 if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
4737 gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
4738 return;
4739 }
4740
4741 if (ctx->CurrentListPtr) {
4742 /* already compiling a display list */
4743 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
4744 return;
4745 }
4746
4747 /* Allocate new display list */
4748 ctx->CurrentListNum = list;
4749 ctx->CurrentBlock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
4750 ctx->CurrentListPtr = ctx->CurrentBlock;
4751 ctx->CurrentPos = 0;
4752 ctx->CompileFlag = GL_TRUE;
4753 ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
4754
4755 ctx->Driver.NewList( ctx, list, mode );
4756
4757 ctx->CurrentDispatch = ctx->Save;
4758 _glapi_set_dispatch( ctx->CurrentDispatch );
4759 }
4760
4761
4762
4763 /*
4764 * End definition of current display list. Is the current
4765 * ASSERT_OUTSIDE_BEGIN_END strong enough to really guarentee that
4766 * we are outside begin/end calls?
4767 */
4768 void
4769 _mesa_EndList( void )
4770 {
4771 GET_CURRENT_CONTEXT(ctx);
4772 if (MESA_VERBOSE&VERBOSE_API)
4773 fprintf(stderr, "glEndList\n");
4774
4775 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glEndList" );
4776 FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
4777
4778
4779 /* Check that a list is under construction */
4780 if (!ctx->CurrentListPtr) {
4781 gl_error( ctx, GL_INVALID_OPERATION, "glEndList" );
4782 return;
4783 }
4784
4785 (void) ALLOC_INSTRUCTION( ctx, OPCODE_END_OF_LIST, 0 );
4786
4787 /* Destroy old list, if any */
4788 gl_destroy_list(ctx, ctx->CurrentListNum);
4789 /* Install the list */
4790 _mesa_HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
4791
4792
4793 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
4794 mesa_print_display_list(ctx->CurrentListNum);
4795
4796 ctx->CurrentListNum = 0;
4797 ctx->CurrentListPtr = NULL;
4798 ctx->ExecuteFlag = GL_TRUE;
4799 ctx->CompileFlag = GL_FALSE;
4800
4801 ctx->Driver.EndList( ctx );
4802
4803 /* Haven't tracked down why this is needed.
4804 */
4805 ctx->NewState = ~0;
4806
4807 ctx->CurrentDispatch = ctx->Exec;
4808 _glapi_set_dispatch( ctx->CurrentDispatch );
4809 }
4810
4811
4812
4813 void
4814 _mesa_CallList( GLuint list )
4815 {
4816 GET_CURRENT_CONTEXT(ctx);
4817 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
4818 /* execute the display list, and restore the CompileFlag. */
4819 GLboolean save_compile_flag;
4820
4821 if (MESA_VERBOSE&VERBOSE_API) {
4822 fprintf(stderr, "glCallList %u\n", list);
4823 mesa_print_display_list( list );
4824 }
4825
4826 save_compile_flag = ctx->CompileFlag;
4827 ctx->CompileFlag = GL_FALSE;
4828
4829 FLUSH_TNL( ctx, (FLUSH_STORED_VERTICES | FLUSH_UPDATE_CURRENT) );
4830 execute_list( ctx, list );
4831 ctx->CompileFlag = save_compile_flag;
4832
4833 /* also restore API function pointers to point to "save" versions */
4834 if (save_compile_flag) {
4835 ctx->CurrentDispatch = ctx->Save;
4836 _glapi_set_dispatch( ctx->CurrentDispatch );
4837 }
4838 }
4839
4840
4841
4842 /*
4843 * Execute glCallLists: call multiple display lists.
4844 */
4845 void
4846 _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
4847 {
4848 GET_CURRENT_CONTEXT(ctx);
4849 GLuint list;
4850 GLint i;
4851 GLboolean save_compile_flag;
4852
4853 /* Save the CompileFlag status, turn it off, execute display list,
4854 * and restore the CompileFlag.
4855 */
4856 save_compile_flag = ctx->CompileFlag;
4857 ctx->CompileFlag = GL_FALSE;
4858
4859 FLUSH_TNL( ctx, (FLUSH_STORED_VERTICES | FLUSH_UPDATE_CURRENT) );
4860
4861 for (i=0;i<n;i++) {
4862 list = translate_id( i, type, lists );
4863 execute_list( ctx, ctx->List.ListBase + list );
4864 }
4865
4866 ctx->CompileFlag = save_compile_flag;
4867
4868 /* also restore API function pointers to point to "save" versions */
4869 if (save_compile_flag) {
4870 ctx->CurrentDispatch = ctx->Save;
4871 _glapi_set_dispatch( ctx->CurrentDispatch );
4872 }
4873 }
4874
4875
4876
4877 /*
4878 * Set the offset added to list numbers in glCallLists.
4879 */
4880 void
4881 _mesa_ListBase( GLuint base )
4882 {
4883 GET_CURRENT_CONTEXT(ctx);
4884 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glListBase");
4885 ctx->List.ListBase = base;
4886 }
4887
4888
4889
4890
4891 /*
4892 * Assign all the pointers in <table> to point to Mesa's display list
4893 * building functions.
4894 *
4895 * This does not include any of the tnl functions - they are
4896 * initialized from _mesa_init_api_defaults and from the active vtxfmt
4897 * struct.
4898 */
4899 void
4900 _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
4901 {
4902 _mesa_init_no_op_table(table, tableSize);
4903
4904 _mesa_loopback_init_api_table( table, GL_FALSE );
4905
4906 /* GL 1.0 */
4907 table->Accum = save_Accum;
4908 table->AlphaFunc = save_AlphaFunc;
4909 table->Bitmap = save_Bitmap;
4910 table->BlendFunc = save_BlendFunc;
4911 table->CallList = save_CallList;
4912 table->CallLists = save_CallLists;
4913 table->Clear = save_Clear;
4914 table->ClearAccum = save_ClearAccum;
4915 table->ClearColor = save_ClearColor;
4916 table->ClearDepth = save_ClearDepth;
4917 table->ClearIndex = save_ClearIndex;
4918 table->ClearStencil = save_ClearStencil;
4919 table->ClipPlane = save_ClipPlane;
4920 table->ColorMask = save_ColorMask;
4921 table->ColorMaterial = save_ColorMaterial;
4922 table->CopyPixels = save_CopyPixels;
4923 table->CullFace = save_CullFace;
4924 table->DeleteLists = _mesa_DeleteLists;
4925 table->DepthFunc = save_DepthFunc;
4926 table->DepthMask = save_DepthMask;
4927 table->DepthRange = save_DepthRange;
4928 table->Disable = save_Disable;
4929 table->DrawBuffer = save_DrawBuffer;
4930 table->DrawPixels = save_DrawPixels;
4931 table->Enable = save_Enable;
4932 table->EndList = _mesa_EndList;
4933 table->EvalMesh1 = _mesa_save_EvalMesh1;
4934 table->EvalMesh2 = _mesa_save_EvalMesh2;
4935 table->Finish = _mesa_Finish;
4936 table->Flush = _mesa_Flush;
4937 table->Fogf = save_Fogf;
4938 table->Fogfv = save_Fogfv;
4939 table->Fogi = save_Fogi;
4940 table->Fogiv = save_Fogiv;
4941 table->FrontFace = save_FrontFace;
4942 table->Frustum = save_Frustum;
4943 table->GenLists = _mesa_GenLists;
4944 table->GetBooleanv = _mesa_GetBooleanv;
4945 table->GetClipPlane = _mesa_GetClipPlane;
4946 table->GetDoublev = _mesa_GetDoublev;
4947 table->GetError = _mesa_GetError;
4948 table->GetFloatv = _mesa_GetFloatv;
4949 table->GetIntegerv = _mesa_GetIntegerv;
4950 table->GetLightfv = _mesa_GetLightfv;
4951 table->GetLightiv = _mesa_GetLightiv;
4952 table->GetMapdv = _mesa_GetMapdv;
4953 table->GetMapfv = _mesa_GetMapfv;
4954 table->GetMapiv = _mesa_GetMapiv;
4955 table->GetMaterialfv = _mesa_GetMaterialfv;
4956 table->GetMaterialiv = _mesa_GetMaterialiv;
4957 table->GetPixelMapfv = _mesa_GetPixelMapfv;
4958 table->GetPixelMapuiv = _mesa_GetPixelMapuiv;
4959 table->GetPixelMapusv = _mesa_GetPixelMapusv;
4960 table->GetPolygonStipple = _mesa_GetPolygonStipple;
4961 table->GetString = _mesa_GetString;
4962 table->GetTexEnvfv = _mesa_GetTexEnvfv;
4963 table->GetTexEnviv = _mesa_GetTexEnviv;
4964 table->GetTexGendv = _mesa_GetTexGendv;
4965 table->GetTexGenfv = _mesa_GetTexGenfv;
4966 table->GetTexGeniv = _mesa_GetTexGeniv;
4967 table->GetTexImage = _mesa_GetTexImage;
4968 table->GetTexLevelParameterfv = _mesa_GetTexLevelParameterfv;
4969 table->GetTexLevelParameteriv = _mesa_GetTexLevelParameteriv;
4970 table->GetTexParameterfv = _mesa_GetTexParameterfv;
4971 table->GetTexParameteriv = _mesa_GetTexParameteriv;
4972 table->Hint = save_Hint;
4973 table->IndexMask = save_IndexMask;
4974 table->InitNames = save_InitNames;
4975 table->IsEnabled = _mesa_IsEnabled;
4976 table->IsList = _mesa_IsList;
4977 table->LightModelf = save_LightModelf;
4978 table->LightModelfv = save_LightModelfv;
4979 table->LightModeli = save_LightModeli;
4980 table->LightModeliv = save_LightModeliv;
4981 table->Lightf = save_Lightf;
4982 table->Lightfv = save_Lightfv;
4983 table->Lighti = save_Lighti;
4984 table->Lightiv = save_Lightiv;
4985 table->LineStipple = save_LineStipple;
4986 table->LineWidth = save_LineWidth;
4987 table->ListBase = save_ListBase;
4988 table->LoadIdentity = save_LoadIdentity;
4989 table->LoadMatrixd = save_LoadMatrixd;
4990 table->LoadMatrixf = save_LoadMatrixf;
4991 table->LoadName = save_LoadName;
4992 table->LogicOp = save_LogicOp;
4993 table->Map1d = save_Map1d;
4994 table->Map1f = save_Map1f;
4995 table->Map2d = save_Map2d;
4996 table->Map2f = save_Map2f;
4997 table->MapGrid1d = save_MapGrid1d;
4998 table->MapGrid1f = save_MapGrid1f;
4999 table->MapGrid2d = save_MapGrid2d;
5000 table->MapGrid2f = save_MapGrid2f;
5001 table->MatrixMode = save_MatrixMode;
5002 table->MultMatrixd = save_MultMatrixd;
5003 table->MultMatrixf = save_MultMatrixf;
5004 table->NewList = save_NewList;
5005 table->Ortho = save_Ortho;
5006 table->PassThrough = save_PassThrough;
5007 table->PixelMapfv = save_PixelMapfv;
5008 table->PixelMapuiv = save_PixelMapuiv;
5009 table->PixelMapusv = save_PixelMapusv;
5010 table->PixelStoref = _mesa_PixelStoref;
5011 table->PixelStorei = _mesa_PixelStorei;
5012 table->PixelTransferf = save_PixelTransferf;
5013 table->PixelTransferi = save_PixelTransferi;
5014 table->PixelZoom = save_PixelZoom;
5015 table->PointSize = save_PointSize;
5016 table->PolygonMode = save_PolygonMode;
5017 table->PolygonOffset = save_PolygonOffset;
5018 table->PolygonStipple = save_PolygonStipple;
5019 table->PopAttrib = save_PopAttrib;
5020 table->PopMatrix = save_PopMatrix;
5021 table->PopName = save_PopName;
5022 table->PushAttrib = save_PushAttrib;
5023 table->PushMatrix = save_PushMatrix;
5024 table->PushName = save_PushName;
5025 table->RasterPos2d = save_RasterPos2d;
5026 table->RasterPos2dv = save_RasterPos2dv;
5027 table->RasterPos2f = save_RasterPos2f;
5028 table->RasterPos2fv = save_RasterPos2fv;
5029 table->RasterPos2i = save_RasterPos2i;
5030 table->RasterPos2iv = save_RasterPos2iv;
5031 table->RasterPos2s = save_RasterPos2s;
5032 table->RasterPos2sv = save_RasterPos2sv;
5033 table->RasterPos3d = save_RasterPos3d;
5034 table->RasterPos3dv = save_RasterPos3dv;
5035 table->RasterPos3f = save_RasterPos3f;
5036 table->RasterPos3fv = save_RasterPos3fv;
5037 table->RasterPos3i = save_RasterPos3i;
5038 table->RasterPos3iv = save_RasterPos3iv;
5039 table->RasterPos3s = save_RasterPos3s;
5040 table->RasterPos3sv = save_RasterPos3sv;
5041 table->RasterPos4d = save_RasterPos4d;
5042 table->RasterPos4dv = save_RasterPos4dv;
5043 table->RasterPos4f = save_RasterPos4f;
5044 table->RasterPos4fv = save_RasterPos4fv;
5045 table->RasterPos4i = save_RasterPos4i;
5046 table->RasterPos4iv = save_RasterPos4iv;
5047 table->RasterPos4s = save_RasterPos4s;
5048 table->RasterPos4sv = save_RasterPos4sv;
5049 table->ReadBuffer = save_ReadBuffer;
5050 table->ReadPixels = _mesa_ReadPixels;
5051 table->RenderMode = _mesa_RenderMode;
5052 table->Rotated = save_Rotated;
5053 table->Rotatef = save_Rotatef;
5054 table->Scaled = save_Scaled;
5055 table->Scalef = save_Scalef;
5056 table->Scissor = save_Scissor;
5057 table->FeedbackBuffer = _mesa_FeedbackBuffer;
5058 table->SelectBuffer = _mesa_SelectBuffer;
5059 table->ShadeModel = save_ShadeModel;
5060 table->StencilFunc = save_StencilFunc;
5061 table->StencilMask = save_StencilMask;
5062 table->StencilOp = save_StencilOp;
5063 table->TexEnvf = save_TexEnvf;
5064 table->TexEnvfv = save_TexEnvfv;
5065 table->TexEnvi = save_TexEnvi;
5066 table->TexEnviv = save_TexEnviv;
5067 table->TexGend = save_TexGend;
5068 table->TexGendv = save_TexGendv;
5069 table->TexGenf = save_TexGenf;
5070 table->TexGenfv = save_TexGenfv;
5071 table->TexGeni = save_TexGeni;
5072 table->TexGeniv = save_TexGeniv;
5073 table->TexImage1D = save_TexImage1D;
5074 table->TexImage2D = save_TexImage2D;
5075 table->TexParameterf = save_TexParameterf;
5076 table->TexParameterfv = save_TexParameterfv;
5077 table->TexParameteri = save_TexParameteri;
5078 table->TexParameteriv = save_TexParameteriv;
5079 table->Translated = save_Translated;
5080 table->Translatef = save_Translatef;
5081 table->Viewport = save_Viewport;
5082
5083 /* GL 1.1 */
5084 table->AreTexturesResident = _mesa_AreTexturesResident;
5085 table->BindTexture = save_BindTexture;
5086 table->ColorPointer = _mesa_ColorPointer;
5087 table->CopyTexImage1D = save_CopyTexImage1D;
5088 table->CopyTexImage2D = save_CopyTexImage2D;
5089 table->CopyTexSubImage1D = save_CopyTexSubImage1D;
5090 table->CopyTexSubImage2D = save_CopyTexSubImage2D;
5091 table->DeleteTextures = _mesa_DeleteTextures;
5092 table->DisableClientState = _mesa_DisableClientState;
5093 table->EdgeFlagPointer = _mesa_EdgeFlagPointer;
5094 table->EnableClientState = _mesa_EnableClientState;
5095 table->GenTextures = _mesa_GenTextures;
5096 table->GetPointerv = _mesa_GetPointerv;
5097 table->IndexPointer = _mesa_IndexPointer;
5098 table->InterleavedArrays = _mesa_InterleavedArrays;
5099 table->IsTexture = _mesa_IsTexture;
5100 table->NormalPointer = _mesa_NormalPointer;
5101 table->PopClientAttrib = _mesa_PopClientAttrib;
5102 table->PrioritizeTextures = save_PrioritizeTextures;
5103 table->PushClientAttrib = _mesa_PushClientAttrib;
5104 table->TexCoordPointer = _mesa_TexCoordPointer;
5105 table->TexSubImage1D = save_TexSubImage1D;
5106 table->TexSubImage2D = save_TexSubImage2D;
5107 table->VertexPointer = _mesa_VertexPointer;
5108
5109 /* GL 1.2 */
5110 table->CopyTexSubImage3D = save_CopyTexSubImage3D;
5111 table->TexImage3D = save_TexImage3D;
5112 table->TexSubImage3D = save_TexSubImage3D;
5113
5114 /* GL_ARB_imaging */
5115 /* Not all are supported */
5116 table->BlendColor = save_BlendColor;
5117 table->BlendEquation = save_BlendEquation;
5118 table->ColorSubTable = save_ColorSubTable;
5119 table->ColorTable = save_ColorTable;
5120 table->ColorTableParameterfv = save_ColorTableParameterfv;
5121 table->ColorTableParameteriv = save_ColorTableParameteriv;
5122 table->ConvolutionFilter1D = save_ConvolutionFilter1D;
5123 table->ConvolutionFilter2D = save_ConvolutionFilter2D;
5124 table->ConvolutionParameterf = save_ConvolutionParameterf;
5125 table->ConvolutionParameterfv = save_ConvolutionParameterfv;
5126 table->ConvolutionParameteri = save_ConvolutionParameteri;
5127 table->ConvolutionParameteriv = save_ConvolutionParameteriv;
5128 table->CopyColorSubTable = save_CopyColorSubTable;
5129 table->CopyColorTable = save_CopyColorTable;
5130 table->CopyConvolutionFilter1D = _mesa_CopyConvolutionFilter1D;
5131 table->CopyConvolutionFilter2D = _mesa_CopyConvolutionFilter2D;
5132 table->GetColorTable = _mesa_GetColorTable;
5133 table->GetColorTableParameterfv = _mesa_GetColorTableParameterfv;
5134 table->GetColorTableParameteriv = _mesa_GetColorTableParameteriv;
5135 table->GetConvolutionFilter = _mesa_GetConvolutionFilter;
5136 table->GetConvolutionParameterfv = _mesa_GetConvolutionParameterfv;
5137 table->GetConvolutionParameteriv = _mesa_GetConvolutionParameteriv;
5138 table->GetHistogram = _mesa_GetHistogram;
5139 table->GetHistogramParameterfv = _mesa_GetHistogramParameterfv;
5140 table->GetHistogramParameteriv = _mesa_GetHistogramParameteriv;
5141 table->GetMinmax = _mesa_GetMinmax;
5142 table->GetMinmaxParameterfv = _mesa_GetMinmaxParameterfv;
5143 table->GetMinmaxParameteriv = _mesa_GetMinmaxParameteriv;
5144 table->GetSeparableFilter = _mesa_GetSeparableFilter;
5145 table->Histogram = save_Histogram;
5146 table->Minmax = save_Minmax;
5147 table->ResetHistogram = save_ResetHistogram;
5148 table->ResetMinmax = save_ResetMinmax;
5149 table->SeparableFilter2D = _mesa_SeparableFilter2D;
5150
5151 /* 2. GL_EXT_blend_color */
5152 #if 0
5153 table->BlendColorEXT = save_BlendColorEXT;
5154 #endif
5155
5156 /* 3. GL_EXT_polygon_offset */
5157 table->PolygonOffsetEXT = save_PolygonOffsetEXT;
5158
5159 /* 6. GL_EXT_texture3d */
5160 #if 0
5161 table->CopyTexSubImage3DEXT = save_CopyTexSubImage3D;
5162 table->TexImage3DEXT = save_TexImage3DEXT;
5163 table->TexSubImage3DEXT = save_TexSubImage3D;
5164 #endif
5165
5166 /* 15. GL_SGIX_pixel_texture */
5167 table->PixelTexGenSGIX = save_PixelTexGenSGIX;
5168
5169 /* 15. GL_SGIS_pixel_texture */
5170 table->PixelTexGenParameteriSGIS = save_PixelTexGenParameteriSGIS;
5171 table->PixelTexGenParameterfSGIS = save_PixelTexGenParameterfSGIS;
5172 table->PixelTexGenParameterivSGIS = save_PixelTexGenParameterivSGIS;
5173 table->PixelTexGenParameterfvSGIS = save_PixelTexGenParameterfvSGIS;
5174 table->GetPixelTexGenParameterivSGIS = _mesa_GetPixelTexGenParameterivSGIS;
5175 table->GetPixelTexGenParameterfvSGIS = _mesa_GetPixelTexGenParameterfvSGIS;
5176
5177 /* 30. GL_EXT_vertex_array */
5178 table->ColorPointerEXT = _mesa_ColorPointerEXT;
5179 table->EdgeFlagPointerEXT = _mesa_EdgeFlagPointerEXT;
5180 table->IndexPointerEXT = _mesa_IndexPointerEXT;
5181 table->NormalPointerEXT = _mesa_NormalPointerEXT;
5182 table->TexCoordPointerEXT = _mesa_TexCoordPointerEXT;
5183 table->VertexPointerEXT = _mesa_VertexPointerEXT;
5184
5185 /* 37. GL_EXT_blend_minmax */
5186 #if 0
5187 table->BlendEquationEXT = save_BlendEquationEXT;
5188 #endif
5189
5190 /* 54. GL_EXT_point_parameters */
5191 table->PointParameterfEXT = save_PointParameterfEXT;
5192 table->PointParameterfvEXT = save_PointParameterfvEXT;
5193
5194 /* 77. GL_PGI_misc_hints */
5195 table->HintPGI = save_HintPGI;
5196
5197 /* 78. GL_EXT_paletted_texture */
5198 #if 0
5199 table->ColorTableEXT = save_ColorTable;
5200 table->ColorSubTableEXT = save_ColorSubTable;
5201 #endif
5202 table->GetColorTableEXT = _mesa_GetColorTable;
5203 table->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv;
5204 table->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv;
5205
5206 /* 97. GL_EXT_compiled_vertex_array */
5207 table->LockArraysEXT = _mesa_LockArraysEXT;
5208 table->UnlockArraysEXT = _mesa_UnlockArraysEXT;
5209
5210 /* GL_ARB_multitexture */
5211 table->ActiveTextureARB = save_ActiveTextureARB;
5212 table->ClientActiveTextureARB = save_ClientActiveTextureARB;
5213
5214 /* GL_EXT_blend_func_separate */
5215 table->BlendFuncSeparateEXT = save_BlendFuncSeparateEXT;
5216
5217 /* GL_MESA_window_pos */
5218 table->WindowPos2dMESA = save_WindowPos2dMESA;
5219 table->WindowPos2dvMESA = save_WindowPos2dvMESA;
5220 table->WindowPos2fMESA = save_WindowPos2fMESA;
5221 table->WindowPos2fvMESA = save_WindowPos2fvMESA;
5222 table->WindowPos2iMESA = save_WindowPos2iMESA;
5223 table->WindowPos2ivMESA = save_WindowPos2ivMESA;
5224 table->WindowPos2sMESA = save_WindowPos2sMESA;
5225 table->WindowPos2svMESA = save_WindowPos2svMESA;
5226 table->WindowPos3dMESA = save_WindowPos3dMESA;
5227 table->WindowPos3dvMESA = save_WindowPos3dvMESA;
5228 table->WindowPos3fMESA = save_WindowPos3fMESA;
5229 table->WindowPos3fvMESA = save_WindowPos3fvMESA;
5230 table->WindowPos3iMESA = save_WindowPos3iMESA;
5231 table->WindowPos3ivMESA = save_WindowPos3ivMESA;
5232 table->WindowPos3sMESA = save_WindowPos3sMESA;
5233 table->WindowPos3svMESA = save_WindowPos3svMESA;
5234 table->WindowPos4dMESA = save_WindowPos4dMESA;
5235 table->WindowPos4dvMESA = save_WindowPos4dvMESA;
5236 table->WindowPos4fMESA = save_WindowPos4fMESA;
5237 table->WindowPos4fvMESA = save_WindowPos4fvMESA;
5238 table->WindowPos4iMESA = save_WindowPos4iMESA;
5239 table->WindowPos4ivMESA = save_WindowPos4ivMESA;
5240 table->WindowPos4sMESA = save_WindowPos4sMESA;
5241 table->WindowPos4svMESA = save_WindowPos4svMESA;
5242
5243 /* GL_MESA_resize_buffers */
5244 table->ResizeBuffersMESA = _mesa_ResizeBuffersMESA;
5245
5246 /* GL_ARB_transpose_matrix */
5247 table->LoadTransposeMatrixdARB = save_LoadTransposeMatrixdARB;
5248 table->LoadTransposeMatrixfARB = save_LoadTransposeMatrixfARB;
5249 table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB;
5250 table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB;
5251
5252 /* ARB 12. GL_ARB_texture_compression */
5253 table->CompressedTexImage3DARB = save_CompressedTexImage3DARB;
5254 table->CompressedTexImage2DARB = save_CompressedTexImage2DARB;
5255 table->CompressedTexImage1DARB = save_CompressedTexImage1DARB;
5256 table->CompressedTexSubImage3DARB = save_CompressedTexSubImage3DARB;
5257 table->CompressedTexSubImage2DARB = save_CompressedTexSubImage2DARB;
5258 table->CompressedTexSubImage1DARB = save_CompressedTexSubImage1DARB;
5259 table->GetCompressedTexImageARB = _mesa_GetCompressedTexImageARB;
5260
5261 /* GL_EXT_secondary_color */
5262 table->SecondaryColorPointerEXT = _mesa_SecondaryColorPointerEXT;
5263
5264 /* GL_EXT_fog_coord */
5265 table->FogCoordPointerEXT = _mesa_FogCoordPointerEXT;
5266 }
5267
5268
5269
5270 /***
5271 *** Debugging code
5272 ***/
5273 static const char *enum_string( GLenum k )
5274 {
5275 return gl_lookup_enum_by_nr( k );
5276 }
5277
5278
5279 /*
5280 * Print the commands in a display list. For debugging only.
5281 * TODO: many commands aren't handled yet.
5282 */
5283 static void print_list( GLcontext *ctx, FILE *f, GLuint list )
5284 {
5285 Node *n;
5286 GLboolean done;
5287
5288 if (!glIsList(list)) {
5289 fprintf(f,"%u is not a display list ID\n",list);
5290 return;
5291 }
5292
5293 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
5294
5295 fprintf( f, "START-LIST %u, address %p\n", list, (void*)n );
5296
5297 done = n ? GL_FALSE : GL_TRUE;
5298 while (!done) {
5299 OpCode opcode = n[0].opcode;
5300 int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
5301
5302 if (i >= 0 && i < ctx->listext.nr_opcodes) {
5303 ctx->listext.opcode[i].print(ctx, &n[1]);
5304 n += ctx->listext.opcode[i].size;
5305 } else {
5306 switch (opcode) {
5307 case OPCODE_ACCUM:
5308 fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f );
5309 break;
5310 case OPCODE_BITMAP:
5311 fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
5312 n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
5313 break;
5314 case OPCODE_CALL_LIST:
5315 fprintf(f,"CallList %d\n", (int) n[1].ui );
5316 break;
5317 case OPCODE_CALL_LIST_OFFSET:
5318 fprintf(f,"CallList %d + offset %u = %u\n", (int) n[1].ui,
5319 ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
5320 break;
5321 case OPCODE_COLOR_TABLE_PARAMETER_FV:
5322 fprintf(f,"ColorTableParameterfv %s %s %f %f %f %f\n",
5323 enum_string(n[1].e), enum_string(n[2].e),
5324 n[3].f, n[4].f, n[5].f, n[6].f);
5325 break;
5326 case OPCODE_COLOR_TABLE_PARAMETER_IV:
5327 fprintf(f,"ColorTableParameteriv %s %s %d %d %d %d\n",
5328 enum_string(n[1].e), enum_string(n[2].e),
5329 n[3].i, n[4].i, n[5].i, n[6].i);
5330 break;
5331 case OPCODE_DISABLE:
5332 fprintf(f,"Disable %s\n", enum_string(n[1].e));
5333 break;
5334 case OPCODE_ENABLE:
5335 fprintf(f,"Enable %s\n", enum_string(n[1].e));
5336 break;
5337 case OPCODE_FRUSTUM:
5338 fprintf(f,"Frustum %g %g %g %g %g %g\n",
5339 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
5340 break;
5341 case OPCODE_LINE_STIPPLE:
5342 fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us );
5343 break;
5344 case OPCODE_LOAD_IDENTITY:
5345 fprintf(f,"LoadIdentity\n");
5346 break;
5347 case OPCODE_LOAD_MATRIX:
5348 fprintf(f,"LoadMatrix\n");
5349 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
5350 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
5351 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
5352 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
5353 break;
5354 case OPCODE_MULT_MATRIX:
5355 fprintf(f,"MultMatrix (or Rotate)\n");
5356 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
5357 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
5358 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
5359 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
5360 break;
5361 case OPCODE_ORTHO:
5362 fprintf(f,"Ortho %g %g %g %g %g %g\n",
5363 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
5364 break;
5365 case OPCODE_POP_ATTRIB:
5366 fprintf(f,"PopAttrib\n");
5367 break;
5368 case OPCODE_POP_MATRIX:
5369 fprintf(f,"PopMatrix\n");
5370 break;
5371 case OPCODE_POP_NAME:
5372 fprintf(f,"PopName\n");
5373 break;
5374 case OPCODE_PUSH_ATTRIB:
5375 fprintf(f,"PushAttrib %x\n", n[1].bf );
5376 break;
5377 case OPCODE_PUSH_MATRIX:
5378 fprintf(f,"PushMatrix\n");
5379 break;
5380 case OPCODE_PUSH_NAME:
5381 fprintf(f,"PushName %d\n", (int) n[1].ui );
5382 break;
5383 case OPCODE_RASTER_POS:
5384 fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f);
5385 break;
5386 case OPCODE_ROTATE:
5387 fprintf(f,"Rotate %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f );
5388 break;
5389 case OPCODE_SCALE:
5390 fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
5391 break;
5392 case OPCODE_TRANSLATE:
5393 fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
5394 break;
5395 case OPCODE_BIND_TEXTURE:
5396 fprintf(f,"BindTexture %s %d\n", gl_lookup_enum_by_nr(n[1].ui),
5397 n[2].ui);
5398 break;
5399 case OPCODE_SHADE_MODEL:
5400 fprintf(f,"ShadeModel %s\n", gl_lookup_enum_by_nr(n[1].ui));
5401 break;
5402
5403 /*
5404 * meta opcodes/commands
5405 */
5406 case OPCODE_ERROR:
5407 fprintf(f,"Error: %s %s\n", enum_string(n[1].e), (const char *)n[2].data );
5408 break;
5409 case OPCODE_CONTINUE:
5410 fprintf(f,"DISPLAY-LIST-CONTINUE\n");
5411 n = (Node *) n[1].next;
5412 break;
5413 case OPCODE_END_OF_LIST:
5414 fprintf(f,"END-LIST %u\n", list);
5415 done = GL_TRUE;
5416 break;
5417 default:
5418 if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
5419 fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
5420 opcode, (void*) n);
5421 return;
5422 }
5423 else {
5424 fprintf(f,"command %d, %u operands\n",opcode,InstSize[opcode]);
5425 }
5426 }
5427 /* increment n to point to next compiled command */
5428 if (opcode!=OPCODE_CONTINUE) {
5429 n += InstSize[opcode];
5430 }
5431 }
5432 }
5433 }
5434
5435
5436
5437 /*
5438 * Clients may call this function to help debug display list problems.
5439 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
5440 * changed, or break in the future without notice.
5441 */
5442 void mesa_print_display_list( GLuint list )
5443 {
5444 GET_CURRENT_CONTEXT(ctx);
5445 print_list( ctx, stderr, list );
5446 }