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