Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
Ignore D3DMetal settings on FEX
NotProtonNot787370f4c20e
diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex 0a6149b..84d1e7d 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -172,6 +172,18 @@ if [ "$np_flavor" = rosetta ] || [ ! -x "$WINELOADER" ] || [ ! -x "$WINESERVER"fiexport WINELOADER WINESERVER+np_dropped=""+if [ "${wine_unix##*/}" = aarch64-unix ]; then+ if [ "${CX_GRAPHICS_BACKEND:-}" = d3dmetal ]; then+ unset -v CX_GRAPHICS_BACKEND+ np_dropped="CX_GRAPHICS_BACKEND=d3dmetal"+ fi+ for name in $(env | LC_ALL=C sed -nE 's/^(D3DM_[A-Z0-9_]*|ROSETTA_ADVERTISE_AVX)=.*/\1/p' | LC_ALL=C sort); do+ unset -v "$name"+ np_dropped="$np_dropped${np_dropped:+ }$name"+ done+fi+# Keeps Wine from inheriting the prefix and template locks (fd 8 and 9).without_lock_fds() {"$@" 8>&- 9>&-@@ -198,6 +210,7 @@ fiecho "STEAM_COMPAT_APP_ID=$STEAM_COMPAT_APP_ID"echo "-- steam env passed through --"env | grep -iE '^(Steam|SDL_)' | sort+ [ -z "$np_dropped" ] || echo "ignored on arm64 Wine: $np_dropped"} >> "$log" 2>&1 || truestage_step="startup"@@ -1501,7 +1514,7 @@ elseecho "=== client staged no overlay renderer, overlay disabled ===" >> "$log" 2>&1 || truefiset -- --args "$shim_exe" "$@"-for name in $(env | sed -nE 's/^(CX_APPLEGPTK_LIBD3DSHARED_PATH|Steam[A-Za-z0-9]*|(CX_GRAPHICS|D3DM_|DXMT_|DXVK_|MTL_|ROSETTA_)[A-Z0-9_]*)=.*/\1/p'); do+for name in $(env | LC_ALL=C sed -nE 's/^(CX_APPLEGPTK_LIBD3DSHARED_PATH|Steam[A-Za-z0-9]*|(CX_GRAPHICS|D3DM_|DXMT_|DXVK_|MTL_|ROSETTA_)[A-Z0-9_]*)=.*/\1/p'); doeval "value=\$$name"# shellcheck disable=SC2154 # eval assigns value on the line aboveset -- --env "$name=$value" "$@"diff --git a/dylib/feats/webpatch.c b/dylib/feats/webpatch.cindex d5b8180..dfa31fc 100644--- a/dylib/feats/webpatch.c+++ b/dylib/feats/webpatch.c@@ -192,6 +192,28 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {"const n=G.findIndex(w=>m(w)||!/^[A-Za-z_]\\w*=/.test(o.slice(w.start,w.end)));" \"return{p:G[0].start,e:G.slice(0,n<0?G.length:n)}})(),"+// Rewrites KEY=value entries before %command% and leaves the rest of the text byte for byte.+#define NP_CX_LAUNCH \+ "(o,id)=>{const " NP_CX_LAUNCH_PARSE \+ "g=k=>{const p=E.e.filter(w=>o.startsWith(k+\"=\",w.start)).pop();" \+ "return p?(p.value===null?o.slice(p.start+k.length+1,p.end):p.value.slice(k.length+1)):\"\"}," \+ "qv=v=>/^[\\w.,:=\\/+@%-]*$/.test(v)?v:\"'\"+v.replace(/'/g,\"'\\\\''\")+\"'\"," \+ "s=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(id,r.trim()===\"%command%\"?\"\":r)};" \+ "return{g,s,k:E.e.map(w=>o.slice(w.start,w.end).split(\"=\")[0])}}"++#define NP_CX_PICK \+ "(t,n)=>{const o=t.strLaunchOptions||\"\";" \+ "if(" NP_FEX_TOOLS ".indexOf(n)<0||/[<>\\n]|\\$'/.test(o))return;" \+ "const L=MSCXLaunch(o,t.unAppID)," \+ "ks=L.k.filter(k=>/^D3DM_[A-Z0-9_]*$/.test(k)||k===\"ROSETTA_ADVERTISE_AVX\"" \+ "||k===\"CX_GRAPHICS_BACKEND\"&&L.g(k)===\"d3dmetal\");" \+ "ks.length&&L.s(ks.map(k=>[k,\"\"]))}"+// CrossOver options panel. Not in great shape, but it'll do#define NP_WEB_IS_ZH \"(()=>{const l=(globalThis.document?.documentElement?.lang||" \@@ -212,33 +234,19 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {".MSCXPanel .MSCXRow{display:flex;flex-direction:row;padding:9px;margin:0;" \"color:#dfe3e6;background:rgba(59,63,72,.5);border-radius:3px}" \".MSCXPanel .MSCXRow:hover{box-shadow:0 6px 8px 0 rgba(0,0,0,.16)}" \- ".MSCXPanel .MSCXNote{padding:6px 2px 0;color:#ffc82c;font-size:13px}" \".MSCXNoBottomGap{margin-bottom:0}\""-// The FEX build runs arm64 Wine, so D3DMetal (x86_64 only) and its DLSS flag cannot-// load, and Rosetta, which reads ROSETTA_ADVERTISE_AVX, never runs. A game already set-// to D3DMetal keeps the entry and a note, so the page does not claim a backend the game-// is not getting.+// FEX runs arm64 Wine, which has no D3DMetal and never runs under Rosetta.#define NP_CX_OPTIONS_BODY(ARG, RT, BARREL) \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," \- NP_CX_LAUNCH_PARSE \- "g=k=>{const p=E.e.filter(w=>o.startsWith(k+\"=\",w.start)).pop();" \- "return p?(p.value===null?o.slice(p.start+k.length+1,p.end):p.value.slice(k.length+1)):\"\"}," \- "qv=v=>/^[\\w.,:=\\/+@%-]*$/.test(v)?v:\"'\"+v.replace(/'/g,\"'\\\\''\")+\"'\"," \- "s=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)}," \+ "L=MSCXLaunch(o,t.unAppID),g=L.g,s=L.s," \"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])," \- "b=g(\"CX_GRAPHICS_BACKEND\")," \- "dk=fex&&\"d3dmetal\"===b," \+ "bv=g(\"CX_GRAPHICS_BACKEND\"),b=fex&&\"d3dmetal\"===bv?\"\":bv," \"dm=!fex&&(\"\"===b||\"d3dmetal\"===b)," \"dx=\"\"===b||\"dxmt\"===b," \"sw=\"1\"===g(\"DXMT_METALFX_SPATIAL_SWAPCHAIN\")," \@@ -257,7 +265,7 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {"{data:\"d3dmetal\",label:\"D3DMetal\"}," \"{data:\"dxmt\",label:\"DXMT\"}," \"{data:\"dxvk\",label:\"DXVK\"}," \- "{data:\"wined3d\",label:\"WineD3D\"}].filter(x=>!fex||dk||x.data!==\"d3dmetal\");" \+ "{data:\"wined3d\",label:\"WineD3D\"}].filter(x=>!fex||x.data!==\"d3dmetal\");" \"if(t.unAppID<2147483648&&(t.vecPlatforms||[]).indexOf(\"osx\")>=0" \"&&!t.strCompatToolName)return null;" \"return(0," RT ".jsx)(\"div\",{className:\"MSCXPanel\",children:(0," RT ".jsxs)(" RT ".Fragment,{children:[" \@@ -269,10 +277,6 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {".concat(\"\"===v.data||\"dxmt\"===v.data?[]:" \"[[\"DXMT_METALFX_SPATIAL_SWAPCHAIN\",\"\"],[\"DXMT_CONFIG\",fx(\"\")]])" \".concat(\"dxmt\"===v.data?[]:[[\"DXMT_ENABLE_NVEXT\",\"\"]]))})," \- "dk&&(0," RT ".jsx)(\"div\",{className:\"MSCXNote\"," \- "children:npL(\"D3DMetal needs the Rosetta build of CrossOver. On the FEX build, " \- "this game runs on another backend.\",\"D3DMetal 需要 Rosetta 版 CrossOver。" \- "在 FEX 版中,此游戏会使用其他图形后端。\")},\"fexnote\")," \"T([\"MTL_HUD_ENABLED\"],npL(\"Metal HUD\",\"Metal 性能监视器\"),\"1\")," \"dm&&T([\"D3DM_ENABLE_METALFX\"],\"DLSS\",\"1\")," \"\"dxmt\"===b&&T([\"DXMT_ENABLE_NVEXT\"],\"DLSS\",\"1\")," \@@ -293,10 +297,12 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {"]})})}"#define NP_CX_OPTIONS_COMPONENT \+ "MSCXLaunch=" NP_CX_LAUNCH ",MSCXPick=" NP_CX_PICK "," \"MSCXOpts=" NP_CX_OPTIONS_BODY("e", "i", "c") ","// Valve is testing a new compatibility page UI, this logic relates to supporting that#define NP_CX_OPTIONS_STATEMENT \+ "var MSCXLaunch=" NP_CX_LAUNCH ";" \"var MSCXOpts=" NP_CX_OPTIONS_BODY("np", NP_C3, NP_C4) ";"// 1.0.x saved CrossOver settings without %command%, this migrates them.@@ -346,8 +352,8 @@ static const np_gate_t g_gates_forcetool[] = {"return(0,i.jsxs)(i.Fragment,{children:[0!=a.length&&(0,i.jsx)(_r,{label:(0,A.we)""(\"#AppProperties_CompatilibityForceTool\"),checked:g,onChange:C,disabled:!r||0===a.length}),""g&&a.length>0&&(0,i.jsx)(c.m,{strClassName:K().TopGap+\" MSCXNoBottomGap\",rgOptions:d,"- "selectedOption:t.strCompatToolName,onChange:e=>SteamClient.Apps.SpecifyCompatTool"- "(t.unAppID,e.data)})]})", 1 },+ "selectedOption:t.strCompatToolName,onChange:e=>{SteamClient.Apps.SpecifyCompatTool"+ "(t.unAppID,e.data);MSCXPick(t,e.data)}})]})", 1 },// Compatibility page container{ "Rt=(0,a.PA)(e=>(0,i.jsxs)(c.nB,{children:[(0,i.jsx)(\"div\",{className:K().HiddenIfNotLast,""children:(0,A.we)(\"#AppProperties_CompatibilityNoOptions\")}),(0,i.jsx)(It,{...e}),"diff --git a/dylib/tests/envcheck.sh b/dylib/tests/envcheck.shindex a7ae692..ce9c974 100755--- a/dylib/tests/envcheck.sh+++ b/dylib/tests/envcheck.sh@@ -61,6 +61,43 @@ for arg in "$@"; docase "$arg" in CX_APPLEGPTK_LIBD3DSHARED_PATH=*) forwarded=${arg#*=} ;; esacdoneis "game launcher receives the path as one argument" "$library" "$forwarded"+# macOS sed stops at the first invalid UTF-8 value.+# shellcheck disable=SC2016 # The stub and loop expand inside the child shell.+after_bad=$(env -i PATH="$PATH" LANG=en_US.UTF-8 DXVK_HUD=1 sh -c '+ env() { printf "A_BAD=a\377b\nDXVK_HUD=1\n"; }+ f=$1; set --; eval "$f"; printf "%s " "$@"' sh "$forward")+is "settings after a non-UTF-8 value are forwarded" "--env DXVK_HUD=1 " "$after_bad"++echo "== Rosetta-only settings on arm64 Wine =="+drop=$(sed -n '/^np_dropped=""$/,/^fi$/p' "$SRC")+[ -n "$drop" ] || { echo "FAIL: the arm64 settings block was not found"; exit 1; }+drop_at=$(grep -n '^np_dropped=""$' "$SRC" | cut -d: -f1)+# shellcheck disable=SC2016 # Match the literal launcher loop.+forward_at=$(grep -n '^for name in $(env ' "$SRC" | cut -d: -f1)+[ "$drop_at" -lt "$forward_at" ] ||+ bad "the arm64 settings block runs before the forwarding loop" "< $forward_at" "$drop_at"+seen() { sh -c 'env | sed -nE "s/^(CX_GRAPHICS_BACKEND|D3DM_[A-Z0-9_]*|DXMT_[A-Z0-9_]*|ROSETTA_[A-Z0-9_]*)=.*/\1/p" | sort | tr "\n" " "'; }+for name in $(seen); do unset -v "$name"; done+CX_ROOT="/R R"+set_all() { export CX_GRAPHICS_BACKEND=d3dmetal D3DM_ENABLE_METALFX=1 ROSETTA_ADVERTISE_AVX=0 DXMT_CONFIG=x; }+set_all+wine_unix="/R R/lib/wine/x86_64-unix"+eval "$drop"+is "x86_64 Wine keeps every setting" \+ "CX_GRAPHICS_BACKEND D3DM_ENABLE_METALFX DXMT_CONFIG ROSETTA_ADVERTISE_AVX " "$(seen)"+is "x86_64 Wine logs nothing" "" "$np_dropped"+wine_unix="/R R/lib/wine/aarch64-unix"+eval "$drop"+is "D3DMetal and Rosetta settings leave the environment" "DXMT_CONFIG " "$(seen)"+is "the run log names what was ignored" \+ "CX_GRAPHICS_BACKEND=d3dmetal D3DM_ENABLE_METALFX ROSETTA_ADVERTISE_AVX" "$np_dropped"+set_all+export CX_GRAPHICS_BACKEND=dxmt+unset -v D3DM_ENABLE_METALFX ROSETTA_ADVERTISE_AVX+eval "$drop"+is "other backends stay" "CX_GRAPHICS_BACKEND DXMT_CONFIG " "$(seen)"+is "nothing to ignore logs nothing" "" "$np_dropped"+unset -v CX_GRAPHICS_BACKEND DXMT_CONFIGif [ "$fails" -eq 0 ]; thenecho "==> envcheck: all assertions hold"diff --git a/dylib/tests/panel-behavior/fex.js b/dylib/tests/panel-behavior/fex.jsindex ca35e4e..ad1d88f 100644--- a/dylib/tests/panel-behavior/fex.js+++ b/dylib/tests/panel-behavior/fex.js@@ -21,7 +21,6 @@ for (const form of Object.keys(FORMS)) {walk(P({ details: details(opts + ' %command%', { strCompatToolName: tool }) }));const toggles = ns => ns.filter(x => x.type === 'Toggle').map(x => x.props.label);const backends = ns => ns.find(x => x.type === 'Dropdown').props.rgOptions.map(o => o.data);- const note = ns => ns.some(x => x.props.className === 'MSCXNote');let r = nodes('');t.ok(backends(r).includes('d3dmetal') === !fex,@@ -29,13 +28,11 @@ for (const form of Object.keys(FORMS)) {t.ok(toggles(r).includes(AVX) === !fex, `the AVX2 row is ${fex ? 'hidden' : 'shown'}`);t.ok(toggles(r).includes('DLSS') === !fex,`automatic ${fex ? 'hides' : 'shows'} the D3DMetal DLSS row`);- t.ok(!note(r), 'automatic shows no note');- // Kept as an entry so the dropdown still names what the options say, with a note- // that the game is not getting it.r = nodes('CX_GRAPHICS_BACKEND=d3dmetal D3DM_ENABLE_METALFX=1');- t.ok(backends(r).includes('d3dmetal'), 'a game set to D3DMetal still shows it selected');- t.ok(note(r) === fex, `the D3DMetal note is ${fex ? 'shown' : 'absent'}`);+ const picked = r.find(x => x.type === 'Dropdown').props.selectedOption;+ t.ok(backends(r).includes('d3dmetal') === !fex && picked === (fex ? '' : 'd3dmetal'),+ `a game set to D3DMetal shows ${fex ? 'Automatic' : 'D3DMetal'} (${picked})`);t.ok(toggles(r).includes('DLSS') === !fex,`D3DMetal ${fex ? 'hides' : 'shows'} its DLSS row`);@@ -52,7 +49,7 @@ for (const form of Object.keys(FORMS)) {t.ok(opts.includes('CX_GRAPHICS_BACKEND=dxmt') && !opts.includes('D3DM_ENABLE_METALFX'),`switching off D3DMetal drops its flag (${opts})`);- // Hidden is not cleared: a value set under the Rosetta build is left for it.+ // Only picking a FEX tool clears hidden values.written.length = 0;const kept = 'ROSETTA_ADVERTISE_AVX=1 CX_GRAPHICS_BACKEND=dxvk';r = nodes(kept);@@ -80,14 +77,31 @@ for (const form of Object.keys(FORMS)) {tp.ok(pr.find(x => x.type === 'Dropdown').props.rgOptions.some(o => o.data === 'd3dmetal'),'a tool whose name prefixes a FEX tool keeps the Rosetta options');failed += tp.failed;+}- const { render: Z } = panel(emit, form, { document: { documentElement: { lang: 'zh-CN' } } },- { fexTools: FEX_TOOLS });- const t = runner(`${form}, FEX, Chinese`);- const zh = walk(Z({ details: details('CX_GRAPHICS_BACKEND=d3dmetal %command%',- { strCompatToolName: 'notproton-fex' }) }));- const text = (zh.find(x => x.props.className === 'MSCXNote') || { props: {} }).props.children;- t.ok(/^D3DMetal 需要/.test(text || ''), `the note is translated (${text})`);+{+ const { pick, written } = panel(emit, 'component', undefined, { fexTools: FEX_TOOLS });+ const t = runner('component, picking a tool');+ const choose = (opts, tool) => {+ written.length = 0;+ pick(details(opts), tool);+ 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";+ const r = choose(all, 'notproton-fex');+ t.ok(r === "WINEDEBUG=-all MTL_HUD_ENABLED=1 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,+ 'names the launch script does not forward are left alone');+ for (const o of ['>D3DM_LOG=1 %command%', "X=$'a\\'b D3DM_Y=1 c' %command%",+ 'wrapper <(x) D3DM_Y=1 %command%', 'D3DM_Y=1 \\\n%command%'])+ t.ok(choose(o, 'notproton-fex') === null, `text the parser does not model is left alone (${o})`);+ t.ok(choose('CX_GRAPHICS_BACKEND=dxmt %command%', 'notproton-fex') === null,+ 'another backend is not a reason to write');+ t.ok(choose('-novid CX_GRAPHICS_BACKEND=d3dmetal', 'notproton-fex') === null,+ 'text after the game, not set before %command%, is left alone');failed += t.failed;}console.log(failed ? `\n${failed} failure(s)` : '\nFEX hides what it cannot run, Rosetta keeps everything');diff --git a/dylib/tests/panel-behavior/harness.js b/dylib/tests/panel-behavior/harness.jsindex 8515e9a..a03c668 100644--- a/dylib/tests/panel-behavior/harness.js+++ b/dylib/tests/panel-behavior/harness.js@@ -37,8 +37,10 @@ function panel(emit, form, globals = { document: { documentElement: { lang: 'en'const SteamClient = {Apps: { SetAppLaunchOptions: (appid, opts) => written.push({ appid, opts }) },};- const build = new Function(f.react, f.barrel, 'SteamClient', 'globalThis', src + '\nreturn MSCXOpts;');- return { render: build(react, barrel, SteamClient, globals), written };+ const build = new Function(f.react, f.barrel, 'SteamClient', 'globalThis',+ src + '\nreturn { MSCXOpts, MSCXPick: typeof MSCXPick === "function" ? MSCXPick : null };');+ const { MSCXOpts, MSCXPick } = build(react, barrel, SteamClient, globals);+ return { render: MSCXOpts, pick: MSCXPick, written };}// Function components are resolved rather than recorded, so a check sees the nodes the