Matteo Bruni : d3dx9: Move the source rect alignment check into the condition for simple copy.
Alexandre Julliard
julliard at winehq.org
Fri Sep 27 15:56:30 CDT 2019
Module: wine
Branch: master
Commit: a9c158b72aae1efed159d40fde086cdc608bc62e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=a9c158b72aae1efed159d40fde086cdc608bc62e
Author: Matteo Bruni <mbruni at codeweavers.com>
Date: Fri Sep 27 20:40:01 2019 +0200
d3dx9: Move the source rect alignment check into the condition for simple copy.
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d3dx9_36/surface.c | 36 +++++++++++++++---------------------
dlls/d3dx9_36/tests/surface.c | 2 +-
dlls/d3dx9_36/tests/texture.c | 34 ++++++++++++++++------------------
3 files changed, 32 insertions(+), 40 deletions(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index a2eca9cbdb..e85805df8e 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -1848,10 +1848,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",
@@ -1871,14 +1871,18 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
return E_FAIL;
}
- if (filter == D3DX_DEFAULT)
- filter = D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER;
-
- IDirect3DSurface9_GetDesc(dst_surface, &surfdesc);
+ srcformatdesc = get_format_info(src_format);
+ if (srcformatdesc->type == FORMAT_UNKNOWN)
+ {
+ FIXME("Unsupported format %#x.\n", src_format);
+ return E_NOTIMPL;
+ }
src_size.width = src_rect->right - src_rect->left;
src_size.height = src_rect->bottom - src_rect->top;
src_size.depth = 1;
+
+ IDirect3DSurface9_GetDesc(dst_surface, &surfdesc);
if (!dst_rect)
{
dst_size.width = surfdesc.Width;
@@ -1899,14 +1903,10 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
return D3D_OK;
}
dst_size.depth = 1;
-
- srcformatdesc = get_format_info(src_format);
destformatdesc = get_format_info(surfdesc.Format);
- if (srcformatdesc->type == FORMAT_UNKNOWN)
- {
- FIXME("Unsupported format %#x.\n", src_format);
- return E_NOTIMPL;
- }
+
+ if (filter == D3DX_DEFAULT)
+ filter = D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER;
if (FAILED(hr = lock_surface(dst_surface, dst_rect, &lockrect, &surface, TRUE)))
return hr;
@@ -1914,16 +1914,10 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
if (src_format == surfdesc.Format
&& dst_size.width == src_size.width
&& dst_size.height == src_size.height
- && color_key == 0) /* Simple copy. */
+ && color_key == 0
+ && !(src_rect->left & (srcformatdesc->block_width - 1))
+ && !(src_rect->top & (srcformatdesc->block_height - 1))) /* Simple copy. */
{
- if (src_rect->left & (srcformatdesc->block_width - 1)
- || src_rect->top & (srcformatdesc->block_height - 1))
- {
- WARN("Source rect %s is misaligned.\n", wine_dbgstr_rect(src_rect));
- unlock_surface(dst_surface, dst_rect, surface, FALSE);
- return D3DXERR_INVALIDDATA;
- }
-
copy_pixels(src_memory, src_pitch, 0, lockrect.pBits, lockrect.Pitch, 0,
&src_size, srcformatdesc);
}
diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c
index 04ce57fa4f..ba44187959 100644
--- a/dlls/d3dx9_36/tests/surface.c
+++ b/dlls/d3dx9_36/tests/surface.c
@@ -1351,7 +1351,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
hr = D3DXLoadSurfaceFromMemory(newsurf, NULL, &rect, &dds_dxt5_8_8[128],
D3DFMT_DXT5, 16 * 2, NULL, &rect, D3DX_FILTER_POINT, 0);
- todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
check_release((IUnknown *)newsurf, 1);
check_release((IUnknown *)tex, 0);
diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c
index fc1589d25e..49aed94a17 100644
--- a/dlls/d3dx9_36/tests/texture.c
+++ b/dlls/d3dx9_36/tests/texture.c
@@ -1804,28 +1804,26 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
hr = D3DXLoadSurfaceFromMemory(surface, NULL, &rect, &dds_dxt5_8_8[128],
D3DFMT_DXT5, 16 * 2, NULL, &rect, D3DX_FILTER_POINT, 0);
- todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- if (SUCCEEDED(hr))
- {
- hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
- ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
- ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- for (y = 0; y < 8; ++y)
+ hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ for (y = 0; y < 8; ++y)
+ {
+ for (x = 0; x < 8; ++x)
{
- for (x = 0; x < 8; ++x)
- {
- ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
- dds_dxt5_8_8_expected_misaligned_3[y * 8 + x], 0),
- "Color at position %u, %u is 0x%08x, expected 0x%08x.\n",
- x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
- dds_dxt5_8_8_expected_misaligned_3[y * 8 + x]);
- }
+ todo_wine_if (x >= 2 && x < 6 && y >= 2 && y < 6)
+ ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
+ dds_dxt5_8_8_expected_misaligned_3[y * 8 + x], 0),
+ "Color at position %u, %u is 0x%08x, expected 0x%08x.\n",
+ x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
+ dds_dxt5_8_8_expected_misaligned_3[y * 8 + x]);
}
- hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
- ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
}
+ hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
IDirect3DSurface9_Release(uncompressed_surface);
IDirect3DSurface9_Release(surface);
More information about the wine-cvs
mailing list