When Vulkan 1.3 is not available, default DXVK to a 1.x version

DXVK 2.x and later require at least Vulkan 1.3.

Also, adjust Vulkan warnings not to tell you to update drivers; just
says we're going with DXVK 1.x.
This commit is contained in:
Daniel Johnson 2023-03-26 16:41:31 -04:00 committed by Mathieu Comandon
parent e8cc972694
commit 8a23ae22a8
4 changed files with 45 additions and 9 deletions

View file

@ -27,7 +27,7 @@ from lutris.util.steam.shortcut import update_all_artwork
from lutris.util.system import create_folder
from lutris.util.wine.d3d_extras import D3DExtrasManager
from lutris.util.wine.dgvoodoo2 import dgvoodoo2Manager
from lutris.util.wine.dxvk import DXVKManager
from lutris.util.wine.dxvk import DXVKManager, REQUIRED_VULKAN_API_VERSION
from lutris.util.wine.dxvk_nvapi import DXVKNVAPIManager
from lutris.util.wine.vkd3d import VKD3DManager
@ -142,7 +142,7 @@ def check_vulkan():
if not vkquery.is_vulkan_supported():
logger.warning("Vulkan is not available or your system isn't Vulkan capable")
else:
required_api_version = 1, 3, 0
required_api_version = REQUIRED_VULKAN_API_VERSION
library_api_version = vkquery.get_vulkan_api_version_tuple()
if library_api_version and library_api_version < required_api_version:
logger.warning("Vulkan reports an API version of %s. "
@ -156,7 +156,8 @@ def check_vulkan():
_("Obsolete vulkan libraries"),
secondary_message=_(
"Lutris has detected that Vulkan API version %s is installed, "
"but to use the latest DXVK version, %s is required."
"but to use the latest DXVK version, %s is required.\n\n"
"DXVK 1.x will be used instead."
) % (
vkquery.format_version_tuple(library_api_version),
vkquery.format_version_tuple(required_api_version)
@ -176,11 +177,11 @@ def check_vulkan():
if settings.read_setting(setting) != "True":
DontShowAgainDialog(
setting,
_("Obsolete vulkan libraries"),
_("Obsolete vulkan driver support"),
secondary_message=_(
"Lutris has detected that the best device available ('%s') supports Vulkan API %s, "
"but to use the latest DXVK version, %s is required.\n\n"
"You may need to upgrade your drivers to a newer version."
"DXVK 1.x will be used instead."
) % (
max_dev_name,
vkquery.format_version_tuple(max_dev_api_version),

View file

@ -5,6 +5,7 @@
# Standard Library
from ctypes import CDLL, POINTER, Structure, byref, c_char_p, c_int32, c_uint32, c_void_p, pointer, c_char, c_uint8, \
c_uint64, c_float, c_size_t
from functools import cache
VkResult = c_int32 # enum (size == 4)
VK_SUCCESS = 0
@ -236,6 +237,7 @@ class VkPhysicalDeviceProperties(Structure):
]
@cache
def is_vulkan_supported():
"""
Returns True iff vulkan library can be loaded, initialized,
@ -257,6 +259,7 @@ def is_vulkan_supported():
return result == VK_SUCCESS and dev_count.value > 0
@cache
def get_vulkan_api_version_tuple():
"""
Queries libvulkan to get the API version; if this library is missing
@ -336,7 +339,19 @@ def get_best_device_info():
key=lambda t: t[1],
reverse=True
)
return by_version[0]
return by_version[0] if by_version else None
@cache
def get_expected_api_version_tuple():
"""Returns the version tuple of the API version we expect
to have; it is the least of the Vulkan library API version, and
the best device's API version."""
api_version = get_vulkan_api_version_tuple()
best_dev = get_best_device_info()
if best_dev:
return min(api_version, best_dev[1])
return api_version
def make_version_tuple(source_int):

View file

@ -45,8 +45,16 @@ class DLLManager:
"""Return version (latest known version if not provided)"""
if self._version:
return self._version
if self.versions:
return self.versions[0]
versions = self.versions
if versions:
recommended_versions = [v for v in versions if self.is_recommended_version(v)]
return recommended_versions[0] if recommended_versions else versions[0]
def is_recommended_version(self, version):
"""True if the version given should be usable as the default; false if it
should not be the default, but may be selected by the user. If only
non-recommended versions exist, we'll still default to one of them, however."""
return True
@property
def path(self):

View file

@ -2,6 +2,8 @@
import os
import shutil
from lutris.util.graphics import vkquery
from lutris import api
from lutris.settings import RUNTIME_DIR
from lutris.util.extract import extract_archive
@ -10,13 +12,23 @@ from lutris.util.log import logger
from lutris.util.system import create_folder, execute, remove_folder
from lutris.util.wine.dll_manager import DLLManager
REQUIRED_VULKAN_API_VERSION = 1, 3, 0
class DXVKManager(DLLManager):
component = "DXVK"
base_dir = os.path.join(RUNTIME_DIR, "dxvk")
versions_path = os.path.join(base_dir, "dxvk_versions.json")
managed_dlls = ("dxgi", "d3d11", "d3d10core", "d3d9", )
managed_dlls = ("dxgi", "d3d11", "d3d10core", "d3d9",)
releases_url = "https://api.github.com/repos/lutris/dxvk/releases"
vulkan_api_version = vkquery.get_expected_api_version_tuple()
def is_recommended_version(self, version):
# DXVK 2.x and later require Vulkan 1.3, so if that iss lacking
# we default to 1.x.
if self.vulkan_api_version and self.vulkan_api_version < REQUIRED_VULKAN_API_VERSION:
return version.startswith("v1.")
return super().is_recommended_version(version)
@staticmethod
def is_managed_dll(dll_path):