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