Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41936 Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/d3dx9_36/surface.c | 9 ++++++++- dlls/d3dx9_36/tests/surface.c | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 8e9b834d88..8b85c97e8b 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -1836,10 +1836,10 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, DWORD filter, D3DCOLOR color_key) { const struct pixel_format_desc *srcformatdesc, *destformatdesc; + struct volume src_size, dst_size; IDirect3DSurface9 *surface; D3DSURFACE_DESC surfdesc; D3DLOCKED_RECT lockrect; - struct volume src_size, dst_size; HRESULT hr;
TRACE("(%p, %p, %s, %p, %#x, %u, %p, %s, %#x, 0x%08x)\n", @@ -1899,6 +1899,13 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, if (FAILED(hr = lock_surface(dst_surface, dst_rect, &lockrect, &surface, TRUE))) return hr;
+ if (!(src_rect->left & (srcformatdesc->block_width - 1) + || src_rect->top & (srcformatdesc->block_height - 1))) + src_memory = (BYTE *)src_memory + src_rect->top * src_pitch + src_rect->left + * srcformatdesc->bytes_per_pixel; + else + FIXME("Source rect position is misaligned, src_rect %s.\n", wine_dbgstr_rect(src_rect)); + if (src_format == surfdesc.Format && dst_size.width == src_size.width && dst_size.height == src_size.height diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 4a10492a08..2c7e088f06 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -980,6 +980,15 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) check_pixel_4bpp(&lockrect, 1, 1, 0xc3f04c39); IDirect3DSurface9_UnlockRect(surf);
+ SetRect(&rect, 1, 1, 2, 2); + SetRect(&destrect, 0, 0, 1, 1); + hr = D3DXLoadSurfaceFromMemory(surf, NULL, &destrect, pixdata_a8b8g8r8, D3DFMT_A8B8G8R8, + 8, NULL, &rect, D3DX_FILTER_NONE, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + check_pixel_4bpp(&lockrect, 0, 0, 0x8df62bc3); + IDirect3DSurface9_UnlockRect(surf); + SetRect(&rect, 0, 0, 2, 2);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a2r10g10b10, D3DFMT_A2R10G10B10,