Henri Verbeet : wined3d: Introduce wined3d_state_reset().

Alexandre Julliard julliard at winehq.org
Mon Mar 15 16:59:13 CDT 2021


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Mon Mar 15 16:11:35 2021 +0100

wined3d: Introduce wined3d_state_reset().

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/cs.c              |  5 +----
 dlls/wined3d/device.c          |  6 ++----
 dlls/wined3d/wined3d_private.h | 16 ++++++++++++----
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 6bb628b5d13..0d28cb7e0b1 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -2079,11 +2079,8 @@ static void wined3d_cs_mt_push_constants(struct wined3d_device_context *context,
 
 static void wined3d_cs_exec_reset_state(struct wined3d_cs *cs, const void *data)
 {
-    struct wined3d_adapter *adapter = cs->c.device->adapter;
-
     state_cleanup(&cs->state);
-    memset(&cs->state, 0, sizeof(cs->state));
-    state_init(&cs->state, &adapter->d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT);
+    wined3d_state_reset(&cs->state, &cs->c.device->adapter->d3d_info);
 }
 
 void wined3d_cs_emit_reset_state(struct wined3d_cs *cs)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 289c5d941d6..4fb6063741a 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1251,8 +1251,7 @@ void wined3d_device_uninit_3d(struct wined3d_device *device)
     heap_free(device->swapchains);
     device->swapchains = NULL;
 
-    memset(state, 0, sizeof(*state));
-    state_init(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
+    wined3d_state_reset(state, &device->adapter->d3d_info);
 }
 
 /* Enables thread safety in the wined3d device and its resources. Called by DirectDraw
@@ -5754,8 +5753,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
 
         device->adapter->adapter_ops->adapter_uninit_3d(device);
 
-        memset(state, 0, sizeof(*state));
-        state_init(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
+        wined3d_state_reset(state, &device->adapter->d3d_info);
 
         device_init_swapchain_state(device, swapchain);
         if (wined3d_settings.logo)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 86d8061d005..06c7d74d199 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3710,6 +3710,18 @@ struct wined3d_state
     struct wined3d_rasterizer_state *rasterizer_state;
 };
 
+void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
+void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, uint32_t flags) DECLSPEC_HIDDEN;
+void state_unbind_resources(struct wined3d_state *state) DECLSPEC_HIDDEN;
+
+static inline void wined3d_state_reset(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info)
+{
+    uint32_t flags = state->flags;
+
+    memset(state, 0, sizeof(*state));
+    state_init(state, d3d_info, flags);
+}
+
 static inline bool wined3d_state_uses_depth_buffer(const struct wined3d_state *state)
 {
     if (!state->depth_stencil_state)
@@ -4639,10 +4651,6 @@ struct wined3d_light_info *wined3d_light_state_get_light(const struct wined3d_li
 HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD light_idx,
         const struct wined3d_light *params, struct wined3d_light_info **light_info) DECLSPEC_HIDDEN;
 
-void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
-void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) DECLSPEC_HIDDEN;
-void state_unbind_resources(struct wined3d_state *state) DECLSPEC_HIDDEN;
-
 enum wined3d_cs_queue_id
 {
     WINED3D_CS_QUEUE_DEFAULT = 0,




More information about the wine-cvs mailing list