Philip Rebohle : dxgi/tests: Add test for colour space support APIs.

Alexandre Julliard julliard at winehq.org
Fri Apr 17 16:12:58 CDT 2020


Module: wine
Branch: master
Commit: 2c748dea407f7e3c5874651fbec6d34c8b4bea86
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2c748dea407f7e3c5874651fbec6d34c8b4bea86

Author: Philip Rebohle <philip.rebohle at tu-dortmund.de>
Date:   Fri Apr 17 20:39:21 2020 +0430

dxgi/tests: Add test for colour space support APIs.

Signed-off-by: Philip Rebohle <philip.rebohle at tu-dortmund.de>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dxgi/tests/dxgi.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)

diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c
index 0fe247016b..32aae2567f 100644
--- a/dlls/dxgi/tests/dxgi.c
+++ b/dlls/dxgi/tests/dxgi.c
@@ -6306,6 +6306,112 @@ static void test_frame_latency_event(IUnknown *device, BOOL is_d3d12)
     ok(ref_count == !is_d3d12, "Factory has %u references left.\n", ref_count);
 }
 
+static void test_colour_space_support(IUnknown *device, BOOL is_d3d12)
+{
+    DXGI_SWAP_CHAIN_DESC1 swapchain_desc;
+    IDXGISwapChain3 *swapchain3;
+    IDXGISwapChain1 *swapchain1;
+    IDXGIFactory2 *factory2;
+    IDXGIFactory *factory;
+    ULONG ref_count;
+    unsigned int i;
+    UINT support;
+    HWND window;
+    HRESULT hr;
+
+    static const DXGI_COLOR_SPACE_TYPE colour_spaces[] =
+    {
+        DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709,
+        DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709,
+        DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P709,
+        DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P2020,
+        DXGI_COLOR_SPACE_RESERVED,
+        DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601,
+        DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601,
+        DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P601,
+        DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709,
+        DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709,
+        DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020,
+        DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020,
+        DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020,
+        DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_LEFT_P2020,
+        DXGI_COLOR_SPACE_RGB_STUDIO_G2084_NONE_P2020,
+        DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_TOPLEFT_P2020,
+        DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_TOPLEFT_P2020,
+        DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020,
+        DXGI_COLOR_SPACE_YCBCR_STUDIO_GHLG_TOPLEFT_P2020,
+        DXGI_COLOR_SPACE_YCBCR_FULL_GHLG_TOPLEFT_P2020,
+    };
+
+    get_factory(device, is_d3d12, &factory);
+
+    hr = IDXGIFactory_QueryInterface(factory, &IID_IDXGIFactory2, (void**)&factory2);
+    IDXGIFactory_Release(factory);
+    if (FAILED(hr))
+    {
+        win_skip("IDXGIFactory2 not available.\n");
+        return;
+    }
+
+    window = create_window();
+
+    swapchain_desc.Width = 640;
+    swapchain_desc.Height = 480;
+    swapchain_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+    swapchain_desc.Stereo = FALSE;
+    swapchain_desc.SampleDesc.Count = 1;
+    swapchain_desc.SampleDesc.Quality = 0;
+    swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
+    swapchain_desc.BufferCount = 2;
+    swapchain_desc.Scaling = DXGI_SCALING_STRETCH;
+    swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
+    swapchain_desc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
+    swapchain_desc.Flags = 0;
+
+    hr = IDXGIFactory2_CreateSwapChainForHwnd(factory2, device,
+            window, &swapchain_desc, NULL, NULL, &swapchain1);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDXGISwapChain1_QueryInterface(swapchain1, &IID_IDXGISwapChain3, (void**)&swapchain3);
+    IDXGISwapChain1_Release(swapchain1);
+    if (FAILED(hr))
+    {
+        win_skip("IDXGISwapChain3 not available.\n");
+        IDXGIFactory2_Release(factory2);
+        DestroyWindow(window);
+        return;
+    }
+
+    for (i = 0; i < ARRAY_SIZE(colour_spaces); ++i)
+    {
+        support = 0xdeadbeef;
+        hr = IDXGISwapChain3_CheckColorSpaceSupport(swapchain3, colour_spaces[i], &support);
+        ok(hr == S_OK, "Got unexpected hr %#x for test %u.\n", hr, i);
+        ok(!(support & ~DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT),
+                "Got unexpected support flags %#x for test %u.\n", support, i);
+
+        if (colour_spaces[i] == DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709)
+        {
+            ok(support & DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT,
+                    "Required colour space not supported for test %u.\n", i);
+        }
+        else if (colour_spaces[i] == DXGI_COLOR_SPACE_RESERVED)
+        {
+            ok(!support, "Invalid colour space supported for test %u.\n", i);
+        }
+
+        hr = IDXGISwapChain3_SetColorSpace1(swapchain3, colour_spaces[i]);
+        ok(hr == (support & DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT) ? S_OK : E_INVALIDARG,
+                "Got unexpected hr %#x for text %u.\n", hr, i);
+    }
+
+    ref_count = IDXGISwapChain3_Release(swapchain3);
+    ok(!ref_count, "Swap chain has %u references left.\n", ref_count);
+    DestroyWindow(window);
+    ref_count = IDXGIFactory2_Release(factory2);
+    ok(ref_count == !is_d3d12, "Factory has %u references left.\n", ref_count);
+}
+
 static void run_on_d3d10(void (*test_func)(IUnknown *device, BOOL is_d3d12))
 {
     IDXGIDevice *device;
@@ -6444,6 +6550,7 @@ START_TEST(dxgi)
     run_on_d3d12(test_output_ownership);
     run_on_d3d12(test_cursor_clipping);
     run_on_d3d12(test_frame_latency_event);
+    run_on_d3d12(test_colour_space_support);
 
     FreeLibrary(d3d12_module);
 }




More information about the wine-cvs mailing list