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