vbo: silence unused var warning
[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_ELEMENT_ARRAY_BUFFER_ARB,
100 GL_READ_ONLY, ib->obj);
101 indices = ADD_POINTERS(map, ib->ptr);
102 } else {
103 indices = ib->ptr;
104 }
105
106 switch (ib->type) {
107 case GL_UNSIGNED_INT: {
108 const GLuint *ui_indices = (const GLuint *)indices;
109 GLuint max_ui = 0;
110 GLuint min_ui = ~0U;
111 if (restart) {
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];
116 }
117 }
118 }
119 else {
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];
123 }
124 }
125 *min_index = min_ui;
126 *max_index = max_ui;
127 break;
128 }
129 case GL_UNSIGNED_SHORT: {
130 const GLushort *us_indices = (const GLushort *)indices;
131 GLuint max_us = 0;
132 GLuint min_us = ~0U;
133 if (restart) {
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];
138 }
139 }
140 }
141 else {
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];
145 }
146 }
147 *min_index = min_us;
148 *max_index = max_us;
149 break;
150 }
151 case GL_UNSIGNED_BYTE: {
152 const GLubyte *ub_indices = (const GLubyte *)indices;
153 GLuint max_ub = 0;
154 GLuint min_ub = ~0U;
155 if (restart) {
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];
160 }
161 }
162 }
163 else {
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];
167 }
168 }
169 *min_index = min_ub;
170 *max_index = max_ub;
171 break;
172 }
173 default:
174 assert(0);
175 break;
176 }
177
178 if (_mesa_is_bufferobj(ib->obj)) {
179 ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, ib->obj);
180 }
181 }
182
183
184 /**
185 * Check that element 'j' of the array has reasonable data.
186 * Map VBO if needed.
187 * For debugging purposes; not normally used.
188 */
189 static void
190 check_array_data(struct gl_context *ctx, struct gl_client_array *array,
191 GLuint attrib, GLuint j)
192 {
193 if (array->Enabled) {
194 const void *data = array->Ptr;
195 if (_mesa_is_bufferobj(array->BufferObj)) {
196 if (!array->BufferObj->Pointer) {
197 /* need to map now */
198 array->BufferObj->Pointer =
199 ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB,
200 GL_READ_ONLY, array->BufferObj);
201 }
202 data = ADD_POINTERS(data, array->BufferObj->Pointer);
203 }
204 switch (array->Type) {
205 case GL_FLOAT:
206 {
207 GLfloat *f = (GLfloat *) ((GLubyte *) data + array->StrideB * j);
208 GLint k;
209 for (k = 0; k < array->Size; k++) {
210 if (IS_INF_OR_NAN(f[k]) ||
211 f[k] >= 1.0e20 || f[k] <= -1.0e10) {
212 printf("Bad array data:\n");
213 printf(" Element[%u].%u = %f\n", j, k, f[k]);
214 printf(" Array %u at %p\n", attrib, (void* ) array);
215 printf(" Type 0x%x, Size %d, Stride %d\n",
216 array->Type, array->Size, array->Stride);
217 printf(" Address/offset %p in Buffer Object %u\n",
218 array->Ptr, array->BufferObj->Name);
219 f[k] = 1.0; /* XXX replace the bad value! */
220 }
221 /*assert(!IS_INF_OR_NAN(f[k]));*/
222 }
223 }
224 break;
225 default:
226 ;
227 }
228 }
229 }
230
231
232 /**
233 * Unmap the buffer object referenced by given array, if mapped.
234 */
235 static void
236 unmap_array_buffer(struct gl_context *ctx, struct gl_client_array *array)
237 {
238 if (array->Enabled &&
239 _mesa_is_bufferobj(array->BufferObj) &&
240 _mesa_bufferobj_mapped(array->BufferObj)) {
241 ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, array->BufferObj);
242 }
243 }
244
245
246 /**
247 * Examine the array's data for NaNs, etc.
248 * For debug purposes; not normally used.
249 */
250 static void
251 check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType,
252 const void *elements, GLint basevertex)
253 {
254 struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
255 const void *elemMap;
256 GLint i, k;
257
258 if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
259 elemMap = ctx->Driver.MapBuffer(ctx,
260 GL_ELEMENT_ARRAY_BUFFER_ARB,
261 GL_READ_ONLY,
262 ctx->Array.ElementArrayBufferObj);
263 elements = ADD_POINTERS(elements, elemMap);
264 }
265
266 for (i = 0; i < count; i++) {
267 GLuint j;
268
269 /* j = element[i] */
270 switch (elemType) {
271 case GL_UNSIGNED_BYTE:
272 j = ((const GLubyte *) elements)[i];
273 break;
274 case GL_UNSIGNED_SHORT:
275 j = ((const GLushort *) elements)[i];
276 break;
277 case GL_UNSIGNED_INT:
278 j = ((const GLuint *) elements)[i];
279 break;
280 default:
281 assert(0);
282 }
283
284 /* check element j of each enabled array */
285 check_array_data(ctx, &arrayObj->Vertex, VERT_ATTRIB_POS, j);
286 check_array_data(ctx, &arrayObj->Normal, VERT_ATTRIB_NORMAL, j);
287 check_array_data(ctx, &arrayObj->Color, VERT_ATTRIB_COLOR0, j);
288 check_array_data(ctx, &arrayObj->SecondaryColor, VERT_ATTRIB_COLOR1, j);
289 for (k = 0; k < Elements(arrayObj->TexCoord); k++) {
290 check_array_data(ctx, &arrayObj->TexCoord[k], VERT_ATTRIB_TEX0 + k, j);
291 }
292 for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) {
293 check_array_data(ctx, &arrayObj->VertexAttrib[k],
294 VERT_ATTRIB_GENERIC0 + k, j);
295 }
296 }
297
298 if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
299 ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB,
300 ctx->Array.ElementArrayBufferObj);
301 }
302
303 unmap_array_buffer(ctx, &arrayObj->Vertex);
304 unmap_array_buffer(ctx, &arrayObj->Normal);
305 unmap_array_buffer(ctx, &arrayObj->Color);
306 for (k = 0; k < Elements(arrayObj->TexCoord); k++) {
307 unmap_array_buffer(ctx, &arrayObj->TexCoord[k]);
308 }
309 for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) {
310 unmap_array_buffer(ctx, &arrayObj->VertexAttrib[k]);
311 }
312 }
313
314
315 /**
316 * Check array data, looking for NaNs, etc.
317 */
318 static void
319 check_draw_arrays_data(struct gl_context *ctx, GLint start, GLsizei count)
320 {
321 /* TO DO */
322 }
323
324
325 /**
326 * Print info/data for glDrawArrays(), for debugging.
327 */
328 static void
329 print_draw_arrays(struct gl_context *ctx,
330 GLenum mode, GLint start, GLsizei count)
331 {
332 struct vbo_context *vbo = vbo_context(ctx);
333 struct vbo_exec_context *exec = &vbo->exec;
334 int i;
335
336 printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n",
337 mode, start, count);
338
339 for (i = 0; i < 32; i++) {
340 GLuint bufName = exec->array.inputs[i]->BufferObj->Name;
341 GLint stride = exec->array.inputs[i]->Stride;
342 printf("attr %2d: size %d stride %d enabled %d "
343 "ptr %p Bufobj %u\n",
344 i,
345 exec->array.inputs[i]->Size,
346 stride,
347 /*exec->array.inputs[i]->Enabled,*/
348 exec->array.legacy_array[i]->Enabled,
349 exec->array.inputs[i]->Ptr,
350 bufName);
351
352 if (bufName) {
353 struct gl_buffer_object *buf = _mesa_lookup_bufferobj(ctx, bufName);
354 GLubyte *p = ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB,
355 GL_READ_ONLY_ARB, buf);
356 int offset = (int) (GLintptr) exec->array.inputs[i]->Ptr;
357 float *f = (float *) (p + offset);
358 int *k = (int *) f;
359 int i;
360 int n = (count * stride) / 4;
361 if (n > 32)
362 n = 32;
363 printf(" Data at offset %d:\n", offset);
364 for (i = 0; i < n; i++) {
365 printf(" float[%d] = 0x%08x %f\n", i, k[i], f[i]);
366 }
367 ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, buf);
368 }
369 }
370 }
371
372
373 /**
374 * Bind the VBO executor to the current vertex array object prior
375 * to drawing.
376 *
377 * Just translate the arrayobj into a sane layout.
378 */
379 static void
380 bind_array_obj(struct gl_context *ctx)
381 {
382 struct vbo_context *vbo = vbo_context(ctx);
383 struct vbo_exec_context *exec = &vbo->exec;
384 struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
385 GLuint i;
386
387 /* TODO: Fix the ArrayObj struct to keep legacy arrays in an array
388 * rather than as individual named arrays. Then this function can
389 * go away.
390 */
391 exec->array.legacy_array[VERT_ATTRIB_POS] = &arrayObj->Vertex;
392 exec->array.legacy_array[VERT_ATTRIB_WEIGHT] = &arrayObj->Weight;
393 exec->array.legacy_array[VERT_ATTRIB_NORMAL] = &arrayObj->Normal;
394 exec->array.legacy_array[VERT_ATTRIB_COLOR0] = &arrayObj->Color;
395 exec->array.legacy_array[VERT_ATTRIB_COLOR1] = &arrayObj->SecondaryColor;
396 exec->array.legacy_array[VERT_ATTRIB_FOG] = &arrayObj->FogCoord;
397 exec->array.legacy_array[VERT_ATTRIB_COLOR_INDEX] = &arrayObj->Index;
398 if (arrayObj->PointSize.Enabled) {
399 /* this aliases COLOR_INDEX */
400 exec->array.legacy_array[VERT_ATTRIB_POINT_SIZE] = &arrayObj->PointSize;
401 }
402 exec->array.legacy_array[VERT_ATTRIB_EDGEFLAG] = &arrayObj->EdgeFlag;
403
404 for (i = 0; i < Elements(arrayObj->TexCoord); i++)
405 exec->array.legacy_array[VERT_ATTRIB_TEX0 + i] = &arrayObj->TexCoord[i];
406
407 for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) {
408 assert(i < Elements(exec->array.generic_array));
409 exec->array.generic_array[i] = &arrayObj->VertexAttrib[i];
410 }
411
412 exec->array.array_obj = arrayObj->Name;
413 }
414
415
416 /**
417 * Set the vbo->exec->inputs[] pointers to point to the enabled
418 * vertex arrays. This depends on the current vertex program/shader
419 * being executed because of whether or not generic vertex arrays
420 * alias the conventional vertex arrays.
421 * For arrays that aren't enabled, we set the input[attrib] pointer
422 * to point at a zero-stride current value "array".
423 */
424 static void
425 recalculate_input_bindings(struct gl_context *ctx)
426 {
427 struct vbo_context *vbo = vbo_context(ctx);
428 struct vbo_exec_context *exec = &vbo->exec;
429 const struct gl_client_array **inputs = &exec->array.inputs[0];
430 GLbitfield const_inputs = 0x0;
431 GLuint i;
432
433 exec->array.program_mode = get_program_mode(ctx);
434 exec->array.enabled_flags = ctx->Array.ArrayObj->_Enabled;
435
436 switch (exec->array.program_mode) {
437 case VP_NONE:
438 /* When no vertex program is active (or the vertex program is generated
439 * from fixed-function state). We put the material values into the
440 * generic slots. This is the only situation where material values
441 * are available as per-vertex attributes.
442 */
443 for (i = 0; i <= VERT_ATTRIB_TEX7; i++) {
444 if (exec->array.legacy_array[i]->Enabled)
445 inputs[i] = exec->array.legacy_array[i];
446 else {
447 inputs[i] = &vbo->legacy_currval[i];
448 const_inputs |= 1 << i;
449 }
450 }
451
452 for (i = 0; i < MAT_ATTRIB_MAX; i++) {
453 inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->mat_currval[i];
454 const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
455 }
456
457 /* Could use just about anything, just to fill in the empty
458 * slots:
459 */
460 for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_MAX - VERT_ATTRIB_GENERIC0; i++) {
461 inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
462 const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
463 }
464 break;
465
466 case VP_NV:
467 /* NV_vertex_program - attribute arrays alias and override
468 * conventional, legacy arrays. No materials, and the generic
469 * slots are vacant.
470 */
471 for (i = 0; i <= VERT_ATTRIB_TEX7; i++) {
472 if (exec->array.generic_array[i]->Enabled)
473 inputs[i] = exec->array.generic_array[i];
474 else if (exec->array.legacy_array[i]->Enabled)
475 inputs[i] = exec->array.legacy_array[i];
476 else {
477 inputs[i] = &vbo->legacy_currval[i];
478 const_inputs |= 1 << i;
479 }
480 }
481
482 /* Could use just about anything, just to fill in the empty
483 * slots:
484 */
485 for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) {
486 inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0];
487 const_inputs |= 1 << i;
488 }
489 break;
490
491 case VP_ARB:
492 /* GL_ARB_vertex_program or GLSL vertex shader - Only the generic[0]
493 * attribute array aliases and overrides the legacy position array.
494 *
495 * Otherwise, legacy attributes available in the legacy slots,
496 * generic attributes in the generic slots and materials are not
497 * available as per-vertex attributes.
498 */
499 if (exec->array.generic_array[0]->Enabled)
500 inputs[0] = exec->array.generic_array[0];
501 else if (exec->array.legacy_array[0]->Enabled)
502 inputs[0] = exec->array.legacy_array[0];
503 else {
504 inputs[0] = &vbo->legacy_currval[0];
505 const_inputs |= 1 << 0;
506 }
507
508 for (i = 1; i <= VERT_ATTRIB_TEX7; i++) {
509 if (exec->array.legacy_array[i]->Enabled)
510 inputs[i] = exec->array.legacy_array[i];
511 else {
512 inputs[i] = &vbo->legacy_currval[i];
513 const_inputs |= 1 << i;
514 }
515 }
516
517 for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) {
518 if (exec->array.generic_array[i]->Enabled)
519 inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i];
520 else {
521 inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
522 const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
523 }
524
525 }
526 break;
527 }
528
529 _mesa_set_varying_vp_inputs( ctx, ~const_inputs );
530 }
531
532
533 /**
534 * Examine the enabled vertex arrays to set the exec->array.inputs[] values.
535 * These will point to the arrays to actually use for drawing. Some will
536 * be user-provided arrays, other will be zero-stride const-valued arrays.
537 * Note that this might set the _NEW_ARRAY dirty flag so state validation
538 * must be done after this call.
539 */
540 static void
541 bind_arrays(struct gl_context *ctx)
542 {
543 if (!ctx->Array.RebindArrays) {
544 return;
545 }
546
547 bind_array_obj(ctx);
548 recalculate_input_bindings(ctx);
549 ctx->Array.RebindArrays = GL_FALSE;
550 }
551
552
553 /**
554 * Helper function called by the other DrawArrays() functions below.
555 * This is where we handle primitive restart for drawing non-indexed
556 * arrays. If primitive restart is enabled, it typically means
557 * splitting one DrawArrays() into two.
558 */
559 static void
560 vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
561 GLsizei count, GLuint numInstances)
562 {
563 struct vbo_context *vbo = vbo_context(ctx);
564 struct vbo_exec_context *exec = &vbo->exec;
565 struct _mesa_prim prim[2];
566
567 bind_arrays(ctx);
568
569 /* Again... because we may have changed the bitmask of per-vertex varying
570 * attributes. If we regenerate the fixed-function vertex program now
571 * we may be able to prune down the number of vertex attributes which we
572 * need in the shader.
573 */
574 if (ctx->NewState)
575 _mesa_update_state(ctx);
576
577 prim[0].begin = 1;
578 prim[0].end = 1;
579 prim[0].weak = 0;
580 prim[0].pad = 0;
581 prim[0].mode = mode;
582 prim[0].start = 0; /* filled in below */
583 prim[0].count = 0; /* filled in below */
584 prim[0].indexed = 0;
585 prim[0].basevertex = 0;
586 prim[0].num_instances = numInstances;
587
588 /* Implement the primitive restart index */
589 if (ctx->Array.PrimitiveRestart && ctx->Array.RestartIndex < count) {
590 GLuint primCount = 0;
591
592 if (ctx->Array.RestartIndex == start) {
593 /* special case: RestartIndex at beginning */
594 if (count > 1) {
595 prim[0].start = start + 1;
596 prim[0].count = count - 1;
597 primCount = 1;
598 }
599 }
600 else if (ctx->Array.RestartIndex == start + count - 1) {
601 /* special case: RestartIndex at end */
602 if (count > 1) {
603 prim[0].start = start;
604 prim[0].count = count - 1;
605 primCount = 1;
606 }
607 }
608 else {
609 /* general case: RestartIndex in middle, split into two prims */
610 prim[0].start = start;
611 prim[0].count = ctx->Array.RestartIndex - start;
612
613 prim[1] = prim[0];
614 prim[1].start = ctx->Array.RestartIndex + 1;
615 prim[1].count = count - prim[1].start;
616
617 primCount = 2;
618 }
619
620 if (primCount > 0) {
621 /* draw one or two prims */
622 check_buffers_are_unmapped(exec->array.inputs);
623 vbo->draw_prims(ctx, exec->array.inputs, prim, primCount, NULL,
624 GL_TRUE, start, start + count - 1);
625 }
626 }
627 else {
628 /* no prim restart */
629 prim[0].start = start;
630 prim[0].count = count;
631
632 check_buffers_are_unmapped(exec->array.inputs);
633 vbo->draw_prims(ctx, exec->array.inputs, prim, 1, NULL,
634 GL_TRUE, start, start + count - 1);
635 }
636 }
637
638
639
640 /**
641 * Called from glDrawArrays when in immediate mode (not display list mode).
642 */
643 static void GLAPIENTRY
644 vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count)
645 {
646 GET_CURRENT_CONTEXT(ctx);
647
648 if (MESA_VERBOSE & VERBOSE_DRAW)
649 _mesa_debug(ctx, "glDrawArrays(%s, %d, %d)\n",
650 _mesa_lookup_enum_by_nr(mode), start, count);
651
652 if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
653 return;
654
655 FLUSH_CURRENT( ctx, 0 );
656
657 if (!_mesa_valid_to_render(ctx, "glDrawArrays")) {
658 return;
659 }
660
661 if (0)
662 check_draw_arrays_data(ctx, start, count);
663
664 vbo_draw_arrays(ctx, mode, start, count, 1);
665
666 if (0)
667 print_draw_arrays(ctx, mode, start, count);
668 }
669
670
671 /**
672 * Called from glDrawArraysInstanced when in immediate mode (not
673 * display list mode).
674 */
675 static void GLAPIENTRY
676 vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count,
677 GLsizei numInstances)
678 {
679 GET_CURRENT_CONTEXT(ctx);
680
681 if (MESA_VERBOSE & VERBOSE_DRAW)
682 _mesa_debug(ctx, "glDrawArraysInstanced(%s, %d, %d, %d)\n",
683 _mesa_lookup_enum_by_nr(mode), start, count, numInstances);
684
685 if (!_mesa_validate_DrawArraysInstanced(ctx, mode, start, count, numInstances))
686 return;
687
688 FLUSH_CURRENT( ctx, 0 );
689
690 if (!_mesa_valid_to_render(ctx, "glDrawArraysInstanced")) {
691 return;
692 }
693
694 if (0)
695 check_draw_arrays_data(ctx, start, count);
696
697 vbo_draw_arrays(ctx, mode, start, count, numInstances);
698
699 if (0)
700 print_draw_arrays(ctx, mode, start, count);
701 }
702
703
704 /**
705 * Map GL_ELEMENT_ARRAY_BUFFER and print contents.
706 * For debugging.
707 */
708 static void
709 dump_element_buffer(struct gl_context *ctx, GLenum type)
710 {
711 const GLvoid *map = ctx->Driver.MapBuffer(ctx,
712 GL_ELEMENT_ARRAY_BUFFER_ARB,
713 GL_READ_ONLY,
714 ctx->Array.ElementArrayBufferObj);
715 switch (type) {
716 case GL_UNSIGNED_BYTE:
717 {
718 const GLubyte *us = (const GLubyte *) map;
719 GLint i;
720 for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size; i++) {
721 printf("%02x ", us[i]);
722 if (i % 32 == 31)
723 printf("\n");
724 }
725 printf("\n");
726 }
727 break;
728 case GL_UNSIGNED_SHORT:
729 {
730 const GLushort *us = (const GLushort *) map;
731 GLint i;
732 for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 2; i++) {
733 printf("%04x ", us[i]);
734 if (i % 16 == 15)
735 printf("\n");
736 }
737 printf("\n");
738 }
739 break;
740 case GL_UNSIGNED_INT:
741 {
742 const GLuint *us = (const GLuint *) map;
743 GLint i;
744 for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 4; i++) {
745 printf("%08x ", us[i]);
746 if (i % 8 == 7)
747 printf("\n");
748 }
749 printf("\n");
750 }
751 break;
752 default:
753 ;
754 }
755
756 ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB,
757 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 #ifdef DEBUG
906 /* 'end' was out of bounds, but now let's check the actual array
907 * indexes to see if any of them are out of bounds.
908 */
909 {
910 GLuint max = _mesa_max_buffer_index(ctx, count, type, indices,
911 ctx->Array.ElementArrayBufferObj);
912 if (max >= ctx->Array.ArrayObj->_MaxElement) {
913 if (warnCount < 10) {
914 _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, "
915 "count %d, type 0x%x, indices=%p)\n"
916 "\tindex=%u is out of bounds (max=%u) "
917 "Element Buffer %u (size %d)\n"
918 "\tSkipping the glDrawRangeElements() call",
919 start, end, count, type, indices, max,
920 ctx->Array.ArrayObj->_MaxElement - 1,
921 ctx->Array.ElementArrayBufferObj->Name,
922 (int) ctx->Array.ElementArrayBufferObj->Size);
923 }
924 }
925 /* XXX we could also find the min index and compare to 'start'
926 * to see if start is correct. But it's more likely to get the
927 * upper bound wrong.
928 */
929 }
930 #endif
931
932 /* Set 'end' to the max possible legal value */
933 assert(ctx->Array.ArrayObj->_MaxElement >= 1);
934 end = ctx->Array.ArrayObj->_MaxElement - 1;
935 }
936 else if (0) {
937 printf("glDraw[Range]Elements{,BaseVertex}"
938 "(start %u, end %u, type 0x%x, count %d) ElemBuf %u, "
939 "base %d\n",
940 start, end, type, count,
941 ctx->Array.ElementArrayBufferObj->Name,
942 basevertex);
943 }
944
945 #if 0
946 check_draw_elements_data(ctx, count, type, indices);
947 #else
948 (void) check_draw_elements_data;
949 #endif
950
951 vbo_validated_drawrangeelements(ctx, mode, GL_TRUE, start, end,
952 count, type, indices, basevertex, 1);
953 }
954
955
956 /**
957 * Called by glDrawRangeElements() in immediate mode.
958 */
959 static void GLAPIENTRY
960 vbo_exec_DrawRangeElements(GLenum mode, GLuint start, GLuint end,
961 GLsizei count, GLenum type, const GLvoid *indices)
962 {
963 GET_CURRENT_CONTEXT(ctx);
964
965 if (MESA_VERBOSE & VERBOSE_DRAW)
966 _mesa_debug(ctx,
967 "glDrawRangeElements(%s, %u, %u, %d, %s, %p)\n",
968 _mesa_lookup_enum_by_nr(mode), start, end, count,
969 _mesa_lookup_enum_by_nr(type), indices);
970
971 vbo_exec_DrawRangeElementsBaseVertex(mode, start, end, count, type,
972 indices, 0);
973 }
974
975
976 /**
977 * Called by glDrawElements() in immediate mode.
978 */
979 static void GLAPIENTRY
980 vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type,
981 const GLvoid *indices)
982 {
983 GET_CURRENT_CONTEXT(ctx);
984
985 if (MESA_VERBOSE & VERBOSE_DRAW)
986 _mesa_debug(ctx, "glDrawElements(%s, %u, %s, %p)\n",
987 _mesa_lookup_enum_by_nr(mode), count,
988 _mesa_lookup_enum_by_nr(type), indices);
989
990 if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 ))
991 return;
992
993 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
994 count, type, indices, 0, 1);
995 }
996
997
998 /**
999 * Called by glDrawElementsBaseVertex() in immediate mode.
1000 */
1001 static void GLAPIENTRY
1002 vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
1003 const GLvoid *indices, GLint basevertex)
1004 {
1005 GET_CURRENT_CONTEXT(ctx);
1006
1007 if (MESA_VERBOSE & VERBOSE_DRAW)
1008 _mesa_debug(ctx, "glDrawElementsBaseVertex(%s, %d, %s, %p, %d)\n",
1009 _mesa_lookup_enum_by_nr(mode), count,
1010 _mesa_lookup_enum_by_nr(type), indices, basevertex);
1011
1012 if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices,
1013 basevertex ))
1014 return;
1015
1016 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
1017 count, type, indices, basevertex, 1);
1018 }
1019
1020
1021 /**
1022 * Called by glDrawElementsInstanced() in immediate mode.
1023 */
1024 static void GLAPIENTRY
1025 vbo_exec_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
1026 const GLvoid *indices, GLsizei numInstances)
1027 {
1028 GET_CURRENT_CONTEXT(ctx);
1029
1030 if (MESA_VERBOSE & VERBOSE_DRAW)
1031 _mesa_debug(ctx, "glDrawElementsInstanced(%s, %d, %s, %p, %d)\n",
1032 _mesa_lookup_enum_by_nr(mode), count,
1033 _mesa_lookup_enum_by_nr(type), indices, numInstances);
1034
1035 if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
1036 numInstances))
1037 return;
1038
1039 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
1040 count, type, indices, 0, numInstances);
1041 }
1042
1043
1044 /**
1045 * Inner support for both _mesa_MultiDrawElements() and
1046 * _mesa_MultiDrawRangeElements().
1047 * This does the actual rendering after we've checked array indexes, etc.
1048 */
1049 static void
1050 vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
1051 const GLsizei *count, GLenum type,
1052 const GLvoid **indices, GLsizei primcount,
1053 const GLint *basevertex)
1054 {
1055 struct vbo_context *vbo = vbo_context(ctx);
1056 struct vbo_exec_context *exec = &vbo->exec;
1057 struct _mesa_index_buffer ib;
1058 struct _mesa_prim *prim;
1059 unsigned int index_type_size = 0;
1060 uintptr_t min_index_ptr, max_index_ptr;
1061 GLboolean fallback = GL_FALSE;
1062 int i;
1063
1064 if (primcount == 0)
1065 return;
1066
1067 FLUSH_CURRENT( ctx, 0 );
1068
1069 if (!_mesa_valid_to_render(ctx, "glMultiDrawElements")) {
1070 return;
1071 }
1072
1073 prim = calloc(1, primcount * sizeof(*prim));
1074 if (prim == NULL) {
1075 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElements");
1076 return;
1077 }
1078
1079 /* Decide if we can do this all as one set of primitives sharing the
1080 * same index buffer, or if we have to reset the index pointer per
1081 * primitive.
1082 */
1083 bind_arrays( ctx );
1084
1085 /* check for dirty state again */
1086 if (ctx->NewState)
1087 _mesa_update_state( ctx );
1088
1089 switch (type) {
1090 case GL_UNSIGNED_INT:
1091 index_type_size = 4;
1092 break;
1093 case GL_UNSIGNED_SHORT:
1094 index_type_size = 2;
1095 break;
1096 case GL_UNSIGNED_BYTE:
1097 index_type_size = 1;
1098 break;
1099 default:
1100 assert(0);
1101 }
1102
1103 min_index_ptr = (uintptr_t)indices[0];
1104 max_index_ptr = 0;
1105 for (i = 0; i < primcount; i++) {
1106 min_index_ptr = MIN2(min_index_ptr, (uintptr_t)indices[i]);
1107 max_index_ptr = MAX2(max_index_ptr, (uintptr_t)indices[i] +
1108 index_type_size * count[i]);
1109 }
1110
1111 /* Check if we can handle this thing as a bunch of index offsets from the
1112 * same index pointer. If we can't, then we have to fall back to doing
1113 * a draw_prims per primitive.
1114 * Check that the difference between each prim's indexes is a multiple of
1115 * the index/element size.
1116 */
1117 if (index_type_size != 1) {
1118 for (i = 0; i < primcount; i++) {
1119 if ((((uintptr_t)indices[i] - min_index_ptr) % index_type_size) != 0) {
1120 fallback = GL_TRUE;
1121 break;
1122 }
1123 }
1124 }
1125
1126 /* If the index buffer isn't in a VBO, then treating the application's
1127 * subranges of the index buffer as one large index buffer may lead to
1128 * us reading unmapped memory.
1129 */
1130 if (!_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj))
1131 fallback = GL_TRUE;
1132
1133 if (!fallback) {
1134 ib.count = (max_index_ptr - min_index_ptr) / index_type_size;
1135 ib.type = type;
1136 ib.obj = ctx->Array.ElementArrayBufferObj;
1137 ib.ptr = (void *)min_index_ptr;
1138
1139 for (i = 0; i < primcount; i++) {
1140 prim[i].begin = (i == 0);
1141 prim[i].end = (i == primcount - 1);
1142 prim[i].weak = 0;
1143 prim[i].pad = 0;
1144 prim[i].mode = mode;
1145 prim[i].start = ((uintptr_t)indices[i] - min_index_ptr) / index_type_size;
1146 prim[i].count = count[i];
1147 prim[i].indexed = 1;
1148 prim[i].num_instances = 1;
1149 if (basevertex != NULL)
1150 prim[i].basevertex = basevertex[i];
1151 else
1152 prim[i].basevertex = 0;
1153 }
1154
1155 check_buffers_are_unmapped(exec->array.inputs);
1156 vbo->draw_prims(ctx, exec->array.inputs, prim, primcount, &ib,
1157 GL_FALSE, ~0, ~0);
1158 } else {
1159 /* render one prim at a time */
1160 for (i = 0; i < primcount; i++) {
1161 ib.count = count[i];
1162 ib.type = type;
1163 ib.obj = ctx->Array.ElementArrayBufferObj;
1164 ib.ptr = indices[i];
1165
1166 prim[0].begin = 1;
1167 prim[0].end = 1;
1168 prim[0].weak = 0;
1169 prim[0].pad = 0;
1170 prim[0].mode = mode;
1171 prim[0].start = 0;
1172 prim[0].count = count[i];
1173 prim[0].indexed = 1;
1174 prim[0].num_instances = 1;
1175 if (basevertex != NULL)
1176 prim[0].basevertex = basevertex[i];
1177 else
1178 prim[0].basevertex = 0;
1179
1180 check_buffers_are_unmapped(exec->array.inputs);
1181 vbo->draw_prims(ctx, exec->array.inputs, prim, 1, &ib,
1182 GL_FALSE, ~0, ~0);
1183 }
1184 }
1185
1186 free(prim);
1187 }
1188
1189
1190 static void GLAPIENTRY
1191 vbo_exec_MultiDrawElements(GLenum mode,
1192 const GLsizei *count, GLenum type,
1193 const GLvoid **indices,
1194 GLsizei primcount)
1195 {
1196 GET_CURRENT_CONTEXT(ctx);
1197 GLint i;
1198
1199 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
1200
1201 for (i = 0; i < primcount; i++) {
1202 if (!_mesa_validate_DrawElements(ctx, mode, count[i], type, indices[i],
1203 0))
1204 return;
1205 }
1206
1207 vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount,
1208 NULL);
1209 }
1210
1211
1212 static void GLAPIENTRY
1213 vbo_exec_MultiDrawElementsBaseVertex(GLenum mode,
1214 const GLsizei *count, GLenum type,
1215 const GLvoid **indices,
1216 GLsizei primcount,
1217 const GLsizei *basevertex)
1218 {
1219 GET_CURRENT_CONTEXT(ctx);
1220 GLint i;
1221
1222 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
1223
1224 for (i = 0; i < primcount; i++) {
1225 if (!_mesa_validate_DrawElements(ctx, mode, count[i], type, indices[i],
1226 basevertex[i]))
1227 return;
1228 }
1229
1230 vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount,
1231 basevertex);
1232 }
1233
1234
1235 /**
1236 * Plug in the immediate-mode vertex array drawing commands into the
1237 * givven vbo_exec_context object.
1238 */
1239 void
1240 vbo_exec_array_init( struct vbo_exec_context *exec )
1241 {
1242 exec->vtxfmt.DrawArrays = vbo_exec_DrawArrays;
1243 exec->vtxfmt.DrawElements = vbo_exec_DrawElements;
1244 exec->vtxfmt.DrawRangeElements = vbo_exec_DrawRangeElements;
1245 exec->vtxfmt.MultiDrawElementsEXT = vbo_exec_MultiDrawElements;
1246 exec->vtxfmt.DrawElementsBaseVertex = vbo_exec_DrawElementsBaseVertex;
1247 exec->vtxfmt.DrawRangeElementsBaseVertex = vbo_exec_DrawRangeElementsBaseVertex;
1248 exec->vtxfmt.MultiDrawElementsBaseVertex = vbo_exec_MultiDrawElementsBaseVertex;
1249 exec->vtxfmt.DrawArraysInstanced = vbo_exec_DrawArraysInstanced;
1250 exec->vtxfmt.DrawElementsInstanced = vbo_exec_DrawElementsInstanced;
1251 }
1252
1253
1254 void
1255 vbo_exec_array_destroy( struct vbo_exec_context *exec )
1256 {
1257 /* nothing to do */
1258 }
1259
1260
1261
1262 /**
1263 * The following functions are only used for OpenGL ES 1/2 support.
1264 * And some aren't even supported (yet) in ES 1/2.
1265 */
1266
1267
1268 void GLAPIENTRY
1269 _mesa_DrawArrays(GLenum mode, GLint first, GLsizei count)
1270 {
1271 vbo_exec_DrawArrays(mode, first, count);
1272 }
1273
1274
1275 void GLAPIENTRY
1276 _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type,
1277 const GLvoid *indices)
1278 {
1279 vbo_exec_DrawElements(mode, count, type, indices);
1280 }
1281
1282
1283 void GLAPIENTRY
1284 _mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
1285 const GLvoid *indices, GLint basevertex)
1286 {
1287 vbo_exec_DrawElementsBaseVertex(mode, count, type, indices, basevertex);
1288 }
1289
1290
1291 void GLAPIENTRY
1292 _mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
1293 GLenum type, const GLvoid *indices)
1294 {
1295 vbo_exec_DrawRangeElements(mode, start, end, count, type, indices);
1296 }
1297
1298
1299 void GLAPIENTRY
1300 _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
1301 GLsizei count, GLenum type,
1302 const GLvoid *indices, GLint basevertex)
1303 {
1304 vbo_exec_DrawRangeElementsBaseVertex(mode, start, end, count, type,
1305 indices, basevertex);
1306 }
1307
1308
1309 void GLAPIENTRY
1310 _mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type,
1311 const GLvoid **indices, GLsizei primcount)
1312 {
1313 vbo_exec_MultiDrawElements(mode, count, type, indices, primcount);
1314 }
1315
1316
1317 void GLAPIENTRY
1318 _mesa_MultiDrawElementsBaseVertex(GLenum mode,
1319 const GLsizei *count, GLenum type,
1320 const GLvoid **indices, GLsizei primcount,
1321 const GLint *basevertex)
1322 {
1323 vbo_exec_MultiDrawElementsBaseVertex(mode, count, type, indices,
1324 primcount, basevertex);
1325 }