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