Skip to content

Banjo-Tooie reaches controllable gameplay; CPU 274 → 540 MIPS; FPS overlay - #19

Merged
matthewcodergamer merged 66 commits into
mainfrom
claude/xbox-360-emulator-optimization-74g72w
Oct 29, 2026
Merged

matthewcodergamer merged 66 commits into
mainfrom
claude/xbox-360-emulator-optimization-74g72w

Conversation

@matthewcodergamer

Copy link
Copy Markdown
Owner

What this does

  • Banjo-Tooie reaches gameplay. A deterministic headless run with controller input goes through the title screen and main menu into Spiral Mountain, and the player can move Banjo there. PROGRESS.md has the full input script.

  • Fixes that got it there:

    • The swap stall at ~58B instructions is fixed.
    • The command processor now honors PM4 type-3 predication, as Xenia does.
    • The fiber scheduler bounds how far a busy thread can fall behind.
    • The HIR interpreter now polls for interrupts.
    • A thread's exit no longer leaks its kernel-service status into the next thread.
  • XAM services, ported from Xenia:

    • XamShowMessageBoxUI: headless preset answer, or a player dialog in the browser.
    • The achievement enumerator, built from the title's XDBF table.
    • XexGetProcedureAddress and XamContentAggregateCreateEnumerator.
    • XamTaskSchedule.
    • Enumerators are now real guest X_KENUMERATOR objects.
  • CPU speed (step 1, in progress). Measured over Banjo's first 30B instructions:

    Change MIPS
    Baseline 274
    No per-call PPCContext zeroing 355
    Ring-buffer call history and cached epilogue check 387
    Compiled-only translation tier 540
    • Compiled-only tier: an evicted translation keeps its compiled code and runs again without being re-translated or recompiled. Cache misses drop from 20.6k to 2.7k.
    • The translation cache budget is now checked against real arena bytes.
    • The JIT emits native vector compares.
  • FPS overlay in the browser player, toggled with the backtick key. It shows:

    • current FPS, 60 s average FPS and 1% low;
    • frame time;
    • CPU emulation vs GPU rendering time;
    • frames submitted vs presented.

    The player used to present at most 2 FPS; it now presents every new frame.

  • run-title tooling:

    • --press, --stick and --dialog-button for input;
    • --frame-at to save frames mid-run;
    • per-thread state, wasm memory and cache stats in the JSON report.
  • Docs: a design for record-to-recompile as a future opt-in option (docs/recompile/RECORD_TO_RECOMPILE.md).

Not done yet

  • Gameplay is still far from real time in the browser:
    • Frames come from the CPU software renderer; the WebGPU renderer is not done yet.
    • CPU speed work continues. The per-call path is now the largest cost.
  • No audio yet (XMA).

Tests

  • Regression runner: 61 pass, 9 fail. The 9 failures are pre-existing foundation tests and are unchanged by this PR.
  • Xenia PPC instruction suite with the JIT forced: pass (1398 tests).
  • Guest JIT differential test: pass (2920 cases).
  • New tests:
    • test-xenos-predication.mjs
    • test-perf-overlay.mjs
    • Kernel-services sections for the new XAM calls.

No game files, decrypted XEX or game-derived shaders are included.


Generated by Claude Code

claude added 30 commits October 14, 2026 21:36
…n infinite waits

- JIT: a segment resumed through RESTORE no longer re-adds its instruction
  count (kLocResumed), and POLL clears the flag so the branch target counts.
- Infinite kernel waits with every fiber blocked advance guest idle time
  (up to 10 s) instead of reporting a deadlock immediately, so timer-driven
  threads can run.
- run-title --det-every N prints a kernel-call determinism trace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
The CP trace now prints the ring words each kick appends, to find what
D3D's command-stream worker queues ahead of the vblank-paced swaps.
PROGRESS.md records the current Swap-stall findings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Port of Xenia CommandProcessor::ExecutePacketType3: a packet with header
bit 0 set runs only when (bin_select & bin_mask) != 0, and a predicated
XE_SWAP never runs. D3D predicated tiling replays one IB per screen bin,
so bin-specific packets (including D3D's GPU-to-CPU deferred callback
requests) ran once per bin. Each extra callback queued another frame on
D3D's worker thread, the ring backlog grew faster than vblank-paced swaps
drained it, and Banjo-Tooie stopped presenting at ~58B instructions.

With the fix Banjo-Tooie runs to 90B instructions and keeps presenting
(VdSwap 2551, previously stuck at ~1542). New regression test
test-xenos-predication.mjs fails before the fix and passes after.
The WPTR trace also prints guest time and vblank count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
… mid-run

--press FROM:TO:BUTTONS holds gamepad 0 buttons between two instruction
counts (millions); --frame-at M1,M2:PREFIX saves PREFIX-M.png when the
run passes each count. Used to verify Banjo-Tooie responds to input.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Banjo-Tooie calls XamShowMessageBoxUI after Start is pressed on the title
screen; the call was unimplemented and stopped the run. Port of Xenia
xam_ui.cc headless path: the focused button is the result, bracketed by
XN_SYS_UI notifications, completed synchronously or through the
overlapped (ninth, stack) argument. The title, text and buttons go to the
debug log and stderr (R360_MESSAGE_BOX). Kernel services test covers the
synchronous and overlapped forms. (Test run pending the current rebuild.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Banjo-Tooie's offline notice offers 'Connect to Xbox LIVE' (focused) and
'Continue playing offline'; Xenia's headless choice of the focused button
loops back into the sign-in UI. As in Xenia's MessageBoxDialog, the
player now chooses: with r360_xam_dialog_set_host_answers(1) an
overlapped call returns ERROR_IO_PENDING and completes on
r360_xam_dialog_answer, and a synchronous call blocks its thread (not a
deadlock) until then. The browser runner shows the dialog with the
title's buttons; run-title --dialog-button N answers headlessly. Kernel
services test covers both forms. (Test run pending the current rebuild.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
A run ends when the title's primary thread calls ExTerminateThread, as in
Xenia (Emulator::WaitUntilExit). R360_PRIMARY_EXIT records why, for the
Banjo-Tooie exit after 'Continue playing offline'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Banjo-Tooie creates an achievement enumerator after 'Continue playing
offline'; the call was unimplemented. Port of Xenia's
XStaticAchievementEnumerator: the XDBF resource named by the title id
(Xenia KernelState::title_xdbf, parsed by Xenia's own xdbf_utils.cc, now
in the build), English strings, X_ACHIEVEMENT_DETAILS records followed by
the requested strings. XexGetModuleSection shares the resource lookup.
Kernel services test covers sizing, argument checks and an empty table.
(Test run pending the current rebuild.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
xenia/xbox.h defines X_STATUS_* macros that collide with the kernel
service constants, so the achievement table is read by xam_xdbf.cpp
(Xenia xdbf_utils) and handed over as plain structs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
A service that sleeps, waits with a timeout, yields or idles switches to
other guest fibers in the middle of its dispatch. Their kernel calls
overwrite the shared per-call state (g_status, g_handled, g_wait, caller
registers), and the resumed call returned with another thread's status.
In Banjo-Tooie a thread's ExTerminateThread left g_status = terminal
while another thread slept in KeDelayExecutionThread; that thread then
'stopped' and the run ended right after the offline notice. Each switch
inside a service now saves and restores the call's state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
…pers

The save/restore wrappers around mid-call fiber switches crashed the core
(out-of-bounds access in KeDelayExecutionThread at ~51.5B). Use the
fiber system's own mechanism instead: g_status, g_handled, g_wait and the
caller registers are R360_FIBER_LOCAL, swapped with each fiber and saved
around interrupt callbacks, so another thread's kernel calls no longer
overwrite a call that is sleeping or waiting. (Banjo-Tooie verification
run pending.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
The fiber-local version still crashes at ~51.6B (out-of-bounds in
KeDelayExecutionThread), like the save/restore wrappers. Narrowing down
which preserved field causes it: the wait record and caller registers go
back to shared state for this test build. (Verification run pending.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Making the per-call kernel state fiber-local (or saving and restoring it
around switches) crashed Banjo-Tooie at ~51.6B inside WaitObjects, so it
is shared again. The bug actually observed is narrower: a thread's
ExTerminateThread leaves g_status = terminal, and the fiber that resumes
next, in the middle of a sleep, returned it as its own. FinishGuestThread
Fiber now resets the status and handled flag when it retires the thread.
(Verification run pending.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Banjo-Tooie looks up XamContentAggregateCreateEnumerator (XAM ordinal
0x279) at run time after the offline notice. Ports from Xenia:
- XexGetProcedureAddress: for xboxkrnl/XAM, one guest trampoline per
  export (KernelModule::GetProcAddressByOrdinal), registered as an import
  thunk so calls reach the same service dispatcher as static imports;
  unimplemented exports still fail closed when called. Name lookups and
  executable exports report the entry point as not found.
- XamContentAggregateCreateEnumerator: XCONTENT_AGGREGATE_DATA items for
  the running title's HDD packages.
Kernel services test covers both. (Test and title runs pending.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Banjo-Tooie calls XamGetPrivateEnumStructureFromHandle on its aggregate
content enumerator. As in Xenia XEnumerator::Initialize, every XAM
enumerator now has a guest X_KENUMERATOR (app id, open/close messages,
user, items per enumerate, flags) with each enumerator's Xenia values;
the aggregate one carries X_KENUMERATOR_CONTENT_AGGREGATE (XEN signature,
handle). XamGetPrivateEnumStructureFromHandle returns it and takes a
reference. Kernel services test covers the layout. (Test and title runs
pending.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Banjo-Tooie schedules a XAM task after the offline notice. Port of
Xenia xam_task.cc: the callback runs with the message on a new guest
thread (executable stack size, 16 KiB minimum) and the task handle is
12345; XamTaskShouldExit returns 0. Kernel services test covers both.
(Test and title runs pending.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
run-title --dialog-button answered the message box at the next host
slice, so the other guest threads ran a wall-clock-dependent number of
instructions meanwhile and runs diverged after the dialog (Banjo-Tooie's
cutscene stall came and went between runs). r360_xam_dialog_set_auto_
answer gives the answer inside the call; the browser keeps the
interactive dialog. Kernel services test covers it. (Test run pending.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
PickTarget always ran the least-run eligible fiber. In Banjo-Tooie's
opening cutscene a timer thread loops Sleep(0) around a critical section
the main thread needs; the timer and idle worker threads stayed far
below the main thread's instruction count, so every pick went to them
and the main thread waited ~50B instructions for the lock (frames stop).
As CFS bounds unfairness, an eligible fiber more than eight quanta ahead
of the least-run one is pulled back to that bound, so a busy thread gets
a turn within a bounded number of the others' instructions, as it would
on its own hardware thread. (Suite and title runs pending.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
After the opening cutscene Banjo-Tooie's main thread loops over its
object table until another thread clears a slot. The function had been
called only once, so it ran in the HIR interpreter, which polled only at
guest calls: no interrupts, no preemption and no host slices for 10B
instructions, and the thread it waits for never ran. Interpreted code now
polls every 4096 instructions, as the guest JIT polls on backward
branches. (Suite and title runs pending.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
claude and others added 29 commits October 17, 2026 05:55
- Non-tail calls that hit the translation cache skip the owner/epilogue
  classification; the full resolver is out of line.
- The HIR interpreter (ExecuteBuilder) is no longer inlined into the
  per-call executor entry.
- __restgprlr register restores read the save area in one access.
- Translation cache maps use a cheap 64-bit key hash (libc++ hashed the
  key byte-wise on wasm32).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
The memo hits 99.9% of lookups and is validated by two epochs (cache map
changes and executable-page rewrites). -O3 is ~4% faster than -O2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
A function entered once that loops (a thread's main loop, a wait loop)
never reached the call-count threshold and was interpreted for its whole
life; past the first 30B instructions of Banjo-Tooie 2.4B HIR instructions
ran in the interpreter, over half the host time. Interior (tail-call) entries
were also always interpreted.

- The interpreter hands a run over to compiled code at a block head after
  1000 interpreted instructions (compiling it then), and at once for an
  interior entry of a hot function. Only for functions whose HIR values are
  all block-local, so every block head is an exact entry point.
- Generated functions start at a requested dispatcher segment.
- A nested call's first run after a translation miss now runs from its new
  cache entry (not inside Assemble), so it has a JIT slot too.
- test-guest-jit-osr.mjs: a loop called once moves to compiled code with the
  interpreter's results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
- The generated code's fault flag and failure record are fiber-local. A
  guest interrupt (RunGuestInterrupt swaps the fiber-local section) whose
  callback failed a wait left the flag set, and the interrupted compiled
  code's next fault check failed with the interrupt's blocker (Banjo-Tooie,
  51.5B instructions, a new thread's first call). A nested compiled run
  also restores its caller's flag.
- The deferred first-run flags are fiber-local (a fiber can switch while a
  non-deferred translation runs guest code).
- JitTakeFunction records the interpreter's OSR slot only for runs it sends
  to the interpreter; a stale record could match a later builder at the
  same address.
- r360_jit_set_osr (bit 0 long runs, bit 1 interior entries) and run-title
  R360_OSR=mask, --trace-from-minstr N for bisecting.
- test-node-wasi-safe.mjs: Node 22's WASI fd_write fast-API callback can
  start a GC that crashes V8 (SIGSEGV); the JIT and PPC suite tests turn
  fast API calls off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
- r360_trace_verbose_from(millions): verbose runtime tracing switched on
  inside the core at an instruction count (run-title --trace-from-minstr),
  since a stuck guest may never reach a host slice to turn it on.
- r360_jit_diag / run-title R360_DIAG=1: a line every 2^27 guest
  instructions from the compiled-code poll with the scheduler state (fiber
  states, wake deadlines, kernel wait object/reason/caller per thread).
- Failed cached runs and failed OSR runs are traced (verbose).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
- webgpu_backend.cpp: the core records a command stream (as Xenia's
  VulkanCommandProcessor records a DeferredCommandBuffer). Shared memory is
  a port of Xenia's SharedMemory: RequestRange uploads the runs of pages not
  valid on the GPU; uploaded pages arm the sparse memory GPU write watch and
  stay valid while their write generation is unchanged; RangeWrittenByGpu
  for resolves.
- render360-webgpu-backend.mjs replays the stream: a 512 MiB shared memory
  buffer (or the adapter's largest), uploads through a staging buffer and
  copyBufferToBuffer in command order.
- tools/browser-test.mjs runs browser-side tests in headless Chromium with
  WebGPU (SwiftShader).
- test-webgpu-shared-memory.mjs (core logic, Node) and
  test-webgpu-shared-memory-browser.mjs (GPU readback matches guest memory,
  one page re-uploaded after a CPU write).
- docs/gpu/WEBGPU_BACKEND.md: the port plan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
Port of Xenia's Vulkan pipeline cache shader modifications, index
conversion, system constants and float constant packing into the GPU
command stream (r360_gpu_set_mode). run-title.mjs gains --gpu-capture
to slice a stream for offline replay (written to a local path only),
and the JIT gains compile-sequence exclusion for bisecting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
render360-webgpu-backend.mjs now replays the whole command stream: Xenia
SPIR-V translated to WGSL by Naga, bind group layouts from the WGSL
declarations (Xenia's descriptor sets as groups 0-3), pipeline state
from the WebGpuPipelineDescription, render targets keyed by EDRAM base,
constants in a dynamic-offset uniform ring and indices in an index ring.
Draws use the D3D12 viewport convention (WebGPU clip space has Y up) and
keep back-face stencil state.

test-webgpu-replay-capture-browser.mjs replays a local capture in
headless Chromium (served from a data root outside the repository; it
skips without one). A Banjo-Tooie menu capture replays all 1390 draws
with no validation errors; textures are placeholders until the texture
cache port lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
webgpu_textures.cpp ports Xenia's TextureCache bindings and keys with
VulkanTextureCache's host formats and LoadTextureDataFromResidentMemoryImpl:
Xenia's own texture_load_* compute shaders (sent once in the stream,
converted by Naga) untile and convert from the shared memory buffer, then
the scratch buffer is copied into WebGPU textures. Fallbacks where WebGPU
lacks Vulkan's formats: S3TC decompression, 16-bit packed texels expanded
to RGBA8, 16-bit normalized to float16, separate signed textures. A
Banjo-Tooie menu capture loads all 144 textures and renders them.

Resolves follow VulkanRenderTargetCache's host render target path: the
owners of the source tiles are dumped into an EDRAM buffer in Xenia's
layout (WGSL port of XeEdramOffsetBytes), Xenia's resolve copy shaders
write shared memory, and resolve clears clear the host render targets.
Swaps carry the front buffer texture. With the software rasterizer off,
draws still reach the WebGPU recorder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
…gging

- render360-webgpu-play.mjs: ?gpu=xenos runs the page on the WebGPU
  backend; the software renderer does no work and the swapped front
  buffer is presented from the GPU.
- r360_gpu_set_mode resets shaders, pipelines, textures, load/resolve
  shaders and shared memory so a new stream consumer starts consistent.
- R360_JIT_LOG_SEQ / R360_JIT_LOG_DUMP print the guest function, HIR and
  wasm of chosen compile requests (naming a bisected miscompile).
- PROGRESS.md: step 2 section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
The EDRAM dump shader used the reserved WGSL word 'unorm'. With it
renamed, a menu capture recorded with the software renderer off replays
with 6 EDRAM dumps, 6 resolves and 8 clears and no validation errors:
the predicated-tiling strips assemble into the full front buffer.

Swaps now carry the front buffer's host swizzle (VulkanTextureCache::
RequestSwapTexture) and the present shader applies it. The JIT gains
r360_jit_set_reject_tail (R360_JIT_REJECT_TAIL) to isolate a tail-call
miscompile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
r360_gpu_set_mode bit 1 (run-title R360_GPU_DEBUG) logs resolve
rectangles, offsets and window offsets and sampled draw viewports; the
capture replay test can compare the EDRAM buffer with the render target
(R360_DEBUG_EDRAM). Used to locate a 32-pixel horizontal offset in the
resolved front buffer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
The overlay now judges guest frames (VdSwap presents/s):
- game FPS, 60 s average and 1% low, stutters over 50 ms per minute;
- emulation speed (100% + headroom when the guest idles, else game FPS/30),
  guest MIPS and the interpreted share;
- CPU ms per guest frame and GPU ms per frame (WebGPU submit to
  completion);
- a frame-time graph with 30 FPS and 50 ms lines and a PASS / not met
  verdict for the bar (avg >= 30, 1% low >= 25, speed >= 100%, <= 1
  stutter/min over >= 10 s).
L downloads a once-a-second JSON log with device details (UA, cores,
memory, GPU adapter) for comparing devices. The core exports
r360_perf_counter (guest and interpreted instructions) and
r360_fiber_idle_ms; run-title reports the same in a perf block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
How the project works, its honest status, the hard rules, locking down
the public test-games repository, and the native iOS app plan: native
core (pthread baton fibers, interpreter only), XcodeGen project,
wgpu-native or Metal renderer, persistent translation cache, optional
JIT detection, entitlements to verify, Wi-Fi game import with resume,
telemetry, and per-device 30 FPS reporting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3e1c533TFYvFAP78LRa6o
… game server

- xenia-ppc-sources.sh: one source list shared by the wasm and native builds
- native/build-native.sh: clang build of the same sources + overlays for
  macos-x86_64/arm64 and ios-arm64; package core merged with r360pkg_ exports
- guest_fibers.cpp: native guest threads as pthreads with a baton (same
  scheduler policy as the Asyncify fibers)
- pointer-carrying r360_* exports widened to uintptr_t (wasm32 ABI unchanged)
- native/src/native_title.cpp: C++ port of handoffDefaultXex boot path
- native/tools/run_title.cpp: native headless runner
- tools/serve-games.py: Range-capable game server for the iOS app
- ios/: XcodeGen project skeleton (work in progress)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Memory::LookupVirtualMappedRange: no MMIO handler on the portable host
  (wasm read zeros at 0x20; native faulted)
- incremental native rebuilds with R360_SKIP_OVERLAYS=1
- ios/Render360: SwiftUI app (library, Files/AirDrop/Mac import with Range
  resume, Metal frontbuffer presenter capped at 30 FPS, touch + GameController
  input, PerfStats port, breadcrumbs, memory guard, signing expiry)
- tools/telemetry-server.py: phone telemetry -> /status on the Mac

Measured (2018 MBP, deterministic 1000, interpreter only): Banjo-Tooie
5B instructions, 132 VdSwap frames at 1280x720, 9.0 MIPS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- iOS core: stat64/JIT write-protect fixes for the iPhoneOS SDK
- boot exactly once per process (the play view started the core twice)
- overlay shows guest instruction/frame progress while booting
- launch-time test hooks (R360_AUTOPLAY, R360_TELEMETRY)
- docs/IOS_APP.md: build, sign, install, import, telemetry, limits

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…~2x native MIPS)

Two std::map lookups per GPU memory word were ~14% of a native Banjo-Tooie
run. 2018 MBP, deterministic 1000, 3B instructions: 19.2 MIPS (was ~9).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ation

native/gpu/xenos_wgpu.cpp ports render360-webgpu-backend.mjs to wgpu-native:
Xenia's SPIR-V goes to wgpu directly (bind group layouts from SPIR-V
reflection), texture-load/resolve shaders keep their push constants
(immediates). EarlyFragmentTests is stripped (wgpu rejects the capability).

run-title --gpu out.png replays the recorded stream through wgpu/Metal and
saves the swapped front buffer; --frame out.png saves the software frame.

2018 MBP (Iris Plus 640), Banjo-Tooie, deterministic 1000, 3B instructions:
68 swaps, 0 GPU errors, every texture load and resolve succeeds; CPU 26.5
MIPS with the software rasterizer off (19.2 with it). Not yet correct: the
core's recorder skips rectangle-list draws (no geometry shaders in WebGPU),
so the XBLA splash shows its white background without the logo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Recorder: rectangle-list draws are shaded on the CPU (Xenia
  ShaderInterpreter, as the software renderer) and drawn with a pass-through
  vertex shader + the game's pixel shader (WebGPU has no geometry shaders);
  host clip-space transform as SpirvShaderTranslator's vertex epilogue.
- Native backend: pass-through VS matches the pixel shader's interpolation
  qualifiers; CPU-shaded vertex ring reused only after a submit.
- Banjo-Tooie XBLA splash now renders on the GPU path (77/77 draws, 0 errors);
  still shifted one 32x32 tile (resolve dest 0x1000 past the swap texture).
- iOS: GPU renderer via a CAMetalLayer (falls back to software frames);
  wgpu-native linked statically (the dylib broke launch on the phone).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app now uses the website's own index.html, styles, library, details,
settings, touch controller and HUD (bundled at build time, served from a
custom scheme), so it matches the website one-to-one. runtime/native-host.js
(inactive on the website) routes Play, input, pause/resume and imports to
the native bridge: games are copied into the app's storage by the native
document picker and inspected by the native core (r360_native_inspect), and
the native core runs the title on the Metal GPU renderer behind the page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app is fully native again: library, game details, boot card, touch
controller (Pause, Back/Start, LB/RB, LT/RT, Move pad, A/B/X/Y in the
website's colors and positions) and HUD are SwiftUI copies of the website's
screens. Box art from x360db by title id (as library/cover-resolver.js);
title/media id from r360_native_inspect. The web bridge is reverted (it hid
the game behind the page's black background and allowed text selection).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sy background apps)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port of xenios-jp/XeniOS src/xenia/hid/touch/touch_layout_ios_defaults.cc
(BSD-3): same normalized frames for Pause, Back/Start, LB/RB, LT/RT,
A/B/X/Y and the move stick (deadzone 0.14, d-pad ring, double-tap forward =
left stick click, hold B = right stick click) plus the full-screen look
swipe zone on the right stick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mpilation prerequisite)

iPhone 11, free team, increased-memory-limit only: a 4.50 GiB PROT_NONE
reservation succeeds, so XenonRecomp-style flat guest memory (base + address)
is possible without extended-virtual-addressing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The native build maps the guest address space as Xenia's Memory does: one
reservation (4 GiB + 64 KiB) with plain virtual memory below 0xA0000000 and
one named 512 MiB physical object mapped at the 0xA0000000 / 0xC0000000 /
0xE0000000 views; the E0 view's 4 KiB physical offset is applied on the CPU
side as XeniOS does on 16 KiB-page hosts (host_address_offset). Every guest
page now has a fixed host address (r360_flat_guest_base() + address), the
layout XenonRecomp-generated code needs. The page table, protections and
GPU/executable watches are unchanged; the browser build is unaffected.

Verified: Banjo-Tooie, deterministic 1000, 3B instructions: 70 frames, the
same frame as the sparse layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iPhone 11: Banjo-Tooie boots and runs on the flat layout (3.15B
instructions, 2840 frames, Metal renderer).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matthewcodergamer
matthewcodergamer merged commit 42c6711 into main Oct 29, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants