As tests showed, DirectDraw, Direct3D 8 and 9 always use the adapter
specified in the device creation parameters regardless of the device
window position when creating a swapchain. Whereas DXGI uses the device
window position to determine which DXGI output to use.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/d3d8/device.c | 21 +++++++++++++------
dlls/d3d9/device.c | 21 ++++++++++++-------
dlls/ddraw/ddraw.c | 1 +
dlls/dxgi/device.c | 45 ++++++++++++++++++++++++++++++++++++++--
dlls/dxgi/dxgi_private.h | 4 +++-
dlls/dxgi/swapchain.c | 33 +++++++++++++++++++++++++----
dlls/dxgi/utils.c | 8 +++++--
dlls/wined3d/device.c | 1 +
dlls/wined3d/swapchain.c | 14 +++----------
include/wine/wined3d.h | 1 +
10 files changed, 116 insertions(+), 33 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index d3a88acc35d..f4bdb748275 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -262,8 +262,8 @@ static enum wined3d_multisample_type wined3d_multisample_type_from_d3d(D3DMULTIS
return (enum wined3d_multisample_type)type;
}
-static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapchain_desc *swapchain_desc,
- const D3DPRESENT_PARAMETERS *present_parameters)
+static BOOL wined3d_swapchain_desc_from_d3d8(struct wined3d_swapchain_desc *swapchain_desc,
+ struct wined3d_output *output, const D3DPRESENT_PARAMETERS *present_parameters)
{
if (!present_parameters->SwapEffect || present_parameters->SwapEffect > D3DSWAPEFFECT_COPY_VSYNC)
{
@@ -293,6 +293,7 @@ static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapch
return FALSE;
}
+ swapchain_desc->output = output;
swapchain_desc->backbuffer_width = present_parameters->BackBufferWidth;
swapchain_desc->backbuffer_height = present_parameters->BackBufferHeight;
swapchain_desc->backbuffer_format = wined3dformat_from_d3dformat(present_parameters->BackBufferFormat);
@@ -846,6 +847,7 @@ static HRESULT WINAPI d3d8_device_CreateAdditionalSwapChain(IDirect3DDevice8 *if
struct wined3d_swapchain_desc desc;
struct d3d8_swapchain *object;
unsigned int swap_interval;
+ unsigned int output_idx;
unsigned int i, count;
HRESULT hr;
@@ -876,7 +878,9 @@ static HRESULT WINAPI d3d8_device_CreateAdditionalSwapChain(IDirect3DDevice8 *if
}
wined3d_mutex_unlock();
- if (!wined3d_swapchain_desc_from_present_parameters(&desc, present_parameters))
+ output_idx = device->adapter_ordinal;
+ if (!wined3d_swapchain_desc_from_d3d8(&desc, device->d3d_parent->wined3d_outputs[output_idx],
+ present_parameters))
return D3DERR_INVALIDCALL;
swap_interval = wined3dswapinterval_from_d3d(present_parameters->FullScreen_PresentationInterval);
if (SUCCEEDED(hr = d3d8_swapchain_create(device, &desc, swap_interval, &object)))
@@ -941,6 +945,7 @@ static HRESULT WINAPI d3d8_device_Reset(IDirect3DDevice8 *iface,
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
struct wined3d_swapchain_desc swapchain_desc;
struct d3d8_swapchain *implicit_swapchain;
+ unsigned int output_idx;
HRESULT hr;
TRACE("iface %p, present_parameters %p.\n", iface, present_parameters);
@@ -950,7 +955,9 @@ static HRESULT WINAPI d3d8_device_Reset(IDirect3DDevice8 *iface,
WARN("App not active, returning D3DERR_DEVICELOST.\n");
return D3DERR_DEVICELOST;
}
- if (!wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, present_parameters))
+ output_idx = device->adapter_ordinal;
+ if (!wined3d_swapchain_desc_from_d3d8(&swapchain_desc,
+ device->d3d_parent->wined3d_outputs[output_idx], present_parameters))
return D3DERR_INVALIDCALL;
swapchain_desc.flags |= WINED3D_SWAPCHAIN_IMPLICIT;
@@ -3718,6 +3725,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
struct wined3d_swapchain_desc swapchain_desc;
struct wined3d_swapchain *wined3d_swapchain;
struct wined3d_adapter *wined3d_adapter;
+ struct wined3d_output *wined3d_output;
struct d3d8_swapchain *d3d_swapchain;
struct wined3d_caps caps;
unsigned int output_idx;
@@ -3750,7 +3758,8 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
if (!(flags & D3DCREATE_FPU_PRESERVE)) setup_fpu();
wined3d_mutex_lock();
- wined3d_adapter = wined3d_output_get_adapter(parent->wined3d_outputs[output_idx]);
+ wined3d_output = parent->wined3d_outputs[output_idx];
+ wined3d_adapter = wined3d_output_get_adapter(wined3d_output);
if (FAILED(hr = wined3d_device_create(wined3d, wined3d_adapter, wined3d_device_type_from_d3d(device_type),
focus_window, flags, 4, feature_levels, ARRAY_SIZE(feature_levels),
&device->device_parent, &device->wined3d_device)))
@@ -3792,7 +3801,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
if (flags & D3DCREATE_MULTITHREADED)
wined3d_device_set_multithreaded(device->wined3d_device);
- if (!wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, parameters))
+ if (!wined3d_swapchain_desc_from_d3d8(&swapchain_desc, wined3d_output, parameters))
{
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 61aee971a1d..2ee582b4c54 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -300,8 +300,9 @@ static enum wined3d_swap_interval wined3dswapinterval_from_d3d(DWORD interval)
}
}
-static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapchain_desc *swapchain_desc,
- const D3DPRESENT_PARAMETERS *present_parameters, BOOL extended)
+static BOOL wined3d_swapchain_desc_from_d3d9(struct wined3d_swapchain_desc *swapchain_desc,
+ struct wined3d_output *output, const D3DPRESENT_PARAMETERS *present_parameters,
+ BOOL extended)
{
D3DSWAPEFFECT highest_swapeffect = extended ? D3DSWAPEFFECT_FLIPEX : D3DSWAPEFFECT_COPY;
UINT highest_bb_count = extended ? 30 : 3;
@@ -332,6 +333,7 @@ static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapch
return FALSE;
}
+ swapchain_desc->output = output;
swapchain_desc->backbuffer_width = present_parameters->BackBufferWidth;
swapchain_desc->backbuffer_height = present_parameters->BackBufferHeight;
swapchain_desc->backbuffer_format = wined3dformat_from_d3dformat(present_parameters->BackBufferFormat);
@@ -887,6 +889,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_CreateAdditionalSwapChain(ID
struct wined3d_swapchain_desc desc;
struct d3d9_swapchain *object;
unsigned int swap_interval;
+ unsigned int output_idx;
unsigned int i, count;
HRESULT hr;
@@ -917,8 +920,9 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_CreateAdditionalSwapChain(ID
}
wined3d_mutex_unlock();
- if (!wined3d_swapchain_desc_from_present_parameters(&desc, present_parameters,
- device->d3d_parent->extended))
+ output_idx = device->adapter_ordinal;
+ if (!wined3d_swapchain_desc_from_d3d9(&desc, device->d3d_parent->wined3d_outputs[output_idx],
+ present_parameters, device->d3d_parent->extended))
return D3DERR_INVALIDCALL;
swap_interval = wined3dswapinterval_from_d3d(present_parameters->PresentationInterval);
if (SUCCEEDED(hr = d3d9_swapchain_create(device, &desc, swap_interval, &object)))
@@ -1042,6 +1046,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
struct wined3d_display_mode wined3d_mode;
struct wined3d_rendertarget_view *rtv;
struct d3d9_swapchain *d3d9_swapchain;
+ unsigned int output_idx;
unsigned int i;
HRESULT hr;
@@ -1060,7 +1065,9 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
wined3d_mode.scanline_ordering = wined3d_scanline_ordering_from_d3d(mode->ScanLineOrdering);
}
- if (!wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, present_parameters, extended))
+ output_idx = device->adapter_ordinal;
+ if (!wined3d_swapchain_desc_from_d3d9(&swapchain_desc,
+ device->d3d_parent->wined3d_outputs[output_idx], present_parameters, extended))
return D3DERR_INVALIDCALL;
swapchain_desc.flags |= WINED3D_SWAPCHAIN_IMPLICIT;
@@ -4763,8 +4770,8 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
for (i = 0; i < count; ++i)
{
- if (!wined3d_swapchain_desc_from_present_parameters(&swapchain_desc[i], ¶meters[i],
- parent->extended))
+ if (!wined3d_swapchain_desc_from_d3d9(&swapchain_desc[i],
+ parent->wined3d_outputs[output_idx + i], ¶meters[i], parent->extended))
{
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 866b7089080..6f640ef422a 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -563,6 +563,7 @@ static HRESULT ddraw_attach_d3d_device(struct ddraw *ddraw, HWND window,
}
memset(&swapchain_desc, 0, sizeof(swapchain_desc));
+ swapchain_desc.output = ddraw->wined3d_output;
swapchain_desc.backbuffer_width = mode.width;
swapchain_desc.backbuffer_height = mode.height;
swapchain_desc.backbuffer_format = mode.format_id;
diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c
index 5edd431199a..5f0c40f2e47 100644
--- a/dlls/dxgi/device.c
+++ b/dlls/dxgi/device.c
@@ -427,13 +427,37 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_factory_create_swapchain(IWineDX
{
struct dxgi_device *device = impl_from_IWineDXGISwapChainFactory(iface);
struct wined3d_swapchain_desc wined3d_desc;
+ struct IDXGIOutput *containing_output;
struct d3d11_swapchain *object;
+ struct IDXGIAdapter *adapter;
HRESULT hr;
TRACE("iface %p, factory %p, window %p, desc %p, fullscreen_desc %p, output %p, swapchain %p.\n",
iface, factory, window, desc, fullscreen_desc, output, swapchain);
- if (FAILED(hr = wined3d_swapchain_desc_from_dxgi(&wined3d_desc, window, desc, fullscreen_desc)))
+ if (FAILED(hr = dxgi_get_output_from_window(factory, window, &containing_output)))
+ {
+ WARN("Failed to get output from window %p, hr %#x.\n", window, hr);
+
+ /* FIXME: As wined3d only supports one output currently, even if a window is on a
+ * non-primary output, the swapchain will use the primary output. Keep this behaviour
+ * until all outputs are correctly enumerated. Otherwise it will create a regression
+ * for applications that specify a device window on a non-primary output */
+ if (FAILED(hr = IDXGIFactory_EnumAdapters(factory, 0, &adapter)))
+ return hr;
+
+ hr = IDXGIAdapter_EnumOutputs(adapter, 0, &containing_output);
+ IDXGIAdapter_Release(adapter);
+ if (FAILED(hr))
+ return hr;
+
+ FIXME("Using the primary output for the device window that is on a non-primary output.\n");
+ }
+
+ hr = wined3d_swapchain_desc_from_dxgi(&wined3d_desc, containing_output, window, desc,
+ fullscreen_desc);
+ IDXGIOutput_Release(containing_output);
+ if (FAILED(hr))
return hr;
if (!(object = heap_alloc_zero(sizeof(*object))))
@@ -474,7 +498,10 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
struct d3d11_swapchain *swapchain;
struct dxgi_adapter *dxgi_adapter;
struct dxgi_factory *dxgi_factory;
+ struct dxgi_output *dxgi_output;
+ struct IDXGIOutput *output;
void *layer_base;
+ HWND window;
HRESULT hr;
if (!(dxgi_factory = unsafe_impl_from_IDXGIFactory(factory)))
@@ -530,11 +557,25 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
return hr;
}
+ window = dxgi_factory_get_device_window(dxgi_factory);
+ if (FAILED(hr = dxgi_get_output_from_window(factory, window, &output)))
+ {
+ ERR("Failed to get output from window %p.\n", window);
+ wined3d_device_decref(device->wined3d_device);
+ IUnknown_Release(device->child_layer);
+ wined3d_private_store_cleanup(&device->private_store);
+ wined3d_mutex_unlock();
+ return hr;
+ }
+ dxgi_output = unsafe_impl_from_IDXGIOutput(output);
+
memset(&swapchain_desc, 0, sizeof(swapchain_desc));
swapchain_desc.swap_effect = WINED3D_SWAP_EFFECT_DISCARD;
- swapchain_desc.device_window = dxgi_factory_get_device_window(dxgi_factory);
+ swapchain_desc.device_window = window;
swapchain_desc.windowed = TRUE;
swapchain_desc.flags = WINED3D_SWAPCHAIN_IMPLICIT;
+ swapchain_desc.output = dxgi_output->wined3d_output;
+ IDXGIOutput_Release(output);
if (!(swapchain = heap_alloc_zero(sizeof(*swapchain))))
{
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index 117fe5e692c..a125a7667d9 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -96,8 +96,10 @@ void wined3d_display_mode_from_dxgi1(struct wined3d_display_mode *wined3d_mode,
DXGI_USAGE dxgi_usage_from_wined3d_bind_flags(unsigned int wined3d_bind_flags) DECLSPEC_HIDDEN;
unsigned int wined3d_bind_flags_from_dxgi_usage(DXGI_USAGE usage) DECLSPEC_HIDDEN;
unsigned int dxgi_swapchain_flags_from_wined3d(unsigned int wined3d_flags) DECLSPEC_HIDDEN;
+HRESULT dxgi_get_output_from_window(IDXGIFactory *factory, HWND window, IDXGIOutput **dxgi_output)
+ DECLSPEC_HIDDEN;
HRESULT wined3d_swapchain_desc_from_dxgi(struct wined3d_swapchain_desc *wined3d_desc,
- HWND window, const DXGI_SWAP_CHAIN_DESC1 *dxgi_desc,
+ IDXGIOutput *dxgi_containing_output, HWND window, const DXGI_SWAP_CHAIN_DESC1 *dxgi_desc,
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *dxgi_fullscreen_desc) DECLSPEC_HIDDEN;
HRESULT dxgi_get_private_data(struct wined3d_private_store *store,
diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c
index 81ba50942ad..5351c69cdd0 100644
--- a/dlls/dxgi/swapchain.c
+++ b/dlls/dxgi/swapchain.c
@@ -111,8 +111,7 @@ BOOL dxgi_validate_swapchain_desc(const DXGI_SWAP_CHAIN_DESC1 *desc)
return TRUE;
}
-static HRESULT dxgi_get_output_from_window(IDXGIFactory *factory, HWND window,
- IDXGIOutput **dxgi_output)
+HRESULT dxgi_get_output_from_window(IDXGIFactory *factory, HWND window, IDXGIOutput **dxgi_output)
{
unsigned int adapter_idx, output_idx;
DXGI_OUTPUT_DESC desc;
@@ -415,6 +414,7 @@ static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH d3d11_swapchain_SetFullscreen
struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface);
struct wined3d_swapchain_desc swapchain_desc;
struct wined3d_swapchain_state *state;
+ struct dxgi_output *dxgi_output;
HRESULT hr;
TRACE("iface %p, fullscreen %#x, target %p.\n", iface, fullscreen, target);
@@ -434,10 +434,12 @@ static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH d3d11_swapchain_SetFullscreen
WARN("Failed to get target output for swapchain, hr %#x.\n", hr);
return hr;
}
+ dxgi_output = unsafe_impl_from_IDXGIOutput(target);
wined3d_mutex_lock();
state = wined3d_swapchain_get_state(swapchain->wined3d_swapchain);
wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &swapchain_desc);
+ swapchain_desc.output = dxgi_output->wined3d_output;
swapchain_desc.windowed = !fullscreen;
hr = dxgi_swapchain_set_fullscreen_state(state, &swapchain_desc, target);
wined3d_mutex_unlock();
@@ -2261,7 +2263,8 @@ static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH d3d12_swapchain_SetFullscreen
return hr;
}
- if (FAILED(hr = wined3d_swapchain_desc_from_dxgi(&wined3d_desc, window, swapchain_desc, fullscreen_desc)))
+ if (FAILED(hr = wined3d_swapchain_desc_from_dxgi(&wined3d_desc, target, window, swapchain_desc,
+ fullscreen_desc)))
goto fail;
wined3d_mutex_lock();
wined3d_desc.windowed = !fullscreen;
@@ -2928,6 +2931,7 @@ static HRESULT d3d12_swapchain_init(struct d3d12_swapchain *swapchain, IWineDXGI
IUnknown *device_parent;
VkInstance vk_instance;
IDXGIAdapter *adapter;
+ IDXGIOutput *output;
VkBool32 supported;
VkDevice vk_device;
VkFence vk_fence;
@@ -2970,8 +2974,29 @@ static HRESULT d3d12_swapchain_init(struct d3d12_swapchain *swapchain, IWineDXGI
if (FAILED(hr = IUnknown_QueryInterface(device_parent, &IID_IDXGIAdapter, (void **)&adapter)))
return hr;
dxgi_adapter = unsafe_impl_from_IDXGIAdapter(adapter);
+
+ if (FAILED(hr = dxgi_get_output_from_window((IDXGIFactory *)factory, window, &output)))
+ {
+ WARN("Failed to get output from window %p, hr %#x.\n", window, hr);
+
+ /* FIXME: As wined3d only supports one output currently, even if a window is on a
+ * non-primary output, the swapchain will use the primary output. Keep this behaviour
+ * until all outputs are correctly enumerated. Otherwise it will create a regression
+ * for applications that specify a device window on a non-primary output */
+ if (FAILED(hr = IDXGIAdapter_EnumOutputs(adapter, 0, &output)))
+ {
+ IDXGIAdapter_Release(adapter);
+ return hr;
+ }
+
+ FIXME("Using the primary output for the device window that is on a non-primary output.\n");
+ }
IDXGIAdapter_Release(adapter);
- if (FAILED(hr = wined3d_swapchain_desc_from_dxgi(&wined3d_desc, window, swapchain_desc, fullscreen_desc)))
+
+ hr = wined3d_swapchain_desc_from_dxgi(&wined3d_desc, output, window, swapchain_desc,
+ fullscreen_desc);
+ IDXGIOutput_Release(output);
+ if (FAILED(hr))
return hr;
if (FAILED(hr = wined3d_swapchain_state_create(&wined3d_desc, window,
dxgi_adapter->factory->wined3d, &swapchain->state)))
diff --git a/dlls/dxgi/utils.c b/dlls/dxgi/utils.c
index a32c7ee1294..ca87e3c1942 100644
--- a/dlls/dxgi/utils.c
+++ b/dlls/dxgi/utils.c
@@ -561,9 +561,12 @@ static unsigned int wined3d_swapchain_flags_from_dxgi(unsigned int flags)
return wined3d_flags;
}
-HRESULT wined3d_swapchain_desc_from_dxgi(struct wined3d_swapchain_desc *wined3d_desc, HWND window,
- const DXGI_SWAP_CHAIN_DESC1 *dxgi_desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *dxgi_fullscreen_desc)
+HRESULT wined3d_swapchain_desc_from_dxgi(struct wined3d_swapchain_desc *wined3d_desc,
+ IDXGIOutput *dxgi_containing_output, HWND window, const DXGI_SWAP_CHAIN_DESC1 *dxgi_desc,
+ const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *dxgi_fullscreen_desc)
{
+ struct dxgi_output *dxgi_output = unsafe_impl_from_IDXGIOutput(dxgi_containing_output);
+
if (dxgi_desc->Scaling != DXGI_SCALING_STRETCH)
FIXME("Ignoring scaling %#x.\n", dxgi_desc->Scaling);
if (dxgi_desc->AlphaMode != DXGI_ALPHA_MODE_IGNORE)
@@ -592,6 +595,7 @@ HRESULT wined3d_swapchain_desc_from_dxgi(struct wined3d_swapchain_desc *wined3d_
return DXGI_ERROR_INVALID_CALL;
}
+ wined3d_desc->output = dxgi_output->wined3d_output;
wined3d_desc->backbuffer_width = dxgi_desc->Width;
wined3d_desc->backbuffer_height = dxgi_desc->Height;
wined3d_desc->backbuffer_format = wined3dformat_from_dxgi_format(dxgi_desc->Format);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 1711014c8d2..cc13ab4863e 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4910,6 +4910,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
}
TRACE("New params:\n");
+ TRACE("output %p\n", swapchain_desc->output);
TRACE("backbuffer_width %u\n", swapchain_desc->backbuffer_width);
TRACE("backbuffer_height %u\n", swapchain_desc->backbuffer_height);
TRACE("backbuffer_format %s\n", debug_d3dformat(swapchain_desc->backbuffer_format));
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 466bcd95cae..3e303789f6e 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -873,7 +873,6 @@ static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struc
{
struct wined3d_resource_desc texture_desc;
struct wined3d_output_desc output_desc;
- struct wined3d_output *output;
BOOL displaymode_set = FALSE;
DWORD texture_flags = 0;
HRESULT hr = E_FAIL;
@@ -934,13 +933,7 @@ static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struc
}
else
{
- if (!(output = wined3d_swapchain_get_output(swapchain)))
- {
- ERR("Failed to get output from swapchain %p.\n", swapchain);
- goto err;
- }
-
- if (FAILED(hr = wined3d_output_get_desc(output, &output_desc)))
+ if (FAILED(hr = wined3d_output_get_desc(desc->output, &output_desc)))
{
ERR("Failed to get output description, hr %#x.\n", hr);
goto err;
@@ -996,8 +989,7 @@ static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struc
if (!desc->windowed && desc->flags & WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH)
{
/* Change the display settings */
- output = wined3d_swapchain_get_output(swapchain);
- if (!output || FAILED(hr = wined3d_output_set_display_mode(output,
+ if (FAILED(hr = wined3d_output_set_display_mode(desc->output,
&swapchain->state.d3d_mode)))
{
WARN("Failed to set display mode, hr %#x.\n", hr);
@@ -1081,7 +1073,7 @@ static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struc
err:
if (displaymode_set)
{
- if (!output || FAILED(wined3d_output_set_display_mode(output,
+ if (FAILED(wined3d_output_set_display_mode(desc->output,
&swapchain->state.original_mode)))
ERR("Failed to restore display mode.\n");
}
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index d3eb8100cd8..cfec8f10c8c 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -1756,6 +1756,7 @@ struct wined3d_adapter_identifier
struct wined3d_swapchain_desc
{
+ struct wined3d_output *output;
unsigned int backbuffer_width;
unsigned int backbuffer_height;
enum wined3d_format_id backbuffer_format;
--
2.25.1