diff --git a/dlls/dxgi/output.c b/dlls/dxgi/output.c index 6d7ca20dc55..0cf80841c27 100644 --- a/dlls/dxgi/output.c +++ b/dlls/dxgi/output.c @@ -228,9 +228,42 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *ifa static HRESULT STDMETHODCALLTYPE dxgi_output_FindClosestMatchingMode(IDXGIOutput *iface, const DXGI_MODE_DESC *mode, DXGI_MODE_DESC *closest_match, IUnknown *device) { - FIXME("iface %p, mode %p, closest_match %p, device %p stub!\n", iface, mode, closest_match, device); + struct dxgi_output *output = impl_from_IDXGIOutput(iface); + struct wined3d_display_mode wined3d_mode; + struct dxgi_adapter *adapter; + struct wined3d *wined3d; + HRESULT hr; - return E_NOTIMPL; + TRACE("iface %p, mode %p, closest_match %p, device %p.\n", iface, mode, closest_match, device); + + if ((!mode->Width && mode->Height) || (mode->Width && !mode->Height)) + return DXGI_ERROR_INVALID_CALL; + + if (mode->Format == DXGI_FORMAT_UNKNOWN && !device) + return DXGI_ERROR_INVALID_CALL; + + TRACE("Mode: %s.\n", debug_dxgi_mode(mode)); + if (mode->Format == DXGI_FORMAT_UNKNOWN) + { + FIXME("Matching formats to device not implemented.\n"); + return E_NOTIMPL; + } + + adapter = output->adapter; + wined3d = adapter->factory->wined3d; + + wined3d_mutex_lock(); + wined3d_display_mode_from_dxgi(&wined3d_mode, mode); + hr = wined3d_find_closest_matching_adapter_mode(wined3d, adapter->ordinal, &wined3d_mode); + wined3d_mutex_unlock(); + + if (SUCCEEDED(hr)) + { + dxgi_mode_from_wined3d(closest_match, &wined3d_mode); + TRACE("Returning %s.\n", debug_dxgi_mode(closest_match)); + } + + return hr; } static HRESULT STDMETHODCALLTYPE dxgi_output_WaitForVBlank(IDXGIOutput *iface) diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c index 23624ebed2d..8ec65e25f81 100644 --- a/dlls/dxgi/tests/device.c +++ b/dlls/dxgi/tests/device.c @@ -225,7 +225,7 @@ static void compute_expected_swapchain_fullscreen_state_after_fullscreen_change_ mode_desc.Width = new_width; mode_desc.Height = new_height; hr = IDXGIOutput_FindClosestMatchingMode(target, &mode_desc, &mode_desc, NULL); - todo_wine ok_(__FILE__, line)(SUCCEEDED(hr), "FindClosestMatchingMode failed, hr %#x.\n", hr); + ok_(__FILE__, line)(SUCCEEDED(hr), "FindClosestMatchingMode failed, hr %#x.\n", hr); new_width = mode_desc.Width; new_height = mode_desc.Height; }