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