mirror of
https://github.com/lutris/lutris
synced 2024-10-14 11:42:36 +00:00
Reorder display options and simplify driver version logging
This commit is contained in:
parent
8dd737af39
commit
e2fe84c544
|
@ -58,7 +58,7 @@ def _get_dxvk_warning(config, option_key):
|
|||
"You are currently running driver %s which does not "
|
||||
"fully support all features for Vulkan and DXVK games."
|
||||
) % (
|
||||
driver_info["nvrm"]["version"],
|
||||
driver_info["version"],
|
||||
)
|
||||
|
||||
return None
|
||||
|
|
|
@ -16,7 +16,7 @@ from lutris.game import Game
|
|||
from lutris.runners.json import load_json_runners
|
||||
from lutris.scanners.lutris import build_path_cache
|
||||
from lutris.services import DEFAULT_SERVICES
|
||||
from lutris.util.graphics import drivers, vkquery
|
||||
from lutris.util.graphics import vkquery
|
||||
from lutris.util.graphics.drivers import get_gpu_cards
|
||||
from lutris.util.graphics.gpu import GPU, GPUS
|
||||
from lutris.util.linux import LINUX_SYSTEM
|
||||
|
@ -46,36 +46,6 @@ def init_dirs():
|
|||
create_folder(directory)
|
||||
|
||||
|
||||
def get_drivers():
|
||||
"""Report on the currently running driver"""
|
||||
driver_info = {}
|
||||
if drivers.is_nvidia():
|
||||
driver_info = drivers.get_nvidia_driver_info()
|
||||
# pylint: disable=logging-format-interpolation
|
||||
logger.info("Using {vendor} drivers {version} for {arch}".format(**driver_info["nvrm"]))
|
||||
gpus = drivers.get_nvidia_gpu_ids()
|
||||
for gpu_id in gpus:
|
||||
gpu_info = drivers.get_nvidia_gpu_info(gpu_id)
|
||||
logger.info("GPU: %s", gpu_info.get("Model"))
|
||||
elif LINUX_SYSTEM.glxinfo:
|
||||
# pylint: disable=no-member
|
||||
if hasattr(LINUX_SYSTEM.glxinfo, "GLX_MESA_query_renderer"):
|
||||
driver_info = {
|
||||
"vendor": LINUX_SYSTEM.glxinfo.opengl_vendor,
|
||||
"version": LINUX_SYSTEM.glxinfo.GLX_MESA_query_renderer.version,
|
||||
"device": LINUX_SYSTEM.glxinfo.GLX_MESA_query_renderer.device
|
||||
}
|
||||
logger.info(
|
||||
"Running %s Mesa driver %s on %s",
|
||||
LINUX_SYSTEM.glxinfo.opengl_vendor,
|
||||
LINUX_SYSTEM.glxinfo.GLX_MESA_query_renderer.version,
|
||||
LINUX_SYSTEM.glxinfo.GLX_MESA_query_renderer.device,
|
||||
)
|
||||
else:
|
||||
logger.warning("glxinfo is not available on your system, unable to detect driver version")
|
||||
return driver_info
|
||||
|
||||
|
||||
def check_libs(all_components=False):
|
||||
"""Checks that required libraries are installed on the system"""
|
||||
missing_libs = LINUX_SYSTEM.get_missing_libs()
|
||||
|
@ -138,10 +108,10 @@ def fill_missing_platforms():
|
|||
|
||||
def run_all_checks() -> None:
|
||||
"""Run all startup checks"""
|
||||
get_drivers() # drivers dict is not used, but may log information
|
||||
for card in get_gpu_cards():
|
||||
gpu = GPU(card)
|
||||
logger.info(gpu)
|
||||
driver_info = gpu.get_driver_info()
|
||||
logger.info("%s Driver %s", gpu, driver_info.get("version"))
|
||||
GPUS[card] = gpu
|
||||
|
||||
check_libs()
|
||||
|
|
|
@ -104,7 +104,93 @@ system_options = [ # pylint: disable=invalid-name
|
|||
"help": _("When the runtime is enabled, prioritize the system libraries"
|
||||
" over the provided ones."),
|
||||
},
|
||||
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "gpu",
|
||||
"type": "choice",
|
||||
"label": _("GPU"),
|
||||
"choices": get_gpu_list,
|
||||
"default": "",
|
||||
"help": _("GPU to use to run games"),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "mangohud",
|
||||
"type": "bool",
|
||||
"label": _("FPS counter (MangoHud)"),
|
||||
"default": False,
|
||||
"condition": system.can_find_executable("mangohud"),
|
||||
"help": _("Display the game's FPS + other information. Requires MangoHud to be installed."),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "reset_desktop",
|
||||
"type": "bool",
|
||||
"label": _("Restore resolution on game exit"),
|
||||
"default": False,
|
||||
"advanced": True,
|
||||
"help": _("Some games don't restore your screen resolution when \n"
|
||||
"closed or when they crash. This is when this option comes \n"
|
||||
"into play to save your bacon."),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "disable_compositor",
|
||||
"label": _("Disable desktop effects"),
|
||||
"type": "bool",
|
||||
"default": False,
|
||||
"advanced": True,
|
||||
"condition": is_compositing_enabled(),
|
||||
"help": _("Disable desktop effects while game is running, "
|
||||
"reducing stuttering and increasing performance"),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "disable_screen_saver",
|
||||
"label": _("Disable screen saver"),
|
||||
"type": "bool",
|
||||
"default": SCREEN_SAVER_INHIBITOR is not None,
|
||||
"advanced": True,
|
||||
"condition": SCREEN_SAVER_INHIBITOR is not None,
|
||||
"help": _("Disable the screen saver while a game is running. "
|
||||
"Requires the screen saver's functionality "
|
||||
"to be exposed over DBus."),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "sdl_video_fullscreen",
|
||||
"type": "choice",
|
||||
"label": _("SDL 1.2 Fullscreen Monitor"),
|
||||
"choices": get_output_list,
|
||||
"default": "off",
|
||||
"advanced": True,
|
||||
"help": _("Hint SDL 1.2 games to use a specific monitor when going "
|
||||
"fullscreen by setting the SDL_VIDEO_FULLSCREEN "
|
||||
"environment variable"),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "display",
|
||||
"type": "choice",
|
||||
"label": _("Turn off monitors except"),
|
||||
"choices": get_output_choices,
|
||||
"default": "off",
|
||||
"advanced": True,
|
||||
"help": _("Only keep the selected screen active while the game is "
|
||||
"running. \n"
|
||||
"This is useful if you have a dual-screen setup, and are \n"
|
||||
"having display issues when running a game in fullscreen."),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "resolution",
|
||||
"type": "choice",
|
||||
"label": _("Switch resolution to"),
|
||||
"advanced": True,
|
||||
"choices": get_resolution_choices,
|
||||
"default": "off",
|
||||
"help": _("Switch to this screen resolution while the game is running."),
|
||||
},
|
||||
{
|
||||
"section": _("Gamescope"),
|
||||
"option": "gamescope",
|
||||
|
@ -220,91 +306,7 @@ system_options = [ # pylint: disable=invalid-name
|
|||
"label": _("Enable Feral GameMode"),
|
||||
"help": _("Request a set of optimisations be temporarily applied to the host OS"),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "gpu",
|
||||
"type": "choice",
|
||||
"label": _("GPU"),
|
||||
"choices": get_gpu_list,
|
||||
"default": "",
|
||||
"help": _("GPU to use to run games"),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "mangohud",
|
||||
"type": "bool",
|
||||
"label": _("FPS counter (MangoHud)"),
|
||||
"default": False,
|
||||
"condition": system.can_find_executable("mangohud"),
|
||||
"help": _("Display the game's FPS + other information. Requires MangoHud to be installed."),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "reset_desktop",
|
||||
"type": "bool",
|
||||
"label": _("Restore resolution on game exit"),
|
||||
"default": False,
|
||||
"help": _("Some games don't restore your screen resolution when \n"
|
||||
"closed or when they crash. This is when this option comes \n"
|
||||
"into play to save your bacon."),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "disable_compositor",
|
||||
"label": _("Disable desktop effects"),
|
||||
"type": "bool",
|
||||
"default": False,
|
||||
"advanced": True,
|
||||
"condition": is_compositing_enabled(),
|
||||
"help": _("Disable desktop effects while game is running, "
|
||||
"reducing stuttering and increasing performance"),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "disable_screen_saver",
|
||||
"label": _("Disable screen saver"),
|
||||
"type": "bool",
|
||||
"default": SCREEN_SAVER_INHIBITOR is not None,
|
||||
"advanced": False,
|
||||
"condition": SCREEN_SAVER_INHIBITOR is not None,
|
||||
"help": _("Disable the screen saver while a game is running. "
|
||||
"Requires the screen saver's functionality "
|
||||
"to be exposed over DBus."),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "sdl_video_fullscreen",
|
||||
"type": "choice",
|
||||
"label": _("SDL 1.2 Fullscreen Monitor"),
|
||||
"choices": get_output_list,
|
||||
"default": "off",
|
||||
"advanced": True,
|
||||
"help": _("Hint SDL 1.2 games to use a specific monitor when going "
|
||||
"fullscreen by setting the SDL_VIDEO_FULLSCREEN "
|
||||
"environment variable"),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "display",
|
||||
"type": "choice",
|
||||
"label": _("Turn off monitors except"),
|
||||
"choices": get_output_choices,
|
||||
"default": "off",
|
||||
"advanced": True,
|
||||
"help": _("Only keep the selected screen active while the game is "
|
||||
"running. \n"
|
||||
"This is useful if you have a dual-screen setup, and are \n"
|
||||
"having display issues when running a game in fullscreen."),
|
||||
},
|
||||
{
|
||||
"section": _("Display"),
|
||||
"option": "resolution",
|
||||
"type": "choice",
|
||||
"label": _("Switch resolution to"),
|
||||
"choices": get_resolution_choices,
|
||||
"default": "off",
|
||||
"help": _("Switch to this screen resolution while the game is running."),
|
||||
},
|
||||
|
||||
{
|
||||
"section": _("Audio"),
|
||||
"option": "reset_pulse",
|
||||
|
|
|
@ -43,21 +43,17 @@ def get_nvidia_driver_info() -> Dict[str, Dict[str, str]]:
|
|||
nvrm_version = content[0].split(": ")[1].strip().split()
|
||||
if "Open" in nvrm_version:
|
||||
return {
|
||||
"nvrm": {
|
||||
"vendor": nvrm_version[0],
|
||||
"platform": nvrm_version[1],
|
||||
"arch": nvrm_version[6],
|
||||
"version": nvrm_version[7],
|
||||
}
|
||||
}
|
||||
return {
|
||||
"nvrm": {
|
||||
"vendor": nvrm_version[0],
|
||||
"platform": nvrm_version[1],
|
||||
"arch": nvrm_version[2],
|
||||
"version": nvrm_version[5],
|
||||
"date": " ".join(nvrm_version[6:]),
|
||||
"arch": nvrm_version[6],
|
||||
"version": nvrm_version[7],
|
||||
}
|
||||
return {
|
||||
"vendor": nvrm_version[0],
|
||||
"platform": nvrm_version[1],
|
||||
"arch": nvrm_version[2],
|
||||
"version": nvrm_version[5],
|
||||
"date": " ".join(nvrm_version[6:]),
|
||||
}
|
||||
|
||||
def invoke_glxinfo() -> Dict[str, Dict[str, str]]:
|
||||
|
@ -68,12 +64,10 @@ def get_nvidia_driver_info() -> Dict[str, Dict[str, str]]:
|
|||
if "nvidia" not in vendor.lower():
|
||||
raise RuntimeError("Expected NVIDIA vendor information, received %s." % vendor)
|
||||
return {
|
||||
"nvrm": {
|
||||
"vendor": vendor,
|
||||
"platform": platform,
|
||||
"arch": arch,
|
||||
"version": glx_info.opengl_version.rsplit(maxsplit=1)[-1], # type: ignore[attr-defined]
|
||||
}
|
||||
"vendor": vendor,
|
||||
"platform": platform,
|
||||
"arch": arch,
|
||||
"version": glx_info.opengl_version.rsplit(maxsplit=1)[-1], # type: ignore[attr-defined]
|
||||
}
|
||||
|
||||
try:
|
||||
|
@ -221,32 +215,11 @@ def is_amd() -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def check_driver() -> None:
|
||||
"""Report on the currently running driver"""
|
||||
if is_nvidia():
|
||||
driver_info = get_nvidia_driver_info()
|
||||
# pylint: disable=logging-format-interpolation
|
||||
logger.info(
|
||||
"Using {vendor} drivers {version} for {arch}".format(**driver_info["nvrm"])
|
||||
)
|
||||
gpus = get_nvidia_gpu_ids()
|
||||
for gpu_id in gpus:
|
||||
gpu_info = get_nvidia_gpu_info(gpu_id)
|
||||
logger.info("GPU: %s", gpu_info.get("Model"))
|
||||
for card in get_gpu_cards():
|
||||
# pylint: disable=logging-format-interpolation
|
||||
logger.info(
|
||||
"GPU: {PCI_ID} {PCI_SUBSYS_ID} using {DRIVER} driver".format(
|
||||
**get_gpu_info(card)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def is_outdated() -> bool:
|
||||
if not is_nvidia():
|
||||
return False
|
||||
driver_info = get_nvidia_driver_info()
|
||||
driver_version = driver_info["nvrm"]["version"]
|
||||
driver_version = driver_info["version"]
|
||||
if not driver_version:
|
||||
logger.error("Failed to get Nvidia version")
|
||||
return True
|
||||
|
|
|
@ -6,6 +6,7 @@ from typing import Dict
|
|||
|
||||
from lutris.util import system
|
||||
from lutris.util.graphics import drivers
|
||||
from lutris.util.linux import LINUX_SYSTEM
|
||||
from lutris.util.log import logger
|
||||
|
||||
VULKANINFO_AVAILABLE = shutil.which("vulkaninfo")
|
||||
|
@ -82,8 +83,17 @@ class GPU:
|
|||
return f"{self.short_name} ({self.pci_id}:{self.pci_subsys_id} {self.driver})"
|
||||
|
||||
def get_driver_info(self):
|
||||
driver_info = {}
|
||||
if self.driver == "nvidia":
|
||||
return drivers.get_nvidia_driver_info()
|
||||
driver_info = drivers.get_nvidia_driver_info()
|
||||
elif LINUX_SYSTEM.glxinfo:
|
||||
if hasattr(LINUX_SYSTEM.glxinfo, "GLX_MESA_query_renderer"):
|
||||
driver_info = {
|
||||
"vendor": LINUX_SYSTEM.glxinfo.opengl_vendor,
|
||||
"version": LINUX_SYSTEM.glxinfo.GLX_MESA_query_renderer.version,
|
||||
"device": LINUX_SYSTEM.glxinfo.GLX_MESA_query_renderer.device
|
||||
}
|
||||
return driver_info
|
||||
|
||||
def get_gpu_info(self) -> Dict[str, str]:
|
||||
"""Return information about a GPU"""
|
||||
|
|
|
@ -226,7 +226,7 @@ class LinuxSystem: # pylint: disable=too-many-public-methods
|
|||
try:
|
||||
minimum_nvidia_version_supported = 515
|
||||
driver_info = drivers.get_nvidia_driver_info()
|
||||
driver_version = driver_info["nvrm"]["version"]
|
||||
driver_version = driver_info["version"]
|
||||
if not driver_version:
|
||||
return False
|
||||
major_version = int(driver_version.split(".")[0])
|
||||
|
|
|
@ -10,13 +10,11 @@ NVRM version: NVIDIA UNIX x86_64 Kernel Module 525.105.17 Tue Mar 28 18:02:59
|
|||
GCC version: gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)
|
||||
"""
|
||||
PROPRIETARY_MODULE_OUTPUT = {
|
||||
"nvrm": {
|
||||
"vendor": "NVIDIA",
|
||||
"platform": "UNIX",
|
||||
"arch": "x86_64",
|
||||
"version": "525.105.17",
|
||||
"date": "Tue Mar 28 18:02:59 UTC 2023",
|
||||
}
|
||||
"vendor": "NVIDIA",
|
||||
"platform": "UNIX",
|
||||
"arch": "x86_64",
|
||||
"version": "525.105.17",
|
||||
"date": "Tue Mar 28 18:02:59 UTC 2023",
|
||||
}
|
||||
|
||||
OPEN_MODULE_VERSION_FILE = """\
|
||||
|
@ -24,12 +22,10 @@ NVRM version: NVIDIA UNIX Open Kernel Module for x86_64 515.43.04 Release Buil
|
|||
GCC version: gcc version 12.1.0 (GCC)
|
||||
"""
|
||||
OPEN_MODULE_OUTPUT = {
|
||||
"nvrm": {
|
||||
"vendor": "NVIDIA",
|
||||
"platform": "UNIX",
|
||||
"arch": "x86_64",
|
||||
"version": "515.43.04",
|
||||
}
|
||||
"vendor": "NVIDIA",
|
||||
"platform": "UNIX",
|
||||
"arch": "x86_64",
|
||||
"version": "515.43.04",
|
||||
}
|
||||
DRIVER_VERSION_FILES = (
|
||||
("Proprietary", PROPRIETARY_MODULE_VERSION_FILE, PROPRIETARY_MODULE_OUTPUT),
|
||||
|
@ -160,12 +156,10 @@ class TestGetNvidiaDriverInfo(unittest.TestCase):
|
|||
self.assertEqual(
|
||||
actual,
|
||||
{
|
||||
"nvrm": {
|
||||
"vendor": "NVIDIA Corporation",
|
||||
"platform": "Linux",
|
||||
"arch": "x86_64",
|
||||
"version": "525.105.17",
|
||||
}
|
||||
"vendor": "NVIDIA Corporation",
|
||||
"platform": "Linux",
|
||||
"arch": "x86_64",
|
||||
"version": "525.105.17",
|
||||
},
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue