Zebediah Figura : d3d8: Track the primary stateblock state locally.

Alexandre Julliard julliard at winehq.org
Thu Sep 26 15:51:19 CDT 2019


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Sep 25 23:05:41 2019 -0500

d3d8: Track the primary stateblock state locally.

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/d3d8/d3d8_private.h |  2 +-
 dlls/d3d8/device.c       | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index 0d4d4faf89..f262d12fc7 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -132,7 +132,7 @@ struct d3d8_device
      * no GetSwapchain, GetBackBuffer doesn't accept a swapchain number). */
     struct wined3d_swapchain *implicit_swapchain;
 
-    struct wined3d_stateblock *recording;
+    struct wined3d_stateblock *recording, *state, *update_state;
 };
 
 HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wined3d *wined3d, UINT adapter,
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 741218c951..aac6c9e2f6 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -595,6 +595,7 @@ static ULONG WINAPI d3d8_device_Release(IDirect3DDevice8 *iface)
 
         if (device->recording)
             wined3d_stateblock_decref(device->recording);
+        wined3d_stateblock_decref(device->state);
 
         wined3d_swapchain_decref(device->implicit_swapchain);
         wined3d_device_release_focus_window(device->wined3d_device);
@@ -914,6 +915,7 @@ static HRESULT WINAPI d3d8_device_Reset(IDirect3DDevice8 *iface,
         if (device->recording)
             wined3d_stateblock_decref(device->recording);
         device->recording = NULL;
+        device->update_state = device->state;
         present_parameters->BackBufferCount = swapchain_desc.backbuffer_count;
         implicit_swapchain = wined3d_swapchain_get_parent(device->implicit_swapchain);
         implicit_swapchain->swap_interval
@@ -1871,7 +1873,7 @@ static HRESULT WINAPI d3d8_device_BeginStateBlock(IDirect3DDevice8 *iface)
 
     wined3d_mutex_lock();
     if (SUCCEEDED(hr = wined3d_device_begin_stateblock(device->wined3d_device, &stateblock)))
-        device->recording = stateblock;
+        device->update_state = device->recording = stateblock;
     wined3d_mutex_unlock();
 
     return hr;
@@ -1898,6 +1900,7 @@ static HRESULT WINAPI d3d8_device_EndStateBlock(IDirect3DDevice8 *iface, DWORD *
     }
     stateblock = device->recording;
     device->recording = NULL;
+    device->update_state = device->state;
 
     *token = d3d8_allocate_handle(&device->handle_table, stateblock, D3D8_HANDLE_SB);
     wined3d_mutex_unlock();
@@ -3607,6 +3610,15 @@ 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)))
+    {
+        ERR("Failed to create primary stateblock, hr %#x.\n", hr);
+        wined3d_device_decref(device->wined3d_device);
+        wined3d_mutex_unlock();
+        return hr;
+    }
+    device->update_state = device->state;
+
     if (!parameters->Windowed)
     {
         if (!focus_window)




More information about the wine-cvs mailing list