[PATCH 2/2] d3d9: call wined3d_device_copy_sub_resource_region instead of wined3d_device_update_surface in d3d9_device_UpdateSurface
Riccardo Bortolato
rikyz619 at gmail.com
Wed Oct 28 09:31:04 CDT 2015
also enabled a failing test in d3d9/tests.
Signed-off-by: Riccardo Bortolato <rikyz619 at gmail.com>
---
dlls/d3d9/device.c | 42 ++++++++++++++++++++++++++++++++++++++++--
dlls/d3d9/tests/device.c | 2 +-
2 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 16b27e5..c60ea86 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1227,16 +1227,54 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface,
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct d3d9_surface *src = unsafe_impl_from_IDirect3DSurface9(src_surface);
struct d3d9_surface *dst = unsafe_impl_from_IDirect3DSurface9(dst_surface);
+ struct wined3d_box src_box;
+ struct wined3d_resource *sub_resource;
+ struct wined3d_resource_desc dst_desc, src_desc;
HRESULT hr;
TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_point %p.\n",
iface, src_surface, src_rect, dst_surface, dst_point);
wined3d_mutex_lock();
- hr = wined3d_device_update_surface(device->wined3d_device, src->wined3d_surface, src_rect,
- dst->wined3d_surface, dst_point);
+ sub_resource = wined3d_texture_get_sub_resource(src->wined3d_texture, src->sub_resource_idx);
+ wined3d_resource_get_desc(sub_resource, &src_desc);
+ sub_resource = wined3d_texture_get_sub_resource(dst->wined3d_texture, dst->sub_resource_idx);
+ wined3d_resource_get_desc(sub_resource, &dst_desc);
+
+ if (src_desc.pool != WINED3D_POOL_SYSTEM_MEM || dst_desc.pool != WINED3D_POOL_DEFAULT)
+ {
+ WARN("source %p must be SYSTEMMEM and dest %p must be DEFAULT, returning WINED3DERR_INVALIDCALL\n",
+ src_surface, dst_surface);
+ wined3d_mutex_unlock();
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (src_rect)
+ {
+ src_box.left = src_rect->left;
+ src_box.top = src_rect->top;
+ src_box.right = src_rect->right;
+ src_box.bottom = src_rect->bottom;
+ }
+ else
+ {
+ src_box.left = 0;
+ src_box.top = 0;
+ src_box.right = src_desc.width;
+ src_box.bottom = src_desc.height;
+ }
+ src_box.front = 0;
+ src_box.back = 1;
+
+ hr = wined3d_device_copy_sub_resource_region(device->wined3d_device,
+ wined3d_texture_get_resource(dst->wined3d_texture), dst->sub_resource_idx, dst_point ? dst_point->x : 0,
+ dst_point ? dst_point->y : 0, 0, wined3d_texture_get_resource(src->wined3d_texture),
+ src->sub_resource_idx, &src_box);
wined3d_mutex_unlock();
+ if (FAILED(hr))
+ return D3DERR_INVALIDCALL;
+
return hr;
}
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 326e789..08c52b2 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -9881,7 +9881,7 @@ static void test_mipmap_lock(void)
hr = IDirect3DDevice9_UpdateSurface(device, surface, NULL, surface_dst, NULL);
ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr);
hr = IDirect3DDevice9_UpdateSurface(device, surface2, NULL, surface_dst2, NULL);
- todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+ ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
/* Apparently there's no validation on the container. */
hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texture,
--
1.9.1
More information about the wine-patches
mailing list