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