Skip to content

Commit

Permalink
proton-tkg: Initial VR support
Browse files Browse the repository at this point in the history
Thanks to @GloriousEggroll for the wined3d patches squashing
  • Loading branch information
Tk-Glitch committed Feb 3, 2020
1 parent e4c1da9 commit ef447dd
Show file tree
Hide file tree
Showing 7 changed files with 1,791 additions and 4 deletions.
2 changes: 0 additions & 2 deletions proton-tkg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ You can also change their default values before building in your `proton-tkg.cfg

- Proton doesn't like running games from NTFS. Consider symlinking your compatdata dir(s) (usually found in /SteamApps) to some place on an EXT4 partition if you want to play games from a NTFS partition.

- SteamVR support is missing for versatility reasons. It might be added at some point.

- Proton-tkg **can** handle 32-bit prefixes. However you'll have to create such a prefix by hand as the Steam client doesn't offer such an option. Also, that prefix will have to be deleted if you want to use an official Proton build with the game bound to it.

- In the userpatches folder, you'll find three patches I decided against merging in the master patch for proton-tkg. You can put them in wine-tkg-git userpatches dir if you want to use them. They might not apply cleanly on older wine bases.
Expand Down
3 changes: 3 additions & 0 deletions proton-tkg/proton-tkg.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ _gamepad_additions="false"
# Proton non-vr-related wined3d additions - Disabled on staging independently of this setting
_wined3d_additions="true"

# Proton wined3d-interop and friends for SteamVR support
_steamvr_support="false"

# Disable nvapi and nvapi64 - Common fix for various games
_proton_nvapi_disable="true"

Expand Down
58 changes: 56 additions & 2 deletions proton-tkg/proton-tkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,53 @@ else
# Grab share template and inject version
echo "1552061114 proton-tkg-$_protontkg_version" > "$_nowhere/proton_dist_tmp/version" && cp -r "$_nowhere/proton_template/share"/* "$_nowhere/proton_dist_tmp/share"/

# Create the dxvk dirs
mkdir -p "$_nowhere/proton_dist_tmp/lib64/wine/dxvk"
mkdir -p "$_nowhere/proton_dist_tmp/lib/wine/dxvk"

# Build vrclient libs
if [ "$_steamvr_support" == "true" ]; then
git clone https://github.com/ValveSoftware/openvr.git || true # It'll complain the path already exists on subsequent builds
cd openvr
git reset --hard HEAD
git clean -xdf
git pull
#git checkout 52065df3d6f3af96300dac98cdf7397f26abfcd7
cd ..

export WINEMAKERFLAGS="--nosource-fix --nolower-include --nodlls --nomsvcrt --dll -I$_nowhere/proton_dist_tmp/include/wine/windows/ -I$_nowhere/proton_dist_tmp/include/ -I$_nowhere/proton_dist_tmp/include/wine/"
export CFLAGS="-O2 -g"
export CXXFLAGS="-Wno-attributes -std=c++0x -O2 -g"
PATH="$_nowhere"/proton_dist_tmp/bin:$PATH

mkdir -p build/vrclient.win64
mkdir -p build/vrclient.win32

cp -a vrclient_x64/* build/vrclient.win64
cp -a vrclient_x64/* build/vrclient.win32 && mv build/vrclient.win32/vrclient_x64 build/vrclient.win32/vrclient && mv build/vrclient.win32/vrclient/vrclient_x64.spec build/vrclient.win32/vrclient/vrclient.spec

cd build/vrclient.win64
winemaker $WINEMAKERFLAGS -L"$_nowhere/proton_dist_tmp/lib64/" -L"$_nowhere/proton_dist_tmp/lib64/wine/" -I"$_nowhere/Proton/build/vrclient.win64/vrclient_x64/" -I"$_nowhere/Proton/build/vrclient.win64/" vrclient_x64
make -C "$_nowhere/Proton/build/vrclient.win64/vrclient_x64" -j$(nproc) && strip vrclient_x64/vrclient_x64.dll.so
winebuild --dll --fake-module -E "$_nowhere/Proton/build/vrclient.win64/vrclient_x64/vrclient_x64.spec" -o vrclient_x64.dll.fake
cd ../..

cd build/vrclient.win32
winemaker $WINEMAKERFLAGS --wine32 -L"$_nowhere/proton_dist_tmp/lib/" -L"$_nowhere/proton_dist_tmp/lib/wine/" -I"$_nowhere/Proton/build/vrclient.win32/vrclient/" -I"$_nowhere/Proton/build/vrclient.win32/" vrclient
make -e CC="winegcc -m32" CXX="wineg++ -m32" -C "$_nowhere/Proton/build/vrclient.win32/vrclient" -j$(nproc) && strip vrclient/vrclient.dll.so
winebuild --dll --fake-module -E "$_nowhere/Proton/build/vrclient.win32/vrclient/vrclient.spec" -o vrclient.dll.fake
cd $_nowhere

# Inject vrclient & openvr libs in our wine-tkg-git build
cp -v Proton/build/vrclient.win64/vrclient_x64/vrclient_x64.dll.so proton_dist_tmp/lib64/wine/ && cp -v Proton/build/vrclient.win64/vrclient_x64.dll.fake proton_dist_tmp/lib64/wine/fakedlls/vrclient_x64.dll
cp -v Proton/build/vrclient.win32/vrclient/vrclient.dll.so proton_dist_tmp/lib/wine/ && cp -v Proton/build/vrclient.win32/vrclient.dll.fake proton_dist_tmp/lib/wine/fakedlls/vrclient.dll

cp -v Proton/openvr/bin/win32/openvr_api.dll proton_dist_tmp/lib/wine/dxvk/openvr_api_dxvk.dll
cp -v Proton/openvr/bin/win64/openvr_api.dll proton_dist_tmp/lib64/wine/dxvk/openvr_api_dxvk.dll

cd Proton
fi

# Build lsteamclient libs
export WINEMAKERFLAGS="--nosource-fix --nolower-include --nodlls --nomsvcrt --dll -I$_nowhere/proton_dist_tmp/include/wine/windows/ -I$_nowhere/proton_dist_tmp/include/"
export CFLAGS="-O2 -g"
Expand Down Expand Up @@ -253,8 +300,8 @@ else
rm -f dxvk-*.tar.*
mv "$_nowhere"/dxvk-* "$_nowhere"/dxvk
fi
mkdir -p proton_dist_tmp/lib64/wine/dxvk && cp -v dxvk/x64/* proton_dist_tmp/lib64/wine/dxvk/
mkdir -p proton_dist_tmp/lib/wine/dxvk && cp -v dxvk/x32/* proton_dist_tmp/lib/wine/dxvk/
cp -v dxvk/x64/* proton_dist_tmp/lib64/wine/dxvk/
cp -v dxvk/x32/* proton_dist_tmp/lib/wine/dxvk/
fi

echo ''
Expand All @@ -274,6 +321,13 @@ else
cd "$_nowhere"
fi

# Patch our proton script to allow for VR support
if [ "$_steamvr_support" == "true" ]; then
cd "$_nowhere/proton_tkg_$_protontkg_version"
patch -Np1 < "$_nowhere/proton_template/vr-support.patch" && rm -f proton.orig
cd "$_nowhere"
fi

# Set Proton-tkg user_settings.py defaults
if [ "$_proton_nvapi_disable" == "true" ]; then
sed -i 's/.*PROTON_NVAPI_DISABLE.*/ "PROTON_NVAPI_DISABLE": "1",/g' "proton_tkg_$_protontkg_version/user_settings.py"
Expand Down
114 changes: 114 additions & 0 deletions proton-tkg/proton_template/vr-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
From 5c5a18438870d10c31933061b2721477658931c9 Mon Sep 17 00:00:00 2001
From: Tk-Glitch <[email protected]>
Date: Mon, 3 Feb 2020 07:17:25 +0100
Subject: proton-tkg: initial vr support


diff --git a/proton b/proton
index 811de5e..028e7dd 100755
--- a/proton
+++ b/proton
@@ -333,6 +333,15 @@ class CompatData:
os.remove(dstfile)
try_copy(steamdir + "/legacycompat/" + f, dstfile)

+ #copy openvr files into place
+ dst = self.prefix_dir + "/drive_c/vrclient/bin/"
+ makedirs(dst)
+ try_copy(g_proton.lib_dir + "wine/fakedlls/vrclient.dll", dst)
+ try_copy(g_proton.lib64_dir + "wine/fakedlls/vrclient_x64.dll", dst)
+
+ try_copy(g_proton.lib_dir + "wine/dxvk/openvr_api_dxvk.dll", self.prefix_dir + "/drive_c/windows/syswow64/")
+ try_copy(g_proton.lib64_dir + "wine/dxvk/openvr_api_dxvk.dll", self.prefix_dir + "/drive_c/windows/system32/")
+
dxvkfiles = ("d3d11", "d3d10", "d3d10core", "d3d10_1")
def make_dxvk_links(dll_dir, link_dir):
for f in dxvkfiles:
@@ -696,6 +705,79 @@ class Session:
else:
self.env["WINEDLLOVERRIDES"] = s

+ def setup_vr(self):
+ #parse linux openvr config and present it in win32 format to the app.
+ #logic from openvr's CVRPathRegistry_Public::GetPaths
+
+ #check environment for overrides
+ vr_runtime = None
+ if "VR_OVERRIDE" in self.env:
+ vr_runtime = self.env["VR_OVERRIDE"]
+ self.env.pop("VR_OVERRIDE")
+
+ vr_config = None
+ if "VR_CONFIG_PATH" in self.env:
+ vr_config = self.env["VR_CONFIG_PATH"]
+ self.env.pop("VR_CONFIG_PATH")
+
+ vr_log = None
+ if "VR_LOG_PATH" in self.env:
+ vr_log = self.env["VR_LOG_PATH"]
+ self.env.pop("VR_LOG_PATH")
+
+ #load from json if needed
+ if vr_runtime is None or \
+ vr_config is None or \
+ vr_log is None:
+ try:
+ path = os.environ.get("XDG_CONFIG_HOME", os.environ["HOME"] + "/.config")
+ path = path + "/openvr/openvrpaths.vrpath"
+
+ with open(path, "r") as jfile:
+ j = json.load(jfile)
+
+ if vr_runtime is None:
+ vr_runtime = j["runtime"][0]
+
+ if vr_config is None:
+ vr_config = j["config"][0]
+
+ if vr_log is None:
+ vr_log = j["log"][0]
+ except (TypeError, ValueError, OSError):
+ #log("Missing or invalid openvrpaths.vrpath file! " + str(sys.exc_info()[1]))
+ pass
+
+ makedirs(g_compatdata.prefix_dir + "/drive_c/users/steamuser/Local Settings/Application Data/openvr")
+
+ #remove existing file
+ vrpaths_name = g_compatdata.prefix_dir + "/drive_c/users/steamuser/Local Settings/Application Data/openvr/openvrpaths.vrpath"
+ if os.path.exists(vrpaths_name):
+ os.remove(vrpaths_name)
+
+ #dump new file
+ if not vr_runtime is None:
+ try:
+ self.env["PROTON_VR_RUNTIME"] = vr_runtime
+
+ j = { "runtime": [ "C:\\vrclient\\", "C:\\vrclient" ] }
+
+ if not vr_config is None:
+ win_vr_config = subprocess.check_output([g_proton.wine_bin, "winepath", "-w", vr_config], env=self.env, stderr=self.log_file).decode("utf-8")
+ j["config"] = [ win_vr_config.strip() ]
+
+ if not vr_log is None:
+ win_vr_log = subprocess.check_output([g_proton.wine_bin, "winepath", "-w", vr_log], env=self.env, stderr=self.log_file).decode("utf-8")
+ j["log"] = [ win_vr_log.strip() ]
+
+ j["version"] = 1
+ j["jsonid"] = "vrpathreg"
+
+ with open(vrpaths_name, "w") as vfile:
+ json.dump(j, vfile, indent=2)
+ except (ValueError, OSError):
+ log("Unable to write VR config! " + str(sys.exc_info()[1]))
+
def dump_dbg_env(self, f):
f.write("PATH=\"" + self.env["PATH"] + "\" \\\n")
f.write("\tTERM=\"xterm\" \\\n") #XXX
@@ -804,6 +886,7 @@ class Session:
subprocess.call(args, env=local_env, stderr=self.log_file, stdout=self.log_file)

def run(self):
+ self.setup_vr()
if "PROTON_DUMP_DEBUG_COMMANDS" in self.env and nonzero(self.env["PROTON_DUMP_DEBUG_COMMANDS"]):
try:
self.dump_dbg_scripts()
1 change: 1 addition & 0 deletions wine-tkg-git/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ source=("$_winesrcdir"::"${_winesrctarget}${_plain_commit}"
'proton-staging_winex11-MWM_Decorations.patch' # Proton friendly version of that staging patchset
'proton-staging_winex11-_NET_ACTIVE_WINDOW-0002.patch' # Proton friendly version of that staging patchset
'proton-staging_winex11-WM_WINDOWPOSCHANGING.patch' # Proton friendly version of that staging patchset
'proton-vr.patch' # wined3d interop and friends for steamvr support

This comment has been minimized.

Copy link
@neVERberleRfellerER

neVERberleRfellerER Feb 3, 2020

Integrity checks (md5) differ in size from the source array.

)

md5sums=('SKIP'
Expand Down
Loading

0 comments on commit ef447dd

Please sign in to comment.