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