Skip to content

Commit d7eea5a

Browse files
proton: add ntsync, fsr4, wayland, amdags options from emtaash's build
1 parent e386858 commit d7eea5a

File tree

1 file changed

+104
-22
lines changed

1 file changed

+104
-22
lines changed

proton

Lines changed: 104 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import shlex
1717
import uuid
1818
import json
1919
import time
20+
import urllib.request
2021

2122
from ctypes import CDLL
2223
from ctypes import CFUNCTYPE
@@ -732,6 +733,9 @@ class CompatData:
732733
#How can this happen??
733734
log("Prefix has an invalid version?! You may want to back up user files and delete this prefix.")
734735
#If it does, just let the Wine upgrade happen and hope it works...
736+
with open(self.creation_sync_guard, "w"):
737+
pass
738+
os.sync()
735739
return
736740

737741
try:
@@ -1009,6 +1013,19 @@ class CompatData:
10091013
os.remove(old)
10101014
os.symlink(src=link, dst=old)
10111015

1016+
def setup_fsr4(self):
1017+
fsr4files = ["amdxcffx64"]
1018+
1019+
for f in fsr4files:
1020+
dst = "drive_c/windows/system32/" + f + ".dll"
1021+
if not file_exists(self.prefix_dir + dst, follow_symlinks=False):
1022+
try:
1023+
tracked_files.write(dst + '\n')
1024+
except Exception:
1025+
pass
1026+
if file_exists(g_proton.lib_dir + "wine/amdprop/" + f + ".dll", follow_symlinks=False):
1027+
self.create_symlink(self.prefix_dir + dst, g_proton.lib_dir + "wine/amdprop/" + f + ".dll")
1028+
10121029
def setup_prefix(self):
10131030
with self.prefix_lock:
10141031
if file_exists(self.version_file, follow_symlinks=True):
@@ -1235,6 +1252,8 @@ class CompatData:
12351252
tracked_files.write(dst + '\n')
12361253
self.create_symlink(self.prefix_dir + dst, g_proton.lib_dir + "wine/icu/i386-windows/" + f + ".dll")
12371254

1255+
self.setup_fsr4()
1256+
12381257
# If the user requested the NVAPI be available, copy it into place.
12391258
# If they didn't, clean up any stray nvapi DLLs.
12401259
if use_nvapi:
@@ -1611,6 +1630,13 @@ class Session:
16111630
self.compat_config.discard(config_name)
16121631
return True
16131632

1633+
def download_file(self, uri, dst):
1634+
try:
1635+
os.makedirs(os.path.dirname(dst), exist_ok=True)
1636+
urllib.request.urlretrieve(uri, dst)
1637+
except Exception:
1638+
pass
1639+
16141640
def try_log_slr_versions(self):
16151641
try:
16161642
if "PRESSURE_VESSEL_RUNTIME_BASE" in self.env:
@@ -1687,10 +1713,6 @@ class Session:
16871713
if not self.check_environment("PROTON_USE_WINED3D", "wined3d"):
16881714
self.check_environment("PROTON_USE_WINED3D11", "wined3d")
16891715
self.check_environment("PROTON_NO_WM_DECORATION", "nowmdecoration")
1690-
self.check_environment("PROTON_ENABLE_WAYLAND", "enablewayland")
1691-
self.check_environment("PROTON_ENABLE_HDR", "enablehdr")
1692-
self.check_environment("PROTON_PREFER_SDL", "sdlinput")
1693-
self.check_environment("PROTON_NO_STEAMINPUT", "sdlinput")
16941716
self.check_environment("PROTON_DXVK_D3D8", "dxvkd3d8")
16951717
self.check_environment("PROTON_NO_D3D11", "nod3d11")
16961718
self.check_environment("PROTON_NO_D3D10", "nod3d10")
@@ -1709,6 +1731,19 @@ class Session:
17091731
self.check_environment("PROTON_DISABLE_NVAPI", "disablenvapi")
17101732
self.check_environment("PROTON_FORCE_NVAPI", "forcenvapi")
17111733
self.check_environment("PROTON_HIDE_APU", "hideapu")
1734+
self.check_environment("PROTON_ENABLE_WAYLAND", "wayland")
1735+
self.check_environment("PROTON_USE_WAYLAND", "wayland")
1736+
self.check_environment("PROTON_PREFER_SDL", "sdlinput")
1737+
self.check_environment("PROTON_USE_SDL", "sdlinput")
1738+
self.check_environment("PROTON_FSR4_UPGRADE", "fsr4")
1739+
self.check_environment("PROTON_NATIVE_AGS", "nativeags")
1740+
self.check_environment("PROTON_ENABLE_HDR", "hdr")
1741+
self.check_environment("PROTON_USE_NTSYNC", "ntsync")
1742+
1743+
if "ntsync" in self.compat_config:
1744+
self.env["WINENTSYNC"] = "1"
1745+
else:
1746+
self.env.pop("WINENTSYNC", "")
17121747

17131748
if "noesync" in self.compat_config:
17141749
self.env.pop("WINEESYNC", "")
@@ -1718,24 +1753,6 @@ class Session:
17181753
if "nowmdecoration" in self.compat_config:
17191754
self.env["WINE_NO_WM_DECORATION"] = "1"
17201755

1721-
if "enablewayland" in self.compat_config:
1722-
if self.env.get("WAYLAND_DISPLAY", False):
1723-
self.dlloverrides["winex11.drv"] = "d"
1724-
self.dlloverrides["winewayland.drv"] = "b"
1725-
self.env["WINE_WAYLAND_HACKS"] = "1"
1726-
if "enablehdr" in self.compat_config:
1727-
self.env["DXVK_HDR"] = "1"
1728-
"""
1729-
It is not possible for winewayland to support xalia since
1730-
there is no way to position toplevel surfaces dynamically in wayland
1731-
"""
1732-
self.env["PROTON_USE_XALIA"] = "0"
1733-
# Steam input does not work on wayland
1734-
self.env["PROTON_NO_STEAMINPUT"] = "1"
1735-
# Make sure SDL will still work with the controllers, steam sets this for some dumb reason
1736-
if "SDL_GAMECONTROLLER_IGNORE_DEVICES" in self.env:
1737-
del self.env["SDL_GAMECONTROLLER_IGNORE_DEVICES"]
1738-
17391756
if "noxim" not in self.compat_config:
17401757
self.env.pop("WINE_ALLOW_XIM")
17411758

@@ -1867,6 +1884,11 @@ class Session:
18671884
if "disablelibglesv2" in self.compat_config:
18681885
self.dlloverrides["libglesv2"] = "d"
18691886

1887+
if "nativeags" in self.compat_config:
1888+
self.dlloverrides["atiadlxx"] = "b"
1889+
self.dlloverrides["atidxx64"] = "b"
1890+
self.dlloverrides["amd_ags_x64"] = "n"
1891+
18701892
if "nomfdxgiman" in self.compat_config:
18711893
self.env["WINE_DO_NOT_CREATE_DXGI_DEVICE_MANAGER"] = "1"
18721894

@@ -1893,6 +1915,44 @@ class Session:
18931915
if "SDL_GAMECONTROLLER_IGNORE_DEVICES" in self.env:
18941916
del self.env["SDL_GAMECONTROLLER_IGNORE_DEVICES"]
18951917

1918+
if "fsr4" in self.compat_config:
1919+
self.env["FSR4_UPGRADE"] = "1"
1920+
versions = ["67D435F7d97000", "67A4D2BC10ad000"]
1921+
version_match = True
1922+
1923+
# TODO: make the following code more efficent
1924+
1925+
# 0. Check downloaded version
1926+
if file_exists(g_proton.lib_dir + "wine/amdprop/amdxcffx64_version", follow_symlinks=False):
1927+
with open(g_proton.lib_dir + "wine/amdprop/amdxcffx64_version", "r") as file:
1928+
first_line = file.readline()
1929+
version_match = False
1930+
for version in versions:
1931+
if first_line in version:
1932+
version_match = True
1933+
else:
1934+
version_match = False
1935+
1936+
# 1. Download amdxcffx64 library
1937+
if not file_exists(g_proton.lib_dir + "wine/amdprop/amdxcffx64.dll", follow_symlinks=False) or not version_match:
1938+
self.download_file("https://download.amd.com/dir/bin/amdxcffx64.dll/" + versions[1] + "/amdxcffx64.dll", g_proton.lib_dir + "wine/amdprop/amdxcffx64.dll")
1939+
1940+
# 2. Update stored version
1941+
if file_exists(g_proton.lib_dir + "wine/amdprop/amdxcffx64.dll", follow_symlinks=False):
1942+
g_compatdata.setup_fsr4()
1943+
if not version_match:
1944+
with open(g_proton.lib_dir + "wine/amdprop/amdxcffx64_version", "w") as file:
1945+
file.write(versions[1] + "\n")
1946+
1947+
if "hdr" in self.compat_config:
1948+
self.env["DXVK_HDR"] = "1"
1949+
1950+
# igdext is loaded either using the LoadLibraryExW hack on 1.3 or lower
1951+
# or using the INTC_ALT_DRIVER_EXTENSIONS_PATH on 2.0 or newer
1952+
# TODO: Load it through driver store data like it is on windows
1953+
# TODO: D3D11 has a different loading mechanism because why not
1954+
self.env["INTC_ALT_DRIVER_EXTENSIONS_PATH"] = "C:\\Windows\\System32"
1955+
18961956
# NVIDIA software may check for the "DriverStore" by querying the
18971957
# NGXCore\NGXPath registry key via `D3DDDI_QUERYREGISTRY_SERVICEKEY` for
18981958
# a given adapter. In the case where this path cannot be found, the
@@ -1937,6 +1997,12 @@ class Session:
19371997
if var in self.env:
19381998
self.log_file.write("Effective " + var + ": " + self.env[var] + "\n")
19391999

2000+
if "fsr4" in self.compat_config:
2001+
if file_exists(g_proton.lib_dir + "wine/amdprop/amdxcffx64.dll", follow_symlinks=False):
2002+
self.log_file.write("INFO: Automatic FSR4 upgrade enabled!\n")
2003+
else:
2004+
self.log_file.write("ERROR: Failed to download amdxcffx64.dll!\n")
2005+
19402006
# check for low fd limit
19412007
_soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
19422008
if hard_limit < 524288:
@@ -1977,6 +2043,22 @@ class Session:
19772043
if "disablenvapi" not in self.compat_config or "forcenvapi" in self.compat_config:
19782044
self.env["DXVK_ENABLE_NVAPI"] = "1"
19792045

2046+
if "wayland" in self.compat_config:
2047+
if "WAYLAND_DISPLAY" in self.env:
2048+
self.dlloverrides["winex11.drv"] = "d"
2049+
self.dlloverrides["winewayland.drv"] = "b"
2050+
self.env["WINE_WAYLAND_HACKS"] = "1"
2051+
"""
2052+
It is not possible for winewayland to support xalia since
2053+
there is no way to position toplevel surfaces dynamically in wayland
2054+
"""
2055+
self.env["PROTON_USE_XALIA"] = "0"
2056+
# Steam input does not work on wayland
2057+
self.env["PROTON_NO_STEAMINPUT"] = "1"
2058+
# Make sure SDL will still work with the controllers, steam sets this for some dumb reason
2059+
if "SDL_GAMECONTROLLER_IGNORE_DEVICES" in self.env:
2060+
del self.env["SDL_GAMECONTROLLER_IGNORE_DEVICES"]
2061+
19802062
if "forcenvapi" in self.compat_config:
19812063
self.env["DXVK_NVAPI_ALLOW_OTHER_DRIVERS"] = "1"
19822064
self.env["DXVK_NVAPI_DRIVER_VERSION"] = "99999"

0 commit comments

Comments
 (0)