mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
Merge main into playstore for 0.6.9.2 (version code 20)
Brings the main fixes and features since 8a8bb2053 to the Play line.
Main's new code keeps the Play gates: bundled PRoot, AddonPack and
ComponentDownloads gates, the SDK guards, PackageInfoCompat and the
accessibility consent check, which now also covers system-key capture.
The accessibility disclosure is rewritten in every locale to describe
the hardware-keyboard keys it keeps in a session. The MaliBridge server
task uses the AGP NDK provider. Review notes are in tools/playstore/POLICY.md.
This commit is contained in:
commit
95cb9159de
517 files changed
+46804
-2489
No files matched your search
@@ -26,5 +26,10 @@ SSBS=$(syms "$D/libssbs.so")
|
||||
for sym in sigaction signal bsd_signal sysv_signal; do
|
||||
grep -qx "$sym" <<<"$SSBS" || { echo "::error::libssbs.so does not export $sym"; exit 1; }
|
||||
done
|
||||
XCLIPSE=$(syms "$D/usr/local/lib/droiddeck-xclipse/libVkLayer_droiddeck_xclipse.so")
|
||||
for sym in vkNegotiateLoaderLayerInterfaceVersion vkGetInstanceProcAddr vkGetDeviceProcAddr; do
|
||||
grep -qx "$sym" <<<"$XCLIPSE" || { echo "::error::the Xclipse layer does not export $sym"; exit 1; }
|
||||
done
|
||||
test -f "$D/usr/local/lib/droiddeck-xclipse/VkLayer_droiddeck_xclipse.json"
|
||||
test -f "$D/usr/local/bin/droiddeck-session"
|
||||
test -f "$D/usr/local/bin/droiddeck-proton-extra"
|
||||
@@ -31,6 +31,14 @@ export BL_DESKTOP=1
|
||||
ln -sf /usr/local/bin/droiddeck-steam-launch /usr/local/bin/steamdeck-steam 2>/dev/null
|
||||
ln -sf /usr/local/bin/droiddeck-steam-shim /usr/local/bin/steam 2>/dev/null
|
||||
python3 /usr/local/bin/droiddeck-desktop-games 2>&1 | sed 's/^/[games] /'
|
||||
python3 /usr/local/bin/droiddeck-desktop-programs 2>&1 | sed 's/^/[programs] /'
|
||||
# startplasma applies this file over the session environment, and keeps what an earlier session wrote.
|
||||
kwriteconfig6 --file plasma-localerc --group Formats --key LANG "${LANG:-C.UTF-8}"
|
||||
if [ -n "${LANGUAGE:-}" ]; then
|
||||
kwriteconfig6 --file plasma-localerc --group Translations --key LANGUAGE "$LANGUAGE"
|
||||
else
|
||||
kwriteconfig6 --file plasma-localerc --group Translations --key LANGUAGE --delete
|
||||
fi
|
||||
cat > /usr/share/applications/droiddeck-steam-x64.desktop <<'ENTRY'
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
@@ -107,8 +115,10 @@ fi
|
||||
if [ "$(cat /usr/share/droiddeck/kwin-compositor 2>/dev/null)" = opengl ]; then
|
||||
unset LIBGL_ALWAYS_SOFTWARE QT_QUICK_BACKEND
|
||||
export KWIN_COMPOSE=O2 MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink LIBGL_KOPPER_DRI2=true
|
||||
if [ -z "${KWIN_RENDER_NODES:-}" ] && [ -c /dev/dri/renderD0 ]; then
|
||||
export KWIN_RENDER_NODES=/dev/dri/renderD0
|
||||
if [ -z "${KWIN_RENDER_NODES:-}" ]; then
|
||||
for node in /dev/dri/renderD0 /dev/dri/renderD307 /dev/dri/renderD*; do
|
||||
if [ -c "$node" ]; then export KWIN_RENDER_NODES="$node"; break; fi
|
||||
done
|
||||
fi
|
||||
mkdir -p /run/droiddeck/kwin
|
||||
printf '#!/bin/sh\nGALLIUM_THREAD=0 exec /usr/bin/kwin_wayland "$@"\n' > /run/droiddeck/kwin/kwin_wayland
|
||||
|
||||
@@ -6,13 +6,18 @@ if [ -n "${BL_DEBUG_DIR:-}" ]; then
|
||||
fi
|
||||
width=${BL_WIDTH:-1280}
|
||||
height=${BL_HEIGHT:-720}
|
||||
backend=${BL_GAMESCOPE_BACKEND:-wayland}
|
||||
case "$backend" in
|
||||
wayland|sdl) ;;
|
||||
*) echo "== unsupported gamescope backend: $backend" >&2; exit 64 ;;
|
||||
esac
|
||||
window=0
|
||||
if [ "${BL_DESKTOP_GPU_WINDOW:-1}" != 0 ] && [ -n "${WAYLAND_DISPLAY:-}" ] && [ "$WAYLAND_DISPLAY" != wayland-0 ]; then
|
||||
if [ "$backend" = wayland ] && [ "${BL_DESKTOP_GPU_WINDOW:-1}" != 0 ] && [ -n "${WAYLAND_DISPLAY:-}" ] && [ "$WAYLAND_DISPLAY" != wayland-0 ]; then
|
||||
window=1
|
||||
parent=$WAYLAND_DISPLAY
|
||||
args=(--backend sdl --expose-wayland -W "$width" -H "$height" -w "$width" -h "$height")
|
||||
args=(--backend sdl --expose-wayland --follow-game-window-mode -W "$width" -H "$height" -w "$width" -h "$height")
|
||||
else
|
||||
args=(--backend wayland --expose-wayland -f -W "$width" -H "$height" -w "$width" -h "$height")
|
||||
args=(--backend "$backend" --expose-wayland -f -W "$width" -H "$height" -w "$width" -h "$height")
|
||||
fi
|
||||
if [ "${BL_FPS:-0}" -gt 0 ]; then
|
||||
args+=(-r "$BL_FPS")
|
||||
@@ -27,6 +32,7 @@ else
|
||||
export WAYLAND_DISPLAY=wayland-0
|
||||
fi
|
||||
export GDK_BACKEND=x11 QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11
|
||||
[ "$backend" = sdl ] && export SDL_VIDEODRIVER=wayland
|
||||
unset LIBGL_ALWAYS_SOFTWARE QT_QUICK_BACKEND KWIN_COMPOSE
|
||||
wsi=",${MESA_VK_WSI_DEBUG:-},"
|
||||
while [[ $wsi == *,sw,* ]]; do wsi=${wsi//,sw,/,}; done
|
||||
@@ -40,7 +46,7 @@ if [ "$window" = 1 ]; then
|
||||
export BL_GPU_CHILD_WSI=${MESA_VK_WSI_DEBUG:-}
|
||||
SDL_VIDEODRIVER=wayland MESA_VK_WSI_DEBUG=sw gamescope "${args[@]}" -- /usr/local/bin/droiddeck-gpu-window "$@"
|
||||
else
|
||||
gamescope "${args[@]}" -- /usr/local/bin/droiddeck-gpu-window "$@"
|
||||
gamescope "${args[@]}" -- env SDL_VIDEODRIVER=x11 /usr/local/bin/droiddeck-gpu-window "$@"
|
||||
fi
|
||||
rc=$?
|
||||
echo "== droiddeck-gpu $(date -u +%H:%M:%S): exited $rc"
|
||||
|
||||
@@ -52,7 +52,7 @@ CLIENT_WAIT = 300
|
||||
GAME_GRACE = 15
|
||||
LAUNCH_WAIT = 15
|
||||
LAUNCH_ASKS = 3
|
||||
CLIENT_PATH = re.compile(r"[a-z]:\\(program files \(x86\)|programdata)\\battle\.net\\")
|
||||
CLIENT_PATH = re.compile(r"[a-z]:\\(program files \(x86\)\\battle\.net\\([^\\]+$|battle\.net\.\d+\\)|programdata\\battle\.net\\)")
|
||||
IDLE = {"agent.exe", "conhost.exe", "explorer.exe", "lsass.exe", "plugplay.exe", "rpcss.exe", "services.exe",
|
||||
"start.exe", "steam.exe", "svchost.exe", "tabtip.exe", "winedevice.exe", "wineserver"}
|
||||
NOT_GAME = IDLE | {"rundll32.exe", "wineboot.exe", "winemenubuilder.exe"}
|
||||
@@ -113,7 +113,9 @@ function field(text, name) {
|
||||
}
|
||||
|
||||
function install() {
|
||||
var form = call("POST", "/install", '{"uid":"' + uid + '","instructions_patch_url":"http://' + zone + '.patch.battle.net:1119/' +
|
||||
// Blizzard's China repository moved to cn.patch.battlenet.com.cn; cn.patch.battle.net only redirects away from it.
|
||||
var patch = zone == "cn" ? "cn.patch.battlenet.com.cn" : zone + ".patch.battle.net";
|
||||
var form = call("POST", "/install", '{"uid":"' + uid + '","instructions_patch_url":"http://' + patch + ':1119/' +
|
||||
product + '","instructions_product":"NGDP","monitor_pid":12345,"priority":{"insert_at_head":true,"value":900}}');
|
||||
save(".form", form);
|
||||
if (form.indexOf('"' + lang + '"') < 0) lang = "enUS";
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
#!/usr/bin/python3
|
||||
import fcntl
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
import runpy
|
||||
import stat
|
||||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
import zlib
|
||||
|
||||
HOME = os.environ.get("HOME", "/root")
|
||||
STEAM_ROOT = sys.argv[1] if len(sys.argv) > 1 else os.path.join(HOME, ".local/share/Steam")
|
||||
BIN_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
OPEN = os.path.join(BIN_DIR, "droiddeck-open")
|
||||
APPS_DIR = os.path.join(HOME, ".local/share/applications")
|
||||
PLACED = os.path.join(HOME, ".local/share/droiddeck/desktop-programs-placed")
|
||||
PREFIX = "droiddeck-program-"
|
||||
SHORTCUT_BIT = 0x80000000
|
||||
WINDOWS_DESKTOPS = ("users/Public/Desktop", "users/steamuser/Desktop")
|
||||
NOT_PROGRAMS = re.compile(r"(?i)^unins")
|
||||
ABSENT = (FileNotFoundError, NotADirectoryError, IsADirectoryError)
|
||||
|
||||
_run = None
|
||||
|
||||
|
||||
def present(path, regular=False):
|
||||
try:
|
||||
mode = os.stat(path).st_mode
|
||||
except ABSENT:
|
||||
return False
|
||||
return stat.S_ISREG(mode) if regular else True
|
||||
|
||||
|
||||
def read(path):
|
||||
try:
|
||||
with open(path, encoding="utf-8", errors="replace") as f:
|
||||
return f.read()
|
||||
except ABSENT:
|
||||
return None
|
||||
|
||||
|
||||
def proton_run():
|
||||
global _run
|
||||
if _run is None:
|
||||
_run = runpy.run_path(os.path.join(BIN_DIR, "droiddeck-proton-run"))
|
||||
return _run
|
||||
|
||||
|
||||
def shortcut_ids(root):
|
||||
tool = runpy.run_path(os.path.join(BIN_DIR, "droiddeck-steam-shortcuts"))
|
||||
# account_dir takes either of these as missing when it cannot be read.
|
||||
read(os.path.join(root, "config", "loginusers.vdf"))
|
||||
listing(os.path.join(root, "userdata"))
|
||||
account = tool["account_dir"](root)
|
||||
if account:
|
||||
try:
|
||||
with open(os.path.join(account, "config", "shortcuts.vdf"), "rb") as f:
|
||||
tool["parse"](f.read())
|
||||
except ABSENT:
|
||||
pass
|
||||
except (ValueError, IndexError, KeyError, struct.error) as error:
|
||||
raise OSError("Steam's shortcuts.vdf cannot be read: %s" % error) from error
|
||||
return {appid for appid, _, _ in proton_run()["shortcut_entries"](root)}
|
||||
|
||||
|
||||
def runs_here(pfx, exe):
|
||||
target = proton_run()["prefix_of"](exe)
|
||||
return target is not None and os.path.realpath(target.compatdata) == os.path.realpath(os.path.dirname(pfx))
|
||||
|
||||
|
||||
def listing(folder, suffix=""):
|
||||
try:
|
||||
names = os.listdir(folder)
|
||||
except ABSENT:
|
||||
return None
|
||||
return sorted(os.path.join(folder, name) for name in names if name.lower().endswith(suffix))
|
||||
|
||||
|
||||
def prefixes(root):
|
||||
compatdata = os.path.join(root, "steamapps", "compatdata")
|
||||
names = listing(compatdata)
|
||||
if names is None:
|
||||
return []
|
||||
owned = shortcut_ids(root)
|
||||
found = []
|
||||
for name in (os.path.basename(path) for path in names):
|
||||
if not re.fullmatch(r"-?[0-9]+", name):
|
||||
continue
|
||||
appid = int(name) % 2 ** 32
|
||||
pfx = os.path.join(compatdata, name, "pfx")
|
||||
if appid & SHORTCUT_BIT and appid not in owned and listing(os.path.join(pfx, "drive_c", "proton_shortcuts")) is not None:
|
||||
found.append((appid, pfx))
|
||||
return found
|
||||
|
||||
|
||||
def zero_terminated(data, start, wide):
|
||||
if wide:
|
||||
end = start
|
||||
while data[end:end + 2] not in (b"\0\0", b""):
|
||||
end += 2
|
||||
return data[start:end].decode("utf-16-le", "replace")
|
||||
end = data.find(b"\0", start)
|
||||
return data[start:end if end >= 0 else len(data)].decode("cp1252", "replace")
|
||||
|
||||
|
||||
def link_target(path):
|
||||
try:
|
||||
with open(path, "rb") as f:
|
||||
data = f.read(1 << 16)
|
||||
size, = struct.unpack_from("<I", data, 0)
|
||||
flags, = struct.unpack_from("<I", data, 0x14)
|
||||
pos, target = size, None
|
||||
if flags & 0x1:
|
||||
pos += 2 + struct.unpack_from("<H", data, pos)[0]
|
||||
if flags & 0x2:
|
||||
info_size, header, info_flags, _, local, _, suffix = struct.unpack_from("<7I", data, pos)
|
||||
if info_flags & 0x1:
|
||||
if header >= 0x24:
|
||||
local_wide, suffix_wide = struct.unpack_from("<2I", data, pos + 0x1C)
|
||||
target = zero_terminated(data, pos + local_wide, True) + zero_terminated(data, pos + suffix_wide, True)
|
||||
else:
|
||||
target = zero_terminated(data, pos + local, False) + zero_terminated(data, pos + suffix, False)
|
||||
pos += info_size
|
||||
args = ""
|
||||
wide = bool(flags & 0x80)
|
||||
for bit in (0x4, 0x8, 0x10, 0x20, 0x40):
|
||||
if flags & bit:
|
||||
count, = struct.unpack_from("<H", data, pos)
|
||||
end = pos + 2 + count * (2 if wide else 1)
|
||||
if bit == 0x20:
|
||||
args = data[pos + 2:end].decode("utf-16-le" if wide else "cp1252", "replace").rstrip("\0")
|
||||
pos = end
|
||||
return target, args
|
||||
except ABSENT + (struct.error, ValueError):
|
||||
return None, ""
|
||||
|
||||
|
||||
def host_path(pfx, windows):
|
||||
found = re.fullmatch(r"([A-Za-z]):\\?(.*)", windows or "")
|
||||
if not found:
|
||||
return None
|
||||
path = os.path.realpath(os.path.join(pfx, "dosdevices", found.group(1).lower() + ":"))
|
||||
for part in (p for p in found.group(2).split("\\") if p):
|
||||
exact = os.path.join(path, part)
|
||||
if not os.path.lexists(exact):
|
||||
try:
|
||||
exact = next((os.path.join(path, name) for name in os.listdir(path) if name.lower() == part.lower()), exact)
|
||||
except ABSENT:
|
||||
return None
|
||||
path = exact
|
||||
return path if present(path) else None
|
||||
|
||||
|
||||
def value(text, key):
|
||||
found = re.search(r"^%s=(.*)$" % re.escape(key), text, re.M)
|
||||
return found.group(1).strip() if found else ""
|
||||
|
||||
|
||||
def windows_link(exec_value):
|
||||
if len(exec_value) >= 2 and exec_value[0] == exec_value[-1] == '"':
|
||||
exec_value = exec_value[1:-1]
|
||||
# A desktop file escapes a backslash once for the key and again inside a quoted Exec argument.
|
||||
return exec_value.replace("\\\\", "\\").replace("\\\\", "\\")
|
||||
|
||||
|
||||
def icon(shortcuts, name):
|
||||
best, size = "system-run", 0
|
||||
for apps in glob.glob(os.path.join(glob.escape(shortcuts), "icons", "*", "apps")):
|
||||
found = re.fullmatch(r"(\d+)x\d+", os.path.basename(os.path.dirname(apps)))
|
||||
path = os.path.join(apps, name + ".png")
|
||||
if name and found and int(found.group(1)) > size and os.path.isfile(path):
|
||||
best, size = path, int(found.group(1))
|
||||
return best
|
||||
|
||||
|
||||
def program(pfx, link):
|
||||
target, args = link_target(link)
|
||||
exe = host_path(pfx, target)
|
||||
if (exe and exe.lower().endswith(".exe") and not NOT_PROGRAMS.match(os.path.basename(exe)) and present(exe, regular=True)
|
||||
and runs_here(pfx, exe)):
|
||||
return exe, args
|
||||
return None, ""
|
||||
|
||||
|
||||
def programs(pfx):
|
||||
shortcuts = os.path.join(pfx, "drive_c", "proton_shortcuts")
|
||||
found = {}
|
||||
for entry in listing(shortcuts, ".desktop") or []:
|
||||
text = read(entry) or ""
|
||||
link = host_path(pfx, windows_link(value(text, "Exec")))
|
||||
if not link or not link.lower().endswith(".lnk"):
|
||||
continue
|
||||
exe, args = program(pfx, link)
|
||||
if exe:
|
||||
found[exe] = dict(name=value(text, "Name") or os.path.splitext(os.path.basename(entry))[0], args=args,
|
||||
icon=icon(shortcuts, value(text, "Icon")), wm_class=value(text, "StartupWMClass"))
|
||||
return found
|
||||
|
||||
|
||||
def on_windows_desktop(pfx):
|
||||
found = set()
|
||||
for folder in WINDOWS_DESKTOPS:
|
||||
for link in listing(os.path.join(pfx, "drive_c", folder), ".lnk") or []:
|
||||
exe, _ = program(pfx, link)
|
||||
if exe:
|
||||
found.add(exe)
|
||||
return found
|
||||
|
||||
|
||||
def windows_args(text):
|
||||
args, current, started, quoted, slashes = [], "", False, False, 0
|
||||
for ch in text:
|
||||
if ch == "\\":
|
||||
slashes += 1
|
||||
started = True
|
||||
elif ch == '"':
|
||||
current += "\\" * (slashes // 2) + ('"' if slashes % 2 else "")
|
||||
if slashes % 2 == 0:
|
||||
quoted = not quoted
|
||||
slashes, started = 0, True
|
||||
else:
|
||||
current += "\\" * slashes
|
||||
slashes = 0
|
||||
if ch in " \t" and not quoted:
|
||||
if started:
|
||||
args.append(current)
|
||||
current, started = "", False
|
||||
else:
|
||||
current += ch
|
||||
started = True
|
||||
if started:
|
||||
args.append(current + "\\" * slashes)
|
||||
return args
|
||||
|
||||
|
||||
def quoted(arg):
|
||||
escaped = re.sub(r'([\\"`$])', r"\\\1", arg).replace("%", "%%")
|
||||
return '"%s"' % escaped.replace("\\", "\\\\")
|
||||
|
||||
|
||||
def entry(exe, found):
|
||||
args = windows_args(found["args"])
|
||||
lines = ["[Desktop Entry]", "Type=Application", "Name=%s" % found["name"].replace("\n", " "),
|
||||
"Comment=Windows program installed from the desktop",
|
||||
"Exec=%s" % " ".join(quoted(arg) for arg in [OPEN, exe] + args),
|
||||
"Icon=%s" % found["icon"], "Terminal=false", "Categories=Game;"]
|
||||
if found["wm_class"]:
|
||||
lines.append("StartupWMClass=%s" % found["wm_class"])
|
||||
return "\n".join(lines) + "\n"
|
||||
|
||||
|
||||
def desktop_dir():
|
||||
try:
|
||||
path = subprocess.run(["xdg-user-dir", "DESKTOP"], capture_output=True, text=True, timeout=5).stdout.strip()
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
path = ""
|
||||
return path if path and path != HOME else os.path.join(HOME, "Desktop")
|
||||
|
||||
|
||||
def sync(directory, wanted, mode=0o644):
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
for name in os.listdir(directory):
|
||||
if name.startswith(PREFIX) and name.endswith(".desktop") and name not in wanted:
|
||||
os.unlink(os.path.join(directory, name))
|
||||
for name, body in wanted.items():
|
||||
path = os.path.join(directory, name)
|
||||
if read(path) != body:
|
||||
try:
|
||||
with open(path + ".tmp", "w", encoding="utf-8") as f:
|
||||
f.write(body)
|
||||
os.chmod(path + ".tmp", mode)
|
||||
os.replace(path + ".tmp", path)
|
||||
except OSError:
|
||||
if os.path.lexists(path + ".tmp"):
|
||||
os.unlink(path + ".tmp")
|
||||
raise
|
||||
|
||||
|
||||
def main():
|
||||
os.makedirs(os.path.dirname(PLACED), exist_ok=True)
|
||||
with open(PLACED + ".lock", "w") as lock:
|
||||
fcntl.flock(lock, fcntl.LOCK_EX)
|
||||
try:
|
||||
refresh()
|
||||
except OSError as error:
|
||||
print("droiddeck-desktop-programs: the menu is left as it was (%s)" % error)
|
||||
|
||||
|
||||
def refresh():
|
||||
menu, desktop_wanted = {}, set()
|
||||
for appid, pfx in prefixes(STEAM_ROOT):
|
||||
on_desktop = on_windows_desktop(pfx)
|
||||
for exe, found in programs(pfx).items():
|
||||
name = "%s%d-%08x.desktop" % (PREFIX, appid, zlib.crc32(exe.encode("utf-8")))
|
||||
menu[name] = entry(exe, found)
|
||||
if exe in on_desktop:
|
||||
desktop_wanted.add(name)
|
||||
placed = set((read(PLACED) or "").split())
|
||||
sync(APPS_DIR, menu)
|
||||
desktop = desktop_dir()
|
||||
shown = {name: menu[name] for name in sorted(desktop_wanted)
|
||||
if name not in placed or present(os.path.join(desktop, name), regular=True)}
|
||||
try:
|
||||
sync(desktop, shown, 0o755)
|
||||
finally:
|
||||
written = {name for name in shown if present(os.path.join(desktop, name), regular=True)}
|
||||
with open(PLACED + ".tmp", "w", encoding="utf-8") as f:
|
||||
f.write("".join(name + "\n" for name in sorted((placed | written) & set(menu))))
|
||||
os.replace(PLACED + ".tmp", PLACED)
|
||||
print("droiddeck-desktop-programs: %d program%s in the menu, %d on the desktop" % (
|
||||
len(menu), "" if len(menu) == 1 else "s", len(shown)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,446 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
PREFIX = "DROIDDECK_PROCESS_TRACE "
|
||||
SCHEMA = 1
|
||||
DEFAULT_INTERVAL_MS = 5_000
|
||||
DEFAULT_DURATION_MS = 86_400_000
|
||||
DEFAULT_MAX_RECORDS = 512
|
||||
HEARTBEAT_MS = 300_000
|
||||
MAX_PROCESSES = 256
|
||||
MAX_MAP_BYTES = 8 * 1024 * 1024
|
||||
MAX_MAP_LINES = 65_536
|
||||
MAX_LIBRARIES = 128
|
||||
MAX_CMDLINE_BYTES = 16 * 1024
|
||||
MAX_ENUMERATED_PROCESSES = 4_096
|
||||
MAX_CHILDREN_BYTES = 64 * 1024
|
||||
SAFE_LIBRARY = re.compile(r"[A-Za-z0-9._+-]{1,128}")
|
||||
WINDOWS_GRAPHICS_LIBRARIES = {
|
||||
"d3d8.dll", "d3d9.dll", "d3d10.dll", "d3d10_1.dll", "d3d10core.dll",
|
||||
"d3d11.dll", "d3d12.dll", "dxgi.dll", "vulkan-1.dll",
|
||||
}
|
||||
KNOWN_GRAPHICS_SONAMES = {
|
||||
"libvulkan.so", "libvulkan_freedreno.so", "libvulkan_panfrost.so", "libvulkan_lvp.so",
|
||||
"libvulkan_virtio.so", "libvulkan_dzn.so", "libvulkan_broadcom.so",
|
||||
"libEGL.so", "libEGL_mesa.so", "libGLESv1_CM.so", "libGLESv2.so", "libGLESv3.so",
|
||||
"libGL.so", "libGLX.so", "libGLX_mesa.so", "libgbm.so", "libwayland-client.so",
|
||||
"libX11.so", "libX11-xcb.so", "libdrm.so", "libdrm_amdgpu.so", "libdrm_freedreno.so",
|
||||
"libdrm_intel.so", "libdrm_nouveau.so", "libdrm_radeon.so", "libxcb.so", "libxcb-dri2.so",
|
||||
"libxcb-dri3.so", "libxcb-glx.so", "libxcb-present.so", "libxcb-randr.so", "libxcb-render.so",
|
||||
"libxcb-shm.so", "libxcb-sync.so", "libxcb-xfixes.so", "libhybris-vulkan-icd.so",
|
||||
"libVkLayer_hybris_compat.so", "libVkLayer_DROIDDECK_placed_memory.so",
|
||||
"libVkLayer_KHRONOS_validation.so", "libVkLayer_FROG_gamescope_wsi_aarch64.so",
|
||||
"libVkLayer_MESA_device_select.so", "libVkLayer_MESA_overlay.so", "libvkd3d.so",
|
||||
"libvkd3d-shader.so", "libvkd3d-utils.so",
|
||||
}
|
||||
|
||||
|
||||
def emit(payload, output=sys.stdout):
|
||||
output.write(PREFIX + json.dumps(payload, separators=(",", ":"), sort_keys=True) + "\n")
|
||||
output.flush()
|
||||
|
||||
|
||||
def process_stat(path):
|
||||
text = path.read_text(errors="replace")
|
||||
end = text.rfind(") ")
|
||||
if end < 0:
|
||||
raise ValueError("invalid process stat")
|
||||
fields = text[end + 2:].split()
|
||||
if len(fields) < 20:
|
||||
raise ValueError("short process stat")
|
||||
return int(fields[1]), fields[19]
|
||||
|
||||
|
||||
def bounded_bytes(path, limit):
|
||||
with path.open("rb") as source:
|
||||
return source.read(limit)
|
||||
|
||||
|
||||
def process_role(comm, cmdline):
|
||||
probe = (comm + "\0" + cmdline.decode("utf-8", "replace")).lower()
|
||||
if "steamwebhelper" in probe:
|
||||
return "steam-webhelper"
|
||||
if "gamescope" in probe:
|
||||
return "gamescope"
|
||||
if "xwayland" in probe:
|
||||
return "xwayland"
|
||||
if "mangoapp" in probe:
|
||||
return "mangoapp"
|
||||
if "pressure-vessel" in probe or "steam-runtime" in probe:
|
||||
return "steam-runtime"
|
||||
if "steamrtarm64/steam" in probe or "steamrt64/steam" in probe or comm.lower() == "steam":
|
||||
return "steam-client"
|
||||
if "fexinterpreter" in probe or comm.lower() == "fex":
|
||||
return "fex"
|
||||
if "wineserver" in probe:
|
||||
return "wineserver"
|
||||
if any(name in probe for name in ("wine64", "wine-preloader", "/wine ")):
|
||||
return "wine"
|
||||
if "pipewire" in probe or "pulseaudio" in probe:
|
||||
return "audio-server"
|
||||
if "dbus-daemon" in probe:
|
||||
return "dbus"
|
||||
if "droiddeck-session" in probe:
|
||||
return "session"
|
||||
return "game-or-helper"
|
||||
|
||||
|
||||
def is_graphics_library(name):
|
||||
lower = name.lower()
|
||||
return (
|
||||
lower in WINDOWS_GRAPHICS_LIBRARIES or
|
||||
lower.startswith(("libvulkan", "libvklayer", "vulkan.", "libegl", "libgles", "libglx",
|
||||
"libgl.so", "libgbm", "libdrm", "libwayland", "libxcb", "libx11")) or
|
||||
"vkd3d" in lower or "dxvk" in lower or "zink" in lower or "mangohud" in lower
|
||||
)
|
||||
|
||||
|
||||
def origin_class(path):
|
||||
lower = path.lower()
|
||||
if lower.startswith("/vendor/"):
|
||||
return "android-vendor"
|
||||
if lower.startswith(("/system/", "/apex/")):
|
||||
return "android-system"
|
||||
if "/files/components/" in lower or "/files/system_vulkan/" in lower:
|
||||
return "droiddeck-component"
|
||||
if "/steamapps/common/" in lower:
|
||||
return "steam-tool"
|
||||
if lower.startswith(("/usr/", "/lib/", "/opt/")):
|
||||
return "guest-runtime"
|
||||
if lower.startswith("/tmp/"):
|
||||
return "temporary"
|
||||
return "other"
|
||||
|
||||
|
||||
def library_identity(name, origin):
|
||||
if origin in {"android-vendor", "android-system"}:
|
||||
return name
|
||||
base = name
|
||||
while True:
|
||||
head, separator, tail = base.rpartition(".")
|
||||
if not separator or not tail.isdigit():
|
||||
break
|
||||
base = head
|
||||
if name.lower() in WINDOWS_GRAPHICS_LIBRARIES or base in KNOWN_GRAPHICS_SONAMES:
|
||||
return name
|
||||
return "sha256:" + hashlib.sha256(name.encode()).hexdigest()[:16]
|
||||
|
||||
|
||||
def graphics_libraries(maps_path):
|
||||
libraries = set()
|
||||
total = 0
|
||||
lines = 0
|
||||
with maps_path.open("rb") as source:
|
||||
while lines < MAX_MAP_LINES and total < MAX_MAP_BYTES:
|
||||
raw = source.readline(min(64 * 1024, MAX_MAP_BYTES - total + 1))
|
||||
if not raw:
|
||||
break
|
||||
total += len(raw)
|
||||
lines += 1
|
||||
if total > MAX_MAP_BYTES:
|
||||
return libraries, "capped"
|
||||
parts = raw.decode("utf-8", "replace").rstrip("\n").split(None, 5)
|
||||
if len(parts) < 6 or not parts[5].startswith("/"):
|
||||
continue
|
||||
mapped = parts[5].removesuffix(" (deleted)")
|
||||
name = os.path.basename(mapped)
|
||||
if SAFE_LIBRARY.fullmatch(name) and is_graphics_library(name):
|
||||
origin = origin_class(mapped)
|
||||
libraries.add((library_identity(name, origin), origin))
|
||||
if len(libraries) >= MAX_LIBRARIES:
|
||||
return libraries, "capped"
|
||||
return libraries, "readable"
|
||||
|
||||
|
||||
class Collector:
|
||||
def __init__(self, proc_root, root_pid):
|
||||
self.proc_root = Path(proc_root)
|
||||
self.root_pid = int(root_pid)
|
||||
self.known = {}
|
||||
self.tokens = {}
|
||||
self.next_token = 1
|
||||
self.self_pid = os.getpid()
|
||||
self.root_identity = None
|
||||
self.last_maps_state = None
|
||||
self.last_provider_error = None
|
||||
|
||||
def _scan_fallback(self, result):
|
||||
capped = False
|
||||
try:
|
||||
entries = self.proc_root.iterdir()
|
||||
except OSError:
|
||||
return capped, "proc-unavailable"
|
||||
examined = 0
|
||||
for entry in entries:
|
||||
if not entry.name.isdigit():
|
||||
continue
|
||||
examined += 1
|
||||
if examined > MAX_ENUMERATED_PROCESSES:
|
||||
capped = True
|
||||
break
|
||||
pid = int(entry.name)
|
||||
if pid == self.self_pid or pid in result:
|
||||
continue
|
||||
try:
|
||||
result[pid] = process_stat(entry / "stat")
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
return capped, None
|
||||
|
||||
def _stats(self):
|
||||
result = {}
|
||||
capped = False
|
||||
try:
|
||||
ppid, start = process_stat(self.proc_root / str(self.root_pid) / "stat")
|
||||
if self.root_pid != self.self_pid:
|
||||
result[self.root_pid] = (ppid, start)
|
||||
except (OSError, ValueError):
|
||||
return result, capped, "proc-unavailable", "children", True
|
||||
queue = [self.root_pid]
|
||||
fallback = False
|
||||
while queue and len(result) < MAX_PROCESSES:
|
||||
parent = queue.pop(0)
|
||||
try:
|
||||
raw = bounded_bytes(
|
||||
self.proc_root / str(parent) / "task" / str(parent) / "children", MAX_CHILDREN_BYTES + 1,
|
||||
)
|
||||
except OSError:
|
||||
fallback = True
|
||||
continue
|
||||
if len(raw) > MAX_CHILDREN_BYTES:
|
||||
capped = True
|
||||
fallback = True
|
||||
continue
|
||||
for value in raw.split():
|
||||
if not value.isdigit():
|
||||
continue
|
||||
pid = int(value)
|
||||
if pid == self.self_pid or pid in result:
|
||||
continue
|
||||
if len(result) >= MAX_PROCESSES:
|
||||
capped = True
|
||||
break
|
||||
try:
|
||||
identity = process_stat(self.proc_root / str(pid) / "stat")
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
if identity[0] != parent:
|
||||
continue
|
||||
result[pid] = identity
|
||||
queue.append(pid)
|
||||
if queue:
|
||||
capped = True
|
||||
if fallback:
|
||||
fallback_capped, error = self._scan_fallback(result)
|
||||
capped = capped or fallback_capped
|
||||
return result, capped, error, "children+scan-fallback", True
|
||||
return result, capped, None, "children", capped
|
||||
|
||||
def scan(self):
|
||||
stats, enumeration_capped, provider_error, scope_method, scope_incomplete = self._stats()
|
||||
descendants = set()
|
||||
root = stats.get(self.root_pid)
|
||||
if self.root_identity is None and root is not None:
|
||||
self.root_identity = root
|
||||
if root is not None and self.root_identity != root:
|
||||
provider_error = "root-reused"
|
||||
elif root is not None:
|
||||
descendants.add(self.root_pid)
|
||||
changed = True
|
||||
while changed and len(descendants) < MAX_PROCESSES:
|
||||
changed = False
|
||||
for pid, (ppid, _) in stats.items():
|
||||
if pid not in descendants and ppid in descendants:
|
||||
descendants.add(pid)
|
||||
changed = True
|
||||
if len(descendants) >= MAX_PROCESSES:
|
||||
break
|
||||
if provider_error is None and root is None:
|
||||
provider_error = "root-unavailable"
|
||||
scope_capped = len(descendants) >= MAX_PROCESSES or enumeration_capped
|
||||
current = {}
|
||||
maps_state = {"readable": 0, "unavailable": 0, "capped": 0}
|
||||
for pid in sorted(descendants):
|
||||
process = self.proc_root / str(pid)
|
||||
try:
|
||||
expected = stats[pid]
|
||||
if process_stat(process / "stat") != expected:
|
||||
continue
|
||||
ppid, start = expected
|
||||
comm = (process / "comm").read_text(errors="replace")[:128].strip()
|
||||
cmdline = bounded_bytes(process / "cmdline", MAX_CMDLINE_BYTES)
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
key = (pid, start)
|
||||
try:
|
||||
libraries, state = graphics_libraries(process / "maps")
|
||||
except (OSError, ValueError):
|
||||
libraries, state = set(), "unavailable"
|
||||
maps_state[state] = maps_state.get(state, 0) + 1
|
||||
current[key] = {
|
||||
"ppid": ppid,
|
||||
"role": process_role(comm, cmdline),
|
||||
"libraries": libraries,
|
||||
"identity": expected,
|
||||
"mapState": state,
|
||||
}
|
||||
stable = {}
|
||||
for key, process in current.items():
|
||||
pid = key[0]
|
||||
try:
|
||||
if process_stat(self.proc_root / str(pid) / "stat") != process["identity"]:
|
||||
continue
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
stable[key] = process
|
||||
final = {}
|
||||
valid_pids = {self.root_pid} if any(key[0] == self.root_pid for key in stable) else set()
|
||||
changed = True
|
||||
while changed:
|
||||
changed = False
|
||||
for key, process in stable.items():
|
||||
pid = key[0]
|
||||
if key not in final and (pid == self.root_pid or process["ppid"] in valid_pids):
|
||||
final[key] = process
|
||||
valid_pids.add(pid)
|
||||
changed = True
|
||||
current = final
|
||||
try:
|
||||
root_final = process_stat(self.proc_root / str(self.root_pid) / "stat")
|
||||
except (OSError, ValueError):
|
||||
root_final = None
|
||||
if root_final is None:
|
||||
if provider_error is None:
|
||||
provider_error = "root-unavailable"
|
||||
current = {}
|
||||
elif self.root_identity != root_final:
|
||||
provider_error = "root-reused"
|
||||
current = {}
|
||||
maps_state = {"readable": 0, "unavailable": 0, "capped": 0}
|
||||
for process in current.values():
|
||||
state = process["mapState"]
|
||||
maps_state[state] = maps_state.get(state, 0) + 1
|
||||
started = sorted(set(current) - set(self.known))
|
||||
exited = sorted(set(self.known) - set(current))
|
||||
roles_changed = any(
|
||||
key in self.known and current[key]["role"] != self.known[key]["role"] for key in current
|
||||
)
|
||||
for key in started:
|
||||
self.tokens[key] = self.next_token
|
||||
self.next_token += 1
|
||||
state_changed = maps_state != self.last_maps_state or provider_error != self.last_provider_error
|
||||
payload = self._snapshot(
|
||||
current, started, exited, maps_state, scope_capped, provider_error, scope_method, scope_incomplete,
|
||||
)
|
||||
for key in exited:
|
||||
self.tokens.pop(key, None)
|
||||
self.known = current
|
||||
self.last_maps_state = maps_state
|
||||
self.last_provider_error = provider_error
|
||||
return payload, bool(started or exited or roles_changed or payload["librariesChanged"] or state_changed)
|
||||
|
||||
def _snapshot(self, current, started, exited, maps_state, scope_capped, provider_error,
|
||||
scope_method, scope_incomplete):
|
||||
previous_libraries = {item for process in self.known.values() for item in process["libraries"]}
|
||||
libraries = {item for process in current.values() for item in process["libraries"]}
|
||||
role_counts = {}
|
||||
for process in current.values():
|
||||
role = process["role"]
|
||||
role_counts[role] = role_counts.get(role, 0) + 1
|
||||
started_rows = [{"token": self.tokens[key], "role": current[key]["role"]} for key in started[:32]]
|
||||
exited_rows = [{"token": self.tokens.get(key, 0), "role": self.known[key]["role"]} for key in exited[:32]]
|
||||
library_rows = [{"name": name, "origin": origin} for name, origin in sorted(libraries)[:MAX_LIBRARIES]]
|
||||
return {
|
||||
"schema": SCHEMA,
|
||||
"event": "snapshot",
|
||||
"scope": "root-descendants",
|
||||
"scopeMethod": scope_method,
|
||||
"scopeIncomplete": scope_incomplete,
|
||||
"procView": "guest-visible",
|
||||
"alive": len(current),
|
||||
"roles": role_counts,
|
||||
"started": started_rows,
|
||||
"startedOmitted": max(0, len(started) - len(started_rows)),
|
||||
"exited": exited_rows,
|
||||
"exitedOmitted": max(0, len(exited) - len(exited_rows)),
|
||||
"libraries": library_rows,
|
||||
"librariesOmitted": max(0, len(libraries) - len(library_rows)),
|
||||
"librariesChanged": libraries != previous_libraries,
|
||||
"maps": maps_state,
|
||||
"scopeCapped": scope_capped,
|
||||
"providerStatus": provider_error or "available",
|
||||
}
|
||||
|
||||
|
||||
def parse_args(argv):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--once", action="store_true")
|
||||
parser.add_argument("--watch", action="store_true")
|
||||
parser.add_argument("--root-pid", type=int, default=os.getppid())
|
||||
parser.add_argument("--proc-root", default="/proc")
|
||||
parser.add_argument("--interval-ms", type=int, default=DEFAULT_INTERVAL_MS)
|
||||
parser.add_argument("--duration-ms", type=int, default=DEFAULT_DURATION_MS)
|
||||
parser.add_argument("--max-records", type=int, default=DEFAULT_MAX_RECORDS)
|
||||
args = parser.parse_args(argv)
|
||||
if args.once == args.watch:
|
||||
parser.error("choose exactly one of --once or --watch")
|
||||
if args.root_pid <= 0:
|
||||
parser.error("--root-pid must be positive")
|
||||
args.interval_ms = min(60_000, max(250, args.interval_ms))
|
||||
args.duration_ms = min(DEFAULT_DURATION_MS, max(0, args.duration_ms))
|
||||
args.max_records = min(1_024, max(3, args.max_records))
|
||||
return args
|
||||
|
||||
|
||||
def main(argv=None, environ=None, output=sys.stdout):
|
||||
environ = os.environ if environ is None else environ
|
||||
if environ.get("DROIDDECK_ENHANCED_DIAGNOSTICS") != "1":
|
||||
return 0
|
||||
args = parse_args(sys.argv[1:] if argv is None else argv)
|
||||
collector = Collector(args.proc_root, args.root_pid)
|
||||
emit({
|
||||
"schema": SCHEMA,
|
||||
"event": "provider",
|
||||
"mode": "once" if args.once else "watch",
|
||||
"intervalMs": args.interval_ms,
|
||||
"durationMs": 0 if args.once else args.duration_ms,
|
||||
"maxRecords": args.max_records,
|
||||
"scope": "root-descendants",
|
||||
"procView": "guest-visible",
|
||||
}, output)
|
||||
records = 1
|
||||
started = time.monotonic()
|
||||
last_heartbeat = started
|
||||
ended_normally = False
|
||||
while records < args.max_records - 1:
|
||||
payload, changed = collector.scan()
|
||||
now = time.monotonic()
|
||||
if changed or records == 1 or (now - last_heartbeat) * 1000 >= HEARTBEAT_MS:
|
||||
if not changed and records > 1:
|
||||
payload["event"] = "heartbeat"
|
||||
payload.pop("libraries", None)
|
||||
payload["librariesUnchanged"] = True
|
||||
payload["elapsedMs"] = int((now - started) * 1000)
|
||||
emit(payload, output)
|
||||
records += 1
|
||||
last_heartbeat = now
|
||||
if args.once or payload["providerStatus"] in {"root-unavailable", "root-reused"} or \
|
||||
(now - started) * 1000 >= args.duration_ms:
|
||||
ended_normally = True
|
||||
break
|
||||
time.sleep(args.interval_ms / 1000)
|
||||
if not ended_normally:
|
||||
emit({"schema": SCHEMA, "event": "limit", "reason": "max-records"}, output)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -14,7 +14,7 @@ install)
|
||||
droiddeck-root /usr/bin/apt-get install -y -q retroarch retroarch-assets $cores || { echo "== FAIL apt-get install"; exit 1; }
|
||||
echo "== STEP PPSSPP"
|
||||
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo || { echo "== FAIL flathub"; exit 1; }
|
||||
flatpak install --user -y --noninteractive flathub org.ppsspp.PPSSPP || { echo "== FAIL org.ppsspp.PPSSPP"; exit 1; }
|
||||
/usr/bin/python3 /usr/local/bin/droiddeck-flatpak install org.ppsspp.PPSSPP || { echo "== FAIL org.ppsspp.PPSSPP"; exit 1; }
|
||||
printf '#!/bin/sh\nexec /usr/local/bin/droiddeck-flatpak-run org.ppsspp.PPSSPP "$@"\n' > /usr/local/bin/PPSSPPSDL.new &&
|
||||
chmod 755 /usr/local/bin/PPSSPPSDL.new && mv -f /usr/local/bin/PPSSPPSDL.new /usr/local/bin/PPSSPPSDL || { echo "== FAIL PPSSPPSDL"; exit 1; }
|
||||
;;
|
||||
|
||||
@@ -111,6 +111,12 @@ def d3dgear_hook(game):
|
||||
return {"WINEDLLOVERRIDES": "d3dgear64=d"}, [], "D3DGear capture hook off (it stops the game drawing)"
|
||||
|
||||
|
||||
@fix
|
||||
def supergiant_dotnet_reporter(game):
|
||||
if "basecampbugreporter.native.dll" in game.files:
|
||||
return {"WINEDLLOVERRIDES": "mscoree=n,b"}, [], "Supergiant: allow the builtin mscoree"
|
||||
|
||||
|
||||
@fix
|
||||
def deep_rock_gdk_raytracing(game):
|
||||
if game.stem == "fsd-wingdk-shipping" and not any(game.has_arg(arg) for arg in ("-raytracing", "-noraytracing")):
|
||||
@@ -153,32 +159,6 @@ def little_nightmares_threads(game):
|
||||
return {"PROTONFIXES_DISABLE": "1"}, [], "Little Nightmares: umu-protonfixes off (its -onethread puts the game and renderer on one thread)"
|
||||
|
||||
|
||||
@fix
|
||||
def caravan_sandwitch_feature_level(game):
|
||||
if "caravansandwitch.exe" in game.files or game.stem == "caravansandwitch-win64-shipping":
|
||||
return {"VKD3D_FEATURE_LEVEL": "12_1"}, [], "Caravan SandWitch: D3D12 feature level 12_1 (12_2 hands it mesh shader pipelines vkd3d-proton cannot build)"
|
||||
|
||||
|
||||
@fix
|
||||
def robocop_rogue_city_feature_level(game):
|
||||
if "robocop.exe" in game.files or game.stem == "robocop-win64-shipping":
|
||||
return {"VKD3D_FEATURE_LEVEL": "12_1"}, [], "RoboCop: Rogue City: D3D12 feature level 12_1"
|
||||
|
||||
|
||||
@fix
|
||||
def reskate_feature_level(game):
|
||||
if "skate.exe" in game.files and "reskate.dll" in game.files:
|
||||
return {"VKD3D_FEATURE_LEVEL": "12_1"}, [], "ReSkate (skate.): D3D12 feature level 12_1"
|
||||
|
||||
|
||||
@fix
|
||||
def cyberpunk_feature_level(game):
|
||||
if game.stem == "cyberpunk2077" or (
|
||||
game.stem == "redprelauncher"
|
||||
and os.path.isfile(os.path.join(os.path.dirname(game.exe), "bin", "x64", "Cyberpunk2077.exe"))
|
||||
):
|
||||
return {"VKD3D_FEATURE_LEVEL": "12_1"}, [], "Cyberpunk 2077: D3D12 feature level 12_1"
|
||||
|
||||
def skip_red_launcher(command):
|
||||
if len(command) > 2 and os.path.basename(command[2]).lower() == "redprelauncher.exe":
|
||||
game = os.path.join(os.path.dirname(command[2]), "bin", "x64", "Cyberpunk2077.exe")
|
||||
@@ -243,6 +223,20 @@ def ubisoft_overlay_off(env):
|
||||
print("droiddeck-game-env: Ubisoft Connect overlay left as is (%s)" % error, file=sys.stderr)
|
||||
|
||||
|
||||
def ubisoft_composition_off(proton, env):
|
||||
prefix = Path(env.get("STEAM_COMPAT_DATA_PATH", "/nonexistent")) / "pfx"
|
||||
if not (prefix / UBISOFT_LAUNCHER).is_dir() or not (prefix / "user.reg").is_file():
|
||||
return
|
||||
try:
|
||||
for program in ("upc.exe", "UplayWebCore.exe"):
|
||||
key = r"HKCU\Software\Wine\AppDefaults\%s\DllOverrides" % program
|
||||
subprocess.run([proton, "runinprefix", "reg.exe", "add", key,
|
||||
"/v", "dcomp", "/t", "REG_SZ", "/d", "", "/f"], env=env, check=True)
|
||||
print("droiddeck-game-env: Ubisoft Connect uses CEF without DirectComposition", file=sys.stderr)
|
||||
except (OSError, ValueError, subprocess.CalledProcessError) as error:
|
||||
print("droiddeck-game-env: Ubisoft Connect composition configuration failed (%s)" % error, file=sys.stderr)
|
||||
|
||||
|
||||
PZ_JVM_FLAGS = ("-XX:+UseG1GC", "-XX:TieredStopAtLevel=1")
|
||||
|
||||
|
||||
@@ -372,6 +366,8 @@ def vram_cap(env):
|
||||
cap = "dxgi.maxDeviceMemory = %d" % int(value)
|
||||
own = result.get("DXVK_CONFIG", "").strip().strip(";").strip()
|
||||
result["DXVK_CONFIG"] = cap + "; " + own if own else cap
|
||||
result["DROIDDECK_VRAM_CAP"] = "1"
|
||||
result["DROIDDECK_VRAM_CAP_MB"] = value
|
||||
return result
|
||||
|
||||
|
||||
@@ -528,9 +524,51 @@ def apply_config(env, config, app_id, fixes=None):
|
||||
if dxvk:
|
||||
own = result.get("DXVK_CONFIG", "").strip().rstrip(";").strip()
|
||||
result["DXVK_CONFIG"] = own + "; " + dxvk if own else dxvk
|
||||
# An open driver pair (PanVK, RADV) on a GPU that is not an Adreno: vkd3d-proton reports the
|
||||
# driver's own feature level and shader model. The app-wide 12_2 / 6_9 over-promised what PanVK
|
||||
# has, and an Unreal DX12 game took paths that crashed. A game's own setting still wins.
|
||||
if env.get("BL_OPEN_DRIVER") == "1":
|
||||
game = config.get("games", {}).get(app_id, {}) or {}
|
||||
for name in ("VKD3D_FEATURE_LEVEL", "VKD3D_SHADER_MODEL"):
|
||||
if name not in game and name in result:
|
||||
result.pop(name)
|
||||
result["DROIDDECK_VKD3D_CAPS"] = "driver"
|
||||
return result
|
||||
|
||||
|
||||
def render_path_defaults(command, env):
|
||||
if len(command) < 3 or command[1] != "waitforexitandrun" or Path(command[2]).name.lower() != "spintires.exe":
|
||||
return None
|
||||
own = env.get("DXVK_CONFIG", "")
|
||||
if re.search(r"(?:^|;)\s*dxvk\.tilerMode\s*=", own) or env.get("DXVK_CONFIG_FILE"):
|
||||
return None
|
||||
if Path("dxvk.conf").is_file() or Path(command[2]).with_name("dxvk.conf").is_file():
|
||||
return None
|
||||
driver = env.get("VK_DRIVER_FILES", env.get("VK_ICD_FILENAMES", ""))
|
||||
if Path(driver).parent.name != "DD-Turnip_v0.4.0":
|
||||
return None
|
||||
try:
|
||||
if Path("/sys/class/kgsl/kgsl-3d0/gpu_model").read_text().strip() != "Adreno722":
|
||||
return None
|
||||
with open(driver, encoding="utf-8") as source:
|
||||
library = json.load(source)["ICD"]["library_path"]
|
||||
if Path(library).name != "libvulkan_freedreno.so":
|
||||
return None
|
||||
except (OSError, ValueError, KeyError, TypeError):
|
||||
return None
|
||||
own = own.strip().rstrip(";").strip()
|
||||
env["DXVK_CONFIG"] = own + "; dxvk.tilerMode = False" if own else "dxvk.tilerMode = False"
|
||||
return "Spintires: DXVK tiler heuristics off on Adreno 722"
|
||||
|
||||
|
||||
def bridge_feature_level(env):
|
||||
if env.get("BL_VKBRIDGE") != "1" or env.get("VKD3D_FEATURE_LEVEL") not in ("12_1", "12_2"):
|
||||
return None
|
||||
was = env["VKD3D_FEATURE_LEVEL"]
|
||||
env["VKD3D_FEATURE_LEVEL"] = "12_0"
|
||||
return "Mali bridge: VKD3D_FEATURE_LEVEL %s capped at 12_0 (no ray tracing or mesh shaders)" % was
|
||||
|
||||
|
||||
GAME_DEBUG_CHANNELS = (
|
||||
"timestamp", "pid", "tid", "seh", "unwind", "threadname", "debugstr", "loaddll", "mscoree",
|
||||
)
|
||||
@@ -923,7 +961,7 @@ def ego_core_plan(command, env):
|
||||
return "%s had no thread plan for %d cores; added a copy of its %s-core plan" % (EGO_RESTRICTIONS, count, source.group(2))
|
||||
|
||||
|
||||
def wait_forwarding_signals(process):
|
||||
def wait_forwarding_signals_raw(process):
|
||||
def forward(signum, frame):
|
||||
try:
|
||||
process.send_signal(signum)
|
||||
@@ -936,20 +974,56 @@ def wait_forwarding_signals(process):
|
||||
finally:
|
||||
for signum, handler in previous.items():
|
||||
signal.signal(signum, handler)
|
||||
return code
|
||||
|
||||
|
||||
def wait_forwarding_signals(process):
|
||||
code = wait_forwarding_signals_raw(process)
|
||||
return 128 - code if code < 0 else code
|
||||
|
||||
|
||||
def start(launch, launch_env, digest, after=None):
|
||||
if after:
|
||||
def diagnostic_game_event(event, app_id, values=None):
|
||||
fields = ["event=" + event, "app_id=" + app_id]
|
||||
fields.extend("%s=%s" % item for item in (values or {}).items())
|
||||
print("DROIDDECK_DIAGNOSTICS " + " ".join(fields), file=sys.stderr, flush=True)
|
||||
|
||||
|
||||
def diagnostic_game_exit(app_id, raw_code, source=None, wrapper_status=None):
|
||||
normalized = 128 - raw_code if raw_code < 0 else raw_code
|
||||
values = {
|
||||
"raw_status": raw_code,
|
||||
"normalized_status": normalized,
|
||||
"wrapper_status": normalized if wrapper_status is None else wrapper_status,
|
||||
"signal": -raw_code if raw_code < 0 else 0,
|
||||
}
|
||||
if source is not None:
|
||||
values["source"] = source
|
||||
diagnostic_game_event("game_exit", app_id, values)
|
||||
|
||||
|
||||
def start(launch, launch_env, digest, after=None, diagnostic_app_id=None):
|
||||
if len(launch) > 1 and launch[1] == "waitforexitandrun":
|
||||
ubisoft_composition_off(launch[0], launch_env)
|
||||
launch, launch_env = system_graphics_launch(launch, launch_env)
|
||||
if after or diagnostic_app_id is not None:
|
||||
process = subprocess.Popen(launch, env=launch_env)
|
||||
if diagnostic_app_id is not None:
|
||||
diagnostic_game_event("game_start", diagnostic_app_id)
|
||||
try:
|
||||
return wait_forwarding_signals(process)
|
||||
raw_code = wait_forwarding_signals_raw(process)
|
||||
finally:
|
||||
try:
|
||||
after()
|
||||
except OSError as error:
|
||||
print("droiddeck-game-env: DiRT telemetry fix: prefix ws2_32 not put back (%s); the next launch does it" % error,
|
||||
file=sys.stderr)
|
||||
if after:
|
||||
try:
|
||||
after()
|
||||
except OSError as error:
|
||||
print("droiddeck-game-env: DiRT telemetry fix: prefix ws2_32 not put back (%s); the next launch does it" % error,
|
||||
file=sys.stderr)
|
||||
code = 128 - raw_code if raw_code < 0 else raw_code
|
||||
if digest and after is None and code == 0:
|
||||
record_install_scripts(digest, launch_env)
|
||||
if diagnostic_app_id is not None:
|
||||
diagnostic_game_exit(diagnostic_app_id, raw_code)
|
||||
return code
|
||||
if digest:
|
||||
code = subprocess.run(launch, env=launch_env, check=False).returncode
|
||||
if code == 0:
|
||||
@@ -958,6 +1032,110 @@ def start(launch, launch_env, digest, after=None):
|
||||
return os.execvpe(launch[0], launch, launch_env)
|
||||
|
||||
|
||||
class SystemGraphicsError(ValueError):
|
||||
pass
|
||||
|
||||
|
||||
def system_graphics_launch(command, env):
|
||||
"""Use the APK's PowerVR compatibility files only for actual Proton game launches."""
|
||||
runtime = env.get("DROIDDECK_POWERVR_RUNTIME")
|
||||
if not runtime or not game_id(env) or len(command) < 3 or command[1] != "waitforexitandrun":
|
||||
return command, env
|
||||
directory = Path(runtime)
|
||||
if not directory.is_absolute():
|
||||
raise SystemGraphicsError("system Vulkan runtime path is not absolute")
|
||||
# run-proton.py picks the same payload by name; Xclipse needs a DXVK within 128 bytes of push data.
|
||||
payload = env.get("DROIDDECK_HYBRIS_DXVK") or "dxvk"
|
||||
if not payload.startswith("dxvk") or "/" in payload:
|
||||
raise SystemGraphicsError("invalid DXVK payload name: %s" % payload)
|
||||
required = (
|
||||
"run-proton.py", "wsi/libVkLayer_window_system_integration.so",
|
||||
"wsi/VkLayer_window_system_integration.json", "lib/libVkLayer_hybris_compat.so",
|
||||
*("%s/%s/%s.dll" % (payload, arch, name) for arch in ("x32", "x64")
|
||||
for name in ("d3d8", "d3d9", "d3d10core", "d3d11", "dxgi")),
|
||||
)
|
||||
try:
|
||||
for name in required:
|
||||
path = directory / name
|
||||
if not path.is_file() or not path.stat().st_size:
|
||||
raise SystemGraphicsError("missing system Vulkan component: %s" % name)
|
||||
wrapper = directory / "run-proton.py"
|
||||
if not os.access(wrapper, os.X_OK):
|
||||
raise SystemGraphicsError("system Vulkan Proton wrapper is not executable")
|
||||
except OSError as error:
|
||||
raise SystemGraphicsError("system Vulkan component is unreadable: %s" % error) from error
|
||||
result = dict(env)
|
||||
layers = "VK_LAYER_window_system_integration:" + env.get("DROIDDECK_HYBRIS_LAYERS", "VK_LAYER_HYBRIS_compat")
|
||||
result.update({
|
||||
"HYBRIS_BC_TEXTURES": "dxvk",
|
||||
"VK_LAYER_PATH": ":".join(filter(None, (str(directory / "wsi"), str(directory / "lib"),
|
||||
env.get("DROIDDECK_HYBRIS_LAYER_PATH")))),
|
||||
"VK_INSTANCE_LAYERS": layers,
|
||||
"ENABLE_GAMESCOPE_WSI": "0",
|
||||
"VK_LOADER_LAYERS_DISABLE": "*gamescope*",
|
||||
"DISABLE_VK_LAYER_VALVE_steam_fossilize_1": "1",
|
||||
})
|
||||
for name in ("DISABLE_WSI_LAYER", "PROTON_USE_WINED3D", "ENABLE_VK_LAYER_VALVE_steam_fossilize_1"):
|
||||
result.pop(name, None)
|
||||
return [str(wrapper), *command], result
|
||||
|
||||
|
||||
def game_logs(command, env, app_id, now=None):
|
||||
"""Detailed graphics logs for one game launch, in the session's log folder: Proton's own log,
|
||||
DXVK's and vkd3d-proton's, and the Vulkan driver's startup messages. The app turns this on
|
||||
(BL_GAME_LOGS=1) on a GPU that is not an Adreno, or with Setup's "Detailed graphics logs"."""
|
||||
if env.get("BL_GAME_LOGS") != "1" or not env.get("BL_DEBUG_DIR") or len(command) < 3 \
|
||||
or command[1] != "waitforexitandrun":
|
||||
return env
|
||||
import time
|
||||
stamp = time.strftime("%Y%m%d-%H%M%S", time.localtime(now))
|
||||
name = app_id or re.sub(r"[^A-Za-z0-9._-]+", "_", Path(command[2]).stem)[:40] or "game"
|
||||
parent = Path(env["BL_DEBUG_DIR"]) / "games"
|
||||
try:
|
||||
parent.mkdir(parents=True, exist_ok=True)
|
||||
folder = Path(tempfile.mkdtemp(prefix=stamp + "-", suffix="-" + name, dir=parent))
|
||||
except OSError as error:
|
||||
print("droiddeck-game-env: no game log folder (%s)" % error, file=sys.stderr)
|
||||
return env
|
||||
result = dict(env)
|
||||
result.update({
|
||||
"PROTON_LOG": "1",
|
||||
"PROTON_LOG_DIR": str(folder),
|
||||
"DXVK_LOG_PATH": str(folder),
|
||||
"DXVK_LOG_LEVEL": env.get("DXVK_LOG_LEVEL", "info"),
|
||||
"VKD3D_LOG_FILE": str(folder / "vkd3d.log"),
|
||||
"VKD3D_DEBUG": env.get("VKD3D_DEBUG", "warn"),
|
||||
"VKD3D_SHADER_DEBUG": env.get("VKD3D_SHADER_DEBUG", "none"),
|
||||
"MESA_LOG_FILE": str(folder / "mesa.log"),
|
||||
"PANVK_DEBUG": env.get("PANVK_DEBUG", "startup"),
|
||||
})
|
||||
try:
|
||||
(folder / "launch.txt").write_text("\n".join([
|
||||
"app: %s" % (app_id or "-"),
|
||||
"exe: %s" % command[2],
|
||||
"proton: %s" % command[0],
|
||||
"started: %s" % time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(now)),
|
||||
] + ["%s=%s" % (key, env[key]) for key in sorted(env)
|
||||
if key.startswith(("VK_", "BL_VK", "BL_DRM", "BL_OPEN", "MESA_", "PANVK", "DXVK_", "VKD3D", "ZINK", "TU_", "DROIDDECK_VKD3D"))]) + "\n")
|
||||
except OSError:
|
||||
pass
|
||||
# Whether the game's sound reaches PulseAudio: the streams 20 s and 60 s in, without waiting.
|
||||
try:
|
||||
subprocess.Popen(["sh", "-c", 'for t in 20 40; do sleep $t; { echo "== $(date +%T)"; '
|
||||
'pactl list sink-inputs 2>&1 | head -80; } >> "$1/audio-streams.txt"; done', "audio", str(folder)],
|
||||
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
start_new_session=True)
|
||||
except OSError:
|
||||
pass
|
||||
return result
|
||||
|
||||
|
||||
def exec_proton(command, env):
|
||||
# Synchronization selection has already picked the actual Proton executable.
|
||||
command, env = system_graphics_launch(command, env)
|
||||
os.execvpe(command[0], command, env)
|
||||
|
||||
|
||||
def main():
|
||||
command = sys.argv[1:]
|
||||
if not command:
|
||||
@@ -974,10 +1152,11 @@ def main():
|
||||
except OSError:
|
||||
digest = None
|
||||
app_id = game_id(env)
|
||||
waiting = bool(app_id and len(command) > 1 and command[1] == "waitforexitandrun")
|
||||
diagnostic_app_id = app_id if waiting and os.environ.get("DROIDDECK_ENHANCED_DIAGNOSTICS") == "1" else None
|
||||
dirt_prefix = None
|
||||
if app_id:
|
||||
gl_default = gl_vsync(env)
|
||||
waiting = len(command) > 1 and command[1] == "waitforexitandrun"
|
||||
if waiting:
|
||||
game_images(env)
|
||||
fixes = {}
|
||||
@@ -1024,10 +1203,17 @@ def main():
|
||||
print("droiddeck-game-env: OpenGL does not wait for the screen refresh (vblank_mode=0)", file=sys.stderr)
|
||||
if app_id and len(command) > 1 and command[1] == "waitforexitandrun":
|
||||
command = offline_without_anticheat(command, env)
|
||||
env = game_logs(command, env, app_id)
|
||||
if mic_enabled == "0":
|
||||
env["AUDIO_DIRECT_MIC"] = "0"
|
||||
env = directaudio_settings(env)
|
||||
env = vram_cap(env)
|
||||
note = render_path_defaults(command, env) if app_id else None
|
||||
if note:
|
||||
print("droiddeck-game-env: " + note, file=sys.stderr)
|
||||
note = bridge_feature_level(env)
|
||||
if note:
|
||||
print("droiddeck-game-env: " + note, file=sys.stderr)
|
||||
env = force_ssbs(command, env)
|
||||
game_cores(env)
|
||||
cpu_topology(env, command)
|
||||
@@ -1049,6 +1235,8 @@ def main():
|
||||
print("droiddeck-game-env: Xbox launch could not start (%s)" % error, file=sys.stderr)
|
||||
return 1
|
||||
if xbox_result is not None:
|
||||
if diagnostic_app_id is not None and isinstance(xbox_result, int):
|
||||
diagnostic_game_exit(diagnostic_app_id, xbox_result, "xbox", xbox_result % 256)
|
||||
return xbox_result
|
||||
after = None
|
||||
prefix = env.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/")
|
||||
@@ -1074,13 +1262,13 @@ def main():
|
||||
launch, launch_env = select_sync(command, env, sync)
|
||||
if launch[0] != command[0]:
|
||||
try:
|
||||
return start(launch, launch_env, digest, after)
|
||||
return start(launch, launch_env, digest, after, diagnostic_app_id)
|
||||
except OSError as error:
|
||||
print("droiddeck-game-env: %s could not start (%s); stock launch" % (launch[0], error), file=sys.stderr)
|
||||
launch, launch_env = command, without_pack(launch_env, env)
|
||||
record_stock(sync, launch, launch_env)
|
||||
try:
|
||||
return start(launch, launch_env, digest, after)
|
||||
return start(launch, launch_env, digest, after, diagnostic_app_id)
|
||||
except OSError:
|
||||
if after:
|
||||
try:
|
||||
@@ -1092,4 +1280,8 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
try:
|
||||
sys.exit(main())
|
||||
except SystemGraphicsError as error:
|
||||
print("droiddeck-game-env: PowerVR graphics runtime unavailable (%s)" % error, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
@@ -17,6 +17,7 @@ PROTON_RUN = os.path.join(BIN, "droiddeck-proton-run")
|
||||
APPIMAGE_RUN = os.path.join(BIN, "droiddeck-appimage-run")
|
||||
SCRIPT_RUN = os.path.join(BIN, "droiddeck-script-run")
|
||||
STEAM_LAUNCH = os.path.join(BIN, "droiddeck-steam-launch")
|
||||
PROGRAMS = os.path.join(BIN, "droiddeck-desktop-programs")
|
||||
CACHE = os.path.join(HOME, ".cache", "droiddeck")
|
||||
IMPORTS = {"appimage": ("/opt/appimages/user", "app"), "folder": ("/opt/droiddeck-apps", "entry")}
|
||||
SHARED_FOLDERS = ("alarms", "android", "audiobooks", "dcim", "documents", "download", "movies", "music",
|
||||
@@ -395,6 +396,11 @@ def main(argv):
|
||||
if status != 0 and time.monotonic() - started < QUICK_FAILURE:
|
||||
notify("%s did not start" % os.path.basename(path),
|
||||
"It exited with status %d; the session's desktop.log says why." % status)
|
||||
if what == "windows":
|
||||
try:
|
||||
subprocess.call([sys.executable, PROGRAMS])
|
||||
except OSError as error:
|
||||
say("%s: %s" % (PROGRAMS, error))
|
||||
return status
|
||||
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ def steam_launch(appid, root):
|
||||
library, install = steam_install(appid, root)
|
||||
if not install or not os.path.isdir(install):
|
||||
return None
|
||||
entry = compat()["appinfo_entries"](os.path.join(root, "appcache", "appinfo.vdf")).get(str(appid), {})
|
||||
entry = compat()["appinfo_entries"](os.path.join(root, "appcache", "appinfo.vdf"), wanted={str(appid)}).get(str(appid), {})
|
||||
options = [option for option in entry.get("launch_options", ())
|
||||
if not option["betakey"] and (not option["oslist"] or "windows" in option["oslist"])]
|
||||
options.sort(key=lambda option: (option["type"] not in ("", "default", "none"),
|
||||
@@ -376,7 +376,7 @@ def shortcut_target(appid, program, start, root):
|
||||
def steam_launches(target, program, root):
|
||||
if target.kind != "steam":
|
||||
return False
|
||||
entry = compat()["appinfo_entries"](os.path.join(root, "appcache", "appinfo.vdf")).get(target.appid, {})
|
||||
entry = compat()["appinfo_entries"](os.path.join(root, "appcache", "appinfo.vdf"), wanted={target.appid}).get(target.appid, {})
|
||||
return os.path.relpath(program, target.install).replace(os.sep, "/").lower() in entry.get("launch", ())
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ read_scripts() { xargs -0 -r awk -v want="${1:-redists}" '
|
||||
proc[depth] = 1
|
||||
program = tolower(part[4])
|
||||
sub(/.*[\\\/]/, "", program)
|
||||
if (program ~ /vulkan|uplay|ubisoft/) vulkan[depth] = 1
|
||||
if (program ~ /vulkan|uplay|ubisoft|eaapp/) vulkan[depth] = 1
|
||||
next
|
||||
}
|
||||
if (n == 3) pending = part[2]
|
||||
@@ -245,7 +245,7 @@ for system in "${regs[@]}"; do
|
||||
had=()
|
||||
for line in "${kept[@]}"; do had[$line]=1; done
|
||||
printf '%s\n' "${other[@]}" "${kept[@]}" >"$seeded"
|
||||
echo "== took Vulkan runtime and Ubisoft Connect markers out of $reg"
|
||||
echo "== took Vulkan runtime, Ubisoft Connect and EA app markers out of $reg"
|
||||
fi
|
||||
if [ ${#had[@]} -gt 0 ] && { [ -z "$id" ] || [ "$id" != "$prev" ]; }; then
|
||||
declare -A held=()
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
# A GPU that is not an Adreno (BL_RAISE_NOFILE=1): the open-files limit goes up to the hard limit
|
||||
# for the whole session tree (gamescope, Steam, games). A Mali PanVK session ran out after ten
|
||||
# minutes ("Too many open files" importing sync files and dma-bufs) and froze.
|
||||
if [ "${BL_RAISE_NOFILE:-0}" = 1 ] && [ -z "${BL_INSIDE:-}" ]; then
|
||||
bl_nofile_was="$(ulimit -Sn)/$(ulimit -Hn)"
|
||||
ulimit -Sn "$(ulimit -Hn)" 2>/dev/null || true
|
||||
echo "== open files: soft/hard $bl_nofile_was -> soft $(ulimit -Sn)"
|
||||
[ -n "${BL_DEBUG_DIR:-}" ] && echo "soft/hard $bl_nofile_was -> soft $(ulimit -Sn) (session tree)" > "$BL_DEBUG_DIR/limits.txt" 2>/dev/null
|
||||
unset bl_nofile_was
|
||||
fi
|
||||
export HOME=${HOME:-/root}
|
||||
mode=${1:-desktop}
|
||||
shift || true
|
||||
@@ -22,6 +32,19 @@ if [ -n "${BL_LOG:-}" ] && [ -z "${BL_INSIDE:-}" ]; then
|
||||
echo "== rootfs: $(cat /.version 2>/dev/null || echo unversioned)"
|
||||
fi
|
||||
|
||||
start_diagnostic_inventory() {
|
||||
[ "${DROIDDECK_ENHANCED_DIAGNOSTICS:-0}" = 1 ] || return 0
|
||||
[ -z "${BL_INSIDE:-}" ] || return 0
|
||||
if ! command -v droiddeck-diagnostic-inventory >/dev/null 2>&1; then
|
||||
printf '%s\n' 'DROIDDECK_PROCESS_TRACE {"schema":1,"event":"provider","status":"unavailable"}'
|
||||
return 0
|
||||
fi
|
||||
droiddeck-diagnostic-inventory --watch --root-pid "$$" &
|
||||
_bl_diagnostic_inventory=$!
|
||||
trap 'kill "$_bl_diagnostic_inventory" 2>/dev/null || true; wait "$_bl_diagnostic_inventory" 2>/dev/null || true' EXIT
|
||||
}
|
||||
start_diagnostic_inventory
|
||||
|
||||
sync_timezone() {
|
||||
local zone=${TZ:-}
|
||||
case "$zone" in ''|/*|*..*) return 0 ;; esac
|
||||
@@ -141,8 +164,13 @@ run_gamescope() (
|
||||
BL_STEAM_EXIT_FILE="$status_file" gamescope "$@"
|
||||
compositor_status=$?
|
||||
if read -r child_status < "$status_file" && [[ $child_status =~ ^[0-9]{1,3}$ ]] \
|
||||
&& [ "$child_status" -gt 0 ] && [ "$child_status" -le 255 ]; then
|
||||
exit "$child_status"
|
||||
&& [ "$child_status" -le 255 ]; then
|
||||
if [ "${DROIDDECK_ENHANCED_DIAGNOSTICS:-0}" = 1 ]; then
|
||||
printf 'DROIDDECK_DIAGNOSTICS event=session_exit compositor_status=%s steam_status=%s\n' "$compositor_status" "$child_status"
|
||||
fi
|
||||
[ "$child_status" -eq 0 ] || exit "$child_status"
|
||||
elif [ "${DROIDDECK_ENHANCED_DIAGNOSTICS:-0}" = 1 ]; then
|
||||
printf 'DROIDDECK_DIAGNOSTICS event=session_exit compositor_status=%s steam_status=unavailable\n' "$compositor_status"
|
||||
fi
|
||||
exit "$compositor_status"
|
||||
)
|
||||
@@ -160,7 +188,7 @@ collect_steam_logs() {
|
||||
cp "$fex_state/status.json" "$fex_state/config/Config.json" "$BL_DEBUG_DIR/droiddeck-fex/" 2>/dev/null
|
||||
fi
|
||||
}
|
||||
trap 'collect_steam_logs 2>/dev/null || true' TERM INT HUP
|
||||
trap 'bl_stopping=1; collect_steam_logs 2>/dev/null || true' TERM INT HUP
|
||||
if [ -n "${BL_VK_DRIVER:-}" ]; then
|
||||
bl_icd_lib=$(sed -n 's/.*"library_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$BL_VK_DRIVER" 2>/dev/null | head -1)
|
||||
bl_icd_lib=$(printf '%s' "$bl_icd_lib" | sed 's|\\/|/|g')
|
||||
@@ -177,6 +205,143 @@ if [ -n "${BL_VK_DRIVER:-}" ]; then
|
||||
fi
|
||||
unset bl_icd_lib
|
||||
fi
|
||||
bl_webhelper_layout() {
|
||||
if [ -n "${BL_VKBRIDGE_WEBHELPER_ARGS:-}" ]; then
|
||||
printf '%s\n' "$BL_VKBRIDGE_WEBHELPER_ARGS"
|
||||
elif [ -z "${BL_VKBRIDGE_CEF_ANGLE:-}" ]; then
|
||||
echo stock
|
||||
elif [ "$BL_VKBRIDGE_CEF_ANGLE" = vulkan ] && [ "${BL_VKBRIDGE_CEF_VULKAN:-1}" != 0 ]; then
|
||||
echo "--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan"
|
||||
else
|
||||
echo "--use-gl=angle --use-angle=$BL_VKBRIDGE_CEF_ANGLE"
|
||||
fi
|
||||
}
|
||||
bl_now_ms() {
|
||||
if [ -n "${EPOCHREALTIME:-}" ]; then
|
||||
local t=${EPOCHREALTIME/[.,]/}
|
||||
echo $((10#$t / 1000))
|
||||
else
|
||||
date +%s%3N
|
||||
fi
|
||||
}
|
||||
vkbridge_wait_socket() {
|
||||
local sock=$1 limit=${2:-10000} start now waited
|
||||
[ -n "$sock" ] || return 1
|
||||
if [ -S "$sock" ]; then
|
||||
echo "== vkbridge: server socket ready (waited 0 ms)"
|
||||
return 0
|
||||
fi
|
||||
start=$(bl_now_ms)
|
||||
while :; do
|
||||
now=$(bl_now_ms)
|
||||
waited=$((now - start))
|
||||
if [ -S "$sock" ]; then
|
||||
echo "== vkbridge: server socket ready (waited $waited ms; the server listens after its startup probe)"
|
||||
return 0
|
||||
fi
|
||||
if [ -n "${bl_stopping:-}" ]; then
|
||||
echo "== vkbridge: no server socket after $waited ms; the session is stopping"
|
||||
return 1
|
||||
fi
|
||||
if [ "$waited" -ge "$limit" ]; then
|
||||
echo "== vkbridge: no server socket after $waited ms (gave up at $limit ms)"
|
||||
return 1
|
||||
fi
|
||||
sleep 0.05
|
||||
done
|
||||
}
|
||||
if [ "${BL_VKBRIDGE:-0}" = 1 ]; then
|
||||
bl_vkb_icd=/usr/local/share/vkbridge/droidbridge_icd.json
|
||||
[ -z "${BL_INSIDE:-}" ] && vkbridge_wait_socket "${VKBRIDGE_SOCKET:-}" "${BL_VKBRIDGE_WAIT_MS:-10000}"
|
||||
bl_vkb_missing=
|
||||
[ -r "$bl_vkb_icd" ] || bl_vkb_missing="$bl_vkb_missing icd"
|
||||
[ -r /usr/local/lib/vkbridge/libvulkan_droidbridge.so ] || bl_vkb_missing="$bl_vkb_missing library"
|
||||
[ -S "${VKBRIDGE_SOCKET:-}" ] || bl_vkb_missing="$bl_vkb_missing socket"
|
||||
if [ -z "$bl_vkb_missing" ]; then
|
||||
export VK_DRIVER_FILES=$bl_vkb_icd VK_ICD_FILENAMES=$bl_vkb_icd
|
||||
export VKBRIDGE_SOCKET VKBRIDGE_CLIENT_LOG
|
||||
if [ -r /root/.vkbridge-env ]; then
|
||||
while IFS='=' read -r _k _v; do
|
||||
case "$_k" in VKBRIDGE_*|BL_VKBRIDGE_*) export "$_k=$_v" ;; esac
|
||||
done < /root/.vkbridge-env
|
||||
[ -z "${BL_INSIDE:-}" ] && echo "== vkbridge: development settings from /root/.vkbridge-env: $(cut -d= -f1 /root/.vkbridge-env | tr '\n' ' ')"
|
||||
fi
|
||||
export VKD3D_FEATURE_LEVEL=${VKD3D_FEATURE_LEVEL:-12_0}
|
||||
unset TU_DEBUG
|
||||
if [ -z "${BL_INSIDE:-}" ]; then
|
||||
step "vkbridge self-test"
|
||||
bl_vkb_smoke=$(timeout 60 /usr/local/bin/droiddeck-vkbridge-smoke 2>&1)
|
||||
printf '%s\n' "$bl_vkb_smoke" | sed 's/^/== vkbridge: /'
|
||||
bl_vkb_why=
|
||||
if printf '%s\n' "$bl_vkb_smoke" | grep -qE '^FAIL memory sharing'; then
|
||||
bl_vkb_why=memory
|
||||
elif printf '%s\n' "$bl_vkb_smoke" | grep -qE '^FAIL (image clear|draw)'; then
|
||||
bl_vkb_why=draw
|
||||
fi
|
||||
if [ -n "$bl_vkb_why" ] && [ -r "${BL_VKBRIDGE_FALLBACK_ICD:-}" ]; then
|
||||
export VK_DRIVER_FILES=$BL_VKBRIDGE_FALLBACK_ICD VK_ICD_FILENAMES=$BL_VKBRIDGE_FALLBACK_ICD BL_VKBRIDGE=0
|
||||
export BL_OPEN_DRIVER=1 BL_DRM_STANDIN=/dev/mali0
|
||||
[ "${BL_STEAM_GPU_COMPOSITING:-0}" = 1 ] || export BL_STEAM_SOFT_COMPOSITING=1
|
||||
if [ "$bl_vkb_why" = memory ]; then
|
||||
echo "== vkbridge: memory sharing = none (no method passed the server's self-test); this session uses the PanVK pair instead ($BL_VKBRIDGE_FALLBACK_ICD)"
|
||||
else
|
||||
echo "== vkbridge: self-test failed images or draws; this session uses the PanVK pair instead ($BL_VKBRIDGE_FALLBACK_ICD)"
|
||||
fi
|
||||
[ -n "${BL_DEBUG_DIR:-}" ] && printf '%s\n%s\n' "$BL_VKBRIDGE_FALLBACK_ICD" "$bl_vkb_why" > "$BL_DEBUG_DIR/vkbridge-fallback" 2>/dev/null
|
||||
elif [ -n "$bl_vkb_why" ]; then
|
||||
echo "== vkbridge: self-test failed ($bl_vkb_why) and no PanVK pair is installed to fall back on; expect a black screen or a lost device - set a Mali driver pair in Setup"
|
||||
fi
|
||||
unset bl_vkb_why
|
||||
unset bl_vkb_smoke
|
||||
if command -v vulkaninfo >/dev/null 2>&1; then
|
||||
timeout 30 vulkaninfo --summary 2>&1 | sed -n '/^Devices:/,$p' | head -40 | sed 's/^/== vulkaninfo: /'
|
||||
fi
|
||||
fi
|
||||
[ "${BL_VKBRIDGE:-0}" = 1 ] && echo "== vulkan driver: Mali bridge ($bl_vkb_icd, server at $VKBRIDGE_SOCKET)"
|
||||
else
|
||||
echo "== vulkan driver: Mali bridge requested but NOT usable (icd $bl_vkb_icd, socket ${VKBRIDGE_SOCKET:-unset}; missing:$bl_vkb_missing)"
|
||||
[ -n "${BL_INSIDE:-}" ] || exit 69
|
||||
fi
|
||||
unset bl_vkb_icd bl_vkb_missing
|
||||
fi
|
||||
if [ "${BL_VENUS:-0}" = 1 ] && [ -z "${BL_INSIDE:-}" ] && command -v vulkaninfo >/dev/null 2>&1; then
|
||||
if bl_vn_info=$(timeout 30 vulkaninfo 2>/dev/null); then
|
||||
case $(printf '%s\n' "$bl_vn_info" | grep -m1 'nullDescriptor') in
|
||||
*true*) echo "== venus: nullDescriptor present (Zink keeps the GPU)" ;;
|
||||
*)
|
||||
export GALLIUM_DRIVER=llvmpipe LIBGL_ALWAYS_SOFTWARE=1
|
||||
unset MESA_LOADER_DRIVER_OVERRIDE LIBGL_KOPPER_DRI2
|
||||
echo "== venus: no nullDescriptor on this device even with the Mali compatibility layer; Steam's GL and Xwayland use llvmpipe (software)"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "== venus: vulkaninfo failed or timed out; GL left on Zink"
|
||||
fi
|
||||
unset bl_vn_info
|
||||
fi
|
||||
if [ "${BL_GAME_LOGS:-0}" = 1 ] && [ -z "${BL_INSIDE:-}" ] && [ -n "${BL_DEBUG_DIR:-}" ]; then
|
||||
(
|
||||
{
|
||||
echo "== VK_DRIVER_FILES=${VK_DRIVER_FILES:-} VK_ICD_FILENAMES=${VK_ICD_FILENAMES:-} BL_DRM_STANDIN=${BL_DRM_STANDIN:-}"
|
||||
if command -v vulkaninfo >/dev/null 2>&1; then
|
||||
timeout 10 vulkaninfo --summary
|
||||
echo "== vulkaninfo exit: $?"
|
||||
if timeout 20 vulkaninfo > "$BL_DEBUG_DIR/vulkan-full.txt" 2>&1; then
|
||||
echo "== device extensions (full list in vulkan-full.txt):"
|
||||
sed -n '/^Device Extensions:/,/^$/p' "$BL_DEBUG_DIR/vulkan-full.txt" | grep -o 'VK_[A-Za-z0-9_]*' | sort -u | tr '\n' ' ' | fold -s -w 200
|
||||
echo
|
||||
echo "== key features:"
|
||||
grep -E '^[[:space:]]+(robustBufferAccess2?|robustImageAccess2?|nullDescriptor|logicOp|fillModeNonSolid|shaderClipDistance|shaderCullDistance|dualSrcBlend|geometryShader|scalarBlockLayout|timelineSemaphore|dynamicRendering|synchronization2|maintenance4|maintenance5|maintenance6|shaderDrawParameters|descriptorIndexing|bufferDeviceAddress|vulkanMemoryModel|hostQueryReset|imagelessFramebuffer|samplerYcbcrConversion|shaderInt64|shaderFloat64|shaderInt16|shaderFloat16|storageBuffer16BitAccess|extendedDynamicState[23]?|vertexInputDynamicState|customBorderColors|customBorderColorWithoutFormat|depthClipEnable|multiViewport|textureCompressionBC|indexTypeUint8|rectangularLines|bresenhamLines|transformFeedback|geometryStreams|graphicsPipelineLibrary|pushDescriptor|primitiveTopologyListRestart|dynamicRenderingLocalRead|shaderDemoteToHelperInvocation|subgroupSizeControl|computeFullSubgroups|inlineUniformBlock|pipelineCreationCacheControl) = ' "$BL_DEBUG_DIR/vulkan-full.txt" | sed 's/^[[:space:]]*/ /' | sort -u
|
||||
else
|
||||
echo "== full vulkaninfo failed or timed out (exit $?)"
|
||||
fi
|
||||
else
|
||||
echo "== vulkaninfo is not in this runtime; GPU nodes:"
|
||||
ls -l /dev/kgsl-3d0 /dev/mali0 /dev/dri 2>&1
|
||||
fi
|
||||
} > "$BL_DEBUG_DIR/vulkan-summary.txt" 2>&1
|
||||
) &
|
||||
fi
|
||||
export GAMESCOPE_FORCE_VULKAN_REALTIME=${BL_GAMESCOPE_REALTIME:-0}
|
||||
rm -rf /tmp/.droiddeck-rx
|
||||
|
||||
@@ -189,6 +354,38 @@ nap() {
|
||||
[ -n "${bl_nap_fd:-}" ] || exec {bl_nap_fd}<> <(:)
|
||||
read -r -t "$1" -u "$bl_nap_fd" _ 2>/dev/null || :
|
||||
}
|
||||
# Which program a driver error came from: Mesa's lines ("radv/amdgpu: The CS has been rejected",
|
||||
# "ZINK: vkQueueWaitIdle failed") carry no process name. For the first three minutes of an open
|
||||
# driver pair's session, every process that appears goes into processes.txt with the session log's
|
||||
# line count at that moment, so an error's line number in session.log points at what had just
|
||||
# started. Pure bash over /proc (no execs: see nap).
|
||||
watch_processes() {
|
||||
local out=$BL_DEBUG_DIR/processes.txt log=$BL_DEBUG_DIR/session.log i p pid comm lines
|
||||
local -a argv new
|
||||
local -A seen=()
|
||||
echo "# seconds session.log-lines pid name command line" > "$out" 2>/dev/null || return 0
|
||||
for ((i = 0; i < 360; i++)); do
|
||||
new=()
|
||||
for p in /proc/[0-9]*; do
|
||||
pid=${p#/proc/}
|
||||
[ -n "${seen[$pid]:-}" ] && continue
|
||||
seen[$pid]=1
|
||||
read -r comm < "$p/comm" 2>/dev/null || continue
|
||||
argv=()
|
||||
mapfile -d '' -t argv < "$p/cmdline" 2>/dev/null
|
||||
new+=("$pid"$'\t'"$comm"$'\t'"${argv[*]:0:8}")
|
||||
done
|
||||
if [ ${#new[@]} -gt 0 ]; then
|
||||
lines=0
|
||||
[ -r "$log" ] && { mapfile -t argv < "$log"; lines=${#argv[@]}; argv=(); }
|
||||
for p in "${new[@]}"; do printf '%s\t%s\t%.200s\n' "$SECONDS" "$lines" "$p"; done >> "$out"
|
||||
fi
|
||||
nap 0.5
|
||||
done
|
||||
}
|
||||
if [ "${BL_OPEN_DRIVER:-0}" = 1 ] && [ -z "${BL_INSIDE:-}" ] && [ -n "${BL_DEBUG_DIR:-}" ]; then
|
||||
watch_processes &
|
||||
fi
|
||||
export XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
|
||||
export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
|
||||
export XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
|
||||
@@ -222,6 +419,7 @@ program_cores() {
|
||||
[ "${BL_PIN_CORES:-1}" = 0 ] && return 0
|
||||
command -v taskset >/dev/null 2>&1 || return 0
|
||||
if [ -n "${BL_GAME_CPUS:-}" ]; then echo "$BL_GAME_CPUS"; return 0; fi
|
||||
[ "$mode" = run ] && return 0
|
||||
local f n max min= list=
|
||||
for f in /sys/devices/system/cpu/cpu[0-9]*/cpufreq/cpuinfo_max_freq; do
|
||||
max=$(cat "$f" 2>/dev/null) || continue
|
||||
@@ -305,10 +503,23 @@ if [ -z "${BL_INSIDE:-}" ]; then
|
||||
echo "== gamescope: games at ${nested}x${nested_h} stretched to the ${width}x${height} output"
|
||||
fi
|
||||
fi
|
||||
backend=${BL_GAMESCOPE_BACKEND:-wayland}
|
||||
case "$backend" in
|
||||
wayland) ;;
|
||||
sdl) export SDL_VIDEODRIVER=wayland ;;
|
||||
*) echo "== unsupported gamescope backend: $backend"; exit 64 ;;
|
||||
esac
|
||||
if [ "$mode" = steam ] && [ "${BL_CURSOR_COMPOSITE:-0}" = 1 ]; then
|
||||
export gamescope_cursor_composite=2
|
||||
fi
|
||||
args=(--backend wayland --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$nested_h")
|
||||
# Through the Mali bridge, Steam's UI flickered while gamescope handed its layers to the phone's
|
||||
# compositor as separate planes, for a reason not yet found; one composited image does not
|
||||
# (Mali-G76 MC4: 145 footer flips in 6 s at rest, 0 composited).
|
||||
if [ "$mode" = steam ] && [ "${BL_VKBRIDGE:-0}" = 1 ] && [ -z "${gamescope_composite_force:-}" ]; then
|
||||
export gamescope_composite_force=1
|
||||
echo "== gamescope: composites every frame (Mali bridge: the Steam UI flickers on separate planes)"
|
||||
fi
|
||||
args=(--backend "$backend" --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$nested_h")
|
||||
if [ "$nested" != "$width" ] || [ "$nested_h" != "$height" ]; then
|
||||
args+=(-S stretch)
|
||||
export BL_STRETCHED=1
|
||||
@@ -609,8 +820,75 @@ case $mode in
|
||||
done 2>/dev/null < "/proc/$_p/status"
|
||||
done
|
||||
_bl_rss=$_rss
|
||||
_bl_swap=$_swap
|
||||
echo "$# processes, resident $((_rss / 1024)) MB, in zram $((_swap / 1024)) MB"
|
||||
}
|
||||
bl_memory_read() {
|
||||
local _k _v _u _kind _fields _avg
|
||||
_bl_mem_total=0 _bl_available=-1 _bl_swap_total=0 _bl_swap_free=-1 _bl_psi=0
|
||||
while read -r _k _v _u; do
|
||||
case $_v in ''|*[!0-9]*) continue ;; esac
|
||||
case $_k in
|
||||
MemTotal:) _bl_mem_total=$_v ;;
|
||||
MemAvailable:) _bl_available=$_v ;;
|
||||
SwapTotal:) _bl_swap_total=$_v ;;
|
||||
SwapFree:) _bl_swap_free=$_v ;;
|
||||
esac
|
||||
done 2>/dev/null < /proc/meminfo
|
||||
if [ -r /proc/pressure/memory ]; then
|
||||
while read -r _kind _fields; do
|
||||
[ "$_kind" = some ] || continue
|
||||
_avg=${_fields#avg10=} _avg=${_avg%% *} _avg=${_avg%%.*}
|
||||
case $_avg in ''|*[!0-9]*) ;; *) _bl_psi=$((10#$_avg)) ;; esac
|
||||
done 2>/dev/null < /proc/pressure/memory
|
||||
fi
|
||||
_bl_headroom=$((_bl_mem_total / 5))
|
||||
[ "$_bl_headroom" -ge $((512 * 1024)) ] || _bl_headroom=$((512 * 1024))
|
||||
[ "$_bl_headroom" -le $((1536 * 1024)) ] || _bl_headroom=$((1536 * 1024))
|
||||
_bl_swap_reserve=$((_bl_swap_total / 5))
|
||||
[ "$_bl_swap_reserve" -ge $((256 * 1024)) ] || _bl_swap_reserve=$((256 * 1024))
|
||||
}
|
||||
bl_memory_tight() {
|
||||
[ "$_bl_mem_total" -gt 0 ] && [ "$_bl_available" -ge 0 ] &&
|
||||
{ [ "$_bl_available" -lt "$_bl_headroom" ] ||
|
||||
{ [ "$_bl_psi" -ge 1 ] && [ "$_bl_available" -lt $((_bl_mem_total / 3)) ]; }; }
|
||||
}
|
||||
bl_client_can_pageout() {
|
||||
bl_memory_read
|
||||
bl_zram_usage "${_bl_pids[@]}" > /dev/null
|
||||
[ "$_bl_mem_total" -gt 0 ] && [ "$_bl_swap_total" -gt 0 ] &&
|
||||
[ $((_bl_swap_free - _bl_rss)) -ge "$_bl_swap_reserve" ]
|
||||
}
|
||||
bl_client_can_readback() {
|
||||
bl_memory_read
|
||||
bl_zram_usage "${_bl_pids[@]}" > /dev/null
|
||||
[ "$_bl_mem_total" -gt 0 ] && ! bl_memory_tight &&
|
||||
[ "$_bl_available" -ge $((_bl_swap * 2)) ] &&
|
||||
[ $((_bl_available - _bl_swap)) -ge "$_bl_headroom" ]
|
||||
}
|
||||
bl_client_pressure() {
|
||||
[ "${BL_ZRAM_CLIENT:-1}" = 1 ] && [ "$_bl_game" = 1 ] &&
|
||||
[ "${#_bl_pids[@]}" -gt 0 ] && bl_memory_tight || return 0
|
||||
[ "$_bl_pressure_at" -lt 0 ] ||
|
||||
[ $((SECONDS - _bl_pressure_at)) -ge "$_bl_pressure_backoff" ] || return 0
|
||||
[ "$_bl_packed" -lt 0 ] || [ $((SECONDS - _bl_packed)) -ge 30 ] || return 0
|
||||
_bl_pressure_at=$SECONDS
|
||||
if ! bl_client_can_pageout; then
|
||||
step "zRAM: pressure reclaim skipped, swap headroom too small ($((_bl_swap_free / 1024)) MB free)"
|
||||
return 0
|
||||
fi
|
||||
[ "$_bl_rss" -ge $((128 * 1024)) ] || return 0
|
||||
local _before=$_bl_rss
|
||||
bl_zram_send 1 "memory pressure, compressing the client (available $((_bl_available / 1024)) MB, swap free $((_bl_swap_free / 1024)) MB)" client
|
||||
_bl_packed=$SECONDS
|
||||
[ "${_bl_pageout_complete:-0}" = 1 ] || return 0
|
||||
bl_zram_usage "${_bl_pids[@]}" > /dev/null
|
||||
if [ $((_before - _bl_rss)) -lt $((16 * 1024)) ]; then
|
||||
_bl_pressure_backoff=$((_bl_pressure_backoff * 2 > 300 ? 300 : _bl_pressure_backoff * 2))
|
||||
else
|
||||
_bl_pressure_backoff=30
|
||||
fi
|
||||
}
|
||||
bl_session_others() {
|
||||
local _p
|
||||
_bl_session=()
|
||||
@@ -639,7 +917,11 @@ case $mode in
|
||||
[ "$_left" = 1 ] || break
|
||||
nap 0.2
|
||||
done
|
||||
for _p in "$@"; do rm -f "/tmp/.bl-zram.ack.$_p"; done
|
||||
_bl_pageout_complete=1
|
||||
for _p in "$@"; do
|
||||
if [ -d "/proc/$_p" ] && [ ! -s "/tmp/.bl-zram.ack.$_p" ]; then _bl_pageout_complete=0; fi
|
||||
rm -f "/tmp/.bl-zram.ack.$_p"
|
||||
done
|
||||
}
|
||||
bl_zram_send() {
|
||||
local _mode=$1 _what=$2 _which=$3 _pids _p
|
||||
@@ -677,8 +959,10 @@ case $mode in
|
||||
[ "$_bl_ram_cap" -gt 0 ] && { [ "$_bl_measured" -lt 0 ] || [ $((SECONDS - _bl_measured)) -ge 30 ]; }
|
||||
}
|
||||
_bl_since=-1 _bl_since_apps= _bl_packed=-1 _bl_measured=-1 _bl_unpack=0 _bl_capped=-1 _bl_backoff=30
|
||||
_bl_pressure_at=-1 _bl_pressure_backoff=30
|
||||
while kill -0 $$ 2>/dev/null; do
|
||||
bl_zram_scan
|
||||
bl_memory_read
|
||||
if bl_cap_due; then
|
||||
if bl_over_cap; then
|
||||
if [ "$_bl_capped" -lt 0 ] || [ $((SECONDS - _bl_capped)) -ge "$_bl_backoff" ]; then
|
||||
@@ -700,29 +984,30 @@ case $mode in
|
||||
fi
|
||||
else
|
||||
_bl_backoff=30
|
||||
if [ "$_bl_unpack" = 1 ] && [ "$_bl_game" = 0 ]; then
|
||||
bl_zram_send 0 "back under the RAM cap, reading the client back" client
|
||||
_bl_unpack=0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
bl_client_pressure
|
||||
if [ "$_bl_game" = 1 ] && bl_game_focused; then
|
||||
if [ "$_bl_since" -lt 0 ] || [ "$_bl_since_apps" != "$_bl_apps" ]; then
|
||||
_bl_since=$SECONDS _bl_since_apps=$_bl_apps
|
||||
fi
|
||||
if [ "${BL_ZRAM_CLIENT:-1}" = 1 ] && [ $((SECONDS - _bl_since)) -ge 20 ] && [ "${#_bl_pids[@]}" -gt 0 ] &&
|
||||
{ [ "$_bl_packed" -lt 0 ] || [ $((SECONDS - _bl_packed)) -ge 300 ]; }; then
|
||||
{ [ "$_bl_packed" -lt 0 ] || [ $((SECONDS - _bl_packed)) -ge 300 ]; } && bl_client_can_pageout; then
|
||||
bl_zram_send 1 "compressing the client" client
|
||||
_bl_packed=$SECONDS
|
||||
fi
|
||||
elif [ "$_bl_game" != 1 ]; then
|
||||
if [ "$_bl_packed" -ge 0 ]; then
|
||||
if bl_over_cap; then _bl_unpack=1; else bl_zram_send 0 "game closed, reading the client back" client; _bl_unpack=0; fi
|
||||
_bl_unpack=1
|
||||
fi
|
||||
_bl_since=-1 _bl_packed=-1
|
||||
else
|
||||
_bl_since=-1
|
||||
fi
|
||||
if [ "$_bl_unpack" = 1 ] && [ "$_bl_game" = 0 ] && ! bl_over_cap && bl_client_can_readback; then
|
||||
bl_zram_send 0 "memory recovered, reading the client back" client
|
||||
_bl_unpack=0
|
||||
fi
|
||||
nap 5
|
||||
done
|
||||
) &
|
||||
@@ -973,6 +1258,20 @@ case $mode in
|
||||
export STEAM_STEAMRT_RECURSION_GUARD=1
|
||||
export LD_LIBRARY_PATH=$steam_root/steamrtarm64:$steam_root/steamrtarm64/panorama${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
||||
export SDL_VIDEO_X11_DGAMOUSE=0
|
||||
bl_steam_path=$PATH
|
||||
bl_steam_angle=vulkan
|
||||
bl_steam_presentation=()
|
||||
if [ "${BL_STEAM_GL_PRESENT:-}" = 1 ]; then
|
||||
bl_steam_path="/usr/local/libexec/droiddeck-steam:$PATH"
|
||||
export DISABLE_GAMESCOPE_WSI=1 LIBGL_KOPPER_DISABLE=true
|
||||
bl_steam_angle=gl
|
||||
bl_steam_presentation=(-cef-disable-gpu-compositing)
|
||||
echo "== steam: system PowerVR uses OpenGL/DRI3 through Zink with software CEF compositing"
|
||||
elif [ "${BL_STEAM_SOFT_COMPOSITING:-}" = 1 ]; then
|
||||
bl_steam_presentation=(-cef-disable-gpu-compositing)
|
||||
echo "== steam: open driver pair - software CEF compositing, GPU raster"
|
||||
fi
|
||||
_bl_cef=(-cef-force-gpu "${bl_steam_presentation[@]}" -cef-use-gl=angle "-cef-use-angle=$bl_steam_angle")
|
||||
decky_loader=$HOME/homebrew/services/PluginLoader
|
||||
if [ -f "$HOME/.droiddeck-decky-enabled" ] && [ -x "$decky_loader" ]; then
|
||||
decky_arch=$(cat "$HOME/homebrew/services/.droiddeck-decky-arch" 2>/dev/null || echo unknown)
|
||||
@@ -1022,12 +1321,36 @@ case $mode in
|
||||
fi
|
||||
_bl_ui=(-gamepadui)
|
||||
[ "${BL_STEAM_UI:-}" = desktop ] && _bl_ui=()
|
||||
_bl_cef=(-cef-force-gpu -cef-use-gl=angle -cef-use-angle=vulkan)
|
||||
# bl_steam_angle / bl_steam_presentation (set above) default to the Adreno values (vulkan,
|
||||
# none); only the system-PowerVR path (BL_STEAM_GL_PRESENT=1) changes them.
|
||||
_bl_cef=(-cef-force-gpu "${bl_steam_presentation[@]}" -cef-use-gl=angle "-cef-use-angle=${bl_steam_angle:-vulkan}")
|
||||
[ "${steam_cef_gpu:-1}" = 1 ] || _bl_cef=(-cef-disable-gpu)
|
||||
if [ "${BL_DESKTOP:-}" = 1 ] && [ "${BL_STEAM_UI:-}" = desktop ]; then
|
||||
_bl_cef=(-cef-disable-gpu)
|
||||
_bl_ui=(-nobigpicture)
|
||||
fi
|
||||
if [ "${BL_VKBRIDGE:-0}" = 1 ]; then
|
||||
# On the GPU the Steam UI held about 400 MB through the bridge (Mali-G76 MC4, 3 GB of RAM); with
|
||||
# a game loading beside it, Android's low-memory killer took the whole session down.
|
||||
if [ -z "${BL_VKBRIDGE_CEF_GPU:-}" ]; then
|
||||
_bl_mem_kb=$(awk '/^MemTotal:/ {print $2}' /proc/meminfo 2>/dev/null)
|
||||
if [ "${_bl_mem_kb:-0}" -gt 0 ] && [ "$_bl_mem_kb" -lt 4194304 ]; then
|
||||
BL_VKBRIDGE_CEF_GPU=0
|
||||
echo "== steam: $((_bl_mem_kb / 1024)) MB of RAM: the browser UI draws in software to leave games the memory"
|
||||
fi
|
||||
fi
|
||||
if [ "${BL_VKBRIDGE_CEF_GPU:-1}" = 0 ]; then
|
||||
_bl_cef=(-cef-disable-gpu -cef-disable-gpu-compositing)
|
||||
echo "== steam: browser UI in software (Mali bridge)"
|
||||
elif [ "${_bl_cef[0]}" = -cef-force-gpu ]; then
|
||||
_bl_cef=(-cef-force-gpu -cef-use-gl=angle -cef-use-angle="${BL_VKBRIDGE_CEF_ANGLE:-vulkan}")
|
||||
fi
|
||||
[ "${BL_VKBRIDGE_CEF_LOG:-0}" = 1 ] && _bl_cef+=(-cef-enable-logging=stderr -cef-v=1)
|
||||
[ -n "${BL_VKBRIDGE_CEF_EXTRA:-}" ] && read -r -a _bl_cef_extra <<<"$BL_VKBRIDGE_CEF_EXTRA" && _bl_cef+=("${_bl_cef_extra[@]}")
|
||||
BL_WEBHELPER_ARGS=$(bl_webhelper_layout)
|
||||
export BL_WEBHELPER_ARGS
|
||||
echo "== steam: web helper process layout: $BL_WEBHELPER_ARGS (Mali bridge)"
|
||||
fi
|
||||
if [ "${BL_STEAM_UI:-}" != desktop ]; then
|
||||
if [ "$steam_x64" = 0 ] || [ "${BL_X64_DECK:-1}" != 0 ]; then
|
||||
_bl_ui+=(-steamdeck -steamos3)
|
||||
@@ -1353,6 +1676,36 @@ case $mode in
|
||||
done
|
||||
) &
|
||||
stop_watcher=$!
|
||||
if [ "${BL_VENUS:-0}" = 1 ] && [ -x /usr/local/bin/droiddeck-glprobe ] && [ "${GALLIUM_DRIVER:-}" = zink ]; then
|
||||
LIBGL_DEBUG=verbose MESA_LOG_LEVEL=debug timeout 20 /usr/local/bin/droiddeck-glprobe 2>&1 | grep -v drirc | head -60 | sed 's/^/== glprobe: /'
|
||||
if [ "${PIPESTATUS[0]}" = 1 ]; then
|
||||
VK_LOADER_DEBUG=error,warn timeout 20 /usr/local/bin/droiddeck-glprobe 2>&1 | grep -v drirc | head -40 | sed 's/^/== glprobe (loader): /'
|
||||
DROIDDECK_MALI_COMPAT_TRACE=1 MESA_DEBUG=1 MESA_LOG_LEVEL=debug LIBGL_DEBUG=verbose ZINK_DEBUG=mem VN_DEBUG=init,result,log_ctx_info \
|
||||
timeout 30 /usr/local/bin/droiddeck-glprobe > "${BL_DEBUG_DIR:-/tmp}/glprobe-trace.txt" 2>&1
|
||||
grep -v drirc "${BL_DEBUG_DIR:-/tmp}/glprobe-trace.txt" | head -120 | sed 's/^/== glprobe (trace): /'
|
||||
echo "== glprobe (trace): last pre-device query before Zink gave up: $(grep 'droiddeck-mali-compat: trace:' "${BL_DEBUG_DIR:-/tmp}/glprobe-trace.txt" | grep -v 'trace: extensions:' | tail -1)"
|
||||
command -v vulkaninfo >/dev/null 2>&1 && DROIDDECK_MALI_COMPAT_TRACE=1 timeout 20 vulkaninfo --summary 2>&1 | head -40 | sed 's/^/== glprobe (vulkaninfo): /'
|
||||
bl_gl_ok=
|
||||
for bl_variant in "ZINK_DEBUG=" "ZINK_DEBUG= ZINK_DESCRIPTORS=auto" "ZINK_DEBUG= LIBGL_KOPPER_DISABLE=true" "ZINK_DEBUG= DROIDDECK_MALI_COMPAT=0"; do
|
||||
if env $bl_variant timeout 20 /usr/local/bin/droiddeck-glprobe 2>&1 | grep -v drirc | head -20 | sed "s/^/== glprobe ($bl_variant): /"; [ "${PIPESTATUS[0]}" = 0 ]; then
|
||||
bl_gl_ok=$bl_variant
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -n "$bl_gl_ok" ] && [ "$bl_gl_ok" != "ZINK_DEBUG= DROIDDECK_MALI_COMPAT=0" ]; then
|
||||
for bl_kv in $bl_gl_ok; do
|
||||
case $bl_kv in *=) unset "${bl_kv%=}" ;; *) export "$bl_kv" ;; esac
|
||||
done
|
||||
echo "== venus: GL through Zink starts with: $bl_gl_ok (the Steam client gets that)"
|
||||
else
|
||||
[ -n "$bl_gl_ok" ] && echo "== venus: Zink starts only without the Mali compatibility layer (then without nullDescriptor); not used"
|
||||
export GALLIUM_DRIVER=llvmpipe LIBGL_ALWAYS_SOFTWARE=1
|
||||
unset MESA_LOADER_DRIVER_OVERRIDE LIBGL_KOPPER_DRI2
|
||||
echo "== venus: GL through Zink did not start (see glprobe above); the Steam client's GL uses llvmpipe (software)"
|
||||
fi
|
||||
unset bl_gl_ok bl_variant bl_kv
|
||||
fi
|
||||
fi
|
||||
rm -f "$HOME/.bl-restart-game" "$HOME/.bl-restarted-for"
|
||||
while :; do
|
||||
rm -f "$HOME/.bl-restart-once" "$HOME/.bl-restart-lost"
|
||||
@@ -1378,6 +1731,8 @@ case $mode in
|
||||
desktop_ui_pid=$!
|
||||
fi
|
||||
steam_started=$SECONDS
|
||||
PATH="$bl_steam_path" \
|
||||
BL_STEAM_WEBHELPER="$steam_root/steamrtarm64/steamwebhelper" \
|
||||
"${steam_client[@]}" "${_bl_ui[@]}" "${_bl_cdp[@]}" "${_bl_lang[@]}" -clientbeta "$steam_channel" \
|
||||
-no-cef-sandbox -cef-ozone-platform=x11 "${_bl_cef[@]}" "$@"
|
||||
rc=$?
|
||||
@@ -1387,6 +1742,9 @@ case $mode in
|
||||
wait "$desktop_ui_pid" 2>/dev/null || true
|
||||
fi
|
||||
echo "== steam exited rc=$rc"
|
||||
if [ "${DROIDDECK_ENHANCED_DIAGNOSTICS:-0}" = 1 ]; then
|
||||
printf 'DROIDDECK_DIAGNOSTICS event=steam_exit shell_status=%s elapsed_seconds=%s\n' "$rc" "$steam_ran"
|
||||
fi
|
||||
collect_steam_logs
|
||||
if [ -f "$HOME/.config/droiddeck/fex-wanted" ] && [ -x /usr/local/bin/droiddeck-fex ]; then
|
||||
/usr/local/bin/droiddeck-fex status >/dev/null 2>&1 || true
|
||||
|
||||
@@ -317,6 +317,74 @@ FRAME_LIMIT_JS = r"""
|
||||
return "installed";
|
||||
})()
|
||||
"""
|
||||
WINDOW_BINDING = "droiddeckWindowAction"
|
||||
WINDOW_TARGET = "createflags=18"
|
||||
WINDOW_MOVES = {"nw": 0, "n": 1, "ne": 2, "e": 3, "se": 4, "s": 5, "sw": 6, "w": 7, "move": 8}
|
||||
WINDOW_JS = r"""
|
||||
(() => {
|
||||
if (window.__droiddeckWindow) return "present";
|
||||
const EDGE = 5, CORNER = 10, THRESHOLD = 3;
|
||||
const CURSORS = { n: "ns-resize", s: "ns-resize", e: "ew-resize", w: "ew-resize",
|
||||
ne: "nesw-resize", sw: "nesw-resize", nw: "nwse-resize", se: "nwse-resize" };
|
||||
const send = action => window.droiddeckWindowAction(action);
|
||||
const filled = () => innerWidth >= screen.availWidth && innerHeight >= screen.availHeight - 60;
|
||||
const side = e => {
|
||||
if (filled()) return "";
|
||||
const right = innerWidth - e.clientX, bottom = innerHeight - e.clientY;
|
||||
const near = (a, b) => a < EDGE || (a < CORNER && b < CORNER);
|
||||
const across = Math.min(e.clientX, right), along = Math.min(e.clientY, bottom);
|
||||
const v = near(e.clientY, across) ? "n" : near(bottom, across) ? "s" : "";
|
||||
const h = near(e.clientX, along) ? "w" : near(right, along) ? "e" : "";
|
||||
return v + h;
|
||||
};
|
||||
const dragging = (x, y) => {
|
||||
for (const node of document.elementsFromPoint(x, y)) {
|
||||
const region = getComputedStyle(node).webkitAppRegion;
|
||||
if (region === "drag") return true;
|
||||
if (region === "no-drag") return false;
|
||||
}
|
||||
return [...document.querySelectorAll("*")].some(node => {
|
||||
if (getComputedStyle(node).webkitAppRegion !== "drag") return false;
|
||||
const box = node.getBoundingClientRect();
|
||||
return x >= box.left && x < box.right && y >= box.top && y < box.bottom;
|
||||
});
|
||||
};
|
||||
const style = document.createElement("style");
|
||||
document.documentElement.append(style);
|
||||
let press = null, shown = "";
|
||||
addEventListener("pointermove", e => {
|
||||
if (press) {
|
||||
if (Math.hypot(e.clientX - press.x, e.clientY - press.y) >= THRESHOLD) {
|
||||
const hit = dragging(press.x, press.y);
|
||||
press = null;
|
||||
if (hit) send("move");
|
||||
}
|
||||
return;
|
||||
}
|
||||
const cursor = e.buttons ? shown : side(e);
|
||||
if (cursor !== shown) {
|
||||
shown = cursor;
|
||||
style.textContent = cursor ? `* { cursor: ${CURSORS[cursor]} !important; }` : "";
|
||||
}
|
||||
}, true);
|
||||
addEventListener("pointerdown", e => {
|
||||
if (e.button !== 0) return;
|
||||
const edge = side(e);
|
||||
if (edge) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
send(edge);
|
||||
} else {
|
||||
press = { x: e.clientX, y: e.clientY };
|
||||
}
|
||||
}, true);
|
||||
addEventListener("pointerup", () => { press = null; }, true);
|
||||
addEventListener("dblclick", e => { if (dragging(e.clientX, e.clientY) && !side(e)) send("maximize"); }, true);
|
||||
SteamClient.Window.ToggleMaximize = () => send("maximize");
|
||||
window.__droiddeckWindow = true;
|
||||
return "installed";
|
||||
})()
|
||||
"""
|
||||
FILE_BINDING = "droiddeckOpenFileDialog"
|
||||
FILE_JS = r"""
|
||||
(() => {
|
||||
@@ -739,6 +807,71 @@ class Watcher:
|
||||
return any(n in wanted or n.startswith("appmanifest_") for n in names)
|
||||
|
||||
|
||||
class XMessage(ctypes.Structure):
|
||||
_fields_ = [("type", ctypes.c_int), ("serial", ctypes.c_ulong), ("send_event", ctypes.c_int),
|
||||
("display", ctypes.c_void_p), ("window", ctypes.c_ulong), ("message_type", ctypes.c_ulong),
|
||||
("format", ctypes.c_int), ("data", ctypes.c_long * 5), ("pad", ctypes.c_long * 20)]
|
||||
|
||||
|
||||
X_ERRORS = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_void_p)(lambda display, error: 0)
|
||||
|
||||
|
||||
def window_action(action):
|
||||
if action != "maximize" and action not in WINDOW_MOVES:
|
||||
return False
|
||||
x11 = ctypes.CDLL("libX11.so.6")
|
||||
x11.XOpenDisplay.restype = ctypes.c_void_p
|
||||
x11.XOpenDisplay.argtypes = [ctypes.c_char_p]
|
||||
x11.XDefaultRootWindow.restype = ctypes.c_ulong
|
||||
x11.XDefaultRootWindow.argtypes = [ctypes.c_void_p]
|
||||
x11.XInternAtom.restype = ctypes.c_ulong
|
||||
x11.XInternAtom.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int]
|
||||
x11.XGetWindowProperty.argtypes = [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_long, ctypes.c_long,
|
||||
ctypes.c_int, ctypes.c_ulong] + [ctypes.c_void_p] * 5
|
||||
x11.XQueryPointer.argtypes = [ctypes.c_void_p, ctypes.c_ulong] + [ctypes.c_void_p] * 7
|
||||
x11.XSendEvent.argtypes = [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_int, ctypes.c_long, ctypes.c_void_p]
|
||||
x11.XFree.argtypes = [ctypes.c_void_p]
|
||||
x11.XFlush.argtypes = [ctypes.c_void_p]
|
||||
x11.XCloseDisplay.argtypes = [ctypes.c_void_p]
|
||||
x11.XSetErrorHandler(X_ERRORS)
|
||||
display = x11.XOpenDisplay(None)
|
||||
if not display:
|
||||
return False
|
||||
try:
|
||||
root = x11.XDefaultRootWindow(display)
|
||||
atom = lambda name: x11.XInternAtom(display, name, 0)
|
||||
kind, width, count, after = ctypes.c_ulong(), ctypes.c_int(), ctypes.c_ulong(), ctypes.c_ulong()
|
||||
data = ctypes.c_void_p()
|
||||
if x11.XGetWindowProperty(display, root, atom(b"_NET_ACTIVE_WINDOW"), 0, 1, 0, 33, ctypes.byref(kind),
|
||||
ctypes.byref(width), ctypes.byref(count), ctypes.byref(after),
|
||||
ctypes.byref(data)) != 0 or not data.value:
|
||||
return False
|
||||
window = ctypes.cast(data, ctypes.POINTER(ctypes.c_ulong))[0] if count.value else 0
|
||||
x11.XFree(data)
|
||||
if not window:
|
||||
return False
|
||||
if action == "maximize":
|
||||
kind_name = b"_NET_WM_STATE"
|
||||
values = [2, atom(b"_NET_WM_STATE_MAXIMIZED_VERT"), atom(b"_NET_WM_STATE_MAXIMIZED_HORZ"), 1, 0]
|
||||
else:
|
||||
ignored = ctypes.c_ulong()
|
||||
x, y, inner, mask = ctypes.c_int(), ctypes.c_int(), ctypes.c_int(), ctypes.c_uint()
|
||||
if not x11.XQueryPointer(display, root, ctypes.byref(ignored), ctypes.byref(ignored), ctypes.byref(x),
|
||||
ctypes.byref(y), ctypes.byref(inner), ctypes.byref(inner), ctypes.byref(mask)):
|
||||
return False
|
||||
if not mask.value & 0x100:
|
||||
return False
|
||||
kind_name = b"_NET_WM_MOVERESIZE"
|
||||
values = [x.value, y.value, WINDOW_MOVES[action], 1, 1]
|
||||
message = XMessage(type=33, window=window, message_type=atom(kind_name), format=32)
|
||||
message.data[:] = values
|
||||
sent = x11.XSendEvent(display, root, 0, (1 << 19) | (1 << 20), ctypes.byref(message))
|
||||
x11.XFlush(display)
|
||||
return bool(sent)
|
||||
finally:
|
||||
x11.XCloseDisplay(display)
|
||||
|
||||
|
||||
class Helper:
|
||||
def __init__(self, steam_root, port, steamos=False, files_only=False):
|
||||
self.steam_root = steam_root
|
||||
@@ -757,6 +890,8 @@ class Helper:
|
||||
self.controls_installed = False
|
||||
self.frame_limit_state = None
|
||||
self.frame_limit_retry = 0
|
||||
self.windows = {}
|
||||
self.windows_retry = 0
|
||||
|
||||
def sync_controls(self):
|
||||
try:
|
||||
@@ -780,6 +915,41 @@ class Helper:
|
||||
except (OSError, ValueError, TypeError):
|
||||
pass
|
||||
|
||||
def sync_windows(self):
|
||||
if os.environ.get("XDG_CURRENT_DESKTOP") != "KDE":
|
||||
return
|
||||
if time.monotonic() >= self.windows_retry:
|
||||
self.windows_retry = time.monotonic() + 2
|
||||
try:
|
||||
targets = http_get(self.port, "/json/list")
|
||||
except (OSError, ValueError):
|
||||
targets = []
|
||||
seen = set()
|
||||
for target in targets:
|
||||
url = target.get("webSocketDebuggerUrl")
|
||||
if WINDOW_TARGET not in target.get("url", "").split("&")[0] or not url:
|
||||
continue
|
||||
seen.add(target.get("id"))
|
||||
try:
|
||||
page = self.windows.get(target.get("id"))
|
||||
if page is None:
|
||||
page = Page(self.port, "/" + url.split("/", 3)[3])
|
||||
page.call("Runtime.addBinding", {"name": WINDOW_BINDING}, timeout=5)
|
||||
self.windows[target.get("id")] = page
|
||||
page.evaluate(WINDOW_JS, timeout=5)
|
||||
except (Closed, OSError, RuntimeError, ValueError) as e:
|
||||
say("window controls: %s" % e)
|
||||
self.windows.pop(target.get("id"), None)
|
||||
for ident in set(self.windows) - seen:
|
||||
del self.windows[ident]
|
||||
for ident, page in list(self.windows.items()):
|
||||
try:
|
||||
for event in page.drain():
|
||||
if called(event, WINDOW_BINDING):
|
||||
window_action(event.get("params", {}).get("payload"))
|
||||
except (Closed, OSError, ValueError):
|
||||
del self.windows[ident]
|
||||
|
||||
def sync_frame_limit(self):
|
||||
if self.frame_limit_state in ("installed", "present") or time.monotonic() < self.frame_limit_retry:
|
||||
return
|
||||
@@ -1025,7 +1195,9 @@ class Helper:
|
||||
say("attached to the client on port %d for its file dialogs" % self.port)
|
||||
while True:
|
||||
self.sync_controls()
|
||||
self.sync_windows()
|
||||
sources = [self.page.ws] + ([self.chooser[1].stdout] if self.chooser is not None else [])
|
||||
sources += [page.ws for page in self.windows.values()]
|
||||
queued = self.page.ws.pending() or bool(self.page.events)
|
||||
ready = [self.page.ws] if queued else select.select(sources, [], [], 0.25)[0]
|
||||
if self.chooser is not None and self.chooser[1].stdout in ready:
|
||||
@@ -1044,7 +1216,9 @@ class Helper:
|
||||
while True:
|
||||
self.sync_controls()
|
||||
self.sync_frame_limit()
|
||||
self.sync_windows()
|
||||
sources = [self.page.ws] + ([watcher] if watcher.fileno() >= 0 else [])
|
||||
sources += [page.ws for page in self.windows.values()]
|
||||
if self.chooser is not None:
|
||||
sources.append(self.chooser[1].stdout)
|
||||
queued = self.page.ws.pending() or bool(self.page.events)
|
||||
|
||||
@@ -11,6 +11,7 @@ import time
|
||||
import unicodedata
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
import zlib
|
||||
|
||||
STATE = ".droiddeck-games.json"
|
||||
TRIED = ".droiddeck-import-tried.json"
|
||||
@@ -301,15 +302,76 @@ def installed_build(folder, appid, installdir):
|
||||
if not (folder / ".download_complete").is_file():
|
||||
return None
|
||||
try:
|
||||
ids = json.loads((folder / ".DepotDownloader/depot.config").read_text())["installedManifestIDs"]
|
||||
depots = sorted((int(depot), int(gid)) for depot, gid in ids.items())
|
||||
except (OSError, ValueError, KeyError, TypeError, AttributeError):
|
||||
return None
|
||||
depots = config_depots((folder / ".DepotDownloader/depot.config").read_bytes())
|
||||
except OSError:
|
||||
depots = None
|
||||
if not depots:
|
||||
depots = completed_depots(folder / ".DepotDownloader/completed")
|
||||
if not depots or not all(0 < depot < 0x80000000 and 0 < gid < 0x7FFFFFFFFFFFFFFF for depot, gid in depots):
|
||||
return None
|
||||
return "".join(f' "{depot}"\n {{\n "manifest" "{gid}"\n }}\n' for depot, gid in depots)
|
||||
|
||||
|
||||
def varint(data, i):
|
||||
value = shift = 0
|
||||
while True:
|
||||
byte = data[i]
|
||||
i += 1
|
||||
value |= (byte & 0x7F) << shift
|
||||
shift += 7
|
||||
if byte < 0x80:
|
||||
return value, i
|
||||
|
||||
|
||||
def proto_fields(data):
|
||||
i = 0
|
||||
while i < len(data):
|
||||
key, i = varint(data, i)
|
||||
kind = key & 7
|
||||
if kind == 0:
|
||||
value, i = varint(data, i)
|
||||
elif kind == 2:
|
||||
size, i = varint(data, i)
|
||||
value, i = data[i:i + size], i + size
|
||||
elif kind in (1, 5):
|
||||
value, i = None, i + (8 if kind == 1 else 4)
|
||||
else:
|
||||
raise ValueError
|
||||
yield key >> 3, kind, value
|
||||
|
||||
|
||||
def config_depots(data):
|
||||
try:
|
||||
ids = json.loads(data.decode())["installedManifestIDs"]
|
||||
return sorted((int(depot), int(gid)) for depot, gid in ids.items())
|
||||
except (ValueError, KeyError, TypeError, AttributeError):
|
||||
pass
|
||||
try:
|
||||
depots = {}
|
||||
for number, kind, entry in proto_fields(zlib.decompress(data, -15)):
|
||||
if number == 1 and kind == 2:
|
||||
fields = {n: v for n, k, v in proto_fields(entry) if k == 0}
|
||||
if 1 in fields and 2 in fields:
|
||||
depots[fields[1]] = fields[2]
|
||||
return sorted(depots.items()) or None
|
||||
except (zlib.error, ValueError, IndexError):
|
||||
return None
|
||||
|
||||
|
||||
def completed_depots(completed):
|
||||
newest = {}
|
||||
try:
|
||||
for manifest in completed.iterdir():
|
||||
match = re.fullmatch(r"(\d+)_(\d+)\.manifest", manifest.name)
|
||||
if match and manifest.is_file():
|
||||
depot, gid, mtime = int(match[1]), int(match[2]), manifest.stat().st_mtime
|
||||
if depot not in newest or mtime > newest[depot][0]:
|
||||
newest[depot] = (mtime, gid)
|
||||
except OSError:
|
||||
return []
|
||||
return sorted((depot, gid) for depot, (_, gid) in newest.items())
|
||||
|
||||
|
||||
def update_not_started(text, steamapps, appid, installdir):
|
||||
fields = dict(re.findall(r'^\s*"(\w+)"\s*"([^"]*)"', text, re.M))
|
||||
return (fields.get("installdir") == installdir and fields.get("buildid", "0") == "0"
|
||||
@@ -318,6 +380,13 @@ def update_not_started(text, steamapps, appid, installdir):
|
||||
and not (steamapps / "downloading" / str(appid)).exists())
|
||||
|
||||
|
||||
def update_on_launch(text):
|
||||
if re.search(r'^\s*"AutoUpdateBehavior"', text, re.M):
|
||||
return re.sub(r'^(\s*"AutoUpdateBehavior"\s*")0(")', r"\g<1>1\2", text, count=1, flags=re.M)
|
||||
end = text.rstrip().rfind("}")
|
||||
return text[:end] + '\t"AutoUpdateBehavior"\t\t"1"\n' + text[end:]
|
||||
|
||||
|
||||
def libraries(steam_root):
|
||||
try:
|
||||
text = (Path(steam_root) / "steamapps/libraryfolders.vdf").read_text(errors="replace")
|
||||
@@ -374,9 +443,11 @@ def seed_install(steam_root, game, appid):
|
||||
minimal = ('"AppState"\n{\n' + f' "appid" "{appid}"\n "Universe" "1"\n "name" "{title}"\n'
|
||||
+ f' "StateFlags" "4"\n "installdir" "{name}"\n' + '}\n')
|
||||
legacy = minimal.replace(' "Universe" "1"\n', '')
|
||||
# Steam checks every file of an import with no build before updating it, from scratch each time it is interrupted.
|
||||
bare = minimal[:-2] + ' "AutoUpdateBehavior" "1"\n}\n'
|
||||
build = installed_build(source, appid, name)
|
||||
if build is None:
|
||||
content = minimal
|
||||
content = bare
|
||||
elif build.lstrip().startswith('"AppState"'):
|
||||
content = build
|
||||
else:
|
||||
@@ -390,13 +461,21 @@ def seed_install(steam_root, game, appid):
|
||||
for root in libraries(steam_root):
|
||||
existing = root / "steamapps" / manifest.name
|
||||
if existing.is_file():
|
||||
if (existing == manifest and source.is_dir() and target.is_symlink()
|
||||
and os.readlink(target) == str(source)
|
||||
and existing.read_text() != content
|
||||
and (existing.read_text() in (minimal, legacy, legacy.replace('"StateFlags" "4"', '"StateFlags" "2"'))
|
||||
or (build is not None and update_not_started(existing.read_text(), steamapps, appid, name)))):
|
||||
if not (existing == manifest and source.is_dir() and target.is_symlink()
|
||||
and os.readlink(target) == str(source)):
|
||||
return True
|
||||
text = existing.read_text()
|
||||
staging = (steamapps / "downloading" / str(appid)).exists()
|
||||
if build is None and update_not_started(text, steamapps, appid, name):
|
||||
wanted = update_on_launch(text)
|
||||
elif ((text in (minimal, bare, legacy, legacy.replace('"StateFlags" "4"', '"StateFlags" "2"')) and not staging)
|
||||
or (build is not None and update_not_started(text, steamapps, appid, name))):
|
||||
wanted = content
|
||||
else:
|
||||
wanted = text
|
||||
if wanted != text:
|
||||
temp = manifest.with_suffix(".droiddeck")
|
||||
temp.write_text(content)
|
||||
temp.write_text(wanted)
|
||||
os.replace(temp, manifest)
|
||||
return True
|
||||
if not source.is_dir():
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
# Staged as taskset in a PATH directory used only by the Steam client.
|
||||
# Valve's ARM64 helper uses `taskset 0x7c /path/to/steamwebhelper ...` and exits
|
||||
# before starting the browser when Android denies sched_setaffinity.
|
||||
set -u
|
||||
if [ "$#" -ge 2 ] && [[ "$1" =~ ^(0[xX])?[0-9a-fA-F]+$ ]] &&
|
||||
[ -n "${BL_STEAM_WEBHELPER:-}" ] && [ "$2" -ef "$BL_STEAM_WEBHELPER" ]; then
|
||||
mask=$1
|
||||
shift
|
||||
# Pin this wrapper before exec; never retry a helper that has already run.
|
||||
if ! /usr/bin/taskset -p "$mask" "$$" >/dev/null 2>&1; then
|
||||
echo "droiddeck: Steam helper CPU pinning unavailable; using the allowed CPUs" >&2
|
||||
fi
|
||||
exec -- "$@"
|
||||
fi
|
||||
# Queries, existing-process changes, and other programs retain taskset's behavior.
|
||||
exec /usr/bin/taskset "$@"
|
||||
@@ -730,7 +730,7 @@ if x64_gpu; then
|
||||
echo "export FEX_THUNKCONFIG='$X64_HOME/thunks.json'"
|
||||
echo "unset LIBGL_ALWAYS_SOFTWARE LIBGL_DRI3_DISABLE GALLIUM_DRIVER"
|
||||
for v in $gpu_vars; do
|
||||
eval "val=\${$v-}"; [ -n "$val" ] && printf "export %s='%s'\n" "$v" "$val"
|
||||
eval "val=\${$v-}"; [ -n "$val" ] && printf "export %s='%s'\n" "$v" "${val//\'/\'\\\'\'}"
|
||||
done
|
||||
} > "$X64_HOME/game-gpu.env"
|
||||
fi
|
||||
@@ -829,7 +829,7 @@ x64_exec() {
|
||||
mkdir -p "$STEAM_X64/logs"
|
||||
touch "$STEAM_X64/logs/bootstrap_log.txt"
|
||||
( tail -n0 -F --pid=$$ "$STEAM_X64/logs/bootstrap_log.txt" 2>/dev/null |
|
||||
grep --line-buffered -oE 'Downloading update \([0-9,]+ of [0-9,]+ KB\)' | sed -u 's/,//g' >&2 ) &
|
||||
grep --line-buffered -oE 'Downloading update \([0-9,]+ of [0-9,]+ KB\)|^[[:space:]]*(\[[^]]+\][[:space:]]*)*(Extracting package|Installing update)\.\.\.[[:space:]]*$' | sed -u 's/,//g' >&2 ) &
|
||||
echo "== x86-64 client: steamrt64 $(x64_manifest_version steamrt64) (the client may update itself)" >&2
|
||||
x64_webhelper_gpu && { x64_gpu_watch >&2 & }
|
||||
exec "${BL_FEX:-/usr/local/bin/FEX}" "$STEAM_X64/steamrt64/steam" "$@"
|
||||
|
||||
@@ -357,6 +357,27 @@ GOG_ROOTS = {"HKEY_LOCAL_MACHINE": "HKEY_LOCAL_MACHINE", "HKLM": "HKEY_LOCAL_MAC
|
||||
"HKEY_CLASSES_ROOT": "HKEY_CLASSES_ROOT", "HKCR": "HKEY_CLASSES_ROOT"}
|
||||
WINE_USER = "C:\\users\\steamuser"
|
||||
|
||||
# GOG completes some installs by running a support installer from the game folder (the
|
||||
# goggame-<id>.script "Execute" action). Under ARM64 FEX that 32-bit self-extractor stops at
|
||||
# "Path not found", so the values it would write are applied here instead. Only products GOG
|
||||
# ships no setRegistry action for are listed; a script's own entries always win.
|
||||
# The Witcher: Enhanced Edition (#694) exits during startup unless the installer's
|
||||
# HKLM\Software\CD Projekt Red\The Witcher keys exist - the same ones The Witcher's own
|
||||
# setup writes (InstallFolder, RegionVersion, IsDjinniInstalled) plus its language.
|
||||
GOG_INSTALL_REGISTRY = {
|
||||
"1207658924": [
|
||||
("HKLM", "Software\\CD Projekt Red\\The Witcher", "InstallFolder", "string", "{app}\\"),
|
||||
("HKLM", "Software\\CD Projekt Red\\The Witcher", "RegionVersion", "string", "US"),
|
||||
("HKLM", "Software\\CD Projekt Red\\The Witcher", "IsDjinniInstalled", "dword", 1),
|
||||
("HKLM", "Software\\CD Projekt Red\\The Witcher", "Language", "string", "{language}"),
|
||||
("HKCU", "Software\\CD Projekt RED\\Witcher\\Settings", "TextLanguage", "string", "{language}"),
|
||||
("HKCU", "Software\\CD Projekt RED\\Witcher\\Settings", "VoiceLanguage", "string", "{language}"),
|
||||
],
|
||||
}
|
||||
# The Witcher's text and voice language IDs, from its installer's registry data.
|
||||
GOG_LANGUAGE_IDS = {"en": 3, "fr": 11, "de": 10, "es": 12, "it": 13, "ru": 14, "cs": 15, "hu": 16,
|
||||
"zh": 21, "pl": 5}
|
||||
|
||||
|
||||
def gog_paths(folder, product):
|
||||
app = windows_path(str(folder))
|
||||
@@ -416,8 +437,94 @@ def gog_entry(arguments, paths):
|
||||
return None
|
||||
|
||||
|
||||
def gog_registry(folder):
|
||||
entries, skipped = [], 0
|
||||
def gog_installed_products(folder):
|
||||
products = {}
|
||||
for info in sorted(Path(folder).glob("goggame-*.info")):
|
||||
product = info.name[len("goggame-"):-len(".info")]
|
||||
if not product.isdigit():
|
||||
continue
|
||||
try:
|
||||
products[product] = json.loads(info.read_text(encoding="utf-8-sig"))
|
||||
except (OSError, ValueError):
|
||||
products[product] = {}
|
||||
return products
|
||||
|
||||
|
||||
def gog_language_id(info):
|
||||
languages = info.get("languages") if isinstance(info, dict) else None
|
||||
if isinstance(languages, str):
|
||||
languages = [languages]
|
||||
code = str(languages[0]).lower()[:2] if isinstance(languages, list) and languages else ""
|
||||
return GOG_LANGUAGE_IDS.get(code, GOG_LANGUAGE_IDS["en"])
|
||||
|
||||
|
||||
GOG_VALUE_HIVES = {"hklm": "local_machine", "hkey_local_machine": "local_machine",
|
||||
"hkcu": "current_user", "hkey_current_user": "current_user",
|
||||
"hkcr": "classes_root", "hkey_classes_root": "classes_root"}
|
||||
|
||||
|
||||
def gog_value_key(root, section, name, view32=True):
|
||||
"""A registry value's identity, keeping the root and the 32-bit view apart.
|
||||
|
||||
The fallback import always targets the 32-bit view (`/reg:32`), which Wine keeps under
|
||||
`Software\\Wow6432Node` for HKLM: a native HKLM value must not pass for the 32-bit one.
|
||||
HKCU\\Software is shared by both views, so its values read the same either way.
|
||||
"""
|
||||
text = section.replace("\\\\", "\\").strip("\\").lower()
|
||||
hive = GOG_VALUE_HIVES.get(root.lower(), root.lower())
|
||||
if text.startswith("software\\wow6432node\\"):
|
||||
text = text[len("software\\wow6432node\\"):]
|
||||
elif hive == "local_machine" and not view32 and text.startswith("software\\"):
|
||||
text = "native\\" + text
|
||||
elif text.startswith("software\\"):
|
||||
text = text[len("software\\"):]
|
||||
return "%s|%s|%s" % (hive, text, name.lower())
|
||||
|
||||
|
||||
def gog_registry_values(pfx):
|
||||
"""Values already in the prefix, so install defaults never overwrite a player's choice."""
|
||||
values = set()
|
||||
for file, root in (("system.reg", "hklm"), ("user.reg", "hkcu")):
|
||||
try:
|
||||
lines = (pfx / file).read_text(encoding="utf-8", errors="ignore").splitlines()
|
||||
except OSError:
|
||||
continue
|
||||
section = ""
|
||||
for line in lines:
|
||||
if line.startswith("["):
|
||||
end = line.find("]")
|
||||
section = line[1:end] if end > 0 else line[1:]
|
||||
continue
|
||||
match = re.match(r'^"([^"]+)"=', line)
|
||||
if match and section:
|
||||
values.add(gog_value_key(root, section, match.group(1), view32=False))
|
||||
return values
|
||||
|
||||
|
||||
def gog_scripted_products(folder):
|
||||
products = set()
|
||||
for script in sorted(Path(folder).glob(GOG_SCRIPTS)):
|
||||
try:
|
||||
actions = json.loads(script.read_text(encoding="utf-8-sig")).get("actions")
|
||||
except (OSError, ValueError, AttributeError):
|
||||
continue
|
||||
if isinstance(actions, list) and any(
|
||||
isinstance(action, dict) and isinstance(action.get("install"), dict)
|
||||
and action["install"].get("action") == "setRegistry" for action in actions):
|
||||
products.add(script.name[len("goggame-"):-len(".script")])
|
||||
return products
|
||||
|
||||
|
||||
def gog_expected_values(folder):
|
||||
"""The fallback values a launch must find, so the marker never hides one that was deleted."""
|
||||
scripted = gog_scripted_products(folder)
|
||||
return [gog_value_key(root, subkey, name) for product in gog_installed_products(folder)
|
||||
if product in GOG_INSTALL_REGISTRY and product not in scripted
|
||||
for root, subkey, name, _kind, _value in GOG_INSTALL_REGISTRY[product]]
|
||||
|
||||
|
||||
def gog_registry(folder, existing=()):
|
||||
entries, skipped, scripted = [], 0, set()
|
||||
for script in sorted(Path(folder).glob(GOG_SCRIPTS)):
|
||||
product = script.name[len("goggame-"):-len(".script")]
|
||||
try:
|
||||
@@ -434,11 +541,28 @@ def gog_registry(folder):
|
||||
skipped += 1
|
||||
else:
|
||||
entries.append(entry)
|
||||
scripted.add(product)
|
||||
for product, info in gog_installed_products(folder).items():
|
||||
if product in scripted or product not in GOG_INSTALL_REGISTRY:
|
||||
continue
|
||||
paths = dict(gog_paths(folder, product), language=str(gog_language_id(info)))
|
||||
for root, subkey, name, kind, value in GOG_INSTALL_REGISTRY[product]:
|
||||
if gog_value_key(root, subkey, name) in existing:
|
||||
continue
|
||||
entry = gog_entry({"root": root, "subkey": subkey, "valueName": name,
|
||||
"valueType": kind, "valueData": value}, paths)
|
||||
if entry is None:
|
||||
skipped += 1
|
||||
else:
|
||||
entries.append(entry)
|
||||
return entries, skipped
|
||||
|
||||
|
||||
def apply_gog_registry(folder, compat_data, proton, timeout=90, installation=None):
|
||||
entries, skipped = gog_registry(folder)
|
||||
pfx = Path(compat_data) / "pfx" if compat_data else None
|
||||
existing = gog_registry_values(pfx) if pfx else set()
|
||||
entries, skipped = gog_registry(folder, existing)
|
||||
expected = gog_expected_values(folder)
|
||||
if installation:
|
||||
product = str(installation["id"])
|
||||
if not product.isdigit():
|
||||
@@ -465,10 +589,10 @@ def apply_gog_registry(folder, compat_data, proton, timeout=90, installation=Non
|
||||
return "no-proton" + note
|
||||
text = "Windows Registry Editor Version 5.00\r\n\r\n" + "".join(entry + "\r\n\r\n" for entry in entries)
|
||||
stamp = hashlib.sha256(text.encode("utf-8")).hexdigest()
|
||||
pfx = Path(compat_data) / "pfx"
|
||||
marker = pfx / GOG_REGISTRY_MARK
|
||||
try:
|
||||
if marker.is_file() and marker.read_text() == stamp and (pfx / "system.reg").is_file():
|
||||
if (marker.is_file() and marker.read_text() == stamp and (pfx / "system.reg").is_file()
|
||||
and set(expected) <= existing):
|
||||
return "ready" + note
|
||||
Path(compat_data).mkdir(parents=True, exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(prefix="droiddeck-gog-") as tmp:
|
||||
|
||||
@@ -476,15 +476,30 @@ def save_state(compat, state):
|
||||
def pending_for(app_id, pending=PENDING):
|
||||
try:
|
||||
with open(pending, encoding="utf-8") as source:
|
||||
ids = json.load(source).get("games", {}).get(str(app_id), [])
|
||||
config = json.load(source)
|
||||
ids = config.get("games", {}).get(str(app_id), [])
|
||||
revisions = config.get("revisions", {})
|
||||
except (OSError, ValueError, AttributeError):
|
||||
return []
|
||||
return [i for i in ids if valid_id(i)] if isinstance(ids, list) else []
|
||||
return {}
|
||||
revisions = revisions if isinstance(revisions, dict) else {}
|
||||
return {i: max(0, revisions[i]) if type(revisions.get(i)) is int else 0
|
||||
for i in ids if valid_id(i)} if isinstance(ids, list) else {}
|
||||
|
||||
|
||||
def wait_for_pending(app_id, pending=PENDING, store=STORE, timeout=PENDING_WAIT, sleep=time.sleep, clock=time.monotonic):
|
||||
def missing():
|
||||
return [cid for cid in pending_for(app_id, pending) if component(store, cid) is None]
|
||||
left = []
|
||||
for cid, revision in pending_for(app_id, pending).items():
|
||||
try:
|
||||
with open(Path(store) / cid / "component.json", encoding="utf-8") as source:
|
||||
meta = json.load(source)
|
||||
installed = meta.get("revision", 0)
|
||||
ready = type(installed) is int and installed >= revision
|
||||
except (OSError, ValueError, AttributeError):
|
||||
ready = False
|
||||
if not ready:
|
||||
left.append(cid)
|
||||
return left
|
||||
left = missing()
|
||||
if not left:
|
||||
return None
|
||||
@@ -585,6 +600,8 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
|
||||
written, registry_notes = apply_registry(pfx, values, new_state, held)
|
||||
notes += registry_notes
|
||||
save_state(compat, new_state)
|
||||
overrides, fallback = reachable_overrides(pfx, overrides)
|
||||
notes += fallback
|
||||
if copied or removed or restored or written:
|
||||
note = "components %s: %d file(s) placed, %d removed" % (",".join(ids) or "none", copied, removed)
|
||||
note += ", %d put back as they were" % restored if restored else ""
|
||||
@@ -592,6 +609,26 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
|
||||
return overrides, notes
|
||||
|
||||
|
||||
def native_dll(pfx, name):
|
||||
for arch in ARCH_DIRS:
|
||||
path = existing(pfx / "drive_c/windows" / arch / (name + ".dll"))
|
||||
if path is None or builtin(path) or not os.access(path, os.R_OK):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def reachable_overrides(pfx, names):
|
||||
kept, notes = [], []
|
||||
for entry in names:
|
||||
name, sep, mode = entry.partition("=")
|
||||
name = name.strip().lower()
|
||||
if sep and mode.strip().lower() == "n" and not native_dll(pfx, name):
|
||||
entry = name + "=n,b"
|
||||
notes.append("%s=n has no native DLL in the prefix; using n,b" % name)
|
||||
kept.append(entry)
|
||||
return kept, notes
|
||||
|
||||
|
||||
def overrides_value(names):
|
||||
modes = {}
|
||||
for entry in names:
|
||||
|
||||
@@ -26,6 +26,9 @@ SNIPER_APPID = "1628350"
|
||||
SLR4_APPID = "4183110"
|
||||
FEX_DEPENDENCIES = (FEX_APPID, SNIPER_APPID, SLR4_APPID)
|
||||
REQUIRED_TOOLS = (PROTON_ARM64_APPID,) + FEX_DEPENDENCIES
|
||||
# Linux builds that bundle an arm64 binary their launcher starts; Steamworks offers no arm64
|
||||
# launch-option architecture, so appinfo cannot say so (#1774).
|
||||
FEX_DEFAULT_APPS = frozenset({"4385780"})
|
||||
FULLY_INSTALLED = 4
|
||||
UPDATE_REQUIRED = 2
|
||||
REQUEST_HANDOFF_SECONDS = 30
|
||||
@@ -173,6 +176,9 @@ bl_components() {
|
||||
local -A cm_sums=()
|
||||
while IFS=$'\\t' read -r scope t want comp rel sum src; do
|
||||
[ -n "$scope" ] || continue
|
||||
# The selected system PowerVR runtime supplies DXVK at launch. Keep saved selections
|
||||
# for a later manual-driver session without rewriting this Proton's bundled files now.
|
||||
[ "$comp" = dxvk ] && [ -n "${DROIDDECK_POWERVR_RUNTIME:-}" ] && continue
|
||||
cm_rows+=("$comp"$'\\t'"$rel"$'\\t'"$sum"$'\\t'"$src")
|
||||
[ "$src" != "-" ] && [ -f "$base/$rel" ] && cm_files+=("$base/$rel")
|
||||
done <<< "$cm_selected"
|
||||
@@ -779,20 +785,32 @@ def launch_options(config):
|
||||
return found
|
||||
|
||||
|
||||
def appinfo_entries(path):
|
||||
def appinfo_entries(path, wanted=None):
|
||||
"""Read metadata for all apps, or only the requested app-id strings."""
|
||||
import struct
|
||||
if wanted is not None:
|
||||
wanted = set(wanted)
|
||||
if not wanted:
|
||||
return {}
|
||||
try:
|
||||
stamp = os.stat(path).st_mtime_ns
|
||||
except OSError:
|
||||
return {}
|
||||
cached = APPINFO_CACHE.get(path)
|
||||
if cached and cached[0] == stamp:
|
||||
return cached[1]
|
||||
try:
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
except OSError:
|
||||
return {}
|
||||
covered = cached[2]
|
||||
if covered is None or (wanted is not None and wanted <= covered):
|
||||
return cached[1] if wanted is None else {app: cached[1][app] for app in wanted if app in cached[1]}
|
||||
data = cached[3]
|
||||
needed = None if wanted is None else wanted - covered
|
||||
else:
|
||||
cached = None
|
||||
needed = wanted
|
||||
try:
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
except OSError:
|
||||
return {}
|
||||
if len(data) < 8:
|
||||
return {}
|
||||
magic = struct.unpack_from("<I", data, 0)[0]
|
||||
@@ -854,6 +872,8 @@ def appinfo_entries(path):
|
||||
break
|
||||
start = offset + 8
|
||||
offset = start + size
|
||||
if needed is not None and str(app) not in needed:
|
||||
continue
|
||||
try:
|
||||
info = section(start + header)[0].get("appinfo", {})
|
||||
except (ValueError, IndexError, struct.error):
|
||||
@@ -878,8 +898,14 @@ def appinfo_entries(path):
|
||||
entry["app_mappings"] = {str(m.get("appid", key)): str(m.get("tool", "")) for key, m in mappings.items()
|
||||
if isinstance(m, dict)} if isinstance(mappings, dict) else {}
|
||||
found[str(app)] = entry
|
||||
APPINFO_CACHE[path] = (stamp, found)
|
||||
return found
|
||||
covered = wanted
|
||||
if cached is not None and wanted is not None:
|
||||
cached[1].update(found)
|
||||
found = cached[1]
|
||||
covered = cached[2] | wanted
|
||||
# None coverage is complete; partial entries keep one immutable file snapshot.
|
||||
APPINFO_CACHE[path] = (stamp, found, covered, data if covered is not None else None)
|
||||
return found if wanted is None else {app: found[app] for app in wanted if app in found}
|
||||
|
||||
|
||||
def appinfo_platforms(path, wanted):
|
||||
@@ -912,7 +938,7 @@ def native_targets(steam_root, apps):
|
||||
if "arm64" in osarch or "aarch64" in osarch:
|
||||
targets[app] = None
|
||||
continue
|
||||
if "windows" in oslist:
|
||||
if "windows" in oslist and app not in FEX_DEFAULT_APPS:
|
||||
targets[app] = NATIVE_CHOICE
|
||||
continue
|
||||
targets[app] = FEX_TOOL
|
||||
@@ -1063,7 +1089,7 @@ def plan_mapping(current, installed, runnable, default, auto, native=None, picks
|
||||
continue
|
||||
mine = auto.get(app)
|
||||
target = native.get(app, default)
|
||||
if not name and app in native_choices:
|
||||
if not name and (app in native_choices or (app in current and app in FEX_DEFAULT_APPS)):
|
||||
target = NATIVE_CHOICE
|
||||
stale = unrunnable(name, runnable)
|
||||
if name and not stale and (mine is None or name != mine):
|
||||
@@ -1360,6 +1386,20 @@ def read_config_mapping(config_path):
|
||||
return read_mapping(tokens, mapping + steam + 1) if mapping is not None else {}
|
||||
|
||||
|
||||
def mapping_entry(app, tool):
|
||||
return ['"%s"' % app, "{", '"name"', '"%s"' % tool, '"config"', '""',
|
||||
'"priority"', '"75"' if app == "0" else '"250"', "}"]
|
||||
|
||||
|
||||
def set_mapping_tool(tokens, block, tool):
|
||||
end = block_end(tokens, block)
|
||||
for i in range(block + 1, end):
|
||||
if tokens[i] == '"name"':
|
||||
tokens[i + 1] = '"%s"' % tool
|
||||
return
|
||||
tokens[block + 1:block + 1] = ['"name"', '"%s"' % tool]
|
||||
|
||||
|
||||
def set_mapping(tokens, mapping, app, tool):
|
||||
block = find_block(tokens[mapping + 1:], [app])
|
||||
if tool is None:
|
||||
@@ -1368,16 +1408,40 @@ def set_mapping(tokens, mapping, app, tool):
|
||||
del tokens[block - 1:block_end(tokens, block) + 1]
|
||||
return
|
||||
if block is None:
|
||||
tokens[mapping + 1:mapping + 1] = [
|
||||
'"%s"' % app, "{", '"name"', '"%s"' % tool, '"config"', '""', '"priority"', '"75"' if app == "0" else '"250"', "}"]
|
||||
tokens[mapping + 1:mapping + 1] = mapping_entry(app, tool)
|
||||
return
|
||||
block += mapping + 1
|
||||
end = block_end(tokens, block)
|
||||
for i in range(block + 1, end):
|
||||
if tokens[i] == '"name"':
|
||||
tokens[i + 1] = '"%s"' % tool
|
||||
return
|
||||
tokens[block + 1:block + 1] = ['"name"', '"%s"' % tool]
|
||||
set_mapping_tool(tokens, block + mapping + 1, tool)
|
||||
|
||||
|
||||
def set_mappings(tokens, mapping, changes):
|
||||
"""Apply a batch with one traversal of the affected mapping entries."""
|
||||
pending = {('"%s"' % app).lower(): (app, tool) for app, tool in changes.items()}
|
||||
# Non-string or aliased keys retain the single writer's sequential semantics.
|
||||
if len(changes) < 2 or len(pending) != len(changes) or any(not isinstance(app, str) for app in changes):
|
||||
for app, tool in changes.items():
|
||||
set_mapping(tokens, mapping, app, tool)
|
||||
return
|
||||
updated = []
|
||||
i = mapping + 1
|
||||
while pending and i < len(tokens) and tokens[i] != "}":
|
||||
if i + 1 < len(tokens) and tokens[i + 1] == "{":
|
||||
end = block_end(tokens, i + 1)
|
||||
change = pending.pop(tokens[i].lower(), None)
|
||||
if change is None:
|
||||
updated.extend(tokens[i:end + 1])
|
||||
elif change[1] is not None:
|
||||
entry = tokens[i:end + 1]
|
||||
set_mapping_tool(entry, 1, change[1])
|
||||
updated.extend(entry)
|
||||
i = end + 1
|
||||
else:
|
||||
updated.append(tokens[i])
|
||||
i += 1
|
||||
added = []
|
||||
for app, tool in reversed(list(pending.values())):
|
||||
if tool is not None:
|
||||
added.extend(mapping_entry(app, tool))
|
||||
tokens[mapping + 1:i] = added + updated
|
||||
|
||||
|
||||
def steam_running():
|
||||
@@ -1450,10 +1514,9 @@ def register_default(config_path, apps=(), protect=(), default=None, catalog=Non
|
||||
if settle and newest:
|
||||
state["own_proton"] = True
|
||||
if newest:
|
||||
for app, name in list(current.items()):
|
||||
if app != "0" and name in gone:
|
||||
set_mapping(tokens, mapping, app, newest)
|
||||
current[app] = newest
|
||||
replacements = {app: newest for app, name in current.items() if app != "0" and name in gone}
|
||||
set_mappings(tokens, mapping, replacements)
|
||||
current.update(replacements)
|
||||
if isinstance(state.get("auto"), dict):
|
||||
state["auto"] = {app: newest if name in gone else name for app, name in state["auto"].items()}
|
||||
steam_root = os.path.dirname(os.path.dirname(os.path.abspath(config_path)))
|
||||
@@ -1469,8 +1532,7 @@ def register_default(config_path, apps=(), protect=(), default=None, catalog=Non
|
||||
changes, auto = plan_mapping(
|
||||
current, apps, names, default, followers(state, current), native, picks,
|
||||
overrides, managed, native_choices)
|
||||
for app, tool in changes.items():
|
||||
set_mapping(tokens, mapping, app, tool)
|
||||
set_mappings(tokens, mapping, changes)
|
||||
text = serialize(tokens)
|
||||
if text != serialize(tokenize(original)):
|
||||
write_changed(config_path, text)
|
||||
@@ -1562,16 +1624,16 @@ def x64_repoint(steam_root, tool, live=False):
|
||||
keep = local_tools(steam_root)
|
||||
moved = []
|
||||
current = read_mapping(tokens, mapping)
|
||||
if "0" not in current:
|
||||
set_mapping(tokens, mapping, "0", tool)
|
||||
changes = {} if "0" in current else {"0": tool}
|
||||
for app, name in current.items():
|
||||
named = name.lower()
|
||||
legacy = named == "droiddeck-proton-arm64"
|
||||
if (named.startswith("proton") or legacy) and named != tool.lower() \
|
||||
and (legacy or named not in keep):
|
||||
set_mapping(tokens, mapping, app, tool)
|
||||
changes[app] = tool
|
||||
if app != "0":
|
||||
moved.append(app)
|
||||
set_mappings(tokens, mapping, changes)
|
||||
text = serialize(tokens)
|
||||
if text != serialize(tokenize(original)):
|
||||
write_changed(config, text)
|
||||
|
||||
+192
-31
@@ -4,13 +4,19 @@
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MAX_HANDLES 4096
|
||||
#ifndef F_DUPFD_QUERY
|
||||
#define F_DUPFD_QUERY 1027
|
||||
#endif
|
||||
#define PVR_HANDLE_BIT UINT32_C(0x80000000)
|
||||
|
||||
struct gem_close {
|
||||
uint32_t handle;
|
||||
@@ -22,11 +28,14 @@ struct handle_entry {
|
||||
uint32_t handle;
|
||||
int dma_fd;
|
||||
int drm_fd;
|
||||
int owned_drm_fd; /* PowerVR: pin the open file description, not its reusable fd number. */
|
||||
int powervr;
|
||||
};
|
||||
|
||||
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static struct handle_entry handle_entries[MAX_HANDLES];
|
||||
static uint32_t next_handle = 1;
|
||||
static uint32_t next_pvr_handle = PVR_HANDLE_BIT;
|
||||
static dev_t kgsl_dev;
|
||||
static int kgsl_state;
|
||||
|
||||
@@ -34,13 +43,42 @@ static int is_kgsl(int fd) {
|
||||
struct stat st;
|
||||
pthread_mutex_lock(&lock);
|
||||
if (kgsl_state == 0) {
|
||||
kgsl_state = stat("/dev/kgsl-3d0", &st) == 0 ? 1 : -1;
|
||||
kgsl_dev = st.st_rdev;
|
||||
const char *standin = getenv("BL_DRM_STANDIN");
|
||||
kgsl_state = stat("/dev/kgsl-3d0", &st) == 0 || (standin && *standin && stat(standin, &st) == 0) ? 1 : -1;
|
||||
if (kgsl_state > 0) kgsl_dev = st.st_rdev;
|
||||
}
|
||||
pthread_mutex_unlock(&lock);
|
||||
return kgsl_state > 0 && fstat(fd, &st) == 0 && S_ISCHR(st.st_mode) && st.st_rdev == kgsl_dev;
|
||||
}
|
||||
|
||||
/* Keep the opt-in separate from GPU detection: manual ICDs must retain native DRM behavior. */
|
||||
struct bl_drm_version {
|
||||
int major, minor, patch;
|
||||
size_t name_len;
|
||||
char *name;
|
||||
size_t date_len;
|
||||
char *date;
|
||||
size_t desc_len;
|
||||
char *desc;
|
||||
};
|
||||
#define BL_DRM_VERSION _IOWR('d', 0x00, struct bl_drm_version)
|
||||
|
||||
static int is_powervr(int fd) {
|
||||
const char *enabled = getenv("BL_POWERVR_DRM_HANDLES");
|
||||
if (!enabled || strcmp(enabled, "1")) return 0;
|
||||
const char *path = getenv("BL_POWERVR_RENDER_NODE");
|
||||
if (!path || !*path) return 0;
|
||||
struct stat node, candidate;
|
||||
if (stat(path, &node) || fstat(fd, &candidate) ||
|
||||
!S_ISCHR(candidate.st_mode) || !S_ISCHR(node.st_mode) ||
|
||||
candidate.st_rdev != node.st_rdev) return 0;
|
||||
char name[16] = {0};
|
||||
struct bl_drm_version version = {.name_len = sizeof(name) - 1, .name = name};
|
||||
/* Bypass the preload's ioctl dispatcher to avoid recursively entering this hook. */
|
||||
return syscall(SYS_ioctl, fd, BL_DRM_VERSION, &version) == 0 &&
|
||||
version.name_len == 3 && !memcmp(name, "pvr", 3);
|
||||
}
|
||||
|
||||
static void *real(const char *name) {
|
||||
void *fn = dlsym(RTLD_NEXT, name);
|
||||
if (!fn) {
|
||||
@@ -49,35 +87,124 @@ static void *real(const char *name) {
|
||||
return fn;
|
||||
}
|
||||
|
||||
static int same_by_flock(int a, int b) {
|
||||
struct stat sa, sb;
|
||||
if (fstat(a, &sa) || fstat(b, &sb) || sa.st_dev != sb.st_dev || sa.st_ino != sb.st_ino ||
|
||||
flock(a, LOCK_EX | LOCK_NB)) {
|
||||
return 0;
|
||||
}
|
||||
int same = flock(b, LOCK_EX | LOCK_NB) == 0;
|
||||
flock(a, LOCK_UN);
|
||||
return same;
|
||||
}
|
||||
|
||||
static int same_file_description(int a, int b) {
|
||||
if (a == b) {
|
||||
return 1;
|
||||
}
|
||||
#ifdef SYS_kcmp
|
||||
int saved_errno = errno;
|
||||
long ret = syscall(SYS_kcmp, getpid(), getpid(), 0 , a, b);
|
||||
errno = saved_errno;
|
||||
return ret == 0;
|
||||
#else
|
||||
return 0;
|
||||
int ret = -1;
|
||||
#ifdef SYS_kcmp
|
||||
static int kcmp_missing;
|
||||
if (!kcmp_missing) {
|
||||
long k = syscall(SYS_kcmp, getpid(), getpid(), 0, a, b);
|
||||
if (k >= 0) {
|
||||
ret = k == 0;
|
||||
} else if (errno == ENOSYS || errno == EPERM) {
|
||||
kcmp_missing = 1;
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
const char *standin = getenv("BL_DRM_STANDIN");
|
||||
ret = standin && *standin ? same_by_flock(a, b) : 0;
|
||||
}
|
||||
errno = saved_errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Android kernels before 6.10 have no F_DUPFD_QUERY, while the app seccomp policy blocks kcmp.
|
||||
* F_SETOWN_EX updates the open file description, so a duplicate observes a temporary owner marker
|
||||
* and an independent open of the same render node does not. Restore the original owner before
|
||||
* returning; no signal is armed because these DRM descriptors do not have O_ASYNC set.
|
||||
*/
|
||||
static int same_owner_description(int owned, int fd) {
|
||||
struct f_owner_ex original_owned, original_fd, observed;
|
||||
if (fcntl(owned, F_GETOWN_EX, &original_owned) < 0 ||
|
||||
fcntl(fd, F_GETOWN_EX, &original_fd) < 0) {
|
||||
return -1;
|
||||
}
|
||||
const struct f_owner_ex candidates[] = {
|
||||
{.type = F_OWNER_TID, .pid = getpid()},
|
||||
{.type = F_OWNER_PID, .pid = getpid()},
|
||||
{.type = F_OWNER_PGRP, .pid = getpgrp()},
|
||||
};
|
||||
const struct f_owner_ex *marker = NULL;
|
||||
for (size_t i = 0; i < sizeof(candidates) / sizeof(candidates[0]); i++) {
|
||||
if (candidates[i].type != original_fd.type || candidates[i].pid != original_fd.pid) {
|
||||
marker = &candidates[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!marker || fcntl(owned, F_SETOWN_EX, marker) < 0) return -1;
|
||||
int observed_result = fcntl(fd, F_GETOWN_EX, &observed);
|
||||
int observed_errno = errno;
|
||||
int restore_result = fcntl(owned, F_SETOWN_EX, &original_owned);
|
||||
int restore_errno = errno;
|
||||
if (restore_result < 0) {
|
||||
errno = restore_errno;
|
||||
return -1;
|
||||
}
|
||||
if (observed_result < 0) {
|
||||
errno = observed_errno;
|
||||
return -1;
|
||||
}
|
||||
return observed.type == marker->type && observed.pid == marker->pid;
|
||||
}
|
||||
|
||||
static int same_owned_description(int owned, int fd) {
|
||||
int saved_errno = errno;
|
||||
int result = fcntl(owned, F_DUPFD_QUERY, fd);
|
||||
if (result >= 0) {
|
||||
errno = saved_errno;
|
||||
return result == 1;
|
||||
}
|
||||
#ifdef SYS_kcmp
|
||||
long compared = syscall(SYS_kcmp, getpid(), getpid(), 0 /* KCMP_FILE */, owned, fd);
|
||||
if (compared >= 0) {
|
||||
errno = saved_errno;
|
||||
return compared == 0;
|
||||
}
|
||||
#endif
|
||||
int owner_match = same_owner_description(owned, fd);
|
||||
errno = saved_errno;
|
||||
return owner_match == 1;
|
||||
}
|
||||
|
||||
static int find_handle_locked(int fd, uint32_t handle) {
|
||||
for (int i = 0; i < MAX_HANDLES; i++) {
|
||||
if (handle_entries[i].handle == handle &&
|
||||
same_file_description(handle_entries[i].drm_fd, fd)) {
|
||||
(handle_entries[i].powervr
|
||||
? same_owned_description(handle_entries[i].owned_drm_fd, fd)
|
||||
: same_file_description(handle_entries[i].drm_fd, fd))) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static uint32_t alloc_handle_locked(void) {
|
||||
static uint32_t alloc_handle_locked(int powervr) {
|
||||
for (int tries = 0; tries <= MAX_HANDLES; tries++) {
|
||||
uint32_t candidate = next_handle++;
|
||||
if (next_handle == 0) {
|
||||
next_handle = 1;
|
||||
uint32_t candidate;
|
||||
if (powervr) {
|
||||
candidate = next_pvr_handle++;
|
||||
if (!(next_pvr_handle & PVR_HANDLE_BIT)) next_pvr_handle = PVR_HANDLE_BIT;
|
||||
} else {
|
||||
candidate = next_handle++;
|
||||
if (next_handle == PVR_HANDLE_BIT) next_handle = 1;
|
||||
}
|
||||
if (candidate == 0) {
|
||||
continue;
|
||||
@@ -97,25 +224,49 @@ static uint32_t alloc_handle_locked(void) {
|
||||
}
|
||||
|
||||
int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle) {
|
||||
if (!is_kgsl(fd)) {
|
||||
int kgsl = is_kgsl(fd);
|
||||
int powervr = !kgsl && is_powervr(fd);
|
||||
if (!kgsl) {
|
||||
int (*fn)(int, int, uint32_t *) = (int (*)(int, int, uint32_t *)) real("drmPrimeFDToHandle");
|
||||
return fn ? fn(fd, prime_fd, handle) : -ENOSYS;
|
||||
if (!fn) return -ENOSYS;
|
||||
int result = fn(fd, prime_fd, handle);
|
||||
if (!result || !powervr || errno != EINVAL) return result;
|
||||
}
|
||||
if (!handle) { errno = EINVAL; return -EINVAL; }
|
||||
int owner = -1;
|
||||
if (powervr) {
|
||||
owner = fcntl(fd, F_DUPFD_CLOEXEC, 0);
|
||||
if (owner < 0) return -errno;
|
||||
/* The old-kernel owner probe mutates shared OFD state briefly; serialize it with lookups. */
|
||||
pthread_mutex_lock(&lock);
|
||||
int owner_matches = same_owned_description(owner, fd);
|
||||
pthread_mutex_unlock(&lock);
|
||||
if (!owner_matches) {
|
||||
close(owner);
|
||||
errno = EOPNOTSUPP;
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
}
|
||||
int dup_fd = fcntl(prime_fd, F_DUPFD_CLOEXEC, 0);
|
||||
if (dup_fd < 0) {
|
||||
return -errno;
|
||||
int error = errno;
|
||||
if (owner >= 0) close(owner);
|
||||
errno = error;
|
||||
return -error;
|
||||
}
|
||||
int ret = -ENOMEM;
|
||||
pthread_mutex_lock(&lock);
|
||||
for (int i = 0; i < MAX_HANDLES; i++) {
|
||||
if (handle_entries[i].handle == 0) {
|
||||
uint32_t token = alloc_handle_locked();
|
||||
uint32_t token = alloc_handle_locked(powervr);
|
||||
if (!token) {
|
||||
break;
|
||||
}
|
||||
handle_entries[i].handle = token;
|
||||
handle_entries[i].dma_fd = dup_fd;
|
||||
handle_entries[i].drm_fd = fd;
|
||||
handle_entries[i].owned_drm_fd = owner;
|
||||
handle_entries[i].powervr = powervr;
|
||||
*handle = token;
|
||||
ret = 0;
|
||||
break;
|
||||
@@ -124,24 +275,32 @@ int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle) {
|
||||
pthread_mutex_unlock(&lock);
|
||||
if (ret) {
|
||||
close(dup_fd);
|
||||
if (owner >= 0) close(owner);
|
||||
errno = -ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd) {
|
||||
if (!is_kgsl(fd)) {
|
||||
int (*fn)(int, uint32_t, uint32_t, int *) = (int (*)(int, uint32_t, uint32_t, int *)) real("drmPrimeHandleToFD");
|
||||
return fn ? fn(fd, handle, flags, prime_fd) : -ENOSYS;
|
||||
}
|
||||
int kgsl = is_kgsl(fd);
|
||||
int ret = -EINVAL;
|
||||
pthread_mutex_lock(&lock);
|
||||
int index = find_handle_locked(fd, handle);
|
||||
if (index >= 0) {
|
||||
*prime_fd = fcntl(handle_entries[index].dma_fd, F_DUPFD_CLOEXEC, 0);
|
||||
ret = *prime_fd < 0 ? -errno : 0;
|
||||
if (!prime_fd || (handle_entries[index].powervr && (flags & ~(O_CLOEXEC | O_RDWR)))) {
|
||||
errno = EINVAL;
|
||||
} else {
|
||||
int command = handle_entries[index].powervr && !(flags & O_CLOEXEC) ? F_DUPFD : F_DUPFD_CLOEXEC;
|
||||
*prime_fd = fcntl(handle_entries[index].dma_fd, command, 0);
|
||||
ret = *prime_fd < 0 ? -errno : 0;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&lock);
|
||||
return ret;
|
||||
if (index >= 0 || kgsl) return ret;
|
||||
/* Unknown handles (including real PowerVR GEM handles) retain kernel semantics. */
|
||||
int (*fn)(int, uint32_t, uint32_t, int *) =
|
||||
(int (*)(int, uint32_t, uint32_t, int *)) real("drmPrimeHandleToFD");
|
||||
return fn ? fn(fd, handle, flags, prime_fd) : -ENOSYS;
|
||||
}
|
||||
|
||||
static int release_handle(int fd, uint32_t handle) {
|
||||
@@ -150,6 +309,7 @@ static int release_handle(int fd, uint32_t handle) {
|
||||
int index = find_handle_locked(fd, handle);
|
||||
if (index >= 0) {
|
||||
close(handle_entries[index].dma_fd);
|
||||
if (handle_entries[index].powervr) close(handle_entries[index].owned_drm_fd);
|
||||
handle_entries[index] = (struct handle_entry){0};
|
||||
found = 1;
|
||||
}
|
||||
@@ -158,22 +318,23 @@ static int release_handle(int fd, uint32_t handle) {
|
||||
}
|
||||
|
||||
int drmCloseBufferHandle(int fd, uint32_t handle) {
|
||||
if (!is_kgsl(fd)) {
|
||||
int (*fn)(int, uint32_t) = (int (*)(int, uint32_t)) real("drmCloseBufferHandle");
|
||||
return fn ? fn(fd, handle) : -ENOSYS;
|
||||
}
|
||||
return release_handle(fd, handle) ? 0 : -EINVAL;
|
||||
if (release_handle(fd, handle)) return 0;
|
||||
if (is_kgsl(fd)) { errno = EINVAL; return -EINVAL; }
|
||||
int (*fn)(int, uint32_t) = (int (*)(int, uint32_t)) real("drmCloseBufferHandle");
|
||||
return fn ? fn(fd, handle) : -ENOSYS;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_drm_gem_close(int fd, unsigned long request, void *arg, int *rc) {
|
||||
if (request != GEM_CLOSE || !arg || !is_kgsl(fd)) {
|
||||
if (request != GEM_CLOSE || !arg) {
|
||||
return 0;
|
||||
}
|
||||
if (release_handle(fd, ((struct gem_close *) arg)->handle)) {
|
||||
*rc = 0;
|
||||
} else {
|
||||
} else if (is_kgsl(fd)) {
|
||||
errno = EINVAL;
|
||||
*rc = -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,112 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#define KGSL_IOC_TYPE 0x09
|
||||
#define KGSL_TIMESTAMP_RETIRED 0x00000002
|
||||
#include "../../quest/kgsl_compat.h"
|
||||
|
||||
struct kgsl_device_waittimestamp_ctxtid {
|
||||
unsigned int context_id;
|
||||
unsigned int timestamp;
|
||||
unsigned int timeout;
|
||||
};
|
||||
#define KGSL_CONTEXTS 1024
|
||||
|
||||
struct kgsl_cmdstream_readtimestamp_ctxtid {
|
||||
unsigned int context_id;
|
||||
unsigned int type;
|
||||
unsigned int timestamp;
|
||||
};
|
||||
static struct {
|
||||
uint32_t submitted;
|
||||
uint32_t retired;
|
||||
int owner;
|
||||
} contexts[KGSL_CONTEXTS];
|
||||
|
||||
#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID \
|
||||
_IOW(KGSL_IOC_TYPE, 0x7, struct kgsl_device_waittimestamp_ctxtid)
|
||||
#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_CTXTID \
|
||||
_IOWR(KGSL_IOC_TYPE, 0x16, struct kgsl_cmdstream_readtimestamp_ctxtid)
|
||||
static void report_denied(unsigned long request, int error) {
|
||||
static unsigned reports;
|
||||
int saved = errno;
|
||||
|
||||
if (__atomic_fetch_add(&reports, 1, __ATOMIC_RELAXED) < 8)
|
||||
fprintf(stderr, "[QuestKGSL] ioctl 0x%lx refused, errno=%d\n", request & 0xff, error);
|
||||
errno = saved;
|
||||
}
|
||||
|
||||
static void note_submit(unsigned int context_id, unsigned int timestamp) {
|
||||
uint32_t known;
|
||||
|
||||
if (context_id >= KGSL_CONTEXTS) return;
|
||||
known = __atomic_load_n(&contexts[context_id].submitted, __ATOMIC_RELAXED);
|
||||
while ((int32_t)(timestamp - known) > 0 &&
|
||||
!__atomic_compare_exchange_n(&contexts[context_id].submitted, &known, timestamp, 1,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED)) {
|
||||
}
|
||||
}
|
||||
|
||||
static int wait_retired(int (*real)(int, unsigned long, void *), int fd, uint32_t id, uint32_t timestamp) {
|
||||
/* KGSL reads a timeout of 0 as wait forever. */
|
||||
struct kgsl_device_waittimestamp_ctxtid wait = {.context_id = id, .timestamp = timestamp, .timeout = 1};
|
||||
|
||||
if (real(fd, IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID, &wait) == 0) return 0;
|
||||
return errno == ETIMEDOUT || errno == ETIME || errno == EINTR || errno == EAGAIN ? 1 : -1;
|
||||
}
|
||||
|
||||
/* shortcut: an unfinished timestamp sleeps a jiffy per poll, read the memstore instead if Quest's mmap of it is proven */
|
||||
static int read_retired(int (*real)(int, unsigned long, void *), int fd,
|
||||
struct kgsl_cmdstream_readtimestamp_ctxtid *read) {
|
||||
uint32_t id = read->context_id;
|
||||
uint32_t timestamp, submitted;
|
||||
int result;
|
||||
|
||||
if (read->type != KGSL_TIMESTAMP_RETIRED || id >= KGSL_CONTEXTS ||
|
||||
__atomic_load_n(&contexts[id].owner, __ATOMIC_RELAXED) != fd + 1)
|
||||
return -1;
|
||||
timestamp = __atomic_load_n(&contexts[id].retired, __ATOMIC_RELAXED);
|
||||
submitted = __atomic_load_n(&contexts[id].submitted, __ATOMIC_RELAXED);
|
||||
/* KGSL checks a context's owner on every wait, which catches one that died with a reused descriptor. */
|
||||
if (timestamp == submitted && wait_retired(real, fd, id, timestamp) < 0) return -1;
|
||||
while (timestamp != submitted) {
|
||||
result = wait_retired(real, fd, id, timestamp + 1);
|
||||
if (result < 0) return -1;
|
||||
if (result > 0) break;
|
||||
timestamp++;
|
||||
__atomic_store_n(&contexts[id].retired, timestamp, __ATOMIC_RELAXED);
|
||||
}
|
||||
read->timestamp = timestamp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Quest refuses some KGSL ioctls, and Mesa 27 turns a failed timestamp read into VK_ERROR_UNKNOWN. */
|
||||
__attribute__((visibility("hidden"))) void bl_kgsl_track(int (*real)(int, unsigned long, void *),
|
||||
int fd, unsigned long request, void *arg,
|
||||
int *rc) {
|
||||
int saved = errno;
|
||||
|
||||
if (arg == NULL) return;
|
||||
if (*rc == 0) {
|
||||
if (request == IOCTL_KGSL_GPU_COMMAND) {
|
||||
const struct kgsl_gpu_command *submit = arg;
|
||||
note_submit(submit->context_id, submit->timestamp);
|
||||
} else if (request == IOCTL_KGSL_GPU_AUX_COMMAND) {
|
||||
const struct kgsl_gpu_aux_command *submit = arg;
|
||||
note_submit(submit->context_id, submit->timestamp);
|
||||
} else if (request == IOCTL_KGSL_DRAWCTXT_CREATE) {
|
||||
const struct kgsl_drawctxt_create *create = arg;
|
||||
if (create->drawctxt_id < KGSL_CONTEXTS) {
|
||||
__atomic_store_n(&contexts[create->drawctxt_id].submitted, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&contexts[create->drawctxt_id].retired, 0, __ATOMIC_RELAXED);
|
||||
/* User timestamps can leave gaps that would take one wait per integer, so their reads stay failed. */
|
||||
__atomic_store_n(&contexts[create->drawctxt_id].owner,
|
||||
create->flags & KGSL_CONTEXT_USER_GENERATED_TS ? 0 : fd + 1, __ATOMIC_RELAXED);
|
||||
}
|
||||
} else if (request == IOCTL_KGSL_DRAWCTXT_DESTROY) {
|
||||
const struct kgsl_drawctxt_destroy *destroy = arg;
|
||||
if (destroy->drawctxt_id < KGSL_CONTEXTS)
|
||||
__atomic_store_n(&contexts[destroy->drawctxt_id].owner, 0, __ATOMIC_RELAXED);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (_IOC_TYPE(request) == KGSL_IOC_TYPE && (saved == EACCES || saved == EPERM ||
|
||||
request == IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_CTXTID))
|
||||
report_denied(request, saved);
|
||||
if (request != IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_CTXTID || saved == EBADF) return;
|
||||
if (read_retired(real, fd, arg) == 0)
|
||||
*rc = 0;
|
||||
else if (errno != saved)
|
||||
report_denied(IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID, errno);
|
||||
}
|
||||
|
||||
static int enabled(void) {
|
||||
static int cached = -1;
|
||||
|
||||
@@ -54,6 +54,9 @@ static int is_lock_query(int cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
int bl_nl_before_dup(int fd, void **state) __attribute__((visibility("hidden")));
|
||||
void bl_nl_after_dup(void *state, int fd) __attribute__((visibility("hidden")));
|
||||
|
||||
int fcntl(int fd, int cmd, ...) {
|
||||
static int (*real_fcntl)(int, int, ...);
|
||||
va_list ap;
|
||||
@@ -69,7 +72,11 @@ int fcntl(int fd, int cmd, ...) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
void *nl_state = NULL;
|
||||
int duplicate = cmd == F_DUPFD || cmd == F_DUPFD_CLOEXEC;
|
||||
if (duplicate && bl_nl_before_dup(fd, &nl_state) != 0) return -1;
|
||||
result = real_fcntl(fd, cmd, arg);
|
||||
if (duplicate) bl_nl_after_dup(nl_state, result);
|
||||
if (result >= 0 || !unsupported(errno)) return result;
|
||||
if (is_lock_command(cmd)) return 0;
|
||||
if (is_lock_query(cmd) && arg != NULL) {
|
||||
|
||||
@@ -111,10 +111,16 @@ typedef int (*accept4_fn)(int, struct sockaddr *, socklen_t *, int);
|
||||
static unsigned guarded_port(void);
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_udevmon_stand_in(int fd);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_bind(int fd, const struct sockaddr *addr,
|
||||
socklen_t len, int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_connect(int fd, const struct sockaddr *addr,
|
||||
socklen_t len, int *rc);
|
||||
|
||||
int bind(int fd, const struct sockaddr *addr, socklen_t len) {
|
||||
static bind_fn real;
|
||||
int nl_rc;
|
||||
if (!real) real = (bind_fn)dlsym(RTLD_NEXT, "bind");
|
||||
if (bl_nl_bind(fd, addr, len, &nl_rc)) return nl_rc;
|
||||
if (bl_udevmon_stand_in(fd)) {
|
||||
if (addr == NULL || len < sizeof(struct sockaddr_nl) || addr->sa_family != AF_NETLINK) {
|
||||
errno = EINVAL;
|
||||
@@ -223,6 +229,8 @@ static int guest_peer(int fd) {
|
||||
|
||||
int connect(int fd, const struct sockaddr *addr, socklen_t len) {
|
||||
static connect_fn real;
|
||||
int nl_rc;
|
||||
if (bl_nl_connect(fd, addr, len, &nl_rc)) return nl_rc;
|
||||
if (!real) real = (connect_fn)dlsym(RTLD_NEXT, "connect");
|
||||
bind_before_loopback_connect(fd, addr, len);
|
||||
unsigned peer = loopback_family(addr, len) ? addr_port(addr, len) : 0;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1442,16 +1442,25 @@ static void ns_received(struct msghdr *msg) {
|
||||
|
||||
int bl_udevmon_recvmsg(int fd, struct msghdr *msg, int flags, ssize_t (*real_recvmsg)(int, struct msghdr *, int),
|
||||
ssize_t *result) __attribute__((visibility("hidden")));
|
||||
int bl_nl_recvmsg(int fd, struct msghdr *msg, int flags, ssize_t (*real_recvmsg)(int, struct msghdr *, int),
|
||||
ssize_t *result) __attribute__((visibility("hidden")));
|
||||
void bl_nl_received(struct msghdr *msg) __attribute__((visibility("hidden")));
|
||||
void bl_nl_closed(int fd) __attribute__((visibility("hidden")));
|
||||
void bl_nl_range_closed(unsigned int first, unsigned int last) __attribute__((visibility("hidden")));
|
||||
int bl_nl_before_dup(int fd, void **state) __attribute__((visibility("hidden")));
|
||||
void bl_nl_after_dup(void *state, int fd) __attribute__((visibility("hidden")));
|
||||
|
||||
ssize_t recvmsg(int fd, struct msghdr *msg, int flags) {
|
||||
static ssize_t (*real)(int, struct msghdr *, int);
|
||||
if (!real) real = (ssize_t (*)(int, struct msghdr *, int))dlsym(RTLD_NEXT, "recvmsg");
|
||||
ssize_t answered;
|
||||
if (msg && bl_nl_recvmsg(fd, msg, flags, real, &answered)) return answered;
|
||||
if (msg && bl_udevmon_recvmsg(fd, msg, flags, real, &answered)) return answered;
|
||||
ssize_t r = real(fd, msg, flags);
|
||||
if (r >= 0 && msg && msg->msg_control && msg->msg_controllen && ns_on()) {
|
||||
if (r >= 0 && msg && msg->msg_control && msg->msg_controllen) {
|
||||
int saved = errno;
|
||||
ns_received(msg);
|
||||
bl_nl_received(msg);
|
||||
if (ns_on()) ns_received(msg);
|
||||
errno = saved;
|
||||
}
|
||||
return r;
|
||||
@@ -1465,6 +1474,7 @@ int close(int fd) {
|
||||
if (fd >= 0) bl_fsync_fds_closed((unsigned int)fd, (unsigned int)fd);
|
||||
bl_venc_closed(fd);
|
||||
bl_vdec_closed(fd);
|
||||
bl_nl_closed(fd);
|
||||
uint64_t *t = __atomic_load_n(&ns_fdt, __ATOMIC_ACQUIRE);
|
||||
if (t && fd >= 0 && fd < NS_FDS && __atomic_load_n(&t[fd], __ATOMIC_ACQUIRE)) ns_forget(fd);
|
||||
int saved = errno;
|
||||
@@ -1480,19 +1490,29 @@ int close(int fd) {
|
||||
int dup2(int oldfd, int newfd) {
|
||||
static int (*real)(int, int);
|
||||
if (!real) real = (int (*)(int, int))dlsym(RTLD_NEXT, "dup2");
|
||||
if (oldfd == newfd) return real(oldfd, newfd);
|
||||
void *nl_state;
|
||||
if (bl_nl_before_dup(oldfd, &nl_state) != 0) return -1;
|
||||
if (oldfd != newfd && newfd >= 0) bl_fsync_fds_closed((unsigned int)newfd, (unsigned int)newfd);
|
||||
uint64_t *t = __atomic_load_n(&ns_fdt, __ATOMIC_ACQUIRE);
|
||||
if (t && oldfd != newfd && newfd >= 0 && newfd < NS_FDS && __atomic_load_n(&t[newfd], __ATOMIC_ACQUIRE)) ns_forget(newfd);
|
||||
return real(oldfd, newfd);
|
||||
int result = real(oldfd, newfd);
|
||||
bl_nl_after_dup(nl_state, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int dup3(int oldfd, int newfd, int flags) {
|
||||
static int (*real)(int, int, int);
|
||||
if (!real) real = (int (*)(int, int, int))dlsym(RTLD_NEXT, "dup3");
|
||||
if (oldfd == newfd) return real(oldfd, newfd, flags);
|
||||
void *nl_state;
|
||||
if (bl_nl_before_dup(oldfd, &nl_state) != 0) return -1;
|
||||
if (oldfd != newfd && newfd >= 0) bl_fsync_fds_closed((unsigned int)newfd, (unsigned int)newfd);
|
||||
uint64_t *t = __atomic_load_n(&ns_fdt, __ATOMIC_ACQUIRE);
|
||||
if (t && oldfd != newfd && newfd >= 0 && newfd < NS_FDS && __atomic_load_n(&t[newfd], __ATOMIC_ACQUIRE)) ns_forget(newfd);
|
||||
return real(oldfd, newfd, flags);
|
||||
int result = real(oldfd, newfd, flags);
|
||||
bl_nl_after_dup(nl_state, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void ns_forget_range(unsigned int first, unsigned int last) {
|
||||
@@ -1513,7 +1533,9 @@ int close_range(unsigned int first, unsigned int last, int flags) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
return real(first, last, flags);
|
||||
int result = real(first, last, flags);
|
||||
if (result == 0 && !(flags & CLOSE_RANGE_CLOEXEC)) bl_nl_range_closed(first, last);
|
||||
return result;
|
||||
}
|
||||
|
||||
void closefrom(int lowfd) {
|
||||
@@ -1523,7 +1545,10 @@ void closefrom(int lowfd) {
|
||||
bl_fsync_fds_closed((unsigned int)lowfd, ~0u);
|
||||
ns_forget_range((unsigned int)lowfd, ~0u);
|
||||
}
|
||||
if (real) real(lowfd);
|
||||
if (real) {
|
||||
real(lowfd);
|
||||
if (lowfd >= 0) bl_nl_range_closed((unsigned int)lowfd, ~0u);
|
||||
}
|
||||
}
|
||||
|
||||
static void ns_fork_prepare(void) {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Based on jdmg28's DroidDeck-Mali fork (commit 6be00e00, GPL-3.0): steam-launch-wrapper runs every
|
||||
* game with --oom-score-adjust 900. Android's lmkd reads 900 as CACHED_APP_MIN_ADJ and kills the
|
||||
* foreground game first when memory runs short; on Linux 6.1 the raise also becomes the process's
|
||||
* permanent minimum. An app's processes cannot go below the score they inherit, so the only writes
|
||||
* that succeed from in here are raises: every write-open of an oom_score_adj file goes to /dev/null.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int is_oom_score_adj(const char *path) {
|
||||
if (path == NULL || strncmp(path, "/proc/", 6) != 0) return 0;
|
||||
const char *p = path + 6;
|
||||
if (strncmp(p, "self/", 5) == 0) {
|
||||
p += 5;
|
||||
} else if (strncmp(p, "thread-self/", 12) == 0) {
|
||||
p += 12;
|
||||
} else {
|
||||
const char *digits = p;
|
||||
while (*p >= '0' && *p <= '9') p++;
|
||||
if (p == digits || *p != '/') return 0;
|
||||
p++;
|
||||
if (strncmp(p, "task/", 5) == 0) {
|
||||
p += 5;
|
||||
digits = p;
|
||||
while (*p >= '0' && *p <= '9') p++;
|
||||
if (p == digits || *p != '/') return 0;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
return strcmp(p, "oom_score_adj") == 0 || strcmp(p, "oom_adj") == 0;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) const char *bl_oom_adj_redirect(const char *path, int writing) {
|
||||
static int logged;
|
||||
if (!writing || !is_oom_score_adj(path)) return path;
|
||||
if (!__atomic_exchange_n(&logged, 1, __ATOMIC_RELAXED)) {
|
||||
static const char msg[] = "droiddeck: an oom_score_adj raise was dropped (Android would treat this program as a cached app)\n";
|
||||
int saved = errno;
|
||||
ssize_t ignored = write(STDERR_FILENO, msg, sizeof(msg) - 1);
|
||||
(void)ignored;
|
||||
errno = saved;
|
||||
}
|
||||
return "/dev/null";
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
int bl_status_without_tracer(const char *path, int flags, const void *caller) __attribute__((visibility("hidden")));
|
||||
int bl_writable_retry(int dirfd, const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int bl_ntsync_open(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
const char *bl_oom_adj_redirect(const char *path, int writing) __attribute__((visibility("hidden")));
|
||||
int bl_venc_open(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int bl_vdec_open(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int bl_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
@@ -53,6 +54,7 @@ int open(const char *path, int flags, ...) {
|
||||
errno = EACCES;
|
||||
return -1;
|
||||
}
|
||||
path = bl_oom_adj_redirect(path, (flags & O_ACCMODE) != O_RDONLY);
|
||||
if ((fd = bl_status_without_tracer(path, flags, __builtin_return_address(0))) >= 0) return fd;
|
||||
if ((fd = bl_ntsync_open(path, flags)) != -2) return fd;
|
||||
if ((fd = bl_venc_open(path, flags)) != -2) return fd;
|
||||
@@ -80,6 +82,7 @@ int openat(int dirfd, const char *path, int flags, ...) {
|
||||
errno = EACCES;
|
||||
return -1;
|
||||
}
|
||||
path = bl_oom_adj_redirect(path, (flags & O_ACCMODE) != O_RDONLY);
|
||||
if ((fd = bl_status_without_tracer(path, flags, __builtin_return_address(0))) >= 0) return fd;
|
||||
if ((fd = bl_ntsync_open(path, flags)) != -2) return fd;
|
||||
if ((fd = bl_venc_open(path, flags)) != -2) return fd;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
@@ -8,6 +9,8 @@
|
||||
|
||||
#define FUSE_MAGIC 0x65735546
|
||||
#define SDCARDFS_MAGIC 0x5dca2df5
|
||||
#define FAT_MAGIC 0x4d44
|
||||
#define EXFAT_MAGIC 0x2011bab0
|
||||
|
||||
static int is_wineserver(void) {
|
||||
static int cached = -1;
|
||||
@@ -27,15 +30,42 @@ static int is_wineserver(void) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
static int has_no_unix_owner(int fd) {
|
||||
struct statfs fs;
|
||||
|
||||
if (fstatfs(fd, &fs) != 0) return 0;
|
||||
return fs.f_type == FUSE_MAGIC || fs.f_type == SDCARDFS_MAGIC || fs.f_type == FAT_MAGIC ||
|
||||
(unsigned int)fs.f_type == EXFAT_MAGIC;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
void bl_storage_owner(int fd, struct stat *st) {
|
||||
struct statfs fs;
|
||||
int saved = errno;
|
||||
uid_t uid;
|
||||
|
||||
if (st != NULL && is_wineserver()) {
|
||||
uid = getuid();
|
||||
if (st->st_uid != uid && fstatfs(fd, &fs) == 0 && (fs.f_type == FUSE_MAGIC || fs.f_type == SDCARDFS_MAGIC)) st->st_uid = uid;
|
||||
if (st->st_uid != uid && has_no_unix_owner(fd)) st->st_uid = uid;
|
||||
}
|
||||
errno = saved;
|
||||
}
|
||||
|
||||
int fchmod(int fd, mode_t mode) {
|
||||
static int (*next_fchmod)(int, mode_t);
|
||||
int saved = errno, result;
|
||||
|
||||
if (next_fchmod == NULL) next_fchmod = dlsym(RTLD_NEXT, "fchmod");
|
||||
if (next_fchmod == NULL) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
result = next_fchmod(fd, mode);
|
||||
if (result != 0 && errno == EPERM && is_wineserver()) {
|
||||
if (has_no_unix_owner(fd)) {
|
||||
errno = saved;
|
||||
return 0;
|
||||
}
|
||||
errno = EPERM;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/* tools/linuxfs/preload/subreaper.c
|
||||
*
|
||||
* Mark every process that loads libblsession.so as a child subreaper.
|
||||
*
|
||||
* wlroots starts Xwayland with a double fork: gamescope -> middle process
|
||||
* (exits immediately) -> Xwayland. With no subreaper in the tree, Xwayland
|
||||
* is reparented to pid 1 and becomes an orphan. On some vendor kernels
|
||||
* (observed on Meizu / Flyme 12) an orphan reaper SIGKILLs it in that window,
|
||||
* which makes gamescope wait forever in wlserver_init() and the UI hangs on
|
||||
* "Starting display and audio".
|
||||
*
|
||||
* With PR_SET_CHILD_SUBREAPER the reparent target becomes the nearest marked
|
||||
* ancestor instead of init, so the orphan event never happens.
|
||||
*
|
||||
* Harmless for processes that do not fork, and cheap (one syscall at load).
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include <sys/prctl.h>
|
||||
|
||||
__attribute__((constructor))
|
||||
static void bl_session_set_subreaper(void)
|
||||
{
|
||||
(void)prctl(PR_SET_CHILD_SUBREAPER, 1);
|
||||
}
|
||||
@@ -102,6 +102,21 @@ static int make_stand_in(int type) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_nl_socket(int type, int *fd);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_owns(int fd);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_getsockname(int fd, struct sockaddr *addr,
|
||||
socklen_t *len, int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_getpeername(int fd, struct sockaddr *addr,
|
||||
socklen_t *len, int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_setsockopt(int fd, int level, int option,
|
||||
const void *value, socklen_t len,
|
||||
int (*real)(int, int, int, const void *, socklen_t),
|
||||
int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_getsockopt(int fd, int level, int option,
|
||||
void *value, socklen_t *len,
|
||||
int (*real)(int, int, int, void *, socklen_t *),
|
||||
int *rc);
|
||||
|
||||
int socket(int domain, int type, int protocol) {
|
||||
static int (*real_socket)(int, int, int);
|
||||
int fd;
|
||||
@@ -111,6 +126,11 @@ int socket(int domain, int type, int protocol) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
if (domain == AF_NETLINK && protocol == NETLINK_ROUTE) {
|
||||
int route_fd;
|
||||
bl_nl_socket(type, &route_fd);
|
||||
return route_fd;
|
||||
}
|
||||
fd = real_socket(domain, type, protocol);
|
||||
if (fd >= 0 || domain != AF_NETLINK || protocol != NETLINK_KOBJECT_UEVENT)
|
||||
return fd;
|
||||
@@ -129,7 +149,9 @@ __attribute__((visibility("hidden"))) int bl_udevmon_stand_in(int fd) {
|
||||
int getsockname(int fd, struct sockaddr *addr, socklen_t *len) {
|
||||
static int (*real_getsockname)(int, struct sockaddr *, socklen_t *);
|
||||
struct sockaddr_nl nl;
|
||||
int route_rc;
|
||||
|
||||
if (bl_nl_getsockname(fd, addr, len, &route_rc)) return route_rc;
|
||||
if (is_stand_in(fd)) {
|
||||
if (addr == NULL || len == NULL) {
|
||||
errno = EFAULT;
|
||||
@@ -150,21 +172,43 @@ int getsockname(int fd, struct sockaddr *addr, socklen_t *len) {
|
||||
return real_getsockname(fd, addr, len);
|
||||
}
|
||||
|
||||
int getpeername(int fd, struct sockaddr *addr, socklen_t *len) {
|
||||
static int (*real)(int, struct sockaddr *, socklen_t *);
|
||||
int route_rc;
|
||||
if (bl_nl_getpeername(fd, addr, len, &route_rc)) return route_rc;
|
||||
if (real == NULL) real = dlsym(RTLD_NEXT, "getpeername");
|
||||
return real(fd, addr, len);
|
||||
}
|
||||
|
||||
int setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen) {
|
||||
static int (*real_setsockopt)(int, int, int, const void *, socklen_t);
|
||||
int route_rc;
|
||||
|
||||
if (real_setsockopt == NULL) real_setsockopt = dlsym(RTLD_NEXT, "setsockopt");
|
||||
if (real_setsockopt == NULL) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
if (bl_nl_setsockopt(fd, level, optname, optval, optlen, real_setsockopt, &route_rc)) return route_rc;
|
||||
if (is_stand_in(fd)) {
|
||||
if (level == SOL_NETLINK)
|
||||
return 0;
|
||||
if (level == SOL_SOCKET && (optname == SO_ATTACH_FILTER || optname == SO_DETACH_FILTER))
|
||||
return 0;
|
||||
}
|
||||
if (real_setsockopt == NULL) real_setsockopt = dlsym(RTLD_NEXT, "setsockopt");
|
||||
if (real_setsockopt == NULL) {
|
||||
return real_setsockopt(fd, level, optname, optval, optlen);
|
||||
}
|
||||
|
||||
int getsockopt(int fd, int level, int option, void *value, socklen_t *len) {
|
||||
static int (*real)(int, int, int, void *, socklen_t *);
|
||||
int route_rc;
|
||||
if (real == NULL) real = dlsym(RTLD_NEXT, "getsockopt");
|
||||
if (real == NULL) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
return real_setsockopt(fd, level, optname, optval, optlen);
|
||||
if (bl_nl_getsockopt(fd, level, option, value, len, real, &route_rc)) return route_rc;
|
||||
return real(fd, level, option, value, len);
|
||||
}
|
||||
|
||||
struct monitor_netlink_header {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Zink keeps kopper when the session draws through Venus.
|
||||
*
|
||||
* On Mali the session reaches the GPU through Venus over vtest, and Xwayland has no DRM node to
|
||||
* build glamor on, so it offers no DRI3. Without DRI3, Zink can only present through kopper (its
|
||||
* Vulkan WSI path). Steam's steamwebhelper.sh exports LIBGL_KOPPER_DISABLE=true for the client
|
||||
* interface unconditionally, so on Mali every GL context the interface asked for failed and the
|
||||
* webhelper restarted until Steam gave up on GPU acceleration. Steam restores that script when
|
||||
* it verifies its install, so the variable is dropped here instead, before Mesa reads it.
|
||||
*/
|
||||
#define _GNU_SOURCE 1
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
__attribute__((constructor)) static void bl_venus_keep_kopper(void) {
|
||||
const char *debug = getenv("VN_DEBUG");
|
||||
if (debug && strstr(debug, "vtest")) unsetenv("LIBGL_KOPPER_DISABLE");
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"file_format_version": "1.2.0",
|
||||
"layer": {
|
||||
"name": "VK_LAYER_DROIDDECK_xclipse",
|
||||
"type": "GLOBAL",
|
||||
"library_path": "./libVkLayer_droiddeck_xclipse.so",
|
||||
"api_version": "1.3.0",
|
||||
"implementation_version": "1",
|
||||
"description": "Workarounds for Samsung Xclipse drivers loaded through libhybris"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
/* Generated by gen_device_chain.py from Vulkan-Headers 1.3.275; do not edit. */
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_DEVICE_DEVICE_MEMORY_REPORT_CREATE_INFO_EXT, VkDeviceDeviceMemoryReportCreateInfoEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_DEVICE_DIAGNOSTICS_CONFIG_CREATE_INFO_NV, VkDeviceDiagnosticsConfigCreateInfoNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO, VkDeviceGroupDeviceCreateInfo)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_DEVICE_MEMORY_OVERALLOCATION_CREATE_INFO_AMD, VkDeviceMemoryOverallocationCreateInfoAMD)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_DEVICE_PRIVATE_DATA_CREATE_INFO, VkDevicePrivateDataCreateInfo)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_DEVICE_QUEUE_SHADER_CORE_CONTROL_CREATE_INFO_ARM, VkDeviceQueueShaderCoreControlCreateInfoARM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES, VkPhysicalDevice16BitStorageFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_4444_FORMATS_FEATURES_EXT, VkPhysicalDevice4444FormatsFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES, VkPhysicalDevice8BitStorageFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR, VkPhysicalDeviceAccelerationStructureFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ADDRESS_BINDING_REPORT_FEATURES_EXT, VkPhysicalDeviceAddressBindingReportFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_AMIGO_PROFILING_FEATURES_SEC, VkPhysicalDeviceAmigoProfilingFeaturesSEC)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ASTC_DECODE_FEATURES_EXT, VkPhysicalDeviceASTCDecodeFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_FEATURES_EXT, VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT, VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT, VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BORDER_COLOR_SWIZZLE_FEATURES_EXT, VkPhysicalDeviceBorderColorSwizzleFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES, VkPhysicalDeviceBufferDeviceAddressFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT, VkPhysicalDeviceBufferDeviceAddressFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_FEATURES_HUAWEI, VkPhysicalDeviceClusterCullingShaderFeaturesHUAWEI)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COHERENT_MEMORY_FEATURES_AMD, VkPhysicalDeviceCoherentMemoryFeaturesAMD)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COLOR_WRITE_ENABLE_FEATURES_EXT, VkPhysicalDeviceColorWriteEnableFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_NV, VkPhysicalDeviceComputeShaderDerivativesFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT, VkPhysicalDeviceConditionalRenderingFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR, VkPhysicalDeviceCooperativeMatrixFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_NV, VkPhysicalDeviceCooperativeMatrixFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COPY_MEMORY_INDIRECT_FEATURES_NV, VkPhysicalDeviceCopyMemoryIndirectFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CORNER_SAMPLED_IMAGE_FEATURES_NV, VkPhysicalDeviceCornerSampledImageFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COVERAGE_REDUCTION_MODE_FEATURES_NV, VkPhysicalDeviceCoverageReductionModeFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUBIC_CLAMP_FEATURES_QCOM, VkPhysicalDeviceCubicClampFeaturesQCOM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUBIC_WEIGHTS_FEATURES_QCOM, VkPhysicalDeviceCubicWeightsFeaturesQCOM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUDA_KERNEL_LAUNCH_FEATURES_NV, VkPhysicalDeviceCudaKernelLaunchFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT, VkPhysicalDeviceCustomBorderColorFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEDICATED_ALLOCATION_IMAGE_ALIASING_FEATURES_NV, VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_BIAS_CONTROL_FEATURES_EXT, VkPhysicalDeviceDepthBiasControlFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLAMP_ZERO_ONE_FEATURES_EXT, VkPhysicalDeviceDepthClampZeroOneFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_CONTROL_FEATURES_EXT, VkPhysicalDeviceDepthClipControlFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT, VkPhysicalDeviceDepthClipEnableFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT, VkPhysicalDeviceDescriptorBufferFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES, VkPhysicalDeviceDescriptorIndexingFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_POOL_OVERALLOCATION_FEATURES_NV, VkPhysicalDeviceDescriptorPoolOverallocationFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_SET_HOST_MAPPING_FEATURES_VALVE, VkPhysicalDeviceDescriptorSetHostMappingFeaturesVALVE)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_COMPUTE_FEATURES_NV, VkPhysicalDeviceDeviceGeneratedCommandsComputeFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_FEATURES_NV, VkPhysicalDeviceDeviceGeneratedCommandsFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT, VkPhysicalDeviceDeviceMemoryReportFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DIAGNOSTICS_CONFIG_FEATURES_NV, VkPhysicalDeviceDiagnosticsConfigFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES, VkPhysicalDeviceDynamicRenderingFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_UNUSED_ATTACHMENTS_FEATURES_EXT, VkPhysicalDeviceDynamicRenderingUnusedAttachmentsFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXCLUSIVE_SCISSOR_FEATURES_NV, VkPhysicalDeviceExclusiveScissorFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT, VkPhysicalDeviceExtendedDynamicState2FeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT, VkPhysicalDeviceExtendedDynamicState3FeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT, VkPhysicalDeviceExtendedDynamicStateFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_SPARSE_ADDRESS_SPACE_FEATURES_NV, VkPhysicalDeviceExtendedSparseAddressSpaceFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_RDMA_FEATURES_NV, VkPhysicalDeviceExternalMemoryRDMAFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FAULT_FEATURES_EXT, VkPhysicalDeviceFaultFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, VkPhysicalDeviceFeatures2)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_FEATURES_EXT, VkPhysicalDeviceFragmentDensityMap2FeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_FEATURES_EXT, VkPhysicalDeviceFragmentDensityMapFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_FEATURES_QCOM, VkPhysicalDeviceFragmentDensityMapOffsetFeaturesQCOM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR, VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT, VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_ENUMS_FEATURES_NV, VkPhysicalDeviceFragmentShadingRateEnumsFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR, VkPhysicalDeviceFragmentShadingRateFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAME_BOUNDARY_FEATURES_EXT, VkPhysicalDeviceFrameBoundaryFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR, VkPhysicalDeviceGlobalPriorityQueryFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_FEATURES_EXT, VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_FEATURES_EXT, VkPhysicalDeviceHostImageCopyFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES, VkPhysicalDeviceHostQueryResetFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES, VkPhysicalDeviceImagelessFramebufferFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_2D_VIEW_OF_3D_FEATURES_EXT, VkPhysicalDeviceImage2DViewOf3DFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT, VkPhysicalDeviceImageCompressionControlFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT, VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_2_FEATURES_QCOM, VkPhysicalDeviceImageProcessing2FeaturesQCOM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_FEATURES_QCOM, VkPhysicalDeviceImageProcessingFeaturesQCOM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES, VkPhysicalDeviceImageRobustnessFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_SLICED_VIEW_OF_3D_FEATURES_EXT, VkPhysicalDeviceImageSlicedViewOf3DFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_MIN_LOD_FEATURES_EXT, VkPhysicalDeviceImageViewMinLodFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT, VkPhysicalDeviceIndexTypeUint8FeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INHERITED_VIEWPORT_SCISSOR_FEATURES_NV, VkPhysicalDeviceInheritedViewportScissorFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES, VkPhysicalDeviceInlineUniformBlockFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INVOCATION_MASK_FEATURES_HUAWEI, VkPhysicalDeviceInvocationMaskFeaturesHUAWEI)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LEGACY_DITHERING_FEATURES_EXT, VkPhysicalDeviceLegacyDitheringFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINEAR_COLOR_ATTACHMENT_FEATURES_NV, VkPhysicalDeviceLinearColorAttachmentFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT, VkPhysicalDeviceLineRasterizationFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES, VkPhysicalDeviceMaintenance4Features)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR, VkPhysicalDeviceMaintenance5FeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_6_FEATURES_KHR, VkPhysicalDeviceMaintenance6FeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_DECOMPRESSION_FEATURES_NV, VkPhysicalDeviceMemoryDecompressionFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT, VkPhysicalDeviceMemoryPriorityFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT, VkPhysicalDeviceMeshShaderFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_NV, VkPhysicalDeviceMeshShaderFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_FEATURES_EXT, VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES, VkPhysicalDeviceMultiviewFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_RENDER_AREAS_FEATURES_QCOM, VkPhysicalDeviceMultiviewPerViewRenderAreasFeaturesQCOM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_VIEWPORTS_FEATURES_QCOM, VkPhysicalDeviceMultiviewPerViewViewportsFeaturesQCOM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_FEATURES_EXT, VkPhysicalDeviceMultiDrawFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT, VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_NESTED_COMMAND_BUFFER_FEATURES_EXT, VkPhysicalDeviceNestedCommandBufferFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_NON_SEAMLESS_CUBE_MAP_FEATURES_EXT, VkPhysicalDeviceNonSeamlessCubeMapFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPACITY_MICROMAP_FEATURES_EXT, VkPhysicalDeviceOpacityMicromapFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV, VkPhysicalDeviceOpticalFlowFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PAGEABLE_DEVICE_LOCAL_MEMORY_FEATURES_EXT, VkPhysicalDevicePageableDeviceLocalMemoryFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PERFORMANCE_QUERY_FEATURES_KHR, VkPhysicalDevicePerformanceQueryFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PER_STAGE_DESCRIPTOR_SET_FEATURES_NV, VkPhysicalDevicePerStageDescriptorSetFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES, VkPhysicalDevicePipelineCreationCacheControlFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR, VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_LIBRARY_GROUP_HANDLES_FEATURES_EXT, VkPhysicalDevicePipelineLibraryGroupHandlesFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_PROPERTIES_FEATURES_EXT, VkPhysicalDevicePipelinePropertiesFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_PROTECTED_ACCESS_FEATURES_EXT, VkPhysicalDevicePipelineProtectedAccessFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_ROBUSTNESS_FEATURES_EXT, VkPhysicalDevicePipelineRobustnessFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_BARRIER_FEATURES_NV, VkPhysicalDevicePresentBarrierFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR, VkPhysicalDevicePresentIdFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR, VkPhysicalDevicePresentWaitFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVES_GENERATED_QUERY_FEATURES_EXT, VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVE_TOPOLOGY_LIST_RESTART_FEATURES_EXT, VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES, VkPhysicalDevicePrivateDataFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES, VkPhysicalDeviceProtectedMemoryFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT, VkPhysicalDeviceProvokingVertexFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT, VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR, VkPhysicalDeviceRayQueryFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_FEATURES_NV, VkPhysicalDeviceRayTracingInvocationReorderFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_MAINTENANCE_1_FEATURES_KHR, VkPhysicalDeviceRayTracingMaintenance1FeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_MOTION_BLUR_FEATURES_NV, VkPhysicalDeviceRayTracingMotionBlurFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR, VkPhysicalDeviceRayTracingPipelineFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_POSITION_FETCH_FEATURES_KHR, VkPhysicalDeviceRayTracingPositionFetchFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RELAXED_LINE_RASTERIZATION_FEATURES_IMG, VkPhysicalDeviceRelaxedLineRasterizationFeaturesIMG)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RENDER_PASS_STRIPED_FEATURES_ARM, VkPhysicalDeviceRenderPassStripedFeaturesARM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_REPRESENTATIVE_FRAGMENT_TEST_FEATURES_NV, VkPhysicalDeviceRepresentativeFragmentTestFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RGBA10X6_FORMATS_FEATURES_EXT, VkPhysicalDeviceRGBA10X6FormatsFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT, VkPhysicalDeviceRobustness2FeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES, VkPhysicalDeviceSamplerYcbcrConversionFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES, VkPhysicalDeviceScalarBlockLayoutFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCHEDULING_CONTROLS_FEATURES_ARM, VkPhysicalDeviceSchedulingControlsFeaturesARM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES, VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_2_FEATURES_EXT, VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT, VkPhysicalDeviceShaderAtomicFloatFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES, VkPhysicalDeviceShaderAtomicInt64Features)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR, VkPhysicalDeviceShaderClockFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_FEATURES_ARM, VkPhysicalDeviceShaderCoreBuiltinsFeaturesARM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES, VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES, VkPhysicalDeviceShaderDrawParametersFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_FEATURES_AMD, VkPhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES, VkPhysicalDeviceShaderFloat16Int8Features)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_IMAGE_ATOMIC_INT64_FEATURES_EXT, VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_IMAGE_FOOTPRINT_FEATURES_NV, VkPhysicalDeviceShaderImageFootprintFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES, VkPhysicalDeviceShaderIntegerDotProductFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_FUNCTIONS_2_FEATURES_INTEL, VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_FEATURES_EXT, VkPhysicalDeviceShaderModuleIdentifierFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT, VkPhysicalDeviceShaderObjectFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SM_BUILTINS_FEATURES_NV, VkPhysicalDeviceShaderSMBuiltinsFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_FEATURES_KHR, VkPhysicalDeviceShaderSubgroupUniformControlFlowFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES, VkPhysicalDeviceShaderTerminateInvocationFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TILE_IMAGE_FEATURES_EXT, VkPhysicalDeviceShaderTileImageFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADING_RATE_IMAGE_FEATURES_NV, VkPhysicalDeviceShadingRateImageFeaturesNV)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES, VkPhysicalDeviceSubgroupSizeControlFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBPASS_MERGE_FEEDBACK_FEATURES_EXT, VkPhysicalDeviceSubpassMergeFeedbackFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBPASS_SHADING_FEATURES_HUAWEI, VkPhysicalDeviceSubpassShadingFeaturesHUAWEI)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT, VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES, VkPhysicalDeviceSynchronization2Features)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT, VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES, VkPhysicalDeviceTextureCompressionASTCHDRFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TILE_PROPERTIES_FEATURES_QCOM, VkPhysicalDeviceTilePropertiesFeaturesQCOM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES, VkPhysicalDeviceTimelineSemaphoreFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT, VkPhysicalDeviceTransformFeedbackFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES, VkPhysicalDeviceUniformBufferStandardLayoutFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES, VkPhysicalDeviceVariablePointersFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_KHR, VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_INPUT_DYNAMIC_STATE_FEATURES_EXT, VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_MAINTENANCE_1_FEATURES_KHR, VkPhysicalDeviceVideoMaintenance1FeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, VkPhysicalDeviceVulkan11Features)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, VkPhysicalDeviceVulkan12Features)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES, VkPhysicalDeviceVulkan13Features)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES, VkPhysicalDeviceVulkanMemoryModelFeatures)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_FEATURES_KHR, VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_YCBCR_2_PLANE_444_FORMATS_FEATURES_EXT, VkPhysicalDeviceYcbcr2Plane444FormatsFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_YCBCR_DEGAMMA_FEATURES_QCOM, VkPhysicalDeviceYcbcrDegammaFeaturesQCOM)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_YCBCR_IMAGE_ARRAYS_FEATURES_EXT, VkPhysicalDeviceYcbcrImageArraysFeaturesEXT)
|
||||
DEVICE_CHAIN(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES, VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures)
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate device_chain.inc: the structures a VkDeviceCreateInfo chain may hold, with their sizes.
|
||||
|
||||
The Xclipse layer copies the chain ahead of the VkPhysicalDeviceFeatures2 it edits, and copying a
|
||||
structure needs its size. Run against the Vulkan-Headers release the build compiles with (Ubuntu
|
||||
24.04's libvulkan-dev is 1.3.275):
|
||||
|
||||
gen_device_chain.py Vulkan-Headers/registry/vk.xml Vulkan-Headers/include/vulkan/vulkan_core.h
|
||||
"""
|
||||
import re
|
||||
import sys
|
||||
import xml.etree.ElementTree as ElementTree
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main(registry, core_header, output):
|
||||
core = Path(core_header).read_text()
|
||||
root = ElementTree.parse(registry).getroot()
|
||||
entries = []
|
||||
for struct in root.iter("type"):
|
||||
if struct.get("category") != "struct" or struct.get("alias"):
|
||||
continue
|
||||
if "VkDeviceCreateInfo" not in (struct.get("structextends") or "").split(","):
|
||||
continue
|
||||
name = struct.get("name")
|
||||
stype = next((member.get("values") for member in struct.findall("member")
|
||||
if member.findtext("name") == "sType"), None)
|
||||
# Platform and provisional structures live outside vulkan_core.h; the layer never builds them.
|
||||
if not stype or not re.search(r"\}\s*" + re.escape(name) + r"\s*;", core):
|
||||
continue
|
||||
entries.append((stype, name))
|
||||
version = re.search(r"#define VK_HEADER_VERSION (\d+)", core).group(1)
|
||||
lines = ["/* Generated by gen_device_chain.py from Vulkan-Headers 1.3.%s; do not edit. */" % version]
|
||||
lines += ["DEVICE_CHAIN(%s, %s)" % entry for entry in sorted(entries)]
|
||||
Path(output).write_text("\n".join(lines) + "\n")
|
||||
print("%d structures" % len(entries))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) not in (3, 4):
|
||||
sys.exit(__doc__)
|
||||
main(sys.argv[1], sys.argv[2], sys.argv[3] if len(sys.argv) == 4 else
|
||||
Path(__file__).with_name("device_chain.inc"))
|
||||
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* VK_LAYER_DROIDDECK_xclipse: workarounds for Samsung's Xclipse driver loaded through libhybris.
|
||||
*
|
||||
* 1. bionic environ. A glibc process never initializes bionic's `environ`; the driver's
|
||||
* AMD-derived shader compiler walks it for AMD_SC_* settings and crashed on the NULL.
|
||||
* Once instance creation has loaded the driver, point it at a snapshot of ours.
|
||||
* 2. YCbCr immutable samplers in compute. Compute pipelines whose layout binds an array of
|
||||
* immutable YCbCr-conversion samplers fail to compile (VK_ERROR_UNKNOWN); gamescope's
|
||||
* composite shaders all bind one. Such bindings get a plain linear sampler instead, so only
|
||||
* multi-planar (NV12) layers sample incorrectly.
|
||||
* 3. Calibrated timestamps. The driver has only VK_EXT_calibrated_timestamps, but the bridge
|
||||
* lists the KHR names too, and Wine calls those; the loader then aborts (it took down Wine's
|
||||
* explorer.exe and with it every game window). The KHR entry points forward to the EXT ones.
|
||||
* 4. BC4/BC5 filtering. The libhybris compat layer emulates BC textures; BC4/BC5 decode into
|
||||
* R16/R16G16 images, for which this driver advertises no linear filtering, so DXVK would
|
||||
* treat them as unfilterable. The layer reports linear filtering for BC4/BC5 where they are
|
||||
* sampled at all (RDNA filters 16-bit normalized formats; at worst they sample unfiltered).
|
||||
* 5. textureCompressionBC. The compat layer emulates BC formats but keeps the feature bit off;
|
||||
* DXVK before 3.0 (the last that fits this driver's 128 bytes of push constants) requires
|
||||
* it. The layer reports it while BC formats are sampleable and clears it at device creation.
|
||||
* Everything else passes straight through.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include <vulkan/vk_layer.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define EXPORT __attribute__((visibility("default")))
|
||||
#define MAX_OBJECTS 64
|
||||
|
||||
extern char **environ;
|
||||
|
||||
/* The loader's dispatch table pointer heads every dispatchable object: an instance shares it
|
||||
* with its physical devices, a device with its queues and command buffers. */
|
||||
typedef void *dispatch_key;
|
||||
static dispatch_key key_of(const void *object) { return *(dispatch_key *)object; }
|
||||
|
||||
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int debug;
|
||||
|
||||
struct instance_data {
|
||||
dispatch_key key;
|
||||
VkInstance handle;
|
||||
PFN_vkGetInstanceProcAddr next;
|
||||
PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT time_domains;
|
||||
PFN_vkGetPhysicalDeviceFeatures features;
|
||||
PFN_vkGetPhysicalDeviceFeatures2 features2;
|
||||
PFN_vkGetPhysicalDeviceFormatProperties format_properties;
|
||||
PFN_vkGetPhysicalDeviceFormatProperties2 format_properties2;
|
||||
};
|
||||
struct device_data {
|
||||
dispatch_key key;
|
||||
VkDevice handle;
|
||||
PFN_vkGetDeviceProcAddr next;
|
||||
PFN_vkCreateSampler create_sampler;
|
||||
PFN_vkDestroySampler destroy_sampler;
|
||||
PFN_vkCreateDescriptorSetLayout create_set_layout;
|
||||
PFN_vkDestroyDevice destroy_device;
|
||||
PFN_vkGetCalibratedTimestampsEXT timestamps;
|
||||
VkSampler fallback;
|
||||
};
|
||||
static struct instance_data instances[MAX_OBJECTS];
|
||||
static struct device_data devices[MAX_OBJECTS];
|
||||
/* The live YCbCr samplers each device created, so set layouts can recognise them. Guarded by lock. */
|
||||
static struct ycbcr_sampler { VkDevice device; VkSampler sampler; } *ycbcr_samplers;
|
||||
static size_t ycbcr_count, ycbcr_capacity;
|
||||
|
||||
static struct instance_data *instance_by_key(dispatch_key key) {
|
||||
for (int i = 0; i < MAX_OBJECTS; i++)
|
||||
if (instances[i].handle && instances[i].key == key) return &instances[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct device_data *device_by_key(dispatch_key key) {
|
||||
for (int i = 0; i < MAX_OBJECTS; i++)
|
||||
if (devices[i].handle && devices[i].key == key) return &devices[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Entries are never freed while their object lives, so a looked-up copy of the pointers is safe. */
|
||||
static struct instance_data instance_of(const void *object) {
|
||||
struct instance_data copy = {0};
|
||||
pthread_mutex_lock(&lock);
|
||||
struct instance_data *data = instance_by_key(key_of(object));
|
||||
if (data) copy = *data;
|
||||
pthread_mutex_unlock(&lock);
|
||||
return copy;
|
||||
}
|
||||
|
||||
static struct device_data device_of(const void *object) {
|
||||
struct device_data copy = {0};
|
||||
pthread_mutex_lock(&lock);
|
||||
struct device_data *data = device_by_key(key_of(object));
|
||||
if (data) copy = *data;
|
||||
pthread_mutex_unlock(&lock);
|
||||
return copy;
|
||||
}
|
||||
|
||||
static void fix_bionic_environ(void) {
|
||||
void *common = dlopen("libhybris-common.so.1", RTLD_NOW | RTLD_NOLOAD);
|
||||
if (!common) return; /* not a libhybris driver */
|
||||
void *(*h_dlopen)(const char *, int) = (void *(*)(const char *, int))dlsym(common, "hybris_dlopen");
|
||||
void *(*h_dlsym)(void *, const char *) = (void *(*)(void *, const char *))dlsym(common, "hybris_dlsym");
|
||||
if (!h_dlopen || !h_dlsym) return;
|
||||
void *libc = h_dlopen("libc.so", RTLD_NOW);
|
||||
char ***bionic_environ = libc ? (char ***)h_dlsym(libc, "environ") : NULL;
|
||||
if (!bionic_environ || *bionic_environ) return;
|
||||
size_t count = 0;
|
||||
while (environ && environ[count]) count++;
|
||||
char **snapshot = calloc(count + 1, sizeof(*snapshot));
|
||||
if (!snapshot) return;
|
||||
for (size_t i = 0; i < count; i++) snapshot[i] = strdup(environ[i]);
|
||||
*bionic_environ = snapshot;
|
||||
if (debug) fprintf(stderr, "xclipse layer: bionic environ set (%zu entries)\n", count);
|
||||
}
|
||||
|
||||
/* ---- instance ---- */
|
||||
|
||||
static VkResult VKAPI_CALL create_instance(const VkInstanceCreateInfo *info, const VkAllocationCallbacks *allocator,
|
||||
VkInstance *instance) {
|
||||
VkLayerInstanceCreateInfo *chain = (VkLayerInstanceCreateInfo *)info->pNext;
|
||||
while (chain && !(chain->sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO && chain->function == VK_LAYER_LINK_INFO))
|
||||
chain = (VkLayerInstanceCreateInfo *)chain->pNext;
|
||||
if (!chain || !chain->u.pLayerInfo) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
PFN_vkGetInstanceProcAddr next = chain->u.pLayerInfo->pfnNextGetInstanceProcAddr;
|
||||
chain->u.pLayerInfo = chain->u.pLayerInfo->pNext;
|
||||
PFN_vkCreateInstance next_create = (PFN_vkCreateInstance)next(NULL, "vkCreateInstance");
|
||||
if (!next_create) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
VkResult result = next_create(info, allocator, instance);
|
||||
if (result != VK_SUCCESS) return result;
|
||||
fix_bionic_environ();
|
||||
struct instance_data data = {
|
||||
.key = key_of(*instance),
|
||||
.handle = *instance,
|
||||
.next = next,
|
||||
.time_domains = (PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT)
|
||||
next(*instance, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT"),
|
||||
.features = (PFN_vkGetPhysicalDeviceFeatures)next(*instance, "vkGetPhysicalDeviceFeatures"),
|
||||
.features2 = (PFN_vkGetPhysicalDeviceFeatures2)next(*instance, "vkGetPhysicalDeviceFeatures2"),
|
||||
.format_properties = (PFN_vkGetPhysicalDeviceFormatProperties)next(*instance, "vkGetPhysicalDeviceFormatProperties"),
|
||||
.format_properties2 = (PFN_vkGetPhysicalDeviceFormatProperties2)next(*instance, "vkGetPhysicalDeviceFormatProperties2"),
|
||||
};
|
||||
pthread_mutex_lock(&lock);
|
||||
for (int i = 0; i < MAX_OBJECTS; i++)
|
||||
if (!instances[i].handle) { instances[i] = data; break; }
|
||||
pthread_mutex_unlock(&lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void VKAPI_CALL destroy_instance(VkInstance instance, const VkAllocationCallbacks *allocator) {
|
||||
PFN_vkGetInstanceProcAddr next = instance_of(instance).next;
|
||||
pthread_mutex_lock(&lock);
|
||||
struct instance_data *data = instance_by_key(key_of(instance));
|
||||
if (data) memset(data, 0, sizeof(*data));
|
||||
pthread_mutex_unlock(&lock);
|
||||
PFN_vkDestroyInstance next_destroy = next ? (PFN_vkDestroyInstance)next(instance, "vkDestroyInstance") : NULL;
|
||||
if (next_destroy) next_destroy(instance, allocator);
|
||||
}
|
||||
|
||||
static VkResult VKAPI_CALL time_domains_khr(VkPhysicalDevice physical, uint32_t *count, VkTimeDomainEXT *domains) {
|
||||
PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT ext = instance_of(physical).time_domains;
|
||||
if (!ext) { *count = 0; return VK_SUCCESS; }
|
||||
return ext(physical, count, domains);
|
||||
}
|
||||
|
||||
/* BC formats sampleable below us although the driver's feature bit is off: the compat layer emulates them. */
|
||||
static int bc_emulated(VkPhysicalDevice physical) {
|
||||
struct instance_data data = instance_of(physical);
|
||||
if (!data.features || !data.format_properties) return 0;
|
||||
VkPhysicalDeviceFeatures native;
|
||||
data.features(physical, &native);
|
||||
if (native.textureCompressionBC) return 0;
|
||||
VkFormatProperties bc1, bc7;
|
||||
data.format_properties(physical, VK_FORMAT_BC1_RGBA_UNORM_BLOCK, &bc1);
|
||||
data.format_properties(physical, VK_FORMAT_BC7_UNORM_BLOCK, &bc7);
|
||||
return (bc1.optimalTilingFeatures & bc7.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0;
|
||||
}
|
||||
|
||||
static void VKAPI_CALL get_features(VkPhysicalDevice physical, VkPhysicalDeviceFeatures *features) {
|
||||
PFN_vkGetPhysicalDeviceFeatures next = instance_of(physical).features;
|
||||
if (next) next(physical, features);
|
||||
if (bc_emulated(physical)) features->textureCompressionBC = VK_TRUE;
|
||||
}
|
||||
|
||||
static void VKAPI_CALL get_features2(VkPhysicalDevice physical, VkPhysicalDeviceFeatures2 *features) {
|
||||
PFN_vkGetPhysicalDeviceFeatures2 next = instance_of(physical).features2;
|
||||
if (next) next(physical, features);
|
||||
if (bc_emulated(physical)) features->features.textureCompressionBC = VK_TRUE;
|
||||
}
|
||||
|
||||
static int bc45(VkFormat format) {
|
||||
return format >= VK_FORMAT_BC4_UNORM_BLOCK && format <= VK_FORMAT_BC5_SNORM_BLOCK;
|
||||
}
|
||||
|
||||
static void VKAPI_CALL get_format_properties(VkPhysicalDevice physical, VkFormat format, VkFormatProperties *out) {
|
||||
PFN_vkGetPhysicalDeviceFormatProperties next = instance_of(physical).format_properties;
|
||||
if (next) next(physical, format, out);
|
||||
if (bc45(format) && (out->optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
|
||||
out->optimalTilingFeatures |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
|
||||
}
|
||||
|
||||
static void VKAPI_CALL get_format_properties2(VkPhysicalDevice physical, VkFormat format, VkFormatProperties2 *out) {
|
||||
PFN_vkGetPhysicalDeviceFormatProperties2 next = instance_of(physical).format_properties2;
|
||||
if (next) next(physical, format, out);
|
||||
if (!bc45(format)) return;
|
||||
if (out->formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)
|
||||
out->formatProperties.optimalTilingFeatures |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
|
||||
for (VkBaseOutStructure *p = (VkBaseOutStructure *)out->pNext; p; p = p->pNext) {
|
||||
if (p->sType != VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3) continue;
|
||||
VkFormatProperties3 *f3 = (VkFormatProperties3 *)p;
|
||||
if (f3->optimalTilingFeatures & VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT)
|
||||
f3->optimalTilingFeatures |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- device ---- */
|
||||
|
||||
/* The size of each structure a VkDeviceCreateInfo chain may hold (device_chain.inc, generated from the
|
||||
* Vulkan registry), plus the loader's own; 0 for anything else. */
|
||||
static size_t chain_size(VkStructureType type) {
|
||||
switch (type) {
|
||||
#define DEVICE_CHAIN(stype, name) case stype: return sizeof(name);
|
||||
#include "device_chain.inc"
|
||||
#undef DEVICE_CHAIN
|
||||
case VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO: return sizeof(VkLayerDeviceCreateInfo);
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
struct chain_copy { void **nodes; size_t count; };
|
||||
|
||||
static void free_chain_copy(struct chain_copy *copy) {
|
||||
for (size_t i = 0; i < copy->count; i++) free(copy->nodes[i]);
|
||||
free(copy->nodes);
|
||||
copy->nodes = NULL;
|
||||
copy->count = 0;
|
||||
}
|
||||
|
||||
/* The chain with textureCompressionBC cleared in a copy of the VkPhysicalDeviceFeatures2 that enables
|
||||
* it: every structure up to it is copied into [copy], the rest is shared. The caller's structures are
|
||||
* never written. *head_out stays [head] when nothing needs clearing, or when a structure ahead of it
|
||||
* is unknown to this build (newer than its Vulkan headers); the compat layer then refuses the bit. */
|
||||
static VkResult chain_without_bc(const void *head, struct chain_copy *copy, const void **head_out) {
|
||||
*head_out = head;
|
||||
const VkBaseInStructure *target = NULL;
|
||||
size_t count = 0;
|
||||
for (const VkBaseInStructure *p = head; p && !target; p = p->pNext) {
|
||||
if (!chain_size(p->sType)) return VK_SUCCESS;
|
||||
count++;
|
||||
if (p->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 &&
|
||||
((const VkPhysicalDeviceFeatures2 *)p)->features.textureCompressionBC) target = p;
|
||||
}
|
||||
if (!target) return VK_SUCCESS;
|
||||
if (!(copy->nodes = calloc(count, sizeof(*copy->nodes)))) return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
VkBaseOutStructure *first = NULL, *last = NULL;
|
||||
for (const VkBaseInStructure *p = head; ; p = p->pNext) {
|
||||
size_t size = chain_size(p->sType);
|
||||
VkBaseOutStructure *node = malloc(size);
|
||||
if (!node) { free_chain_copy(copy); return VK_ERROR_OUT_OF_HOST_MEMORY; }
|
||||
copy->nodes[copy->count++] = node;
|
||||
memcpy(node, p, size);
|
||||
if (last) last->pNext = node; else first = node;
|
||||
last = node;
|
||||
if (p == target) {
|
||||
((VkPhysicalDeviceFeatures2 *)node)->features.textureCompressionBC = VK_FALSE;
|
||||
*head_out = first; /* its pNext still leads to the caller's remaining structures */
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static VkResult VKAPI_CALL create_device(VkPhysicalDevice physical, const VkDeviceCreateInfo *info,
|
||||
const VkAllocationCallbacks *allocator, VkDevice *device) {
|
||||
VkLayerDeviceCreateInfo *chain = (VkLayerDeviceCreateInfo *)info->pNext;
|
||||
while (chain && !(chain->sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO && chain->function == VK_LAYER_LINK_INFO))
|
||||
chain = (VkLayerDeviceCreateInfo *)chain->pNext;
|
||||
if (!chain || !chain->u.pLayerInfo) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
PFN_vkGetInstanceProcAddr next_gipa = chain->u.pLayerInfo->pfnNextGetInstanceProcAddr;
|
||||
PFN_vkGetDeviceProcAddr next_gdpa = chain->u.pLayerInfo->pfnNextGetDeviceProcAddr;
|
||||
chain->u.pLayerInfo = chain->u.pLayerInfo->pNext;
|
||||
PFN_vkCreateDevice next_create = (PFN_vkCreateDevice)next_gipa(NULL, "vkCreateDevice");
|
||||
if (!next_create) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
|
||||
VkDeviceCreateInfo patched = *info;
|
||||
/* An emulated textureCompressionBC never reaches the compat layer, which refuses the bit. */
|
||||
int strip_bc = bc_emulated(physical);
|
||||
VkPhysicalDeviceFeatures plain_features;
|
||||
if (strip_bc && info->pEnabledFeatures && info->pEnabledFeatures->textureCompressionBC) {
|
||||
plain_features = *info->pEnabledFeatures;
|
||||
plain_features.textureCompressionBC = VK_FALSE;
|
||||
patched.pEnabledFeatures = &plain_features;
|
||||
}
|
||||
struct chain_copy copy = {0};
|
||||
if (strip_bc) {
|
||||
VkResult copied = chain_without_bc(info->pNext, ©, &patched.pNext);
|
||||
if (copied != VK_SUCCESS) return copied;
|
||||
}
|
||||
VkResult result = next_create(physical, &patched, allocator, device);
|
||||
free_chain_copy(©);
|
||||
if (result != VK_SUCCESS) return result;
|
||||
|
||||
PFN_vkCreateSampler create_sampler = (PFN_vkCreateSampler)next_gdpa(*device, "vkCreateSampler");
|
||||
VkSamplerCreateInfo plain = {
|
||||
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
|
||||
.magFilter = VK_FILTER_LINEAR, .minFilter = VK_FILTER_LINEAR,
|
||||
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK,
|
||||
};
|
||||
VkSampler fallback = VK_NULL_HANDLE;
|
||||
if (create_sampler) create_sampler(*device, &plain, NULL, &fallback);
|
||||
struct device_data data = {
|
||||
.key = key_of(*device),
|
||||
.handle = *device,
|
||||
.next = next_gdpa,
|
||||
.create_sampler = create_sampler,
|
||||
.destroy_sampler = (PFN_vkDestroySampler)next_gdpa(*device, "vkDestroySampler"),
|
||||
.create_set_layout = (PFN_vkCreateDescriptorSetLayout)next_gdpa(*device, "vkCreateDescriptorSetLayout"),
|
||||
.destroy_device = (PFN_vkDestroyDevice)next_gdpa(*device, "vkDestroyDevice"),
|
||||
.timestamps = (PFN_vkGetCalibratedTimestampsEXT)next_gdpa(*device, "vkGetCalibratedTimestampsEXT"),
|
||||
.fallback = fallback,
|
||||
};
|
||||
pthread_mutex_lock(&lock);
|
||||
for (int i = 0; i < MAX_OBJECTS; i++)
|
||||
if (!devices[i].handle) { devices[i] = data; break; }
|
||||
pthread_mutex_unlock(&lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void VKAPI_CALL destroy_device(VkDevice device, const VkAllocationCallbacks *allocator) {
|
||||
struct device_data data = device_of(device);
|
||||
pthread_mutex_lock(&lock);
|
||||
struct device_data *entry = device_by_key(key_of(device));
|
||||
if (entry) memset(entry, 0, sizeof(*entry));
|
||||
for (size_t k = 0; k < ycbcr_count;)
|
||||
if (ycbcr_samplers[k].device == device) ycbcr_samplers[k] = ycbcr_samplers[--ycbcr_count];
|
||||
else k++;
|
||||
pthread_mutex_unlock(&lock);
|
||||
if (data.fallback && data.destroy_sampler) data.destroy_sampler(device, data.fallback, NULL);
|
||||
if (data.destroy_device) data.destroy_device(device, allocator);
|
||||
}
|
||||
|
||||
static VkResult VKAPI_CALL timestamps_khr(VkDevice device, uint32_t count, const VkCalibratedTimestampInfoEXT *infos,
|
||||
uint64_t *timestamps, uint64_t *deviation) {
|
||||
PFN_vkGetCalibratedTimestampsEXT ext = device_of(device).timestamps;
|
||||
return ext ? ext(device, count, infos, timestamps, deviation) : VK_ERROR_FEATURE_NOT_PRESENT;
|
||||
}
|
||||
|
||||
static VkResult VKAPI_CALL create_sampler(VkDevice device, const VkSamplerCreateInfo *info,
|
||||
const VkAllocationCallbacks *allocator, VkSampler *sampler) {
|
||||
PFN_vkCreateSampler next = device_of(device).create_sampler;
|
||||
if (!next) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
VkResult result = next(device, info, allocator, sampler);
|
||||
if (result != VK_SUCCESS) return result;
|
||||
int ycbcr = 0;
|
||||
for (const VkBaseInStructure *p = info->pNext; p && !ycbcr; p = p->pNext)
|
||||
ycbcr = p->sType == VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO;
|
||||
if (!ycbcr) return result;
|
||||
pthread_mutex_lock(&lock);
|
||||
if (ycbcr_count == ycbcr_capacity) {
|
||||
size_t capacity = ycbcr_capacity ? ycbcr_capacity * 2 : 16;
|
||||
struct ycbcr_sampler *grown = realloc(ycbcr_samplers, capacity * sizeof(*grown));
|
||||
if (!grown) {
|
||||
pthread_mutex_unlock(&lock);
|
||||
/* An untracked YCbCr sampler would reach a compute layout unreplaced: fail instead. */
|
||||
PFN_vkDestroySampler destroy = device_of(device).destroy_sampler;
|
||||
if (destroy) destroy(device, *sampler, allocator);
|
||||
*sampler = VK_NULL_HANDLE;
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
ycbcr_samplers = grown;
|
||||
ycbcr_capacity = capacity;
|
||||
}
|
||||
ycbcr_samplers[ycbcr_count++] = (struct ycbcr_sampler){device, *sampler};
|
||||
pthread_mutex_unlock(&lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void VKAPI_CALL destroy_sampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks *allocator) {
|
||||
pthread_mutex_lock(&lock);
|
||||
for (size_t k = 0; k < ycbcr_count; k++)
|
||||
if (ycbcr_samplers[k].device == device && ycbcr_samplers[k].sampler == sampler) {
|
||||
ycbcr_samplers[k] = ycbcr_samplers[--ycbcr_count];
|
||||
break;
|
||||
}
|
||||
pthread_mutex_unlock(&lock);
|
||||
PFN_vkDestroySampler next = device_of(device).destroy_sampler;
|
||||
if (next) next(device, sampler, allocator);
|
||||
}
|
||||
|
||||
/* Called with lock held. */
|
||||
static int is_ycbcr(VkDevice device, VkSampler sampler) {
|
||||
for (size_t k = 0; sampler && k < ycbcr_count; k++)
|
||||
if (ycbcr_samplers[k].device == device && ycbcr_samplers[k].sampler == sampler) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static VkResult VKAPI_CALL create_set_layout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *info,
|
||||
const VkAllocationCallbacks *allocator, VkDescriptorSetLayout *layout) {
|
||||
struct device_data data = device_of(device);
|
||||
if (!data.create_set_layout) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
int replace = 0;
|
||||
pthread_mutex_lock(&lock);
|
||||
for (uint32_t b = 0; data.fallback && b < info->bindingCount && !replace; b++) {
|
||||
const VkDescriptorSetLayoutBinding *binding = &info->pBindings[b];
|
||||
if (!(binding->stageFlags & VK_SHADER_STAGE_COMPUTE_BIT) || !binding->pImmutableSamplers) continue;
|
||||
for (uint32_t s = 0; s < binding->descriptorCount; s++)
|
||||
if (is_ycbcr(device, binding->pImmutableSamplers[s])) { replace = 1; break; }
|
||||
}
|
||||
pthread_mutex_unlock(&lock);
|
||||
if (!replace) return data.create_set_layout(device, info, allocator, layout);
|
||||
|
||||
VkResult result = VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
VkDescriptorSetLayoutBinding *bindings = calloc(info->bindingCount, sizeof(*bindings));
|
||||
VkSampler **arrays = calloc(info->bindingCount, sizeof(*arrays));
|
||||
if (!bindings || !arrays) goto done;
|
||||
for (uint32_t b = 0; b < info->bindingCount; b++) {
|
||||
bindings[b] = info->pBindings[b];
|
||||
if (!(bindings[b].stageFlags & VK_SHADER_STAGE_COMPUTE_BIT) || !bindings[b].pImmutableSamplers) continue;
|
||||
/* Without the replacement the driver would see the samplers it cannot compile: fail instead. */
|
||||
if (!(arrays[b] = malloc(bindings[b].descriptorCount * sizeof(VkSampler)))) goto done;
|
||||
pthread_mutex_lock(&lock);
|
||||
for (uint32_t s = 0; s < bindings[b].descriptorCount; s++) {
|
||||
VkSampler original = bindings[b].pImmutableSamplers[s];
|
||||
arrays[b][s] = is_ycbcr(device, original) ? data.fallback : original;
|
||||
}
|
||||
pthread_mutex_unlock(&lock);
|
||||
bindings[b].pImmutableSamplers = arrays[b];
|
||||
}
|
||||
VkDescriptorSetLayoutCreateInfo patched = *info;
|
||||
patched.pBindings = bindings;
|
||||
result = data.create_set_layout(device, &patched, allocator, layout);
|
||||
if (debug) fprintf(stderr, "xclipse layer: compute YCbCr immutable samplers replaced (%d)\n", result);
|
||||
done:
|
||||
for (uint32_t b = 0; arrays && b < info->bindingCount; b++) free(arrays[b]);
|
||||
free(arrays);
|
||||
free(bindings);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ---- dispatch ---- */
|
||||
|
||||
static PFN_vkVoidFunction device_hook(const char *name) {
|
||||
if (!strcmp(name, "vkGetDeviceProcAddr")) return NULL; /* handled by the caller */
|
||||
if (!strcmp(name, "vkDestroyDevice")) return (PFN_vkVoidFunction)destroy_device;
|
||||
if (!strcmp(name, "vkCreateSampler")) return (PFN_vkVoidFunction)create_sampler;
|
||||
if (!strcmp(name, "vkDestroySampler")) return (PFN_vkVoidFunction)destroy_sampler;
|
||||
if (!strcmp(name, "vkCreateDescriptorSetLayout")) return (PFN_vkVoidFunction)create_set_layout;
|
||||
if (!strcmp(name, "vkGetCalibratedTimestampsKHR")) return (PFN_vkVoidFunction)timestamps_khr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *name) {
|
||||
if (!strcmp(name, "vkGetDeviceProcAddr")) return (PFN_vkVoidFunction)vkGetDeviceProcAddr;
|
||||
PFN_vkVoidFunction hook = device_hook(name);
|
||||
if (hook) return hook;
|
||||
struct device_data data = device ? device_of(device) : (struct device_data){0};
|
||||
return data.next ? data.next(device, name) : NULL;
|
||||
}
|
||||
|
||||
EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *name) {
|
||||
if (!strcmp(name, "vkGetInstanceProcAddr")) return (PFN_vkVoidFunction)vkGetInstanceProcAddr;
|
||||
if (!strcmp(name, "vkCreateInstance")) return (PFN_vkVoidFunction)create_instance;
|
||||
if (!strcmp(name, "vkDestroyInstance")) return (PFN_vkVoidFunction)destroy_instance;
|
||||
if (!strcmp(name, "vkCreateDevice")) return (PFN_vkVoidFunction)create_device;
|
||||
if (!strcmp(name, "vkGetDeviceProcAddr")) return (PFN_vkVoidFunction)vkGetDeviceProcAddr;
|
||||
if (!strcmp(name, "vkGetPhysicalDeviceFeatures")) return (PFN_vkVoidFunction)get_features;
|
||||
if (!strcmp(name, "vkGetPhysicalDeviceFeatures2") || !strcmp(name, "vkGetPhysicalDeviceFeatures2KHR"))
|
||||
return (PFN_vkVoidFunction)get_features2;
|
||||
if (!strcmp(name, "vkGetPhysicalDeviceCalibrateableTimeDomainsKHR")) return (PFN_vkVoidFunction)time_domains_khr;
|
||||
if (!strcmp(name, "vkGetPhysicalDeviceFormatProperties")) return (PFN_vkVoidFunction)get_format_properties;
|
||||
if (!strcmp(name, "vkGetPhysicalDeviceFormatProperties2") || !strcmp(name, "vkGetPhysicalDeviceFormatProperties2KHR"))
|
||||
return (PFN_vkVoidFunction)get_format_properties2;
|
||||
PFN_vkVoidFunction hook = device_hook(name);
|
||||
if (hook) return hook;
|
||||
PFN_vkGetInstanceProcAddr next = instance ? instance_of(instance).next : NULL;
|
||||
return next ? next(instance, name) : NULL;
|
||||
}
|
||||
|
||||
EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *negotiate) {
|
||||
if (!negotiate || negotiate->loaderLayerInterfaceVersion < 2) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
debug = getenv("DROIDDECK_XCLIPSE_LAYER_DEBUG") != NULL;
|
||||
negotiate->loaderLayerInterfaceVersion = 2;
|
||||
negotiate->pfnGetInstanceProcAddr = vkGetInstanceProcAddr;
|
||||
negotiate->pfnGetDeviceProcAddr = vkGetDeviceProcAddr;
|
||||
negotiate->pfnGetPhysicalDeviceProcAddr = NULL;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
Reference in new issue
Block a user