[PATCH 4/6] wined3d: Pass the client stateblock state to wined3d stateblock methods.

Zebediah Figura z.figura12 at gmail.com
Tue Nov 26 22:58:26 CST 2019


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/d3d8/device.c        | 10 +++++-----
 dlls/d3d9/device.c        |  4 ++--
 dlls/d3d9/stateblock.c    |  6 +++---
 dlls/ddraw/ddraw.c        |  7 ++++---
 dlls/ddraw/device.c       |  8 ++++----
 dlls/wined3d/stateblock.c | 32 +++++++++++++++++---------------
 dlls/wined3d/wined3d.spec |  6 +++---
 include/wine/wined3d.h    |  8 +++++---
 8 files changed, 43 insertions(+), 38 deletions(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 9dd3ef016f7..89cdb4e14b0 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -1909,7 +1909,7 @@ static HRESULT WINAPI d3d8_device_BeginStateBlock(IDirect3DDevice8 *iface)
         return D3DERR_INVALIDCALL;
     }
 
-    if (SUCCEEDED(hr = wined3d_stateblock_create(device->wined3d_device, WINED3D_SBT_RECORDED, &stateblock)))
+    if (SUCCEEDED(hr = wined3d_stateblock_create(device->wined3d_device, NULL, WINED3D_SBT_RECORDED, &stateblock)))
         device->update_state = device->recording = stateblock;
     wined3d_mutex_unlock();
 
@@ -1985,7 +1985,7 @@ static HRESULT WINAPI d3d8_device_ApplyStateBlock(IDirect3DDevice8 *iface, DWORD
         wined3d_mutex_unlock();
         return D3DERR_INVALIDCALL;
     }
-    wined3d_stateblock_apply(stateblock);
+    wined3d_stateblock_apply(stateblock, device->state);
     device->sysmem_vb = 0;
     for (i = 0; i < D3D8_MAX_STREAMS; ++i)
     {
@@ -2025,7 +2025,7 @@ static HRESULT WINAPI d3d8_device_CaptureStateBlock(IDirect3DDevice8 *iface, DWO
         wined3d_mutex_unlock();
         return D3DERR_INVALIDCALL;
     }
-    wined3d_stateblock_capture(stateblock);
+    wined3d_stateblock_capture(stateblock, device->state);
     wined3d_mutex_unlock();
 
     return D3D_OK;
@@ -2081,7 +2081,7 @@ static HRESULT WINAPI d3d8_device_CreateStateBlock(IDirect3DDevice8 *iface,
         WARN("Trying to create a stateblock while recording, returning D3DERR_INVALIDCALL.\n");
         return D3DERR_INVALIDCALL;
     }
-    hr = wined3d_stateblock_create(device->wined3d_device, (enum wined3d_stateblock_type)type, &stateblock);
+    hr = wined3d_stateblock_create(device->wined3d_device, device->state, (enum wined3d_stateblock_type)type, &stateblock);
     if (FAILED(hr))
     {
         wined3d_mutex_unlock();
@@ -3685,7 +3685,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
         return hr;
     }
 
-    if (FAILED(hr = wined3d_stateblock_create(device->wined3d_device, WINED3D_SBT_PRIMARY, &device->state)))
+    if (FAILED(hr = wined3d_stateblock_create(device->wined3d_device, NULL, WINED3D_SBT_PRIMARY, &device->state)))
     {
         ERR("Failed to create primary stateblock, hr %#x.\n", hr);
         wined3d_device_decref(device->wined3d_device);
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 58bdd7458c2..2d66c569938 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2407,7 +2407,7 @@ static HRESULT WINAPI d3d9_device_BeginStateBlock(IDirect3DDevice9Ex *iface)
         return D3DERR_INVALIDCALL;
     }
 
-    if (SUCCEEDED(hr = wined3d_stateblock_create(device->wined3d_device, WINED3D_SBT_RECORDED, &stateblock)))
+    if (SUCCEEDED(hr = wined3d_stateblock_create(device->wined3d_device, device->state, WINED3D_SBT_RECORDED, &stateblock)))
         device->update_state = device->recording = stateblock;
     wined3d_mutex_unlock();
 
@@ -4593,7 +4593,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
     if (flags & D3DCREATE_ADAPTERGROUP_DEVICE)
         count = caps.NumberOfAdaptersInGroup;
 
-    if (FAILED(hr = wined3d_stateblock_create(device->wined3d_device, WINED3D_SBT_PRIMARY, &device->state)))
+    if (FAILED(hr = wined3d_stateblock_create(device->wined3d_device, NULL, WINED3D_SBT_PRIMARY, &device->state)))
     {
         ERR("Failed to create the primary stateblock, hr %#x.\n", hr);
         wined3d_device_decref(device->wined3d_device);
diff --git a/dlls/d3d9/stateblock.c b/dlls/d3d9/stateblock.c
index 02213280181..dfb8d8d7551 100644
--- a/dlls/d3d9/stateblock.c
+++ b/dlls/d3d9/stateblock.c
@@ -106,7 +106,7 @@ static HRESULT WINAPI d3d9_stateblock_Capture(IDirect3DStateBlock9 *iface)
         WARN("Trying to capture stateblock while recording, returning D3DERR_INVALIDCALL.\n");
         return D3DERR_INVALIDCALL;
     }
-    wined3d_stateblock_capture(stateblock->wined3d_stateblock);
+    wined3d_stateblock_capture(stateblock->wined3d_stateblock, device->state);
     wined3d_mutex_unlock();
 
     return D3D_OK;
@@ -134,7 +134,7 @@ static HRESULT WINAPI d3d9_stateblock_Apply(IDirect3DStateBlock9 *iface)
         WARN("Trying to apply stateblock while recording, returning D3DERR_INVALIDCALL.\n");
         return D3DERR_INVALIDCALL;
     }
-    wined3d_stateblock_apply(stateblock->wined3d_stateblock);
+    wined3d_stateblock_apply(stateblock->wined3d_stateblock, device->state);
     device->sysmem_vb = 0;
     for (i = 0; i < D3D9_MAX_STREAMS; ++i)
     {
@@ -193,7 +193,7 @@ HRESULT stateblock_init(struct d3d9_stateblock *stateblock, struct d3d9_device *
     else
     {
         wined3d_mutex_lock();
-        hr = wined3d_stateblock_create(device->wined3d_device,
+        hr = wined3d_stateblock_create(device->wined3d_device, device->state,
                 (enum wined3d_stateblock_type)type, &stateblock->wined3d_stateblock);
         wined3d_mutex_unlock();
         if (FAILED(hr))
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 69ef612cd4a..d744df8c918 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -900,7 +900,8 @@ static HRESULT ddraw_set_cooperative_level(struct ddraw *ddraw, HWND window,
         {
             restore_state = TRUE;
 
-            if (FAILED(hr = wined3d_stateblock_create(ddraw->wined3d_device, WINED3D_SBT_ALL, &stateblock)))
+            if (FAILED(hr = wined3d_stateblock_create(ddraw->wined3d_device,
+                    ddraw->state, WINED3D_SBT_ALL, &stateblock)))
             {
                 ERR("Failed to create stateblock, hr %#x.\n", hr);
                 goto done;
@@ -937,7 +938,7 @@ static HRESULT ddraw_set_cooperative_level(struct ddraw *ddraw, HWND window,
             wined3d_rendertarget_view_decref(rtv);
         }
 
-        wined3d_stateblock_apply(stateblock);
+        wined3d_stateblock_apply(stateblock, ddraw->state);
         wined3d_stateblock_decref(stateblock);
     }
 
@@ -5026,7 +5027,7 @@ HRESULT ddraw_init(struct ddraw *ddraw, DWORD flags, enum wined3d_device_type de
 
     list_init(&ddraw->surface_list);
 
-    if (FAILED(hr = wined3d_stateblock_create(ddraw->wined3d_device, WINED3D_SBT_PRIMARY, &ddraw->state)))
+    if (FAILED(hr = wined3d_stateblock_create(ddraw->wined3d_device, NULL, WINED3D_SBT_PRIMARY, &ddraw->state)))
     {
         ERR("Failed to create the primary stateblock, hr %#x.\n", hr);
         wined3d_device_decref(ddraw->wined3d_device);
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index faeb7ba1ff8..51576c81e28 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -5642,7 +5642,7 @@ static HRESULT d3d_device7_BeginStateBlock(IDirect3DDevice7 *iface)
         WARN("Trying to begin a stateblock while recording, returning D3DERR_INBEGINSTATEBLOCK.\n");
         return D3DERR_INBEGINSTATEBLOCK;
     }
-    if (SUCCEEDED(hr = wined3d_stateblock_create(device->wined3d_device, WINED3D_SBT_RECORDED, &stateblock)))
+    if (SUCCEEDED(hr = wined3d_stateblock_create(device->wined3d_device, NULL, WINED3D_SBT_RECORDED, &stateblock)))
         device->update_state = device->recording = stateblock;
     wined3d_mutex_unlock();
 
@@ -5822,7 +5822,7 @@ static HRESULT d3d_device7_ApplyStateBlock(IDirect3DDevice7 *iface, DWORD stateb
         return D3DERR_INVALIDSTATEBLOCK;
     }
 
-    wined3d_stateblock_apply(wined3d_sb);
+    wined3d_stateblock_apply(wined3d_sb, device->state);
     wined3d_mutex_unlock();
 
     return D3D_OK;
@@ -5882,7 +5882,7 @@ static HRESULT d3d_device7_CaptureStateBlock(IDirect3DDevice7 *iface, DWORD stat
         return D3DERR_INVALIDSTATEBLOCK;
     }
 
-    wined3d_stateblock_capture(wined3d_sb);
+    wined3d_stateblock_capture(wined3d_sb, device->state);
     wined3d_mutex_unlock();
 
     return D3D_OK;
@@ -6012,7 +6012,7 @@ static HRESULT d3d_device7_CreateStateBlock(IDirect3DDevice7 *iface,
     }
 
     /* The D3DSTATEBLOCKTYPE enum is fine here. */
-    hr = wined3d_stateblock_create(device->wined3d_device, type, &wined3d_sb);
+    hr = wined3d_stateblock_create(device->wined3d_device, device->state, type, &wined3d_sb);
     if (FAILED(hr))
     {
         WARN("Failed to create stateblock, hr %#x.\n", hr);
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index dc714914ec3..1c3704c10a5 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -395,7 +395,7 @@ void CDECL wined3d_stateblock_init_contained_states(struct wined3d_stateblock *s
     }
 }
 
-static void stateblock_init_lights(struct list *dst_map, struct list *src_map)
+static void stateblock_init_lights(struct list *dst_map, const struct list *src_map)
 {
     unsigned int i;
 
@@ -757,13 +757,14 @@ static void wined3d_state_record_lights(struct wined3d_light_state *dst_state,
     }
 }
 
-void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
+void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock,
+        const struct wined3d_stateblock *device_state)
 {
-    const struct wined3d_stateblock_state *state = &stateblock->device->stateblock_state;
+    const struct wined3d_stateblock_state *state = &device_state->stateblock_state;
     unsigned int i;
     DWORD map;
 
-    TRACE("stateblock %p.\n", stateblock);
+    TRACE("stateblock %p, device_state %p.\n", stateblock, device_state);
 
     if (stateblock->changed.vertexShader && stateblock->stateblock_state.vs != state->vs)
     {
@@ -1029,14 +1030,15 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
     TRACE("Capture done.\n");
 }
 
-void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
+void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
+        struct wined3d_stateblock *device_state)
 {
-    struct wined3d_stateblock_state *state = &stateblock->device->stateblock_state;
+    struct wined3d_stateblock_state *state = &device_state->stateblock_state;
     struct wined3d_device *device = stateblock->device;
     unsigned int i;
     DWORD map;
 
-    TRACE("Applying stateblock %p to device %p.\n", stateblock, device);
+    TRACE("stateblock %p, device_state %p.\n", stateblock, device_state);
 
     if (stateblock->changed.vertexShader)
     {
@@ -1989,7 +1991,7 @@ void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state,
 
 }
 
-static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
+static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, const struct wined3d_stateblock *device_state,
         struct wined3d_device *device, enum wined3d_stateblock_type type)
 {
     const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
@@ -2010,7 +2012,7 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
     {
         case WINED3D_SBT_ALL:
             stateblock_init_lights(stateblock->stateblock_state.light_state.light_map,
-                    device->stateblock_state.light_state.light_map);
+                    device_state->stateblock_state.light_state.light_map);
             stateblock_savedstates_set_all(&stateblock->changed,
                     d3d_info->limits.vs_uniform_count, d3d_info->limits.ps_uniform_count);
             break;
@@ -2022,7 +2024,7 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
 
         case WINED3D_SBT_VERTEX_STATE:
             stateblock_init_lights(stateblock->stateblock_state.light_state.light_map,
-                    device->stateblock_state.light_state.light_map);
+                    device_state->stateblock_state.light_state.light_map);
             stateblock_savedstates_set_vertex(&stateblock->changed,
                     d3d_info->limits.vs_uniform_count);
             break;
@@ -2033,7 +2035,7 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
     }
 
     wined3d_stateblock_init_contained_states(stateblock);
-    wined3d_stateblock_capture(stateblock);
+    wined3d_stateblock_capture(stateblock, device_state);
 
     /* According to the tests, stream offset is not updated in the captured state if
      * the state was captured on state block creation. This is not the case for
@@ -2044,19 +2046,19 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
     return WINED3D_OK;
 }
 
-HRESULT CDECL wined3d_stateblock_create(struct wined3d_device *device,
+HRESULT CDECL wined3d_stateblock_create(struct wined3d_device *device, const struct wined3d_stateblock *device_state,
         enum wined3d_stateblock_type type, struct wined3d_stateblock **stateblock)
 {
     struct wined3d_stateblock *object;
     HRESULT hr;
 
-    TRACE("device %p, type %#x, stateblock %p.\n",
-            device, type, stateblock);
+    TRACE("device %p, device_state %p, type %#x, stateblock %p.\n",
+            device, device_state, type, stateblock);
 
     if (!(object = heap_alloc_zero(sizeof(*object))))
         return E_OUTOFMEMORY;
 
-    hr = stateblock_init(object, device, type);
+    hr = stateblock_init(object, device_state, device, type);
     if (FAILED(hr))
     {
         WARN("Failed to initialize stateblock, hr %#x.\n", hr);
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 9c05dd8e938..fed5ce1b128 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -255,9 +255,9 @@
 @ cdecl wined3d_shader_resource_view_get_parent(ptr)
 @ cdecl wined3d_shader_resource_view_incref(ptr)
 
-@ cdecl wined3d_stateblock_apply(ptr)
-@ cdecl wined3d_stateblock_capture(ptr)
-@ cdecl wined3d_stateblock_create(ptr long ptr)
+@ cdecl wined3d_stateblock_apply(ptr ptr)
+@ cdecl wined3d_stateblock_capture(ptr ptr)
+@ cdecl wined3d_stateblock_create(ptr ptr long ptr)
 @ cdecl wined3d_stateblock_decref(ptr)
 @ cdecl wined3d_stateblock_incref(ptr)
 @ cdecl wined3d_stateblock_init_contained_states(ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index f455cdb979c..eba14e9a022 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2659,9 +2659,11 @@ void __cdecl wined3d_shader_resource_view_generate_mipmaps(struct wined3d_shader
 void * __cdecl wined3d_shader_resource_view_get_parent(const struct wined3d_shader_resource_view *view);
 ULONG __cdecl wined3d_shader_resource_view_incref(struct wined3d_shader_resource_view *view);
 
-void __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock);
-void __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock);
-HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device,
+void __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
+        struct wined3d_stateblock *device_state);
+void __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock,
+        const struct wined3d_stateblock *device_state);
+HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device, const struct wined3d_stateblock *device_state,
         enum wined3d_stateblock_type type, struct wined3d_stateblock **stateblock);
 ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
 ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
-- 
2.23.0




More information about the wine-devel mailing list