From 3f509ebc5c8445ac8a8cba08a76690c3b15c90e6 Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Sun, 5 Jul 2026 14:16:12 +0200 Subject: [PATCH] [iterate-4C] --ui: make threaded GPU the default (was opt-in XENIA_UI_GPU_THREAD) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Measured ~5× faster boot under --ui (~12 → ~63 MIPS) by moving the per-frame PM4 drain (draws, YUV texture decode, resolves) + UI publish off the emulation thread onto the GPU worker — canary's async-command-thread model. User-confirmed visuals identical to the inline path (splash + intro video render correctly). Flip the default: `--ui` now uses the threaded GPU backend. Opt back to inline with `--gpu-inline` or `XENIA_UI_GPU_INLINE=1`. The deterministic golden path already passes `--gpu-inline`, so goldens are unaffected (n2m re-checked MATCH). `XENIA_UI_GPU_THREAD` retained as a no-op alias. Headless default (M1.9 threaded) unchanged. Note: threading the GPU only helps GPU-bound phases (boot). The intro VIDEO is CPU-bound on multi-threaded 720p-YUV software decode (FP-arith-heavy, mostly JIT fallback), so it stays ~real-video-length; that needs the multi-core / native-FP levers, not GPU threading. --- crates/xenia-app/src/main.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/xenia-app/src/main.rs b/crates/xenia-app/src/main.rs index ba79147..ff7e297 100644 --- a/crates/xenia-app/src/main.rs +++ b/crates/xenia-app/src/main.rs @@ -966,19 +966,23 @@ fn cmd_exec_inner( let v = v.trim().to_ascii_lowercase(); v == "1" || v == "true" || v == "yes" }); - // A.5 — opt-in threaded GPU under `--ui`. Off by default: `--ui` still - // forces the inline backend (the safe, milestone-verified path). When - // `XENIA_UI_GPU_THREAD=1` is set alongside `--ui`, the GPU command - // processing + per-swap UI publish move to the worker thread, freeing the - // emulation thread from the ~12 ms/frame inline PM4 drain. See - // `run_with_ui` (hook install) and `GpuSystem::run_ui_publish`. - let env_ui_thread = std::env::var("XENIA_UI_GPU_THREAD") + // A.5 — threaded GPU under `--ui`, now the DEFAULT. The GPU command + // processing + per-swap UI publish run on the worker thread, freeing the + // emulation thread from the ~12 ms/frame inline PM4 drain — measured ~5× + // faster boot under `--ui` (~12 → ~63 MIPS), visuals confirmed identical to + // the inline path. See `run_with_ui` (hook install) and + // `GpuSystem::run_ui_publish`. Opt back to the inline backend with + // `--gpu-inline` or `XENIA_UI_GPU_INLINE=1` (the deterministic golden path + // already uses `--gpu-inline`, so goldens are unaffected). `XENIA_UI_GPU_THREAD` + // is retained as a no-op alias for back-compat. + let env_ui_inline = std::env::var("XENIA_UI_GPU_INLINE") .ok() .is_some_and(|v| { let v = v.trim().to_ascii_lowercase(); v == "1" || v == "true" || v == "yes" }); - let ui_threaded = ui && env_ui_thread; + let ui_inline_optout = gpu_inline || env_inline || env_ui_inline; + let ui_threaded = ui && !ui_inline_optout; let force_inline = gpu_inline || env_inline || (ui && !ui_threaded); let force_thread = gpu_thread || env_thread || ui_threaded; let use_threaded = if force_inline {