mirror of
https://github.com/bottlesdevs/Bottles.git
synced 2026-10-28 14:29:36 +08:00
This commit is the first of many to avoid the back-end rewrite. * document Result object * document Diff class * remove layered env code * remove Notifications since deprecated * fix method name (PEP8) * add convenient method to force kill wineserver when stalled * use force_f_stalled in runner * use Result obj in Downloader.download * handle the Result obj in ComponentManager.download * code cleanup * remove old RunnerName type * remove old note repositories can now instruct this changes * code cleanup * code cleanup * code cleanup * code cleanup * new trailing newline * extend __validate_template method with essential paths * code cleanup * improve offline check the old method was too slow, the new one just checks the headers with curl, which is much faster * remove deprecations and old migrations * fixes #2345 * fix typo Co-authored-by: Kinsteen <pitiqui69@gmail.com> * fix exception string * remove cabextract binary check since it's already done in health.py * remove reportMissingImports useless now since the main package moved from src to bottles * add PycURL * replace urllib with pycurl in crucial points Co-authored-by: Kinsteen <pitiqui69@gmail.com>
95 lines
2.5 KiB
Python
95 lines
2.5 KiB
Python
# vulkan.py
|
|
#
|
|
# Copyright 2022 brombinmirko <send@mirko.pm>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, in version 3 of the License.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
import os
|
|
from glob import glob
|
|
import shutil
|
|
import subprocess
|
|
|
|
from bottles.backend.utils.display import DisplayUtils
|
|
|
|
|
|
class VulkanUtils:
|
|
__vk_icd_dirs = [
|
|
"/usr/share/vulkan",
|
|
"/etc/vulkan",
|
|
"/usr/local/share/vulkan",
|
|
"/usr/local/etc/vulkan"
|
|
]
|
|
if "FLATPAK_ID" in os.environ:
|
|
__vk_icd_dirs += [
|
|
"/usr/lib/x86_64-linux-gnu/GL/vulkan",
|
|
"/usr/lib/i386-linux-gnu/GL/vulkan",
|
|
]
|
|
|
|
def __init__(self):
|
|
self.loaders = self.__get_vk_icd_loaders()
|
|
|
|
def __get_vk_icd_loaders(self):
|
|
loaders = {
|
|
"nvidia": [],
|
|
"amd": [],
|
|
"intel": []
|
|
}
|
|
|
|
for _dir in self.__vk_icd_dirs:
|
|
_files = glob(f"{_dir}/icd.d/*.json", recursive=True)
|
|
|
|
for file in _files:
|
|
if "nvidia" in file.lower():
|
|
loaders["nvidia"] += [file]
|
|
elif "amd" in file.lower() or "radeon" in file.lower():
|
|
loaders["amd"] += [file]
|
|
elif "intel" in file.lower():
|
|
loaders["intel"] += [file]
|
|
|
|
return loaders
|
|
|
|
def get_vk_icd(self, vendor: str, as_string=False):
|
|
vendors = [
|
|
"nvidia",
|
|
"amd",
|
|
"intel"
|
|
]
|
|
icd = []
|
|
|
|
if vendor in vendors:
|
|
icd = self.loaders[vendor]
|
|
|
|
if as_string:
|
|
icd = ":".join(icd)
|
|
|
|
return icd
|
|
|
|
@staticmethod
|
|
def check_support():
|
|
return True
|
|
|
|
@staticmethod
|
|
def test_vulkan():
|
|
if shutil.which("vulkaninfo") is None:
|
|
return "vulkaninfo tool not found"
|
|
|
|
res = subprocess.Popen(
|
|
"vulkaninfo",
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
shell=True
|
|
).communicate()[0].decode("utf-8")
|
|
|
|
return res
|