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