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