[2/5] d3dx9: Introduce a separate pixel format type for compressed pixel formats.

Józef Kucia joseph.kucia at gmail.com
Mon Oct 22 10:20:27 CDT 2012


---
 dlls/d3dx9_36/d3dx9_36_private.h |  1 +
 dlls/d3dx9_36/surface.c          | 29 ++++++++++-------------------
 dlls/d3dx9_36/util.c             | 10 +++++-----
 dlls/d3dx9_36/volume.c           |  4 +---
 4 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/dlls/d3dx9_36/d3dx9_36_private.h b/dlls/d3dx9_36/d3dx9_36_private.h
index bd208f8..a7efbee 100644
--- a/dlls/d3dx9_36/d3dx9_36_private.h
+++ b/dlls/d3dx9_36/d3dx9_36_private.h
@@ -47,6 +47,7 @@ struct volume
 /* for internal use */
 enum format_type {
     FORMAT_ARGB,   /* unsigned */
+    FORMAT_DXT,
     FORMAT_UNKNOWN
 };
 
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index daa6cfe..d49730d 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -307,7 +307,7 @@ static HRESULT calculate_dds_surface_size(D3DFORMAT format, UINT width, UINT hei
     UINT *pitch, UINT *size)
 {
     const struct pixel_format_desc *format_desc = get_format_info(format);
-    if (format_desc->format == D3DFMT_UNKNOWN)
+    if (format_desc->type == FORMAT_UNKNOWN)
         return E_NOTIMPL;
 
     if (format_desc->block_width != 1 || format_desc->block_height != 1)
@@ -460,7 +460,11 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur
     if (FAILED(hr)) return hr;
 
     pixel_format = get_format_info(src_desc.Format);
-    if (pixel_format->type == FORMAT_UNKNOWN) return E_NOTIMPL;
+    if (pixel_format->type != FORMAT_ARGB)
+    {
+        FIXME("Unsupported pixel format %#x\n", src_desc.Format);
+        return E_NOTIMPL;
+    }
 
     file_size = calculate_dds_file_size(src_desc.Format, src_desc.Width, src_desc.Height, 1, 1, 1);
 
@@ -1028,7 +1032,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
 
     formatdesc = get_format_info(imginfo.Format);
 
-    if (formatdesc->format == D3DFMT_UNKNOWN)
+    if (formatdesc->type == FORMAT_UNKNOWN)
     {
         FIXME("Unsupported pixel format\n");
         hr = D3DXERR_INVALIDDATA;
@@ -1676,15 +1680,13 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
     }
     else /* Stretching or format conversion. */
     {
-        if (srcformatdesc->bytes_per_pixel > 4 || destformatdesc->bytes_per_pixel > 4
-                || srcformatdesc->block_height != 1 || srcformatdesc->block_width != 1
-                || destformatdesc->block_height != 1 || destformatdesc->block_width != 1)
+        if (srcformatdesc->type != FORMAT_ARGB || destformatdesc->type != FORMAT_ARGB)
         {
             FIXME("Format conversion missing %#x -> %#x\n", src_format, surfdesc.Format);
             return E_NOTIMPL;
         }
 
-        if (FAILED(hr = IDirect3DSurface9_LockRect(dst_surface, &lockrect, dst_rect, 0)))
+        if (FAILED(IDirect3DSurface9_LockRect(dst_surface, &lockrect, dst_rect, 0)))
             return D3DXERR_INVALIDDATA;
 
         if ((filter & 0xf) == D3DX_FILTER_NONE)
@@ -1952,7 +1954,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
 
             src_format_desc = get_format_info(src_surface_desc.Format);
             dst_format_desc = get_format_info(d3d_pixel_format);
-            if (src_format_desc->format == D3DFMT_UNKNOWN || dst_format_desc->format == D3DFMT_UNKNOWN)
+            if (src_format_desc->type != FORMAT_ARGB || dst_format_desc->type != FORMAT_ARGB)
             {
                 FIXME("Unsupported pixel format conversion %#x -> %#x\n",
                     src_surface_desc.Format, d3d_pixel_format);
@@ -1960,17 +1962,6 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
                 goto cleanup;
             }
 
-            if (src_format_desc->bytes_per_pixel > 4
-                || dst_format_desc->bytes_per_pixel > 4
-                || src_format_desc->block_height != 1 || src_format_desc->block_width != 1
-                || dst_format_desc->block_height != 1 || dst_format_desc->block_width != 1)
-            {
-                FIXME("Format conversion missing %#x -> %#x\n",
-                        src_surface_desc.Format, d3d_pixel_format);
-                hr = E_NOTIMPL;
-                goto cleanup;
-            }
-
             size.width = width;
             size.height = height;
             size.depth = 1;
diff --git a/dlls/d3dx9_36/util.c b/dlls/d3dx9_36/util.c
index 72008a2..40972d8 100644
--- a/dlls/d3dx9_36/util.c
+++ b/dlls/d3dx9_36/util.c
@@ -65,11 +65,11 @@ static const struct pixel_format_desc formats[] =
     {D3DFMT_A4L4,        {4,  4,  0,  0}, { 4,  0,  0,  0}, 1, 1, 1,  1, FORMAT_ARGB,    la_from_rgba, la_to_rgba},
     {D3DFMT_L8,          {0,  8,  0,  0}, { 0,  0,  0,  0}, 1, 1, 1,  1, FORMAT_ARGB,    la_from_rgba, la_to_rgba},
     {D3DFMT_L16,         {0, 16,  0,  0}, { 0,  0,  0,  0}, 2, 1, 1,  2, FORMAT_ARGB,    la_from_rgba, la_to_rgba},
-    {D3DFMT_DXT1,        {0,  0,  0,  0}, { 0,  0,  0,  0}, 1, 4, 4,  8, FORMAT_ARGB,    NULL,         NULL      },
-    {D3DFMT_DXT2,        {0,  0,  0,  0}, { 0,  0,  0,  0}, 1, 4, 4, 16, FORMAT_ARGB,    NULL,         NULL      },
-    {D3DFMT_DXT3,        {0,  0,  0,  0}, { 0,  0,  0,  0}, 1, 4, 4, 16, FORMAT_ARGB,    NULL,         NULL      },
-    {D3DFMT_DXT4,        {0,  0,  0,  0}, { 0,  0,  0,  0}, 1, 4, 4, 16, FORMAT_ARGB,    NULL,         NULL      },
-    {D3DFMT_DXT5,        {0,  0,  0,  0}, { 0,  0,  0,  0}, 1, 4, 4, 16, FORMAT_ARGB,    NULL,         NULL      },
+    {D3DFMT_DXT1,        {0,  0,  0,  0}, { 0,  0,  0,  0}, 1, 4, 4,  8, FORMAT_DXT,     NULL,         NULL      },
+    {D3DFMT_DXT2,        {0,  0,  0,  0}, { 0,  0,  0,  0}, 1, 4, 4, 16, FORMAT_DXT,     NULL,         NULL      },
+    {D3DFMT_DXT3,        {0,  0,  0,  0}, { 0,  0,  0,  0}, 1, 4, 4, 16, FORMAT_DXT,     NULL,         NULL      },
+    {D3DFMT_DXT4,        {0,  0,  0,  0}, { 0,  0,  0,  0}, 1, 4, 4, 16, FORMAT_DXT,     NULL,         NULL      },
+    {D3DFMT_DXT5,        {0,  0,  0,  0}, { 0,  0,  0,  0}, 1, 4, 4, 16, FORMAT_DXT,     NULL,         NULL      },
     /* marks last element */
     {D3DFMT_UNKNOWN,     {0,  0,  0,  0}, { 0,  0,  0,  0}, 0, 1, 1,  0, FORMAT_UNKNOWN, NULL,         NULL      },
 };
diff --git a/dlls/d3dx9_36/volume.c b/dlls/d3dx9_36/volume.c
index 2becba5..f773c7f 100644
--- a/dlls/d3dx9_36/volume.c
+++ b/dlls/d3dx9_36/volume.c
@@ -195,9 +195,7 @@ HRESULT WINAPI D3DXLoadVolumeFromMemory(IDirect3DVolume9 *dst_volume,
     {
         const BYTE *src_addr;
 
-        if (src_format_desc->bytes_per_pixel > 4 || dst_format_desc->bytes_per_pixel > 4
-                || src_format_desc->block_height != 1 || src_format_desc->block_width != 1
-                || dst_format_desc->block_height != 1 || dst_format_desc->block_width != 1)
+        if (src_format_desc->type != FORMAT_ARGB || dst_format_desc->type != FORMAT_ARGB)
         {
             FIXME("Pixel format conversion not implemented %#x -> %#x\n",
                     src_format_desc->format, dst_format_desc->format);
-- 
1.7.12.4




More information about the wine-patches mailing list