feat(metal): a MetalFX temporal scaler smoke spike #381
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/381"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by wz11wz on 2026-11-27T15:15:28Z.
Refs #375, M0 of the plan posted there.
victory-metalgains ametalfxmodule: a smoke spike that builds anMTLFXTemporalScalerthroughobjc2-metal-fx0.3 and proves the whole path works on the host Mac with no title involved:encodeToCommandBuffer, then readback throughgetBytesThe test (
temporal_scaler_scales_synthetic_input) asserts the output is not flat: 471 distinct values sampled from the upscaled frame on an M1 Max. No Metal Shader Converter involvement, so the spike runs wherever macOS 14+ does.Next up per the plan: the M1 context seam behind
VICTORY_METALFX=1(ffxCreateContextbuilds the scaler fromCreateUpscale), then M2 dispatch with the motion-vector dump harness.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by wz11wz on 2026-11-27T15:37:45Z.
M1 landed in this branch (
30dd7c8): theVICTORY_METALFX=1seam infidelityfx.rs.ffxCreateContext'sCREATE_UPSCALEbranch now decodes and validates the create description into anUpscalerConfigand hands the title a context that is ours;ffxDestroyContextfrees it;ffxDispatchrefuses loudly until the scaler build lands (M2 - the create description carries no formats, so the scaler is built lazily at the first dispatch, which is also where the module stops being cfg(windows)-only).Verified: the Windows clippy gate compiles the seam and its roundtrip tests clean (they run in CI there), and both documented suites stay green (384 + 520, 0 failed). Next: M2's un-gating and the dispatch with the motion-vector dump harness.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by wz11wz on 2026-11-27T15:59:42Z.
M1.5 and M1.6 landed (
b42f9ef), from the review feedback:host_state, the sharedonce!macro.fidelityfxkeeps the PC forwarding behindpc_*helpers undercfg(windows), and the module itself iscfg(any(windows, target_os = "macos"))- the interception compiles on a Mac for the first time, and its roundtrip tests run there too (they were excluded before).VICTORY_METALFX=1, so the module actually enters the import registry there (it never did before - that gap meant the first M1 was unreachable from the title).Suites: arm64 145 passed (was 141 - the fidelityfx tests joined), x86 384+520... 388 total, 0 failed; Windows clippy clean for everything but
msc.rs's pre-existing errors (#379).Next: M2 - the dispatch builds the scaler from the seven resources' formats, with the motion-vector dump harness; then a real run to verify the interception end to end.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by wz11wz on 2026-11-27T16:05:45Z.
M1.7 landed (
2ce2117), from the call-order catch: the title negotiates before it creates, so M1.6's serving() flip alone left the seam dark. Under VICTORY_METALFX=1:ffxQuerynow answersGET_VERSIONS(one provider; the count-then-ids/names two-pass both supported) andGET_PROVIDER_VERSIONwith our id/nameffxConfigureaccepts-and-ignores settingsMEMORY_USAGE_WITH_DEVICEkeeps the same refusal the Windows path already makes, and that path is known to reach a working upscaling0x6d65_7461, "MetalFX (victory)"): create ignores the requested one, and the real DLL's values can be dumped on Windows via the PCversions()helper if the title ever cross-checksTest:
metalfx_query_negotiates_one_providercovers both query kinds. Suites: arm64 146, x86 389, 0 failed; Windows clippy clean for everything butmsc.rs(#379).That closes M1 properly: with the switch on, a macOS run should now show the version query answered, our context created, and the dispatch refusal logged - the three markers to look for in the next real run before M2 wires the scaler in.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T16:23:49Z.
Leaving this open while it is a spike: with VICTORY_METALFX on, every upscale is still refused, so it does nothing yet, and the switch is not in docs/native-host.md. Its ucrt test and verify.sh commits are on main already through #370, so a rebase will drop them.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by wz11wz on 2026-11-27T16:33:29Z.
Step D of the plan landed (
5e986bb): a synthetic calibration suite next to the spike invictory-metal/src/metalfx.rs— the check the proposal asked to settle before the dispatch, with one revision to the reference side, noted at the end.The harness. A bright square pans across known ground truth (+3, +2) input pixels per frame — (+6, +4) output pixels at the spike's 2x scale — while the motion texture is fed independently, so the convention can be checked against the same content. Three tests: a still scene must not drift; the panning scene must track ground truth within 1.5 output pixels with a bright interior and no ghosting at the vacated edge; and a sign-flip differential prints both conventions for the record.
Results on the M1 Max (all green):
The finding that matters for M2: the sign-flip differential is indistinguishable on synthetic frames — documented (+6, +4) and flipped (-6, -4) both read interior 3.000 / bleed 0.000. Idealized frames hide convention errors (no noise, no jitter, uniform motion), so synthetic calibration alone cannot settle the convention. The real-frame dump-and-compare stays the gate before the dispatch is trusted.
Reference-side revision: the original plan compared FSR vs MetalFX, which wanted a Windows box with
VICTORY_FIDELITYFX_DIRas the reference. I do not have one, so the comparison is now same-machine before/after: dump the title's upscale dispatches onmain(no interception — the title's own FidelityFX DLL runs, its passes partially refused) and again underVICTORY_METALFX=1, same scene, same frames (deterministic input replay). What to check: the FSR-class passes leave the refused list, MetalFX's output is present and non-degenerate where FSR's was refused, frame meter, stability. The synthetic suite above anchors the ground truth in between.Next: M2 — the dispatch builds the scaler from the seven resources, with this harness extended to the real dump path.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by wz11wz on 2026-11-27T16:38:57Z.
Rebased onto
main(b998bb65): the ucrt test andverify.shcommits dropped out of the diff, as expected — this branch is now the seven MetalFX commits and nothing else. All four metalfx tests green on the rebased tree.Remaining before this is more than a spike, per your note: M2's dispatch (the scaler built from the seven resources at the first real upscale) and a
docs/native-host.mdentry forVICTORY_METALFX. Both are what's next.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by wz11wz on 2026-11-27T16:53:31Z.
Question for @LakshanSivakumar while we test this seam in a real run: how do you get into the prologue world, and have you seen a deterministic crash at frame ~800?
What we hit (M1 Max, macOS 26, console=series-x, this branch,
VICTORY_METALFX=1):0xc0000005, a write through a null pointer in title code; the title's own breakpad handler then faults a second time during upload and victory exits 134. Two title crash logs saved (Peds 42/600, Cars 122/700, TileHeap 3.4 GB - the world was streaming in, so the transition had started).ffx*import, so we could not verify the interception end to end yet.So: which run setup and input sequence reaches the prologue world for you, and does the frame-~800 crash ring a bell? Happy to file a full tester report with both crash logs if that helps, or to try your exact recipe and report back.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by wz11wz on 2026-11-28T07:16:18Z.
Status: the serving seam is now live on the native path, and the unit layer is green on Apple Silicon.
use_host_dirwas only ever called from the Wine-side runner (run.rs);native_run.rsnever called it, so on macOS the serving module was only held in tests. Wired into native startup now (this push) — verified headless: the startup logsFidelityFX: no PC build on this host; MetalFX serves when VICTORY_METALFX=1and the FidelityFX loader binds (amd_fidelityfx_loader_xbox.dll: 4 hle).All five fidelityfx unit tests pass on Apple Silicon — but only with the right target:
cargo test -p victory-hle --lib --target x86_64-apple-darwin. Without--targetcargo builds the arm64 test binary, theapple + x86_64gate silently compiles the module out, and the fidelityfx tests are absent (no error, just missing). Worth a note in the PR docs.Verified against a 240s headless run of Grand Theft Auto VI: the FidelityFX loader binds at startup, but the deep markers (
provider version answered/configure accepted) never fire — the title's upscaler dll (amd_fidelityfx_upscaler_xbox.dll, which exports theffx*entry points itself and importsd3d12_xs.dll) is only loaded at a later game state than any headless run reaches (also blocked by the #404 crash, see the analysis there: the residency-ordered submission path and the fence-lag accumulation model).Remaining for M2: the dispatch —
metalfx_dispatchstill refuses ("the scaler itself lands at the first dispatch"), so the realMTLFXTemporalScalerintegration with the dispatch's console resources is the last implementation piece.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.