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

commit 8dcbf4645c6d293a19cb27f7835155e08eb00cb0
Author:     winesync <[email protected]>
AuthorDate: Mon Sep 21 22:56:57 2020 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Thu Feb 4 16:37:03 2021 +0100

    [WINESYNC] d3dx9: Pass rectangle to {lock|unlock}_surface().
    
    This fixes regressions introduced by commits
    65956ae50a136fe8467a0332c7495f36617a16dc, 
092c14b9d86ee1e96e465908cc524ec85988d0ff.
    Surface source or destination rectangles were left behind.
    
    Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47546
    Signed-off-by: Paul Gofman <[email protected]>
    Signed-off-by: Matteo Bruni <[email protected]>
    Signed-off-by: Alexandre Julliard <[email protected]>
    
    wine commit id 378204527e1f42ed1373a0cd7356770d235e319d by Paul Gofman 
<[email protected]>
---
 dll/directx/wine/d3dx9_36/d3dx9_private.h     |   4 +-
 dll/directx/wine/d3dx9_36/surface.c           |  68 +++++++----
 dll/directx/wine/d3dx9_36/texture.c           |   4 +-
 modules/rostests/winetests/d3dx9_36/surface.c | 166 ++++++++++++++++----------
 sdk/tools/winesync/d3dx9.cfg                  |   2 +-
 5 files changed, 155 insertions(+), 89 deletions(-)

diff --git a/dll/directx/wine/d3dx9_36/d3dx9_private.h 
b/dll/directx/wine/d3dx9_36/d3dx9_private.h
index 5bb68b281ba..b847b7a681f 100644
--- a/dll/directx/wine/d3dx9_36/d3dx9_private.h
+++ b/dll/directx/wine/d3dx9_36/d3dx9_private.h
@@ -121,9 +121,9 @@ HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, 
const PALETTEENTRY *d
     const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN;
 HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, 
const void *src_data,
     const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const 
D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN;
-HRESULT lock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock,
+HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, 
D3DLOCKED_RECT *lock,
         IDirect3DSurface9 **temp_surface, BOOL write) DECLSPEC_HIDDEN;
-HRESULT unlock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock,
+HRESULT unlock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, 
D3DLOCKED_RECT *lock,
         IDirect3DSurface9 *temp_surface, BOOL update) DECLSPEC_HIDDEN;
 
 unsigned short float_32_to_16(const float in) DECLSPEC_HIDDEN;
diff --git a/dll/directx/wine/d3dx9_36/surface.c 
b/dll/directx/wine/d3dx9_36/surface.c
index c3c19e056be..a310a05e391 100644
--- a/dll/directx/wine/d3dx9_36/surface.c
+++ b/dll/directx/wine/d3dx9_36/surface.c
@@ -202,9 +202,10 @@ static const struct {
     { 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000, D3DFMT_X8B8G8R8 },
 };
 
-HRESULT lock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock,
+HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, 
D3DLOCKED_RECT *lock,
         IDirect3DSurface9 **temp_surface, BOOL write)
 {
+    unsigned int width, height;
     IDirect3DDevice9 *device;
     D3DSURFACE_DESC desc;
     DWORD lock_flag;
@@ -212,25 +213,36 @@ HRESULT lock_surface(IDirect3DSurface9 *surface, 
D3DLOCKED_RECT *lock,
 
     lock_flag = write ? D3DLOCK_DISCARD : D3DLOCK_READONLY;
     *temp_surface = NULL;
-    if (FAILED(hr = IDirect3DSurface9_LockRect(surface, lock, NULL, 
lock_flag)))
+    if (FAILED(hr = IDirect3DSurface9_LockRect(surface, lock, surface_rect, 
lock_flag)))
     {
         IDirect3DSurface9_GetDevice(surface, &device);
         IDirect3DSurface9_GetDesc(surface, &desc);
 
-        hr = write ? IDirect3DDevice9_CreateOffscreenPlainSurface(device, 
desc.Width, desc.Height,
+        if (surface_rect)
+        {
+            width = surface_rect->right - surface_rect->left;
+            height = surface_rect->bottom - surface_rect->top;
+        }
+        else
+        {
+            width = desc.Width;
+            height = desc.Height;
+        }
+
+        hr = write ? IDirect3DDevice9_CreateOffscreenPlainSurface(device, 
width, height,
                 desc.Format, D3DPOOL_SYSTEMMEM, temp_surface, NULL)
-                : IDirect3DDevice9_CreateRenderTarget(device, desc.Width, 
desc.Height,
+                : IDirect3DDevice9_CreateRenderTarget(device, width, height,
                 desc.Format, D3DMULTISAMPLE_NONE, 0, TRUE, temp_surface, NULL);
         if (FAILED(hr))
         {
             WARN("Failed to create temporary surface, surface %p, format %#x,"
                     " usage %#x, pool %#x, write %#x, width %u, height %u.\n",
-                    surface, desc.Format, desc.Usage, desc.Pool, write, 
desc.Width, desc.Height);
+                    surface, desc.Format, desc.Usage, desc.Pool, write, width, 
height);
             IDirect3DDevice9_Release(device);
             return hr;
         }
 
-        if (write || SUCCEEDED(hr = IDirect3DDevice9_StretchRect(device, 
surface, NULL,
+        if (write || SUCCEEDED(hr = IDirect3DDevice9_StretchRect(device, 
surface, surface_rect,
                 *temp_surface, NULL, D3DTEXF_NONE)))
             hr = IDirect3DSurface9_LockRect(*temp_surface, lock, NULL, 
lock_flag);
 
@@ -248,20 +260,34 @@ HRESULT lock_surface(IDirect3DSurface9 *surface, 
D3DLOCKED_RECT *lock,
     return hr;
 }
 
-HRESULT unlock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock,
+HRESULT unlock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, 
D3DLOCKED_RECT *lock,
         IDirect3DSurface9 *temp_surface, BOOL update)
 {
     IDirect3DDevice9 *device;
+    POINT surface_point;
     HRESULT hr;
 
     if (!temp_surface)
-        return IDirect3DSurface9_UnlockRect(surface);
+    {
+        hr = IDirect3DSurface9_UnlockRect(surface);
+        return hr;
+    }
 
     hr = IDirect3DSurface9_UnlockRect(temp_surface);
     if (update)
     {
+        if (surface_rect)
+        {
+            surface_point.x = surface_rect->left;
+            surface_point.y = surface_rect->top;
+        }
+        else
+        {
+            surface_point.x = 0;
+            surface_point.y = 0;
+        }
         IDirect3DSurface9_GetDevice(surface, &device);
-        if (FAILED(hr = IDirect3DDevice9_UpdateSurface(device, temp_surface, 
NULL, surface, NULL)))
+        if (FAILED(hr = IDirect3DDevice9_UpdateSurface(device, temp_surface, 
NULL, surface, &surface_point)))
             WARN("Updating surface failed, hr %#x, surface %p, temp_surface 
%p.\n",
                     hr, surface, temp_surface);
         IDirect3DDevice9_Release(device);
@@ -573,7 +599,7 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer 
**dst_buffer, IDirect3DSur
         return hr;
     }
 
-    hr = lock_surface(src_surface, &locked_rect, &temp_surface, FALSE);
+    hr = lock_surface(src_surface, NULL, &locked_rect, &temp_surface, FALSE);
     if (FAILED(hr))
     {
         ID3DXBuffer_Release(buffer);
@@ -586,7 +612,7 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer 
**dst_buffer, IDirect3DSur
     copy_pixels(locked_rect.pBits, locked_rect.Pitch, 0, pixels, dst_pitch, 0,
         &volume, pixel_format);
 
-    unlock_surface(src_surface, &locked_rect, temp_surface, FALSE);
+    unlock_surface(src_surface, NULL, &locked_rect, temp_surface, FALSE);
 
     *dst_buffer = buffer;
     return D3D_OK;
@@ -1874,7 +1900,7 @@ HRESULT WINAPI 
D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
         return E_NOTIMPL;
     }
 
-    if (FAILED(hr = lock_surface(dst_surface, &lockrect, &surface, TRUE)))
+    if (FAILED(hr = lock_surface(dst_surface, dst_rect, &lockrect, &surface, 
TRUE)))
         return hr;
 
     if (src_format == surfdesc.Format
@@ -1890,7 +1916,7 @@ HRESULT WINAPI 
D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
                     && src_size.height != surfdesc.Height))
         {
             WARN("Source rect %s is misaligned.\n", 
wine_dbgstr_rect(src_rect));
-            unlock_surface(dst_surface, &lockrect, surface, FALSE);
+            unlock_surface(dst_surface, dst_rect, &lockrect, surface, FALSE);
             return D3DXERR_INVALIDDATA;
         }
 
@@ -1903,7 +1929,7 @@ HRESULT WINAPI 
D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
                 || !is_conversion_to_supported(destformatdesc))
         {
             FIXME("Unsupported format conversion %#x -> %#x.\n", src_format, 
surfdesc.Format);
-            unlock_surface(dst_surface, &lockrect, surface, FALSE);
+            unlock_surface(dst_surface, dst_rect, &lockrect, surface, FALSE);
             return E_NOTIMPL;
         }
 
@@ -1924,7 +1950,7 @@ HRESULT WINAPI 
D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
         }
     }
 
-    return unlock_surface(dst_surface, &lockrect, surface, TRUE);
+    return unlock_surface(dst_surface, dst_rect, &lockrect, surface, TRUE);
 }
 
 /************************************************************
@@ -2008,13 +2034,13 @@ HRESULT WINAPI 
D3DXLoadSurfaceFromSurface(IDirect3DSurface9 *dst_surface,
         src_rect = &s;
     }
 
-    if (FAILED(lock_surface(src_surface, &lock, &temp_surface, FALSE)))
+    if (FAILED(lock_surface(src_surface, NULL, &lock, &temp_surface, FALSE)))
         return D3DXERR_INVALIDDATA;
 
     hr = D3DXLoadSurfaceFromMemory(dst_surface, dst_palette, dst_rect, 
lock.pBits,
             src_desc.Format, lock.Pitch, src_palette, src_rect, filter, 
color_key);
 
-    if (FAILED(unlock_surface(src_surface, &lock, temp_surface, FALSE)))
+    if (FAILED(unlock_surface(src_surface, NULL, &lock, temp_surface, FALSE)))
         return D3DXERR_INVALIDDATA;
 
     return hr;
@@ -2190,12 +2216,12 @@ HRESULT WINAPI 
D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
         TRACE("Using pixel format %s %#x\n", debugstr_guid(&wic_pixel_format), 
d3d_pixel_format);
         if (src_surface_desc.Format == d3d_pixel_format) /* Simple copy */
         {
-            if (FAILED(hr = lock_surface(src_surface, &locked_rect, 
&temp_surface, FALSE)))
+            if (FAILED(hr = lock_surface(src_surface, src_rect, &locked_rect, 
&temp_surface, FALSE)))
                 goto cleanup;
 
             IWICBitmapFrameEncode_WritePixels(frame, height,
                 locked_rect.Pitch, height * locked_rect.Pitch, 
locked_rect.pBits);
-            unlock_surface(src_surface, &locked_rect, temp_surface, FALSE);
+            unlock_surface(src_surface, src_rect, &locked_rect, temp_surface, 
FALSE);
         }
         else /* Pixel format conversion */
         {
@@ -2225,14 +2251,14 @@ HRESULT WINAPI 
D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
                 hr = E_OUTOFMEMORY;
                 goto cleanup;
             }
-            if (FAILED(hr = lock_surface(src_surface, &locked_rect, 
&temp_surface, FALSE)))
+            if (FAILED(hr = lock_surface(src_surface, src_rect, &locked_rect, 
&temp_surface, FALSE)))
             {
                 HeapFree(GetProcessHeap(), 0, dst_data);
                 goto cleanup;
             }
             convert_argb_pixels(locked_rect.pBits, locked_rect.Pitch, 0, 
&size, src_format_desc,
                 dst_data, dst_pitch, 0, &size, dst_format_desc, 0, NULL);
-            unlock_surface(src_surface, &locked_rect, temp_surface, FALSE);
+            unlock_surface(src_surface, src_rect, &locked_rect, temp_surface, 
FALSE);
 
             IWICBitmapFrameEncode_WritePixels(frame, height, dst_pitch, 
dst_pitch * height, dst_data);
             HeapFree(GetProcessHeap(), 0, dst_data);
diff --git a/dll/directx/wine/d3dx9_36/texture.c 
b/dll/directx/wine/d3dx9_36/texture.c
index 943e7fec06f..0ebb4bea4a0 100644
--- a/dll/directx/wine/d3dx9_36/texture.c
+++ b/dll/directx/wine/d3dx9_36/texture.c
@@ -1357,7 +1357,7 @@ HRESULT WINAPI D3DXFillTexture(struct IDirect3DTexture9 
*texture, LPD3DXFILL2D f
 
         if (FAILED(hr = IDirect3DTexture9_GetSurfaceLevel(texture, m, 
&surface)))
             return hr;
-        if (FAILED(hr = lock_surface(surface, &lock_rect, &temp_surface, 
TRUE)))
+        if (FAILED(hr = lock_surface(surface, NULL, &lock_rect, &temp_surface, 
TRUE)))
         {
             IDirect3DSurface9_Release(surface);
             return hr;
@@ -1383,7 +1383,7 @@ HRESULT WINAPI D3DXFillTexture(struct IDirect3DTexture9 
*texture, LPD3DXFILL2D f
                 fill_texture(format, data + y * lock_rect.Pitch + x * 
format->bytes_per_pixel, &value);
             }
         }
-        if (FAILED(hr = unlock_surface(surface, &lock_rect, temp_surface, 
TRUE)))
+        if (FAILED(hr = unlock_surface(surface, NULL, &lock_rect, 
temp_surface, TRUE)))
         {
             IDirect3DSurface9_Release(surface);
             return hr;
diff --git a/modules/rostests/winetests/d3dx9_36/surface.c 
b/modules/rostests/winetests/d3dx9_36/surface.c
index 56b79d80cb2..a43072ff1f4 100644
--- a/modules/rostests/winetests/d3dx9_36/surface.c
+++ b/modules/rostests/winetests/d3dx9_36/surface.c
@@ -957,17 +957,34 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
         check_pixel_4bpp(&lockrect, 1, 1, 0xfffe9aff);
         IDirect3DSurface9_UnlockRect(surf);
 
-        hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8b8g8r8, 
D3DFMT_A8B8G8R8, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
-        ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected 
%#x\n", hr, D3D_OK);
-        IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
+        hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8b8g8r8, 
D3DFMT_A8B8G8R8,
+                8, NULL, &rect, D3DX_FILTER_NONE, 0);
+        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, 
D3DLOCK_READONLY);
+        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
         check_pixel_4bpp(&lockrect, 0, 0, 0xc3f04c39);
         check_pixel_4bpp(&lockrect, 1, 0, 0x2392e85a);
         check_pixel_4bpp(&lockrect, 0, 1, 0x09fd97b1);
         check_pixel_4bpp(&lockrect, 1, 1, 0x8df62bc3);
         IDirect3DSurface9_UnlockRect(surf);
 
-        hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a2r10g10b10, 
D3DFMT_A2R10G10B10, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
-        ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected 
%#x\n", hr, D3D_OK);
+        SetRect(&rect, 0, 0, 1, 1);
+        SetRect(&destrect, 1, 1, 2, 2);
+        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, 0xc3f04c39);
+        check_pixel_4bpp(&lockrect, 1, 0, 0x2392e85a);
+        check_pixel_4bpp(&lockrect, 0, 1, 0x09fd97b1);
+        check_pixel_4bpp(&lockrect, 1, 1, 0xc3f04c39);
+        IDirect3DSurface9_UnlockRect(surf);
+
+        SetRect(&rect, 0, 0, 2, 2);
+
+        hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a2r10g10b10, 
D3DFMT_A2R10G10B10,
+                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, 0x555c95bf);
         check_pixel_4bpp(&lockrect, 1, 0, 0x556d663f);
@@ -1386,98 +1403,121 @@ static void 
test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9 *device)
 
 static void test_D3DXSaveSurfaceToFile(IDirect3DDevice9 *device)
 {
-    HRESULT hr;
+    const BYTE pixels[] =
+            {0xff, 0x00, 0x00, 0x00, 0xff, 0x00,
+             0x00, 0x00, 0xff, 0x00, 0x00, 0xff,};
+    DWORD pitch = sizeof(pixels) / 2;
     IDirect3DSurface9 *surface;
-    RECT rect;
-    D3DLOCKED_RECT lock_rect;
     D3DXIMAGE_INFO image_info;
-    const BYTE pixels[] = { 0xff, 0x00, 0x00, 0x00, 0xff, 0x00,
-                            0x00, 0x00, 0xff, 0x00, 0x00, 0xff };
-    DWORD pitch = sizeof(pixels) / 2;
+    D3DLOCKED_RECT lock_rect;
+    HRESULT hr;
+    RECT rect;
 
     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 2, 2, 
D3DFMT_R8G8B8, D3DPOOL_SCRATCH, &surface, NULL);
-    if (FAILED(hr)) {
-       skip("Couldn't create surface\n");
+    if (FAILED(hr))
+    {
+       skip("Couldn't create surface.\n");
        return;
     }
 
     SetRect(&rect, 0, 0, 2, 2);
-    hr = D3DXLoadSurfaceFromMemory(surface, NULL, NULL, pixels, D3DFMT_R8G8B8, 
pitch, NULL, &rect, D3DX_FILTER_NONE, 0);
-    if (SUCCEEDED(hr)) {
-        hr = D3DXSaveSurfaceToFileA("saved_surface.bmp", D3DXIFF_BMP, surface, 
NULL, NULL);
-        ok(hr == D3D_OK, "D3DXSaveSurfaceToFileA returned %#x, expected 
%#x\n", hr, D3D_OK);
+    hr = D3DXLoadSurfaceFromMemory(surface, NULL, NULL, pixels, D3DFMT_R8G8B8,
+            pitch, NULL, &rect, D3DX_FILTER_NONE, 0);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
 
-        hr = D3DXLoadSurfaceFromFileA(surface, NULL, NULL, 
"saved_surface.bmp", NULL, D3DX_FILTER_NONE, 0, &image_info);
-        ok(hr == D3D_OK, "Couldn't load saved surface %#x\n", hr);
-        if (FAILED(hr)) goto next_tests;
+    hr = D3DXSaveSurfaceToFileA("saved_surface.bmp", D3DXIFF_BMP, surface, 
NULL, NULL);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
 
-        ok(image_info.Width == 2, "Wrong width %u\n", image_info.Width);
-        ok(image_info.Height == 2, "Wrong height %u\n", image_info.Height);
-        ok(image_info.Format == D3DFMT_R8G8B8, "Wrong format %#x\n", 
image_info.Format);
-        ok(image_info.ImageFileFormat == D3DXIFF_BMP, "Wrong file format 
%u\n", image_info.ImageFileFormat);
+    hr = D3DXLoadSurfaceFromFileA(surface, NULL, NULL, "saved_surface.bmp",
+            NULL, D3DX_FILTER_NONE, 0, &image_info);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
 
-        hr = IDirect3DSurface9_LockRect(surface, &lock_rect, NULL, 
D3DLOCK_READONLY);
-        ok(hr == D3D_OK, "Couldn't lock surface %#x\n", hr);
-        if (FAILED(hr)) goto next_tests;
+    ok(image_info.Width == 2, "Wrong width %u.\n", image_info.Width);
+    ok(image_info.Height == 2, "Wrong height %u.\n", image_info.Height);
+    ok(image_info.Format == D3DFMT_R8G8B8, "Wrong format %#x.\n", 
image_info.Format);
+    ok(image_info.ImageFileFormat == D3DXIFF_BMP, "Wrong file format %u.\n", 
image_info.ImageFileFormat);
 
-        ok(!memcmp(lock_rect.pBits, pixels, pitch), "Pixel data mismatch in 
first row\n");
-        ok(!memcmp((BYTE *)lock_rect.pBits + lock_rect.Pitch, pixels + pitch, 
pitch), "Pixel data mismatch in second row\n");
+    hr = IDirect3DSurface9_LockRect(surface, &lock_rect, NULL, 
D3DLOCK_READONLY);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    ok(!memcmp(lock_rect.pBits, pixels, pitch),
+            "Pixel data mismatch in the first row.\n");
+    ok(!memcmp((BYTE *)lock_rect.pBits + lock_rect.Pitch, pixels + pitch, 
pitch),
+            "Pixel data mismatch in the second row.\n");
 
-        IDirect3DSurface9_UnlockRect(surface);
-    } else skip("Couldn't fill surface\n");
+    IDirect3DSurface9_UnlockRect(surface);
+
+    SetRect(&rect, 0, 1, 2, 2);
+    hr = D3DXSaveSurfaceToFileA("saved_surface.bmp", D3DXIFF_BMP, surface, 
NULL, &rect);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    SetRect(&rect, 0, 0, 2, 1);
+    hr = D3DXLoadSurfaceFromFileA(surface, NULL, &rect, "saved_surface.bmp", 
NULL,
+            D3DX_FILTER_NONE, 0, &image_info);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DSurface9_LockRect(surface, &lock_rect, NULL, 
D3DLOCK_READONLY);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(!memcmp(lock_rect.pBits, pixels + pitch, pitch),
+            "Pixel data mismatch in the first row.\n");
+    ok(!memcmp((BYTE *)lock_rect.pBits + lock_rect.Pitch, pixels + pitch, 
pitch),
+            "Pixel data mismatch in the second row.\n");
+    IDirect3DSurface9_UnlockRect(surface);
+
+    SetRect(&rect, 0, 0, 2, 2);
+    hr = D3DXLoadSurfaceFromMemory(surface, NULL, NULL, pixels, D3DFMT_R8G8B8,
+            pitch, NULL, &rect, D3DX_FILTER_NONE, 0);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
 
-next_tests:
     hr = D3DXSaveSurfaceToFileA(NULL, D3DXIFF_BMP, surface, NULL, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "D3DXSaveSurfaceToFileA returned %#x, 
expected %#x\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
 
     /* PPM and TGA are supported, even though MSDN claims they aren't */
-    todo_wine {
-    hr = D3DXSaveSurfaceToFileA("saved_surface.ppm", D3DXIFF_PPM, surface, 
NULL, NULL);
-    ok(hr == D3D_OK, "D3DXSaveSurfaceToFileA returned %#x, expected %#x\n", 
hr, D3D_OK);
-    hr = D3DXSaveSurfaceToFileA("saved_surface.tga", D3DXIFF_TGA, surface, 
NULL, NULL);
-    ok(hr == D3D_OK, "D3DXSaveSurfaceToFileA returned %#x, expected %#x\n", 
hr, D3D_OK);
+    todo_wine
+    {
+        hr = D3DXSaveSurfaceToFileA("saved_surface.ppm", D3DXIFF_PPM, surface, 
NULL, NULL);
+        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        hr = D3DXSaveSurfaceToFileA("saved_surface.tga", D3DXIFF_TGA, surface, 
NULL, NULL);
+        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
     }
 
     hr = D3DXSaveSurfaceToFileA("saved_surface.dds", D3DXIFF_DDS, surface, 
NULL, NULL);
-    ok(hr == D3D_OK, "D3DXSaveSurfaceToFileA returned %#x, expected %#x\n", 
hr, D3D_OK);
-    if (SUCCEEDED(hr)) {
-        hr = D3DXLoadSurfaceFromFileA(surface, NULL, NULL, 
"saved_surface.dds", NULL, D3DX_FILTER_NONE, 0, &image_info);
-        ok(hr == D3D_OK, "Couldn't load saved surface %#x\n", hr);
-
-        if (SUCCEEDED(hr)) {
-            ok(image_info.Width == 2, "Wrong width %u\n", image_info.Width);
-            ok(image_info.Format == D3DFMT_R8G8B8, "Wrong format %#x\n", 
image_info.Format);
-            ok(image_info.ImageFileFormat == D3DXIFF_DDS, "Wrong file format 
%u\n", image_info.ImageFileFormat);
-
-            hr = IDirect3DSurface9_LockRect(surface, &lock_rect, NULL, 
D3DLOCK_READONLY);
-            ok(hr == D3D_OK, "Couldn't lock surface %#x\n", hr);
-            if (SUCCEEDED(hr)) {
-                ok(!memcmp(lock_rect.pBits, pixels, pitch), "Pixel data 
mismatch in first row\n");
-                ok(!memcmp((BYTE *)lock_rect.pBits + lock_rect.Pitch, pixels + 
pitch, pitch), "Pixel data mismatch in second row\n");
-                IDirect3DSurface9_UnlockRect(surface);
-            }
-        }
-    } else skip("Couldn't save surface\n");
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = D3DXLoadSurfaceFromFileA(surface, NULL, NULL, "saved_surface.dds",
+            NULL, D3DX_FILTER_NONE, 0, &image_info);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    ok(image_info.Width == 2, "Wrong width %u.\n", image_info.Width);
+    ok(image_info.Format == D3DFMT_R8G8B8, "Wrong format %#x.\n", 
image_info.Format);
+    ok(image_info.ImageFileFormat == D3DXIFF_DDS, "Wrong file format %u.\n", 
image_info.ImageFileFormat);
+
+    hr = IDirect3DSurface9_LockRect(surface, &lock_rect, NULL, 
D3DLOCK_READONLY);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(!memcmp(lock_rect.pBits, pixels, pitch),
+            "Pixel data mismatch in the first row.\n");
+    ok(!memcmp((BYTE *)lock_rect.pBits + lock_rect.Pitch, pixels + pitch, 
pitch),
+            "Pixel data mismatch in the second row.\n");
+    IDirect3DSurface9_UnlockRect(surface);
 
     hr = D3DXSaveSurfaceToFileA("saved_surface", D3DXIFF_PFM + 1, surface, 
NULL, NULL);
-    ok(hr == D3DERR_INVALIDCALL, "D3DXSaveSurfaceToFileA returned %#x, 
expected %#x\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
 
     SetRect(&rect, 0, 0, 4, 4);
     hr = D3DXSaveSurfaceToFileA("saved_surface.bmp", D3DXIFF_BMP, surface, 
NULL, &rect);
-    ok(hr == D3DERR_INVALIDCALL, "D3DXSaveSurfaceToFileA returned %#x, 
expected %#x\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
     SetRect(&rect, 2, 0, 1, 4);
     hr = D3DXSaveSurfaceToFileA("saved_surface.bmp", D3DXIFF_BMP, surface, 
NULL, &rect);
-    ok(hr == D3DERR_INVALIDCALL, "D3DXSaveSurfaceToFileA returned %#x, 
expected %#x\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
     SetRect(&rect, 0, 2, 4, 1);
     hr = D3DXSaveSurfaceToFileA("saved_surface.bmp", D3DXIFF_BMP, surface, 
NULL, &rect);
-    ok(hr == D3DERR_INVALIDCALL, "D3DXSaveSurfaceToFileA returned %#x, 
expected %#x\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
     SetRect(&rect, -1, -1, 2, 2);
     hr = D3DXSaveSurfaceToFileA("saved_surface.bmp", D3DXIFF_BMP, surface, 
NULL, &rect);
-    ok(hr == D3DERR_INVALIDCALL, "D3DXSaveSurfaceToFileA returned %#x, 
expected %#x\n", hr, D3DERR_INVALIDCALL);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
     SetRectEmpty(&rect);
     hr = D3DXSaveSurfaceToFileA("saved_surface.bmp", D3DXIFF_BMP, surface, 
NULL, &rect);
     /* fails when debug version of d3d9 is used */
-    ok(hr == D3D_OK || broken(hr == D3DERR_INVALIDCALL), 
"D3DXSaveSurfaceToFileA returned %#x, expected %#x\n", hr, D3D_OK);
+    ok(hr == D3D_OK || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr 
%#x.\n", hr);
 
     DeleteFileA("saved_surface.bmp");
     DeleteFileA("saved_surface.ppm");
diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg
index 1d7f99ec8c8..7c5682d4be6 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: 9fb5745a7997bbfe033779650f1193d85369cef2}
+tags: {wine: 378204527e1f42ed1373a0cd7356770d235e319d}

Reply via email to