Added patch to implement support for DDS file format in D3DXSaveTextureToFileInMemory.

This commit is contained in:
Sebastian Lackner 2015-01-12 19:03:14 +01:00
parent a6b41279d8
commit ecd57240d0
7 changed files with 237 additions and 0 deletions

View File

@ -37,6 +37,11 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
===================================
**Bugfixes and features included in the next upcoming release [1]:**
* Support for DDS file format in D3DXSaveTextureToFileInMemory ([Wine Bug #26898](https://bugs.winehq.org/show_bug.cgi?id=26898))
**Bugs fixed in Wine Staging 1.7.34-1 [135]:**
* ATL IOCS data should not be stored in GWLP_USERDATA ([Wine Bug #21767](https://bugs.winehq.org/show_bug.cgi?id=21767))

1
debian/changelog vendored
View File

@ -1,5 +1,6 @@
wine-staging (1.7.35) UNRELEASED; urgency=low
* Add support for Gentoo epatch backend to patchinstall.sh.
* Added patch to implement support for DDS file format in D3DXSaveTextureToFileInMemory.
-- Sebastian Lackner <sebastian@fds-team.de> Mon, 12 Jan 2015 13:06:22 +0100
wine-staging (1.7.34-1) unstable; urgency=low

View File

@ -0,0 +1,47 @@
From 85bb1e11795df868ab19f6b40b07036f2922eba4 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 | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index f187031..ae10adc 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -77,7 +77,7 @@ static const GUID *d3dformat_to_wic_guid(D3DFORMAT format)
/* dds_header.flags */
#define DDS_CAPS 0x1
#define DDS_HEIGHT 0x2
-#define DDS_WIDTH 0x2
+#define DDS_WIDTH 0x4
#define DDS_PITCH 0x8
#define DDS_PIXELFORMAT 0x1000
#define DDS_MIPMAPCOUNT 0x20000
@@ -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))
--
2.2.1

View File

@ -0,0 +1,43 @@
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

View File

@ -0,0 +1,117 @@
From 560676d5a7e14b73de4a1be6e47ee37754c0c331 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
file.
---
dlls/d3dx9_36/d3dx9_36_private.h | 2 ++
dlls/d3dx9_36/surface.c | 62 ++++++++++++++++++++++++++++++++++++++++
dlls/d3dx9_36/texture.c | 5 +---
3 files changed, 65 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_36_private.h b/dlls/d3dx9_36/d3dx9_36_private.h
index 79f3b76..41bed31 100644
--- a/dlls/d3dx9_36/d3dx9_36_private.h
+++ b/dlls/d3dx9_36/d3dx9_36_private.h
@@ -97,6 +97,8 @@ 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 save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture,
+ const PALETTEENTRY *src_palette) DECLSPEC_HIDDEN;
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
--- 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
return D3D_OK;
}
+static HRESULT get_surface(D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex,
+ int face, UINT level, struct IDirect3DSurface9 **surf)
+{
+ switch (type)
+ {
+ case D3DRTYPE_TEXTURE:
+ return IDirect3DTexture9_GetSurfaceLevel((IDirect3DTexture9*) tex, level, surf);
+ case D3DRTYPE_CUBETEXTURE:
+ return IDirect3DCubeTexture9_GetCubeMapSurface((IDirect3DCubeTexture9*) tex, face, level, surf);
+ default:
+ ERR("Unexpected texture type\n");
+ return E_NOTIMPL;
+ }
+}
+
+HRESULT save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
+{
+ HRESULT hr;
+ D3DRESOURCETYPE type;
+ UINT mip_levels;
+ IDirect3DSurface9 *surface;
+
+ type = IDirect3DBaseTexture9_GetType(src_texture);
+
+ if ((type != D3DRTYPE_TEXTURE) && (type != D3DRTYPE_CUBETEXTURE) && (type != D3DRTYPE_VOLUMETEXTURE))
+ return D3DERR_INVALIDCALL;
+
+ if (type == D3DRTYPE_CUBETEXTURE)
+ {
+ FIXME("Cube texture not supported yet\n");
+ return E_NOTIMPL;
+ }
+ else if (type == D3DRTYPE_VOLUMETEXTURE)
+ {
+ FIXME("Volume texture not supported yet\n");
+ return E_NOTIMPL;
+ }
+
+ mip_levels = IDirect3DTexture9_GetLevelCount(src_texture);
+
+ if (mip_levels > 1)
+ {
+ FIXME("Mipmap not supported yet\n");
+ return E_NOTIMPL;
+ }
+
+ if (src_palette)
+ {
+ FIXME("Saving surfaces with palettized pixel formats not implemented yet\n");
+ return E_NOTIMPL;
+ }
+
+ hr = get_surface(type, src_texture, D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface);
+
+ if (SUCCEEDED(hr))
+ {
+ hr = save_dds_surface_to_memory(dst_buffer, surface, NULL);
+ IDirect3DSurface9_Release(surface);
+ }
+
+ return hr;
+}
HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette,
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
--- a/dlls/d3dx9_36/texture.c
+++ b/dlls/d3dx9_36/texture.c
@@ -1873,10 +1873,7 @@ HRESULT WINAPI D3DXSaveTextureToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
if (!dst_buffer || !src_texture) return D3DERR_INVALIDCALL;
if (file_format == D3DXIFF_DDS)
- {
- FIXME("DDS file format isn't supported yet\n");
- return E_NOTIMPL;
- }
+ return save_dds_texture_to_memory(dst_buffer, src_texture, src_palette);
type = IDirect3DBaseTexture9_GetType(src_texture);
switch (type)
--
2.2.1

View File

@ -0,0 +1 @@
Fixes: [26898] Support for DDS file format in D3DXSaveTextureToFileInMemory

View File

@ -64,6 +64,7 @@ patch_enable_all ()
enable_d3d9_Surface_Refcount="$1"
enable_d3dx9_36_ConvertToIndexedBlended="$1"
enable_d3dx9_36_D3DXStubs="$1"
enable_d3dx9_36_DDS="$1"
enable_d3dx9_36_DXTn="$1"
enable_d3dx9_36_DrawText="$1"
enable_d3dx9_36_Filter_Warnings="$1"
@ -222,6 +223,9 @@ patch_enable ()
d3dx9_36-D3DXStubs)
enable_d3dx9_36_D3DXStubs="$2"
;;
d3dx9_36-DDS)
enable_d3dx9_36_DDS="$2"
;;
d3dx9_36-DXTn)
enable_d3dx9_36_DXTn="$2"
;;
@ -1086,6 +1090,25 @@ if test "$enable_d3dx9_36_D3DXStubs" -eq 1; then
) >> "$patchlist"
fi
# Patchset d3dx9_36-DDS
# |
# | This patchset fixes the following Wine bugs:
# | * [#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
# |
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
(
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 },';
) >> "$patchlist"
fi
# Patchset wined3d-DXTn
# |
# | This patchset fixes the following Wine bugs: