=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: d3d9: 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: 70a95cea66384b475bd3584768b5fffc5f940a17
URL: https://source.winehq.org/git/wine.git/?a=commit;h=70a95cea66384b475bd3584768b5fffc5f940a17
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Tue Dec 25 13:24:34 2018 +0100
d3d9: Fix Reset() with system memory buffers.
Fixes a regression introduced by commit
b18a53a5b44b651cde8e05200c75eacf54f49926.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46362
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/d3d9/device.c | 15 +++++++++++++++
dlls/d3d9/tests/device.c | 16 ++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 17f6565..c1418e9 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -875,6 +875,8 @@ static UINT WINAPI d3d9_device_GetNumberOfSwapChains(IDirect3DDevice9Ex *iface)
static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
{
+ struct d3d9_vertexbuffer *vertex_buffer;
+ struct d3d9_indexbuffer *index_buffer;
struct wined3d_resource_desc desc;
IDirect3DBaseTexture9 *texture;
struct d3d9_surface *surface;
@@ -886,6 +888,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_INVALIDCALL;
}
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 6edf2b3..bc8d708 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -1827,6 +1827,8 @@ static void test_reset(void)
IDirect3DDevice9 *device2 = NULL;
IDirect3DSwapChain9 *swapchain;
struct device_desc device_desc;
+ IDirect3DVertexBuffer9 *vb;
+ IDirect3DIndexBuffer9 *ib;
DEVMODEW devmode;
IDirect3D9 *d3d;
D3DCAPS9 caps;
@@ -2198,6 +2200,20 @@ static void test_reset(void)
ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
IDirect3DSurface9_Release(surface);
+ hr = IDirect3DDevice9_CreateVertexBuffer(device1, 16, 0,
+ D3DFVF_XYZ, D3DPOOL_SYSTEMMEM, &vb, NULL);
+ ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_Reset(device1, &d3dpp);
+ ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
+ IDirect3DVertexBuffer9_Release(vb);
+
+ hr = IDirect3DDevice9_CreateIndexBuffer(device1, 16, 0,
+ D3DFMT_INDEX16, D3DPOOL_SYSTEMMEM, &ib, NULL);
+ ok(hr == D3D_OK, "Failed to create index buffer, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_Reset(device1, &d3dpp);
+ ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
+ IDirect3DIndexBuffer9_Release(ib);
+
/* The depth stencil should get reset to the auto depth stencil when present. */
hr = IDirect3DDevice9_SetDepthStencilSurface(device1, NULL);
ok(hr == D3D_OK, "SetDepthStencilSurface failed with 0x%08x\n", hr);
More information about the wine-cvs
mailing list