[PATCH 2/6] ddraw: Return D3DERR_INBEGINSTATEBLOCK when BeginStateBlock() is called while recording.

Zebediah Figura z.figura12 at gmail.com
Thu Apr 4 18:37:56 CDT 2019


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/ddraw/ddraw_private.h |  2 ++
 dlls/ddraw/device.c        | 10 +++++++++-
 dlls/ddraw/tests/ddraw7.c  |  2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index 2e58123463..19f21a8923 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -346,6 +346,8 @@ struct d3d_device
     D3DMATRIXHANDLE          world, proj, view;
 
     struct wined3d_vec4 user_clip_planes[D3DMAXUSERCLIPPLANES];
+
+    BOOL recording;
 };
 
 HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown *rt_iface,
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index adfbc4152b..4ab7621e1a 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -5644,7 +5644,14 @@ static HRESULT d3d_device7_BeginStateBlock(IDirect3DDevice7 *iface)
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_begin_stateblock(device->wined3d_device);
+    if (device->recording)
+    {
+        wined3d_mutex_unlock();
+        WARN("Trying to begin a stateblock while recording, returning D3DERR_INBEGINSTATEBLOCK.\n");
+        return D3DERR_INBEGINSTATEBLOCK;
+    }
+    if (SUCCEEDED(hr = wined3d_device_begin_stateblock(device->wined3d_device)))
+        device->recording = TRUE;
     wined3d_mutex_unlock();
 
     return hr_ddraw_from_wined3d(hr);
@@ -5705,6 +5712,7 @@ static HRESULT d3d_device7_EndStateBlock(IDirect3DDevice7 *iface, DWORD *statebl
         *stateblock = 0;
         return hr_ddraw_from_wined3d(hr);
     }
+    device->recording = FALSE;
 
     h = ddraw_allocate_handle(&device->handle_table, wined3d_sb, DDRAW_HANDLE_STATEBLOCK);
     if (h == DDRAW_INVALID_HANDLE)
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 168253e468..c0d2aad06d 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -15863,7 +15863,7 @@ static void test_begin_end_state_block(void)
     ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
 
     hr = IDirect3DDevice7_BeginStateBlock(device);
-    todo_wine ok(hr == D3DERR_INBEGINSTATEBLOCK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INBEGINSTATEBLOCK, "Got unexpected hr %#x.\n", hr);
 
     hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock);
     todo_wine ok(hr == D3DERR_INBEGINSTATEBLOCK, "Got unexpected hr %#x.\n", hr);
-- 
2.20.1




More information about the wine-devel mailing list