[PATCH 1/3] dxgi: Improve d3d12_swapchain_CheckColorSpaceSupport stub.
Monster Hunter World needs this function to succeed. This behaves correctly under the assumption that the system has no HDR support, and only reports standard sRGB as supported. Signed-off-by: Philip Rebohle <philip.rebohle(a)tu-dortmund.de> --- dlls/dxgi/swapchain.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 7d15b4d48d..7a680a28e9 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -2684,10 +2684,19 @@ static UINT STDMETHODCALLTYPE d3d12_swapchain_GetCurrentBackBufferIndex(IDXGISwa static HRESULT STDMETHODCALLTYPE d3d12_swapchain_CheckColorSpaceSupport(IDXGISwapChain3 *iface, DXGI_COLOR_SPACE_TYPE colour_space, UINT *colour_space_support) { - FIXME("iface %p, colour_space %#x, colour_space_support %p stub!\n", + UINT support_flags = 0; + + FIXME("iface %p, colour_space %#x, colour_space_support %p semi-stub!\n", iface, colour_space, colour_space_support); - return E_NOTIMPL; + if (!colour_space_support) + return E_INVALIDARG; + + if (colour_space == DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709) + support_flags |= DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT; + + *colour_space_support = support_flags; + return S_OK; } static HRESULT STDMETHODCALLTYPE d3d12_swapchain_SetColorSpace1(IDXGISwapChain3 *iface, -- 2.26.0
Signed-off-by: Philip Rebohle <philip.rebohle(a)tu-dortmund.de> --- dlls/dxgi/swapchain.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 7a680a28e9..c607c71eee 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -2702,9 +2702,15 @@ static HRESULT STDMETHODCALLTYPE d3d12_swapchain_CheckColorSpaceSupport(IDXGISwa static HRESULT STDMETHODCALLTYPE d3d12_swapchain_SetColorSpace1(IDXGISwapChain3 *iface, DXGI_COLOR_SPACE_TYPE colour_space) { - FIXME("iface %p, colour_space %#x stub!\n", iface, colour_space); + FIXME("iface %p, colour_space %#x semi-stub!\n", iface, colour_space); - return E_NOTIMPL; + if (colour_space != DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709) + { + WARN("Colour space %u not supported.\n", colour_space); + return E_INVALIDARG; + } + + return S_OK; } static HRESULT STDMETHODCALLTYPE d3d12_swapchain_ResizeBuffers1(IDXGISwapChain3 *iface, -- 2.26.0
Signed-off-by: Philip Rebohle <philip.rebohle(a)tu-dortmund.de> --- dlls/dxgi/tests/dxgi.c | 109 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c index 41c1101608..0d1777304f 100644 --- a/dlls/dxgi/tests/dxgi.c +++ b/dlls/dxgi/tests/dxgi.c @@ -6309,6 +6309,114 @@ 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_color_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 color_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 = CreateWindowA("static", "dxgi_test", 0, 640, 480, 0, 0, 0, 0, 0, 0); + + 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, "Failed to create swap chain, 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); + return; + } + + for (i = 0; i < ARRAY_SIZE(color_spaces); i++) + { + support = 0xdeadbeef; + hr = IDXGISwapChain3_CheckColorSpaceSupport(swapchain3, color_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 (color_spaces[i] == DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709) + { + ok(support & DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT, + "Required color space not supported for test %u.\n", i); + } + else if (color_spaces[i] == DXGI_COLOR_SPACE_RESERVED) + ok(!support, "Invalid color space supported for test %u.\n", i); + + hr = IDXGISwapChain3_SetColorSpace1(swapchain3, color_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; @@ -6447,6 +6555,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_color_space_support); FreeLibrary(d3d12_module); } -- 2.26.0
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=69763 Your paranoid android. === build (build log) === error: patch failed: dlls/dxgi/tests/dxgi.c:6309 Task: Patch failed to apply === debiant (build log) === error: patch failed: dlls/dxgi/tests/dxgi.c:6309 Task: Patch failed to apply === debiant (build log) === error: patch failed: dlls/dxgi/tests/dxgi.c:6309 Task: Patch failed to apply
participants (2)
-
Marvin -
Philip Rebohle