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