From deae0044f4d7e3432871d89cba259f4d942d17d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michael=20M=C3=BCller?= Date: Wed, 1 Nov 2017 22:08:45 +0100 Subject: [PATCH] wined3d: Add support for start instance in draw_primitive_arrays(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/directx.c | 5 +++++ dlls/wined3d/drawprim.c | 16 +++++++++++++++- dlls/wined3d/wined3d_gl.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index eae7505bf5c..ef3a7fd67a6 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -109,6 +109,7 @@ static const struct wined3d_extension_map gl_extension_map[] = {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422 }, /* ARB */ + {"GL_ARB_base_instance", ARB_BASE_INSTANCE }, {"GL_ARB_blend_func_extended", ARB_BLEND_FUNC_EXTENDED }, {"GL_ARB_clear_buffer_object", ARB_CLEAR_BUFFER_OBJECT }, {"GL_ARB_clear_texture", ARB_CLEAR_TEXTURE }, @@ -2686,6 +2687,9 @@ static void load_gl_funcs(struct wined3d_gl_info *gl_info) /* GL_APPLE_flush_buffer_range */ USE_GL_FUNC(glBufferParameteriAPPLE) USE_GL_FUNC(glFlushMappedBufferRangeAPPLE) + /* GL_ARB_base_instance */ + USE_GL_FUNC(glDrawArraysInstancedBaseInstance) + USE_GL_FUNC(glDrawElementsInstancedBaseVertexBaseInstance) /* GL_ARB_blend_func_extended */ USE_GL_FUNC(glBindFragDataLocationIndexed) USE_GL_FUNC(glGetFragDataIndex) @@ -3881,6 +3885,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, {ARB_ES2_COMPATIBILITY, MAKEDWORD_VERSION(4, 1)}, {ARB_VIEWPORT_ARRAY, MAKEDWORD_VERSION(4, 1)}, + {ARB_BASE_INSTANCE, MAKEDWORD_VERSION(4, 2)}, {ARB_CONSERVATIVE_DEPTH, MAKEDWORD_VERSION(4, 2)}, {ARB_INTERNALFORMAT_QUERY, MAKEDWORD_VERSION(4, 2)}, {ARB_MAP_BUFFER_ALIGNMENT, MAKEDWORD_VERSION(4, 2)}, diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 67fca6299f2..a7ca74897c7 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -69,18 +69,32 @@ static void draw_primitive_arrays(struct wined3d_context *context, const struct return; } - if (start_instance) + if (start_instance && !(gl_info->supported[ARB_BASE_INSTANCE] && gl_info->supported[ARB_INSTANCED_ARRAYS])) FIXME("Start instance (%u) not supported.\n", start_instance); if (gl_info->supported[ARB_INSTANCED_ARRAYS]) { if (!idx_size) { + if (gl_info->supported[ARB_BASE_INSTANCE]) + { + GL_EXTCALL(glDrawArraysInstancedBaseInstance(state->gl_primitive_type, start_idx, count, instance_count, start_instance)); + checkGLcall("glDrawArraysInstancedBaseInstance"); + return; + } + GL_EXTCALL(glDrawArraysInstanced(state->gl_primitive_type, start_idx, count, instance_count)); checkGLcall("glDrawArraysInstanced"); return; } + if (gl_info->supported[ARB_BASE_INSTANCE]) + { + GL_EXTCALL(glDrawElementsInstancedBaseVertexBaseInstance(state->gl_primitive_type, count, idx_type, + (const char *)idx_data + (idx_size * start_idx), instance_count, base_vertex_idx, start_instance)); + checkGLcall("glDrawElementsInstancedBaseVertexBaseInstance"); + return; + } if (gl_info->supported[ARB_DRAW_ELEMENTS_BASE_VERTEX]) { GL_EXTCALL(glDrawElementsInstancedBaseVertex(state->gl_primitive_type, count, idx_type, diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h index 47f3770cb80..f676b2f457e 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h @@ -42,6 +42,7 @@ enum wined3d_gl_extension APPLE_FLUSH_BUFFER_RANGE, APPLE_YCBCR_422, /* ARB */ + ARB_BASE_INSTANCE, ARB_BLEND_FUNC_EXTENDED, ARB_CLEAR_BUFFER_OBJECT, ARB_CLEAR_TEXTURE, -- 2.11.4.GIT