mesa: Drop the always-software-primitive-restart paths.
[mesa.git] / src / mesa / vbo / vbo_exec_array.c
1 /**************************************************************************
2 *
3 * Copyright 2003 VMware, Inc.
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 VMWARE 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/dispatch.h"
34 #include "main/varray.h"
35 #include "main/bufferobj.h"
36 #include "main/enums.h"
37 #include "main/macros.h"
38 #include "main/transformfeedback.h"
39
40 #include "vbo_context.h"
41
42
43 /**
44 * All vertex buffers should be in an unmapped state when we're about
45 * to draw. This debug function checks that.
46 */
47 static void
48 check_buffers_are_unmapped(const struct gl_client_array **inputs)
49 {
50 #ifdef DEBUG
51 GLuint i;
52
53 for (i = 0; i < VERT_ATTRIB_MAX; i++) {
54 if (inputs[i]) {
55 struct gl_buffer_object *obj = inputs[i]->BufferObj;
56 assert(!_mesa_check_disallowed_mapping(obj));
57 (void) obj;
58 }
59 }
60 #endif
61 }
62
63
64 /**
65 * A debug function that may be called from other parts of Mesa as
66 * needed during debugging.
67 */
68 void
69 vbo_check_buffers_are_unmapped(struct gl_context *ctx)
70 {
71 struct vbo_context *vbo = vbo_context(ctx);
72 struct vbo_exec_context *exec = &vbo->exec;
73 /* check the current vertex arrays */
74 check_buffers_are_unmapped(exec->array.inputs);
75 /* check the current glBegin/glVertex/glEnd-style VBO */
76 assert(!_mesa_check_disallowed_mapping(exec->vtx.bufferobj));
77 }
78
79
80
81 /**
82 * Compute min and max elements by scanning the index buffer for
83 * glDraw[Range]Elements() calls.
84 * If primitive restart is enabled, we need to ignore restart
85 * indexes when computing min/max.
86 */
87 static void
88 vbo_get_minmax_index(struct gl_context *ctx,
89 const struct _mesa_prim *prim,
90 const struct _mesa_index_buffer *ib,
91 GLuint *min_index, GLuint *max_index,
92 const GLuint count)
93 {
94 const GLboolean restart = ctx->Array._PrimitiveRestart;
95 const GLuint restartIndex = _mesa_primitive_restart_index(ctx, ib->type);
96 const int index_size = vbo_sizeof_ib_type(ib->type);
97 const char *indices;
98 GLuint i;
99
100 indices = (char *) ib->ptr + prim->start * index_size;
101 if (_mesa_is_bufferobj(ib->obj)) {
102 GLsizeiptr size = MIN2(count * index_size, ib->obj->Size);
103 indices = ctx->Driver.MapBufferRange(ctx, (GLintptr) indices, size,
104 GL_MAP_READ_BIT, ib->obj,
105 MAP_INTERNAL);
106 }
107
108 switch (ib->type) {
109 case GL_UNSIGNED_INT: {
110 const GLuint *ui_indices = (const GLuint *)indices;
111 GLuint max_ui = 0;
112 GLuint min_ui = ~0U;
113 if (restart) {
114 for (i = 0; i < count; i++) {
115 if (ui_indices[i] != restartIndex) {
116 if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
117 if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
118 }
119 }
120 }
121 else {
122 for (i = 0; i < count; i++) {
123 if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
124 if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
125 }
126 }
127 *min_index = min_ui;
128 *max_index = max_ui;
129 break;
130 }
131 case GL_UNSIGNED_SHORT: {
132 const GLushort *us_indices = (const GLushort *)indices;
133 GLuint max_us = 0;
134 GLuint min_us = ~0U;
135 if (restart) {
136 for (i = 0; i < count; i++) {
137 if (us_indices[i] != restartIndex) {
138 if (us_indices[i] > max_us) max_us = us_indices[i];
139 if (us_indices[i] < min_us) min_us = us_indices[i];
140 }
141 }
142 }
143 else {
144 for (i = 0; i < count; i++) {
145 if (us_indices[i] > max_us) max_us = us_indices[i];
146 if (us_indices[i] < min_us) min_us = us_indices[i];
147 }
148 }
149 *min_index = min_us;
150 *max_index = max_us;
151 break;
152 }
153 case GL_UNSIGNED_BYTE: {
154 const GLubyte *ub_indices = (const GLubyte *)indices;
155 GLuint max_ub = 0;
156 GLuint min_ub = ~0U;
157 if (restart) {
158 for (i = 0; i < count; i++) {
159 if (ub_indices[i] != restartIndex) {
160 if (ub_indices[i] > max_ub) max_ub = ub_indices[i];
161 if (ub_indices[i] < min_ub) min_ub = ub_indices[i];
162 }
163 }
164 }
165 else {
166 for (i = 0; i < count; i++) {
167 if (ub_indices[i] > max_ub) max_ub = ub_indices[i];
168 if (ub_indices[i] < min_ub) min_ub = ub_indices[i];
169 }
170 }
171 *min_index = min_ub;
172 *max_index = max_ub;
173 break;
174 }
175 default:
176 assert(0);
177 break;
178 }
179
180 if (_mesa_is_bufferobj(ib->obj)) {
181 ctx->Driver.UnmapBuffer(ctx, ib->obj, MAP_INTERNAL);
182 }
183 }
184
185 /**
186 * Compute min and max elements for nr_prims
187 */
188 void
189 vbo_get_minmax_indices(struct gl_context *ctx,
190 const struct _mesa_prim *prims,
191 const struct _mesa_index_buffer *ib,
192 GLuint *min_index,
193 GLuint *max_index,
194 GLuint nr_prims)
195 {
196 GLuint tmp_min, tmp_max;
197 GLuint i;
198 GLuint count;
199
200 *min_index = ~0;
201 *max_index = 0;
202
203 for (i = 0; i < nr_prims; i++) {
204 const struct _mesa_prim *start_prim;
205
206 start_prim = &prims[i];
207 count = start_prim->count;
208 /* Do combination if possible to reduce map/unmap count */
209 while ((i + 1 < nr_prims) &&
210 (prims[i].start + prims[i].count == prims[i+1].start)) {
211 count += prims[i+1].count;
212 i++;
213 }
214 vbo_get_minmax_index(ctx, start_prim, ib, &tmp_min, &tmp_max, count);
215 *min_index = MIN2(*min_index, tmp_min);
216 *max_index = MAX2(*max_index, tmp_max);
217 }
218 }
219
220
221 /**
222 * Check that element 'j' of the array has reasonable data.
223 * Map VBO if needed.
224 * For debugging purposes; not normally used.
225 */
226 static void
227 check_array_data(struct gl_context *ctx, struct gl_client_array *array,
228 GLuint attrib, GLuint j)
229 {
230 if (array->Enabled) {
231 const void *data = array->Ptr;
232 if (_mesa_is_bufferobj(array->BufferObj)) {
233 if (!array->BufferObj->Mappings[MAP_INTERNAL].Pointer) {
234 /* need to map now */
235 array->BufferObj->Mappings[MAP_INTERNAL].Pointer =
236 ctx->Driver.MapBufferRange(ctx, 0, array->BufferObj->Size,
237 GL_MAP_READ_BIT, array->BufferObj,
238 MAP_INTERNAL);
239 }
240 data = ADD_POINTERS(data,
241 array->BufferObj->Mappings[MAP_INTERNAL].Pointer);
242 }
243 switch (array->Type) {
244 case GL_FLOAT:
245 {
246 GLfloat *f = (GLfloat *) ((GLubyte *) data + array->StrideB * j);
247 GLint k;
248 for (k = 0; k < array->Size; k++) {
249 if (IS_INF_OR_NAN(f[k]) ||
250 f[k] >= 1.0e20 || f[k] <= -1.0e10) {
251 printf("Bad array data:\n");
252 printf(" Element[%u].%u = %f\n", j, k, f[k]);
253 printf(" Array %u at %p\n", attrib, (void* ) array);
254 printf(" Type 0x%x, Size %d, Stride %d\n",
255 array->Type, array->Size, array->Stride);
256 printf(" Address/offset %p in Buffer Object %u\n",
257 array->Ptr, array->BufferObj->Name);
258 f[k] = 1.0; /* XXX replace the bad value! */
259 }
260 /*assert(!IS_INF_OR_NAN(f[k]));*/
261 }
262 }
263 break;
264 default:
265 ;
266 }
267 }
268 }
269
270
271 /**
272 * Unmap the buffer object referenced by given array, if mapped.
273 */
274 static void
275 unmap_array_buffer(struct gl_context *ctx, struct gl_client_array *array)
276 {
277 if (array->Enabled &&
278 _mesa_is_bufferobj(array->BufferObj) &&
279 _mesa_bufferobj_mapped(array->BufferObj, MAP_INTERNAL)) {
280 ctx->Driver.UnmapBuffer(ctx, array->BufferObj, MAP_INTERNAL);
281 }
282 }
283
284
285 /**
286 * Examine the array's data for NaNs, etc.
287 * For debug purposes; not normally used.
288 */
289 static void
290 check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType,
291 const void *elements, GLint basevertex)
292 {
293 struct gl_vertex_array_object *vao = ctx->Array.VAO;
294 const void *elemMap;
295 GLint i, k;
296
297 if (_mesa_is_bufferobj(ctx->Array.VAO->IndexBufferObj)) {
298 elemMap = ctx->Driver.MapBufferRange(ctx, 0,
299 ctx->Array.VAO->IndexBufferObj->Size,
300 GL_MAP_READ_BIT,
301 ctx->Array.VAO->IndexBufferObj,
302 MAP_INTERNAL);
303 elements = ADD_POINTERS(elements, elemMap);
304 }
305
306 for (i = 0; i < count; i++) {
307 GLuint j;
308
309 /* j = element[i] */
310 switch (elemType) {
311 case GL_UNSIGNED_BYTE:
312 j = ((const GLubyte *) elements)[i];
313 break;
314 case GL_UNSIGNED_SHORT:
315 j = ((const GLushort *) elements)[i];
316 break;
317 case GL_UNSIGNED_INT:
318 j = ((const GLuint *) elements)[i];
319 break;
320 default:
321 assert(0);
322 }
323
324 /* check element j of each enabled array */
325 for (k = 0; k < Elements(vao->_VertexAttrib); k++) {
326 check_array_data(ctx, &vao->_VertexAttrib[k], k, j);
327 }
328 }
329
330 if (_mesa_is_bufferobj(vao->IndexBufferObj)) {
331 ctx->Driver.UnmapBuffer(ctx, ctx->Array.VAO->IndexBufferObj,
332 MAP_INTERNAL);
333 }
334
335 for (k = 0; k < Elements(vao->_VertexAttrib); k++) {
336 unmap_array_buffer(ctx, &vao->_VertexAttrib[k]);
337 }
338 }
339
340
341 /**
342 * Check array data, looking for NaNs, etc.
343 */
344 static void
345 check_draw_arrays_data(struct gl_context *ctx, GLint start, GLsizei count)
346 {
347 /* TO DO */
348 }
349
350
351 /**
352 * Print info/data for glDrawArrays(), for debugging.
353 */
354 static void
355 print_draw_arrays(struct gl_context *ctx,
356 GLenum mode, GLint start, GLsizei count)
357 {
358 struct vbo_context *vbo = vbo_context(ctx);
359 struct vbo_exec_context *exec = &vbo->exec;
360 struct gl_vertex_array_object *vao = ctx->Array.VAO;
361 int i;
362
363 printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n",
364 mode, start, count);
365
366 for (i = 0; i < 32; i++) {
367 struct gl_buffer_object *bufObj = exec->array.inputs[i]->BufferObj;
368 GLuint bufName = bufObj->Name;
369 GLint stride = exec->array.inputs[i]->Stride;
370 printf("attr %2d: size %d stride %d enabled %d "
371 "ptr %p Bufobj %u\n",
372 i,
373 exec->array.inputs[i]->Size,
374 stride,
375 /*exec->array.inputs[i]->Enabled,*/
376 vao->_VertexAttrib[VERT_ATTRIB_FF(i)].Enabled,
377 exec->array.inputs[i]->Ptr,
378 bufName);
379
380 if (bufName) {
381 GLubyte *p = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size,
382 GL_MAP_READ_BIT, bufObj,
383 MAP_INTERNAL);
384 int offset = (int) (GLintptr) exec->array.inputs[i]->Ptr;
385 float *f = (float *) (p + offset);
386 int *k = (int *) f;
387 int i;
388 int n = (count * stride) / 4;
389 if (n > 32)
390 n = 32;
391 printf(" Data at offset %d:\n", offset);
392 for (i = 0; i < n; i++) {
393 printf(" float[%d] = 0x%08x %f\n", i, k[i], f[i]);
394 }
395 ctx->Driver.UnmapBuffer(ctx, bufObj, MAP_INTERNAL);
396 }
397 }
398 }
399
400
401 /**
402 * Set the vbo->exec->inputs[] pointers to point to the enabled
403 * vertex arrays. This depends on the current vertex program/shader
404 * being executed because of whether or not generic vertex arrays
405 * alias the conventional vertex arrays.
406 * For arrays that aren't enabled, we set the input[attrib] pointer
407 * to point at a zero-stride current value "array".
408 */
409 static void
410 recalculate_input_bindings(struct gl_context *ctx)
411 {
412 struct vbo_context *vbo = vbo_context(ctx);
413 struct vbo_exec_context *exec = &vbo->exec;
414 struct gl_client_array *vertexAttrib = ctx->Array.VAO->_VertexAttrib;
415 const struct gl_client_array **inputs = &exec->array.inputs[0];
416 GLbitfield64 const_inputs = 0x0;
417 GLuint i;
418
419 switch (get_program_mode(ctx)) {
420 case VP_NONE:
421 /* When no vertex program is active (or the vertex program is generated
422 * from fixed-function state). We put the material values into the
423 * generic slots. This is the only situation where material values
424 * are available as per-vertex attributes.
425 */
426 for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
427 if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled)
428 inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)];
429 else {
430 inputs[i] = &vbo->currval[VBO_ATTRIB_POS+i];
431 const_inputs |= VERT_BIT(i);
432 }
433 }
434
435 for (i = 0; i < MAT_ATTRIB_MAX; i++) {
436 inputs[VERT_ATTRIB_GENERIC(i)] =
437 &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+i];
438 const_inputs |= VERT_BIT_GENERIC(i);
439 }
440
441 /* Could use just about anything, just to fill in the empty
442 * slots:
443 */
444 for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_GENERIC_MAX; i++) {
445 inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->currval[VBO_ATTRIB_GENERIC0+i];
446 const_inputs |= VERT_BIT_GENERIC(i);
447 }
448 break;
449
450 case VP_ARB:
451 /* There are no shaders in OpenGL ES 1.x, so this code path should be
452 * impossible to reach. The meta code is careful to not use shaders in
453 * ES1.
454 */
455 assert(ctx->API != API_OPENGLES);
456
457 /* In the compatibility profile of desktop OpenGL, the generic[0]
458 * attribute array aliases and overrides the legacy position array.
459 * Otherwise, legacy attributes available in the legacy slots,
460 * generic attributes in the generic slots and materials are not
461 * available as per-vertex attributes.
462 *
463 * In all other APIs, only the generic attributes exist, and none of the
464 * slots are considered "magic."
465 */
466 if (ctx->API == API_OPENGL_COMPAT) {
467 if (vertexAttrib[VERT_ATTRIB_GENERIC0].Enabled)
468 inputs[0] = &vertexAttrib[VERT_ATTRIB_GENERIC0];
469 else if (vertexAttrib[VERT_ATTRIB_POS].Enabled)
470 inputs[0] = &vertexAttrib[VERT_ATTRIB_POS];
471 else {
472 inputs[0] = &vbo->currval[VBO_ATTRIB_POS];
473 const_inputs |= VERT_BIT_POS;
474 }
475
476 for (i = 1; i < VERT_ATTRIB_FF_MAX; i++) {
477 if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled)
478 inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)];
479 else {
480 inputs[i] = &vbo->currval[VBO_ATTRIB_POS+i];
481 const_inputs |= VERT_BIT_FF(i);
482 }
483 }
484
485 for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) {
486 if (vertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
487 inputs[VERT_ATTRIB_GENERIC(i)] =
488 &vertexAttrib[VERT_ATTRIB_GENERIC(i)];
489 else {
490 inputs[VERT_ATTRIB_GENERIC(i)] =
491 &vbo->currval[VBO_ATTRIB_GENERIC0+i];
492 const_inputs |= VERT_BIT_GENERIC(i);
493 }
494 }
495
496 inputs[VERT_ATTRIB_GENERIC0] = inputs[0];
497 } else {
498 /* Other parts of the code assume that inputs[0] through
499 * inputs[VERT_ATTRIB_FF_MAX] will be non-NULL. However, in OpenGL
500 * ES 2.0+ or OpenGL core profile, none of these arrays should ever
501 * be enabled.
502 */
503 for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
504 assert(!vertexAttrib[VERT_ATTRIB_FF(i)].Enabled);
505
506 inputs[i] = &vbo->currval[VBO_ATTRIB_POS+i];
507 const_inputs |= VERT_BIT_FF(i);
508 }
509
510 for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
511 if (vertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
512 inputs[VERT_ATTRIB_GENERIC(i)] =
513 &vertexAttrib[VERT_ATTRIB_GENERIC(i)];
514 else {
515 inputs[VERT_ATTRIB_GENERIC(i)] =
516 &vbo->currval[VBO_ATTRIB_GENERIC0+i];
517 const_inputs |= VERT_BIT_GENERIC(i);
518 }
519 }
520 }
521
522 break;
523 }
524
525 _mesa_set_varying_vp_inputs( ctx, VERT_BIT_ALL & (~const_inputs) );
526 ctx->NewDriverState |= ctx->DriverFlags.NewArray;
527 }
528
529
530 /**
531 * Examine the enabled vertex arrays to set the exec->array.inputs[] values.
532 * These will point to the arrays to actually use for drawing. Some will
533 * be user-provided arrays, other will be zero-stride const-valued arrays.
534 * Note that this might set the _NEW_VARYING_VP_INPUTS dirty flag so state
535 * validation must be done after this call.
536 */
537 void
538 vbo_bind_arrays(struct gl_context *ctx)
539 {
540 struct vbo_context *vbo = vbo_context(ctx);
541 struct vbo_exec_context *exec = &vbo->exec;
542
543 vbo_draw_method(vbo, DRAW_ARRAYS);
544
545 if (exec->array.recalculate_inputs) {
546 recalculate_input_bindings(ctx);
547 exec->array.recalculate_inputs = GL_FALSE;
548
549 /* Again... because we may have changed the bitmask of per-vertex varying
550 * attributes. If we regenerate the fixed-function vertex program now
551 * we may be able to prune down the number of vertex attributes which we
552 * need in the shader.
553 */
554 if (ctx->NewState) {
555 /* Setting "validating" to TRUE prevents _mesa_update_state from
556 * invalidating what we just did.
557 */
558 exec->validating = GL_TRUE;
559 _mesa_update_state(ctx);
560 exec->validating = GL_FALSE;
561 }
562 }
563 }
564
565 /**
566 * Helper function called by the other DrawArrays() functions below.
567 * This is where we handle primitive restart for drawing non-indexed
568 * arrays. If primitive restart is enabled, it typically means
569 * splitting one DrawArrays() into two.
570 */
571 static void
572 vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
573 GLsizei count, GLuint numInstances, GLuint baseInstance)
574 {
575 struct vbo_context *vbo = vbo_context(ctx);
576 struct vbo_exec_context *exec = &vbo->exec;
577 struct _mesa_prim prim[2];
578
579 vbo_bind_arrays(ctx);
580
581 /* init most fields to zero */
582 memset(prim, 0, sizeof(prim));
583 prim[0].begin = 1;
584 prim[0].end = 1;
585 prim[0].mode = mode;
586 prim[0].num_instances = numInstances;
587 prim[0].base_instance = baseInstance;
588 prim[0].is_indirect = 0;
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, prim, primCount, NULL,
626 GL_TRUE, start, start + count - 1, NULL, NULL);
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, prim, 1, NULL,
636 GL_TRUE, start, start + count - 1,
637 NULL, NULL);
638 }
639
640 if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) {
641 _mesa_flush(ctx);
642 }
643 }
644
645
646 /**
647 * Execute a glRectf() function.
648 */
649 static void GLAPIENTRY
650 vbo_exec_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
651 {
652 GET_CURRENT_CONTEXT(ctx);
653 ASSERT_OUTSIDE_BEGIN_END(ctx);
654
655 CALL_Begin(GET_DISPATCH(), (GL_QUADS));
656 CALL_Vertex2f(GET_DISPATCH(), (x1, y1));
657 CALL_Vertex2f(GET_DISPATCH(), (x2, y1));
658 CALL_Vertex2f(GET_DISPATCH(), (x2, y2));
659 CALL_Vertex2f(GET_DISPATCH(), (x1, y2));
660 CALL_End(GET_DISPATCH(), ());
661 }
662
663
664 static void GLAPIENTRY
665 vbo_exec_EvalMesh1(GLenum mode, GLint i1, GLint i2)
666 {
667 GET_CURRENT_CONTEXT(ctx);
668 GLint i;
669 GLfloat u, du;
670 GLenum prim;
671
672 switch (mode) {
673 case GL_POINT:
674 prim = GL_POINTS;
675 break;
676 case GL_LINE:
677 prim = GL_LINE_STRIP;
678 break;
679 default:
680 _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" );
681 return;
682 }
683
684 /* No effect if vertex maps disabled.
685 */
686 if (!ctx->Eval.Map1Vertex4 &&
687 !ctx->Eval.Map1Vertex3)
688 return;
689
690 du = ctx->Eval.MapGrid1du;
691 u = ctx->Eval.MapGrid1u1 + i1 * du;
692
693 CALL_Begin(GET_DISPATCH(), (prim));
694 for (i=i1;i<=i2;i++,u+=du) {
695 CALL_EvalCoord1f(GET_DISPATCH(), (u));
696 }
697 CALL_End(GET_DISPATCH(), ());
698 }
699
700
701 static void GLAPIENTRY
702 vbo_exec_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
703 {
704 GET_CURRENT_CONTEXT(ctx);
705 GLfloat u, du, v, dv, v1, u1;
706 GLint i, j;
707
708 switch (mode) {
709 case GL_POINT:
710 case GL_LINE:
711 case GL_FILL:
712 break;
713 default:
714 _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
715 return;
716 }
717
718 /* No effect if vertex maps disabled.
719 */
720 if (!ctx->Eval.Map2Vertex4 &&
721 !ctx->Eval.Map2Vertex3)
722 return;
723
724 du = ctx->Eval.MapGrid2du;
725 dv = ctx->Eval.MapGrid2dv;
726 v1 = ctx->Eval.MapGrid2v1 + j1 * dv;
727 u1 = ctx->Eval.MapGrid2u1 + i1 * du;
728
729 switch (mode) {
730 case GL_POINT:
731 CALL_Begin(GET_DISPATCH(), (GL_POINTS));
732 for (v=v1,j=j1;j<=j2;j++,v+=dv) {
733 for (u=u1,i=i1;i<=i2;i++,u+=du) {
734 CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
735 }
736 }
737 CALL_End(GET_DISPATCH(), ());
738 break;
739 case GL_LINE:
740 for (v=v1,j=j1;j<=j2;j++,v+=dv) {
741 CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP));
742 for (u=u1,i=i1;i<=i2;i++,u+=du) {
743 CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
744 }
745 CALL_End(GET_DISPATCH(), ());
746 }
747 for (u=u1,i=i1;i<=i2;i++,u+=du) {
748 CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP));
749 for (v=v1,j=j1;j<=j2;j++,v+=dv) {
750 CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
751 }
752 CALL_End(GET_DISPATCH(), ());
753 }
754 break;
755 case GL_FILL:
756 for (v=v1,j=j1;j<j2;j++,v+=dv) {
757 CALL_Begin(GET_DISPATCH(), (GL_TRIANGLE_STRIP));
758 for (u=u1,i=i1;i<=i2;i++,u+=du) {
759 CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
760 CALL_EvalCoord2f(GET_DISPATCH(), (u, v+dv));
761 }
762 CALL_End(GET_DISPATCH(), ());
763 }
764 break;
765 }
766 }
767
768
769 /**
770 * Called from glDrawArrays when in immediate mode (not display list mode).
771 */
772 static void GLAPIENTRY
773 vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count)
774 {
775 GET_CURRENT_CONTEXT(ctx);
776
777 if (MESA_VERBOSE & VERBOSE_DRAW)
778 _mesa_debug(ctx, "glDrawArrays(%s, %d, %d)\n",
779 _mesa_lookup_enum_by_nr(mode), start, count);
780
781 if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
782 return;
783
784 if (0)
785 check_draw_arrays_data(ctx, start, count);
786
787 vbo_draw_arrays(ctx, mode, start, count, 1, 0);
788
789 if (0)
790 print_draw_arrays(ctx, mode, start, count);
791 }
792
793
794 /**
795 * Called from glDrawArraysInstanced when in immediate mode (not
796 * display list mode).
797 */
798 static void GLAPIENTRY
799 vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count,
800 GLsizei numInstances)
801 {
802 GET_CURRENT_CONTEXT(ctx);
803
804 if (MESA_VERBOSE & VERBOSE_DRAW)
805 _mesa_debug(ctx, "glDrawArraysInstanced(%s, %d, %d, %d)\n",
806 _mesa_lookup_enum_by_nr(mode), start, count, numInstances);
807
808 if (!_mesa_validate_DrawArraysInstanced(ctx, mode, start, count, numInstances))
809 return;
810
811 if (0)
812 check_draw_arrays_data(ctx, start, count);
813
814 vbo_draw_arrays(ctx, mode, start, count, numInstances, 0);
815
816 if (0)
817 print_draw_arrays(ctx, mode, start, count);
818 }
819
820
821 /**
822 * Called from glDrawArraysInstancedBaseInstance when in immediate mode.
823 */
824 static void GLAPIENTRY
825 vbo_exec_DrawArraysInstancedBaseInstance(GLenum mode, GLint first, GLsizei count,
826 GLsizei numInstances, GLuint baseInstance)
827 {
828 GET_CURRENT_CONTEXT(ctx);
829
830 if (MESA_VERBOSE & VERBOSE_DRAW)
831 _mesa_debug(ctx, "glDrawArraysInstancedBaseInstance(%s, %d, %d, %d, %d)\n",
832 _mesa_lookup_enum_by_nr(mode), first, count,
833 numInstances, baseInstance);
834
835 if (!_mesa_validate_DrawArraysInstanced(ctx, mode, first, count,
836 numInstances))
837 return;
838
839 if (0)
840 check_draw_arrays_data(ctx, first, count);
841
842 vbo_draw_arrays(ctx, mode, first, count, numInstances, baseInstance);
843
844 if (0)
845 print_draw_arrays(ctx, mode, first, count);
846 }
847
848
849
850 /**
851 * Map GL_ELEMENT_ARRAY_BUFFER and print contents.
852 * For debugging.
853 */
854 #if 0
855 static void
856 dump_element_buffer(struct gl_context *ctx, GLenum type)
857 {
858 const GLvoid *map =
859 ctx->Driver.MapBufferRange(ctx, 0,
860 ctx->Array.VAO->IndexBufferObj->Size,
861 GL_MAP_READ_BIT,
862 ctx->Array.VAO->IndexBufferObj,
863 MAP_INTERNAL);
864 switch (type) {
865 case GL_UNSIGNED_BYTE:
866 {
867 const GLubyte *us = (const GLubyte *) map;
868 GLint i;
869 for (i = 0; i < ctx->Array.VAO->IndexBufferObj->Size; i++) {
870 printf("%02x ", us[i]);
871 if (i % 32 == 31)
872 printf("\n");
873 }
874 printf("\n");
875 }
876 break;
877 case GL_UNSIGNED_SHORT:
878 {
879 const GLushort *us = (const GLushort *) map;
880 GLint i;
881 for (i = 0; i < ctx->Array.VAO->IndexBufferObj->Size / 2; i++) {
882 printf("%04x ", us[i]);
883 if (i % 16 == 15)
884 printf("\n");
885 }
886 printf("\n");
887 }
888 break;
889 case GL_UNSIGNED_INT:
890 {
891 const GLuint *us = (const GLuint *) map;
892 GLint i;
893 for (i = 0; i < ctx->Array.VAO->IndexBufferObj->Size / 4; i++) {
894 printf("%08x ", us[i]);
895 if (i % 8 == 7)
896 printf("\n");
897 }
898 printf("\n");
899 }
900 break;
901 default:
902 ;
903 }
904
905 ctx->Driver.UnmapBuffer(ctx, ctx->Array.VAO->IndexBufferObj,
906 MAP_INTERNAL);
907 }
908 #endif
909
910
911 /**
912 * Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements.
913 * Do the rendering for a glDrawElements or glDrawRangeElements call after
914 * we've validated buffer bounds, etc.
915 */
916 static void
917 vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
918 GLboolean index_bounds_valid,
919 GLuint start, GLuint end,
920 GLsizei count, GLenum type,
921 const GLvoid *indices,
922 GLint basevertex, GLuint numInstances,
923 GLuint baseInstance)
924 {
925 struct vbo_context *vbo = vbo_context(ctx);
926 struct vbo_exec_context *exec = &vbo->exec;
927 struct _mesa_index_buffer ib;
928 struct _mesa_prim prim[1];
929
930 vbo_bind_arrays(ctx);
931
932 ib.count = count;
933 ib.type = type;
934 ib.obj = ctx->Array.VAO->IndexBufferObj;
935 ib.ptr = indices;
936
937 prim[0].begin = 1;
938 prim[0].end = 1;
939 prim[0].weak = 0;
940 prim[0].pad = 0;
941 prim[0].mode = mode;
942 prim[0].start = 0;
943 prim[0].count = count;
944 prim[0].indexed = 1;
945 prim[0].is_indirect = 0;
946 prim[0].basevertex = basevertex;
947 prim[0].num_instances = numInstances;
948 prim[0].base_instance = baseInstance;
949
950 /* Need to give special consideration to rendering a range of
951 * indices starting somewhere above zero. Typically the
952 * application is issuing multiple DrawRangeElements() to draw
953 * successive primitives layed out linearly in the vertex arrays.
954 * Unless the vertex arrays are all in a VBO (or locked as with
955 * CVA), the OpenGL semantics imply that we need to re-read or
956 * re-upload the vertex data on each draw call.
957 *
958 * In the case of hardware tnl, we want to avoid starting the
959 * upload at zero, as it will mean every draw call uploads an
960 * increasing amount of not-used vertex data. Worse - in the
961 * software tnl module, all those vertices might be transformed and
962 * lit but never rendered.
963 *
964 * If we just upload or transform the vertices in start..end,
965 * however, the indices will be incorrect.
966 *
967 * At this level, we don't know exactly what the requirements of
968 * the backend are going to be, though it will likely boil down to
969 * either:
970 *
971 * 1) Do nothing, everything is in a VBO and is processed once
972 * only.
973 *
974 * 2) Adjust the indices and vertex arrays so that start becomes
975 * zero.
976 *
977 * Rather than doing anything here, I'll provide a helper function
978 * for the latter case elsewhere.
979 */
980
981 check_buffers_are_unmapped(exec->array.inputs);
982 vbo->draw_prims(ctx, prim, 1, &ib,
983 index_bounds_valid, start, end, NULL, NULL);
984
985 if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) {
986 _mesa_flush(ctx);
987 }
988 }
989
990
991 /**
992 * Called by glDrawRangeElementsBaseVertex() in immediate mode.
993 */
994 static void GLAPIENTRY
995 vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
996 GLuint start, GLuint end,
997 GLsizei count, GLenum type,
998 const GLvoid *indices,
999 GLint basevertex)
1000 {
1001 static GLuint warnCount = 0;
1002 GLboolean index_bounds_valid = GL_TRUE;
1003
1004 /* This is only useful to catch invalid values in the "end" parameter
1005 * like ~0.
1006 */
1007 GLuint max_element = 2 * 1000 * 1000 * 1000; /* just a big number */
1008
1009 GET_CURRENT_CONTEXT(ctx);
1010
1011 if (MESA_VERBOSE & VERBOSE_DRAW)
1012 _mesa_debug(ctx,
1013 "glDrawRangeElementsBaseVertex(%s, %u, %u, %d, %s, %p, %d)\n",
1014 _mesa_lookup_enum_by_nr(mode), start, end, count,
1015 _mesa_lookup_enum_by_nr(type), indices, basevertex);
1016
1017 if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count,
1018 type, indices, basevertex ))
1019 return;
1020
1021 if ((int) end + basevertex < 0 ||
1022 start + basevertex >= max_element) {
1023 /* The application requested we draw using a range of indices that's
1024 * outside the bounds of the current VBO. This is invalid and appears
1025 * to give undefined results. The safest thing to do is to simply
1026 * ignore the range, in case the application botched their range tracking
1027 * but did provide valid indices. Also issue a warning indicating that
1028 * the application is broken.
1029 */
1030 if (warnCount++ < 10) {
1031 _mesa_warning(ctx, "glDrawRangeElements(start %u, end %u, "
1032 "basevertex %d, count %d, type 0x%x, indices=%p):\n"
1033 "\trange is outside VBO bounds (max=%u); ignoring.\n"
1034 "\tThis should be fixed in the application.",
1035 start, end, basevertex, count, type, indices,
1036 max_element - 1);
1037 }
1038 index_bounds_valid = GL_FALSE;
1039 }
1040
1041 /* NOTE: It's important that 'end' is a reasonable value.
1042 * in _tnl_draw_prims(), we use end to determine how many vertices
1043 * to transform. If it's too large, we can unnecessarily split prims
1044 * or we can read/write out of memory in several different places!
1045 */
1046
1047 /* Catch/fix some potential user errors */
1048 if (type == GL_UNSIGNED_BYTE) {
1049 start = MIN2(start, 0xff);
1050 end = MIN2(end, 0xff);
1051 }
1052 else if (type == GL_UNSIGNED_SHORT) {
1053 start = MIN2(start, 0xffff);
1054 end = MIN2(end, 0xffff);
1055 }
1056
1057 if (0) {
1058 printf("glDraw[Range]Elements{,BaseVertex}"
1059 "(start %u, end %u, type 0x%x, count %d) ElemBuf %u, "
1060 "base %d\n",
1061 start, end, type, count,
1062 ctx->Array.VAO->IndexBufferObj->Name,
1063 basevertex);
1064 }
1065
1066 if ((int) start + basevertex < 0 ||
1067 end + basevertex >= max_element)
1068 index_bounds_valid = GL_FALSE;
1069
1070 #if 0
1071 check_draw_elements_data(ctx, count, type, indices);
1072 #else
1073 (void) check_draw_elements_data;
1074 #endif
1075
1076 vbo_validated_drawrangeelements(ctx, mode, index_bounds_valid, start, end,
1077 count, type, indices, basevertex, 1, 0);
1078 }
1079
1080
1081 /**
1082 * Called by glDrawRangeElements() in immediate mode.
1083 */
1084 static void GLAPIENTRY
1085 vbo_exec_DrawRangeElements(GLenum mode, GLuint start, GLuint end,
1086 GLsizei count, GLenum type, const GLvoid *indices)
1087 {
1088 if (MESA_VERBOSE & VERBOSE_DRAW) {
1089 GET_CURRENT_CONTEXT(ctx);
1090 _mesa_debug(ctx,
1091 "glDrawRangeElements(%s, %u, %u, %d, %s, %p)\n",
1092 _mesa_lookup_enum_by_nr(mode), start, end, count,
1093 _mesa_lookup_enum_by_nr(type), indices);
1094 }
1095
1096 vbo_exec_DrawRangeElementsBaseVertex(mode, start, end, count, type,
1097 indices, 0);
1098 }
1099
1100
1101 /**
1102 * Called by glDrawElements() in immediate mode.
1103 */
1104 static void GLAPIENTRY
1105 vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type,
1106 const GLvoid *indices)
1107 {
1108 GET_CURRENT_CONTEXT(ctx);
1109
1110 if (MESA_VERBOSE & VERBOSE_DRAW)
1111 _mesa_debug(ctx, "glDrawElements(%s, %u, %s, %p)\n",
1112 _mesa_lookup_enum_by_nr(mode), count,
1113 _mesa_lookup_enum_by_nr(type), indices);
1114
1115 if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 ))
1116 return;
1117
1118 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
1119 count, type, indices, 0, 1, 0);
1120 }
1121
1122
1123 /**
1124 * Called by glDrawElementsBaseVertex() in immediate mode.
1125 */
1126 static void GLAPIENTRY
1127 vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
1128 const GLvoid *indices, GLint basevertex)
1129 {
1130 GET_CURRENT_CONTEXT(ctx);
1131
1132 if (MESA_VERBOSE & VERBOSE_DRAW)
1133 _mesa_debug(ctx, "glDrawElementsBaseVertex(%s, %d, %s, %p, %d)\n",
1134 _mesa_lookup_enum_by_nr(mode), count,
1135 _mesa_lookup_enum_by_nr(type), indices, basevertex);
1136
1137 if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices,
1138 basevertex ))
1139 return;
1140
1141 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
1142 count, type, indices, basevertex, 1, 0);
1143 }
1144
1145
1146 /**
1147 * Called by glDrawElementsInstanced() in immediate mode.
1148 */
1149 static void GLAPIENTRY
1150 vbo_exec_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
1151 const GLvoid *indices, GLsizei numInstances)
1152 {
1153 GET_CURRENT_CONTEXT(ctx);
1154
1155 if (MESA_VERBOSE & VERBOSE_DRAW)
1156 _mesa_debug(ctx, "glDrawElementsInstanced(%s, %d, %s, %p, %d)\n",
1157 _mesa_lookup_enum_by_nr(mode), count,
1158 _mesa_lookup_enum_by_nr(type), indices, numInstances);
1159
1160 if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
1161 numInstances, 0))
1162 return;
1163
1164 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
1165 count, type, indices, 0, numInstances, 0);
1166 }
1167
1168
1169 /**
1170 * Called by glDrawElementsInstancedBaseVertex() in immediate mode.
1171 */
1172 static void GLAPIENTRY
1173 vbo_exec_DrawElementsInstancedBaseVertex(GLenum mode, GLsizei count, GLenum type,
1174 const GLvoid *indices, GLsizei numInstances,
1175 GLint basevertex)
1176 {
1177 GET_CURRENT_CONTEXT(ctx);
1178
1179 if (MESA_VERBOSE & VERBOSE_DRAW)
1180 _mesa_debug(ctx, "glDrawElementsInstancedBaseVertex(%s, %d, %s, %p, %d; %d)\n",
1181 _mesa_lookup_enum_by_nr(mode), count,
1182 _mesa_lookup_enum_by_nr(type), indices,
1183 numInstances, basevertex);
1184
1185 if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
1186 numInstances, basevertex))
1187 return;
1188
1189 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
1190 count, type, indices, basevertex, numInstances, 0);
1191 }
1192
1193
1194 /**
1195 * Called by glDrawElementsInstancedBaseInstance() in immediate mode.
1196 */
1197 static void GLAPIENTRY
1198 vbo_exec_DrawElementsInstancedBaseInstance(GLenum mode, GLsizei count, GLenum type,
1199 const GLvoid *indices, GLsizei numInstances,
1200 GLuint baseInstance)
1201 {
1202 GET_CURRENT_CONTEXT(ctx);
1203
1204 if (MESA_VERBOSE & VERBOSE_DRAW)
1205 _mesa_debug(ctx, "glDrawElementsInstancedBaseInstance(%s, %d, %s, %p, %d, %d)\n",
1206 _mesa_lookup_enum_by_nr(mode), count,
1207 _mesa_lookup_enum_by_nr(type), indices,
1208 numInstances, baseInstance);
1209
1210 if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
1211 numInstances, 0))
1212 return;
1213
1214 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
1215 count, type, indices, 0, numInstances,
1216 baseInstance);
1217 }
1218
1219
1220 /**
1221 * Called by glDrawElementsInstancedBaseVertexBaseInstance() in immediate mode.
1222 */
1223 static void GLAPIENTRY
1224 vbo_exec_DrawElementsInstancedBaseVertexBaseInstance(GLenum mode, GLsizei count, GLenum type,
1225 const GLvoid *indices, GLsizei numInstances,
1226 GLint basevertex, GLuint baseInstance)
1227 {
1228 GET_CURRENT_CONTEXT(ctx);
1229
1230 if (MESA_VERBOSE & VERBOSE_DRAW)
1231 _mesa_debug(ctx, "glDrawElementsInstancedBaseVertexBaseInstance(%s, %d, %s, %p, %d, %d, %d)\n",
1232 _mesa_lookup_enum_by_nr(mode), count,
1233 _mesa_lookup_enum_by_nr(type), indices,
1234 numInstances, basevertex, baseInstance);
1235
1236 if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
1237 numInstances, basevertex))
1238 return;
1239
1240 vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
1241 count, type, indices, basevertex, numInstances,
1242 baseInstance);
1243 }
1244
1245
1246 /**
1247 * Inner support for both _mesa_MultiDrawElements() and
1248 * _mesa_MultiDrawRangeElements().
1249 * This does the actual rendering after we've checked array indexes, etc.
1250 */
1251 static void
1252 vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
1253 const GLsizei *count, GLenum type,
1254 const GLvoid * const *indices,
1255 GLsizei primcount,
1256 const GLint *basevertex)
1257 {
1258 struct vbo_context *vbo = vbo_context(ctx);
1259 struct vbo_exec_context *exec = &vbo->exec;
1260 struct _mesa_index_buffer ib;
1261 struct _mesa_prim *prim;
1262 unsigned int index_type_size = vbo_sizeof_ib_type(type);
1263 uintptr_t min_index_ptr, max_index_ptr;
1264 GLboolean fallback = GL_FALSE;
1265 int i;
1266
1267 if (primcount == 0)
1268 return;
1269
1270 prim = calloc(primcount, sizeof(*prim));
1271 if (prim == NULL) {
1272 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElements");
1273 return;
1274 }
1275
1276 vbo_bind_arrays(ctx);
1277
1278 min_index_ptr = (uintptr_t)indices[0];
1279 max_index_ptr = 0;
1280 for (i = 0; i < primcount; i++) {
1281 min_index_ptr = MIN2(min_index_ptr, (uintptr_t)indices[i]);
1282 max_index_ptr = MAX2(max_index_ptr, (uintptr_t)indices[i] +
1283 index_type_size * count[i]);
1284 }
1285
1286 /* Check if we can handle this thing as a bunch of index offsets from the
1287 * same index pointer. If we can't, then we have to fall back to doing
1288 * a draw_prims per primitive.
1289 * Check that the difference between each prim's indexes is a multiple of
1290 * the index/element size.
1291 */
1292 if (index_type_size != 1) {
1293 for (i = 0; i < primcount; i++) {
1294 if ((((uintptr_t)indices[i] - min_index_ptr) % index_type_size) != 0) {
1295 fallback = GL_TRUE;
1296 break;
1297 }
1298 }
1299 }
1300
1301 /* Draw primitives individually if one count is zero, so we can easily skip
1302 * that primitive.
1303 */
1304 for (i = 0; i < primcount; i++) {
1305 if (count[i] == 0) {
1306 fallback = GL_TRUE;
1307 break;
1308 }
1309 }
1310
1311 /* If the index buffer isn't in a VBO, then treating the application's
1312 * subranges of the index buffer as one large index buffer may lead to
1313 * us reading unmapped memory.
1314 */
1315 if (!_mesa_is_bufferobj(ctx->Array.VAO->IndexBufferObj))
1316 fallback = GL_TRUE;
1317
1318 if (!fallback) {
1319 ib.count = (max_index_ptr - min_index_ptr) / index_type_size;
1320 ib.type = type;
1321 ib.obj = ctx->Array.VAO->IndexBufferObj;
1322 ib.ptr = (void *)min_index_ptr;
1323
1324 for (i = 0; i < primcount; i++) {
1325 prim[i].begin = (i == 0);
1326 prim[i].end = (i == primcount - 1);
1327 prim[i].weak = 0;
1328 prim[i].pad = 0;
1329 prim[i].mode = mode;
1330 prim[i].start = ((uintptr_t)indices[i] - min_index_ptr) / index_type_size;
1331 prim[i].count = count[i];
1332 prim[i].indexed = 1;
1333 prim[i].num_instances = 1;
1334 prim[i].base_instance = 0;
1335 prim[i].is_indirect = 0;
1336 if (basevertex != NULL)
1337 prim[i].basevertex = basevertex[i];
1338 else
1339 prim[i].basevertex = 0;
1340 }
1341
1342 check_buffers_are_unmapped(exec->array.inputs);
1343 vbo->draw_prims(ctx, prim, primcount, &ib,
1344 false, ~0, ~0, NULL, NULL);
1345 } else {
1346 /* render one prim at a time */
1347 for (i = 0; i < primcount; i++) {
1348 if (count[i] == 0)
1349 continue;
1350 ib.count = count[i];
1351 ib.type = type;
1352 ib.obj = ctx->Array.VAO->IndexBufferObj;
1353 ib.ptr = indices[i];
1354
1355 prim[0].begin = 1;
1356 prim[0].end = 1;
1357 prim[0].weak = 0;
1358 prim[0].pad = 0;
1359 prim[0].mode = mode;
1360 prim[0].start = 0;
1361 prim[0].count = count[i];
1362 prim[0].indexed = 1;
1363 prim[0].num_instances = 1;
1364 prim[0].base_instance = 0;
1365 prim[0].is_indirect = 0;
1366 if (basevertex != NULL)
1367 prim[0].basevertex = basevertex[i];
1368 else
1369 prim[0].basevertex = 0;
1370
1371 check_buffers_are_unmapped(exec->array.inputs);
1372 vbo->draw_prims(ctx, prim, 1, &ib,
1373 false, ~0, ~0, NULL, NULL);
1374 }
1375 }
1376
1377 free(prim);
1378
1379 if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) {
1380 _mesa_flush(ctx);
1381 }
1382 }
1383
1384
1385 static void GLAPIENTRY
1386 vbo_exec_MultiDrawElements(GLenum mode,
1387 const GLsizei *count, GLenum type,
1388 const GLvoid * const *indices,
1389 GLsizei primcount)
1390 {
1391 GET_CURRENT_CONTEXT(ctx);
1392
1393 if (!_mesa_validate_MultiDrawElements(ctx, mode, count, type, indices,
1394 primcount, NULL))
1395 return;
1396
1397 vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount,
1398 NULL);
1399 }
1400
1401
1402 static void GLAPIENTRY
1403 vbo_exec_MultiDrawElementsBaseVertex(GLenum mode,
1404 const GLsizei *count, GLenum type,
1405 const GLvoid * const *indices,
1406 GLsizei primcount,
1407 const GLsizei *basevertex)
1408 {
1409 GET_CURRENT_CONTEXT(ctx);
1410
1411 if (!_mesa_validate_MultiDrawElements(ctx, mode, count, type, indices,
1412 primcount, basevertex))
1413 return;
1414
1415 vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount,
1416 basevertex);
1417 }
1418
1419 static void
1420 vbo_draw_transform_feedback(struct gl_context *ctx, GLenum mode,
1421 struct gl_transform_feedback_object *obj,
1422 GLuint stream, GLuint numInstances)
1423 {
1424 struct vbo_context *vbo = vbo_context(ctx);
1425 struct vbo_exec_context *exec = &vbo->exec;
1426 struct _mesa_prim prim[2];
1427
1428 if (!_mesa_validate_DrawTransformFeedback(ctx, mode, obj, stream,
1429 numInstances)) {
1430 return;
1431 }
1432
1433 if (ctx->Driver.GetTransformFeedbackVertexCount &&
1434 (ctx->Const.AlwaysUseGetTransformFeedbackVertexCount ||
1435 !vbo_all_varyings_in_vbos(exec->array.inputs))) {
1436 GLsizei n = ctx->Driver.GetTransformFeedbackVertexCount(ctx, obj, stream);
1437 vbo_draw_arrays(ctx, mode, 0, n, numInstances, 0);
1438 return;
1439 }
1440
1441 vbo_bind_arrays(ctx);
1442
1443 /* init most fields to zero */
1444 memset(prim, 0, sizeof(prim));
1445 prim[0].begin = 1;
1446 prim[0].end = 1;
1447 prim[0].mode = mode;
1448 prim[0].num_instances = numInstances;
1449 prim[0].base_instance = 0;
1450 prim[0].is_indirect = 0;
1451
1452 /* Maybe we should do some primitive splitting for primitive restart
1453 * (like in DrawArrays), but we have no way to know how many vertices
1454 * will be rendered. */
1455
1456 check_buffers_are_unmapped(exec->array.inputs);
1457 vbo->draw_prims(ctx, prim, 1, NULL,
1458 GL_TRUE, 0, 0, obj, NULL);
1459
1460 if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) {
1461 _mesa_flush(ctx);
1462 }
1463 }
1464
1465 /**
1466 * Like DrawArrays, but take the count from a transform feedback object.
1467 * \param mode GL_POINTS, GL_LINES, GL_TRIANGLE_STRIP, etc.
1468 * \param name the transform feedback object
1469 * User still has to setup of the vertex attribute info with
1470 * glVertexPointer, glColorPointer, etc.
1471 * Part of GL_ARB_transform_feedback2.
1472 */
1473 static void GLAPIENTRY
1474 vbo_exec_DrawTransformFeedback(GLenum mode, GLuint name)
1475 {
1476 GET_CURRENT_CONTEXT(ctx);
1477 struct gl_transform_feedback_object *obj =
1478 _mesa_lookup_transform_feedback_object(ctx, name);
1479
1480 if (MESA_VERBOSE & VERBOSE_DRAW)
1481 _mesa_debug(ctx, "glDrawTransformFeedback(%s, %d)\n",
1482 _mesa_lookup_enum_by_nr(mode), name);
1483
1484 vbo_draw_transform_feedback(ctx, mode, obj, 0, 1);
1485 }
1486
1487 static void GLAPIENTRY
1488 vbo_exec_DrawTransformFeedbackStream(GLenum mode, GLuint name, GLuint stream)
1489 {
1490 GET_CURRENT_CONTEXT(ctx);
1491 struct gl_transform_feedback_object *obj =
1492 _mesa_lookup_transform_feedback_object(ctx, name);
1493
1494 if (MESA_VERBOSE & VERBOSE_DRAW)
1495 _mesa_debug(ctx, "glDrawTransformFeedbackStream(%s, %u, %u)\n",
1496 _mesa_lookup_enum_by_nr(mode), name, stream);
1497
1498 vbo_draw_transform_feedback(ctx, mode, obj, stream, 1);
1499 }
1500
1501 static void GLAPIENTRY
1502 vbo_exec_DrawTransformFeedbackInstanced(GLenum mode, GLuint name,
1503 GLsizei primcount)
1504 {
1505 GET_CURRENT_CONTEXT(ctx);
1506 struct gl_transform_feedback_object *obj =
1507 _mesa_lookup_transform_feedback_object(ctx, name);
1508
1509 if (MESA_VERBOSE & VERBOSE_DRAW)
1510 _mesa_debug(ctx, "glDrawTransformFeedbackInstanced(%s, %d)\n",
1511 _mesa_lookup_enum_by_nr(mode), name);
1512
1513 vbo_draw_transform_feedback(ctx, mode, obj, 0, primcount);
1514 }
1515
1516 static void GLAPIENTRY
1517 vbo_exec_DrawTransformFeedbackStreamInstanced(GLenum mode, GLuint name,
1518 GLuint stream, GLsizei primcount)
1519 {
1520 GET_CURRENT_CONTEXT(ctx);
1521 struct gl_transform_feedback_object *obj =
1522 _mesa_lookup_transform_feedback_object(ctx, name);
1523
1524 if (MESA_VERBOSE & VERBOSE_DRAW)
1525 _mesa_debug(ctx, "glDrawTransformFeedbackStreamInstanced"
1526 "(%s, %u, %u, %i)\n",
1527 _mesa_lookup_enum_by_nr(mode), name, stream, primcount);
1528
1529 vbo_draw_transform_feedback(ctx, mode, obj, stream, primcount);
1530 }
1531
1532 static void
1533 vbo_validated_drawarraysindirect(struct gl_context *ctx,
1534 GLenum mode, const GLvoid *indirect)
1535 {
1536 struct vbo_context *vbo = vbo_context(ctx);
1537 struct vbo_exec_context *exec = &vbo->exec;
1538 struct _mesa_prim prim[1];
1539
1540 vbo_bind_arrays(ctx);
1541
1542 memset(prim, 0, sizeof(prim));
1543 prim[0].begin = 1;
1544 prim[0].end = 1;
1545 prim[0].mode = mode;
1546 prim[0].is_indirect = 1;
1547 prim[0].indirect_offset = (GLsizeiptr)indirect;
1548
1549 /* NOTE: We do NOT want to handle primitive restart here, nor perform any
1550 * other checks that require knowledge of the values in the command buffer.
1551 * That would defeat the whole purpose of this function.
1552 */
1553
1554 check_buffers_are_unmapped(exec->array.inputs);
1555 vbo->draw_prims(ctx, prim, 1,
1556 NULL, GL_TRUE, 0, ~0,
1557 NULL,
1558 ctx->DrawIndirectBuffer);
1559
1560 if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH)
1561 _mesa_flush(ctx);
1562 }
1563
1564 static void
1565 vbo_validated_multidrawarraysindirect(struct gl_context *ctx,
1566 GLenum mode,
1567 const GLvoid *indirect,
1568 GLsizei primcount, GLsizei stride)
1569 {
1570 struct vbo_context *vbo = vbo_context(ctx);
1571 struct vbo_exec_context *exec = &vbo->exec;
1572 struct _mesa_prim *prim;
1573 GLsizei i;
1574 GLsizeiptr offset = (GLsizeiptr)indirect;
1575
1576 if (primcount == 0)
1577 return;
1578 prim = calloc(primcount, sizeof(*prim));
1579 if (prim == NULL) {
1580 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawArraysIndirect");
1581 return;
1582 }
1583
1584 vbo_bind_arrays(ctx);
1585
1586 prim[0].begin = 1;
1587 prim[primcount - 1].end = 1;
1588 for (i = 0; i < primcount; ++i, offset += stride) {
1589 prim[i].mode = mode;
1590 prim[i].indirect_offset = offset;
1591 prim[i].is_indirect = 1;
1592 }
1593
1594 check_buffers_are_unmapped(exec->array.inputs);
1595 vbo->draw_prims(ctx, prim, primcount,
1596 NULL, GL_TRUE, 0, ~0,
1597 NULL,
1598 ctx->DrawIndirectBuffer);
1599
1600 free(prim);
1601
1602 if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH)
1603 _mesa_flush(ctx);
1604 }
1605
1606 static void
1607 vbo_validated_drawelementsindirect(struct gl_context *ctx,
1608 GLenum mode, GLenum type,
1609 const GLvoid *indirect)
1610 {
1611 struct vbo_context *vbo = vbo_context(ctx);
1612 struct vbo_exec_context *exec = &vbo->exec;
1613 struct _mesa_index_buffer ib;
1614 struct _mesa_prim prim[1];
1615
1616 vbo_bind_arrays(ctx);
1617
1618 ib.count = 0; /* unknown */
1619 ib.type = type;
1620 ib.obj = ctx->Array.VAO->IndexBufferObj;
1621 ib.ptr = NULL;
1622
1623 memset(prim, 0, sizeof(prim));
1624 prim[0].begin = 1;
1625 prim[0].end = 1;
1626 prim[0].mode = mode;
1627 prim[0].indexed = 1;
1628 prim[0].indirect_offset = (GLsizeiptr)indirect;
1629 prim[0].is_indirect = 1;
1630
1631 check_buffers_are_unmapped(exec->array.inputs);
1632 vbo->draw_prims(ctx, prim, 1,
1633 &ib, GL_TRUE, 0, ~0,
1634 NULL,
1635 ctx->DrawIndirectBuffer);
1636
1637 if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH)
1638 _mesa_flush(ctx);
1639 }
1640
1641 static void
1642 vbo_validated_multidrawelementsindirect(struct gl_context *ctx,
1643 GLenum mode, GLenum type,
1644 const GLvoid *indirect,
1645 GLsizei primcount, GLsizei stride)
1646 {
1647 struct vbo_context *vbo = vbo_context(ctx);
1648 struct vbo_exec_context *exec = &vbo->exec;
1649 struct _mesa_index_buffer ib;
1650 struct _mesa_prim *prim;
1651 GLsizei i;
1652 GLsizeiptr offset = (GLsizeiptr)indirect;
1653
1654 if (primcount == 0)
1655 return;
1656 prim = calloc(primcount, sizeof(*prim));
1657 if (prim == NULL) {
1658 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElementsIndirect");
1659 return;
1660 }
1661
1662 vbo_bind_arrays(ctx);
1663
1664 /* NOTE: IndexBufferObj is guaranteed to be a VBO. */
1665
1666 ib.count = 0; /* unknown */
1667 ib.type = type;
1668 ib.obj = ctx->Array.VAO->IndexBufferObj;
1669 ib.ptr = NULL;
1670
1671 prim[0].begin = 1;
1672 prim[primcount - 1].end = 1;
1673 for (i = 0; i < primcount; ++i, offset += stride) {
1674 prim[i].mode = mode;
1675 prim[i].indexed = 1;
1676 prim[i].indirect_offset = offset;
1677 prim[i].is_indirect = 1;
1678 }
1679
1680 check_buffers_are_unmapped(exec->array.inputs);
1681 vbo->draw_prims(ctx, prim, primcount,
1682 &ib, GL_TRUE, 0, ~0,
1683 NULL,
1684 ctx->DrawIndirectBuffer);
1685
1686 free(prim);
1687
1688 if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH)
1689 _mesa_flush(ctx);
1690 }
1691
1692 /**
1693 * Like [Multi]DrawArrays/Elements, but they take most arguments from
1694 * a buffer object.
1695 */
1696 static void GLAPIENTRY
1697 vbo_exec_DrawArraysIndirect(GLenum mode, const GLvoid *indirect)
1698 {
1699 GET_CURRENT_CONTEXT(ctx);
1700
1701 if (MESA_VERBOSE & VERBOSE_DRAW)
1702 _mesa_debug(ctx, "glDrawArraysIndirect(%s, %p)\n",
1703 _mesa_lookup_enum_by_nr(mode), indirect);
1704
1705 if (!_mesa_validate_DrawArraysIndirect(ctx, mode, indirect))
1706 return;
1707
1708 vbo_validated_drawarraysindirect(ctx, mode, indirect);
1709 }
1710
1711 static void GLAPIENTRY
1712 vbo_exec_DrawElementsIndirect(GLenum mode, GLenum type,
1713 const GLvoid *indirect)
1714 {
1715 GET_CURRENT_CONTEXT(ctx);
1716
1717 if (MESA_VERBOSE & VERBOSE_DRAW)
1718 _mesa_debug(ctx, "glDrawElementsIndirect(%s, %s, %p)\n",
1719 _mesa_lookup_enum_by_nr(mode),
1720 _mesa_lookup_enum_by_nr(type), indirect);
1721
1722 if (!_mesa_validate_DrawElementsIndirect(ctx, mode, type, indirect))
1723 return;
1724
1725 vbo_validated_drawelementsindirect(ctx, mode, type, indirect);
1726 }
1727
1728 static void GLAPIENTRY
1729 vbo_exec_MultiDrawArraysIndirect(GLenum mode,
1730 const GLvoid *indirect,
1731 GLsizei primcount, GLsizei stride)
1732 {
1733 GET_CURRENT_CONTEXT(ctx);
1734
1735 if (MESA_VERBOSE & VERBOSE_DRAW)
1736 _mesa_debug(ctx, "glMultiDrawArraysIndirect(%s, %p, %i, %i)\n",
1737 _mesa_lookup_enum_by_nr(mode), indirect, primcount, stride);
1738
1739 /* If <stride> is zero, the array elements are treated as tightly packed. */
1740 if (stride == 0)
1741 stride = 4 * sizeof(GLuint); /* sizeof(DrawArraysIndirectCommand) */
1742
1743 if (!_mesa_validate_MultiDrawArraysIndirect(ctx, mode,
1744 indirect,
1745 primcount, stride))
1746 return;
1747
1748 vbo_validated_multidrawarraysindirect(ctx, mode,
1749 indirect,
1750 primcount, stride);
1751 }
1752
1753 static void GLAPIENTRY
1754 vbo_exec_MultiDrawElementsIndirect(GLenum mode, GLenum type,
1755 const GLvoid *indirect,
1756 GLsizei primcount, GLsizei stride)
1757 {
1758 GET_CURRENT_CONTEXT(ctx);
1759
1760 if (MESA_VERBOSE & VERBOSE_DRAW)
1761 _mesa_debug(ctx, "glMultiDrawElementsIndirect(%s, %s, %p, %i, %i)\n",
1762 _mesa_lookup_enum_by_nr(mode),
1763 _mesa_lookup_enum_by_nr(type), indirect, primcount, stride);
1764
1765 /* If <stride> is zero, the array elements are treated as tightly packed. */
1766 if (stride == 0)
1767 stride = 5 * sizeof(GLuint); /* sizeof(DrawElementsIndirectCommand) */
1768
1769 if (!_mesa_validate_MultiDrawElementsIndirect(ctx, mode, type,
1770 indirect,
1771 primcount, stride))
1772 return;
1773
1774 vbo_validated_multidrawelementsindirect(ctx, mode, type,
1775 indirect,
1776 primcount, stride);
1777 }
1778
1779 /**
1780 * Initialize the dispatch table with the VBO functions for drawing.
1781 */
1782 void
1783 vbo_initialize_exec_dispatch(const struct gl_context *ctx,
1784 struct _glapi_table *exec)
1785 {
1786 SET_DrawArrays(exec, vbo_exec_DrawArrays);
1787 SET_DrawElements(exec, vbo_exec_DrawElements);
1788
1789 if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) {
1790 SET_DrawRangeElements(exec, vbo_exec_DrawRangeElements);
1791 }
1792
1793 SET_MultiDrawElementsEXT(exec, vbo_exec_MultiDrawElements);
1794
1795 if (ctx->API == API_OPENGL_COMPAT) {
1796 SET_Rectf(exec, vbo_exec_Rectf);
1797 SET_EvalMesh1(exec, vbo_exec_EvalMesh1);
1798 SET_EvalMesh2(exec, vbo_exec_EvalMesh2);
1799 }
1800
1801 if (_mesa_is_desktop_gl(ctx)) {
1802 SET_DrawElementsBaseVertex(exec, vbo_exec_DrawElementsBaseVertex);
1803 SET_DrawRangeElementsBaseVertex(exec, vbo_exec_DrawRangeElementsBaseVertex);
1804 SET_MultiDrawElementsBaseVertex(exec, vbo_exec_MultiDrawElementsBaseVertex);
1805 SET_DrawArraysInstancedBaseInstance(exec, vbo_exec_DrawArraysInstancedBaseInstance);
1806 SET_DrawElementsInstancedBaseInstance(exec, vbo_exec_DrawElementsInstancedBaseInstance);
1807 SET_DrawElementsInstancedBaseVertex(exec, vbo_exec_DrawElementsInstancedBaseVertex);
1808 SET_DrawElementsInstancedBaseVertexBaseInstance(exec, vbo_exec_DrawElementsInstancedBaseVertexBaseInstance);
1809 }
1810
1811 if (ctx->API == API_OPENGL_CORE) {
1812 SET_DrawArraysIndirect(exec, vbo_exec_DrawArraysIndirect);
1813 SET_DrawElementsIndirect(exec, vbo_exec_DrawElementsIndirect);
1814 SET_MultiDrawArraysIndirect(exec, vbo_exec_MultiDrawArraysIndirect);
1815 SET_MultiDrawElementsIndirect(exec, vbo_exec_MultiDrawElementsIndirect);
1816 }
1817
1818 if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) {
1819 SET_DrawArraysInstancedARB(exec, vbo_exec_DrawArraysInstanced);
1820 SET_DrawElementsInstancedARB(exec, vbo_exec_DrawElementsInstanced);
1821 }
1822
1823 if (_mesa_is_desktop_gl(ctx)) {
1824 SET_DrawTransformFeedback(exec, vbo_exec_DrawTransformFeedback);
1825 SET_DrawTransformFeedbackStream(exec, vbo_exec_DrawTransformFeedbackStream);
1826 SET_DrawTransformFeedbackInstanced(exec, vbo_exec_DrawTransformFeedbackInstanced);
1827 SET_DrawTransformFeedbackStreamInstanced(exec, vbo_exec_DrawTransformFeedbackStreamInstanced);
1828 }
1829 }
1830
1831
1832
1833 /**
1834 * The following functions are only used for OpenGL ES 1/2 support.
1835 * And some aren't even supported (yet) in ES 1/2.
1836 */
1837
1838
1839 void GLAPIENTRY
1840 _mesa_DrawArrays(GLenum mode, GLint first, GLsizei count)
1841 {
1842 vbo_exec_DrawArrays(mode, first, count);
1843 }
1844
1845 void GLAPIENTRY
1846 _mesa_DrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
1847 GLsizei primcount)
1848 {
1849 vbo_exec_DrawArraysInstanced(mode, first, count, primcount);
1850 }
1851
1852 void GLAPIENTRY
1853 _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type,
1854 const GLvoid *indices)
1855 {
1856 vbo_exec_DrawElements(mode, count, type, indices);
1857 }
1858
1859
1860 void GLAPIENTRY
1861 _mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
1862 const GLvoid *indices, GLint basevertex)
1863 {
1864 vbo_exec_DrawElementsBaseVertex(mode, count, type, indices, basevertex);
1865 }
1866
1867
1868 void GLAPIENTRY
1869 _mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
1870 GLenum type, const GLvoid *indices)
1871 {
1872 vbo_exec_DrawRangeElements(mode, start, end, count, type, indices);
1873 }
1874
1875
1876 void GLAPIENTRY
1877 _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
1878 GLsizei count, GLenum type,
1879 const GLvoid *indices, GLint basevertex)
1880 {
1881 vbo_exec_DrawRangeElementsBaseVertex(mode, start, end, count, type,
1882 indices, basevertex);
1883 }
1884
1885
1886 void GLAPIENTRY
1887 _mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type,
1888 const GLvoid **indices, GLsizei primcount)
1889 {
1890 vbo_exec_MultiDrawElements(mode, count, type, indices, primcount);
1891 }
1892
1893
1894 void GLAPIENTRY
1895 _mesa_MultiDrawElementsBaseVertex(GLenum mode,
1896 const GLsizei *count, GLenum type,
1897 const GLvoid **indices, GLsizei primcount,
1898 const GLint *basevertex)
1899 {
1900 vbo_exec_MultiDrawElementsBaseVertex(mode, count, type, indices,
1901 primcount, basevertex);
1902 }
1903
1904 void GLAPIENTRY
1905 _mesa_DrawTransformFeedback(GLenum mode, GLuint name)
1906 {
1907 vbo_exec_DrawTransformFeedback(mode, name);
1908 }