From: Józef Kucia Subject: [PATCH 3/5] wined3d: Allow draw calls without vertex declaration. Message-Id: <1464077871-16140-3-git-send-email-jkucia@codeweavers.com> Date: Tue, 24 May 2016 10:17:49 +0200 In-Reply-To: <1464077871-16140-1-git-send-email-jkucia@codeweavers.com> References: <1464077871-16140-1-git-send-email-jkucia@codeweavers.com> Signed-off-by: Józef Kucia --- 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 e741969..3bf2b5b 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -3020,12 +3020,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. */ @@ -3120,9 +3125,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; @@ -3177,17 +3182,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 { @@ -3195,15 +3204,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 5bac3d0..d161d15 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3484,12 +3484,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; @@ -3526,14 +3520,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 8c19aa8..31d5187 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3537,7 +3537,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) -- 2.7.3