+ /* From the ARB_draw_indirect spec:
+ *
+ * "Initially zero is bound to DRAW_INDIRECT_BUFFER. In the
+ * compatibility profile, this indicates that DrawArraysIndirect and
+ * DrawElementsIndirect are to source their arguments directly from the
+ * pointer passed as their <indirect> parameters."
+ */
+ if (ctx->API == API_OPENGL_COMPAT &&
+ !_mesa_is_bufferobj(ctx->DrawIndirectBuffer)) {
+ /*
+ * Unlike regular DrawElementsInstancedBaseVertex commands, the indices
+ * may not come from a client array and must come from an index buffer.
+ * If no element array buffer is bound, an INVALID_OPERATION error is
+ * generated.
+ */
+ if (!_mesa_is_bufferobj(ctx->Array.VAO->IndexBufferObj)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawElementsIndirect(no buffer bound "
+ "to GL_ELEMENT_ARRAY_BUFFER)");
+ } else {
+ DrawElementsIndirectCommand *cmd =
+ (DrawElementsIndirectCommand *) indirect;
+
+ /* Convert offset to pointer */
+ void *offset = (void *)
+ ((cmd->firstIndex * _mesa_sizeof_type(type)) & 0xffffffffUL);
+
+ vbo_exec_DrawElementsInstancedBaseVertexBaseInstance(mode, cmd->count,
+ type, offset,
+ cmd->primCount,
+ cmd->baseVertex,
+ cmd->baseInstance);
+ }
+
+ return;
+ }
+
+ FLUSH_FOR_DRAW(ctx);
+
+ if (_mesa_is_no_error_enabled(ctx)) {
+ _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx));
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+ } else {
+ _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx));
+
+ if (!_mesa_validate_DrawElementsIndirect(ctx, mode, type, indirect))
+ return;
+ }
+
+ if (skip_validated_draw(ctx))