[WINESYNC] d3dx9: Move the source rect alignment check into the condition for simple copy.

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id a9c158b72aae1efed159d40fde086cdc608bc62e by Matteo Bruni <mbruni@codeweavers.com>
This commit is contained in:
winesync 2020-09-21 23:00:50 +02:00 committed by Jérôme Gardou
parent bbf66db254
commit 8c85a63a2b
4 changed files with 33 additions and 41 deletions

View file

@ -1852,10 +1852,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",
@ -1875,14 +1875,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;
@ -1903,14 +1907,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;
@ -1918,16 +1918,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);
}

View file

@ -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);

View file

@ -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);

View file

@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc
include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h,
include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h,
include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h}
tags: {wine: d2f3fc03cb1dbcae77e199f3fd8eb2ccf419cfa5}
tags: {wine: a9c158b72aae1efed159d40fde086cdc608bc62e}