Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 16 ++++++++++++---- dlls/wined3d/stateblock.c | 32 +++++++++++++++++++++++--------- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index e7ad5441eb..bf357cb001 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2199,21 +2199,29 @@ void CDECL wined3d_device_get_scissor_rects(const struct wined3d_device *device, void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device, struct wined3d_vertex_declaration *declaration) { - struct wined3d_vertex_declaration *prev = device->update_state->vertex_declaration; + struct wined3d_vertex_declaration *prev = device->state.vertex_declaration;
TRACE("device %p, declaration %p.\n", device, declaration);
+ if (declaration) + wined3d_vertex_declaration_incref(declaration); + if (device->update_stateblock_state->vertex_declaration) + wined3d_vertex_declaration_decref(device->update_stateblock_state->vertex_declaration); + device->update_stateblock_state->vertex_declaration = declaration; + if (device->recording) + { device->recording->changed.vertexDecl = TRUE; + return; + }
if (declaration == prev) return;
if (declaration) wined3d_vertex_declaration_incref(declaration); - device->update_state->vertex_declaration = declaration; - if (!device->recording) - wined3d_cs_emit_set_vertex_declaration(device->cs, declaration); + device->state.vertex_declaration = declaration; + wined3d_cs_emit_set_vertex_declaration(device->cs, declaration); if (prev) wined3d_vertex_declaration_decref(prev); } diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 4b76b38326..f0ad07e0a8 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -523,11 +523,18 @@ void state_unbind_resources(struct wined3d_state *state)
void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) { + struct wined3d_vertex_declaration *decl; struct wined3d_texture *texture; struct wined3d_buffer *buffer; struct wined3d_shader *shader; unsigned int i;
+ if ((decl = state->vertex_declaration)) + { + state->vertex_declaration = NULL; + wined3d_vertex_declaration_decref(decl); + } + if ((buffer = state->index_buffer)) { state->index_buffer = NULL; @@ -814,16 +821,16 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) stateblock->stateblock_state.index_format = state->index_format; }
- if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration != src_state->vertex_declaration) + if (stateblock->changed.vertexDecl && stateblock->stateblock_state.vertex_declaration != state->vertex_declaration) { TRACE("Updating vertex declaration from %p to %p.\n", - stateblock->state.vertex_declaration, src_state->vertex_declaration); + stateblock->stateblock_state.vertex_declaration, state->vertex_declaration);
- if (src_state->vertex_declaration) - wined3d_vertex_declaration_incref(src_state->vertex_declaration); - if (stateblock->state.vertex_declaration) - wined3d_vertex_declaration_decref(stateblock->state.vertex_declaration); - stateblock->state.vertex_declaration = src_state->vertex_declaration; + if (state->vertex_declaration) + wined3d_vertex_declaration_incref(state->vertex_declaration); + if (stateblock->stateblock_state.vertex_declaration) + wined3d_vertex_declaration_decref(stateblock->stateblock_state.vertex_declaration); + stateblock->stateblock_state.vertex_declaration = state->vertex_declaration; }
if (stateblock->changed.material @@ -1124,8 +1131,15 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) wined3d_device_set_base_vertex_index(device, stateblock->stateblock_state.base_vertex_index); }
- if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration) - wined3d_device_set_vertex_declaration(device, stateblock->state.vertex_declaration); + if (stateblock->changed.vertexDecl && stateblock->stateblock_state.vertex_declaration) + { + if (stateblock->stateblock_state.vertex_declaration) + wined3d_vertex_declaration_incref(stateblock->stateblock_state.vertex_declaration); + if (state->vertex_declaration) + wined3d_vertex_declaration_decref(state->vertex_declaration); + state->vertex_declaration = stateblock->stateblock_state.vertex_declaration; + wined3d_device_set_vertex_declaration(device, stateblock->stateblock_state.vertex_declaration); + }
if (stateblock->changed.material) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 87e0b23596..dc2896a614 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2967,6 +2967,7 @@ struct wined3d_dummy_textures
struct wined3d_stateblock_state { + struct wined3d_vertex_declaration *vertex_declaration; struct wined3d_buffer *index_buffer; enum wined3d_format_id index_format; int base_vertex_index;