Module: wine Branch: master Commit: b18d8ec04ae842c668f0f8c9bc35f3fa6575477e URL: http://source.winehq.org/git/wine.git/?a=commit;h=b18d8ec04ae842c668f0f8c9bc...
Author: Józef Kucia jkucia@codeweavers.com Date: Tue May 24 10:17:49 2016 +0200
wined3d: Allow draw calls without vertex declaration.
Signed-off-by: Józef Kucia jkucia@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wined3d/context.c | 34 +++++++++++++++++++--------------- dlls/wined3d/device.c | 14 +------------- dlls/wined3d/wined3d_private.h | 3 ++- 3 files changed, 22 insertions(+), 29 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index d5dfa61..f07b3ab 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -3013,12 +3013,17 @@ void context_stream_info_from_declaration(struct wined3d_context *context, { /* We need to deal with frequency data! */ struct wined3d_vertex_declaration *declaration = state->vertex_declaration; - BOOL use_vshader = use_vs(state); BOOL generic_attributes = context->d3d_info->ffp_generic_attributes; + BOOL use_vshader = use_vs(state); unsigned int i;
stream_info->use_map = 0; stream_info->swizzle_map = 0; + stream_info->position_transformed = 0; + + if (!declaration) + return; + stream_info->position_transformed = declaration->position_transformed;
/* Translate the declaration into strided data. */ @@ -3113,9 +3118,9 @@ void context_stream_info_from_declaration(struct wined3d_context *context, /* Context activation is done by the caller. */ static void context_update_stream_info(struct wined3d_context *context, const struct wined3d_state *state) { - const struct wined3d_gl_info *gl_info = context->gl_info; - const struct wined3d_d3d_info *d3d_info = context->d3d_info; struct wined3d_stream_info *stream_info = &context->stream_info; + const struct wined3d_d3d_info *d3d_info = context->d3d_info; + const struct wined3d_gl_info *gl_info = context->gl_info; DWORD prev_all_vbo = stream_info->all_vbo; unsigned int i; WORD map; @@ -3170,17 +3175,21 @@ static void context_update_stream_info(struct wined3d_context *context, const st TRACE("Load array %u {%#x:%p}.\n", i, element->data.buffer_object, element->data.addr); }
+ if (prev_all_vbo != stream_info->all_vbo) + context_invalidate_state(context, STATE_INDEXBUFFER); + + context->use_immediate_mode_draw = FALSE; + + if (stream_info->all_vbo) + return; + if (use_vs(state)) { - if (state->vertex_declaration->half_float_conv_needed && !stream_info->all_vbo) + if (state->vertex_declaration->half_float_conv_needed) { TRACE("Using immediate mode draw with vertex shaders for FLOAT16 conversion.\n"); context->use_immediate_mode_draw = TRUE; } - else - { - context->use_immediate_mode_draw = FALSE; - } } else { @@ -3188,15 +3197,10 @@ static void context_update_stream_info(struct wined3d_context *context, const st slow_mask |= -!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] & ((1u << WINED3D_FFP_DIFFUSE) | (1u << WINED3D_FFP_SPECULAR));
- if (((stream_info->position_transformed && !d3d_info->xyzrhw) - || (stream_info->use_map & slow_mask)) && !stream_info->all_vbo) + if ((stream_info->position_transformed && !d3d_info->xyzrhw) + || (stream_info->use_map & slow_mask)) context->use_immediate_mode_draw = TRUE; - else - context->use_immediate_mode_draw = FALSE; } - - if (prev_all_vbo != stream_info->all_vbo) - context_invalidate_state(context, STATE_INDEXBUFFER); }
/* Context activation is done by the caller. */ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 5171a8e..84834a4 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3482,12 +3482,6 @@ HRESULT CDECL wined3d_device_draw_primitive(struct wined3d_device *device, UINT { TRACE("device %p, start_vertex %u, vertex_count %u.\n", device, start_vertex, vertex_count);
- if (!device->state.vertex_declaration) - { - WARN("Called without a valid vertex declaration set.\n"); - return WINED3DERR_INVALIDCALL; - } - if (device->state.load_base_vertex_index) { device->state.load_base_vertex_index = 0; @@ -3524,14 +3518,8 @@ HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *devic return WINED3DERR_INVALIDCALL; }
- if (!device->state.vertex_declaration) - { - WARN("Called without a valid vertex declaration set.\n"); - return WINED3DERR_INVALIDCALL; - } - if (!gl_info->supported[ARB_DRAW_ELEMENTS_BASE_VERTEX] && - device->state.load_base_vertex_index != device->state.base_vertex_index) + device->state.load_base_vertex_index != device->state.base_vertex_index) { device->state.load_base_vertex_index = device->state.base_vertex_index; device_invalidate_state(device, STATE_BASEVERTEXINDEX); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f3ad8ef..b5a2732 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3544,7 +3544,8 @@ static inline BOOL use_vs(const struct wined3d_state *state) { /* Check state->vertex_declaration to allow this to be used before the * stream info is validated, for example in device_update_tex_unit_map(). */ - return state->shader[WINED3D_SHADER_TYPE_VERTEX] && !state->vertex_declaration->position_transformed; + return state->shader[WINED3D_SHADER_TYPE_VERTEX] + && (!state->vertex_declaration || !state->vertex_declaration->position_transformed); }
static inline BOOL use_ps(const struct wined3d_state *state)