[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;
} else {
bool hasMulz = adapter != nullptr
&& (adapter->matchesDriver(VK_DRIVER_ID_MESA_RADV, 0, 0)
|| adapter->matchesDriver(VK_DRIVER_ID_MESA_NVK, 0, 0));
&& (adapter->matchesDriver(VK_DRIVER_ID_MESA_RADV)
|| adapter->matchesDriver(VK_DRIVER_ID_MESA_NVK));
d3d9FloatEmulation = hasMulz ? D3D9FloatEmulation::Strict : D3D9FloatEmulation::Enabled;
}

View File

@ -415,7 +415,7 @@ namespace dxvk {
m_deviceFeatures.khrPresentWait.presentWait;
// 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.khrPresentWait.presentWait = VK_FALSE;
}
@ -430,10 +430,7 @@ namespace dxvk {
// Log feature support info an extension list
Logger::info(str::format("Device properties:"
"\n Device : ", m_deviceInfo.core.properties.deviceName,
"\n Driver : ", m_deviceInfo.vk12.driverName, " ",
VK_VERSION_MAJOR(m_deviceInfo.core.properties.driverVersion), ".",
VK_VERSION_MINOR(m_deviceInfo.core.properties.driverVersion), ".",
VK_VERSION_PATCH(m_deviceInfo.core.properties.driverVersion)));
"\n Driver : ", m_deviceInfo.vk12.driverName, " ", m_deviceInfo.driverVersion.toString()));
Logger::info("Enabled device extensions:");
this->logNameList(extensionNameList);
@ -631,9 +628,7 @@ namespace dxvk {
Logger::info(str::format("Device properties:"
"\n Device name: ", m_deviceInfo.core.properties.deviceName,
"\n Driver: ", m_deviceInfo.vk12.driverName, " ",
VK_VERSION_MAJOR(m_deviceInfo.core.properties.driverVersion), ".",
VK_VERSION_MINOR(m_deviceInfo.core.properties.driverVersion), ".",
VK_VERSION_PATCH(m_deviceInfo.core.properties.driverVersion)));
m_deviceInfo.driverVersion.toString()));
Logger::info("Enabled device extensions:");
this->logNameList(extensionNameList);
@ -669,26 +664,29 @@ namespace dxvk {
bool DxvkAdapter::matchesDriver(
VkDriverIdKHR driver,
uint32_t minVer,
uint32_t maxVer) const {
Version minVer,
Version maxVer) const {
bool driverMatches = driver == m_deviceInfo.vk12.driverID;
if (minVer) driverMatches &= m_deviceInfo.core.properties.driverVersion >= minVer;
if (maxVer) driverMatches &= m_deviceInfo.core.properties.driverVersion < maxVer;
if (minVer) driverMatches &= m_deviceInfo.driverVersion >= minVer;
if (maxVer) driverMatches &= m_deviceInfo.driverVersion < maxVer;
return driverMatches;
}
bool DxvkAdapter::matchesDriver(
VkDriverIdKHR driver) const {
return driver == m_deviceInfo.vk12.driverID;
}
void DxvkAdapter::logAdapterInfo() const {
const auto deviceInfo = this->devicePropertiesExt();
const auto memoryInfo = this->memoryProperties();
Logger::info(str::format(deviceInfo.core.properties.deviceName, ":",
"\n Driver : ", deviceInfo.vk12.driverName, " ",
VK_VERSION_MAJOR(deviceInfo.core.properties.driverVersion), ".",
VK_VERSION_MINOR(deviceInfo.core.properties.driverVersion), ".",
VK_VERSION_PATCH(deviceInfo.core.properties.driverVersion)));
"\n Driver : ", deviceInfo.vk12.driverName, " ", deviceInfo.driverVersion.toString()));
for (uint32_t i = 0; i < memoryInfo.memoryHeapCount; i++) {
constexpr VkDeviceSize mib = 1024 * 1024;
@ -790,22 +788,8 @@ namespace dxvk {
m_vki->vkGetPhysicalDeviceProperties2(m_handle, &m_deviceInfo.core);
// Some drivers reports the driver version in a slightly different format
switch (m_deviceInfo.vk12.driverID) {
case VK_DRIVER_ID_NVIDIA_PROPRIETARY:
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:;
}
m_deviceInfo.driverVersion = decodeDriverVersion(
m_deviceInfo.vk12.driverID, m_deviceInfo.core.properties.driverVersion);
}
@ -1321,4 +1305,25 @@ namespace dxvk {
"\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(
VkDriverIdKHR driver,
uint32_t minVer,
uint32_t maxVer) const;
Version minVer,
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
@ -343,6 +352,8 @@ namespace dxvk {
static void logFeatures(const DxvkDeviceFeatures& features);
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
// 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 true;
@ -325,12 +325,12 @@ namespace dxvk {
DxvkDevicePerfHints DxvkDevice::getPerfHints() {
DxvkDevicePerfHints hints;
hints.preferFbDepthStencilCopy = m_features.extShaderStencilExport
&& (m_adapter->matchesDriver(VK_DRIVER_ID_MESA_RADV_KHR, 0, 0)
|| m_adapter->matchesDriver(VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR, 0, 0)
|| m_adapter->matchesDriver(VK_DRIVER_ID_AMD_PROPRIETARY_KHR, 0, 0));
&& (m_adapter->matchesDriver(VK_DRIVER_ID_MESA_RADV_KHR)
|| m_adapter->matchesDriver(VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR)
|| m_adapter->matchesDriver(VK_DRIVER_ID_AMD_PROPRIETARY_KHR));
hints.preferFbResolve = m_features.amdShaderFragmentMask
&& (m_adapter->matchesDriver(VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR, 0, 0)
|| m_adapter->matchesDriver(VK_DRIVER_ID_AMD_PROPRIETARY_KHR, 0, 0));
&& (m_adapter->matchesDriver(VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR)
|| m_adapter->matchesDriver(VK_DRIVER_ID_AMD_PROPRIETARY_KHR));
return hints;
}

View File

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

View File

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