From fcaab6aa46e6aa5e1152527c28a91817adcf775e Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sat, 6 Feb 2021 08:57:32 +0000 Subject: [PATCH] [d3d9] Expose adapter/backbuffer formats properly Matches native behaviour in my testing. --- src/d3d9/d3d9_adapter.cpp | 12 ++++++------ src/d3d9/d3d9_device.cpp | 4 +--- src/d3d9/d3d9_monitor.cpp | 18 ++++++++++++++++-- src/d3d9/d3d9_monitor.h | 8 +++++--- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/d3d9/d3d9_adapter.cpp b/src/d3d9/d3d9_adapter.cpp index 24aeac6b8..a46e46ac4 100644 --- a/src/d3d9/d3d9_adapter.cpp +++ b/src/d3d9/d3d9_adapter.cpp @@ -90,10 +90,10 @@ namespace dxvk { D3D9Format AdapterFormat, D3D9Format BackBufferFormat, BOOL bWindowed) { - if (!IsSupportedAdapterFormat(AdapterFormat, bWindowed) && !bWindowed) + if (!IsSupportedAdapterFormat(AdapterFormat)) return D3DERR_NOTAVAILABLE; - if (!IsSupportedBackBufferFormat(BackBufferFormat, bWindowed)) + if (!IsSupportedBackBufferFormat(AdapterFormat, BackBufferFormat, bWindowed)) return D3DERR_NOTAVAILABLE; return D3D_OK; @@ -106,7 +106,7 @@ namespace dxvk { DWORD Usage, D3DRESOURCETYPE RType, D3D9Format CheckFormat) { - if (!IsSupportedAdapterFormat(AdapterFormat, false)) + if (!IsSupportedAdapterFormat(AdapterFormat)) return D3DERR_NOTAVAILABLE; const bool dmap = Usage & D3DUSAGE_DMAP; @@ -232,7 +232,7 @@ namespace dxvk { D3DDEVTYPE DeviceType, D3D9Format SourceFormat, D3D9Format TargetFormat) { - bool sourceSupported = IsSupportedBackBufferFormat(SourceFormat, FALSE); + bool sourceSupported = IsSupportedBackBufferFormat(D3D9Format::Unknown, SourceFormat, TRUE); bool targetSupported = TargetFormat == D3D9Format::X1R5G5B5 || TargetFormat == D3D9Format::A1R5G5B5 || TargetFormat == D3D9Format::R5G6B5 @@ -757,7 +757,7 @@ namespace dxvk { m_modeCacheFormat = Format; // Skip unsupported formats - if (!IsSupportedAdapterFormat(Format, false)) + if (!IsSupportedAdapterFormat(Format)) return; auto& options = m_parent->GetOptions(); @@ -808,4 +808,4 @@ namespace dxvk { }); } -} \ No newline at end of file +} diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 754010496..16874d4a9 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -6873,9 +6873,7 @@ namespace dxvk { " - Windowed: ", pPresentationParameters->Windowed ? "true" : "false", "\n")); if (backBufferFmt != D3D9Format::Unknown) { - if (!IsSupportedBackBufferFormat( - backBufferFmt, - pPresentationParameters->Windowed)) { + if (!IsSupportedBackBufferFormat(backBufferFmt)) { Logger::err(str::format("D3D9DeviceEx::ResetSwapChain: Unsupported backbuffer format: ", EnumerateFormat(pPresentationParameters->BackBufferFormat))); return D3DERR_INVALIDCALL; diff --git a/src/d3d9/d3d9_monitor.cpp b/src/d3d9/d3d9_monitor.cpp index 94a3da927..8a5656cdd 100644 --- a/src/d3d9/d3d9_monitor.cpp +++ b/src/d3d9/d3d9_monitor.cpp @@ -26,8 +26,7 @@ namespace dxvk { bool IsSupportedAdapterFormat( - D3D9Format Format, - BOOL Windowed) { + D3D9Format Format) { return Format == D3D9Format::A2R10G10B10 || Format == D3D9Format::X8R8G8B8 || Format == D3D9Format::X1R5G5B5 @@ -36,8 +35,23 @@ namespace dxvk { bool IsSupportedBackBufferFormat( + D3D9Format AdapterFormat, D3D9Format BackBufferFormat, BOOL Windowed) { + if (!Windowed) { + return (AdapterFormat == D3D9Format::A2R10G10B10 && BackBufferFormat == D3D9Format::A2R10G10B10) || + (AdapterFormat == D3D9Format::X8R8G8B8 && BackBufferFormat == D3D9Format::X8R8G8B8) || + (AdapterFormat == D3D9Format::X8R8G8B8 && BackBufferFormat == D3D9Format::A8R8G8B8) || + (AdapterFormat == D3D9Format::X1R5G5B5 && BackBufferFormat == D3D9Format::X1R5G5B5) || + (AdapterFormat == D3D9Format::X1R5G5B5 && BackBufferFormat == D3D9Format::A1R5G5B5) || + (AdapterFormat == D3D9Format::R5G6B5 && BackBufferFormat == D3D9Format::R5G6B5); + } + + return IsSupportedBackBufferFormat(BackBufferFormat); + } + + bool IsSupportedBackBufferFormat( + D3D9Format BackBufferFormat) { return BackBufferFormat == D3D9Format::A2R10G10B10 || BackBufferFormat == D3D9Format::A8R8G8B8 || BackBufferFormat == D3D9Format::X8R8G8B8 diff --git a/src/d3d9/d3d9_monitor.h b/src/d3d9/d3d9_monitor.h index 8c187513b..0a9d1a89d 100644 --- a/src/d3d9/d3d9_monitor.h +++ b/src/d3d9/d3d9_monitor.h @@ -23,11 +23,13 @@ namespace dxvk { * \returns If it is supported as a swapchain/backbuffer format. */ bool IsSupportedAdapterFormat( - D3D9Format Format, - BOOL Windowed); + D3D9Format Format); bool IsSupportedBackBufferFormat( + D3D9Format AdapterFormat, D3D9Format BackBufferFormat, BOOL Windowed); -} \ No newline at end of file + bool IsSupportedBackBufferFormat( + D3D9Format BackBufferFormat); +}