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