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