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