From 537bd43ea843fb1419c1a744065c79ee185767e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Thu, 4 Aug 2016 17:23:43 +0200 Subject: [PATCH] dxgi: Implement IDXGISwapChain_ResizeTarget(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/dxgi/dxgi_private.h | 4 ++++ dlls/dxgi/factory.c | 8 -------- dlls/dxgi/swapchain.c | 26 ++++++++++++++++++++++++-- dlls/dxgi/utils.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index 71488119435..987370f1d03 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -79,10 +79,14 @@ struct dxgi_device_layer /* TRACE helper functions */ const char *debug_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN; +const char *debug_dxgi_mode(const DXGI_MODE_DESC *desc) DECLSPEC_HIDDEN; void dump_feature_levels(const D3D_FEATURE_LEVEL *feature_levels, unsigned int level_count) DECLSPEC_HIDDEN; DXGI_FORMAT dxgi_format_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN; +UINT dxgi_rational_to_uint(const DXGI_RATIONAL *rational) DECLSPEC_HIDDEN; +enum wined3d_scanline_ordering wined3d_scanline_ordering_from_dxgi( + DXGI_MODE_SCANLINE_ORDER scanline_order) DECLSPEC_HIDDEN; void dxgi_sample_desc_from_wined3d(DXGI_SAMPLE_DESC *desc, enum wined3d_multisample_type wined3d_type, unsigned int wined3d_quality) DECLSPEC_HIDDEN; void wined3d_sample_desc_from_dxgi(enum wined3d_multisample_type *wined3d_type, diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c index 3aa859765f4..d54eea9cad9 100644 --- a/dlls/dxgi/factory.c +++ b/dlls/dxgi/factory.c @@ -180,14 +180,6 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_GetWindowAssociation(IDXGIFactory1 return E_NOTIMPL; } -static UINT dxgi_rational_to_uint(const DXGI_RATIONAL *rational) -{ - if (rational->Denominator) - return rational->Numerator / rational->Denominator; - else - return rational->Numerator; -} - static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory1 *iface, IUnknown *device, DXGI_SWAP_CHAIN_DESC *desc, IDXGISwapChain **swapchain) { diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 869c79920ef..172b0f4af57 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -337,9 +337,31 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain *if static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeTarget(IDXGISwapChain *iface, const DXGI_MODE_DESC *target_mode_desc) { - FIXME("iface %p, target_mode_desc %p stub!\n", iface, target_mode_desc); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct wined3d_display_mode mode; + HRESULT hr; - return E_NOTIMPL; + TRACE("iface %p, target_mode_desc %p.\n", iface, target_mode_desc); + + if (!target_mode_desc) + return DXGI_ERROR_INVALID_CALL; + + TRACE("Mode: %s.\n", debug_dxgi_mode(target_mode_desc)); + + if (target_mode_desc->Scaling) + FIXME("Ignoring scaling %#x.\n", target_mode_desc->Scaling); + + mode.width = target_mode_desc->Width; + mode.height = target_mode_desc->Height; + mode.refresh_rate = dxgi_rational_to_uint(&target_mode_desc->RefreshRate); + mode.format_id = wined3dformat_from_dxgi_format(target_mode_desc->Format); + mode.scanline_ordering = wined3d_scanline_ordering_from_dxgi(target_mode_desc->ScanlineOrdering); + + wined3d_mutex_lock(); + hr = wined3d_swapchain_resize_target(swapchain->wined3d_swapchain, &mode); + wined3d_mutex_unlock(); + + return hr; } static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetContainingOutput(IDXGISwapChain *iface, IDXGIOutput **output) diff --git a/dlls/dxgi/utils.c b/dlls/dxgi/utils.c index 5c6c5bd707b..9371de1ed43 100644 --- a/dlls/dxgi/utils.c +++ b/dlls/dxgi/utils.c @@ -364,6 +364,14 @@ enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format) } } +const char *debug_dxgi_mode(const DXGI_MODE_DESC *desc) +{ + return wine_dbg_sprintf("resolution %ux%u, refresh rate %u / %u, " + "format %s, scanline ordering %#x, scaling %#x", + desc->Width, desc->Height, desc->RefreshRate.Numerator, desc->RefreshRate.Denominator, + debug_dxgi_format(desc->Format), desc->ScanlineOrdering, desc->Scaling); +} + void dump_feature_levels(const D3D_FEATURE_LEVEL *feature_levels, unsigned int level_count) { unsigned int i; @@ -379,6 +387,28 @@ void dump_feature_levels(const D3D_FEATURE_LEVEL *feature_levels, unsigned int l TRACE(" [%u] = %s.\n", i, debug_feature_level(feature_levels[i])); } +UINT dxgi_rational_to_uint(const DXGI_RATIONAL *rational) +{ + if (rational->Denominator) + return rational->Numerator / rational->Denominator; + else + return rational->Numerator; +} + +enum wined3d_scanline_ordering wined3d_scanline_ordering_from_dxgi(DXGI_MODE_SCANLINE_ORDER scanline_order) +{ + switch (scanline_order) + { + case DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED: + return WINED3D_SCANLINE_ORDERING_UNKNOWN; + case DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE: + return WINED3D_SCANLINE_ORDERING_PROGRESSIVE; + default: + FIXME("Unhandled scanline ordering %#x.\n", scanline_order); + return WINED3D_SCANLINE_ORDERING_UNKNOWN; + } +} + void dxgi_sample_desc_from_wined3d(DXGI_SAMPLE_DESC *desc, enum wined3d_multisample_type wined3d_type, unsigned int wined3d_quality) {