Zebediah Figura : d3d8: Use wined3d_stateblock_* methods directly in BeginStateBlock() and EndStateBlock().

Alexandre Julliard julliard at winehq.org
Tue Nov 26 16:21:24 CST 2019


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Tue Nov 26 09:57:37 2019 -0600

d3d8: Use wined3d_stateblock_* methods directly in BeginStateBlock() and EndStateBlock().

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/device.c       | 20 +++++++++++++-------
 dlls/d3d8/tests/device.c |  8 --------
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index e85fd72d02..564dc9d9d0 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -1902,7 +1902,14 @@ static HRESULT WINAPI d3d8_device_BeginStateBlock(IDirect3DDevice8 *iface)
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    if (SUCCEEDED(hr = wined3d_device_begin_stateblock(device->wined3d_device, &stateblock)))
+    if (device->recording)
+    {
+        wined3d_mutex_unlock();
+        WARN("Trying to begin a stateblock while recording, returning D3DERR_INBEGINSTATEBLOCK.\n");
+        return D3DERR_INVALIDCALL;
+    }
+
+    if (SUCCEEDED(hr = wined3d_stateblock_create(device->wined3d_device, WINED3D_SBT_RECORDED, &stateblock)))
         device->update_state = device->recording = stateblock;
     wined3d_mutex_unlock();
 
@@ -1913,7 +1920,6 @@ static HRESULT WINAPI d3d8_device_EndStateBlock(IDirect3DDevice8 *iface, DWORD *
 {
     struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
     struct wined3d_stateblock *stateblock;
-    HRESULT hr;
 
     TRACE("iface %p, token %p.\n", iface, token);
 
@@ -1921,14 +1927,14 @@ static HRESULT WINAPI d3d8_device_EndStateBlock(IDirect3DDevice8 *iface, DWORD *
      * of memory later and cause locking problems)
      */
     wined3d_mutex_lock();
-    hr = wined3d_device_end_stateblock(device->wined3d_device);
-    if (FAILED(hr))
+    if (!device->recording)
     {
-        WARN("Failed to end the state block, %#x.\n", hr);
         wined3d_mutex_unlock();
-        return hr;
+        WARN("Trying to end a stateblock, but no stateblock is being recorded.\n");
+        return D3DERR_INVALIDCALL;
     }
     stateblock = device->recording;
+    wined3d_stateblock_init_contained_states(stateblock);
     device->recording = NULL;
     device->update_state = device->state;
 
@@ -1947,7 +1953,7 @@ static HRESULT WINAPI d3d8_device_EndStateBlock(IDirect3DDevice8 *iface, DWORD *
 
     TRACE("Returning %#x (%p).\n", *token, stateblock);
 
-    return hr;
+    return D3D_OK;
 }
 
 static HRESULT WINAPI d3d8_device_ApplyStateBlock(IDirect3DDevice8 *iface, DWORD token)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 9fc06c3c9d..f598ad4f45 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -9665,20 +9665,12 @@ static void test_draw_primitive(void)
 
     hr = IDirect3DDevice8_GetStreamSource(device, 0, &current_vb, &stride);
     ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
-todo_wine {
     ok(!current_vb, "Unexpected vb %p.\n", current_vb);
     ok(!stride, "Unexpected stride %u.\n", stride);
-}
-    if (current_vb)
-        IDirect3DVertexBuffer8_Release(current_vb);
     hr = IDirect3DDevice8_GetIndices(device, &current_ib, &base_vertex_index);
     ok(SUCCEEDED(hr), "GetIndices failed, hr %#x.\n", hr);
-todo_wine {
     ok(!current_ib, "Unexpected index buffer %p.\n", current_ib);
     ok(!base_vertex_index, "Unexpected base vertex index %u.\n", base_vertex_index);
-}
-    if (current_ib)
-        IDirect3DIndexBuffer8_Release(current_ib);
 
     hr = IDirect3DDevice8_CaptureStateBlock(device, stateblock);
     ok(SUCCEEDED(hr), "Capture failed, hr %#x.\n", hr);




More information about the wine-cvs mailing list