[GH #83] Feature request: iOS target (iPhone/iPad) - scope and feasibility #83
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Zettrox/ztrx. Originally posted by itsonewi on 2026-11-25T09:15:30Z.
What I am asking for
A way to run ztrx on iPhone / iPad, so that people who own a capable phone but not a capable Windows PC can use it at all.
Why
The requirements here are Windows 10/11 x64 with AVX2 and an NVIDIA RTX 20-series or newer GPU. That is a machine many people who would use ztrx do not have, while they do have a recent iPhone. If an iOS target were possible, that hardware gap would matter much less.
What I already understand about the blockers (so this is not a "just build it for ARM" request)
Questions
I am not asking anyone to commit to this. I would just like to know whether the answer is "no", "not now", or "yes, and here is what help would look like".
Imported from Zettrox/ztrx. Originally posted by xiaotu030202 on 2026-11-25T11:13:06Z.
Scope and feasibility, measured from the code
I read the tree rather than reasoning about what a port "usually" involves, so the numbers below are from
mainat the time of writing. I have no iOS device and no game files, so this is an analysis of what the code would need, not a port that runs.Short version: the shader recompiler is the part that would carry over, and it is also the part that cannot be reused as it stands. The blocker is not Metal and not the JIT rules in the abstract — it is that
victory-shaderemits DXIL by calling a DXIL-shaped bitcode builder directly, with no intermediate representation another backend could target.What is there now
lower.rsimports the DXIL builder and calls it inline:and inside, the emitted programs lean on DX12-only runtime facilities directly — 50 call sites between
createHandleFromHeap,rawBufferLoad,ResourceDescriptorHeap-style heap indexing and barriers:So the shape is: RDNA2 machine code → (per-instruction lowering that already knows it is writing DXIL) → DXIL → D3D12. There is no
Program-level IR with two backends behind it.emit::HostShaderis a DXIL container plus root-signature description; nothing in the tree can accept anything else.The three blockers, with what each actually costs
1. A second shader backend (the real work)
To render on Metal, the lower half has to be retargeted. Two routes, and the code decides which is cheaper:
(a) RDNA2 → SPIR-V → MSL. Add an
emitthat lowers the existing RDNA2 reading to SPIR-V, then MSL at build time. SPIRV-Cross's MSL backend exists and is the piece with a track record for exactly this. The catch is thatlower.rsdoes not produce a representation you can retarget: its calls are the DXIL, so this is not "add a backend", it is "rewrite the back half oflower.rsto emit to an IR, then write two backends". At 477 KB of per-instruction lowering, that is the bulk of the shader crate.(b) RDNA2 → DXIL → MSL via an existing translator. There are DXIL→SPIR-V and SPIR-V→MSL paths in various states, but the console-specific things
lower.rsemits on purpose — the heap handles, the raw buffer loads at computed indices, the 16-bit packing, the wave intrinsics it already special-cases per stage — are exactly the constructs a generic translator is least likely to accept. Theshortcut:notes in the tree show how much of this is already approximate even for the target D3D12 is.Either way the translator's tests are the asset.
intersect_tests.rs,wave64_tests.rs,waterfall_tests.rsand the DIFF harness (diff_tests.rs, which compiles the same program with AMD'sdxc.exeand the PC one and compares) encode RDNA2 semantics against reference output. Those apply to a Metal backend unchanged — they are the reason a second backend is a large job rather than an unbounded one.2. The x64 code has no JIT path on iOS
Confirmed from the shape of the loader, not from memory:
victory-loadermaps the title's PE image into the process and lets its x86-64 run. iOS allows no JIT for a third-party app without an entitlement the App Store does not grant, so the title's code would have to be translated to ARM64 ahead of time and shipped alongside. That is a static recompiler for x86-64 → AArch64 over a shipping game's code, which is a different project from this one — and it has to be correct, because you cannot fall back to the interpreter for the hot path.Alternative that avoids it: run the title on a host PC and stream. That is not what the issue asks for, but it is the only path that does not require the AOT translator.
3. Everything above the GPU is Windows-specific in small pieces
victory-hleimplements the console's API surface by calling Windows. On iOS there is noCreateFileW, no XAudio2, no GameInput; each module invictory-hle/src/modules/would need a second implementation over an iOS equivalent, and the ones that already carryshortcut:notes (audio reverb silent, speech silent, HDR not done) would each get harder. This is the boring part and it is large.What I would suggest as the actual next step
Not a port. A retargeting spike, because it answers the question with numbers instead of opinion:
valu_tests.rsandwave64_tests.rs.That yields three numbers nobody has: how many distinct RDNA2 instruction forms the tests actually exercise (a proxy for the minimum viable backend), whether the heap-handle and raw-load constructs survive SPIRV-Cross, and whether MSL reproduces the 1-ULP-level results the tests pin. If (2) fails, the answer is "not without replacing the shader backend wholesale" and the decision is easy.
I can write step 1's opcode inventory from the tree right now without any device — the tests are in the repository. Steps 2 and 3 need macOS hardware I do not have.
On the distribution question
GPL-3.0-or-later and the App Store are incompatible, so this would be sideloading, which on iOS means either an EU alternative marketplace (DMA, so region-limited) or a developer-account build with a 7-day / 1-year profile. Both are much smaller user bases than "anyone with a recent iPhone". That is a product question rather than a technical one, but it changes who the iOS target actually serves: not the person in the issue's Why section, unless they are in the EU and willing to sideload.
What I am not saying
I am not saying it is impossible, and I am not saying it is a weekend. The tree says the shader backend is the cost and the tests are the leverage. If the maintainer wants the opcode inventory from step 1, I can produce it as a PR to
docs/with no code changes.Also, for completeness: I ran
cargo test --workspaceon this tree (Windows 11, RTX 5070 Ti, Rust 1.98.1 pinned) and it is green — 0 failures, which is why I looked at what is missing rather than at a failure.fxceless/victory-forkfails one test anduiliannn/VItoriaBranother, both on the same machine; I reported those separately.