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