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