Christian Costa : d3dx9: Improve generated DDS file header.

Alexandre Julliard julliard at wine.codeweavers.com
Sat Jan 9 03:32:18 CST 2016


Module: wine
Branch: master
Commit: d2307b1ffcf9ad935376078eb1f3d8f8c6aebcb9
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d2307b1ffcf9ad935376078eb1f3d8f8c6aebcb9

Author: Christian Costa <titan.costa at gmail.com>
Date:   Tue Dec 22 18:26:32 2015 +1100

d3dx9: Improve generated DDS file header.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3dx9_36/surface.c       |  8 +++-----
 dlls/d3dx9_36/tests/surface.c | 10 +++++-----
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index b14f5e7..4fa2a76 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -487,13 +487,11 @@ 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) - FIELD_OFFSET(struct dds_header, size);
+    header->flags = DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | 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 f22bf21..183086f 100644
--- a/dlls/d3dx9_36/tests/surface.c
+++ b/dlls/d3dx9_36/tests/surface.c
@@ -1277,14 +1277,14 @@ 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 %u.\n", header->size);
+    ok(header->size == 124, "Invalid DDS size %u.\n", header->size);
     ok(header->height == 4, "Got unexpected height %u.\n", header->height);
     ok(header->width == 4, "Got unexpected width %u.\n", header->width);
-    todo_wine ok(!header->depth, "Got unexpected depth %u.\n", header->depth);
-    todo_wine ok(!header->miplevels, "Got unexpected miplevels %u.\n", header->miplevels);
-    todo_wine ok(!header->pitch_or_linear_size, "Got unexpected pitch_or_linear_size %u.\n", header->pitch_or_linear_size);
+    ok(!header->depth, "Got unexpected depth %u.\n", header->depth);
+    ok(!header->miplevels, "Got unexpected miplevels %u.\n", header->miplevels);
+    ok(!header->pitch_or_linear_size, "Got unexpected pitch_or_linear_size %u.\n", header->pitch_or_linear_size);
     todo_wine ok(header->caps == (DDS_CAPS_TEXTURE | DDSCAPS_ALPHA), "Got unexpected caps %x.\n", header->caps);
-    todo_wine ok(header->flags == (DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | DDS_PIXELFORMAT),
+    ok(header->flags == (DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | DDS_PIXELFORMAT),
             "Got unexpected flags %x.\n", header->flags);
     ID3DXBuffer_Release(buffer);
 




More information about the wine-cvs mailing list