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