mesa: Remove target parameter from dd_function_table::MapBuffer
[mesa.git] / src / mesa / vbo / vbo_exec_array.c
1 /**************************************************************************
2 *
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * Copyright 2009 VMware, Inc.
5 * All Rights Reserved.
6 *
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:
14 *
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
17 * of the Software.
18 *
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.
26 *
27 **************************************************************************/
28
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
38 #include "vbo_context.h"
39
40
41 /**
42 * All vertex buffers should be in an unmapped state when we're about
43 * to draw. This debug function checks that.
44 */
45 static void
46 check_buffers_are_unmapped(const struct gl_client_array **inputs)
47 {
48 #ifdef DEBUG
49 GLuint i;
50
51 for (i = 0; i < VERT_ATTRIB_MAX; i++) {
52 if (inputs[i]) {
53 struct gl_buffer_object *obj = inputs[i]->BufferObj;
54 assert(!_mesa_bufferobj_mapped(obj));
55 (void) obj;
56 }
57 }
58 #endif
59 }
60
61
62 /**
63 * A debug function that may be called from other parts of Mesa as
64 * needed during debugging.
65 */
66 void
67 vbo_check_buffers_are_unmapped(struct gl_context *ctx)
68 {
69 struct vbo_context *vbo = vbo_context(ctx);
70 struct vbo_exec_context *exec = &vbo->exec;
71 /* check the current vertex arrays */
72 check_buffers_are_unmapped(exec->array.inputs);
73 /* check the current glBegin/glVertex/glEnd-style VBO */
74 assert(!_mesa_bufferobj_mapped(exec->vtx.bufferobj));
75 }
76
77
78
79 /**
80 * Compute min and max elements by scanning the index buffer for
81 * glDraw[Range]Elements() calls.
82 * If primitive restart is enabled, we need to ignore restart
83 * indexes when computing min/max.
84 */
85 void
86 vbo_get_minmax_index(struct gl_context *ctx,
87 const struct _mesa_prim *prim,
88 const struct _mesa_index_buffer *ib,
89 GLuint *min_index, GLuint *max_index)
90 {
91 const GLboolean restart = ctx->Array.PrimitiveRestart;
92 const GLuint restartIndex = ctx->Array.RestartIndex;
93 const GLuint count = prim->count;
94 const void *indices;
95 GLuint i;
96
97 if (_mesa_is_bufferobj(ib->obj)) {
98 const GLvoid *map =
99 ctx->Driver.MapBuffer(ctx, GL_READ_ONLY, ib->obj);
100 indices = ADD_POINTERS(map, ib->ptr);
101 } else {
102 indices = ib->ptr;
103 }
104
105 switch (ib->type) {
106 case GL_UNSIGNED_INT: {
107 const GLuint *ui_indices = (const GLuint *)indices;
108 GLuint max_ui = 0;
109 GLuint min_ui = ~0U;
110 if (restart) {
111 for (i = 0; i < count; i++) {
112 if (ui_indices[i] != restartIndex) {
113 if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
114 if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
115 }
116 }
117 }
118 else {
119 for (i = 0; i < count; i++) {
120 if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
121 if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
122 }
123 }
124 *min_index = min_ui;
125 *max_index = max_ui;
126 break;
127 }
128 case GL_UNSIGNED_SHORT: {
129 const GLushort *us_indices = (const GLushort *)indices;
130 GLuint max_us = 0;
131 GLuint min_us = ~0U;
132 if (restart) {
133 for (i = 0; i < count; i++) {
134 if (us_indices[i] != restartIndex) {
135 if (us_indices[i] > max_us) max_us = us_indices[i];
136 if (us_indices[i] < min_us) min_us = us_indices[i];
137 }
138 }
139 }
140 else {
141 for (i = 0; i < count; i++) {
142 if (us_indices[i] > max_us) max_us = us_indices[i];
143 if (us_indices[i] < min_us) min_us = us_indices[i];
144 }
145 }
146 *min_index = min_us;
147 *max_index = max_us;
148 break;
149 }
150 case GL_UNSIGNED_BYTE: {
151 const GLubyte *ub_indices = (const GLubyte *)indices;
152 GLuint max_ub = 0;
153 GLuint min_ub = ~0U;
154 if (restart) {
155 for (i = 0; i < count; i++) {
156 if (ub_indices[i] != restartIndex) {
157 if (ub_indices[i] > max_ub) max_ub = ub_indices[i];
158 if (ub_indices[i] < min_ub) min_ub = ub_indices[i];
159 }
160 }
161 }
162 else {
163 for (i = 0; i < count; i++) {
164 if (ub_indices[i] > max_ub) max_ub = ub_indices[i];
165 if (ub_indices[i] < min_ub) min_ub = ub_indices[i];
166 }
167 }
168 *min_index = min_ub;
169 *max_index = max_ub;
170 break;
171 }
172 default:
173 assert(0);
174 break;
175 }
176
177 if (_mesa_is_bufferobj(ib->obj)) {
178 ctx->Driver.UnmapBuffer(ctx, ib->obj);
179 }
180 }
181
182
183 /**
184 * Check that element 'j' of the array has reasonable data.
185 * Map VBO if needed.
186 * For debugging purposes; not normally used.
187 */
188 static void
189 check_array_data(struct gl_context *ctx, struct gl_client_array *array,
190 GLuint attrib, GLuint j)
191 {
192 if (array->Enabled) {
193 const void *data = array->Ptr;
194 if (_mesa_is_bufferobj(array->BufferObj)) {
195 if (!array->BufferObj->Pointer) {
196 /* need to map now */
197 array->BufferObj->Pointer =
198 ctx->Driver.MapBuffer(ctx, GL_READ_ONLY, array->BufferObj);
199 }
200 data = ADD_POINTERS(data, array->BufferObj->Pointer);
201 }
202 switch (array->Type) {
203 case GL_FLOAT:
204 {
205 GLfloat *f = (GLfloat *) ((GLubyte *) data + array->StrideB * j);
206 GLint k;
207 for (k = 0; k < array->Size; k++) {
208 if (IS_INF_OR_NAN(f[k]) ||
209 f[k] >= 1.0e20 || f[k] <= -1.0e10) {
210 printf("Bad array data:\n");
211 printf(" Element[%u].%u = %f\n", j, k, f[k]);
212 printf(" Array %u at %p\n", attrib, (void* ) array);
213 printf(" Type 0x%x, Size %d, Stride %d\n",
214 array->Type, array->Size, array->Stride);
215 printf(" Address/offset %p in Buffer Object %u\n",
216 array->Ptr, array->BufferObj->Name);
217 f[k] = 1.0; /* XXX replace the bad value! */
218 }
219 /*assert(!IS_INF_OR_NAN(f[k]));*/
220 }
221 }
222 break;
223 default:
224 ;
225 }
226 }
227 }
228
229
230 /**
231 * Unmap the buffer object referenced by given array, if mapped.
232 */
233 static void
234 unmap_array_buffer(struct gl_context *ctx, struct gl_client_array *array)
235 {
236 if (array->Enabled &&
237 _mesa_is_bufferobj(array->BufferObj) &&
238 _mesa_bufferobj_mapped(array->BufferObj)) {
239 ctx->Driver.UnmapBuffer(ctx, array->BufferObj);
240 }
241 }
242
243
244 /**
245 * Examine the array's data for NaNs, etc.
246 * For debug purposes; not normally used.
247 */
248 static void
249 check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType,
250 const void *elements, GLint basevertex)
251 {
252 struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
253 const void *elemMap;
254 GLint i, k;
255
256 if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
257 elemMap = ctx->Driver.MapBuffer(ctx,
258 GL_READ_ONLY,
259 ctx->Array.ElementArrayBufferObj);
260 elements = ADD_POINTERS(elements, elemMap);
261 }
262
263 for (i = 0; i < count; i++) {
264 GLuint j;
265
266 /* j = element[i] */
267 switch (elemType) {
268 case GL_UNSIGNED_BYTE:
269 j = ((const GLubyte *) elements)[i];
270 break;
271 case GL_UNSIGNED_SHORT:
272 j = ((const GLushort *) elements)[i];
273 break;
274 case GL_UNSIGNED_INT:
275 j = ((const GLuint *) elements)[i];
276 break;
277 default:
278 assert(0);
279 }
280
281 /* check element j of each enabled array */
282 check_array_data(ctx, &arrayObj->Vertex, VERT_ATTRIB_POS, j);
283 check_array_data(ctx, &arrayObj->Normal, VERT_ATTRIB_NORMAL, j);
284 check_array_data(ctx, &arrayObj->Color, VERT_ATTRIB_COLOR0, j);
285 check_array_data(ctx, &arrayObj->SecondaryColor, VERT_ATTRIB_COLOR1, j);
286 for (k = 0; k < Elements(arrayObj->TexCoord); k++) {
287 check_array_data(ctx, &arrayObj->TexCoord[k], VERT_ATTRIB_TEX0 + k, j);
288 }
289 for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) {
290 check_array_data(ctx, &arrayObj->VertexAttrib[k],
291 VERT_ATTRIB_GENERIC0 + k, j);
292 }
293 }
294
295 if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
296 ctx->Driver.UnmapBuffer(ctx, ctx->Array.ElementArrayBufferObj);
297 }
298
299 unmap_array_buffer(ctx, &arrayObj->Vertex);
300 unmap_array_buffer(ctx, &arrayObj->Normal);
301 unmap_array_buffer(ctx, &arrayObj->Color);
302 for (k = 0; k < Elements(arrayObj->TexCoord); k++) {
303 unmap_array_buffer(ctx, &arrayObj->TexCoord[k]);
304 }
305 for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) {
306 unmap_array_buffer(ctx, &arrayObj->VertexAttrib[k]);
307 }
308 }
309
310
311 /**
312 * Check array data, looking for NaNs, etc.
313 */
314 static void
315 check_draw_arrays_data(struct gl_context *ctx, GLint start, GLsizei count)
316 {
317 /* TO DO */
318 }
319
320
321 /**
322 * Print info/data for glDrawArrays(), for debugging.
323 */
324 static void
325 print_draw_arrays(struct gl_context *ctx,
326 GLenum mode, GLint start, GLsizei count)
327 {
328 struct vbo_context *vbo = vbo_context(ctx);
329 struct vbo_exec_context *exec = &vbo->exec;
330 int i;
331
332 printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n",
333 mode, start, count);
334
335 for (i = 0; i < 32; i++) {
336 struct gl_buffer_object *bufObj = exec->array.inputs[i]->BufferObj;
337 GLuint bufName = bufObj->Name;
338 GLint stride = exec->array.inputs[i]->Stride;
339 printf("attr %2d: size %d stride %d enabled %d "
340 "ptr %p Bufobj %u\n",
341 i,
342 exec->array.inputs[i]->Size,
343 stride,
344 /*exec->array.inputs[i]->Enabled,*/
345 exec->array.legacy_array[i]->Enabled,
346 exec->array.inputs[i]->Ptr,
347 bufName);
348
349 if (bufName) {
350 GLubyte *p = ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, bufObj);
351 int offset = (int) (GLintptr) exec->array.inputs[i]->Ptr;
352 float *f = (float *) (p + offset);
353 int *k = (int *) f;
354 int i;
355 int n = (count * stride) / 4;
356 if (n > 32)
357 n = 32;
358 printf(" Data at offset %d:\n", offset);
359 for (i = 0; i < n; i++) {
360 printf(" float[%d] = 0x%08x %f\n", i, k[i], f[i]);
361 }
362 ctx->Driver.UnmapBuffer(ctx, bufObj);
363 }
364 }
365 }
366
367
368 /**
369 * Bind the VBO executor to the current vertex array object prior
370 * to drawing.
371 *
372 * Just translate the arrayobj into a sane layout.
373 */
374 static void
375 bind_array_obj(struct gl_context *ctx)
376 {
377 struct vbo_context *vbo = vbo_context(ctx);
378 struct vbo_exec_context *exec = &vbo->exec;
379 struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
380 GLuint i;
381
382 /* TODO: Fix the ArrayObj struct to keep legacy arrays in an array
383 * rather than as individual named arrays. Then this function can
384 * go away.
385 */
386 exec->array.legacy_array[VERT_ATTRIB_POS] = &arrayObj->Vertex;
387 exec->array.legacy_array[VERT_ATTRIB_WEIGHT] = &arrayObj->Weight;
388 exec->array.legacy_array[VERT_ATTRIB_NORMAL] = &arrayObj->Normal;
389 exec->array.legacy_array[VERT_ATTRIB_COLOR0] = &arrayObj->Color;
390 exec->array.legacy_array[VERT_ATTRIB_COLOR1] = &arrayObj->SecondaryColor;
391 exec->array.legacy_array[VERT_ATTRIB_FOG] = &arrayObj->FogCoord;
392 exec->array.legacy_array[VERT_ATTRIB_COLOR_INDEX] = &arrayObj->Index;
393 if (arrayObj->PointSize.Enabled) {
394 /* this aliases COLOR_INDEX */
395 exec->array.legacy_array[VERT_ATTRIB_POINT_SIZE] = &arrayObj->PointSize;
396 }
397 exec->array.legacy_array[VERT_ATTRIB_EDGEFLAG] = &arrayObj->EdgeFlag;
398
399 for (i = 0; i < Elements(arrayObj->TexCoord); i++)
400 exec->array.legacy_array[VERT_ATTRIB_TEX0 + i] = &arrayObj->TexCoord[i];
401
402 for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) {
403 assert(i < Elements(exec->array.generic_array));
404 exec->array.generic_array[i] = &arrayObj->VertexAttrib[i];
405 }
406
407 exec->array.array_obj = arrayObj->Name;
408 }
409
410
411 /**
412 * Set the vbo->exec->inputs[] pointers to point to the enabled
413 * vertex arrays. This depends on the current vertex program/shader
414 * being executed because of whether or not generic vertex arrays
415 * alias the conventional vertex arrays.
416 * For arrays that aren't enabled, we set the input[attrib] pointer
417 * to point at a zero-stride current value "array".
418 */
419 static void
420 recalculate_input_bindings(struct gl_context *ctx)
421 {
422 struct vbo_context *vbo = vbo_context(ctx);
423 struct vbo_exec_context *exec = &vbo->exec;
424 const struct gl_client_array **inputs = &exec->array.inputs[0];
425 GLbitfield const_inputs = 0x0;
426 GLuint i;
427
428 exec->array.program_mode = get_program_mode(ctx);
429 exec->array.enabled_flags = ctx->Array.ArrayObj->_Enabled;
430
431 switch (exec->array.program_mode) {
432 case VP_NONE:
433 /* When no vertex program is active (or the vertex program is generated
434 * from fixed-function state). We put the material values into the
435 * generic slots. This is the only situation where material values
436 * are available as per-vertex attributes.
437 */
438 for (i = 0; i <= VERT_ATTRIB_TEX7; i++) {
439 if (exec->array.legacy_array[i]->Enabled)
440 inputs[i] = exec->array.legacy_array[i];
441 else {
442 inputs[i] = &vbo->legacy_currval[i];
443 const_inputs |= 1 << i;
444 }
445 }
446
447 for (i = 0; i < MAT_ATTRIB_MAX; i++) {
448 inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->mat_currval[i];
449 const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
450 }
451
452 /* Could use just about anything, just to fill in the empty
453 * slots:
454 */
455 for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_MAX - VERT_ATTRIB_GENERIC0; i++) {
456 inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
457 const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
458 }
459
460 /* There is no need to make _NEW_ARRAY dirty here for the TnL program,
461 * because it already takes care of invalidating the state necessary
462 * to revalidate vertex arrays. Not marking the state as dirty also
463 * improves performance (quite significantly in some apps).
464 */
465 if (!ctx->VertexProgram._MaintainTnlProgram)
466 ctx->NewState |= _NEW_ARRAY;
467 break;
468
469 case VP_NV:
470 /* NV_vertex_program - attribute arrays alias and override
471 * conventional, legacy arrays. No materials, and the generic
472 * slots are vacant.
473 */
474 for (i = 0; i <= VERT_ATTRIB_TEX7; i++) {
475 if (exec->array.generic_array[i]->Enabled)
476 inputs[i] = exec->array.generic_array[i];
477 else if (exec->array.legacy_array[i]->Enabled)
478 inputs[i] = exec->array.legacy_array[i];
479 else {
480 inputs[i] = &vbo->legacy_currval[i];
481 const_inputs |= 1 << i;
482 }
483 }
484
485 /* Could use just about anything, just to fill in the empty
486 * slots:
487 */
488 for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) {
489 inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0];
490 const_inputs |= 1 << i;
491 }
492
493 ctx->NewState |= _NEW_ARRAY;
494 break;
495
496 case VP_ARB:
497 /* GL_ARB_vertex_program or GLSL vertex shader - Only the generic[0]
498 * attribute array aliases and overrides the legacy position array.
499 *
500 * Otherwise, legacy attributes available in the legacy slots,
501 * generic attributes in the generic slots and materials are not
502 * available as per-vertex attributes.
503 */
504 if (exec->array.generic_array[0]->Enabled)
505 inputs[0] = exec->array.generic_array[0];
506 else if (exec->array.legacy_array[0]->Enabled)
507 inputs[0] = exec->array.legacy_array[0];
508 else {
509 inputs[0] = &vbo->legacy_currval[0];
510 const_inputs |= 1 << 0;
511 }
512
513 for (i = 1; i <= VERT_ATTRIB_TEX7; i++) {
514 if (exec->array.legacy_array[i]->Enabled)
515 inputs[i] = exec->array.legacy_array[i];
516 else {
517 inputs[i] = &vbo->legacy_currval[i];
518 const_inputs |= 1 << i;
519 }
520 }
521
522 for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) {
523 if (exec->array.generic_array[i]->Enabled)
524 inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i];
525 else {
526 inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
527 const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
528 }
529 }
530
531 ctx->NewState |= _NEW_ARRAY;
532 break;
533 }
534
535 _mesa_set_varying_vp_inputs( ctx, ~const_inputs );
536 }
537
538
539 /**
540 * Examine the enabled vertex arrays to set the exec->array.inputs[] values.
541 * These will point to the arrays to actually use for drawing. Some will
542 * be user-provided arrays, other will be zero-stride const-valued arrays.
543 * Note that this might set the _NEW_ARRAY dirty flag so state validation
544 * must be done after this call.
545 */
546 static void
547 bind_arrays(struct gl_context *ctx)
548 {
549 if (!ctx->Array.RebindArrays) {
550 return;
551 }
552
553 bind_array_obj(ctx);
554 recalculate_input_bindings(ctx);
555 ctx->Array.RebindArrays = GL_FALSE;
556 }
557
558
559 /**
560 * Helper function called by the other DrawArrays() functions below.
561 * This is where we handle primitive restart for drawing non-indexed
562 * arrays. If primitive restart is enabled, it typically means
563 * splitting one DrawArrays() into two.
564 */
565 static void
566 vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
567 GLsizei count, GLuint numInstances)
568 {
569 struct vbo_context *vbo = vbo_context(ctx);
570 struct vbo_exec_context *exec = &vbo->exec;
571 struct _mesa_prim prim[2];
572
573 bind_arrays(ctx);
574
575 /* Again... because we may have changed the bitmask of per-vertex varying
576 * attributes. If we regenerate the fixed-function vertex program now
577 * we may be able to prune down the number of vertex attributes which we
578 * need in the shader.
579 */
580 if (ctx->NewState)
581 _mesa_update_state(ctx);
582
583 /* init most fields to zero */
584 memset(prim, 0, sizeof(prim));
585 prim[0].begin = 1;
586 prim[0].end = 1;
587 prim[0].mode = mode;
588 prim[0].num_instances = numInstances;
589
590 /* Implement the primitive restart index */
591 if (ctx->Array.PrimitiveRestart && ctx->Array.RestartIndex < count) {
592 GLuint primCount = 0;
593
594 if (ctx->Array.RestartIndex == start) {
595 /* special case: RestartIndex at beginning */
596 if (count > 1) {
597 prim[0].start = start + 1;
598 prim[0].count = count - 1;
599 primCount = 1;
600 }
601 }
602 else if (ctx->Array.RestartIndex == start + count - 1) {
603 /* special case: RestartIndex at end */
604 if (count > 1) {
605 prim[0].start = start;
606 prim[0].count = count - 1;
607 primCount = 1;
608 }
609 }
610 else {
611 /* general case: RestartIndex in middle, split into two prims */
612 prim[0].start = start;
613 prim[0].count = ctx->Array.RestartIndex - start;
614
615 prim[1] = prim[0];
616 prim[1].start = ctx->Array.RestartIndex + 1;
617 prim[1].count = count - prim[1].start;
618
619 primCount = 2;
620 }
621
622 if (primCount > 0) {
623 /* draw one or two prims */
624 check_buffers_are_unmapped(exec->array.inputs);
625 vbo->draw_prims(ctx, exec->array.inputs, prim, primCount, NULL,
626 GL_TRUE, start, start + count - 1);
627 }
628 }
629 else {
630 /* no prim restart */
631 prim[0].start = start;
632 prim[0].count = count;
633
634 check_buffers_are_unmapped(exec->array.inputs);
635 vbo->draw_prims(ctx, exec->array.inputs, prim, 1, NULL,
636 GL_TRUE, start, start + count - 1);
637 }
638 }
639
640
641
642 /**
643 * Called from glDrawArrays when in immediate mode (not display list mode).
644 */
645 static void GLAPIENTRY
646 vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count)
647 {
648 GET_CURRENT_CONTEXT(ctx);
649
650 if (MESA_VERBOSE & VERBOSE_DRAW)
651 _mesa_debug(ctx, "glDrawArrays(%s, %d, %d)\n",
652 _mesa_lookup_enum_by_nr(mode), start, count);
653
654 if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
655 return;
656
657 FLUSH_CURRENT( ctx, 0 );
658
659 if (!_mesa_valid_to_render(ctx, "glDrawArrays")) {
660 return;
661 }
662
663 if (0)
664 check_draw_arrays_data(ctx, start, count);
665
666 vbo_draw_arrays(ctx, mode, start, count, 1);
667
668 if (0)
669 print_draw_arrays(ctx, mode, start, count);
670 }
671
672
673 /**
674 * Called from glDrawArraysInstanced when in immediate mode (not
675 * display list mode).
676 */
677 static void GLAPIENTRY
678 vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count,
679 GLsizei numInstances)
680 {
681 GET_CURRENT_CONTEXT(ctx);
682
683 if (MESA_VERBOSE & VERBOSE_DRAW)
684 _mesa_debug(ctx, "glDrawArraysInstanced(%s, %d, %d, %d)\n",
685 _mesa_lookup_enum_by_nr(mode), start, count, numInstances);
686
687 if (!_mesa_validate_DrawArraysInstanced(ctx, mode, start, count, numInstances))
688 return;
689
690 FLUSH_CURRENT( ctx, 0 );
691
692 if (!_mesa_valid_to_render(ctx, "glDrawArraysInstanced")) {
693 return;
694 }
695
696 if (0)
697 check_draw_arrays_data(ctx, start, count);
698
699 vbo_draw_arrays(ctx, mode, start, count, numInstances);
700
701 if (0)
702 print_draw_arrays(ctx, mode, start, count);
703 }
704
705
706 /**
707 * Map GL_ELEMENT_ARRAY_BUFFER and print contents.
708 * For debugging.
709 */
710 static void
711 dump_element_buffer(struct gl_context *ctx, GLenum type)
712 {
713 const GLvoid *map = ctx->Driver.MapBuffer(ctx,
714 GL_READ_ONLY,
715 ctx->Array.ElementArrayBufferObj);
716 switch (type) {
717 case GL_UNSIGNED_BYTE:
718 {
719 const GLubyte *us = (const GLubyte *) map;
720 GLint i;
721 for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size; i++) {
722 printf("%02x ", us[i]);
723 if (i % 32 == 31)
724 printf("\n");
725 }
726 printf("\n");
727 }
728 break;
729 case GL_UNSIGNED_SHORT:
730 {
731 const GLushort *us = (const GLushort *) map;
732 GLint i;
733 for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 2; i++) {
734 printf("%04x ", us[i]);
735 if (i % 16 == 15)
736 printf("\n");
737 }
738 printf("\n");
739 }
740 break;
741 case GL_UNSIGNED_INT:
742 {
743 const GLuint *us = (const GLuint *) map;
744 GLint i;
745 for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 4; i++) {
746 printf("%08x ", us[i]);
747 if (i % 8 == 7)
748 printf("\n");
749 }
750 printf("\n");
751 }
752 break;
753 default:
754 ;
755 }
756
757 ctx->Driver.UnmapBuffer(ctx, ctx->Array.ElementArrayBufferObj);
758 }
759
760
761 /**
762 * Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements.
763 * Do the rendering for a glDrawElements or glDrawRangeElements call after
764 * we've validated buffer bounds, etc.
765 */
766 static void
767 vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
768 GLboolean index_bounds_valid,
769 GLuint start, GLuint end,
770 GLsizei count, GLenum type,
771 const GLvoid *indices,
772 GLint basevertex, GLint numInstances)
773 {
774 struct vbo_context *vbo = vbo_context(ctx);
775 struct vbo_exec_context *exec = &vbo->exec;
776 struct _mesa_index_buffer ib;
777 struct _mesa_prim prim[1];
778
779 FLUSH_CURRENT( ctx, 0 );
780
781 if (!_mesa_valid_to_render(ctx, "glDraw[Range]Elements")) {
782 return;
783 }
784
785 bind_arrays( ctx );
786
787 /* check for dirty state again */
788 if (ctx->NewState)
789 _mesa_update_state( ctx );
790
791 ib.count = count;
792 ib.type = type;
793 ib.obj = ctx->Array.ElementArrayBufferObj;
794 ib.ptr = indices;
795
796 prim[0].begin = 1;
797 prim[0].end = 1;
798 prim[0].weak = 0;
799 prim[0].pad = 0;
800 prim[0].mode = mode;
801 prim[0].start = 0;
802 prim[0].count = count;
803 prim[0].indexed = 1;
804 prim[0].basevertex = basevertex;
805 prim[0].num_instances = numInstances;
806
807 /* Need to give special consideration to rendering a range of
808 * indices starting somewhere above zero. Typically the
809 * application is issuing multiple DrawRangeElements() to draw
810 * successive primitives layed out linearly in the vertex arrays.
811 * Unless the vertex arrays are all in a VBO (or locked as with
812 * CVA), the OpenGL semantics imply that we need to re-read or
813 * re-upload the vertex data on each draw call.
814 *
815 * In the case of hardware tnl, we want to avoid starting the
816 * upload at zero, as it will mean every draw call uploads an
817 * increasing amount of not-used vertex data. Worse - in the
818 * software tnl module, all those vertices might be transformed and
819 * lit but never rendered.
820 *
821 * If we just upload or transform the vertices in start..end,
822 * however, the indices will be incorrect.
823 *
824 * At this level, we don't know exactly what the requirements of
825 * the backend are going to be, though it will likely boil down to
826 * either:
827 *
828 * 1) Do nothing, everything is in a VBO and is processed once
829 * only.
830 *
831 * 2) Adjust the indices and vertex arrays so that start becomes
832 * zero.
833 *
834 * Rather than doing anything here, I'll provide a helper function
835 * for the latter case elsewhere.
836 */
837
838 check_buffers_are_unmapped(exec->array.inputs);
839 vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib,
840 index_bounds_valid, start, end );
841 }
842
843
844 /**
845 * Called by glDrawRangeElementsBaseVertex() in immediate mode.
846 */
847 static void GLAPIENTRY
848 vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
849 GLuint start, GLuint end,
850 GLsizei count, GLenum type,
851 const GLvoid *indices,
852 GLint basevertex)
853 {
854 static GLuint warnCount = 0;
855 GET_CURRENT_CONTEXT(ctx);
856
857 if (MESA_VERBOSE & VERBOSE_DRAW)
858 _mesa_debug(ctx,
859 "glDrawRangeElementsBaseVertex(%s, %u, %u, %d, %s, %p, %d)\n",
860 _mesa_lookup_enum_by_nr(mode), start, end, count,
861 _mesa_lookup_enum_by_nr(type), indices, basevertex);
862
863 if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count,
864 type, indices, basevertex ))
865 return;
866
867 /* NOTE: It's important that 'end' is a reasonable value.
868 * in _tnl_draw_prims(), we use end to determine how many vertices
869 * to transform. If it's too large, we can unnecessarily split prims
870 * or we can read/write out of memory in several different places!
871 */
872
873 /* Catch/fix some potential user errors */
874 if (type == GL_UNSIGNED_BYTE) {
875 start = MIN2(start, 0xff);
876 end = MIN2(end, 0xff);
877 }
878 else if (type == GL_UNSIGNED_SHORT) {
879 start = MIN2(start, 0xffff);
880 end = MIN2(end, 0xffff);
881 }
882
883 if (end >= ctx->Array.ArrayObj->_MaxElement) {
884 /* the max element is out of bounds of one or more enabled arrays */
885 warnCount++;
886
887 if (warnCount < 10) {
888 _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, count %d, "
889 "type 0x%x, indices=%p)\n"
890 "\tend is out of bounds (max=%u) "
891 "Element Buffer %u (size %d)\n"
892 "\tThis should probably be fixed in the application.",
893 start, end, count, type, indices,
894 ctx->Array.ArrayObj->_MaxElement - 1,
895 ctx->Array.ElementArrayBufferObj->Name,
896 (int) ctx->Array.ElementArrayBufferObj->Size);
897 }
898
899 if (0)
900 dump_element_buffer(ctx, type);
901
902 if (0)
903 _mesa_print_arrays(ctx);
904
905 /* 'end' was out of bounds, but now let's check the actual array
906 * indexes to see if any of them are out of bounds.
907 */
908 if (0) {
909 GLuint max = _mesa_max_buffer_index(ctx, count, type, indices,
910 ctx->Array.ElementArrayBufferObj);
911 if (max >= ctx->Array.ArrayObj->_MaxElement) {
912 if (warnCount < 10) {
913 _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, "
914 "count %d, type 0x%x, indices=%p)\n"
915 "\tindex=%u is out of bounds (max=%u) "
916 "Element Buffer %u (size %d)\n"
917 "\tSkipping the glDrawRangeElements() call",
918 start, end, count, type, indices, max,
919 ctx->Array.ArrayObj->_MaxElement - 1,
920 ctx->Array.ElementArrayBufferObj->Name,
921 (int) ctx->Array.ElementArrayBufferObj->Size);
922 }
923 }
924 /* XXX we could also find the min index and compare to 'start'
925 * to see if start is correct. But it's more likely to get the
926 * upper bound wrong.
927 */
928 }
929
930 /* Set 'end' to the max possible legal value */
931 assert(ctx->Array.ArrayObj->_MaxElement >= 1);
932 end = ctx->Array.ArrayObj->_MaxElement - 1;
933
934 if (end < start) {
935 return;
936 }
937 }
938
939 if (0) {
940 printf("glDraw[Range]Elements{,BaseVertex}"
941 "(start %u, end %u, type 0x%x, count %d) ElemBuf %u, "
942 "base %d\n",
943 start, end, type, count,
944 ctx->Array.ElementArrayBufferObj->Name,
945 basevertex);
946 }
947
948 #if 0
949 check_draw_elements_data(ctx, count, type, indices);
950 #else
951 (void) check_draw_elements_data;
952 #endif
953
954 vbo_validated_drawrangeelements(ctx, mode, GL_TRUE, start, end,
955 count, type, indices, basevertex, 1);
956 }
957
958
959 /**
960 * Called by glDrawRangeElements() in immediate mode.
961 */
962 static void GLAPIENTRY
963 vbo_exec_DrawRangeElements(GLenum mode, GLuint start, GLuint end,
964 GLsizei count, GLenum type, const GLvoid *indices)
965 {
966 if (MESA_VERBOSE & VERBOSE_DRAW) {
967 GET_CURRENT_CONTEXT(ctx);
968 _mesa_debug(ctx,
969 "glDrawRangeElements(%s, %u, %u, %d, %s, %p)\n",
970 _mesa_lookup_enum_by_nr(mode), start, end, count,
971 _mesa_lookup_enum_by_nr(type), indices);
972 }
973
974 vbo_exec_DrawRangeElementsBaseVertex(mode, start, end, count, type,
975 indices, 0);
976 }
977
978
979 /**
980 * Called by glDrawElements() in immediate mode.
981 */
982 static void GLAPIENTRY
983 vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type,
984 const GLvoid *indices)
985 {
986 GET_CURRENT_CONTEXT(ctx);
987
988 if (MESA_VERBOSE & VERBOSE_DRAW)
989 _mesa_debug(ctx, "glDrawElements(%s, %u, %s, %p)\n",
990 _mesa_lookup_enum_by_nr(mode), count,
991 _mesa_lookup_enum_by_nr(type), indices);
992
993 if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 ))
994 return;
995
996 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
997 count, type, indices, 0, 1);
998 }
999
1000
1001 /**
1002 * Called by glDrawElementsBaseVertex() in immediate mode.
1003 */
1004 static void GLAPIENTRY
1005 vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
1006 const GLvoid *indices, GLint basevertex)
1007 {
1008 GET_CURRENT_CONTEXT(ctx);
1009
1010 if (MESA_VERBOSE & VERBOSE_DRAW)
1011 _mesa_debug(ctx, "glDrawElementsBaseVertex(%s, %d, %s, %p, %d)\n",
1012 _mesa_lookup_enum_by_nr(mode), count,
1013 _mesa_lookup_enum_by_nr(type), indices, basevertex);
1014
1015 if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices,
1016 basevertex ))
1017 return;
1018
1019 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
1020 count, type, indices, basevertex, 1);
1021 }
1022
1023
1024 /**
1025 * Called by glDrawElementsInstanced() in immediate mode.
1026 */
1027 static void GLAPIENTRY
1028 vbo_exec_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
1029 const GLvoid *indices, GLsizei numInstances)
1030 {
1031 GET_CURRENT_CONTEXT(ctx);
1032
1033 if (MESA_VERBOSE & VERBOSE_DRAW)
1034 _mesa_debug(ctx, "glDrawElementsInstanced(%s, %d, %s, %p, %d)\n",
1035 _mesa_lookup_enum_by_nr(mode), count,
1036 _mesa_lookup_enum_by_nr(type), indices, numInstances);
1037
1038 if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
1039 numInstances, 0))
1040 return;
1041
1042 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
1043 count, type, indices, 0, numInstances);
1044 }
1045
1046 /**
1047 * Called by glDrawElementsInstancedBaseVertex() in immediate mode.
1048 */
1049 static void GLAPIENTRY
1050 vbo_exec_DrawElementsInstancedBaseVertex(GLenum mode, GLsizei count, GLenum type,
1051 const GLvoid *indices, GLsizei numInstances,
1052 GLint basevertex)
1053 {
1054 GET_CURRENT_CONTEXT(ctx);
1055
1056 if (MESA_VERBOSE & VERBOSE_DRAW)
1057 _mesa_debug(ctx, "glDrawElementsInstancedBaseVertex(%s, %d, %s, %p, %d; %d)\n",
1058 _mesa_lookup_enum_by_nr(mode), count,
1059 _mesa_lookup_enum_by_nr(type), indices,
1060 numInstances, basevertex);
1061
1062 if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
1063 numInstances, basevertex))
1064 return;
1065
1066 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
1067 count, type, indices, basevertex, numInstances);
1068 }
1069
1070
1071 /**
1072 * Inner support for both _mesa_MultiDrawElements() and
1073 * _mesa_MultiDrawRangeElements().
1074 * This does the actual rendering after we've checked array indexes, etc.
1075 */
1076 static void
1077 vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
1078 const GLsizei *count, GLenum type,
1079 const GLvoid **indices, GLsizei primcount,
1080 const GLint *basevertex)
1081 {
1082 struct vbo_context *vbo = vbo_context(ctx);
1083 struct vbo_exec_context *exec = &vbo->exec;
1084 struct _mesa_index_buffer ib;
1085 struct _mesa_prim *prim;
1086 unsigned int index_type_size = 0;
1087 uintptr_t min_index_ptr, max_index_ptr;
1088 GLboolean fallback = GL_FALSE;
1089 int i;
1090
1091 if (primcount == 0)
1092 return;
1093
1094 FLUSH_CURRENT( ctx, 0 );
1095
1096 if (!_mesa_valid_to_render(ctx, "glMultiDrawElements")) {
1097 return;
1098 }
1099
1100 prim = calloc(1, primcount * sizeof(*prim));
1101 if (prim == NULL) {
1102 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElements");
1103 return;
1104 }
1105
1106 /* Decide if we can do this all as one set of primitives sharing the
1107 * same index buffer, or if we have to reset the index pointer per
1108 * primitive.
1109 */
1110 bind_arrays( ctx );
1111
1112 /* check for dirty state again */
1113 if (ctx->NewState)
1114 _mesa_update_state( ctx );
1115
1116 switch (type) {
1117 case GL_UNSIGNED_INT:
1118 index_type_size = 4;
1119 break;
1120 case GL_UNSIGNED_SHORT:
1121 index_type_size = 2;
1122 break;
1123 case GL_UNSIGNED_BYTE:
1124 index_type_size = 1;
1125 break;
1126 default:
1127 assert(0);
1128 }
1129
1130 min_index_ptr = (uintptr_t)indices[0];
1131 max_index_ptr = 0;
1132 for (i = 0; i < primcount; i++) {
1133 min_index_ptr = MIN2(min_index_ptr, (uintptr_t)indices[i]);
1134 max_index_ptr = MAX2(max_index_ptr, (uintptr_t)indices[i] +
1135 index_type_size * count[i]);
1136 }
1137
1138 /* Check if we can handle this thing as a bunch of index offsets from the
1139 * same index pointer. If we can't, then we have to fall back to doing
1140 * a draw_prims per primitive.
1141 * Check that the difference between each prim's indexes is a multiple of
1142 * the index/element size.
1143 */
1144 if (index_type_size != 1) {
1145 for (i = 0; i < primcount; i++) {
1146 if ((((uintptr_t)indices[i] - min_index_ptr) % index_type_size) != 0) {
1147 fallback = GL_TRUE;
1148 break;
1149 }
1150 }
1151 }
1152
1153 /* If the index buffer isn't in a VBO, then treating the application's
1154 * subranges of the index buffer as one large index buffer may lead to
1155 * us reading unmapped memory.
1156 */
1157 if (!_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj))
1158 fallback = GL_TRUE;
1159
1160 if (!fallback) {
1161 ib.count = (max_index_ptr - min_index_ptr) / index_type_size;
1162 ib.type = type;
1163 ib.obj = ctx->Array.ElementArrayBufferObj;
1164 ib.ptr = (void *)min_index_ptr;
1165
1166 for (i = 0; i < primcount; i++) {
1167 prim[i].begin = (i == 0);
1168 prim[i].end = (i == primcount - 1);
1169 prim[i].weak = 0;
1170 prim[i].pad = 0;
1171 prim[i].mode = mode;
1172 prim[i].start = ((uintptr_t)indices[i] - min_index_ptr) / index_type_size;
1173 prim[i].count = count[i];
1174 prim[i].indexed = 1;
1175 prim[i].num_instances = 1;
1176 if (basevertex != NULL)
1177 prim[i].basevertex = basevertex[i];
1178 else
1179 prim[i].basevertex = 0;
1180 }
1181
1182 check_buffers_are_unmapped(exec->array.inputs);
1183 vbo->draw_prims(ctx, exec->array.inputs, prim, primcount, &ib,
1184 GL_FALSE, ~0, ~0);
1185 } else {
1186 /* render one prim at a time */
1187 for (i = 0; i < primcount; i++) {
1188 ib.count = count[i];
1189 ib.type = type;
1190 ib.obj = ctx->Array.ElementArrayBufferObj;
1191 ib.ptr = indices[i];
1192
1193 prim[0].begin = 1;
1194 prim[0].end = 1;
1195 prim[0].weak = 0;
1196 prim[0].pad = 0;
1197 prim[0].mode = mode;
1198 prim[0].start = 0;
1199 prim[0].count = count[i];
1200 prim[0].indexed = 1;
1201 prim[0].num_instances = 1;
1202 if (basevertex != NULL)
1203 prim[0].basevertex = basevertex[i];
1204 else
1205 prim[0].basevertex = 0;
1206
1207 check_buffers_are_unmapped(exec->array.inputs);
1208 vbo->draw_prims(ctx, exec->array.inputs, prim, 1, &ib,
1209 GL_FALSE, ~0, ~0);
1210 }
1211 }
1212
1213 free(prim);
1214 }
1215
1216
1217 static void GLAPIENTRY
1218 vbo_exec_MultiDrawElements(GLenum mode,
1219 const GLsizei *count, GLenum type,
1220 const GLvoid **indices,
1221 GLsizei primcount)
1222 {
1223 GET_CURRENT_CONTEXT(ctx);
1224 GLint i;
1225
1226 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
1227
1228 for (i = 0; i < primcount; i++) {
1229 if (!_mesa_validate_DrawElements(ctx, mode, count[i], type, indices[i],
1230 0))
1231 return;
1232 }
1233
1234 vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount,
1235 NULL);
1236 }
1237
1238
1239 static void GLAPIENTRY
1240 vbo_exec_MultiDrawElementsBaseVertex(GLenum mode,
1241 const GLsizei *count, GLenum type,
1242 const GLvoid **indices,
1243 GLsizei primcount,
1244 const GLsizei *basevertex)
1245 {
1246 GET_CURRENT_CONTEXT(ctx);
1247 GLint i;
1248
1249 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
1250
1251 for (i = 0; i < primcount; i++) {
1252 if (!_mesa_validate_DrawElements(ctx, mode, count[i], type, indices[i],
1253 basevertex[i]))
1254 return;
1255 }
1256
1257 vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount,
1258 basevertex);
1259 }
1260
1261
1262 /**
1263 * Plug in the immediate-mode vertex array drawing commands into the
1264 * givven vbo_exec_context object.
1265 */
1266 void
1267 vbo_exec_array_init( struct vbo_exec_context *exec )
1268 {
1269 exec->vtxfmt.DrawArrays = vbo_exec_DrawArrays;
1270 exec->vtxfmt.DrawElements = vbo_exec_DrawElements;
1271 exec->vtxfmt.DrawRangeElements = vbo_exec_DrawRangeElements;
1272 exec->vtxfmt.MultiDrawElementsEXT = vbo_exec_MultiDrawElements;
1273 exec->vtxfmt.DrawElementsBaseVertex = vbo_exec_DrawElementsBaseVertex;
1274 exec->vtxfmt.DrawRangeElementsBaseVertex = vbo_exec_DrawRangeElementsBaseVertex;
1275 exec->vtxfmt.MultiDrawElementsBaseVertex = vbo_exec_MultiDrawElementsBaseVertex;
1276 exec->vtxfmt.DrawArraysInstanced = vbo_exec_DrawArraysInstanced;
1277 exec->vtxfmt.DrawElementsInstanced = vbo_exec_DrawElementsInstanced;
1278 exec->vtxfmt.DrawElementsInstancedBaseVertex = vbo_exec_DrawElementsInstancedBaseVertex;
1279 }
1280
1281
1282 void
1283 vbo_exec_array_destroy( struct vbo_exec_context *exec )
1284 {
1285 /* nothing to do */
1286 }
1287
1288
1289
1290 /**
1291 * The following functions are only used for OpenGL ES 1/2 support.
1292 * And some aren't even supported (yet) in ES 1/2.
1293 */
1294
1295
1296 void GLAPIENTRY
1297 _mesa_DrawArrays(GLenum mode, GLint first, GLsizei count)
1298 {
1299 vbo_exec_DrawArrays(mode, first, count);
1300 }
1301
1302
1303 void GLAPIENTRY
1304 _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type,
1305 const GLvoid *indices)
1306 {
1307 vbo_exec_DrawElements(mode, count, type, indices);
1308 }
1309
1310
1311 void GLAPIENTRY
1312 _mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
1313 const GLvoid *indices, GLint basevertex)
1314 {
1315 vbo_exec_DrawElementsBaseVertex(mode, count, type, indices, basevertex);
1316 }
1317
1318
1319 void GLAPIENTRY
1320 _mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
1321 GLenum type, const GLvoid *indices)
1322 {
1323 vbo_exec_DrawRangeElements(mode, start, end, count, type, indices);
1324 }
1325
1326
1327 void GLAPIENTRY
1328 _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
1329 GLsizei count, GLenum type,
1330 const GLvoid *indices, GLint basevertex)
1331 {
1332 vbo_exec_DrawRangeElementsBaseVertex(mode, start, end, count, type,
1333 indices, basevertex);
1334 }
1335
1336
1337 void GLAPIENTRY
1338 _mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type,
1339 const GLvoid **indices, GLsizei primcount)
1340 {
1341 vbo_exec_MultiDrawElements(mode, count, type, indices, primcount);
1342 }
1343
1344
1345 void GLAPIENTRY
1346 _mesa_MultiDrawElementsBaseVertex(GLenum mode,
1347 const GLsizei *count, GLenum type,
1348 const GLvoid **indices, GLsizei primcount,
1349 const GLint *basevertex)
1350 {
1351 vbo_exec_MultiDrawElementsBaseVertex(mode, count, type, indices,
1352 primcount, basevertex);
1353 }