mesa: Change "BRIAN PAUL" to "THE AUTHORS" in license text.
[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 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26
27 /**
28 * \file dlist.c
29 * Display lists management functions.
30 */
31
32 #include "glheader.h"
33 #include "imports.h"
34 #include "api_arrayelt.h"
35 #include "api_exec.h"
36 #include "api_loopback.h"
37 #include "api_validate.h"
38 #include "atifragshader.h"
39 #include "config.h"
40 #include "bufferobj.h"
41 #include "arrayobj.h"
42 #include "context.h"
43 #include "dlist.h"
44 #include "enums.h"
45 #include "eval.h"
46 #include "fbobject.h"
47 #include "framebuffer.h"
48 #include "glapi/glapi.h"
49 #include "glformats.h"
50 #include "hash.h"
51 #include "image.h"
52 #include "light.h"
53 #include "macros.h"
54 #include "pack.h"
55 #include "pbo.h"
56 #include "queryobj.h"
57 #include "samplerobj.h"
58 #include "shaderapi.h"
59 #include "syncobj.h"
60 #include "teximage.h"
61 #include "texstorage.h"
62 #include "mtypes.h"
63 #include "varray.h"
64 #include "arbprogram.h"
65 #include "transformfeedback.h"
66
67 #include "math/m_matrix.h"
68
69 #include "main/dispatch.h"
70
71
72
73 /**
74 * Other parts of Mesa (such as the VBO module) can plug into the display
75 * list system. This structure describes new display list instructions.
76 */
77 struct gl_list_instruction
78 {
79 GLuint Size;
80 void (*Execute)( struct gl_context *ctx, void *data );
81 void (*Destroy)( struct gl_context *ctx, void *data );
82 void (*Print)( struct gl_context *ctx, void *data );
83 };
84
85
86 #define MAX_DLIST_EXT_OPCODES 16
87
88 /**
89 * Used by device drivers to hook new commands into display lists.
90 */
91 struct gl_list_extensions
92 {
93 struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES];
94 GLuint NumOpcodes;
95 };
96
97
98
99 /**
100 * Flush vertices.
101 *
102 * \param ctx GL context.
103 *
104 * Checks if dd_function_table::SaveNeedFlush is marked to flush
105 * stored (save) vertices, and calls
106 * dd_function_table::SaveFlushVertices if so.
107 */
108 #define SAVE_FLUSH_VERTICES(ctx) \
109 do { \
110 if (ctx->Driver.SaveNeedFlush) \
111 ctx->Driver.SaveFlushVertices(ctx); \
112 } while (0)
113
114
115 /**
116 * Macro to assert that the API call was made outside the
117 * glBegin()/glEnd() pair, with return value.
118 *
119 * \param ctx GL context.
120 * \param retval value to return value in case the assertion fails.
121 */
122 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \
123 do { \
124 if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \
125 ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
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 <= GL_POLYGON || \
140 ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
141 _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
142 return; \
143 } \
144 } while (0)
145
146 /**
147 * Macro to assert that the API call was made outside the
148 * glBegin()/glEnd() pair and flush the vertices.
149 *
150 * \param ctx GL context.
151 */
152 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \
153 do { \
154 ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \
155 SAVE_FLUSH_VERTICES(ctx); \
156 } while (0)
157
158 /**
159 * Macro to assert that the API call was made outside the
160 * glBegin()/glEnd() pair and flush the vertices, with return value.
161 *
162 * \param ctx GL context.
163 * \param retval value to return value in case the assertion fails.
164 */
165 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\
166 do { \
167 ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \
168 SAVE_FLUSH_VERTICES(ctx); \
169 } while (0)
170
171
172
173 /**
174 * Display list opcodes.
175 *
176 * The fact that these identifiers are assigned consecutive
177 * integer values starting at 0 is very important, see InstSize array usage)
178 */
179 typedef enum
180 {
181 OPCODE_INVALID = -1, /* Force signed enum */
182 OPCODE_ACCUM,
183 OPCODE_ALPHA_FUNC,
184 OPCODE_BIND_TEXTURE,
185 OPCODE_BITMAP,
186 OPCODE_BLEND_COLOR,
187 OPCODE_BLEND_EQUATION,
188 OPCODE_BLEND_EQUATION_SEPARATE,
189 OPCODE_BLEND_FUNC_SEPARATE,
190
191 OPCODE_BLEND_EQUATION_I,
192 OPCODE_BLEND_EQUATION_SEPARATE_I,
193 OPCODE_BLEND_FUNC_I,
194 OPCODE_BLEND_FUNC_SEPARATE_I,
195
196 OPCODE_CALL_LIST,
197 OPCODE_CALL_LIST_OFFSET,
198 OPCODE_CLEAR,
199 OPCODE_CLEAR_ACCUM,
200 OPCODE_CLEAR_COLOR,
201 OPCODE_CLEAR_DEPTH,
202 OPCODE_CLEAR_INDEX,
203 OPCODE_CLEAR_STENCIL,
204 OPCODE_CLEAR_BUFFER_IV,
205 OPCODE_CLEAR_BUFFER_UIV,
206 OPCODE_CLEAR_BUFFER_FV,
207 OPCODE_CLEAR_BUFFER_FI,
208 OPCODE_CLIP_PLANE,
209 OPCODE_COLOR_MASK,
210 OPCODE_COLOR_MASK_INDEXED,
211 OPCODE_COLOR_MATERIAL,
212 OPCODE_COLOR_TABLE,
213 OPCODE_COLOR_TABLE_PARAMETER_FV,
214 OPCODE_COLOR_TABLE_PARAMETER_IV,
215 OPCODE_COLOR_SUB_TABLE,
216 OPCODE_CONVOLUTION_FILTER_1D,
217 OPCODE_CONVOLUTION_FILTER_2D,
218 OPCODE_CONVOLUTION_PARAMETER_I,
219 OPCODE_CONVOLUTION_PARAMETER_IV,
220 OPCODE_CONVOLUTION_PARAMETER_F,
221 OPCODE_CONVOLUTION_PARAMETER_FV,
222 OPCODE_COPY_COLOR_SUB_TABLE,
223 OPCODE_COPY_COLOR_TABLE,
224 OPCODE_COPY_PIXELS,
225 OPCODE_COPY_TEX_IMAGE1D,
226 OPCODE_COPY_TEX_IMAGE2D,
227 OPCODE_COPY_TEX_SUB_IMAGE1D,
228 OPCODE_COPY_TEX_SUB_IMAGE2D,
229 OPCODE_COPY_TEX_SUB_IMAGE3D,
230 OPCODE_CULL_FACE,
231 OPCODE_DEPTH_FUNC,
232 OPCODE_DEPTH_MASK,
233 OPCODE_DEPTH_RANGE,
234 OPCODE_DISABLE,
235 OPCODE_DISABLE_INDEXED,
236 OPCODE_DRAW_BUFFER,
237 OPCODE_DRAW_PIXELS,
238 OPCODE_ENABLE,
239 OPCODE_ENABLE_INDEXED,
240 OPCODE_EVALMESH1,
241 OPCODE_EVALMESH2,
242 OPCODE_FOG,
243 OPCODE_FRONT_FACE,
244 OPCODE_FRUSTUM,
245 OPCODE_HINT,
246 OPCODE_HISTOGRAM,
247 OPCODE_INDEX_MASK,
248 OPCODE_INIT_NAMES,
249 OPCODE_LIGHT,
250 OPCODE_LIGHT_MODEL,
251 OPCODE_LINE_STIPPLE,
252 OPCODE_LINE_WIDTH,
253 OPCODE_LIST_BASE,
254 OPCODE_LOAD_IDENTITY,
255 OPCODE_LOAD_MATRIX,
256 OPCODE_LOAD_NAME,
257 OPCODE_LOGIC_OP,
258 OPCODE_MAP1,
259 OPCODE_MAP2,
260 OPCODE_MAPGRID1,
261 OPCODE_MAPGRID2,
262 OPCODE_MATRIX_MODE,
263 OPCODE_MIN_MAX,
264 OPCODE_MULT_MATRIX,
265 OPCODE_ORTHO,
266 OPCODE_PASSTHROUGH,
267 OPCODE_PIXEL_MAP,
268 OPCODE_PIXEL_TRANSFER,
269 OPCODE_PIXEL_ZOOM,
270 OPCODE_POINT_SIZE,
271 OPCODE_POINT_PARAMETERS,
272 OPCODE_POLYGON_MODE,
273 OPCODE_POLYGON_STIPPLE,
274 OPCODE_POLYGON_OFFSET,
275 OPCODE_POP_ATTRIB,
276 OPCODE_POP_MATRIX,
277 OPCODE_POP_NAME,
278 OPCODE_PRIORITIZE_TEXTURE,
279 OPCODE_PUSH_ATTRIB,
280 OPCODE_PUSH_MATRIX,
281 OPCODE_PUSH_NAME,
282 OPCODE_RASTER_POS,
283 OPCODE_READ_BUFFER,
284 OPCODE_RESET_HISTOGRAM,
285 OPCODE_RESET_MIN_MAX,
286 OPCODE_ROTATE,
287 OPCODE_SCALE,
288 OPCODE_SCISSOR,
289 OPCODE_SELECT_TEXTURE_SGIS,
290 OPCODE_SELECT_TEXTURE_COORD_SET,
291 OPCODE_SHADE_MODEL,
292 OPCODE_STENCIL_FUNC,
293 OPCODE_STENCIL_MASK,
294 OPCODE_STENCIL_OP,
295 OPCODE_TEXENV,
296 OPCODE_TEXGEN,
297 OPCODE_TEXPARAMETER,
298 OPCODE_TEX_IMAGE1D,
299 OPCODE_TEX_IMAGE2D,
300 OPCODE_TEX_IMAGE3D,
301 OPCODE_TEX_SUB_IMAGE1D,
302 OPCODE_TEX_SUB_IMAGE2D,
303 OPCODE_TEX_SUB_IMAGE3D,
304 OPCODE_TRANSLATE,
305 OPCODE_VIEWPORT,
306 OPCODE_WINDOW_POS,
307 /* GL_ARB_multitexture */
308 OPCODE_ACTIVE_TEXTURE,
309 /* GL_ARB_texture_compression */
310 OPCODE_COMPRESSED_TEX_IMAGE_1D,
311 OPCODE_COMPRESSED_TEX_IMAGE_2D,
312 OPCODE_COMPRESSED_TEX_IMAGE_3D,
313 OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
314 OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
315 OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
316 /* GL_ARB_multisample */
317 OPCODE_SAMPLE_COVERAGE,
318 /* GL_ARB_window_pos */
319 OPCODE_WINDOW_POS_ARB,
320 /* GL_NV_fragment_program */
321 OPCODE_BIND_PROGRAM_NV,
322 OPCODE_PROGRAM_LOCAL_PARAMETER_ARB,
323 /* GL_EXT_stencil_two_side */
324 OPCODE_ACTIVE_STENCIL_FACE_EXT,
325 /* GL_EXT_depth_bounds_test */
326 OPCODE_DEPTH_BOUNDS_EXT,
327 /* GL_ARB_vertex/fragment_program */
328 OPCODE_PROGRAM_STRING_ARB,
329 OPCODE_PROGRAM_ENV_PARAMETER_ARB,
330 /* GL_ARB_occlusion_query */
331 OPCODE_BEGIN_QUERY_ARB,
332 OPCODE_END_QUERY_ARB,
333 /* GL_ARB_draw_buffers */
334 OPCODE_DRAW_BUFFERS_ARB,
335 /* GL_ATI_fragment_shader */
336 OPCODE_TEX_BUMP_PARAMETER_ATI,
337 /* GL_ATI_fragment_shader */
338 OPCODE_BIND_FRAGMENT_SHADER_ATI,
339 OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI,
340 /* OpenGL 2.0 */
341 OPCODE_STENCIL_FUNC_SEPARATE,
342 OPCODE_STENCIL_OP_SEPARATE,
343 OPCODE_STENCIL_MASK_SEPARATE,
344
345 /* GL_ARB_shader_objects */
346 OPCODE_USE_PROGRAM,
347 OPCODE_UNIFORM_1F,
348 OPCODE_UNIFORM_2F,
349 OPCODE_UNIFORM_3F,
350 OPCODE_UNIFORM_4F,
351 OPCODE_UNIFORM_1FV,
352 OPCODE_UNIFORM_2FV,
353 OPCODE_UNIFORM_3FV,
354 OPCODE_UNIFORM_4FV,
355 OPCODE_UNIFORM_1I,
356 OPCODE_UNIFORM_2I,
357 OPCODE_UNIFORM_3I,
358 OPCODE_UNIFORM_4I,
359 OPCODE_UNIFORM_1IV,
360 OPCODE_UNIFORM_2IV,
361 OPCODE_UNIFORM_3IV,
362 OPCODE_UNIFORM_4IV,
363 OPCODE_UNIFORM_MATRIX22,
364 OPCODE_UNIFORM_MATRIX33,
365 OPCODE_UNIFORM_MATRIX44,
366 OPCODE_UNIFORM_MATRIX23,
367 OPCODE_UNIFORM_MATRIX32,
368 OPCODE_UNIFORM_MATRIX24,
369 OPCODE_UNIFORM_MATRIX42,
370 OPCODE_UNIFORM_MATRIX34,
371 OPCODE_UNIFORM_MATRIX43,
372
373 /* OpenGL 3.0 */
374 OPCODE_UNIFORM_1UI,
375 OPCODE_UNIFORM_2UI,
376 OPCODE_UNIFORM_3UI,
377 OPCODE_UNIFORM_4UI,
378 OPCODE_UNIFORM_1UIV,
379 OPCODE_UNIFORM_2UIV,
380 OPCODE_UNIFORM_3UIV,
381 OPCODE_UNIFORM_4UIV,
382
383 /* GL_ARB_color_buffer_float */
384 OPCODE_CLAMP_COLOR,
385
386 /* GL_EXT_framebuffer_blit */
387 OPCODE_BLIT_FRAMEBUFFER,
388
389 /* Vertex attributes -- fallback for when optimized display
390 * list build isn't active.
391 */
392 OPCODE_ATTR_1F_NV,
393 OPCODE_ATTR_2F_NV,
394 OPCODE_ATTR_3F_NV,
395 OPCODE_ATTR_4F_NV,
396 OPCODE_ATTR_1F_ARB,
397 OPCODE_ATTR_2F_ARB,
398 OPCODE_ATTR_3F_ARB,
399 OPCODE_ATTR_4F_ARB,
400 OPCODE_MATERIAL,
401 OPCODE_BEGIN,
402 OPCODE_END,
403 OPCODE_RECTF,
404 OPCODE_EVAL_C1,
405 OPCODE_EVAL_C2,
406 OPCODE_EVAL_P1,
407 OPCODE_EVAL_P2,
408
409 /* GL_EXT_provoking_vertex */
410 OPCODE_PROVOKING_VERTEX,
411
412 /* GL_EXT_transform_feedback */
413 OPCODE_BEGIN_TRANSFORM_FEEDBACK,
414 OPCODE_END_TRANSFORM_FEEDBACK,
415 OPCODE_BIND_TRANSFORM_FEEDBACK,
416 OPCODE_PAUSE_TRANSFORM_FEEDBACK,
417 OPCODE_RESUME_TRANSFORM_FEEDBACK,
418 OPCODE_DRAW_TRANSFORM_FEEDBACK,
419
420 /* GL_EXT_texture_integer */
421 OPCODE_CLEARCOLOR_I,
422 OPCODE_CLEARCOLOR_UI,
423 OPCODE_TEXPARAMETER_I,
424 OPCODE_TEXPARAMETER_UI,
425
426 /* GL_EXT_separate_shader_objects */
427 OPCODE_ACTIVE_PROGRAM_EXT,
428 OPCODE_USE_SHADER_PROGRAM_EXT,
429
430 /* GL_ARB_instanced_arrays */
431 OPCODE_VERTEX_ATTRIB_DIVISOR,
432
433 /* GL_NV_texture_barrier */
434 OPCODE_TEXTURE_BARRIER_NV,
435
436 /* GL_ARB_sampler_object */
437 OPCODE_BIND_SAMPLER,
438 OPCODE_SAMPLER_PARAMETERIV,
439 OPCODE_SAMPLER_PARAMETERFV,
440 OPCODE_SAMPLER_PARAMETERIIV,
441 OPCODE_SAMPLER_PARAMETERUIV,
442
443 /* GL_ARB_geometry_shader4 */
444 OPCODE_PROGRAM_PARAMETERI,
445 OPCODE_FRAMEBUFFER_TEXTURE,
446 OPCODE_FRAMEBUFFER_TEXTURE_FACE,
447
448 /* GL_ARB_sync */
449 OPCODE_WAIT_SYNC,
450
451 /* GL_NV_conditional_render */
452 OPCODE_BEGIN_CONDITIONAL_RENDER,
453 OPCODE_END_CONDITIONAL_RENDER,
454
455 /* ARB_timer_query */
456 OPCODE_QUERY_COUNTER,
457
458 /* ARB_transform_feedback3 */
459 OPCODE_BEGIN_QUERY_INDEXED,
460 OPCODE_END_QUERY_INDEXED,
461 OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM,
462
463 /* ARB_transform_feedback_instanced */
464 OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED,
465 OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED,
466
467 /* ARB_uniform_buffer_object */
468 OPCODE_UNIFORM_BLOCK_BINDING,
469
470 /* The following three are meta instructions */
471 OPCODE_ERROR, /* raise compiled-in error */
472 OPCODE_CONTINUE,
473 OPCODE_END_OF_LIST,
474 OPCODE_EXT_0
475 } OpCode;
476
477
478
479 /**
480 * Display list node.
481 *
482 * Display list instructions are stored as sequences of "nodes". Nodes
483 * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
484 * are linked together with a pointer.
485 *
486 * Each instruction in the display list is stored as a sequence of
487 * contiguous nodes in memory.
488 * Each node is the union of a variety of data types.
489 */
490 union gl_dlist_node
491 {
492 OpCode opcode;
493 GLboolean b;
494 GLbitfield bf;
495 GLubyte ub;
496 GLshort s;
497 GLushort us;
498 GLint i;
499 GLuint ui;
500 GLenum e;
501 GLfloat f;
502 GLsizei si;
503 GLvoid *data;
504 void *next; /* If prev node's opcode==OPCODE_CONTINUE */
505 };
506
507
508 typedef union gl_dlist_node Node;
509
510
511 /**
512 * Used to store a 64-bit uint in a pair of "Nodes" for the sake of 32-bit
513 * environment. In 64-bit env, sizeof(Node)==8 anyway.
514 */
515 union uint64_pair
516 {
517 GLuint64 uint64;
518 GLuint uint32[2];
519 };
520
521
522 /**
523 * How many nodes to allocate at a time.
524 *
525 * \note Reduced now that we hold vertices etc. elsewhere.
526 */
527 #define BLOCK_SIZE 256
528
529
530
531 /**
532 * Number of nodes of storage needed for each instruction.
533 * Sizes for dynamically allocated opcodes are stored in the context struct.
534 */
535 static GLuint InstSize[OPCODE_END_OF_LIST + 1];
536
537
538 void mesa_print_display_list(GLuint list);
539
540
541 /**********************************************************************/
542 /***** Private *****/
543 /**********************************************************************/
544
545
546 /**
547 * Make an empty display list. This is used by glGenLists() to
548 * reserve display list IDs.
549 */
550 static struct gl_display_list *
551 make_list(GLuint name, GLuint count)
552 {
553 struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list);
554 dlist->Name = name;
555 dlist->Head = malloc(sizeof(Node) * count);
556 dlist->Head[0].opcode = OPCODE_END_OF_LIST;
557 return dlist;
558 }
559
560
561 /**
562 * Lookup function to just encapsulate casting.
563 */
564 static inline struct gl_display_list *
565 lookup_list(struct gl_context *ctx, GLuint list)
566 {
567 return (struct gl_display_list *)
568 _mesa_HashLookup(ctx->Shared->DisplayList, list);
569 }
570
571
572 /** Is the given opcode an extension code? */
573 static inline GLboolean
574 is_ext_opcode(OpCode opcode)
575 {
576 return (opcode >= OPCODE_EXT_0);
577 }
578
579
580 /** Destroy an extended opcode instruction */
581 static GLint
582 ext_opcode_destroy(struct gl_context *ctx, Node *node)
583 {
584 const GLint i = node[0].opcode - OPCODE_EXT_0;
585 GLint step;
586 ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]);
587 step = ctx->ListExt->Opcode[i].Size;
588 return step;
589 }
590
591
592 /** Execute an extended opcode instruction */
593 static GLint
594 ext_opcode_execute(struct gl_context *ctx, Node *node)
595 {
596 const GLint i = node[0].opcode - OPCODE_EXT_0;
597 GLint step;
598 ctx->ListExt->Opcode[i].Execute(ctx, &node[1]);
599 step = ctx->ListExt->Opcode[i].Size;
600 return step;
601 }
602
603
604 /** Print an extended opcode instruction */
605 static GLint
606 ext_opcode_print(struct gl_context *ctx, Node *node)
607 {
608 const GLint i = node[0].opcode - OPCODE_EXT_0;
609 GLint step;
610 ctx->ListExt->Opcode[i].Print(ctx, &node[1]);
611 step = ctx->ListExt->Opcode[i].Size;
612 return step;
613 }
614
615
616 /**
617 * Delete the named display list, but don't remove from hash table.
618 * \param dlist - display list pointer
619 */
620 void
621 _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist)
622 {
623 Node *n, *block;
624 GLboolean done;
625
626 n = block = dlist->Head;
627
628 done = block ? GL_FALSE : GL_TRUE;
629 while (!done) {
630 const OpCode opcode = n[0].opcode;
631
632 /* check for extension opcodes first */
633 if (is_ext_opcode(opcode)) {
634 n += ext_opcode_destroy(ctx, n);
635 }
636 else {
637 switch (opcode) {
638 /* for some commands, we need to free malloc'd memory */
639 case OPCODE_MAP1:
640 free(n[6].data);
641 n += InstSize[n[0].opcode];
642 break;
643 case OPCODE_MAP2:
644 free(n[10].data);
645 n += InstSize[n[0].opcode];
646 break;
647 case OPCODE_DRAW_PIXELS:
648 free(n[5].data);
649 n += InstSize[n[0].opcode];
650 break;
651 case OPCODE_BITMAP:
652 free(n[7].data);
653 n += InstSize[n[0].opcode];
654 break;
655 case OPCODE_COLOR_TABLE:
656 free(n[6].data);
657 n += InstSize[n[0].opcode];
658 break;
659 case OPCODE_COLOR_SUB_TABLE:
660 free(n[6].data);
661 n += InstSize[n[0].opcode];
662 break;
663 case OPCODE_CONVOLUTION_FILTER_1D:
664 free(n[6].data);
665 n += InstSize[n[0].opcode];
666 break;
667 case OPCODE_CONVOLUTION_FILTER_2D:
668 free(n[7].data);
669 n += InstSize[n[0].opcode];
670 break;
671 case OPCODE_POLYGON_STIPPLE:
672 free(n[1].data);
673 n += InstSize[n[0].opcode];
674 break;
675 case OPCODE_TEX_IMAGE1D:
676 free(n[8].data);
677 n += InstSize[n[0].opcode];
678 break;
679 case OPCODE_TEX_IMAGE2D:
680 free(n[9].data);
681 n += InstSize[n[0].opcode];
682 break;
683 case OPCODE_TEX_IMAGE3D:
684 free(n[10].data);
685 n += InstSize[n[0].opcode];
686 break;
687 case OPCODE_TEX_SUB_IMAGE1D:
688 free(n[7].data);
689 n += InstSize[n[0].opcode];
690 break;
691 case OPCODE_TEX_SUB_IMAGE2D:
692 free(n[9].data);
693 n += InstSize[n[0].opcode];
694 break;
695 case OPCODE_TEX_SUB_IMAGE3D:
696 free(n[11].data);
697 n += InstSize[n[0].opcode];
698 break;
699 case OPCODE_COMPRESSED_TEX_IMAGE_1D:
700 free(n[7].data);
701 n += InstSize[n[0].opcode];
702 break;
703 case OPCODE_COMPRESSED_TEX_IMAGE_2D:
704 free(n[8].data);
705 n += InstSize[n[0].opcode];
706 break;
707 case OPCODE_COMPRESSED_TEX_IMAGE_3D:
708 free(n[9].data);
709 n += InstSize[n[0].opcode];
710 break;
711 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:
712 free(n[7].data);
713 n += InstSize[n[0].opcode];
714 break;
715 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:
716 free(n[9].data);
717 n += InstSize[n[0].opcode];
718 break;
719 case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:
720 free(n[11].data);
721 n += InstSize[n[0].opcode];
722 break;
723 case OPCODE_PROGRAM_STRING_ARB:
724 free(n[4].data); /* program string */
725 n += InstSize[n[0].opcode];
726 break;
727 case OPCODE_UNIFORM_1FV:
728 case OPCODE_UNIFORM_2FV:
729 case OPCODE_UNIFORM_3FV:
730 case OPCODE_UNIFORM_4FV:
731 case OPCODE_UNIFORM_1IV:
732 case OPCODE_UNIFORM_2IV:
733 case OPCODE_UNIFORM_3IV:
734 case OPCODE_UNIFORM_4IV:
735 case OPCODE_UNIFORM_1UIV:
736 case OPCODE_UNIFORM_2UIV:
737 case OPCODE_UNIFORM_3UIV:
738 case OPCODE_UNIFORM_4UIV:
739 free(n[3].data);
740 n += InstSize[n[0].opcode];
741 break;
742 case OPCODE_UNIFORM_MATRIX22:
743 case OPCODE_UNIFORM_MATRIX33:
744 case OPCODE_UNIFORM_MATRIX44:
745 case OPCODE_UNIFORM_MATRIX24:
746 case OPCODE_UNIFORM_MATRIX42:
747 case OPCODE_UNIFORM_MATRIX23:
748 case OPCODE_UNIFORM_MATRIX32:
749 case OPCODE_UNIFORM_MATRIX34:
750 case OPCODE_UNIFORM_MATRIX43:
751 free(n[4].data);
752 n += InstSize[n[0].opcode];
753 break;
754
755 case OPCODE_CONTINUE:
756 n = (Node *) n[1].next;
757 free(block);
758 block = n;
759 break;
760 case OPCODE_END_OF_LIST:
761 free(block);
762 done = GL_TRUE;
763 break;
764 default:
765 /* Most frequent case */
766 n += InstSize[n[0].opcode];
767 break;
768 }
769 }
770 }
771
772 free(dlist);
773 }
774
775
776 /**
777 * Destroy a display list and remove from hash table.
778 * \param list - display list number
779 */
780 static void
781 destroy_list(struct gl_context *ctx, GLuint list)
782 {
783 struct gl_display_list *dlist;
784
785 if (list == 0)
786 return;
787
788 dlist = lookup_list(ctx, list);
789 if (!dlist)
790 return;
791
792 _mesa_delete_list(ctx, dlist);
793 _mesa_HashRemove(ctx->Shared->DisplayList, list);
794 }
795
796
797 /*
798 * Translate the nth element of list from <type> to GLint.
799 */
800 static GLint
801 translate_id(GLsizei n, GLenum type, const GLvoid * list)
802 {
803 GLbyte *bptr;
804 GLubyte *ubptr;
805 GLshort *sptr;
806 GLushort *usptr;
807 GLint *iptr;
808 GLuint *uiptr;
809 GLfloat *fptr;
810
811 switch (type) {
812 case GL_BYTE:
813 bptr = (GLbyte *) list;
814 return (GLint) bptr[n];
815 case GL_UNSIGNED_BYTE:
816 ubptr = (GLubyte *) list;
817 return (GLint) ubptr[n];
818 case GL_SHORT:
819 sptr = (GLshort *) list;
820 return (GLint) sptr[n];
821 case GL_UNSIGNED_SHORT:
822 usptr = (GLushort *) list;
823 return (GLint) usptr[n];
824 case GL_INT:
825 iptr = (GLint *) list;
826 return iptr[n];
827 case GL_UNSIGNED_INT:
828 uiptr = (GLuint *) list;
829 return (GLint) uiptr[n];
830 case GL_FLOAT:
831 fptr = (GLfloat *) list;
832 return (GLint) FLOORF(fptr[n]);
833 case GL_2_BYTES:
834 ubptr = ((GLubyte *) list) + 2 * n;
835 return (GLint) ubptr[0] * 256
836 + (GLint) ubptr[1];
837 case GL_3_BYTES:
838 ubptr = ((GLubyte *) list) + 3 * n;
839 return (GLint) ubptr[0] * 65536
840 + (GLint) ubptr[1] * 256
841 + (GLint) ubptr[2];
842 case GL_4_BYTES:
843 ubptr = ((GLubyte *) list) + 4 * n;
844 return (GLint) ubptr[0] * 16777216
845 + (GLint) ubptr[1] * 65536
846 + (GLint) ubptr[2] * 256
847 + (GLint) ubptr[3];
848 default:
849 return 0;
850 }
851 }
852
853
854
855
856 /**********************************************************************/
857 /***** Public *****/
858 /**********************************************************************/
859
860 /**
861 * Wrapper for _mesa_unpack_image/bitmap() that handles pixel buffer objects.
862 * If width < 0 or height < 0 or format or type are invalid we'll just
863 * return NULL. We will not generate an error since OpenGL command
864 * arguments aren't error-checked until the command is actually executed
865 * (not when they're compiled).
866 * But if we run out of memory, GL_OUT_OF_MEMORY will be recorded.
867 */
868 static GLvoid *
869 unpack_image(struct gl_context *ctx, GLuint dimensions,
870 GLsizei width, GLsizei height, GLsizei depth,
871 GLenum format, GLenum type, const GLvoid * pixels,
872 const struct gl_pixelstore_attrib *unpack)
873 {
874 if (width <= 0 || height <= 0) {
875 return NULL;
876 }
877
878 if (_mesa_bytes_per_pixel(format, type) < 0) {
879 /* bad format and/or type */
880 return NULL;
881 }
882
883 if (!_mesa_is_bufferobj(unpack->BufferObj)) {
884 /* no PBO */
885 GLvoid *image;
886
887 if (type == GL_BITMAP)
888 image = _mesa_unpack_bitmap(width, height, pixels, unpack);
889 else
890 image = _mesa_unpack_image(dimensions, width, height, depth,
891 format, type, pixels, unpack);
892 if (pixels && !image) {
893 _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
894 }
895 return image;
896 }
897 else if (_mesa_validate_pbo_access(dimensions, unpack, width, height,
898 depth, format, type, INT_MAX, pixels)) {
899 const GLubyte *map, *src;
900 GLvoid *image;
901
902 map = (GLubyte *)
903 ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
904 GL_MAP_READ_BIT, unpack->BufferObj);
905 if (!map) {
906 /* unable to map src buffer! */
907 _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO");
908 return NULL;
909 }
910
911 src = ADD_POINTERS(map, pixels);
912 if (type == GL_BITMAP)
913 image = _mesa_unpack_bitmap(width, height, src, unpack);
914 else
915 image = _mesa_unpack_image(dimensions, width, height, depth,
916 format, type, src, unpack);
917
918 ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj);
919
920 if (!image) {
921 _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
922 }
923 return image;
924 }
925
926 /* bad access! */
927 _mesa_error(ctx, GL_INVALID_OPERATION, "invalid PBO access");
928 return NULL;
929 }
930
931 /**
932 * Allocate space for a display list instruction (opcode + payload space).
933 * \param opcode the instruction opcode (OPCODE_* value)
934 * \param bytes instruction payload size (not counting opcode)
935 * \return pointer to allocated memory (the opcode space)
936 */
937 static Node *
938 dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes)
939 {
940 const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node);
941 Node *n;
942
943 if (opcode < (GLuint) OPCODE_EXT_0) {
944 if (InstSize[opcode] == 0) {
945 /* save instruction size now */
946 InstSize[opcode] = numNodes;
947 }
948 else {
949 /* make sure instruction size agrees */
950 ASSERT(numNodes == InstSize[opcode]);
951 }
952 }
953
954 if (ctx->ListState.CurrentPos + numNodes + 2 > BLOCK_SIZE) {
955 /* This block is full. Allocate a new block and chain to it */
956 Node *newblock;
957 n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
958 n[0].opcode = OPCODE_CONTINUE;
959 newblock = malloc(sizeof(Node) * BLOCK_SIZE);
960 if (!newblock) {
961 _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list");
962 return NULL;
963 }
964 n[1].next = (Node *) newblock;
965 ctx->ListState.CurrentBlock = newblock;
966 ctx->ListState.CurrentPos = 0;
967 }
968
969 n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
970 ctx->ListState.CurrentPos += numNodes;
971
972 n[0].opcode = opcode;
973
974 return n;
975 }
976
977
978
979 /**
980 * Allocate space for a display list instruction. Used by callers outside
981 * this file for things like VBO vertex data.
982 *
983 * \param opcode the instruction opcode (OPCODE_* value)
984 * \param bytes instruction size in bytes, not counting opcode.
985 * \return pointer to the usable data area (not including the internal
986 * opcode).
987 */
988 void *
989 _mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint bytes)
990 {
991 Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes);
992 if (n)
993 return n + 1; /* return pointer to payload area, after opcode */
994 else
995 return NULL;
996 }
997
998
999 /**
1000 * This function allows modules and drivers to get their own opcodes
1001 * for extending display list functionality.
1002 * \param ctx the rendering context
1003 * \param size number of bytes for storing the new display list command
1004 * \param execute function to execute the new display list command
1005 * \param destroy function to destroy the new display list command
1006 * \param print function to print the new display list command
1007 * \return the new opcode number or -1 if error
1008 */
1009 GLint
1010 _mesa_dlist_alloc_opcode(struct gl_context *ctx,
1011 GLuint size,
1012 void (*execute) (struct gl_context *, void *),
1013 void (*destroy) (struct gl_context *, void *),
1014 void (*print) (struct gl_context *, void *))
1015 {
1016 if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) {
1017 const GLuint i = ctx->ListExt->NumOpcodes++;
1018 ctx->ListExt->Opcode[i].Size =
1019 1 + (size + sizeof(Node) - 1) / sizeof(Node);
1020 ctx->ListExt->Opcode[i].Execute = execute;
1021 ctx->ListExt->Opcode[i].Destroy = destroy;
1022 ctx->ListExt->Opcode[i].Print = print;
1023 return i + OPCODE_EXT_0;
1024 }
1025 return -1;
1026 }
1027
1028
1029 /**
1030 * Allocate space for a display list instruction. The space is basically
1031 * an array of Nodes where node[0] holds the opcode, node[1] is the first
1032 * function parameter, node[2] is the second parameter, etc.
1033 *
1034 * \param opcode one of OPCODE_x
1035 * \param nparams number of function parameters
1036 * \return pointer to start of instruction space
1037 */
1038 static inline Node *
1039 alloc_instruction(struct gl_context *ctx, OpCode opcode, GLuint nparams)
1040 {
1041 return dlist_alloc(ctx, opcode, nparams * sizeof(Node));
1042 }
1043
1044
1045
1046 /*
1047 * Display List compilation functions
1048 */
1049 static void GLAPIENTRY
1050 save_Accum(GLenum op, GLfloat value)
1051 {
1052 GET_CURRENT_CONTEXT(ctx);
1053 Node *n;
1054 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1055 n = alloc_instruction(ctx, OPCODE_ACCUM, 2);
1056 if (n) {
1057 n[1].e = op;
1058 n[2].f = value;
1059 }
1060 if (ctx->ExecuteFlag) {
1061 CALL_Accum(ctx->Exec, (op, value));
1062 }
1063 }
1064
1065
1066 static void GLAPIENTRY
1067 save_AlphaFunc(GLenum func, GLclampf ref)
1068 {
1069 GET_CURRENT_CONTEXT(ctx);
1070 Node *n;
1071 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1072 n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2);
1073 if (n) {
1074 n[1].e = func;
1075 n[2].f = (GLfloat) ref;
1076 }
1077 if (ctx->ExecuteFlag) {
1078 CALL_AlphaFunc(ctx->Exec, (func, ref));
1079 }
1080 }
1081
1082
1083 static void GLAPIENTRY
1084 save_BindTexture(GLenum target, GLuint texture)
1085 {
1086 GET_CURRENT_CONTEXT(ctx);
1087 Node *n;
1088 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1089 n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2);
1090 if (n) {
1091 n[1].e = target;
1092 n[2].ui = texture;
1093 }
1094 if (ctx->ExecuteFlag) {
1095 CALL_BindTexture(ctx->Exec, (target, texture));
1096 }
1097 }
1098
1099
1100 static void GLAPIENTRY
1101 save_Bitmap(GLsizei width, GLsizei height,
1102 GLfloat xorig, GLfloat yorig,
1103 GLfloat xmove, GLfloat ymove, const GLubyte * pixels)
1104 {
1105 GET_CURRENT_CONTEXT(ctx);
1106 Node *n;
1107 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1108 n = alloc_instruction(ctx, OPCODE_BITMAP, 7);
1109 if (n) {
1110 n[1].i = (GLint) width;
1111 n[2].i = (GLint) height;
1112 n[3].f = xorig;
1113 n[4].f = yorig;
1114 n[5].f = xmove;
1115 n[6].f = ymove;
1116 n[7].data = unpack_image(ctx, 2, width, height, 1, GL_COLOR_INDEX,
1117 GL_BITMAP, pixels, &ctx->Unpack);
1118 }
1119 if (ctx->ExecuteFlag) {
1120 CALL_Bitmap(ctx->Exec, (width, height,
1121 xorig, yorig, xmove, ymove, pixels));
1122 }
1123 }
1124
1125
1126 static void GLAPIENTRY
1127 save_BlendEquation(GLenum mode)
1128 {
1129 GET_CURRENT_CONTEXT(ctx);
1130 Node *n;
1131 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1132 n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1);
1133 if (n) {
1134 n[1].e = mode;
1135 }
1136 if (ctx->ExecuteFlag) {
1137 CALL_BlendEquation(ctx->Exec, (mode));
1138 }
1139 }
1140
1141
1142 static void GLAPIENTRY
1143 save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA)
1144 {
1145 GET_CURRENT_CONTEXT(ctx);
1146 Node *n;
1147 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1148 n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2);
1149 if (n) {
1150 n[1].e = modeRGB;
1151 n[2].e = modeA;
1152 }
1153 if (ctx->ExecuteFlag) {
1154 CALL_BlendEquationSeparate(ctx->Exec, (modeRGB, modeA));
1155 }
1156 }
1157
1158
1159 static void GLAPIENTRY
1160 save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
1161 GLenum sfactorA, GLenum dfactorA)
1162 {
1163 GET_CURRENT_CONTEXT(ctx);
1164 Node *n;
1165 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1166 n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4);
1167 if (n) {
1168 n[1].e = sfactorRGB;
1169 n[2].e = dfactorRGB;
1170 n[3].e = sfactorA;
1171 n[4].e = dfactorA;
1172 }
1173 if (ctx->ExecuteFlag) {
1174 CALL_BlendFuncSeparate(ctx->Exec,
1175 (sfactorRGB, dfactorRGB, sfactorA, dfactorA));
1176 }
1177 }
1178
1179
1180 static void GLAPIENTRY
1181 save_BlendFunc(GLenum srcfactor, GLenum dstfactor)
1182 {
1183 save_BlendFuncSeparateEXT(srcfactor, dstfactor, srcfactor, dstfactor);
1184 }
1185
1186
1187 static void GLAPIENTRY
1188 save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
1189 {
1190 GET_CURRENT_CONTEXT(ctx);
1191 Node *n;
1192 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1193 n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4);
1194 if (n) {
1195 n[1].f = red;
1196 n[2].f = green;
1197 n[3].f = blue;
1198 n[4].f = alpha;
1199 }
1200 if (ctx->ExecuteFlag) {
1201 CALL_BlendColor(ctx->Exec, (red, green, blue, alpha));
1202 }
1203 }
1204
1205 /* GL_ARB_draw_buffers_blend */
1206 static void GLAPIENTRY
1207 save_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
1208 GLenum sfactorA, GLenum dfactorA)
1209 {
1210 GET_CURRENT_CONTEXT(ctx);
1211 Node *n;
1212 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1213 n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 5);
1214 if (n) {
1215 n[1].ui = buf;
1216 n[2].e = sfactorRGB;
1217 n[3].e = dfactorRGB;
1218 n[4].e = sfactorA;
1219 n[5].e = dfactorA;
1220 }
1221 if (ctx->ExecuteFlag) {
1222 CALL_BlendFuncSeparateiARB(ctx->Exec, (buf, sfactorRGB, dfactorRGB,
1223 sfactorA, dfactorA));
1224 }
1225 }
1226
1227 /* GL_ARB_draw_buffers_blend */
1228 static void GLAPIENTRY
1229 save_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
1230 {
1231 GET_CURRENT_CONTEXT(ctx);
1232 Node *n;
1233 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1234 n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 3);
1235 if (n) {
1236 n[1].ui = buf;
1237 n[2].e = sfactor;
1238 n[3].e = dfactor;
1239 }
1240 if (ctx->ExecuteFlag) {
1241 CALL_BlendFunciARB(ctx->Exec, (buf, sfactor, dfactor));
1242 }
1243 }
1244
1245 /* GL_ARB_draw_buffers_blend */
1246 static void GLAPIENTRY
1247 save_BlendEquationi(GLuint buf, GLenum mode)
1248 {
1249 GET_CURRENT_CONTEXT(ctx);
1250 Node *n;
1251 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1252 n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_I, 2);
1253 if (n) {
1254 n[1].ui = buf;
1255 n[2].e = mode;
1256 }
1257 if (ctx->ExecuteFlag) {
1258 CALL_BlendEquationiARB(ctx->Exec, (buf, mode));
1259 }
1260 }
1261
1262 /* GL_ARB_draw_buffers_blend */
1263 static void GLAPIENTRY
1264 save_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA)
1265 {
1266 GET_CURRENT_CONTEXT(ctx);
1267 Node *n;
1268 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1269 n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE_I, 3);
1270 if (n) {
1271 n[1].ui = buf;
1272 n[2].e = modeRGB;
1273 n[3].e = modeA;
1274 }
1275 if (ctx->ExecuteFlag) {
1276 CALL_BlendEquationSeparateiARB(ctx->Exec, (buf, modeRGB, modeA));
1277 }
1278 }
1279
1280
1281 /* GL_ARB_draw_instanced. */
1282 static void GLAPIENTRY
1283 save_DrawArraysInstancedARB(GLenum mode,
1284 GLint first,
1285 GLsizei count,
1286 GLsizei primcount)
1287 {
1288 GET_CURRENT_CONTEXT(ctx);
1289 _mesa_error(ctx, GL_INVALID_OPERATION,
1290 "glDrawArraysInstanced() during display list compile");
1291 }
1292
1293 static void GLAPIENTRY
1294 save_DrawElementsInstancedARB(GLenum mode,
1295 GLsizei count,
1296 GLenum type,
1297 const GLvoid *indices,
1298 GLsizei primcount)
1299 {
1300 GET_CURRENT_CONTEXT(ctx);
1301 _mesa_error(ctx, GL_INVALID_OPERATION,
1302 "glDrawElementsInstanced() during display list compile");
1303 }
1304
1305 static void GLAPIENTRY
1306 save_DrawElementsInstancedBaseVertexARB(GLenum mode,
1307 GLsizei count,
1308 GLenum type,
1309 const GLvoid *indices,
1310 GLsizei primcount,
1311 GLint basevertex)
1312 {
1313 GET_CURRENT_CONTEXT(ctx);
1314 _mesa_error(ctx, GL_INVALID_OPERATION,
1315 "glDrawElementsInstancedBaseVertex() during display list compile");
1316 }
1317
1318 /* GL_ARB_base_instance. */
1319 static void GLAPIENTRY
1320 save_DrawArraysInstancedBaseInstance(GLenum mode,
1321 GLint first,
1322 GLsizei count,
1323 GLsizei primcount,
1324 GLuint baseinstance)
1325 {
1326 GET_CURRENT_CONTEXT(ctx);
1327 _mesa_error(ctx, GL_INVALID_OPERATION,
1328 "glDrawArraysInstancedBaseInstance() during display list compile");
1329 }
1330
1331 static void APIENTRY
1332 save_DrawElementsInstancedBaseInstance(GLenum mode,
1333 GLsizei count,
1334 GLenum type,
1335 const void *indices,
1336 GLsizei primcount,
1337 GLuint baseinstance)
1338 {
1339 GET_CURRENT_CONTEXT(ctx);
1340 _mesa_error(ctx, GL_INVALID_OPERATION,
1341 "glDrawElementsInstancedBaseInstance() during display list compile");
1342 }
1343
1344 static void APIENTRY
1345 save_DrawElementsInstancedBaseVertexBaseInstance(GLenum mode,
1346 GLsizei count,
1347 GLenum type,
1348 const void *indices,
1349 GLsizei primcount,
1350 GLint basevertex,
1351 GLuint baseinstance)
1352 {
1353 GET_CURRENT_CONTEXT(ctx);
1354 _mesa_error(ctx, GL_INVALID_OPERATION,
1355 "glDrawElementsInstancedBaseVertexBaseInstance() during display list compile");
1356 }
1357
1358 static void invalidate_saved_current_state( struct gl_context *ctx )
1359 {
1360 GLint i;
1361
1362 for (i = 0; i < VERT_ATTRIB_MAX; i++)
1363 ctx->ListState.ActiveAttribSize[i] = 0;
1364
1365 for (i = 0; i < MAT_ATTRIB_MAX; i++)
1366 ctx->ListState.ActiveMaterialSize[i] = 0;
1367
1368 memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current);
1369
1370 ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
1371 }
1372
1373 static void GLAPIENTRY
1374 save_CallList(GLuint list)
1375 {
1376 GET_CURRENT_CONTEXT(ctx);
1377 Node *n;
1378 SAVE_FLUSH_VERTICES(ctx);
1379
1380 n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1);
1381 if (n) {
1382 n[1].ui = list;
1383 }
1384
1385 /* After this, we don't know what state we're in. Invalidate all
1386 * cached information previously gathered:
1387 */
1388 invalidate_saved_current_state( ctx );
1389
1390 if (ctx->ExecuteFlag) {
1391 _mesa_CallList(list);
1392 }
1393 }
1394
1395
1396 static void GLAPIENTRY
1397 save_CallLists(GLsizei num, GLenum type, const GLvoid * lists)
1398 {
1399 GET_CURRENT_CONTEXT(ctx);
1400 GLint i;
1401 GLboolean typeErrorFlag;
1402
1403 SAVE_FLUSH_VERTICES(ctx);
1404
1405 switch (type) {
1406 case GL_BYTE:
1407 case GL_UNSIGNED_BYTE:
1408 case GL_SHORT:
1409 case GL_UNSIGNED_SHORT:
1410 case GL_INT:
1411 case GL_UNSIGNED_INT:
1412 case GL_FLOAT:
1413 case GL_2_BYTES:
1414 case GL_3_BYTES:
1415 case GL_4_BYTES:
1416 typeErrorFlag = GL_FALSE;
1417 break;
1418 default:
1419 typeErrorFlag = GL_TRUE;
1420 }
1421
1422 for (i = 0; i < num; i++) {
1423 GLint list = translate_id(i, type, lists);
1424 Node *n = alloc_instruction(ctx, OPCODE_CALL_LIST_OFFSET, 2);
1425 if (n) {
1426 n[1].i = list;
1427 n[2].b = typeErrorFlag;
1428 }
1429 }
1430
1431 /* After this, we don't know what state we're in. Invalidate all
1432 * cached information previously gathered:
1433 */
1434 invalidate_saved_current_state( ctx );
1435
1436 if (ctx->ExecuteFlag) {
1437 CALL_CallLists(ctx->Exec, (num, type, lists));
1438 }
1439 }
1440
1441
1442 static void GLAPIENTRY
1443 save_Clear(GLbitfield mask)
1444 {
1445 GET_CURRENT_CONTEXT(ctx);
1446 Node *n;
1447 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1448 n = alloc_instruction(ctx, OPCODE_CLEAR, 1);
1449 if (n) {
1450 n[1].bf = mask;
1451 }
1452 if (ctx->ExecuteFlag) {
1453 CALL_Clear(ctx->Exec, (mask));
1454 }
1455 }
1456
1457
1458 static void GLAPIENTRY
1459 save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
1460 {
1461 GET_CURRENT_CONTEXT(ctx);
1462 Node *n;
1463 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1464 n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6);
1465 if (n) {
1466 n[1].e = buffer;
1467 n[2].i = drawbuffer;
1468 n[3].i = value[0];
1469 if (buffer == GL_COLOR) {
1470 n[4].i = value[1];
1471 n[5].i = value[2];
1472 n[6].i = value[3];
1473 }
1474 else {
1475 n[4].i = 0;
1476 n[5].i = 0;
1477 n[6].i = 0;
1478 }
1479 }
1480 if (ctx->ExecuteFlag) {
1481 CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));
1482 }
1483 }
1484
1485
1486 static void GLAPIENTRY
1487 save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
1488 {
1489 GET_CURRENT_CONTEXT(ctx);
1490 Node *n;
1491 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1492 n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6);
1493 if (n) {
1494 n[1].e = buffer;
1495 n[2].i = drawbuffer;
1496 n[3].ui = value[0];
1497 if (buffer == GL_COLOR) {
1498 n[4].ui = value[1];
1499 n[5].ui = value[2];
1500 n[6].ui = value[3];
1501 }
1502 else {
1503 n[4].ui = 0;
1504 n[5].ui = 0;
1505 n[6].ui = 0;
1506 }
1507 }
1508 if (ctx->ExecuteFlag) {
1509 CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));
1510 }
1511 }
1512
1513
1514 static void GLAPIENTRY
1515 save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
1516 {
1517 GET_CURRENT_CONTEXT(ctx);
1518 Node *n;
1519 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1520 n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6);
1521 if (n) {
1522 n[1].e = buffer;
1523 n[2].i = drawbuffer;
1524 n[3].f = value[0];
1525 if (buffer == GL_COLOR) {
1526 n[4].f = value[1];
1527 n[5].f = value[2];
1528 n[6].f = value[3];
1529 }
1530 else {
1531 n[4].f = 0.0F;
1532 n[5].f = 0.0F;
1533 n[6].f = 0.0F;
1534 }
1535 }
1536 if (ctx->ExecuteFlag) {
1537 CALL_ClearBufferfv(ctx->Exec, (buffer, drawbuffer, value));
1538 }
1539 }
1540
1541
1542 static void GLAPIENTRY
1543 save_ClearBufferfi(GLenum buffer, GLint drawbuffer,
1544 GLfloat depth, GLint stencil)
1545 {
1546 GET_CURRENT_CONTEXT(ctx);
1547 Node *n;
1548 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1549 n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4);
1550 if (n) {
1551 n[1].e = buffer;
1552 n[2].i = drawbuffer;
1553 n[3].f = depth;
1554 n[4].i = stencil;
1555 }
1556 if (ctx->ExecuteFlag) {
1557 CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));
1558 }
1559 }
1560
1561
1562 static void GLAPIENTRY
1563 save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
1564 {
1565 GET_CURRENT_CONTEXT(ctx);
1566 Node *n;
1567 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1568 n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4);
1569 if (n) {
1570 n[1].f = red;
1571 n[2].f = green;
1572 n[3].f = blue;
1573 n[4].f = alpha;
1574 }
1575 if (ctx->ExecuteFlag) {
1576 CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha));
1577 }
1578 }
1579
1580
1581 static void GLAPIENTRY
1582 save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1583 {
1584 GET_CURRENT_CONTEXT(ctx);
1585 Node *n;
1586 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1587 n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4);
1588 if (n) {
1589 n[1].f = red;
1590 n[2].f = green;
1591 n[3].f = blue;
1592 n[4].f = alpha;
1593 }
1594 if (ctx->ExecuteFlag) {
1595 CALL_ClearColor(ctx->Exec, (red, green, blue, alpha));
1596 }
1597 }
1598
1599
1600 static void GLAPIENTRY
1601 save_ClearDepth(GLclampd depth)
1602 {
1603 GET_CURRENT_CONTEXT(ctx);
1604 Node *n;
1605 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1606 n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1);
1607 if (n) {
1608 n[1].f = (GLfloat) depth;
1609 }
1610 if (ctx->ExecuteFlag) {
1611 CALL_ClearDepth(ctx->Exec, (depth));
1612 }
1613 }
1614
1615
1616 static void GLAPIENTRY
1617 save_ClearIndex(GLfloat c)
1618 {
1619 GET_CURRENT_CONTEXT(ctx);
1620 Node *n;
1621 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1622 n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1);
1623 if (n) {
1624 n[1].f = c;
1625 }
1626 if (ctx->ExecuteFlag) {
1627 CALL_ClearIndex(ctx->Exec, (c));
1628 }
1629 }
1630
1631
1632 static void GLAPIENTRY
1633 save_ClearStencil(GLint s)
1634 {
1635 GET_CURRENT_CONTEXT(ctx);
1636 Node *n;
1637 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1638 n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1);
1639 if (n) {
1640 n[1].i = s;
1641 }
1642 if (ctx->ExecuteFlag) {
1643 CALL_ClearStencil(ctx->Exec, (s));
1644 }
1645 }
1646
1647
1648 static void GLAPIENTRY
1649 save_ClipPlane(GLenum plane, const GLdouble * equ)
1650 {
1651 GET_CURRENT_CONTEXT(ctx);
1652 Node *n;
1653 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1654 n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5);
1655 if (n) {
1656 n[1].e = plane;
1657 n[2].f = (GLfloat) equ[0];
1658 n[3].f = (GLfloat) equ[1];
1659 n[4].f = (GLfloat) equ[2];
1660 n[5].f = (GLfloat) equ[3];
1661 }
1662 if (ctx->ExecuteFlag) {
1663 CALL_ClipPlane(ctx->Exec, (plane, equ));
1664 }
1665 }
1666
1667
1668
1669 static void GLAPIENTRY
1670 save_ColorMask(GLboolean red, GLboolean green,
1671 GLboolean blue, GLboolean alpha)
1672 {
1673 GET_CURRENT_CONTEXT(ctx);
1674 Node *n;
1675 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1676 n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4);
1677 if (n) {
1678 n[1].b = red;
1679 n[2].b = green;
1680 n[3].b = blue;
1681 n[4].b = alpha;
1682 }
1683 if (ctx->ExecuteFlag) {
1684 CALL_ColorMask(ctx->Exec, (red, green, blue, alpha));
1685 }
1686 }
1687
1688
1689 static void GLAPIENTRY
1690 save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green,
1691 GLboolean blue, GLboolean alpha)
1692 {
1693 GET_CURRENT_CONTEXT(ctx);
1694 Node *n;
1695 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1696 n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5);
1697 if (n) {
1698 n[1].ui = buf;
1699 n[2].b = red;
1700 n[3].b = green;
1701 n[4].b = blue;
1702 n[5].b = alpha;
1703 }
1704 if (ctx->ExecuteFlag) {
1705 /*CALL_ColorMaski(ctx->Exec, (buf, red, green, blue, alpha));*/
1706 }
1707 }
1708
1709
1710 static void GLAPIENTRY
1711 save_ColorMaterial(GLenum face, GLenum mode)
1712 {
1713 GET_CURRENT_CONTEXT(ctx);
1714 Node *n;
1715 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1716
1717 n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2);
1718 if (n) {
1719 n[1].e = face;
1720 n[2].e = mode;
1721 }
1722 if (ctx->ExecuteFlag) {
1723 CALL_ColorMaterial(ctx->Exec, (face, mode));
1724 }
1725 }
1726
1727
1728 static void GLAPIENTRY
1729 save_ColorTable(GLenum target, GLenum internalFormat,
1730 GLsizei width, GLenum format, GLenum type,
1731 const GLvoid * table)
1732 {
1733 GET_CURRENT_CONTEXT(ctx);
1734 if (_mesa_is_proxy_texture(target)) {
1735 /* execute immediately */
1736 CALL_ColorTable(ctx->Exec, (target, internalFormat, width,
1737 format, type, table));
1738 }
1739 else {
1740 Node *n;
1741 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1742 n = alloc_instruction(ctx, OPCODE_COLOR_TABLE, 6);
1743 if (n) {
1744 n[1].e = target;
1745 n[2].e = internalFormat;
1746 n[3].i = width;
1747 n[4].e = format;
1748 n[5].e = type;
1749 n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, table,
1750 &ctx->Unpack);
1751 }
1752 if (ctx->ExecuteFlag) {
1753 CALL_ColorTable(ctx->Exec, (target, internalFormat, width,
1754 format, type, table));
1755 }
1756 }
1757 }
1758
1759
1760
1761 static void GLAPIENTRY
1762 save_ColorTableParameterfv(GLenum target, GLenum pname,
1763 const GLfloat *params)
1764 {
1765 GET_CURRENT_CONTEXT(ctx);
1766 Node *n;
1767
1768 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1769
1770 n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6);
1771 if (n) {
1772 n[1].e = target;
1773 n[2].e = pname;
1774 n[3].f = params[0];
1775 if (pname == GL_COLOR_TABLE_SGI ||
1776 pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1777 pname == GL_TEXTURE_COLOR_TABLE_SGI) {
1778 n[4].f = params[1];
1779 n[5].f = params[2];
1780 n[6].f = params[3];
1781 }
1782 }
1783
1784 if (ctx->ExecuteFlag) {
1785 CALL_ColorTableParameterfv(ctx->Exec, (target, pname, params));
1786 }
1787 }
1788
1789
1790 static void GLAPIENTRY
1791 save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
1792 {
1793 GET_CURRENT_CONTEXT(ctx);
1794 Node *n;
1795
1796 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1797
1798 n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6);
1799 if (n) {
1800 n[1].e = target;
1801 n[2].e = pname;
1802 n[3].i = params[0];
1803 if (pname == GL_COLOR_TABLE_SGI ||
1804 pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1805 pname == GL_TEXTURE_COLOR_TABLE_SGI) {
1806 n[4].i = params[1];
1807 n[5].i = params[2];
1808 n[6].i = params[3];
1809 }
1810 }
1811
1812 if (ctx->ExecuteFlag) {
1813 CALL_ColorTableParameteriv(ctx->Exec, (target, pname, params));
1814 }
1815 }
1816
1817
1818
1819 static void GLAPIENTRY
1820 save_ColorSubTable(GLenum target, GLsizei start, GLsizei count,
1821 GLenum format, GLenum type, const GLvoid * table)
1822 {
1823 GET_CURRENT_CONTEXT(ctx);
1824 Node *n;
1825 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1826 n = alloc_instruction(ctx, OPCODE_COLOR_SUB_TABLE, 6);
1827 if (n) {
1828 n[1].e = target;
1829 n[2].i = start;
1830 n[3].i = count;
1831 n[4].e = format;
1832 n[5].e = type;
1833 n[6].data = unpack_image(ctx, 1, count, 1, 1, format, type, table,
1834 &ctx->Unpack);
1835 }
1836 if (ctx->ExecuteFlag) {
1837 CALL_ColorSubTable(ctx->Exec,
1838 (target, start, count, format, type, table));
1839 }
1840 }
1841
1842
1843 static void GLAPIENTRY
1844 save_CopyColorSubTable(GLenum target, GLsizei start,
1845 GLint x, GLint y, GLsizei width)
1846 {
1847 GET_CURRENT_CONTEXT(ctx);
1848 Node *n;
1849
1850 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1851 n = alloc_instruction(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5);
1852 if (n) {
1853 n[1].e = target;
1854 n[2].i = start;
1855 n[3].i = x;
1856 n[4].i = y;
1857 n[5].i = width;
1858 }
1859 if (ctx->ExecuteFlag) {
1860 CALL_CopyColorSubTable(ctx->Exec, (target, start, x, y, width));
1861 }
1862 }
1863
1864
1865 static void GLAPIENTRY
1866 save_CopyColorTable(GLenum target, GLenum internalformat,
1867 GLint x, GLint y, GLsizei width)
1868 {
1869 GET_CURRENT_CONTEXT(ctx);
1870 Node *n;
1871
1872 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1873 n = alloc_instruction(ctx, OPCODE_COPY_COLOR_TABLE, 5);
1874 if (n) {
1875 n[1].e = target;
1876 n[2].e = internalformat;
1877 n[3].i = x;
1878 n[4].i = y;
1879 n[5].i = width;
1880 }
1881 if (ctx->ExecuteFlag) {
1882 CALL_CopyColorTable(ctx->Exec, (target, internalformat, x, y, width));
1883 }
1884 }
1885
1886
1887 static void GLAPIENTRY
1888 save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
1889 GLenum format, GLenum type, const GLvoid * filter)
1890 {
1891 GET_CURRENT_CONTEXT(ctx);
1892 Node *n;
1893
1894 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1895
1896 n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6);
1897 if (n) {
1898 n[1].e = target;
1899 n[2].e = internalFormat;
1900 n[3].i = width;
1901 n[4].e = format;
1902 n[5].e = type;
1903 n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, filter,
1904 &ctx->Unpack);
1905 }
1906 if (ctx->ExecuteFlag) {
1907 CALL_ConvolutionFilter1D(ctx->Exec, (target, internalFormat, width,
1908 format, type, filter));
1909 }
1910 }
1911
1912
1913 static void GLAPIENTRY
1914 save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
1915 GLsizei width, GLsizei height, GLenum format,
1916 GLenum type, const GLvoid * filter)
1917 {
1918 GET_CURRENT_CONTEXT(ctx);
1919 Node *n;
1920
1921 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1922
1923 n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7);
1924 if (n) {
1925 n[1].e = target;
1926 n[2].e = internalFormat;
1927 n[3].i = width;
1928 n[4].i = height;
1929 n[5].e = format;
1930 n[6].e = type;
1931 n[7].data = unpack_image(ctx, 2, width, height, 1, format, type, filter,
1932 &ctx->Unpack);
1933 }
1934 if (ctx->ExecuteFlag) {
1935 CALL_ConvolutionFilter2D(ctx->Exec,
1936 (target, internalFormat, width, height, format,
1937 type, filter));
1938 }
1939 }
1940
1941
1942 static void GLAPIENTRY
1943 save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
1944 {
1945 GET_CURRENT_CONTEXT(ctx);
1946 Node *n;
1947 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1948 n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3);
1949 if (n) {
1950 n[1].e = target;
1951 n[2].e = pname;
1952 n[3].i = param;
1953 }
1954 if (ctx->ExecuteFlag) {
1955 CALL_ConvolutionParameteri(ctx->Exec, (target, pname, param));
1956 }
1957 }
1958
1959
1960 static void GLAPIENTRY
1961 save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
1962 {
1963 GET_CURRENT_CONTEXT(ctx);
1964 Node *n;
1965 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1966 n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6);
1967 if (n) {
1968 n[1].e = target;
1969 n[2].e = pname;
1970 n[3].i = params[0];
1971 if (pname == GL_CONVOLUTION_BORDER_COLOR ||
1972 pname == GL_CONVOLUTION_FILTER_SCALE ||
1973 pname == GL_CONVOLUTION_FILTER_BIAS) {
1974 n[4].i = params[1];
1975 n[5].i = params[2];
1976 n[6].i = params[3];
1977 }
1978 else {
1979 n[4].i = n[5].i = n[6].i = 0;
1980 }
1981 }
1982 if (ctx->ExecuteFlag) {
1983 CALL_ConvolutionParameteriv(ctx->Exec, (target, pname, params));
1984 }
1985 }
1986
1987
1988 static void GLAPIENTRY
1989 save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
1990 {
1991 GET_CURRENT_CONTEXT(ctx);
1992 Node *n;
1993 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1994 n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3);
1995 if (n) {
1996 n[1].e = target;
1997 n[2].e = pname;
1998 n[3].f = param;
1999 }
2000 if (ctx->ExecuteFlag) {
2001 CALL_ConvolutionParameterf(ctx->Exec, (target, pname, param));
2002 }
2003 }
2004
2005
2006 static void GLAPIENTRY
2007 save_ConvolutionParameterfv(GLenum target, GLenum pname,
2008 const GLfloat *params)
2009 {
2010 GET_CURRENT_CONTEXT(ctx);
2011 Node *n;
2012 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2013 n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6);
2014 if (n) {
2015 n[1].e = target;
2016 n[2].e = pname;
2017 n[3].f = params[0];
2018 if (pname == GL_CONVOLUTION_BORDER_COLOR ||
2019 pname == GL_CONVOLUTION_FILTER_SCALE ||
2020 pname == GL_CONVOLUTION_FILTER_BIAS) {
2021 n[4].f = params[1];
2022 n[5].f = params[2];
2023 n[6].f = params[3];
2024 }
2025 else {
2026 n[4].f = n[5].f = n[6].f = 0.0F;
2027 }
2028 }
2029 if (ctx->ExecuteFlag) {
2030 CALL_ConvolutionParameterfv(ctx->Exec, (target, pname, params));
2031 }
2032 }
2033
2034
2035 static void GLAPIENTRY
2036 save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
2037 {
2038 GET_CURRENT_CONTEXT(ctx);
2039 Node *n;
2040 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2041 n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5);
2042 if (n) {
2043 n[1].i = x;
2044 n[2].i = y;
2045 n[3].i = (GLint) width;
2046 n[4].i = (GLint) height;
2047 n[5].e = type;
2048 }
2049 if (ctx->ExecuteFlag) {
2050 CALL_CopyPixels(ctx->Exec, (x, y, width, height, type));
2051 }
2052 }
2053
2054
2055
2056 static void GLAPIENTRY
2057 save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat,
2058 GLint x, GLint y, GLsizei width, GLint border)
2059 {
2060 GET_CURRENT_CONTEXT(ctx);
2061 Node *n;
2062 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2063 n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7);
2064 if (n) {
2065 n[1].e = target;
2066 n[2].i = level;
2067 n[3].e = internalformat;
2068 n[4].i = x;
2069 n[5].i = y;
2070 n[6].i = width;
2071 n[7].i = border;
2072 }
2073 if (ctx->ExecuteFlag) {
2074 CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat,
2075 x, y, width, border));
2076 }
2077 }
2078
2079
2080 static void GLAPIENTRY
2081 save_CopyTexImage2D(GLenum target, GLint level,
2082 GLenum internalformat,
2083 GLint x, GLint y, GLsizei width,
2084 GLsizei height, GLint border)
2085 {
2086 GET_CURRENT_CONTEXT(ctx);
2087 Node *n;
2088 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2089 n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8);
2090 if (n) {
2091 n[1].e = target;
2092 n[2].i = level;
2093 n[3].e = internalformat;
2094 n[4].i = x;
2095 n[5].i = y;
2096 n[6].i = width;
2097 n[7].i = height;
2098 n[8].i = border;
2099 }
2100 if (ctx->ExecuteFlag) {
2101 CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat,
2102 x, y, width, height, border));
2103 }
2104 }
2105
2106
2107
2108 static void GLAPIENTRY
2109 save_CopyTexSubImage1D(GLenum target, GLint level,
2110 GLint xoffset, GLint x, GLint y, GLsizei width)
2111 {
2112 GET_CURRENT_CONTEXT(ctx);
2113 Node *n;
2114 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2115 n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6);
2116 if (n) {
2117 n[1].e = target;
2118 n[2].i = level;
2119 n[3].i = xoffset;
2120 n[4].i = x;
2121 n[5].i = y;
2122 n[6].i = width;
2123 }
2124 if (ctx->ExecuteFlag) {
2125 CALL_CopyTexSubImage1D(ctx->Exec,
2126 (target, level, xoffset, x, y, width));
2127 }
2128 }
2129
2130
2131 static void GLAPIENTRY
2132 save_CopyTexSubImage2D(GLenum target, GLint level,
2133 GLint xoffset, GLint yoffset,
2134 GLint x, GLint y, GLsizei width, GLint height)
2135 {
2136 GET_CURRENT_CONTEXT(ctx);
2137 Node *n;
2138 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2139 n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8);
2140 if (n) {
2141 n[1].e = target;
2142 n[2].i = level;
2143 n[3].i = xoffset;
2144 n[4].i = yoffset;
2145 n[5].i = x;
2146 n[6].i = y;
2147 n[7].i = width;
2148 n[8].i = height;
2149 }
2150 if (ctx->ExecuteFlag) {
2151 CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
2152 x, y, width, height));
2153 }
2154 }
2155
2156
2157 static void GLAPIENTRY
2158 save_CopyTexSubImage3D(GLenum target, GLint level,
2159 GLint xoffset, GLint yoffset, GLint zoffset,
2160 GLint x, GLint y, GLsizei width, GLint height)
2161 {
2162 GET_CURRENT_CONTEXT(ctx);
2163 Node *n;
2164 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2165 n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9);
2166 if (n) {
2167 n[1].e = target;
2168 n[2].i = level;
2169 n[3].i = xoffset;
2170 n[4].i = yoffset;
2171 n[5].i = zoffset;
2172 n[6].i = x;
2173 n[7].i = y;
2174 n[8].i = width;
2175 n[9].i = height;
2176 }
2177 if (ctx->ExecuteFlag) {
2178 CALL_CopyTexSubImage3D(ctx->Exec, (target, level,
2179 xoffset, yoffset, zoffset,
2180 x, y, width, height));
2181 }
2182 }
2183
2184
2185 static void GLAPIENTRY
2186 save_CullFace(GLenum mode)
2187 {
2188 GET_CURRENT_CONTEXT(ctx);
2189 Node *n;
2190 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2191 n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1);
2192 if (n) {
2193 n[1].e = mode;
2194 }
2195 if (ctx->ExecuteFlag) {
2196 CALL_CullFace(ctx->Exec, (mode));
2197 }
2198 }
2199
2200
2201 static void GLAPIENTRY
2202 save_DepthFunc(GLenum func)
2203 {
2204 GET_CURRENT_CONTEXT(ctx);
2205 Node *n;
2206 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2207 n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1);
2208 if (n) {
2209 n[1].e = func;
2210 }
2211 if (ctx->ExecuteFlag) {
2212 CALL_DepthFunc(ctx->Exec, (func));
2213 }
2214 }
2215
2216
2217 static void GLAPIENTRY
2218 save_DepthMask(GLboolean mask)
2219 {
2220 GET_CURRENT_CONTEXT(ctx);
2221 Node *n;
2222 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2223 n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1);
2224 if (n) {
2225 n[1].b = mask;
2226 }
2227 if (ctx->ExecuteFlag) {
2228 CALL_DepthMask(ctx->Exec, (mask));
2229 }
2230 }
2231
2232
2233 static void GLAPIENTRY
2234 save_DepthRange(GLclampd nearval, GLclampd farval)
2235 {
2236 GET_CURRENT_CONTEXT(ctx);
2237 Node *n;
2238 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2239 n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2);
2240 if (n) {
2241 n[1].f = (GLfloat) nearval;
2242 n[2].f = (GLfloat) farval;
2243 }
2244 if (ctx->ExecuteFlag) {
2245 CALL_DepthRange(ctx->Exec, (nearval, farval));
2246 }
2247 }
2248
2249
2250 static void GLAPIENTRY
2251 save_Disable(GLenum cap)
2252 {
2253 GET_CURRENT_CONTEXT(ctx);
2254 Node *n;
2255 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2256 n = alloc_instruction(ctx, OPCODE_DISABLE, 1);
2257 if (n) {
2258 n[1].e = cap;
2259 }
2260 if (ctx->ExecuteFlag) {
2261 CALL_Disable(ctx->Exec, (cap));
2262 }
2263 }
2264
2265
2266 static void GLAPIENTRY
2267 save_DisableIndexed(GLuint index, GLenum cap)
2268 {
2269 GET_CURRENT_CONTEXT(ctx);
2270 Node *n;
2271 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2272 n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2);
2273 if (n) {
2274 n[1].ui = index;
2275 n[2].e = cap;
2276 }
2277 if (ctx->ExecuteFlag) {
2278 CALL_Disablei(ctx->Exec, (index, cap));
2279 }
2280 }
2281
2282
2283 static void GLAPIENTRY
2284 save_DrawBuffer(GLenum mode)
2285 {
2286 GET_CURRENT_CONTEXT(ctx);
2287 Node *n;
2288 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2289 n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1);
2290 if (n) {
2291 n[1].e = mode;
2292 }
2293 if (ctx->ExecuteFlag) {
2294 CALL_DrawBuffer(ctx->Exec, (mode));
2295 }
2296 }
2297
2298
2299 static void GLAPIENTRY
2300 save_DrawPixels(GLsizei width, GLsizei height,
2301 GLenum format, GLenum type, const GLvoid * pixels)
2302 {
2303 GET_CURRENT_CONTEXT(ctx);
2304 Node *n;
2305
2306 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2307
2308 n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 5);
2309 if (n) {
2310 n[1].i = width;
2311 n[2].i = height;
2312 n[3].e = format;
2313 n[4].e = type;
2314 n[5].data = unpack_image(ctx, 2, width, height, 1, format, type,
2315 pixels, &ctx->Unpack);
2316 }
2317 if (ctx->ExecuteFlag) {
2318 CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels));
2319 }
2320 }
2321
2322
2323
2324 static void GLAPIENTRY
2325 save_Enable(GLenum cap)
2326 {
2327 GET_CURRENT_CONTEXT(ctx);
2328 Node *n;
2329 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2330 n = alloc_instruction(ctx, OPCODE_ENABLE, 1);
2331 if (n) {
2332 n[1].e = cap;
2333 }
2334 if (ctx->ExecuteFlag) {
2335 CALL_Enable(ctx->Exec, (cap));
2336 }
2337 }
2338
2339
2340
2341 static void GLAPIENTRY
2342 save_EnableIndexed(GLuint index, GLenum cap)
2343 {
2344 GET_CURRENT_CONTEXT(ctx);
2345 Node *n;
2346 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2347 n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2);
2348 if (n) {
2349 n[1].ui = index;
2350 n[2].e = cap;
2351 }
2352 if (ctx->ExecuteFlag) {
2353 CALL_Enablei(ctx->Exec, (index, cap));
2354 }
2355 }
2356
2357
2358
2359 static void GLAPIENTRY
2360 save_EvalMesh1(GLenum mode, GLint i1, GLint i2)
2361 {
2362 GET_CURRENT_CONTEXT(ctx);
2363 Node *n;
2364 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2365 n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3);
2366 if (n) {
2367 n[1].e = mode;
2368 n[2].i = i1;
2369 n[3].i = i2;
2370 }
2371 if (ctx->ExecuteFlag) {
2372 CALL_EvalMesh1(ctx->Exec, (mode, i1, i2));
2373 }
2374 }
2375
2376
2377 static void GLAPIENTRY
2378 save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
2379 {
2380 GET_CURRENT_CONTEXT(ctx);
2381 Node *n;
2382 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2383 n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5);
2384 if (n) {
2385 n[1].e = mode;
2386 n[2].i = i1;
2387 n[3].i = i2;
2388 n[4].i = j1;
2389 n[5].i = j2;
2390 }
2391 if (ctx->ExecuteFlag) {
2392 CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2));
2393 }
2394 }
2395
2396
2397
2398
2399 static void GLAPIENTRY
2400 save_Fogfv(GLenum pname, const GLfloat *params)
2401 {
2402 GET_CURRENT_CONTEXT(ctx);
2403 Node *n;
2404 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2405 n = alloc_instruction(ctx, OPCODE_FOG, 5);
2406 if (n) {
2407 n[1].e = pname;
2408 n[2].f = params[0];
2409 n[3].f = params[1];
2410 n[4].f = params[2];
2411 n[5].f = params[3];
2412 }
2413 if (ctx->ExecuteFlag) {
2414 CALL_Fogfv(ctx->Exec, (pname, params));
2415 }
2416 }
2417
2418
2419 static void GLAPIENTRY
2420 save_Fogf(GLenum pname, GLfloat param)
2421 {
2422 GLfloat parray[4];
2423 parray[0] = param;
2424 parray[1] = parray[2] = parray[3] = 0.0F;
2425 save_Fogfv(pname, parray);
2426 }
2427
2428
2429 static void GLAPIENTRY
2430 save_Fogiv(GLenum pname, const GLint *params)
2431 {
2432 GLfloat p[4];
2433 switch (pname) {
2434 case GL_FOG_MODE:
2435 case GL_FOG_DENSITY:
2436 case GL_FOG_START:
2437 case GL_FOG_END:
2438 case GL_FOG_INDEX:
2439 p[0] = (GLfloat) *params;
2440 p[1] = 0.0f;
2441 p[2] = 0.0f;
2442 p[3] = 0.0f;
2443 break;
2444 case GL_FOG_COLOR:
2445 p[0] = INT_TO_FLOAT(params[0]);
2446 p[1] = INT_TO_FLOAT(params[1]);
2447 p[2] = INT_TO_FLOAT(params[2]);
2448 p[3] = INT_TO_FLOAT(params[3]);
2449 break;
2450 default:
2451 /* Error will be caught later in gl_Fogfv */
2452 ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F);
2453 }
2454 save_Fogfv(pname, p);
2455 }
2456
2457
2458 static void GLAPIENTRY
2459 save_Fogi(GLenum pname, GLint param)
2460 {
2461 GLint parray[4];
2462 parray[0] = param;
2463 parray[1] = parray[2] = parray[3] = 0;
2464 save_Fogiv(pname, parray);
2465 }
2466
2467
2468 static void GLAPIENTRY
2469 save_FrontFace(GLenum mode)
2470 {
2471 GET_CURRENT_CONTEXT(ctx);
2472 Node *n;
2473 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2474 n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1);
2475 if (n) {
2476 n[1].e = mode;
2477 }
2478 if (ctx->ExecuteFlag) {
2479 CALL_FrontFace(ctx->Exec, (mode));
2480 }
2481 }
2482
2483
2484 static void GLAPIENTRY
2485 save_Frustum(GLdouble left, GLdouble right,
2486 GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
2487 {
2488 GET_CURRENT_CONTEXT(ctx);
2489 Node *n;
2490 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2491 n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6);
2492 if (n) {
2493 n[1].f = (GLfloat) left;
2494 n[2].f = (GLfloat) right;
2495 n[3].f = (GLfloat) bottom;
2496 n[4].f = (GLfloat) top;
2497 n[5].f = (GLfloat) nearval;
2498 n[6].f = (GLfloat) farval;
2499 }
2500 if (ctx->ExecuteFlag) {
2501 CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval));
2502 }
2503 }
2504
2505
2506 static void GLAPIENTRY
2507 save_Hint(GLenum target, GLenum mode)
2508 {
2509 GET_CURRENT_CONTEXT(ctx);
2510 Node *n;
2511 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2512 n = alloc_instruction(ctx, OPCODE_HINT, 2);
2513 if (n) {
2514 n[1].e = target;
2515 n[2].e = mode;
2516 }
2517 if (ctx->ExecuteFlag) {
2518 CALL_Hint(ctx->Exec, (target, mode));
2519 }
2520 }
2521
2522
2523 static void GLAPIENTRY
2524 save_Histogram(GLenum target, GLsizei width, GLenum internalFormat,
2525 GLboolean sink)
2526 {
2527 GET_CURRENT_CONTEXT(ctx);
2528 Node *n;
2529
2530 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2531 n = alloc_instruction(ctx, OPCODE_HISTOGRAM, 4);
2532 if (n) {
2533 n[1].e = target;
2534 n[2].i = width;
2535 n[3].e = internalFormat;
2536 n[4].b = sink;
2537 }
2538 if (ctx->ExecuteFlag) {
2539 CALL_Histogram(ctx->Exec, (target, width, internalFormat, sink));
2540 }
2541 }
2542
2543
2544 static void GLAPIENTRY
2545 save_IndexMask(GLuint mask)
2546 {
2547 GET_CURRENT_CONTEXT(ctx);
2548 Node *n;
2549 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2550 n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1);
2551 if (n) {
2552 n[1].ui = mask;
2553 }
2554 if (ctx->ExecuteFlag) {
2555 CALL_IndexMask(ctx->Exec, (mask));
2556 }
2557 }
2558
2559
2560 static void GLAPIENTRY
2561 save_InitNames(void)
2562 {
2563 GET_CURRENT_CONTEXT(ctx);
2564 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2565 (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0);
2566 if (ctx->ExecuteFlag) {
2567 CALL_InitNames(ctx->Exec, ());
2568 }
2569 }
2570
2571
2572 static void GLAPIENTRY
2573 save_Lightfv(GLenum light, GLenum pname, const GLfloat *params)
2574 {
2575 GET_CURRENT_CONTEXT(ctx);
2576 Node *n;
2577 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2578 n = alloc_instruction(ctx, OPCODE_LIGHT, 6);
2579 if (n) {
2580 GLint i, nParams;
2581 n[1].e = light;
2582 n[2].e = pname;
2583 switch (pname) {
2584 case GL_AMBIENT:
2585 nParams = 4;
2586 break;
2587 case GL_DIFFUSE:
2588 nParams = 4;
2589 break;
2590 case GL_SPECULAR:
2591 nParams = 4;
2592 break;
2593 case GL_POSITION:
2594 nParams = 4;
2595 break;
2596 case GL_SPOT_DIRECTION:
2597 nParams = 3;
2598 break;
2599 case GL_SPOT_EXPONENT:
2600 nParams = 1;
2601 break;
2602 case GL_SPOT_CUTOFF:
2603 nParams = 1;
2604 break;
2605 case GL_CONSTANT_ATTENUATION:
2606 nParams = 1;
2607 break;
2608 case GL_LINEAR_ATTENUATION:
2609 nParams = 1;
2610 break;
2611 case GL_QUADRATIC_ATTENUATION:
2612 nParams = 1;
2613 break;
2614 default:
2615 nParams = 0;
2616 }
2617 for (i = 0; i < nParams; i++) {
2618 n[3 + i].f = params[i];
2619 }
2620 }
2621 if (ctx->ExecuteFlag) {
2622 CALL_Lightfv(ctx->Exec, (light, pname, params));
2623 }
2624 }
2625
2626
2627 static void GLAPIENTRY
2628 save_Lightf(GLenum light, GLenum pname, GLfloat param)
2629 {
2630 GLfloat parray[4];
2631 parray[0] = param;
2632 parray[1] = parray[2] = parray[3] = 0.0F;
2633 save_Lightfv(light, pname, parray);
2634 }
2635
2636
2637 static void GLAPIENTRY
2638 save_Lightiv(GLenum light, GLenum pname, const GLint *params)
2639 {
2640 GLfloat fparam[4];
2641 switch (pname) {
2642 case GL_AMBIENT:
2643 case GL_DIFFUSE:
2644 case GL_SPECULAR:
2645 fparam[0] = INT_TO_FLOAT(params[0]);
2646 fparam[1] = INT_TO_FLOAT(params[1]);
2647 fparam[2] = INT_TO_FLOAT(params[2]);
2648 fparam[3] = INT_TO_FLOAT(params[3]);
2649 break;
2650 case GL_POSITION:
2651 fparam[0] = (GLfloat) params[0];
2652 fparam[1] = (GLfloat) params[1];
2653 fparam[2] = (GLfloat) params[2];
2654 fparam[3] = (GLfloat) params[3];
2655 break;
2656 case GL_SPOT_DIRECTION:
2657 fparam[0] = (GLfloat) params[0];
2658 fparam[1] = (GLfloat) params[1];
2659 fparam[2] = (GLfloat) params[2];
2660 break;
2661 case GL_SPOT_EXPONENT:
2662 case GL_SPOT_CUTOFF:
2663 case GL_CONSTANT_ATTENUATION:
2664 case GL_LINEAR_ATTENUATION:
2665 case GL_QUADRATIC_ATTENUATION:
2666 fparam[0] = (GLfloat) params[0];
2667 break;
2668 default:
2669 /* error will be caught later in gl_Lightfv */
2670 ;
2671 }
2672 save_Lightfv(light, pname, fparam);
2673 }
2674
2675
2676 static void GLAPIENTRY
2677 save_Lighti(GLenum light, GLenum pname, GLint param)
2678 {
2679 GLint parray[4];
2680 parray[0] = param;
2681 parray[1] = parray[2] = parray[3] = 0;
2682 save_Lightiv(light, pname, parray);
2683 }
2684
2685
2686 static void GLAPIENTRY
2687 save_LightModelfv(GLenum pname, const GLfloat *params)
2688 {
2689 GET_CURRENT_CONTEXT(ctx);
2690 Node *n;
2691 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2692 n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5);
2693 if (n) {
2694 n[1].e = pname;
2695 n[2].f = params[0];
2696 n[3].f = params[1];
2697 n[4].f = params[2];
2698 n[5].f = params[3];
2699 }
2700 if (ctx->ExecuteFlag) {
2701 CALL_LightModelfv(ctx->Exec, (pname, params));
2702 }
2703 }
2704
2705
2706 static void GLAPIENTRY
2707 save_LightModelf(GLenum pname, GLfloat param)
2708 {
2709 GLfloat parray[4];
2710 parray[0] = param;
2711 parray[1] = parray[2] = parray[3] = 0.0F;
2712 save_LightModelfv(pname, parray);
2713 }
2714
2715
2716 static void GLAPIENTRY
2717 save_LightModeliv(GLenum pname, const GLint *params)
2718 {
2719 GLfloat fparam[4];
2720 switch (pname) {
2721 case GL_LIGHT_MODEL_AMBIENT:
2722 fparam[0] = INT_TO_FLOAT(params[0]);
2723 fparam[1] = INT_TO_FLOAT(params[1]);
2724 fparam[2] = INT_TO_FLOAT(params[2]);
2725 fparam[3] = INT_TO_FLOAT(params[3]);
2726 break;
2727 case GL_LIGHT_MODEL_LOCAL_VIEWER:
2728 case GL_LIGHT_MODEL_TWO_SIDE:
2729 case GL_LIGHT_MODEL_COLOR_CONTROL:
2730 fparam[0] = (GLfloat) params[0];
2731 fparam[1] = 0.0F;
2732 fparam[2] = 0.0F;
2733 fparam[3] = 0.0F;
2734 break;
2735 default:
2736 /* Error will be caught later in gl_LightModelfv */
2737 ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F);
2738 }
2739 save_LightModelfv(pname, fparam);
2740 }
2741
2742
2743 static void GLAPIENTRY
2744 save_LightModeli(GLenum pname, GLint param)
2745 {
2746 GLint parray[4];
2747 parray[0] = param;
2748 parray[1] = parray[2] = parray[3] = 0;
2749 save_LightModeliv(pname, parray);
2750 }
2751
2752
2753 static void GLAPIENTRY
2754 save_LineStipple(GLint factor, GLushort pattern)
2755 {
2756 GET_CURRENT_CONTEXT(ctx);
2757 Node *n;
2758 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2759 n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2);
2760 if (n) {
2761 n[1].i = factor;
2762 n[2].us = pattern;
2763 }
2764 if (ctx->ExecuteFlag) {
2765 CALL_LineStipple(ctx->Exec, (factor, pattern));
2766 }
2767 }
2768
2769
2770 static void GLAPIENTRY
2771 save_LineWidth(GLfloat width)
2772 {
2773 GET_CURRENT_CONTEXT(ctx);
2774 Node *n;
2775 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2776 n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1);
2777 if (n) {
2778 n[1].f = width;
2779 }
2780 if (ctx->ExecuteFlag) {
2781 CALL_LineWidth(ctx->Exec, (width));
2782 }
2783 }
2784
2785
2786 static void GLAPIENTRY
2787 save_ListBase(GLuint base)
2788 {
2789 GET_CURRENT_CONTEXT(ctx);
2790 Node *n;
2791 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2792 n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1);
2793 if (n) {
2794 n[1].ui = base;
2795 }
2796 if (ctx->ExecuteFlag) {
2797 CALL_ListBase(ctx->Exec, (base));
2798 }
2799 }
2800
2801
2802 static void GLAPIENTRY
2803 save_LoadIdentity(void)
2804 {
2805 GET_CURRENT_CONTEXT(ctx);
2806 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2807 (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0);
2808 if (ctx->ExecuteFlag) {
2809 CALL_LoadIdentity(ctx->Exec, ());
2810 }
2811 }
2812
2813
2814 static void GLAPIENTRY
2815 save_LoadMatrixf(const GLfloat * m)
2816 {
2817 GET_CURRENT_CONTEXT(ctx);
2818 Node *n;
2819 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2820 n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16);
2821 if (n) {
2822 GLuint i;
2823 for (i = 0; i < 16; i++) {
2824 n[1 + i].f = m[i];
2825 }
2826 }
2827 if (ctx->ExecuteFlag) {
2828 CALL_LoadMatrixf(ctx->Exec, (m));
2829 }
2830 }
2831
2832
2833 static void GLAPIENTRY
2834 save_LoadMatrixd(const GLdouble * m)
2835 {
2836 GLfloat f[16];
2837 GLint i;
2838 for (i = 0; i < 16; i++) {
2839 f[i] = (GLfloat) m[i];
2840 }
2841 save_LoadMatrixf(f);
2842 }
2843
2844
2845 static void GLAPIENTRY
2846 save_LoadName(GLuint name)
2847 {
2848 GET_CURRENT_CONTEXT(ctx);
2849 Node *n;
2850 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2851 n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1);
2852 if (n) {
2853 n[1].ui = name;
2854 }
2855 if (ctx->ExecuteFlag) {
2856 CALL_LoadName(ctx->Exec, (name));
2857 }
2858 }
2859
2860
2861 static void GLAPIENTRY
2862 save_LogicOp(GLenum opcode)
2863 {
2864 GET_CURRENT_CONTEXT(ctx);
2865 Node *n;
2866 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2867 n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1);
2868 if (n) {
2869 n[1].e = opcode;
2870 }
2871 if (ctx->ExecuteFlag) {
2872 CALL_LogicOp(ctx->Exec, (opcode));
2873 }
2874 }
2875
2876
2877 static void GLAPIENTRY
2878 save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
2879 GLint order, const GLdouble * points)
2880 {
2881 GET_CURRENT_CONTEXT(ctx);
2882 Node *n;
2883 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2884 n = alloc_instruction(ctx, OPCODE_MAP1, 6);
2885 if (n) {
2886 GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points);
2887 n[1].e = target;
2888 n[2].f = (GLfloat) u1;
2889 n[3].f = (GLfloat) u2;
2890 n[4].i = _mesa_evaluator_components(target); /* stride */
2891 n[5].i = order;
2892 n[6].data = (void *) pnts;
2893 }
2894 if (ctx->ExecuteFlag) {
2895 CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points));
2896 }
2897 }
2898
2899 static void GLAPIENTRY
2900 save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
2901 GLint order, const GLfloat * points)
2902 {
2903 GET_CURRENT_CONTEXT(ctx);
2904 Node *n;
2905 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2906 n = alloc_instruction(ctx, OPCODE_MAP1, 6);
2907 if (n) {
2908 GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points);
2909 n[1].e = target;
2910 n[2].f = u1;
2911 n[3].f = u2;
2912 n[4].i = _mesa_evaluator_components(target); /* stride */
2913 n[5].i = order;
2914 n[6].data = (void *) pnts;
2915 }
2916 if (ctx->ExecuteFlag) {
2917 CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points));
2918 }
2919 }
2920
2921
2922 static void GLAPIENTRY
2923 save_Map2d(GLenum target,
2924 GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
2925 GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
2926 const GLdouble * points)
2927 {
2928 GET_CURRENT_CONTEXT(ctx);
2929 Node *n;
2930 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2931 n = alloc_instruction(ctx, OPCODE_MAP2, 10);
2932 if (n) {
2933 GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder,
2934 vstride, vorder, points);
2935 n[1].e = target;
2936 n[2].f = (GLfloat) u1;
2937 n[3].f = (GLfloat) u2;
2938 n[4].f = (GLfloat) v1;
2939 n[5].f = (GLfloat) v2;
2940 /* XXX verify these strides are correct */
2941 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */
2942 n[7].i = _mesa_evaluator_components(target); /*vstride */
2943 n[8].i = uorder;
2944 n[9].i = vorder;
2945 n[10].data = (void *) pnts;
2946 }
2947 if (ctx->ExecuteFlag) {
2948 CALL_Map2d(ctx->Exec, (target,
2949 u1, u2, ustride, uorder,
2950 v1, v2, vstride, vorder, points));
2951 }
2952 }
2953
2954
2955 static void GLAPIENTRY
2956 save_Map2f(GLenum target,
2957 GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
2958 GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
2959 const GLfloat * points)
2960 {
2961 GET_CURRENT_CONTEXT(ctx);
2962 Node *n;
2963 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2964 n = alloc_instruction(ctx, OPCODE_MAP2, 10);
2965 if (n) {
2966 GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder,
2967 vstride, vorder, points);
2968 n[1].e = target;
2969 n[2].f = u1;
2970 n[3].f = u2;
2971 n[4].f = v1;
2972 n[5].f = v2;
2973 /* XXX verify these strides are correct */
2974 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */
2975 n[7].i = _mesa_evaluator_components(target); /*vstride */
2976 n[8].i = uorder;
2977 n[9].i = vorder;
2978 n[10].data = (void *) pnts;
2979 }
2980 if (ctx->ExecuteFlag) {
2981 CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
2982 v1, v2, vstride, vorder, points));
2983 }
2984 }
2985
2986
2987 static void GLAPIENTRY
2988 save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2)
2989 {
2990 GET_CURRENT_CONTEXT(ctx);
2991 Node *n;
2992 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2993 n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3);
2994 if (n) {
2995 n[1].i = un;
2996 n[2].f = u1;
2997 n[3].f = u2;
2998 }
2999 if (ctx->ExecuteFlag) {
3000 CALL_MapGrid1f(ctx->Exec, (un, u1, u2));
3001 }
3002 }
3003
3004
3005 static void GLAPIENTRY
3006 save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2)
3007 {
3008 save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
3009 }
3010
3011
3012 static void GLAPIENTRY
3013 save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2,
3014 GLint vn, GLfloat v1, GLfloat v2)
3015 {
3016 GET_CURRENT_CONTEXT(ctx);
3017 Node *n;
3018 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3019 n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6);
3020 if (n) {
3021 n[1].i = un;
3022 n[2].f = u1;
3023 n[3].f = u2;
3024 n[4].i = vn;
3025 n[5].f = v1;
3026 n[6].f = v2;
3027 }
3028 if (ctx->ExecuteFlag) {
3029 CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2));
3030 }
3031 }
3032
3033
3034
3035 static void GLAPIENTRY
3036 save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2,
3037 GLint vn, GLdouble v1, GLdouble v2)
3038 {
3039 save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2,
3040 vn, (GLfloat) v1, (GLfloat) v2);
3041 }
3042
3043
3044 static void GLAPIENTRY
3045 save_MatrixMode(GLenum mode)
3046 {
3047 GET_CURRENT_CONTEXT(ctx);
3048 Node *n;
3049 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3050 n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1);
3051 if (n) {
3052 n[1].e = mode;
3053 }
3054 if (ctx->ExecuteFlag) {
3055 CALL_MatrixMode(ctx->Exec, (mode));
3056 }
3057 }
3058
3059
3060 static void GLAPIENTRY
3061 save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
3062 {
3063 GET_CURRENT_CONTEXT(ctx);
3064 Node *n;
3065
3066 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3067 n = alloc_instruction(ctx, OPCODE_MIN_MAX, 3);
3068 if (n) {
3069 n[1].e = target;
3070 n[2].e = internalFormat;
3071 n[3].b = sink;
3072 }
3073 if (ctx->ExecuteFlag) {
3074 CALL_Minmax(ctx->Exec, (target, internalFormat, sink));
3075 }
3076 }
3077
3078
3079 static void GLAPIENTRY
3080 save_MultMatrixf(const GLfloat * m)
3081 {
3082 GET_CURRENT_CONTEXT(ctx);
3083 Node *n;
3084 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3085 n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16);
3086 if (n) {
3087 GLuint i;
3088 for (i = 0; i < 16; i++) {
3089 n[1 + i].f = m[i];
3090 }
3091 }
3092 if (ctx->ExecuteFlag) {
3093 CALL_MultMatrixf(ctx->Exec, (m));
3094 }
3095 }
3096
3097
3098 static void GLAPIENTRY
3099 save_MultMatrixd(const GLdouble * m)
3100 {
3101 GLfloat f[16];
3102 GLint i;
3103 for (i = 0; i < 16; i++) {
3104 f[i] = (GLfloat) m[i];
3105 }
3106 save_MultMatrixf(f);
3107 }
3108
3109
3110 static void GLAPIENTRY
3111 save_NewList(GLuint name, GLenum mode)
3112 {
3113 GET_CURRENT_CONTEXT(ctx);
3114 /* It's an error to call this function while building a display list */
3115 _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
3116 (void) name;
3117 (void) mode;
3118 }
3119
3120
3121
3122 static void GLAPIENTRY
3123 save_Ortho(GLdouble left, GLdouble right,
3124 GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
3125 {
3126 GET_CURRENT_CONTEXT(ctx);
3127 Node *n;
3128 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3129 n = alloc_instruction(ctx, OPCODE_ORTHO, 6);
3130 if (n) {
3131 n[1].f = (GLfloat) left;
3132 n[2].f = (GLfloat) right;
3133 n[3].f = (GLfloat) bottom;
3134 n[4].f = (GLfloat) top;
3135 n[5].f = (GLfloat) nearval;
3136 n[6].f = (GLfloat) farval;
3137 }
3138 if (ctx->ExecuteFlag) {
3139 CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval));
3140 }
3141 }
3142
3143
3144 static void GLAPIENTRY
3145 save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values)
3146 {
3147 GET_CURRENT_CONTEXT(ctx);
3148 Node *n;
3149 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3150 n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 3);
3151 if (n) {
3152 n[1].e = map;
3153 n[2].i = mapsize;
3154 n[3].data = malloc(mapsize * sizeof(GLfloat));
3155 memcpy(n[3].data, (void *) values, mapsize * sizeof(GLfloat));
3156 }
3157 if (ctx->ExecuteFlag) {
3158 CALL_PixelMapfv(ctx->Exec, (map, mapsize, values));
3159 }
3160 }
3161
3162
3163 static void GLAPIENTRY
3164 save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values)
3165 {
3166 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
3167 GLint i;
3168 if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
3169 for (i = 0; i < mapsize; i++) {
3170 fvalues[i] = (GLfloat) values[i];
3171 }
3172 }
3173 else {
3174 for (i = 0; i < mapsize; i++) {
3175 fvalues[i] = UINT_TO_FLOAT(values[i]);
3176 }
3177 }
3178 save_PixelMapfv(map, mapsize, fvalues);
3179 }
3180
3181
3182 static void GLAPIENTRY
3183 save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
3184 {
3185 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
3186 GLint i;
3187 if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
3188 for (i = 0; i < mapsize; i++) {
3189 fvalues[i] = (GLfloat) values[i];
3190 }
3191 }
3192 else {
3193 for (i = 0; i < mapsize; i++) {
3194 fvalues[i] = USHORT_TO_FLOAT(values[i]);
3195 }
3196 }
3197 save_PixelMapfv(map, mapsize, fvalues);
3198 }
3199
3200
3201 static void GLAPIENTRY
3202 save_PixelTransferf(GLenum pname, GLfloat param)
3203 {
3204 GET_CURRENT_CONTEXT(ctx);
3205 Node *n;
3206 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3207 n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2);
3208 if (n) {
3209 n[1].e = pname;
3210 n[2].f = param;
3211 }
3212 if (ctx->ExecuteFlag) {
3213 CALL_PixelTransferf(ctx->Exec, (pname, param));
3214 }
3215 }
3216
3217
3218 static void GLAPIENTRY
3219 save_PixelTransferi(GLenum pname, GLint param)
3220 {
3221 save_PixelTransferf(pname, (GLfloat) param);
3222 }
3223
3224
3225 static void GLAPIENTRY
3226 save_PixelZoom(GLfloat xfactor, GLfloat yfactor)
3227 {
3228 GET_CURRENT_CONTEXT(ctx);
3229 Node *n;
3230 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3231 n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2);
3232 if (n) {
3233 n[1].f = xfactor;
3234 n[2].f = yfactor;
3235 }
3236 if (ctx->ExecuteFlag) {
3237 CALL_PixelZoom(ctx->Exec, (xfactor, yfactor));
3238 }
3239 }
3240
3241
3242 static void GLAPIENTRY
3243 save_PointParameterfvEXT(GLenum pname, const GLfloat *params)
3244 {
3245 GET_CURRENT_CONTEXT(ctx);
3246 Node *n;
3247 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3248 n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4);
3249 if (n) {
3250 n[1].e = pname;
3251 n[2].f = params[0];
3252 n[3].f = params[1];
3253 n[4].f = params[2];
3254 }
3255 if (ctx->ExecuteFlag) {
3256 CALL_PointParameterfv(ctx->Exec, (pname, params));
3257 }
3258 }
3259
3260
3261 static void GLAPIENTRY
3262 save_PointParameterfEXT(GLenum pname, GLfloat param)
3263 {
3264 GLfloat parray[3];
3265 parray[0] = param;
3266 parray[1] = parray[2] = 0.0F;
3267 save_PointParameterfvEXT(pname, parray);
3268 }
3269
3270 static void GLAPIENTRY
3271 save_PointParameteriNV(GLenum pname, GLint param)
3272 {
3273 GLfloat parray[3];
3274 parray[0] = (GLfloat) param;
3275 parray[1] = parray[2] = 0.0F;
3276 save_PointParameterfvEXT(pname, parray);
3277 }
3278
3279 static void GLAPIENTRY
3280 save_PointParameterivNV(GLenum pname, const GLint * param)
3281 {
3282 GLfloat parray[3];
3283 parray[0] = (GLfloat) param[0];
3284 parray[1] = parray[2] = 0.0F;
3285 save_PointParameterfvEXT(pname, parray);
3286 }
3287
3288
3289 static void GLAPIENTRY
3290 save_PointSize(GLfloat size)
3291 {
3292 GET_CURRENT_CONTEXT(ctx);
3293 Node *n;
3294 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3295 n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1);
3296 if (n) {
3297 n[1].f = size;
3298 }
3299 if (ctx->ExecuteFlag) {
3300 CALL_PointSize(ctx->Exec, (size));
3301 }
3302 }
3303
3304
3305 static void GLAPIENTRY
3306 save_PolygonMode(GLenum face, GLenum mode)
3307 {
3308 GET_CURRENT_CONTEXT(ctx);
3309 Node *n;
3310 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3311 n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2);
3312 if (n) {
3313 n[1].e = face;
3314 n[2].e = mode;
3315 }
3316 if (ctx->ExecuteFlag) {
3317 CALL_PolygonMode(ctx->Exec, (face, mode));
3318 }
3319 }
3320
3321
3322 static void GLAPIENTRY
3323 save_PolygonStipple(const GLubyte * pattern)
3324 {
3325 GET_CURRENT_CONTEXT(ctx);
3326 Node *n;
3327
3328 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3329
3330 n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, 1);
3331 if (n) {
3332 n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP,
3333 pattern, &ctx->Unpack);
3334 }
3335 if (ctx->ExecuteFlag) {
3336 CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern));
3337 }
3338 }
3339
3340
3341 static void GLAPIENTRY
3342 save_PolygonOffset(GLfloat factor, GLfloat units)
3343 {
3344 GET_CURRENT_CONTEXT(ctx);
3345 Node *n;
3346 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3347 n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2);
3348 if (n) {
3349 n[1].f = factor;
3350 n[2].f = units;
3351 }
3352 if (ctx->ExecuteFlag) {
3353 CALL_PolygonOffset(ctx->Exec, (factor, units));
3354 }
3355 }
3356
3357
3358 static void GLAPIENTRY
3359 save_PolygonOffsetEXT(GLfloat factor, GLfloat bias)
3360 {
3361 GET_CURRENT_CONTEXT(ctx);
3362 /* XXX mult by DepthMaxF here??? */
3363 save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias);
3364 }
3365
3366
3367 static void GLAPIENTRY
3368 save_PopAttrib(void)
3369 {
3370 GET_CURRENT_CONTEXT(ctx);
3371 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3372 (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0);
3373 if (ctx->ExecuteFlag) {
3374 CALL_PopAttrib(ctx->Exec, ());
3375 }
3376 }
3377
3378
3379 static void GLAPIENTRY
3380 save_PopMatrix(void)
3381 {
3382 GET_CURRENT_CONTEXT(ctx);
3383 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3384 (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0);
3385 if (ctx->ExecuteFlag) {
3386 CALL_PopMatrix(ctx->Exec, ());
3387 }
3388 }
3389
3390
3391 static void GLAPIENTRY
3392 save_PopName(void)
3393 {
3394 GET_CURRENT_CONTEXT(ctx);
3395 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3396 (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0);
3397 if (ctx->ExecuteFlag) {
3398 CALL_PopName(ctx->Exec, ());
3399 }
3400 }
3401
3402
3403 static void GLAPIENTRY
3404 save_PrioritizeTextures(GLsizei num, const GLuint * textures,
3405 const GLclampf * priorities)
3406 {
3407 GET_CURRENT_CONTEXT(ctx);
3408 GLint i;
3409 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3410
3411 for (i = 0; i < num; i++) {
3412 Node *n;
3413 n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2);
3414 if (n) {
3415 n[1].ui = textures[i];
3416 n[2].f = priorities[i];
3417 }
3418 }
3419 if (ctx->ExecuteFlag) {
3420 CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities));
3421 }
3422 }
3423
3424
3425 static void GLAPIENTRY
3426 save_PushAttrib(GLbitfield mask)
3427 {
3428 GET_CURRENT_CONTEXT(ctx);
3429 Node *n;
3430 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3431 n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1);
3432 if (n) {
3433 n[1].bf = mask;
3434 }
3435 if (ctx->ExecuteFlag) {
3436 CALL_PushAttrib(ctx->Exec, (mask));
3437 }
3438 }
3439
3440
3441 static void GLAPIENTRY
3442 save_PushMatrix(void)
3443 {
3444 GET_CURRENT_CONTEXT(ctx);
3445 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3446 (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0);
3447 if (ctx->ExecuteFlag) {
3448 CALL_PushMatrix(ctx->Exec, ());
3449 }
3450 }
3451
3452
3453 static void GLAPIENTRY
3454 save_PushName(GLuint name)
3455 {
3456 GET_CURRENT_CONTEXT(ctx);
3457 Node *n;
3458 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3459 n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1);
3460 if (n) {
3461 n[1].ui = name;
3462 }
3463 if (ctx->ExecuteFlag) {
3464 CALL_PushName(ctx->Exec, (name));
3465 }
3466 }
3467
3468
3469 static void GLAPIENTRY
3470 save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
3471 {
3472 GET_CURRENT_CONTEXT(ctx);
3473 Node *n;
3474 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3475 n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4);
3476 if (n) {
3477 n[1].f = x;
3478 n[2].f = y;
3479 n[3].f = z;
3480 n[4].f = w;
3481 }
3482 if (ctx->ExecuteFlag) {
3483 CALL_RasterPos4f(ctx->Exec, (x, y, z, w));
3484 }
3485 }
3486
3487 static void GLAPIENTRY
3488 save_RasterPos2d(GLdouble x, GLdouble y)
3489 {
3490 save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3491 }
3492
3493 static void GLAPIENTRY
3494 save_RasterPos2f(GLfloat x, GLfloat y)
3495 {
3496 save_RasterPos4f(x, y, 0.0F, 1.0F);
3497 }
3498
3499 static void GLAPIENTRY
3500 save_RasterPos2i(GLint x, GLint y)
3501 {
3502 save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3503 }
3504
3505 static void GLAPIENTRY
3506 save_RasterPos2s(GLshort x, GLshort y)
3507 {
3508 save_RasterPos4f(x, y, 0.0F, 1.0F);
3509 }
3510
3511 static void GLAPIENTRY
3512 save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
3513 {
3514 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3515 }
3516
3517 static void GLAPIENTRY
3518 save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
3519 {
3520 save_RasterPos4f(x, y, z, 1.0F);
3521 }
3522
3523 static void GLAPIENTRY
3524 save_RasterPos3i(GLint x, GLint y, GLint z)
3525 {
3526 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3527 }
3528
3529 static void GLAPIENTRY
3530 save_RasterPos3s(GLshort x, GLshort y, GLshort z)
3531 {
3532 save_RasterPos4f(x, y, z, 1.0F);
3533 }
3534
3535 static void GLAPIENTRY
3536 save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3537 {
3538 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3539 }
3540
3541 static void GLAPIENTRY
3542 save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
3543 {
3544 save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3545 }
3546
3547 static void GLAPIENTRY
3548 save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
3549 {
3550 save_RasterPos4f(x, y, z, w);
3551 }
3552
3553 static void GLAPIENTRY
3554 save_RasterPos2dv(const GLdouble * v)
3555 {
3556 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3557 }
3558
3559 static void GLAPIENTRY
3560 save_RasterPos2fv(const GLfloat * v)
3561 {
3562 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
3563 }
3564
3565 static void GLAPIENTRY
3566 save_RasterPos2iv(const GLint * v)
3567 {
3568 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3569 }
3570
3571 static void GLAPIENTRY
3572 save_RasterPos2sv(const GLshort * v)
3573 {
3574 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
3575 }
3576
3577 static void GLAPIENTRY
3578 save_RasterPos3dv(const GLdouble * v)
3579 {
3580 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3581 }
3582
3583 static void GLAPIENTRY
3584 save_RasterPos3fv(const GLfloat * v)
3585 {
3586 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3587 }
3588
3589 static void GLAPIENTRY
3590 save_RasterPos3iv(const GLint * v)
3591 {
3592 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3593 }
3594
3595 static void GLAPIENTRY
3596 save_RasterPos3sv(const GLshort * v)
3597 {
3598 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3599 }
3600
3601 static void GLAPIENTRY
3602 save_RasterPos4dv(const GLdouble * v)
3603 {
3604 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3605 (GLfloat) v[2], (GLfloat) v[3]);
3606 }
3607
3608 static void GLAPIENTRY
3609 save_RasterPos4fv(const GLfloat * v)
3610 {
3611 save_RasterPos4f(v[0], v[1], v[2], v[3]);
3612 }
3613
3614 static void GLAPIENTRY
3615 save_RasterPos4iv(const GLint * v)
3616 {
3617 save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3618 (GLfloat) v[2], (GLfloat) v[3]);
3619 }
3620
3621 static void GLAPIENTRY
3622 save_RasterPos4sv(const GLshort * v)
3623 {
3624 save_RasterPos4f(v[0], v[1], v[2], v[3]);
3625 }
3626
3627
3628 static void GLAPIENTRY
3629 save_PassThrough(GLfloat token)
3630 {
3631 GET_CURRENT_CONTEXT(ctx);
3632 Node *n;
3633 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3634 n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1);
3635 if (n) {
3636 n[1].f = token;
3637 }
3638 if (ctx->ExecuteFlag) {
3639 CALL_PassThrough(ctx->Exec, (token));
3640 }
3641 }
3642
3643
3644 static void GLAPIENTRY
3645 save_ReadBuffer(GLenum mode)
3646 {
3647 GET_CURRENT_CONTEXT(ctx);
3648 Node *n;
3649 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3650 n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1);
3651 if (n) {
3652 n[1].e = mode;
3653 }
3654 if (ctx->ExecuteFlag) {
3655 CALL_ReadBuffer(ctx->Exec, (mode));
3656 }
3657 }
3658
3659
3660 static void GLAPIENTRY
3661 save_ResetHistogram(GLenum target)
3662 {
3663 GET_CURRENT_CONTEXT(ctx);
3664 Node *n;
3665 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3666 n = alloc_instruction(ctx, OPCODE_RESET_HISTOGRAM, 1);
3667 if (n) {
3668 n[1].e = target;
3669 }
3670 if (ctx->ExecuteFlag) {
3671 CALL_ResetHistogram(ctx->Exec, (target));
3672 }
3673 }
3674
3675
3676 static void GLAPIENTRY
3677 save_ResetMinmax(GLenum target)
3678 {
3679 GET_CURRENT_CONTEXT(ctx);
3680 Node *n;
3681 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3682 n = alloc_instruction(ctx, OPCODE_RESET_MIN_MAX, 1);
3683 if (n) {
3684 n[1].e = target;
3685 }
3686 if (ctx->ExecuteFlag) {
3687 CALL_ResetMinmax(ctx->Exec, (target));
3688 }
3689 }
3690
3691
3692 static void GLAPIENTRY
3693 save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
3694 {
3695 GET_CURRENT_CONTEXT(ctx);
3696 Node *n;
3697 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3698 n = alloc_instruction(ctx, OPCODE_ROTATE, 4);
3699 if (n) {
3700 n[1].f = angle;
3701 n[2].f = x;
3702 n[3].f = y;
3703 n[4].f = z;
3704 }
3705 if (ctx->ExecuteFlag) {
3706 CALL_Rotatef(ctx->Exec, (angle, x, y, z));
3707 }
3708 }
3709
3710
3711 static void GLAPIENTRY
3712 save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
3713 {
3714 save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
3715 }
3716
3717
3718 static void GLAPIENTRY
3719 save_Scalef(GLfloat x, GLfloat y, GLfloat z)
3720 {
3721 GET_CURRENT_CONTEXT(ctx);
3722 Node *n;
3723 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3724 n = alloc_instruction(ctx, OPCODE_SCALE, 3);
3725 if (n) {
3726 n[1].f = x;
3727 n[2].f = y;
3728 n[3].f = z;
3729 }
3730 if (ctx->ExecuteFlag) {
3731 CALL_Scalef(ctx->Exec, (x, y, z));
3732 }
3733 }
3734
3735
3736 static void GLAPIENTRY
3737 save_Scaled(GLdouble x, GLdouble y, GLdouble z)
3738 {
3739 save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
3740 }
3741
3742
3743 static void GLAPIENTRY
3744 save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
3745 {
3746 GET_CURRENT_CONTEXT(ctx);
3747 Node *n;
3748 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3749 n = alloc_instruction(ctx, OPCODE_SCISSOR, 4);
3750 if (n) {
3751 n[1].i = x;
3752 n[2].i = y;
3753 n[3].i = width;
3754 n[4].i = height;
3755 }
3756 if (ctx->ExecuteFlag) {
3757 CALL_Scissor(ctx->Exec, (x, y, width, height));
3758 }
3759 }
3760
3761
3762 static void GLAPIENTRY
3763 save_ShadeModel(GLenum mode)
3764 {
3765 GET_CURRENT_CONTEXT(ctx);
3766 Node *n;
3767 ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);
3768
3769 if (ctx->ExecuteFlag) {
3770 CALL_ShadeModel(ctx->Exec, (mode));
3771 }
3772
3773 if (ctx->ListState.Current.ShadeModel == mode)
3774 return;
3775
3776 SAVE_FLUSH_VERTICES(ctx);
3777
3778 /* Only save the value if we know the statechange will take effect:
3779 */
3780 if (!_mesa_inside_dlist_begin_end(ctx))
3781 ctx->ListState.Current.ShadeModel = mode;
3782
3783 n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1);
3784 if (n) {
3785 n[1].e = mode;
3786 }
3787 }
3788
3789
3790 static void GLAPIENTRY
3791 save_StencilFunc(GLenum func, GLint ref, GLuint mask)
3792 {
3793 GET_CURRENT_CONTEXT(ctx);
3794 Node *n;
3795 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3796 n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3);
3797 if (n) {
3798 n[1].e = func;
3799 n[2].i = ref;
3800 n[3].ui = mask;
3801 }
3802 if (ctx->ExecuteFlag) {
3803 CALL_StencilFunc(ctx->Exec, (func, ref, mask));
3804 }
3805 }
3806
3807
3808 static void GLAPIENTRY
3809 save_StencilMask(GLuint mask)
3810 {
3811 GET_CURRENT_CONTEXT(ctx);
3812 Node *n;
3813 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3814 n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1);
3815 if (n) {
3816 n[1].ui = mask;
3817 }
3818 if (ctx->ExecuteFlag) {
3819 CALL_StencilMask(ctx->Exec, (mask));
3820 }
3821 }
3822
3823
3824 static void GLAPIENTRY
3825 save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
3826 {
3827 GET_CURRENT_CONTEXT(ctx);
3828 Node *n;
3829 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3830 n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3);
3831 if (n) {
3832 n[1].e = fail;
3833 n[2].e = zfail;
3834 n[3].e = zpass;
3835 }
3836 if (ctx->ExecuteFlag) {
3837 CALL_StencilOp(ctx->Exec, (fail, zfail, zpass));
3838 }
3839 }
3840
3841
3842 static void GLAPIENTRY
3843 save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
3844 {
3845 GET_CURRENT_CONTEXT(ctx);
3846 Node *n;
3847 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3848 n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3849 if (n) {
3850 n[1].e = face;
3851 n[2].e = func;
3852 n[3].i = ref;
3853 n[4].ui = mask;
3854 }
3855 if (ctx->ExecuteFlag) {
3856 CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask));
3857 }
3858 }
3859
3860
3861 static void GLAPIENTRY
3862 save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
3863 GLuint mask)
3864 {
3865 GET_CURRENT_CONTEXT(ctx);
3866 Node *n;
3867 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3868 /* GL_FRONT */
3869 n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3870 if (n) {
3871 n[1].e = GL_FRONT;
3872 n[2].e = frontfunc;
3873 n[3].i = ref;
3874 n[4].ui = mask;
3875 }
3876 /* GL_BACK */
3877 n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3878 if (n) {
3879 n[1].e = GL_BACK;
3880 n[2].e = backfunc;
3881 n[3].i = ref;
3882 n[4].ui = mask;
3883 }
3884 if (ctx->ExecuteFlag) {
3885 CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask));
3886 CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask));
3887 }
3888 }
3889
3890
3891 static void GLAPIENTRY
3892 save_StencilMaskSeparate(GLenum face, GLuint mask)
3893 {
3894 GET_CURRENT_CONTEXT(ctx);
3895 Node *n;
3896 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3897 n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2);
3898 if (n) {
3899 n[1].e = face;
3900 n[2].ui = mask;
3901 }
3902 if (ctx->ExecuteFlag) {
3903 CALL_StencilMaskSeparate(ctx->Exec, (face, mask));
3904 }
3905 }
3906
3907
3908 static void GLAPIENTRY
3909 save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
3910 {
3911 GET_CURRENT_CONTEXT(ctx);
3912 Node *n;
3913 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3914 n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4);
3915 if (n) {
3916 n[1].e = face;
3917 n[2].e = fail;
3918 n[3].e = zfail;
3919 n[4].e = zpass;
3920 }
3921 if (ctx->ExecuteFlag) {
3922 CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass));
3923 }
3924 }
3925
3926
3927 static void GLAPIENTRY
3928 save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
3929 {
3930 GET_CURRENT_CONTEXT(ctx);
3931 Node *n;
3932 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3933 n = alloc_instruction(ctx, OPCODE_TEXENV, 6);
3934 if (n) {
3935 n[1].e = target;
3936 n[2].e = pname;
3937 if (pname == GL_TEXTURE_ENV_COLOR) {
3938 n[3].f = params[0];
3939 n[4].f = params[1];
3940 n[5].f = params[2];
3941 n[6].f = params[3];
3942 }
3943 else {
3944 n[3].f = params[0];
3945 n[4].f = n[5].f = n[6].f = 0.0F;
3946 }
3947 }
3948 if (ctx->ExecuteFlag) {
3949 CALL_TexEnvfv(ctx->Exec, (target, pname, params));
3950 }
3951 }
3952
3953
3954 static void GLAPIENTRY
3955 save_TexEnvf(GLenum target, GLenum pname, GLfloat param)
3956 {
3957 GLfloat parray[4];
3958 parray[0] = (GLfloat) param;
3959 parray[1] = parray[2] = parray[3] = 0.0F;
3960 save_TexEnvfv(target, pname, parray);
3961 }
3962
3963
3964 static void GLAPIENTRY
3965 save_TexEnvi(GLenum target, GLenum pname, GLint param)
3966 {
3967 GLfloat p[4];
3968 p[0] = (GLfloat) param;
3969 p[1] = p[2] = p[3] = 0.0F;
3970 save_TexEnvfv(target, pname, p);
3971 }
3972
3973
3974 static void GLAPIENTRY
3975 save_TexEnviv(GLenum target, GLenum pname, const GLint * param)
3976 {
3977 GLfloat p[4];
3978 if (pname == GL_TEXTURE_ENV_COLOR) {
3979 p[0] = INT_TO_FLOAT(param[0]);
3980 p[1] = INT_TO_FLOAT(param[1]);
3981 p[2] = INT_TO_FLOAT(param[2]);
3982 p[3] = INT_TO_FLOAT(param[3]);
3983 }
3984 else {
3985 p[0] = (GLfloat) param[0];
3986 p[1] = p[2] = p[3] = 0.0F;
3987 }
3988 save_TexEnvfv(target, pname, p);
3989 }
3990
3991
3992 static void GLAPIENTRY
3993 save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params)
3994 {
3995 GET_CURRENT_CONTEXT(ctx);
3996 Node *n;
3997 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3998 n = alloc_instruction(ctx, OPCODE_TEXGEN, 6);
3999 if (n) {
4000 n[1].e = coord;
4001 n[2].e = pname;
4002 n[3].f = params[0];
4003 n[4].f = params[1];
4004 n[5].f = params[2];
4005 n[6].f = params[3];
4006 }
4007 if (ctx->ExecuteFlag) {
4008 CALL_TexGenfv(ctx->Exec, (coord, pname, params));
4009 }
4010 }
4011
4012
4013 static void GLAPIENTRY
4014 save_TexGeniv(GLenum coord, GLenum pname, const GLint *params)
4015 {
4016 GLfloat p[4];
4017 p[0] = (GLfloat) params[0];
4018 p[1] = (GLfloat) params[1];
4019 p[2] = (GLfloat) params[2];
4020 p[3] = (GLfloat) params[3];
4021 save_TexGenfv(coord, pname, p);
4022 }
4023
4024
4025 static void GLAPIENTRY
4026 save_TexGend(GLenum coord, GLenum pname, GLdouble param)
4027 {
4028 GLfloat parray[4];
4029 parray[0] = (GLfloat) param;
4030 parray[1] = parray[2] = parray[3] = 0.0F;
4031 save_TexGenfv(coord, pname, parray);
4032 }
4033
4034
4035 static void GLAPIENTRY
4036 save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params)
4037 {
4038 GLfloat p[4];
4039 p[0] = (GLfloat) params[0];
4040 p[1] = (GLfloat) params[1];
4041 p[2] = (GLfloat) params[2];
4042 p[3] = (GLfloat) params[3];
4043 save_TexGenfv(coord, pname, p);
4044 }
4045
4046
4047 static void GLAPIENTRY
4048 save_TexGenf(GLenum coord, GLenum pname, GLfloat param)
4049 {
4050 GLfloat parray[4];
4051 parray[0] = param;
4052 parray[1] = parray[2] = parray[3] = 0.0F;
4053 save_TexGenfv(coord, pname, parray);
4054 }
4055
4056
4057 static void GLAPIENTRY
4058 save_TexGeni(GLenum coord, GLenum pname, GLint param)
4059 {
4060 GLint parray[4];
4061 parray[0] = param;
4062 parray[1] = parray[2] = parray[3] = 0;
4063 save_TexGeniv(coord, pname, parray);
4064 }
4065
4066
4067 static void GLAPIENTRY
4068 save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
4069 {
4070 GET_CURRENT_CONTEXT(ctx);
4071 Node *n;
4072 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4073 n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6);
4074 if (n) {
4075 n[1].e = target;
4076 n[2].e = pname;
4077 n[3].f = params[0];
4078 n[4].f = params[1];
4079 n[5].f = params[2];
4080 n[6].f = params[3];
4081 }
4082 if (ctx->ExecuteFlag) {
4083 CALL_TexParameterfv(ctx->Exec, (target, pname, params));
4084 }
4085 }
4086
4087
4088 static void GLAPIENTRY
4089 save_TexParameterf(GLenum target, GLenum pname, GLfloat param)
4090 {
4091 GLfloat parray[4];
4092 parray[0] = param;
4093 parray[1] = parray[2] = parray[3] = 0.0F;
4094 save_TexParameterfv(target, pname, parray);
4095 }
4096
4097
4098 static void GLAPIENTRY
4099 save_TexParameteri(GLenum target, GLenum pname, GLint param)
4100 {
4101 GLfloat fparam[4];
4102 fparam[0] = (GLfloat) param;
4103 fparam[1] = fparam[2] = fparam[3] = 0.0F;
4104 save_TexParameterfv(target, pname, fparam);
4105 }
4106
4107
4108 static void GLAPIENTRY
4109 save_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
4110 {
4111 GLfloat fparam[4];
4112 fparam[0] = (GLfloat) params[0];
4113 fparam[1] = fparam[2] = fparam[3] = 0.0F;
4114 save_TexParameterfv(target, pname, fparam);
4115 }
4116
4117
4118 static void GLAPIENTRY
4119 save_TexImage1D(GLenum target,
4120 GLint level, GLint components,
4121 GLsizei width, GLint border,
4122 GLenum format, GLenum type, const GLvoid * pixels)
4123 {
4124 GET_CURRENT_CONTEXT(ctx);
4125 if (target == GL_PROXY_TEXTURE_1D) {
4126 /* don't compile, execute immediately */
4127 CALL_TexImage1D(ctx->Exec, (target, level, components, width,
4128 border, format, type, pixels));
4129 }
4130 else {
4131 Node *n;
4132 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4133 n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 8);
4134 if (n) {
4135 n[1].e = target;
4136 n[2].i = level;
4137 n[3].i = components;
4138 n[4].i = (GLint) width;
4139 n[5].i = border;
4140 n[6].e = format;
4141 n[7].e = type;
4142 n[8].data = unpack_image(ctx, 1, width, 1, 1, format, type,
4143 pixels, &ctx->Unpack);
4144 }
4145 if (ctx->ExecuteFlag) {
4146 CALL_TexImage1D(ctx->Exec, (target, level, components, width,
4147 border, format, type, pixels));
4148 }
4149 }
4150 }
4151
4152
4153 static void GLAPIENTRY
4154 save_TexImage2D(GLenum target,
4155 GLint level, GLint components,
4156 GLsizei width, GLsizei height, GLint border,
4157 GLenum format, GLenum type, const GLvoid * pixels)
4158 {
4159 GET_CURRENT_CONTEXT(ctx);
4160 if (target == GL_PROXY_TEXTURE_2D) {
4161 /* don't compile, execute immediately */
4162 CALL_TexImage2D(ctx->Exec, (target, level, components, width,
4163 height, border, format, type, pixels));
4164 }
4165 else {
4166 Node *n;
4167 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4168 n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 9);
4169 if (n) {
4170 n[1].e = target;
4171 n[2].i = level;
4172 n[3].i = components;
4173 n[4].i = (GLint) width;
4174 n[5].i = (GLint) height;
4175 n[6].i = border;
4176 n[7].e = format;
4177 n[8].e = type;
4178 n[9].data = unpack_image(ctx, 2, width, height, 1, format, type,
4179 pixels, &ctx->Unpack);
4180 }
4181 if (ctx->ExecuteFlag) {
4182 CALL_TexImage2D(ctx->Exec, (target, level, components, width,
4183 height, border, format, type, pixels));
4184 }
4185 }
4186 }
4187
4188
4189 static void GLAPIENTRY
4190 save_TexImage3D(GLenum target,
4191 GLint level, GLint internalFormat,
4192 GLsizei width, GLsizei height, GLsizei depth,
4193 GLint border,
4194 GLenum format, GLenum type, const GLvoid * pixels)
4195 {
4196 GET_CURRENT_CONTEXT(ctx);
4197 if (target == GL_PROXY_TEXTURE_3D) {
4198 /* don't compile, execute immediately */
4199 CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
4200 height, depth, border, format, type,
4201 pixels));
4202 }
4203 else {
4204 Node *n;
4205 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4206 n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 10);
4207 if (n) {
4208 n[1].e = target;
4209 n[2].i = level;
4210 n[3].i = (GLint) internalFormat;
4211 n[4].i = (GLint) width;
4212 n[5].i = (GLint) height;
4213 n[6].i = (GLint) depth;
4214 n[7].i = border;
4215 n[8].e = format;
4216 n[9].e = type;
4217 n[10].data = unpack_image(ctx, 3, width, height, depth, format, type,
4218 pixels, &ctx->Unpack);
4219 }
4220 if (ctx->ExecuteFlag) {
4221 CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
4222 height, depth, border, format, type,
4223 pixels));
4224 }
4225 }
4226 }
4227
4228
4229 static void GLAPIENTRY
4230 save_TexSubImage1D(GLenum target, GLint level, GLint xoffset,
4231 GLsizei width, GLenum format, GLenum type,
4232 const GLvoid * pixels)
4233 {
4234 GET_CURRENT_CONTEXT(ctx);
4235 Node *n;
4236
4237 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4238
4239 n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 7);
4240 if (n) {
4241 n[1].e = target;
4242 n[2].i = level;
4243 n[3].i = xoffset;
4244 n[4].i = (GLint) width;
4245 n[5].e = format;
4246 n[6].e = type;
4247 n[7].data = unpack_image(ctx, 1, width, 1, 1, format, type,
4248 pixels, &ctx->Unpack);
4249 }
4250 if (ctx->ExecuteFlag) {
4251 CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width,
4252 format, type, pixels));
4253 }
4254 }
4255
4256
4257 static void GLAPIENTRY
4258 save_TexSubImage2D(GLenum target, GLint level,
4259 GLint xoffset, GLint yoffset,
4260 GLsizei width, GLsizei height,
4261 GLenum format, GLenum type, const GLvoid * pixels)
4262 {
4263 GET_CURRENT_CONTEXT(ctx);
4264 Node *n;
4265
4266 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4267
4268 n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 9);
4269 if (n) {
4270 n[1].e = target;
4271 n[2].i = level;
4272 n[3].i = xoffset;
4273 n[4].i = yoffset;
4274 n[5].i = (GLint) width;
4275 n[6].i = (GLint) height;
4276 n[7].e = format;
4277 n[8].e = type;
4278 n[9].data = unpack_image(ctx, 2, width, height, 1, format, type,
4279 pixels, &ctx->Unpack);
4280 }
4281 if (ctx->ExecuteFlag) {
4282 CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
4283 width, height, format, type, pixels));
4284 }
4285 }
4286
4287
4288 static void GLAPIENTRY
4289 save_TexSubImage3D(GLenum target, GLint level,
4290 GLint xoffset, GLint yoffset, GLint zoffset,
4291 GLsizei width, GLsizei height, GLsizei depth,
4292 GLenum format, GLenum type, const GLvoid * pixels)
4293 {
4294 GET_CURRENT_CONTEXT(ctx);
4295 Node *n;
4296
4297 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4298
4299 n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 11);
4300 if (n) {
4301 n[1].e = target;
4302 n[2].i = level;
4303 n[3].i = xoffset;
4304 n[4].i = yoffset;
4305 n[5].i = zoffset;
4306 n[6].i = (GLint) width;
4307 n[7].i = (GLint) height;
4308 n[8].i = (GLint) depth;
4309 n[9].e = format;
4310 n[10].e = type;
4311 n[11].data = unpack_image(ctx, 3, width, height, depth, format, type,
4312 pixels, &ctx->Unpack);
4313 }
4314 if (ctx->ExecuteFlag) {
4315 CALL_TexSubImage3D(ctx->Exec, (target, level,
4316 xoffset, yoffset, zoffset,
4317 width, height, depth, format, type,
4318 pixels));
4319 }
4320 }
4321
4322
4323 static void GLAPIENTRY
4324 save_Translatef(GLfloat x, GLfloat y, GLfloat z)
4325 {
4326 GET_CURRENT_CONTEXT(ctx);
4327 Node *n;
4328 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4329 n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3);
4330 if (n) {
4331 n[1].f = x;
4332 n[2].f = y;
4333 n[3].f = z;
4334 }
4335 if (ctx->ExecuteFlag) {
4336 CALL_Translatef(ctx->Exec, (x, y, z));
4337 }
4338 }
4339
4340
4341 static void GLAPIENTRY
4342 save_Translated(GLdouble x, GLdouble y, GLdouble z)
4343 {
4344 save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
4345 }
4346
4347
4348
4349 static void GLAPIENTRY
4350 save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
4351 {
4352 GET_CURRENT_CONTEXT(ctx);
4353 Node *n;
4354 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4355 n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4);
4356 if (n) {
4357 n[1].i = x;
4358 n[2].i = y;
4359 n[3].i = (GLint) width;
4360 n[4].i = (GLint) height;
4361 }
4362 if (ctx->ExecuteFlag) {
4363 CALL_Viewport(ctx->Exec, (x, y, width, height));
4364 }
4365 }
4366
4367
4368 static void GLAPIENTRY
4369 save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4370 {
4371 GET_CURRENT_CONTEXT(ctx);
4372 Node *n;
4373 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4374 n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4);
4375 if (n) {
4376 n[1].f = x;
4377 n[2].f = y;
4378 n[3].f = z;
4379 n[4].f = w;
4380 }
4381 if (ctx->ExecuteFlag) {
4382 CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w));
4383 }
4384 }
4385
4386 static void GLAPIENTRY
4387 save_WindowPos2dMESA(GLdouble x, GLdouble y)
4388 {
4389 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
4390 }
4391
4392 static void GLAPIENTRY
4393 save_WindowPos2fMESA(GLfloat x, GLfloat y)
4394 {
4395 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
4396 }
4397
4398 static void GLAPIENTRY
4399 save_WindowPos2iMESA(GLint x, GLint y)
4400 {
4401 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
4402 }
4403
4404 static void GLAPIENTRY
4405 save_WindowPos2sMESA(GLshort x, GLshort y)
4406 {
4407 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
4408 }
4409
4410 static void GLAPIENTRY
4411 save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
4412 {
4413 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
4414 }
4415
4416 static void GLAPIENTRY
4417 save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
4418 {
4419 save_WindowPos4fMESA(x, y, z, 1.0F);
4420 }
4421
4422 static void GLAPIENTRY
4423 save_WindowPos3iMESA(GLint x, GLint y, GLint z)
4424 {
4425 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
4426 }
4427
4428 static void GLAPIENTRY
4429 save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
4430 {
4431 save_WindowPos4fMESA(x, y, z, 1.0F);
4432 }
4433
4434 static void GLAPIENTRY
4435 save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4436 {
4437 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
4438 }
4439
4440 static void GLAPIENTRY
4441 save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
4442 {
4443 save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
4444 }
4445
4446 static void GLAPIENTRY
4447 save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
4448 {
4449 save_WindowPos4fMESA(x, y, z, w);
4450 }
4451
4452 static void GLAPIENTRY
4453 save_WindowPos2dvMESA(const GLdouble * v)
4454 {
4455 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
4456 }
4457
4458 static void GLAPIENTRY
4459 save_WindowPos2fvMESA(const GLfloat * v)
4460 {
4461 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
4462 }
4463
4464 static void GLAPIENTRY
4465 save_WindowPos2ivMESA(const GLint * v)
4466 {
4467 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
4468 }
4469
4470 static void GLAPIENTRY
4471 save_WindowPos2svMESA(const GLshort * v)
4472 {
4473 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
4474 }
4475
4476 static void GLAPIENTRY
4477 save_WindowPos3dvMESA(const GLdouble * v)
4478 {
4479 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
4480 }
4481
4482 static void GLAPIENTRY
4483 save_WindowPos3fvMESA(const GLfloat * v)
4484 {
4485 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
4486 }
4487
4488 static void GLAPIENTRY
4489 save_WindowPos3ivMESA(const GLint * v)
4490 {
4491 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
4492 }
4493
4494 static void GLAPIENTRY
4495 save_WindowPos3svMESA(const GLshort * v)
4496 {
4497 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
4498 }
4499
4500 static void GLAPIENTRY
4501 save_WindowPos4dvMESA(const GLdouble * v)
4502 {
4503 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
4504 (GLfloat) v[2], (GLfloat) v[3]);
4505 }
4506
4507 static void GLAPIENTRY
4508 save_WindowPos4fvMESA(const GLfloat * v)
4509 {
4510 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
4511 }
4512
4513 static void GLAPIENTRY
4514 save_WindowPos4ivMESA(const GLint * v)
4515 {
4516 save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
4517 (GLfloat) v[2], (GLfloat) v[3]);
4518 }
4519
4520 static void GLAPIENTRY
4521 save_WindowPos4svMESA(const GLshort * v)
4522 {
4523 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
4524 }
4525
4526
4527
4528 /* GL_ARB_multitexture */
4529 static void GLAPIENTRY
4530 save_ActiveTextureARB(GLenum target)
4531 {
4532 GET_CURRENT_CONTEXT(ctx);
4533 Node *n;
4534 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4535 n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1);
4536 if (n) {
4537 n[1].e = target;
4538 }
4539 if (ctx->ExecuteFlag) {
4540 CALL_ActiveTexture(ctx->Exec, (target));
4541 }
4542 }
4543
4544
4545 /* GL_ARB_transpose_matrix */
4546
4547 static void GLAPIENTRY
4548 save_LoadTransposeMatrixdARB(const GLdouble m[16])
4549 {
4550 GLfloat tm[16];
4551 _math_transposefd(tm, m);
4552 save_LoadMatrixf(tm);
4553 }
4554
4555
4556 static void GLAPIENTRY
4557 save_LoadTransposeMatrixfARB(const GLfloat m[16])
4558 {
4559 GLfloat tm[16];
4560 _math_transposef(tm, m);
4561 save_LoadMatrixf(tm);
4562 }
4563
4564
4565 static void GLAPIENTRY
4566 save_MultTransposeMatrixdARB(const GLdouble m[16])
4567 {
4568 GLfloat tm[16];
4569 _math_transposefd(tm, m);
4570 save_MultMatrixf(tm);
4571 }
4572
4573
4574 static void GLAPIENTRY
4575 save_MultTransposeMatrixfARB(const GLfloat m[16])
4576 {
4577 GLfloat tm[16];
4578 _math_transposef(tm, m);
4579 save_MultMatrixf(tm);
4580 }
4581
4582 static GLvoid *copy_data(const GLvoid *data, GLsizei size, const char *func)
4583 {
4584 GET_CURRENT_CONTEXT(ctx);
4585 GLvoid *image;
4586
4587 if (!data)
4588 return NULL;
4589
4590 image = malloc(size);
4591 if (!image) {
4592 _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
4593 return NULL;
4594 }
4595 memcpy(image, data, size);
4596
4597 return image;
4598 }
4599
4600
4601 /* GL_ARB_texture_compression */
4602 static void GLAPIENTRY
4603 save_CompressedTexImage1DARB(GLenum target, GLint level,
4604 GLenum internalFormat, GLsizei width,
4605 GLint border, GLsizei imageSize,
4606 const GLvoid * data)
4607 {
4608 GET_CURRENT_CONTEXT(ctx);
4609 if (target == GL_PROXY_TEXTURE_1D) {
4610 /* don't compile, execute immediately */
4611 CALL_CompressedTexImage1D(ctx->Exec, (target, level, internalFormat,
4612 width, border, imageSize,
4613 data));
4614 }
4615 else {
4616 Node *n;
4617 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4618
4619 n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7);
4620 if (n) {
4621 n[1].e = target;
4622 n[2].i = level;
4623 n[3].e = internalFormat;
4624 n[4].i = (GLint) width;
4625 n[5].i = border;
4626 n[6].i = imageSize;
4627 n[7].data = copy_data(data, imageSize, "glCompressedTexImage1DARB");
4628 }
4629 if (ctx->ExecuteFlag) {
4630 CALL_CompressedTexImage1D(ctx->Exec,
4631 (target, level, internalFormat, width,
4632 border, imageSize, data));
4633 }
4634 }
4635 }
4636
4637
4638 static void GLAPIENTRY
4639 save_CompressedTexImage2DARB(GLenum target, GLint level,
4640 GLenum internalFormat, GLsizei width,
4641 GLsizei height, GLint border, GLsizei imageSize,
4642 const GLvoid * data)
4643 {
4644 GET_CURRENT_CONTEXT(ctx);
4645 if (target == GL_PROXY_TEXTURE_2D) {
4646 /* don't compile, execute immediately */
4647 CALL_CompressedTexImage2D(ctx->Exec, (target, level, internalFormat,
4648 width, height, border,
4649 imageSize, data));
4650 }
4651 else {
4652 Node *n;
4653 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4654
4655 n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8);
4656 if (n) {
4657 n[1].e = target;
4658 n[2].i = level;
4659 n[3].e = internalFormat;
4660 n[4].i = (GLint) width;
4661 n[5].i = (GLint) height;
4662 n[6].i = border;
4663 n[7].i = imageSize;
4664 n[8].data = copy_data(data, imageSize, "glCompressedTexImage2DARB");
4665 }
4666 if (ctx->ExecuteFlag) {
4667 CALL_CompressedTexImage2D(ctx->Exec,
4668 (target, level, internalFormat, width,
4669 height, border, imageSize, data));
4670 }
4671 }
4672 }
4673
4674
4675 static void GLAPIENTRY
4676 save_CompressedTexImage3DARB(GLenum target, GLint level,
4677 GLenum internalFormat, GLsizei width,
4678 GLsizei height, GLsizei depth, GLint border,
4679 GLsizei imageSize, const GLvoid * data)
4680 {
4681 GET_CURRENT_CONTEXT(ctx);
4682 if (target == GL_PROXY_TEXTURE_3D) {
4683 /* don't compile, execute immediately */
4684 CALL_CompressedTexImage3D(ctx->Exec, (target, level, internalFormat,
4685 width, height, depth, border,
4686 imageSize, data));
4687 }
4688 else {
4689 Node *n;
4690 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4691
4692 n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9);
4693 if (n) {
4694 n[1].e = target;
4695 n[2].i = level;
4696 n[3].e = internalFormat;
4697 n[4].i = (GLint) width;
4698 n[5].i = (GLint) height;
4699 n[6].i = (GLint) depth;
4700 n[7].i = border;
4701 n[8].i = imageSize;
4702 n[9].data = copy_data(data, imageSize, "glCompressedTexImage3DARB");
4703 }
4704 if (ctx->ExecuteFlag) {
4705 CALL_CompressedTexImage3D(ctx->Exec,
4706 (target, level, internalFormat, width,
4707 height, depth, border, imageSize,
4708 data));
4709 }
4710 }
4711 }
4712
4713
4714 static void GLAPIENTRY
4715 save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
4716 GLsizei width, GLenum format,
4717 GLsizei imageSize, const GLvoid * data)
4718 {
4719 Node *n;
4720 GET_CURRENT_CONTEXT(ctx);
4721 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4722
4723 n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7);
4724 if (n) {
4725 n[1].e = target;
4726 n[2].i = level;
4727 n[3].i = xoffset;
4728 n[4].i = (GLint) width;
4729 n[5].e = format;
4730 n[6].i = imageSize;
4731 n[7].data = copy_data(data, imageSize, "glCompressedTexSubImage1DARB");
4732 }
4733 if (ctx->ExecuteFlag) {
4734 CALL_CompressedTexSubImage1D(ctx->Exec, (target, level, xoffset,
4735 width, format, imageSize,
4736 data));
4737 }
4738 }
4739
4740
4741 static void GLAPIENTRY
4742 save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
4743 GLint yoffset, GLsizei width, GLsizei height,
4744 GLenum format, GLsizei imageSize,
4745 const GLvoid * data)
4746 {
4747 Node *n;
4748 GET_CURRENT_CONTEXT(ctx);
4749 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4750
4751 n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9);
4752 if (n) {
4753 n[1].e = target;
4754 n[2].i = level;
4755 n[3].i = xoffset;
4756 n[4].i = yoffset;
4757 n[5].i = (GLint) width;
4758 n[6].i = (GLint) height;
4759 n[7].e = format;
4760 n[8].i = imageSize;
4761 n[9].data = copy_data(data, imageSize, "glCompressedTexSubImage2DARB");
4762 }
4763 if (ctx->ExecuteFlag) {
4764 CALL_CompressedTexSubImage2D(ctx->Exec,
4765 (target, level, xoffset, yoffset, width,
4766 height, format, imageSize, data));
4767 }
4768 }
4769
4770
4771 static void GLAPIENTRY
4772 save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
4773 GLint yoffset, GLint zoffset, GLsizei width,
4774 GLsizei height, GLsizei depth, GLenum format,
4775 GLsizei imageSize, const GLvoid * data)
4776 {
4777 Node *n;
4778 GET_CURRENT_CONTEXT(ctx);
4779 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4780
4781 n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11);
4782 if (n) {
4783 n[1].e = target;
4784 n[2].i = level;
4785 n[3].i = xoffset;
4786 n[4].i = yoffset;
4787 n[5].i = zoffset;
4788 n[6].i = (GLint) width;
4789 n[7].i = (GLint) height;
4790 n[8].i = (GLint) depth;
4791 n[9].e = format;
4792 n[10].i = imageSize;
4793 n[11].data = copy_data(data, imageSize, "glCompressedTexSubImage3DARB");
4794 }
4795 if (ctx->ExecuteFlag) {
4796 CALL_CompressedTexSubImage3D(ctx->Exec,
4797 (target, level, xoffset, yoffset,
4798 zoffset, width, height, depth, format,
4799 imageSize, data));
4800 }
4801 }
4802
4803
4804 /* GL_ARB_multisample */
4805 static void GLAPIENTRY
4806 save_SampleCoverageARB(GLclampf value, GLboolean invert)
4807 {
4808 GET_CURRENT_CONTEXT(ctx);
4809 Node *n;
4810 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4811 n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2);
4812 if (n) {
4813 n[1].f = value;
4814 n[2].b = invert;
4815 }
4816 if (ctx->ExecuteFlag) {
4817 CALL_SampleCoverage(ctx->Exec, (value, invert));
4818 }
4819 }
4820
4821
4822 /*
4823 * GL_NV_fragment_program
4824 */
4825 static void GLAPIENTRY
4826 save_BindProgramNV(GLenum target, GLuint id)
4827 {
4828 GET_CURRENT_CONTEXT(ctx);
4829 Node *n;
4830 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4831 n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_NV, 2);
4832 if (n) {
4833 n[1].e = target;
4834 n[2].ui = id;
4835 }
4836 if (ctx->ExecuteFlag) {
4837 CALL_BindProgramARB(ctx->Exec, (target, id));
4838 }
4839 }
4840
4841 static void GLAPIENTRY
4842 save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
4843 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4844 {
4845 GET_CURRENT_CONTEXT(ctx);
4846 Node *n;
4847 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4848 n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
4849 if (n) {
4850 n[1].e = target;
4851 n[2].ui = index;
4852 n[3].f = x;
4853 n[4].f = y;
4854 n[5].f = z;
4855 n[6].f = w;
4856 }
4857 if (ctx->ExecuteFlag) {
4858 CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
4859 }
4860 }
4861
4862
4863 static void GLAPIENTRY
4864 save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
4865 const GLfloat *params)
4866 {
4867 save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
4868 params[2], params[3]);
4869 }
4870
4871
4872 static void GLAPIENTRY
4873 save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
4874 const GLfloat * params)
4875 {
4876 GET_CURRENT_CONTEXT(ctx);
4877 Node *n;
4878 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4879
4880 if (count > 0) {
4881 GLint i;
4882 const GLfloat * p = params;
4883
4884 for (i = 0 ; i < count ; i++) {
4885 n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
4886 if (n) {
4887 n[1].e = target;
4888 n[2].ui = index;
4889 n[3].f = p[0];
4890 n[4].f = p[1];
4891 n[5].f = p[2];
4892 n[6].f = p[3];
4893 p += 4;
4894 }
4895 }
4896 }
4897
4898 if (ctx->ExecuteFlag) {
4899 CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params));
4900 }
4901 }
4902
4903
4904 static void GLAPIENTRY
4905 save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
4906 GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4907 {
4908 save_ProgramEnvParameter4fARB(target, index,
4909 (GLfloat) x,
4910 (GLfloat) y, (GLfloat) z, (GLfloat) w);
4911 }
4912
4913
4914 static void GLAPIENTRY
4915 save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
4916 const GLdouble *params)
4917 {
4918 save_ProgramEnvParameter4fARB(target, index,
4919 (GLfloat) params[0],
4920 (GLfloat) params[1],
4921 (GLfloat) params[2], (GLfloat) params[3]);
4922 }
4923
4924
4925 static void GLAPIENTRY
4926 save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
4927 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4928 {
4929 GET_CURRENT_CONTEXT(ctx);
4930 Node *n;
4931 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4932 n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4933 if (n) {
4934 n[1].e = target;
4935 n[2].ui = index;
4936 n[3].f = x;
4937 n[4].f = y;
4938 n[5].f = z;
4939 n[6].f = w;
4940 }
4941 if (ctx->ExecuteFlag) {
4942 CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
4943 }
4944 }
4945
4946
4947 static void GLAPIENTRY
4948 save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
4949 const GLfloat *params)
4950 {
4951 GET_CURRENT_CONTEXT(ctx);
4952 Node *n;
4953 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4954 n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4955 if (n) {
4956 n[1].e = target;
4957 n[2].ui = index;
4958 n[3].f = params[0];
4959 n[4].f = params[1];
4960 n[5].f = params[2];
4961 n[6].f = params[3];
4962 }
4963 if (ctx->ExecuteFlag) {
4964 CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params));
4965 }
4966 }
4967
4968
4969 static void GLAPIENTRY
4970 save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
4971 const GLfloat *params)
4972 {
4973 GET_CURRENT_CONTEXT(ctx);
4974 Node *n;
4975 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4976
4977 if (count > 0) {
4978 GLint i;
4979 const GLfloat * p = params;
4980
4981 for (i = 0 ; i < count ; i++) {
4982 n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4983 if (n) {
4984 n[1].e = target;
4985 n[2].ui = index;
4986 n[3].f = p[0];
4987 n[4].f = p[1];
4988 n[5].f = p[2];
4989 n[6].f = p[3];
4990 p += 4;
4991 }
4992 }
4993 }
4994
4995 if (ctx->ExecuteFlag) {
4996 CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params));
4997 }
4998 }
4999
5000
5001 static void GLAPIENTRY
5002 save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
5003 GLdouble x, GLdouble y,
5004 GLdouble z, GLdouble w)
5005 {
5006 GET_CURRENT_CONTEXT(ctx);
5007 Node *n;
5008 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5009 n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5010 if (n) {
5011 n[1].e = target;
5012 n[2].ui = index;
5013 n[3].f = (GLfloat) x;
5014 n[4].f = (GLfloat) y;
5015 n[5].f = (GLfloat) z;
5016 n[6].f = (GLfloat) w;
5017 }
5018 if (ctx->ExecuteFlag) {
5019 CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w));
5020 }
5021 }
5022
5023
5024 static void GLAPIENTRY
5025 save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
5026 const GLdouble *params)
5027 {
5028 GET_CURRENT_CONTEXT(ctx);
5029 Node *n;
5030 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5031 n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5032 if (n) {
5033 n[1].e = target;
5034 n[2].ui = index;
5035 n[3].f = (GLfloat) params[0];
5036 n[4].f = (GLfloat) params[1];
5037 n[5].f = (GLfloat) params[2];
5038 n[6].f = (GLfloat) params[3];
5039 }
5040 if (ctx->ExecuteFlag) {
5041 CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params));
5042 }
5043 }
5044
5045
5046 /* GL_EXT_stencil_two_side */
5047 static void GLAPIENTRY
5048 save_ActiveStencilFaceEXT(GLenum face)
5049 {
5050 GET_CURRENT_CONTEXT(ctx);
5051 Node *n;
5052 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5053 n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1);
5054 if (n) {
5055 n[1].e = face;
5056 }
5057 if (ctx->ExecuteFlag) {
5058 CALL_ActiveStencilFaceEXT(ctx->Exec, (face));
5059 }
5060 }
5061
5062
5063 /* GL_EXT_depth_bounds_test */
5064 static void GLAPIENTRY
5065 save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax)
5066 {
5067 GET_CURRENT_CONTEXT(ctx);
5068 Node *n;
5069 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5070 n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2);
5071 if (n) {
5072 n[1].f = (GLfloat) zmin;
5073 n[2].f = (GLfloat) zmax;
5074 }
5075 if (ctx->ExecuteFlag) {
5076 CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax));
5077 }
5078 }
5079
5080
5081
5082 static void GLAPIENTRY
5083 save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
5084 const GLvoid * string)
5085 {
5086 GET_CURRENT_CONTEXT(ctx);
5087 Node *n;
5088
5089 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5090
5091 n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4);
5092 if (n) {
5093 GLubyte *programCopy = malloc(len);
5094 if (!programCopy) {
5095 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
5096 return;
5097 }
5098 memcpy(programCopy, string, len);
5099 n[1].e = target;
5100 n[2].e = format;
5101 n[3].i = len;
5102 n[4].data = programCopy;
5103 }
5104 if (ctx->ExecuteFlag) {
5105 CALL_ProgramStringARB(ctx->Exec, (target, format, len, string));
5106 }
5107 }
5108
5109
5110 static void GLAPIENTRY
5111 save_BeginQueryARB(GLenum target, GLuint id)
5112 {
5113 GET_CURRENT_CONTEXT(ctx);
5114 Node *n;
5115 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5116 n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2);
5117 if (n) {
5118 n[1].e = target;
5119 n[2].ui = id;
5120 }
5121 if (ctx->ExecuteFlag) {
5122 CALL_BeginQuery(ctx->Exec, (target, id));
5123 }
5124 }
5125
5126 static void GLAPIENTRY
5127 save_EndQueryARB(GLenum target)
5128 {
5129 GET_CURRENT_CONTEXT(ctx);
5130 Node *n;
5131 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5132 n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1);
5133 if (n) {
5134 n[1].e = target;
5135 }
5136 if (ctx->ExecuteFlag) {
5137 CALL_EndQuery(ctx->Exec, (target));
5138 }
5139 }
5140
5141 static void GLAPIENTRY
5142 save_QueryCounter(GLuint id, GLenum target)
5143 {
5144 GET_CURRENT_CONTEXT(ctx);
5145 Node *n;
5146 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5147 n = alloc_instruction(ctx, OPCODE_QUERY_COUNTER, 2);
5148 if (n) {
5149 n[1].ui = id;
5150 n[2].e = target;
5151 }
5152 if (ctx->ExecuteFlag) {
5153 CALL_QueryCounter(ctx->Exec, (id, target));
5154 }
5155 }
5156
5157 static void GLAPIENTRY
5158 save_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
5159 {
5160 GET_CURRENT_CONTEXT(ctx);
5161 Node *n;
5162 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5163 n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_INDEXED, 3);
5164 if (n) {
5165 n[1].e = target;
5166 n[2].ui = index;
5167 n[3].ui = id;
5168 }
5169 if (ctx->ExecuteFlag) {
5170 CALL_BeginQueryIndexed(ctx->Exec, (target, index, id));
5171 }
5172 }
5173
5174 static void GLAPIENTRY
5175 save_EndQueryIndexed(GLenum target, GLuint index)
5176 {
5177 GET_CURRENT_CONTEXT(ctx);
5178 Node *n;
5179 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5180 n = alloc_instruction(ctx, OPCODE_END_QUERY_INDEXED, 2);
5181 if (n) {
5182 n[1].e = target;
5183 n[2].ui = index;
5184 }
5185 if (ctx->ExecuteFlag) {
5186 CALL_EndQueryIndexed(ctx->Exec, (target, index));
5187 }
5188 }
5189
5190
5191 static void GLAPIENTRY
5192 save_DrawBuffersARB(GLsizei count, const GLenum * buffers)
5193 {
5194 GET_CURRENT_CONTEXT(ctx);
5195 Node *n;
5196 ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5197 n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS);
5198 if (n) {
5199 GLint i;
5200 n[1].i = count;
5201 if (count > MAX_DRAW_BUFFERS)
5202 count = MAX_DRAW_BUFFERS;
5203 for (i = 0; i < count; i++) {
5204 n[2 + i].e = buffers[i];
5205 }
5206 }
5207 if (ctx->ExecuteFlag) {
5208 CALL_DrawBuffers(ctx->Exec, (count, buffers));
5209 }
5210 }
5211
5212 static void GLAPIENTRY
5213 save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param)
5214 {
5215 GET_CURRENT_CONTEXT(ctx);
5216 Node *n;
5217
5218 n = alloc_instruction(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5);
5219 if (n) {
5220 n[1].ui = pname;
5221 n[2].f = param[0];
5222 n[3].f = param[1];
5223 n[4].f = param[2];
5224 n[5].f = param[3];
5225 }
5226 if (ctx->ExecuteFlag) {
5227 CALL_TexBumpParameterfvATI(ctx->Exec, (pname, param));
5228 }
5229 }
5230
5231 static void GLAPIENTRY
5232 save_TexBumpParameterivATI(GLenum pname, const GLint *param)
5233 {
5234 GLfloat p[4];
5235 p[0] = INT_TO_FLOAT(param[0]);
5236 p[1] = INT_TO_FLOAT(param[1]);
5237 p[2] = INT_TO_FLOAT(param[2]);
5238 p[3] = INT_TO_FLOAT(param[3]);
5239 save_TexBumpParameterfvATI(pname, p);
5240 }
5241
5242 static void GLAPIENTRY
5243 save_BindFragmentShaderATI(GLuint id)
5244 {
5245 GET_CURRENT_CONTEXT(ctx);
5246 Node *n;
5247
5248 n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
5249 if (n) {
5250 n[1].ui = id;
5251 }
5252 if (ctx->ExecuteFlag) {
5253 CALL_BindFragmentShaderATI(ctx->Exec, (id));
5254 }
5255 }
5256
5257 static void GLAPIENTRY
5258 save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value)
5259 {
5260 GET_CURRENT_CONTEXT(ctx);
5261 Node *n;
5262
5263 n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
5264 if (n) {
5265 n[1].ui = dst;
5266 n[2].f = value[0];
5267 n[3].f = value[1];
5268 n[4].f = value[2];
5269 n[5].f = value[3];
5270 }
5271 if (ctx->ExecuteFlag) {
5272 CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value));
5273 }
5274 }
5275
5276 static void GLAPIENTRY
5277 save_Attr1fNV(GLenum attr, GLfloat x)
5278 {
5279 GET_CURRENT_CONTEXT(ctx);
5280 Node *n;
5281 SAVE_FLUSH_VERTICES(ctx);
5282 n = alloc_instruction(ctx, OPCODE_ATTR_1F_NV, 2);
5283 if (n) {
5284 n[1].e = attr;
5285 n[2].f = x;
5286 }
5287
5288 ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5289 ctx->ListState.ActiveAttribSize[attr] = 1;
5290 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
5291
5292 if (ctx->ExecuteFlag) {
5293 CALL_VertexAttrib1fNV(ctx->Exec, (attr, x));
5294 }
5295 }
5296
5297 static void GLAPIENTRY
5298 save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y)
5299 {
5300 GET_CURRENT_CONTEXT(ctx);
5301 Node *n;
5302 SAVE_FLUSH_VERTICES(ctx);
5303 n = alloc_instruction(ctx, OPCODE_ATTR_2F_NV, 3);
5304 if (n) {
5305 n[1].e = attr;
5306 n[2].f = x;
5307 n[3].f = y;
5308 }
5309
5310 ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5311 ctx->ListState.ActiveAttribSize[attr] = 2;
5312 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
5313
5314 if (ctx->ExecuteFlag) {
5315 CALL_VertexAttrib2fNV(ctx->Exec, (attr, x, y));
5316 }
5317 }
5318
5319 static void GLAPIENTRY
5320 save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
5321 {
5322 GET_CURRENT_CONTEXT(ctx);
5323 Node *n;
5324 SAVE_FLUSH_VERTICES(ctx);
5325 n = alloc_instruction(ctx, OPCODE_ATTR_3F_NV, 4);
5326 if (n) {
5327 n[1].e = attr;
5328 n[2].f = x;
5329 n[3].f = y;
5330 n[4].f = z;
5331 }
5332
5333 ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5334 ctx->ListState.ActiveAttribSize[attr] = 3;
5335 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
5336
5337 if (ctx->ExecuteFlag) {
5338 CALL_VertexAttrib3fNV(ctx->Exec, (attr, x, y, z));
5339 }
5340 }
5341
5342 static void GLAPIENTRY
5343 save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5344 {
5345 GET_CURRENT_CONTEXT(ctx);
5346 Node *n;
5347 SAVE_FLUSH_VERTICES(ctx);
5348 n = alloc_instruction(ctx, OPCODE_ATTR_4F_NV, 5);
5349 if (n) {
5350 n[1].e = attr;
5351 n[2].f = x;
5352 n[3].f = y;
5353 n[4].f = z;
5354 n[5].f = w;
5355 }
5356
5357 ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5358 ctx->ListState.ActiveAttribSize[attr] = 4;
5359 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
5360
5361 if (ctx->ExecuteFlag) {
5362 CALL_VertexAttrib4fNV(ctx->Exec, (attr, x, y, z, w));
5363 }
5364 }
5365
5366
5367 static void GLAPIENTRY
5368 save_Attr1fARB(GLenum attr, GLfloat x)
5369 {
5370 GET_CURRENT_CONTEXT(ctx);
5371 Node *n;
5372 SAVE_FLUSH_VERTICES(ctx);
5373 n = alloc_instruction(ctx, OPCODE_ATTR_1F_ARB, 2);
5374 if (n) {
5375 n[1].e = attr;
5376 n[2].f = x;
5377 }
5378
5379 ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5380 ctx->ListState.ActiveAttribSize[attr] = 1;
5381 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
5382
5383 if (ctx->ExecuteFlag) {
5384 CALL_VertexAttrib1fARB(ctx->Exec, (attr, x));
5385 }
5386 }
5387
5388 static void GLAPIENTRY
5389 save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y)
5390 {
5391 GET_CURRENT_CONTEXT(ctx);
5392 Node *n;
5393 SAVE_FLUSH_VERTICES(ctx);
5394 n = alloc_instruction(ctx, OPCODE_ATTR_2F_ARB, 3);
5395 if (n) {
5396 n[1].e = attr;
5397 n[2].f = x;
5398 n[3].f = y;
5399 }
5400
5401 ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5402 ctx->ListState.ActiveAttribSize[attr] = 2;
5403 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
5404
5405 if (ctx->ExecuteFlag) {
5406 CALL_VertexAttrib2fARB(ctx->Exec, (attr, x, y));
5407 }
5408 }
5409
5410 static void GLAPIENTRY
5411 save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
5412 {
5413 GET_CURRENT_CONTEXT(ctx);
5414 Node *n;
5415 SAVE_FLUSH_VERTICES(ctx);
5416 n = alloc_instruction(ctx, OPCODE_ATTR_3F_ARB, 4);
5417 if (n) {
5418 n[1].e = attr;
5419 n[2].f = x;
5420 n[3].f = y;
5421 n[4].f = z;
5422 }
5423
5424 ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5425 ctx->ListState.ActiveAttribSize[attr] = 3;
5426 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
5427
5428 if (ctx->ExecuteFlag) {
5429 CALL_VertexAttrib3fARB(ctx->Exec, (attr, x, y, z));
5430 }
5431 }
5432
5433 static void GLAPIENTRY
5434 save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5435 {
5436 GET_CURRENT_CONTEXT(ctx);
5437 Node *n;
5438 SAVE_FLUSH_VERTICES(ctx);
5439 n = alloc_instruction(ctx, OPCODE_ATTR_4F_ARB, 5);
5440 if (n) {
5441 n[1].e = attr;
5442 n[2].f = x;
5443 n[3].f = y;
5444 n[4].f = z;
5445 n[5].f = w;
5446 }
5447
5448 ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5449 ctx->ListState.ActiveAttribSize[attr] = 4;
5450 ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
5451
5452 if (ctx->ExecuteFlag) {
5453 CALL_VertexAttrib4fARB(ctx->Exec, (attr, x, y, z, w));
5454 }
5455 }
5456
5457
5458 static void GLAPIENTRY
5459 save_EvalCoord1f(GLfloat x)
5460 {
5461 GET_CURRENT_CONTEXT(ctx);
5462 Node *n;
5463 SAVE_FLUSH_VERTICES(ctx);
5464 n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1);
5465 if (n) {
5466 n[1].f = x;
5467 }
5468 if (ctx->ExecuteFlag) {
5469 CALL_EvalCoord1f(ctx->Exec, (x));
5470 }
5471 }
5472
5473 static void GLAPIENTRY
5474 save_EvalCoord1fv(const GLfloat * v)
5475 {
5476 save_EvalCoord1f(v[0]);
5477 }
5478
5479 static void GLAPIENTRY
5480 save_EvalCoord2f(GLfloat x, GLfloat y)
5481 {
5482 GET_CURRENT_CONTEXT(ctx);
5483 Node *n;
5484 SAVE_FLUSH_VERTICES(ctx);
5485 n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2);
5486 if (n) {
5487 n[1].f = x;
5488 n[2].f = y;
5489 }
5490 if (ctx->ExecuteFlag) {
5491 CALL_EvalCoord2f(ctx->Exec, (x, y));
5492 }
5493 }
5494
5495 static void GLAPIENTRY
5496 save_EvalCoord2fv(const GLfloat * v)
5497 {
5498 save_EvalCoord2f(v[0], v[1]);
5499 }
5500
5501
5502 static void GLAPIENTRY
5503 save_EvalPoint1(GLint x)
5504 {
5505 GET_CURRENT_CONTEXT(ctx);
5506 Node *n;
5507 SAVE_FLUSH_VERTICES(ctx);
5508 n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1);
5509 if (n) {
5510 n[1].i = x;
5511 }
5512 if (ctx->ExecuteFlag) {
5513 CALL_EvalPoint1(ctx->Exec, (x));
5514 }
5515 }
5516
5517 static void GLAPIENTRY
5518 save_EvalPoint2(GLint x, GLint y)
5519 {
5520 GET_CURRENT_CONTEXT(ctx);
5521 Node *n;
5522 SAVE_FLUSH_VERTICES(ctx);
5523 n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2);
5524 if (n) {
5525 n[1].i = x;
5526 n[2].i = y;
5527 }
5528 if (ctx->ExecuteFlag) {
5529 CALL_EvalPoint2(ctx->Exec, (x, y));
5530 }
5531 }
5532
5533 static void GLAPIENTRY
5534 save_Indexf(GLfloat x)
5535 {
5536 save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, x);
5537 }
5538
5539 static void GLAPIENTRY
5540 save_Indexfv(const GLfloat * v)
5541 {
5542 save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, v[0]);
5543 }
5544
5545 static void GLAPIENTRY
5546 save_EdgeFlag(GLboolean x)
5547 {
5548 save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? 1.0f : 0.0f);
5549 }
5550
5551
5552 /**
5553 * Compare 'count' elements of vectors 'a' and 'b'.
5554 * \return GL_TRUE if equal, GL_FALSE if different.
5555 */
5556 static inline GLboolean
5557 compare_vec(const GLfloat *a, const GLfloat *b, GLuint count)
5558 {
5559 return memcmp( a, b, count * sizeof(GLfloat) ) == 0;
5560 }
5561
5562
5563 /**
5564 * This glMaterial function is used for glMaterial calls that are outside
5565 * a glBegin/End pair. For glMaterial inside glBegin/End, see the VBO code.
5566 */
5567 static void GLAPIENTRY
5568 save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
5569 {
5570 GET_CURRENT_CONTEXT(ctx);
5571 Node *n;
5572 int args, i;
5573 GLuint bitmask;
5574
5575 switch (face) {
5576 case GL_BACK:
5577 case GL_FRONT:
5578 case GL_FRONT_AND_BACK:
5579 break;
5580 default:
5581 _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(face)");
5582 return;
5583 }
5584
5585 switch (pname) {
5586 case GL_EMISSION:
5587 case GL_AMBIENT:
5588 case GL_DIFFUSE:
5589 case GL_SPECULAR:
5590 case GL_AMBIENT_AND_DIFFUSE:
5591 args = 4;
5592 break;
5593 case GL_SHININESS:
5594 args = 1;
5595 break;
5596 case GL_COLOR_INDEXES:
5597 args = 3;
5598 break;
5599 default:
5600 _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(pname)");
5601 return;
5602 }
5603
5604 if (ctx->ExecuteFlag) {
5605 CALL_Materialfv(ctx->Exec, (face, pname, param));
5606 }
5607
5608 bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL);
5609
5610 /* Try to eliminate redundant statechanges. Because it is legal to
5611 * call glMaterial even inside begin/end calls, don't need to worry
5612 * about ctx->Driver.CurrentSavePrimitive here.
5613 */
5614 for (i = 0; i < MAT_ATTRIB_MAX; i++) {
5615 if (bitmask & (1 << i)) {
5616 if (ctx->ListState.ActiveMaterialSize[i] == args &&
5617 compare_vec(ctx->ListState.CurrentMaterial[i], param, args)) {
5618 /* no change in material value */
5619 bitmask &= ~(1 << i);
5620 }
5621 else {
5622 ctx->ListState.ActiveMaterialSize[i] = args;
5623 COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param);
5624 }
5625 }
5626 }
5627
5628 /* If this call has no effect, return early */
5629 if (bitmask == 0)
5630 return;
5631
5632 SAVE_FLUSH_VERTICES(ctx);
5633
5634 n = alloc_instruction(ctx, OPCODE_MATERIAL, 6);
5635 if (n) {
5636 n[1].e = face;
5637 n[2].e = pname;
5638 for (i = 0; i < args; i++)
5639 n[3 + i].f = param[i];
5640 }
5641 }
5642
5643 static void GLAPIENTRY
5644 save_Begin(GLenum mode)
5645 {
5646 GET_CURRENT_CONTEXT(ctx);
5647 Node *n;
5648 GLboolean error = GL_FALSE;
5649
5650 if (ctx->ExecuteFlag && !_mesa_valid_prim_mode(ctx, mode, "glBegin")) {
5651 error = GL_TRUE;
5652 }
5653 else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) {
5654 /* Typically the first begin. This may raise an error on
5655 * playback, depending on whether CallList is issued from inside
5656 * a begin/end or not.
5657 */
5658 ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM;
5659 }
5660 else if (!_mesa_inside_dlist_begin_end(ctx)) {
5661 ctx->Driver.CurrentSavePrimitive = mode;
5662 }
5663 else {
5664 _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin");
5665 error = GL_TRUE;
5666 }
5667
5668 if (!error) {
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
5682 if (ctx->ExecuteFlag) {
5683 CALL_Begin(ctx->Exec, (mode));
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 acumulated list state:
8634 */
8635 invalidate_saved_current_state( ctx );
8636
8637 /* Allocate new display list */
8638 ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE);
8639 ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head;
8640 ctx->ListState.CurrentPos = 0;
8641
8642 ctx->Driver.NewList(ctx, name, mode);
8643
8644 ctx->CurrentDispatch = ctx->Save;
8645 _glapi_set_dispatch(ctx->CurrentDispatch);
8646 }
8647
8648
8649 /**
8650 * End definition of current display list.
8651 */
8652 void GLAPIENTRY
8653 _mesa_EndList(void)
8654 {
8655 GET_CURRENT_CONTEXT(ctx);
8656 SAVE_FLUSH_VERTICES(ctx);
8657 FLUSH_VERTICES(ctx, 0);
8658
8659 if (MESA_VERBOSE & VERBOSE_API)
8660 _mesa_debug(ctx, "glEndList\n");
8661
8662 /* Check that a list is under construction */
8663 if (!ctx->ListState.CurrentList) {
8664 _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList");
8665 return;
8666 }
8667
8668 /* Call before emitting END_OF_LIST, in case the driver wants to
8669 * emit opcodes itself.
8670 */
8671 ctx->Driver.EndList(ctx);
8672
8673 (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0);
8674
8675 /* Destroy old list, if any */
8676 destroy_list(ctx, ctx->ListState.CurrentList->Name);
8677
8678 /* Install the new list */
8679 _mesa_HashInsert(ctx->Shared->DisplayList,
8680 ctx->ListState.CurrentList->Name,
8681 ctx->ListState.CurrentList);
8682
8683
8684 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
8685 mesa_print_display_list(ctx->ListState.CurrentList->Name);
8686
8687 ctx->ListState.CurrentList = NULL;
8688 ctx->ExecuteFlag = GL_TRUE;
8689 ctx->CompileFlag = GL_FALSE;
8690
8691 ctx->CurrentDispatch = ctx->Exec;
8692 _glapi_set_dispatch(ctx->CurrentDispatch);
8693 }
8694
8695
8696 void GLAPIENTRY
8697 _mesa_CallList(GLuint list)
8698 {
8699 GLboolean save_compile_flag;
8700 GET_CURRENT_CONTEXT(ctx);
8701 FLUSH_CURRENT(ctx, 0);
8702
8703 if (MESA_VERBOSE & VERBOSE_API)
8704 _mesa_debug(ctx, "glCallList %d\n", list);
8705
8706 if (list == 0) {
8707 _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)");
8708 return;
8709 }
8710
8711 if (0)
8712 mesa_print_display_list( list );
8713
8714 /* VERY IMPORTANT: Save the CompileFlag status, turn it off,
8715 * execute the display list, and restore the CompileFlag.
8716 */
8717 save_compile_flag = ctx->CompileFlag;
8718 if (save_compile_flag) {
8719 ctx->CompileFlag = GL_FALSE;
8720 }
8721
8722 execute_list(ctx, list);
8723 ctx->CompileFlag = save_compile_flag;
8724
8725 /* also restore API function pointers to point to "save" versions */
8726 if (save_compile_flag) {
8727 ctx->CurrentDispatch = ctx->Save;
8728 _glapi_set_dispatch(ctx->CurrentDispatch);
8729 }
8730 }
8731
8732
8733 /**
8734 * Execute glCallLists: call multiple display lists.
8735 */
8736 void GLAPIENTRY
8737 _mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
8738 {
8739 GET_CURRENT_CONTEXT(ctx);
8740 GLint i;
8741 GLboolean save_compile_flag;
8742
8743 if (MESA_VERBOSE & VERBOSE_API)
8744 _mesa_debug(ctx, "glCallLists %d\n", n);
8745
8746 switch (type) {
8747 case GL_BYTE:
8748 case GL_UNSIGNED_BYTE:
8749 case GL_SHORT:
8750 case GL_UNSIGNED_SHORT:
8751 case GL_INT:
8752 case GL_UNSIGNED_INT:
8753 case GL_FLOAT:
8754 case GL_2_BYTES:
8755 case GL_3_BYTES:
8756 case GL_4_BYTES:
8757 /* OK */
8758 break;
8759 default:
8760 _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
8761 return;
8762 }
8763
8764 /* Save the CompileFlag status, turn it off, execute display list,
8765 * and restore the CompileFlag.
8766 */
8767 save_compile_flag = ctx->CompileFlag;
8768 ctx->CompileFlag = GL_FALSE;
8769
8770 for (i = 0; i < n; i++) {
8771 GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists));
8772 execute_list(ctx, list);
8773 }
8774
8775 ctx->CompileFlag = save_compile_flag;
8776
8777 /* also restore API function pointers to point to "save" versions */
8778 if (save_compile_flag) {
8779 ctx->CurrentDispatch = ctx->Save;
8780 _glapi_set_dispatch(ctx->CurrentDispatch);
8781 }
8782 }
8783
8784
8785 /**
8786 * Set the offset added to list numbers in glCallLists.
8787 */
8788 void GLAPIENTRY
8789 _mesa_ListBase(GLuint base)
8790 {
8791 GET_CURRENT_CONTEXT(ctx);
8792 FLUSH_VERTICES(ctx, 0); /* must be called before assert */
8793 ASSERT_OUTSIDE_BEGIN_END(ctx);
8794 ctx->List.ListBase = base;
8795 }
8796
8797 /**
8798 * Setup the given dispatch table to point to Mesa's display list
8799 * building functions.
8800 *
8801 * This does not include any of the tnl functions - they are
8802 * initialized from _mesa_init_api_defaults and from the active vtxfmt
8803 * struct.
8804 */
8805 void
8806 _mesa_initialize_save_table(const struct gl_context *ctx)
8807 {
8808 struct _glapi_table *table = ctx->Save;
8809 int numEntries = MAX2(_gloffset_COUNT, _glapi_get_dispatch_table_size());
8810
8811 /* Initially populate the dispatch table with the contents of the
8812 * normal-execution dispatch table. This lets us skip populating functions
8813 * that should be called directly instead of compiled into display lists.
8814 */
8815 memcpy(table, ctx->Exec, numEntries * sizeof(_glapi_proc));
8816
8817 _mesa_loopback_init_api_table(ctx, table);
8818
8819 /* GL 1.0 */
8820 SET_Accum(table, save_Accum);
8821 SET_AlphaFunc(table, save_AlphaFunc);
8822 SET_Bitmap(table, save_Bitmap);
8823 SET_BlendFunc(table, save_BlendFunc);
8824 SET_CallList(table, save_CallList);
8825 SET_CallLists(table, save_CallLists);
8826 SET_Clear(table, save_Clear);
8827 SET_ClearAccum(table, save_ClearAccum);
8828 SET_ClearColor(table, save_ClearColor);
8829 SET_ClearDepth(table, save_ClearDepth);
8830 SET_ClearIndex(table, save_ClearIndex);
8831 SET_ClearStencil(table, save_ClearStencil);
8832 SET_ClipPlane(table, save_ClipPlane);
8833 SET_ColorMask(table, save_ColorMask);
8834 SET_ColorMaski(table, save_ColorMaskIndexed);
8835 SET_ColorMaterial(table, save_ColorMaterial);
8836 SET_CopyPixels(table, save_CopyPixels);
8837 SET_CullFace(table, save_CullFace);
8838 SET_DepthFunc(table, save_DepthFunc);
8839 SET_DepthMask(table, save_DepthMask);
8840 SET_DepthRange(table, save_DepthRange);
8841 SET_Disable(table, save_Disable);
8842 SET_Disablei(table, save_DisableIndexed);
8843 SET_DrawBuffer(table, save_DrawBuffer);
8844 SET_DrawPixels(table, save_DrawPixels);
8845 SET_Enable(table, save_Enable);
8846 SET_Enablei(table, save_EnableIndexed);
8847 SET_EvalMesh1(table, save_EvalMesh1);
8848 SET_EvalMesh2(table, save_EvalMesh2);
8849 SET_Fogf(table, save_Fogf);
8850 SET_Fogfv(table, save_Fogfv);
8851 SET_Fogi(table, save_Fogi);
8852 SET_Fogiv(table, save_Fogiv);
8853 SET_FrontFace(table, save_FrontFace);
8854 SET_Frustum(table, save_Frustum);
8855 SET_Hint(table, save_Hint);
8856 SET_IndexMask(table, save_IndexMask);
8857 SET_InitNames(table, save_InitNames);
8858 SET_LightModelf(table, save_LightModelf);
8859 SET_LightModelfv(table, save_LightModelfv);
8860 SET_LightModeli(table, save_LightModeli);
8861 SET_LightModeliv(table, save_LightModeliv);
8862 SET_Lightf(table, save_Lightf);
8863 SET_Lightfv(table, save_Lightfv);
8864 SET_Lighti(table, save_Lighti);
8865 SET_Lightiv(table, save_Lightiv);
8866 SET_LineStipple(table, save_LineStipple);
8867 SET_LineWidth(table, save_LineWidth);
8868 SET_ListBase(table, save_ListBase);
8869 SET_LoadIdentity(table, save_LoadIdentity);
8870 SET_LoadMatrixd(table, save_LoadMatrixd);
8871 SET_LoadMatrixf(table, save_LoadMatrixf);
8872 SET_LoadName(table, save_LoadName);
8873 SET_LogicOp(table, save_LogicOp);
8874 SET_Map1d(table, save_Map1d);
8875 SET_Map1f(table, save_Map1f);
8876 SET_Map2d(table, save_Map2d);
8877 SET_Map2f(table, save_Map2f);
8878 SET_MapGrid1d(table, save_MapGrid1d);
8879 SET_MapGrid1f(table, save_MapGrid1f);
8880 SET_MapGrid2d(table, save_MapGrid2d);
8881 SET_MapGrid2f(table, save_MapGrid2f);
8882 SET_MatrixMode(table, save_MatrixMode);
8883 SET_MultMatrixd(table, save_MultMatrixd);
8884 SET_MultMatrixf(table, save_MultMatrixf);
8885 SET_NewList(table, save_NewList);
8886 SET_Ortho(table, save_Ortho);
8887 SET_PassThrough(table, save_PassThrough);
8888 SET_PixelMapfv(table, save_PixelMapfv);
8889 SET_PixelMapuiv(table, save_PixelMapuiv);
8890 SET_PixelMapusv(table, save_PixelMapusv);
8891 SET_PixelTransferf(table, save_PixelTransferf);
8892 SET_PixelTransferi(table, save_PixelTransferi);
8893 SET_PixelZoom(table, save_PixelZoom);
8894 SET_PointSize(table, save_PointSize);
8895 SET_PolygonMode(table, save_PolygonMode);
8896 SET_PolygonOffset(table, save_PolygonOffset);
8897 SET_PolygonStipple(table, save_PolygonStipple);
8898 SET_PopAttrib(table, save_PopAttrib);
8899 SET_PopMatrix(table, save_PopMatrix);
8900 SET_PopName(table, save_PopName);
8901 SET_PushAttrib(table, save_PushAttrib);
8902 SET_PushMatrix(table, save_PushMatrix);
8903 SET_PushName(table, save_PushName);
8904 SET_RasterPos2d(table, save_RasterPos2d);
8905 SET_RasterPos2dv(table, save_RasterPos2dv);
8906 SET_RasterPos2f(table, save_RasterPos2f);
8907 SET_RasterPos2fv(table, save_RasterPos2fv);
8908 SET_RasterPos2i(table, save_RasterPos2i);
8909 SET_RasterPos2iv(table, save_RasterPos2iv);
8910 SET_RasterPos2s(table, save_RasterPos2s);
8911 SET_RasterPos2sv(table, save_RasterPos2sv);
8912 SET_RasterPos3d(table, save_RasterPos3d);
8913 SET_RasterPos3dv(table, save_RasterPos3dv);
8914 SET_RasterPos3f(table, save_RasterPos3f);
8915 SET_RasterPos3fv(table, save_RasterPos3fv);
8916 SET_RasterPos3i(table, save_RasterPos3i);
8917 SET_RasterPos3iv(table, save_RasterPos3iv);
8918 SET_RasterPos3s(table, save_RasterPos3s);
8919 SET_RasterPos3sv(table, save_RasterPos3sv);
8920 SET_RasterPos4d(table, save_RasterPos4d);
8921 SET_RasterPos4dv(table, save_RasterPos4dv);
8922 SET_RasterPos4f(table, save_RasterPos4f);
8923 SET_RasterPos4fv(table, save_RasterPos4fv);
8924 SET_RasterPos4i(table, save_RasterPos4i);
8925 SET_RasterPos4iv(table, save_RasterPos4iv);
8926 SET_RasterPos4s(table, save_RasterPos4s);
8927 SET_RasterPos4sv(table, save_RasterPos4sv);
8928 SET_ReadBuffer(table, save_ReadBuffer);
8929 SET_Rotated(table, save_Rotated);
8930 SET_Rotatef(table, save_Rotatef);
8931 SET_Scaled(table, save_Scaled);
8932 SET_Scalef(table, save_Scalef);
8933 SET_Scissor(table, save_Scissor);
8934 SET_ShadeModel(table, save_ShadeModel);
8935 SET_StencilFunc(table, save_StencilFunc);
8936 SET_StencilMask(table, save_StencilMask);
8937 SET_StencilOp(table, save_StencilOp);
8938 SET_TexEnvf(table, save_TexEnvf);
8939 SET_TexEnvfv(table, save_TexEnvfv);
8940 SET_TexEnvi(table, save_TexEnvi);
8941 SET_TexEnviv(table, save_TexEnviv);
8942 SET_TexGend(table, save_TexGend);
8943 SET_TexGendv(table, save_TexGendv);
8944 SET_TexGenf(table, save_TexGenf);
8945 SET_TexGenfv(table, save_TexGenfv);
8946 SET_TexGeni(table, save_TexGeni);
8947 SET_TexGeniv(table, save_TexGeniv);
8948 SET_TexImage1D(table, save_TexImage1D);
8949 SET_TexImage2D(table, save_TexImage2D);
8950 SET_TexParameterf(table, save_TexParameterf);
8951 SET_TexParameterfv(table, save_TexParameterfv);
8952 SET_TexParameteri(table, save_TexParameteri);
8953 SET_TexParameteriv(table, save_TexParameteriv);
8954 SET_Translated(table, save_Translated);
8955 SET_Translatef(table, save_Translatef);
8956 SET_Viewport(table, save_Viewport);
8957
8958 /* GL 1.1 */
8959 SET_BindTexture(table, save_BindTexture);
8960 SET_CopyTexImage1D(table, save_CopyTexImage1D);
8961 SET_CopyTexImage2D(table, save_CopyTexImage2D);
8962 SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D);
8963 SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D);
8964 SET_PrioritizeTextures(table, save_PrioritizeTextures);
8965 SET_TexSubImage1D(table, save_TexSubImage1D);
8966 SET_TexSubImage2D(table, save_TexSubImage2D);
8967
8968 /* GL 1.2 */
8969 SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D);
8970 SET_TexImage3D(table, save_TexImage3D);
8971 SET_TexSubImage3D(table, save_TexSubImage3D);
8972
8973 /* GL 2.0 */
8974 SET_StencilFuncSeparate(table, save_StencilFuncSeparate);
8975 SET_StencilMaskSeparate(table, save_StencilMaskSeparate);
8976 SET_StencilOpSeparate(table, save_StencilOpSeparate);
8977
8978 /* ATI_separate_stencil */
8979 SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI);
8980
8981 /* GL_ARB_imaging */
8982 /* Not all are supported */
8983 SET_BlendColor(table, save_BlendColor);
8984 SET_BlendEquation(table, save_BlendEquation);
8985 SET_ColorSubTable(table, save_ColorSubTable);
8986 SET_ColorTable(table, save_ColorTable);
8987 SET_ColorTableParameterfv(table, save_ColorTableParameterfv);
8988 SET_ColorTableParameteriv(table, save_ColorTableParameteriv);
8989 SET_ConvolutionFilter1D(table, save_ConvolutionFilter1D);
8990 SET_ConvolutionFilter2D(table, save_ConvolutionFilter2D);
8991 SET_ConvolutionParameterf(table, save_ConvolutionParameterf);
8992 SET_ConvolutionParameterfv(table, save_ConvolutionParameterfv);
8993 SET_ConvolutionParameteri(table, save_ConvolutionParameteri);
8994 SET_ConvolutionParameteriv(table, save_ConvolutionParameteriv);
8995 SET_CopyColorSubTable(table, save_CopyColorSubTable);
8996 SET_CopyColorTable(table, save_CopyColorTable);
8997 SET_Histogram(table, save_Histogram);
8998 SET_Minmax(table, save_Minmax);
8999 SET_ResetHistogram(table, save_ResetHistogram);
9000 SET_ResetMinmax(table, save_ResetMinmax);
9001
9002 /* 2. GL_EXT_blend_color */
9003 #if 0
9004 SET_BlendColorEXT(table, save_BlendColorEXT);
9005 #endif
9006
9007 /* 3. GL_EXT_polygon_offset */
9008 SET_PolygonOffsetEXT(table, save_PolygonOffsetEXT);
9009
9010 /* 6. GL_EXT_texture3d */
9011 #if 0
9012 SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D);
9013 SET_TexImage3DEXT(table, save_TexImage3DEXT);
9014 SET_TexSubImage3DEXT(table, save_TexSubImage3D);
9015 #endif
9016
9017 /* 14. GL_SGI_color_table */
9018 #if 0
9019 SET_ColorTableSGI(table, save_ColorTable);
9020 SET_ColorSubTableSGI(table, save_ColorSubTable);
9021 #endif
9022
9023 /* 37. GL_EXT_blend_minmax */
9024 #if 0
9025 SET_BlendEquationEXT(table, save_BlendEquationEXT);
9026 #endif
9027
9028 /* 54. GL_EXT_point_parameters */
9029 SET_PointParameterf(table, save_PointParameterfEXT);
9030 SET_PointParameterfv(table, save_PointParameterfvEXT);
9031
9032 /* 173. GL_EXT_blend_func_separate */
9033 SET_BlendFuncSeparate(table, save_BlendFuncSeparateEXT);
9034
9035 /* 197. GL_MESA_window_pos */
9036 SET_WindowPos2d(table, save_WindowPos2dMESA);
9037 SET_WindowPos2dv(table, save_WindowPos2dvMESA);
9038 SET_WindowPos2f(table, save_WindowPos2fMESA);
9039 SET_WindowPos2fv(table, save_WindowPos2fvMESA);
9040 SET_WindowPos2i(table, save_WindowPos2iMESA);
9041 SET_WindowPos2iv(table, save_WindowPos2ivMESA);
9042 SET_WindowPos2s(table, save_WindowPos2sMESA);
9043 SET_WindowPos2sv(table, save_WindowPos2svMESA);
9044 SET_WindowPos3d(table, save_WindowPos3dMESA);
9045 SET_WindowPos3dv(table, save_WindowPos3dvMESA);
9046 SET_WindowPos3f(table, save_WindowPos3fMESA);
9047 SET_WindowPos3fv(table, save_WindowPos3fvMESA);
9048 SET_WindowPos3i(table, save_WindowPos3iMESA);
9049 SET_WindowPos3iv(table, save_WindowPos3ivMESA);
9050 SET_WindowPos3s(table, save_WindowPos3sMESA);
9051 SET_WindowPos3sv(table, save_WindowPos3svMESA);
9052 SET_WindowPos4dMESA(table, save_WindowPos4dMESA);
9053 SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA);
9054 SET_WindowPos4fMESA(table, save_WindowPos4fMESA);
9055 SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA);
9056 SET_WindowPos4iMESA(table, save_WindowPos4iMESA);
9057 SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA);
9058 SET_WindowPos4sMESA(table, save_WindowPos4sMESA);
9059 SET_WindowPos4svMESA(table, save_WindowPos4svMESA);
9060
9061 /* 233. GL_NV_vertex_program */
9062 /* The following commands DO NOT go into display lists:
9063 * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV,
9064 * VertexAttribPointerNV, GetProgram*, GetVertexAttrib*
9065 */
9066 SET_BindProgramARB(table, save_BindProgramNV);
9067
9068 /* 244. GL_ATI_envmap_bumpmap */
9069 SET_TexBumpParameterivATI(table, save_TexBumpParameterivATI);
9070 SET_TexBumpParameterfvATI(table, save_TexBumpParameterfvATI);
9071
9072 /* 245. GL_ATI_fragment_shader */
9073 SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI);
9074 SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI);
9075
9076 /* 262. GL_NV_point_sprite */
9077 SET_PointParameteri(table, save_PointParameteriNV);
9078 SET_PointParameteriv(table, save_PointParameterivNV);
9079
9080 /* 268. GL_EXT_stencil_two_side */
9081 SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT);
9082
9083 /* ???. GL_EXT_depth_bounds_test */
9084 SET_DepthBoundsEXT(table, save_DepthBoundsEXT);
9085
9086 /* ARB 1. GL_ARB_multitexture */
9087 SET_ActiveTexture(table, save_ActiveTextureARB);
9088
9089 /* ARB 3. GL_ARB_transpose_matrix */
9090 SET_LoadTransposeMatrixd(table, save_LoadTransposeMatrixdARB);
9091 SET_LoadTransposeMatrixf(table, save_LoadTransposeMatrixfARB);
9092 SET_MultTransposeMatrixd(table, save_MultTransposeMatrixdARB);
9093 SET_MultTransposeMatrixf(table, save_MultTransposeMatrixfARB);
9094
9095 /* ARB 5. GL_ARB_multisample */
9096 SET_SampleCoverage(table, save_SampleCoverageARB);
9097
9098 /* ARB 12. GL_ARB_texture_compression */
9099 SET_CompressedTexImage3D(table, save_CompressedTexImage3DARB);
9100 SET_CompressedTexImage2D(table, save_CompressedTexImage2DARB);
9101 SET_CompressedTexImage1D(table, save_CompressedTexImage1DARB);
9102 SET_CompressedTexSubImage3D(table, save_CompressedTexSubImage3DARB);
9103 SET_CompressedTexSubImage2D(table, save_CompressedTexSubImage2DARB);
9104 SET_CompressedTexSubImage1D(table, save_CompressedTexSubImage1DARB);
9105
9106 /* ARB 14. GL_ARB_point_parameters */
9107 /* aliased with EXT_point_parameters functions */
9108
9109 /* ARB 25. GL_ARB_window_pos */
9110 /* aliased with MESA_window_pos functions */
9111
9112 /* ARB 26. GL_ARB_vertex_program */
9113 /* ARB 27. GL_ARB_fragment_program */
9114 /* glVertexAttrib* functions alias the NV ones, handled elsewhere */
9115 SET_ProgramStringARB(table, save_ProgramStringARB);
9116 SET_BindProgramARB(table, save_BindProgramNV);
9117 SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB);
9118 SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB);
9119 SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB);
9120 SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB);
9121 SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB);
9122 SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB);
9123 SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB);
9124 SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB);
9125
9126 SET_BeginQuery(table, save_BeginQueryARB);
9127 SET_EndQuery(table, save_EndQueryARB);
9128 SET_QueryCounter(table, save_QueryCounter);
9129
9130 SET_DrawBuffers(table, save_DrawBuffersARB);
9131
9132 SET_BlitFramebuffer(table, save_BlitFramebufferEXT);
9133
9134 SET_UseProgram(table, save_UseProgramObjectARB);
9135 SET_Uniform1f(table, save_Uniform1fARB);
9136 SET_Uniform2f(table, save_Uniform2fARB);
9137 SET_Uniform3f(table, save_Uniform3fARB);
9138 SET_Uniform4f(table, save_Uniform4fARB);
9139 SET_Uniform1fv(table, save_Uniform1fvARB);
9140 SET_Uniform2fv(table, save_Uniform2fvARB);
9141 SET_Uniform3fv(table, save_Uniform3fvARB);
9142 SET_Uniform4fv(table, save_Uniform4fvARB);
9143 SET_Uniform1i(table, save_Uniform1iARB);
9144 SET_Uniform2i(table, save_Uniform2iARB);
9145 SET_Uniform3i(table, save_Uniform3iARB);
9146 SET_Uniform4i(table, save_Uniform4iARB);
9147 SET_Uniform1iv(table, save_Uniform1ivARB);
9148 SET_Uniform2iv(table, save_Uniform2ivARB);
9149 SET_Uniform3iv(table, save_Uniform3ivARB);
9150 SET_Uniform4iv(table, save_Uniform4ivARB);
9151 SET_UniformMatrix2fv(table, save_UniformMatrix2fvARB);
9152 SET_UniformMatrix3fv(table, save_UniformMatrix3fvARB);
9153 SET_UniformMatrix4fv(table, save_UniformMatrix4fvARB);
9154 SET_UniformMatrix2x3fv(table, save_UniformMatrix2x3fv);
9155 SET_UniformMatrix3x2fv(table, save_UniformMatrix3x2fv);
9156 SET_UniformMatrix2x4fv(table, save_UniformMatrix2x4fv);
9157 SET_UniformMatrix4x2fv(table, save_UniformMatrix4x2fv);
9158 SET_UniformMatrix3x4fv(table, save_UniformMatrix3x4fv);
9159 SET_UniformMatrix4x3fv(table, save_UniformMatrix4x3fv);
9160
9161 /* 299. GL_EXT_blend_equation_separate */
9162 SET_BlendEquationSeparate(table, save_BlendEquationSeparateEXT);
9163
9164 /* GL_EXT_gpu_program_parameters */
9165 SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT);
9166 SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT);
9167
9168 /* 364. GL_EXT_provoking_vertex */
9169 SET_ProvokingVertex(table, save_ProvokingVertexEXT);
9170
9171 /* GL_EXT_texture_integer */
9172 SET_ClearColorIiEXT(table, save_ClearColorIi);
9173 SET_ClearColorIuiEXT(table, save_ClearColorIui);
9174 SET_TexParameterIiv(table, save_TexParameterIiv);
9175 SET_TexParameterIuiv(table, save_TexParameterIuiv);
9176
9177 /* 377. GL_EXT_separate_shader_objects */
9178 SET_UseShaderProgramEXT(table, save_UseShaderProgramEXT);
9179 SET_ActiveProgramEXT(table, save_ActiveProgramEXT);
9180
9181 /* GL_ARB_color_buffer_float */
9182 SET_ClampColor(table, save_ClampColorARB);
9183
9184 /* GL 3.0 */
9185 SET_ClearBufferiv(table, save_ClearBufferiv);
9186 SET_ClearBufferuiv(table, save_ClearBufferuiv);
9187 SET_ClearBufferfv(table, save_ClearBufferfv);
9188 SET_ClearBufferfi(table, save_ClearBufferfi);
9189 #if 0
9190 SET_Uniform1ui(table, save_Uniform1ui);
9191 SET_Uniform2ui(table, save_Uniform2ui);
9192 SET_Uniform3ui(table, save_Uniform3ui);
9193 SET_Uniform4ui(table, save_Uniform4ui);
9194 SET_Uniform1uiv(table, save_Uniform1uiv);
9195 SET_Uniform2uiv(table, save_Uniform2uiv);
9196 SET_Uniform3uiv(table, save_Uniform3uiv);
9197 SET_Uniform4uiv(table, save_Uniform4uiv);
9198 #else
9199 (void) save_Uniform1ui;
9200 (void) save_Uniform2ui;
9201 (void) save_Uniform3ui;
9202 (void) save_Uniform4ui;
9203 (void) save_Uniform1uiv;
9204 (void) save_Uniform2uiv;
9205 (void) save_Uniform3uiv;
9206 (void) save_Uniform4uiv;
9207 #endif
9208
9209 /* These are: */
9210 SET_BeginTransformFeedback(table, save_BeginTransformFeedback);
9211 SET_EndTransformFeedback(table, save_EndTransformFeedback);
9212 SET_BindTransformFeedback(table, save_BindTransformFeedback);
9213 SET_PauseTransformFeedback(table, save_PauseTransformFeedback);
9214 SET_ResumeTransformFeedback(table, save_ResumeTransformFeedback);
9215 SET_DrawTransformFeedback(table, save_DrawTransformFeedback);
9216 SET_DrawTransformFeedbackStream(table, save_DrawTransformFeedbackStream);
9217 SET_DrawTransformFeedbackInstanced(table,
9218 save_DrawTransformFeedbackInstanced);
9219 SET_DrawTransformFeedbackStreamInstanced(table,
9220 save_DrawTransformFeedbackStreamInstanced);
9221 SET_BeginQueryIndexed(table, save_BeginQueryIndexed);
9222 SET_EndQueryIndexed(table, save_EndQueryIndexed);
9223
9224 /* GL_ARB_instanced_arrays */
9225 SET_VertexAttribDivisor(table, save_VertexAttribDivisor);
9226
9227 /* GL_NV_texture_barrier */
9228 SET_TextureBarrierNV(table, save_TextureBarrierNV);
9229
9230 SET_BindSampler(table, save_BindSampler);
9231 SET_SamplerParameteri(table, save_SamplerParameteri);
9232 SET_SamplerParameterf(table, save_SamplerParameterf);
9233 SET_SamplerParameteriv(table, save_SamplerParameteriv);
9234 SET_SamplerParameterfv(table, save_SamplerParameterfv);
9235 SET_SamplerParameterIiv(table, save_SamplerParameterIiv);
9236 SET_SamplerParameterIuiv(table, save_SamplerParameterIuiv);
9237
9238 /* GL_ARB_draw_buffer_blend */
9239 SET_BlendFunciARB(table, save_BlendFunci);
9240 SET_BlendFuncSeparateiARB(table, save_BlendFuncSeparatei);
9241 SET_BlendEquationiARB(table, save_BlendEquationi);
9242 SET_BlendEquationSeparateiARB(table, save_BlendEquationSeparatei);
9243
9244 /* GL_ARB_geometry_shader4 */
9245 SET_ProgramParameteri(table, save_ProgramParameteri);
9246 SET_FramebufferTexture(table, save_FramebufferTexture);
9247 SET_FramebufferTextureFaceARB(table, save_FramebufferTextureFace);
9248
9249 /* GL_NV_conditional_render */
9250 SET_BeginConditionalRender(table, save_BeginConditionalRender);
9251 SET_EndConditionalRender(table, save_EndConditionalRender);
9252
9253 /* GL_ARB_sync */
9254 SET_WaitSync(table, save_WaitSync);
9255
9256 /* GL_ARB_uniform_buffer_object */
9257 SET_UniformBlockBinding(table, save_UniformBlockBinding);
9258 }
9259
9260
9261
9262 static const char *
9263 enum_string(GLenum k)
9264 {
9265 return _mesa_lookup_enum_by_nr(k);
9266 }
9267
9268
9269 /**
9270 * Print the commands in a display list. For debugging only.
9271 * TODO: many commands aren't handled yet.
9272 */
9273 static void GLAPIENTRY
9274 print_list(struct gl_context *ctx, GLuint list)
9275 {
9276 struct gl_display_list *dlist;
9277 Node *n;
9278 GLboolean done;
9279
9280 if (!islist(ctx, list)) {
9281 printf("%u is not a display list ID\n", list);
9282 return;
9283 }
9284
9285 dlist = lookup_list(ctx, list);
9286 if (!dlist)
9287 return;
9288
9289 n = dlist->Head;
9290
9291 printf("START-LIST %u, address %p\n", list, (void *) n);
9292
9293 done = n ? GL_FALSE : GL_TRUE;
9294 while (!done) {
9295 const OpCode opcode = n[0].opcode;
9296
9297 if (is_ext_opcode(opcode)) {
9298 n += ext_opcode_print(ctx, n);
9299 }
9300 else {
9301 switch (opcode) {
9302 case OPCODE_ACCUM:
9303 printf("Accum %s %g\n", enum_string(n[1].e), n[2].f);
9304 break;
9305 case OPCODE_BITMAP:
9306 printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
9307 n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data);
9308 break;
9309 case OPCODE_CALL_LIST:
9310 printf("CallList %d\n", (int) n[1].ui);
9311 break;
9312 case OPCODE_CALL_LIST_OFFSET:
9313 printf("CallList %d + offset %u = %u\n", (int) n[1].ui,
9314 ctx->List.ListBase, ctx->List.ListBase + n[1].ui);
9315 break;
9316 case OPCODE_COLOR_TABLE_PARAMETER_FV:
9317 printf("ColorTableParameterfv %s %s %f %f %f %f\n",
9318 enum_string(n[1].e), enum_string(n[2].e),
9319 n[3].f, n[4].f, n[5].f, n[6].f);
9320 break;
9321 case OPCODE_COLOR_TABLE_PARAMETER_IV:
9322 printf("ColorTableParameteriv %s %s %d %d %d %d\n",
9323 enum_string(n[1].e), enum_string(n[2].e),
9324 n[3].i, n[4].i, n[5].i, n[6].i);
9325 break;
9326 case OPCODE_DISABLE:
9327 printf("Disable %s\n", enum_string(n[1].e));
9328 break;
9329 case OPCODE_ENABLE:
9330 printf("Enable %s\n", enum_string(n[1].e));
9331 break;
9332 case OPCODE_FRUSTUM:
9333 printf("Frustum %g %g %g %g %g %g\n",
9334 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
9335 break;
9336 case OPCODE_LINE_STIPPLE:
9337 printf("LineStipple %d %x\n", n[1].i, (int) n[2].us);
9338 break;
9339 case OPCODE_LOAD_IDENTITY:
9340 printf("LoadIdentity\n");
9341 break;
9342 case OPCODE_LOAD_MATRIX:
9343 printf("LoadMatrix\n");
9344 printf(" %8f %8f %8f %8f\n",
9345 n[1].f, n[5].f, n[9].f, n[13].f);
9346 printf(" %8f %8f %8f %8f\n",
9347 n[2].f, n[6].f, n[10].f, n[14].f);
9348 printf(" %8f %8f %8f %8f\n",
9349 n[3].f, n[7].f, n[11].f, n[15].f);
9350 printf(" %8f %8f %8f %8f\n",
9351 n[4].f, n[8].f, n[12].f, n[16].f);
9352 break;
9353 case OPCODE_MULT_MATRIX:
9354 printf("MultMatrix (or Rotate)\n");
9355 printf(" %8f %8f %8f %8f\n",
9356 n[1].f, n[5].f, n[9].f, n[13].f);
9357 printf(" %8f %8f %8f %8f\n",
9358 n[2].f, n[6].f, n[10].f, n[14].f);
9359 printf(" %8f %8f %8f %8f\n",
9360 n[3].f, n[7].f, n[11].f, n[15].f);
9361 printf(" %8f %8f %8f %8f\n",
9362 n[4].f, n[8].f, n[12].f, n[16].f);
9363 break;
9364 case OPCODE_ORTHO:
9365 printf("Ortho %g %g %g %g %g %g\n",
9366 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
9367 break;
9368 case OPCODE_POP_ATTRIB:
9369 printf("PopAttrib\n");
9370 break;
9371 case OPCODE_POP_MATRIX:
9372 printf("PopMatrix\n");
9373 break;
9374 case OPCODE_POP_NAME:
9375 printf("PopName\n");
9376 break;
9377 case OPCODE_PUSH_ATTRIB:
9378 printf("PushAttrib %x\n", n[1].bf);
9379 break;
9380 case OPCODE_PUSH_MATRIX:
9381 printf("PushMatrix\n");
9382 break;
9383 case OPCODE_PUSH_NAME:
9384 printf("PushName %d\n", (int) n[1].ui);
9385 break;
9386 case OPCODE_RASTER_POS:
9387 printf("RasterPos %g %g %g %g\n",
9388 n[1].f, n[2].f, n[3].f, n[4].f);
9389 break;
9390 case OPCODE_ROTATE:
9391 printf("Rotate %g %g %g %g\n",
9392 n[1].f, n[2].f, n[3].f, n[4].f);
9393 break;
9394 case OPCODE_SCALE:
9395 printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f);
9396 break;
9397 case OPCODE_TRANSLATE:
9398 printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f);
9399 break;
9400 case OPCODE_BIND_TEXTURE:
9401 printf("BindTexture %s %d\n",
9402 _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui);
9403 break;
9404 case OPCODE_SHADE_MODEL:
9405 printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui));
9406 break;
9407 case OPCODE_MAP1:
9408 printf("Map1 %s %.3f %.3f %d %d\n",
9409 _mesa_lookup_enum_by_nr(n[1].ui),
9410 n[2].f, n[3].f, n[4].i, n[5].i);
9411 break;
9412 case OPCODE_MAP2:
9413 printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
9414 _mesa_lookup_enum_by_nr(n[1].ui),
9415 n[2].f, n[3].f, n[4].f, n[5].f,
9416 n[6].i, n[7].i, n[8].i, n[9].i);
9417 break;
9418 case OPCODE_MAPGRID1:
9419 printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f);
9420 break;
9421 case OPCODE_MAPGRID2:
9422 printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
9423 n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
9424 break;
9425 case OPCODE_EVALMESH1:
9426 printf("EvalMesh1 %d %d\n", n[1].i, n[2].i);
9427 break;
9428 case OPCODE_EVALMESH2:
9429 printf("EvalMesh2 %d %d %d %d\n",
9430 n[1].i, n[2].i, n[3].i, n[4].i);
9431 break;
9432
9433 case OPCODE_ATTR_1F_NV:
9434 printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f);
9435 break;
9436 case OPCODE_ATTR_2F_NV:
9437 printf("ATTR_2F_NV attr %d: %f %f\n",
9438 n[1].i, n[2].f, n[3].f);
9439 break;
9440 case OPCODE_ATTR_3F_NV:
9441 printf("ATTR_3F_NV attr %d: %f %f %f\n",
9442 n[1].i, n[2].f, n[3].f, n[4].f);
9443 break;
9444 case OPCODE_ATTR_4F_NV:
9445 printf("ATTR_4F_NV attr %d: %f %f %f %f\n",
9446 n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
9447 break;
9448 case OPCODE_ATTR_1F_ARB:
9449 printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f);
9450 break;
9451 case OPCODE_ATTR_2F_ARB:
9452 printf("ATTR_2F_ARB attr %d: %f %f\n",
9453 n[1].i, n[2].f, n[3].f);
9454 break;
9455 case OPCODE_ATTR_3F_ARB:
9456 printf("ATTR_3F_ARB attr %d: %f %f %f\n",
9457 n[1].i, n[2].f, n[3].f, n[4].f);
9458 break;
9459 case OPCODE_ATTR_4F_ARB:
9460 printf("ATTR_4F_ARB attr %d: %f %f %f %f\n",
9461 n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
9462 break;
9463
9464 case OPCODE_MATERIAL:
9465 printf("MATERIAL %x %x: %f %f %f %f\n",
9466 n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f);
9467 break;
9468 case OPCODE_BEGIN:
9469 printf("BEGIN %x\n", n[1].i);
9470 break;
9471 case OPCODE_END:
9472 printf("END\n");
9473 break;
9474 case OPCODE_RECTF:
9475 printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f,
9476 n[4].f);
9477 break;
9478 case OPCODE_EVAL_C1:
9479 printf("EVAL_C1 %f\n", n[1].f);
9480 break;
9481 case OPCODE_EVAL_C2:
9482 printf("EVAL_C2 %f %f\n", n[1].f, n[2].f);
9483 break;
9484 case OPCODE_EVAL_P1:
9485 printf("EVAL_P1 %d\n", n[1].i);
9486 break;
9487 case OPCODE_EVAL_P2:
9488 printf("EVAL_P2 %d %d\n", n[1].i, n[2].i);
9489 break;
9490
9491 case OPCODE_PROVOKING_VERTEX:
9492 printf("ProvokingVertex %s\n",
9493 _mesa_lookup_enum_by_nr(n[1].ui));
9494 break;
9495
9496 /*
9497 * meta opcodes/commands
9498 */
9499 case OPCODE_ERROR:
9500 printf("Error: %s %s\n",
9501 enum_string(n[1].e), (const char *) n[2].data);
9502 break;
9503 case OPCODE_CONTINUE:
9504 printf("DISPLAY-LIST-CONTINUE\n");
9505 n = (Node *) n[1].next;
9506 break;
9507 case OPCODE_END_OF_LIST:
9508 printf("END-LIST %u\n", list);
9509 done = GL_TRUE;
9510 break;
9511 default:
9512 if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
9513 printf
9514 ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
9515 opcode, (void *) n);
9516 return;
9517 }
9518 else {
9519 printf("command %d, %u operands\n", opcode,
9520 InstSize[opcode]);
9521 }
9522 }
9523 /* increment n to point to next compiled command */
9524 if (opcode != OPCODE_CONTINUE) {
9525 n += InstSize[opcode];
9526 }
9527 }
9528 }
9529 }
9530
9531
9532
9533 /**
9534 * Clients may call this function to help debug display list problems.
9535 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
9536 * changed, or break in the future without notice.
9537 */
9538 void
9539 mesa_print_display_list(GLuint list)
9540 {
9541 GET_CURRENT_CONTEXT(ctx);
9542 print_list(ctx, list);
9543 }
9544
9545
9546 /**********************************************************************/
9547 /***** Initialization *****/
9548 /**********************************************************************/
9549
9550 static void
9551 save_vtxfmt_init(GLvertexformat * vfmt)
9552 {
9553 _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_);
9554
9555 vfmt->Begin = save_Begin;
9556
9557 _MESA_INIT_DLIST_VTXFMT(vfmt, save_);
9558
9559 vfmt->Color3f = save_Color3f;
9560 vfmt->Color3fv = save_Color3fv;
9561 vfmt->Color4f = save_Color4f;
9562 vfmt->Color4fv = save_Color4fv;
9563 vfmt->EdgeFlag = save_EdgeFlag;
9564 vfmt->End = save_End;
9565
9566 _MESA_INIT_EVAL_VTXFMT(vfmt, save_);
9567
9568 vfmt->FogCoordfEXT = save_FogCoordfEXT;
9569 vfmt->FogCoordfvEXT = save_FogCoordfvEXT;
9570 vfmt->Indexf = save_Indexf;
9571 vfmt->Indexfv = save_Indexfv;
9572 vfmt->Materialfv = save_Materialfv;
9573 vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f;
9574 vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv;
9575 vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f;
9576 vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv;
9577 vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f;
9578 vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv;
9579 vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f;
9580 vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv;
9581 vfmt->Normal3f = save_Normal3f;
9582 vfmt->Normal3fv = save_Normal3fv;
9583 vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT;
9584 vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT;
9585 vfmt->TexCoord1f = save_TexCoord1f;
9586 vfmt->TexCoord1fv = save_TexCoord1fv;
9587 vfmt->TexCoord2f = save_TexCoord2f;
9588 vfmt->TexCoord2fv = save_TexCoord2fv;
9589 vfmt->TexCoord3f = save_TexCoord3f;
9590 vfmt->TexCoord3fv = save_TexCoord3fv;
9591 vfmt->TexCoord4f = save_TexCoord4f;
9592 vfmt->TexCoord4fv = save_TexCoord4fv;
9593 vfmt->Vertex2f = save_Vertex2f;
9594 vfmt->Vertex2fv = save_Vertex2fv;
9595 vfmt->Vertex3f = save_Vertex3f;
9596 vfmt->Vertex3fv = save_Vertex3fv;
9597 vfmt->Vertex4f = save_Vertex4f;
9598 vfmt->Vertex4fv = save_Vertex4fv;
9599 vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB;
9600 vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB;
9601 vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB;
9602 vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB;
9603 vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB;
9604 vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB;
9605 vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB;
9606 vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB;
9607
9608 vfmt->Rectf = save_Rectf;
9609
9610 /* GL_ARB_draw_instanced */
9611 vfmt->DrawArraysInstanced = save_DrawArraysInstancedARB;
9612 vfmt->DrawElementsInstanced = save_DrawElementsInstancedARB;
9613
9614 /* GL_ARB_draw_elements_base_vertex */
9615 vfmt->DrawElementsInstancedBaseVertex = save_DrawElementsInstancedBaseVertexARB;
9616
9617 /* GL_ARB_base_instance */
9618 vfmt->DrawArraysInstancedBaseInstance = save_DrawArraysInstancedBaseInstance;
9619 vfmt->DrawElementsInstancedBaseInstance = save_DrawElementsInstancedBaseInstance;
9620 vfmt->DrawElementsInstancedBaseVertexBaseInstance = save_DrawElementsInstancedBaseVertexBaseInstance;
9621
9622 /* The driver is required to implement these as
9623 * 1) They can probably do a better job.
9624 * 2) A lot of new mechanisms would have to be added to this module
9625 * to support it. That code would probably never get used,
9626 * because of (1).
9627 */
9628 #if 0
9629 vfmt->DrawArrays = 0;
9630 vfmt->DrawElements = 0;
9631 vfmt->DrawRangeElements = 0;
9632 vfmt->MultiDrawElemementsEXT = 0;
9633 vfmt->DrawElementsBaseVertex = 0;
9634 vfmt->DrawRangeElementsBaseVertex = 0;
9635 vfmt->MultiDrawElemementsBaseVertex = 0;
9636 #endif
9637 }
9638
9639
9640 void
9641 _mesa_install_dlist_vtxfmt(struct _glapi_table *disp,
9642 const GLvertexformat *vfmt)
9643 {
9644 SET_CallList(disp, vfmt->CallList);
9645 SET_CallLists(disp, vfmt->CallLists);
9646 }
9647
9648
9649 /**
9650 * Initialize display list state for given context.
9651 */
9652 void
9653 _mesa_init_display_list(struct gl_context *ctx)
9654 {
9655 static GLboolean tableInitialized = GL_FALSE;
9656
9657 /* zero-out the instruction size table, just once */
9658 if (!tableInitialized) {
9659 memset(InstSize, 0, sizeof(InstSize));
9660 tableInitialized = GL_TRUE;
9661 }
9662
9663 /* extension info */
9664 ctx->ListExt = CALLOC_STRUCT(gl_list_extensions);
9665
9666 /* Display list */
9667 ctx->ListState.CallDepth = 0;
9668 ctx->ExecuteFlag = GL_TRUE;
9669 ctx->CompileFlag = GL_FALSE;
9670 ctx->ListState.CurrentBlock = NULL;
9671 ctx->ListState.CurrentPos = 0;
9672
9673 /* Display List group */
9674 ctx->List.ListBase = 0;
9675
9676 save_vtxfmt_init(&ctx->ListState.ListVtxfmt);
9677 }
9678
9679
9680 void
9681 _mesa_free_display_list_data(struct gl_context *ctx)
9682 {
9683 free(ctx->ListExt);
9684 ctx->ListExt = NULL;
9685 }