From 654b517057d381903137ededd43c554ed52921a0 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Wed, 17 Aug 2022 19:43:12 +0000 Subject: [PATCH] [d3d9] Add helpers for new WSI interface --- src/d3d9/d3d9_monitor.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/d3d9/d3d9_monitor.h b/src/d3d9/d3d9_monitor.h index 0a9d1a89d..b3e7a7b79 100644 --- a/src/d3d9/d3d9_monitor.h +++ b/src/d3d9/d3d9_monitor.h @@ -4,6 +4,9 @@ #include "d3d9_format.h" +#include "../wsi/wsi_window.h" +#include "../wsi/wsi_monitor.h" + namespace dxvk { /** @@ -32,4 +35,27 @@ namespace dxvk { bool IsSupportedBackBufferFormat( D3D9Format BackBufferFormat); + + inline wsi::WsiMode ConvertDisplayMode(const D3DDISPLAYMODEEX& mode) { + wsi::WsiMode wsiMode = { }; + wsiMode.width = mode.Width; + wsiMode.height = mode.Height; + wsiMode.refreshRate = wsi::WsiRational{ mode.RefreshRate, 1 }; + wsiMode.bitsPerPixel = GetMonitorFormatBpp(EnumerateFormat(mode.Format)); + wsiMode.interlaced = mode.ScanLineOrdering == D3DSCANLINEORDERING_INTERLACED; + return wsiMode; + } + + + inline D3DDISPLAYMODEEX ConvertDisplayMode(const wsi::WsiMode& wsiMode) { + D3DDISPLAYMODEEX d3d9Mode = { }; + d3d9Mode.Size = sizeof(D3DDISPLAYMODEEX); + d3d9Mode.Width = wsiMode.width; + d3d9Mode.Height = wsiMode.height; + d3d9Mode.RefreshRate = wsiMode.refreshRate.numerator / wsiMode.refreshRate.denominator; + d3d9Mode.Format = D3DFMT_X8R8G8B8; + d3d9Mode.ScanLineOrdering = wsiMode.interlaced ? D3DSCANLINEORDERING_INTERLACED : D3DSCANLINEORDERING_PROGRESSIVE; + return d3d9Mode; + } + }