https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a1f2064705d8a0a58c409…
commit a1f2064705d8a0a58c4090e42a32abd70831a323
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Jan 4 01:48:04 2020 +0100
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed Feb 26 18:19:18 2020 +0100
[WINESYNC]d3dx9: Use temporary surface in D3DXSaveSurfaceToFileInMemory() for
unmappable textures.
Fixes a regression triggered by commit
949dbbd31f450178c90ea8267097a975b77c3219.
Signed-off-by: Paul Gofman <gofmanp(a)gmail.com>
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 092c14b9d86ee1e96e465908cc524ec85988d0ff by Paul Gofman
<gofmanp(a)gmail.com>
---
dll/directx/wine/d3dx9_36/surface.c | 20 ++++++-------
modules/rostests/winetests/d3dx9_36/surface.c | 43 ++++++++++++++++++++++++---
sdk/tools/winesync/d3dx9.cfg | 2 +-
3 files changed, 49 insertions(+), 16 deletions(-)
diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c
index faac1419517..23e8f7691f2 100644
--- a/dll/directx/wine/d3dx9_36/surface.c
+++ b/dll/directx/wine/d3dx9_36/surface.c
@@ -530,6 +530,7 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer,
IDirect3DSur
BYTE *pixels;
struct volume volume;
const struct pixel_format_desc *pixel_format;
+ IDirect3DSurface9 *temp_surface;
if (src_rect)
{
@@ -569,7 +570,7 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer,
IDirect3DSur
return hr;
}
- hr = IDirect3DSurface9_LockRect(src_surface, &locked_rect, NULL,
D3DLOCK_READONLY);
+ hr = lock_surface(src_surface, &locked_rect, &temp_surface, FALSE);
if (FAILED(hr))
{
ID3DXBuffer_Release(buffer);
@@ -582,7 +583,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);
- IDirect3DSurface9_UnlockRect(src_surface);
+ unlock_surface(src_surface, &locked_rect, temp_surface, FALSE);
*dst_buffer = buffer;
return D3D_OK;
@@ -2124,6 +2125,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer
**dst_buffer, D3DXIMAGE
WICPixelFormatGUID wic_pixel_format;
D3DFORMAT d3d_pixel_format;
D3DSURFACE_DESC src_surface_desc;
+ IDirect3DSurface9 *temp_surface;
D3DLOCKED_RECT locked_rect;
int width, height;
STATSTG stream_stats;
@@ -2131,7 +2133,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer
**dst_buffer, D3DXIMAGE
ID3DXBuffer *buffer;
DWORD size;
- TRACE("(%p, %#x, %p, %p, %s)\n",
+ TRACE("dst_buffer %p, file_format %#x, src_surface %p, src_palette %p, src_rect
%s.\n",
dst_buffer, file_format, src_surface, src_palette, wine_dbgstr_rect(src_rect));
if (!dst_buffer || !src_surface) return D3DERR_INVALIDCALL;
@@ -2225,16 +2227,14 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer
**dst_buffer, D3DXIMAGE
if (SUCCEEDED(hr) && d3d_pixel_format != D3DFMT_UNKNOWN)
{
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 */
{
- hr = IDirect3DSurface9_LockRect(src_surface, &locked_rect, src_rect,
D3DLOCK_READONLY);
- if (FAILED(hr))
+ if (FAILED(hr = lock_surface(src_surface, &locked_rect,
&temp_surface, FALSE)))
goto cleanup;
IWICBitmapFrameEncode_WritePixels(frame, height,
locked_rect.Pitch, height * locked_rect.Pitch, locked_rect.pBits);
- IDirect3DSurface9_UnlockRect(src_surface);
+ unlock_surface(src_surface, &locked_rect, temp_surface, FALSE);
}
else /* Pixel format conversion */
{
@@ -2264,16 +2264,14 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer
**dst_buffer, D3DXIMAGE
hr = E_OUTOFMEMORY;
goto cleanup;
}
-
- hr = IDirect3DSurface9_LockRect(src_surface, &locked_rect, src_rect,
D3DLOCK_READONLY);
- if (FAILED(hr))
+ if (FAILED(hr = lock_surface(src_surface, &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);
- IDirect3DSurface9_UnlockRect(src_surface);
+ unlock_surface(src_surface, &locked_rect, temp_surface, FALSE);
IWICBitmapFrameEncode_WritePixels(frame, height, dst_pitch, dst_pitch *
height, dst_data);
HeapFree(GetProcessHeap(), 0, dst_data);
diff --git a/modules/rostests/winetests/d3dx9_36/surface.c
b/modules/rostests/winetests/d3dx9_36/surface.c
index d3450722ef7..6cb1ddb73ce 100644
--- a/modules/rostests/winetests/d3dx9_36/surface.c
+++ b/modules/rostests/winetests/d3dx9_36/surface.c
@@ -1253,16 +1253,30 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
static void test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9 *device)
{
- HRESULT hr;
- RECT rect;
- ID3DXBuffer *buffer;
- IDirect3DSurface9 *surface;
+ static const struct
+ {
+ DWORD usage;
+ D3DPOOL pool;
+ }
+ test_access_types[] =
+ {
+ {0, D3DPOOL_MANAGED},
+ {0, D3DPOOL_DEFAULT},
+ {D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT},
+ };
+
struct
{
DWORD magic;
struct dds_header header;
BYTE *data;
} *dds;
+ IDirect3DSurface9 *surface;
+ IDirect3DTexture9 *texture;
+ ID3DXBuffer *buffer;
+ unsigned int i;
+ HRESULT hr;
+ RECT rect;
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 4, 4, D3DFMT_A8R8G8B8,
D3DPOOL_SCRATCH, &surface, NULL);
if (FAILED(hr)) {
@@ -1317,6 +1331,27 @@ static void test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9
*device)
ID3DXBuffer_Release(buffer);
IDirect3DSurface9_Release(surface);
+
+ for (i = 0; i < ARRAY_SIZE(test_access_types); ++i)
+ {
+ hr = IDirect3DDevice9_CreateTexture(device, 4, 4, 0, test_access_types[i].usage,
+ D3DFMT_A8R8G8B8, test_access_types[i].pool, &texture, NULL);
+ ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i);
+
+ hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
+ ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i);
+
+ hr = D3DXSaveSurfaceToFileInMemory(&buffer, D3DXIFF_DDS, surface, NULL,
NULL);
+ ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i);
+ ID3DXBuffer_Release(buffer);
+
+ hr = D3DXSaveSurfaceToFileInMemory(&buffer, D3DXIFF_BMP, surface, NULL,
NULL);
+ ok(hr == D3D_OK, "Unexpected hr %#x, i %u.\n", hr, i);
+ ID3DXBuffer_Release(buffer);
+
+ IDirect3DSurface9_Release(surface);
+ IDirect3DTexture9_Release(texture);
+ }
}
static void test_D3DXSaveSurfaceToFile(IDirect3DDevice9 *device)
diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg
index dd03a62177b..746b3659388 100644
--- a/sdk/tools/winesync/d3dx9.cfg
+++ b/sdk/tools/winesync/d3dx9.cfg
@@ -33,4 +33,4 @@ files:
include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h
include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h
tags:
- wine: ce090114340fe6ce9314f543a1389de9bdc6df14
+ wine: 092c14b9d86ee1e96e465908cc524ec85988d0ff