Rebase against 91dd155e9bc13c1bc1be860cd67fe3e48c20feae.

This commit is contained in:
Sebastian Lackner
2016-01-09 13:36:37 +01:00
parent c891e58561
commit 11093e0bf8
13 changed files with 92 additions and 346 deletions

View File

@@ -0,0 +1,32 @@
From cfbee3f0f952769dbf663489c2a209493c7412d3 Mon Sep 17 00:00:00 2001
From: Christian Costa <titan.costa@gmail.com>
Date: Sun, 11 Jan 2015 16:18:03 +0100
Subject: d3dx9_36: Add support for FOURCC surface to
save_dds_surface_to_memory.
---
dlls/d3dx9_36/surface.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index 4fa2a76..58b676d 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -311,6 +311,14 @@ static HRESULT d3dformat_to_dds_pixel_format(struct dds_pixel_format *pixel_form
}
}
+ /* Reuse dds_fourcc_to_d3dformat as D3DFORMAT and FOURCC are DWORD with same values */
+ if (dds_fourcc_to_d3dformat(d3dformat) != D3DFMT_UNKNOWN)
+ {
+ pixel_format->flags |= DDS_PF_FOURCC;
+ pixel_format->fourcc = d3dformat;
+ return D3D_OK;
+ }
+
WARN("Unknown pixel format %#x\n", d3dformat);
return E_NOTIMPL;
}
--
2.6.4

View File

@@ -1,74 +0,0 @@
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,52 +0,0 @@
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.
The different fixes are:
- Fix header size of the DDS file
- Remove DDS_MIPMAPCOUNT as mipmap levels are not supported yet
- 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 +++----
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
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -487,13 +487,12 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur
memset(header, 0, sizeof(*header));
header->signature = MAKEFOURCC('D','D','S',' ');
- header->size = sizeof(*header);
- header->flags = DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | DDS_PITCH | DDS_PIXELFORMAT | DDS_MIPMAPCOUNT;
+ /* The signature is not really part of the DDS header */
+ header->size = sizeof(*header) - sizeof(header->signature);
+ header->flags = DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | DDS_PITCH | DDS_PIXELFORMAT;
header->height = src_desc.Height;
header->width = src_desc.Width;
header->pitch_or_linear_size = dst_pitch;
- header->depth = 1;
- header->miplevels = 1;
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.6.2

View File

@@ -1,4 +1,4 @@
From 560676d5a7e14b73de4a1be6e47ee37754c0c331 Mon Sep 17 00:00:00 2001
From f9702dad952fdc873a72b4a2781bf2171ff3f814 Mon Sep 17 00:00:00 2001
From: Christian Costa <titan.costa@gmail.com>
Date: Sun, 11 Jan 2015 16:29:30 +0100
Subject: d3dx9_36: Improve D3DXSaveTextureToFile to save simple texture to dds
@@ -24,10 +24,10 @@ index 79f3b76..41bed31 100644
unsigned short float_32_to_16(const float in) DECLSPEC_HIDDEN;
float float_16_to_32(const unsigned short in) DECLSPEC_HIDDEN;
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index 629c94c..0a9c177 100644
index 58b676d..79e8d53 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -530,6 +530,68 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur
@@ -527,6 +527,68 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur
return D3D_OK;
}
@@ -97,7 +97,7 @@ index 629c94c..0a9c177 100644
const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key,
const D3DXIMAGE_INFO *src_info)
diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c
index de42307..e062379 100644
index 38349e2..5c06700 100644
--- a/dlls/d3dx9_36/texture.c
+++ b/dlls/d3dx9_36/texture.c
@@ -1873,10 +1873,7 @@ HRESULT WINAPI D3DXSaveTextureToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
@@ -113,5 +113,5 @@ index de42307..e062379 100644
type = IDirect3DBaseTexture9_GetType(src_texture);
switch (type)
--
2.2.1
2.6.4

View File

@@ -1,43 +0,0 @@
From 26c87c400c478b878b72b9cb7d216f89a9a58d1f Mon Sep 17 00:00:00 2001
From: Christian Costa <titan.costa@gmail.com>
Date: Sun, 11 Jan 2015 16:18:03 +0100
Subject: d3dx9_36: Add support for FOURCC surface to
save_dds_surface_to_memory.
---
dlls/d3dx9_36/surface.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index ae10adc..629c94c 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -311,6 +311,14 @@ static HRESULT d3dformat_to_dds_pixel_format(struct dds_pixel_format *pixel_form
}
}
+ /* Reuse dds_fourcc_to_d3dformat as D3DFORMAT and FOURCC are DWORD with same values */
+ if (dds_fourcc_to_d3dformat(d3dformat) != D3DFMT_UNKNOWN)
+ {
+ pixel_format->flags |= DDS_PF_FOURCC;
+ pixel_format->fourcc = d3dformat;
+ return D3D_OK;
+ }
+
WARN("Unknown pixel format %#x\n", d3dformat);
return E_NOTIMPL;
}
@@ -489,7 +497,9 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur
header->signature = MAKEFOURCC('D','D','S',' ');
/* The signature is not really part of the DDS header */
header->size = sizeof(*header) - sizeof(header->signature);
- header->flags = DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | DDS_PITCH | DDS_PIXELFORMAT;
+ header->flags = DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | DDS_PIXELFORMAT;
+ /* Note that native does not set DDS_LINEARSIZE flag nor pitch_or_linear_size field for DXTn */
+ header->flags |= (pixel_format->block_width != 1) || (pixel_format->block_height != 1) ? DDS_LINEARSIZE : DDS_PITCH;
header->height = src_desc.Height;
header->width = src_desc.Width;
header->pitch_or_linear_size = dst_pitch;
--
2.2.1