Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
5f3aa16
Make guest instruction clock deterministic across JIT rewinds; idle o…
claude Oct 14, 2026
4cb1e0f
Trace ring words per WPTR kick; update progress report
claude Oct 14, 2026
971ad22
Honor PM4 type-3 predication on tiling bins
claude Oct 16, 2026
d483f05
run-title: --press to hold gamepad buttons, --frame-at to save frames…
claude Oct 16, 2026
799aff9
Progress report: Swap stall fixed, Rare intro renders
claude Oct 16, 2026
6a4d2f6
XAM: XamShowMessageBoxUI (Xenia headless semantics)
claude Oct 16, 2026
8589f71
Kernel services test: zero the overlapped block for XamShowMessageBoxUI
claude Oct 16, 2026
ce95227
XamShowMessageBoxUI: let the player answer (host dialog mode)
claude Oct 16, 2026
e567258
Log the primary thread's exit (code, thread, caller stack)
claude Oct 16, 2026
87a20ec
XAM: XamUserCreateAchievementEnumerator over the title's XDBF table
claude Oct 16, 2026
c680146
Build fix: parse XDBF in its own translation unit
claude Oct 16, 2026
8e4c8e2
Build fix: XamUserCreateAchievementEnumerator flags argument
claude Oct 16, 2026
83e2241
Build: count xam_xdbf.cpp in the expected compile results
claude Oct 16, 2026
614a561
run-title: pass R360_PRIMARY_EXIT and R360_MESSAGE_BOX through
claude Oct 16, 2026
904612b
Log why a guest thread's exit ends a run (R360_FIBER_STOP)
claude Oct 16, 2026
517cf68
Trace guest thread exits and fiber starts
claude Oct 16, 2026
05bc8bf
Kernel services: keep a call's state across mid-call fiber switches
claude Oct 16, 2026
41d25d1
Kernel services: per-call state is fiber-local, not save/restore wrap…
claude Oct 16, 2026
bbcc073
Bisect: only the service status is fiber-local
claude Oct 16, 2026
09f5d78
Trap report: keep the wasm stack of a core trap
claude Oct 16, 2026
2778065
Thread exit: reset the service status it leaves behind
claude Oct 16, 2026
00d118a
XexGetProcedureAddress and XamContentAggregateCreateEnumerator
claude Oct 16, 2026
c5d592d
XAM enumerators get guest X_KENUMERATOR objects
claude Oct 16, 2026
8870003
XAM: XamTaskSchedule and XamTaskShouldExit
claude Oct 16, 2026
bd608a2
Build fix: XamTaskShouldExit was already implemented
claude Oct 16, 2026
1a25243
Progress: Banjo-Tooie reaches its main menu with controller input
claude Oct 16, 2026
3596c95
run-title: per-thread state in the JSON report
claude Oct 16, 2026
14c139a
Deterministic headless dialog answers
claude Oct 17, 2026
ebb4174
Guest fiber scheduler: bound how far a busy thread can fall behind
claude Oct 17, 2026
ea3f534
HIR interpreter polls for interrupts and preemption
claude Oct 17, 2026
5c32177
run-title: --stick to hold the left analog stick
claude Oct 17, 2026
f2f9dff
Progress: Banjo-Tooie reaches gameplay in Spiral Mountain
claude Oct 17, 2026
24eb7fb
Docs: record-to-recompile as a future opt-in option
claude Oct 17, 2026
255aacc
Progress: Banjo-Tooie is controllable in Spiral Mountain
claude Oct 17, 2026
2be892a
CPU speed: per-call context fix; native vector compares in the JIT
claude Oct 17, 2026
62dc714
FPS and frame-time overlay in the browser player
claude Oct 17, 2026
a5c48e9
CPU: compiled-only translation tier and cheaper guest calls (387 -> 5…
claude Oct 17, 2026
2f0f075
Merge remote-tracking branch 'origin/main' into claude/xbox-360-emula…
claude Oct 17, 2026
1e7e769
CPU: fast path for cached plain calls (543 -> 642 MIPS)
claude Oct 17, 2026
91c2d7d
CPU: memo translation-cache lookups; build at -O3 (642 -> 665 MIPS)
claude Oct 17, 2026
0f71244
Guest JIT: on-stack replacement into compiled code
claude Oct 17, 2026
a2649c7
Guest JIT: per-thread fault state; OSR bisect switches; test WASI guard
claude Oct 17, 2026
44d8b79
Diagnostics for runs that never return to the host
claude Oct 17, 2026
a36e877
WebGPU backend, stage 1: shared memory (port of Xenia SharedMemory)
claude Oct 17, 2026
a99ef19
WebGPU backend: record draws, pipelines, render targets and swaps
claude Oct 17, 2026
d9a0163
WebGPU backend: replay shaders, pipelines, render targets and draws
claude Oct 17, 2026
24dc36b
WebGPU backend: texture cache, EDRAM resolves and clears
claude Oct 17, 2026
d0c53cb
WebGPU play path (opt-in), state reset on mode change, JIT compile lo…
claude Oct 17, 2026
697ae47
WebGPU resolves verified on a Banjo-Tooie menu capture; swap swizzle
claude Oct 17, 2026
2730502
WebGPU capture debugging: resolve/draw logging, EDRAM comparison
claude Oct 17, 2026
9274379
30 FPS bar: overlay and per-device log
claude Oct 17, 2026
54e10d9
docs: prompt for an agent on the owner's Mac (native iOS app plan)
claude Oct 17, 2026
858290e
Native core build for macOS/iOS (interpreter only), native boot port,…
Oct 17, 2026
e10ff96
Native Banjo-Tooie boot on macOS; iOS app sources; telemetry server
Oct 17, 2026
366a5a9
iOS app builds, signs (free team) and runs on the iPhone 11
Oct 17, 2026
1bfdc10
PROGRESS: native iOS app on the iPhone 11, measured numbers
Oct 17, 2026
8b13494
Cache the last physical range in r360_kernel_gpu_address_to_virtual (…
Oct 17, 2026
b1783fc
Native Xenos GPU backend on wgpu-native (Metal), headless GPU verific…
Oct 18, 2026
5932ad4
Rectangle lists on the GPU path; Metal GPU renderer in the iOS app
Oct 18, 2026
e1578b8
iOS app shows the Render360 website UI over the native emulator
Oct 18, 2026
9e9b889
iOS: native SwiftUI recreation of the website UI; remove the web view
Oct 18, 2026
b815092
iOS: pause the guest while the app is in the background (iOS kills bu…
Oct 18, 2026
5ab870c
iOS: XeniOS touch controls (FPS Compact layout, ported 1:1)
Oct 18, 2026
ad4a911
iOS: probe the flat guest address reservation at startup (static reco…
Oct 18, 2026
1b7e567
Native flat guest memory (Xenia layout) for static recompilation
Oct 18, 2026
f0c156c
Flat guest memory: use vm_map (mach_vm_map is not in the iOS SDK)
Oct 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/xenia-browser-bootstrap-fastlane.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ on:
- 'test-browser-thread-scheduler.mjs'
- 'test-direct-call-sparse-window.mjs'
- 'test-translation-window-consistency.mjs'
- 'test-xenos-predication.mjs'
- 'test-hir-load-offset-addressing.mjs'
- 'test-hir-cache-control.mjs'
- 'test-hir-rotate-left.mjs'
Expand Down Expand Up @@ -268,6 +269,9 @@ jobs:
- name: Verify translations do not depend on decoder-window history
run: timeout 90s node ./test-translation-window-consistency.mjs build/xenia-ppc-bootstrap/xenia_ppc_bootstrap.wasm

- name: Verify PM4 type-3 predication on tiling bins
run: timeout 90s node ./test-xenos-predication.mjs build/xenia-ppc-bootstrap/xenia_ppc_bootstrap.wasm

- name: Verify signed PPC LOAD_OFFSET effective addresses
run: timeout 90s node ./test-hir-load-offset-addressing.mjs build/xenia-ppc-bootstrap/xenia_ppc_bootstrap.wasm

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/xenia-wasm32-bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- 'test-title-gpu-runtime.mjs'
- 'test-direct-call-sparse-window.mjs'
- 'test-translation-window-consistency.mjs'
- 'test-xenos-predication.mjs'
- 'render360-title-gpu-traffic.mjs'
- 'test-xenos-semantic-foundation.mjs'
- 'test-xenos-title-state-foundation.mjs'
Expand Down Expand Up @@ -191,6 +192,8 @@ jobs:
run: node ./test-direct-call-sparse-window.mjs build/xenia-ppc-bootstrap/xenia_ppc_bootstrap.wasm
- name: Verify translations do not depend on decoder-window history
run: node ./test-translation-window-consistency.mjs build/xenia-ppc-bootstrap/xenia_ppc_bootstrap.wasm
- name: Verify PM4 type-3 predication on tiling bins
run: node ./test-xenos-predication.mjs build/xenia-ppc-bootstrap/xenia_ppc_bootstrap.wasm
- name: Verify locked foundations and XEX bring-up
run: |
node ./test-xenia-ppc-translation-probe.mjs build/xenia-ppc-bootstrap/xenia_ppc_bootstrap.wasm
Expand Down
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,21 @@ node_modules/
*.log
build/
upstream/
# Game data never goes in git (owner rule): discs, packages, decrypted images, captures, manifests
*.iso
*.xex
*.xcp
*.god
*.stfs
*.con
*.r360cap
*.gpucap
rexglue-manifest*
/games-local/

# iOS: personal signing values, build products
/ios/Signing.local.xcconfig
/ios/Render360.xcodeproj/
/ios/build/
*.ipa
/logs/
193 changes: 172 additions & 21 deletions PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,189 @@ Branch: `claude/xbox-360-emulator-optimization-74g72w`. Test title: Banjo-Tooie
HIR executor and guest JIT. File loading finishes (`db360.textures.cmp`,
~50 MB, is read in full); 7 title threads run.
- CPU: guest JIT compiles Xenia HIR to WebAssembly. Headless speed is about
180M guest instructions/s (6B instructions in ~62 s, down from 223 s).
- Deterministic headless runs (`run-title --deterministic 1000`): identical
flags give identical results up to at least 4B instructions.
665M guest instructions/s over Banjo's first 30B instructions (see Step 1).
- Deterministic headless runs (`run-title --deterministic 1000`): two
identical runs match through 58.3B instructions (1098 checkpoints, same
frames, draws and GPU packets). Fixed: a JIT segment resumed after an
Asyncify rewind re-added its instruction count, which made the guest clock
depend on host timing.
- Infinite kernel waits with every thread blocked now let guest time pass
(up to 10 s) so timers and vblank can wake threads, instead of stopping as
a deadlock.
- Shader path: Xenia SpirvShaderTranslator → Naga → WGSL. All shaders seen
during loading compile in Chromium WebGPU (SwiftShader).

## Current blocker
At about 58B instructions the main thread blocks inside D3D `Swap` waiting
for a GPU timestamp. D3D's presentation watchdog thread then keeps
re-presenting the previous frame, and those replays rewrite older timestamps.
No new frame is presented after that (VdSwap stops at ~1540). Root cause not
yet confirmed: the open question is why the main thread's target timestamp
is never observed. Runs still diverge slightly past ~58B (kernel-call counts
differ between identical runs), which blocks exact replay of the stall.
## Fixed: Swap stall at ~58B instructions
Root cause: the command processor ignored PM4 type-3 predication. D3D
predicated tiling replays each frame's command buffer once per screen bin,
and packets meant for one bin (including D3D's GPU-to-CPU deferred callback
requests) ran in every pass. Each extra callback made D3D's worker thread
queue another frame, the ring backlog outgrew the vblank-paced swaps, and
the main thread waited forever for its frame. Ported Xenia's check
(`ExecutePacketType3`: skip predicated packets when `bin_select & bin_mask`
is 0, never run a predicated swap).

After the fix (deterministic headless runs):
- 90B instructions: 2551 frames (VdSwap), was stuck at ~1542.
- 120B instructions: 3067 frames; the title polls the controller every
frame (XamInputGetState 4056 calls by 90B, was 20).
- Frame at 61B: the Rare logo intro renders (software renderer).

## Verified: title screen, input and main menu
Headless deterministic run (`run-title --deterministic 1000`), software
renderer, controller input injected with `--press`:
- 61B instructions: Rare logo intro.
- 80B: title screen ("PRESS START TO PLAY") over a moving 3D flythrough.
- Start at 80B: the title asks "Gamer profile not online" (offline profile);
the player's answer is passed back (`--dialog-button 1` = "Continue
playing offline"; in the browser the page shows the dialog).
- 82B: main menu, Banjo's room, rendered in 3D.
- 85B: "Trial game" notice (the default license is trial, as in Xenia).
- 90B: "PRESS A TO PLAY THE GAME"; frames change every second and the run
reaches its instruction limit with no blocker.

Fixed on the way (each with a kernel services test):
- XamShowMessageBoxUI (headless focused button, or the player's answer).
- XamUserCreateAchievementEnumerator (title XDBF via Xenia xdbf_utils).
- XexGetProcedureAddress (kernel export trampolines),
XamContentAggregateCreateEnumerator, XamGetPrivateEnumStructureFromHandle
(guest X_KENUMERATOR objects), XamTaskSchedule.
- A thread's exit left the kernel service status at "terminal" and the next
thread resuming mid-sleep returned it, ending the run.

## Verified: in-game in Spiral Mountain
Same headless run, continued: A at "PRESS A TO PLAY THE GAME" starts the
opening cutscene (rainy night, "B SKIP"); B skips it, and by 108B the game
is in Spiral Mountain (first level) with the HUD (health honeycombs), the
"SPIRAL MOUNTAIN" title and in-game dialogue; frames keep changing to the
115B instruction limit (3268 frames presented).

Two scheduler bugs blocked it (single host thread running all guest
threads as fibers):
- Least-run-first scheduling starved the busy main thread: a timer thread
looping Sleep(0) around a critical section kept winning, and the main
thread waited ~50B instructions for the lock. Lag is now bounded (8
quanta), as CFS bounds it.
- The HIR interpreter polled for interrupts and preemption only at guest
calls. A function called once that loops waiting for another thread ran
10B instructions without letting that thread run. It now polls every 4096
instructions, as the guest JIT polls on backward branches.
Headless message-box answers are now given inside the call
(`--dialog-button`), so runs no longer depend on host timing.

Known visual issue: Banjo's own model renders incompletely (small,
fragmented); the level, HUD and other characters render.

## Verified: player control in gameplay
Continuing the same run: A clears the Bottles dialogue (116-120B), then the
left stick held forward (`--stick 122000:126000:0:1`) walks Banjo along the
path in Spiral Mountain: the camera follows him past Bottles (124B) and by
127B he has reached the boulder pit, which triggers the next dialogue.
Frames keep changing to the 127.5B instruction limit (3607 frames).

## Step 1: CPU speed (in progress)
Benchmark: Banjo-Tooie, first 30B guest instructions headless
(`run-title --max-minstr 30000 --render-from-minstr 999999 --deterministic
1000`), same container, Node 22. MIPS = guest instructions per second.

| Change | MIPS | Cache misses |
| --- | --- | --- |
| Baseline (start of step 1) | 274 | — |
| No per-call `PPCContext` zeroing | 355 | 19.6k |
| Native vector compares in the JIT | 347 | — |
| Flat executable-page generation table; guest function object only on a miss | 355 | 19.6k |
| Ring-buffer call/stack history (was a 32-entry shift per call); cached epilogue signature per tail target | 387 | 20.6k |
| Compiled-only tier: an evicted translation keeps its compiled code (when it holds no HIR pointers) and runs again without retranslating or recompiling | 503–543 | 2.7k |
| Small fast path for plain calls that hit the cache; interpreter kept out of the per-call entry; one read for `__restgprlr` register restores; cheap 64-bit key hash | 642 | 2.7k |
| Memo of cache lookups (99.9% hit; neutral); build at `-O3` instead of `-O2` | 663–671 | 2.7k |

What the profile showed: 74.5M guest calls in 30B instructions. The
translation cache (192 MiB of HIR) holds ~1000 functions, fewer than one
frame touches, so per-frame functions were evicted and retranslated and
recompiled 100+ times each. The JIT's function table only grows, so every
recompile also leaked a module. The compiled-only tier fixes both. Only
0.11% of instructions are interpreted (interior entries and cold code).
The cache budget is now checked against real arena bytes (Xenia's `Arena`
chunks), not an estimate. Wasm memory at 30B: 668 MiB.

Benchmark noise between identical runs is about ±4%.

Next: cut the per-call path (JIT → resolver → cache → executor → JIT), which
is now the largest cost: 74.5M guest calls go through ~10 host frames each,
all instrumented by Asyncify for guest-thread fibers.

## Step 2: WebGPU renderer (in progress)
A port of Xenia's Vulkan backend (docs/gpu/WEBGPU_BACKEND.md).

- **Core side:** records a command stream.
- **Replay:** `render360-webgpu-backend.mjs` replays it into WebGPU.
- **Shaders:** Xenia's SPIR-V shader translator, converted to WGSL by Naga.
- **Vertex fetch:** read from a 512 MiB shared memory buffer.
- **Texture cache:** a port of `TextureCache`/`VulkanTextureCache`. Xenia's own texture load compute shaders do the untiling and format conversion.
- **Resolves:** the host render targets owning the tiles are dumped into an EDRAM buffer. Xenia's resolve copy shaders then write shared memory.

Measured on a Banjo-Tooie main menu capture (2 frames; headless Chromium, SwiftShader):

| Stage | Draws replayed | Validation errors | Result |
| --- | --- | --- | --- |
| Draw path, placeholder textures | 1390 | 0 | geometry only |
| Texture cache | 2400 | 0 | 144 textures loaded, menu art and text correct |

The menu is drawn in screen tiles (predicated tiling) and assembled by
resolves, so the presented frame needs the resolve path.

Opt-in in the browser: `?gpu=xenos` switches the page to the WebGPU play
path. The software renderer then does no work, and each frame presents the
swapped front buffer from the GPU.

## Not yet
- Speed: reaching gameplay takes ~1 hour headless with the software
renderer; the browser needs the WebGPU renderer and faster CPU emulation
to be playable in real time.
- Audio: XMA decoding (Xenia uses FFmpeg's XMA/WMA Pro decoder).
- Banjo's model looks small and partly fragmented in some frames.

## Tests (latest build)
- Regression runner: 59 pass, 9 fail. The 9 failures are pre-existing
- Regression runner: 61 of 70 pass. The 9 failures are pre-existing
foundation tests (fpu/vmx/wasm-backend probes, guest-control, translation
probe) and are unchanged by recent work.
- Xenia PPC instruction suite with JIT forced: pass (1406 functions).
- Guest JIT differential test: pass (73 instructions).
- New: `test-translation-window-consistency.mjs` fails before the window fix
and passes after it.
- Xenia PPC instruction suite with JIT forced: pass (1398 tests, 1406
functions compiled).
- Guest JIT differential test: pass (2920 cases, 73 instructions).
- `test-translation-window-consistency.mjs` fails before the window fix and
passes after it.
- `test-xenos-predication.mjs` fails before the predication fix and passes
after it.

## Not done yet
- Interactive gameplay: not reached.
- Interactive gameplay: reached and controllable headlessly; not yet at a
playable speed in the browser.
- WebGPU real-time renderer: only the shader pipeline is proven; draws,
render targets, textures and resolves are not implemented. Frames come
from the CPU software renderer.
- Audio: XMA decoding not implemented (XMA register window only).

## Next task
Make headless runs fully deterministic past 58B, then reproduce the Swap
stall with a watch on the fence word and dumps of the replayed indirect
buffers, and fix the earliest confirmed cause.
## Native iOS app on the iPhone 11 (2026-10-17)

Native app (`ios/`, SwiftUI + Metal, core from `native/build-native.sh`), signed
with the free Personal Team, installed with `devicectl`; see `docs/IOS_APP.md`.
Interpreter only (no arm64 JIT backend exists yet).

Measured, Banjo-Tooie (host clock, phone telemetry to `tools/telemetry-server.py`):

| Device | Run | Guest instr. | Frames | MIPS | Memory used / free | Thermal |
| --- | --- | --- | --- | --- | --- | --- |
| iPhone 11 | 94 s, then stopped from the app | 867M | 92 (VdSwap, 1280x720) | 11-13 cool, 5.8 once "serious" | 532 MB / 1816 MB | serious |
| 2018 MBP (native run-title, `--deterministic 1000`) | 554 s | 5000M | 132 | 9.0 | – | – |

- Entitlements on the signed app: increased-memory-limit granted (≈2.1 GB
available at start); extended-virtual-addressing is not available to a free team.
- JIT probe on the phone: not available (no StikDebug).
- Game FPS ≈ 1, emulation speed ≈ 1% of real time: the 30 FPS bar is far off.
Limit: CPU (interpreted PPC); gameplay (~127B instructions) is hours away.
- Fixed on the way: the play view booted the core twice; `MMIOHandler` null
lookup (wasm read zeros); ~20 r360_* exports truncated 64-bit pointers.

Next: profile the native interpreter (9-13 MIPS is low even for an
interpreter), then an arm64 backend for JIT-enabled devices. Watch Dogs /
ReXGlue manifest not started.
Loading
Loading