Skip to content

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

Add a toggle for reduced x87 precision

NotProtonNot0fad001c150c
diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.sh
index 3e9ce37..ffa11c2 100755
--- a/dylib/feats/compat_run.sh
+++ b/dylib/feats/compat_run.sh
@@ -182,6 +182,8 @@ if [ "${wine_unix##*/}" = aarch64-unix ]; then
unset -v "$name"
np_dropped="$np_dropped${np_dropped:+ }$name"
done
+ fex_from=environment
+ [ -n "${FEX_X87REDUCEDPRECISION+x}" ] || fex_from=default
export FEX_X87REDUCEDPRECISION="${FEX_X87REDUCEDPRECISION-1}"
fi
@@ -1173,6 +1175,8 @@ if [ -n "$STEAM_COMPAT_DATA_PATH" ]; then
refuse_foreign_prefix
claim_prefix
echo "sync: WINEMSYNC=$WINEMSYNC from $msync_from" >> "$log" 2>&1 || true
+ [ "${wine_unix##*/}" != aarch64-unix ] \
+ || echo "fex: FEX_X87REDUCEDPRECISION=$FEX_X87REDUCEDPRECISION from $fex_from" >> "$log" 2>&1 || true
without_lock_fds "$WINESERVER" -k >> "$log" 2>&1 || true
stage_step="prefix seed"
seed_prefix_from_template
diff --git a/dylib/feats/webpatch.c b/dylib/feats/webpatch.c
index da883dd..98c82a1 100644
--- a/dylib/feats/webpatch.c
+++ b/dylib/feats/webpatch.c
@@ -351,7 +351,12 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {
"\"允许游戏直接读取控制器(可能导致 Steam Input 失效,不推荐)\"," \
"\"Lascia che i giochi leggano direttamente i controller (pu\\u00f2 interferire con Steam Input, sconsigliato)\"),\"1\",\"\")," \
"T([\"NOTPROTON_DISABLE_HIDRAW\"],npL(\"Disable hidraw\",\"停用 hidraw\",\"Disable hidraw\"),\"1\",\"\")" \
- "]},\"ctl\")" \
+ "]},\"ctl\")," \
+ "fex&&(0," RT ".jsx)(" BARREL ".XY,{label:\"FEX\"," \
+ "children:(0," RT ".jsx)(" BARREL ".Yh,{className:\"MSCXRow\"," \
+ "label:\"Reduced x87 precision (Reducing precision improves game performance, is enabled by default in CrossOver Preview)\"," \
+ "checked:\"0\"!==g(\"FEX_X87REDUCEDPRECISION\")," \
+ "onChange:v=>s([[\"FEX_X87REDUCEDPRECISION\",v?\"\":\"0\"]])},\"FEX_X87REDUCEDPRECISION\")},\"fex\")" \
"]})})}"
#define NP_CX_OPTIONS_CAPTURE(RT, BARREL) \
diff --git a/dylib/tests/envcheck.sh b/dylib/tests/envcheck.sh
index 1e74d2b..fa486ab 100755
--- a/dylib/tests/envcheck.sh
+++ b/dylib/tests/envcheck.sh
@@ -132,10 +132,12 @@ is "x86_64 Wine leaves it unset" "unset" "${FEX_X87REDUCEDPRECISION-unset}"
wine_unix="/R R/lib/wine/aarch64-unix"
eval "$drop"
is "arm64 Wine turns it on" "1" "$FEX_X87REDUCEDPRECISION"
+is "the default is logged as the default" "default" "$fex_from"
is "helpers inherit it" "1" "$(sh -c 'printf %s "$FEX_X87REDUCEDPRECISION"')"
FEX_X87REDUCEDPRECISION=0
eval "$drop"
is "a launch option of 0 is kept" "0" "$FEX_X87REDUCEDPRECISION"
+is "a launch option is logged as one" "environment" "$fex_from"
FEX_X87REDUCEDPRECISION=
eval "$drop"
is "an empty launch option is kept" "" "$FEX_X87REDUCEDPRECISION"
diff --git a/dylib/tests/panel-behavior/fex.js b/dylib/tests/panel-behavior/fex.js
index 74a5efd..b28ad18 100644
--- a/dylib/tests/panel-behavior/fex.js
+++ b/dylib/tests/panel-behavior/fex.js
@@ -7,6 +7,7 @@ const emit = process.argv[2];
if (!emit) { console.error('usage: fex.js <emit>'); process.exit(2); }
const AVX = 'Advertise AVX2 to Rosetta';
+const X87 = 'Reduced x87 precision (Reducing precision improves game performance, is enabled by default in CrossOver Preview)';
// The hook passes only FEX tools; notproton-rosetta stands for a Rosetta tool next to it.
const FEX_TOOLS = ['notproton-fex'];
@@ -26,6 +27,23 @@ for (const form of Object.keys(FORMS)) {
t.ok(backends(r).includes('d3dmetal') === !fex,
`D3DMetal is ${fex ? 'not ' : ''}offered (${backends(r)})`);
t.ok(toggles(r).includes(AVX) === !fex, `the AVX2 row is ${fex ? 'hidden' : 'shown'}`);
+ t.ok(toggles(r).includes(X87) === fex, `the x87 row is ${fex ? 'shown' : 'hidden'}`);
+ t.ok(r.some(x => x.type === 'Section' && x.props.label === 'FEX') === fex,
+ `the FEX section is ${fex ? 'shown' : 'hidden'}`);
+ if (fex) {
+ const x87 = ns => ns.find(x => x.type === 'Toggle' && x.props.label === X87);
+ t.ok(x87(r).props.checked === true, 'the x87 row is on by default');
+ written.length = 0;
+ x87(r).props.onChange(false);
+ t.ok(written[written.length - 1].opts.includes('FEX_X87REDUCEDPRECISION=0'),
+ `turning the x87 row off writes 0 (${written[written.length - 1].opts})`);
+ const off = nodes('FEX_X87REDUCEDPRECISION=0');
+ t.ok(x87(off).props.checked === false, 'a game set to 0 shows the x87 row off');
+ written.length = 0;
+ x87(off).props.onChange(true);
+ t.ok(!written[written.length - 1].opts.includes('FEX_X87REDUCEDPRECISION'),
+ `turning the x87 row on removes the entry (${written[written.length - 1].opts})`);
+ }
t.ok(toggles(r).includes('DLSS') === !fex,
`automatic ${fex ? 'hides' : 'shows'} the D3DMetal DLSS row`);
@@ -88,9 +106,9 @@ for (const form of Object.keys(FORMS)) {
return written.length ? written[written.length - 1].opts : null;
};
const all = 'WINEDEBUG=-all CX_GRAPHICS_BACKEND=d3dmetal D3DM_ENABLE_METALFX=1 MTL_HUD_ENABLED=1 ' +
- "ROSETTA_ADVERTISE_AVX=0 DXMT_CONFIG='a;b' %command% -novid";
+ "ROSETTA_ADVERTISE_AVX=0 FEX_X87REDUCEDPRECISION=0 DXMT_CONFIG='a;b' %command% -novid";
const r = choose(all, 'notproton-fex');
- t.ok(r === "WINEDEBUG=-all MTL_HUD_ENABLED=1 DXMT_CONFIG='a;b' %command% -novid",
+ t.ok(r === "WINEDEBUG=-all MTL_HUD_ENABLED=1 FEX_X87REDUCEDPRECISION=0 DXMT_CONFIG='a;b' %command% -novid",
`picking FEX drops only the D3DMetal and Rosetta entries (${r})`);
t.ok(choose(all, 'notproton-rosetta') === null, 'picking a Rosetta tool writes nothing');
t.ok(choose('D3DM_lower=1 %command%', 'notproton-fex') === null,