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