mesa: move assertions in test_attachment_completeness()
[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 num, 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 < num; 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, (num, 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 GLfloat parray[4];
1887 parray[0] = param;
1888 parray[1] = parray[2] = parray[3] = 0.0F;
1889 save_Fogfv(pname, parray);
1890 }
1891
1892
1893 static void GLAPIENTRY
1894 save_Fogiv(GLenum pname, const GLint *params)
1895 {
1896 GLfloat p[4];
1897 switch (pname) {
1898 case GL_FOG_MODE:
1899 case GL_FOG_DENSITY:
1900 case GL_FOG_START:
1901 case GL_FOG_END:
1902 case GL_FOG_INDEX:
1903 p[0] = (GLfloat) *params;
1904 break;
1905 case GL_FOG_COLOR:
1906 p[0] = INT_TO_FLOAT(params[0]);
1907 p[1] = INT_TO_FLOAT(params[1]);
1908 p[2] = INT_TO_FLOAT(params[2]);
1909 p[3] = INT_TO_FLOAT(params[3]);
1910 break;
1911 default:
1912 /* Error will be caught later in gl_Fogfv */
1913 ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F);
1914 }
1915 save_Fogfv(pname, p);
1916 }
1917
1918
1919 static void GLAPIENTRY
1920 save_Fogi(GLenum pname, GLint param)
1921 {
1922 GLint parray[4];
1923 parray[0] = param;
1924 parray[1] = parray[2] = parray[3] = 0;
1925 save_Fogiv(pname, parray);
1926 }
1927
1928
1929 static void GLAPIENTRY
1930 save_FrontFace(GLenum mode)
1931 {
1932 GET_CURRENT_CONTEXT(ctx);
1933 Node *n;
1934 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1935 n = ALLOC_INSTRUCTION(ctx, OPCODE_FRONT_FACE, 1);
1936 if (n) {
1937 n[1].e = mode;
1938 }
1939 if (ctx->ExecuteFlag) {
1940 CALL_FrontFace(ctx->Exec, (mode));
1941 }
1942 }
1943
1944
1945 static void GLAPIENTRY
1946 save_Frustum(GLdouble left, GLdouble right,
1947 GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
1948 {
1949 GET_CURRENT_CONTEXT(ctx);
1950 Node *n;
1951 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1952 n = ALLOC_INSTRUCTION(ctx, OPCODE_FRUSTUM, 6);
1953 if (n) {
1954 n[1].f = (GLfloat) left;
1955 n[2].f = (GLfloat) right;
1956 n[3].f = (GLfloat) bottom;
1957 n[4].f = (GLfloat) top;
1958 n[5].f = (GLfloat) nearval;
1959 n[6].f = (GLfloat) farval;
1960 }
1961 if (ctx->ExecuteFlag) {
1962 CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval));
1963 }
1964 }
1965
1966
1967 static void GLAPIENTRY
1968 save_Hint(GLenum target, GLenum mode)
1969 {
1970 GET_CURRENT_CONTEXT(ctx);
1971 Node *n;
1972 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1973 n = ALLOC_INSTRUCTION(ctx, OPCODE_HINT, 2);
1974 if (n) {
1975 n[1].e = target;
1976 n[2].e = mode;
1977 }
1978 if (ctx->ExecuteFlag) {
1979 CALL_Hint(ctx->Exec, (target, mode));
1980 }
1981 }
1982
1983
1984 static void GLAPIENTRY
1985 save_Histogram(GLenum target, GLsizei width, GLenum internalFormat,
1986 GLboolean sink)
1987 {
1988 GET_CURRENT_CONTEXT(ctx);
1989 Node *n;
1990
1991 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1992 n = ALLOC_INSTRUCTION(ctx, OPCODE_HISTOGRAM, 4);
1993 if (n) {
1994 n[1].e = target;
1995 n[2].i = width;
1996 n[3].e = internalFormat;
1997 n[4].b = sink;
1998 }
1999 if (ctx->ExecuteFlag) {
2000 CALL_Histogram(ctx->Exec, (target, width, internalFormat, sink));
2001 }
2002 }
2003
2004
2005 static void GLAPIENTRY
2006 save_IndexMask(GLuint mask)
2007 {
2008 GET_CURRENT_CONTEXT(ctx);
2009 Node *n;
2010 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2011 n = ALLOC_INSTRUCTION(ctx, OPCODE_INDEX_MASK, 1);
2012 if (n) {
2013 n[1].ui = mask;
2014 }
2015 if (ctx->ExecuteFlag) {
2016 CALL_IndexMask(ctx->Exec, (mask));
2017 }
2018 }
2019
2020
2021 static void GLAPIENTRY
2022 save_InitNames(void)
2023 {
2024 GET_CURRENT_CONTEXT(ctx);
2025 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2026 (void) ALLOC_INSTRUCTION(ctx, OPCODE_INIT_NAMES, 0);
2027 if (ctx->ExecuteFlag) {
2028 CALL_InitNames(ctx->Exec, ());
2029 }
2030 }
2031
2032
2033 static void GLAPIENTRY
2034 save_Lightfv(GLenum light, GLenum pname, const GLfloat *params)
2035 {
2036 GET_CURRENT_CONTEXT(ctx);
2037 Node *n;
2038 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2039 n = ALLOC_INSTRUCTION(ctx, OPCODE_LIGHT, 6);
2040 if (n) {
2041 GLint i, nParams;
2042 n[1].e = light;
2043 n[2].e = pname;
2044 switch (pname) {
2045 case GL_AMBIENT:
2046 nParams = 4;
2047 break;
2048 case GL_DIFFUSE:
2049 nParams = 4;
2050 break;
2051 case GL_SPECULAR:
2052 nParams = 4;
2053 break;
2054 case GL_POSITION:
2055 nParams = 4;
2056 break;
2057 case GL_SPOT_DIRECTION:
2058 nParams = 3;
2059 break;
2060 case GL_SPOT_EXPONENT:
2061 nParams = 1;
2062 break;
2063 case GL_SPOT_CUTOFF:
2064 nParams = 1;
2065 break;
2066 case GL_CONSTANT_ATTENUATION:
2067 nParams = 1;
2068 break;
2069 case GL_LINEAR_ATTENUATION:
2070 nParams = 1;
2071 break;
2072 case GL_QUADRATIC_ATTENUATION:
2073 nParams = 1;
2074 break;
2075 default:
2076 nParams = 0;
2077 }
2078 for (i = 0; i < nParams; i++) {
2079 n[3 + i].f = params[i];
2080 }
2081 }
2082 if (ctx->ExecuteFlag) {
2083 CALL_Lightfv(ctx->Exec, (light, pname, params));
2084 }
2085 }
2086
2087
2088 static void GLAPIENTRY
2089 save_Lightf(GLenum light, GLenum pname, GLfloat param)
2090 {
2091 GLfloat parray[4];
2092 parray[0] = param;
2093 parray[1] = parray[2] = parray[3] = 0.0F;
2094 save_Lightfv(light, pname, parray);
2095 }
2096
2097
2098 static void GLAPIENTRY
2099 save_Lightiv(GLenum light, GLenum pname, const GLint *params)
2100 {
2101 GLfloat fparam[4];
2102 switch (pname) {
2103 case GL_AMBIENT:
2104 case GL_DIFFUSE:
2105 case GL_SPECULAR:
2106 fparam[0] = INT_TO_FLOAT(params[0]);
2107 fparam[1] = INT_TO_FLOAT(params[1]);
2108 fparam[2] = INT_TO_FLOAT(params[2]);
2109 fparam[3] = INT_TO_FLOAT(params[3]);
2110 break;
2111 case GL_POSITION:
2112 fparam[0] = (GLfloat) params[0];
2113 fparam[1] = (GLfloat) params[1];
2114 fparam[2] = (GLfloat) params[2];
2115 fparam[3] = (GLfloat) params[3];
2116 break;
2117 case GL_SPOT_DIRECTION:
2118 fparam[0] = (GLfloat) params[0];
2119 fparam[1] = (GLfloat) params[1];
2120 fparam[2] = (GLfloat) params[2];
2121 break;
2122 case GL_SPOT_EXPONENT:
2123 case GL_SPOT_CUTOFF:
2124 case GL_CONSTANT_ATTENUATION:
2125 case GL_LINEAR_ATTENUATION:
2126 case GL_QUADRATIC_ATTENUATION:
2127 fparam[0] = (GLfloat) params[0];
2128 break;
2129 default:
2130 /* error will be caught later in gl_Lightfv */
2131 ;
2132 }
2133 save_Lightfv(light, pname, fparam);
2134 }
2135
2136
2137 static void GLAPIENTRY
2138 save_Lighti(GLenum light, GLenum pname, GLint param)
2139 {
2140 GLint parray[4];
2141 parray[0] = param;
2142 parray[1] = parray[2] = parray[3] = 0;
2143 save_Lightiv(light, pname, parray);
2144 }
2145
2146
2147 static void GLAPIENTRY
2148 save_LightModelfv(GLenum pname, const GLfloat *params)
2149 {
2150 GET_CURRENT_CONTEXT(ctx);
2151 Node *n;
2152 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2153 n = ALLOC_INSTRUCTION(ctx, OPCODE_LIGHT_MODEL, 5);
2154 if (n) {
2155 n[1].e = pname;
2156 n[2].f = params[0];
2157 n[3].f = params[1];
2158 n[4].f = params[2];
2159 n[5].f = params[3];
2160 }
2161 if (ctx->ExecuteFlag) {
2162 CALL_LightModelfv(ctx->Exec, (pname, params));
2163 }
2164 }
2165
2166
2167 static void GLAPIENTRY
2168 save_LightModelf(GLenum pname, GLfloat param)
2169 {
2170 GLfloat parray[4];
2171 parray[0] = param;
2172 parray[1] = parray[2] = parray[3] = 0.0F;
2173 save_LightModelfv(pname, parray);
2174 }
2175
2176
2177 static void GLAPIENTRY
2178 save_LightModeliv(GLenum pname, const GLint *params)
2179 {
2180 GLfloat fparam[4];
2181 switch (pname) {
2182 case GL_LIGHT_MODEL_AMBIENT:
2183 fparam[0] = INT_TO_FLOAT(params[0]);
2184 fparam[1] = INT_TO_FLOAT(params[1]);
2185 fparam[2] = INT_TO_FLOAT(params[2]);
2186 fparam[3] = INT_TO_FLOAT(params[3]);
2187 break;
2188 case GL_LIGHT_MODEL_LOCAL_VIEWER:
2189 case GL_LIGHT_MODEL_TWO_SIDE:
2190 case GL_LIGHT_MODEL_COLOR_CONTROL:
2191 fparam[0] = (GLfloat) params[0];
2192 break;
2193 default:
2194 /* Error will be caught later in gl_LightModelfv */
2195 ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F);
2196 }
2197 save_LightModelfv(pname, fparam);
2198 }
2199
2200
2201 static void GLAPIENTRY
2202 save_LightModeli(GLenum pname, GLint param)
2203 {
2204 GLint parray[4];
2205 parray[0] = param;
2206 parray[1] = parray[2] = parray[3] = 0;
2207 save_LightModeliv(pname, parray);
2208 }
2209
2210
2211 static void GLAPIENTRY
2212 save_LineStipple(GLint factor, GLushort pattern)
2213 {
2214 GET_CURRENT_CONTEXT(ctx);
2215 Node *n;
2216 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2217 n = ALLOC_INSTRUCTION(ctx, OPCODE_LINE_STIPPLE, 2);
2218 if (n) {
2219 n[1].i = factor;
2220 n[2].us = pattern;
2221 }
2222 if (ctx->ExecuteFlag) {
2223 CALL_LineStipple(ctx->Exec, (factor, pattern));
2224 }
2225 }
2226
2227
2228 static void GLAPIENTRY
2229 save_LineWidth(GLfloat width)
2230 {
2231 GET_CURRENT_CONTEXT(ctx);
2232 Node *n;
2233 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2234 n = ALLOC_INSTRUCTION(ctx, OPCODE_LINE_WIDTH, 1);
2235 if (n) {
2236 n[1].f = width;
2237 }
2238 if (ctx->ExecuteFlag) {
2239 CALL_LineWidth(ctx->Exec, (width));
2240 }
2241 }
2242
2243
2244 static void GLAPIENTRY
2245 save_ListBase(GLuint base)
2246 {
2247 GET_CURRENT_CONTEXT(ctx);
2248 Node *n;
2249 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2250 n = ALLOC_INSTRUCTION(ctx, OPCODE_LIST_BASE, 1);
2251 if (n) {
2252 n[1].ui = base;
2253 }
2254 if (ctx->ExecuteFlag) {
2255 CALL_ListBase(ctx->Exec, (base));
2256 }
2257 }
2258
2259
2260 static void GLAPIENTRY
2261 save_LoadIdentity(void)
2262 {
2263 GET_CURRENT_CONTEXT(ctx);
2264 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2265 (void) ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_IDENTITY, 0);
2266 if (ctx->ExecuteFlag) {
2267 CALL_LoadIdentity(ctx->Exec, ());
2268 }
2269 }
2270
2271
2272 static void GLAPIENTRY
2273 save_LoadMatrixf(const GLfloat * m)
2274 {
2275 GET_CURRENT_CONTEXT(ctx);
2276 Node *n;
2277 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2278 n = ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_MATRIX, 16);
2279 if (n) {
2280 GLuint i;
2281 for (i = 0; i < 16; i++) {
2282 n[1 + i].f = m[i];
2283 }
2284 }
2285 if (ctx->ExecuteFlag) {
2286 CALL_LoadMatrixf(ctx->Exec, (m));
2287 }
2288 }
2289
2290
2291 static void GLAPIENTRY
2292 save_LoadMatrixd(const GLdouble * m)
2293 {
2294 GLfloat f[16];
2295 GLint i;
2296 for (i = 0; i < 16; i++) {
2297 f[i] = (GLfloat) m[i];
2298 }
2299 save_LoadMatrixf(f);
2300 }
2301
2302
2303 static void GLAPIENTRY
2304 save_LoadName(GLuint name)
2305 {
2306 GET_CURRENT_CONTEXT(ctx);
2307 Node *n;
2308 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2309 n = ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_NAME, 1);
2310 if (n) {
2311 n[1].ui = name;
2312 }
2313 if (ctx->ExecuteFlag) {
2314 CALL_LoadName(ctx->Exec, (name));
2315 }
2316 }
2317
2318
2319 static void GLAPIENTRY
2320 save_LogicOp(GLenum opcode)
2321 {
2322 GET_CURRENT_CONTEXT(ctx);
2323 Node *n;
2324 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2325 n = ALLOC_INSTRUCTION(ctx, OPCODE_LOGIC_OP, 1);
2326 if (n) {
2327 n[1].e = opcode;
2328 }
2329 if (ctx->ExecuteFlag) {
2330 CALL_LogicOp(ctx->Exec, (opcode));
2331 }
2332 }
2333
2334
2335 static void GLAPIENTRY
2336 save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
2337 GLint order, const GLdouble * points)
2338 {
2339 GET_CURRENT_CONTEXT(ctx);
2340 Node *n;
2341 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2342 n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP1, 6);
2343 if (n) {
2344 GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points);
2345 n[1].e = target;
2346 n[2].f = (GLfloat) u1;
2347 n[3].f = (GLfloat) u2;
2348 n[4].i = _mesa_evaluator_components(target); /* stride */
2349 n[5].i = order;
2350 n[6].data = (void *) pnts;
2351 }
2352 if (ctx->ExecuteFlag) {
2353 CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points));
2354 }
2355 }
2356
2357 static void GLAPIENTRY
2358 save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
2359 GLint order, const GLfloat * points)
2360 {
2361 GET_CURRENT_CONTEXT(ctx);
2362 Node *n;
2363 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2364 n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP1, 6);
2365 if (n) {
2366 GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points);
2367 n[1].e = target;
2368 n[2].f = u1;
2369 n[3].f = u2;
2370 n[4].i = _mesa_evaluator_components(target); /* stride */
2371 n[5].i = order;
2372 n[6].data = (void *) pnts;
2373 }
2374 if (ctx->ExecuteFlag) {
2375 CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points));
2376 }
2377 }
2378
2379
2380 static void GLAPIENTRY
2381 save_Map2d(GLenum target,
2382 GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
2383 GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
2384 const GLdouble * points)
2385 {
2386 GET_CURRENT_CONTEXT(ctx);
2387 Node *n;
2388 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2389 n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP2, 10);
2390 if (n) {
2391 GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder,
2392 vstride, vorder, points);
2393 n[1].e = target;
2394 n[2].f = (GLfloat) u1;
2395 n[3].f = (GLfloat) u2;
2396 n[4].f = (GLfloat) v1;
2397 n[5].f = (GLfloat) v2;
2398 /* XXX verify these strides are correct */
2399 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */
2400 n[7].i = _mesa_evaluator_components(target); /*vstride */
2401 n[8].i = uorder;
2402 n[9].i = vorder;
2403 n[10].data = (void *) pnts;
2404 }
2405 if (ctx->ExecuteFlag) {
2406 CALL_Map2d(ctx->Exec, (target,
2407 u1, u2, ustride, uorder,
2408 v1, v2, vstride, vorder, points));
2409 }
2410 }
2411
2412
2413 static void GLAPIENTRY
2414 save_Map2f(GLenum target,
2415 GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
2416 GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
2417 const GLfloat * points)
2418 {
2419 GET_CURRENT_CONTEXT(ctx);
2420 Node *n;
2421 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2422 n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP2, 10);
2423 if (n) {
2424 GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder,
2425 vstride, vorder, points);
2426 n[1].e = target;
2427 n[2].f = u1;
2428 n[3].f = u2;
2429 n[4].f = v1;
2430 n[5].f = v2;
2431 /* XXX verify these strides are correct */
2432 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */
2433 n[7].i = _mesa_evaluator_components(target); /*vstride */
2434 n[8].i = uorder;
2435 n[9].i = vorder;
2436 n[10].data = (void *) pnts;
2437 }
2438 if (ctx->ExecuteFlag) {
2439 CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
2440 v1, v2, vstride, vorder, points));
2441 }
2442 }
2443
2444
2445 static void GLAPIENTRY
2446 save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2)
2447 {
2448 GET_CURRENT_CONTEXT(ctx);
2449 Node *n;
2450 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2451 n = ALLOC_INSTRUCTION(ctx, OPCODE_MAPGRID1, 3);
2452 if (n) {
2453 n[1].i = un;
2454 n[2].f = u1;
2455 n[3].f = u2;
2456 }
2457 if (ctx->ExecuteFlag) {
2458 CALL_MapGrid1f(ctx->Exec, (un, u1, u2));
2459 }
2460 }
2461
2462
2463 static void GLAPIENTRY
2464 save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2)
2465 {
2466 save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
2467 }
2468
2469
2470 static void GLAPIENTRY
2471 save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2,
2472 GLint vn, GLfloat v1, GLfloat v2)
2473 {
2474 GET_CURRENT_CONTEXT(ctx);
2475 Node *n;
2476 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2477 n = ALLOC_INSTRUCTION(ctx, OPCODE_MAPGRID2, 6);
2478 if (n) {
2479 n[1].i = un;
2480 n[2].f = u1;
2481 n[3].f = u2;
2482 n[4].i = vn;
2483 n[5].f = v1;
2484 n[6].f = v2;
2485 }
2486 if (ctx->ExecuteFlag) {
2487 CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2));
2488 }
2489 }
2490
2491
2492
2493 static void GLAPIENTRY
2494 save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2,
2495 GLint vn, GLdouble v1, GLdouble v2)
2496 {
2497 save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2,
2498 vn, (GLfloat) v1, (GLfloat) v2);
2499 }
2500
2501
2502 static void GLAPIENTRY
2503 save_MatrixMode(GLenum mode)
2504 {
2505 GET_CURRENT_CONTEXT(ctx);
2506 Node *n;
2507 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2508 n = ALLOC_INSTRUCTION(ctx, OPCODE_MATRIX_MODE, 1);
2509 if (n) {
2510 n[1].e = mode;
2511 }
2512 if (ctx->ExecuteFlag) {
2513 CALL_MatrixMode(ctx->Exec, (mode));
2514 }
2515 }
2516
2517
2518 static void GLAPIENTRY
2519 save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
2520 {
2521 GET_CURRENT_CONTEXT(ctx);
2522 Node *n;
2523
2524 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2525 n = ALLOC_INSTRUCTION(ctx, OPCODE_MIN_MAX, 3);
2526 if (n) {
2527 n[1].e = target;
2528 n[2].e = internalFormat;
2529 n[3].b = sink;
2530 }
2531 if (ctx->ExecuteFlag) {
2532 CALL_Minmax(ctx->Exec, (target, internalFormat, sink));
2533 }
2534 }
2535
2536
2537 static void GLAPIENTRY
2538 save_MultMatrixf(const GLfloat * m)
2539 {
2540 GET_CURRENT_CONTEXT(ctx);
2541 Node *n;
2542 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2543 n = ALLOC_INSTRUCTION(ctx, OPCODE_MULT_MATRIX, 16);
2544 if (n) {
2545 GLuint i;
2546 for (i = 0; i < 16; i++) {
2547 n[1 + i].f = m[i];
2548 }
2549 }
2550 if (ctx->ExecuteFlag) {
2551 CALL_MultMatrixf(ctx->Exec, (m));
2552 }
2553 }
2554
2555
2556 static void GLAPIENTRY
2557 save_MultMatrixd(const GLdouble * m)
2558 {
2559 GLfloat f[16];
2560 GLint i;
2561 for (i = 0; i < 16; i++) {
2562 f[i] = (GLfloat) m[i];
2563 }
2564 save_MultMatrixf(f);
2565 }
2566
2567
2568 static void GLAPIENTRY
2569 save_NewList(GLuint name, GLenum mode)
2570 {
2571 GET_CURRENT_CONTEXT(ctx);
2572 /* It's an error to call this function while building a display list */
2573 _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
2574 (void) name;
2575 (void) mode;
2576 }
2577
2578
2579
2580 static void GLAPIENTRY
2581 save_Ortho(GLdouble left, GLdouble right,
2582 GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
2583 {
2584 GET_CURRENT_CONTEXT(ctx);
2585 Node *n;
2586 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2587 n = ALLOC_INSTRUCTION(ctx, OPCODE_ORTHO, 6);
2588 if (n) {
2589 n[1].f = (GLfloat) left;
2590 n[2].f = (GLfloat) right;
2591 n[3].f = (GLfloat) bottom;
2592 n[4].f = (GLfloat) top;
2593 n[5].f = (GLfloat) nearval;
2594 n[6].f = (GLfloat) farval;
2595 }
2596 if (ctx->ExecuteFlag) {
2597 CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval));
2598 }
2599 }
2600
2601
2602 static void GLAPIENTRY
2603 save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values)
2604 {
2605 GET_CURRENT_CONTEXT(ctx);
2606 Node *n;
2607 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2608 n = ALLOC_INSTRUCTION(ctx, OPCODE_PIXEL_MAP, 3);
2609 if (n) {
2610 n[1].e = map;
2611 n[2].i = mapsize;
2612 n[3].data = (void *) _mesa_malloc(mapsize * sizeof(GLfloat));
2613 MEMCPY(n[3].data, (void *) values, mapsize * sizeof(GLfloat));
2614 }
2615 if (ctx->ExecuteFlag) {
2616 CALL_PixelMapfv(ctx->Exec, (map, mapsize, values));
2617 }
2618 }
2619
2620
2621 static void GLAPIENTRY
2622 save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values)
2623 {
2624 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2625 GLint i;
2626 if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
2627 for (i = 0; i < mapsize; i++) {
2628 fvalues[i] = (GLfloat) values[i];
2629 }
2630 }
2631 else {
2632 for (i = 0; i < mapsize; i++) {
2633 fvalues[i] = UINT_TO_FLOAT(values[i]);
2634 }
2635 }
2636 save_PixelMapfv(map, mapsize, fvalues);
2637 }
2638
2639
2640 static void GLAPIENTRY
2641 save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
2642 {
2643 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2644 GLint i;
2645 if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
2646 for (i = 0; i < mapsize; i++) {
2647 fvalues[i] = (GLfloat) values[i];
2648 }
2649 }
2650 else {
2651 for (i = 0; i < mapsize; i++) {
2652 fvalues[i] = USHORT_TO_FLOAT(values[i]);
2653 }
2654 }
2655 save_PixelMapfv(map, mapsize, fvalues);
2656 }
2657
2658
2659 static void GLAPIENTRY
2660 save_PixelTransferf(GLenum pname, GLfloat param)
2661 {
2662 GET_CURRENT_CONTEXT(ctx);
2663 Node *n;
2664 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2665 n = ALLOC_INSTRUCTION(ctx, OPCODE_PIXEL_TRANSFER, 2);
2666 if (n) {
2667 n[1].e = pname;
2668 n[2].f = param;
2669 }
2670 if (ctx->ExecuteFlag) {
2671 CALL_PixelTransferf(ctx->Exec, (pname, param));
2672 }
2673 }
2674
2675
2676 static void GLAPIENTRY
2677 save_PixelTransferi(GLenum pname, GLint param)
2678 {
2679 save_PixelTransferf(pname, (GLfloat) param);
2680 }
2681
2682
2683 static void GLAPIENTRY
2684 save_PixelZoom(GLfloat xfactor, GLfloat yfactor)
2685 {
2686 GET_CURRENT_CONTEXT(ctx);
2687 Node *n;
2688 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2689 n = ALLOC_INSTRUCTION(ctx, OPCODE_PIXEL_ZOOM, 2);
2690 if (n) {
2691 n[1].f = xfactor;
2692 n[2].f = yfactor;
2693 }
2694 if (ctx->ExecuteFlag) {
2695 CALL_PixelZoom(ctx->Exec, (xfactor, yfactor));
2696 }
2697 }
2698
2699
2700 static void GLAPIENTRY
2701 save_PointParameterfvEXT(GLenum pname, const GLfloat *params)
2702 {
2703 GET_CURRENT_CONTEXT(ctx);
2704 Node *n;
2705 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2706 n = ALLOC_INSTRUCTION(ctx, OPCODE_POINT_PARAMETERS, 4);
2707 if (n) {
2708 n[1].e = pname;
2709 n[2].f = params[0];
2710 n[3].f = params[1];
2711 n[4].f = params[2];
2712 }
2713 if (ctx->ExecuteFlag) {
2714 CALL_PointParameterfvEXT(ctx->Exec, (pname, params));
2715 }
2716 }
2717
2718
2719 static void GLAPIENTRY
2720 save_PointParameterfEXT(GLenum pname, GLfloat param)
2721 {
2722 GLfloat parray[3];
2723 parray[0] = param;
2724 parray[1] = parray[2] = 0.0F;
2725 save_PointParameterfvEXT(pname, parray);
2726 }
2727
2728 static void GLAPIENTRY
2729 save_PointParameteriNV(GLenum pname, GLint param)
2730 {
2731 GLfloat parray[3];
2732 parray[0] = (GLfloat) param;
2733 parray[1] = parray[2] = 0.0F;
2734 save_PointParameterfvEXT(pname, parray);
2735 }
2736
2737 static void GLAPIENTRY
2738 save_PointParameterivNV(GLenum pname, const GLint * param)
2739 {
2740 GLfloat parray[3];
2741 parray[0] = (GLfloat) param[0];
2742 parray[1] = parray[2] = 0.0F;
2743 save_PointParameterfvEXT(pname, parray);
2744 }
2745
2746
2747 static void GLAPIENTRY
2748 save_PointSize(GLfloat size)
2749 {
2750 GET_CURRENT_CONTEXT(ctx);
2751 Node *n;
2752 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2753 n = ALLOC_INSTRUCTION(ctx, OPCODE_POINT_SIZE, 1);
2754 if (n) {
2755 n[1].f = size;
2756 }
2757 if (ctx->ExecuteFlag) {
2758 CALL_PointSize(ctx->Exec, (size));
2759 }
2760 }
2761
2762
2763 static void GLAPIENTRY
2764 save_PolygonMode(GLenum face, GLenum mode)
2765 {
2766 GET_CURRENT_CONTEXT(ctx);
2767 Node *n;
2768 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2769 n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_MODE, 2);
2770 if (n) {
2771 n[1].e = face;
2772 n[2].e = mode;
2773 }
2774 if (ctx->ExecuteFlag) {
2775 CALL_PolygonMode(ctx->Exec, (face, mode));
2776 }
2777 }
2778
2779
2780 static void GLAPIENTRY
2781 save_PolygonStipple(const GLubyte * pattern)
2782 {
2783 GET_CURRENT_CONTEXT(ctx);
2784 Node *n;
2785
2786 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2787
2788 n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_STIPPLE, 1);
2789 if (n) {
2790 n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP,
2791 pattern, &ctx->Unpack);
2792 }
2793 if (ctx->ExecuteFlag) {
2794 CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern));
2795 }
2796 }
2797
2798
2799 static void GLAPIENTRY
2800 save_PolygonOffset(GLfloat factor, GLfloat units)
2801 {
2802 GET_CURRENT_CONTEXT(ctx);
2803 Node *n;
2804 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2805 n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_OFFSET, 2);
2806 if (n) {
2807 n[1].f = factor;
2808 n[2].f = units;
2809 }
2810 if (ctx->ExecuteFlag) {
2811 CALL_PolygonOffset(ctx->Exec, (factor, units));
2812 }
2813 }
2814
2815
2816 static void GLAPIENTRY
2817 save_PolygonOffsetEXT(GLfloat factor, GLfloat bias)
2818 {
2819 GET_CURRENT_CONTEXT(ctx);
2820 /* XXX mult by DepthMaxF here??? */
2821 save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias);
2822 }
2823
2824
2825 static void GLAPIENTRY
2826 save_PopAttrib(void)
2827 {
2828 GET_CURRENT_CONTEXT(ctx);
2829 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2830 (void) ALLOC_INSTRUCTION(ctx, OPCODE_POP_ATTRIB, 0);
2831 if (ctx->ExecuteFlag) {
2832 CALL_PopAttrib(ctx->Exec, ());
2833 }
2834 }
2835
2836
2837 static void GLAPIENTRY
2838 save_PopMatrix(void)
2839 {
2840 GET_CURRENT_CONTEXT(ctx);
2841 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2842 (void) ALLOC_INSTRUCTION(ctx, OPCODE_POP_MATRIX, 0);
2843 if (ctx->ExecuteFlag) {
2844 CALL_PopMatrix(ctx->Exec, ());
2845 }
2846 }
2847
2848
2849 static void GLAPIENTRY
2850 save_PopName(void)
2851 {
2852 GET_CURRENT_CONTEXT(ctx);
2853 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2854 (void) ALLOC_INSTRUCTION(ctx, OPCODE_POP_NAME, 0);
2855 if (ctx->ExecuteFlag) {
2856 CALL_PopName(ctx->Exec, ());
2857 }
2858 }
2859
2860
2861 static void GLAPIENTRY
2862 save_PrioritizeTextures(GLsizei num, const GLuint * textures,
2863 const GLclampf * priorities)
2864 {
2865 GET_CURRENT_CONTEXT(ctx);
2866 GLint i;
2867 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2868
2869 for (i = 0; i < num; i++) {
2870 Node *n;
2871 n = ALLOC_INSTRUCTION(ctx, OPCODE_PRIORITIZE_TEXTURE, 2);
2872 if (n) {
2873 n[1].ui = textures[i];
2874 n[2].f = priorities[i];
2875 }
2876 }
2877 if (ctx->ExecuteFlag) {
2878 CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities));
2879 }
2880 }
2881
2882
2883 static void GLAPIENTRY
2884 save_PushAttrib(GLbitfield mask)
2885 {
2886 GET_CURRENT_CONTEXT(ctx);
2887 Node *n;
2888 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2889 n = ALLOC_INSTRUCTION(ctx, OPCODE_PUSH_ATTRIB, 1);
2890 if (n) {
2891 n[1].bf = mask;
2892 }
2893 if (ctx->ExecuteFlag) {
2894 CALL_PushAttrib(ctx->Exec, (mask));
2895 }
2896 }
2897
2898
2899 static void GLAPIENTRY
2900 save_PushMatrix(void)
2901 {
2902 GET_CURRENT_CONTEXT(ctx);
2903 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2904 (void) ALLOC_INSTRUCTION(ctx, OPCODE_PUSH_MATRIX, 0);
2905 if (ctx->ExecuteFlag) {
2906 CALL_PushMatrix(ctx->Exec, ());
2907 }
2908 }
2909
2910
2911 static void GLAPIENTRY
2912 save_PushName(GLuint name)
2913 {
2914 GET_CURRENT_CONTEXT(ctx);
2915 Node *n;
2916 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2917 n = ALLOC_INSTRUCTION(ctx, OPCODE_PUSH_NAME, 1);
2918 if (n) {
2919 n[1].ui = name;
2920 }
2921 if (ctx->ExecuteFlag) {
2922 CALL_PushName(ctx->Exec, (name));
2923 }
2924 }
2925
2926
2927 static void GLAPIENTRY
2928 save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
2929 {
2930 GET_CURRENT_CONTEXT(ctx);
2931 Node *n;
2932 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2933 n = ALLOC_INSTRUCTION(ctx, OPCODE_RASTER_POS, 4);
2934 if (n) {
2935 n[1].f = x;
2936 n[2].f = y;
2937 n[3].f = z;
2938 n[4].f = w;
2939 }
2940 if (ctx->ExecuteFlag) {
2941 CALL_RasterPos4f(ctx->Exec, (x, y, z, w));
2942 }
2943 }
2944
2945 static void GLAPIENTRY
2946 save_RasterPos2d(GLdouble x, GLdouble y)
2947 {
2948 save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
2949 }
2950
2951 static void GLAPIENTRY
2952 save_RasterPos2f(GLfloat x, GLfloat y)
2953 {
2954 save_RasterPos4f(x, y, 0.0F, 1.0F);
2955 }
2956
2957 static void GLAPIENTRY
2958 save_RasterPos2i(GLint x, GLint y)
2959 {
2960 save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
2961 }
2962
2963 static void GLAPIENTRY
2964 save_RasterPos2s(GLshort x, GLshort y)
2965 {
2966 save_RasterPos4f(x, y, 0.0F, 1.0F);
2967 }
2968
2969 static void GLAPIENTRY
2970 save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
2971 {
2972 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
2973 }
2974
2975 static void GLAPIENTRY
2976 save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
2977 {
2978 save_RasterPos4f(x, y, z, 1.0F);
2979 }
2980
2981 static void GLAPIENTRY
2982 save_RasterPos3i(GLint x, GLint y, GLint z)
2983 {
2984 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
2985 }
2986
2987 static void GLAPIENTRY
2988 save_RasterPos3s(GLshort x, GLshort y, GLshort z)
2989 {
2990 save_RasterPos4f(x, y, z, 1.0F);
2991 }
2992
2993 static void GLAPIENTRY
2994 save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
2995 {
2996 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
2997 }
2998
2999 static void GLAPIENTRY
3000 save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
3001 {
3002 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3003 }
3004
3005 static void GLAPIENTRY
3006 save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
3007 {
3008 save_RasterPos4f(x, y, z, w);
3009 }
3010
3011 static void GLAPIENTRY
3012 save_RasterPos2dv(const GLdouble * v)
3013 {
3014 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3015 }
3016
3017 static void GLAPIENTRY
3018 save_RasterPos2fv(const GLfloat * v)
3019 {
3020 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
3021 }
3022
3023 static void GLAPIENTRY
3024 save_RasterPos2iv(const GLint * v)
3025 {
3026 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3027 }
3028
3029 static void GLAPIENTRY
3030 save_RasterPos2sv(const GLshort * v)
3031 {
3032 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
3033 }
3034
3035 static void GLAPIENTRY
3036 save_RasterPos3dv(const GLdouble * v)
3037 {
3038 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3039 }
3040
3041 static void GLAPIENTRY
3042 save_RasterPos3fv(const GLfloat * v)
3043 {
3044 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3045 }
3046
3047 static void GLAPIENTRY
3048 save_RasterPos3iv(const GLint * v)
3049 {
3050 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3051 }
3052
3053 static void GLAPIENTRY
3054 save_RasterPos3sv(const GLshort * v)
3055 {
3056 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3057 }
3058
3059 static void GLAPIENTRY
3060 save_RasterPos4dv(const GLdouble * v)
3061 {
3062 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3063 (GLfloat) v[2], (GLfloat) v[3]);
3064 }
3065
3066 static void GLAPIENTRY
3067 save_RasterPos4fv(const GLfloat * v)
3068 {
3069 save_RasterPos4f(v[0], v[1], v[2], v[3]);
3070 }
3071
3072 static void GLAPIENTRY
3073 save_RasterPos4iv(const GLint * v)
3074 {
3075 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3076 (GLfloat) v[2], (GLfloat) v[3]);
3077 }
3078
3079 static void GLAPIENTRY
3080 save_RasterPos4sv(const GLshort * v)
3081 {
3082 save_RasterPos4f(v[0], v[1], v[2], v[3]);
3083 }
3084
3085
3086 static void GLAPIENTRY
3087 save_PassThrough(GLfloat token)
3088 {
3089 GET_CURRENT_CONTEXT(ctx);
3090 Node *n;
3091 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3092 n = ALLOC_INSTRUCTION(ctx, OPCODE_PASSTHROUGH, 1);
3093 if (n) {
3094 n[1].f = token;
3095 }
3096 if (ctx->ExecuteFlag) {
3097 CALL_PassThrough(ctx->Exec, (token));
3098 }
3099 }
3100
3101
3102 static void GLAPIENTRY
3103 save_ReadBuffer(GLenum mode)
3104 {
3105 GET_CURRENT_CONTEXT(ctx);
3106 Node *n;
3107 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3108 n = ALLOC_INSTRUCTION(ctx, OPCODE_READ_BUFFER, 1);
3109 if (n) {
3110 n[1].e = mode;
3111 }
3112 if (ctx->ExecuteFlag) {
3113 CALL_ReadBuffer(ctx->Exec, (mode));
3114 }
3115 }
3116
3117
3118 static void GLAPIENTRY
3119 save_ResetHistogram(GLenum target)
3120 {
3121 GET_CURRENT_CONTEXT(ctx);
3122 Node *n;
3123 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3124 n = ALLOC_INSTRUCTION(ctx, OPCODE_RESET_HISTOGRAM, 1);
3125 if (n) {
3126 n[1].e = target;
3127 }
3128 if (ctx->ExecuteFlag) {
3129 CALL_ResetHistogram(ctx->Exec, (target));
3130 }
3131 }
3132
3133
3134 static void GLAPIENTRY
3135 save_ResetMinmax(GLenum target)
3136 {
3137 GET_CURRENT_CONTEXT(ctx);
3138 Node *n;
3139 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3140 n = ALLOC_INSTRUCTION(ctx, OPCODE_RESET_MIN_MAX, 1);
3141 if (n) {
3142 n[1].e = target;
3143 }
3144 if (ctx->ExecuteFlag) {
3145 CALL_ResetMinmax(ctx->Exec, (target));
3146 }
3147 }
3148
3149
3150 static void GLAPIENTRY
3151 save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
3152 {
3153 GET_CURRENT_CONTEXT(ctx);
3154 Node *n;
3155 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3156 n = ALLOC_INSTRUCTION(ctx, OPCODE_ROTATE, 4);
3157 if (n) {
3158 n[1].f = angle;
3159 n[2].f = x;
3160 n[3].f = y;
3161 n[4].f = z;
3162 }
3163 if (ctx->ExecuteFlag) {
3164 CALL_Rotatef(ctx->Exec, (angle, x, y, z));
3165 }
3166 }
3167
3168
3169 static void GLAPIENTRY
3170 save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
3171 {
3172 save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
3173 }
3174
3175
3176 static void GLAPIENTRY
3177 save_Scalef(GLfloat x, GLfloat y, GLfloat z)
3178 {
3179 GET_CURRENT_CONTEXT(ctx);
3180 Node *n;
3181 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3182 n = ALLOC_INSTRUCTION(ctx, OPCODE_SCALE, 3);
3183 if (n) {
3184 n[1].f = x;
3185 n[2].f = y;
3186 n[3].f = z;
3187 }
3188 if (ctx->ExecuteFlag) {
3189 CALL_Scalef(ctx->Exec, (x, y, z));
3190 }
3191 }
3192
3193
3194 static void GLAPIENTRY
3195 save_Scaled(GLdouble x, GLdouble y, GLdouble z)
3196 {
3197 save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
3198 }
3199
3200
3201 static void GLAPIENTRY
3202 save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
3203 {
3204 GET_CURRENT_CONTEXT(ctx);
3205 Node *n;
3206 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3207 n = ALLOC_INSTRUCTION(ctx, OPCODE_SCISSOR, 4);
3208 if (n) {
3209 n[1].i = x;
3210 n[2].i = y;
3211 n[3].i = width;
3212 n[4].i = height;
3213 }
3214 if (ctx->ExecuteFlag) {
3215 CALL_Scissor(ctx->Exec, (x, y, width, height));
3216 }
3217 }
3218
3219
3220 static void GLAPIENTRY
3221 save_ShadeModel(GLenum mode)
3222 {
3223 GET_CURRENT_CONTEXT(ctx);
3224 Node *n;
3225 ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);
3226
3227 if (ctx->ExecuteFlag) {
3228 CALL_ShadeModel(ctx->Exec, (mode));
3229 }
3230
3231 if (ctx->ListState.Current.ShadeModel == mode)
3232 return;
3233
3234 SAVE_FLUSH_VERTICES(ctx);
3235
3236 /* Only save the value if we know the statechange will take effect:
3237 */
3238 if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END)
3239 ctx->ListState.Current.ShadeModel = mode;
3240
3241 n = ALLOC_INSTRUCTION(ctx, OPCODE_SHADE_MODEL, 1);
3242 if (n) {
3243 n[1].e = mode;
3244 }
3245 }
3246
3247
3248 static void GLAPIENTRY
3249 save_StencilFunc(GLenum func, GLint ref, GLuint mask)
3250 {
3251 GET_CURRENT_CONTEXT(ctx);
3252 Node *n;
3253 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3254 n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC, 3);
3255 if (n) {
3256 n[1].e = func;
3257 n[2].i = ref;
3258 n[3].ui = mask;
3259 }
3260 if (ctx->ExecuteFlag) {
3261 CALL_StencilFunc(ctx->Exec, (func, ref, mask));
3262 }
3263 }
3264
3265
3266 static void GLAPIENTRY
3267 save_StencilMask(GLuint mask)
3268 {
3269 GET_CURRENT_CONTEXT(ctx);
3270 Node *n;
3271 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3272 n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_MASK, 1);
3273 if (n) {
3274 n[1].ui = mask;
3275 }
3276 if (ctx->ExecuteFlag) {
3277 CALL_StencilMask(ctx->Exec, (mask));
3278 }
3279 }
3280
3281
3282 static void GLAPIENTRY
3283 save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
3284 {
3285 GET_CURRENT_CONTEXT(ctx);
3286 Node *n;
3287 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3288 n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_OP, 3);
3289 if (n) {
3290 n[1].e = fail;
3291 n[2].e = zfail;
3292 n[3].e = zpass;
3293 }
3294 if (ctx->ExecuteFlag) {
3295 CALL_StencilOp(ctx->Exec, (fail, zfail, zpass));
3296 }
3297 }
3298
3299
3300 static void GLAPIENTRY
3301 save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
3302 {
3303 GET_CURRENT_CONTEXT(ctx);
3304 Node *n;
3305 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3306 n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3307 if (n) {
3308 n[1].e = face;
3309 n[2].e = func;
3310 n[3].i = ref;
3311 n[4].ui = mask;
3312 }
3313 if (ctx->ExecuteFlag) {
3314 CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask));
3315 }
3316 }
3317
3318
3319 static void GLAPIENTRY
3320 save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
3321 GLuint mask)
3322 {
3323 GET_CURRENT_CONTEXT(ctx);
3324 Node *n;
3325 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3326 /* GL_FRONT */
3327 n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3328 if (n) {
3329 n[1].e = GL_FRONT;
3330 n[2].e = frontfunc;
3331 n[3].i = ref;
3332 n[4].ui = mask;
3333 }
3334 /* GL_BACK */
3335 n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3336 if (n) {
3337 n[1].e = GL_BACK;
3338 n[2].e = backfunc;
3339 n[3].i = ref;
3340 n[4].ui = mask;
3341 }
3342 if (ctx->ExecuteFlag) {
3343 CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask));
3344 CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask));
3345 }
3346 }
3347
3348
3349 static void GLAPIENTRY
3350 save_StencilMaskSeparate(GLenum face, GLuint mask)
3351 {
3352 GET_CURRENT_CONTEXT(ctx);
3353 Node *n;
3354 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3355 n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2);
3356 if (n) {
3357 n[1].e = face;
3358 n[2].ui = mask;
3359 }
3360 if (ctx->ExecuteFlag) {
3361 CALL_StencilMaskSeparate(ctx->Exec, (face, mask));
3362 }
3363 }
3364
3365
3366 static void GLAPIENTRY
3367 save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
3368 {
3369 GET_CURRENT_CONTEXT(ctx);
3370 Node *n;
3371 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3372 n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_OP_SEPARATE, 4);
3373 if (n) {
3374 n[1].e = face;
3375 n[2].e = fail;
3376 n[3].e = zfail;
3377 n[4].e = zpass;
3378 }
3379 if (ctx->ExecuteFlag) {
3380 CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass));
3381 }
3382 }
3383
3384
3385 static void GLAPIENTRY
3386 save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
3387 {
3388 GET_CURRENT_CONTEXT(ctx);
3389 Node *n;
3390 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3391 n = ALLOC_INSTRUCTION(ctx, OPCODE_TEXENV, 6);
3392 if (n) {
3393 n[1].e = target;
3394 n[2].e = pname;
3395 if (pname == GL_TEXTURE_ENV_COLOR) {
3396 n[3].f = params[0];
3397 n[4].f = params[1];
3398 n[5].f = params[2];
3399 n[6].f = params[3];
3400 }
3401 else {
3402 n[3].f = params[0];
3403 n[4].f = n[5].f = n[6].f = 0.0F;
3404 }
3405 }
3406 if (ctx->ExecuteFlag) {
3407 CALL_TexEnvfv(ctx->Exec, (target, pname, params));
3408 }
3409 }
3410
3411
3412 static void GLAPIENTRY
3413 save_TexEnvf(GLenum target, GLenum pname, GLfloat param)
3414 {
3415 GLfloat parray[4];
3416 parray[0] = (GLfloat) param;
3417 parray[1] = parray[2] = parray[3] = 0.0F;
3418 save_TexEnvfv(target, pname, parray);
3419 }
3420
3421
3422 static void GLAPIENTRY
3423 save_TexEnvi(GLenum target, GLenum pname, GLint param)
3424 {
3425 GLfloat p[4];
3426 p[0] = (GLfloat) param;
3427 p[1] = p[2] = p[3] = 0.0;
3428 save_TexEnvfv(target, pname, p);
3429 }
3430
3431
3432 static void GLAPIENTRY
3433 save_TexEnviv(GLenum target, GLenum pname, const GLint * param)
3434 {
3435 GLfloat p[4];
3436 if (pname == GL_TEXTURE_ENV_COLOR) {
3437 p[0] = INT_TO_FLOAT(param[0]);
3438 p[1] = INT_TO_FLOAT(param[1]);
3439 p[2] = INT_TO_FLOAT(param[2]);
3440 p[3] = INT_TO_FLOAT(param[3]);
3441 }
3442 else {
3443 p[0] = (GLfloat) param[0];
3444 p[1] = p[2] = p[3] = 0.0F;
3445 }
3446 save_TexEnvfv(target, pname, p);
3447 }
3448
3449
3450 static void GLAPIENTRY
3451 save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params)
3452 {
3453 GET_CURRENT_CONTEXT(ctx);
3454 Node *n;
3455 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3456 n = ALLOC_INSTRUCTION(ctx, OPCODE_TEXGEN, 6);
3457 if (n) {
3458 n[1].e = coord;
3459 n[2].e = pname;
3460 n[3].f = params[0];
3461 n[4].f = params[1];
3462 n[5].f = params[2];
3463 n[6].f = params[3];
3464 }
3465 if (ctx->ExecuteFlag) {
3466 CALL_TexGenfv(ctx->Exec, (coord, pname, params));
3467 }
3468 }
3469
3470
3471 static void GLAPIENTRY
3472 save_TexGeniv(GLenum coord, GLenum pname, const GLint *params)
3473 {
3474 GLfloat p[4];
3475 p[0] = (GLfloat) params[0];
3476 p[1] = (GLfloat) params[1];
3477 p[2] = (GLfloat) params[2];
3478 p[3] = (GLfloat) params[3];
3479 save_TexGenfv(coord, pname, p);
3480 }
3481
3482
3483 static void GLAPIENTRY
3484 save_TexGend(GLenum coord, GLenum pname, GLdouble param)
3485 {
3486 GLfloat parray[4];
3487 parray[0] = (GLfloat) param;
3488 parray[1] = parray[2] = parray[3] = 0.0F;
3489 save_TexGenfv(coord, pname, parray);
3490 }
3491
3492
3493 static void GLAPIENTRY
3494 save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params)
3495 {
3496 GLfloat p[4];
3497 p[0] = (GLfloat) params[0];
3498 p[1] = (GLfloat) params[1];
3499 p[2] = (GLfloat) params[2];
3500 p[3] = (GLfloat) params[3];
3501 save_TexGenfv(coord, pname, p);
3502 }
3503
3504
3505 static void GLAPIENTRY
3506 save_TexGenf(GLenum coord, GLenum pname, GLfloat param)
3507 {
3508 GLfloat parray[4];
3509 parray[0] = param;
3510 parray[1] = parray[2] = parray[3] = 0.0F;
3511 save_TexGenfv(coord, pname, parray);
3512 }
3513
3514
3515 static void GLAPIENTRY
3516 save_TexGeni(GLenum coord, GLenum pname, GLint param)
3517 {
3518 GLint parray[4];
3519 parray[0] = param;
3520 parray[1] = parray[2] = parray[3] = 0;
3521 save_TexGeniv(coord, pname, parray);
3522 }
3523
3524
3525 static void GLAPIENTRY
3526 save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
3527 {
3528 GET_CURRENT_CONTEXT(ctx);
3529 Node *n;
3530 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3531 n = ALLOC_INSTRUCTION(ctx, OPCODE_TEXPARAMETER, 6);
3532 if (n) {
3533 n[1].e = target;
3534 n[2].e = pname;
3535 n[3].f = params[0];
3536 n[4].f = params[1];
3537 n[5].f = params[2];
3538 n[6].f = params[3];
3539 }
3540 if (ctx->ExecuteFlag) {
3541 CALL_TexParameterfv(ctx->Exec, (target, pname, params));
3542 }
3543 }
3544
3545
3546 static void GLAPIENTRY
3547 save_TexParameterf(GLenum target, GLenum pname, GLfloat param)
3548 {
3549 GLfloat parray[4];
3550 parray[0] = param;
3551 parray[1] = parray[2] = parray[3] = 0.0F;
3552 save_TexParameterfv(target, pname, parray);
3553 }
3554
3555
3556 static void GLAPIENTRY
3557 save_TexParameteri(GLenum target, GLenum pname, GLint param)
3558 {
3559 GLfloat fparam[4];
3560 fparam[0] = (GLfloat) param;
3561 fparam[1] = fparam[2] = fparam[3] = 0.0;
3562 save_TexParameterfv(target, pname, fparam);
3563 }
3564
3565
3566 static void GLAPIENTRY
3567 save_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
3568 {
3569 GLfloat fparam[4];
3570 fparam[0] = (GLfloat) params[0];
3571 fparam[1] = fparam[2] = fparam[3] = 0.0;
3572 save_TexParameterfv(target, pname, fparam);
3573 }
3574
3575
3576 static void GLAPIENTRY
3577 save_TexImage1D(GLenum target,
3578 GLint level, GLint components,
3579 GLsizei width, GLint border,
3580 GLenum format, GLenum type, const GLvoid * pixels)
3581 {
3582 GET_CURRENT_CONTEXT(ctx);
3583 if (target == GL_PROXY_TEXTURE_1D) {
3584 /* don't compile, execute immediately */
3585 CALL_TexImage1D(ctx->Exec, (target, level, components, width,
3586 border, format, type, pixels));
3587 }
3588 else {
3589 Node *n;
3590 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3591 n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_IMAGE1D, 8);
3592 if (n) {
3593 n[1].e = target;
3594 n[2].i = level;
3595 n[3].i = components;
3596 n[4].i = (GLint) width;
3597 n[5].i = border;
3598 n[6].e = format;
3599 n[7].e = type;
3600 n[8].data = unpack_image(ctx, 1, width, 1, 1, format, type,
3601 pixels, &ctx->Unpack);
3602 }
3603 if (ctx->ExecuteFlag) {
3604 CALL_TexImage1D(ctx->Exec, (target, level, components, width,
3605 border, format, type, pixels));
3606 }
3607 }
3608 }
3609
3610
3611 static void GLAPIENTRY
3612 save_TexImage2D(GLenum target,
3613 GLint level, GLint components,
3614 GLsizei width, GLsizei height, GLint border,
3615 GLenum format, GLenum type, const GLvoid * pixels)
3616 {
3617 GET_CURRENT_CONTEXT(ctx);
3618 if (target == GL_PROXY_TEXTURE_2D) {
3619 /* don't compile, execute immediately */
3620 CALL_TexImage2D(ctx->Exec, (target, level, components, width,
3621 height, border, format, type, pixels));
3622 }
3623 else {
3624 Node *n;
3625 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3626 n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_IMAGE2D, 9);
3627 if (n) {
3628 n[1].e = target;
3629 n[2].i = level;
3630 n[3].i = components;
3631 n[4].i = (GLint) width;
3632 n[5].i = (GLint) height;
3633 n[6].i = border;
3634 n[7].e = format;
3635 n[8].e = type;
3636 n[9].data = unpack_image(ctx, 2, width, height, 1, format, type,
3637 pixels, &ctx->Unpack);
3638 }
3639 if (ctx->ExecuteFlag) {
3640 CALL_TexImage2D(ctx->Exec, (target, level, components, width,
3641 height, border, format, type, pixels));
3642 }
3643 }
3644 }
3645
3646
3647 static void GLAPIENTRY
3648 save_TexImage3D(GLenum target,
3649 GLint level, GLint internalFormat,
3650 GLsizei width, GLsizei height, GLsizei depth,
3651 GLint border,
3652 GLenum format, GLenum type, const GLvoid * pixels)
3653 {
3654 GET_CURRENT_CONTEXT(ctx);
3655 if (target == GL_PROXY_TEXTURE_3D) {
3656 /* don't compile, execute immediately */
3657 CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
3658 height, depth, border, format, type,
3659 pixels));
3660 }
3661 else {
3662 Node *n;
3663 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3664 n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_IMAGE3D, 10);
3665 if (n) {
3666 n[1].e = target;
3667 n[2].i = level;
3668 n[3].i = (GLint) internalFormat;
3669 n[4].i = (GLint) width;
3670 n[5].i = (GLint) height;
3671 n[6].i = (GLint) depth;
3672 n[7].i = border;
3673 n[8].e = format;
3674 n[9].e = type;
3675 n[10].data = unpack_image(ctx, 3, width, height, depth, format, type,
3676 pixels, &ctx->Unpack);
3677 }
3678 if (ctx->ExecuteFlag) {
3679 CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
3680 height, depth, border, format, type,
3681 pixels));
3682 }
3683 }
3684 }
3685
3686
3687 static void GLAPIENTRY
3688 save_TexSubImage1D(GLenum target, GLint level, GLint xoffset,
3689 GLsizei width, GLenum format, GLenum type,
3690 const GLvoid * pixels)
3691 {
3692 GET_CURRENT_CONTEXT(ctx);
3693 Node *n;
3694
3695 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3696
3697 n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_SUB_IMAGE1D, 7);
3698 if (n) {
3699 n[1].e = target;
3700 n[2].i = level;
3701 n[3].i = xoffset;
3702 n[4].i = (GLint) width;
3703 n[5].e = format;
3704 n[6].e = type;
3705 n[7].data = unpack_image(ctx, 1, width, 1, 1, format, type,
3706 pixels, &ctx->Unpack);
3707 }
3708 if (ctx->ExecuteFlag) {
3709 CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width,
3710 format, type, pixels));
3711 }
3712 }
3713
3714
3715 static void GLAPIENTRY
3716 save_TexSubImage2D(GLenum target, GLint level,
3717 GLint xoffset, GLint yoffset,
3718 GLsizei width, GLsizei height,
3719 GLenum format, GLenum type, const GLvoid * pixels)
3720 {
3721 GET_CURRENT_CONTEXT(ctx);
3722 Node *n;
3723
3724 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3725
3726 n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_SUB_IMAGE2D, 9);
3727 if (n) {
3728 n[1].e = target;
3729 n[2].i = level;
3730 n[3].i = xoffset;
3731 n[4].i = yoffset;
3732 n[5].i = (GLint) width;
3733 n[6].i = (GLint) height;
3734 n[7].e = format;
3735 n[8].e = type;
3736 n[9].data = unpack_image(ctx, 2, width, height, 1, format, type,
3737 pixels, &ctx->Unpack);
3738 }
3739 if (ctx->ExecuteFlag) {
3740 CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
3741 width, height, format, type, pixels));
3742 }
3743 }
3744
3745
3746 static void GLAPIENTRY
3747 save_TexSubImage3D(GLenum target, GLint level,
3748 GLint xoffset, GLint yoffset, GLint zoffset,
3749 GLsizei width, GLsizei height, GLsizei depth,
3750 GLenum format, GLenum type, const GLvoid * pixels)
3751 {
3752 GET_CURRENT_CONTEXT(ctx);
3753 Node *n;
3754
3755 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3756
3757 n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_SUB_IMAGE3D, 11);
3758 if (n) {
3759 n[1].e = target;
3760 n[2].i = level;
3761 n[3].i = xoffset;
3762 n[4].i = yoffset;
3763 n[5].i = zoffset;
3764 n[6].i = (GLint) width;
3765 n[7].i = (GLint) height;
3766 n[8].i = (GLint) depth;
3767 n[9].e = format;
3768 n[10].e = type;
3769 n[11].data = unpack_image(ctx, 3, width, height, depth, format, type,
3770 pixels, &ctx->Unpack);
3771 }
3772 if (ctx->ExecuteFlag) {
3773 CALL_TexSubImage3D(ctx->Exec, (target, level,
3774 xoffset, yoffset, zoffset,
3775 width, height, depth, format, type,
3776 pixels));
3777 }
3778 }
3779
3780
3781 static void GLAPIENTRY
3782 save_Translatef(GLfloat x, GLfloat y, GLfloat z)
3783 {
3784 GET_CURRENT_CONTEXT(ctx);
3785 Node *n;
3786 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3787 n = ALLOC_INSTRUCTION(ctx, OPCODE_TRANSLATE, 3);
3788 if (n) {
3789 n[1].f = x;
3790 n[2].f = y;
3791 n[3].f = z;
3792 }
3793 if (ctx->ExecuteFlag) {
3794 CALL_Translatef(ctx->Exec, (x, y, z));
3795 }
3796 }
3797
3798
3799 static void GLAPIENTRY
3800 save_Translated(GLdouble x, GLdouble y, GLdouble z)
3801 {
3802 save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
3803 }
3804
3805
3806
3807 static void GLAPIENTRY
3808 save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
3809 {
3810 GET_CURRENT_CONTEXT(ctx);
3811 Node *n;
3812 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3813 n = ALLOC_INSTRUCTION(ctx, OPCODE_VIEWPORT, 4);
3814 if (n) {
3815 n[1].i = x;
3816 n[2].i = y;
3817 n[3].i = (GLint) width;
3818 n[4].i = (GLint) height;
3819 }
3820 if (ctx->ExecuteFlag) {
3821 CALL_Viewport(ctx->Exec, (x, y, width, height));
3822 }
3823 }
3824
3825
3826 static void GLAPIENTRY
3827 save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
3828 {
3829 GET_CURRENT_CONTEXT(ctx);
3830 Node *n;
3831 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3832 n = ALLOC_INSTRUCTION(ctx, OPCODE_WINDOW_POS, 4);
3833 if (n) {
3834 n[1].f = x;
3835 n[2].f = y;
3836 n[3].f = z;
3837 n[4].f = w;
3838 }
3839 if (ctx->ExecuteFlag) {
3840 CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w));
3841 }
3842 }
3843
3844 static void GLAPIENTRY
3845 save_WindowPos2dMESA(GLdouble x, GLdouble y)
3846 {
3847 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3848 }
3849
3850 static void GLAPIENTRY
3851 save_WindowPos2fMESA(GLfloat x, GLfloat y)
3852 {
3853 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3854 }
3855
3856 static void GLAPIENTRY
3857 save_WindowPos2iMESA(GLint x, GLint y)
3858 {
3859 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3860 }
3861
3862 static void GLAPIENTRY
3863 save_WindowPos2sMESA(GLshort x, GLshort y)
3864 {
3865 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3866 }
3867
3868 static void GLAPIENTRY
3869 save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
3870 {
3871 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3872 }
3873
3874 static void GLAPIENTRY
3875 save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
3876 {
3877 save_WindowPos4fMESA(x, y, z, 1.0F);
3878 }
3879
3880 static void GLAPIENTRY
3881 save_WindowPos3iMESA(GLint x, GLint y, GLint z)
3882 {
3883 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3884 }
3885
3886 static void GLAPIENTRY
3887 save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
3888 {
3889 save_WindowPos4fMESA(x, y, z, 1.0F);
3890 }
3891
3892 static void GLAPIENTRY
3893 save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3894 {
3895 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3896 }
3897
3898 static void GLAPIENTRY
3899 save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
3900 {
3901 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3902 }
3903
3904 static void GLAPIENTRY
3905 save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
3906 {
3907 save_WindowPos4fMESA(x, y, z, w);
3908 }
3909
3910 static void GLAPIENTRY
3911 save_WindowPos2dvMESA(const GLdouble * v)
3912 {
3913 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3914 }
3915
3916 static void GLAPIENTRY
3917 save_WindowPos2fvMESA(const GLfloat * v)
3918 {
3919 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3920 }
3921
3922 static void GLAPIENTRY
3923 save_WindowPos2ivMESA(const GLint * v)
3924 {
3925 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3926 }
3927
3928 static void GLAPIENTRY
3929 save_WindowPos2svMESA(const GLshort * v)
3930 {
3931 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3932 }
3933
3934 static void GLAPIENTRY
3935 save_WindowPos3dvMESA(const GLdouble * v)
3936 {
3937 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3938 }
3939
3940 static void GLAPIENTRY
3941 save_WindowPos3fvMESA(const GLfloat * v)
3942 {
3943 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3944 }
3945
3946 static void GLAPIENTRY
3947 save_WindowPos3ivMESA(const GLint * v)
3948 {
3949 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3950 }
3951
3952 static void GLAPIENTRY
3953 save_WindowPos3svMESA(const GLshort * v)
3954 {
3955 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3956 }
3957
3958 static void GLAPIENTRY
3959 save_WindowPos4dvMESA(const GLdouble * v)
3960 {
3961 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
3962 (GLfloat) v[2], (GLfloat) v[3]);
3963 }
3964
3965 static void GLAPIENTRY
3966 save_WindowPos4fvMESA(const GLfloat * v)
3967 {
3968 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3969 }
3970
3971 static void GLAPIENTRY
3972 save_WindowPos4ivMESA(const GLint * v)
3973 {
3974 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
3975 (GLfloat) v[2], (GLfloat) v[3]);
3976 }
3977
3978 static void GLAPIENTRY
3979 save_WindowPos4svMESA(const GLshort * v)
3980 {
3981 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3982 }
3983
3984
3985
3986 /* GL_ARB_multitexture */
3987 static void GLAPIENTRY
3988 save_ActiveTextureARB(GLenum target)
3989 {
3990 GET_CURRENT_CONTEXT(ctx);
3991 Node *n;
3992 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3993 n = ALLOC_INSTRUCTION(ctx, OPCODE_ACTIVE_TEXTURE, 1);
3994 if (n) {
3995 n[1].e = target;
3996 }
3997 if (ctx->ExecuteFlag) {
3998 CALL_ActiveTextureARB(ctx->Exec, (target));
3999 }
4000 }
4001
4002
4003 /* GL_ARB_transpose_matrix */
4004
4005 static void GLAPIENTRY
4006 save_LoadTransposeMatrixdARB(const GLdouble m[16])
4007 {
4008 GLfloat tm[16];
4009 _math_transposefd(tm, m);
4010 save_LoadMatrixf(tm);
4011 }
4012
4013
4014 static void GLAPIENTRY
4015 save_LoadTransposeMatrixfARB(const GLfloat m[16])
4016 {
4017 GLfloat tm[16];
4018 _math_transposef(tm, m);
4019 save_LoadMatrixf(tm);
4020 }
4021
4022
4023 static void GLAPIENTRY
4024 save_MultTransposeMatrixdARB(const GLdouble m[16])
4025 {
4026 GLfloat tm[16];
4027 _math_transposefd(tm, m);
4028 save_MultMatrixf(tm);
4029 }
4030
4031
4032 static void GLAPIENTRY
4033 save_MultTransposeMatrixfARB(const GLfloat m[16])
4034 {
4035 GLfloat tm[16];
4036 _math_transposef(tm, m);
4037 save_MultMatrixf(tm);
4038 }
4039
4040
4041 /* GL_ARB_texture_compression */
4042 static void GLAPIENTRY
4043 save_CompressedTexImage1DARB(GLenum target, GLint level,
4044 GLenum internalFormat, GLsizei width,
4045 GLint border, GLsizei imageSize,
4046 const GLvoid * data)
4047 {
4048 GET_CURRENT_CONTEXT(ctx);
4049 if (target == GL_PROXY_TEXTURE_1D) {
4050 /* don't compile, execute immediately */
4051 CALL_CompressedTexImage1DARB(ctx->Exec, (target, level, internalFormat,
4052 width, border, imageSize,
4053 data));
4054 }
4055 else {
4056 Node *n;
4057 GLvoid *image;
4058 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4059 /* make copy of image */
4060 image = _mesa_malloc(imageSize);
4061 if (!image) {
4062 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
4063 return;
4064 }
4065 MEMCPY(image, data, imageSize);
4066 n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7);
4067 if (n) {
4068 n[1].e = target;
4069 n[2].i = level;
4070 n[3].e = internalFormat;
4071 n[4].i = (GLint) width;
4072 n[5].i = border;
4073 n[6].i = imageSize;
4074 n[7].data = image;
4075 }
4076 else if (image) {
4077 _mesa_free(image);
4078 }
4079 if (ctx->ExecuteFlag) {
4080 CALL_CompressedTexImage1DARB(ctx->Exec,
4081 (target, level, internalFormat, width,
4082 border, imageSize, data));
4083 }
4084 }
4085 }
4086
4087
4088 static void GLAPIENTRY
4089 save_CompressedTexImage2DARB(GLenum target, GLint level,
4090 GLenum internalFormat, GLsizei width,
4091 GLsizei height, GLint border, GLsizei imageSize,
4092 const GLvoid * data)
4093 {
4094 GET_CURRENT_CONTEXT(ctx);
4095 if (target == GL_PROXY_TEXTURE_2D) {
4096 /* don't compile, execute immediately */
4097 CALL_CompressedTexImage2DARB(ctx->Exec, (target, level, internalFormat,
4098 width, height, border,
4099 imageSize, data));
4100 }
4101 else {
4102 Node *n;
4103 GLvoid *image;
4104 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4105 /* make copy of image */
4106 image = _mesa_malloc(imageSize);
4107 if (!image) {
4108 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
4109 return;
4110 }
4111 MEMCPY(image, data, imageSize);
4112 n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8);
4113 if (n) {
4114 n[1].e = target;
4115 n[2].i = level;
4116 n[3].e = internalFormat;
4117 n[4].i = (GLint) width;
4118 n[5].i = (GLint) height;
4119 n[6].i = border;
4120 n[7].i = imageSize;
4121 n[8].data = image;
4122 }
4123 else if (image) {
4124 _mesa_free(image);
4125 }
4126 if (ctx->ExecuteFlag) {
4127 CALL_CompressedTexImage2DARB(ctx->Exec,
4128 (target, level, internalFormat, width,
4129 height, border, imageSize, data));
4130 }
4131 }
4132 }
4133
4134
4135 static void GLAPIENTRY
4136 save_CompressedTexImage3DARB(GLenum target, GLint level,
4137 GLenum internalFormat, GLsizei width,
4138 GLsizei height, GLsizei depth, GLint border,
4139 GLsizei imageSize, const GLvoid * data)
4140 {
4141 GET_CURRENT_CONTEXT(ctx);
4142 if (target == GL_PROXY_TEXTURE_3D) {
4143 /* don't compile, execute immediately */
4144 CALL_CompressedTexImage3DARB(ctx->Exec, (target, level, internalFormat,
4145 width, height, depth, border,
4146 imageSize, data));
4147 }
4148 else {
4149 Node *n;
4150 GLvoid *image;
4151 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4152 /* make copy of image */
4153 image = _mesa_malloc(imageSize);
4154 if (!image) {
4155 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
4156 return;
4157 }
4158 MEMCPY(image, data, imageSize);
4159 n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9);
4160 if (n) {
4161 n[1].e = target;
4162 n[2].i = level;
4163 n[3].e = internalFormat;
4164 n[4].i = (GLint) width;
4165 n[5].i = (GLint) height;
4166 n[6].i = (GLint) depth;
4167 n[7].i = border;
4168 n[8].i = imageSize;
4169 n[9].data = image;
4170 }
4171 else if (image) {
4172 _mesa_free(image);
4173 }
4174 if (ctx->ExecuteFlag) {
4175 CALL_CompressedTexImage3DARB(ctx->Exec,
4176 (target, level, internalFormat, width,
4177 height, depth, border, imageSize,
4178 data));
4179 }
4180 }
4181 }
4182
4183
4184 static void GLAPIENTRY
4185 save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
4186 GLsizei width, GLenum format,
4187 GLsizei imageSize, const GLvoid * data)
4188 {
4189 Node *n;
4190 GLvoid *image;
4191
4192 GET_CURRENT_CONTEXT(ctx);
4193 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4194
4195 /* make copy of image */
4196 image = _mesa_malloc(imageSize);
4197 if (!image) {
4198 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
4199 return;
4200 }
4201 MEMCPY(image, data, imageSize);
4202 n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7);
4203 if (n) {
4204 n[1].e = target;
4205 n[2].i = level;
4206 n[3].i = xoffset;
4207 n[4].i = (GLint) width;
4208 n[5].e = format;
4209 n[6].i = imageSize;
4210 n[7].data = image;
4211 }
4212 else if (image) {
4213 _mesa_free(image);
4214 }
4215 if (ctx->ExecuteFlag) {
4216 CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset,
4217 width, format, imageSize,
4218 data));
4219 }
4220 }
4221
4222
4223 static void GLAPIENTRY
4224 save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
4225 GLint yoffset, GLsizei width, GLsizei height,
4226 GLenum format, GLsizei imageSize,
4227 const GLvoid * data)
4228 {
4229 Node *n;
4230 GLvoid *image;
4231
4232 GET_CURRENT_CONTEXT(ctx);
4233 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4234
4235 /* make copy of image */
4236 image = _mesa_malloc(imageSize);
4237 if (!image) {
4238 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
4239 return;
4240 }
4241 MEMCPY(image, data, imageSize);
4242 n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9);
4243 if (n) {
4244 n[1].e = target;
4245 n[2].i = level;
4246 n[3].i = xoffset;
4247 n[4].i = yoffset;
4248 n[5].i = (GLint) width;
4249 n[6].i = (GLint) height;
4250 n[7].e = format;
4251 n[8].i = imageSize;
4252 n[9].data = image;
4253 }
4254 else if (image) {
4255 _mesa_free(image);
4256 }
4257 if (ctx->ExecuteFlag) {
4258 CALL_CompressedTexSubImage2DARB(ctx->Exec,
4259 (target, level, xoffset, yoffset, width,
4260 height, format, imageSize, data));
4261 }
4262 }
4263
4264
4265 static void GLAPIENTRY
4266 save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
4267 GLint yoffset, GLint zoffset, GLsizei width,
4268 GLsizei height, GLsizei depth, GLenum format,
4269 GLsizei imageSize, const GLvoid * data)
4270 {
4271 Node *n;
4272 GLvoid *image;
4273
4274 GET_CURRENT_CONTEXT(ctx);
4275 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4276
4277 /* make copy of image */
4278 image = _mesa_malloc(imageSize);
4279 if (!image) {
4280 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
4281 return;
4282 }
4283 MEMCPY(image, data, imageSize);
4284 n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11);
4285 if (n) {
4286 n[1].e = target;
4287 n[2].i = level;
4288 n[3].i = xoffset;
4289 n[4].i = yoffset;
4290 n[5].i = zoffset;
4291 n[6].i = (GLint) width;
4292 n[7].i = (GLint) height;
4293 n[8].i = (GLint) depth;
4294 n[9].e = format;
4295 n[10].i = imageSize;
4296 n[11].data = image;
4297 }
4298 else if (image) {
4299 _mesa_free(image);
4300 }
4301 if (ctx->ExecuteFlag) {
4302 CALL_CompressedTexSubImage3DARB(ctx->Exec,
4303 (target, level, xoffset, yoffset,
4304 zoffset, width, height, depth, format,
4305 imageSize, data));
4306 }
4307 }
4308
4309
4310 /* GL_ARB_multisample */
4311 static void GLAPIENTRY
4312 save_SampleCoverageARB(GLclampf value, GLboolean invert)
4313 {
4314 GET_CURRENT_CONTEXT(ctx);
4315 Node *n;
4316 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4317 n = ALLOC_INSTRUCTION(ctx, OPCODE_SAMPLE_COVERAGE, 2);
4318 if (n) {
4319 n[1].f = value;
4320 n[2].b = invert;
4321 }
4322 if (ctx->ExecuteFlag) {
4323 CALL_SampleCoverageARB(ctx->Exec, (value, invert));
4324 }
4325 }
4326
4327
4328 /*
4329 * GL_NV_vertex_program
4330 */
4331 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
4332 static void GLAPIENTRY
4333 save_BindProgramNV(GLenum target, GLuint id)
4334 {
4335 GET_CURRENT_CONTEXT(ctx);
4336 Node *n;
4337 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4338 n = ALLOC_INSTRUCTION(ctx, OPCODE_BIND_PROGRAM_NV, 2);
4339 if (n) {
4340 n[1].e = target;
4341 n[2].ui = id;
4342 }
4343 if (ctx->ExecuteFlag) {
4344 CALL_BindProgramNV(ctx->Exec, (target, id));
4345 }
4346 }
4347
4348 static void GLAPIENTRY
4349 save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
4350 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4351 {
4352 GET_CURRENT_CONTEXT(ctx);
4353 Node *n;
4354 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4355 n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
4356 if (n) {
4357 n[1].e = target;
4358 n[2].ui = index;
4359 n[3].f = x;
4360 n[4].f = y;
4361 n[5].f = z;
4362 n[6].f = w;
4363 }
4364 if (ctx->ExecuteFlag) {
4365 CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
4366 }
4367 }
4368
4369
4370 static void GLAPIENTRY
4371 save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
4372 const GLfloat *params)
4373 {
4374 save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
4375 params[2], params[3]);
4376 }
4377
4378
4379 static void GLAPIENTRY
4380 save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
4381 const GLfloat * params)
4382 {
4383 GET_CURRENT_CONTEXT(ctx);
4384 Node *n;
4385 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4386
4387 if (count > 0) {
4388 GLint i;
4389 const GLfloat * p = params;
4390
4391 for (i = 0 ; i < count ; i++) {
4392 n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
4393 if (n) {
4394 n[1].e = target;
4395 n[2].ui = index;
4396 n[3].f = p[0];
4397 n[4].f = p[1];
4398 n[5].f = p[2];
4399 n[6].f = p[3];
4400 p += 4;
4401 }
4402 }
4403 }
4404
4405 if (ctx->ExecuteFlag) {
4406 CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params));
4407 }
4408 }
4409
4410
4411 static void GLAPIENTRY
4412 save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
4413 GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4414 {
4415 save_ProgramEnvParameter4fARB(target, index,
4416 (GLfloat) x,
4417 (GLfloat) y, (GLfloat) z, (GLfloat) w);
4418 }
4419
4420
4421 static void GLAPIENTRY
4422 save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
4423 const GLdouble *params)
4424 {
4425 save_ProgramEnvParameter4fARB(target, index,
4426 (GLfloat) params[0],
4427 (GLfloat) params[1],
4428 (GLfloat) params[2], (GLfloat) params[3]);
4429 }
4430
4431 #endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program */
4432
4433 #if FEATURE_NV_vertex_program
4434 static void GLAPIENTRY
4435 save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
4436 {
4437 GET_CURRENT_CONTEXT(ctx);
4438 Node *n;
4439 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4440 n = ALLOC_INSTRUCTION(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6);
4441 if (n) {
4442 n[1].e = target;
4443 n[2].ui = id;
4444 n[3].f = params[0];
4445 n[4].f = params[1];
4446 n[5].f = params[2];
4447 n[6].f = params[3];
4448 }
4449 if (ctx->ExecuteFlag) {
4450 CALL_ExecuteProgramNV(ctx->Exec, (target, id, params));
4451 }
4452 }
4453
4454
4455 static void GLAPIENTRY
4456 save_ProgramParameters4dvNV(GLenum target, GLuint index,
4457 GLuint num, const GLdouble *params)
4458 {
4459 GLuint i;
4460 for (i = 0; i < num; i++) {
4461 save_ProgramEnvParameter4dvARB(target, index + i, params + 4 * i);
4462 }
4463 }
4464
4465
4466 static void GLAPIENTRY
4467 save_ProgramParameters4fvNV(GLenum target, GLuint index,
4468 GLuint num, const GLfloat *params)
4469 {
4470 GLuint i;
4471 for (i = 0; i < num; i++) {
4472 save_ProgramEnvParameter4fvARB(target, index + i, params + 4 * i);
4473 }
4474 }
4475
4476
4477 static void GLAPIENTRY
4478 save_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
4479 const GLubyte * program)
4480 {
4481 GET_CURRENT_CONTEXT(ctx);
4482 Node *n;
4483
4484 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4485
4486 n = ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_PROGRAM_NV, 4);
4487 if (n) {
4488 GLubyte *programCopy = (GLubyte *) _mesa_malloc(len);
4489 if (!programCopy) {
4490 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
4491 return;
4492 }
4493 _mesa_memcpy(programCopy, program, len);
4494 n[1].e = target;
4495 n[2].ui = id;
4496 n[3].i = len;
4497 n[4].data = programCopy;
4498 }
4499 if (ctx->ExecuteFlag) {
4500 CALL_LoadProgramNV(ctx->Exec, (target, id, len, program));
4501 }
4502 }
4503
4504
4505 static void GLAPIENTRY
4506 save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids)
4507 {
4508 GET_CURRENT_CONTEXT(ctx);
4509 Node *n;
4510
4511 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4512
4513 n = ALLOC_INSTRUCTION(ctx, OPCODE_TRACK_MATRIX_NV, 2);
4514 if (n) {
4515 GLuint *idCopy = (GLuint *) _mesa_malloc(num * sizeof(GLuint));
4516 if (!idCopy) {
4517 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV");
4518 return;
4519 }
4520 _mesa_memcpy(idCopy, ids, num * sizeof(GLuint));
4521 n[1].i = num;
4522 n[2].data = idCopy;
4523 }
4524 if (ctx->ExecuteFlag) {
4525 CALL_RequestResidentProgramsNV(ctx->Exec, (num, ids));
4526 }
4527 }
4528
4529
4530 static void GLAPIENTRY
4531 save_TrackMatrixNV(GLenum target, GLuint address,
4532 GLenum matrix, GLenum transform)
4533 {
4534 GET_CURRENT_CONTEXT(ctx);
4535 Node *n;
4536 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4537 n = ALLOC_INSTRUCTION(ctx, OPCODE_TRACK_MATRIX_NV, 4);
4538 if (n) {
4539 n[1].e = target;
4540 n[2].ui = address;
4541 n[3].e = matrix;
4542 n[4].e = transform;
4543 }
4544 if (ctx->ExecuteFlag) {
4545 CALL_TrackMatrixNV(ctx->Exec, (target, address, matrix, transform));
4546 }
4547 }
4548 #endif /* FEATURE_NV_vertex_program */
4549
4550
4551 /*
4552 * GL_NV_fragment_program
4553 */
4554 #if FEATURE_NV_fragment_program
4555 static void GLAPIENTRY
4556 save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
4557 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4558 {
4559 GET_CURRENT_CONTEXT(ctx);
4560 Node *n;
4561 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4562 n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4563 if (n) {
4564 n[1].e = target;
4565 n[2].ui = index;
4566 n[3].f = x;
4567 n[4].f = y;
4568 n[5].f = z;
4569 n[6].f = w;
4570 }
4571 if (ctx->ExecuteFlag) {
4572 CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
4573 }
4574 }
4575
4576
4577 static void GLAPIENTRY
4578 save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
4579 const GLfloat *params)
4580 {
4581 GET_CURRENT_CONTEXT(ctx);
4582 Node *n;
4583 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4584 n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4585 if (n) {
4586 n[1].e = target;
4587 n[2].ui = index;
4588 n[3].f = params[0];
4589 n[4].f = params[1];
4590 n[5].f = params[2];
4591 n[6].f = params[3];
4592 }
4593 if (ctx->ExecuteFlag) {
4594 CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params));
4595 }
4596 }
4597
4598
4599 static void GLAPIENTRY
4600 save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
4601 const GLfloat *params)
4602 {
4603 GET_CURRENT_CONTEXT(ctx);
4604 Node *n;
4605 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4606
4607 if (count > 0) {
4608 GLint i;
4609 const GLfloat * p = params;
4610
4611 for (i = 0 ; i < count ; i++) {
4612 n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4613 if (n) {
4614 n[1].e = target;
4615 n[2].ui = index;
4616 n[3].f = p[0];
4617 n[4].f = p[1];
4618 n[5].f = p[2];
4619 n[6].f = p[3];
4620 p += 4;
4621 }
4622 }
4623 }
4624
4625 if (ctx->ExecuteFlag) {
4626 CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params));
4627 }
4628 }
4629
4630
4631 static void GLAPIENTRY
4632 save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
4633 GLdouble x, GLdouble y,
4634 GLdouble z, GLdouble w)
4635 {
4636 GET_CURRENT_CONTEXT(ctx);
4637 Node *n;
4638 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4639 n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4640 if (n) {
4641 n[1].e = target;
4642 n[2].ui = index;
4643 n[3].f = (GLfloat) x;
4644 n[4].f = (GLfloat) y;
4645 n[5].f = (GLfloat) z;
4646 n[6].f = (GLfloat) w;
4647 }
4648 if (ctx->ExecuteFlag) {
4649 CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w));
4650 }
4651 }
4652
4653
4654 static void GLAPIENTRY
4655 save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
4656 const GLdouble *params)
4657 {
4658 GET_CURRENT_CONTEXT(ctx);
4659 Node *n;
4660 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4661 n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4662 if (n) {
4663 n[1].e = target;
4664 n[2].ui = index;
4665 n[3].f = (GLfloat) params[0];
4666 n[4].f = (GLfloat) params[1];
4667 n[5].f = (GLfloat) params[2];
4668 n[6].f = (GLfloat) params[3];
4669 }
4670 if (ctx->ExecuteFlag) {
4671 CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params));
4672 }
4673 }
4674
4675 static void GLAPIENTRY
4676 save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name,
4677 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4678 {
4679 GET_CURRENT_CONTEXT(ctx);
4680 Node *n;
4681
4682 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4683
4684 n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6);
4685 if (n) {
4686 GLubyte *nameCopy = (GLubyte *) _mesa_malloc(len);
4687 if (!nameCopy) {
4688 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV");
4689 return;
4690 }
4691 _mesa_memcpy(nameCopy, name, len);
4692 n[1].ui = id;
4693 n[2].i = len;
4694 n[3].data = nameCopy;
4695 n[4].f = x;
4696 n[5].f = y;
4697 n[6].f = z;
4698 n[7].f = w;
4699 }
4700 if (ctx->ExecuteFlag) {
4701 CALL_ProgramNamedParameter4fNV(ctx->Exec, (id, len, name, x, y, z, w));
4702 }
4703 }
4704
4705
4706 static void GLAPIENTRY
4707 save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name,
4708 const float v[])
4709 {
4710 save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]);
4711 }
4712
4713
4714 static void GLAPIENTRY
4715 save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name,
4716 GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4717 {
4718 save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y,
4719 (GLfloat) z, (GLfloat) w);
4720 }
4721
4722
4723 static void GLAPIENTRY
4724 save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name,
4725 const double v[])
4726 {
4727 save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0],
4728 (GLfloat) v[1], (GLfloat) v[2],
4729 (GLfloat) v[3]);
4730 }
4731
4732 #endif /* FEATURE_NV_fragment_program */
4733
4734
4735
4736 /* GL_EXT_stencil_two_side */
4737 static void GLAPIENTRY
4738 save_ActiveStencilFaceEXT(GLenum face)
4739 {
4740 GET_CURRENT_CONTEXT(ctx);
4741 Node *n;
4742 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4743 n = ALLOC_INSTRUCTION(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1);
4744 if (n) {
4745 n[1].e = face;
4746 }
4747 if (ctx->ExecuteFlag) {
4748 CALL_ActiveStencilFaceEXT(ctx->Exec, (face));
4749 }
4750 }
4751
4752
4753 /* GL_EXT_depth_bounds_test */
4754 static void GLAPIENTRY
4755 save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax)
4756 {
4757 GET_CURRENT_CONTEXT(ctx);
4758 Node *n;
4759 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4760 n = ALLOC_INSTRUCTION(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2);
4761 if (n) {
4762 n[1].f = (GLfloat) zmin;
4763 n[2].f = (GLfloat) zmax;
4764 }
4765 if (ctx->ExecuteFlag) {
4766 CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax));
4767 }
4768 }
4769
4770
4771
4772 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
4773
4774 static void GLAPIENTRY
4775 save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
4776 const GLvoid * string)
4777 {
4778 GET_CURRENT_CONTEXT(ctx);
4779 Node *n;
4780
4781 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4782
4783 n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_STRING_ARB, 4);
4784 if (n) {
4785 GLubyte *programCopy = (GLubyte *) _mesa_malloc(len);
4786 if (!programCopy) {
4787 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
4788 return;
4789 }
4790 _mesa_memcpy(programCopy, string, len);
4791 n[1].e = target;
4792 n[2].e = format;
4793 n[3].i = len;
4794 n[4].data = programCopy;
4795 }
4796 if (ctx->ExecuteFlag) {
4797 CALL_ProgramStringARB(ctx->Exec, (target, format, len, string));
4798 }
4799 }
4800
4801 #endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
4802
4803
4804 #if FEATURE_ARB_occlusion_query
4805
4806 static void GLAPIENTRY
4807 save_BeginQueryARB(GLenum target, GLuint id)
4808 {
4809 GET_CURRENT_CONTEXT(ctx);
4810 Node *n;
4811 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4812 n = ALLOC_INSTRUCTION(ctx, OPCODE_BEGIN_QUERY_ARB, 2);
4813 if (n) {
4814 n[1].e = target;
4815 n[2].ui = id;
4816 }
4817 if (ctx->ExecuteFlag) {
4818 CALL_BeginQueryARB(ctx->Exec, (target, id));
4819 }
4820 }
4821
4822
4823 static void GLAPIENTRY
4824 save_EndQueryARB(GLenum target)
4825 {
4826 GET_CURRENT_CONTEXT(ctx);
4827 Node *n;
4828 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4829 n = ALLOC_INSTRUCTION(ctx, OPCODE_END_QUERY_ARB, 1);
4830 if (n) {
4831 n[1].e = target;
4832 }
4833 if (ctx->ExecuteFlag) {
4834 CALL_EndQueryARB(ctx->Exec, (target));
4835 }
4836 }
4837
4838 #endif /* FEATURE_ARB_occlusion_query */
4839
4840
4841 static void GLAPIENTRY
4842 save_DrawBuffersARB(GLsizei count, const GLenum * buffers)
4843 {
4844 GET_CURRENT_CONTEXT(ctx);
4845 Node *n;
4846 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4847 n = ALLOC_INSTRUCTION(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS);
4848 if (n) {
4849 GLint i;
4850 n[1].i = count;
4851 if (count > MAX_DRAW_BUFFERS)
4852 count = MAX_DRAW_BUFFERS;
4853 for (i = 0; i < count; i++) {
4854 n[2 + i].e = buffers[i];
4855 }
4856 }
4857 if (ctx->ExecuteFlag) {
4858 CALL_DrawBuffersARB(ctx->Exec, (count, buffers));
4859 }
4860 }
4861
4862 static void GLAPIENTRY
4863 save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param)
4864 {
4865 GET_CURRENT_CONTEXT(ctx);
4866 Node *n;
4867
4868 n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5);
4869 if (n) {
4870 n[1].ui = pname;
4871 n[2].f = param[0];
4872 n[3].f = param[1];
4873 n[4].f = param[2];
4874 n[5].f = param[3];
4875 }
4876 if (ctx->ExecuteFlag) {
4877 CALL_TexBumpParameterfvATI(ctx->Exec, (pname, param));
4878 }
4879 }
4880
4881 static void GLAPIENTRY
4882 save_TexBumpParameterivATI(GLenum pname, const GLint *param)
4883 {
4884 GLfloat p[4];
4885 p[0] = INT_TO_FLOAT(param[0]);
4886 p[1] = INT_TO_FLOAT(param[1]);
4887 p[2] = INT_TO_FLOAT(param[2]);
4888 p[3] = INT_TO_FLOAT(param[3]);
4889 save_TexBumpParameterfvATI(pname, p);
4890 }
4891
4892 #if FEATURE_ATI_fragment_shader
4893 static void GLAPIENTRY
4894 save_BindFragmentShaderATI(GLuint id)
4895 {
4896 GET_CURRENT_CONTEXT(ctx);
4897 Node *n;
4898
4899 n = ALLOC_INSTRUCTION(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
4900 if (n) {
4901 n[1].ui = id;
4902 }
4903 if (ctx->ExecuteFlag) {
4904 CALL_BindFragmentShaderATI(ctx->Exec, (id));
4905 }
4906 }
4907
4908 static void GLAPIENTRY
4909 save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value)
4910 {
4911 GET_CURRENT_CONTEXT(ctx);
4912 Node *n;
4913
4914 n = ALLOC_INSTRUCTION(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
4915 if (n) {
4916 n[1].ui = dst;
4917 n[2].f = value[0];
4918 n[3].f = value[1];
4919 n[4].f = value[2];
4920 n[5].f = value[3];
4921 }
4922 if (ctx->ExecuteFlag) {
4923 CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value));
4924 }
4925 }
4926 #endif
4927
4928 static void
4929 save_Attr1fNV(GLenum attr, GLfloat x)
4930 {
4931 GET_CURRENT_CONTEXT(ctx);
4932 Node *n;
4933 SAVE_FLUSH_VERTICES(ctx);
4934 n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_1F_NV, 2);
4935 if (n) {
4936 n[1].e = attr;
4937 n[2].f = x;
4938 }
4939
4940 ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
4941 ctx->ListState.ActiveAttribSize[attr] = 1;
4942 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
4943
4944 if (ctx->ExecuteFlag) {
4945 CALL_VertexAttrib1fNV(ctx->Exec, (attr, x));
4946 }
4947 }
4948
4949 static void
4950 save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y)
4951 {
4952 GET_CURRENT_CONTEXT(ctx);
4953 Node *n;
4954 SAVE_FLUSH_VERTICES(ctx);
4955 n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_2F_NV, 3);
4956 if (n) {
4957 n[1].e = attr;
4958 n[2].f = x;
4959 n[3].f = y;
4960 }
4961
4962 ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
4963 ctx->ListState.ActiveAttribSize[attr] = 2;
4964 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
4965
4966 if (ctx->ExecuteFlag) {
4967 CALL_VertexAttrib2fNV(ctx->Exec, (attr, x, y));
4968 }
4969 }
4970
4971 static void
4972 save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
4973 {
4974 GET_CURRENT_CONTEXT(ctx);
4975 Node *n;
4976 SAVE_FLUSH_VERTICES(ctx);
4977 n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_3F_NV, 4);
4978 if (n) {
4979 n[1].e = attr;
4980 n[2].f = x;
4981 n[3].f = y;
4982 n[4].f = z;
4983 }
4984
4985 ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
4986 ctx->ListState.ActiveAttribSize[attr] = 3;
4987 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
4988
4989 if (ctx->ExecuteFlag) {
4990 CALL_VertexAttrib3fNV(ctx->Exec, (attr, x, y, z));
4991 }
4992 }
4993
4994 static void
4995 save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4996 {
4997 GET_CURRENT_CONTEXT(ctx);
4998 Node *n;
4999 SAVE_FLUSH_VERTICES(ctx);
5000 n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_4F_NV, 5);
5001 if (n) {
5002 n[1].e = attr;
5003 n[2].f = x;
5004 n[3].f = y;
5005 n[4].f = z;
5006 n[5].f = w;
5007 }
5008
5009 ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
5010 ctx->ListState.ActiveAttribSize[attr] = 4;
5011 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
5012
5013 if (ctx->ExecuteFlag) {
5014 CALL_VertexAttrib4fNV(ctx->Exec, (attr, x, y, z, w));
5015 }
5016 }
5017
5018
5019 static void
5020 save_Attr1fARB(GLenum attr, GLfloat x)
5021 {
5022 GET_CURRENT_CONTEXT(ctx);
5023 Node *n;
5024 SAVE_FLUSH_VERTICES(ctx);
5025 n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_1F_ARB, 2);
5026 if (n) {
5027 n[1].e = attr;
5028 n[2].f = x;
5029 }
5030
5031 ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5032 ctx->ListState.ActiveAttribSize[attr] = 1;
5033 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
5034
5035 if (ctx->ExecuteFlag) {
5036 CALL_VertexAttrib1fARB(ctx->Exec, (attr, x));
5037 }
5038 }
5039
5040 static void
5041 save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y)
5042 {
5043 GET_CURRENT_CONTEXT(ctx);
5044 Node *n;
5045 SAVE_FLUSH_VERTICES(ctx);
5046 n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_2F_ARB, 3);
5047 if (n) {
5048 n[1].e = attr;
5049 n[2].f = x;
5050 n[3].f = y;
5051 }
5052
5053 ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5054 ctx->ListState.ActiveAttribSize[attr] = 2;
5055 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
5056
5057 if (ctx->ExecuteFlag) {
5058 CALL_VertexAttrib2fARB(ctx->Exec, (attr, x, y));
5059 }
5060 }
5061
5062 static void
5063 save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
5064 {
5065 GET_CURRENT_CONTEXT(ctx);
5066 Node *n;
5067 SAVE_FLUSH_VERTICES(ctx);
5068 n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_3F_ARB, 4);
5069 if (n) {
5070 n[1].e = attr;
5071 n[2].f = x;
5072 n[3].f = y;
5073 n[4].f = z;
5074 }
5075
5076 ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5077 ctx->ListState.ActiveAttribSize[attr] = 3;
5078 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
5079
5080 if (ctx->ExecuteFlag) {
5081 CALL_VertexAttrib3fARB(ctx->Exec, (attr, x, y, z));
5082 }
5083 }
5084
5085 static void
5086 save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5087 {
5088 GET_CURRENT_CONTEXT(ctx);
5089 Node *n;
5090 SAVE_FLUSH_VERTICES(ctx);
5091 n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_4F_ARB, 5);
5092 if (n) {
5093 n[1].e = attr;
5094 n[2].f = x;
5095 n[3].f = y;
5096 n[4].f = z;
5097 n[5].f = w;
5098 }
5099
5100 ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5101 ctx->ListState.ActiveAttribSize[attr] = 4;
5102 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
5103
5104 if (ctx->ExecuteFlag) {
5105 CALL_VertexAttrib4fARB(ctx->Exec, (attr, x, y, z, w));
5106 }
5107 }
5108
5109
5110 static void GLAPIENTRY
5111 save_EvalCoord1f(GLfloat x)
5112 {
5113 GET_CURRENT_CONTEXT(ctx);
5114 Node *n;
5115 SAVE_FLUSH_VERTICES(ctx);
5116 n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_C1, 1);
5117 if (n) {
5118 n[1].f = x;
5119 }
5120 if (ctx->ExecuteFlag) {
5121 CALL_EvalCoord1f(ctx->Exec, (x));
5122 }
5123 }
5124
5125 static void GLAPIENTRY
5126 save_EvalCoord1fv(const GLfloat * v)
5127 {
5128 save_EvalCoord1f(v[0]);
5129 }
5130
5131 static void GLAPIENTRY
5132 save_EvalCoord2f(GLfloat x, GLfloat y)
5133 {
5134 GET_CURRENT_CONTEXT(ctx);
5135 Node *n;
5136 SAVE_FLUSH_VERTICES(ctx);
5137 n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_C2, 2);
5138 if (n) {
5139 n[1].f = x;
5140 n[2].f = y;
5141 }
5142 if (ctx->ExecuteFlag) {
5143 CALL_EvalCoord2f(ctx->Exec, (x, y));
5144 }
5145 }
5146
5147 static void GLAPIENTRY
5148 save_EvalCoord2fv(const GLfloat * v)
5149 {
5150 save_EvalCoord2f(v[0], v[1]);
5151 }
5152
5153
5154 static void GLAPIENTRY
5155 save_EvalPoint1(GLint x)
5156 {
5157 GET_CURRENT_CONTEXT(ctx);
5158 Node *n;
5159 SAVE_FLUSH_VERTICES(ctx);
5160 n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_P1, 1);
5161 if (n) {
5162 n[1].i = x;
5163 }
5164 if (ctx->ExecuteFlag) {
5165 CALL_EvalPoint1(ctx->Exec, (x));
5166 }
5167 }
5168
5169 static void GLAPIENTRY
5170 save_EvalPoint2(GLint x, GLint y)
5171 {
5172 GET_CURRENT_CONTEXT(ctx);
5173 Node *n;
5174 SAVE_FLUSH_VERTICES(ctx);
5175 n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_P2, 2);
5176 if (n) {
5177 n[1].i = x;
5178 n[2].i = y;
5179 }
5180 if (ctx->ExecuteFlag) {
5181 CALL_EvalPoint2(ctx->Exec, (x, y));
5182 }
5183 }
5184
5185 static void GLAPIENTRY
5186 save_Indexf(GLfloat x)
5187 {
5188 save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, x);
5189 }
5190
5191 static void GLAPIENTRY
5192 save_Indexfv(const GLfloat * v)
5193 {
5194 save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, v[0]);
5195 }
5196
5197 static void GLAPIENTRY
5198 save_EdgeFlag(GLboolean x)
5199 {
5200 save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0);
5201 }
5202
5203 static INLINE GLboolean compare4fv( const GLfloat *a,
5204 const GLfloat *b,
5205 GLuint count )
5206 {
5207 return memcmp( a, b, count * sizeof(GLfloat) ) == 0;
5208 }
5209
5210
5211 static void GLAPIENTRY
5212 save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
5213 {
5214 GET_CURRENT_CONTEXT(ctx);
5215 Node *n;
5216 int args, i;
5217 GLuint bitmask;
5218
5219 switch (face) {
5220 case GL_BACK:
5221 case GL_FRONT:
5222 case GL_FRONT_AND_BACK:
5223 break;
5224 default:
5225 _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(face)");
5226 return;
5227 }
5228
5229 switch (pname) {
5230 case GL_EMISSION:
5231 case GL_AMBIENT:
5232 case GL_DIFFUSE:
5233 case GL_SPECULAR:
5234 case GL_AMBIENT_AND_DIFFUSE:
5235 args = 4;
5236 break;
5237 case GL_SHININESS:
5238 args = 1;
5239 break;
5240 case GL_COLOR_INDEXES:
5241 args = 3;
5242 break;
5243 default:
5244 _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)");
5245 return;
5246 }
5247
5248 if (ctx->ExecuteFlag) {
5249 CALL_Materialfv(ctx->Exec, (face, pname, param));
5250 }
5251
5252 bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL);
5253
5254 /* Try to eliminate redundant statechanges. Because it is legal to
5255 * call glMaterial even inside begin/end calls, don't need to worry
5256 * about ctx->Driver.CurrentSavePrimitive here.
5257 */
5258 for (i = 0; i < MAT_ATTRIB_MAX; i++) {
5259 if (bitmask & (1 << i)) {
5260 if (ctx->ListState.ActiveMaterialSize[i] == args &&
5261 compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) {
5262 bitmask &= ~(1 << i);
5263 }
5264 else {
5265 ctx->ListState.ActiveMaterialSize[i] = args;
5266 COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param);
5267 }
5268 }
5269 }
5270
5271 /* If this call has effect, return early:
5272 */
5273 if (bitmask == 0)
5274 return;
5275
5276 SAVE_FLUSH_VERTICES(ctx);
5277
5278 n = ALLOC_INSTRUCTION(ctx, OPCODE_MATERIAL, 6);
5279 if (n) {
5280 n[1].e = face;
5281 n[2].e = pname;
5282 for (i = 0; i < args; i++)
5283 n[3 + i].f = param[i];
5284 }
5285 }
5286
5287 static void GLAPIENTRY
5288 save_Begin(GLenum mode)
5289 {
5290 GET_CURRENT_CONTEXT(ctx);
5291 Node *n;
5292 GLboolean error = GL_FALSE;
5293
5294 if ( /*mode < GL_POINTS || */ mode > GL_POLYGON) {
5295 _mesa_compile_error(ctx, GL_INVALID_ENUM, "Begin (mode)");
5296 error = GL_TRUE;
5297 }
5298 else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) {
5299 /* Typically the first begin. This may raise an error on
5300 * playback, depending on whether CallList is issued from inside
5301 * a begin/end or not.
5302 */
5303 ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM;
5304 }
5305 else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) {
5306 ctx->Driver.CurrentSavePrimitive = mode;
5307 }
5308 else {
5309 _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin");
5310 error = GL_TRUE;
5311 }
5312
5313 if (!error) {
5314 /* Give the driver an opportunity to hook in an optimized
5315 * display list compiler.
5316 */
5317 if (ctx->Driver.NotifySaveBegin(ctx, mode))
5318 return;
5319
5320 SAVE_FLUSH_VERTICES(ctx);
5321 n = ALLOC_INSTRUCTION(ctx, OPCODE_BEGIN, 1);
5322 if (n) {
5323 n[1].e = mode;
5324 }
5325 }
5326
5327 if (ctx->ExecuteFlag) {
5328 CALL_Begin(ctx->Exec, (mode));
5329 }
5330 }
5331
5332 static void GLAPIENTRY
5333 save_End(void)
5334 {
5335 GET_CURRENT_CONTEXT(ctx);
5336 SAVE_FLUSH_VERTICES(ctx);
5337 (void) ALLOC_INSTRUCTION(ctx, OPCODE_END, 0);
5338 ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
5339 if (ctx->ExecuteFlag) {
5340 CALL_End(ctx->Exec, ());
5341 }
5342 }
5343
5344 static void GLAPIENTRY
5345 save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d)
5346 {
5347 GET_CURRENT_CONTEXT(ctx);
5348 Node *n;
5349 SAVE_FLUSH_VERTICES(ctx);
5350 n = ALLOC_INSTRUCTION(ctx, OPCODE_RECTF, 4);
5351 if (n) {
5352 n[1].f = a;
5353 n[2].f = b;
5354 n[3].f = c;
5355 n[4].f = d;
5356 }
5357 if (ctx->ExecuteFlag) {
5358 CALL_Rectf(ctx->Exec, (a, b, c, d));
5359 }
5360 }
5361
5362
5363 static void GLAPIENTRY
5364 save_Vertex2f(GLfloat x, GLfloat y)
5365 {
5366 save_Attr2fNV(VERT_ATTRIB_POS, x, y);
5367 }
5368
5369 static void GLAPIENTRY
5370 save_Vertex2fv(const GLfloat * v)
5371 {
5372 save_Attr2fNV(VERT_ATTRIB_POS, v[0], v[1]);
5373 }
5374
5375 static void GLAPIENTRY
5376 save_Vertex3f(GLfloat x, GLfloat y, GLfloat z)
5377 {
5378 save_Attr3fNV(VERT_ATTRIB_POS, x, y, z);
5379 }
5380
5381 static void GLAPIENTRY
5382 save_Vertex3fv(const GLfloat * v)
5383 {
5384 save_Attr3fNV(VERT_ATTRIB_POS, v[0], v[1], v[2]);
5385 }
5386
5387 static void GLAPIENTRY
5388 save_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5389 {
5390 save_Attr4fNV(VERT_ATTRIB_POS, x, y, z, w);
5391 }
5392
5393 static void GLAPIENTRY
5394 save_Vertex4fv(const GLfloat * v)
5395 {
5396 save_Attr4fNV(VERT_ATTRIB_POS, v[0], v[1], v[2], v[3]);
5397 }
5398
5399 static void GLAPIENTRY
5400 save_TexCoord1f(GLfloat x)
5401 {
5402 save_Attr1fNV(VERT_ATTRIB_TEX0, x);
5403 }
5404
5405 static void GLAPIENTRY
5406 save_TexCoord1fv(const GLfloat * v)
5407 {
5408 save_Attr1fNV(VERT_ATTRIB_TEX0, v[0]);
5409 }
5410
5411 static void GLAPIENTRY
5412 save_TexCoord2f(GLfloat x, GLfloat y)
5413 {
5414 save_Attr2fNV(VERT_ATTRIB_TEX0, x, y);
5415 }
5416
5417 static void GLAPIENTRY
5418 save_TexCoord2fv(const GLfloat * v)
5419 {
5420 save_Attr2fNV(VERT_ATTRIB_TEX0, v[0], v[1]);
5421 }
5422
5423 static void GLAPIENTRY
5424 save_TexCoord3f(GLfloat x, GLfloat y, GLfloat z)
5425 {
5426 save_Attr3fNV(VERT_ATTRIB_TEX0, x, y, z);
5427 }
5428
5429 static void GLAPIENTRY
5430 save_TexCoord3fv(const GLfloat * v)
5431 {
5432 save_Attr3fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2]);
5433 }
5434
5435 static void GLAPIENTRY
5436 save_TexCoord4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5437 {
5438 save_Attr4fNV(VERT_ATTRIB_TEX0, x, y, z, w);
5439 }
5440
5441 static void GLAPIENTRY
5442 save_TexCoord4fv(const GLfloat * v)
5443 {
5444 save_Attr4fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3]);
5445 }
5446
5447 static void GLAPIENTRY
5448 save_Normal3f(GLfloat x, GLfloat y, GLfloat z)
5449 {
5450 save_Attr3fNV(VERT_ATTRIB_NORMAL, x, y, z);
5451 }
5452
5453 static void GLAPIENTRY
5454 save_Normal3fv(const GLfloat * v)
5455 {
5456 save_Attr3fNV(VERT_ATTRIB_NORMAL, v[0], v[1], v[2]);
5457 }
5458
5459 static void GLAPIENTRY
5460 save_FogCoordfEXT(GLfloat x)
5461 {
5462 save_Attr1fNV(VERT_ATTRIB_FOG, x);
5463 }
5464
5465 static void GLAPIENTRY
5466 save_FogCoordfvEXT(const GLfloat * v)
5467 {
5468 save_Attr1fNV(VERT_ATTRIB_FOG, v[0]);
5469 }
5470
5471 static void GLAPIENTRY
5472 save_Color3f(GLfloat x, GLfloat y, GLfloat z)
5473 {
5474 save_Attr3fNV(VERT_ATTRIB_COLOR0, x, y, z);
5475 }
5476
5477 static void GLAPIENTRY
5478 save_Color3fv(const GLfloat * v)
5479 {
5480 save_Attr3fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2]);
5481 }
5482
5483 static void GLAPIENTRY
5484 save_Color4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5485 {
5486 save_Attr4fNV(VERT_ATTRIB_COLOR0, x, y, z, w);
5487 }
5488
5489 static void GLAPIENTRY
5490 save_Color4fv(const GLfloat * v)
5491 {
5492 save_Attr4fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3]);
5493 }
5494
5495 static void GLAPIENTRY
5496 save_SecondaryColor3fEXT(GLfloat x, GLfloat y, GLfloat z)
5497 {
5498 save_Attr3fNV(VERT_ATTRIB_COLOR1, x, y, z);
5499 }
5500
5501 static void GLAPIENTRY
5502 save_SecondaryColor3fvEXT(const GLfloat * v)
5503 {
5504 save_Attr3fNV(VERT_ATTRIB_COLOR1, v[0], v[1], v[2]);
5505 }
5506
5507
5508 /* Just call the respective ATTR for texcoord
5509 */
5510 static void GLAPIENTRY
5511 save_MultiTexCoord1f(GLenum target, GLfloat x)
5512 {
5513 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5514 save_Attr1fNV(attr, x);
5515 }
5516
5517 static void GLAPIENTRY
5518 save_MultiTexCoord1fv(GLenum target, const GLfloat * v)
5519 {
5520 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5521 save_Attr1fNV(attr, v[0]);
5522 }
5523
5524 static void GLAPIENTRY
5525 save_MultiTexCoord2f(GLenum target, GLfloat x, GLfloat y)
5526 {
5527 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5528 save_Attr2fNV(attr, x, y);
5529 }
5530
5531 static void GLAPIENTRY
5532 save_MultiTexCoord2fv(GLenum target, const GLfloat * v)
5533 {
5534 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5535 save_Attr2fNV(attr, v[0], v[1]);
5536 }
5537
5538 static void GLAPIENTRY
5539 save_MultiTexCoord3f(GLenum target, GLfloat x, GLfloat y, GLfloat z)
5540 {
5541 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5542 save_Attr3fNV(attr, x, y, z);
5543 }
5544
5545 static void GLAPIENTRY
5546 save_MultiTexCoord3fv(GLenum target, const GLfloat * v)
5547 {
5548 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5549 save_Attr3fNV(attr, v[0], v[1], v[2]);
5550 }
5551
5552 static void GLAPIENTRY
5553 save_MultiTexCoord4f(GLenum target, GLfloat x, GLfloat y,
5554 GLfloat z, GLfloat w)
5555 {
5556 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5557 save_Attr4fNV(attr, x, y, z, w);
5558 }
5559
5560 static void GLAPIENTRY
5561 save_MultiTexCoord4fv(GLenum target, const GLfloat * v)
5562 {
5563 GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5564 save_Attr4fNV(attr, v[0], v[1], v[2], v[3]);
5565 }
5566
5567
5568 /**
5569 * Record a GL_INVALID_VALUE error when a invalid vertex attribute
5570 * index is found.
5571 */
5572 static void
5573 index_error(void)
5574 {
5575 GET_CURRENT_CONTEXT(ctx);
5576 _mesa_error(ctx, GL_INVALID_VALUE, "VertexAttribf(index)");
5577 }
5578
5579
5580 /* First level for NV_vertex_program:
5581 *
5582 * Check for errors at compile time?.
5583 */
5584 static void GLAPIENTRY
5585 save_VertexAttrib1fNV(GLuint index, GLfloat x)
5586 {
5587 if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
5588 save_Attr1fNV(index, x);
5589 else
5590 index_error();
5591 }
5592
5593 static void GLAPIENTRY
5594 save_VertexAttrib1fvNV(GLuint index, const GLfloat * v)
5595 {
5596 if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
5597 save_Attr1fNV(index, v[0]);
5598 else
5599 index_error();
5600 }
5601
5602 static void GLAPIENTRY
5603 save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y)
5604 {
5605 if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
5606 save_Attr2fNV(index, x, y);
5607 else
5608 index_error();
5609 }
5610
5611 static void GLAPIENTRY
5612 save_VertexAttrib2fvNV(GLuint index, const GLfloat * v)
5613 {
5614 if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
5615 save_Attr2fNV(index, v[0], v[1]);
5616 else
5617 index_error();
5618 }
5619
5620 static void GLAPIENTRY
5621 save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z)
5622 {
5623 if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
5624 save_Attr3fNV(index, x, y, z);
5625 else
5626 index_error();
5627 }
5628
5629 static void GLAPIENTRY
5630 save_VertexAttrib3fvNV(GLuint index, const GLfloat * v)
5631 {
5632 if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
5633 save_Attr3fNV(index, v[0], v[1], v[2]);
5634 else
5635 index_error();
5636 }
5637
5638 static void GLAPIENTRY
5639 save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y,
5640 GLfloat z, GLfloat w)
5641 {
5642 if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
5643 save_Attr4fNV(index, x, y, z, w);
5644 else
5645 index_error();
5646 }
5647
5648 static void GLAPIENTRY
5649 save_VertexAttrib4fvNV(GLuint index, const GLfloat * v)
5650 {
5651 if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
5652 save_Attr4fNV(index, v[0], v[1], v[2], v[3]);
5653 else
5654 index_error();
5655 }
5656
5657
5658
5659
5660 static void GLAPIENTRY
5661 save_VertexAttrib1fARB(GLuint index, GLfloat x)
5662 {
5663 if (index < MAX_VERTEX_GENERIC_ATTRIBS)
5664 save_Attr1fARB(index, x);
5665 else
5666 index_error();
5667 }
5668
5669 static void GLAPIENTRY
5670 save_VertexAttrib1fvARB(GLuint index, const GLfloat * v)
5671 {
5672 if (index < MAX_VERTEX_GENERIC_ATTRIBS)
5673 save_Attr1fARB(index, v[0]);
5674 else
5675 index_error();
5676 }
5677
5678 static void GLAPIENTRY
5679 save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y)
5680 {
5681 if (index < MAX_VERTEX_GENERIC_ATTRIBS)
5682 save_Attr2fARB(index, x, y);
5683 else
5684 index_error();
5685 }
5686
5687 static void GLAPIENTRY
5688 save_VertexAttrib2fvARB(GLuint index, const GLfloat * v)
5689 {
5690 if (index < MAX_VERTEX_GENERIC_ATTRIBS)
5691 save_Attr2fARB(index, v[0], v[1]);
5692 else
5693 index_error();
5694 }
5695
5696 static void GLAPIENTRY
5697 save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z)
5698 {
5699 if (index < MAX_VERTEX_GENERIC_ATTRIBS)
5700 save_Attr3fARB(index, x, y, z);
5701 else
5702 index_error();
5703 }
5704
5705 static void GLAPIENTRY
5706 save_VertexAttrib3fvARB(GLuint index, const GLfloat * v)
5707 {
5708 if (index < MAX_VERTEX_GENERIC_ATTRIBS)
5709 save_Attr3fARB(index, v[0], v[1], v[2]);
5710 else
5711 index_error();
5712 }
5713
5714 static void GLAPIENTRY
5715 save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z,
5716 GLfloat w)
5717 {
5718 if (index < MAX_VERTEX_GENERIC_ATTRIBS)
5719 save_Attr4fARB(index, x, y, z, w);
5720 else
5721 index_error();
5722 }
5723
5724 static void GLAPIENTRY
5725 save_VertexAttrib4fvARB(GLuint index, const GLfloat * v)
5726 {
5727 if (index < MAX_VERTEX_GENERIC_ATTRIBS)
5728 save_Attr4fARB(index, v[0], v[1], v[2], v[3]);
5729 else
5730 index_error();
5731 }
5732
5733
5734 /* GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */
5735
5736 static void GLAPIENTRY
5737 exec_BindAttribLocationARB(GLuint program, GLuint index, const GLchar *name)
5738 {
5739 GET_CURRENT_CONTEXT(ctx);
5740 FLUSH_VERTICES(ctx, 0);
5741 CALL_BindAttribLocationARB(ctx->Exec, (program, index, name));
5742 }
5743
5744 static GLint GLAPIENTRY
5745 exec_GetAttribLocationARB(GLuint program, const GLchar *name)
5746 {
5747 GET_CURRENT_CONTEXT(ctx);
5748 FLUSH_VERTICES(ctx, 0);
5749 return CALL_GetAttribLocationARB(ctx->Exec, (program, name));
5750 }
5751 /* XXX more shader functions needed here */
5752
5753
5754
5755 #if FEATURE_EXT_framebuffer_blit
5756 static void GLAPIENTRY
5757 save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
5758 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
5759 GLbitfield mask, GLenum filter)
5760 {
5761 GET_CURRENT_CONTEXT(ctx);
5762 Node *n;
5763 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5764 n = ALLOC_INSTRUCTION(ctx, OPCODE_BLIT_FRAMEBUFFER, 10);
5765 if (n) {
5766 n[1].i = srcX0;
5767 n[2].i = srcY0;
5768 n[3].i = srcX1;
5769 n[4].i = srcY1;
5770 n[5].i = dstX0;
5771 n[6].i = dstY0;
5772 n[7].i = dstX1;
5773 n[8].i = dstY1;
5774 n[9].i = mask;
5775 n[10].e = filter;
5776 }
5777 if (ctx->ExecuteFlag) {
5778 CALL_BlitFramebufferEXT(ctx->Exec, (srcX0, srcY0, srcX1, srcY1,
5779 dstX0, dstY0, dstX1, dstY1,
5780 mask, filter));
5781 }
5782 }
5783 #endif
5784
5785
5786 /**
5787 * Save an error-generating command into display list.
5788 *
5789 * KW: Will appear in the list before the vertex buffer containing the
5790 * command that provoked the error. I don't see this as a problem.
5791 */
5792 static void
5793 save_error(GLcontext *ctx, GLenum error, const char *s)
5794 {
5795 Node *n;
5796 n = ALLOC_INSTRUCTION(ctx, OPCODE_ERROR, 2);
5797 if (n) {
5798 n[1].e = error;
5799 n[2].data = (void *) s;
5800 }
5801 }
5802
5803
5804 /**
5805 * Compile an error into current display list.
5806 */
5807 void
5808 _mesa_compile_error(GLcontext *ctx, GLenum error, const char *s)
5809 {
5810 if (ctx->CompileFlag)
5811 save_error(ctx, error, s);
5812 if (ctx->ExecuteFlag)
5813 _mesa_error(ctx, error, s);
5814 }
5815
5816
5817 /**
5818 * Test if ID names a display list.
5819 */
5820 static GLboolean
5821 islist(GLcontext *ctx, GLuint list)
5822 {
5823 if (list > 0 && lookup_list(ctx, list)) {
5824 return GL_TRUE;
5825 }
5826 else {
5827 return GL_FALSE;
5828 }
5829 }
5830
5831
5832
5833 /**********************************************************************/
5834 /* Display list execution */
5835 /**********************************************************************/
5836
5837
5838 /*
5839 * Execute a display list. Note that the ListBase offset must have already
5840 * been added before calling this function. I.e. the list argument is
5841 * the absolute list number, not relative to ListBase.
5842 * \param list - display list number
5843 */
5844 static void
5845 execute_list(GLcontext *ctx, GLuint list)
5846 {
5847 struct gl_display_list *dlist;
5848 Node *n;
5849 GLboolean done;
5850
5851 if (list == 0 || !islist(ctx, list))
5852 return;
5853
5854 if (ctx->ListState.CallDepth == MAX_LIST_NESTING) {
5855 /* raise an error? */
5856 return;
5857 }
5858
5859 dlist = lookup_list(ctx, list);
5860 if (!dlist)
5861 return;
5862
5863 ctx->ListState.CallDepth++;
5864
5865 if (ctx->Driver.BeginCallList)
5866 ctx->Driver.BeginCallList(ctx, dlist);
5867
5868 n = dlist->Head;
5869
5870 done = GL_FALSE;
5871 while (!done) {
5872 OpCode opcode = n[0].opcode;
5873 int i = (int) n[0].opcode - (int) OPCODE_EXT_0;
5874
5875 if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
5876 /* this is a driver-extended opcode */
5877 ctx->ListExt.Opcode[i].Execute(ctx, &n[1]);
5878 n += ctx->ListExt.Opcode[i].Size;
5879 }
5880 else {
5881 switch (opcode) {
5882 case OPCODE_ERROR:
5883 _mesa_error(ctx, n[1].e, (const char *) n[2].data);
5884 break;
5885 case OPCODE_ACCUM:
5886 CALL_Accum(ctx->Exec, (n[1].e, n[2].f));
5887 break;
5888 case OPCODE_ALPHA_FUNC:
5889 CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f));
5890 break;
5891 case OPCODE_BIND_TEXTURE:
5892 CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui));
5893 break;
5894 case OPCODE_BITMAP:
5895 {
5896 const struct gl_pixelstore_attrib save = ctx->Unpack;
5897 ctx->Unpack = ctx->DefaultPacking;
5898 CALL_Bitmap(ctx->Exec, ((GLsizei) n[1].i, (GLsizei) n[2].i,
5899 n[3].f, n[4].f, n[5].f, n[6].f,
5900 (const GLubyte *) n[7].data));
5901 ctx->Unpack = save; /* restore */
5902 }
5903 break;
5904 case OPCODE_BLEND_COLOR:
5905 CALL_BlendColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
5906 break;
5907 case OPCODE_BLEND_EQUATION:
5908 CALL_BlendEquation(ctx->Exec, (n[1].e));
5909 break;
5910 case OPCODE_BLEND_EQUATION_SEPARATE:
5911 CALL_BlendEquationSeparateEXT(ctx->Exec, (n[1].e, n[2].e));
5912 break;
5913 case OPCODE_BLEND_FUNC_SEPARATE:
5914 CALL_BlendFuncSeparateEXT(ctx->Exec,
5915 (n[1].e, n[2].e, n[3].e, n[4].e));
5916 break;
5917 case OPCODE_CALL_LIST:
5918 /* Generated by glCallList(), don't add ListBase */
5919 if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
5920 execute_list(ctx, n[1].ui);
5921 }
5922 break;
5923 case OPCODE_CALL_LIST_OFFSET:
5924 /* Generated by glCallLists() so we must add ListBase */
5925 if (n[2].b) {
5926 /* user specified a bad data type at compile time */
5927 _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
5928 }
5929 else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
5930 GLuint list = (GLuint) (ctx->List.ListBase + n[1].i);
5931 execute_list(ctx, list);
5932 }
5933 break;
5934 case OPCODE_CLEAR:
5935 CALL_Clear(ctx->Exec, (n[1].bf));
5936 break;
5937 case OPCODE_CLEAR_COLOR:
5938 CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
5939 break;
5940 case OPCODE_CLEAR_ACCUM:
5941 CALL_ClearAccum(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
5942 break;
5943 case OPCODE_CLEAR_DEPTH:
5944 CALL_ClearDepth(ctx->Exec, ((GLclampd) n[1].f));
5945 break;
5946 case OPCODE_CLEAR_INDEX:
5947 CALL_ClearIndex(ctx->Exec, ((GLfloat) n[1].ui));
5948 break;
5949 case OPCODE_CLEAR_STENCIL:
5950 CALL_ClearStencil(ctx->Exec, (n[1].i));
5951 break;
5952 case OPCODE_CLIP_PLANE:
5953 {
5954 GLdouble eq[4];
5955 eq[0] = n[2].f;
5956 eq[1] = n[3].f;
5957 eq[2] = n[4].f;
5958 eq[3] = n[5].f;
5959 CALL_ClipPlane(ctx->Exec, (n[1].e, eq));
5960 }
5961 break;
5962 case OPCODE_COLOR_MASK:
5963 CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b));
5964 break;
5965 case OPCODE_COLOR_MATERIAL:
5966 CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e));
5967 break;
5968 case OPCODE_COLOR_TABLE:
5969 {
5970 const struct gl_pixelstore_attrib save = ctx->Unpack;
5971 ctx->Unpack = ctx->DefaultPacking;
5972 CALL_ColorTable(ctx->Exec, (n[1].e, n[2].e, n[3].i, n[4].e,
5973 n[5].e, n[6].data));
5974 ctx->Unpack = save; /* restore */
5975 }
5976 break;
5977 case OPCODE_COLOR_TABLE_PARAMETER_FV:
5978 {
5979 GLfloat params[4];
5980 params[0] = n[3].f;
5981 params[1] = n[4].f;
5982 params[2] = n[5].f;
5983 params[3] = n[6].f;
5984 CALL_ColorTableParameterfv(ctx->Exec,
5985 (n[1].e, n[2].e, params));
5986 }
5987 break;
5988 case OPCODE_COLOR_TABLE_PARAMETER_IV:
5989 {
5990 GLint params[4];
5991 params[0] = n[3].i;
5992 params[1] = n[4].i;
5993 params[2] = n[5].i;
5994 params[3] = n[6].i;
5995 CALL_ColorTableParameteriv(ctx->Exec,
5996 (n[1].e, n[2].e, params));
5997 }
5998 break;
5999 case OPCODE_COLOR_SUB_TABLE:
6000 {
6001 const struct gl_pixelstore_attrib save = ctx->Unpack;
6002 ctx->Unpack = ctx->DefaultPacking;
6003 CALL_ColorSubTable(ctx->Exec, (n[1].e, n[2].i, n[3].i,
6004 n[4].e, n[5].e, n[6].data));
6005 ctx->Unpack = save; /* restore */
6006 }
6007 break;
6008 case OPCODE_CONVOLUTION_FILTER_1D:
6009 {
6010 const struct gl_pixelstore_attrib save = ctx->Unpack;
6011 ctx->Unpack = ctx->DefaultPacking;
6012 CALL_ConvolutionFilter1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
6013 n[4].e, n[5].e,
6014 n[6].data));
6015 ctx->Unpack = save; /* restore */
6016 }
6017 break;
6018 case OPCODE_CONVOLUTION_FILTER_2D:
6019 {
6020 const struct gl_pixelstore_attrib save = ctx->Unpack;
6021 ctx->Unpack = ctx->DefaultPacking;
6022 CALL_ConvolutionFilter2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
6023 n[4].i, n[5].e, n[6].e,
6024 n[7].data));
6025 ctx->Unpack = save; /* restore */
6026 }
6027 break;
6028 case OPCODE_CONVOLUTION_PARAMETER_I:
6029 CALL_ConvolutionParameteri(ctx->Exec, (n[1].e, n[2].e, n[3].i));
6030 break;
6031 case OPCODE_CONVOLUTION_PARAMETER_IV:
6032 {
6033 GLint params[4];
6034 params[0] = n[3].i;
6035 params[1] = n[4].i;
6036 params[2] = n[5].i;
6037 params[3] = n[6].i;
6038 CALL_ConvolutionParameteriv(ctx->Exec,
6039 (n[1].e, n[2].e, params));
6040 }
6041 break;
6042 case OPCODE_CONVOLUTION_PARAMETER_F:
6043 CALL_ConvolutionParameterf(ctx->Exec, (n[1].e, n[2].e, n[3].f));
6044 break;
6045 case OPCODE_CONVOLUTION_PARAMETER_FV:
6046 {
6047 GLfloat params[4];
6048 params[0] = n[3].f;
6049 params[1] = n[4].f;
6050 params[2] = n[5].f;
6051 params[3] = n[6].f;
6052 CALL_ConvolutionParameterfv(ctx->Exec,
6053 (n[1].e, n[2].e, params));
6054 }
6055 break;
6056 case OPCODE_COPY_COLOR_SUB_TABLE:
6057 CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i,
6058 n[3].i, n[4].i, n[5].i));
6059 break;
6060 case OPCODE_COPY_COLOR_TABLE:
6061 CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i,
6062 n[3].i, n[4].i, n[5].i));
6063 break;
6064 case OPCODE_COPY_PIXELS:
6065 CALL_CopyPixels(ctx->Exec, (n[1].i, n[2].i,
6066 (GLsizei) n[3].i, (GLsizei) n[4].i,
6067 n[5].e));
6068 break;
6069 case OPCODE_COPY_TEX_IMAGE1D:
6070 CALL_CopyTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i,
6071 n[5].i, n[6].i, n[7].i));
6072 break;
6073 case OPCODE_COPY_TEX_IMAGE2D:
6074 CALL_CopyTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i,
6075 n[5].i, n[6].i, n[7].i, n[8].i));
6076 break;
6077 case OPCODE_COPY_TEX_SUB_IMAGE1D:
6078 CALL_CopyTexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
6079 n[4].i, n[5].i, n[6].i));
6080 break;
6081 case OPCODE_COPY_TEX_SUB_IMAGE2D:
6082 CALL_CopyTexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
6083 n[4].i, n[5].i, n[6].i, n[7].i,
6084 n[8].i));
6085 break;
6086 case OPCODE_COPY_TEX_SUB_IMAGE3D:
6087 CALL_CopyTexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
6088 n[4].i, n[5].i, n[6].i, n[7].i,
6089 n[8].i, n[9].i));
6090 break;
6091 case OPCODE_CULL_FACE:
6092 CALL_CullFace(ctx->Exec, (n[1].e));
6093 break;
6094 case OPCODE_DEPTH_FUNC:
6095 CALL_DepthFunc(ctx->Exec, (n[1].e));
6096 break;
6097 case OPCODE_DEPTH_MASK:
6098 CALL_DepthMask(ctx->Exec, (n[1].b));
6099 break;
6100 case OPCODE_DEPTH_RANGE:
6101 CALL_DepthRange(ctx->Exec,
6102 ((GLclampd) n[1].f, (GLclampd) n[2].f));
6103 break;
6104 case OPCODE_DISABLE:
6105 CALL_Disable(ctx->Exec, (n[1].e));
6106 break;
6107 case OPCODE_DRAW_BUFFER:
6108 CALL_DrawBuffer(ctx->Exec, (n[1].e));
6109 break;
6110 case OPCODE_DRAW_PIXELS:
6111 {
6112 const struct gl_pixelstore_attrib save = ctx->Unpack;
6113 ctx->Unpack = ctx->DefaultPacking;
6114 CALL_DrawPixels(ctx->Exec, (n[1].i, n[2].i, n[3].e, n[4].e,
6115 n[5].data));
6116 ctx->Unpack = save; /* restore */
6117 }
6118 break;
6119 case OPCODE_ENABLE:
6120 CALL_Enable(ctx->Exec, (n[1].e));
6121 break;
6122 case OPCODE_EVALMESH1:
6123 CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i));
6124 break;
6125 case OPCODE_EVALMESH2:
6126 CALL_EvalMesh2(ctx->Exec,
6127 (n[1].e, n[2].i, n[3].i, n[4].i, n[5].i));
6128 break;
6129 case OPCODE_FOG:
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_Fogfv(ctx->Exec, (n[1].e, p));
6137 }
6138 break;
6139 case OPCODE_FRONT_FACE:
6140 CALL_FrontFace(ctx->Exec, (n[1].e));
6141 break;
6142 case OPCODE_FRUSTUM:
6143 CALL_Frustum(ctx->Exec,
6144 (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f));
6145 break;
6146 case OPCODE_HINT:
6147 CALL_Hint(ctx->Exec, (n[1].e, n[2].e));
6148 break;
6149 case OPCODE_HISTOGRAM:
6150 CALL_Histogram(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].b));
6151 break;
6152 case OPCODE_INDEX_MASK:
6153 CALL_IndexMask(ctx->Exec, (n[1].ui));
6154 break;
6155 case OPCODE_INIT_NAMES:
6156 CALL_InitNames(ctx->Exec, ());
6157 break;
6158 case OPCODE_LIGHT:
6159 {
6160 GLfloat p[4];
6161 p[0] = n[3].f;
6162 p[1] = n[4].f;
6163 p[2] = n[5].f;
6164 p[3] = n[6].f;
6165 CALL_Lightfv(ctx->Exec, (n[1].e, n[2].e, p));
6166 }
6167 break;
6168 case OPCODE_LIGHT_MODEL:
6169 {
6170 GLfloat p[4];
6171 p[0] = n[2].f;
6172 p[1] = n[3].f;
6173 p[2] = n[4].f;
6174 p[3] = n[5].f;
6175 CALL_LightModelfv(ctx->Exec, (n[1].e, p));
6176 }
6177 break;
6178 case OPCODE_LINE_STIPPLE:
6179 CALL_LineStipple(ctx->Exec, (n[1].i, n[2].us));
6180 break;
6181 case OPCODE_LINE_WIDTH:
6182 CALL_LineWidth(ctx->Exec, (n[1].f));
6183 break;
6184 case OPCODE_LIST_BASE:
6185 CALL_ListBase(ctx->Exec, (n[1].ui));
6186 break;
6187 case OPCODE_LOAD_IDENTITY:
6188 CALL_LoadIdentity(ctx->Exec, ());
6189 break;
6190 case OPCODE_LOAD_MATRIX:
6191 if (sizeof(Node) == sizeof(GLfloat)) {
6192 CALL_LoadMatrixf(ctx->Exec, (&n[1].f));
6193 }
6194 else {
6195 GLfloat m[16];
6196 GLuint i;
6197 for (i = 0; i < 16; i++) {
6198 m[i] = n[1 + i].f;
6199 }
6200 CALL_LoadMatrixf(ctx->Exec, (m));
6201 }
6202 break;
6203 case OPCODE_LOAD_NAME:
6204 CALL_LoadName(ctx->Exec, (n[1].ui));
6205 break;
6206 case OPCODE_LOGIC_OP:
6207 CALL_LogicOp(ctx->Exec, (n[1].e));
6208 break;
6209 case OPCODE_MAP1:
6210 {
6211 GLenum target = n[1].e;
6212 GLint ustride = _mesa_evaluator_components(target);
6213 GLint uorder = n[5].i;
6214 GLfloat u1 = n[2].f;
6215 GLfloat u2 = n[3].f;
6216 CALL_Map1f(ctx->Exec, (target, u1, u2, ustride, uorder,
6217 (GLfloat *) n[6].data));
6218 }
6219 break;
6220 case OPCODE_MAP2:
6221 {
6222 GLenum target = n[1].e;
6223 GLfloat u1 = n[2].f;
6224 GLfloat u2 = n[3].f;
6225 GLfloat v1 = n[4].f;
6226 GLfloat v2 = n[5].f;
6227 GLint ustride = n[6].i;
6228 GLint vstride = n[7].i;
6229 GLint uorder = n[8].i;
6230 GLint vorder = n[9].i;
6231 CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
6232 v1, v2, vstride, vorder,
6233 (GLfloat *) n[10].data));
6234 }
6235 break;
6236 case OPCODE_MAPGRID1:
6237 CALL_MapGrid1f(ctx->Exec, (n[1].i, n[2].f, n[3].f));
6238 break;
6239 case OPCODE_MAPGRID2:
6240 CALL_MapGrid2f(ctx->Exec,
6241 (n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f));
6242 break;
6243 case OPCODE_MATRIX_MODE:
6244 CALL_MatrixMode(ctx->Exec, (n[1].e));
6245 break;
6246 case OPCODE_MIN_MAX:
6247 CALL_Minmax(ctx->Exec, (n[1].e, n[2].e, n[3].b));
6248 break;
6249 case OPCODE_MULT_MATRIX:
6250 if (sizeof(Node) == sizeof(GLfloat)) {
6251 CALL_MultMatrixf(ctx->Exec, (&n[1].f));
6252 }
6253 else {
6254 GLfloat m[16];
6255 GLuint i;
6256 for (i = 0; i < 16; i++) {
6257 m[i] = n[1 + i].f;
6258 }
6259 CALL_MultMatrixf(ctx->Exec, (m));
6260 }
6261 break;
6262 case OPCODE_ORTHO:
6263 CALL_Ortho(ctx->Exec,
6264 (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f));
6265 break;
6266 case OPCODE_PASSTHROUGH:
6267 CALL_PassThrough(ctx->Exec, (n[1].f));
6268 break;
6269 case OPCODE_PIXEL_MAP:
6270 CALL_PixelMapfv(ctx->Exec,
6271 (n[1].e, n[2].i, (GLfloat *) n[3].data));
6272 break;
6273 case OPCODE_PIXEL_TRANSFER:
6274 CALL_PixelTransferf(ctx->Exec, (n[1].e, n[2].f));
6275 break;
6276 case OPCODE_PIXEL_ZOOM:
6277 CALL_PixelZoom(ctx->Exec, (n[1].f, n[2].f));
6278 break;
6279 case OPCODE_POINT_SIZE:
6280 CALL_PointSize(ctx->Exec, (n[1].f));
6281 break;
6282 case OPCODE_POINT_PARAMETERS:
6283 {
6284 GLfloat params[3];
6285 params[0] = n[2].f;
6286 params[1] = n[3].f;
6287 params[2] = n[4].f;
6288 CALL_PointParameterfvEXT(ctx->Exec, (n[1].e, params));
6289 }
6290 break;
6291 case OPCODE_POLYGON_MODE:
6292 CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e));
6293 break;
6294 case OPCODE_POLYGON_STIPPLE:
6295 {
6296 const struct gl_pixelstore_attrib save = ctx->Unpack;
6297 ctx->Unpack = ctx->DefaultPacking;
6298 CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data));
6299 ctx->Unpack = save; /* restore */
6300 }
6301 break;
6302 case OPCODE_POLYGON_OFFSET:
6303 CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f));
6304 break;
6305 case OPCODE_POP_ATTRIB:
6306 CALL_PopAttrib(ctx->Exec, ());
6307 break;
6308 case OPCODE_POP_MATRIX:
6309 CALL_PopMatrix(ctx->Exec, ());
6310 break;
6311 case OPCODE_POP_NAME:
6312 CALL_PopName(ctx->Exec, ());
6313 break;
6314 case OPCODE_PRIORITIZE_TEXTURE:
6315 CALL_PrioritizeTextures(ctx->Exec, (1, &n[1].ui, &n[2].f));
6316 break;
6317 case OPCODE_PUSH_ATTRIB:
6318 CALL_PushAttrib(ctx->Exec, (n[1].bf));
6319 break;
6320 case OPCODE_PUSH_MATRIX:
6321 CALL_PushMatrix(ctx->Exec, ());
6322 break;
6323 case OPCODE_PUSH_NAME:
6324 CALL_PushName(ctx->Exec, (n[1].ui));
6325 break;
6326 case OPCODE_RASTER_POS:
6327 CALL_RasterPos4f(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
6328 break;
6329 case OPCODE_READ_BUFFER:
6330 CALL_ReadBuffer(ctx->Exec, (n[1].e));
6331 break;
6332 case OPCODE_RESET_HISTOGRAM:
6333 CALL_ResetHistogram(ctx->Exec, (n[1].e));
6334 break;
6335 case OPCODE_RESET_MIN_MAX:
6336 CALL_ResetMinmax(ctx->Exec, (n[1].e));
6337 break;
6338 case OPCODE_ROTATE:
6339 CALL_Rotatef(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
6340 break;
6341 case OPCODE_SCALE:
6342 CALL_Scalef(ctx->Exec, (n[1].f, n[2].f, n[3].f));
6343 break;
6344 case OPCODE_SCISSOR:
6345 CALL_Scissor(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
6346 break;
6347 case OPCODE_SHADE_MODEL:
6348 CALL_ShadeModel(ctx->Exec, (n[1].e));
6349 break;
6350 case OPCODE_STENCIL_FUNC:
6351 CALL_StencilFunc(ctx->Exec, (n[1].e, n[2].i, n[3].ui));
6352 break;
6353 case OPCODE_STENCIL_MASK:
6354 CALL_StencilMask(ctx->Exec, (n[1].ui));
6355 break;
6356 case OPCODE_STENCIL_OP:
6357 CALL_StencilOp(ctx->Exec, (n[1].e, n[2].e, n[3].e));
6358 break;
6359 case OPCODE_STENCIL_FUNC_SEPARATE:
6360 CALL_StencilFuncSeparate(ctx->Exec,
6361 (n[1].e, n[2].e, n[3].i, n[4].ui));
6362 break;
6363 case OPCODE_STENCIL_MASK_SEPARATE:
6364 CALL_StencilMaskSeparate(ctx->Exec, (n[1].e, n[2].ui));
6365 break;
6366 case OPCODE_STENCIL_OP_SEPARATE:
6367 CALL_StencilOpSeparate(ctx->Exec,
6368 (n[1].e, n[2].e, n[3].e, n[4].e));
6369 break;
6370 case OPCODE_TEXENV:
6371 {
6372 GLfloat params[4];
6373 params[0] = n[3].f;
6374 params[1] = n[4].f;
6375 params[2] = n[5].f;
6376 params[3] = n[6].f;
6377 CALL_TexEnvfv(ctx->Exec, (n[1].e, n[2].e, params));
6378 }
6379 break;
6380 case OPCODE_TEXGEN:
6381 {
6382 GLfloat params[4];
6383 params[0] = n[3].f;
6384 params[1] = n[4].f;
6385 params[2] = n[5].f;
6386 params[3] = n[6].f;
6387 CALL_TexGenfv(ctx->Exec, (n[1].e, n[2].e, params));
6388 }
6389 break;
6390 case OPCODE_TEXPARAMETER:
6391 {
6392 GLfloat params[4];
6393 params[0] = n[3].f;
6394 params[1] = n[4].f;
6395 params[2] = n[5].f;
6396 params[3] = n[6].f;
6397 CALL_TexParameterfv(ctx->Exec, (n[1].e, n[2].e, params));
6398 }
6399 break;
6400 case OPCODE_TEX_IMAGE1D:
6401 {
6402 const struct gl_pixelstore_attrib save = ctx->Unpack;
6403 ctx->Unpack = ctx->DefaultPacking;
6404 CALL_TexImage1D(ctx->Exec, (n[1].e, /* target */
6405 n[2].i, /* level */
6406 n[3].i, /* components */
6407 n[4].i, /* width */
6408 n[5].e, /* border */
6409 n[6].e, /* format */
6410 n[7].e, /* type */
6411 n[8].data));
6412 ctx->Unpack = save; /* restore */
6413 }
6414 break;
6415 case OPCODE_TEX_IMAGE2D:
6416 {
6417 const struct gl_pixelstore_attrib save = ctx->Unpack;
6418 ctx->Unpack = ctx->DefaultPacking;
6419 CALL_TexImage2D(ctx->Exec, (n[1].e, /* target */
6420 n[2].i, /* level */
6421 n[3].i, /* components */
6422 n[4].i, /* width */
6423 n[5].i, /* height */
6424 n[6].e, /* border */
6425 n[7].e, /* format */
6426 n[8].e, /* type */
6427 n[9].data));
6428 ctx->Unpack = save; /* restore */
6429 }
6430 break;
6431 case OPCODE_TEX_IMAGE3D:
6432 {
6433 const struct gl_pixelstore_attrib save = ctx->Unpack;
6434 ctx->Unpack = ctx->DefaultPacking;
6435 CALL_TexImage3D(ctx->Exec, (n[1].e, /* target */
6436 n[2].i, /* level */
6437 n[3].i, /* components */
6438 n[4].i, /* width */
6439 n[5].i, /* height */
6440 n[6].i, /* depth */
6441 n[7].e, /* border */
6442 n[8].e, /* format */
6443 n[9].e, /* type */
6444 n[10].data));
6445 ctx->Unpack = save; /* restore */
6446 }
6447 break;
6448 case OPCODE_TEX_SUB_IMAGE1D:
6449 {
6450 const struct gl_pixelstore_attrib save = ctx->Unpack;
6451 ctx->Unpack = ctx->DefaultPacking;
6452 CALL_TexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
6453 n[4].i, n[5].e,
6454 n[6].e, n[7].data));
6455 ctx->Unpack = save; /* restore */
6456 }
6457 break;
6458 case OPCODE_TEX_SUB_IMAGE2D:
6459 {
6460 const struct gl_pixelstore_attrib save = ctx->Unpack;
6461 ctx->Unpack = ctx->DefaultPacking;
6462 CALL_TexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
6463 n[4].i, n[5].e,
6464 n[6].i, n[7].e, n[8].e,
6465 n[9].data));
6466 ctx->Unpack = save; /* restore */
6467 }
6468 break;
6469 case OPCODE_TEX_SUB_IMAGE3D:
6470 {
6471 const struct gl_pixelstore_attrib save = ctx->Unpack;
6472 ctx->Unpack = ctx->DefaultPacking;
6473 CALL_TexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
6474 n[4].i, n[5].i, n[6].i, n[7].i,
6475 n[8].i, n[9].e, n[10].e,
6476 n[11].data));
6477 ctx->Unpack = save; /* restore */
6478 }
6479 break;
6480 case OPCODE_TRANSLATE:
6481 CALL_Translatef(ctx->Exec, (n[1].f, n[2].f, n[3].f));
6482 break;
6483 case OPCODE_VIEWPORT:
6484 CALL_Viewport(ctx->Exec, (n[1].i, n[2].i,
6485 (GLsizei) n[3].i, (GLsizei) n[4].i));
6486 break;
6487 case OPCODE_WINDOW_POS:
6488 CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
6489 break;
6490 case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
6491 CALL_ActiveTextureARB(ctx->Exec, (n[1].e));
6492 break;
6493 case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */
6494 CALL_CompressedTexImage1DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e,
6495 n[4].i, n[5].i, n[6].i,
6496 n[7].data));
6497 break;
6498 case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */
6499 CALL_CompressedTexImage2DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e,
6500 n[4].i, n[5].i, n[6].i,
6501 n[7].i, n[8].data));
6502 break;
6503 case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */
6504 CALL_CompressedTexImage3DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e,
6505 n[4].i, n[5].i, n[6].i,
6506 n[7].i, n[8].i,
6507 n[9].data));
6508 break;
6509 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */
6510 CALL_CompressedTexSubImage1DARB(ctx->Exec,
6511 (n[1].e, n[2].i, n[3].i, n[4].i,
6512 n[5].e, n[6].i, n[7].data));
6513 break;
6514 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */
6515 CALL_CompressedTexSubImage2DARB(ctx->Exec,
6516 (n[1].e, n[2].i, n[3].i, n[4].i,
6517 n[5].i, n[6].i, n[7].e, n[8].i,
6518 n[9].data));
6519 break;
6520 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */
6521 CALL_CompressedTexSubImage3DARB(ctx->Exec,
6522 (n[1].e, n[2].i, n[3].i, n[4].i,
6523 n[5].i, n[6].i, n[7].i, n[8].i,
6524 n[9].e, n[10].i, n[11].data));
6525 break;
6526 case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */
6527 CALL_SampleCoverageARB(ctx->Exec, (n[1].f, n[2].b));
6528 break;
6529 case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */
6530 CALL_WindowPos3fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f));
6531 break;
6532 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
6533 case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */
6534 CALL_BindProgramNV(ctx->Exec, (n[1].e, n[2].ui));
6535 break;
6536 #endif
6537 #if FEATURE_NV_vertex_program
6538 case OPCODE_EXECUTE_PROGRAM_NV:
6539 {
6540 GLfloat v[4];
6541 v[0] = n[3].f;
6542 v[1] = n[4].f;
6543 v[2] = n[5].f;
6544 v[3] = n[6].f;
6545 CALL_ExecuteProgramNV(ctx->Exec, (n[1].e, n[2].ui, v));
6546 }
6547 break;
6548 case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
6549 CALL_RequestResidentProgramsNV(ctx->Exec, (n[1].ui,
6550 (GLuint *) n[2].data));
6551 break;
6552 case OPCODE_LOAD_PROGRAM_NV:
6553 CALL_LoadProgramNV(ctx->Exec, (n[1].e, n[2].ui, n[3].i,
6554 (const GLubyte *) n[4].data));
6555 break;
6556 case OPCODE_TRACK_MATRIX_NV:
6557 CALL_TrackMatrixNV(ctx->Exec, (n[1].e, n[2].ui, n[3].e, n[4].e));
6558 break;
6559 #endif
6560
6561 #if FEATURE_NV_fragment_program
6562 case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB:
6563 CALL_ProgramLocalParameter4fARB(ctx->Exec,
6564 (n[1].e, n[2].ui, n[3].f, n[4].f,
6565 n[5].f, n[6].f));
6566 break;
6567 case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
6568 CALL_ProgramNamedParameter4fNV(ctx->Exec, (n[1].ui, n[2].i,
6569 (const GLubyte *) n[3].
6570 data, n[4].f, n[5].f,
6571 n[6].f, n[7].f));
6572 break;
6573 #endif
6574
6575 case OPCODE_ACTIVE_STENCIL_FACE_EXT:
6576 CALL_ActiveStencilFaceEXT(ctx->Exec, (n[1].e));
6577 break;
6578 case OPCODE_DEPTH_BOUNDS_EXT:
6579 CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f));
6580 break;
6581 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
6582 case OPCODE_PROGRAM_STRING_ARB:
6583 CALL_ProgramStringARB(ctx->Exec,
6584 (n[1].e, n[2].e, n[3].i, n[4].data));
6585 break;
6586 #endif
6587 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program
6588 case OPCODE_PROGRAM_ENV_PARAMETER_ARB:
6589 CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f,
6590 n[4].f, n[5].f,
6591 n[6].f));
6592 break;
6593 #endif
6594 #if FEATURE_ARB_occlusion_query
6595 case OPCODE_BEGIN_QUERY_ARB:
6596 CALL_BeginQueryARB(ctx->Exec, (n[1].e, n[2].ui));
6597 break;
6598 case OPCODE_END_QUERY_ARB:
6599 CALL_EndQueryARB(ctx->Exec, (n[1].e));
6600 break;
6601 #endif
6602 case OPCODE_DRAW_BUFFERS_ARB:
6603 {
6604 GLenum buffers[MAX_DRAW_BUFFERS];
6605 GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS);
6606 for (i = 0; i < count; i++)
6607 buffers[i] = n[2 + i].e;
6608 CALL_DrawBuffersARB(ctx->Exec, (n[1].i, buffers));
6609 }
6610 break;
6611 #if FEATURE_EXT_framebuffer_blit
6612 case OPCODE_BLIT_FRAMEBUFFER:
6613 CALL_BlitFramebufferEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i,
6614 n[5].i, n[6].i, n[7].i, n[8].i,
6615 n[9].i, n[10].e));
6616 break;
6617 #endif
6618 case OPCODE_TEX_BUMP_PARAMETER_ATI:
6619 {
6620 GLfloat values[4];
6621 GLuint i, pname = n[1].ui;
6622
6623 for (i = 0; i < 4; i++)
6624 values[i] = n[1 + i].f;
6625 CALL_TexBumpParameterfvATI(ctx->Exec, (pname, values));
6626 }
6627 break;
6628 #if FEATURE_ATI_fragment_shader
6629 case OPCODE_BIND_FRAGMENT_SHADER_ATI:
6630 CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i));
6631 break;
6632 case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI:
6633 {
6634 GLfloat values[4];
6635 GLuint i, dst = n[1].ui;
6636
6637 for (i = 0; i < 4; i++)
6638 values[i] = n[1 + i].f;
6639 CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, values));
6640 }
6641 break;
6642 #endif
6643 case OPCODE_ATTR_1F_NV:
6644 CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f));
6645 break;
6646 case OPCODE_ATTR_2F_NV:
6647 /* Really shouldn't have to do this - the Node structure
6648 * is convenient, but it would be better to store the data
6649 * packed appropriately so that it can be sent directly
6650 * on. With x86_64 becoming common, this will start to
6651 * matter more.
6652 */
6653 if (sizeof(Node) == sizeof(GLfloat))
6654 CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f));
6655 else
6656 CALL_VertexAttrib2fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f));
6657 break;
6658 case OPCODE_ATTR_3F_NV:
6659 if (sizeof(Node) == sizeof(GLfloat))
6660 CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f));
6661 else
6662 CALL_VertexAttrib3fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f,
6663 n[4].f));
6664 break;
6665 case OPCODE_ATTR_4F_NV:
6666 if (sizeof(Node) == sizeof(GLfloat))
6667 CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f));
6668 else
6669 CALL_VertexAttrib4fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f,
6670 n[4].f, n[5].f));
6671 break;
6672 case OPCODE_ATTR_1F_ARB:
6673 CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f));
6674 break;
6675 case OPCODE_ATTR_2F_ARB:
6676 /* Really shouldn't have to do this - the Node structure
6677 * is convenient, but it would be better to store the data
6678 * packed appropriately so that it can be sent directly
6679 * on. With x86_64 becoming common, this will start to
6680 * matter more.
6681 */
6682 if (sizeof(Node) == sizeof(GLfloat))
6683 CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f));
6684 else
6685 CALL_VertexAttrib2fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f));
6686 break;
6687 case OPCODE_ATTR_3F_ARB:
6688 if (sizeof(Node) == sizeof(GLfloat))
6689 CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f));
6690 else
6691 CALL_VertexAttrib3fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f,
6692 n[4].f));
6693 break;
6694 case OPCODE_ATTR_4F_ARB:
6695 if (sizeof(Node) == sizeof(GLfloat))
6696 CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f));
6697 else
6698 CALL_VertexAttrib4fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f,
6699 n[4].f, n[5].f));
6700 break;
6701 case OPCODE_MATERIAL:
6702 if (sizeof(Node) == sizeof(GLfloat))
6703 CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f));
6704 else {
6705 GLfloat f[4];
6706 f[0] = n[3].f;
6707 f[1] = n[4].f;
6708 f[2] = n[5].f;
6709 f[3] = n[6].f;
6710 CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, f));
6711 }
6712 break;
6713 case OPCODE_BEGIN:
6714 CALL_Begin(ctx->Exec, (n[1].e));
6715 break;
6716 case OPCODE_END:
6717 CALL_End(ctx->Exec, ());
6718 break;
6719 case OPCODE_RECTF:
6720 CALL_Rectf(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
6721 break;
6722 case OPCODE_EVAL_C1:
6723 CALL_EvalCoord1f(ctx->Exec, (n[1].f));
6724 break;
6725 case OPCODE_EVAL_C2:
6726 CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f));
6727 break;
6728 case OPCODE_EVAL_P1:
6729 CALL_EvalPoint1(ctx->Exec, (n[1].i));
6730 break;
6731 case OPCODE_EVAL_P2:
6732 CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i));
6733 break;
6734
6735 case OPCODE_CONTINUE:
6736 n = (Node *) n[1].next;
6737 break;
6738 case OPCODE_END_OF_LIST:
6739 done = GL_TRUE;
6740 break;
6741 default:
6742 {
6743 char msg[1000];
6744 _mesa_sprintf(msg, "Error in execute_list: opcode=%d",
6745 (int) opcode);
6746 _mesa_problem(ctx, msg);
6747 }
6748 done = GL_TRUE;
6749 }
6750
6751 /* increment n to point to next compiled command */
6752 if (opcode != OPCODE_CONTINUE) {
6753 n += InstSize[opcode];
6754 }
6755 }
6756 }
6757
6758 if (ctx->Driver.EndCallList)
6759 ctx->Driver.EndCallList(ctx);
6760
6761 ctx->ListState.CallDepth--;
6762 }
6763
6764
6765
6766 /**********************************************************************/
6767 /* GL functions */
6768 /**********************************************************************/
6769
6770 /**
6771 * Test if a display list number is valid.
6772 */
6773 GLboolean GLAPIENTRY
6774 _mesa_IsList(GLuint list)
6775 {
6776 GET_CURRENT_CONTEXT(ctx);
6777 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
6778 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
6779 return islist(ctx, list);
6780 }
6781
6782
6783 /**
6784 * Delete a sequence of consecutive display lists.
6785 */
6786 void GLAPIENTRY
6787 _mesa_DeleteLists(GLuint list, GLsizei range)
6788 {
6789 GET_CURRENT_CONTEXT(ctx);
6790 GLuint i;
6791 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
6792 ASSERT_OUTSIDE_BEGIN_END(ctx);
6793
6794 if (range < 0) {
6795 _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists");
6796 return;
6797 }
6798 for (i = list; i < list + range; i++) {
6799 destroy_list(ctx, i);
6800 }
6801 }
6802
6803
6804 /**
6805 * Return a display list number, n, such that lists n through n+range-1
6806 * are free.
6807 */
6808 GLuint GLAPIENTRY
6809 _mesa_GenLists(GLsizei range)
6810 {
6811 GET_CURRENT_CONTEXT(ctx);
6812 GLuint base;
6813 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
6814 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
6815
6816 if (range < 0) {
6817 _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists");
6818 return 0;
6819 }
6820 if (range == 0) {
6821 return 0;
6822 }
6823
6824 /*
6825 * Make this an atomic operation
6826 */
6827 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
6828
6829 base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
6830 if (base) {
6831 /* reserve the list IDs by with empty/dummy lists */
6832 GLint i;
6833 for (i = 0; i < range; i++) {
6834 _mesa_HashInsert(ctx->Shared->DisplayList, base + i,
6835 make_list(base + i, 1));
6836 }
6837 }
6838
6839 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
6840
6841 return base;
6842 }
6843
6844
6845 /**
6846 * Begin a new display list.
6847 */
6848 void GLAPIENTRY
6849 _mesa_NewList(GLuint name, GLenum mode)
6850 {
6851 GET_CURRENT_CONTEXT(ctx);
6852
6853 FLUSH_CURRENT(ctx, 0); /* must be called before assert */
6854 ASSERT_OUTSIDE_BEGIN_END(ctx);
6855
6856 if (MESA_VERBOSE & VERBOSE_API)
6857 _mesa_debug(ctx, "glNewList %u %s\n", name,
6858 _mesa_lookup_enum_by_nr(mode));
6859
6860 if (name == 0) {
6861 _mesa_error(ctx, GL_INVALID_VALUE, "glNewList");
6862 return;
6863 }
6864
6865 if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) {
6866 _mesa_error(ctx, GL_INVALID_ENUM, "glNewList");
6867 return;
6868 }
6869
6870 if (ctx->ListState.CurrentList) {
6871 /* already compiling a display list */
6872 _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
6873 return;
6874 }
6875
6876 ctx->CompileFlag = GL_TRUE;
6877 ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
6878
6879 /* Reset acumulated list state:
6880 */
6881 invalidate_saved_current_state( ctx );
6882
6883 /* Allocate new display list */
6884 ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE);
6885 ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head;
6886 ctx->ListState.CurrentPos = 0;
6887
6888 ctx->Driver.NewList(ctx, name, mode);
6889
6890 ctx->CurrentDispatch = ctx->Save;
6891 _glapi_set_dispatch(ctx->CurrentDispatch);
6892 }
6893
6894
6895 /**
6896 * End definition of current display list.
6897 */
6898 void GLAPIENTRY
6899 _mesa_EndList(void)
6900 {
6901 GET_CURRENT_CONTEXT(ctx);
6902 SAVE_FLUSH_VERTICES(ctx);
6903 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
6904
6905 if (MESA_VERBOSE & VERBOSE_API)
6906 _mesa_debug(ctx, "glEndList\n");
6907
6908 /* Check that a list is under construction */
6909 if (!ctx->ListState.CurrentList) {
6910 _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList");
6911 return;
6912 }
6913
6914 /* Call before emitting END_OF_LIST, in case the driver wants to
6915 * emit opcodes itself.
6916 */
6917 ctx->Driver.EndList(ctx);
6918
6919 (void) ALLOC_INSTRUCTION(ctx, OPCODE_END_OF_LIST, 0);
6920
6921 /* Destroy old list, if any */
6922 destroy_list(ctx, ctx->ListState.CurrentList->Name);
6923
6924 /* Install the new list */
6925 _mesa_HashInsert(ctx->Shared->DisplayList,
6926 ctx->ListState.CurrentList->Name,
6927 ctx->ListState.CurrentList);
6928
6929
6930 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
6931 mesa_print_display_list(ctx->ListState.CurrentList->Name);
6932
6933 ctx->ListState.CurrentList = NULL;
6934 ctx->ExecuteFlag = GL_TRUE;
6935 ctx->CompileFlag = GL_FALSE;
6936
6937 ctx->CurrentDispatch = ctx->Exec;
6938 _glapi_set_dispatch(ctx->CurrentDispatch);
6939 }
6940
6941
6942 void GLAPIENTRY
6943 _mesa_CallList(GLuint list)
6944 {
6945 GLboolean save_compile_flag;
6946 GET_CURRENT_CONTEXT(ctx);
6947 FLUSH_CURRENT(ctx, 0);
6948 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
6949 /* execute the display list, and restore the CompileFlag. */
6950
6951 if (MESA_VERBOSE & VERBOSE_API)
6952 _mesa_debug(ctx, "glCallList %d\n", list);
6953
6954 if (list == 0) {
6955 _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)");
6956 return;
6957 }
6958
6959 /* mesa_print_display_list( list ); */
6960
6961 save_compile_flag = ctx->CompileFlag;
6962 if (save_compile_flag) {
6963 ctx->CompileFlag = GL_FALSE;
6964 }
6965
6966 execute_list(ctx, list);
6967 ctx->CompileFlag = save_compile_flag;
6968
6969 /* also restore API function pointers to point to "save" versions */
6970 if (save_compile_flag) {
6971 ctx->CurrentDispatch = ctx->Save;
6972 _glapi_set_dispatch(ctx->CurrentDispatch);
6973 }
6974 }
6975
6976
6977 /**
6978 * Execute glCallLists: call multiple display lists.
6979 */
6980 void GLAPIENTRY
6981 _mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
6982 {
6983 GET_CURRENT_CONTEXT(ctx);
6984 GLint i;
6985 GLboolean save_compile_flag;
6986
6987 if (MESA_VERBOSE & VERBOSE_API)
6988 _mesa_debug(ctx, "glCallLists %d\n", n);
6989
6990 switch (type) {
6991 case GL_BYTE:
6992 case GL_UNSIGNED_BYTE:
6993 case GL_SHORT:
6994 case GL_UNSIGNED_SHORT:
6995 case GL_INT:
6996 case GL_UNSIGNED_INT:
6997 case GL_FLOAT:
6998 case GL_2_BYTES:
6999 case GL_3_BYTES:
7000 case GL_4_BYTES:
7001 /* OK */
7002 break;
7003 default:
7004 _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
7005 return;
7006 }
7007
7008 /* Save the CompileFlag status, turn it off, execute display list,
7009 * and restore the CompileFlag.
7010 */
7011 save_compile_flag = ctx->CompileFlag;
7012 ctx->CompileFlag = GL_FALSE;
7013
7014 for (i = 0; i < n; i++) {
7015 GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists));
7016 execute_list(ctx, list);
7017 }
7018
7019 ctx->CompileFlag = save_compile_flag;
7020
7021 /* also restore API function pointers to point to "save" versions */
7022 if (save_compile_flag) {
7023 ctx->CurrentDispatch = ctx->Save;
7024 _glapi_set_dispatch(ctx->CurrentDispatch);
7025 }
7026 }
7027
7028
7029 /**
7030 * Set the offset added to list numbers in glCallLists.
7031 */
7032 void GLAPIENTRY
7033 _mesa_ListBase(GLuint base)
7034 {
7035 GET_CURRENT_CONTEXT(ctx);
7036 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
7037 ASSERT_OUTSIDE_BEGIN_END(ctx);
7038 ctx->List.ListBase = base;
7039 }
7040
7041
7042 /* Can no longer assume ctx->Exec->Func is equal to _mesa_Func.
7043 */
7044 static void GLAPIENTRY
7045 exec_Finish(void)
7046 {
7047 GET_CURRENT_CONTEXT(ctx);
7048 FLUSH_VERTICES(ctx, 0);
7049 CALL_Finish(ctx->Exec, ());
7050 }
7051
7052 static void GLAPIENTRY
7053 exec_Flush(void)
7054 {
7055 GET_CURRENT_CONTEXT(ctx);
7056 FLUSH_VERTICES(ctx, 0);
7057 CALL_Flush(ctx->Exec, ());
7058 }
7059
7060 static void GLAPIENTRY
7061 exec_GetBooleanv(GLenum pname, GLboolean *params)
7062 {
7063 GET_CURRENT_CONTEXT(ctx);
7064 FLUSH_VERTICES(ctx, 0);
7065 CALL_GetBooleanv(ctx->Exec, (pname, params));
7066 }
7067
7068 static void GLAPIENTRY
7069 exec_GetClipPlane(GLenum plane, GLdouble * equation)
7070 {
7071 GET_CURRENT_CONTEXT(ctx);
7072 FLUSH_VERTICES(ctx, 0);
7073 CALL_GetClipPlane(ctx->Exec, (plane, equation));
7074 }
7075
7076 static void GLAPIENTRY
7077 exec_GetDoublev(GLenum pname, GLdouble *params)
7078 {
7079 GET_CURRENT_CONTEXT(ctx);
7080 FLUSH_VERTICES(ctx, 0);
7081 CALL_GetDoublev(ctx->Exec, (pname, params));
7082 }
7083
7084 static GLenum GLAPIENTRY
7085 exec_GetError(void)
7086 {
7087 GET_CURRENT_CONTEXT(ctx);
7088 FLUSH_VERTICES(ctx, 0);
7089 return CALL_GetError(ctx->Exec, ());
7090 }
7091
7092 static void GLAPIENTRY
7093 exec_GetFloatv(GLenum pname, GLfloat *params)
7094 {
7095 GET_CURRENT_CONTEXT(ctx);
7096 FLUSH_VERTICES(ctx, 0);
7097 CALL_GetFloatv(ctx->Exec, (pname, params));
7098 }
7099
7100 static void GLAPIENTRY
7101 exec_GetIntegerv(GLenum pname, GLint *params)
7102 {
7103 GET_CURRENT_CONTEXT(ctx);
7104 FLUSH_VERTICES(ctx, 0);
7105 CALL_GetIntegerv(ctx->Exec, (pname, params));
7106 }
7107
7108 static void GLAPIENTRY
7109 exec_GetLightfv(GLenum light, GLenum pname, GLfloat *params)
7110 {
7111 GET_CURRENT_CONTEXT(ctx);
7112 FLUSH_VERTICES(ctx, 0);
7113 CALL_GetLightfv(ctx->Exec, (light, pname, params));
7114 }
7115
7116 static void GLAPIENTRY
7117 exec_GetLightiv(GLenum light, GLenum pname, GLint *params)
7118 {
7119 GET_CURRENT_CONTEXT(ctx);
7120 FLUSH_VERTICES(ctx, 0);
7121 CALL_GetLightiv(ctx->Exec, (light, pname, params));
7122 }
7123
7124 static void GLAPIENTRY
7125 exec_GetMapdv(GLenum target, GLenum query, GLdouble * v)
7126 {
7127 GET_CURRENT_CONTEXT(ctx);
7128 FLUSH_VERTICES(ctx, 0);
7129 CALL_GetMapdv(ctx->Exec, (target, query, v));
7130 }
7131
7132 static void GLAPIENTRY
7133 exec_GetMapfv(GLenum target, GLenum query, GLfloat * v)
7134 {
7135 GET_CURRENT_CONTEXT(ctx);
7136 FLUSH_VERTICES(ctx, 0);
7137 CALL_GetMapfv(ctx->Exec, (target, query, v));
7138 }
7139
7140 static void GLAPIENTRY
7141 exec_GetMapiv(GLenum target, GLenum query, GLint * v)
7142 {
7143 GET_CURRENT_CONTEXT(ctx);
7144 FLUSH_VERTICES(ctx, 0);
7145 CALL_GetMapiv(ctx->Exec, (target, query, v));
7146 }
7147
7148 static void GLAPIENTRY
7149 exec_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params)
7150 {
7151 GET_CURRENT_CONTEXT(ctx);
7152 FLUSH_VERTICES(ctx, 0);
7153 CALL_GetMaterialfv(ctx->Exec, (face, pname, params));
7154 }
7155
7156 static void GLAPIENTRY
7157 exec_GetMaterialiv(GLenum face, GLenum pname, GLint *params)
7158 {
7159 GET_CURRENT_CONTEXT(ctx);
7160 FLUSH_VERTICES(ctx, 0);
7161 CALL_GetMaterialiv(ctx->Exec, (face, pname, params));
7162 }
7163
7164 static void GLAPIENTRY
7165 exec_GetPixelMapfv(GLenum map, GLfloat *values)
7166 {
7167 GET_CURRENT_CONTEXT(ctx);
7168 FLUSH_VERTICES(ctx, 0);
7169 CALL_GetPixelMapfv(ctx->Exec, (map, values));
7170 }
7171
7172 static void GLAPIENTRY
7173 exec_GetPixelMapuiv(GLenum map, GLuint *values)
7174 {
7175 GET_CURRENT_CONTEXT(ctx);
7176 FLUSH_VERTICES(ctx, 0);
7177 CALL_GetPixelMapuiv(ctx->Exec, (map, values));
7178 }
7179
7180 static void GLAPIENTRY
7181 exec_GetPixelMapusv(GLenum map, GLushort *values)
7182 {
7183 GET_CURRENT_CONTEXT(ctx);
7184 FLUSH_VERTICES(ctx, 0);
7185 CALL_GetPixelMapusv(ctx->Exec, (map, values));
7186 }
7187
7188 static void GLAPIENTRY
7189 exec_GetPolygonStipple(GLubyte * dest)
7190 {
7191 GET_CURRENT_CONTEXT(ctx);
7192 FLUSH_VERTICES(ctx, 0);
7193 CALL_GetPolygonStipple(ctx->Exec, (dest));
7194 }
7195
7196 static const GLubyte *GLAPIENTRY
7197 exec_GetString(GLenum name)
7198 {
7199 GET_CURRENT_CONTEXT(ctx);
7200 FLUSH_VERTICES(ctx, 0);
7201 return CALL_GetString(ctx->Exec, (name));
7202 }
7203
7204 static void GLAPIENTRY
7205 exec_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params)
7206 {
7207 GET_CURRENT_CONTEXT(ctx);
7208 FLUSH_VERTICES(ctx, 0);
7209 CALL_GetTexEnvfv(ctx->Exec, (target, pname, params));
7210 }
7211
7212 static void GLAPIENTRY
7213 exec_GetTexEnviv(GLenum target, GLenum pname, GLint *params)
7214 {
7215 GET_CURRENT_CONTEXT(ctx);
7216 FLUSH_VERTICES(ctx, 0);
7217 CALL_GetTexEnviv(ctx->Exec, (target, pname, params));
7218 }
7219
7220 static void GLAPIENTRY
7221 exec_GetTexGendv(GLenum coord, GLenum pname, GLdouble *params)
7222 {
7223 GET_CURRENT_CONTEXT(ctx);
7224 FLUSH_VERTICES(ctx, 0);
7225 CALL_GetTexGendv(ctx->Exec, (coord, pname, params));
7226 }
7227
7228 static void GLAPIENTRY
7229 exec_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params)
7230 {
7231 GET_CURRENT_CONTEXT(ctx);
7232 FLUSH_VERTICES(ctx, 0);
7233 CALL_GetTexGenfv(ctx->Exec, (coord, pname, params));
7234 }
7235
7236 static void GLAPIENTRY
7237 exec_GetTexGeniv(GLenum coord, GLenum pname, GLint *params)
7238 {
7239 GET_CURRENT_CONTEXT(ctx);
7240 FLUSH_VERTICES(ctx, 0);
7241 CALL_GetTexGeniv(ctx->Exec, (coord, pname, params));
7242 }
7243
7244 static void GLAPIENTRY
7245 exec_GetTexImage(GLenum target, GLint level, GLenum format,
7246 GLenum type, GLvoid * pixels)
7247 {
7248 GET_CURRENT_CONTEXT(ctx);
7249 FLUSH_VERTICES(ctx, 0);
7250 CALL_GetTexImage(ctx->Exec, (target, level, format, type, pixels));
7251 }
7252
7253 static void GLAPIENTRY
7254 exec_GetTexLevelParameterfv(GLenum target, GLint level,
7255 GLenum pname, GLfloat *params)
7256 {
7257 GET_CURRENT_CONTEXT(ctx);
7258 FLUSH_VERTICES(ctx, 0);
7259 CALL_GetTexLevelParameterfv(ctx->Exec, (target, level, pname, params));
7260 }
7261
7262 static void GLAPIENTRY
7263 exec_GetTexLevelParameteriv(GLenum target, GLint level,
7264 GLenum pname, GLint *params)
7265 {
7266 GET_CURRENT_CONTEXT(ctx);
7267 FLUSH_VERTICES(ctx, 0);
7268 CALL_GetTexLevelParameteriv(ctx->Exec, (target, level, pname, params));
7269 }
7270
7271 static void GLAPIENTRY
7272 exec_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
7273 {
7274 GET_CURRENT_CONTEXT(ctx);
7275 FLUSH_VERTICES(ctx, 0);
7276 CALL_GetTexParameterfv(ctx->Exec, (target, pname, params));
7277 }
7278
7279 static void GLAPIENTRY
7280 exec_GetTexParameteriv(GLenum target, GLenum pname, GLint *params)
7281 {
7282 GET_CURRENT_CONTEXT(ctx);
7283 FLUSH_VERTICES(ctx, 0);
7284 CALL_GetTexParameteriv(ctx->Exec, (target, pname, params));
7285 }
7286
7287 static GLboolean GLAPIENTRY
7288 exec_IsEnabled(GLenum cap)
7289 {
7290 GET_CURRENT_CONTEXT(ctx);
7291 FLUSH_VERTICES(ctx, 0);
7292 return CALL_IsEnabled(ctx->Exec, (cap));
7293 }
7294
7295 static void GLAPIENTRY
7296 exec_PixelStoref(GLenum pname, GLfloat param)
7297 {
7298 GET_CURRENT_CONTEXT(ctx);
7299 FLUSH_VERTICES(ctx, 0);
7300 CALL_PixelStoref(ctx->Exec, (pname, param));
7301 }
7302
7303 static void GLAPIENTRY
7304 exec_PixelStorei(GLenum pname, GLint param)
7305 {
7306 GET_CURRENT_CONTEXT(ctx);
7307 FLUSH_VERTICES(ctx, 0);
7308 CALL_PixelStorei(ctx->Exec, (pname, param));
7309 }
7310
7311 static void GLAPIENTRY
7312 exec_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
7313 GLenum format, GLenum type, GLvoid * pixels)
7314 {
7315 GET_CURRENT_CONTEXT(ctx);
7316 FLUSH_VERTICES(ctx, 0);
7317 CALL_ReadPixels(ctx->Exec, (x, y, width, height, format, type, pixels));
7318 }
7319
7320 static GLint GLAPIENTRY
7321 exec_RenderMode(GLenum mode)
7322 {
7323 GET_CURRENT_CONTEXT(ctx);
7324 FLUSH_VERTICES(ctx, 0);
7325 return CALL_RenderMode(ctx->Exec, (mode));
7326 }
7327
7328 static void GLAPIENTRY
7329 exec_FeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer)
7330 {
7331 GET_CURRENT_CONTEXT(ctx);
7332 FLUSH_VERTICES(ctx, 0);
7333 CALL_FeedbackBuffer(ctx->Exec, (size, type, buffer));
7334 }
7335
7336 static void GLAPIENTRY
7337 exec_SelectBuffer(GLsizei size, GLuint * buffer)
7338 {
7339 GET_CURRENT_CONTEXT(ctx);
7340 FLUSH_VERTICES(ctx, 0);
7341 CALL_SelectBuffer(ctx->Exec, (size, buffer));
7342 }
7343
7344 static GLboolean GLAPIENTRY
7345 exec_AreTexturesResident(GLsizei n, const GLuint * texName,
7346 GLboolean * residences)
7347 {
7348 GET_CURRENT_CONTEXT(ctx);
7349 FLUSH_VERTICES(ctx, 0);
7350 return CALL_AreTexturesResident(ctx->Exec, (n, texName, residences));
7351 }
7352
7353 static void GLAPIENTRY
7354 exec_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
7355 {
7356 GET_CURRENT_CONTEXT(ctx);
7357 FLUSH_VERTICES(ctx, 0);
7358 CALL_ColorPointer(ctx->Exec, (size, type, stride, ptr));
7359 }
7360
7361 static void GLAPIENTRY
7362 exec_DeleteTextures(GLsizei n, const GLuint * texName)
7363 {
7364 GET_CURRENT_CONTEXT(ctx);
7365 FLUSH_VERTICES(ctx, 0);
7366 CALL_DeleteTextures(ctx->Exec, (n, texName));
7367 }
7368
7369 static void GLAPIENTRY
7370 exec_DisableClientState(GLenum cap)
7371 {
7372 GET_CURRENT_CONTEXT(ctx);
7373 FLUSH_VERTICES(ctx, 0);
7374 CALL_DisableClientState(ctx->Exec, (cap));
7375 }
7376
7377 static void GLAPIENTRY
7378 exec_EdgeFlagPointer(GLsizei stride, const GLvoid * vptr)
7379 {
7380 GET_CURRENT_CONTEXT(ctx);
7381 FLUSH_VERTICES(ctx, 0);
7382 CALL_EdgeFlagPointer(ctx->Exec, (stride, vptr));
7383 }
7384
7385 static void GLAPIENTRY
7386 exec_EnableClientState(GLenum cap)
7387 {
7388 GET_CURRENT_CONTEXT(ctx);
7389 FLUSH_VERTICES(ctx, 0);
7390 CALL_EnableClientState(ctx->Exec, (cap));
7391 }
7392
7393 static void GLAPIENTRY
7394 exec_GenTextures(GLsizei n, GLuint * texName)
7395 {
7396 GET_CURRENT_CONTEXT(ctx);
7397 FLUSH_VERTICES(ctx, 0);
7398 CALL_GenTextures(ctx->Exec, (n, texName));
7399 }
7400
7401 static void GLAPIENTRY
7402 exec_GetPointerv(GLenum pname, GLvoid **params)
7403 {
7404 GET_CURRENT_CONTEXT(ctx);
7405 FLUSH_VERTICES(ctx, 0);
7406 CALL_GetPointerv(ctx->Exec, (pname, params));
7407 }
7408
7409 static void GLAPIENTRY
7410 exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
7411 {
7412 GET_CURRENT_CONTEXT(ctx);
7413 FLUSH_VERTICES(ctx, 0);
7414 CALL_IndexPointer(ctx->Exec, (type, stride, ptr));
7415 }
7416
7417 static void GLAPIENTRY
7418 exec_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer)
7419 {
7420 GET_CURRENT_CONTEXT(ctx);
7421 FLUSH_VERTICES(ctx, 0);
7422 CALL_InterleavedArrays(ctx->Exec, (format, stride, pointer));
7423 }
7424
7425 static GLboolean GLAPIENTRY
7426 exec_IsTexture(GLuint texture)
7427 {
7428 GET_CURRENT_CONTEXT(ctx);
7429 FLUSH_VERTICES(ctx, 0);
7430 return CALL_IsTexture(ctx->Exec, (texture));
7431 }
7432
7433 static void GLAPIENTRY
7434 exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
7435 {
7436 GET_CURRENT_CONTEXT(ctx);
7437 FLUSH_VERTICES(ctx, 0);
7438 CALL_NormalPointer(ctx->Exec, (type, stride, ptr));
7439 }
7440
7441 static void GLAPIENTRY
7442 exec_PopClientAttrib(void)
7443 {
7444 GET_CURRENT_CONTEXT(ctx);
7445 FLUSH_VERTICES(ctx, 0);
7446 CALL_PopClientAttrib(ctx->Exec, ());
7447 }
7448
7449 static void GLAPIENTRY
7450 exec_PushClientAttrib(GLbitfield mask)
7451 {
7452 GET_CURRENT_CONTEXT(ctx);
7453 FLUSH_VERTICES(ctx, 0);
7454 CALL_PushClientAttrib(ctx->Exec, (mask));
7455 }
7456
7457 static void GLAPIENTRY
7458 exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
7459 const GLvoid *ptr)
7460 {
7461 GET_CURRENT_CONTEXT(ctx);
7462 FLUSH_VERTICES(ctx, 0);
7463 CALL_TexCoordPointer(ctx->Exec, (size, type, stride, ptr));
7464 }
7465
7466 static void GLAPIENTRY
7467 exec_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img)
7468 {
7469 GET_CURRENT_CONTEXT(ctx);
7470 FLUSH_VERTICES(ctx, 0);
7471 CALL_GetCompressedTexImageARB(ctx->Exec, (target, level, img));
7472 }
7473
7474 static void GLAPIENTRY
7475 exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
7476 const GLvoid *ptr)
7477 {
7478 GET_CURRENT_CONTEXT(ctx);
7479 FLUSH_VERTICES(ctx, 0);
7480 CALL_VertexPointer(ctx->Exec, (size, type, stride, ptr));
7481 }
7482
7483 static void GLAPIENTRY
7484 exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
7485 GLint x, GLint y, GLsizei width)
7486 {
7487 GET_CURRENT_CONTEXT(ctx);
7488 FLUSH_VERTICES(ctx, 0);
7489 CALL_CopyConvolutionFilter1D(ctx->Exec,
7490 (target, internalFormat, x, y, width));
7491 }
7492
7493 static void GLAPIENTRY
7494 exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat,
7495 GLint x, GLint y, GLsizei width, GLsizei height)
7496 {
7497 GET_CURRENT_CONTEXT(ctx);
7498 FLUSH_VERTICES(ctx, 0);
7499 CALL_CopyConvolutionFilter2D(ctx->Exec,
7500 (target, internalFormat, x, y, width,
7501 height));
7502 }
7503
7504 static void GLAPIENTRY
7505 exec_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * data)
7506 {
7507 GET_CURRENT_CONTEXT(ctx);
7508 FLUSH_VERTICES(ctx, 0);
7509 CALL_GetColorTable(ctx->Exec, (target, format, type, data));
7510 }
7511
7512 static void GLAPIENTRY
7513 exec_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params)
7514 {
7515 GET_CURRENT_CONTEXT(ctx);
7516 FLUSH_VERTICES(ctx, 0);
7517 CALL_GetColorTableParameterfv(ctx->Exec, (target, pname, params));
7518 }
7519
7520 static void GLAPIENTRY
7521 exec_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params)
7522 {
7523 GET_CURRENT_CONTEXT(ctx);
7524 FLUSH_VERTICES(ctx, 0);
7525 CALL_GetColorTableParameteriv(ctx->Exec, (target, pname, params));
7526 }
7527
7528 static void GLAPIENTRY
7529 exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
7530 GLvoid * image)
7531 {
7532 GET_CURRENT_CONTEXT(ctx);
7533 FLUSH_VERTICES(ctx, 0);
7534 CALL_GetConvolutionFilter(ctx->Exec, (target, format, type, image));
7535 }
7536
7537 static void GLAPIENTRY
7538 exec_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params)
7539 {
7540 GET_CURRENT_CONTEXT(ctx);
7541 FLUSH_VERTICES(ctx, 0);
7542 CALL_GetConvolutionParameterfv(ctx->Exec, (target, pname, params));
7543 }
7544
7545 static void GLAPIENTRY
7546 exec_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params)
7547 {
7548 GET_CURRENT_CONTEXT(ctx);
7549 FLUSH_VERTICES(ctx, 0);
7550 CALL_GetConvolutionParameteriv(ctx->Exec, (target, pname, params));
7551 }
7552
7553 static void GLAPIENTRY
7554 exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
7555 GLenum type, GLvoid *values)
7556 {
7557 GET_CURRENT_CONTEXT(ctx);
7558 FLUSH_VERTICES(ctx, 0);
7559 CALL_GetHistogram(ctx->Exec, (target, reset, format, type, values));
7560 }
7561
7562 static void GLAPIENTRY
7563 exec_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params)
7564 {
7565 GET_CURRENT_CONTEXT(ctx);
7566 FLUSH_VERTICES(ctx, 0);
7567 CALL_GetHistogramParameterfv(ctx->Exec, (target, pname, params));
7568 }
7569
7570 static void GLAPIENTRY
7571 exec_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params)
7572 {
7573 GET_CURRENT_CONTEXT(ctx);
7574 FLUSH_VERTICES(ctx, 0);
7575 CALL_GetHistogramParameteriv(ctx->Exec, (target, pname, params));
7576 }
7577
7578 static void GLAPIENTRY
7579 exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
7580 GLenum type, GLvoid *values)
7581 {
7582 GET_CURRENT_CONTEXT(ctx);
7583 FLUSH_VERTICES(ctx, 0);
7584 CALL_GetMinmax(ctx->Exec, (target, reset, format, type, values));
7585 }
7586
7587 static void GLAPIENTRY
7588 exec_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params)
7589 {
7590 GET_CURRENT_CONTEXT(ctx);
7591 FLUSH_VERTICES(ctx, 0);
7592 CALL_GetMinmaxParameterfv(ctx->Exec, (target, pname, params));
7593 }
7594
7595 static void GLAPIENTRY
7596 exec_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params)
7597 {
7598 GET_CURRENT_CONTEXT(ctx);
7599 FLUSH_VERTICES(ctx, 0);
7600 CALL_GetMinmaxParameteriv(ctx->Exec, (target, pname, params));
7601 }
7602
7603 static void GLAPIENTRY
7604 exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
7605 GLvoid *row, GLvoid *column, GLvoid *span)
7606 {
7607 GET_CURRENT_CONTEXT(ctx);
7608 FLUSH_VERTICES(ctx, 0);
7609 CALL_GetSeparableFilter(ctx->Exec,
7610 (target, format, type, row, column, span));
7611 }
7612
7613 static void GLAPIENTRY
7614 exec_SeparableFilter2D(GLenum target, GLenum internalFormat,
7615 GLsizei width, GLsizei height, GLenum format,
7616 GLenum type, const GLvoid *row, const GLvoid *column)
7617 {
7618 GET_CURRENT_CONTEXT(ctx);
7619 FLUSH_VERTICES(ctx, 0);
7620 CALL_SeparableFilter2D(ctx->Exec,
7621 (target, internalFormat, width, height, format,
7622 type, row, column));
7623 }
7624
7625 static void GLAPIENTRY
7626 exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride,
7627 GLsizei count, const GLvoid *ptr)
7628 {
7629 GET_CURRENT_CONTEXT(ctx);
7630 FLUSH_VERTICES(ctx, 0);
7631 CALL_ColorPointerEXT(ctx->Exec, (size, type, stride, count, ptr));
7632 }
7633
7634 static void GLAPIENTRY
7635 exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr)
7636 {
7637 GET_CURRENT_CONTEXT(ctx);
7638 FLUSH_VERTICES(ctx, 0);
7639 CALL_EdgeFlagPointerEXT(ctx->Exec, (stride, count, ptr));
7640 }
7641
7642 static void GLAPIENTRY
7643 exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
7644 const GLvoid *ptr)
7645 {
7646 GET_CURRENT_CONTEXT(ctx);
7647 FLUSH_VERTICES(ctx, 0);
7648 CALL_IndexPointerEXT(ctx->Exec, (type, stride, count, ptr));
7649 }
7650
7651 static void GLAPIENTRY
7652 exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
7653 const GLvoid *ptr)
7654 {
7655 GET_CURRENT_CONTEXT(ctx);
7656 FLUSH_VERTICES(ctx, 0);
7657 CALL_NormalPointerEXT(ctx->Exec, (type, stride, count, ptr));
7658 }
7659
7660 static void GLAPIENTRY
7661 exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
7662 GLsizei count, const GLvoid *ptr)
7663 {
7664 GET_CURRENT_CONTEXT(ctx);
7665 FLUSH_VERTICES(ctx, 0);
7666 CALL_TexCoordPointerEXT(ctx->Exec, (size, type, stride, count, ptr));
7667 }
7668
7669 static void GLAPIENTRY
7670 exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
7671 GLsizei count, const GLvoid *ptr)
7672 {
7673 GET_CURRENT_CONTEXT(ctx);
7674 FLUSH_VERTICES(ctx, 0);
7675 CALL_VertexPointerEXT(ctx->Exec, (size, type, stride, count, ptr));
7676 }
7677
7678 static void GLAPIENTRY
7679 exec_LockArraysEXT(GLint first, GLsizei count)
7680 {
7681 GET_CURRENT_CONTEXT(ctx);
7682 FLUSH_VERTICES(ctx, 0);
7683 CALL_LockArraysEXT(ctx->Exec, (first, count));
7684 }
7685
7686 static void GLAPIENTRY
7687 exec_UnlockArraysEXT(void)
7688 {
7689 GET_CURRENT_CONTEXT(ctx);
7690 FLUSH_VERTICES(ctx, 0);
7691 CALL_UnlockArraysEXT(ctx->Exec, ());
7692 }
7693
7694 static void GLAPIENTRY
7695 exec_ClientActiveTextureARB(GLenum target)
7696 {
7697 GET_CURRENT_CONTEXT(ctx);
7698 FLUSH_VERTICES(ctx, 0);
7699 CALL_ClientActiveTextureARB(ctx->Exec, (target));
7700 }
7701
7702 static void GLAPIENTRY
7703 exec_SecondaryColorPointerEXT(GLint size, GLenum type,
7704 GLsizei stride, const GLvoid *ptr)
7705 {
7706 GET_CURRENT_CONTEXT(ctx);
7707 FLUSH_VERTICES(ctx, 0);
7708 CALL_SecondaryColorPointerEXT(ctx->Exec, (size, type, stride, ptr));
7709 }
7710
7711 static void GLAPIENTRY
7712 exec_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
7713 {
7714 GET_CURRENT_CONTEXT(ctx);
7715 FLUSH_VERTICES(ctx, 0);
7716 CALL_FogCoordPointerEXT(ctx->Exec, (type, stride, ptr));
7717 }
7718
7719 /* GL_EXT_multi_draw_arrays */
7720 static void GLAPIENTRY
7721 exec_MultiDrawArraysEXT(GLenum mode, GLint * first,
7722 GLsizei * count, GLsizei primcount)
7723 {
7724 GET_CURRENT_CONTEXT(ctx);
7725 FLUSH_VERTICES(ctx, 0);
7726 CALL_MultiDrawArraysEXT(ctx->Exec, (mode, first, count, primcount));
7727 }
7728
7729 /* GL_EXT_multi_draw_arrays */
7730 static void GLAPIENTRY
7731 exec_MultiDrawElementsEXT(GLenum mode, const GLsizei * count,
7732 GLenum type, const GLvoid ** indices,
7733 GLsizei primcount)
7734 {
7735 GET_CURRENT_CONTEXT(ctx);
7736 FLUSH_VERTICES(ctx, 0);
7737 CALL_MultiDrawElementsEXT(ctx->Exec,
7738 (mode, count, type, indices, primcount));
7739 }
7740
7741 /* GL_IBM_multimode_draw_arrays */
7742 static void GLAPIENTRY
7743 exec_MultiModeDrawArraysIBM(const GLenum * mode, const GLint * first,
7744 const GLsizei * count, GLsizei primcount,
7745 GLint modestride)
7746 {
7747 GET_CURRENT_CONTEXT(ctx);
7748 FLUSH_VERTICES(ctx, 0);
7749 CALL_MultiModeDrawArraysIBM(ctx->Exec,
7750 (mode, first, count, primcount, modestride));
7751 }
7752
7753 /* GL_IBM_multimode_draw_arrays */
7754 static void GLAPIENTRY
7755 exec_MultiModeDrawElementsIBM(const GLenum * mode,
7756 const GLsizei * count,
7757 GLenum type,
7758 const GLvoid * const *indices,
7759 GLsizei primcount, GLint modestride)
7760 {
7761 GET_CURRENT_CONTEXT(ctx);
7762 FLUSH_VERTICES(ctx, 0);
7763 CALL_MultiModeDrawElementsIBM(ctx->Exec,
7764 (mode, count, type, indices, primcount,
7765 modestride));
7766 }
7767
7768
7769
7770 /**
7771 * Setup the given dispatch table to point to Mesa's display list
7772 * building functions.
7773 *
7774 * This does not include any of the tnl functions - they are
7775 * initialized from _mesa_init_api_defaults and from the active vtxfmt
7776 * struct.
7777 */
7778 void
7779 _mesa_init_dlist_table(struct _glapi_table *table)
7780 {
7781 _mesa_loopback_init_api_table(table);
7782
7783 /* GL 1.0 */
7784 SET_Accum(table, save_Accum);
7785 SET_AlphaFunc(table, save_AlphaFunc);
7786 SET_Bitmap(table, save_Bitmap);
7787 SET_BlendFunc(table, save_BlendFunc);
7788 SET_CallList(table, _mesa_save_CallList);
7789 SET_CallLists(table, _mesa_save_CallLists);
7790 SET_Clear(table, save_Clear);
7791 SET_ClearAccum(table, save_ClearAccum);
7792 SET_ClearColor(table, save_ClearColor);
7793 SET_ClearDepth(table, save_ClearDepth);
7794 SET_ClearIndex(table, save_ClearIndex);
7795 SET_ClearStencil(table, save_ClearStencil);
7796 SET_ClipPlane(table, save_ClipPlane);
7797 SET_ColorMask(table, save_ColorMask);
7798 SET_ColorMaterial(table, save_ColorMaterial);
7799 SET_CopyPixels(table, save_CopyPixels);
7800 SET_CullFace(table, save_CullFace);
7801 SET_DeleteLists(table, _mesa_DeleteLists);
7802 SET_DepthFunc(table, save_DepthFunc);
7803 SET_DepthMask(table, save_DepthMask);
7804 SET_DepthRange(table, save_DepthRange);
7805 SET_Disable(table, save_Disable);
7806 SET_DrawBuffer(table, save_DrawBuffer);
7807 SET_DrawPixels(table, save_DrawPixels);
7808 SET_Enable(table, save_Enable);
7809 SET_EndList(table, _mesa_EndList);
7810 SET_EvalMesh1(table, _mesa_save_EvalMesh1);
7811 SET_EvalMesh2(table, _mesa_save_EvalMesh2);
7812 SET_Finish(table, exec_Finish);
7813 SET_Flush(table, exec_Flush);
7814 SET_Fogf(table, save_Fogf);
7815 SET_Fogfv(table, save_Fogfv);
7816 SET_Fogi(table, save_Fogi);
7817 SET_Fogiv(table, save_Fogiv);
7818 SET_FrontFace(table, save_FrontFace);
7819 SET_Frustum(table, save_Frustum);
7820 SET_GenLists(table, _mesa_GenLists);
7821 SET_GetBooleanv(table, exec_GetBooleanv);
7822 SET_GetClipPlane(table, exec_GetClipPlane);
7823 SET_GetDoublev(table, exec_GetDoublev);
7824 SET_GetError(table, exec_GetError);
7825 SET_GetFloatv(table, exec_GetFloatv);
7826 SET_GetIntegerv(table, exec_GetIntegerv);
7827 SET_GetLightfv(table, exec_GetLightfv);
7828 SET_GetLightiv(table, exec_GetLightiv);
7829 SET_GetMapdv(table, exec_GetMapdv);
7830 SET_GetMapfv(table, exec_GetMapfv);
7831 SET_GetMapiv(table, exec_GetMapiv);
7832 SET_GetMaterialfv(table, exec_GetMaterialfv);
7833 SET_GetMaterialiv(table, exec_GetMaterialiv);
7834 SET_GetPixelMapfv(table, exec_GetPixelMapfv);
7835 SET_GetPixelMapuiv(table, exec_GetPixelMapuiv);
7836 SET_GetPixelMapusv(table, exec_GetPixelMapusv);
7837 SET_GetPolygonStipple(table, exec_GetPolygonStipple);
7838 SET_GetString(table, exec_GetString);
7839 SET_GetTexEnvfv(table, exec_GetTexEnvfv);
7840 SET_GetTexEnviv(table, exec_GetTexEnviv);
7841 SET_GetTexGendv(table, exec_GetTexGendv);
7842 SET_GetTexGenfv(table, exec_GetTexGenfv);
7843 SET_GetTexGeniv(table, exec_GetTexGeniv);
7844 SET_GetTexImage(table, exec_GetTexImage);
7845 SET_GetTexLevelParameterfv(table, exec_GetTexLevelParameterfv);
7846 SET_GetTexLevelParameteriv(table, exec_GetTexLevelParameteriv);
7847 SET_GetTexParameterfv(table, exec_GetTexParameterfv);
7848 SET_GetTexParameteriv(table, exec_GetTexParameteriv);
7849 SET_Hint(table, save_Hint);
7850 SET_IndexMask(table, save_IndexMask);
7851 SET_InitNames(table, save_InitNames);
7852 SET_IsEnabled(table, exec_IsEnabled);
7853 SET_IsList(table, _mesa_IsList);
7854 SET_LightModelf(table, save_LightModelf);
7855 SET_LightModelfv(table, save_LightModelfv);
7856 SET_LightModeli(table, save_LightModeli);
7857 SET_LightModeliv(table, save_LightModeliv);
7858 SET_Lightf(table, save_Lightf);
7859 SET_Lightfv(table, save_Lightfv);
7860 SET_Lighti(table, save_Lighti);
7861 SET_Lightiv(table, save_Lightiv);
7862 SET_LineStipple(table, save_LineStipple);
7863 SET_LineWidth(table, save_LineWidth);
7864 SET_ListBase(table, save_ListBase);
7865 SET_LoadIdentity(table, save_LoadIdentity);
7866 SET_LoadMatrixd(table, save_LoadMatrixd);
7867 SET_LoadMatrixf(table, save_LoadMatrixf);
7868 SET_LoadName(table, save_LoadName);
7869 SET_LogicOp(table, save_LogicOp);
7870 SET_Map1d(table, save_Map1d);
7871 SET_Map1f(table, save_Map1f);
7872 SET_Map2d(table, save_Map2d);
7873 SET_Map2f(table, save_Map2f);
7874 SET_MapGrid1d(table, save_MapGrid1d);
7875 SET_MapGrid1f(table, save_MapGrid1f);
7876 SET_MapGrid2d(table, save_MapGrid2d);
7877 SET_MapGrid2f(table, save_MapGrid2f);
7878 SET_MatrixMode(table, save_MatrixMode);
7879 SET_MultMatrixd(table, save_MultMatrixd);
7880 SET_MultMatrixf(table, save_MultMatrixf);
7881 SET_NewList(table, save_NewList);
7882 SET_Ortho(table, save_Ortho);
7883 SET_PassThrough(table, save_PassThrough);
7884 SET_PixelMapfv(table, save_PixelMapfv);
7885 SET_PixelMapuiv(table, save_PixelMapuiv);
7886 SET_PixelMapusv(table, save_PixelMapusv);
7887 SET_PixelStoref(table, exec_PixelStoref);
7888 SET_PixelStorei(table, exec_PixelStorei);
7889 SET_PixelTransferf(table, save_PixelTransferf);
7890 SET_PixelTransferi(table, save_PixelTransferi);
7891 SET_PixelZoom(table, save_PixelZoom);
7892 SET_PointSize(table, save_PointSize);
7893 SET_PolygonMode(table, save_PolygonMode);
7894 SET_PolygonOffset(table, save_PolygonOffset);
7895 SET_PolygonStipple(table, save_PolygonStipple);
7896 SET_PopAttrib(table, save_PopAttrib);
7897 SET_PopMatrix(table, save_PopMatrix);
7898 SET_PopName(table, save_PopName);
7899 SET_PushAttrib(table, save_PushAttrib);
7900 SET_PushMatrix(table, save_PushMatrix);
7901 SET_PushName(table, save_PushName);
7902 SET_RasterPos2d(table, save_RasterPos2d);
7903 SET_RasterPos2dv(table, save_RasterPos2dv);
7904 SET_RasterPos2f(table, save_RasterPos2f);
7905 SET_RasterPos2fv(table, save_RasterPos2fv);
7906 SET_RasterPos2i(table, save_RasterPos2i);
7907 SET_RasterPos2iv(table, save_RasterPos2iv);
7908 SET_RasterPos2s(table, save_RasterPos2s);
7909 SET_RasterPos2sv(table, save_RasterPos2sv);
7910 SET_RasterPos3d(table, save_RasterPos3d);
7911 SET_RasterPos3dv(table, save_RasterPos3dv);
7912 SET_RasterPos3f(table, save_RasterPos3f);
7913 SET_RasterPos3fv(table, save_RasterPos3fv);
7914 SET_RasterPos3i(table, save_RasterPos3i);
7915 SET_RasterPos3iv(table, save_RasterPos3iv);
7916 SET_RasterPos3s(table, save_RasterPos3s);
7917 SET_RasterPos3sv(table, save_RasterPos3sv);
7918 SET_RasterPos4d(table, save_RasterPos4d);
7919 SET_RasterPos4dv(table, save_RasterPos4dv);
7920 SET_RasterPos4f(table, save_RasterPos4f);
7921 SET_RasterPos4fv(table, save_RasterPos4fv);
7922 SET_RasterPos4i(table, save_RasterPos4i);
7923 SET_RasterPos4iv(table, save_RasterPos4iv);
7924 SET_RasterPos4s(table, save_RasterPos4s);
7925 SET_RasterPos4sv(table, save_RasterPos4sv);
7926 SET_ReadBuffer(table, save_ReadBuffer);
7927 SET_ReadPixels(table, exec_ReadPixels);
7928 SET_RenderMode(table, exec_RenderMode);
7929 SET_Rotated(table, save_Rotated);
7930 SET_Rotatef(table, save_Rotatef);
7931 SET_Scaled(table, save_Scaled);
7932 SET_Scalef(table, save_Scalef);
7933 SET_Scissor(table, save_Scissor);
7934 SET_FeedbackBuffer(table, exec_FeedbackBuffer);
7935 SET_SelectBuffer(table, exec_SelectBuffer);
7936 SET_ShadeModel(table, save_ShadeModel);
7937 SET_StencilFunc(table, save_StencilFunc);
7938 SET_StencilMask(table, save_StencilMask);
7939 SET_StencilOp(table, save_StencilOp);
7940 SET_TexEnvf(table, save_TexEnvf);
7941 SET_TexEnvfv(table, save_TexEnvfv);
7942 SET_TexEnvi(table, save_TexEnvi);
7943 SET_TexEnviv(table, save_TexEnviv);
7944 SET_TexGend(table, save_TexGend);
7945 SET_TexGendv(table, save_TexGendv);
7946 SET_TexGenf(table, save_TexGenf);
7947 SET_TexGenfv(table, save_TexGenfv);
7948 SET_TexGeni(table, save_TexGeni);
7949 SET_TexGeniv(table, save_TexGeniv);
7950 SET_TexImage1D(table, save_TexImage1D);
7951 SET_TexImage2D(table, save_TexImage2D);
7952 SET_TexParameterf(table, save_TexParameterf);
7953 SET_TexParameterfv(table, save_TexParameterfv);
7954 SET_TexParameteri(table, save_TexParameteri);
7955 SET_TexParameteriv(table, save_TexParameteriv);
7956 SET_Translated(table, save_Translated);
7957 SET_Translatef(table, save_Translatef);
7958 SET_Viewport(table, save_Viewport);
7959
7960 /* GL 1.1 */
7961 SET_AreTexturesResident(table, exec_AreTexturesResident);
7962 SET_BindTexture(table, save_BindTexture);
7963 SET_ColorPointer(table, exec_ColorPointer);
7964 SET_CopyTexImage1D(table, save_CopyTexImage1D);
7965 SET_CopyTexImage2D(table, save_CopyTexImage2D);
7966 SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D);
7967 SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D);
7968 SET_DeleteTextures(table, exec_DeleteTextures);
7969 SET_DisableClientState(table, exec_DisableClientState);
7970 SET_EdgeFlagPointer(table, exec_EdgeFlagPointer);
7971 SET_EnableClientState(table, exec_EnableClientState);
7972 SET_GenTextures(table, exec_GenTextures);
7973 SET_GetPointerv(table, exec_GetPointerv);
7974 SET_IndexPointer(table, exec_IndexPointer);
7975 SET_InterleavedArrays(table, exec_InterleavedArrays);
7976 SET_IsTexture(table, exec_IsTexture);
7977 SET_NormalPointer(table, exec_NormalPointer);
7978 SET_PopClientAttrib(table, exec_PopClientAttrib);
7979 SET_PrioritizeTextures(table, save_PrioritizeTextures);
7980 SET_PushClientAttrib(table, exec_PushClientAttrib);
7981 SET_TexCoordPointer(table, exec_TexCoordPointer);
7982 SET_TexSubImage1D(table, save_TexSubImage1D);
7983 SET_TexSubImage2D(table, save_TexSubImage2D);
7984 SET_VertexPointer(table, exec_VertexPointer);
7985
7986 /* GL 1.2 */
7987 SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D);
7988 SET_TexImage3D(table, save_TexImage3D);
7989 SET_TexSubImage3D(table, save_TexSubImage3D);
7990
7991 /* GL 2.0 */
7992 SET_StencilFuncSeparate(table, save_StencilFuncSeparate);
7993 SET_StencilMaskSeparate(table, save_StencilMaskSeparate);
7994 SET_StencilOpSeparate(table, save_StencilOpSeparate);
7995
7996 /* ATI_separate_stencil */
7997 SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI);
7998
7999 /* GL_ARB_imaging */
8000 /* Not all are supported */
8001 SET_BlendColor(table, save_BlendColor);
8002 SET_BlendEquation(table, save_BlendEquation);
8003 SET_ColorSubTable(table, save_ColorSubTable);
8004 SET_ColorTable(table, save_ColorTable);
8005 SET_ColorTableParameterfv(table, save_ColorTableParameterfv);
8006 SET_ColorTableParameteriv(table, save_ColorTableParameteriv);
8007 SET_ConvolutionFilter1D(table, save_ConvolutionFilter1D);
8008 SET_ConvolutionFilter2D(table, save_ConvolutionFilter2D);
8009 SET_ConvolutionParameterf(table, save_ConvolutionParameterf);
8010 SET_ConvolutionParameterfv(table, save_ConvolutionParameterfv);
8011 SET_ConvolutionParameteri(table, save_ConvolutionParameteri);
8012 SET_ConvolutionParameteriv(table, save_ConvolutionParameteriv);
8013 SET_CopyColorSubTable(table, save_CopyColorSubTable);
8014 SET_CopyColorTable(table, save_CopyColorTable);
8015 SET_CopyConvolutionFilter1D(table, exec_CopyConvolutionFilter1D);
8016 SET_CopyConvolutionFilter2D(table, exec_CopyConvolutionFilter2D);
8017 SET_GetColorTable(table, exec_GetColorTable);
8018 SET_GetColorTableParameterfv(table, exec_GetColorTableParameterfv);
8019 SET_GetColorTableParameteriv(table, exec_GetColorTableParameteriv);
8020 SET_GetConvolutionFilter(table, exec_GetConvolutionFilter);
8021 SET_GetConvolutionParameterfv(table, exec_GetConvolutionParameterfv);
8022 SET_GetConvolutionParameteriv(table, exec_GetConvolutionParameteriv);
8023 SET_GetHistogram(table, exec_GetHistogram);
8024 SET_GetHistogramParameterfv(table, exec_GetHistogramParameterfv);
8025 SET_GetHistogramParameteriv(table, exec_GetHistogramParameteriv);
8026 SET_GetMinmax(table, exec_GetMinmax);
8027 SET_GetMinmaxParameterfv(table, exec_GetMinmaxParameterfv);
8028 SET_GetMinmaxParameteriv(table, exec_GetMinmaxParameteriv);
8029 SET_GetSeparableFilter(table, exec_GetSeparableFilter);
8030 SET_Histogram(table, save_Histogram);
8031 SET_Minmax(table, save_Minmax);
8032 SET_ResetHistogram(table, save_ResetHistogram);
8033 SET_ResetMinmax(table, save_ResetMinmax);
8034 SET_SeparableFilter2D(table, exec_SeparableFilter2D);
8035
8036 /* 2. GL_EXT_blend_color */
8037 #if 0
8038 SET_BlendColorEXT(table, save_BlendColorEXT);
8039 #endif
8040
8041 /* 3. GL_EXT_polygon_offset */
8042 SET_PolygonOffsetEXT(table, save_PolygonOffsetEXT);
8043
8044 /* 6. GL_EXT_texture3d */
8045 #if 0
8046 SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D);
8047 SET_TexImage3DEXT(table, save_TexImage3DEXT);
8048 SET_TexSubImage3DEXT(table, save_TexSubImage3D);
8049 #endif
8050
8051 /* 14. GL_SGI_color_table */
8052 #if 0
8053 SET_ColorTableSGI(table, save_ColorTable);
8054 SET_ColorSubTableSGI(table, save_ColorSubTable);
8055 SET_GetColorTableSGI(table, exec_GetColorTable);
8056 SET_GetColorTableParameterfvSGI(table, exec_GetColorTableParameterfv);
8057 SET_GetColorTableParameterivSGI(table, exec_GetColorTableParameteriv);
8058 #endif
8059
8060 /* 30. GL_EXT_vertex_array */
8061 SET_ColorPointerEXT(table, exec_ColorPointerEXT);
8062 SET_EdgeFlagPointerEXT(table, exec_EdgeFlagPointerEXT);
8063 SET_IndexPointerEXT(table, exec_IndexPointerEXT);
8064 SET_NormalPointerEXT(table, exec_NormalPointerEXT);
8065 SET_TexCoordPointerEXT(table, exec_TexCoordPointerEXT);
8066 SET_VertexPointerEXT(table, exec_VertexPointerEXT);
8067
8068 /* 37. GL_EXT_blend_minmax */
8069 #if 0
8070 SET_BlendEquationEXT(table, save_BlendEquationEXT);
8071 #endif
8072
8073 /* 54. GL_EXT_point_parameters */
8074 SET_PointParameterfEXT(table, save_PointParameterfEXT);
8075 SET_PointParameterfvEXT(table, save_PointParameterfvEXT);
8076
8077 /* 97. GL_EXT_compiled_vertex_array */
8078 SET_LockArraysEXT(table, exec_LockArraysEXT);
8079 SET_UnlockArraysEXT(table, exec_UnlockArraysEXT);
8080
8081 /* 145. GL_EXT_secondary_color */
8082 SET_SecondaryColorPointerEXT(table, exec_SecondaryColorPointerEXT);
8083
8084 /* 148. GL_EXT_multi_draw_arrays */
8085 SET_MultiDrawArraysEXT(table, exec_MultiDrawArraysEXT);
8086 SET_MultiDrawElementsEXT(table, exec_MultiDrawElementsEXT);
8087
8088 /* 149. GL_EXT_fog_coord */
8089 SET_FogCoordPointerEXT(table, exec_FogCoordPointerEXT);
8090
8091 /* 173. GL_EXT_blend_func_separate */
8092 SET_BlendFuncSeparateEXT(table, save_BlendFuncSeparateEXT);
8093
8094 /* 196. GL_MESA_resize_buffers */
8095 SET_ResizeBuffersMESA(table, _mesa_ResizeBuffersMESA);
8096
8097 /* 197. GL_MESA_window_pos */
8098 SET_WindowPos2dMESA(table, save_WindowPos2dMESA);
8099 SET_WindowPos2dvMESA(table, save_WindowPos2dvMESA);
8100 SET_WindowPos2fMESA(table, save_WindowPos2fMESA);
8101 SET_WindowPos2fvMESA(table, save_WindowPos2fvMESA);
8102 SET_WindowPos2iMESA(table, save_WindowPos2iMESA);
8103 SET_WindowPos2ivMESA(table, save_WindowPos2ivMESA);
8104 SET_WindowPos2sMESA(table, save_WindowPos2sMESA);
8105 SET_WindowPos2svMESA(table, save_WindowPos2svMESA);
8106 SET_WindowPos3dMESA(table, save_WindowPos3dMESA);
8107 SET_WindowPos3dvMESA(table, save_WindowPos3dvMESA);
8108 SET_WindowPos3fMESA(table, save_WindowPos3fMESA);
8109 SET_WindowPos3fvMESA(table, save_WindowPos3fvMESA);
8110 SET_WindowPos3iMESA(table, save_WindowPos3iMESA);
8111 SET_WindowPos3ivMESA(table, save_WindowPos3ivMESA);
8112 SET_WindowPos3sMESA(table, save_WindowPos3sMESA);
8113 SET_WindowPos3svMESA(table, save_WindowPos3svMESA);
8114 SET_WindowPos4dMESA(table, save_WindowPos4dMESA);
8115 SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA);
8116 SET_WindowPos4fMESA(table, save_WindowPos4fMESA);
8117 SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA);
8118 SET_WindowPos4iMESA(table, save_WindowPos4iMESA);
8119 SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA);
8120 SET_WindowPos4sMESA(table, save_WindowPos4sMESA);
8121 SET_WindowPos4svMESA(table, save_WindowPos4svMESA);
8122
8123 /* 200. GL_IBM_multimode_draw_arrays */
8124 SET_MultiModeDrawArraysIBM(table, exec_MultiModeDrawArraysIBM);
8125 SET_MultiModeDrawElementsIBM(table, exec_MultiModeDrawElementsIBM);
8126
8127 #if FEATURE_NV_vertex_program
8128 /* 233. GL_NV_vertex_program */
8129 /* The following commands DO NOT go into display lists:
8130 * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV,
8131 * VertexAttribPointerNV, GetProgram*, GetVertexAttrib*
8132 */
8133 SET_BindProgramNV(table, save_BindProgramNV);
8134 SET_DeleteProgramsNV(table, _mesa_DeletePrograms);
8135 SET_ExecuteProgramNV(table, save_ExecuteProgramNV);
8136 SET_GenProgramsNV(table, _mesa_GenPrograms);
8137 SET_AreProgramsResidentNV(table, _mesa_AreProgramsResidentNV);
8138 SET_RequestResidentProgramsNV(table, save_RequestResidentProgramsNV);
8139 SET_GetProgramParameterfvNV(table, _mesa_GetProgramParameterfvNV);
8140 SET_GetProgramParameterdvNV(table, _mesa_GetProgramParameterdvNV);
8141 SET_GetProgramivNV(table, _mesa_GetProgramivNV);
8142 SET_GetProgramStringNV(table, _mesa_GetProgramStringNV);
8143 SET_GetTrackMatrixivNV(table, _mesa_GetTrackMatrixivNV);
8144 SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV);
8145 SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV);
8146 SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV);
8147 SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV);
8148 SET_IsProgramNV(table, _mesa_IsProgramARB);
8149 SET_LoadProgramNV(table, save_LoadProgramNV);
8150 SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB);
8151 SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB);
8152 SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB);
8153 SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB);
8154 SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV);
8155 SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV);
8156 SET_TrackMatrixNV(table, save_TrackMatrixNV);
8157 SET_VertexAttribPointerNV(table, _mesa_VertexAttribPointerNV);
8158 #endif
8159
8160 /* 244. GL_ATI_envmap_bumpmap */
8161 SET_TexBumpParameterivATI(table, save_TexBumpParameterivATI);
8162 SET_TexBumpParameterfvATI(table, save_TexBumpParameterfvATI);
8163
8164 /* 245. GL_ATI_fragment_shader */
8165 #if FEATURE_ATI_fragment_shader
8166 SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI);
8167 SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI);
8168 #endif
8169
8170 /* 282. GL_NV_fragment_program */
8171 #if FEATURE_NV_fragment_program
8172 SET_ProgramNamedParameter4fNV(table, save_ProgramNamedParameter4fNV);
8173 SET_ProgramNamedParameter4dNV(table, save_ProgramNamedParameter4dNV);
8174 SET_ProgramNamedParameter4fvNV(table, save_ProgramNamedParameter4fvNV);
8175 SET_ProgramNamedParameter4dvNV(table, save_ProgramNamedParameter4dvNV);
8176 SET_GetProgramNamedParameterfvNV(table,
8177 _mesa_GetProgramNamedParameterfvNV);
8178 SET_GetProgramNamedParameterdvNV(table,
8179 _mesa_GetProgramNamedParameterdvNV);
8180 SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB);
8181 SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB);
8182 SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB);
8183 SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB);
8184 SET_GetProgramLocalParameterdvARB(table,
8185 _mesa_GetProgramLocalParameterdvARB);
8186 SET_GetProgramLocalParameterfvARB(table,
8187 _mesa_GetProgramLocalParameterfvARB);
8188 #endif
8189
8190 /* 262. GL_NV_point_sprite */
8191 SET_PointParameteriNV(table, save_PointParameteriNV);
8192 SET_PointParameterivNV(table, save_PointParameterivNV);
8193
8194 /* 268. GL_EXT_stencil_two_side */
8195 SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT);
8196
8197 /* 273. GL_APPLE_vertex_array_object */
8198 SET_BindVertexArrayAPPLE(table, _mesa_BindVertexArrayAPPLE);
8199 SET_DeleteVertexArraysAPPLE(table, _mesa_DeleteVertexArraysAPPLE);
8200 SET_GenVertexArraysAPPLE(table, _mesa_GenVertexArraysAPPLE);
8201 SET_IsVertexArrayAPPLE(table, _mesa_IsVertexArrayAPPLE);
8202
8203 /* ???. GL_EXT_depth_bounds_test */
8204 SET_DepthBoundsEXT(table, save_DepthBoundsEXT);
8205
8206 /* ARB 1. GL_ARB_multitexture */
8207 SET_ActiveTextureARB(table, save_ActiveTextureARB);
8208 SET_ClientActiveTextureARB(table, exec_ClientActiveTextureARB);
8209
8210 /* ARB 3. GL_ARB_transpose_matrix */
8211 SET_LoadTransposeMatrixdARB(table, save_LoadTransposeMatrixdARB);
8212 SET_LoadTransposeMatrixfARB(table, save_LoadTransposeMatrixfARB);
8213 SET_MultTransposeMatrixdARB(table, save_MultTransposeMatrixdARB);
8214 SET_MultTransposeMatrixfARB(table, save_MultTransposeMatrixfARB);
8215
8216 /* ARB 5. GL_ARB_multisample */
8217 SET_SampleCoverageARB(table, save_SampleCoverageARB);
8218
8219 /* ARB 12. GL_ARB_texture_compression */
8220 SET_CompressedTexImage3DARB(table, save_CompressedTexImage3DARB);
8221 SET_CompressedTexImage2DARB(table, save_CompressedTexImage2DARB);
8222 SET_CompressedTexImage1DARB(table, save_CompressedTexImage1DARB);
8223 SET_CompressedTexSubImage3DARB(table, save_CompressedTexSubImage3DARB);
8224 SET_CompressedTexSubImage2DARB(table, save_CompressedTexSubImage2DARB);
8225 SET_CompressedTexSubImage1DARB(table, save_CompressedTexSubImage1DARB);
8226 SET_GetCompressedTexImageARB(table, exec_GetCompressedTexImageARB);
8227
8228 /* ARB 14. GL_ARB_point_parameters */
8229 /* aliased with EXT_point_parameters functions */
8230
8231 /* ARB 25. GL_ARB_window_pos */
8232 /* aliased with MESA_window_pos functions */
8233
8234 /* ARB 26. GL_ARB_vertex_program */
8235 /* ARB 27. GL_ARB_fragment_program */
8236 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
8237 /* glVertexAttrib* functions alias the NV ones, handled elsewhere */
8238 SET_VertexAttribPointerARB(table, _mesa_VertexAttribPointerARB);
8239 SET_EnableVertexAttribArrayARB(table, _mesa_EnableVertexAttribArrayARB);
8240 SET_DisableVertexAttribArrayARB(table, _mesa_DisableVertexAttribArrayARB);
8241 SET_ProgramStringARB(table, save_ProgramStringARB);
8242 SET_BindProgramNV(table, save_BindProgramNV);
8243 SET_DeleteProgramsNV(table, _mesa_DeletePrograms);
8244 SET_GenProgramsNV(table, _mesa_GenPrograms);
8245 SET_IsProgramNV(table, _mesa_IsProgramARB);
8246 SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV);
8247 SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV);
8248 SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV);
8249 SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV);
8250 SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB);
8251 SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB);
8252 SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB);
8253 SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB);
8254 SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB);
8255 SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB);
8256 SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB);
8257 SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB);
8258 SET_GetProgramEnvParameterdvARB(table, _mesa_GetProgramEnvParameterdvARB);
8259 SET_GetProgramEnvParameterfvARB(table, _mesa_GetProgramEnvParameterfvARB);
8260 SET_GetProgramLocalParameterdvARB(table,
8261 _mesa_GetProgramLocalParameterdvARB);
8262 SET_GetProgramLocalParameterfvARB(table,
8263 _mesa_GetProgramLocalParameterfvARB);
8264 SET_GetProgramivARB(table, _mesa_GetProgramivARB);
8265 SET_GetProgramStringARB(table, _mesa_GetProgramStringARB);
8266 #endif
8267
8268 /* ARB 28. GL_ARB_vertex_buffer_object */
8269 #if FEATURE_ARB_vertex_buffer_object
8270 /* None of the extension's functions get compiled */
8271 SET_BindBufferARB(table, _mesa_BindBufferARB);
8272 SET_BufferDataARB(table, _mesa_BufferDataARB);
8273 SET_BufferSubDataARB(table, _mesa_BufferSubDataARB);
8274 SET_DeleteBuffersARB(table, _mesa_DeleteBuffersARB);
8275 SET_GenBuffersARB(table, _mesa_GenBuffersARB);
8276 SET_GetBufferParameterivARB(table, _mesa_GetBufferParameterivARB);
8277 SET_GetBufferPointervARB(table, _mesa_GetBufferPointervARB);
8278 SET_GetBufferSubDataARB(table, _mesa_GetBufferSubDataARB);
8279 SET_IsBufferARB(table, _mesa_IsBufferARB);
8280 SET_MapBufferARB(table, _mesa_MapBufferARB);
8281 SET_UnmapBufferARB(table, _mesa_UnmapBufferARB);
8282 #endif
8283
8284 #if FEATURE_ARB_occlusion_query
8285 SET_BeginQueryARB(table, save_BeginQueryARB);
8286 SET_EndQueryARB(table, save_EndQueryARB);
8287 SET_GenQueriesARB(table, _mesa_GenQueriesARB);
8288 SET_DeleteQueriesARB(table, _mesa_DeleteQueriesARB);
8289 SET_IsQueryARB(table, _mesa_IsQueryARB);
8290 SET_GetQueryivARB(table, _mesa_GetQueryivARB);
8291 SET_GetQueryObjectivARB(table, _mesa_GetQueryObjectivARB);
8292 SET_GetQueryObjectuivARB(table, _mesa_GetQueryObjectuivARB);
8293 #endif
8294 SET_DrawBuffersARB(table, save_DrawBuffersARB);
8295
8296 #if FEATURE_EXT_framebuffer_blit
8297 SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT);
8298 #endif
8299
8300 /* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */
8301 SET_BindAttribLocationARB(table, exec_BindAttribLocationARB);
8302 SET_GetAttribLocationARB(table, exec_GetAttribLocationARB);
8303 /* XXX additional functions need to be implemented here! */
8304
8305 /* 299. GL_EXT_blend_equation_separate */
8306 SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT);
8307
8308 /* GL_EXT_gpu_program_parmaeters */
8309 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
8310 SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT);
8311 SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT);
8312 #endif
8313 }
8314
8315
8316
8317 static const char *
8318 enum_string(GLenum k)
8319 {
8320 return _mesa_lookup_enum_by_nr(k);
8321 }
8322
8323
8324 /**
8325 * Print the commands in a display list. For debugging only.
8326 * TODO: many commands aren't handled yet.
8327 */
8328 static void GLAPIENTRY
8329 print_list(GLcontext *ctx, GLuint list)
8330 {
8331 struct gl_display_list *dlist;
8332 Node *n;
8333 GLboolean done;
8334
8335 if (!islist(ctx, list)) {
8336 _mesa_printf("%u is not a display list ID\n", list);
8337 return;
8338 }
8339
8340 dlist = lookup_list(ctx, list);
8341 if (!dlist)
8342 return;
8343
8344 n = dlist->Head;
8345
8346 _mesa_printf("START-LIST %u, address %p\n", list, (void *) n);
8347
8348 done = n ? GL_FALSE : GL_TRUE;
8349 while (!done) {
8350 OpCode opcode = n[0].opcode;
8351 GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
8352
8353 if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
8354 /* this is a driver-extended opcode */
8355 ctx->ListExt.Opcode[i].Print(ctx, &n[1]);
8356 n += ctx->ListExt.Opcode[i].Size;
8357 }
8358 else {
8359 switch (opcode) {
8360 case OPCODE_ACCUM:
8361 _mesa_printf("Accum %s %g\n", enum_string(n[1].e), n[2].f);
8362 break;
8363 case OPCODE_BITMAP:
8364 _mesa_printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
8365 n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data);
8366 break;
8367 case OPCODE_CALL_LIST:
8368 _mesa_printf("CallList %d\n", (int) n[1].ui);
8369 break;
8370 case OPCODE_CALL_LIST_OFFSET:
8371 _mesa_printf("CallList %d + offset %u = %u\n", (int) n[1].ui,
8372 ctx->List.ListBase, ctx->List.ListBase + n[1].ui);
8373 break;
8374 case OPCODE_COLOR_TABLE_PARAMETER_FV:
8375 _mesa_printf("ColorTableParameterfv %s %s %f %f %f %f\n",
8376 enum_string(n[1].e), enum_string(n[2].e),
8377 n[3].f, n[4].f, n[5].f, n[6].f);
8378 break;
8379 case OPCODE_COLOR_TABLE_PARAMETER_IV:
8380 _mesa_printf("ColorTableParameteriv %s %s %d %d %d %d\n",
8381 enum_string(n[1].e), enum_string(n[2].e),
8382 n[3].i, n[4].i, n[5].i, n[6].i);
8383 break;
8384 case OPCODE_DISABLE:
8385 _mesa_printf("Disable %s\n", enum_string(n[1].e));
8386 break;
8387 case OPCODE_ENABLE:
8388 _mesa_printf("Enable %s\n", enum_string(n[1].e));
8389 break;
8390 case OPCODE_FRUSTUM:
8391 _mesa_printf("Frustum %g %g %g %g %g %g\n",
8392 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
8393 break;
8394 case OPCODE_LINE_STIPPLE:
8395 _mesa_printf("LineStipple %d %x\n", n[1].i, (int) n[2].us);
8396 break;
8397 case OPCODE_LOAD_IDENTITY:
8398 _mesa_printf("LoadIdentity\n");
8399 break;
8400 case OPCODE_LOAD_MATRIX:
8401 _mesa_printf("LoadMatrix\n");
8402 _mesa_printf(" %8f %8f %8f %8f\n",
8403 n[1].f, n[5].f, n[9].f, n[13].f);
8404 _mesa_printf(" %8f %8f %8f %8f\n",
8405 n[2].f, n[6].f, n[10].f, n[14].f);
8406 _mesa_printf(" %8f %8f %8f %8f\n",
8407 n[3].f, n[7].f, n[11].f, n[15].f);
8408 _mesa_printf(" %8f %8f %8f %8f\n",
8409 n[4].f, n[8].f, n[12].f, n[16].f);
8410 break;
8411 case OPCODE_MULT_MATRIX:
8412 _mesa_printf("MultMatrix (or Rotate)\n");
8413 _mesa_printf(" %8f %8f %8f %8f\n",
8414 n[1].f, n[5].f, n[9].f, n[13].f);
8415 _mesa_printf(" %8f %8f %8f %8f\n",
8416 n[2].f, n[6].f, n[10].f, n[14].f);
8417 _mesa_printf(" %8f %8f %8f %8f\n",
8418 n[3].f, n[7].f, n[11].f, n[15].f);
8419 _mesa_printf(" %8f %8f %8f %8f\n",
8420 n[4].f, n[8].f, n[12].f, n[16].f);
8421 break;
8422 case OPCODE_ORTHO:
8423 _mesa_printf("Ortho %g %g %g %g %g %g\n",
8424 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
8425 break;
8426 case OPCODE_POP_ATTRIB:
8427 _mesa_printf("PopAttrib\n");
8428 break;
8429 case OPCODE_POP_MATRIX:
8430 _mesa_printf("PopMatrix\n");
8431 break;
8432 case OPCODE_POP_NAME:
8433 _mesa_printf("PopName\n");
8434 break;
8435 case OPCODE_PUSH_ATTRIB:
8436 _mesa_printf("PushAttrib %x\n", n[1].bf);
8437 break;
8438 case OPCODE_PUSH_MATRIX:
8439 _mesa_printf("PushMatrix\n");
8440 break;
8441 case OPCODE_PUSH_NAME:
8442 _mesa_printf("PushName %d\n", (int) n[1].ui);
8443 break;
8444 case OPCODE_RASTER_POS:
8445 _mesa_printf("RasterPos %g %g %g %g\n",
8446 n[1].f, n[2].f, n[3].f, n[4].f);
8447 break;
8448 case OPCODE_ROTATE:
8449 _mesa_printf("Rotate %g %g %g %g\n",
8450 n[1].f, n[2].f, n[3].f, n[4].f);
8451 break;
8452 case OPCODE_SCALE:
8453 _mesa_printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f);
8454 break;
8455 case OPCODE_TRANSLATE:
8456 _mesa_printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f);
8457 break;
8458 case OPCODE_BIND_TEXTURE:
8459 _mesa_printf("BindTexture %s %d\n",
8460 _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui);
8461 break;
8462 case OPCODE_SHADE_MODEL:
8463 _mesa_printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui));
8464 break;
8465 case OPCODE_MAP1:
8466 _mesa_printf("Map1 %s %.3f %.3f %d %d\n",
8467 _mesa_lookup_enum_by_nr(n[1].ui),
8468 n[2].f, n[3].f, n[4].i, n[5].i);
8469 break;
8470 case OPCODE_MAP2:
8471 _mesa_printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
8472 _mesa_lookup_enum_by_nr(n[1].ui),
8473 n[2].f, n[3].f, n[4].f, n[5].f,
8474 n[6].i, n[7].i, n[8].i, n[9].i);
8475 break;
8476 case OPCODE_MAPGRID1:
8477 _mesa_printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f);
8478 break;
8479 case OPCODE_MAPGRID2:
8480 _mesa_printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
8481 n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
8482 break;
8483 case OPCODE_EVALMESH1:
8484 _mesa_printf("EvalMesh1 %d %d\n", n[1].i, n[2].i);
8485 break;
8486 case OPCODE_EVALMESH2:
8487 _mesa_printf("EvalMesh2 %d %d %d %d\n",
8488 n[1].i, n[2].i, n[3].i, n[4].i);
8489 break;
8490
8491 case OPCODE_ATTR_1F_NV:
8492 _mesa_printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f);
8493 break;
8494 case OPCODE_ATTR_2F_NV:
8495 _mesa_printf("ATTR_2F_NV attr %d: %f %f\n",
8496 n[1].i, n[2].f, n[3].f);
8497 break;
8498 case OPCODE_ATTR_3F_NV:
8499 _mesa_printf("ATTR_3F_NV attr %d: %f %f %f\n",
8500 n[1].i, n[2].f, n[3].f, n[4].f);
8501 break;
8502 case OPCODE_ATTR_4F_NV:
8503 _mesa_printf("ATTR_4F_NV attr %d: %f %f %f %f\n",
8504 n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
8505 break;
8506 case OPCODE_ATTR_1F_ARB:
8507 _mesa_printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f);
8508 break;
8509 case OPCODE_ATTR_2F_ARB:
8510 _mesa_printf("ATTR_2F_ARB attr %d: %f %f\n",
8511 n[1].i, n[2].f, n[3].f);
8512 break;
8513 case OPCODE_ATTR_3F_ARB:
8514 _mesa_printf("ATTR_3F_ARB attr %d: %f %f %f\n",
8515 n[1].i, n[2].f, n[3].f, n[4].f);
8516 break;
8517 case OPCODE_ATTR_4F_ARB:
8518 _mesa_printf("ATTR_4F_ARB attr %d: %f %f %f %f\n",
8519 n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
8520 break;
8521
8522 case OPCODE_MATERIAL:
8523 _mesa_printf("MATERIAL %x %x: %f %f %f %f\n",
8524 n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f);
8525 break;
8526 case OPCODE_BEGIN:
8527 _mesa_printf("BEGIN %x\n", n[1].i);
8528 break;
8529 case OPCODE_END:
8530 _mesa_printf("END\n");
8531 break;
8532 case OPCODE_RECTF:
8533 _mesa_printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f,
8534 n[4].f);
8535 break;
8536 case OPCODE_EVAL_C1:
8537 _mesa_printf("EVAL_C1 %f\n", n[1].f);
8538 break;
8539 case OPCODE_EVAL_C2:
8540 _mesa_printf("EVAL_C2 %f %f\n", n[1].f, n[2].f);
8541 break;
8542 case OPCODE_EVAL_P1:
8543 _mesa_printf("EVAL_P1 %d\n", n[1].i);
8544 break;
8545 case OPCODE_EVAL_P2:
8546 _mesa_printf("EVAL_P2 %d %d\n", n[1].i, n[2].i);
8547 break;
8548
8549 /*
8550 * meta opcodes/commands
8551 */
8552 case OPCODE_ERROR:
8553 _mesa_printf("Error: %s %s\n",
8554 enum_string(n[1].e), (const char *) n[2].data);
8555 break;
8556 case OPCODE_CONTINUE:
8557 _mesa_printf("DISPLAY-LIST-CONTINUE\n");
8558 n = (Node *) n[1].next;
8559 break;
8560 case OPCODE_END_OF_LIST:
8561 _mesa_printf("END-LIST %u\n", list);
8562 done = GL_TRUE;
8563 break;
8564 default:
8565 if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
8566 _mesa_printf
8567 ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
8568 opcode, (void *) n);
8569 return;
8570 }
8571 else {
8572 _mesa_printf("command %d, %u operands\n", opcode,
8573 InstSize[opcode]);
8574 }
8575 }
8576 /* increment n to point to next compiled command */
8577 if (opcode != OPCODE_CONTINUE) {
8578 n += InstSize[opcode];
8579 }
8580 }
8581 }
8582 }
8583
8584
8585
8586 /**
8587 * Clients may call this function to help debug display list problems.
8588 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
8589 * changed, or break in the future without notice.
8590 */
8591 void
8592 mesa_print_display_list(GLuint list)
8593 {
8594 GET_CURRENT_CONTEXT(ctx);
8595 print_list(ctx, list);
8596 }
8597
8598
8599 /**********************************************************************/
8600 /***** Initialization *****/
8601 /**********************************************************************/
8602
8603 void
8604 _mesa_save_vtxfmt_init(GLvertexformat * vfmt)
8605 {
8606 vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
8607 vfmt->Begin = save_Begin;
8608 vfmt->CallList = _mesa_save_CallList;
8609 vfmt->CallLists = _mesa_save_CallLists;
8610 vfmt->Color3f = save_Color3f;
8611 vfmt->Color3fv = save_Color3fv;
8612 vfmt->Color4f = save_Color4f;
8613 vfmt->Color4fv = save_Color4fv;
8614 vfmt->EdgeFlag = save_EdgeFlag;
8615 vfmt->End = save_End;
8616 vfmt->EvalCoord1f = save_EvalCoord1f;
8617 vfmt->EvalCoord1fv = save_EvalCoord1fv;
8618 vfmt->EvalCoord2f = save_EvalCoord2f;
8619 vfmt->EvalCoord2fv = save_EvalCoord2fv;
8620 vfmt->EvalPoint1 = save_EvalPoint1;
8621 vfmt->EvalPoint2 = save_EvalPoint2;
8622 vfmt->FogCoordfEXT = save_FogCoordfEXT;
8623 vfmt->FogCoordfvEXT = save_FogCoordfvEXT;
8624 vfmt->Indexf = save_Indexf;
8625 vfmt->Indexfv = save_Indexfv;
8626 vfmt->Materialfv = save_Materialfv;
8627 vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f;
8628 vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv;
8629 vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f;
8630 vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv;
8631 vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f;
8632 vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv;
8633 vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f;
8634 vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv;
8635 vfmt->Normal3f = save_Normal3f;
8636 vfmt->Normal3fv = save_Normal3fv;
8637 vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT;
8638 vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT;
8639 vfmt->TexCoord1f = save_TexCoord1f;
8640 vfmt->TexCoord1fv = save_TexCoord1fv;
8641 vfmt->TexCoord2f = save_TexCoord2f;
8642 vfmt->TexCoord2fv = save_TexCoord2fv;
8643 vfmt->TexCoord3f = save_TexCoord3f;
8644 vfmt->TexCoord3fv = save_TexCoord3fv;
8645 vfmt->TexCoord4f = save_TexCoord4f;
8646 vfmt->TexCoord4fv = save_TexCoord4fv;
8647 vfmt->Vertex2f = save_Vertex2f;
8648 vfmt->Vertex2fv = save_Vertex2fv;
8649 vfmt->Vertex3f = save_Vertex3f;
8650 vfmt->Vertex3fv = save_Vertex3fv;
8651 vfmt->Vertex4f = save_Vertex4f;
8652 vfmt->Vertex4fv = save_Vertex4fv;
8653 vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV;
8654 vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV;
8655 vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV;
8656 vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV;
8657 vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV;
8658 vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV;
8659 vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV;
8660 vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV;
8661 vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB;
8662 vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB;
8663 vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB;
8664 vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB;
8665 vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB;
8666 vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB;
8667 vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB;
8668 vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB;
8669
8670 vfmt->EvalMesh1 = _mesa_save_EvalMesh1;
8671 vfmt->EvalMesh2 = _mesa_save_EvalMesh2;
8672 vfmt->Rectf = save_Rectf;
8673
8674 /* The driver is required to implement these as
8675 * 1) They can probably do a better job.
8676 * 2) A lot of new mechanisms would have to be added to this module
8677 * to support it. That code would probably never get used,
8678 * because of (1).
8679 */
8680 #if 0
8681 vfmt->DrawArrays = 0;
8682 vfmt->DrawElements = 0;
8683 vfmt->DrawRangeElements = 0;
8684 #endif
8685 }
8686
8687
8688 /**
8689 * Initialize display list state for given context.
8690 */
8691 void
8692 _mesa_init_display_list(GLcontext *ctx)
8693 {
8694 static GLboolean tableInitialized = GL_FALSE;
8695
8696 /* zero-out the instruction size table, just once */
8697 if (!tableInitialized) {
8698 _mesa_bzero(InstSize, sizeof(InstSize));
8699 tableInitialized = GL_TRUE;
8700 }
8701
8702 /* Display list */
8703 ctx->ListState.CallDepth = 0;
8704 ctx->ExecuteFlag = GL_TRUE;
8705 ctx->CompileFlag = GL_FALSE;
8706 ctx->ListState.CurrentBlock = NULL;
8707 ctx->ListState.CurrentPos = 0;
8708
8709 /* Display List group */
8710 ctx->List.ListBase = 0;
8711
8712 _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt);
8713 }