diff --git a/src/dxgi/dxgi_monitor.h b/src/dxgi/dxgi_monitor.h index 0c70101b2..eee6d47e2 100644 --- a/src/dxgi/dxgi_monitor.h +++ b/src/dxgi/dxgi_monitor.h @@ -5,6 +5,8 @@ #include "dxgi_interfaces.h" +#include "../wsi/wsi_monitor.h" + namespace dxvk { class DxgiSwapChain; @@ -55,4 +57,33 @@ namespace dxvk { uint32_t GetMonitorFormatBpp( DXGI_FORMAT Format); + /** + * \brief Converts a DXVK WSI display mode to a DXGI display mode + */ + inline DXGI_MODE_DESC1 ConvertDisplayMode(const wsi::WsiMode& WsiMode) { + DXGI_MODE_DESC1 dxgiMode = { }; + dxgiMode.Width = WsiMode.width; + dxgiMode.Height = WsiMode.height; + dxgiMode.RefreshRate = DXGI_RATIONAL{ WsiMode.refreshRate.numerator, WsiMode.refreshRate.denominator }; + dxgiMode.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; // FIXME + dxgiMode.ScanlineOrdering = WsiMode.interlaced ? DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST : DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE; + dxgiMode.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; + dxgiMode.Stereo = FALSE; + return dxgiMode; + } + + /** + * \brief Converts a DXGI display mode to a DXVK WSI display mode + */ + inline wsi::WsiMode ConvertDisplayMode(const DXGI_MODE_DESC1& DxgiMode) { + wsi::WsiMode wsiMode = { }; + wsiMode.width = DxgiMode.Width; + wsiMode.height = DxgiMode.Height; + wsiMode.refreshRate = wsi::WsiRational{ DxgiMode.RefreshRate.Numerator, DxgiMode.RefreshRate.Denominator }; + wsiMode.bitsPerPixel = GetMonitorFormatBpp(DxgiMode.Format); + wsiMode.interlaced = DxgiMode.ScanlineOrdering == DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST + || DxgiMode.ScanlineOrdering == DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST; + return wsiMode; + } + } \ No newline at end of file