feat(metal): a MetalFX temporal scaler smoke spike #384

Open
github-bot wants to merge 18 commits from github-bot/gh-381 into main AGit
Owner

@⁠wz11wz on GitHub · 2026-11-27 15:15 UTC · original
wz11wz:feat/metalfx-upscaler-spike → main · +2413 −155 · 24 files · 18 commits · draft

Refs #378, M0 of the plan posted there.

victory-metal gains a metalfx module: a smoke spike that builds an MTLFXTemporalScaler through objc2-metal-fx 0.3 and proves the whole path works on the host Mac with no title involved:

  • descriptor (640x360 in, 1280x720 out, RGBA16Float colour / Depth32Float depth / RG16Float motion)
  • synthetic shared textures, the colour one filled with a gradient
  • per-frame setters (textures, input content size, jitter, motion scale, reset)
  • encodeToCommandBuffer, then readback through getBytes

The 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 (ffxCreateContext builds the scaler from CreateUpscale), then M2 dispatch with the motion-vector dump harness.

**@⁠wz11wz** on GitHub · 2026-11-27 15:15 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/381) `wz11wz:feat/metalfx-upscaler-spike` → `main` · +2413 −155 · 24 files · 18 commits · draft Refs #378, M0 of the plan posted there. `victory-metal` gains a `metalfx` module: a smoke spike that builds an `MTLFXTemporalScaler` through `objc2-metal-fx` 0.3 and proves the whole path works on the host Mac with no title involved: - descriptor (640x360 in, 1280x720 out, RGBA16Float colour / Depth32Float depth / RG16Float motion) - synthetic shared textures, the colour one filled with a gradient - per-frame setters (textures, input content size, jitter, motion scale, reset) - `encodeToCommandBuffer`, then readback through `getBytes` The 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` (`ffxCreateContext` builds the scaler from `CreateUpscale`), then M2 dispatch with the motion-vector dump harness.
The ucrt started serving vcruntime140.dll's memory and string functions
when the title has not mapped its own copy (#104), but
dlls_that_are_not_the_c_runtime_are_left_alone still asserted the old
behaviour, so ./verify failed on a clean checkout. Rename the test to
say what it now checks and note why a bare test process sees the served
branch.

Also add tools/macos/verify.sh: one gate that runs both documented test
suites and the CI clippy run for the Windows target, prints a PASS/FAIL
line per check with counts, and exits non-zero on any failure.
The first step of serving the title's FidelityFX upscaler with MetalFX:
victory-metal gains a metalfx module that builds an MTLFXTemporalScaler
over synthetic shared textures (RGBA16Float colour, Depth32Float depth,
RG16Float motion), encodes it through encodeToCommandBuffer, and checks
the output moved. No title, no shaders, no Metal Shader Converter; the
test proves the objc2-metal-fx 0.3 surface works end to end on the host
Mac, which the issue asked to settle first.

Refs #375
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 15:21:54 +00:00
With VICTORY_METALFX=1, ffxCreateContext's CREATE_UPSCALE branch builds a
MetalFX context instead of forwarding to a PC FidelityFX build: the
create description (max render/output sizes, flags) is decoded into an
UpscalerConfig and validated (non-zero sizes, an upscale, a scale factor
in MetalFX's range), and the context handle is a Box of that config.
ffxDestroyContext frees our contexts; ffxDispatch refuses a MetalFX
context loudly for now - the scaler itself is built at the first
dispatch in M2, where the resource formats show up, since the create
description does not carry them.

The module is cfg(windows) today, so the seam compiles under the
Windows clippy gate (which also runs the new roundtrip tests in CI);
un-gating it for the macOS build is M2's first move, together with the
dispatch.
Author
Owner

@⁠wz11wz on GitHub · 2026-11-27 15:37 UTC · original

M1 landed in this branch (30dd7c8): the VICTORY_METALFX=1 seam in fidelityfx.rs. ffxCreateContext's CREATE_UPSCALE branch now decodes and validates the create description into an UpscalerConfig and hands the title a context that is ours; ffxDestroyContext frees it; ffxDispatch refuses 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.

**@⁠wz11wz** on GitHub · 2026-11-27 15:37 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/381#issuecomment-7222289690) M1 landed in this branch (30dd7c8): the `VICTORY_METALFX=1` seam in `fidelityfx.rs`. `ffxCreateContext`'s `CREATE_UPSCALE` branch now decodes and validates the create description into an `UpscalerConfig` and hands the title a context that is ours; `ffxDestroyContext` frees it; `ffxDispatch` refuses 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.
The interception's descriptions, return codes, backend link and shared
logging macro are the SDK's own and identical on both sides; the Windows
DLL loading is not. fidelityfx_common carries the shared half (and now
compiles on macOS), fidelityfx keeps the PC forwarding behind pc_*
helpers and cfg(windows), and the module itself is
cfg(any(windows, target_os = "macos")) so the MetalFX provider (M2) can
live in it. The roundtrip tests now run on a Mac for the first time -
they were cfg(windows)-excluded before.
serving() gated the module out of the import registry on macOS, so
VICTORY_METALFX=1 never reached anything. On macOS the module now serves
when the switch is on: the title's ffxCreateContext lands in our
MetalFX context seam instead of running the title's own FidelityFX
DLL (whose FSR compute passes are the wave64 refusal class).
Author
Owner

@⁠wz11wz on GitHub · 2026-11-27 15:59 UTC · original

M1.5 and M1.6 landed (b42f9ef), from the review feedback:

  • fidelityfx_common now carries the platform-independent half: descriptions, return codes, the backend link, host_state, the shared once! macro. fidelityfx keeps the PC forwarding behind pc_* helpers under cfg(windows), and the module itself is cfg(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).
  • serving() now answers yes on macOS under 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 (#382).

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.

**@⁠wz11wz** on GitHub · 2026-11-27 15:59 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/381#issuecomment-7222729016) M1.5 and M1.6 landed (b42f9ef), from the review feedback: - **fidelityfx_common** now carries the platform-independent half: descriptions, return codes, the backend link, `host_state`, the shared `once!` macro. `fidelityfx` keeps the PC forwarding behind `pc_*` helpers under `cfg(windows)`, and the module itself is `cfg(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). - **serving()** now answers yes on macOS under `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 (#382). 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.
The title's call order is query first: a NO_PROVIDER out of ffxQuery
concludes there is no provider and never reaches ffxCreateContext, so
M1.6's serving() flip alone left the seam dark. Under
VICTORY_METALFX=1, ffxQuery now answers GET_VERSIONS (one provider, our
id and name; the count-then-ids/names two-pass both supported) and
GET_PROVIDER_VERSION, and ffxConfigure accepts-and-ignores settings as
the PC DLL effectively does. The provider id is our own - create ignores
the requested one; the real DLL's values should be dumped on Windows
(the PC versions() helper logs them) if the title ever cross-checks.

The device-carrying query refusal stays: MEMORY_USAGE_WITH_DEVICE is
refused exactly as the Windows path already does, and that path is known
to reach a working upscaling.
Author
Owner

@⁠wz11wz on GitHub · 2026-11-27 16:05 UTC · original

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:

  • ffxQuery now answers GET_VERSIONS (one provider; the count-then-ids/names two-pass both supported) and GET_PROVIDER_VERSION with our id/name
  • ffxConfigure accepts-and-ignores settings
  • MEMORY_USAGE_WITH_DEVICE keeps the same refusal the Windows path already makes, and that path is known to reach a working upscaling
  • the provider id is our own (0x6d65_7461, "MetalFX (victory)"): create ignores the requested one, and the real DLL's values can be dumped on Windows via the PC versions() helper if the title ever cross-checks

Test: metalfx_query_negotiates_one_provider covers both query kinds. Suites: arm64 146, x86 389, 0 failed; Windows clippy clean for everything but msc.rs (#382).

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.

**@⁠wz11wz** on GitHub · 2026-11-27 16:05 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/381#issuecomment-7222850047) 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: - `ffxQuery` now answers `GET_VERSIONS` (one provider; the count-then-ids/names two-pass both supported) and `GET_PROVIDER_VERSION` with our id/name - `ffxConfigure` accepts-and-ignores settings - `MEMORY_USAGE_WITH_DEVICE` keeps the same refusal the Windows path already makes, and that path is known to reach a working upscaling - the provider id is our own (`0x6d65_7461`, "MetalFX (victory)"): create ignores the requested one, and the real DLL's values can be dumped on Windows via the PC `versions()` helper if the title ever cross-checks Test: `metalfx_query_negotiates_one_provider` covers both query kinds. Suites: arm64 146, x86 389, 0 failed; Windows clippy clean for everything but `msc.rs` (#382). 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.
Hayyan612's requirement: the title's x86-64 code runs under Rosetta, so
the Apple half of the gate is the vendor plus that architecture;
iOS/iPadOS stay out. fidelityfx_common is pure repr(C) parsing
(c_void/c_char/usize - no x86_64 assumptions), so a vendor-only gate
would also be safe if the iPad builds ever want it.
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-27 16:23 UTC · original

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 #373, so a rebase will drop them.

**@⁠LakshanSivakumar** on GitHub · 2026-11-27 16:23 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/381#issuecomment-7223211827) 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 #373, so a rebase will drop them.
A bright square pans across known ground-truth motion (+3, +2) input
pixels per frame — (+6, +4) output pixels at the suite's 2x scale —
while the motion texture is fed independently, so the convention can
be checked against the same content. Three new tests:

- still_scene_holds_position: zero motion and zero jitter must not
  drift the square (catches hallucinated motion and history drift)
- panning_scene_tracks_documented_motion: the output tracks ground
  truth within 1.5 output pixels, the interior stays bright, and the
  vacated background holds no ghosting
- panning_convention_differential_report: the same scene with the
  motion sign flipped, printed for the calibration record (asserts
  nothing)

All four green on an M1 Max (macOS 26): still-scene drift is 0.00,
the panning scene tracks within 1.5 px with a 3.000/3.0 interior and
0.000 trailing bleed under Apple's documented convention. One finding
worth recording: the sign-flip differential is indistinguishable on
synthetic frames (both conventions read 3.000 interior / 0.000 bleed) —
idealized frames hide convention errors, so the real-frame
dump-and-compare over the title's own dispatches stays the gate before
M2's dispatch can be trusted.
Author
Owner

@⁠wz11wz on GitHub · 2026-11-27 16:33 UTC · original

Step D of the plan landed (5e986bb): a synthetic calibration suite next to the spike in victory-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):

  • still scene: drift 0.00 output pixels
  • panning: tracks (+6, +4) within 1.5 px, interior 3.000 of 3.0, trailing bleed 0.000 under Apple's documented convention (output-space pixels, previous frame to current)
  • the suite caught one real measurement bug on the way in: an earlier draft moved the colour content while claiming zero motion, and the drift read exactly the ground truth doubled — which is the failure mode these tests exist to catch

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_DIR as the reference. I do not have one, so the comparison is now same-machine before/after: dump the title's upscale dispatches on main (no interception — the title's own FidelityFX DLL runs, its passes partially refused) and again under VICTORY_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.

**@⁠wz11wz** on GitHub · 2026-11-27 16:33 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/381#issuecomment-7223399700) Step D of the plan landed (5e986bb): a synthetic calibration suite next to the spike in `victory-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):** - still scene: drift 0.00 output pixels - panning: tracks (+6, +4) within 1.5 px, interior 3.000 of 3.0, trailing bleed 0.000 under Apple's documented convention (output-space pixels, previous frame to current) - the suite caught one real measurement bug on the way in: an earlier draft moved the colour content while claiming zero motion, and the drift read exactly the ground truth doubled — which is the failure mode these tests exist to catch **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_DIR` as the reference. I do not have one, so the comparison is now same-machine before/after: dump the title's upscale dispatches on `main` (no interception — the title's own FidelityFX DLL runs, its passes partially refused) and again under `VICTORY_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.
github-bot force-pushed github-bot/gh-381 from 5e986bbd27 to a56d211aad 2026-11-27 16:47:55 +00:00 Compare
Author
Owner

@⁠wz11wz on GitHub · 2026-11-27 16:38 UTC · original

Rebased onto main (b998bb65): the ucrt test and verify.sh commits 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.md entry for VICTORY_METALFX. Both are what's next.

**@⁠wz11wz** on GitHub · 2026-11-27 16:38 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/381#issuecomment-7223508334) Rebased onto `main` (b998bb65): the ucrt test and `verify.sh` commits 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.md` entry for `VICTORY_METALFX`. Both are what's next.
The clippy gate checks the whole workspace for the Windows target,
where victory-metal's  and  dependencies do not exist
(they are macOS-only in Cargo.toml).  uses both unconditionally,
so every Windows-target build of the crate failed with E0433 — CI run
#795 on this branch was the first to hit it, because main itself is not
CI-checked on pushes and the errors predate this branch (#379's
noted "msc.rs pre-existing errors").

Every other module in this crate is already macOS-gated, and the crate
doc says it is empty on other targets; msc was the one module missing
the gate. Verified with cargo check --all-targets --target
x86_64-pc-windows-gnullvm and the full clippy gate command.
Author
Owner

@⁠wz11wz on GitHub · 2026-11-27 16:53 UTC · original

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):

  • Two windowed interactive runs crash deterministically when the user advances past the menus: frame 799 and 807 (~2m15s and ~2m25s in). First-chance 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).
  • Two headless runs with auto-Enter (240 s and 600 s, frames 6784 and 17792) never crash - and never call a single 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.

**@⁠wz11wz** on GitHub · 2026-11-27 16:53 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/381#issuecomment-7223789123) 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`): - Two **windowed interactive** runs crash deterministically when the user advances past the menus: frame **799** and **807** (~2m15s and ~2m25s in). First-chance `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). - Two **headless** runs with auto-Enter (240 s and 600 s, frames 6784 and 17792) never crash - and never call a single `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.
github-bot referenced this pull request from a commit 2026-11-28 00:42:29 +00:00
run.rs (the Wine path) called fidelityfx::use_host_dir before the import
registry was first consulted; native_run.rs never did, so on macOS the
serving module was only ever held in tests. With VICTORY_METALFX=1 the
startup now logs 'FidelityFX: no PC build on this host; MetalFX serves
when VICTORY_METALFX=1' on the native path (verified headless, M2).
Author
Owner

@⁠wz11wz on GitHub · 2026-11-28 07:16 UTC · original

Status: the serving seam is now live on the native path, and the unit layer is green on Apple Silicon.

  • use_host_dir was only ever called from the Wine-side runner (run.rs); native_run.rs never called it, so on macOS the serving module was only held in tests. Wired into native startup now (this push) — verified headless: the startup logs FidelityFX: no PC build on this host; MetalFX serves when VICTORY_METALFX=1 and 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 --target cargo builds the arm64 test binary, the apple + x86_64 gate 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 the ffx* entry points itself and imports d3d12_xs.dll) is only loaded at a later game state than any headless run reaches (also blocked by the #408 crash, see the analysis there: the residency-ordered submission path and the fence-lag accumulation model).

Remaining for M2: the dispatch — metalfx_dispatch still refuses ("the scaler itself lands at the first dispatch"), so the real MTLFXTemporalScaler integration with the dispatch's console resources is the last implementation piece.

**@⁠wz11wz** on GitHub · 2026-11-28 07:16 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/381#issuecomment-7235826707) **Status: the serving seam is now live on the native path, and the unit layer is green on Apple Silicon.** - `use_host_dir` was only ever called from the Wine-side runner (`run.rs`); `native_run.rs` never called it, so on macOS the serving module was only held in tests. Wired into native startup now (this push) — verified headless: the startup logs `FidelityFX: no PC build on this host; MetalFX serves when VICTORY_METALFX=1` and 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 `--target` cargo builds the arm64 test binary, the `apple + x86_64` gate 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 the `ffx*` entry points itself and imports `d3d12_xs.dll`) is only loaded at a later game state than any headless run reaches (also blocked by the #408 crash, see the analysis there: the residency-ordered submission path and the fence-lag accumulation model). Remaining for M2: the dispatch — `metalfx_dispatch` still refuses ("the scaler itself lands at the first dispatch"), so the real `MTLFXTemporalScaler` integration with the dispatch's console resources is the last implementation piece.
mod.rs registered the fidelityfx module only on Windows, so VICTORY_METALFX=1
never served the title on macOS; and the title's amd_fidelityfx_upscaler_xbox.dll
was refused as outside the host policy. The module now registers whenever it
serves (MetalFX on macOS, the PC build on Windows) and serves the upscaler DLL
name too, and ffxDispatch records the title's upscaling through
native::metalfx_record (textures resolve to host copies; the temporal scaler is
built from them at the first encode). This is the scaler the #375 plan's M2
ends with.

(cherry picked from commit 5554f99ce82b18577706d5db06bde5266be03bde)
The title reads fields of the provider context past the description it
handed us; a bare 24-byte config made those reads land past the allocation
and the run faulted at image+0x55e56f8 right after the first dispatch.
Hand out a 4 KiB zeroed block instead.

(cherry picked from commit f04f97c2a46c76efcff030fd7f0a3c4d1c9e708a)
The title-side period (object+0x10c) is never initialised on this path, so
the first dispatch's counter/period divide faults (image+0x28f03e8). The
first-chance handler now writes VICTORY_METALFX_PERIOD (default 8) once per
object and re-executes the divide; a second fault on the same object falls
through to the title's own handling.

(cherry picked from commit aefb363a8ff34b661d34a91e3967a26be3e39a31)
The FSR3.1 phase table (1.5x = 18, 1.7x = 23, 2.0x = 32, 3.0x = 72, custom
= ceil(8n^2)) is what a title's period field holds: the dispatch divides its
frame counter by it. metalfx_query now answers GetJitterPhaseCount and
GetJitterOffset (0x10004/0x10005, Halton(2,3)) per the SDK headers, and the
first-chance fallback writes 18 instead of 8 for a 1.5x context.

(cherry picked from commit 070de1c72057e142ca24163a622f743c92831967)
Synthetic gradients land in host textures through buffer copies, one
metalfx_upscale command goes through a list and the host, and the output is
read back through another buffer copy: the recording and submission path of
the #375 dispatch, checked against ground truth in 0.4 s instead of a game
run. Also carry suspect_tests.rs over from the m2 branch, whose mod entry
had come along without its file.

(cherry picked from commit 0b52ce2e5395b27a0843b741da881fdad9af6fb3)
image+0x55e56f8 compares a queue node pointer ([rcx+0x38]) against the
queue's own buffer head (rcx+0x70) and faults right after the first FSR
dispatch on the MetalFX path. The first-chance handler now prints the queue
object's first words and the node pointer, so what the node should have
been can be read off one game run.

(cherry picked from commit afde113cee4c3df3615a99f3ecafcc3c1450a23c)
The #375 plan's last step: what the seam answers, the jitter phase table, the
padded provider context, what is refused (frame generation, sharpening), and
how the whole chain is verified — a synthetic 2x upscale through the host in
0.4 s, and a 400 s game run at the Series S profile with the dispatch recorded
and the phase count answered. fidelityfx leaves the cfg(windows) backlog list.

(cherry picked from commit 435dc311232e3382d65acdd514d67b957e33a6a7)
The title's probe of its pooled-object table (image+0x50eb80f) has no exit for a
handle that is in no group. When the title frees an object while a job still
holds it, the job spins for good, the job that empties the table waits for it,
and the main thread waits behind that: the freeze of #456.

With VICTORY_LOOKUP_EXIT=1 the first byte of the probe's miss path becomes an
int3 before the title runs, if the code there is the one expected. Its handler
does what the replaced instructions did, or, when the group just probed has an
empty control byte, returns through the function's own epilogue. Off by default;
the offsets are those of the build we test.

Refs #456

(cherry picked from commit b21746f161f88b6cf95782a74fad2894d6655a73)
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/native/host.rs
  • docs/native-host.md
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/384/head:github-bot/gh-381'
git switch 'github-bot/gh-381'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-381'
git switch 'github-bot/gh-381'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-381'
git switch 'github-bot/gh-381'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-381'
git switch 'main'
git merge --squash 'github-bot/gh-381'
git switch 'main'
git merge --ff-only 'github-bot/gh-381'
git switch 'main'
git merge 'github-bot/gh-381'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.