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