mirror of
https://github.com/reactos/reactos.git
synced 2025-05-07 02:41:22 +00:00
[WINESYNC]d3dx9: Use temporary surface in D3DXSaveSurfaceToFileInMemory() for unmappable textures.
Fixes a regression triggered by commit 949dbbd31f450178c90ea8267097a975b77c3219. Signed-off-by: Paul Gofman <gofmanp@gmail.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id 092c14b9d86ee1e96e465908cc524ec85988d0ff by Paul Gofman <gofmanp@gmail.com>
This commit is contained in:
parent
9e1d68edb0
commit
a1f2064705
3 changed files with 49 additions and 16 deletions
|
@ -530,6 +530,7 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur
|
||||||
BYTE *pixels;
|
BYTE *pixels;
|
||||||
struct volume volume;
|
struct volume volume;
|
||||||
const struct pixel_format_desc *pixel_format;
|
const struct pixel_format_desc *pixel_format;
|
||||||
|
IDirect3DSurface9 *temp_surface;
|
||||||
|
|
||||||
if (src_rect)
|
if (src_rect)
|
||||||
{
|
{
|
||||||
|
@ -569,7 +570,7 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur
|
||||||
return hr;
|
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))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
ID3DXBuffer_Release(buffer);
|
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,
|
copy_pixels(locked_rect.pBits, locked_rect.Pitch, 0, pixels, dst_pitch, 0,
|
||||||
&volume, pixel_format);
|
&volume, pixel_format);
|
||||||
|
|
||||||
IDirect3DSurface9_UnlockRect(src_surface);
|
unlock_surface(src_surface, &locked_rect, temp_surface, FALSE);
|
||||||
|
|
||||||
*dst_buffer = buffer;
|
*dst_buffer = buffer;
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
|
@ -2124,6 +2125,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
|
||||||
WICPixelFormatGUID wic_pixel_format;
|
WICPixelFormatGUID wic_pixel_format;
|
||||||
D3DFORMAT d3d_pixel_format;
|
D3DFORMAT d3d_pixel_format;
|
||||||
D3DSURFACE_DESC src_surface_desc;
|
D3DSURFACE_DESC src_surface_desc;
|
||||||
|
IDirect3DSurface9 *temp_surface;
|
||||||
D3DLOCKED_RECT locked_rect;
|
D3DLOCKED_RECT locked_rect;
|
||||||
int width, height;
|
int width, height;
|
||||||
STATSTG stream_stats;
|
STATSTG stream_stats;
|
||||||
|
@ -2131,7 +2133,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
|
||||||
ID3DXBuffer *buffer;
|
ID3DXBuffer *buffer;
|
||||||
DWORD size;
|
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));
|
dst_buffer, file_format, src_surface, src_palette, wine_dbgstr_rect(src_rect));
|
||||||
|
|
||||||
if (!dst_buffer || !src_surface) return D3DERR_INVALIDCALL;
|
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)
|
if (SUCCEEDED(hr) && d3d_pixel_format != D3DFMT_UNKNOWN)
|
||||||
{
|
{
|
||||||
TRACE("Using pixel format %s %#x\n", debugstr_guid(&wic_pixel_format), d3d_pixel_format);
|
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 (src_surface_desc.Format == d3d_pixel_format) /* Simple copy */
|
||||||
{
|
{
|
||||||
hr = IDirect3DSurface9_LockRect(src_surface, &locked_rect, src_rect, D3DLOCK_READONLY);
|
if (FAILED(hr = lock_surface(src_surface, &locked_rect, &temp_surface, FALSE)))
|
||||||
if (FAILED(hr))
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
IWICBitmapFrameEncode_WritePixels(frame, height,
|
IWICBitmapFrameEncode_WritePixels(frame, height,
|
||||||
locked_rect.Pitch, height * locked_rect.Pitch, locked_rect.pBits);
|
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 */
|
else /* Pixel format conversion */
|
||||||
{
|
{
|
||||||
|
@ -2264,16 +2264,14 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
|
||||||
hr = E_OUTOFMEMORY;
|
hr = E_OUTOFMEMORY;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
if (FAILED(hr = lock_surface(src_surface, &locked_rect, &temp_surface, FALSE)))
|
||||||
hr = IDirect3DSurface9_LockRect(src_surface, &locked_rect, src_rect, D3DLOCK_READONLY);
|
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, dst_data);
|
HeapFree(GetProcessHeap(), 0, dst_data);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
convert_argb_pixels(locked_rect.pBits, locked_rect.Pitch, 0, &size, src_format_desc,
|
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);
|
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);
|
IWICBitmapFrameEncode_WritePixels(frame, height, dst_pitch, dst_pitch * height, dst_data);
|
||||||
HeapFree(GetProcessHeap(), 0, dst_data);
|
HeapFree(GetProcessHeap(), 0, dst_data);
|
||||||
|
|
|
@ -1253,16 +1253,30 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
|
||||||
|
|
||||||
static void test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9 *device)
|
static void test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9 *device)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
static const struct
|
||||||
RECT rect;
|
{
|
||||||
ID3DXBuffer *buffer;
|
DWORD usage;
|
||||||
IDirect3DSurface9 *surface;
|
D3DPOOL pool;
|
||||||
|
}
|
||||||
|
test_access_types[] =
|
||||||
|
{
|
||||||
|
{0, D3DPOOL_MANAGED},
|
||||||
|
{0, D3DPOOL_DEFAULT},
|
||||||
|
{D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT},
|
||||||
|
};
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
DWORD magic;
|
DWORD magic;
|
||||||
struct dds_header header;
|
struct dds_header header;
|
||||||
BYTE *data;
|
BYTE *data;
|
||||||
} *dds;
|
} *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);
|
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 4, 4, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &surface, NULL);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
|
@ -1317,6 +1331,27 @@ static void test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9 *device)
|
||||||
ID3DXBuffer_Release(buffer);
|
ID3DXBuffer_Release(buffer);
|
||||||
|
|
||||||
IDirect3DSurface9_Release(surface);
|
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)
|
static void test_D3DXSaveSurfaceToFile(IDirect3DDevice9 *device)
|
||||||
|
|
|
@ -33,4 +33,4 @@ files:
|
||||||
include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h
|
include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h
|
||||||
include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h
|
include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h
|
||||||
tags:
|
tags:
|
||||||
wine: ce090114340fe6ce9314f543a1389de9bdc6df14
|
wine: 092c14b9d86ee1e96e465908cc524ec85988d0ff
|
||||||
|
|
Loading…
Reference in a new issue