Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

Merge upstream/main into integrate (ray.31)

raymondchins302b20ede04a
diff --cc Makefile
index 9463732,40ac529..51f4a00
--- a/Makefile
+++ b/Makefile
@@@ -444,7 -453,7 +463,7 @@@ overlay-shim-tests: $(OVERLAY_SHIM
$(call SKIP,overlay-shim-tests,$(OVERLAY_SHIM_TESTS)); exit 0; fi; \
mkdir -p $(OUT_DIR); \
fail=0; ran=0; skipped=0; \
- for t in device bridge delivery framegen; do \
- for t in device bridge delivery ownership; do \
++ for t in device bridge delivery framegen ownership; do \
for a in arm64 x86_64; do \
$(CC) -arch $$a $(OVERLAY_SHIM_TEST_FLAGS) -o $(OUT_DIR)/$$t.$$a \
$(OVERLAY_SHIM_TESTS)/$$t.m || exit 1; \
diff --cc dylib/feats/compat_run.sh
index 8962e0d,f24cbac..4fa5681
--- a/dylib/feats/compat_run.sh
+++ b/dylib/feats/compat_run.sh
@@@ -296,628 -237,21 +296,643 @@@ case "$app_id" in ''|0) app_id=$(basena
case "$app_id" in ''|*[!0-9]*) app_id=0 ;; esac
echo "app_id=$app_id (STEAM_COMPAT_APP_ID=$STEAM_COMPAT_APP_ID)" >> "$log" 2>&1 || true
+# SDL has no built-in mapping for some pads (GameSir G7 Pro dongle, 3537:1022), so
+# winebus hands games their raw button order. Mappings in gamecontrollerdb.txt reach
+# winebus through the environment; its registry "map" loader crashes in this Wine.
+# macOS Steam has no virtual gamepad Wine could read, so a pad Steam Input claims (and
+# lists in SDL_GAMECONTROLLER_IGNORE_DEVICES) would reach the game as nothing. Games read
+# pads directly unless the launch options set NOTPROTON_RAW_CONTROLLERS=0.
+if [ "${NOTPROTON_RAW_CONTROLLERS:-1}" = "1" ]; then
+ NOTPROTON_RAW_CONTROLLERS=1
+ SDL_GAMECONTROLLER_IGNORE_DEVICES=
+ export NOTPROTON_RAW_CONTROLLERS SDL_GAMECONTROLLER_IGNORE_DEVICES
+fi
+
+# SDL hands pads that macOS GameController.framework knows (GameSir G7 Pro over Bluetooth)
+# to its MFi driver, which finds nothing outside an app run loop such as winedevice.exe's,
+# so the pad never reached Wine. IOKit reads them instead.
+SDL_JOYSTICK_MFI=0
+export SDL_JOYSTICK_MFI
+
+# The full database, gamecontrollerdb.merged.txt from scripts/update-gamecontrollerdb.sh
+# (~90 KB), reaches SDL as a file: SDL_Init reads SDL_GAMECONTROLLERCONFIG_FILE (SDL 2.0.22+),
+# then the variable's lines, which outrank the file's. Only the hand-written lines ride in
+# the variable, which every Wine process inherits. A runner SDL without the hint gets the
+# database in the variable instead. The variable keeps the last line per GUID, newest
+# first, up to pad_cap bytes.
+np_pad_mappings() {
+ pad_db="$np_support/gamecontrollerdb.txt"
+ pad_full="$np_support/gamecontrollerdb.merged.txt"
+ pad_sdl="$CX_ROOT/lib/libSDL2-2.0.0.dylib"
+ pad_cap=32768
+ pad_env_src=""
+ if [ -f "$pad_full" ] && [ -z "$SDL_GAMECONTROLLERCONFIG_FILE" ]; then
+ if [ -f "$pad_sdl" ] && LC_ALL=C grep -q -a SDL_GAMECONTROLLERCONFIG_FILE "$pad_sdl" 2>/dev/null; then
+ SDL_GAMECONTROLLERCONFIG_FILE="$pad_full"
+ export SDL_GAMECONTROLLERCONFIG_FILE
+ echo "controllers: mapping file $pad_full" >> "$log" 2>&1 || true
+ else
+ pad_env_src="$pad_full"
+ echo "controllers: $pad_sdl lacks SDL_GAMECONTROLLERCONFIG_FILE, $pad_full goes in the environment (capped)" >> "$log" 2>&1 || true
+ fi
+ fi
+ [ -f "$pad_db" ] || pad_db=""
+ [ -n "$pad_env_src$pad_db" ] || return 0
+ # Last line per GUID, newest first until pad_cap bytes, printed in file order
+ pad_maps=$(cat ${pad_env_src:+"$pad_env_src"} ${pad_db:+"$pad_db"} | tr -d '\r' \
+ | sed -e '/^[[:space:]]*#/d' -e '/^[[:space:]]*$/d' \
+ | awk -v cap="$pad_cap" '
+ { line[NR] = $0 }
+ END {
+ for (i = NR; i >= 1; i--) {
+ g = tolower(substr(line[i], 1, 32))
+ if (g in seen) continue
+ seen[g] = 1
+ if (size + length(line[i]) + 1 > cap) { dropped++; continue }
+ size += length(line[i]) + 1
+ keep[i] = 1
+ }
+ for (i = 1; i <= NR; i++) if (i in keep) print line[i]
+ if (dropped) printf "controllers: %d mapping(s) over the %d-byte cap dropped\n", dropped, cap > "/dev/stderr"
+ }' 2>> "$log")
+ [ -n "$pad_maps" ] || return 0
+ if [ -n "$SDL_GAMECONTROLLERCONFIG" ]; then
+ SDL_GAMECONTROLLERCONFIG="$SDL_GAMECONTROLLERCONFIG
+$pad_maps"
+ else
+ SDL_GAMECONTROLLERCONFIG="$pad_maps"
+ fi
+ export SDL_GAMECONTROLLERCONFIG
+ echo "controllers: $(printf '%s\n' "$pad_maps" | wc -l | tr -d ' ') mapping(s) in SDL_GAMECONTROLLERCONFIG from ${pad_env_src:+$pad_env_src }${pad_db}" >> "$log" 2>&1 || true
+}
+np_pad_mappings
+
+# Per-game fixes: the shipped gamefixes-default/<appid>.conf, then the user's
+# gamefixes/<appid>.conf, the later file winning per key. KEY=VALUE lines are checked
+# against an allow-list and never sourced, and the launch options win over both files.
+gamefix_keys=""
+gamefix_backend=""
+gamefix_dlloverrides=""
+gamefix_msync=""
+gamefix_nvapi=""
+gamefix_dlss_fg=""
+gamefix_args=""
+
+gamefix_log() {
+ echo "gamefix: $*" >> "$log" 2>&1 || true
+}
+
+# Wine syntax: name[,name...]=[n|b|n,b|b,n|d] entries joined by semicolons.
+valid_dll_overrides() {
+ rest=$1
+ [ -n "$rest" ] || return 1
+ while [ -n "$rest" ]; do
+ entry=${rest%%;*}
+ case "$rest" in *';'*) rest=${rest#*;} ;; *) rest="" ;; esac
+ [ -n "$entry" ] || continue
+ case "$entry" in *=*) ;; *) return 1 ;; esac
+ case "${entry%%=*}" in ''|,*|*,|*,,*|*[!A-Za-z0-9_.,+-]*) return 1 ;; esac
+ case "${entry#*=}" in ''|n|b|d|n,b|b,n) ;; *) return 1 ;; esac
+ done
+}
+
+# Prints why a pair is refused, and nothing when it is allowed.
+gamefix_reason() {
+ # shellcheck disable=SC2016 # the patterns match these characters literally
+ case "$2" in
+ *'`'*|*'$('*|*'"'*|*"'"*) echo "a backtick, \$( or a quote in the value"; return 0 ;;
+ *[[:cntrl:]]*) echo "a control character in the value"; return 0 ;;
+ esac
+ if [ "${#2}" -gt 1024 ]; then echo "a value over 1024 characters"; return 0; fi
+ case "$1" in
+ BACKEND)
+ case "$2" in dxmt|dxvk|wined3d|d3dmetal) ;; *) echo "not dxmt, dxvk, wined3d or d3dmetal" ;; esac ;;
+ MSYNC|RETINA|NVAPI|DLSS_FG|STDOUT_NULL|VSYNC|FRAMEGEN_UI|FRAMEGEN_FALLBACK|STEAMDECK)
+ case "$2" in 0|1) ;; *) echo "not 0 or 1" ;; esac ;;
+ FRAMEGEN)
+ # 1 is the 2x of the first release.
+ case "$2" in 0|1|2|3|adaptive) ;; *) echo "not 0, 1, 2, 3 or adaptive" ;; esac ;;
+ FRAMEGEN_QUALITY)
+ case "$2" in performance|balanced|quality) ;; *) echo "not performance, balanced or quality" ;; esac ;;
+ FRAMEGEN_ENGINE)
+ case "$2" in own|metalfx) ;; *) echo "not own or metalfx" ;; esac ;;
+ DLLOVERRIDES)
+ valid_dll_overrides "$2" || echo "not Wine override syntax" ;;
+ ARGS)
+ # Space-separated arguments, each of A-Za-z0-9_+./:=,- only, so none can glob or quote.
+ case "$2" in *[!A-Za-z0-9_+./:=,\ -]*) echo "an argument with characters outside A-Za-z0-9_+./:=,-" ;; esac ;;
+ MTL_HUD_ENABLED|WINEDEBUG|WINE_LARGE_ADDRESS_AWARE|WINE_CPU_TOPOLOGY) ;;
+ ROSETTA_ADVERTISE_AVX)
+ case "$2" in 0|1) ;; *) echo "not 0 or 1" ;; esac ;;
+ DXMT_?*|DXVK_?*|MVK_?*|VKD3D_?*|D3DM_?*|STAGING_?*) ;;
+ *) echo "not on the allow-list" ;;
+ esac
+}
+
+gamefix_read() {
+ [ -f "$1" ] || return 0
+ if [ ! -r "$1" ] || [ "$(stat -f %z "$1" 2>/dev/null || echo 0)" -gt 65536 ]; then
+ gamefix_log "$2 conf $1 is unreadable or over 64 KiB, ignored"
+ return 0
+ fi
+ gamefix_log "reading the $2 conf $1"
+ lineno=0
+ while IFS= read -r line || [ -n "$line" ]; do
+ lineno=$((lineno + 1))
+ while :; do case "$line" in [[:space:]]*) line=${line#?} ;; *) break ;; esac; done
+ while :; do case "$line" in *[[:space:]]) line=${line%?} ;; *) break ;; esac; done
+ case "$line" in ''|'#'*) continue ;; esac
+ key=${line%%=*}
+ case "$line" in
+ [A-Z]*=*) case "$key" in *[!A-Z0-9_]*) key="" ;; esac ;;
+ *) key="" ;;
+ esac
+ if [ -z "$key" ]; then
+ gamefix_log "$2 conf line $lineno rejected: not KEY=VALUE"
+ continue
+ fi
+ value=${line#*=}
+ reason=$(gamefix_reason "$key" "$value")
+ if [ -n "$reason" ]; then
+ gamefix_log "$2 conf line $lineno rejected $key: $reason"
+ continue
+ fi
+ case " $gamefix_keys " in
+ *" $key "*) gamefix_log "$2 conf line $lineno replaces the earlier $key" ;;
+ *) gamefix_keys="${gamefix_keys:+$gamefix_keys }$key" ;;
+ esac
+ # key is [A-Z0-9_] only, so the eval names a variable and copies the value verbatim
+ eval "gamefix_value_$key=\$value gamefix_from_$key=\$2"
+ done < "$1"
+}
+
+gamefix_apply_env() {
+ eval "launch_set=\${$1+x}"
+ if [ -n "$launch_set" ]; then
+ gamefix_log "$1 kept from the launch options, the $3 conf value is not applied"
+ else
+ export "$1=$2"
+ gamefix_log "applied $1=$2 from the $3 conf"
+ fi
+}
+
+load_gamefixes() {
+ case "$app_id" in ''|0) return 0 ;; esac
+ gamefix_read "$np_support/gamefixes/default.conf" global
+ gamefix_read "$np_support/gamefixes-default/$app_id.conf" default
+ gamefix_read "$np_support/gamefixes/$app_id.conf" user
+ for key in $gamefix_keys; do
+ eval "value=\$gamefix_value_$key from=\$gamefix_from_$key"
+ # shellcheck disable=SC2154 # eval assigns from on the line above
+ case "$key" in
+ BACKEND) gamefix_backend=$value; gamefix_log "BACKEND=$value from the $from conf" ;;
+ DLLOVERRIDES) gamefix_dlloverrides=$value
+ gamefix_log "DLLOVERRIDES=$value from the $from conf, launch options still win per DLL" ;;
+ MSYNC) gamefix_msync=$value; gamefix_log "MSYNC=$value from the $from conf" ;;
+ NVAPI) gamefix_nvapi=$value; gamefix_log "NVAPI=$value from the $from conf" ;;
+ DLSS_FG) gamefix_dlss_fg=$value; gamefix_log "DLSS_FG=$value from the $from conf" ;;
+ STDOUT_NULL) gamefix_apply_env NOTPROTON_STDOUT_NULL "$value" "$from" ;;
+ VSYNC) gamefix_apply_env NOTPROTON_VSYNC "$value" "$from" ;;
+ ARGS)
+ if [ "$verb" = waitforexitandrun ]; then
+ gamefix_args=$value
+ gamefix_log "ARGS=$value from the $from conf, added after the launch options' arguments"
+ else
+ gamefix_log "ARGS not applied, $verb is not the game launch"
+ fi ;;
+ RETINA) gamefix_apply_env NOTPROTON_RETINA "$value" "$from" ;;
+ # Steam reads SteamDeck in mixed case, which a conf key cannot spell.
+ STEAMDECK) gamefix_apply_env SteamDeck "$value" "$from" ;;
+ FRAMEGEN|FRAMEGEN_QUALITY|FRAMEGEN_UI|FRAMEGEN_FALLBACK|FRAMEGEN_ENGINE)
+ gamefix_apply_env "NOTPROTON_$key" "$value" "$from" ;;
+ *) gamefix_apply_env "$key" "$value" "$from" ;;
+ esac
+ done
+}
+
+# Launch options > gamefix MSYNC > an engine with msync > the prefix's last choice > off.
+resolve_msync() {
+ msync_from=environment
+ [ -z "$WINEMSYNC" ] || return 0
+ engine_msync=0
+ [ ! -e "$CX_ROOT/.notproton-msync" ] || engine_msync=1
+ case "$gamefix_msync" in
+ 0) WINEMSYNC=0; msync_from=gamefix; return 0 ;;
+ 1)
+ if [ "$engine_msync" -eq 1 ]; then WINEMSYNC=1; msync_from=gamefix; return 0; fi
+ gamefix_log "MSYNC=1 not applied, the engine has no .notproton-msync" ;;
+ esac
+ if [ "$engine_msync" -eq 1 ]; then WINEMSYNC=1; msync_from=engine; return 0; fi
+ if [ -r "$STEAM_COMPAT_DATA_PATH/notproton-msync" ]; then
+ WINEMSYNC=$(tr -d ' \t\n' \
+ < "$STEAM_COMPAT_DATA_PATH/notproton-msync" 2>/dev/null || true)
+ msync_from=carried-over
+ fi
+ [ -n "$WINEMSYNC" ] || msync_from=default
+}
+
+# Graphics backends. The engine keeps Wine's own dxgi/d3d11/d3d10core/d3d12 in lib/wine and
+# ships the alternatives under lib/notproton-backends/<name>/<arch>-windows, which a game
+# gets as natives in its prefix. WineCX with d3dmetal.enabled has Apple's D3DMetal as those
+# builtins instead and defaults to it. An engine without that folder bakes its DLLs into
+# lib/wine, so nothing is swapped there.
+backend_root="$CX_ROOT/lib/notproton-backends"
+backend=""
+backend_from=""
+backend_overrides=""
+
+graphics_log() {
+ echo "graphics: $*" >> "$log" 2>&1 || true
+}
+
+# WineCX with a Game Porting Toolkit linked in: Apple's D3DMetal forwarders are the
+# dxgi/d3d10/d3d11/d3d12 builtins of lib/wine, and Wine's own are set aside in
+# notproton-backends/wine-stock, so wined3d is not there to fall back on.
+d3dmetal_engine() {
+ [ -f "$backend_root/d3dmetal.enabled" ]
+}
+
+# The lower-case module names of the DLLs in one backend folder, winemetal left to lib/wine.
+backend_dlls() {
+ for f in "$1"/*.[dD][lL][lL]; do
+ [ -f "$f" ] || continue
+ name=${f##*/}
+ name=$(printf '%s' "${name%.*}" | tr '[:upper:]' '[:lower:]')
+ case "$name" in ''|*[!a-z0-9_]*|winemetal) continue ;; esac
+ printf '%s\n' "$name"
+ done
+}
+
+# Every DLL some backend ships, so a copy one of them left in the prefix can be overridden.
+managed_dlls() {
+ {
+ printf '%s\n' dxgi d3d11 d3d10core
+ ! d3dmetal_engine || printf '%s\n' d3d10 d3d12
+ for dir in "$backend_root"/*/x86_64-windows "$backend_root"/*/i386-windows; do
+ # nvapi-shim is not a Direct3D backend; its nvapi64 is handled with NVAPI below.
+ case "$dir" in "$backend_root"/wine-stock/*|"$backend_root"/nvapi-shim/*) continue ;; esac
+ [ ! -d "$dir" ] || backend_dlls "$dir"
+ done
+ } | sort -u
+}
+
+backend_available() {
+ case "$1" in
+ wined3d) ! d3dmetal_engine ;;
+ d3dmetal) d3dmetal_engine ;;
+ dxmt|dxvk) [ -n "$(backend_dlls "$backend_root/$1/x86_64-windows")" ] ;;
+ *) return 1 ;;
+ esac
+}
+
+backend_record() {
+ record="$STEAM_COMPAT_DATA_PATH/notproton-backend"
+ [ -n "$STEAM_COMPAT_DATA_PATH" ] && [ -f "$record" ] && [ ! -L "$record" ] || return 1
+ recorded=$(sed -n 1p "$record" 2>/dev/null) || return 1
+ case "$recorded" in
+ dxmt|dxvk|wined3d|d3dmetal|dxmt-builtin) printf '%s' "$recorded" ;;
+ *) return 1 ;;
+ esac
+}
+
+# One little-endian unsigned word of 1, 2 or 4 bytes, inside the file only.
+pe_word() {
+ [ "$2" -ge 0 ] && [ $(($2 + $3)) -le "$pe_size" ] || return 1
+ word=$(od -A n -t "u$3" -j "$2" -N "$3" "$1" 2>/dev/null | tr -d ' \n')
+ case "$word" in ''|*[!0-9]*) return 1 ;; esac
+ printf '%s' "$word"
+}
+
+# Count 4-byte words, all of them inside the file, space-separated.
+pe_words() {
+ [ "$2" -ge 0 ] && [ $(($2 + $3 * 4)) -le "$pe_size" ] || return 1
+ od -A n -v -t u4 -j "$2" -N $(($3 * 4)) "$1" 2>/dev/null | tr -s ' \n' ' '
+}
+
+# The file offset of an RVA, from the section table words in pe_sections.
+pe_rva_offset() {
+ rva=$1
+ # shellcheck disable=SC2086 # the table is a list of numbers and has to split
+ set -- $pe_sections
+ while [ "$#" -ge 10 ]; do
+ span=$3
+ [ "$5" -le "$span" ] || span=$5
+ if [ "$rva" -ge "$4" ] && [ "$rva" -lt $(($4 + span)) ]; then
+ [ $((rva - $4)) -lt "$5" ] || return 1
+ offset=$((rva - $4 + $6))
+ [ "$offset" -lt "$pe_size" ] || return 1
+ printf '%s' "$offset"
+ return 0
+ fi
+ shift 10
+ done
+ return 1
+}
+
+# A game whose exe imports d3d12.dll is D3D12, which needs Wine's own dxgi (vkd3d), since
+# DXMT's dxgi refuses swap chains for devices it did not make. Only the static import
+# table counts, and anything that does not parse as a PE detects nothing.
+imports_d3d12() {
+ pe=$1
+ [ -f "$pe" ] || return 1
+ pe_size=$(stat -f %z "$pe" 2>/dev/null) || return 1
+ [ "$(od -A n -t x1 -N 2 "$pe" 2>/dev/null | tr -d ' \n')" = 4d5a ] || return 1
+ header=$(pe_word "$pe" 60 4) || return 1
+ [ "$(od -A n -t x1 -j "$header" -N 4 "$pe" 2>/dev/null | tr -d ' \n')" = 50450000 ] || return 1
+ section_count=$(pe_word "$pe" $((header + 6)) 2) || return 1
+ optional_size=$(pe_word "$pe" $((header + 20)) 2) || return 1
+ optional=$((header + 24))
+ case "$(pe_word "$pe" "$optional" 2)" in
+ 267) directories=$((optional + 96)) ;;
+ 523) directories=$((optional + 112)) ;;
+ *) return 1 ;;
+ esac
+ directory_count=$(pe_word "$pe" $((directories - 4)) 4) || return 1
+ [ "$directory_count" -ge 2 ] && [ $((directories + 16)) -le $((optional + optional_size)) ] || return 1
+ import_rva=$(pe_word "$pe" $((directories + 8)) 4) || return 1
+ [ "$import_rva" -gt 0 ] && [ "$section_count" -ge 1 ] && [ "$section_count" -le 96 ] || return 1
+ pe_sections=$(pe_words "$pe" $((optional + optional_size)) $((section_count * 10))) || return 1
+ imports=$(pe_rva_offset "$import_rva") || return 1
+ descriptors=$(((pe_size - imports) / 20))
+ [ "$descriptors" -le 512 ] || descriptors=512
+ [ "$descriptors" -ge 1 ] || return 1
+ table=$(pe_words "$pe" "$imports" $((descriptors * 5))) || return 1
+ # shellcheck disable=SC2086 # the table is a list of numbers and has to split
+ set -- $table
+ while [ "$#" -ge 5 ]; do
+ [ "$1$4$5" != 000 ] || return 1
+ if [ "$4" -gt 0 ] && name_at=$(pe_rva_offset "$4"); then
+ module=$(dd if="$pe" bs=1 skip="$name_at" count=16 2>/dev/null \
+ | LC_ALL=C tr '\0' '\n' | head -n 1 | LC_ALL=C tr '[:upper:]' '[:lower:]')
+ [ "$module" != d3d12.dll ] || return 0
+ fi
+ shift 5
+ done
+ return 1
+}
+
+# NOTPROTON_BACKEND > CX_GRAPHICS_BACKEND > gamefix BACKEND > auto-detect > dxmt, then down
+# to what the engine has.
+select_backend() {
+ wanted=""
+ backend_from=""
+ if [ ! -d "$backend_root" ]; then
+ backend=dxmt-builtin
+ backend_from="legacy engine layout, no lib/notproton-backends"
+ if [ -n "${NOTPROTON_BACKEND:-}$gamefix_backend" ]; then
+ graphics_log "requested backend ${NOTPROTON_BACKEND:-$gamefix_backend} ignored, the engine bakes its graphics DLLs into lib/wine"
+ fi
+ return 0
+ fi
+ case "${NOTPROTON_BACKEND:-}" in
+ '') ;;
+ dxmt|dxvk|wined3d|d3dmetal)
+ wanted=$NOTPROTON_BACKEND
+ backend_from="NOTPROTON_BACKEND in the launch options" ;;
+ *) graphics_log "NOTPROTON_BACKEND is not dxmt, dxvk, wined3d or d3dmetal, ignored" ;;
+ esac
+ # The Steam panel's Graphics menu writes CX_GRAPHICS_BACKEND.
+ if [ -z "$wanted" ] && [ -n "${CX_GRAPHICS_BACKEND:-}" ]; then
+ case "$(printf '%s' "$CX_GRAPHICS_BACKEND" | tr '[:upper:]' '[:lower:]')" in
+ d3dmetal) wanted=d3dmetal ;;
+ dxmt) wanted=dxmt ;;
+ dxvk) wanted=dxvk ;;
+ wined3d|opengl|wine) wanted=wined3d ;;
+ *) graphics_log "CX_GRAPHICS_BACKEND is not a backend this engine maps, ignored" ;;
+ esac
+ [ -z "$wanted" ] || backend_from="CX_GRAPHICS_BACKEND in the launch options"
+ fi
+ if [ -z "$wanted" ] && [ -n "$gamefix_backend" ]; then
+ wanted=$gamefix_backend
+ backend_from="BACKEND in the gamefix conf"
+ fi
+ # A helper has no game to inspect, so it keeps what the game last ran with.
+ if [ -z "$wanted" ] && [ "$verb" != waitforexitandrun ] \
+ && recorded=$(backend_record) && [ "$recorded" != dxmt-builtin ]; then
+ wanted=$recorded
+ backend_from="carried over from the last launch"
+ fi
+ # D3DMetal, when the engine has it, runs D3D11 and D3D12 alike and is the default.
+ if [ -z "$wanted" ] && [ "$verb" = waitforexitandrun ] && [ -f "$1" ]; then
+ if imports_d3d12 "$1"; then
+ if d3dmetal_engine; then wanted=d3dmetal; else wanted=wined3d; fi
+ backend_from="auto-detected, the game imports d3d12.dll"
+ elif d3dmetal_engine; then
+ wanted=d3dmetal
+ backend_from="auto-detected, the engine has D3DMetal"
+ else
+ wanted=dxmt
+ backend_from="auto-detected, the game does not import d3d12.dll"
+ fi
+ fi
+ if [ -z "$wanted" ]; then
+ if d3dmetal_engine; then wanted=d3dmetal; else wanted=dxmt; fi
+ backend_from=default
+ fi
+ backend=$wanted
+ while ! backend_available "$backend"; do
+ case "$backend" in
+ d3dmetal) why="no d3dmetal.enabled marker"; next=dxmt ;;
+ dxvk) why="no x86_64 DLLs in notproton-backends/dxvk"; next=dxmt ;;
+ wined3d) why="D3DMetal replaces Wine's Direct3D in this engine"; next=d3dmetal ;;
+ *)
+ why="no x86_64 DLLs in notproton-backends/$backend"
+ if d3dmetal_engine; then next=d3dmetal; else next=wined3d; fi ;;
+ esac
+ graphics_log "$backend is not available ($why), falling back to $next"
+ backend_from="$backend_from, fell back from $backend"
+ backend=$next
+ done
+}
+
+# Returns 0 when the destination already matches or was replaced.
+stage_backend_file() {
+ [ -f "$1" ] && [ ! -d "$2" ] || return 1
+ if [ -f "$2" ] && [ ! -L "$2" ] \
+ && [ "$(stat -f %z "$1" 2>/dev/null)" = "$(stat -f %z "$2" 2>/dev/null)" ] \
+ && cmp -s "$1" "$2"; then
+ return 0
+ fi
+ staging="$2.notproton.$$"
+ rm -f "$staging" 2>/dev/null || true
+ if { cp -c -f "$1" "$staging" 2>/dev/null || cp -f "$1" "$staging" 2>> "$log"; } \
+ && mv -f "$staging" "$2" 2>> "$log"; then
+ graphics_log "staged ${1#"$CX_ROOT/"} as ${2#"$WINEPREFIX/"}"
+ return 0
+ fi
+ rm -f "$staging" 2>/dev/null || true
+ return 1
+}
+
+# A prefix copy identical to some backend's DLL was put there by a launch, so it goes
+# back to Wine's own. Anything else in the prefix is left alone.
+restore_stock_dll() {
+ [ -f "$3" ] && [ ! -L "$3" ] || return 0
+ # Wine's own copy, which D3DMetal moves aside. A link in lib/wine is Apple's and is
+ # never copied into a prefix.
+ stock="$backend_root/wine-stock/$1/$2.dll"
+ [ -f "$stock" ] && [ ! -L "$stock" ] || stock="$CX_ROOT/lib/wine/$1/$2.dll"
+ [ -f "$stock" ] && [ ! -L "$stock" ] || return 0
+ ! cmp -s "$stock" "$3" || return 0
+ for theirs in "$backend_root"/*/"$1"/*.[dD][lL][lL]; do
+ case "$theirs" in "$backend_root"/wine-stock/*|"$backend_root"/nvapi-shim/*) continue ;; esac
+ [ -f "$theirs" ] || continue
+ base=${theirs##*/}
+ [ "$(printf '%s' "${base%.*}" | tr '[:upper:]' '[:lower:]')" = "$2" ] || continue
+ if cmp -s "$theirs" "$3"; then
+ stage_backend_file "$stock" "$3"
+ return
+ fi
+ done
+ return 0
+}
+
+# Copies the chosen backend's DLLs into the prefix and sets them native, and sets every
+# other DLL a backend could have left there builtin.
+activate_backend() {
+ backend_overrides=""
+ [ "$backend" != dxmt-builtin ] || return 0
+ managed=$(managed_dlls)
+ shipped=""
+ case "$backend" in
+ dxmt|dxvk) shipped=$({ backend_dlls "$backend_root/$backend/x86_64-windows"
+ backend_dlls "$backend_root/$backend/i386-windows"; } | sort -u | tr '\n' ' ') ;;
+ esac
+ staging_failed=0
+ for pair in x86_64-windows:system32 i386-windows:syswow64; do
+ arch=${pair%%:*}
+ dir="$WINEPREFIX/drive_c/windows/${pair##*:}"
+ [ -n "$WINEPREFIX" ] && [ -d "$dir" ] || continue
+ ships=""
+ case "$backend" in
+ dxmt|dxvk) ships=$(backend_dlls "$backend_root/$backend/$arch" | tr '\n' ' ') ;;
+ esac
+ for name in $managed; do
+ case " $ships " in
+ *" $name "*)
+ if ! stage_backend_file "$backend_root/$backend/$arch/$name.dll" "$dir/$name.dll"; then
+ graphics_log "could not stage $backend $arch/$name.dll into the prefix"
+ staging_failed=1
+ fi ;;
+ *)
+ restore_stock_dll "$arch" "$name" "$dir/$name.dll" \
+ || graphics_log "could not restore Wine's $arch/$name.dll in the prefix" ;;
+ esac
+ done
+ done
+ if [ "$staging_failed" -eq 1 ]; then
+ if d3dmetal_engine; then next=d3dmetal; else next=wined3d; fi
+ graphics_log "$backend could not be staged, falling back to $next"
+ backend=$next
+ backend_from="$backend_from, fell back after staging failed"
+ activate_backend
+ return
+ fi
+ native=""
+ builtin=""
+ for name in $managed; do
+ case " $shipped " in
+ *" $name "*) native="${native:+$native,}$name" ;;
+ *) builtin="${builtin:+$builtin,}$name" ;;
+ esac
+ done
+ backend_overrides="${native:+$native=n,b}"
+ [ -z "$builtin" ] || backend_overrides="${backend_overrides:+$backend_overrides;}$builtin=b"
+ # A linked Game Porting Toolkit can bring Apple's nvapi64 and nvngx (DLSS on MetalFX) into
+ # lib/wine. An nvapi that answers sends some games down NVIDIA-only paths, so both stay
+ # disabled unless the game's conf says NVAPI=1, and then only on D3DMetal, the only
+ # backend they talk to.
+ if d3dmetal_engine && [ -e "$CX_ROOT/lib/wine/x86_64-windows/nvapi64.dll" ]; then
+ nv_dlls=nvapi64
+ [ ! -e "$CX_ROOT/lib/wine/x86_64-windows/nvngx.dll" ] || nv_dlls="nvapi64,nvngx"
+ if [ "$gamefix_nvapi" = 1 ] && [ "$backend" = d3dmetal ]; then
+ # Apple's nvapi reports driver 561.09, which some games call out of date (Deadlock)
+ # and hide DLSS for. nvapi-shim/ goes in front as a native nvapi64 and reports a newer
+ # driver (NOTPROTON_NVAPI_DRIVER), passing everything else to Apple's nvapi.dll.
+ # The shim reaches Apple's nvapi by its internal name nvapi.dll, which Wine only maps to
+ # the lib/wine builtin when a builtin-marked placeholder of that name is in system32.
+ if stage_backend_file "$CX_ROOT/lib/wine/x86_64-windows/nvapi.dll" \
+ "$WINEPREFIX/drive_c/windows/system32/nvapi.dll" \
+ && stage_backend_file "$backend_root/nvapi-shim/x86_64-windows/nvapi64.dll" \
+ "$WINEPREFIX/drive_c/windows/system32/nvapi64.dll"; then
+ backend_overrides="${backend_overrides:+$backend_overrides;}nvapi64=n,b"
+ nv_dlls=${nv_dlls#nvapi64}
+ nv_dlls=${nv_dlls#,}
+ fi
+ [ -z "$nv_dlls" ] || backend_overrides="${backend_overrides:+$backend_overrides;}$nv_dlls=b"
+ # D3DMetal reports an AMD adapter (0x1002) on its own, and games only offer DLSS on an
+ # NVIDIA one. A D3DM_* value from a conf or the launch options wins.
+ export D3DM_VENDOR_ID="${D3DM_VENDOR_ID:-0x10de}" D3DM_DEVICE_ID="${D3DM_DEVICE_ID:-0x2684}"
+ export D3DM_DEVICE_DESCRIPTION="${D3DM_DEVICE_DESCRIPTION:-NVIDIA GeForce RTX 4090}"
+ # Streamline loads an NGX core only when it is NVIDIA-signed; the engine's crypt32 and
+ # wintrust answer for Apple's bridge from a signed Streamline module (ngx-signer-patch/).
+ export NOTPROTON_NGX_SIGNER=1
+ # wined3d (wined3d-patch/) reports this instead of its table's GeForce 8 era 31.0.13.4052,
+ # which games read through d3d9 (Deadlock: driver warning, no async shader creation).
+ export NOTPROTON_DRIVER_VERSION="${NOTPROTON_DRIVER_VERSION:-32.0.15.9541}"
+ # DLSS frame generation wants hardware GPU scheduling; winecx's win32u reports it on
+ # only for CX_ACTIVE_GRAPHICS_BACKEND=d3dmetal (CW HACK 24905). Opt-in: frank Whisky
+ # #231 saw MetalFX frame interpolation on an M5 with D3DMetal 4.0b2 hang WindowServer.
+ if [ "$gamefix_dlss_fg" = 1 ]; then
+ export CX_ACTIVE_GRAPHICS_BACKEND=d3dmetal
+ graphics_log "DLSS_FG=1: hardware GPU scheduling reported on for DLSS frame generation"
+ fi
+ graphics_log "NVAPI=1: $nv_dlls on, adapter $D3DM_VENDOR_ID:$D3DM_DEVICE_ID ($D3DM_DEVICE_DESCRIPTION)"
+ else
+ [ "$gamefix_nvapi" != 1 ] || graphics_log "NVAPI=1 not applied, $backend is not d3dmetal"
+ backend_overrides="${backend_overrides:+$backend_overrides;}$nv_dlls=d"
+ fi
+ fi
+ if [ "$backend" = d3dmetal ]; then
+ if [ -n "${CX_GRAPHICS_BACKEND:-}" ] && [ "$CX_GRAPHICS_BACKEND" != d3dmetal ]; then
+ graphics_log "CX_GRAPHICS_BACKEND=$CX_GRAPHICS_BACKEND replaced by d3dmetal"
+ fi
+ export CX_GRAPHICS_BACKEND=d3dmetal
+ fi
+}
+
+record_backend() {
+ [ -n "$STEAM_COMPAT_DATA_PATH" ] || return 0
+ record="$STEAM_COMPAT_DATA_PATH/notproton-backend"
+ [ ! -L "$record" ] || return 0
+ previous=$(backend_record) || previous=""
+ if [ -n "$previous" ] && [ "$previous" != "$backend" ]; then
+ graphics_log "backend switched from $previous to $backend"
+ fi
+ if ! { printf '%s\n%s\n' "$backend" "$backend_from" > "$record.new" \
+ && mv -f "$record.new" "$record"; } 2>/dev/null; then
+ rm -f "$record.new" 2>/dev/null || true
+ graphics_log "could not record the backend in $record"
+ fi
+}
+
+# Last entry wins: backend, then the gamefix conf, then the launch options.
+compose_dll_overrides() {
+ composed=$backend_overrides
+ for part in "$gamefix_dlloverrides" "${WINEDLLOVERRIDES:-}"; do
+ [ -n "$part" ] || continue
+ composed="${composed:+$composed;}$part"
+ done
+ [ -z "$composed" ] || export WINEDLLOVERRIDES="$composed"
+}
+
+load_gamefixes || true
+
+ # Steam gives every non-Steam shortcut a game ID ending in 0x02000000.
+ shortcut_game_id() {
+ case "$1" in ''|*[!0-9]*) return 1 ;; esac
+ [ "${#1}" -le 20 ] || return 1
+ high=0
+ low="$1"
+ if [ "${#1}" -gt 10 ]; then
+ high="${1%??????????}"
+ low="${1#"$high"}"
+ fi
+ high="${high#"${high%%[!0]*}"}"
+ low="${low#"${low%%[!0]*}"}"
+ [ $(( (${high:-0} % 4294967296 * 1410065408 + ${low:-0}) % 4294967296 )) = 33554432 ]
+ }
+
# Steam does not set SteamAppId or SteamGameId for helpers like the install-script
# evaluator. If they are set, SteamAPI_Init registers the helper as the running game so the
# real launch fails with AppError_16. Not applicable to non-Steam shortcuts, which come in
diff --cc dylib/feats/webpatch.c
index 4a60323,4f40bed..5f20142
--- a/dylib/feats/webpatch.c
+++ b/dylib/feats/webpatch.c
@@@ -1,9 -1,8 +1,10 @@@
// Enables Steam Play in the UI/enables the Compatibility tab in game properties
#include "webpatch.h"
+ #include "nativeplatform.h"
#include "../util/log.h"
+#include <dirent.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@@ -265,62 -297,11 +302,62 @@@ static int out_expand(np_out_t *o, cons
ARG "=>{" \
"const t=" ARG ".details,o=t.strLaunchOptions||\"\"," \
"fex=" NP_FEX_TOOLS ".indexOf(t.strCompatToolName||\"" NP_FALLBACK_TOOL "\")>=0," \
- "npZh=" NP_WEB_IS_ZH ",npL=(en,zh)=>npZh?zh:en," \
- "npZh=" NP_WEB_IS_ZH ",npIt=" NP_WEB_IS_IT ",npL=(en,zh,it)=>npZh?zh:npIt?it:en," \
- "L=MSCXLaunch(o,t.unAppID),g=L.g,s=L.s," \
++ "npZh=" NP_WEB_IS_ZH ",npIt=" NP_WEB_IS_IT ",npL=(en,zh,it)=>npZh?zh:npIt&&it?it:en," \
+ NP_CX_LAUNCH_PARSE \
+ "nat=t.unAppID<2147483648&&(t.vecPlatforms||[]).indexOf(\"osx\")>=0&&!t.strCompatToolName," \
+ "wv=w=>w.value===null?o.slice(w.start,w.end):w.value," \
+ "NE=E.c<0?[]:E.G.slice(0,E.c).filter(w=>/^[A-Za-z_]\\w*=/.test(wv(w)))," \
+ "A=k=>(nat?NE.filter(w=>wv(w).startsWith(k+\"=\")):E.e.filter(w=>o.startsWith(k+\"=\",w.start))).pop()," \
+ "g=k=>{const p=A(k);return p?wv(p).slice(k.length+1):\"\"}," \
+ "qv=v=>/^[\\w.,:=\\/+@%-]*$/.test(v)?v:\"'\"+v.replace(/'/g,\"'\\\\''\")+\"'\"," \
+ "sl=ps=>{const add=ps.filter(p=>p[1]).map(p=>p[0]+\"=\"+qv(p[1])).join(\" \");let r;" \
+ "if(!/%command%/i.test(o)){if(!add)return;r=add+\" %command%\"+(o.trim()?\" \"+o:\"\")}" \
+ "else{let at=E.p;r=o.slice(0,at)+(add?add+\" \":\"\");" \
+ "E.e.forEach(w=>{if(ps.some(p=>o.startsWith(p[0]+\"=\",w.start))){" \
+ "r+=o.slice(at,w.start);at=w.end;while(o[at]===\" \"||o[at]===\"\\t\")at++}});r+=o.slice(at)}" \
+ "SteamClient.Apps.SetAppLaunchOptions(t.unAppID,r.trim()===\"%command%\"?\"\":r)}," \
+ /* Native games run through np-native, which also forces arm64: <launcher> VAR=VALUE ... \
+ %command% <game args>. Assignments are read from any word before %command%, so the \
+ older "/usr/bin/arch ... -e VAR=VALUE" form is understood, and rewritten without the \
+ arch prefix and its DYLD_INSERT_LIBRARIES. */ \
+ "sn=ps=>{const c=E.c<0?null:E.G[E.c]," \
+ "L=Fx.h?Fx.h+\"/.notproton/np-native\":(c&&E.G.slice(0,E.c).map(wv)" \
+ ".find(x=>/\\/\\.notproton\\/np-native$/.test(x)))||\"\";" \
+ "if(!L||!c&&!ps.some(p=>p[1]))return;" \
+ "const kn=w=>{const x=wv(w);return x.slice(0,x.indexOf(\"=\"))};" \
+ "let vs=NE.filter(w=>kn(w)!==\"DYLD_INSERT_LIBRARIES\").map(w=>[kn(w),o.slice(w.start,w.end)]);" \
+ "ps.forEach(p=>{const i=vs.findIndex(x=>x[0]===p[0]);vs=vs.filter(x=>x[0]!==p[0]);" \
+ "if(p[1])vs.splice(i<0?vs.length:i,0,[p[0],p[0]+\"=\"+qv(p[1])])});" \
+ "const h=[qv(L)].concat(vs.map(x=>x[1])).join(\" \");" \
+ "SteamClient.Apps.SetAppLaunchOptions(t.unAppID," \
+ "c?o.slice(0,E.p)+h+\" \"+o.slice(c.start):h+\" %command%\"+(o.trim()?\" \"+o.trim():\"\"))}," \
+ "s=ps=>nat?sn(ps):sl(ps)," \
+ "Fx=globalThis.MSCXFx||{}," \
+ "dv=k=>{if(nat){const a=(Fx.na||{})[t.unAppID]||{},n=Fx.ng||{};" \
+ "return k in a?a[k]:k in n?n[k]:(Fx.d||{})[k]||\"\"}" \
+ "const a=(Fx.a||{})[t.unAppID]||{},en=Fx.e||{},x=en[t.strCompatToolName]||en[\"\"]||{};" \
+ "return k in a?a[k]:k in(Fx.g||{})?Fx.g[k]:k in x?x[k]:(Fx.d||{})[k]||\"\"}," \
+ "ev=k=>A(k)?g(k):dv(k)," \
"T=(ks,l,on,off)=>(0," RT ".jsx)(" BARREL ".Yh,{className:\"MSCXRow\",label:l," \
- "checked:g(ks[0])===on," \
- "onChange:v=>s(ks.map(k=>[k,v?on:(off||\"\")]))},ks[0])," \
+ "checked:ev(ks[0])===on," \
+ "onChange:v=>s(ks.map(k=>[k,v?(dv(k)===on?\"\":on):(dv(k)===on?(off||\"0\"):\"\")]))},ks[0])," \
+ /* A labelled dropdown: its label above it, full width, without a row box around it, \
+ like the section dropdowns. n turns a raw value, set or not, into an option's data, so \
+ picking what the confs already give drops the argument instead of writing it. */ \
+ "D=(k,l,O,n)=>(0," RT ".jsx)(" BARREL ".m,{label:l,strClassName:\"MSCXDrop\",rgOptions:O," \
+ "selectedOption:n(ev(k)),onChange:v=>s([[k,v.data===n(dv(k))?\"\":v.data]])},k)," \
+ "lc=z=>x=>(x||z).toLowerCase()," \
+ "fz=x=>{x=(x||\"\").toLowerCase();return x===\"1\"?\"2\":/^(0|off|false|no)?$/.test(x)?\"0\":x}," \
+ "fo=fz(ev(\"NOTPROTON_FRAMEGEN\"))!==\"0\"," \
+ "FG=()=>(0," RT ".jsxs)(" BARREL ".XY,{label:\"Frame Generation (Experimental. Adds input lag)\",children:[" \
+ "D(\"NOTPROTON_FRAMEGEN\",\"Mode\",[{data:\"0\",label:\"Off\"},{data:\"2\",label:\"2x\"}," \
+ "{data:\"3\",label:\"3x\"},{data:\"adaptive\",label:\"Adaptive (fills to display refresh)\"}],fz)," \
+ "fo&&D(\"NOTPROTON_FRAMEGEN_QUALITY\",\"Quality\",[{data:\"performance\",label:\"Performance\"}," \
+ "{data:\"balanced\",label:\"Balanced\"},{data:\"quality\",label:\"Quality\"}],lc(\"balanced\"))," \
+ "fo&&T([\"NOTPROTON_FRAMEGEN_UI\"],\"Protect UI (keeps static HUD and menus sharp)\",\"1\",\"0\")," \
+ "fo&&T([\"NOTPROTON_FRAMEGEN_FALLBACK\"],\"Fast-motion fallback (skips frames that would smear)\",\"1\",\"0\")," \
+ "fo&&D(\"NOTPROTON_FRAMEGEN_ENGINE\",\"Engine\",[{data:\"own\",label:\"Built-in optical flow\"}," \
+ "{data:\"metalfx\",label:\"MetalFX\"}],lc(\"own\"))]},\"fgn\")," \
"bv=g(\"CX_GRAPHICS_BACKEND\"),b=fex&&\"d3dmetal\"===bv?\"\":bv," \
"dm=!fex&&(\"\"===b||\"d3dmetal\"===b)," \
"dx=\"\"===b||\"dxmt\"===b," \
@@@ -341,16 -322,11 +378,16 @@@
"{data:\"dxmt\",label:\"DXMT\"}," \
"{data:\"dxvk\",label:\"DXVK\"}," \
"{data:\"wined3d\",label:\"WineD3D\"}].filter(x=>!fex||x.data!==\"d3dmetal\");" \
- "if(t.unAppID<2147483648&&(t.vecPlatforms||[]).indexOf(\"osx\")>=0" \
- "&&!t.strCompatToolName)return null;" \
+ "if(nat)return(0," RT ".jsx)(\"div\",{className:\"MSCXPanel\",children:(0," RT ".jsxs)(" RT ".Fragment,{children:[" \
+ "(0," RT ".jsx)(\"style\",{children:" NP_CX_OPTIONS_CSS "})," \
+ "T([\"MTL_HUD_ENABLED\"],\"Metal HUD\",\"1\"),FG()," \
+ "(0," RT ".jsx)(" BARREL ".XY,{label:\"Controllers\",children:" \
+ "D(\"NP_PAD_MODE\",\"Controller layer\",[{data:\"\",label:\"Automatic\"},{data:\"hid\",label:\"Raw HID (Unity, SDL, Unreal)\"}," \
+ "{data:\"gc\",label:\"GameController\"},{data:\"off\",label:\"Off\"}],lc(\"\"))},\"ctl\")" \
+ "]})});" \
"return(0," RT ".jsx)(\"div\",{className:\"MSCXPanel\",children:(0," RT ".jsxs)(" RT ".Fragment,{children:[" \
"(0," RT ".jsx)(\"style\",{children:" NP_CX_OPTIONS_CSS "})," \
- "(0," RT ".jsxs)(" BARREL ".XY,{label:npL(\"Graphics\",\"图形\"),children:[" \
+ "(0," RT ".jsxs)(" BARREL ".XY,{label:npL(\"Graphics\",\"图形\",\"Grafica\"),children:[" \
"(0," RT ".jsx)(" BARREL ".m,{rgOptions:B,selectedOption:b," \
"onChange:v=>s([[\"CX_GRAPHICS_BACKEND\",v.data]]" \
".concat(\"\"===v.data||\"d3dmetal\"===v.data?[]:[[\"D3DM_ENABLE_METALFX\",\"\"]])" \
@@@ -370,11 -346,10 +407,11 @@@
"children:(0," RT ".jsx)(" BARREL ".m,{rgOptions:U," \
"selectedOption:sw?(U.find(u=>u.data&&+u.data===fn)||{data:String(fn)}).data:\"\"," \
"onChange:v=>s([[\"DXMT_METALFX_SPATIAL_SWAPCHAIN\",v.data?\"1\":\"\"],[\"DXMT_CONFIG\",fx(v.data)]])})},\"usf\")," \
+ "FG()," \
"(0," RT ".jsx)(" BARREL ".XY,{label:npL(\"Controllers (May break Steam Input. Not recommended)\"," \
- "\"控制器(可能导致 Steam Input 失效,不推荐)\"),children:" \
+ "\"控制器(可能导致 Steam Input 失效,不推荐)\",\"Controller (pu\\u00f2 interferire con Steam Input, sconsigliato)\"),children:" \
"T([\"NOTPROTON_RAW_CONTROLLERS\"],npL(\"Let games read controllers directly\"," \
- "\"允许游戏直接读取控制器\"),\"1\",\"\")},\"ctl\")" \
+ "\"允许游戏直接读取控制器\",\"Lascia che i giochi leggano direttamente i controller\"),\"1\",\"\")},\"ctl\")" \
"]})})}"
#define NP_CX_OPTIONS_CAPTURE(RT, BARREL) \
diff --cc dylib/version.h
index c24c880,42183e9..c853aad
--- a/dylib/version.h
+++ b/dylib/version.h
@@@ -2,6 -2,6 +2,6 @@@
#ifndef NOTPROTON_VERSION_H
#define NOTPROTON_VERSION_H
- #define NOTPROTON_VERSION "1.1.9-winehq.1-ray.30"
-#define NOTPROTON_VERSION "1.1.9"
++#define NOTPROTON_VERSION "1.1.9-winehq.1-ray.31"
#endif // NOTPROTON_VERSION_H
diff --cc overlay-shim/overlay_shim.m
index 523e783,0c62301..d88753a
--- a/overlay-shim/overlay_shim.m
+++ b/overlay-shim/overlay_shim.m
@@@ -264,10 -258,7 +280,10 @@@ static int stage_claimed(Class seen, Cl
return 1;
}
+// Frame generation (NOTPROTON_FRAMEGEN=1), one translation unit with the shim
+#include "framegen.m"
+
- static void encoder_mark(id encoder, NSUInteger format)
+ static void encoder_mark(id encoder, NSUInteger format, id<MTLCommandBuffer> buffer)
{
os_unfair_lock_lock(&encoder_lock);
for (int i = 0; i < max_encoders; i++) {
@@@ -497,16 -496,8 +533,9 @@@ static id hook_render_encoder(id self,
NSUInteger format = attachment.pixelFormat;
- encoder_mark(encoder, format);
+ encoder_mark(encoder, format, self);
+ framegen_note_render_pass(self, attachment);
- if (!overlay_pass)
- return encoder;
- for (int i = 0; i < pipeline_count; i++) {
- if (pipelines[i].base_format != format)
- variant_for(&pipelines[i], format);
- }
-
return encoder;
}
static void hook_set_pipeline_state(id self, SEL selector, id state)