From b03de97f1b6058723f8b4978ab023b22111621b7 Mon Sep 17 00:00:00 2001 From: WinterSnowfall Date: Sun, 23 Jun 2024 03:43:14 +0300 Subject: [PATCH] [d3d9] Expose support for D16_LOCKABLE only on AMD --- dxvk.conf | 11 +++++++++++ src/d3d9/d3d9_adapter.cpp | 4 ++-- src/d3d9/d3d9_format.cpp | 9 +++++++++ src/d3d9/d3d9_format.h | 1 + src/d3d9/d3d9_options.cpp | 1 + src/d3d9/d3d9_options.h | 3 +++ 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/dxvk.conf b/dxvk.conf index 5d552adf8..453024feb 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -570,6 +570,17 @@ # d3d9.supportX4R4G4B4 = True +# Support D16_LOCKABLE +# +# Support the D16_LOCKABLE format. +# Always enabled on AMD, or when spoofing an AMD GPU +# via customVendorId, disabled by default on Nvidia and Intel. +# +# Supported values: +# - True/False + +# d3d9.supportD16Lockable = False + # Disable A8 as a Render Target # # Disable support for A8 format render targets diff --git a/src/d3d9/d3d9_adapter.cpp b/src/d3d9/d3d9_adapter.cpp index d320dc6b2..d1fa49c47 100644 --- a/src/d3d9/d3d9_adapter.cpp +++ b/src/d3d9/d3d9_adapter.cpp @@ -227,14 +227,14 @@ namespace dxvk { if (!IsDepthFormat(DepthStencilFormat)) return D3DERR_NOTAVAILABLE; - auto dsfMapping = ConvertFormatUnfixed(DepthStencilFormat); + auto dsfMapping = GetFormatMapping(DepthStencilFormat); if (dsfMapping.FormatColor == VK_FORMAT_UNDEFINED) return D3DERR_NOTAVAILABLE; if (RenderTargetFormat == dxvk::D3D9Format::NULL_FORMAT) return D3D_OK; - auto rtfMapping = ConvertFormatUnfixed(RenderTargetFormat); + auto rtfMapping = GetFormatMapping(RenderTargetFormat); if (rtfMapping.FormatColor == VK_FORMAT_UNDEFINED) return D3DERR_NOTAVAILABLE; diff --git a/src/d3d9/d3d9_format.cpp b/src/d3d9/d3d9_format.cpp index 5ba1985ca..63a00d522 100644 --- a/src/d3d9/d3d9_format.cpp +++ b/src/d3d9/d3d9_format.cpp @@ -438,8 +438,14 @@ namespace dxvk { D3D9VkFormatTable::D3D9VkFormatTable( const Rc& adapter, const D3D9Options& options) { + + const auto& props = adapter->deviceProperties(); + uint32_t vendorId = options.customVendorId == -1 ? props.vendorID : uint32_t(options.customVendorId); + m_dfSupport = options.supportDFFormats; m_x4r4g4b4Support = options.supportX4R4G4B4; + // Only AMD supports D16_LOCKABLE natively + m_d16lockableSupport = vendorId == uint32_t(DxvkGpuVendor::Amd) ? true : options.supportD16Lockable; // AMD do not support 24-bit depth buffers on Vulkan, // so we have to fall back to a 32-bit depth format. @@ -472,6 +478,9 @@ namespace dxvk { if (Format == D3D9Format::X4R4G4B4 && !m_x4r4g4b4Support) return D3D9_VK_FORMAT_MAPPING(); + if (Format == D3D9Format::D16_LOCKABLE && !m_d16lockableSupport) + return D3D9_VK_FORMAT_MAPPING(); + if (Format == D3D9Format::DF16 && !m_dfSupport) return D3D9_VK_FORMAT_MAPPING(); diff --git a/src/d3d9/d3d9_format.h b/src/d3d9/d3d9_format.h index beff7f67a..a8927a9c1 100644 --- a/src/d3d9/d3d9_format.h +++ b/src/d3d9/d3d9_format.h @@ -217,6 +217,7 @@ namespace dxvk { bool m_dfSupport; bool m_x4r4g4b4Support; + bool m_d16lockableSupport; }; inline bool IsFourCCFormat(D3D9Format format) { diff --git a/src/d3d9/d3d9_options.cpp b/src/d3d9/d3d9_options.cpp index 4e2bfc35c..3221c29c8 100644 --- a/src/d3d9/d3d9_options.cpp +++ b/src/d3d9/d3d9_options.cpp @@ -55,6 +55,7 @@ namespace dxvk { this->maxAvailableMemory = config.getOption ("d3d9.maxAvailableMemory", 4096); this->supportDFFormats = config.getOption ("d3d9.supportDFFormats", vendorId != uint32_t(DxvkGpuVendor::Nvidia)); this->supportX4R4G4B4 = config.getOption ("d3d9.supportX4R4G4B4", true); + this->supportD16Lockable = config.getOption ("d3d9.supportD16Lockable", false); this->useD32forD24 = config.getOption ("d3d9.useD32forD24", false); this->disableA8RT = config.getOption ("d3d9.disableA8RT", false); this->invariantPosition = config.getOption ("d3d9.invariantPosition", true); diff --git a/src/d3d9/d3d9_options.h b/src/d3d9/d3d9_options.h index 3ba4e3406..6ab697ed3 100644 --- a/src/d3d9/d3d9_options.h +++ b/src/d3d9/d3d9_options.h @@ -78,6 +78,9 @@ namespace dxvk { /// Support X4R4G4B4 bool supportX4R4G4B4; + /// Support D16_LOCKABLE + bool supportD16Lockable; + /// Use D32f for D24 bool useD32forD24;