[GH #83] Feature request: iOS target (iPhone/iPad) - scope and feasibility #83

Open
opened 2026-11-25 10:11:20 +00:00 by itsonewi · 1 comment
itsonewi commented 2026-11-25 10:11:20 +00:00 (Migrated from github.com)

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)

  • The runtime is x64 native code plus DXIL / Direct3D 12, and the GPU path assumes shader model 6.6 with mesh shaders on an NVIDIA card. iOS has no D3D12 and no NVIDIA driver: it would need a Metal renderer, and the RDNA2 → DXIL recompiler would need a DXIL → MSL (or RDNA2 → MSL) path. That is a second GPU backend, not a port.
  • iOS does not allow JIT for third-party apps, so "the game's x64 code runs natively" has no direct equivalent. It would need ahead-of-time translation of the title's x64 code to ARM64, plus the PE loader and the thunk layer on top.
  • The only non-Windows path that works today is Linux/Wine with vkd3d-proton (#23, #62), and the upstream XCL project has a macOS path through CrossOver/Wine + D3DMetal + Rosetta 2 (xcl-dev/xcl#258). None of those components exist on iOS.
  • GPL-3.0-or-later and the App Store terms are incompatible, so distribution would be sideloading only.

Questions

  1. Is an iOS (or, more generally, a mobile ARM64) target something you would consider in scope, even as a long-term direction?
  2. If not, is there a smaller direction that serves the same users — for example a lower-memory or lower-end preset for 6–8 GB cards, or the 4 GB tuning in #73? Those seem to be the closest thing to "runs on what people already own".
  3. Would an RFC / design issue for an ARM64 + Metal backend be welcome, or is that out of scope for the project?

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".

<!-- greyfinch-sync:Zettrox/ztrx:issue:6601121263 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/issues/83). Originally posted by [itsonewi](https://github.com/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) - The runtime is x64 native code plus DXIL / Direct3D 12, and the GPU path assumes shader model 6.6 with mesh shaders on an NVIDIA card. iOS has no D3D12 and no NVIDIA driver: it would need a Metal renderer, and the RDNA2 → DXIL recompiler would need a DXIL → MSL (or RDNA2 → MSL) path. That is a second GPU backend, not a port. - iOS does not allow JIT for third-party apps, so "the game's x64 code runs natively" has no direct equivalent. It would need ahead-of-time translation of the title's x64 code to ARM64, plus the PE loader and the thunk layer on top. - The only non-Windows path that works today is Linux/Wine with vkd3d-proton (#23, #62), and the upstream XCL project has a macOS path through CrossOver/Wine + D3DMetal + Rosetta 2 (xcl-dev/xcl#258). None of those components exist on iOS. - GPL-3.0-or-later and the App Store terms are incompatible, so distribution would be sideloading only. **Questions** 1. Is an iOS (or, more generally, a mobile ARM64) target something you would consider in scope, even as a long-term direction? 2. If not, is there a smaller direction that serves the same users — for example a lower-memory or lower-end preset for 6–8 GB cards, or the 4 GB tuning in #73? Those seem to be the closest thing to "runs on what people already own". 3. Would an RFC / design issue for an ARM64 + Metal backend be welcome, or is that out of scope for the project? 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".
xiaotu030202 commented 2026-11-25 12:07:12 +00:00 (Migrated from github.com)
Author

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 main at 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-shader emits DXIL by calling a DXIL-shaped bitcode builder directly, with no intermediate representation another backend could target.

What is there now

crates/victory-shader/src/emit/
    lower.rs      477 KB   RDNA2 -> DXIL, one machine instruction at a time
    bitcode.rs     39 KB   the DXIL (LLVM bitcode) builder lower.rs calls
    shader.rs      34 KB   the DXIL entry: heaps, clamping, root signatures
crates/victory-gpu/src/         294 references to ID3D12* across the crate

lower.rs imports the DXIL builder and calls it inline:

use super::bitcode::{Attr, Bin, Cast, Rmw, Tag, Term, V, pred};

and inside, the emitted programs lean on DX12-only runtime facilities directly — 50 call sites between createHandleFromHeap, rawBufferLoad, ResourceDescriptorHeap-style heap indexing and barriers:

createHandleFromHeap / rawBufferLoad / barrier / ResourceDescriptorHeap   50 matches
ID3D12*                                                                  294 matches

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::HostShader is 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 emit that 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 that lower.rs does 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 of lower.rs to 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.rs emits 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. The shortcut: 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.rs and the DIFF harness (diff_tests.rs, which compiles the same program with AMD's dxc.exe and 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-loader maps 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-hle implements the console's API surface by calling Windows. On iOS there is no CreateFileW, no XAudio2, no GameInput; each module in victory-hle/src/modules/ would need a second implementation over an iOS equivalent, and the ones that already carry shortcut: 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:

  1. Take the 40-odd simplest translated programs that already have reference output in valu_tests.rs and wave64_tests.rs.
  2. Write a throwaway RDNA2 → SPIR-V emitter covering only the opcodes those programs use, and run them through SPIRV-Cross to MSL on a Mac.
  3. Compare against the same reference output the existing tests use.

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 --workspace on 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-fork fails one test and uiliannn/VItoriaBr another, both on the same machine; I reported those separately.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7160752112 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/issues/83#issuecomment-7160752112). Originally posted by [xiaotu030202](https://github.com/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 `main` at 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-shader` emits DXIL by calling a DXIL-shaped bitcode builder directly, with no intermediate representation another backend could target. ## What is there now ``` crates/victory-shader/src/emit/ lower.rs 477 KB RDNA2 -> DXIL, one machine instruction at a time bitcode.rs 39 KB the DXIL (LLVM bitcode) builder lower.rs calls shader.rs 34 KB the DXIL entry: heaps, clamping, root signatures crates/victory-gpu/src/ 294 references to ID3D12* across the crate ``` `lower.rs` imports the DXIL builder and calls it inline: ```rust use super::bitcode::{Attr, Bin, Cast, Rmw, Tag, Term, V, pred}; ``` and inside, the emitted programs lean on DX12-only runtime facilities directly — 50 call sites between `createHandleFromHeap`, `rawBufferLoad`, `ResourceDescriptorHeap`-style heap indexing and barriers: ``` createHandleFromHeap / rawBufferLoad / barrier / ResourceDescriptorHeap 50 matches ID3D12* 294 matches ``` 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::HostShader` is 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 `emit` that 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 that `lower.rs` does 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 of `lower.rs` to 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.rs` emits 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. The `shortcut:` 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.rs` and the DIFF harness (`diff_tests.rs`, which compiles the same program with AMD's `dxc.exe` and 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-loader` maps 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-hle` implements the console's API surface by calling Windows. On iOS there is no `CreateFileW`, no XAudio2, no GameInput; each module in `victory-hle/src/modules/` would need a second implementation over an iOS equivalent, and the ones that already carry `shortcut:` 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: 1. Take the 40-odd simplest translated programs that already have reference output in `valu_tests.rs` and `wave64_tests.rs`. 2. Write a throwaway RDNA2 → SPIR-V emitter covering only the opcodes those programs use, and run them through SPIRV-Cross to MSL on a Mac. 3. Compare against the same reference output the existing tests use. 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 --workspace` on 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-fork` fails one test and `uiliannn/VItoriaBr` another, both on the same machine; I reported those separately.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Zettrox/ztrx#83
No description provided.