1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * Copyright 2009 VMware, Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
29 #include "main/glheader.h"
30 #include "main/context.h"
31 #include "main/state.h"
32 #include "main/api_validate.h"
33 #include "main/varray.h"
34 #include "main/bufferobj.h"
35 #include "main/enums.h"
36 #include "main/macros.h"
37 #include "main/transformfeedback.h"
39 #include "vbo_context.h"
43 * All vertex buffers should be in an unmapped state when we're about
44 * to draw. This debug function checks that.
47 check_buffers_are_unmapped(const struct gl_client_array
**inputs
)
52 for (i
= 0; i
< VERT_ATTRIB_MAX
; i
++) {
54 struct gl_buffer_object
*obj
= inputs
[i
]->BufferObj
;
55 assert(!_mesa_bufferobj_mapped(obj
));
64 * A debug function that may be called from other parts of Mesa as
65 * needed during debugging.
68 vbo_check_buffers_are_unmapped(struct gl_context
*ctx
)
70 struct vbo_context
*vbo
= vbo_context(ctx
);
71 struct vbo_exec_context
*exec
= &vbo
->exec
;
72 /* check the current vertex arrays */
73 check_buffers_are_unmapped(exec
->array
.inputs
);
74 /* check the current glBegin/glVertex/glEnd-style VBO */
75 assert(!_mesa_bufferobj_mapped(exec
->vtx
.bufferobj
));
81 * Compute min and max elements by scanning the index buffer for
82 * glDraw[Range]Elements() calls.
83 * If primitive restart is enabled, we need to ignore restart
84 * indexes when computing min/max.
87 vbo_get_minmax_index(struct gl_context
*ctx
,
88 const struct _mesa_prim
*prim
,
89 const struct _mesa_index_buffer
*ib
,
90 GLuint
*min_index
, GLuint
*max_index
,
93 const GLboolean restart
= ctx
->Array
.PrimitiveRestart
;
94 const GLuint restartIndex
= ctx
->Array
.RestartIndex
;
95 const int index_size
= vbo_sizeof_ib_type(ib
->type
);
99 indices
= (char *) ib
->ptr
+ prim
->start
* index_size
;
100 if (_mesa_is_bufferobj(ib
->obj
)) {
101 GLsizeiptr size
= MIN2(count
* index_size
, ib
->obj
->Size
);
102 indices
= ctx
->Driver
.MapBufferRange(ctx
, (GLintptr
) indices
, size
,
103 GL_MAP_READ_BIT
, ib
->obj
);
107 case GL_UNSIGNED_INT
: {
108 const GLuint
*ui_indices
= (const GLuint
*)indices
;
112 for (i
= 0; i
< count
; i
++) {
113 if (ui_indices
[i
] != restartIndex
) {
114 if (ui_indices
[i
] > max_ui
) max_ui
= ui_indices
[i
];
115 if (ui_indices
[i
] < min_ui
) min_ui
= ui_indices
[i
];
120 for (i
= 0; i
< count
; i
++) {
121 if (ui_indices
[i
] > max_ui
) max_ui
= ui_indices
[i
];
122 if (ui_indices
[i
] < min_ui
) min_ui
= ui_indices
[i
];
129 case GL_UNSIGNED_SHORT
: {
130 const GLushort
*us_indices
= (const GLushort
*)indices
;
134 for (i
= 0; i
< count
; i
++) {
135 if (us_indices
[i
] != restartIndex
) {
136 if (us_indices
[i
] > max_us
) max_us
= us_indices
[i
];
137 if (us_indices
[i
] < min_us
) min_us
= us_indices
[i
];
142 for (i
= 0; i
< count
; i
++) {
143 if (us_indices
[i
] > max_us
) max_us
= us_indices
[i
];
144 if (us_indices
[i
] < min_us
) min_us
= us_indices
[i
];
151 case GL_UNSIGNED_BYTE
: {
152 const GLubyte
*ub_indices
= (const GLubyte
*)indices
;
156 for (i
= 0; i
< count
; i
++) {
157 if (ub_indices
[i
] != restartIndex
) {
158 if (ub_indices
[i
] > max_ub
) max_ub
= ub_indices
[i
];
159 if (ub_indices
[i
] < min_ub
) min_ub
= ub_indices
[i
];
164 for (i
= 0; i
< count
; i
++) {
165 if (ub_indices
[i
] > max_ub
) max_ub
= ub_indices
[i
];
166 if (ub_indices
[i
] < min_ub
) min_ub
= ub_indices
[i
];
178 if (_mesa_is_bufferobj(ib
->obj
)) {
179 ctx
->Driver
.UnmapBuffer(ctx
, ib
->obj
);
184 * Compute min and max elements for nr_prims
187 vbo_get_minmax_indices(struct gl_context
*ctx
,
188 const struct _mesa_prim
*prims
,
189 const struct _mesa_index_buffer
*ib
,
194 GLuint tmp_min
, tmp_max
;
201 for (i
= 0; i
< nr_prims
; i
++) {
202 const struct _mesa_prim
*start_prim
;
204 start_prim
= &prims
[i
];
205 count
= start_prim
->count
;
206 /* Do combination if possible to reduce map/unmap count */
207 while ((i
+ 1 < nr_prims
) &&
208 (prims
[i
].start
+ prims
[i
].count
== prims
[i
+1].start
)) {
209 count
+= prims
[i
+1].count
;
212 vbo_get_minmax_index(ctx
, start_prim
, ib
, &tmp_min
, &tmp_max
, count
);
213 *min_index
= MIN2(*min_index
, tmp_min
);
214 *max_index
= MAX2(*max_index
, tmp_max
);
220 * Check that element 'j' of the array has reasonable data.
222 * For debugging purposes; not normally used.
225 check_array_data(struct gl_context
*ctx
, struct gl_client_array
*array
,
226 GLuint attrib
, GLuint j
)
228 if (array
->Enabled
) {
229 const void *data
= array
->Ptr
;
230 if (_mesa_is_bufferobj(array
->BufferObj
)) {
231 if (!array
->BufferObj
->Pointer
) {
232 /* need to map now */
233 array
->BufferObj
->Pointer
=
234 ctx
->Driver
.MapBufferRange(ctx
, 0, array
->BufferObj
->Size
,
235 GL_MAP_READ_BIT
, array
->BufferObj
);
237 data
= ADD_POINTERS(data
, array
->BufferObj
->Pointer
);
239 switch (array
->Type
) {
242 GLfloat
*f
= (GLfloat
*) ((GLubyte
*) data
+ array
->StrideB
* j
);
244 for (k
= 0; k
< array
->Size
; k
++) {
245 if (IS_INF_OR_NAN(f
[k
]) ||
246 f
[k
] >= 1.0e20
|| f
[k
] <= -1.0e10
) {
247 printf("Bad array data:\n");
248 printf(" Element[%u].%u = %f\n", j
, k
, f
[k
]);
249 printf(" Array %u at %p\n", attrib
, (void* ) array
);
250 printf(" Type 0x%x, Size %d, Stride %d\n",
251 array
->Type
, array
->Size
, array
->Stride
);
252 printf(" Address/offset %p in Buffer Object %u\n",
253 array
->Ptr
, array
->BufferObj
->Name
);
254 f
[k
] = 1.0; /* XXX replace the bad value! */
256 /*assert(!IS_INF_OR_NAN(f[k]));*/
268 * Unmap the buffer object referenced by given array, if mapped.
271 unmap_array_buffer(struct gl_context
*ctx
, struct gl_client_array
*array
)
273 if (array
->Enabled
&&
274 _mesa_is_bufferobj(array
->BufferObj
) &&
275 _mesa_bufferobj_mapped(array
->BufferObj
)) {
276 ctx
->Driver
.UnmapBuffer(ctx
, array
->BufferObj
);
282 * Examine the array's data for NaNs, etc.
283 * For debug purposes; not normally used.
286 check_draw_elements_data(struct gl_context
*ctx
, GLsizei count
, GLenum elemType
,
287 const void *elements
, GLint basevertex
)
289 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
293 if (_mesa_is_bufferobj(ctx
->Array
.ArrayObj
->ElementArrayBufferObj
)) {
294 elemMap
= ctx
->Driver
.MapBufferRange(ctx
, 0,
295 ctx
->Array
.ArrayObj
->ElementArrayBufferObj
->Size
,
297 ctx
->Array
.ArrayObj
->ElementArrayBufferObj
);
298 elements
= ADD_POINTERS(elements
, elemMap
);
301 for (i
= 0; i
< count
; i
++) {
306 case GL_UNSIGNED_BYTE
:
307 j
= ((const GLubyte
*) elements
)[i
];
309 case GL_UNSIGNED_SHORT
:
310 j
= ((const GLushort
*) elements
)[i
];
312 case GL_UNSIGNED_INT
:
313 j
= ((const GLuint
*) elements
)[i
];
319 /* check element j of each enabled array */
320 for (k
= 0; k
< Elements(arrayObj
->VertexAttrib
); k
++) {
321 check_array_data(ctx
, &arrayObj
->VertexAttrib
[k
], k
, j
);
325 if (_mesa_is_bufferobj(arrayObj
->ElementArrayBufferObj
)) {
326 ctx
->Driver
.UnmapBuffer(ctx
, ctx
->Array
.ArrayObj
->ElementArrayBufferObj
);
329 for (k
= 0; k
< Elements(arrayObj
->VertexAttrib
); k
++) {
330 unmap_array_buffer(ctx
, &arrayObj
->VertexAttrib
[k
]);
336 * Check array data, looking for NaNs, etc.
339 check_draw_arrays_data(struct gl_context
*ctx
, GLint start
, GLsizei count
)
346 * Print info/data for glDrawArrays(), for debugging.
349 print_draw_arrays(struct gl_context
*ctx
,
350 GLenum mode
, GLint start
, GLsizei count
)
352 struct vbo_context
*vbo
= vbo_context(ctx
);
353 struct vbo_exec_context
*exec
= &vbo
->exec
;
354 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
357 printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n",
360 for (i
= 0; i
< 32; i
++) {
361 struct gl_buffer_object
*bufObj
= exec
->array
.inputs
[i
]->BufferObj
;
362 GLuint bufName
= bufObj
->Name
;
363 GLint stride
= exec
->array
.inputs
[i
]->Stride
;
364 printf("attr %2d: size %d stride %d enabled %d "
365 "ptr %p Bufobj %u\n",
367 exec
->array
.inputs
[i
]->Size
,
369 /*exec->array.inputs[i]->Enabled,*/
370 arrayObj
->VertexAttrib
[VERT_ATTRIB_FF(i
)].Enabled
,
371 exec
->array
.inputs
[i
]->Ptr
,
375 GLubyte
*p
= ctx
->Driver
.MapBufferRange(ctx
, 0, bufObj
->Size
,
376 GL_MAP_READ_BIT
, bufObj
);
377 int offset
= (int) (GLintptr
) exec
->array
.inputs
[i
]->Ptr
;
378 float *f
= (float *) (p
+ offset
);
381 int n
= (count
* stride
) / 4;
384 printf(" Data at offset %d:\n", offset
);
385 for (i
= 0; i
< n
; i
++) {
386 printf(" float[%d] = 0x%08x %f\n", i
, k
[i
], f
[i
]);
388 ctx
->Driver
.UnmapBuffer(ctx
, bufObj
);
395 * Set the vbo->exec->inputs[] pointers to point to the enabled
396 * vertex arrays. This depends on the current vertex program/shader
397 * being executed because of whether or not generic vertex arrays
398 * alias the conventional vertex arrays.
399 * For arrays that aren't enabled, we set the input[attrib] pointer
400 * to point at a zero-stride current value "array".
403 recalculate_input_bindings(struct gl_context
*ctx
)
405 struct vbo_context
*vbo
= vbo_context(ctx
);
406 struct vbo_exec_context
*exec
= &vbo
->exec
;
407 struct gl_client_array
*vertexAttrib
= ctx
->Array
.ArrayObj
->VertexAttrib
;
408 const struct gl_client_array
**inputs
= &exec
->array
.inputs
[0];
409 GLbitfield64 const_inputs
= 0x0;
412 switch (get_program_mode(ctx
)) {
414 /* When no vertex program is active (or the vertex program is generated
415 * from fixed-function state). We put the material values into the
416 * generic slots. This is the only situation where material values
417 * are available as per-vertex attributes.
419 for (i
= 0; i
< VERT_ATTRIB_FF_MAX
; i
++) {
420 if (vertexAttrib
[VERT_ATTRIB_FF(i
)].Enabled
)
421 inputs
[i
] = &vertexAttrib
[VERT_ATTRIB_FF(i
)];
423 inputs
[i
] = &vbo
->currval
[VBO_ATTRIB_POS
+i
];
424 const_inputs
|= VERT_BIT(i
);
428 for (i
= 0; i
< MAT_ATTRIB_MAX
; i
++) {
429 inputs
[VERT_ATTRIB_GENERIC(i
)] =
430 &vbo
->currval
[VBO_ATTRIB_MAT_FRONT_AMBIENT
+i
];
431 const_inputs
|= VERT_BIT_GENERIC(i
);
434 /* Could use just about anything, just to fill in the empty
437 for (i
= MAT_ATTRIB_MAX
; i
< VERT_ATTRIB_GENERIC_MAX
; i
++) {
438 inputs
[VERT_ATTRIB_GENERIC(i
)] = &vbo
->currval
[VBO_ATTRIB_GENERIC0
+i
];
439 const_inputs
|= VERT_BIT_GENERIC(i
);
444 /* NV_vertex_program - attribute arrays alias and override
445 * conventional, legacy arrays. No materials, and the generic
448 for (i
= 0; i
< VERT_ATTRIB_FF_MAX
; i
++) {
449 if (i
< VERT_ATTRIB_GENERIC_MAX
450 && vertexAttrib
[VERT_ATTRIB_GENERIC(i
)].Enabled
)
451 inputs
[i
] = &vertexAttrib
[VERT_ATTRIB_GENERIC(i
)];
452 else if (vertexAttrib
[VERT_ATTRIB_FF(i
)].Enabled
)
453 inputs
[i
] = &vertexAttrib
[VERT_ATTRIB_FF(i
)];
455 inputs
[i
] = &vbo
->currval
[VBO_ATTRIB_POS
+i
];
456 const_inputs
|= VERT_BIT_FF(i
);
460 /* Could use just about anything, just to fill in the empty
463 for (i
= 0; i
< VERT_ATTRIB_GENERIC_MAX
; i
++) {
464 inputs
[VERT_ATTRIB_GENERIC(i
)] = &vbo
->currval
[VBO_ATTRIB_GENERIC0
+i
];
465 const_inputs
|= VERT_BIT_GENERIC(i
);
470 /* GL_ARB_vertex_program or GLSL vertex shader - Only the generic[0]
471 * attribute array aliases and overrides the legacy position array.
473 * Otherwise, legacy attributes available in the legacy slots,
474 * generic attributes in the generic slots and materials are not
475 * available as per-vertex attributes.
477 if (vertexAttrib
[VERT_ATTRIB_GENERIC0
].Enabled
)
478 inputs
[0] = &vertexAttrib
[VERT_ATTRIB_GENERIC0
];
479 else if (vertexAttrib
[VERT_ATTRIB_POS
].Enabled
)
480 inputs
[0] = &vertexAttrib
[VERT_ATTRIB_POS
];
482 inputs
[0] = &vbo
->currval
[VBO_ATTRIB_POS
];
483 const_inputs
|= VERT_BIT_POS
;
486 for (i
= 1; i
< VERT_ATTRIB_FF_MAX
; i
++) {
487 if (vertexAttrib
[VERT_ATTRIB_FF(i
)].Enabled
)
488 inputs
[i
] = &vertexAttrib
[VERT_ATTRIB_FF(i
)];
490 inputs
[i
] = &vbo
->currval
[VBO_ATTRIB_POS
+i
];
491 const_inputs
|= VERT_BIT_FF(i
);
495 for (i
= 1; i
< VERT_ATTRIB_GENERIC_MAX
; i
++) {
496 if (vertexAttrib
[VERT_ATTRIB_GENERIC(i
)].Enabled
)
497 inputs
[VERT_ATTRIB_GENERIC(i
)] = &vertexAttrib
[VERT_ATTRIB_GENERIC(i
)];
499 inputs
[VERT_ATTRIB_GENERIC(i
)] = &vbo
->currval
[VBO_ATTRIB_GENERIC0
+i
];
500 const_inputs
|= VERT_BIT_GENERIC(i
);
504 inputs
[VERT_ATTRIB_GENERIC0
] = inputs
[0];
508 _mesa_set_varying_vp_inputs( ctx
, VERT_BIT_ALL
& (~const_inputs
) );
509 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewArray
;
514 * Examine the enabled vertex arrays to set the exec->array.inputs[] values.
515 * These will point to the arrays to actually use for drawing. Some will
516 * be user-provided arrays, other will be zero-stride const-valued arrays.
517 * Note that this might set the _NEW_VARYING_VP_INPUTS dirty flag so state
518 * validation must be done after this call.
521 vbo_bind_arrays(struct gl_context
*ctx
)
523 struct vbo_context
*vbo
= vbo_context(ctx
);
524 struct vbo_exec_context
*exec
= &vbo
->exec
;
526 vbo_draw_method(vbo
, DRAW_ARRAYS
);
528 if (exec
->array
.recalculate_inputs
) {
529 recalculate_input_bindings(ctx
);
531 /* Again... because we may have changed the bitmask of per-vertex varying
532 * attributes. If we regenerate the fixed-function vertex program now
533 * we may be able to prune down the number of vertex attributes which we
534 * need in the shader.
537 _mesa_update_state(ctx
);
540 exec
->array
.recalculate_inputs
= GL_FALSE
;
546 * Handle a draw case that potentially has primitive restart enabled.
548 * If primitive restart is enabled, and PrimitiveRestartInSoftware is
549 * set, then vbo_sw_primitive_restart is used to handle the primitive
550 * restart case in software.
553 vbo_handle_primitive_restart(struct gl_context
*ctx
,
554 const struct _mesa_prim
*prim
,
556 const struct _mesa_index_buffer
*ib
,
557 GLboolean index_bounds_valid
,
561 struct vbo_context
*vbo
= vbo_context(ctx
);
564 ctx
->Const
.PrimitiveRestartInSoftware
&&
565 ctx
->Array
.PrimitiveRestart
) {
566 /* Handle primitive restart in software */
567 vbo_sw_primitive_restart(ctx
, prim
, nr_prims
, ib
);
569 /* Call driver directly for draw_prims */
570 vbo
->draw_prims(ctx
, prim
, nr_prims
, ib
,
571 index_bounds_valid
, min_index
, max_index
, NULL
);
577 * Helper function called by the other DrawArrays() functions below.
578 * This is where we handle primitive restart for drawing non-indexed
579 * arrays. If primitive restart is enabled, it typically means
580 * splitting one DrawArrays() into two.
583 vbo_draw_arrays(struct gl_context
*ctx
, GLenum mode
, GLint start
,
584 GLsizei count
, GLuint numInstances
, GLuint baseInstance
)
586 struct vbo_context
*vbo
= vbo_context(ctx
);
587 struct vbo_exec_context
*exec
= &vbo
->exec
;
588 struct _mesa_prim prim
[2];
590 vbo_bind_arrays(ctx
);
592 /* init most fields to zero */
593 memset(prim
, 0, sizeof(prim
));
597 prim
[0].num_instances
= numInstances
;
598 prim
[0].base_instance
= baseInstance
;
600 /* Implement the primitive restart index */
601 if (ctx
->Array
.PrimitiveRestart
&& ctx
->Array
.RestartIndex
< count
) {
602 GLuint primCount
= 0;
604 if (ctx
->Array
.RestartIndex
== start
) {
605 /* special case: RestartIndex at beginning */
607 prim
[0].start
= start
+ 1;
608 prim
[0].count
= count
- 1;
612 else if (ctx
->Array
.RestartIndex
== start
+ count
- 1) {
613 /* special case: RestartIndex at end */
615 prim
[0].start
= start
;
616 prim
[0].count
= count
- 1;
621 /* general case: RestartIndex in middle, split into two prims */
622 prim
[0].start
= start
;
623 prim
[0].count
= ctx
->Array
.RestartIndex
- start
;
626 prim
[1].start
= ctx
->Array
.RestartIndex
+ 1;
627 prim
[1].count
= count
- prim
[1].start
;
633 /* draw one or two prims */
634 check_buffers_are_unmapped(exec
->array
.inputs
);
635 vbo
->draw_prims(ctx
, prim
, primCount
, NULL
,
636 GL_TRUE
, start
, start
+ count
- 1, NULL
);
640 /* no prim restart */
641 prim
[0].start
= start
;
642 prim
[0].count
= count
;
644 check_buffers_are_unmapped(exec
->array
.inputs
);
645 vbo
->draw_prims(ctx
, prim
, 1, NULL
,
646 GL_TRUE
, start
, start
+ count
- 1,
650 if (MESA_DEBUG_FLAGS
& DEBUG_ALWAYS_FLUSH
) {
658 * Called from glDrawArrays when in immediate mode (not display list mode).
660 static void GLAPIENTRY
661 vbo_exec_DrawArrays(GLenum mode
, GLint start
, GLsizei count
)
663 GET_CURRENT_CONTEXT(ctx
);
665 if (MESA_VERBOSE
& VERBOSE_DRAW
)
666 _mesa_debug(ctx
, "glDrawArrays(%s, %d, %d)\n",
667 _mesa_lookup_enum_by_nr(mode
), start
, count
);
669 if (!_mesa_validate_DrawArrays( ctx
, mode
, start
, count
))
673 check_draw_arrays_data(ctx
, start
, count
);
675 vbo_draw_arrays(ctx
, mode
, start
, count
, 1, 0);
678 print_draw_arrays(ctx
, mode
, start
, count
);
683 * Called from glDrawArraysInstanced when in immediate mode (not
684 * display list mode).
686 static void GLAPIENTRY
687 vbo_exec_DrawArraysInstanced(GLenum mode
, GLint start
, GLsizei count
,
688 GLsizei numInstances
)
690 GET_CURRENT_CONTEXT(ctx
);
692 if (MESA_VERBOSE
& VERBOSE_DRAW
)
693 _mesa_debug(ctx
, "glDrawArraysInstanced(%s, %d, %d, %d)\n",
694 _mesa_lookup_enum_by_nr(mode
), start
, count
, numInstances
);
696 if (!_mesa_validate_DrawArraysInstanced(ctx
, mode
, start
, count
, numInstances
))
700 check_draw_arrays_data(ctx
, start
, count
);
702 vbo_draw_arrays(ctx
, mode
, start
, count
, numInstances
, 0);
705 print_draw_arrays(ctx
, mode
, start
, count
);
710 * Called from glDrawArraysInstancedBaseInstance when in immediate mode.
712 static void GLAPIENTRY
713 vbo_exec_DrawArraysInstancedBaseInstance(GLenum mode
, GLint first
, GLsizei count
,
714 GLsizei numInstances
, GLuint baseInstance
)
716 GET_CURRENT_CONTEXT(ctx
);
718 if (MESA_VERBOSE
& VERBOSE_DRAW
)
719 _mesa_debug(ctx
, "glDrawArraysInstancedBaseInstance(%s, %d, %d, %d, %d)\n",
720 _mesa_lookup_enum_by_nr(mode
), first
, count
,
721 numInstances
, baseInstance
);
723 if (!_mesa_validate_DrawArraysInstanced(ctx
, mode
, first
, count
,
728 check_draw_arrays_data(ctx
, first
, count
);
730 vbo_draw_arrays(ctx
, mode
, first
, count
, numInstances
, baseInstance
);
733 print_draw_arrays(ctx
, mode
, first
, count
);
739 * Map GL_ELEMENT_ARRAY_BUFFER and print contents.
744 dump_element_buffer(struct gl_context
*ctx
, GLenum type
)
747 ctx
->Driver
.MapBufferRange(ctx
, 0,
748 ctx
->Array
.ArrayObj
->ElementArrayBufferObj
->Size
,
750 ctx
->Array
.ArrayObj
->ElementArrayBufferObj
);
752 case GL_UNSIGNED_BYTE
:
754 const GLubyte
*us
= (const GLubyte
*) map
;
756 for (i
= 0; i
< ctx
->Array
.ArrayObj
->ElementArrayBufferObj
->Size
; i
++) {
757 printf("%02x ", us
[i
]);
764 case GL_UNSIGNED_SHORT
:
766 const GLushort
*us
= (const GLushort
*) map
;
768 for (i
= 0; i
< ctx
->Array
.ArrayObj
->ElementArrayBufferObj
->Size
/ 2; i
++) {
769 printf("%04x ", us
[i
]);
776 case GL_UNSIGNED_INT
:
778 const GLuint
*us
= (const GLuint
*) map
;
780 for (i
= 0; i
< ctx
->Array
.ArrayObj
->ElementArrayBufferObj
->Size
/ 4; i
++) {
781 printf("%08x ", us
[i
]);
792 ctx
->Driver
.UnmapBuffer(ctx
, ctx
->Array
.ArrayObj
->ElementArrayBufferObj
);
798 * Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements.
799 * Do the rendering for a glDrawElements or glDrawRangeElements call after
800 * we've validated buffer bounds, etc.
803 vbo_validated_drawrangeelements(struct gl_context
*ctx
, GLenum mode
,
804 GLboolean index_bounds_valid
,
805 GLuint start
, GLuint end
,
806 GLsizei count
, GLenum type
,
807 const GLvoid
*indices
,
808 GLint basevertex
, GLint numInstances
,
811 struct vbo_context
*vbo
= vbo_context(ctx
);
812 struct vbo_exec_context
*exec
= &vbo
->exec
;
813 struct _mesa_index_buffer ib
;
814 struct _mesa_prim prim
[1];
816 vbo_bind_arrays(ctx
);
820 ib
.obj
= ctx
->Array
.ArrayObj
->ElementArrayBufferObj
;
829 prim
[0].count
= count
;
831 prim
[0].basevertex
= basevertex
;
832 prim
[0].num_instances
= numInstances
;
833 prim
[0].base_instance
= baseInstance
;
835 /* Need to give special consideration to rendering a range of
836 * indices starting somewhere above zero. Typically the
837 * application is issuing multiple DrawRangeElements() to draw
838 * successive primitives layed out linearly in the vertex arrays.
839 * Unless the vertex arrays are all in a VBO (or locked as with
840 * CVA), the OpenGL semantics imply that we need to re-read or
841 * re-upload the vertex data on each draw call.
843 * In the case of hardware tnl, we want to avoid starting the
844 * upload at zero, as it will mean every draw call uploads an
845 * increasing amount of not-used vertex data. Worse - in the
846 * software tnl module, all those vertices might be transformed and
847 * lit but never rendered.
849 * If we just upload or transform the vertices in start..end,
850 * however, the indices will be incorrect.
852 * At this level, we don't know exactly what the requirements of
853 * the backend are going to be, though it will likely boil down to
856 * 1) Do nothing, everything is in a VBO and is processed once
859 * 2) Adjust the indices and vertex arrays so that start becomes
862 * Rather than doing anything here, I'll provide a helper function
863 * for the latter case elsewhere.
866 check_buffers_are_unmapped(exec
->array
.inputs
);
867 vbo_handle_primitive_restart(ctx
, prim
, 1, &ib
,
868 index_bounds_valid
, start
, end
);
870 if (MESA_DEBUG_FLAGS
& DEBUG_ALWAYS_FLUSH
) {
877 * Called by glDrawRangeElementsBaseVertex() in immediate mode.
879 static void GLAPIENTRY
880 vbo_exec_DrawRangeElementsBaseVertex(GLenum mode
,
881 GLuint start
, GLuint end
,
882 GLsizei count
, GLenum type
,
883 const GLvoid
*indices
,
886 static GLuint warnCount
= 0;
887 GLboolean index_bounds_valid
= GL_TRUE
;
888 GET_CURRENT_CONTEXT(ctx
);
890 if (MESA_VERBOSE
& VERBOSE_DRAW
)
892 "glDrawRangeElementsBaseVertex(%s, %u, %u, %d, %s, %p, %d)\n",
893 _mesa_lookup_enum_by_nr(mode
), start
, end
, count
,
894 _mesa_lookup_enum_by_nr(type
), indices
, basevertex
);
896 if (!_mesa_validate_DrawRangeElements( ctx
, mode
, start
, end
, count
,
897 type
, indices
, basevertex
))
900 if ((int) end
+ basevertex
< 0 ||
901 start
+ basevertex
>= ctx
->Array
.ArrayObj
->_MaxElement
) {
902 /* The application requested we draw using a range of indices that's
903 * outside the bounds of the current VBO. This is invalid and appears
904 * to give undefined results. The safest thing to do is to simply
905 * ignore the range, in case the application botched their range tracking
906 * but did provide valid indices. Also issue a warning indicating that
907 * the application is broken.
909 if (warnCount
++ < 10) {
910 _mesa_warning(ctx
, "glDrawRangeElements(start %u, end %u, "
911 "basevertex %d, count %d, type 0x%x, indices=%p):\n"
912 "\trange is outside VBO bounds (max=%u); ignoring.\n"
913 "\tThis should be fixed in the application.",
914 start
, end
, basevertex
, count
, type
, indices
,
915 ctx
->Array
.ArrayObj
->_MaxElement
- 1);
917 index_bounds_valid
= GL_FALSE
;
920 /* NOTE: It's important that 'end' is a reasonable value.
921 * in _tnl_draw_prims(), we use end to determine how many vertices
922 * to transform. If it's too large, we can unnecessarily split prims
923 * or we can read/write out of memory in several different places!
926 /* Catch/fix some potential user errors */
927 if (type
== GL_UNSIGNED_BYTE
) {
928 start
= MIN2(start
, 0xff);
929 end
= MIN2(end
, 0xff);
931 else if (type
== GL_UNSIGNED_SHORT
) {
932 start
= MIN2(start
, 0xffff);
933 end
= MIN2(end
, 0xffff);
937 printf("glDraw[Range]Elements{,BaseVertex}"
938 "(start %u, end %u, type 0x%x, count %d) ElemBuf %u, "
940 start
, end
, type
, count
,
941 ctx
->Array
.ArrayObj
->ElementArrayBufferObj
->Name
,
945 if ((int) start
+ basevertex
< 0 ||
946 end
+ basevertex
>= ctx
->Array
.ArrayObj
->_MaxElement
)
947 index_bounds_valid
= GL_FALSE
;
950 check_draw_elements_data(ctx
, count
, type
, indices
);
952 (void) check_draw_elements_data
;
955 vbo_validated_drawrangeelements(ctx
, mode
, index_bounds_valid
, start
, end
,
956 count
, type
, indices
, basevertex
, 1, 0);
961 * Called by glDrawRangeElements() in immediate mode.
963 static void GLAPIENTRY
964 vbo_exec_DrawRangeElements(GLenum mode
, GLuint start
, GLuint end
,
965 GLsizei count
, GLenum type
, const GLvoid
*indices
)
967 if (MESA_VERBOSE
& VERBOSE_DRAW
) {
968 GET_CURRENT_CONTEXT(ctx
);
970 "glDrawRangeElements(%s, %u, %u, %d, %s, %p)\n",
971 _mesa_lookup_enum_by_nr(mode
), start
, end
, count
,
972 _mesa_lookup_enum_by_nr(type
), indices
);
975 vbo_exec_DrawRangeElementsBaseVertex(mode
, start
, end
, count
, type
,
981 * Called by glDrawElements() in immediate mode.
983 static void GLAPIENTRY
984 vbo_exec_DrawElements(GLenum mode
, GLsizei count
, GLenum type
,
985 const GLvoid
*indices
)
987 GET_CURRENT_CONTEXT(ctx
);
989 if (MESA_VERBOSE
& VERBOSE_DRAW
)
990 _mesa_debug(ctx
, "glDrawElements(%s, %u, %s, %p)\n",
991 _mesa_lookup_enum_by_nr(mode
), count
,
992 _mesa_lookup_enum_by_nr(type
), indices
);
994 if (!_mesa_validate_DrawElements( ctx
, mode
, count
, type
, indices
, 0 ))
997 vbo_validated_drawrangeelements(ctx
, mode
, GL_FALSE
, ~0, ~0,
998 count
, type
, indices
, 0, 1, 0);
1003 * Called by glDrawElementsBaseVertex() in immediate mode.
1005 static void GLAPIENTRY
1006 vbo_exec_DrawElementsBaseVertex(GLenum mode
, GLsizei count
, GLenum type
,
1007 const GLvoid
*indices
, GLint basevertex
)
1009 GET_CURRENT_CONTEXT(ctx
);
1011 if (MESA_VERBOSE
& VERBOSE_DRAW
)
1012 _mesa_debug(ctx
, "glDrawElementsBaseVertex(%s, %d, %s, %p, %d)\n",
1013 _mesa_lookup_enum_by_nr(mode
), count
,
1014 _mesa_lookup_enum_by_nr(type
), indices
, basevertex
);
1016 if (!_mesa_validate_DrawElements( ctx
, mode
, count
, type
, indices
,
1020 vbo_validated_drawrangeelements(ctx
, mode
, GL_FALSE
, ~0, ~0,
1021 count
, type
, indices
, basevertex
, 1, 0);
1026 * Called by glDrawElementsInstanced() in immediate mode.
1028 static void GLAPIENTRY
1029 vbo_exec_DrawElementsInstanced(GLenum mode
, GLsizei count
, GLenum type
,
1030 const GLvoid
*indices
, GLsizei numInstances
)
1032 GET_CURRENT_CONTEXT(ctx
);
1034 if (MESA_VERBOSE
& VERBOSE_DRAW
)
1035 _mesa_debug(ctx
, "glDrawElementsInstanced(%s, %d, %s, %p, %d)\n",
1036 _mesa_lookup_enum_by_nr(mode
), count
,
1037 _mesa_lookup_enum_by_nr(type
), indices
, numInstances
);
1039 if (!_mesa_validate_DrawElementsInstanced(ctx
, mode
, count
, type
, indices
,
1043 vbo_validated_drawrangeelements(ctx
, mode
, GL_FALSE
, ~0, ~0,
1044 count
, type
, indices
, 0, numInstances
, 0);
1049 * Called by glDrawElementsInstancedBaseVertex() in immediate mode.
1051 static void GLAPIENTRY
1052 vbo_exec_DrawElementsInstancedBaseVertex(GLenum mode
, GLsizei count
, GLenum type
,
1053 const GLvoid
*indices
, GLsizei numInstances
,
1056 GET_CURRENT_CONTEXT(ctx
);
1058 if (MESA_VERBOSE
& VERBOSE_DRAW
)
1059 _mesa_debug(ctx
, "glDrawElementsInstancedBaseVertex(%s, %d, %s, %p, %d; %d)\n",
1060 _mesa_lookup_enum_by_nr(mode
), count
,
1061 _mesa_lookup_enum_by_nr(type
), indices
,
1062 numInstances
, basevertex
);
1064 if (!_mesa_validate_DrawElementsInstanced(ctx
, mode
, count
, type
, indices
,
1065 numInstances
, basevertex
))
1068 vbo_validated_drawrangeelements(ctx
, mode
, GL_FALSE
, ~0, ~0,
1069 count
, type
, indices
, basevertex
, numInstances
, 0);
1074 * Called by glDrawElementsInstancedBaseInstance() in immediate mode.
1076 static void GLAPIENTRY
1077 vbo_exec_DrawElementsInstancedBaseInstance(GLenum mode
, GLsizei count
, GLenum type
,
1078 const GLvoid
*indices
, GLsizei numInstances
,
1079 GLuint baseInstance
)
1081 GET_CURRENT_CONTEXT(ctx
);
1083 if (MESA_VERBOSE
& VERBOSE_DRAW
)
1084 _mesa_debug(ctx
, "glDrawElementsInstancedBaseInstance(%s, %d, %s, %p, %d, %d)\n",
1085 _mesa_lookup_enum_by_nr(mode
), count
,
1086 _mesa_lookup_enum_by_nr(type
), indices
,
1087 numInstances
, baseInstance
);
1089 if (!_mesa_validate_DrawElementsInstanced(ctx
, mode
, count
, type
, indices
,
1093 vbo_validated_drawrangeelements(ctx
, mode
, GL_FALSE
, ~0, ~0,
1094 count
, type
, indices
, 0, numInstances
,
1100 * Called by glDrawElementsInstancedBaseVertexBaseInstance() in immediate mode.
1102 static void GLAPIENTRY
1103 vbo_exec_DrawElementsInstancedBaseVertexBaseInstance(GLenum mode
, GLsizei count
, GLenum type
,
1104 const GLvoid
*indices
, GLsizei numInstances
,
1105 GLint basevertex
, GLuint baseInstance
)
1107 GET_CURRENT_CONTEXT(ctx
);
1109 if (MESA_VERBOSE
& VERBOSE_DRAW
)
1110 _mesa_debug(ctx
, "glDrawElementsInstancedBaseVertexBaseInstance(%s, %d, %s, %p, %d, %d, %d)\n",
1111 _mesa_lookup_enum_by_nr(mode
), count
,
1112 _mesa_lookup_enum_by_nr(type
), indices
,
1113 numInstances
, basevertex
, baseInstance
);
1115 if (!_mesa_validate_DrawElementsInstanced(ctx
, mode
, count
, type
, indices
,
1116 numInstances
, basevertex
))
1119 vbo_validated_drawrangeelements(ctx
, mode
, GL_FALSE
, ~0, ~0,
1120 count
, type
, indices
, basevertex
, numInstances
,
1126 * Inner support for both _mesa_MultiDrawElements() and
1127 * _mesa_MultiDrawRangeElements().
1128 * This does the actual rendering after we've checked array indexes, etc.
1131 vbo_validated_multidrawelements(struct gl_context
*ctx
, GLenum mode
,
1132 const GLsizei
*count
, GLenum type
,
1133 const GLvoid
* const *indices
,
1135 const GLint
*basevertex
)
1137 struct vbo_context
*vbo
= vbo_context(ctx
);
1138 struct vbo_exec_context
*exec
= &vbo
->exec
;
1139 struct _mesa_index_buffer ib
;
1140 struct _mesa_prim
*prim
;
1141 unsigned int index_type_size
= vbo_sizeof_ib_type(type
);
1142 uintptr_t min_index_ptr
, max_index_ptr
;
1143 GLboolean fallback
= GL_FALSE
;
1149 prim
= calloc(1, primcount
* sizeof(*prim
));
1151 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glMultiDrawElements");
1155 vbo_bind_arrays(ctx
);
1157 min_index_ptr
= (uintptr_t)indices
[0];
1159 for (i
= 0; i
< primcount
; i
++) {
1160 min_index_ptr
= MIN2(min_index_ptr
, (uintptr_t)indices
[i
]);
1161 max_index_ptr
= MAX2(max_index_ptr
, (uintptr_t)indices
[i
] +
1162 index_type_size
* count
[i
]);
1165 /* Check if we can handle this thing as a bunch of index offsets from the
1166 * same index pointer. If we can't, then we have to fall back to doing
1167 * a draw_prims per primitive.
1168 * Check that the difference between each prim's indexes is a multiple of
1169 * the index/element size.
1171 if (index_type_size
!= 1) {
1172 for (i
= 0; i
< primcount
; i
++) {
1173 if ((((uintptr_t)indices
[i
] - min_index_ptr
) % index_type_size
) != 0) {
1180 /* If the index buffer isn't in a VBO, then treating the application's
1181 * subranges of the index buffer as one large index buffer may lead to
1182 * us reading unmapped memory.
1184 if (!_mesa_is_bufferobj(ctx
->Array
.ArrayObj
->ElementArrayBufferObj
))
1188 ib
.count
= (max_index_ptr
- min_index_ptr
) / index_type_size
;
1190 ib
.obj
= ctx
->Array
.ArrayObj
->ElementArrayBufferObj
;
1191 ib
.ptr
= (void *)min_index_ptr
;
1193 for (i
= 0; i
< primcount
; i
++) {
1194 prim
[i
].begin
= (i
== 0);
1195 prim
[i
].end
= (i
== primcount
- 1);
1198 prim
[i
].mode
= mode
;
1199 prim
[i
].start
= ((uintptr_t)indices
[i
] - min_index_ptr
) / index_type_size
;
1200 prim
[i
].count
= count
[i
];
1201 prim
[i
].indexed
= 1;
1202 prim
[i
].num_instances
= 1;
1203 prim
[i
].base_instance
= 0;
1204 if (basevertex
!= NULL
)
1205 prim
[i
].basevertex
= basevertex
[i
];
1207 prim
[i
].basevertex
= 0;
1210 check_buffers_are_unmapped(exec
->array
.inputs
);
1211 vbo_handle_primitive_restart(ctx
, prim
, primcount
, &ib
,
1214 /* render one prim at a time */
1215 for (i
= 0; i
< primcount
; i
++) {
1216 ib
.count
= count
[i
];
1218 ib
.obj
= ctx
->Array
.ArrayObj
->ElementArrayBufferObj
;
1219 ib
.ptr
= indices
[i
];
1225 prim
[0].mode
= mode
;
1227 prim
[0].count
= count
[i
];
1228 prim
[0].indexed
= 1;
1229 prim
[0].num_instances
= 1;
1230 prim
[0].base_instance
= 0;
1231 if (basevertex
!= NULL
)
1232 prim
[0].basevertex
= basevertex
[i
];
1234 prim
[0].basevertex
= 0;
1236 check_buffers_are_unmapped(exec
->array
.inputs
);
1237 vbo_handle_primitive_restart(ctx
, prim
, 1, &ib
,
1244 if (MESA_DEBUG_FLAGS
& DEBUG_ALWAYS_FLUSH
) {
1250 static void GLAPIENTRY
1251 vbo_exec_MultiDrawElements(GLenum mode
,
1252 const GLsizei
*count
, GLenum type
,
1253 const GLvoid
**indices
,
1256 GET_CURRENT_CONTEXT(ctx
);
1258 if (!_mesa_validate_MultiDrawElements(ctx
, mode
, count
, type
, indices
,
1262 vbo_validated_multidrawelements(ctx
, mode
, count
, type
, indices
, primcount
,
1267 static void GLAPIENTRY
1268 vbo_exec_MultiDrawElementsBaseVertex(GLenum mode
,
1269 const GLsizei
*count
, GLenum type
,
1270 const GLvoid
* const *indices
,
1272 const GLsizei
*basevertex
)
1274 GET_CURRENT_CONTEXT(ctx
);
1276 if (!_mesa_validate_MultiDrawElements(ctx
, mode
, count
, type
, indices
,
1277 primcount
, basevertex
))
1280 vbo_validated_multidrawelements(ctx
, mode
, count
, type
, indices
, primcount
,
1284 #if FEATURE_EXT_transform_feedback
1287 vbo_draw_transform_feedback(struct gl_context
*ctx
, GLenum mode
,
1288 struct gl_transform_feedback_object
*obj
,
1289 GLuint stream
, GLuint numInstances
)
1291 struct vbo_context
*vbo
= vbo_context(ctx
);
1292 struct vbo_exec_context
*exec
= &vbo
->exec
;
1293 struct _mesa_prim prim
[2];
1295 if (!_mesa_validate_DrawTransformFeedback(ctx
, mode
, obj
, stream
,
1300 vbo_bind_arrays(ctx
);
1302 /* init most fields to zero */
1303 memset(prim
, 0, sizeof(prim
));
1306 prim
[0].mode
= mode
;
1307 prim
[0].num_instances
= numInstances
;
1308 prim
[0].base_instance
= 0;
1310 /* Maybe we should do some primitive splitting for primitive restart
1311 * (like in DrawArrays), but we have no way to know how many vertices
1312 * will be rendered. */
1314 check_buffers_are_unmapped(exec
->array
.inputs
);
1315 vbo
->draw_prims(ctx
, prim
, 1, NULL
,
1316 GL_TRUE
, 0, 0, obj
);
1318 if (MESA_DEBUG_FLAGS
& DEBUG_ALWAYS_FLUSH
) {
1324 * Like DrawArrays, but take the count from a transform feedback object.
1325 * \param mode GL_POINTS, GL_LINES, GL_TRIANGLE_STRIP, etc.
1326 * \param name the transform feedback object
1327 * User still has to setup of the vertex attribute info with
1328 * glVertexPointer, glColorPointer, etc.
1329 * Part of GL_ARB_transform_feedback2.
1331 static void GLAPIENTRY
1332 vbo_exec_DrawTransformFeedback(GLenum mode
, GLuint name
)
1334 GET_CURRENT_CONTEXT(ctx
);
1335 struct gl_transform_feedback_object
*obj
=
1336 _mesa_lookup_transform_feedback_object(ctx
, name
);
1338 if (MESA_VERBOSE
& VERBOSE_DRAW
)
1339 _mesa_debug(ctx
, "glDrawTransformFeedback(%s, %d)\n",
1340 _mesa_lookup_enum_by_nr(mode
), name
);
1342 vbo_draw_transform_feedback(ctx
, mode
, obj
, 0, 1);
1345 static void GLAPIENTRY
1346 vbo_exec_DrawTransformFeedbackStream(GLenum mode
, GLuint name
, GLuint stream
)
1348 GET_CURRENT_CONTEXT(ctx
);
1349 struct gl_transform_feedback_object
*obj
=
1350 _mesa_lookup_transform_feedback_object(ctx
, name
);
1352 if (MESA_VERBOSE
& VERBOSE_DRAW
)
1353 _mesa_debug(ctx
, "glDrawTransformFeedbackStream(%s, %u, %u)\n",
1354 _mesa_lookup_enum_by_nr(mode
), name
, stream
);
1356 vbo_draw_transform_feedback(ctx
, mode
, obj
, stream
, 1);
1359 static void GLAPIENTRY
1360 vbo_exec_DrawTransformFeedbackInstanced(GLenum mode
, GLuint name
,
1363 GET_CURRENT_CONTEXT(ctx
);
1364 struct gl_transform_feedback_object
*obj
=
1365 _mesa_lookup_transform_feedback_object(ctx
, name
);
1367 if (MESA_VERBOSE
& VERBOSE_DRAW
)
1368 _mesa_debug(ctx
, "glDrawTransformFeedbackInstanced(%s, %d)\n",
1369 _mesa_lookup_enum_by_nr(mode
), name
);
1371 vbo_draw_transform_feedback(ctx
, mode
, obj
, 0, primcount
);
1374 static void GLAPIENTRY
1375 vbo_exec_DrawTransformFeedbackStreamInstanced(GLenum mode
, GLuint name
,
1376 GLuint stream
, GLsizei primcount
)
1378 GET_CURRENT_CONTEXT(ctx
);
1379 struct gl_transform_feedback_object
*obj
=
1380 _mesa_lookup_transform_feedback_object(ctx
, name
);
1382 if (MESA_VERBOSE
& VERBOSE_DRAW
)
1383 _mesa_debug(ctx
, "glDrawTransformFeedbackStreamInstanced"
1384 "(%s, %u, %u, %i)\n",
1385 _mesa_lookup_enum_by_nr(mode
), name
, stream
, primcount
);
1387 vbo_draw_transform_feedback(ctx
, mode
, obj
, stream
, primcount
);
1393 * Plug in the immediate-mode vertex array drawing commands into the
1394 * givven vbo_exec_context object.
1397 vbo_exec_array_init( struct vbo_exec_context
*exec
)
1399 exec
->vtxfmt
.DrawArrays
= vbo_exec_DrawArrays
;
1400 exec
->vtxfmt
.DrawElements
= vbo_exec_DrawElements
;
1401 exec
->vtxfmt
.DrawRangeElements
= vbo_exec_DrawRangeElements
;
1402 exec
->vtxfmt
.MultiDrawElementsEXT
= vbo_exec_MultiDrawElements
;
1403 exec
->vtxfmt
.DrawElementsBaseVertex
= vbo_exec_DrawElementsBaseVertex
;
1404 exec
->vtxfmt
.DrawRangeElementsBaseVertex
= vbo_exec_DrawRangeElementsBaseVertex
;
1405 exec
->vtxfmt
.MultiDrawElementsBaseVertex
= vbo_exec_MultiDrawElementsBaseVertex
;
1406 exec
->vtxfmt
.DrawArraysInstanced
= vbo_exec_DrawArraysInstanced
;
1407 exec
->vtxfmt
.DrawArraysInstancedBaseInstance
= vbo_exec_DrawArraysInstancedBaseInstance
;
1408 exec
->vtxfmt
.DrawElementsInstanced
= vbo_exec_DrawElementsInstanced
;
1409 exec
->vtxfmt
.DrawElementsInstancedBaseInstance
= vbo_exec_DrawElementsInstancedBaseInstance
;
1410 exec
->vtxfmt
.DrawElementsInstancedBaseVertex
= vbo_exec_DrawElementsInstancedBaseVertex
;
1411 exec
->vtxfmt
.DrawElementsInstancedBaseVertexBaseInstance
= vbo_exec_DrawElementsInstancedBaseVertexBaseInstance
;
1412 #if FEATURE_EXT_transform_feedback
1413 exec
->vtxfmt
.DrawTransformFeedback
= vbo_exec_DrawTransformFeedback
;
1414 exec
->vtxfmt
.DrawTransformFeedbackStream
=
1415 vbo_exec_DrawTransformFeedbackStream
;
1416 exec
->vtxfmt
.DrawTransformFeedbackInstanced
=
1417 vbo_exec_DrawTransformFeedbackInstanced
;
1418 exec
->vtxfmt
.DrawTransformFeedbackStreamInstanced
=
1419 vbo_exec_DrawTransformFeedbackStreamInstanced
;
1425 vbo_exec_array_destroy( struct vbo_exec_context
*exec
)
1433 * The following functions are only used for OpenGL ES 1/2 support.
1434 * And some aren't even supported (yet) in ES 1/2.
1439 _mesa_DrawArrays(GLenum mode
, GLint first
, GLsizei count
)
1441 vbo_exec_DrawArrays(mode
, first
, count
);
1446 _mesa_DrawElements(GLenum mode
, GLsizei count
, GLenum type
,
1447 const GLvoid
*indices
)
1449 vbo_exec_DrawElements(mode
, count
, type
, indices
);
1454 _mesa_DrawElementsBaseVertex(GLenum mode
, GLsizei count
, GLenum type
,
1455 const GLvoid
*indices
, GLint basevertex
)
1457 vbo_exec_DrawElementsBaseVertex(mode
, count
, type
, indices
, basevertex
);
1462 _mesa_DrawRangeElements(GLenum mode
, GLuint start
, GLuint end
, GLsizei count
,
1463 GLenum type
, const GLvoid
*indices
)
1465 vbo_exec_DrawRangeElements(mode
, start
, end
, count
, type
, indices
);
1470 _mesa_DrawRangeElementsBaseVertex(GLenum mode
, GLuint start
, GLuint end
,
1471 GLsizei count
, GLenum type
,
1472 const GLvoid
*indices
, GLint basevertex
)
1474 vbo_exec_DrawRangeElementsBaseVertex(mode
, start
, end
, count
, type
,
1475 indices
, basevertex
);
1480 _mesa_MultiDrawElementsEXT(GLenum mode
, const GLsizei
*count
, GLenum type
,
1481 const GLvoid
**indices
, GLsizei primcount
)
1483 vbo_exec_MultiDrawElements(mode
, count
, type
, indices
, primcount
);
1488 _mesa_MultiDrawElementsBaseVertex(GLenum mode
,
1489 const GLsizei
*count
, GLenum type
,
1490 const GLvoid
**indices
, GLsizei primcount
,
1491 const GLint
*basevertex
)
1493 vbo_exec_MultiDrawElementsBaseVertex(mode
, count
, type
, indices
,
1494 primcount
, basevertex
);
1497 #if FEATURE_EXT_transform_feedback
1500 _mesa_DrawTransformFeedback(GLenum mode
, GLuint name
)
1502 vbo_exec_DrawTransformFeedback(mode
, name
);