https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8c85a63a2bc43405c593fff5d456c9f0cfc2d123

commit 8c85a63a2bc43405c593fff5d456c9f0cfc2d123
Author:     winesync <[email protected]>
AuthorDate: Mon Sep 21 23:00:50 2020 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Thu Feb 4 16:37:04 2021 +0100

    [WINESYNC] d3dx9: Move the source rect alignment check into the condition 
for simple copy.
    
    Signed-off-by: Matteo Bruni <[email protected]>
    Signed-off-by: Alexandre Julliard <[email protected]>
    
    wine commit id a9c158b72aae1efed159d40fde086cdc608bc62e by Matteo Bruni 
<[email protected]>
---
 dll/directx/wine/d3dx9_36/surface.c           | 36 +++++++++++----------------
 modules/rostests/winetests/d3dx9_36/surface.c |  2 +-
 modules/rostests/winetests/d3dx9_36/texture.c | 34 ++++++++++++-------------
 sdk/tools/winesync/d3dx9.cfg                  |  2 +-
 4 files changed, 33 insertions(+), 41 deletions(-)

diff --git a/dll/directx/wine/d3dx9_36/surface.c 
b/dll/directx/wine/d3dx9_36/surface.c
index c60364a12d2..4786c90bd9b 100644
--- a/dll/directx/wine/d3dx9_36/surface.c
+++ b/dll/directx/wine/d3dx9_36/surface.c
@@ -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);
     }
diff --git a/modules/rostests/winetests/d3dx9_36/surface.c 
b/modules/rostests/winetests/d3dx9_36/surface.c
index 04ce57fa4f5..ba441879597 100644
--- a/modules/rostests/winetests/d3dx9_36/surface.c
+++ b/modules/rostests/winetests/d3dx9_36/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/modules/rostests/winetests/d3dx9_36/texture.c 
b/modules/rostests/winetests/d3dx9_36/texture.c
index fc1589d25e3..49aed94a174 100644
--- a/modules/rostests/winetests/d3dx9_36/texture.c
+++ b/modules/rostests/winetests/d3dx9_36/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);
diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg
index a6dc16d1d1e..02c8841279b 100644
--- a/sdk/tools/winesync/d3dx9.cfg
+++ b/sdk/tools/winesync/d3dx9.cfg
@@ -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}

Reply via email to