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