Commit 1835e2f5 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Add support for ARB_instanced_arrays.

parent 52c6abb4
......@@ -105,6 +105,7 @@ static const struct wined3d_extension_map gl_extension_map[] =
{"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4 },
{"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL },
{"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX },
{"GL_ARB_instanced_arrays", ARB_INSTANCED_ARRAYS, },
{"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT },
{"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE },
{"GL_ARB_multisample", ARB_MULTISAMPLE }, /* needs GLX_ARB_MULTISAMPLE as well */
......
......@@ -676,6 +676,9 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co
struct wined3d_stream_info stridedlcl;
UINT idx_size = 0;
if (device->instance_count)
instance_count = device->instance_count;
if (indexed)
{
if (!state->user_stream)
......@@ -753,11 +756,11 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co
glPrimType, idx_data, idx_size, start_idx);
}
}
else if (device->instance_count)
else if (!gl_info->supported[ARB_INSTANCED_ARRAYS] && instance_count)
{
/* Instancing emulation with mixing immediate mode and arrays */
drawStridedInstanced(gl_info, state, stream_info, index_count, glPrimType,
idx_data, idx_size, start_idx, base_vertex_index, device->instance_count);
idx_data, idx_size, start_idx, base_vertex_index, instance_count);
}
else
{
......
......@@ -4101,6 +4101,8 @@ static inline void unload_numbered_array(struct wined3d_context *context, int i)
GL_EXTCALL(glDisableVertexAttribArrayARB(i));
checkGLcall("glDisableVertexAttribArrayARB(reg)");
if (gl_info->supported[ARB_INSTANCED_ARRAYS])
GL_EXTCALL(glVertexAttribDivisorARB(i, 0));
context->numbered_array_mask &= ~(1 << i);
}
......@@ -4143,13 +4145,25 @@ static void load_numbered_arrays(struct wined3d_context *context,
stream = &state->streams[stream_info->elements[i].stream_idx];
/* Do not load instance data. It will be specified using glTexCoord by drawprim */
if (stream->flags & WINED3DSTREAMSOURCE_INSTANCEDATA)
{
if (!device->instance_count)
device->instance_count = state->streams[0].frequency ? state->streams[0].frequency : 1;
if (context->numbered_array_mask & (1 << i)) unload_numbered_array(context, i);
continue;
if (!gl_info->supported[ARB_INSTANCED_ARRAYS])
{
/* Unload instanced arrays, they will be loaded using
* immediate mode instead. */
if (context->numbered_array_mask & (1 << i))
unload_numbered_array(context, i);
continue;
}
GL_EXTCALL(glVertexAttribDivisorARB(i, 1));
}
else if (gl_info->supported[ARB_INSTANCED_ARRAYS])
{
GL_EXTCALL(glVertexAttribDivisorARB(i, 0));
}
TRACE_(d3d_shader)("Loading array %u [VBO=%u]\n", i, stream_info->elements[i].data.buffer_object);
......
......@@ -57,6 +57,7 @@ enum wined3d_gl_extension
ARB_GEOMETRY_SHADER4,
ARB_HALF_FLOAT_PIXEL,
ARB_HALF_FLOAT_VERTEX,
ARB_INSTANCED_ARRAYS,
ARB_MAP_BUFFER_ALIGNMENT,
ARB_MAP_BUFFER_RANGE,
ARB_MULTISAMPLE,
......@@ -214,6 +215,8 @@ enum wined3d_gl_extension
USE_GL_FUNC(glFramebufferTextureFaceARB) \
USE_GL_FUNC(glFramebufferTextureLayerARB) \
USE_GL_FUNC(glProgramParameteriARB) \
/* GL_ARB_instanced_arrays */ \
USE_GL_FUNC(glVertexAttribDivisorARB) \
/* GL_ARB_map_buffer_range */ \
USE_GL_FUNC(glFlushMappedBufferRange) \
USE_GL_FUNC(glMapBufferRange) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment