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