Zebediah Figura : wined3d: Store vertex declaration in the wined3d_stateblock_state structure.

Alexandre Julliard julliard at winehq.org
Thu Feb 7 16:20:56 CST 2019


Module: wine
Branch: master
Commit: 61cc88675fea2ad616c781883349b20651dce196
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=61cc88675fea2ad616c781883349b20651dce196

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Feb  6 19:38:26 2019 -0600

wined3d: Store vertex declaration in the wined3d_stateblock_state structure.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 3100991..c1d86ab 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 fe2ff29..ebff906 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 f1b2b7a..11a0f69 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2970,6 +2970,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;




More information about the wine-cvs mailing list