1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 13:08:50 +01:00

[dxvk] Use new Version helper to deal with driver version numbers

This commit is contained in:
Philip Rebohle 2024-05-17 21:07:37 +02:00 committed by Philip Rebohle
parent 4225f35034
commit 3420cd78ac
6 changed files with 63 additions and 48 deletions

View File

@ -90,8 +90,8 @@ namespace dxvk {
d3d9FloatEmulation = D3D9FloatEmulation::Enabled; d3d9FloatEmulation = D3D9FloatEmulation::Enabled;
} else { } else {
bool hasMulz = adapter != nullptr bool hasMulz = adapter != nullptr
&& (adapter->matchesDriver(VK_DRIVER_ID_MESA_RADV, 0, 0) && (adapter->matchesDriver(VK_DRIVER_ID_MESA_RADV)
|| adapter->matchesDriver(VK_DRIVER_ID_MESA_NVK, 0, 0)); || adapter->matchesDriver(VK_DRIVER_ID_MESA_NVK));
d3d9FloatEmulation = hasMulz ? D3D9FloatEmulation::Strict : D3D9FloatEmulation::Enabled; d3d9FloatEmulation = hasMulz ? D3D9FloatEmulation::Strict : D3D9FloatEmulation::Enabled;
} }

View File

@ -415,7 +415,7 @@ namespace dxvk {
m_deviceFeatures.khrPresentWait.presentWait; m_deviceFeatures.khrPresentWait.presentWait;
// Unless we're on an Nvidia driver where these extensions are known to be broken // Unless we're on an Nvidia driver where these extensions are known to be broken
if (matchesDriver(VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0, VK_MAKE_VERSION(535, 0, 0))) { if (matchesDriver(VK_DRIVER_ID_NVIDIA_PROPRIETARY, Version(), Version(535, 0, 0))) {
enabledFeatures.khrPresentId.presentId = VK_FALSE; enabledFeatures.khrPresentId.presentId = VK_FALSE;
enabledFeatures.khrPresentWait.presentWait = VK_FALSE; enabledFeatures.khrPresentWait.presentWait = VK_FALSE;
} }
@ -430,10 +430,7 @@ namespace dxvk {
// Log feature support info an extension list // Log feature support info an extension list
Logger::info(str::format("Device properties:" Logger::info(str::format("Device properties:"
"\n Device : ", m_deviceInfo.core.properties.deviceName, "\n Device : ", m_deviceInfo.core.properties.deviceName,
"\n Driver : ", m_deviceInfo.vk12.driverName, " ", "\n Driver : ", m_deviceInfo.vk12.driverName, " ", m_deviceInfo.driverVersion.toString()));
VK_VERSION_MAJOR(m_deviceInfo.core.properties.driverVersion), ".",
VK_VERSION_MINOR(m_deviceInfo.core.properties.driverVersion), ".",
VK_VERSION_PATCH(m_deviceInfo.core.properties.driverVersion)));
Logger::info("Enabled device extensions:"); Logger::info("Enabled device extensions:");
this->logNameList(extensionNameList); this->logNameList(extensionNameList);
@ -631,9 +628,7 @@ namespace dxvk {
Logger::info(str::format("Device properties:" Logger::info(str::format("Device properties:"
"\n Device name: ", m_deviceInfo.core.properties.deviceName, "\n Device name: ", m_deviceInfo.core.properties.deviceName,
"\n Driver: ", m_deviceInfo.vk12.driverName, " ", "\n Driver: ", m_deviceInfo.vk12.driverName, " ",
VK_VERSION_MAJOR(m_deviceInfo.core.properties.driverVersion), ".", m_deviceInfo.driverVersion.toString()));
VK_VERSION_MINOR(m_deviceInfo.core.properties.driverVersion), ".",
VK_VERSION_PATCH(m_deviceInfo.core.properties.driverVersion)));
Logger::info("Enabled device extensions:"); Logger::info("Enabled device extensions:");
this->logNameList(extensionNameList); this->logNameList(extensionNameList);
@ -669,26 +664,29 @@ namespace dxvk {
bool DxvkAdapter::matchesDriver( bool DxvkAdapter::matchesDriver(
VkDriverIdKHR driver, VkDriverIdKHR driver,
uint32_t minVer, Version minVer,
uint32_t maxVer) const { Version maxVer) const {
bool driverMatches = driver == m_deviceInfo.vk12.driverID; bool driverMatches = driver == m_deviceInfo.vk12.driverID;
if (minVer) driverMatches &= m_deviceInfo.core.properties.driverVersion >= minVer; if (minVer) driverMatches &= m_deviceInfo.driverVersion >= minVer;
if (maxVer) driverMatches &= m_deviceInfo.core.properties.driverVersion < maxVer; if (maxVer) driverMatches &= m_deviceInfo.driverVersion < maxVer;
return driverMatches; return driverMatches;
} }
bool DxvkAdapter::matchesDriver(
VkDriverIdKHR driver) const {
return driver == m_deviceInfo.vk12.driverID;
}
void DxvkAdapter::logAdapterInfo() const { void DxvkAdapter::logAdapterInfo() const {
const auto deviceInfo = this->devicePropertiesExt(); const auto deviceInfo = this->devicePropertiesExt();
const auto memoryInfo = this->memoryProperties(); const auto memoryInfo = this->memoryProperties();
Logger::info(str::format(deviceInfo.core.properties.deviceName, ":", Logger::info(str::format(deviceInfo.core.properties.deviceName, ":",
"\n Driver : ", deviceInfo.vk12.driverName, " ", "\n Driver : ", deviceInfo.vk12.driverName, " ", deviceInfo.driverVersion.toString()));
VK_VERSION_MAJOR(deviceInfo.core.properties.driverVersion), ".",
VK_VERSION_MINOR(deviceInfo.core.properties.driverVersion), ".",
VK_VERSION_PATCH(deviceInfo.core.properties.driverVersion)));
for (uint32_t i = 0; i < memoryInfo.memoryHeapCount; i++) { for (uint32_t i = 0; i < memoryInfo.memoryHeapCount; i++) {
constexpr VkDeviceSize mib = 1024 * 1024; constexpr VkDeviceSize mib = 1024 * 1024;
@ -790,22 +788,8 @@ namespace dxvk {
m_vki->vkGetPhysicalDeviceProperties2(m_handle, &m_deviceInfo.core); m_vki->vkGetPhysicalDeviceProperties2(m_handle, &m_deviceInfo.core);
// Some drivers reports the driver version in a slightly different format // Some drivers reports the driver version in a slightly different format
switch (m_deviceInfo.vk12.driverID) { m_deviceInfo.driverVersion = decodeDriverVersion(
case VK_DRIVER_ID_NVIDIA_PROPRIETARY: m_deviceInfo.vk12.driverID, m_deviceInfo.core.properties.driverVersion);
m_deviceInfo.core.properties.driverVersion = VK_MAKE_VERSION(
(m_deviceInfo.core.properties.driverVersion >> 22) & 0x3ff,
(m_deviceInfo.core.properties.driverVersion >> 14) & 0x0ff,
(m_deviceInfo.core.properties.driverVersion >> 6) & 0x0ff);
break;
case VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS:
m_deviceInfo.core.properties.driverVersion = VK_MAKE_VERSION(
m_deviceInfo.core.properties.driverVersion >> 14,
m_deviceInfo.core.properties.driverVersion & 0x3fff, 0);
break;
default:;
}
} }
@ -1321,4 +1305,25 @@ namespace dxvk {
"\n Sparse : ", queues.sparse != VK_QUEUE_FAMILY_IGNORED ? str::format(queues.sparse) : "n/a")); "\n Sparse : ", queues.sparse != VK_QUEUE_FAMILY_IGNORED ? str::format(queues.sparse) : "n/a"));
} }
Version DxvkAdapter::decodeDriverVersion(VkDriverId driverId, uint32_t version) {
switch (driverId) {
case VK_DRIVER_ID_NVIDIA_PROPRIETARY:
return Version(
(version >> 22) & 0x3ff,
(version >> 14) & 0x0ff,
(version >> 6) & 0x0ff);
break;
case VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS:
return Version(version >> 14, version & 0x3fff, 0);
default:
return Version(
VK_API_VERSION_MAJOR(version),
VK_API_VERSION_MINOR(version),
VK_API_VERSION_PATCH(version));
}
}
} }

View File

@ -255,8 +255,17 @@ namespace dxvk {
*/ */
bool matchesDriver( bool matchesDriver(
VkDriverIdKHR driver, VkDriverIdKHR driver,
uint32_t minVer, Version minVer,
uint32_t maxVer) const; Version maxVer) const;
/**
* \brief Tests if the driver matches certain criteria
*
* \param [in] driver Driver ID
* \returns \c True if the driver matches these criteria
*/
bool matchesDriver(
VkDriverIdKHR driver) const;
/** /**
* \brief Logs DXVK adapter info * \brief Logs DXVK adapter info
@ -343,6 +352,8 @@ namespace dxvk {
static void logFeatures(const DxvkDeviceFeatures& features); static void logFeatures(const DxvkDeviceFeatures& features);
static void logQueueFamilies(const DxvkAdapterQueueIndices& queues); static void logQueueFamilies(const DxvkAdapterQueueIndices& queues);
static Version decodeDriverVersion(VkDriverId driverId, uint32_t version);
}; };
} }

View File

@ -82,7 +82,7 @@ namespace dxvk {
// Disable lifetime tracking for drivers that do not have any // Disable lifetime tracking for drivers that do not have any
// significant issues with 32-bit address space to begin with // significant issues with 32-bit address space to begin with
if (m_adapter->matchesDriver(VK_DRIVER_ID_MESA_RADV_KHR, 0, 0)) if (m_adapter->matchesDriver(VK_DRIVER_ID_MESA_RADV_KHR))
return false; return false;
return true; return true;
@ -325,12 +325,12 @@ namespace dxvk {
DxvkDevicePerfHints DxvkDevice::getPerfHints() { DxvkDevicePerfHints DxvkDevice::getPerfHints() {
DxvkDevicePerfHints hints; DxvkDevicePerfHints hints;
hints.preferFbDepthStencilCopy = m_features.extShaderStencilExport hints.preferFbDepthStencilCopy = m_features.extShaderStencilExport
&& (m_adapter->matchesDriver(VK_DRIVER_ID_MESA_RADV_KHR, 0, 0) && (m_adapter->matchesDriver(VK_DRIVER_ID_MESA_RADV_KHR)
|| m_adapter->matchesDriver(VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR, 0, 0) || m_adapter->matchesDriver(VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR)
|| m_adapter->matchesDriver(VK_DRIVER_ID_AMD_PROPRIETARY_KHR, 0, 0)); || m_adapter->matchesDriver(VK_DRIVER_ID_AMD_PROPRIETARY_KHR));
hints.preferFbResolve = m_features.amdShaderFragmentMask hints.preferFbResolve = m_features.amdShaderFragmentMask
&& (m_adapter->matchesDriver(VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR, 0, 0) && (m_adapter->matchesDriver(VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR)
|| m_adapter->matchesDriver(VK_DRIVER_ID_AMD_PROPRIETARY_KHR, 0, 0)); || m_adapter->matchesDriver(VK_DRIVER_ID_AMD_PROPRIETARY_KHR));
return hints; return hints;
} }

View File

@ -2,6 +2,8 @@
#include "dxvk_include.h" #include "dxvk_include.h"
#include "../util/util_version.h"
namespace dxvk { namespace dxvk {
/** /**
@ -13,6 +15,7 @@ namespace dxvk {
* so before using them, check whether they are supported. * so before using them, check whether they are supported.
*/ */
struct DxvkDeviceInfo { struct DxvkDeviceInfo {
Version driverVersion;
VkPhysicalDeviceProperties2 core; VkPhysicalDeviceProperties2 core;
VkPhysicalDeviceVulkan11Properties vk11; VkPhysicalDeviceVulkan11Properties vk11;
VkPhysicalDeviceVulkan12Properties vk12; VkPhysicalDeviceVulkan12Properties vk12;

View File

@ -129,12 +129,8 @@ namespace dxvk::hud {
std::string driverInfo = props.vk12.driverInfo; std::string driverInfo = props.vk12.driverInfo;
if (driverInfo.empty()) { if (driverInfo.empty())
driverInfo = str::format( driverInfo = props.driverVersion.toString();
VK_VERSION_MAJOR(props.core.properties.driverVersion), ".",
VK_VERSION_MINOR(props.core.properties.driverVersion), ".",
VK_VERSION_PATCH(props.core.properties.driverVersion));
}
m_deviceName = props.core.properties.deviceName; m_deviceName = props.core.properties.deviceName;
m_driverName = str::format("Driver: ", props.vk12.driverName); m_driverName = str::format("Driver: ", props.vk12.driverName);