From: Zhiyi Zhang <zzhang@codeweavers.com> So that we can get the original values of ScanlineOrdering and Scaling even when they are invalid. This is similar to how d3d12_swapchain_GetFullscreenDesc() works. --- dlls/dxgi/device.c | 2 +- dlls/dxgi/dxgi_private.h | 3 ++- dlls/dxgi/factory.c | 8 ++++++++ dlls/dxgi/swapchain.c | 18 +++--------------- dlls/dxgi/tests/dxgi.c | 4 ---- 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c index 46d252f2b67..eedcc81d845 100644 --- a/dlls/dxgi/device.c +++ b/dlls/dxgi/device.c @@ -462,7 +462,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_factory_create_swapchain(IWineDX return E_OUTOFMEMORY; } - if (FAILED(hr = d3d11_swapchain_init(object, device, &wined3d_desc))) + if (FAILED(hr = d3d11_swapchain_init(object, device, &wined3d_desc, fullscreen_desc))) { WARN("Failed to initialise swapchain, hr %#lx.\n", hr); free(object); diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index 483aac4d566..c74a80f5c22 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -180,13 +180,14 @@ struct d3d11_swapchain IWineDXGIDevice *device; IWineDXGIFactory *factory; + DXGI_SWAP_CHAIN_FULLSCREEN_DESC fullscreen_desc; IDXGIOutput *target; LONG present_count; LONG in_set_fullscreen_state; }; HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_device *device, - struct wined3d_swapchain_desc *desc); + struct wined3d_swapchain_desc *desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc); HRESULT d3d12_swapchain_create(IWineDXGIFactory *factory, ID3D12CommandQueue *queue, HWND window, const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c index ebdb42a3806..43594d14d4e 100644 --- a/dlls/dxgi/factory.c +++ b/dlls/dxgi/factory.c @@ -272,6 +272,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, IDXGIOutput *output, IDXGISwapChain1 **swapchain) { + DXGI_SWAP_CHAIN_FULLSCREEN_DESC windowed_fullscreen_desc; IWineDXGISwapChainFactory *swapchain_factory; ID3D12CommandQueue *command_queue; HRESULT hr; @@ -291,6 +292,13 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa return DXGI_ERROR_UNSUPPORTED; } + if (!fullscreen_desc) + { + memset(&windowed_fullscreen_desc, 0, sizeof(windowed_fullscreen_desc)); + windowed_fullscreen_desc.Windowed = TRUE; + fullscreen_desc = &windowed_fullscreen_desc; + } + if (!dxgi_validate_swapchain_desc(desc)) return DXGI_ERROR_INVALID_CALL; diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 5c49c7f2482..206fcd3683b 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -662,12 +662,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetFullscreenDesc(IDXGISwapChai wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &wined3d_desc); wined3d_mutex_unlock(); - FIXME("Ignoring ScanlineOrdering and Scaling.\n"); - - desc->RefreshRate.Numerator = wined3d_desc.refresh_rate; - desc->RefreshRate.Denominator = 1; - desc->ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; - desc->Scaling = DXGI_MODE_SCALING_UNSPECIFIED; + *desc = swapchain->fullscreen_desc; desc->Windowed = wined3d_desc.windowed; return S_OK; @@ -989,7 +984,7 @@ static HRESULT d3d11_swapchain_create_d3d11_textures(struct d3d11_swapchain *swa } HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_device *device, - struct wined3d_swapchain_desc *desc) + struct wined3d_swapchain_desc *desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc) { struct wined3d_swapchain_state *state; BOOL fullscreen; @@ -1008,6 +1003,7 @@ HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_devi swapchain->IDXGISwapChain4_iface.lpVtbl = &d3d11_swapchain_vtbl; swapchain->state_parent.ops = &d3d11_swapchain_state_parent_ops; + swapchain->fullscreen_desc = *fullscreen_desc; swapchain->refcount = 1; wined3d_mutex_lock(); wined3d_private_store_init(&swapchain->private_store); @@ -3389,7 +3385,6 @@ HRESULT d3d12_swapchain_create(IWineDXGIFactory *factory, ID3D12CommandQueue *qu const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, IDXGISwapChain1 **swapchain) { - DXGI_SWAP_CHAIN_FULLSCREEN_DESC default_fullscreen_desc; struct D3D12_COMMAND_QUEUE_DESC queue_desc; struct d3d12_swapchain *object; ID3D12Device *device; @@ -3402,13 +3397,6 @@ HRESULT d3d12_swapchain_create(IWineDXGIFactory *factory, ID3D12CommandQueue *qu if (queue_desc.Type != D3D12_COMMAND_LIST_TYPE_DIRECT) return DXGI_ERROR_INVALID_CALL; - if (!fullscreen_desc) - { - memset(&default_fullscreen_desc, 0, sizeof(default_fullscreen_desc)); - default_fullscreen_desc.Windowed = TRUE; - fullscreen_desc = &default_fullscreen_desc; - } - if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY; diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c index de49e55ee95..96dcf7a38cd 100644 --- a/dlls/dxgi/tests/dxgi.c +++ b/dlls/dxgi/tests/dxgi.c @@ -2250,7 +2250,6 @@ static void test_create_swapchain(IUnknown *device, BOOL is_d3d12) { hr = IDXGISwapChain1_GetFullscreenDesc(swapchain1, &fullscreen_desc); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - todo_wine_if(!is_d3d12) ok(fullscreen_desc.ScanlineOrdering == creation_desc.BufferDesc.ScanlineOrdering, "Got unexpected scanline ordering %d.\n", fullscreen_desc.ScanlineOrdering); ok(fullscreen_desc.Scaling == creation_desc.BufferDesc.Scaling, @@ -2291,7 +2290,6 @@ static void test_create_swapchain(IUnknown *device, BOOL is_d3d12) { hr = IDXGISwapChain1_GetFullscreenDesc(swapchain1, &fullscreen_desc); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - todo_wine_if(!is_d3d12) ok(fullscreen_desc.ScanlineOrdering == creation_desc.BufferDesc.ScanlineOrdering, "Got unexpected scanline ordering %d.\n", fullscreen_desc.ScanlineOrdering); ok(fullscreen_desc.Scaling == creation_desc.BufferDesc.Scaling, @@ -2336,7 +2334,6 @@ static void test_create_swapchain(IUnknown *device, BOOL is_d3d12) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(fullscreen_desc.ScanlineOrdering == creation_desc.BufferDesc.ScanlineOrdering, "Got unexpected scanline ordering %d.\n", fullscreen_desc.ScanlineOrdering); - todo_wine_if(!is_d3d12) ok(fullscreen_desc.Scaling == creation_desc.BufferDesc.Scaling, "Got unexpected scanline ordering %d.\n", fullscreen_desc.ScanlineOrdering); todo_wine @@ -2377,7 +2374,6 @@ static void test_create_swapchain(IUnknown *device, BOOL is_d3d12) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(fullscreen_desc.ScanlineOrdering == creation_desc.BufferDesc.ScanlineOrdering, "Got unexpected scanline ordering %d.\n", fullscreen_desc.ScanlineOrdering); - todo_wine_if(!is_d3d12) ok(fullscreen_desc.Scaling == creation_desc.BufferDesc.Scaling, "Got unexpected scanline ordering %d.\n", fullscreen_desc.ScanlineOrdering); todo_wine -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11231