[PATCH 1/5] ddraw/tests: Only set DDSCAPS_OVERLAY if supported (try 2).

Stefan Dösinger stefan at codeweavers.com
Mon Mar 10 17:43:07 CDT 2014


VMWare apparently supports YUV formats as non-overlay formats (see
fg-win7u64* test machines). All the real hardware I have seen requires
DDSCAPS_OVERLAY for those formats.

There is no way to check format and surface type compatibility. If the
format is supported, but DDSCAPS_OVERLAY isn't, assume the driver
supports those formats without the overlay cap. If DDSCAPS_OVERLAY is
supported, use it for YUV formats.

Try 2: Don't query HEL caps. I verified that this does not cause a crash
on my usual set of Windows machines. None of them crashed, so I guess my
memory was wrong.

Properly request an OFFSCREENPLAIN surface when removing the overlay
capability.
---
 dlls/ddraw/tests/ddraw4.c | 13 +++++++++++++
 dlls/ddraw/tests/ddraw7.c | 13 +++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 5a2dba1..9dafe95 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -4043,6 +4043,8 @@ static void test_block_formats_creation(void)
     DWORD supported_fmts = 0, supported_overlay_fmts = 0;
     DWORD num_fourcc_codes = 0, *fourcc_codes;
     DDSURFACEDESC2 ddsd;
+    DDCAPS hal_caps;
+    BOOL overlay_support;
     static const struct
     {
         DWORD fourcc;
@@ -4132,6 +4134,12 @@ static void test_block_formats_creation(void)
     }
     HeapFree(GetProcessHeap(), 0, fourcc_codes);
 
+    memset(&hal_caps, 0, sizeof(hal_caps));
+    hal_caps.dwSize = sizeof(hal_caps);
+    hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, NULL);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    overlay_support = !!(hal_caps.ddsCaps.dwCaps & DDSCAPS_OVERLAY);
+
     for (i = 0; i < sizeof(formats) / sizeof(*formats); i++)
     {
         for (j = 0; j < sizeof(types) / sizeof(*types); j++)
@@ -4165,6 +4173,11 @@ static void test_block_formats_creation(void)
                     U4(ddsd).ddpfPixelFormat.dwFourCC = formats[i].fourcc;
                     ddsd.dwWidth = w;
                     ddsd.dwHeight = h;
+                    if (!overlay_support && ddsd.ddsCaps.dwCaps & DDSCAPS_OVERLAY)
+                    {
+                        ddsd.ddsCaps.dwCaps &= ~DDSCAPS_OVERLAY;
+                        ddsd.ddsCaps.dwCaps |= DDSCAPS_OFFSCREENPLAIN;
+                    }
 
                     /* TODO: Handle power of two limitations. I cannot test the pow2
                      * behavior on windows because I have no hardware that doesn't at
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 1218a21..855e3b2 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -3850,6 +3850,8 @@ static void test_block_formats_creation(void)
     DWORD supported_fmts = 0, supported_overlay_fmts = 0;
     DWORD num_fourcc_codes = 0, *fourcc_codes;
     DDSURFACEDESC2 ddsd;
+    DDCAPS hal_caps;
+    BOOL overlay_support;
     static const struct
     {
         DWORD fourcc;
@@ -3939,6 +3941,12 @@ static void test_block_formats_creation(void)
     }
     HeapFree(GetProcessHeap(), 0, fourcc_codes);
 
+    memset(&hal_caps, 0, sizeof(hal_caps));
+    hal_caps.dwSize = sizeof(hal_caps);
+    hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, NULL);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    overlay_support = !!(hal_caps.ddsCaps.dwCaps & DDSCAPS_OVERLAY);
+
     for (i = 0; i < sizeof(formats) / sizeof(*formats); i++)
     {
         for (j = 0; j < sizeof(types) / sizeof(*types); j++)
@@ -3972,6 +3980,11 @@ static void test_block_formats_creation(void)
                     U4(ddsd).ddpfPixelFormat.dwFourCC = formats[i].fourcc;
                     ddsd.dwWidth = w;
                     ddsd.dwHeight = h;
+                    if (!overlay_support && ddsd.ddsCaps.dwCaps & DDSCAPS_OVERLAY)
+                    {
+                        ddsd.ddsCaps.dwCaps &= ~DDSCAPS_OVERLAY;
+                        ddsd.ddsCaps.dwCaps |= DDSCAPS_OFFSCREENPLAIN;
+                    }
 
                     /* TODO: Handle power of two limitations. I cannot test the pow2
                      * behavior on windows because I have no hardware that doesn't at
-- 
1.8.3.2




More information about the wine-patches mailing list