=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: d3d8: Fix Reset() with system memory buffers.

Alexandre Julliard julliard at winehq.org
Thu Dec 27 16:01:03 CST 2018


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

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Tue Dec 25 13:24:35 2018 +0100

d3d8: Fix Reset() with system memory buffers.

Fixes a regression introduced by commit
75b7ff60562880b6e7b646a8fa84486670162d00.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3d8/device.c       | 15 +++++++++++++++
 dlls/d3d8/tests/device.c | 18 +++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 11ee0b2..b4d445d 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -826,6 +826,8 @@ static HRESULT WINAPI d3d8_device_CreateAdditionalSwapChain(IDirect3DDevice8 *if
 
 static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
 {
+    struct d3d8_vertexbuffer *vertex_buffer;
+    struct d3d8_indexbuffer *index_buffer;
     struct wined3d_resource_desc desc;
     IDirect3DBaseTexture8 *texture;
     struct d3d8_surface *surface;
@@ -837,6 +839,19 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
 
     if (desc.resource_type != WINED3D_RTYPE_TEXTURE_2D)
     {
+        if (desc.bind_flags & WINED3D_BIND_VERTEX_BUFFER)
+        {
+            vertex_buffer = wined3d_resource_get_parent(resource);
+            if (vertex_buffer && vertex_buffer->draw_buffer)
+                return D3D_OK;
+        }
+        if (desc.bind_flags & WINED3D_BIND_INDEX_BUFFER)
+        {
+            index_buffer = wined3d_resource_get_parent(resource);
+            if (index_buffer && index_buffer->draw_buffer)
+                return D3D_OK;
+        }
+
         WARN("Resource %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", resource);
         return D3DERR_DEVICELOST;
     }
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 49d2a98..adfeca8 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -1312,6 +1312,8 @@ static void test_reset(void)
     D3DPRESENT_PARAMETERS d3dpp;
     IDirect3DSurface8 *surface;
     IDirect3DTexture8 *texture;
+    IDirect3DVertexBuffer8 *vb;
+    IDirect3DIndexBuffer8 *ib;
     UINT adapter_mode_count;
     D3DLOCKED_RECT lockrect;
     UINT mode_count = 0;
@@ -1704,6 +1706,20 @@ static void test_reset(void)
     ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr);
     IDirect3DTexture8_Release(texture);
 
+    hr = IDirect3DDevice8_CreateVertexBuffer(device1, 16, 0,
+            D3DFVF_XYZ, D3DPOOL_SYSTEMMEM, &vb);
+    ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#x.\n", hr);
+    hr = IDirect3DDevice8_Reset(device1, &d3dpp);
+    ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
+    IDirect3DVertexBuffer8_Release(vb);
+
+    hr = IDirect3DDevice8_CreateIndexBuffer(device1, 16, 0,
+            D3DFMT_INDEX16, D3DPOOL_SYSTEMMEM, &ib);
+    ok(hr == D3D_OK, "Failed to create index buffer, hr %#x.\n", hr);
+    hr = IDirect3DDevice8_Reset(device1, &d3dpp);
+    ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
+    IDirect3DIndexBuffer8_Release(ib);
+
     /* The depth stencil should get reset to the auto depth stencil when present. */
     hr = IDirect3DDevice8_SetRenderTarget(device1, NULL, NULL);
     ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
@@ -2878,7 +2894,7 @@ static void test_wndproc(void)
             && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpect screen size %ux%u.\n",
             devmode.dmPelsWidth, devmode.dmPelsHeight);
 
-    /* I have to minimize and restore the focus window, otherwise native d3d9 fails
+    /* I have to minimize and restore the focus window, otherwise native d3d8 fails
      * device::reset with D3DERR_DEVICELOST. This does not happen when the window
      * restore is triggered by the user. */
     expect_messages = reactivate_messages;




More information about the wine-cvs mailing list