From 6664601b83753ab18080b0d0001636d3b70b6cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Fri, 13 Jan 2017 12:53:47 +0100 Subject: [PATCH] d3d9: Return D3D_OK from UnlockRect() for not locked textures. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d9/surface.c | 11 ++++++++--- dlls/d3d9/tests/device.c | 3 +-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c index 2f8d44759ac..07eaf7b7daf 100644 --- a/dlls/d3d9/surface.c +++ b/dlls/d3d9/surface.c @@ -273,11 +273,16 @@ static HRESULT WINAPI d3d9_surface_UnlockRect(IDirect3DSurface9 *iface) hr = wined3d_resource_unmap(wined3d_texture_get_resource(surface->wined3d_texture), surface->sub_resource_idx); wined3d_mutex_unlock(); - switch(hr) + if (hr == WINEDDERR_NOTLOCKED) { - case WINEDDERR_NOTLOCKED: return D3DERR_INVALIDCALL; - default: return hr; + D3DRESOURCETYPE type; + if (surface->texture) + type = IDirect3DBaseTexture9_GetType(&surface->texture->IDirect3DBaseTexture9_iface); + else + type = D3DRTYPE_SURFACE; + hr = type == D3DRTYPE_TEXTURE ? D3D_OK : D3DERR_INVALIDCALL; } + return hr; } static HRESULT WINAPI d3d9_surface_GetDC(IDirect3DSurface9 *iface, HDC *dc) diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 39cc2e20b52..758e5c8bdb1 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -7376,7 +7376,6 @@ static void test_lockrect_invalid(void) ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name); expected_hr = resources[r].type == D3DRTYPE_TEXTURE ? D3D_OK : D3DERR_INVALIDCALL; hr = IDirect3DSurface9_UnlockRect(surface); - todo_wine_if(resources[r].type == D3DRTYPE_TEXTURE) ok(hr == expected_hr, "Got hr %#x, expected %#x, type %s.\n", hr, expected_hr, resources[r].name); for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i) @@ -7490,7 +7489,7 @@ static void test_lockrect_invalid(void) hr = IDirect3DTexture9_UnlockRect(texture, 0); ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x, type %s.\n", hr, resources[r].name); hr = IDirect3DTexture9_UnlockRect(texture, 0); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name); + ok(hr == D3D_OK, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name); hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, &test_data[0].rect, 0); ok(hr == D3D_OK, "Got unexpected hr %#x for rect %s, type %s.\n",