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