[PATCH 5/5] d3dx9: Don't forbid supported format conversions.

Matteo Bruni mbruni at codeweavers.com
Fri Jan 27 12:52:56 CST 2017


Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
It turns out I wrote this patch two times. The second time it was because
of World of Warships, where a R16F texture used for the sea waves is
converted to R32F. No idea what the first time was about, at least the
second version was a bit nicer so it wasn't for nothing...

I'm not particularly happy with the name of the two helpers but I
couldn't find anything better.

 dlls/d3dx9_36/d3dx9_private.h | 16 ++++++++++++++++
 dlls/d3dx9_36/surface.c       | 11 ++++++-----
 dlls/d3dx9_36/volume.c        |  4 ++--
 3 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h
index add73bf..9d926c7 100644
--- a/dlls/d3dx9_36/d3dx9_private.h
+++ b/dlls/d3dx9_36/d3dx9_private.h
@@ -65,6 +65,22 @@ struct pixel_format_desc {
     void (*to_rgba)(const struct vec4 *src, struct vec4 *dst, const PALETTEENTRY *palette);
 };
 
+static inline BOOL is_conversion_from_supported(const struct pixel_format_desc *format)
+{
+    if (format->type == FORMAT_ARGB || format->type == FORMAT_ARGBF16
+            || format->type == FORMAT_ARGBF)
+        return TRUE;
+    return !!format->to_rgba;
+}
+
+static inline BOOL is_conversion_to_supported(const struct pixel_format_desc *format)
+{
+    if (format->type == FORMAT_ARGB || format->type == FORMAT_ARGBF16
+            || format->type == FORMAT_ARGBF)
+        return TRUE;
+    return !!format->from_rgba;
+}
+
 HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN;
 HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN;
 
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index 1bfe75a..fc74779 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -1837,10 +1837,10 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
     }
     else /* Stretching or format conversion. */
     {
-        if (((srcformatdesc->type != FORMAT_ARGB) && (srcformatdesc->type != FORMAT_INDEX)) ||
-            (destformatdesc->type != FORMAT_ARGB))
+        if (!is_conversion_from_supported(srcformatdesc)
+                || !is_conversion_to_supported(destformatdesc))
         {
-            FIXME("Format conversion missing %#x -> %#x\n", src_format, surfdesc.Format);
+            FIXME("Unsupported format conversion %#x -> %#x.\n", src_format, surfdesc.Format);
             return E_NOTIMPL;
         }
 
@@ -2112,9 +2112,10 @@ 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->type != FORMAT_ARGB || dst_format_desc->type != FORMAT_ARGB)
+            if (!is_conversion_from_supported(src_format_desc)
+                    || !is_conversion_to_supported(dst_format_desc))
             {
-                FIXME("Unsupported pixel format conversion %#x -> %#x\n",
+                FIXME("Unsupported format conversion %#x -> %#x.\n",
                     src_surface_desc.Format, d3d_pixel_format);
                 hr = E_NOTIMPL;
                 goto cleanup;
diff --git a/dlls/d3dx9_36/volume.c b/dlls/d3dx9_36/volume.c
index 7dc61cf..f07e552 100644
--- a/dlls/d3dx9_36/volume.c
+++ b/dlls/d3dx9_36/volume.c
@@ -188,8 +188,8 @@ HRESULT WINAPI D3DXLoadVolumeFromMemory(IDirect3DVolume9 *dst_volume,
         const BYTE *src_addr;
 
 
-        if (((src_format_desc->type != FORMAT_ARGB) && (src_format_desc->type != FORMAT_INDEX)) ||
-            (dst_format_desc->type != FORMAT_ARGB))
+        if (!is_conversion_from_supported(src_format_desc)
+                || !is_conversion_to_supported(dst_format_desc))
         {
             FIXME("Pixel format conversion is not implemented %#x -> %#x\n",
                     src_format_desc->format, dst_format_desc->format);
-- 
2.10.2




More information about the wine-patches mailing list