d3dx9_36-DDS: Add initial tests for D3DXSaveSurfaceToFileInMemory.

This commit is contained in:
Sebastian Lackner 2015-11-13 19:09:04 +01:00
parent 2c3f70b42b
commit e5bff1feaf
5 changed files with 98 additions and 8 deletions

View File

@ -0,0 +1,74 @@
From 68efe5449591b9b1366d66d87fff1a8c9f8002e5 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 16 Oct 2015 14:06:30 +1100
Subject: d3dx9_36/tests: Add D3DXSaveSurfaceToFileInMemory D3DXIFF_DDS tests
Also updates the structure dds_header to be the same as d3dx9_36/surface.c.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
dlls/d3dx9_36/tests/surface.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c
index 1697a03..77bd142 100644
--- a/dlls/d3dx9_36/tests/surface.c
+++ b/dlls/d3dx9_36/tests/surface.c
@@ -211,7 +211,9 @@ struct dds_header
struct dds_pixel_format pixel_format;
DWORD caps;
DWORD caps2;
- DWORD reserved2[3];
+ DWORD caps3;
+ DWORD caps4;
+ DWORD reserved2;
};
/* fills dds_header with reasonable default values */
@@ -1231,6 +1233,7 @@ static void test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9 *device)
RECT rect;
ID3DXBuffer *buffer;
IDirect3DSurface9 *surface;
+ struct dds_header *header;
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 4, 4, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &surface, NULL);
if (FAILED(hr)) {
@@ -1248,6 +1251,35 @@ static void test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9 *device)
ID3DXBuffer_Release(buffer);
}
+ SetRect(&rect, 0, 0, 0, 0);
+ hr = D3DXSaveSurfaceToFileInMemory(&buffer, D3DXIFF_DDS, surface, NULL, &rect);
+ todo_wine ok(hr == D3D_OK || broken(hr == D3DERR_INVALIDCALL), "D3DXSaveSurfaceToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
+ if (SUCCEEDED(hr)) {
+ header = ID3DXBuffer_GetBufferPointer(buffer);
+
+ ok(header->magic == MAKEFOURCC('D','D','S',' '), "Invalid DDS signature\n");
+ todo_wine ok(header->size == 124, "Invalid DDS size %d\n", header->size);
+ ok(header->height == 0, "Wrong height %d\n", header->height);
+ ok(header->width == 0, "Wrong width %d\n", header->width);
+ ok(header->flags == (DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | DDS_PIXELFORMAT),
+ "Wrong flags %x\n", header->flags);
+ ID3DXBuffer_Release(buffer);
+ }
+
+ hr = D3DXSaveSurfaceToFileInMemory(&buffer, D3DXIFF_DDS, surface, NULL, NULL);
+ ok(hr == D3D_OK || broken(hr == D3DERR_INVALIDCALL), "D3DXSaveSurfaceToFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
+ if (SUCCEEDED(hr)) {
+ header = ID3DXBuffer_GetBufferPointer(buffer);
+
+ ok(header->magic == MAKEFOURCC('D','D','S',' '), "Invalid DDS signature\n");
+ todo_wine ok(header->size == 124, "Invalid DDS size %d\n", header->size);
+ ok(header->height == 4, "Wrong height %d\n", header->height);
+ ok(header->width == 4, "Wrong width %d\n", header->width);
+ todo_wine ok(header->flags == (DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | DDS_PIXELFORMAT),
+ "Wrong flags %x\n", header->flags);
+ ID3DXBuffer_Release(buffer);
+ }
+
IDirect3DSurface9_Release(surface);
}
--
2.6.2

View File

@ -1,4 +1,4 @@
From 226f9f6bd5622c18ec4ab78f3b71ef205a550d16 Mon Sep 17 00:00:00 2001
From 88f02c608de86c125cbddd543c34ea2bfce30993 Mon Sep 17 00:00:00 2001
From: Christian Costa <titan.costa@gmail.com>
Date: Sun, 11 Jan 2015 16:09:43 +0100
Subject: d3dx9_36: Fix several issues in save_dds_surface_to_memory.
@ -9,8 +9,9 @@ The different fixes are:
- Fix DDS_WIDTH define to correct value 4
- Do not set depth and miplevels fields as their flags are not set (to match native)
---
dlls/d3dx9_36/surface.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
dlls/d3dx9_36/surface.c | 7 +++----
dlls/d3dx9_36/tests/surface.c | 2 +-
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index b8bb710..6f6132c 100644
@ -33,6 +34,19 @@ index b8bb710..6f6132c 100644
header->caps = DDS_CAPS_TEXTURE;
hr = d3dformat_to_dds_pixel_format(&header->pixel_format, src_desc.Format);
if (FAILED(hr))
diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c
index 77bd142..f04fa67 100644
--- a/dlls/d3dx9_36/tests/surface.c
+++ b/dlls/d3dx9_36/tests/surface.c
@@ -1272,7 +1272,7 @@ static void test_D3DXSaveSurfaceToFileInMemory(IDirect3DDevice9 *device)
header = ID3DXBuffer_GetBufferPointer(buffer);
ok(header->magic == MAKEFOURCC('D','D','S',' '), "Invalid DDS signature\n");
- todo_wine ok(header->size == 124, "Invalid DDS size %d\n", header->size);
+ ok(header->size == 124, "Invalid DDS size %d\n", header->size);
ok(header->height == 4, "Wrong height %d\n", header->height);
ok(header->width == 4, "Wrong width %d\n", header->width);
todo_wine ok(header->flags == (DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | DDS_PIXELFORMAT),
--
2.5.0
2.6.2

View File

@ -2587,13 +2587,15 @@ fi
# | * [#26898] Support for DDS file format in D3DXSaveTextureToFileInMemory
# |
# | Modified files:
# | * dlls/d3dx9_36/d3dx9_36_private.h, dlls/d3dx9_36/surface.c, dlls/d3dx9_36/texture.c
# | * dlls/d3dx9_36/d3dx9_36_private.h, dlls/d3dx9_36/surface.c, dlls/d3dx9_36/tests/surface.c, dlls/d3dx9_36/texture.c
# |
if test "$enable_d3dx9_36_DDS" -eq 1; then
patch_apply d3dx9_36-DDS/0001-d3dx9_36-Fix-several-issues-in-save_dds_surface_to_m.patch
patch_apply d3dx9_36-DDS/0002-d3dx9_36-Add-support-for-FOURCC-surface-to-save_dds_.patch
patch_apply d3dx9_36-DDS/0003-d3dx9_36-Improve-D3DXSaveTextureToFile-to-save-simpl.patch
patch_apply d3dx9_36-DDS/0001-d3dx9_36-tests-Add-D3DXSaveSurfaceToFileInMemory-D3D.patch
patch_apply d3dx9_36-DDS/0002-d3dx9_36-Fix-several-issues-in-save_dds_surface_to_m.patch
patch_apply d3dx9_36-DDS/0003-d3dx9_36-Add-support-for-FOURCC-surface-to-save_dds_.patch
patch_apply d3dx9_36-DDS/0004-d3dx9_36-Improve-D3DXSaveTextureToFile-to-save-simpl.patch
(
echo '+ { "Alistair Leslie-Hughes", "d3dx9_36/tests: Add D3DXSaveSurfaceToFileInMemory D3DXIFF_DDS tests.", 1 },';
echo '+ { "Christian Costa", "d3dx9_36: Fix several issues in save_dds_surface_to_memory.", 1 },';
echo '+ { "Christian Costa", "d3dx9_36: Add support for FOURCC surface to save_dds_surface_to_memory.", 1 },';
echo '+ { "Christian Costa", "d3dx9_36: Improve D3DXSaveTextureToFile to save simple texture to dds file.", 1 },';