vrend: take start_instance in instanced drawing into account

Note that it is also possible to draw just one instance with
start_intance larger than zero, and one must call

   glDrawElementsInstancedBaseVertexBaseInstance
or
   glDrawArraysInstancedBaseInstance

in this case.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: John Bates <jbates@chromium.org>
macos/master
Gert Wollny 3 years ago
parent fe82483966
commit 30026fd745
  1. 23
      src/vrend_renderer.c

@ -5008,12 +5008,13 @@ int vrend_draw_vbo(struct vrend_context *ctx,
glMultiDrawArraysIndirect(mode, (GLvoid const *)(unsigned long)info->indirect.offset, info->indirect.draw_count, info->indirect.stride); glMultiDrawArraysIndirect(mode, (GLvoid const *)(unsigned long)info->indirect.offset, info->indirect.draw_count, info->indirect.stride);
else else
glDrawArraysIndirect(mode, (GLvoid const *)(unsigned long)info->indirect.offset); glDrawArraysIndirect(mode, (GLvoid const *)(unsigned long)info->indirect.offset);
} else if (info->instance_count <= 1) } else if (info->instance_count > 0) {
if (info->start_instance > 0)
glDrawArraysInstancedBaseInstance(mode, start, count, info->instance_count, info->start_instance);
else
glDrawArraysInstancedARB(mode, start, count, info->instance_count);
} else
glDrawArrays(mode, start, count); glDrawArrays(mode, start, count);
else if (info->start_instance)
glDrawArraysInstancedBaseInstance(mode, start, count, info->instance_count, info->start_instance);
else
glDrawArraysInstancedARB(mode, start, count, info->instance_count);
} else { } else {
GLenum elsz; GLenum elsz;
GLenum mode = info->mode; GLenum mode = info->mode;
@ -5039,9 +5040,15 @@ int vrend_draw_vbo(struct vrend_context *ctx,
else else
glDrawElementsIndirect(mode, elsz, (GLvoid const *)(unsigned long)info->indirect.offset); glDrawElementsIndirect(mode, elsz, (GLvoid const *)(unsigned long)info->indirect.offset);
} else if (info->index_bias) { } else if (info->index_bias) {
if (info->instance_count > 1) if (info->instance_count > 0) {
glDrawElementsInstancedBaseVertex(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info->instance_count, info->index_bias); if (info->start_instance > 0)
else if (info->min_index != 0 || info->max_index != (unsigned)-1) glDrawElementsInstancedBaseVertexBaseInstance(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset,
info->instance_count, info->index_bias, info->start_instance);
else
glDrawElementsInstancedBaseVertex(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info->instance_count, info->index_bias);
} else if (info->min_index != 0 || info->max_index != (unsigned)-1)
glDrawRangeElementsBaseVertex(mode, info->min_index, info->max_index, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info->index_bias); glDrawRangeElementsBaseVertex(mode, info->min_index, info->max_index, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info->index_bias);
else else
glDrawElementsBaseVertex(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info->index_bias); glDrawElementsBaseVertex(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info->index_bias);

Loading…
Cancel
Save