Console CPU instructions: no VirtualQuery for CLZERO into the coherent window #314

Closed
github-bot wants to merge 1 commit from gh-pr/314/head into gh-pr/314/base
Owner

@⁠philkd on GitHub · 2026-11-23 23:07 UTC · original
philkd:clzero-coherent-window → main · +5 −0 · 1 files · 1 commits · closed without merging

Related to #278

What is in it

  • crates/xcl/src/eh.rs: is_writable returns early for a range inside the committed coherent window (+5 lines)

Tested

  • NVIDIA GeForce RTX 5080 (driver 621.01, 32-lane waves), Intel Core i5-12600K, Windows 11 22631, rustc 1.100.0, DXC from Windows SDK 10.0.26100.0; tests in debug, the game in release
  • cargo test --workspace -- --test-threads=4: 652 passed, 0 failed, 40 ignored (SKIPPED: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64)
  • No new test: the change only makes is_writable faster, its answer for the coherent window is the same as before, so a test that fails without it would have to time VirtualQuery
  • Retail title (Series package 1.0.2.1), XCL_NETWORK=0: ~1.5 fps → 30 fps (the title's frame clock) on the first-run and account screens, and it now reaches the Navigation menu. Before the fix, two thread dumps 5 s apart had the main thread in the exception handler under game_scarlett_master.exe+0x4e8aab0 (a CLZERO loop) both times
  • The smoke blocks say gpu: Virtual Desktop Monitor: smoke.ps1 takes the first display adapter, a virtual one on this machine; both runs were on the RTX 5080

Regression run

main:

xcl-smoke v1
commit: 4017f8ff8faaae6007fd83910d230a027dd85a33
gpu: Virtual Desktop Monitor
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 64 (PresentX 64)
presents per 2 s (last 3): 3 2 3
device removals: 0
crashes: 0
peak commit: 15015 MB

PR:

xcl-smoke v1
commit: df1efcd42b7a9f8bb98207b388b12f9eb72a9bcf
gpu: Virtual Desktop Monitor
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1263 (PresentX 1263)
presents per 2 s (last 3): 60 40 7
device removals: 0
crashes: 0
peak commit: 18426 MB

Not tested

  • AMD CPUs (they run CLZERO natively), AMD GPUs, Windows 10, entering the game world

AI use

  • Claude Code with Claude Opus 5.5: found the cause, wrote the change, ran the tests and the regression runs
**@⁠philkd** on GitHub · 2026-11-23 23:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/314) `philkd:clzero-coherent-window` → `main` · +5 −0 · 1 files · 1 commits · closed without merging Related to #278 **What is in it** - `crates/xcl/src/eh.rs`: `is_writable` returns early for a range inside the committed coherent window (+5 lines) **Tested** - NVIDIA GeForce RTX 5080 (driver 621.01, 32-lane waves), Intel Core i5-12600K, Windows 11 22631, rustc 1.100.0, DXC from Windows SDK 10.0.26100.0; tests in debug, the game in release - `cargo test --workspace -- --test-threads=4`: 652 passed, 0 failed, 40 ignored (SKIPPED: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`: no wave64) - No new test: the change only makes `is_writable` faster, its answer for the coherent window is the same as before, so a test that fails without it would have to time `VirtualQuery` - Retail title (Series package 1.0.2.1), `XCL_NETWORK=0`: ~1.5 fps → 30 fps (the title's frame clock) on the first-run and account screens, and it now reaches the Navigation menu. Before the fix, two thread dumps 5 s apart had the main thread in the exception handler under `game_scarlett_master.exe+0x4e8aab0` (a CLZERO loop) both times - The smoke blocks say `gpu: Virtual Desktop Monitor`: `smoke.ps1` takes the first display adapter, a virtual one on this machine; both runs were on the RTX 5080 **Regression run** main: ``` xcl-smoke v1 commit: 4017f8ff8faaae6007fd83910d230a027dd85a33 gpu: Virtual Desktop Monitor title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 64 (PresentX 64) presents per 2 s (last 3): 3 2 3 device removals: 0 crashes: 0 peak commit: 15015 MB ``` PR: ``` xcl-smoke v1 commit: df1efcd42b7a9f8bb98207b388b12f9eb72a9bcf gpu: Virtual Desktop Monitor title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1263 (PresentX 1263) presents per 2 s (last 3): 60 40 7 device removals: 0 crashes: 0 peak commit: 18426 MB ``` **Not tested** - AMD CPUs (they run CLZERO natively), AMD GPUs, Windows 10, entering the game world **AI use** - Claude Code with Claude Opus 5.5: found the cause, wrote the change, ran the tests and the regression runs
On a CPU without CLZERO (Intel), every emulated CLZERO / CLZERO loop checked its target
with is_writable, which calls VirtualQuery. VirtualQuery sizes the region by walking it to
its end, and the coherent window is one committed region of up to 4 GiB: ~40 ms a call
(the cost uma::in_committed_window already notes for DirectStorage). The retail game runs
about 25 emulated instructions a second, nearly all of them CLZERO loops into that window,
and two thread dumps 5 s apart found its main thread in the exception handler both times:
1-2 presents a second.

The coherent window is committed and read-write as a whole, so a target inside it is
writable without asking; readable() and read_committed() already take this path.

Measured on the retail game (RTX 5080, i5-12600K): ~1.5 fps -> 30 fps (the title's frame
clock) on its first-run and account screens, and it reaches the Navigation menu.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:19:49 +00:00
github-bot closed this pull request 2026-11-26 04:19:49 +00:00
Author
Owner

@⁠ghost on GitHub · 2026-11-24 00:05 UTC · original

This now conflicts with main (3516080), and main already has the same check: #306 (a99f64c, "no VirtualQuery at every emulated instruction") added if bytes > 0 && crate::gpu::uma::get().is_some_and(|u| u.in_committed_window(va, bytes)) { return true; } to is_writable in eh.rs. So this PR looks superseded, unless you meant to cover something #306 doesn't.

AI use

  • Claude Code (Claude Opus 5.5) checked the merge and wrote this note; I checked it before posting.
**@⁠ghost** on GitHub · 2026-11-24 00:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/314#issuecomment-7117685543) This now conflicts with `main` (`3516080`), and `main` already has the same check: #306 (`a99f64c`, "no VirtualQuery at every emulated instruction") added `if bytes > 0 && crate::gpu::uma::get().is_some_and(|u| u.in_committed_window(va, bytes)) { return true; }` to `is_writable` in `eh.rs`. So this PR looks superseded, unless you meant to cover something #306 doesn't. **AI use** - Claude Code (Claude Opus 5.5) checked the merge and wrote this note; I checked it before posting.
Author
Owner

@⁠philkd on GitHub · 2026-11-24 09:13 UTC · original

Closing: #306 (merged) takes the same VirtualQuery out of the CLZERO path, and more.

**@⁠philkd** on GitHub · 2026-11-24 09:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/314#issuecomment-7127118173) Closing: #306 (merged) takes the same VirtualQuery out of the CLZERO path, and more.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.